Skip to content

Commit

Permalink
Fixed issue #1805 where point clouds which had their material inherit…
Browse files Browse the repository at this point in the history
…ed from higher up in the hierarchy would not display vertex colors
  • Loading branch information
AlexandruPopovici committed Sep 28, 2023
1 parent 39a6bf1 commit 7aeeb98
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
4 changes: 3 additions & 1 deletion packages/viewer-sandbox/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,9 @@ const getStream = () => {
// 'https://speckle.xyz/streams/46caea9b53/commits/71938adcd1'
// 'https://speckle.xyz/streams/2f9f2f3021/commits/75bd13f513'
// 'https://speckle.xyz/streams/25d8a162af/commits/6c842a713c'
'https://speckle.xyz/streams/76e3acde68/commits/0ea3d47e6c'
// 'https://speckle.xyz/streams/76e3acde68/commits/0ea3d47e6c'
// Point cloud
'https://speckle.xyz/streams/b920636274/commits/8df6496749'
)
}

Expand Down
24 changes: 14 additions & 10 deletions packages/viewer/src/modules/materials/Materials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,24 @@ export default class Materials {

private defaultGradientTextureData: ImageData = null

public static renderMaterialFromNode(node: TreeNode): RenderMaterial {
if (!node) return null
public static renderMaterialFromNode(
materialNode: TreeNode,
geometryNode: TreeNode
): RenderMaterial {
if (!materialNode) return null
let renderMaterial: RenderMaterial = null
if (node.model.raw.renderMaterial) {
if (materialNode.model.raw.renderMaterial) {
renderMaterial = {
id: node.model.raw.renderMaterial.id,
color: node.model.raw.renderMaterial.diffuse,
id: materialNode.model.raw.renderMaterial.id,
color: materialNode.model.raw.renderMaterial.diffuse,
opacity:
node.model.raw.renderMaterial.opacity !== undefined
? node.model.raw.renderMaterial.opacity
materialNode.model.raw.renderMaterial.opacity !== undefined
? materialNode.model.raw.renderMaterial.opacity
: 1,
roughness: node.model.raw.renderMaterial.roughness,
metalness: node.model.raw.renderMaterial.metalness,
vertexColors: node.model.raw.colors && node.model.raw.colors.length > 0
roughness: materialNode.model.raw.renderMaterial.roughness,
metalness: materialNode.model.raw.renderMaterial.metalness,
vertexColors:
geometryNode.model.raw.colors && geometryNode.model.raw.colors.length > 0
}
}
return renderMaterial
Expand Down
3 changes: 2 additions & 1 deletion packages/viewer/src/modules/tree/RenderTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ export class RenderTree {
speckleType: GeometryConverter.getSpeckleType(node.model),
geometry: geometryData,
renderMaterial: Materials.renderMaterialFromNode(
renderMaterialNode || displayStyleNode
renderMaterialNode || displayStyleNode,
node
),
/** Line-type geometry can also use a renderMaterial*/
displayStyle: Materials.displayStyleFromNode(
Expand Down

0 comments on commit 7aeeb98

Please sign in to comment.