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
714 stars 286 forks source link

[FEATURE SUGGESTION] FastNavPlugin - ability to configure IFC types to hide while moving #873

Open xeolabs opened 2 years ago

xeolabs commented 2 years ago

What is FastNavPlugin

FastNavPlugin is a xeokit Viewer plugin that makes interaction smoother with large models, by temporarily switching the Viewer to faster, lower-quality rendering modes whenever we interact.

New Feature

Extend FastNavPlugin with the options to:

I started this experiment a while back, which I'll resurrect: https://gist.github.com/xeolabs/f6a7d6292155b6b7d0e05f861b916849

Don't try to use that experimental code BTW, it's not supposed to work yet.

The code shows how these new options would look.

In this example, we're hiding objects that meet the following conditions:

  1. are IfcWindow or IfcSpace
  2. have a boundary that is less than 4 units across and more than 14 triangles
  3. are not IfcSlab or IfcWall

    import {Viewer, XKTLoaderPlugin, FastNavPlugin} from "xeokit-sdk.es.js";
    
    const viewer = new Viewer({
       canvasId: "myCanvas"
    });
    
    viewer.scene.camera.eye = [-66.26, 105.84, -281.92];
    viewer.scene.camera.look = [42.45, 49.62, -43.59];
    viewer.scene.camera.up = [0.05, 0.95, 0.15];
    
    new FastNavPlugin(viewer, {
      hideTypes: ["IfcWindow", "IfcSpace"...],
      dontHideTypes: ["IfcSlab", "IfcWall"...],
      hideSmallerThan : 4,
      hideMoreTrianglesThan : 14,
    
      //...
    });
    
    const xktLoader = new XKTLoaderPlugin(viewer);
    
    const model = xktLoader.load({
       id: "myModel",
       src: "./models/xkt/HolterTower.xkt"
    });
Amoki commented 2 years ago

The LOD mechanism by @tmarti in https://github.com/xeokit/xeokit-sdk/pull/824 could work very well with this. Instead of always hiding objects, it hides objects only if FPS drops below a defined threshold. It feels better on high-end computers while being more performant on mobile/company laptops.