@plastic-software/three 0.179.0 → 0.180.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 (173) hide show
  1. package/build/three.cjs +166 -106
  2. package/build/three.core.js +112 -20
  3. package/build/three.core.min.js +1 -1
  4. package/build/three.module.js +55 -89
  5. package/build/three.module.min.js +1 -1
  6. package/build/three.tsl.js +30 -5
  7. package/build/three.tsl.min.js +1 -1
  8. package/build/three.webgpu.js +2896 -1048
  9. package/build/three.webgpu.min.js +1 -1
  10. package/build/three.webgpu.nodes.js +2896 -1048
  11. package/build/three.webgpu.nodes.min.js +1 -1
  12. package/examples/jsm/Addons.js +1 -1
  13. package/examples/jsm/controls/ArcballControls.js +7 -7
  14. package/examples/jsm/controls/DragControls.js +6 -56
  15. package/examples/jsm/controls/FirstPersonControls.js +2 -2
  16. package/examples/jsm/controls/PointerLockControls.js +0 -8
  17. package/examples/jsm/exporters/GLTFExporter.js +30 -22
  18. package/examples/jsm/exporters/KTX2Exporter.js +4 -2
  19. package/examples/jsm/exporters/PLYExporter.js +1 -1
  20. package/examples/jsm/libs/ktx-parse.module.js +1 -1
  21. package/examples/jsm/lines/Line2.js +3 -3
  22. package/examples/jsm/lines/LineGeometry.js +1 -1
  23. package/examples/jsm/lines/LineSegments2.js +2 -2
  24. package/examples/jsm/lines/Wireframe.js +2 -2
  25. package/examples/jsm/lines/WireframeGeometry2.js +1 -1
  26. package/examples/jsm/lines/webgpu/LineSegments2.js +1 -1
  27. package/examples/jsm/lines/webgpu/Wireframe.js +1 -1
  28. package/examples/jsm/loaders/ColladaLoader.js +1 -1
  29. package/examples/jsm/loaders/EXRLoader.js +5 -5
  30. package/examples/jsm/loaders/GLTFLoader.js +9 -5
  31. package/examples/jsm/loaders/HDRCubeTextureLoader.js +5 -5
  32. package/examples/jsm/loaders/HDRLoader.js +486 -0
  33. package/examples/jsm/loaders/KTX2Loader.js +112 -32
  34. package/examples/jsm/loaders/RGBELoader.js +7 -473
  35. package/examples/jsm/loaders/TTFLoader.js +4 -4
  36. package/examples/jsm/loaders/UltraHDRLoader.js +1 -1
  37. package/examples/jsm/loaders/lwo/IFFParser.js +1 -1
  38. package/examples/jsm/materials/WoodNodeMaterial.js +533 -0
  39. package/examples/jsm/math/ColorSpaces.js +19 -1
  40. package/examples/jsm/math/ConvexHull.js +2 -2
  41. package/examples/jsm/math/Lut.js +2 -2
  42. package/examples/jsm/misc/MD2CharacterComplex.js +1 -1
  43. package/examples/jsm/misc/ProgressiveLightMap.js +1 -1
  44. package/examples/jsm/misc/Volume.js +1 -1
  45. package/examples/jsm/postprocessing/OutlinePass.js +1 -1
  46. package/examples/jsm/postprocessing/SSRPass.js +37 -8
  47. package/examples/jsm/shaders/UnpackDepthRGBAShader.js +1 -1
  48. package/examples/jsm/transpiler/GLSLDecoder.js +22 -19
  49. package/examples/jsm/transpiler/TSLEncoder.js +2 -10
  50. package/examples/jsm/transpiler/WGSLEncoder.js +24 -0
  51. package/examples/jsm/tsl/display/AnamorphicNode.js +27 -4
  52. package/examples/jsm/tsl/display/BloomNode.js +3 -3
  53. package/examples/jsm/tsl/display/ChromaticAberrationNode.js +2 -1
  54. package/examples/jsm/tsl/display/DepthOfFieldNode.js +439 -90
  55. package/examples/jsm/tsl/display/GTAONode.js +8 -0
  56. package/examples/jsm/tsl/display/GaussianBlurNode.js +47 -35
  57. package/examples/jsm/tsl/display/OutlineNode.js +2 -2
  58. package/examples/jsm/tsl/display/SSRNode.js +180 -65
  59. package/examples/jsm/tsl/display/TRAANode.js +1 -1
  60. package/examples/jsm/tsl/display/boxBlur.js +64 -0
  61. package/examples/jsm/tsl/display/hashBlur.js +15 -18
  62. package/examples/jsm/utils/BufferGeometryUtils.js +1 -1
  63. package/examples/jsm/utils/ShadowMapViewerGPU.js +12 -5
  64. package/examples/jsm/webxr/OculusHandModel.js +1 -1
  65. package/package.json +1 -1
  66. package/src/Three.Core.js +1 -0
  67. package/src/Three.TSL.js +29 -4
  68. package/src/animation/AnimationClip.js +17 -2
  69. package/src/constants.js +11 -3
  70. package/src/core/BufferGeometry.js +2 -2
  71. package/src/extras/TextureUtils.js +2 -1
  72. package/src/extras/lib/earcut.js +1 -1
  73. package/src/lights/webgpu/ProjectorLight.js +1 -1
  74. package/src/materials/Material.js +12 -0
  75. package/src/materials/MeshDistanceMaterial.js +1 -1
  76. package/src/materials/nodes/PointsNodeMaterial.js +81 -28
  77. package/src/materials/nodes/SpriteNodeMaterial.js +3 -15
  78. package/src/materials/nodes/manager/NodeMaterialObserver.js +1 -1
  79. package/src/math/ColorManagement.js +7 -1
  80. package/src/nodes/Nodes.js +3 -0
  81. package/src/nodes/TSL.js +3 -0
  82. package/src/nodes/accessors/BufferNode.js +1 -1
  83. package/src/nodes/accessors/Camera.js +133 -7
  84. package/src/nodes/accessors/ClippingNode.js +6 -5
  85. package/src/nodes/accessors/CubeTextureNode.js +2 -2
  86. package/src/nodes/accessors/InstanceNode.js +3 -1
  87. package/src/nodes/accessors/Object3DNode.js +1 -1
  88. package/src/nodes/accessors/ReferenceBaseNode.js +1 -1
  89. package/src/nodes/accessors/ReferenceNode.js +1 -1
  90. package/src/nodes/accessors/Texture3DNode.js +13 -0
  91. package/src/nodes/accessors/TextureNode.js +71 -19
  92. package/src/nodes/code/FunctionCallNode.js +19 -0
  93. package/src/nodes/code/FunctionNode.js +23 -0
  94. package/src/nodes/core/AssignNode.js +4 -3
  95. package/src/nodes/core/ContextNode.js +24 -0
  96. package/src/nodes/core/Node.js +16 -20
  97. package/src/nodes/core/NodeBuilder.js +48 -14
  98. package/src/nodes/core/NodeFrame.js +1 -1
  99. package/src/nodes/core/NodeUniform.js +1 -1
  100. package/src/nodes/core/NodeUtils.js +1 -2
  101. package/src/nodes/core/StackNode.js +29 -4
  102. package/src/nodes/core/StructNode.js +5 -5
  103. package/src/nodes/core/StructTypeNode.js +1 -0
  104. package/src/nodes/core/SubBuildNode.js +2 -2
  105. package/src/nodes/core/UniformNode.js +16 -9
  106. package/src/nodes/core/VarNode.js +0 -21
  107. package/src/nodes/display/FrontFacingNode.js +4 -8
  108. package/src/nodes/display/PassNode.js +1 -1
  109. package/src/nodes/display/ScreenNode.js +42 -13
  110. package/src/nodes/display/ViewportDepthTextureNode.js +16 -4
  111. package/src/nodes/display/ViewportSharedTextureNode.js +12 -0
  112. package/src/nodes/display/ViewportTextureNode.js +42 -12
  113. package/src/nodes/gpgpu/SubgroupFunctionNode.js +430 -0
  114. package/src/nodes/lighting/LightsNode.js +1 -1
  115. package/src/nodes/math/BitcastNode.js +156 -0
  116. package/src/nodes/math/ConditionalNode.js +18 -2
  117. package/src/nodes/math/MathNode.js +3 -15
  118. package/src/nodes/math/OperatorNode.js +4 -3
  119. package/src/nodes/tsl/TSLCore.js +432 -152
  120. package/src/nodes/utils/JoinNode.js +3 -1
  121. package/src/nodes/utils/MemberNode.js +58 -7
  122. package/src/nodes/utils/RTTNode.js +1 -1
  123. package/src/nodes/utils/ReflectorNode.js +51 -7
  124. package/src/nodes/utils/SampleNode.js +12 -2
  125. package/src/nodes/utils/SplitNode.js +11 -0
  126. package/src/nodes/utils/Timer.js +0 -47
  127. package/src/objects/BatchedMesh.js +2 -2
  128. package/src/objects/LOD.js +1 -1
  129. package/src/objects/Sprite.js +2 -2
  130. package/src/renderers/WebGLRenderer.js +0 -9
  131. package/src/renderers/common/Attributes.js +1 -1
  132. package/src/renderers/common/Backend.js +19 -1
  133. package/src/renderers/common/Bindings.js +2 -0
  134. package/src/renderers/common/ChainMap.js +1 -1
  135. package/src/renderers/common/DataMap.js +1 -1
  136. package/src/renderers/common/Pipelines.js +1 -1
  137. package/src/renderers/common/RenderContext.js +2 -2
  138. package/src/renderers/common/RenderObject.js +14 -2
  139. package/src/renderers/common/Renderer.js +39 -19
  140. package/src/renderers/common/SampledTexture.js +1 -1
  141. package/src/renderers/common/Sampler.js +25 -13
  142. package/src/renderers/common/Textures.js +34 -12
  143. package/src/renderers/common/TimestampQueryPool.js +3 -3
  144. package/src/renderers/common/XRManager.js +35 -19
  145. package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
  146. package/src/renderers/common/nodes/NodeLibrary.js +5 -5
  147. package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +1 -1
  148. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
  149. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +1 -1
  150. package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +1 -1
  151. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +7 -15
  152. package/src/renderers/shaders/ShaderLib/depth.glsl.js +1 -1
  153. package/src/renderers/webgl/WebGLProgram.js +4 -4
  154. package/src/renderers/webgl/WebGLShadowMap.js +1 -1
  155. package/src/renderers/webgl/WebGLTextures.js +1 -0
  156. package/src/renderers/webgl/WebGLUtils.js +3 -2
  157. package/src/renderers/webgl-fallback/WebGLBackend.js +186 -135
  158. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +110 -17
  159. package/src/renderers/webgl-fallback/utils/WebGLState.js +1 -1
  160. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +52 -3
  161. package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +9 -10
  162. package/src/renderers/webgl-fallback/utils/WebGLUtils.js +3 -2
  163. package/src/renderers/webgpu/WebGPUBackend.js +35 -31
  164. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +124 -34
  165. package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -2
  166. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +9 -18
  167. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +114 -25
  168. package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +3 -3
  169. package/src/renderers/webxr/WebXRManager.js +39 -24
  170. package/src/textures/ExternalTexture.js +15 -4
  171. package/src/textures/Source.js +1 -1
  172. package/src/textures/VideoTexture.js +0 -3
  173. package/examples/jsm/loaders/RGBMLoader.js +0 -1148
@@ -1,8 +1,15 @@
1
- import { float, Fn, vec2, uv, sin, rand, degrees, cos, Loop, vec4, premultiplyAlpha, unpremultiplyAlpha } from 'three/tsl';
1
+ import { float, Fn, vec2, uv, sin, rand, degrees, cos, Loop, vec4, premultiplyAlpha, unpremultiplyAlpha, convertToTexture, nodeObject } from 'three/tsl';
2
2
 
3
3
  /**
4
4
  * Applies a hash blur effect to the given texture node.
5
5
  *
6
+ * The approach of this blur is different compared to Gaussian and box blur since
7
+ * it does not rely on a kernel to apply a convolution. Instead, it reads the base
8
+ * texture multiple times in a random pattern and then averages the samples. A
9
+ * typical artifact of this technique is a slightly noisy appearance of the blur which
10
+ * can be mitigated by increasing the number of iterations (see `repeats` parameter).
11
+ * Compared to Gaussian blur, hash blur requires just a single pass.
12
+ *
6
13
  * Reference: {@link https://www.shadertoy.com/view/4lXXWn}.
7
14
  *
8
15
  * @function
@@ -10,42 +17,32 @@ import { float, Fn, vec2, uv, sin, rand, degrees, cos, Loop, vec4, premultiplyAl
10
17
  * @param {Node<float>} [bluramount=float(0.1)] - This node determines the amount of blur.
11
18
  * @param {Object} [options={}] - Additional options for the hash blur effect.
12
19
  * @param {Node<float>} [options.repeats=float(45)] - The number of iterations for the blur effect.
13
- * @param {Node<vec4>} [options.mask=null] - A mask node to control the alpha blending of the blur.
14
20
  * @param {boolean} [options.premultipliedAlpha=false] - Whether to use premultiplied alpha for the blur effect.
15
21
  * @return {Node<vec4>} The blurred texture node.
16
22
  */
17
23
  export const hashBlur = /*#__PURE__*/ Fn( ( [ textureNode, bluramount = float( 0.1 ), options = {} ] ) => {
18
24
 
19
- const {
20
- repeats = float( 45 ),
21
- mask = null,
22
- premultipliedAlpha = false
23
- } = options;
24
-
25
- const draw = ( uv ) => {
26
-
27
- let sample = textureNode.sample( uv );
28
-
29
- if ( mask !== null ) {
25
+ textureNode = convertToTexture( textureNode );
30
26
 
31
- const alpha = mask.sample( uv ).x;
27
+ const repeats = nodeObject( options.repeats ) || float( 45 );
28
+ const premultipliedAlpha = options.premultipliedAlpha || false;
32
29
 
33
- sample = vec4( sample.rgb, sample.a.mul( alpha ) );
30
+ const tap = ( uv ) => {
34
31
 
35
- }
32
+ const sample = textureNode.sample( uv );
36
33
 
37
34
  return premultipliedAlpha ? premultiplyAlpha( sample ) : sample;
38
35
 
39
36
  };
40
37
 
41
38
  const targetUV = textureNode.uvNode || uv();
42
- const blurred_image = vec4( 0. ).toVar();
39
+ const blurred_image = vec4( 0. );
43
40
 
44
41
  Loop( { start: 0., end: repeats, type: 'float' }, ( { i } ) => {
45
42
 
46
43
  const q = vec2( vec2( cos( degrees( i.div( repeats ).mul( 360. ) ) ), sin( degrees( i.div( repeats ).mul( 360. ) ) ) ).mul( rand( vec2( i, targetUV.x.add( targetUV.y ) ) ).add( bluramount ) ) );
47
44
  const uv2 = vec2( targetUV.add( q.mul( bluramount ) ) );
48
- blurred_image.addAssign( draw( uv2 ) );
45
+ blurred_image.addAssign( tap( uv2 ) );
49
46
 
50
47
  } );
51
48
 
@@ -446,7 +446,7 @@ function deepCloneAttribute( attribute ) {
446
446
  * single {@link InterleavedBuffer} instance. All attributes must have compatible types.
447
447
  *
448
448
  * @param {Array<BufferAttribute>} attributes - The attributes to interleave.
449
- * @return {Array<InterleavedBufferAttribute>} An array of interleaved attributes. If interleave does not succeed, the method returns `null`.
449
+ * @return {?Array<InterleavedBufferAttribute>} An array of interleaved attributes. If interleave does not succeed, the method returns `null`.
450
450
  */
451
451
  function interleaveAttributes( attributes ) {
452
452
 
@@ -7,9 +7,10 @@ import {
7
7
  OrthographicCamera,
8
8
  PlaneGeometry,
9
9
  Scene,
10
- Texture
10
+ DepthTexture,
11
+ Vector2
11
12
  } from 'three';
12
- import { texture } from 'three/tsl';
13
+ import { uv, uniform, textureLoad } from 'three/tsl';
13
14
 
14
15
  /**
15
16
  * This is a helper for visualising a given light's shadow map.
@@ -60,8 +61,10 @@ class ShadowMapViewer {
60
61
 
61
62
  const material = new NodeMaterial();
62
63
 
63
- const shadowMapUniform = texture( new Texture() );
64
- material.fragmentNode = shadowMapUniform;
64
+ const textureDimension = uniform( new Vector2() );
65
+
66
+ const shadowMapUniform = textureLoad( new DepthTexture(), uv().flipY().mul( textureDimension ) );
67
+ material.fragmentNode = shadowMapUniform.x.oneMinus();
65
68
 
66
69
  const plane = new PlaneGeometry( frame.width, frame.height );
67
70
  const mesh = new Mesh( plane, material );
@@ -173,7 +176,11 @@ class ShadowMapViewer {
173
176
  //always end up with the scene's first added shadow casting light's shadowMap
174
177
  //in the shader
175
178
  //See: https://github.com/mrdoob/three.js/issues/5932
176
- shadowMapUniform.value = light.shadow.map.texture;
179
+
180
+ const depthTexture = light.shadow.map.depthTexture;
181
+
182
+ shadowMapUniform.value = depthTexture;
183
+ textureDimension.value.set( depthTexture.width, depthTexture.height );
177
184
 
178
185
  currentAutoClear = renderer.autoClear;
179
186
  renderer.autoClear = false; // To allow render overlay
@@ -122,7 +122,7 @@ class OculusHandModel extends Object3D {
122
122
  /**
123
123
  * Returns the pointer position which is the position of the index finger tip.
124
124
  *
125
- * @return {Vector3|null} The pointer position. Returns `null` if not index finger tip joint was found.
125
+ * @return {?Vector3} The pointer position. Returns `null` if not index finger tip joint was found.
126
126
  */
127
127
  getPointerPosition() {
128
128
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plastic-software/three",
3
- "version": "0.179.0",
3
+ "version": "0.180.0",
4
4
  "description": "JavaScript 3D library",
5
5
  "type": "module",
6
6
  "main": "./build/three.cjs",
package/src/Three.Core.js CHANGED
@@ -34,6 +34,7 @@ export { CompressedCubeTexture } from './textures/CompressedCubeTexture.js';
34
34
  export { CubeTexture } from './textures/CubeTexture.js';
35
35
  export { CanvasTexture } from './textures/CanvasTexture.js';
36
36
  export { DepthTexture } from './textures/DepthTexture.js';
37
+ export { ExternalTexture } from './textures/ExternalTexture.js';
37
38
  export { Texture } from './textures/Texture.js';
38
39
  export * from './geometries/Geometries.js';
39
40
  export * from './materials/Materials.js';
package/src/Three.TSL.js CHANGED
@@ -97,6 +97,7 @@ export const buffer = TSL.buffer;
97
97
  export const bufferAttribute = TSL.bufferAttribute;
98
98
  export const bumpMap = TSL.bumpMap;
99
99
  export const burn = TSL.burn;
100
+ export const builtin = TSL.builtin;
100
101
  export const bvec2 = TSL.bvec2;
101
102
  export const bvec3 = TSL.bvec3;
102
103
  export const bvec4 = TSL.bvec4;
@@ -111,6 +112,7 @@ export const cameraPosition = TSL.cameraPosition;
111
112
  export const cameraProjectionMatrix = TSL.cameraProjectionMatrix;
112
113
  export const cameraProjectionMatrixInverse = TSL.cameraProjectionMatrixInverse;
113
114
  export const cameraViewMatrix = TSL.cameraViewMatrix;
115
+ export const cameraViewport = TSL.cameraViewport;
114
116
  export const cameraWorldMatrix = TSL.cameraWorldMatrix;
115
117
  export const cbrt = TSL.cbrt;
116
118
  export const cdl = TSL.cdl;
@@ -177,6 +179,8 @@ export const faceDirection = TSL.faceDirection;
177
179
  export const faceForward = TSL.faceForward;
178
180
  export const faceforward = TSL.faceforward;
179
181
  export const float = TSL.float;
182
+ export const floatBitsToInt = TSL.floatBitsToInt;
183
+ export const floatBitsToUint = TSL.floatBitsToUint;
180
184
  export const floor = TSL.floor;
181
185
  export const fog = TSL.fog;
182
186
  export const fract = TSL.fract;
@@ -219,6 +223,7 @@ export const instancedBufferAttribute = TSL.instancedBufferAttribute;
219
223
  export const instancedDynamicBufferAttribute = TSL.instancedDynamicBufferAttribute;
220
224
  export const instancedMesh = TSL.instancedMesh;
221
225
  export const int = TSL.int;
226
+ export const intBitsToFloat = TSL.intBitsToFloat;
222
227
  export const inverse = TSL.inverse;
223
228
  export const inverseSqrt = TSL.inverseSqrt;
224
229
  export const inversesqrt = TSL.inversesqrt;
@@ -465,6 +470,7 @@ export const saturate = TSL.saturate;
465
470
  export const saturation = TSL.saturation;
466
471
  export const screen = TSL.screen;
467
472
  export const screenCoordinate = TSL.screenCoordinate;
473
+ export const screenDPR = TSL.screenDPR;
468
474
  export const screenSize = TSL.screenSize;
469
475
  export const screenUV = TSL.screenUV;
470
476
  export const scriptable = TSL.scriptable;
@@ -504,15 +510,35 @@ export const storageTexture = TSL.storageTexture;
504
510
  export const string = TSL.string;
505
511
  export const struct = TSL.struct;
506
512
  export const sub = TSL.sub;
513
+ export const subgroupAdd = TSL.subgroupAdd;
514
+ export const subgroupAll = TSL.subgroupAll;
515
+ export const subgroupAnd = TSL.subgroupAnd;
516
+ export const subgroupAny = TSL.subgroupAny;
517
+ export const subgroupBallot = TSL.subgroupBallot;
518
+ export const subgroupBroadcast = TSL.subgroupBroadcast;
519
+ export const subgroupBroadcastFirst = TSL.subgroupBroadcastFirst;
507
520
  export const subBuild = TSL.subBuild;
521
+ export const subgroupElect = TSL.subgroupElect;
522
+ export const subgroupExclusiveAdd = TSL.subgroupExclusiveAdd;
523
+ export const subgroupExclusiveMul = TSL.subgroupExclusiveMul;
524
+ export const subgroupInclusiveAdd = TSL.subgroupInclusiveAdd;
525
+ export const subgroupInclusiveMul = TSL.subgroupInclusiveMul;
508
526
  export const subgroupIndex = TSL.subgroupIndex;
527
+ export const subgroupMax = TSL.subgroupMax;
528
+ export const subgroupMin = TSL.subgroupMin;
529
+ export const subgroupMul = TSL.subgroupMul;
530
+ export const subgroupOr = TSL.subgroupOr;
531
+ export const subgroupShuffle = TSL.subgroupShuffle;
532
+ export const subgroupShuffleDown = TSL.subgroupShuffleDown;
533
+ export const subgroupShuffleUp = TSL.subgroupShuffleUp;
534
+ export const subgroupShuffleXor = TSL.subgroupShuffleXor;
509
535
  export const subgroupSize = TSL.subgroupSize;
536
+ export const subgroupXor = TSL.subgroupXor;
510
537
  export const tan = TSL.tan;
511
538
  export const tangentGeometry = TSL.tangentGeometry;
512
539
  export const tangentLocal = TSL.tangentLocal;
513
540
  export const tangentView = TSL.tangentView;
514
541
  export const tangentWorld = TSL.tangentWorld;
515
- export const temp = TSL.temp;
516
542
  export const texture = TSL.texture;
517
543
  export const texture3D = TSL.texture3D;
518
544
  export const textureBarrier = TSL.textureBarrier;
@@ -524,9 +550,6 @@ export const textureSize = TSL.textureSize;
524
550
  export const textureStore = TSL.textureStore;
525
551
  export const thickness = TSL.thickness;
526
552
  export const time = TSL.time;
527
- export const timerDelta = TSL.timerDelta;
528
- export const timerGlobal = TSL.timerGlobal;
529
- export const timerLocal = TSL.timerLocal;
530
553
  export const toneMapping = TSL.toneMapping;
531
554
  export const toneMappingExposure = TSL.toneMappingExposure;
532
555
  export const toonOutlinePass = TSL.toonOutlinePass;
@@ -543,10 +566,12 @@ export const triplanarTexture = TSL.triplanarTexture;
543
566
  export const triplanarTextures = TSL.triplanarTextures;
544
567
  export const trunc = TSL.trunc;
545
568
  export const uint = TSL.uint;
569
+ export const uintBitsToFloat = TSL.uintBitsToFloat;
546
570
  export const uniform = TSL.uniform;
547
571
  export const uniformArray = TSL.uniformArray;
548
572
  export const uniformCubeTexture = TSL.uniformCubeTexture;
549
573
  export const uniformGroup = TSL.uniformGroup;
574
+ export const uniformFlow = TSL.uniformFlow;
550
575
  export const uniformTexture = TSL.uniformTexture;
551
576
  export const unpremultiplyAlpha = TSL.unpremultiplyAlpha;
552
577
  export const userData = TSL.userData;
@@ -67,6 +67,14 @@ class AnimationClip {
67
67
  */
68
68
  this.uuid = generateUUID();
69
69
 
70
+ /**
71
+ * An object that can be used to store custom data about the animation clip.
72
+ * It should not hold references to functions as these will not be cloned.
73
+ *
74
+ * @type {Object}
75
+ */
76
+ this.userData = {};
77
+
70
78
  // this means it should figure out its duration by scanning the tracks
71
79
  if ( this.duration < 0 ) {
72
80
 
@@ -98,6 +106,8 @@ class AnimationClip {
98
106
  const clip = new this( json.name, json.duration, tracks, json.blendMode );
99
107
  clip.uuid = json.uuid;
100
108
 
109
+ clip.userData = JSON.parse( json.userData || '{}' );
110
+
101
111
  return clip;
102
112
 
103
113
  }
@@ -120,7 +130,8 @@ class AnimationClip {
120
130
  'duration': clip.duration,
121
131
  'tracks': tracks,
122
132
  'uuid': clip.uuid,
123
- 'blendMode': clip.blendMode
133
+ 'blendMode': clip.blendMode,
134
+ 'userData': JSON.stringify( clip.userData ),
124
135
 
125
136
  };
126
137
 
@@ -515,7 +526,11 @@ class AnimationClip {
515
526
 
516
527
  }
517
528
 
518
- return new this.constructor( this.name, this.duration, tracks, this.blendMode );
529
+ const clip = new this.constructor( this.name, this.duration, tracks, this.blendMode );
530
+
531
+ clip.userData = JSON.parse( JSON.stringify( this.userData ) );
532
+
533
+ return clip;
519
534
 
520
535
  }
521
536
 
package/src/constants.js CHANGED
@@ -1,4 +1,4 @@
1
- export const REVISION = '179';
1
+ export const REVISION = '180';
2
2
 
3
3
  /**
4
4
  * Represents mouse buttons and interaction types in context of controls.
@@ -724,6 +724,14 @@ export const UnsignedInt248Type = 1020;
724
724
  */
725
725
  export const UnsignedInt5999Type = 35902;
726
726
 
727
+ /**
728
+ * An unsigned int 10_11_11 (packed) data type for textures.
729
+ *
730
+ * @type {number}
731
+ * @constant
732
+ */
733
+ export const UnsignedInt101111Type = 35899;
734
+
727
735
  /**
728
736
  * Discards the red, green and blue components and reads just the alpha component.
729
737
  *
@@ -1665,6 +1673,6 @@ export const InterpolationSamplingMode = {
1665
1673
  * @property {string} NORMAL - Normal sampling mode.
1666
1674
  * @property {string} CENTROID - Centroid sampling mode.
1667
1675
  * @property {string} SAMPLE - Sample-specific sampling mode.
1668
- * @property {string} FLAT_FIRST - Flat interpolation using the first vertex.
1669
- * @property {string} FLAT_EITHER - Flat interpolation using either vertex.
1676
+ * @property {string} FIRST - Flat interpolation using the first vertex.
1677
+ * @property {string} EITHER - Flat interpolation using either vertex.
1670
1678
  */
@@ -156,7 +156,7 @@ class BufferGeometry extends EventDispatcher {
156
156
  /**
157
157
  * Bounding box for the geometry which can be calculated with `computeBoundingBox()`.
158
158
  *
159
- * @type {Box3}
159
+ * @type {?Box3}
160
160
  * @default null
161
161
  */
162
162
  this.boundingBox = null;
@@ -164,7 +164,7 @@ class BufferGeometry extends EventDispatcher {
164
164
  /**
165
165
  * Bounding sphere for the geometry which can be calculated with `computeBoundingSphere()`.
166
166
  *
167
- * @type {Sphere}
167
+ * @type {?Sphere}
168
168
  * @default null
169
169
  */
170
170
  this.boundingSphere = null;
@@ -1,4 +1,4 @@
1
- import { AlphaFormat, RedFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBFormat, RGBAFormat, RGBAIntegerFormat, RGB_S3TC_DXT1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGB_PVRTC_2BPPV1_Format, RGBA_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_BPTC_Format, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format, UnsignedByteType, ByteType, UnsignedShortType, ShortType, HalfFloatType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedIntType, IntType, FloatType, UnsignedInt5999Type } from '../constants.js';
1
+ import { AlphaFormat, RedFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBFormat, RGBAFormat, RGBAIntegerFormat, RGB_S3TC_DXT1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGB_PVRTC_2BPPV1_Format, RGBA_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_BPTC_Format, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format, UnsignedByteType, ByteType, UnsignedShortType, ShortType, HalfFloatType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedIntType, IntType, FloatType, UnsignedInt5999Type, UnsignedInt101111Type } from '../constants.js';
2
2
 
3
3
  /**
4
4
  * Scales the texture as large as possible within its surface without cropping
@@ -215,6 +215,7 @@ function getTextureTypeByteLength( type ) {
215
215
  case FloatType:
216
216
  return { byteLength: 4, components: 1 };
217
217
  case UnsignedInt5999Type:
218
+ case UnsignedInt101111Type:
218
219
  return { byteLength: 4, components: 3 };
219
220
 
220
221
  }
@@ -487,7 +487,7 @@ function pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, px, py) {
487
487
 
488
488
  // check if a diagonal between two polygon nodes is valid (lies in polygon interior)
489
489
  function isValidDiagonal(a, b) {
490
- return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && // dones't intersect other edges
490
+ return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && // doesn't intersect other edges
491
491
  (locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && // locally visible
492
492
  (area(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not create opposite-facing sectors
493
493
  equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0); // special zero-length case
@@ -24,7 +24,7 @@ class ProjectorLight extends SpotLight {
24
24
  /**
25
25
  * Aspect ratio of the light. Set to `null` to use the texture aspect ratio.
26
26
  *
27
- * @type {number}
27
+ * @type {?number}
28
28
  * @default null
29
29
  */
30
30
  this.aspect = null;
@@ -664,6 +664,18 @@ class Material extends EventDispatcher {
664
664
 
665
665
  }
666
666
 
667
+ if ( this.sheenColorMap && this.sheenColorMap.isTexture ) {
668
+
669
+ data.sheenColorMap = this.sheenColorMap.toJSON( meta ).uuid;
670
+
671
+ }
672
+
673
+ if ( this.sheenRoughnessMap && this.sheenRoughnessMap.isTexture ) {
674
+
675
+ data.sheenRoughnessMap = this.sheenRoughnessMap.toJSON( meta ).uuid;
676
+
677
+ }
678
+
667
679
  if ( this.dispersion !== undefined ) data.dispersion = this.dispersion;
668
680
 
669
681
  if ( this.iridescence !== undefined ) data.iridescence = this.iridescence;
@@ -7,7 +7,7 @@ import { Material } from './Material.js';
7
7
  * Can also be used to customize the shadow casting of an object by assigning
8
8
  * an instance of `MeshDistanceMaterial` to {@link Object3D#customDistanceMaterial}.
9
9
  * The following examples demonstrates this approach in order to ensure
10
- * transparent parts of objects do no cast shadows.
10
+ * transparent parts of objects do not cast shadows.
11
11
  *
12
12
  * @augments Material
13
13
  */
@@ -1,18 +1,36 @@
1
1
  import SpriteNodeMaterial from './SpriteNodeMaterial.js';
2
- import { viewport } from '../../nodes/display/ScreenNode.js';
2
+ import { viewportSize, screenDPR } from '../../nodes/display/ScreenNode.js';
3
3
  import { positionGeometry, positionLocal, positionView } from '../../nodes/accessors/Position.js';
4
4
  import { modelViewMatrix } from '../../nodes/accessors/ModelNode.js';
5
5
  import { materialPointSize } from '../../nodes/accessors/MaterialNode.js';
6
6
  import { rotate } from '../../nodes/utils/RotateNode.js';
7
- import { float, vec2, vec3, vec4 } from '../../nodes/tsl/TSLBase.js';
7
+ import { float, uniform, vec2, vec3, vec4 } from '../../nodes/tsl/TSLBase.js';
8
8
 
9
9
  import { PointsMaterial } from '../PointsMaterial.js';
10
+ import { Vector2 } from '../../math/Vector2.js';
10
11
 
11
12
  const _defaultValues = /*@__PURE__*/ new PointsMaterial();
13
+ const _size = /*@__PURE__*/ new Vector2();
12
14
 
13
15
  /**
14
16
  * Node material version of {@link PointsMaterial}.
15
17
  *
18
+ * This material can be used in two ways:
19
+ *
20
+ * - By rendering point primitives with {@link Points}. Since WebGPU only supports point primitives
21
+ * with a pixel size of `1`, it's not possible to define a size.
22
+ *
23
+ * ```js
24
+ * const pointCloud = new THREE.Points( geometry, new THREE.PointsNodeMaterial() );
25
+ * ```
26
+ *
27
+ * - By rendering point primitives with {@link Sprites}. In this case, size is honored,
28
+ * see {@link PointsNodeMaterial#sizeNode}.
29
+ *
30
+ * ```js
31
+ * const instancedPoints = new THREE.Sprite( new THREE.PointsNodeMaterial( { positionNode: instancedBufferAttribute( positionAttribute ) } ) );
32
+ * ```
33
+ *
16
34
  * @augments SpriteNodeMaterial
17
35
  */
18
36
  class PointsNodeMaterial extends SpriteNodeMaterial {
@@ -68,68 +86,95 @@ class PointsNodeMaterial extends SpriteNodeMaterial {
68
86
 
69
87
  }
70
88
 
71
- setupVertex( builder ) {
89
+ setupVertexSprite( builder ) {
72
90
 
73
- const mvp = super.setupVertex( builder );
91
+ const { material, camera } = builder;
92
+
93
+ const { rotationNode, scaleNode, sizeNode, sizeAttenuation } = this;
94
+
95
+ let mvp = super.setupVertex( builder );
74
96
 
75
97
  // skip further processing if the material is not a node material
76
98
 
77
- if ( builder.material.isNodeMaterial !== true ) {
99
+ if ( material.isNodeMaterial !== true ) {
78
100
 
79
101
  return mvp;
80
102
 
81
103
  }
82
104
 
83
- // ndc space
105
+ // point size
84
106
 
85
- const { rotationNode, scaleNode, sizeNode } = this;
107
+ let pointSize = sizeNode !== null ? vec2( sizeNode ) : materialPointSize;
86
108
 
87
- const alignedPosition = positionGeometry.xy.toVar();
88
- const aspect = viewport.z.div( viewport.w );
109
+ pointSize = pointSize.mul( screenDPR );
89
110
 
90
- // rotation
111
+ // size attenuation
91
112
 
92
- if ( rotationNode && rotationNode.isNode ) {
113
+ if ( camera.isPerspectiveCamera && sizeAttenuation === true ) {
93
114
 
94
- const rotation = float( rotationNode );
115
+ // follow WebGLRenderer's implementation, and scale by half the canvas height in logical units
95
116
 
96
- alignedPosition.assign( rotate( alignedPosition, rotation ) );
117
+ pointSize = pointSize.mul( scale.div( positionView.z.negate() ) );
97
118
 
98
119
  }
99
120
 
100
- // point size
101
-
102
- let pointSize = sizeNode !== null ? vec2( sizeNode ) : materialPointSize;
121
+ // scale
103
122
 
104
- if ( this.sizeAttenuation === true ) {
123
+ if ( scaleNode && scaleNode.isNode ) {
105
124
 
106
- pointSize = pointSize.mul( pointSize.div( positionView.z.negate() ) );
125
+ pointSize = pointSize.mul( vec2( scaleNode ) );
107
126
 
108
127
  }
109
128
 
110
- // scale
129
+ // compute offset
111
130
 
112
- if ( scaleNode && scaleNode.isNode ) {
131
+ let offset = positionGeometry.xy;
113
132
 
114
- pointSize = pointSize.mul( vec2( scaleNode ) );
133
+ // apply rotation
134
+
135
+ if ( rotationNode && rotationNode.isNode ) {
136
+
137
+ const rotation = float( rotationNode );
138
+
139
+ offset = rotate( offset, rotation );
115
140
 
116
141
  }
117
142
 
118
- alignedPosition.mulAssign( pointSize.mul( 2 ) );
143
+ // account for point size
144
+
145
+ offset = offset.mul( pointSize );
146
+
147
+ // scale by viewport size
148
+
149
+ offset = offset.div( viewportSize.div( 2 ) );
119
150
 
120
- alignedPosition.assign( alignedPosition.div( viewport.z ) );
121
- alignedPosition.y.assign( alignedPosition.y.mul( aspect ) );
151
+ // compensate for the perspective divide
122
152
 
123
- // back to clip space
124
- alignedPosition.assign( alignedPosition.mul( mvp.w ) );
153
+ offset = offset.mul( mvp.w );
125
154
 
126
- //clipPos.xy += offset;
127
- mvp.addAssign( vec4( alignedPosition, 0, 0 ) );
155
+ // add offset
156
+
157
+ mvp = mvp.add( vec4( offset, 0, 0 ) );
128
158
 
129
159
  return mvp;
130
160
 
131
161
  }
132
162
 
163
+ setupVertex( builder ) {
164
+
165
+ if ( builder.object.isPoints ) {
166
+
167
+ return super.setupVertex( builder );
168
+
169
+
170
+ } else {
171
+
172
+ return this.setupVertexSprite( builder );
173
+
174
+ }
175
+
176
+ }
177
+
133
178
  /**
134
179
  * Whether alpha to coverage should be used or not.
135
180
  *
@@ -155,4 +200,12 @@ class PointsNodeMaterial extends SpriteNodeMaterial {
155
200
 
156
201
  }
157
202
 
203
+ const scale = /*@__PURE__*/ uniform( 1 ).onFrameUpdate( function ( { renderer } ) {
204
+
205
+ const size = renderer.getSize( _size ); // logical units
206
+
207
+ this.value = 0.5 * size.y;
208
+
209
+ } );
210
+
158
211
  export default PointsNodeMaterial;
@@ -1,5 +1,4 @@
1
1
  import NodeMaterial from './NodeMaterial.js';
2
- import { cameraProjectionMatrix } from '../../nodes/accessors/Camera.js';
3
2
  import { materialRotation } from '../../nodes/accessors/MaterialNode.js';
4
3
  import { modelViewMatrix, modelWorldMatrix } from '../../nodes/accessors/ModelNode.js';
5
4
  import { positionGeometry } from '../../nodes/accessors/Position.js';
@@ -111,9 +110,7 @@ class SpriteNodeMaterial extends NodeMaterial {
111
110
 
112
111
  const { object, camera } = builder;
113
112
 
114
- const sizeAttenuation = this.sizeAttenuation;
115
-
116
- const { positionNode, rotationNode, scaleNode } = this;
113
+ const { positionNode, rotationNode, scaleNode, sizeAttenuation } = this;
117
114
 
118
115
  const mvPosition = modelViewMatrix.mul( vec3( positionNode || 0 ) );
119
116
 
@@ -125,18 +122,9 @@ class SpriteNodeMaterial extends NodeMaterial {
125
122
 
126
123
  }
127
124
 
128
- if ( sizeAttenuation === false ) {
129
-
130
- if ( camera.isPerspectiveCamera ) {
131
-
132
- scale = scale.mul( mvPosition.z.negate() );
133
-
134
- } else {
135
-
136
- const orthoScale = float( 2.0 ).div( cameraProjectionMatrix.element( 1 ).element( 1 ) );
137
- scale = scale.mul( orthoScale.mul( 2 ) );
125
+ if ( camera.isPerspectiveCamera && sizeAttenuation === false ) {
138
126
 
139
- }
127
+ scale = scale.mul( mvPosition.z.negate() );
140
128
 
141
129
  }
142
130
 
@@ -548,7 +548,7 @@ class NodeMaterialObserver {
548
548
  *
549
549
  * @param {LightsNode} lightsNode - The lights node.
550
550
  * @param {number} renderId - The render ID.
551
- * @return {Array} The lights for the given lights node and render ID.
551
+ * @return {Array<Object>} The lights for the given lights node and render ID.
552
552
  */
553
553
  getLights( lightsNode, renderId ) {
554
554
 
@@ -34,7 +34,7 @@ function createColorManagement() {
34
34
  * - luminanceCoefficients: RGB luminance coefficients
35
35
  *
36
36
  * Optional:
37
- * - outputColorSpaceConfig: { drawingBufferColorSpace: ColorSpace }
37
+ * - outputColorSpaceConfig: { drawingBufferColorSpace: ColorSpace, toneMappingMode: 'extended' | 'standard' }
38
38
  * - workingColorSpaceConfig: { unpackColorSpace: ColorSpace }
39
39
  *
40
40
  * Reference:
@@ -103,6 +103,12 @@ function createColorManagement() {
103
103
 
104
104
  },
105
105
 
106
+ getToneMappingMode: function ( colorSpace ) {
107
+
108
+ return this.spaces[ colorSpace ].outputColorSpaceConfig.toneMappingMode || 'standard';
109
+
110
+ },
111
+
106
112
  getLuminanceCoefficients: function ( target, colorSpace = this.workingColorSpace ) {
107
113
 
108
114
  return target.fromArray( this.spaces[ colorSpace ].luminanceCoefficients );
@@ -57,6 +57,9 @@ export { default as MemberNode } from './utils/MemberNode.js';
57
57
  export { default as DebugNode } from './utils/DebugNode.js';
58
58
  export { default as EventNode } from './utils/EventNode.js';
59
59
 
60
+ // math
61
+ export { default as BitcastNode } from './math/BitcastNode.js';
62
+
60
63
  // accessors
61
64
  export { default as UniformArrayNode } from './accessors/UniformArrayNode.js';
62
65
  export { default as BufferAttributeNode } from './accessors/BufferAttributeNode.js';