I am working on an object editor in three.js. Right now I am struggling with the one problem. I load a point cloud, make a clone of it and store it as the initial default object and perform a matrix rotation on the loaded point cloud.
let loaderMaster = new THREE.PLYLoader();
loaderMaster.load('./ply_data/rawMaster.ply', function(mGeom) {
var scanMaterialM = new THREE.PointsMaterial({
size: 15,
color: 0xff0000
});
mGeom.computeVertexNormals();
masterCloud = new THREE.Points(mGeom, scanMaterialM);
masterCloud.rotation.x = -90 * Math.PI / 180;
masterCloud.geometry.scale(-1, -1, 1);
masterCloud.name = "masterMesh";
masterRawGeo = masterCloud.clone();
scene.add(masterCloud)
transformControlmaster.attach(masterCloud)
scene.add(transformControlmaster);
transform('master');
});
Everything works fine in this first step. When something has to be performed a second time. I remove the current point cloud from the scene and replace it with the initial default clone and then perform the new matrix manipulation on it. But the result is complete rubbish. It seems even I removed the object and cleaned the scene somehow the first manipulation is somehow stored. What is the best practice to change replace the geometry with a deep copy clone, fully uninfluenced by previous manipulations?
Thanks a lot in advance!!!
If you actually transform the geometry (e.g. via BufferGeometry.translate()), you have to create a copy of mGeom
. If you transform the THREE.Points
object instead (the actual point cloud), the geometry data won't change. Creating a new instance of THREE.Points
with the same geometry object should already work.
If that is not the case, consider to demonstrate your issue with a live example.