Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 49 additions & 53 deletions build/three.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -18993,7 +18993,7 @@ class BufferGeometry extends EventDispatcher {
* This dictionary holds the morph targets of the geometry.
*
* Note: Once the geometry has been rendered, the morph attribute data cannot
* be changed. You will have to call `dispose()?, and create a new geometry instance.
* be changed. You will have to call `dispose()`, and create a new geometry instance.
*
* @type {Object}
*/
Expand Down Expand Up @@ -31416,7 +31416,7 @@ class PolyhedronGeometry extends BufferGeometry {
*/
static fromJSON( data ) {

return new PolyhedronGeometry( data.vertices, data.indices, data.radius, data.details );
return new PolyhedronGeometry( data.vertices, data.indices, data.radius, data.detail );

}

Expand Down Expand Up @@ -46046,10 +46046,6 @@ class SpotLight extends Light {

}

const _projScreenMatrix = /*@__PURE__*/ new Matrix4();
const _lightPositionWorld = /*@__PURE__*/ new Vector3();
const _lookTarget = /*@__PURE__*/ new Vector3();

/**
* Represents the shadow configuration of point lights.
*
Expand All @@ -46073,52 +46069,6 @@ class PointLightShadow extends LightShadow {
*/
this.isPointLightShadow = true;

this._cubeDirections = [
new Vector3( 1, 0, 0 ), new Vector3( -1, 0, 0 ), new Vector3( 0, 1, 0 ),
new Vector3( 0, -1, 0 ), new Vector3( 0, 0, 1 ), new Vector3( 0, 0, -1 )
];

this._cubeUps = [
new Vector3( 0, -1, 0 ), new Vector3( 0, -1, 0 ), new Vector3( 0, 0, 1 ),
new Vector3( 0, 0, -1 ), new Vector3( 0, -1, 0 ), new Vector3( 0, -1, 0 )
];

}

/**
* Update the matrices for the camera and shadow, used internally by the renderer.
*
* @param {Light} light - The light for which the shadow is being rendered.
* @param {number} [faceIndex=0] - The cube face index (0-5).
*/
updateMatrices( light, faceIndex = 0 ) {

const camera = this.camera;
const shadowMatrix = this.matrix;

const far = light.distance || camera.far;

if ( far !== camera.far ) {

camera.far = far;
camera.updateProjectionMatrix();

}

_lightPositionWorld.setFromMatrixPosition( light.matrixWorld );
camera.position.copy( _lightPositionWorld );

_lookTarget.copy( camera.position );
_lookTarget.add( this._cubeDirections[ faceIndex ] );
camera.up.copy( this._cubeUps[ faceIndex ] );
camera.lookAt( _lookTarget );
camera.updateMatrixWorld();

shadowMatrix.makeTranslation( - _lightPositionWorld.x, - _lightPositionWorld.y, - _lightPositionWorld.z );

_projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
this._frustum.setFromProjectionMatrix( _projScreenMatrix, camera.coordinateSystem, camera.reversedDepth );

}

}
Expand Down Expand Up @@ -67718,6 +67668,20 @@ const vertex = "void main() {\n\tgl_Position = vec4( position, 1.0 );\n}";

const fragment = "uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );\n\tgl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );\n}";

const _cubeDirections = [
/*@__PURE__*/ new Vector3( 1, 0, 0 ), /*@__PURE__*/ new Vector3( -1, 0, 0 ), /*@__PURE__*/ new Vector3( 0, 1, 0 ),
/*@__PURE__*/ new Vector3( 0, -1, 0 ), /*@__PURE__*/ new Vector3( 0, 0, 1 ), /*@__PURE__*/ new Vector3( 0, 0, -1 )
];

const _cubeUps = [
/*@__PURE__*/ new Vector3( 0, -1, 0 ), /*@__PURE__*/ new Vector3( 0, -1, 0 ), /*@__PURE__*/ new Vector3( 0, 0, 1 ),
/*@__PURE__*/ new Vector3( 0, 0, -1 ), /*@__PURE__*/ new Vector3( 0, -1, 0 ), /*@__PURE__*/ new Vector3( 0, -1, 0 )
];

const _projScreenMatrix = /*@__PURE__*/ new Matrix4();
const _lightPositionWorld = /*@__PURE__*/ new Vector3();
const _lookTarget = /*@__PURE__*/ new Vector3();

function WebGLShadowMap( renderer, objects, capabilities ) {

let _frustum = new Frustum();
Expand Down Expand Up @@ -67997,7 +67961,39 @@ function WebGLShadowMap( renderer, objects, capabilities ) {

}

shadow.updateMatrices( light, face );
if ( light.isPointLight ) {

const camera = shadow.camera;
const shadowMatrix = shadow.matrix;

const far = light.distance || camera.far;

if ( far !== camera.far ) {

camera.far = far;
camera.updateProjectionMatrix();

}

_lightPositionWorld.setFromMatrixPosition( light.matrixWorld );
camera.position.copy( _lightPositionWorld );

_lookTarget.copy( camera.position );
_lookTarget.add( _cubeDirections[ face ] );
camera.up.copy( _cubeUps[ face ] );
camera.lookAt( _lookTarget );
camera.updateMatrixWorld();

shadowMatrix.makeTranslation( - _lightPositionWorld.x, - _lightPositionWorld.y, - _lightPositionWorld.z );

_projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
shadow._frustum.setFromProjectionMatrix( _projScreenMatrix, camera.coordinateSystem, camera.reversedDepth );

} else {

shadow.updateMatrices( light );

}

_frustum = shadow.getFrustum();

Expand Down
96 changes: 23 additions & 73 deletions build/three.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -18991,7 +18991,7 @@ class BufferGeometry extends EventDispatcher {
* This dictionary holds the morph targets of the geometry.
*
* Note: Once the geometry has been rendered, the morph attribute data cannot
* be changed. You will have to call `dispose()?, and create a new geometry instance.
* be changed. You will have to call `dispose()`, and create a new geometry instance.
*
* @type {Object}
*/
Expand Down Expand Up @@ -26799,7 +26799,7 @@ class Frustum {

}

const _projScreenMatrix$2 = /*@__PURE__*/ new Matrix4();
const _projScreenMatrix$1 = /*@__PURE__*/ new Matrix4();
const _frustum$1 = /*@__PURE__*/ new Frustum();

/**
Expand Down Expand Up @@ -26844,13 +26844,13 @@ class FrustumArray {

const camera = cameraArray.cameras[ i ];

_projScreenMatrix$2.multiplyMatrices(
_projScreenMatrix$1.multiplyMatrices(
camera.projectionMatrix,
camera.matrixWorldInverse
);

_frustum$1.setFromProjectionMatrix(
_projScreenMatrix$2,
_projScreenMatrix$1,
camera.coordinateSystem,
camera.reversedDepth
);
Expand Down Expand Up @@ -26887,13 +26887,13 @@ class FrustumArray {

const camera = cameraArray.cameras[ i ];

_projScreenMatrix$2.multiplyMatrices(
_projScreenMatrix$1.multiplyMatrices(
camera.projectionMatrix,
camera.matrixWorldInverse
);

_frustum$1.setFromProjectionMatrix(
_projScreenMatrix$2,
_projScreenMatrix$1,
camera.coordinateSystem,
camera.reversedDepth
);
Expand Down Expand Up @@ -26930,13 +26930,13 @@ class FrustumArray {

const camera = cameraArray.cameras[ i ];

_projScreenMatrix$2.multiplyMatrices(
_projScreenMatrix$1.multiplyMatrices(
camera.projectionMatrix,
camera.matrixWorldInverse
);

_frustum$1.setFromProjectionMatrix(
_projScreenMatrix$2,
_projScreenMatrix$1,
camera.coordinateSystem,
camera.reversedDepth
);
Expand Down Expand Up @@ -26973,13 +26973,13 @@ class FrustumArray {

const camera = cameraArray.cameras[ i ];

_projScreenMatrix$2.multiplyMatrices(
_projScreenMatrix$1.multiplyMatrices(
camera.projectionMatrix,
camera.matrixWorldInverse
);

_frustum$1.setFromProjectionMatrix(
_projScreenMatrix$2,
_projScreenMatrix$1,
camera.coordinateSystem,
camera.reversedDepth
);
Expand Down Expand Up @@ -27016,13 +27016,13 @@ class FrustumArray {

const camera = cameraArray.cameras[ i ];

_projScreenMatrix$2.multiplyMatrices(
_projScreenMatrix$1.multiplyMatrices(
camera.projectionMatrix,
camera.matrixWorldInverse
);

_frustum$1.setFromProjectionMatrix(
_projScreenMatrix$2,
_projScreenMatrix$1,
camera.coordinateSystem,
camera.reversedDepth
);
Expand Down Expand Up @@ -31414,7 +31414,7 @@ class PolyhedronGeometry extends BufferGeometry {
*/
static fromJSON( data ) {

return new PolyhedronGeometry( data.vertices, data.indices, data.radius, data.details );
return new PolyhedronGeometry( data.vertices, data.indices, data.radius, data.detail );

}

Expand Down Expand Up @@ -45453,9 +45453,9 @@ class HemisphereLight extends Light {

}

const _projScreenMatrix$1 = /*@__PURE__*/ new Matrix4();
const _lightPositionWorld$1 = /*@__PURE__*/ new Vector3();
const _lookTarget$1 = /*@__PURE__*/ new Vector3();
const _projScreenMatrix = /*@__PURE__*/ new Matrix4();
const _lightPositionWorld = /*@__PURE__*/ new Vector3();
const _lookTarget = /*@__PURE__*/ new Vector3();

/**
* Abstract base class for light shadow classes. These classes
Expand Down Expand Up @@ -45641,15 +45641,15 @@ class LightShadow {
const shadowCamera = this.camera;
const shadowMatrix = this.matrix;

_lightPositionWorld$1.setFromMatrixPosition( light.matrixWorld );
shadowCamera.position.copy( _lightPositionWorld$1 );
_lightPositionWorld.setFromMatrixPosition( light.matrixWorld );
shadowCamera.position.copy( _lightPositionWorld );

_lookTarget$1.setFromMatrixPosition( light.target.matrixWorld );
shadowCamera.lookAt( _lookTarget$1 );
_lookTarget.setFromMatrixPosition( light.target.matrixWorld );
shadowCamera.lookAt( _lookTarget );
shadowCamera.updateMatrixWorld();

_projScreenMatrix$1.multiplyMatrices( shadowCamera.projectionMatrix, shadowCamera.matrixWorldInverse );
this._frustum.setFromProjectionMatrix( _projScreenMatrix$1, shadowCamera.coordinateSystem, shadowCamera.reversedDepth );
_projScreenMatrix.multiplyMatrices( shadowCamera.projectionMatrix, shadowCamera.matrixWorldInverse );
this._frustum.setFromProjectionMatrix( _projScreenMatrix, shadowCamera.coordinateSystem, shadowCamera.reversedDepth );

if ( shadowCamera.reversedDepth ) {

Expand All @@ -45671,7 +45671,7 @@ class LightShadow {

}

shadowMatrix.multiply( _projScreenMatrix$1 );
shadowMatrix.multiply( _projScreenMatrix );

}

Expand Down Expand Up @@ -46044,10 +46044,6 @@ class SpotLight extends Light {

}

const _projScreenMatrix = /*@__PURE__*/ new Matrix4();
const _lightPositionWorld = /*@__PURE__*/ new Vector3();
const _lookTarget = /*@__PURE__*/ new Vector3();

/**
* Represents the shadow configuration of point lights.
*
Expand All @@ -46071,52 +46067,6 @@ class PointLightShadow extends LightShadow {
*/
this.isPointLightShadow = true;

this._cubeDirections = [
new Vector3( 1, 0, 0 ), new Vector3( -1, 0, 0 ), new Vector3( 0, 1, 0 ),
new Vector3( 0, -1, 0 ), new Vector3( 0, 0, 1 ), new Vector3( 0, 0, -1 )
];

this._cubeUps = [
new Vector3( 0, -1, 0 ), new Vector3( 0, -1, 0 ), new Vector3( 0, 0, 1 ),
new Vector3( 0, 0, -1 ), new Vector3( 0, -1, 0 ), new Vector3( 0, -1, 0 )
];

}

/**
* Update the matrices for the camera and shadow, used internally by the renderer.
*
* @param {Light} light - The light for which the shadow is being rendered.
* @param {number} [faceIndex=0] - The cube face index (0-5).
*/
updateMatrices( light, faceIndex = 0 ) {

const camera = this.camera;
const shadowMatrix = this.matrix;

const far = light.distance || camera.far;

if ( far !== camera.far ) {

camera.far = far;
camera.updateProjectionMatrix();

}

_lightPositionWorld.setFromMatrixPosition( light.matrixWorld );
camera.position.copy( _lightPositionWorld );

_lookTarget.copy( camera.position );
_lookTarget.add( this._cubeDirections[ faceIndex ] );
camera.up.copy( this._cubeUps[ faceIndex ] );
camera.lookAt( _lookTarget );
camera.updateMatrixWorld();

shadowMatrix.makeTranslation( - _lightPositionWorld.x, - _lightPositionWorld.y, - _lightPositionWorld.z );

_projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
this._frustum.setFromProjectionMatrix( _projScreenMatrix, camera.coordinateSystem, camera.reversedDepth );

}

}
Expand Down
2 changes: 1 addition & 1 deletion build/three.core.min.js

Large diffs are not rendered by default.

Loading
Loading