hiukim / mind-ar-js

Web Augmented Reality. Image Tracking, Face Tracking. Tensorflow.js
MIT License
2.16k stars 399 forks source link

Is it possible to use raycaster with Three.js and Mind-ar? #299

Closed BrunoFigueiraBarros closed 1 year ago

BrunoFigueiraBarros commented 1 year ago

Is it possible to use raycaster with Three.js and Mind-ar?

Does anyone have an example using GLTF

BrunoFigueiraBarros commented 1 year ago

@hiukim could you show some example?

hiukim commented 1 year ago

I think it should be the same as how you would normally use raycaster.

BrunoFigueiraBarros commented 1 year ago

@hiukim I'm using normal raycast but it's not working

  function onClick() {

            event.preventDefault();

            mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
            mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;

            raycaster.setFromCamera(mouse, camera);

            var intersects = raycaster.intersectObjects(scene.children, true);

            if (intersects.length > 0) {

                intersects[0].object.material.color.set( 0xff0000 );
                console.log('Intersection:', intersects[0]);

            }
            render();
        }
hiukim commented 1 year ago

I can't see any obvious error with your code at first sight. There might be bugs on other parts, I'm not sure. Or there might be bugs on three.js side or the loaded models.

BrunoFigueiraBarros commented 1 year ago

I managed to solve it, thanks Old render(); New renderer.render(scene, camera);