diff --git a/packages/viewer-sandbox/src/main.ts b/packages/viewer-sandbox/src/main.ts index d44835d2c..a01d1eecf 100644 --- a/packages/viewer-sandbox/src/main.ts +++ b/packages/viewer-sandbox/src/main.ts @@ -262,7 +262,10 @@ const getStream = () => { // 'https://latest.speckle.dev/streams/92b620fb17/commits/f9063fe647' // 'https://speckle.xyz/streams/be0f962efb/objects/37639741c363a123100eda8044f2fe3f' // 'https://latest.speckle.dev/streams/92b620fb17/objects/a4e2fad01e69cd886ecbfedf221f5301' - 'https://latest.speckle.dev/streams/3f895e614f/commits/7e16d2ab71' + // 'https://latest.speckle.dev/streams/3f895e614f/commits/7e16d2ab71' + // 'https://latest.speckle.dev/streams/c1faab5c62/objects/d3466547df9df86397eb4dff7ac9713f' + // 'https://latest.speckle.dev/streams/c1faab5c62/commits/140c443886' + 'https://latest.speckle.dev/streams/e258b0e8db/commits/108971810d' ) } diff --git a/packages/viewer/src/modules/converter/Converter.ts b/packages/viewer/src/modules/converter/Converter.ts index 36e07b3db..d7e1319ad 100644 --- a/packages/viewer/src/modules/converter/Converter.ts +++ b/packages/viewer/src/modules/converter/Converter.ts @@ -359,6 +359,34 @@ export default class Coverter { // return hash // } + /** This is only used for Blocks to search for convertible objects, without using the main 'traverse' function + * It's only looking for 'elements' and 'displayValues' + * I think it can be used for RevitInstances as well to replace it's current lookup, but I'm afraid to do it + */ + private async displayableLookup(obj, node) { + if (this.directNodeConverterExists(obj)) { + await this.convertToNode(obj, node) + } else { + const displayValues = this.getDisplayValue(obj) + const elements = this.getElementsValue(obj) + const entries = [ + ...(displayValues ? displayValues : []), + ...(elements ? elements : []) + ] + for (const entry of entries) { + const value = await this.resolveReference(entry) + const valueNode: TreeNode = this.tree.parse({ + id: this.getNodeId(value), + raw: Object.assign({}, value), + atomic: false, + children: [] + }) + this.tree.addNode(valueNode, node) + await this.displayableLookup(value, valueNode) + } + } + } + private async BlockInstanceToNode(obj, node) { const definition = await this.resolveReference(this.getBlockDefinition(obj)) node.model.raw.definition = definition @@ -372,11 +400,8 @@ export default class Coverter { children: [] }) this.tree.addNode(childNode, node) - // console.warn( - // `Added child node with id ${childNode.model.id} to parent node ${node.model.id}` - // ) - await this.convertToNode(ref, childNode) + this.displayableLookup(ref, childNode) } }