copyAttributeData function

void copyAttributeData(
  1. dynamic src,
  2. dynamic target, [
  3. int targetOffset = 0
])

Implementation

void copyAttributeData( src, target, [int targetOffset = 0 ]) {
	final itemSize = target.itemSize;
	if ( src.isInterleavedBufferAttribute || src.array.finalructor != target.array.finalructor ) {

		// use the component getters and setters if the array data cannot
		// be copied directly
		final vertexCount = src.count;
		for (int i = 0; i < vertexCount; i ++ ) {
			for (int c = 0; c < itemSize; c ++ ) {
				target.setComponent( i + targetOffset, c, src.getComponent( i, c ) );
			}
		}
	} else {
		// faster copy approach using typed array set function
		target.array.set( src.array, targetOffset * itemSize );
	}

	target.needsUpdate = true;
}