Closed goverdhanpaliwal closed 11 months ago
The highlight mesh and the mesh being selected must have the same transformations for scale, rotation, and position otherwise they will not line up.
Hey @gkjohnson, As per what I got from your previous reply, I have set
highlightMesh = new THREE.Mesh()
highlightMesh.geometry = mesh.geometry.clone();
highlightMesh.position = mesh.position.clone();
highlightMesh.rotation = mesh.rotation.clone();
highlightMesh.scale = mesh.scale.clone();
highlightMesh.geometry.drawRange.count = 0;
highlightMesh.material = new THREE.MeshBasicMaterial({
opacity: 0.05,
transparent: true,
depthWrite: false,
});
highlightMesh.material.color.set(0xff9800).convertSRGBToLinear();
highlightMesh.renderOrder = 1;
group.add(highlightMesh);
highlightWireframeMesh = new THREE.Mesh();
highlightWireframeMesh.geometry = highlightMesh.geometry;
highlightWireframeMesh.position = mesh.position.clone();
highlightWireframeMesh.rotation = mesh.rotation.clone();
highlightWireframeMesh.scale = mesh.scale.clone();
highlightWireframeMesh.material = new THREE.MeshBasicMaterial({
opacity: 0.25,
transparent: true,
wireframe: true,
depthWrite: false,
});
highlightWireframeMesh.material.color.copy(highlightMesh.material.color);
highlightWireframeMesh.renderOrder = 2;
group.add(highlightWireframeMesh);
After setting this, I'm not getting the appropriate results. Can you please tell me if this is the correct way to set the position, rotation, and scale, or is there something else I'm missing?
highlightWireframeMesh.position = mesh.position.clone(); highlightWireframeMesh.rotation = mesh.rotation.clone(); highlightWireframeMesh.scale = mesh.scale.clone();
This is not a valid way to modify the position, rotation, or scale of an object in three.js. You need to use the copy
function to copy data from the target vectors and rotations.
If you need help understanding the fundamentals of how to manipulate transforms on three.js objects I recommend reading through the three.js docs and asking at the forum
Three-mesh-bvh lasso selection is not working correctly with different models
We are trying to add a cropping 3D GLB model feature in our application using the lasso select tool. some exported model from Blender is not showing properly the selected area. For example doll model looks fine Windturbine has issue Can you please debug this model and help me to solve this issue, I am not able to figure out the reason for the error.
To Reproduce Steps to reproduce the behaviour: Run the pasted code below. attached codesandbox url https://codesandbox.io/s/rzqhvk Code
Live example https://codesandbox.io/s/rzqhvk
Expected behavior
Screenshots
Platform: