diff --git a/packages/viewer/src/modules/objects/SpeckleInstancedMesh.ts b/packages/viewer/src/modules/objects/SpeckleInstancedMesh.ts index a9995932dd..d890f67d78 100644 --- a/packages/viewer/src/modules/objects/SpeckleInstancedMesh.ts +++ b/packages/viewer/src/modules/objects/SpeckleInstancedMesh.ts @@ -60,9 +60,10 @@ export default class SpeckleInstancedMesh extends Group { public static MeshBatchNumber = 0 private tas: TopLevelAccelerationStructure - private batchMaterial: Material | null = null + private batchMaterial: Material private materialCache: { [id: string]: Material } = {} private materialStack: Array> = [] + private batchMaterialStack: Array = [] private materialCacheLUT: { [id: string]: number } = {} private _batchObjects!: BatchObject[] @@ -107,6 +108,36 @@ export default class SpeckleInstancedMesh extends Group { this.instances.forEach((value) => (value.material = overrideMaterial)) } + public setOverrideBatchMaterial(material: Material) { + const overrideMaterial = this.getCachedMaterial(material, true) + this.batchMaterialStack.push(overrideMaterial) + const materials = this.materials + for (let k = 0; k < materials.length; k++) { + if (materials[k].uuid === this.batchMaterial.uuid) { + materials[k] = overrideMaterial + } + } + this.instances.forEach((value) => { + if ((value.material as Material).uuid === this.batchMaterial.uuid) + value.material = overrideMaterial + }) + } + + public restoreBatchMaterial() { + const overrideBatchMaterial = this.batchMaterialStack.pop() + if (!overrideBatchMaterial) return + + for (let k = 0; k < this.materials.length; k++) { + if (this.materials[k].uuid === overrideBatchMaterial.uuid) { + this.materials[k] = this.batchMaterial + } + } + this.instances.forEach((value) => { + if ((value.material as Material).uuid === overrideBatchMaterial.uuid) + value.material = this.batchMaterial + }) + } + private lookupMaterial(material: Material) { return ( this.materialCache[material.id] || diff --git a/packages/viewer/src/modules/pipeline/Pipelines/Pipeline.ts b/packages/viewer/src/modules/pipeline/Pipelines/Pipeline.ts index 1afda75453..c4b720ac8d 100644 --- a/packages/viewer/src/modules/pipeline/Pipelines/Pipeline.ts +++ b/packages/viewer/src/modules/pipeline/Pipelines/Pipeline.ts @@ -51,8 +51,6 @@ export abstract class Pipeline { this.jitterIndex = 0 } - public renderRequest() {} - public render(): boolean { this.speckleRenderer.renderer.getDrawingBufferSize(this.drawingSize) if (this.drawingSize.length() === 0) return false