Git Product home page Git Product logo

Comments (6)

gkjohnson avatar gkjohnson commented on May 27, 2024

Raycasting is handled with a custom traversal algorithm so the raycast function on each mesh is replaced with a custom one on load to avoid redundant raycasting work. It's the only way to disable raycasting on an object in three.js.

Can you explain in more detail what you're trying to do? Why do you need to replace the raycasting function?

from 3dtilesrendererjs.

Junior2Ran avatar Junior2Ran commented on May 27, 2024

First, I still cannot get it why the code is written like Object.getPrototypeOf(c).raycast rather than c.raycast. I assume that it can also work with your custom traverse raycasting design above.

In my project, 3DTiles data is BIM which is so heavy and large. Even the raycasting has been optimised, the performance is still not good. In fact, I'm gonna replace raycast function to BVH. I noticed that you are also the BVH author, is there an elegant way to deal with it?

from 3dtilesrendererjs.

gkjohnson avatar gkjohnson commented on May 27, 2024

First, I still cannot get it why the code is written like Object.getPrototypeOf(c).raycast rather than c.raycast. I assume that it can also work with your custom traverse raycasting design above.

As I said the raycasting performs custom traversal by overriding the root "raycast" function and it's required to replace the existing raycast function with an "empty" one so duplicate raycasting is not performed. The prototype raycast function is retrieved when leaf nodes are traversed to so we have the associated raycast function associated with the object type. Because we replace the original raycast function with the empty one it's no longer available.

In my project, 3DTiles data is BIM which is so heavy and large. Even the raycasting has been optimised, the performance is still not good. In fact, I'm gonna replace raycast function to BVH. I noticed that you are also the BVH author, is there an elegant way to deal with it?

three-mesh-bvh suggests overriding the prototype of Mesh in the documentation which will work just fine here since the prototype is modified:

Mesh.prototype.raycast = accleratedRaycast;

It's possible to add something that allows for more control over this but I'd like to avoid it if possible. At least this limitation should be listed in the documentation, I'd think.

from 3dtilesrendererjs.

ligaofeng0901 avatar ligaofeng0901 commented on May 27, 2024

three-mesh-bvh suggests overriding the prototype of Mesh in the documentation which will work just fine here since the prototype is modified:

Mesh.prototype.raycast = accleratedRaycast;

I don't think this is an elegant way. Using c.raycast is a better way. I only want to modify raycasting on some meshes, not all. Mesh.prototype.raycast is a global affecting API. This may cause some compatible issues when using some other third-party libaraies

from 3dtilesrendererjs.

gkjohnson avatar gkjohnson commented on May 27, 2024

I don't think this is an elegant way. Using c.raycast is a better way.

I'm not interested in repeating what I've already stated previously. If there's something specific you don't understand about why the current approach is being used I'm happy to answer. But statements like this are not helpful.

I only want to modify raycasting on some meshes, not all.

I won't be dealing with hypothetical situations. Please be specific about what function you're replacing the raycast one with and why.

The current "optimizedRaycast" and "firstHitOnly" options enabled by the overwritten raycast functions provide a 2-5x performance improvement over the naive raycast approach in some cases. And it would be even higher (4-10x or more) if there were a way to get rid of some other unnecessary three.js overhead.

from 3dtilesrendererjs.

gkjohnson avatar gkjohnson commented on May 27, 2024

I'll close this until more information or details can be provided on the purpose. Ultimately changes need to be made in three.js to support this. Or a custom raycaster solution needs to be provided, which I don't think is an elegant solution.

from 3dtilesrendererjs.

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.