|
@@ -1,5 +1,5 @@
|
|
|
// threejs.org/license
|
|
|
-const REVISION = '121';
|
|
|
+const REVISION = '122';
|
|
|
const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
|
|
|
const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
|
|
|
const CullFaceNone = 0;
|
|
@@ -917,9 +917,7 @@ class Vector2 {
|
|
|
|
|
|
}
|
|
|
|
|
|
- fromArray( array, offset ) {
|
|
|
-
|
|
|
- if ( offset === undefined ) offset = 0;
|
|
|
+ fromArray( array, offset = 0 ) {
|
|
|
|
|
|
this.x = array[ offset ];
|
|
|
this.y = array[ offset + 1 ];
|
|
@@ -928,10 +926,7 @@ class Vector2 {
|
|
|
|
|
|
}
|
|
|
|
|
|
- toArray( array, offset ) {
|
|
|
-
|
|
|
- if ( array === undefined ) array = [];
|
|
|
- if ( offset === undefined ) offset = 0;
|
|
|
+ toArray( array = [], offset = 0 ) {
|
|
|
|
|
|
array[ offset ] = this.x;
|
|
|
array[ offset + 1 ] = this.y;
|
|
@@ -1289,9 +1284,7 @@ class Matrix3 {
|
|
|
|
|
|
}
|
|
|
|
|
|
- fromArray( array, offset ) {
|
|
|
-
|
|
|
- if ( offset === undefined ) offset = 0;
|
|
|
+ fromArray( array, offset = 0 ) {
|
|
|
|
|
|
for ( let i = 0; i < 9; i ++ ) {
|
|
|
|
|
@@ -1303,10 +1296,7 @@ class Matrix3 {
|
|
|
|
|
|
}
|
|
|
|
|
|
- toArray( array, offset ) {
|
|
|
-
|
|
|
- if ( array === undefined ) array = [];
|
|
|
- if ( offset === undefined ) offset = 0;
|
|
|
+ toArray( array = [], offset = 0 ) {
|
|
|
|
|
|
const te = this.elements;
|
|
|
|
|
@@ -2291,9 +2281,7 @@ class Vector4 {
|
|
|
|
|
|
}
|
|
|
|
|
|
- fromArray( array, offset ) {
|
|
|
-
|
|
|
- if ( offset === undefined ) offset = 0;
|
|
|
+ fromArray( array, offset = 0 ) {
|
|
|
|
|
|
this.x = array[ offset ];
|
|
|
this.y = array[ offset + 1 ];
|
|
@@ -2304,10 +2292,7 @@ class Vector4 {
|
|
|
|
|
|
}
|
|
|
|
|
|
- toArray( array, offset ) {
|
|
|
-
|
|
|
- if ( array === undefined ) array = [];
|
|
|
- if ( offset === undefined ) offset = 0;
|
|
|
+ toArray( array = [], offset = 0 ) {
|
|
|
|
|
|
array[ offset ] = this.x;
|
|
|
array[ offset + 1 ] = this.y;
|
|
@@ -3051,9 +3036,7 @@ class Quaternion {
|
|
|
|
|
|
}
|
|
|
|
|
|
- fromArray( array, offset ) {
|
|
|
-
|
|
|
- if ( offset === undefined ) offset = 0;
|
|
|
+ fromArray( array, offset = 0 ) {
|
|
|
|
|
|
this._x = array[ offset ];
|
|
|
this._y = array[ offset + 1 ];
|
|
@@ -3066,10 +3049,7 @@ class Quaternion {
|
|
|
|
|
|
}
|
|
|
|
|
|
- toArray( array, offset ) {
|
|
|
-
|
|
|
- if ( array === undefined ) array = [];
|
|
|
- if ( offset === undefined ) offset = 0;
|
|
|
+ toArray( array = [], offset = 0 ) {
|
|
|
|
|
|
array[ offset ] = this._x;
|
|
|
array[ offset + 1 ] = this._y;
|
|
@@ -3769,9 +3749,7 @@ class Vector3 {
|
|
|
|
|
|
}
|
|
|
|
|
|
- fromArray( array, offset ) {
|
|
|
-
|
|
|
- if ( offset === undefined ) offset = 0;
|
|
|
+ fromArray( array, offset = 0 ) {
|
|
|
|
|
|
this.x = array[ offset ];
|
|
|
this.y = array[ offset + 1 ];
|
|
@@ -3781,10 +3759,7 @@ class Vector3 {
|
|
|
|
|
|
}
|
|
|
|
|
|
- toArray( array, offset ) {
|
|
|
-
|
|
|
- if ( array === undefined ) array = [];
|
|
|
- if ( offset === undefined ) offset = 0;
|
|
|
+ toArray( array = [], offset = 0 ) {
|
|
|
|
|
|
array[ offset ] = this.x;
|
|
|
array[ offset + 1 ] = this.y;
|
|
@@ -5887,9 +5862,7 @@ class Matrix4 {
|
|
|
|
|
|
}
|
|
|
|
|
|
- fromArray( array, offset ) {
|
|
|
-
|
|
|
- if ( offset === undefined ) offset = 0;
|
|
|
+ fromArray( array, offset = 0 ) {
|
|
|
|
|
|
for ( let i = 0; i < 16; i ++ ) {
|
|
|
|
|
@@ -5901,10 +5874,7 @@ class Matrix4 {
|
|
|
|
|
|
}
|
|
|
|
|
|
- toArray( array, offset ) {
|
|
|
-
|
|
|
- if ( array === undefined ) array = [];
|
|
|
- if ( offset === undefined ) offset = 0;
|
|
|
+ toArray( array = [], offset = 0 ) {
|
|
|
|
|
|
const te = this.elements;
|
|
|
|
|
@@ -6219,10 +6189,7 @@ class Euler {
|
|
|
|
|
|
}
|
|
|
|
|
|
- toArray( array, offset ) {
|
|
|
-
|
|
|
- if ( array === undefined ) array = [];
|
|
|
- if ( offset === undefined ) offset = 0;
|
|
|
+ toArray( array = [], offset = 0 ) {
|
|
|
|
|
|
array[ offset ] = this._x;
|
|
|
array[ offset + 1 ] = this._y;
|
|
@@ -6680,6 +6647,25 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
|
|
|
|
|
|
},
|
|
|
|
|
|
+ clear: function () {
|
|
|
+
|
|
|
+ for ( let i = 0; i < this.children.length; i ++ ) {
|
|
|
+
|
|
|
+ const object = this.children[ i ];
|
|
|
+
|
|
|
+ object.parent = null;
|
|
|
+
|
|
|
+ object.dispatchEvent( _removedEvent );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ this.children.length = 0;
|
|
|
+
|
|
|
+ return this;
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
attach: function ( object ) {
|
|
|
|
|
|
// adds object as a child of this, while maintaining the object's world transform
|
|
@@ -8255,9 +8241,7 @@ class Color {
|
|
|
|
|
|
}
|
|
|
|
|
|
- fromArray( array, offset ) {
|
|
|
-
|
|
|
- if ( offset === undefined ) offset = 0;
|
|
|
+ fromArray( array, offset = 0 ) {
|
|
|
|
|
|
this.r = array[ offset ];
|
|
|
this.g = array[ offset + 1 ];
|
|
@@ -8267,10 +8251,7 @@ class Color {
|
|
|
|
|
|
}
|
|
|
|
|
|
- toArray( array, offset ) {
|
|
|
-
|
|
|
- if ( array === undefined ) array = [];
|
|
|
- if ( offset === undefined ) offset = 0;
|
|
|
+ toArray( array = [], offset = 0 ) {
|
|
|
|
|
|
array[ offset ] = this.r;
|
|
|
array[ offset + 1 ] = this.g;
|
|
@@ -11859,7 +11840,7 @@ Camera.prototype = Object.assign( Object.create( Object3D.prototype ), {
|
|
|
|
|
|
}
|
|
|
|
|
|
- this.updateMatrixWorld( true );
|
|
|
+ this.updateWorldMatrix( true, false );
|
|
|
|
|
|
const e = this.matrixWorld.elements;
|
|
|
|
|
@@ -12214,22 +12195,6 @@ function CubeCamera( near, far, renderTarget ) {
|
|
|
|
|
|
};
|
|
|
|
|
|
- this.clear = function ( renderer, color, depth, stencil ) {
|
|
|
-
|
|
|
- const currentRenderTarget = renderer.getRenderTarget();
|
|
|
-
|
|
|
- for ( let i = 0; i < 6; i ++ ) {
|
|
|
-
|
|
|
- renderer.setRenderTarget( renderTarget, i );
|
|
|
-
|
|
|
- renderer.clear( color, depth, stencil );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- renderer.setRenderTarget( currentRenderTarget );
|
|
|
-
|
|
|
- };
|
|
|
-
|
|
|
}
|
|
|
|
|
|
CubeCamera.prototype = Object.create( Object3D.prototype );
|
|
@@ -12245,6 +12210,16 @@ function CubeTexture( images, mapping, wrapS, wrapT, magFilter, minFilter, forma
|
|
|
|
|
|
this.flipY = false;
|
|
|
|
|
|
+ // Why CubeTexture._needsFlipEnvMap is necessary:
|
|
|
+ //
|
|
|
+ // By convention -- likely based on the RenderMan spec from the 1990's -- cube maps are specified by WebGL (and three.js)
|
|
|
+ // in a coordinate system in which positive-x is to the right when looking up the positive-z axis -- in other words,
|
|
|
+ // in a left-handed coordinate system. By continuing this convention, preexisting cube maps continued to render correctly.
|
|
|
+
|
|
|
+ // three.js uses a right-handed coordinate system. So environment maps used in three.js appear to have px and nx swapped
|
|
|
+ // and the flag _needsFlipEnvMap controls this conversion. The flip is not required (and thus _needsFlipEnvMap is set to false)
|
|
|
+ // when using WebGLCubeRenderTarget.texture as a cube texture.
|
|
|
+
|
|
|
this._needsFlipEnvMap = true;
|
|
|
|
|
|
}
|
|
@@ -12386,6 +12361,22 @@ WebGLCubeRenderTarget.prototype.fromEquirectangularTexture = function ( renderer
|
|
|
|
|
|
};
|
|
|
|
|
|
+WebGLCubeRenderTarget.prototype.clear = function ( renderer, color, depth, stencil ) {
|
|
|
+
|
|
|
+ const currentRenderTarget = renderer.getRenderTarget();
|
|
|
+
|
|
|
+ for ( let i = 0; i < 6; i ++ ) {
|
|
|
+
|
|
|
+ renderer.setRenderTarget( this, i );
|
|
|
+
|
|
|
+ renderer.clear( color, depth, stencil );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ renderer.setRenderTarget( currentRenderTarget );
|
|
|
+
|
|
|
+};
|
|
|
+
|
|
|
function DataTexture( data, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding ) {
|
|
|
|
|
|
Texture.call( this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );
|
|
@@ -14973,6 +14964,8 @@ function WebGLCubeMaps( renderer ) {
|
|
|
renderer.setRenderList( currentRenderList );
|
|
|
renderer.setRenderState( currentRenderState );
|
|
|
|
|
|
+ texture.addEventListener( 'dispose', onTextureDispose );
|
|
|
+
|
|
|
return mapTextureMapping( renderTarget.texture, texture.mapping );
|
|
|
|
|
|
} else {
|
|
@@ -14993,6 +14986,23 @@ function WebGLCubeMaps( renderer ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ function onTextureDispose( event ) {
|
|
|
+
|
|
|
+ const texture = event.target;
|
|
|
+
|
|
|
+ texture.removeEventListener( 'dispose', onTextureDispose );
|
|
|
+
|
|
|
+ const cubemap = cubemaps.get( texture );
|
|
|
+
|
|
|
+ if ( cubemap !== undefined ) {
|
|
|
+
|
|
|
+ cubemaps.delete( texture );
|
|
|
+ cubemap.dispose();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
function dispose() {
|
|
|
|
|
|
cubemaps = new WeakMap();
|
|
@@ -15102,7 +15112,7 @@ function WebGLGeometries( gl, attributes, info, bindingStates ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- bindingStates.releaseStatesOfGeometry( geometry );
|
|
|
+ bindingStates.releaseStatesOfGeometry( buffergeometry );
|
|
|
|
|
|
if ( geometry.isInstancedBufferGeometry === true ) {
|
|
|
|
|
@@ -18224,7 +18234,7 @@ function shadowCastingLightsFirst( lightA, lightB ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
-function WebGLLights() {
|
|
|
+function WebGLLights( extensions, capabilities ) {
|
|
|
|
|
|
const cache = new UniformsCache();
|
|
|
|
|
@@ -18481,8 +18491,34 @@ function WebGLLights() {
|
|
|
|
|
|
if ( rectAreaLength > 0 ) {
|
|
|
|
|
|
- state.rectAreaLTC1 = UniformsLib.LTC_1;
|
|
|
- state.rectAreaLTC2 = UniformsLib.LTC_2;
|
|
|
+ if ( capabilities.isWebGL2 ) {
|
|
|
+
|
|
|
+ // WebGL 2
|
|
|
+
|
|
|
+ state.rectAreaLTC1 = UniformsLib.LTC_FLOAT_1;
|
|
|
+ state.rectAreaLTC2 = UniformsLib.LTC_FLOAT_2;
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ // WebGL 1
|
|
|
+
|
|
|
+ if ( extensions.has( 'OES_texture_float_linear' ) === true ) {
|
|
|
+
|
|
|
+ state.rectAreaLTC1 = UniformsLib.LTC_FLOAT_1;
|
|
|
+ state.rectAreaLTC2 = UniformsLib.LTC_FLOAT_2;
|
|
|
+
|
|
|
+ } else if ( extensions.has( 'OES_texture_half_float_linear' ) === true ) {
|
|
|
+
|
|
|
+ state.rectAreaLTC1 = UniformsLib.LTC_HALF_1;
|
|
|
+ state.rectAreaLTC2 = UniformsLib.LTC_HALF_2;
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ console.error( 'THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.' );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -18540,9 +18576,9 @@ function WebGLLights() {
|
|
|
|
|
|
}
|
|
|
|
|
|
-function WebGLRenderState() {
|
|
|
+function WebGLRenderState( extensions, capabilities ) {
|
|
|
|
|
|
- const lights = new WebGLLights();
|
|
|
+ const lights = new WebGLLights( extensions, capabilities );
|
|
|
|
|
|
const lightsArray = [];
|
|
|
const shadowsArray = [];
|
|
@@ -18590,7 +18626,7 @@ function WebGLRenderState() {
|
|
|
|
|
|
}
|
|
|
|
|
|
-function WebGLRenderStates() {
|
|
|
+function WebGLRenderStates( extensions, capabilities ) {
|
|
|
|
|
|
let renderStates = new WeakMap();
|
|
|
|
|
@@ -18600,7 +18636,7 @@ function WebGLRenderStates() {
|
|
|
|
|
|
if ( renderStates.has( scene ) === false ) {
|
|
|
|
|
|
- renderState = new WebGLRenderState();
|
|
|
+ renderState = new WebGLRenderState( extensions, capabilities );
|
|
|
renderStates.set( scene, new WeakMap() );
|
|
|
renderStates.get( scene ).set( camera, renderState );
|
|
|
|
|
@@ -18608,7 +18644,7 @@ function WebGLRenderStates() {
|
|
|
|
|
|
if ( renderStates.get( scene ).has( camera ) === false ) {
|
|
|
|
|
|
- renderState = new WebGLRenderState();
|
|
|
+ renderState = new WebGLRenderState( extensions, capabilities );
|
|
|
renderStates.get( scene ).set( camera, renderState );
|
|
|
|
|
|
} else {
|
|
@@ -23330,7 +23366,7 @@ function WebGLRenderer( parameters ) {
|
|
|
programCache = new WebGLPrograms( _this, cubemaps, extensions, capabilities, bindingStates, clipping );
|
|
|
materials = new WebGLMaterials( properties );
|
|
|
renderLists = new WebGLRenderLists( properties );
|
|
|
- renderStates = new WebGLRenderStates();
|
|
|
+ renderStates = new WebGLRenderStates( extensions, capabilities );
|
|
|
background = new WebGLBackground( _this, cubemaps, state, objects, _premultipliedAlpha );
|
|
|
|
|
|
bufferRenderer = new WebGLBufferRenderer( _gl, extensions, info, capabilities );
|
|
@@ -23906,9 +23942,9 @@ function WebGLRenderer( parameters ) {
|
|
|
currentRenderState = renderStates.get( scene, camera );
|
|
|
currentRenderState.init();
|
|
|
|
|
|
- scene.traverse( function ( object ) {
|
|
|
+ scene.traverseVisible( function ( object ) {
|
|
|
|
|
|
- if ( object.isLight ) {
|
|
|
+ if ( object.isLight && object.layers.test( camera.layers ) ) {
|
|
|
|
|
|
currentRenderState.pushLight( object );
|
|
|
|
|
@@ -27139,6 +27175,12 @@ VideoTexture.prototype = Object.assign( Object.create( Texture.prototype ), {
|
|
|
|
|
|
constructor: VideoTexture,
|
|
|
|
|
|
+ clone: function () {
|
|
|
+
|
|
|
+ return new this.constructor( this.image ).copy( this );
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
isVideoTexture: true,
|
|
|
|
|
|
update: function () {
|
|
@@ -39903,9 +39945,7 @@ class SphericalHarmonics3 {
|
|
|
|
|
|
}
|
|
|
|
|
|
- fromArray( array, offset ) {
|
|
|
-
|
|
|
- if ( offset === undefined ) offset = 0;
|
|
|
+ fromArray( array, offset = 0 ) {
|
|
|
|
|
|
const coefficients = this.coefficients;
|
|
|
|
|
@@ -39919,10 +39959,7 @@ class SphericalHarmonics3 {
|
|
|
|
|
|
}
|
|
|
|
|
|
- toArray( array, offset ) {
|
|
|
-
|
|
|
- if ( array === undefined ) array = [];
|
|
|
- if ( offset === undefined ) offset = 0;
|
|
|
+ toArray( array = [], offset = 0 ) {
|
|
|
|
|
|
const coefficients = this.coefficients;
|
|
|
|
|
@@ -40076,12 +40113,12 @@ MaterialLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
|
|
|
|
|
|
if ( json.uuid !== undefined ) material.uuid = json.uuid;
|
|
|
if ( json.name !== undefined ) material.name = json.name;
|
|
|
- if ( json.color !== undefined ) material.color.setHex( json.color );
|
|
|
+ if ( json.color !== undefined && material.color !== undefined ) material.color.setHex( json.color );
|
|
|
if ( json.roughness !== undefined ) material.roughness = json.roughness;
|
|
|
if ( json.metalness !== undefined ) material.metalness = json.metalness;
|
|
|
if ( json.sheen !== undefined ) material.sheen = new Color().setHex( json.sheen );
|
|
|
- if ( json.emissive !== undefined ) material.emissive.setHex( json.emissive );
|
|
|
- if ( json.specular !== undefined ) material.specular.setHex( json.specular );
|
|
|
+ if ( json.emissive !== undefined && material.emissive !== undefined ) material.emissive.setHex( json.emissive );
|
|
|
+ if ( json.specular !== undefined && material.specular !== undefined ) material.specular.setHex( json.specular );
|
|
|
if ( json.shininess !== undefined ) material.shininess = json.shininess;
|
|
|
if ( json.clearcoat !== undefined ) material.clearcoat = json.clearcoat;
|
|
|
if ( json.clearcoatRoughness !== undefined ) material.clearcoatRoughness = json.clearcoatRoughness;
|
|
@@ -42880,12 +42917,12 @@ class Audio extends Object3D {
|
|
|
if ( this._connected === true ) {
|
|
|
|
|
|
this.disconnect();
|
|
|
- this.filters = value;
|
|
|
+ this.filters = value.slice();
|
|
|
this.connect();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- this.filters = value;
|
|
|
+ this.filters = value.slice();
|
|
|
|
|
|
}
|
|
|
|
|
@@ -44467,7 +44504,12 @@ Object.assign( AnimationObjectGroup.prototype, {
|
|
|
const lastIndex = -- nObjects,
|
|
|
lastObject = objects[ lastIndex ];
|
|
|
|
|
|
- indicesByUUID[ lastObject.uuid ] = index;
|
|
|
+ if ( lastIndex > 0 ) {
|
|
|
+
|
|
|
+ indicesByUUID[ lastObject.uuid ] = index;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
objects[ index ] = lastObject;
|
|
|
objects.pop();
|
|
|
|
|
@@ -50827,6 +50869,13 @@ CubeCamera.prototype.updateCubeMap = function ( renderer, scene ) {
|
|
|
|
|
|
};
|
|
|
|
|
|
+CubeCamera.prototype.clear = function ( renderer, color, depth, stencil ) {
|
|
|
+
|
|
|
+ console.warn( 'THREE.CubeCamera: .clear() is now .renderTarget.clear().' );
|
|
|
+ return this.renderTarget.clear( renderer, color, depth, stencil );
|
|
|
+
|
|
|
+};
|
|
|
+
|
|
|
//
|
|
|
|
|
|
const GeometryUtils = {
|