Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About Clipping 3dtiles #165

Open
AHSss opened this issue May 6, 2024 · 1 comment
Open

About Clipping 3dtiles #165

AHSss opened this issue May 6, 2024 · 1 comment

Comments

@AHSss
Copy link

AHSss commented May 6, 2024

I want Clip the model,Here is what I tried

const clipPlanes = [
    new THREE.Plane(new THREE.Vector3(1, 0, 0), -50),
    new THREE.Plane(new THREE.Vector3(-1, 0, 0), -50),
    new THREE.Plane(new THREE.Vector3(0, 0, -1), -10),
    new THREE.Plane(new THREE.Vector3(0, 0, 1), -10),
]
const animate = () => {
    deltaTime.value = colck.getDelta()
    if (tilesRuntime.value) {
        console.log(tilesRuntime.value)
        scene.traverse((obj: any) => {
            if (obj.type == "Mesh") {
                if (obj.material.length > 1) {
                    obj.material.forEach((element: any) => {
                        element.clippingPlanes = clipPlanes;
                        element.clipIntersection = true;
                    });
                } else {
                    obj.material.clippingPlanes = clipPlanes;
                    obj.material.clipIntersection = true;
                }
            }
        })
        tilesRuntime.value.update(deltaTime.value, renderer, camera)
    }
    renderer.render(scene, camera);
    requestAnimationFrame(animate);
}

I got the effect I wanted, but I put the clip's code in the animate, This may seem like a poor performance. Is there a better way?@wanyanyan @Avnerus
image

@Avnerus
Copy link
Collaborator

Avnerus commented May 28, 2024

Hi!
Check the contentPostProcess option. It allows you to run a callback after each tile mesh is processed.

Even more efficient would be to avoid downloading tiles that are in the clipping range, but that requires hooking into the loaders.gl traversal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants