super-three 0.167.0 → 0.168.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 (311) hide show
  1. package/build/three.cjs +165 -44
  2. package/build/three.module.js +165 -45
  3. package/build/three.module.min.js +1 -1
  4. package/build/three.webgpu.js +23600 -21931
  5. package/build/three.webgpu.min.js +1 -1
  6. package/examples/jsm/Addons.js +3 -1
  7. package/examples/jsm/animation/AnimationClipCreator.js +1 -1
  8. package/examples/jsm/capabilities/WebGL.js +27 -21
  9. package/examples/jsm/controls/ArcballControls.js +174 -158
  10. package/examples/jsm/controls/DragControls.js +260 -132
  11. package/examples/jsm/controls/FirstPersonControls.js +175 -163
  12. package/examples/jsm/controls/FlyControls.js +194 -188
  13. package/examples/jsm/controls/OrbitControls.js +777 -786
  14. package/examples/jsm/controls/PointerLockControls.js +24 -15
  15. package/examples/jsm/controls/TrackballControls.js +453 -452
  16. package/examples/jsm/effects/AnaglyphEffect.js +6 -13
  17. package/examples/jsm/effects/ParallaxBarrierEffect.js +17 -11
  18. package/examples/jsm/effects/StereoEffect.js +6 -1
  19. package/examples/jsm/environments/RoomEnvironment.js +1 -1
  20. package/examples/jsm/exporters/GLTFExporter.js +6 -1
  21. package/examples/jsm/exporters/USDZExporter.js +29 -8
  22. package/examples/jsm/helpers/LightProbeHelper.js +42 -43
  23. package/examples/jsm/loaders/KTX2Loader.js +19 -7
  24. package/examples/jsm/loaders/MaterialXLoader.js +11 -4
  25. package/examples/jsm/loaders/PCDLoader.js +9 -9
  26. package/examples/jsm/objects/SkyMesh.js +188 -0
  27. package/examples/jsm/objects/Water2Mesh.js +159 -0
  28. package/examples/jsm/objects/WaterMesh.js +102 -0
  29. package/examples/jsm/physics/RapierPhysics.js +20 -0
  30. package/examples/jsm/postprocessing/OutlinePass.js +31 -46
  31. package/examples/jsm/postprocessing/SSAARenderPass.js +3 -1
  32. package/examples/jsm/shaders/BleachBypassShader.js +1 -2
  33. package/examples/jsm/shaders/OutputShader.js +1 -1
  34. package/examples/jsm/transpiler/TSLEncoder.js +8 -8
  35. package/examples/jsm/utils/TextureUtils.js +1 -1
  36. package/package.json +2 -1
  37. package/src/Three.WebGPU.js +6 -0
  38. package/src/Three.js +1 -0
  39. package/src/constants.js +1 -1
  40. package/src/extras/Controls.js +32 -0
  41. package/src/loaders/ObjectLoader.js +3 -3
  42. package/src/{nodes/loaders → loaders/nodes}/NodeLoader.js +4 -4
  43. package/src/{nodes/loaders → loaders/nodes}/NodeMaterialLoader.js +1 -2
  44. package/src/materials/Material.js +4 -7
  45. package/src/{nodes/materials → materials/nodes}/InstancedPointsNodeMaterial.js +33 -24
  46. package/src/{nodes/materials → materials/nodes}/Line2NodeMaterial.js +34 -37
  47. package/src/{nodes/materials → materials/nodes}/LineBasicNodeMaterial.js +3 -4
  48. package/src/{nodes/materials → materials/nodes}/LineDashedNodeMaterial.js +7 -9
  49. package/src/{nodes/materials → materials/nodes}/MeshBasicNodeMaterial.js +11 -11
  50. package/src/{nodes/materials → materials/nodes}/MeshLambertNodeMaterial.js +5 -5
  51. package/src/{nodes/materials → materials/nodes}/MeshMatcapNodeMaterial.js +8 -8
  52. package/src/materials/nodes/MeshNormalNodeMaterial.js +40 -0
  53. package/src/{nodes/materials → materials/nodes}/MeshPhongNodeMaterial.js +9 -8
  54. package/src/{nodes/materials → materials/nodes}/MeshPhysicalNodeMaterial.js +18 -17
  55. package/src/{nodes/materials → materials/nodes}/MeshSSSNodeMaterial.js +6 -6
  56. package/src/{nodes/materials → materials/nodes}/MeshStandardNodeMaterial.js +17 -11
  57. package/src/{nodes/materials → materials/nodes}/MeshToonNodeMaterial.js +4 -4
  58. package/src/{nodes/materials → materials/nodes}/NodeMaterial.js +67 -86
  59. package/src/{nodes/materials/Materials.js → materials/nodes/NodeMaterials.js} +1 -1
  60. package/src/{nodes/materials → materials/nodes}/PointsNodeMaterial.js +3 -4
  61. package/src/{nodes/materials → materials/nodes}/ShadowNodeMaterial.js +4 -4
  62. package/src/{nodes/materials → materials/nodes}/SpriteNodeMaterial.js +11 -11
  63. package/src/{nodes/materials → materials/nodes}/VolumeNodeMaterial.js +14 -16
  64. package/src/nodes/Nodes.js +103 -159
  65. package/src/nodes/TSL.js +176 -0
  66. package/src/nodes/accessors/AccessorsUtils.js +8 -8
  67. package/src/nodes/accessors/BatchNode.js +48 -20
  68. package/src/nodes/accessors/{BitangentNode.js → Bitangent.js} +9 -9
  69. package/src/nodes/accessors/BufferAttributeNode.js +5 -5
  70. package/src/nodes/accessors/BufferNode.js +4 -4
  71. package/src/nodes/accessors/{CameraNode.js → Camera.js} +10 -10
  72. package/src/nodes/accessors/ClippingNode.js +16 -14
  73. package/src/nodes/accessors/CubeTextureNode.js +5 -7
  74. package/src/nodes/accessors/InstanceNode.js +17 -13
  75. package/src/nodes/accessors/InstancedPointsMaterialNode.js +4 -4
  76. package/src/nodes/accessors/MaterialNode.js +52 -55
  77. package/src/nodes/accessors/MaterialProperties.js +3 -0
  78. package/src/nodes/accessors/MaterialReferenceNode.js +6 -4
  79. package/src/nodes/accessors/ModelNode.js +11 -11
  80. package/src/nodes/accessors/ModelViewProjectionNode.js +6 -7
  81. package/src/nodes/accessors/MorphNode.js +12 -12
  82. package/src/nodes/accessors/Normal.js +62 -0
  83. package/src/nodes/accessors/Object3DNode.js +10 -10
  84. package/src/nodes/accessors/PointUVNode.js +4 -4
  85. package/src/nodes/accessors/Position.js +10 -0
  86. package/src/nodes/accessors/ReferenceBaseNode.js +143 -0
  87. package/src/nodes/accessors/ReferenceNode.js +13 -7
  88. package/src/nodes/accessors/ReflectVector.js +10 -0
  89. package/src/nodes/accessors/RendererReferenceNode.js +6 -6
  90. package/src/nodes/accessors/SceneNode.js +5 -6
  91. package/src/nodes/accessors/SkinningNode.js +84 -21
  92. package/src/nodes/accessors/StorageBufferNode.js +4 -5
  93. package/src/nodes/accessors/StorageTextureNode.js +5 -5
  94. package/src/nodes/accessors/Tangent.js +22 -0
  95. package/src/nodes/accessors/Texture3DNode.js +11 -11
  96. package/src/nodes/accessors/{TextureBicubicNode.js → TextureBicubic.js} +3 -32
  97. package/src/nodes/accessors/TextureNode.js +16 -21
  98. package/src/nodes/accessors/TextureSizeNode.js +4 -6
  99. package/src/nodes/accessors/{UniformsNode.js → UniformArrayNode.js} +17 -8
  100. package/src/nodes/accessors/UserDataNode.js +4 -4
  101. package/src/nodes/accessors/VelocityNode.js +83 -0
  102. package/src/nodes/accessors/VertexColorNode.js +4 -4
  103. package/src/nodes/code/CodeNode.js +5 -5
  104. package/src/nodes/code/ExpressionNode.js +4 -4
  105. package/src/nodes/code/FunctionCallNode.js +5 -5
  106. package/src/nodes/code/FunctionNode.js +5 -23
  107. package/src/nodes/code/ScriptableNode.js +4 -6
  108. package/src/nodes/code/ScriptableValueNode.js +4 -6
  109. package/src/nodes/core/AssignNode.js +5 -5
  110. package/src/nodes/core/AttributeNode.js +7 -20
  111. package/src/nodes/core/BypassNode.js +5 -5
  112. package/src/nodes/core/CacheNode.js +5 -5
  113. package/src/nodes/core/ConstNode.js +2 -2
  114. package/src/nodes/core/ContextNode.js +17 -11
  115. package/src/nodes/core/IndexNode.js +12 -7
  116. package/src/nodes/core/InputNode.js +2 -2
  117. package/src/nodes/core/MRTNode.js +12 -6
  118. package/src/nodes/core/Node.js +39 -19
  119. package/src/nodes/core/NodeBuilder.js +46 -33
  120. package/src/nodes/core/NodeUtils.js +1 -0
  121. package/src/nodes/core/OutputStructNode.js +4 -4
  122. package/src/nodes/core/ParameterNode.js +4 -4
  123. package/src/nodes/core/PropertyNode.js +32 -32
  124. package/src/nodes/core/StackNode.js +26 -10
  125. package/src/nodes/core/StructTypeNode.js +2 -2
  126. package/src/nodes/core/TempNode.js +2 -2
  127. package/src/nodes/core/UniformGroupNode.js +8 -9
  128. package/src/nodes/core/UniformNode.js +4 -4
  129. package/src/nodes/core/VarNode.js +6 -6
  130. package/src/nodes/core/VaryingNode.js +5 -5
  131. package/src/nodes/display/AfterImageNode.js +9 -9
  132. package/src/nodes/display/AnaglyphPassNode.js +61 -0
  133. package/src/nodes/display/AnamorphicNode.js +11 -11
  134. package/src/nodes/display/BleachBypass.js +26 -0
  135. package/src/nodes/display/BlendMode.js +54 -0
  136. package/src/nodes/display/BloomNode.js +21 -19
  137. package/src/nodes/display/BumpMapNode.js +7 -12
  138. package/src/nodes/display/ColorAdjustment.js +46 -0
  139. package/src/nodes/display/ColorSpaceFunctions.js +38 -0
  140. package/src/nodes/display/ColorSpaceNode.js +40 -63
  141. package/src/nodes/display/DenoiseNode.js +20 -17
  142. package/src/nodes/display/DepthOfFieldNode.js +8 -6
  143. package/src/nodes/display/DotScreenNode.js +10 -22
  144. package/src/nodes/display/FXAANode.js +17 -15
  145. package/src/nodes/display/FilmNode.js +7 -6
  146. package/src/nodes/display/FrontFacingNode.js +5 -5
  147. package/src/nodes/display/GTAONode.js +19 -15
  148. package/src/nodes/display/GaussianBlurNode.js +11 -8
  149. package/src/nodes/display/Lut3DNode.js +6 -5
  150. package/src/nodes/display/MotionBlur.js +25 -0
  151. package/src/nodes/display/NormalMapNode.js +8 -10
  152. package/src/nodes/display/ParallaxBarrierPassNode.js +55 -0
  153. package/src/nodes/display/PassNode.js +84 -8
  154. package/src/nodes/display/PixelationPassNode.js +12 -7
  155. package/src/nodes/display/PosterizeNode.js +4 -6
  156. package/src/nodes/display/RGBShiftNode.js +8 -7
  157. package/src/nodes/display/RenderOutputNode.js +9 -9
  158. package/src/nodes/display/SSAAPassNode.js +284 -0
  159. package/src/nodes/display/Sepia.js +17 -0
  160. package/src/nodes/display/SobelOperatorNode.js +9 -7
  161. package/src/nodes/display/StereoCompositePassNode.js +107 -0
  162. package/src/nodes/display/StereoPassNode.js +80 -0
  163. package/src/nodes/display/ToneMappingFunctions.js +190 -0
  164. package/src/nodes/display/ToneMappingNode.js +12 -173
  165. package/src/nodes/display/TransitionNode.js +9 -8
  166. package/src/nodes/display/ViewportDepthNode.js +30 -29
  167. package/src/nodes/display/ViewportDepthTextureNode.js +6 -8
  168. package/src/nodes/display/ViewportNode.js +26 -25
  169. package/src/nodes/display/ViewportSharedTextureNode.js +6 -8
  170. package/src/nodes/display/ViewportTextureNode.js +7 -10
  171. package/src/nodes/fog/FogExp2Node.js +4 -6
  172. package/src/nodes/fog/FogNode.js +5 -7
  173. package/src/nodes/fog/FogRangeNode.js +4 -6
  174. package/src/nodes/functions/BSDF/BRDF_GGX.js +4 -4
  175. package/src/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
  176. package/src/nodes/functions/BSDF/BRDF_Sheen.js +6 -6
  177. package/src/nodes/functions/BSDF/DFGApprox.js +2 -2
  178. package/src/nodes/functions/BSDF/D_GGX.js +2 -2
  179. package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +3 -3
  180. package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
  181. package/src/nodes/functions/BSDF/F_Schlick.js +2 -2
  182. package/src/nodes/functions/BSDF/LTC.js +6 -6
  183. package/src/nodes/functions/BSDF/Schlick_to_F0.js +2 -2
  184. package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
  185. package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
  186. package/src/nodes/functions/BasicLightingModel.js +1 -1
  187. package/src/nodes/functions/PhongLightingModel.js +5 -5
  188. package/src/nodes/functions/PhysicalLightingModel.js +32 -31
  189. package/src/nodes/functions/ShadowMaskModel.js +1 -1
  190. package/src/nodes/functions/ToonLightingModel.js +3 -3
  191. package/src/nodes/functions/material/getGeometryRoughness.js +4 -4
  192. package/src/nodes/functions/material/getRoughness.js +2 -2
  193. package/src/nodes/geometry/RangeNode.js +4 -4
  194. package/src/nodes/gpgpu/ComputeNode.js +5 -5
  195. package/src/nodes/lighting/AONode.js +2 -2
  196. package/src/nodes/lighting/AmbientLightNode.js +2 -7
  197. package/src/nodes/lighting/AnalyticLightNode.js +34 -13
  198. package/src/nodes/lighting/BasicEnvironmentNode.js +4 -3
  199. package/src/nodes/lighting/BasicLightMapNode.js +3 -3
  200. package/src/nodes/lighting/DirectionalLightNode.js +2 -7
  201. package/src/nodes/lighting/EnvironmentNode.js +20 -19
  202. package/src/nodes/lighting/HemisphereLightNode.js +3 -7
  203. package/src/nodes/lighting/IESSpotLightNode.js +3 -8
  204. package/src/nodes/lighting/IrradianceNode.js +2 -2
  205. package/src/nodes/lighting/LightNode.js +5 -5
  206. package/src/nodes/lighting/LightProbeNode.js +76 -0
  207. package/src/nodes/lighting/LightUtils.js +3 -3
  208. package/src/nodes/lighting/LightingContextNode.js +15 -17
  209. package/src/nodes/lighting/LightingNode.js +2 -2
  210. package/src/nodes/lighting/LightsNode.js +94 -76
  211. package/src/nodes/lighting/PointLightNode.js +3 -8
  212. package/src/nodes/lighting/RectAreaLightNode.js +2 -6
  213. package/src/nodes/lighting/SpotLightNode.js +3 -8
  214. package/src/nodes/materialx/MaterialXNodes.js +2 -2
  215. package/src/nodes/materialx/lib/mx_hsv.js +36 -31
  216. package/src/nodes/materialx/lib/mx_noise.js +96 -96
  217. package/src/nodes/materialx/lib/mx_transform_color.js +2 -2
  218. package/src/nodes/math/{CondNode.js → ConditionalNode.js} +18 -7
  219. package/src/nodes/math/Hash.js +13 -0
  220. package/src/nodes/math/MathNode.js +124 -124
  221. package/src/nodes/math/MathUtils.js +0 -7
  222. package/src/nodes/math/OperatorNode.js +94 -52
  223. package/src/nodes/math/TriNoise3D.js +19 -29
  224. package/src/nodes/pmrem/PMREMNode.js +58 -15
  225. package/src/nodes/pmrem/PMREMUtils.js +46 -46
  226. package/src/nodes/procedural/Checker.js +14 -0
  227. package/src/nodes/tsl/TSLBase.js +30 -0
  228. package/src/nodes/{shadernode/ShaderNode.js → tsl/TSLCore.js} +105 -97
  229. package/src/nodes/utils/ArrayElementNode.js +2 -2
  230. package/src/nodes/utils/ConvertNode.js +2 -2
  231. package/src/nodes/utils/CubeMapNode.js +157 -0
  232. package/src/nodes/utils/Discard.js +8 -0
  233. package/src/nodes/utils/EquirectUVNode.js +5 -5
  234. package/src/nodes/utils/FlipNode.js +65 -0
  235. package/src/nodes/utils/FunctionOverloadingNode.js +5 -5
  236. package/src/nodes/utils/JoinNode.js +2 -2
  237. package/src/nodes/utils/LoopNode.js +12 -6
  238. package/src/nodes/utils/MatcapUVNode.js +6 -6
  239. package/src/nodes/utils/MaxMipLevelNode.js +4 -4
  240. package/src/nodes/utils/OscNode.js +7 -7
  241. package/src/nodes/utils/Packing.js +4 -0
  242. package/src/nodes/utils/RTTNode.js +8 -8
  243. package/src/nodes/utils/ReflectorNode.js +8 -3
  244. package/src/nodes/utils/RemapNode.js +7 -7
  245. package/src/nodes/utils/RotateNode.js +4 -12
  246. package/src/nodes/utils/SetNode.js +2 -2
  247. package/src/nodes/utils/SplitNode.js +2 -2
  248. package/src/nodes/utils/SpriteSheetUVNode.js +5 -5
  249. package/src/nodes/utils/SpriteUtils.js +47 -0
  250. package/src/nodes/utils/StorageArrayElementNode.js +4 -6
  251. package/src/nodes/utils/TimerNode.js +5 -5
  252. package/src/nodes/utils/TriplanarTexturesNode.js +7 -9
  253. package/src/nodes/utils/UVUtils.js +19 -0
  254. package/src/nodes/utils/ViewportUtils.js +14 -0
  255. package/src/objects/BatchedMesh.js +2 -3
  256. package/src/renderers/WebGLRenderer.js +24 -0
  257. package/src/renderers/common/Backend.js +2 -2
  258. package/src/renderers/common/Background.js +3 -1
  259. package/src/renderers/common/BindGroup.js +3 -1
  260. package/src/renderers/common/Bindings.js +13 -15
  261. package/src/renderers/common/ClippingContext.js +14 -5
  262. package/src/renderers/common/CubeRenderTarget.js +9 -3
  263. package/src/renderers/common/PostProcessing.js +4 -1
  264. package/src/renderers/common/QuadMesh.js +2 -0
  265. package/src/renderers/common/RenderContext.js +24 -0
  266. package/src/renderers/common/RenderList.js +1 -1
  267. package/src/renderers/common/RenderObject.js +2 -2
  268. package/src/renderers/common/Renderer.js +75 -49
  269. package/src/renderers/common/SampledTexture.js +12 -3
  270. package/src/renderers/common/StandardRenderer.js +18 -0
  271. package/src/renderers/common/Textures.js +8 -12
  272. package/src/renderers/common/extras/PMREMGenerator.js +12 -13
  273. package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
  274. package/src/renderers/common/nodes/NodeLibrary.js +118 -0
  275. package/src/renderers/common/nodes/NodeSampledTexture.js +2 -2
  276. package/src/renderers/common/nodes/Nodes.js +36 -9
  277. package/src/renderers/common/nodes/StandardNodeLibrary.js +105 -0
  278. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +2 -2
  279. package/src/renderers/webgl/WebGLProgram.js +1 -1
  280. package/src/renderers/webgl/WebGLProperties.js +7 -0
  281. package/src/renderers/webgl/WebGLTextures.js +61 -4
  282. package/src/renderers/webgl-fallback/WebGLBackend.js +88 -68
  283. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +57 -9
  284. package/src/renderers/webgl-fallback/utils/WebGLState.js +21 -0
  285. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +28 -21
  286. package/src/renderers/webgpu/WebGPUBackend.js +86 -68
  287. package/src/renderers/webgpu/WebGPURenderer.js +8 -8
  288. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +99 -63
  289. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +45 -21
  290. package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -1
  291. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +6 -15
  292. package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
  293. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +36 -21
  294. package/src/renderers/webgpu/utils/WebGPUUtils.js +18 -1
  295. package/src/renderers/webxr/WebXRManager.js +32 -25
  296. package/examples/jsm/loaders/LogLuvLoader.js +0 -606
  297. package/src/nodes/accessors/NormalNode.js +0 -14
  298. package/src/nodes/accessors/PositionNode.js +0 -10
  299. package/src/nodes/accessors/ReflectVectorNode.js +0 -10
  300. package/src/nodes/accessors/TangentNode.js +0 -23
  301. package/src/nodes/core/NodeKeywords.js +0 -80
  302. package/src/nodes/display/BlendModeNode.js +0 -128
  303. package/src/nodes/display/ColorAdjustmentNode.js +0 -104
  304. package/src/nodes/materials/MeshNormalNodeMaterial.js +0 -40
  305. package/src/nodes/math/HashNode.js +0 -34
  306. package/src/nodes/procedural/CheckerNode.js +0 -42
  307. package/src/nodes/utils/DiscardNode.js +0 -28
  308. package/src/nodes/utils/PackingNode.js +0 -55
  309. package/src/nodes/utils/RotateUVNode.js +0 -35
  310. /package/src/{nodes/loaders → loaders/nodes}/NodeObjectLoader.js +0 -0
  311. /package/src/nodes/accessors/{UVNode.js → UV.js} +0 -0
@@ -1,12 +1,13 @@
1
+ import { registerNode } from '../core/Node.js';
1
2
  import TempNode from '../core/TempNode.js';
2
- import { addNodeClass } from '../core/Node.js';
3
3
  import { texture } from '../accessors/TextureNode.js';
4
4
  import { textureCubeUV } from './PMREMUtils.js';
5
5
  import { uniform } from '../core/UniformNode.js';
6
6
  import { NodeUpdateType } from '../core/constants.js';
7
- import { nodeProxy, vec3 } from '../shadernode/ShaderNode.js';
7
+ import { nodeProxy, vec3 } from '../tsl/TSLBase.js';
8
8
 
9
9
  import { WebGLCoordinateSystem } from '../../constants.js';
10
+ import { Texture } from '../../textures/Texture.js';
10
11
 
11
12
  let _generator = null;
12
13
 
@@ -32,25 +33,32 @@ function _getPMREMFromTexture( texture ) {
32
33
 
33
34
  if ( pmremVersion !== texture.pmremVersion ) {
34
35
 
36
+ const image = texture.image;
37
+
35
38
  if ( texture.isCubeTexture ) {
36
39
 
37
- if ( texture.source.data.some( ( texture ) => texture === undefined ) ) {
40
+ if ( isCubeMapReady( image ) ) {
41
+
42
+ cacheTexture = _generator.fromCubemap( texture, cacheTexture );
43
+
44
+ } else {
38
45
 
39
- throw new Error( 'PMREMNode: Undefined texture in CubeTexture. Use onLoad callback or async loader' );
46
+ return null;
40
47
 
41
48
  }
42
49
 
43
- cacheTexture = _generator.fromCubemap( texture, cacheTexture );
44
50
 
45
51
  } else {
46
52
 
47
- if ( texture.image === undefined ) {
53
+ if ( isEquirectangularMapReady( image ) ) {
48
54
 
49
- throw new Error( 'PMREMNode: Undefined image in Texture. Use onLoad callback or async loader' );
55
+ cacheTexture = _generator.fromEquirectangular( texture, cacheTexture );
50
56
 
51
- }
57
+ } else {
52
58
 
53
- cacheTexture = _generator.fromEquirectangular( texture, cacheTexture );
59
+ return null;
60
+
61
+ }
54
62
 
55
63
  }
56
64
 
@@ -77,7 +85,12 @@ class PMREMNode extends TempNode {
77
85
  this.levelNode = levelNode;
78
86
 
79
87
  this._generator = null;
80
- this._texture = texture( null );
88
+
89
+ const defaultTexture = new Texture();
90
+ defaultTexture.isRenderTargetTexture = true;
91
+
92
+ this._texture = texture( defaultTexture );
93
+
81
94
  this._width = uniform( 0 );
82
95
  this._height = uniform( 0 );
83
96
  this._maxMip = uniform( 0 );
@@ -129,9 +142,13 @@ class PMREMNode extends TempNode {
129
142
 
130
143
  }
131
144
 
132
- this._pmrem = pmrem;
145
+ if ( pmrem !== null ) {
146
+
147
+ this._pmrem = pmrem;
133
148
 
134
- this.updateFromTexture( pmrem );
149
+ this.updateFromTexture( pmrem );
150
+
151
+ }
135
152
 
136
153
  }
137
154
 
@@ -187,8 +204,34 @@ class PMREMNode extends TempNode {
187
204
 
188
205
  }
189
206
 
190
- export const pmremTexture = nodeProxy( PMREMNode );
207
+ export default PMREMNode;
191
208
 
192
- addNodeClass( 'PMREMNode', PMREMNode );
209
+ PMREMNode.type = /*@__PURE__*/ registerNode( 'PMREM', PMREMNode );
193
210
 
194
- export default PMREMNode;
211
+ function isCubeMapReady( image ) {
212
+
213
+ if ( image === null || image === undefined ) return false;
214
+
215
+ let count = 0;
216
+ const length = 6;
217
+
218
+ for ( let i = 0; i < length; i ++ ) {
219
+
220
+ if ( image[ i ] !== undefined ) count ++;
221
+
222
+ }
223
+
224
+ return count === length;
225
+
226
+
227
+ }
228
+
229
+ function isEquirectangularMapReady( image ) {
230
+
231
+ if ( image === null || image === undefined ) return false;
232
+
233
+ return image.height > 0;
234
+
235
+ }
236
+
237
+ export const pmremTexture = /*@__PURE__*/ nodeProxy( PMREMNode );
@@ -1,30 +1,30 @@
1
- import { tslFn, int, float, vec2, vec3, vec4, If } from '../shadernode/ShaderNode.js';
1
+ import { Fn, int, float, vec2, vec3, vec4, If } from '../tsl/TSLBase.js';
2
2
  import { cos, sin, abs, max, exp2, log2, clamp, fract, mix, floor, normalize, cross, all } from '../math/MathNode.js';
3
3
  import { mul } from '../math/OperatorNode.js';
4
- import { cond } from '../math/CondNode.js';
5
- import { loop, Break } from '../utils/LoopNode.js';
4
+ import { select } from '../math/ConditionalNode.js';
5
+ import { Loop, Break } from '../utils/LoopNode.js';
6
6
 
7
7
  // These defines must match with PMREMGenerator
8
8
 
9
- const cubeUV_r0 = float( 1.0 );
10
- const cubeUV_m0 = float( - 2.0 );
11
- const cubeUV_r1 = float( 0.8 );
12
- const cubeUV_m1 = float( - 1.0 );
13
- const cubeUV_r4 = float( 0.4 );
14
- const cubeUV_m4 = float( 2.0 );
15
- const cubeUV_r5 = float( 0.305 );
16
- const cubeUV_m5 = float( 3.0 );
17
- const cubeUV_r6 = float( 0.21 );
18
- const cubeUV_m6 = float( 4.0 );
9
+ const cubeUV_r0 = /*@__PURE__*/ float( 1.0 );
10
+ const cubeUV_m0 = /*@__PURE__*/ float( - 2.0 );
11
+ const cubeUV_r1 = /*@__PURE__*/ float( 0.8 );
12
+ const cubeUV_m1 = /*@__PURE__*/ float( - 1.0 );
13
+ const cubeUV_r4 = /*@__PURE__*/ float( 0.4 );
14
+ const cubeUV_m4 = /*@__PURE__*/ float( 2.0 );
15
+ const cubeUV_r5 = /*@__PURE__*/ float( 0.305 );
16
+ const cubeUV_m5 = /*@__PURE__*/ float( 3.0 );
17
+ const cubeUV_r6 = /*@__PURE__*/ float( 0.21 );
18
+ const cubeUV_m6 = /*@__PURE__*/ float( 4.0 );
19
19
 
20
- const cubeUV_minMipLevel = float( 4.0 );
21
- const cubeUV_minTileSize = float( 16.0 );
20
+ const cubeUV_minMipLevel = /*@__PURE__*/ float( 4.0 );
21
+ const cubeUV_minTileSize = /*@__PURE__*/ float( 16.0 );
22
22
 
23
23
  // These shader functions convert between the UV coordinates of a single face of
24
24
  // a cubemap, the 0-5 integer index of a cube face, and the direction vector for
25
25
  // sampling a textureCube (not generally normalized ).
26
26
 
27
- const getFace = tslFn( ( [ direction ] ) => {
27
+ const getFace = /*@__PURE__*/ Fn( ( [ direction ] ) => {
28
28
 
29
29
  const absDirection = vec3( abs( direction ) ).toVar();
30
30
  const face = float( - 1.0 ).toVar();
@@ -33,23 +33,23 @@ const getFace = tslFn( ( [ direction ] ) => {
33
33
 
34
34
  If( absDirection.x.greaterThan( absDirection.y ), () => {
35
35
 
36
- face.assign( cond( direction.x.greaterThan( 0.0 ), 0.0, 3.0 ) );
36
+ face.assign( select( direction.x.greaterThan( 0.0 ), 0.0, 3.0 ) );
37
37
 
38
- } ).else( () => {
38
+ } ).Else( () => {
39
39
 
40
- face.assign( cond( direction.y.greaterThan( 0.0 ), 1.0, 4.0 ) );
40
+ face.assign( select( direction.y.greaterThan( 0.0 ), 1.0, 4.0 ) );
41
41
 
42
42
  } );
43
43
 
44
- } ).else( () => {
44
+ } ).Else( () => {
45
45
 
46
46
  If( absDirection.z.greaterThan( absDirection.y ), () => {
47
47
 
48
- face.assign( cond( direction.z.greaterThan( 0.0 ), 2.0, 5.0 ) );
48
+ face.assign( select( direction.z.greaterThan( 0.0 ), 2.0, 5.0 ) );
49
49
 
50
- } ).else( () => {
50
+ } ).Else( () => {
51
51
 
52
- face.assign( cond( direction.y.greaterThan( 0.0 ), 1.0, 4.0 ) );
52
+ face.assign( select( direction.y.greaterThan( 0.0 ), 1.0, 4.0 ) );
53
53
 
54
54
  } );
55
55
 
@@ -66,7 +66,7 @@ const getFace = tslFn( ( [ direction ] ) => {
66
66
  } );
67
67
 
68
68
  // RH coordinate system; PMREM face-indexing convention
69
- const getUV = tslFn( ( [ direction, face ] ) => {
69
+ const getUV = /*@__PURE__*/ Fn( ( [ direction, face ] ) => {
70
70
 
71
71
  const uv = vec2().toVar();
72
72
 
@@ -74,23 +74,23 @@ const getUV = tslFn( ( [ direction, face ] ) => {
74
74
 
75
75
  uv.assign( vec2( direction.z, direction.y ).div( abs( direction.x ) ) ); // pos x
76
76
 
77
- } ).elseif( face.equal( 1.0 ), () => {
77
+ } ).ElseIf( face.equal( 1.0 ), () => {
78
78
 
79
79
  uv.assign( vec2( direction.x.negate(), direction.z.negate() ).div( abs( direction.y ) ) ); // pos y
80
80
 
81
- } ).elseif( face.equal( 2.0 ), () => {
81
+ } ).ElseIf( face.equal( 2.0 ), () => {
82
82
 
83
83
  uv.assign( vec2( direction.x.negate(), direction.y ).div( abs( direction.z ) ) ); // pos z
84
84
 
85
- } ).elseif( face.equal( 3.0 ), () => {
85
+ } ).ElseIf( face.equal( 3.0 ), () => {
86
86
 
87
87
  uv.assign( vec2( direction.z.negate(), direction.y ).div( abs( direction.x ) ) ); // neg x
88
88
 
89
- } ).elseif( face.equal( 4.0 ), () => {
89
+ } ).ElseIf( face.equal( 4.0 ), () => {
90
90
 
91
91
  uv.assign( vec2( direction.x.negate(), direction.z ).div( abs( direction.y ) ) ); // neg y
92
92
 
93
- } ).else( () => {
93
+ } ).Else( () => {
94
94
 
95
95
  uv.assign( vec2( direction.x, direction.y ).div( abs( direction.z ) ) ); // neg z
96
96
 
@@ -107,7 +107,7 @@ const getUV = tslFn( ( [ direction, face ] ) => {
107
107
  ]
108
108
  } );
109
109
 
110
- const roughnessToMip = tslFn( ( [ roughness ] ) => {
110
+ const roughnessToMip = /*@__PURE__*/ Fn( ( [ roughness ] ) => {
111
111
 
112
112
  const mip = float( 0.0 ).toVar();
113
113
 
@@ -115,19 +115,19 @@ const roughnessToMip = tslFn( ( [ roughness ] ) => {
115
115
 
116
116
  mip.assign( cubeUV_r0.sub( roughness ).mul( cubeUV_m1.sub( cubeUV_m0 ) ).div( cubeUV_r0.sub( cubeUV_r1 ) ).add( cubeUV_m0 ) );
117
117
 
118
- } ).elseif( roughness.greaterThanEqual( cubeUV_r4 ), () => {
118
+ } ).ElseIf( roughness.greaterThanEqual( cubeUV_r4 ), () => {
119
119
 
120
120
  mip.assign( cubeUV_r1.sub( roughness ).mul( cubeUV_m4.sub( cubeUV_m1 ) ).div( cubeUV_r1.sub( cubeUV_r4 ) ).add( cubeUV_m1 ) );
121
121
 
122
- } ).elseif( roughness.greaterThanEqual( cubeUV_r5 ), () => {
122
+ } ).ElseIf( roughness.greaterThanEqual( cubeUV_r5 ), () => {
123
123
 
124
124
  mip.assign( cubeUV_r4.sub( roughness ).mul( cubeUV_m5.sub( cubeUV_m4 ) ).div( cubeUV_r4.sub( cubeUV_r5 ) ).add( cubeUV_m4 ) );
125
125
 
126
- } ).elseif( roughness.greaterThanEqual( cubeUV_r6 ), () => {
126
+ } ).ElseIf( roughness.greaterThanEqual( cubeUV_r6 ), () => {
127
127
 
128
128
  mip.assign( cubeUV_r5.sub( roughness ).mul( cubeUV_m6.sub( cubeUV_m5 ) ).div( cubeUV_r5.sub( cubeUV_r6 ) ).add( cubeUV_m5 ) );
129
129
 
130
- } ).else( () => {
130
+ } ).Else( () => {
131
131
 
132
132
  mip.assign( float( - 2.0 ).mul( log2( mul( 1.16, roughness ) ) ) ); // 1.16 = 1.79^0.25
133
133
 
@@ -144,7 +144,7 @@ const roughnessToMip = tslFn( ( [ roughness ] ) => {
144
144
  } );
145
145
 
146
146
  // RH coordinate system; PMREM face-indexing convention
147
- export const getDirection = tslFn( ( [ uv_immutable, face ] ) => {
147
+ export const getDirection = /*@__PURE__*/ Fn( ( [ uv_immutable, face ] ) => {
148
148
 
149
149
  const uv = uv_immutable.toVar();
150
150
  uv.assign( mul( 2.0, uv ).sub( 1.0 ) );
@@ -154,26 +154,26 @@ export const getDirection = tslFn( ( [ uv_immutable, face ] ) => {
154
154
 
155
155
  direction.assign( direction.zyx ); // ( 1, v, u ) pos x
156
156
 
157
- } ).elseif( face.equal( 1.0 ), () => {
157
+ } ).ElseIf( face.equal( 1.0 ), () => {
158
158
 
159
159
  direction.assign( direction.xzy );
160
160
  direction.xz.mulAssign( - 1.0 ); // ( -u, 1, -v ) pos y
161
161
 
162
- } ).elseif( face.equal( 2.0 ), () => {
162
+ } ).ElseIf( face.equal( 2.0 ), () => {
163
163
 
164
164
  direction.x.mulAssign( - 1.0 ); // ( -u, v, 1 ) pos z
165
165
 
166
- } ).elseif( face.equal( 3.0 ), () => {
166
+ } ).ElseIf( face.equal( 3.0 ), () => {
167
167
 
168
168
  direction.assign( direction.zyx );
169
169
  direction.xz.mulAssign( - 1.0 ); // ( -1, v, -u ) neg x
170
170
 
171
- } ).elseif( face.equal( 4.0 ), () => {
171
+ } ).ElseIf( face.equal( 4.0 ), () => {
172
172
 
173
173
  direction.assign( direction.xzy );
174
174
  direction.xy.mulAssign( - 1.0 ); // ( -u, -1, v ) neg y
175
175
 
176
- } ).elseif( face.equal( 5.0 ), () => {
176
+ } ).ElseIf( face.equal( 5.0 ), () => {
177
177
 
178
178
  direction.z.mulAssign( - 1.0 ); // ( u, v, -1 ) neg zS
179
179
 
@@ -192,7 +192,7 @@ export const getDirection = tslFn( ( [ uv_immutable, face ] ) => {
192
192
 
193
193
  //
194
194
 
195
- export const textureCubeUV = tslFn( ( [ envMap, sampleDir_immutable, roughness_immutable, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP ] ) => {
195
+ export const textureCubeUV = /*@__PURE__*/ Fn( ( [ envMap, sampleDir_immutable, roughness_immutable, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP ] ) => {
196
196
 
197
197
  const roughness = float( roughness_immutable );
198
198
  const sampleDir = vec3( sampleDir_immutable );
@@ -214,7 +214,7 @@ export const textureCubeUV = tslFn( ( [ envMap, sampleDir_immutable, roughness_i
214
214
 
215
215
  } );
216
216
 
217
- const bilinearCubeUV = tslFn( ( [ envMap, direction_immutable, mipInt_immutable, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP ] ) => {
217
+ const bilinearCubeUV = /*@__PURE__*/ Fn( ( [ envMap, direction_immutable, mipInt_immutable, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP ] ) => {
218
218
 
219
219
  const mipInt = float( mipInt_immutable ).toVar();
220
220
  const direction = vec3( direction_immutable );
@@ -241,7 +241,7 @@ const bilinearCubeUV = tslFn( ( [ envMap, direction_immutable, mipInt_immutable,
241
241
 
242
242
  } );
243
243
 
244
- const getSample = tslFn( ( { envMap, mipInt, outputDirection, theta, axis, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP } ) => {
244
+ const getSample = /*@__PURE__*/ Fn( ( { envMap, mipInt, outputDirection, theta, axis, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP } ) => {
245
245
 
246
246
  const cosTheta = cos( theta );
247
247
 
@@ -254,9 +254,9 @@ const getSample = tslFn( ( { envMap, mipInt, outputDirection, theta, axis, CUBEU
254
254
 
255
255
  } );
256
256
 
257
- export const blur = tslFn( ( { n, latitudinal, poleAxis, outputDirection, weights, samples, dTheta, mipInt, envMap, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP } ) => {
257
+ export const blur = /*@__PURE__*/ Fn( ( { n, latitudinal, poleAxis, outputDirection, weights, samples, dTheta, mipInt, envMap, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP } ) => {
258
258
 
259
- const axis = vec3( cond( latitudinal, poleAxis, cross( poleAxis, outputDirection ) ) ).toVar();
259
+ const axis = vec3( select( latitudinal, poleAxis, cross( poleAxis, outputDirection ) ) ).toVar();
260
260
 
261
261
  If( all( axis.equals( vec3( 0.0 ) ) ), () => {
262
262
 
@@ -269,7 +269,7 @@ export const blur = tslFn( ( { n, latitudinal, poleAxis, outputDirection, weight
269
269
  const gl_FragColor = vec3().toVar();
270
270
  gl_FragColor.addAssign( weights.element( int( 0 ) ).mul( getSample( { theta: 0.0, axis, outputDirection, mipInt, envMap, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP } ) ) );
271
271
 
272
- loop( { start: int( 1 ), end: n }, ( { i } ) => {
272
+ Loop( { start: int( 1 ), end: n }, ( { i } ) => {
273
273
 
274
274
  If( i.greaterThanEqual( samples ), () => {
275
275
 
@@ -0,0 +1,14 @@
1
+ import { uv } from '../accessors/UV.js';
2
+ import { Fn } from '../tsl/TSLBase.js';
3
+
4
+ export const checker = /*@__PURE__*/ Fn( ( [ coord = uv() ] ) => {
5
+
6
+ const uv = coord.mul( 2.0 );
7
+
8
+ const cx = uv.x.floor();
9
+ const cy = uv.y.floor();
10
+ const result = cx.add( cy ).mod( 2.0 );
11
+
12
+ return result.sign();
13
+
14
+ } );
@@ -0,0 +1,30 @@
1
+ // Non-PURE exports list, side-effects are required here.
2
+ // TSL Base Syntax
3
+
4
+ export * from './TSLCore.js'; // float(), vec2(), vec3(), vec4(), mat3(), mat4(), Fn(), If(), element(), nodeObject(), nodeProxy(), ...
5
+ export * from '../core/UniformNode.js'; // uniform()
6
+ export * from '../core/PropertyNode.js'; // property() <-> TODO: Seperate Material Properties in other file
7
+ export * from '../core/AssignNode.js'; // .assign()
8
+ export * from '../code/FunctionCallNode.js'; // .call()
9
+ export * from '../math/OperatorNode.js'; // .add(), .sub(), ...
10
+ export * from '../math/MathNode.js'; // abs(), floor(), ...
11
+ export * from '../math/ConditionalNode.js'; // select(), ...
12
+ export * from '../core/ContextNode.js'; // .context()
13
+ export * from '../core/VarNode.js'; // .var() -> TODO: Maybe rename .toVar() -> .var()
14
+ export * from '../core/VaryingNode.js'; // varying() -> TODO: Add vertexStage()
15
+ export * from '../display/ColorSpaceNode.js'; // .toColorSpace()
16
+ export * from '../display/ToneMappingNode.js'; // .toToneMapping()
17
+ export * from '../accessors/BufferAttributeNode.js'; // .toAttribute()
18
+ export * from '../gpgpu/ComputeNode.js'; // .compute()
19
+ export * from '../core/CacheNode.js'; // .cache()
20
+ export * from '../core/BypassNode.js'; // .bypass()
21
+ export * from '../utils/RemapNode.js'; // .remap(), .remapClamp()
22
+ export * from '../code/ExpressionNode.js'; // expression()
23
+ export * from '../utils/Discard.js'; // Discard(), Return()
24
+ export * from '../display/RenderOutputNode.js'; // .renderOutput()
25
+
26
+ export function addNodeElement( name/*, nodeElement*/ ) {
27
+
28
+ console.warn( 'THREE.TSLBase: AddNodeElement has been removed in favor of tree-shaking. Trying add', name );
29
+
30
+ }