Browse Source

Updated builds.

Mr.doob 11 years ago
parent
commit
36b7392889
2 changed files with 1040 additions and 299 deletions
  1. 936 217
      build/three.js
  2. 104 82
      build/three.min.js

+ 936 - 217
build/three.js

@@ -9397,7 +9397,7 @@ THREE.BufferGeometry.prototype = {
 
 				var indices = this.attributes[ "index" ].array;
 
-				var offsets = this.offsets;
+				var offsets = (this.offsets.length > 0 ? this.offsets : [ { start: 0, count: indices.length, index: 0 } ]);
 
 				for ( j = 0, jl = offsets.length; j < jl; ++ j ) {
 
@@ -9943,24 +9943,34 @@ THREE.EventDispatcher.prototype.apply( THREE.BufferGeometry.prototype );
  * @author mrdoob / http://mrdoob.com/
  */
 
-THREE.BufferGeometryManipulator = function ( bufferGeometry ) {
+THREE.Geometry2 = function ( vertices, normals, uvs ) {
 
-	this.vertices = [];
-	this.normals = [];
-	this.uvs = [];
+	THREE.BufferGeometry.call( this );
 
-	var attributes = bufferGeometry.attributes;
-	var length = attributes.position.array.length / 3;
+	this.attributes[ 'position' ] = { array: vertices, itemSize: 3 };
+	this.attributes[ 'normal' ] = { array: normals, itemSize: 3 };
+	this.attributes[ 'uv' ] = { array: uvs, itemSize: 2 };	
 
-	for ( var i = 0; i < length; i ++ ) {
+};
 
-		this.vertices.push( new THREE.ProxyVector3( attributes.position.array, i * 3 ) );
-		this.normals.push( new THREE.ProxyVector3( attributes.normal.array, i * 3 ) );
-		this.uvs.push( new THREE.ProxyVector2( attributes.uv.array, i * 2 ) );
+THREE.Geometry2.prototype = Object.create( THREE.BufferGeometry.prototype );
+/**
+ * @author mrdoob / http://mrdoob.com/
+ */
 
-	}
+THREE.IndexedGeometry2 = function ( indices, vertices, normals, uvs ) {
+
+	THREE.BufferGeometry.call( this );
+
+	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.IndexedGeometry2.prototype = Object.create( THREE.BufferGeometry.prototype );
+
 /**
  * @author mrdoob / http://mrdoob.com/
  * @author kile / http://kile.stravaganza.org/
@@ -10630,73 +10640,179 @@ THREE.GeometryIdCount = 0;
  * @author mrdoob / http://mrdoob.com/
  */
 
-THREE.Geometry2 = function ( vertices, normals, uvs ) {
+THREE.GeometryEditor = function ( geometry ) {
 
-	THREE.BufferGeometry.call( this );
+	this.geometry = geometry;
 
-	this.attributes[ 'position' ] = { array: vertices, itemSize: 3 };
-	this.attributes[ 'normal' ] = { array: normals, itemSize: 3 };
-	this.attributes[ 'uv' ] = { array: uvs, itemSize: 2 };	
+};
+
+Object.defineProperties( THREE.GeometryEditor.prototype, {
+	vertices: { 
+		enumerable: true,
+		get: function() { return this.createVertexProxies(); }
+	},
+	normals: {
+		enumerable: true,
+		get: function() { return this.createNormalProxies(); } 
+	},
+	uvs: {
+		enumerable: true,
+		get: function() { return this.createUVProxies(); } 
+	}
+} );
+
+THREE.GeometryEditor.prototype.createVertexProxies = function () {
+
+	Object.defineProperty( this, 'vertices', { value: [], writable: true } );
+
+	var attributes = this.geometry.attributes;
+	var length = attributes.position.array.length / 3;
+
+	for ( var i = 0; i < length; i ++ ) {
+
+		this.vertices.push( new THREE.ProxyVector3( attributes.position.array, i * 3 ) );
+
+	}
+
+	return this.vertices;
 
 };
 
-THREE.Geometry2.prototype = Object.create( THREE.BufferGeometry.prototype );
+THREE.GeometryEditor.prototype.createNormalProxies = function () {
+
+	Object.defineProperty( this, 'normals', { value: [], writable: true } );
+
+	var attributes = this.geometry.attributes;
+	var length = attributes.position.array.length / 3;
+
+	for ( var i = 0; i < length; i ++ ) {
+
+		this.normals.push( new THREE.ProxyVector3( attributes.normal.array, i * 3 ) );
+
+	}
+
+	return this.normals;
+
+};
 
-THREE.Geometry99 = function ( ) {
+THREE.GeometryEditor.prototype.createUVProxies = function () {
+
+	Object.defineProperty( this, 'uvs', { value: [], writable: true } );
+
+	var attributes = this.geometry.attributes;
+	var length = attributes.position.array.length / 3;
+
+	for ( var i = 0; i < length; i ++ ) {
+
+		this.uvs.push( new THREE.ProxyVector2( attributes.uv.array, i * 2 ) );
+
+	}
+
+	return this.uvs;
+
+};
+/**
+ * @author mrdoob / http://mrdoob.com/
+ * @author kile / http://kile.stravaganza.org/
+ * @author alteredq / http://alteredqualia.com/
+ * @author mikael emtinger / http://gomo.se/
+ * @author zz85 / http://www.lab4games.net/zz85/blog
+ * @author bhouston / http://exocortex.com
+ * @author jbaicoianu / http://baicoianu.com
+ */
+
+THREE.ProxyGeometry = function ( ) {
 
 	THREE.BufferGeometry.call( this );
 
+	this.addEventListener( 'allocate', this.onGeometryAllocate);
+
+	// TODO - implement as BufferGeometry attributes
+	this.morphTargets = [];
+	this.morphColors = [];
+
 };
 
-THREE.Geometry99.prototype = Object.create( THREE.BufferGeometry.prototype );
+THREE.ProxyGeometry.prototype = Object.create( THREE.IndexedGeometry2.prototype );
 
-Object.defineProperties( THREE.Geometry99.prototype, {
+Object.defineProperties(THREE.ProxyGeometry.prototype, {
 	vertices: { 
 		enumerable: true, 
-		get: function () { return this.createVertexProxies(); } 
+		configurable: true, 
+		get: function() { return this.createVertexProxies(); }
 	},
 	faces: {
 		enumerable: true,	
-		get: function () { return this.createFaceProxies() } 
+		get: function() { return this.createFaceProxies() } 
 	},
 	faceVertexUvs: {
 		enumerable: true,	
-		get: function () { return this.createUvProxies() } 
+		get: function() { return this.createUvProxies() } 
+	},
+	colors: {
+		enumerable: true,	
+		get: function() { return this.createColorProxies() } 
+	},
+	skinIndices: {
+		enumerable: true,	
+		get: function() { return this.createSkinIndexProxies() } 
+	},
+	skinWeights: {
+		enumerable: true,	
+		get: function() { return this.createSkinWeightProxies() } 
 	},
 	// TODO - fill in additional proxies:
 	// - morphColors
 	// - morphNormals
 	// - morphTargets
-	// - skinIndex
-	// - skinWeights
-
 
 	verticesNeedUpdate: {
 		enumerable: true,	
-		get: function () { return this.attributes[ 'position' ].needsUpdate; } ,
-		set: function ( v ) { this.attributes[ 'position' ].needsUpdate = v; } 
+		get: function() { if (this.attributes[ 'position' ]) return this.attributes[ 'position' ].needsUpdate; } ,
+		set: function(v) { if (this.attributes[ 'position' ]) this.attributes[ 'position' ].needsUpdate = v; } 
 	},
 	colorsNeedUpdate: {
 		enumerable: true,	
-		get: function () { if ( this.attributes[ 'color' ] ) return this.attributes[ 'color' ].needsUpdate; } ,
-		set: function ( v ) { if ( this.attributes[ 'color' ] ) this.attributes[ 'color' ].needsUpdate = v; } 
+		get: function() { if (this.attributes[ 'color' ]) return this.attributes[ 'color' ].needsUpdate; } ,
+		set: function(v) { if (this.attributes[ 'color' ]) this.attributes[ 'color' ].needsUpdate = v; } 
 	},
 	normalsNeedUpdate: {
 		enumerable: true,	
-		get: function () { if ( this.attributes[ 'normal' ] ) return this.attributes[ 'normal' ].needsUpdate; } ,
-		set: function ( v ) { if ( this.attributes[ 'normal' ] ) this.attributes[ 'normal' ].needsUpdate = v; } 
+		get: function() { if (this.attributes[ 'normal' ]) return this.attributes[ 'normal' ].needsUpdate; } ,
+		set: function(v) { if (this.attributes[ 'normal' ]) this.attributes[ 'normal' ].needsUpdate = v; } 
 	},
 });
 
-THREE.Geometry99.prototype.createVertexProxies = function () {
+THREE.ProxyGeometry.prototype.createVertexProxies = function(values) {
 
-	// Replace the prototype getter with a local array property
+	if (!this.hasOwnProperty('vertices')) {
+
+		// Replace the prototype getter with a local array property
+
+		Object.defineProperty( this, "vertices", { value: [], writable: true } );
+
+	} else {
+
+		// Start with a new, empty array
 
-	Object.defineProperty( this, "vertices", { value: [] } );
+		this.vertices = [];
+
+	}
 
 	// If the attribute buffer has already been populated, set up proxy objects
 
-	this.populateProxyFromBuffer( this.vertices, "position", THREE.TypedVector3, 3 );
+	this.populateProxyFromBuffer(this.vertices, "position", THREE.ProxyVector3, 3);
+
+	// If values were passed in, store them in the buffer via the proxy objects
+
+	if (values) {
+
+		for (var i = 0; i < values.length; i++) {
+
+			this.vertices[i].copy(values[i]);
+
+		}
+	}
 
 	// Return a reference to the newly-created array
 
@@ -10704,32 +10820,47 @@ THREE.Geometry99.prototype.createVertexProxies = function () {
 
 }
 
-THREE.Geometry99.prototype.createFaceProxies = function () {
+THREE.ProxyGeometry.prototype.createFaceProxies = function(values) {
 
-	// Replace the prototype getter with a local array property
+	if (!this.hasOwnProperty("faces")) {
 
-	Object.defineProperty( this, "faces", { value: [] } );
+		// Replace the prototype getter with a local array property
+
+		Object.defineProperty( this, "faces", { value: [], writable: true } );
+
+	} else {
+
+		// Start with a new, empty array
+
+		this.faces = [];
+	}
 
 	// If the attribute buffer has already been populated, set up proxy objects
 
 	var faces = this.faces,
-	    indexarray = false,
-	    positionarray = false,
-	    normalarray = false,
-	    colorarray = false;
+			indexarray = false,
+			positionarray = false,
+			normalarray = false,
+			colorarray = false,
+			tangentarray = false;
 
-	if ( this.attributes.position ) {
-		positionarray = this.attributes[ 'position' ].array;
-	}
-	if ( this.attributes.index ) {
+	if ( this.attributes[ 'index' ] ) {
 		indexarray = this.attributes[ 'index' ].array;
 	}
+	if ( this.attributes[ 'position' ] ) {
+		positionarray = this.attributes[ 'position' ].array;
+	}
 	if (this.attributes[ 'normal' ]) {
 		normalarray = this.attributes[ 'normal' ].array;
 	}
 	if (this.attributes[ 'color' ]) {
 		colorarray = this.attributes[ 'color' ].array;
 	}
+	if (this.attributes[ 'tangent' ]) {
+		tangentarray = this.attributes[ 'tangent' ].array;
+	}
+
+	// TODO - this should be accomplished using "virtual" functions on various classes (IndexedGeometry, SmoothGeometry, etc)
 
 	if (indexarray) {
 
@@ -10737,76 +10868,57 @@ THREE.Geometry99.prototype.createFaceProxies = function () {
 
 			var o = i * 3;
 
-			// Generate face.vertexNormals and face.vertexFaceColors
-			var vertexNormals = false,
-			    vertexColors = false;
-			if (normalarray) {
-
-				vertexNormals = [
-					new THREE.TypedVector3(normalarray, indexarray[o] * 3),
-					new THREE.TypedVector3(normalarray, indexarray[o+1] * 3),
-					new THREE.TypedVector3(normalarray, indexarray[o+2] * 3),
-				]
-
-			}
+			var face = new THREE.ProxyFace3( indexarray, i * 3 );
+			faces.push(face);
 
-			// TODO - do BufferGeometries support face normals?
+		}
 
-			if (colorarray) {
+	} else if (positionarray) {
 
-				vertexColors = [
-					new THREE.TypedColor(colorarray, indexarray[o] * 3),
-					new THREE.TypedColor(colorarray, indexarray[o+1] * 3),
-					new THREE.TypedColor(colorarray, indexarray[o+2] * 3),
-				]
+		for ( var i = 0, l = positionarray.length / 3; i < l; i += 3 ) {
 
-			}
+			var o = i * 3;
+			var v1 = i, v2 = i+1, v3 = i+2;
 
-			var face = new THREE.TypedFace3( indexarray, i * 3, vertexNormals );
+			var face = new THREE.ProxyFace3( v1, v2, v3 );
+			faces.push(face);
 
 		}
 
-	} else {
+	}
 
-		for ( var i = 0, l = positionarray.length / 3; i < l; i += 3 ) {
+	// If values were passed in, store them in the buffer via the proxy objects
 
-			var o = i * 3;
+	if (values) {
 
-			var v1 = i, v2 = i+1, v3 = i+2;
+		for (var i = 0, l = values.length; i < l; i++) {
 
-			// Generate face.vertexNormals and face.vertexColors
+			var f = faces[i],
+			    v = values[i];
 
-			// TODO - do BufferGeometries support face normals/face colors?
-			// Maybe they could be implemented using some sort of TypedMultiVector3 which would let us expose a single
-			// face.normal Vector3, and it would simultaneously update the three vertexNormals involved in this face with the same values
+			f.a = v.a;
+			f.b = v.b;
+			f.c = v.c;
 
-			var vertexNormals = false,
-			    vertexColors = false;
-			if (normalarray) {
+		}
 
-				vertexNormals = [
-					new THREE.TypedVector3(normalarray, o),
-					new THREE.TypedVector3(normalarray, o+3),
-					new THREE.TypedVector3(normalarray, o+6),
-				];
+	}
 
-			}
+	if (normalarray) {
 
-			if (colorarray) {
+		this.createFaceVertexNormalProxies(values);
 
-				vertexColors = [
-					new THREE.TypedColor(colorarray, o),
-					new THREE.TypedColor(colorarray, o+3),
-					new THREE.TypedColor(colorarray, o+6),
-				];
+	}
 
-			}
+	if (colorarray) {
 
-			var face = new THREE.Face3( v1, v2, v3, vertexNormals, vertexColors );
+		this.createFaceVertexColorProxies(values);
 
-			faces.push(face);
+	}
 
-		}
+	if (tangentarray) {
+
+		this.createFaceVertexTangentProxies(values);
 
 	}
 
@@ -10815,51 +10927,49 @@ THREE.Geometry99.prototype.createFaceProxies = function () {
 	return this.faces;
 
 }
-THREE.Geometry99.prototype.createUvProxies = function () {
 
-	// Replace the prototype getter with a local array property
-
-	Object.defineProperty( this, "faceVertexUvs", { value: [[]] } );
-
-	// If the attribute buffer has already been populated, set up proxy objects
+THREE.ProxyGeometry.prototype.createFaceVertexNormalProxies = function(values) {
 
-	if ( this.attributes.uv ) {
+	if ( this.attributes[ 'normal' ] && this.attributes[ 'normal' ].array ) {
 
-		var faces = this.faces;
-		var uvarray = this.attributes.uv.array;
+		var normalarray = this.attributes[ 'normal' ].array;
 
-		for ( var i = 0, l = faces.length; i < l; i ++ ) {
+		for (var i = 0, l = this.faces.length; i < l; i++) {
 
-			var f = faces[i];
+			var f = this.faces[i];
 
-			this.faceVertexUvs[ 0 ][ i ] = [];
-			this.faceVertexUvs[ 0 ][ i ][ 0 ] = new THREE.TypedVector2( uvarray, f.a * 2 );
-			this.faceVertexUvs[ 0 ][ i ][ 1 ] = new THREE.TypedVector2( uvarray, f.b * 2 );
-			this.faceVertexUvs[ 0 ][ i ][ 2 ] = new THREE.TypedVector2( uvarray, f.c * 2 );
+			f.vertexNormals = [
+				new THREE.ProxyVector3(normalarray, f.a * 3),
+				new THREE.ProxyVector3(normalarray, f.b * 3),
+				new THREE.ProxyVector3(normalarray, f.c * 3),
+			];
+			f.normal = new THREE.MultiVector3(f.vertexNormals);
 
 		}
-	
 	}
 
-	// Return a reference to the newly-created array
+	// If values were passed in, store them in the buffer via the proxy objects
 
-	return this.faceVertexUvs;
+	if (values) {
 
-}
+		for (var i = 0, l = values.length; i < l; i++) {
 
-THREE.Geometry99.prototype.populateProxyFromBuffer = function ( attr, buffername, proxytype, itemsize, offset, count ) {
+			var f = this.faces[i],
+			    v = values[i];
 
-	if ( this.attributes[ buffername ] ) {
+			if (v.vertexNormals.length > 0) {
 
-		var array = this.attributes[ buffername ].array;
-		var size = itemsize || this.attributes[ buffername ].itemSize;
-		var start = offset || 0;
-		
-		count = count || ( array.length / size - start );
+				for (var j = 0, l2 = f.vertexNormals.length; j < l2; j++) {
 
-		for ( var i = start, l = start + count; i < l; i ++ ) {
+					f.vertexNormals[j].copy(v.vertexNormals[j]);
 
-			attr.push( new proxytype( array, i * size ) );
+				}
+
+			} else if (v.normal) {
+
+				f.normal.copy(v.normal);
+
+			}
 
 		}
 
@@ -10867,127 +10977,736 @@ THREE.Geometry99.prototype.populateProxyFromBuffer = function ( attr, buffername
 
 }
 
-// Proxies
+THREE.ProxyGeometry.prototype.createFaceVertexColorProxies = function(values) {
 
-THREE.TypedVector2 = function ( array, offset ) {
+	if ( this.attributes[ 'color' ] && this.attributes[ 'color' ].array ) {
 
-	this.array = array;
-	this.offset = offset;
-	
-};
+		var colorarray = this.attributes[ 'color' ].array;
 
-THREE.TypedVector2.prototype = Object.create( THREE.Vector2.prototype );
+		for (var i = 0, l = this.faces.length; i < l; i++) {
+			var f = this.faces[i];
 
-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; }
+			if ( this.attributes[ 'index' ] ) {
+				f.vertexColors = [
+						new THREE.ProxyColor(colorarray, f.a * 3),
+						new THREE.ProxyColor(colorarray, f.b * 3),
+						new THREE.ProxyColor(colorarray, f.c * 3),
+					];
+			} else {
+				var o = i * 9;
+
+				f.vertexColors = [
+						new THREE.ProxyColor(colorarray, o),
+						new THREE.ProxyColor(colorarray, o + 3),
+						new THREE.ProxyColor(colorarray, o + 6),
+					];
+			}
+			f.color = new THREE.MultiColor(f.vertexColors);
+
+		}
 	}
-} );
 
-//
+	// If values were passed in, store them in the buffer via the proxy objects
 
+	if (values) {
 
-THREE.TypedVector3 = function ( array, offset ) {
-	
-	this.array = array;
-	this.offset = offset;
+		for (var i = 0, l = values.length; i < l; i++) {
 
-};
+			var f = this.faces[i],
+			    v = values[i];
 
-THREE.TypedVector3.prototype = Object.create( THREE.Vector3.prototype );
+			for (var j = 0, l2 = f.vertexColors.length; j < l2; j++) {
 
-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; }
-	}
-} );
+				if (v.vertexColors.length > 0) {
 
-//
+					f.vertexColors[j].copy(v.vertexColors[j]);
 
-THREE.TypedFace3 = function ( array, offset, vertexNormals ) {
+				} else if (v.color) {
 
-	this.array = array;
-	this.offset = offset;
-	this.vertexNormals = vertexNormals;
+					f.color.copy(v.color);
 
-	//THREE.Face3.call( this, array[offset], array[offset+1], array[offset+2] /*, normal, color, materialIndex */);
+				}
 
-}
+			}
 
-THREE.TypedFace3.prototype = Object.create( THREE.Face3.prototype );
+		}
 
-Object.defineProperties( THREE.TypedFace3.prototype, {
-	'a': {
-		enumerable: true,	
-		get: function () { return this.array[ this.offset ]; },
-		set: function ( v ) { this.array[ this.offset ] = v; }
-	},
-	'b': {
-		enumerable: true,	
-		get: function () { return this.array[ this.offset + 1 ]; },
-		set: function ( v ) { this.array[ this.offset + 1 ] = v; }
-	},
-	'c': {
-		enumerable: true,	
-		get: function () { return this.array[ this.offset + 2 ]; },
-		set: function ( v ) { this.array[ this.offset + 2 ] = v; }
-	},
-} );
+	}
 
-THREE.TypedColor = function ( array, offset ) {
-	this.array = array;
-	this.offset = offset;
 }
-THREE.TypedColor.prototype = Object.create( THREE.Color.prototype );
 
-Object.defineProperties( THREE.TypedColor.prototype, {
-	'r': {
-		enumerable: true,	
-		get: function () { return this.array[ this.offset ]; },
-		set: function ( v ) { this.array[ this.offset ] = v; }
-	},
-	'g': {
-		enumerable: true,	
-		get: function () { return this.array[ this.offset + 1 ]; },
-		set: function ( v ) { this.array[ this.offset + 1 ] = v; }
-	},
-	'b': {
-		enumerable: true,	
-		get: function () { return this.array[ this.offset + 2 ]; },
-		set: function ( v ) { this.array[ this.offset + 2 ] = v; }
-	}
-} );
+THREE.ProxyGeometry.prototype.createFaceVertexTangentProxies = function(values) {
 
-/**
- * @author mrdoob / http://mrdoob.com/
- */
+	if ( this.attributes[ 'tangent' ] && this.attributes[ 'tangent' ].array ) {
 
-THREE.IndexedGeometry2 = function ( indices, vertices, normals, uvs ) {
+		var tangentarray = this.attributes[ 'tangent' ].array;
 
-	THREE.BufferGeometry.call( this );
+		for (var i = 0, l = this.faces.length; i < l; i++) {
 
-	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 };	
+			var f = this.faces[i];
+
+			f.vertexTangents = [
+				new THREE.ProxyVector3(tangentarray, f.a * 3),
+				new THREE.ProxyVector3(tangentarray, f.b * 3),
+				new THREE.ProxyVector3(tangentarray, f.c * 3),
+			];
+
+		}
+	}
+
+	// If values were passed in, store them in the buffer via the proxy objects
+
+	if (values) {
+
+		for (var i = 0, l = values.length; i < l; i++) {
+
+			var f = this.faces[i],
+			    v = values[i];
+
+			if (v.vertexTangents.length > 0) {
+
+				for (var j = 0, l2 = f.vertexTangents.length; j < l2; j++) {
+
+					f.vertexTangents[j].copy(v.vertexTangents[j]);
+
+				}
+
+			}
+
+		}
+
+	}
+
+}
+
+THREE.ProxyGeometry.prototype.createUvProxies = function(values) {
+
+	// Replace the prototype getter with a local array property
+
+	if (!this.hasOwnProperty("faceVertexUvs")) {
+		Object.defineProperty( this, "faceVertexUvs", { value: [[]], writable: true } );
+	} else {
+		this.faceVertexUvs = [[]];
+	}
+
+	// If the attribute buffer has already been populated, set up proxy objects
+
+	if ( this.attributes[ 'uv' ] && this.attributes[ 'uv' ].array ) {
+
+		var faces = this.faces;
+		var uvarray = this.attributes[ 'uv' ].array;
+
+		for (var i = 0, l = faces.length; i < l; i++) {
+			var f = faces[i];
+
+			this.faceVertexUvs[0][i] = [];
+
+			if ( this.attributes[ 'index' ] ) {
+				this.faceVertexUvs[0][i][0] = new THREE.ProxyVector2(uvarray, f.a * 2);
+				this.faceVertexUvs[0][i][1] = new THREE.ProxyVector2(uvarray, f.b * 2);
+				this.faceVertexUvs[0][i][2] = new THREE.ProxyVector2(uvarray, f.c * 2);
+			} else {
+				var o = i * 6;
+				this.faceVertexUvs[0][i][0] = new THREE.ProxyVector2(uvarray, o);
+				this.faceVertexUvs[0][i][1] = new THREE.ProxyVector2(uvarray, o + 2);
+				this.faceVertexUvs[0][i][2] = new THREE.ProxyVector2(uvarray, o + 4);
+			}
+
+		}
+	
+	}
+
+	// If values were passed in, store them in the buffer via the proxy objects
+
+	if (values) {
+
+		for (var i = 0, l = values.length; i < l; i++) {
+
+			for (var j = 0, l2 = values[i].length; j < l2; j++) {
+
+				var uv = values[i][j];
+				this.faceVertexUvs[0][i][j].copy(uv);
+
+			}
+
+		}
+
+	}
+
+	// Return a reference to the newly-created array
+
+	return this.faceVertexUvs;
+
+}
+
+THREE.ProxyGeometry.prototype.createSkinIndexProxies = function(values) {
+
+	// Replace the prototype getter with a local array property
+
+	if (!this.hasOwnProperty('skinIndices')) {
+		Object.defineProperty( this, "skinIndices", { value: [], writable: true } );
+	} else {
+		this.skinIndices = [];
+	}
+
+	// If the attribute buffer has already been populated, set up proxy objects
+
+	this.populateProxyFromBuffer(this.skinIndices, "skinIndex", THREE.ProxyVector4, 4);
+
+	// If values were passed in, store them in the buffer via the proxy objects
+
+	if (values) {
+
+		for (var i = 0; i < values.length; i++) {
+
+			this.skinIndices[i].copy(values[i]);
+
+		}
+
+	}
+
+	// Return a reference to the newly-created array
+
+	return this.skinIndices;
+
+}
+
+THREE.ProxyGeometry.prototype.createSkinWeightProxies = function(values) {
+
+	// Replace the prototype getter with a local array property
+
+	if (!this.hasOwnProperty('skinWeights')) {
+		Object.defineProperty( this, "skinWeights", { value: [], writable: true } );
+	} else {
+		this.skinWeights = [];
+	}
+
+	// If the attribute buffer has already been populated, set up proxy objects
+
+	this.populateProxyFromBuffer(this.skinWeights, "skinWeight", THREE.ProxyVector4, 4);
+
+	// If values were passed in, store them in the buffer via the proxy objects
+
+	if (values) {
+
+		for (var i = 0; i < values.length; i++) {
+
+			this.skinWeights[i].copy(values[i]);
+
+		}
+
+	}
+
+	// Return a reference to the newly-created array
+
+	return this.skinWeights;
+
+}
+
+THREE.ProxyGeometry.prototype.createColorProxies = function(values) {
+
+	// Replace the prototype getter with a local array property
+
+	if (!this.hasOwnProperty('colors')) {
+		Object.defineProperty( this, "colors", { value: [], writable: true } );
+	} else {
+		this.colors = [];
+	}
+
+	// If the attribute buffer has already been populated, set up proxy objects
+
+	this.populateProxyFromBuffer(this.colors, "color", THREE.ProxyColor, 3);
+
+	// If values were passed in, store them in the buffer via the proxy objects
+
+	if (values) {
+
+		for (var i = 0; i < values.length; i++) {
+
+			this.colors[i].copy(values[i]);
+
+		}
+
+	}
+
+	// Return a reference to the newly-created array
+
+	return this.colors;
+
+}
+
+THREE.ProxyGeometry.prototype.populateProxyFromBuffer = function(attr, buffername, proxytype, itemsize, offset, count) {
+
+	if ( this.attributes[ buffername ] && this.attributes[ buffername ].array ) {
+
+		var array = this.attributes[ buffername ].array;
+		var size = itemsize || this.attributes[ buffername ].itemSize;
+		var start = offset || 0;
+		
+		count = count || (array.length / size - start);
+
+		for ( var i = start, l = start + count; i < l; i ++ ) {
+
+			attr.push( new proxytype( array, i * size ) );
+
+		}
+
+	}
+
+}
+
+/*
+ * Checks for duplicate vertices with hashmap.
+ * Duplicated vertices are removed
+ * and faces' vertices are updated.
+ */
+
+THREE.ProxyGeometry.prototype.mergeVertices = function () {
+
+	var verticesMap = {}; // Hashmap for looking up vertice by position coordinates (and making sure they are unique)
+	var unique = [], changes = [];
+
+	var v, key;
+	var precisionPoints = 4; // number of decimal points, eg. 4 for epsilon of 0.0001
+	var precision = Math.pow( 10, precisionPoints );
+	var i,il, face;
+	var indices, k, j, jl, u;
+
+	for ( i = 0, il = this.vertices.length; i < il; i ++ ) {
+
+		v = this.vertices[ i ];
+		key = Math.round( v.x * precision ) + '_' + Math.round( v.y * precision ) + '_' + Math.round( v.z * precision );
+
+		if ( verticesMap[ key ] === undefined ) {
+
+			verticesMap[ key ] = i;
+			unique.push( this.vertices[ i ] );
+			changes[ i ] = unique.length - 1;
+
+		} else {
+
+			//console.log('Duplicate vertex found. ', i, ' could be using ', verticesMap[key]);
+			changes[ i ] = changes[ verticesMap[ key ] ];
+
+		}
+
+	};
+
+
+	// if faces are completely degenerate after merging vertices, we
+	// have to remove them from the geometry.
+	var faceIndicesToRemove = [];
+
+	for( i = 0, il = this.faces.length; i < il; i ++ ) {
+
+		face = this.faces[ i ];
+
+		face.a = changes[ face.a ];
+		face.b = changes[ face.b ];
+		face.c = changes[ face.c ];
+
+		indices = [ face.a, face.b, face.c ];
+
+		var dupIndex = -1;
+
+		// if any duplicate vertices are found in a Face3
+		// we have to remove the face as nothing can be saved
+		for ( var n = 0; n < 3; n ++ ) {
+			if ( indices[ n ] == indices[ ( n + 1 ) % 3 ] ) {
+
+				dupIndex = n;
+				faceIndicesToRemove.push( i );
+				break;
+
+			}
+		}
+
+	}
+
+	for ( i = faceIndicesToRemove.length - 1; i >= 0; i -- ) {
+		var idx = faceIndicesToRemove[ i ];
+
+		this.faces.splice( idx, 1 );
+
+		for ( j = 0, jl = this.faceVertexUvs.length; j < jl; j ++ ) {
+
+			this.faceVertexUvs[ j ].splice( idx, 1 );
+
+		}
+
+	}
+
+	// Use unique set of vertices
+
+	var diff = this.vertices.length - unique.length;
+	this.vertices = unique;
+	return diff;
+
+}
+
+THREE.ProxyGeometry.prototype.onGeometryAllocate = function (ev) {
+
+	// Prevent allocate event listener from firing multiple times
+	this.removeEventListener( 'allocate', this.onGeometryAllocate);
+
+	if (this.hasOwnProperty('vertices')) {
+		var attr = new THREE.Float32Attribute(this.vertices.length, 3);
+		this.addAttribute('position', attr);
+		this.createVertexProxies(this.vertices);
+	}
+	if (this.hasOwnProperty('faces')) {
+		var idxattr = new THREE.Uint16Attribute(this.faces.length, 3);
+		this.addAttribute('index', idxattr);
+
+		if (this.faces.length > 0) {
+			var hasnormals = (this.hasOwnProperty('normals') || this.faces[0].normal || this.faces[0].vertexNormals.length > 0);
+			var hascolors = (this.hasOwnProperty('colors') || this.faces[0].color || this.faces[0].vertexColors.length > 0);
+			var hastangents = (this.faces[0].vertexTangents.length > 0);
+
+			if (hasnormals) {
+				var normalattr = new THREE.Float32Attribute(this.vertices.length, 3);
+				this.addAttribute('normal', normalattr);
+			}
+
+			if (hascolors) {
+				var colorattr = new THREE.Float32Attribute(this.faces.length * 3, 3);
+				this.addAttribute('color', colorattr);
+			}
+
+			if (hastangents) {
+				var tangentattr = new THREE.Float32Attribute(this.faces.length * 3, 3);
+				this.addAttribute('tangent', tangentattr);
+			}
+		}
+
+		this.createFaceProxies(this.faces);
+	}
+
+	if (this.hasOwnProperty('faceVertexUvs')) {
+
+		var uvattr = new THREE.Float32Attribute(this.faces.length * 3, 2);
+		this.addAttribute('uv', uvattr);
+		this.createUvProxies(this.faceVertexUvs[0]);
+
+	}
+
+	if (this.hasOwnProperty('skinIndices')) {
+
+		var skinidxattr = new THREE.Float32Attribute(this.skinIndices.length, 4);
+		this.addAttribute('skinIndex', skinidxattr);
+		this.createSkinIndexProxies(this.skinIndices);
+
+	}
+
+	if (this.hasOwnProperty('skinWeights')) {
+
+		var skinweightattr = new THREE.Float32Attribute(this.skinWeights.length, 4);
+		this.addAttribute('skinWeight', skinweightattr);
+		this.createSkinWeightProxies(this.skinWeights);
+
+	}
+}
+
+THREE.ProxyGeometry.prototype.computeFaceNormals = function() {
+
+	this.dispatchEvent( { type: 'allocate' } );
+
+	return THREE.BufferGeometry.prototype.computeFaceNormals.call(this);
+
+}
+
+THREE.ProxyGeometry.prototype.computeVertexNormals = function() {
+
+	this.dispatchEvent( { type: 'allocate' } );
+
+	return THREE.BufferGeometry.prototype.computeVertexNormals.call(this);
+
+}
+
+THREE.ProxyGeometry.prototype.computeTangents = function() {
+
+	this.dispatchEvent( { type: 'allocate' } );
+
+	var ret = THREE.BufferGeometry.prototype.computeTangents.call(this);
+
+	// FIXME - this doesn't work yet
+	//this.createFaceVertexTangentProxies();
+
+	return ret;
+
+}
+
+THREE.ProxyGeometry.prototype.computeBoundingSphere = function() {
+
+	this.dispatchEvent( { type: 'allocate' } );
+
+	return THREE.BufferGeometry.prototype.computeBoundingSphere.call(this);
+
+}
+
+THREE.ProxyGeometry.prototype.computeBoundingBox = function () {
+
+	this.dispatchEvent( { type: 'allocate' } );
+
+	return THREE.BufferGeometry.prototype.computeBoundingBox.call(this);
+
+}
+THREE.ProxyGeometry.prototype.clone = function () {
+
+	var buff = THREE.BufferGeometry.prototype.clone.call(this);
+	var geo = new THREE.ProxyGeometry();
+	geo.attributes = buff.attributes;
+	geo.offsets = buff.offsets;
+
+	return geo;
+
+}
+
+THREE.EventDispatcher.prototype.apply( THREE.ProxyGeometry.prototype );
+
+THREE.ProxyGeometryIdCount = 0;
+
+// Allows updating of multiple THREE.Color objects with the same value
+// Used for face.color -> face.vertexColor[] compatibility layer for non-indexed geometry
+
+THREE.MultiColor = function(links) {
+
+	this.links = links;
+
+}
+
+THREE.MultiColor.prototype = Object.create( THREE.Color.prototype );
+
+THREE.MultiColor.prototype.setAll = function(axis, value) {
+
+	for (var i = 0, l = this.links.length; i < l; i++) {
+
+		this.links[i][axis] = value;
+
+	}
+
+}
+
+// Getters return value from the first linked color
+// Setters set the same value for all linked colors
+Object.defineProperties( THREE.MultiColor.prototype, {
+	'r': {
+		get: function () { return (this.links[0] ? this.links[0].r : 0); },
+		set: function ( v ) { this.setAll('r', v); }
+	},
+	'g': {
+		get: function () { return (this.links[0] ? this.links[0].g : 0); },
+		set: function ( v ) { this.setAll('g', v); }
+	},
+	'b': {
+		get: function () { return (this.links[0] ? this.links[0].b : 0); },
+		set: function ( v ) { this.setAll('b', v); }
+	}
+} );
+
+
+// Allows updating of multiple THREE.Vector3 objects with the same value
+// Used for face.normal -> face.vertexNormal[] compatibility layer for FlatShading
+
+THREE.MultiVector3 = function(links) {
+
+	this.links = links;
+
+}
+
+THREE.MultiVector3.prototype = Object.create( THREE.Vector3.prototype );
+
+THREE.MultiVector3.prototype.setAll = function(axis, value) {
+
+	for (var i = 0, l = this.links.length; i < l; i++) {
+
+		this.links[i][axis] = value;
+
+	}
+
+}
+
+// Getters return value from the first linked vector
+// Setters set the same value for all linked vectors
+Object.defineProperties( THREE.MultiVector3.prototype, {
+	'x': {
+		get: function () { return (this.links[0] ? this.links[0].x : 0); },
+		set: function ( v ) { this.setAll('x', v); }
+	},
+	'y': {
+		get: function () { return (this.links[0] ? this.links[0].y : 0); },
+		set: function ( v ) { this.setAll('y', v); }
+	},
+	'z': {
+		get: function () { return (this.links[0] ? this.links[0].z : 0); },
+		set: function ( v ) { this.setAll('z', v); }
+	}
+} );
+
+
+
+/**
+ * @author mrdoob / http://mrdoob.com/
+ * @author jbaicoianu / http://baicoianu.com/
+ */
+
+THREE.ProxyColor = function ( array, offset ) {
+
+	this.array = array;
+	this.offset = offset;
+
+}
+
+THREE.ProxyColor.prototype = Object.create( THREE.Color.prototype );
+
+Object.defineProperties( THREE.ProxyColor.prototype, {
+	'r': {
+		enumerable: true,	
+		get: function () { return this.array[ this.offset ]; },
+		set: function ( v ) { this.array[ this.offset ] = v; }
+	},
+	'g': {
+		enumerable: true,	
+		get: function () { return this.array[ this.offset + 1 ]; },
+		set: function ( v ) { this.array[ this.offset + 1 ] = v; }
+	},
+	'b': {
+		enumerable: true,	
+		get: function () { return this.array[ this.offset + 2 ]; },
+		set: function ( v ) { this.array[ this.offset + 2 ] = v; }
+	}
+} );
+
+
+/**
+ * @author mrdoob / http://mrdoob.com/
+ * @author jbaicoianu / http://baicoianu.com/
+ */
+
+THREE.ProxyVector2 = function ( array, offset ) {
+	
+	this.array = array;
+	this.offset = offset;
+
+};
+
+THREE.ProxyVector2.prototype = Object.create( THREE.Vector2.prototype );
+
+Object.defineProperties( THREE.ProxyVector2.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; }
+	}
+} );
+
+
+/**
+ * @author mrdoob / http://mrdoob.com/
+ * @author jbaicoianu / http://baicoianu.com/
+ */
+
+THREE.ProxyVector3 = function ( array, offset ) {
+	
+	this.array = array;
+	this.offset = offset;
+
+};
+
+THREE.ProxyVector3.prototype = Object.create( THREE.Vector3.prototype );
+
+Object.defineProperties( THREE.ProxyVector3.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; }
+	}
+} );
+
+
+/**
+ * @author mrdoob / http://mrdoob.com/
+ * @author jbaicoianu / http://baicoianu.com/
+ */
+
+THREE.ProxyVector4 = function ( array, offset ) {
+	
+	this.array = array;
+	this.offset = offset;
 
 };
 
-THREE.IndexedGeometry2.prototype = Object.create( THREE.Geometry99.prototype );
+THREE.ProxyVector4.prototype = Object.create( THREE.Vector4.prototype );
+
+Object.defineProperties( THREE.ProxyVector4.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; }
+	},
+	'w': {
+		get: function () { return this.array[ this.offset + 3 ]; },
+		set: function ( v ) { this.array[ this.offset + 3 ] = v; }
+	}
+} );
+
+
+/**
+ * @author jbaicoianu / http://baicoianu.com/
+ */
+
+THREE.ProxyFace3 = function ( array, offset, vertexNormals, vertexColors, vertexTangents ) {
+
+	this.array = array;
+	this.offset = offset;
+	this.vertexNormals = vertexNormals || [];
+	this.vertexColors = vertexColors || [];
+	this.vertexTangents = vertexTangents || [];
+
+	this.normal = new THREE.MultiVector3( this.vertexNormals );
+	this.color = new THREE.MultiColor( this.vertexColors );
+
+	//THREE.Face3.call( this, array[offset], array[offset+1], array[offset+2] /*, normal, color, materialIndex */);
+
+}
+
+THREE.ProxyFace3.prototype = Object.create( THREE.Face3.prototype );
+
+Object.defineProperties( THREE.ProxyFace3.prototype, {
+	'a': {
+		enumerable: true,	
+		get: function () { return this.array[ this.offset ]; },
+		set: function ( v ) { this.array[ this.offset ] = v; }
+	},
+	'b': {
+		enumerable: true,	
+		get: function () { return this.array[ this.offset + 1 ]; },
+		set: function ( v ) { this.array[ this.offset + 1 ] = v; }
+	},
+	'c': {
+		enumerable: true,	
+		get: function () { return this.array[ this.offset + 2 ]; },
+		set: function ( v ) { this.array[ this.offset + 2 ] = v; }
+	},
+} );
+
 
 /**
  * @author mrdoob / http://mrdoob.com/

File diff suppressed because it is too large
+ 104 - 82
build/three.min.js


Some files were not shown because too many files changed in this diff