@prisoner849 I am opening this thread again because the issue I am facing right now is related to this topic. So as you know already I am plotting a pcd file. and then also plotting bboxes based on the supplied coordinates. Recently, I got this pcd file
0.zip (2.3 MB)
But on trying to plot the pcd file on the viewer, its showing nothing.
The method I use to plot pcd is follows:
private loadPCD() {
const loader = new PCDLoader();
loader.load(
this.url,
(points: THREE.Points) => {
if (this.pcdLoaded) {
return;
}
points.userData.boundingBoxAnnotationContent =
this.boundingBoxAnnotationContent;
const geometry: THREE.BufferGeometry = <THREE.BufferGeometry>(
points.geometry
);
const material: THREE.PointsMaterial = <THREE.PointsMaterial>(
points.material
);
//geometry.center();
//geometry.rotateX(Math.PI);
material.side = THREE.DoubleSide;
material.color.setHex(this.defaults.hex);
this.pointCloud = points;
this.grid = this.setGridHelper();
this.scene.add(this.grid);
this.scene.add(this.pointCloud);
this.populate3DBoundingBoxAnnotation();
this.render();
if (this.cameraControlsEnabled) this.animate();
this.saveCameraControlState();
this.centerOfLidar = this.getVisualCenterOfPolygon(geometry);
const count = geometry.attributes.position.count;
this.numberOfPointsLoaded = count;
this.numberOfPointsShowing = this.numberOfPointsLoaded;
this.isLoading = false;
this.event.emit({
trigger: "lidar-data-loaded-trigger",
loaded: true,
referencedAnnotation: {
resourceHasAnnotatedJSON: this.resourceHasAnnotatedJSON,
annotationContent: this.boundingBoxAnnotationContent,
},
});
this.pcdLoaded = true;
this.initStats();
this.evaluateDistanceFromOrigin(geometry);
},
(progress) => {
this.progress = Math.round((100 * progress.loaded) / progress.total);
},
(err) => {
console.error(err);
this.isLoading = false;
this.event.emit({
trigger: "lidar-data-loaded-trigger",
loaded: false,
referencedAnnotation: {
resourceHasAnnotatedJSON: this.resourceHasAnnotatedJSON,
annotationContent: this.boundingBoxAnnotationContent,
},
});
this.loadingError = true;
}
);
}
If I uncomment the geometry change in the above method, the point shows up on the screen but if I comment it, it does not show the points on screen. And in both cases, the bounding boxes with the applied coordinates are not shown as well.
Here is the bbox coordinate data with rotation.z negated already from the initial source.
[
{
"class_id": 7,
"name": "Vehicle: Truck:2",
"val": [],
"coordinates": {
"position": {
"x": 49701.430889590025,
"y": 36669.48588375059,
"z": 108.28206422988977
},
"rotation": {
"x": 0,
"y": 0,
"z": -1.1588591747591366
},
"scale": {
"x": 6.527588845825132,
"y": 2.7053958469647084,
"z": 3.088753093568613
}
}
},
{
"class_id": 7,
"name": "Vehicle: Truck:3",
"val": [],
"coordinates": {
"position": {
"x": 49803.019495930326,
"y": 36710.521479010895,
"z": 108.73881850510237
},
"rotation": {
"x": 0,
"y": 0,
"z": 0.5487445375123619
},
"scale": {
"x": 12.30766479140657,
"y": 3.3607588655188474,
"z": 3.998681604635891
}
}
},
{
"class_id": 7,
"name": "Vehicle: Truck:1",
"val": [],
"coordinates": {
"position": {
"x": 49754.891900327755,
"y": 36682.65824592283,
"z": 108.6824678750207
},
"rotation": {
"x": 0,
"y": 0,
"z": 0.5331106969643833
},
"scale": {
"x": 12.745152036697608,
"y": 3.4765292357818036,
"z": 3.7974907141831835
}
}
},
{
"class_id": 7,
"name": "Vehicle: Truck:4",
"val": [],
"coordinates": {
"position": {
"x": 49782.54922455341,
"y": 36707.84639024677,
"z": 108.72185596904264
},
"rotation": {
"x": 0,
"y": 0,
"z": -2.7345906594565985
},
"scale": {
"x": 12.555134377146214,
"y": 3.065328958835853,
"z": 4.1331076282010315
}
}
},
{
"class_id": 7,
"name": "Vehicle: Truck:5",
"val": [],
"coordinates": {
"position": {
"x": 49741.74598573557,
"y": 36719.28439844109,
"z": 109.1961204137063
},
"rotation": {
"x": 0,
"y": 0,
"z": -2.6185516904570356
},
"scale": {
"x": 12.492040840733727,
"y": 2.9599363257716074,
"z": 3.277454879289394
}
}
},
{
"class_id": 7,
"name": "Vehicle: Truck:6",
"val": [],
"coordinates": {
"position": {
"x": 49736.46146911247,
"y": 36720.44107252165,
"z": 109.13622880837758
},
"rotation": {
"x": 0,
"y": 0,
"z": -2.592521994924967
},
"scale": {
"x": 2.0797496300919427,
"y": 2.2058505020229275,
"z": 3.2304734340850843
}
}
},
{
"class_id": 7,
"name": "Vehicle: Truck:7",
"val": [],
"coordinates": {
"position": {
"x": 49735.16018826656,
"y": 36723.93703218062,
"z": 109.14892092301095
},
"rotation": {
"x": 0,
"y": 0,
"z": -2.618420575003002
},
"scale": {
"x": 2.570057617341567,
"y": 2.9026862045568005,
"z": 3.369490628625357
}
}
},
{
"class_id": 7,
"name": "Vehicle: Truck:8",
"val": [],
"coordinates": {
"position": {
"x": 49734.01925786012,
"y": 36728.18294314357,
"z": 109.14013250617006
},
"rotation": {
"x": 0,
"y": 0,
"z": -2.6322886166299746
},
"scale": {
"x": 1.5056279558793502,
"y": 0.9114685402080243,
"z": 2.574374945033881
}
}
},
{
"class_id": 7,
"name": "Vehicle: Truck:9",
"val": [],
"coordinates": {
"position": {
"x": 49731.195508937504,
"y": 36733.58976601708,
"z": 108.99684350238908
},
"rotation": {
"x": 0,
"y": 0,
"z": -2.636120184277253
},
"scale": {
"x": 4.810655340916085,
"y": 2.9795990582530196,
"z": 3.7451833488407686
}
}
},
{
"class_id": 7,
"name": "Vehicle: Truck:10",
"val": [],
"coordinates": {
"position": {
"x": 49727.53774149401,
"y": 36735.74911941773,
"z": 109.02745131035608
},
"rotation": {
"x": 0,
"y": 0,
"z": -2.6140092792938177
},
"scale": {
"x": 1.7584739344099969,
"y": 2.6945024844782703,
"z": 3.540029356579609
}
}
},
{
"class_id": 14,
"name": "Pedestrian: Police_officer:1",
"val": [],
"coordinates": {
"position": {
"x": 49707.65490809687,
"y": 36674.67255627485,
"z": 107.4897887384395
},
"rotation": {
"x": 0,
"y": 0,
"z": 2.183734612557144
},
"scale": {
"x": 1.1649735821544855,
"y": 0.6528685587950898,
"z": 1.7922125170513628
}
}
},
{
"class_id": 12,
"name": "Pedestrian: Construction_Worker:1",
"val": [],
"coordinates": {
"position": {
"x": 49777.75286579109,
"y": 36725.43445148972,
"z": 107.89595597364253
},
"rotation": {
"x": 0,
"y": 0,
"z": 2.7086425568669847
},
"scale": {
"x": 0.8775186301537322,
"y": 0.4993571979217251,
"z": 2.0770678551218342
}
}
}
]
And this is how I create each bbox instance
createBoundingBoxInstance(
geometry: THREE.BoxGeometry,
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.scene.add(cube);
this.boundingBoxText.push(myText);
cube.updateWorldMatrix(true, false);
cube.getWorldPosition(vector);
vector.project(this.camera);
}
Note: previously with your solution it worked and plotted both pcd and bbox, but that time the pcd contents and the corresponding bbox coords were relatively smaller numbers, but this time both the pcd number and bbox coords are numerically very high in terms of coordinates, and that is why may be it is not showing up on the screen. Pls help me with a uniform approach for this which should work for any kind of valid pcd file and bbox coordinates.
Expected result is: https://global.discourse-cdn.com/flex035/uploads/threejs/original/3X/0/9/09148a89adedabee7fc529ef4f7ea12eb35fb6da.png
Thanks for your help all throughout this. If you want, I can open another thread on this.
CC @Mugen87 @mrdoob