diff --git a/examples/canvas_geometry_terrain.html b/examples/canvas_geometry_terrain.html
index cd6176f7e4bd023775b02846f7f767e414ebd976..2f04c1fd40634867889f2b06f356d764f0f68f6c 100644
--- a/examples/canvas_geometry_terrain.html
+++ b/examples/canvas_geometry_terrain.html
@@ -36,8 +36,6 @@
-
-
@@ -77,8 +75,6 @@
var plane = new THREE.PlaneGeometry( 2000, 2000, quality - 1, quality - 1 );
plane.applyMatrix( new THREE.Matrix4().makeRotationX( - Math.PI / 2 ) );
- plane = new THREE.Geometry5b( plane );
-
for ( var i = 0, l = plane.vertices.length; i < l; i ++ ) {
var x = i % quality, y = Math.floor( i / quality );
diff --git a/src/extras/geometries/PlaneBufferGeometry.js b/src/extras/geometries/PlaneBufferGeometry.js
new file mode 100644
index 0000000000000000000000000000000000000000..630911b88acdfadf0b3adeb6264a296330ac4faa
--- /dev/null
+++ b/src/extras/geometries/PlaneBufferGeometry.js
@@ -0,0 +1,93 @@
+/**
+ * @author mrdoob / http://mrdoob.com/
+ * based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as
+ */
+
+THREE.PlaneBufferGeometry = function ( width, height, widthSegments, heightSegments ) {
+
+ THREE.BufferGeometry.call( this );
+
+ this.parameters = {
+ width: width,
+ height: height,
+ widthSegments: widthSegments,
+ heightSegments: heightSegments
+ };
+
+ var width_half = width / 2;
+ var height_half = height / 2;
+
+ var gridX = widthSegments || 1;
+ var gridY = heightSegments || 1;
+
+ var gridX1 = gridX + 1;
+ var gridY1 = gridY + 1;
+
+ var segment_width = width / gridX;
+ var segment_height = 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 ] = 1 - ( iy / gridY );
+
+ offset += 3;
+ offset2 += 2;
+
+ }
+
+ }
+
+ offset = 0;
+
+ var indices = new Uint16Array( gridX * gridY * 6 );
+
+ 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.PlaneBufferGeometry.prototype = Object.create( THREE.BufferGeometry.prototype );
diff --git a/src/extras/geometries/PlaneGeometry.js b/src/extras/geometries/PlaneGeometry.js
index 85480c043a27836e531aadfff582f1debc782f76..869becbd68f8347f38b8b89574423b7c38ac6f22 100644
--- a/src/extras/geometries/PlaneGeometry.js
+++ b/src/extras/geometries/PlaneGeometry.js
@@ -5,89 +5,22 @@
THREE.PlaneGeometry = function ( width, height, widthSegments, heightSegments ) {
- THREE.BufferGeometry.call( this );
+ THREE.PlaneBufferGeometry.call( this, width, height, widthSegments, heightSegments );
- this.parameters = {
- width: width,
- height: height,
- widthSegments: widthSegments,
- heightSegments: heightSegments
- };
+ var length = this.attributes.position.array.length;
- var width_half = width / 2;
- var height_half = height / 2;
+ this.vertices = [];
+ this.normals = [];
+ this.uvs = [];
- var gridX = widthSegments || 1;
- var gridY = heightSegments || 1;
+ for ( var i = 0, l = length / 3; i < l; i ++ ) {
- var gridX1 = gridX + 1;
- var gridY1 = gridY + 1;
-
- var segment_width = width / gridX;
- var segment_height = 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 ] = 1 - ( iy / gridY );
-
- offset += 3;
- offset2 += 2;
-
- }
+ 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 ) );
}
- offset = 0;
-
- var indices = new Uint16Array( gridX * gridY * 6 );
-
- 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.PlaneGeometry.prototype = Object.create( THREE.BufferGeometry.prototype );
+THREE.PlaneGeometry.prototype = Object.create( THREE.PlaneBufferGeometry.prototype );
diff --git a/src/math/TypedVector2.js b/src/math/TypedVector2.js
new file mode 100644
index 0000000000000000000000000000000000000000..f3f4f3a53859ba7c060ec85cc4f43cf473a5e242
--- /dev/null
+++ b/src/math/TypedVector2.js
@@ -0,0 +1,23 @@
+/**
+ * @author mrdoob / http://mrdoob.com/
+ */
+
+THREE.TypedVector2 = function ( array, offset ) {
+
+ this.array = array;
+ this.offset = offset;
+
+};
+
+THREE.TypedVector2.prototype = Object.create( THREE.Vector2.prototype );
+
+Object.defineProperties( THREE.TypedVector2.prototype, {
+ 'x': {
+ get: function () { return this.array[ this.offset ]; },
+ set: function ( v ) { this.array[ this.offset ] = v; }
+ },
+ 'y': {
+ get: function () { return this.array[ this.offset + 1 ]; },
+ set: function ( v ) { this.array[ this.offset + 1 ] = v; }
+ }
+} );
\ No newline at end of file
diff --git a/src/math/TypedVector3.js b/src/math/TypedVector3.js
new file mode 100644
index 0000000000000000000000000000000000000000..71a5b4824942d58e832863e0c3dbbdbdeab5bc14
--- /dev/null
+++ b/src/math/TypedVector3.js
@@ -0,0 +1,27 @@
+/**
+ * @author mrdoob / http://mrdoob.com/
+ */
+
+THREE.TypedVector3 = function ( array, offset ) {
+
+ this.array = array;
+ this.offset = offset;
+
+};
+
+THREE.TypedVector3.prototype = Object.create( THREE.Vector3.prototype );
+
+Object.defineProperties( THREE.TypedVector3.prototype, {
+ 'x': {
+ get: function () { return this.array[ this.offset ]; },
+ set: function ( v ) { this.array[ this.offset ] = v; }
+ },
+ 'y': {
+ get: function () { return this.array[ this.offset + 1 ]; },
+ set: function ( v ) { this.array[ this.offset + 1 ] = v; }
+ },
+ 'z': {
+ get: function () { return this.array[ this.offset + 2 ]; },
+ set: function ( v ) { this.array[ this.offset + 2 ] = v; }
+ }
+} );
\ No newline at end of file
diff --git a/utils/build/includes/common.json b/utils/build/includes/common.json
index a9f954cf25e4e6add91e22c3b93f90148c7e240a..6fba8af21f6b29669b462f9c306a1a707d2104fb 100644
--- a/utils/build/includes/common.json
+++ b/utils/build/includes/common.json
@@ -5,6 +5,8 @@
"src/math/Vector2.js",
"src/math/Vector3.js",
"src/math/Vector4.js",
+ "src/math/TypedVector2.js",
+ "src/math/TypedVector3.js",
"src/math/Euler.js",
"src/math/Line3.js",
"src/math/Box2.js",
diff --git a/utils/build/includes/extras.json b/utils/build/includes/extras.json
index 0d3bd9b9053188f7e6297331faf5d47d617ad9c5..52edcda99b9286adcd576112ce8d07b6d1d023c4 100644
--- a/utils/build/includes/extras.json
+++ b/utils/build/includes/extras.json
@@ -32,6 +32,7 @@
"src/extras/geometries/ExtrudeGeometry.js",
"src/extras/geometries/ShapeGeometry.js",
"src/extras/geometries/LatheGeometry.js",
+ "src/extras/geometries/PlaneBufferGeometry.js",
"src/extras/geometries/PlaneGeometry.js",
"src/extras/geometries/RingGeometry.js",
"src/extras/geometries/SphereGeometry.js",