super-three 0.161.0 → 0.163.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 (206) hide show
  1. package/build/three.cjs +822 -1332
  2. package/build/three.module.js +820 -1328
  3. package/build/three.module.min.js +1 -1
  4. package/examples/jsm/controls/DragControls.js +91 -30
  5. package/examples/jsm/controls/OrbitControls.js +32 -6
  6. package/examples/jsm/controls/TransformControls.js +9 -9
  7. package/examples/jsm/exporters/GLTFExporter.js +30 -3
  8. package/examples/jsm/exporters/USDZExporter.js +15 -0
  9. package/examples/jsm/geometries/TextGeometry.js +10 -2
  10. package/examples/jsm/interactive/HTMLMesh.js +7 -9
  11. package/examples/jsm/interactive/InteractiveGroup.js +15 -25
  12. package/examples/jsm/libs/fflate.module.js +694 -496
  13. package/examples/jsm/libs/rhino3dm/rhino3dm.js +1 -8723
  14. package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +1 -8734
  15. package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
  16. package/examples/jsm/libs/tween.module.js +32 -14
  17. package/examples/jsm/lines/LineMaterial.js +0 -2
  18. package/examples/jsm/loaders/3DMLoader.js +13 -21
  19. package/examples/jsm/loaders/3MFLoader.js +2 -0
  20. package/examples/jsm/loaders/EXRLoader.js +89 -19
  21. package/examples/jsm/loaders/FBXLoader.js +1 -1
  22. package/examples/jsm/loaders/GLTFLoader.js +6 -0
  23. package/examples/jsm/loaders/KTX2Loader.js +2 -6
  24. package/examples/jsm/loaders/LUT3dlLoader.js +0 -15
  25. package/examples/jsm/loaders/LUTCubeLoader.js +0 -14
  26. package/examples/jsm/loaders/LUTImageLoader.js +0 -14
  27. package/examples/jsm/loaders/RGBMLoader.js +16 -0
  28. package/examples/jsm/loaders/VOXLoader.js +9 -2
  29. package/examples/jsm/loaders/VRMLLoader.js +6 -2
  30. package/examples/jsm/misc/GPUComputationRenderer.js +0 -6
  31. package/examples/jsm/misc/ProgressiveLightMap.js +1 -0
  32. package/examples/jsm/nodes/Nodes.js +15 -8
  33. package/examples/jsm/nodes/accessors/AccessorsUtils.js +10 -0
  34. package/examples/jsm/nodes/accessors/BatchNode.js +78 -0
  35. package/examples/jsm/nodes/accessors/ClippingNode.js +144 -0
  36. package/examples/jsm/nodes/accessors/InstanceNode.js +25 -2
  37. package/examples/jsm/nodes/accessors/MaterialNode.js +2 -2
  38. package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +2 -12
  39. package/examples/jsm/nodes/accessors/MorphNode.js +20 -10
  40. package/examples/jsm/nodes/accessors/NormalNode.js +12 -2
  41. package/examples/jsm/nodes/accessors/ReferenceNode.js +87 -29
  42. package/examples/jsm/nodes/accessors/RendererReferenceNode.js +29 -0
  43. package/examples/jsm/nodes/accessors/SkinningNode.js +31 -10
  44. package/examples/jsm/nodes/accessors/StorageBufferNode.js +18 -0
  45. package/examples/jsm/nodes/accessors/TangentNode.js +8 -2
  46. package/examples/jsm/nodes/accessors/TextureNode.js +30 -7
  47. package/examples/jsm/nodes/accessors/UniformsNode.js +140 -0
  48. package/examples/jsm/nodes/code/CodeNode.js +6 -0
  49. package/examples/jsm/nodes/core/AssignNode.js +68 -12
  50. package/examples/jsm/nodes/core/Node.js +67 -6
  51. package/examples/jsm/nodes/core/NodeBuilder.js +23 -24
  52. package/examples/jsm/nodes/core/NodeFrame.js +8 -8
  53. package/examples/jsm/nodes/core/NodeUtils.js +2 -2
  54. package/examples/jsm/nodes/core/TempNode.js +1 -1
  55. package/examples/jsm/nodes/core/UniformNode.js +20 -0
  56. package/examples/jsm/nodes/display/BlendModeNode.js +30 -1
  57. package/examples/jsm/nodes/display/NormalMapNode.js +3 -5
  58. package/examples/jsm/nodes/display/PassNode.js +17 -1
  59. package/examples/jsm/nodes/display/ToneMappingNode.js +8 -4
  60. package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +6 -0
  61. package/examples/jsm/nodes/fog/FogExp2Node.js +4 -5
  62. package/examples/jsm/nodes/fog/FogNode.js +13 -3
  63. package/examples/jsm/nodes/fog/FogRangeNode.js +4 -3
  64. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +1 -1
  65. package/examples/jsm/nodes/lighting/EnvironmentNode.js +12 -69
  66. package/examples/jsm/nodes/materials/NodeMaterial.js +70 -17
  67. package/examples/jsm/nodes/math/CondNode.js +42 -7
  68. package/examples/jsm/nodes/math/MathNode.js +20 -0
  69. package/examples/jsm/nodes/pmrem/PMREMNode.js +193 -0
  70. package/examples/jsm/nodes/pmrem/PMREMUtils.js +288 -0
  71. package/examples/jsm/nodes/shadernode/ShaderNode.js +1 -1
  72. package/examples/jsm/nodes/utils/ArrayElementNode.js +0 -6
  73. package/examples/jsm/nodes/utils/EquirectUVNode.js +1 -1
  74. package/examples/jsm/nodes/utils/LoopNode.js +2 -0
  75. package/examples/jsm/nodes/utils/StorageArrayElementNode.js +91 -0
  76. package/examples/jsm/objects/QuadMesh.js +7 -23
  77. package/examples/jsm/physics/RapierPhysics.js +4 -4
  78. package/examples/jsm/postprocessing/GlitchPass.js +0 -3
  79. package/examples/jsm/postprocessing/LUTPass.js +5 -71
  80. package/examples/jsm/postprocessing/OutputPass.js +2 -0
  81. package/examples/jsm/postprocessing/SAOPass.js +0 -1
  82. package/examples/jsm/postprocessing/SSAOPass.js +0 -3
  83. package/examples/jsm/renderers/common/Animation.js +3 -0
  84. package/examples/jsm/renderers/common/Background.js +3 -3
  85. package/examples/jsm/renderers/common/ClippingContext.js +165 -0
  86. package/examples/jsm/renderers/common/Info.js +11 -19
  87. package/examples/jsm/renderers/common/PostProcessing.js +12 -4
  88. package/examples/jsm/renderers/common/RenderContext.js +3 -1
  89. package/examples/jsm/renderers/common/RenderContexts.js +2 -13
  90. package/examples/jsm/renderers/common/RenderObject.js +46 -3
  91. package/examples/jsm/renderers/common/RenderObjects.js +2 -0
  92. package/examples/jsm/renderers/common/Renderer.js +113 -39
  93. package/examples/jsm/renderers/common/StorageBufferAttribute.js +2 -2
  94. package/examples/jsm/renderers/common/StorageInstancedBufferAttribute.js +17 -0
  95. package/examples/jsm/renderers/common/Textures.js +3 -13
  96. package/examples/jsm/renderers/common/UniformsGroup.js +6 -4
  97. package/examples/jsm/renderers/common/extras/PMREMGenerator.js +777 -0
  98. package/examples/jsm/renderers/common/nodes/NodeStorageBuffer.js +23 -0
  99. package/examples/jsm/renderers/common/nodes/NodeUniformBuffer.js +23 -0
  100. package/examples/jsm/renderers/common/nodes/Nodes.js +6 -18
  101. package/examples/jsm/renderers/webgl/WebGLBackend.js +174 -30
  102. package/examples/jsm/renderers/webgl/WebGLBufferRenderer.js +141 -0
  103. package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +136 -11
  104. package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +8 -2
  105. package/examples/jsm/renderers/webgl/utils/WebGLConstants.js +1 -0
  106. package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +90 -0
  107. package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +3 -1
  108. package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +0 -2
  109. package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +0 -2
  110. package/examples/jsm/renderers/webgpu/WebGPUBackend.js +67 -37
  111. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +20 -43
  112. package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +32 -1
  113. package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +18 -4
  114. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +94 -20
  115. package/examples/jsm/shaders/OutputShader.js +4 -0
  116. package/examples/jsm/utils/GPUStatsPanel.js +10 -45
  117. package/examples/jsm/utils/SkeletonUtils.js +14 -3
  118. package/examples/jsm/utils/TextureUtils.js +1 -1
  119. package/examples/jsm/webxr/VRButton.js +13 -5
  120. package/examples/jsm/webxr/XRButton.js +0 -1
  121. package/examples/jsm/webxr/XRControllerModelFactory.js +8 -0
  122. package/package.json +4 -3
  123. package/src/Three.Legacy.js +20 -0
  124. package/src/Three.js +0 -2
  125. package/src/animation/AnimationClip.js +1 -1
  126. package/src/constants.js +4 -7
  127. package/src/core/BufferAttribute.js +0 -11
  128. package/src/core/BufferGeometry.js +23 -29
  129. package/src/core/Object3D.js +21 -7
  130. package/src/core/Raycaster.js +18 -4
  131. package/src/core/RenderTarget.js +44 -21
  132. package/src/extras/PMREMGenerator.js +11 -0
  133. package/src/extras/curves/EllipseCurve.js +2 -2
  134. package/src/helpers/SpotLightHelper.js +18 -1
  135. package/src/loaders/DataTextureLoader.js +0 -4
  136. package/src/loaders/MaterialLoader.js +1 -0
  137. package/src/loaders/ObjectLoader.js +4 -1
  138. package/src/materials/Material.js +2 -1
  139. package/src/materials/MeshBasicMaterial.js +3 -0
  140. package/src/materials/MeshLambertMaterial.js +3 -0
  141. package/src/materials/MeshPhongMaterial.js +3 -0
  142. package/src/materials/MeshStandardMaterial.js +3 -0
  143. package/src/materials/ShaderMaterial.js +0 -4
  144. package/src/math/Quaternion.js +13 -12
  145. package/src/math/Spherical.js +4 -5
  146. package/src/math/Vector3.js +7 -7
  147. package/src/objects/BatchedMesh.js +4 -3
  148. package/src/objects/InstancedMesh.js +63 -0
  149. package/src/objects/Mesh.js +0 -1
  150. package/src/renderers/WebGLCubeRenderTarget.js +1 -10
  151. package/src/renderers/WebGLRenderer.js +70 -136
  152. package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -0
  153. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +1 -1
  154. package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +2 -2
  155. package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +2 -2
  156. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
  157. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +2 -10
  158. package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +2 -16
  159. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +1 -1
  160. package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +14 -0
  161. package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +11 -2
  162. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +32 -22
  163. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +23 -0
  164. package/src/renderers/shaders/ShaderChunk.js +2 -0
  165. package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +3 -2
  166. package/src/renderers/shaders/ShaderLib/depth.glsl.js +2 -0
  167. package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +2 -0
  168. package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +1 -0
  169. package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +1 -0
  170. package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +1 -0
  171. package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +1 -0
  172. package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -0
  173. package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +1 -0
  174. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +1 -0
  175. package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +1 -0
  176. package/src/renderers/shaders/ShaderLib/points.glsl.js +1 -0
  177. package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -0
  178. package/src/renderers/shaders/ShaderLib.js +3 -2
  179. package/src/renderers/shaders/UniformsLib.js +1 -0
  180. package/src/renderers/shaders/UniformsUtils.js +10 -1
  181. package/src/renderers/webgl/WebGLAttributes.js +6 -33
  182. package/src/renderers/webgl/WebGLBackground.js +18 -0
  183. package/src/renderers/webgl/WebGLBindingStates.js +14 -51
  184. package/src/renderers/webgl/WebGLBufferRenderer.js +3 -25
  185. package/src/renderers/webgl/WebGLCapabilities.js +2 -12
  186. package/src/renderers/webgl/WebGLCubeUVMaps.js +10 -6
  187. package/src/renderers/webgl/WebGLExtensions.js +4 -19
  188. package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +3 -25
  189. package/src/renderers/webgl/WebGLLights.js +6 -32
  190. package/src/renderers/webgl/WebGLMaterials.js +26 -4
  191. package/src/renderers/webgl/WebGLMorphtargets.js +79 -210
  192. package/src/renderers/webgl/WebGLProgram.js +30 -48
  193. package/src/renderers/webgl/WebGLPrograms.js +5 -14
  194. package/src/renderers/webgl/WebGLRenderStates.js +8 -6
  195. package/src/renderers/webgl/WebGLState.js +21 -75
  196. package/src/renderers/webgl/WebGLTextures.js +143 -275
  197. package/src/renderers/webgl/WebGLUniformsGroups.js +1 -1
  198. package/src/renderers/webgl/WebGLUtils.js +6 -57
  199. package/src/renderers/webxr/WebXRDepthSensing.js +2 -3
  200. package/src/renderers/webxr/WebXRManager.js +2 -2
  201. package/src/scenes/Scene.js +14 -0
  202. package/src/textures/Texture.js +6 -24
  203. package/examples/jsm/nodes/core/ArrayUniformNode.js +0 -26
  204. package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +0 -37
  205. package/src/renderers/WebGL1Renderer.js +0 -7
  206. package/src/renderers/WebGLMultipleRenderTargets.js +0 -82
@@ -5,7 +5,6 @@
5
5
  export * from './core/constants.js';
6
6
 
7
7
  // core
8
- export { default as ArrayUniformNode /* @TODO: arrayUniform */ } from './core/ArrayUniformNode.js';
9
8
  export { default as AssignNode, assign } from './core/AssignNode.js';
10
9
  export { default as AttributeNode, attribute } from './core/AttributeNode.js';
11
10
  export { default as BypassNode, bypass } from './core/BypassNode.js';
@@ -39,7 +38,7 @@ import * as NodeUtils from './core/NodeUtils.js';
39
38
  export { NodeUtils };
40
39
 
41
40
  // math
42
- export { default as MathNode, PI, PI2, EPSILON, INFINITY, radians, degrees, exp, exp2, log, log2, sqrt, inverseSqrt, floor, ceil, normalize, fract, sin, cos, tan, asin, acos, atan, abs, sign, length, lengthSq, negate, oneMinus, dFdx, dFdy, round, reciprocal, trunc, fwidth, bitcast, atan2, min, max, mod, step, reflect, distance, difference, dot, cross, pow, pow2, pow3, pow4, transformDirection, mix, clamp, saturate, refract, smoothstep, faceForward, cbrt } from './math/MathNode.js';
41
+ export { default as MathNode, PI, PI2, EPSILON, INFINITY, radians, degrees, exp, exp2, log, log2, sqrt, inverseSqrt, floor, ceil, normalize, fract, sin, cos, tan, asin, acos, atan, abs, sign, length, lengthSq, negate, oneMinus, dFdx, dFdy, round, reciprocal, trunc, fwidth, bitcast, atan2, min, max, mod, step, reflect, distance, difference, dot, cross, pow, pow2, pow3, pow4, transformDirection, mix, clamp, saturate, refract, smoothstep, faceForward, cbrt, all, any, equals } from './math/MathNode.js';
43
42
 
44
43
  export { default as OperatorNode, add, sub, mul, div, remainder, equal, lessThan, greaterThan, lessThanEqual, greaterThanEqual, and, or, not, xor, bitAnd, bitNot, bitOr, bitXor, shiftLeft, shiftRight } from './math/OperatorNode.js';
45
44
  export { default as CondNode, cond } from './math/CondNode.js';
@@ -56,7 +55,7 @@ export { default as DiscardNode, discard } from './utils/DiscardNode.js';
56
55
  export { default as EquirectUVNode, equirectUV } from './utils/EquirectUVNode.js';
57
56
  export { default as FunctionOverloadingNode, overloadingFn } from './utils/FunctionOverloadingNode.js';
58
57
  export { default as JoinNode } from './utils/JoinNode.js';
59
- export { default as LoopNode, loop } from './utils/LoopNode.js';
58
+ export { default as LoopNode, loop, Continue, Break } from './utils/LoopNode.js';
60
59
  export { default as MatcapUVNode, matcapUV } from './utils/MatcapUVNode.js';
61
60
  export { default as MaxMipLevelNode, maxMipLevel } from './utils/MaxMipLevelNode.js';
62
61
  export { default as OscNode, oscSine, oscSquare, oscTriangle, oscSawtooth } from './utils/OscNode.js';
@@ -65,9 +64,9 @@ export { default as RemapNode, remap, remapClamp } from './utils/RemapNode.js';
65
64
  export { default as RotateUVNode, rotateUV } from './utils/RotateUVNode.js';
66
65
  export { default as RotateNode, rotate } from './utils/RotateNode.js';
67
66
  export { default as SetNode } from './utils/SetNode.js';
68
- export { default as SpecularMIPLevelNode, specularMIPLevel } from './utils/SpecularMIPLevelNode.js';
69
67
  export { default as SplitNode } from './utils/SplitNode.js';
70
68
  export { default as SpriteSheetUVNode, spritesheetUV } from './utils/SpriteSheetUVNode.js';
69
+ export { default as StorageArrayElementNode } from './utils/StorageArrayElementNode.js';
71
70
  export { default as TimerNode, timerLocal, timerGlobal, timerDelta, frameId } from './utils/TimerNode.js';
72
71
  export { default as TriplanarTexturesNode, triplanarTextures, triplanarTexture } from './utils/TriplanarTexturesNode.js';
73
72
  export { default as ReflectorNode, reflector } from './utils/ReflectorNode.js';
@@ -76,6 +75,8 @@ export { default as ReflectorNode, reflector } from './utils/ReflectorNode.js';
76
75
  export * from './shadernode/ShaderNode.js';
77
76
 
78
77
  // accessors
78
+ export { TBNViewMatrix, parallaxDirection, parallaxUV } from './accessors/AccessorsUtils.js';
79
+ export { default as UniformsNode, uniforms } from './accessors/UniformsNode.js';
79
80
  export { default as BitangentNode, bitangentGeometry, bitangentLocal, bitangentView, bitangentWorld, transformedBitangentView, transformedBitangentWorld } from './accessors/BitangentNode.js';
80
81
  export { default as BufferAttributeNode, bufferAttribute, dynamicBufferAttribute, instancedBufferAttribute, instancedDynamicBufferAttribute } from './accessors/BufferAttributeNode.js';
81
82
  export { default as BufferNode, buffer } from './accessors/BufferNode.js';
@@ -83,9 +84,11 @@ export { default as CameraNode, cameraProjectionMatrix, cameraProjectionMatrixIn
83
84
  export { default as VertexColorNode, vertexColor } from './accessors/VertexColorNode.js';
84
85
  export { default as CubeTextureNode, cubeTexture } from './accessors/CubeTextureNode.js';
85
86
  export { default as InstanceNode, instance } from './accessors/InstanceNode.js';
87
+ export { default as BatchNode, batch } from './accessors/BatchNode.js';
86
88
  export { default as MaterialNode, materialAlphaTest, materialColor, materialShininess, materialEmissive, materialOpacity, materialSpecularColor, materialSpecularStrength, materialReflectivity, materialRoughness, materialMetalness, materialNormal, materialClearcoat, materialClearcoatRoughness, materialClearcoatNormal, materialRotation, materialSheen, materialSheenRoughness, materialIridescence, materialIridescenceIOR, materialIridescenceThickness, materialLineScale, materialLineDashSize, materialLineGapSize, materialLineWidth, materialLineDashOffset, materialPointWidth } from './accessors/MaterialNode.js';
87
89
  export { default as MaterialReferenceNode, materialReference } from './accessors/MaterialReferenceNode.js';
88
- export { default as MorphNode, morph } from './accessors/MorphNode.js';
90
+ export { default as RendererReferenceNode, rendererReference } from './accessors/RendererReferenceNode.js';
91
+ export { default as MorphNode, morphReference } from './accessors/MorphNode.js';
89
92
  export { default as TextureBicubicNode, textureBicubic } from './accessors/TextureBicubicNode.js';
90
93
  export { default as ModelNode, modelDirection, modelViewMatrix, modelNormalMatrix, modelWorldMatrix, modelPosition, modelViewPosition, modelScale } from './accessors/ModelNode.js';
91
94
  export { default as ModelViewProjectionNode, modelViewProjection } from './accessors/ModelViewProjectionNode.js';
@@ -93,11 +96,11 @@ export { default as NormalNode, normalGeometry, normalLocal, normalView, normalW
93
96
  export { default as Object3DNode, objectDirection, objectViewMatrix, objectNormalMatrix, objectWorldMatrix, objectPosition, objectScale, objectViewPosition } from './accessors/Object3DNode.js';
94
97
  export { default as PointUVNode, pointUV } from './accessors/PointUVNode.js';
95
98
  export { default as PositionNode, positionGeometry, positionLocal, positionWorld, positionWorldDirection, positionView, positionViewDirection } from './accessors/PositionNode.js';
96
- export { default as ReferenceNode, reference, referenceIndex } from './accessors/ReferenceNode.js';
99
+ export { default as ReferenceNode, reference, referenceBuffer } from './accessors/ReferenceNode.js';
97
100
  export { default as ReflectVectorNode, reflectVector } from './accessors/ReflectVectorNode.js';
98
101
  export { default as SkinningNode, skinning } from './accessors/SkinningNode.js';
99
102
  export { default as SceneNode, backgroundBlurriness, backgroundIntensity } from './accessors/SceneNode.js';
100
- export { default as StorageBufferNode, storage } from './accessors/StorageBufferNode.js';
103
+ export { default as StorageBufferNode, storage, storageObject } from './accessors/StorageBufferNode.js';
101
104
  export { default as TangentNode, tangentGeometry, tangentLocal, tangentView, tangentWorld, transformedTangentView, transformedTangentWorld } from './accessors/TangentNode.js';
102
105
  export { default as TextureNode, texture, textureLoad, /*textureLevel,*/ sampler } from './accessors/TextureNode.js';
103
106
  export { default as TextureStoreNode, textureStore } from './accessors/TextureStoreNode.js';
@@ -110,7 +113,7 @@ export { default as BumpMapNode, bumpMap } from './display/BumpMapNode.js';
110
113
  export { default as ColorAdjustmentNode, saturation, vibrance, hue, lumaCoeffs, luminance, threshold } from './display/ColorAdjustmentNode.js';
111
114
  export { default as ColorSpaceNode, linearToColorSpace, colorSpaceToLinear, linearTosRGB, sRGBToLinear } from './display/ColorSpaceNode.js';
112
115
  export { default as FrontFacingNode, frontFacing, faceDirection } from './display/FrontFacingNode.js';
113
- export { default as NormalMapNode, normalMap, TBNViewMatrix } from './display/NormalMapNode.js';
116
+ export { default as NormalMapNode, normalMap } from './display/NormalMapNode.js';
114
117
  export { default as PosterizeNode, posterize } from './display/PosterizeNode.js';
115
118
  export { default as ToneMappingNode, toneMapping } from './display/ToneMappingNode.js';
116
119
  export { default as ViewportNode, viewport, viewportCoordinate, viewportResolution, viewportTopLeft, viewportBottomLeft, viewportTopRight, viewportBottomRight } from './display/ViewportNode.js';
@@ -158,6 +161,10 @@ export { default as EnvironmentNode } from './lighting/EnvironmentNode.js';
158
161
  export { default as AONode } from './lighting/AONode.js';
159
162
  export { default as AnalyticLightNode } from './lighting/AnalyticLightNode.js';
160
163
 
164
+ // pmrem
165
+ export { default as PMREMNode, pmremTexture } from './pmrem/PMREMNode.js';
166
+ export * as PMREMUtils from './pmrem/PMREMUtils.js';
167
+
161
168
  // procedural
162
169
  export { default as CheckerNode, checker } from './procedural/CheckerNode.js';
163
170
 
@@ -0,0 +1,10 @@
1
+ import { bitangentView } from './BitangentNode.js';
2
+ import { normalView } from './NormalNode.js';
3
+ import { tangentView } from './TangentNode.js';
4
+ import { mat3 } from '../shadernode/ShaderNode.js';
5
+ import { positionViewDirection } from './PositionNode.js';
6
+
7
+ export const TBNViewMatrix = mat3( tangentView, bitangentView, normalView );
8
+
9
+ export const parallaxDirection = positionViewDirection.mul( TBNViewMatrix )/*.normalize()*/;
10
+ export const parallaxUV = ( uv, scale ) => uv.sub( parallaxDirection.mul( scale ) );
@@ -0,0 +1,78 @@
1
+ import Node, { addNodeClass } from '../core/Node.js';
2
+ import { normalLocal } from './NormalNode.js';
3
+ import { positionLocal } from './PositionNode.js';
4
+ import { nodeProxy, vec3, mat3, mat4, int, ivec2, float } from '../shadernode/ShaderNode.js';
5
+ import { textureLoad } from './TextureNode.js';
6
+ import { textureSize } from './TextureSizeNode.js';
7
+ import { attribute } from '../core/AttributeNode.js';
8
+ import { tangentLocal } from './TangentNode.js';
9
+
10
+ class BatchNode extends Node {
11
+
12
+ constructor( batchMesh ) {
13
+
14
+ super( 'void' );
15
+
16
+ this.batchMesh = batchMesh;
17
+
18
+
19
+ this.instanceColorNode = null;
20
+
21
+ this.batchingIdNode = null;
22
+
23
+ }
24
+
25
+ setup( builder ) {
26
+
27
+ // POSITION
28
+
29
+ if ( this.batchingIdNode === null ) {
30
+
31
+ this.batchingIdNode = attribute( 'batchId' );
32
+
33
+ }
34
+
35
+ const matriceTexture = this.batchMesh._matricesTexture;
36
+
37
+ const size = textureSize( textureLoad( matriceTexture ), 0 );
38
+ const j = float( int( this.batchingIdNode ) ).mul( 4 ).toVar();
39
+
40
+ const x = int( j.mod( size ) );
41
+ const y = int( j ).div( int( size ) );
42
+ const batchingMatrix = mat4(
43
+ textureLoad( matriceTexture, ivec2( x, y ) ),
44
+ textureLoad( matriceTexture, ivec2( x.add( 1 ), y ) ),
45
+ textureLoad( matriceTexture, ivec2( x.add( 2 ), y ) ),
46
+ textureLoad( matriceTexture, ivec2( x.add( 3 ), y ) )
47
+ );
48
+
49
+
50
+ const bm = mat3(
51
+ batchingMatrix[ 0 ].xyz,
52
+ batchingMatrix[ 1 ].xyz,
53
+ batchingMatrix[ 2 ].xyz
54
+ );
55
+
56
+ positionLocal.assign( batchingMatrix.mul( positionLocal ) );
57
+
58
+ const transformedNormal = normalLocal.div( vec3( bm[ 0 ].dot( bm[ 0 ] ), bm[ 1 ].dot( bm[ 1 ] ), bm[ 2 ].dot( bm[ 2 ] ) ) );
59
+
60
+ const batchingNormal = bm.mul( transformedNormal ).xyz;
61
+
62
+ normalLocal.assign( batchingNormal );
63
+
64
+ if ( builder.hasGeometryAttribute( 'tangent' ) ) {
65
+
66
+ tangentLocal.mulAssign( bm );
67
+
68
+ }
69
+
70
+ }
71
+
72
+ }
73
+
74
+ export default BatchNode;
75
+
76
+ export const batch = nodeProxy( BatchNode );
77
+
78
+ addNodeClass( 'batch', BatchNode );
@@ -0,0 +1,144 @@
1
+
2
+ import Node from '../core/Node.js';
3
+ import { nodeObject } from '../shadernode/ShaderNode.js';
4
+ import { positionView } from './PositionNode.js';
5
+ import { diffuseColor, property } from '../core/PropertyNode.js';
6
+ import { tslFn } from '../shadernode/ShaderNode.js';
7
+ import { loop } from '../utils/LoopNode.js';
8
+ import { smoothstep } from '../math/MathNode.js';
9
+ import { uniforms } from './UniformsNode.js';
10
+
11
+ class ClippingNode extends Node {
12
+
13
+ constructor( scope = ClippingNode.DEFAULT ) {
14
+
15
+ super();
16
+
17
+ this.scope = scope;
18
+
19
+ }
20
+
21
+ setup( builder ) {
22
+
23
+ super.setup( builder );
24
+
25
+ const clippingContext = builder.clippingContext;
26
+ const { localClipIntersection, localClippingCount, globalClippingCount } = clippingContext;
27
+
28
+ const numClippingPlanes = globalClippingCount + localClippingCount;
29
+ const numUnionClippingPlanes = localClipIntersection ? numClippingPlanes - localClippingCount : numClippingPlanes;
30
+
31
+ if ( this.scope === ClippingNode.ALPHA_TO_COVERAGE ) {
32
+
33
+ return this.setupAlphaToCoverage( clippingContext.planes, numClippingPlanes, numUnionClippingPlanes );
34
+
35
+ } else {
36
+
37
+ return this.setupDefault( clippingContext.planes, numClippingPlanes, numUnionClippingPlanes );
38
+
39
+ }
40
+
41
+ }
42
+
43
+ setupAlphaToCoverage( planes, numClippingPlanes, numUnionClippingPlanes ) {
44
+
45
+ return tslFn( () => {
46
+
47
+ const clippingPlanes = uniforms( planes );
48
+
49
+ const distanceToPlane = property( 'float', 'distanceToPlane' );
50
+ const distanceGradient = property( 'float', 'distanceToGradient' );
51
+
52
+ const clipOpacity = property( 'float', 'clipOpacity' );
53
+
54
+ clipOpacity.assign( 1 );
55
+
56
+ let plane;
57
+
58
+ loop( numUnionClippingPlanes, ( { i } ) => {
59
+
60
+ plane = clippingPlanes.element( i );
61
+
62
+ distanceToPlane.assign( positionView.dot( plane.xyz ).negate().add( plane.w ) );
63
+ distanceGradient.assign( distanceToPlane.fwidth().div( 2.0 ) );
64
+
65
+ clipOpacity.mulAssign( smoothstep( distanceGradient.negate(), distanceGradient, distanceToPlane ) );
66
+
67
+ clipOpacity.equal( 0.0 ).discard();
68
+
69
+ } );
70
+
71
+ if ( numUnionClippingPlanes < numClippingPlanes ) {
72
+
73
+ const unionClipOpacity = property( 'float', 'unionclipOpacity' );
74
+
75
+ unionClipOpacity.assign( 1 );
76
+
77
+ loop( { start: numUnionClippingPlanes, end: numClippingPlanes }, ( { i } ) => {
78
+
79
+ plane = clippingPlanes.element( i );
80
+
81
+ distanceToPlane.assign( positionView.dot( plane.xyz ).negate().add( plane.w ) );
82
+ distanceGradient.assign( distanceToPlane.fwidth().div( 2.0 ) );
83
+
84
+ unionClipOpacity.mulAssign( smoothstep( distanceGradient.negate(), distanceGradient, distanceToPlane ).oneMinus() );
85
+
86
+ } );
87
+
88
+ clipOpacity.mulAssign( unionClipOpacity.oneMinus() );
89
+
90
+ }
91
+
92
+ diffuseColor.a.mulAssign( clipOpacity );
93
+
94
+ diffuseColor.a.equal( 0.0 ).discard();
95
+
96
+ } )();
97
+
98
+ }
99
+
100
+ setupDefault( planes, numClippingPlanes, numUnionClippingPlanes ) {
101
+
102
+ return tslFn( () => {
103
+
104
+ const clippingPlanes = uniforms( planes );
105
+
106
+ let plane;
107
+
108
+ loop( numUnionClippingPlanes, ( { i } ) => {
109
+
110
+ plane = clippingPlanes.element( i );
111
+ positionView.dot( plane.xyz ).greaterThan( plane.w ).discard();
112
+
113
+ } );
114
+
115
+ if ( numUnionClippingPlanes < numClippingPlanes ) {
116
+
117
+ const clipped = property( 'bool', 'clipped' );
118
+
119
+ clipped.assign( true );
120
+
121
+ loop( { start: numUnionClippingPlanes, end: numClippingPlanes }, ( { i } ) => {
122
+
123
+ plane = clippingPlanes.element( i );
124
+ clipped.assign( positionView.dot( plane.xyz ).greaterThan( plane.w ).and( clipped ) );
125
+
126
+ } );
127
+
128
+ clipped.discard();
129
+ }
130
+
131
+ } )();
132
+
133
+ }
134
+
135
+ }
136
+
137
+ ClippingNode.ALPHA_TO_COVERAGE = 'alphaToCoverage';
138
+ ClippingNode.DEFAULT = 'default';
139
+
140
+ export default ClippingNode;
141
+
142
+ export const clipping = () => nodeObject( new ClippingNode() );
143
+
144
+ export const clippingAlpha = () => nodeObject( new ClippingNode( ClippingNode.ALPHA_TO_COVERAGE ) );
@@ -1,9 +1,10 @@
1
1
  import Node, { addNodeClass } from '../core/Node.js';
2
+ import { varyingProperty } from '../core/PropertyNode.js';
2
3
  import { instancedBufferAttribute, instancedDynamicBufferAttribute } from './BufferAttributeNode.js';
3
4
  import { normalLocal } from './NormalNode.js';
4
5
  import { positionLocal } from './PositionNode.js';
5
6
  import { nodeProxy, vec3, mat3, mat4 } from '../shadernode/ShaderNode.js';
6
- import { DynamicDrawUsage, InstancedInterleavedBuffer } from 'three';
7
+ import { DynamicDrawUsage, InstancedInterleavedBuffer, InstancedBufferAttribute } from 'three';
7
8
 
8
9
  class InstanceNode extends Node {
9
10
 
@@ -15,15 +16,18 @@ class InstanceNode extends Node {
15
16
 
16
17
  this.instanceMatrixNode = null;
17
18
 
19
+ this.instanceColorNode = null;
20
+
18
21
  }
19
22
 
20
23
  setup( /*builder*/ ) {
21
24
 
22
25
  let instanceMatrixNode = this.instanceMatrixNode;
23
26
 
27
+ const instanceMesh = this.instanceMesh;
28
+
24
29
  if ( instanceMatrixNode === null ) {
25
30
 
26
- const instanceMesh = this.instanceMesh;
27
31
  const instanceAttribute = instanceMesh.instanceMatrix;
28
32
  const buffer = new InstancedInterleavedBuffer( instanceAttribute.array, 16, 1 );
29
33
 
@@ -43,6 +47,17 @@ class InstanceNode extends Node {
43
47
 
44
48
  }
45
49
 
50
+ const instanceColorAttribute = instanceMesh.instanceColor;
51
+
52
+ if ( instanceColorAttribute && this.instanceColorNode === null ) {
53
+
54
+ const buffer = new InstancedBufferAttribute( instanceColorAttribute.array, 3 );
55
+ const bufferFn = instanceColorAttribute.usage === DynamicDrawUsage ? instancedDynamicBufferAttribute : instancedBufferAttribute;
56
+
57
+ this.instanceColorNode = vec3( bufferFn( buffer, 'vec3', 3, 0 ) );
58
+
59
+ }
60
+
46
61
  // POSITION
47
62
 
48
63
  const instancePosition = instanceMatrixNode.mul( positionLocal ).xyz;
@@ -60,6 +75,14 @@ class InstanceNode extends Node {
60
75
  positionLocal.assign( instancePosition );
61
76
  normalLocal.assign( instanceNormal );
62
77
 
78
+ // COLOR
79
+
80
+ if ( this.instanceColorNode !== null ) {
81
+
82
+ varyingProperty( 'vec3', 'vInstanceColor' ).assign( this.instanceColorNode );
83
+
84
+ }
85
+
63
86
  }
64
87
 
65
88
  }
@@ -227,11 +227,11 @@ class MaterialNode extends Node {
227
227
 
228
228
  } else if ( scope === MaterialNode.IRIDESCENCE_THICKNESS ) {
229
229
 
230
- const iridescenceThicknessMaximum = reference( 1, 'float', material.iridescenceThicknessRange );
230
+ const iridescenceThicknessMaximum = reference( '1', 'float', material.iridescenceThicknessRange );
231
231
 
232
232
  if ( material.iridescenceThicknessMap ) {
233
233
 
234
- const iridescenceThicknessMinimum = reference( 0, 'float', material.iridescenceThicknessRange );
234
+ const iridescenceThicknessMinimum = reference( '0', 'float', material.iridescenceThicknessRange );
235
235
 
236
236
  node = iridescenceThicknessMaximum.sub( iridescenceThicknessMinimum ).mul( this.getTexture( scope ).g ).add( iridescenceThicknessMinimum );
237
237
 
@@ -24,24 +24,14 @@ class MaterialReferenceNode extends ReferenceNode {
24
24
 
25
25
  }*/
26
26
 
27
- updateReference( frame ) {
27
+ updateReference( state ) {
28
28
 
29
- this.reference = this.material !== null ? this.material : frame.material;
29
+ this.reference = this.material !== null ? this.material : state.material;
30
30
 
31
31
  return this.reference;
32
32
 
33
33
  }
34
34
 
35
- setup( builder ) {
36
-
37
- const material = this.material !== null ? this.material : builder.material;
38
-
39
- this.node.value = material[ this.property ];
40
-
41
- return super.setup( builder );
42
-
43
- }
44
-
45
35
  }
46
36
 
47
37
  export default MaterialReferenceNode;
@@ -1,14 +1,15 @@
1
1
  import Node, { addNodeClass } from '../core/Node.js';
2
2
  import { NodeUpdateType } from '../core/constants.js';
3
- import { nodeProxy, tslFn } from '../shadernode/ShaderNode.js';
3
+ import { float, nodeProxy, tslFn } from '../shadernode/ShaderNode.js';
4
4
  import { uniform } from '../core/UniformNode.js';
5
- import { referenceIndex } from './ReferenceNode.js';
5
+ import { reference } from './ReferenceNode.js';
6
6
  import { positionLocal } from './PositionNode.js';
7
7
  import { normalLocal } from './NormalNode.js';
8
8
  import { textureLoad } from './TextureNode.js';
9
- import { vertexIndex } from '../core/IndexNode.js';
9
+ import { instanceIndex, vertexIndex } from '../core/IndexNode.js';
10
10
  import { ivec2, int } from '../shadernode/ShaderNode.js';
11
11
  import { DataArrayTexture, Vector2, Vector4, FloatType } from 'three';
12
+ import { loop } from '../utils/LoopNode.js';
12
13
 
13
14
  const morphTextures = new WeakMap();
14
15
  const morphVec4 = new Vector4();
@@ -185,10 +186,19 @@ class MorphNode extends Node {
185
186
 
186
187
  const width = int( size.width );
187
188
 
188
- for ( let i = 0; i < morphTargetsCount; i ++ ) {
189
+ loop( morphTargetsCount, ( { i } ) => {
190
+
191
+ const influence = float( 0 ).toVar();
192
+
193
+ if ( this.mesh.isInstancedMesh === true && ( this.mesh.morphTexture !== null && this.mesh.morphTexture !== undefined ) ) {
194
+
195
+ influence.assign( textureLoad( this.mesh.morphTexture, ivec2( int( i ).add( 1 ), int( instanceIndex ) ) ).r );
189
196
 
190
- const influence = referenceIndex( 'morphTargetInfluences', i, 'float' );
191
- const depth = int( i );
197
+ } else {
198
+
199
+ influence.assign( reference( 'morphTargetInfluences', 'float' ).element( i ).toVar() );
200
+
201
+ }
192
202
 
193
203
  if ( hasMorphPosition === true ) {
194
204
 
@@ -197,7 +207,7 @@ class MorphNode extends Node {
197
207
  influence,
198
208
  stride,
199
209
  width,
200
- depth,
210
+ depth: i,
201
211
  offset: int( 0 )
202
212
  } ) );
203
213
 
@@ -210,13 +220,13 @@ class MorphNode extends Node {
210
220
  influence,
211
221
  stride,
212
222
  width,
213
- depth,
223
+ depth: i,
214
224
  offset: int( 1 )
215
225
  } ) );
216
226
 
217
227
  }
218
228
 
219
- }
229
+ } );
220
230
 
221
231
  }
222
232
 
@@ -240,6 +250,6 @@ class MorphNode extends Node {
240
250
 
241
251
  export default MorphNode;
242
252
 
243
- export const morph = nodeProxy( MorphNode );
253
+ export const morphReference = nodeProxy( MorphNode );
244
254
 
245
255
  addNodeClass( 'MorphNode', MorphNode );
@@ -5,7 +5,7 @@ import { property } from '../core/PropertyNode.js';
5
5
  import { normalize } from '../math/MathNode.js';
6
6
  import { cameraViewMatrix } from './CameraNode.js';
7
7
  import { modelNormalMatrix } from './ModelNode.js';
8
- import { nodeImmutable } from '../shadernode/ShaderNode.js';
8
+ import { nodeImmutable, vec3 } from '../shadernode/ShaderNode.js';
9
9
 
10
10
  class NormalNode extends Node {
11
11
 
@@ -37,7 +37,17 @@ class NormalNode extends Node {
37
37
 
38
38
  if ( scope === NormalNode.GEOMETRY ) {
39
39
 
40
- outputNode = attribute( 'normal', 'vec3' );
40
+ const geometryAttribute = builder.hasGeometryAttribute( 'normal' );
41
+
42
+ if ( geometryAttribute === false ) {
43
+
44
+ outputNode = vec3( 0, 1, 0 );
45
+
46
+ } else {
47
+
48
+ outputNode = attribute( 'normal', 'vec3' );
49
+
50
+ }
41
51
 
42
52
  } else if ( scope === NormalNode.LOCAL ) {
43
53