提交 db539378 编写于 作者: M Mr.doob

Updated builds.

上级 3d01a173
...@@ -5074,9 +5074,13 @@ THREE.Matrix4.prototype = { ...@@ -5074,9 +5074,13 @@ THREE.Matrix4.prototype = {
return function ( eye, target, up ) { return function ( eye, target, up ) {
if ( x === undefined ) x = new THREE.Vector3(); if ( x === undefined ) {
if ( y === undefined ) y = new THREE.Vector3();
if ( z === undefined ) z = new THREE.Vector3(); x = new THREE.Vector3();
y = new THREE.Vector3();
z = new THREE.Vector3();
}
var te = this.elements; var te = this.elements;
...@@ -5092,7 +5096,7 @@ THREE.Matrix4.prototype = { ...@@ -5092,7 +5096,7 @@ THREE.Matrix4.prototype = {
if ( x.lengthSq() === 0 ) { if ( x.lengthSq() === 0 ) {
z.x += 0.0001; z.z += 0.0001;
x.crossVectors( up, z ).normalize(); x.crossVectors( up, z ).normalize();
} }
...@@ -5558,8 +5562,12 @@ THREE.Matrix4.prototype = { ...@@ -5558,8 +5562,12 @@ THREE.Matrix4.prototype = {
return function ( position, quaternion, scale ) { return function ( position, quaternion, scale ) {
if ( vector === undefined ) vector = new THREE.Vector3(); if ( vector === undefined ) {
if ( matrix === undefined ) matrix = new THREE.Matrix4();
vector = new THREE.Vector3();
matrix = new THREE.Matrix4();
}
var te = this.elements; var te = this.elements;
...@@ -17131,21 +17139,6 @@ THREE.PerspectiveCamera.prototype = Object.assign( Object.create( THREE.Camera.p ...@@ -17131,21 +17139,6 @@ THREE.PerspectiveCamera.prototype = Object.assign( Object.create( THREE.Camera.p
}, },
/**
* Sets the FOV by focal length (DEPRECATED).
*
* Optionally also sets .filmGauge, otherwise uses it. See .setFocalLength.
*/
setLens: function ( focalLength, filmGauge ) {
console.warn( "THREE.PerspectiveCamera.setLens is deprecated. " +
"Use .setFocalLength and .filmGauge for a photographic setup." );
if ( filmGauge !== undefined ) this.filmGauge = filmGauge;
this.setFocalLength( focalLength );
},
/** /**
* Sets the FOV by focal length in respect to the current .filmGauge. * Sets the FOV by focal length in respect to the current .filmGauge.
* *
...@@ -23804,7 +23797,7 @@ THREE.ShaderChunk[ 'common' ] = "#define PI 3.14159265359\n#define PI2 6.2831853 ...@@ -23804,7 +23797,7 @@ THREE.ShaderChunk[ 'common' ] = "#define PI 3.14159265359\n#define PI2 6.2831853
// File:src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl // File:src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl
THREE.ShaderChunk[ 'cube_uv_reflection_fragment' ] = "#ifdef ENVMAP_TYPE_CUBE_UV\nconst float cubeUV_textureSize = 1024.0;\nint getFaceFromDirection(vec3 direction) {\n vec3 absDirection = abs(direction);\n int face = -1;\n if( absDirection.x > absDirection.z ) {\n if(absDirection.x > absDirection.y )\n face = direction.x > 0.0 ? 0 : 3;\n else\n face = direction.y > 0.0 ? 1 : 4;\n }\n else {\n if(absDirection.z > absDirection.y )\n face = direction.z > 0.0 ? 2 : 5;\n else\n face = direction.y > 0.0 ? 1 : 4;\n }\n return face;\n}\nfloat cubeUV_maxLods1 = log2(cubeUV_textureSize*0.25) - 1.0;\nfloat cubeUV_rangeClamp = exp2((6.0 - 1.0) * 2.0);\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n float scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n float dxRoughness = dFdx(roughness);\n float dyRoughness = dFdy(roughness);\n vec3 dx = dFdx( vec * scale * dxRoughness );\n vec3 dy = dFdy( vec * scale * dyRoughness );\n float d = max( dot( dx, dx ), dot( dy, dy ) );\n d = clamp(d, 1.0, cubeUV_rangeClamp);\n float mipLevel = 0.5 * log2(d);\n return vec2(floor(mipLevel), fract(mipLevel));\n}\nfloat cubeUV_maxLods2 = log2(cubeUV_textureSize*0.25) - 2.0;\nconst float cubeUV_rcpTextureSize = 1.0 / cubeUV_textureSize;\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n mipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n float a = 16.0 * cubeUV_rcpTextureSize;\n vec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n vec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n float powScale = exp2_packed.x * exp2_packed.y;\n float scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n float mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n bool bRes = mipLevel == 0.0;\n scale = bRes && (scale < a) ? a : scale;\n vec3 r;\n vec2 offset;\n int face = getFaceFromDirection(direction);\n float rcpPowScale = 1.0 / powScale;\n if( face == 0) {\n r = vec3(direction.x, -direction.z, direction.y);\n offset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n offset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n }\n else if( face == 1) {\n r = vec3(direction.y, direction.x, direction.z);\n offset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n offset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n }\n else if( face == 2) {\n r = vec3(direction.z, direction.x, direction.y);\n offset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n offset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n }\n else if( face == 3) {\n r = vec3(direction.x, direction.z, direction.y);\n offset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n offset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n }\n else if( face == 4) {\n r = vec3(direction.y, direction.x, -direction.z);\n offset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n offset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n }\n else {\n r = vec3(direction.z, -direction.x, direction.y);\n offset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n offset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n }\n r = normalize(r);\n float texelOffset = 0.5 * cubeUV_rcpTextureSize;\n vec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n vec2 base = offset + vec2( texelOffset );\n return base + s * ( scale - 2.0 * texelOffset );\n}\nfloat cubeUV_maxLods3 = log2(cubeUV_textureSize*0.25) - 3.0;\nvec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {\n float roughnessVal = roughness* cubeUV_maxLods3;\n float r1 = floor(roughnessVal);\n float r2 = r1 + 1.0;\n float t = fract(roughnessVal);\n vec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n float s = mipInfo.y;\n float level0 = mipInfo.x;\n float level1 = level0 + 1.0;\n level1 = level1 > 5.0 ? 5.0 : level1;\n level0 += min( floor( s + 0.5 ), 5.0 );\n vec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n vec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n vec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n vec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n vec4 result = mix(color10, color20, t);\n return vec4(result.rgb, 1.0);\n}\n#endif\n"; THREE.ShaderChunk[ 'cube_uv_reflection_fragment' ] = "#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n vec3 absDirection = abs(direction);\n int face = -1;\n if( absDirection.x > absDirection.z ) {\n if(absDirection.x > absDirection.y )\n face = direction.x > 0.0 ? 0 : 3;\n else\n face = direction.y > 0.0 ? 1 : 4;\n }\n else {\n if(absDirection.z > absDirection.y )\n face = direction.z > 0.0 ? 2 : 5;\n else\n face = direction.y > 0.0 ? 1 : 4;\n }\n return face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n float scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n float dxRoughness = dFdx(roughness);\n float dyRoughness = dFdy(roughness);\n vec3 dx = dFdx( vec * scale * dxRoughness );\n vec3 dy = dFdy( vec * scale * dyRoughness );\n float d = max( dot( dx, dx ), dot( dy, dy ) );\n d = clamp(d, 1.0, cubeUV_rangeClamp);\n float mipLevel = 0.5 * log2(d);\n return vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n mipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n float a = 16.0 * cubeUV_rcpTextureSize;\n vec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n vec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n float powScale = exp2_packed.x * exp2_packed.y;\n float scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n float mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n bool bRes = mipLevel == 0.0;\n scale = bRes && (scale < a) ? a : scale;\n vec3 r;\n vec2 offset;\n int face = getFaceFromDirection(direction);\n float rcpPowScale = 1.0 / powScale;\n if( face == 0) {\n r = vec3(direction.x, -direction.z, direction.y);\n offset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n offset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n }\n else if( face == 1) {\n r = vec3(direction.y, direction.x, direction.z);\n offset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n offset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n }\n else if( face == 2) {\n r = vec3(direction.z, direction.x, direction.y);\n offset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n offset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n }\n else if( face == 3) {\n r = vec3(direction.x, direction.z, direction.y);\n offset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n offset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n }\n else if( face == 4) {\n r = vec3(direction.y, direction.x, -direction.z);\n offset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n offset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n }\n else {\n r = vec3(direction.z, -direction.x, direction.y);\n offset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n offset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n }\n r = normalize(r);\n float texelOffset = 0.5 * cubeUV_rcpTextureSize;\n vec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n vec2 base = offset + vec2( texelOffset );\n return base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {\n float roughnessVal = roughness* cubeUV_maxLods3;\n float r1 = floor(roughnessVal);\n float r2 = r1 + 1.0;\n float t = fract(roughnessVal);\n vec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n float s = mipInfo.y;\n float level0 = mipInfo.x;\n float level1 = level0 + 1.0;\n level1 = level1 > 5.0 ? 5.0 : level1;\n level0 += min( floor( s + 0.5 ), 5.0 );\n vec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n vec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n vec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n vec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n vec4 result = mix(color10, color20, t);\n return vec4(result.rgb, 1.0);\n}\n#endif\n";
// File:src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl // File:src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl
...@@ -24736,21 +24729,11 @@ THREE.WebGLRenderer = function ( parameters ) { ...@@ -24736,21 +24729,11 @@ THREE.WebGLRenderer = function ( parameters ) {
// clipping // clipping
_clipping = new THREE.WebGLClipping(),
_clippingEnabled = false, _clippingEnabled = false,
_localClippingEnabled = false, _localClippingEnabled = false,
_clipRenderingShadows = false,
_numClippingPlanes = 0,
_clippingPlanesUniform = {
type: '4fv', value: null, needsUpdate: false },
_globalClippingState = null,
_numGlobalClippingPlanes = 0,
_matrix3 = new THREE.Matrix3(),
_sphere = new THREE.Sphere(), _sphere = new THREE.Sphere(),
_plane = new THREE.Plane(),
// camera matrices cache // camera matrices cache
...@@ -25827,7 +25810,9 @@ THREE.WebGLRenderer = function ( parameters ) { ...@@ -25827,7 +25810,9 @@ THREE.WebGLRenderer = function ( parameters ) {
sprites.length = 0; sprites.length = 0;
lensFlares.length = 0; lensFlares.length = 0;
setupGlobalClippingPlanes( this.clippingPlanes, camera ); _localClippingEnabled = this.localClippingEnabled;
_clippingEnabled = _clipping.init(
this.clippingPlanes, _localClippingEnabled, camera );
projectObject( scene, camera ); projectObject( scene, camera );
...@@ -25844,12 +25829,7 @@ THREE.WebGLRenderer = function ( parameters ) { ...@@ -25844,12 +25829,7 @@ THREE.WebGLRenderer = function ( parameters ) {
// //
if ( _clippingEnabled ) { if ( _clippingEnabled ) _clipping.beginShadows();
_clipRenderingShadows = true;
setupClippingPlanes( null );
}
setupShadows( lights ); setupShadows( lights );
...@@ -25857,12 +25837,7 @@ THREE.WebGLRenderer = function ( parameters ) { ...@@ -25857,12 +25837,7 @@ THREE.WebGLRenderer = function ( parameters ) {
setupLights( lights, camera ); setupLights( lights, camera );
if ( _clippingEnabled ) { if ( _clippingEnabled ) _clipping.endShadows();
_clipRenderingShadows = false;
resetGlobalClippingState();
}
// //
...@@ -25999,7 +25974,10 @@ THREE.WebGLRenderer = function ( parameters ) { ...@@ -25999,7 +25974,10 @@ THREE.WebGLRenderer = function ( parameters ) {
applyMatrix4( object.matrixWorld ); applyMatrix4( object.matrixWorld );
if ( ! _frustum.intersectsSphere( sphere ) ) return false; if ( ! _frustum.intersectsSphere( sphere ) ) return false;
if ( _numClippingPlanes === 0 ) return true;
var numPlanes = _clipping.numPlanes;
if ( numPlanes === 0 ) return true;
var planes = _this.clippingPlanes, var planes = _this.clippingPlanes,
...@@ -26012,7 +25990,7 @@ THREE.WebGLRenderer = function ( parameters ) { ...@@ -26012,7 +25990,7 @@ THREE.WebGLRenderer = function ( parameters ) {
// out when deeper than radius in the negative halfspace // out when deeper than radius in the negative halfspace
if ( planes[ i ].distanceToPoint( center ) < negRad ) return false; if ( planes[ i ].distanceToPoint( center ) < negRad ) return false;
} while ( ++ i !== _numClippingPlanes ); } while ( ++ i !== numPlanes );
return true; return true;
...@@ -26159,7 +26137,7 @@ THREE.WebGLRenderer = function ( parameters ) { ...@@ -26159,7 +26137,7 @@ THREE.WebGLRenderer = function ( parameters ) {
var materialProperties = properties.get( material ); var materialProperties = properties.get( material );
var parameters = programCache.getParameters( var parameters = programCache.getParameters(
material, _lights, fog, _numClippingPlanes, object ); material, _lights, fog, _clipping.numPlanes, object );
var code = programCache.getProgramCode( material, parameters ); var code = programCache.getProgramCode( material, parameters );
...@@ -26261,8 +26239,8 @@ THREE.WebGLRenderer = function ( parameters ) { ...@@ -26261,8 +26239,8 @@ THREE.WebGLRenderer = function ( parameters ) {
! ( material instanceof THREE.RawShaderMaterial ) || ! ( material instanceof THREE.RawShaderMaterial ) ||
material.clipping === true ) { material.clipping === true ) {
materialProperties.numClippingPlanes = _numClippingPlanes; materialProperties.numClippingPlanes = _clipping.numPlanes;
uniforms.clippingPlanes = _clippingPlanesUniform; uniforms.clippingPlanes = _clipping.uniform;
} }
...@@ -26343,14 +26321,14 @@ THREE.WebGLRenderer = function ( parameters ) { ...@@ -26343,14 +26321,14 @@ THREE.WebGLRenderer = function ( parameters ) {
// we might want to call this function with some ClippingGroup // we might want to call this function with some ClippingGroup
// object instead of the material, once it becomes feasible // object instead of the material, once it becomes feasible
// (#8465, #8379) // (#8465, #8379)
setClippingState( _clipping.setState(
material.clippingPlanes, material.clipShadows, material.clippingPlanes, material.clipShadows,
camera, materialProperties, useCache ); camera, materialProperties, useCache );
} }
if ( materialProperties.numClippingPlanes !== undefined && if ( materialProperties.numClippingPlanes !== undefined &&
materialProperties.numClippingPlanes !== _numClippingPlanes ) { materialProperties.numClippingPlanes !== _clipping.numPlanes ) {
material.needsUpdate = true; material.needsUpdate = true;
...@@ -27076,124 +27054,6 @@ THREE.WebGLRenderer = function ( parameters ) { ...@@ -27076,124 +27054,6 @@ THREE.WebGLRenderer = function ( parameters ) {
} }
// Clipping
function setupGlobalClippingPlanes( planes, camera ) {
_clippingEnabled =
_this.clippingPlanes.length !== 0 ||
_this.localClippingEnabled ||
// enable state of previous frame - the clipping code has to
// run another frame in order to reset the state:
_numGlobalClippingPlanes !== 0 ||
_localClippingEnabled;
_localClippingEnabled = _this.localClippingEnabled;
_globalClippingState = setupClippingPlanes( planes, camera, 0 );
_numGlobalClippingPlanes = planes !== null ? planes.length : 0;
}
function setupClippingPlanes( planes, camera, dstOffset, skipTransform ) {
var nPlanes = planes !== null ? planes.length : 0,
dstArray = null;
if ( nPlanes !== 0 ) {
dstArray = _clippingPlanesUniform.value;
if ( skipTransform !== true || dstArray === null ) {
var flatSize = dstOffset + nPlanes * 4,
viewMatrix = camera.matrixWorldInverse,
viewNormalMatrix = _matrix3.getNormalMatrix( viewMatrix );
if ( dstArray === null || dstArray.length < flatSize ) {
dstArray = new Float32Array( flatSize );
}
for ( var i = 0, i4 = dstOffset; i !== nPlanes; ++ i, i4 += 4 ) {
var plane = _plane.copy( planes[ i ] ).
applyMatrix4( viewMatrix, viewNormalMatrix );
plane.normal.toArray( dstArray, i4 );
dstArray[ i4 + 3 ] = plane.constant;
}
}
_clippingPlanesUniform.value = dstArray;
_clippingPlanesUniform.needsUpdate = true;
}
_numClippingPlanes = nPlanes;
return dstArray;
}
function resetGlobalClippingState() {
if ( _clippingPlanesUniform.value !== _globalClippingState ) {
_clippingPlanesUniform.value = _globalClippingState;
_clippingPlanesUniform.needsUpdate = _numGlobalClippingPlanes > 0;
}
_numClippingPlanes = _numGlobalClippingPlanes;
}
function setClippingState( planes, clipShadows, camera, cache, fromCache ) {
if ( ! _localClippingEnabled ||
planes === null || planes.length === 0 ||
_clipRenderingShadows && ! clipShadows ) {
// there's no local clipping
if ( _clipRenderingShadows ) {
// there's no global clipping
setupClippingPlanes( null );
} else {
resetGlobalClippingState();
}
} else {
var nGlobal = _clipRenderingShadows ? 0 : _numGlobalClippingPlanes,
lGlobal = nGlobal * 4,
dstArray = cache.clippingState || null;
_clippingPlanesUniform.value = dstArray; // ensure unique state
dstArray = setupClippingPlanes(
planes, camera, lGlobal, fromCache );
for ( var i = 0; i !== lGlobal; ++ i ) {
dstArray[ i ] = _globalClippingState[ i ];
}
cache.clippingState = dstArray;
_numClippingPlanes += nGlobal;
}
}
// GL state setting // GL state setting
this.setFaceCulling = function ( cullFace, frontFaceDirection ) { this.setFaceCulling = function ( cullFace, frontFaceDirection ) {
...@@ -28350,6 +28210,161 @@ THREE.WebGLBufferRenderer = function ( _gl, extensions, _infoRender ) { ...@@ -28350,6 +28210,161 @@ THREE.WebGLBufferRenderer = function ( _gl, extensions, _infoRender ) {
}; };
// File:src/renderers/webgl/WebGLClipping.js
THREE.WebGLClipping = function() {
var scope = this,
globalState = null,
numGlobalPlanes = 0,
localClippingEnabled = false,
renderingShadows = false,
plane = new THREE.Plane(),
viewNormalMatrix = new THREE.Matrix3(),
uniform = { value: null, needsUpdate: false };
this.uniform = uniform;
this.numPlanes = 0;
this.init = function( planes, enableLocalClipping, camera ) {
var enabled =
planes.length !== 0 ||
enableLocalClipping ||
// enable state of previous frame - the clipping code has to
// run another frame in order to reset the state:
numGlobalPlanes !== 0 ||
localClippingEnabled;
localClippingEnabled = enableLocalClipping;
globalState = projectPlanes( planes, camera, 0 );
numGlobalPlanes = planes.length;
return enabled;
};
this.beginShadows = function() {
renderingShadows = true;
projectPlanes( null );
};
this.endShadows = function() {
renderingShadows = false;
resetGlobalState();
};
this.setState = function( planes, clipShadows, camera, cache, fromCache ) {
if ( ! localClippingEnabled ||
planes === null || planes.length === 0 ||
renderingShadows && ! clipShadows ) {
// there's no local clipping
if ( renderingShadows ) {
// there's no global clipping
projectPlanes( null );
} else {
resetGlobalState();
}
} else {
var nGlobal = renderingShadows ? 0 : numGlobalPlanes,
lGlobal = nGlobal * 4,
dstArray = cache.clippingState || null;
uniform.value = dstArray; // ensure unique state
dstArray = projectPlanes( planes, camera, lGlobal, fromCache );
for ( var i = 0; i !== lGlobal; ++ i ) {
dstArray[ i ] = globalState[ i ];
}
cache.clippingState = dstArray;
this.numPlanes += nGlobal;
}
};
function resetGlobalState() {
if ( uniform.value !== globalState ) {
uniform.value = globalState;
uniform.needsUpdate = numGlobalPlanes > 0;
}
scope.numPlanes = numGlobalPlanes;
}
function projectPlanes( planes, camera, dstOffset, skipTransform ) {
var nPlanes = planes !== null ? planes.length : 0,
dstArray = null;
if ( nPlanes !== 0 ) {
dstArray = uniform.value;
if ( skipTransform !== true || dstArray === null ) {
var flatSize = dstOffset + nPlanes * 4,
viewMatrix = camera.matrixWorldInverse;
viewNormalMatrix.getNormalMatrix( viewMatrix );
if ( dstArray === null || dstArray.length < flatSize ) {
dstArray = new Float32Array( flatSize );
}
for ( var i = 0, i4 = dstOffset;
i !== nPlanes; ++ i, i4 += 4 ) {
plane.copy( planes[ i ] ).
applyMatrix4( viewMatrix, viewNormalMatrix );
plane.normal.toArray( dstArray, i4 );
dstArray[ i4 + 3 ] = plane.constant;
}
}
uniform.value = dstArray;
uniform.needsUpdate = true;
}
scope.numPlanes = nPlanes;
return dstArray;
}
};
// File:src/renderers/webgl/WebGLIndexedBufferRenderer.js // File:src/renderers/webgl/WebGLIndexedBufferRenderer.js
/** /**
...@@ -32857,6 +32872,18 @@ Object.defineProperties( THREE.Object3D.prototype, { ...@@ -32857,6 +32872,18 @@ Object.defineProperties( THREE.Object3D.prototype, {
// //
THREE.PerspectiveCamera.prototype.setLens = function( focalLength, filmGauge ) {
console.warn( "THREE.PerspectiveCamera.setLens is deprecated. " +
"Use .setFocalLength and .filmGauge for a photographic setup." );
if ( filmGauge !== undefined ) this.filmGauge = filmGauge;
this.setFocalLength( focalLength );
};
//
Object.defineProperties( THREE, { Object.defineProperties( THREE, {
PointCloud: { PointCloud: {
value: function ( geometry, material ) { value: function ( geometry, material ) {
...@@ -36660,7 +36687,6 @@ THREE.CylinderBufferGeometry = function( radiusTop, radiusBottom, height, radial ...@@ -36660,7 +36687,6 @@ THREE.CylinderBufferGeometry = function( radiusTop, radiusBottom, height, radial
}; };
var scope = this; var scope = this;
var twoPi = 2.0 * Math.PI;
radiusTop = radiusTop !== undefined ? radiusTop : 20; radiusTop = radiusTop !== undefined ? radiusTop : 20;
radiusBottom = radiusBottom !== undefined ? radiusBottom : 20; radiusBottom = radiusBottom !== undefined ? radiusBottom : 20;
...@@ -36671,7 +36697,7 @@ THREE.CylinderBufferGeometry = function( radiusTop, radiusBottom, height, radial ...@@ -36671,7 +36697,7 @@ THREE.CylinderBufferGeometry = function( radiusTop, radiusBottom, height, radial
openEnded = openEnded !== undefined ? openEnded : false; openEnded = openEnded !== undefined ? openEnded : false;
thetaStart = thetaStart !== undefined ? thetaStart : 0.0; thetaStart = thetaStart !== undefined ? thetaStart : 0.0;
thetaLength = thetaLength !== undefined ? thetaLength : twoPi; thetaLength = thetaLength !== undefined ? thetaLength : 2.0 * Math.PI;
// used to calculate buffer length // used to calculate buffer length
...@@ -36854,9 +36880,8 @@ THREE.CylinderBufferGeometry = function( radiusTop, radiusBottom, height, radial ...@@ -36854,9 +36880,8 @@ THREE.CylinderBufferGeometry = function( radiusTop, radiusBottom, height, radial
function generateCap( top ) { function generateCap( top ) {
var x, var x, centerIndexStart, centerIndexEnd;
centerIndexStart,
centerIndexEnd;
var uv = new THREE.Vector2(); var uv = new THREE.Vector2();
var vertex = new THREE.Vector3(); var vertex = new THREE.Vector3();
...@@ -36915,7 +36940,7 @@ THREE.CylinderBufferGeometry = function( radiusTop, radiusBottom, height, radial ...@@ -36915,7 +36940,7 @@ THREE.CylinderBufferGeometry = function( radiusTop, radiusBottom, height, radial
// uv // uv
uv.x = ( cosTheta * 0.5 ) + 0.5; uv.x = ( cosTheta * 0.5 ) + 0.5;
uv.y = ( sinTheta * 0.5 ) + 0.5; uv.y = ( sinTheta * 0.5 * sign ) + 0.5;
uvs.setXY( index, uv.x, uv.y ); uvs.setXY( index, uv.x, uv.y );
// increase index // increase index
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册