Skip to content

Commit

Permalink
Check if variables exist before resolving them
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo committed Dec 4, 2023
1 parent d5f3a71 commit 0693561
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions src/components/gltf-model-plus.js
Original file line number Diff line number Diff line change
Expand Up @@ -919,23 +919,25 @@ class GLTFMozBehaviorExtension {
}
}
}
for (const variable of graph.variables) {
const type = variable.valueTypeName;
const value = variable.initialValue;
if (type && value.index !== undefined) {
deps.push(
parser.getDependency(type, value.index).then(loadedDep => {
if (type === "texture" && !parser.json.textures[value.index].extensions?.MOZ_texture_rgbe) {
loadedDep.encoding = THREE.sRGBEncoding;
}
// Not associated materials don't get their components resolved in GLTFHubsComponentsExtension as they are not referenced by any object
if (type === "material" && !loadedDep.userData.gltfExtensions) {
loadedDep.userData.gltfExtensions = Object.assign({}, parser.json.materials[value.index].extensions);
}
value.dep = loadedDep;
return loadedDep;
})
);
if (graph.variables) {
for (const variable of graph.variables) {
const type = variable.valueTypeName;
const value = variable.initialValue;
if (type && value.index !== undefined) {
deps.push(
parser.getDependency(type, value.index).then(loadedDep => {
if (type === "texture" && !parser.json.textures[value.index].extensions?.MOZ_texture_rgbe) {
loadedDep.encoding = THREE.sRGBEncoding;
}
// Not associated materials don't get their components resolved in GLTFHubsComponentsExtension as they are not referenced by any object
if (type === "material" && !loadedDep.userData.gltfExtensions) {
loadedDep.userData.gltfExtensions = Object.assign({}, parser.json.materials[value.index].extensions);
}
value.dep = loadedDep;
return loadedDep;
})
);
}
}
}

Expand Down

0 comments on commit 0693561

Please sign in to comment.