super-three 0.184.0 → 0.185.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 (366) hide show
  1. package/build/three.cjs +1260 -927
  2. package/build/three.core.js +1104 -829
  3. package/build/three.core.min.js +1 -1
  4. package/build/three.module.js +156 -98
  5. package/build/three.module.min.js +1 -1
  6. package/build/three.tsl.js +11 -4
  7. package/build/three.tsl.min.js +1 -1
  8. package/build/three.webgpu.js +7538 -3367
  9. package/build/three.webgpu.min.js +1 -1
  10. package/build/three.webgpu.nodes.js +7538 -3366
  11. package/build/three.webgpu.nodes.min.js +1 -1
  12. package/examples/jsm/Addons.js +3 -0
  13. package/examples/jsm/controls/ArcballControls.js +6 -2
  14. package/examples/jsm/controls/FirstPersonControls.js +79 -42
  15. package/examples/jsm/controls/TransformControls.js +68 -15
  16. package/examples/jsm/csm/CSMFrustum.js +31 -6
  17. package/examples/jsm/csm/CSMShadowNode.js +4 -1
  18. package/examples/jsm/effects/AsciiEffect.js +14 -1
  19. package/examples/jsm/exporters/DRACOExporter.js +27 -6
  20. package/examples/jsm/exporters/GLTFExporter.js +114 -12
  21. package/examples/jsm/exporters/PLYExporter.js +286 -73
  22. package/examples/jsm/exporters/USDZExporter.js +347 -112
  23. package/examples/jsm/generators/CityGenerator.js +346 -0
  24. package/examples/jsm/generators/ForestGenerator.js +347 -0
  25. package/examples/jsm/generators/TerrainGenerator.js +504 -0
  26. package/examples/jsm/generators/TreeGenerator.js +377 -0
  27. package/examples/jsm/generators/city/SidewalkGenerator.js +253 -0
  28. package/examples/jsm/generators/city/SkyscraperGenerator.js +1357 -0
  29. package/examples/jsm/geometries/LoftGeometry.js +355 -0
  30. package/examples/jsm/helpers/LightProbeGridHelper.js +1 -1
  31. package/examples/jsm/helpers/LightProbeHelper.js +5 -4
  32. package/examples/jsm/helpers/ViewHelper.js +16 -6
  33. package/examples/jsm/inspector/Inspector.js +53 -15
  34. package/examples/jsm/inspector/RendererInspector.js +152 -36
  35. package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphEditor.js +1 -1
  36. package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphLoader.js +1 -1
  37. package/examples/jsm/inspector/tabs/Console.js +200 -18
  38. package/examples/jsm/inspector/tabs/Memory.js +8 -0
  39. package/examples/jsm/inspector/tabs/Parameters.js +64 -4
  40. package/examples/jsm/inspector/tabs/Performance.js +21 -6
  41. package/examples/jsm/inspector/tabs/Settings.js +51 -9
  42. package/examples/jsm/inspector/tabs/Timeline.js +178 -93
  43. package/examples/jsm/inspector/tabs/Viewer.js +628 -16
  44. package/examples/jsm/inspector/ui/Graph.js +162 -25
  45. package/examples/jsm/inspector/ui/Item.js +92 -13
  46. package/examples/jsm/inspector/ui/List.js +1 -1
  47. package/examples/jsm/inspector/ui/Profiler.js +90 -45
  48. package/examples/jsm/inspector/ui/Style.js +1788 -1401
  49. package/examples/jsm/inspector/ui/Tab.js +5 -3
  50. package/examples/jsm/inspector/ui/Values.js +71 -6
  51. package/examples/jsm/inspector/ui/utils.js +130 -10
  52. package/examples/jsm/libs/basis/README.md +0 -1
  53. package/examples/jsm/libs/demuxer_mp4.js +3 -3
  54. package/examples/jsm/libs/draco/README.md +0 -1
  55. package/examples/jsm/libs/meshopt_clusterizer.module.js +421 -0
  56. package/examples/jsm/libs/meshopt_simplifier.module.js +627 -0
  57. package/examples/jsm/libs/mikktspace.module.js +34 -9
  58. package/examples/jsm/lighting/ClusteredLighting.js +55 -0
  59. package/examples/jsm/lighting/LightProbeGrid.js +106 -76
  60. package/examples/jsm/lines/LineMaterial.js +38 -15
  61. package/examples/jsm/lines/LineSegments2.js +8 -0
  62. package/examples/jsm/lines/webgpu/LineSegments2.js +8 -0
  63. package/examples/jsm/loaders/3DMLoader.js +1 -1
  64. package/examples/jsm/loaders/DRACOLoader.js +46 -13
  65. package/examples/jsm/loaders/EXRLoader.js +27 -55
  66. package/examples/jsm/loaders/HDRLoader.js +6 -28
  67. package/examples/jsm/loaders/KTX2Loader.js +31 -12
  68. package/examples/jsm/loaders/LDrawLoader.js +8 -8
  69. package/examples/jsm/loaders/LUT3dlLoader.js +2 -2
  70. package/examples/jsm/loaders/LUTCubeLoader.js +2 -2
  71. package/examples/jsm/loaders/LWOLoader.js +4 -0
  72. package/examples/jsm/loaders/LottieLoader.js +1 -1
  73. package/examples/jsm/loaders/MaterialXLoader.js +31 -9
  74. package/examples/jsm/loaders/NRRDLoader.js +3 -3
  75. package/examples/jsm/loaders/PCDLoader.js +7 -7
  76. package/examples/jsm/loaders/PLYLoader.js +218 -55
  77. package/examples/jsm/loaders/SVGLoader.js +547 -495
  78. package/examples/jsm/loaders/TTFLoader.js +1 -1
  79. package/examples/jsm/loaders/USDLoader.js +33 -9
  80. package/examples/jsm/loaders/VRMLLoader.js +1 -1
  81. package/examples/jsm/loaders/usd/USDAParser.js +93 -20
  82. package/examples/jsm/loaders/usd/USDCParser.js +1 -1
  83. package/examples/jsm/loaders/usd/USDComposer.js +52 -19
  84. package/examples/jsm/misc/TileCreasedNormalsPlugin.js +270 -0
  85. package/examples/jsm/misc/Volume.js +2 -2
  86. package/examples/jsm/objects/GroundedSkybox.js +1 -1
  87. package/examples/jsm/objects/Reflector.js +2 -3
  88. package/examples/jsm/objects/Water2Mesh.js +1 -1
  89. package/examples/jsm/physics/AmmoPhysics.js +15 -8
  90. package/examples/jsm/physics/RapierPhysics.js +27 -2
  91. package/examples/jsm/shaders/VolumeShader.js +31 -44
  92. package/examples/jsm/transpiler/GLSLDecoder.js +6 -6
  93. package/examples/jsm/transpiler/Linker.js +1 -1
  94. package/examples/jsm/tsl/display/BloomNode.js +59 -19
  95. package/examples/jsm/tsl/display/DepthOfFieldNode.js +2 -2
  96. package/examples/jsm/tsl/display/FXAANode.js +11 -12
  97. package/examples/jsm/tsl/display/GTAONode.js +34 -13
  98. package/examples/jsm/tsl/display/GodraysNode.js +1 -1
  99. package/examples/jsm/tsl/display/ImportanceSampledEnvironment.js +560 -0
  100. package/examples/jsm/tsl/display/PixelationPassNode.js +2 -2
  101. package/examples/jsm/tsl/display/RecurrentDenoiseNode.js +912 -0
  102. package/examples/jsm/tsl/display/SSAAPassNode.js +13 -25
  103. package/examples/jsm/tsl/display/SSGINode.js +89 -39
  104. package/examples/jsm/tsl/display/SSRNode.js +829 -132
  105. package/examples/jsm/tsl/display/SSSNode.js +2 -2
  106. package/examples/jsm/tsl/display/TemporalReprojectNode.js +1023 -0
  107. package/examples/jsm/tsl/lighting/ClusteredLightsNode.js +622 -0
  108. package/examples/jsm/tsl/lighting/DynamicLightsNode.js +1 -1
  109. package/examples/jsm/tsl/math/curlNoise.js +107 -0
  110. package/examples/jsm/tsl/shadows/TileShadowNode.js +1 -1
  111. package/examples/jsm/tsl/shadows/TileShadowNodeHelper.js +3 -3
  112. package/examples/jsm/tsl/utils/GroundedSkybox.js +62 -0
  113. package/examples/jsm/tsl/utils/RNoise.js +51 -0
  114. package/examples/jsm/tsl/utils/SpecularHelpers.js +325 -0
  115. package/examples/jsm/utils/BufferGeometryUtils.js +126 -59
  116. package/examples/jsm/utils/GeometryCompressionUtils.js +1 -1
  117. package/examples/jsm/utils/SceneOptimizer.js +1 -1
  118. package/examples/jsm/webxr/ARButton.js +1 -1
  119. package/examples/jsm/webxr/WebGLXRFallback.js +89 -0
  120. package/examples/jsm/webxr/XRControllerModelFactory.js +2 -2
  121. package/package.json +7 -7
  122. package/src/Three.TSL.js +10 -3
  123. package/src/Three.WebGPU.js +4 -0
  124. package/src/animation/AnimationAction.js +15 -11
  125. package/src/animation/AnimationClip.js +0 -139
  126. package/src/animation/KeyframeTrack.js +2 -2
  127. package/src/animation/PropertyBinding.js +2 -2
  128. package/src/cameras/Camera.js +2 -2
  129. package/src/cameras/StereoCamera.js +5 -2
  130. package/src/constants.js +1 -1
  131. package/src/core/BufferGeometry.js +29 -7
  132. package/src/core/Object3D.js +17 -7
  133. package/src/core/Raycaster.js +1 -1
  134. package/src/core/RenderTarget.js +15 -2
  135. package/src/extras/PMREMGenerator.js +6 -4
  136. package/src/extras/TextureUtils.js +1 -1
  137. package/src/extras/core/ShapePath.js +149 -160
  138. package/src/geometries/SphereGeometry.js +8 -3
  139. package/src/helpers/DirectionalLightHelper.js +2 -0
  140. package/src/helpers/HemisphereLightHelper.js +2 -0
  141. package/src/helpers/PointLightHelper.js +2 -0
  142. package/src/helpers/SpotLightHelper.js +1 -1
  143. package/src/loaders/DataTextureLoader.js +69 -38
  144. package/src/loaders/LoadingManager.js +5 -0
  145. package/src/loaders/MaterialLoader.js +36 -266
  146. package/src/loaders/ObjectLoader.js +3 -1
  147. package/src/materials/LineBasicMaterial.js +4 -0
  148. package/src/materials/Material.js +196 -1
  149. package/src/materials/MeshBasicMaterial.js +24 -0
  150. package/src/materials/MeshDepthMaterial.js +10 -0
  151. package/src/materials/MeshDistanceMaterial.js +10 -0
  152. package/src/materials/MeshLambertMaterial.js +40 -1
  153. package/src/materials/MeshMatcapMaterial.js +25 -1
  154. package/src/materials/MeshNormalMaterial.js +9 -1
  155. package/src/materials/MeshPhongMaterial.js +40 -1
  156. package/src/materials/MeshPhysicalMaterial.js +38 -0
  157. package/src/materials/MeshStandardMaterial.js +42 -1
  158. package/src/materials/MeshToonMaterial.js +34 -1
  159. package/src/materials/PointsMaterial.js +7 -0
  160. package/src/materials/ShaderMaterial.js +86 -0
  161. package/src/materials/SpriteMaterial.js +7 -0
  162. package/src/materials/nodes/Line2NodeMaterial.js +378 -322
  163. package/src/materials/nodes/MeshBasicNodeMaterial.js +2 -2
  164. package/src/materials/nodes/MeshNormalNodeMaterial.js +2 -2
  165. package/src/materials/nodes/MeshPhongNodeMaterial.js +0 -9
  166. package/src/materials/nodes/MeshPhysicalNodeMaterial.js +0 -30
  167. package/src/materials/nodes/MeshSSSNodeMaterial.js +0 -13
  168. package/src/materials/nodes/MeshStandardNodeMaterial.js +0 -11
  169. package/src/materials/nodes/NodeMaterial.js +115 -71
  170. package/src/materials/nodes/SpriteNodeMaterial.js +0 -10
  171. package/src/materials/nodes/manager/NodeMaterialObserver.js +49 -20
  172. package/src/math/Box3.js +5 -0
  173. package/src/math/FrustumArray.js +103 -133
  174. package/src/math/Interpolant.js +1 -1
  175. package/src/math/MathUtils.js +2 -2
  176. package/src/math/Matrix3.js +11 -0
  177. package/src/math/Matrix4.js +28 -3
  178. package/src/math/Vector2.js +2 -2
  179. package/src/math/Vector3.js +2 -2
  180. package/src/math/Vector4.js +2 -2
  181. package/src/math/interpolants/BezierInterpolant.js +4 -6
  182. package/src/nodes/Nodes.js +2 -5
  183. package/src/nodes/TSL.js +8 -6
  184. package/src/nodes/accessors/Arrays.js +4 -4
  185. package/src/nodes/accessors/Batch.js +108 -0
  186. package/src/nodes/accessors/Bitangent.js +2 -2
  187. package/src/nodes/accessors/BufferAttributeNode.js +13 -2
  188. package/src/nodes/accessors/Camera.js +7 -7
  189. package/src/nodes/accessors/ClippingNode.js +1 -1
  190. package/src/nodes/accessors/Instance.js +264 -0
  191. package/src/nodes/accessors/MaterialNode.js +18 -2
  192. package/src/nodes/accessors/MaterialProperties.js +4 -3
  193. package/src/nodes/accessors/{MorphNode.js → Morph.js} +99 -112
  194. package/src/nodes/accessors/Normal.js +13 -13
  195. package/src/nodes/accessors/Position.js +5 -1
  196. package/src/nodes/accessors/ReferenceNode.js +1 -0
  197. package/src/nodes/accessors/ReflectVector.js +3 -3
  198. package/src/nodes/accessors/SceneProperties.js +1 -1
  199. package/src/nodes/accessors/Skinning.js +263 -0
  200. package/src/nodes/accessors/StorageBufferNode.js +2 -2
  201. package/src/nodes/accessors/StorageTexture3DNode.js +100 -0
  202. package/src/nodes/accessors/StorageTextureNode.js +39 -7
  203. package/src/nodes/accessors/Tangent.js +4 -4
  204. package/src/nodes/accessors/TextureNode.js +60 -5
  205. package/src/nodes/code/FunctionNode.js +2 -16
  206. package/src/nodes/core/MRTNode.js +7 -2
  207. package/src/nodes/core/Node.js +39 -2
  208. package/src/nodes/core/NodeBuilder.js +201 -41
  209. package/src/nodes/core/NodeUtils.js +13 -13
  210. package/src/nodes/core/OutputStructNode.js +1 -1
  211. package/src/nodes/core/OverrideContextNode.js +153 -0
  212. package/src/nodes/core/PropertyNode.js +51 -5
  213. package/src/nodes/core/StackNode.js +56 -34
  214. package/src/nodes/core/StructNode.js +4 -6
  215. package/src/nodes/core/StructTypeNode.js +6 -6
  216. package/src/nodes/core/VarNode.js +8 -0
  217. package/src/nodes/core/VaryingNode.js +12 -2
  218. package/src/nodes/display/BlendModes.js +1 -41
  219. package/src/nodes/display/BumpMapNode.js +6 -1
  220. package/src/nodes/display/ColorAdjustment.js +10 -9
  221. package/src/nodes/display/FrontFacingNode.js +38 -9
  222. package/src/nodes/display/NormalMapNode.js +2 -2
  223. package/src/nodes/display/PassNode.js +35 -43
  224. package/src/nodes/display/PremultiplyAlphaFunctions.js +39 -0
  225. package/src/nodes/display/RenderOutputNode.js +12 -3
  226. package/src/nodes/functions/VolumetricLightingModel.js +40 -7
  227. package/src/nodes/gpgpu/WorkgroupInfoNode.js +1 -1
  228. package/src/nodes/lighting/EnvironmentNode.js +2 -2
  229. package/src/nodes/lighting/IESSpotLightNode.js +40 -2
  230. package/src/nodes/lighting/LightingContextNode.js +10 -2
  231. package/src/nodes/lighting/LightsNode.js +90 -37
  232. package/src/nodes/lighting/PointShadowNode.js +6 -1
  233. package/src/nodes/lighting/ShadowFilterNode.js +21 -52
  234. package/src/nodes/lighting/ShadowNode.js +34 -14
  235. package/src/nodes/materialx/lib/mx_noise.js +2 -2
  236. package/src/nodes/math/ConditionalNode.js +3 -3
  237. package/src/nodes/math/MathNode.js +39 -11
  238. package/src/nodes/math/OperatorNode.js +23 -23
  239. package/src/nodes/parsers/GLSLNodeFunction.js +1 -1
  240. package/src/nodes/pmrem/PMREMNode.js +33 -2
  241. package/src/nodes/tsl/TSLCore.js +63 -18
  242. package/src/nodes/utils/EquirectUV.js +30 -5
  243. package/src/nodes/utils/FunctionOverloadingNode.js +1 -1
  244. package/src/nodes/utils/Packing.js +35 -4
  245. package/src/nodes/utils/RTTNode.js +40 -24
  246. package/src/nodes/utils/ReflectorNode.js +1 -0
  247. package/src/nodes/utils/StorageArrayElementNode.js +1 -1
  248. package/src/objects/BatchedMesh.js +22 -14
  249. package/src/objects/InstancedMesh.js +0 -11
  250. package/src/objects/Skeleton.js +0 -9
  251. package/src/renderers/WebGLRenderer.js +19 -15
  252. package/src/renderers/common/Backend.js +49 -5
  253. package/src/renderers/common/Bindings.js +114 -45
  254. package/src/renderers/common/Buffer.js +9 -0
  255. package/src/renderers/common/ClippingContext.js +10 -2
  256. package/src/renderers/common/Info.js +63 -22
  257. package/src/renderers/common/Lighting.js +53 -5
  258. package/src/renderers/common/RenderList.js +41 -4
  259. package/src/renderers/common/RenderObject.js +73 -13
  260. package/src/renderers/common/Renderer.js +281 -108
  261. package/src/renderers/common/Sampler.js +16 -48
  262. package/src/renderers/common/Textures.js +32 -5
  263. package/src/renderers/common/TimestampQueryPool.js +1 -1
  264. package/src/renderers/common/UniformsGroup.js +31 -9
  265. package/src/renderers/common/XRManager.js +340 -22
  266. package/src/renderers/common/extras/PMREMGenerator.js +15 -38
  267. package/src/renderers/common/nodes/NodeBuilderState.js +9 -1
  268. package/src/renderers/common/nodes/NodeLibrary.js +4 -4
  269. package/src/renderers/common/nodes/NodeManager.js +63 -14
  270. package/src/renderers/common/nodes/NodeUniformBuffer.js +13 -0
  271. package/src/renderers/shaders/ShaderChunk/common.glsl.js +13 -4
  272. package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +0 -6
  273. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +1 -1
  274. package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +2 -2
  275. package/src/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js +1 -1
  276. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +1 -1
  277. package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +1 -1
  278. package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +2 -2
  279. package/src/renderers/shaders/ShaderChunk/normal_vertex.glsl.js +6 -0
  280. package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +1 -1
  281. package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
  282. package/src/renderers/shaders/ShaderLib/distance.glsl.js +1 -1
  283. package/src/renderers/webgl/WebGLOutput.js +2 -1
  284. package/src/renderers/webgl/WebGLProgram.js +5 -4
  285. package/src/renderers/webgl/WebGLPrograms.js +12 -5
  286. package/src/renderers/webgl/WebGLRenderLists.js +9 -1
  287. package/src/renderers/webgl/WebGLShaderCache.js +5 -11
  288. package/src/renderers/webgl/WebGLTextures.js +20 -7
  289. package/src/renderers/webgl/WebGLUniformsGroups.js +66 -38
  290. package/src/renderers/webgl-fallback/WebGLBackend.js +84 -25
  291. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +138 -8
  292. package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +1 -1
  293. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +52 -22
  294. package/src/renderers/webgl-fallback/utils/WebGLUtils.js +4 -2
  295. package/src/renderers/webgpu/WebGPUBackend.js +480 -169
  296. package/src/renderers/webgpu/descriptors/GPUBindGroupDescriptor.js +48 -0
  297. package/src/renderers/webgpu/descriptors/GPUBufferDescriptor.js +57 -0
  298. package/src/renderers/webgpu/descriptors/GPUCommandEncoderDescriptor.js +30 -0
  299. package/src/renderers/webgpu/descriptors/GPUComputePassDescriptor.js +38 -0
  300. package/src/renderers/webgpu/descriptors/GPUComputePipelineDescriptor.js +48 -0
  301. package/src/renderers/webgpu/descriptors/GPUCopyExternalImageDestInfo.js +47 -0
  302. package/src/renderers/webgpu/descriptors/GPUCopyExternalImageSourceInfo.js +50 -0
  303. package/src/renderers/webgpu/descriptors/GPUExtent3D.js +51 -0
  304. package/src/renderers/webgpu/descriptors/GPUPipelineLayoutDescriptor.js +39 -0
  305. package/src/renderers/webgpu/descriptors/GPUQuerySetDescriptor.js +47 -0
  306. package/src/renderers/webgpu/descriptors/GPURenderBundleEncoderDescriptor.js +74 -0
  307. package/src/renderers/webgpu/descriptors/GPURenderPassColorAttachment.js +72 -0
  308. package/src/renderers/webgpu/descriptors/GPURenderPassDepthStencilAttachment.js +99 -0
  309. package/src/renderers/webgpu/descriptors/GPURenderPassDescriptor.js +72 -0
  310. package/src/renderers/webgpu/descriptors/GPURenderPassTimestampWrites.js +49 -0
  311. package/src/renderers/webgpu/descriptors/GPURenderPipelineDescriptor.js +130 -0
  312. package/src/renderers/webgpu/descriptors/GPUSamplerDescriptor.js +119 -0
  313. package/src/renderers/webgpu/descriptors/GPUShaderModuleDescriptor.js +46 -0
  314. package/src/renderers/webgpu/descriptors/GPUTexelCopyBufferInfo.js +57 -0
  315. package/src/renderers/webgpu/descriptors/GPUTexelCopyBufferLayout.js +48 -0
  316. package/src/renderers/webgpu/descriptors/GPUTexelCopyTextureInfo.js +61 -0
  317. package/src/renderers/webgpu/descriptors/GPUTextureDescriptor.js +99 -0
  318. package/src/renderers/webgpu/descriptors/GPUTextureViewDescriptor.js +108 -0
  319. package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +0 -1
  320. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +164 -7
  321. package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +1 -1
  322. package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +98 -38
  323. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +72 -68
  324. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +164 -69
  325. package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +158 -95
  326. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +297 -141
  327. package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +33 -18
  328. package/src/renderers/webgpu/utils/WebGPUUtils.js +38 -3
  329. package/src/textures/DepthTexture.js +1 -1
  330. package/src/textures/ExternalTexture.js +0 -3
  331. package/examples/fonts/LICENSE +0 -13
  332. package/examples/fonts/MPLUSRounded1c/MPLUSRounded1c-Regular.typeface.json.zip +0 -0
  333. package/examples/fonts/MPLUSRounded1c/OFL.txt +0 -91
  334. package/examples/fonts/README.md +0 -11
  335. package/examples/fonts/droid/NOTICE +0 -190
  336. package/examples/fonts/droid/README.txt +0 -18
  337. package/examples/fonts/droid/droid_sans_bold.typeface.json +0 -1
  338. package/examples/fonts/droid/droid_sans_mono_regular.typeface.json +0 -1
  339. package/examples/fonts/droid/droid_sans_regular.typeface.json +0 -1
  340. package/examples/fonts/droid/droid_serif_bold.typeface.json +0 -1
  341. package/examples/fonts/droid/droid_serif_regular.typeface.json +0 -1
  342. package/examples/fonts/gentilis_bold.typeface.json +0 -1
  343. package/examples/fonts/gentilis_regular.typeface.json +0 -1
  344. package/examples/fonts/helvetiker_bold.typeface.json +0 -1
  345. package/examples/fonts/helvetiker_regular.typeface.json +0 -1
  346. package/examples/fonts/optimer_bold.typeface.json +0 -1
  347. package/examples/fonts/optimer_regular.typeface.json +0 -1
  348. package/examples/fonts/ttf/README.md +0 -9
  349. package/examples/fonts/ttf/kenpixel.ttf +0 -0
  350. package/examples/jsm/inspector/extensions/extensions.json +0 -6
  351. package/examples/jsm/libs/ammo.wasm.js +0 -822
  352. package/examples/jsm/libs/ammo.wasm.wasm +0 -0
  353. package/examples/jsm/libs/draco/draco_encoder.js +0 -33
  354. package/examples/jsm/libs/draco/gltf/draco_encoder.js +0 -33
  355. package/examples/jsm/libs/lottie_canvas.module.js +0 -14849
  356. package/examples/jsm/libs/opentype.module.js +0 -14506
  357. package/examples/jsm/libs/rhino3dm/rhino3dm.js +0 -21
  358. package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +0 -16
  359. package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
  360. package/examples/jsm/lighting/TiledLighting.js +0 -42
  361. package/examples/jsm/tsl/display/AnamorphicNode.js +0 -293
  362. package/examples/jsm/tsl/lighting/TiledLightsNode.js +0 -442
  363. package/src/nodes/accessors/BatchNode.js +0 -163
  364. package/src/nodes/accessors/InstanceNode.js +0 -349
  365. package/src/nodes/accessors/InstancedMeshNode.js +0 -50
  366. package/src/nodes/accessors/SkinningNode.js +0 -328
@@ -1,14 +1,50 @@
1
1
  import Node from '../core/Node.js';
2
- import { nodeObject, property, vec3 } from '../tsl/TSLBase.js';
2
+ import { property, vec3 } from '../tsl/TSLBase.js';
3
3
  import { hashArray } from '../core/NodeUtils.js';
4
4
  import { warn } from '../../utils.js';
5
5
 
6
+ /**
7
+ * A node representing the total diffuse light.
8
+ *
9
+ * @type {Node<vec3>}
10
+ */
11
+ const totalDiffuse = property( 'vec3', 'totalDiffuse' );
12
+
13
+ /**
14
+ * A node representing the total specular light.
15
+ *
16
+ * @type {Node<vec3>}
17
+ */
18
+ const totalSpecular = property( 'vec3', 'totalSpecular' );
19
+
20
+ /**
21
+ * A node representing the outgoing light.
22
+ *
23
+ * @type {Node<vec3>}
24
+ */
25
+ const outgoingLight = property( 'vec3', 'outgoingLight' );
26
+
27
+ /**
28
+ * Sorts an array of lights in ascending order by their IDs.
29
+ *
30
+ * @private
31
+ * @param {Array<Light>} lights - The array of lights to sort.
32
+ * @return {Array<Light>} The sorted array of lights.
33
+ */
6
34
  const sortLights = ( lights ) => {
7
35
 
8
36
  return lights.sort( ( a, b ) => a.id - b.id );
9
37
 
10
38
  };
11
39
 
40
+ /**
41
+ * Finds and returns a lighting node associated with a specific light ID.
42
+ *
43
+ * @private
44
+ * @param {number} id - The ID of the light to search for.
45
+ * @param {Array<LightingNode>} lightNodes - The array of lighting nodes to search within.
46
+ * @return {?LightingNode} The matching lighting node, or null if not found.
47
+ */
12
48
  const getLightNodeById = ( id, lightNodes ) => {
13
49
 
14
50
  for ( const lightNode of lightNodes ) {
@@ -25,7 +61,20 @@ const getLightNodeById = ( id, lightNodes ) => {
25
61
 
26
62
  };
27
63
 
64
+ /**
65
+ * WeakMap cache mapping light objects to their corresponding lighting node instances.
66
+ *
67
+ * @private
68
+ * @type {WeakMap<Light, LightingNode>}
69
+ */
28
70
  const _lightsNodeRef = /*@__PURE__*/ new WeakMap();
71
+
72
+ /**
73
+ * Array used to temporarily store light IDs and shadow casting states for hashing.
74
+ *
75
+ * @private
76
+ * @type {Array<number>}
77
+ */
29
78
  const _hashData = [];
30
79
 
31
80
  /**
@@ -55,21 +104,21 @@ class LightsNode extends Node {
55
104
  *
56
105
  * @type {Node<vec3>}
57
106
  */
58
- this.totalDiffuseNode = property( 'vec3', 'totalDiffuse' );
107
+ this.totalDiffuseNode = totalDiffuse;
59
108
 
60
109
  /**
61
110
  * A node representing the total specular light.
62
111
  *
63
112
  * @type {Node<vec3>}
64
113
  */
65
- this.totalSpecularNode = property( 'vec3', 'totalSpecular' );
114
+ this.totalSpecularNode = totalSpecular;
66
115
 
67
116
  /**
68
117
  * A node representing the outgoing light.
69
118
  *
70
119
  * @type {Node<vec3>}
71
120
  */
72
- this.outgoingLightNode = property( 'vec3', 'outgoingLight' );
121
+ this.outgoingLightNode = outgoingLight;
73
122
 
74
123
  /**
75
124
  * An array representing the lights in the scene.
@@ -79,25 +128,6 @@ class LightsNode extends Node {
79
128
  */
80
129
  this._lights = [];
81
130
 
82
- /**
83
- * For each light in the scene, this node will create a
84
- * corresponding light node.
85
- *
86
- * @private
87
- * @type {?Array<LightingNode>}
88
- * @default null
89
- */
90
- this._lightNodes = null;
91
-
92
- /**
93
- * A hash for identifying the current light nodes setup.
94
- *
95
- * @private
96
- * @type {?string}
97
- * @default null
98
- */
99
- this._lightNodesHash = null;
100
-
101
131
  /**
102
132
  * `LightsNode` sets this property to `true` by default.
103
133
  *
@@ -152,26 +182,36 @@ class LightsNode extends Node {
152
182
  */
153
183
  getHash( builder ) {
154
184
 
155
- if ( this._lightNodesHash === null ) {
185
+ const nodeData = builder.getDataFromNode( this );
186
+
187
+ if ( nodeData.lightNodesHash === undefined ) {
156
188
 
157
- if ( this._lightNodes === null ) this.setupLightsNode( builder );
189
+ const lightNodes = this.setupLightsNode( builder );
190
+
191
+ nodeData.lightNodes = lightNodes;
158
192
 
159
193
  const hash = [];
160
194
 
161
- for ( const lightNode of this._lightNodes ) {
195
+ for ( const lightNode of lightNodes ) {
162
196
 
163
197
  hash.push( lightNode.getHash() );
164
198
 
165
199
  }
166
200
 
167
- this._lightNodesHash = 'lights-' + hash.join( ',' );
201
+ nodeData.lightNodesHash = 'lights-' + hash.join( ',' );
168
202
 
169
203
  }
170
204
 
171
- return this._lightNodesHash;
205
+ return nodeData.lightNodesHash;
172
206
 
173
207
  }
174
208
 
209
+ /**
210
+ * Analyzes the node's dependencies by building all nested light nodes
211
+ * and the output node.
212
+ *
213
+ * @param {NodeBuilder} builder - A reference to the current node builder.
214
+ */
175
215
  analyze( builder ) {
176
216
 
177
217
  const properties = builder.getNodeProperties( this );
@@ -191,21 +231,24 @@ class LightsNode extends Node {
191
231
  * process lights in the node system.
192
232
  *
193
233
  * @param {NodeBuilder} builder - A reference to the current node builder.
234
+ * @return {Array<LightingNode>} The array of lighting nodes.
194
235
  */
195
236
  setupLightsNode( builder ) {
196
237
 
238
+ const nodeData = builder.getDataFromNode( this );
197
239
  const lightNodes = [];
198
240
 
199
- const previousLightNodes = this._lightNodes;
241
+ const previousLightNodes = nodeData.lightNodes || null;
242
+ const materialLightings = builder.context.materialLightings;
200
243
 
201
- const lights = sortLights( this._lights );
244
+ const lights = sortLights( [ ...materialLightings, ...this._lights ] );
202
245
  const nodeLibrary = builder.renderer.library;
203
246
 
204
247
  for ( const light of lights ) {
205
248
 
206
249
  if ( light.isNode ) {
207
250
 
208
- lightNodes.push( nodeObject( light ) );
251
+ lightNodes.push( light );
209
252
 
210
253
  } else {
211
254
 
@@ -244,7 +287,7 @@ class LightsNode extends Node {
244
287
 
245
288
  }
246
289
 
247
- this._lightNodes = lightNodes;
290
+ return lightNodes;
248
291
 
249
292
  }
250
293
 
@@ -267,6 +310,13 @@ class LightsNode extends Node {
267
310
 
268
311
  }
269
312
 
313
+ /**
314
+ * Sets up a direct rect area light in the lighting model.
315
+ *
316
+ * @param {Object} builder - The builder object containing the context and stack.
317
+ * @param {Object} lightNode - The light node.
318
+ * @param {Object} lightData - The light object containing color and area light properties.
319
+ */
270
320
  setupDirectRectAreaLight( builder, lightNode, lightData ) {
271
321
 
272
322
  const { lightingModel, reflectedLight } = builder.context;
@@ -298,9 +348,15 @@ class LightsNode extends Node {
298
348
 
299
349
  getLightNodes( builder ) {
300
350
 
301
- if ( this._lightNodes === null ) this.setupLightsNode( builder );
351
+ const nodeData = builder.getDataFromNode( this );
352
+
353
+ if ( nodeData.lightNodes === undefined ) {
354
+
355
+ nodeData.lightNodes = this.setupLightsNode( builder );
302
356
 
303
- return this._lightNodes;
357
+ }
358
+
359
+ return nodeData.lightNodes;
304
360
 
305
361
  }
306
362
 
@@ -387,9 +443,6 @@ class LightsNode extends Node {
387
443
 
388
444
  this._lights = lights;
389
445
 
390
- this._lightNodes = null;
391
- this._lightNodesHash = null;
392
-
393
446
  return this;
394
447
 
395
448
  }
@@ -12,7 +12,7 @@ import { CubeDepthTexture } from '../../textures/CubeDepthTexture.js';
12
12
  import { screenCoordinate } from '../display/ScreenNode.js';
13
13
  import { interleavedGradientNoise, vogelDiskSample } from '../utils/PostProcessingUtils.js';
14
14
  import { abs, normalize, cross } from '../math/MathNode.js';
15
- import { viewZToPerspectiveDepth, viewZToReversedPerspectiveDepth } from '../display/ViewportDepthNode.js';
15
+ import { viewZToLogarithmicDepth, viewZToPerspectiveDepth, viewZToReversedPerspectiveDepth } from '../display/ViewportDepthNode.js';
16
16
 
17
17
  const _clearColor = /*@__PURE__*/ new Color();
18
18
  const _projScreenMatrix = /*@__PURE__*/ new Matrix4();
@@ -117,6 +117,11 @@ const pointShadowFilter = /*@__PURE__*/ Fn( ( { filterFn, depthTexture, shadowCo
117
117
  dp = viewZToReversedPerspectiveDepth( viewZ.negate(), shadowCameraNear, shadowCameraFar );
118
118
  dp.subAssign( bias );
119
119
 
120
+ } else if ( builder.renderer.logarithmicDepthBuffer ) {
121
+
122
+ dp = viewZToLogarithmicDepth( viewZ.negate(), shadowCameraNear, shadowCameraFar );
123
+ dp.addAssign( bias );
124
+
120
125
  } else {
121
126
 
122
127
  dp = viewZToPerspectiveDepth( viewZ.negate(), shadowCameraNear, shadowCameraFar );
@@ -1,4 +1,4 @@
1
- import { float, vec2, vec4, If, Fn } from '../tsl/TSLBase.js';
1
+ import { float, vec2, vec4, If, Fn, ivec2 } from '../tsl/TSLBase.js';
2
2
  import { reference } from '../accessors/ReferenceNode.js';
3
3
  import { texture } from '../accessors/TextureNode.js';
4
4
  import { mix, fract, step, max, clamp } from '../math/MathNode.js';
@@ -97,69 +97,38 @@ export const PCFShadowFilter = /*@__PURE__*/ Fn( ( { depthTexture, shadowCoord,
97
97
  */
98
98
  export const PCFSoftShadowFilter = /*@__PURE__*/ Fn( ( { depthTexture, shadowCoord, shadow, depthLayer } ) => {
99
99
 
100
- const depthCompare = ( uv, compare ) => {
100
+ const mapSize = reference( 'mapSize', 'vec2', shadow ).setGroup( renderGroup );
101
101
 
102
- let depth = texture( depthTexture, uv );
102
+ const texelSize = vec2( 1 ).div( mapSize );
103
103
 
104
- if ( depthTexture.isArrayTexture ) {
104
+ const uv = shadowCoord.xy;
105
+ const f = fract( uv.mul( mapSize ).add( 0.5 ) ).toConst();
106
+ uv.subAssign( f.sub( 0.5 ).mul( texelSize ) );
105
107
 
106
- depth = depth.depth( depthLayer );
108
+ const gatherCompare = ( offset ) => {
107
109
 
108
- }
110
+ let t = texture( depthTexture, uv ).offset( offset ).gather();
109
111
 
110
- return depth.compare( compare );
112
+ if ( depthTexture.isArrayTexture ) {
111
113
 
112
- };
114
+ t = t.depth( depthLayer );
113
115
 
116
+ }
114
117
 
115
- const mapSize = reference( 'mapSize', 'vec2', shadow ).setGroup( renderGroup );
118
+ return t.compare( shadowCoord.z );
116
119
 
117
- const texelSize = vec2( 1 ).div( mapSize );
118
- const dx = texelSize.x;
119
- const dy = texelSize.y;
120
+ };
120
121
 
121
- const uv = shadowCoord.xy;
122
- const f = fract( uv.mul( mapSize ).add( 0.5 ) );
123
- uv.subAssign( f.mul( texelSize ) );
122
+ const c1 = gatherCompare( ivec2( - 1, 1 ) ).toConst();
123
+ const c2 = gatherCompare( ivec2( 1, 1 ) ).toConst();
124
+ const c3 = gatherCompare( ivec2( - 1, - 1 ) ).toConst();
125
+ const c4 = gatherCompare( ivec2( 1, - 1 ) ).toConst();
124
126
 
125
127
  return add(
126
- depthCompare( uv, shadowCoord.z ),
127
- depthCompare( uv.add( vec2( dx, 0 ) ), shadowCoord.z ),
128
- depthCompare( uv.add( vec2( 0, dy ) ), shadowCoord.z ),
129
- depthCompare( uv.add( texelSize ), shadowCoord.z ),
130
- mix(
131
- depthCompare( uv.add( vec2( dx.negate(), 0 ) ), shadowCoord.z ),
132
- depthCompare( uv.add( vec2( dx.mul( 2 ), 0 ) ), shadowCoord.z ),
133
- f.x
134
- ),
135
- mix(
136
- depthCompare( uv.add( vec2( dx.negate(), dy ) ), shadowCoord.z ),
137
- depthCompare( uv.add( vec2( dx.mul( 2 ), dy ) ), shadowCoord.z ),
138
- f.x
139
- ),
140
- mix(
141
- depthCompare( uv.add( vec2( 0, dy.negate() ) ), shadowCoord.z ),
142
- depthCompare( uv.add( vec2( 0, dy.mul( 2 ) ) ), shadowCoord.z ),
143
- f.y
144
- ),
145
- mix(
146
- depthCompare( uv.add( vec2( dx, dy.negate() ) ), shadowCoord.z ),
147
- depthCompare( uv.add( vec2( dx, dy.mul( 2 ) ) ), shadowCoord.z ),
148
- f.y
149
- ),
150
- mix(
151
- mix(
152
- depthCompare( uv.add( vec2( dx.negate(), dy.negate() ) ), shadowCoord.z ),
153
- depthCompare( uv.add( vec2( dx.mul( 2 ), dy.negate() ) ), shadowCoord.z ),
154
- f.x
155
- ),
156
- mix(
157
- depthCompare( uv.add( vec2( dx.negate(), dy.mul( 2 ) ) ), shadowCoord.z ),
158
- depthCompare( uv.add( vec2( dx.mul( 2 ), dy.mul( 2 ) ) ), shadowCoord.z ),
159
- f.x
160
- ),
161
- f.y
162
- )
128
+ mix( c1.x, c2.y, f.x ).add( c1.y ).add( c2.x ).mul( f.y ),
129
+ mix( c1.w, c2.z, f.x ).add( c1.z ).add( c2.w ),
130
+ mix( c3.x, c4.y, f.x ).add( c3.y ).add( c4.x ),
131
+ mix( c3.w, c4.z, f.x ).add( c3.z ).add( c4.w ).mul( f.y.oneMinus() )
163
132
  ).mul( 1 / 9 );
164
133
 
165
134
  } );
@@ -1,28 +1,27 @@
1
+ import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
2
+ import QuadMesh from '../../renderers/common/QuadMesh.js';
3
+ import ChainMap from '../../renderers/common/ChainMap.js';
1
4
  import ShadowBaseNode, { shadowPositionWorld } from './ShadowBaseNode.js';
2
- import { float, vec2, vec3, vec4, int, Fn } from '../tsl/TSLBase.js';
5
+ import { float, vec2, vec3, vec4, int, Fn } from '../tsl/TSLCore.js';
3
6
  import { reference } from '../accessors/ReferenceNode.js';
4
- import { texture, textureLoad } from '../accessors/TextureNode.js';
7
+ import { texture } from '../accessors/TextureNode.js';
5
8
  import { cubeTexture } from '../accessors/CubeTextureNode.js';
6
9
  import { normalWorld } from '../accessors/Normal.js';
7
10
  import { mix, sqrt } from '../math/MathNode.js';
8
11
  import { add } from '../math/OperatorNode.js';
9
12
  import { DepthTexture } from '../../textures/DepthTexture.js';
10
- import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
11
- import QuadMesh from '../../renderers/common/QuadMesh.js';
12
13
  import { Loop } from '../utils/LoopNode.js';
13
14
  import { screenCoordinate } from '../display/ScreenNode.js';
14
15
  import { Compatibility, GreaterEqualCompare, HalfFloatType, LessEqualCompare, LinearFilter, NearestFilter, PCFShadowMap, PCFSoftShadowMap, RGFormat, VSMShadowMap } from '../../constants.js';
15
16
  import { renderGroup } from '../core/UniformGroupNode.js';
16
- import { viewZToLogarithmicDepth } from '../display/ViewportDepthNode.js';
17
+ import { viewZToLogarithmicDepth, perspectiveDepthToViewZ, orthographicDepthToViewZ, viewZToOrthographicDepth } from '../display/ViewportDepthNode.js';
17
18
  import { lightShadowMatrix } from '../accessors/Lights.js';
18
19
  import { resetRendererAndSceneState, restoreRendererAndSceneState } from '../../renderers/common/RendererUtils.js';
19
20
  import { getDataFromObject } from '../core/NodeUtils.js';
20
21
  import { getShadowMaterial, disposeShadowMaterial, BasicShadowFilter, PCFShadowFilter, PCFSoftShadowFilter, VSMShadowFilter } from './ShadowFilterNode.js';
21
- import ChainMap from '../../renderers/common/ChainMap.js';
22
- import { textureSize } from '../accessors/TextureSizeNode.js';
23
- import { uv } from '../accessors/UV.js';
24
22
  import { positionLocal } from '../accessors/Position.js';
25
23
  import { uniform } from '../core/UniformNode.js';
24
+ import { equirectDirection } from '../utils/EquirectUV.js';
26
25
 
27
26
  //
28
27
 
@@ -49,7 +48,7 @@ export const getShadowRenderObjectFunction = ( renderer, shadow, shadowType, use
49
48
 
50
49
  if ( renderObjectFunction === undefined || ( renderObjectFunction.shadowType !== shadowType || renderObjectFunction.useVelocity !== useVelocity ) ) {
51
50
 
52
- renderObjectFunction = ( object, scene, _camera, geometry, material, group, ...params ) => {
51
+ renderObjectFunction = ( object, scene, _camera, geometry, material, group, lightsNode, clippingContext, passId ) => {
53
52
 
54
53
  if ( object.castShadow === true || ( object.receiveShadow && shadowType === VSMShadowMap ) ) {
55
54
 
@@ -61,7 +60,7 @@ export const getShadowRenderObjectFunction = ( renderer, shadow, shadowType, use
61
60
 
62
61
  object.onBeforeShadow( renderer, object, _camera, shadow.camera, geometry, scene.overrideMaterial, group );
63
62
 
64
- renderer.renderObject( object, scene, _camera, geometry, material, group, ...params );
63
+ renderer.renderObject( object, scene, _camera, geometry, material, group, lightsNode, clippingContext, passId );
65
64
 
66
65
  object.onAfterShadow( renderer, object, _camera, shadow.camera, geometry, scene.overrideMaterial, group );
67
66
 
@@ -595,7 +594,7 @@ class ShadowNode extends ShadowBaseNode {
595
594
 
596
595
  if ( this.shadowMap.texture.isCubeTexture ) {
597
596
 
598
- return cubeTexture( this.shadowMap.texture );
597
+ return cubeTexture( this.shadowMap.texture, equirectDirection() );
599
598
 
600
599
  }
601
600
 
@@ -607,15 +606,36 @@ class ShadowNode extends ShadowBaseNode {
607
606
 
608
607
  return shadowOutput.toInspector( `${ inspectName } / Depth`, () => {
609
608
 
610
- // TODO: Use linear depth
609
+ const shadowCameraNear = reference( 'near', 'float', this.shadow.camera );
610
+ const shadowCameraFar = reference( 'far', 'float', this.shadow.camera );
611
+
612
+ let depthNode;
611
613
 
612
614
  if ( this.shadowMap.texture.isCubeTexture ) {
613
615
 
614
- return cubeTexture( this.shadowMap.texture ).r.oneMinus();
616
+ depthNode = cubeTexture( this.shadowMap.depthTexture, equirectDirection() ).r;
617
+
618
+ } else {
619
+
620
+ depthNode = texture( this.shadowMap.depthTexture ).r;
615
621
 
616
622
  }
617
623
 
618
- return textureLoad( this.shadowMap.depthTexture, uv().mul( textureSize( texture( this.shadowMap.depthTexture ) ) ) ).r.oneMinus();
624
+ let linearDepth;
625
+
626
+ if ( this.shadow.camera.isPerspectiveCamera ) {
627
+
628
+ linearDepth = perspectiveDepthToViewZ( depthNode, shadowCameraNear, shadowCameraFar );
629
+
630
+ } else {
631
+
632
+ linearDepth = orthographicDepthToViewZ( depthNode, shadowCameraNear, shadowCameraFar );
633
+
634
+ }
635
+
636
+ linearDepth = viewZToOrthographicDepth( linearDepth, shadowCameraNear, shadowCameraFar );
637
+
638
+ return linearDepth.oneMinus();
619
639
 
620
640
  } );
621
641
 
@@ -15,7 +15,7 @@ export const mx_select = /*@__PURE__*/ Fn( ( [ b_immutable, t_immutable, f_immut
15
15
  const t = float( t_immutable ).toVar();
16
16
  const b = bool( b_immutable ).toVar();
17
17
 
18
- return select( b, t, f );
18
+ return select( b, t, f ).uniformFlow();
19
19
 
20
20
  } ).setLayout( {
21
21
  name: 'mx_select',
@@ -32,7 +32,7 @@ export const mx_negate_if = /*@__PURE__*/ Fn( ( [ val_immutable, b_immutable ] )
32
32
  const b = bool( b_immutable ).toVar();
33
33
  const val = float( val_immutable ).toVar();
34
34
 
35
- return select( b, val.negate(), val );
35
+ return select( b, val.negate(), val ).uniformFlow();
36
36
 
37
37
  } ).setLayout( {
38
38
  name: 'mx_negate_if',
@@ -7,12 +7,12 @@ import { warn } from '../../utils.js';
7
7
  * Represents a logical `if/else` statement. Can be used as an alternative
8
8
  * to the `If()`/`Else()` syntax.
9
9
  *
10
- * The corresponding TSL `select()` looks like so:
10
+ * The `select()` method is called in a chaining fashion on a condition. The parameter nodes of `select()`
11
+ * determine the outcome of the entire statement.
12
+ *
11
13
  * ```js
12
14
  * velocity = position.greaterThanEqual( limit ).select( velocity.negate(), velocity );
13
15
  * ```
14
- * The `select()` method is called in a chaining fashion on a condition. The parameter nodes of `select()`
15
- * determine the outcome of the entire statement.
16
16
  *
17
17
  * @augments Node
18
18
  */
@@ -40,7 +40,7 @@ class MathNode extends TempNode {
40
40
 
41
41
  let finalOp = new MathNode( method, aNode, bNode );
42
42
 
43
- for ( let i = 2; i < arguments.length - 1; i ++ ) {
43
+ for ( let i = 3; i < arguments.length - 1; i ++ ) {
44
44
 
45
45
  finalOp = new MathNode( method, finalOp, arguments[ i ] );
46
46
 
@@ -181,25 +181,23 @@ class MathNode extends TempNode {
181
181
 
182
182
  } else if ( method === MathNode.TRANSFORM_DIRECTION ) {
183
183
 
184
- // dir can be either a direction vector or a normal vector
185
- // upper-left 3x3 of matrix is assumed to be orthogonal
184
+ // pre-multiplies the direction by the matrix and normalizes the result
186
185
 
187
- let tA = aNode;
188
- let tB = bNode;
186
+ let matrixNode, directionNode;
189
187
 
190
- if ( builder.isMatrix( tA.getNodeType( builder ) ) ) {
188
+ if ( builder.isMatrix( aNode.getNodeType( builder ) ) ) {
191
189
 
192
- tB = vec4( vec3( tB ), 0.0 );
190
+ matrixNode = aNode;
191
+ directionNode = bNode;
193
192
 
194
193
  } else {
195
194
 
196
- tA = vec4( vec3( tA ), 0.0 );
195
+ matrixNode = bNode;
196
+ directionNode = aNode;
197
197
 
198
198
  }
199
199
 
200
- const mulNode = mul( tA, tB ).xyz;
201
-
202
- outputNode = normalize( mulNode );
200
+ outputNode = normalize( mul( matrixNode, vec4( vec3( directionNode ), 0.0 ) ).xyz );
203
201
 
204
202
  }
205
203
 
@@ -988,6 +986,34 @@ export const pow4 = ( x ) => mul( x, x, x, x );
988
986
  */
989
987
  export const transformDirection = /*@__PURE__*/ nodeProxyIntent( MathNode, MathNode.TRANSFORM_DIRECTION ).setParameterLength( 2 );
990
988
 
989
+ /**
990
+ * Transforms a normal vector by the view matrix and then normalizes the result.
991
+ *
992
+ * The upper-left 3x3 of the view matrix is assumed to be orthonormal, so the
993
+ * normal can be transformed directly without involving the normal matrix.
994
+ *
995
+ * @tsl
996
+ * @function
997
+ * @param {Node<vec3>} normal - The normal vector, given in world space.
998
+ * @param {Node<mat3|mat4>} viewMatrix - The view matrix.
999
+ * @returns {Node<vec3>} The normal vector in view space.
1000
+ */
1001
+ export const transformNormalByViewMatrix = ( normal, viewMatrix ) => normalize( mul( viewMatrix, vec4( vec3( normal ), 0.0 ) ).xyz );
1002
+
1003
+ /**
1004
+ * Transforms a normal vector by the inverse of the view matrix and then normalizes the result.
1005
+ *
1006
+ * The upper-left 3x3 of the view matrix is assumed to be orthonormal, so post-multiplying
1007
+ * by the view matrix is equivalent to pre-multiplying by its inverse.
1008
+ *
1009
+ * @tsl
1010
+ * @function
1011
+ * @param {Node<vec3>} normal - The normal vector, given in view space.
1012
+ * @param {Node<mat3|mat4>} viewMatrix - The view matrix.
1013
+ * @returns {Node<vec3>} The normal vector in world space.
1014
+ */
1015
+ export const transformNormalByInverseViewMatrix = ( normal, viewMatrix ) => normalize( vec4( vec3( normal ), 0.0 ).mul( viewMatrix ).xyz );
1016
+
991
1017
  /**
992
1018
  * Returns the cube root of a number.
993
1019
  *
@@ -1188,6 +1214,8 @@ addMethodChaining( 'pow2', pow2 );
1188
1214
  addMethodChaining( 'pow3', pow3 );
1189
1215
  addMethodChaining( 'pow4', pow4 );
1190
1216
  addMethodChaining( 'transformDirection', transformDirection );
1217
+ addMethodChaining( 'transformNormalByViewMatrix', transformNormalByViewMatrix );
1218
+ addMethodChaining( 'transformNormalByInverseViewMatrix', transformNormalByInverseViewMatrix );
1191
1219
  addMethodChaining( 'mix', mixElement );
1192
1220
  addMethodChaining( 'clamp', clamp );
1193
1221
  addMethodChaining( 'refract', refract );
@@ -1,8 +1,6 @@
1
1
  import { WebGLCoordinateSystem } from '../../constants.js';
2
2
  import TempNode from '../core/TempNode.js';
3
- import StackTrace from '../core/StackTrace.js';
4
3
  import { addMethodChaining, Fn, int, nodeProxyIntent } from '../tsl/TSLCore.js';
5
- import { warn } from '../../utils.js';
6
4
 
7
5
  const _vectorOperators = {
8
6
  '==': 'equal',
@@ -130,10 +128,16 @@ class OperatorNode extends TempNode {
130
128
 
131
129
  return builder.getIntegerType( typeA );
132
130
 
133
- } else if ( op === '!' || op === '&&' || op === '||' || op === '^^' ) {
131
+ } else if ( op === '&&' || op === '||' || op === '^^' ) {
134
132
 
135
133
  return 'bool';
136
134
 
135
+ } else if ( op === '!' ) {
136
+
137
+ const typeLength = builder.getTypeLength( typeA );
138
+
139
+ return typeLength > 1 ? `bvec${ typeLength }` : 'bool';
140
+
137
141
  } else if ( op === '==' || op === '!=' || op === '<' || op === '>' || op === '<=' || op === '>=' ) {
138
142
 
139
143
  const typeLength = Math.max( builder.getTypeLength( typeA ), builder.getTypeLength( typeB ) );
@@ -332,9 +336,23 @@ class OperatorNode extends TempNode {
332
336
 
333
337
  }
334
338
 
335
- } else if ( op === '!' || op === '~' ) {
339
+ } else if ( op === '!' ) {
340
+
341
+ if ( isGLSL && builder.isVector( typeA ) ) {
342
+
343
+ return builder.format( `not( ${a} )`, output );
344
+
345
+ } else {
346
+
347
+ // WGSL and scalars on GLSL
348
+
349
+ return builder.format( `( ${op} ${a} )`, typeA, output );
350
+
351
+ }
352
+
353
+ } else if ( op === '~' ) {
336
354
 
337
- return builder.format( `(${op}${a})`, typeA, output );
355
+ return builder.format( `( ${op} ${a} )`, typeA, output );
338
356
 
339
357
  } else if ( fnOpSnippet ) {
340
358
 
@@ -732,21 +750,3 @@ addMethodChaining( 'incrementBefore', incrementBefore );
732
750
  addMethodChaining( 'decrementBefore', decrementBefore );
733
751
  addMethodChaining( 'increment', increment );
734
752
  addMethodChaining( 'decrement', decrement );
735
-
736
- /**
737
- * @tsl
738
- * @function
739
- * @deprecated since r175. Use {@link mod} instead.
740
- *
741
- * @param {Node} a - The first input.
742
- * @param {Node} b - The second input.
743
- * @returns {OperatorNode}
744
- */
745
- export const modInt = ( a, b ) => { // @deprecated, r175
746
-
747
- warn( 'TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.', new StackTrace() );
748
- return mod( int( a ), int( b ) );
749
-
750
- };
751
-
752
- addMethodChaining( 'modInt', modInt );
@@ -95,7 +95,7 @@ const parse = ( source ) => {
95
95
 
96
96
  } else {
97
97
 
98
- throw new Error( 'FunctionNode: Function is not a GLSL code.' );
98
+ throw new Error( 'THREE.FunctionNode: Function is not a GLSL code.' );
99
99
 
100
100
  }
101
101