Three.js: Frustum: request add function

Created on 30 Mar 2020  路  5Comments  路  Source: mrdoob/three.js

Request add Frustum function named containsSphere.code like this

function (sphere) {

        var planes = this.planes;

        for (var i = 0; i < 6; i++) {

            if (planes[i].distanceToPoint(sphere.center) < sphere.radius) {

                return false;

            }

        }

        return true;

    }

It will be useful to judge whether or not to see a whole object.

Enhancement

Most helpful comment

Not sure why you use an instance of Frustum 馃.

I agree that everything that's needed is available but just for some more context OP is probably trying to calculate what is in view of a camera by the hierarchical bounds to the camera frustum -- basically doing manual frustum culling so you know which objects need to be processed further for that frame. The existing Frustum.intersectsSphere should be enough here, though.

It could be a way to instead of calculating geometric errors in 3dtils

Shameless plug but OP if you're interested I am also working on a 3d tiles implementation for three.js that you can check out here if you're interested:

https://github.com/NASA-AMMOS/3DTilesRendererJS

All 5 comments

Can you please explain why the existing Frustum.intersectsSphere() method is not sufficient for you?

Can you please explain why the existing Frustum.intersectsSphere() method is not sufficient for you?

It could be a way to instead of calculating geometric errors in 3dtils銆侷n a spatial octree,I can use it to make calculating which level probably see銆侷 use it to judge which terrain i can see full object, then i can draw the object and only his parent.

In order to determine if an object's bounding volume is inside a specific cell of a Octree or other spatial structures like BVH, I would use Box3.intersectsSphere() or Box3.containsBox() (just derive the AABB from your sphere). Not sure why you use an instance of Frustum 馃.

It seems the existing interface is sufficient for your use case. Closing.

Not sure why you use an instance of Frustum 馃.

I agree that everything that's needed is available but just for some more context OP is probably trying to calculate what is in view of a camera by the hierarchical bounds to the camera frustum -- basically doing manual frustum culling so you know which objects need to be processed further for that frame. The existing Frustum.intersectsSphere should be enough here, though.

It could be a way to instead of calculating geometric errors in 3dtils

Shameless plug but OP if you're interested I am also working on a 3d tiles implementation for three.js that you can check out here if you're interested:

https://github.com/NASA-AMMOS/3DTilesRendererJS

Not sure why you use an instance of Frustum 馃.

I agree that everything that's needed is available but just for some more context OP is probably trying to calculate what is in view of a camera by the hierarchical bounds to the camera frustum -- basically doing manual frustum culling so you know which objects need to be processed further for that frame. The existing Frustum.intersectsSphere should be enough here, though.

It could be a way to instead of calculating geometric errors in 3dtils

Shameless plug but OP if you're interested I am also working on a 3d tiles implementation for three.js that you can check out here if you're interested:

https://github.com/NASA-AMMOS/3DTilesRendererJS

Yes,it is what i'm doing.Thanks

Was this page helpful?
0 / 5 - 0 ratings