Can someone in this thread pls tell me, how can I make a bounding box with the following coordinates data:
{
pos:{
x:49754.891900327755,
y:36682.65824592283,
z:108.6824678750207,
},
rot:{
x:0,
y:0,
z:0.5331106969643833,
},
scale:{
x:12.745152036697608,
y:3.4765292357818036,
z:3.7974907141831835
}
}
My current implementation works but does not display on the screen as the position coordinates are too high
createBoundingBoxInstance(
geometry: THREE.BoxBufferGeometry,
color: string | THREE.Color | number,
coords: Coordinates,
vector: THREE.Vector3,
label: string,
wireframe?: boolean,
transparent?: boolean,
depthWrite?: boolean,
doubleSide?: boolean,
opacity?: number
) {
const _color = color ? color : this.defaults.boundingBoxConfig.color;
const _wireframe = wireframe
? wireframe
: this.defaults.boundingBoxConfig.wireframe;
const _transparent = transparent
? transparent
: this.defaults.boundingBoxConfig.transparent;
const _depthWrite = depthWrite
? depthWrite
: this.defaults.boundingBoxConfig.depthWrite;
const _side = doubleSide
? THREE.DoubleSide
: this.defaults.boundingBoxConfig.side;
const _opacity = opacity
? opacity
: this.defaults.boundingBoxConfig.opacity;
const material = new THREE.MeshBasicMaterial({
color: _color,
wireframe: _wireframe,
transparent: _transparent,
opacity: _opacity,
depthWrite: _depthWrite,
side: _side,
});
material.name = label;
const cube = new THREE.Mesh(geometry, material);
cube.visible = false; // initialize as an invisible bounding box.
cube.position.x = coords.position.x;
cube.position.y = coords.position.y;
cube.position.z = coords.position.z;
cube.rotation.x = coords.rotation.x;
cube.rotation.y = coords.rotation.y;
cube.rotation.z = coords.rotation.z;
cube.scale.x = coords.scale.x;
cube.scale.y = coords.scale.y;
cube.scale.z = coords.scale.z;
const myText = this.addTextToBBox(label);
myText.sync();
cube.add(myText);
this.boundingBoxText.push(myText);
cube.updateWorldMatrix(true, false);
vector.project(this.camera);
this.scene.add(cube);
this.scene.matrixWorldNeedsUpdate=true
}
I tried using worldToLocal but no luck.
Here is one related link with this topic opened by me
Can someone pls let me know/help how are large coordinates in three js handled so that they appear on the screen.
The final output of my implementation is a point cloud output which works fine and looks like this
But I want to display this point cloud along with the bounding boxes something like this
