nytimes / three-loader-3dtiles

This is a Three.js loader module for handling OGC 3D Tiles, created by Cesium. It currently supports the two main formats, Batched 3D Model (b3dm) - based on glTF Point cloud.
Other
454 stars 64 forks source link

Wrong model culling rendering issues #164

Open mchao123 opened 5 months ago

mchao123 commented 5 months ago

With version 1.2.1, after zooming the camera several times with "OrbitControls", there is a problem with model culling, it looks like the model is moving away from the camera. There is no good solution at the moment and by the way there is no manual for version 1.2.3, maybe the documentation should be updated. Thanks for your help.

Additional note: The main problem is when moving the viewpoint after zooming in, then restoring the viewpoint and repeating the operation about four times. I restored the viewpoint using the following code

let lastPerspectiveStop: () => void;
export const setPerspective = ([cameraP, controlsP] = Config['perspective'], animate = 500) => {
    lastPerspectiveStop && lastPerspectiveStop();
    const lastCamera = [...camera.position.toArray()];
    const lastControls = [...controls.target.toArray()];
    if (animate) {
        lastPerspectiveStop = tween(animate, (i) => {
            camera.position.fromArray(lastCamera.map((c, k) => c + (cameraP[k] - c) * i));
            controls.target.fromArray(lastControls.map((c, k) => c + (controlsP[k] - c) * i));
            camera.updateMatrix();
            controls.update();
            renderContenxt(i === 1);
        }, Tween.easeInOut);
    }
    else {
        camera.position.fromArray(cameraP);
        controls.target.fromArray(controlsP);
        camera.updateMatrix();
        controls.update();
        renderContenxt();
    }
    return [lastCamera, lastControls] as [[number, number, number], [number, number, number]];
};

Could this be the cause?