super-three 0.167.0 → 0.169.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 (387) hide show
  1. package/build/three.cjs +532 -173
  2. package/build/three.module.js +532 -174
  3. package/build/three.module.min.js +1 -1
  4. package/build/three.webgpu.js +18173 -14266
  5. package/build/three.webgpu.min.js +1 -1
  6. package/build/three.webgpu.nodes.js +79941 -0
  7. package/build/three.webgpu.nodes.min.js +6 -0
  8. package/examples/jsm/Addons.js +0 -4
  9. package/examples/jsm/animation/AnimationClipCreator.js +1 -1
  10. package/examples/jsm/capabilities/WebGL.js +27 -21
  11. package/examples/jsm/controls/ArcballControls.js +174 -158
  12. package/examples/jsm/controls/DragControls.js +260 -132
  13. package/examples/jsm/controls/FirstPersonControls.js +175 -163
  14. package/examples/jsm/controls/FlyControls.js +194 -188
  15. package/examples/jsm/controls/OrbitControls.js +777 -786
  16. package/examples/jsm/controls/PointerLockControls.js +24 -15
  17. package/examples/jsm/controls/TrackballControls.js +469 -448
  18. package/examples/jsm/controls/TransformControls.js +97 -62
  19. package/examples/jsm/effects/AnaglyphEffect.js +6 -13
  20. package/examples/jsm/effects/ParallaxBarrierEffect.js +17 -11
  21. package/examples/jsm/effects/StereoEffect.js +6 -1
  22. package/examples/jsm/environments/RoomEnvironment.js +1 -1
  23. package/examples/jsm/exporters/DRACOExporter.js +4 -2
  24. package/examples/jsm/exporters/EXRExporter.js +19 -11
  25. package/examples/jsm/exporters/GLTFExporter.js +6 -1
  26. package/examples/jsm/exporters/KTX2Exporter.js +21 -13
  27. package/examples/jsm/exporters/OBJExporter.js +5 -1
  28. package/examples/jsm/exporters/PLYExporter.js +9 -7
  29. package/examples/jsm/exporters/USDZExporter.js +29 -8
  30. package/examples/jsm/geometries/DecalGeometry.js +4 -1
  31. package/examples/jsm/geometries/InstancedPointsGeometry.js +1 -1
  32. package/examples/jsm/helpers/LightProbeHelper.js +43 -44
  33. package/examples/jsm/helpers/LightProbeHelperGPU.js +65 -0
  34. package/examples/jsm/libs/basis/basis_transcoder.js +8 -10
  35. package/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
  36. package/examples/jsm/libs/ktx-parse.module.js +1 -1
  37. package/examples/jsm/lights/LightProbeGenerator.js +24 -10
  38. package/examples/jsm/loaders/ColladaLoader.js +9 -6
  39. package/examples/jsm/loaders/DRACOLoader.js +3 -1
  40. package/examples/jsm/loaders/FBXLoader.js +30 -20
  41. package/examples/jsm/loaders/GLTFLoader.js +5 -10
  42. package/examples/jsm/loaders/KTX2Loader.js +27 -12
  43. package/examples/jsm/loaders/MTLLoader.js +4 -3
  44. package/examples/jsm/loaders/MaterialXLoader.js +40 -14
  45. package/examples/jsm/loaders/OBJLoader.js +5 -3
  46. package/examples/jsm/loaders/PCDLoader.js +14 -13
  47. package/examples/jsm/loaders/PDBLoader.js +3 -2
  48. package/examples/jsm/loaders/PLYLoader.js +8 -5
  49. package/examples/jsm/loaders/STLLoader.js +3 -2
  50. package/examples/jsm/loaders/VRMLLoader.js +10 -10
  51. package/examples/jsm/loaders/VTKLoader.js +4 -3
  52. package/examples/jsm/loaders/XYZLoader.js +3 -2
  53. package/examples/jsm/misc/Timer.js +1 -1
  54. package/examples/jsm/modifiers/CurveModifierGPU.js +233 -0
  55. package/examples/jsm/objects/LensflareMesh.js +322 -0
  56. package/examples/jsm/objects/SkyMesh.js +187 -0
  57. package/examples/jsm/objects/Water2Mesh.js +158 -0
  58. package/examples/jsm/objects/WaterMesh.js +101 -0
  59. package/examples/jsm/physics/JoltPhysics.js +1 -1
  60. package/examples/jsm/physics/RapierPhysics.js +21 -1
  61. package/examples/jsm/postprocessing/OutlinePass.js +31 -46
  62. package/examples/jsm/postprocessing/SSAARenderPass.js +3 -1
  63. package/examples/jsm/shaders/BleachBypassShader.js +1 -2
  64. package/examples/jsm/shaders/OutputShader.js +1 -1
  65. package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
  66. package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -2
  67. package/examples/jsm/transpiler/TSLEncoder.js +8 -8
  68. package/examples/jsm/utils/GeometryCompressionUtils.js +37 -122
  69. package/examples/jsm/utils/ShadowMapViewer.js +3 -8
  70. package/examples/jsm/utils/ShadowMapViewerGPU.js +201 -0
  71. package/examples/jsm/utils/SkeletonUtils.js +84 -66
  72. package/examples/jsm/utils/TextureUtils.js +2 -1
  73. package/examples/jsm/utils/TextureUtilsGPU.js +63 -0
  74. package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
  75. package/package.json +3 -2
  76. package/src/Three.WebGPU.Nodes.js +200 -0
  77. package/src/Three.WebGPU.js +7 -0
  78. package/src/Three.js +1 -0
  79. package/src/audio/Audio.js +2 -2
  80. package/src/constants.js +1 -1
  81. package/src/core/BufferAttribute.js +0 -9
  82. package/src/core/Clock.js +1 -1
  83. package/src/core/InterleavedBuffer.js +0 -9
  84. package/src/extras/Controls.js +32 -0
  85. package/src/geometries/CylinderGeometry.js +11 -4
  86. package/src/loaders/MaterialLoader.js +7 -1
  87. package/src/loaders/ObjectLoader.js +3 -3
  88. package/src/{nodes/loaders → loaders/nodes}/NodeLoader.js +25 -5
  89. package/src/{nodes/loaders → loaders/nodes}/NodeMaterialLoader.js +21 -18
  90. package/src/{nodes/loaders → loaders/nodes}/NodeObjectLoader.js +19 -0
  91. package/src/materials/Material.js +4 -7
  92. package/src/materials/nodes/InstancedPointsNodeMaterial.js +156 -0
  93. package/src/{nodes/materials → materials/nodes}/Line2NodeMaterial.js +56 -59
  94. package/src/{nodes/materials → materials/nodes}/LineBasicNodeMaterial.js +8 -5
  95. package/src/{nodes/materials → materials/nodes}/LineDashedNodeMaterial.js +12 -10
  96. package/src/{nodes/materials → materials/nodes}/MeshBasicNodeMaterial.js +16 -12
  97. package/src/{nodes/materials → materials/nodes}/MeshLambertNodeMaterial.js +10 -6
  98. package/src/{nodes/materials → materials/nodes}/MeshMatcapNodeMaterial.js +13 -9
  99. package/src/{nodes/materials → materials/nodes}/MeshNormalNodeMaterial.js +13 -9
  100. package/src/{nodes/materials → materials/nodes}/MeshPhongNodeMaterial.js +14 -9
  101. package/src/{nodes/materials → materials/nodes}/MeshPhysicalNodeMaterial.js +22 -18
  102. package/src/{nodes/materials → materials/nodes}/MeshSSSNodeMaterial.js +10 -7
  103. package/src/{nodes/materials → materials/nodes}/MeshStandardNodeMaterial.js +22 -12
  104. package/src/{nodes/materials → materials/nodes}/MeshToonNodeMaterial.js +9 -5
  105. package/src/{nodes/materials → materials/nodes}/NodeMaterial.js +71 -115
  106. package/src/{nodes/materials/Materials.js → materials/nodes/NodeMaterials.js} +3 -1
  107. package/src/{nodes/materials → materials/nodes}/PointsNodeMaterial.js +8 -5
  108. package/src/{nodes/materials → materials/nodes}/ShadowNodeMaterial.js +9 -5
  109. package/src/{nodes/materials → materials/nodes}/SpriteNodeMaterial.js +47 -14
  110. package/src/{nodes/materials → materials/nodes}/VolumeNodeMaterial.js +24 -22
  111. package/src/materials/nodes/manager/NodeMaterialObserver.js +302 -0
  112. package/src/math/Triangle.js +24 -0
  113. package/src/nodes/Nodes.js +103 -159
  114. package/src/nodes/TSL.js +179 -0
  115. package/src/nodes/accessors/AccessorsUtils.js +8 -8
  116. package/src/nodes/accessors/BatchNode.js +53 -21
  117. package/src/nodes/accessors/{BitangentNode.js → Bitangent.js} +9 -9
  118. package/src/nodes/accessors/BufferAttributeNode.js +8 -5
  119. package/src/nodes/accessors/BufferNode.js +7 -4
  120. package/src/nodes/accessors/Camera.js +13 -0
  121. package/src/nodes/accessors/ClippingNode.js +19 -13
  122. package/src/nodes/accessors/CubeTextureNode.js +9 -8
  123. package/src/nodes/accessors/InstanceNode.js +19 -15
  124. package/src/nodes/accessors/InstancedPointsMaterialNode.js +8 -5
  125. package/src/nodes/accessors/Lights.js +51 -0
  126. package/src/nodes/accessors/MaterialNode.js +56 -55
  127. package/src/nodes/accessors/MaterialProperties.js +3 -0
  128. package/src/nodes/accessors/MaterialReferenceNode.js +9 -4
  129. package/src/nodes/accessors/ModelNode.js +47 -12
  130. package/src/nodes/accessors/ModelViewProjectionNode.js +12 -9
  131. package/src/nodes/accessors/MorphNode.js +17 -13
  132. package/src/nodes/accessors/Normal.js +88 -0
  133. package/src/nodes/accessors/Object3DNode.js +17 -33
  134. package/src/nodes/accessors/PointUVNode.js +9 -5
  135. package/src/nodes/accessors/Position.js +10 -0
  136. package/src/nodes/accessors/ReferenceBaseNode.js +171 -0
  137. package/src/nodes/accessors/ReferenceNode.js +50 -7
  138. package/src/nodes/accessors/ReflectVector.js +10 -0
  139. package/src/nodes/accessors/RendererReferenceNode.js +12 -6
  140. package/src/nodes/accessors/SceneNode.js +9 -6
  141. package/src/nodes/accessors/SkinningNode.js +88 -21
  142. package/src/nodes/accessors/StorageBufferNode.js +22 -5
  143. package/src/nodes/accessors/StorageTextureNode.js +9 -6
  144. package/src/nodes/accessors/Tangent.js +22 -0
  145. package/src/nodes/accessors/Texture3DNode.js +16 -13
  146. package/src/nodes/accessors/{TextureBicubicNode.js → TextureBicubic.js} +3 -32
  147. package/src/nodes/accessors/TextureNode.js +29 -23
  148. package/src/nodes/accessors/TextureSizeNode.js +10 -9
  149. package/src/nodes/accessors/{UniformsNode.js → UniformArrayNode.js} +26 -14
  150. package/src/nodes/accessors/UserDataNode.js +10 -7
  151. package/src/nodes/accessors/VelocityNode.js +134 -0
  152. package/src/nodes/accessors/VertexColorNode.js +7 -4
  153. package/src/nodes/code/CodeNode.js +9 -5
  154. package/src/nodes/code/ExpressionNode.js +10 -6
  155. package/src/nodes/code/FunctionCallNode.js +8 -5
  156. package/src/nodes/code/FunctionNode.js +8 -23
  157. package/src/nodes/code/ScriptableNode.js +13 -10
  158. package/src/nodes/code/ScriptableValueNode.js +9 -7
  159. package/src/nodes/core/AssignNode.js +12 -9
  160. package/src/nodes/core/AttributeNode.js +12 -21
  161. package/src/nodes/core/BypassNode.js +11 -7
  162. package/src/nodes/core/CacheNode.js +10 -6
  163. package/src/nodes/core/ConstNode.js +6 -3
  164. package/src/nodes/core/ContextNode.js +21 -11
  165. package/src/nodes/core/IndexNode.js +35 -8
  166. package/src/nodes/core/InputNode.js +7 -3
  167. package/src/nodes/core/MRTNode.js +16 -7
  168. package/src/nodes/core/Node.js +19 -40
  169. package/src/nodes/core/NodeBuilder.js +117 -38
  170. package/src/nodes/core/NodeUtils.js +49 -6
  171. package/src/nodes/core/OutputStructNode.js +10 -6
  172. package/src/nodes/core/ParameterNode.js +7 -4
  173. package/src/nodes/core/PropertyNode.js +36 -32
  174. package/src/nodes/core/StackNode.js +31 -11
  175. package/src/nodes/core/StructTypeNode.js +7 -3
  176. package/src/nodes/core/TempNode.js +8 -4
  177. package/src/nodes/core/UniformGroupNode.js +14 -11
  178. package/src/nodes/core/UniformNode.js +7 -4
  179. package/src/nodes/core/VarNode.js +12 -8
  180. package/src/nodes/core/VaryingNode.js +10 -6
  181. package/src/nodes/display/AfterImageNode.js +15 -9
  182. package/src/nodes/display/AnaglyphPassNode.js +67 -0
  183. package/src/nodes/display/AnamorphicNode.js +17 -11
  184. package/src/nodes/display/BleachBypass.js +26 -0
  185. package/src/nodes/display/BlendMode.js +54 -0
  186. package/src/nodes/display/BloomNode.js +27 -19
  187. package/src/nodes/display/BumpMapNode.js +13 -12
  188. package/src/nodes/display/ColorAdjustment.js +46 -0
  189. package/src/nodes/display/ColorSpaceFunctions.js +38 -0
  190. package/src/nodes/display/ColorSpaceNode.js +67 -61
  191. package/src/nodes/display/DenoiseNode.js +23 -17
  192. package/src/nodes/display/DepthOfFieldNode.js +12 -7
  193. package/src/nodes/display/DotScreenNode.js +13 -22
  194. package/src/nodes/display/FXAANode.js +21 -16
  195. package/src/nodes/display/FilmNode.js +11 -7
  196. package/src/nodes/display/FrontFacingNode.js +10 -6
  197. package/src/nodes/display/GTAONode.js +22 -15
  198. package/src/nodes/display/GaussianBlurNode.js +14 -8
  199. package/src/nodes/display/Lut3DNode.js +10 -6
  200. package/src/nodes/display/MotionBlur.js +25 -0
  201. package/src/nodes/display/NormalMapNode.js +13 -13
  202. package/src/nodes/display/ParallaxBarrierPassNode.js +58 -0
  203. package/src/nodes/display/PassNode.js +95 -8
  204. package/src/nodes/display/PixelationPassNode.js +20 -8
  205. package/src/nodes/display/PosterizeNode.js +8 -7
  206. package/src/nodes/display/RGBShiftNode.js +11 -7
  207. package/src/nodes/display/RenderOutputNode.js +15 -11
  208. package/src/nodes/display/SSAAPassNode.js +287 -0
  209. package/src/nodes/display/ScreenNode.js +181 -0
  210. package/src/nodes/display/Sepia.js +17 -0
  211. package/src/nodes/display/SobelOperatorNode.js +13 -8
  212. package/src/nodes/display/StereoCompositePassNode.js +110 -0
  213. package/src/nodes/display/StereoPassNode.js +83 -0
  214. package/src/nodes/display/ToneMappingFunctions.js +190 -0
  215. package/src/nodes/display/ToneMappingNode.js +15 -175
  216. package/src/nodes/display/ToonOutlinePassNode.js +111 -0
  217. package/src/nodes/display/TransitionNode.js +12 -8
  218. package/src/nodes/display/ViewportDepthNode.js +34 -29
  219. package/src/nodes/display/ViewportDepthTextureNode.js +10 -9
  220. package/src/nodes/display/ViewportSharedTextureNode.js +10 -9
  221. package/src/nodes/display/ViewportTextureNode.js +11 -11
  222. package/src/nodes/fog/FogExp2Node.js +8 -7
  223. package/src/nodes/fog/FogNode.js +10 -8
  224. package/src/nodes/fog/FogRangeNode.js +8 -7
  225. package/src/nodes/functions/BSDF/BRDF_GGX.js +4 -4
  226. package/src/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
  227. package/src/nodes/functions/BSDF/BRDF_Sheen.js +6 -6
  228. package/src/nodes/functions/BSDF/DFGApprox.js +2 -2
  229. package/src/nodes/functions/BSDF/D_GGX.js +2 -2
  230. package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +3 -3
  231. package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
  232. package/src/nodes/functions/BSDF/F_Schlick.js +2 -2
  233. package/src/nodes/functions/BSDF/LTC.js +6 -6
  234. package/src/nodes/functions/BSDF/Schlick_to_F0.js +2 -2
  235. package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
  236. package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
  237. package/src/nodes/functions/BasicLightingModel.js +1 -1
  238. package/src/nodes/functions/PhongLightingModel.js +5 -5
  239. package/src/nodes/functions/PhysicalLightingModel.js +34 -33
  240. package/src/nodes/functions/ShadowMaskModel.js +1 -1
  241. package/src/nodes/functions/ToonLightingModel.js +3 -3
  242. package/src/nodes/functions/material/getGeometryRoughness.js +4 -4
  243. package/src/nodes/functions/material/getRoughness.js +2 -2
  244. package/src/nodes/functions/material/getShIrradianceAt.js +28 -0
  245. package/src/nodes/geometry/RangeNode.js +9 -5
  246. package/src/nodes/gpgpu/AtomicFunctionNode.js +99 -0
  247. package/src/nodes/gpgpu/BarrierNode.js +40 -0
  248. package/src/nodes/gpgpu/ComputeBuiltinNode.js +98 -0
  249. package/src/nodes/gpgpu/ComputeNode.js +10 -6
  250. package/src/nodes/gpgpu/WorkgroupInfoNode.js +100 -0
  251. package/src/nodes/lighting/AONode.js +6 -3
  252. package/src/nodes/lighting/AmbientLightNode.js +6 -8
  253. package/src/nodes/lighting/AnalyticLightNode.js +225 -36
  254. package/src/nodes/lighting/BasicEnvironmentNode.js +8 -4
  255. package/src/nodes/lighting/BasicLightMapNode.js +7 -4
  256. package/src/nodes/lighting/DirectionalLightNode.js +7 -9
  257. package/src/nodes/lighting/EnvironmentNode.js +23 -19
  258. package/src/nodes/lighting/HemisphereLightNode.js +11 -11
  259. package/src/nodes/lighting/IESSpotLightNode.js +7 -9
  260. package/src/nodes/lighting/IrradianceNode.js +6 -3
  261. package/src/nodes/lighting/LightProbeNode.js +53 -0
  262. package/src/nodes/lighting/LightUtils.js +3 -3
  263. package/src/nodes/lighting/LightingContextNode.js +19 -18
  264. package/src/nodes/lighting/LightingNode.js +7 -3
  265. package/src/nodes/lighting/LightsNode.js +112 -75
  266. package/src/nodes/lighting/PointLightNode.js +12 -13
  267. package/src/nodes/lighting/RectAreaLightNode.js +11 -11
  268. package/src/nodes/lighting/SpotLightNode.js +14 -16
  269. package/src/nodes/materialx/MaterialXNodes.js +2 -2
  270. package/src/nodes/materialx/lib/mx_hsv.js +36 -31
  271. package/src/nodes/materialx/lib/mx_noise.js +96 -96
  272. package/src/nodes/materialx/lib/mx_transform_color.js +2 -2
  273. package/src/nodes/math/{CondNode.js → ConditionalNode.js} +38 -10
  274. package/src/nodes/math/Hash.js +13 -0
  275. package/src/nodes/math/MathNode.js +127 -124
  276. package/src/nodes/math/MathUtils.js +0 -7
  277. package/src/nodes/math/OperatorNode.js +97 -52
  278. package/src/nodes/math/TriNoise3D.js +19 -29
  279. package/src/nodes/pmrem/PMREMNode.js +61 -15
  280. package/src/nodes/pmrem/PMREMUtils.js +46 -46
  281. package/src/nodes/procedural/Checker.js +14 -0
  282. package/src/nodes/tsl/TSLBase.js +30 -0
  283. package/src/nodes/{shadernode/ShaderNode.js → tsl/TSLCore.js} +105 -97
  284. package/src/nodes/utils/ArrayElementNode.js +8 -4
  285. package/src/nodes/utils/ConvertNode.js +7 -3
  286. package/src/nodes/utils/CubeMapNode.js +160 -0
  287. package/src/nodes/utils/Discard.js +8 -0
  288. package/src/nodes/utils/EquirectUVNode.js +9 -6
  289. package/src/nodes/utils/FlipNode.js +68 -0
  290. package/src/nodes/utils/FunctionOverloadingNode.js +9 -5
  291. package/src/nodes/utils/JoinNode.js +6 -3
  292. package/src/nodes/utils/LoopNode.js +16 -6
  293. package/src/nodes/utils/MatcapUVNode.js +10 -7
  294. package/src/nodes/utils/MaxMipLevelNode.js +8 -5
  295. package/src/nodes/utils/OscNode.js +12 -8
  296. package/src/nodes/utils/Packing.js +4 -0
  297. package/src/nodes/utils/RTTNode.js +11 -8
  298. package/src/nodes/utils/ReflectorNode.js +12 -4
  299. package/src/nodes/utils/RemapNode.js +12 -8
  300. package/src/nodes/utils/RotateNode.js +8 -13
  301. package/src/nodes/utils/SetNode.js +7 -4
  302. package/src/nodes/utils/SplitNode.js +7 -3
  303. package/src/nodes/utils/SpriteSheetUVNode.js +10 -6
  304. package/src/nodes/utils/SpriteUtils.js +47 -0
  305. package/src/nodes/utils/StorageArrayElementNode.js +11 -12
  306. package/src/nodes/utils/TimerNode.js +8 -5
  307. package/src/nodes/utils/TriplanarTexturesNode.js +11 -9
  308. package/src/nodes/utils/UVUtils.js +19 -0
  309. package/src/nodes/utils/ViewportUtils.js +14 -0
  310. package/src/objects/BatchedMesh.js +78 -13
  311. package/src/objects/LOD.js +21 -0
  312. package/src/objects/Line.js +1 -0
  313. package/src/objects/Mesh.js +7 -23
  314. package/src/objects/Points.js +2 -0
  315. package/src/renderers/WebGLRenderer.js +88 -41
  316. package/src/renderers/common/Backend.js +2 -2
  317. package/src/renderers/common/Background.js +3 -1
  318. package/src/renderers/common/BindGroup.js +3 -1
  319. package/src/renderers/common/Bindings.js +13 -15
  320. package/src/renderers/common/BundleGroup.js +26 -0
  321. package/src/renderers/common/ClippingContext.js +15 -5
  322. package/src/renderers/common/CubeRenderTarget.js +9 -3
  323. package/src/renderers/common/PostProcessing.js +4 -1
  324. package/src/renderers/common/QuadMesh.js +2 -0
  325. package/src/renderers/common/RenderContext.js +23 -0
  326. package/src/renderers/common/RenderList.js +1 -1
  327. package/src/renderers/common/RenderObject.js +117 -6
  328. package/src/renderers/common/RenderObjects.js +8 -1
  329. package/src/renderers/common/Renderer.js +128 -94
  330. package/src/renderers/common/SampledTexture.js +12 -3
  331. package/src/renderers/common/Textures.js +8 -12
  332. package/src/renderers/common/extras/PMREMGenerator.js +19 -22
  333. package/src/renderers/common/nodes/NodeBuilderState.js +4 -4
  334. package/src/renderers/common/nodes/NodeLibrary.js +118 -0
  335. package/src/renderers/common/nodes/NodeSampledTexture.js +2 -2
  336. package/src/renderers/common/nodes/Nodes.js +65 -19
  337. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +2 -2
  338. package/src/renderers/shaders/ShaderLib/sprite.glsl.js +2 -4
  339. package/src/renderers/webgl/WebGLAttributes.js +45 -14
  340. package/src/renderers/webgl/WebGLCapabilities.js +9 -0
  341. package/src/renderers/webgl/WebGLProgram.js +3 -1
  342. package/src/renderers/webgl/WebGLPrograms.js +21 -17
  343. package/src/renderers/webgl/WebGLProperties.js +7 -0
  344. package/src/renderers/webgl/WebGLState.js +21 -0
  345. package/src/renderers/webgl/WebGLTextures.js +83 -4
  346. package/src/renderers/webgl-fallback/WebGLBackend.js +135 -110
  347. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +60 -12
  348. package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +6 -0
  349. package/src/renderers/webgl-fallback/utils/WebGLState.js +20 -2
  350. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +89 -37
  351. package/src/renderers/webgpu/WebGPUBackend.js +112 -86
  352. package/src/renderers/webgpu/WebGPURenderer.Nodes.js +42 -0
  353. package/src/renderers/webgpu/WebGPURenderer.js +9 -6
  354. package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +59 -0
  355. package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +105 -0
  356. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +189 -73
  357. package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +6 -16
  358. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +45 -21
  359. package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -1
  360. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +7 -16
  361. package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
  362. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +43 -26
  363. package/src/renderers/webgpu/utils/WebGPUUtils.js +19 -2
  364. package/src/renderers/webxr/WebXRManager.js +32 -25
  365. package/src/utils.js +33 -1
  366. package/examples/jsm/geometries/SDFGeometryGenerator.js +0 -144
  367. package/examples/jsm/loaders/LogLuvLoader.js +0 -606
  368. package/examples/jsm/loaders/TiltLoader.js +0 -520
  369. package/examples/jsm/utils/GPUStatsPanel.js +0 -95
  370. package/examples/jsm/utils/PackedPhongMaterial.js +0 -178
  371. package/src/nodes/accessors/CameraNode.js +0 -19
  372. package/src/nodes/accessors/NormalNode.js +0 -14
  373. package/src/nodes/accessors/PositionNode.js +0 -10
  374. package/src/nodes/accessors/ReflectVectorNode.js +0 -10
  375. package/src/nodes/accessors/TangentNode.js +0 -23
  376. package/src/nodes/core/NodeKeywords.js +0 -80
  377. package/src/nodes/display/BlendModeNode.js +0 -128
  378. package/src/nodes/display/ColorAdjustmentNode.js +0 -104
  379. package/src/nodes/display/ViewportNode.js +0 -137
  380. package/src/nodes/lighting/LightNode.js +0 -57
  381. package/src/nodes/materials/InstancedPointsNodeMaterial.js +0 -162
  382. package/src/nodes/math/HashNode.js +0 -34
  383. package/src/nodes/procedural/CheckerNode.js +0 -42
  384. package/src/nodes/utils/DiscardNode.js +0 -28
  385. package/src/nodes/utils/PackingNode.js +0 -55
  386. package/src/nodes/utils/RotateUVNode.js +0 -35
  387. /package/src/nodes/accessors/{UVNode.js → UV.js} +0 -0
@@ -0,0 +1,187 @@
1
+ import {
2
+ BackSide,
3
+ BoxGeometry,
4
+ Mesh,
5
+ Vector3
6
+ } from 'three';
7
+ import { Fn, NodeMaterial, float, vec3, acos, add, mul, clamp, cos, dot, exp, max, mix, modelViewProjection, normalize, positionWorld, pow, smoothstep, sub, varying, varyingProperty, vec4, uniform, cameraPosition } from 'three/tsl';
8
+
9
+ /**
10
+ * Based on "A Practical Analytic Model for Daylight"
11
+ * aka The Preetham Model, the de facto standard analytic skydome model
12
+ * https://www.researchgate.net/publication/220720443_A_Practical_Analytic_Model_for_Daylight
13
+ *
14
+ * First implemented by Simon Wallner
15
+ * http://simonwallner.at/project/atmospheric-scattering/
16
+ *
17
+ * Improved by Martin Upitis
18
+ * http://blenderartists.org/forum/showthread.php?245954-preethams-sky-impementation-HDR
19
+ *
20
+ * Three.js integration by zz85 http://twitter.com/blurspline
21
+ */
22
+
23
+ class SkyMesh extends Mesh {
24
+
25
+ constructor() {
26
+
27
+ const material = new NodeMaterial();
28
+
29
+ super( new BoxGeometry( 1, 1, 1 ), material );
30
+
31
+ this.turbidity = uniform( 2 );
32
+ this.rayleigh = uniform( 1 );
33
+ this.mieCoefficient = uniform( 0.005 );
34
+ this.mieDirectionalG = uniform( 0.8 );
35
+ this.sunPosition = uniform( new Vector3() );
36
+ this.upUniform = uniform( new Vector3( 0, 1, 0 ) );
37
+
38
+ this.isSky = true;
39
+
40
+ const vertexNode = /*@__PURE__*/ Fn( () => {
41
+
42
+ // constants for atmospheric scattering
43
+ const e = float( 2.71828182845904523536028747135266249775724709369995957 );
44
+ // const pi = float( 3.141592653589793238462643383279502884197169 );
45
+
46
+ // wavelength of used primaries, according to preetham
47
+ // const lambda = vec3( 680E-9, 550E-9, 450E-9 );
48
+ // this pre-calcuation replaces older TotalRayleigh(vec3 lambda) function:
49
+ // (8.0 * pow(pi, 3.0) * pow(pow(n, 2.0) - 1.0, 2.0) * (6.0 + 3.0 * pn)) / (3.0 * N * pow(lambda, vec3(4.0)) * (6.0 - 7.0 * pn))
50
+ const totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 );
51
+
52
+ // mie stuff
53
+ // K coefficient for the primaries
54
+ // const v = float( 4.0 );
55
+ // const K = vec3( 0.686, 0.678, 0.666 );
56
+ // MieConst = pi * pow( ( 2.0 * pi ) / lambda, vec3( v - 2.0 ) ) * K
57
+ const MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 );
58
+
59
+ // earth shadow hack
60
+ // cutoffAngle = pi / 1.95;
61
+ const cutoffAngle = float( 1.6110731556870734 );
62
+ const steepness = float( 1.5 );
63
+ const EE = float( 1000.0 );
64
+
65
+ // varying sun position
66
+
67
+ const vSunDirection = normalize( this.sunPosition );
68
+ varyingProperty( 'vec3', 'vSunDirection' ).assign( vSunDirection );
69
+
70
+ // varying sun intensity
71
+
72
+ const angle = dot( vSunDirection, this.upUniform );
73
+ const zenithAngleCos = clamp( angle, - 1, 1 );
74
+ const sunIntensity = EE.mul( max( 0.0, float( 1.0 ).sub( pow( e, cutoffAngle.sub( acos( zenithAngleCos ) ).div( steepness ).negate() ) ) ) );
75
+ varyingProperty( 'float', 'vSunE' ).assign( sunIntensity );
76
+
77
+ // varying sun fade
78
+
79
+ const vSunfade = float( 1.0 ).sub( clamp( float( 1.0 ).sub( exp( this.sunPosition.y.div( 450000.0 ) ) ), 0, 1 ) );
80
+ varyingProperty( 'float', 'vSunfade' ).assign( vSunfade );
81
+
82
+ // varying vBetaR
83
+
84
+ const rayleighCoefficient = this.rayleigh.sub( float( 1.0 ).mul( float( 1.0 ).sub( vSunfade ) ) );
85
+
86
+ // extinction (absorbtion + out scattering)
87
+ // rayleigh coefficients
88
+ varyingProperty( 'vec3', 'vBetaR' ).assign( totalRayleigh.mul( rayleighCoefficient ) );
89
+
90
+ // varying vBetaM
91
+
92
+ const c = float( 0.2 ).mul( this.turbidity ).mul( 10E-18 );
93
+ const totalMie = float( 0.434 ).mul( c ).mul( MieConst );
94
+
95
+ varyingProperty( 'vec3', 'vBetaM' ).assign( totalMie.mul( this.mieCoefficient ) );
96
+
97
+ // position
98
+
99
+ const position = modelViewProjection();
100
+ position.z.assign( position.w ); // set z to camera.far
101
+
102
+ return position;
103
+
104
+ } )();
105
+
106
+ const fragmentNode = /*@__PURE__*/ Fn( () => {
107
+
108
+ const vSunDirection = varying( vec3(), 'vSunDirection' );
109
+ const vSunE = varying( float(), 'vSunE' );
110
+ const vSunfade = varying( float(), 'vSunfade' );
111
+ const vBetaR = varying( vec3(), 'vBetaR' );
112
+ const vBetaM = varying( vec3(), 'vBetaM' );
113
+
114
+ // constants for atmospheric scattering
115
+ const pi = float( 3.141592653589793238462643383279502884197169 );
116
+
117
+ // optical length at zenith for molecules
118
+ const rayleighZenithLength = float( 8.4E3 );
119
+ const mieZenithLength = float( 1.25E3 );
120
+ // 66 arc seconds -> degrees, and the cosine of that
121
+ const sunAngularDiameterCos = float( 0.999956676946448443553574619906976478926848692873900859324 );
122
+
123
+ // 3.0 / ( 16.0 * pi )
124
+ const THREE_OVER_SIXTEENPI = float( 0.05968310365946075 );
125
+ // 1.0 / ( 4.0 * pi )
126
+ const ONE_OVER_FOURPI = float( 0.07957747154594767 );
127
+
128
+ //
129
+
130
+ const direction = normalize( positionWorld.sub( cameraPosition ) );
131
+
132
+ // optical length
133
+ // cutoff angle at 90 to avoid singularity in next formula.
134
+ const zenithAngle = acos( max( 0.0, dot( this.upUniform, direction ) ) );
135
+ const inverse = float( 1.0 ).div( cos( zenithAngle ).add( float( 0.15 ).mul( pow( float( 93.885 ).sub( zenithAngle.mul( 180.0 ).div( pi ) ), - 1.253 ) ) ) );
136
+ const sR = rayleighZenithLength.mul( inverse );
137
+ const sM = mieZenithLength.mul( inverse );
138
+
139
+ // combined extinction factor
140
+ const Fex = exp( mul( vBetaR, sR ).add( mul( vBetaM, sM ) ).negate() );
141
+
142
+ // in scattering
143
+ const cosTheta = dot( direction, vSunDirection );
144
+
145
+ // betaRTheta
146
+
147
+ const c = cosTheta.mul( 0.5 ).add( 0.5 );
148
+ const rPhase = THREE_OVER_SIXTEENPI.mul( float( 1.0 ).add( pow( c, 2.0 ) ) );
149
+ const betaRTheta = vBetaR.mul( rPhase );
150
+
151
+ // betaMTheta
152
+
153
+ const g2 = pow( this.mieDirectionalG, 2.0 );
154
+ const inv = float( 1.0 ).div( pow( float( 1.0 ).sub( float( 2.0 ).mul( this.mieDirectionalG ).mul( cosTheta ) ).add( g2 ), 1.5 ) );
155
+ const mPhase = ONE_OVER_FOURPI.mul( float( 1.0 ).sub( g2 ) ).mul( inv );
156
+ const betaMTheta = vBetaM.mul( mPhase );
157
+
158
+ const Lin = pow( vSunE.mul( add( betaRTheta, betaMTheta ).div( add( vBetaR, vBetaM ) ) ).mul( sub( 1.0, Fex ) ), vec3( 1.5 ) );
159
+ Lin.mulAssign( mix( vec3( 1.0 ), pow( vSunE.mul( add( betaRTheta, betaMTheta ).div( add( vBetaR, vBetaM ) ) ).mul( Fex ), vec3( 1.0 / 2.0 ) ), clamp( pow( sub( 1.0, dot( this.upUniform, vSunDirection ) ), 5.0 ), 0.0, 1.0 ) ) );
160
+
161
+ // nightsky
162
+
163
+ const L0 = vec3( 0.1 ).mul( Fex );
164
+
165
+ // composition + solar disc
166
+ const sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos.add( 0.00002 ), cosTheta );
167
+ L0.addAssign( vSunE.mul( 19000.0 ).mul( Fex ).mul( sundisk ) );
168
+
169
+ const texColor = add( Lin, L0 ).mul( 0.04 ).add( vec3( 0.0, 0.0003, 0.00075 ) );
170
+
171
+ const retColor = pow( texColor, vec3( float( 1.0 ).div( float( 1.2 ).add( vSunfade.mul( 1.2 ) ) ) ) );
172
+
173
+ return vec4( retColor, 1.0 );
174
+
175
+ } )();
176
+
177
+ material.side = BackSide;
178
+ material.depthWrite = false;
179
+
180
+ material.vertexNode = vertexNode;
181
+ material.fragmentNode = fragmentNode;
182
+
183
+ }
184
+
185
+ }
186
+
187
+ export { SkyMesh };
@@ -0,0 +1,158 @@
1
+ import {
2
+ Color,
3
+ Mesh,
4
+ Vector2,
5
+ Vector3
6
+ } from 'three';
7
+ import { Fn, NodeMaterial, NodeUpdateType, TempNode, vec2, viewportSafeUV, viewportSharedTexture, reflector, pow, float, abs, texture, uniform, vec4, cameraPosition, positionWorld, uv, mix, vec3, normalize, max, dot, screenUV } from 'three/tsl';
8
+
9
+ /**
10
+ * References:
11
+ * https://alex.vlachos.com/graphics/Vlachos-SIGGRAPH10-WaterFlow.pdf
12
+ * http://graphicsrunner.blogspot.de/2010/08/water-using-flow-maps.html
13
+ *
14
+ */
15
+
16
+ class WaterMesh extends Mesh {
17
+
18
+ constructor( geometry, options = {} ) {
19
+
20
+ const material = new NodeMaterial();
21
+
22
+ super( geometry, material );
23
+
24
+ this.isWater = true;
25
+
26
+ material.fragmentNode = new WaterNode( options, this );
27
+
28
+ }
29
+
30
+ }
31
+
32
+ class WaterNode extends TempNode {
33
+
34
+ constructor( options, waterBody ) {
35
+
36
+ super( 'vec4' );
37
+
38
+ this.waterBody = waterBody;
39
+
40
+ this.normalMap0 = texture( options.normalMap0 );
41
+ this.normalMap1 = texture( options.normalMap1 );
42
+ this.flowMap = texture( options.flowMap !== undefined ? options.flowMap : null );
43
+
44
+ this.color = uniform( options.color !== undefined ? new Color( options.color ) : new Color( 0xffffff ) );
45
+ this.flowDirection = uniform( options.flowDirection !== undefined ? options.flowDirection : new Vector2( 1, 0 ) );
46
+ this.flowSpeed = uniform( options.flowSpeed !== undefined ? options.flowSpeed : 0.03 );
47
+ this.reflectivity = uniform( options.reflectivity !== undefined ? options.reflectivity : 0.02 );
48
+ this.scale = uniform( options.scale !== undefined ? options.scale : 1 );
49
+ this.flowConfig = uniform( new Vector3() );
50
+
51
+ this.updateBeforeType = NodeUpdateType.RENDER;
52
+
53
+ this._cycle = 0.15; // a cycle of a flow map phase
54
+ this._halfCycle = this._cycle * 0.5;
55
+
56
+ this._USE_FLOW = options.flowMap !== undefined;
57
+
58
+ }
59
+
60
+ updateFlow( delta ) {
61
+
62
+ this.flowConfig.value.x += this.flowSpeed.value * delta; // flowMapOffset0
63
+ this.flowConfig.value.y = this.flowConfig.value.x + this._halfCycle; // flowMapOffset1
64
+
65
+ // Important: The distance between offsets should be always the value of "halfCycle".
66
+ // Moreover, both offsets should be in the range of [ 0, cycle ].
67
+ // This approach ensures a smooth water flow and avoids "reset" effects.
68
+
69
+ if ( this.flowConfig.value.x >= this._cycle ) {
70
+
71
+ this.flowConfig.value.x = 0;
72
+ this.flowConfig.value.y = this._halfCycle;
73
+
74
+ } else if ( this.flowConfig.value.y >= this._cycle ) {
75
+
76
+ this.flowConfig.value.y = this.flowConfig.value.y - this._cycle;
77
+
78
+ }
79
+
80
+ this.flowConfig.value.z = this._halfCycle;
81
+
82
+ }
83
+
84
+ updateBefore( frame ) {
85
+
86
+ this.updateFlow( frame.deltaTime );
87
+
88
+ }
89
+
90
+ setup() {
91
+
92
+ const outputNode = Fn( () => {
93
+
94
+ const flowMapOffset0 = this.flowConfig.x;
95
+ const flowMapOffset1 = this.flowConfig.y;
96
+ const halfCycle = this.flowConfig.z;
97
+
98
+ const toEye = normalize( cameraPosition.sub( positionWorld ) );
99
+
100
+ let flow;
101
+
102
+ if ( this._USE_FLOW === true ) {
103
+
104
+ flow = this.flowMap.rg.mul( 2 ).sub( 1 );
105
+
106
+ } else {
107
+
108
+ flow = vec2( this.flowDirection.x, this.flowDirection.y );
109
+
110
+ }
111
+
112
+ flow.x.mulAssign( - 1 );
113
+
114
+ // sample normal maps (distort uvs with flowdata)
115
+
116
+ const uvs = uv();
117
+
118
+ const normalUv0 = uvs.mul( this.scale ).add( flow.mul( flowMapOffset0 ) );
119
+ const normalUv1 = uvs.mul( this.scale ).add( flow.mul( flowMapOffset1 ) );
120
+
121
+ const normalColor0 = this.normalMap0.uv( normalUv0 );
122
+ const normalColor1 = this.normalMap1.uv( normalUv1 );
123
+
124
+ // linear interpolate to get the final normal color
125
+ const flowLerp = abs( halfCycle.sub( flowMapOffset0 ) ).div( halfCycle );
126
+ const normalColor = mix( normalColor0, normalColor1, flowLerp );
127
+
128
+ // calculate normal vector
129
+ const normal = normalize( vec3( normalColor.r.mul( 2 ).sub( 1 ), normalColor.b, normalColor.g.mul( 2 ).sub( 1 ) ) );
130
+
131
+ // calculate the fresnel term to blend reflection and refraction maps
132
+ const theta = max( dot( toEye, normal ), 0 );
133
+ const reflectance = pow( float( 1.0 ).sub( theta ), 5.0 ).mul( float( 1.0 ).sub( this.reflectivity ) ).add( this.reflectivity );
134
+
135
+ // reflector, refractor
136
+
137
+ const offset = normal.xz.mul( 0.05 ).toVar();
138
+
139
+ const reflectionSampler = reflector();
140
+ this.waterBody.add( reflectionSampler.target );
141
+ reflectionSampler.uvNode = reflectionSampler.uvNode.add( offset );
142
+
143
+ const refractorUV = screenUV.add( offset );
144
+ const refractionSampler = viewportSharedTexture( viewportSafeUV( refractorUV ) );
145
+
146
+ // calculate final uv coords
147
+
148
+ return vec4( this.color, 1.0 ).mul( mix( refractionSampler, reflectionSampler, reflectance ) );
149
+
150
+ } )();
151
+
152
+ return outputNode;
153
+
154
+ }
155
+
156
+ }
157
+
158
+ export { WaterMesh };
@@ -0,0 +1,101 @@
1
+ import {
2
+ Color,
3
+ Mesh,
4
+ Vector3
5
+ } from 'three';
6
+ import { Fn, NodeMaterial, add, cameraPosition, div, normalize, positionWorld, sub, timerLocal, texture, vec2, vec3, vec4, max, dot, reflect, pow, length, float, uniform, reflector, mul, mix } from 'three/tsl';
7
+
8
+ /**
9
+ * Work based on :
10
+ * https://github.com/Slayvin: Flat mirror for three.js
11
+ * https://home.adelphi.edu/~stemkoski/ : An implementation of water shader based on the flat mirror
12
+ * http://29a.ch/ && http://29a.ch/slides/2012/webglwater/ : Water shader explanations in WebGL
13
+ */
14
+
15
+ class WaterMesh extends Mesh {
16
+
17
+ constructor( geometry, options ) {
18
+
19
+ const material = new NodeMaterial();
20
+
21
+ super( geometry, material );
22
+
23
+ this.isWater = true;
24
+
25
+ this.resolution = options.resolution !== undefined ? options.resolution : 0.5;
26
+
27
+ // uniforms
28
+
29
+ this.waterNormals = texture( options.waterNormals );
30
+ this.alpha = uniform( options.alpha !== undefined ? options.alpha : 1.0 );
31
+ this.size = uniform( options.size !== undefined ? options.size : 1.0 );
32
+ this.sunColor = uniform( new Color( options.sunColor !== undefined ? options.sunColor : 0xffffff ) );
33
+ this.sunDirection = uniform( options.sunDirection !== undefined ? options.sunDirection : new Vector3( 0.70707, 0.70707, 0.0 ) );
34
+ this.waterColor = uniform( new Color( options.waterColor !== undefined ? options.waterColor : 0x7f7f7f ) );
35
+ this.distortionScale = uniform( options.distortionScale !== undefined ? options.distortionScale : 20.0 );
36
+
37
+ // TSL
38
+
39
+ const timeNode = timerLocal();
40
+
41
+ const getNoise = Fn( ( [ uv ] ) => {
42
+
43
+ const uv0 = add( div( uv, 103 ), vec2( div( timeNode, 17 ), div( timeNode, 29 ) ) ).toVar();
44
+ const uv1 = div( uv, 107 ).sub( vec2( div( timeNode, - 19 ), div( timeNode, 31 ) ) ).toVar();
45
+ const uv2 = add( div( uv, vec2( 8907.0, 9803.0 ) ), vec2( div( timeNode, 101 ), div( timeNode, 97 ) ) ).toVar();
46
+ const uv3 = sub( div( uv, vec2( 1091.0, 1027.0 ) ), vec2( div( timeNode, 109 ), div( timeNode, - 113 ) ) ).toVar();
47
+
48
+ const sample0 = this.waterNormals.uv( uv0 );
49
+ const sample1 = this.waterNormals.uv( uv1 );
50
+ const sample2 = this.waterNormals.uv( uv2 );
51
+ const sample3 = this.waterNormals.uv( uv3 );
52
+
53
+ const noise = sample0.add( sample1 ).add( sample2 ).add( sample3 );
54
+
55
+ return noise.mul( 0.5 ).sub( 1 );
56
+
57
+ } );
58
+
59
+ const fragmentNode = Fn( () => {
60
+
61
+ const noise = getNoise( positionWorld.xz.mul( this.size ) );
62
+ const surfaceNormal = normalize( noise.xzy.mul( 1.5, 1.0, 1.5 ) );
63
+
64
+ const diffuseLight = vec3( 0 ).toVar();
65
+ const specularLight = vec3( 0 ).toVar();
66
+
67
+ const worldToEye = cameraPosition.sub( positionWorld );
68
+ const eyeDirection = normalize( worldToEye );
69
+
70
+ const reflection = normalize( reflect( this.sunDirection.negate(), surfaceNormal ) );
71
+ const direction = max( 0.0, dot( eyeDirection, reflection ) );
72
+ specularLight.addAssign( pow( direction, 100 ).mul( this.sunColor ).mul( 2.0 ) );
73
+ diffuseLight.addAssign( max( dot( this.sunDirection, surfaceNormal ), 0.0 ).mul( this.sunColor ).mul( 0.5 ) );
74
+
75
+ const distance = length( worldToEye );
76
+
77
+ const distortion = surfaceNormal.xy.mul( float( 0.001 ).add( float( 1.0 ).div( distance ) ) ).mul( this.distortionScale );
78
+
79
+ const mirrorSampler = reflector();
80
+ mirrorSampler.uvNode = mirrorSampler.uvNode.add( distortion );
81
+ mirrorSampler.resolution = this.resolution;
82
+
83
+ this.add( mirrorSampler.target );
84
+
85
+ const theta = max( dot( eyeDirection, surfaceNormal ), 0.0 );
86
+ const rf0 = float( 0.3 );
87
+ const reflectance = mul( pow( float( 1.0 ).sub( theta ), 5.0 ), float( 1.0 ).sub( rf0 ) ).add( rf0 );
88
+ const scatter = max( 0.0, dot( surfaceNormal, eyeDirection ) ).mul( this.waterColor );
89
+ const albedo = mix( this.sunColor.mul( diffuseLight ).mul( 0.3 ).add( scatter ), mirrorSampler.rgb.mul( specularLight ).add( mirrorSampler.rgb.mul( 0.9 ) ).add( vec3( 0.1 ) ), reflectance );
90
+
91
+ return vec4( albedo, this.alpha );
92
+
93
+ } )();
94
+
95
+ material.fragmentNode = fragmentNode;
96
+
97
+ }
98
+
99
+ }
100
+
101
+ export { WaterMesh };
@@ -61,7 +61,7 @@ async function JoltPhysics() {
61
61
 
62
62
  if ( Jolt === null ) {
63
63
 
64
- const { default: initJolt } = await import( JOLT_PATH );
64
+ const { default: initJolt } = await import( `${JOLT_PATH}` );
65
65
  Jolt = await initJolt();
66
66
 
67
67
  }
@@ -28,6 +28,26 @@ function getShape( geometry ) {
28
28
  const radius = parameters.radius !== undefined ? parameters.radius : 1;
29
29
  return RAPIER.ColliderDesc.ball( radius );
30
30
 
31
+ } else if ( geometry.type === 'BufferGeometry' ) {
32
+
33
+ const vertices = [];
34
+ const vertex = new Vector3();
35
+ const position = geometry.getAttribute( 'position' );
36
+
37
+ for ( let i = 0; i < position.count; i ++ ) {
38
+
39
+ vertex.fromBufferAttribute( position, i );
40
+ vertices.push( vertex.x, vertex.y, vertex.z );
41
+
42
+ }
43
+
44
+ // if the buffer is non-indexed, generate an index buffer
45
+ const indices = geometry.getIndex() === null
46
+ ? Uint32Array.from( Array( parseInt( vertices.length / 3 ) ).keys() )
47
+ : geometry.getIndex().array;
48
+
49
+ return RAPIER.ColliderDesc.trimesh( vertices, indices );
50
+
31
51
  }
32
52
 
33
53
  return null;
@@ -38,7 +58,7 @@ async function RapierPhysics() {
38
58
 
39
59
  if ( RAPIER === null ) {
40
60
 
41
- RAPIER = await import( RAPIER_PATH );
61
+ RAPIER = await import( `${RAPIER_PATH}` );
42
62
  await RAPIER.init();
43
63
 
44
64
  }
@@ -35,7 +35,7 @@ class OutlinePass extends Pass {
35
35
  this.pulsePeriod = 0;
36
36
 
37
37
  this._visibilityCache = new Map();
38
-
38
+ this._selectionCache = new Set();
39
39
 
40
40
  this.resolution = ( resolution !== undefined ) ? new Vector2( resolution.x, resolution.y ) : new Vector2( 256, 256 );
41
41
 
@@ -172,29 +172,18 @@ class OutlinePass extends Pass {
172
172
 
173
173
  }
174
174
 
175
- changeVisibilityOfSelectedObjects( bVisible ) {
175
+ updateSelectionCache() {
176
176
 
177
- const cache = this._visibilityCache;
177
+ const cache = this._selectionCache;
178
178
 
179
179
  function gatherSelectedMeshesCallBack( object ) {
180
180
 
181
- if ( object.isMesh ) {
182
-
183
- if ( bVisible === true ) {
184
-
185
- object.visible = cache.get( object );
186
-
187
- } else {
188
-
189
- cache.set( object, object.visible );
190
- object.visible = bVisible;
191
-
192
- }
193
-
194
- }
181
+ if ( object.isMesh ) cache.add( object );
195
182
 
196
183
  }
197
184
 
185
+ cache.clear();
186
+
198
187
  for ( let i = 0; i < this.selectedObjects.length; i ++ ) {
199
188
 
200
189
  const selectedObject = this.selectedObjects[ i ];
@@ -204,56 +193,49 @@ class OutlinePass extends Pass {
204
193
 
205
194
  }
206
195
 
207
- changeVisibilityOfNonSelectedObjects( bVisible ) {
196
+ changeVisibilityOfSelectedObjects( bVisible ) {
208
197
 
209
198
  const cache = this._visibilityCache;
210
- const selectedMeshes = [];
211
-
212
- function gatherSelectedMeshesCallBack( object ) {
213
-
214
- if ( object.isMesh ) selectedMeshes.push( object );
215
199
 
216
- }
217
-
218
- for ( let i = 0; i < this.selectedObjects.length; i ++ ) {
200
+ for ( const mesh of this._selectionCache ) {
219
201
 
220
- const selectedObject = this.selectedObjects[ i ];
221
- selectedObject.traverse( gatherSelectedMeshesCallBack );
202
+ if ( bVisible === true ) {
222
203
 
223
- }
204
+ mesh.visible = cache.get( mesh );
224
205
 
225
- function VisibilityChangeCallBack( object ) {
206
+ } else {
226
207
 
227
- if ( object.isMesh || object.isSprite ) {
208
+ cache.set( mesh, mesh.visible );
209
+ mesh.visible = bVisible;
228
210
 
229
- // only meshes and sprites are supported by OutlinePass
211
+ }
230
212
 
231
- let bFound = false;
213
+ }
232
214
 
233
- for ( let i = 0; i < selectedMeshes.length; i ++ ) {
215
+ }
234
216
 
235
- const selectedObjectId = selectedMeshes[ i ].id;
217
+ changeVisibilityOfNonSelectedObjects( bVisible ) {
236
218
 
237
- if ( selectedObjectId === object.id ) {
219
+ const visibilityCache = this._visibilityCache;
220
+ const selectionCache = this._selectionCache;
238
221
 
239
- bFound = true;
240
- break;
222
+ function VisibilityChangeCallBack( object ) {
241
223
 
242
- }
224
+ if ( object.isMesh || object.isSprite ) {
243
225
 
244
- }
226
+ // only meshes and sprites are supported by OutlinePass
245
227
 
246
- if ( bFound === false ) {
228
+ if ( ! selectionCache.has( object ) ) {
247
229
 
248
230
  const visibility = object.visible;
249
231
 
250
- if ( bVisible === false || cache.get( object ) === true ) {
232
+ if ( bVisible === false || visibilityCache.get( object ) === true ) {
251
233
 
252
234
  object.visible = bVisible;
253
235
 
254
236
  }
255
237
 
256
- cache.set( object, visibility );
238
+ visibilityCache.set( object, visibility );
257
239
 
258
240
  }
259
241
 
@@ -264,11 +246,11 @@ class OutlinePass extends Pass {
264
246
 
265
247
  if ( bVisible === true ) {
266
248
 
267
- object.visible = cache.get( object ); // restore
249
+ object.visible = visibilityCache.get( object ); // restore
268
250
 
269
251
  } else {
270
252
 
271
- cache.set( object, object.visible );
253
+ visibilityCache.set( object, object.visible );
272
254
  object.visible = bVisible;
273
255
 
274
256
  }
@@ -306,6 +288,8 @@ class OutlinePass extends Pass {
306
288
 
307
289
  renderer.setClearColor( 0xffffff, 1 );
308
290
 
291
+ this.updateSelectionCache();
292
+
309
293
  // Make selected objects invisible
310
294
  this.changeVisibilityOfSelectedObjects( false );
311
295
 
@@ -337,6 +321,7 @@ class OutlinePass extends Pass {
337
321
  this.renderScene.overrideMaterial = null;
338
322
  this.changeVisibilityOfNonSelectedObjects( true );
339
323
  this._visibilityCache.clear();
324
+ this._selectionCache.clear();
340
325
 
341
326
  this.renderScene.background = currentBackground;
342
327
 
@@ -462,7 +447,7 @@ class OutlinePass extends Pass {
462
447
  worldPosition = instanceMatrix * worldPosition;
463
448
 
464
449
  #endif
465
-
450
+
466
451
  worldPosition = modelMatrix * worldPosition;
467
452
 
468
453
  projTexCoord = textureMatrix * worldPosition;
@@ -31,6 +31,8 @@ class SSAARenderPass extends Pass {
31
31
  this.sampleLevel = 4; // specified as n, where the number of samples is 2^n, so sampleLevel = 4, is 2^4 samples, 16.
32
32
  this.unbiased = true;
33
33
 
34
+ this.stencilBuffer = false;
35
+
34
36
  // as we need to clear the buffer in this pass, clearColor must be set to something, defaults to black.
35
37
  this.clearColor = ( clearColor !== undefined ) ? clearColor : 0x000000;
36
38
  this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0;
@@ -79,7 +81,7 @@ class SSAARenderPass extends Pass {
79
81
 
80
82
  if ( ! this.sampleRenderTarget ) {
81
83
 
82
- this.sampleRenderTarget = new WebGLRenderTarget( readBuffer.width, readBuffer.height, { type: HalfFloatType } );
84
+ this.sampleRenderTarget = new WebGLRenderTarget( readBuffer.width, readBuffer.height, { type: HalfFloatType, stencilBuffer: this.stencilBuffer } );
83
85
  this.sampleRenderTarget.texture.name = 'SSAARenderPass.sample';
84
86
 
85
87
  }
@@ -38,8 +38,7 @@ const BleachBypassShader = {
38
38
 
39
39
  vec4 base = texture2D( tDiffuse, vUv );
40
40
 
41
- vec3 lumCoeff = vec3( 0.25, 0.65, 0.1 );
42
- float lum = dot( lumCoeff, base.rgb );
41
+ float lum = luminance( base.rgb );
43
42
  vec3 blend = vec3( lum );
44
43
 
45
44
  float L = min( 1.0, max( 0.0, 10.0 * ( lum - 0.45 ) ) );
@@ -54,7 +54,7 @@ const OutputShader = {
54
54
 
55
55
  #elif defined( CINEON_TONE_MAPPING )
56
56
 
57
- gl_FragColor.rgb = OptimizedCineonToneMapping( gl_FragColor.rgb );
57
+ gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );
58
58
 
59
59
  #elif defined( ACES_FILMIC_TONE_MAPPING )
60
60