|
@@ -10858,13 +10858,13 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, {
|
|
|
|
|
|
if ( this.matrixWorldNeedsUpdate || force ) {
|
|
|
|
|
|
- if ( this.parent ) {
|
|
|
+ if ( this.parent === null ) {
|
|
|
|
|
|
- this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );
|
|
|
+ this.matrixWorld.copy( this.matrix );
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- this.matrixWorld.copy( this.matrix );
|
|
|
+ this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -15874,13 +15874,12 @@ function WebGLAttributes( gl ) {
|
|
|
|
|
|
function createBuffer( attribute, bufferType ) {
|
|
|
|
|
|
- var buffer = gl.createBuffer();
|
|
|
-
|
|
|
- gl.bindBuffer( bufferType, buffer );
|
|
|
-
|
|
|
var array = attribute.array;
|
|
|
var usage = attribute.dynamic ? gl.DYNAMIC_DRAW : gl.STATIC_DRAW;
|
|
|
|
|
|
+ var buffer = gl.createBuffer();
|
|
|
+
|
|
|
+ gl.bindBuffer( bufferType, buffer );
|
|
|
gl.bufferData( bufferType, array, usage );
|
|
|
|
|
|
attribute.onUploadCallback();
|
|
@@ -15932,33 +15931,34 @@ function WebGLAttributes( gl ) {
|
|
|
|
|
|
function updateBuffer( buffer, attribute, bufferType ) {
|
|
|
|
|
|
+ var array = attribute.array;
|
|
|
+ var updateRange = attribute.updateRange;
|
|
|
+
|
|
|
gl.bindBuffer( bufferType, buffer );
|
|
|
|
|
|
if ( attribute.dynamic === false ) {
|
|
|
|
|
|
- gl.bufferData( bufferType, attribute.array, gl.STATIC_DRAW );
|
|
|
+ gl.bufferData( bufferType, array, gl.STATIC_DRAW );
|
|
|
|
|
|
- } else if ( attribute.updateRange.count === - 1 ) {
|
|
|
+ } else if ( updateRange.count === - 1 ) {
|
|
|
|
|
|
// Not using update ranges
|
|
|
|
|
|
- gl.bufferSubData( bufferType, 0, attribute.array );
|
|
|
+ gl.bufferSubData( bufferType, 0, array );
|
|
|
|
|
|
- } else if ( attribute.updateRange.count === 0 ) {
|
|
|
+ } else if ( updateRange.count === 0 ) {
|
|
|
|
|
|
console.error( 'THREE.WebGLObjects.updateBuffer: dynamic THREE.BufferAttribute marked as needsUpdate but updateRange.count is 0, ensure you are using set methods or updating manually.' );
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- gl.bufferSubData( bufferType, attribute.updateRange.offset * attribute.array.BYTES_PER_ELEMENT,
|
|
|
- attribute.array.subarray( attribute.updateRange.offset, attribute.updateRange.offset + attribute.updateRange.count ) );
|
|
|
+ gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT,
|
|
|
+ array.subarray( updateRange.offset, updateRange.offset + updateRange.count ) );
|
|
|
|
|
|
- attribute.updateRange.count = 0; // reset range
|
|
|
+ updateRange.count = 0; // reset range
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
//
|
|
@@ -15995,9 +15995,10 @@ function WebGLAttributes( gl ) {
|
|
|
|
|
|
buffers[ attribute.id ] = createBuffer( attribute, bufferType );
|
|
|
|
|
|
- } else if ( data.version !== attribute.version ) {
|
|
|
+ } else if ( data.version < attribute.version ) {
|
|
|
|
|
|
updateBuffer( data.buffer, attribute, bufferType );
|
|
|
+
|
|
|
data.version = attribute.version;
|
|
|
|
|
|
}
|
|
@@ -16166,7 +16167,7 @@ function WebGLBufferRenderer( gl, extensions, infoRender ) {
|
|
|
* @author mrdoob / http://mrdoob.com/
|
|
|
*/
|
|
|
|
|
|
-function WebGLGeometries( gl, attributes, info ) {
|
|
|
+function WebGLGeometries( gl, attributes, infoMemory ) {
|
|
|
|
|
|
var geometries = {};
|
|
|
var wireframeAttributes = {};
|
|
@@ -16214,13 +16215,12 @@ function WebGLGeometries( gl, attributes, info ) {
|
|
|
|
|
|
//
|
|
|
|
|
|
- info.memory.geometries --;
|
|
|
+ infoMemory.geometries --;
|
|
|
|
|
|
}
|
|
|
|
|
|
- function get( object ) {
|
|
|
+ function get( object, geometry ) {
|
|
|
|
|
|
- var geometry = object.geometry;
|
|
|
var buffergeometry = geometries[ geometry.id ];
|
|
|
|
|
|
if ( buffergeometry ) return buffergeometry;
|
|
@@ -16245,12 +16245,47 @@ function WebGLGeometries( gl, attributes, info ) {
|
|
|
|
|
|
geometries[ geometry.id ] = buffergeometry;
|
|
|
|
|
|
- info.memory.geometries ++;
|
|
|
+ infoMemory.geometries ++;
|
|
|
|
|
|
return buffergeometry;
|
|
|
|
|
|
}
|
|
|
|
|
|
+ function update( geometry ) {
|
|
|
+
|
|
|
+ var index = geometry.index;
|
|
|
+ var geometryAttributes = geometry.attributes;
|
|
|
+
|
|
|
+ if ( index !== null ) {
|
|
|
+
|
|
|
+ attributes.update( index, gl.ELEMENT_ARRAY_BUFFER );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ for ( var name in geometryAttributes ) {
|
|
|
+
|
|
|
+ attributes.update( geometryAttributes[ name ], gl.ARRAY_BUFFER );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // morph targets
|
|
|
+
|
|
|
+ var morphAttributes = geometry.morphAttributes;
|
|
|
+
|
|
|
+ for ( var name in morphAttributes ) {
|
|
|
+
|
|
|
+ var array = morphAttributes[ name ];
|
|
|
+
|
|
|
+ for ( var i = 0, l = array.length; i < l; i ++ ) {
|
|
|
+
|
|
|
+ attributes.update( array[ i ], gl.ARRAY_BUFFER );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
function getWireframeAttribute( geometry ) {
|
|
|
|
|
|
var attribute = wireframeAttributes[ geometry.id ];
|
|
@@ -16306,46 +16341,12 @@ function WebGLGeometries( gl, attributes, info ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- function update( geometry ) {
|
|
|
-
|
|
|
- var index = geometry.index;
|
|
|
- var geometryAttributes = geometry.attributes;
|
|
|
-
|
|
|
- if ( index !== null ) {
|
|
|
-
|
|
|
- attributes.update( index, gl.ELEMENT_ARRAY_BUFFER );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- for ( var name in geometryAttributes ) {
|
|
|
-
|
|
|
- attributes.update( geometryAttributes[ name ], gl.ARRAY_BUFFER );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- // morph targets
|
|
|
-
|
|
|
- var morphAttributes = geometry.morphAttributes;
|
|
|
-
|
|
|
- for ( var name in morphAttributes ) {
|
|
|
-
|
|
|
- var array = morphAttributes[ name ];
|
|
|
-
|
|
|
- for ( var i = 0, l = array.length; i < l; i ++ ) {
|
|
|
-
|
|
|
- attributes.update( array[ i ], gl.ARRAY_BUFFER );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
return {
|
|
|
|
|
|
get: get,
|
|
|
- getWireframeAttribute: getWireframeAttribute,
|
|
|
- update: update
|
|
|
+ update: update,
|
|
|
+
|
|
|
+ getWireframeAttribute: getWireframeAttribute
|
|
|
|
|
|
};
|
|
|
|
|
@@ -16450,23 +16451,32 @@ function WebGLLights() {
|
|
|
* @author mrdoob / http://mrdoob.com/
|
|
|
*/
|
|
|
|
|
|
-function WebGLObjects( gl, geometries ) {
|
|
|
+function WebGLObjects( gl, geometries, infoRender ) {
|
|
|
|
|
|
function update( object ) {
|
|
|
|
|
|
- // TODO: Avoid updating twice (when using shadowMap). Maybe add frame counter.
|
|
|
+ var frame = infoRender.frame;
|
|
|
|
|
|
- var geometry = geometries.get( object );
|
|
|
+ var geometry = object.geometry;
|
|
|
+ var buffergeometry = geometries.get( object, geometry );
|
|
|
|
|
|
- if ( object.geometry.isGeometry ) {
|
|
|
+ // Update once per frame
|
|
|
|
|
|
- geometry.updateFromObject( object );
|
|
|
+ if ( buffergeometry.__frame !== frame ) {
|
|
|
|
|
|
- }
|
|
|
+ if ( geometry.isGeometry ) {
|
|
|
|
|
|
- geometries.update( geometry );
|
|
|
+ buffergeometry.updateFromObject( object );
|
|
|
|
|
|
- return geometry;
|
|
|
+ }
|
|
|
+
|
|
|
+ geometries.update( buffergeometry );
|
|
|
+
|
|
|
+ buffergeometry.__frame = frame;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return buffergeometry;
|
|
|
|
|
|
}
|
|
|
|
|
@@ -17509,9 +17519,8 @@ function WebGLPrograms( renderer, capabilities ) {
|
|
|
* @author mrdoob / http://mrdoob.com/
|
|
|
*/
|
|
|
|
|
|
-function WebGLTextures( _gl, extensions, state, properties, capabilities, paramThreeToGL, info ) {
|
|
|
+function WebGLTextures( _gl, extensions, state, properties, capabilities, paramThreeToGL, infoMemory ) {
|
|
|
|
|
|
- var _infoMemory = info.memory;
|
|
|
var _isWebGL2 = ( typeof WebGL2RenderingContext !== 'undefined' && _gl instanceof WebGL2RenderingContext );
|
|
|
|
|
|
//
|
|
@@ -17600,7 +17609,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, paramT
|
|
|
|
|
|
deallocateTexture( texture );
|
|
|
|
|
|
- _infoMemory.textures --;
|
|
|
+ infoMemory.textures --;
|
|
|
|
|
|
|
|
|
}
|
|
@@ -17613,7 +17622,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, paramT
|
|
|
|
|
|
deallocateRenderTarget( renderTarget );
|
|
|
|
|
|
- _infoMemory.textures --;
|
|
|
+ infoMemory.textures --;
|
|
|
|
|
|
}
|
|
|
|
|
@@ -17732,7 +17741,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, paramT
|
|
|
|
|
|
textureProperties.__image__webglTextureCube = _gl.createTexture();
|
|
|
|
|
|
- _infoMemory.textures ++;
|
|
|
+ infoMemory.textures ++;
|
|
|
|
|
|
}
|
|
|
|
|
@@ -17903,7 +17912,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, paramT
|
|
|
|
|
|
textureProperties.__webglTexture = _gl.createTexture();
|
|
|
|
|
|
- _infoMemory.textures ++;
|
|
|
+ infoMemory.textures ++;
|
|
|
|
|
|
}
|
|
|
|
|
@@ -18204,7 +18213,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, paramT
|
|
|
|
|
|
textureProperties.__webglTexture = _gl.createTexture();
|
|
|
|
|
|
- _infoMemory.textures ++;
|
|
|
+ infoMemory.textures ++;
|
|
|
|
|
|
var isCube = ( renderTarget.isWebGLRenderTargetCube === true );
|
|
|
var isTargetPowerOfTwo = isPowerOfTwo( renderTarget );
|
|
@@ -19793,8 +19802,14 @@ function WebGLRenderer( parameters ) {
|
|
|
|
|
|
// info
|
|
|
|
|
|
+ _infoMemory = {
|
|
|
+ geometries: 0,
|
|
|
+ textures: 0
|
|
|
+ },
|
|
|
+
|
|
|
_infoRender = {
|
|
|
|
|
|
+ frame: 0,
|
|
|
calls: 0,
|
|
|
vertices: 0,
|
|
|
faces: 0,
|
|
@@ -19805,12 +19820,7 @@ function WebGLRenderer( parameters ) {
|
|
|
this.info = {
|
|
|
|
|
|
render: _infoRender,
|
|
|
- memory: {
|
|
|
-
|
|
|
- geometries: 0,
|
|
|
- textures: 0
|
|
|
-
|
|
|
- },
|
|
|
+ memory: _infoMemory,
|
|
|
programs: null
|
|
|
|
|
|
};
|
|
@@ -19888,10 +19898,10 @@ function WebGLRenderer( parameters ) {
|
|
|
var state = new WebGLState( _gl, extensions, paramThreeToGL );
|
|
|
|
|
|
var properties = new WebGLProperties();
|
|
|
- var textures = new WebGLTextures( _gl, extensions, state, properties, capabilities, paramThreeToGL, this.info );
|
|
|
+ var textures = new WebGLTextures( _gl, extensions, state, properties, capabilities, paramThreeToGL, _infoMemory );
|
|
|
var attributes = new WebGLAttributes( _gl );
|
|
|
- var geometries = new WebGLGeometries( _gl, attributes, this.info );
|
|
|
- var objects = new WebGLObjects( _gl, geometries );
|
|
|
+ var geometries = new WebGLGeometries( _gl, attributes, _infoMemory );
|
|
|
+ var objects = new WebGLObjects( _gl, geometries, _infoRender );
|
|
|
var programCache = new WebGLPrograms( this, capabilities );
|
|
|
var lightCache = new WebGLLights();
|
|
|
|
|
@@ -20751,6 +20761,7 @@ function WebGLRenderer( parameters ) {
|
|
|
|
|
|
//
|
|
|
|
|
|
+ _infoRender.frame ++;
|
|
|
_infoRender.calls = 0;
|
|
|
_infoRender.vertices = 0;
|
|
|
_infoRender.faces = 0;
|
|
@@ -21017,7 +21028,8 @@ function WebGLRenderer( parameters ) {
|
|
|
|
|
|
if ( sortObjects ) {
|
|
|
|
|
|
- _vector3.setFromMatrixPosition( object.matrixWorld ).applyMatrix4( _projScreenMatrix );
|
|
|
+ _vector3.setFromMatrixPosition( object.matrixWorld )
|
|
|
+ .applyMatrix4( _projScreenMatrix );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -21035,7 +21047,8 @@ function WebGLRenderer( parameters ) {
|
|
|
|
|
|
if ( sortObjects ) {
|
|
|
|
|
|
- _vector3.setFromMatrixPosition( object.matrixWorld ).applyMatrix4( _projScreenMatrix );
|
|
|
+ _vector3.setFromMatrixPosition( object.matrixWorld )
|
|
|
+ .applyMatrix4( _projScreenMatrix );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -29973,6 +29986,64 @@ AmbientLight.prototype = Object.assign( Object.create( Light.prototype ), {
|
|
|
|
|
|
} );
|
|
|
|
|
|
+/**
|
|
|
+ * @author abelnation / http://github.com/abelnation
|
|
|
+ */
|
|
|
+
|
|
|
+function RectAreaLight ( color, intensity, width, height ) {
|
|
|
+
|
|
|
+ Light.call( this, color, intensity );
|
|
|
+
|
|
|
+ this.type = 'RectAreaLight';
|
|
|
+
|
|
|
+ this.position.set( 0, 1, 0 );
|
|
|
+ this.updateMatrix();
|
|
|
+
|
|
|
+ this.width = ( width !== undefined ) ? width : 10;
|
|
|
+ this.height = ( height !== undefined ) ? height : 10;
|
|
|
+
|
|
|
+ // TODO (abelnation): distance/decay
|
|
|
+
|
|
|
+ // TODO (abelnation): update method for RectAreaLight to update transform to lookat target
|
|
|
+
|
|
|
+ // TODO (abelnation): shadows
|
|
|
+ // this.shadow = new THREE.RectAreaLightShadow( new THREE.PerspectiveCamera( 90, 1, 0.5, 500 ) );
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+// TODO (abelnation): RectAreaLight update when light shape is changed
|
|
|
+RectAreaLight.prototype = Object.assign( Object.create( Light.prototype ), {
|
|
|
+
|
|
|
+ constructor: RectAreaLight,
|
|
|
+
|
|
|
+ isRectAreaLight: true,
|
|
|
+
|
|
|
+ copy: function ( source ) {
|
|
|
+
|
|
|
+ Light.prototype.copy.call( this, source );
|
|
|
+
|
|
|
+ this.width = source.width;
|
|
|
+ this.height = source.height;
|
|
|
+
|
|
|
+ // this.shadow = source.shadow.clone();
|
|
|
+
|
|
|
+ return this;
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ toJSON: function ( meta ) {
|
|
|
+
|
|
|
+ var data = Light.prototype.toJSON.call( this, meta );
|
|
|
+
|
|
|
+ data.object.width = this.width;
|
|
|
+ data.object.height = this.height;
|
|
|
+
|
|
|
+ return data;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+} );
|
|
|
+
|
|
|
/**
|
|
|
* @author tschw
|
|
|
* @author Ben Houston / http://clara.io/
|
|
@@ -33415,6 +33486,12 @@ Object.assign( ObjectLoader.prototype, {
|
|
|
|
|
|
break;
|
|
|
|
|
|
+ case 'RectAreaLight':
|
|
|
+
|
|
|
+ object = new RectAreaLight( data.color, data.intensity, data.width, data.height );
|
|
|
+
|
|
|
+ break;
|
|
|
+
|
|
|
case 'SpotLight':
|
|
|
|
|
|
object = new SpotLight( data.color, data.intensity, data.distance, data.angle, data.penumbra, data.decay );
|
|
@@ -35218,53 +35295,6 @@ Object.assign( AudioLoader.prototype, {
|
|
|
|
|
|
} );
|
|
|
|
|
|
-/**
|
|
|
- * @author abelnation / http://github.com/abelnation
|
|
|
- */
|
|
|
-
|
|
|
-function RectAreaLight ( color, intensity, width, height ) {
|
|
|
-
|
|
|
- Light.call( this, color, intensity );
|
|
|
-
|
|
|
- this.type = 'RectAreaLight';
|
|
|
-
|
|
|
- this.position.set( 0, 1, 0 );
|
|
|
- this.updateMatrix();
|
|
|
-
|
|
|
- this.width = ( width !== undefined ) ? width : 10;
|
|
|
- this.height = ( height !== undefined ) ? height : 10;
|
|
|
-
|
|
|
- // TODO (abelnation): distance/decay
|
|
|
-
|
|
|
- // TODO (abelnation): update method for RectAreaLight to update transform to lookat target
|
|
|
-
|
|
|
- // TODO (abelnation): shadows
|
|
|
- // this.shadow = new THREE.RectAreaLightShadow( new THREE.PerspectiveCamera( 90, 1, 0.5, 500 ) );
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-// TODO (abelnation): RectAreaLight update when light shape is changed
|
|
|
-RectAreaLight.prototype = Object.assign( Object.create( Light.prototype ), {
|
|
|
-
|
|
|
- constructor: RectAreaLight,
|
|
|
-
|
|
|
- isRectAreaLight: true,
|
|
|
-
|
|
|
- copy: function ( source ) {
|
|
|
-
|
|
|
- Light.prototype.copy.call( this, source );
|
|
|
-
|
|
|
- this.width = source.width;
|
|
|
- this.height = source.height;
|
|
|
-
|
|
|
- // this.shadow = source.shadow.clone();
|
|
|
-
|
|
|
- return this;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-} );
|
|
|
-
|
|
|
/**
|
|
|
* @author mrdoob / http://mrdoob.com/
|
|
|
*/
|