super-three 0.164.0 → 0.165.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 (124) hide show
  1. package/README.md +3 -3
  2. package/build/three.cjs +664 -217
  3. package/build/three.module.js +664 -217
  4. package/build/three.module.min.js +1 -1
  5. package/examples/jsm/controls/TransformControls.js +1 -1
  6. package/examples/jsm/environments/RoomEnvironment.js +1 -5
  7. package/examples/jsm/exporters/GLTFExporter.js +1 -1
  8. package/examples/jsm/exporters/USDZExporter.js +6 -4
  9. package/examples/jsm/helpers/ViewHelper.js +32 -67
  10. package/examples/jsm/libs/tween.module.js +75 -64
  11. package/examples/jsm/lines/LineMaterial.js +1 -15
  12. package/examples/jsm/lines/LineSegments2.js +15 -0
  13. package/examples/jsm/lines/Wireframe.js +16 -1
  14. package/examples/jsm/loaders/DRACOLoader.js +1 -1
  15. package/examples/jsm/loaders/FBXLoader.js +24 -13
  16. package/examples/jsm/loaders/GLTFLoader.js +2 -0
  17. package/examples/jsm/loaders/LDrawLoader.js +3 -2
  18. package/examples/jsm/loaders/MMDLoader.js +31 -12
  19. package/examples/jsm/modifiers/CurveModifier.js +11 -9
  20. package/examples/jsm/nodes/Nodes.js +12 -11
  21. package/examples/jsm/nodes/accessors/BitangentNode.js +7 -83
  22. package/examples/jsm/nodes/accessors/BufferNode.js +6 -0
  23. package/examples/jsm/nodes/accessors/CameraNode.js +12 -119
  24. package/examples/jsm/nodes/accessors/MaterialNode.js +2 -0
  25. package/examples/jsm/nodes/accessors/ModelNode.js +3 -0
  26. package/examples/jsm/nodes/accessors/NormalNode.js +9 -101
  27. package/examples/jsm/nodes/accessors/PositionNode.js +6 -100
  28. package/examples/jsm/nodes/accessors/ReferenceNode.js +6 -0
  29. package/examples/jsm/nodes/accessors/ReflectVectorNode.js +2 -31
  30. package/examples/jsm/nodes/accessors/{TextureStoreNode.js → StorageTextureNode.js} +19 -6
  31. package/examples/jsm/nodes/accessors/TangentNode.js +11 -97
  32. package/examples/jsm/nodes/accessors/Texture3DNode.js +100 -0
  33. package/examples/jsm/nodes/accessors/UVNode.js +2 -46
  34. package/examples/jsm/nodes/core/AttributeNode.js +15 -3
  35. package/examples/jsm/nodes/core/ContextNode.js +6 -0
  36. package/examples/jsm/nodes/core/Node.js +15 -2
  37. package/examples/jsm/nodes/core/NodeBuilder.js +20 -9
  38. package/examples/jsm/nodes/core/NodeKeywords.js +1 -1
  39. package/examples/jsm/nodes/core/OutputStructNode.js +1 -5
  40. package/examples/jsm/nodes/core/PropertyNode.js +1 -0
  41. package/examples/jsm/nodes/core/VaryingNode.js +40 -9
  42. package/examples/jsm/nodes/display/AfterImageNode.js +14 -2
  43. package/examples/jsm/nodes/display/PassNode.js +3 -1
  44. package/examples/jsm/nodes/display/ViewportNode.js +1 -1
  45. package/examples/jsm/nodes/functions/PhysicalLightingModel.js +61 -17
  46. package/examples/jsm/nodes/functions/ToonLightingModel.js +49 -0
  47. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +2 -1
  48. package/examples/jsm/nodes/lighting/LightsNode.js +17 -0
  49. package/examples/jsm/nodes/materials/Line2NodeMaterial.js +1 -1
  50. package/examples/jsm/nodes/materials/Materials.js +3 -0
  51. package/examples/jsm/nodes/materials/MeshMatcapNodeMaterial.js +52 -0
  52. package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +21 -4
  53. package/examples/jsm/nodes/materials/MeshToonNodeMaterial.js +34 -0
  54. package/examples/jsm/nodes/materials/NodeMaterial.js +13 -5
  55. package/examples/jsm/nodes/materials/VolumeNodeMaterial.js +106 -0
  56. package/examples/jsm/nodes/math/HashNode.js +2 -2
  57. package/examples/jsm/nodes/shadernode/ShaderNode.js +55 -33
  58. package/examples/jsm/nodes/utils/ArrayElementNode.js +1 -1
  59. package/examples/jsm/nodes/utils/MatcapUVNode.js +1 -1
  60. package/examples/jsm/nodes/utils/TimerNode.js +1 -1
  61. package/examples/jsm/objects/Lensflare.js +2 -2
  62. package/examples/jsm/postprocessing/RenderPass.js +1 -1
  63. package/examples/jsm/renderers/CSS2DRenderer.js +25 -5
  64. package/examples/jsm/renderers/CSS3DRenderer.js +24 -3
  65. package/examples/jsm/renderers/common/Attributes.js +2 -0
  66. package/examples/jsm/renderers/common/Bindings.js +17 -0
  67. package/examples/jsm/renderers/common/ChainMap.js +18 -48
  68. package/examples/jsm/renderers/common/ClippingContext.js +4 -4
  69. package/examples/jsm/renderers/common/Pipelines.js +2 -2
  70. package/examples/jsm/renderers/common/RenderBundle.js +18 -0
  71. package/examples/jsm/renderers/common/RenderBundles.js +38 -0
  72. package/examples/jsm/renderers/common/RenderList.js +9 -0
  73. package/examples/jsm/renderers/common/RenderObject.js +6 -0
  74. package/examples/jsm/renderers/common/Renderer.js +139 -11
  75. package/examples/jsm/renderers/common/Uniform.js +1 -1
  76. package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +18 -4
  77. package/examples/jsm/renderers/common/nodes/NodeSampler.js +6 -0
  78. package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +17 -5
  79. package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +93 -6
  80. package/examples/jsm/renderers/webgpu/WebGPUBackend.js +50 -4
  81. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +69 -11
  82. package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +10 -1
  83. package/examples/jsm/renderers/webgpu/utils/WebGPUConstants.js +6 -0
  84. package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +62 -19
  85. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +62 -3
  86. package/examples/jsm/utils/BufferGeometryUtils.js +18 -16
  87. package/examples/jsm/utils/GPUStatsPanel.js +2 -0
  88. package/examples/jsm/utils/SortUtils.js +8 -5
  89. package/package.json +3 -2
  90. package/src/animation/tracks/BooleanKeyframeTrack.js +10 -1
  91. package/src/animation/tracks/QuaternionKeyframeTrack.js +1 -2
  92. package/src/animation/tracks/StringKeyframeTrack.js +10 -1
  93. package/src/constants.js +1 -1
  94. package/src/core/Object3D.js +2 -0
  95. package/src/core/Raycaster.js +6 -2
  96. package/src/loaders/FileLoader.js +4 -0
  97. package/src/loaders/LoaderUtils.js +3 -1
  98. package/src/loaders/ObjectLoader.js +1 -0
  99. package/src/objects/BatchedMesh.js +91 -1
  100. package/src/renderers/WebGLRenderer.js +288 -57
  101. package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +15 -0
  102. package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -1
  103. package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +9 -1
  104. package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +8 -22
  105. package/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js +1 -1
  106. package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +1 -1
  107. package/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js +3 -14
  108. package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +10 -31
  109. package/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js +3 -23
  110. package/src/renderers/webgl/WebGLBackground.js +6 -0
  111. package/src/renderers/webgl/WebGLExtensions.js +3 -1
  112. package/src/renderers/webgl/WebGLLights.js +9 -12
  113. package/src/renderers/webgl/WebGLMaterials.js +1 -5
  114. package/src/renderers/webgl/WebGLMorphtargets.js +1 -2
  115. package/src/renderers/webgl/WebGLProgram.js +2 -31
  116. package/src/renderers/webgl/WebGLPrograms.js +14 -14
  117. package/src/renderers/webgl/WebGLRenderStates.js +2 -2
  118. package/src/renderers/webgl/WebGLTextures.js +139 -70
  119. package/src/renderers/webxr/WebXRDepthSensing.js +3 -3
  120. package/src/renderers/webxr/WebXRManager.js +6 -2
  121. package/src/textures/CompressedArrayTexture.js +14 -0
  122. package/src/textures/DataArrayTexture.js +14 -0
  123. package/src/textures/DepthTexture.js +1 -3
  124. package/src/utils.js +30 -1
@@ -3,7 +3,7 @@ import { NoColorSpace, FloatType } from 'three';
3
3
  import NodeUniformsGroup from '../../common/nodes/NodeUniformsGroup.js';
4
4
 
5
5
  import NodeSampler from '../../common/nodes/NodeSampler.js';
6
- import { NodeSampledTexture, NodeSampledCubeTexture } from '../../common/nodes/NodeSampledTexture.js';
6
+ import { NodeSampledTexture, NodeSampledCubeTexture, NodeSampledTexture3D } from '../../common/nodes/NodeSampledTexture.js';
7
7
 
8
8
  import NodeUniformBuffer from '../../common/nodes/NodeUniformBuffer.js';
9
9
  import NodeStorageBuffer from '../../common/nodes/NodeStorageBuffer.js';
@@ -13,6 +13,8 @@ import { NodeBuilder, CodeNode } from '../../../nodes/Nodes.js';
13
13
  import { getFormat } from '../utils/WebGPUTextureUtils.js';
14
14
 
15
15
  import WGSLNodeParser from './WGSLNodeParser.js';
16
+ import { GPUStorageTextureAccess } from '../utils/WebGPUConstants.js';
17
+
16
18
 
17
19
  // GPUShaderStage is not defined in browsers not supporting WebGPU
18
20
  const GPUShaderStage = self.GPUShaderStage;
@@ -316,7 +318,7 @@ class WGSLNodeBuilder extends NodeBuilder {
316
318
  const name = node.name;
317
319
  const type = node.type;
318
320
 
319
- if ( type === 'texture' || type === 'cubeTexture' || type === 'storageTexture' ) {
321
+ if ( type === 'texture' || type === 'cubeTexture' || type === 'storageTexture' || type === 'texture3D' ) {
320
322
 
321
323
  return name;
322
324
 
@@ -336,6 +338,12 @@ class WGSLNodeBuilder extends NodeBuilder {
336
338
 
337
339
  }
338
340
 
341
+ getOutputStructName() {
342
+
343
+ return 'output';
344
+
345
+ }
346
+
339
347
  _getUniformGroupCount( shaderStage ) {
340
348
 
341
349
  return Object.keys( this.uniforms[ shaderStage ] ).length;
@@ -358,6 +366,41 @@ class WGSLNodeBuilder extends NodeBuilder {
358
366
 
359
367
  }
360
368
 
369
+ getStorageAccess( node ) {
370
+
371
+ if ( node.isStorageTextureNode ) {
372
+
373
+ switch ( node.access ) {
374
+
375
+ case GPUStorageTextureAccess.ReadOnly: {
376
+
377
+ return 'read';
378
+
379
+ }
380
+
381
+ case GPUStorageTextureAccess.WriteOnly: {
382
+
383
+ return 'write';
384
+
385
+ }
386
+
387
+ default: {
388
+
389
+ return 'read_write';
390
+
391
+ }
392
+
393
+ }
394
+
395
+ } else {
396
+
397
+ // @TODO: Account for future read-only storage buffer pull request
398
+ return 'read_write';
399
+
400
+ }
401
+
402
+ }
403
+
361
404
  getUniformFromNode( node, type, shaderStage, name = null ) {
362
405
 
363
406
  const uniformNode = super.getUniformFromNode( node, type, shaderStage, name );
@@ -369,21 +412,25 @@ class WGSLNodeBuilder extends NodeBuilder {
369
412
 
370
413
  const bindings = this.bindings[ shaderStage ];
371
414
 
372
- if ( type === 'texture' || type === 'cubeTexture' || type === 'storageTexture' ) {
415
+ if ( type === 'texture' || type === 'cubeTexture' || type === 'storageTexture' || type === 'texture3D' ) {
373
416
 
374
417
  let texture = null;
375
418
 
376
419
  if ( type === 'texture' || type === 'storageTexture' ) {
377
420
 
378
- texture = new NodeSampledTexture( uniformNode.name, uniformNode.node );
421
+ texture = new NodeSampledTexture( uniformNode.name, uniformNode.node, node.access ? node.access : null );
379
422
 
380
423
  } else if ( type === 'cubeTexture' ) {
381
424
 
382
- texture = new NodeSampledCubeTexture( uniformNode.name, uniformNode.node );
425
+ texture = new NodeSampledCubeTexture( uniformNode.name, uniformNode.node, node.access ? node.access : null );
426
+
427
+ } else if ( type === 'texture3D' ) {
428
+
429
+ texture = new NodeSampledTexture3D( uniformNode.name, uniformNode.node, node.access ? node.access : null );
383
430
 
384
431
  }
385
432
 
386
- texture.store = node.isStoreTextureNode === true;
433
+ texture.store = node.isStorageTextureNode === true;
387
434
  texture.setVisibility( gpuShaderStageLib[ shaderStage ] );
388
435
 
389
436
  if ( shaderStage === 'fragment' && this.isUnfilterable( node.value ) === false && texture.store === false ) {
@@ -455,7 +502,7 @@ class WGSLNodeBuilder extends NodeBuilder {
455
502
 
456
503
  isReference( type ) {
457
504
 
458
- return super.isReference( type ) || type === 'texture_2d' || type === 'texture_cube' || type === 'texture_depth_2d' || type === 'texture_storage_2d';
505
+ return super.isReference( type ) || type === 'texture_2d' || type === 'texture_cube' || type === 'texture_depth_2d' || type === 'texture_storage_2d' || type === 'texture_3d';
459
506
 
460
507
  }
461
508
 
@@ -618,6 +665,10 @@ ${ flowData.code }
618
665
 
619
666
  }
620
667
 
668
+ const builtins = this.getBuiltins( 'output' );
669
+
670
+ if ( builtins ) snippets.push( builtins );
671
+
621
672
  return snippets.join( ',\n' );
622
673
 
623
674
  }
@@ -638,6 +689,8 @@ ${ flowData.code }
638
689
 
639
690
  snippets.push( snippet );
640
691
 
692
+ snippets.push( `\nvar<private> output : ${ name };\n\n`);
693
+
641
694
  }
642
695
 
643
696
  return snippets.join( '\n\n' );
@@ -734,11 +787,11 @@ ${ flowData.code }
734
787
 
735
788
  for ( const uniform of uniforms ) {
736
789
 
737
- if ( uniform.type === 'texture' || uniform.type === 'cubeTexture' || uniform.type === 'storageTexture' ) {
790
+ if ( uniform.type === 'texture' || uniform.type === 'cubeTexture' || uniform.type === 'storageTexture' || uniform.type === 'texture3D' ) {
738
791
 
739
792
  const texture = uniform.node.value;
740
793
 
741
- if ( shaderStage === 'fragment' && this.isUnfilterable( texture ) === false && uniform.node.isStoreTextureNode !== true ) {
794
+ if ( shaderStage === 'fragment' && this.isUnfilterable( texture ) === false && uniform.node.isStorageTextureNode !== true ) {
742
795
 
743
796
  if ( texture.isDepthTexture === true && texture.compareFunction !== null ) {
744
797
 
@@ -770,11 +823,16 @@ ${ flowData.code }
770
823
 
771
824
  textureType = 'texture_external';
772
825
 
773
- } else if ( uniform.node.isStoreTextureNode === true ) {
826
+ } else if ( texture.isData3DTexture === true ) {
827
+
828
+ textureType = 'texture_3d<f32>';
829
+
830
+ } else if ( uniform.node.isStorageTextureNode === true ) {
774
831
 
775
832
  const format = getFormat( texture );
833
+ const access = this.getStorageAccess( uniform.node );
776
834
 
777
- textureType = `texture_storage_2d<${ format }, write>`;
835
+ textureType = `texture_storage_2d<${ format }, ${access}>`;
778
836
 
779
837
  } else {
780
838
 
@@ -62,8 +62,9 @@ class WebGPUBindingUtils {
62
62
  } else if ( binding.isSampledTexture && binding.store ) {
63
63
 
64
64
  const format = this.backend.get( binding.texture ).texture.format;
65
+ const access = binding.access;
65
66
 
66
- bindingGPU.storageTexture = { format }; // GPUStorageTextureBindingLayout
67
+ bindingGPU.storageTexture = { format, access }; // GPUStorageTextureBindingLayout
67
68
 
68
69
  } else if ( binding.isSampledTexture ) {
69
70
 
@@ -103,6 +104,10 @@ class WebGPUBindingUtils {
103
104
 
104
105
  texture.viewDimension = GPUTextureViewDimension.TwoDArray;
105
106
 
107
+ } else if ( binding.isSampledTexture3D ) {
108
+
109
+ texture.viewDimension = GPUTextureViewDimension.ThreeD;
110
+
106
111
  }
107
112
 
108
113
  bindingGPU.texture = texture;
@@ -214,6 +219,10 @@ class WebGPUBindingUtils {
214
219
 
215
220
  dimensionViewGPU = GPUTextureViewDimension.Cube;
216
221
 
222
+ } else if ( binding.isSampledTexture3D ) {
223
+
224
+ dimensionViewGPU = GPUTextureViewDimension.ThreeD;
225
+
217
226
  } else if ( binding.texture.isDataArrayTexture ) {
218
227
 
219
228
  dimensionViewGPU = GPUTextureViewDimension.TwoDArray;
@@ -269,6 +269,12 @@ export const GPUBufferBindingType = {
269
269
  ReadOnlyStorage: 'read-only-storage'
270
270
  };
271
271
 
272
+ export const GPUStorageTextureAccess = {
273
+ WriteOnly: 'write-only',
274
+ ReadOnly: 'read-only',
275
+ ReadWrite: 'read-write',
276
+ };
277
+
272
278
  export const GPUSamplerBindingType = {
273
279
  Filtering: 'filtering',
274
280
  NonFiltering: 'non-filtering',
@@ -23,6 +23,27 @@ class WebGPUPipelineUtils {
23
23
 
24
24
  }
25
25
 
26
+ _getSampleCount( renderObjectContext ) {
27
+
28
+ let sampleCount = this.backend.utils.getSampleCount( renderObjectContext );
29
+
30
+ if ( sampleCount > 1 ) {
31
+
32
+ // WebGPU only supports power-of-two sample counts and 2 is not a valid value
33
+ sampleCount = Math.pow( 2, Math.floor( Math.log2( sampleCount ) ) );
34
+
35
+ if ( sampleCount === 2 ) {
36
+
37
+ sampleCount = 4;
38
+
39
+ }
40
+
41
+ }
42
+
43
+ return sampleCount;
44
+
45
+ }
46
+
26
47
  createRenderPipeline( renderObject, promises ) {
27
48
 
28
49
  const { object, material, geometry, pipeline } = renderObject;
@@ -102,22 +123,11 @@ class WebGPUPipelineUtils {
102
123
  const primitiveState = this._getPrimitiveState( object, geometry, material );
103
124
  const depthCompare = this._getDepthCompare( material );
104
125
  const depthStencilFormat = utils.getCurrentDepthStencilFormat( renderObject.context );
105
- let sampleCount = utils.getSampleCount( renderObject.context );
106
-
107
- if ( sampleCount > 1 ) {
108
126
 
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
- }
127
+ const sampleCount = this._getSampleCount( renderObject.context );
119
128
 
120
129
  const pipelineDescriptor = {
130
+ label: 'renderPipeline',
121
131
  vertex: Object.assign( {}, vertexModule, { buffers: vertexBuffers } ),
122
132
  fragment: Object.assign( {}, fragmentModule, { targets } ),
123
133
  primitive: primitiveState,
@@ -162,6 +172,35 @@ class WebGPUPipelineUtils {
162
172
 
163
173
  }
164
174
 
175
+ createBundleEncoder( renderContext, renderObject ) {
176
+
177
+ const backend = this.backend;
178
+ const { utils, device } = backend;
179
+
180
+ const renderContextData = backend.get( renderContext );
181
+ const renderObjectData = backend.get( renderObject );
182
+
183
+ const depthStencilFormat = utils.getCurrentDepthStencilFormat( renderContext );
184
+ const colorFormat = utils.getCurrentColorFormat( renderContext );
185
+ const sampleCount = this._getSampleCount( renderObject.context );
186
+
187
+ const descriptor = {
188
+ label: 'renderBundleEncoder',
189
+ colorFormats: [ colorFormat ],
190
+ depthStencilFormat,
191
+ sampleCount
192
+ };
193
+
194
+ const bundleEncoder = device.createRenderBundleEncoder( descriptor );
195
+
196
+ renderObjectData.bundleEncoder = bundleEncoder;
197
+ renderContextData.currentSets = { attributes: {} };
198
+ renderContextData._renderBundleViewport = renderContext.width + '_' + renderContext.height;
199
+
200
+ return bundleEncoder;
201
+
202
+ }
203
+
165
204
  createComputePipeline( pipeline, bindings ) {
166
205
 
167
206
  const backend = this.backend;
@@ -186,17 +225,21 @@ class WebGPUPipelineUtils {
186
225
  let color, alpha;
187
226
 
188
227
  const blending = material.blending;
228
+ const blendSrc = material.blendSrc;
229
+ const blendDst = material.blendDst;
230
+ const blendEquation = material.blendEquation;
231
+
189
232
 
190
233
  if ( blending === CustomBlending ) {
191
234
 
192
- const blendSrcAlpha = material.blendSrcAlpha !== null ? material.blendSrcAlpha : GPUBlendFactor.One;
193
- const blendDstAlpha = material.blendDstAlpha !== null ? material.blendDstAlpha : GPUBlendFactor.Zero;
194
- const blendEquationAlpha = material.blendEquationAlpha !== null ? material.blendEquationAlpha : GPUBlendFactor.Add;
235
+ const blendSrcAlpha = material.blendSrcAlpha !== null ? material.blendSrcAlpha : blendSrc;
236
+ const blendDstAlpha = material.blendDstAlpha !== null ? material.blendDstAlpha : blendDst;
237
+ const blendEquationAlpha = material.blendEquationAlpha !== null ? material.blendEquationAlpha : blendEquation;
195
238
 
196
239
  color = {
197
- srcFactor: this._getBlendFactor( material.blendSrc ),
198
- dstFactor: this._getBlendFactor( material.blendDst ),
199
- operation: this._getBlendOperation( material.blendEquation )
240
+ srcFactor: this._getBlendFactor( blendSrc ),
241
+ dstFactor: this._getBlendFactor( blendDst ),
242
+ operation: this._getBlendOperation( blendEquation )
200
243
  };
201
244
 
202
245
  alpha = {
@@ -3,7 +3,7 @@ import {
3
3
  } from './WebGPUConstants.js';
4
4
 
5
5
  import {
6
- CubeTexture, Texture,
6
+ ByteType, ShortType, CubeTexture, Texture,
7
7
  NearestFilter, NearestMipmapNearestFilter, NearestMipmapLinearFilter,
8
8
  RepeatWrapping, MirroredRepeatWrapping,
9
9
  RGB_ETC2_Format, RGBA_ETC2_EAC_Format,
@@ -327,11 +327,11 @@ class WebGPUTextureUtils {
327
327
 
328
328
  // transfer texture data
329
329
 
330
- if ( texture.isDataTexture || texture.isData3DTexture ) {
330
+ if ( texture.isDataTexture ) {
331
331
 
332
332
  this._copyBufferToTexture( options.image, textureData.texture, textureDescriptorGPU, 0, texture.flipY );
333
333
 
334
- } else if ( texture.isDataArrayTexture ) {
334
+ } else if ( texture.isDataArrayTexture || texture.isData3DTexture ) {
335
335
 
336
336
  for ( let i = 0; i < options.image.depth; i ++ ) {
337
337
 
@@ -913,6 +913,25 @@ export function getFormat( texture, device = null ) {
913
913
 
914
914
  switch ( type ) {
915
915
 
916
+ case ByteType:
917
+ formatGPU = GPUTextureFormat.RGBA8Snorm;
918
+ break;
919
+
920
+ case ShortType:
921
+ formatGPU = GPUTextureFormat.RGBA16Sint;
922
+ break;
923
+
924
+ case UnsignedShortType:
925
+ formatGPU = GPUTextureFormat.RGBA16Uint;
926
+ break;
927
+ case UnsignedIntType:
928
+ formatGPU = GPUTextureFormat.RGBA32Uint;
929
+ break;
930
+
931
+ case IntType:
932
+ formatGPU = GPUTextureFormat.RGBA32Sint;
933
+ break;
934
+
916
935
  case UnsignedByteType:
917
936
  formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.RGBA8UnormSRGB : GPUTextureFormat.RGBA8Unorm;
918
937
  break;
@@ -951,6 +970,26 @@ export function getFormat( texture, device = null ) {
951
970
 
952
971
  switch ( type ) {
953
972
 
973
+ case ByteType:
974
+ formatGPU = GPUTextureFormat.R8Snorm;
975
+ break;
976
+
977
+ case ShortType:
978
+ formatGPU = GPUTextureFormat.R16Sint;
979
+ break;
980
+
981
+ case UnsignedShortType:
982
+ formatGPU = GPUTextureFormat.R16Uint;
983
+ break;
984
+
985
+ case UnsignedIntType:
986
+ formatGPU = GPUTextureFormat.R32Uint;
987
+ break;
988
+
989
+ case IntType:
990
+ formatGPU = GPUTextureFormat.R32Sint;
991
+ break;
992
+
954
993
  case UnsignedByteType:
955
994
  formatGPU = GPUTextureFormat.R8Unorm;
956
995
  break;
@@ -974,6 +1013,26 @@ export function getFormat( texture, device = null ) {
974
1013
 
975
1014
  switch ( type ) {
976
1015
 
1016
+ case ByteType:
1017
+ formatGPU = GPUTextureFormat.RG8Snorm;
1018
+ break;
1019
+
1020
+ case ShortType:
1021
+ formatGPU = GPUTextureFormat.RG16Sint;
1022
+ break;
1023
+
1024
+ case UnsignedShortType:
1025
+ formatGPU = GPUTextureFormat.RG16Uint;
1026
+ break;
1027
+
1028
+ case UnsignedIntType:
1029
+ formatGPU = GPUTextureFormat.RG32Uint;
1030
+ break;
1031
+
1032
+ case IntType:
1033
+ formatGPU = GPUTextureFormat.RG32Sint;
1034
+ break;
1035
+
977
1036
  case UnsignedByteType:
978
1037
  formatGPU = GPUTextureFormat.RG8Unorm;
979
1038
  break;
@@ -623,20 +623,22 @@ function mergeVertices( geometry, tolerance = 1e-4 ) {
623
623
  const name = attributeNames[ i ];
624
624
  const attr = geometry.attributes[ name ];
625
625
 
626
- tmpAttributes[ name ] = new BufferAttribute(
626
+ tmpAttributes[ name ] = new attr.constructor(
627
627
  new attr.array.constructor( attr.count * attr.itemSize ),
628
628
  attr.itemSize,
629
629
  attr.normalized
630
630
  );
631
631
 
632
- const morphAttr = geometry.morphAttributes[ name ];
633
- if ( morphAttr ) {
632
+ const morphAttributes = geometry.morphAttributes[ name ];
633
+ if ( morphAttributes ) {
634
634
 
635
- tmpMorphAttributes[ name ] = new BufferAttribute(
636
- new morphAttr.array.constructor( morphAttr.count * morphAttr.itemSize ),
637
- morphAttr.itemSize,
638
- morphAttr.normalized
639
- );
635
+ if ( ! tmpMorphAttributes[ name ] ) tmpMorphAttributes[ name ] = [];
636
+ morphAttributes.forEach( ( morphAttr, i ) => {
637
+
638
+ const array = new morphAttr.array.constructor( morphAttr.count * morphAttr.itemSize );
639
+ tmpMorphAttributes[ name ][ i ] = new morphAttr.constructor( array, morphAttr.itemSize, morphAttr.normalized );
640
+
641
+ } );
640
642
 
641
643
  }
642
644
 
@@ -681,22 +683,22 @@ function mergeVertices( geometry, tolerance = 1e-4 ) {
681
683
 
682
684
  const name = attributeNames[ j ];
683
685
  const attribute = geometry.getAttribute( name );
684
- const morphAttr = geometry.morphAttributes[ name ];
686
+ const morphAttributes = geometry.morphAttributes[ name ];
685
687
  const itemSize = attribute.itemSize;
686
- const newarray = tmpAttributes[ name ];
688
+ const newArray = tmpAttributes[ name ];
687
689
  const newMorphArrays = tmpMorphAttributes[ name ];
688
690
 
689
691
  for ( let k = 0; k < itemSize; k ++ ) {
690
692
 
691
693
  const getterFunc = getters[ k ];
692
694
  const setterFunc = setters[ k ];
693
- newarray[ setterFunc ]( nextIndex, attribute[ getterFunc ]( index ) );
695
+ newArray[ setterFunc ]( nextIndex, attribute[ getterFunc ]( index ) );
694
696
 
695
- if ( morphAttr ) {
697
+ if ( morphAttributes ) {
696
698
 
697
- for ( let m = 0, ml = morphAttr.length; m < ml; m ++ ) {
699
+ for ( let m = 0, ml = morphAttributes.length; m < ml; m ++ ) {
698
700
 
699
- newMorphArrays[ m ][ setterFunc ]( nextIndex, morphAttr[ m ][ getterFunc ]( index ) );
701
+ newMorphArrays[ m ][ setterFunc ]( nextIndex, morphAttributes[ m ][ getterFunc ]( index ) );
700
702
 
701
703
  }
702
704
 
@@ -720,7 +722,7 @@ function mergeVertices( geometry, tolerance = 1e-4 ) {
720
722
 
721
723
  const tmpAttribute = tmpAttributes[ name ];
722
724
 
723
- result.setAttribute( name, new BufferAttribute(
725
+ result.setAttribute( name, new tmpAttribute.constructor(
724
726
  tmpAttribute.array.slice( 0, nextIndex * tmpAttribute.itemSize ),
725
727
  tmpAttribute.itemSize,
726
728
  tmpAttribute.normalized,
@@ -732,7 +734,7 @@ function mergeVertices( geometry, tolerance = 1e-4 ) {
732
734
 
733
735
  const tmpMorphAttribute = tmpMorphAttributes[ name ][ j ];
734
736
 
735
- result.morphAttributes[ name ][ j ] = new BufferAttribute(
737
+ result.morphAttributes[ name ][ j ] = new tmpMorphAttribute.constructor(
736
738
  tmpMorphAttribute.array.slice( 0, nextIndex * tmpMorphAttribute.itemSize ),
737
739
  tmpMorphAttribute.itemSize,
738
740
  tmpMorphAttribute.normalized,
@@ -56,6 +56,8 @@ export class GPUStatsPanel extends Stats.Panel {
56
56
 
57
57
  }
58
58
 
59
+ gl.deleteQuery( query );
60
+
59
61
  this.activeQueries --;
60
62
 
61
63
 
@@ -1,6 +1,9 @@
1
1
  // Hybrid radix sort from
2
2
  // - https://gist.github.com/sciecode/93ed864dd77c5c8803c6a86698d68dab
3
3
  // - https://github.com/mrdoob/three.js/pull/27202#issuecomment-1817640271
4
+ //
5
+ // expects unsigned 32b integer values
6
+
4
7
  const POWER = 3;
5
8
  const BIT_MAX = 32;
6
9
  const BIN_BITS = 1 << POWER;
@@ -102,11 +105,11 @@ export const radixSort = ( arr, opt ) => {
102
105
 
103
106
  for ( let j = start + 1; j < start + len; j ++ ) {
104
107
 
105
- const p = a[ j ], t = get( p );
108
+ const p = a[ j ], t = get( p ) >>> 0;
106
109
  let i = j;
107
- while ( i > 0 ) {
110
+ while ( i > start ) {
108
111
 
109
- if ( compare( get( a[ i - 1 ] ), t ) )
112
+ if ( compare( get( a[ i - 1 ] ) >>> 0, t ) )
110
113
  a[ i ] = a[ -- i ];
111
114
  else
112
115
  break;
@@ -140,14 +143,14 @@ export const radixSort = ( arr, opt ) => {
140
143
  bin.fill( 0 );
141
144
 
142
145
  for ( let j = start; j < end; j ++ )
143
- bin[ ( get( a[ j ] ) >> shift ) & BIN_MAX ] ++;
146
+ bin[ ( get( a[ j ] ) >>> shift ) & BIN_MAX ] ++;
144
147
 
145
148
  accumulate( bin );
146
149
 
147
150
  cache.set( bin );
148
151
 
149
152
  for ( let j = end - 1; j >= start; j -- )
150
- b[ start + -- bin[ ( get( a[ j ] ) >> shift ) & BIN_MAX ] ] = a[ j ];
153
+ b[ start + -- bin[ ( get( a[ j ] ) >>> shift ) & BIN_MAX ] ] = a[ j ];
151
154
 
152
155
  if ( depth == ITERATIONS - 1 ) return;
153
156
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "super-three",
3
- "version": "0.164.0",
3
+ "version": "0.165.0",
4
4
  "description": "JavaScript 3D library",
5
5
  "type": "module",
6
6
  "main": "./build/three.cjs",
@@ -41,7 +41,7 @@
41
41
  ],
42
42
  "scripts": {
43
43
  "start": "npm run dev",
44
- "test": "npm run lint && npm run test-unit",
44
+ "test": "npm run lint && npm run test-unit && npm run test-unit-addons",
45
45
  "build": "rollup -c utils/build/rollup.config.js",
46
46
  "build-module": "rollup -c utils/build/rollup.config.js --configOnlyModule",
47
47
  "dev": "concurrently --names \"ROLLUP,HTTP\" -c \"bgBlue.bold,bgGreen.bold\" \"rollup -c utils/build/rollup.config.js -w -m inline\" \"servez -p 8080\"",
@@ -58,6 +58,7 @@
58
58
  "lint": "npm run lint-core",
59
59
  "lint-fix": "npm run lint-core -- --fix && npm run lint-addons -- --fix && npm run lint-examples -- --fix && npm run lint-docs -- --fix && npm run lint-editor -- --fix && npm run lint-playground -- --fix && npm run lint-manual -- --fix && npm run lint-test -- --fix && npm run lint-utils -- --fix",
60
60
  "test-unit": "qunit -r failonlyreporter -f !-webonly test/unit/three.source.unit.js",
61
+ "test-unit-addons": "qunit -r failonlyreporter -f !-webonly test/unit/three.addons.unit.js",
61
62
  "test-e2e": "node test/e2e/puppeteer.js",
62
63
  "test-e2e-cov": "node test/e2e/check-coverage.js",
63
64
  "test-treeshake": "rollup -c test/rollup.treeshake.config.js",
@@ -4,7 +4,16 @@ import { KeyframeTrack } from '../KeyframeTrack.js';
4
4
  /**
5
5
  * A Track of Boolean keyframe values.
6
6
  */
7
- class BooleanKeyframeTrack extends KeyframeTrack {}
7
+ class BooleanKeyframeTrack extends KeyframeTrack {
8
+
9
+ // No interpolation parameter because only InterpolateDiscrete is valid.
10
+ constructor( name, times, values ) {
11
+
12
+ super( name, times, values );
13
+
14
+ }
15
+
16
+ }
8
17
 
9
18
  BooleanKeyframeTrack.prototype.ValueTypeName = 'bool';
10
19
  BooleanKeyframeTrack.prototype.ValueBufferType = Array;
@@ -1,4 +1,3 @@
1
- import { InterpolateLinear } from '../../constants.js';
2
1
  import { KeyframeTrack } from '../KeyframeTrack.js';
3
2
  import { QuaternionLinearInterpolant } from '../../math/interpolants/QuaternionLinearInterpolant.js';
4
3
 
@@ -17,7 +16,7 @@ class QuaternionKeyframeTrack extends KeyframeTrack {
17
16
 
18
17
  QuaternionKeyframeTrack.prototype.ValueTypeName = 'quaternion';
19
18
  // ValueBufferType is inherited
20
- QuaternionKeyframeTrack.prototype.DefaultInterpolation = InterpolateLinear;
19
+ // DefaultInterpolation is inherited;
21
20
  QuaternionKeyframeTrack.prototype.InterpolantFactoryMethodSmooth = undefined;
22
21
 
23
22
  export { QuaternionKeyframeTrack };
@@ -4,7 +4,16 @@ import { KeyframeTrack } from '../KeyframeTrack.js';
4
4
  /**
5
5
  * A Track that interpolates Strings
6
6
  */
7
- class StringKeyframeTrack extends KeyframeTrack {}
7
+ class StringKeyframeTrack extends KeyframeTrack {
8
+
9
+ // No interpolation parameter because only InterpolateDiscrete is valid.
10
+ constructor( name, times, values ) {
11
+
12
+ super( name, times, values );
13
+
14
+ }
15
+
16
+ }
8
17
 
9
18
  StringKeyframeTrack.prototype.ValueTypeName = 'string';
10
19
  StringKeyframeTrack.prototype.ValueBufferType = Array;
package/src/constants.js CHANGED
@@ -1,4 +1,4 @@
1
- export const REVISION = '164';
1
+ export const REVISION = '165';
2
2
 
3
3
  export const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
4
4
  export const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
@@ -761,6 +761,8 @@ class Object3D extends EventDispatcher {
761
761
 
762
762
  object.matricesTexture = this._matricesTexture.toJSON( meta );
763
763
 
764
+ if ( this._colorsTexture !== null ) object.colorsTexture = this._colorsTexture.toJSON( meta );
765
+
764
766
  if ( this.boundingSphere !== null ) {
765
767
 
766
768
  object.boundingSphere = {
@@ -101,13 +101,17 @@ function ascSort( a, b ) {
101
101
 
102
102
  function intersect( object, raycaster, intersects, recursive ) {
103
103
 
104
+ let propagate = true;
105
+
104
106
  if ( object.layers.test( raycaster.layers ) ) {
105
107
 
106
- object.raycast( raycaster, intersects );
108
+ const result = object.raycast( raycaster, intersects );
109
+
110
+ if ( result === false ) propagate = false;
107
111
 
108
112
  }
109
113
 
110
- if ( recursive === true ) {
114
+ if ( propagate === true && recursive === true ) {
111
115
 
112
116
  const children = object.children;
113
117