@playcanvas/supersplat-viewer 1.8.0 → 1.8.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playcanvas/supersplat-viewer",
3
- "version": "1.8.0",
3
+ "version": "1.8.2",
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",
@@ -47,7 +47,7 @@
47
47
  "concurrently": "9.2.1",
48
48
  "eslint": "9.39.1",
49
49
  "globals": "16.5.0",
50
- "playcanvas": "2.13.0",
50
+ "playcanvas": "2.13.1",
51
51
  "postcss": "8.5.6",
52
52
  "publint": "0.3.15",
53
53
  "rollup": "4.53.2",
package/public/index.html CHANGED
@@ -43,12 +43,7 @@
43
43
  <pc-scene>
44
44
  <!-- Camera (with XR support) -->
45
45
  <pc-entity name="camera root">
46
- <pc-entity name="camera">
47
- <pc-camera near-clip="0.001" far-clip="5000" horizontal-fov="true" tonemap="none"></pc-camera>
48
- </pc-entity>
49
- <!-- XR controllers will be added here -->
50
- <pc-scripts>
51
- </pc-scripts>
46
+ <pc-entity name="camera"></pc-entity>
52
47
  </pc-entity>
53
48
  <!-- Light (for XR controllers) -->
54
49
  <pc-entity name="light" rotation="35 45 0">
package/public/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  const TRACEID_GPU_TIMINGS = 'GpuTimings';
2
2
 
3
- const version = '2.13.0';
4
- const revision = '920c8d0';
3
+ const version = '2.13.1';
4
+ const revision = '5d53ea1';
5
5
  function extend(target, ex) {
6
6
  for(const prop in ex){
7
7
  const copy = ex[prop];
@@ -154,6 +154,17 @@ const platform = {
154
154
  environment: environment,
155
155
  browser: environment === 'browser',
156
156
  worker: environment === 'worker',
157
+ desktop: [
158
+ 'windows',
159
+ 'osx',
160
+ 'linux',
161
+ 'cros'
162
+ ].includes(platformName),
163
+ mobile: [
164
+ 'android',
165
+ 'ios'
166
+ ].includes(platformName),
167
+ ios: platformName === 'ios',
157
168
  android: platformName === 'android',
158
169
  touch: touch,
159
170
  passiveEvents: passiveEvents,
@@ -6555,6 +6566,10 @@ class GraphicsDevice extends EventHandler {
6555
6566
  if (this.textureFloatFilterable) capsDefines.set('CAPS_TEXTURE_FLOAT_FILTERABLE', '');
6556
6567
  if (this.textureFloatRenderable) capsDefines.set('CAPS_TEXTURE_FLOAT_RENDERABLE', '');
6557
6568
  if (this.supportsMultiDraw) capsDefines.set('CAPS_MULTI_DRAW', '');
6569
+ if (platform.desktop) capsDefines.set('PLATFORM_DESKTOP', '');
6570
+ if (platform.mobile) capsDefines.set('PLATFORM_MOBILE', '');
6571
+ if (platform.android) capsDefines.set('PLATFORM_ANDROID', '');
6572
+ if (platform.ios) capsDefines.set('PLATFORM_IOS', '');
6558
6573
  }
6559
6574
  destroy() {
6560
6575
  this.fire('destroy');
@@ -33981,6 +33996,7 @@ var glslGsplatCopyToWorkBufferPS = `
33981
33996
  #include "gsplatEvalSHVS"
33982
33997
  #include "gsplatQuatToMat3VS"
33983
33998
  #include "gsplatSourceFormatVS"
33999
+ #include "packHalfPS"
33984
34000
  uniform mat4 uTransform;
33985
34001
  uniform int uStartLine;
33986
34002
  uniform int uViewportWidth;
@@ -34057,8 +34073,8 @@ void main(void) {
34057
34073
  pcFragColor0 = color;
34058
34074
  #endif
34059
34075
  #ifndef GSPLAT_COLOR_ONLY
34060
- pcFragColor1 = uvec4(floatBitsToUint(modelCenter.x), floatBitsToUint(modelCenter.y), floatBitsToUint(modelCenter.z), packHalf2x16(vec2(covA.z, covB.z)));
34061
- pcFragColor2 = uvec2(packHalf2x16(covA.xy), packHalf2x16(covB.xy));
34076
+ pcFragColor1 = uvec4(floatBitsToUint(modelCenter.x), floatBitsToUint(modelCenter.y), floatBitsToUint(modelCenter.z), packHalf2x16Safe(vec2(covA.z, covB.z)));
34077
+ pcFragColor2 = uvec2(packHalf2x16Safe(covA.xy), packHalf2x16Safe(covB.xy));
34062
34078
  #endif
34063
34079
  }
34064
34080
  }
@@ -34071,6 +34087,7 @@ var wgslGsplatCopyToWorkBufferPS = `
34071
34087
  #include "gsplatEvalSHVS"
34072
34088
  #include "gsplatQuatToMat3VS"
34073
34089
  #include "gsplatSourceFormatVS"
34090
+ #include "packHalfPS"
34074
34091
  uniform uTransform: mat4x4f;
34075
34092
  uniform uStartLine: i32;
34076
34093
  uniform uViewportWidth: i32;
@@ -34138,8 +34155,8 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
34138
34155
  color = vec4f(color.xyz * uniform.uColorMultiply, color.w);
34139
34156
  output.color = color;
34140
34157
  #ifndef GSPLAT_COLOR_ONLY
34141
- output.color1 = vec4u(bitcast<u32>(modelCenter.x), bitcast<u32>(modelCenter.y), bitcast<u32>(modelCenter.z), pack2x16float(vec2f(covA.z, covB.z)));
34142
- output.color2 = vec2u(pack2x16float(covA.xy), pack2x16float(covB.xy));
34158
+ output.color1 = vec4u(bitcast<u32>(modelCenter.x), bitcast<u32>(modelCenter.y), bitcast<u32>(modelCenter.z), pack2x16floatSafe(vec2f(covA.z, covB.z)));
34159
+ output.color2 = vec2u(pack2x16floatSafe(covA.xy), pack2x16floatSafe(covB.xy));
34143
34160
  #endif
34144
34161
  }
34145
34162
 
@@ -41973,6 +41990,70 @@ void opacityDither(float alpha, float id) {
41973
41990
  var outputPS$1 = `
41974
41991
  `;
41975
41992
 
41993
+ var packHalfPS$1 = `
41994
+ #if defined(PLATFORM_ANDROID)
41995
+ uint floatToHalf(float a) {
41996
+ uint u = floatBitsToUint(a);
41997
+ uint sign = (u >> 16u) & 0x8000u;
41998
+ uint absu = u & 0x7FFFFFFFu;
41999
+ uint man = u & 0x007FFFFFu;
42000
+ int e32 = int((u >> 23u) & 0xFFu) - 127;
42001
+
42002
+ if ((absu & 0x7F800000u) == 0x7F800000u) {
42003
+ bool isnan = (man != 0u);
42004
+ return sign | (isnan ? 0x7E00u : 0x7C00u);
42005
+ }
42006
+
42007
+ if (e32 > 15) return sign | 0x7C00u;
42008
+
42009
+ if (e32 >= -14) {
42010
+ uint he = uint(e32 + 15);
42011
+ uint hm = man >> 13u;
42012
+ uint rem = man & 0x1FFFu;
42013
+ uint add = (rem > 0x1000u || (rem == 0x1000u && (hm & 1u) == 1u)) ? 1u : 0u;
42014
+ hm = (hm + add) & 0x3FFu;
42015
+ if ((hm & 0x400u) != 0u) {
42016
+ hm = 0u; he = he + 1u;
42017
+ if (he >= 31u) return sign | 0x7C00u;
42018
+ }
42019
+ return sign | (he << 10u) | hm;
42020
+ }
42021
+
42022
+ if (e32 >= -24) {
42023
+ uint s = uint(-(e32 + 1));
42024
+ uint mnorm = 0x00800000u | man;
42025
+ uint hm = mnorm >> s;
42026
+ uint mask = (1u << s) - 1u;
42027
+ uint rem = mnorm & mask;
42028
+ uint halfBt = 1u << (s - 1u);
42029
+ uint add = (rem > halfBt || (rem == halfBt && (hm & 1u) == 1u)) ? 1u : 0u;
42030
+ hm = hm + add;
42031
+ if (hm >= 0x400u) return sign | (1u << 10u);
42032
+ return sign | hm;
42033
+ }
42034
+
42035
+ return sign;
42036
+ }
42037
+ uint packHalf2x16Safe(vec2 v) {
42038
+ uint u_x = floatBitsToUint(v.x);
42039
+ uint u_y = floatBitsToUint(v.y);
42040
+
42041
+ int e32_x = int((u_x >> 23u) & 0xFFu) - 127;
42042
+ int e32_y = int((u_y >> 23u) & 0xFFu) - 127;
42043
+
42044
+ if (e32_x < -14 || e32_y < -14) {
42045
+ return (floatToHalf(v.y) << 16u) | floatToHalf(v.x);
42046
+ }
42047
+
42048
+ return packHalf2x16(v);
42049
+ }
42050
+ #else
42051
+ uint packHalf2x16Safe(vec2 v) {
42052
+ return packHalf2x16(v);
42053
+ }
42054
+ #endif
42055
+ `;
42056
+
41976
42057
  var outputAlphaPS$1 = `
41977
42058
  #if LIT_BLEND_TYPE == NORMAL || LIT_BLEND_TYPE == ADDITIVEALPHA || defined(LIT_ALPHA_TO_COVERAGE)
41978
42059
  gl_FragColor.a = litArgs_opacity;
@@ -43968,6 +44049,7 @@ const shaderChunksGLSL = {
43968
44049
  opacityDitherPS: opacityDitherPS$1,
43969
44050
  outputPS: outputPS$1,
43970
44051
  outputAlphaPS: outputAlphaPS$1,
44052
+ packHalfPS: packHalfPS$1,
43971
44053
  outputTex2DPS: outputTex2DPS$1,
43972
44054
  sheenPS: sheenPS$1,
43973
44055
  sheenGlossPS: sheenGlossPS$1,
@@ -47321,6 +47403,70 @@ var outputAlphaPS = `
47321
47403
  #endif
47322
47404
  `;
47323
47405
 
47406
+ var packHalfPS = `
47407
+ #if defined(PLATFORM_ANDROID)
47408
+ fn floatToHalf(a: f32) -> u32 {
47409
+ let u: u32 = bitcast<u32>(a);
47410
+ let sign: u32 = (u >> 16u) & 0x8000u;
47411
+ let absu: u32 = u & 0x7FFFFFFFu;
47412
+ let man: u32 = u & 0x007FFFFFu;
47413
+ let e32: i32 = i32((u >> 23u) & 0xFFu) - 127;
47414
+
47415
+ if ((absu & 0x7F800000u) == 0x7F800000u) {
47416
+ let isnan = (man != 0u);
47417
+ return sign | select(0x7C00u, 0x7E00u, isnan);
47418
+ }
47419
+
47420
+ if (e32 > 15) { return sign | 0x7C00u; }
47421
+
47422
+ if (e32 >= -14) {
47423
+ var he: u32 = u32(e32 + 15);
47424
+ var hm: u32 = man >> 13u;
47425
+ let rem: u32 = man & 0x1FFFu;
47426
+ let add: u32 = select(0u, 1u, (rem > 0x1000u) || (rem == 0x1000u && (hm & 1u) == 1u));
47427
+ hm = (hm + add) & 0x3FFu;
47428
+ if ((hm & 0x400u) != 0u) {
47429
+ hm = 0u; he = he + 1u;
47430
+ if (he >= 31u) { return sign | 0x7C00u; }
47431
+ }
47432
+ return sign | (he << 10u) | hm;
47433
+ }
47434
+
47435
+ if (e32 >= -24) {
47436
+ let s: u32 = u32(-(e32 + 1));
47437
+ let mnorm: u32 = 0x00800000u | man;
47438
+ var hm: u32 = mnorm >> s;
47439
+ let mask: u32 = (1u << s) - 1u;
47440
+ let rem: u32 = mnorm & mask;
47441
+ let halfBt: u32 = 1u << (s - 1u);
47442
+ let add: u32 = select(0u, 1u, (rem > halfBt) || (rem == halfBt && (hm & 1u) == 1u));
47443
+ hm = hm + add;
47444
+ if (hm >= 0x400u) { return sign | (1u << 10u); }
47445
+ return sign | hm;
47446
+ }
47447
+
47448
+ return sign;
47449
+ }
47450
+ fn pack2x16floatSafe(v: vec2f) -> u32 {
47451
+ let u_x: u32 = bitcast<u32>(v.x);
47452
+ let u_y: u32 = bitcast<u32>(v.y);
47453
+
47454
+ let e32_x: i32 = i32((u_x >> 23u) & 0xFFu) - 127;
47455
+ let e32_y: i32 = i32((u_y >> 23u) & 0xFFu) - 127;
47456
+
47457
+ if (e32_x < -14 || e32_y < -14) {
47458
+ return (floatToHalf(v.y) << 16u) | floatToHalf(v.x);
47459
+ }
47460
+
47461
+ return pack2x16float(v);
47462
+ }
47463
+ #else
47464
+ fn pack2x16floatSafe(v: vec2f) -> u32 {
47465
+ return pack2x16float(v);
47466
+ }
47467
+ #endif
47468
+ `;
47469
+
47324
47470
  var outputTex2DPS = `
47325
47471
  varying vUv0: vec2f;
47326
47472
  var source: texture_2d<f32>;
@@ -49226,6 +49372,7 @@ const shaderChunksWGSL = {
49226
49372
  opacityDitherPS,
49227
49373
  outputPS,
49228
49374
  outputAlphaPS,
49375
+ packHalfPS,
49229
49376
  outputTex2DPS,
49230
49377
  sheenPS,
49231
49378
  sheenGlossPS,
@@ -76064,6 +76211,9 @@ new BoundingBox();
76064
76211
  new Color(1, 0, 1)
76065
76212
  ];
76066
76213
  class GSplatOctreeInstance {
76214
+ get hasPendingLoads() {
76215
+ return this.pending.size > 0 || this.prefetchPending.size > 0;
76216
+ }
76067
76217
  constructor(octree, placement, assetLoader){
76068
76218
  this.activePlacements = new Set();
76069
76219
  this.dirtyModifiedPlacements = false;
@@ -76923,6 +77073,16 @@ class GSplatManager {
76923
77073
  }
76924
77074
  return _cameraDeltas;
76925
77075
  }
77076
+ fireFrameReadyEvent() {
77077
+ const ready = this.sortedVersion === this.lastWorldStateVersion;
77078
+ let loading = this.director.assetLoader.isLoading;
77079
+ if (!loading) {
77080
+ for (const [, inst] of this.octreeInstances){
77081
+ loading ||= inst.hasPendingLoads;
77082
+ }
77083
+ }
77084
+ this.director.eventHandler.fire('frame:ready', this.cameraNode.camera, this.renderer.layer, ready, loading);
77085
+ }
76926
77086
  update() {
76927
77087
  this.sorter.applyPendingSorted();
76928
77088
  let fullUpdate = false;
@@ -77025,6 +77185,7 @@ class GSplatManager {
77025
77185
  }
77026
77186
  tempOctreesTicked.clear();
77027
77187
  }
77188
+ this.fireFrameReadyEvent();
77028
77189
  const { textureSize } = this.workBuffer;
77029
77190
  return textureSize * textureSize;
77030
77191
  }
@@ -77522,6 +77683,9 @@ class GSplatAssetLoaderBase {
77522
77683
  load(url) {}
77523
77684
  unload(url) {}
77524
77685
  getResource(url) {}
77686
+ get isLoading() {
77687
+ return false;
77688
+ }
77525
77689
  constructor(){
77526
77690
  this.cooldownTicks = 100;
77527
77691
  }
@@ -77532,6 +77696,9 @@ class GSplatAssetLoader extends GSplatAssetLoaderBase {
77532
77696
  super(), this._urlToAsset = new Map(), this.maxConcurrentLoads = 2, this.maxRetries = 2, this._currentlyLoading = new Set(), this._loadQueue = [], this._retryCount = new Map();
77533
77697
  this._registry = registry;
77534
77698
  }
77699
+ get isLoading() {
77700
+ return this._currentlyLoading.size > 0 || this._loadQueue.length > 0;
77701
+ }
77535
77702
  load(url) {
77536
77703
  const asset = this._urlToAsset.get(url);
77537
77704
  if (asset?.loaded || this._currentlyLoading.has(url)) {
@@ -77650,6 +77817,8 @@ vec4 readColor(in SplatSource source) {
77650
77817
  `;
77651
77818
 
77652
77819
  var gsplatCommonVS$1 = `
77820
+ #include "gsplatHelpersVS"
77821
+ #include "gsplatCustomizeVS"
77653
77822
  #include "gsplatStructsVS"
77654
77823
  #include "gsplatEvalSHVS"
77655
77824
  #include "gsplatQuatToMat3VS"
@@ -77666,6 +77835,7 @@ void clipCorner(inout SplatCorner corner, float alpha) {
77666
77835
  `;
77667
77836
 
77668
77837
  var gsplatCompressedDataVS$1 = `
77838
+ #include "gsplatPackingPS"
77669
77839
  uniform highp usampler2D packedTexture;
77670
77840
  uniform highp sampler2D chunkTexture;
77671
77841
  vec4 chunkDataA;
@@ -77681,14 +77851,6 @@ vec3 unpack111011(uint bits) {
77681
77851
  float(bits & 0x7ffu) / 2047.0
77682
77852
  );
77683
77853
  }
77684
- vec4 unpack8888(uint bits) {
77685
- return vec4(
77686
- float(bits >> 24u) / 255.0,
77687
- float((bits >> 16u) & 0xffu) / 255.0,
77688
- float((bits >> 8u) & 0xffu) / 255.0,
77689
- float(bits & 0xffu) / 255.0
77690
- );
77691
- }
77692
77854
  const float norm = sqrt(2.0);
77693
77855
  vec4 unpackRotation(uint bits) {
77694
77856
  float a = (float((bits >> 20u) & 0x3ffu) / 1023.0 - 0.5) * norm;
@@ -78227,8 +78389,6 @@ bool initSource(out SplatSource source) {
78227
78389
  `;
78228
78390
 
78229
78391
  var gsplatVS$1 = `
78230
- #include "gsplatHelpersVS"
78231
- #include "gsplatCustomizeVS"
78232
78392
  #include "gsplatCommonVS"
78233
78393
  varying mediump vec2 gaussianUV;
78234
78394
  varying mediump vec4 gaussianColor;
@@ -78393,6 +78553,8 @@ fn readColor(source: ptr<function, SplatSource>) -> vec4f {
78393
78553
  `;
78394
78554
 
78395
78555
  var gsplatCommonVS = `
78556
+ #include "gsplatHelpersVS"
78557
+ #include "gsplatCustomizeVS"
78396
78558
  #include "gsplatStructsVS"
78397
78559
  #include "gsplatEvalSHVS"
78398
78560
  #include "gsplatQuatToMat3VS"
@@ -78409,6 +78571,7 @@ fn clipCorner(corner: ptr<function, SplatCorner>, alpha: f32) {
78409
78571
  `;
78410
78572
 
78411
78573
  var gsplatCompressedDataVS = `
78574
+ #include "gsplatPackingPS"
78412
78575
  var packedTexture: texture_2d<u32>;
78413
78576
  var chunkTexture: texture_2d<uff>;
78414
78577
  var<private> chunkDataA: vec4f;
@@ -78420,14 +78583,6 @@ var<private> packedData: vec4u;
78420
78583
  fn unpack111011(bits: u32) -> vec3f {
78421
78584
  return (vec3f((vec3<u32>(bits) >> vec3<u32>(21u, 11u, 0u)) & vec3<u32>(0x7ffu, 0x3ffu, 0x7ffu))) / vec3f(2047.0, 1023.0, 2047.0);
78422
78585
  }
78423
- fn unpack8888(bits: u32) -> vec4f {
78424
- return vec4f(
78425
- f32((bits >> 24u) & 0xffu),
78426
- f32((bits >> 16u) & 0xffu),
78427
- f32((bits >> 8u) & 0xffu),
78428
- f32(bits & 0xffu)
78429
- ) / 255.0;
78430
- }
78431
78586
  const norm_const: f32 = sqrt(2.0);
78432
78587
  fn unpackRotation(bits: u32) -> vec4f {
78433
78588
  let a = (f32((bits >> 20u) & 0x3ffu) / 1023.0 - 0.5) * norm_const;
@@ -79026,8 +79181,6 @@ fn initSource(source: ptr<function, SplatSource>) -> bool {
79026
79181
  `;
79027
79182
 
79028
79183
  var gsplatVS = `
79029
- #include "gsplatHelpersVS"
79030
- #include "gsplatCustomizeVS"
79031
79184
  #include "gsplatCommonVS"
79032
79185
  varying gaussianUV: vec2f;
79033
79186
  varying gaussianColor: vec4f;
@@ -79170,6 +79323,9 @@ class GSplatComponentSystem extends ComponentSystem {
79170
79323
  static{
79171
79324
  this.EVENT_MATERIALCREATED = 'material:created';
79172
79325
  }
79326
+ static{
79327
+ this.EVENT_FRAMEREADY = 'frame:ready';
79328
+ }
79173
79329
  constructor(app){
79174
79330
  super(app);
79175
79331
  this.id = 'gsplat';
@@ -101527,8 +101683,10 @@ class Viewer {
101527
101683
  this.cameraFrame.destroy();
101528
101684
  this.cameraFrame = null;
101529
101685
  }
101530
- camera.camera.toneMapping = tonemapTable[settings.tonemapping];
101531
- camera.camera.clearColor = new Color(background.color);
101686
+ if (!app.xr.active) {
101687
+ camera.camera.toneMapping = tonemapTable[settings.tonemapping];
101688
+ camera.camera.clearColor = new Color(background.color);
101689
+ }
101532
101690
  }
101533
101691
  }
101534
101692
  }
@@ -102060,6 +102218,7 @@ const initXr = (global) => {
102060
102218
  const cameraPosition = new Vec3();
102061
102219
  const cameraRotation = new Quat();
102062
102220
  const angles = new Vec3();
102221
+ parent.addComponent('script');
102063
102222
  parent.script.create(XrControllers);
102064
102223
  parent.script.create(XrNavigation);
102065
102224
  app.xr.on('start', () => {
@@ -102189,6 +102348,7 @@ const main = (app, camera, settingsJson, config) => {
102189
102348
  if (config.poster) {
102190
102349
  initPoster(events);
102191
102350
  }
102351
+ camera.addComponent('camera');
102192
102352
  // Initialize XR support
102193
102353
  initXr(global);
102194
102354
  // Initialize user interface