super-three 0.160.1 → 0.161.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 (145) hide show
  1. package/LICENSE +1 -1
  2. package/build/three.cjs +379 -108
  3. package/build/three.module.js +380 -108
  4. package/build/three.module.min.js +1 -1
  5. package/examples/jsm/Addons.js +5 -1
  6. package/examples/jsm/capabilities/WebGPU.js +13 -9
  7. package/examples/jsm/controls/OrbitControls.js +102 -13
  8. package/examples/jsm/curves/NURBSUtils.js +59 -4
  9. package/examples/jsm/curves/NURBSVolume.js +62 -0
  10. package/examples/jsm/exporters/USDZExporter.js +8 -7
  11. package/examples/jsm/helpers/TextureHelper.js +3 -3
  12. package/examples/jsm/loaders/3DMLoader.js +44 -43
  13. package/examples/jsm/loaders/DDSLoader.js +1 -0
  14. package/examples/jsm/loaders/KTX2Loader.js +20 -5
  15. package/examples/jsm/loaders/LUT3dlLoader.js +78 -46
  16. package/examples/jsm/loaders/LUTCubeLoader.js +81 -67
  17. package/examples/jsm/loaders/LUTImageLoader.js +3 -2
  18. package/examples/jsm/loaders/MaterialXLoader.js +115 -16
  19. package/examples/jsm/loaders/SVGLoader.js +4 -3
  20. package/examples/jsm/loaders/VRMLLoader.js +1 -1
  21. package/examples/jsm/materials/MeshPostProcessingMaterial.js +144 -0
  22. package/examples/jsm/misc/Timer.js +13 -4
  23. package/examples/jsm/nodes/Nodes.js +16 -5
  24. package/examples/jsm/nodes/accessors/BufferAttributeNode.js +5 -3
  25. package/examples/jsm/nodes/accessors/CameraNode.js +9 -4
  26. package/examples/jsm/nodes/accessors/CubeTextureNode.js +12 -1
  27. package/examples/jsm/nodes/accessors/StorageBufferNode.js +27 -0
  28. package/examples/jsm/nodes/accessors/TextureStoreNode.js +56 -3
  29. package/examples/jsm/nodes/accessors/VertexColorNode.js +70 -0
  30. package/examples/jsm/nodes/core/AttributeNode.js +1 -1
  31. package/examples/jsm/nodes/core/NodeBuilder.js +23 -18
  32. package/examples/jsm/nodes/core/NodeFrame.js +16 -8
  33. package/examples/jsm/nodes/core/constants.js +1 -0
  34. package/examples/jsm/nodes/display/AfterImageNode.js +148 -0
  35. package/examples/jsm/nodes/display/AnamorphicNode.js +148 -0
  36. package/examples/jsm/nodes/display/ColorAdjustmentNode.js +3 -0
  37. package/examples/jsm/nodes/display/GaussianBlurNode.js +33 -13
  38. package/examples/jsm/nodes/display/PassNode.js +3 -2
  39. package/examples/jsm/nodes/display/ToneMappingNode.js +46 -3
  40. package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +1 -4
  41. package/examples/jsm/nodes/display/ViewportNode.js +0 -2
  42. package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +4 -4
  43. package/examples/jsm/nodes/fog/FogNode.js +2 -1
  44. package/examples/jsm/nodes/lighting/AmbientLightNode.js +1 -1
  45. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +13 -5
  46. package/examples/jsm/nodes/lighting/LightingContextNode.js +1 -1
  47. package/examples/jsm/nodes/lighting/LightsNode.js +1 -1
  48. package/examples/jsm/nodes/materials/Line2NodeMaterial.js +18 -30
  49. package/examples/jsm/nodes/materials/Materials.js +1 -0
  50. package/examples/jsm/nodes/materials/MeshSSSNodeMaterial.js +84 -0
  51. package/examples/jsm/nodes/materials/NodeMaterial.js +6 -4
  52. package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +1 -7
  53. package/examples/jsm/nodes/math/MathNode.js +12 -2
  54. package/examples/jsm/nodes/math/MathUtils.js +15 -0
  55. package/examples/jsm/nodes/math/OperatorNode.js +13 -5
  56. package/examples/jsm/nodes/math/TriNoise3D.js +71 -0
  57. package/examples/jsm/nodes/shadernode/ShaderNode.js +10 -1
  58. package/examples/jsm/nodes/utils/ArrayElementNode.js +6 -0
  59. package/examples/jsm/nodes/utils/JoinNode.js +2 -2
  60. package/examples/jsm/nodes/utils/LoopNode.js +3 -3
  61. package/examples/jsm/nodes/utils/ReflectorNode.js +227 -0
  62. package/examples/jsm/nodes/utils/RotateNode.js +68 -0
  63. package/examples/jsm/nodes/utils/RotateUVNode.js +1 -9
  64. package/examples/jsm/nodes/utils/SplitNode.js +4 -4
  65. package/examples/jsm/objects/GroundedSkybox.js +50 -0
  66. package/examples/jsm/objects/QuadMesh.js +8 -2
  67. package/examples/jsm/objects/Water2.js +8 -8
  68. package/examples/jsm/postprocessing/GTAOPass.js +11 -1
  69. package/examples/jsm/renderers/common/Backend.js +14 -0
  70. package/examples/jsm/renderers/common/Bindings.js +1 -1
  71. package/examples/jsm/renderers/common/DataMap.js +1 -1
  72. package/examples/jsm/renderers/common/Info.js +25 -1
  73. package/examples/jsm/renderers/common/Pipelines.js +8 -8
  74. package/examples/jsm/renderers/common/PostProcessing.js +2 -2
  75. package/examples/jsm/renderers/common/ProgrammableStage.js +3 -1
  76. package/examples/jsm/renderers/common/RenderObject.js +2 -0
  77. package/examples/jsm/renderers/common/Renderer.js +238 -22
  78. package/examples/jsm/renderers/common/StorageBufferAttribute.js +17 -0
  79. package/examples/jsm/renderers/common/Textures.js +25 -5
  80. package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +2 -1
  81. package/examples/jsm/renderers/common/nodes/Nodes.js +4 -2
  82. package/examples/jsm/renderers/webgl/WebGLBackend.js +631 -270
  83. package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +37 -30
  84. package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +89 -8
  85. package/examples/jsm/renderers/webgl/utils/WebGLConstants.js +11 -0
  86. package/examples/jsm/renderers/webgl/utils/WebGLState.js +197 -0
  87. package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +377 -11
  88. package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +2 -2
  89. package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +1 -21
  90. package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +2 -2
  91. package/examples/jsm/renderers/webgpu/WebGPUBackend.js +289 -102
  92. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +7 -2
  93. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +56 -39
  94. package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +9 -1
  95. package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +38 -4
  96. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +85 -12
  97. package/examples/jsm/transpiler/AST.js +1 -1
  98. package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
  99. package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
  100. package/examples/jsm/transpiler/TSLEncoder.js +1 -1
  101. package/examples/jsm/utils/BufferGeometryUtils.js +23 -27
  102. package/examples/jsm/utils/SortUtils.js +2 -0
  103. package/examples/jsm/webxr/ARButton.js +12 -2
  104. package/examples/jsm/webxr/VRButton.js +12 -2
  105. package/examples/jsm/webxr/XRButton.js +12 -2
  106. package/examples/jsm/webxr/XRControllerModelFactory.js +6 -1
  107. package/examples/jsm/webxr/XRHandMeshModel.js +3 -1
  108. package/package.json +2 -2
  109. package/src/audio/Audio.js +1 -3
  110. package/src/cameras/PerspectiveCamera.js +35 -0
  111. package/src/constants.js +1 -2
  112. package/src/core/BufferAttribute.js +2 -1
  113. package/src/core/InterleavedBuffer.js +2 -1
  114. package/src/core/InterleavedBufferAttribute.js +20 -0
  115. package/src/materials/ShaderMaterial.js +2 -1
  116. package/src/math/Triangle.js +0 -30
  117. package/src/objects/BatchedMesh.js +6 -7
  118. package/src/objects/SkinnedMesh.js +0 -8
  119. package/src/renderers/WebGLRenderer.js +5 -1
  120. package/src/renderers/shaders/ShaderChunk/alphatest_fragment.glsl.js +9 -0
  121. package/src/renderers/shaders/ShaderChunk/clipping_planes_fragment.glsl.js +56 -11
  122. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +15 -7
  123. package/src/renderers/shaders/ShaderLib/depth.glsl.js +1 -2
  124. package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +1 -2
  125. package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +1 -1
  126. package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +1 -2
  127. package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +1 -1
  128. package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +1 -2
  129. package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +3 -1
  130. package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +1 -1
  131. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +1 -1
  132. package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +1 -1
  133. package/src/renderers/shaders/ShaderLib/points.glsl.js +1 -1
  134. package/src/renderers/shaders/ShaderLib/sprite.glsl.js +1 -1
  135. package/src/renderers/webgl/WebGLAttributes.js +2 -2
  136. package/src/renderers/webgl/WebGLCubeMaps.js +1 -1
  137. package/src/renderers/webgl/WebGLProgram.js +30 -3
  138. package/src/renderers/webgl/WebGLPrograms.js +19 -11
  139. package/src/renderers/webgl/WebGLTextures.js +90 -16
  140. package/src/renderers/webxr/WebXRDepthSensing.js +105 -0
  141. package/src/renderers/webxr/WebXRManager.js +46 -0
  142. package/src/textures/Source.js +1 -0
  143. package/build/three.js +0 -54519
  144. package/build/three.min.js +0 -7
  145. package/examples/jsm/objects/GroundProjectedSkybox.js +0 -172
@@ -9,20 +9,24 @@ import UniformBuffer from '../../common/UniformBuffer.js';
9
9
  import StorageBuffer from '../../common/StorageBuffer.js';
10
10
  import { getVectorLength, getStrideLength } from '../../common/BufferUtils.js';
11
11
 
12
- import { NodeBuilder, CodeNode, NodeMaterial } from '../../../nodes/Nodes.js';
12
+ import { NodeBuilder, CodeNode } from '../../../nodes/Nodes.js';
13
13
 
14
14
  import { getFormat } from '../utils/WebGPUTextureUtils.js';
15
15
 
16
16
  import WGSLNodeParser from './WGSLNodeParser.js';
17
17
 
18
+ // GPUShaderStage is not defined in browsers not supporting WebGPU
19
+ const GPUShaderStage = self.GPUShaderStage;
20
+
18
21
  const gpuShaderStageLib = {
19
- 'vertex': GPUShaderStage.VERTEX,
20
- 'fragment': GPUShaderStage.FRAGMENT,
21
- 'compute': GPUShaderStage.COMPUTE
22
+ 'vertex': GPUShaderStage ? GPUShaderStage.VERTEX : 1,
23
+ 'fragment': GPUShaderStage ? GPUShaderStage.FRAGMENT : 2,
24
+ 'compute': GPUShaderStage ? GPUShaderStage.COMPUTE : 4
22
25
  };
23
26
 
24
27
  const supports = {
25
- instance: true
28
+ instance: true,
29
+ storageBuffer: true
26
30
  };
27
31
 
28
32
  const wgslFnOpLib = {
@@ -51,6 +55,11 @@ const wgslTypeLib = {
51
55
  uvec4: 'vec4<u32>',
52
56
  bvec4: 'vec4<bool>',
53
57
 
58
+ mat2: 'mat2x2<f32>',
59
+ imat2: 'mat2x2<i32>',
60
+ umat2: 'mat2x2<u32>',
61
+ bmat2: 'mat2x2<bool>',
62
+
54
63
  mat3: 'mat3x3<f32>',
55
64
  imat3: 'mat3x3<i32>',
56
65
  umat3: 'mat3x3<u32>',
@@ -65,7 +74,10 @@ const wgslTypeLib = {
65
74
  const wgslMethods = {
66
75
  dFdx: 'dpdx',
67
76
  dFdy: '- dpdy',
68
- mod: 'threejs_mod',
77
+ mod_float: 'threejs_mod_float',
78
+ mod_vec2: 'threejs_mod_vec2',
79
+ mod_vec3: 'threejs_mod_vec3',
80
+ mod_vec4: 'threejs_mod_vec4',
69
81
  lessThanEqual: 'threejs_lessThanEqual',
70
82
  greaterThan: 'threejs_greaterThan',
71
83
  inversesqrt: 'inverseSqrt',
@@ -94,13 +106,10 @@ fn threejs_greaterThan( a : vec3<f32>, b : vec3<f32> ) -> vec3<bool> {
94
106
 
95
107
  }
96
108
  ` ),
97
- mod: new CodeNode( `
98
- fn threejs_mod( x : f32, y : f32 ) -> f32 {
99
-
100
- return x - y * floor( x / y );
101
-
102
- }
103
- ` ),
109
+ mod_float: new CodeNode( 'fn threejs_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }' ),
110
+ mod_vec2: new CodeNode( 'fn threejs_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }' ),
111
+ mod_vec3: new CodeNode( 'fn threejs_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }' ),
112
+ mod_vec4: new CodeNode( 'fn threejs_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }' ),
104
113
  repeatWrapping: new CodeNode( `
105
114
  fn threejs_repeatWrapping( uv : vec2<f32>, dimension : vec2<u32> ) -> vec2<u32> {
106
115
 
@@ -124,24 +133,6 @@ class WGSLNodeBuilder extends NodeBuilder {
124
133
 
125
134
  }
126
135
 
127
- build() {
128
-
129
- const { object, material } = this;
130
-
131
- if ( material !== null ) {
132
-
133
- NodeMaterial.fromMaterial( material ).build( this );
134
-
135
- } else {
136
-
137
- this.addFlow( 'compute', object );
138
-
139
- }
140
-
141
- return super.build();
142
-
143
- }
144
-
145
136
  needsColorSpaceToLinear( texture ) {
146
137
 
147
138
  return texture.isVideoTexture === true && texture.colorSpace !== NoColorSpace;
@@ -222,6 +213,12 @@ class WGSLNodeBuilder extends NodeBuilder {
222
213
 
223
214
  }
224
215
 
216
+ generateTextureStore( texture, textureProperty, uvIndexSnippet, valueSnippet ) {
217
+
218
+ return `textureStore( ${ textureProperty }, ${ uvIndexSnippet }, ${ valueSnippet } )`;
219
+
220
+ }
221
+
225
222
  isUnfilterable( texture ) {
226
223
 
227
224
  return texture.isDataTexture === true && texture.type === FloatType;
@@ -297,7 +294,7 @@ class WGSLNodeBuilder extends NodeBuilder {
297
294
  const name = node.name;
298
295
  const type = node.type;
299
296
 
300
- if ( type === 'texture' || type === 'cubeTexture' ) {
297
+ if ( type === 'texture' || type === 'cubeTexture' || type === 'storageTexture' ) {
301
298
 
302
299
  return name;
303
300
 
@@ -350,11 +347,11 @@ class WGSLNodeBuilder extends NodeBuilder {
350
347
 
351
348
  const bindings = this.bindings[ shaderStage ];
352
349
 
353
- if ( type === 'texture' || type === 'cubeTexture' ) {
350
+ if ( type === 'texture' || type === 'cubeTexture' || type === 'storageTexture' ) {
354
351
 
355
352
  let texture = null;
356
353
 
357
- if ( type === 'texture' ) {
354
+ if ( type === 'texture' || type === 'storageTexture' ) {
358
355
 
359
356
  texture = new NodeSampledTexture( uniformNode.name, uniformNode.node );
360
357
 
@@ -737,7 +734,7 @@ ${ flowData.code }
737
734
 
738
735
  for ( const uniform of uniforms ) {
739
736
 
740
- if ( uniform.type === 'texture' || uniform.type === 'cubeTexture' ) {
737
+ if ( uniform.type === 'texture' || uniform.type === 'cubeTexture' || uniform.type === 'storageTexture' ) {
741
738
 
742
739
  const texture = uniform.node.value;
743
740
 
@@ -936,15 +933,23 @@ ${ flowData.code }
936
933
 
937
934
  }
938
935
 
939
- getMethod( method ) {
936
+ getMethod( method, output = null ) {
940
937
 
941
- if ( wgslPolyfill[ method ] !== undefined ) {
938
+ let wgslMethod;
942
939
 
943
- this._include( method );
940
+ if ( output !== null ) {
941
+
942
+ wgslMethod = this._getWGSLMethod( method + '_' + output );
944
943
 
945
944
  }
946
945
 
947
- return wgslMethods[ method ] || method;
946
+ if ( wgslMethod === undefined ) {
947
+
948
+ wgslMethod = this._getWGSLMethod( method );
949
+
950
+ }
951
+
952
+ return wgslMethod || method;
948
953
 
949
954
  }
950
955
 
@@ -960,6 +965,18 @@ ${ flowData.code }
960
965
 
961
966
  }
962
967
 
968
+ _getWGSLMethod( method ) {
969
+
970
+ if ( wgslPolyfill[ method ] !== undefined ) {
971
+
972
+ this._include( method );
973
+
974
+ }
975
+
976
+ return wgslMethods[ method ];
977
+
978
+ }
979
+
963
980
  _include( name ) {
964
981
 
965
982
  const codeNode = wgslPolyfill[ name ];
@@ -42,7 +42,15 @@ class WebGPUAttributeUtils {
42
42
 
43
43
  const device = backend.device;
44
44
 
45
- const array = bufferAttribute.array;
45
+ let array = bufferAttribute.array;
46
+
47
+ if ( bufferAttribute.isStorageBufferAttribute && bufferAttribute.itemSize === 3 ) {
48
+
49
+ bufferAttribute.itemSize = 4;
50
+ array = new array.constructor( bufferAttribute.count * 4 );
51
+
52
+ }
53
+
46
54
  const size = array.byteLength + ( ( 4 - ( array.byteLength % 4 ) ) % 4 ); // ensure 4 byte alignment, see #20441
47
55
 
48
56
  buffer = device.createBuffer( {
@@ -23,7 +23,7 @@ class WebGPUPipelineUtils {
23
23
 
24
24
  }
25
25
 
26
- createRenderPipeline( renderObject ) {
26
+ createRenderPipeline( renderObject, promises ) {
27
27
 
28
28
  const { object, material, geometry, pipeline } = renderObject;
29
29
  const { vertexProgram, fragmentProgram } = pipeline;
@@ -102,9 +102,22 @@ class WebGPUPipelineUtils {
102
102
  const primitiveState = this._getPrimitiveState( object, geometry, material );
103
103
  const depthCompare = this._getDepthCompare( material );
104
104
  const depthStencilFormat = utils.getCurrentDepthStencilFormat( renderObject.context );
105
- const sampleCount = utils.getSampleCount( renderObject.context );
105
+ let sampleCount = utils.getSampleCount( renderObject.context );
106
106
 
107
- pipelineData.pipeline = device.createRenderPipeline( {
107
+ if ( sampleCount > 1 ) {
108
+
109
+ // WebGPU only supports power-of-two sample counts and 2 is not a valid value
110
+ sampleCount = Math.pow( 2, Math.floor( Math.log2( sampleCount ) ) );
111
+
112
+ if ( sampleCount === 2 ) {
113
+
114
+ sampleCount = 4;
115
+
116
+ }
117
+
118
+ }
119
+
120
+ const pipelineDescriptor = {
108
121
  vertex: Object.assign( {}, vertexModule, { buffers: vertexBuffers } ),
109
122
  fragment: Object.assign( {}, fragmentModule, { targets } ),
110
123
  primitive: primitiveState,
@@ -124,7 +137,28 @@ class WebGPUPipelineUtils {
124
137
  layout: device.createPipelineLayout( {
125
138
  bindGroupLayouts: [ bindingsData.layout ]
126
139
  } )
127
- } );
140
+ };
141
+
142
+ if ( promises === null ) {
143
+
144
+ pipelineData.pipeline = device.createRenderPipeline( pipelineDescriptor );
145
+
146
+ } else {
147
+
148
+ const p = new Promise( ( resolve /*, reject*/ ) => {
149
+
150
+ device.createRenderPipelineAsync( pipelineDescriptor ).then( pipeline => {
151
+
152
+ pipelineData.pipeline = pipeline;
153
+ resolve();
154
+
155
+ } );
156
+
157
+ } );
158
+
159
+ promises.push( p );
160
+
161
+ }
128
162
 
129
163
  }
130
164
 
@@ -113,7 +113,21 @@ class WebGPUTextureUtils {
113
113
  const dimension = this._getDimension( texture );
114
114
  const format = texture.internalFormat || getFormat( texture, backend.device );
115
115
 
116
- const sampleCount = options.sampleCount !== undefined ? options.sampleCount : 1;
116
+ let sampleCount = options.sampleCount !== undefined ? options.sampleCount : 1;
117
+
118
+ if ( sampleCount > 1 ) {
119
+
120
+ // WebGPU only supports power-of-two sample counts and 2 is not a valid value
121
+ sampleCount = Math.pow( 2, Math.floor( Math.log2( sampleCount ) ) );
122
+
123
+ if ( sampleCount === 2 ) {
124
+
125
+ sampleCount = 4;
126
+
127
+ }
128
+
129
+ }
130
+
117
131
  const primarySampleCount = texture.isRenderTargetTexture ? 1 : sampleCount;
118
132
 
119
133
  let usage = GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.COPY_SRC;
@@ -360,6 +374,9 @@ class WebGPUTextureUtils {
360
374
  const format = textureData.textureDescriptorGPU.format;
361
375
  const bytesPerTexel = this._getBytesPerTexel( format );
362
376
 
377
+ let bytesPerRow = width * bytesPerTexel;
378
+ bytesPerRow = Math.ceil( bytesPerRow / 256 ) * 256; // Align to 256 bytes
379
+
363
380
  const readBuffer = device.createBuffer(
364
381
  {
365
382
  size: width * height * bytesPerTexel,
@@ -376,7 +393,7 @@ class WebGPUTextureUtils {
376
393
  },
377
394
  {
378
395
  buffer: readBuffer,
379
- bytesPerRow: width * bytesPerTexel
396
+ bytesPerRow: bytesPerRow
380
397
  },
381
398
  {
382
399
  width: width,
@@ -665,15 +682,57 @@ class WebGPUTextureUtils {
665
682
 
666
683
  _getBytesPerTexel( format ) {
667
684
 
668
- if ( format === GPUTextureFormat.R8Unorm ) return 1;
669
- if ( format === GPUTextureFormat.R16Float ) return 2;
670
- if ( format === GPUTextureFormat.RG8Unorm ) return 2;
671
- if ( format === GPUTextureFormat.RG16Float ) return 4;
672
- if ( format === GPUTextureFormat.R32Float ) return 4;
673
- if ( format === GPUTextureFormat.RGBA8Unorm || format === GPUTextureFormat.RGBA8UnormSRGB ) return 4;
674
- if ( format === GPUTextureFormat.RG32Float ) return 8;
675
- if ( format === GPUTextureFormat.RGBA16Float ) return 8;
676
- if ( format === GPUTextureFormat.RGBA32Float ) return 16;
685
+ // 8-bit formats
686
+ if ( format === GPUTextureFormat.R8Unorm ||
687
+ format === GPUTextureFormat.R8Snorm ||
688
+ format === GPUTextureFormat.R8Uint ||
689
+ format === GPUTextureFormat.R8Sint ) return 1;
690
+
691
+ // 16-bit formats
692
+ if ( format === GPUTextureFormat.R16Uint ||
693
+ format === GPUTextureFormat.R16Sint ||
694
+ format === GPUTextureFormat.R16Float ||
695
+ format === GPUTextureFormat.RG8Unorm ||
696
+ format === GPUTextureFormat.RG8Snorm ||
697
+ format === GPUTextureFormat.RG8Uint ||
698
+ format === GPUTextureFormat.RG8Sint ) return 2;
699
+
700
+ // 32-bit formats
701
+ if ( format === GPUTextureFormat.R32Uint ||
702
+ format === GPUTextureFormat.R32Sint ||
703
+ format === GPUTextureFormat.R32Float ||
704
+ format === GPUTextureFormat.RG16Uint ||
705
+ format === GPUTextureFormat.RG16Sint ||
706
+ format === GPUTextureFormat.RG16Float ||
707
+ format === GPUTextureFormat.RGBA8Unorm ||
708
+ format === GPUTextureFormat.RGBA8UnormSRGB ||
709
+ format === GPUTextureFormat.RGBA8Snorm ||
710
+ format === GPUTextureFormat.RGBA8Uint ||
711
+ format === GPUTextureFormat.RGBA8Sint ||
712
+ format === GPUTextureFormat.BGRA8Unorm ||
713
+ format === GPUTextureFormat.BGRA8UnormSRGB ||
714
+ // Packed 32-bit formats
715
+ format === GPUTextureFormat.RGB9E5UFloat ||
716
+ format === GPUTextureFormat.RGB10A2Unorm ||
717
+ format === GPUTextureFormat.RG11B10UFloat ||
718
+ format === GPUTextureFormat.Depth32Float ||
719
+ format === GPUTextureFormat.Depth24Plus ||
720
+ format === GPUTextureFormat.Depth24PlusStencil8 ||
721
+ format === GPUTextureFormat.Depth32FloatStencil8 ) return 4;
722
+
723
+ // 64-bit formats
724
+ if ( format === GPUTextureFormat.RG32Uint ||
725
+ format === GPUTextureFormat.RG32Sint ||
726
+ format === GPUTextureFormat.RG32Float ||
727
+ format === GPUTextureFormat.RGBA16Uint ||
728
+ format === GPUTextureFormat.RGBA16Sint ||
729
+ format === GPUTextureFormat.RGBA16Float ) return 8;
730
+
731
+ // 128-bit formats
732
+ if ( format === GPUTextureFormat.RGBA32Uint ||
733
+ format === GPUTextureFormat.RGBA32Sint ||
734
+ format === GPUTextureFormat.RGBA32Float ) return 16;
735
+
677
736
 
678
737
  }
679
738
 
@@ -699,6 +758,9 @@ class WebGPUTextureUtils {
699
758
  if ( format === GPUTextureFormat.RG16Sint ) return Int16Array;
700
759
  if ( format === GPUTextureFormat.RGBA16Uint ) return Uint16Array;
701
760
  if ( format === GPUTextureFormat.RGBA16Sint ) return Int16Array;
761
+ if ( format === GPUTextureFormat.R16Float ) return Float32Array;
762
+ if ( format === GPUTextureFormat.RG16Float ) return Float32Array;
763
+ if ( format === GPUTextureFormat.RGBA16Float ) return Float32Array;
702
764
 
703
765
 
704
766
  if ( format === GPUTextureFormat.R32Uint ) return Uint32Array;
@@ -711,6 +773,17 @@ class WebGPUTextureUtils {
711
773
  if ( format === GPUTextureFormat.RGBA32Sint ) return Int32Array;
712
774
  if ( format === GPUTextureFormat.RGBA32Float ) return Float32Array;
713
775
 
776
+ if ( format === GPUTextureFormat.BGRA8Unorm ) return Uint8Array;
777
+ if ( format === GPUTextureFormat.BGRA8UnormSRGB ) return Uint8Array;
778
+ if ( format === GPUTextureFormat.RGB10A2Unorm ) return Uint32Array;
779
+ if ( format === GPUTextureFormat.RGB9E5UFloat ) return Uint32Array;
780
+ if ( format === GPUTextureFormat.RG11B10UFloat ) return Uint32Array;
781
+
782
+ if ( format === GPUTextureFormat.Depth32Float ) return Float32Array;
783
+ if ( format === GPUTextureFormat.Depth24Plus ) return Uint32Array;
784
+ if ( format === GPUTextureFormat.Depth24PlusStencil8 ) return Uint32Array;
785
+ if ( format === GPUTextureFormat.Depth32FloatStencil8 ) return Float32Array;
786
+
714
787
  }
715
788
 
716
789
  _getDimension( texture ) {
@@ -741,7 +814,7 @@ export function getFormat( texture, device = null ) {
741
814
 
742
815
  let formatGPU;
743
816
 
744
- if ( /*texture.isRenderTargetTexture === true ||*/ texture.isFramebufferTexture === true ) {
817
+ if ( texture.isFramebufferTexture === true && texture.type === UnsignedByteType ) {
745
818
 
746
819
  formatGPU = GPUTextureFormat.BGRA8Unorm;
747
820
 
@@ -267,4 +267,4 @@ export class For {
267
267
 
268
268
  }
269
269
 
270
- }
270
+ }
@@ -938,4 +938,4 @@ class GLSLDecoder {
938
938
 
939
939
  }
940
940
 
941
- export default GLSLDecoder;
941
+ export default GLSLDecoder;
@@ -46,4 +46,4 @@ class ShaderToyDecoder extends GLSLDecoder {
46
46
 
47
47
  }
48
48
 
49
- export default ShaderToyDecoder;
49
+ export default ShaderToyDecoder;
@@ -712,4 +712,4 @@ ${ this.tab }} );\n\n`;
712
712
 
713
713
  }
714
714
 
715
- export default TSLEncoder;
715
+ export default TSLEncoder;
@@ -311,13 +311,6 @@ function mergeAttributes( attributes ) {
311
311
 
312
312
  const attribute = attributes[ i ];
313
313
 
314
- if ( attribute.isInterleavedBufferAttribute ) {
315
-
316
- console.error( 'THREE.BufferGeometryUtils: .mergeAttributes() failed. InterleavedBufferAttributes are not supported.' );
317
- return null;
318
-
319
- }
320
-
321
314
  if ( TypedArray === undefined ) TypedArray = attribute.array.constructor;
322
315
  if ( TypedArray !== attribute.array.constructor ) {
323
316
 
@@ -350,22 +343,41 @@ function mergeAttributes( attributes ) {
350
343
 
351
344
  }
352
345
 
353
- arrayLength += attribute.array.length;
346
+ arrayLength += attribute.count * itemSize;
354
347
 
355
348
  }
356
349
 
357
350
  const array = new TypedArray( arrayLength );
351
+ const result = new BufferAttribute( array, itemSize, normalized );
358
352
  let offset = 0;
359
353
 
360
354
  for ( let i = 0; i < attributes.length; ++ i ) {
361
355
 
362
- array.set( attributes[ i ].array, offset );
356
+ const attribute = attributes[ i ];
357
+ if ( attribute.isInterleavedBufferAttribute ) {
358
+
359
+ const tupleOffset = offset / itemSize;
360
+ for ( let j = 0, l = attribute.count; j < l; j ++ ) {
361
+
362
+ for ( let c = 0; c < itemSize; c ++ ) {
363
363
 
364
- offset += attributes[ i ].array.length;
364
+ const value = attribute.getComponent( j, c );
365
+ result.setComponent( j + tupleOffset, c, value );
366
+
367
+ }
368
+
369
+ }
370
+
371
+ } else {
372
+
373
+ array.set( attribute.array, offset );
374
+
375
+ }
376
+
377
+ offset += attribute.count * itemSize;
365
378
 
366
379
  }
367
380
 
368
- const result = new BufferAttribute( array, itemSize, normalized );
369
381
  if ( gpuType !== undefined ) {
370
382
 
371
383
  result.gpuType = gpuType;
@@ -1345,26 +1357,10 @@ function toCreasedNormals( geometry, creaseAngle = Math.PI / 3 /* 60 degrees */
1345
1357
 
1346
1358
  }
1347
1359
 
1348
- function mergeBufferGeometries( geometries, useGroups = false ) {
1349
-
1350
- console.warn( 'THREE.BufferGeometryUtils: mergeBufferGeometries() has been renamed to mergeGeometries().' ); // @deprecated, r151
1351
- return mergeGeometries( geometries, useGroups );
1352
-
1353
- }
1354
-
1355
- function mergeBufferAttributes( attributes ) {
1356
-
1357
- console.warn( 'THREE.BufferGeometryUtils: mergeBufferAttributes() has been renamed to mergeAttributes().' ); // @deprecated, r151
1358
- return mergeAttributes( attributes );
1359
-
1360
- }
1361
-
1362
1360
  export {
1363
1361
  computeMikkTSpaceTangents,
1364
1362
  mergeGeometries,
1365
- mergeBufferGeometries,
1366
1363
  mergeAttributes,
1367
- mergeBufferAttributes,
1368
1364
  interleaveAttributes,
1369
1365
  estimateBytesUsed,
1370
1366
  mergeVertices,
@@ -13,8 +13,10 @@ const bins_buffer = new ArrayBuffer( ( ITERATIONS + 1 ) * BIN_SIZE * 4 );
13
13
 
14
14
  let c = 0;
15
15
  for ( let i = 0; i < ( ITERATIONS + 1 ); i ++ ) {
16
+
16
17
  bins[ i ] = new Uint32Array( bins_buffer, c, BIN_SIZE );
17
18
  c += BIN_SIZE * 4;
19
+
18
20
  }
19
21
 
20
22
  const defaultGet = ( el ) => el;
@@ -107,7 +107,12 @@ class ARButton {
107
107
  if ( navigator.xr.offerSession !== undefined ) {
108
108
 
109
109
  navigator.xr.offerSession( 'immersive-ar', sessionInit )
110
- .then( onSessionStarted );
110
+ .then( onSessionStarted )
111
+ .catch( ( err ) => {
112
+
113
+ console.warn( err );
114
+
115
+ } );
111
116
 
112
117
  }
113
118
 
@@ -118,7 +123,12 @@ class ARButton {
118
123
  if ( navigator.xr.offerSession !== undefined ) {
119
124
 
120
125
  navigator.xr.offerSession( 'immersive-ar', sessionInit )
121
- .then( onSessionStarted );
126
+ .then( onSessionStarted )
127
+ .catch( ( err ) => {
128
+
129
+ console.warn( err );
130
+
131
+ } );
122
132
 
123
133
  }
124
134
 
@@ -73,7 +73,12 @@ class VRButton {
73
73
  if ( navigator.xr.offerSession !== undefined ) {
74
74
 
75
75
  navigator.xr.offerSession( 'immersive-vr', sessionInit )
76
- .then( onSessionStarted );
76
+ .then( onSessionStarted )
77
+ .catch( ( err ) => {
78
+
79
+ console.warn( err );
80
+
81
+ } );
77
82
 
78
83
  }
79
84
 
@@ -84,7 +89,12 @@ class VRButton {
84
89
  if ( navigator.xr.offerSession !== undefined ) {
85
90
 
86
91
  navigator.xr.offerSession( 'immersive-vr', sessionInit )
87
- .then( onSessionStarted );
92
+ .then( onSessionStarted )
93
+ .catch( ( err ) => {
94
+
95
+ console.warn( err );
96
+
97
+ } );
88
98
 
89
99
  }
90
100
 
@@ -77,7 +77,12 @@ class XRButton {
77
77
  if ( navigator.xr.offerSession !== undefined ) {
78
78
 
79
79
  navigator.xr.offerSession( mode, sessionOptions )
80
- .then( onSessionStarted );
80
+ .then( onSessionStarted )
81
+ .catch( ( err ) => {
82
+
83
+ console.warn( err );
84
+
85
+ } );
81
86
 
82
87
  }
83
88
 
@@ -88,7 +93,12 @@ class XRButton {
88
93
  if ( navigator.xr.offerSession !== undefined ) {
89
94
 
90
95
  navigator.xr.offerSession( mode, sessionOptions )
91
- .then( onSessionStarted );
96
+ .then( onSessionStarted )
97
+ .catch( ( err ) => {
98
+
99
+ console.warn( err );
100
+
101
+ } );
92
102
 
93
103
  }
94
104
 
@@ -206,11 +206,12 @@ function addAssetSceneToControllerModel( controllerModel, scene ) {
206
206
 
207
207
  class XRControllerModelFactory {
208
208
 
209
- constructor( gltfLoader = null ) {
209
+ constructor( gltfLoader = null, onLoad = null ) {
210
210
 
211
211
  this.gltfLoader = gltfLoader;
212
212
  this.path = DEFAULT_PROFILES_PATH;
213
213
  this._assetCache = {};
214
+ this.onLoad = onLoad;
214
215
 
215
216
  // If a GLTFLoader wasn't supplied to the constructor create a new one.
216
217
  if ( ! this.gltfLoader ) {
@@ -247,6 +248,8 @@ class XRControllerModelFactory {
247
248
 
248
249
  addAssetSceneToControllerModel( controllerModel, scene );
249
250
 
251
+ if ( this.onLoad ) this.onLoad( scene );
252
+
250
253
  } else {
251
254
 
252
255
  if ( ! this.gltfLoader ) {
@@ -264,6 +267,8 @@ class XRControllerModelFactory {
264
267
 
265
268
  addAssetSceneToControllerModel( controllerModel, scene );
266
269
 
270
+ if ( this.onLoad ) this.onLoad( scene );
271
+
267
272
  },
268
273
  null,
269
274
  () => {
@@ -4,7 +4,7 @@ const DEFAULT_HAND_PROFILE_PATH = 'https://cdn.jsdelivr.net/npm/@webxr-input-pro
4
4
 
5
5
  class XRHandMeshModel {
6
6
 
7
- constructor( handModel, controller, path, handedness, loader = null ) {
7
+ constructor( handModel, controller, path, handedness, loader = null, onLoad = null ) {
8
8
 
9
9
  this.controller = controller;
10
10
  this.handModel = handModel;
@@ -74,6 +74,8 @@ class XRHandMeshModel {
74
74
 
75
75
  } );
76
76
 
77
+ if ( onLoad ) onLoad( object );
78
+
77
79
  } );
78
80
 
79
81
  }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "super-three",
3
- "version": "0.160.1",
3
+ "version": "0.161.0",
4
4
  "description": "JavaScript 3D library",
5
5
  "type": "module",
6
- "main": "./build/three.js",
6
+ "main": "./build/three.cjs",
7
7
  "module": "./build/three.module.js",
8
8
  "exports": {
9
9
  ".": {