|
@@ -10664,35 +10664,44 @@ THREE.Geometry99 = function ( ) {
|
|
|
THREE.Geometry99.prototype = Object.create( THREE.BufferGeometry.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() }
|
|
|
-
|
|
|
+ enumerable: true,
|
|
|
+ get: function () { return this.createFaceProxies() }
|
|
|
},
|
|
|
faceVertexUvs: {
|
|
|
-
|
|
|
- enumerable: true,
|
|
|
- get: function() { return this.createUvProxies() }
|
|
|
-
|
|
|
- }
|
|
|
+ enumerable: true,
|
|
|
+ get: function () { return this.createUvProxies() }
|
|
|
+ },
|
|
|
// TODO - fill in additional proxies:
|
|
|
- // - colors
|
|
|
// - morphColors
|
|
|
// - morphNormals
|
|
|
// - morphTargets
|
|
|
// - skinIndex
|
|
|
// - skinWeights
|
|
|
-} );
|
|
|
|
|
|
-THREE.Geometry99.prototype.createVertexProxies = function() {
|
|
|
+
|
|
|
+ verticesNeedUpdate: {
|
|
|
+ enumerable: true,
|
|
|
+ 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; }
|
|
|
+ },
|
|
|
+ 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; }
|
|
|
+ },
|
|
|
+});
|
|
|
+
|
|
|
+THREE.Geometry99.prototype.createVertexProxies = function () {
|
|
|
|
|
|
// Replace the prototype getter with a local array property
|
|
|
|
|
@@ -10700,13 +10709,13 @@ THREE.Geometry99.prototype.createVertexProxies = function() {
|
|
|
|
|
|
// If the attribute buffer has already been populated, set up proxy objects
|
|
|
|
|
|
- this.populateProxyFromBuffer( this.vertices, "position", THREE.ProxyVector3, 3 );
|
|
|
+ this.populateProxyFromBuffer( this.vertices, "position", THREE.TypedVector3, 3 );
|
|
|
|
|
|
// Return a reference to the newly-created array
|
|
|
|
|
|
return this.vertices;
|
|
|
|
|
|
-};
|
|
|
+}
|
|
|
|
|
|
THREE.Geometry99.prototype.createFaceProxies = function () {
|
|
|
|
|
@@ -10716,47 +10725,101 @@ THREE.Geometry99.prototype.createFaceProxies = function () {
|
|
|
|
|
|
// If the attribute buffer has already been populated, set up proxy objects
|
|
|
|
|
|
+ var faces = this.faces,
|
|
|
+ indexarray = false,
|
|
|
+ positionarray = false,
|
|
|
+ normalarray = false,
|
|
|
+ colorarray = false;
|
|
|
+
|
|
|
+ if ( this.attributes.position ) {
|
|
|
+ positionarray = this.attributes[ 'position' ].array;
|
|
|
+ }
|
|
|
if ( this.attributes.index ) {
|
|
|
+ indexarray = this.attributes[ 'index' ].array;
|
|
|
+ }
|
|
|
+ if (this.attributes[ 'normal' ]) {
|
|
|
+ normalarray = this.attributes[ 'normal' ].array;
|
|
|
+ }
|
|
|
+ if (this.attributes[ 'color' ]) {
|
|
|
+ colorarray = this.attributes[ 'color' ].array;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (indexarray) {
|
|
|
+
|
|
|
+ for ( var i = 0, l = indexarray.length / 3; i < l; i ++ ) {
|
|
|
+
|
|
|
+ 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 indexarray = this.attributes[ 'index' ].array;
|
|
|
- var size = 3;
|
|
|
- var attr = this.faces;
|
|
|
+ }
|
|
|
+
|
|
|
+ // TODO - do BufferGeometries support face normals?
|
|
|
+
|
|
|
+ if (colorarray) {
|
|
|
|
|
|
- var normalarray = false;
|
|
|
+ vertexColors = [
|
|
|
+ new THREE.TypedColor(colorarray, indexarray[o] * 3),
|
|
|
+ new THREE.TypedColor(colorarray, indexarray[o+1] * 3),
|
|
|
+ new THREE.TypedColor(colorarray, indexarray[o+2] * 3),
|
|
|
+ ]
|
|
|
|
|
|
- if (this.attributes[ 'normal' ]) {
|
|
|
+ }
|
|
|
|
|
|
- normalarray = this.attributes[ 'normal' ].array;
|
|
|
+ var face = new THREE.TypedFace3( indexarray, i * 3, vertexNormals );
|
|
|
|
|
|
}
|
|
|
|
|
|
- for ( var i = 0, l = indexarray.length / size; i < l; i ++ ) {
|
|
|
+ } else {
|
|
|
+
|
|
|
+ for ( var i = 0, l = positionarray.length / 3; i < l; i += 3 ) {
|
|
|
|
|
|
- var o = i * size;
|
|
|
+ var o = i * 3;
|
|
|
|
|
|
- // Generate faceVertexNormals
|
|
|
- var vertexNormals;
|
|
|
+ var v1 = i, v2 = i+1, v3 = i+2;
|
|
|
+
|
|
|
+ // Generate face.vertexNormals and face.vertexColors
|
|
|
+
|
|
|
+ // 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
|
|
|
+
|
|
|
+ var vertexNormals = false,
|
|
|
+ vertexColors = false;
|
|
|
if (normalarray) {
|
|
|
|
|
|
vertexNormals = [
|
|
|
- new THREE.ProxyVector3( normalarray, indexarray[ o ] * 3 ),
|
|
|
- new THREE.ProxyVector3( normalarray, indexarray[ o + 1 ] * 3 ),
|
|
|
- new THREE.ProxyVector3( normalarray, indexarray[ o + 2 ] * 3 )
|
|
|
- ]
|
|
|
+ new THREE.TypedVector3(normalarray, o),
|
|
|
+ new THREE.TypedVector3(normalarray, o+3),
|
|
|
+ new THREE.TypedVector3(normalarray, o+6),
|
|
|
+ ];
|
|
|
|
|
|
}
|
|
|
|
|
|
- // TODO - do BufferGeometries support face normals?
|
|
|
+ if (colorarray) {
|
|
|
|
|
|
- var face = new THREE.ProxyFace3( indexarray, i * size, vertexNormals );
|
|
|
+ vertexColors = [
|
|
|
+ new THREE.TypedColor(colorarray, o),
|
|
|
+ new THREE.TypedColor(colorarray, o+3),
|
|
|
+ new THREE.TypedColor(colorarray, o+6),
|
|
|
+ ];
|
|
|
|
|
|
- attr.push( face );
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
+ var face = new THREE.Face3( v1, v2, v3, vertexNormals, vertexColors );
|
|
|
|
|
|
- } else {
|
|
|
+ faces.push(face);
|
|
|
|
|
|
- // TODO - should be able to generate Face data even for non-indexed geometries
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -10764,8 +10827,7 @@ THREE.Geometry99.prototype.createFaceProxies = function () {
|
|
|
|
|
|
return this.faces;
|
|
|
|
|
|
-};
|
|
|
-
|
|
|
+}
|
|
|
THREE.Geometry99.prototype.createUvProxies = function () {
|
|
|
|
|
|
// Replace the prototype getter with a local array property
|
|
@@ -10783,9 +10845,9 @@ THREE.Geometry99.prototype.createUvProxies = function () {
|
|
|
var f = faces[i];
|
|
|
|
|
|
this.faceVertexUvs[0][i] = [];
|
|
|
- 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);
|
|
|
+ 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);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -10795,7 +10857,7 @@ THREE.Geometry99.prototype.createUvProxies = function () {
|
|
|
|
|
|
return this.faceVertexUvs;
|
|
|
|
|
|
-};
|
|
|
+}
|
|
|
|
|
|
THREE.Geometry99.prototype.populateProxyFromBuffer = function ( attr, buffername, proxytype, itemsize, offset, count ) {
|
|
|
|
|
@@ -10804,7 +10866,7 @@ THREE.Geometry99.prototype.populateProxyFromBuffer = function ( attr, buffername
|
|
|
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 ++ ) {
|
|
@@ -10815,38 +10877,20 @@ THREE.Geometry99.prototype.populateProxyFromBuffer = function ( attr, buffername
|
|
|
|
|
|
}
|
|
|
|
|
|
-};
|
|
|
-/**
|
|
|
- * @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.Geometry99.prototype );
|
|
|
+}
|
|
|
|
|
|
-/**
|
|
|
- * @author mrdoob / http://mrdoob.com/
|
|
|
- */
|
|
|
+// Proxies
|
|
|
|
|
|
-THREE.ProxyVector2 = function ( array, offset ) {
|
|
|
+THREE.TypedVector2 = function ( array, offset ) {
|
|
|
|
|
|
this.array = array;
|
|
|
this.offset = offset;
|
|
|
|
|
|
};
|
|
|
|
|
|
-THREE.ProxyVector2.prototype = Object.create( THREE.Vector2.prototype );
|
|
|
+THREE.TypedVector2.prototype = Object.create( THREE.Vector2.prototype );
|
|
|
|
|
|
-Object.defineProperties( THREE.ProxyVector2.prototype, {
|
|
|
+Object.defineProperties( THREE.TypedVector2.prototype, {
|
|
|
'x': {
|
|
|
get: function () { return this.array[ this.offset ]; },
|
|
|
set: function ( v ) { this.array[ this.offset ] = v; }
|
|
@@ -10856,20 +10900,20 @@ Object.defineProperties( THREE.ProxyVector2.prototype, {
|
|
|
set: function ( v ) { this.array[ this.offset + 1 ] = v; }
|
|
|
}
|
|
|
} );
|
|
|
-/**
|
|
|
- * @author mrdoob / http://mrdoob.com/
|
|
|
- */
|
|
|
|
|
|
-THREE.ProxyVector3 = function ( array, offset ) {
|
|
|
+//
|
|
|
+
|
|
|
+
|
|
|
+THREE.TypedVector3 = function ( array, offset ) {
|
|
|
|
|
|
this.array = array;
|
|
|
this.offset = offset;
|
|
|
|
|
|
};
|
|
|
|
|
|
-THREE.ProxyVector3.prototype = Object.create( THREE.Vector3.prototype );
|
|
|
+THREE.TypedVector3.prototype = Object.create( THREE.Vector3.prototype );
|
|
|
|
|
|
-Object.defineProperties( THREE.ProxyVector3.prototype, {
|
|
|
+Object.defineProperties( THREE.TypedVector3.prototype, {
|
|
|
'x': {
|
|
|
get: function () { return this.array[ this.offset ]; },
|
|
|
set: function ( v ) { this.array[ this.offset ] = v; }
|
|
@@ -10883,11 +10927,10 @@ Object.defineProperties( THREE.ProxyVector3.prototype, {
|
|
|
set: function ( v ) { this.array[ this.offset + 2 ] = v; }
|
|
|
}
|
|
|
} );
|
|
|
-/**
|
|
|
- * @author mrdoob / http://mrdoob.com/
|
|
|
- */
|
|
|
|
|
|
-THREE.ProxyFace3 = function ( array, offset, vertexNormals ) {
|
|
|
+//
|
|
|
+
|
|
|
+THREE.TypedFace3 = function ( array, offset, vertexNormals ) {
|
|
|
|
|
|
this.array = array;
|
|
|
this.offset = offset;
|
|
@@ -10897,25 +10940,67 @@ THREE.ProxyFace3 = function ( array, offset, vertexNormals ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
-THREE.ProxyFace3.prototype = Object.create( THREE.Face3.prototype );
|
|
|
+THREE.TypedFace3.prototype = Object.create( THREE.Face3.prototype );
|
|
|
|
|
|
-Object.defineProperties( THREE.ProxyFace3.prototype, {
|
|
|
+Object.defineProperties( THREE.TypedFace3.prototype, {
|
|
|
'a': {
|
|
|
- enumerable: true,
|
|
|
+ enumerable: true,
|
|
|
get: function () { return this.array[ this.offset ]; },
|
|
|
set: function ( v ) { this.array[ this.offset ] = v; }
|
|
|
},
|
|
|
'b': {
|
|
|
- enumerable: true,
|
|
|
+ enumerable: true,
|
|
|
get: function () { return this.array[ this.offset + 1 ]; },
|
|
|
set: function ( v ) { this.array[ this.offset + 1 ] = v; }
|
|
|
},
|
|
|
'c': {
|
|
|
- enumerable: true,
|
|
|
+ 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; }
|
|
|
+ }
|
|
|
+} );
|
|
|
+
|
|
|
+/**
|
|
|
+ * @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.Geometry99.prototype );
|
|
|
+
|
|
|
/**
|
|
|
* @author mrdoob / http://mrdoob.com/
|
|
|
* @author mikael emtinger / http://gomo.se/
|