super-three 0.169.1 → 0.170.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/three.cjs +24628 -24228
- package/build/three.core.js +37002 -0
- package/build/three.core.min.js +6 -0
- package/build/three.module.js +10519 -47108
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +533 -0
- package/build/three.tsl.min.js +6 -0
- package/build/three.webgpu.js +17071 -53583
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +17134 -53623
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +3 -3
- package/examples/jsm/animation/MMDAnimationHelper.js +2 -0
- package/examples/jsm/animation/MMDPhysics.js +2 -0
- package/examples/jsm/capabilities/WebGPU.js +1 -10
- package/examples/jsm/controls/ArcballControls.js +25 -21
- package/examples/jsm/controls/OrbitControls.js +41 -9
- package/examples/jsm/controls/PointerLockControls.js +2 -5
- package/examples/jsm/controls/TransformControls.js +22 -6
- package/examples/jsm/csm/CSM.js +2 -2
- package/examples/jsm/csm/CSMFrustum.js +7 -4
- package/examples/jsm/csm/CSMHelper.js +2 -0
- package/examples/jsm/csm/CSMShadowNode.js +437 -0
- package/examples/jsm/curves/NURBSCurve.js +34 -3
- package/examples/jsm/exporters/GLTFExporter.js +138 -71
- package/examples/jsm/exporters/KTX2Exporter.js +35 -12
- package/examples/jsm/exporters/MMDExporter.js +6 -0
- package/examples/jsm/exporters/USDZExporter.js +21 -3
- package/examples/jsm/geometries/DecalGeometry.js +70 -21
- package/examples/jsm/geometries/InstancedPointsGeometry.js +2 -0
- package/examples/jsm/helpers/TextureHelperGPU.js +175 -0
- package/examples/jsm/interactive/HTMLMesh.js +1 -0
- package/examples/jsm/lighting/TiledLighting.js +18 -0
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +1 -1
- package/examples/jsm/lines/LineGeometry.js +25 -0
- package/examples/jsm/lines/LineMaterial.js +0 -1
- package/examples/jsm/lines/LineSegmentsGeometry.js +2 -0
- package/examples/jsm/lines/webgpu/Line2.js +2 -1
- package/examples/jsm/lines/webgpu/LineSegments2.js +2 -16
- package/examples/jsm/lines/webgpu/Wireframe.js +57 -0
- package/examples/jsm/loaders/3DMLoader.js +1 -0
- package/examples/jsm/loaders/3MFLoader.js +91 -0
- package/examples/jsm/loaders/FBXLoader.js +12 -2
- package/examples/jsm/loaders/GLTFLoader.js +2 -0
- package/examples/jsm/loaders/KTX2Loader.js +143 -49
- package/examples/jsm/loaders/LDrawLoader.js +22 -136
- package/examples/jsm/loaders/LottieLoader.js +1 -0
- package/examples/jsm/loaders/MMDLoader.js +3 -0
- package/examples/jsm/loaders/MaterialXLoader.js +2 -2
- package/examples/jsm/materials/LDrawConditionalLineMaterial.js +143 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +114 -0
- package/examples/jsm/math/ColorSpaces.js +76 -0
- package/examples/jsm/misc/ProgressiveLightMap.js +52 -40
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +293 -0
- package/examples/jsm/misc/VolumeSlice.js +1 -0
- package/examples/jsm/objects/InstancedPoints.js +2 -4
- package/examples/jsm/objects/LensflareMesh.js +4 -2
- package/examples/jsm/objects/SkyMesh.js +5 -3
- package/examples/jsm/objects/Water2Mesh.js +7 -3
- package/examples/jsm/objects/WaterMesh.js +12 -10
- package/examples/jsm/postprocessing/AfterimagePass.js +14 -3
- package/examples/jsm/postprocessing/SSRPass.js +6 -0
- package/examples/jsm/renderers/CSS2DRenderer.js +6 -3
- package/examples/jsm/renderers/CSS3DRenderer.js +7 -4
- package/examples/jsm/shaders/FXAAShader.js +225 -224
- package/examples/jsm/transpiler/AST.js +2 -2
- package/examples/jsm/transpiler/GLSLDecoder.js +57 -25
- package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
- package/examples/jsm/transpiler/TSLEncoder.js +11 -6
- package/{src/nodes → examples/jsm/tsl}/display/AfterImageNode.js +18 -21
- package/{src/nodes → examples/jsm/tsl}/display/AnaglyphPassNode.js +2 -6
- package/{src/nodes → examples/jsm/tsl}/display/AnamorphicNode.js +12 -18
- package/{src/nodes → examples/jsm/tsl}/display/BleachBypass.js +1 -3
- package/{src/nodes → examples/jsm/tsl}/display/BloomNode.js +12 -41
- package/{src/nodes → examples/jsm/tsl}/display/DenoiseNode.js +60 -47
- package/{src/nodes → examples/jsm/tsl}/display/DepthOfFieldNode.js +4 -9
- package/{src/nodes → examples/jsm/tsl}/display/DotScreenNode.js +2 -9
- package/examples/jsm/tsl/display/FXAANode.js +316 -0
- package/{src/nodes → examples/jsm/tsl}/display/FilmNode.js +4 -7
- package/{src/nodes → examples/jsm/tsl}/display/GTAONode.js +73 -78
- package/{src/nodes → examples/jsm/tsl}/display/GaussianBlurNode.js +78 -42
- package/examples/jsm/tsl/display/LensflareNode.js +161 -0
- package/{src/nodes → examples/jsm/tsl}/display/Lut3DNode.js +3 -5
- package/{src/nodes → examples/jsm/tsl}/display/MotionBlur.js +2 -3
- package/examples/jsm/tsl/display/OutlineNode.js +434 -0
- package/{src/nodes → examples/jsm/tsl}/display/ParallaxBarrierPassNode.js +2 -5
- package/{src/nodes → examples/jsm/tsl}/display/PixelationPassNode.js +5 -17
- package/{src/nodes → examples/jsm/tsl}/display/RGBShiftNode.js +2 -6
- package/examples/jsm/tsl/display/SMAANode.js +620 -0
- package/{src/nodes → examples/jsm/tsl}/display/SSAAPassNode.js +10 -25
- package/examples/jsm/tsl/display/SSRNode.js +366 -0
- package/{src/nodes → examples/jsm/tsl}/display/Sepia.js +1 -2
- package/{src/nodes → examples/jsm/tsl}/display/SobelOperatorNode.js +4 -12
- package/{src/nodes → examples/jsm/tsl}/display/StereoCompositePassNode.js +9 -11
- package/{src/nodes → examples/jsm/tsl}/display/StereoPassNode.js +10 -11
- package/examples/jsm/tsl/display/TRAAPassNode.js +355 -0
- package/{src/nodes → examples/jsm/tsl}/display/TransitionNode.js +3 -7
- package/examples/jsm/tsl/display/hashBlur.js +24 -0
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +389 -0
- package/examples/jsm/utils/SceneOptimizer.js +410 -0
- package/examples/jsm/utils/UVsDebug.js +1 -1
- package/examples/jsm/utils/{TextureUtilsGPU.js → WebGPUTextureUtils.js} +2 -1
- package/examples/jsm/webxr/OculusHandPointerModel.js +21 -21
- package/examples/jsm/webxr/Text2D.js +6 -6
- package/package.json +4 -4
- package/src/Three.Core.js +178 -0
- package/src/Three.TSL.js +526 -0
- package/src/Three.WebGPU.Nodes.js +9 -186
- package/src/Three.WebGPU.js +8 -186
- package/src/Three.js +1 -177
- package/src/animation/AnimationClip.js +2 -2
- package/src/animation/AnimationObjectGroup.js +2 -2
- package/src/audio/Audio.js +38 -0
- package/src/cameras/PerspectiveCamera.js +6 -6
- package/src/cameras/StereoCamera.js +2 -2
- package/src/constants.js +1 -6
- package/src/core/BufferGeometry.js +48 -8
- package/src/core/InterleavedBuffer.js +4 -4
- package/src/core/Object3D.js +2 -2
- package/src/extras/core/Curve.js +3 -3
- package/src/extras/core/Shape.js +2 -2
- package/src/geometries/CylinderGeometry.js +2 -2
- package/src/geometries/EdgesGeometry.js +2 -2
- package/src/geometries/LatheGeometry.js +2 -2
- package/src/lights/SpotLightShadow.js +2 -2
- package/src/materials/LineDashedMaterial.js +0 -1
- package/src/materials/Material.js +2 -2
- package/src/materials/MeshPhongMaterial.js +1 -1
- package/src/materials/MeshPhysicalMaterial.js +2 -2
- package/src/materials/MeshStandardMaterial.js +2 -2
- package/src/materials/nodes/Line2NodeMaterial.js +32 -13
- package/src/materials/nodes/LineDashedNodeMaterial.js +4 -2
- package/src/materials/nodes/NodeMaterial.js +93 -23
- package/src/materials/nodes/SpriteNodeMaterial.js +11 -2
- package/src/materials/nodes/manager/NodeMaterialObserver.js +119 -7
- package/src/math/ColorManagement.js +143 -102
- package/src/math/Line3.js +2 -2
- package/src/math/Quaternion.js +2 -2
- package/src/math/Spherical.js +3 -3
- package/src/math/Vector2.js +7 -7
- package/src/math/Vector3.js +9 -9
- package/src/math/Vector4.js +22 -9
- package/src/nodes/Nodes.js +2 -21
- package/src/nodes/TSL.js +9 -25
- package/src/nodes/accessors/Arrays.js +27 -0
- package/src/nodes/accessors/BuiltinNode.js +26 -0
- package/src/nodes/accessors/Camera.js +0 -1
- package/src/nodes/accessors/ClippingNode.js +76 -42
- package/src/nodes/accessors/InstanceNode.js +17 -20
- package/src/nodes/accessors/InstancedMeshNode.js +26 -0
- package/src/nodes/accessors/Lights.js +32 -0
- package/src/nodes/accessors/SceneNode.js +35 -1
- package/src/nodes/accessors/StorageBufferNode.js +61 -19
- package/src/nodes/accessors/StorageTextureNode.js +10 -4
- package/src/nodes/accessors/TextureNode.js +1 -1
- package/src/nodes/accessors/VelocityNode.js +13 -3
- package/src/nodes/code/FunctionCallNode.js +16 -5
- package/src/nodes/code/ScriptableNode.js +4 -4
- package/src/nodes/core/Node.js +1 -0
- package/src/nodes/core/NodeBuilder.js +31 -14
- package/src/nodes/core/NodeUtils.js +28 -0
- package/src/nodes/core/VarNode.js +15 -3
- package/src/nodes/core/constants.js +6 -0
- package/src/nodes/display/BlendModes.js +99 -0
- package/src/nodes/display/ColorAdjustment.js +53 -4
- package/src/nodes/display/ColorSpaceFunctions.js +5 -5
- package/src/nodes/display/ColorSpaceNode.js +27 -39
- package/src/nodes/display/PassNode.js +6 -4
- package/src/nodes/display/ToneMappingNode.js +1 -1
- package/src/nodes/display/ToonOutlinePassNode.js +3 -3
- package/src/nodes/display/ViewportDepthNode.js +48 -1
- package/src/nodes/functions/PhysicalLightingModel.js +21 -15
- package/src/nodes/functions/material/getAlphaHashThreshold.js +70 -0
- package/src/nodes/functions/material/getGeometryRoughness.js +8 -2
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +22 -0
- package/src/nodes/gpgpu/ComputeNode.js +9 -1
- package/src/nodes/lighting/AnalyticLightNode.js +23 -419
- package/src/nodes/lighting/LightsNode.js +24 -12
- package/src/nodes/lighting/PointLightNode.js +41 -22
- package/src/nodes/lighting/PointShadowNode.js +254 -0
- package/src/nodes/lighting/RectAreaLightNode.js +3 -0
- package/src/nodes/lighting/ShadowNode.js +593 -0
- package/src/nodes/lighting/SpotLightNode.js +14 -2
- package/src/nodes/utils/LoopNode.js +2 -2
- package/src/nodes/utils/Oscillators.js +6 -0
- package/src/nodes/utils/PostProcessingUtils.js +89 -0
- package/src/nodes/utils/RTTNode.js +9 -1
- package/src/nodes/utils/ReflectorNode.js +101 -15
- package/src/nodes/utils/StorageArrayElementNode.js +2 -2
- package/src/nodes/utils/Timer.js +29 -0
- package/src/objects/BatchedMesh.js +472 -296
- package/src/objects/ClippingGroup.js +19 -0
- package/src/objects/Skeleton.js +2 -2
- package/src/renderers/WebGLRenderer.js +183 -109
- package/src/renderers/common/Animation.js +23 -11
- package/src/renderers/common/Attributes.js +4 -0
- package/src/renderers/common/Backend.js +2 -0
- package/src/renderers/common/Background.js +15 -5
- package/src/renderers/common/Bindings.js +23 -6
- package/src/renderers/common/ClippingContext.js +77 -85
- package/src/renderers/common/Constants.js +2 -1
- package/src/renderers/common/Geometries.js +20 -0
- package/src/renderers/common/IndirectStorageBufferAttribute.js +15 -0
- package/src/renderers/common/Lighting.js +45 -0
- package/src/renderers/common/PostProcessingUtils.js +86 -0
- package/src/renderers/common/RenderList.js +48 -17
- package/src/renderers/common/RenderLists.js +4 -2
- package/src/renderers/common/RenderObject.js +45 -28
- package/src/renderers/common/RenderObjects.js +12 -6
- package/src/renderers/common/Renderer.js +222 -77
- package/src/renderers/common/Textures.js +41 -17
- package/src/renderers/common/UniformsGroup.js +16 -4
- package/src/renderers/common/extras/PMREMGenerator.js +89 -13
- package/src/renderers/common/nodes/NodeLibrary.js +2 -15
- package/src/renderers/common/nodes/NodeStorageBuffer.js +2 -3
- package/src/renderers/common/nodes/NodeUniform.js +42 -0
- package/src/renderers/common/nodes/Nodes.js +2 -2
- package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +4 -24
- package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +2 -2
- package/src/renderers/webgl/WebGLBackground.js +20 -1
- package/src/renderers/webgl/WebGLBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLCapabilities.js +0 -7
- package/src/renderers/webgl/WebGLGeometries.js +0 -28
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLProgram.js +24 -28
- package/src/renderers/webgl/WebGLPrograms.js +5 -2
- package/src/renderers/webgl/WebGLState.js +37 -1
- package/src/renderers/webgl/WebGLTextures.js +29 -12
- package/src/renderers/webgl-fallback/WebGLBackend.js +111 -37
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +2 -7
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +43 -12
- package/src/renderers/webgl-fallback/utils/WebGLState.js +26 -1
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +37 -9
- package/src/renderers/webgpu/WebGPUBackend.js +152 -56
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +1 -1
- package/src/renderers/webgpu/WebGPURenderer.js +1 -1
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +0 -8
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +13 -34
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +192 -92
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +12 -4
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +15 -2
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +72 -7
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +29 -9
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +29 -7
- package/src/renderers/webgpu/utils/WebGPUUtils.js +0 -1
- package/src/renderers/webxr/WebXRManager.js +4 -4
- package/src/textures/Source.js +2 -2
- package/src/textures/Texture.js +2 -2
- package/examples/jsm/cameras/CinematicCamera.js +0 -208
- package/src/nodes/display/BlendMode.js +0 -54
- package/src/nodes/display/FXAANode.js +0 -332
- package/src/nodes/utils/OscNode.js +0 -85
- package/src/nodes/utils/TimerNode.js +0 -97
- /package/examples/jsm/utils/{TextureUtils.js → WebGLTextureUtils.js} +0 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { abs, cross, float, Fn, normalize, ivec2, sub, vec2, vec3, vec4 } from '../tsl/TSLBase.js';
|
|
2
|
+
import { textureSize } from '../accessors/TextureSizeNode.js';
|
|
3
|
+
import { textureLoad } from '../accessors/TextureNode.js';
|
|
4
|
+
import { WebGPUCoordinateSystem } from '../../constants.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Computes a position in view space based on a fragment's screen position expressed as uv coordinates, the fragments
|
|
8
|
+
* depth value and the camera's inverse projection matrix.
|
|
9
|
+
*
|
|
10
|
+
* @param {vec2} screenPosition - The fragment's screen position expressed as uv coordinates.
|
|
11
|
+
* @param {float} depth - The fragment's depth value.
|
|
12
|
+
* @param {mat4} projectionMatrixInverse - The camera's inverse projection matrix.
|
|
13
|
+
* @return {vec3} The fragments position in view space.
|
|
14
|
+
*/
|
|
15
|
+
export const getViewPosition = /*@__PURE__*/ Fn( ( [ screenPosition, depth, projectionMatrixInverse ], builder ) => {
|
|
16
|
+
|
|
17
|
+
let clipSpacePosition;
|
|
18
|
+
|
|
19
|
+
if ( builder.renderer.coordinateSystem === WebGPUCoordinateSystem ) {
|
|
20
|
+
|
|
21
|
+
screenPosition = vec2( screenPosition.x, screenPosition.y.oneMinus() ).mul( 2.0 ).sub( 1.0 );
|
|
22
|
+
clipSpacePosition = vec4( vec3( screenPosition, depth ), 1.0 );
|
|
23
|
+
|
|
24
|
+
} else {
|
|
25
|
+
|
|
26
|
+
clipSpacePosition = vec4( vec3( screenPosition.x, screenPosition.y.oneMinus(), depth ).mul( 2.0 ).sub( 1.0 ), 1.0 );
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const viewSpacePosition = vec4( projectionMatrixInverse.mul( clipSpacePosition ) );
|
|
31
|
+
|
|
32
|
+
return viewSpacePosition.xyz.div( viewSpacePosition.w );
|
|
33
|
+
|
|
34
|
+
} );
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Computes a screen position expressed as uv coordinates based on a fragment's position in view space
|
|
38
|
+
* and the camera's projection matrix
|
|
39
|
+
*
|
|
40
|
+
* @param {vec3} viewPosition - The fragments position in view space.
|
|
41
|
+
* @param {mat4} projectionMatrix - The camera's projection matrix.
|
|
42
|
+
* @return {vec2} The fragment's screen position expressed as uv coordinates.
|
|
43
|
+
*/
|
|
44
|
+
export const getScreenPosition = /*@__PURE__*/ Fn( ( [ viewPosition, projectionMatrix ] ) => {
|
|
45
|
+
|
|
46
|
+
const sampleClipPos = projectionMatrix.mul( vec4( viewPosition, 1.0 ) );
|
|
47
|
+
const sampleUv = sampleClipPos.xy.div( sampleClipPos.w ).mul( 0.5 ).add( 0.5 ).toVar();
|
|
48
|
+
return vec2( sampleUv.x, sampleUv.y.oneMinus() );
|
|
49
|
+
|
|
50
|
+
} );
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Computes a normal vector based on depth data. Can be used as a fallback when no normal render
|
|
54
|
+
* target is available or if flat surface normals are required.
|
|
55
|
+
*
|
|
56
|
+
* @param {vec2} uv - The texture coordinate.
|
|
57
|
+
* @param {DepthTexture} depthTexture - The depth texture.
|
|
58
|
+
* @param {mat4} projectionMatrixInverse - The camera's inverse projection matrix.
|
|
59
|
+
* @return {vec3} The computed normal vector.
|
|
60
|
+
*/
|
|
61
|
+
export const getNormalFromDepth = /*@__PURE__*/ Fn( ( [ uv, depthTexture, projectionMatrixInverse ] ) => {
|
|
62
|
+
|
|
63
|
+
const size = textureSize( textureLoad( depthTexture ) );
|
|
64
|
+
const p = ivec2( uv.mul( size ) ).toVar();
|
|
65
|
+
|
|
66
|
+
const c0 = textureLoad( depthTexture, p ).toVar();
|
|
67
|
+
|
|
68
|
+
const l2 = textureLoad( depthTexture, p.sub( ivec2( 2, 0 ) ) ).toVar();
|
|
69
|
+
const l1 = textureLoad( depthTexture, p.sub( ivec2( 1, 0 ) ) ).toVar();
|
|
70
|
+
const r1 = textureLoad( depthTexture, p.add( ivec2( 1, 0 ) ) ).toVar();
|
|
71
|
+
const r2 = textureLoad( depthTexture, p.add( ivec2( 2, 0 ) ) ).toVar();
|
|
72
|
+
const b2 = textureLoad( depthTexture, p.add( ivec2( 0, 2 ) ) ).toVar();
|
|
73
|
+
const b1 = textureLoad( depthTexture, p.add( ivec2( 0, 1 ) ) ).toVar();
|
|
74
|
+
const t1 = textureLoad( depthTexture, p.sub( ivec2( 0, 1 ) ) ).toVar();
|
|
75
|
+
const t2 = textureLoad( depthTexture, p.sub( ivec2( 0, 2 ) ) ).toVar();
|
|
76
|
+
|
|
77
|
+
const dl = abs( sub( float( 2 ).mul( l1 ).sub( l2 ), c0 ) ).toVar();
|
|
78
|
+
const dr = abs( sub( float( 2 ).mul( r1 ).sub( r2 ), c0 ) ).toVar();
|
|
79
|
+
const db = abs( sub( float( 2 ).mul( b1 ).sub( b2 ), c0 ) ).toVar();
|
|
80
|
+
const dt = abs( sub( float( 2 ).mul( t1 ).sub( t2 ), c0 ) ).toVar();
|
|
81
|
+
|
|
82
|
+
const ce = getViewPosition( uv, c0, projectionMatrixInverse ).toVar();
|
|
83
|
+
|
|
84
|
+
const dpdx = dl.lessThan( dr ).select( ce.sub( getViewPosition( uv.sub( vec2( float( 1 ).div( size.x ), 0 ) ), l1, projectionMatrixInverse ) ), ce.negate().add( getViewPosition( uv.add( vec2( float( 1 ).div( size.x ), 0 ) ), r1, projectionMatrixInverse ) ) );
|
|
85
|
+
const dpdy = db.lessThan( dt ).select( ce.sub( getViewPosition( uv.add( vec2( 0, float( 1 ).div( size.y ) ) ), b1, projectionMatrixInverse ) ), ce.negate().add( getViewPosition( uv.sub( vec2( 0, float( 1 ).div( size.y ) ) ), t1, projectionMatrixInverse ) ) );
|
|
86
|
+
|
|
87
|
+
return normalize( cross( dpdx, dpdy ) );
|
|
88
|
+
|
|
89
|
+
} );
|
|
@@ -130,4 +130,12 @@ class RTTNode extends TextureNode {
|
|
|
130
130
|
export default RTTNode;
|
|
131
131
|
|
|
132
132
|
export const rtt = ( node, ...params ) => nodeObject( new RTTNode( nodeObject( node ), ...params ) );
|
|
133
|
-
|
|
133
|
+
|
|
134
|
+
export const convertToTexture = ( node, ...params ) => {
|
|
135
|
+
|
|
136
|
+
if ( node.isTextureNode ) return node;
|
|
137
|
+
if ( node.isPassNode ) return node.getTextureNode();
|
|
138
|
+
|
|
139
|
+
return rtt( node, ...params );
|
|
140
|
+
|
|
141
|
+
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import Node from '../core/Node.js';
|
|
1
2
|
import TextureNode from '../accessors/TextureNode.js';
|
|
2
3
|
import { nodeObject } from '../tsl/TSLBase.js';
|
|
3
4
|
import { NodeUpdateType } from '../core/constants.js';
|
|
4
5
|
import { screenUV } from '../display/ScreenNode.js';
|
|
5
6
|
|
|
6
|
-
import { HalfFloatType, LinearMipMapLinearFilter } from '../../constants.js';
|
|
7
|
+
import { HalfFloatType, LinearMipMapLinearFilter, WebGPUCoordinateSystem } from '../../constants.js';
|
|
7
8
|
import { Plane } from '../../math/Plane.js';
|
|
8
9
|
import { Object3D } from '../../core/Object3D.js';
|
|
9
10
|
import { Vector2 } from '../../math/Vector2.js';
|
|
@@ -11,6 +12,7 @@ import { Vector3 } from '../../math/Vector3.js';
|
|
|
11
12
|
import { Vector4 } from '../../math/Vector4.js';
|
|
12
13
|
import { Matrix4 } from '../../math/Matrix4.js';
|
|
13
14
|
import { RenderTarget } from '../../core/RenderTarget.js';
|
|
15
|
+
import { DepthTexture } from '../../textures/DepthTexture.js';
|
|
14
16
|
|
|
15
17
|
const _reflectorPlane = new Plane();
|
|
16
18
|
const _normal = new Vector3();
|
|
@@ -29,6 +31,8 @@ const _size = new Vector2();
|
|
|
29
31
|
const _defaultRT = new RenderTarget();
|
|
30
32
|
const _defaultUV = screenUV.flipX();
|
|
31
33
|
|
|
34
|
+
_defaultRT.depthTexture = new DepthTexture( 1, 1 );
|
|
35
|
+
|
|
32
36
|
let _inReflector = false;
|
|
33
37
|
|
|
34
38
|
class ReflectorNode extends TextureNode {
|
|
@@ -41,28 +45,104 @@ class ReflectorNode extends TextureNode {
|
|
|
41
45
|
|
|
42
46
|
constructor( parameters = {} ) {
|
|
43
47
|
|
|
44
|
-
super( _defaultRT.texture, _defaultUV );
|
|
48
|
+
super( parameters.defaultTexture || _defaultRT.texture, _defaultUV );
|
|
49
|
+
|
|
50
|
+
this._reflectorBaseNode = parameters.reflector || new ReflectorBaseNode( this, parameters );
|
|
51
|
+
this._depthNode = null;
|
|
52
|
+
|
|
53
|
+
this.setUpdateMatrix( false );
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
get reflector() {
|
|
58
|
+
|
|
59
|
+
return this._reflectorBaseNode;
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
get target() {
|
|
64
|
+
|
|
65
|
+
return this._reflectorBaseNode.target;
|
|
66
|
+
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
getDepthNode() {
|
|
70
|
+
|
|
71
|
+
if ( this._depthNode === null ) {
|
|
72
|
+
|
|
73
|
+
if ( this._reflectorBaseNode.depth !== true ) {
|
|
74
|
+
|
|
75
|
+
throw new Error( 'THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ' );
|
|
76
|
+
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
this._depthNode = nodeObject( new ReflectorNode( {
|
|
80
|
+
defaultTexture: _defaultRT.depthTexture,
|
|
81
|
+
reflector: this._reflectorBaseNode
|
|
82
|
+
} ) );
|
|
83
|
+
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return this._depthNode;
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
setup( builder ) {
|
|
91
|
+
|
|
92
|
+
// ignore if used in post-processing
|
|
93
|
+
if ( ! builder.object.isQuadMesh ) this._reflectorBaseNode.build( builder );
|
|
94
|
+
|
|
95
|
+
return super.setup( builder );
|
|
96
|
+
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
clone() {
|
|
100
|
+
|
|
101
|
+
const texture = new this.constructor( this.reflectorNode );
|
|
102
|
+
texture._reflectorBaseNode = this._reflectorBaseNode;
|
|
103
|
+
|
|
104
|
+
return texture;
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
class ReflectorBaseNode extends Node {
|
|
112
|
+
|
|
113
|
+
static get type() {
|
|
114
|
+
|
|
115
|
+
return 'ReflectorBaseNode';
|
|
116
|
+
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
constructor( textureNode, parameters = {} ) {
|
|
120
|
+
|
|
121
|
+
super();
|
|
45
122
|
|
|
46
123
|
const {
|
|
47
124
|
target = new Object3D(),
|
|
48
125
|
resolution = 1,
|
|
49
126
|
generateMipmaps = false,
|
|
50
|
-
bounces = true
|
|
127
|
+
bounces = true,
|
|
128
|
+
depth = false
|
|
51
129
|
} = parameters;
|
|
52
130
|
|
|
53
131
|
//
|
|
54
132
|
|
|
133
|
+
this.textureNode = textureNode;
|
|
134
|
+
|
|
55
135
|
this.target = target;
|
|
56
136
|
this.resolution = resolution;
|
|
57
137
|
this.generateMipmaps = generateMipmaps;
|
|
58
138
|
this.bounces = bounces;
|
|
139
|
+
this.depth = depth;
|
|
59
140
|
|
|
60
141
|
this.updateBeforeType = bounces ? NodeUpdateType.RENDER : NodeUpdateType.FRAME;
|
|
61
142
|
|
|
62
143
|
this.virtualCameras = new WeakMap();
|
|
63
144
|
this.renderTargets = new WeakMap();
|
|
64
145
|
|
|
65
|
-
|
|
66
146
|
}
|
|
67
147
|
|
|
68
148
|
_updateResolution( renderTarget, renderer ) {
|
|
@@ -83,12 +163,6 @@ class ReflectorNode extends TextureNode {
|
|
|
83
163
|
|
|
84
164
|
}
|
|
85
165
|
|
|
86
|
-
getTextureNode() {
|
|
87
|
-
|
|
88
|
-
return this.textureNode;
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
92
166
|
getVirtualCamera( camera ) {
|
|
93
167
|
|
|
94
168
|
let virtualCamera = this.virtualCameras.get( camera );
|
|
@@ -115,8 +189,14 @@ class ReflectorNode extends TextureNode {
|
|
|
115
189
|
|
|
116
190
|
if ( this.generateMipmaps === true ) {
|
|
117
191
|
|
|
118
|
-
|
|
119
|
-
|
|
192
|
+
renderTarget.texture.minFilter = LinearMipMapLinearFilter;
|
|
193
|
+
renderTarget.texture.generateMipmaps = true;
|
|
194
|
+
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if ( this.depth === true ) {
|
|
198
|
+
|
|
199
|
+
renderTarget.depthTexture = new DepthTexture();
|
|
120
200
|
|
|
121
201
|
}
|
|
122
202
|
|
|
@@ -130,7 +210,7 @@ class ReflectorNode extends TextureNode {
|
|
|
130
210
|
|
|
131
211
|
updateBefore( frame ) {
|
|
132
212
|
|
|
133
|
-
if ( this.bounces === false && _inReflector ) return
|
|
213
|
+
if ( this.bounces === false && _inReflector ) return;
|
|
134
214
|
|
|
135
215
|
_inReflector = true;
|
|
136
216
|
|
|
@@ -210,12 +290,18 @@ class ReflectorNode extends TextureNode {
|
|
|
210
290
|
// Replacing the third row of the projection matrix
|
|
211
291
|
projectionMatrix.elements[ 2 ] = clipPlane.x;
|
|
212
292
|
projectionMatrix.elements[ 6 ] = clipPlane.y;
|
|
213
|
-
projectionMatrix.elements[ 10 ] = clipPlane.z - clipBias;
|
|
293
|
+
projectionMatrix.elements[ 10 ] = ( renderer.coordinateSystem === WebGPUCoordinateSystem ) ? ( clipPlane.z - clipBias ) : ( clipPlane.z + 1.0 - clipBias );
|
|
214
294
|
projectionMatrix.elements[ 14 ] = clipPlane.w;
|
|
215
295
|
|
|
216
296
|
//
|
|
217
297
|
|
|
218
|
-
this.value = renderTarget.texture;
|
|
298
|
+
this.textureNode.value = renderTarget.texture;
|
|
299
|
+
|
|
300
|
+
if ( this.depth === true ) {
|
|
301
|
+
|
|
302
|
+
this.textureNode.getDepthNode().value = renderTarget.depthTexture;
|
|
303
|
+
|
|
304
|
+
}
|
|
219
305
|
|
|
220
306
|
material.visible = false;
|
|
221
307
|
|
|
@@ -33,7 +33,7 @@ class StorageArrayElementNode extends ArrayElementNode {
|
|
|
33
33
|
|
|
34
34
|
if ( builder.isAvailable( 'storageBuffer' ) === false ) {
|
|
35
35
|
|
|
36
|
-
if ( this.node.
|
|
36
|
+
if ( this.node.isPBO === true ) {
|
|
37
37
|
|
|
38
38
|
builder.setupPBO( this.node );
|
|
39
39
|
|
|
@@ -55,7 +55,7 @@ class StorageArrayElementNode extends ArrayElementNode {
|
|
|
55
55
|
|
|
56
56
|
if ( builder.isAvailable( 'storageBuffer' ) === false ) {
|
|
57
57
|
|
|
58
|
-
if ( this.node.
|
|
58
|
+
if ( this.node.isPBO === true && isAssignContext !== true && ( this.node.value.isInstancedBufferAttribute || builder.shaderStage !== 'compute' ) ) {
|
|
59
59
|
|
|
60
60
|
snippet = builder.generatePBO( this );
|
|
61
61
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { renderGroup } from '../core/UniformGroupNode.js';
|
|
2
|
+
import { uniform } from '../core/UniformNode.js';
|
|
3
|
+
|
|
4
|
+
export const time = /*@__PURE__*/ uniform( 0 ).setGroup( renderGroup ).onRenderUpdate( ( frame ) => frame.time );
|
|
5
|
+
export const deltaTime = /*@__PURE__*/ uniform( 0 ).setGroup( renderGroup ).onRenderUpdate( ( frame ) => frame.deltaTime );
|
|
6
|
+
export const frameId = /*@__PURE__*/ uniform( 0, 'uint' ).setGroup( renderGroup ).onRenderUpdate( ( frame ) => frame.frameId );
|
|
7
|
+
|
|
8
|
+
// Deprecated
|
|
9
|
+
|
|
10
|
+
export const timerLocal = ( timeScale = 1 ) => { // @deprecated, r170
|
|
11
|
+
|
|
12
|
+
console.warn( 'TSL: timerLocal() is deprecated. Use "time" instead.' );
|
|
13
|
+
return time.mul( timeScale );
|
|
14
|
+
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const timerGlobal = ( timeScale = 1 ) => { // @deprecated, r170
|
|
18
|
+
|
|
19
|
+
console.warn( 'TSL: timerGlobal() is deprecated. Use "time" instead.' );
|
|
20
|
+
return time.mul( timeScale );
|
|
21
|
+
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const timerDelta = ( timeScale = 1 ) => { // @deprecated, r170
|
|
25
|
+
|
|
26
|
+
console.warn( 'TSL: timerDelta() is deprecated. Use "deltaTime" instead.' );
|
|
27
|
+
return deltaTime.mul( timeScale );
|
|
28
|
+
|
|
29
|
+
};
|