copy method
BufferGeometry
copy(
- BufferGeometry source
inherited
Implementation
BufferGeometry copy(BufferGeometry source) {
// reset
// this.index = null;
// this.attributes = {};
// this.morphAttributes = {};
// this.groups = [];
// this.boundingBox = null;
// this.boundingSphere = null;
// used for storing cloned, shared data
// Map data = {};
// name
name = source.name;
// index
final index = source.index;
if (index != null) {
setIndex(index.clone());
}
// attributes
final attributes = source.attributes;
for (String name in attributes.keys) {
final attribute = attributes[name];
setAttributeFromString(name, attribute.clone());
}
// morph attributes
final morphAttributes = source.morphAttributes;
for (String name in morphAttributes.keys) {
List<BufferAttribute> array = [];
final morphAttribute = morphAttributes[name]!;
// morphAttribute: array of Float32BufferAttributes
for (int i = 0, l = morphAttribute.length; i < l; i++) {
array.add(morphAttribute[i].clone());
}
this.morphAttributes[name] = array;
}
morphTargetsRelative = source.morphTargetsRelative;
// groups
List<Map<String,dynamic>> groups = source.groups;
for (int i = 0, l = groups.length; i < l; i++) {
final group = groups[i];
addGroup(group["start"], group["count"], group["materialIndex"]);
}
// bounding box
final boundingBox = source.boundingBox;
if (boundingBox != null) {
this.boundingBox = boundingBox.clone();
}
// bounding sphere
final boundingSphere = source.boundingSphere;
if (boundingSphere != null) {
this.boundingSphere = boundingSphere.clone();
}
// draw range
drawRange["start"] = source.drawRange["start"]!;
drawRange["count"] = source.drawRange["count"]!;
// user data
userData = source.userData;
return this;
}