super-three 0.172.0 → 0.173.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 (178) hide show
  1. package/LICENSE +1 -1
  2. package/build/three.cjs +439 -380
  3. package/build/three.core.js +413 -41
  4. package/build/three.core.min.js +2 -2
  5. package/build/three.module.js +28 -344
  6. package/build/three.module.min.js +2 -2
  7. package/build/three.tsl.js +11 -3
  8. package/build/three.tsl.min.js +2 -2
  9. package/build/three.webgpu.js +7550 -1798
  10. package/build/three.webgpu.min.js +2 -2
  11. package/build/three.webgpu.nodes.js +7551 -1798
  12. package/build/three.webgpu.nodes.min.js +2 -2
  13. package/examples/jsm/animation/CCDIKSolver.js +6 -5
  14. package/examples/jsm/capabilities/WebGPU.js +1 -1
  15. package/examples/jsm/controls/ArcballControls.js +23 -21
  16. package/examples/jsm/exporters/GLTFExporter.js +26 -25
  17. package/examples/jsm/geometries/TextGeometry.js +1 -12
  18. package/examples/jsm/interactive/InteractiveGroup.js +108 -51
  19. package/examples/jsm/libs/demuxer_mp4.js +109 -0
  20. package/examples/jsm/loaders/GCodeLoader.js +3 -1
  21. package/examples/jsm/loaders/GLTFLoader.js +0 -2
  22. package/examples/jsm/loaders/TDSLoader.js +0 -1
  23. package/examples/jsm/materials/MeshGouraudMaterial.js +2 -0
  24. package/examples/jsm/misc/GPUComputationRenderer.js +6 -7
  25. package/examples/jsm/misc/ProgressiveLightMap.js +4 -3
  26. package/examples/jsm/misc/ProgressiveLightMapGPU.js +4 -3
  27. package/examples/jsm/misc/Volume.js +7 -5
  28. package/examples/jsm/misc/VolumeSlice.js +5 -3
  29. package/examples/jsm/objects/WaterMesh.js +25 -20
  30. package/examples/jsm/physics/JoltPhysics.js +7 -7
  31. package/examples/jsm/physics/RapierPhysics.js +4 -4
  32. package/examples/jsm/postprocessing/OutputPass.js +2 -0
  33. package/examples/jsm/shaders/OutputShader.js +5 -1
  34. package/examples/jsm/transpiler/GLSLDecoder.js +2 -2
  35. package/examples/jsm/transpiler/TSLEncoder.js +2 -0
  36. package/package.json +1 -1
  37. package/src/Three.Core.js +2 -0
  38. package/src/Three.TSL.js +9 -1
  39. package/src/cameras/ArrayCamera.js +1 -0
  40. package/src/constants.js +6 -1
  41. package/src/core/BufferAttribute.js +4 -0
  42. package/src/core/EventDispatcher.js +8 -6
  43. package/src/extras/ImageUtils.js +1 -11
  44. package/src/loaders/nodes/NodeObjectLoader.js +1 -1
  45. package/src/materials/nodes/MeshBasicNodeMaterial.js +1 -1
  46. package/src/materials/nodes/MeshPhysicalNodeMaterial.js +1 -1
  47. package/src/materials/nodes/NodeMaterial.js +5 -5
  48. package/src/materials/nodes/NodeMaterials.js +0 -1
  49. package/src/materials/nodes/PointsNodeMaterial.js +109 -7
  50. package/src/materials/nodes/SpriteNodeMaterial.js +1 -1
  51. package/src/materials/nodes/VolumeNodeMaterial.js +3 -3
  52. package/src/materials/nodes/manager/NodeMaterialObserver.js +8 -0
  53. package/src/nodes/Nodes.js +4 -0
  54. package/src/nodes/TSL.js +4 -0
  55. package/src/nodes/accessors/Arrays.js +30 -8
  56. package/src/nodes/accessors/BatchNode.js +3 -3
  57. package/src/nodes/accessors/BufferAttributeNode.js +1 -1
  58. package/src/nodes/accessors/Camera.js +64 -3
  59. package/src/nodes/accessors/InstanceNode.js +1 -1
  60. package/src/nodes/accessors/MaterialNode.js +9 -9
  61. package/src/nodes/accessors/ModelViewProjectionNode.js +1 -1
  62. package/src/nodes/accessors/Normal.js +6 -2
  63. package/src/nodes/accessors/Object3DNode.js +0 -1
  64. package/src/nodes/accessors/Position.js +6 -6
  65. package/src/nodes/accessors/ReferenceBaseNode.js +2 -4
  66. package/src/nodes/accessors/ReferenceNode.js +2 -3
  67. package/src/nodes/accessors/StorageBufferNode.js +42 -5
  68. package/src/nodes/accessors/Tangent.js +2 -2
  69. package/src/nodes/accessors/Texture3DNode.js +1 -1
  70. package/src/nodes/accessors/TextureNode.js +12 -5
  71. package/src/nodes/accessors/UniformArrayNode.js +9 -3
  72. package/src/nodes/accessors/VelocityNode.js +0 -2
  73. package/src/nodes/code/ScriptableNode.js +3 -3
  74. package/src/nodes/core/ArrayNode.js +125 -0
  75. package/src/nodes/core/ConstNode.js +8 -0
  76. package/src/nodes/core/Node.js +14 -1
  77. package/src/nodes/core/NodeBuilder.js +229 -19
  78. package/src/nodes/core/NodeUtils.js +11 -1
  79. package/src/nodes/core/NodeVar.js +17 -1
  80. package/src/nodes/core/OutputStructNode.js +19 -9
  81. package/src/nodes/core/StackNode.js +20 -1
  82. package/src/nodes/core/StructNode.js +121 -0
  83. package/src/nodes/core/StructType.js +13 -0
  84. package/src/nodes/core/StructTypeNode.js +82 -21
  85. package/src/nodes/core/TempNode.js +1 -1
  86. package/src/nodes/core/VarNode.js +94 -7
  87. package/src/nodes/core/VaryingNode.js +19 -3
  88. package/src/nodes/display/BlendModes.js +88 -1
  89. package/src/nodes/display/BumpMapNode.js +6 -6
  90. package/src/nodes/display/NormalMapNode.js +6 -6
  91. package/src/nodes/display/PassNode.js +3 -1
  92. package/src/nodes/display/ScreenNode.js +9 -0
  93. package/src/nodes/fog/Fog.js +17 -0
  94. package/src/nodes/gpgpu/AtomicFunctionNode.js +20 -4
  95. package/src/nodes/gpgpu/ComputeBuiltinNode.js +8 -0
  96. package/src/nodes/gpgpu/WorkgroupInfoNode.js +1 -1
  97. package/src/nodes/lighting/ShadowNode.js +1 -1
  98. package/src/nodes/math/ConditionalNode.js +8 -1
  99. package/src/nodes/math/MathNode.js +14 -1
  100. package/src/nodes/math/OperatorNode.js +96 -18
  101. package/src/nodes/pmrem/PMREMUtils.js +1 -1
  102. package/src/nodes/shapes/Shapes.js +33 -0
  103. package/src/nodes/tsl/TSLBase.js +1 -0
  104. package/src/nodes/tsl/TSLCore.js +22 -2
  105. package/src/nodes/utils/ArrayElementNode.js +1 -1
  106. package/src/nodes/utils/LoopNode.js +8 -1
  107. package/src/nodes/utils/MemberNode.js +68 -0
  108. package/src/nodes/utils/StorageArrayElementNode.js +14 -0
  109. package/src/nodes/utils/Timer.js +21 -0
  110. package/src/objects/BatchedMesh.js +1 -1
  111. package/src/objects/Line.js +6 -6
  112. package/src/renderers/WebGLRenderer.js +7 -0
  113. package/src/renderers/common/Animation.js +23 -1
  114. package/src/renderers/common/Backend.js +58 -15
  115. package/src/renderers/common/Background.js +14 -0
  116. package/src/renderers/common/Binding.js +1 -1
  117. package/src/renderers/common/BufferUtils.js +1 -1
  118. package/src/renderers/common/BundleGroup.js +1 -1
  119. package/src/renderers/common/ChainMap.js +9 -7
  120. package/src/renderers/common/ClippingContext.js +1 -1
  121. package/src/renderers/common/Color4.js +7 -3
  122. package/src/renderers/common/Geometries.js +2 -23
  123. package/src/renderers/common/Info.js +1 -45
  124. package/src/renderers/common/Lighting.js +8 -6
  125. package/src/renderers/common/Pipelines.js +3 -3
  126. package/src/renderers/common/PostProcessing.js +24 -8
  127. package/src/renderers/common/QuadMesh.js +1 -1
  128. package/src/renderers/common/RenderBundles.js +9 -3
  129. package/src/renderers/common/RenderContext.js +37 -3
  130. package/src/renderers/common/RenderContexts.js +30 -17
  131. package/src/renderers/common/RenderList.js +2 -2
  132. package/src/renderers/common/RenderLists.js +9 -3
  133. package/src/renderers/common/RenderObject.js +76 -17
  134. package/src/renderers/common/RenderObjects.js +9 -7
  135. package/src/renderers/common/Renderer.js +86 -67
  136. package/src/renderers/common/SampledTexture.js +0 -1
  137. package/src/renderers/common/StorageBufferAttribute.js +1 -1
  138. package/src/renderers/common/StorageInstancedBufferAttribute.js +1 -1
  139. package/src/renderers/common/StorageTexture.js +1 -1
  140. package/src/renderers/common/Textures.js +14 -7
  141. package/src/renderers/common/TimestampQueryPool.js +39 -0
  142. package/src/renderers/common/Uniform.js +37 -1
  143. package/src/renderers/common/UniformsGroup.js +2 -0
  144. package/src/renderers/common/XRManager.js +1193 -0
  145. package/src/renderers/common/XRRenderTarget.js +74 -0
  146. package/src/renderers/common/extras/PMREMGenerator.js +53 -8
  147. package/src/renderers/common/nodes/NodeBuilderState.js +4 -4
  148. package/src/renderers/common/nodes/NodeLibrary.js +5 -5
  149. package/src/renderers/common/nodes/NodeSampledTexture.js +0 -1
  150. package/src/renderers/common/nodes/NodeUniform.js +54 -2
  151. package/src/renderers/common/nodes/Nodes.js +25 -18
  152. package/src/renderers/webgl/WebGLBackground.js +4 -0
  153. package/src/renderers/webgl-fallback/WebGLBackend.js +295 -110
  154. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +347 -17
  155. package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +57 -0
  156. package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +28 -0
  157. package/src/renderers/webgl-fallback/utils/WebGLExtensions.js +45 -0
  158. package/src/renderers/webgl-fallback/utils/WebGLState.js +323 -11
  159. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +167 -21
  160. package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +359 -0
  161. package/src/renderers/webgl-fallback/utils/WebGLUtils.js +43 -0
  162. package/src/renderers/webgpu/WebGPUBackend.js +132 -149
  163. package/src/renderers/webgpu/WebGPURenderer.Nodes.js +6 -4
  164. package/src/renderers/webgpu/WebGPURenderer.js +5 -4
  165. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +615 -41
  166. package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +85 -6
  167. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +85 -0
  168. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +102 -3
  169. package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +98 -1
  170. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +257 -9
  171. package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +274 -0
  172. package/src/renderers/webgpu/utils/WebGPUUtils.js +86 -4
  173. package/src/renderers/webxr/WebXRManager.js +13 -2
  174. package/src/textures/VideoFrameTexture.js +35 -0
  175. package/examples/jsm/geometries/InstancedPointsGeometry.js +0 -176
  176. package/examples/jsm/objects/InstancedPoints.js +0 -19
  177. package/src/materials/nodes/InstancedPointsNodeMaterial.js +0 -209
  178. package/src/nodes/accessors/InstancedPointsMaterialNode.js +0 -37
package/build/three.cjs CHANGED
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * @license
3
- * Copyright 2010-2024 Three.js Authors
3
+ * Copyright 2010-2025 Three.js Authors
4
4
  * SPDX-License-Identifier: MIT
5
5
  */
6
6
  'use strict';
7
7
 
8
- const REVISION = '172';
8
+ const REVISION = '173';
9
9
 
10
10
  const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
11
11
  const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
@@ -217,6 +217,11 @@ const GLSL3 = '300 es';
217
217
  const WebGLCoordinateSystem = 2000;
218
218
  const WebGPUCoordinateSystem = 2001;
219
219
 
220
+ const TimestampQuery = {
221
+ COMPUTE: 'compute',
222
+ RENDER: 'render'
223
+ };
224
+
220
225
  /**
221
226
  * https://github.com/mrdoob/eventdispatcher.js/
222
227
  */
@@ -245,19 +250,20 @@ class EventDispatcher {
245
250
 
246
251
  hasEventListener( type, listener ) {
247
252
 
248
- if ( this._listeners === undefined ) return false;
249
-
250
253
  const listeners = this._listeners;
251
254
 
255
+ if ( listeners === undefined ) return false;
256
+
252
257
  return listeners[ type ] !== undefined && listeners[ type ].indexOf( listener ) !== - 1;
253
258
 
254
259
  }
255
260
 
256
261
  removeEventListener( type, listener ) {
257
262
 
258
- if ( this._listeners === undefined ) return;
259
-
260
263
  const listeners = this._listeners;
264
+
265
+ if ( listeners === undefined ) return;
266
+
261
267
  const listenerArray = listeners[ type ];
262
268
 
263
269
  if ( listenerArray !== undefined ) {
@@ -276,9 +282,10 @@ class EventDispatcher {
276
282
 
277
283
  dispatchEvent( event ) {
278
284
 
279
- if ( this._listeners === undefined ) return;
280
-
281
285
  const listeners = this._listeners;
286
+
287
+ if ( listeners === undefined ) return;
288
+
282
289
  const listenerArray = listeners[ event.type ];
283
290
 
284
291
  if ( listenerArray !== undefined ) {
@@ -1856,17 +1863,7 @@ class ImageUtils {
1856
1863
 
1857
1864
  }
1858
1865
 
1859
- if ( canvas.width > 2048 || canvas.height > 2048 ) {
1860
-
1861
- console.warn( 'THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons', image );
1862
-
1863
- return canvas.toDataURL( 'image/jpeg', 0.6 );
1864
-
1865
- } else {
1866
-
1867
- return canvas.toDataURL( 'image/png' );
1868
-
1869
- }
1866
+ return canvas.toDataURL( 'image/png' );
1870
1867
 
1871
1868
  }
1872
1869
 
@@ -10002,6 +9999,8 @@ const DataUtils = {
10002
9999
  const _vector$9 = /*@__PURE__*/ new Vector3();
10003
10000
  const _vector2$1 = /*@__PURE__*/ new Vector2();
10004
10001
 
10002
+ let _id$3 = 0;
10003
+
10005
10004
  class BufferAttribute {
10006
10005
 
10007
10006
  constructor( array, itemSize, normalized = false ) {
@@ -10014,6 +10013,8 @@ class BufferAttribute {
10014
10013
 
10015
10014
  this.isBufferAttribute = true;
10016
10015
 
10016
+ Object.defineProperty( this, 'id', { value: _id$3 ++ } );
10017
+
10017
10018
  this.name = '';
10018
10019
 
10019
10020
  this.array = array;
@@ -13251,6 +13252,358 @@ class WebGLCubeRenderTarget extends WebGLRenderTarget {
13251
13252
 
13252
13253
  }
13253
13254
 
13255
+ class Group extends Object3D {
13256
+
13257
+ constructor() {
13258
+
13259
+ super();
13260
+
13261
+ this.isGroup = true;
13262
+
13263
+ this.type = 'Group';
13264
+
13265
+ }
13266
+
13267
+ }
13268
+
13269
+ const _moveEvent = { type: 'move' };
13270
+
13271
+ class WebXRController {
13272
+
13273
+ constructor() {
13274
+
13275
+ this._targetRay = null;
13276
+ this._grip = null;
13277
+ this._hand = null;
13278
+
13279
+ }
13280
+
13281
+ getHandSpace() {
13282
+
13283
+ if ( this._hand === null ) {
13284
+
13285
+ this._hand = new Group();
13286
+ this._hand.matrixAutoUpdate = false;
13287
+ this._hand.visible = false;
13288
+
13289
+ this._hand.joints = {};
13290
+ this._hand.inputState = { pinching: false };
13291
+
13292
+ }
13293
+
13294
+ return this._hand;
13295
+
13296
+ }
13297
+
13298
+ getTargetRaySpace() {
13299
+
13300
+ if ( this._targetRay === null ) {
13301
+
13302
+ this._targetRay = new Group();
13303
+ this._targetRay.matrixAutoUpdate = false;
13304
+ this._targetRay.visible = false;
13305
+ this._targetRay.hasLinearVelocity = false;
13306
+ this._targetRay.linearVelocity = new Vector3();
13307
+ this._targetRay.hasAngularVelocity = false;
13308
+ this._targetRay.angularVelocity = new Vector3();
13309
+
13310
+ }
13311
+
13312
+ return this._targetRay;
13313
+
13314
+ }
13315
+
13316
+ getGripSpace() {
13317
+
13318
+ if ( this._grip === null ) {
13319
+
13320
+ this._grip = new Group();
13321
+ this._grip.matrixAutoUpdate = false;
13322
+ this._grip.visible = false;
13323
+ this._grip.hasLinearVelocity = false;
13324
+ this._grip.linearVelocity = new Vector3();
13325
+ this._grip.hasAngularVelocity = false;
13326
+ this._grip.angularVelocity = new Vector3();
13327
+
13328
+ }
13329
+
13330
+ return this._grip;
13331
+
13332
+ }
13333
+
13334
+ dispatchEvent( event ) {
13335
+
13336
+ if ( this._targetRay !== null ) {
13337
+
13338
+ this._targetRay.dispatchEvent( event );
13339
+
13340
+ }
13341
+
13342
+ if ( this._grip !== null ) {
13343
+
13344
+ this._grip.dispatchEvent( event );
13345
+
13346
+ }
13347
+
13348
+ if ( this._hand !== null ) {
13349
+
13350
+ this._hand.dispatchEvent( event );
13351
+
13352
+ }
13353
+
13354
+ return this;
13355
+
13356
+ }
13357
+
13358
+ connect( inputSource ) {
13359
+
13360
+ if ( inputSource && inputSource.hand ) {
13361
+
13362
+ const hand = this._hand;
13363
+
13364
+ if ( hand ) {
13365
+
13366
+ for ( const inputjoint of inputSource.hand.values() ) {
13367
+
13368
+ // Initialize hand with joints when connected
13369
+ this._getHandJoint( hand, inputjoint );
13370
+
13371
+ }
13372
+
13373
+ }
13374
+
13375
+ }
13376
+
13377
+ this.dispatchEvent( { type: 'connected', data: inputSource } );
13378
+
13379
+ return this;
13380
+
13381
+ }
13382
+
13383
+ disconnect( inputSource ) {
13384
+
13385
+ this.dispatchEvent( { type: 'disconnected', data: inputSource } );
13386
+
13387
+ if ( this._targetRay !== null ) {
13388
+
13389
+ this._targetRay.visible = false;
13390
+
13391
+ }
13392
+
13393
+ if ( this._grip !== null ) {
13394
+
13395
+ this._grip.visible = false;
13396
+
13397
+ }
13398
+
13399
+ if ( this._hand !== null ) {
13400
+
13401
+ this._hand.visible = false;
13402
+
13403
+ }
13404
+
13405
+ return this;
13406
+
13407
+ }
13408
+
13409
+ update( inputSource, frame, referenceSpace ) {
13410
+
13411
+ let inputPose = null;
13412
+ let gripPose = null;
13413
+ let handPose = null;
13414
+
13415
+ const targetRay = this._targetRay;
13416
+ const grip = this._grip;
13417
+ const hand = this._hand;
13418
+
13419
+ if ( inputSource && frame.session.visibilityState !== 'visible-blurred' ) {
13420
+
13421
+ if ( hand && inputSource.hand ) {
13422
+
13423
+ handPose = true;
13424
+
13425
+ for ( const inputjoint of inputSource.hand.values() ) {
13426
+
13427
+ // Update the joints groups with the XRJoint poses
13428
+ const jointPose = frame.getJointPose( inputjoint, referenceSpace );
13429
+
13430
+ // The transform of this joint will be updated with the joint pose on each frame
13431
+ const joint = this._getHandJoint( hand, inputjoint );
13432
+
13433
+ if ( jointPose !== null ) {
13434
+
13435
+ joint.matrix.fromArray( jointPose.transform.matrix );
13436
+ joint.matrix.decompose( joint.position, joint.rotation, joint.scale );
13437
+ joint.matrixWorldNeedsUpdate = true;
13438
+ joint.jointRadius = jointPose.radius;
13439
+
13440
+ }
13441
+
13442
+ joint.visible = jointPose !== null;
13443
+
13444
+ }
13445
+
13446
+ // Custom events
13447
+
13448
+ // Check pinchz
13449
+ const indexTip = hand.joints[ 'index-finger-tip' ];
13450
+ const thumbTip = hand.joints[ 'thumb-tip' ];
13451
+ const distance = indexTip.position.distanceTo( thumbTip.position );
13452
+
13453
+ const distanceToPinch = 0.02;
13454
+ const threshold = 0.005;
13455
+
13456
+ if ( hand.inputState.pinching && distance > distanceToPinch + threshold ) {
13457
+
13458
+ hand.inputState.pinching = false;
13459
+ this.dispatchEvent( {
13460
+ type: 'pinchend',
13461
+ handedness: inputSource.handedness,
13462
+ target: this
13463
+ } );
13464
+
13465
+ } else if ( ! hand.inputState.pinching && distance <= distanceToPinch - threshold ) {
13466
+
13467
+ hand.inputState.pinching = true;
13468
+ this.dispatchEvent( {
13469
+ type: 'pinchstart',
13470
+ handedness: inputSource.handedness,
13471
+ target: this
13472
+ } );
13473
+
13474
+ }
13475
+
13476
+ } else {
13477
+
13478
+ if ( grip !== null && inputSource.gripSpace ) {
13479
+
13480
+ gripPose = frame.getPose( inputSource.gripSpace, referenceSpace );
13481
+
13482
+ if ( gripPose !== null ) {
13483
+
13484
+ grip.matrix.fromArray( gripPose.transform.matrix );
13485
+ grip.matrix.decompose( grip.position, grip.rotation, grip.scale );
13486
+ grip.matrixWorldNeedsUpdate = true;
13487
+
13488
+ if ( gripPose.linearVelocity ) {
13489
+
13490
+ grip.hasLinearVelocity = true;
13491
+ grip.linearVelocity.copy( gripPose.linearVelocity );
13492
+
13493
+ } else {
13494
+
13495
+ grip.hasLinearVelocity = false;
13496
+
13497
+ }
13498
+
13499
+ if ( gripPose.angularVelocity ) {
13500
+
13501
+ grip.hasAngularVelocity = true;
13502
+ grip.angularVelocity.copy( gripPose.angularVelocity );
13503
+
13504
+ } else {
13505
+
13506
+ grip.hasAngularVelocity = false;
13507
+
13508
+ }
13509
+
13510
+ }
13511
+
13512
+ }
13513
+
13514
+ }
13515
+
13516
+ if ( targetRay !== null ) {
13517
+
13518
+ inputPose = frame.getPose( inputSource.targetRaySpace, referenceSpace );
13519
+
13520
+ // Some runtimes (namely Vive Cosmos with Vive OpenXR Runtime) have only grip space and ray space is equal to it
13521
+ if ( inputPose === null && gripPose !== null ) {
13522
+
13523
+ inputPose = gripPose;
13524
+
13525
+ }
13526
+
13527
+ if ( inputPose !== null ) {
13528
+
13529
+ targetRay.matrix.fromArray( inputPose.transform.matrix );
13530
+ targetRay.matrix.decompose( targetRay.position, targetRay.rotation, targetRay.scale );
13531
+ targetRay.matrixWorldNeedsUpdate = true;
13532
+
13533
+ if ( inputPose.linearVelocity ) {
13534
+
13535
+ targetRay.hasLinearVelocity = true;
13536
+ targetRay.linearVelocity.copy( inputPose.linearVelocity );
13537
+
13538
+ } else {
13539
+
13540
+ targetRay.hasLinearVelocity = false;
13541
+
13542
+ }
13543
+
13544
+ if ( inputPose.angularVelocity ) {
13545
+
13546
+ targetRay.hasAngularVelocity = true;
13547
+ targetRay.angularVelocity.copy( inputPose.angularVelocity );
13548
+
13549
+ } else {
13550
+
13551
+ targetRay.hasAngularVelocity = false;
13552
+
13553
+ }
13554
+
13555
+ this.dispatchEvent( _moveEvent );
13556
+
13557
+ }
13558
+
13559
+ }
13560
+
13561
+
13562
+ }
13563
+
13564
+ if ( targetRay !== null ) {
13565
+
13566
+ targetRay.visible = ( inputPose !== null );
13567
+
13568
+ }
13569
+
13570
+ if ( grip !== null ) {
13571
+
13572
+ grip.visible = ( gripPose !== null );
13573
+
13574
+ }
13575
+
13576
+ if ( hand !== null ) {
13577
+
13578
+ hand.visible = ( handPose !== null );
13579
+
13580
+ }
13581
+
13582
+ return this;
13583
+
13584
+ }
13585
+
13586
+ // private method
13587
+
13588
+ _getHandJoint( hand, inputjoint ) {
13589
+
13590
+ if ( hand.joints[ inputjoint.jointName ] === undefined ) {
13591
+
13592
+ const joint = new Group();
13593
+ joint.matrixAutoUpdate = false;
13594
+ joint.visible = false;
13595
+ hand.joints[ inputjoint.jointName ] = joint;
13596
+
13597
+ hand.add( joint );
13598
+
13599
+ }
13600
+
13601
+ return hand.joints[ inputjoint.jointName ];
13602
+
13603
+ }
13604
+
13605
+ }
13606
+
13254
13607
  class FogExp2 {
13255
13608
 
13256
13609
  constructor( color, density = 0.00025 ) {
@@ -16214,7 +16567,7 @@ class BatchedMesh extends Mesh {
16214
16567
  const instanceInfo = this._instanceInfo;
16215
16568
  for ( let i = 0, l = instanceInfo.length; i < l; i ++ ) {
16216
16569
 
16217
- if ( instanceInfo[ i ].geometryIndex === geometryId ) {
16570
+ if ( instanceInfo[ i ].active && instanceInfo[ i ].geometryIndex === geometryId ) {
16218
16571
 
16219
16572
  this.deleteInstance( i );
16220
16573
 
@@ -17065,7 +17418,7 @@ class Line extends Object3D {
17065
17418
  const a = index.getX( i );
17066
17419
  const b = index.getX( i + 1 );
17067
17420
 
17068
- const intersect = checkIntersection( this, raycaster, _ray$1, localThresholdSq, a, b );
17421
+ const intersect = checkIntersection( this, raycaster, _ray$1, localThresholdSq, a, b, i );
17069
17422
 
17070
17423
  if ( intersect ) {
17071
17424
 
@@ -17080,7 +17433,7 @@ class Line extends Object3D {
17080
17433
  const a = index.getX( end - 1 );
17081
17434
  const b = index.getX( start );
17082
17435
 
17083
- const intersect = checkIntersection( this, raycaster, _ray$1, localThresholdSq, a, b );
17436
+ const intersect = checkIntersection( this, raycaster, _ray$1, localThresholdSq, a, b, end - 1 );
17084
17437
 
17085
17438
  if ( intersect ) {
17086
17439
 
@@ -17097,7 +17450,7 @@ class Line extends Object3D {
17097
17450
 
17098
17451
  for ( let i = start, l = end - 1; i < l; i += step ) {
17099
17452
 
17100
- const intersect = checkIntersection( this, raycaster, _ray$1, localThresholdSq, i, i + 1 );
17453
+ const intersect = checkIntersection( this, raycaster, _ray$1, localThresholdSq, i, i + 1, i );
17101
17454
 
17102
17455
  if ( intersect ) {
17103
17456
 
@@ -17109,7 +17462,7 @@ class Line extends Object3D {
17109
17462
 
17110
17463
  if ( this.isLineLoop ) {
17111
17464
 
17112
- const intersect = checkIntersection( this, raycaster, _ray$1, localThresholdSq, end - 1, start );
17465
+ const intersect = checkIntersection( this, raycaster, _ray$1, localThresholdSq, end - 1, start, end - 1 );
17113
17466
 
17114
17467
  if ( intersect ) {
17115
17468
 
@@ -17156,7 +17509,7 @@ class Line extends Object3D {
17156
17509
 
17157
17510
  }
17158
17511
 
17159
- function checkIntersection( object, raycaster, ray, thresholdSq, a, b ) {
17512
+ function checkIntersection( object, raycaster, ray, thresholdSq, a, b, i ) {
17160
17513
 
17161
17514
  const positionAttribute = object.geometry.attributes.position;
17162
17515
 
@@ -17179,7 +17532,7 @@ function checkIntersection( object, raycaster, ray, thresholdSq, a, b ) {
17179
17532
  // What do we want? intersection point on the ray or on the segment??
17180
17533
  // point: raycaster.ray.at( distance ),
17181
17534
  point: _intersectPointOnSegment.clone().applyMatrix4( object.matrixWorld ),
17182
- index: a,
17535
+ index: i,
17183
17536
  face: null,
17184
17537
  faceIndex: null,
17185
17538
  barycoord: null,
@@ -17458,20 +17811,6 @@ function testPoint( point, index, localThresholdSq, matrixWorld, raycaster, inte
17458
17811
 
17459
17812
  }
17460
17813
 
17461
- class Group extends Object3D {
17462
-
17463
- constructor() {
17464
-
17465
- super();
17466
-
17467
- this.isGroup = true;
17468
-
17469
- this.type = 'Group';
17470
-
17471
- }
17472
-
17473
- }
17474
-
17475
17814
  class VideoTexture extends Texture {
17476
17815
 
17477
17816
  constructor( video, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) {
@@ -17523,6 +17862,38 @@ class VideoTexture extends Texture {
17523
17862
 
17524
17863
  }
17525
17864
 
17865
+ class VideoFrameTexture extends VideoTexture {
17866
+
17867
+ constructor( mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) {
17868
+
17869
+ super( {}, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );
17870
+
17871
+ this.isVideoFrameTexture = true;
17872
+
17873
+ }
17874
+
17875
+ update() {
17876
+
17877
+ // overwrites `VideoTexture.update()` with an empty method since
17878
+ // this type of texture is updated via `setFrame()`.
17879
+
17880
+ }
17881
+
17882
+ clone() {
17883
+
17884
+ return new this.constructor().copy( this ); // restoring Texture.clone()
17885
+
17886
+ }
17887
+
17888
+ setFrame( frame ) {
17889
+
17890
+ this.image = frame;
17891
+ this.needsUpdate = true;
17892
+
17893
+ }
17894
+
17895
+ }
17896
+
17526
17897
  class FramebufferTexture extends Texture {
17527
17898
 
17528
17899
  constructor( width, height ) {
@@ -30704,6 +31075,7 @@ class ArrayCamera extends PerspectiveCamera {
30704
31075
  this.isArrayCamera = true;
30705
31076
 
30706
31077
  this.cameras = array;
31078
+ this.index = 0;
30707
31079
 
30708
31080
  }
30709
31081
 
@@ -38592,6 +38964,8 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
38592
38964
  boxMesh.geometry.dispose();
38593
38965
  boxMesh.material.dispose();
38594
38966
 
38967
+ boxMesh = undefined;
38968
+
38595
38969
  }
38596
38970
 
38597
38971
  if ( planeMesh !== undefined ) {
@@ -38599,6 +38973,8 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
38599
38973
  planeMesh.geometry.dispose();
38600
38974
  planeMesh.material.dispose();
38601
38975
 
38976
+ planeMesh = undefined;
38977
+
38602
38978
  }
38603
38979
 
38604
38980
  }
@@ -49899,344 +50275,6 @@ class WebGLMultiviewRenderTarget extends WebGLRenderTarget {
49899
50275
 
49900
50276
  WebGLMultiviewRenderTarget.prototype.isWebGLMultiviewRenderTarget = true;
49901
50277
 
49902
- const _moveEvent = { type: 'move' };
49903
-
49904
- class WebXRController {
49905
-
49906
- constructor() {
49907
-
49908
- this._targetRay = null;
49909
- this._grip = null;
49910
- this._hand = null;
49911
-
49912
- }
49913
-
49914
- getHandSpace() {
49915
-
49916
- if ( this._hand === null ) {
49917
-
49918
- this._hand = new Group();
49919
- this._hand.matrixAutoUpdate = false;
49920
- this._hand.visible = false;
49921
-
49922
- this._hand.joints = {};
49923
- this._hand.inputState = { pinching: false };
49924
-
49925
- }
49926
-
49927
- return this._hand;
49928
-
49929
- }
49930
-
49931
- getTargetRaySpace() {
49932
-
49933
- if ( this._targetRay === null ) {
49934
-
49935
- this._targetRay = new Group();
49936
- this._targetRay.matrixAutoUpdate = false;
49937
- this._targetRay.visible = false;
49938
- this._targetRay.hasLinearVelocity = false;
49939
- this._targetRay.linearVelocity = new Vector3();
49940
- this._targetRay.hasAngularVelocity = false;
49941
- this._targetRay.angularVelocity = new Vector3();
49942
-
49943
- }
49944
-
49945
- return this._targetRay;
49946
-
49947
- }
49948
-
49949
- getGripSpace() {
49950
-
49951
- if ( this._grip === null ) {
49952
-
49953
- this._grip = new Group();
49954
- this._grip.matrixAutoUpdate = false;
49955
- this._grip.visible = false;
49956
- this._grip.hasLinearVelocity = false;
49957
- this._grip.linearVelocity = new Vector3();
49958
- this._grip.hasAngularVelocity = false;
49959
- this._grip.angularVelocity = new Vector3();
49960
-
49961
- }
49962
-
49963
- return this._grip;
49964
-
49965
- }
49966
-
49967
- dispatchEvent( event ) {
49968
-
49969
- if ( this._targetRay !== null ) {
49970
-
49971
- this._targetRay.dispatchEvent( event );
49972
-
49973
- }
49974
-
49975
- if ( this._grip !== null ) {
49976
-
49977
- this._grip.dispatchEvent( event );
49978
-
49979
- }
49980
-
49981
- if ( this._hand !== null ) {
49982
-
49983
- this._hand.dispatchEvent( event );
49984
-
49985
- }
49986
-
49987
- return this;
49988
-
49989
- }
49990
-
49991
- connect( inputSource ) {
49992
-
49993
- if ( inputSource && inputSource.hand ) {
49994
-
49995
- const hand = this._hand;
49996
-
49997
- if ( hand ) {
49998
-
49999
- for ( const inputjoint of inputSource.hand.values() ) {
50000
-
50001
- // Initialize hand with joints when connected
50002
- this._getHandJoint( hand, inputjoint );
50003
-
50004
- }
50005
-
50006
- }
50007
-
50008
- }
50009
-
50010
- this.dispatchEvent( { type: 'connected', data: inputSource } );
50011
-
50012
- return this;
50013
-
50014
- }
50015
-
50016
- disconnect( inputSource ) {
50017
-
50018
- this.dispatchEvent( { type: 'disconnected', data: inputSource } );
50019
-
50020
- if ( this._targetRay !== null ) {
50021
-
50022
- this._targetRay.visible = false;
50023
-
50024
- }
50025
-
50026
- if ( this._grip !== null ) {
50027
-
50028
- this._grip.visible = false;
50029
-
50030
- }
50031
-
50032
- if ( this._hand !== null ) {
50033
-
50034
- this._hand.visible = false;
50035
-
50036
- }
50037
-
50038
- return this;
50039
-
50040
- }
50041
-
50042
- update( inputSource, frame, referenceSpace ) {
50043
-
50044
- let inputPose = null;
50045
- let gripPose = null;
50046
- let handPose = null;
50047
-
50048
- const targetRay = this._targetRay;
50049
- const grip = this._grip;
50050
- const hand = this._hand;
50051
-
50052
- if ( inputSource && frame.session.visibilityState !== 'visible-blurred' ) {
50053
-
50054
- if ( hand && inputSource.hand ) {
50055
-
50056
- handPose = true;
50057
-
50058
- for ( const inputjoint of inputSource.hand.values() ) {
50059
-
50060
- // Update the joints groups with the XRJoint poses
50061
- const jointPose = frame.getJointPose( inputjoint, referenceSpace );
50062
-
50063
- // The transform of this joint will be updated with the joint pose on each frame
50064
- const joint = this._getHandJoint( hand, inputjoint );
50065
-
50066
- if ( jointPose !== null ) {
50067
-
50068
- joint.matrix.fromArray( jointPose.transform.matrix );
50069
- joint.matrix.decompose( joint.position, joint.rotation, joint.scale );
50070
- joint.matrixWorldNeedsUpdate = true;
50071
- joint.jointRadius = jointPose.radius;
50072
-
50073
- }
50074
-
50075
- joint.visible = jointPose !== null;
50076
-
50077
- }
50078
-
50079
- // Custom events
50080
-
50081
- // Check pinchz
50082
- const indexTip = hand.joints[ 'index-finger-tip' ];
50083
- const thumbTip = hand.joints[ 'thumb-tip' ];
50084
- const distance = indexTip.position.distanceTo( thumbTip.position );
50085
-
50086
- const distanceToPinch = 0.02;
50087
- const threshold = 0.005;
50088
-
50089
- if ( hand.inputState.pinching && distance > distanceToPinch + threshold ) {
50090
-
50091
- hand.inputState.pinching = false;
50092
- this.dispatchEvent( {
50093
- type: 'pinchend',
50094
- handedness: inputSource.handedness,
50095
- target: this
50096
- } );
50097
-
50098
- } else if ( ! hand.inputState.pinching && distance <= distanceToPinch - threshold ) {
50099
-
50100
- hand.inputState.pinching = true;
50101
- this.dispatchEvent( {
50102
- type: 'pinchstart',
50103
- handedness: inputSource.handedness,
50104
- target: this
50105
- } );
50106
-
50107
- }
50108
-
50109
- } else {
50110
-
50111
- if ( grip !== null && inputSource.gripSpace ) {
50112
-
50113
- gripPose = frame.getPose( inputSource.gripSpace, referenceSpace );
50114
-
50115
- if ( gripPose !== null ) {
50116
-
50117
- grip.matrix.fromArray( gripPose.transform.matrix );
50118
- grip.matrix.decompose( grip.position, grip.rotation, grip.scale );
50119
- grip.matrixWorldNeedsUpdate = true;
50120
-
50121
- if ( gripPose.linearVelocity ) {
50122
-
50123
- grip.hasLinearVelocity = true;
50124
- grip.linearVelocity.copy( gripPose.linearVelocity );
50125
-
50126
- } else {
50127
-
50128
- grip.hasLinearVelocity = false;
50129
-
50130
- }
50131
-
50132
- if ( gripPose.angularVelocity ) {
50133
-
50134
- grip.hasAngularVelocity = true;
50135
- grip.angularVelocity.copy( gripPose.angularVelocity );
50136
-
50137
- } else {
50138
-
50139
- grip.hasAngularVelocity = false;
50140
-
50141
- }
50142
-
50143
- }
50144
-
50145
- }
50146
-
50147
- }
50148
-
50149
- if ( targetRay !== null ) {
50150
-
50151
- inputPose = frame.getPose( inputSource.targetRaySpace, referenceSpace );
50152
-
50153
- // Some runtimes (namely Vive Cosmos with Vive OpenXR Runtime) have only grip space and ray space is equal to it
50154
- if ( inputPose === null && gripPose !== null ) {
50155
-
50156
- inputPose = gripPose;
50157
-
50158
- }
50159
-
50160
- if ( inputPose !== null ) {
50161
-
50162
- targetRay.matrix.fromArray( inputPose.transform.matrix );
50163
- targetRay.matrix.decompose( targetRay.position, targetRay.rotation, targetRay.scale );
50164
- targetRay.matrixWorldNeedsUpdate = true;
50165
-
50166
- if ( inputPose.linearVelocity ) {
50167
-
50168
- targetRay.hasLinearVelocity = true;
50169
- targetRay.linearVelocity.copy( inputPose.linearVelocity );
50170
-
50171
- } else {
50172
-
50173
- targetRay.hasLinearVelocity = false;
50174
-
50175
- }
50176
-
50177
- if ( inputPose.angularVelocity ) {
50178
-
50179
- targetRay.hasAngularVelocity = true;
50180
- targetRay.angularVelocity.copy( inputPose.angularVelocity );
50181
-
50182
- } else {
50183
-
50184
- targetRay.hasAngularVelocity = false;
50185
-
50186
- }
50187
-
50188
- this.dispatchEvent( _moveEvent );
50189
-
50190
- }
50191
-
50192
- }
50193
-
50194
-
50195
- }
50196
-
50197
- if ( targetRay !== null ) {
50198
-
50199
- targetRay.visible = ( inputPose !== null );
50200
-
50201
- }
50202
-
50203
- if ( grip !== null ) {
50204
-
50205
- grip.visible = ( gripPose !== null );
50206
-
50207
- }
50208
-
50209
- if ( hand !== null ) {
50210
-
50211
- hand.visible = ( handPose !== null );
50212
-
50213
- }
50214
-
50215
- return this;
50216
-
50217
- }
50218
-
50219
- // private method
50220
-
50221
- _getHandJoint( hand, inputjoint ) {
50222
-
50223
- if ( hand.joints[ inputjoint.jointName ] === undefined ) {
50224
-
50225
- const joint = new Group();
50226
- joint.matrixAutoUpdate = false;
50227
- joint.visible = false;
50228
- hand.joints[ inputjoint.jointName ] = joint;
50229
-
50230
- hand.add( joint );
50231
-
50232
- }
50233
-
50234
- return hand.joints[ inputjoint.jointName ];
50235
-
50236
- }
50237
-
50238
- }
50239
-
50240
50278
  const _occlusion_vertex = `
50241
50279
  void main() {
50242
50280
 
@@ -50576,6 +50614,12 @@ class WebXRManager extends EventDispatcher {
50576
50614
 
50577
50615
  };
50578
50616
 
50617
+ this.getRenderTarget = function () {
50618
+
50619
+ return newRenderTarget;
50620
+
50621
+ };
50622
+
50579
50623
  this.getFrame = function () {
50580
50624
 
50581
50625
  return xrFrame;
@@ -50614,7 +50658,9 @@ class WebXRManager extends EventDispatcher {
50614
50658
  currentPixelRatio = renderer.getPixelRatio();
50615
50659
  renderer.getSize( currentSize );
50616
50660
 
50617
- const useLayers = session.enabledFeatures !== undefined && session.enabledFeatures.includes( 'layers' );
50661
+ // Check that the browser implements the necessary APIs to use an
50662
+ // XRProjectionLayer rather than an XRWebGLLayer
50663
+ const useLayers = typeof XRWebGLBinding !== 'undefined' && 'createProjectionLayer' in XRWebGLBinding.prototype;
50618
50664
 
50619
50665
  if ( ! useLayers ) {
50620
50666
 
@@ -51173,8 +51219,11 @@ class WebXRManager extends EventDispatcher {
51173
51219
  //
51174
51220
 
51175
51221
  const enabledFeatures = session.enabledFeatures;
51222
+ const gpuDepthSensingEnabled = enabledFeatures &&
51223
+ enabledFeatures.includes( 'depth-sensing' ) &&
51224
+ session.depthUsage == 'gpu-optimized';
51176
51225
 
51177
- if ( enabledFeatures && enabledFeatures.includes( 'depth-sensing' ) ) {
51226
+ if ( gpuDepthSensingEnabled && glBinding ) {
51178
51227
 
51179
51228
  const depthData = glBinding.getDepthInformation( views[ 0 ] );
51180
51229
 
@@ -54485,6 +54534,13 @@ class WebGLRenderer {
54485
54534
  const _scratchFrameBuffer = _gl.createFramebuffer();
54486
54535
  this.setRenderTarget = function ( renderTarget, activeCubeFace = 0, activeMipmapLevel = 0 ) {
54487
54536
 
54537
+ // Render to base layer instead of canvas in WebXR
54538
+ if ( renderTarget === null && this.xr.isPresenting ) {
54539
+
54540
+ renderTarget = this.xr.getRenderTarget();
54541
+
54542
+ }
54543
+
54488
54544
  _currentRenderTarget = renderTarget;
54489
54545
  _currentActiveCubeFace = activeCubeFace;
54490
54546
  _currentActiveMipmapLevel = activeMipmapLevel;
@@ -55538,6 +55594,7 @@ exports.TetrahedronGeometry = TetrahedronGeometry;
55538
55594
  exports.Texture = Texture;
55539
55595
  exports.TextureLoader = TextureLoader;
55540
55596
  exports.TextureUtils = TextureUtils;
55597
+ exports.TimestampQuery = TimestampQuery;
55541
55598
  exports.TorusGeometry = TorusGeometry;
55542
55599
  exports.TorusKnotGeometry = TorusKnotGeometry;
55543
55600
  exports.Triangle = Triangle;
@@ -55566,6 +55623,7 @@ exports.Vector2 = Vector2;
55566
55623
  exports.Vector3 = Vector3;
55567
55624
  exports.Vector4 = Vector4;
55568
55625
  exports.VectorKeyframeTrack = VectorKeyframeTrack;
55626
+ exports.VideoFrameTexture = VideoFrameTexture;
55569
55627
  exports.VideoTexture = VideoTexture;
55570
55628
  exports.WebGL3DRenderTarget = WebGL3DRenderTarget;
55571
55629
  exports.WebGLArrayRenderTarget = WebGLArrayRenderTarget;
@@ -55575,6 +55633,7 @@ exports.WebGLRenderTarget = WebGLRenderTarget;
55575
55633
  exports.WebGLRenderer = WebGLRenderer;
55576
55634
  exports.WebGLUtils = WebGLUtils;
55577
55635
  exports.WebGPUCoordinateSystem = WebGPUCoordinateSystem;
55636
+ exports.WebXRController = WebXRController;
55578
55637
  exports.WireframeGeometry = WireframeGeometry;
55579
55638
  exports.WrapAroundEnding = WrapAroundEnding;
55580
55639
  exports.ZeroCurvatureEnding = ZeroCurvatureEnding;