createNodeMesh method

dynamic createNodeMesh(
  1. dynamic nodeIndex
)

Implementation

createNodeMesh(nodeIndex) async {
  var json = this.json;
  var parser = this;
  Map<String, dynamic> nodeDef = json["nodes"][nodeIndex];

  if (nodeDef["mesh"] == null) return null;

  var mesh = await parser.getDependency('mesh', nodeDef["mesh"]);

  var node = parser._getNodeRef(parser.meshCache, nodeDef["mesh"], mesh);

  // if weights are provided on the node, override weights on the mesh.
  if (nodeDef["weights"] != null) {
    node.traverse((o) {
      if (!o.isMesh) return;

      for (var i = 0, il = nodeDef["weights"].length; i < il; i++) {
        o.morphTargetInfluences[i] = nodeDef["weights"][i];
      }
    });
  }

  return node;
}