Archived
Compare commits
7
Commits
dev3D
..
d8417ca0b2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d8417ca0b2 | ||
|
|
547af1f986 | ||
|
|
87c03e83bd | ||
|
|
fac1e9bb18 | ||
|
|
09c34e270c | ||
|
|
9488c565b1 | ||
|
|
a52ce66b0a |
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 318 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 6.0 KiB |
Submodule Bita-3D-Explorer deleted from 5fb1cb8672.
@@ -0,0 +1,156 @@
|
||||
# CLAUDE.md
|
||||
|
||||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||
|
||||
---
|
||||
|
||||
# Bitua 3D Explorer
|
||||
|
||||
## Project Overview
|
||||
Interactive web-based 3D product visualization for the **Bitua Smart Cabinet Series** (medical/laboratory equipment). Users can explore the cabinet in 3D, interact with features (door, biometric reader, lock, camera), and simulate product storage capacity.
|
||||
|
||||
## Tech Stack
|
||||
- **Three.js v0.162.0** — 3D rendering (loaded via CDN)
|
||||
- **GSAP** — smooth camera transitions and door animations (loaded via CDN)
|
||||
- **Vanilla JS ES6 modules** — no framework, no build step
|
||||
- **GLB/GLTF** — 3D model format with DRACO compression support
|
||||
|
||||
## Architecture
|
||||
The entire application lives in a single file: `index.html` (56 KB). There is no build system, no package.json, no bundler. All dependencies are loaded from CDN at runtime.
|
||||
|
||||
### Key Assets
|
||||
- `Cabinet v2.5 con eje.glb` — main 3D model (~5.7 MB)
|
||||
- `GUI_Standby.png` — texture applied to the GUI screen mesh (solid1_61)
|
||||
|
||||
### Responsive Design
|
||||
The app is mobile-responsive with three breakpoints:
|
||||
- **0–480px** (Mobile): Bottom-sheet sidebar UI with floating action button (FAB)
|
||||
- **481–768px** (Tablet): Narrower sidebar (240px), optimized spacing
|
||||
- **769px+** (Desktop): Original layout with right-side panel (280px)
|
||||
|
||||
See `RESPONSIVE_DESIGN_IMPLEMENTATION.md` for detailed CSS changes (lines 506–767 in `index.html`).
|
||||
|
||||
## Key Systems (all inside index.html)
|
||||
|
||||
### 1. Scene & Rendering
|
||||
- WebGLRenderer with MSAA, PCFSoftShadowMap shadows, ACESFilmicToneMapping
|
||||
- PerspectiveCamera (45° FOV), OrbitControls with damping
|
||||
|
||||
### 2. Material System
|
||||
Materials are assigned by matching mesh names (regex patterns):
|
||||
- Glass trays → MeshPhysicalMaterial (transmission: 1.0, IOR: 1.5)
|
||||
- Green polycarbonate → MeshPhysicalMaterial (transmission: 0.95, green tint)
|
||||
- Lock/hinges → MeshStandardMaterial (metalness: 1.0)
|
||||
- LED bar → emissive MeshStandardMaterial (emissiveIntensity: 10)
|
||||
|
||||
### 3. Door/Hinge Animation
|
||||
- Door meshes (names containing "PUERTA") are reparented into a THREE.Group pivot at the hinge axis
|
||||
- GSAP animates rotation −120° (−2.09 rad) around Y-axis, 1.2s "power2.inOut"
|
||||
|
||||
### 4. Interaction System
|
||||
Raycasting on click detects:
|
||||
- **Lock** (solid1_102, CERRADURA, CILINDRO) → zoom + annotation
|
||||
- **Biometric readers** (solid1_114, solid1_37–41) → zoom + auto-open door
|
||||
- **Facial recognition** (solid1_103) → zoom + annotation
|
||||
- **Camera** (solid1_105, MESHFEATURE1) → zoom + annotation
|
||||
- **Door/hinges** (PUERTA, BISAGRA) → toggle door open/closed
|
||||
- **GUI/Console** (solid1_61) → info panel
|
||||
|
||||
### 5. Annotation System
|
||||
Semi-transparent callout panels with SVG leader lines connecting to 3D objects in screen space. Updates position every frame.
|
||||
|
||||
### 6. Capacity Simulator
|
||||
Right sidebar with product dimension inputs. Spawns blue semi-transparent boxes inside the cabinet using a grid-packing algorithm. Interior dimensions: {x: 0.8, y: 1.6, z: 0.5} meters.
|
||||
|
||||
### 7. Debug Overlay
|
||||
Press `D` to toggle camera position/target display with copy-to-clipboard.
|
||||
|
||||
## Common Development Tasks
|
||||
|
||||
### Adding a New Interaction
|
||||
1. Find the target mesh name using Node.js scripts: `node search_meshes.js <pattern>`
|
||||
2. Add mesh name pattern to the `raycastTargets` array in `index.html`
|
||||
3. Add handler in the click event listener's if-else chain
|
||||
4. Test with debug overlay (press `D`) to verify camera zoom targets
|
||||
|
||||
### Modifying Materials
|
||||
1. All material assignments happen in `initMaterials()` - materials are matched by regex patterns on mesh names
|
||||
2. Glass trays use `MeshPhysicalMaterial` with `transmission: 1.0`
|
||||
3. To adjust colors/metalness/roughness: find the regex pattern and modify the material properties
|
||||
4. Re-serve the app to see changes (hard refresh in browser)
|
||||
|
||||
### Adjusting Capacity Simulator Grid
|
||||
- Interior cabinet dimensions are hardcoded: `{x: 0.8, y: 1.6, z: 0.5}` meters
|
||||
- Grid-packing algorithm spawns blue boxes inside these bounds
|
||||
- Modify `spawnProductBox()` function to change packing behavior or visual style
|
||||
|
||||
### Inspecting the 3D Model
|
||||
Use Node.js utility scripts to understand the GLB structure without modifying code:
|
||||
```bash
|
||||
node list_names.js # All mesh names
|
||||
node print_hierarchy.js # Full scene tree
|
||||
node search_meshes.js "pattern" # Find meshes by regex
|
||||
node inspect_solid1_61.js # Details on GUI screen mesh
|
||||
```
|
||||
|
||||
## Development
|
||||
|
||||
### Running Locally
|
||||
Serve the directory with any static file server:
|
||||
```bash
|
||||
# Python
|
||||
python -m http.server 8080
|
||||
|
||||
# Node.js (npx)
|
||||
npx serve .
|
||||
|
||||
# VS Code Live Server extension also works
|
||||
```
|
||||
Then open `http://localhost:8080` in a browser.
|
||||
|
||||
**Note:** Must be served over HTTP (not opened as a `file://` URL) due to CORS restrictions on GLB loading.
|
||||
|
||||
## Utility Scripts
|
||||
Node.js analysis scripts for inspecting the GLB model (not part of the runtime app):
|
||||
|
||||
| Script | Purpose |
|
||||
|---|---|
|
||||
| `list_names.js` | List all mesh/node names in the model |
|
||||
| `print_hierarchy.js` | Print full scene hierarchy |
|
||||
| `search_meshes.js` | Search for meshes by name pattern |
|
||||
| `search_target_meshes.js` | Find specific interaction target meshes |
|
||||
| `extract_hinges.js` | Extract BISAGRA (hinge) components |
|
||||
| `find_led.js` | Locate LED bar mesh |
|
||||
| `inspect_solid1_61.js` | Deep inspect GUI screen mesh |
|
||||
| `check_indices.js` | Validate geometry index data |
|
||||
| `compare_models.js` | Compare two model variants |
|
||||
|
||||
Run with: `node <script>.js`
|
||||
|
||||
## Git & Deployment
|
||||
|
||||
### Repository
|
||||
- **Remote URL:** https://github.com/MartinSereyC/Bitua-3D-Explorer.git
|
||||
- **Production branch:** `main` (stable, deployed code)
|
||||
- **Development branch:** `dev3D` (active development)
|
||||
- **Clone:** `git clone https://github.com/MartinSereyC/Bitua-3D-Explorer.git`
|
||||
|
||||
### Workflow
|
||||
```bash
|
||||
# Check out development branch
|
||||
git checkout dev3D
|
||||
|
||||
# Make changes and commit
|
||||
git add -A
|
||||
git commit -m "Your message"
|
||||
|
||||
# Push to development
|
||||
git push origin dev3D
|
||||
|
||||
# When ready for production, merge dev3D → main (via PR or direct merge)
|
||||
```
|
||||
|
||||
**Branch strategy:**
|
||||
- Work on `dev3D` for feature development and testing
|
||||
- Push to `main` only when code is production-ready
|
||||
- `main` is always stable and deployable
|
||||
@@ -0,0 +1 @@
|
||||
**Repositorio archivado.** Este repositorio está archivado y se conserva como respaldo en dos lugares independientes: GitHub (`bitua-io/Bitua-3D-Explorer`) y Gitea (`gitea.bitua.io/bitua/Bitua-3D-Explorer`). Ya no hay mirror entre ellos y no recibe cambios. Archivado en el barrido de repos muertos ([bitua/network#36](https://gitea.bitua.io/bitua/network/issues/36)).
|
||||
Binary file not shown.
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"annotations": {
|
||||
"lock": {
|
||||
"title": "Abrir con llave.",
|
||||
"body": "Ante cortes de energía, la maquina permanece cerrada"
|
||||
},
|
||||
"biometric": {
|
||||
"title": "Apertura biométrica",
|
||||
"subtitle": "Funcionalidades acorde a rol del usuario",
|
||||
"details": {
|
||||
"clinicalUsers": "Uso diario, consumen insumos",
|
||||
"operator": "Repone inventario."
|
||||
}
|
||||
},
|
||||
"facialRecognition": {
|
||||
"title": "Reconocimiento facial (Opcional)",
|
||||
"body": "Apertura de puerta con reconocimiento facial"
|
||||
},
|
||||
"camera": {
|
||||
"title": "Cámara (Opcional)",
|
||||
"body": "Grabación de sesión cuando se abre la puerta."
|
||||
}
|
||||
},
|
||||
"infoPanels": {
|
||||
"faceRecognition": {
|
||||
"title": "Face Recognition Security",
|
||||
"body": "Our AI-powered volumetric face recognition identifies users in under 0.5 seconds, ensuring hands-free, high-security access."
|
||||
},
|
||||
"default": {
|
||||
"title": "Interactive Display & Navigation",
|
||||
"body": "Navigate through stored inventory, track usage logs, and manage permissions directly from this integrated touchscreen."
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
export const translations = {
|
||||
en: {
|
||||
title: "Bitua 3D Explorer - Interactive",
|
||||
loading: "Initializing Experience...",
|
||||
navTitle: "Smart Cabinet V2.5",
|
||||
simTitle: "Capacity Simulator",
|
||||
prodWidth: "Product Width (cm)",
|
||||
prodHeight: "Product Height (cm)",
|
||||
prodDepth: "Product Depth (cm)",
|
||||
runSim: "Run Simulation",
|
||||
capEst: "Capacity Estimation:",
|
||||
unitsFit: "units fit inside.",
|
||||
clickInteract: "Click to interact",
|
||||
infoHint: "🖱️ Click to interact | Right-click to pan | Simulator on the right",
|
||||
infoHintProd: "🖱️ Click to interact | Right-click to pan",
|
||||
home: "🏠 Home",
|
||||
// Annotations
|
||||
lockTitle: "Open with Key",
|
||||
lockBody: "In case of power failure, the machine remains locked.",
|
||||
bioTitle: "Biometric Opening",
|
||||
bioSubtitle: "Functionalities according to user role",
|
||||
bioUser: "Clinical User: Daily use, consume supplies.",
|
||||
bioOp: "Operator: Restock inventory",
|
||||
faceTitle: "Facial Recognition (Optional)",
|
||||
faceBody: "Door opening with facial recognition",
|
||||
camTitle: "Camera (Optional)",
|
||||
camBody: "Session recording when the door is opened",
|
||||
screenTitle: "Screen",
|
||||
screenBody: "Touch screen to enter",
|
||||
homeScreenTitle: "Start Screen",
|
||||
homeScreenBody: "Open machine with fingerprint, patient ID or Operator",
|
||||
// Debug
|
||||
camDebug: "Camera Debug",
|
||||
copy: "COPY",
|
||||
pos: "POS",
|
||||
tgt: "TGT",
|
||||
part: "Part",
|
||||
labelPlaceholder: "Label this view...",
|
||||
saveView: "SAVE VIEW",
|
||||
descPlaceholder: "Description / notes for this viewpoint...",
|
||||
copyJson: "COPY JSON",
|
||||
exportFile: "EXPORT FILE",
|
||||
debugHint: "Press 'D' for Camera Coordinates"
|
||||
},
|
||||
es: {
|
||||
title: "Bitua 3D Explorer - Interactivo",
|
||||
loading: "Inicializando Experiencia...",
|
||||
navTitle: "Smart Cabinet V2.5",
|
||||
simTitle: "Simulador de Capacidad",
|
||||
prodWidth: "Ancho del Producto (cm)",
|
||||
prodHeight: "Alto del Producto (cm)",
|
||||
prodDepth: "Profundidad del Producto (cm)",
|
||||
runSim: "Ejecutar Simulación",
|
||||
capEst: "Estimación de Capacidad:",
|
||||
unitsFit: "unidades caben dentro.",
|
||||
clickInteract: "Clic para interactuar",
|
||||
infoHint: "🖱️ Clic para interactuar | Clic derecho para desplazar | Simulador a la derecha",
|
||||
infoHintProd: "🖱️ Clic para interactuar | Clic derecho para desplazar",
|
||||
home: "🏠 Inicio",
|
||||
// Annotations
|
||||
lockTitle: "Abrir con llave",
|
||||
lockBody: "Ante cortes de energía, la máquina permanece cerrada.",
|
||||
bioTitle: "Apertura Biométrica",
|
||||
bioSubtitle: "Funcionalidades acorde a rol de usuarios",
|
||||
bioUser: "Usuario clínico: Utilizan la máquina diariamente, consumen insumos.",
|
||||
bioOp: "Operador: Repone inventario",
|
||||
faceTitle: "Reconocimiento facial (Opcional)",
|
||||
faceBody: "Apertura de puerta con reconocimiento facial",
|
||||
camTitle: "Cámara (Opcional)",
|
||||
camBody: "Grabación de sesión cuando se abre la puerta",
|
||||
screenTitle: "Pantalla",
|
||||
screenBody: "Pantalla táctil para ingresar",
|
||||
homeScreenTitle: "Pantalla de inicio",
|
||||
homeScreenBody: "Abrir máquina con huella, ID de paciente u Operador",
|
||||
// Debug
|
||||
camDebug: "Depuración de Cámara",
|
||||
copy: "COPIAR",
|
||||
pos: "POS",
|
||||
tgt: "OBJ",
|
||||
part: "Parte",
|
||||
labelPlaceholder: "Etiquetar esta vista...",
|
||||
saveView: "GUARDAR VISTA",
|
||||
descPlaceholder: "Descripción / notas para este punto de vista...",
|
||||
copyJson: "COPIAR JSON",
|
||||
exportFile: "EXPORTAR ARCHIVO",
|
||||
debugHint: "Presiona 'D' para Coordenadas de Cámara"
|
||||
}
|
||||
};
|
||||
+37
-1670
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,680 @@
|
||||
import * as THREE from 'three';
|
||||
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
|
||||
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
|
||||
import { DRACOLoader } from 'three/addons/loaders/DRACOLoader.js';
|
||||
import { RectAreaLightUniformsLib } from 'three/addons/lights/RectAreaLightUniformsLib.js';
|
||||
import gsap from 'gsap';
|
||||
import { translations } from './i18n.js';
|
||||
|
||||
// --- I18n Engine ---
|
||||
let currentLang = localStorage.getItem('bitua-lang') || 'es';
|
||||
|
||||
function updateUI() {
|
||||
try {
|
||||
const t = translations[currentLang];
|
||||
if (!t) {
|
||||
console.error(`❌ Translation for ${currentLang} not found.`);
|
||||
return;
|
||||
}
|
||||
document.querySelectorAll('[data-i18n]').forEach(el => {
|
||||
const key = el.getAttribute('data-i18n');
|
||||
if (t[key]) {
|
||||
if (el.tagName === 'INPUT' || el.tagName === 'TEXTAREA') {
|
||||
el.placeholder = t[key];
|
||||
} else {
|
||||
el.innerHTML = t[key];
|
||||
}
|
||||
}
|
||||
});
|
||||
const langLabel = document.getElementById('lang-label');
|
||||
if (langLabel) langLabel.textContent = currentLang.toUpperCase();
|
||||
|
||||
// Update page title if needed
|
||||
if (t.title) document.title = t.title;
|
||||
} catch (e) {
|
||||
console.error("❌ Error in updateUI:", e);
|
||||
}
|
||||
}
|
||||
|
||||
// Initial UI update is handled after dev check
|
||||
|
||||
// Language Selector Logic
|
||||
window.addEventListener('load', () => {
|
||||
const langSelector = document.querySelector('.lang-selector');
|
||||
langSelector.addEventListener('click', () => {
|
||||
currentLang = currentLang === 'es' ? 'en' : 'es';
|
||||
localStorage.setItem('bitua-lang', currentLang);
|
||||
updateUI();
|
||||
console.log(`🌐 Language switched to: ${currentLang}`);
|
||||
});
|
||||
});
|
||||
|
||||
// Initialize RectAreaLight support
|
||||
RectAreaLightUniformsLib.init();
|
||||
console.log("🚀 Bitua 3D Explorer - Multilingüe V2.2 script started");
|
||||
|
||||
// --- Dev Mode Check ---
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const isDev = urlParams.get('dev') === 'true';
|
||||
|
||||
// Hide production-unfriendly elements
|
||||
if (!isDev) {
|
||||
const sidebar = document.getElementById('sidebar');
|
||||
const debugHint = document.getElementById('debug-toggle-hint');
|
||||
const infoContent = document.getElementById('info-content');
|
||||
if (sidebar) sidebar.style.display = 'none';
|
||||
if (debugHint) debugHint.style.display = 'none';
|
||||
if (infoContent) infoContent.setAttribute('data-i18n', 'infoHintProd');
|
||||
}
|
||||
|
||||
// Initial UI Update
|
||||
updateUI();
|
||||
|
||||
// --- Setup ---
|
||||
const canvas = document.querySelector('#three-canvas');
|
||||
const renderer = new THREE.WebGLRenderer({ canvas, antialias: true, alpha: true });
|
||||
let internalLight = null;
|
||||
renderer.setPixelRatio(window.devicePixelRatio);
|
||||
renderer.setSize(window.innerWidth, window.innerHeight);
|
||||
renderer.shadowMap.enabled = true;
|
||||
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
|
||||
renderer.toneMapping = THREE.ACESFilmicToneMapping;
|
||||
renderer.toneMappingExposure = 1.0;
|
||||
|
||||
const scene = new THREE.Scene();
|
||||
scene.background = new THREE.Color(0xf5f5f7);
|
||||
const camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 100);
|
||||
camera.position.set(3, 1.5, 5);
|
||||
|
||||
const controls = new OrbitControls(camera, renderer.domElement);
|
||||
controls.enableDamping = true;
|
||||
controls.dampingFactor = 0.05;
|
||||
|
||||
// --- Lighting ---
|
||||
const ambientLight = new THREE.AmbientLight(0xffffff, 1.0);
|
||||
scene.add(ambientLight);
|
||||
|
||||
const spotLight = new THREE.SpotLight(0xffffff, 60);
|
||||
spotLight.position.set(5, 5, 5);
|
||||
spotLight.castShadow = true;
|
||||
scene.add(spotLight);
|
||||
|
||||
const fillLight = new THREE.DirectionalLight(0xffffff, 0.8);
|
||||
fillLight.position.set(-5, 2, -5);
|
||||
scene.add(fillLight);
|
||||
|
||||
const pmremGenerator = new THREE.PMREMGenerator(renderer);
|
||||
pmremGenerator.compileEquirectangularShader();
|
||||
const envScene = new THREE.Scene();
|
||||
|
||||
const envLight1 = new THREE.PointLight(0xffffff, 100);
|
||||
envLight1.position.set(5, 10, 5);
|
||||
envScene.add(envLight1);
|
||||
|
||||
const envLight2 = new THREE.PointLight(0xffffff, 80);
|
||||
envLight2.position.set(-5, 5, -5);
|
||||
envScene.add(envLight2);
|
||||
|
||||
const envLight3 = new THREE.RectAreaLight(0xffffff, 50, 10, 10);
|
||||
envLight3.position.set(0, 10, 0);
|
||||
envLight3.lookAt(0, 0, 0);
|
||||
envScene.add(envLight3);
|
||||
|
||||
const renderTarget = pmremGenerator.fromScene(envScene);
|
||||
scene.environment = renderTarget.texture;
|
||||
|
||||
// --- Model Management ---
|
||||
const loader = new GLTFLoader();
|
||||
const dracoLoader = new DRACOLoader();
|
||||
dracoLoader.setDecoderPath('https://www.gstatic.com/draco/versioned/decoders/1.5.6/');
|
||||
loader.setDRACOLoader(dracoLoader);
|
||||
|
||||
// --- Texture Loading ---
|
||||
const textureLoader = new THREE.TextureLoader();
|
||||
const standbyTexture = textureLoader.load('GUI_Standby.png');
|
||||
standbyTexture.colorSpace = THREE.SRGBColorSpace;
|
||||
standbyTexture.flipY = false;
|
||||
|
||||
let model = null;
|
||||
let isDoorOpen = false;
|
||||
let hingePivot = null;
|
||||
let centerOffset = null;
|
||||
|
||||
const DOOR_OPEN_ANGLE = -(Math.PI * 120) / 180;
|
||||
|
||||
function setupShadows(m) {
|
||||
m.traverse((child) => {
|
||||
if (child.isMesh) {
|
||||
child.castShadow = true;
|
||||
child.receiveShadow = true;
|
||||
|
||||
if (child.geometry) {
|
||||
child.geometry.computeVertexNormals();
|
||||
}
|
||||
|
||||
if (child.material) {
|
||||
const materials = Array.isArray(child.material) ? child.material : [child.material];
|
||||
materials.forEach(mat => {
|
||||
mat.flatShading = false;
|
||||
mat.needsUpdate = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const polycarbonateMaterial = new THREE.MeshPhysicalMaterial({
|
||||
color: 0x4caf50,
|
||||
transmission: 0.95,
|
||||
opacity: 1,
|
||||
thickness: 0.05,
|
||||
roughness: 0.1,
|
||||
metalness: 0,
|
||||
ior: 1.58,
|
||||
depthWrite: true,
|
||||
envMapIntensity: 2.5,
|
||||
side: THREE.DoubleSide,
|
||||
flatShading: false
|
||||
});
|
||||
|
||||
const glassMaterial = new THREE.MeshPhysicalMaterial({
|
||||
color: 0xffffff,
|
||||
transmission: 1.0,
|
||||
opacity: 1,
|
||||
thickness: 0.02,
|
||||
roughness: 0,
|
||||
metalness: 0,
|
||||
ior: 1.5,
|
||||
depthWrite: true,
|
||||
envMapIntensity: 3.0,
|
||||
side: THREE.DoubleSide,
|
||||
flatShading: false
|
||||
});
|
||||
|
||||
const acrylicMaterial = new THREE.MeshStandardMaterial({
|
||||
color: 0xffffff,
|
||||
roughness: 0.3,
|
||||
metalness: 0.0,
|
||||
transparent: false,
|
||||
envMapIntensity: 0.8,
|
||||
side: THREE.DoubleSide,
|
||||
flatShading: false
|
||||
});
|
||||
|
||||
const aluminumMaterial = new THREE.MeshStandardMaterial({
|
||||
color: 0xe5e5e5,
|
||||
metalness: 1.0,
|
||||
roughness: 0.4,
|
||||
envMapIntensity: 1.5,
|
||||
flatShading: false
|
||||
});
|
||||
|
||||
function setupGlassMaterials(m) {
|
||||
const acrylicTargetNames = [
|
||||
'A INTERIOR SEPARADOR IZQUIERDO:1',
|
||||
'A INTERIOR SEPARADOR ATRAS:1',
|
||||
'A INTERIOR SEPARADOR:1',
|
||||
'V2.5 A INTERIOR SEPARADOR SUPERIOR:1',
|
||||
'V2.5 A TAPA DE REGISTRO INFERIOR:1'
|
||||
];
|
||||
|
||||
try {
|
||||
let consoleMaterial = null;
|
||||
const meshToUpdate = [];
|
||||
|
||||
m.traverse((child) => {
|
||||
if (!child.isMesh) return;
|
||||
|
||||
const meshName = child.name || "UNNAMED";
|
||||
const parentName = (child.parent && child.parent.name) ? child.parent.name : "";
|
||||
|
||||
// Note: Normalization for matching avoids names needing exact symbols
|
||||
// BUT we should be consistent with the original logic
|
||||
const normMesh = meshName.toUpperCase().replace(/[^A-Z0-9]/g, '');
|
||||
const normParent = parentName.toUpperCase().replace(/[^A-Z0-9]/g, '');
|
||||
const combinedNorm = normMesh + "_" + normParent;
|
||||
|
||||
// Updated screen detection to handle the "includes" correctly
|
||||
const isScreen = normMesh.includes('SOLID161') || combinedNorm.includes('PANTALLANUEVA');
|
||||
|
||||
if (isScreen) {
|
||||
const geo = child.geometry;
|
||||
const positions = geo.attributes.position;
|
||||
const bbox = new THREE.Box3().setFromBufferAttribute(positions);
|
||||
const size = new THREE.Vector3();
|
||||
bbox.getSize(size);
|
||||
|
||||
const dims = [
|
||||
{ axis: 'x', size: size.x },
|
||||
{ axis: 'y', size: size.y },
|
||||
{ axis: 'z', size: size.z }
|
||||
].sort((a, b) => b.size - a.size);
|
||||
|
||||
const uAxis = dims[0].axis;
|
||||
const vAxis = dims[1].axis;
|
||||
const uvArr = new Float32Array(positions.count * 2);
|
||||
|
||||
for (let i = 0; i < positions.count; i++) {
|
||||
const coords = { x: positions.getX(i), y: positions.getY(i), z: positions.getZ(i) };
|
||||
const u0 = (coords[uAxis] - bbox.min[uAxis]) / Math.max(size[uAxis], 0.001);
|
||||
const v0 = (coords[vAxis] - bbox.min[vAxis]) / Math.max(size[vAxis], 0.001);
|
||||
uvArr[i * 2] = 1 - v0;
|
||||
uvArr[i * 2 + 1] = 1 - u0;
|
||||
}
|
||||
geo.setAttribute('uv', new THREE.BufferAttribute(uvArr, 2));
|
||||
child.material = new THREE.MeshBasicMaterial({ map: standbyTexture, side: THREE.DoubleSide });
|
||||
console.log(`📺 Screen textured: ${meshName}`);
|
||||
}
|
||||
|
||||
if (combinedNorm.includes('LADODERECHOCONSOLA')) consoleMaterial = child.material;
|
||||
if (combinedNorm.includes('SOPORTELECTORBIOMETRICO')) meshToUpdate.push(child);
|
||||
|
||||
const isDoor = combinedNorm.includes('V251PPPVIDRIO') || (combinedNorm.includes('PUERTA') && combinedNorm.includes('VIDRIO')) || (combinedNorm.includes('GLASS') && combinedNorm.includes('DOOR'));
|
||||
|
||||
if (isDoor) {
|
||||
child.visible = false;
|
||||
console.log(`👻 Hiding CAD door: ${meshName}`);
|
||||
} else if (combinedNorm.includes('SOPORTE')) {
|
||||
child.material = acrylicMaterial;
|
||||
} else if (combinedNorm.includes('BANDEJA') && (combinedNorm.includes('VIDRIO') || combinedNorm.includes('GLASS'))) {
|
||||
child.material = glassMaterial;
|
||||
} else if (combinedNorm.includes('BANDEJA')) {
|
||||
child.material = polycarbonateMaterial;
|
||||
} else if (combinedNorm.includes('VIDRIO') || combinedNorm.includes('GLASS')) {
|
||||
if (child.visible) child.material = glassMaterial;
|
||||
} else if (combinedNorm.includes('SEPARADOR') || acrylicTargetNames.includes(parentName.trim()) || acrylicTargetNames.includes(meshName.trim())) {
|
||||
child.material = acrylicMaterial;
|
||||
} else if (combinedNorm.includes('CILINDRO') || combinedNorm.includes('CERRADURA') || normMesh.includes('SOLID1102')) {
|
||||
child.material = aluminumMaterial;
|
||||
}
|
||||
});
|
||||
|
||||
if (consoleMaterial && meshToUpdate.length > 0) {
|
||||
meshToUpdate.forEach(mesh => mesh.material = consoleMaterial);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("❌ Critical error in setupGlassMaterials:", error);
|
||||
}
|
||||
}
|
||||
|
||||
function setupLEDBarLighting(m) {
|
||||
let ledBarMesh = null;
|
||||
const isLEDBar = (name) => {
|
||||
if (!name) return false;
|
||||
const normalized = name.toLowerCase().replace(/\s+/g, '');
|
||||
return normalized.includes('barraled') || (normalized.includes('barra') && normalized.includes('led'));
|
||||
};
|
||||
|
||||
m.traverse((child) => {
|
||||
if (isLEDBar(child.name)) {
|
||||
if (child.isMesh) ledBarMesh = child;
|
||||
else if (child.children.length > 0) {
|
||||
child.traverse((subChild) => { if (subChild.isMesh && !ledBarMesh) ledBarMesh = subChild; });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (ledBarMesh) {
|
||||
ledBarMesh.material = new THREE.MeshStandardMaterial({
|
||||
color: 0xffffff, emissive: 0xffffff, emissiveIntensity: 10,
|
||||
metalness: 0.1, roughness: 0.1, flatShading: false
|
||||
});
|
||||
const box = new THREE.Box3().setFromObject(ledBarMesh);
|
||||
const size = new THREE.Vector3(); box.getSize(size);
|
||||
const width = Math.max(size.x, 0.05); const height = Math.max(size.z, 0.05);
|
||||
const center = new THREE.Vector3(); box.getCenter(center);
|
||||
const localPos = center.clone().sub(m.position);
|
||||
|
||||
const rectLight = new THREE.RectAreaLight(0xffffff, 5, width, height);
|
||||
rectLight.position.set(localPos.x, localPos.y - 0.02, localPos.z);
|
||||
rectLight.rotation.x = -Math.PI / 2;
|
||||
m.add(rectLight);
|
||||
|
||||
const pointLight = new THREE.PointLight(0xffffff, 3, 5);
|
||||
pointLight.position.set(localPos.x, localPos.y - 0.05, localPos.z);
|
||||
m.add(pointLight);
|
||||
}
|
||||
}
|
||||
|
||||
function setupHingePivot() {
|
||||
const hingeAssemblies = [];
|
||||
const doorNodes = [];
|
||||
let ejeRotacionNode = null;
|
||||
let leftPanelNode = null;
|
||||
|
||||
model.traverse((child) => {
|
||||
if (!child.name) return;
|
||||
if (child.name.includes('BISAGRA')) {
|
||||
if (child.parent && !child.parent.name.includes('BISAGRA')) hingeAssemblies.push(child);
|
||||
}
|
||||
const normChildDoor = child.name.toUpperCase().replace(/[^A-Z0-9]/g, '');
|
||||
const parentNameUpper = (child.parent && child.parent.name) ? child.parent.name.toUpperCase() : '';
|
||||
if (child.name === 'V251_PPP_PUERTA1' || (normChildDoor.includes('PUERTA') && !parentNameUpper.includes('PUERTA'))) doorNodes.push(child);
|
||||
if (child.name.toLowerCase().includes('eje') && child.name.toLowerCase().includes('rotaci')) ejeRotacionNode = child;
|
||||
else if (child.name.includes('Eje') && child.name.includes('rotaci')) ejeRotacionNode = child;
|
||||
if (child.name.toUpperCase().includes('PANEL IZQUIERDO')) leftPanelNode = child;
|
||||
});
|
||||
|
||||
if (hingeAssemblies.length === 0 && doorNodes.length === 0 && !ejeRotacionNode) return;
|
||||
|
||||
const hingeNodes = [];
|
||||
hingeAssemblies.forEach(assembly => {
|
||||
const allMeshes = [];
|
||||
assembly.traverse((child) => { if (child.isMesh) allMeshes.push(child); });
|
||||
if (allMeshes.length > 0) {
|
||||
let minX = Infinity; let maxX = -Infinity;
|
||||
const centers = new Map();
|
||||
allMeshes.forEach(mesh => {
|
||||
const box = new THREE.Box3().setFromObject(mesh);
|
||||
const c = new THREE.Vector3(); box.getCenter(c);
|
||||
centers.set(mesh, c);
|
||||
if (c.x < minX) minX = c.x; if (c.x > maxX) maxX = c.x;
|
||||
});
|
||||
const thresholdX = (minX + Math.max(minX + 0.001, maxX)) / 2;
|
||||
allMeshes.forEach(mesh => { if (centers.get(mesh).x > thresholdX) hingeNodes.push(mesh); });
|
||||
} else hingeNodes.push(assembly);
|
||||
});
|
||||
|
||||
let pivotWorldPos = new THREE.Vector3();
|
||||
if (ejeRotacionNode) {
|
||||
new THREE.Box3().setFromObject(ejeRotacionNode).getCenter(pivotWorldPos);
|
||||
ejeRotacionNode.visible = false;
|
||||
} else if (hingeNodes.length > 0) {
|
||||
hingeNodes.forEach(h => { const wp = new THREE.Vector3(); h.getWorldPosition(wp); pivotWorldPos.add(wp); });
|
||||
pivotWorldPos.divideScalar(hingeNodes.length);
|
||||
} else {
|
||||
const box = new THREE.Box3().setFromObject(doorNodes[0]);
|
||||
pivotWorldPos.set(box.min.x, (box.min.y + box.max.y) / 2, box.min.z);
|
||||
}
|
||||
pivotWorldPos.y = 0;
|
||||
|
||||
hingePivot = new THREE.Group();
|
||||
hingePivot.name = 'HingePivot';
|
||||
hingePivot.position.copy(pivotWorldPos);
|
||||
model.add(hingePivot);
|
||||
|
||||
const nodesToReparent = [...doorNodes, ...hingeNodes];
|
||||
nodesToReparent.forEach(node => {
|
||||
const wp = new THREE.Vector3(); const wq = new THREE.Quaternion(); const ws = new THREE.Vector3();
|
||||
node.getWorldPosition(wp); node.getWorldQuaternion(wq); node.getWorldScale(ws);
|
||||
if (node.parent) node.parent.remove(node);
|
||||
hingePivot.add(node);
|
||||
const pivotWM = new THREE.Matrix4(); hingePivot.updateWorldMatrix(true, false);
|
||||
pivotWM.copy(hingePivot.matrixWorld).invert();
|
||||
const newWM = new THREE.Matrix4().compose(wp, wq, ws);
|
||||
const newLM = pivotWM.multiply(newWM);
|
||||
const np = new THREE.Vector3(); const nq = new THREE.Quaternion(); const ns = new THREE.Vector3();
|
||||
newLM.decompose(np, nq, ns);
|
||||
node.position.copy(np); node.quaternion.copy(nq); node.scale.copy(ns);
|
||||
});
|
||||
}
|
||||
|
||||
// Load Model
|
||||
loader.load('V2.5.1 AAA ENSAMBLE CABINET MAIN 3D visualizer.glb', (gltf) => {
|
||||
model = gltf.scene;
|
||||
const box = new THREE.Box3().setFromObject(model);
|
||||
centerOffset = box.getCenter(new THREE.Vector3());
|
||||
model.position.sub(centerOffset);
|
||||
setupShadows(model); setupGlassMaterials(model); setupLEDBarLighting(model);
|
||||
scene.add(model); setupHingePivot();
|
||||
document.getElementById('progress').style.width = '100%';
|
||||
document.getElementById('loader').style.opacity = '0';
|
||||
setTimeout(() => document.getElementById('loader').style.display = 'none', 500);
|
||||
}, (progress) => {
|
||||
if (progress.total > 0) document.getElementById('progress').style.width = (progress.loaded / progress.total * 100) + '%';
|
||||
}, (error) => console.error(error));
|
||||
|
||||
// --- Interaction ---
|
||||
const raycaster = new THREE.Raycaster();
|
||||
const mouse = new THREE.Vector2();
|
||||
let hoveredMesh = null;
|
||||
let currentLockTarget = null;
|
||||
|
||||
function isInteractiveMesh(object) {
|
||||
if (!object) return false;
|
||||
let combinedNorm = object.name.toUpperCase();
|
||||
object.traverseAncestors(a => { if (a.name) combinedNorm += " " + a.name.toUpperCase(); });
|
||||
if (combinedNorm.includes('CILINDRO') || combinedNorm.includes('CERRADURA') || combinedNorm.includes('SOLID1_70')) return true;
|
||||
if (combinedNorm.includes('SOLID1_82') || combinedNorm.includes('SOLID1_37') || combinedNorm.includes('SOLID1_41') ||
|
||||
combinedNorm.includes('SOLID1_40') || combinedNorm.includes('SOLID1_39') ||
|
||||
combinedNorm.includes('HUELLERO') || combinedNorm.includes('LECTOR') || combinedNorm.includes('BIOMETRICO')) return true;
|
||||
if (combinedNorm.includes('SOLID1_71')) return true;
|
||||
if (combinedNorm.includes('MESHFEATURE1') || combinedNorm.includes('SOLID1_73')) return true;
|
||||
if (combinedNorm.includes('SOLID1_81') || combinedNorm.includes('SOLID1_43') || combinedNorm.includes('PANTALLANUEVA')) return true;
|
||||
let isDoor = false;
|
||||
object.traverseAncestors((ancestor) => {
|
||||
if (ancestor.name && (ancestor.name.includes('PUERTA') || ancestor.name.includes('BISAGRA') || ancestor.name === 'HingePivot')) isDoor = true;
|
||||
});
|
||||
return isDoor;
|
||||
}
|
||||
|
||||
function applyHoverGlow(mesh) {
|
||||
if (!mesh.userData.glowCloned) {
|
||||
const origMat = mesh.material;
|
||||
mesh.material = origMat.clone();
|
||||
mesh.userData.origEmissive = mesh.material.emissive ? mesh.material.emissive.getHex() : 0x000000;
|
||||
mesh.userData.origEmissiveIntensity = mesh.material.emissiveIntensity || 0;
|
||||
mesh.userData.glowCloned = true;
|
||||
}
|
||||
if (mesh.material.emissive) {
|
||||
mesh.material.emissive.setHex(0x88bbff);
|
||||
mesh.material.emissiveIntensity = 0.22;
|
||||
}
|
||||
}
|
||||
|
||||
function removeHoverGlow(mesh) {
|
||||
if (!mesh || !mesh.userData.glowCloned) return;
|
||||
if (mesh.material.emissive) {
|
||||
mesh.material.emissive.setHex(mesh.userData.origEmissive);
|
||||
mesh.material.emissiveIntensity = mesh.userData.origEmissiveIntensity;
|
||||
}
|
||||
}
|
||||
|
||||
function zoomToLock() {
|
||||
smoothCameraTransition(new THREE.Vector3(0.8528, 0.087, 1.0604), new THREE.Vector3(0.4028, -0.063, 0.3104));
|
||||
}
|
||||
function zoomToBiometric() {
|
||||
smoothCameraTransition(new THREE.Vector3(0.048, 0.720, 4.001), new THREE.Vector3(-0.033, -0.279, 0.108));
|
||||
}
|
||||
function zoomToCamera() {
|
||||
smoothCameraTransition(new THREE.Vector3(1.333, 0.388, 1.915), new THREE.Vector3(0.094, 0.287, 0.417));
|
||||
}
|
||||
|
||||
function showAnnotation(target, contentHTML) {
|
||||
currentLockTarget = target;
|
||||
const annotation = document.getElementById('lock-annotation');
|
||||
annotation.innerHTML = contentHTML;
|
||||
annotation.style.display = 'block';
|
||||
document.getElementById('leader-line').style.display = 'block';
|
||||
updateAnnotationPosition();
|
||||
}
|
||||
|
||||
function hideAnnotation() {
|
||||
currentLockTarget = null;
|
||||
document.getElementById('lock-annotation').style.display = 'none';
|
||||
document.getElementById('leader-line').style.display = 'none';
|
||||
}
|
||||
|
||||
function updateAnnotationPosition() {
|
||||
if (!currentLockTarget) return;
|
||||
const wp = new THREE.Vector3(); currentLockTarget.getWorldPosition(wp);
|
||||
const vector = wp.clone().project(camera);
|
||||
const x = (vector.x * 0.5 + 0.5) * canvas.clientWidth;
|
||||
const y = (1 - (vector.y * 0.5 + 0.5)) * canvas.clientHeight;
|
||||
const annotation = document.getElementById('lock-annotation');
|
||||
const bx = x + 100; const by = y - 50;
|
||||
annotation.style.left = `${bx}px`; annotation.style.top = `${by}px`;
|
||||
const br = annotation.getBoundingClientRect();
|
||||
const sx = bx; const sy = by + br.height / 2;
|
||||
document.getElementById('line-path').setAttribute('d', `M ${sx} ${sy} L ${x} ${y}`);
|
||||
}
|
||||
|
||||
window.addEventListener('click', (event) => {
|
||||
if (event.target.closest('#sidebar') || event.target.closest('#camera-debug') || event.target.closest('.lang-selector')) return;
|
||||
const rect = canvas.getBoundingClientRect();
|
||||
mouse.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
|
||||
mouse.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
|
||||
raycaster.setFromCamera(mouse, camera);
|
||||
const intersects = raycaster.intersectObjects(scene.children, true);
|
||||
|
||||
if (intersects.length > 0) {
|
||||
const object = intersects[0].object;
|
||||
console.log('📦 Clicked Part:', {
|
||||
name: object.name,
|
||||
parent: object.parent ? object.parent.name : 'root',
|
||||
object: object
|
||||
});
|
||||
const t = translations[currentLang];
|
||||
let combinedName = object.name.toUpperCase();
|
||||
object.traverseAncestors(a => { if (a.name) combinedName += " " + a.name.toUpperCase(); });
|
||||
|
||||
let isDoorClick = false;
|
||||
object.traverseAncestors((ancestor) => {
|
||||
if (ancestor.name && (ancestor.name.includes('PUERTA') || ancestor.name.includes('BISAGRA') || ancestor.name === 'HingePivot')) isDoorClick = true;
|
||||
});
|
||||
|
||||
if (combinedName.includes('CILINDRO') || combinedName.includes('CERRADURA') || combinedName.includes('SOLID1_70')) {
|
||||
zoomToLock();
|
||||
showAnnotation(object, `<strong>${t.lockTitle}</strong><br>${t.lockBody}`);
|
||||
} else if (combinedName.includes('SOLID1_82') || combinedName.includes('SOLID1_37') || combinedName.includes('SOLID1_41') || combinedName.includes('SOLID1_40') || combinedName.includes('SOLID1_39') || combinedName.includes('HUELLERO') || combinedName.includes('LECTOR') || combinedName.includes('BIOMETRICO')) {
|
||||
zoomToBiometric();
|
||||
showAnnotation(object, `<strong>${t.bioTitle}</strong><br><div style="margin-top: 5px; font-size: 14px; font-weight: 400; line-height: 1.4;">${t.bioSubtitle}<br><strong>${t.bioUser.split(':')[0]}:</strong> ${t.bioUser.split(':')[1]} <br><strong>${t.bioOp.split(':')[0]}:</strong> ${t.bioOp.split(':')[1]}</div>`);
|
||||
if (!isDoorOpen) toggleDoor();
|
||||
} else if (combinedName.includes('SOLID1_71')) {
|
||||
zoomToBiometric();
|
||||
showAnnotation(object, `<strong>${t.faceTitle}</strong><br>${t.faceBody}`);
|
||||
} else if (combinedName.includes('MESHFEATURE1') || combinedName.includes('SOLID1_73')) {
|
||||
zoomToCamera();
|
||||
showAnnotation(object, `<strong>${t.camTitle}</strong><br>${t.camBody}`);
|
||||
} else if (combinedName.includes('SOLID1_81')) {
|
||||
smoothCameraTransition(new THREE.Vector3(0.3826, 0.3248, 0.657), new THREE.Vector3(0.3328, 0.2782, 0.121));
|
||||
showAnnotation(object, `<strong>${t.screenTitle}</strong><br>${t.screenBody}`);
|
||||
} else if (combinedName.includes('SOLID1_43') || combinedName.includes('PANTALLANUEVA')) {
|
||||
smoothCameraTransition(new THREE.Vector3(0.4489, 0.328, 0.6403), new THREE.Vector3(0.4363, 0.3089, 0.4923));
|
||||
showAnnotation(object, `<strong>${t.homeScreenTitle}</strong><br>${t.homeScreenBody}`);
|
||||
} else if (object.name.includes('PUERTA') || object.name.includes('BISAGRA') || isDoorClick) {
|
||||
toggleDoor(); hideAnnotation();
|
||||
} else {
|
||||
hideAnnotation();
|
||||
}
|
||||
} else {
|
||||
hideAnnotation();
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener('mousemove', (event) => {
|
||||
if (!model || event.target.closest('#sidebar') || event.target.closest('.lang-selector')) return;
|
||||
const rect = canvas.getBoundingClientRect();
|
||||
mouse.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
|
||||
mouse.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
|
||||
raycaster.setFromCamera(mouse, camera);
|
||||
const intersects = raycaster.intersectObjects(scene.children, true);
|
||||
const hit = intersects.length > 0 ? intersects[0].object : null;
|
||||
const interactive = hit && isInteractiveMesh(hit) ? hit : null;
|
||||
if (interactive !== hoveredMesh) {
|
||||
if (hoveredMesh) removeHoverGlow(hoveredMesh);
|
||||
if (interactive) applyHoverGlow(interactive);
|
||||
hoveredMesh = interactive;
|
||||
canvas.style.cursor = interactive ? 'pointer' : 'default';
|
||||
}
|
||||
});
|
||||
|
||||
function smoothCameraTransition(newPos, newTarget, duration = 1.5) {
|
||||
gsap.to(camera.position, { x: newPos.x, y: newPos.y, z: newPos.z, duration, ease: "power2.inOut", overwrite: "auto" });
|
||||
gsap.to(controls.target, { x: newTarget.x, y: newTarget.y, z: newTarget.z, duration, ease: "power2.inOut", overwrite: "auto", onUpdate: () => camera.lookAt(controls.target) });
|
||||
}
|
||||
|
||||
function toggleDoor() {
|
||||
if (!hingePivot) return;
|
||||
isDoorOpen = !isDoorOpen;
|
||||
gsap.to(hingePivot.rotation, { y: isDoorOpen ? DOOR_OPEN_ANGLE : 0, duration: 1.2, ease: "power2.inOut" });
|
||||
}
|
||||
|
||||
// --- UI Logic ---
|
||||
document.getElementById('sidebar-header').addEventListener('click', () => {
|
||||
const sb = document.getElementById('sidebar');
|
||||
sb.classList.toggle('collapsed');
|
||||
document.getElementById('sidebar-toggle-icon').textContent = sb.classList.contains('collapsed') ? '📦' : '✕';
|
||||
});
|
||||
|
||||
document.getElementById('btn-home').addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
smoothCameraTransition(new THREE.Vector3(3, 1.5, 5), new THREE.Vector3(0, 0, 0));
|
||||
});
|
||||
|
||||
// --- Simulator Logic ---
|
||||
let simBoxes = [];
|
||||
const INTERIOR_SIZE = { x: 0.8, y: 1.6, z: 0.5 };
|
||||
const INTERIOR_OFFSET = { x: 0, y: 0.5, z: 0 };
|
||||
|
||||
document.getElementById('btn-simulate').addEventListener('click', () => {
|
||||
simBoxes.forEach(box => scene.remove(box)); simBoxes = [];
|
||||
const pw = parseFloat(document.getElementById('prod-w').value) / 100;
|
||||
const ph = parseFloat(document.getElementById('prod-h').value) / 100;
|
||||
const pd = parseFloat(document.getElementById('prod-d').value) / 100;
|
||||
if (isNaN(pw) || isNaN(ph) || isNaN(pd) || pw <= 0) return;
|
||||
const gap = 0.005;
|
||||
const nx = Math.floor(INTERIOR_SIZE.x / (pw + gap));
|
||||
const ny = Math.floor(INTERIOR_SIZE.y / (ph + gap));
|
||||
const nz = Math.floor(INTERIOR_SIZE.z / (pd + gap));
|
||||
const total = nx * ny * nz;
|
||||
document.getElementById('result-panel').style.display = 'block';
|
||||
document.getElementById('result-count').innerText = total;
|
||||
|
||||
const visualLimit = Math.min(total, 500);
|
||||
const boxGeo = new THREE.BoxGeometry(pw, ph, pd);
|
||||
const boxMat = new THREE.MeshPhongMaterial({ color: 0x007aff, transparent: true, opacity: 0.7, shininess: 50 });
|
||||
let spawned = 0;
|
||||
for (let z = 0; z < nz && spawned < visualLimit; z++) {
|
||||
for (let y = 0; y < ny && spawned < visualLimit; y++) {
|
||||
for (let x = 0; x < nx && spawned < visualLimit; x++) {
|
||||
const m = new THREE.Mesh(boxGeo, boxMat);
|
||||
m.position.set((x * (pw + gap)) - (INTERIOR_SIZE.x / 2) + (pw / 2), (y * (ph + gap)) - (INTERIOR_SIZE.y / 2) + (ph / 2) + INTERIOR_OFFSET.y, (z * (pd + gap)) - (INTERIOR_SIZE.z / 2) + (pd / 2));
|
||||
scene.add(m); simBoxes.push(m); spawned++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (simBoxes.length > 0) gsap.from(simBoxes.map(b => b.scale), { x: 0, y: 0, z: 0, duration: 0.5, stagger: 0.01, ease: "back.out(1.7)" });
|
||||
if (!isDoorOpen) toggleDoor();
|
||||
});
|
||||
|
||||
// --- Debug Logic ---
|
||||
if (isDev) {
|
||||
const debugOverlay = document.getElementById('camera-debug');
|
||||
const camPosEl = document.getElementById('cam-pos');
|
||||
const camTgtEl = document.getElementById('cam-tgt');
|
||||
let debugEnabled = false;
|
||||
debugOverlay.style.display = 'none';
|
||||
|
||||
window.addEventListener('keydown', (e) => {
|
||||
if (e.key.toLowerCase() === 'd') {
|
||||
debugEnabled = !debugEnabled;
|
||||
debugOverlay.style.display = debugEnabled ? 'block' : 'none';
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById('btn-copy-debug').addEventListener('click', () => {
|
||||
const p = camera.position; const t = controls.target;
|
||||
const text = `POS: ${p.x.toFixed(3)}, ${p.y.toFixed(3)}, ${p.z.toFixed(3)}\nTGT: ${t.x.toFixed(3)}, ${t.y.toFixed(3)}, ${t.z.toFixed(3)}`;
|
||||
navigator.clipboard.writeText(text);
|
||||
});
|
||||
}
|
||||
|
||||
// --- Render Loop ---
|
||||
function animate() {
|
||||
requestAnimationFrame(animate);
|
||||
controls.update();
|
||||
updateAnnotationPosition();
|
||||
if (document.getElementById('camera-debug').style.display !== 'none') {
|
||||
const p = camera.position; const t = controls.target;
|
||||
document.getElementById('cam-pos').textContent = `${p.x.toFixed(3)}, ${p.y.toFixed(3)}, ${p.z.toFixed(3)}`;
|
||||
document.getElementById('cam-tgt').textContent = `${t.x.toFixed(3)}, ${t.y.toFixed(3)}, ${t.z.toFixed(3)}`;
|
||||
}
|
||||
renderer.render(scene, camera);
|
||||
}
|
||||
animate();
|
||||
|
||||
window.addEventListener('resize', () => {
|
||||
camera.aspect = window.innerWidth / window.innerHeight; camera.updateProjectionMatrix();
|
||||
renderer.setSize(window.innerWidth, window.innerHeight);
|
||||
});
|
||||
@@ -0,0 +1,586 @@
|
||||
:root {
|
||||
--primary: #007aff;
|
||||
--bg: #f5f5f7;
|
||||
--card-bg: #ffffff;
|
||||
--text: #1d1d1f;
|
||||
}
|
||||
|
||||
@keyframes glow-pulse {
|
||||
0%, 100% { box-shadow: 0 4px 10px rgba(0, 122, 255, 0.25); }
|
||||
50% { box-shadow: 0 4px 22px rgba(0, 122, 255, 0.6), 0 0 14px rgba(0, 122, 255, 0.28); }
|
||||
}
|
||||
|
||||
@keyframes glow-pulse-pill {
|
||||
0%, 100% { box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1), 0 0 8px rgba(0, 122, 255, 0.2); }
|
||||
50% { box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15), 0 0 18px rgba(0, 122, 255, 0.5); }
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;
|
||||
background-color: var(--bg);
|
||||
color: var(--text);
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 10px 40px;
|
||||
background: #ffffff;
|
||||
z-index: 10;
|
||||
box-shadow: 0 1px 10px rgba(0, 0, 0, 0.05);
|
||||
height: 80px;
|
||||
}
|
||||
|
||||
.header-logo {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.header-logo img {
|
||||
height: 40px;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.header-nav {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.header-nav a {
|
||||
text-decoration: none;
|
||||
color: #1d1d1f;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
transition: color 0.2s ease;
|
||||
}
|
||||
|
||||
.header-nav a:hover {
|
||||
color: #00bf72; /* Teal matching logo */
|
||||
}
|
||||
|
||||
.header-nav a.active {
|
||||
color: #00bf72;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.lang-selector {
|
||||
border: 1px solid #e0e0e0;
|
||||
padding: 5px 12px;
|
||||
border-radius: 20px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
background: #f5f5f7;
|
||||
transition: all 0.2s ease;
|
||||
user-select: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.lang-selector:hover {
|
||||
background: #e5e5e7;
|
||||
border-color: #d1d1d6;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
header { padding: 0 20px; height: 60px; }
|
||||
.header-nav { display: none; }
|
||||
}
|
||||
|
||||
#container {
|
||||
flex: 1;
|
||||
position: relative;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#three-canvas {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* Loading UI */
|
||||
#loader {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: var(--bg);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 100;
|
||||
transition: opacity 0.5s ease;
|
||||
}
|
||||
|
||||
.progress-bar {
|
||||
width: 200px;
|
||||
height: 4px;
|
||||
background: #e0e0e0;
|
||||
border-radius: 2px;
|
||||
overflow: hidden;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
#progress {
|
||||
width: 0%;
|
||||
height: 100%;
|
||||
background: var(--primary);
|
||||
transition: width 0.3s ease;
|
||||
}
|
||||
|
||||
/* Info Overlay */
|
||||
.info-panel {
|
||||
position: absolute;
|
||||
bottom: 30px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
background: rgba(0, 0, 0, 0.7);
|
||||
color: white;
|
||||
padding: 12px 24px;
|
||||
border-radius: 30px;
|
||||
font-size: 14px;
|
||||
pointer-events: none;
|
||||
backdrop-filter: blur(10px);
|
||||
text-align: center;
|
||||
z-index: 5;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
#btn-home {
|
||||
background: var(--primary);
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 8px 16px;
|
||||
border-radius: 20px;
|
||||
cursor: pointer;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
transition: background 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
pointer-events: auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
animation: glow-pulse 2.5s ease-in-out infinite;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
#btn-home:hover {
|
||||
background: #005bb7;
|
||||
transform: translateY(-2px);
|
||||
animation-play-state: paused;
|
||||
box-shadow: 0 6px 18px rgba(0, 122, 255, 0.55);
|
||||
}
|
||||
|
||||
#btn-home:active {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
/* Interaction Tooltip (Click to open) */
|
||||
#tooltip {
|
||||
position: absolute;
|
||||
background: white;
|
||||
padding: 8px 16px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
|
||||
display: none;
|
||||
pointer-events: none;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
z-index: 20;
|
||||
}
|
||||
|
||||
#sidebar {
|
||||
position: absolute;
|
||||
top: 100px;
|
||||
right: 20px;
|
||||
width: 280px;
|
||||
background: rgba(255, 255, 255, 0.9);
|
||||
backdrop-filter: blur(20px);
|
||||
padding: 0;
|
||||
border-radius: 20px;
|
||||
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
|
||||
z-index: 10;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#sidebar.collapsed {
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
border-radius: 30px;
|
||||
cursor: pointer;
|
||||
animation: glow-pulse-pill 3s ease-in-out infinite;
|
||||
}
|
||||
|
||||
#sidebar-header {
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
border-radius: 20px 20px 0 0;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
|
||||
#sidebar:not(.collapsed) #sidebar-header:hover {
|
||||
background: rgba(0, 122, 255, 0.05);
|
||||
}
|
||||
|
||||
#btn-simulate {
|
||||
background: var(--primary);
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 10px 18px;
|
||||
border-radius: 14px;
|
||||
cursor: pointer;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
width: 100%;
|
||||
animation: glow-pulse 2.8s ease-in-out infinite;
|
||||
transition: background 0.2s, transform 0.15s;
|
||||
}
|
||||
|
||||
#btn-simulate:hover {
|
||||
background: #005bb7;
|
||||
animation-play-state: paused;
|
||||
box-shadow: 0 6px 18px rgba(0, 122, 255, 0.55);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
#btn-simulate:active {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
#sidebar-header h2 {
|
||||
margin: 0;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
#sidebar-content {
|
||||
padding: 0 24px 24px 24px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 15px;
|
||||
transition: opacity 0.2s;
|
||||
}
|
||||
|
||||
#sidebar.collapsed #sidebar-content {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
#sidebar.collapsed #sidebar-header h2 {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#sidebar-toggle-icon {
|
||||
font-size: 20px;
|
||||
transition: transform 0.3s;
|
||||
}
|
||||
|
||||
#sidebar.collapsed #sidebar-toggle-icon {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
|
||||
#sidebar:not(.collapsed) #sidebar-toggle-icon {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
/* Input Styles */
|
||||
.input-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.input-group label {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.input-group input {
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #e0e0e0;
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
outline: none;
|
||||
transition: border-color 0.2s;
|
||||
}
|
||||
|
||||
.input-group input:focus {
|
||||
border-color: var(--primary);
|
||||
}
|
||||
|
||||
#result-panel {
|
||||
background: #f0f7ff;
|
||||
padding: 12px;
|
||||
border-radius: 12px;
|
||||
font-size: 13px;
|
||||
color: #1d1d1f;
|
||||
line-height: 1.5;
|
||||
display: none;
|
||||
}
|
||||
|
||||
#result-count {
|
||||
font-weight: 700;
|
||||
font-size: 18px;
|
||||
color: var(--primary);
|
||||
}
|
||||
|
||||
/* Lock Annotation Styles */
|
||||
#lock-annotation {
|
||||
position: absolute;
|
||||
background: rgba(255, 255, 255, 0.95);
|
||||
padding: 12px 20px;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
|
||||
display: none;
|
||||
pointer-events: auto;
|
||||
font-size: 16px;
|
||||
font-weight: 400;
|
||||
z-index: 100;
|
||||
border-left: 4px solid var(--primary);
|
||||
backdrop-filter: blur(10px);
|
||||
color: var(--text);
|
||||
max-width: 250px;
|
||||
}
|
||||
|
||||
#leader-line {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
pointer-events: none;
|
||||
z-index: 99;
|
||||
display: none;
|
||||
}
|
||||
|
||||
#leader-line path {
|
||||
fill: none;
|
||||
stroke: #444444; /* Dark gray */
|
||||
stroke-width: 2;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
/* Debug Overlay */
|
||||
#camera-debug {
|
||||
position: absolute;
|
||||
top: 20px;
|
||||
left: 20px;
|
||||
background: rgba(0, 0, 0, 0.8);
|
||||
color: #00ff00;
|
||||
padding: 15px;
|
||||
border-radius: 10px;
|
||||
font-family: 'Courier New', Courier, monospace;
|
||||
font-size: 12px;
|
||||
pointer-events: none;
|
||||
z-index: 1000;
|
||||
display: none;
|
||||
border: 1px solid #00ff00;
|
||||
box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
|
||||
pointer-events: auto; /* Enable interaction for the button */
|
||||
}
|
||||
|
||||
#camera-debug h3 {
|
||||
margin: 0 0 10px 0;
|
||||
font-size: 14px;
|
||||
border-bottom: 1px solid #00ff00;
|
||||
padding-bottom: 5px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
#btn-copy-debug {
|
||||
background: #00ff00;
|
||||
color: black;
|
||||
border: none;
|
||||
padding: 2px 8px;
|
||||
border-radius: 4px;
|
||||
font-size: 10px;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
#btn-copy-debug:hover {
|
||||
background: #00cc00;
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
#btn-copy-debug:active {
|
||||
transform: scale(0.95);
|
||||
}
|
||||
|
||||
#debug-last-clicked {
|
||||
margin-top: 6px;
|
||||
color: #aaffaa;
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
#debug-last-clicked span {
|
||||
color: #ffff00;
|
||||
}
|
||||
|
||||
#debug-paragraph-input {
|
||||
width: 100%;
|
||||
margin-top: 6px;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
border: 1px solid #00aa00;
|
||||
color: #00ff00;
|
||||
font-family: 'Courier New', Courier, monospace;
|
||||
font-size: 10px;
|
||||
padding: 4px 6px;
|
||||
border-radius: 4px;
|
||||
outline: none;
|
||||
resize: vertical;
|
||||
min-height: 48px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
#debug-paragraph-input::placeholder { color: #006600; }
|
||||
|
||||
#debug-save-row {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
margin-top: 10px;
|
||||
padding-top: 10px;
|
||||
border-top: 1px solid #004400;
|
||||
}
|
||||
|
||||
#debug-label-input {
|
||||
flex: 1;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
border: 1px solid #00aa00;
|
||||
color: #00ff00;
|
||||
font-family: 'Courier New', Courier, monospace;
|
||||
font-size: 10px;
|
||||
padding: 3px 6px;
|
||||
border-radius: 4px;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
#debug-label-input::placeholder {
|
||||
color: #006600;
|
||||
}
|
||||
|
||||
#btn-save-view {
|
||||
background: #00aa00;
|
||||
color: black;
|
||||
border: none;
|
||||
padding: 3px 8px;
|
||||
border-radius: 4px;
|
||||
font-size: 10px;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
#btn-save-view:hover { background: #00cc00; }
|
||||
#btn-save-view:active { transform: scale(0.95); }
|
||||
|
||||
#debug-viewpoints-list {
|
||||
max-height: 160px;
|
||||
overflow-y: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
.debug-vp-entry {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
background: rgba(0, 80, 0, 0.3);
|
||||
border: 1px solid #004400;
|
||||
border-radius: 4px;
|
||||
padding: 4px 6px;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.debug-vp-label {
|
||||
font-weight: bold;
|
||||
color: #aaffaa;
|
||||
font-size: 10px;
|
||||
flex: 1;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.debug-vp-coords {
|
||||
color: #007700;
|
||||
font-size: 9px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.debug-vp-del {
|
||||
background: none;
|
||||
border: none;
|
||||
color: #ff4444;
|
||||
cursor: pointer;
|
||||
font-size: 11px;
|
||||
padding: 0 2px;
|
||||
line-height: 1;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.debug-vp-del:hover { color: #ff0000; }
|
||||
|
||||
#debug-export-row {
|
||||
display: none;
|
||||
gap: 6px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
#debug-export-row button {
|
||||
flex: 1;
|
||||
border: none;
|
||||
padding: 4px 8px;
|
||||
border-radius: 4px;
|
||||
font-size: 10px;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
font-family: 'Courier New', Courier, monospace;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
#btn-copy-json { background: #00ff00; color: black; }
|
||||
#btn-copy-json:hover { background: #00cc00; }
|
||||
|
||||
#btn-export-views { background: #0055ff; color: white; }
|
||||
#btn-export-views:hover { background: #0044cc; }
|
||||
|
||||
#debug-export-row button:active { transform: scale(0.95); }
|
||||
|
||||
#debug-toggle-hint {
|
||||
position: absolute;
|
||||
bottom: 80px;
|
||||
left: 20px;
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
padding: 5px 10px;
|
||||
border-radius: 5px;
|
||||
font-size: 10px;
|
||||
color: #666;
|
||||
pointer-events: none;
|
||||
}
|
||||
Reference in new issue
Block a user