Raycasting URDFRobot & URDFLink objects

Hello everyone,

I’m currently raycasting objects, which works perfectly for Meshes. But doesn’t work for URDFRobot objects.

URDFRobots are actually child classes from Object3D, therefore I assumed that it will also work for them but no success so far.
I use the urdf-loader - npm to load the URDF Objects, therefore I’m not sure if the threejs discourse forum is the right place to ask this question.

    const intersects = this.raycaster.intersectObjects(this.scene.children);
    if (intersects.length > 0) {
      if (this.INTERSECTEDONCLICK.value != intersects[0].object) {
        this.transformControls.detach()
        this.INTERSECTEDONCLICK.next(intersects[0].object);
        this.transformControls.attach(this.INTERSECTEDONCLICK.value)
      }
    } 

I’m sure the URDFRobot is on the “this.scene.children” list. But so far no luck intersecting the URDFRobot.

any ideas?

I couldn’t create a fiddle I spend couple of hours creating a working jsfiddle, but did not succeed either, since I couldn’t use the URDFLoader from the external library using CDN.

The URDF Loader classes support raycasting but without a working example it’s hard to help. Which version of three.js are you using?

I couldn’t create a fiddle I spend couple of hours creating a working jsfiddle, but did not succeed either, since I couldn’t use the URDFLoader from the external library using CDN.

The library should work just fine via unpkg.com or skypack.dev to convert the bare module imports. There’s also a UMD variant available on unpkg, as well, if you’re not using module imports.

Hi Garrett,

I tried creating my first fiddle but was not able to make it run the URDFLoader, therefore I was not able to create a full example.

https://jsfiddle.net/ugurkoysuren/xLnrkb79/2/

What am I missing?

Thank you in advance!

If you open up the console you can see what the issues are. It looks like you’re loading URDFLoader multiple times? And the URDF you’re loading requires ColladaLoader so that must be included on the page.