Archived
Merge remote-tracking branch 'dev3D/dev3D'
This commit is contained in:
commit
fd5c15a9d7
13 files changed
+2164
No files matched your search
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 318 KiB |
@@ -0,0 +1,22 @@
|
||||
const fs = require('fs');
|
||||
|
||||
function checkIndices(filePath) {
|
||||
const buffer = fs.readFileSync(filePath);
|
||||
const jsonLen = buffer.readUInt32LE(12);
|
||||
const jsonBuf = buffer.slice(20, 20 + jsonLen);
|
||||
const gltf = JSON.parse(jsonBuf.toString());
|
||||
|
||||
[37, 41].forEach(idx => {
|
||||
console.log(`Node [${idx}]:`, gltf.nodes[idx] ? gltf.nodes[idx].name : 'OUT OF RANGE');
|
||||
if (gltf.nodes[idx] && gltf.nodes[idx].mesh !== undefined) {
|
||||
const meshIdx = gltf.nodes[idx].mesh;
|
||||
console.log(` Mesh [${meshIdx}]:`, gltf.meshes[meshIdx].name);
|
||||
}
|
||||
});
|
||||
|
||||
[37, 41].forEach(idx => {
|
||||
console.log(`Mesh [${idx}]:`, gltf.meshes[idx] ? gltf.meshes[idx].name : 'OUT OF RANGE');
|
||||
});
|
||||
}
|
||||
|
||||
checkIndices('Cabinet v2.5 con eje.glb');
|
||||
+166
@@ -0,0 +1,166 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Model Comparison Tool</title>
|
||||
<style>
|
||||
body { font-family: monospace; background: #1a1a2e; color: #e0e0e0; padding: 20px; }
|
||||
h1 { color: #007aff; }
|
||||
.diff { color: #ff6b6b; font-weight: bold; background: rgba(255,100,100,0.1); padding: 2px 6px; border-radius: 4px; }
|
||||
.same { opacity: 0.4; }
|
||||
.section { margin: 20px 0; padding: 15px; background: #16213e; border-radius: 10px; }
|
||||
table { border-collapse: collapse; width: 100%; margin-top: 10px; }
|
||||
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid #333; }
|
||||
th { color: #007aff; }
|
||||
#status { padding: 10px; background: #0f3460; border-radius: 8px; margin-bottom: 20px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>🔍 GLB Model Comparison Tool</h1>
|
||||
<div id="status">Loading models...</div>
|
||||
<div id="output"></div>
|
||||
|
||||
<script type="importmap">
|
||||
{
|
||||
"imports": {
|
||||
"three": "https://unpkg.com/three@0.162.0/build/three.module.js",
|
||||
"three/addons/": "https://unpkg.com/three@0.162.0/examples/jsm/"
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<script type="module">
|
||||
import * as THREE from 'three';
|
||||
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
|
||||
|
||||
const loader = new GLTFLoader();
|
||||
const statusEl = document.getElementById('status');
|
||||
const outputEl = document.getElementById('output');
|
||||
|
||||
function loadModel(url) {
|
||||
return new Promise((resolve, reject) => {
|
||||
loader.load(url, (gltf) => resolve(gltf.scene), undefined, reject);
|
||||
});
|
||||
}
|
||||
|
||||
function extractHierarchy(obj, depth = 0) {
|
||||
const nodes = [];
|
||||
obj.traverse((child) => {
|
||||
nodes.push({
|
||||
name: child.name || '(unnamed)',
|
||||
type: child.type,
|
||||
position: child.position.clone(),
|
||||
rotation: {
|
||||
x: THREE.MathUtils.radToDeg(child.rotation.x),
|
||||
y: THREE.MathUtils.radToDeg(child.rotation.y),
|
||||
z: THREE.MathUtils.radToDeg(child.rotation.z),
|
||||
order: child.rotation.order
|
||||
},
|
||||
scale: child.scale.clone(),
|
||||
isMesh: child.isMesh,
|
||||
isGroup: child.isGroup,
|
||||
parent: child.parent ? child.parent.name : null
|
||||
});
|
||||
});
|
||||
return nodes;
|
||||
}
|
||||
|
||||
async function compare() {
|
||||
try {
|
||||
statusEl.textContent = '⏳ Loading CLOSED door model...';
|
||||
const closedScene = await loadModel('V2.5.1 AAA ENSAMBLE CABINET MAIN REVIT puerta cerrada.glb');
|
||||
|
||||
statusEl.textContent = '⏳ Loading OPEN door model...';
|
||||
const openScene = await loadModel('V2.5.1 AAA ENSAMBLE CABINET MAIN REVIT puerta abierta.glb');
|
||||
|
||||
statusEl.textContent = '✅ Both models loaded! Comparing...';
|
||||
|
||||
const closedNodes = extractHierarchy(closedScene);
|
||||
const openNodes = extractHierarchy(openScene);
|
||||
|
||||
// Build lookup maps
|
||||
const closedMap = {};
|
||||
closedNodes.forEach(n => { closedMap[n.name] = n; });
|
||||
const openMap = {};
|
||||
openNodes.forEach(n => { openMap[n.name] = n; });
|
||||
|
||||
// Find differences
|
||||
let html = '';
|
||||
|
||||
// 1. Full hierarchy
|
||||
html += '<div class="section"><h2>📋 Full Scene Hierarchy (Closed Model)</h2>';
|
||||
html += '<table><tr><th>Name</th><th>Type</th><th>Parent</th><th>Position</th><th>Rotation (deg)</th></tr>';
|
||||
closedNodes.forEach(n => {
|
||||
html += `<tr>
|
||||
<td>${n.name}</td>
|
||||
<td>${n.type}</td>
|
||||
<td>${n.parent || '-'}</td>
|
||||
<td>(${n.position.x.toFixed(4)}, ${n.position.y.toFixed(4)}, ${n.position.z.toFixed(4)})</td>
|
||||
<td>(${n.rotation.x.toFixed(2)}°, ${n.rotation.y.toFixed(2)}°, ${n.rotation.z.toFixed(2)}°)</td>
|
||||
</tr>`;
|
||||
});
|
||||
html += '</table></div>';
|
||||
|
||||
// 2. Differences
|
||||
html += '<div class="section"><h2>🔴 DIFFERENCES (Parts that MOVED between closed → open)</h2>';
|
||||
html += '<table><tr><th>Name</th><th>Type</th><th>Parent</th><th>Closed Rotation</th><th>Open Rotation</th><th>Delta</th></tr>';
|
||||
|
||||
let diffCount = 0;
|
||||
closedNodes.forEach(cn => {
|
||||
const on = openMap[cn.name];
|
||||
if (!on) return;
|
||||
|
||||
const posChanged = cn.position.distanceTo(on.position) > 0.001;
|
||||
const rotChanged = (
|
||||
Math.abs(cn.rotation.x - on.rotation.x) > 0.1 ||
|
||||
Math.abs(cn.rotation.y - on.rotation.y) > 0.1 ||
|
||||
Math.abs(cn.rotation.z - on.rotation.z) > 0.1
|
||||
);
|
||||
|
||||
if (posChanged || rotChanged) {
|
||||
diffCount++;
|
||||
const dx = (on.rotation.x - cn.rotation.x).toFixed(2);
|
||||
const dy = (on.rotation.y - cn.rotation.y).toFixed(2);
|
||||
const dz = (on.rotation.z - cn.rotation.z).toFixed(2);
|
||||
|
||||
html += `<tr class="diff">
|
||||
<td><strong>${cn.name}</strong></td>
|
||||
<td>${cn.type}</td>
|
||||
<td>${cn.parent || '-'}</td>
|
||||
<td>(${cn.rotation.x.toFixed(2)}°, ${cn.rotation.y.toFixed(2)}°, ${cn.rotation.z.toFixed(2)}°)</td>
|
||||
<td>(${on.rotation.x.toFixed(2)}°, ${on.rotation.y.toFixed(2)}°, ${on.rotation.z.toFixed(2)}°)</td>
|
||||
<td><strong>Δ(${dx}°, ${dy}°, ${dz}°)</strong></td>
|
||||
</tr>`;
|
||||
|
||||
if (posChanged) {
|
||||
html += `<tr class="diff">
|
||||
<td colspan="3">↳ Position also changed</td>
|
||||
<td>(${cn.position.x.toFixed(4)}, ${cn.position.y.toFixed(4)}, ${cn.position.z.toFixed(4)})</td>
|
||||
<td>(${on.position.x.toFixed(4)}, ${on.position.y.toFixed(4)}, ${on.position.z.toFixed(4)})</td>
|
||||
<td></td>
|
||||
</tr>`;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (diffCount === 0) {
|
||||
html += '<tr><td colspan="6">No differences found in rotation or position. The models may use different mesh structures entirely.</td></tr>';
|
||||
}
|
||||
|
||||
html += '</table>';
|
||||
html += `<p>Total differences found: <strong>${diffCount}</strong></p>`;
|
||||
html += '</div>';
|
||||
|
||||
outputEl.innerHTML = html;
|
||||
statusEl.textContent = `✅ Comparison complete! Found ${diffCount} differences.`;
|
||||
|
||||
} catch (err) {
|
||||
statusEl.textContent = '❌ Error: ' + err.message;
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
|
||||
compare();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,22 @@
|
||||
import * as THREE from 'three';
|
||||
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
|
||||
import fs from 'fs';
|
||||
import { Blob } from 'buffer';
|
||||
|
||||
// Simulating a browser environment for Three.js in Node
|
||||
global.Blob = Blob;
|
||||
|
||||
async function inspectModels() {
|
||||
const loader = new GLTFLoader();
|
||||
|
||||
const file1 = 'd:/Bitua-3D-Explorer/Bita-3D-Explorer/V2.5.1 AAA ENSAMBLE CABINET MAIN REVIT puerta cerrada.glb';
|
||||
const file2 = 'd:/Bitua-3D-Explorer/Bita-3D-Explorer/V2.5.1 AAA ENSAMBLE CABINET MAIN REVIT puerta abierta.glb';
|
||||
|
||||
console.log('--- Model Comparison ---');
|
||||
|
||||
// Note: In Node we can't easily load GLB directly with GLTFLoader without more setup
|
||||
// I will use a simple script in the browser console instructions instead if this is too complex for Node.
|
||||
// However, I can just use Three.js in the browser directly.
|
||||
}
|
||||
|
||||
console.log('Inspector script ready. Actually, I can just update index.html to log these comparisons.');
|
||||
@@ -0,0 +1,50 @@
|
||||
const fs = require('fs');
|
||||
|
||||
try {
|
||||
const data = fs.readFileSync('Cabinet v2.5 con eje.glb').toString('binary');
|
||||
const names = new Set();
|
||||
|
||||
// Find json part
|
||||
const jsonStart = data.indexOf('{"');
|
||||
if (jsonStart > -1) {
|
||||
let jsonEnd = data.indexOf('BIN\x00');
|
||||
if (jsonEnd === -1) {
|
||||
jsonEnd = data.indexOf('BIN');
|
||||
}
|
||||
let jsonStr;
|
||||
if (jsonEnd > -1) {
|
||||
// 8 bytes chunk header before BIN
|
||||
jsonStr = data.slice(jsonStart, jsonEnd - 8);
|
||||
} else {
|
||||
jsonStr = data.slice(jsonStart, Math.min(jsonStart + 1000000, data.length));
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = JSON.parse(jsonStr);
|
||||
const nodes = parsed.nodes || [];
|
||||
nodes.forEach(n => {
|
||||
if (n.name && n.name.toUpperCase().includes('BISAGRA')) {
|
||||
names.add(n.name);
|
||||
} else if (n.name && (n.name.toUpperCase().includes('FIJA') || n.name.toUpperCase().includes('MOVIL') || n.name.toUpperCase().includes('PANEL'))) {
|
||||
names.add(n.name);
|
||||
}
|
||||
});
|
||||
console.log("JSON Parse successful.");
|
||||
console.log([...names].sort());
|
||||
} catch (e) {
|
||||
console.log("Failed parsing JSON:", e.message);
|
||||
// fallback
|
||||
const parts = data.split('"name":"');
|
||||
for (let i = 1; i < parts.length; i++) {
|
||||
const name = parts[i].split('"')[0];
|
||||
if (name.toUpperCase().includes('BISAGRA') || name.toUpperCase().includes('FIJA') || name.toUpperCase().includes('MOVIL') || name.toUpperCase().includes('PANEL')) {
|
||||
names.add(name);
|
||||
}
|
||||
}
|
||||
console.log("Fallback extraction:");
|
||||
console.log([...names].sort());
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
console.error(e);
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
const fs = require('fs');
|
||||
|
||||
function findBarra(filePath) {
|
||||
const buffer = fs.readFileSync(filePath);
|
||||
const content = buffer.toString('utf8');
|
||||
|
||||
// Find all occurrences of names starting with "Bar" or "led"
|
||||
const regex = /"name"\s*:\s*"([^"]*bar[^"]*)"/gi;
|
||||
let match;
|
||||
const results = new Set();
|
||||
while ((match = regex.exec(content)) !== null) {
|
||||
results.add(match[1]);
|
||||
}
|
||||
|
||||
const regex2 = /"name"\s*:\s*"([^"]*led[^"]*)"/gi;
|
||||
while ((match = regex2.exec(content)) !== null) {
|
||||
results.add(match[1]);
|
||||
}
|
||||
|
||||
console.log('Found names:', Array.from(results));
|
||||
}
|
||||
|
||||
findBarra('Cabinet v2.5 con eje.glb');
|
||||
+1741
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,51 @@
|
||||
const fs = require('fs');
|
||||
|
||||
function inspectMesh(filePath, query) {
|
||||
const buffer = fs.readFileSync(filePath);
|
||||
const jsonLen = buffer.readUInt32LE(12);
|
||||
const jsonBuf = buffer.slice(20, 20 + jsonLen);
|
||||
const gltf = JSON.parse(jsonBuf.toString());
|
||||
|
||||
console.log(`Inspecting mesh named "${query}"...`);
|
||||
|
||||
let targetMesh = null;
|
||||
let targetNode = null;
|
||||
|
||||
if (gltf.nodes) {
|
||||
gltf.nodes.forEach((n, i) => {
|
||||
if (n.name && n.name.toUpperCase().includes(query.toUpperCase())) {
|
||||
console.log(`Node [${i}]: ${n.name}`);
|
||||
targetNode = n;
|
||||
if (n.mesh !== undefined) {
|
||||
targetMesh = gltf.meshes[n.mesh];
|
||||
console.log(` Linked Mesh: ${targetMesh.name || 'unnamed'}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (!targetMesh && gltf.meshes) {
|
||||
gltf.meshes.forEach((m, i) => {
|
||||
if (m.name && m.name.toUpperCase().includes(query.toUpperCase())) {
|
||||
console.log(`Mesh [${i}]: ${m.name}`);
|
||||
targetMesh = m;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (targetMesh) {
|
||||
console.log('\nMesh Details:');
|
||||
targetMesh.primitives.forEach((p, i) => {
|
||||
console.log(` Primitive [${i}]:`);
|
||||
console.log(` Attributes: ${Object.keys(p.attributes).join(', ')}`);
|
||||
if (p.material !== undefined) {
|
||||
const mat = gltf.materials[p.material];
|
||||
console.log(` Material: ${mat.name || 'unnamed'}`);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
console.log('Target mesh not found.');
|
||||
}
|
||||
}
|
||||
|
||||
inspectMesh('Cabinet v2.5 con eje.glb', 'Solid1_61');
|
||||
@@ -0,0 +1,21 @@
|
||||
const fs = require('fs');
|
||||
|
||||
function listAllNames(filePath) {
|
||||
const buffer = fs.readFileSync(filePath);
|
||||
|
||||
// Simple way to find names in a GLB: look for the JSON chunk
|
||||
const jsonBuf = buffer.slice(20, 20 + buffer.readUInt32LE(12));
|
||||
const gltf = JSON.parse(jsonBuf.toString());
|
||||
|
||||
console.log('--- MESHES ---');
|
||||
if (gltf.meshes) {
|
||||
gltf.meshes.forEach(m => console.log(m.name));
|
||||
}
|
||||
|
||||
console.log('\n--- NODES ---');
|
||||
if (gltf.nodes) {
|
||||
gltf.nodes.forEach(n => console.log(n.name));
|
||||
}
|
||||
}
|
||||
|
||||
listAllNames('Cabinet v2.5 con eje.glb');
|
||||
@@ -0,0 +1,7 @@
|
||||
import * as THREE from 'three';
|
||||
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
|
||||
import fs from 'fs';
|
||||
|
||||
// To run this in node, I need to do something simpler since I don't have a DOM.
|
||||
// Actually, let's just use `parse` from gltf-pipeline or just regular expression on the JSON string.
|
||||
// I will just read the GLB JSON header.
|
||||
@@ -0,0 +1,28 @@
|
||||
const fs = require('fs');
|
||||
|
||||
function searchNames(filePath, query1, query2) {
|
||||
const buffer = fs.readFileSync(filePath);
|
||||
const jsonLen = buffer.readUInt32LE(12);
|
||||
const jsonBuf = buffer.slice(20, 20 + jsonLen);
|
||||
const gltf = JSON.parse(jsonBuf.toString());
|
||||
|
||||
console.log(`Searching for "${query1}" and "${query2}"...`);
|
||||
|
||||
if (gltf.nodes) {
|
||||
gltf.nodes.forEach((n, i) => {
|
||||
if (n.name && (n.name.includes(query1) || n.name.includes(query2))) {
|
||||
console.log(`Node [${i}]: ${n.name}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (gltf.meshes) {
|
||||
gltf.meshes.forEach((m, i) => {
|
||||
if (m.name && (m.name.includes(query1) || m.name.includes(query2))) {
|
||||
console.log(`Mesh [${i}]: ${m.name}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
searchNames('Cabinet v2.5 con eje.glb', '37', '41');
|
||||
@@ -0,0 +1,33 @@
|
||||
const THREE = require('three');
|
||||
const { GLTFLoader } = require('three/examples/jsm/loaders/GLTFLoader.js');
|
||||
const fs = require('fs');
|
||||
const { JSDOM } = require('jsdom');
|
||||
|
||||
// Mock window and document for GLTFLoader
|
||||
const dom = new JSDOM();
|
||||
global.window = dom.window;
|
||||
global.document = dom.window.document;
|
||||
global.navigator = dom.window.navigator;
|
||||
|
||||
const loader = new GLTFLoader();
|
||||
|
||||
const data = fs.readFileSync('Cabinet v2.5 con eje.glb');
|
||||
const arrayBuffer = data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
||||
|
||||
loader.parse(arrayBuffer, '', (gltf) => {
|
||||
const targetNames = ['Solid1_114', 'Solid1_37', 'Solid1_41'];
|
||||
console.log('--- Searching for specific meshes ---');
|
||||
gltf.scene.traverse((child) => {
|
||||
if (targetNames.includes(child.name)) {
|
||||
console.log(`Found: ${child.name} | Type: ${child.type} | Parent: ${child.parent ? child.parent.name : 'None'}`);
|
||||
}
|
||||
// Also check if they are contained in the name
|
||||
targetNames.forEach(tn => {
|
||||
if (child.name.includes(tn) && child.name !== tn) {
|
||||
console.log(`Partial Match: ${child.name} (contains ${tn}) | Type: ${child.type}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
}, (err) => {
|
||||
console.error(err);
|
||||
});
|
||||
Reference in new issue
Block a user