Hi guys.
I want to get position and normal through raycaster. It works fine when the box was not rotated.
When the box was rotated, raycaster get wrong normals.
How can I fixed this?!
Hi guys.
I want to get position and normal through raycaster. It works fine when the box was not rotated.
When the box was rotated, raycaster get wrong normals.
How can I fixed this?!
Hi!
Could you provide the code of what and how you do with raycaster and given normal?
function onMouseDown(event) {
mouse.x = (event.clientX / renderer.domElement.clientWidth) * 2 - 1;
mouse.y = - (event.clientY / renderer.domElement.clientHeight) * 2 + 1;
raycaster.setFromCamera(mouse, camera);
// See if the ray from the camera into the world hits one of our meshes
var intersects = raycaster.intersectObjects(objectList);
// Toggle rotation bool for meshes that we clicked
if (intersects.length > 0) {
helper.position.set(0, 0, 0);
helper.lookAt(intersects[0].face.normal);
helper.position.copy(intersects[0].point);
}
}
I use transformControls to rotate the box
transformControl = new THREE.TransformControls(camera, renderer.domElement);
transformControl.addEventListener('change', render);
transformControl.addEventListener('dragging-changed', function (event) {
orbitControl.enabled = !event.value;
});
renderScene.add(transformControl);
Have a look at this example:
https://threejs.org/examples/?q=decals#webgl_decals
and its source code:
A working example, based on the example with decals:
thank you all ! It works:grin:
You’re welcome