Skip to content

Commit c33985f

Browse files
authored
Fix assignment of geomprops in Web Viewer (AcademySoftwareFoundation#2471)
The web viewer did assign vertex attributes no matter if they existed, leading to exceptions when a loaded file e.g. didn't have UV coordinates. I also added more properties – UV0, UV1, UV2, Color, Color1 – so that they can be leveraged in loaded materials.
1 parent 08163d3 commit c33985f

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

javascript/MaterialXView/source/viewer.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,20 @@ export class Scene
192192
// Use default MaterialX naming convention.
193193
var startStreamTime = performance.now();
194194
child.geometry.attributes.i_position = child.geometry.attributes.position;
195-
child.geometry.attributes.i_normal = child.geometry.attributes.normal;
196-
child.geometry.attributes.i_tangent = child.geometry.attributes.tangent;
197-
child.geometry.attributes.i_texcoord_0 = child.geometry.attributes.uv;
195+
if (child.geometry.attributes.normal)
196+
child.geometry.attributes.i_normal = child.geometry.attributes.normal;
197+
if (child.geometry.attributes.tangent)
198+
child.geometry.attributes.i_tangent = child.geometry.attributes.tangent;
199+
if (child.geometry.attributes.color)
200+
child.geometry.attributes.i_color_0 = child.geometry.attributes.color;
201+
if (child.geometry.attributes.color_1)
202+
child.geometry.attributes.i_color_1 = child.geometry.attributes.color_1;
203+
if (child.geometry.attributes.uv)
204+
child.geometry.attributes.i_texcoord_0 = child.geometry.attributes.uv;
205+
if (child.geometry.attributes.uv1)
206+
child.geometry.attributes.i_texcoord_1 = child.geometry.attributes.uv1;
207+
if (child.geometry.attributes.uv2)
208+
child.geometry.attributes.i_texcoord_2 = child.geometry.attributes.uv2;
198209
streamTime += performance.now() - startStreamTime;
199210
}
200211
});

0 commit comments

Comments
 (0)