Git Product home page Git Product logo

Comments (6)

gkjohnson avatar gkjohnson commented on May 17, 2024

@mquander

Do you feel this be an option on the bounds tree constructor or the raycaster, a la firstHitOnly so it can be more easily used globally?

Constructor Option

geometry.computeBoundsTree({ intersectLeafNodesOnly: true });

// ...

geometry.intersectLeafNodesOnly = false;

Raycaster Option

raycaster.intersectLeafNodesOnly = true;
raycaster.intersectObjects( scene );

I'm thinking both options could be available and if the raycaster option is set to true then it overrides the setting on the geometry bounds tree. The same thing could be added for firstHitOnly so it's available as a constructor option, as well.

from three-mesh-bvh.

gkjohnson avatar gkjohnson commented on May 17, 2024

The default return value for a raycast hit includes the following values which won't all be available on a leaf node hit:

{
  distance,
  point,
  face,
  faceIndex,
  object,
  uv
}

I'm imagining face, faceIndex, and uv all being set to null in the case of a leaf node hit. Maybe an extra boolean value of leafNodeHit or reference to the hit tree node can be included to indicate that triangles were not checked.

from three-mesh-bvh.

gkjohnson avatar gkjohnson commented on May 17, 2024

Lastly I'm expecting that the behavior when Raycaster.firstHitOnly = false is to return the hits on all leaf nodes that the ray intersects. I'm not sure if there's a better option.

from three-mesh-bvh.

mqp avatar mqp commented on May 17, 2024

It seems to me like an option on the bounds tree to stop at leaf nodes and an option on the raycaster to only get the first intersection are independently useful and reasonable:

  1. computeTruncatedBoundsTree + firstHitOnly = cheap construction, cheap raycast, get closest leaf node volume intersected
  2. computeTruncatedBoundsTree + !firstHitOnly = cheap construction, more expensive raycast, get all leaf node volumes intersected
  3. computeFullBoundsTree + firstHitOnly = same as in current implementation
  4. computeFullBoundsTree + !firstHitOnly = same as in current implementation

from three-mesh-bvh.

gkjohnson avatar gkjohnson commented on May 17, 2024

I agree there should be two different flags -- sorry I was unclear. My question was about whether or not there should be an "intersectLeafNodesOnly" flag on both the raycaster and in the BVH constructor.

The flag on the BVH would mean that only that BVH would stop checking at the leafs. If it was set on the raycaster then the raycast would stop at the leaf on every bounds tree being cast against, like a global override. I think the flag in the constructor options is generally more flexible and has more utility so I vote for that until there's a need otherwise.

from three-mesh-bvh.

mqp avatar mqp commented on May 17, 2024

Tree construction and raycasting got way faster and more memory-efficient since we wrote this, and we think it can get even better, so I'm not sure it seems like a high priority anymore.

from three-mesh-bvh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.