From bf2804d21aae379937ebbefcef62f62c9604dc0b Mon Sep 17 00:00:00 2001 From: samip Date: Wed, 4 Dec 2024 17:13:56 -0800 Subject: [PATCH] Fix handling of missing scenes in the Web Viewer (#2124) JsViewerX attempted to use a cube when the selected GLTF file contained no model, but the code never added it to the scene. --- javascript/MaterialXView/source/viewer.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/javascript/MaterialXView/source/viewer.js b/javascript/MaterialXView/source/viewer.js index febe34c809..e558ad0bc9 100644 --- a/javascript/MaterialXView/source/viewer.js +++ b/javascript/MaterialXView/source/viewer.js @@ -90,14 +90,14 @@ export class Scene } this.#_rootNode = null; - const model = gltfData.scene; + let model = gltfData.scene; if (!model) { const geometry = new THREE.BoxGeometry(1, 1, 1); const material = new THREE.MeshBasicMaterial({ color: 0xdddddd }); const cube = new THREE.Mesh(geometry, material); - obj = new Group(); - obj.add(geometry); + model = new Group(); + model.add(cube); } else {