updateMorphTargets top-level property
@param {Mesh} mesh @param {GLTF.Mesh} meshDef
Implementation
Function updateMorphTargets = (mesh, Map<String, dynamic> meshDef) {
mesh.updateMorphTargets();
if (meshDef["weights"] != null) {
for (var i = 0, il = meshDef["weights"].length; i < il; i++) {
mesh.morphTargetInfluences[i] = meshDef["weights"][i];
}
}
// .extras has user-defined data, so check that .extras.targetNames is an array.
if (meshDef["extras"] != null && meshDef["extras"]["targetNames"] is List) {
var targetNames = meshDef["extras"]["targetNames"];
if (mesh.morphTargetInfluences.length == targetNames.length) {
mesh.morphTargetDictionary = Map<String, dynamic>();
for (var i = 0, il = targetNames.length; i < il; i++) {
mesh.morphTargetDictionary[targetNames[i]] = i;
}
} else {
print(
'THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.');
}
}
};