tahamajs/RR / Docs /visualizer /src /builders /macro_builder.js
tahamajs's picture
download
raw
2.05 kB
/**
* builders/macro_builder.js
* =========================
* Builds consolidated macro bounding volumes for far-view Level-of-Detail (LOD 0).
*/
import * as THREE from 'three';
import { materials, edgeMatMacro } from '../core/materials.js';
import { createLayerLabelSprite } from './label_builder.js';
/**
* Builds macro bounding boxes for far camera zoom distances.
* @param {Array<object>} macroNodes - Macro node definitions from spatialData
* @param {number} offsetX - Column horizontal offset (-4.5 or +4.5)
* @param {boolean} isCompressedSide - True if compressed column
* @param {THREE.Group} macroGroup - Macro scene group
* @param {Array<THREE.Object3D>} visualObjects - Registry array for lifecycle cleanup
* @param {Array<THREE.Mesh>} macroMeshes - Array tracking macro meshes
* @param {Array<THREE.Mesh>} interactableMeshes - Array tracking raycasting interactables
*/
export function buildMacroBlocks(
macroNodes,
offsetX,
isCompressedSide,
macroGroup,
visualObjects,
macroMeshes,
interactableMeshes
) {
if (!macroNodes || !macroNodes.length) return;
macroNodes.forEach(node => {
const geo = new THREE.BoxGeometry(node.width, node.height, node.depth);
const mesh = new THREE.Mesh(geo, materials.macro_box);
mesh.position.set(offsetX, node.y, 0);
mesh.userData = {
...node,
isMacro: true,
side: isCompressedSide ? 'compressed' : 'baseline'
};
const wireGeo = new THREE.EdgesGeometry(geo);
const wireLine = new THREE.LineSegments(wireGeo, edgeMatMacro);
wireLine.raycast = () => {};
mesh.add(wireLine);
macroGroup.add(mesh);
visualObjects.push(mesh);
macroMeshes.push(mesh);
interactableMeshes.push(mesh);
// Macro floating label
const lbl = node.label || node.name || node.parent_layer_name || 'Layer';
createLayerLabelSprite(lbl, offsetX, node.y + node.height / 2 + 0.45, true, macroGroup, visualObjects);
});
}

Xet Storage Details

Size:
2.05 kB
·
Xet hash:
616d8a270178e790bd5929e0d54ab79b9a0f6fc4dc6e907139a6ca48840fd592

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.