Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model - nodesByName - use id if name is undefined #4870

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions Source/Scene/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
}
Expand All @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down