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

Moved wip classes out of src.

上级 fd9885a8
/**
* @author mrdoob / http://mrdoob.com/
*/
THREE.Geometry3 = function ( size ) {
THREE.BufferGeometry.call( this );
var verticesBuffer = new ArrayBuffer( size * 3 * 4 );
var normalsBuffer = new ArrayBuffer( size * 3 * 4 );
var uvsBuffer = new ArrayBuffer( size * 2 * 4 );
this.vertices = [];
this.normals = [];
this.uvs = [];
for ( var i = 0; i < size; i ++ ) {
this.vertices.push( new Float32Array( verticesBuffer, i * 3 * 4, 3 ) );
this.normals.push( new Float32Array( normalsBuffer, i * 3 * 4, 3 ) );
this.uvs.push( new Float32Array( uvsBuffer, i * 2 * 4, 2 ) );
}
this.attributes[ 'position' ] = { array: new Float32Array( verticesBuffer, 0, size * 3 ), itemSize: 3 };
this.attributes[ 'normal' ] = { array: new Float32Array( normalsBuffer, 0, size * 3 ), itemSize: 3 };
this.attributes[ 'uv' ] = { array: new Float32Array( uvsBuffer, 0, size * 2 ), itemSize: 2 };
};
THREE.Geometry3.prototype = Object.create( THREE.BufferGeometry.prototype );
\ No newline at end of file
/**
* @author mrdoob / http://mrdoob.com/
*/
THREE.IndexedGeometry3 = function ( indices, size ) {
THREE.BufferGeometry.call( this );
var verticesBuffer = new ArrayBuffer( size * 3 * 4 );
var normalsBuffer = new ArrayBuffer( size * 3 * 4 );
var uvsBuffer = new ArrayBuffer( size * 2 * 4 );
this.indices = new Uint16Array( indices );
this.vertices = [];
this.normals = [];
this.uvs = [];
for ( var i = 0; i < size; i ++ ) {
this.vertices.push( new Float32Array( verticesBuffer, i * 3 * 4, 3 ) );
this.normals.push( new Float32Array( normalsBuffer, i * 3 * 4, 3 ) );
this.uvs.push( new Float32Array( uvsBuffer, i * 2 * 4, 2 ) );
}
this.attributes[ 'index' ] = { array: this.indices, itemSize: 1 };
this.attributes[ 'position' ] = { array: new Float32Array( verticesBuffer, 0, size * 3 ), itemSize: 3 };
this.attributes[ 'normal' ] = { array: new Float32Array( normalsBuffer, 0, size * 3 ), itemSize: 3 };
this.attributes[ 'uv' ] = { array: new Float32Array( uvsBuffer, 0, size * 2 ), itemSize: 2 };
};
THREE.Geometry3.prototype = Object.create( THREE.BufferGeometry.prototype );
\ No newline at end of file
......@@ -28,8 +28,6 @@ THREE.PlaneGeometry2 = function ( width, height, widthSegments, heightSegments )
var offset = 0;
var normal = new THREE.Vector3( 0, 0, 1 );
for ( var iy = 0; iy < gridY; iy ++ ) {
var y1 = iy * segmentHeight - heightHalf;
......
/**
* @author mrdoob / http://mrdoob.com/
* based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as
*/
THREE.PlaneGeometry3 = function ( width, height, widthSegments, heightSegments ) {
THREE.Geometry3.call( this, ( widthSegments * heightSegments ) * 2 * 3 );
var vertices = this.vertices;
var normals = this.normals;
var uvs = this.uvs;
this.width = width;
this.height = height;
this.widthSegments = widthSegments || 1;
this.heightSegments = heightSegments || 1;
var widthHalf = width / 2;
var heightHalf = height / 2;
var gridX = this.widthSegments;
var gridY = this.heightSegments;
var segmentWidth = this.width / gridX;
var segmentHeight = this.height / gridY;
var offset = 0;
for ( var iy = 0; iy < gridY; iy ++ ) {
var y1 = iy * segmentHeight - heightHalf;
var y2 = ( iy + 1 ) * segmentHeight - heightHalf;
for ( var ix = 0; ix < gridX; ix ++ ) {
var x1 = ix * segmentWidth - widthHalf;
var x2 = ( ix + 1 ) * segmentWidth - widthHalf;
vertices[ offset + 0 ][ 0 ] = x1;
vertices[ offset + 0 ][ 1 ] = y1;
vertices[ offset + 1 ][ 0 ] = x2;
vertices[ offset + 1 ][ 1 ] = y1;
vertices[ offset + 2 ][ 0 ] = x1;
vertices[ offset + 2 ][ 1 ] = y2;
normals[ offset + 0 ][ 2 ] = 1;
normals[ offset + 1 ][ 2 ] = 1;
normals[ offset + 2 ][ 2 ] = 1;
vertices[ offset + 3 ][ 0 ] = x2;
vertices[ offset + 3 ][ 1 ] = y1;
vertices[ offset + 4 ][ 0 ] = x2;
vertices[ offset + 4 ][ 1 ] = y2;
vertices[ offset + 5 ][ 0 ] = x1;
vertices[ offset + 5 ][ 1 ] = y2;
normals[ offset + 3 ][ 2 ] = 1;
normals[ offset + 4 ][ 2 ] = 1;
normals[ offset + 5 ][ 2 ] = 1;
offset += 6;
}
}
};
THREE.PlaneGeometry3.prototype = Object.create( THREE.Geometry3.prototype );
/**
* @author mrdoob / http://mrdoob.com/
* based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as
*/
THREE.PlaneGeometryB = function ( width, height, widthSegments, heightSegments ) {
THREE.BufferGeometry.call( this );
this.width = width;
this.height = height;
this.widthSegments = widthSegments || 1;
this.heightSegments = heightSegments || 1;
var width_half = width / 2;
var height_half = height / 2;
var gridX = this.widthSegments;
var gridY = this.heightSegments;
var gridX1 = gridX + 1;
var gridY1 = gridY + 1;
var segment_width = this.width / gridX;
var segment_height = this.height / gridY;
var vertices = new Float32Array( gridX1 * gridY1 * 3 );
var normals = new Float32Array( gridX1 * gridY1 * 3 );
var uvs = new Float32Array( gridX1 * gridY1 * 2 );
var offset = 0;
var offset2 = 0;
for ( var iy = 0; iy < gridY1; iy ++ ) {
var y = iy * segment_height - height_half;
for ( var ix = 0; ix < gridX1; ix ++ ) {
var x = ix * segment_width - width_half;
vertices[ offset ] = x;
vertices[ offset + 1 ] = - y;
normals[ offset + 2 ] = 1;
uvs[ offset2 ] = ix / gridX;
uvs[ offset2 + 1 ] = iy / gridY;
offset += 3;
offset2 += 2;
}
}
var indices = new Uint16Array( gridX * gridY * 6 );
var offset = 0;
for ( var iy = 0; iy < gridY; iy ++ ) {
for ( var ix = 0; ix < gridX; ix ++ ) {
var a = ix + gridX1 * iy;
var b = ix + gridX1 * ( iy + 1 );
var c = ( ix + 1 ) + gridX1 * ( iy + 1 );
var d = ( ix + 1 ) + gridX1 * iy;
indices[ offset ] = a;
indices[ offset + 1 ] = b;
indices[ offset + 2 ] = d;
indices[ offset + 3 ] = b;
indices[ offset + 4 ] = c;
indices[ offset + 5 ] = d;
offset += 6;
}
}
this.attributes[ 'index' ] = { array: indices, itemSize: 1 };
this.attributes[ 'position' ] = { array: vertices, itemSize: 3 };
this.attributes[ 'normal' ] = { array: normals, itemSize: 3 };
this.attributes[ 'uv' ] = { array: uvs, itemSize: 2 };
};
THREE.PlaneGeometryB.prototype = Object.create( THREE.BufferGeometry.prototype );
......@@ -30,7 +30,6 @@
"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",
......@@ -48,7 +47,6 @@
"src/loaders/JSONLoader.js",
"src/loaders/LoadingManager.js",
"src/loaders/BufferGeometryLoader.js",
"src/loaders/Geometry2Loader.js",
"src/loaders/MaterialLoader.js",
"src/loaders/ObjectLoader.js",
"src/loaders/SceneLoader.js",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册