super-three 0.169.0 → 0.169.1

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.
@@ -26836,20 +26836,6 @@ function WebGLUtils( gl, extensions ) {
26836
26836
 
26837
26837
  }
26838
26838
 
26839
- class Group extends Object3D {
26840
-
26841
- constructor() {
26842
-
26843
- super();
26844
-
26845
- this.isGroup = true;
26846
-
26847
- this.type = 'Group';
26848
-
26849
- }
26850
-
26851
- }
26852
-
26853
26839
  class ArrayCamera extends PerspectiveCamera {
26854
26840
 
26855
26841
  constructor( array = [] ) {
@@ -26864,553 +26850,6 @@ class ArrayCamera extends PerspectiveCamera {
26864
26850
 
26865
26851
  }
26866
26852
 
26867
- /**
26868
- * @author jsantell / https://www.jsantell.com/
26869
- * @author mrdoob / http://mrdoob.com/
26870
- */
26871
-
26872
-
26873
- var cameraLPos = new Vector3();
26874
- var cameraRPos = new Vector3();
26875
-
26876
- /**
26877
- * Assumes 2 cameras that are parallel and share an X-axis, and that
26878
- * the cameras' projection and world matrices have already been set.
26879
- * And that near and far planes are identical for both cameras.
26880
- * Visualization of this technique: https://computergraphics.stackexchange.com/a/4765
26881
- */
26882
- function setProjectionFromUnion( camera, cameraL, cameraR ) {
26883
-
26884
- cameraLPos.setFromMatrixPosition( cameraL.matrixWorld );
26885
- cameraRPos.setFromMatrixPosition( cameraR.matrixWorld );
26886
-
26887
- var ipd = cameraLPos.distanceTo( cameraRPos );
26888
-
26889
- var projL = cameraL.projectionMatrix.elements;
26890
- var projR = cameraR.projectionMatrix.elements;
26891
-
26892
- // VR systems will have identical far and near planes, and
26893
- // most likely identical top and bottom frustum extents.
26894
- // Use the left camera for these values.
26895
- var near = projL[ 14 ] / ( projL[ 10 ] - 1 );
26896
- var far = projL[ 14 ] / ( projL[ 10 ] + 1 );
26897
- var topFov = ( projL[ 9 ] + 1 ) / projL[ 5 ];
26898
- var bottomFov = ( projL[ 9 ] - 1 ) / projL[ 5 ];
26899
-
26900
- var leftFov = ( projL[ 8 ] - 1 ) / projL[ 0 ];
26901
- var rightFov = ( projR[ 8 ] + 1 ) / projR[ 0 ];
26902
- var left = near * leftFov;
26903
- var right = near * rightFov;
26904
-
26905
- // Calculate the new camera's position offset from the
26906
- // left camera. xOffset should be roughly half `ipd`.
26907
- var zOffset = ipd / ( - leftFov + rightFov );
26908
- var xOffset = zOffset * - leftFov;
26909
-
26910
- // TODO: Better way to apply this offset?
26911
- cameraL.matrixWorld.decompose( camera.position, camera.quaternion, camera.scale );
26912
- camera.translateX( xOffset );
26913
- camera.translateZ( zOffset );
26914
- camera.matrixWorld.compose( camera.position, camera.quaternion, camera.scale );
26915
- camera.matrixWorldInverse.copy( camera.matrixWorld ).invert();
26916
-
26917
- // Find the union of the frustum values of the cameras and scale
26918
- // the values so that the near plane's position does not change in world space,
26919
- // although must now be relative to the new union camera.
26920
- var near2 = near + zOffset;
26921
- var far2 = far + zOffset;
26922
- var left2 = left - xOffset;
26923
- var right2 = right + ( ipd - xOffset );
26924
- var top2 = topFov * far / far2 * near2;
26925
- var bottom2 = bottomFov * far / far2 * near2;
26926
-
26927
- camera.projectionMatrix.makePerspective( left2, right2, top2, bottom2, near2, far2 );
26928
-
26929
- }
26930
-
26931
- /**
26932
- * @author mrdoob / http://mrdoob.com/
26933
- */
26934
-
26935
-
26936
- function WebVRManager( renderer ) {
26937
-
26938
- var renderWidth, renderHeight;
26939
- var scope = this;
26940
-
26941
- var device = null;
26942
- var frameData = null;
26943
-
26944
- var poseTarget = null;
26945
-
26946
- var controllers = [];
26947
- var standingMatrix = new Matrix4();
26948
- var standingMatrixInverse = new Matrix4();
26949
-
26950
- var framebufferScaleFactor = 1.0;
26951
-
26952
- var referenceSpaceType = 'local-floor';
26953
-
26954
- if ( typeof window !== 'undefined' && 'VRFrameData' in window ) {
26955
-
26956
- frameData = new window.VRFrameData();
26957
- window.addEventListener( 'vrdisplaypresentchange', onVRDisplayPresentChange, false );
26958
-
26959
- }
26960
-
26961
- var matrixWorldInverse = new Matrix4();
26962
- var tempQuaternion = new Quaternion();
26963
- var tempPosition = new Vector3();
26964
-
26965
- var cameraL = new PerspectiveCamera();
26966
- cameraL.viewport = new Vector4();
26967
- cameraL.layers.enable( 1 );
26968
-
26969
- var cameraR = new PerspectiveCamera();
26970
- cameraR.viewport = new Vector4();
26971
- cameraR.layers.enable( 2 );
26972
-
26973
- var cameraVR = new ArrayCamera( [ cameraL, cameraR ] );
26974
- cameraVR.layers.enable( 1 );
26975
- cameraVR.layers.enable( 2 );
26976
-
26977
- var currentSize = new Vector2(), currentPixelRatio;
26978
-
26979
- function onVRDisplayPresentChange() {
26980
-
26981
- var isPresenting = scope.isPresenting = device !== null && device.isPresenting === true;
26982
-
26983
- if ( isPresenting ) {
26984
-
26985
- var eyeParameters = device.getEyeParameters( 'left' );
26986
- renderWidth = 2 * eyeParameters.renderWidth * framebufferScaleFactor;
26987
- renderHeight = eyeParameters.renderHeight * framebufferScaleFactor;
26988
-
26989
- currentPixelRatio = renderer.getPixelRatio();
26990
- renderer.getSize( currentSize );
26991
-
26992
- renderer.setDrawingBufferSize( renderWidth, renderHeight, 1 );
26993
-
26994
- cameraL.viewport.set( 0, 0, renderWidth / 2, renderHeight );
26995
- cameraR.viewport.set( renderWidth / 2, 0, renderWidth / 2, renderHeight );
26996
-
26997
- animation.start();
26998
-
26999
- scope.dispatchEvent( { type: 'sessionstart' } );
27000
-
27001
- } else {
27002
-
27003
- if ( scope.enabled ) {
27004
-
27005
- renderer.setDrawingBufferSize( currentSize.width, currentSize.height, currentPixelRatio );
27006
-
27007
- }
27008
-
27009
- animation.stop();
27010
-
27011
- scope.dispatchEvent( { type: 'sessionend' } );
27012
-
27013
- }
27014
-
27015
- }
27016
-
27017
- //
27018
-
27019
- var triggers = [];
27020
- var grips = [];
27021
-
27022
- function findGamepad( id ) {
27023
-
27024
- var gamepads = navigator.getGamepads && navigator.getGamepads();
27025
-
27026
- for ( var i = 0, l = gamepads.length; i < l; i ++ ) {
27027
-
27028
- var gamepad = gamepads[ i ];
27029
-
27030
- if ( gamepad && ( gamepad.id === 'Daydream Controller' ||
27031
- gamepad.id === 'Gear VR Controller' || gamepad.id === 'Oculus Go Controller' ||
27032
- gamepad.id === 'OpenVR Gamepad' || gamepad.id.startsWith( 'Oculus Touch' ) ||
27033
- gamepad.id.startsWith( 'HTC Vive Focus' ) ||
27034
- gamepad.id.startsWith( 'Spatial Controller' ) ) ) {
27035
-
27036
- var hand = gamepad.hand;
27037
-
27038
- if ( id === 0 && ( hand === '' || hand === 'right' ) ) return gamepad;
27039
- if ( id === 1 && ( hand === 'left' ) ) return gamepad;
27040
-
27041
- }
27042
-
27043
- }
27044
-
27045
- }
27046
-
27047
- function updateControllers() {
27048
-
27049
- for ( var i = 0; i < controllers.length; i ++ ) {
27050
-
27051
- var controller = controllers[ i ];
27052
-
27053
- var gamepad = findGamepad( i );
27054
-
27055
- if ( gamepad !== undefined && gamepad.pose !== undefined ) {
27056
-
27057
- if ( gamepad.pose === null ) return;
27058
-
27059
- // Pose
27060
-
27061
- var pose = gamepad.pose;
27062
-
27063
- if ( pose.hasPosition === false ) controller.position.set( 0.2, - 0.6, - 0.05 );
27064
-
27065
- if ( pose.position !== null ) controller.position.fromArray( pose.position );
27066
- if ( pose.orientation !== null ) controller.quaternion.fromArray( pose.orientation );
27067
- controller.matrix.compose( controller.position, controller.quaternion, controller.scale );
27068
- controller.matrix.premultiply( standingMatrix );
27069
- controller.matrix.decompose( controller.position, controller.quaternion, controller.scale );
27070
- controller.matrixWorldNeedsUpdate = true;
27071
- controller.visible = true;
27072
-
27073
- // Trigger
27074
-
27075
- var buttonId = gamepad.id === 'Daydream Controller' ? 0 : 1;
27076
-
27077
- if ( triggers[ i ] === undefined ) triggers[ i ] = false;
27078
-
27079
- if ( triggers[ i ] !== gamepad.buttons[ buttonId ].pressed ) {
27080
-
27081
- triggers[ i ] = gamepad.buttons[ buttonId ].pressed;
27082
-
27083
- if ( triggers[ i ] === true ) {
27084
-
27085
- controller.dispatchEvent( { type: 'selectstart' } );
27086
-
27087
- } else {
27088
-
27089
- controller.dispatchEvent( { type: 'selectend' } );
27090
- controller.dispatchEvent( { type: 'select' } );
27091
-
27092
- }
27093
-
27094
- }
27095
-
27096
- // Grip
27097
- buttonId = 2;
27098
-
27099
- if ( grips[ i ] === undefined ) grips[ i ] = false;
27100
-
27101
- // Skip if the grip button doesn't exist on this controller
27102
- if ( gamepad.buttons[ buttonId ] !== undefined ) {
27103
-
27104
- if ( grips[ i ] !== gamepad.buttons[ buttonId ].pressed ) {
27105
-
27106
- grips[ i ] = gamepad.buttons[ buttonId ].pressed;
27107
-
27108
- if ( grips[ i ] === true ) {
27109
-
27110
- controller.dispatchEvent( { type: 'squeezestart' } );
27111
-
27112
- } else {
27113
-
27114
- controller.dispatchEvent( { type: 'squeezeend' } );
27115
- controller.dispatchEvent( { type: 'squeeze' } );
27116
-
27117
- }
27118
-
27119
- }
27120
-
27121
- }
27122
-
27123
- } else {
27124
-
27125
- controller.visible = false;
27126
-
27127
- }
27128
-
27129
- }
27130
-
27131
- }
27132
-
27133
- function updateViewportFromBounds( viewport, bounds ) {
27134
-
27135
- if ( bounds !== null && bounds.length === 4 ) {
27136
-
27137
- viewport.set( bounds[ 0 ] * renderWidth, bounds[ 1 ] * renderHeight, bounds[ 2 ] * renderWidth, bounds[ 3 ] * renderHeight );
27138
-
27139
- }
27140
-
27141
- }
27142
-
27143
- //
27144
-
27145
- this.enabled = false;
27146
-
27147
- this.getController = function ( id ) {
27148
-
27149
- var controller = controllers[ id ];
27150
-
27151
- if ( controller === undefined ) {
27152
-
27153
- controller = new Group();
27154
- controller.matrixAutoUpdate = false;
27155
- controller.visible = false;
27156
-
27157
- controllers[ id ] = controller;
27158
-
27159
- }
27160
-
27161
- return controller;
27162
-
27163
- };
27164
-
27165
- this.getDevice = function () {
27166
-
27167
- return device;
27168
-
27169
- };
27170
-
27171
- this.setDevice = function ( value ) {
27172
-
27173
- if ( value !== undefined ) device = value;
27174
-
27175
- animation.setContext( value );
27176
-
27177
- };
27178
-
27179
- this.setFramebufferScaleFactor = function ( value ) {
27180
-
27181
- framebufferScaleFactor = value;
27182
-
27183
- };
27184
-
27185
- this.setReferenceSpaceType = function ( value ) {
27186
-
27187
- referenceSpaceType = value;
27188
-
27189
- };
27190
-
27191
- this.setPoseTarget = function ( object ) {
27192
-
27193
- if ( object !== undefined ) poseTarget = object;
27194
-
27195
- };
27196
-
27197
- //
27198
-
27199
- this.cameraAutoUpdate = true;
27200
-
27201
- this.updateCamera = function ( camera ) {
27202
-
27203
- var userHeight = referenceSpaceType === 'local-floor' ? 1.6 : 0;
27204
-
27205
- device.depthNear = camera.near;
27206
- device.depthFar = camera.far;
27207
-
27208
- device.getFrameData( frameData );
27209
-
27210
- //
27211
-
27212
- if ( referenceSpaceType === 'local-floor' ) {
27213
-
27214
- var stageParameters = device.stageParameters;
27215
-
27216
- if ( stageParameters ) {
27217
-
27218
- standingMatrix.fromArray( stageParameters.sittingToStandingTransform );
27219
-
27220
- } else {
27221
-
27222
- standingMatrix.makeTranslation( 0, userHeight, 0 );
27223
-
27224
- }
27225
-
27226
- }
27227
-
27228
-
27229
- var pose = frameData.pose;
27230
- var poseObject = poseTarget !== null ? poseTarget : camera;
27231
-
27232
- // We want to manipulate poseObject by its position and quaternion components since users may rely on them.
27233
- poseObject.matrix.copy( standingMatrix );
27234
- poseObject.matrix.decompose( poseObject.position, poseObject.quaternion, poseObject.scale );
27235
-
27236
- if ( pose.orientation !== null ) {
27237
-
27238
- tempQuaternion.fromArray( pose.orientation );
27239
- poseObject.quaternion.multiply( tempQuaternion );
27240
-
27241
- }
27242
-
27243
- if ( pose.position !== null ) {
27244
-
27245
- tempQuaternion.setFromRotationMatrix( standingMatrix );
27246
- tempPosition.fromArray( pose.position );
27247
- tempPosition.applyQuaternion( tempQuaternion );
27248
- poseObject.position.add( tempPosition );
27249
-
27250
- }
27251
-
27252
- poseObject.updateMatrixWorld();
27253
-
27254
- var children = poseObject.children;
27255
- for ( var i = 0, l = children.length; i < l; i ++ ) {
27256
-
27257
- children[ i ].updateMatrixWorld( true );
27258
-
27259
- }
27260
-
27261
- //
27262
-
27263
- cameraL.near = camera.near;
27264
- cameraR.near = camera.near;
27265
-
27266
- cameraL.far = camera.far;
27267
- cameraR.far = camera.far;
27268
-
27269
- cameraL.matrixWorldInverse.fromArray( frameData.leftViewMatrix );
27270
- cameraR.matrixWorldInverse.fromArray( frameData.rightViewMatrix );
27271
-
27272
- // TODO (mrdoob) Double check this code
27273
-
27274
- standingMatrixInverse.copy( standingMatrix ).invert();
27275
-
27276
- if ( referenceSpaceType === 'local-floor' ) {
27277
-
27278
- cameraL.matrixWorldInverse.multiply( standingMatrixInverse );
27279
- cameraR.matrixWorldInverse.multiply( standingMatrixInverse );
27280
-
27281
- }
27282
-
27283
- var parent = poseObject.parent;
27284
-
27285
- if ( parent !== null ) {
27286
-
27287
- matrixWorldInverse.copy( parent.matrixWorld ).invert();
27288
-
27289
- cameraL.matrixWorldInverse.multiply( matrixWorldInverse );
27290
- cameraR.matrixWorldInverse.multiply( matrixWorldInverse );
27291
-
27292
- }
27293
-
27294
- // envMap and Mirror needs camera.matrixWorld
27295
-
27296
- cameraL.matrixWorld.copy( cameraL.matrixWorldInverse ).invert();
27297
- cameraR.matrixWorld.copy( cameraR.matrixWorldInverse ).invert();
27298
-
27299
- cameraL.projectionMatrix.fromArray( frameData.leftProjectionMatrix );
27300
- cameraR.projectionMatrix.fromArray( frameData.rightProjectionMatrix );
27301
-
27302
- setProjectionFromUnion( cameraVR, cameraL, cameraR );
27303
-
27304
- //
27305
-
27306
- var layers = device.getLayers();
27307
-
27308
- if ( layers.length ) {
27309
-
27310
- var layer = layers[ 0 ];
27311
-
27312
- updateViewportFromBounds( cameraL.viewport, layer.leftBounds );
27313
- updateViewportFromBounds( cameraR.viewport, layer.rightBounds );
27314
-
27315
- }
27316
-
27317
- updateControllers();
27318
-
27319
- return cameraVR;
27320
-
27321
- };
27322
-
27323
- this.getCamera = function () {
27324
-
27325
- return cameraVR;
27326
-
27327
- };
27328
-
27329
- // Dummy getFoveation/setFoveation to have the same API as WebXR
27330
-
27331
- this.getFoveation = function () {
27332
-
27333
- return 1;
27334
-
27335
- };
27336
-
27337
- this.setFoveation = function ( foveation ) {
27338
-
27339
- if ( foveation !== 1 ) {
27340
-
27341
- console.warn( 'THREE.WebVRManager: setFoveation() not used in WebVR.' );
27342
-
27343
- }
27344
-
27345
- };
27346
-
27347
- // Dummy getEnvironmentBlendMode to have the same API as WebXR
27348
-
27349
- this.getEnvironmentBlendMode = function () {
27350
-
27351
- if ( scope.isPresenting ) {
27352
-
27353
- return 'opaque';
27354
-
27355
- }
27356
-
27357
- };
27358
-
27359
- //
27360
-
27361
- this.getStandingMatrix = function () {
27362
-
27363
- return standingMatrix;
27364
-
27365
- };
27366
-
27367
- this.isPresenting = false;
27368
-
27369
- // Animation Loop
27370
-
27371
- var animation = new WebGLAnimation();
27372
-
27373
- this.setAnimationLoop = function ( callback ) {
27374
-
27375
- animation.setAnimationLoop( callback );
27376
-
27377
- if ( this.isPresenting ) animation.start();
27378
-
27379
- };
27380
-
27381
- this.submitFrame = function () {
27382
-
27383
- if ( this.isPresenting ) device.submitFrame();
27384
-
27385
- };
27386
-
27387
- this.dispose = function () {
27388
-
27389
- if ( typeof window !== 'undefined' ) {
27390
-
27391
- window.removeEventListener( 'vrdisplaypresentchange', onVRDisplayPresentChange );
27392
-
27393
- }
27394
-
27395
- };
27396
-
27397
- // DEPRECATED
27398
-
27399
- this.setFrameOfReferenceType = function () {
27400
-
27401
- console.warn( 'THREE.WebVRManager: setFrameOfReferenceType() has been deprecated.' );
27402
-
27403
- };
27404
-
27405
- }
27406
-
27407
- Object.assign( WebVRManager.prototype, {
27408
- addEventListener: EventDispatcher.prototype.addEventListener,
27409
- hasEventListener: EventDispatcher.prototype.hasEventListener,
27410
- removeEventListener: EventDispatcher.prototype.removeEventListener,
27411
- dispatchEvent: EventDispatcher.prototype.dispatchEvent
27412
- } );
27413
-
27414
26853
  /**
27415
26854
  * @author fernandojsg / http://fernandojsg.com
27416
26855
  * @author Takahiro https://github.com/takahirox
@@ -27444,6 +26883,20 @@ class WebGLMultiviewRenderTarget extends WebGLRenderTarget {
27444
26883
 
27445
26884
  WebGLMultiviewRenderTarget.prototype.isWebGLMultiviewRenderTarget = true;
27446
26885
 
26886
+ class Group extends Object3D {
26887
+
26888
+ constructor() {
26889
+
26890
+ super();
26891
+
26892
+ this.isGroup = true;
26893
+
26894
+ this.type = 'Group';
26895
+
26896
+ }
26897
+
26898
+ }
26899
+
27447
26900
  const _moveEvent = { type: 'move' };
27448
26901
 
27449
26902
  class WebXRController {
@@ -30023,7 +29476,7 @@ class WebGLRenderer {
30023
29476
 
30024
29477
  // xr
30025
29478
 
30026
- const xr = ( typeof navigator !== 'undefined' && 'xr' in navigator ) ? new WebXRManager( _this, _gl, extensions, multiviewStereo ) : new WebVRManager( _this );
29479
+ const xr = new WebXRManager( _this, _gl );
30027
29480
 
30028
29481
  this.xr = xr;
30029
29482
 
@@ -30983,13 +30436,6 @@ class WebGLRenderer {
30983
30436
 
30984
30437
  if ( scene.isScene === true ) scene.onAfterRender( _this, scene, camera );
30985
30438
 
30986
- textures.runDeferredUploads();
30987
-
30988
- if ( xr.enabled && xr.submitFrame ) {
30989
-
30990
- xr.submitFrame();
30991
-
30992
- }
30993
30439
  // _gl.finish();
30994
30440
 
30995
30441
  bindingStates.resetDefaultState();