Spaces:
Running
Running
Upload 2 files
Browse files- js/app-controller.js +14 -1
- js/gui-controller.js +40 -1
js/app-controller.js
CHANGED
|
@@ -10,13 +10,17 @@ class ApplicationController {
|
|
| 10 |
this.renderer = null;
|
| 11 |
this.guiController = null;
|
| 12 |
this.configuration = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
// Application state
|
| 15 |
this.state = {
|
| 16 |
atomicNumber: 1,
|
| 17 |
elementSymbol: 'H',
|
| 18 |
displaySettings: {
|
| 19 |
-
particleCount:
|
| 20 |
particleSize: CONSTANTS.PARTICLE_SIZE,
|
| 21 |
opacity: CONSTANTS.PARTICLE_OPACITY,
|
| 22 |
scale: 1.0, // Scale factor for atom size (0.1 to 3.0)
|
|
@@ -37,6 +41,15 @@ class ApplicationController {
|
|
| 37 |
};
|
| 38 |
}
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
/**
|
| 41 |
* Initialize all subsystems
|
| 42 |
* @param {HTMLCanvasElement} canvas
|
|
|
|
| 10 |
this.renderer = null;
|
| 11 |
this.guiController = null;
|
| 12 |
this.configuration = null;
|
| 13 |
+
this.isMobile = this.detectMobile();
|
| 14 |
+
|
| 15 |
+
// Adjust default particle count for mobile devices
|
| 16 |
+
const defaultParticleCount = this.isMobile ? 30000 : CONSTANTS.DEFAULT_PARTICLE_COUNT;
|
| 17 |
|
| 18 |
// Application state
|
| 19 |
this.state = {
|
| 20 |
atomicNumber: 1,
|
| 21 |
elementSymbol: 'H',
|
| 22 |
displaySettings: {
|
| 23 |
+
particleCount: defaultParticleCount,
|
| 24 |
particleSize: CONSTANTS.PARTICLE_SIZE,
|
| 25 |
opacity: CONSTANTS.PARTICLE_OPACITY,
|
| 26 |
scale: 1.0, // Scale factor for atom size (0.1 to 3.0)
|
|
|
|
| 41 |
};
|
| 42 |
}
|
| 43 |
|
| 44 |
+
/**
|
| 45 |
+
* Detect if device is mobile
|
| 46 |
+
* @returns {boolean}
|
| 47 |
+
*/
|
| 48 |
+
detectMobile() {
|
| 49 |
+
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
|
| 50 |
+
|| window.innerWidth <= 768;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
/**
|
| 54 |
* Initialize all subsystems
|
| 55 |
* @param {HTMLCanvasElement} canvas
|
js/gui-controller.js
CHANGED
|
@@ -9,23 +9,62 @@ class GUIController {
|
|
| 9 |
this.gui = null;
|
| 10 |
this.folders = {};
|
| 11 |
this.orbitalControls = new Map();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
}
|
| 13 |
|
| 14 |
/**
|
| 15 |
* Initialize lil-gui interface
|
| 16 |
*/
|
| 17 |
initialize() {
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
this.gui.title('Electron Cloud Visualizer');
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
this.createAtomControls();
|
| 22 |
this.createDisplayControls();
|
| 23 |
this.createCameraControls();
|
| 24 |
this.createCredits();
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
return this.gui;
|
| 27 |
}
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
/**
|
| 30 |
* Create Atom Settings controls
|
| 31 |
*/
|
|
|
|
| 9 |
this.gui = null;
|
| 10 |
this.folders = {};
|
| 11 |
this.orbitalControls = new Map();
|
| 12 |
+
this.isMobile = this.detectMobile();
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* Detect if device is mobile
|
| 17 |
+
* @returns {boolean}
|
| 18 |
+
*/
|
| 19 |
+
detectMobile() {
|
| 20 |
+
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
|
| 21 |
+
|| window.innerWidth <= 768;
|
| 22 |
}
|
| 23 |
|
| 24 |
/**
|
| 25 |
* Initialize lil-gui interface
|
| 26 |
*/
|
| 27 |
initialize() {
|
| 28 |
+
// Adjust GUI width based on device
|
| 29 |
+
const guiWidth = this.isMobile ? Math.min(window.innerWidth - 20, 320) : 450;
|
| 30 |
+
|
| 31 |
+
this.gui = new lil.GUI({
|
| 32 |
+
width: guiWidth,
|
| 33 |
+
autoPlace: true
|
| 34 |
+
});
|
| 35 |
this.gui.title('Electron Cloud Visualizer');
|
| 36 |
|
| 37 |
+
// Close all folders by default on mobile for better UX
|
| 38 |
+
if (this.isMobile) {
|
| 39 |
+
this.gui.close();
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
this.createAtomControls();
|
| 43 |
this.createDisplayControls();
|
| 44 |
this.createCameraControls();
|
| 45 |
this.createCredits();
|
| 46 |
|
| 47 |
+
// Add mobile-specific styling
|
| 48 |
+
if (this.isMobile) {
|
| 49 |
+
this.applyMobileStyling();
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
return this.gui;
|
| 53 |
}
|
| 54 |
|
| 55 |
+
/**
|
| 56 |
+
* Apply mobile-specific styling to GUI
|
| 57 |
+
*/
|
| 58 |
+
applyMobileStyling() {
|
| 59 |
+
const guiElement = this.gui.domElement;
|
| 60 |
+
guiElement.style.position = 'fixed';
|
| 61 |
+
guiElement.style.top = '10px';
|
| 62 |
+
guiElement.style.right = '10px';
|
| 63 |
+
guiElement.style.maxHeight = 'calc(100vh - 20px)';
|
| 64 |
+
guiElement.style.overflowY = 'auto';
|
| 65 |
+
guiElement.style.zIndex = '1000';
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
/**
|
| 69 |
* Create Atom Settings controls
|
| 70 |
*/
|