@plastic-software/three 0.183.4 → 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.
Files changed (277) hide show
  1. package/build/three.cjs +773 -286
  2. package/build/three.core.js +372 -110
  3. package/build/three.core.min.js +1 -1
  4. package/build/three.module.js +426 -180
  5. package/build/three.module.min.js +1 -1
  6. package/build/three.tsl.js +7 -1
  7. package/build/three.tsl.min.js +1 -1
  8. package/build/three.webgpu.js +2979 -1281
  9. package/build/three.webgpu.min.js +1 -1
  10. package/build/three.webgpu.nodes.js +2942 -1281
  11. package/build/three.webgpu.nodes.min.js +1 -1
  12. package/examples/jsm/Addons.js +11 -0
  13. package/examples/jsm/animation/CCDIKSolver.js +5 -1
  14. package/examples/jsm/controls/ArcballControls.js +4 -1
  15. package/examples/jsm/controls/DragControls.js +2 -2
  16. package/examples/jsm/controls/FirstPersonControls.js +58 -54
  17. package/examples/jsm/controls/FlyControls.js +4 -0
  18. package/examples/jsm/controls/OrbitControls.js +2 -2
  19. package/examples/jsm/controls/TrackballControls.js +2 -2
  20. package/examples/jsm/controls/TransformControls.js +34 -2
  21. package/examples/jsm/csm/CSMShadowNode.js +6 -2
  22. package/examples/jsm/exporters/GLTFExporter.js +21 -5
  23. package/examples/jsm/geometries/TextGeometry.js +18 -0
  24. package/examples/jsm/helpers/LightProbeGridHelper.js +221 -0
  25. package/examples/jsm/inspector/Extension.js +13 -0
  26. package/examples/jsm/inspector/Inspector.js +169 -114
  27. package/examples/jsm/inspector/RendererInspector.js +2 -2
  28. package/examples/jsm/inspector/extensions/extensions.json +6 -0
  29. package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphEditor.js +916 -0
  30. package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphLoader.js +281 -0
  31. package/examples/jsm/inspector/tabs/Memory.js +128 -0
  32. package/examples/jsm/inspector/tabs/Parameters.js +34 -2
  33. package/examples/jsm/inspector/tabs/Performance.js +2 -2
  34. package/examples/jsm/inspector/tabs/Settings.js +264 -0
  35. package/examples/jsm/inspector/tabs/Timeline.js +1611 -0
  36. package/examples/jsm/inspector/tabs/Viewer.js +105 -3
  37. package/examples/jsm/inspector/ui/Graph.js +2 -2
  38. package/examples/jsm/inspector/ui/List.js +1 -1
  39. package/examples/jsm/inspector/ui/Profiler.js +273 -176
  40. package/examples/jsm/inspector/ui/Style.js +64 -10
  41. package/examples/jsm/inspector/ui/Tab.js +39 -7
  42. package/examples/jsm/inspector/ui/Values.js +39 -2
  43. package/examples/jsm/inspector/ui/utils.js +13 -0
  44. package/examples/jsm/interaction/InteractionManager.js +226 -0
  45. package/examples/jsm/libs/meshopt_decoder.module.js +8 -8
  46. package/examples/jsm/lighting/DynamicLighting.js +82 -0
  47. package/examples/jsm/lighting/LightProbeGrid.js +651 -0
  48. package/examples/jsm/lines/LineMaterial.js +1 -1
  49. package/examples/jsm/loaders/EXRLoader.js +682 -43
  50. package/examples/jsm/loaders/FBXLoader.js +233 -33
  51. package/examples/jsm/loaders/GLTFLoader.js +24 -7
  52. package/examples/jsm/loaders/HDRLoader.js +1 -1
  53. package/examples/jsm/loaders/KTX2Loader.js +8 -2
  54. package/examples/jsm/loaders/LDrawLoader.js +39 -47
  55. package/examples/jsm/loaders/SVGLoader.js +1 -1
  56. package/examples/jsm/loaders/VTKLoader.js +5 -1
  57. package/examples/jsm/loaders/collada/ColladaComposer.js +101 -7
  58. package/examples/jsm/loaders/collada/ColladaParser.js +19 -4
  59. package/examples/jsm/loaders/usd/USDAParser.js +6 -0
  60. package/examples/jsm/loaders/usd/USDCParser.js +26 -0
  61. package/examples/jsm/loaders/usd/USDComposer.js +656 -103
  62. package/examples/jsm/misc/GPUComputationRenderer.js +2 -0
  63. package/examples/jsm/misc/RollerCoaster.js +42 -4
  64. package/examples/jsm/modifiers/TessellateModifier.js +1 -1
  65. package/examples/jsm/objects/Reflector.js +73 -25
  66. package/examples/jsm/objects/Sky.js +14 -2
  67. package/examples/jsm/objects/SkyMesh.js +23 -6
  68. package/examples/jsm/renderers/Projector.js +18 -38
  69. package/examples/jsm/renderers/SVGRenderer.js +6 -25
  70. package/examples/jsm/transpiler/GLSLDecoder.js +2 -2
  71. package/examples/jsm/tsl/WebGLNodesHandler.js +605 -0
  72. package/examples/jsm/tsl/display/AfterImageNode.js +10 -0
  73. package/examples/jsm/tsl/display/AnamorphicNode.js +11 -0
  74. package/examples/jsm/tsl/display/BilateralBlurNode.js +10 -0
  75. package/examples/jsm/tsl/display/ChromaticAberrationNode.js +3 -36
  76. package/examples/jsm/tsl/display/FSR1Node.js +477 -0
  77. package/examples/jsm/tsl/display/GTAONode.js +2 -1
  78. package/examples/jsm/tsl/display/GaussianBlurNode.js +10 -0
  79. package/examples/jsm/tsl/display/GodraysNode.js +2 -11
  80. package/examples/jsm/tsl/display/OutlineNode.js +66 -16
  81. package/examples/jsm/tsl/display/SSGINode.js +0 -4
  82. package/examples/jsm/tsl/display/SharpenNode.js +283 -0
  83. package/examples/jsm/tsl/display/TAAUNode.js +835 -0
  84. package/examples/jsm/tsl/display/TRAANode.js +48 -7
  85. package/examples/jsm/tsl/lighting/DynamicLightsNode.js +300 -0
  86. package/examples/jsm/tsl/lighting/data/AmbientLightDataNode.js +61 -0
  87. package/examples/jsm/tsl/lighting/data/DirectionalLightDataNode.js +111 -0
  88. package/examples/jsm/tsl/lighting/data/HemisphereLightDataNode.js +99 -0
  89. package/examples/jsm/tsl/lighting/data/PointLightDataNode.js +134 -0
  90. package/examples/jsm/tsl/lighting/data/SpotLightDataNode.js +161 -0
  91. package/examples/jsm/tsl/math/Bayer.js +13 -2
  92. package/examples/jsm/utils/BufferGeometryUtils.js +2 -3
  93. package/examples/jsm/utils/ColorUtils.js +76 -0
  94. package/examples/jsm/utils/SkeletonUtils.js +14 -8
  95. package/examples/jsm/webxr/XRHandMeshModel.js +36 -10
  96. package/examples/jsm/webxr/XRHandModelFactory.js +2 -1
  97. package/package.json +4 -4
  98. package/src/Three.Core.js +1 -0
  99. package/src/Three.TSL.js +6 -0
  100. package/src/Three.WebGPU.Nodes.js +3 -0
  101. package/src/Three.WebGPU.js +6 -0
  102. package/src/animation/AnimationAction.js +11 -1
  103. package/src/audio/AudioContext.js +2 -2
  104. package/src/constants.js +1 -1
  105. package/src/core/BufferAttribute.js +13 -1
  106. package/src/core/Clock.js +1 -1
  107. package/src/core/Object3D.js +1 -5
  108. package/src/core/RenderTarget.js +1 -0
  109. package/src/extras/curves/CatmullRomCurve3.js +3 -2
  110. package/src/loaders/AudioLoader.js +11 -1
  111. package/src/loaders/DataTextureLoader.js +6 -4
  112. package/src/loaders/FileLoader.js +1 -2
  113. package/src/loaders/ImageBitmapLoader.js +4 -6
  114. package/src/loaders/MaterialLoader.js +1 -1
  115. package/src/loaders/ObjectLoader.js +25 -4
  116. package/src/loaders/nodes/NodeObjectLoader.js +18 -0
  117. package/src/materials/MeshToonMaterial.js +1 -1
  118. package/src/materials/nodes/Line2NodeMaterial.js +27 -0
  119. package/src/materials/nodes/NodeMaterial.js +0 -27
  120. package/src/materials/nodes/manager/NodeMaterialObserver.js +188 -89
  121. package/src/math/Line3.js +3 -0
  122. package/src/math/Matrix2.js +13 -9
  123. package/src/math/Matrix3.js +13 -9
  124. package/src/math/Matrix4.js +13 -9
  125. package/src/math/Plane.js +4 -3
  126. package/src/math/Triangle.js +1 -1
  127. package/src/math/Vector2.js +11 -7
  128. package/src/math/Vector3.js +12 -8
  129. package/src/math/Vector4.js +13 -9
  130. package/src/nodes/Nodes.js +0 -1
  131. package/src/nodes/TSL.js +1 -1
  132. package/src/nodes/accessors/BufferAttributeNode.js +9 -3
  133. package/src/nodes/accessors/CubeTextureNode.js +7 -1
  134. package/src/nodes/accessors/MaterialProperties.js +2 -5
  135. package/src/nodes/accessors/Object3DNode.js +1 -1
  136. package/src/nodes/accessors/ReferenceBaseNode.js +2 -2
  137. package/src/nodes/accessors/ReferenceNode.js +4 -4
  138. package/src/nodes/accessors/SceneProperties.js +2 -8
  139. package/src/nodes/accessors/StorageBufferNode.js +10 -4
  140. package/src/nodes/accessors/StorageTextureNode.js +4 -9
  141. package/src/nodes/accessors/TextureNode.js +10 -2
  142. package/src/nodes/accessors/UniformArrayNode.js +2 -2
  143. package/src/nodes/code/FunctionCallNode.js +1 -1
  144. package/src/nodes/code/FunctionNode.js +1 -1
  145. package/src/nodes/core/ArrayNode.js +1 -1
  146. package/src/nodes/core/AssignNode.js +1 -1
  147. package/src/nodes/core/AttributeNode.js +1 -1
  148. package/src/nodes/core/BypassNode.js +1 -1
  149. package/src/nodes/core/ContextNode.js +1 -1
  150. package/src/nodes/core/IndexNode.js +2 -1
  151. package/src/nodes/core/InputNode.js +1 -1
  152. package/src/nodes/core/InspectorNode.js +1 -1
  153. package/src/nodes/core/IsolateNode.js +1 -1
  154. package/src/nodes/core/Node.js +83 -12
  155. package/src/nodes/core/NodeBuilder.js +117 -16
  156. package/src/nodes/core/NodeUtils.js +1 -1
  157. package/src/nodes/core/OutputStructNode.js +1 -1
  158. package/src/nodes/core/ParameterNode.js +1 -1
  159. package/src/nodes/core/StackNode.js +1 -1
  160. package/src/nodes/core/StructNode.js +1 -1
  161. package/src/nodes/core/StructTypeNode.js +1 -1
  162. package/src/nodes/core/SubBuildNode.js +1 -1
  163. package/src/nodes/core/UniformGroupNode.js +36 -6
  164. package/src/nodes/core/VarNode.js +1 -1
  165. package/src/nodes/core/VaryingNode.js +1 -1
  166. package/src/nodes/display/NormalMapNode.js +2 -2
  167. package/src/nodes/display/PassNode.js +27 -7
  168. package/src/nodes/display/RenderOutputNode.js +4 -4
  169. package/src/nodes/display/ScreenNode.js +1 -1
  170. package/src/nodes/display/ViewportDepthTextureNode.js +11 -15
  171. package/src/nodes/display/ViewportTextureNode.js +18 -7
  172. package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
  173. package/src/nodes/geometry/RangeNode.js +1 -1
  174. package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
  175. package/src/nodes/gpgpu/BarrierNode.js +9 -0
  176. package/src/nodes/gpgpu/ComputeBuiltinNode.js +1 -1
  177. package/src/nodes/gpgpu/ComputeNode.js +69 -44
  178. package/src/nodes/gpgpu/SubgroupFunctionNode.js +1 -1
  179. package/src/nodes/lighting/LightsNode.js +6 -27
  180. package/src/nodes/lighting/ShadowNode.js +24 -2
  181. package/src/nodes/math/BitcastNode.js +1 -1
  182. package/src/nodes/math/ConditionalNode.js +1 -1
  183. package/src/nodes/math/MathNode.js +73 -1
  184. package/src/nodes/math/OperatorNode.js +1 -1
  185. package/src/nodes/math/PackFloatNode.js +1 -1
  186. package/src/nodes/math/UnpackFloatNode.js +1 -1
  187. package/src/nodes/tsl/TSLBase.js +1 -1
  188. package/src/nodes/tsl/TSLCore.js +21 -3
  189. package/src/nodes/utils/ArrayElementNode.js +1 -1
  190. package/src/nodes/utils/ConvertNode.js +1 -1
  191. package/src/nodes/utils/DebugNode.js +1 -1
  192. package/src/nodes/utils/EventNode.js +30 -0
  193. package/src/nodes/utils/FlipNode.js +1 -1
  194. package/src/nodes/utils/FunctionOverloadingNode.js +1 -1
  195. package/src/nodes/utils/JoinNode.js +1 -1
  196. package/src/nodes/utils/MemberNode.js +1 -1
  197. package/src/nodes/utils/Remap.js +48 -0
  198. package/src/nodes/utils/RotateNode.js +1 -1
  199. package/src/nodes/utils/SetNode.js +1 -1
  200. package/src/nodes/utils/SplitNode.js +1 -1
  201. package/src/objects/BatchedMesh.js +17 -2
  202. package/src/objects/InstancedMesh.js +19 -3
  203. package/src/objects/SkinnedMesh.js +26 -9
  204. package/src/renderers/WebGLRenderer.js +147 -48
  205. package/src/renderers/common/Animation.js +3 -3
  206. package/src/renderers/common/Attributes.js +15 -1
  207. package/src/renderers/common/Backend.js +0 -8
  208. package/src/renderers/common/Background.js +2 -2
  209. package/src/renderers/common/BindGroup.js +1 -8
  210. package/src/renderers/common/Bindings.js +2 -2
  211. package/src/renderers/common/ComputePipeline.js +1 -1
  212. package/src/renderers/common/CubeRenderTarget.js +1 -1
  213. package/src/renderers/common/Info.js +333 -4
  214. package/src/renderers/common/InspectorBase.js +6 -1
  215. package/src/renderers/common/Pipelines.js +36 -3
  216. package/src/renderers/common/ReadbackBuffer.js +78 -0
  217. package/src/renderers/common/RenderBundle.js +3 -1
  218. package/src/renderers/common/RenderBundles.js +5 -2
  219. package/src/renderers/common/RenderObject.js +2 -2
  220. package/src/renderers/common/RenderObjects.js +3 -3
  221. package/src/renderers/common/RenderPipeline.js +35 -6
  222. package/src/renderers/common/Renderer.js +232 -53
  223. package/src/renderers/common/Textures.js +72 -3
  224. package/src/renderers/common/UniformsGroup.js +1 -1
  225. package/src/renderers/common/XRManager.js +34 -27
  226. package/src/renderers/common/extras/PMREMGenerator.js +23 -15
  227. package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
  228. package/src/renderers/common/nodes/NodeManager.js +230 -99
  229. package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +0 -1
  230. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +1 -1
  231. package/src/renderers/shaders/ShaderChunk/lightprobes_pars_fragment.glsl.js +80 -0
  232. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +8 -0
  233. package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +2 -0
  234. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +1 -3
  235. package/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js +7 -0
  236. package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +0 -1
  237. package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +12 -2
  238. package/src/renderers/shaders/ShaderChunk.js +2 -0
  239. package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +1 -2
  240. package/src/renderers/shaders/ShaderLib.js +0 -1
  241. package/src/renderers/shaders/UniformsLib.js +7 -2
  242. package/src/renderers/shaders/UniformsUtils.js +27 -5
  243. package/src/renderers/webgl/WebGLAnimation.js +2 -1
  244. package/src/renderers/webgl/WebGLBackground.js +13 -13
  245. package/src/renderers/webgl/WebGLBufferRenderer.js +0 -32
  246. package/src/renderers/webgl/WebGLCapabilities.js +6 -0
  247. package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +0 -32
  248. package/src/renderers/webgl/WebGLMaterials.js +12 -13
  249. package/src/renderers/webgl/WebGLOutput.js +4 -1
  250. package/src/renderers/webgl/WebGLProgram.js +4 -0
  251. package/src/renderers/webgl/WebGLPrograms.js +19 -3
  252. package/src/renderers/webgl/WebGLRenderStates.js +13 -2
  253. package/src/renderers/webgl/WebGLState.js +43 -0
  254. package/src/renderers/webgl/WebGLTextures.js +129 -26
  255. package/src/renderers/webgl/WebGLUniformsGroups.js +19 -0
  256. package/src/renderers/webgl-fallback/WebGLBackend.js +106 -65
  257. package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +0 -41
  258. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +29 -51
  259. package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +53 -19
  260. package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +25 -0
  261. package/src/renderers/webgl-fallback/utils/WebGLState.js +42 -1
  262. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +63 -50
  263. package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +1 -1
  264. package/src/renderers/webgpu/WebGPUBackend.js +160 -146
  265. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +55 -33
  266. package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +103 -17
  267. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +1 -1
  268. package/src/renderers/webgpu/utils/WebGPUCapabilities.js +48 -0
  269. package/src/renderers/webgpu/utils/WebGPUConstants.js +8 -0
  270. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +91 -17
  271. package/src/renderers/webgpu/utils/WebGPUUtils.js +18 -2
  272. package/src/renderers/webxr/WebXRController.js +12 -0
  273. package/src/textures/HTMLTexture.js +74 -0
  274. package/src/textures/Source.js +1 -1
  275. package/src/textures/Texture.js +13 -2
  276. package/src/utils.js +23 -1
  277. package/src/nodes/utils/RemapNode.js +0 -125
@@ -21,6 +21,15 @@ class BarrierNode extends Node {
21
21
 
22
22
  this.scope = scope;
23
23
 
24
+ this.isBarrierNode = true;
25
+
26
+ }
27
+
28
+ setup( builder ) {
29
+
30
+ builder.allowEarlyReturns = false;
31
+ builder.allowGlobalVariables = false;
32
+
24
33
  }
25
34
 
26
35
  generate( builder ) {
@@ -55,7 +55,7 @@ class ComputeBuiltinNode extends Node {
55
55
  * @param {NodeBuilder} builder - The current node builder.
56
56
  * @return {string} The node type.
57
57
  */
58
- getNodeType( /*builder*/ ) {
58
+ generateNodeType( /*builder*/ ) {
59
59
 
60
60
  return this.nodeType;
61
61
 
@@ -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
- * TODO
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 - TODO
24
- * @param {Array<number>} workgroupSize - TODO.
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
- * TODO
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
- * TODO
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
- * TODO
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
- * TODO
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
- * TODO
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
- * TODO
97
- *
98
- * @param {number|Array<number>} count - Array with [ x, y, z ] values for dispatch or a single number for the count
99
- * @return {ComputeNode}
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
- * TODO
152
+ * Sets the callback to run during initialization.
160
153
  *
161
- * @param {Function} callback - TODO.
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 - TODO
239
- * @param {Array<number>} [workgroupSize=[64]] - TODO.
240
- * @returns {AtomicFunctionNode}
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 - TODO
278
- * @param {number|Array<number>} count - TODO.
279
- * @param {Array<number>} [workgroupSize=[64]] - TODO.
280
- * @returns {AtomicFunctionNode}
281
- */
282
- export const compute = ( node, count, workgroupSize ) => computeKernel( node, workgroupSize ).setCount( count );
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 );
@@ -75,7 +75,7 @@ class SubgroupFunctionNode extends TempNode {
75
75
 
76
76
  }
77
77
 
78
- getNodeType( builder ) {
78
+ generateNodeType( builder ) {
79
79
 
80
80
  const method = this.method;
81
81
 
@@ -213,14 +213,12 @@ class LightsNode extends Node {
213
213
 
214
214
  if ( previousLightNodes !== null ) {
215
215
 
216
- lightNode = getLightNodeById( light.id, previousLightNodes ); // reuse existing light node
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
- let lightNode = null;
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
- } else {
241
-
242
- lightNode = _lightsNodeRef.get( light );
233
+ _lightsNodeRef.set( light, new lightNodeClass( light ) );
243
234
 
244
235
  }
245
236
 
246
- lightNodes.push( lightNode );
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 shadowPosition = lightShadowMatrix( light ).mul( shadowPositionWorld.add( normalWorld.mul( normalBias ) ) );
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
  //
@@ -60,7 +60,7 @@ class BitcastNode extends TempNode {
60
60
 
61
61
  }
62
62
 
63
- getNodeType( builder ) {
63
+ generateNodeType( builder ) {
64
64
 
65
65
  // GLSL aliasing
66
66
  if ( this.inputType !== null ) {
@@ -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
- getNodeType( builder ) {
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
- getNodeType( builder ) {
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
- getNodeType( builder, output = null ) {
111
+ generateNodeType( builder, output = null ) {
112
112
 
113
113
  const op = this.op;
114
114
 
@@ -48,7 +48,7 @@ class PackFloatNode extends TempNode {
48
48
 
49
49
  }
50
50
 
51
- getNodeType() {
51
+ generateNodeType() {
52
52
 
53
53
  return 'uint';
54
54
 
@@ -48,7 +48,7 @@ class UnpackFloatNode extends TempNode {
48
48
 
49
49
  }
50
50
 
51
- getNodeType() {
51
+ generateNodeType() {
52
52
 
53
53
  return 'vec2';
54
54
 
@@ -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/RemapNode.js'; // .remap(), .remapClamp()
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()
@@ -461,7 +461,7 @@ class ShaderCallNodeInternal extends Node {
461
461
 
462
462
  }
463
463
 
464
- getNodeType( builder ) {
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 const defined = ( v ) => typeof v === 'object' && v !== null ? v.value : v; // TODO: remove boolean conversion and defined function
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
- getNodeType( builder ) {
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
- getNodeType( builder ) {
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
- getNodeType( builder ) {
51
+ generateNodeType( builder ) {
52
52
 
53
53
  const requestType = this.node.getNodeType( builder );
54
54
 
@@ -19,7 +19,7 @@ class DebugNode extends TempNode {
19
19
 
20
20
  }
21
21
 
22
- getNodeType( builder ) {
22
+ generateNodeType( builder ) {
23
23
 
24
24
  return this.node.getNodeType( builder );
25
25