diff --git a/packages/viewer/src/modules/batching/Batcher.ts b/packages/viewer/src/modules/batching/Batcher.ts index db13a23df..41f951cbf 100644 --- a/packages/viewer/src/modules/batching/Batcher.ts +++ b/packages/viewer/src/modules/batching/Batcher.ts @@ -47,6 +47,10 @@ export default class Batcher { matRef = batch[0].renderData.renderMaterial } else if (batchType === GeometryType.LINE) { matRef = batch[0].renderData.displayStyle + } else if (batchType === GeometryType.POINT) { + matRef = batch[0].renderData.renderMaterial + } else if (batchType === GeometryType.POINT_CLOUD) { + matRef = batch[0].renderData.renderMaterial } const material = this.materials.updateMaterialMap( diff --git a/packages/viewer/src/modules/materials/Materials.ts b/packages/viewer/src/modules/materials/Materials.ts index bb87f531a..8189f009c 100644 --- a/packages/viewer/src/modules/materials/Materials.ts +++ b/packages/viewer/src/modules/materials/Materials.ts @@ -241,7 +241,7 @@ export default class Materials { sizeAttenuation: false // clippingPlanes: this.viewer.sectionBox.planes }) - this.materialMap[NodeRenderView.NullPointCloudMaterialHash] = + this.materialMap[NodeRenderView.NullPointCloudVertexColorsMaterialHash] = new SpecklePointMaterial({ color: 0xffffff, vertexColors: true, @@ -249,6 +249,14 @@ export default class Materials { sizeAttenuation: false // clippingPlanes: this.viewer.sectionBox.planes }) + this.materialMap[NodeRenderView.NullPointCloudMaterialHash] = + new SpecklePointMaterial({ + color: 0xffffff, + vertexColors: false, + size: 2, + sizeAttenuation: false + // clippingPlanes: this.viewer.sectionBox.planes + }) } private makeMeshMaterial(materialData: RenderMaterial): Material { @@ -289,6 +297,21 @@ export default class Materials { return mat } + private makePointMaterial(materialData: RenderMaterial): Material { + const mat = new SpecklePointMaterial({ + color: materialData.color, + opacity: materialData.opacity, + vertexColors: false, + size: 2, + sizeAttenuation: false + // clippingPlanes: this.viewer.sectionBox.planes + }) + mat.transparent = mat.opacity < 1 ? true : false + mat.depthWrite = mat.transparent ? false : true + mat.color.convertSRGBToLinear() + return mat + } + public updateMaterialMap( hash: number, material: RenderMaterial | DisplayStyle, @@ -309,7 +332,7 @@ export default class Materials { this.materialMap[hash] = this.makeLineMaterial(material as DisplayStyle) break case GeometryType.POINT: - console.error(`No material definition for points!`) + this.materialMap[hash] = this.makePointMaterial(material as RenderMaterial) break } } diff --git a/packages/viewer/src/modules/tree/NodeRenderView.ts b/packages/viewer/src/modules/tree/NodeRenderView.ts index dfee52dce..b2aabb4c2 100644 --- a/packages/viewer/src/modules/tree/NodeRenderView.ts +++ b/packages/viewer/src/modules/tree/NodeRenderView.ts @@ -46,8 +46,10 @@ export class NodeRenderView { public static readonly NullPointMaterialHash = this.hashCode( GeometryType.POINT.toString() ) - public static readonly NullPointCloudMaterialHash = this.hashCode( + GeometryType.POINT_CLOUD.toString() + ) + public static readonly NullPointCloudVertexColorsMaterialHash = this.hashCode( GeometryType.POINT_CLOUD.toString() + 'vertexColors' )