super-three 0.168.0 → 0.169.1

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 (288) hide show
  1. package/build/three.cjs +384 -700
  2. package/build/three.module.js +384 -700
  3. package/build/three.module.min.js +1 -1
  4. package/build/three.webgpu.js +24644 -22406
  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 -6
  9. package/examples/jsm/controls/TrackballControls.js +32 -12
  10. package/examples/jsm/controls/TransformControls.js +97 -62
  11. package/examples/jsm/exporters/DRACOExporter.js +4 -2
  12. package/examples/jsm/exporters/EXRExporter.js +19 -11
  13. package/examples/jsm/exporters/KTX2Exporter.js +21 -13
  14. package/examples/jsm/exporters/OBJExporter.js +5 -1
  15. package/examples/jsm/exporters/PLYExporter.js +9 -7
  16. package/examples/jsm/geometries/DecalGeometry.js +4 -1
  17. package/examples/jsm/geometries/InstancedPointsGeometry.js +1 -1
  18. package/examples/jsm/helpers/LightProbeHelper.js +1 -1
  19. package/examples/jsm/helpers/LightProbeHelperGPU.js +65 -0
  20. package/examples/jsm/libs/basis/basis_transcoder.js +8 -10
  21. package/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
  22. package/examples/jsm/libs/ktx-parse.module.js +1 -1
  23. package/examples/jsm/lights/LightProbeGenerator.js +24 -10
  24. package/examples/jsm/loaders/ColladaLoader.js +9 -6
  25. package/examples/jsm/loaders/DRACOLoader.js +3 -1
  26. package/examples/jsm/loaders/FBXLoader.js +30 -20
  27. package/examples/jsm/loaders/GLTFLoader.js +5 -10
  28. package/examples/jsm/loaders/KTX2Loader.js +10 -7
  29. package/examples/jsm/loaders/MTLLoader.js +4 -3
  30. package/examples/jsm/loaders/MaterialXLoader.js +29 -10
  31. package/examples/jsm/loaders/OBJLoader.js +5 -3
  32. package/examples/jsm/loaders/PCDLoader.js +5 -4
  33. package/examples/jsm/loaders/PDBLoader.js +3 -2
  34. package/examples/jsm/loaders/PLYLoader.js +8 -5
  35. package/examples/jsm/loaders/STLLoader.js +3 -2
  36. package/examples/jsm/loaders/VRMLLoader.js +10 -10
  37. package/examples/jsm/loaders/VTKLoader.js +4 -3
  38. package/examples/jsm/loaders/XYZLoader.js +3 -2
  39. package/examples/jsm/misc/Timer.js +1 -1
  40. package/examples/jsm/modifiers/CurveModifierGPU.js +233 -0
  41. package/examples/jsm/objects/LensflareMesh.js +322 -0
  42. package/examples/jsm/objects/SkyMesh.js +1 -2
  43. package/examples/jsm/objects/Water2Mesh.js +2 -3
  44. package/examples/jsm/objects/WaterMesh.js +1 -2
  45. package/examples/jsm/physics/JoltPhysics.js +1 -1
  46. package/examples/jsm/physics/RapierPhysics.js +1 -1
  47. package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
  48. package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -2
  49. package/examples/jsm/utils/GeometryCompressionUtils.js +37 -122
  50. package/examples/jsm/utils/ShadowMapViewer.js +3 -8
  51. package/examples/jsm/utils/ShadowMapViewerGPU.js +201 -0
  52. package/examples/jsm/utils/SkeletonUtils.js +84 -66
  53. package/examples/jsm/utils/TextureUtils.js +1 -0
  54. package/examples/jsm/utils/TextureUtilsGPU.js +63 -0
  55. package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
  56. package/package.json +2 -2
  57. package/src/Three.WebGPU.Nodes.js +200 -0
  58. package/src/Three.WebGPU.js +2 -1
  59. package/src/audio/Audio.js +2 -2
  60. package/src/constants.js +1 -1
  61. package/src/core/BufferAttribute.js +0 -9
  62. package/src/core/Clock.js +1 -1
  63. package/src/core/InterleavedBuffer.js +0 -9
  64. package/src/extras/Controls.js +1 -1
  65. package/src/geometries/CylinderGeometry.js +11 -4
  66. package/src/loaders/MaterialLoader.js +7 -1
  67. package/src/loaders/nodes/NodeLoader.js +24 -4
  68. package/src/loaders/nodes/NodeMaterialLoader.js +21 -17
  69. package/src/loaders/nodes/NodeObjectLoader.js +19 -0
  70. package/src/materials/nodes/InstancedPointsNodeMaterial.js +19 -34
  71. package/src/materials/nodes/Line2NodeMaterial.js +26 -26
  72. package/src/materials/nodes/LineBasicNodeMaterial.js +7 -3
  73. package/src/materials/nodes/LineDashedNodeMaterial.js +7 -3
  74. package/src/materials/nodes/MeshBasicNodeMaterial.js +7 -3
  75. package/src/materials/nodes/MeshLambertNodeMaterial.js +7 -3
  76. package/src/materials/nodes/MeshMatcapNodeMaterial.js +7 -3
  77. package/src/materials/nodes/MeshNormalNodeMaterial.js +7 -3
  78. package/src/materials/nodes/MeshPhongNodeMaterial.js +7 -3
  79. package/src/materials/nodes/MeshPhysicalNodeMaterial.js +6 -3
  80. package/src/materials/nodes/MeshSSSNodeMaterial.js +6 -3
  81. package/src/materials/nodes/MeshStandardNodeMaterial.js +7 -3
  82. package/src/materials/nodes/MeshToonNodeMaterial.js +7 -3
  83. package/src/materials/nodes/NodeMaterial.js +20 -45
  84. package/src/materials/nodes/NodeMaterials.js +2 -0
  85. package/src/materials/nodes/PointsNodeMaterial.js +7 -3
  86. package/src/materials/nodes/ShadowNodeMaterial.js +7 -3
  87. package/src/materials/nodes/SpriteNodeMaterial.js +39 -6
  88. package/src/materials/nodes/VolumeNodeMaterial.js +13 -9
  89. package/src/materials/nodes/manager/NodeMaterialObserver.js +302 -0
  90. package/src/math/Triangle.js +24 -0
  91. package/src/nodes/Nodes.js +3 -3
  92. package/src/nodes/TSL.js +96 -93
  93. package/src/nodes/accessors/BatchNode.js +7 -3
  94. package/src/nodes/accessors/BufferAttributeNode.js +6 -3
  95. package/src/nodes/accessors/BufferNode.js +6 -3
  96. package/src/nodes/accessors/Camera.js +10 -16
  97. package/src/nodes/accessors/ClippingNode.js +7 -3
  98. package/src/nodes/accessors/CubeTextureNode.js +6 -3
  99. package/src/nodes/accessors/InstanceNode.js +11 -11
  100. package/src/nodes/accessors/InstancedPointsMaterialNode.js +6 -3
  101. package/src/nodes/accessors/Lights.js +51 -0
  102. package/src/nodes/accessors/MaterialNode.js +8 -4
  103. package/src/nodes/accessors/MaterialReferenceNode.js +6 -3
  104. package/src/nodes/accessors/ModelNode.js +42 -7
  105. package/src/nodes/accessors/ModelViewProjectionNode.js +9 -5
  106. package/src/nodes/accessors/MorphNode.js +7 -3
  107. package/src/nodes/accessors/Normal.js +32 -6
  108. package/src/nodes/accessors/Object3DNode.js +11 -27
  109. package/src/nodes/accessors/PointUVNode.js +7 -3
  110. package/src/nodes/accessors/ReferenceBaseNode.js +32 -4
  111. package/src/nodes/accessors/ReferenceNode.js +40 -3
  112. package/src/nodes/accessors/RendererReferenceNode.js +9 -3
  113. package/src/nodes/accessors/SceneNode.js +7 -3
  114. package/src/nodes/accessors/SkinningNode.js +7 -3
  115. package/src/nodes/accessors/StorageBufferNode.js +21 -3
  116. package/src/nodes/accessors/StorageTextureNode.js +7 -4
  117. package/src/nodes/accessors/Texture3DNode.js +7 -4
  118. package/src/nodes/accessors/TextureNode.js +19 -8
  119. package/src/nodes/accessors/TextureSizeNode.js +8 -5
  120. package/src/nodes/accessors/UniformArrayNode.js +12 -9
  121. package/src/nodes/accessors/UserDataNode.js +9 -6
  122. package/src/nodes/accessors/VelocityNode.js +74 -23
  123. package/src/nodes/accessors/VertexColorNode.js +6 -3
  124. package/src/nodes/code/CodeNode.js +7 -3
  125. package/src/nodes/code/ExpressionNode.js +8 -4
  126. package/src/nodes/code/FunctionCallNode.js +6 -3
  127. package/src/nodes/code/FunctionNode.js +6 -3
  128. package/src/nodes/code/ScriptableNode.js +11 -6
  129. package/src/nodes/code/ScriptableValueNode.js +7 -3
  130. package/src/nodes/core/AssignNode.js +9 -6
  131. package/src/nodes/core/AttributeNode.js +7 -3
  132. package/src/nodes/core/BypassNode.js +8 -4
  133. package/src/nodes/core/CacheNode.js +8 -4
  134. package/src/nodes/core/ConstNode.js +6 -3
  135. package/src/nodes/core/ContextNode.js +7 -3
  136. package/src/nodes/core/IndexNode.js +25 -3
  137. package/src/nodes/core/InputNode.js +7 -3
  138. package/src/nodes/core/MRTNode.js +6 -3
  139. package/src/nodes/core/Node.js +10 -51
  140. package/src/nodes/core/NodeBuilder.js +71 -5
  141. package/src/nodes/core/NodeUtils.js +48 -6
  142. package/src/nodes/core/OutputStructNode.js +8 -4
  143. package/src/nodes/core/ParameterNode.js +6 -3
  144. package/src/nodes/core/PropertyNode.js +7 -3
  145. package/src/nodes/core/StackNode.js +7 -3
  146. package/src/nodes/core/StructTypeNode.js +7 -3
  147. package/src/nodes/core/TempNode.js +8 -4
  148. package/src/nodes/core/UniformGroupNode.js +10 -6
  149. package/src/nodes/core/UniformNode.js +6 -3
  150. package/src/nodes/core/VarNode.js +8 -4
  151. package/src/nodes/core/VaryingNode.js +7 -3
  152. package/src/nodes/display/AfterImageNode.js +6 -0
  153. package/src/nodes/display/AnaglyphPassNode.js +6 -0
  154. package/src/nodes/display/AnamorphicNode.js +6 -0
  155. package/src/nodes/display/BloomNode.js +6 -0
  156. package/src/nodes/display/BumpMapNode.js +6 -0
  157. package/src/nodes/display/ColorSpaceFunctions.js +4 -4
  158. package/src/nodes/display/ColorSpaceNode.js +43 -14
  159. package/src/nodes/display/DenoiseNode.js +6 -3
  160. package/src/nodes/display/DepthOfFieldNode.js +6 -3
  161. package/src/nodes/display/DotScreenNode.js +8 -5
  162. package/src/nodes/display/FXAANode.js +6 -3
  163. package/src/nodes/display/FilmNode.js +6 -3
  164. package/src/nodes/display/FrontFacingNode.js +7 -3
  165. package/src/nodes/display/GTAONode.js +6 -3
  166. package/src/nodes/display/GaussianBlurNode.js +6 -3
  167. package/src/nodes/display/Lut3DNode.js +6 -3
  168. package/src/nodes/display/NormalMapNode.js +8 -6
  169. package/src/nodes/display/ParallaxBarrierPassNode.js +8 -5
  170. package/src/nodes/display/PassNode.js +18 -7
  171. package/src/nodes/display/PixelationPassNode.js +12 -5
  172. package/src/nodes/display/PosterizeNode.js +6 -3
  173. package/src/nodes/display/RGBShiftNode.js +6 -3
  174. package/src/nodes/display/RenderOutputNode.js +12 -8
  175. package/src/nodes/display/SSAAPassNode.js +6 -3
  176. package/src/nodes/display/ScreenNode.js +181 -0
  177. package/src/nodes/display/SobelOperatorNode.js +6 -3
  178. package/src/nodes/display/StereoCompositePassNode.js +6 -3
  179. package/src/nodes/display/StereoPassNode.js +6 -3
  180. package/src/nodes/display/ToneMappingFunctions.js +12 -12
  181. package/src/nodes/display/ToneMappingNode.js +8 -7
  182. package/src/nodes/display/ToonOutlinePassNode.js +111 -0
  183. package/src/nodes/display/TransitionNode.js +6 -3
  184. package/src/nodes/display/ViewportDepthNode.js +7 -3
  185. package/src/nodes/display/ViewportDepthTextureNode.js +8 -5
  186. package/src/nodes/display/ViewportSharedTextureNode.js +8 -5
  187. package/src/nodes/display/ViewportTextureNode.js +8 -5
  188. package/src/nodes/fog/FogExp2Node.js +6 -3
  189. package/src/nodes/fog/FogNode.js +7 -3
  190. package/src/nodes/fog/FogRangeNode.js +6 -3
  191. package/src/nodes/functions/PhysicalLightingModel.js +2 -2
  192. package/src/nodes/functions/material/getShIrradianceAt.js +28 -0
  193. package/src/nodes/geometry/RangeNode.js +7 -3
  194. package/src/nodes/gpgpu/AtomicFunctionNode.js +99 -0
  195. package/src/nodes/gpgpu/BarrierNode.js +40 -0
  196. package/src/nodes/gpgpu/ComputeBuiltinNode.js +98 -0
  197. package/src/nodes/gpgpu/ComputeNode.js +8 -4
  198. package/src/nodes/gpgpu/WorkgroupInfoNode.js +100 -0
  199. package/src/nodes/lighting/AONode.js +6 -3
  200. package/src/nodes/lighting/AmbientLightNode.js +6 -3
  201. package/src/nodes/lighting/AnalyticLightNode.js +198 -30
  202. package/src/nodes/lighting/BasicEnvironmentNode.js +6 -3
  203. package/src/nodes/lighting/BasicLightMapNode.js +6 -3
  204. package/src/nodes/lighting/DirectionalLightNode.js +7 -4
  205. package/src/nodes/lighting/EnvironmentNode.js +6 -3
  206. package/src/nodes/lighting/HemisphereLightNode.js +10 -6
  207. package/src/nodes/lighting/IESSpotLightNode.js +6 -3
  208. package/src/nodes/lighting/IrradianceNode.js +6 -3
  209. package/src/nodes/lighting/LightProbeNode.js +8 -31
  210. package/src/nodes/lighting/LightingContextNode.js +6 -3
  211. package/src/nodes/lighting/LightingNode.js +7 -3
  212. package/src/nodes/lighting/LightsNode.js +24 -5
  213. package/src/nodes/lighting/PointLightNode.js +11 -7
  214. package/src/nodes/lighting/RectAreaLightNode.js +11 -7
  215. package/src/nodes/lighting/SpotLightNode.js +13 -10
  216. package/src/nodes/math/ConditionalNode.js +23 -6
  217. package/src/nodes/math/MathNode.js +6 -3
  218. package/src/nodes/math/OperatorNode.js +6 -3
  219. package/src/nodes/pmrem/PMREMNode.js +6 -3
  220. package/src/nodes/utils/ArrayElementNode.js +8 -4
  221. package/src/nodes/utils/ConvertNode.js +7 -3
  222. package/src/nodes/utils/CubeMapNode.js +6 -3
  223. package/src/nodes/utils/EquirectUVNode.js +6 -3
  224. package/src/nodes/utils/FlipNode.js +7 -4
  225. package/src/nodes/utils/FunctionOverloadingNode.js +7 -3
  226. package/src/nodes/utils/JoinNode.js +6 -3
  227. package/src/nodes/utils/LoopNode.js +7 -3
  228. package/src/nodes/utils/MatcapUVNode.js +6 -3
  229. package/src/nodes/utils/MaxMipLevelNode.js +6 -3
  230. package/src/nodes/utils/OscNode.js +7 -3
  231. package/src/nodes/utils/RTTNode.js +6 -3
  232. package/src/nodes/utils/ReflectorNode.js +8 -5
  233. package/src/nodes/utils/RemapNode.js +7 -3
  234. package/src/nodes/utils/RotateNode.js +6 -3
  235. package/src/nodes/utils/SetNode.js +7 -4
  236. package/src/nodes/utils/SplitNode.js +7 -3
  237. package/src/nodes/utils/SpriteSheetUVNode.js +7 -3
  238. package/src/nodes/utils/StorageArrayElementNode.js +9 -8
  239. package/src/nodes/utils/TimerNode.js +6 -3
  240. package/src/nodes/utils/TriplanarTexturesNode.js +7 -3
  241. package/src/nodes/utils/ViewportUtils.js +2 -2
  242. package/src/objects/BatchedMesh.js +76 -10
  243. package/src/objects/LOD.js +21 -0
  244. package/src/objects/Line.js +1 -0
  245. package/src/objects/Mesh.js +7 -23
  246. package/src/objects/Points.js +2 -0
  247. package/src/renderers/WebGLRenderer.js +65 -50
  248. package/src/renderers/common/BundleGroup.js +26 -0
  249. package/src/renderers/common/ClippingContext.js +4 -3
  250. package/src/renderers/common/RenderContext.js +4 -5
  251. package/src/renderers/common/RenderObject.js +116 -5
  252. package/src/renderers/common/RenderObjects.js +8 -1
  253. package/src/renderers/common/Renderer.js +57 -49
  254. package/src/renderers/common/extras/PMREMGenerator.js +7 -9
  255. package/src/renderers/common/nodes/NodeBuilderState.js +3 -3
  256. package/src/renderers/common/nodes/Nodes.js +33 -14
  257. package/src/renderers/shaders/ShaderLib/sprite.glsl.js +2 -4
  258. package/src/renderers/webgl/WebGLAttributes.js +45 -14
  259. package/src/renderers/webgl/WebGLCapabilities.js +9 -0
  260. package/src/renderers/webgl/WebGLProgram.js +2 -0
  261. package/src/renderers/webgl/WebGLPrograms.js +21 -17
  262. package/src/renderers/webgl/WebGLState.js +21 -0
  263. package/src/renderers/webgl/WebGLTextures.js +22 -0
  264. package/src/renderers/webgl-fallback/WebGLBackend.js +50 -45
  265. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +4 -4
  266. package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +6 -0
  267. package/src/renderers/webgl-fallback/utils/WebGLState.js +1 -4
  268. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +61 -16
  269. package/src/renderers/webgpu/WebGPUBackend.js +33 -25
  270. package/src/renderers/webgpu/WebGPURenderer.Nodes.js +42 -0
  271. package/src/renderers/webgpu/WebGPURenderer.js +5 -2
  272. package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +59 -0
  273. package/src/renderers/{common → webgpu}/nodes/StandardNodeLibrary.js +11 -11
  274. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +91 -11
  275. package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +6 -16
  276. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +1 -1
  277. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +7 -5
  278. package/src/renderers/webgpu/utils/WebGPUUtils.js +1 -1
  279. package/src/utils.js +33 -1
  280. package/examples/jsm/geometries/SDFGeometryGenerator.js +0 -144
  281. package/examples/jsm/loaders/TiltLoader.js +0 -520
  282. package/examples/jsm/utils/GPUStatsPanel.js +0 -95
  283. package/examples/jsm/utils/PackedPhongMaterial.js +0 -178
  284. package/src/nodes/display/ViewportNode.js +0 -138
  285. package/src/nodes/lighting/LightNode.js +0 -57
  286. package/src/renderers/common/StandardRenderer.js +0 -18
  287. package/src/renderers/webvr/WebVRManager.js +0 -495
  288. package/src/renderers/webvr/WebVRUtils.js +0 -66
@@ -1,8 +1,14 @@
1
- import Node, { registerNode } from '../core/Node.js';
1
+ import Node from '../core/Node.js';
2
2
  import { float, addMethodChaining, nodeProxy } from '../tsl/TSLCore.js';
3
3
 
4
4
  class RemapNode extends Node {
5
5
 
6
+ static get type() {
7
+
8
+ return 'RemapNode';
9
+
10
+ }
11
+
6
12
  constructor( node, inLowNode, inHighNode, outLowNode = float( 0 ), outHighNode = float( 1 ) ) {
7
13
 
8
14
  super();
@@ -33,8 +39,6 @@ class RemapNode extends Node {
33
39
 
34
40
  export default RemapNode;
35
41
 
36
- RemapNode.type = /*@__PURE__*/ registerNode( 'Remap', RemapNode );
37
-
38
42
  export const remap = /*@__PURE__*/ nodeProxy( RemapNode, null, null, { doClamp: false } );
39
43
  export const remapClamp = /*@__PURE__*/ nodeProxy( RemapNode );
40
44
 
@@ -1,10 +1,15 @@
1
- import { registerNode } from '../core/Node.js';
2
1
  import TempNode from '../core/TempNode.js';
3
2
  import { nodeProxy, vec4, mat2, mat4 } from '../tsl/TSLBase.js';
4
3
  import { cos, sin } from '../math/MathNode.js';
5
4
 
6
5
  class RotateNode extends TempNode {
7
6
 
7
+ static get type() {
8
+
9
+ return 'RotateNode';
10
+
11
+ }
12
+
8
13
  constructor( positionNode, rotationNode ) {
9
14
 
10
15
  super();
@@ -55,6 +60,4 @@ class RotateNode extends TempNode {
55
60
 
56
61
  export default RotateNode;
57
62
 
58
- RotateNode.type = /*@__PURE__*/ registerNode( 'Rotate', RotateNode );
59
-
60
63
  export const rotate = /*@__PURE__*/ nodeProxy( RotateNode );
@@ -1,9 +1,14 @@
1
- import { registerNode } from '../core/Node.js';
2
1
  import TempNode from '../core/TempNode.js';
3
2
  import { vectorComponents } from '../core/constants.js';
4
3
 
5
4
  class SetNode extends TempNode {
6
5
 
6
+ static get type() {
7
+
8
+ return 'SetNode';
9
+
10
+ }
11
+
7
12
  constructor( sourceNode, components, targetNode ) {
8
13
 
9
14
  super();
@@ -25,7 +30,7 @@ class SetNode extends TempNode {
25
30
  const { sourceNode, components, targetNode } = this;
26
31
 
27
32
  const sourceType = this.getNodeType( builder );
28
- const targetType = builder.getTypeFromLength( components.length );
33
+ const targetType = builder.getTypeFromLength( components.length, targetNode.getNodeType( builder ) );
29
34
 
30
35
  const targetSnippet = targetNode.build( builder, targetType );
31
36
  const sourceSnippet = sourceNode.build( builder, sourceType );
@@ -58,5 +63,3 @@ class SetNode extends TempNode {
58
63
  }
59
64
 
60
65
  export default SetNode;
61
-
62
- SetNode.type = /*@__PURE__*/ registerNode( 'Set', SetNode );
@@ -1,10 +1,16 @@
1
- import Node, { registerNode } from '../core/Node.js';
1
+ import Node from '../core/Node.js';
2
2
  import { vectorComponents } from '../core/constants.js';
3
3
 
4
4
  const stringVectorComponents = vectorComponents.join( '' );
5
5
 
6
6
  class SplitNode extends Node {
7
7
 
8
+ static get type() {
9
+
10
+ return 'SplitNode';
11
+
12
+ }
13
+
8
14
  constructor( node, components = 'x' ) {
9
15
 
10
16
  super();
@@ -108,5 +114,3 @@ class SplitNode extends Node {
108
114
  }
109
115
 
110
116
  export default SplitNode;
111
-
112
- SplitNode.type = /*@__PURE__*/ registerNode( 'Split', SplitNode );
@@ -1,9 +1,15 @@
1
- import Node, { registerNode } from '../core/Node.js';
1
+ import Node from '../core/Node.js';
2
2
  import { uv } from '../accessors/UV.js';
3
3
  import { nodeProxy, float, vec2 } from '../tsl/TSLBase.js';
4
4
 
5
5
  class SpriteSheetUVNode extends Node {
6
6
 
7
+ static get type() {
8
+
9
+ return 'SpriteSheetUVNode';
10
+
11
+ }
12
+
7
13
  constructor( countNode, uvNode = uv(), frameNode = float( 0 ) ) {
8
14
 
9
15
  super( 'vec2' );
@@ -36,6 +42,4 @@ class SpriteSheetUVNode extends Node {
36
42
 
37
43
  export default SpriteSheetUVNode;
38
44
 
39
- SpriteSheetUVNode.type = /*@__PURE__*/ registerNode( 'SpriteSheetUV', SpriteSheetUVNode );
40
-
41
45
  export const spritesheetUV = /*@__PURE__*/ nodeProxy( SpriteSheetUVNode );
@@ -1,9 +1,14 @@
1
- import { registerNode } from '../core/Node.js';
2
1
  import { nodeProxy } from '../tsl/TSLBase.js';
3
2
  import ArrayElementNode from './ArrayElementNode.js';
4
3
 
5
4
  class StorageArrayElementNode extends ArrayElementNode {
6
5
 
6
+ static get type() {
7
+
8
+ return 'StorageArrayElementNode';
9
+
10
+ }
11
+
7
12
  constructor( storageBufferNode, indexNode ) {
8
13
 
9
14
  super( storageBufferNode, indexNode );
@@ -28,7 +33,7 @@ class StorageArrayElementNode extends ArrayElementNode {
28
33
 
29
34
  if ( builder.isAvailable( 'storageBuffer' ) === false ) {
30
35
 
31
- if ( ! this.node.instanceIndex && this.node.bufferObject === true ) {
36
+ if ( this.node.bufferObject === true ) {
32
37
 
33
38
  builder.setupPBO( this.node );
34
39
 
@@ -50,15 +55,13 @@ class StorageArrayElementNode extends ArrayElementNode {
50
55
 
51
56
  if ( builder.isAvailable( 'storageBuffer' ) === false ) {
52
57
 
53
- const { node } = this;
54
-
55
- if ( ! node.instanceIndex && this.node.bufferObject === true && isAssignContext !== true ) {
58
+ if ( this.node.bufferObject === true && isAssignContext !== true ) {
56
59
 
57
60
  snippet = builder.generatePBO( this );
58
61
 
59
62
  } else {
60
63
 
61
- snippet = node.build( builder );
64
+ snippet = this.node.build( builder );
62
65
 
63
66
  }
64
67
 
@@ -84,6 +87,4 @@ class StorageArrayElementNode extends ArrayElementNode {
84
87
 
85
88
  export default StorageArrayElementNode;
86
89
 
87
- StorageArrayElementNode.type = /*@__PURE__*/ registerNode( 'StorageArrayElement', StorageArrayElementNode );
88
-
89
90
  export const storageElement = /*@__PURE__*/ nodeProxy( StorageArrayElementNode );
@@ -1,10 +1,15 @@
1
- import { registerNode } from '../core/Node.js';
2
1
  import UniformNode from '../core/UniformNode.js';
3
2
  import { NodeUpdateType } from '../core/constants.js';
4
3
  import { nodeObject, nodeImmutable } from '../tsl/TSLBase.js';
5
4
 
6
5
  class TimerNode extends UniformNode {
7
6
 
7
+ static get type() {
8
+
9
+ return 'TimerNode';
10
+
11
+ }
12
+
8
13
  constructor( scope = TimerNode.LOCAL, scale = 1, value = 0 ) {
9
14
 
10
15
  super( value );
@@ -85,8 +90,6 @@ TimerNode.FRAME = 'frame';
85
90
 
86
91
  export default TimerNode;
87
92
 
88
- TimerNode.type = /*@__PURE__*/ registerNode( 'Timer', TimerNode );
89
-
90
93
  // @TODO: add support to use node in timeScale
91
94
  export const timerLocal = ( timeScale, value = 0 ) => nodeObject( new TimerNode( TimerNode.LOCAL, timeScale, value ) );
92
95
  export const timerGlobal = ( timeScale, value = 0 ) => nodeObject( new TimerNode( TimerNode.GLOBAL, timeScale, value ) );
@@ -1,4 +1,4 @@
1
- import Node, { registerNode } from '../core/Node.js';
1
+ import Node from '../core/Node.js';
2
2
  import { add } from '../math/OperatorNode.js';
3
3
  import { normalLocal } from '../accessors/Normal.js';
4
4
  import { positionLocal } from '../accessors/Position.js';
@@ -7,6 +7,12 @@ import { nodeProxy, float, vec3 } from '../tsl/TSLBase.js';
7
7
 
8
8
  class TriplanarTexturesNode extends Node {
9
9
 
10
+ static get type() {
11
+
12
+ return 'TriplanarTexturesNode';
13
+
14
+ }
15
+
10
16
  constructor( textureXNode, textureYNode = null, textureZNode = null, scaleNode = float( 1 ), positionNode = positionLocal, normalNode = normalLocal ) {
11
17
 
12
18
  super( 'vec4' );
@@ -54,7 +60,5 @@ class TriplanarTexturesNode extends Node {
54
60
 
55
61
  export default TriplanarTexturesNode;
56
62
 
57
- TriplanarTexturesNode.type = /*@__PURE__*/ registerNode( 'TriplanarTextures', TriplanarTexturesNode );
58
-
59
63
  export const triplanarTextures = /*@__PURE__*/ nodeProxy( TriplanarTexturesNode );
60
64
  export const triplanarTexture = ( ...params ) => triplanarTextures( ...params );
@@ -1,5 +1,5 @@
1
1
  import { Fn } from '../tsl/TSLBase.js';
2
- import { viewportUV } from '../display/ViewportNode.js';
2
+ import { screenUV } from '../display/ScreenNode.js';
3
3
  import { viewportDepthTexture } from '../display/ViewportDepthTextureNode.js';
4
4
  import { linearDepth } from '../display/ViewportDepthNode.js';
5
5
 
@@ -7,7 +7,7 @@ export const viewportSafeUV = /*@__PURE__*/ Fn( ( [ uv = null ] ) => {
7
7
 
8
8
  const depth = linearDepth();
9
9
  const depthDiff = linearDepth( viewportDepthTexture( uv ) ).sub( depth );
10
- const finalUV = depthDiff.lessThan( 0 ).select( viewportUV, uv );
10
+ const finalUV = depthDiff.lessThan( 0 ).select( screenUV, uv );
11
11
 
12
12
  return finalUV;
13
13
 
@@ -145,6 +145,9 @@ class BatchedMesh extends Mesh {
145
145
  // stores visible, active, and geometry id per object
146
146
  this._drawInfo = [];
147
147
 
148
+ // instance ids that have been set as inactive, and are available to be overwritten
149
+ this._availableInstanceIds = [];
150
+
148
151
  // geometry information
149
152
  this._drawRanges = [];
150
153
  this._reservedRanges = [];
@@ -344,23 +347,36 @@ class BatchedMesh extends Mesh {
344
347
 
345
348
  addInstance( geometryId ) {
346
349
 
350
+ const atCapacity = this._drawInfo.length >= this.maxInstanceCount;
351
+
347
352
  // ensure we're not over geometry
348
- if ( this._drawInfo.length >= this._maxInstanceCount ) {
353
+ if ( atCapacity && this._availableInstanceIds.length === 0 ) {
349
354
 
350
355
  throw new Error( 'BatchedMesh: Maximum item count reached.' );
351
356
 
352
357
  }
353
358
 
354
- this._drawInfo.push( {
355
-
359
+ const instanceDrawInfo = {
356
360
  visible: true,
357
361
  active: true,
358
362
  geometryIndex: geometryId,
363
+ };
359
364
 
360
- } );
365
+ let drawId = null;
366
+
367
+ // Prioritize using previously freed instance ids
368
+ if ( this._availableInstanceIds.length > 0 ) {
369
+
370
+ drawId = this._availableInstanceIds.pop();
371
+ this._drawInfo[ drawId ] = instanceDrawInfo;
372
+
373
+ } else {
374
+
375
+ drawId = this._drawInfo.length;
376
+ this._drawInfo.push( instanceDrawInfo );
377
+
378
+ }
361
379
 
362
- // initialize the matrix
363
- const drawId = this._drawInfo.length - 1;
364
380
  const matricesTexture = this._matricesTexture;
365
381
  const matricesArray = matricesTexture.image.data;
366
382
  _identityMatrix.toArray( matricesArray, drawId * 16 );
@@ -609,11 +625,8 @@ class BatchedMesh extends Mesh {
609
625
  }
610
626
  */
611
627
 
612
- /*
613
628
  deleteInstance( instanceId ) {
614
629
 
615
- // Note: User needs to call optimize() afterward to pack the data.
616
-
617
630
  const drawInfo = this._drawInfo;
618
631
  if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
619
632
 
@@ -622,12 +635,12 @@ class BatchedMesh extends Mesh {
622
635
  }
623
636
 
624
637
  drawInfo[ instanceId ].active = false;
638
+ this._availableInstanceIds.push( instanceId );
625
639
  this._visibilityChanged = true;
626
640
 
627
641
  return this;
628
642
 
629
643
  }
630
- */
631
644
 
632
645
  // get bounding box and compute it if it doesn't exist
633
646
  getBoundingBoxAt( geometryId, target ) {
@@ -832,6 +845,59 @@ class BatchedMesh extends Mesh {
832
845
 
833
846
  }
834
847
 
848
+ setGeometryIdAt( instanceId, geometryId ) {
849
+
850
+ // return early if the geometry is out of range or not active
851
+ const drawInfo = this._drawInfo;
852
+ if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
853
+
854
+ return null;
855
+
856
+ }
857
+
858
+ // check if the provided geometryId is within the valid range
859
+ if ( geometryId < 0 || geometryId >= this._geometryCount ) {
860
+
861
+ return null;
862
+
863
+ }
864
+
865
+ drawInfo[ instanceId ].geometryIndex = geometryId;
866
+
867
+ return this;
868
+
869
+ }
870
+
871
+ getGeometryIdAt( instanceId ) {
872
+
873
+ const drawInfo = this._drawInfo;
874
+ if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
875
+
876
+ return - 1;
877
+
878
+ }
879
+
880
+ return drawInfo[ instanceId ].geometryIndex;
881
+
882
+ }
883
+
884
+ getGeometryRangeAt( geometryId, target = {} ) {
885
+
886
+ if ( geometryId < 0 || geometryId >= this._geometryCount ) {
887
+
888
+ return null;
889
+
890
+ }
891
+
892
+ const drawRange = this._drawRanges[ geometryId ];
893
+
894
+ target.start = drawRange.start;
895
+ target.count = drawRange.count;
896
+
897
+ return target;
898
+
899
+ }
900
+
835
901
  raycast( raycaster, intersects ) {
836
902
 
837
903
  const drawInfo = this._drawInfo;
@@ -74,6 +74,27 @@ class LOD extends Object3D {
74
74
 
75
75
  }
76
76
 
77
+ removeLevel( distance ) {
78
+
79
+ const levels = this.levels;
80
+
81
+ for ( let i = 0; i < levels.length; i ++ ) {
82
+
83
+ if ( levels[ i ].distance === distance ) {
84
+
85
+ const removedElements = levels.splice( i, 1 );
86
+ this.remove( removedElements[ 0 ].object );
87
+
88
+ return true;
89
+
90
+ }
91
+
92
+ }
93
+
94
+ return false;
95
+
96
+ }
97
+
77
98
  getCurrentLevel() {
78
99
 
79
100
  return this._currentLevel;
@@ -236,6 +236,7 @@ function checkIntersection( object, raycaster, ray, thresholdSq, a, b ) {
236
236
  index: a,
237
237
  face: null,
238
238
  faceIndex: null,
239
+ barycoord: null,
239
240
  object: object
240
241
 
241
242
  };
@@ -21,14 +21,6 @@ const _vC = /*@__PURE__*/ new Vector3();
21
21
  const _tempA = /*@__PURE__*/ new Vector3();
22
22
  const _morphA = /*@__PURE__*/ new Vector3();
23
23
 
24
- const _uvA = /*@__PURE__*/ new Vector2();
25
- const _uvB = /*@__PURE__*/ new Vector2();
26
- const _uvC = /*@__PURE__*/ new Vector2();
27
-
28
- const _normalA = /*@__PURE__*/ new Vector3();
29
- const _normalB = /*@__PURE__*/ new Vector3();
30
- const _normalC = /*@__PURE__*/ new Vector3();
31
-
32
24
  const _intersectionPoint = /*@__PURE__*/ new Vector3();
33
25
  const _intersectionPointWorld = /*@__PURE__*/ new Vector3();
34
26
 
@@ -371,33 +363,24 @@ function checkGeometryIntersection( object, material, raycaster, ray, uv, uv1, n
371
363
 
372
364
  if ( intersection ) {
373
365
 
374
- if ( uv ) {
366
+ const barycoord = new Vector3();
367
+ Triangle.getBarycoord( _intersectionPoint, _vA, _vB, _vC, barycoord );
375
368
 
376
- _uvA.fromBufferAttribute( uv, a );
377
- _uvB.fromBufferAttribute( uv, b );
378
- _uvC.fromBufferAttribute( uv, c );
369
+ if ( uv ) {
379
370
 
380
- intersection.uv = Triangle.getInterpolation( _intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2() );
371
+ intersection.uv = Triangle.getInterpolatedAttribute( uv, a, b, c, barycoord, new Vector2() );
381
372
 
382
373
  }
383
374
 
384
375
  if ( uv1 ) {
385
376
 
386
- _uvA.fromBufferAttribute( uv1, a );
387
- _uvB.fromBufferAttribute( uv1, b );
388
- _uvC.fromBufferAttribute( uv1, c );
389
-
390
- intersection.uv1 = Triangle.getInterpolation( _intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2() );
377
+ intersection.uv1 = Triangle.getInterpolatedAttribute( uv1, a, b, c, barycoord, new Vector2() );
391
378
 
392
379
  }
393
380
 
394
381
  if ( normal ) {
395
382
 
396
- _normalA.fromBufferAttribute( normal, a );
397
- _normalB.fromBufferAttribute( normal, b );
398
- _normalC.fromBufferAttribute( normal, c );
399
-
400
- intersection.normal = Triangle.getInterpolation( _intersectionPoint, _vA, _vB, _vC, _normalA, _normalB, _normalC, new Vector3() );
383
+ intersection.normal = Triangle.getInterpolatedAttribute( normal, a, b, c, barycoord, new Vector3() );
401
384
 
402
385
  if ( intersection.normal.dot( ray.direction ) > 0 ) {
403
386
 
@@ -418,6 +401,7 @@ function checkGeometryIntersection( object, material, raycaster, ray, uv, uv1, n
418
401
  Triangle.getNormal( _vA, _vB, _vC, face.normal );
419
402
 
420
403
  intersection.face = face;
404
+ intersection.barycoord = barycoord;
421
405
 
422
406
  }
423
407
 
@@ -155,6 +155,8 @@ function testPoint( point, index, localThresholdSq, matrixWorld, raycaster, inte
155
155
  point: intersectPoint,
156
156
  index: index,
157
157
  face: null,
158
+ faceIndex: null,
159
+ barycoord: null,
158
160
  object: object
159
161
 
160
162
  } );