GLTF Model not detecting with raycast

Hi I added gltf model but after when I click on the model then it didn’t work. Your help would be appreciated

Is there any way to detect the gltf loader with raycast ?.Is there any person who can help me ?

Any chance to put mode detailed description of the problem, providing an editalbe live code example (jsfiddle, codepen, codesandbox etc.)?

let me do…

Hi, you can share the model?

Thanks for the reply.All things are working but the thing is when I click on model then it shows me specific model mesh instead of all model mesh and one more thing is to show me griphelper as well.I dont know why it’s happening.

Only you know what and how works in your code. Without a live code example, all we can do is fortune-telling. Please, put more effort in asking the question, providing an example, that demonstrates the issue(s).

1 Like

Ok i will share with you in a while

var scope;
class RaycastOnModel {
constructor()
{

    scope=this;
    this.ModelLoad_Scope = new ModelLoad();

    this.ModelLoad_Scope.initScene();

    scope.Raycaster = new Raycaster();

    scope.pointer = new THREE.Vector2();

    this.init();

}

init()

{  

    window.addEventListener('pointermove',scope.mouseMove,false);

    window.addEventListener('click',scope.pickModel);

}

mouseMove(event)

{  

    scope.pointer.x = ( event.clientX / window.innerWidth ) * 2 - 1;

    scope.pointer.y = - ( event.clientY / window.innerHeight ) * 2 + 1;  

}

pickModel()

 {  

    scope.Raycaster.setFromCamera(scope.pointer,scope.ModelLoad_Scope.camera);      

    let intersects = scope.Raycaster.intersectObjects(scope.ModelLoad_Scope.scene.children,true);

    if(intersects.length )

        console.log(intersects);

 }

};

export {RaycastOnModel} ;

scripts are too many so I cant share on live demo .So I send you the code there of ray casting

as you can see when i click on model then it will show many children’s including grid. I want to just click the model which i get the whole object and apply properties accordingly