@playcanvas/supersplat-viewer 1.4.0 → 1.5.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.
- package/dist/index.js +1 -1
- package/package.json +6 -6
- package/public/index.js +66 -39
- 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.
|
|
3
|
+
"version": "1.5.0",
|
|
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,14 +41,14 @@
|
|
|
41
41
|
"@playcanvas/web-components": "^0.2.10",
|
|
42
42
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
43
43
|
"@rollup/plugin-typescript": "^12.1.4",
|
|
44
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
45
|
-
"@typescript-eslint/parser": "^8.
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "^8.44.0",
|
|
45
|
+
"@typescript-eslint/parser": "^8.44.0",
|
|
46
46
|
"concurrently": "^9.2.1",
|
|
47
47
|
"eslint": "^9.35.0",
|
|
48
|
-
"globals": "^16.
|
|
49
|
-
"playcanvas": "^2.11.
|
|
48
|
+
"globals": "^16.4.0",
|
|
49
|
+
"playcanvas": "^2.11.8",
|
|
50
50
|
"publint": "^0.3.12",
|
|
51
|
-
"rollup": "^4.50.
|
|
51
|
+
"rollup": "^4.50.2",
|
|
52
52
|
"rollup-plugin-copy": "^3.5.0",
|
|
53
53
|
"rollup-plugin-string": "^3.0.0",
|
|
54
54
|
"serve": "^14.2.5",
|
package/public/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const TRACEID_GPU_TIMINGS = 'GpuTimings';
|
|
2
2
|
|
|
3
|
-
const version = '2.11.
|
|
4
|
-
const revision = '
|
|
3
|
+
const version = '2.11.8';
|
|
4
|
+
const revision = 'd712e1a';
|
|
5
5
|
function extend(target, ex) {
|
|
6
6
|
for(const prop in ex){
|
|
7
7
|
const copy = ex[prop];
|
|
@@ -3277,6 +3277,12 @@ class Quat {
|
|
|
3277
3277
|
let m20 = d[8];
|
|
3278
3278
|
let m21 = d[9];
|
|
3279
3279
|
let m22 = d[10];
|
|
3280
|
+
const det = m00 * (m11 * m22 - m12 * m21) - m01 * (m10 * m22 - m12 * m20) + m02 * (m10 * m21 - m11 * m20);
|
|
3281
|
+
if (det < 0) {
|
|
3282
|
+
m00 = -m00;
|
|
3283
|
+
m01 = -m01;
|
|
3284
|
+
m02 = -m02;
|
|
3285
|
+
}
|
|
3280
3286
|
let l;
|
|
3281
3287
|
l = m00 * m00 + m01 * m01 + m02 * m02;
|
|
3282
3288
|
if (l === 0) return this.set(0, 0, 0, 1);
|
|
@@ -34678,7 +34684,7 @@ const resolve = (scope, values)=>{
|
|
|
34678
34684
|
class GSplatSogsIterator {
|
|
34679
34685
|
constructor(data, p, r, s, c, sh){
|
|
34680
34686
|
const lerp = (a, b, t)=>a * (1 - t) + b * t;
|
|
34681
|
-
const { meta } = data;
|
|
34687
|
+
const { meta, shBands } = data;
|
|
34682
34688
|
const { means, scales, sh0, shN } = meta;
|
|
34683
34689
|
const means_l_data = p && data.means_l._levels[0];
|
|
34684
34690
|
const means_u_data = p && data.means_u._levels[0];
|
|
@@ -34688,6 +34694,11 @@ class GSplatSogsIterator {
|
|
|
34688
34694
|
const sh_labels_data = sh && data.sh_labels._levels[0];
|
|
34689
34695
|
const sh_centroids_data = sh && data.sh_centroids._levels[0];
|
|
34690
34696
|
const norm = 2.0 / Math.sqrt(2.0);
|
|
34697
|
+
const coeffs = {
|
|
34698
|
+
1: 3,
|
|
34699
|
+
2: 8,
|
|
34700
|
+
3: 15
|
|
34701
|
+
}[shBands] ?? 0;
|
|
34691
34702
|
this.read = (i)=>{
|
|
34692
34703
|
if (p) {
|
|
34693
34704
|
const nx = lerp(means.mins[0], means.maxs[0], ((means_u_data[i * 4 + 0] << 8) + means_l_data[i * 4 + 0]) / 65535);
|
|
@@ -34748,17 +34759,17 @@ class GSplatSogsIterator {
|
|
|
34748
34759
|
}
|
|
34749
34760
|
if (sh) {
|
|
34750
34761
|
const n = sh_labels_data[i * 4 + 0] + (sh_labels_data[i * 4 + 1] << 8);
|
|
34751
|
-
const u = n % 64 *
|
|
34762
|
+
const u = n % 64 * coeffs;
|
|
34752
34763
|
const v = Math.floor(n / 64);
|
|
34753
34764
|
if (meta.version === 2) {
|
|
34754
34765
|
for(let j = 0; j < 3; ++j){
|
|
34755
|
-
for(let k = 0; k <
|
|
34766
|
+
for(let k = 0; k < coeffs; ++k){
|
|
34756
34767
|
sh[j * 15 + k] = shN.codebook[sh_centroids_data[(u + k) * 4 + j + v * data.sh_centroids.width * 4]];
|
|
34757
34768
|
}
|
|
34758
34769
|
}
|
|
34759
34770
|
} else {
|
|
34760
34771
|
for(let j = 0; j < 3; ++j){
|
|
34761
|
-
for(let k = 0; k <
|
|
34772
|
+
for(let k = 0; k < coeffs; ++k){
|
|
34762
34773
|
sh[j * 15 + k] = lerp(shN.mins, shN.maxs, sh_centroids_data[(u + k) * 4 + j + v * data.sh_centroids.width * 4] / 255);
|
|
34763
34774
|
}
|
|
34764
34775
|
}
|
|
@@ -34819,7 +34830,9 @@ class GSplatSogsData {
|
|
|
34819
34830
|
}
|
|
34820
34831
|
}
|
|
34821
34832
|
calcFocalPoint(result, pred) {
|
|
34822
|
-
|
|
34833
|
+
const { mins, maxs } = this.meta.means;
|
|
34834
|
+
const map = (v)=>Math.sign(v) * (Math.exp(Math.abs(v)) - 1);
|
|
34835
|
+
result.set((map(mins[0]) + map(maxs[0])) * 0.5, (map(mins[1]) + map(maxs[1])) * 0.5, (map(mins[2]) + map(maxs[2])) * 0.5);
|
|
34823
34836
|
}
|
|
34824
34837
|
get isSogs() {
|
|
34825
34838
|
return true;
|
|
@@ -82171,7 +82184,7 @@ class SogBundleParser {
|
|
|
82171
82184
|
let texture;
|
|
82172
82185
|
if (file) {
|
|
82173
82186
|
texture = new Asset(filename, 'texture', {
|
|
82174
|
-
url: filename
|
|
82187
|
+
url: `${url.load}/${filename}`,
|
|
82175
82188
|
filename,
|
|
82176
82189
|
contents: file.data
|
|
82177
82190
|
}, {
|
|
@@ -95278,7 +95291,6 @@ class AppController {
|
|
|
95278
95291
|
* @param dt - delta time in seconds
|
|
95279
95292
|
* @param state - the current state of the app
|
|
95280
95293
|
* @param state.cameraMode - the current camera mode
|
|
95281
|
-
* @param state.snap - whether the camera is snapped to the target
|
|
95282
95294
|
* @param distance - the distance to the camera target
|
|
95283
95295
|
*/
|
|
95284
95296
|
update(dt, state, distance) {
|
|
@@ -95296,7 +95308,6 @@ class AppController {
|
|
|
95296
95308
|
this._state.shift += key[keyCode.SHIFT];
|
|
95297
95309
|
this._state.ctrl += key[keyCode.CTRL];
|
|
95298
95310
|
if (state.cameraMode !== 'fly' && this._state.axis.length() > 0) {
|
|
95299
|
-
state.snap = true;
|
|
95300
95311
|
state.cameraMode = 'fly';
|
|
95301
95312
|
}
|
|
95302
95313
|
const orbit = +(state.cameraMode === 'orbit');
|
|
@@ -95308,7 +95319,7 @@ class AppController {
|
|
|
95308
95319
|
// desktop move
|
|
95309
95320
|
const v = tmpV1.set(0, 0, 0);
|
|
95310
95321
|
const keyMove = this._state.axis.clone().normalize();
|
|
95311
|
-
v.add(keyMove.mulScalar(fly * this.moveSpeed * (this._state.shift ?
|
|
95322
|
+
v.add(keyMove.mulScalar(fly * this.moveSpeed * (this._state.shift ? 4 : this._state.ctrl ? 0.25 : 1) * dt));
|
|
95312
95323
|
const panMove = screenToWorld(this._camera, mouse[0], mouse[1], distance);
|
|
95313
95324
|
v.add(panMove.mulScalar(pan));
|
|
95314
95325
|
const wheelMove = new Vec3(0, 0, -wheel[0]);
|
|
@@ -95404,7 +95415,29 @@ class Picker {
|
|
|
95404
95415
|
}
|
|
95405
95416
|
}
|
|
95406
95417
|
|
|
95418
|
+
const vecToAngles = (result, vec) => {
|
|
95419
|
+
const radToDeg = 180 / Math.PI;
|
|
95420
|
+
result.x = Math.asin(vec.y) * radToDeg;
|
|
95421
|
+
result.y = Math.atan2(-vec.x, -vec.z) * radToDeg;
|
|
95422
|
+
result.z = 0;
|
|
95423
|
+
return result;
|
|
95424
|
+
};
|
|
95407
95425
|
const pose = new Pose();
|
|
95426
|
+
const avec = new Vec3();
|
|
95427
|
+
const bvec = new Vec3();
|
|
95428
|
+
// lerp between two poses
|
|
95429
|
+
const lerpPose = (result, a, b, t) => {
|
|
95430
|
+
// lerp camera position
|
|
95431
|
+
result.position.lerp(a.position, b.position, t);
|
|
95432
|
+
// lerp focus point and subtract from camera position
|
|
95433
|
+
a.getFocus(avec);
|
|
95434
|
+
b.getFocus(bvec);
|
|
95435
|
+
avec.lerp(avec, bvec, t).sub(result.position);
|
|
95436
|
+
// calculate distance
|
|
95437
|
+
result.distance = avec.length();
|
|
95438
|
+
// set angles
|
|
95439
|
+
vecToAngles(result.angles, avec.mulScalar(1.0 / result.distance));
|
|
95440
|
+
};
|
|
95408
95441
|
/**
|
|
95409
95442
|
* Creates a rotation animation track
|
|
95410
95443
|
*
|
|
@@ -95580,13 +95613,14 @@ class Viewer {
|
|
|
95580
95613
|
if (animCamera) {
|
|
95581
95614
|
state.cameraMode = 'anim';
|
|
95582
95615
|
}
|
|
95583
|
-
// this pose stores the current camera position. it will be blended/smoothed
|
|
95584
|
-
// toward the current active camera
|
|
95585
|
-
const activePose = new Pose();
|
|
95586
95616
|
// create controller
|
|
95587
95617
|
// set move speed based on scene size, within reason
|
|
95588
95618
|
const controller = new AppController(app.graphicsDevice.canvas, entity.camera);
|
|
95589
|
-
|
|
95619
|
+
// fixed move speed
|
|
95620
|
+
controller.moveSpeed = 4;
|
|
95621
|
+
// this pose stores the current camera position. it will be blended/smoothed
|
|
95622
|
+
// toward the current active camera
|
|
95623
|
+
const activePose = new Pose();
|
|
95590
95624
|
if (state.cameraMode === 'anim') {
|
|
95591
95625
|
// first frame of the animation
|
|
95592
95626
|
activePose.copy(animCamera.update(controller.frame, 0));
|
|
@@ -95598,11 +95632,7 @@ class Viewer {
|
|
|
95598
95632
|
// place all user cameras at the start position
|
|
95599
95633
|
orbitCamera.attach(activePose, false);
|
|
95600
95634
|
flyCamera.attach(activePose, false);
|
|
95601
|
-
// transition time between cameras
|
|
95602
|
-
let transitionTimer = 0;
|
|
95603
95635
|
// the previous camera we're transitioning away from
|
|
95604
|
-
const prevPose = new Pose();
|
|
95605
|
-
let prevCamera = null;
|
|
95606
95636
|
let prevCameraMode = 'orbit';
|
|
95607
95637
|
// handle input events
|
|
95608
95638
|
events.on('inputEvent', (eventName, event) => {
|
|
@@ -95614,7 +95644,6 @@ class Viewer {
|
|
|
95614
95644
|
}
|
|
95615
95645
|
case 'fly': {
|
|
95616
95646
|
if (state.cameraMode !== 'orbit') {
|
|
95617
|
-
state.snap = true;
|
|
95618
95647
|
state.cameraMode = 'orbit';
|
|
95619
95648
|
}
|
|
95620
95649
|
orbitCamera.attach(pose, true);
|
|
@@ -95641,6 +95670,10 @@ class Viewer {
|
|
|
95641
95670
|
break;
|
|
95642
95671
|
}
|
|
95643
95672
|
});
|
|
95673
|
+
let currCamera = getCamera(state.cameraMode);
|
|
95674
|
+
const prevPose = new Pose();
|
|
95675
|
+
// transition time between cameras
|
|
95676
|
+
let transitionTimer = 1;
|
|
95644
95677
|
// application update
|
|
95645
95678
|
app.on('update', (deltaTime) => {
|
|
95646
95679
|
// in xr mode we leave the camera alone
|
|
@@ -95654,20 +95687,19 @@ class Viewer {
|
|
|
95654
95687
|
events.fire('touchJoystickUpdate', controller.joystick.base, controller.joystick.stick);
|
|
95655
95688
|
}
|
|
95656
95689
|
// use dt of 0 if animation is paused
|
|
95657
|
-
const dt = state.cameraMode === 'anim' ?
|
|
95658
|
-
|
|
95659
|
-
|
|
95690
|
+
const dt = state.cameraMode === 'anim' && state.animationPaused ? 0 : deltaTime;
|
|
95691
|
+
// update the camera we're transitioning from
|
|
95692
|
+
transitionTimer = Math.min(1, transitionTimer + deltaTime * 2.0);
|
|
95660
95693
|
// update camera
|
|
95661
|
-
pose.copy(
|
|
95662
|
-
// blend camera smoothly during transitions
|
|
95694
|
+
pose.copy(currCamera.update(controller.frame, dt));
|
|
95663
95695
|
if (transitionTimer < 1) {
|
|
95664
|
-
|
|
95665
|
-
|
|
95666
|
-
|
|
95667
|
-
|
|
95696
|
+
// handle lerp away from previous camera
|
|
95697
|
+
lerpPose(activePose, prevPose, pose, easeOut(transitionTimer));
|
|
95698
|
+
}
|
|
95699
|
+
else {
|
|
95700
|
+
activePose.copy(pose);
|
|
95668
95701
|
}
|
|
95669
95702
|
// apply to camera
|
|
95670
|
-
activePose.copy(pose);
|
|
95671
95703
|
entity.setPosition(activePose.position);
|
|
95672
95704
|
entity.setEulerAngles(activePose.angles);
|
|
95673
95705
|
// update animation timeline
|
|
@@ -95679,19 +95711,16 @@ class Viewer {
|
|
|
95679
95711
|
events.on('cameraMode:changed', (value, prev) => {
|
|
95680
95712
|
prevCameraMode = prev;
|
|
95681
95713
|
prevPose.copy(activePose);
|
|
95682
|
-
|
|
95683
|
-
|
|
95714
|
+
getCamera(prev).detach();
|
|
95715
|
+
currCamera = getCamera(value);
|
|
95684
95716
|
switch (value) {
|
|
95685
95717
|
case 'orbit':
|
|
95686
95718
|
case 'fly':
|
|
95687
|
-
|
|
95719
|
+
currCamera.attach(activePose, false);
|
|
95688
95720
|
break;
|
|
95689
95721
|
}
|
|
95690
95722
|
// reset camera transition timer
|
|
95691
|
-
|
|
95692
|
-
transitionTimer = 0;
|
|
95693
|
-
}
|
|
95694
|
-
state.snap = false;
|
|
95723
|
+
transitionTimer = 0;
|
|
95695
95724
|
});
|
|
95696
95725
|
events.on('setAnimationTime', (time) => {
|
|
95697
95726
|
if (animCamera) {
|
|
@@ -95713,7 +95742,6 @@ class Viewer {
|
|
|
95713
95742
|
const result = await picker.pick(event.offsetX, event.offsetY);
|
|
95714
95743
|
if (result) {
|
|
95715
95744
|
if (state.cameraMode !== 'orbit') {
|
|
95716
|
-
state.snap = true;
|
|
95717
95745
|
state.cameraMode = 'orbit';
|
|
95718
95746
|
}
|
|
95719
95747
|
// snap distance of focus to picked point to interpolate rotation only
|
|
@@ -95910,7 +95938,6 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|
|
95910
95938
|
progress: 0,
|
|
95911
95939
|
inputMode: 'desktop', // desktop, touch
|
|
95912
95940
|
cameraMode: 'orbit', // orbit, anim, fly
|
|
95913
|
-
snap: false, // snap to camera target
|
|
95914
95941
|
hasAnimation: false,
|
|
95915
95942
|
animationDuration: 0,
|
|
95916
95943
|
animationTime: 0,
|