@playcanvas/supersplat-viewer 1.17.2 → 1.17.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playcanvas/supersplat-viewer",
3
- "version": "1.17.2",
3
+ "version": "1.17.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",
package/public/index.js CHANGED
@@ -72033,16 +72033,15 @@ const migrateV2 = (v1) => {
72033
72033
  animTracks: v1.animTracks.map((animTrackV1) => {
72034
72034
  return migrateAnimTrackV2(animTrackV1, v1.camera.fov || 60);
72035
72035
  }),
72036
- cameras: [{
72036
+ cameras: (v1.camera.position && v1.camera.target) ? [{
72037
72037
  initial: {
72038
- position: (v1.camera.position || [0, 0, 5]),
72039
- target: (v1.camera.target || [0, 0, 0]),
72038
+ position: v1.camera.position,
72039
+ target: v1.camera.target,
72040
72040
  fov: v1.camera.fov || 75
72041
72041
  }
72042
- }],
72042
+ }] : [],
72043
72043
  annotations: [],
72044
- startMode: v1.camera.startAnim === 'animTrack' ? 'animTrack' : 'default',
72045
- hasStartPose: !!(v1.camera.position && v1.camera.target)
72044
+ startMode: v1.camera.startAnim === 'animTrack' ? 'animTrack' : 'default'
72046
72045
  };
72047
72046
  };
72048
72047
  // import a json object to conform to the latest settings schema. settings is assumed to be one of the well-formed schemas
@@ -74177,10 +74176,13 @@ class CameraManager {
74177
74176
  // holds the camera state
74178
74177
  camera = new Camera();
74179
74178
  constructor(global, bbox, collider = null) {
74180
- const { events, settings, state } = global;
74181
- const camera0 = settings.cameras[0].initial;
74182
- const frameCamera = createFrameCamera(bbox, camera0.fov);
74183
- const resetCamera = createCamera(new Vec3(camera0.position), new Vec3(camera0.target), camera0.fov);
74179
+ const { config, events, settings, state } = global;
74180
+ const camera0 = settings.cameras[0]?.initial;
74181
+ const defaultFov = camera0?.fov ?? 75;
74182
+ const frameCamera = createFrameCamera(bbox, defaultFov);
74183
+ const resetCamera = camera0 ?
74184
+ createCamera(new Vec3(camera0.position), new Vec3(camera0.target), camera0.fov) :
74185
+ frameCamera;
74184
74186
  const getAnimTrack = (initial, isObjectExperience) => {
74185
74187
  const { animTracks } = settings;
74186
74188
  // extract the camera animation track from settings
@@ -74197,7 +74199,7 @@ class CameraManager {
74197
74199
  };
74198
74200
  // object experience starts outside the bounding box
74199
74201
  const isObjectExperience = !bbox.containsPoint(resetCamera.position);
74200
- const animTrack = getAnimTrack(settings.hasStartPose ? resetCamera : frameCamera, isObjectExperience);
74202
+ const animTrack = getAnimTrack(resetCamera, isObjectExperience);
74201
74203
  const controllers = {
74202
74204
  orbit: new OrbitController(),
74203
74205
  fly: new FlyController(),
@@ -74219,7 +74221,7 @@ class CameraManager {
74219
74221
  state.hasAnimation = !!controllers.anim;
74220
74222
  state.animationDuration = controllers.anim ? controllers.anim.animState.cursor.duration : 0;
74221
74223
  // initialize camera mode and initial camera position
74222
- state.cameraMode = state.hasAnimation ? 'anim' : (isObjectExperience ? 'orbit' : (collider ? 'walk' : 'fly'));
74224
+ state.cameraMode = (state.hasAnimation && !config.noanim) ? 'anim' : (isObjectExperience ? 'orbit' : (collider ? 'walk' : 'fly'));
74223
74225
  this.camera.copy(resetCamera);
74224
74226
  const target = new Camera(this.camera); // the active controller updates this
74225
74227
  const from = new Camera(this.camera); // stores the previous camera state during transition
@@ -75985,19 +75987,21 @@ class Viewer {
75985
75987
  const { graphicsDevice } = app;
75986
75988
  // enable anonymous CORS for image loading in safari
75987
75989
  app.loader.getHandler('texture').imgParser.crossOrigin = 'anonymous';
75990
+ // render skybox as plain equirect
75991
+ const glsl = ShaderChunks.get(graphicsDevice, 'glsl');
75992
+ glsl.set('skyboxPS', glsl.get('skyboxPS').replace('mapRoughnessUv(uv, mipLevel)', 'uv'));
75993
+ const wgsl = ShaderChunks.get(graphicsDevice, 'wgsl');
75994
+ wgsl.set('skyboxPS', wgsl.get('skyboxPS').replace('mapRoughnessUv(uv, uniform.mipLevel)', 'uv'));
75988
75995
  this.origChunks = {
75989
75996
  glsl: {
75990
- gsplatOutputVS: ShaderChunks.get(graphicsDevice, 'glsl').get('gsplatOutputVS')
75997
+ gsplatOutputVS: glsl.get('gsplatOutputVS'),
75998
+ skyboxPS: glsl.get('skyboxPS')
75991
75999
  },
75992
76000
  wgsl: {
75993
- gsplatOutputVS: ShaderChunks.get(graphicsDevice, 'wgsl').get('gsplatOutputVS')
76001
+ gsplatOutputVS: wgsl.get('gsplatOutputVS'),
76002
+ skyboxPS: wgsl.get('skyboxPS')
75994
76003
  }
75995
76004
  };
75996
- // render skybox as plain equirect
75997
- const glsl = ShaderChunks.get(graphicsDevice, 'glsl');
75998
- glsl.set('skyboxPS', glsl.get('skyboxPS').replace('mapRoughnessUv(uv, mipLevel)', 'uv'));
75999
- const wgsl = ShaderChunks.get(graphicsDevice, 'wgsl');
76000
- wgsl.set('skyboxPS', wgsl.get('skyboxPS').replace('mapRoughnessUv(uv, uniform.mipLevel)', 'uv'));
76001
76005
  // disable auto render, we'll render only when camera changes
76002
76006
  app.autoRender = false;
76003
76007
  // configure the camera
@@ -76246,6 +76250,10 @@ class Viewer {
76246
76250
  // force gsplat shader to write gamma-space colors
76247
76251
  ShaderChunks.get(app.graphicsDevice, 'glsl').set('gsplatOutputVS', gammaChunkGlsl);
76248
76252
  ShaderChunks.get(app.graphicsDevice, 'wgsl').set('gsplatOutputVS', gammaChunkWgsl);
76253
+ // force skybox shader to write gamma-space colors (inline pow replaces the
76254
+ // gammaCorrectOutput call which is a no-op under CameraFrame's GAMMA_NONE)
76255
+ ShaderChunks.get(app.graphicsDevice, 'glsl').set('skyboxPS', this.origChunks.glsl.skyboxPS.replace('gammaCorrectOutput(toneMap(processEnvironment(linear)))', 'pow(toneMap(processEnvironment(linear)) + 0.0000001, vec3(1.0 / 2.2))'));
76256
+ ShaderChunks.get(app.graphicsDevice, 'wgsl').set('skyboxPS', this.origChunks.wgsl.skyboxPS.replace('gammaCorrectOutput(toneMap(processEnvironment(linear)))', 'pow(toneMap(processEnvironment(linear)) + 0.0000001, vec3f(1.0 / 2.2))'));
76249
76257
  // ensure the final compose blit doesn't perform linear->gamma conversion.
76250
76258
  RenderTarget.prototype.isColorBufferSrgb = function (index) {
76251
76259
  return this === app.graphicsDevice.backBuffer ? true : origIsColorBufferSrgb.call(this, index);
@@ -76258,9 +76266,11 @@ class Viewer {
76258
76266
  this.cameraFrame.destroy();
76259
76267
  this.cameraFrame = null;
76260
76268
  }
76261
- // restore gsplat output shader chunks to engine defaults
76269
+ // restore shader chunks to engine defaults
76262
76270
  ShaderChunks.get(app.graphicsDevice, 'glsl').set('gsplatOutputVS', this.origChunks.glsl.gsplatOutputVS);
76263
76271
  ShaderChunks.get(app.graphicsDevice, 'wgsl').set('gsplatOutputVS', this.origChunks.wgsl.gsplatOutputVS);
76272
+ ShaderChunks.get(app.graphicsDevice, 'glsl').set('skyboxPS', this.origChunks.glsl.skyboxPS);
76273
+ ShaderChunks.get(app.graphicsDevice, 'wgsl').set('skyboxPS', this.origChunks.wgsl.skyboxPS);
76264
76274
  // restore original isColorBufferSrgb behavior
76265
76275
  RenderTarget.prototype.isColorBufferSrgb = origIsColorBufferSrgb;
76266
76276
  if (!app.xr.active) {
@@ -78134,7 +78144,7 @@ const initXr = (global) => {
78134
78144
  });
78135
78145
  };
78136
78146
 
78137
- var version = "1.17.2";
78147
+ var version = "1.17.4";
78138
78148
 
78139
78149
  const loadGsplat = async (app, config, progressCallback) => {
78140
78150
  const { contents, contentUrl, unified, aa } = config;