Archived
Compare commits
4
Commits
dev3D
..
fac1e9bb18
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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: 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
|
||||
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."
|
||||
}
|
||||
}
|
||||
}
|
||||
+76
-41
@@ -588,7 +588,7 @@
|
||||
"imports": {
|
||||
"three": "https://unpkg.com/three@0.162.0/build/three.module.js",
|
||||
"three/addons/": "https://unpkg.com/three@0.162.0/examples/jsm/",
|
||||
"gsap": "https://cdn.skypack.dev/gsap"
|
||||
"gsap": "https://esm.run/gsap@3.12.5"
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -787,10 +787,35 @@
|
||||
const lastEntry = meshList[meshList.length - 1];
|
||||
|
||||
// 0. GUI STANDBY (Specific Screen Mesh)
|
||||
if (normMesh.includes('SOLID1_61')) {
|
||||
// Also check combinedNorm so parent "V2.5 PANTALLA NUEVA:1" matches (Solid1_43)
|
||||
if (normMesh.includes('SOLID1_61') || combinedNorm.includes('PANTALLANUEVA')) {
|
||||
// Generate planar UV coordinates — this mesh has none in the GLB (CAD export)
|
||||
const geo = child.geometry;
|
||||
const positions = geo.attributes.position;
|
||||
const bbox = new THREE.Box3().setFromBufferAttribute(positions);
|
||||
const size = new THREE.Vector3();
|
||||
bbox.getSize(size);
|
||||
// Pick the two largest dimensions as the UV plane axes
|
||||
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]) / size[uAxis];
|
||||
const v0 = (coords[vAxis] - bbox.min[vAxis]) / size[vAxis];
|
||||
// Rotate 90° CCW + mirror on Y: new_u = 1 - v0, new_v = 1 - u0
|
||||
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,
|
||||
transparent: true,
|
||||
side: THREE.DoubleSide
|
||||
});
|
||||
lastEntry.matched = "📺 GUI STANDBY";
|
||||
@@ -979,8 +1004,11 @@
|
||||
hingeAssemblies.push(child);
|
||||
}
|
||||
}
|
||||
// Door assembly (top level)
|
||||
if (child.name === 'V251_PPP_PUERTA1') {
|
||||
// Door assembly (top level) — match both old and new model names
|
||||
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);
|
||||
}
|
||||
// Check for explicit rotation axis part
|
||||
@@ -1047,16 +1075,7 @@
|
||||
hingeNodes.push(mesh);
|
||||
movingCount++;
|
||||
} else {
|
||||
// Left side -> Fixed
|
||||
// Make it appear lighter by adding subtle emissive
|
||||
const newMat = new THREE.MeshStandardMaterial({
|
||||
color: 0x555555, // Base grey
|
||||
emissive: 0x333333, // Subtle glow to look "lighter"
|
||||
metalness: 0.6,
|
||||
roughness: 0.4,
|
||||
flatShading: false
|
||||
});
|
||||
mesh.material = newMat;
|
||||
// Left side -> Fixed (keep original GLB color for uniform appearance)
|
||||
fixedCount++;
|
||||
}
|
||||
});
|
||||
@@ -1158,7 +1177,7 @@
|
||||
|
||||
// Load the model
|
||||
loader.load(
|
||||
'Cabinet v2.5 con eje.glb',
|
||||
'V2.5.1 AAA ENSAMBLE CABINET MAIN 3D visualizer.glb',
|
||||
(gltf) => {
|
||||
model = gltf.scene;
|
||||
|
||||
@@ -1202,12 +1221,16 @@
|
||||
|
||||
function isInteractiveMesh(object) {
|
||||
if (!object) return false;
|
||||
const norm = object.name.toUpperCase();
|
||||
if (norm.includes('CILINDRO') || norm.includes('CERRADURA') || norm.includes('SOLID1_102')) return true;
|
||||
if (norm.includes('SOLID1_114') || norm.includes('SOLID1_37') || norm.includes('SOLID1_41') ||
|
||||
norm.includes('SOLID1_40') || norm.includes('SOLID1_39')) return true;
|
||||
if (norm.includes('SOLID1_103')) return true;
|
||||
if (norm.includes('MESHFEATURE1') || norm.includes('SOLID1_105')) return true;
|
||||
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 && (
|
||||
@@ -1283,7 +1306,10 @@
|
||||
console.log('Clicked:', object.name);
|
||||
lastClickedPart = object.name;
|
||||
if (debugPartName) debugPartName.textContent = object.name || 'unnamed';
|
||||
const normName = object.name.toUpperCase();
|
||||
|
||||
// Get full hierarchical name for matching (helps when mesh name is just "Solid1")
|
||||
let combinedName = object.name.toUpperCase();
|
||||
object.traverseAncestors(a => { if (a.name) combinedName += " " + a.name.toUpperCase(); });
|
||||
|
||||
// Check if clicking door or hinge area (traverse ancestors including pivot)
|
||||
let isDoorClick = false;
|
||||
@@ -1297,26 +1323,38 @@
|
||||
}
|
||||
});
|
||||
|
||||
if (normName.includes('CILINDRO') || normName.includes('CERRADURA') || normName.includes('SOLID1_102')) {
|
||||
if (combinedName.includes('CILINDRO') || combinedName.includes('CERRADURA') || combinedName.includes('SOLID1_70')) {
|
||||
zoomToLock(object);
|
||||
showAnnotation(object, "<strong>Abrir con llave.</strong><br>Ante cortes de energía, la maquina permanece cerrada");
|
||||
} else if (normName.includes('SOLID1_114') || normName.includes('SOLID1_37') || normName.includes('SOLID1_41') || normName.includes('SOLID1_40') || normName.includes('SOLID1_39')) {
|
||||
showAnnotation(object, "<strong>Abrir con llave</strong><br>Ante cortes de energía, la máquina pertenece cerrada,");
|
||||
} 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(object);
|
||||
showAnnotation(object, `
|
||||
<strong>Apertura biométrica</strong><br>
|
||||
<span style="font-size: 14px; opacity: 0.8;">Funcionalidades acorde a rol del usuario</span>
|
||||
<div style="margin-top: 10px; font-size: 13px; font-weight: 400; line-height: 1.4;">
|
||||
<strong>Usuarios clínicos:</strong> Uso diario, consumen insumos<br>
|
||||
<strong>Operador:</strong> Repone inventario.
|
||||
<strong>Apertura Biométrica</strong><br>
|
||||
<div style="margin-top: 5px; font-size: 14px; font-weight: 400; line-height: 1.4;">
|
||||
Funcionalidades acorde a rol de usuarios<br>
|
||||
<strong>Usuario clínico:</strong> Utilizan la máquina diariamente, consumen insumos. <br>
|
||||
<strong>Operador:</strong> Repone inventario
|
||||
</div>
|
||||
`);
|
||||
if (!isDoorOpen) toggleDoor();
|
||||
} else if (normName.includes('SOLID1_103')) {
|
||||
} else if (combinedName.includes('SOLID1_71')) {
|
||||
zoomToBiometric(object);
|
||||
showAnnotation(object, "<strong>Reconocimiento facial (Opcional)</strong><br>Apertura de puerta con reconocimiento facial");
|
||||
} else if (normName.includes('MESHFEATURE1') || normName.includes('SOLID1_105')) {
|
||||
showAnnotation(object, "<strong>Reconocimiento facial (opcional)</strong><br>Apertura de puerta con reconocimiento facial");
|
||||
} else if (combinedName.includes('MESHFEATURE1') || combinedName.includes('SOLID1_73')) {
|
||||
zoomToCamera(object);
|
||||
showAnnotation(object, "<strong>Cámara (Opcional)</strong><br>Grabación de sesión cuando se abre la puerta.");
|
||||
showAnnotation(object, "<strong>Cámara (Opcional)</strong><br>Grabación de sesión cuando se abre la puerta");
|
||||
} 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>Pantalla</strong><br>Pantalla táctil para ingresar");
|
||||
} 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>Pantalla de inicio</strong><br>Abrir máquina con huella, ID de paciente u Operador");
|
||||
} else if (object.name.includes('PUERTA') || object.name.includes('BISAGRA') || isDoorClick) {
|
||||
toggleDoor();
|
||||
hideAnnotation();
|
||||
@@ -1377,13 +1415,10 @@
|
||||
}
|
||||
|
||||
function zoomToLock(target) {
|
||||
const worldPos = new THREE.Vector3();
|
||||
target.getWorldPosition(worldPos);
|
||||
const cameraTargetPos = new THREE.Vector3(0.8528, 0.087, 1.0604);
|
||||
const focusTarget = new THREE.Vector3(0.4028, -0.063, 0.3104);
|
||||
|
||||
const zoomTarget = worldPos.clone();
|
||||
const cameraTargetPos = worldPos.clone().add(new THREE.Vector3(0.45, 0.15, 0.75));
|
||||
|
||||
smoothCameraTransition(cameraTargetPos, zoomTarget);
|
||||
smoothCameraTransition(cameraTargetPos, focusTarget);
|
||||
}
|
||||
|
||||
function zoomToBiometric(target) {
|
||||
|
||||
Reference in new issue
Block a user