From d122873f0ef2677a994c46c8d15a3b4c1ab59338 Mon Sep 17 00:00:00 2001 From: Alexandru Popovici Date: Wed, 12 Mar 2025 17:02:44 +0200 Subject: [PATCH 1/2] fix(viewer-lib): Fixed the issue where ghosted lines would not appear transparent (#4174) --- packages/viewer-sandbox/src/main.ts | 5 +++++ .../viewer/src/modules/batching/LineBatch.ts | 18 ++++++++++++++++-- .../viewer/src/modules/materials/Materials.ts | 2 ++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/packages/viewer-sandbox/src/main.ts b/packages/viewer-sandbox/src/main.ts index 92856a5a1..81f5723dc 100644 --- a/packages/viewer-sandbox/src/main.ts +++ b/packages/viewer-sandbox/src/main.ts @@ -474,6 +474,11 @@ const getStream = () => { // Custom normals // 'https://latest.speckle.systems/projects/51c449c440/models/08e97226cf' + + // A LOT of text objects + // 'https://app.speckle.systems/projects/e771a388b1/models/f5c967dfa9' + + // 'https://app.speckle.systems/projects/16cffbc224/models/1e142b07a0' ) } diff --git a/packages/viewer/src/modules/batching/LineBatch.ts b/packages/viewer/src/modules/batching/LineBatch.ts index 4dd1bc61d..e68c1e705 100644 --- a/packages/viewer/src/modules/batching/LineBatch.ts +++ b/packages/viewer/src/modules/batching/LineBatch.ts @@ -31,8 +31,11 @@ export default class LineBatch implements Batch { public renderViews: NodeRenderView[] protected geometry: LineSegmentsGeometry public batchMaterial: SpeckleLineMaterial + protected batchTransparent: boolean + protected batchOpacity: number protected mesh: LineSegments2 - public colorBuffer!: InstancedInterleavedBuffer + public colorBuffer: InstancedInterleavedBuffer + private static readonly vector4Buffer: Vector4 = new Vector4() public get bounds(): Box3 { @@ -94,6 +97,9 @@ export default class LineBatch implements Batch { public setBatchMaterial(material: SpeckleLineMaterial) { this.batchMaterial = material + /** Not a fan of this :( */ + this.batchTransparent = material.transparent + this.batchOpacity = material.opacity } public onUpdate(deltaTime: number) { @@ -169,6 +175,9 @@ export default class LineBatch implements Batch { public setBatchBuffers(ranges: BatchUpdateRange[]): void { const data = this.colorBuffer.array as number[] + /** Reset transparency */ + this.batchMaterial.transparent = this.batchTransparent + this.batchMaterial.opacity = this.batchOpacity for (let i = 0; i < ranges.length; i++) { const material = ranges[i].material as SpeckleLineMaterial @@ -179,6 +188,10 @@ export default class LineBatch implements Batch { : material.color const alpha: number = material.visible ? material.opacity : 0 this.batchMaterial.transparent ||= material.opacity < 1 + this.batchMaterial.opacity = Math.min( + this.batchMaterial.opacity, + material.opacity + ) const start = ranges[i].offset * this.colorBuffer.stride const len = ranges[i].offset * this.colorBuffer.stride + @@ -211,7 +224,8 @@ export default class LineBatch implements Batch { ]) this.mesh.material = this.batchMaterial this.mesh.visible = true - this.batchMaterial.transparent = false + this.batchMaterial.transparent = this.batchTransparent + this.batchMaterial.opacity = this.batchOpacity } public buildBatch() { diff --git a/packages/viewer/src/modules/materials/Materials.ts b/packages/viewer/src/modules/materials/Materials.ts index d6a4c3842..c6d27fd37 100644 --- a/packages/viewer/src/modules/materials/Materials.ts +++ b/packages/viewer/src/modules/materials/Materials.ts @@ -425,6 +425,8 @@ export default class Materials { ;(this.lineGhostMaterial).pixelThreshold = 0.5 ;(this.lineGhostMaterial).resolution = new Vector2() ;(this.lineGhostMaterial).toneMapped = false + ;(this.lineGhostMaterial).opacity = 0.1 + ;(this.lineGhostMaterial).transparent = true this.lineColoredMaterial = new SpeckleLineMaterial( { From e6cbe556b55e92df03d26a7bd272e776ec27950e Mon Sep 17 00:00:00 2001 From: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Wed, 12 Mar 2025 15:51:37 +0000 Subject: [PATCH 2/2] Bump IFC nuget (#4176) --- packages/fileimport-service/ifc-dotnet/ifc-converter.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/fileimport-service/ifc-dotnet/ifc-converter.csproj b/packages/fileimport-service/ifc-dotnet/ifc-converter.csproj index a600eedb5..df2c94ad1 100644 --- a/packages/fileimport-service/ifc-dotnet/ifc-converter.csproj +++ b/packages/fileimport-service/ifc-dotnet/ifc-converter.csproj @@ -10,7 +10,7 @@ - +