@gnsx/three 0.184.19 → 0.185.2

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 (367) hide show
  1. package/build/three.cjs +1667 -1189
  2. package/build/three.core.js +1289 -871
  3. package/build/three.core.min.js +1 -1
  4. package/build/three.module.js +157 -97
  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 +7542 -3371
  9. package/build/three.webgpu.min.js +1 -1
  10. package/build/three.webgpu.nodes.js +7542 -3370
  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 +57 -64
  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 +124 -91
  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 -74
  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 +92 -37
  232. package/src/nodes/lighting/PointShadowNode.js +7 -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/profiler/ProfilerService.js +185 -42
  252. package/src/renderers/WebGLRenderer.js +21 -15
  253. package/src/renderers/common/Backend.js +49 -5
  254. package/src/renderers/common/Bindings.js +114 -45
  255. package/src/renderers/common/Buffer.js +9 -0
  256. package/src/renderers/common/ClippingContext.js +10 -2
  257. package/src/renderers/common/Info.js +63 -22
  258. package/src/renderers/common/Lighting.js +53 -5
  259. package/src/renderers/common/RenderList.js +42 -4
  260. package/src/renderers/common/RenderObject.js +73 -13
  261. package/src/renderers/common/Renderer.js +282 -109
  262. package/src/renderers/common/Sampler.js +16 -48
  263. package/src/renderers/common/Textures.js +32 -5
  264. package/src/renderers/common/TimestampQueryPool.js +1 -1
  265. package/src/renderers/common/UniformsGroup.js +31 -9
  266. package/src/renderers/common/XRManager.js +340 -22
  267. package/src/renderers/common/extras/PMREMGenerator.js +15 -38
  268. package/src/renderers/common/nodes/NodeBuilderState.js +9 -1
  269. package/src/renderers/common/nodes/NodeLibrary.js +4 -4
  270. package/src/renderers/common/nodes/NodeManager.js +63 -14
  271. package/src/renderers/common/nodes/NodeUniformBuffer.js +13 -0
  272. package/src/renderers/shaders/ShaderChunk/common.glsl.js +13 -4
  273. package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +0 -6
  274. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +1 -1
  275. package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +2 -2
  276. package/src/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js +1 -1
  277. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +1 -1
  278. package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +1 -1
  279. package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +2 -2
  280. package/src/renderers/shaders/ShaderChunk/normal_vertex.glsl.js +6 -0
  281. package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +1 -1
  282. package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
  283. package/src/renderers/shaders/ShaderLib/distance.glsl.js +1 -1
  284. package/src/renderers/webgl/WebGLOutput.js +2 -1
  285. package/src/renderers/webgl/WebGLProgram.js +5 -4
  286. package/src/renderers/webgl/WebGLPrograms.js +11 -4
  287. package/src/renderers/webgl/WebGLRenderLists.js +9 -1
  288. package/src/renderers/webgl/WebGLShaderCache.js +5 -11
  289. package/src/renderers/webgl/WebGLTextures.js +20 -7
  290. package/src/renderers/webgl/WebGLUniformsGroups.js +66 -38
  291. package/src/renderers/webgl-fallback/WebGLBackend.js +84 -25
  292. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +138 -8
  293. package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +1 -1
  294. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +52 -22
  295. package/src/renderers/webgl-fallback/utils/WebGLUtils.js +4 -2
  296. package/src/renderers/webgpu/WebGPUBackend.js +480 -169
  297. package/src/renderers/webgpu/descriptors/GPUBindGroupDescriptor.js +48 -0
  298. package/src/renderers/webgpu/descriptors/GPUBufferDescriptor.js +57 -0
  299. package/src/renderers/webgpu/descriptors/GPUCommandEncoderDescriptor.js +30 -0
  300. package/src/renderers/webgpu/descriptors/GPUComputePassDescriptor.js +38 -0
  301. package/src/renderers/webgpu/descriptors/GPUComputePipelineDescriptor.js +48 -0
  302. package/src/renderers/webgpu/descriptors/GPUCopyExternalImageDestInfo.js +47 -0
  303. package/src/renderers/webgpu/descriptors/GPUCopyExternalImageSourceInfo.js +50 -0
  304. package/src/renderers/webgpu/descriptors/GPUExtent3D.js +51 -0
  305. package/src/renderers/webgpu/descriptors/GPUPipelineLayoutDescriptor.js +39 -0
  306. package/src/renderers/webgpu/descriptors/GPUQuerySetDescriptor.js +47 -0
  307. package/src/renderers/webgpu/descriptors/GPURenderBundleEncoderDescriptor.js +74 -0
  308. package/src/renderers/webgpu/descriptors/GPURenderPassColorAttachment.js +72 -0
  309. package/src/renderers/webgpu/descriptors/GPURenderPassDepthStencilAttachment.js +99 -0
  310. package/src/renderers/webgpu/descriptors/GPURenderPassDescriptor.js +72 -0
  311. package/src/renderers/webgpu/descriptors/GPURenderPassTimestampWrites.js +49 -0
  312. package/src/renderers/webgpu/descriptors/GPURenderPipelineDescriptor.js +130 -0
  313. package/src/renderers/webgpu/descriptors/GPUSamplerDescriptor.js +119 -0
  314. package/src/renderers/webgpu/descriptors/GPUShaderModuleDescriptor.js +46 -0
  315. package/src/renderers/webgpu/descriptors/GPUTexelCopyBufferInfo.js +57 -0
  316. package/src/renderers/webgpu/descriptors/GPUTexelCopyBufferLayout.js +48 -0
  317. package/src/renderers/webgpu/descriptors/GPUTexelCopyTextureInfo.js +61 -0
  318. package/src/renderers/webgpu/descriptors/GPUTextureDescriptor.js +99 -0
  319. package/src/renderers/webgpu/descriptors/GPUTextureViewDescriptor.js +108 -0
  320. package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +0 -1
  321. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +164 -7
  322. package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +1 -1
  323. package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +98 -38
  324. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +72 -68
  325. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +164 -69
  326. package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +158 -95
  327. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +297 -141
  328. package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +33 -18
  329. package/src/renderers/webgpu/utils/WebGPUUtils.js +38 -3
  330. package/src/textures/DepthTexture.js +1 -1
  331. package/src/textures/ExternalTexture.js +0 -3
  332. package/examples/fonts/LICENSE +0 -13
  333. package/examples/fonts/MPLUSRounded1c/MPLUSRounded1c-Regular.typeface.json.zip +0 -0
  334. package/examples/fonts/MPLUSRounded1c/OFL.txt +0 -91
  335. package/examples/fonts/README.md +0 -11
  336. package/examples/fonts/droid/NOTICE +0 -190
  337. package/examples/fonts/droid/README.txt +0 -18
  338. package/examples/fonts/droid/droid_sans_bold.typeface.json +0 -1
  339. package/examples/fonts/droid/droid_sans_mono_regular.typeface.json +0 -1
  340. package/examples/fonts/droid/droid_sans_regular.typeface.json +0 -1
  341. package/examples/fonts/droid/droid_serif_bold.typeface.json +0 -1
  342. package/examples/fonts/droid/droid_serif_regular.typeface.json +0 -1
  343. package/examples/fonts/gentilis_bold.typeface.json +0 -1
  344. package/examples/fonts/gentilis_regular.typeface.json +0 -1
  345. package/examples/fonts/helvetiker_bold.typeface.json +0 -1
  346. package/examples/fonts/helvetiker_regular.typeface.json +0 -1
  347. package/examples/fonts/optimer_bold.typeface.json +0 -1
  348. package/examples/fonts/optimer_regular.typeface.json +0 -1
  349. package/examples/fonts/ttf/README.md +0 -9
  350. package/examples/fonts/ttf/kenpixel.ttf +0 -0
  351. package/examples/jsm/inspector/extensions/extensions.json +0 -6
  352. package/examples/jsm/libs/ammo.wasm.js +0 -822
  353. package/examples/jsm/libs/ammo.wasm.wasm +0 -0
  354. package/examples/jsm/libs/draco/draco_encoder.js +0 -33
  355. package/examples/jsm/libs/draco/gltf/draco_encoder.js +0 -33
  356. package/examples/jsm/libs/lottie_canvas.module.js +0 -14849
  357. package/examples/jsm/libs/opentype.module.js +0 -14506
  358. package/examples/jsm/libs/rhino3dm/rhino3dm.js +0 -21
  359. package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +0 -16
  360. package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
  361. package/examples/jsm/lighting/TiledLighting.js +0 -42
  362. package/examples/jsm/tsl/display/AnamorphicNode.js +0 -293
  363. package/examples/jsm/tsl/lighting/TiledLightsNode.js +0 -442
  364. package/src/nodes/accessors/BatchNode.js +0 -163
  365. package/src/nodes/accessors/InstanceNode.js +0 -349
  366. package/src/nodes/accessors/InstancedMeshNode.js +0 -50
  367. package/src/nodes/accessors/SkinningNode.js +0 -328
@@ -1,17 +1,53 @@
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
  // WITH_GENESYS
6
6
  import LightProbeGridNode from './LightProbeGridNode.js';
7
7
  // !WITH_GENESYS
8
8
 
9
+ /**
10
+ * A node representing the total diffuse light.
11
+ *
12
+ * @type {Node<vec3>}
13
+ */
14
+ const totalDiffuse = property( 'vec3', 'totalDiffuse' );
15
+
16
+ /**
17
+ * A node representing the total specular light.
18
+ *
19
+ * @type {Node<vec3>}
20
+ */
21
+ const totalSpecular = property( 'vec3', 'totalSpecular' );
22
+
23
+ /**
24
+ * A node representing the outgoing light.
25
+ *
26
+ * @type {Node<vec3>}
27
+ */
28
+ const outgoingLight = property( 'vec3', 'outgoingLight' );
29
+
30
+ /**
31
+ * Sorts an array of lights in ascending order by their IDs.
32
+ *
33
+ * @private
34
+ * @param {Array<Light>} lights - The array of lights to sort.
35
+ * @return {Array<Light>} The sorted array of lights.
36
+ */
9
37
  const sortLights = ( lights ) => {
10
38
 
11
39
  return lights.sort( ( a, b ) => a.id - b.id );
12
40
 
13
41
  };
14
42
 
43
+ /**
44
+ * Finds and returns a lighting node associated with a specific light ID.
45
+ *
46
+ * @private
47
+ * @param {number} id - The ID of the light to search for.
48
+ * @param {Array<LightingNode>} lightNodes - The array of lighting nodes to search within.
49
+ * @return {?LightingNode} The matching lighting node, or null if not found.
50
+ */
15
51
  const getLightNodeById = ( id, lightNodes ) => {
16
52
 
17
53
  for ( const lightNode of lightNodes ) {
@@ -28,7 +64,20 @@ const getLightNodeById = ( id, lightNodes ) => {
28
64
 
29
65
  };
30
66
 
67
+ /**
68
+ * WeakMap cache mapping light objects to their corresponding lighting node instances.
69
+ *
70
+ * @private
71
+ * @type {WeakMap<Light, LightingNode>}
72
+ */
31
73
  const _lightsNodeRef = /*@__PURE__*/ new WeakMap();
74
+
75
+ /**
76
+ * Array used to temporarily store light IDs and shadow casting states for hashing.
77
+ *
78
+ * @private
79
+ * @type {Array<number>}
80
+ */
32
81
  const _hashData = [];
33
82
 
34
83
  /**
@@ -58,21 +107,21 @@ class LightsNode extends Node {
58
107
  *
59
108
  * @type {Node<vec3>}
60
109
  */
61
- this.totalDiffuseNode = property( 'vec3', 'totalDiffuse' );
110
+ this.totalDiffuseNode = totalDiffuse;
62
111
 
63
112
  /**
64
113
  * A node representing the total specular light.
65
114
  *
66
115
  * @type {Node<vec3>}
67
116
  */
68
- this.totalSpecularNode = property( 'vec3', 'totalSpecular' );
117
+ this.totalSpecularNode = totalSpecular;
69
118
 
70
119
  /**
71
120
  * A node representing the outgoing light.
72
121
  *
73
122
  * @type {Node<vec3>}
74
123
  */
75
- this.outgoingLightNode = property( 'vec3', 'outgoingLight' );
124
+ this.outgoingLightNode = outgoingLight;
76
125
 
77
126
  /**
78
127
  * An array representing the lights in the scene.
@@ -91,6 +140,7 @@ class LightsNode extends Node {
91
140
  */
92
141
  this._lightProbeGrids = [];
93
142
 
143
+
94
144
  /**
95
145
  * Cached light probe grid node reused across {@link LightsNode#setupLightsNode} calls.
96
146
  *
@@ -101,25 +151,6 @@ class LightsNode extends Node {
101
151
  this._lightProbeGridNode = null;
102
152
  // !WITH_GENESYS
103
153
 
104
- /**
105
- * For each light in the scene, this node will create a
106
- * corresponding light node.
107
- *
108
- * @private
109
- * @type {?Array<LightingNode>}
110
- * @default null
111
- */
112
- this._lightNodes = null;
113
-
114
- /**
115
- * A hash for identifying the current light nodes setup.
116
- *
117
- * @private
118
- * @type {?string}
119
- * @default null
120
- */
121
- this._lightNodesHash = null;
122
-
123
154
  /**
124
155
  * `LightsNode` sets this property to `true` by default.
125
156
  *
@@ -186,26 +217,36 @@ class LightsNode extends Node {
186
217
  */
187
218
  getHash( builder ) {
188
219
 
189
- if ( this._lightNodesHash === null ) {
220
+ const nodeData = builder.getDataFromNode( this );
221
+
222
+ if ( nodeData.lightNodesHash === undefined ) {
223
+
224
+ const lightNodes = this.setupLightsNode( builder );
190
225
 
191
- if ( this._lightNodes === null ) this.setupLightsNode( builder );
226
+ nodeData.lightNodes = lightNodes;
192
227
 
193
228
  const hash = [];
194
229
 
195
- for ( const lightNode of this._lightNodes ) {
230
+ for ( const lightNode of lightNodes ) {
196
231
 
197
232
  hash.push( lightNode.getHash() );
198
233
 
199
234
  }
200
235
 
201
- this._lightNodesHash = 'lights-' + hash.join( ',' );
236
+ nodeData.lightNodesHash = 'lights-' + hash.join( ',' );
202
237
 
203
238
  }
204
239
 
205
- return this._lightNodesHash;
240
+ return nodeData.lightNodesHash;
206
241
 
207
242
  }
208
243
 
244
+ /**
245
+ * Analyzes the node's dependencies by building all nested light nodes
246
+ * and the output node.
247
+ *
248
+ * @param {NodeBuilder} builder - A reference to the current node builder.
249
+ */
209
250
  analyze( builder ) {
210
251
 
211
252
  const properties = builder.getNodeProperties( this );
@@ -225,21 +266,24 @@ class LightsNode extends Node {
225
266
  * process lights in the node system.
226
267
  *
227
268
  * @param {NodeBuilder} builder - A reference to the current node builder.
269
+ * @return {Array<LightingNode>} The array of lighting nodes.
228
270
  */
229
271
  setupLightsNode( builder ) {
230
272
 
273
+ const nodeData = builder.getDataFromNode( this );
231
274
  const lightNodes = [];
232
275
 
233
- const previousLightNodes = this._lightNodes;
276
+ const previousLightNodes = nodeData.lightNodes || null;
277
+ const materialLightings = builder.context.materialLightings;
234
278
 
235
- const lights = sortLights( this._lights );
279
+ const lights = sortLights( [ ...materialLightings, ...this._lights ] );
236
280
  const nodeLibrary = builder.renderer.library;
237
281
 
238
282
  for ( const light of lights ) {
239
283
 
240
284
  if ( light.isNode ) {
241
285
 
242
- lightNodes.push( nodeObject( light ) );
286
+ lightNodes.push( light );
243
287
 
244
288
  } else {
245
289
 
@@ -278,11 +322,12 @@ class LightsNode extends Node {
278
322
 
279
323
  }
280
324
 
325
+
281
326
  // WITH_GENESYS
282
327
  this._appendLightProbeGridNode( lightNodes );
283
328
  // !WITH_GENESYS
284
329
 
285
- this._lightNodes = lightNodes;
330
+ return lightNodes;
286
331
 
287
332
  }
288
333
 
@@ -335,6 +380,13 @@ class LightsNode extends Node {
335
380
 
336
381
  }
337
382
 
383
+ /**
384
+ * Sets up a direct rect area light in the lighting model.
385
+ *
386
+ * @param {Object} builder - The builder object containing the context and stack.
387
+ * @param {Object} lightNode - The light node.
388
+ * @param {Object} lightData - The light object containing color and area light properties.
389
+ */
338
390
  setupDirectRectAreaLight( builder, lightNode, lightData ) {
339
391
 
340
392
  const { lightingModel, reflectedLight } = builder.context;
@@ -366,9 +418,15 @@ class LightsNode extends Node {
366
418
 
367
419
  getLightNodes( builder ) {
368
420
 
369
- if ( this._lightNodes === null ) this.setupLightsNode( builder );
421
+ const nodeData = builder.getDataFromNode( this );
370
422
 
371
- return this._lightNodes;
423
+ if ( nodeData.lightNodes === undefined ) {
424
+
425
+ nodeData.lightNodes = this.setupLightsNode( builder );
426
+
427
+ }
428
+
429
+ return nodeData.lightNodes;
372
430
 
373
431
  }
374
432
 
@@ -455,9 +513,6 @@ class LightsNode extends Node {
455
513
 
456
514
  this._lights = lights;
457
515
 
458
- this._lightNodes = null;
459
- this._lightNodesHash = null;
460
-
461
516
  return this;
462
517
 
463
518
  }
@@ -12,7 +12,8 @@ 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
  // WITH_GENESYS
17
18
  import { ProfilerService } from '../../profiler/ProfilerService.js';
18
19
  // !WITH_GENESYS
@@ -120,6 +121,11 @@ const pointShadowFilter = /*@__PURE__*/ Fn( ( { filterFn, depthTexture, shadowCo
120
121
  dp = viewZToReversedPerspectiveDepth( viewZ.negate(), shadowCameraNear, shadowCameraFar );
121
122
  dp.subAssign( bias );
122
123
 
124
+ } else if ( builder.renderer.logarithmicDepthBuffer ) {
125
+
126
+ dp = viewZToLogarithmicDepth( viewZ.negate(), shadowCameraNear, shadowCameraFar );
127
+ dp.addAssign( bias );
128
+
123
129
  } else {
124
130
 
125
131
  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
  // WITH_GENESYS
28
27
  import { ProfilerService } from '../../profiler/ProfilerService.js';
@@ -53,7 +52,7 @@ export const getShadowRenderObjectFunction = ( renderer, shadow, shadowType, use
53
52
 
54
53
  if ( renderObjectFunction === undefined || ( renderObjectFunction.shadowType !== shadowType || renderObjectFunction.useVelocity !== useVelocity ) ) {
55
54
 
56
- renderObjectFunction = ( object, scene, _camera, geometry, material, group, ...params ) => {
55
+ renderObjectFunction = ( object, scene, _camera, geometry, material, group, lightsNode, clippingContext, passId ) => {
57
56
 
58
57
  if ( object.castShadow === true || ( object.receiveShadow && shadowType === VSMShadowMap ) ) {
59
58
 
@@ -65,7 +64,7 @@ export const getShadowRenderObjectFunction = ( renderer, shadow, shadowType, use
65
64
 
66
65
  object.onBeforeShadow( renderer, object, _camera, shadow.camera, geometry, scene.overrideMaterial, group );
67
66
 
68
- renderer.renderObject( object, scene, _camera, geometry, material, group, ...params );
67
+ renderer.renderObject( object, scene, _camera, geometry, material, group, lightsNode, clippingContext, passId );
69
68
 
70
69
  object.onAfterShadow( renderer, object, _camera, shadow.camera, geometry, scene.overrideMaterial, group );
71
70
 
@@ -599,7 +598,7 @@ class ShadowNode extends ShadowBaseNode {
599
598
 
600
599
  if ( this.shadowMap.texture.isCubeTexture ) {
601
600
 
602
- return cubeTexture( this.shadowMap.texture );
601
+ return cubeTexture( this.shadowMap.texture, equirectDirection() );
603
602
 
604
603
  }
605
604
 
@@ -611,15 +610,36 @@ class ShadowNode extends ShadowBaseNode {
611
610
 
612
611
  return shadowOutput.toInspector( `${ inspectName } / Depth`, () => {
613
612
 
614
- // TODO: Use linear depth
613
+ const shadowCameraNear = reference( 'near', 'float', this.shadow.camera );
614
+ const shadowCameraFar = reference( 'far', 'float', this.shadow.camera );
615
+
616
+ let depthNode;
615
617
 
616
618
  if ( this.shadowMap.texture.isCubeTexture ) {
617
619
 
618
- return cubeTexture( this.shadowMap.texture ).r.oneMinus();
620
+ depthNode = cubeTexture( this.shadowMap.depthTexture, equirectDirection() ).r;
621
+
622
+ } else {
623
+
624
+ depthNode = texture( this.shadowMap.depthTexture ).r;
619
625
 
620
626
  }
621
627
 
622
- return textureLoad( this.shadowMap.depthTexture, uv().mul( textureSize( texture( this.shadowMap.depthTexture ) ) ) ).r.oneMinus();
628
+ let linearDepth;
629
+
630
+ if ( this.shadow.camera.isPerspectiveCamera ) {
631
+
632
+ linearDepth = perspectiveDepthToViewZ( depthNode, shadowCameraNear, shadowCameraFar );
633
+
634
+ } else {
635
+
636
+ linearDepth = orthographicDepthToViewZ( depthNode, shadowCameraNear, shadowCameraFar );
637
+
638
+ }
639
+
640
+ linearDepth = viewZToOrthographicDepth( linearDepth, shadowCameraNear, shadowCameraFar );
641
+
642
+ return linearDepth.oneMinus();
623
643
 
624
644
  } );
625
645
 
@@ -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