xeokit / xeokit-sdk

Open source JavaScript SDK for viewing high-detail, full-precision 3D BIM and AEC models in the Web browser.
https://xeokit.io
Other
738 stars 291 forks source link

View Culling #322

Closed xeolabs closed 4 years ago

xeolabs commented 4 years ago

ViewCullPlugin

See PR https://github.com/xeokit/xeokit-sdk/pull/355

Create ViewCullPlugin, which uses frustum culling to accelerate rendering performance.

ViewCullPlugin works by automatically marking every Entity culled whenever it falls outside our current view.

Since xeokit's renderer does not process culled Entitys, this plugin can be used to avoid wasting GPU on objects that we're not looking at.

Use ViewCullPlugin by simply adding it to your Viewer.

const viewer = new Viewer({
    canvasId: "myCanvas",
    transparent: true
});

const viewCullPlugin = new ViewCullPlugin(viewer, {
    maxTreeDepth: 20
});

const xktLoader = new XKTLoaderPlugin(viewer);

const model = xktLoader.load({
    id: "myModel",
    src: "./models/xkt/OTCConferenceCenter/OTCConferenceCenter.xkt",
    metaModelSrc: "./metaModels/OTCConferenceCenter/metaModel.json"
});
xeolabs commented 4 years ago

\ping @tmarti

xeolabs commented 4 years ago

Added in 1.3.51

barnabasmolnar commented 4 years ago

Hi,

I'm getting the following error when trying to destroy the viewer:

objectCullStates._destroy is not a function

Pointing to the ObjectCullStates.js file and the following piece of code:

scene.on("destroyed", () => {
    delete sceneObjectCullStates[sceneId];
    objectCullStates._destroy();
});

Could you please look into it? Thanks.