How to save mesh imported via 3dmloader as mesh object?

I imported a Rhino3d mesh object via 3dmloader, as shown below. May I ask how to assign it as a mesh object so that I can use it later, e.g., applying raycaster on it? It seems that child.geometry only gives me the first instance of the mesh. Thanks.

// load 3dm files
const loader = new Rhino3dmLoader(); 
loader.setLibraryPath( '/jsm/libs/rhino3dm/' ); 

loader.load('./models/building.3dm', 
            function ( object ) {
                object.traverse ( 
                    function( child ) { 
                        if ( child instanceof THREE.Mesh ) { 
                            child.material = meshMaterial_b; 
                        } 
                    } 
                ); 
                scene.add( object );
                // control.attach( object ); 
                // scene.add( control ); 
            } );

It’s probably best if you save a reference to the entire object. A mesh can consist of a hierarchy of meshes so you want to use all of them for raycasting.

The object reference can then be use by passing it to Raycaster.intersectObject(). You only have to make sure to set the second parameter to true so all descendants of the mesh are checked, too.

Thanks, @Mugen87 May I ask how to “save a reference to the entire object”?

Something like this:

// load 3dm files
const loader = new Rhino3dmLoader(); 
loader.setLibraryPath( '/jsm/libs/rhino3dm/' ); 

let myObject;

loader.load('./models/building.3dm', 
  function ( object ) {
      object.traverse ( 
          function( child ) { 
              if ( child instanceof THREE.Mesh ) { 
                  child.material = meshMaterial_b; 
              } 
          } 
      ); 
      scene.add( object );

      myObject = object;
  } );