@playcanvas/supersplat-viewer 1.43.2 → 1.43.3
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.
- package/dist/index.js +1 -1
- package/dist/settings.js +1 -1
- package/dist/settings.js.map +1 -1
- package/dist/viewer.js +105 -18
- package/dist/viewer.js.map +1 -1
- package/package.json +1 -1
- package/public/index.js +105 -18
- package/public/index.js.map +1 -1
package/package.json
CHANGED
package/public/index.js
CHANGED
|
@@ -99156,7 +99156,7 @@ deepFreeze({
|
|
|
99156
99156
|
});
|
|
99157
99157
|
/** Size limits for annotations. Intentionally tight for now. */
|
|
99158
99158
|
deepFreeze({
|
|
99159
|
-
maxCount:
|
|
99159
|
+
maxCount: 50,
|
|
99160
99160
|
titleMax: 60,
|
|
99161
99161
|
textMax: 280
|
|
99162
99162
|
});
|
|
@@ -99267,7 +99267,7 @@ const importSettings = (settings) => {
|
|
|
99267
99267
|
return result;
|
|
99268
99268
|
};
|
|
99269
99269
|
|
|
99270
|
-
var version = "1.43.
|
|
99270
|
+
var version = "1.43.3";
|
|
99271
99271
|
|
|
99272
99272
|
class Tooltip {
|
|
99273
99273
|
register;
|
|
@@ -102783,6 +102783,18 @@ class TeleportTarget {
|
|
|
102783
102783
|
}
|
|
102784
102784
|
}
|
|
102785
102785
|
|
|
102786
|
+
/**
|
|
102787
|
+
* Whether an input source is a bare tracked hand. Some runtimes (SteamVR) also give a controller a
|
|
102788
|
+
* hand, posed from its finger sensors; it keeps its buttons and thumbsticks, so it stays a
|
|
102789
|
+
* controller. A bare hand has a generic-hand profile, or a gamepad with no axes, as the engine's
|
|
102790
|
+
* XR scripts tell them apart.
|
|
102791
|
+
*
|
|
102792
|
+
* @param source - The input source.
|
|
102793
|
+
* @returns True for a bare hand.
|
|
102794
|
+
*/
|
|
102795
|
+
const isHand = (source) => !!source.hand &&
|
|
102796
|
+
(!source.gamepad?.axes.length || source.profiles.some((profile) => profile.startsWith('generic-hand')));
|
|
102797
|
+
|
|
102786
102798
|
// The menu's rows, a column centred on its anchor (meters, at real size), each ROW_HEIGHT tall and
|
|
102787
102799
|
// drawn at PIXELS per meter: a hand's length across, read from about 40 cm
|
|
102788
102800
|
const ROW_WIDTH = 0.12;
|
|
@@ -103015,7 +103027,7 @@ class XrPalmMenu {
|
|
|
103015
103027
|
* @returns Whether it points at the open menu.
|
|
103016
103028
|
*/
|
|
103017
103029
|
pointsAt(source) {
|
|
103018
|
-
return this.open && !source
|
|
103030
|
+
return this.open && !isHand(source) && !!this.pointedAt(source);
|
|
103019
103031
|
}
|
|
103020
103032
|
/**
|
|
103021
103033
|
* Takes a select that starts on a row of the open menu, pressing it. A hand's select is left
|
|
@@ -103025,7 +103037,7 @@ class XrPalmMenu {
|
|
|
103025
103037
|
* @returns True when the menu took the select.
|
|
103026
103038
|
*/
|
|
103027
103039
|
select(source) {
|
|
103028
|
-
if (!this.open || source
|
|
103040
|
+
if (!this.open || isHand(source))
|
|
103029
103041
|
return false;
|
|
103030
103042
|
const quad = this.pointedAt(source);
|
|
103031
103043
|
if (!quad)
|
|
@@ -103228,7 +103240,7 @@ class XrPalmMenu {
|
|
|
103228
103240
|
// the left hand or controller when it is in use, else the other: a hand that has lost tracking
|
|
103229
103241
|
// stays an input source, and would keep the menu closed on the other
|
|
103230
103242
|
preferred() {
|
|
103231
|
-
const usable = this.app.xr.input.inputSources.filter((source) => source.handedness !== 'none' && (!source
|
|
103243
|
+
const usable = this.app.xr.input.inputSources.filter((source) => source.handedness !== 'none' && (!isHand(source) || source.hand.tracking));
|
|
103232
103244
|
return usable.find((source) => source.handedness === 'left') ?? usable[0] ?? null;
|
|
103233
103245
|
}
|
|
103234
103246
|
// opens the menu on an open palm facing the eyes, or on a controller's toggle button
|
|
@@ -103241,7 +103253,7 @@ class XrPalmMenu {
|
|
|
103241
103253
|
}
|
|
103242
103254
|
if (!source)
|
|
103243
103255
|
return;
|
|
103244
|
-
if (source
|
|
103256
|
+
if (isHand(source)) {
|
|
103245
103257
|
this.setOpen(this.palmFacing(source));
|
|
103246
103258
|
return;
|
|
103247
103259
|
}
|
|
@@ -103288,7 +103300,7 @@ class XrPalmMenu {
|
|
|
103288
103300
|
anchorPose(source) {
|
|
103289
103301
|
const scale = this.scale;
|
|
103290
103302
|
const hand = source.hand;
|
|
103291
|
-
if (
|
|
103303
|
+
if (isHand(source)) {
|
|
103292
103304
|
const knuckle = hand.getJointById('middle-finger-metacarpal');
|
|
103293
103305
|
const proximal = hand.getJointById('middle-finger-phalanx-proximal');
|
|
103294
103306
|
if (!knuckle || !proximal || !this.palmNormal(source))
|
|
@@ -103326,7 +103338,7 @@ class XrPalmMenu {
|
|
|
103326
103338
|
}
|
|
103327
103339
|
// whether a source's ray points at the menu: a controller's
|
|
103328
103340
|
pointing(source) {
|
|
103329
|
-
return source.targetRayMode === 'tracked-pointer' && !source
|
|
103341
|
+
return source.targetRayMode === 'tracked-pointer' && !isHand(source);
|
|
103330
103342
|
}
|
|
103331
103343
|
// controllers' rays, and the other hand's fingertip, highlight the row they are on; the
|
|
103332
103344
|
// fingertip presses it
|
|
@@ -103343,7 +103355,7 @@ class XrPalmMenu {
|
|
|
103343
103355
|
side = this.sideOf(quad);
|
|
103344
103356
|
}
|
|
103345
103357
|
}
|
|
103346
|
-
if (!hovered && this.anchor
|
|
103358
|
+
if (!hovered && this.anchor && isHand(this.anchor)) {
|
|
103347
103359
|
const poked = this.poke(this.anchor);
|
|
103348
103360
|
if (poked) {
|
|
103349
103361
|
hovered = poked;
|
|
@@ -103368,7 +103380,7 @@ class XrPalmMenu {
|
|
|
103368
103380
|
}
|
|
103369
103381
|
// the row the other hand's index fingertip is on, pressing it once it reaches it
|
|
103370
103382
|
poke(anchor) {
|
|
103371
|
-
const poking = this.app.xr.input.inputSources.find((source) => source !== anchor && source.hand
|
|
103383
|
+
const poking = this.app.xr.input.inputSources.find((source) => source !== anchor && isHand(source) && source.hand.tracking);
|
|
103372
103384
|
const tip = poking?.hand.getJointById('index-finger-tip');
|
|
103373
103385
|
if (!poking || !tip) {
|
|
103374
103386
|
this.pokeReady = true;
|
|
@@ -104331,7 +104343,7 @@ class XrArPlacement {
|
|
|
104331
104343
|
placingInput() {
|
|
104332
104344
|
if (this.pointers.size === 0)
|
|
104333
104345
|
return 'screen';
|
|
104334
|
-
return [...this.pointers.keys()].some((source) => !source
|
|
104346
|
+
return [...this.pointers.keys()].some((source) => !isHand(source)) ? 'controller' : 'hand';
|
|
104335
104347
|
}
|
|
104336
104348
|
// low in the middle of the screen, a share of its width across: a point of the view's
|
|
104337
104349
|
// projection at HINT_SCREEN_AHEAD, square to the camera
|
|
@@ -104385,6 +104397,78 @@ class XrArPlacement {
|
|
|
104385
104397
|
}
|
|
104386
104398
|
}
|
|
104387
104399
|
|
|
104400
|
+
const controllerHand = (source) => !!source.hand && !isHand(source);
|
|
104401
|
+
// Updates a controller with a hand as the controller it is: its hand's joints, then, with the hand
|
|
104402
|
+
// set aside, the grip pose and target ray the engine gives a device. The hand's squeeze test reads
|
|
104403
|
+
// back the grip button's squeeze, so it neither starts nor ends one
|
|
104404
|
+
const patchSource = (source) => {
|
|
104405
|
+
if (!controllerHand(source))
|
|
104406
|
+
return;
|
|
104407
|
+
const internals = source;
|
|
104408
|
+
const hand = internals._hand;
|
|
104409
|
+
const update = internals.update;
|
|
104410
|
+
hand._fingerIsClosed = () => internals._squeezing;
|
|
104411
|
+
internals.update = (frame) => {
|
|
104412
|
+
hand.update(frame);
|
|
104413
|
+
internals._hand = null;
|
|
104414
|
+
try {
|
|
104415
|
+
update.call(internals, frame);
|
|
104416
|
+
}
|
|
104417
|
+
finally {
|
|
104418
|
+
internals._hand = hand;
|
|
104419
|
+
}
|
|
104420
|
+
};
|
|
104421
|
+
};
|
|
104422
|
+
// Runs a callback with the hands of the controllers among `sources` set aside, so engine code that
|
|
104423
|
+
// would take them for bare hands sees the devices
|
|
104424
|
+
const withoutControllerHands = (sources, callback) => {
|
|
104425
|
+
const setAside = [];
|
|
104426
|
+
for (const source of sources) {
|
|
104427
|
+
if (!controllerHand(source))
|
|
104428
|
+
continue;
|
|
104429
|
+
const internals = source;
|
|
104430
|
+
setAside.push([internals, internals._hand]);
|
|
104431
|
+
internals._hand = null;
|
|
104432
|
+
}
|
|
104433
|
+
try {
|
|
104434
|
+
return callback();
|
|
104435
|
+
}
|
|
104436
|
+
finally {
|
|
104437
|
+
for (const [internals, hand] of setAside)
|
|
104438
|
+
internals._hand = hand;
|
|
104439
|
+
}
|
|
104440
|
+
};
|
|
104441
|
+
/**
|
|
104442
|
+
* Runs a callback with a controller's hand set aside, so engine code that would take the
|
|
104443
|
+
* controller for a bare hand (XrNavigation's palm test for the system menu) sees the device.
|
|
104444
|
+
*
|
|
104445
|
+
* @param source - The input source.
|
|
104446
|
+
* @param callback - The callback.
|
|
104447
|
+
* @returns The callback's result.
|
|
104448
|
+
*/
|
|
104449
|
+
const withoutControllerHand = (source, callback) => withoutControllerHands([source], callback);
|
|
104450
|
+
/**
|
|
104451
|
+
* Patches the controllers with a hand as the session adds them, and runs XrControllers' update
|
|
104452
|
+
* with their hands set aside, so it shows and places their models as it does a device's: at the
|
|
104453
|
+
* grip, hidden only while the session is, rather than posing joints the model does not have and
|
|
104454
|
+
* hiding it whenever the hand loses tracking.
|
|
104455
|
+
*
|
|
104456
|
+
* @param app - The application.
|
|
104457
|
+
* @param controllers - The XrControllers script.
|
|
104458
|
+
* @returns A handle that removes the patch.
|
|
104459
|
+
*/
|
|
104460
|
+
const patchControllerHands = (app, controllers) => {
|
|
104461
|
+
const added = app.xr.input.on('add', patchSource);
|
|
104462
|
+
const update = controllers.update;
|
|
104463
|
+
controllers.update = (dt) => withoutControllerHands(app.xr.input.inputSources, () => update.call(controllers, dt));
|
|
104464
|
+
return {
|
|
104465
|
+
off() {
|
|
104466
|
+
added.off();
|
|
104467
|
+
controllers.update = update;
|
|
104468
|
+
}
|
|
104469
|
+
};
|
|
104470
|
+
};
|
|
104471
|
+
|
|
104388
104472
|
/**
|
|
104389
104473
|
* Clears each eye's depth texture of a WebGPU XR session to the far plane every frame, ahead of the
|
|
104390
104474
|
* engine's frame.
|
|
@@ -105278,15 +105362,15 @@ const overshoot = (x) => {
|
|
|
105278
105362
|
return 1 + (c + 1) * y * y * y + c * y * y;
|
|
105279
105363
|
};
|
|
105280
105364
|
// a side's tracked hand, or else its controller
|
|
105281
|
-
const sourceOf = (sources, handedness) => sources.find((source) => source
|
|
105282
|
-
sources.find((source) => !source
|
|
105365
|
+
const sourceOf = (sources, handedness) => sources.find((source) => isHand(source) && source.handedness === handedness) ??
|
|
105366
|
+
sources.find((source) => !isHand(source) && source.grip && source.handedness === handedness) ??
|
|
105283
105367
|
null;
|
|
105284
105368
|
// where a right hand or controller is for the cover test, the resize and the turn: the hand's
|
|
105285
105369
|
// COVER_JOINT, or the controller's grip; null where a hand is not tracked
|
|
105286
105370
|
const pointOf = (source) => {
|
|
105287
105371
|
if (!source)
|
|
105288
105372
|
return null;
|
|
105289
|
-
if (!source
|
|
105373
|
+
if (!isHand(source))
|
|
105290
105374
|
return source.getPosition();
|
|
105291
105375
|
return source.hand.tracking ? (source.hand.getJointById(COVER_JOINT)?.getPosition() ?? null) : null;
|
|
105292
105376
|
};
|
|
@@ -105495,7 +105579,7 @@ class XrIceCream {
|
|
|
105495
105579
|
const sources = xr.input.inputSources;
|
|
105496
105580
|
const left = sourceOf(sources, 'left');
|
|
105497
105581
|
const tracked = !!left &&
|
|
105498
|
-
(left
|
|
105582
|
+
(isHand(left)
|
|
105499
105583
|
? left.hand.tracking && measureFist(left.hand, this.handPosition, this.handRotation)
|
|
105500
105584
|
: measureGrip(left, this.handPosition, this.handRotation, this.userScale()));
|
|
105501
105585
|
if (tracked) {
|
|
@@ -105511,7 +105595,7 @@ class XrIceCream {
|
|
|
105511
105595
|
// a hand out of sight, or covered, is neither open nor closed: losing it counts by LOST_TIME
|
|
105512
105596
|
if (tracked && left && !covered) {
|
|
105513
105597
|
const wasFist = this.openFor < FLICKER_TIME;
|
|
105514
|
-
const closed = left.squeezing || (wasFist &&
|
|
105598
|
+
const closed = left.squeezing || (wasFist && isHand(left) && foldedFingers(left.hand) >= HELD_FINGERS);
|
|
105515
105599
|
this.openFor = closed ? 0 : this.openFor + dt;
|
|
105516
105600
|
}
|
|
105517
105601
|
const fist = this.openFor < FLICKER_TIME;
|
|
@@ -106516,6 +106600,8 @@ const initXr = (global) => {
|
|
|
106516
106600
|
parent.addComponent('script');
|
|
106517
106601
|
// its models by input source (the script's own typing is Script)
|
|
106518
106602
|
const controllers = parent.script.create(XrControllers);
|
|
106603
|
+
// TEMPORARY: controllers that report a hand (SteamVR), as playcanvas/engine#10053 handles them
|
|
106604
|
+
const controllerHandPatch = patchControllerHands(app, controllers);
|
|
106519
106605
|
// the members of the navigation the viewer uses (the script's own typing is Script)
|
|
106520
106606
|
const navigation = parent.script.create(XrNavigation);
|
|
106521
106607
|
replaceTeleportArc(navigation);
|
|
@@ -106541,7 +106627,7 @@ const initXr = (global) => {
|
|
|
106541
106627
|
const handStyle = new XrHandStyle();
|
|
106542
106628
|
const modelAdded = app.on('xr:controller:add', (source, entity) => {
|
|
106543
106629
|
scaleModel(entity);
|
|
106544
|
-
if (source
|
|
106630
|
+
if (isHand(source)) {
|
|
106545
106631
|
handStyle.apply(entity);
|
|
106546
106632
|
if (xr.type === 'immersive-ar')
|
|
106547
106633
|
entity.enabled = false;
|
|
@@ -107014,7 +107100,7 @@ const initXr = (global) => {
|
|
|
107014
107100
|
]);
|
|
107015
107101
|
// and, while the splat is held, takes the rest: the world to teleport in is in the hand
|
|
107016
107102
|
const isSystemSelect = navigation._isSystemSelect.bind(navigation);
|
|
107017
|
-
navigation._isSystemSelect = (source) => isSystemSelect(source) || menu.select(source) || !!iceCream?.holding;
|
|
107103
|
+
navigation._isSystemSelect = (source) => withoutControllerHand(source, () => isSystemSelect(source)) || menu.select(source) || !!iceCream?.holding;
|
|
107018
107104
|
const cancel = events.on('inputEvent', (event) => {
|
|
107019
107105
|
if (event === 'cancel' && xr.active) {
|
|
107020
107106
|
void end().catch(() => {
|
|
@@ -107078,6 +107164,7 @@ const initXr = (global) => {
|
|
|
107078
107164
|
cancel.off();
|
|
107079
107165
|
updating.off();
|
|
107080
107166
|
modelAdded.off();
|
|
107167
|
+
controllerHandPatch.off();
|
|
107081
107168
|
handStyle.destroy();
|
|
107082
107169
|
forgetReferenceSpace();
|
|
107083
107170
|
menu.destroy();
|