@plastic-software/three 0.180.0 → 0.181.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 +943 -486
- package/build/three.core.js +506 -327
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +435 -163
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +8 -2
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +3753 -1177
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +3752 -1176
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/fonts/MPLUSRounded1c/MPLUSRounded1c-Regular.typeface.json.zip +0 -0
- package/examples/fonts/MPLUSRounded1c/OFL.txt +91 -0
- package/examples/jsm/animation/CCDIKSolver.js +1 -1
- package/examples/jsm/controls/ArcballControls.js +1 -1
- package/examples/jsm/controls/DragControls.js +1 -1
- package/examples/jsm/controls/FirstPersonControls.js +1 -1
- package/examples/jsm/controls/FlyControls.js +1 -1
- package/examples/jsm/controls/OrbitControls.js +2 -2
- package/examples/jsm/controls/PointerLockControls.js +2 -2
- package/examples/jsm/controls/TrackballControls.js +1 -1
- package/examples/jsm/controls/TransformControls.js +1 -1
- package/examples/jsm/effects/AsciiEffect.js +8 -8
- package/examples/jsm/exporters/DRACOExporter.js +2 -2
- package/examples/jsm/exporters/EXRExporter.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +3 -3
- package/examples/jsm/exporters/USDZExporter.js +9 -2
- package/examples/jsm/geometries/DecalGeometry.js +2 -2
- package/examples/jsm/geometries/ParametricGeometry.js +1 -1
- package/examples/jsm/geometries/TeapotGeometry.js +2 -2
- package/examples/jsm/geometries/TextGeometry.js +3 -2
- package/examples/jsm/gpgpu/BitonicSort.js +715 -0
- package/examples/jsm/helpers/ViewHelper.js +43 -5
- package/examples/jsm/inspector/Inspector.js +427 -0
- package/examples/jsm/inspector/RendererInspector.js +415 -0
- package/examples/jsm/inspector/tabs/Console.js +204 -0
- package/examples/jsm/inspector/tabs/Parameters.js +332 -0
- package/examples/jsm/inspector/tabs/Performance.js +268 -0
- package/examples/jsm/inspector/tabs/Viewer.js +166 -0
- package/examples/jsm/inspector/ui/Graph.js +95 -0
- package/examples/jsm/inspector/ui/Item.js +170 -0
- package/examples/jsm/inspector/ui/List.js +75 -0
- package/examples/jsm/inspector/ui/Profiler.js +170 -0
- package/examples/jsm/inspector/ui/Style.js +654 -0
- package/examples/jsm/inspector/ui/Tab.js +46 -0
- package/examples/jsm/inspector/ui/Values.js +423 -0
- package/examples/jsm/inspector/ui/utils.js +56 -0
- package/examples/jsm/interactive/HTMLMesh.js +6 -10
- package/examples/jsm/interactive/InteractiveGroup.js +1 -1
- package/examples/jsm/interactive/SelectionBox.js +30 -0
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +1 -1
- package/examples/jsm/loaders/3MFLoader.js +1 -1
- package/examples/jsm/loaders/ColladaLoader.js +2 -2
- package/examples/jsm/loaders/DDSLoader.js +1 -1
- package/examples/jsm/loaders/DRACOLoader.js +73 -22
- package/examples/jsm/loaders/FBXLoader.js +2 -2
- package/examples/jsm/loaders/FontLoader.js +23 -5
- package/examples/jsm/loaders/GLTFLoader.js +5 -3
- package/examples/jsm/loaders/KTX2Loader.js +28 -21
- package/examples/jsm/loaders/KTXLoader.js +2 -2
- package/examples/jsm/loaders/LDrawLoader.js +1 -1
- package/examples/jsm/loaders/LUT3dlLoader.js +2 -2
- package/examples/jsm/loaders/LUTCubeLoader.js +1 -1
- package/examples/jsm/loaders/LWOLoader.js +2 -2
- package/examples/jsm/loaders/MaterialXLoader.js +22 -5
- package/examples/jsm/loaders/OBJLoader.js +1 -1
- package/examples/jsm/loaders/PDBLoader.js +1 -1
- package/examples/jsm/loaders/SVGLoader.js +2 -2
- package/examples/jsm/loaders/UltraHDRLoader.js +1 -1
- package/examples/jsm/math/ConvexHull.js +1 -1
- package/examples/jsm/math/ImprovedNoise.js +1 -1
- package/examples/jsm/math/SimplexNoise.js +1 -1
- package/examples/jsm/misc/ProgressiveLightMap.js +9 -3
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +7 -1
- package/examples/jsm/misc/TubePainter.js +383 -40
- package/examples/jsm/modifiers/SimplifyModifier.js +1 -1
- package/examples/jsm/objects/ReflectorForSSRPass.js +1 -0
- package/examples/jsm/objects/Sky.js +1 -1
- package/examples/jsm/objects/SkyMesh.js +1 -1
- package/examples/jsm/objects/Water.js +3 -3
- package/examples/jsm/objects/WaterMesh.js +6 -6
- package/examples/jsm/postprocessing/GlitchPass.js +2 -2
- package/examples/jsm/postprocessing/UnrealBloomPass.js +8 -6
- package/examples/jsm/renderers/CSS2DRenderer.js +16 -5
- package/examples/jsm/renderers/CSS3DRenderer.js +7 -6
- package/examples/jsm/renderers/SVGRenderer.js +1 -1
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +1 -1
- package/examples/jsm/shaders/AfterimageShader.js +1 -1
- package/examples/jsm/shaders/BleachBypassShader.js +1 -1
- package/examples/jsm/shaders/BokehShader.js +1 -1
- package/examples/jsm/shaders/BokehShader2.js +1 -1
- package/examples/jsm/shaders/DotScreenShader.js +1 -1
- package/examples/jsm/shaders/FocusShader.js +1 -1
- package/examples/jsm/shaders/GTAOShader.js +2 -2
- package/examples/jsm/shaders/GodRaysShader.js +1 -1
- package/examples/jsm/shaders/KaleidoShader.js +1 -1
- package/examples/jsm/shaders/PoissonDenoiseShader.js +2 -2
- package/examples/jsm/shaders/SSRShader.js +1 -1
- package/examples/jsm/shaders/SepiaShader.js +1 -1
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +1 -1
- package/examples/jsm/shaders/TriangleBlurShader.js +1 -1
- package/examples/jsm/shaders/VignetteShader.js +1 -1
- package/examples/jsm/transpiler/TSLEncoder.js +7 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +26 -24
- package/examples/jsm/tsl/display/AnamorphicNode.js +2 -1
- package/examples/jsm/tsl/display/BloomNode.js +4 -0
- package/examples/jsm/tsl/display/DenoiseNode.js +2 -0
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +7 -0
- package/examples/jsm/tsl/display/GTAONode.js +45 -5
- package/examples/jsm/tsl/display/GaussianBlurNode.js +5 -3
- package/examples/jsm/tsl/display/OutlineNode.js +11 -0
- package/examples/jsm/tsl/display/SSGINode.js +654 -0
- package/examples/jsm/tsl/display/SSRNode.js +2 -0
- package/examples/jsm/tsl/display/SSSNode.js +488 -0
- package/examples/jsm/tsl/display/TRAANode.js +123 -6
- package/examples/jsm/tsl/display/boxBlur.js +1 -0
- package/examples/jsm/tsl/display/hashBlur.js +1 -0
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +21 -1
- package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
- package/examples/jsm/webxr/XRHandModelFactory.js +2 -6
- package/package.json +5 -10
- package/src/Three.Core.js +3 -2
- package/src/Three.TSL.js +7 -1
- package/src/Three.WebGPU.Nodes.js +2 -0
- package/src/Three.WebGPU.js +2 -0
- package/src/animation/AnimationClip.js +3 -2
- package/src/animation/AnimationMixer.js +3 -3
- package/src/animation/AnimationObjectGroup.js +2 -1
- package/src/animation/KeyframeTrack.js +7 -6
- package/src/animation/PropertyBinding.js +12 -11
- package/src/audio/Audio.js +10 -9
- package/src/audio/PositionalAudio.js +1 -1
- package/src/cameras/OrthographicCamera.js +1 -1
- package/src/cameras/PerspectiveCamera.js +1 -1
- package/src/cameras/StereoCamera.js +2 -2
- package/src/constants.js +1 -1
- package/src/core/BufferGeometry.js +8 -8
- package/src/core/EventDispatcher.js +1 -1
- package/src/core/InterleavedBuffer.js +1 -1
- package/src/core/InterleavedBufferAttribute.js +3 -2
- package/src/core/Object3D.js +3 -2
- package/src/core/Raycaster.js +2 -1
- package/src/core/RenderTarget.js +10 -1
- package/src/extras/Controls.js +5 -4
- package/src/extras/DataUtils.js +2 -1
- package/src/extras/Earcut.js +6 -0
- package/src/extras/ImageUtils.js +2 -2
- package/src/extras/PMREMGenerator.js +268 -55
- package/src/extras/core/Curve.js +2 -1
- package/src/extras/core/Interpolations.js +7 -1
- package/src/extras/core/ShapePath.js +4 -4
- package/src/extras/lib/earcut.js +7 -7
- package/src/geometries/BoxGeometry.js +1 -0
- package/src/geometries/CapsuleGeometry.js +1 -0
- package/src/geometries/CircleGeometry.js +1 -0
- package/src/geometries/ConeGeometry.js +1 -0
- package/src/geometries/CylinderGeometry.js +1 -0
- package/src/geometries/DodecahedronGeometry.js +1 -0
- package/src/geometries/ExtrudeGeometry.js +8 -6
- package/src/geometries/IcosahedronGeometry.js +1 -0
- package/src/geometries/LatheGeometry.js +1 -0
- package/src/geometries/OctahedronGeometry.js +1 -0
- package/src/geometries/PlaneGeometry.js +1 -0
- package/src/geometries/RingGeometry.js +1 -0
- package/src/geometries/ShapeGeometry.js +1 -0
- package/src/geometries/SphereGeometry.js +1 -0
- package/src/geometries/TetrahedronGeometry.js +1 -0
- package/src/geometries/TorusGeometry.js +1 -0
- package/src/geometries/TorusKnotGeometry.js +1 -0
- package/src/geometries/TubeGeometry.js +1 -0
- package/src/helpers/CameraHelper.js +1 -1
- package/src/loaders/AnimationLoader.js +2 -1
- package/src/loaders/AudioLoader.js +2 -1
- package/src/loaders/BufferGeometryLoader.js +2 -2
- package/src/loaders/Cache.js +2 -2
- package/src/loaders/DataTextureLoader.js +1 -1
- package/src/loaders/FileLoader.js +3 -2
- package/src/loaders/ImageBitmapLoader.js +5 -4
- package/src/loaders/ImageLoader.js +1 -1
- package/src/loaders/Loader.js +3 -3
- package/src/loaders/LoadingManager.js +25 -3
- package/src/loaders/MaterialLoader.js +3 -2
- package/src/loaders/ObjectLoader.js +13 -13
- package/src/loaders/TextureLoader.js +1 -1
- package/src/loaders/nodes/NodeLoader.js +3 -2
- package/src/materials/Material.js +4 -3
- package/src/materials/MeshBasicMaterial.js +1 -0
- package/src/materials/MeshDepthMaterial.js +1 -0
- package/src/materials/MeshLambertMaterial.js +2 -1
- package/src/materials/MeshMatcapMaterial.js +22 -0
- package/src/materials/MeshNormalMaterial.js +1 -0
- package/src/materials/MeshPhongMaterial.js +2 -1
- package/src/materials/MeshPhysicalMaterial.js +2 -1
- package/src/materials/MeshStandardMaterial.js +8 -7
- package/src/materials/MeshToonMaterial.js +1 -0
- package/src/materials/PointsMaterial.js +1 -1
- package/src/materials/ShaderMaterial.js +2 -2
- package/src/materials/nodes/Line2NodeMaterial.js +2 -2
- package/src/materials/nodes/MeshSSSNodeMaterial.js +1 -1
- package/src/materials/nodes/NodeMaterial.js +62 -22
- package/src/materials/nodes/manager/NodeMaterialObserver.js +2 -1
- package/src/math/Color.js +6 -5
- package/src/math/ColorManagement.js +2 -2
- package/src/math/Cylindrical.js +1 -1
- package/src/math/Euler.js +2 -1
- package/src/math/MathUtils.js +13 -11
- package/src/math/Matrix2.js +1 -1
- package/src/math/Matrix3.js +2 -2
- package/src/math/Matrix4.js +7 -7
- package/src/math/Plane.js +1 -1
- package/src/math/Quaternion.js +68 -66
- package/src/math/Spherical.js +1 -1
- package/src/nodes/Nodes.js +1 -1
- package/src/nodes/TSL.js +1 -1
- package/src/nodes/accessors/CubeTextureNode.js +3 -2
- package/src/nodes/accessors/InstanceNode.js +22 -4
- package/src/nodes/accessors/Lights.js +10 -0
- package/src/nodes/accessors/Normal.js +5 -4
- package/src/nodes/accessors/Position.js +18 -2
- package/src/nodes/accessors/ReferenceNode.js +2 -1
- package/src/nodes/accessors/SceneNode.js +2 -1
- package/src/nodes/accessors/StorageBufferNode.js +2 -1
- package/src/nodes/accessors/StorageTextureNode.js +22 -0
- package/src/nodes/accessors/Texture3DNode.js +1 -1
- package/src/nodes/accessors/TextureNode.js +61 -27
- package/src/nodes/code/FunctionCallNode.js +5 -4
- package/src/nodes/core/ArrayNode.js +1 -0
- package/src/nodes/core/AttributeNode.js +2 -1
- package/src/nodes/core/ContextNode.js +5 -10
- package/src/nodes/core/IndexNode.js +2 -2
- package/src/nodes/core/InputNode.js +2 -1
- package/src/nodes/core/InspectorNode.js +128 -0
- package/src/nodes/core/{CacheNode.js → IsolateNode.js} +40 -7
- package/src/nodes/core/Node.js +137 -12
- package/src/nodes/core/NodeBuilder.js +135 -21
- package/src/nodes/core/NodeFrame.js +20 -20
- package/src/nodes/core/NodeFunction.js +2 -1
- package/src/nodes/core/NodeParser.js +2 -1
- package/src/nodes/core/NodeUtils.js +17 -90
- package/src/nodes/core/ParameterNode.js +31 -0
- package/src/nodes/core/PropertyNode.js +7 -0
- package/src/nodes/core/StackNode.js +16 -14
- package/src/nodes/core/UniformNode.js +2 -1
- package/src/nodes/core/VarNode.js +70 -12
- package/src/nodes/core/VaryingNode.js +3 -2
- package/src/nodes/display/BlendModes.js +5 -4
- package/src/nodes/display/BumpMapNode.js +1 -1
- package/src/nodes/display/ColorAdjustment.js +1 -1
- package/src/nodes/display/NormalMapNode.js +2 -1
- package/src/nodes/display/PassNode.js +51 -10
- package/src/nodes/display/RenderOutputNode.js +28 -2
- package/src/nodes/display/ScreenNode.js +2 -1
- package/src/nodes/display/ToneMappingNode.js +31 -4
- package/src/nodes/display/ToonOutlinePassNode.js +8 -0
- package/src/nodes/fog/Fog.js +3 -2
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +52 -0
- package/src/nodes/functions/BSDF/DFGApprox.js +60 -19
- package/src/nodes/functions/BasicLightingModel.js +2 -1
- package/src/nodes/functions/PhysicalLightingModel.js +3 -2
- package/src/nodes/functions/VolumetricLightingModel.js +5 -5
- package/src/nodes/geometry/RangeNode.js +40 -4
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +2 -1
- package/src/nodes/gpgpu/ComputeNode.js +17 -5
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +25 -0
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +2 -1
- package/src/nodes/lighting/EnvironmentNode.js +6 -6
- package/src/nodes/lighting/LightsNode.js +2 -3
- package/src/nodes/lighting/PointShadowNode.js +6 -0
- package/src/nodes/lighting/ShadowFilterNode.js +2 -0
- package/src/nodes/lighting/ShadowNode.js +75 -8
- package/src/nodes/math/ConditionalNode.js +6 -5
- package/src/nodes/math/MathNode.js +22 -4
- package/src/nodes/math/OperatorNode.js +3 -2
- package/src/nodes/pmrem/PMREMUtils.js +117 -2
- package/src/nodes/shapes/Shapes.js +1 -1
- package/src/nodes/tsl/TSLBase.js +5 -2
- package/src/nodes/tsl/TSLCore.js +36 -15
- package/src/nodes/utils/DebugNode.js +2 -1
- package/src/nodes/utils/EventNode.js +36 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +37 -19
- package/src/nodes/utils/JoinNode.js +3 -2
- package/src/nodes/utils/LoopNode.js +20 -24
- package/src/nodes/utils/MemberNode.js +2 -1
- package/src/nodes/utils/PostProcessingUtils.js +28 -1
- package/src/nodes/utils/RTTNode.js +12 -2
- package/src/nodes/utils/ReflectorNode.js +10 -3
- package/src/objects/Line.js +2 -1
- package/src/objects/LineSegments.js +2 -1
- package/src/objects/Skeleton.js +3 -2
- package/src/objects/SkinnedMesh.js +3 -1
- package/src/objects/Sprite.js +2 -1
- package/src/renderers/WebGLRenderer.js +48 -32
- package/src/renderers/common/Animation.js +13 -1
- package/src/renderers/common/Backend.js +93 -30
- package/src/renderers/common/Background.js +2 -1
- package/src/renderers/common/Bindings.js +56 -2
- package/src/renderers/common/CanvasTarget.js +341 -0
- package/src/renderers/common/Geometries.js +26 -0
- package/src/renderers/common/Info.js +4 -2
- package/src/renderers/common/InspectorBase.js +146 -0
- package/src/renderers/common/PostProcessing.js +6 -25
- package/src/renderers/common/QuadMesh.js +7 -1
- package/src/renderers/common/RenderList.js +7 -3
- package/src/renderers/common/RenderObject.js +3 -1
- package/src/renderers/common/RenderObjects.js +1 -1
- package/src/renderers/common/Renderer.js +436 -228
- package/src/renderers/common/RendererUtils.js +9 -0
- package/src/renderers/common/SampledTexture.js +8 -0
- package/src/renderers/common/Sampler.js +37 -11
- package/src/renderers/common/StorageTexture.js +9 -1
- package/src/renderers/common/Textures.js +89 -35
- package/src/renderers/common/TimestampQueryPool.js +63 -1
- package/src/renderers/common/UniformsGroup.js +2 -1
- package/src/renderers/common/XRManager.js +7 -3
- package/src/renderers/common/extras/PMREMGenerator.js +160 -65
- package/src/renderers/common/nodes/NodeLibrary.js +4 -2
- package/src/renderers/common/nodes/NodeSampler.js +13 -1
- package/src/renderers/common/nodes/Nodes.js +38 -16
- package/src/renderers/shaders/DFGLUTData.js +64 -0
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -12
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +52 -18
- package/src/renderers/shaders/UniformsLib.js +1 -0
- package/src/renderers/shaders/UniformsUtils.js +25 -4
- package/src/renderers/webgl/WebGLCapabilities.js +2 -1
- package/src/renderers/webgl/WebGLExtensions.js +2 -25
- package/src/renderers/webgl/WebGLInfo.js +3 -1
- package/src/renderers/webgl/WebGLProgram.js +11 -10
- package/src/renderers/webgl/WebGLPrograms.js +2 -1
- package/src/renderers/webgl/WebGLShadowMap.js +2 -1
- package/src/renderers/webgl/WebGLState.js +15 -14
- package/src/renderers/webgl/WebGLTextures.js +18 -14
- package/src/renderers/webgl/WebGLUniformsGroups.js +5 -3
- package/src/renderers/webgl-fallback/WebGLBackend.js +22 -41
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +74 -11
- package/src/renderers/webgl-fallback/utils/WebGLConstants.js +2 -3
- package/src/renderers/webgl-fallback/utils/WebGLState.js +6 -5
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +117 -16
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +42 -12
- package/src/renderers/webgpu/WebGPUBackend.js +134 -108
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +2 -1
- package/src/renderers/webgpu/WebGPURenderer.js +3 -2
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +21 -19
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +2 -1
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +5 -3
- package/src/renderers/webgpu/utils/WebGPUConstants.js +5 -0
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +44 -16
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +6 -8
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +146 -74
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +29 -6
- package/src/renderers/webgpu/utils/WebGPUUtils.js +22 -2
- package/src/renderers/webxr/WebXRManager.js +3 -2
- package/src/textures/Source.js +2 -1
- package/src/textures/Texture.js +3 -2
- package/src/textures/VideoTexture.js +2 -0
- package/src/utils.js +67 -3
|
@@ -67,8 +67,11 @@ class RangeNode extends Node {
|
|
|
67
67
|
*/
|
|
68
68
|
getVectorLength( builder ) {
|
|
69
69
|
|
|
70
|
-
const
|
|
71
|
-
const
|
|
70
|
+
const minNode = this.getConstNode( this.minNode );
|
|
71
|
+
const maxNode = this.getConstNode( this.maxNode );
|
|
72
|
+
|
|
73
|
+
const minLength = builder.getTypeLength( getValueType( minNode.value ) );
|
|
74
|
+
const maxLength = builder.getTypeLength( getValueType( maxNode.value ) );
|
|
72
75
|
|
|
73
76
|
return minLength > maxLength ? minLength : maxLength;
|
|
74
77
|
|
|
@@ -86,6 +89,36 @@ class RangeNode extends Node {
|
|
|
86
89
|
|
|
87
90
|
}
|
|
88
91
|
|
|
92
|
+
/**
|
|
93
|
+
* Returns a constant node from the given node by traversing it.
|
|
94
|
+
*
|
|
95
|
+
* @param {Node} node - The node to traverse.
|
|
96
|
+
* @returns {Node} The constant node, if found.
|
|
97
|
+
*/
|
|
98
|
+
getConstNode( node ) {
|
|
99
|
+
|
|
100
|
+
let output = null;
|
|
101
|
+
|
|
102
|
+
node.traverse( n => {
|
|
103
|
+
|
|
104
|
+
if ( n.isConstNode === true ) {
|
|
105
|
+
|
|
106
|
+
output = n;
|
|
107
|
+
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
} );
|
|
111
|
+
|
|
112
|
+
if ( output === null ) {
|
|
113
|
+
|
|
114
|
+
throw new Error( 'THREE.TSL: No "ConstNode" found in node graph.' );
|
|
115
|
+
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return output;
|
|
119
|
+
|
|
120
|
+
}
|
|
121
|
+
|
|
89
122
|
setup( builder ) {
|
|
90
123
|
|
|
91
124
|
const object = builder.object;
|
|
@@ -94,8 +127,11 @@ class RangeNode extends Node {
|
|
|
94
127
|
|
|
95
128
|
if ( object.count > 1 ) {
|
|
96
129
|
|
|
97
|
-
const
|
|
98
|
-
const
|
|
130
|
+
const minNode = this.getConstNode( this.minNode );
|
|
131
|
+
const maxNode = this.getConstNode( this.maxNode );
|
|
132
|
+
|
|
133
|
+
const minValue = minNode.value;
|
|
134
|
+
const maxValue = maxNode.value;
|
|
99
135
|
|
|
100
136
|
const minLength = builder.getTypeLength( getValueType( minValue ) );
|
|
101
137
|
const maxLength = builder.getTypeLength( getValueType( maxValue ) );
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Node from '../core/Node.js';
|
|
2
2
|
import { nodeObject } from '../tsl/TSLBase.js';
|
|
3
|
+
import { warn } from '../../utils.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* `ComputeBuiltinNode` represents a compute-scope builtin value that expose information
|
|
@@ -110,7 +111,7 @@ class ComputeBuiltinNode extends Node {
|
|
|
110
111
|
|
|
111
112
|
} else {
|
|
112
113
|
|
|
113
|
-
|
|
114
|
+
warn( `ComputeBuiltinNode: Compute built-in value ${builtinName} can not be accessed in the ${builder.shaderStage} stage` );
|
|
114
115
|
return builder.generateConst( nodeType );
|
|
115
116
|
|
|
116
117
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Node from '../core/Node.js';
|
|
2
2
|
import { NodeUpdateType } from '../core/constants.js';
|
|
3
3
|
import { addMethodChaining, nodeObject } from '../tsl/TSLCore.js';
|
|
4
|
+
import { warn, error } from '../../utils.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* TODO
|
|
@@ -53,7 +54,7 @@ class ComputeNode extends Node {
|
|
|
53
54
|
/**
|
|
54
55
|
* TODO
|
|
55
56
|
*
|
|
56
|
-
* @type {number}
|
|
57
|
+
* @type {number|Array<number>}
|
|
57
58
|
*/
|
|
58
59
|
this.count = null;
|
|
59
60
|
|
|
@@ -90,6 +91,12 @@ class ComputeNode extends Node {
|
|
|
90
91
|
|
|
91
92
|
}
|
|
92
93
|
|
|
94
|
+
/**
|
|
95
|
+
* TODO
|
|
96
|
+
*
|
|
97
|
+
* @param {number|Array<number>} count - Array with [ x, y, z ] values for dispatch or a single number for the count
|
|
98
|
+
* @return {ComputeNode}
|
|
99
|
+
*/
|
|
93
100
|
setCount( count ) {
|
|
94
101
|
|
|
95
102
|
this.count = count;
|
|
@@ -98,6 +105,11 @@ class ComputeNode extends Node {
|
|
|
98
105
|
|
|
99
106
|
}
|
|
100
107
|
|
|
108
|
+
/**
|
|
109
|
+
* TODO
|
|
110
|
+
*
|
|
111
|
+
* @return {number|Array<number>}
|
|
112
|
+
*/
|
|
101
113
|
getCount() {
|
|
102
114
|
|
|
103
115
|
return this.count;
|
|
@@ -136,7 +148,7 @@ class ComputeNode extends Node {
|
|
|
136
148
|
*/
|
|
137
149
|
label( name ) {
|
|
138
150
|
|
|
139
|
-
|
|
151
|
+
warn( 'TSL: "label()" has been deprecated. Use "setName()" instead.' ); // @deprecated r179
|
|
140
152
|
|
|
141
153
|
return this.setName( name );
|
|
142
154
|
|
|
@@ -230,7 +242,7 @@ export const computeKernel = ( node, workgroupSize = [ 64 ] ) => {
|
|
|
230
242
|
|
|
231
243
|
if ( workgroupSize.length === 0 || workgroupSize.length > 3 ) {
|
|
232
244
|
|
|
233
|
-
|
|
245
|
+
error( 'TSL: compute() workgroupSize must have 1, 2, or 3 elements' );
|
|
234
246
|
|
|
235
247
|
}
|
|
236
248
|
|
|
@@ -240,7 +252,7 @@ export const computeKernel = ( node, workgroupSize = [ 64 ] ) => {
|
|
|
240
252
|
|
|
241
253
|
if ( typeof val !== 'number' || val <= 0 || ! Number.isInteger( val ) ) {
|
|
242
254
|
|
|
243
|
-
|
|
255
|
+
error( `TSL: compute() workgroupSize element at index [ ${ i } ] must be a positive integer` );
|
|
244
256
|
|
|
245
257
|
}
|
|
246
258
|
|
|
@@ -262,7 +274,7 @@ export const computeKernel = ( node, workgroupSize = [ 64 ] ) => {
|
|
|
262
274
|
* @tsl
|
|
263
275
|
* @function
|
|
264
276
|
* @param {Node} node - TODO
|
|
265
|
-
* @param {number} count - TODO.
|
|
277
|
+
* @param {number|Array<number>} count - TODO.
|
|
266
278
|
* @param {Array<number>} [workgroupSize=[64]] - TODO.
|
|
267
279
|
* @returns {AtomicFunctionNode}
|
|
268
280
|
*/
|
|
@@ -203,6 +203,7 @@ export default SubgroupFunctionNode;
|
|
|
203
203
|
* Returns true if this invocation has the lowest subgroup_invocation_id
|
|
204
204
|
* among active invocations in the subgroup.
|
|
205
205
|
*
|
|
206
|
+
* @tsl
|
|
206
207
|
* @method
|
|
207
208
|
* @return {bool} The result of the computation.
|
|
208
209
|
*/
|
|
@@ -212,6 +213,7 @@ export const subgroupElect = /*@__PURE__*/ nodeProxyIntent( SubgroupFunctionNode
|
|
|
212
213
|
* Returns a set of bitfields where the bit corresponding to subgroup_invocation_id
|
|
213
214
|
* is 1 if pred is true for that active invocation and 0 otherwise.
|
|
214
215
|
*
|
|
216
|
+
* @tsl
|
|
215
217
|
* @method
|
|
216
218
|
* @param {bool} pred - A boolean that sets the bit corresponding to the invocations subgroup invocation id.
|
|
217
219
|
* @return {vec4<u32>}- A bitfield corresponding to the pred value of each subgroup invocation.
|
|
@@ -221,6 +223,7 @@ export const subgroupBallot = /*@__PURE__*/ nodeProxyIntent( SubgroupFunctionNod
|
|
|
221
223
|
/**
|
|
222
224
|
* A reduction that adds e among all active invocations and returns that result.
|
|
223
225
|
*
|
|
226
|
+
* @tsl
|
|
224
227
|
* @method
|
|
225
228
|
* @param {number} e - The value provided to the reduction by the current invocation.
|
|
226
229
|
* @return {number} The accumulated result of the reduction operation.
|
|
@@ -230,6 +233,7 @@ export const subgroupAdd = /*@__PURE__*/ nodeProxyIntent( SubgroupFunctionNode,
|
|
|
230
233
|
/**
|
|
231
234
|
* An inclusive scan returning the sum of e for all active invocations with subgroup_invocation_id less than or equal to this invocation.
|
|
232
235
|
*
|
|
236
|
+
* @tsl
|
|
233
237
|
* @method
|
|
234
238
|
* @param {number} e - The value provided to the inclusive scan by the current invocation.
|
|
235
239
|
* @return {number} The accumulated result of the inclusive scan operation.
|
|
@@ -239,6 +243,7 @@ export const subgroupInclusiveAdd = /*@__PURE__*/ nodeProxyIntent( SubgroupFunct
|
|
|
239
243
|
/**
|
|
240
244
|
* An exclusive scan that returns the sum of e for all active invocations with subgroup_invocation_id less than this invocation.
|
|
241
245
|
*
|
|
246
|
+
* @tsl
|
|
242
247
|
* @method
|
|
243
248
|
* @param {number} e - The value provided to the exclusive scan by the current invocation.
|
|
244
249
|
* @return {number} The accumulated result of the exclusive scan operation.
|
|
@@ -248,6 +253,7 @@ export const subgroupExclusiveAdd = /*@__PURE__*/ nodeProxyIntent( SubgroupFunct
|
|
|
248
253
|
/**
|
|
249
254
|
* A reduction that multiplies e among all active invocations and returns that result.
|
|
250
255
|
*
|
|
256
|
+
* @tsl
|
|
251
257
|
* @method
|
|
252
258
|
* @param {number} e - The value provided to the reduction by the current invocation.
|
|
253
259
|
* @return {number} The accumulated result of the reduction operation.
|
|
@@ -257,6 +263,7 @@ export const subgroupMul = /*@__PURE__*/ nodeProxyIntent( SubgroupFunctionNode,
|
|
|
257
263
|
/**
|
|
258
264
|
* An inclusive scan returning the product of e for all active invocations with subgroup_invocation_id less than or equal to this invocation.
|
|
259
265
|
*
|
|
266
|
+
* @tsl
|
|
260
267
|
* @method
|
|
261
268
|
* @param {number} e - The value provided to the inclusive scan by the current invocation.
|
|
262
269
|
* @return {number} The accumulated result of the inclusive scan operation.
|
|
@@ -266,6 +273,7 @@ export const subgroupInclusiveMul = /*@__PURE__*/ nodeProxyIntent( SubgroupFunct
|
|
|
266
273
|
/**
|
|
267
274
|
* An exclusive scan that returns the product of e for all active invocations with subgroup_invocation_id less than this invocation.
|
|
268
275
|
*
|
|
276
|
+
* @tsl
|
|
269
277
|
* @method
|
|
270
278
|
* @param {number} e - The value provided to the exclusive scan by the current invocation.
|
|
271
279
|
* @return {number} The accumulated result of the exclusive scan operation.
|
|
@@ -275,6 +283,7 @@ export const subgroupExclusiveMul = /*@__PURE__*/ nodeProxyIntent( SubgroupFunct
|
|
|
275
283
|
/**
|
|
276
284
|
* A reduction that performs a bitwise and of e among all active invocations and returns that result.
|
|
277
285
|
*
|
|
286
|
+
* @tsl
|
|
278
287
|
* @method
|
|
279
288
|
* @param {number} e - The value provided to the reduction by the current invocation.
|
|
280
289
|
* @return {number} The result of the reduction operation.
|
|
@@ -284,6 +293,7 @@ export const subgroupAnd = /*@__PURE__*/ nodeProxyIntent( SubgroupFunctionNode,
|
|
|
284
293
|
/**
|
|
285
294
|
* A reduction that performs a bitwise or of e among all active invocations and returns that result.
|
|
286
295
|
*
|
|
296
|
+
* @tsl
|
|
287
297
|
* @method
|
|
288
298
|
* @param {number} e - The value provided to the reduction by the current invocation.
|
|
289
299
|
* @return {number} The result of the reduction operation.
|
|
@@ -293,6 +303,7 @@ export const subgroupOr = /*@__PURE__*/ nodeProxyIntent( SubgroupFunctionNode, S
|
|
|
293
303
|
/**
|
|
294
304
|
* A reduction that performs a bitwise xor of e among all active invocations and returns that result.
|
|
295
305
|
*
|
|
306
|
+
* @tsl
|
|
296
307
|
* @method
|
|
297
308
|
* @param {number} e - The value provided to the reduction by the current invocation.
|
|
298
309
|
* @return {number} The result of the reduction operation.
|
|
@@ -302,6 +313,7 @@ export const subgroupXor = /*@__PURE__*/ nodeProxyIntent( SubgroupFunctionNode,
|
|
|
302
313
|
/**
|
|
303
314
|
* A reduction that performs a min of e among all active invocations and returns that result.
|
|
304
315
|
*
|
|
316
|
+
* @tsl
|
|
305
317
|
* @method
|
|
306
318
|
* @param {number} e - The value provided to the reduction by the current invocation.
|
|
307
319
|
* @return {number} The result of the reduction operation.
|
|
@@ -311,6 +323,7 @@ export const subgroupMin = /*@__PURE__*/ nodeProxyIntent( SubgroupFunctionNode,
|
|
|
311
323
|
/**
|
|
312
324
|
* A reduction that performs a max of e among all active invocations and returns that result.
|
|
313
325
|
*
|
|
326
|
+
* @tsl
|
|
314
327
|
* @method
|
|
315
328
|
* @param {number} e - The value provided to the reduction by the current invocation.
|
|
316
329
|
* @return {number} The result of the reduction operation.
|
|
@@ -320,6 +333,7 @@ export const subgroupMax = /*@__PURE__*/ nodeProxyIntent( SubgroupFunctionNode,
|
|
|
320
333
|
/**
|
|
321
334
|
* Returns true if e is true for all active invocations in the subgroup.
|
|
322
335
|
*
|
|
336
|
+
* @tsl
|
|
323
337
|
* @method
|
|
324
338
|
* @return {bool} The result of the computation.
|
|
325
339
|
*/
|
|
@@ -328,6 +342,7 @@ export const subgroupAll = /*@__PURE__*/ nodeProxyIntent( SubgroupFunctionNode,
|
|
|
328
342
|
/**
|
|
329
343
|
* Returns true if e is true for any active invocation in the subgroup
|
|
330
344
|
*
|
|
345
|
+
* @tsl
|
|
331
346
|
* @method
|
|
332
347
|
* @return {bool} The result of the computation.
|
|
333
348
|
*/
|
|
@@ -336,6 +351,7 @@ export const subgroupAny = /*@__PURE__*/ nodeProxyIntent( SubgroupFunctionNode,
|
|
|
336
351
|
/**
|
|
337
352
|
* Broadcasts e from the active invocation with the lowest subgroup_invocation_id in the subgroup to all other active invocations.
|
|
338
353
|
*
|
|
354
|
+
* @tsl
|
|
339
355
|
* @method
|
|
340
356
|
* @param {number} e - The value to broadcast from the lowest subgroup invocation.
|
|
341
357
|
* @param {number} id - The subgroup invocation to broadcast from.
|
|
@@ -346,6 +362,7 @@ export const subgroupBroadcastFirst = /*@__PURE__*/ nodeProxyIntent( SubgroupFun
|
|
|
346
362
|
/**
|
|
347
363
|
* Swaps e between invocations in the quad in the X direction.
|
|
348
364
|
*
|
|
365
|
+
* @tsl
|
|
349
366
|
* @method
|
|
350
367
|
* @param {number} e - The value to swap from the current invocation.
|
|
351
368
|
* @return {number} The value received from the swap operation.
|
|
@@ -355,6 +372,7 @@ export const quadSwapX = /*@__PURE__*/ nodeProxyIntent( SubgroupFunctionNode, Su
|
|
|
355
372
|
/**
|
|
356
373
|
* Swaps e between invocations in the quad in the Y direction.
|
|
357
374
|
*
|
|
375
|
+
* @tsl
|
|
358
376
|
* @method
|
|
359
377
|
* @param {number} e - The value to swap from the current invocation.
|
|
360
378
|
* @return {number} The value received from the swap operation.
|
|
@@ -364,6 +382,7 @@ export const quadSwapY = /*@__PURE__*/ nodeProxyIntent( SubgroupFunctionNode, Su
|
|
|
364
382
|
/**
|
|
365
383
|
* Swaps e between invocations in the quad diagonally.
|
|
366
384
|
*
|
|
385
|
+
* @tsl
|
|
367
386
|
* @method
|
|
368
387
|
* @param {number} e - The value to swap from the current invocation.
|
|
369
388
|
* @return {number} The value received from the swap operation.
|
|
@@ -373,6 +392,7 @@ export const quadSwapDiagonal = /*@__PURE__*/ nodeProxyIntent( SubgroupFunctionN
|
|
|
373
392
|
/**
|
|
374
393
|
* Broadcasts e from the invocation whose subgroup_invocation_id matches id, to all active invocations.
|
|
375
394
|
*
|
|
395
|
+
* @tsl
|
|
376
396
|
* @method
|
|
377
397
|
* @param {number} e - The value to broadcast from subgroup invocation 'id'.
|
|
378
398
|
* @param {number} id - The subgroup invocation to broadcast from.
|
|
@@ -383,6 +403,7 @@ export const subgroupBroadcast = /*@__PURE__*/ nodeProxyIntent( SubgroupFunction
|
|
|
383
403
|
/**
|
|
384
404
|
* Returns v from the active invocation whose subgroup_invocation_id matches id
|
|
385
405
|
*
|
|
406
|
+
* @tsl
|
|
386
407
|
* @method
|
|
387
408
|
* @param {number} v - The value to return from subgroup invocation id^mask.
|
|
388
409
|
* @param {number} id - The subgroup invocation which returns the value v.
|
|
@@ -393,6 +414,7 @@ export const subgroupShuffle = /*@__PURE__*/ nodeProxyIntent( SubgroupFunctionNo
|
|
|
393
414
|
/**
|
|
394
415
|
* Returns v from the active invocation whose subgroup_invocation_id matches subgroup_invocation_id ^ mask.
|
|
395
416
|
*
|
|
417
|
+
* @tsl
|
|
396
418
|
* @method
|
|
397
419
|
* @param {number} v - The value to return from subgroup invocation id^mask.
|
|
398
420
|
* @param {number} mask - A bitmask that determines the target invocation via a XOR operation.
|
|
@@ -403,6 +425,7 @@ export const subgroupShuffleXor = /*@__PURE__*/ nodeProxyIntent( SubgroupFunctio
|
|
|
403
425
|
/**
|
|
404
426
|
* Returns v from the active invocation whose subgroup_invocation_id matches subgroup_invocation_id - delta
|
|
405
427
|
*
|
|
428
|
+
* @tsl
|
|
406
429
|
* @method
|
|
407
430
|
* @param {number} v - The value to return from subgroup invocation id^mask.
|
|
408
431
|
* @param {number} delta - A value that offsets the current in.
|
|
@@ -413,6 +436,7 @@ export const subgroupShuffleUp = /*@__PURE__*/ nodeProxyIntent( SubgroupFunction
|
|
|
413
436
|
/**
|
|
414
437
|
* Returns v from the active invocation whose subgroup_invocation_id matches subgroup_invocation_id + delta
|
|
415
438
|
*
|
|
439
|
+
* @tsl
|
|
416
440
|
* @method
|
|
417
441
|
* @param {number} v - The value to return from subgroup invocation id^mask.
|
|
418
442
|
* @param {number} delta - A value that offsets the current subgroup invocation.
|
|
@@ -423,6 +447,7 @@ export const subgroupShuffleDown = /*@__PURE__*/ nodeProxyIntent( SubgroupFuncti
|
|
|
423
447
|
/**
|
|
424
448
|
* Broadcasts e from the quad invocation with id equal to id.
|
|
425
449
|
*
|
|
450
|
+
* @tsl
|
|
426
451
|
* @method
|
|
427
452
|
* @param {number} e - The value to broadcast.
|
|
428
453
|
* @return {number} The broadcast value.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import ArrayElementNode from '../utils/ArrayElementNode.js';
|
|
2
2
|
import { nodeObject } from '../tsl/TSLCore.js';
|
|
3
3
|
import Node from '../core/Node.js';
|
|
4
|
+
import { warn } from '../../utils.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Represents an element of a 'workgroup' scoped buffer.
|
|
@@ -149,7 +150,7 @@ class WorkgroupInfoNode extends Node {
|
|
|
149
150
|
*/
|
|
150
151
|
label( name ) {
|
|
151
152
|
|
|
152
|
-
|
|
153
|
+
warn( 'TSL: "label()" has been deprecated. Use "setName()" instead.' ); // @deprecated r179
|
|
153
154
|
|
|
154
155
|
return this.setName( name );
|
|
155
156
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import LightingNode from './LightingNode.js';
|
|
2
|
-
import {
|
|
2
|
+
import { isolate } from '../core/IsolateNode.js';
|
|
3
3
|
import { roughness, clearcoatRoughness } from '../core/PropertyNode.js';
|
|
4
4
|
import { cameraViewMatrix } from '../accessors/Camera.js';
|
|
5
5
|
import { normalView, clearcoatNormalView, normalWorld } from '../accessors/Normal.js';
|
|
6
6
|
import { positionViewDirection } from '../accessors/Position.js';
|
|
7
|
-
import { float } from '../tsl/TSLBase.js';
|
|
7
|
+
import { float, pow4 } from '../tsl/TSLBase.js';
|
|
8
8
|
import { bentNormalView } from '../accessors/AccessorsUtils.js';
|
|
9
9
|
import { pmremTexture } from '../pmrem/PMREMNode.js';
|
|
10
10
|
import { materialEnvIntensity } from '../accessors/MaterialProperties.js';
|
|
@@ -77,8 +77,8 @@ class EnvironmentNode extends LightingNode {
|
|
|
77
77
|
const radiance = envNode.context( createRadianceContext( roughness, radianceNormalView ) ).mul( materialEnvIntensity );
|
|
78
78
|
const irradiance = envNode.context( createIrradianceContext( normalWorld ) ).mul( Math.PI ).mul( materialEnvIntensity );
|
|
79
79
|
|
|
80
|
-
const isolateRadiance =
|
|
81
|
-
const isolateIrradiance =
|
|
80
|
+
const isolateRadiance = isolate( radiance );
|
|
81
|
+
const isolateIrradiance = isolate( irradiance );
|
|
82
82
|
|
|
83
83
|
//
|
|
84
84
|
|
|
@@ -93,7 +93,7 @@ class EnvironmentNode extends LightingNode {
|
|
|
93
93
|
if ( clearcoatRadiance ) {
|
|
94
94
|
|
|
95
95
|
const clearcoatRadianceContext = envNode.context( createRadianceContext( clearcoatRoughness, clearcoatNormalView ) ).mul( materialEnvIntensity );
|
|
96
|
-
const isolateClearcoatRadiance =
|
|
96
|
+
const isolateClearcoatRadiance = isolate( clearcoatRadianceContext );
|
|
97
97
|
|
|
98
98
|
clearcoatRadiance.addAssign( isolateClearcoatRadiance );
|
|
99
99
|
|
|
@@ -117,7 +117,7 @@ const createRadianceContext = ( roughnessNode, normalViewNode ) => {
|
|
|
117
117
|
reflectVec = positionViewDirection.negate().reflect( normalViewNode );
|
|
118
118
|
|
|
119
119
|
// Mixing the reflection with the normal is more accurate and keeps rough objects from gathering light from behind their tangent plane.
|
|
120
|
-
reflectVec =
|
|
120
|
+
reflectVec = pow4( roughnessNode ).mix( reflectVec, normalViewNode ).normalize();
|
|
121
121
|
|
|
122
122
|
reflectVec = reflectVec.transformDirection( cameraViewMatrix );
|
|
123
123
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Node from '../core/Node.js';
|
|
2
2
|
import { nodeObject, property, vec3 } from '../tsl/TSLBase.js';
|
|
3
3
|
import { hashArray } from '../core/NodeUtils.js';
|
|
4
|
+
import { warn } from '../../utils.js';
|
|
4
5
|
|
|
5
6
|
const sortLights = ( lights ) => {
|
|
6
7
|
|
|
@@ -224,7 +225,7 @@ class LightsNode extends Node {
|
|
|
224
225
|
|
|
225
226
|
if ( lightNodeClass === null ) {
|
|
226
227
|
|
|
227
|
-
|
|
228
|
+
warn( `LightsNode.setupNodeLights: Light node not found for ${ light.constructor.name }` );
|
|
228
229
|
continue;
|
|
229
230
|
|
|
230
231
|
}
|
|
@@ -368,8 +369,6 @@ class LightsNode extends Node {
|
|
|
368
369
|
|
|
369
370
|
}
|
|
370
371
|
|
|
371
|
-
context.material.transparent = true;
|
|
372
|
-
|
|
373
372
|
}
|
|
374
373
|
|
|
375
374
|
totalDiffuseNode.assign( totalDiffuse );
|
|
@@ -279,8 +279,14 @@ class PointShadowNode extends ShadowNode {
|
|
|
279
279
|
|
|
280
280
|
shadow.updateMatrices( light, vp );
|
|
281
281
|
|
|
282
|
+
const currentSceneName = scene.name;
|
|
283
|
+
|
|
284
|
+
scene.name = `Point Light Shadow [ ${ light.name || 'ID: ' + light.id } ] - Face ${ vp + 1 }`;
|
|
285
|
+
|
|
282
286
|
renderer.render( scene, shadow.camera );
|
|
283
287
|
|
|
288
|
+
scene.name = currentSceneName;
|
|
289
|
+
|
|
284
290
|
}
|
|
285
291
|
|
|
286
292
|
//
|
|
@@ -245,6 +245,8 @@ const linearShadowDistance = ( light ) => {
|
|
|
245
245
|
* If not, it creates a new `NodeMaterial` configured for shadow rendering and stores it
|
|
246
246
|
* in the `shadowMaterialLib` for future use.
|
|
247
247
|
*
|
|
248
|
+
* @tsl
|
|
249
|
+
* @function
|
|
248
250
|
* @param {Light} light - The light source for which the shadow material is needed.
|
|
249
251
|
* If the light is a point light, a depth node is calculated
|
|
250
252
|
* using the linear shadow distance.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import ShadowBaseNode, { shadowPositionWorld } from './ShadowBaseNode.js';
|
|
2
2
|
import { float, vec2, vec3, int, Fn, nodeObject } from '../tsl/TSLBase.js';
|
|
3
3
|
import { reference } from '../accessors/ReferenceNode.js';
|
|
4
|
-
import { texture } from '../accessors/TextureNode.js';
|
|
4
|
+
import { texture, textureLoad } from '../accessors/TextureNode.js';
|
|
5
5
|
import { normalWorld } from '../accessors/Normal.js';
|
|
6
6
|
import { mix, sqrt } from '../math/MathNode.js';
|
|
7
7
|
import { add } from '../math/OperatorNode.js';
|
|
@@ -18,6 +18,9 @@ import { resetRendererAndSceneState, restoreRendererAndSceneState } from '../../
|
|
|
18
18
|
import { getDataFromObject } from '../core/NodeUtils.js';
|
|
19
19
|
import { getShadowMaterial, BasicShadowFilter, PCFShadowFilter, PCFSoftShadowFilter, VSMShadowFilter } from './ShadowFilterNode.js';
|
|
20
20
|
import ChainMap from '../../renderers/common/ChainMap.js';
|
|
21
|
+
import { warn } from '../../utils.js';
|
|
22
|
+
import { textureSize } from '../accessors/TextureSizeNode.js';
|
|
23
|
+
import { uv } from '../accessors/UV.js';
|
|
21
24
|
|
|
22
25
|
//
|
|
23
26
|
|
|
@@ -27,6 +30,8 @@ const _shadowRenderObjectKeys = [];
|
|
|
27
30
|
/**
|
|
28
31
|
* Creates a function to render shadow objects in a scene.
|
|
29
32
|
*
|
|
33
|
+
* @tsl
|
|
34
|
+
* @function
|
|
30
35
|
* @param {Renderer} renderer - The renderer.
|
|
31
36
|
* @param {LightShadow} shadow - The light shadow object containing shadow properties.
|
|
32
37
|
* @param {number} shadowType - The type of shadow map (e.g., BasicShadowMap).
|
|
@@ -268,6 +273,22 @@ class ShadowNode extends ShadowBaseNode {
|
|
|
268
273
|
*/
|
|
269
274
|
this._node = null;
|
|
270
275
|
|
|
276
|
+
/**
|
|
277
|
+
* The current shadow map type of this shadow node.
|
|
278
|
+
*
|
|
279
|
+
* @type {?number}
|
|
280
|
+
* @private
|
|
281
|
+
* @default null
|
|
282
|
+
*/
|
|
283
|
+
this._currentShadowType = null;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* A Weak Map holding the current frame ID per camera. Used
|
|
287
|
+
* to control the update of shadow maps.
|
|
288
|
+
*
|
|
289
|
+
* @type {WeakMap<Camera,number>}
|
|
290
|
+
* @private
|
|
291
|
+
*/
|
|
271
292
|
this._cameraFrameId = new WeakMap();
|
|
272
293
|
|
|
273
294
|
/**
|
|
@@ -405,7 +426,7 @@ class ShadowNode extends ShadowBaseNode {
|
|
|
405
426
|
*/
|
|
406
427
|
setupShadow( builder ) {
|
|
407
428
|
|
|
408
|
-
const { renderer } = builder;
|
|
429
|
+
const { renderer, camera } = builder;
|
|
409
430
|
|
|
410
431
|
const { light, shadow } = this;
|
|
411
432
|
|
|
@@ -413,6 +434,7 @@ class ShadowNode extends ShadowBaseNode {
|
|
|
413
434
|
|
|
414
435
|
const { depthTexture, shadowMap } = this.setupRenderTarget( shadow, builder );
|
|
415
436
|
|
|
437
|
+
shadow.camera.coordinateSystem = camera.coordinateSystem;
|
|
416
438
|
shadow.camera.updateProjectionMatrix();
|
|
417
439
|
|
|
418
440
|
// VSM
|
|
@@ -514,7 +536,19 @@ class ShadowNode extends ShadowBaseNode {
|
|
|
514
536
|
this.shadowMap = shadowMap;
|
|
515
537
|
this.shadow.map = shadowMap;
|
|
516
538
|
|
|
517
|
-
|
|
539
|
+
// Shadow Output + Inspector
|
|
540
|
+
|
|
541
|
+
const inspectName = `${ this.light.type } Shadow [ ${ this.light.name || 'ID: ' + this.light.id } ]`;
|
|
542
|
+
|
|
543
|
+
return shadowOutput.toInspector( `${ inspectName } / Color`, () => {
|
|
544
|
+
|
|
545
|
+
return texture( this.shadowMap.texture );
|
|
546
|
+
|
|
547
|
+
} ).toInspector( `${ inspectName } / Depth`, () => {
|
|
548
|
+
|
|
549
|
+
return textureLoad( this.shadowMap.depthTexture, uv().mul( textureSize( texture( this.shadowMap.depthTexture ) ) ) ).x.oneMinus();
|
|
550
|
+
|
|
551
|
+
} );
|
|
518
552
|
|
|
519
553
|
}
|
|
520
554
|
|
|
@@ -531,6 +565,15 @@ class ShadowNode extends ShadowBaseNode {
|
|
|
531
565
|
|
|
532
566
|
return Fn( () => {
|
|
533
567
|
|
|
568
|
+
const currentShadowType = builder.renderer.shadowMap.type;
|
|
569
|
+
|
|
570
|
+
if ( this._currentShadowType !== currentShadowType ) {
|
|
571
|
+
|
|
572
|
+
this._reset();
|
|
573
|
+
this._node = null;
|
|
574
|
+
|
|
575
|
+
}
|
|
576
|
+
|
|
534
577
|
let node = this._node;
|
|
535
578
|
|
|
536
579
|
this.setupShadowPosition( builder );
|
|
@@ -538,12 +581,13 @@ class ShadowNode extends ShadowBaseNode {
|
|
|
538
581
|
if ( node === null ) {
|
|
539
582
|
|
|
540
583
|
this._node = node = this.setupShadow( builder );
|
|
584
|
+
this._currentShadowType = currentShadowType;
|
|
541
585
|
|
|
542
586
|
}
|
|
543
587
|
|
|
544
588
|
if ( builder.material.shadowNode ) { // @deprecated, r171
|
|
545
589
|
|
|
546
|
-
|
|
590
|
+
warn( 'NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.' );
|
|
547
591
|
|
|
548
592
|
}
|
|
549
593
|
|
|
@@ -576,8 +620,14 @@ class ShadowNode extends ShadowBaseNode {
|
|
|
576
620
|
|
|
577
621
|
shadowMap.setSize( shadow.mapSize.width, shadow.mapSize.height, shadowMap.depth );
|
|
578
622
|
|
|
623
|
+
const currentSceneName = scene.name;
|
|
624
|
+
|
|
625
|
+
scene.name = `Shadow Map [ ${ light.name || 'ID: ' + light.id } ]`;
|
|
626
|
+
|
|
579
627
|
renderer.render( scene, shadow.camera );
|
|
580
628
|
|
|
629
|
+
scene.name = currentSceneName;
|
|
630
|
+
|
|
581
631
|
}
|
|
582
632
|
|
|
583
633
|
/**
|
|
@@ -664,8 +714,27 @@ class ShadowNode extends ShadowBaseNode {
|
|
|
664
714
|
*/
|
|
665
715
|
dispose() {
|
|
666
716
|
|
|
667
|
-
this.
|
|
668
|
-
|
|
717
|
+
this._reset();
|
|
718
|
+
|
|
719
|
+
super.dispose();
|
|
720
|
+
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
/**
|
|
724
|
+
* Resets the resouce state of this shadow node.
|
|
725
|
+
*
|
|
726
|
+
* @private
|
|
727
|
+
*/
|
|
728
|
+
_reset() {
|
|
729
|
+
|
|
730
|
+
this._currentShadowType = null;
|
|
731
|
+
|
|
732
|
+
if ( this.shadowMap ) {
|
|
733
|
+
|
|
734
|
+
this.shadowMap.dispose();
|
|
735
|
+
this.shadowMap = null;
|
|
736
|
+
|
|
737
|
+
}
|
|
669
738
|
|
|
670
739
|
if ( this.vsmShadowMapVertical !== null ) {
|
|
671
740
|
|
|
@@ -687,8 +756,6 @@ class ShadowNode extends ShadowBaseNode {
|
|
|
687
756
|
|
|
688
757
|
}
|
|
689
758
|
|
|
690
|
-
super.dispose();
|
|
691
|
-
|
|
692
759
|
}
|
|
693
760
|
|
|
694
761
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Node from '../core/Node.js';
|
|
2
2
|
import { property } from '../core/PropertyNode.js';
|
|
3
3
|
import { addMethodChaining, nodeProxy } from '../tsl/TSLCore.js';
|
|
4
|
+
import { warn } from '../../utils.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Represents a logical `if/else` statement. Can be used as an alternative
|
|
@@ -99,9 +100,9 @@ class ConditionalNode extends Node {
|
|
|
99
100
|
|
|
100
101
|
setup( builder ) {
|
|
101
102
|
|
|
102
|
-
const condNode = this.condNode
|
|
103
|
-
const ifNode = this.ifNode.
|
|
104
|
-
const elseNode = this.elseNode ? this.elseNode.
|
|
103
|
+
const condNode = this.condNode;
|
|
104
|
+
const ifNode = this.ifNode.isolate();
|
|
105
|
+
const elseNode = this.elseNode ? this.elseNode.isolate() : null;
|
|
105
106
|
|
|
106
107
|
//
|
|
107
108
|
|
|
@@ -173,7 +174,7 @@ class ConditionalNode extends Node {
|
|
|
173
174
|
|
|
174
175
|
if ( functionNode === null ) {
|
|
175
176
|
|
|
176
|
-
|
|
177
|
+
warn( 'TSL: Return statement used in an inline \'Fn()\'. Define a layout struct to allow return values.' );
|
|
177
178
|
|
|
178
179
|
ifSnippet = '// ' + ifSnippet;
|
|
179
180
|
|
|
@@ -203,7 +204,7 @@ class ConditionalNode extends Node {
|
|
|
203
204
|
|
|
204
205
|
if ( functionNode === null ) {
|
|
205
206
|
|
|
206
|
-
|
|
207
|
+
warn( 'TSL: Return statement used in an inline \'Fn()\'. Define a layout struct to allow return values.' );
|
|
207
208
|
|
|
208
209
|
elseSnippet = '// ' + elseSnippet;
|
|
209
210
|
|