diff --git a/packages/viewer-sandbox/src/Sandbox.ts b/packages/viewer-sandbox/src/Sandbox.ts index b7eba663aa..5a447428aa 100644 --- a/packages/viewer-sandbox/src/Sandbox.ts +++ b/packages/viewer-sandbox/src/Sandbox.ts @@ -148,7 +148,7 @@ export default class Sandbox { this.addStreamControls(url) this.addViewControls() this.addBatches() - this.properties = await this.viewer.getObjectProperties() + // this.properties = await this.viewer.getObjectProperties() this.batchesParams.totalBvhSize = this.getBVHSize() this.refresh() }) @@ -467,11 +467,8 @@ export default class Sandbox { // ) this.viewer - .getExtension(SelectionExtension) - .selectObjects(this.ids /*['c3138e24a866d447eb86b2a8107b2c09']*/) - setTimeout(() => { - console.log(this.viewer.getRenderer().renderingStats) - }, 1000) + .getExtension(FilteringExtension) + .isolateObjects(this.ids /*['1c8f29e7d48e531f6acbf987a50467f9']*/) }) const rotate = this.tabs.pages[0].addButton({ diff --git a/packages/viewer-sandbox/src/main.ts b/packages/viewer-sandbox/src/main.ts index cb5cd45e41..0979dddc98 100644 --- a/packages/viewer-sandbox/src/main.ts +++ b/packages/viewer-sandbox/src/main.ts @@ -183,7 +183,7 @@ const getStream = () => { // 'https://latest.speckle.dev/streams/1c2b3db9fb/commits/f12861736e' // 'https://latest.speckle.dev/streams/1c2b3db9fb/commits/1015d417ea' // Jedd's views - 'https://latest.speckle.dev/streams/c1faab5c62/commits/e6632fe057' + // 'https://latest.speckle.dev/streams/c1faab5c62/commits/e6632fe057' // 'https://latest.speckle.dev/streams/7d051a6449/commits/7632757a33' // 'https://latest.speckle.dev/streams/4658eb53b9/commits/d8ec9cccf7' // MEPs (whatever they are) @@ -303,7 +303,7 @@ const getStream = () => { // 'https://speckle.xyz/streams/2f9f2f3021/commits/75bd13f513' // 'https://speckle.xyz/streams/0a2f096caf/commits/eee0e4436f?overlay=72828bce0d&c=%5B14.04465,-332.88372,258.40392,53.09575,31.13694,126.39999,0,1%5D&filter=%7B%22propertyInfoKey%22%3A%22level.name%22%7D' // 'Bilal's tests - // 'https://latest.speckle.dev/streams/97750296c2/commits/5386a0af02' // 700k+ objects 30kk tris + 'https://latest.speckle.dev/streams/97750296c2/commits/5386a0af02' // 700k+ objects 30kk tris // 'https://latest.speckle.dev/streams/97750296c2/commits/2a6fd781f2' // NEW // 'https://latest.speckle.dev/streams/97750296c2/commits/48f0567a88' // 1015849 objects diff --git a/packages/viewer/src/modules/extensions/FilteringExtension.ts b/packages/viewer/src/modules/extensions/FilteringExtension.ts index bb791c76cc..acb9f7f1d0 100644 --- a/packages/viewer/src/modules/extensions/FilteringExtension.ts +++ b/packages/viewer/src/modules/extensions/FilteringExtension.ts @@ -148,12 +148,28 @@ export class FilteringExtension extends Extension { this.VisibilityState.command = command - let walkFunc: (node: TreeNode) => boolean if (command === Command.HIDE || command === Command.SHOW) - walkFunc = this.visibilityWalk - if (command === Command.ISOLATE || command === Command.UNISOLATE) - walkFunc = this.isolationWalk - this.WTI.walk(walkFunc.bind(this)) + this.WTI.walk(this.visibilityWalk.bind(this)) + if (command === Command.ISOLATE || command === Command.UNISOLATE) { + // this.WTI.walk(this.isolationWalk.bind(this)) + const rvMap = {} + this.WTI.walk((node: TreeNode) => { + if (!node.model.atomic || this.WTI.isRoot(node)) return true + const rvNodes = this.WTI.getRenderTree().getRenderViewNodesForNode(node, node) + if (!this.VisibilityState.ids[node.model.raw.id]) { + rvNodes.forEach((rvNode: TreeNode) => { + rvMap[rvNode.model.id] = rvNode.model.renderView + }) + } else { + rvNodes.forEach((rvNode: TreeNode) => { + delete rvMap[rvNode.model.id] + }) + } + return true + }) + this.VisibilityState.rvs = Object.values(rvMap) + } + return this.setFilters() } @@ -508,17 +524,26 @@ export class FilteringExtension extends Extension { if (this.idCache[key] && this.idCache[key].length) return this.idCache[key] - this.WTI.walk((node: TreeNode) => { - if (objectIds.includes(node.model.raw.id)) { - const subtree = node.all((node) => { - return node.model.raw !== undefined - }) - const idList = subtree.map((node) => node.model.raw.id) - allIds.push(...idList) - this.idCache[node.model.raw.id] = idList - } - return true - }) + for (let k = 0; k < objectIds.length; k++) { + const node = this.WTI.findId(objectIds[k])[0] + const subtree = node.all((node) => { + return node.model.raw !== undefined + }) + const idList = subtree.map((node) => node.model.raw.id) + allIds.push(...idList) + this.idCache[node.model.raw.id] = idList + } + // this.WTI.walk((node: TreeNode) => { + // if (objectIds.includes(node.model.raw.id)) { + // const subtree = node.all((node) => { + // return node.model.raw !== undefined + // }) + // const idList = subtree.map((node) => node.model.raw.id) + // allIds.push(...idList) + // this.idCache[node.model.raw.id] = idList + // } + // return true + // }) this.idCache[key] = allIds return allIds