super-three 0.154.1 → 0.155.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 (106) hide show
  1. package/build/three.cjs +256 -38
  2. package/build/three.js +256 -38
  3. package/build/three.min.js +1 -1
  4. package/build/three.module.js +255 -39
  5. package/build/three.module.min.js +1 -1
  6. package/examples/jsm/controls/OrbitControls.js +143 -21
  7. package/examples/jsm/environments/RoomEnvironment.js +1 -1
  8. package/examples/jsm/exporters/USDZExporter.js +1 -0
  9. package/examples/jsm/interactive/SelectionHelper.js +7 -0
  10. package/examples/jsm/loaders/FBXLoader.js +1 -1
  11. package/examples/jsm/loaders/GLTFLoader.js +8 -3
  12. package/examples/jsm/loaders/KTX2Loader.js +4 -4
  13. package/examples/jsm/loaders/LDrawLoader.js +1 -1
  14. package/examples/jsm/loaders/NRRDLoader.js +3 -3
  15. package/examples/jsm/loaders/PLYLoader.js +1 -1
  16. package/examples/jsm/loaders/TGALoader.js +10 -10
  17. package/examples/jsm/loaders/VRMLLoader.js +1 -1
  18. package/examples/jsm/misc/GPUComputationRenderer.js +0 -9
  19. package/examples/jsm/misc/Volume.js +4 -6
  20. package/examples/jsm/nodes/Nodes.js +5 -6
  21. package/examples/jsm/nodes/accessors/BufferAttributeNode.js +1 -1
  22. package/examples/jsm/nodes/accessors/CubeTextureNode.js +2 -0
  23. package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +14 -1
  24. package/examples/jsm/nodes/accessors/InstanceNode.js +8 -8
  25. package/examples/jsm/nodes/accessors/MaterialNode.js +34 -44
  26. package/examples/jsm/nodes/accessors/SceneNode.js +6 -0
  27. package/examples/jsm/nodes/accessors/TextureNode.js +48 -7
  28. package/examples/jsm/nodes/core/LightingModel.js +7 -9
  29. package/examples/jsm/nodes/core/Node.js +11 -2
  30. package/examples/jsm/nodes/core/PropertyNode.js +4 -0
  31. package/examples/jsm/nodes/display/BumpMapNode.js +77 -0
  32. package/examples/jsm/nodes/display/NormalMapNode.js +2 -2
  33. package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +10 -2
  34. package/examples/jsm/nodes/functions/BSDF/Schlick_to_F0.js +13 -0
  35. package/examples/jsm/nodes/functions/PhongLightingModel.js +53 -14
  36. package/examples/jsm/nodes/functions/PhysicalLightingModel.js +236 -97
  37. package/examples/jsm/nodes/geometry/RangeNode.js +2 -2
  38. package/examples/jsm/nodes/gpgpu/ComputeNode.js +13 -0
  39. package/examples/jsm/nodes/lighting/AONode.js +1 -1
  40. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +58 -20
  41. package/examples/jsm/nodes/lighting/DirectionalLightNode.js +7 -10
  42. package/examples/jsm/nodes/lighting/EnvironmentNode.js +22 -12
  43. package/examples/jsm/nodes/lighting/HemisphereLightNode.js +1 -1
  44. package/examples/jsm/nodes/lighting/LightingContextNode.js +12 -9
  45. package/examples/jsm/nodes/lighting/PointLightNode.js +7 -10
  46. package/examples/jsm/nodes/lighting/SpotLightNode.js +7 -10
  47. package/examples/jsm/nodes/materials/Materials.js +1 -0
  48. package/examples/jsm/nodes/materials/MeshLambertNodeMaterial.js +34 -0
  49. package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +2 -0
  50. package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +2 -2
  51. package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +19 -2
  52. package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +2 -2
  53. package/examples/jsm/nodes/materials/NodeMaterial.js +50 -24
  54. package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +2 -2
  55. package/examples/jsm/nodes/shadernode/ShaderNode.js +2 -2
  56. package/examples/jsm/objects/Reflector.js +1 -9
  57. package/examples/jsm/objects/Refractor.js +0 -8
  58. package/examples/jsm/offscreen/scene.js +0 -1
  59. package/examples/jsm/postprocessing/MaskPass.js +4 -1
  60. package/examples/jsm/postprocessing/OutputPass.js +33 -14
  61. package/examples/jsm/postprocessing/UnrealBloomPass.js +21 -17
  62. package/examples/jsm/renderers/common/Background.js +22 -20
  63. package/examples/jsm/renderers/common/Binding.js +8 -0
  64. package/examples/jsm/renderers/common/Bindings.js +2 -6
  65. package/examples/jsm/renderers/common/Geometries.js +1 -1
  66. package/examples/jsm/renderers/common/Pipelines.js +94 -45
  67. package/examples/jsm/renderers/common/RenderContext.js +1 -0
  68. package/examples/jsm/renderers/common/RenderContexts.js +16 -5
  69. package/examples/jsm/renderers/common/RenderObject.js +20 -4
  70. package/examples/jsm/renderers/common/RenderObjects.js +10 -7
  71. package/examples/jsm/renderers/common/Renderer.js +70 -39
  72. package/examples/jsm/renderers/common/Textures.js +20 -8
  73. package/examples/jsm/renderers/common/nodes/Nodes.js +15 -4
  74. package/examples/jsm/renderers/webgpu/WebGPUBackend.js +51 -54
  75. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +33 -9
  76. package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +55 -36
  77. package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +83 -5
  78. package/examples/jsm/renderers/webgpu/utils/WebGPUConstants.js +24 -22
  79. package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +83 -130
  80. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +35 -8
  81. package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +1 -1
  82. package/examples/jsm/shaders/OutputShader.js +19 -2
  83. package/examples/jsm/utils/BufferGeometryUtils.js +13 -4
  84. package/examples/jsm/webxr/OculusHandPointerModel.js +2 -2
  85. package/package.json +2 -2
  86. package/src/Three.js +2 -0
  87. package/src/animation/PropertyBinding.js +1 -1
  88. package/src/cameras/CubeCamera.js +1 -4
  89. package/src/constants.js +1 -1
  90. package/src/core/BufferAttribute.js +20 -0
  91. package/src/core/Object3D.js +1 -1
  92. package/src/core/RenderTarget.js +122 -0
  93. package/src/geometries/CapsuleGeometry.js +1 -1
  94. package/src/loaders/DataTextureLoader.js +21 -2
  95. package/src/renderers/WebGLMultipleRenderTargets.js +0 -2
  96. package/src/renderers/WebGLRenderTarget.js +3 -110
  97. package/src/renderers/WebGLRenderer.js +62 -8
  98. package/src/renderers/shaders/ShaderChunk/iridescence_fragment.glsl.js +1 -2
  99. package/src/renderers/webgl/WebGLGeometries.js +5 -1
  100. package/src/renderers/webgl/WebGLMaterials.js +1 -1
  101. package/src/renderers/webgl/WebGLPrograms.js +14 -2
  102. package/src/renderers/webgl/WebGLTextures.js +97 -12
  103. package/src/textures/CompressedCubeTexture.js +19 -0
  104. package/examples/jsm/nodes/functions/BSDF/BRDF_BlinnPhong.js +0 -30
  105. package/examples/jsm/renderers/common/RenderTarget.js +0 -15
  106. package/examples/jsm/renderers/common/nodes/NodeRender.js +0 -302
@@ -33,24 +33,11 @@ class WebGPUPipelineUtils {
33
33
  const utils = backend.utils;
34
34
 
35
35
  const pipelineData = backend.get( pipeline );
36
-
37
- // determine shader attributes
38
-
39
- const shaderAttributes = backend.attributeUtils.createShaderAttributes( renderObject );
36
+ const bindingsData = backend.get( renderObject.getBindings() );
40
37
 
41
38
  // vertex buffers
42
39
 
43
- const vertexBuffers = [];
44
-
45
- for ( const attribute of shaderAttributes ) {
46
-
47
- vertexBuffers.push( {
48
- arrayStride: attribute.arrayStride,
49
- attributes: [ { shaderLocation: attribute.slot, offset: attribute.offset, format: attribute.format } ],
50
- stepMode: attribute.stepMode
51
- } );
52
-
53
- }
40
+ const vertexBuffers = backend.attributeUtils.createShaderVertexBuffers( renderObject );
54
41
 
55
42
  // blending
56
43
 
@@ -58,10 +45,7 @@ class WebGPUPipelineUtils {
58
45
 
59
46
  if ( material.transparent === true && material.blending !== NoBlending ) {
60
47
 
61
- blending = {
62
- alpha: this._getAlphaBlend( material ),
63
- color: this._getColorBlend( material )
64
- };
48
+ blending = this._getBlending( material );
65
49
 
66
50
  }
67
51
 
@@ -112,12 +96,14 @@ class WebGPUPipelineUtils {
112
96
  multisample: {
113
97
  count: sampleCount
114
98
  },
115
- layout: 'auto'
99
+ layout: device.createPipelineLayout( {
100
+ bindGroupLayouts: [ bindingsData.layout ]
101
+ } )
116
102
  } );
117
103
 
118
104
  }
119
105
 
120
- createComputePipeline( pipeline ) {
106
+ createComputePipeline( pipeline, bindings ) {
121
107
 
122
108
  const backend = this.backend;
123
109
  const device = backend.device;
@@ -125,100 +111,119 @@ class WebGPUPipelineUtils {
125
111
  const computeProgram = backend.get( pipeline.computeProgram ).module;
126
112
 
127
113
  const pipelineGPU = backend.get( pipeline );
114
+ const bindingsData = backend.get( bindings );
128
115
 
129
116
  pipelineGPU.pipeline = device.createComputePipeline( {
130
117
  compute: computeProgram,
131
- layout: 'auto'
118
+ layout: device.createPipelineLayout( {
119
+ bindGroupLayouts: [ bindingsData.layout ]
120
+ } )
132
121
  } );
133
122
 
134
123
  }
135
124
 
136
- _getAlphaBlend( material ) {
125
+ _getBlending( material ) {
126
+
127
+ let color, alpha;
137
128
 
138
129
  const blending = material.blending;
139
- const premultipliedAlpha = material.premultipliedAlpha;
140
130
 
141
- let alphaBlend = undefined;
131
+ if ( blending === CustomBlending ) {
142
132
 
143
- switch ( blending ) {
133
+ const blendSrcAlpha = material.blendSrcAlpha !== null ? material.blendSrcAlpha : GPUBlendFactor.One;
134
+ const blendDstAlpha = material.blendDstAlpha !== null ? material.blendDstAlpha : GPUBlendFactor.Zero;
135
+ const blendEquationAlpha = material.blendEquationAlpha !== null ? material.blendEquationAlpha : GPUBlendFactor.Add;
144
136
 
145
- case NormalBlending:
137
+ color = {
138
+ srcFactor: this._getBlendFactor( material.blendSrc ),
139
+ dstFactor: this._getBlendFactor( material.blendDst ),
140
+ operation: this._getBlendOperation( material.blendEquation )
141
+ };
146
142
 
147
- if ( premultipliedAlpha === false ) {
143
+ alpha = {
144
+ srcFactor: this._getBlendFactor( blendSrcAlpha ),
145
+ dstFactor: this._getBlendFactor( blendDstAlpha ),
146
+ operation: this._getBlendOperation( blendEquationAlpha )
147
+ };
148
148
 
149
- alphaBlend = {
150
- srcFactor: GPUBlendFactor.One,
151
- dstFactor: GPUBlendFactor.OneMinusSrcAlpha,
152
- operation: GPUBlendOperation.Add
153
- };
149
+ } else {
154
150
 
155
- }
151
+ const premultipliedAlpha = material.premultipliedAlpha;
156
152
 
157
- break;
153
+ const setBlend = ( srcRGB, dstRGB, srcAlpha, dstAlpha ) => {
158
154
 
159
- case AdditiveBlending:
155
+ color = {
156
+ srcFactor: srcRGB,
157
+ dstFactor: dstRGB,
158
+ operation: GPUBlendOperation.Add
159
+ };
160
160
 
161
- alphaBlend = {
162
- srcFactor: GPUBlendFactor.Zero,
163
- dstFactor: GPUBlendFactor.One,
161
+ alpha = {
162
+ srcFactor: srcAlpha,
163
+ dstFactor: dstAlpha,
164
164
  operation: GPUBlendOperation.Add
165
165
  };
166
166
 
167
- break;
167
+ };
168
+
169
+ if ( premultipliedAlpha ) {
168
170
 
169
- case SubtractiveBlending:
171
+ switch ( blending ) {
170
172
 
171
- if ( premultipliedAlpha === true ) {
173
+ case NormalBlending:
174
+ setBlend( GPUBlendFactor.SrcAlpha, GPUBlendFactor.OneMinusSrcAlpha, GPUBlendFactor.One, GPUBlendFactor.OneMinusSrcAlpha );
175
+ break;
172
176
 
173
- alphaBlend = {
174
- srcFactor: GPUBlendFactor.OneMinusSrcColor,
175
- dstFactor: GPUBlendFactor.OneMinusSrcAlpha,
176
- operation: GPUBlendOperation.Add
177
- };
177
+ case AdditiveBlending:
178
+ setBlend( GPUBlendFactor.SrcAlpha, GPUBlendFactor.One, GPUBlendFactor.One, GPUBlendFactor.One );
179
+ break;
180
+
181
+ case SubtractiveBlending:
182
+ setBlend( GPUBlendFactor.Zero, GPUBlendFactor.OneMinusSrc, GPUBlendFactor.Zero, GPUBlendFactor.One );
183
+ break;
184
+
185
+ case MultiplyBlending:
186
+ setBlend( GPUBlendFactor.Zero, GPUBlendFactor.Src, GPUBlendFactor.Zero, GPUBlendFactor.SrcAlpha );
187
+ break;
178
188
 
179
189
  }
180
190
 
181
- break;
191
+ } else {
182
192
 
183
- case MultiplyBlending:
193
+ switch ( blending ) {
184
194
 
185
- if ( premultipliedAlpha === true ) {
195
+ case NormalBlending:
196
+ setBlend( GPUBlendFactor.SrcAlpha, GPUBlendFactor.OneMinusSrcAlpha, GPUBlendFactor.One, GPUBlendFactor.OneMinusSrcAlpha );
197
+ break;
186
198
 
187
- alphaBlend = {
188
- srcFactor: GPUBlendFactor.Zero,
189
- dstFactor: GPUBlendFactor.SrcAlpha,
190
- operation: GPUBlendOperation.Add
191
- };
199
+ case AdditiveBlending:
200
+ setBlend( GPUBlendFactor.SrcAlpha, GPUBlendFactor.One, GPUBlendFactor.SrcAlpha, GPUBlendFactor.One );
201
+ break;
192
202
 
193
- }
203
+ case SubtractiveBlending:
204
+ setBlend( GPUBlendFactor.Zero, GPUBlendFactor.OneMinusSrc, GPUBlendFactor.Zero, GPUBlendFactor.One );
205
+ break;
194
206
 
195
- break;
207
+ case MultiplyBlending:
208
+ setBlend( GPUBlendFactor.Zero, GPUBlendFactor.Src, GPUBlendFactor.Zero, GPUBlendFactor.Src );
209
+ break;
196
210
 
197
- case CustomBlending:
211
+ }
198
212
 
199
- const blendSrcAlpha = material.blendSrcAlpha;
200
- const blendDstAlpha = material.blendDstAlpha;
201
- const blendEquationAlpha = material.blendEquationAlpha;
213
+ }
202
214
 
203
- if ( blendSrcAlpha !== null && blendDstAlpha !== null && blendEquationAlpha !== null ) {
215
+ }
204
216
 
205
- alphaBlend = {
206
- srcFactor: this._getBlendFactor( blendSrcAlpha ),
207
- dstFactor: this._getBlendFactor( blendDstAlpha ),
208
- operation: this._getBlendOperation( blendEquationAlpha )
209
- };
217
+ if ( color !== undefined && alpha !== undefined ) {
210
218
 
211
- }
219
+ return { color, alpha };
212
220
 
213
- break;
221
+ } else {
214
222
 
215
- default:
216
- console.error( 'THREE.WebGPURenderer: Blending not supported.', blending );
223
+ console.error( 'THREE.WebGPURenderer: Invalid blending: ', blending );
217
224
 
218
225
  }
219
226
 
220
- return alphaBlend;
221
-
222
227
  }
223
228
 
224
229
  _getBlendFactor( blend ) {
@@ -236,11 +241,11 @@ class WebGPUPipelineUtils {
236
241
  break;
237
242
 
238
243
  case SrcColorFactor:
239
- blendFactor = GPUBlendFactor.SrcColor;
244
+ blendFactor = GPUBlendFactor.Src;
240
245
  break;
241
246
 
242
247
  case OneMinusSrcColorFactor:
243
- blendFactor = GPUBlendFactor.OneMinusSrcColor;
248
+ blendFactor = GPUBlendFactor.OneMinusSrc;
244
249
  break;
245
250
 
246
251
  case SrcAlphaFactor:
@@ -252,7 +257,7 @@ class WebGPUPipelineUtils {
252
257
  break;
253
258
 
254
259
  case DstColorFactor:
255
- blendFactor = GPUBlendFactor.DstColor;
260
+ blendFactor = GPUBlendFactor.Dst;
256
261
  break;
257
262
 
258
263
  case OneMinusDstColorFactor:
@@ -272,11 +277,11 @@ class WebGPUPipelineUtils {
272
277
  break;
273
278
 
274
279
  case BlendColorFactor:
275
- blendFactor = GPUBlendFactor.BlendColor;
280
+ blendFactor = GPUBlendFactor.Constant;
276
281
  break;
277
282
 
278
283
  case OneMinusBlendColorFactor:
279
- blendFactor = GPUBlendFactor.OneMinusBlendColor;
284
+ blendFactor = GPUBlendFactor.OneMinusConstant;
280
285
  break;
281
286
 
282
287
  default:
@@ -288,58 +293,6 @@ class WebGPUPipelineUtils {
288
293
 
289
294
  }
290
295
 
291
- _getColorBlend( material ) {
292
-
293
- const blending = material.blending;
294
- const premultipliedAlpha = material.premultipliedAlpha;
295
-
296
- const colorBlend = {
297
- srcFactor: null,
298
- dstFactor: null,
299
- operation: null
300
- };
301
-
302
- switch ( blending ) {
303
-
304
- case NormalBlending:
305
- colorBlend.srcFactor = ( premultipliedAlpha === true ) ? GPUBlendFactor.One : GPUBlendFactor.SrcAlpha;
306
- colorBlend.dstFactor = GPUBlendFactor.OneMinusSrcAlpha;
307
- colorBlend.operation = GPUBlendOperation.Add;
308
- break;
309
-
310
- case AdditiveBlending:
311
- colorBlend.srcFactor = ( premultipliedAlpha === true ) ? GPUBlendFactor.One : GPUBlendFactor.SrcAlpha;
312
- colorBlend.dstFactor = GPUBlendFactor.One;
313
- colorBlend.operation = GPUBlendOperation.Add;
314
- break;
315
-
316
- case SubtractiveBlending:
317
- colorBlend.srcFactor = GPUBlendFactor.Zero;
318
- colorBlend.dstFactor = ( premultipliedAlpha === true ) ? GPUBlendFactor.Zero : GPUBlendFactor.OneMinusSrcColor;
319
- colorBlend.operation = GPUBlendOperation.Add;
320
- break;
321
-
322
- case MultiplyBlending:
323
- colorBlend.srcFactor = GPUBlendFactor.Zero;
324
- colorBlend.dstFactor = GPUBlendFactor.SrcColor;
325
- colorBlend.operation = GPUBlendOperation.Add;
326
- break;
327
-
328
- case CustomBlending:
329
- colorBlend.srcFactor = this._getBlendFactor( material.blendSrc );
330
- colorBlend.dstFactor = this._getBlendFactor( material.blendDst );
331
- colorBlend.operation = this._getBlendOperation( material.blendEquation );
332
- break;
333
-
334
- default:
335
- console.error( 'THREE.WebGPURenderer: Blending not supported.', blending );
336
-
337
- }
338
-
339
- return colorBlend;
340
-
341
- }
342
-
343
296
  _getStencilCompare( material ) {
344
297
 
345
298
  let stencilCompare;
@@ -19,13 +19,13 @@ import WebGPUTextureMipmapUtils from './WebGPUTextureMipmapUtils.js';
19
19
 
20
20
  const _compareToWebGPU = {
21
21
  [ NeverCompare ]: 'never',
22
- [ AlwaysCompare ]: 'less',
23
- [ LessCompare ]: 'equal',
22
+ [ LessCompare ]: 'less',
23
+ [ EqualCompare ]: 'equal',
24
24
  [ LessEqualCompare ]: 'less-equal',
25
- [ EqualCompare ]: 'greater',
26
- [ GreaterEqualCompare ]: 'not-equal',
27
- [ GreaterCompare ]: 'greater-equal',
28
- [ NotEqualCompare ]: 'always'
25
+ [ GreaterCompare ]: 'greater',
26
+ [ GreaterEqualCompare ]: 'greater-equal',
27
+ [ AlwaysCompare ]: 'always',
28
+ [ NotEqualCompare ]: 'not-equal'
29
29
  };
30
30
 
31
31
  class WebGPUTextureUtils {
@@ -103,8 +103,9 @@ class WebGPUTextureUtils {
103
103
  const dimension = this._getDimension( texture );
104
104
  const mipLevelCount = this._getMipLevelCount( texture, width, height, needsMipmaps );
105
105
  const format = texture.internalFormat || this._getFormat( texture );
106
- //const sampleCount = texture.isRenderTargetTexture || texture.isDepthTexture ? backend.utils.getSampleCount( renderContext ) : 1;
106
+
107
107
  const sampleCount = options.sampleCount !== undefined ? options.sampleCount : 1;
108
+ const primarySampleCount = texture.isRenderTargetTexture ? 1 : sampleCount;
108
109
 
109
110
  let usage = GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.COPY_SRC;
110
111
 
@@ -122,7 +123,7 @@ class WebGPUTextureUtils {
122
123
  depthOrArrayLayers: depth,
123
124
  },
124
125
  mipLevelCount: mipLevelCount,
125
- sampleCount: sampleCount,
126
+ sampleCount: primarySampleCount,
126
127
  dimension: dimension,
127
128
  format: format,
128
129
  usage: usage
@@ -144,10 +145,29 @@ class WebGPUTextureUtils {
144
145
 
145
146
  } else {
146
147
 
148
+ if ( format === undefined ) {
149
+
150
+ console.warn( 'WebGPURenderer: Texture format not supported.' );
151
+
152
+ return this.createDefaultTexture( texture );
153
+
154
+ }
155
+
147
156
  textureData.texture = backend.device.createTexture( textureDescriptorGPU );
148
157
 
149
158
  }
150
159
 
160
+ if ( texture.isRenderTargetTexture && sampleCount > 1 ) {
161
+
162
+ const msaaTextureDescriptorGPU = Object.assign( {}, textureDescriptorGPU );
163
+
164
+ msaaTextureDescriptorGPU.label = msaaTextureDescriptorGPU.label + '-msaa';
165
+ msaaTextureDescriptorGPU.sampleCount = sampleCount;
166
+
167
+ textureData.msaaTexture = backend.device.createTexture( msaaTextureDescriptorGPU );
168
+
169
+ }
170
+
151
171
  textureData.initialized = true;
152
172
 
153
173
  textureData.needsMipmaps = needsMipmaps;
@@ -162,6 +182,8 @@ class WebGPUTextureUtils {
162
182
 
163
183
  textureData.texture.destroy();
164
184
 
185
+ if ( textureData.msaaTexture !== undefined ) textureData.msaaTexture.destroy();
186
+
165
187
  backend.delete( texture );
166
188
 
167
189
  }
@@ -201,6 +223,9 @@ class WebGPUTextureUtils {
201
223
 
202
224
  const { needsMipmaps, textureDescriptorGPU } = textureData;
203
225
 
226
+ if ( textureDescriptorGPU === undefined ) // unsupported texture format
227
+ return;
228
+
204
229
  // transfer texture data
205
230
 
206
231
  if ( texture.isDataTexture || texture.isDataArrayTexture || texture.isData3DTexture ) {
@@ -243,6 +268,8 @@ class WebGPUTextureUtils {
243
268
 
244
269
  textureData.version = texture.version;
245
270
 
271
+ if ( texture.onUpdate ) texture.onUpdate( texture );
272
+
246
273
  }
247
274
 
248
275
  async copyTextureToBuffer( texture, x, y, width, height ) {
@@ -79,7 +79,7 @@ class WebGPUUtils {
79
79
 
80
80
  if ( renderContext.texture !== null ) {
81
81
 
82
- return 1;
82
+ return renderContext.sampleCount;
83
83
 
84
84
  }
85
85
 
@@ -1,3 +1,7 @@
1
+ import {
2
+ ShaderChunk
3
+ } from 'three';
4
+
1
5
  const OutputShader = {
2
6
 
3
7
  uniforms: {
@@ -8,6 +12,13 @@ const OutputShader = {
8
12
  },
9
13
 
10
14
  vertexShader: /* glsl */`
15
+ precision highp float;
16
+
17
+ uniform mat4 modelViewMatrix;
18
+ uniform mat4 projectionMatrix;
19
+
20
+ attribute vec3 position;
21
+ attribute vec2 uv;
11
22
 
12
23
  varying vec2 vUv;
13
24
 
@@ -19,10 +30,12 @@ const OutputShader = {
19
30
  }`,
20
31
 
21
32
  fragmentShader: /* glsl */`
33
+
34
+ precision highp float;
22
35
 
23
36
  uniform sampler2D tDiffuse;
24
37
 
25
- #include <tonemapping_pars_fragment>
38
+ ` + ShaderChunk[ 'tonemapping_pars_fragment' ] + ShaderChunk[ 'colorspace_pars_fragment' ] + `
26
39
 
27
40
  varying vec2 vUv;
28
41
 
@@ -52,7 +65,11 @@ const OutputShader = {
52
65
 
53
66
  // color space
54
67
 
55
- gl_FragColor = LinearTosRGB( gl_FragColor );
68
+ #ifdef SRGB_COLOR_SPACE
69
+
70
+ gl_FragColor = LinearTosRGB( gl_FragColor );
71
+
72
+ #endif
56
73
 
57
74
  }`
58
75
 
@@ -1229,14 +1229,21 @@ function mergeGroups( geometry ) {
1229
1229
  }
1230
1230
 
1231
1231
 
1232
- // Creates a new, non-indexed geometry with smooth normals everywhere except faces that meet at
1233
- // an angle greater than the crease angle.
1232
+ /**
1233
+ * Modifies the supplied geometry if it is non-indexed, otherwise creates a new,
1234
+ * non-indexed geometry. Returns the geometry with smooth normals everywhere except
1235
+ * faces that meet at an angle greater than the crease angle.
1236
+ *
1237
+ * @param {BufferGeometry} geometry
1238
+ * @param {number} [creaseAngle]
1239
+ * @return {BufferGeometry}
1240
+ */
1234
1241
  function toCreasedNormals( geometry, creaseAngle = Math.PI / 3 /* 60 degrees */ ) {
1235
1242
 
1236
1243
  const creaseDot = Math.cos( creaseAngle );
1237
1244
  const hashMultiplier = ( 1 + 1e-10 ) * 1e2;
1238
1245
 
1239
- // reusable vertors
1246
+ // reusable vectors
1240
1247
  const verts = [ new Vector3(), new Vector3(), new Vector3() ];
1241
1248
  const tempVec1 = new Vector3();
1242
1249
  const tempVec2 = new Vector3();
@@ -1253,7 +1260,9 @@ function toCreasedNormals( geometry, creaseAngle = Math.PI / 3 /* 60 degrees */
1253
1260
 
1254
1261
  }
1255
1262
 
1256
- const resultGeometry = geometry.toNonIndexed();
1263
+ // BufferGeometry.toNonIndexed() warns if the geometry is non-indexed
1264
+ // and returns the original geometry
1265
+ const resultGeometry = geometry.index ? geometry.toNonIndexed() : geometry;
1257
1266
  const posAttr = resultGeometry.attributes.position;
1258
1267
  const vertexMap = {};
1259
1268
 
@@ -70,8 +70,8 @@ class OculusHandPointerModel extends THREE.Object3D {
70
70
  this.visible = false;
71
71
  this.xrInputSource = null;
72
72
 
73
- this.pointerGeometry.dispose();
74
- this.pointerMesh.material.dispose();
73
+ if ( this.pointerGeometry ) this.pointerGeometry.dispose();
74
+ if ( this.pointerMesh && this.pointerMesh.material ) this.pointerMesh.material.dispose();
75
75
 
76
76
  this.clear();
77
77
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "super-three",
3
- "version": "0.154.1",
3
+ "version": "0.155.0",
4
4
  "description": "JavaScript 3D library",
5
5
  "type": "module",
6
6
  "main": "./build/three.js",
@@ -103,7 +103,7 @@
103
103
  "rollup": "^3.20.2",
104
104
  "rollup-plugin-filesize": "^10.0.0",
105
105
  "rollup-plugin-visualizer": "^5.9.0",
106
- "servez": "^1.14.2"
106
+ "servez": "^2.0.0"
107
107
  },
108
108
  "overrides": {
109
109
  "jpeg-js": "^0.4.4"
package/src/Three.js CHANGED
@@ -34,6 +34,7 @@ export { DataArrayTexture } from './textures/DataArrayTexture.js';
34
34
  export { Data3DTexture } from './textures/Data3DTexture.js';
35
35
  export { CompressedTexture } from './textures/CompressedTexture.js';
36
36
  export { CompressedArrayTexture } from './textures/CompressedArrayTexture.js';
37
+ export { CompressedCubeTexture } from './textures/CompressedCubeTexture.js';
37
38
  export { CubeTexture } from './textures/CubeTexture.js';
38
39
  export { CanvasTexture } from './textures/CanvasTexture.js';
39
40
  export { DepthTexture } from './textures/DepthTexture.js';
@@ -91,6 +92,7 @@ export { AnimationObjectGroup } from './animation/AnimationObjectGroup.js';
91
92
  export { AnimationMixer } from './animation/AnimationMixer.js';
92
93
  export { AnimationClip } from './animation/AnimationClip.js';
93
94
  export { AnimationAction } from './animation/AnimationAction.js';
95
+ export { RenderTarget } from './core/RenderTarget.js';
94
96
  export { Uniform } from './core/Uniform.js';
95
97
  export { UniformsGroup } from './core/UniformsGroup.js';
96
98
  export { InstancedBufferGeometry } from './core/InstancedBufferGeometry.js';
@@ -436,7 +436,7 @@ class PropertyBinding {
436
436
  // ensure there is a value node
437
437
  if ( ! targetObject ) {
438
438
 
439
- console.error( 'THREE.PropertyBinding: Trying to update node for track: ' + this.path + ' but it wasn\'t found.' );
439
+ console.warn( 'THREE.PropertyBinding: No target node found for track: ' + this.path + '.' );
440
440
  return;
441
441
 
442
442
  }
@@ -1,4 +1,4 @@
1
- import { NoToneMapping, WebGLCoordinateSystem, WebGPUCoordinateSystem } from '../constants.js';
1
+ import { WebGLCoordinateSystem, WebGPUCoordinateSystem } from '../constants.js';
2
2
  import { Object3D } from '../core/Object3D.js';
3
3
  import { PerspectiveCamera } from './PerspectiveCamera.js';
4
4
 
@@ -126,10 +126,8 @@ class CubeCamera extends Object3D {
126
126
 
127
127
  const currentRenderTarget = renderer.getRenderTarget();
128
128
 
129
- const currentToneMapping = renderer.toneMapping;
130
129
  const currentXrEnabled = renderer.xr.enabled;
131
130
 
132
- renderer.toneMapping = NoToneMapping;
133
131
  renderer.xr.enabled = false;
134
132
 
135
133
  const generateMipmaps = renderTarget.texture.generateMipmaps;
@@ -158,7 +156,6 @@ class CubeCamera extends Object3D {
158
156
 
159
157
  renderer.setRenderTarget( currentRenderTarget );
160
158
 
161
- renderer.toneMapping = currentToneMapping;
162
159
  renderer.xr.enabled = currentXrEnabled;
163
160
 
164
161
  renderTarget.texture.needsPMREMUpdate = true;
package/src/constants.js CHANGED
@@ -1,4 +1,4 @@
1
- export const REVISION = '154';
1
+ export const REVISION = '155';
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 };
@@ -175,6 +175,26 @@ class BufferAttribute {
175
175
 
176
176
  }
177
177
 
178
+ getComponent( index, component ) {
179
+
180
+ let value = this.array[ index * this.itemSize + component ];
181
+
182
+ if ( this.normalized ) value = denormalize( value, this.array );
183
+
184
+ return value;
185
+
186
+ }
187
+
188
+ setComponent( index, component, value ) {
189
+
190
+ if ( this.normalized ) value = normalize( value, this.array );
191
+
192
+ this.array[ index * this.itemSize + component ] = value;
193
+
194
+ return this;
195
+
196
+ }
197
+
178
198
  getX( index ) {
179
199
 
180
200
  let x = this.array[ index * this.itemSize ];
@@ -945,7 +945,7 @@ class Object3D extends EventDispatcher {
945
945
  this.frustumCulled = source.frustumCulled;
946
946
  this.renderOrder = source.renderOrder;
947
947
 
948
- this.animations = source.animations;
948
+ this.animations = source.animations.slice();
949
949
 
950
950
  this.userData = JSON.parse( JSON.stringify( source.userData ) );
951
951