mirror of
https://github.com/MapMakersAndProgrammers/Alternativa3D.git
synced 2025-10-26 01:49:07 -07:00
Merge pull request #69 from ChrisDenham/patch-6
Adding Geometry clone function.
This commit is contained in:
@@ -141,6 +141,34 @@ package alternativa.engine3d.resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a copy of object.
|
||||||
|
* @return A copy of this <code>Geometry</code>.
|
||||||
|
*/
|
||||||
|
public function clone():Geometry
|
||||||
|
{
|
||||||
|
var geometry:Geometry = new Geometry();
|
||||||
|
geometry.clonePropertiesFrom(this);
|
||||||
|
return geometry;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copies basic properties of <code>Geometry</code>. This method calls from <code>clone()</code> method.
|
||||||
|
* @param source <code>Geometry</code>, properties of which will be copied.
|
||||||
|
*/
|
||||||
|
protected function clonePropertiesFrom(source:Geometry):void {
|
||||||
|
var n:int = source._vertexStreams.length;
|
||||||
|
for (var i:int = 0; i < n; ++i)
|
||||||
|
{
|
||||||
|
addVertexStream(source.getVertexStreamAttributes(i));
|
||||||
|
_vertexStreams[i].data.length = source._vertexStreams[i].data.length;
|
||||||
|
_vertexStreams[i].data.writeBytes(source._vertexStreams[i].data);
|
||||||
|
_vertexStreams[i].data.position = source._vertexStreams[i].data.position;
|
||||||
|
}
|
||||||
|
_numVertices = source._numVertices;
|
||||||
|
_indices = source._indices.slice();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculation of vertex normals.
|
* Calculation of vertex normals.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user