@plastic-software/three 0.182.0 → 0.183.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 (298) hide show
  1. package/LICENSE +1 -1
  2. package/build/three.cjs +11520 -10877
  3. package/build/three.core.js +11732 -11340
  4. package/build/three.core.min.js +2 -2
  5. package/build/three.module.js +509 -262
  6. package/build/three.module.min.js +2 -2
  7. package/build/three.tsl.js +7 -11
  8. package/build/three.tsl.min.js +2 -2
  9. package/build/three.webgpu.js +3072 -2607
  10. package/build/three.webgpu.min.js +2 -2
  11. package/build/three.webgpu.nodes.js +3071 -2607
  12. package/build/three.webgpu.nodes.min.js +2 -2
  13. package/examples/jsm/Addons.js +0 -3
  14. package/examples/jsm/animation/CCDIKSolver.js +2 -2
  15. package/examples/jsm/controls/ArcballControls.js +3 -3
  16. package/examples/jsm/controls/OrbitControls.js +103 -0
  17. package/examples/jsm/effects/AnaglyphEffect.js +102 -7
  18. package/examples/jsm/environments/ColorEnvironment.js +59 -0
  19. package/examples/jsm/environments/RoomEnvironment.js +1 -0
  20. package/examples/jsm/exporters/EXRExporter.js +1 -1
  21. package/examples/jsm/exporters/GLTFExporter.js +131 -4
  22. package/examples/jsm/exporters/USDZExporter.js +22 -3
  23. package/examples/jsm/helpers/AnimationPathHelper.js +302 -0
  24. package/examples/jsm/helpers/ViewHelper.js +67 -8
  25. package/examples/jsm/inspector/Inspector.js +21 -5
  26. package/examples/jsm/inspector/tabs/Console.js +39 -5
  27. package/examples/jsm/inspector/tabs/Parameters.js +16 -0
  28. package/examples/jsm/inspector/ui/Style.js +25 -1
  29. package/examples/jsm/libs/meshopt_decoder.module.js +6 -5
  30. package/examples/jsm/lines/LineMaterial.js +6 -0
  31. package/examples/jsm/loaders/3MFLoader.js +2 -2
  32. package/examples/jsm/loaders/AMFLoader.js +2 -2
  33. package/examples/jsm/loaders/ColladaLoader.js +24 -4026
  34. package/examples/jsm/loaders/EXRLoader.js +5 -5
  35. package/examples/jsm/loaders/FBXLoader.js +2 -2
  36. package/examples/jsm/loaders/GCodeLoader.js +34 -8
  37. package/examples/jsm/loaders/GLTFLoader.js +122 -171
  38. package/examples/jsm/loaders/KMZLoader.js +5 -5
  39. package/examples/jsm/loaders/KTX2Loader.js +5 -5
  40. package/examples/jsm/loaders/LWOLoader.js +7 -39
  41. package/examples/jsm/loaders/NRRDLoader.js +2 -2
  42. package/examples/jsm/loaders/PCDLoader.js +3 -2
  43. package/examples/jsm/loaders/USDLoader.js +100 -40
  44. package/examples/jsm/loaders/UltraHDRLoader.js +182 -30
  45. package/examples/jsm/loaders/VRMLLoader.js +77 -0
  46. package/examples/jsm/loaders/VTKLoader.js +37 -24
  47. package/examples/jsm/loaders/collada/ColladaComposer.js +2950 -0
  48. package/examples/jsm/loaders/collada/ColladaParser.js +1962 -0
  49. package/examples/jsm/loaders/usd/USDAParser.js +447 -366
  50. package/examples/jsm/loaders/usd/USDCParser.js +1841 -6
  51. package/examples/jsm/loaders/usd/USDComposer.js +4041 -0
  52. package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +2 -2
  53. package/examples/jsm/objects/LensflareMesh.js +1 -1
  54. package/examples/jsm/objects/Sky.js +76 -4
  55. package/examples/jsm/objects/SkyMesh.js +114 -7
  56. package/examples/jsm/objects/Water.js +4 -3
  57. package/examples/jsm/objects/Water2.js +5 -3
  58. package/examples/jsm/objects/WaterMesh.js +5 -7
  59. package/examples/jsm/physics/JoltPhysics.js +7 -5
  60. package/examples/jsm/physics/RapierPhysics.js +6 -4
  61. package/examples/jsm/postprocessing/EffectComposer.js +7 -5
  62. package/examples/jsm/postprocessing/RenderTransitionPass.js +1 -1
  63. package/examples/jsm/renderers/CSS3DRenderer.js +1 -1
  64. package/examples/jsm/renderers/SVGRenderer.js +2 -2
  65. package/examples/jsm/shaders/GTAOShader.js +19 -6
  66. package/examples/jsm/shaders/HalftoneShader.js +12 -1
  67. package/examples/jsm/shaders/PoissonDenoiseShader.js +6 -2
  68. package/examples/jsm/shaders/SAOShader.js +17 -4
  69. package/examples/jsm/shaders/SSAOShader.js +11 -1
  70. package/examples/jsm/shaders/SSRShader.js +6 -5
  71. package/examples/jsm/shaders/VignetteShader.js +1 -1
  72. package/examples/jsm/tsl/display/AfterImageNode.js +1 -1
  73. package/examples/jsm/tsl/display/AnaglyphPassNode.js +456 -16
  74. package/examples/jsm/tsl/display/AnamorphicNode.js +1 -1
  75. package/examples/jsm/tsl/display/BilateralBlurNode.js +364 -0
  76. package/examples/jsm/tsl/display/BloomNode.js +5 -5
  77. package/examples/jsm/tsl/display/CRT.js +150 -0
  78. package/examples/jsm/tsl/display/DenoiseNode.js +1 -1
  79. package/examples/jsm/tsl/display/DepthOfFieldNode.js +1 -1
  80. package/examples/jsm/tsl/display/DotScreenNode.js +1 -1
  81. package/examples/jsm/tsl/display/FXAANode.js +2 -2
  82. package/examples/jsm/tsl/display/GTAONode.js +2 -2
  83. package/examples/jsm/tsl/display/GaussianBlurNode.js +11 -2
  84. package/examples/jsm/tsl/display/GodraysNode.js +624 -0
  85. package/examples/jsm/tsl/display/LensflareNode.js +1 -1
  86. package/examples/jsm/tsl/display/Lut3DNode.js +1 -1
  87. package/examples/jsm/tsl/display/OutlineNode.js +3 -3
  88. package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +2 -2
  89. package/examples/jsm/tsl/display/PixelationPassNode.js +5 -5
  90. package/examples/jsm/tsl/display/RGBShiftNode.js +2 -2
  91. package/examples/jsm/tsl/display/RetroPassNode.js +263 -0
  92. package/examples/jsm/tsl/display/SMAANode.js +2 -2
  93. package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
  94. package/examples/jsm/tsl/display/SSGINode.js +2 -2
  95. package/examples/jsm/tsl/display/SSRNode.js +7 -7
  96. package/examples/jsm/tsl/display/SSSNode.js +2 -2
  97. package/examples/jsm/tsl/display/Shape.js +29 -0
  98. package/examples/jsm/tsl/display/SobelOperatorNode.js +2 -2
  99. package/examples/jsm/tsl/display/StereoPassNode.js +1 -2
  100. package/examples/jsm/tsl/display/TRAANode.js +9 -12
  101. package/examples/jsm/tsl/display/TransitionNode.js +1 -1
  102. package/examples/jsm/tsl/display/depthAwareBlend.js +80 -0
  103. package/examples/jsm/tsl/math/Bayer.js +40 -1
  104. package/examples/jsm/utils/LDrawUtils.js +1 -1
  105. package/package.json +11 -19
  106. package/src/Three.Core.js +1 -1
  107. package/src/Three.TSL.js +5 -9
  108. package/src/Three.WebGPU.Nodes.js +2 -0
  109. package/src/Three.WebGPU.js +3 -0
  110. package/src/Three.js +1 -0
  111. package/src/animation/AnimationAction.js +1 -1
  112. package/src/animation/AnimationClip.js +1 -1
  113. package/src/animation/AnimationMixer.js +6 -0
  114. package/src/animation/KeyframeTrack.js +46 -7
  115. package/src/animation/PropertyMixer.js +4 -4
  116. package/src/audio/Audio.js +1 -1
  117. package/src/audio/AudioListener.js +5 -3
  118. package/src/cameras/Camera.js +32 -2
  119. package/src/cameras/CubeCamera.js +20 -0
  120. package/src/constants.js +30 -1
  121. package/src/core/Clock.js +7 -0
  122. package/src/core/Object3D.js +56 -4
  123. package/src/core/RenderTarget.js +3 -4
  124. package/src/extras/PMREMGenerator.js +4 -8
  125. package/src/geometries/TorusGeometry.js +8 -3
  126. package/src/helpers/CameraHelper.js +3 -0
  127. package/src/helpers/DirectionalLightHelper.js +4 -1
  128. package/src/helpers/HemisphereLightHelper.js +3 -0
  129. package/src/helpers/PointLightHelper.js +0 -24
  130. package/src/helpers/SpotLightHelper.js +3 -0
  131. package/src/lights/LightShadow.js +15 -3
  132. package/src/lights/webgpu/IESSpotLight.js +2 -1
  133. package/src/loaders/Cache.js +28 -0
  134. package/src/loaders/FileLoader.js +1 -1
  135. package/src/loaders/ImageBitmapLoader.js +8 -3
  136. package/src/loaders/Loader.js +6 -0
  137. package/src/loaders/ObjectLoader.js +18 -1
  138. package/src/materials/MeshLambertMaterial.js +9 -0
  139. package/src/materials/MeshPhongMaterial.js +9 -0
  140. package/src/materials/nodes/Line2NodeMaterial.js +5 -5
  141. package/src/materials/nodes/MeshPhysicalNodeMaterial.js +2 -0
  142. package/src/materials/nodes/NodeMaterial.js +15 -24
  143. package/src/materials/nodes/manager/NodeMaterialObserver.js +9 -3
  144. package/src/math/Line3.js +3 -5
  145. package/src/math/MathUtils.js +10 -10
  146. package/src/math/Matrix4.js +35 -26
  147. package/src/math/Quaternion.js +3 -29
  148. package/src/math/Vector3.js +3 -3
  149. package/src/math/interpolants/BezierInterpolant.js +108 -0
  150. package/src/nodes/Nodes.js +87 -68
  151. package/src/nodes/TSL.js +2 -5
  152. package/src/nodes/accessors/Arrays.js +1 -1
  153. package/src/nodes/accessors/Bitangent.js +5 -5
  154. package/src/nodes/accessors/BufferAttributeNode.js +1 -1
  155. package/src/nodes/accessors/Camera.js +149 -28
  156. package/src/nodes/accessors/InstanceNode.js +105 -40
  157. package/src/nodes/accessors/Normal.js +9 -9
  158. package/src/nodes/accessors/Position.js +34 -2
  159. package/src/nodes/accessors/SceneProperties.js +53 -0
  160. package/src/nodes/accessors/SkinningNode.js +12 -24
  161. package/src/nodes/accessors/StorageBufferNode.js +0 -19
  162. package/src/nodes/accessors/StorageTextureNode.js +37 -1
  163. package/src/nodes/accessors/Tangent.js +3 -3
  164. package/src/nodes/accessors/Texture3DNode.js +6 -34
  165. package/src/nodes/accessors/TextureNode.js +58 -22
  166. package/src/nodes/accessors/UniformArrayNode.js +2 -0
  167. package/src/nodes/core/MRTNode.js +48 -2
  168. package/src/nodes/core/Node.js +29 -3
  169. package/src/nodes/core/NodeBuilder.js +115 -40
  170. package/src/nodes/core/NodeError.js +28 -0
  171. package/src/nodes/core/NodeUtils.js +5 -3
  172. package/src/nodes/core/OutputStructNode.js +12 -10
  173. package/src/nodes/core/ParameterNode.js +2 -1
  174. package/src/nodes/core/StackNode.js +9 -8
  175. package/src/nodes/core/StackTrace.js +139 -0
  176. package/src/nodes/core/StructNode.js +15 -0
  177. package/src/nodes/core/SubBuildNode.js +1 -1
  178. package/src/nodes/core/UniformNode.js +2 -1
  179. package/src/nodes/core/VarNode.js +1 -1
  180. package/src/nodes/core/VaryingNode.js +1 -18
  181. package/src/nodes/display/BlendModes.js +0 -64
  182. package/src/nodes/display/ColorAdjustment.js +17 -0
  183. package/src/nodes/display/ColorSpaceNode.js +3 -3
  184. package/src/nodes/display/NormalMapNode.js +2 -2
  185. package/src/nodes/display/PassNode.js +21 -2
  186. package/src/nodes/display/RenderOutputNode.js +3 -3
  187. package/src/nodes/display/ScreenNode.js +2 -1
  188. package/src/nodes/display/ToneMappingNode.js +1 -1
  189. package/src/nodes/display/ToonOutlinePassNode.js +2 -2
  190. package/src/nodes/display/ViewportDepthNode.js +52 -4
  191. package/src/nodes/display/ViewportTextureNode.js +21 -4
  192. package/src/nodes/fog/Fog.js +18 -35
  193. package/src/nodes/functions/PhysicalLightingModel.js +25 -3
  194. package/src/nodes/geometry/RangeNode.js +4 -2
  195. package/src/nodes/gpgpu/ComputeNode.js +5 -4
  196. package/src/nodes/gpgpu/WorkgroupInfoNode.js +2 -1
  197. package/src/nodes/lighting/EnvironmentNode.js +28 -3
  198. package/src/nodes/lighting/PointShadowNode.js +24 -12
  199. package/src/nodes/lighting/ShadowFilterNode.js +15 -43
  200. package/src/nodes/lighting/ShadowNode.js +54 -32
  201. package/src/nodes/math/ConditionalNode.js +2 -2
  202. package/src/nodes/math/MathNode.js +3 -40
  203. package/src/nodes/math/OperatorNode.js +2 -1
  204. package/src/nodes/pmrem/PMREMUtils.js +9 -15
  205. package/src/nodes/tsl/TSLCore.js +13 -10
  206. package/src/nodes/utils/DebugNode.js +11 -11
  207. package/src/nodes/utils/JoinNode.js +2 -2
  208. package/src/nodes/utils/LoopNode.js +1 -1
  209. package/src/nodes/utils/MemberNode.js +1 -1
  210. package/src/nodes/utils/RTTNode.js +1 -1
  211. package/src/nodes/utils/ReflectorNode.js +2 -3
  212. package/src/nodes/utils/SpriteSheetUV.js +35 -0
  213. package/src/nodes/utils/UVUtils.js +4 -2
  214. package/src/objects/BatchedMesh.js +22 -12
  215. package/src/objects/InstancedMesh.js +11 -0
  216. package/src/renderers/WebGLRenderer.js +34 -60
  217. package/src/renderers/common/Backend.js +21 -0
  218. package/src/renderers/common/Background.js +7 -4
  219. package/src/renderers/common/BindGroup.js +1 -9
  220. package/src/renderers/common/Bindings.js +20 -5
  221. package/src/renderers/common/BlendMode.js +143 -0
  222. package/src/renderers/common/BundleGroup.js +1 -1
  223. package/src/renderers/common/CubeRenderTarget.js +50 -6
  224. package/src/renderers/common/Geometries.js +17 -3
  225. package/src/renderers/common/Lighting.js +5 -21
  226. package/src/renderers/common/Pipelines.js +4 -4
  227. package/src/renderers/common/PostProcessing.js +8 -206
  228. package/src/renderers/common/RenderBundles.js +2 -1
  229. package/src/renderers/common/RenderContext.js +16 -0
  230. package/src/renderers/common/RenderContexts.js +33 -56
  231. package/src/renderers/common/RenderLists.js +2 -1
  232. package/src/renderers/common/RenderObject.js +2 -3
  233. package/src/renderers/common/RenderObjectPipeline.js +40 -0
  234. package/src/renderers/common/RenderObjects.js +18 -2
  235. package/src/renderers/common/RenderPipeline.js +203 -17
  236. package/src/renderers/common/Renderer.js +207 -40
  237. package/src/renderers/common/Sampler.js +4 -4
  238. package/src/renderers/common/StorageBuffer.js +13 -1
  239. package/src/renderers/common/Textures.js +16 -0
  240. package/src/renderers/common/TimestampQueryPool.js +5 -3
  241. package/src/renderers/common/Uniform.js +8 -0
  242. package/src/renderers/common/UniformsGroup.js +60 -0
  243. package/src/renderers/common/XRManager.js +2 -2
  244. package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
  245. package/src/renderers/common/nodes/{Nodes.js → NodeManager.js} +18 -6
  246. package/src/renderers/common/nodes/NodeStorageBuffer.js +13 -2
  247. package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +2 -2
  248. package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +1 -5
  249. package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +1 -5
  250. package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -5
  251. package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +8 -10
  252. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +7 -11
  253. package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +6 -0
  254. package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +6 -2
  255. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +23 -1
  256. package/src/renderers/shaders/ShaderChunk/packing.glsl.js +20 -4
  257. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +55 -24
  258. package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -0
  259. package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -0
  260. package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -0
  261. package/src/renderers/shaders/ShaderLib.js +4 -2
  262. package/src/renderers/shaders/UniformsLib.js +0 -3
  263. package/src/renderers/webgl/WebGLBackground.js +2 -2
  264. package/src/renderers/webgl/WebGLBindingStates.js +99 -27
  265. package/src/renderers/webgl/WebGLEnvironments.js +228 -0
  266. package/src/renderers/webgl/WebGLGeometries.js +10 -7
  267. package/src/renderers/webgl/WebGLMaterials.js +12 -0
  268. package/src/renderers/webgl/WebGLObjects.js +3 -1
  269. package/src/renderers/webgl/WebGLProgram.js +2 -2
  270. package/src/renderers/webgl/WebGLPrograms.js +10 -4
  271. package/src/renderers/webgl/WebGLRenderLists.js +15 -0
  272. package/src/renderers/webgl/WebGLShadowMap.js +5 -4
  273. package/src/renderers/webgl/WebGLState.js +12 -17
  274. package/src/renderers/webgl-fallback/WebGLBackend.js +71 -7
  275. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +98 -29
  276. package/src/renderers/webgl-fallback/utils/WebGLState.js +168 -7
  277. package/src/renderers/webgpu/WebGPUBackend.js +58 -9
  278. package/src/renderers/webgpu/WebGPURenderer.js +1 -0
  279. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +257 -45
  280. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +8 -19
  281. package/src/renderers/webgpu/utils/WebGPUConstants.js +1 -1
  282. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +56 -31
  283. package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +152 -200
  284. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +25 -25
  285. package/src/renderers/webgpu/utils/WebGPUUtils.js +10 -6
  286. package/src/renderers/webxr/WebXRManager.js +2 -2
  287. package/src/textures/Texture.js +2 -2
  288. package/src/utils.js +246 -3
  289. package/examples/jsm/materials/MeshGouraudMaterial.js +0 -433
  290. package/examples/jsm/materials/MeshPostProcessingMaterial.js +0 -167
  291. package/examples/jsm/shaders/GodRaysShader.js +0 -333
  292. package/src/nodes/accessors/SceneNode.js +0 -145
  293. package/src/nodes/code/ScriptableNode.js +0 -726
  294. package/src/nodes/code/ScriptableValueNode.js +0 -253
  295. package/src/nodes/display/PosterizeNode.js +0 -65
  296. package/src/nodes/utils/SpriteSheetUVNode.js +0 -90
  297. package/src/renderers/webgl/WebGLCubeMaps.js +0 -99
  298. package/src/renderers/webgl/WebGLCubeUVMaps.js +0 -134
@@ -1,4 +1,5 @@
1
1
  import { error } from '../../utils.js';
2
+ import StackTrace from '../core/StackTrace.js';
2
3
  import PropertyNode from './PropertyNode.js';
3
4
 
4
5
  /**
@@ -55,7 +56,7 @@ class ParameterNode extends PropertyNode {
55
56
 
56
57
  } else {
57
58
 
58
- error( `TSL: Member "${ name }" not found in struct "${ type }".` );
59
+ error( `TSL: Member "${ name }" not found in struct "${ type }".`, new StackTrace() );
59
60
 
60
61
  memberType = 'float';
61
62
 
@@ -1,4 +1,5 @@
1
1
  import Node from './Node.js';
2
+ import StackTrace from '../core/StackTrace.js';
2
3
  import { select } from '../math/ConditionalNode.js';
3
4
  import { ShaderNode, nodeProxy, getCurrentStack, setCurrentStack, nodeObject } from '../tsl/TSLBase.js';
4
5
  import { error } from '../../utils.js';
@@ -90,19 +91,19 @@ class StackNode extends Node {
90
91
 
91
92
  getElementType( builder ) {
92
93
 
93
- return this.hasOutput ? this.outputNode.getElementType( builder ) : 'void';
94
+ return this.hasOutput( builder ) ? this.outputNode.getElementType( builder ) : 'void';
94
95
 
95
96
  }
96
97
 
97
98
  getNodeType( builder ) {
98
99
 
99
- return this.hasOutput ? this.outputNode.getNodeType( builder ) : 'void';
100
+ return this.hasOutput( builder ) ? this.outputNode.getNodeType( builder ) : 'void';
100
101
 
101
102
  }
102
103
 
103
104
  getMemberType( builder, name ) {
104
105
 
105
- return this.hasOutput ? this.outputNode.getMemberType( builder, name ) : 'void';
106
+ return this.hasOutput( builder ) ? this.outputNode.getMemberType( builder, name ) : 'void';
106
107
 
107
108
  }
108
109
 
@@ -117,7 +118,7 @@ class StackNode extends Node {
117
118
 
118
119
  if ( node.isNode !== true ) {
119
120
 
120
- error( 'TSL: Invalid node added to stack.' );
121
+ error( 'TSL: Invalid node added to stack.', new StackTrace() );
121
122
  return this;
122
123
 
123
124
  }
@@ -229,7 +230,7 @@ class StackNode extends Node {
229
230
 
230
231
  } else {
231
232
 
232
- error( 'TSL: Invalid parameter length. Case() requires at least two parameters.' );
233
+ error( 'TSL: Invalid parameter length. Case() requires at least two parameters.', new StackTrace() );
233
234
 
234
235
  }
235
236
 
@@ -311,9 +312,9 @@ class StackNode extends Node {
311
312
 
312
313
  }
313
314
 
314
- get hasOutput() {
315
+ hasOutput( builder ) {
315
316
 
316
- return this.outputNode && this.outputNode.isNode;
317
+ return this.outputNode && this.outputNode.isNode && this.outputNode.getNodeType( builder ) !== 'void';
317
318
 
318
319
  }
319
320
 
@@ -392,7 +393,7 @@ class StackNode extends Node {
392
393
 
393
394
  let result;
394
395
 
395
- if ( this.hasOutput ) {
396
+ if ( this.hasOutput( builder ) ) {
396
397
 
397
398
  result = this.outputNode.build( builder, ...params );
398
399
 
@@ -0,0 +1,139 @@
1
+ // Pre-compiled RegExp patterns for ignored files
2
+ const IGNORED_FILES = [
3
+ /^StackTrace\.js$/,
4
+ /^TSLCore\.js$/,
5
+ /^.*Node\.js$/,
6
+ /^three\.webgpu.*\.js$/
7
+ ];
8
+
9
+ /**
10
+ * Parses the stack trace and filters out ignored files.
11
+ * Returns an array with function name, file, line, and column.
12
+ */
13
+ function getFilteredStack( stack ) {
14
+
15
+ // Pattern to extract function name, file, line, and column from different browsers
16
+ // Chrome: "at functionName (file.js:1:2)" or "at file.js:1:2"
17
+ // Firefox: "functionName@file.js:1:2"
18
+ const regex = /(?:at\s+(.+?)\s+\()?(?:(.+?)@)?([^@\s()]+):(\d+):(\d+)/;
19
+
20
+ return stack.split( '\n' )
21
+ .map( line => {
22
+
23
+ const match = line.match( regex );
24
+ if ( ! match ) return null; // Skip if line format is invalid
25
+
26
+ // Chrome: match[1], Firefox: match[2]
27
+ const fn = match[ 1 ] || match[ 2 ] || '';
28
+ const file = match[ 3 ].split( '?' )[ 0 ]; // Clean file name (Vite/HMR)
29
+ const lineNum = parseInt( match[ 4 ], 10 );
30
+ const column = parseInt( match[ 5 ], 10 );
31
+
32
+ // Extract only the filename from full path
33
+ const fileName = file.split( '/' ).pop();
34
+
35
+ return {
36
+ fn: fn,
37
+ file: fileName,
38
+ line: lineNum,
39
+ column: column
40
+ };
41
+
42
+ } )
43
+ .filter( frame => {
44
+
45
+ // Only keep frames that are valid and not in the ignore list
46
+ return frame && ! IGNORED_FILES.some( regex => regex.test( frame.file ) );
47
+
48
+ } );
49
+
50
+ }
51
+
52
+ /**
53
+ * Class representing a stack trace for debugging purposes.
54
+ */
55
+ class StackTrace {
56
+
57
+ /**
58
+ * Creates a StackTrace instance by capturing and filtering the current stack trace.
59
+ *
60
+ * @param {Error|string|null} stackMessage - An optional stack trace to use instead of capturing a new one.
61
+ */
62
+ constructor( stackMessage = null ) {
63
+
64
+ /**
65
+ * This flag can be used for type testing.
66
+ *
67
+ * @type {boolean}
68
+ * @readonly
69
+ * @default true
70
+ */
71
+ this.isStackTrace = true;
72
+
73
+ /**
74
+ * The stack trace.
75
+ *
76
+ * @type {Array<{fn: string, file: string, line: number, column: number}>}
77
+ */
78
+ this.stack = getFilteredStack( stackMessage ? stackMessage : new Error().stack );
79
+
80
+ }
81
+
82
+ /**
83
+ * Returns a formatted location string of the top stack frame.
84
+ *
85
+ * @returns {string} The formatted stack trace message.
86
+ */
87
+ getLocation() {
88
+
89
+ if ( this.stack.length === 0 ) {
90
+
91
+ return '[Unknown location]';
92
+
93
+ }
94
+
95
+ const mainStack = this.stack[ 0 ];
96
+
97
+ const fn = mainStack.fn;
98
+ const fnName = fn ? `"${ fn }()" at ` : '';
99
+
100
+ return `${fnName}"${mainStack.file}:${mainStack.line}"`; // :${mainStack.column}
101
+
102
+ }
103
+
104
+ /**
105
+ * Returns the full error message including the stack trace.
106
+ *
107
+ * @param {string} message - The error message.
108
+ * @returns {string} The full error message with stack trace.
109
+ */
110
+ getError( message ) {
111
+
112
+ if ( this.stack.length === 0 ) {
113
+
114
+ return message;
115
+
116
+ }
117
+
118
+ // Output: "Error: message\n at functionName (file.js:line:column)"
119
+ const stackString = this.stack.map( frame => {
120
+
121
+ const location = `${ frame.file }:${ frame.line }:${ frame.column }`;
122
+
123
+ if ( frame.fn ) {
124
+
125
+ return ` at ${ frame.fn } (${ location })`;
126
+
127
+ }
128
+
129
+ return ` at ${ location }`;
130
+
131
+ } ).join( '\n' );
132
+
133
+ return `${ message }\n${ stackString }`;
134
+
135
+ }
136
+
137
+ }
138
+
139
+ export default StackTrace;
@@ -52,6 +52,21 @@ class StructNode extends Node {
52
52
 
53
53
  }
54
54
 
55
+ _getChildren() {
56
+
57
+ // Ensure struct type is the last child for correct code generation order
58
+
59
+ const children = super._getChildren();
60
+
61
+ const structTypeProperty = children.find( child => child.childNode === this.structTypeNode );
62
+
63
+ children.splice( children.indexOf( structTypeProperty ), 1 );
64
+ children.push( structTypeProperty );
65
+
66
+ return children;
67
+
68
+ }
69
+
55
70
  generate( builder ) {
56
71
 
57
72
  const nodeVar = builder.getVarFromNode( this );
@@ -86,4 +86,4 @@ export default SubBuildNode;
86
86
  * @param {?string} [type=null] - The type of the node, if known.
87
87
  * @returns {Node} A node object wrapping the SubBuildNode instance.
88
88
  */
89
- export const subBuild = ( node, name, type = null ) => nodeObject( new SubBuildNode( nodeObject( node ), name, type ) );
89
+ export const subBuild = ( node, name, type = null ) => new SubBuildNode( nodeObject( node ), name, type );
@@ -1,4 +1,5 @@
1
1
  import InputNode from './InputNode.js';
2
+ import StackTrace from '../core/StackTrace.js';
2
3
  import { objectGroup } from './UniformGroupNode.js';
3
4
  import { getConstNodeType } from '../tsl/TSLCore.js';
4
5
  import { getValueFromType } from './NodeUtils.js';
@@ -78,7 +79,7 @@ class UniformNode extends InputNode {
78
79
  */
79
80
  label( name ) {
80
81
 
81
- warn( 'TSL: "label()" has been deprecated. Use "setName()" instead.' ); // @deprecated r179
82
+ warn( 'TSL: "label()" has been deprecated. Use "setName()" instead.', new StackTrace() ); // @deprecated r179
82
83
 
83
84
  return this.setName( name );
84
85
 
@@ -254,7 +254,7 @@ class VarNode extends Node {
254
254
 
255
255
  if ( this.isIntent( builder ) !== true ) {
256
256
 
257
- error( 'TSL: ".toVar()" can not be used with void type.' );
257
+ error( 'TSL: ".toVar()" can not be used with void type.', this.stackTrace );
258
258
 
259
259
  }
260
260
 
@@ -2,7 +2,6 @@ import Node from './Node.js';
2
2
  import { NodeShaderStage } from './constants.js';
3
3
  import { addMethodChaining, nodeProxy } from '../tsl/TSLCore.js';
4
4
  import { subBuild } from './SubBuildNode.js';
5
- import { warn } from '../../utils.js';
6
5
 
7
6
  /**
8
7
  * Class for representing shader varyings as nodes. Varyings are create from
@@ -37,7 +36,7 @@ class VaryingNode extends Node {
37
36
  *
38
37
  * @type {Node}
39
38
  */
40
- this.node = node;
39
+ this.node = subBuild( node, 'VERTEX' );
41
40
 
42
41
  /**
43
42
  * The name of the varying in the shader. If no name is defined,
@@ -209,19 +208,3 @@ export const vertexStage = ( node ) => varying( node );
209
208
 
210
209
  addMethodChaining( 'toVarying', varying );
211
210
  addMethodChaining( 'toVertexStage', vertexStage );
212
-
213
- // Deprecated
214
-
215
- addMethodChaining( 'varying', ( ...params ) => { // @deprecated, r173
216
-
217
- warn( 'TSL: .varying() has been renamed to .toVarying().' );
218
- return varying( ...params );
219
-
220
- } );
221
-
222
- addMethodChaining( 'vertexStage', ( ...params ) => { // @deprecated, r173
223
-
224
- warn( 'TSL: .vertexStage() has been renamed to .toVertexStage().' );
225
- return varying( ...params );
226
-
227
- } );
@@ -1,6 +1,5 @@
1
1
  import { Fn, If, vec4 } from '../tsl/TSLBase.js';
2
2
  import { mix, min, step } from '../math/MathNode.js';
3
- import { warn } from '../../utils.js';
4
3
 
5
4
  /**
6
5
  * Represents a "Color Burn" blend mode.
@@ -170,66 +169,3 @@ export const unpremultiplyAlpha = /*@__PURE__*/ Fn( ( [ color ] ) => {
170
169
  return vec4( color.rgb.div( color.a ), color.a );
171
170
 
172
171
  }, { color: 'vec4', return: 'vec4' } );
173
-
174
-
175
- // Deprecated
176
-
177
- /**
178
- * @tsl
179
- * @function
180
- * @deprecated since r171. Use {@link blendBurn} instead.
181
- *
182
- * @param {...any} params
183
- * @returns {Function}
184
- */
185
- export const burn = ( ...params ) => { // @deprecated, r171
186
-
187
- warn( 'TSL: "burn" has been renamed. Use "blendBurn" instead.' );
188
- return blendBurn( params );
189
-
190
- };
191
-
192
- /**
193
- * @tsl
194
- * @function
195
- * @deprecated since r171. Use {@link blendDodge} instead.
196
- *
197
- * @param {...any} params
198
- * @returns {Function}
199
- */
200
- export const dodge = ( ...params ) => { // @deprecated, r171
201
-
202
- warn( 'TSL: "dodge" has been renamed. Use "blendDodge" instead.' );
203
- return blendDodge( params );
204
-
205
- };
206
-
207
- /**
208
- * @tsl
209
- * @function
210
- * @deprecated since r171. Use {@link blendScreen} instead.
211
- *
212
- * @param {...any} params
213
- * @returns {Function}
214
- */
215
- export const screen = ( ...params ) => { // @deprecated, r171
216
-
217
- warn( 'TSL: "screen" has been renamed. Use "blendScreen" instead.' );
218
- return blendScreen( params );
219
-
220
- };
221
-
222
- /**
223
- * @tsl
224
- * @function
225
- * @deprecated since r171. Use {@link blendOverlay} instead.
226
- *
227
- * @param {...any} params
228
- * @returns {Function}
229
- */
230
- export const overlay = ( ...params ) => { // @deprecated, r171
231
-
232
- warn( 'TSL: "overlay" has been renamed. Use "blendOverlay" instead.' );
233
- return blendOverlay( params );
234
-
235
- };
@@ -139,3 +139,20 @@ export const cdl = /*@__PURE__*/ Fn( ( [
139
139
  return vec4( v.rgb, color.a );
140
140
 
141
141
  } );
142
+
143
+ /**
144
+ * TSL function for creating a posterize effect which reduces the number of colors
145
+ * in an image, resulting in a more blocky and stylized appearance.
146
+ *
147
+ * @tsl
148
+ * @function
149
+ * @param {Node} sourceNode - The input color.
150
+ * @param {Node} stepsNode - Controls the intensity of the posterization effect. A lower number results in a more blocky appearance.
151
+ * @returns {Node} The posterized color.
152
+ */
153
+ export const posterize = Fn( ( [ source, steps ] ) => {
154
+
155
+ return source.mul( steps ).floor().div( steps );
156
+
157
+ } );
158
+
@@ -135,7 +135,7 @@ export default ColorSpaceNode;
135
135
  * @param {string} targetColorSpace - The target color space.
136
136
  * @returns {ColorSpaceNode}
137
137
  */
138
- export const workingToColorSpace = ( node, targetColorSpace ) => nodeObject( new ColorSpaceNode( nodeObject( node ), WORKING_COLOR_SPACE, targetColorSpace ) );
138
+ export const workingToColorSpace = ( node, targetColorSpace ) => new ColorSpaceNode( nodeObject( node ), WORKING_COLOR_SPACE, targetColorSpace );
139
139
 
140
140
  /**
141
141
  * TSL function for converting a given color node from the given color space to the current working color space.
@@ -146,7 +146,7 @@ export const workingToColorSpace = ( node, targetColorSpace ) => nodeObject( new
146
146
  * @param {string} sourceColorSpace - The source color space.
147
147
  * @returns {ColorSpaceNode}
148
148
  */
149
- export const colorSpaceToWorking = ( node, sourceColorSpace ) => nodeObject( new ColorSpaceNode( nodeObject( node ), sourceColorSpace, WORKING_COLOR_SPACE ) );
149
+ export const colorSpaceToWorking = ( node, sourceColorSpace ) => new ColorSpaceNode( nodeObject( node ), sourceColorSpace, WORKING_COLOR_SPACE );
150
150
 
151
151
  /**
152
152
  * TSL function for converting a given color node from one color space to another one.
@@ -158,7 +158,7 @@ export const colorSpaceToWorking = ( node, sourceColorSpace ) => nodeObject( new
158
158
  * @param {string} targetColorSpace - The target color space.
159
159
  * @returns {ColorSpaceNode}
160
160
  */
161
- export const convertColorSpace = ( node, sourceColorSpace, targetColorSpace ) => nodeObject( new ColorSpaceNode( nodeObject( node ), sourceColorSpace, targetColorSpace ) );
161
+ export const convertColorSpace = ( node, sourceColorSpace, targetColorSpace ) => new ColorSpaceNode( nodeObject( node ), sourceColorSpace, targetColorSpace );
162
162
 
163
163
  addMethodChaining( 'workingToColorSpace', workingToColorSpace );
164
164
  addMethodChaining( 'colorSpaceToWorking', colorSpaceToWorking );
@@ -69,7 +69,7 @@ class NormalMapNode extends TempNode {
69
69
 
70
70
  }
71
71
 
72
- setup( { material } ) {
72
+ setup( builder ) {
73
73
 
74
74
  const { normalMapType, scaleNode, unpackNormalMode } = this;
75
75
 
@@ -105,7 +105,7 @@ class NormalMapNode extends TempNode {
105
105
 
106
106
  let scale = scaleNode;
107
107
 
108
- if ( material.flatShading === true ) {
108
+ if ( builder.isFlatShading() === true ) {
109
109
 
110
110
  scale = directionToFaceDirection( scale );
111
111
 
@@ -44,13 +44,23 @@ class PassTextureNode extends TextureNode {
44
44
  */
45
45
  this.passNode = passNode;
46
46
 
47
+ /**
48
+ * This flag can be used for type testing.
49
+ *
50
+ * @type {boolean}
51
+ * @default true
52
+ * @readonly
53
+ */
54
+ this.isPassTextureNode = true;
55
+
47
56
  this.setUpdateMatrix( false );
48
57
 
49
58
  }
50
59
 
51
60
  setup( builder ) {
52
61
 
53
- this.passNode.build( builder );
62
+ const properties = builder.getNodeProperties( this );
63
+ properties.passNode = this.passNode;
54
64
 
55
65
  return super.setup( builder );
56
66
 
@@ -107,6 +117,15 @@ class PassMultipleTextureNode extends PassTextureNode {
107
117
  */
108
118
  this.previousTexture = previousTexture;
109
119
 
120
+ /**
121
+ * This flag can be used for type testing.
122
+ *
123
+ * @type {boolean}
124
+ * @default true
125
+ * @readonly
126
+ */
127
+ this.isPassMultipleTextureNode = true;
128
+
110
129
  }
111
130
 
112
131
  /**
@@ -150,7 +169,7 @@ class PassMultipleTextureNode extends PassTextureNode {
150
169
  * via MRT for further processing.
151
170
  *
152
171
  * ```js
153
- * const postProcessing = new PostProcessing( renderer );
172
+ * const postProcessing = new RenderPipeline( renderer );
154
173
  *
155
174
  * const scenePass = pass( scene, camera );
156
175
  *
@@ -13,10 +13,10 @@ import { ColorManagement } from '../../math/ColorManagement.js';
13
13
  * in the effect chain.
14
14
  *
15
15
  * When applying tone mapping and color space conversion manually with this node,
16
- * you have to set {@link PostProcessing#outputColorTransform} to `false`.
16
+ * you have to set {@link RenderPipeline#outputColorTransform} to `false`.
17
17
  *
18
18
  * ```js
19
- * const postProcessing = new PostProcessing( renderer );
19
+ * const postProcessing = new RenderPipeline( renderer );
20
20
  * postProcessing.outputColorTransform = false;
21
21
  *
22
22
  * const scenePass = pass( scene, camera );
@@ -145,6 +145,6 @@ export default RenderOutputNode;
145
145
  * @param {?string} [outputColorSpace=null] - The output color space.
146
146
  * @returns {RenderOutputNode}
147
147
  */
148
- export const renderOutput = ( color, toneMapping = null, outputColorSpace = null ) => nodeObject( new RenderOutputNode( nodeObject( color ), toneMapping, outputColorSpace ) );
148
+ export const renderOutput = ( color, toneMapping = null, outputColorSpace = null ) => new RenderOutputNode( nodeObject( color ), toneMapping, outputColorSpace );
149
149
 
150
150
  addMethodChaining( 'renderOutput', renderOutput );
@@ -1,4 +1,5 @@
1
1
  import Node from '../core/Node.js';
2
+ import StackTrace from '../core/StackTrace.js';
2
3
  import { NodeUpdateType } from '../core/constants.js';
3
4
  import { uniform } from '../core/UniformNode.js';
4
5
  import { Fn, nodeImmutable, vec2 } from '../tsl/TSLBase.js';
@@ -284,7 +285,7 @@ export const viewportUV = /*@__PURE__*/ viewportCoordinate.div( viewportSize );
284
285
  */
285
286
  export const viewportResolution = /*@__PURE__*/ ( Fn( () => { // @deprecated, r169
286
287
 
287
- warn( 'TSL: "viewportResolution" is deprecated. Use "screenSize" instead.' );
288
+ warn( 'TSL: "viewportResolution" is deprecated. Use "screenSize" instead.', new StackTrace() );
288
289
 
289
290
  return screenSize;
290
291
 
@@ -134,7 +134,7 @@ export default ToneMappingNode;
134
134
  * @param {Node<vec3> | Color} color - The color node to process.
135
135
  * @returns {ToneMappingNode<vec3>}
136
136
  */
137
- export const toneMapping = ( mapping, exposure, color ) => nodeObject( new ToneMappingNode( mapping, nodeObject( exposure ), nodeObject( color ) ) );
137
+ export const toneMapping = ( mapping, exposure, color ) => new ToneMappingNode( mapping, nodeObject( exposure ), nodeObject( color ) );
138
138
 
139
139
  /**
140
140
  * TSL object that represents the global tone mapping exposure of the renderer.
@@ -14,7 +14,7 @@ import PassNode from './PassNode.js';
14
14
  * will receive the outline.
15
15
  *
16
16
  * ```js
17
- * const postProcessing = new PostProcessing( renderer );
17
+ * const postProcessing = new RenderPipeline( renderer );
18
18
  *
19
19
  * const scenePass = toonOutlinePass( scene, camera );
20
20
  *
@@ -188,4 +188,4 @@ export default ToonOutlinePassNode;
188
188
  * @param {number} [alpha=1] - Defines the outline's alpha.
189
189
  * @returns {ToonOutlinePassNode}
190
190
  */
191
- export const toonOutlinePass = ( scene, camera, color = new Color( 0, 0, 0 ), thickness = 0.003, alpha = 1 ) => nodeObject( new ToonOutlinePassNode( scene, camera, nodeObject( color ), nodeObject( thickness ), nodeObject( alpha ) ) );
191
+ export const toonOutlinePass = ( scene, camera, color = new Color( 0, 0, 0 ), thickness = 0.003, alpha = 1 ) => new ToonOutlinePassNode( scene, camera, nodeObject( color ), nodeObject( thickness ), nodeObject( alpha ) );
@@ -1,5 +1,5 @@
1
1
  import Node from '../core/Node.js';
2
- import { float, log, log2, nodeImmutable, nodeProxy } from '../tsl/TSLBase.js';
2
+ import { float, Fn, log, log2, nodeImmutable, nodeProxy } from '../tsl/TSLBase.js';
3
3
  import { cameraNear, cameraFar } from '../accessors/Camera.js';
4
4
  import { positionView } from '../accessors/Position.js';
5
5
  import { viewportDepthTexture } from './ViewportDepthTextureNode.js';
@@ -86,7 +86,7 @@ class ViewportDepthNode extends Node {
86
86
 
87
87
  if ( value !== null ) {
88
88
 
89
- node = depthBase().assign( value );
89
+ node = depthBase().assign( value );
90
90
 
91
91
  }
92
92
 
@@ -152,6 +152,18 @@ export default ViewportDepthNode;
152
152
  */
153
153
  export const viewZToOrthographicDepth = ( viewZ, near, far ) => viewZ.add( near ).div( near.sub( far ) );
154
154
 
155
+ /**
156
+ * TSL function for converting a viewZ value to a reversed orthographic depth value.
157
+ *
158
+ * @tsl
159
+ * @function
160
+ * @param {Node<float>} viewZ - The viewZ node.
161
+ * @param {Node<float>} near - The camera's near value.
162
+ * @param {Node<float>} far - The camera's far value.
163
+ * @returns {Node<float>}
164
+ */
165
+ export const viewZToReversedOrthographicDepth = ( viewZ, near, far ) => viewZ.add( far ).div( far.sub( near ) );
166
+
155
167
  /**
156
168
  * TSL function for converting an orthographic depth value to a viewZ value.
157
169
  *
@@ -162,7 +174,19 @@ export const viewZToOrthographicDepth = ( viewZ, near, far ) => viewZ.add( near
162
174
  * @param {Node<float>} far - The camera's far value.
163
175
  * @returns {Node<float>}
164
176
  */
165
- export const orthographicDepthToViewZ = ( depth, near, far ) => near.sub( far ).mul( depth ).sub( near );
177
+ export const orthographicDepthToViewZ = /*@__PURE__*/ Fn( ( [ depth, near, far ], builder ) => {
178
+
179
+ if ( builder.renderer.reversedDepthBuffer === true ) {
180
+
181
+ return far.sub( near ).mul( depth ).sub( far );
182
+
183
+ } else {
184
+
185
+ return near.sub( far ).mul( depth ).sub( near );
186
+
187
+ }
188
+
189
+ } );
166
190
 
167
191
  /**
168
192
  * TSL function for converting a viewZ value to a perspective depth value.
@@ -178,6 +202,18 @@ export const orthographicDepthToViewZ = ( depth, near, far ) => near.sub( far ).
178
202
  */
179
203
  export const viewZToPerspectiveDepth = ( viewZ, near, far ) => near.add( viewZ ).mul( far ).div( far.sub( near ).mul( viewZ ) );
180
204
 
205
+ /**
206
+ * TSL function for converting a viewZ value to a reversed perspective depth value.
207
+ *
208
+ * @tsl
209
+ * @function
210
+ * @param {Node<float>} viewZ - The viewZ node.
211
+ * @param {Node<float>} near - The camera's near value.
212
+ * @param {Node<float>} far - The camera's far value.
213
+ * @returns {Node<float>}
214
+ */
215
+ export const viewZToReversedPerspectiveDepth = ( viewZ, near, far ) => near.mul( viewZ.add( far ) ).div( viewZ.mul( near.sub( far ) ) );
216
+
181
217
  /**
182
218
  * TSL function for converting a perspective depth value to a viewZ value.
183
219
  *
@@ -188,7 +224,19 @@ export const viewZToPerspectiveDepth = ( viewZ, near, far ) => near.add( viewZ )
188
224
  * @param {Node<float>} far - The camera's far value.
189
225
  * @returns {Node<float>}
190
226
  */
191
- export const perspectiveDepthToViewZ = ( depth, near, far ) => near.mul( far ).div( far.sub( near ).mul( depth ).sub( far ) );
227
+ export const perspectiveDepthToViewZ = /*@__PURE__*/ Fn( ( [ depth, near, far ], builder ) => {
228
+
229
+ if ( builder.renderer.reversedDepthBuffer === true ) {
230
+
231
+ return near.mul( far ).div( near.sub( far ).mul( depth ).sub( near ) );
232
+
233
+ } else {
234
+
235
+ return near.mul( far ).div( far.sub( near ).mul( depth ).sub( far ) );
236
+
237
+ }
238
+
239
+ } );
192
240
 
193
241
  /**
194
242
  * TSL function for converting a viewZ value to a logarithmic depth value.