copy method
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
// var data = {};
// name
name = source.name;
// index
var index = source.index;
if (index != null) {
setIndex(index.clone());
}
// attributes
var attributes = source.attributes;
for (var name in attributes.keys) {
var attribute = attributes[name];
setAttribute(name, attribute.clone());
}
// morph attributes
var morphAttributes = source.morphAttributes;
for (var name in morphAttributes.keys) {
List<BufferAttribute> array = [];
var morphAttribute = morphAttributes[name]!;
// morphAttribute: array of Float32BufferAttributes
for (var i = 0, l = morphAttribute.length; i < l; i++) {
array.add(morphAttribute[i].clone());
}
this.morphAttributes[name] = array;
}
morphTargetsRelative = source.morphTargetsRelative;
// groups
var groups = source.groups;
for (var i = 0, l = groups.length; i < l; i++) {
var group = groups[i];
addGroup(group["start"], group["count"], group["materialIndex"]);
}
// bounding box
var boundingBox = source.boundingBox;
if (boundingBox != null) {
this.boundingBox = boundingBox.clone();
}
// bounding sphere
var 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;
}