HollowBond/Public/ecma/Objects/Debug/HoleObjectDebug.ecma.js

46 lines
1.4 KiB
JavaScript

"use strict";
const HoleObjectDebug = (function(){
const HoleObjectDebug = function(hollow_bond, model){
const self = this;
this.model = model;
const floor_height = hollow_bond.room_height || 3,
width = model.xt - model.xf,
floors = model.yt - model.yf,
depth = model.zt - model.zf,
height = floors * floor_height;
this.mesh = new THREE.Group();
// 1. Geometría compartida y material de caras translúcidas
const geometry = hollow_bond.inspector.geometries.hole.get(width, floors, depth),
face_material = hollow_bond.inspector.materials.hole.get(),
box_mesh = new THREE.Mesh(geometry, face_material);
this.mesh.add(box_mesh);
// 2. Líneas de aristas para marcar vértices y límites
const edges_geo = new THREE.EdgesGeometry(geometry),
edge_material = hollow_bond.inspector.materials.hole.get_edges(),
edges_mesh = new THREE.LineSegments(edges_geo, edge_material);
this.mesh.add(edges_mesh);
// 3. Posicionamiento en el mundo
this.mesh.position.set(
model.xf + width / 2,
(model.yf * floor_height) + (height / 2),
model.zf + depth / 2
);
this.destroy = () => {
if(edges_geo) edges_geo.dispose();
};
};
return HoleObjectDebug;
})();