super-three 0.161.0 → 0.162.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 (131) hide show
  1. package/build/three.cjs +490 -393
  2. package/build/three.module.js +490 -391
  3. package/build/three.module.min.js +1 -1
  4. package/examples/jsm/controls/DragControls.js +91 -30
  5. package/examples/jsm/controls/OrbitControls.js +32 -6
  6. package/examples/jsm/controls/TransformControls.js +6 -6
  7. package/examples/jsm/exporters/GLTFExporter.js +11 -1
  8. package/examples/jsm/interactive/InteractiveGroup.js +15 -25
  9. package/examples/jsm/libs/rhino3dm/rhino3dm.js +1 -8723
  10. package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +1 -8734
  11. package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
  12. package/examples/jsm/libs/tween.module.js +32 -14
  13. package/examples/jsm/loaders/3DMLoader.js +13 -21
  14. package/examples/jsm/loaders/VOXLoader.js +9 -2
  15. package/examples/jsm/loaders/VRMLLoader.js +6 -2
  16. package/examples/jsm/misc/ProgressiveLightMap.js +1 -0
  17. package/examples/jsm/nodes/Nodes.js +9 -7
  18. package/examples/jsm/nodes/accessors/AccessorsUtils.js +10 -0
  19. package/examples/jsm/nodes/accessors/ClippingNode.js +144 -0
  20. package/examples/jsm/nodes/accessors/MaterialNode.js +2 -2
  21. package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +2 -12
  22. package/examples/jsm/nodes/accessors/MorphNode.js +8 -8
  23. package/examples/jsm/nodes/accessors/ReferenceNode.js +87 -29
  24. package/examples/jsm/nodes/accessors/SkinningNode.js +31 -10
  25. package/examples/jsm/nodes/accessors/StorageBufferNode.js +18 -0
  26. package/examples/jsm/nodes/accessors/TangentNode.js +8 -2
  27. package/examples/jsm/nodes/accessors/TextureNode.js +1 -1
  28. package/examples/jsm/nodes/accessors/UniformsNode.js +140 -0
  29. package/examples/jsm/nodes/code/CodeNode.js +6 -0
  30. package/examples/jsm/nodes/core/AssignNode.js +68 -12
  31. package/examples/jsm/nodes/core/Node.js +14 -4
  32. package/examples/jsm/nodes/core/NodeBuilder.js +3 -9
  33. package/examples/jsm/nodes/core/NodeFrame.js +2 -2
  34. package/examples/jsm/nodes/core/TempNode.js +1 -1
  35. package/examples/jsm/nodes/display/BlendModeNode.js +30 -1
  36. package/examples/jsm/nodes/display/NormalMapNode.js +3 -5
  37. package/examples/jsm/nodes/materials/NodeMaterial.js +37 -6
  38. package/examples/jsm/nodes/math/CondNode.js +42 -7
  39. package/examples/jsm/nodes/math/MathNode.js +20 -0
  40. package/examples/jsm/nodes/utils/ArrayElementNode.js +0 -6
  41. package/examples/jsm/nodes/utils/LoopNode.js +2 -0
  42. package/examples/jsm/nodes/utils/StorageArrayElementNode.js +91 -0
  43. package/examples/jsm/postprocessing/OutputPass.js +2 -0
  44. package/examples/jsm/renderers/common/Background.js +2 -2
  45. package/examples/jsm/renderers/common/ClippingContext.js +165 -0
  46. package/examples/jsm/renderers/common/RenderContext.js +2 -0
  47. package/examples/jsm/renderers/common/RenderContexts.js +2 -13
  48. package/examples/jsm/renderers/common/RenderObject.js +44 -1
  49. package/examples/jsm/renderers/common/RenderObjects.js +3 -1
  50. package/examples/jsm/renderers/common/Renderer.js +94 -37
  51. package/examples/jsm/renderers/common/StorageBufferAttribute.js +2 -2
  52. package/examples/jsm/renderers/common/StorageInstancedBufferAttribute.js +17 -0
  53. package/examples/jsm/renderers/common/Textures.js +3 -13
  54. package/examples/jsm/renderers/common/UniformsGroup.js +6 -4
  55. package/examples/jsm/renderers/common/nodes/NodeStorageBuffer.js +23 -0
  56. package/examples/jsm/renderers/common/nodes/NodeUniformBuffer.js +23 -0
  57. package/examples/jsm/renderers/common/nodes/Nodes.js +1 -0
  58. package/examples/jsm/renderers/webgl/WebGLBackend.js +26 -6
  59. package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +135 -10
  60. package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +7 -1
  61. package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +47 -0
  62. package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +1 -0
  63. package/examples/jsm/renderers/webgpu/WebGPUBackend.js +13 -12
  64. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +15 -40
  65. package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +7 -1
  66. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +2 -2
  67. package/examples/jsm/shaders/OutputShader.js +4 -0
  68. package/examples/jsm/utils/SkeletonUtils.js +14 -3
  69. package/examples/jsm/webxr/VRButton.js +13 -5
  70. package/examples/jsm/webxr/XRButton.js +0 -1
  71. package/examples/jsm/webxr/XRControllerModelFactory.js +8 -0
  72. package/package.json +4 -3
  73. package/src/Three.Legacy.js +20 -0
  74. package/src/Three.js +0 -1
  75. package/src/constants.js +2 -5
  76. package/src/core/BufferAttribute.js +0 -11
  77. package/src/core/BufferGeometry.js +23 -29
  78. package/src/core/Object3D.js +11 -0
  79. package/src/core/Raycaster.js +18 -4
  80. package/src/core/RenderTarget.js +44 -21
  81. package/src/extras/PMREMGenerator.js +2 -0
  82. package/src/extras/curves/EllipseCurve.js +2 -2
  83. package/src/helpers/SpotLightHelper.js +18 -1
  84. package/src/loaders/DataTextureLoader.js +0 -4
  85. package/src/loaders/MaterialLoader.js +1 -0
  86. package/src/loaders/ObjectLoader.js +2 -1
  87. package/src/materials/Material.js +2 -1
  88. package/src/materials/MeshBasicMaterial.js +3 -0
  89. package/src/materials/MeshLambertMaterial.js +3 -0
  90. package/src/materials/MeshPhongMaterial.js +3 -0
  91. package/src/materials/MeshStandardMaterial.js +3 -0
  92. package/src/math/Quaternion.js +13 -12
  93. package/src/math/Vector3.js +7 -7
  94. package/src/objects/InstancedMesh.js +53 -0
  95. package/src/objects/Mesh.js +0 -1
  96. package/src/renderers/WebGLCubeRenderTarget.js +1 -10
  97. package/src/renderers/WebGLRenderer.js +15 -22
  98. package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -0
  99. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +1 -1
  100. package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +2 -2
  101. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +1 -1
  102. package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +14 -0
  103. package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +11 -2
  104. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +23 -0
  105. package/src/renderers/shaders/ShaderChunk.js +2 -0
  106. package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +3 -2
  107. package/src/renderers/shaders/ShaderLib/depth.glsl.js +2 -0
  108. package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +2 -0
  109. package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +1 -0
  110. package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +1 -0
  111. package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +1 -0
  112. package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +1 -0
  113. package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -0
  114. package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +1 -0
  115. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +1 -0
  116. package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +1 -0
  117. package/src/renderers/shaders/ShaderLib/points.glsl.js +1 -0
  118. package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -0
  119. package/src/renderers/shaders/ShaderLib.js +2 -1
  120. package/src/renderers/shaders/UniformsLib.js +1 -0
  121. package/src/renderers/webgl/WebGLBackground.js +18 -0
  122. package/src/renderers/webgl/WebGLMaterials.js +24 -1
  123. package/src/renderers/webgl/WebGLMorphtargets.js +15 -8
  124. package/src/renderers/webgl/WebGLProgram.js +12 -1
  125. package/src/renderers/webgl/WebGLPrograms.js +19 -16
  126. package/src/renderers/webgl/WebGLState.js +11 -21
  127. package/src/renderers/webgl/WebGLTextures.js +80 -50
  128. package/src/scenes/Scene.js +8 -0
  129. package/src/textures/Texture.js +1 -29
  130. package/examples/jsm/nodes/core/ArrayUniformNode.js +0 -26
  131. package/src/renderers/WebGLMultipleRenderTargets.js +0 -82
@@ -8,6 +8,9 @@ class DualAttributeData {
8
8
 
9
9
  this.buffers = [ attributeData.bufferGPU, dualBuffer ];
10
10
  this.type = attributeData.type;
11
+ this.bufferType = attributeData.bufferType;
12
+ this.pbo = attributeData.pbo;
13
+ this.byteLength = attributeData.byteLength;
11
14
  this.bytesPerElement = attributeData.BYTES_PER_ELEMENT;
12
15
  this.version = attributeData.version;
13
16
  this.isInteger = attributeData.isInteger;
@@ -126,14 +129,17 @@ class WebGLAttributeUtils {
126
129
 
127
130
  let attributeData = {
128
131
  bufferGPU,
132
+ bufferType,
129
133
  type,
134
+ byteLength: array.byteLength,
130
135
  bytesPerElement: array.BYTES_PER_ELEMENT,
131
136
  version: attribute.version,
137
+ pbo: attribute.pbo,
132
138
  isInteger: type === gl.INT || type === gl.UNSIGNED_INT || attribute.gpuType === IntType,
133
139
  id: _id ++
134
140
  };
135
141
 
136
- if ( attribute.isStorageBufferAttribute ) {
142
+ if ( attribute.isStorageBufferAttribute || attribute.isStorageInstancedBufferAttribute ) {
137
143
 
138
144
  // create buffer for tranform feedback use
139
145
  const bufferGPUDual = this._createBuffer( gl, bufferType, array, usage );
@@ -135,6 +135,17 @@ class WebGLTextureUtils {
135
135
 
136
136
  }
137
137
 
138
+ if ( glFormat === gl.RGB ) {
139
+
140
+ if ( glType === gl.FLOAT ) internalFormat = gl.RGB32F;
141
+ if ( glType === gl.HALF_FLOAT ) internalFormat = gl.RGB16F;
142
+ if ( glType === gl.UNSIGNED_BYTE ) internalFormat = gl.RGB8;
143
+ if ( glType === gl.UNSIGNED_SHORT_5_6_5 ) internalFormat = gl.RGB565;
144
+ if ( glType === gl.UNSIGNED_SHORT_5_5_5_1 ) internalFormat = gl.RGB5_A1;
145
+ if ( glType === gl.UNSIGNED_SHORT_4_4_4_4 ) internalFormat = gl.RGB4;
146
+
147
+ }
148
+
138
149
  if ( glFormat === gl.RGBA ) {
139
150
 
140
151
  if ( glType === gl.FLOAT ) internalFormat = gl.RGBA32F;
@@ -207,6 +218,7 @@ class WebGLTextureUtils {
207
218
  if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false ) return; // verify extension for WebGL 1 and WebGL 2
208
219
 
209
220
  if ( texture.anisotropy > 1 || currentAnisotropy !== texture.anisotropy ) {
221
+
210
222
  const extension = extensions.get( 'EXT_texture_filter_anisotropic' );
211
223
  gl.texParameterf( textureType, extension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min( texture.anisotropy, backend.getMaxAnisotropy() ) );
212
224
  backend.get( texture ).currentAnisotropy = texture.anisotropy;
@@ -289,6 +301,41 @@ class WebGLTextureUtils {
289
301
 
290
302
  }
291
303
 
304
+ copyBufferToTexture( buffer, texture ) {
305
+
306
+ const { gl, backend } = this;
307
+
308
+ const { textureGPU, glTextureType, glFormat, glType } = backend.get( texture );
309
+
310
+ const { width, height } = texture.source.data;
311
+
312
+ gl.bindBuffer( gl.PIXEL_UNPACK_BUFFER, buffer );
313
+
314
+ backend.state.bindTexture( glTextureType, textureGPU );
315
+
316
+ gl.pixelStorei( gl.UNPACK_FLIP_Y_WEBGL, false );
317
+ gl.pixelStorei( gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false );
318
+ gl.texSubImage2D( glTextureType, 0, 0, 0, width, height, glFormat, glType, 0 );
319
+
320
+ gl.bindBuffer( gl.PIXEL_UNPACK_BUFFER, null );
321
+
322
+ backend.state.unbindTexture();
323
+ // debug
324
+ // const framebuffer = gl.createFramebuffer();
325
+ // gl.bindFramebuffer( gl.FRAMEBUFFER, framebuffer );
326
+ // gl.framebufferTexture2D( gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, glTextureType, textureGPU, 0 );
327
+
328
+ // const readout = new Float32Array( width * height * 4 );
329
+
330
+ // const altFormat = gl.getParameter( gl.IMPLEMENTATION_COLOR_READ_FORMAT );
331
+ // const altType = gl.getParameter( gl.IMPLEMENTATION_COLOR_READ_TYPE );
332
+
333
+ // gl.readPixels( 0, 0, width, height, altFormat, altType, readout );
334
+ // gl.bindFramebuffer( gl.FRAMEBUFFER, null );
335
+ // console.log( readout );
336
+
337
+ }
338
+
292
339
  updateTexture( texture, options ) {
293
340
 
294
341
  const { gl } = this;
@@ -35,6 +35,7 @@ class WebGLUtils {
35
35
  }
36
36
 
37
37
  if ( p === AlphaFormat ) return gl.ALPHA;
38
+ if ( p === gl.RGB ) return gl.RGB; // patch since legacy doesn't use RGBFormat for rendering but here it's needed for packing optimization
38
39
  if ( p === RGBAFormat ) return gl.RGBA;
39
40
  if ( p === LuminanceFormat ) return gl.LUMINANCE;
40
41
  if ( p === LuminanceAlphaFormat ) return gl.LUMINANCE_ALPHA;
@@ -602,9 +602,6 @@ class WebGPUBackend extends Backend {
602
602
  supportsDepth = renderer.depth;
603
603
  supportsStencil = renderer.stencil;
604
604
 
605
- depth = depth && supportsDepth;
606
- stencil = stencil && supportsStencil;
607
-
608
605
  const descriptor = this._getDefaultRenderPassDescriptor();
609
606
 
610
607
  if ( color ) {
@@ -619,7 +616,7 @@ class WebGPUBackend extends Backend {
619
616
 
620
617
  }
621
618
 
622
- if ( depth || stencil ) {
619
+ if ( supportsDepth || supportsStencil ) {
623
620
 
624
621
  depthStencilAttachment = descriptor.depthStencilAttachment;
625
622
 
@@ -630,9 +627,6 @@ class WebGPUBackend extends Backend {
630
627
  supportsDepth = renderTargetData.depth;
631
628
  supportsStencil = renderTargetData.stencil;
632
629
 
633
- depth = depth && supportsDepth;
634
- stencil = stencil && supportsStencil;
635
-
636
630
  if ( color ) {
637
631
 
638
632
  for ( const texture of renderTargetData.textures ) {
@@ -666,7 +660,7 @@ class WebGPUBackend extends Backend {
666
660
 
667
661
  }
668
662
 
669
- if ( depth || stencil ) {
663
+ if ( supportsDepth || supportsStencil ) {
670
664
 
671
665
  const depthTextureData = this.get( renderTargetData.depthTexture );
672
666
 
@@ -680,7 +674,7 @@ class WebGPUBackend extends Backend {
680
674
 
681
675
  //
682
676
 
683
- if ( depthStencilAttachment !== undefined ) {
677
+ if ( supportsDepth ) {
684
678
 
685
679
  if ( depth ) {
686
680
 
@@ -695,7 +689,11 @@ class WebGPUBackend extends Backend {
695
689
 
696
690
  }
697
691
 
698
- //
692
+ }
693
+
694
+ //
695
+
696
+ if ( supportsStencil ) {
699
697
 
700
698
  if ( stencil ) {
701
699
 
@@ -929,7 +927,8 @@ class WebGPUBackend extends Backend {
929
927
  data.side !== material.side || data.alphaToCoverage !== material.alphaToCoverage ||
930
928
  data.sampleCount !== sampleCount || data.colorSpace !== colorSpace ||
931
929
  data.colorFormat !== colorFormat || data.depthStencilFormat !== depthStencilFormat ||
932
- data.primitiveTopology !== primitiveTopology
930
+ data.primitiveTopology !== primitiveTopology ||
931
+ data.clippingContextVersion !== renderObject.clippingContextVersion
933
932
  ) {
934
933
 
935
934
  data.material = material; data.materialVersion = material.version;
@@ -947,6 +946,7 @@ class WebGPUBackend extends Backend {
947
946
  data.colorFormat = colorFormat;
948
947
  data.depthStencilFormat = depthStencilFormat;
949
948
  data.primitiveTopology = primitiveTopology;
949
+ data.clippingContextVersion = renderObject.clippingContextVersion;
950
950
 
951
951
  needsUpdate = true;
952
952
 
@@ -975,7 +975,8 @@ class WebGPUBackend extends Backend {
975
975
  material.side,
976
976
  utils.getSampleCount( renderContext ),
977
977
  utils.getCurrentColorSpace( renderContext ), utils.getCurrentColorFormat( renderContext ), utils.getCurrentDepthStencilFormat( renderContext ),
978
- utils.getPrimitiveTopology( object, material )
978
+ utils.getPrimitiveTopology( object, material ),
979
+ renderObject.clippingContextVersion
979
980
  ].join();
980
981
 
981
982
  }
@@ -5,9 +5,8 @@ import NodeUniformsGroup from '../../common/nodes/NodeUniformsGroup.js';
5
5
  import NodeSampler from '../../common/nodes/NodeSampler.js';
6
6
  import { NodeSampledTexture, NodeSampledCubeTexture } from '../../common/nodes/NodeSampledTexture.js';
7
7
 
8
- import UniformBuffer from '../../common/UniformBuffer.js';
9
- import StorageBuffer from '../../common/StorageBuffer.js';
10
- import { getVectorLength, getStrideLength } from '../../common/BufferUtils.js';
8
+ import NodeUniformBuffer from '../../common/nodes/NodeUniformBuffer.js';
9
+ import NodeStorageBuffer from '../../common/nodes/NodeStorageBuffer.js';
11
10
 
12
11
  import { NodeBuilder, CodeNode } from '../../../nodes/Nodes.js';
13
12
 
@@ -78,6 +77,10 @@ const wgslMethods = {
78
77
  mod_vec2: 'threejs_mod_vec2',
79
78
  mod_vec3: 'threejs_mod_vec3',
80
79
  mod_vec4: 'threejs_mod_vec4',
80
+ equals_bool: 'threejs_equals_bool',
81
+ equals_bvec2: 'threejs_equals_bvec2',
82
+ equals_bvec3: 'threejs_equals_bvec3',
83
+ equals_bvec4: 'threejs_equals_bvec4',
81
84
  lessThanEqual: 'threejs_lessThanEqual',
82
85
  greaterThan: 'threejs_greaterThan',
83
86
  inversesqrt: 'inverseSqrt',
@@ -110,6 +113,10 @@ fn threejs_greaterThan( a : vec3<f32>, b : vec3<f32> ) -> vec3<bool> {
110
113
  mod_vec2: new CodeNode( 'fn threejs_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }' ),
111
114
  mod_vec3: new CodeNode( 'fn threejs_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }' ),
112
115
  mod_vec4: new CodeNode( 'fn threejs_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }' ),
116
+ equals_bool: new CodeNode( 'fn threejs_equals_bool( a : bool, b : bool ) -> bool { return a == b; }' ),
117
+ equals_bvec2: new CodeNode( 'fn threejs_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }' ),
118
+ equals_bvec3: new CodeNode( 'fn threejs_equals_bvec3( a : vec3f, b : vec3f ) -> vec3<bool> { return vec3<bool>( a.x == b.x, a.y == b.y, a.z == b.z ); }' ),
119
+ equals_bvec4: new CodeNode( 'fn threejs_equals_bvec4( a : vec4f, b : vec4f ) -> vec4<bool> { return vec4<bool>( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }' ),
113
120
  repeatWrapping: new CodeNode( `
114
121
  fn threejs_repeatWrapping( uv : vec2<f32>, dimension : vec2<u32> ) -> vec2<u32> {
115
122
 
@@ -383,8 +390,8 @@ class WGSLNodeBuilder extends NodeBuilder {
383
390
 
384
391
  } else if ( type === 'buffer' || type === 'storageBuffer' ) {
385
392
 
386
- const bufferClass = type === 'storageBuffer' ? StorageBuffer : UniformBuffer;
387
- const buffer = new bufferClass( 'NodeBuffer_' + node.id, node.value );
393
+ const bufferClass = type === 'storageBuffer' ? NodeStorageBuffer : NodeUniformBuffer;
394
+ const buffer = new bufferClass( node );
388
395
  buffer.setVisibility( gpuShaderStageLib[ shaderStage ] );
389
396
 
390
397
  bindings.push( buffer );
@@ -411,31 +418,9 @@ class WGSLNodeBuilder extends NodeBuilder {
411
418
 
412
419
  }
413
420
 
414
- if ( node.isArrayUniformNode === true ) {
421
+ uniformGPU = this.getNodeUniform( uniformNode, type );
415
422
 
416
- uniformGPU = [];
417
-
418
- for ( const uniformNode of node.nodes ) {
419
-
420
- const uniformNodeGPU = this.getNodeUniform( uniformNode, type );
421
-
422
- // fit bounds to buffer
423
- uniformNodeGPU.boundary = getVectorLength( uniformNodeGPU.itemSize );
424
- uniformNodeGPU.itemSize = getStrideLength( uniformNodeGPU.itemSize );
425
-
426
- uniformsGroup.addUniform( uniformNodeGPU );
427
-
428
- uniformGPU.push( uniformNodeGPU );
429
-
430
- }
431
-
432
- } else {
433
-
434
- uniformGPU = this.getNodeUniform( uniformNode, type );
435
-
436
- uniformsGroup.addUniform( uniformGPU );
437
-
438
- }
423
+ uniformsGroup.addUniform( uniformGPU );
439
424
 
440
425
  }
441
426
 
@@ -806,17 +791,7 @@ ${ flowData.code }
806
791
  snippets: []
807
792
  } );
808
793
 
809
- if ( Array.isArray( uniform.value ) === true ) {
810
-
811
- const length = uniform.value.length;
812
-
813
- group.snippets.push( `uniform ${vectorType}[ ${length} ] ${uniform.name}` );
814
-
815
- } else {
816
-
817
- group.snippets.push( `\t${uniform.name} : ${ vectorType}` );
818
-
819
- }
794
+ group.snippets.push( `\t${ uniform.name } : ${ vectorType }` );
820
795
 
821
796
  }
822
797
 
@@ -44,11 +44,17 @@ class WebGPUAttributeUtils {
44
44
 
45
45
  let array = bufferAttribute.array;
46
46
 
47
- if ( bufferAttribute.isStorageBufferAttribute && bufferAttribute.itemSize === 3 ) {
47
+ if ( ( bufferAttribute.isStorageBufferAttribute || bufferAttribute.isStorageInstancedBufferAttribute ) && bufferAttribute.itemSize === 3 ) {
48
48
 
49
49
  bufferAttribute.itemSize = 4;
50
50
  array = new array.constructor( bufferAttribute.count * 4 );
51
51
 
52
+ for ( let i = 0; i < bufferAttribute.count; i ++ ) {
53
+
54
+ array.set( bufferAttribute.array.subarray( i * 3, i * 3 + 3 ), i * 4 );
55
+
56
+ }
57
+
52
58
  }
53
59
 
54
60
  const size = array.byteLength + ( ( 4 - ( array.byteLength % 4 ) ) % 4 ); // ensure 4 byte alignment, see #20441
@@ -327,13 +327,13 @@ class WebGPUTextureUtils {
327
327
 
328
328
  if ( texture.isDataTexture || texture.isData3DTexture ) {
329
329
 
330
- this._copyBufferToTexture( options.image, textureData.texture, textureDescriptorGPU, 0, false );
330
+ this._copyBufferToTexture( options.image, textureData.texture, textureDescriptorGPU, 0, texture.flipY );
331
331
 
332
332
  } else if ( texture.isDataArrayTexture ) {
333
333
 
334
334
  for ( let i = 0; i < options.image.depth; i ++ ) {
335
335
 
336
- this._copyBufferToTexture( options.image, textureData.texture, textureDescriptorGPU, i, false, i );
336
+ this._copyBufferToTexture( options.image, textureData.texture, textureDescriptorGPU, i, texture.flipY, i );
337
337
 
338
338
  }
339
339
 
@@ -64,6 +64,10 @@ const OutputShader = {
64
64
 
65
65
  gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );
66
66
 
67
+ #elif defined( NEUTRAL_TONE_MAPPING )
68
+
69
+ gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );
70
+
67
71
  #endif
68
72
 
69
73
  // color space
@@ -200,7 +200,8 @@ function retarget( target, source, options = {} ) {
200
200
  function retargetClip( target, source, clip, options = {} ) {
201
201
 
202
202
  options.useFirstFramePosition = options.useFirstFramePosition !== undefined ? options.useFirstFramePosition : false;
203
- options.fps = options.fps !== undefined ? options.fps : 30;
203
+ // Calculate the fps from the source clip based on the track with the most frames, unless fps is already provided.
204
+ options.fps = options.fps !== undefined ? options.fps : ( Math.max( ...clip.tracks.map( track => track.times.length ) ) / clip.duration );
204
205
  options.names = options.names || [];
205
206
 
206
207
  if ( ! source.isObject3D ) {
@@ -210,7 +211,7 @@ function retargetClip( target, source, clip, options = {} ) {
210
211
  }
211
212
 
212
213
  const numFrames = Math.round( clip.duration * ( options.fps / 1000 ) * 1000 ),
213
- delta = 1 / options.fps,
214
+ delta = clip.duration / ( numFrames - 1 ),
214
215
  convertedTracks = [],
215
216
  mixer = new AnimationMixer( source ),
216
217
  bones = getBones( target.skeleton ),
@@ -287,7 +288,17 @@ function retargetClip( target, source, clip, options = {} ) {
287
288
 
288
289
  }
289
290
 
290
- mixer.update( delta );
291
+ if ( i === numFrames - 2 ) {
292
+
293
+ // last mixer update before final loop iteration
294
+ // make sure we do not go over or equal to clip duration
295
+ mixer.update( delta - 0.0000001 );
296
+
297
+ } else {
298
+
299
+ mixer.update( delta );
300
+
301
+ }
291
302
 
292
303
  source.updateMatrixWorld();
293
304
 
@@ -1,6 +1,6 @@
1
1
  class VRButton {
2
2
 
3
- static createButton( renderer ) {
3
+ static createButton( renderer, sessionInit = {} ) {
4
4
 
5
5
  const button = document.createElement( 'button' );
6
6
 
@@ -46,7 +46,15 @@ class VRButton {
46
46
  // ('local' is always available for immersive sessions and doesn't need to
47
47
  // be requested separately.)
48
48
 
49
- const sessionInit = { optionalFeatures: [ 'local-floor', 'bounded-floor', 'hand-tracking', 'layers' ] };
49
+ const sessionOptions = {
50
+ ...sessionInit,
51
+ optionalFeatures: [
52
+ 'local-floor',
53
+ 'bounded-floor',
54
+ 'layers',
55
+ ...( sessionInit.optionalFeatures || [] )
56
+ ],
57
+ };
50
58
 
51
59
  button.onmouseenter = function () {
52
60
 
@@ -64,7 +72,7 @@ class VRButton {
64
72
 
65
73
  if ( currentSession === null ) {
66
74
 
67
- navigator.xr.requestSession( 'immersive-vr', sessionInit ).then( onSessionStarted );
75
+ navigator.xr.requestSession( 'immersive-vr', sessionOptions ).then( onSessionStarted );
68
76
 
69
77
  } else {
70
78
 
@@ -72,7 +80,7 @@ class VRButton {
72
80
 
73
81
  if ( navigator.xr.offerSession !== undefined ) {
74
82
 
75
- navigator.xr.offerSession( 'immersive-vr', sessionInit )
83
+ navigator.xr.offerSession( 'immersive-vr', sessionOptions )
76
84
  .then( onSessionStarted )
77
85
  .catch( ( err ) => {
78
86
 
@@ -88,7 +96,7 @@ class VRButton {
88
96
 
89
97
  if ( navigator.xr.offerSession !== undefined ) {
90
98
 
91
- navigator.xr.offerSession( 'immersive-vr', sessionInit )
99
+ navigator.xr.offerSession( 'immersive-vr', sessionOptions )
92
100
  .then( onSessionStarted )
93
101
  .catch( ( err ) => {
94
102
 
@@ -45,7 +45,6 @@ class XRButton {
45
45
  optionalFeatures: [
46
46
  'local-floor',
47
47
  'bounded-floor',
48
- 'hand-tracking',
49
48
  'layers',
50
49
  ...( sessionInit.optionalFeatures || [] )
51
50
  ],
@@ -222,6 +222,14 @@ class XRControllerModelFactory {
222
222
 
223
223
  }
224
224
 
225
+ setPath( path ) {
226
+
227
+ this.path = path;
228
+
229
+ return this;
230
+
231
+ }
232
+
225
233
  createControllerModel( controller ) {
226
234
 
227
235
  const controllerModel = new XRControllerModel();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "super-three",
3
- "version": "0.161.0",
3
+ "version": "0.162.0",
4
4
  "description": "JavaScript 3D library",
5
5
  "type": "module",
6
6
  "main": "./build/three.cjs",
@@ -45,6 +45,7 @@
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\"",
48
+ "dev-ssl": "concurrently --names \"ROLLUP,HTTPS\" -c \"bgBlue.bold,bgGreen.bold\" \"rollup -c utils/build/rollup.config.js -w -m inline\" \"servez -p 8080 --ssl\"",
48
49
  "lint-core": "eslint src",
49
50
  "lint-addons": "eslint examples/jsm --ext .js --ignore-pattern libs --ignore-pattern ifc",
50
51
  "lint-examples": "eslint examples --ext .html",
@@ -94,13 +95,13 @@
94
95
  "eslint": "^8.37.0",
95
96
  "eslint-config-mdcs": "^5.0.0",
96
97
  "eslint-plugin-compat": "^4.1.2",
97
- "eslint-plugin-html": "^7.1.0",
98
+ "eslint-plugin-html": "^8.0.0",
98
99
  "eslint-plugin-import": "^2.27.5",
99
100
  "failonlyreporter": "^1.0.0",
100
101
  "jimp": "^0.22.7",
101
102
  "magic-string": "^0.30.0",
102
103
  "pixelmatch": "^5.3.0",
103
- "puppeteer": "^21.5.1",
104
+ "puppeteer": "^22.0.0",
104
105
  "qunit": "^2.19.4",
105
106
  "rollup": "^4.6.0",
106
107
  "rollup-plugin-filesize": "^10.0.0",
@@ -1 +1,21 @@
1
+ import { WebGLRenderTarget } from './renderers/WebGLRenderTarget.js';
1
2
 
3
+ export class WebGLMultipleRenderTargets extends WebGLRenderTarget { // @deprecated, r162
4
+
5
+ constructor( width = 1, height = 1, count = 1, options = {} ) {
6
+
7
+ console.warn( 'THREE.WebGLMultipleRenderTargets has been deprecated and will be removed in r172. Use THREE.WebGLRenderTarget and set the "count" parameter to enable MRT.' );
8
+
9
+ super( width, height, { ...options, count } );
10
+
11
+ this.isWebGLMultipleRenderTargets = true;
12
+
13
+ }
14
+
15
+ get texture() {
16
+
17
+ return this.textures;
18
+
19
+ }
20
+
21
+ }
package/src/Three.js CHANGED
@@ -2,7 +2,6 @@ import { REVISION } from './constants.js';
2
2
 
3
3
  export { WebGLArrayRenderTarget } from './renderers/WebGLArrayRenderTarget.js';
4
4
  export { WebGL3DRenderTarget } from './renderers/WebGL3DRenderTarget.js';
5
- export { WebGLMultipleRenderTargets } from './renderers/WebGLMultipleRenderTargets.js';
6
5
  export { WebGLCubeRenderTarget } from './renderers/WebGLCubeRenderTarget.js';
7
6
  export { WebGLRenderTarget } from './renderers/WebGLRenderTarget.js';
8
7
  export { WebGLRenderer } from './renderers/WebGLRenderer.js';
package/src/constants.js CHANGED
@@ -1,4 +1,4 @@
1
- export const REVISION = '161';
1
+ export const REVISION = '162';
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 };
@@ -57,6 +57,7 @@ export const CineonToneMapping = 3;
57
57
  export const ACESFilmicToneMapping = 4;
58
58
  export const CustomToneMapping = 5;
59
59
  export const AgXToneMapping = 6;
60
+ export const NeutralToneMapping = 7;
60
61
  export const AttachedBindMode = 'attached';
61
62
  export const DetachedBindMode = 'detached';
62
63
 
@@ -148,10 +149,6 @@ export const AdditiveAnimationBlendMode = 2501;
148
149
  export const TrianglesDrawMode = 0;
149
150
  export const TriangleStripDrawMode = 1;
150
151
  export const TriangleFanDrawMode = 2;
151
- /** @deprecated Use LinearSRGBColorSpace or NoColorSpace in three.js r152+. */
152
- export const LinearEncoding = 3000;
153
- /** @deprecated Use SRGBColorSpace in three.js r152+. */
154
- export const sRGBEncoding = 3001;
155
152
  export const BasicDepthPacking = 3200;
156
153
  export const RGBADepthPacking = 3201;
157
154
  export const TangentSpaceNormalMap = 0;
@@ -623,20 +623,9 @@ class Float32BufferAttribute extends BufferAttribute {
623
623
 
624
624
  }
625
625
 
626
- class Float64BufferAttribute extends BufferAttribute {
627
-
628
- constructor( array, itemSize, normalized ) {
629
-
630
- super( new Float64Array( array ), itemSize, normalized );
631
-
632
- }
633
-
634
- }
635
-
636
626
  //
637
627
 
638
628
  export {
639
- Float64BufferAttribute,
640
629
  Float32BufferAttribute,
641
630
  Float16BufferAttribute,
642
631
  Uint32BufferAttribute,