|
@@ -4133,23 +4133,26 @@ THREE.Matrix3.prototype = {
|
|
|
|
|
|
var v1 = new THREE.Vector3();
|
|
|
|
|
|
- return function ( a ) {
|
|
|
+ return function ( array, offset, length ) {
|
|
|
|
|
|
- for ( var i = 0, il = a.length; i < il; i += 3 ) {
|
|
|
+ if ( offset === undefined ) offset = 0;
|
|
|
+ if ( length === undefined ) length = array.length;
|
|
|
|
|
|
- v1.x = a[ i ];
|
|
|
- v1.y = a[ i + 1 ];
|
|
|
- v1.z = a[ i + 2 ];
|
|
|
+ for ( var i = 0, j = offset, il; i < length; i += 3, j += 3 ) {
|
|
|
+
|
|
|
+ v1.x = array[ j ];
|
|
|
+ v1.y = array[ j + 1 ];
|
|
|
+ v1.z = array[ j + 2 ];
|
|
|
|
|
|
v1.applyMatrix3( this );
|
|
|
|
|
|
- a[ i ] = v1.x;
|
|
|
- a[ i + 1 ] = v1.y;
|
|
|
- a[ i + 2 ] = v1.z;
|
|
|
+ array[ j ] = v1.x;
|
|
|
+ array[ j + 1 ] = v1.y;
|
|
|
+ array[ j + 2 ] = v1.z;
|
|
|
|
|
|
}
|
|
|
|
|
|
- return a;
|
|
|
+ return array;
|
|
|
|
|
|
};
|
|
|
|
|
@@ -4763,23 +4766,26 @@ THREE.Matrix4.prototype = {
|
|
|
|
|
|
var v1 = new THREE.Vector3();
|
|
|
|
|
|
- return function ( a ) {
|
|
|
+ return function ( array, offset, length ) {
|
|
|
+
|
|
|
+ if ( offset === undefined ) offset = 0;
|
|
|
+ if ( length === undefined ) length = array.length;
|
|
|
|
|
|
- for ( var i = 0, il = a.length; i < il; i += 3 ) {
|
|
|
+ for ( var i = 0, j = offset, il; i < length; i += 3, j += 3 ) {
|
|
|
|
|
|
- v1.x = a[ i ];
|
|
|
- v1.y = a[ i + 1 ];
|
|
|
- v1.z = a[ i + 2 ];
|
|
|
+ v1.x = array[ j ];
|
|
|
+ v1.y = array[ j + 1 ];
|
|
|
+ v1.z = array[ j + 2 ];
|
|
|
|
|
|
v1.applyMatrix4( this );
|
|
|
|
|
|
- a[ i ] = v1.x;
|
|
|
- a[ i + 1 ] = v1.y;
|
|
|
- a[ i + 2 ] = v1.z;
|
|
|
+ array[ j ] = v1.x;
|
|
|
+ array[ j + 1 ] = v1.y;
|
|
|
+ array[ j + 2 ] = v1.z;
|
|
|
|
|
|
}
|
|
|
|
|
|
- return a;
|
|
|
+ return array;
|
|
|
|
|
|
};
|
|
|
|
|
@@ -9495,28 +9501,6 @@ THREE.BufferGeometry.prototype = {
|
|
|
|
|
|
},
|
|
|
|
|
|
- normalizeNormals: function () {
|
|
|
-
|
|
|
- var normals = this.attributes[ "normal" ].array;
|
|
|
-
|
|
|
- var x, y, z, n;
|
|
|
-
|
|
|
- for ( var i = 0, il = normals.length; i < il; i += 3 ) {
|
|
|
-
|
|
|
- x = normals[ i ];
|
|
|
- y = normals[ i + 1 ];
|
|
|
- z = normals[ i + 2 ];
|
|
|
-
|
|
|
- n = 1.0 / Math.sqrt( x * x + y * y + z * z );
|
|
|
-
|
|
|
- normals[ i ] *= n;
|
|
|
- normals[ i + 1 ] *= n;
|
|
|
- normals[ i + 2 ] *= n;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
computeTangents: function () {
|
|
|
|
|
|
// based on http://www.terathon.com/code/tangent.html
|
|
@@ -9827,6 +9811,34 @@ THREE.BufferGeometry.prototype = {
|
|
|
return offsets;
|
|
|
},
|
|
|
|
|
|
+ merge: function () {
|
|
|
+
|
|
|
+ console.log( 'BufferGeometry.merge(): TODO' );
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ normalizeNormals: function () {
|
|
|
+
|
|
|
+ var normals = this.attributes[ "normal" ].array;
|
|
|
+
|
|
|
+ var x, y, z, n;
|
|
|
+
|
|
|
+ for ( var i = 0, il = normals.length; i < il; i += 3 ) {
|
|
|
+
|
|
|
+ x = normals[ i ];
|
|
|
+ y = normals[ i + 1 ];
|
|
|
+ z = normals[ i + 2 ];
|
|
|
+
|
|
|
+ n = 1.0 / Math.sqrt( x * x + y * y + z * z );
|
|
|
+
|
|
|
+ normals[ i ] *= n;
|
|
|
+ normals[ i + 1 ] *= n;
|
|
|
+ normals[ i + 2 ] *= n;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
/*
|
|
|
reoderBuffers:
|
|
|
Reorder attributes based on a new indexBuffer and indexMap.
|
|
@@ -9943,34 +9955,150 @@ THREE.EventDispatcher.prototype.apply( THREE.BufferGeometry.prototype );
|
|
|
* @author mrdoob / http://mrdoob.com/
|
|
|
*/
|
|
|
|
|
|
-THREE.Geometry2 = function ( vertices, normals, uvs ) {
|
|
|
+THREE.Geometry2 = function ( size ) {
|
|
|
|
|
|
THREE.BufferGeometry.call( this );
|
|
|
|
|
|
+ if ( size !== undefined ) {
|
|
|
+
|
|
|
+ this.vertices = new Float32Array( size * 3 * 3 );
|
|
|
+ this.normals = new Float32Array( size * 3 * 3 );
|
|
|
+ this.uvs = new Float32Array( size * 3 * 2 );
|
|
|
+
|
|
|
+ this.attributes[ 'position' ] = { array: this.vertices, itemSize: 3 };
|
|
|
+ this.attributes[ 'normal' ] = { array: this.normals, itemSize: 3 };
|
|
|
+ this.attributes[ 'uv' ] = { array: this.uvs, itemSize: 2 };
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+};
|
|
|
+
|
|
|
+THREE.Geometry2.prototype = Object.create( THREE.BufferGeometry.prototype );
|
|
|
+
|
|
|
+THREE.Geometry2.prototype.setArrays = function ( vertices, normals, uvs ) {
|
|
|
+
|
|
|
+ this.vertices = vertices;
|
|
|
+ this.normals = normals;
|
|
|
+ this.uvs = uvs;
|
|
|
+
|
|
|
this.attributes[ 'position' ] = { array: vertices, itemSize: 3 };
|
|
|
this.attributes[ 'normal' ] = { array: normals, itemSize: 3 };
|
|
|
- this.attributes[ 'uv' ] = { array: uvs, itemSize: 2 };
|
|
|
+ this.attributes[ 'uv' ] = { array: uvs, itemSize: 2 };
|
|
|
+
|
|
|
+ return this;
|
|
|
|
|
|
};
|
|
|
|
|
|
-THREE.Geometry2.prototype = Object.create( THREE.BufferGeometry.prototype );
|
|
|
+THREE.Geometry2.prototype.merge = ( function () {
|
|
|
+
|
|
|
+ var offset = 0;
|
|
|
+ var normalMatrix = new THREE.Matrix3();
|
|
|
+
|
|
|
+ return function ( geometry, matrix, startOffset ) {
|
|
|
+
|
|
|
+ if ( startOffset !== undefined ) offset = startOffset;
|
|
|
+
|
|
|
+ var offset2 = offset * 2;
|
|
|
+ var offset3 = offset * 3;
|
|
|
+
|
|
|
+ var vertices = this.attributes[ 'position' ].array;
|
|
|
+ var normals = this.attributes[ 'normal' ].array;
|
|
|
+ var uvs = this.attributes[ 'uv' ].array;
|
|
|
+
|
|
|
+ if ( geometry instanceof THREE.Geometry2 ) {
|
|
|
+
|
|
|
+ var vertices2 = geometry.attributes[ 'position' ].array;
|
|
|
+ var normals2 = geometry.attributes[ 'normal' ].array;
|
|
|
+ var uvs2 = geometry.attributes[ 'uv' ].array;
|
|
|
+
|
|
|
+ for ( var i = 0, l = vertices2.length; i < l; i += 3 ) {
|
|
|
+
|
|
|
+ vertices[ i + offset3 ] = vertices2[ i ];
|
|
|
+ vertices[ i + offset3 + 1 ] = vertices2[ i + 1 ];
|
|
|
+ vertices[ i + offset3 + 2 ] = vertices2[ i + 2 ];
|
|
|
+
|
|
|
+ normals[ i + offset3 ] = normals2[ i ];
|
|
|
+ normals[ i + offset3 + 1 ] = normals2[ i + 1 ];
|
|
|
+ normals[ i + offset3 + 2 ] = normals2[ i + 2 ];
|
|
|
+
|
|
|
+ uvs[ i + offset2 ] = uvs2[ i ];
|
|
|
+ uvs[ i + offset2 + 1 ] = uvs2[ i + 1 ];
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if ( geometry instanceof THREE.IndexedGeometry2 ) {
|
|
|
+
|
|
|
+ var indices2 = geometry.attributes[ 'index' ].array;
|
|
|
+ var vertices2 = geometry.attributes[ 'position' ].array;
|
|
|
+ var normals2 = geometry.attributes[ 'normal' ].array;
|
|
|
+ var uvs2 = geometry.attributes[ 'uv' ].array;
|
|
|
+
|
|
|
+ for ( var i = 0, l = indices2.length; i < l; i ++ ) {
|
|
|
+
|
|
|
+ var index = indices2[ i ];
|
|
|
+
|
|
|
+ var index3 = index * 3;
|
|
|
+ var i3 = i * 3;
|
|
|
+
|
|
|
+ vertices[ i3 + offset3 ] = vertices2[ index3 ];
|
|
|
+ vertices[ i3 + offset3 + 1 ] = vertices2[ index3 + 1 ];
|
|
|
+ vertices[ i3 + offset3 + 2 ] = vertices2[ index3 + 2 ];
|
|
|
+
|
|
|
+ normals[ i3 + offset3 ] = normals2[ index3 ];
|
|
|
+ normals[ i3 + offset3 + 1 ] = normals2[ index3 + 1 ];
|
|
|
+ normals[ i3 + offset3 + 2 ] = normals2[ index3 + 2 ];
|
|
|
+
|
|
|
+ var index2 = index * 2;
|
|
|
+ var i2 = i * 2;
|
|
|
+
|
|
|
+ uvs[ i2 + offset2 ] = uvs2[ index2 ];
|
|
|
+ uvs[ i2 + offset2 + 1 ] = uvs2[ index2 + 1 ];
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( matrix !== undefined ) {
|
|
|
+
|
|
|
+ matrix.applyToVector3Array( vertices, offset3, indices2.length * 3 );
|
|
|
+
|
|
|
+ normalMatrix.getNormalMatrix( matrix );
|
|
|
+ normalMatrix.applyToVector3Array( normals, offset3, indices2.length * 3 );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ offset += indices2.length;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
+} )();
|
|
|
/**
|
|
|
* @author mrdoob / http://mrdoob.com/
|
|
|
*/
|
|
|
|
|
|
-THREE.IndexedGeometry2 = function ( indices, vertices, normals, uvs ) {
|
|
|
+THREE.IndexedGeometry2 = function () {
|
|
|
|
|
|
THREE.BufferGeometry.call( this );
|
|
|
|
|
|
+};
|
|
|
+
|
|
|
+THREE.IndexedGeometry2.prototype = Object.create( THREE.BufferGeometry.prototype );
|
|
|
+
|
|
|
+THREE.IndexedGeometry2.prototype.setArrays = function ( indices, vertices, normals, uvs ) {
|
|
|
+
|
|
|
+ this.indices = indices;
|
|
|
+ this.vertices = vertices;
|
|
|
+ this.normals = normals;
|
|
|
+ this.uvs = uvs;
|
|
|
+
|
|
|
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 );
|
|
|
+ return this;
|
|
|
|
|
|
+};
|
|
|
/**
|
|
|
* @author mrdoob / http://mrdoob.com/
|
|
|
* @author kile / http://kile.stravaganza.org/
|
|
@@ -10223,8 +10351,6 @@ THREE.Geometry.prototype = {
|
|
|
|
|
|
for ( f = 0, fl = this.faces.length; f < fl; f ++ ) {
|
|
|
|
|
|
- face = this.faces[ f ];
|
|
|
-
|
|
|
faceNormal = new THREE.Vector3();
|
|
|
vertexNormals = { a: new THREE.Vector3(), b: new THREE.Vector3(), c: new THREE.Vector3() };
|
|
|
|
|
@@ -28539,6 +28665,9 @@ THREE.WebGLShader = ( function () {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ // --enable-privileged-webgl-extension
|
|
|
+ // console.log( type, gl.getExtension( 'WEBGL_debug_shaders' ).getTranslatedShaderSource( shader ) );
|
|
|
+
|
|
|
return shader;
|
|
|
|
|
|
};
|
|
@@ -33866,7 +33995,9 @@ THREE.CircleGeometry = function ( radius, segments, thetaStart, thetaLength ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- THREE.IndexedGeometry2.call( this, indices, vertices, normals, uvs );
|
|
|
+ THREE.IndexedGeometry2.call( this );
|
|
|
+
|
|
|
+ this.setArrays( indices, vertices, normals, uvs );
|
|
|
|
|
|
this.boundingSphere = new THREE.Sphere( new THREE.Vector3(), radius );
|
|
|
|
|
@@ -35068,7 +35199,10 @@ THREE.PlaneGeometry = function ( width, height, widthSegments, heightSegments )
|
|
|
|
|
|
}
|
|
|
|
|
|
- THREE.IndexedGeometry2.call( this, indices, vertices, normals, uvs );
|
|
|
+ THREE.IndexedGeometry2.call( this );
|
|
|
+
|
|
|
+ this.setArrays( indices, vertices, normals, uvs );
|
|
|
+ this.computeBoundingSphere();
|
|
|
|
|
|
};
|
|
|
|
|
@@ -38458,6 +38592,8 @@ THREE.ShadowMapPlugin = function () {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ _renderer.setMaterialFaces( objectMaterial );
|
|
|
+
|
|
|
if ( buffer instanceof THREE.BufferGeometry ) {
|
|
|
|
|
|
_renderer.renderBufferDirect( shadowCamera, scene.__lights, fog, material, buffer, object );
|