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

PerformanceModel tiling to support streaming #29

Closed xeolabs closed 5 years ago

xeolabs commented 5 years ago

Requirement

Ability to incrementally load (ie. stream geometry into) a PerformanceModel while it is rendering.

Solution

Extend PerformanceModel with "tiles". These are optional bins within which entities may be created. Finalizing a tile makes it immediately visible.

createTile({ // Start building a tile
    id: "myTile1"
})

// Create a reusable geometry

createGeometry({ // Sharable (instanced) geometry
    id: "myGeometry1",
    tileId: "myTile1",
    positions:[..],
    normals: [..],
    indices: [..],
    tileId: "bla"  // <<---------- Include this geometry to our tile
})

// Create mesh with own inline geometry

createMesh({ // Mesh with unique geometry
    id: "myMesh1",
    tileId: "myTile1", // <<---------- Add mesh to our tile
    positions:[..],
    normals: [..],
    indices: [..]
})

// Create mesh that uses our reusable geometry 

createMesh({// Mesh with instanced geometry
    id: "myMesh2",
    tileId: "myTile1", // <<---------- Add mesh to our tile
    geometryId: "myGeometry" // <<--- Geometry must be in same tile
})

// Create entity that contains our two meshes

createEntity({ 
    id: "myEntity1",
    tileId: "myTile1", // <<---------- Add entity to our tile
    meshIds: ["myMesh1", "myMesh2"] // <<--- Meshes must be in same tile
})

// Start building another tile concurrently

createTile({ 
    id: "myTile2"
});

// Create the entities in our first tile 
// We can then no longer add anything to that tile

finalizeTile("myTile1"); 

//...
sha-N commented 5 years ago

Looking forward for this. Tiling will allow for loading complex geometries right?

xeolabs commented 5 years ago

Currently, PerformanceModel has a finalize() method that must be called before the PerformanceModel starts rendering.

Tiling is just about partitioning the PerformanceModel so that we don't have to load the entire model before we can start rendering it. A tile is an arbitrary grouping of the geometries we create within a PerformanceModel, where each tile becomes renderable as soon as it is "finalized", while we continue to build the next tile.

This will be flexible so it can be used for different cases, such as:

  1. load portions of a spatially-divided scene on-demand as we look at them (eg. where each tile corresponds to an octant in an octree) or
  2. load and render the most interesting elements of a building first, while we continue to stream in the less-visually important elements like plumbing. Load walls, roof and floors in a tile, finalize that to see those, then load plumbing in another tile, finalize that, electrical in another tile, and so on.

while at the same time containing everything in the same model within xeokit (instead of having a separate model for each tile).

xeolabs commented 5 years ago

This PerformanceModel enhancement is now in master: https://github.com/xeokit/xeokit-sdk/pull/37

Next step: find ways to use the enhancement in BIMServerLoaderPlugin and GLTFLoaderPlugin. Will require extensions to those plugins for user to indicate how loaded entities should be partitioned into layers, (ie. how to prioritize what entities get loaded into the first layers, for immediate rendering).