@playcanvas/supersplat-viewer 1.36.1 → 1.37.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/dist/viewer.js +116 -36
- package/dist/viewer.js.map +1 -1
- package/docs/api.md +4 -0
- package/package.json +6 -6
- package/public/index.js +20668 -16874
- package/public/index.js.map +1 -1
package/dist/viewer.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { AppBase, AppOptions, CameraComponentSystem, LightComponentSystem, RenderComponentSystem, GSplatComponentSystem, ScriptComponentSystem, ContainerHandler, TextureHandler, GSplatHandler, BinaryHandler, XrManager, Asset, SEMANTIC_POSITION, INDEXFORMAT_UINT32, Vec3, PROJECTION_PERSPECTIVE, math, Script, Entity, Mat4, version as version$1, Quat, Pose, OrbitController as OrbitController$1, Vec2, ShaderUtils, Texture, ADDRESS_CLAMP_TO_EDGE, FILTER_LINEAR, PIXELFORMAT_RGBA8, RenderTarget, ASPECT_AUTO, BlendState, drawQuadWithShader, Vec4, Color, PROJECTION_ORTHOGRAPHIC, ShaderChunks, FILTER_NEAREST, PIXELFORMAT_RGBA16F, RenderPassPicker, BLENDEQUATION_MIN, BLENDMODE_ONE, ShaderMaterial, CULLFACE_NONE, BLEND_NONE, PIXELFORMAT_R32F, PIXELFORMAT_R16F, GamepadSource, KeyboardMouseSource, MultiTouchSource, InputFrame,
|
|
1
|
+
import { AppBase, AppOptions, CameraComponentSystem, LightComponentSystem, RenderComponentSystem, GSplatComponentSystem, ScriptComponentSystem, ContainerHandler, TextureHandler, GSplatHandler, BinaryHandler, XrManager, Asset, SEMANTIC_POSITION, INDEXFORMAT_UINT32, Vec3, PROJECTION_PERSPECTIVE, math, Script, Entity, Mat4, version as version$1, Quat, Pose, OrbitController as OrbitController$1, Vec2, ShaderUtils, Texture, ADDRESS_CLAMP_TO_EDGE, FILTER_LINEAR, PIXELFORMAT_RGBA8, RenderTarget, ASPECT_AUTO, BlendState, drawQuadWithShader, Vec4, Color, PROJECTION_ORTHOGRAPHIC, ShaderChunks, FILTER_NEAREST, PIXELFORMAT_RGBA16F, RenderPassPicker, BLENDEQUATION_MIN, BLENDMODE_ONE, ShaderMaterial, CULLFACE_NONE, BLEND_NONE, Mesh, PRIMITIVE_TRISTRIP, GraphNode, MeshInstance, PIXELFORMAT_R32F, PIXELFORMAT_R16F, GamepadSource, KeyboardMouseSource, MultiTouchSource, InputFrame, PRIMITIVE_TRIANGLES, Layer, SORTMODE_MANUAL, CULLFACE_BACK, BLEND_NORMAL, FUNC_EQUAL, StandardMaterial, FUNC_LESSEQUAL, RENDERSTYLE_WIREFRAME, PIXELFORMAT_RGBA32F, SAMPLETYPE_UNFILTERABLE_FLOAT, SHADERLANGUAGE_WGSL, Frustum, BoundingSphere, StorageBuffer, BUFFERUSAGE_COPY_DST, Compute, BUFFERUSAGE_COPY_SRC, BindGroupFormat, BindStorageBufferFormat, BindUniformBufferFormat, SHADERSTAGE_COMPUTE, Shader, UniformBufferFormat, UniformFormat, UNIFORMTYPE_UINT, BindTextureFormat, TEXTUREDIMENSION_2D, SAMPLETYPE_DEPTH, PIXELFORMAT_DEPTH, PIXELFORMAT_RGBA16U, PIXELFORMAT_R32U, BLEND_PREMULTIPLIED, Camera as Camera$1, UNIFORMTYPE_MAT4, UNIFORMTYPE_VEC4, UNIFORMTYPE_VEC2, UNIFORMTYPE_FLOAT, RenderPass, SHADER_FORWARD, BindStorageTextureFormat, DEVICETYPE_WEBGL2, platform, BoundingBox, GSPLAT_DEBUG_LOD, GSPLAT_DEBUG_NONE, MiniStats, CameraFrame, TONEMAP_NEUTRAL, TONEMAP_ACES2, TONEMAP_ACES, TONEMAP_HEJL, TONEMAP_FILMIC, TONEMAP_LINEAR, TONEMAP_NONE, LAYERID_SKYBOX, GSPLAT_RENDERER_RASTER_GPU_SORT, GSPLAT_RENDERER_RASTER_CPU_SORT, revision, EventHandler, createGraphicsDevice, Keyboard, TouchDevice as TouchDevice$1, Mouse } from 'playcanvas';
|
|
2
2
|
import { XrControllers } from 'playcanvas/scripts/esm/xr/xr-controllers.mjs';
|
|
3
|
+
import { XrManipulation } from 'playcanvas/scripts/esm/xr/xr-manipulation.mjs';
|
|
3
4
|
import { XrNavigation } from 'playcanvas/scripts/esm/xr/xr-navigation.mjs';
|
|
4
5
|
|
|
5
6
|
class App extends AppBase {
|
|
@@ -2558,7 +2559,7 @@ const importSettings = (settings) => {
|
|
|
2558
2559
|
return result;
|
|
2559
2560
|
};
|
|
2560
2561
|
|
|
2561
|
-
var version = "1.
|
|
2562
|
+
var version = "1.37.0";
|
|
2562
2563
|
|
|
2563
2564
|
class Tooltip {
|
|
2564
2565
|
register;
|
|
@@ -7884,6 +7885,7 @@ class PickDepthOverlay {
|
|
|
7884
7885
|
picker;
|
|
7885
7886
|
resolveShader;
|
|
7886
7887
|
material = new ShaderMaterial();
|
|
7888
|
+
quad;
|
|
7887
7889
|
depthTarget = null;
|
|
7888
7890
|
onFrameEnd = () => this.resolve();
|
|
7889
7891
|
onPrerender = () => this.draw();
|
|
@@ -7929,6 +7931,20 @@ class PickDepthOverlay {
|
|
|
7929
7931
|
attributes: { vertex_position: SEMANTIC_POSITION }
|
|
7930
7932
|
};
|
|
7931
7933
|
material.update();
|
|
7934
|
+
// fullscreen quad in the default draw layer, shown on frames draw() allows; the node is
|
|
7935
|
+
// outside the hierarchy, so its fixed transform is synced here once
|
|
7936
|
+
const mesh = new Mesh(app.graphicsDevice);
|
|
7937
|
+
mesh.setPositions([-0.5, -0.5, 0, 0.5, -0.5, 0, -0.5, 0.5, 0, 0.5, 0.5, 0]);
|
|
7938
|
+
mesh.update(PRIMITIVE_TRISTRIP);
|
|
7939
|
+
const node = new GraphNode('PickDepthColour');
|
|
7940
|
+
node.setLocalScale(2, -2, 1);
|
|
7941
|
+
node.getWorldTransform();
|
|
7942
|
+
this.quad = new MeshInstance(mesh, material, node);
|
|
7943
|
+
this.quad.cull = false;
|
|
7944
|
+
this.quad.castShadow = false;
|
|
7945
|
+
this.quad.pick = false;
|
|
7946
|
+
this.quad.visible = false;
|
|
7947
|
+
app.scene.defaultDrawLayer.addMeshInstances([this.quad], true);
|
|
7932
7948
|
}
|
|
7933
7949
|
get enabled() {
|
|
7934
7950
|
return this._enabled;
|
|
@@ -7945,6 +7961,7 @@ class PickDepthOverlay {
|
|
|
7945
7961
|
this.app.off('frameend', this.onFrameEnd);
|
|
7946
7962
|
this.app.off('prerender', this.onPrerender);
|
|
7947
7963
|
this.resolvedRenders = -1;
|
|
7964
|
+
this.quad.visible = false;
|
|
7948
7965
|
}
|
|
7949
7966
|
this.app.renderNextFrame = true;
|
|
7950
7967
|
}
|
|
@@ -7989,14 +8006,17 @@ class PickDepthOverlay {
|
|
|
7989
8006
|
this.app.renderNextFrame = true;
|
|
7990
8007
|
}
|
|
7991
8008
|
draw() {
|
|
8009
|
+
this.quad.visible = false;
|
|
7992
8010
|
// nothing resolved yet: the first frame's end resolves, and asks for the next
|
|
7993
8011
|
if (!this.depthTarget || this.resolvedRenders < 0 || this.camera.camera.renderTarget)
|
|
7994
8012
|
return;
|
|
7995
8013
|
this.material.setParameter('surfaceDepth', this.depthTarget.colorBuffer);
|
|
7996
|
-
this.
|
|
8014
|
+
this.quad.visible = true;
|
|
7997
8015
|
}
|
|
7998
8016
|
destroy() {
|
|
7999
8017
|
this.enabled = false;
|
|
8018
|
+
this.app.scene.defaultDrawLayer.removeMeshInstances([this.quad], true);
|
|
8019
|
+
this.quad.destroy();
|
|
8000
8020
|
this.material.destroy();
|
|
8001
8021
|
this.resolveShader.destroy();
|
|
8002
8022
|
this.depthTarget?.colorBuffer.destroy();
|
|
@@ -14167,6 +14187,7 @@ class VoxelDebugOverlay {
|
|
|
14167
14187
|
compute;
|
|
14168
14188
|
storageTexture;
|
|
14169
14189
|
overlayMaterial;
|
|
14190
|
+
quad;
|
|
14170
14191
|
nodesBuffer;
|
|
14171
14192
|
leafDataBuffer;
|
|
14172
14193
|
collision;
|
|
@@ -14286,6 +14307,20 @@ class VoxelDebugOverlay {
|
|
|
14286
14307
|
attributes: { vertex_position: SEMANTIC_POSITION }
|
|
14287
14308
|
};
|
|
14288
14309
|
this.overlayMaterial.update();
|
|
14310
|
+
// Fullscreen quad in the default draw layer, shown on frames update() composites.
|
|
14311
|
+
// The node is outside the hierarchy, so its fixed transform is synced here once.
|
|
14312
|
+
const mesh = new Mesh(device);
|
|
14313
|
+
mesh.setPositions([-0.5, -0.5, 0, 0.5, -0.5, 0, -0.5, 0.5, 0, 0.5, 0.5, 0]);
|
|
14314
|
+
mesh.update(PRIMITIVE_TRISTRIP);
|
|
14315
|
+
const node = new GraphNode('VoxelOverlayComposite');
|
|
14316
|
+
node.setLocalScale(2, -2, 1);
|
|
14317
|
+
node.getWorldTransform();
|
|
14318
|
+
this.quad = new MeshInstance(mesh, this.overlayMaterial, node);
|
|
14319
|
+
this.quad.cull = false;
|
|
14320
|
+
this.quad.castShadow = false;
|
|
14321
|
+
this.quad.pick = false;
|
|
14322
|
+
this.quad.visible = false;
|
|
14323
|
+
app.scene.defaultDrawLayer.addMeshInstances([this.quad], true);
|
|
14289
14324
|
}
|
|
14290
14325
|
createStorageTexture(width, height) {
|
|
14291
14326
|
return new Texture(this.app.graphicsDevice, {
|
|
@@ -14300,6 +14335,7 @@ class VoxelDebugOverlay {
|
|
|
14300
14335
|
});
|
|
14301
14336
|
}
|
|
14302
14337
|
update() {
|
|
14338
|
+
this.quad.visible = false;
|
|
14303
14339
|
if (!this.enabled || this.collision.nodes.length === 0)
|
|
14304
14340
|
return;
|
|
14305
14341
|
const { app, camera, compute, collision } = this;
|
|
@@ -14371,9 +14407,11 @@ class VoxelDebugOverlay {
|
|
|
14371
14407
|
compute.setupDispatch(workgroupsX, workgroupsY, 1);
|
|
14372
14408
|
device.computeDispatch([compute], 'VoxelDebugOverlay');
|
|
14373
14409
|
// Composite overlay on top of the scene
|
|
14374
|
-
|
|
14410
|
+
this.quad.visible = true;
|
|
14375
14411
|
}
|
|
14376
14412
|
destroy() {
|
|
14413
|
+
this.app.scene.defaultDrawLayer.removeMeshInstances([this.quad], true);
|
|
14414
|
+
this.quad.destroy();
|
|
14377
14415
|
this.compute.destroy();
|
|
14378
14416
|
this.compute.shader.destroy();
|
|
14379
14417
|
this.overlayMaterial.destroy();
|
|
@@ -14383,7 +14421,11 @@ class VoxelDebugOverlay {
|
|
|
14383
14421
|
}
|
|
14384
14422
|
}
|
|
14385
14423
|
|
|
14386
|
-
//
|
|
14424
|
+
// Standalone headsets run XR on a mobile gpu, which draws every splat once per eye, but their
|
|
14425
|
+
// browsers report a desktop platform. Their sessions render with fixed foveation and a 72 Hz
|
|
14426
|
+
// target, at 0.8x resolution in performance mode, and the viewer lowers the splat budget.
|
|
14427
|
+
const standaloneHeadset = /OculusBrowser|PicoBrowser/.test(globalThis.navigator?.userAgent ?? '');
|
|
14428
|
+
// The viewer reconfigures the camera (clear color, post effects) when state.xrMode changes
|
|
14387
14429
|
const initXr = (global) => {
|
|
14388
14430
|
const { app, events, state, camera, renderer, root } = global;
|
|
14389
14431
|
const { xr } = app;
|
|
@@ -14422,15 +14464,17 @@ const initXr = (global) => {
|
|
|
14422
14464
|
});
|
|
14423
14465
|
}
|
|
14424
14466
|
const parent = camera.parent;
|
|
14425
|
-
const clearColor = new Color();
|
|
14426
14467
|
const parentPosition = new Vec3();
|
|
14427
14468
|
const parentRotation = new Quat();
|
|
14428
14469
|
const cameraPosition = new Vec3();
|
|
14429
14470
|
const cameraRotation = new Quat();
|
|
14430
|
-
const angles = new Vec3();
|
|
14431
14471
|
parent.addComponent('script');
|
|
14432
14472
|
parent.script.create(XrControllers);
|
|
14433
14473
|
parent.script.create(XrNavigation);
|
|
14474
|
+
// Grabbing with both hands drags, turns and scales the scene. Created once the splat entity
|
|
14475
|
+
// it moves has loaded, which is before XR can start, and put back when the session ends, as
|
|
14476
|
+
// the viewer's camera, collision and annotations assume the authored placement.
|
|
14477
|
+
let manipulation = null;
|
|
14434
14478
|
const started = xr.on('start', () => {
|
|
14435
14479
|
if (destroyed)
|
|
14436
14480
|
return;
|
|
@@ -14440,14 +14484,30 @@ const initXr = (global) => {
|
|
|
14440
14484
|
parentRotation.copy(parent.getRotation());
|
|
14441
14485
|
cameraPosition.copy(camera.getPosition());
|
|
14442
14486
|
cameraRotation.copy(camera.getRotation());
|
|
14443
|
-
|
|
14444
|
-
//
|
|
14445
|
-
|
|
14446
|
-
|
|
14447
|
-
|
|
14448
|
-
|
|
14449
|
-
|
|
14487
|
+
// Start the session where the camera is, facing its heading with pitch and roll reset:
|
|
14488
|
+
// where it looks across the ground, or where the top of its view points when it looks
|
|
14489
|
+
// straight up or down. The yaw of getEulerAngles() only covers -90 to 90 degrees, so a
|
|
14490
|
+
// camera facing further round would start the session facing the wrong way.
|
|
14491
|
+
const { forward } = camera;
|
|
14492
|
+
let x = forward.x;
|
|
14493
|
+
let z = forward.z;
|
|
14494
|
+
if (x * x + z * z < 1e-6) {
|
|
14495
|
+
const { up } = camera;
|
|
14496
|
+
const sign = forward.y < 0 ? 1 : -1;
|
|
14497
|
+
x = up.x * sign;
|
|
14498
|
+
z = up.z * sign;
|
|
14450
14499
|
}
|
|
14500
|
+
parent.setPosition(cameraPosition.x, 0, cameraPosition.z);
|
|
14501
|
+
parent.setEulerAngles(0, Math.atan2(-x, -z) * math.RAD_TO_DEG, 0);
|
|
14502
|
+
if (standaloneHeadset) {
|
|
14503
|
+
xr.fixedFoveation = 1;
|
|
14504
|
+
if (xr.supportedFrameRates?.includes(72))
|
|
14505
|
+
xr.updateTargetFrameRate(72);
|
|
14506
|
+
}
|
|
14507
|
+
// AR scales about the hands, for content brought to a tabletop; VR about the feet, so
|
|
14508
|
+
// the user stays standing on the scene
|
|
14509
|
+
if (manipulation)
|
|
14510
|
+
manipulation.scalePivot = xr.type === 'immersive-ar' ? 'hands' : 'feet';
|
|
14451
14511
|
state.xrMode = xr.type === 'immersive-ar' ? 'ar' : 'vr';
|
|
14452
14512
|
});
|
|
14453
14513
|
const ended = xr.on('end', () => {
|
|
@@ -14459,9 +14519,7 @@ const initXr = (global) => {
|
|
|
14459
14519
|
parent.setRotation(parentRotation);
|
|
14460
14520
|
camera.setPosition(cameraPosition);
|
|
14461
14521
|
camera.setRotation(cameraRotation);
|
|
14462
|
-
|
|
14463
|
-
camera.camera.clearColor = clearColor;
|
|
14464
|
-
}
|
|
14522
|
+
manipulation?.reset();
|
|
14465
14523
|
state.xrMode = null;
|
|
14466
14524
|
// Restore the canvas to the correct position in the DOM after exiting XR. In
|
|
14467
14525
|
// some browsers (e.g. Chrome on Android) the canvas is moved to a new root
|
|
@@ -14495,6 +14553,7 @@ const initXr = (global) => {
|
|
|
14495
14553
|
await new Promise((resolve, reject) => {
|
|
14496
14554
|
rejectStart = reject;
|
|
14497
14555
|
xr.start(camera.camera, type, 'local-floor', {
|
|
14556
|
+
framebufferScaleFactor: standaloneHeadset && state.performanceMode ? 0.8 : 1,
|
|
14498
14557
|
callback: (error) => {
|
|
14499
14558
|
if (destroyed) {
|
|
14500
14559
|
// Browser session requests cannot be cancelled. Close a late result.
|
|
@@ -14564,6 +14623,11 @@ const initXr = (global) => {
|
|
|
14564
14623
|
return {
|
|
14565
14624
|
start,
|
|
14566
14625
|
end,
|
|
14626
|
+
setManipulationTarget: (entity) => {
|
|
14627
|
+
manipulation = parent.script.create(XrManipulation, {
|
|
14628
|
+
properties: { target: entity }
|
|
14629
|
+
});
|
|
14630
|
+
},
|
|
14567
14631
|
destroy: () => {
|
|
14568
14632
|
destroyed = true;
|
|
14569
14633
|
availability.off();
|
|
@@ -14613,6 +14677,16 @@ const budgets = {
|
|
|
14613
14677
|
high: 4
|
|
14614
14678
|
}
|
|
14615
14679
|
};
|
|
14680
|
+
// budget while an XR session runs on a standalone headset, millions of splats. On a Quest 3,
|
|
14681
|
+
// 1M splats render at about 30 fps (40 at 0.8x resolution), against 10 fps at the 4M desktop
|
|
14682
|
+
// budget it otherwise gets
|
|
14683
|
+
const standaloneXrBudget = 1;
|
|
14684
|
+
// how much further away parts of the scene behind the camera count when choosing their detail,
|
|
14685
|
+
// which saves a lot of splats while orbiting, and the turn after which detail is chosen again.
|
|
14686
|
+
// XR sessions choose detail by distance alone, with no penalty and no turn-triggered choices: a
|
|
14687
|
+
// head turning less than 90 degrees brought the coarse detail chosen for behind it into view
|
|
14688
|
+
const lodBehindPenalty = 5;
|
|
14689
|
+
const lodUpdateAngle = 90;
|
|
14616
14690
|
const tonemapTable = {
|
|
14617
14691
|
none: TONEMAP_NONE,
|
|
14618
14692
|
linear: TONEMAP_LINEAR,
|
|
@@ -14796,19 +14870,15 @@ class Viewer {
|
|
|
14796
14870
|
}
|
|
14797
14871
|
}
|
|
14798
14872
|
// reconfigure camera when entering/exiting XR. The stochastic renderer has no stereo
|
|
14799
|
-
// path yet, so the engine's renderer draws the splats for the session
|
|
14800
|
-
|
|
14873
|
+
// path yet, so the engine's renderer draws the splats for the session. Follows xrMode
|
|
14874
|
+
// rather than app.xr.active, which still reports the session while its 'end' handlers run
|
|
14875
|
+
const xrModeChanged = events.on('xrMode:changed', () => {
|
|
14801
14876
|
if (this.destroyed)
|
|
14802
14877
|
return;
|
|
14803
14878
|
this.configureCamera(settings);
|
|
14804
|
-
this.splatRenderer?.setEnabled(
|
|
14805
|
-
};
|
|
14806
|
-
const xrStart = app.xr.on('start', configureXrCamera);
|
|
14807
|
-
const xrEnd = app.xr.on('end', configureXrCamera);
|
|
14808
|
-
this.onDestroy(() => {
|
|
14809
|
-
xrStart.off();
|
|
14810
|
-
xrEnd.off();
|
|
14879
|
+
this.splatRenderer?.setEnabled(state.xrMode === null);
|
|
14811
14880
|
});
|
|
14881
|
+
this.onDestroy(() => xrModeChanged.off());
|
|
14812
14882
|
// debug ministats, from the flag at start and the debug panel's toggle after
|
|
14813
14883
|
this.setMiniStats(config.ministats);
|
|
14814
14884
|
this.onDestroy(() => {
|
|
@@ -14904,9 +14974,8 @@ class Viewer {
|
|
|
14904
14974
|
// frame after the gsplat component is created, and lodUpdateAngle / lodBehindPenalty shape
|
|
14905
14975
|
// which nodes that first pass pulls in.
|
|
14906
14976
|
// these two allow LOD behind camera to drop, saves lots of splats
|
|
14907
|
-
gsplat.lodUpdateAngle =
|
|
14908
|
-
gsplat.lodBehindPenalty =
|
|
14909
|
-
gsplat.lodMode = GSPLAT_LODMODE_DISTANCE;
|
|
14977
|
+
gsplat.lodUpdateAngle = lodUpdateAngle;
|
|
14978
|
+
gsplat.lodBehindPenalty = lodBehindPenalty;
|
|
14910
14979
|
gsplat.minContribution = 1;
|
|
14911
14980
|
gsplat.alphaClip = 1 / 255;
|
|
14912
14981
|
gsplat.antiAlias = config.aa;
|
|
@@ -14999,6 +15068,7 @@ class Viewer {
|
|
|
14999
15068
|
if (this.destroyed)
|
|
15000
15069
|
return;
|
|
15001
15070
|
const gsplatComponent = results[0].gsplat;
|
|
15071
|
+
this.xr.setManipulationTarget(results[0]);
|
|
15002
15072
|
// get scene bounding box
|
|
15003
15073
|
const gsplatBbox = gsplatComponent.customAabb;
|
|
15004
15074
|
if (gsplatBbox) {
|
|
@@ -15068,11 +15138,16 @@ class Viewer {
|
|
|
15068
15138
|
if (config.budget !== undefined && Number.isFinite(config.budget) && config.budget > 0) {
|
|
15069
15139
|
return config.budget;
|
|
15070
15140
|
}
|
|
15141
|
+
if (standaloneHeadset && state.xrMode !== null) {
|
|
15142
|
+
return standaloneXrBudget;
|
|
15143
|
+
}
|
|
15071
15144
|
const quality = platform.mobile ? budgets.mobile : budgets.desktop;
|
|
15072
15145
|
return state.performanceMode ? quality.low : quality.high;
|
|
15073
15146
|
};
|
|
15074
15147
|
gsplat.splatBudget = budget() * 1000000;
|
|
15075
15148
|
gsplat.colorUpdateAngle = state.performanceMode ? 1 : 0.2;
|
|
15149
|
+
gsplat.lodBehindPenalty = state.xrMode === null ? lodBehindPenalty : 1;
|
|
15150
|
+
gsplat.lodUpdateAngle = state.xrMode === null ? lodUpdateAngle : 0;
|
|
15076
15151
|
gsplatComponent.lodRangeMin = 0;
|
|
15077
15152
|
gsplatComponent.lodRangeMax = 1000;
|
|
15078
15153
|
// request a frame so the param changes are processed (full work-buffer
|
|
@@ -15116,6 +15191,7 @@ class Viewer {
|
|
|
15116
15191
|
app.autoRender = false;
|
|
15117
15192
|
// handle quality mode changes
|
|
15118
15193
|
events.on('performanceMode:changed', applyPerfSettings);
|
|
15194
|
+
events.on('xrMode:changed', applyPerfSettings);
|
|
15119
15195
|
applyPerfSettings();
|
|
15120
15196
|
// the stochastic renderer consumes the engine's world under whatever
|
|
15121
15197
|
// renderer mode the engine resolved; switching modes here would rebuild
|
|
@@ -15385,13 +15461,14 @@ class Viewer {
|
|
|
15385
15461
|
// configure camera based on application mode and post process settings
|
|
15386
15462
|
configureCamera(settings) {
|
|
15387
15463
|
const { global } = this;
|
|
15388
|
-
const { app, config, camera } = global;
|
|
15464
|
+
const { app, config, camera, state } = global;
|
|
15389
15465
|
const { postEffectSettings } = settings;
|
|
15390
15466
|
const { background } = settings;
|
|
15391
15467
|
// hpr override takes precedence over settings.highPrecisionRendering
|
|
15392
15468
|
const highPrecisionRendering = config.hpr ?? settings.highPrecisionRendering;
|
|
15393
15469
|
const postFxRequested = !config.nofx && (anyPostEffectEnabled(postEffectSettings) || highPrecisionRendering);
|
|
15394
|
-
|
|
15470
|
+
// CameraFrame has no XR path, so post effects are off for the session
|
|
15471
|
+
const enableCameraFrame = state.xrMode === null && postFxRequested;
|
|
15395
15472
|
if (enableCameraFrame) {
|
|
15396
15473
|
// create instance
|
|
15397
15474
|
if (!this.cameraFrame) {
|
|
@@ -15429,11 +15506,14 @@ class Viewer {
|
|
|
15429
15506
|
ShaderChunks.get(app.graphicsDevice, 'wgsl').set('skyboxPS', this.origChunks.wgsl.skyboxPS);
|
|
15430
15507
|
// restore original isColorBufferSrgb behavior
|
|
15431
15508
|
setBackBufferSrgb(app.graphicsDevice, false);
|
|
15432
|
-
|
|
15433
|
-
|
|
15434
|
-
|
|
15435
|
-
|
|
15436
|
-
|
|
15509
|
+
camera.camera.toneMapping = tonemapTable[settings.tonemapping];
|
|
15510
|
+
// AR composites the scene over the passthrough view
|
|
15511
|
+
camera.camera.clearColor = state.xrMode === 'ar' ? new Color(0, 0, 0, 0) : new Color(background.color);
|
|
15512
|
+
}
|
|
15513
|
+
// the sky would cover AR's passthrough view entirely, so it is hidden for the session
|
|
15514
|
+
const skyLayer = app.scene.layers.getLayerById(LAYERID_SKYBOX);
|
|
15515
|
+
if (skyLayer)
|
|
15516
|
+
skyLayer.enabled = state.xrMode !== 'ar';
|
|
15437
15517
|
// Mesh overlay bakes its vertex colors based on the current gamma
|
|
15438
15518
|
// path; reapply when CameraFrame is created/destroyed (e.g. on XR
|
|
15439
15519
|
// start/end) so the overlay tracks the new path.
|