@playcanvas/supersplat-viewer 1.16.3 → 1.16.5
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 +1 -1
- package/public/index.js +522 -27
- package/public/index.js.map +1 -1
package/package.json
CHANGED
package/public/index.js
CHANGED
|
@@ -22008,7 +22008,7 @@ class RenderPassUpdateClustered extends RenderPass {
|
|
|
22008
22008
|
let _skinUpdateIndex = 0;
|
|
22009
22009
|
const viewProjMat = new Mat4();
|
|
22010
22010
|
const viewInvMat = new Mat4();
|
|
22011
|
-
const viewMat = new Mat4();
|
|
22011
|
+
const viewMat$1 = new Mat4();
|
|
22012
22012
|
const viewMat3 = new Mat3();
|
|
22013
22013
|
const tempSphere = new BoundingSphere();
|
|
22014
22014
|
const tempFrustum = new Frustum();
|
|
@@ -22155,11 +22155,11 @@ class Renderer {
|
|
|
22155
22155
|
viewInvMat.setTRS(pos, rot, Vec3.ONE);
|
|
22156
22156
|
}
|
|
22157
22157
|
this.viewInvId.setValue(viewInvMat.data);
|
|
22158
|
-
viewMat.copy(viewInvMat).invert();
|
|
22159
|
-
this.viewId.setValue(viewMat.data);
|
|
22160
|
-
viewMat3.setFromMat4(viewMat);
|
|
22158
|
+
viewMat$1.copy(viewInvMat).invert();
|
|
22159
|
+
this.viewId.setValue(viewMat$1.data);
|
|
22160
|
+
viewMat3.setFromMat4(viewMat$1);
|
|
22161
22161
|
this.viewId3.setValue(viewMat3.data);
|
|
22162
|
-
viewProjMat.mul2(projMat, viewMat);
|
|
22162
|
+
viewProjMat.mul2(projMat, viewMat$1);
|
|
22163
22163
|
this.viewProjId.setValue(viewProjMat.data);
|
|
22164
22164
|
camera._storeShaderMatrices(viewProjMat, jitterX, jitterY, this.device.renderVersion);
|
|
22165
22165
|
this.flipYId.setValue(flipY ? -1 : 1);
|
|
@@ -22243,8 +22243,8 @@ class Renderer {
|
|
|
22243
22243
|
viewInvMat.setTRS(pos, rot, Vec3.ONE);
|
|
22244
22244
|
this.viewInvId.setValue(viewInvMat.data);
|
|
22245
22245
|
}
|
|
22246
|
-
viewMat.copy(viewInvMat).invert();
|
|
22247
|
-
viewProjMat.mul2(projMat, viewMat);
|
|
22246
|
+
viewMat$1.copy(viewInvMat).invert();
|
|
22247
|
+
viewProjMat.mul2(projMat, viewMat$1);
|
|
22248
22248
|
camera.frustum.setFromMat4(viewProjMat);
|
|
22249
22249
|
}
|
|
22250
22250
|
setBaseConstants(device, material) {
|
|
@@ -70618,15 +70618,21 @@ const createRotateTrack = (position, target, fov, keys = 12, duration = 20) => {
|
|
|
70618
70618
|
const positions = [];
|
|
70619
70619
|
const targets = [];
|
|
70620
70620
|
const fovs = new Array(keys).fill(fov);
|
|
70621
|
-
const
|
|
70622
|
-
const
|
|
70623
|
-
const
|
|
70621
|
+
const dx = position.x - target.x;
|
|
70622
|
+
const dy = position.y - target.y;
|
|
70623
|
+
const dz = position.z - target.z;
|
|
70624
|
+
const horizontalRadius = Math.sqrt(dx * dx + dz * dz);
|
|
70625
|
+
const totalDist = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
70626
|
+
// when the offset is nearly vertical, use a fraction of the total distance
|
|
70627
|
+
// as the orbit radius so the camera actually moves in a circle
|
|
70628
|
+
const minRadius = totalDist * 0.3;
|
|
70629
|
+
const radius = Math.max(horizontalRadius, minRadius);
|
|
70630
|
+
const startAngle = Math.atan2(dx, dz);
|
|
70624
70631
|
for (let i = 0; i < keys; ++i) {
|
|
70625
|
-
|
|
70626
|
-
|
|
70627
|
-
positions.push(target.
|
|
70628
|
-
positions.push(target.
|
|
70629
|
-
positions.push(target.z + vec.z);
|
|
70632
|
+
const angle = startAngle - i / keys * Math.PI * 2;
|
|
70633
|
+
positions.push(target.x + radius * Math.sin(angle));
|
|
70634
|
+
positions.push(target.y + dy);
|
|
70635
|
+
positions.push(target.z + radius * Math.cos(angle));
|
|
70630
70636
|
targets.push(target.x);
|
|
70631
70637
|
targets.push(target.y);
|
|
70632
70638
|
targets.push(target.z);
|
|
@@ -70788,8 +70794,9 @@ const nearlyEquals = (a, b, epsilon = 1e-4) => {
|
|
|
70788
70794
|
};
|
|
70789
70795
|
const vecToAngles = (result, vec) => {
|
|
70790
70796
|
const radToDeg = 180 / Math.PI;
|
|
70791
|
-
|
|
70792
|
-
result.
|
|
70797
|
+
const horizLenSq = vec.x * vec.x + vec.z * vec.z;
|
|
70798
|
+
result.x = Math.asin(Math.max(-1, Math.min(1, vec.y))) * radToDeg;
|
|
70799
|
+
result.y = horizLenSq > 1e-8 ? Math.atan2(-vec.x, -vec.z) * radToDeg : 0;
|
|
70793
70800
|
result.z = 0;
|
|
70794
70801
|
return result;
|
|
70795
70802
|
};
|
|
@@ -71199,6 +71206,112 @@ class OrbitController {
|
|
|
71199
71206
|
}
|
|
71200
71207
|
}
|
|
71201
71208
|
|
|
71209
|
+
const RAD_TO_DEG = 180 / Math.PI;
|
|
71210
|
+
/** XZ distance below which the walker considers itself arrived */
|
|
71211
|
+
const ARRIVAL_DIST = 0.5;
|
|
71212
|
+
/** Minimum XZ speed (m/s) to not count as blocked */
|
|
71213
|
+
const BLOCKED_SPEED = 0.6;
|
|
71214
|
+
/** Seconds of continuous low-progress before stopping the walk */
|
|
71215
|
+
const BLOCKED_DURATION = 0.2;
|
|
71216
|
+
/**
|
|
71217
|
+
* Generates synthetic move/rotate input to auto-walk toward a target position.
|
|
71218
|
+
*
|
|
71219
|
+
* Designed to feed into FpsController's existing update path so there is no
|
|
71220
|
+
* duplicated physics. Each frame it appends yaw-rotation and forward-movement
|
|
71221
|
+
* deltas to the shared CameraFrame, and monitors arrival / blocked conditions.
|
|
71222
|
+
*/
|
|
71223
|
+
class WalkSource {
|
|
71224
|
+
/**
|
|
71225
|
+
* Forward input scale (matches InputController.moveSpeed for consistent
|
|
71226
|
+
* speed with regular WASD walking).
|
|
71227
|
+
*/
|
|
71228
|
+
walkSpeed = 4;
|
|
71229
|
+
/**
|
|
71230
|
+
* Yaw rotation damping while auto-walking toward a target.
|
|
71231
|
+
*/
|
|
71232
|
+
rotateDamping = 0.99;
|
|
71233
|
+
/**
|
|
71234
|
+
* Callback fired when an auto-walk completes (arrival or obstacle).
|
|
71235
|
+
*/
|
|
71236
|
+
onComplete = null;
|
|
71237
|
+
_target = null;
|
|
71238
|
+
_blockedTime = 0;
|
|
71239
|
+
_prevDist = Infinity;
|
|
71240
|
+
get isWalking() {
|
|
71241
|
+
return this._target !== null;
|
|
71242
|
+
}
|
|
71243
|
+
/**
|
|
71244
|
+
* Begin auto-walking toward a world-space target position.
|
|
71245
|
+
*
|
|
71246
|
+
* @param target - The destination (XZ used for navigation).
|
|
71247
|
+
*/
|
|
71248
|
+
walkTo(target) {
|
|
71249
|
+
if (!this._target) {
|
|
71250
|
+
this._target = new Vec3();
|
|
71251
|
+
}
|
|
71252
|
+
this._target.copy(target);
|
|
71253
|
+
this._blockedTime = 0;
|
|
71254
|
+
this._prevDist = Infinity;
|
|
71255
|
+
}
|
|
71256
|
+
/**
|
|
71257
|
+
* Cancel any active auto-walk.
|
|
71258
|
+
*/
|
|
71259
|
+
cancelWalk() {
|
|
71260
|
+
if (this._target) {
|
|
71261
|
+
this._target = null;
|
|
71262
|
+
this._blockedTime = 0;
|
|
71263
|
+
this.onComplete?.();
|
|
71264
|
+
}
|
|
71265
|
+
}
|
|
71266
|
+
/**
|
|
71267
|
+
* Compute walk deltas and append them to the frame. Must be called
|
|
71268
|
+
* before* the camera controller reads the frame.
|
|
71269
|
+
*
|
|
71270
|
+
* @param dt - Frame delta time in seconds.
|
|
71271
|
+
* @param cameraPosition - Camera world position (previous frame output).
|
|
71272
|
+
* @param cameraAngles - Camera Euler angles in degrees (previous frame output).
|
|
71273
|
+
* @param frame - The shared CameraFrame to append deltas to.
|
|
71274
|
+
*/
|
|
71275
|
+
update(dt, cameraPosition, cameraAngles, frame) {
|
|
71276
|
+
if (!this._target)
|
|
71277
|
+
return;
|
|
71278
|
+
const target = this._target;
|
|
71279
|
+
const dx = target.x - cameraPosition.x;
|
|
71280
|
+
const dz = target.z - cameraPosition.z;
|
|
71281
|
+
const xzDist = Math.sqrt(dx * dx + dz * dz);
|
|
71282
|
+
// arrival
|
|
71283
|
+
if (xzDist < ARRIVAL_DIST) {
|
|
71284
|
+
this.cancelWalk();
|
|
71285
|
+
return;
|
|
71286
|
+
}
|
|
71287
|
+
// blocked detection: compare with previous frame's distance
|
|
71288
|
+
if (this._prevDist !== Infinity && dt > 0) {
|
|
71289
|
+
const speed = (this._prevDist - xzDist) / dt;
|
|
71290
|
+
if (speed < BLOCKED_SPEED) {
|
|
71291
|
+
this._blockedTime += dt;
|
|
71292
|
+
if (this._blockedTime >= BLOCKED_DURATION) {
|
|
71293
|
+
this.cancelWalk();
|
|
71294
|
+
return;
|
|
71295
|
+
}
|
|
71296
|
+
}
|
|
71297
|
+
else {
|
|
71298
|
+
this._blockedTime = 0;
|
|
71299
|
+
}
|
|
71300
|
+
}
|
|
71301
|
+
this._prevDist = xzDist;
|
|
71302
|
+
// yaw toward target
|
|
71303
|
+
const targetYaw = Math.atan2(-dx, -dz) * RAD_TO_DEG;
|
|
71304
|
+
let yawDiff = targetYaw - cameraAngles.y;
|
|
71305
|
+
yawDiff = ((yawDiff % 360) + 540) % 360 - 180;
|
|
71306
|
+
const rotAlpha = damp(this.rotateDamping, dt);
|
|
71307
|
+
// FpsController applies: _angles.y += -rotate[0]
|
|
71308
|
+
frame.deltas.rotate.append([-(yawDiff * rotAlpha), 0, 0]);
|
|
71309
|
+
// scale forward speed by alignment: turn in place first, then accelerate
|
|
71310
|
+
const alignment = Math.max(0, Math.cos(yawDiff * Math.PI / 180));
|
|
71311
|
+
frame.deltas.move.append([0, 0, this.walkSpeed * dt * alignment]);
|
|
71312
|
+
}
|
|
71313
|
+
}
|
|
71314
|
+
|
|
71202
71315
|
const tmpCamera = new Camera();
|
|
71203
71316
|
const tmpv = new Vec3();
|
|
71204
71317
|
const createCamera = (position, target, fov) => {
|
|
@@ -71246,6 +71359,10 @@ class CameraManager {
|
|
|
71246
71359
|
};
|
|
71247
71360
|
controllers.fly.collider = collider;
|
|
71248
71361
|
controllers.fps.collider = collider;
|
|
71362
|
+
const walkSource = new WalkSource();
|
|
71363
|
+
walkSource.onComplete = () => {
|
|
71364
|
+
events.fire('walkComplete');
|
|
71365
|
+
};
|
|
71249
71366
|
const getController = (cameraMode) => {
|
|
71250
71367
|
return controllers[cameraMode];
|
|
71251
71368
|
};
|
|
@@ -71277,6 +71394,9 @@ class CameraManager {
|
|
|
71277
71394
|
// update transition timer
|
|
71278
71395
|
transitionTimer = Math.min(1, transitionTimer + deltaTime * transitionSpeed);
|
|
71279
71396
|
const controller = getController(state.cameraMode);
|
|
71397
|
+
if (state.cameraMode === 'fps') {
|
|
71398
|
+
walkSource.update(dt, this.camera.position, this.camera.angles, frame);
|
|
71399
|
+
}
|
|
71280
71400
|
controller.update(dt, frame, target);
|
|
71281
71401
|
if (transitionTimer < 1) {
|
|
71282
71402
|
// lerp away from previous camera during transition
|
|
@@ -71347,6 +71467,9 @@ class CameraManager {
|
|
|
71347
71467
|
});
|
|
71348
71468
|
// handle camera mode switching
|
|
71349
71469
|
events.on('cameraMode:changed', (value, prev) => {
|
|
71470
|
+
if (prev === 'fps') {
|
|
71471
|
+
walkSource.cancelWalk();
|
|
71472
|
+
}
|
|
71350
71473
|
// snapshot the current pose before any controller mutation
|
|
71351
71474
|
startTransition();
|
|
71352
71475
|
target.copy(this.camera);
|
|
@@ -71386,6 +71509,21 @@ class CameraManager {
|
|
|
71386
71509
|
target.fov = tmpCamera.fov;
|
|
71387
71510
|
startTransition();
|
|
71388
71511
|
});
|
|
71512
|
+
// tap-to-walk: start auto-walking toward a picked 3D position
|
|
71513
|
+
events.on('walkTo', (position) => {
|
|
71514
|
+
if (state.cameraMode === 'fps') {
|
|
71515
|
+
walkSource.walkTo(position);
|
|
71516
|
+
events.fire('walkIndicator:setTarget', position);
|
|
71517
|
+
}
|
|
71518
|
+
});
|
|
71519
|
+
// cancel any active auto-walk
|
|
71520
|
+
events.on('walkCancel', () => {
|
|
71521
|
+
walkSource.cancelWalk();
|
|
71522
|
+
events.fire('walkIndicator:setTarget', null);
|
|
71523
|
+
});
|
|
71524
|
+
events.on('walkComplete', () => {
|
|
71525
|
+
events.fire('walkIndicator:setTarget', null);
|
|
71526
|
+
});
|
|
71389
71527
|
}
|
|
71390
71528
|
}
|
|
71391
71529
|
|
|
@@ -71659,12 +71797,16 @@ class InputController {
|
|
|
71659
71797
|
_tapTouches = 0;
|
|
71660
71798
|
_tapDelta = 0;
|
|
71661
71799
|
_tapJump = false;
|
|
71800
|
+
// Screen coordinates of the last touch start (for tap-to-walk picking)
|
|
71801
|
+
_lastTouchOffsetX = 0;
|
|
71802
|
+
_lastTouchOffsetY = 0;
|
|
71803
|
+
_picker = null;
|
|
71662
71804
|
moveSpeed = 4;
|
|
71663
71805
|
orbitSpeed = 18;
|
|
71664
71806
|
pinchSpeed = 0.4;
|
|
71665
71807
|
wheelSpeed = 0.06;
|
|
71666
|
-
mouseRotateSensitivity = 0.
|
|
71667
|
-
touchRotateSensitivity = 1.
|
|
71808
|
+
mouseRotateSensitivity = 0.5;
|
|
71809
|
+
touchRotateSensitivity = 1.5;
|
|
71668
71810
|
touchPinchMoveSensitivity = 1.5;
|
|
71669
71811
|
gamepadRotateSensitivity = 1.0;
|
|
71670
71812
|
constructor(global) {
|
|
@@ -71691,6 +71833,13 @@ class InputController {
|
|
|
71691
71833
|
// Detect double taps manually because iOS doesn't send dblclick events
|
|
71692
71834
|
const lastTap = { time: 0, x: 0, y: 0 };
|
|
71693
71835
|
canvas.addEventListener('pointerdown', (event) => {
|
|
71836
|
+
// Store touch coordinates for tap-to-walk picking
|
|
71837
|
+
this._lastTouchOffsetX = event.offsetX;
|
|
71838
|
+
this._lastTouchOffsetY = event.offsetY;
|
|
71839
|
+
// Cancel any active auto-walk on new touch input
|
|
71840
|
+
if (state.cameraMode === 'fps' && event.pointerType === 'touch') {
|
|
71841
|
+
events.fire('walkCancel');
|
|
71842
|
+
}
|
|
71694
71843
|
const now = Date.now();
|
|
71695
71844
|
const delay = Math.max(0, now - lastTap.time);
|
|
71696
71845
|
if (delay < 300 &&
|
|
@@ -71706,16 +71855,15 @@ class InputController {
|
|
|
71706
71855
|
}
|
|
71707
71856
|
});
|
|
71708
71857
|
// Calculate pick location on double click
|
|
71709
|
-
let picker = null;
|
|
71710
71858
|
events.on('inputEvent', async (eventName, event) => {
|
|
71711
71859
|
switch (eventName) {
|
|
71712
71860
|
case 'dblclick': {
|
|
71713
71861
|
if (state.cameraMode === 'fps')
|
|
71714
71862
|
break;
|
|
71715
|
-
if (!
|
|
71716
|
-
|
|
71863
|
+
if (!this._picker) {
|
|
71864
|
+
this._picker = new Picker(app, camera);
|
|
71717
71865
|
}
|
|
71718
|
-
const result = await
|
|
71866
|
+
const result = await this._picker.pick(event.offsetX / canvas.clientWidth, event.offsetY / canvas.clientHeight);
|
|
71719
71867
|
if (result) {
|
|
71720
71868
|
events.fire('pick', result);
|
|
71721
71869
|
}
|
|
@@ -71845,7 +71993,11 @@ class InputController {
|
|
|
71845
71993
|
this._state.shift += key[keyCode.SHIFT];
|
|
71846
71994
|
this._state.ctrl += key[keyCode.CTRL];
|
|
71847
71995
|
const isFps = state.cameraMode === 'fps';
|
|
71848
|
-
//
|
|
71996
|
+
// Cancel any active auto-walk when the user provides WASD/arrow input
|
|
71997
|
+
if (isFps && (this._state.axis.x !== 0 || this._state.axis.z !== 0)) {
|
|
71998
|
+
events.fire('walkCancel');
|
|
71999
|
+
}
|
|
72000
|
+
// Tap detection using existing MultiTouchSource deltas
|
|
71849
72001
|
if (isFps) {
|
|
71850
72002
|
const prevTaps = this._tapTouches;
|
|
71851
72003
|
this._tapTouches = Math.max(0, this._tapTouches + count[0]);
|
|
@@ -71860,7 +72012,24 @@ class InputController {
|
|
|
71860
72012
|
// Touch just ended (1+ → 0): check if it was a tap
|
|
71861
72013
|
if (prevTaps > 0 && this._tapTouches === 0) {
|
|
71862
72014
|
if (this._tapDelta < TAP_EPSILON) {
|
|
71863
|
-
|
|
72015
|
+
if (state.touchControlScheme === 'pinch') {
|
|
72016
|
+
// Tap-to-walk: pick the 3D location and auto-walk toward it
|
|
72017
|
+
const { app, camera } = this.global;
|
|
72018
|
+
const canvas = app.graphicsDevice.canvas;
|
|
72019
|
+
if (!this._picker) {
|
|
72020
|
+
this._picker = new Picker(app, camera);
|
|
72021
|
+
}
|
|
72022
|
+
const pickX = this._lastTouchOffsetX / canvas.clientWidth;
|
|
72023
|
+
const pickY = this._lastTouchOffsetY / canvas.clientHeight;
|
|
72024
|
+
this._picker.pick(pickX, pickY).then((result) => {
|
|
72025
|
+
if (result && state.cameraMode === 'fps') {
|
|
72026
|
+
events.fire('walkTo', result);
|
|
72027
|
+
}
|
|
72028
|
+
});
|
|
72029
|
+
}
|
|
72030
|
+
else {
|
|
72031
|
+
this._tapJump = true;
|
|
72032
|
+
}
|
|
71864
72033
|
}
|
|
71865
72034
|
}
|
|
71866
72035
|
}
|
|
@@ -72567,6 +72736,326 @@ class VoxelDebugOverlay {
|
|
|
72567
72736
|
}
|
|
72568
72737
|
}
|
|
72569
72738
|
|
|
72739
|
+
const gsplatPSGlsl = /* glsl */ `
|
|
72740
|
+
|
|
72741
|
+
#ifndef DITHER_NONE
|
|
72742
|
+
#include "bayerPS"
|
|
72743
|
+
#include "opacityDitherPS"
|
|
72744
|
+
varying float id;
|
|
72745
|
+
#endif
|
|
72746
|
+
|
|
72747
|
+
#if defined(SHADOW_PASS) || defined(PICK_PASS) || defined(PREPASS_PASS)
|
|
72748
|
+
uniform float alphaClip;
|
|
72749
|
+
#endif
|
|
72750
|
+
|
|
72751
|
+
#ifdef PREPASS_PASS
|
|
72752
|
+
varying float vLinearDepth;
|
|
72753
|
+
#include "floatAsUintPS"
|
|
72754
|
+
#endif
|
|
72755
|
+
|
|
72756
|
+
varying mediump vec2 gaussianUV;
|
|
72757
|
+
varying mediump vec4 gaussianColor;
|
|
72758
|
+
|
|
72759
|
+
#if defined(GSPLAT_UNIFIED_ID) && defined(PICK_PASS)
|
|
72760
|
+
flat varying uint vPickId;
|
|
72761
|
+
#endif
|
|
72762
|
+
|
|
72763
|
+
#ifdef PICK_PASS
|
|
72764
|
+
#include "pickPS"
|
|
72765
|
+
#endif
|
|
72766
|
+
|
|
72767
|
+
#ifndef PICK_PASS
|
|
72768
|
+
uniform vec4 camera_params;
|
|
72769
|
+
#endif
|
|
72770
|
+
uniform vec4 viewport_size;
|
|
72771
|
+
uniform mat4 matrix_projection;
|
|
72772
|
+
|
|
72773
|
+
uniform mat4 walk_viewInverse;
|
|
72774
|
+
uniform vec3 walk_target;
|
|
72775
|
+
uniform float walk_radius;
|
|
72776
|
+
uniform float walk_time;
|
|
72777
|
+
|
|
72778
|
+
float walkLinearizeDepth(float z) {
|
|
72779
|
+
if (camera_params.w == 0.0)
|
|
72780
|
+
return (camera_params.z * camera_params.y) /
|
|
72781
|
+
(camera_params.y + z * (camera_params.z - camera_params.y));
|
|
72782
|
+
else
|
|
72783
|
+
return camera_params.z + z * (camera_params.y - camera_params.z);
|
|
72784
|
+
}
|
|
72785
|
+
|
|
72786
|
+
vec3 walkReconstructWorldPos() {
|
|
72787
|
+
float linearDepth = walkLinearizeDepth(gl_FragCoord.z);
|
|
72788
|
+
vec2 ndc = gl_FragCoord.xy * viewport_size.zw * 2.0 - 1.0;
|
|
72789
|
+
vec3 viewPos = vec3(
|
|
72790
|
+
ndc.x * linearDepth / matrix_projection[0][0],
|
|
72791
|
+
ndc.y * linearDepth / matrix_projection[1][1],
|
|
72792
|
+
-linearDepth
|
|
72793
|
+
);
|
|
72794
|
+
return (walk_viewInverse * vec4(viewPos, 1.0)).xyz;
|
|
72795
|
+
}
|
|
72796
|
+
|
|
72797
|
+
const float EXP4 = exp(-4.0);
|
|
72798
|
+
const float INV_EXP4 = 1.0 / (1.0 - EXP4);
|
|
72799
|
+
|
|
72800
|
+
float normExp(float x) {
|
|
72801
|
+
return (exp(x * -4.0) - EXP4) * INV_EXP4;
|
|
72802
|
+
}
|
|
72803
|
+
|
|
72804
|
+
void main(void) {
|
|
72805
|
+
mediump float A = dot(gaussianUV, gaussianUV);
|
|
72806
|
+
if (A > 1.0) {
|
|
72807
|
+
discard;
|
|
72808
|
+
}
|
|
72809
|
+
|
|
72810
|
+
mediump float alpha = normExp(A) * gaussianColor.a;
|
|
72811
|
+
|
|
72812
|
+
#if defined(SHADOW_PASS) || defined(PICK_PASS) || defined(PREPASS_PASS)
|
|
72813
|
+
if (alpha < alphaClip) {
|
|
72814
|
+
discard;
|
|
72815
|
+
}
|
|
72816
|
+
#endif
|
|
72817
|
+
|
|
72818
|
+
#ifdef PICK_PASS
|
|
72819
|
+
|
|
72820
|
+
#ifdef GSPLAT_UNIFIED_ID
|
|
72821
|
+
pcFragColor0 = encodePickOutput(vPickId);
|
|
72822
|
+
#else
|
|
72823
|
+
pcFragColor0 = getPickOutput();
|
|
72824
|
+
#endif
|
|
72825
|
+
#ifdef DEPTH_PICK_PASS
|
|
72826
|
+
pcFragColor1 = getPickDepth();
|
|
72827
|
+
#endif
|
|
72828
|
+
|
|
72829
|
+
#elif SHADOW_PASS
|
|
72830
|
+
|
|
72831
|
+
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
|
|
72832
|
+
|
|
72833
|
+
#elif PREPASS_PASS
|
|
72834
|
+
|
|
72835
|
+
gl_FragColor = float2vec4(vLinearDepth);
|
|
72836
|
+
|
|
72837
|
+
#else
|
|
72838
|
+
if (alpha < 1.0 / 255.0) {
|
|
72839
|
+
discard;
|
|
72840
|
+
}
|
|
72841
|
+
|
|
72842
|
+
#ifndef DITHER_NONE
|
|
72843
|
+
opacityDither(alpha, id * 0.013);
|
|
72844
|
+
#endif
|
|
72845
|
+
|
|
72846
|
+
if (walk_radius > 0.0) {
|
|
72847
|
+
vec3 walkWorldPos = walkReconstructWorldPos();
|
|
72848
|
+
float xzDist = length(walkWorldPos.xz - walk_target.xz);
|
|
72849
|
+
|
|
72850
|
+
float columnFade = 1.0 - smoothstep(walk_radius * 0.6, walk_radius, xzDist);
|
|
72851
|
+
|
|
72852
|
+
float ringPhase = fract(walk_time * 0.5);
|
|
72853
|
+
float ringDist = abs(xzDist / walk_radius - ringPhase);
|
|
72854
|
+
float ring = smoothstep(0.12, 0.0, ringDist) * 0.4;
|
|
72855
|
+
|
|
72856
|
+
float glow = (columnFade * 0.3 + ring) * alpha;
|
|
72857
|
+
|
|
72858
|
+
vec3 glowColor = mix(vec3(0.2, 0.6, 1.0), vec3(1.0), 0.3);
|
|
72859
|
+
gl_FragColor = vec4(gaussianColor.xyz * alpha + glowColor * glow, alpha);
|
|
72860
|
+
} else {
|
|
72861
|
+
gl_FragColor = vec4(gaussianColor.xyz * alpha, alpha);
|
|
72862
|
+
}
|
|
72863
|
+
#endif
|
|
72864
|
+
}
|
|
72865
|
+
`;
|
|
72866
|
+
const gsplatPSWgsl = /* wgsl */ `
|
|
72867
|
+
|
|
72868
|
+
#ifndef DITHER_NONE
|
|
72869
|
+
#include "bayerPS"
|
|
72870
|
+
#include "opacityDitherPS"
|
|
72871
|
+
varying id: f32;
|
|
72872
|
+
#endif
|
|
72873
|
+
|
|
72874
|
+
#if defined(SHADOW_PASS) || defined(PICK_PASS) || defined(PREPASS_PASS)
|
|
72875
|
+
uniform alphaClip: f32;
|
|
72876
|
+
#endif
|
|
72877
|
+
|
|
72878
|
+
#ifdef PREPASS_PASS
|
|
72879
|
+
varying vLinearDepth: f32;
|
|
72880
|
+
#include "floatAsUintPS"
|
|
72881
|
+
#endif
|
|
72882
|
+
|
|
72883
|
+
const EXP4_F: f32 = exp(-4.0);
|
|
72884
|
+
const INV_EXP4_F: f32 = 1.0 / (1.0 - EXP4_F);
|
|
72885
|
+
|
|
72886
|
+
fn normExp(x: f32) -> f32 {
|
|
72887
|
+
return (exp(x * -4.0) - EXP4_F) * INV_EXP4_F;
|
|
72888
|
+
}
|
|
72889
|
+
|
|
72890
|
+
varying gaussianUV: vec2f;
|
|
72891
|
+
varying gaussianColor: vec4f;
|
|
72892
|
+
|
|
72893
|
+
#if defined(GSPLAT_UNIFIED_ID) && defined(PICK_PASS)
|
|
72894
|
+
varying @interpolate(flat) vPickId: u32;
|
|
72895
|
+
#endif
|
|
72896
|
+
|
|
72897
|
+
#ifdef PICK_PASS
|
|
72898
|
+
#include "pickPS"
|
|
72899
|
+
#endif
|
|
72900
|
+
|
|
72901
|
+
uniform walk_viewInverse: mat4x4f;
|
|
72902
|
+
uniform walk_target: vec3f;
|
|
72903
|
+
uniform walk_radius: f32;
|
|
72904
|
+
uniform walk_time: f32;
|
|
72905
|
+
|
|
72906
|
+
fn walkLinearizeDepth(z: f32) -> f32 {
|
|
72907
|
+
if (uniform.camera_params.w == 0.0) {
|
|
72908
|
+
return (uniform.camera_params.z * uniform.camera_params.y) /
|
|
72909
|
+
(uniform.camera_params.y + z * (uniform.camera_params.z - uniform.camera_params.y));
|
|
72910
|
+
} else {
|
|
72911
|
+
return uniform.camera_params.z + z * (uniform.camera_params.y - uniform.camera_params.z);
|
|
72912
|
+
}
|
|
72913
|
+
}
|
|
72914
|
+
|
|
72915
|
+
fn walkReconstructWorldPos(fragCoord: vec4f) -> vec3f {
|
|
72916
|
+
let linearDepth = walkLinearizeDepth(fragCoord.z);
|
|
72917
|
+
let ndc = fragCoord.xy * uniform.viewport_size.zw * 2.0 - 1.0;
|
|
72918
|
+
let viewPos = vec3f(
|
|
72919
|
+
ndc.x * linearDepth / uniform.matrix_projection[0][0],
|
|
72920
|
+
ndc.y * linearDepth / uniform.matrix_projection[1][1],
|
|
72921
|
+
-linearDepth
|
|
72922
|
+
);
|
|
72923
|
+
return (uniform.walk_viewInverse * vec4f(viewPos, 1.0)).xyz;
|
|
72924
|
+
}
|
|
72925
|
+
|
|
72926
|
+
@fragment
|
|
72927
|
+
fn fragmentMain(input: FragmentInput) -> FragmentOutput {
|
|
72928
|
+
var output: FragmentOutput;
|
|
72929
|
+
|
|
72930
|
+
let A: f32 = f32(dot(gaussianUV, gaussianUV));
|
|
72931
|
+
if (A > 1.0) {
|
|
72932
|
+
discard;
|
|
72933
|
+
return output;
|
|
72934
|
+
}
|
|
72935
|
+
|
|
72936
|
+
var alpha: f32 = normExp(A) * f32(gaussianColor.a);
|
|
72937
|
+
|
|
72938
|
+
#if defined(SHADOW_PASS) || defined(PICK_PASS) || defined(PREPASS_PASS)
|
|
72939
|
+
if (alpha < uniform.alphaClip) {
|
|
72940
|
+
discard;
|
|
72941
|
+
return output;
|
|
72942
|
+
}
|
|
72943
|
+
#endif
|
|
72944
|
+
|
|
72945
|
+
#ifdef PICK_PASS
|
|
72946
|
+
|
|
72947
|
+
#ifdef GSPLAT_UNIFIED_ID
|
|
72948
|
+
output.color = encodePickOutput(vPickId);
|
|
72949
|
+
#else
|
|
72950
|
+
output.color = getPickOutput();
|
|
72951
|
+
#endif
|
|
72952
|
+
#ifdef DEPTH_PICK_PASS
|
|
72953
|
+
output.color1 = getPickDepth();
|
|
72954
|
+
#endif
|
|
72955
|
+
|
|
72956
|
+
#elif SHADOW_PASS
|
|
72957
|
+
|
|
72958
|
+
output.color = vec4f(0.0, 0.0, 0.0, 1.0);
|
|
72959
|
+
|
|
72960
|
+
#elif PREPASS_PASS
|
|
72961
|
+
|
|
72962
|
+
output.color = float2vec4(vLinearDepth);
|
|
72963
|
+
|
|
72964
|
+
#else
|
|
72965
|
+
|
|
72966
|
+
if (alpha < 1.0 / 255.0) {
|
|
72967
|
+
discard;
|
|
72968
|
+
return output;
|
|
72969
|
+
}
|
|
72970
|
+
|
|
72971
|
+
#ifndef DITHER_NONE
|
|
72972
|
+
opacityDither(alpha, id * 0.013);
|
|
72973
|
+
#endif
|
|
72974
|
+
|
|
72975
|
+
let gc = vec3f(gaussianColor.xyz);
|
|
72976
|
+
|
|
72977
|
+
if (uniform.walk_radius > 0.0) {
|
|
72978
|
+
let walkWorldPos = walkReconstructWorldPos(pcPosition);
|
|
72979
|
+
let xzDist = length(walkWorldPos.xz - uniform.walk_target.xz);
|
|
72980
|
+
|
|
72981
|
+
let columnFade = 1.0 - smoothstep(uniform.walk_radius * 0.6, uniform.walk_radius, xzDist);
|
|
72982
|
+
|
|
72983
|
+
let ringPhase = fract(uniform.walk_time * 0.5);
|
|
72984
|
+
let ringDist = abs(xzDist / uniform.walk_radius - ringPhase);
|
|
72985
|
+
let ring = smoothstep(0.12, 0.0, ringDist) * 0.4;
|
|
72986
|
+
|
|
72987
|
+
let glow = (columnFade * 0.3 + ring) * alpha;
|
|
72988
|
+
|
|
72989
|
+
let glowColor = mix(vec3f(0.2, 0.6, 1.0), vec3f(1.0), 0.3);
|
|
72990
|
+
output.color = vec4f(gc * alpha + glowColor * glow, alpha);
|
|
72991
|
+
} else {
|
|
72992
|
+
output.color = vec4f(gc * alpha, alpha);
|
|
72993
|
+
}
|
|
72994
|
+
#endif
|
|
72995
|
+
|
|
72996
|
+
return output;
|
|
72997
|
+
}`;
|
|
72998
|
+
const viewMat = new Mat4();
|
|
72999
|
+
const invViewMat = new Mat4();
|
|
73000
|
+
class WalkIndicator {
|
|
73001
|
+
app;
|
|
73002
|
+
target = null;
|
|
73003
|
+
startTime = 0;
|
|
73004
|
+
origGlsl;
|
|
73005
|
+
origWgsl;
|
|
73006
|
+
constructor(app) {
|
|
73007
|
+
this.app = app;
|
|
73008
|
+
const device = app.graphicsDevice;
|
|
73009
|
+
const glsl = ShaderChunks.get(device, 'glsl');
|
|
73010
|
+
const wgsl = ShaderChunks.get(device, 'wgsl');
|
|
73011
|
+
this.origGlsl = glsl.get('gsplatPS');
|
|
73012
|
+
this.origWgsl = wgsl.get('gsplatPS');
|
|
73013
|
+
glsl.set('gsplatPS', gsplatPSGlsl);
|
|
73014
|
+
wgsl.set('gsplatPS', gsplatPSWgsl);
|
|
73015
|
+
}
|
|
73016
|
+
/**
|
|
73017
|
+
* Set or clear the walk target position.
|
|
73018
|
+
*
|
|
73019
|
+
* @param pos - World-space target position, or null to clear.
|
|
73020
|
+
*/
|
|
73021
|
+
setTarget(pos) {
|
|
73022
|
+
this.target = pos ? pos.clone() : null;
|
|
73023
|
+
if (pos) {
|
|
73024
|
+
this.startTime = performance.now() / 1000;
|
|
73025
|
+
}
|
|
73026
|
+
}
|
|
73027
|
+
/**
|
|
73028
|
+
* Update uniforms for the walk highlight effect. Call from a prerender hook.
|
|
73029
|
+
*
|
|
73030
|
+
* @param camera - The camera entity used for rendering.
|
|
73031
|
+
*/
|
|
73032
|
+
update(camera) {
|
|
73033
|
+
const device = this.app.graphicsDevice;
|
|
73034
|
+
const scope = device.scope;
|
|
73035
|
+
const cam = camera.camera;
|
|
73036
|
+
viewMat.copy(cam.viewMatrix);
|
|
73037
|
+
invViewMat.copy(viewMat).invert();
|
|
73038
|
+
scope.resolve('walk_viewInverse').setValue(invViewMat.data);
|
|
73039
|
+
if (this.target) {
|
|
73040
|
+
const elapsed = performance.now() / 1000 - this.startTime;
|
|
73041
|
+
scope.resolve('walk_target').setValue([this.target.x, this.target.y, this.target.z]);
|
|
73042
|
+
scope.resolve('walk_radius').setValue(1.5);
|
|
73043
|
+
scope.resolve('walk_time').setValue(elapsed);
|
|
73044
|
+
this.app.renderNextFrame = true;
|
|
73045
|
+
}
|
|
73046
|
+
else {
|
|
73047
|
+
scope.resolve('walk_target').setValue([0, 0, 0]);
|
|
73048
|
+
scope.resolve('walk_radius').setValue(0);
|
|
73049
|
+
scope.resolve('walk_time').setValue(0);
|
|
73050
|
+
}
|
|
73051
|
+
}
|
|
73052
|
+
destroy() {
|
|
73053
|
+
const device = this.app.graphicsDevice;
|
|
73054
|
+
ShaderChunks.get(device, 'glsl').set('gsplatPS', this.origGlsl);
|
|
73055
|
+
ShaderChunks.get(device, 'wgsl').set('gsplatPS', this.origWgsl);
|
|
73056
|
+
}
|
|
73057
|
+
}
|
|
73058
|
+
|
|
72570
73059
|
const gammaChunkGlsl = `
|
|
72571
73060
|
vec3 prepareOutputFromGamma(vec3 gammaColor) {
|
|
72572
73061
|
return gammaColor;
|
|
@@ -72648,6 +73137,7 @@ class Viewer {
|
|
|
72648
73137
|
annotations;
|
|
72649
73138
|
forceRenderNextFrame = false;
|
|
72650
73139
|
voxelOverlay = null;
|
|
73140
|
+
walkIndicator = null;
|
|
72651
73141
|
origChunks;
|
|
72652
73142
|
constructor(global, gsplatLoad, skyboxLoad, voxelLoad) {
|
|
72653
73143
|
this.global = global;
|
|
@@ -72755,9 +73245,10 @@ class Viewer {
|
|
|
72755
73245
|
applyCamera(this.cameraManager.camera);
|
|
72756
73246
|
}
|
|
72757
73247
|
});
|
|
72758
|
-
// Render voxel debug overlay
|
|
73248
|
+
// Render voxel debug overlay and update walk indicator
|
|
72759
73249
|
app.on('prerender', () => {
|
|
72760
73250
|
this.voxelOverlay?.update();
|
|
73251
|
+
this.walkIndicator?.update(camera);
|
|
72761
73252
|
});
|
|
72762
73253
|
// update state on first frame
|
|
72763
73254
|
events.on('firstFrame', () => {
|
|
@@ -72790,6 +73281,10 @@ class Viewer {
|
|
|
72790
73281
|
}
|
|
72791
73282
|
this.cameraManager = new CameraManager(global, sceneBound, collider);
|
|
72792
73283
|
applyCamera(this.cameraManager.camera);
|
|
73284
|
+
this.walkIndicator = new WalkIndicator(app);
|
|
73285
|
+
events.on('walkIndicator:setTarget', (pos) => {
|
|
73286
|
+
this.walkIndicator?.setTarget(pos);
|
|
73287
|
+
});
|
|
72793
73288
|
const { instance } = gsplat;
|
|
72794
73289
|
if (instance) {
|
|
72795
73290
|
// kick off gsplat sorting immediately now that camera is in position
|
|
@@ -74513,7 +75008,7 @@ const initXr = (global) => {
|
|
|
74513
75008
|
});
|
|
74514
75009
|
};
|
|
74515
75010
|
|
|
74516
|
-
var version = "1.16.
|
|
75011
|
+
var version = "1.16.5";
|
|
74517
75012
|
|
|
74518
75013
|
const loadGsplat = async (app, config, progressCallback) => {
|
|
74519
75014
|
const { contents, contentUrl, unified, aa } = config;
|