Sign in to follow this  

How to use Scene.pickWithRay ?

Recommended Posts

I'm trying to pick a mesh with Scene.pickWithRay and having problems.

	    var pickResult = scene.pickWithRay(ray, function (mesh) {
	      if (mesh.voxelData) {
	        return mesh;

	    var mesh = pickResult.pickedMesh; //Get the mesh picked

I can trigger the debugger statement no problem with the mesh I want.

The mesh looks like it has the required properties:

function (){return!!this._isEnabled&&(!this.parent||this.parent.isEnabled())}

I'm not sure what to do in the predicate function. The docs could be more clear:

I've tried returning true and returning the mesh. Both situations `pickResult.pickedMesh` is undefined.

Share this post

Link to post
Share on other sites

In the predicate function you write your own logic of what meshes should be valid or not for picking.

In your case that is if the mesh has voxelData so what you should do there is return true. As long as mesh has voxelData it will be checked against the ray. Just because the predicate function returns true doesn't mean the ray will hit.
So as RaananW said if your debugger statement is executed the ray most likely doesn't hit your mesh.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.