Selaa lähdekoodia

Fixed Geometry99 merge conflicts.

Mr.doob 11 vuotta sitten
vanhempi
commit
53161648e6
3 muutettua tiedostoa jossa 77 lisäystä ja 27 poistoa
  1. 3 3
      examples/js/wip/PlaneGeometry6.js
  2. 74 21
      src/core/Geometry99.js
  3. 0 3
      utils/build/includes/common.json

+ 3 - 3
examples/js/wip/PlaneGeometry6.js

@@ -18,9 +18,9 @@ THREE.PlaneGeometry6 = function ( width, height, widthSegments, heightSegments )
 
 	for ( var i = 0, l = vertices.length / 3; i < l; i ++ ) {
 
-		this.vertices.push( new THREE.ProxyVector3( vertices, i * 3 ) );
-		this.normals.push( new THREE.ProxyVector3( normals, i * 3 ) );
-		this.uvs.push( new THREE.ProxyVector2( uvs, i * 2 ) );
+		this.vertices.push( new THREE.TypedVector3( vertices, i * 3 ) );
+		this.normals.push( new THREE.TypedVector3( normals, i * 3 ) );
+		this.uvs.push( new THREE.TypedVector2( uvs, i * 2 ) );
 
 	}
 

+ 74 - 21
src/core/Geometry99.js

@@ -7,18 +7,18 @@ THREE.Geometry99 = function ( ) {
 
 THREE.Geometry99.prototype = Object.create( THREE.BufferGeometry.prototype );
 
-Object.defineProperties(THREE.Geometry99.prototype, {
+Object.defineProperties( THREE.Geometry99.prototype, {
 	vertices: { 
 		enumerable: true, 
-		get: function() { return this.createVertexProxies(); } 
+		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() } 
 	},
 	// TODO - fill in additional proxies:
 	// - morphColors
@@ -30,22 +30,22 @@ Object.defineProperties(THREE.Geometry99.prototype, {
 
 	verticesNeedUpdate: {
 		enumerable: true,	
-		get: function() { return this.attributes[ 'position' ].needsUpdate; } ,
-		set: function(v) { this.attributes[ 'position' ].needsUpdate = v; } 
+		get: function () { return this.attributes[ 'position' ].needsUpdate; } ,
+		set: function ( v ) { 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.Geometry99.prototype.createVertexProxies = function () {
 
 	// Replace the prototype getter with a local array property
 
@@ -53,7 +53,7 @@ THREE.Geometry99.prototype.createVertexProxies = function() {
 
 	// 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.TypedVector3, 3 );
 
 	// Return a reference to the newly-created array
 
@@ -61,7 +61,7 @@ THREE.Geometry99.prototype.createVertexProxies = function() {
 
 }
 
-THREE.Geometry99.prototype.createFaceProxies = function() {
+THREE.Geometry99.prototype.createFaceProxies = function () {
 
 	// Replace the prototype getter with a local array property
 
@@ -172,7 +172,7 @@ THREE.Geometry99.prototype.createFaceProxies = function() {
 	return this.faces;
 
 }
-THREE.Geometry99.prototype.createUvProxies = function() {
+THREE.Geometry99.prototype.createUvProxies = function () {
 
 	// Replace the prototype getter with a local array property
 
@@ -185,13 +185,14 @@ THREE.Geometry99.prototype.createUvProxies = function() {
 		var faces = this.faces;
 		var uvarray = this.attributes.uv.array;
 
-		for (var i = 0, l = faces.length; i < l; i++) {
+		for ( var i = 0, l = faces.length; i < l; i ++ ) {
+
 			var f = 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);
+			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 );
 
 		}
 	
@@ -203,14 +204,15 @@ THREE.Geometry99.prototype.createUvProxies = function() {
 
 }
 
-THREE.Geometry99.prototype.populateProxyFromBuffer = function(attr, buffername, proxytype, itemsize, offset, count) {
+THREE.Geometry99.prototype.populateProxyFromBuffer = function ( attr, buffername, proxytype, itemsize, offset, count ) {
 
 	if ( this.attributes[ buffername ] ) {
 
 		var array = this.attributes[ buffername ].array;
 		var size = itemsize || this.attributes[ buffername ].itemSize;
 		var start = offset || 0;
-		var count = count || (array.length / size - start);
+		
+		count = count || ( array.length / size - start );
 
 		for ( var i = start, l = start + count; i < l; i ++ ) {
 
@@ -222,6 +224,57 @@ THREE.Geometry99.prototype.populateProxyFromBuffer = function(attr, buffername,
 
 }
 
+// Proxies
+
+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; }
+	}
+} );
+
+//
+
+
+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; }
+	}
+} );
+
+//
+
 THREE.TypedFace3 = function ( array, offset, vertexNormals ) {
 
 	this.array = array;

+ 0 - 3
utils/build/includes/common.json

@@ -34,9 +34,6 @@
 	"src/core/Geometry2.js",
 	"src/core/Geometry99.js",
 	"src/core/IndexedGeometry2.js",
-	"src/core/ProxyVector2.js",
-	"src/core/ProxyVector3.js",
-	"src/core/ProxyFace3.js",
 	"src/cameras/Camera.js",
 	"src/cameras/OrthographicCamera.js",
 	"src/cameras/PerspectiveCamera.js",