@plastic-software/three 0.183.3 → 0.184.0
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 +783 -290
- package/build/three.core.js +372 -110
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +436 -184
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +7 -1
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +2979 -1281
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +2942 -1281
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +11 -0
- package/examples/jsm/animation/CCDIKSolver.js +5 -1
- package/examples/jsm/controls/ArcballControls.js +4 -1
- package/examples/jsm/controls/DragControls.js +2 -2
- package/examples/jsm/controls/FirstPersonControls.js +58 -54
- package/examples/jsm/controls/FlyControls.js +4 -0
- package/examples/jsm/controls/OrbitControls.js +2 -2
- package/examples/jsm/controls/TrackballControls.js +2 -2
- package/examples/jsm/controls/TransformControls.js +34 -2
- package/examples/jsm/csm/CSMShadowNode.js +6 -2
- package/examples/jsm/exporters/GLTFExporter.js +21 -5
- package/examples/jsm/geometries/TextGeometry.js +18 -0
- package/examples/jsm/helpers/LightProbeGridHelper.js +221 -0
- package/examples/jsm/inspector/Extension.js +13 -0
- package/examples/jsm/inspector/Inspector.js +169 -114
- package/examples/jsm/inspector/RendererInspector.js +2 -2
- package/examples/jsm/inspector/extensions/extensions.json +6 -0
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphEditor.js +916 -0
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphLoader.js +281 -0
- package/examples/jsm/inspector/tabs/Memory.js +128 -0
- package/examples/jsm/inspector/tabs/Parameters.js +34 -2
- package/examples/jsm/inspector/tabs/Performance.js +2 -2
- package/examples/jsm/inspector/tabs/Settings.js +264 -0
- package/examples/jsm/inspector/tabs/Timeline.js +1611 -0
- package/examples/jsm/inspector/tabs/Viewer.js +105 -3
- package/examples/jsm/inspector/ui/Graph.js +2 -2
- package/examples/jsm/inspector/ui/List.js +1 -1
- package/examples/jsm/inspector/ui/Profiler.js +273 -176
- package/examples/jsm/inspector/ui/Style.js +64 -10
- package/examples/jsm/inspector/ui/Tab.js +39 -7
- package/examples/jsm/inspector/ui/Values.js +39 -2
- package/examples/jsm/inspector/ui/utils.js +13 -0
- package/examples/jsm/interaction/InteractionManager.js +226 -0
- package/examples/jsm/libs/meshopt_decoder.module.js +8 -8
- package/examples/jsm/lighting/DynamicLighting.js +82 -0
- package/examples/jsm/lighting/LightProbeGrid.js +651 -0
- package/examples/jsm/lines/LineMaterial.js +1 -1
- package/examples/jsm/loaders/EXRLoader.js +682 -43
- package/examples/jsm/loaders/FBXLoader.js +233 -33
- package/examples/jsm/loaders/GLTFLoader.js +24 -7
- package/examples/jsm/loaders/HDRLoader.js +1 -1
- package/examples/jsm/loaders/KTX2Loader.js +8 -2
- package/examples/jsm/loaders/LDrawLoader.js +39 -47
- package/examples/jsm/loaders/SVGLoader.js +1 -1
- package/examples/jsm/loaders/VTKLoader.js +5 -1
- package/examples/jsm/loaders/collada/ColladaComposer.js +101 -7
- package/examples/jsm/loaders/collada/ColladaParser.js +19 -4
- package/examples/jsm/loaders/usd/USDAParser.js +6 -0
- package/examples/jsm/loaders/usd/USDCParser.js +26 -0
- package/examples/jsm/loaders/usd/USDComposer.js +656 -103
- package/examples/jsm/misc/GPUComputationRenderer.js +2 -0
- package/examples/jsm/misc/RollerCoaster.js +42 -4
- package/examples/jsm/modifiers/TessellateModifier.js +1 -1
- package/examples/jsm/objects/Reflector.js +73 -25
- package/examples/jsm/objects/Sky.js +14 -2
- package/examples/jsm/objects/SkyMesh.js +23 -6
- package/examples/jsm/renderers/Projector.js +18 -38
- package/examples/jsm/renderers/SVGRenderer.js +6 -25
- package/examples/jsm/transpiler/GLSLDecoder.js +2 -2
- package/examples/jsm/tsl/WebGLNodesHandler.js +605 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +10 -0
- package/examples/jsm/tsl/display/AnamorphicNode.js +11 -0
- package/examples/jsm/tsl/display/BilateralBlurNode.js +10 -0
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +3 -36
- package/examples/jsm/tsl/display/FSR1Node.js +477 -0
- package/examples/jsm/tsl/display/GTAONode.js +2 -1
- package/examples/jsm/tsl/display/GaussianBlurNode.js +10 -0
- package/examples/jsm/tsl/display/GodraysNode.js +2 -11
- package/examples/jsm/tsl/display/OutlineNode.js +66 -16
- package/examples/jsm/tsl/display/SSGINode.js +0 -4
- package/examples/jsm/tsl/display/SharpenNode.js +283 -0
- package/examples/jsm/tsl/display/TAAUNode.js +835 -0
- package/examples/jsm/tsl/display/TRAANode.js +48 -7
- package/examples/jsm/tsl/lighting/DynamicLightsNode.js +300 -0
- package/examples/jsm/tsl/lighting/data/AmbientLightDataNode.js +61 -0
- package/examples/jsm/tsl/lighting/data/DirectionalLightDataNode.js +111 -0
- package/examples/jsm/tsl/lighting/data/HemisphereLightDataNode.js +99 -0
- package/examples/jsm/tsl/lighting/data/PointLightDataNode.js +134 -0
- package/examples/jsm/tsl/lighting/data/SpotLightDataNode.js +161 -0
- package/examples/jsm/tsl/math/Bayer.js +13 -2
- package/examples/jsm/utils/BufferGeometryUtils.js +2 -3
- package/examples/jsm/utils/ColorUtils.js +76 -0
- package/examples/jsm/utils/SkeletonUtils.js +14 -8
- package/examples/jsm/webxr/XRHandMeshModel.js +36 -10
- package/examples/jsm/webxr/XRHandModelFactory.js +2 -1
- package/package.json +4 -4
- package/src/Three.Core.js +1 -0
- package/src/Three.TSL.js +6 -0
- package/src/Three.WebGPU.Nodes.js +3 -0
- package/src/Three.WebGPU.js +6 -0
- package/src/animation/AnimationAction.js +11 -1
- package/src/audio/AudioContext.js +2 -2
- package/src/constants.js +1 -1
- package/src/core/BufferAttribute.js +13 -1
- package/src/core/Clock.js +1 -1
- package/src/core/Object3D.js +1 -5
- package/src/core/RenderTarget.js +1 -0
- package/src/extras/PMREMGenerator.js +1 -1
- package/src/extras/curves/CatmullRomCurve3.js +3 -2
- package/src/loaders/AudioLoader.js +11 -1
- package/src/loaders/DataTextureLoader.js +6 -4
- package/src/loaders/FileLoader.js +1 -2
- package/src/loaders/ImageBitmapLoader.js +4 -6
- package/src/loaders/MaterialLoader.js +1 -1
- package/src/loaders/ObjectLoader.js +25 -4
- package/src/loaders/nodes/NodeObjectLoader.js +18 -0
- package/src/materials/MeshToonMaterial.js +1 -1
- package/src/materials/nodes/Line2NodeMaterial.js +27 -0
- package/src/materials/nodes/NodeMaterial.js +0 -27
- package/src/materials/nodes/manager/NodeMaterialObserver.js +188 -89
- package/src/math/Line3.js +3 -0
- package/src/math/Matrix2.js +13 -9
- package/src/math/Matrix3.js +13 -9
- package/src/math/Matrix4.js +13 -9
- package/src/math/Plane.js +4 -3
- package/src/math/Triangle.js +1 -1
- package/src/math/Vector2.js +11 -7
- package/src/math/Vector3.js +12 -8
- package/src/math/Vector4.js +13 -9
- package/src/nodes/Nodes.js +0 -1
- package/src/nodes/TSL.js +1 -1
- package/src/nodes/accessors/BufferAttributeNode.js +9 -3
- package/src/nodes/accessors/CubeTextureNode.js +7 -1
- package/src/nodes/accessors/MaterialProperties.js +2 -5
- package/src/nodes/accessors/Object3DNode.js +1 -1
- package/src/nodes/accessors/ReferenceBaseNode.js +2 -2
- package/src/nodes/accessors/ReferenceNode.js +4 -4
- package/src/nodes/accessors/SceneProperties.js +2 -8
- package/src/nodes/accessors/StorageBufferNode.js +10 -4
- package/src/nodes/accessors/StorageTextureNode.js +4 -9
- package/src/nodes/accessors/TextureNode.js +10 -2
- package/src/nodes/accessors/UniformArrayNode.js +2 -2
- package/src/nodes/code/FunctionCallNode.js +1 -1
- package/src/nodes/code/FunctionNode.js +1 -1
- package/src/nodes/core/ArrayNode.js +1 -1
- package/src/nodes/core/AssignNode.js +1 -1
- package/src/nodes/core/AttributeNode.js +1 -1
- package/src/nodes/core/BypassNode.js +1 -1
- package/src/nodes/core/ContextNode.js +1 -1
- package/src/nodes/core/IndexNode.js +2 -1
- package/src/nodes/core/InputNode.js +1 -1
- package/src/nodes/core/InspectorNode.js +1 -1
- package/src/nodes/core/IsolateNode.js +1 -1
- package/src/nodes/core/Node.js +83 -12
- package/src/nodes/core/NodeBuilder.js +117 -16
- package/src/nodes/core/NodeUtils.js +1 -1
- package/src/nodes/core/OutputStructNode.js +1 -1
- package/src/nodes/core/ParameterNode.js +1 -1
- package/src/nodes/core/StackNode.js +1 -1
- package/src/nodes/core/StructNode.js +1 -1
- package/src/nodes/core/StructTypeNode.js +1 -1
- package/src/nodes/core/SubBuildNode.js +1 -1
- package/src/nodes/core/UniformGroupNode.js +36 -6
- package/src/nodes/core/VarNode.js +1 -1
- package/src/nodes/core/VaryingNode.js +1 -1
- package/src/nodes/display/NormalMapNode.js +2 -2
- package/src/nodes/display/PassNode.js +27 -7
- package/src/nodes/display/RenderOutputNode.js +4 -4
- package/src/nodes/display/ScreenNode.js +1 -1
- package/src/nodes/display/ViewportDepthTextureNode.js +11 -15
- package/src/nodes/display/ViewportTextureNode.js +18 -7
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
- package/src/nodes/geometry/RangeNode.js +1 -1
- package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
- package/src/nodes/gpgpu/BarrierNode.js +9 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +1 -1
- package/src/nodes/gpgpu/ComputeNode.js +69 -44
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +1 -1
- package/src/nodes/lighting/LightsNode.js +6 -27
- package/src/nodes/lighting/ShadowNode.js +24 -2
- package/src/nodes/math/BitcastNode.js +1 -1
- package/src/nodes/math/ConditionalNode.js +1 -1
- package/src/nodes/math/MathNode.js +73 -1
- package/src/nodes/math/OperatorNode.js +1 -1
- package/src/nodes/math/PackFloatNode.js +1 -1
- package/src/nodes/math/UnpackFloatNode.js +1 -1
- package/src/nodes/tsl/TSLBase.js +1 -1
- package/src/nodes/tsl/TSLCore.js +21 -3
- package/src/nodes/utils/ArrayElementNode.js +1 -1
- package/src/nodes/utils/ConvertNode.js +1 -1
- package/src/nodes/utils/DebugNode.js +1 -1
- package/src/nodes/utils/EventNode.js +30 -0
- package/src/nodes/utils/FlipNode.js +1 -1
- package/src/nodes/utils/FunctionOverloadingNode.js +1 -1
- package/src/nodes/utils/JoinNode.js +1 -1
- package/src/nodes/utils/MemberNode.js +1 -1
- package/src/nodes/utils/Remap.js +48 -0
- package/src/nodes/utils/RotateNode.js +1 -1
- package/src/nodes/utils/SetNode.js +1 -1
- package/src/nodes/utils/SplitNode.js +1 -1
- package/src/objects/BatchedMesh.js +17 -2
- package/src/objects/InstancedMesh.js +19 -3
- package/src/objects/SkinnedMesh.js +26 -9
- package/src/renderers/WebGLRenderer.js +148 -49
- package/src/renderers/common/Animation.js +3 -3
- package/src/renderers/common/Attributes.js +15 -1
- package/src/renderers/common/Backend.js +0 -8
- package/src/renderers/common/Background.js +2 -2
- package/src/renderers/common/BindGroup.js +1 -8
- package/src/renderers/common/Bindings.js +2 -2
- package/src/renderers/common/ComputePipeline.js +1 -1
- package/src/renderers/common/CubeRenderTarget.js +1 -1
- package/src/renderers/common/Info.js +333 -4
- package/src/renderers/common/InspectorBase.js +6 -1
- package/src/renderers/common/Pipelines.js +36 -3
- package/src/renderers/common/ReadbackBuffer.js +78 -0
- package/src/renderers/common/RenderBundle.js +3 -1
- package/src/renderers/common/RenderBundles.js +5 -2
- package/src/renderers/common/RenderObject.js +2 -2
- package/src/renderers/common/RenderObjects.js +3 -3
- package/src/renderers/common/RenderPipeline.js +35 -6
- package/src/renderers/common/Renderer.js +232 -53
- package/src/renderers/common/Textures.js +72 -3
- package/src/renderers/common/UniformsGroup.js +1 -1
- package/src/renderers/common/XRManager.js +34 -27
- package/src/renderers/common/extras/PMREMGenerator.js +23 -15
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/NodeManager.js +230 -99
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +20 -0
- package/src/renderers/shaders/ShaderChunk/beginnormal_vertex.glsl.js +9 -1
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +0 -1
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lightprobes_pars_fragment.glsl.js +80 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +2 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +1 -3
- package/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +0 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +12 -2
- package/src/renderers/shaders/ShaderChunk.js +2 -0
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib.js +0 -1
- package/src/renderers/shaders/UniformsLib.js +7 -2
- package/src/renderers/shaders/UniformsUtils.js +27 -5
- package/src/renderers/webgl/WebGLAnimation.js +2 -1
- package/src/renderers/webgl/WebGLBackground.js +13 -13
- package/src/renderers/webgl/WebGLBufferRenderer.js +0 -32
- package/src/renderers/webgl/WebGLCapabilities.js +6 -0
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +0 -32
- package/src/renderers/webgl/WebGLMaterials.js +12 -13
- package/src/renderers/webgl/WebGLOutput.js +4 -1
- package/src/renderers/webgl/WebGLProgram.js +5 -0
- package/src/renderers/webgl/WebGLPrograms.js +24 -3
- package/src/renderers/webgl/WebGLRenderStates.js +13 -2
- package/src/renderers/webgl/WebGLState.js +43 -0
- package/src/renderers/webgl/WebGLTextures.js +129 -26
- package/src/renderers/webgl/WebGLUniformsGroups.js +19 -0
- package/src/renderers/webgl-fallback/WebGLBackend.js +106 -65
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +0 -41
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +29 -51
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +53 -19
- package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +25 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +42 -1
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +63 -50
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +1 -1
- package/src/renderers/webgpu/WebGPUBackend.js +160 -146
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +55 -33
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +103 -17
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +1 -1
- package/src/renderers/webgpu/utils/WebGPUCapabilities.js +48 -0
- package/src/renderers/webgpu/utils/WebGPUConstants.js +8 -0
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +91 -17
- package/src/renderers/webgpu/utils/WebGPUUtils.js +18 -2
- package/src/renderers/webxr/WebXRController.js +12 -0
- package/src/textures/HTMLTexture.js +74 -0
- package/src/textures/Source.js +1 -1
- package/src/textures/Texture.js +13 -2
- package/src/utils.js +23 -1
- package/src/nodes/utils/RemapNode.js +0 -125
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import Node from '../core/Node.js';
|
|
2
|
+
import { instanceIndex } from '../core/IndexNode.js';
|
|
2
3
|
import StackTrace from '../core/StackTrace.js';
|
|
4
|
+
import { uniform } from '../core/UniformNode.js';
|
|
3
5
|
import { NodeUpdateType } from '../core/constants.js';
|
|
4
6
|
import { addMethodChaining, nodeObject } from '../tsl/TSLCore.js';
|
|
5
7
|
import { warn, error } from '../../utils.js';
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
|
-
*
|
|
10
|
+
* Represents a compute shader node.
|
|
9
11
|
*
|
|
10
12
|
* @augments Node
|
|
11
13
|
*/
|
|
@@ -20,8 +22,8 @@ class ComputeNode extends Node {
|
|
|
20
22
|
/**
|
|
21
23
|
* Constructs a new compute node.
|
|
22
24
|
*
|
|
23
|
-
* @param {Node} computeNode -
|
|
24
|
-
* @param {Array<number>} workgroupSize -
|
|
25
|
+
* @param {Node} computeNode - The node that defines the compute shader logic.
|
|
26
|
+
* @param {Array<number>} workgroupSize - An array defining the X, Y, and Z dimensions of the workgroup for compute shader execution.
|
|
25
27
|
*/
|
|
26
28
|
constructor( computeNode, workgroupSize ) {
|
|
27
29
|
|
|
@@ -37,15 +39,14 @@ class ComputeNode extends Node {
|
|
|
37
39
|
this.isComputeNode = true;
|
|
38
40
|
|
|
39
41
|
/**
|
|
40
|
-
*
|
|
42
|
+
* The node that defines the compute shader logic.
|
|
41
43
|
*
|
|
42
44
|
* @type {Node}
|
|
43
45
|
*/
|
|
44
46
|
this.computeNode = computeNode;
|
|
45
47
|
|
|
46
|
-
|
|
47
48
|
/**
|
|
48
|
-
*
|
|
49
|
+
* An array defining the X, Y, and Z dimensions of the workgroup for compute shader execution.
|
|
49
50
|
*
|
|
50
51
|
* @type {Array<number>}
|
|
51
52
|
* @default [ 64 ]
|
|
@@ -53,14 +54,23 @@ class ComputeNode extends Node {
|
|
|
53
54
|
this.workgroupSize = workgroupSize;
|
|
54
55
|
|
|
55
56
|
/**
|
|
56
|
-
*
|
|
57
|
+
* The total number of threads (invocations) to execute. If it is a number, it will be used
|
|
58
|
+
* to automatically generate bounds checking against `instanceIndex`.
|
|
57
59
|
*
|
|
58
60
|
* @type {number|Array<number>}
|
|
59
61
|
*/
|
|
60
62
|
this.count = null;
|
|
61
63
|
|
|
62
64
|
/**
|
|
63
|
-
*
|
|
65
|
+
* The dispatch size for workgroups on X, Y, and Z axes.
|
|
66
|
+
* Used directly if `count` is not provided.
|
|
67
|
+
*
|
|
68
|
+
* @type {number|Array<number>}
|
|
69
|
+
*/
|
|
70
|
+
this.dispatchSize = null;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The version of the node.
|
|
64
74
|
*
|
|
65
75
|
* @type {number}
|
|
66
76
|
*/
|
|
@@ -84,36 +94,19 @@ class ComputeNode extends Node {
|
|
|
84
94
|
this.updateBeforeType = NodeUpdateType.OBJECT;
|
|
85
95
|
|
|
86
96
|
/**
|
|
87
|
-
*
|
|
97
|
+
* A callback executed when the compute node finishes initialization.
|
|
88
98
|
*
|
|
89
99
|
* @type {?Function}
|
|
90
100
|
*/
|
|
91
101
|
this.onInitFunction = null;
|
|
92
102
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
*/
|
|
101
|
-
setCount( count ) {
|
|
102
|
-
|
|
103
|
-
this.count = count;
|
|
104
|
-
|
|
105
|
-
return this;
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* TODO
|
|
111
|
-
*
|
|
112
|
-
* @return {number|Array<number>}
|
|
113
|
-
*/
|
|
114
|
-
getCount() {
|
|
115
|
-
|
|
116
|
-
return this.count;
|
|
103
|
+
/**
|
|
104
|
+
* A uniform node holding the dispatch count for bounds checking.
|
|
105
|
+
* Created automatically when `count` is a number.
|
|
106
|
+
*
|
|
107
|
+
* @type {?UniformNode}
|
|
108
|
+
*/
|
|
109
|
+
this.countNode = null;
|
|
117
110
|
|
|
118
111
|
}
|
|
119
112
|
|
|
@@ -156,9 +149,9 @@ class ComputeNode extends Node {
|
|
|
156
149
|
}
|
|
157
150
|
|
|
158
151
|
/**
|
|
159
|
-
*
|
|
152
|
+
* Sets the callback to run during initialization.
|
|
160
153
|
*
|
|
161
|
-
* @param {Function} callback -
|
|
154
|
+
* @param {Function} callback - The callback function.
|
|
162
155
|
* @return {ComputeNode} A reference to this node.
|
|
163
156
|
*/
|
|
164
157
|
onInit( callback ) {
|
|
@@ -182,6 +175,12 @@ class ComputeNode extends Node {
|
|
|
182
175
|
|
|
183
176
|
setup( builder ) {
|
|
184
177
|
|
|
178
|
+
if ( this.count !== null && this.countNode === null ) {
|
|
179
|
+
|
|
180
|
+
this.countNode = uniform( this.count, 'uint' ).onObjectUpdate( () => this.count );
|
|
181
|
+
|
|
182
|
+
}
|
|
183
|
+
|
|
185
184
|
const result = this.computeNode.build( builder );
|
|
186
185
|
|
|
187
186
|
if ( result ) {
|
|
@@ -211,6 +210,16 @@ class ComputeNode extends Node {
|
|
|
211
210
|
|
|
212
211
|
}
|
|
213
212
|
|
|
213
|
+
if ( this.count !== null && builder.allowEarlyReturns === true ) {
|
|
214
|
+
|
|
215
|
+
const countSnippet = this.countNode.build( builder, 'uint' );
|
|
216
|
+
const indexSnippet = instanceIndex.build( builder, 'uint' );
|
|
217
|
+
|
|
218
|
+
builder.flow.code = `${ builder.tab }if ( ${ indexSnippet } >= ${ countSnippet } ) { return; }\n\n${ builder.flow.code }`;
|
|
219
|
+
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
|
|
214
223
|
} else {
|
|
215
224
|
|
|
216
225
|
const properties = builder.getNodeProperties( this );
|
|
@@ -235,9 +244,9 @@ export default ComputeNode;
|
|
|
235
244
|
*
|
|
236
245
|
* @tsl
|
|
237
246
|
* @function
|
|
238
|
-
* @param {Node} node -
|
|
239
|
-
* @param {Array<number>} [workgroupSize=[64]] -
|
|
240
|
-
* @returns {
|
|
247
|
+
* @param {Node} node - The TSL logic for the compute shader.
|
|
248
|
+
* @param {Array<number>} [workgroupSize=[64]] - The workgroup size.
|
|
249
|
+
* @returns {ComputeNode}
|
|
241
250
|
*/
|
|
242
251
|
export const computeKernel = ( node, workgroupSize = [ 64 ] ) => {
|
|
243
252
|
|
|
@@ -274,12 +283,28 @@ export const computeKernel = ( node, workgroupSize = [ 64 ] ) => {
|
|
|
274
283
|
*
|
|
275
284
|
* @tsl
|
|
276
285
|
* @function
|
|
277
|
-
* @param {Node} node -
|
|
278
|
-
* @param {number|Array<number>} count -
|
|
279
|
-
* @param {Array<number>} [workgroupSize=[64]] -
|
|
280
|
-
* @returns {
|
|
281
|
-
|
|
282
|
-
export const compute = ( node, count, workgroupSize ) =>
|
|
286
|
+
* @param {Node} node - The TSL logic for the compute shader.
|
|
287
|
+
* @param {number|Array<number>} count - The compute count or dispatch size.
|
|
288
|
+
* @param {Array<number>} [workgroupSize=[64]] - The workgroup size.
|
|
289
|
+
* @returns {ComputeNode}
|
|
290
|
+
, */
|
|
291
|
+
export const compute = ( node, count, workgroupSize ) => {
|
|
292
|
+
|
|
293
|
+
const computeNode = computeKernel( node, workgroupSize );
|
|
294
|
+
|
|
295
|
+
if ( typeof count === 'number' ) {
|
|
296
|
+
|
|
297
|
+
computeNode.count = count;
|
|
298
|
+
|
|
299
|
+
} else {
|
|
300
|
+
|
|
301
|
+
computeNode.dispatchSize = count;
|
|
302
|
+
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
return computeNode;
|
|
306
|
+
|
|
307
|
+
};
|
|
283
308
|
|
|
284
309
|
addMethodChaining( 'compute', compute );
|
|
285
310
|
addMethodChaining( 'computeKernel', computeKernel );
|
|
@@ -213,14 +213,12 @@ class LightsNode extends Node {
|
|
|
213
213
|
|
|
214
214
|
if ( previousLightNodes !== null ) {
|
|
215
215
|
|
|
216
|
-
lightNode = getLightNodeById( light.id, previousLightNodes );
|
|
216
|
+
lightNode = getLightNodeById( light.id, previousLightNodes );
|
|
217
217
|
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
if ( lightNode === null ) {
|
|
221
221
|
|
|
222
|
-
// find the corresponding node type for a given light
|
|
223
|
-
|
|
224
222
|
const lightNodeClass = nodeLibrary.getLightNodeClass( light.constructor );
|
|
225
223
|
|
|
226
224
|
if ( lightNodeClass === null ) {
|
|
@@ -230,23 +228,18 @@ class LightsNode extends Node {
|
|
|
230
228
|
|
|
231
229
|
}
|
|
232
230
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
if ( ! _lightsNodeRef.has( light ) ) {
|
|
236
|
-
|
|
237
|
-
lightNode = new lightNodeClass( light );
|
|
238
|
-
_lightsNodeRef.set( light, lightNode );
|
|
231
|
+
if ( _lightsNodeRef.has( light ) === false ) {
|
|
239
232
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
lightNode = _lightsNodeRef.get( light );
|
|
233
|
+
_lightsNodeRef.set( light, new lightNodeClass( light ) );
|
|
243
234
|
|
|
244
235
|
}
|
|
245
236
|
|
|
246
|
-
|
|
237
|
+
lightNode = _lightsNodeRef.get( light );
|
|
247
238
|
|
|
248
239
|
}
|
|
249
240
|
|
|
241
|
+
lightNodes.push( lightNode );
|
|
242
|
+
|
|
250
243
|
}
|
|
251
244
|
|
|
252
245
|
}
|
|
@@ -325,8 +318,6 @@ class LightsNode extends Node {
|
|
|
325
318
|
|
|
326
319
|
builder.lightsNode = this;
|
|
327
320
|
|
|
328
|
-
//
|
|
329
|
-
|
|
330
321
|
let outgoingLightNode = this.outgoingLightNode;
|
|
331
322
|
|
|
332
323
|
const context = builder.context;
|
|
@@ -342,16 +333,10 @@ class LightsNode extends Node {
|
|
|
342
333
|
|
|
343
334
|
const stack = builder.addStack();
|
|
344
335
|
|
|
345
|
-
//
|
|
346
|
-
|
|
347
336
|
properties.nodes = stack.nodes;
|
|
348
337
|
|
|
349
|
-
//
|
|
350
|
-
|
|
351
338
|
lightingModel.start( builder );
|
|
352
339
|
|
|
353
|
-
//
|
|
354
|
-
|
|
355
340
|
const { backdrop, backdropAlpha } = context;
|
|
356
341
|
const { directDiffuse, directSpecular, indirectDiffuse, indirectSpecular } = context.reflectedLight;
|
|
357
342
|
|
|
@@ -376,12 +361,8 @@ class LightsNode extends Node {
|
|
|
376
361
|
|
|
377
362
|
outgoingLightNode.assign( totalDiffuseNode.add( totalSpecularNode ) );
|
|
378
363
|
|
|
379
|
-
//
|
|
380
|
-
|
|
381
364
|
lightingModel.finish( builder );
|
|
382
365
|
|
|
383
|
-
//
|
|
384
|
-
|
|
385
366
|
outgoingLightNode = outgoingLightNode.bypass( builder.removeStack() );
|
|
386
367
|
|
|
387
368
|
} else {
|
|
@@ -390,8 +371,6 @@ class LightsNode extends Node {
|
|
|
390
371
|
|
|
391
372
|
}
|
|
392
373
|
|
|
393
|
-
//
|
|
394
|
-
|
|
395
374
|
builder.lightsNode = currentLightsNode;
|
|
396
375
|
|
|
397
376
|
return outgoingLightNode;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ShadowBaseNode, { shadowPositionWorld } from './ShadowBaseNode.js';
|
|
2
|
-
import { float, vec2, vec3, int, Fn } from '../tsl/TSLBase.js';
|
|
2
|
+
import { float, vec2, vec3, vec4, int, Fn } from '../tsl/TSLBase.js';
|
|
3
3
|
import { reference } from '../accessors/ReferenceNode.js';
|
|
4
4
|
import { texture, textureLoad } from '../accessors/TextureNode.js';
|
|
5
5
|
import { cubeTexture } from '../accessors/CubeTextureNode.js';
|
|
@@ -21,6 +21,8 @@ import { getShadowMaterial, disposeShadowMaterial, BasicShadowFilter, PCFShadowF
|
|
|
21
21
|
import ChainMap from '../../renderers/common/ChainMap.js';
|
|
22
22
|
import { textureSize } from '../accessors/TextureSizeNode.js';
|
|
23
23
|
import { uv } from '../accessors/UV.js';
|
|
24
|
+
import { positionLocal } from '../accessors/Position.js';
|
|
25
|
+
import { uniform } from '../core/UniformNode.js';
|
|
24
26
|
|
|
25
27
|
//
|
|
26
28
|
|
|
@@ -506,7 +508,27 @@ class ShadowNode extends ShadowBaseNode {
|
|
|
506
508
|
const shadowIntensity = reference( 'intensity', 'float', shadow ).setGroup( renderGroup );
|
|
507
509
|
const normalBias = reference( 'normalBias', 'float', shadow ).setGroup( renderGroup );
|
|
508
510
|
|
|
509
|
-
const
|
|
511
|
+
const shadowMatrix = lightShadowMatrix( light );
|
|
512
|
+
const shadowNormalBias = normalWorld.mul( normalBias );
|
|
513
|
+
|
|
514
|
+
let shadowPosition;
|
|
515
|
+
|
|
516
|
+
if ( ! renderer.highPrecision || builder.material.receivedShadowPositionNode || builder.context.shadowPositionWorld ) {
|
|
517
|
+
|
|
518
|
+
shadowPosition = shadowMatrix.mul( shadowPositionWorld.add( shadowNormalBias ) );
|
|
519
|
+
|
|
520
|
+
} else {
|
|
521
|
+
|
|
522
|
+
const highpShadowModelMatrix = uniform( 'mat4' ).onObjectUpdate( ( { object }, self ) => {
|
|
523
|
+
|
|
524
|
+
return self.value.multiplyMatrices( shadowMatrix.value, object.matrixWorld );
|
|
525
|
+
|
|
526
|
+
} );
|
|
527
|
+
|
|
528
|
+
shadowPosition = highpShadowModelMatrix.mul( positionLocal ).add( shadowMatrix.mul( vec4( shadowNormalBias, 0 ) ) );
|
|
529
|
+
|
|
530
|
+
}
|
|
531
|
+
|
|
510
532
|
const shadowCoord = this.setupShadowCoord( builder, shadowPosition );
|
|
511
533
|
|
|
512
534
|
//
|
|
@@ -66,7 +66,7 @@ class ConditionalNode extends Node {
|
|
|
66
66
|
* @param {NodeBuilder} builder - The current node builder.
|
|
67
67
|
* @return {string} The node type.
|
|
68
68
|
*/
|
|
69
|
-
|
|
69
|
+
generateNodeType( builder ) {
|
|
70
70
|
|
|
71
71
|
const { ifNode, elseNode } = builder.getNodeProperties( this );
|
|
72
72
|
|
|
@@ -133,7 +133,7 @@ class MathNode extends TempNode {
|
|
|
133
133
|
* @param {NodeBuilder} builder - The current node builder.
|
|
134
134
|
* @return {string} The node type.
|
|
135
135
|
*/
|
|
136
|
-
|
|
136
|
+
generateNodeType( builder ) {
|
|
137
137
|
|
|
138
138
|
const method = this.method;
|
|
139
139
|
|
|
@@ -345,11 +345,17 @@ MathNode.CEIL = 'ceil';
|
|
|
345
345
|
MathNode.NORMALIZE = 'normalize';
|
|
346
346
|
MathNode.FRACT = 'fract';
|
|
347
347
|
MathNode.SIN = 'sin';
|
|
348
|
+
MathNode.SINH = 'sinh';
|
|
348
349
|
MathNode.COS = 'cos';
|
|
350
|
+
MathNode.COSH = 'cosh';
|
|
349
351
|
MathNode.TAN = 'tan';
|
|
352
|
+
MathNode.TANH = 'tanh';
|
|
350
353
|
MathNode.ASIN = 'asin';
|
|
354
|
+
MathNode.ASINH = 'asinh';
|
|
351
355
|
MathNode.ACOS = 'acos';
|
|
356
|
+
MathNode.ACOSH = 'acosh';
|
|
352
357
|
MathNode.ATAN = 'atan';
|
|
358
|
+
MathNode.ATANH = 'atanh';
|
|
353
359
|
MathNode.ABS = 'abs';
|
|
354
360
|
MathNode.SIGN = 'sign';
|
|
355
361
|
MathNode.LENGTH = 'length';
|
|
@@ -590,6 +596,16 @@ export const fract = /*@__PURE__*/ nodeProxyIntent( MathNode, MathNode.FRACT ).s
|
|
|
590
596
|
*/
|
|
591
597
|
export const sin = /*@__PURE__*/ nodeProxyIntent( MathNode, MathNode.SIN ).setParameterLength( 1 );
|
|
592
598
|
|
|
599
|
+
/**
|
|
600
|
+
* Returns the hyperbolic sine of the parameter.
|
|
601
|
+
*
|
|
602
|
+
* @tsl
|
|
603
|
+
* @function
|
|
604
|
+
* @param {Node | number} x - The parameter.
|
|
605
|
+
* @returns {Node}
|
|
606
|
+
*/
|
|
607
|
+
export const sinh = /*@__PURE__*/ nodeProxyIntent( MathNode, MathNode.SINH ).setParameterLength( 1 );
|
|
608
|
+
|
|
593
609
|
/**
|
|
594
610
|
* Returns the cosine of the parameter.
|
|
595
611
|
*
|
|
@@ -600,6 +616,16 @@ export const sin = /*@__PURE__*/ nodeProxyIntent( MathNode, MathNode.SIN ).setPa
|
|
|
600
616
|
*/
|
|
601
617
|
export const cos = /*@__PURE__*/ nodeProxyIntent( MathNode, MathNode.COS ).setParameterLength( 1 );
|
|
602
618
|
|
|
619
|
+
/**
|
|
620
|
+
* Returns the hyperbolic cosine of the parameter.
|
|
621
|
+
*
|
|
622
|
+
* @tsl
|
|
623
|
+
* @function
|
|
624
|
+
* @param {Node | number} x - The parameter.
|
|
625
|
+
* @returns {Node}
|
|
626
|
+
*/
|
|
627
|
+
export const cosh = /*@__PURE__*/ nodeProxyIntent( MathNode, MathNode.COSH ).setParameterLength( 1 );
|
|
628
|
+
|
|
603
629
|
/**
|
|
604
630
|
* Returns the tangent of the parameter.
|
|
605
631
|
*
|
|
@@ -610,6 +636,16 @@ export const cos = /*@__PURE__*/ nodeProxyIntent( MathNode, MathNode.COS ).setPa
|
|
|
610
636
|
*/
|
|
611
637
|
export const tan = /*@__PURE__*/ nodeProxyIntent( MathNode, MathNode.TAN ).setParameterLength( 1 );
|
|
612
638
|
|
|
639
|
+
/**
|
|
640
|
+
* Returns the hyperbolic tangent of the parameter.
|
|
641
|
+
*
|
|
642
|
+
* @tsl
|
|
643
|
+
* @function
|
|
644
|
+
* @param {Node | number} x - The parameter.
|
|
645
|
+
* @returns {Node}
|
|
646
|
+
*/
|
|
647
|
+
export const tanh = /*@__PURE__*/ nodeProxyIntent( MathNode, MathNode.TANH ).setParameterLength( 1 );
|
|
648
|
+
|
|
613
649
|
/**
|
|
614
650
|
* Returns the arcsine of the parameter.
|
|
615
651
|
*
|
|
@@ -620,6 +656,16 @@ export const tan = /*@__PURE__*/ nodeProxyIntent( MathNode, MathNode.TAN ).setPa
|
|
|
620
656
|
*/
|
|
621
657
|
export const asin = /*@__PURE__*/ nodeProxyIntent( MathNode, MathNode.ASIN ).setParameterLength( 1 );
|
|
622
658
|
|
|
659
|
+
/**
|
|
660
|
+
* Returns the inverse hyperbolic sine of the parameter.
|
|
661
|
+
*
|
|
662
|
+
* @tsl
|
|
663
|
+
* @function
|
|
664
|
+
* @param {Node | number} x - The parameter.
|
|
665
|
+
* @returns {Node}
|
|
666
|
+
*/
|
|
667
|
+
export const asinh = /*@__PURE__*/ nodeProxyIntent( MathNode, MathNode.ASINH ).setParameterLength( 1 );
|
|
668
|
+
|
|
623
669
|
/**
|
|
624
670
|
* Returns the arccosine of the parameter.
|
|
625
671
|
*
|
|
@@ -630,6 +676,16 @@ export const asin = /*@__PURE__*/ nodeProxyIntent( MathNode, MathNode.ASIN ).set
|
|
|
630
676
|
*/
|
|
631
677
|
export const acos = /*@__PURE__*/ nodeProxyIntent( MathNode, MathNode.ACOS ).setParameterLength( 1 );
|
|
632
678
|
|
|
679
|
+
/**
|
|
680
|
+
* Returns the inverse hyperbolic cosine of the parameter.
|
|
681
|
+
*
|
|
682
|
+
* @tsl
|
|
683
|
+
* @function
|
|
684
|
+
* @param {Node | number} x - The parameter.
|
|
685
|
+
* @returns {Node}
|
|
686
|
+
*/
|
|
687
|
+
export const acosh = /*@__PURE__*/ nodeProxyIntent( MathNode, MathNode.ACOSH ).setParameterLength( 1 );
|
|
688
|
+
|
|
633
689
|
/**
|
|
634
690
|
* Returns the arc-tangent of the parameter.
|
|
635
691
|
* If two parameters are provided, the result is `atan2(y/x)`.
|
|
@@ -642,6 +698,16 @@ export const acos = /*@__PURE__*/ nodeProxyIntent( MathNode, MathNode.ACOS ).set
|
|
|
642
698
|
*/
|
|
643
699
|
export const atan = /*@__PURE__*/ nodeProxyIntent( MathNode, MathNode.ATAN ).setParameterLength( 1, 2 );
|
|
644
700
|
|
|
701
|
+
/**
|
|
702
|
+
* Returns the inverse hyperbolic tangent of the parameter.
|
|
703
|
+
*
|
|
704
|
+
* @tsl
|
|
705
|
+
* @function
|
|
706
|
+
* @param {Node | number} x - The parameter.
|
|
707
|
+
* @returns {Node}
|
|
708
|
+
*/
|
|
709
|
+
export const atanh = /*@__PURE__*/ nodeProxyIntent( MathNode, MathNode.ATANH ).setParameterLength( 1 );
|
|
710
|
+
|
|
645
711
|
/**
|
|
646
712
|
* Returns the absolute value of the parameter.
|
|
647
713
|
*
|
|
@@ -1087,11 +1153,17 @@ addMethodChaining( 'ceil', ceil );
|
|
|
1087
1153
|
addMethodChaining( 'normalize', normalize );
|
|
1088
1154
|
addMethodChaining( 'fract', fract );
|
|
1089
1155
|
addMethodChaining( 'sin', sin );
|
|
1156
|
+
addMethodChaining( 'sinh', sinh );
|
|
1090
1157
|
addMethodChaining( 'cos', cos );
|
|
1158
|
+
addMethodChaining( 'cosh', cosh );
|
|
1091
1159
|
addMethodChaining( 'tan', tan );
|
|
1160
|
+
addMethodChaining( 'tanh', tanh );
|
|
1092
1161
|
addMethodChaining( 'asin', asin );
|
|
1162
|
+
addMethodChaining( 'asinh', asinh );
|
|
1093
1163
|
addMethodChaining( 'acos', acos );
|
|
1164
|
+
addMethodChaining( 'acosh', acosh );
|
|
1094
1165
|
addMethodChaining( 'atan', atan );
|
|
1166
|
+
addMethodChaining( 'atanh', atanh );
|
|
1095
1167
|
addMethodChaining( 'abs', abs );
|
|
1096
1168
|
addMethodChaining( 'sign', sign );
|
|
1097
1169
|
addMethodChaining( 'length', length );
|
|
@@ -108,7 +108,7 @@ class OperatorNode extends TempNode {
|
|
|
108
108
|
* @param {?string} [output=null] - The output type.
|
|
109
109
|
* @return {string} The node type.
|
|
110
110
|
*/
|
|
111
|
-
|
|
111
|
+
generateNodeType( builder, output = null ) {
|
|
112
112
|
|
|
113
113
|
const op = this.op;
|
|
114
114
|
|
package/src/nodes/tsl/TSLBase.js
CHANGED
|
@@ -21,7 +21,7 @@ export * from '../accessors/BufferAttributeNode.js'; // .toAttribute()
|
|
|
21
21
|
export * from '../gpgpu/ComputeNode.js'; // .compute()
|
|
22
22
|
export * from '../core/IsolateNode.js'; // .isolate()
|
|
23
23
|
export * from '../core/BypassNode.js'; // .bypass()
|
|
24
|
-
export * from '../utils/
|
|
24
|
+
export * from '../utils/Remap.js'; // .remap(), .remapClamp()
|
|
25
25
|
export * from '../code/ExpressionNode.js'; // expression()
|
|
26
26
|
export * from '../utils/Discard.js'; // Discard(), Return()
|
|
27
27
|
export * from '../display/RenderOutputNode.js'; // .renderOutput()
|
package/src/nodes/tsl/TSLCore.js
CHANGED
|
@@ -461,7 +461,7 @@ class ShaderCallNodeInternal extends Node {
|
|
|
461
461
|
|
|
462
462
|
}
|
|
463
463
|
|
|
464
|
-
|
|
464
|
+
generateNodeType( builder ) {
|
|
465
465
|
|
|
466
466
|
return this.shaderNode.nodeType || this.getOutputNode( builder ).getNodeType( builder );
|
|
467
467
|
|
|
@@ -917,7 +917,25 @@ const ConvertType = function ( type, cacheMap = null ) {
|
|
|
917
917
|
|
|
918
918
|
// exports
|
|
919
919
|
|
|
920
|
-
export
|
|
920
|
+
export function defined( value ) {
|
|
921
|
+
|
|
922
|
+
if ( value && value.isNode ) {
|
|
923
|
+
|
|
924
|
+
value.traverse( ( node ) => {
|
|
925
|
+
|
|
926
|
+
if ( node.isConstNode ) {
|
|
927
|
+
|
|
928
|
+
value = node.value;
|
|
929
|
+
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
} );
|
|
933
|
+
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
return Boolean( value );
|
|
937
|
+
|
|
938
|
+
}
|
|
921
939
|
|
|
922
940
|
// utils
|
|
923
941
|
|
|
@@ -1018,7 +1036,7 @@ class FnNode extends Node {
|
|
|
1018
1036
|
|
|
1019
1037
|
}
|
|
1020
1038
|
|
|
1021
|
-
|
|
1039
|
+
generateNodeType( builder ) {
|
|
1022
1040
|
|
|
1023
1041
|
return this.shaderNode.getNodeType( builder ) || 'float';
|
|
1024
1042
|
|
|
@@ -55,7 +55,7 @@ class ArrayElementNode extends Node { // @TODO: If extending from TempNode it br
|
|
|
55
55
|
* @param {NodeBuilder} builder - The current node builder.
|
|
56
56
|
* @return {string} The node type.
|
|
57
57
|
*/
|
|
58
|
-
|
|
58
|
+
generateNodeType( builder ) {
|
|
59
59
|
|
|
60
60
|
return this.node.getElementType( builder );
|
|
61
61
|
|
|
@@ -48,7 +48,7 @@ class ConvertNode extends Node {
|
|
|
48
48
|
* @param {NodeBuilder} builder - The current node builder.
|
|
49
49
|
* @return {string} The node type.
|
|
50
50
|
*/
|
|
51
|
-
|
|
51
|
+
generateNodeType( builder ) {
|
|
52
52
|
|
|
53
53
|
const requestType = this.node.getNodeType( builder );
|
|
54
54
|
|