gkjohnson / three-mesh-bvh

A BVH implementation to speed up raycasting and enable spatial queries against three.js meshes.
https://gkjohnson.github.io/three-mesh-bvh/example/bundle/raycast.html
MIT License
2.52k stars 265 forks source link

raycaster.firstHitOnly and raycaster.intersectObjects difficult #527

Closed Runasia closed 1 year ago

Runasia commented 1 year ago

Hi, I wirte this const raycaster = new Raycaster() raycaster.firstHitOnly = true;

attribute firstHitOnly of Raycaster() not exist in three.module.js.(i try ctrl+f
the version is "name": "three", "version": "0.149.0",

another difficult is raycaster.intersectObjects return a undefine value. this is my code raycaster.setFromCamera(mouse, camera); raycaster.intersectObjects(ifcModels,true); I debug in Google Chrome and make sure mouse & camera & ifcmodels has value image

and thanks seeing this issue.

gkjohnson commented 1 year ago

attribute firstHitOnly of Raycaster() not exist in three.module.js.(i try ctrl+f

This is specified as a part of the three-mesh-bvh and the dts files.

Can you check if the raycasting works correctly without three-mesh-bvh? There should be no difference in the raycasting results between three.js and three-mesh-bvh.

Runasia commented 1 year ago

This is specified as a part of the three-mesh-bvh and the dts files.

Thanks!Because of your suggestion i finded that . due to import {Raycaster, Vector2} from "three"; So i make a mistake to find Raycaster's attribute (firstHitOnly) in three.js . and my idea even can't find not defined firstHitOnly and think Raycaster just belone in three.module.js , Maybe I am too rely on it.

Can you check if the raycasting works correctly without three-mesh-bvh? There should be no difference in the raycasting results between three.js and three-mesh-bvh.

It's work!! And it can find expressId !

ifcModels = []
  ifcLoader.load('/bimModel/rac_advanced_sample_project.ifc', function (ifcModel) {
    scene.add(ifcModel);
    ifcModels.push(ifcModel)
    // ifcLoader.ifcManager.setupThreeMeshBVH(

    //     acceleratedRaycast,
    //     computeBoundsTree,
    //     disposeBoundsTree
    // );
  });

Thanks for your help!@gkjohnson.

gkjohnson commented 1 year ago

You should submit a bug to IFC.js with a minimal example of the problem, then. There should be no difference in results between three.js' raycast results and three-mesh-bvhs.