@playcanvas/supersplat-viewer 1.8.2 → 1.8.4
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/package.json +6 -6
- package/public/index.js +74 -30
- 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.8.
|
|
3
|
+
"version": "1.8.4",
|
|
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",
|
|
@@ -41,20 +41,20 @@
|
|
|
41
41
|
"@playcanvas/web-components": "0.2.11",
|
|
42
42
|
"@rollup/plugin-node-resolve": "16.0.3",
|
|
43
43
|
"@rollup/plugin-typescript": "12.3.0",
|
|
44
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
45
|
-
"@typescript-eslint/parser": "8.
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "8.47.0",
|
|
45
|
+
"@typescript-eslint/parser": "8.47.0",
|
|
46
46
|
"autoprefixer": "10.4.22",
|
|
47
47
|
"concurrently": "9.2.1",
|
|
48
48
|
"eslint": "9.39.1",
|
|
49
49
|
"globals": "16.5.0",
|
|
50
|
-
"playcanvas": "2.13.
|
|
50
|
+
"playcanvas": "2.13.5",
|
|
51
51
|
"postcss": "8.5.6",
|
|
52
52
|
"publint": "0.3.15",
|
|
53
|
-
"rollup": "4.53.
|
|
53
|
+
"rollup": "4.53.3",
|
|
54
54
|
"rollup-plugin-copy": "3.5.0",
|
|
55
55
|
"rollup-plugin-scss": "4.0.1",
|
|
56
56
|
"rollup-plugin-string": "3.0.0",
|
|
57
|
-
"sass": "1.94.
|
|
57
|
+
"sass": "1.94.2",
|
|
58
58
|
"serve": "14.2.5",
|
|
59
59
|
"typescript": "5.9.3"
|
|
60
60
|
},
|
package/public/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const TRACEID_GPU_TIMINGS = 'GpuTimings';
|
|
2
2
|
|
|
3
|
-
const version = '2.13.
|
|
4
|
-
const revision = '
|
|
3
|
+
const version = '2.13.5';
|
|
4
|
+
const revision = '5aa2502';
|
|
5
5
|
function extend(target, ex) {
|
|
6
6
|
for(const prop in ex){
|
|
7
7
|
const copy = ex[prop];
|
|
@@ -3608,13 +3608,18 @@ class BoundingBox {
|
|
|
3608
3608
|
return this._max.copy(this.center).add(this.halfExtents);
|
|
3609
3609
|
}
|
|
3610
3610
|
containsPoint(point) {
|
|
3611
|
-
const
|
|
3612
|
-
const
|
|
3613
|
-
if (point.x <
|
|
3611
|
+
const c = this.center;
|
|
3612
|
+
const h = this.halfExtents;
|
|
3613
|
+
if (point.x < c.x - h.x || point.x > c.x + h.x || point.y < c.y - h.y || point.y > c.y + h.y || point.z < c.z - h.z || point.z > c.z + h.z) {
|
|
3614
3614
|
return false;
|
|
3615
3615
|
}
|
|
3616
3616
|
return true;
|
|
3617
3617
|
}
|
|
3618
|
+
closestPoint(point, result = new Vec3()) {
|
|
3619
|
+
const c = this.center;
|
|
3620
|
+
const h = this.halfExtents;
|
|
3621
|
+
return result.set(Math.max(c.x - h.x, Math.min(point.x, c.x + h.x)), Math.max(c.y - h.y, Math.min(point.y, c.y + h.y)), Math.max(c.z - h.z, Math.min(point.z, c.z + h.z)));
|
|
3622
|
+
}
|
|
3618
3623
|
setFromTransformedAabb(aabb, m, ignoreScale = false) {
|
|
3619
3624
|
const ac = aabb.center;
|
|
3620
3625
|
const ar = aabb.halfExtents;
|
|
@@ -13168,10 +13173,12 @@ class WebglUploadStream {
|
|
|
13168
13173
|
gl.bufferSubData(gl.PIXEL_UNPACK_BUFFER, 0, new Uint8Array(data.buffer, data.byteOffset, byteSize));
|
|
13169
13174
|
gl.bindBuffer(gl.PIXEL_UNPACK_BUFFER, null);
|
|
13170
13175
|
device.setTexture(target, 0);
|
|
13176
|
+
device.activeTexture(0);
|
|
13177
|
+
device.bindTexture(target);
|
|
13171
13178
|
gl.bindBuffer(gl.PIXEL_UNPACK_BUFFER, pboInfo.pbo);
|
|
13172
13179
|
device.setUnpackFlipY(false);
|
|
13173
13180
|
device.setUnpackPremultiplyAlpha(false);
|
|
13174
|
-
gl.pixelStorei(gl.UNPACK_ALIGNMENT,
|
|
13181
|
+
gl.pixelStorei(gl.UNPACK_ALIGNMENT, data.BYTES_PER_ELEMENT);
|
|
13175
13182
|
gl.pixelStorei(gl.UNPACK_ROW_LENGTH, 0);
|
|
13176
13183
|
gl.pixelStorei(gl.UNPACK_SKIP_ROWS, 0);
|
|
13177
13184
|
gl.pixelStorei(gl.UNPACK_SKIP_PIXELS, 0);
|
|
@@ -33997,7 +34004,6 @@ var glslGsplatCopyToWorkBufferPS = `
|
|
|
33997
34004
|
#include "gsplatQuatToMat3VS"
|
|
33998
34005
|
#include "gsplatSourceFormatVS"
|
|
33999
34006
|
#include "packHalfPS"
|
|
34000
|
-
uniform mat4 uTransform;
|
|
34001
34007
|
uniform int uStartLine;
|
|
34002
34008
|
uniform int uViewportWidth;
|
|
34003
34009
|
#ifdef GSPLAT_LOD
|
|
@@ -34037,7 +34043,7 @@ void main(void) {
|
|
|
34037
34043
|
source.id = uint(originalIndex);
|
|
34038
34044
|
source.uv = ivec2(source.id % srcSize, source.id / srcSize);
|
|
34039
34045
|
vec3 modelCenter = readCenter(source);
|
|
34040
|
-
|
|
34046
|
+
vec3 worldCenter = (matrix_model * vec4(modelCenter, 1.0)).xyz;
|
|
34041
34047
|
SplatCenter center;
|
|
34042
34048
|
initCenter(modelCenter, center);
|
|
34043
34049
|
vec3 covA, covB;
|
|
@@ -34047,7 +34053,7 @@ void main(void) {
|
|
|
34047
34053
|
covA.y, covB.x, covB.y,
|
|
34048
34054
|
covA.z, covB.y, covB.z
|
|
34049
34055
|
);
|
|
34050
|
-
mat3 linear = mat3(
|
|
34056
|
+
mat3 linear = mat3(matrix_model);
|
|
34051
34057
|
mat3 Ct = linear * C * transpose(linear);
|
|
34052
34058
|
covA = Ct[0];
|
|
34053
34059
|
covB = vec3(Ct[1][1], Ct[1][2], Ct[2][2]);
|
|
@@ -34073,7 +34079,7 @@ void main(void) {
|
|
|
34073
34079
|
pcFragColor0 = color;
|
|
34074
34080
|
#endif
|
|
34075
34081
|
#ifndef GSPLAT_COLOR_ONLY
|
|
34076
|
-
pcFragColor1 = uvec4(floatBitsToUint(
|
|
34082
|
+
pcFragColor1 = uvec4(floatBitsToUint(worldCenter.x), floatBitsToUint(worldCenter.y), floatBitsToUint(worldCenter.z), packHalf2x16Safe(vec2(covA.z, covB.z)));
|
|
34077
34083
|
pcFragColor2 = uvec2(packHalf2x16Safe(covA.xy), packHalf2x16Safe(covB.xy));
|
|
34078
34084
|
#endif
|
|
34079
34085
|
}
|
|
@@ -34088,7 +34094,6 @@ var wgslGsplatCopyToWorkBufferPS = `
|
|
|
34088
34094
|
#include "gsplatQuatToMat3VS"
|
|
34089
34095
|
#include "gsplatSourceFormatVS"
|
|
34090
34096
|
#include "packHalfPS"
|
|
34091
|
-
uniform uTransform: mat4x4f;
|
|
34092
34097
|
uniform uStartLine: i32;
|
|
34093
34098
|
uniform uViewportWidth: i32;
|
|
34094
34099
|
#ifdef GSPLAT_LOD
|
|
@@ -34129,7 +34134,7 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
|
|
|
34129
34134
|
source.id = u32(originalIndex);
|
|
34130
34135
|
source.uv = vec2i(i32(source.id % srcSize), i32(source.id / srcSize));
|
|
34131
34136
|
var modelCenter = readCenter(&source);
|
|
34132
|
-
|
|
34137
|
+
let worldCenter = (uniform.matrix_model * vec4f(modelCenter, 1.0)).xyz;
|
|
34133
34138
|
var center: SplatCenter;
|
|
34134
34139
|
initCenter(modelCenter, ¢er);
|
|
34135
34140
|
var covA: vec3f;
|
|
@@ -34140,7 +34145,7 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
|
|
|
34140
34145
|
vec3f(covA.y, covB.x, covB.y),
|
|
34141
34146
|
vec3f(covA.z, covB.y, covB.z)
|
|
34142
34147
|
);
|
|
34143
|
-
let linear = mat3x3f(uniform.
|
|
34148
|
+
let linear = mat3x3f(uniform.matrix_model[0].xyz, uniform.matrix_model[1].xyz, uniform.matrix_model[2].xyz);
|
|
34144
34149
|
let Ct = linear * C * transpose(linear);
|
|
34145
34150
|
covA = Ct[0];
|
|
34146
34151
|
covB = vec3f(Ct[1][1], Ct[1][2], Ct[2][2]);
|
|
@@ -34155,7 +34160,7 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
|
|
|
34155
34160
|
color = vec4f(color.xyz * uniform.uColorMultiply, color.w);
|
|
34156
34161
|
output.color = color;
|
|
34157
34162
|
#ifndef GSPLAT_COLOR_ONLY
|
|
34158
|
-
output.color1 = vec4u(bitcast<u32>(
|
|
34163
|
+
output.color1 = vec4u(bitcast<u32>(worldCenter.x), bitcast<u32>(worldCenter.y), bitcast<u32>(worldCenter.z), pack2x16floatSafe(vec2f(covA.z, covB.z)));
|
|
34159
34164
|
output.color2 = vec2u(pack2x16floatSafe(covA.xy), pack2x16floatSafe(covB.xy));
|
|
34160
34165
|
#endif
|
|
34161
34166
|
}
|
|
@@ -34212,7 +34217,6 @@ class GSplatWorkBufferRenderPass extends RenderPass {
|
|
|
34212
34217
|
const { intervals, activeSplats, lineStart, viewport, intervalTexture } = splatInfo;
|
|
34213
34218
|
const workBufferRenderInfo = resource.getWorkBufferRenderInfo(intervals.length > 0, this.workBuffer.colorTextureFormat, this.colorOnly);
|
|
34214
34219
|
workBufferRenderInfo.material.setParameters(device);
|
|
34215
|
-
scope.resolve('uTransform').setValue(splatInfo.node.getWorldTransform().data);
|
|
34216
34220
|
if (intervalTexture) {
|
|
34217
34221
|
scope.resolve('uIntervalsTexture').setValue(intervalTexture.texture);
|
|
34218
34222
|
}
|
|
@@ -76258,7 +76262,8 @@ class GSplatOctreeInstance {
|
|
|
76258
76262
|
}
|
|
76259
76263
|
calculateNodeLod(localCameraPosition, localCameraForward, nodeIndex, maxLod, lodDistances, lodBehindPenalty) {
|
|
76260
76264
|
const node = this.octree.nodes[nodeIndex];
|
|
76261
|
-
|
|
76265
|
+
node.bounds.closestPoint(localCameraPosition, _dirToNode);
|
|
76266
|
+
_dirToNode.sub(localCameraPosition);
|
|
76262
76267
|
let distance = _dirToNode.length();
|
|
76263
76268
|
if (lodBehindPenalty > 1 && distance > 0.01) {
|
|
76264
76269
|
const dotOverDistance = localCameraForward.dot(_dirToNode) / distance;
|
|
@@ -77085,6 +77090,7 @@ class GSplatManager {
|
|
|
77085
77090
|
}
|
|
77086
77091
|
update() {
|
|
77087
77092
|
this.sorter.applyPendingSorted();
|
|
77093
|
+
this.renderer.updateViewport(this.cameraNode);
|
|
77088
77094
|
let fullUpdate = false;
|
|
77089
77095
|
this.framesTillFullUpdate--;
|
|
77090
77096
|
if (this.framesTillFullUpdate <= 0) {
|
|
@@ -77224,7 +77230,6 @@ class GSplatManager {
|
|
|
77224
77230
|
});
|
|
77225
77231
|
});
|
|
77226
77232
|
this.sorter.setSortParams(sorterRequest, this.scene.gsplat.radialSorting);
|
|
77227
|
-
this.renderer.updateViewport(cameraNode);
|
|
77228
77233
|
}
|
|
77229
77234
|
prepareSortParameters(worldState) {
|
|
77230
77235
|
return {
|
|
@@ -101190,8 +101195,16 @@ class Picker {
|
|
|
101190
101195
|
}
|
|
101191
101196
|
}
|
|
101192
101197
|
|
|
101198
|
+
/* Vec initialisation to avoid recurrent memory allocation */
|
|
101193
101199
|
const tmpV1 = new Vec3();
|
|
101194
101200
|
const tmpV2 = new Vec3();
|
|
101201
|
+
const mouseRotate = new Vec3();
|
|
101202
|
+
const flyMove = new Vec3();
|
|
101203
|
+
const pinchMove = new Vec3();
|
|
101204
|
+
const orbitRotate = new Vec3();
|
|
101205
|
+
const flyRotate = new Vec3();
|
|
101206
|
+
const stickMove = new Vec3();
|
|
101207
|
+
const stickRotate = new Vec3();
|
|
101195
101208
|
/**
|
|
101196
101209
|
* Converts screen space mouse deltas to world space pan vector.
|
|
101197
101210
|
*
|
|
@@ -101377,33 +101390,33 @@ class InputController {
|
|
|
101377
101390
|
deltas.move.append([v.x, v.y, orbit ? -v.z : v.z]);
|
|
101378
101391
|
// desktop rotate
|
|
101379
101392
|
v.set(0, 0, 0);
|
|
101380
|
-
|
|
101393
|
+
mouseRotate.set(mouse[0], mouse[1], 0);
|
|
101381
101394
|
v.add(mouseRotate.mulScalar((1 - pan) * this.orbitSpeed * orbitFactor * dt));
|
|
101382
101395
|
deltas.rotate.append([v.x, v.y, v.z]);
|
|
101383
101396
|
// mobile move
|
|
101384
101397
|
v.set(0, 0, 0);
|
|
101385
101398
|
const orbitMove = screenToWorld(camera, touch[0], touch[1], distance);
|
|
101386
101399
|
v.add(orbitMove.mulScalar(orbit * pan));
|
|
101387
|
-
|
|
101400
|
+
flyMove.set(leftInput[0], 0, -leftInput[1]);
|
|
101388
101401
|
v.add(flyMove.mulScalar(fly * this.moveSpeed * dt));
|
|
101389
|
-
|
|
101402
|
+
pinchMove.set(0, 0, pinch[0]);
|
|
101390
101403
|
v.add(pinchMove.mulScalar(orbit * double * this.pinchSpeed * dt));
|
|
101391
101404
|
deltas.move.append([v.x, v.y, v.z]);
|
|
101392
101405
|
// mobile rotate
|
|
101393
101406
|
v.set(0, 0, 0);
|
|
101394
|
-
|
|
101407
|
+
orbitRotate.set(touch[0], touch[1], 0);
|
|
101395
101408
|
v.add(orbitRotate.mulScalar(orbit * (1 - pan) * this.orbitSpeed * dt));
|
|
101396
|
-
|
|
101409
|
+
flyRotate.set(rightInput[0], rightInput[1], 0);
|
|
101397
101410
|
v.add(flyRotate.mulScalar(fly * this.orbitSpeed * orbitFactor * dt));
|
|
101398
101411
|
deltas.rotate.append([v.x, v.y, v.z]);
|
|
101399
101412
|
// gamepad move
|
|
101400
101413
|
v.set(0, 0, 0);
|
|
101401
|
-
|
|
101414
|
+
stickMove.set(leftStick[0], 0, -leftStick[1]);
|
|
101402
101415
|
v.add(stickMove.mulScalar(this.moveSpeed * dt));
|
|
101403
101416
|
deltas.move.append([v.x, v.y, v.z]);
|
|
101404
101417
|
// gamepad rotate
|
|
101405
101418
|
v.set(0, 0, 0);
|
|
101406
|
-
|
|
101419
|
+
stickRotate.set(rightStick[0], rightStick[1], 0);
|
|
101407
101420
|
v.add(stickRotate.mulScalar(this.orbitSpeed * orbitFactor * dt));
|
|
101408
101421
|
deltas.rotate.append([v.x, v.y, v.z]);
|
|
101409
101422
|
// update touch joystick UI
|
|
@@ -101505,6 +101518,7 @@ class Viewer {
|
|
|
101505
101518
|
inputController;
|
|
101506
101519
|
cameraManager;
|
|
101507
101520
|
annotations;
|
|
101521
|
+
forceRenderNextFrame = false;
|
|
101508
101522
|
constructor(global, gsplatLoad, skyboxLoad) {
|
|
101509
101523
|
this.global = global;
|
|
101510
101524
|
const { app, settings, config, events, state, camera } = global;
|
|
@@ -101575,6 +101589,9 @@ class Viewer {
|
|
|
101575
101589
|
if (!state.readyToRender) {
|
|
101576
101590
|
app.renderNextFrame = false;
|
|
101577
101591
|
}
|
|
101592
|
+
if (this.forceRenderNextFrame) {
|
|
101593
|
+
app.renderNextFrame = true;
|
|
101594
|
+
}
|
|
101578
101595
|
if (app.renderNextFrame) {
|
|
101579
101596
|
prevWorld.copy(world);
|
|
101580
101597
|
prevProj.copy(proj);
|
|
@@ -101618,7 +101635,9 @@ class Viewer {
|
|
|
101618
101635
|
if (gsplatBbox) {
|
|
101619
101636
|
sceneBound.setFromTransformedAabb(gsplatBbox, results[0].getWorldTransform());
|
|
101620
101637
|
}
|
|
101621
|
-
|
|
101638
|
+
if (!config.noui) {
|
|
101639
|
+
this.annotations = new Annotations(global, this.cameraFrame != null);
|
|
101640
|
+
}
|
|
101622
101641
|
this.inputController = new InputController(global);
|
|
101623
101642
|
this.cameraManager = new CameraManager(global, sceneBound);
|
|
101624
101643
|
applyCamera(this.cameraManager.camera);
|
|
@@ -101643,11 +101662,36 @@ class Viewer {
|
|
|
101643
101662
|
});
|
|
101644
101663
|
}
|
|
101645
101664
|
else {
|
|
101646
|
-
//
|
|
101647
|
-
|
|
101648
|
-
|
|
101649
|
-
|
|
101650
|
-
|
|
101665
|
+
// in unified mode, for now we hard-code LOD range on mobile vs desktop
|
|
101666
|
+
const range = platform.mobile ? [2, 5] : [0, 2];
|
|
101667
|
+
const { gsplat } = app.scene;
|
|
101668
|
+
gsplat.lodRangeMin = range[0];
|
|
101669
|
+
gsplat.lodRangeMax = range[1];
|
|
101670
|
+
// FIXME: remove ignore when gsplat system is documented
|
|
101671
|
+
// @ts-ignore
|
|
101672
|
+
const eventHandler = app.systems.gsplat;
|
|
101673
|
+
// force render empty frames otherwise unified rendering doesn't update
|
|
101674
|
+
this.forceRenderNextFrame = true;
|
|
101675
|
+
const readyHandler = (camera, layer, ready, loading) => {
|
|
101676
|
+
if (ready && !loading) {
|
|
101677
|
+
eventHandler.off('frame:ready', readyHandler);
|
|
101678
|
+
this.forceRenderNextFrame = false;
|
|
101679
|
+
state.readyToRender = true;
|
|
101680
|
+
// wait for the first valid frame to complete rendering
|
|
101681
|
+
app.once('frameend', () => {
|
|
101682
|
+
events.fire('firstFrame');
|
|
101683
|
+
// emit first frame event on window
|
|
101684
|
+
window.firstFrame?.();
|
|
101685
|
+
});
|
|
101686
|
+
}
|
|
101687
|
+
};
|
|
101688
|
+
eventHandler.on('frame:ready', readyHandler);
|
|
101689
|
+
// render when ready is set
|
|
101690
|
+
eventHandler.on('frame:ready', (camera, layer, ready, loading) => {
|
|
101691
|
+
if (ready) {
|
|
101692
|
+
app.renderNextFrame = true;
|
|
101693
|
+
}
|
|
101694
|
+
});
|
|
101651
101695
|
}
|
|
101652
101696
|
});
|
|
101653
101697
|
}
|