fix(viewer-lib): Fixed explode mode (#984) (#5748)

This commit is contained in:
Alexandru Popovici
2026-03-02 18:11:12 +02:00
committed by GitHub
parent c97c6539d7
commit e902142a94
2 changed files with 15 additions and 3 deletions
+6 -2
View File
@@ -134,9 +134,11 @@ const createViewer = async (containerName: string, _stream: string) => {
const getStream = () => {
return (
// prettier-ignore
'https://app.speckle.systems/projects/1b96a34aae/models/a8698c0c67'
// 'https://app.speckle.systems/projects/1b96a34aae/models/a8698c0c67'
// Revit sample house (good for bim-like stuff with many display meshes)
// 'https://app.speckle.systems/streams/da9e320dad/commits/5388ef24b8'
'https://app.speckle.systems/projects/9638b98615/models/2d8e1ef75b@241c9de8d5'
// 'https://app.speckle.systems/streams/da9e320dad/commits/5388ef24b8' :'(
// 'https://app.speckle.systems/streams/da9e320dad/objects/ee5d160d84090822813bc74188da34a7'
//large tower
@@ -673,6 +675,8 @@ const getStream = () => {
// Texts and empty texts
// 'https://app.speckle.systems/projects/8b466869c0/models/d1eabb3c74'
// 'https://app.speckle.systems/projects/d7d987146d/models/1556042389'
)
}
@@ -23,6 +23,7 @@ export class ExplodeExtension extends Extension {
/** Similar to SpeckleRenderer's visibleSceneBox, but with static boxes from render views */
public get visibleWorld(): Box3 {
const bounds: Box3 = new Box3()
const scratchBox = new Box3()
const batches = this.viewer.getRenderer().batcher.getBatches()
for (let k = 0; k < batches.length; k++) {
const batch = batches[k]
@@ -48,7 +49,14 @@ export class ExplodeExtension extends Extension {
if (s.batchStart >= qEnd) break
const sEnd = s.batchStart + s.batchCount
if (s.batchStart >= qStart && sEnd <= qEnd) {
bounds.union(s.aabb)
/** Alex 18.02.2026: There is an issue with using the render view's aabb.
* Instanced render views will always provide incorrect bounds unless transformed
* Which is what we are doing here */
scratchBox.copy(s.aabb)
s.renderData.geometry.transform &&
s.renderData.geometry.instanced &&
scratchBox.applyMatrix4(s.renderData.geometry.transform)
bounds.union(scratchBox)
}
}
}