super-three 0.177.0 → 0.179.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 (211) hide show
  1. package/README.md +1 -1
  2. package/build/three.cjs +959 -231
  3. package/build/three.core.js +751 -170
  4. package/build/three.core.min.js +1 -1
  5. package/build/three.module.js +210 -64
  6. package/build/three.module.min.js +1 -1
  7. package/build/three.tsl.js +78 -29
  8. package/build/three.tsl.min.js +1 -1
  9. package/build/three.webgpu.js +3269 -1545
  10. package/build/three.webgpu.min.js +1 -1
  11. package/build/three.webgpu.nodes.js +3093 -1545
  12. package/build/three.webgpu.nodes.min.js +1 -1
  13. package/examples/jsm/Addons.js +1 -2
  14. package/examples/jsm/capabilities/WebGL.js +0 -27
  15. package/examples/jsm/capabilities/WebGPU.js +1 -1
  16. package/examples/jsm/controls/ArcballControls.js +1 -1
  17. package/examples/jsm/controls/TransformControls.js +61 -14
  18. package/examples/jsm/csm/CSMShadowNode.js +4 -4
  19. package/examples/jsm/environments/RoomEnvironment.js +8 -3
  20. package/examples/jsm/exporters/USDZExporter.js +676 -299
  21. package/examples/jsm/geometries/RoundedBoxGeometry.js +47 -8
  22. package/examples/jsm/interactive/HTMLMesh.js +5 -3
  23. package/examples/jsm/libs/meshopt_decoder.module.js +75 -58
  24. package/examples/jsm/lights/LightProbeGenerator.js +14 -3
  25. package/examples/jsm/loaders/ColladaLoader.js +1 -1
  26. package/examples/jsm/loaders/EXRLoader.js +210 -22
  27. package/examples/jsm/loaders/FBXLoader.js +2 -2
  28. package/examples/jsm/loaders/MaterialXLoader.js +212 -30
  29. package/examples/jsm/loaders/TTFLoader.js +13 -1
  30. package/examples/jsm/loaders/USDLoader.js +219 -0
  31. package/examples/jsm/loaders/USDZLoader.js +4 -892
  32. package/examples/jsm/loaders/usd/USDAParser.js +741 -0
  33. package/examples/jsm/loaders/usd/USDCParser.js +17 -0
  34. package/examples/jsm/objects/LensflareMesh.js +3 -3
  35. package/examples/jsm/objects/SkyMesh.js +2 -2
  36. package/examples/jsm/physics/RapierPhysics.js +95 -16
  37. package/examples/jsm/postprocessing/GTAOPass.js +10 -9
  38. package/examples/jsm/postprocessing/OutlinePass.js +17 -17
  39. package/examples/jsm/postprocessing/SSAOPass.js +10 -9
  40. package/examples/jsm/shaders/UnpackDepthRGBAShader.js +11 -2
  41. package/examples/jsm/transpiler/AST.js +381 -30
  42. package/examples/jsm/transpiler/GLSLDecoder.js +226 -86
  43. package/examples/jsm/transpiler/Linker.js +327 -0
  44. package/examples/jsm/transpiler/TSLEncoder.js +197 -92
  45. package/examples/jsm/transpiler/Transpiler.js +17 -1
  46. package/examples/jsm/transpiler/TranspilerUtils.js +29 -0
  47. package/examples/jsm/transpiler/WGSLEncoder.js +788 -0
  48. package/examples/jsm/tsl/display/BloomNode.js +8 -7
  49. package/examples/jsm/tsl/display/ChromaticAberrationNode.js +206 -0
  50. package/examples/jsm/tsl/display/GaussianBlurNode.js +8 -10
  51. package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
  52. package/examples/jsm/tsl/display/{TRAAPassNode.js → TRAANode.js} +181 -172
  53. package/examples/jsm/tsl/display/hashBlur.js +3 -3
  54. package/examples/jsm/tsl/lighting/TiledLightsNode.js +1 -1
  55. package/package.json +1 -1
  56. package/src/Three.Core.js +1 -0
  57. package/src/Three.TSL.js +77 -28
  58. package/src/Three.WebGPU.js +2 -0
  59. package/src/animation/KeyframeTrack.js +1 -1
  60. package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
  61. package/src/animation/tracks/StringKeyframeTrack.js +1 -1
  62. package/src/cameras/Camera.js +14 -0
  63. package/src/cameras/OrthographicCamera.js +1 -1
  64. package/src/cameras/PerspectiveCamera.js +1 -1
  65. package/src/constants.js +3 -3
  66. package/src/core/BufferAttribute.js +3 -3
  67. package/src/core/Clock.js +2 -8
  68. package/src/core/GLBufferAttribute.js +13 -1
  69. package/src/core/Object3D.js +1 -1
  70. package/{examples/jsm/misc → src/core}/Timer.js +4 -42
  71. package/src/extras/PMREMGenerator.js +11 -0
  72. package/src/extras/core/Path.js +22 -22
  73. package/src/helpers/CameraHelper.js +41 -11
  74. package/src/helpers/SkeletonHelper.js +35 -6
  75. package/src/lights/LightShadow.js +21 -8
  76. package/src/lights/PointLightShadow.js +1 -1
  77. package/src/loaders/FileLoader.js +27 -4
  78. package/src/loaders/ImageBitmapLoader.js +27 -4
  79. package/src/loaders/ImageLoader.js +55 -8
  80. package/src/loaders/Loader.js +14 -0
  81. package/src/loaders/LoadingManager.js +23 -0
  82. package/src/materials/MeshBasicMaterial.js +1 -1
  83. package/src/materials/nodes/Line2NodeMaterial.js +0 -8
  84. package/src/materials/nodes/MeshBasicNodeMaterial.js +4 -3
  85. package/src/materials/nodes/MeshMatcapNodeMaterial.js +1 -1
  86. package/src/materials/nodes/MeshNormalNodeMaterial.js +2 -2
  87. package/src/materials/nodes/MeshPhysicalNodeMaterial.js +2 -1
  88. package/src/materials/nodes/MeshSSSNodeMaterial.js +2 -2
  89. package/src/materials/nodes/NodeMaterial.js +28 -5
  90. package/src/materials/nodes/PointsNodeMaterial.js +5 -0
  91. package/src/materials/nodes/manager/NodeMaterialObserver.js +87 -2
  92. package/src/math/Frustum.js +25 -9
  93. package/src/math/FrustumArray.js +10 -5
  94. package/src/math/Line3.js +129 -2
  95. package/src/math/Matrix4.js +48 -27
  96. package/src/math/Quaternion.js +1 -1
  97. package/src/math/Spherical.js +2 -2
  98. package/src/nodes/Nodes.js +2 -3
  99. package/src/nodes/TSL.js +5 -3
  100. package/src/nodes/accessors/AccessorsUtils.js +7 -8
  101. package/src/nodes/accessors/Bitangent.js +31 -25
  102. package/src/nodes/accessors/Camera.js +12 -12
  103. package/src/nodes/accessors/Normal.js +95 -29
  104. package/src/nodes/accessors/Object3DNode.js +1 -1
  105. package/src/nodes/accessors/Position.js +7 -7
  106. package/src/nodes/accessors/ReferenceNode.js +18 -3
  107. package/src/nodes/accessors/ReflectVector.js +3 -3
  108. package/src/nodes/accessors/SceneNode.js +1 -1
  109. package/src/nodes/accessors/StorageTextureNode.js +1 -1
  110. package/src/nodes/accessors/Tangent.js +25 -17
  111. package/src/nodes/accessors/TangentUtils.js +46 -0
  112. package/src/nodes/accessors/TextureBicubic.js +21 -3
  113. package/src/nodes/accessors/TextureNode.js +12 -0
  114. package/src/nodes/accessors/UniformArrayNode.js +0 -16
  115. package/src/nodes/core/ArrayNode.js +12 -0
  116. package/src/nodes/core/AssignNode.js +3 -0
  117. package/src/nodes/core/CacheNode.js +0 -14
  118. package/src/nodes/core/ContextNode.js +20 -1
  119. package/src/nodes/core/Node.js +15 -3
  120. package/src/nodes/core/NodeBuilder.js +228 -92
  121. package/src/nodes/core/NodeUtils.js +4 -1
  122. package/src/nodes/core/StackNode.js +49 -29
  123. package/src/nodes/core/SubBuildNode.js +89 -0
  124. package/src/nodes/core/UniformNode.js +63 -5
  125. package/src/nodes/core/VarNode.js +91 -2
  126. package/src/nodes/core/VaryingNode.js +6 -4
  127. package/src/nodes/display/BlendModes.js +2 -2
  128. package/src/nodes/display/FrontFacingNode.js +34 -2
  129. package/src/nodes/display/NormalMapNode.js +19 -50
  130. package/src/nodes/display/PassNode.js +157 -9
  131. package/src/nodes/display/ScreenNode.js +0 -26
  132. package/src/nodes/display/ViewportTextureNode.js +67 -7
  133. package/src/nodes/functions/BSDF/BRDF_GGX.js +2 -6
  134. package/src/nodes/functions/BSDF/BRDF_Sheen.js +4 -4
  135. package/src/nodes/functions/PhongLightingModel.js +3 -3
  136. package/src/nodes/functions/PhysicalLightingModel.js +16 -16
  137. package/src/nodes/functions/material/getGeometryRoughness.js +2 -2
  138. package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
  139. package/src/nodes/gpgpu/ComputeNode.js +67 -23
  140. package/src/nodes/gpgpu/WorkgroupInfoNode.js +28 -3
  141. package/src/nodes/lighting/EnvironmentNode.js +5 -5
  142. package/src/nodes/lighting/LightsNode.js +4 -4
  143. package/src/nodes/lighting/ProjectorLightNode.js +19 -6
  144. package/src/nodes/lighting/ShadowFilterNode.js +1 -1
  145. package/src/nodes/lighting/ShadowNode.js +2 -2
  146. package/src/nodes/materialx/MaterialXNodes.js +131 -2
  147. package/src/nodes/materialx/lib/mx_noise.js +165 -1
  148. package/src/nodes/math/ConditionalNode.js +1 -20
  149. package/src/nodes/math/MathNode.js +90 -55
  150. package/src/nodes/math/OperatorNode.js +22 -39
  151. package/src/nodes/tsl/TSLBase.js +1 -0
  152. package/src/nodes/tsl/TSLCore.js +114 -55
  153. package/src/nodes/utils/DebugNode.js +1 -1
  154. package/src/nodes/utils/EquirectUV.js +27 -0
  155. package/src/nodes/utils/EventNode.js +83 -0
  156. package/src/nodes/utils/LoopNode.js +0 -17
  157. package/src/nodes/utils/MatcapUV.js +22 -0
  158. package/src/nodes/utils/RTTNode.js +22 -5
  159. package/src/nodes/utils/ReflectorNode.js +11 -4
  160. package/src/nodes/utils/SampleNode.js +81 -0
  161. package/src/nodes/utils/TriplanarTextures.js +65 -0
  162. package/src/objects/BatchedMesh.js +4 -2
  163. package/src/renderers/WebGLRenderer.js +26 -24
  164. package/src/renderers/common/Background.js +2 -2
  165. package/src/renderers/common/Bindings.js +19 -18
  166. package/src/renderers/common/Color4.js +2 -2
  167. package/src/renderers/common/CubeRenderTarget.js +1 -1
  168. package/src/renderers/common/PostProcessing.js +60 -5
  169. package/src/renderers/common/RenderObject.js +68 -3
  170. package/src/renderers/common/Renderer.js +19 -16
  171. package/src/renderers/common/SampledTexture.js +3 -71
  172. package/src/renderers/common/Sampler.js +79 -0
  173. package/src/renderers/common/Storage3DTexture.js +100 -0
  174. package/src/renderers/common/StorageArrayTexture.js +84 -0
  175. package/src/renderers/common/StorageTexture.js +19 -0
  176. package/src/renderers/common/Textures.js +19 -3
  177. package/src/renderers/common/XRManager.js +31 -12
  178. package/src/renderers/common/XRRenderTarget.js +21 -4
  179. package/src/renderers/common/extras/PMREMGenerator.js +1 -1
  180. package/src/renderers/common/nodes/NodeSampledTexture.js +0 -12
  181. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +20 -2
  182. package/src/renderers/shaders/ShaderLib/depth.glsl.js +11 -2
  183. package/src/renderers/webgl/WebGLAttributes.js +4 -0
  184. package/src/renderers/webgl/WebGLCapabilities.js +2 -2
  185. package/src/renderers/webgl/WebGLProgram.js +12 -6
  186. package/src/renderers/webgl/WebGLPrograms.js +6 -4
  187. package/src/renderers/webgl/WebGLShadowMap.js +11 -1
  188. package/src/renderers/webgl/WebGLState.js +4 -4
  189. package/src/renderers/webgl/WebGLTextures.js +19 -7
  190. package/src/renderers/webgl-fallback/WebGLBackend.js +103 -72
  191. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +3 -5
  192. package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +4 -0
  193. package/src/renderers/webgl-fallback/utils/WebGLState.js +4 -4
  194. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +2 -0
  195. package/src/renderers/webgpu/WebGPUBackend.js +63 -16
  196. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +64 -79
  197. package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +6 -0
  198. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +45 -31
  199. package/src/renderers/webgpu/utils/WebGPUConstants.js +7 -1
  200. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +5 -5
  201. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +12 -65
  202. package/src/renderers/webgpu/utils/WebGPUUtils.js +2 -17
  203. package/src/renderers/webxr/WebXRDepthSensing.js +6 -10
  204. package/src/renderers/webxr/WebXRManager.js +68 -6
  205. package/src/textures/ExternalTexture.js +45 -0
  206. package/src/textures/FramebufferTexture.js +2 -2
  207. package/src/textures/Source.js +11 -1
  208. package/src/textures/VideoTexture.js +30 -2
  209. package/src/nodes/utils/EquirectUVNode.js +0 -65
  210. package/src/nodes/utils/MatcapUVNode.js +0 -49
  211. package/src/nodes/utils/TriplanarTexturesNode.js +0 -148
@@ -1,6 +1,6 @@
1
1
  import { WebGLCoordinateSystem } from '../../constants.js';
2
2
  import TempNode from '../core/TempNode.js';
3
- import { addMethodChaining, Fn, int, nodeProxy } from '../tsl/TSLCore.js';
3
+ import { addMethodChaining, Fn, int, nodeProxyIntent } from '../tsl/TSLCore.js';
4
4
 
5
5
  const _vectorOperators = {
6
6
  '==': 'equal',
@@ -419,7 +419,7 @@ export default OperatorNode;
419
419
  * @param {...Node} params - Additional input parameters.
420
420
  * @returns {OperatorNode}
421
421
  */
422
- export const add = /*@__PURE__*/ nodeProxy( OperatorNode, '+' ).setParameterLength( 2, Infinity ).setName( 'add' );
422
+ export const add = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '+' ).setParameterLength( 2, Infinity ).setName( 'add' );
423
423
 
424
424
  /**
425
425
  * Returns the subtraction of two or more value.
@@ -431,7 +431,7 @@ export const add = /*@__PURE__*/ nodeProxy( OperatorNode, '+' ).setParameterLeng
431
431
  * @param {...Node} params - Additional input parameters.
432
432
  * @returns {OperatorNode}
433
433
  */
434
- export const sub = /*@__PURE__*/ nodeProxy( OperatorNode, '-' ).setParameterLength( 2, Infinity ).setName( 'sub' );
434
+ export const sub = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '-' ).setParameterLength( 2, Infinity ).setName( 'sub' );
435
435
 
436
436
  /**
437
437
  * Returns the multiplication of two or more value.
@@ -443,7 +443,7 @@ export const sub = /*@__PURE__*/ nodeProxy( OperatorNode, '-' ).setParameterLeng
443
443
  * @param {...Node} params - Additional input parameters.
444
444
  * @returns {OperatorNode}
445
445
  */
446
- export const mul = /*@__PURE__*/ nodeProxy( OperatorNode, '*' ).setParameterLength( 2, Infinity ).setName( 'mul' );
446
+ export const mul = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '*' ).setParameterLength( 2, Infinity ).setName( 'mul' );
447
447
 
448
448
  /**
449
449
  * Returns the division of two or more value.
@@ -455,7 +455,7 @@ export const mul = /*@__PURE__*/ nodeProxy( OperatorNode, '*' ).setParameterLeng
455
455
  * @param {...Node} params - Additional input parameters.
456
456
  * @returns {OperatorNode}
457
457
  */
458
- export const div = /*@__PURE__*/ nodeProxy( OperatorNode, '/' ).setParameterLength( 2, Infinity ).setName( 'div' );
458
+ export const div = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '/' ).setParameterLength( 2, Infinity ).setName( 'div' );
459
459
 
460
460
  /**
461
461
  * Computes the remainder of dividing the first node by the second one.
@@ -466,7 +466,7 @@ export const div = /*@__PURE__*/ nodeProxy( OperatorNode, '/' ).setParameterLeng
466
466
  * @param {Node} b - The second input.
467
467
  * @returns {OperatorNode}
468
468
  */
469
- export const mod = /*@__PURE__*/ nodeProxy( OperatorNode, '%' ).setParameterLength( 2 ).setName( 'mod' );
469
+ export const mod = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '%' ).setParameterLength( 2 ).setName( 'mod' );
470
470
 
471
471
  /**
472
472
  * Checks if two nodes are equal.
@@ -477,7 +477,7 @@ export const mod = /*@__PURE__*/ nodeProxy( OperatorNode, '%' ).setParameterLeng
477
477
  * @param {Node} b - The second input.
478
478
  * @returns {OperatorNode}
479
479
  */
480
- export const equal = /*@__PURE__*/ nodeProxy( OperatorNode, '==' ).setParameterLength( 2 ).setName( 'equal' );
480
+ export const equal = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '==' ).setParameterLength( 2 ).setName( 'equal' );
481
481
 
482
482
  /**
483
483
  * Checks if two nodes are not equal.
@@ -488,7 +488,7 @@ export const equal = /*@__PURE__*/ nodeProxy( OperatorNode, '==' ).setParameterL
488
488
  * @param {Node} b - The second input.
489
489
  * @returns {OperatorNode}
490
490
  */
491
- export const notEqual = /*@__PURE__*/ nodeProxy( OperatorNode, '!=' ).setParameterLength( 2 ).setName( 'notEqual' );
491
+ export const notEqual = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '!=' ).setParameterLength( 2 ).setName( 'notEqual' );
492
492
 
493
493
  /**
494
494
  * Checks if the first node is less than the second.
@@ -499,7 +499,7 @@ export const notEqual = /*@__PURE__*/ nodeProxy( OperatorNode, '!=' ).setParamet
499
499
  * @param {Node} b - The second input.
500
500
  * @returns {OperatorNode}
501
501
  */
502
- export const lessThan = /*@__PURE__*/ nodeProxy( OperatorNode, '<' ).setParameterLength( 2 ).setName( 'lessThan' );
502
+ export const lessThan = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '<' ).setParameterLength( 2 ).setName( 'lessThan' );
503
503
 
504
504
  /**
505
505
  * Checks if the first node is greater than the second.
@@ -510,7 +510,7 @@ export const lessThan = /*@__PURE__*/ nodeProxy( OperatorNode, '<' ).setParamete
510
510
  * @param {Node} b - The second input.
511
511
  * @returns {OperatorNode}
512
512
  */
513
- export const greaterThan = /*@__PURE__*/ nodeProxy( OperatorNode, '>' ).setParameterLength( 2 ).setName( 'greaterThan' );
513
+ export const greaterThan = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '>' ).setParameterLength( 2 ).setName( 'greaterThan' );
514
514
 
515
515
  /**
516
516
  * Checks if the first node is less than or equal to the second.
@@ -521,7 +521,7 @@ export const greaterThan = /*@__PURE__*/ nodeProxy( OperatorNode, '>' ).setParam
521
521
  * @param {Node} b - The second input.
522
522
  * @returns {OperatorNode}
523
523
  */
524
- export const lessThanEqual = /*@__PURE__*/ nodeProxy( OperatorNode, '<=' ).setParameterLength( 2 ).setName( 'lessThanEqual' );
524
+ export const lessThanEqual = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '<=' ).setParameterLength( 2 ).setName( 'lessThanEqual' );
525
525
 
526
526
  /**
527
527
  * Checks if the first node is greater than or equal to the second.
@@ -532,7 +532,7 @@ export const lessThanEqual = /*@__PURE__*/ nodeProxy( OperatorNode, '<=' ).setPa
532
532
  * @param {Node} b - The second input.
533
533
  * @returns {OperatorNode}
534
534
  */
535
- export const greaterThanEqual = /*@__PURE__*/ nodeProxy( OperatorNode, '>=' ).setParameterLength( 2 ).setName( 'greaterThanEqual' );
535
+ export const greaterThanEqual = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '>=' ).setParameterLength( 2 ).setName( 'greaterThanEqual' );
536
536
 
537
537
  /**
538
538
  * Performs a logical AND operation on multiple nodes.
@@ -542,7 +542,7 @@ export const greaterThanEqual = /*@__PURE__*/ nodeProxy( OperatorNode, '>=' ).se
542
542
  * @param {...Node} nodes - The input nodes to be combined using AND.
543
543
  * @returns {OperatorNode}
544
544
  */
545
- export const and = /*@__PURE__*/ nodeProxy( OperatorNode, '&&' ).setParameterLength( 2, Infinity ).setName( 'and' );
545
+ export const and = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '&&' ).setParameterLength( 2, Infinity ).setName( 'and' );
546
546
 
547
547
  /**
548
548
  * Performs a logical OR operation on multiple nodes.
@@ -552,7 +552,7 @@ export const and = /*@__PURE__*/ nodeProxy( OperatorNode, '&&' ).setParameterLen
552
552
  * @param {...Node} nodes - The input nodes to be combined using OR.
553
553
  * @returns {OperatorNode}
554
554
  */
555
- export const or = /*@__PURE__*/ nodeProxy( OperatorNode, '||' ).setParameterLength( 2, Infinity ).setName( 'or' );
555
+ export const or = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '||' ).setParameterLength( 2, Infinity ).setName( 'or' );
556
556
 
557
557
  /**
558
558
  * Performs logical NOT on a node.
@@ -562,7 +562,7 @@ export const or = /*@__PURE__*/ nodeProxy( OperatorNode, '||' ).setParameterLeng
562
562
  * @param {Node} value - The value.
563
563
  * @returns {OperatorNode}
564
564
  */
565
- export const not = /*@__PURE__*/ nodeProxy( OperatorNode, '!' ).setParameterLength( 1 ).setName( 'not' );
565
+ export const not = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '!' ).setParameterLength( 1 ).setName( 'not' );
566
566
 
567
567
  /**
568
568
  * Performs logical XOR on two nodes.
@@ -573,7 +573,7 @@ export const not = /*@__PURE__*/ nodeProxy( OperatorNode, '!' ).setParameterLeng
573
573
  * @param {Node} b - The second input.
574
574
  * @returns {OperatorNode}
575
575
  */
576
- export const xor = /*@__PURE__*/ nodeProxy( OperatorNode, '^^' ).setParameterLength( 2 ).setName( 'xor' );
576
+ export const xor = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '^^' ).setParameterLength( 2 ).setName( 'xor' );
577
577
 
578
578
  /**
579
579
  * Performs bitwise AND on two nodes.
@@ -584,7 +584,7 @@ export const xor = /*@__PURE__*/ nodeProxy( OperatorNode, '^^' ).setParameterLen
584
584
  * @param {Node} b - The second input.
585
585
  * @returns {OperatorNode}
586
586
  */
587
- export const bitAnd = /*@__PURE__*/ nodeProxy( OperatorNode, '&' ).setParameterLength( 2 ).setName( 'bitAnd' );
587
+ export const bitAnd = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '&' ).setParameterLength( 2 ).setName( 'bitAnd' );
588
588
 
589
589
  /**
590
590
  * Performs bitwise NOT on a node.
@@ -595,7 +595,7 @@ export const bitAnd = /*@__PURE__*/ nodeProxy( OperatorNode, '&' ).setParameterL
595
595
  * @param {Node} b - The second input.
596
596
  * @returns {OperatorNode}
597
597
  */
598
- export const bitNot = /*@__PURE__*/ nodeProxy( OperatorNode, '~' ).setParameterLength( 2 ).setName( 'bitNot' );
598
+ export const bitNot = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '~' ).setParameterLength( 2 ).setName( 'bitNot' );
599
599
 
600
600
  /**
601
601
  * Performs bitwise OR on two nodes.
@@ -606,7 +606,7 @@ export const bitNot = /*@__PURE__*/ nodeProxy( OperatorNode, '~' ).setParameterL
606
606
  * @param {Node} b - The second input.
607
607
  * @returns {OperatorNode}
608
608
  */
609
- export const bitOr = /*@__PURE__*/ nodeProxy( OperatorNode, '|' ).setParameterLength( 2 ).setName( 'bitOr' );
609
+ export const bitOr = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '|' ).setParameterLength( 2 ).setName( 'bitOr' );
610
610
 
611
611
  /**
612
612
  * Performs bitwise XOR on two nodes.
@@ -617,7 +617,7 @@ export const bitOr = /*@__PURE__*/ nodeProxy( OperatorNode, '|' ).setParameterLe
617
617
  * @param {Node} b - The second input.
618
618
  * @returns {OperatorNode}
619
619
  */
620
- export const bitXor = /*@__PURE__*/ nodeProxy( OperatorNode, '^' ).setParameterLength( 2 ).setName( 'bitXor' );
620
+ export const bitXor = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '^' ).setParameterLength( 2 ).setName( 'bitXor' );
621
621
 
622
622
  /**
623
623
  * Shifts a node to the left.
@@ -628,7 +628,7 @@ export const bitXor = /*@__PURE__*/ nodeProxy( OperatorNode, '^' ).setParameterL
628
628
  * @param {Node} b - The value to shift.
629
629
  * @returns {OperatorNode}
630
630
  */
631
- export const shiftLeft = /*@__PURE__*/ nodeProxy( OperatorNode, '<<' ).setParameterLength( 2 ).setName( 'shiftLeft' );
631
+ export const shiftLeft = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '<<' ).setParameterLength( 2 ).setName( 'shiftLeft' );
632
632
 
633
633
  /**
634
634
  * Shifts a node to the right.
@@ -639,7 +639,7 @@ export const shiftLeft = /*@__PURE__*/ nodeProxy( OperatorNode, '<<' ).setParame
639
639
  * @param {Node} b - The value to shift.
640
640
  * @returns {OperatorNode}
641
641
  */
642
- export const shiftRight = /*@__PURE__*/ nodeProxy( OperatorNode, '>>' ).setParameterLength( 2 ).setName( 'shiftRight' );
642
+ export const shiftRight = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '>>' ).setParameterLength( 2 ).setName( 'shiftRight' );
643
643
 
644
644
  /**
645
645
  * Increments a node by 1.
@@ -730,22 +730,6 @@ addMethodChaining( 'decrementBefore', decrementBefore );
730
730
  addMethodChaining( 'increment', increment );
731
731
  addMethodChaining( 'decrement', decrement );
732
732
 
733
- /**
734
- * @tsl
735
- * @function
736
- * @deprecated since r168. Use {@link mod} instead.
737
- *
738
- * @param {Node} a - The first input.
739
- * @param {Node} b - The second input.
740
- * @returns {OperatorNode}
741
- */
742
- export const remainder = ( a, b ) => { // @deprecated, r168
743
-
744
- console.warn( 'THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.' );
745
- return mod( a, b );
746
-
747
- };
748
-
749
733
  /**
750
734
  * @tsl
751
735
  * @function
@@ -762,5 +746,4 @@ export const modInt = ( a, b ) => { // @deprecated, r175
762
746
 
763
747
  };
764
748
 
765
- addMethodChaining( 'remainder', remainder );
766
749
  addMethodChaining( 'modInt', modInt );
@@ -24,6 +24,7 @@ export * from '../code/ExpressionNode.js'; // expression()
24
24
  export * from '../utils/Discard.js'; // Discard(), Return()
25
25
  export * from '../display/RenderOutputNode.js'; // .renderOutput()
26
26
  export * from '../utils/DebugNode.js'; // debug()
27
+ export * from '../core/SubBuildNode.js'; // subBuild()
27
28
 
28
29
  export function addNodeElement( name/*, nodeElement*/ ) {
29
30
 
@@ -61,6 +61,10 @@ const shaderNodeHandler = {
61
61
 
62
62
  return node.isStackNode ? ( ...params ) => nodeObj.add( nodeElement( ...params ) ) : ( ...params ) => nodeElement( nodeObj, ...params );
63
63
 
64
+ } else if ( prop === 'toVarIntent' ) {
65
+
66
+ return () => nodeObj;
67
+
64
68
  } else if ( prop === 'self' ) {
65
69
 
66
70
  return node;
@@ -175,7 +179,7 @@ const ShaderNodeObject = function ( obj, altType = null ) {
175
179
 
176
180
  } else if ( type === 'shader' ) {
177
181
 
178
- return Fn( obj );
182
+ return obj.isFn ? obj : Fn( obj );
179
183
 
180
184
  }
181
185
 
@@ -211,7 +215,28 @@ const ShaderNodeArray = function ( array, altType = null ) {
211
215
 
212
216
  const ShaderNodeProxy = function ( NodeClass, scope = null, factor = null, settings = null ) {
213
217
 
214
- const assignNode = ( node ) => nodeObject( settings !== null ? Object.assign( node, settings ) : node );
218
+ function assignNode( node ) {
219
+
220
+ if ( settings !== null ) {
221
+
222
+ node = nodeObject( Object.assign( node, settings ) );
223
+
224
+ if ( settings.intent === true ) {
225
+
226
+ node = node.toVarIntent();
227
+
228
+ }
229
+
230
+ } else {
231
+
232
+ node = nodeObject( node );
233
+
234
+ }
235
+
236
+ return node;
237
+
238
+
239
+ }
215
240
 
216
241
  let fn, name = scope, minParams, maxParams;
217
242
 
@@ -325,16 +350,22 @@ class ShaderCallNodeInternal extends Node {
325
350
  const { shaderNode, inputNodes } = this;
326
351
 
327
352
  const properties = builder.getNodeProperties( shaderNode );
328
- const onceNS = shaderNode.namespace && shaderNode.namespace === builder.namespace ? builder.getNamespace( 'once' ) : 'once';
329
353
 
330
- if ( properties[ onceNS ] ) {
354
+ const subBuild = builder.getClosestSubBuild( shaderNode.subBuilds ) || '';
355
+ const subBuildProperty = subBuild || 'default';
356
+
357
+ if ( properties[ subBuildProperty ] ) {
331
358
 
332
- return properties[ onceNS ];
359
+ return properties[ subBuildProperty ];
333
360
 
334
361
  }
335
362
 
336
363
  //
337
364
 
365
+ const previousSubBuildFn = builder.subBuildFn;
366
+
367
+ builder.subBuildFn = subBuild;
368
+
338
369
  let result = null;
339
370
 
340
371
  if ( shaderNode.layout ) {
@@ -365,16 +396,46 @@ class ShaderCallNodeInternal extends Node {
365
396
 
366
397
  } else {
367
398
 
399
+ let inputs = inputNodes;
400
+
401
+ if ( Array.isArray( inputs ) ) {
402
+
403
+ // If inputs is an array, we need to convert it to a Proxy
404
+ // so we can call TSL functions using the syntax `Fn( ( { r, g, b } ) => { ... } )`
405
+ // and call through `fn( 0, 1, 0 )` or `fn( { r: 0, g: 1, b: 0 } )`
406
+
407
+ let index = 0;
408
+
409
+ inputs = new Proxy( inputs, {
410
+ get: ( target, property, receiver ) => {
411
+
412
+ if ( target[ property ] === undefined ) {
413
+
414
+ return target[ index ++ ];
415
+
416
+ } else {
417
+
418
+ return Reflect.get( target, property, receiver );
419
+
420
+ }
421
+
422
+ }
423
+ } );
424
+
425
+ }
426
+
368
427
  const jsFunc = shaderNode.jsFunc;
369
- const outputNode = inputNodes !== null || jsFunc.length > 1 ? jsFunc( inputNodes || [], builder ) : jsFunc( builder );
428
+ const outputNode = inputs !== null || jsFunc.length > 1 ? jsFunc( inputs || [], builder ) : jsFunc( builder );
370
429
 
371
430
  result = nodeObject( outputNode );
372
431
 
373
432
  }
374
433
 
434
+ builder.subBuildFn = previousSubBuildFn;
435
+
375
436
  if ( shaderNode.once ) {
376
437
 
377
- properties[ onceNS ] = result;
438
+ properties[ subBuildProperty ] = result;
378
439
 
379
440
  }
380
441
 
@@ -395,11 +456,12 @@ class ShaderCallNodeInternal extends Node {
395
456
  getOutputNode( builder ) {
396
457
 
397
458
  const properties = builder.getNodeProperties( this );
398
- const outputNamespace = builder.getOutputNamespace();
459
+ const subBuildOutput = builder.getSubBuildOutput( this );
399
460
 
400
- properties[ outputNamespace ] = properties[ outputNamespace ] || this.setupOutput( builder );
461
+ properties[ subBuildOutput ] = properties[ subBuildOutput ] || this.setupOutput( builder );
462
+ properties[ subBuildOutput ].subBuild = builder.getClosestSubBuild( this );
401
463
 
402
- return properties[ outputNamespace ];
464
+ return properties[ subBuildOutput ];
403
465
 
404
466
  }
405
467
 
@@ -410,23 +472,45 @@ class ShaderCallNodeInternal extends Node {
410
472
  const buildStage = builder.getBuildStage();
411
473
  const properties = builder.getNodeProperties( this );
412
474
 
413
- const outputNamespace = builder.getOutputNamespace();
475
+ const subBuildOutput = builder.getSubBuildOutput( this );
414
476
  const outputNode = this.getOutputNode( builder );
415
477
 
416
478
  if ( buildStage === 'setup' ) {
417
479
 
418
- const initializedNamespace = builder.getNamespace( 'initialized' );
480
+ const subBuildInitialized = builder.getSubBuildProperty( 'initialized', this );
481
+
482
+ if ( properties[ subBuildInitialized ] !== true ) {
483
+
484
+ properties[ subBuildInitialized ] = true;
485
+
486
+ properties[ subBuildOutput ] = this.getOutputNode( builder );
487
+ properties[ subBuildOutput ].build( builder );
488
+
489
+ // If the shaderNode has subBuilds, add them to the chaining nodes
490
+ // so they can be built later in the build process.
491
+
492
+ if ( this.shaderNode.subBuilds ) {
419
493
 
420
- if ( properties[ initializedNamespace ] !== true ) {
494
+ for ( const node of builder.chaining ) {
421
495
 
422
- properties[ initializedNamespace ] = true;
496
+ const nodeData = builder.getDataFromNode( node, 'any' );
497
+ nodeData.subBuilds = nodeData.subBuilds || new Set();
423
498
 
424
- properties[ outputNamespace ] = this.getOutputNode( builder );
425
- properties[ outputNamespace ].build( builder );
499
+ for ( const subBuild of this.shaderNode.subBuilds ) {
500
+
501
+ nodeData.subBuilds.add( subBuild );
502
+
503
+ }
504
+
505
+ //builder.getDataFromNode( node ).subBuilds = nodeData.subBuilds;
506
+
507
+ }
508
+
509
+ }
426
510
 
427
511
  }
428
512
 
429
- result = properties[ outputNamespace ];
513
+ result = properties[ subBuildOutput ];
430
514
 
431
515
  } else if ( buildStage === 'analyze' ) {
432
516
 
@@ -456,7 +540,6 @@ class ShaderNodeInternal extends Node {
456
540
  this.global = true;
457
541
 
458
542
  this.once = false;
459
- this.namespace = null;
460
543
 
461
544
  }
462
545
 
@@ -524,20 +607,6 @@ const getConstNode = ( value, type ) => {
524
607
 
525
608
  };
526
609
 
527
- const safeGetNodeType = ( node ) => {
528
-
529
- try {
530
-
531
- return node.getNodeType();
532
-
533
- } catch ( _ ) {
534
-
535
- return undefined;
536
-
537
- }
538
-
539
- };
540
-
541
610
  const ConvertType = function ( type, cacheMap = null ) {
542
611
 
543
612
  return ( ...params ) => {
@@ -550,20 +619,20 @@ const ConvertType = function ( type, cacheMap = null ) {
550
619
 
551
620
  if ( params.length === 1 && cacheMap !== null && cacheMap.has( params[ 0 ] ) ) {
552
621
 
553
- return nodeObject( cacheMap.get( params[ 0 ] ) );
622
+ return nodeObjectIntent( cacheMap.get( params[ 0 ] ) );
554
623
 
555
624
  }
556
625
 
557
626
  if ( params.length === 1 ) {
558
627
 
559
628
  const node = getConstNode( params[ 0 ], type );
560
- if ( safeGetNodeType( node ) === type ) return nodeObject( node );
561
- return nodeObject( new ConvertNode( node, type ) );
629
+ if ( node.nodeType === type ) return nodeObjectIntent( node );
630
+ return nodeObjectIntent( new ConvertNode( node, type ) );
562
631
 
563
632
  }
564
633
 
565
634
  const nodes = params.map( param => getConstNode( param ) );
566
- return nodeObject( new JoinNode( nodes, type ) );
635
+ return nodeObjectIntent( new JoinNode( nodes, type ) );
567
636
 
568
637
  };
569
638
 
@@ -586,10 +655,12 @@ export function ShaderNode( jsFunc, nodeType ) {
586
655
  }
587
656
 
588
657
  export const nodeObject = ( val, altType = null ) => /* new */ ShaderNodeObject( val, altType );
658
+ export const nodeObjectIntent = ( val, altType = null ) => /* new */ nodeObject( val, altType ).toVarIntent();
589
659
  export const nodeObjects = ( val, altType = null ) => new ShaderNodeObjects( val, altType );
590
660
  export const nodeArray = ( val, altType = null ) => new ShaderNodeArray( val, altType );
591
- export const nodeProxy = ( ...params ) => new ShaderNodeProxy( ...params );
592
- export const nodeImmutable = ( ...params ) => new ShaderNodeImmutable( ...params );
661
+ export const nodeProxy = ( NodeClass, scope = null, factor = null, settings = null ) => new ShaderNodeProxy( NodeClass, scope, factor, settings );
662
+ export const nodeImmutable = ( NodeClass, ...params ) => new ShaderNodeImmutable( NodeClass, ...params );
663
+ export const nodeProxyIntent = ( NodeClass, scope = null, factor = null, settings = {} ) => new ShaderNodeProxy( NodeClass, scope, factor, { intent: true, ...settings } );
593
664
 
594
665
  let fnId = 0;
595
666
 
@@ -645,13 +716,15 @@ export const Fn = ( jsFunc, layout = null ) => {
645
716
 
646
717
  if ( nodeType === 'void' ) fnCall.toStack();
647
718
 
648
- return fnCall;
719
+ return fnCall.toVarIntent();
649
720
 
650
721
  };
651
722
 
652
723
  fn.shaderNode = shaderNode;
653
724
  fn.id = shaderNode.id;
654
725
 
726
+ fn.isFn = true;
727
+
655
728
  fn.getNodeType = ( ...params ) => shaderNode.getNodeType( ...params );
656
729
  fn.getCacheKey = ( ...params ) => shaderNode.getCacheKey( ...params );
657
730
 
@@ -663,10 +736,10 @@ export const Fn = ( jsFunc, layout = null ) => {
663
736
 
664
737
  };
665
738
 
666
- fn.once = ( namespace = null ) => {
739
+ fn.once = ( subBuilds = null ) => {
667
740
 
668
741
  shaderNode.once = true;
669
- shaderNode.namespace = namespace;
742
+ shaderNode.subBuilds = subBuilds;
670
743
 
671
744
  return fn;
672
745
 
@@ -853,17 +926,3 @@ addMethodChaining( 'append', ( node ) => { // @deprecated, r176
853
926
 
854
927
  } );
855
928
 
856
- /**
857
- * @tsl
858
- * @function
859
- * @deprecated since r168. Use {@link Fn} instead.
860
- *
861
- * @param {...any} params
862
- * @returns {Function}
863
- */
864
- export const tslFn = ( ...params ) => { // @deprecated, r168
865
-
866
- console.warn( 'THREE.TSL: tslFn() has been renamed to Fn().' );
867
- return Fn( ...params );
868
-
869
- };
@@ -77,6 +77,6 @@ export default DebugNode;
77
77
  * @param {?Function} [callback=null] - Optional callback function to handle the debug output.
78
78
  * @returns {DebugNode}
79
79
  */
80
- export const debug = ( node, callback = null ) => nodeObject( new DebugNode( nodeObject( node ), callback ) );
80
+ export const debug = ( node, callback = null ) => nodeObject( new DebugNode( nodeObject( node ), callback ) ).toStack();
81
81
 
82
82
  addMethodChaining( 'debug', debug );
@@ -0,0 +1,27 @@
1
+ import { positionWorldDirection } from '../accessors/Position.js';
2
+ import { Fn, vec2 } from '../tsl/TSLBase.js';
3
+
4
+ /**
5
+ * TSL function for creating an equirect uv node.
6
+ *
7
+ * Can be used to compute texture coordinates for projecting an
8
+ * equirectangular texture onto a mesh for using it as the scene's
9
+ * background.
10
+ *
11
+ * ```js
12
+ * scene.backgroundNode = texture( equirectTexture, equirectUV() );
13
+ * ```
14
+ *
15
+ * @tsl
16
+ * @function
17
+ * @param {?Node<vec3>} [dirNode=positionWorldDirection] - A direction vector for sampling which is by default `positionWorldDirection`.
18
+ * @returns {Node<vec2>}
19
+ */
20
+ export const equirectUV = /*@__PURE__*/ Fn( ( [ dir = positionWorldDirection ] ) => {
21
+
22
+ const u = dir.z.atan( dir.x ).mul( 1 / ( Math.PI * 2 ) ).add( 0.5 );
23
+ const v = dir.y.clamp( - 1.0, 1.0 ).asin().mul( 1 / Math.PI ).add( 0.5 );
24
+
25
+ return vec2( u, v );
26
+
27
+ } );
@@ -0,0 +1,83 @@
1
+ import Node from '../core/Node.js';
2
+ import { NodeUpdateType } from '../core/constants.js';
3
+ import { nodeObject } from '../tsl/TSLCore.js';
4
+
5
+ /**
6
+ * EventNode is a node that executes a callback during specific update phases.
7
+ *
8
+ * @augments Node
9
+ */
10
+ class EventNode extends Node {
11
+
12
+ static get type() {
13
+
14
+ return 'EventNode';
15
+
16
+ }
17
+
18
+ /**
19
+ * Creates an EventNode.
20
+ *
21
+ * @param {string} eventType - The type of event
22
+ * @param {Function} callback - The callback to execute on update.
23
+ */
24
+ constructor( eventType, callback ) {
25
+
26
+ super( 'void' );
27
+
28
+ this.eventType = eventType;
29
+ this.callback = callback;
30
+
31
+ if ( eventType === EventNode.OBJECT ) {
32
+
33
+ this.updateType = NodeUpdateType.OBJECT;
34
+
35
+ } else if ( eventType === EventNode.MATERIAL ) {
36
+
37
+ this.updateType = NodeUpdateType.RENDER;
38
+
39
+ }
40
+
41
+ }
42
+
43
+ update( frame ) {
44
+
45
+ this.callback( frame );
46
+
47
+ }
48
+
49
+ }
50
+
51
+ EventNode.OBJECT = 'object';
52
+ EventNode.MATERIAL = 'material';
53
+
54
+ export default EventNode;
55
+
56
+ /**
57
+ * Helper to create an EventNode and add it to the stack.
58
+ *
59
+ * @param {string} type - The event type.
60
+ * @param {Function} callback - The callback function.
61
+ * @returns {EventNode}
62
+ */
63
+ const createEvent = ( type, callback ) => nodeObject( new EventNode( type, callback ) ).toStack();
64
+
65
+ /**
66
+ * Creates an event that triggers a function every time an object (Mesh|Sprite) is rendered.
67
+ *
68
+ * The event will be bound to the declared TSL function `Fn()`; it must be declared within a `Fn()` or the JS function call must be inherited from one.
69
+ *
70
+ * @param {Function} callback - The callback function.
71
+ * @returns {EventNode}
72
+ */
73
+ export const OnObjectUpdate = ( callback ) => createEvent( EventNode.OBJECT, callback );
74
+
75
+ /**
76
+ * Creates an event that triggers a function when the first object that uses the material is rendered.
77
+ *
78
+ * The event will be bound to the declared TSL function `Fn()`; it must be declared within a `Fn()` or the JS function call must be inherited from one.
79
+ *
80
+ * @param {Function} callback - The callback function.
81
+ * @returns {EventNode}
82
+ */
83
+ export const OnMaterialUpdate = ( callback ) => createEvent( EventNode.MATERIAL, callback );
@@ -351,20 +351,3 @@ export const Continue = () => expression( 'continue' ).toStack();
351
351
  * @returns {ExpressionNode}
352
352
  */
353
353
  export const Break = () => expression( 'break' ).toStack();
354
-
355
- // Deprecated
356
-
357
- /**
358
- * @tsl
359
- * @function
360
- * @deprecated since r168. Use {@link Loop} instead.
361
- *
362
- * @param {...any} params
363
- * @returns {LoopNode}
364
- */
365
- export const loop = ( ...params ) => { // @deprecated, r168
366
-
367
- console.warn( 'THREE.TSL: loop() has been renamed to Loop().' );
368
- return Loop( ...params );
369
-
370
- };