@playcanvas/supersplat-viewer 1.43.1 → 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/README.md +4 -0
- package/dist/index.js +1 -1
- package/dist/settings.js +1 -1
- package/dist/settings.js.map +1 -1
- package/dist/viewer.js +108 -22
- package/dist/viewer.js.map +1 -1
- package/package.json +3 -3
- package/public/index.js +137 -51
- package/public/index.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playcanvas/supersplat-viewer",
|
|
3
|
-
"version": "1.43.
|
|
3
|
+
"version": "1.43.3",
|
|
4
4
|
"author": "PlayCanvas <support@playcanvas.com>",
|
|
5
5
|
"homepage": "https://github.com/playcanvas/supersplat-viewer#readme",
|
|
6
6
|
"description": "Viewer for https://superspl.at",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"README.md"
|
|
59
59
|
],
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"playcanvas": "^2.24.
|
|
61
|
+
"playcanvas": "^2.24.1"
|
|
62
62
|
},
|
|
63
63
|
"peerDependenciesMeta": {
|
|
64
64
|
"playcanvas": {
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"autoprefixer": "10.6.2",
|
|
74
74
|
"concurrently": "9.2.5",
|
|
75
75
|
"eslint": "9.39.5",
|
|
76
|
-
"playcanvas": "2.24.
|
|
76
|
+
"playcanvas": "2.24.1",
|
|
77
77
|
"postcss": "8.5.32",
|
|
78
78
|
"prettier": "3.9.10",
|
|
79
79
|
"publint": "0.3.25",
|
package/public/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const TRACEID_GPU_TIMINGS = "GpuTimings";
|
|
2
2
|
|
|
3
|
-
const version$1 = "2.24.
|
|
4
|
-
const revision = "
|
|
3
|
+
const version$1 = "2.24.1";
|
|
4
|
+
const revision = "8597cab";
|
|
5
5
|
function extend(target, ex) {
|
|
6
6
|
for (const prop in ex) {
|
|
7
7
|
const copy = ex[prop];
|
|
@@ -11948,9 +11948,20 @@ var webgpu_clear_default = `
|
|
|
11948
11948
|
output.position = vec4(pos[vertexIndex], ubMesh.depth, 1.0);
|
|
11949
11949
|
return output;
|
|
11950
11950
|
}
|
|
11951
|
+
struct FragmentOutput {
|
|
11952
|
+
@location(0) color0 : vec4f,
|
|
11953
|
+
@location(1) color1 : vec4f,
|
|
11954
|
+
@location(2) color2 : vec4f,
|
|
11955
|
+
@location(3) color3 : vec4f,
|
|
11956
|
+
@location(4) color4 : vec4f,
|
|
11957
|
+
@location(5) color5 : vec4f,
|
|
11958
|
+
@location(6) color6 : vec4f,
|
|
11959
|
+
@location(7) color7 : vec4f
|
|
11960
|
+
}
|
|
11951
11961
|
@fragment
|
|
11952
|
-
fn fragmentMain() ->
|
|
11953
|
-
|
|
11962
|
+
fn fragmentMain() -> FragmentOutput {
|
|
11963
|
+
let color = ubMesh.color;
|
|
11964
|
+
return FragmentOutput(color, color, color, color, color, color, color, color);
|
|
11954
11965
|
}
|
|
11955
11966
|
`;
|
|
11956
11967
|
|
|
@@ -41141,10 +41152,10 @@ class GSplatSogIterator {
|
|
|
41141
41152
|
const { means, scales, sh0, shN } = meta;
|
|
41142
41153
|
const v3 = meta.version === 3;
|
|
41143
41154
|
const codebooks = meta.version >= 2;
|
|
41144
|
-
const means_l_data =
|
|
41145
|
-
const means_u_data =
|
|
41146
|
-
const quats_data = r &&
|
|
41147
|
-
const scales_data =
|
|
41155
|
+
const means_l_data = p && data.means_l._levels[0];
|
|
41156
|
+
const means_u_data = p && data.means_u._levels[0];
|
|
41157
|
+
const quats_data = r && data.quats._levels[0];
|
|
41158
|
+
const scales_data = s && data.scales._levels[0];
|
|
41148
41159
|
const sh0_data = c && data.sh0._levels[0];
|
|
41149
41160
|
const sh_labels_data = sh && data.sh_labels._levels[0];
|
|
41150
41161
|
const sh_centroids_data = sh && data.sh_centroids._levels[0];
|
|
@@ -41161,9 +41172,9 @@ class GSplatSogIterator {
|
|
|
41161
41172
|
p.z = Math.sign(nz) * (Math.exp(Math.abs(nz)) - 1);
|
|
41162
41173
|
}
|
|
41163
41174
|
if (r && v3) {
|
|
41164
|
-
const px = (
|
|
41165
|
-
const py = (
|
|
41166
|
-
const pz = (
|
|
41175
|
+
const px = (quats_data[i * 4 + 0] - 128) / 127;
|
|
41176
|
+
const py = (quats_data[i * 4 + 1] - 128) / 127;
|
|
41177
|
+
const pz = (quats_data[i * 4 + 2] - 128) / 127;
|
|
41167
41178
|
const len = Math.sqrt(px * px + py * py + pz * pz);
|
|
41168
41179
|
const t = len * Math.PI * 0.5;
|
|
41169
41180
|
const k = len > 1e-12 ? Math.sin(t) / len : Math.PI * 0.5;
|
|
@@ -41346,7 +41357,7 @@ class GSplatSogData {
|
|
|
41346
41357
|
const { means_l, means_u, quats, scales, sh0, sh_labels, sh_centroids } = this;
|
|
41347
41358
|
means_l._levels[0] = await readImageDataAsync(means_l);
|
|
41348
41359
|
means_u._levels[0] = await readImageDataAsync(means_u);
|
|
41349
|
-
|
|
41360
|
+
quats._levels[0] = await readImageDataAsync(quats);
|
|
41350
41361
|
scales._levels[0] = await readImageDataAsync(scales);
|
|
41351
41362
|
sh0._levels[0] = await readImageDataAsync(sh0);
|
|
41352
41363
|
if (shBands > 0) {
|
|
@@ -41613,16 +41624,13 @@ class GSplatSogResource extends GSplatResourceBase {
|
|
|
41613
41624
|
super(device, gsplatData, options);
|
|
41614
41625
|
const { meta, means_l } = gsplatData;
|
|
41615
41626
|
const isV2 = meta.version >= 2;
|
|
41616
|
-
const isV3 = meta.version === 3;
|
|
41617
41627
|
const hasSH = gsplatData.shBands > 0;
|
|
41618
41628
|
if (means_l) {
|
|
41619
41629
|
this.streams.textureDimensions.set(means_l.width, means_l.height);
|
|
41620
41630
|
}
|
|
41621
41631
|
this.streams.textures.set("means_l", gsplatData.means_l);
|
|
41622
41632
|
this.streams.textures.set("means_u", gsplatData.means_u);
|
|
41623
|
-
|
|
41624
|
-
this.streams.textures.set("quats", gsplatData.quats);
|
|
41625
|
-
}
|
|
41633
|
+
this.streams.textures.set("quats", gsplatData.quats);
|
|
41626
41634
|
this.streams.textures.set("scales", gsplatData.scales);
|
|
41627
41635
|
this.streams.textures.set("sh0", gsplatData.sh0);
|
|
41628
41636
|
if (hasSH) {
|
|
@@ -41638,7 +41646,7 @@ class GSplatSogResource extends GSplatResourceBase {
|
|
|
41638
41646
|
const streams = [
|
|
41639
41647
|
{ name: "means_l", format: PIXELFORMAT_RGBA8 },
|
|
41640
41648
|
{ name: "means_u", format: PIXELFORMAT_RGBA8 },
|
|
41641
|
-
|
|
41649
|
+
{ name: "quats", format: PIXELFORMAT_RGBA8 },
|
|
41642
41650
|
{ name: "scales", format: PIXELFORMAT_RGBA8 },
|
|
41643
41651
|
{ name: "sh0", format: PIXELFORMAT_RGBA8 }
|
|
41644
41652
|
];
|
|
@@ -70917,11 +70925,7 @@ vec3 getCenter() {
|
|
|
70917
70925
|
}
|
|
70918
70926
|
#if SOG_VERSION >= 3
|
|
70919
70927
|
vec4 getRotation() {
|
|
70920
|
-
vec3 b = floor(
|
|
70921
|
-
texelFetch(means_l, splat.uv, 0).w,
|
|
70922
|
-
texelFetch(means_u, splat.uv, 0).w,
|
|
70923
|
-
texelFetch(scales, splat.uv, 0).w
|
|
70924
|
-
) * 255.0 + 0.5);
|
|
70928
|
+
vec3 b = floor(texelFetch(quats, splat.uv, 0).xyz * 255.0 + 0.5);
|
|
70925
70929
|
vec3 p = (b - 128.0) / 127.0;
|
|
70926
70930
|
float len = length(p);
|
|
70927
70931
|
float t = len * 1.5707963267948966;
|
|
@@ -72225,11 +72229,7 @@ fn getCenter() -> vec3f {
|
|
|
72225
72229
|
}
|
|
72226
72230
|
#if SOG_VERSION >= 3
|
|
72227
72231
|
fn getRotation() -> vec4f {
|
|
72228
|
-
let b = floor(
|
|
72229
|
-
textureLoad(means_l, splat.uv, 0).w,
|
|
72230
|
-
textureLoad(means_u, splat.uv, 0).w,
|
|
72231
|
-
textureLoad(scales, splat.uv, 0).w
|
|
72232
|
-
) * 255.0 + 0.5);
|
|
72232
|
+
let b = floor(textureLoad(quats, splat.uv, 0).xyz * 255.0 + 0.5);
|
|
72233
72233
|
let p = (b - 128.0) / 127.0;
|
|
72234
72234
|
let len = length(p);
|
|
72235
72235
|
let t = len * 1.5707963267948966;
|
|
@@ -76977,7 +76977,7 @@ class SogBundleParser {
|
|
|
76977
76977
|
data.numSplats = meta.count;
|
|
76978
76978
|
data.means_l = textures[meta.means.files[0]].resource;
|
|
76979
76979
|
data.means_u = textures[meta.means.files[1]].resource;
|
|
76980
|
-
data.quats =
|
|
76980
|
+
data.quats = textures[meta.quats.files[0]].resource;
|
|
76981
76981
|
data.scales = textures[meta.scales.files[0]].resource;
|
|
76982
76982
|
data.sh0 = textures[meta.sh0.files[0]].resource;
|
|
76983
76983
|
data.sh_centroids = textures[meta.shN?.files[0]]?.resource;
|
|
@@ -77170,7 +77170,7 @@ class SogParser {
|
|
|
77170
77170
|
data.numSplats = meta.count;
|
|
77171
77171
|
data.means_l = textures.means[0].resource;
|
|
77172
77172
|
data.means_u = textures.means[1].resource;
|
|
77173
|
-
data.quats = textures.quats[0]
|
|
77173
|
+
data.quats = textures.quats[0].resource;
|
|
77174
77174
|
data.scales = textures.scales[0].resource;
|
|
77175
77175
|
data.sh0 = textures.sh0[0].resource;
|
|
77176
77176
|
data.sh_centroids = textures.shN?.[0]?.resource;
|
|
@@ -95968,11 +95968,10 @@ class DirectSplatSource {
|
|
|
95968
95968
|
device.computeDispatch([compute], 'sse-splat-decode-sh');
|
|
95969
95969
|
this.decodedSH.set(resource, { texture, compute });
|
|
95970
95970
|
}
|
|
95971
|
-
// the packed layout applies to sog v2 files, the only ones the repack reads.
|
|
95972
|
-
//
|
|
95971
|
+
// the packed layout applies to sog v2 files, the only ones the repack reads. Sog v3 files have
|
|
95972
|
+
// the same textures, but a different rotation and opacity encoding and 24-bit sh labels
|
|
95973
95973
|
packedActive() {
|
|
95974
|
-
|
|
95975
|
-
return !!textures && textures.has('sogCodebook') && textures.has('quats');
|
|
95974
|
+
return this.resource?.gsplatData?.meta?.version === 2;
|
|
95976
95975
|
}
|
|
95977
95976
|
hasSH() {
|
|
95978
95977
|
const textures = this.resource?.streams.textures;
|
|
@@ -99157,7 +99156,7 @@ deepFreeze({
|
|
|
99157
99156
|
});
|
|
99158
99157
|
/** Size limits for annotations. Intentionally tight for now. */
|
|
99159
99158
|
deepFreeze({
|
|
99160
|
-
maxCount:
|
|
99159
|
+
maxCount: 50,
|
|
99161
99160
|
titleMax: 60,
|
|
99162
99161
|
textMax: 280
|
|
99163
99162
|
});
|
|
@@ -99268,7 +99267,7 @@ const importSettings = (settings) => {
|
|
|
99268
99267
|
return result;
|
|
99269
99268
|
};
|
|
99270
99269
|
|
|
99271
|
-
var version = "1.43.
|
|
99270
|
+
var version = "1.43.3";
|
|
99272
99271
|
|
|
99273
99272
|
class Tooltip {
|
|
99274
99273
|
register;
|
|
@@ -102784,6 +102783,18 @@ class TeleportTarget {
|
|
|
102784
102783
|
}
|
|
102785
102784
|
}
|
|
102786
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
|
+
|
|
102787
102798
|
// The menu's rows, a column centred on its anchor (meters, at real size), each ROW_HEIGHT tall and
|
|
102788
102799
|
// drawn at PIXELS per meter: a hand's length across, read from about 40 cm
|
|
102789
102800
|
const ROW_WIDTH = 0.12;
|
|
@@ -103016,7 +103027,7 @@ class XrPalmMenu {
|
|
|
103016
103027
|
* @returns Whether it points at the open menu.
|
|
103017
103028
|
*/
|
|
103018
103029
|
pointsAt(source) {
|
|
103019
|
-
return this.open && !source
|
|
103030
|
+
return this.open && !isHand(source) && !!this.pointedAt(source);
|
|
103020
103031
|
}
|
|
103021
103032
|
/**
|
|
103022
103033
|
* Takes a select that starts on a row of the open menu, pressing it. A hand's select is left
|
|
@@ -103026,7 +103037,7 @@ class XrPalmMenu {
|
|
|
103026
103037
|
* @returns True when the menu took the select.
|
|
103027
103038
|
*/
|
|
103028
103039
|
select(source) {
|
|
103029
|
-
if (!this.open || source
|
|
103040
|
+
if (!this.open || isHand(source))
|
|
103030
103041
|
return false;
|
|
103031
103042
|
const quad = this.pointedAt(source);
|
|
103032
103043
|
if (!quad)
|
|
@@ -103229,7 +103240,7 @@ class XrPalmMenu {
|
|
|
103229
103240
|
// the left hand or controller when it is in use, else the other: a hand that has lost tracking
|
|
103230
103241
|
// stays an input source, and would keep the menu closed on the other
|
|
103231
103242
|
preferred() {
|
|
103232
|
-
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));
|
|
103233
103244
|
return usable.find((source) => source.handedness === 'left') ?? usable[0] ?? null;
|
|
103234
103245
|
}
|
|
103235
103246
|
// opens the menu on an open palm facing the eyes, or on a controller's toggle button
|
|
@@ -103242,7 +103253,7 @@ class XrPalmMenu {
|
|
|
103242
103253
|
}
|
|
103243
103254
|
if (!source)
|
|
103244
103255
|
return;
|
|
103245
|
-
if (source
|
|
103256
|
+
if (isHand(source)) {
|
|
103246
103257
|
this.setOpen(this.palmFacing(source));
|
|
103247
103258
|
return;
|
|
103248
103259
|
}
|
|
@@ -103289,7 +103300,7 @@ class XrPalmMenu {
|
|
|
103289
103300
|
anchorPose(source) {
|
|
103290
103301
|
const scale = this.scale;
|
|
103291
103302
|
const hand = source.hand;
|
|
103292
|
-
if (
|
|
103303
|
+
if (isHand(source)) {
|
|
103293
103304
|
const knuckle = hand.getJointById('middle-finger-metacarpal');
|
|
103294
103305
|
const proximal = hand.getJointById('middle-finger-phalanx-proximal');
|
|
103295
103306
|
if (!knuckle || !proximal || !this.palmNormal(source))
|
|
@@ -103327,7 +103338,7 @@ class XrPalmMenu {
|
|
|
103327
103338
|
}
|
|
103328
103339
|
// whether a source's ray points at the menu: a controller's
|
|
103329
103340
|
pointing(source) {
|
|
103330
|
-
return source.targetRayMode === 'tracked-pointer' && !source
|
|
103341
|
+
return source.targetRayMode === 'tracked-pointer' && !isHand(source);
|
|
103331
103342
|
}
|
|
103332
103343
|
// controllers' rays, and the other hand's fingertip, highlight the row they are on; the
|
|
103333
103344
|
// fingertip presses it
|
|
@@ -103344,7 +103355,7 @@ class XrPalmMenu {
|
|
|
103344
103355
|
side = this.sideOf(quad);
|
|
103345
103356
|
}
|
|
103346
103357
|
}
|
|
103347
|
-
if (!hovered && this.anchor
|
|
103358
|
+
if (!hovered && this.anchor && isHand(this.anchor)) {
|
|
103348
103359
|
const poked = this.poke(this.anchor);
|
|
103349
103360
|
if (poked) {
|
|
103350
103361
|
hovered = poked;
|
|
@@ -103369,7 +103380,7 @@ class XrPalmMenu {
|
|
|
103369
103380
|
}
|
|
103370
103381
|
// the row the other hand's index fingertip is on, pressing it once it reaches it
|
|
103371
103382
|
poke(anchor) {
|
|
103372
|
-
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);
|
|
103373
103384
|
const tip = poking?.hand.getJointById('index-finger-tip');
|
|
103374
103385
|
if (!poking || !tip) {
|
|
103375
103386
|
this.pokeReady = true;
|
|
@@ -104332,7 +104343,7 @@ class XrArPlacement {
|
|
|
104332
104343
|
placingInput() {
|
|
104333
104344
|
if (this.pointers.size === 0)
|
|
104334
104345
|
return 'screen';
|
|
104335
|
-
return [...this.pointers.keys()].some((source) => !source
|
|
104346
|
+
return [...this.pointers.keys()].some((source) => !isHand(source)) ? 'controller' : 'hand';
|
|
104336
104347
|
}
|
|
104337
104348
|
// low in the middle of the screen, a share of its width across: a point of the view's
|
|
104338
104349
|
// projection at HINT_SCREEN_AHEAD, square to the camera
|
|
@@ -104386,6 +104397,78 @@ class XrArPlacement {
|
|
|
104386
104397
|
}
|
|
104387
104398
|
}
|
|
104388
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
|
+
|
|
104389
104472
|
/**
|
|
104390
104473
|
* Clears each eye's depth texture of a WebGPU XR session to the far plane every frame, ahead of the
|
|
104391
104474
|
* engine's frame.
|
|
@@ -105279,15 +105362,15 @@ const overshoot = (x) => {
|
|
|
105279
105362
|
return 1 + (c + 1) * y * y * y + c * y * y;
|
|
105280
105363
|
};
|
|
105281
105364
|
// a side's tracked hand, or else its controller
|
|
105282
|
-
const sourceOf = (sources, handedness) => sources.find((source) => source
|
|
105283
|
-
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) ??
|
|
105284
105367
|
null;
|
|
105285
105368
|
// where a right hand or controller is for the cover test, the resize and the turn: the hand's
|
|
105286
105369
|
// COVER_JOINT, or the controller's grip; null where a hand is not tracked
|
|
105287
105370
|
const pointOf = (source) => {
|
|
105288
105371
|
if (!source)
|
|
105289
105372
|
return null;
|
|
105290
|
-
if (!source
|
|
105373
|
+
if (!isHand(source))
|
|
105291
105374
|
return source.getPosition();
|
|
105292
105375
|
return source.hand.tracking ? (source.hand.getJointById(COVER_JOINT)?.getPosition() ?? null) : null;
|
|
105293
105376
|
};
|
|
@@ -105496,7 +105579,7 @@ class XrIceCream {
|
|
|
105496
105579
|
const sources = xr.input.inputSources;
|
|
105497
105580
|
const left = sourceOf(sources, 'left');
|
|
105498
105581
|
const tracked = !!left &&
|
|
105499
|
-
(left
|
|
105582
|
+
(isHand(left)
|
|
105500
105583
|
? left.hand.tracking && measureFist(left.hand, this.handPosition, this.handRotation)
|
|
105501
105584
|
: measureGrip(left, this.handPosition, this.handRotation, this.userScale()));
|
|
105502
105585
|
if (tracked) {
|
|
@@ -105512,7 +105595,7 @@ class XrIceCream {
|
|
|
105512
105595
|
// a hand out of sight, or covered, is neither open nor closed: losing it counts by LOST_TIME
|
|
105513
105596
|
if (tracked && left && !covered) {
|
|
105514
105597
|
const wasFist = this.openFor < FLICKER_TIME;
|
|
105515
|
-
const closed = left.squeezing || (wasFist &&
|
|
105598
|
+
const closed = left.squeezing || (wasFist && isHand(left) && foldedFingers(left.hand) >= HELD_FINGERS);
|
|
105516
105599
|
this.openFor = closed ? 0 : this.openFor + dt;
|
|
105517
105600
|
}
|
|
105518
105601
|
const fist = this.openFor < FLICKER_TIME;
|
|
@@ -106517,6 +106600,8 @@ const initXr = (global) => {
|
|
|
106517
106600
|
parent.addComponent('script');
|
|
106518
106601
|
// its models by input source (the script's own typing is Script)
|
|
106519
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);
|
|
106520
106605
|
// the members of the navigation the viewer uses (the script's own typing is Script)
|
|
106521
106606
|
const navigation = parent.script.create(XrNavigation);
|
|
106522
106607
|
replaceTeleportArc(navigation);
|
|
@@ -106542,7 +106627,7 @@ const initXr = (global) => {
|
|
|
106542
106627
|
const handStyle = new XrHandStyle();
|
|
106543
106628
|
const modelAdded = app.on('xr:controller:add', (source, entity) => {
|
|
106544
106629
|
scaleModel(entity);
|
|
106545
|
-
if (source
|
|
106630
|
+
if (isHand(source)) {
|
|
106546
106631
|
handStyle.apply(entity);
|
|
106547
106632
|
if (xr.type === 'immersive-ar')
|
|
106548
106633
|
entity.enabled = false;
|
|
@@ -107015,7 +107100,7 @@ const initXr = (global) => {
|
|
|
107015
107100
|
]);
|
|
107016
107101
|
// and, while the splat is held, takes the rest: the world to teleport in is in the hand
|
|
107017
107102
|
const isSystemSelect = navigation._isSystemSelect.bind(navigation);
|
|
107018
|
-
navigation._isSystemSelect = (source) => isSystemSelect(source) || menu.select(source) || !!iceCream?.holding;
|
|
107103
|
+
navigation._isSystemSelect = (source) => withoutControllerHand(source, () => isSystemSelect(source)) || menu.select(source) || !!iceCream?.holding;
|
|
107019
107104
|
const cancel = events.on('inputEvent', (event) => {
|
|
107020
107105
|
if (event === 'cancel' && xr.active) {
|
|
107021
107106
|
void end().catch(() => {
|
|
@@ -107079,6 +107164,7 @@ const initXr = (global) => {
|
|
|
107079
107164
|
cancel.off();
|
|
107080
107165
|
updating.off();
|
|
107081
107166
|
modelAdded.off();
|
|
107167
|
+
controllerHandPatch.off();
|
|
107082
107168
|
handStyle.destroy();
|
|
107083
107169
|
forgetReferenceSpace();
|
|
107084
107170
|
menu.destroy();
|