Wrong normal with raycaster

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?!

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);

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;

Have a look at this example:
and its source code:

1 Like

A working example, based on the example with decals:

1 Like

thank you all ! It works:grin:

You’re welcome :slight_smile: :beers: