super-three 0.162.0 → 0.163.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/build/three.cjs +407 -1014
  2. package/build/three.module.js +406 -1013
  3. package/build/three.module.min.js +1 -1
  4. package/examples/jsm/controls/TransformControls.js +3 -3
  5. package/examples/jsm/exporters/GLTFExporter.js +21 -4
  6. package/examples/jsm/exporters/USDZExporter.js +15 -0
  7. package/examples/jsm/geometries/TextGeometry.js +10 -2
  8. package/examples/jsm/interactive/HTMLMesh.js +7 -9
  9. package/examples/jsm/libs/fflate.module.js +694 -496
  10. package/examples/jsm/lines/LineMaterial.js +0 -2
  11. package/examples/jsm/loaders/3MFLoader.js +2 -0
  12. package/examples/jsm/loaders/EXRLoader.js +89 -19
  13. package/examples/jsm/loaders/FBXLoader.js +1 -1
  14. package/examples/jsm/loaders/GLTFLoader.js +6 -0
  15. package/examples/jsm/loaders/KTX2Loader.js +2 -6
  16. package/examples/jsm/loaders/LUT3dlLoader.js +0 -15
  17. package/examples/jsm/loaders/LUTCubeLoader.js +0 -14
  18. package/examples/jsm/loaders/LUTImageLoader.js +0 -14
  19. package/examples/jsm/loaders/RGBMLoader.js +16 -0
  20. package/examples/jsm/misc/GPUComputationRenderer.js +0 -6
  21. package/examples/jsm/nodes/Nodes.js +6 -1
  22. package/examples/jsm/nodes/accessors/BatchNode.js +78 -0
  23. package/examples/jsm/nodes/accessors/InstanceNode.js +25 -2
  24. package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +1 -1
  25. package/examples/jsm/nodes/accessors/MorphNode.js +13 -3
  26. package/examples/jsm/nodes/accessors/NormalNode.js +12 -2
  27. package/examples/jsm/nodes/accessors/ReferenceNode.js +1 -1
  28. package/examples/jsm/nodes/accessors/RendererReferenceNode.js +29 -0
  29. package/examples/jsm/nodes/accessors/TextureNode.js +30 -7
  30. package/examples/jsm/nodes/core/Node.js +55 -4
  31. package/examples/jsm/nodes/core/NodeBuilder.js +21 -16
  32. package/examples/jsm/nodes/core/NodeFrame.js +10 -10
  33. package/examples/jsm/nodes/core/NodeUtils.js +2 -2
  34. package/examples/jsm/nodes/core/UniformNode.js +20 -0
  35. package/examples/jsm/nodes/display/PassNode.js +17 -1
  36. package/examples/jsm/nodes/display/ToneMappingNode.js +8 -4
  37. package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +6 -0
  38. package/examples/jsm/nodes/fog/FogExp2Node.js +4 -5
  39. package/examples/jsm/nodes/fog/FogNode.js +13 -3
  40. package/examples/jsm/nodes/fog/FogRangeNode.js +4 -3
  41. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +1 -1
  42. package/examples/jsm/nodes/lighting/EnvironmentNode.js +12 -69
  43. package/examples/jsm/nodes/materials/NodeMaterial.js +33 -11
  44. package/examples/jsm/nodes/pmrem/PMREMNode.js +193 -0
  45. package/examples/jsm/nodes/pmrem/PMREMUtils.js +288 -0
  46. package/examples/jsm/nodes/shadernode/ShaderNode.js +1 -1
  47. package/examples/jsm/nodes/utils/EquirectUVNode.js +1 -1
  48. package/examples/jsm/objects/QuadMesh.js +7 -23
  49. package/examples/jsm/physics/RapierPhysics.js +4 -4
  50. package/examples/jsm/postprocessing/GlitchPass.js +0 -3
  51. package/examples/jsm/postprocessing/LUTPass.js +5 -71
  52. package/examples/jsm/postprocessing/SAOPass.js +0 -1
  53. package/examples/jsm/postprocessing/SSAOPass.js +0 -3
  54. package/examples/jsm/renderers/common/Animation.js +3 -0
  55. package/examples/jsm/renderers/common/Background.js +5 -5
  56. package/examples/jsm/renderers/common/Info.js +11 -19
  57. package/examples/jsm/renderers/common/PostProcessing.js +12 -4
  58. package/examples/jsm/renderers/common/RenderContext.js +1 -1
  59. package/examples/jsm/renderers/common/RenderObject.js +4 -4
  60. package/examples/jsm/renderers/common/RenderObjects.js +1 -1
  61. package/examples/jsm/renderers/common/Renderer.js +25 -8
  62. package/examples/jsm/renderers/common/extras/PMREMGenerator.js +777 -0
  63. package/examples/jsm/renderers/common/nodes/Nodes.js +5 -18
  64. package/examples/jsm/renderers/webgl/WebGLBackend.js +148 -24
  65. package/examples/jsm/renderers/webgl/WebGLBufferRenderer.js +141 -0
  66. package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +3 -3
  67. package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +1 -1
  68. package/examples/jsm/renderers/webgl/utils/WebGLConstants.js +1 -0
  69. package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +43 -0
  70. package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +3 -2
  71. package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +0 -2
  72. package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +0 -2
  73. package/examples/jsm/renderers/webgpu/WebGPUBackend.js +54 -25
  74. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +5 -3
  75. package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +25 -0
  76. package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +18 -4
  77. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +92 -18
  78. package/examples/jsm/utils/GPUStatsPanel.js +10 -45
  79. package/examples/jsm/utils/TextureUtils.js +1 -1
  80. package/package.json +1 -1
  81. package/src/Three.js +0 -1
  82. package/src/animation/AnimationClip.js +1 -1
  83. package/src/constants.js +3 -3
  84. package/src/core/Object3D.js +10 -7
  85. package/src/extras/PMREMGenerator.js +9 -0
  86. package/src/loaders/ObjectLoader.js +2 -0
  87. package/src/materials/ShaderMaterial.js +0 -4
  88. package/src/math/Spherical.js +4 -5
  89. package/src/objects/BatchedMesh.js +4 -3
  90. package/src/objects/InstancedMesh.js +10 -0
  91. package/src/renderers/WebGLRenderer.js +55 -114
  92. package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +2 -2
  93. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
  94. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +2 -10
  95. package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +2 -16
  96. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +32 -22
  97. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +1 -1
  98. package/src/renderers/shaders/ShaderLib.js +1 -1
  99. package/src/renderers/shaders/UniformsUtils.js +10 -1
  100. package/src/renderers/webgl/WebGLAttributes.js +6 -33
  101. package/src/renderers/webgl/WebGLBindingStates.js +14 -51
  102. package/src/renderers/webgl/WebGLBufferRenderer.js +3 -25
  103. package/src/renderers/webgl/WebGLCapabilities.js +2 -12
  104. package/src/renderers/webgl/WebGLCubeUVMaps.js +10 -6
  105. package/src/renderers/webgl/WebGLExtensions.js +4 -19
  106. package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +3 -25
  107. package/src/renderers/webgl/WebGLLights.js +6 -32
  108. package/src/renderers/webgl/WebGLMaterials.js +2 -3
  109. package/src/renderers/webgl/WebGLMorphtargets.js +79 -217
  110. package/src/renderers/webgl/WebGLProgram.js +18 -47
  111. package/src/renderers/webgl/WebGLPrograms.js +20 -32
  112. package/src/renderers/webgl/WebGLRenderStates.js +8 -6
  113. package/src/renderers/webgl/WebGLState.js +15 -59
  114. package/src/renderers/webgl/WebGLTextures.js +75 -237
  115. package/src/renderers/webgl/WebGLUniformsGroups.js +1 -1
  116. package/src/renderers/webgl/WebGLUtils.js +6 -57
  117. package/src/renderers/webxr/WebXRDepthSensing.js +2 -3
  118. package/src/renderers/webxr/WebXRManager.js +2 -2
  119. package/src/scenes/Scene.js +7 -1
  120. package/src/textures/Texture.js +11 -1
  121. package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +0 -37
  122. package/src/renderers/WebGL1Renderer.js +0 -7
@@ -1049,9 +1049,11 @@ class WebGPUBackend extends Backend {
1049
1049
  beginningOfPassWriteIndex: 0, // Write timestamp in index 0 when pass begins.
1050
1050
  endOfPassWriteIndex: 1, // Write timestamp in index 1 when pass ends.
1051
1051
  };
1052
+
1052
1053
  Object.assign( descriptor, {
1053
1054
  timestampWrites,
1054
1055
  } );
1056
+
1055
1057
  renderContextData.timeStampQuerySet = timeStampQuerySet;
1056
1058
 
1057
1059
  }
@@ -1084,33 +1086,29 @@ class WebGPUBackend extends Backend {
1084
1086
 
1085
1087
  }
1086
1088
 
1087
- async resolveTimestampAsync( renderContext, type = 'render' ) {
1088
-
1089
- if ( ! this.hasFeature( GPUFeatureName.TimestampQuery ) || ! this.trackTimestamp ) return;
1090
-
1091
- const renderContextData = this.get( renderContext );
1092
-
1093
- // handle timestamp query results
1094
-
1089
+ async resolveTimestampAsync(renderContext, type = 'render') {
1090
+ if (!this.hasFeature(GPUFeatureName.TimestampQuery) || !this.trackTimestamp) return;
1091
+
1092
+ const renderContextData = this.get(renderContext);
1095
1093
  const { currentTimestampQueryBuffer } = renderContextData;
1096
-
1097
- if ( currentTimestampQueryBuffer ) {
1098
-
1099
- renderContextData.currentTimestampQueryBuffer = null;
1100
-
1101
- await currentTimestampQueryBuffer.mapAsync( GPUMapMode.READ );
1102
-
1103
- const times = new BigUint64Array( currentTimestampQueryBuffer.getMappedRange() );
1104
-
1105
- const duration = Number( times[ 1 ] - times[ 0 ] ) / 1000000;
1106
- // console.log( `Compute ${type} duration: ${Number( times[ 1 ] - times[ 0 ] ) / 1000000}ms` );
1107
- this.renderer.info.updateTimestamp( type, duration );
1108
-
1109
- currentTimestampQueryBuffer.unmap();
1110
-
1094
+
1095
+ if (currentTimestampQueryBuffer === undefined) return;
1096
+
1097
+ const buffer = currentTimestampQueryBuffer;
1098
+
1099
+ try {
1100
+ await buffer.mapAsync(GPUMapMode.READ);
1101
+ const times = new BigUint64Array(buffer.getMappedRange());
1102
+ const duration = Number(times[1] - times[0]) / 1000000;
1103
+ this.renderer.info.updateTimestamp(type, duration);
1104
+ } catch (error) {
1105
+ console.error(`Error mapping buffer: ${error}`);
1106
+ // Optionally handle the error, e.g., re-queue the buffer or skip it
1107
+ } finally {
1108
+ buffer.unmap();
1111
1109
  }
1112
-
1113
1110
  }
1111
+
1114
1112
 
1115
1113
  // node builder
1116
1114
 
@@ -1236,7 +1234,7 @@ class WebGPUBackend extends Backend {
1236
1234
 
1237
1235
  if ( ! this.adapter ) {
1238
1236
 
1239
- console.warn( 'WebGPUBackend: WebGPU adapter has not been initialized yet. Please use detectSupportAsync instead' );
1237
+ console.warn( 'WebGPUBackend: WebGPU adapter has not been initialized yet. Please use hasFeatureAsync instead' );
1240
1238
 
1241
1239
  return false;
1242
1240
 
@@ -1246,6 +1244,37 @@ class WebGPUBackend extends Backend {
1246
1244
 
1247
1245
  }
1248
1246
 
1247
+ copyTextureToTexture( position, srcTexture, dstTexture, level = 0 ) {
1248
+
1249
+ const encoder = this.device.createCommandEncoder( { label: 'copyTextureToTexture_' + srcTexture.id + '_' + dstTexture.id } );
1250
+
1251
+ const sourceGPU = this.get( srcTexture ).texture;
1252
+ const destinationGPU = this.get( dstTexture ).texture;
1253
+
1254
+ encoder.copyTextureToTexture(
1255
+ {
1256
+ texture: sourceGPU,
1257
+ mipLevel: level,
1258
+ origin: { x: 0, y: 0, z: 0 }
1259
+ },
1260
+ {
1261
+ texture: destinationGPU,
1262
+ mipLevel: level,
1263
+ origin: { x: position.x, y: position.y, z: position.z }
1264
+ },
1265
+ [
1266
+ srcTexture.image.width,
1267
+ srcTexture.image.height
1268
+ ]
1269
+ );
1270
+
1271
+ this.device.queue.submit( [ encoder.finish() ] );
1272
+
1273
+ }
1274
+
1275
+
1276
+
1277
+
1249
1278
  copyFramebufferToTexture( texture, renderContext ) {
1250
1279
 
1251
1280
  const renderContextData = this.get( renderContext );
@@ -228,7 +228,7 @@ class WGSLNodeBuilder extends NodeBuilder {
228
228
 
229
229
  isUnfilterable( texture ) {
230
230
 
231
- return texture.isDataTexture === true && texture.type === FloatType;
231
+ return this.getComponentTypeFromTexture( texture ) !== 'float' || ( texture.isDataTexture === true && texture.type === FloatType );
232
232
 
233
233
  }
234
234
 
@@ -759,11 +759,13 @@ ${ flowData.code }
759
759
 
760
760
  const format = getFormat( texture );
761
761
 
762
- textureType = 'texture_storage_2d<' + format + ', write>';
762
+ textureType = `texture_storage_2d<${ format }, write>`;
763
763
 
764
764
  } else {
765
765
 
766
- textureType = 'texture_2d<f32>';
766
+ const componentPrefix = this.getComponentTypeFromTexture( texture ).charAt( 0 );
767
+
768
+ textureType = `texture_2d<${ componentPrefix }32>`;
767
769
 
768
770
  }
769
771
 
@@ -17,7 +17,9 @@ const typedAttributeToVertexFormatPrefix = new Map( [
17
17
 
18
18
  const typeArraysToVertexFormatPrefixForItemSize1 = new Map( [
19
19
  [ Int32Array, 'sint32' ],
20
+ [ Int16Array, 'sint32' ], // patch for INT16
20
21
  [ Uint32Array, 'uint32' ],
22
+ [ Uint16Array, 'uint32' ], // patch for UINT16
21
23
  [ Float32Array, 'float32' ]
22
24
  ] );
23
25
 
@@ -44,6 +46,22 @@ class WebGPUAttributeUtils {
44
46
 
45
47
  let array = bufferAttribute.array;
46
48
 
49
+ // patch for INT16 and UINT16
50
+ if ( attribute.normalized === false && ( array.constructor === Int16Array || array.constructor === Uint16Array ) ) {
51
+
52
+ const tempArray = new Uint32Array( array.length );
53
+ for ( let i = 0; i < array.length; i ++ ) {
54
+
55
+ tempArray[ i ] = array[ i ];
56
+
57
+ }
58
+
59
+ array = tempArray;
60
+
61
+ }
62
+
63
+ bufferAttribute.array = array;
64
+
47
65
  if ( ( bufferAttribute.isStorageBufferAttribute || bufferAttribute.isStorageInstancedBufferAttribute ) && bufferAttribute.itemSize === 3 ) {
48
66
 
49
67
  bufferAttribute.itemSize = 4;
@@ -149,6 +167,13 @@ class WebGPUAttributeUtils {
149
167
 
150
168
  }
151
169
 
170
+ // patch for INT16 and UINT16
171
+ if ( geometryAttribute.normalized === false && ( geometryAttribute.array.constructor === Int16Array || geometryAttribute.array.constructor === Uint16Array ) ) {
172
+
173
+ arrayStride = 4;
174
+
175
+ }
176
+
152
177
  vertexBufferLayout = {
153
178
  arrayStride,
154
179
  attributes: [],
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  GPUTextureAspect, GPUTextureViewDimension, GPUBufferBindingType, GPUTextureSampleType
3
3
  } from './WebGPUConstants.js';
4
- import { FloatType } from 'three';
4
+ import { FloatType, IntType, UnsignedIntType } from 'three';
5
5
 
6
6
  class WebGPUBindingUtils {
7
7
 
@@ -73,11 +73,25 @@ class WebGPUBindingUtils {
73
73
 
74
74
  texture.sampleType = GPUTextureSampleType.Depth;
75
75
 
76
- } else if ( binding.texture.isDataTexture && binding.texture.type === FloatType ) {
76
+ } else if ( binding.texture.isDataTexture ) {
77
77
 
78
- // @TODO: Add support for this soon: backend.hasFeature( 'float32-filterable' )
78
+ const type = binding.texture.type;
79
79
 
80
- texture.sampleType = GPUTextureSampleType.UnfilterableFloat;
80
+ if ( type === IntType ) {
81
+
82
+ texture.sampleType = GPUTextureSampleType.SInt;
83
+
84
+ } else if ( type === UnsignedIntType ) {
85
+
86
+ texture.sampleType = GPUTextureSampleType.UInt;
87
+
88
+ } else if ( type === FloatType ) {
89
+
90
+ // @TODO: Add support for this soon: backend.hasFeature( 'float32-filterable' )
91
+
92
+ texture.sampleType = GPUTextureSampleType.UnfilterableFloat;
93
+
94
+ }
81
95
 
82
96
  }
83
97
 
@@ -7,10 +7,10 @@ import {
7
7
  NearestFilter, NearestMipmapNearestFilter, NearestMipmapLinearFilter,
8
8
  RepeatWrapping, MirroredRepeatWrapping,
9
9
  RGB_ETC2_Format, RGBA_ETC2_EAC_Format,
10
- RGBAFormat, RedFormat, RGFormat, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, UnsignedByteType, FloatType, HalfFloatType, SRGBColorSpace, DepthFormat, DepthStencilFormat,
10
+ RGBAFormat, RGBFormat, RedFormat, RGFormat, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, UnsignedByteType, FloatType, HalfFloatType, SRGBColorSpace, DepthFormat, DepthStencilFormat,
11
11
  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,
12
- RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, UnsignedIntType, UnsignedShortType, UnsignedInt248Type,
13
- NeverCompare, AlwaysCompare, LessCompare, LessEqualCompare, EqualCompare, GreaterEqualCompare, GreaterCompare, NotEqualCompare
12
+ RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, UnsignedIntType, UnsignedShortType, UnsignedInt248Type, UnsignedInt5999Type,
13
+ NeverCompare, AlwaysCompare, LessCompare, LessEqualCompare, EqualCompare, GreaterEqualCompare, GreaterCompare, NotEqualCompare, IntType, RedIntegerFormat, RGIntegerFormat, RGBAIntegerFormat
14
14
  } from 'three';
15
15
 
16
16
  import { CubeReflectionMapping, CubeRefractionMapping, EquirectangularReflectionMapping, EquirectangularRefractionMapping, DepthTexture } from 'three';
@@ -38,8 +38,8 @@ class WebGPUTextureUtils {
38
38
 
39
39
  this._passUtils = null;
40
40
 
41
- this.defaultTexture = null;
42
- this.defaultCubeTexture = null;
41
+ this.defaultTexture = {};
42
+ this.defaultCubeTexture = {};
43
43
 
44
44
  this.colorBuffer = null;
45
45
 
@@ -79,13 +79,15 @@ class WebGPUTextureUtils {
79
79
 
80
80
  let textureGPU;
81
81
 
82
+ const format = getFormat( texture );
83
+
82
84
  if ( texture.isCubeTexture ) {
83
85
 
84
- textureGPU = this._getDefaultCubeTextureGPU();
86
+ textureGPU = this._getDefaultCubeTextureGPU( format );
85
87
 
86
88
  } else {
87
89
 
88
- textureGPU = this._getDefaultTextureGPU();
90
+ textureGPU = this._getDefaultTextureGPU( format );
89
91
 
90
92
  }
91
93
 
@@ -111,7 +113,7 @@ class WebGPUTextureUtils {
111
113
  const { width, height, depth, levels } = options;
112
114
 
113
115
  const dimension = this._getDimension( texture );
114
- const format = texture.internalFormat || getFormat( texture, backend.device );
116
+ const format = texture.internalFormat || options.format || getFormat( texture, backend.device );
115
117
 
116
118
  let sampleCount = options.sampleCount !== undefined ? options.sampleCount : 1;
117
119
 
@@ -268,7 +270,7 @@ class WebGPUTextureUtils {
268
270
 
269
271
  }
270
272
 
271
- getDepthBuffer( depth = true, stencil = true ) {
273
+ getDepthBuffer( depth = true, stencil = false ) {
272
274
 
273
275
  const backend = this.backend;
274
276
  const { width, height } = backend.getDrawingBufferSize();
@@ -422,19 +424,19 @@ class WebGPUTextureUtils {
422
424
 
423
425
  }
424
426
 
425
- _getDefaultTextureGPU() {
427
+ _getDefaultTextureGPU( format ) {
426
428
 
427
- let defaultTexture = this.defaultTexture;
429
+ let defaultTexture = this.defaultTexture[ format ];
428
430
 
429
- if ( defaultTexture === null ) {
431
+ if ( defaultTexture === undefined ) {
430
432
 
431
433
  const texture = new Texture();
432
434
  texture.minFilter = NearestFilter;
433
435
  texture.magFilter = NearestFilter;
434
436
 
435
- this.createTexture( texture, { width: 1, height: 1 } );
437
+ this.createTexture( texture, { width: 1, height: 1, format } );
436
438
 
437
- this.defaultTexture = defaultTexture = texture;
439
+ this.defaultTexture[ format ] = defaultTexture = texture;
438
440
 
439
441
  }
440
442
 
@@ -442,11 +444,11 @@ class WebGPUTextureUtils {
442
444
 
443
445
  }
444
446
 
445
- _getDefaultCubeTextureGPU() {
447
+ _getDefaultCubeTextureGPU( format ) {
446
448
 
447
- let defaultCubeTexture = this.defaultTexture;
449
+ let defaultCubeTexture = this.defaultTexture[ format ];
448
450
 
449
- if ( defaultCubeTexture === null ) {
451
+ if ( defaultCubeTexture === undefined ) {
450
452
 
451
453
  const texture = new CubeTexture();
452
454
  texture.minFilter = NearestFilter;
@@ -454,7 +456,7 @@ class WebGPUTextureUtils {
454
456
 
455
457
  this.createTexture( texture, { width: 1, height: 1, depth: 6 } );
456
458
 
457
- this.defaultCubeTexture = defaultCubeTexture = texture;
459
+ this.defaultCubeTexture[ format ] = defaultCubeTexture = texture;
458
460
 
459
461
  }
460
462
 
@@ -930,6 +932,21 @@ export function getFormat( texture, device = null ) {
930
932
 
931
933
  break;
932
934
 
935
+ case RGBFormat:
936
+
937
+ switch ( type ) {
938
+
939
+ case UnsignedInt5999Type:
940
+ formatGPU = GPUTextureFormat.RGB9E5UFloat;
941
+ break;
942
+
943
+ default:
944
+ console.error( 'WebGPURenderer: Unsupported texture type with RGBFormat.', type );
945
+
946
+ }
947
+
948
+ break;
949
+
933
950
  case RedFormat:
934
951
 
935
952
  switch ( type ) {
@@ -1026,6 +1043,63 @@ export function getFormat( texture, device = null ) {
1026
1043
 
1027
1044
  break;
1028
1045
 
1046
+ case RedIntegerFormat:
1047
+
1048
+ switch ( type ) {
1049
+
1050
+ case IntType:
1051
+ formatGPU = GPUTextureFormat.R32Sint;
1052
+ break;
1053
+
1054
+ case UnsignedIntType:
1055
+ formatGPU = GPUTextureFormat.R32Uint;
1056
+ break;
1057
+
1058
+ default:
1059
+ console.error( 'WebGPURenderer: Unsupported texture type with RedIntegerFormat.', type );
1060
+
1061
+ }
1062
+
1063
+ break;
1064
+
1065
+ case RGIntegerFormat:
1066
+
1067
+ switch ( type ) {
1068
+
1069
+ case IntType:
1070
+ formatGPU = GPUTextureFormat.RG32Sint;
1071
+ break;
1072
+
1073
+ case UnsignedIntType:
1074
+ formatGPU = GPUTextureFormat.RG32Uint;
1075
+ break;
1076
+
1077
+ default:
1078
+ console.error( 'WebGPURenderer: Unsupported texture type with RGIntegerFormat.', type );
1079
+
1080
+ }
1081
+
1082
+ break;
1083
+
1084
+ case RGBAIntegerFormat:
1085
+
1086
+ switch ( type ) {
1087
+
1088
+ case IntType:
1089
+ formatGPU = GPUTextureFormat.RGBA32Sint;
1090
+ break;
1091
+
1092
+ case UnsignedIntType:
1093
+ formatGPU = GPUTextureFormat.RGBA32Uint;
1094
+ break;
1095
+
1096
+ default:
1097
+ console.error( 'WebGPURenderer: Unsupported texture type with RGBAIntegerFormat.', type );
1098
+
1099
+ }
1100
+
1101
+ break;
1102
+
1029
1103
  default:
1030
1104
  console.error( 'WebGPURenderer: Unsupported texture format.', format );
1031
1105
 
@@ -1,6 +1,5 @@
1
1
  import Stats from '../libs/stats.module.js';
2
2
 
3
- // https://www.khronos.org/registry/webgl/extensions/EXT_disjoint_timer_query/
4
3
  // https://www.khronos.org/registry/webgl/extensions/EXT_disjoint_timer_query_webgl2/
5
4
  export class GPUStatsPanel extends Stats.Panel {
6
5
 
@@ -8,18 +7,11 @@ export class GPUStatsPanel extends Stats.Panel {
8
7
 
9
8
  super( name, '#f90', '#210' );
10
9
 
11
- let isWebGL2 = true;
12
- let extension = context.getExtension( 'EXT_disjoint_timer_query_webgl2' );
13
- if ( extension === null ) {
14
-
15
- isWebGL2 = false;
16
- extension = context.getExtension( 'EXT_disjoint_timer_query' );
17
-
18
- if ( extension === null ) {
10
+ const extension = context.getExtension( 'EXT_disjoint_timer_query_webgl2' );
19
11
 
20
- console.warn( 'GPUStatsPanel: disjoint_time_query extension not available.' );
12
+ if ( extension === null ) {
21
13
 
22
- }
14
+ console.warn( 'GPUStatsPanel: disjoint_time_query extension not available.' );
23
15
 
24
16
  }
25
17
 
@@ -40,40 +32,21 @@ export class GPUStatsPanel extends Stats.Panel {
40
32
  }
41
33
 
42
34
  // create the query object
43
- let query;
44
- if ( isWebGL2 ) {
45
-
46
- query = gl.createQuery();
47
- gl.beginQuery( ext.TIME_ELAPSED_EXT, query );
48
-
49
- } else {
50
-
51
- query = ext.createQueryEXT();
52
- ext.beginQueryEXT( ext.TIME_ELAPSED_EXT, query );
53
-
54
- }
35
+ const query = gl.createQuery();
36
+ gl.beginQuery( ext.TIME_ELAPSED_EXT, query );
55
37
 
56
38
  this.activeQueries ++;
57
39
 
58
40
  const checkQuery = () => {
59
41
 
60
42
  // check if the query is available and valid
61
- let available, disjoint, ns;
62
- if ( isWebGL2 ) {
63
43
 
64
- available = gl.getQueryParameter( query, gl.QUERY_RESULT_AVAILABLE );
65
- disjoint = gl.getParameter( ext.GPU_DISJOINT_EXT );
66
- ns = gl.getQueryParameter( query, gl.QUERY_RESULT );
67
-
68
- } else {
69
-
70
- available = ext.getQueryObjectEXT( query, ext.QUERY_RESULT_AVAILABLE_EXT );
71
- disjoint = gl.getParameter( ext.GPU_DISJOINT_EXT );
72
- ns = ext.getQueryObjectEXT( query, ext.QUERY_RESULT_EXT );
73
-
74
- }
44
+ const available = gl.getQueryParameter( query, gl.QUERY_RESULT_AVAILABLE );
45
+ const disjoint = gl.getParameter( ext.GPU_DISJOINT_EXT );
46
+ const ns = gl.getQueryParameter( query, gl.QUERY_RESULT );
75
47
 
76
48
  const ms = ns * 1e-6;
49
+
77
50
  if ( available ) {
78
51
 
79
52
  // update the display if it is valid
@@ -111,15 +84,7 @@ export class GPUStatsPanel extends Stats.Panel {
111
84
 
112
85
  }
113
86
 
114
- if ( isWebGL2 ) {
115
-
116
- gl.endQuery( ext.TIME_ELAPSED_EXT );
117
-
118
- } else {
119
-
120
- ext.endQueryEXT( ext.TIME_ELAPSED_EXT );
121
-
122
- }
87
+ gl.endQuery( ext.TIME_ELAPSED_EXT );
123
88
 
124
89
  };
125
90
 
@@ -48,7 +48,7 @@ export function decompress( texture, maxTextureSize = Infinity, renderer = null
48
48
  if ( ! fullscreenQuad ) {
49
49
 
50
50
  fullscreenQuad = new Mesh( fullscreenQuadGeometry, fullscreenQuadMaterial );
51
- fullscreenQuad.frustrumCulled = false;
51
+ fullscreenQuad.frustumCulled = false;
52
52
 
53
53
  }
54
54
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "super-three",
3
- "version": "0.162.0",
3
+ "version": "0.163.0",
4
4
  "description": "JavaScript 3D library",
5
5
  "type": "module",
6
6
  "main": "./build/three.cjs",
package/src/Three.js CHANGED
@@ -5,7 +5,6 @@ export { WebGL3DRenderTarget } from './renderers/WebGL3DRenderTarget.js';
5
5
  export { WebGLCubeRenderTarget } from './renderers/WebGLCubeRenderTarget.js';
6
6
  export { WebGLRenderTarget } from './renderers/WebGLRenderTarget.js';
7
7
  export { WebGLRenderer } from './renderers/WebGLRenderer.js';
8
- export { WebGL1Renderer } from './renderers/WebGL1Renderer.js';
9
8
  export { ShaderLib } from './renderers/shaders/ShaderLib.js';
10
9
  export { UniformsLib } from './renderers/shaders/UniformsLib.js';
11
10
  export { UniformsUtils } from './renderers/shaders/UniformsUtils.js';
@@ -11,7 +11,7 @@ import { NormalAnimationBlendMode } from '../constants.js';
11
11
 
12
12
  class AnimationClip {
13
13
 
14
- constructor( name, duration = - 1, tracks, blendMode = NormalAnimationBlendMode ) {
14
+ constructor( name = '', duration = - 1, tracks = [], blendMode = NormalAnimationBlendMode ) {
15
15
 
16
16
  this.name = name;
17
17
  this.tracks = tracks;
package/src/constants.js CHANGED
@@ -1,4 +1,4 @@
1
- export const REVISION = '162';
1
+ export const REVISION = '163';
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 };
@@ -91,7 +91,9 @@ export const HalfFloatType = 1016;
91
91
  export const UnsignedShort4444Type = 1017;
92
92
  export const UnsignedShort5551Type = 1018;
93
93
  export const UnsignedInt248Type = 1020;
94
+ export const UnsignedInt5999Type = 35902;
94
95
  export const AlphaFormat = 1021;
96
+ export const RGBFormat = 1022;
95
97
  export const RGBAFormat = 1023;
96
98
  export const LuminanceFormat = 1024;
97
99
  export const LuminanceAlphaFormat = 1025;
@@ -207,7 +209,5 @@ export const StreamCopyUsage = 35042;
207
209
  export const GLSL1 = '100';
208
210
  export const GLSL3 = '300 es';
209
211
 
210
- export const _SRGBAFormat = 1035; // fallback for WebGL 1
211
-
212
212
  export const WebGLCoordinateSystem = 2000;
213
213
  export const WebGPUCoordinateSystem = 2001;
@@ -333,12 +333,7 @@ class Object3D extends EventDispatcher {
333
333
 
334
334
  if ( object && object.isObject3D ) {
335
335
 
336
- if ( object.parent !== null ) {
337
-
338
- object.parent.remove( object );
339
-
340
- }
341
-
336
+ object.removeFromParent();
342
337
  object.parent = this;
343
338
  this.children.push( object );
344
339
 
@@ -431,10 +426,18 @@ class Object3D extends EventDispatcher {
431
426
 
432
427
  object.applyMatrix4( _m1 );
433
428
 
434
- this.add( object );
429
+ object.removeFromParent();
430
+ object.parent = this;
431
+ this.children.push( object );
435
432
 
436
433
  object.updateWorldMatrix( false, true );
437
434
 
435
+ object.dispatchEvent( _addedEvent );
436
+
437
+ _childaddedEvent.child = object;
438
+ this.dispatchEvent( _childaddedEvent );
439
+ _childaddedEvent.child = null;
440
+
438
441
  return this;
439
442
 
440
443
  }
@@ -40,6 +40,7 @@ const _clearColor = /*@__PURE__*/ new Color();
40
40
  let _oldTarget = null;
41
41
  let _oldActiveCubeFace = 0;
42
42
  let _oldActiveMipmapLevel = 0;
43
+ let _oldXrEnabled = false;
43
44
 
44
45
  // Golden Ratio
45
46
  const PHI = ( 1 + Math.sqrt( 5 ) ) / 2;
@@ -107,6 +108,9 @@ class PMREMGenerator {
107
108
  _oldTarget = this._renderer.getRenderTarget();
108
109
  _oldActiveCubeFace = this._renderer.getActiveCubeFace();
109
110
  _oldActiveMipmapLevel = this._renderer.getActiveMipmapLevel();
111
+ _oldXrEnabled = this._renderer.xr.enabled;
112
+
113
+ this._renderer.xr.enabled = false;
110
114
 
111
115
  this._setSize( 256 );
112
116
 
@@ -222,6 +226,8 @@ class PMREMGenerator {
222
226
  _cleanup( outputTarget ) {
223
227
 
224
228
  this._renderer.setRenderTarget( _oldTarget, _oldActiveCubeFace, _oldActiveMipmapLevel );
229
+ this._renderer.xr.enabled = _oldXrEnabled;
230
+
225
231
  outputTarget.scissorTest = false;
226
232
  _setViewport( outputTarget, 0, 0, outputTarget.width, outputTarget.height );
227
233
 
@@ -242,6 +248,9 @@ class PMREMGenerator {
242
248
  _oldTarget = this._renderer.getRenderTarget();
243
249
  _oldActiveCubeFace = this._renderer.getActiveCubeFace();
244
250
  _oldActiveMipmapLevel = this._renderer.getActiveMipmapLevel();
251
+ _oldXrEnabled = this._renderer.xr.enabled;
252
+
253
+ this._renderer.xr.enabled = false;
245
254
 
246
255
  const cubeUVRenderTarget = renderTarget || this._allocateTargets();
247
256
  this._textureToCubeUV( texture, cubeUVRenderTarget );
@@ -813,6 +813,8 @@ class ObjectLoader extends Loader {
813
813
  if ( data.backgroundBlurriness !== undefined ) object.backgroundBlurriness = data.backgroundBlurriness;
814
814
  if ( data.backgroundIntensity !== undefined ) object.backgroundIntensity = data.backgroundIntensity;
815
815
  if ( data.backgroundRotation !== undefined ) object.backgroundRotation.fromArray( data.backgroundRotation );
816
+
817
+ if ( data.environmentIntensity !== undefined ) object.environmentIntensity = data.environmentIntensity;
816
818
  if ( data.environmentRotation !== undefined ) object.environmentRotation.fromArray( data.environmentRotation );
817
819
 
818
820
  break;
@@ -33,10 +33,6 @@ class ShaderMaterial extends Material {
33
33
  this.forceSinglePass = true;
34
34
 
35
35
  this.extensions = {
36
- derivatives: false, // set to use derivatives
37
- fragDepth: false, // set to use fragment depth values
38
- drawBuffers: false, // set to use draw buffers
39
- shaderTextureLOD: false, // set to use shader texture LOD
40
36
  clipCullDistance: false, // set to use vertex shader clipping
41
37
  multiDraw: false // set to use vertex shader multi_draw / enable gl_DrawID
42
38
  };
@@ -1,12 +1,11 @@
1
+ import * as MathUtils from './MathUtils.js';
2
+
1
3
  /**
2
4
  * Ref: https://en.wikipedia.org/wiki/Spherical_coordinate_system
3
5
  *
4
- * The polar angle (phi) is measured from the positive y-axis. The positive y-axis is up.
5
- * The azimuthal angle (theta) is measured from the positive z-axis.
6
+ * phi (the polar angle) is measured from the positive y-axis. The positive y-axis is up.
7
+ * theta (the azimuthal angle) is measured from the positive z-axis.
6
8
  */
7
-
8
- import * as MathUtils from './MathUtils.js';
9
-
10
9
  class Spherical {
11
10
 
12
11
  constructor( radius = 1, phi = 0, theta = 0 ) {