addPrimitiveAttributes top-level property
@param {BufferGeometry} geometry @param {GLTF.Primitive} primitiveDef @param {GLTFParser} parser @return {Promise
Implementation
Function addPrimitiveAttributes = (geometry, Map<String, dynamic> primitiveDef, GLTFParser parser) async {
var attributes = primitiveDef["attributes"];
List pending = [];
assignAttributeAccessor(accessorIndex, attributeName) async {
final accessor = await parser.getDependency('accessor', accessorIndex);
return geometry.setAttribute(attributeName, accessor);
}
List<String> attKeys = geometry.attributes.keys.toList();
for (var gltfAttributeName in attributes.keys) {
var threeAttributeName = webGlAttributes[gltfAttributeName] ?? gltfAttributeName.toLowerCase();
// Skip attributes already provided by e.g. Draco extension.
if (attKeys.contains(threeAttributeName)) {
// skip
} else {
await assignAttributeAccessor(attributes[gltfAttributeName], threeAttributeName);
pending.add(geometry);
}
}
if (primitiveDef["indices"] != null && geometry.index == null) {
var accessor = await parser.getDependency('accessor', primitiveDef["indices"]);
geometry.setIndex(accessor);
}
assignExtrasToUserData(geometry, primitiveDef);
computeBounds(geometry, primitiveDef, parser);
return primitiveDef["targets"] != null ? await addMorphTargets(geometry, primitiveDef["targets"], parser) : geometry;
};