From 97e4260b3972df187875d08b5c0c88140f26e815 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Sat, 14 Jan 2017 21:33:08 -0500 Subject: [PATCH] Model byName uses id if name is undefined --- Source/Scene/Model.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Source/Scene/Model.js b/Source/Scene/Model.js index 3d6cc75f72eb..c3ebfec04b56 100644 --- a/Source/Scene/Model.js +++ b/Source/Scene/Model.js @@ -1486,8 +1486,9 @@ define([ }; runtimeNode.publicNode = new ModelNode(model, node, runtimeNode, id, getTransform(node)); + var name = defaultValue(node.name, id); runtimeNodes[id] = runtimeNode; - runtimeNodesByName[node.name] = runtimeNode; + runtimeNodesByName[name] = runtimeNode; if (defined(node.skin)) { skinnedNodesIds.push(id); @@ -1517,8 +1518,9 @@ define([ }; var material = materials[id]; + var name = defaultValue(material.name, id); var modelMaterial = new ModelMaterial(model, material, id); - runtimeMaterialsByName[material.name] = modelMaterial; + runtimeMaterialsByName[name] = modelMaterial; runtimeMaterialsById[id] = modelMaterial; } } @@ -1536,7 +1538,8 @@ define([ for (var id in meshes) { if (meshes.hasOwnProperty(id)) { var mesh = meshes[id]; - runtimeMeshesByName[mesh.name] = new ModelMesh(mesh, runtimeMaterialsById, id); + var name = defaultValue(mesh.name, id); + runtimeMeshesByName[name] = new ModelMesh(mesh, runtimeMaterialsById, id); if (usesQuantizedAttributes) { // Cache primitives according to their program var primitives = mesh.primitives; @@ -3019,6 +3022,7 @@ define([ for (var j = 0; j < meshesLength; ++j) { var id = meshes[j]; var mesh = gltfMeshes[id]; + var name = defaultValue(mesh.name, id); var primitives = mesh.primitives; var length = primitives.length; @@ -3086,7 +3090,7 @@ define([ primitive : defaultValue(model.pickPrimitive, model), id : model.id, node : runtimeNode.publicNode, - mesh : runtimeMeshesByName[mesh.name] + mesh : runtimeMeshesByName[name] }; var castShadows = ShadowMode.castShadows(model._shadows);