提交 be4757d0 编写于 作者: M Mr.doob

So now Geometry2 basically adds helper arrays to BufferGeometry.

上级 0732de13
/**
* @author mrdoob / http://mrdoob.com/
*/
THREE.Geometry2 = function ( bufferGeometry ) {
var vertices = [];
var normals = [];
var uvs = [];
var attributes = bufferGeometry.attributes;
var length = attributes.position.array.length;
for ( var i = 0, l = length / 3; i < l; i ++ ) {
vertices.push( new THREE.TypedVector3( attributes.position.array, i * 3 ) );
normals.push( new THREE.TypedVector3( attributes.normal.array, i * 3 ) );
uvs.push( new THREE.TypedVector2( attributes.uv.array, i * 2 ) );
}
bufferGeometry.vertices = vertices;
bufferGeometry.normals = normals;
bufferGeometry.uvs = uvs;
return bufferGeometry;
};
\ No newline at end of file
/**
* @author mrdoob / http://mrdoob.com/
* based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as
*/
THREE.PlaneGeometry = function ( width, height, widthSegments, heightSegments ) {
THREE.PlaneBufferGeometry.call( this, width, height, widthSegments, heightSegments );
var length = this.attributes.position.array.length;
this.vertices = [];
this.normals = [];
this.uvs = [];
for ( var i = 0, l = length / 3; i < l; i ++ ) {
this.vertices.push( new THREE.TypedVector3( this.attributes.position.array, i * 3 ) );
this.normals.push( new THREE.TypedVector3( this.attributes.normal.array, i * 3 ) );
this.uvs.push( new THREE.TypedVector2( this.attributes.uv.array, i * 2 ) );
}
return new THREE.Geometry2( new THREE.PlaneBufferGeometry( width, height, widthSegments, heightSegments ) );
};
THREE.PlaneGeometry.prototype = Object.create( THREE.PlaneBufferGeometry.prototype );
......@@ -32,6 +32,7 @@
"src/core/BufferAttribute.js",
"src/core/BufferGeometry.js",
"src/core/Geometry.js",
"src/core/Geometry2.js",
"src/cameras/Camera.js",
"src/cameras/OrthographicCamera.js",
"src/cameras/PerspectiveCamera.js",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册