@playcanvas/supersplat-viewer 1.16.13 → 1.17.1
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 +7 -7
- package/public/index.js +469 -301
- package/public/index.js.map +1 -1
package/public/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const TRACEID_GPU_TIMINGS = 'GpuTimings';
|
|
2
2
|
|
|
3
|
-
const version$1 = '2.17.0
|
|
4
|
-
const revision = '
|
|
3
|
+
const version$1 = '2.17.0';
|
|
4
|
+
const revision = '4322c03';
|
|
5
5
|
function extend(target, ex) {
|
|
6
6
|
for(const prop in ex){
|
|
7
7
|
const copy = ex[prop];
|
|
@@ -3675,6 +3675,8 @@ const CLEARFLAG_STENCIL = 4;
|
|
|
3675
3675
|
const CULLFACE_NONE = 0;
|
|
3676
3676
|
const CULLFACE_BACK = 1;
|
|
3677
3677
|
const CULLFACE_FRONT = 2;
|
|
3678
|
+
const FRONTFACE_CCW = 0;
|
|
3679
|
+
const FRONTFACE_CW = 1;
|
|
3678
3680
|
const FILTER_NEAREST = 0;
|
|
3679
3681
|
const FILTER_LINEAR = 1;
|
|
3680
3682
|
const FILTER_NEAREST_MIPMAP_NEAREST = 2;
|
|
@@ -6544,6 +6546,7 @@ class GraphicsDevice extends EventHandler {
|
|
|
6544
6546
|
this.blendState = new BlendState();
|
|
6545
6547
|
this.depthState = new DepthState();
|
|
6546
6548
|
this.cullMode = CULLFACE_BACK;
|
|
6549
|
+
this.frontFace = FRONTFACE_CCW;
|
|
6547
6550
|
this.vx = this.vy = this.vw = this.vh = 0;
|
|
6548
6551
|
this.sx = this.sy = this.sw = this.sh = 0;
|
|
6549
6552
|
this.blendColor = new Color(0, 0, 0, 0);
|
|
@@ -6553,6 +6556,14 @@ class GraphicsDevice extends EventHandler {
|
|
|
6553
6556
|
setBlendColor(r, g, b, a) {}
|
|
6554
6557
|
setDepthState(depthState) {}
|
|
6555
6558
|
setCullMode(cullMode) {}
|
|
6559
|
+
setFrontFace(frontFace) {}
|
|
6560
|
+
setDrawStates(blendState = BlendState.NOBLEND, depthState = DepthState.NODEPTH, cullMode = CULLFACE_NONE, frontFace = FRONTFACE_CCW, stencilFront, stencilBack) {
|
|
6561
|
+
this.setBlendState(blendState);
|
|
6562
|
+
this.setDepthState(depthState);
|
|
6563
|
+
this.setCullMode(cullMode);
|
|
6564
|
+
this.setFrontFace(frontFace);
|
|
6565
|
+
this.setStencilState(stencilFront, stencilBack);
|
|
6566
|
+
}
|
|
6556
6567
|
setRenderTarget(renderTarget) {
|
|
6557
6568
|
this.renderTarget = renderTarget;
|
|
6558
6569
|
}
|
|
@@ -7409,6 +7420,10 @@ const _cullModes = [
|
|
|
7409
7420
|
'back',
|
|
7410
7421
|
'front'
|
|
7411
7422
|
];
|
|
7423
|
+
const _frontFace = [
|
|
7424
|
+
'ccw',
|
|
7425
|
+
'cw'
|
|
7426
|
+
];
|
|
7412
7427
|
const _stencilOps = [
|
|
7413
7428
|
'keep',
|
|
7414
7429
|
'zero',
|
|
@@ -7427,7 +7442,7 @@ const _indexFormat = [
|
|
|
7427
7442
|
let CacheEntry$1 = class CacheEntry {
|
|
7428
7443
|
};
|
|
7429
7444
|
class WebgpuRenderPipeline extends WebgpuPipeline {
|
|
7430
|
-
get(primitive, vertexFormat0, vertexFormat1, ibFormat, shader, renderTarget, bindGroupFormats, blendState, depthState, cullMode, stencilEnabled, stencilFront, stencilBack) {
|
|
7445
|
+
get(primitive, vertexFormat0, vertexFormat1, ibFormat, shader, renderTarget, bindGroupFormats, blendState, depthState, cullMode, stencilEnabled, stencilFront, stencilBack, frontFace) {
|
|
7431
7446
|
const primitiveType = primitive.type;
|
|
7432
7447
|
if (ibFormat && primitiveType !== PRIMITIVE_LINESTRIP && primitiveType !== PRIMITIVE_TRISTRIP) {
|
|
7433
7448
|
ibFormat = undefined;
|
|
@@ -7447,6 +7462,7 @@ class WebgpuRenderPipeline extends WebgpuPipeline {
|
|
|
7447
7462
|
lookupHashes[11] = stencilEnabled ? stencilFront.key : 0;
|
|
7448
7463
|
lookupHashes[12] = stencilEnabled ? stencilBack.key : 0;
|
|
7449
7464
|
lookupHashes[13] = ibFormat ?? 0;
|
|
7465
|
+
lookupHashes[14] = frontFace;
|
|
7450
7466
|
const hash = hash32Fnv1a(lookupHashes);
|
|
7451
7467
|
let cacheEntries = this.cache.get(hash);
|
|
7452
7468
|
if (cacheEntries) {
|
|
@@ -7462,7 +7478,7 @@ class WebgpuRenderPipeline extends WebgpuPipeline {
|
|
|
7462
7478
|
const vertexBufferLayout = this.vertexBufferLayout.get(vertexFormat0, vertexFormat1);
|
|
7463
7479
|
const cacheEntry = new CacheEntry$1();
|
|
7464
7480
|
cacheEntry.hashes = new Uint32Array(lookupHashes);
|
|
7465
|
-
cacheEntry.pipeline = this.create(primitiveTopology, ibFormat, shader, renderTarget, pipelineLayout, blendState, depthState, vertexBufferLayout, cullMode, stencilEnabled, stencilFront, stencilBack);
|
|
7481
|
+
cacheEntry.pipeline = this.create(primitiveTopology, ibFormat, shader, renderTarget, pipelineLayout, blendState, depthState, vertexBufferLayout, cullMode, stencilEnabled, stencilFront, stencilBack, frontFace);
|
|
7466
7482
|
if (cacheEntries) {
|
|
7467
7483
|
cacheEntries.push(cacheEntry);
|
|
7468
7484
|
} else {
|
|
@@ -7527,7 +7543,7 @@ class WebgpuRenderPipeline extends WebgpuPipeline {
|
|
|
7527
7543
|
}
|
|
7528
7544
|
return depthStencil;
|
|
7529
7545
|
}
|
|
7530
|
-
create(primitiveTopology, ibFormat, shader, renderTarget, pipelineLayout, blendState, depthState, vertexBufferLayout, cullMode, stencilEnabled, stencilFront, stencilBack) {
|
|
7546
|
+
create(primitiveTopology, ibFormat, shader, renderTarget, pipelineLayout, blendState, depthState, vertexBufferLayout, cullMode, stencilEnabled, stencilFront, stencilBack, frontFace) {
|
|
7531
7547
|
const wgpu = this.device.wgpu;
|
|
7532
7548
|
const webgpuShader = shader.impl;
|
|
7533
7549
|
const desc = {
|
|
@@ -7538,7 +7554,7 @@ class WebgpuRenderPipeline extends WebgpuPipeline {
|
|
|
7538
7554
|
},
|
|
7539
7555
|
primitive: {
|
|
7540
7556
|
topology: primitiveTopology,
|
|
7541
|
-
frontFace:
|
|
7557
|
+
frontFace: _frontFace[frontFace],
|
|
7542
7558
|
cullMode: _cullModes[cullMode]
|
|
7543
7559
|
},
|
|
7544
7560
|
depthStencil: this.getDepthStencil(depthState, renderTarget, stencilEnabled, stencilFront, stencilBack, primitiveTopology),
|
|
@@ -7575,7 +7591,7 @@ class WebgpuRenderPipeline extends WebgpuPipeline {
|
|
|
7575
7591
|
return pipeline;
|
|
7576
7592
|
}
|
|
7577
7593
|
constructor(device){
|
|
7578
|
-
super(device), this.lookupHashes = new Uint32Array(
|
|
7594
|
+
super(device), this.lookupHashes = new Uint32Array(15);
|
|
7579
7595
|
this.vertexBufferLayout = new WebgpuVertexBufferLayout();
|
|
7580
7596
|
this.cache = new Map();
|
|
7581
7597
|
}
|
|
@@ -10705,25 +10721,27 @@ class WebgpuClearRenderer {
|
|
|
10705
10721
|
uniformBuffer.startUpdate(dynamicBindGroup);
|
|
10706
10722
|
device.setBindGroup(BINDGROUP_MESH_UB, dynamicBindGroup.bindGroup, dynamicBindGroup.offsets);
|
|
10707
10723
|
device.setBindGroup(BINDGROUP_MESH, device.emptyBindGroup);
|
|
10724
|
+
let blendState;
|
|
10708
10725
|
if (flags & CLEARFLAG_COLOR && (renderTarget.colorBuffer || renderTarget.impl.assignedColorTexture)) {
|
|
10709
10726
|
const color = options.color ?? defaultOptions.color;
|
|
10710
10727
|
this.colorData.set(color);
|
|
10711
|
-
|
|
10728
|
+
blendState = BlendState.NOBLEND;
|
|
10712
10729
|
} else {
|
|
10713
|
-
|
|
10730
|
+
blendState = BlendState.NOWRITE;
|
|
10714
10731
|
}
|
|
10715
10732
|
uniformBuffer.set('color', this.colorData);
|
|
10733
|
+
let depthState;
|
|
10716
10734
|
if (flags & CLEARFLAG_DEPTH && renderTarget.depth) {
|
|
10717
10735
|
const depth = options.depth ?? defaultOptions.depth;
|
|
10718
10736
|
uniformBuffer.set('depth', depth);
|
|
10719
|
-
|
|
10737
|
+
depthState = DepthState.WRITEDEPTH;
|
|
10720
10738
|
} else {
|
|
10721
10739
|
uniformBuffer.set('depth', 1);
|
|
10722
|
-
|
|
10740
|
+
depthState = DepthState.NODEPTH;
|
|
10723
10741
|
}
|
|
10724
10742
|
if (flags & CLEARFLAG_STENCIL && renderTarget.stencil) ;
|
|
10725
10743
|
uniformBuffer.endUpdate();
|
|
10726
|
-
device.
|
|
10744
|
+
device.setDrawStates(blendState, depthState);
|
|
10727
10745
|
device.setShader(this.shader);
|
|
10728
10746
|
device.draw(primitive);
|
|
10729
10747
|
}
|
|
@@ -11830,7 +11848,7 @@ class WebgpuGraphicsDevice extends GraphicsDevice {
|
|
|
11830
11848
|
this.submitVertexBuffer(vb1, vbSlot);
|
|
11831
11849
|
}
|
|
11832
11850
|
}
|
|
11833
|
-
pipeline = this.renderPipeline.get(primitive, vb0?.format, vb1?.format, indexBuffer?.format, this.shader, this.renderTarget, this.bindGroupFormats, this.blendState, this.depthState, this.cullMode, this.stencilEnabled, this.stencilFront, this.stencilBack);
|
|
11851
|
+
pipeline = this.renderPipeline.get(primitive, vb0?.format, vb1?.format, indexBuffer?.format, this.shader, this.renderTarget, this.bindGroupFormats, this.blendState, this.depthState, this.cullMode, this.stencilEnabled, this.stencilFront, this.stencilBack, this.frontFace);
|
|
11834
11852
|
if (this.pipeline !== pipeline) {
|
|
11835
11853
|
this.pipeline = pipeline;
|
|
11836
11854
|
passEncoder.setPipeline(pipeline);
|
|
@@ -11900,6 +11918,9 @@ class WebgpuGraphicsDevice extends GraphicsDevice {
|
|
|
11900
11918
|
setCullMode(cullMode) {
|
|
11901
11919
|
this.cullMode = cullMode;
|
|
11902
11920
|
}
|
|
11921
|
+
setFrontFace(frontFace) {
|
|
11922
|
+
this.frontFace = frontFace;
|
|
11923
|
+
}
|
|
11903
11924
|
setAlphaToCoverage(state) {}
|
|
11904
11925
|
initializeContextCaches() {
|
|
11905
11926
|
super.initializeContextCaches();
|
|
@@ -14717,6 +14738,13 @@ class WebglGraphicsDevice extends GraphicsDevice {
|
|
|
14717
14738
|
this.cullMode = cullMode;
|
|
14718
14739
|
}
|
|
14719
14740
|
}
|
|
14741
|
+
setFrontFace(frontFace) {
|
|
14742
|
+
if (this.frontFace !== frontFace) {
|
|
14743
|
+
const mode = this.glFrontFace[frontFace];
|
|
14744
|
+
this.gl.frontFace(mode);
|
|
14745
|
+
this.frontFace = frontFace;
|
|
14746
|
+
}
|
|
14747
|
+
}
|
|
14720
14748
|
setShader(shader, asyncCompile = false) {
|
|
14721
14749
|
if (shader !== this.shader) {
|
|
14722
14750
|
this.shader = shader;
|
|
@@ -14918,6 +14946,10 @@ class WebglGraphicsDevice extends GraphicsDevice {
|
|
|
14918
14946
|
gl.FRONT,
|
|
14919
14947
|
gl.FRONT_AND_BACK
|
|
14920
14948
|
];
|
|
14949
|
+
this.glFrontFace = [
|
|
14950
|
+
gl.CCW,
|
|
14951
|
+
gl.CW
|
|
14952
|
+
];
|
|
14921
14953
|
this.glFilter = [
|
|
14922
14954
|
gl.NEAREST,
|
|
14923
14955
|
gl.LINEAR,
|
|
@@ -15268,6 +15300,7 @@ class NullGraphicsDevice extends GraphicsDevice {
|
|
|
15268
15300
|
setStencilState(stencilFront, stencilBack) {}
|
|
15269
15301
|
setBlendColor(r, g, b, a) {}
|
|
15270
15302
|
setCullMode(cullMode) {}
|
|
15303
|
+
setFrontFace(frontFace) {}
|
|
15271
15304
|
setAlphaToCoverage(state) {}
|
|
15272
15305
|
initializeContextCaches() {
|
|
15273
15306
|
super.initializeContextCaches();
|
|
@@ -17216,9 +17249,7 @@ class QuadRender {
|
|
|
17216
17249
|
class RenderPassQuad extends RenderPass {
|
|
17217
17250
|
execute() {
|
|
17218
17251
|
const { device } = this;
|
|
17219
|
-
device.
|
|
17220
|
-
device.setDepthState(DepthState.NODEPTH);
|
|
17221
|
-
device.setStencilState(null, null);
|
|
17252
|
+
device.setDrawStates();
|
|
17222
17253
|
this.quad.render(this.rect, this.scissorRect);
|
|
17223
17254
|
}
|
|
17224
17255
|
constructor(device, quad, rect, scissorRect){
|
|
@@ -21025,6 +21056,7 @@ class Material {
|
|
|
21025
21056
|
this._blendState.copy(source._blendState);
|
|
21026
21057
|
this._depthState.copy(source._depthState);
|
|
21027
21058
|
this.cull = source.cull;
|
|
21059
|
+
this.frontFace = source.frontFace;
|
|
21028
21060
|
this.stencilFront = source.stencilFront?.clone();
|
|
21029
21061
|
if (source.stencilBack) {
|
|
21030
21062
|
this.stencilBack = source.stencilFront === source.stencilBack ? this.stencilFront : source.stencilBack.clone();
|
|
@@ -21177,6 +21209,7 @@ class Material {
|
|
|
21177
21209
|
this._blendState = new BlendState();
|
|
21178
21210
|
this._depthState = new DepthState();
|
|
21179
21211
|
this.cull = CULLFACE_BACK;
|
|
21212
|
+
this.frontFace = FRONTFACE_CCW;
|
|
21180
21213
|
this.stencilFront = null;
|
|
21181
21214
|
this.stencilBack = null;
|
|
21182
21215
|
this._shaderChunks = null;
|
|
@@ -21652,7 +21685,7 @@ class ShadowRenderer {
|
|
|
21652
21685
|
material.updateUniforms(device, scene);
|
|
21653
21686
|
material.dirty = false;
|
|
21654
21687
|
}
|
|
21655
|
-
renderer.
|
|
21688
|
+
renderer.setupCullModeAndFrontFace(true, flipFactor, meshInstance);
|
|
21656
21689
|
material.setParameters(device);
|
|
21657
21690
|
meshInstance.setParameters(device, passFlags);
|
|
21658
21691
|
const shaderInstance = meshInstance.getShaderInstance(shadowPass, 0, scene, cameraShaderParams, this.viewUniformFormat, this.viewBindGroupFormat);
|
|
@@ -21978,10 +22011,7 @@ class RenderPassCookieRenderer extends RenderPass {
|
|
|
21978
22011
|
}
|
|
21979
22012
|
execute() {
|
|
21980
22013
|
const device = this.device;
|
|
21981
|
-
device.
|
|
21982
|
-
device.setCullMode(CULLFACE_NONE);
|
|
21983
|
-
device.setDepthState(DepthState.NODEPTH);
|
|
21984
|
-
device.setStencilState();
|
|
22014
|
+
device.setDrawStates();
|
|
21985
22015
|
const renderTargetWidth = this.renderTarget.colorBuffer.width;
|
|
21986
22016
|
const cubeSlotsOffsets = this._cubeSlotsOffsets;
|
|
21987
22017
|
const filteredLights = this._filteredLights;
|
|
@@ -22276,24 +22306,18 @@ class Renderer {
|
|
|
22276
22306
|
});
|
|
22277
22307
|
}
|
|
22278
22308
|
}
|
|
22279
|
-
|
|
22309
|
+
setupCullModeAndFrontFace(cullFaces, flipFactor, drawCall) {
|
|
22280
22310
|
const material = drawCall.material;
|
|
22281
|
-
|
|
22282
|
-
|
|
22283
|
-
|
|
22284
|
-
|
|
22285
|
-
flipFaces = flipFactor * drawCall.flipFacesFactor * drawCall.node.worldScaleSign;
|
|
22286
|
-
}
|
|
22287
|
-
if (flipFaces < 0) {
|
|
22288
|
-
mode = material.cull === CULLFACE_FRONT ? CULLFACE_BACK : CULLFACE_FRONT;
|
|
22289
|
-
} else {
|
|
22290
|
-
mode = material.cull;
|
|
22291
|
-
}
|
|
22292
|
-
}
|
|
22293
|
-
this.device.setCullMode(mode);
|
|
22294
|
-
if (mode === CULLFACE_NONE && material.cull === CULLFACE_NONE) {
|
|
22295
|
-
this.twoSidedLightingNegScaleFactorId.setValue(drawCall.node.worldScaleSign);
|
|
22311
|
+
const flipFaces = flipFactor * drawCall.flipFacesFactor * drawCall.node.worldScaleSign;
|
|
22312
|
+
let frontFace = material.frontFace;
|
|
22313
|
+
if (flipFaces < 0) {
|
|
22314
|
+
frontFace = frontFace === FRONTFACE_CCW ? FRONTFACE_CW : FRONTFACE_CCW;
|
|
22296
22315
|
}
|
|
22316
|
+
this.device.setCullMode(cullFaces ? material.cull : CULLFACE_NONE);
|
|
22317
|
+
this.device.setFrontFace(frontFace);
|
|
22318
|
+
}
|
|
22319
|
+
setupCullMode(cullFaces, flipFactor, drawCall) {
|
|
22320
|
+
this.setupCullModeAndFrontFace(cullFaces, flipFactor, drawCall);
|
|
22297
22321
|
}
|
|
22298
22322
|
updateCameraFrustum(camera) {
|
|
22299
22323
|
if (camera.xr && camera.xr.views.list.length) {
|
|
@@ -22325,6 +22349,7 @@ class Renderer {
|
|
|
22325
22349
|
}
|
|
22326
22350
|
setBaseConstants(device, material) {
|
|
22327
22351
|
device.setCullMode(material.cull);
|
|
22352
|
+
device.setFrontFace(material.frontFace);
|
|
22328
22353
|
if (material.opacityMap) {
|
|
22329
22354
|
this.opacityMapId.setValue(material.opacityMap);
|
|
22330
22355
|
}
|
|
@@ -22786,8 +22811,6 @@ class Renderer {
|
|
|
22786
22811
|
this.alphaTestId = scope.resolve('alpha_ref');
|
|
22787
22812
|
this.opacityMapId = scope.resolve('texture_opacityMap');
|
|
22788
22813
|
this.exposureId = scope.resolve('exposure');
|
|
22789
|
-
this.twoSidedLightingNegScaleFactorId = scope.resolve('twoSidedLightingNegScaleFactor');
|
|
22790
|
-
this.twoSidedLightingNegScaleFactorId.setValue(0);
|
|
22791
22814
|
this.morphPositionTex = scope.resolve('morphPositionTex');
|
|
22792
22815
|
this.morphNormalTex = scope.resolve('morphNormalTex');
|
|
22793
22816
|
this.morphTexParams = scope.resolve('morph_tex_params');
|
|
@@ -23354,7 +23377,7 @@ class ForwardRenderer extends Renderer {
|
|
|
23354
23377
|
device.setDepthState(material.depthState);
|
|
23355
23378
|
device.setAlphaToCoverage(material.alphaToCoverage);
|
|
23356
23379
|
}
|
|
23357
|
-
this.
|
|
23380
|
+
this.setupCullModeAndFrontFace(camera._cullFaces, flipFactor, drawCall);
|
|
23358
23381
|
const stencilFront = drawCall.stencilFront ?? material.stencilFront;
|
|
23359
23382
|
const stencilBack = drawCall.stencilBack ?? material.stencilBack;
|
|
23360
23383
|
device.setStencilState(stencilFront, stencilBack);
|
|
@@ -29034,15 +29057,11 @@ class RenderPassShaderQuad extends RenderPass {
|
|
|
29034
29057
|
return this._shader;
|
|
29035
29058
|
}
|
|
29036
29059
|
execute() {
|
|
29037
|
-
|
|
29038
|
-
device.setBlendState(this.blendState);
|
|
29039
|
-
device.setCullMode(this.cullMode);
|
|
29040
|
-
device.setDepthState(this.depthState);
|
|
29041
|
-
device.setStencilState(this.stencilFront, this.stencilBack);
|
|
29060
|
+
this.device.setDrawStates(this.blendState, this.depthState, this.cullMode, this.frontFace, this.stencilFront, this.stencilBack);
|
|
29042
29061
|
this.quadRender?.render(this.viewport, this.scissor);
|
|
29043
29062
|
}
|
|
29044
29063
|
constructor(...args){
|
|
29045
|
-
super(...args), this._shader = null, this.quadRender = null, this.cullMode = CULLFACE_NONE, this.blendState = BlendState.NOBLEND, this.depthState = DepthState.NODEPTH, this.stencilFront = null, this.stencilBack = null;
|
|
29064
|
+
super(...args), this._shader = null, this.quadRender = null, this.cullMode = CULLFACE_NONE, this.frontFace = FRONTFACE_CCW, this.blendState = BlendState.NOBLEND, this.depthState = DepthState.NODEPTH, this.stencilFront = null, this.stencilBack = null;
|
|
29046
29065
|
}
|
|
29047
29066
|
}
|
|
29048
29067
|
|
|
@@ -31843,10 +31862,7 @@ class GSplatWorkBufferRenderPass extends RenderPass {
|
|
|
31843
31862
|
}
|
|
31844
31863
|
execute() {
|
|
31845
31864
|
const { device, splats, cameraNode, _partialData } = this;
|
|
31846
|
-
device.
|
|
31847
|
-
device.setCullMode(CULLFACE_NONE);
|
|
31848
|
-
device.setDepthState(DepthState.NODEPTH);
|
|
31849
|
-
device.setStencilState();
|
|
31865
|
+
device.setDrawStates();
|
|
31850
31866
|
const viewInvMat = cameraNode.getWorldTransform();
|
|
31851
31867
|
const viewMat = _viewMat.copy(viewInvMat).invert();
|
|
31852
31868
|
device.scope.resolve('matrix_view').setValue(viewMat.data);
|
|
@@ -32952,10 +32968,7 @@ class GSplatResolveSH {
|
|
|
32952
32968
|
shN_mins: meta.shN.mins,
|
|
32953
32969
|
shN_maxs: meta.shN.maxs
|
|
32954
32970
|
});
|
|
32955
|
-
device.
|
|
32956
|
-
device.setDepthState(DepthState.NODEPTH);
|
|
32957
|
-
device.setStencilState(null, null);
|
|
32958
|
-
device.setBlendState(BlendState.NOBLEND);
|
|
32971
|
+
device.setDrawStates();
|
|
32959
32972
|
this.quadRender.render();
|
|
32960
32973
|
};
|
|
32961
32974
|
this.renderPass.executeCallback = execute;
|
|
@@ -42271,9 +42284,8 @@ void getRefraction() {
|
|
|
42271
42284
|
`;
|
|
42272
42285
|
|
|
42273
42286
|
var twoSidedLightingPS$1 = `
|
|
42274
|
-
uniform float twoSidedLightingNegScaleFactor;
|
|
42275
42287
|
void handleTwoSidedLighting() {
|
|
42276
|
-
dTBN[2]
|
|
42288
|
+
if (!gl_FrontFacing) dTBN[2] = -dTBN[2];
|
|
42277
42289
|
}
|
|
42278
42290
|
`;
|
|
42279
42291
|
|
|
@@ -47593,9 +47605,8 @@ fn getRefraction() {
|
|
|
47593
47605
|
`;
|
|
47594
47606
|
|
|
47595
47607
|
var twoSidedLightingPS = `
|
|
47596
|
-
uniform twoSidedLightingNegScaleFactor: f32;
|
|
47597
47608
|
fn handleTwoSidedLighting() {
|
|
47598
|
-
dTBN[2] = dTBN[2]
|
|
47609
|
+
if (!pcFrontFacing) { dTBN[2] = -dTBN[2]; }
|
|
47599
47610
|
}
|
|
47600
47611
|
`;
|
|
47601
47612
|
|
|
@@ -53189,6 +53200,24 @@ class GSplatRenderer {
|
|
|
53189
53200
|
const GsplatAllocId = new NumericIds();
|
|
53190
53201
|
|
|
53191
53202
|
class GSplatPlacement {
|
|
53203
|
+
set lodBaseDistance(value) {
|
|
53204
|
+
if (this._lodBaseDistance !== value) {
|
|
53205
|
+
this._lodBaseDistance = value;
|
|
53206
|
+
this.lodDirty = true;
|
|
53207
|
+
}
|
|
53208
|
+
}
|
|
53209
|
+
get lodBaseDistance() {
|
|
53210
|
+
return this._lodBaseDistance;
|
|
53211
|
+
}
|
|
53212
|
+
set lodMultiplier(value) {
|
|
53213
|
+
if (this._lodMultiplier !== value) {
|
|
53214
|
+
this._lodMultiplier = value;
|
|
53215
|
+
this.lodDirty = true;
|
|
53216
|
+
}
|
|
53217
|
+
}
|
|
53218
|
+
get lodMultiplier() {
|
|
53219
|
+
return this._lodMultiplier;
|
|
53220
|
+
}
|
|
53192
53221
|
destroy() {
|
|
53193
53222
|
this._streams?.destroy();
|
|
53194
53223
|
this._streams = null;
|
|
@@ -53225,19 +53254,8 @@ class GSplatPlacement {
|
|
|
53225
53254
|
const aabb = this._aabb ?? this.resource?.aabb;
|
|
53226
53255
|
return aabb;
|
|
53227
53256
|
}
|
|
53228
|
-
|
|
53229
|
-
|
|
53230
|
-
if (isOctree) {
|
|
53231
|
-
if (distances) {
|
|
53232
|
-
this.resource.octree?.lodLevels ?? 1;
|
|
53233
|
-
this._lodDistances = distances.slice();
|
|
53234
|
-
} else {
|
|
53235
|
-
this._lodDistances = null;
|
|
53236
|
-
}
|
|
53237
|
-
}
|
|
53238
|
-
}
|
|
53239
|
-
get lodDistances() {
|
|
53240
|
-
return this._lodDistances ? this._lodDistances.slice() : null;
|
|
53257
|
+
getLodDistance(level) {
|
|
53258
|
+
return this.lodBaseDistance * Math.pow(this.lodMultiplier, level);
|
|
53241
53259
|
}
|
|
53242
53260
|
getInstanceTexture(name, device) {
|
|
53243
53261
|
const resource = this.resource;
|
|
@@ -53270,10 +53288,12 @@ class GSplatPlacement {
|
|
|
53270
53288
|
this.id = 0;
|
|
53271
53289
|
this.allocId = GsplatAllocId.get();
|
|
53272
53290
|
this.lodIndex = 0;
|
|
53273
|
-
this.
|
|
53291
|
+
this._lodBaseDistance = 5;
|
|
53292
|
+
this._lodMultiplier = 3;
|
|
53274
53293
|
this._aabb = null;
|
|
53275
53294
|
this.parameters = null;
|
|
53276
53295
|
this._streams = null;
|
|
53296
|
+
this.lodDirty = false;
|
|
53277
53297
|
this.renderDirty = false;
|
|
53278
53298
|
this.workBufferUpdate = WORKBUFFER_UPDATE_AUTO;
|
|
53279
53299
|
this._lastFormatVersion = -1;
|
|
@@ -53294,6 +53314,7 @@ const _localCameraFwd = new Vec3();
|
|
|
53294
53314
|
const _dirToNode = new Vec3();
|
|
53295
53315
|
const _tempCompletedUrls = [];
|
|
53296
53316
|
new BoundingBox();
|
|
53317
|
+
const REF_TAN_HALF_FOV = Math.tan(22.5 * math.DEG_TO_RAD);
|
|
53297
53318
|
[
|
|
53298
53319
|
new Color(1, 0, 0),
|
|
53299
53320
|
new Color(0, 1, 0),
|
|
@@ -53311,7 +53332,6 @@ class NodeInfo {
|
|
|
53311
53332
|
this.optimalLod = -1;
|
|
53312
53333
|
this.worldDistance = 0;
|
|
53313
53334
|
this.inst = null;
|
|
53314
|
-
this.nodeIndex = 0;
|
|
53315
53335
|
this.lods = null;
|
|
53316
53336
|
this.allocId = GsplatAllocId.get();
|
|
53317
53337
|
}
|
|
@@ -53388,26 +53408,6 @@ class GSplatOctreeInstance {
|
|
|
53388
53408
|
}
|
|
53389
53409
|
return toRelease;
|
|
53390
53410
|
}
|
|
53391
|
-
calculateNodeLod(localCameraPosition, localCameraForward, nodeIndex, maxLod, lodDistances, lodBehindPenalty) {
|
|
53392
|
-
const node = this.octree.nodes[nodeIndex];
|
|
53393
|
-
node.bounds.closestPoint(localCameraPosition, _dirToNode);
|
|
53394
|
-
_dirToNode.sub(localCameraPosition);
|
|
53395
|
-
let distance = _dirToNode.length();
|
|
53396
|
-
if (lodBehindPenalty > 1 && distance > 0.01) {
|
|
53397
|
-
const dotOverDistance = localCameraForward.dot(_dirToNode) / distance;
|
|
53398
|
-
if (dotOverDistance < 0) {
|
|
53399
|
-
const t = -dotOverDistance;
|
|
53400
|
-
const factor = 1 + t * (lodBehindPenalty - 1);
|
|
53401
|
-
distance *= factor;
|
|
53402
|
-
}
|
|
53403
|
-
}
|
|
53404
|
-
for(let lod = 0; lod < maxLod; lod++){
|
|
53405
|
-
if (distance < lodDistances[lod]) {
|
|
53406
|
-
return lod;
|
|
53407
|
-
}
|
|
53408
|
-
}
|
|
53409
|
-
return maxLod;
|
|
53410
|
-
}
|
|
53411
53411
|
selectDesiredLodIndex(node, optimalLodIndex, maxLod, lodUnderfillLimit) {
|
|
53412
53412
|
if (lodUnderfillLimit > 0) {
|
|
53413
53413
|
const allowedMaxCoarseLod = Math.min(maxLod, optimalLodIndex + lodUnderfillLimit);
|
|
@@ -53452,29 +53452,24 @@ class GSplatOctreeInstance {
|
|
|
53452
53452
|
}
|
|
53453
53453
|
updateLod(cameraNode, params) {
|
|
53454
53454
|
const maxLod = this.octree.lodLevels - 1;
|
|
53455
|
-
const
|
|
53456
|
-
5,
|
|
53457
|
-
10,
|
|
53458
|
-
15,
|
|
53459
|
-
20,
|
|
53460
|
-
25,
|
|
53461
|
-
30,
|
|
53462
|
-
35,
|
|
53463
|
-
40,
|
|
53464
|
-
45,
|
|
53465
|
-
50,
|
|
53466
|
-
55,
|
|
53467
|
-
60
|
|
53468
|
-
];
|
|
53455
|
+
const { lodBaseDistance, lodMultiplier } = this.placement;
|
|
53469
53456
|
const { lodRangeMin, lodRangeMax } = params;
|
|
53470
53457
|
const rangeMin = Math.max(0, Math.min(lodRangeMin ?? 0, maxLod));
|
|
53471
53458
|
const rangeMax = Math.max(rangeMin, Math.min(lodRangeMax ?? maxLod, maxLod));
|
|
53472
53459
|
const uniformScale = this.placement.node.getWorldTransform().getScale().x;
|
|
53473
|
-
this.evaluateNodeLods(cameraNode, maxLod,
|
|
53460
|
+
this.evaluateNodeLods(cameraNode, maxLod, lodBaseDistance, lodMultiplier, rangeMin, rangeMax, params, uniformScale);
|
|
53474
53461
|
this.applyLodChanges(maxLod, params);
|
|
53475
53462
|
}
|
|
53476
|
-
evaluateNodeLods(cameraNode, maxLod,
|
|
53463
|
+
evaluateNodeLods(cameraNode, maxLod, lodBaseDistance, lodMultiplier, rangeMin, rangeMax, params, uniformScale) {
|
|
53477
53464
|
const { lodBehindPenalty } = params;
|
|
53465
|
+
const camera = cameraNode.camera;
|
|
53466
|
+
let tanHalfVFov = Math.tan(camera.fov * 0.5 * math.DEG_TO_RAD);
|
|
53467
|
+
if (camera.horizontalFov) {
|
|
53468
|
+
tanHalfVFov /= camera.aspectRatio;
|
|
53469
|
+
}
|
|
53470
|
+
const tanHalfHFov = tanHalfVFov * camera.aspectRatio;
|
|
53471
|
+
const fovScale = Math.min(tanHalfVFov, tanHalfHFov) / REF_TAN_HALF_FOV;
|
|
53472
|
+
const invLogMult = 1.0 / Math.log(lodMultiplier);
|
|
53478
53473
|
const worldCameraPosition = cameraNode.getPosition();
|
|
53479
53474
|
const octreeWorldTransform = this.placement.node.getWorldTransform();
|
|
53480
53475
|
_invWorldMat.copy(octreeWorldTransform).invert();
|
|
@@ -53499,18 +53494,18 @@ class GSplatOctreeInstance {
|
|
|
53499
53494
|
penalizedDistance = actualDistance * factor;
|
|
53500
53495
|
}
|
|
53501
53496
|
}
|
|
53502
|
-
|
|
53503
|
-
|
|
53504
|
-
|
|
53505
|
-
|
|
53506
|
-
|
|
53507
|
-
|
|
53497
|
+
const fovAdjustedDistance = penalizedDistance * fovScale;
|
|
53498
|
+
let optimalLodIndex;
|
|
53499
|
+
if (fovAdjustedDistance < lodBaseDistance) {
|
|
53500
|
+
optimalLodIndex = 0;
|
|
53501
|
+
} else {
|
|
53502
|
+
const rawLod = 1 + Math.log(fovAdjustedDistance / lodBaseDistance) * invLogMult;
|
|
53503
|
+
optimalLodIndex = Math.min(maxLod, rawLod | 0);
|
|
53508
53504
|
}
|
|
53509
53505
|
if (optimalLodIndex < rangeMin) optimalLodIndex = rangeMin;
|
|
53510
53506
|
if (optimalLodIndex > rangeMax) optimalLodIndex = rangeMax;
|
|
53511
|
-
const worldDistance = actualDistance * uniformScale;
|
|
53512
53507
|
nodeInfo.optimalLod = optimalLodIndex;
|
|
53513
|
-
nodeInfo.worldDistance =
|
|
53508
|
+
nodeInfo.worldDistance = fovAdjustedDistance * uniformScale;
|
|
53514
53509
|
const lod = nodes[nodeIndex].lods[optimalLodIndex];
|
|
53515
53510
|
if (lod && lod.count) {
|
|
53516
53511
|
totalSplats += lod.count;
|
|
@@ -53518,29 +53513,18 @@ class GSplatOctreeInstance {
|
|
|
53518
53513
|
}
|
|
53519
53514
|
return totalSplats;
|
|
53520
53515
|
}
|
|
53521
|
-
evaluateOptimalLods(cameraNode, params) {
|
|
53516
|
+
evaluateOptimalLods(cameraNode, params, budgetScale = 1) {
|
|
53522
53517
|
const maxLod = this.octree.lodLevels - 1;
|
|
53523
|
-
const
|
|
53524
|
-
5,
|
|
53525
|
-
10,
|
|
53526
|
-
15,
|
|
53527
|
-
20,
|
|
53528
|
-
25,
|
|
53529
|
-
30,
|
|
53530
|
-
35,
|
|
53531
|
-
40,
|
|
53532
|
-
45,
|
|
53533
|
-
50,
|
|
53534
|
-
55,
|
|
53535
|
-
60
|
|
53536
|
-
];
|
|
53518
|
+
const { lodBaseDistance, lodMultiplier } = this.placement;
|
|
53537
53519
|
const { lodRangeMin, lodRangeMax } = params;
|
|
53538
53520
|
const rangeMin = Math.max(0, Math.min(lodRangeMin ?? 0, maxLod));
|
|
53539
53521
|
const rangeMax = Math.max(rangeMin, Math.min(lodRangeMax ?? maxLod, maxLod));
|
|
53540
53522
|
this.rangeMin = rangeMin;
|
|
53541
53523
|
this.rangeMax = rangeMax;
|
|
53542
53524
|
const uniformScale = this.placement.node.getWorldTransform().getScale().x;
|
|
53543
|
-
|
|
53525
|
+
const effectiveBase = lodBaseDistance * budgetScale;
|
|
53526
|
+
const effectiveMult = Math.max(1.2, lodMultiplier * Math.pow(budgetScale, -0.2));
|
|
53527
|
+
return this.evaluateNodeLods(cameraNode, maxLod, effectiveBase, effectiveMult, rangeMin, rangeMax, params, uniformScale);
|
|
53544
53528
|
}
|
|
53545
53529
|
applyLodChanges(maxLod, params) {
|
|
53546
53530
|
const nodes = this.octree.nodes;
|
|
@@ -53689,6 +53673,10 @@ class GSplatOctreeInstance {
|
|
|
53689
53673
|
this.previousPosition.copy(this.placement.node.getPosition());
|
|
53690
53674
|
}
|
|
53691
53675
|
update() {
|
|
53676
|
+
if (this.placement.lodDirty) {
|
|
53677
|
+
this.placement.lodDirty = false;
|
|
53678
|
+
this.needsLodUpdate = true;
|
|
53679
|
+
}
|
|
53692
53680
|
if (this.pending.size) {
|
|
53693
53681
|
for (const fileIndex of this.pending){
|
|
53694
53682
|
this.octree.ensureFileResource(fileIndex);
|
|
@@ -53785,7 +53773,6 @@ class GSplatOctreeInstance {
|
|
|
53785
53773
|
for(let i = 0; i < octree.nodes.length; i++){
|
|
53786
53774
|
const nodeInfo = new NodeInfo();
|
|
53787
53775
|
nodeInfo.inst = this;
|
|
53788
|
-
nodeInfo.nodeIndex = i;
|
|
53789
53776
|
this.nodeInfos[i] = nodeInfo;
|
|
53790
53777
|
}
|
|
53791
53778
|
const numFiles = octree.files.length;
|
|
@@ -55264,10 +55251,11 @@ class GSplatBudgetBalancer {
|
|
|
55264
55251
|
return;
|
|
55265
55252
|
}
|
|
55266
55253
|
const isOverBudget = currentSplats > budget;
|
|
55267
|
-
|
|
55254
|
+
let done = false;
|
|
55255
|
+
while(!done && (isOverBudget ? currentSplats > budget : currentSplats < budget)){
|
|
55268
55256
|
let modified = false;
|
|
55269
55257
|
if (isOverBudget) {
|
|
55270
|
-
for(let b = NUM_BUCKETS - 1; b >= 0 &&
|
|
55258
|
+
for(let b = NUM_BUCKETS - 1; b >= 0 && !done; b--){
|
|
55271
55259
|
const bucket = this._buckets[b];
|
|
55272
55260
|
for(let i = 0, len = bucket.length; i < len; i++){
|
|
55273
55261
|
const nodeInfo = bucket[i];
|
|
@@ -55277,12 +55265,15 @@ class GSplatBudgetBalancer {
|
|
|
55277
55265
|
currentSplats -= lods[optimalLod].count - lods[optimalLod + 1].count;
|
|
55278
55266
|
nodeInfo.optimalLod = optimalLod + 1;
|
|
55279
55267
|
modified = true;
|
|
55280
|
-
if (currentSplats <= budget)
|
|
55268
|
+
if (currentSplats <= budget) {
|
|
55269
|
+
done = true;
|
|
55270
|
+
break;
|
|
55271
|
+
}
|
|
55281
55272
|
}
|
|
55282
55273
|
}
|
|
55283
55274
|
}
|
|
55284
55275
|
} else {
|
|
55285
|
-
for(let b = 0; b < NUM_BUCKETS &&
|
|
55276
|
+
for(let b = 0; b < NUM_BUCKETS && !done; b++){
|
|
55286
55277
|
const bucket = this._buckets[b];
|
|
55287
55278
|
for(let i = 0, len = bucket.length; i < len; i++){
|
|
55288
55279
|
const nodeInfo = bucket[i];
|
|
@@ -55294,7 +55285,13 @@ class GSplatBudgetBalancer {
|
|
|
55294
55285
|
nodeInfo.optimalLod = optimalLod - 1;
|
|
55295
55286
|
currentSplats += splatsAdded;
|
|
55296
55287
|
modified = true;
|
|
55297
|
-
if (currentSplats >= budget)
|
|
55288
|
+
if (currentSplats >= budget) {
|
|
55289
|
+
done = true;
|
|
55290
|
+
break;
|
|
55291
|
+
}
|
|
55292
|
+
} else {
|
|
55293
|
+
done = true;
|
|
55294
|
+
break;
|
|
55298
55295
|
}
|
|
55299
55296
|
}
|
|
55300
55297
|
}
|
|
@@ -56128,7 +56125,9 @@ class GSplatManager {
|
|
|
56128
56125
|
cameraRotated = true;
|
|
56129
56126
|
}
|
|
56130
56127
|
}
|
|
56131
|
-
|
|
56128
|
+
const currentFov = this.cameraNode.camera.fov;
|
|
56129
|
+
const fovChanged = this.lastLodCameraFov < 0 || Math.abs(currentFov - this.lastLodCameraFov) > this.lastLodCameraFov * 0.02;
|
|
56130
|
+
return cameraMoved || cameraRotated || fovChanged;
|
|
56132
56131
|
}
|
|
56133
56132
|
testCameraMovedForSort() {
|
|
56134
56133
|
const epsilon = 0.001;
|
|
@@ -56226,8 +56225,9 @@ class GSplatManager {
|
|
|
56226
56225
|
}
|
|
56227
56226
|
const octreeBudget = Math.max(1, budget - fixedSplats);
|
|
56228
56227
|
const globalMaxDistance = this.computeGlobalMaxDistance();
|
|
56228
|
+
let totalOptimalSplats = 0;
|
|
56229
56229
|
for (const [, inst] of this.octreeInstances){
|
|
56230
|
-
inst.evaluateOptimalLods(this.cameraNode, this.scene.gsplat);
|
|
56230
|
+
totalOptimalSplats += inst.evaluateOptimalLods(this.cameraNode, this.scene.gsplat, this._budgetScale);
|
|
56231
56231
|
for (const placement of inst.activePlacements){
|
|
56232
56232
|
const resource = placement.resource;
|
|
56233
56233
|
const numSplats = resource?.numSplats ?? 0;
|
|
@@ -56235,6 +56235,16 @@ class GSplatManager {
|
|
|
56235
56235
|
}
|
|
56236
56236
|
}
|
|
56237
56237
|
const adjustedBudget = Math.max(1, octreeBudget - paddingEstimate);
|
|
56238
|
+
if (totalOptimalSplats > 0) {
|
|
56239
|
+
const ratio = totalOptimalSplats / adjustedBudget;
|
|
56240
|
+
const budgetScaleDeadZone = 0.4;
|
|
56241
|
+
const budgetScaleBlendRate = 0.3;
|
|
56242
|
+
if (ratio > 1 + budgetScaleDeadZone || ratio < 1 - budgetScaleDeadZone) {
|
|
56243
|
+
const invCorrection = 1 / Math.sqrt(ratio);
|
|
56244
|
+
this._budgetScale *= 1 + (invCorrection - 1) * budgetScaleBlendRate;
|
|
56245
|
+
this._budgetScale = Math.max(0.01, Math.min(this._budgetScale, 100.0));
|
|
56246
|
+
}
|
|
56247
|
+
}
|
|
56238
56248
|
this._budgetBalancer.balance(this.octreeInstances, adjustedBudget, globalMaxDistance);
|
|
56239
56249
|
for (const [, inst] of this.octreeInstances){
|
|
56240
56250
|
const maxLod = inst.octree.lodLevels - 1;
|
|
@@ -56319,12 +56329,15 @@ class GSplatManager {
|
|
|
56319
56329
|
for (const [, inst] of this.octreeInstances){
|
|
56320
56330
|
inst.updateMoved();
|
|
56321
56331
|
}
|
|
56322
|
-
this.
|
|
56323
|
-
this.
|
|
56332
|
+
const cameraNode = this.cameraNode;
|
|
56333
|
+
this.lastLodCameraPos.copy(cameraNode.getPosition());
|
|
56334
|
+
this.lastLodCameraFwd.copy(cameraNode.forward);
|
|
56335
|
+
this.lastLodCameraFov = cameraNode.camera.fov;
|
|
56324
56336
|
const budget = this.scene.gsplat.splatBudget;
|
|
56325
56337
|
if (budget > 0) {
|
|
56326
56338
|
this._enforceBudget(budget);
|
|
56327
56339
|
} else {
|
|
56340
|
+
this._budgetScale = 1.0;
|
|
56328
56341
|
for (const [, inst] of this.octreeInstances){
|
|
56329
56342
|
inst.updateLod(this.cameraNode, this.scene.gsplat);
|
|
56330
56343
|
}
|
|
@@ -56618,12 +56631,14 @@ class GSplatManager {
|
|
|
56618
56631
|
this.framesTillFullUpdate = 0;
|
|
56619
56632
|
this.lastLodCameraPos = new Vec3(Infinity, Infinity, Infinity);
|
|
56620
56633
|
this.lastLodCameraFwd = new Vec3(Infinity, Infinity, Infinity);
|
|
56634
|
+
this.lastLodCameraFov = -1;
|
|
56621
56635
|
this.lastSortCameraPos = new Vec3(Infinity, Infinity, Infinity);
|
|
56622
56636
|
this.lastSortCameraFwd = new Vec3(Infinity, Infinity, Infinity);
|
|
56623
56637
|
this.lastCullingCameraFwd = new Vec3(Infinity, Infinity, Infinity);
|
|
56624
56638
|
this.lastCullingProjMat = new Mat4();
|
|
56625
56639
|
this.sortNeeded = true;
|
|
56626
56640
|
this._budgetBalancer = new GSplatBudgetBalancer();
|
|
56641
|
+
this._budgetScale = 1.0;
|
|
56627
56642
|
this._allocationMap = new Map();
|
|
56628
56643
|
this.lastColorUpdateCameraPos = new Vec3(Infinity, Infinity, Infinity);
|
|
56629
56644
|
this.lastColorUpdateCameraFwd = new Vec3(Infinity, Infinity, Infinity);
|
|
@@ -56935,14 +56950,32 @@ class GSplatComponent extends Component {
|
|
|
56935
56950
|
get castShadows() {
|
|
56936
56951
|
return this._castShadows;
|
|
56937
56952
|
}
|
|
56938
|
-
set
|
|
56939
|
-
this.
|
|
56953
|
+
set lodBaseDistance(value) {
|
|
56954
|
+
this._lodBaseDistance = Math.max(0.1, value);
|
|
56955
|
+
if (this._placement) {
|
|
56956
|
+
this._placement.lodBaseDistance = this._lodBaseDistance;
|
|
56957
|
+
}
|
|
56958
|
+
}
|
|
56959
|
+
get lodBaseDistance() {
|
|
56960
|
+
return this._lodBaseDistance;
|
|
56961
|
+
}
|
|
56962
|
+
set lodMultiplier(value) {
|
|
56963
|
+
this._lodMultiplier = Math.max(1.2, value);
|
|
56940
56964
|
if (this._placement) {
|
|
56941
|
-
this._placement.
|
|
56965
|
+
this._placement.lodMultiplier = this._lodMultiplier;
|
|
56966
|
+
}
|
|
56967
|
+
}
|
|
56968
|
+
get lodMultiplier() {
|
|
56969
|
+
return this._lodMultiplier;
|
|
56970
|
+
}
|
|
56971
|
+
set lodDistances(value) {
|
|
56972
|
+
if (Array.isArray(value) && value.length > 0) {
|
|
56973
|
+
this.lodBaseDistance = value[0];
|
|
56974
|
+
this.lodMultiplier = 3;
|
|
56942
56975
|
}
|
|
56943
56976
|
}
|
|
56944
56977
|
get lodDistances() {
|
|
56945
|
-
return
|
|
56978
|
+
return [];
|
|
56946
56979
|
}
|
|
56947
56980
|
set splatBudget(value) {}
|
|
56948
56981
|
get splatBudget() {
|
|
@@ -57207,7 +57240,8 @@ class GSplatComponent extends Component {
|
|
|
57207
57240
|
if (this.unified) {
|
|
57208
57241
|
this._placement = null;
|
|
57209
57242
|
this._placement = new GSplatPlacement(resource, this.entity, 0, this._parameters, null, this._id);
|
|
57210
|
-
this._placement.
|
|
57243
|
+
this._placement.lodBaseDistance = this._lodBaseDistance;
|
|
57244
|
+
this._placement.lodMultiplier = this._lodMultiplier;
|
|
57211
57245
|
this._placement.workBufferUpdate = this._workBufferUpdate;
|
|
57212
57246
|
this._placement.workBufferModifier = this._workBufferModifier;
|
|
57213
57247
|
if (this.enabled && this.entity.enabled) {
|
|
@@ -57231,20 +57265,7 @@ class GSplatComponent extends Component {
|
|
|
57231
57265
|
constructor(system, entity){
|
|
57232
57266
|
super(system, entity), this._layers = [
|
|
57233
57267
|
LAYERID_WORLD
|
|
57234
|
-
], this._instance = null, this._placement = null, this._id = PickerId.get(), this._materialTmp = null, this._highQualitySH = true, this.
|
|
57235
|
-
5,
|
|
57236
|
-
10,
|
|
57237
|
-
15,
|
|
57238
|
-
20,
|
|
57239
|
-
25,
|
|
57240
|
-
30,
|
|
57241
|
-
35,
|
|
57242
|
-
40,
|
|
57243
|
-
45,
|
|
57244
|
-
50,
|
|
57245
|
-
55,
|
|
57246
|
-
60
|
|
57247
|
-
], this._customAabb = null, this._resource = null, this._evtLayersChanged = null, this._evtLayerAdded = null, this._evtLayerRemoved = null, this._castShadows = false, this._unified = false, this._parameters = new Map(), this._workBufferUpdate = WORKBUFFER_UPDATE_AUTO, this._workBufferModifier = null;
|
|
57268
|
+
], this._instance = null, this._placement = null, this._id = PickerId.get(), this._materialTmp = null, this._highQualitySH = true, this._lodBaseDistance = 5, this._lodMultiplier = 3, this._customAabb = null, this._resource = null, this._evtLayersChanged = null, this._evtLayerAdded = null, this._evtLayerRemoved = null, this._castShadows = false, this._unified = false, this._parameters = new Map(), this._workBufferUpdate = WORKBUFFER_UPDATE_AUTO, this._workBufferModifier = null;
|
|
57248
57269
|
this._assetReference = new AssetReference('asset', this, system.app.assets, {
|
|
57249
57270
|
add: this._onGSplatAssetAdded,
|
|
57250
57271
|
load: this._onGSplatAssetLoad,
|
|
@@ -58816,7 +58837,8 @@ const _schema = [
|
|
|
58816
58837
|
];
|
|
58817
58838
|
const _properties = [
|
|
58818
58839
|
'unified',
|
|
58819
|
-
'
|
|
58840
|
+
'lodBaseDistance',
|
|
58841
|
+
'lodMultiplier',
|
|
58820
58842
|
'castShadows',
|
|
58821
58843
|
'material',
|
|
58822
58844
|
'highQualitySH',
|
|
@@ -62667,6 +62689,7 @@ class PlyParser {
|
|
|
62667
62689
|
|
|
62668
62690
|
const combineProgress = (target, assets)=>{
|
|
62669
62691
|
const map = new Map();
|
|
62692
|
+
const count = assets.length;
|
|
62670
62693
|
const fire = ()=>{
|
|
62671
62694
|
let loaded = 0;
|
|
62672
62695
|
let total = 0;
|
|
@@ -62674,6 +62697,10 @@ const combineProgress = (target, assets)=>{
|
|
|
62674
62697
|
loaded += value.loaded;
|
|
62675
62698
|
total += value.total;
|
|
62676
62699
|
});
|
|
62700
|
+
const reporting = map.size;
|
|
62701
|
+
if (reporting > 0 && reporting < count) {
|
|
62702
|
+
total = Math.ceil(total * count / reporting);
|
|
62703
|
+
}
|
|
62677
62704
|
target.fire('progress', loaded, total);
|
|
62678
62705
|
};
|
|
62679
62706
|
assets.forEach((asset)=>{
|
|
@@ -67236,37 +67263,37 @@ varying uv0: vec2f;
|
|
|
67236
67263
|
@fragment
|
|
67237
67264
|
fn fragmentMain(input: FragmentInput) -> FragmentOutput {
|
|
67238
67265
|
var output: FragmentOutput;
|
|
67239
|
-
let e:
|
|
67266
|
+
let e: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, input.uv0).rgb);
|
|
67240
67267
|
#ifdef BOXFILTER
|
|
67241
|
-
var value:
|
|
67268
|
+
var value: half3 = e;
|
|
67242
67269
|
#ifdef PREMULTIPLY
|
|
67243
|
-
let premultiply:
|
|
67244
|
-
value
|
|
67270
|
+
let premultiply: half = half(textureSample(premultiplyTexture, premultiplyTextureSampler, input.uv0).{PREMULTIPLY_SRC_CHANNEL});
|
|
67271
|
+
value *= premultiply;
|
|
67245
67272
|
#endif
|
|
67246
67273
|
#else
|
|
67247
67274
|
let x: f32 = uniform.sourceInvResolution.x;
|
|
67248
67275
|
let y: f32 = uniform.sourceInvResolution.y;
|
|
67249
|
-
let a:
|
|
67250
|
-
let b:
|
|
67251
|
-
let c:
|
|
67252
|
-
let d:
|
|
67253
|
-
let f:
|
|
67254
|
-
let g:
|
|
67255
|
-
let h:
|
|
67256
|
-
let i:
|
|
67257
|
-
let j:
|
|
67258
|
-
let k:
|
|
67259
|
-
let l:
|
|
67260
|
-
let m:
|
|
67261
|
-
var value:
|
|
67262
|
-
value
|
|
67263
|
-
value
|
|
67264
|
-
value
|
|
67276
|
+
let a: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x - 2.0 * x, input.uv0.y + 2.0 * y)).rgb);
|
|
67277
|
+
let b: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x, input.uv0.y + 2.0 * y)).rgb);
|
|
67278
|
+
let c: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x + 2.0 * x, input.uv0.y + 2.0 * y)).rgb);
|
|
67279
|
+
let d: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x - 2.0 * x, input.uv0.y)).rgb);
|
|
67280
|
+
let f: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x + 2.0 * x, input.uv0.y)).rgb);
|
|
67281
|
+
let g: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x - 2.0 * x, input.uv0.y - 2.0 * y)).rgb);
|
|
67282
|
+
let h: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x, input.uv0.y - 2.0 * y)).rgb);
|
|
67283
|
+
let i: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x + 2.0 * x, input.uv0.y - 2.0 * y)).rgb);
|
|
67284
|
+
let j: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x - x, input.uv0.y + y)).rgb);
|
|
67285
|
+
let k: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x + x, input.uv0.y + y)).rgb);
|
|
67286
|
+
let l: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x - x, input.uv0.y - y)).rgb);
|
|
67287
|
+
let m: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x + x, input.uv0.y - y)).rgb);
|
|
67288
|
+
var value: half3 = e * half(0.125);
|
|
67289
|
+
value += (a + c + g + i) * half(0.03125);
|
|
67290
|
+
value += (b + d + f + h) * half(0.0625);
|
|
67291
|
+
value += (j + k + l + m) * half(0.125);
|
|
67265
67292
|
#endif
|
|
67266
67293
|
#ifdef REMOVE_INVALID
|
|
67267
|
-
value = max(value,
|
|
67294
|
+
value = max(value, half3(0.0));
|
|
67268
67295
|
#endif
|
|
67269
|
-
output.color = vec4f(value, 1.0);
|
|
67296
|
+
output.color = vec4f(vec3f(value), 1.0);
|
|
67270
67297
|
return output;
|
|
67271
67298
|
}
|
|
67272
67299
|
`;
|
|
@@ -67332,10 +67359,9 @@ var glslUpsamplePS = `
|
|
|
67332
67359
|
vec3 g = texture2D (sourceTexture, vec2 (uv0.x - x, uv0.y - y)).rgb;
|
|
67333
67360
|
vec3 h = texture2D (sourceTexture, vec2 (uv0.x, uv0.y - y)).rgb;
|
|
67334
67361
|
vec3 i = texture2D (sourceTexture, vec2 (uv0.x + x, uv0.y - y)).rgb;
|
|
67335
|
-
vec3 value = e *
|
|
67336
|
-
value += (b + d + f + h) *
|
|
67337
|
-
value += (a + c + g + i);
|
|
67338
|
-
value *= 1.0 / 16.0;
|
|
67362
|
+
vec3 value = e * 0.25;
|
|
67363
|
+
value += (b + d + f + h) * 0.125;
|
|
67364
|
+
value += (a + c + g + i) * 0.0625;
|
|
67339
67365
|
gl_FragColor = vec4(value, 1.0);
|
|
67340
67366
|
}
|
|
67341
67367
|
`;
|
|
@@ -67350,20 +67376,19 @@ var wgslUpsamplePS = `
|
|
|
67350
67376
|
var output: FragmentOutput;
|
|
67351
67377
|
let x: f32 = uniform.sourceInvResolution.x;
|
|
67352
67378
|
let y: f32 = uniform.sourceInvResolution.y;
|
|
67353
|
-
let a:
|
|
67354
|
-
let b:
|
|
67355
|
-
let c:
|
|
67356
|
-
let d:
|
|
67357
|
-
let e:
|
|
67358
|
-
let f:
|
|
67359
|
-
let g:
|
|
67360
|
-
let h:
|
|
67361
|
-
let i:
|
|
67362
|
-
var value:
|
|
67363
|
-
value
|
|
67364
|
-
value
|
|
67365
|
-
|
|
67366
|
-
output.color = vec4f(value, 1.0);
|
|
67379
|
+
let a: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x - x, input.uv0.y + y)).rgb);
|
|
67380
|
+
let b: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x, input.uv0.y + y)).rgb);
|
|
67381
|
+
let c: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x + x, input.uv0.y + y)).rgb);
|
|
67382
|
+
let d: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x - x, input.uv0.y)).rgb);
|
|
67383
|
+
let e: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x, input.uv0.y)).rgb);
|
|
67384
|
+
let f: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x + x, input.uv0.y)).rgb);
|
|
67385
|
+
let g: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x - x, input.uv0.y - y)).rgb);
|
|
67386
|
+
let h: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x, input.uv0.y - y)).rgb);
|
|
67387
|
+
let i: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x + x, input.uv0.y - y)).rgb);
|
|
67388
|
+
var value: half3 = e * half(0.25);
|
|
67389
|
+
value += (b + d + f + h) * half(0.125);
|
|
67390
|
+
value += (a + c + g + i) * half(0.0625);
|
|
67391
|
+
output.color = vec4f(vec3f(value), 1.0);
|
|
67367
67392
|
return output;
|
|
67368
67393
|
}
|
|
67369
67394
|
`;
|
|
@@ -67754,9 +67779,14 @@ var composeFringingPS$1 = `
|
|
|
67754
67779
|
var composeCasPS$1 = `
|
|
67755
67780
|
#ifdef CAS
|
|
67756
67781
|
uniform float sharpness;
|
|
67757
|
-
|
|
67758
|
-
|
|
67759
|
-
|
|
67782
|
+
#ifdef CAS_HDR
|
|
67783
|
+
float maxComponent(float x, float y, float z) { return max(x, max(y, z)); }
|
|
67784
|
+
vec3 toSDR(vec3 c) { return c / (1.0 + maxComponent(c.r, c.g, c.b)); }
|
|
67785
|
+
vec3 toHDR(vec3 c) { return c / (1.0 - maxComponent(c.r, c.g, c.b)); }
|
|
67786
|
+
#else
|
|
67787
|
+
vec3 toSDR(vec3 c) { return c; }
|
|
67788
|
+
vec3 toHDR(vec3 c) { return c; }
|
|
67789
|
+
#endif
|
|
67760
67790
|
vec3 applyCas(vec3 color, vec2 uv, float sharpness) {
|
|
67761
67791
|
float x = sceneTextureInvRes.x;
|
|
67762
67792
|
float y = sceneTextureInvRes.y;
|
|
@@ -68090,24 +68120,29 @@ var composeFringingPS = `
|
|
|
68090
68120
|
var composeCasPS = `
|
|
68091
68121
|
#ifdef CAS
|
|
68092
68122
|
uniform sharpness: f32;
|
|
68093
|
-
|
|
68094
|
-
|
|
68095
|
-
|
|
68123
|
+
#ifdef CAS_HDR
|
|
68124
|
+
fn maxComponent(x: f32, y: f32, z: f32) -> f32 { return max(x, max(y, z)); }
|
|
68125
|
+
fn toSDR(c: vec3f) -> vec3f { return c / (1.0 + maxComponent(c.r, c.g, c.b)); }
|
|
68126
|
+
fn toHDR(c: vec3f) -> vec3f { return c / (1.0 - maxComponent(c.r, c.g, c.b)); }
|
|
68127
|
+
#else
|
|
68128
|
+
fn toSDR(c: vec3f) -> vec3f { return c; }
|
|
68129
|
+
fn toHDR(c: vec3f) -> vec3f { return c; }
|
|
68130
|
+
#endif
|
|
68096
68131
|
fn applyCas(color: vec3f, uv: vec2f, sharpness: f32) -> vec3f {
|
|
68097
68132
|
let x = uniform.sceneTextureInvRes.x;
|
|
68098
68133
|
let y = uniform.sceneTextureInvRes.y;
|
|
68099
|
-
let a = toSDR(textureSampleLevel(sceneTexture, sceneTextureSampler, uv + vec2f(0.0, -y), 0.0).rgb);
|
|
68100
|
-
let b = toSDR(textureSampleLevel(sceneTexture, sceneTextureSampler, uv + vec2f(-x, 0.0), 0.0).rgb);
|
|
68101
|
-
let c = toSDR(color.rgb);
|
|
68102
|
-
let d = toSDR(textureSampleLevel(sceneTexture, sceneTextureSampler, uv + vec2f(x, 0.0), 0.0).rgb);
|
|
68103
|
-
let e = toSDR(textureSampleLevel(sceneTexture, sceneTextureSampler, uv + vec2f(0.0, y), 0.0).rgb);
|
|
68134
|
+
let a: half3 = half3(toSDR(textureSampleLevel(sceneTexture, sceneTextureSampler, uv + vec2f(0.0, -y), 0.0).rgb));
|
|
68135
|
+
let b: half3 = half3(toSDR(textureSampleLevel(sceneTexture, sceneTextureSampler, uv + vec2f(-x, 0.0), 0.0).rgb));
|
|
68136
|
+
let c: half3 = half3(toSDR(color.rgb));
|
|
68137
|
+
let d: half3 = half3(toSDR(textureSampleLevel(sceneTexture, sceneTextureSampler, uv + vec2f(x, 0.0), 0.0).rgb));
|
|
68138
|
+
let e: half3 = half3(toSDR(textureSampleLevel(sceneTexture, sceneTextureSampler, uv + vec2f(0.0, y), 0.0).rgb));
|
|
68104
68139
|
let min_g = min(a.g, min(b.g, min(c.g, min(d.g, e.g))));
|
|
68105
68140
|
let max_g = max(a.g, max(b.g, max(c.g, max(d.g, e.g))));
|
|
68106
|
-
let sharpening_amount = sqrt(min(1.0 - max_g, min_g) / max_g);
|
|
68107
|
-
let w = sharpening_amount * uniform.sharpness;
|
|
68108
|
-
var res = (w * (a + b + d + e) + c) / (4.0 * w + 1.0);
|
|
68109
|
-
res = max(res,
|
|
68110
|
-
return toHDR(res);
|
|
68141
|
+
let sharpening_amount = sqrt(min(half(1.0) - max_g, min_g) / max_g);
|
|
68142
|
+
let w = sharpening_amount * half(uniform.sharpness);
|
|
68143
|
+
var res = (w * (a + b + d + e) + c) / (half(4.0) * w + half(1.0));
|
|
68144
|
+
res = max(res, half3(0.0));
|
|
68145
|
+
return toHDR(vec3f(res));
|
|
68111
68146
|
}
|
|
68112
68147
|
#endif
|
|
68113
68148
|
`;
|
|
@@ -68267,6 +68302,15 @@ class RenderPassCompose extends RenderPassShaderQuad {
|
|
|
68267
68302
|
get isSharpnessEnabled() {
|
|
68268
68303
|
return this._sharpness > 0;
|
|
68269
68304
|
}
|
|
68305
|
+
set hdrScene(value) {
|
|
68306
|
+
if (this._hdrScene !== value) {
|
|
68307
|
+
this._hdrScene = value;
|
|
68308
|
+
this._shaderDirty = true;
|
|
68309
|
+
}
|
|
68310
|
+
}
|
|
68311
|
+
get hdrScene() {
|
|
68312
|
+
return this._hdrScene;
|
|
68313
|
+
}
|
|
68270
68314
|
postInit() {
|
|
68271
68315
|
this.setClearColor(Color.BLACK);
|
|
68272
68316
|
this.setClearDepth(1.0);
|
|
@@ -68295,7 +68339,7 @@ class RenderPassCompose extends RenderPassShaderQuad {
|
|
|
68295
68339
|
const declHash = hashCode(customChunks.get('composeDeclarationsPS') ?? '');
|
|
68296
68340
|
const startHash = hashCode(customChunks.get('composeMainStartPS') ?? '');
|
|
68297
68341
|
const endHash = hashCode(customChunks.get('composeMainEndPS') ?? '');
|
|
68298
|
-
const key = `${this.toneMapping}` + `-${gammaCorrectionName}` + `-${this.bloomTexture ? 'bloom' : 'nobloom'}` + `-${this.cocTexture ? 'dof' : 'nodof'}` + `-${this.blurTextureUpscale ? 'dofupscale' : ''}` + `-${this.ssaoTexture ? 'ssao' : 'nossao'}` + `-${this.gradingEnabled ? 'grading' : 'nograding'}` + `-${this.colorEnhanceEnabled ? 'colorenhance' : 'nocolorenhance'}` + `-${this.colorLUT ? 'colorlut' : 'nocolorlut'}` + `-${this.vignetteEnabled ? 'vignette' : 'novignette'}` + `-${this.fringingEnabled ? 'fringing' : 'nofringing'}` + `-${this.taaEnabled ? 'taa' : 'notaa'}` + `-${this.isSharpnessEnabled ? 'cas' : 'nocas'}` + `-${this._debug ?? ''}` + `-decl${declHash}-start${startHash}-end${endHash}`;
|
|
68342
|
+
const key = `${this.toneMapping}` + `-${gammaCorrectionName}` + `-${this.bloomTexture ? 'bloom' : 'nobloom'}` + `-${this.cocTexture ? 'dof' : 'nodof'}` + `-${this.blurTextureUpscale ? 'dofupscale' : ''}` + `-${this.ssaoTexture ? 'ssao' : 'nossao'}` + `-${this.gradingEnabled ? 'grading' : 'nograding'}` + `-${this.colorEnhanceEnabled ? 'colorenhance' : 'nocolorenhance'}` + `-${this.colorLUT ? 'colorlut' : 'nocolorlut'}` + `-${this.vignetteEnabled ? 'vignette' : 'novignette'}` + `-${this.fringingEnabled ? 'fringing' : 'nofringing'}` + `-${this.taaEnabled ? 'taa' : 'notaa'}` + `-${this.isSharpnessEnabled ? this._hdrScene ? 'cashdr' : 'cas' : 'nocas'}` + `-${this._debug ?? ''}` + `-decl${declHash}-start${startHash}-end${endHash}`;
|
|
68299
68343
|
if (this._key !== key) {
|
|
68300
68344
|
this._key = key;
|
|
68301
68345
|
const defines = new Map();
|
|
@@ -68311,7 +68355,10 @@ class RenderPassCompose extends RenderPassShaderQuad {
|
|
|
68311
68355
|
if (this.vignetteEnabled) defines.set('VIGNETTE', true);
|
|
68312
68356
|
if (this.fringingEnabled) defines.set('FRINGING', true);
|
|
68313
68357
|
if (this.taaEnabled) defines.set('TAA', true);
|
|
68314
|
-
if (this.isSharpnessEnabled)
|
|
68358
|
+
if (this.isSharpnessEnabled) {
|
|
68359
|
+
defines.set('CAS', true);
|
|
68360
|
+
if (this._hdrScene) defines.set('CAS_HDR', true);
|
|
68361
|
+
}
|
|
68315
68362
|
if (this._debug) defines.set('DEBUG_COMPOSE', this._debug);
|
|
68316
68363
|
const includes = new Map(shaderChunks);
|
|
68317
68364
|
this.shader = ShaderUtils.createShader(this.device, {
|
|
@@ -68396,7 +68443,7 @@ class RenderPassCompose extends RenderPassShaderQuad {
|
|
|
68396
68443
|
super.execute();
|
|
68397
68444
|
}
|
|
68398
68445
|
constructor(graphicsDevice){
|
|
68399
|
-
super(graphicsDevice), this.sceneTexture = null, this.bloomIntensity = 0.01, this._bloomTexture = null, this._cocTexture = null, this.blurTexture = null, this.blurTextureUpscale = false, this._ssaoTexture = null, this._toneMapping = TONEMAP_LINEAR, this._gradingEnabled = false, this.gradingSaturation = 1, this.gradingContrast = 1, this.gradingBrightness = 1, this.gradingTint = new Color(1, 1, 1, 1), this._shaderDirty = true, this._vignetteEnabled = false, this.vignetteInner = 0.5, this.vignetteOuter = 1.0, this.vignetteCurvature = 0.5, this.vignetteIntensity = 0.3, this.vignetteColor = new Color(0, 0, 0), this._fringingEnabled = false, this.fringingIntensity = 10, this._colorEnhanceEnabled = false, this.colorEnhanceShadows = 0, this.colorEnhanceHighlights = 0, this.colorEnhanceVibrance = 0, this.colorEnhanceDehaze = 0, this.colorEnhanceMidtones = 0, this._taaEnabled = false, this._sharpness = 0.5, this._gammaCorrection = GAMMA_SRGB, this._colorLUT = null, this.colorLUTIntensity = 1, this._key = '', this._debug = null, this._customComposeChunks = new Map([
|
|
68446
|
+
super(graphicsDevice), this.sceneTexture = null, this.bloomIntensity = 0.01, this._bloomTexture = null, this._cocTexture = null, this.blurTexture = null, this.blurTextureUpscale = false, this._ssaoTexture = null, this._toneMapping = TONEMAP_LINEAR, this._gradingEnabled = false, this.gradingSaturation = 1, this.gradingContrast = 1, this.gradingBrightness = 1, this.gradingTint = new Color(1, 1, 1, 1), this._shaderDirty = true, this._vignetteEnabled = false, this.vignetteInner = 0.5, this.vignetteOuter = 1.0, this.vignetteCurvature = 0.5, this.vignetteIntensity = 0.3, this.vignetteColor = new Color(0, 0, 0), this._fringingEnabled = false, this.fringingIntensity = 10, this._colorEnhanceEnabled = false, this.colorEnhanceShadows = 0, this.colorEnhanceHighlights = 0, this.colorEnhanceVibrance = 0, this.colorEnhanceDehaze = 0, this.colorEnhanceMidtones = 0, this._taaEnabled = false, this._hdrScene = true, this._sharpness = 0.5, this._gammaCorrection = GAMMA_SRGB, this._colorLUT = null, this.colorLUTIntensity = 1, this._key = '', this._debug = null, this._customComposeChunks = new Map([
|
|
68400
68447
|
[
|
|
68401
68448
|
'composeDeclarationsPS',
|
|
68402
68449
|
''
|
|
@@ -69838,6 +69885,7 @@ class RenderPassCameraFrame extends RenderPass {
|
|
|
69838
69885
|
setupComposePass(options) {
|
|
69839
69886
|
this.composePass = new RenderPassCompose(this.device);
|
|
69840
69887
|
this.composePass.bloomTexture = this.bloomPass?.bloomTexture;
|
|
69888
|
+
this.composePass.hdrScene = this.hdrFormat !== PIXELFORMAT_RGBA8;
|
|
69841
69889
|
this.composePass.taaEnabled = options.taaEnabled;
|
|
69842
69890
|
this.composePass.cocTexture = this.dofPass?.cocTexture;
|
|
69843
69891
|
this.composePass.blurTexture = this.dofPass?.blurTexture;
|
|
@@ -71254,30 +71302,13 @@ class MiniStats {
|
|
|
71254
71302
|
this.resize(this.sizes[value].width, this.sizes[value].height, this.sizes[value].graphs);
|
|
71255
71303
|
this.opacity = value > 0 ? 0.85 : 0.7;
|
|
71256
71304
|
if (value < this.gpuTimingMinSize && this.gpuPassGraphs) {
|
|
71257
|
-
|
|
71258
|
-
const index = this.graphs.indexOf(passData.graph);
|
|
71259
|
-
if (index !== -1) {
|
|
71260
|
-
this.graphs.splice(index, 1);
|
|
71261
|
-
}
|
|
71262
|
-
this.freeRow(passData.graph);
|
|
71263
|
-
passData.graph.destroy();
|
|
71264
|
-
}
|
|
71265
|
-
this.gpuPassGraphs.clear();
|
|
71266
|
-
const gpuGraph = this.graphs.find((g)=>g.name === 'GPU');
|
|
71267
|
-
if (gpuGraph) gpuGraph.graphType = 0.33;
|
|
71305
|
+
this.clearSubGraphs(this.gpuPassGraphs, 'GPU', 0.33);
|
|
71268
71306
|
}
|
|
71269
71307
|
if (value < this.cpuTimingMinSize && this.cpuGraphs) {
|
|
71270
|
-
|
|
71271
|
-
|
|
71272
|
-
|
|
71273
|
-
|
|
71274
|
-
}
|
|
71275
|
-
this.freeRow(statData.graph);
|
|
71276
|
-
statData.graph.destroy();
|
|
71277
|
-
}
|
|
71278
|
-
this.cpuGraphs.clear();
|
|
71279
|
-
const cpuGraph = this.graphs.find((g)=>g.name === 'CPU');
|
|
71280
|
-
if (cpuGraph) cpuGraph.graphType = 0.66;
|
|
71308
|
+
this.clearSubGraphs(this.cpuGraphs, 'CPU', 0.66);
|
|
71309
|
+
}
|
|
71310
|
+
if (value < this.vramTimingMinSize && this.vramGraphs) {
|
|
71311
|
+
this.clearSubGraphs(this.vramGraphs);
|
|
71281
71312
|
}
|
|
71282
71313
|
}
|
|
71283
71314
|
get activeSizeIndex() {
|
|
@@ -71508,6 +71539,21 @@ class MiniStats {
|
|
|
71508
71539
|
this.graphRows.delete(graph);
|
|
71509
71540
|
}
|
|
71510
71541
|
}
|
|
71542
|
+
clearSubGraphs(subGraphs, mainGraphName, graphType) {
|
|
71543
|
+
for (const statData of subGraphs.values()){
|
|
71544
|
+
const index = this.graphs.indexOf(statData.graph);
|
|
71545
|
+
if (index !== -1) {
|
|
71546
|
+
this.graphs.splice(index, 1);
|
|
71547
|
+
}
|
|
71548
|
+
this.freeRow(statData.graph);
|
|
71549
|
+
statData.graph.destroy();
|
|
71550
|
+
}
|
|
71551
|
+
subGraphs.clear();
|
|
71552
|
+
if (mainGraphName) {
|
|
71553
|
+
const mainGraph = this.graphs.find((g)=>g.name === mainGraphName);
|
|
71554
|
+
if (mainGraph) mainGraph.graphType = graphType;
|
|
71555
|
+
}
|
|
71556
|
+
}
|
|
71511
71557
|
ensureTextureHeight(requiredRows) {
|
|
71512
71558
|
const maxWidth = this.sizes[this.sizes.length - 1].width;
|
|
71513
71559
|
const requiredWidth = math.nextPowerOfTwo(maxWidth);
|
|
@@ -73517,6 +73563,7 @@ class AnimState {
|
|
|
73517
73563
|
result = [];
|
|
73518
73564
|
position = new Vec3();
|
|
73519
73565
|
target = new Vec3();
|
|
73566
|
+
fov = 90;
|
|
73520
73567
|
constructor(spline, duration, loopMode, frameRate) {
|
|
73521
73568
|
this.spline = spline;
|
|
73522
73569
|
this.cursor.reset(duration, loopMode);
|
|
@@ -73532,18 +73579,20 @@ class AnimState {
|
|
|
73532
73579
|
if (result.every(isFinite)) {
|
|
73533
73580
|
position.set(result[0], result[1], result[2]);
|
|
73534
73581
|
target.set(result[3], result[4], result[5]);
|
|
73582
|
+
this.fov = result[6];
|
|
73535
73583
|
}
|
|
73536
73584
|
}
|
|
73537
73585
|
// construct an animation from a settings track
|
|
73538
73586
|
static fromTrack(track) {
|
|
73539
73587
|
const { keyframes, duration, frameRate, loopMode, smoothness } = track;
|
|
73540
73588
|
const { times, values } = keyframes;
|
|
73541
|
-
const { position, target } = values;
|
|
73542
|
-
// construct the points array containing position and
|
|
73589
|
+
const { position, target, fov } = values;
|
|
73590
|
+
// construct the points array containing position, target and fov
|
|
73543
73591
|
const points = [];
|
|
73544
73592
|
for (let i = 0; i < times.length; i++) {
|
|
73545
73593
|
points.push(position[i * 3], position[i * 3 + 1], position[i * 3 + 2]);
|
|
73546
73594
|
points.push(target[i * 3], target[i * 3 + 1], target[i * 3 + 2]);
|
|
73595
|
+
points.push(fov[i]);
|
|
73547
73596
|
}
|
|
73548
73597
|
const extra = (duration === times[times.length - 1] / frameRate) ? 1 : 0;
|
|
73549
73598
|
const spline = CubicSpline.fromPointsLooping((duration + extra) * frameRate, times, points, smoothness);
|
|
@@ -73558,14 +73607,13 @@ class AnimController {
|
|
|
73558
73607
|
this.animState.update(0);
|
|
73559
73608
|
}
|
|
73560
73609
|
onEnter(camera) {
|
|
73561
|
-
// snap camera to start position
|
|
73562
73610
|
camera.look(this.animState.position, this.animState.target);
|
|
73611
|
+
camera.fov = this.animState.fov;
|
|
73563
73612
|
}
|
|
73564
73613
|
update(deltaTime, inputFrame, camera) {
|
|
73565
73614
|
this.animState.update(deltaTime);
|
|
73566
|
-
// update camera pose
|
|
73567
73615
|
camera.look(this.animState.position, this.animState.target);
|
|
73568
|
-
|
|
73616
|
+
camera.fov = this.animState.fov;
|
|
73569
73617
|
inputFrame.read();
|
|
73570
73618
|
}
|
|
73571
73619
|
onExit(camera) {
|
|
@@ -73621,6 +73669,7 @@ const p$1 = new Pose();
|
|
|
73621
73669
|
const pushOut = { x: 0, y: 0, z: 0 };
|
|
73622
73670
|
class FlyController {
|
|
73623
73671
|
controller;
|
|
73672
|
+
fov = 90;
|
|
73624
73673
|
/** Optional voxel collider for sphere collision with sliding */
|
|
73625
73674
|
collider = null;
|
|
73626
73675
|
constructor() {
|
|
@@ -73664,6 +73713,7 @@ class FlyController {
|
|
|
73664
73713
|
}
|
|
73665
73714
|
}
|
|
73666
73715
|
camera.position.copy(pose.position);
|
|
73716
|
+
camera.fov = this.fov;
|
|
73667
73717
|
}
|
|
73668
73718
|
onExit(camera) {
|
|
73669
73719
|
}
|
|
@@ -73675,6 +73725,7 @@ class FlyController {
|
|
|
73675
73725
|
const p = new Pose();
|
|
73676
73726
|
class OrbitController {
|
|
73677
73727
|
controller;
|
|
73728
|
+
fov = 90;
|
|
73678
73729
|
constructor() {
|
|
73679
73730
|
this.controller = new OrbitController$1();
|
|
73680
73731
|
this.controller.zoomRange = new Vec2(0.01, Infinity);
|
|
@@ -73694,6 +73745,7 @@ class OrbitController {
|
|
|
73694
73745
|
camera.position.copy(pose.position);
|
|
73695
73746
|
camera.angles.copy(pose.angles);
|
|
73696
73747
|
camera.distance = pose.distance;
|
|
73748
|
+
camera.fov = this.fov;
|
|
73697
73749
|
}
|
|
73698
73750
|
onExit(camera) {
|
|
73699
73751
|
}
|
|
@@ -73701,42 +73753,51 @@ class OrbitController {
|
|
|
73701
73753
|
p.position.copy(camera.position);
|
|
73702
73754
|
p.angles.copy(camera.angles);
|
|
73703
73755
|
p.distance = camera.distance;
|
|
73756
|
+
this.fov = camera.fov;
|
|
73704
73757
|
this.controller.attach(p, false);
|
|
73705
73758
|
}
|
|
73706
73759
|
}
|
|
73707
73760
|
|
|
73761
|
+
const FIXED_DT = 1 / 60;
|
|
73762
|
+
const MAX_SUBSTEPS = 10;
|
|
73708
73763
|
/** Pre-allocated push-out vector for capsule collision */
|
|
73709
73764
|
const out = { x: 0, y: 0, z: 0 };
|
|
73710
73765
|
const v = new Vec3();
|
|
73711
73766
|
const d = new Vec3();
|
|
73712
73767
|
const forward = new Vec3();
|
|
73713
73768
|
const right$1 = new Vec3();
|
|
73769
|
+
const moveStep = [0, 0, 0];
|
|
73714
73770
|
const offset = new Vec3();
|
|
73715
73771
|
const rotation = new Quat();
|
|
73716
73772
|
/**
|
|
73717
|
-
* First-person
|
|
73773
|
+
* First-person camera controller with spring-damper suspension over voxel terrain.
|
|
73718
73774
|
*
|
|
73719
73775
|
* Movement is constrained to the horizontal plane (XZ) relative to the camera yaw.
|
|
73720
|
-
* Vertical
|
|
73721
|
-
* voxel
|
|
73776
|
+
* Vertical positioning uses a spring-damper system that hovers the capsule above the
|
|
73777
|
+
* voxel surface, filtering out terrain noise for smooth camera motion. Capsule
|
|
73778
|
+
* collision handles walls and obstacles. When airborne, normal gravity applies.
|
|
73722
73779
|
*/
|
|
73723
73780
|
class WalkController {
|
|
73724
73781
|
/**
|
|
73725
73782
|
* Optional voxel collider for capsule collision with sliding
|
|
73726
73783
|
*/
|
|
73727
73784
|
collider = null;
|
|
73785
|
+
/**
|
|
73786
|
+
* Field of view in degrees for walk mode.
|
|
73787
|
+
*/
|
|
73788
|
+
fov = 96;
|
|
73728
73789
|
/**
|
|
73729
73790
|
* Total capsule height in meters (default: human proportion)
|
|
73730
73791
|
*/
|
|
73731
|
-
capsuleHeight = 1.
|
|
73792
|
+
capsuleHeight = 1.5;
|
|
73732
73793
|
/**
|
|
73733
73794
|
* Capsule radius in meters
|
|
73734
73795
|
*/
|
|
73735
|
-
capsuleRadius = 0.
|
|
73796
|
+
capsuleRadius = 0.2;
|
|
73736
73797
|
/**
|
|
73737
73798
|
* Camera height from the bottom of the capsule in meters
|
|
73738
73799
|
*/
|
|
73739
|
-
eyeHeight = 1.
|
|
73800
|
+
eyeHeight = 1.3;
|
|
73740
73801
|
/**
|
|
73741
73802
|
* Gravity acceleration in m/s^2
|
|
73742
73803
|
*/
|
|
@@ -73744,11 +73805,11 @@ class WalkController {
|
|
|
73744
73805
|
/**
|
|
73745
73806
|
* Jump velocity in m/s
|
|
73746
73807
|
*/
|
|
73747
|
-
jumpSpeed =
|
|
73808
|
+
jumpSpeed = 4;
|
|
73748
73809
|
/**
|
|
73749
73810
|
* Movement speed in m/s when grounded
|
|
73750
73811
|
*/
|
|
73751
|
-
moveGroundSpeed =
|
|
73812
|
+
moveGroundSpeed = 7;
|
|
73752
73813
|
/**
|
|
73753
73814
|
* Movement speed in m/s when in the air (for air control)
|
|
73754
73815
|
*/
|
|
@@ -73765,41 +73826,116 @@ class WalkController {
|
|
|
73765
73826
|
* Velocity damping factor when grounded (0 = no damping, 1 = full damping)
|
|
73766
73827
|
*/
|
|
73767
73828
|
velocityDampingGround = 0.99;
|
|
73829
|
+
/**
|
|
73830
|
+
* Velocity damping factor when grounded with no movement input.
|
|
73831
|
+
* More aggressive than normal ground damping to prevent slope drift.
|
|
73832
|
+
*/
|
|
73833
|
+
velocityDampingIdle = 0.9;
|
|
73768
73834
|
/**
|
|
73769
73835
|
* Velocity damping factor when in the air (0 = no damping, 1 = full damping)
|
|
73770
73836
|
*/
|
|
73771
|
-
velocityDampingAir = 0.
|
|
73837
|
+
velocityDampingAir = 0.998;
|
|
73838
|
+
/**
|
|
73839
|
+
* Target clearance from capsule bottom to ground surface in meters.
|
|
73840
|
+
* The capsule hovers this far above terrain to avoid bouncing on noisy voxels.
|
|
73841
|
+
*/
|
|
73842
|
+
hoverHeight = 0.2;
|
|
73843
|
+
/**
|
|
73844
|
+
* Spring stiffness for ground-following suspension (higher = stiffer tracking).
|
|
73845
|
+
*/
|
|
73846
|
+
springStiffness = 800;
|
|
73847
|
+
/**
|
|
73848
|
+
* Damping coefficient for ground-following suspension.
|
|
73849
|
+
* Critical damping is approximately 2 * sqrt(springStiffness).
|
|
73850
|
+
*/
|
|
73851
|
+
springDamping = 57;
|
|
73852
|
+
/**
|
|
73853
|
+
* Maximum downward raycast distance to search for ground below the capsule.
|
|
73854
|
+
*/
|
|
73855
|
+
groundProbeRange = 1.0;
|
|
73772
73856
|
_position = new Vec3();
|
|
73857
|
+
_prevPosition = new Vec3();
|
|
73773
73858
|
_angles = new Vec3();
|
|
73774
73859
|
_velocity = new Vec3();
|
|
73860
|
+
_accumulator = 0;
|
|
73775
73861
|
_grounded = false;
|
|
73776
73862
|
_jumping = false;
|
|
73863
|
+
_jumpHeld = false;
|
|
73777
73864
|
onEnter(camera) {
|
|
73778
73865
|
this.goto(camera);
|
|
73779
73866
|
if (this.collider) {
|
|
73780
|
-
this.
|
|
73781
|
-
if (
|
|
73867
|
+
const groundY = this._probeGround(this._position);
|
|
73868
|
+
if (groundY !== null) {
|
|
73782
73869
|
this._grounded = true;
|
|
73783
73870
|
this._velocity.y = 0;
|
|
73871
|
+
this._position.y = groundY + this.hoverHeight + this.eyeHeight;
|
|
73872
|
+
this._prevPosition.copy(this._position);
|
|
73784
73873
|
}
|
|
73785
73874
|
}
|
|
73786
73875
|
}
|
|
73787
73876
|
update(deltaTime, inputFrame, camera) {
|
|
73788
73877
|
const { move, rotate } = inputFrame.read();
|
|
73789
|
-
//
|
|
73878
|
+
// apply rotation at display rate for responsive mouse look
|
|
73879
|
+
this._angles.add(v.set(-rotate[1], -rotate[0], 0));
|
|
73880
|
+
this._angles.x = math.clamp(this._angles.x, -90, 90);
|
|
73881
|
+
this._accumulator = Math.min(this._accumulator + deltaTime, MAX_SUBSTEPS * FIXED_DT);
|
|
73882
|
+
const numSteps = Math.floor(this._accumulator / FIXED_DT);
|
|
73883
|
+
if (numSteps > 0) {
|
|
73884
|
+
const invSteps = 1 / numSteps;
|
|
73885
|
+
moveStep[0] = move[0] * invSteps;
|
|
73886
|
+
moveStep[1] = move[1];
|
|
73887
|
+
moveStep[2] = move[2] * invSteps;
|
|
73888
|
+
for (let i = 0; i < numSteps; i++) {
|
|
73889
|
+
this._prevPosition.copy(this._position);
|
|
73890
|
+
this._step(FIXED_DT, moveStep);
|
|
73891
|
+
this._accumulator -= FIXED_DT;
|
|
73892
|
+
}
|
|
73893
|
+
}
|
|
73894
|
+
const alpha = this._accumulator / FIXED_DT;
|
|
73895
|
+
camera.position.lerp(this._prevPosition, this._position, alpha);
|
|
73896
|
+
camera.angles.set(this._angles.x, this._angles.y, 0);
|
|
73897
|
+
camera.fov = this.fov;
|
|
73898
|
+
}
|
|
73899
|
+
_step(dt, move) {
|
|
73900
|
+
const hasInput = move[0] !== 0 || move[2] !== 0;
|
|
73901
|
+
// ground probe: cast a ray downward to find the terrain surface
|
|
73902
|
+
const groundY = this._probeGround(this._position);
|
|
73903
|
+
const hasGround = groundY !== null;
|
|
73904
|
+
// jump (require release before re-triggering)
|
|
73790
73905
|
if (this._velocity.y < 0) {
|
|
73791
73906
|
this._jumping = false;
|
|
73792
73907
|
}
|
|
73793
|
-
if (move[1] && !this._jumping && this._grounded) {
|
|
73908
|
+
if (move[1] && !this._jumping && this._grounded && !this._jumpHeld) {
|
|
73794
73909
|
this._jumping = true;
|
|
73795
73910
|
this._velocity.y = this.jumpSpeed;
|
|
73796
73911
|
this._grounded = false;
|
|
73797
73912
|
}
|
|
73798
|
-
|
|
73799
|
-
|
|
73800
|
-
|
|
73801
|
-
|
|
73802
|
-
|
|
73913
|
+
this._jumpHeld = !!move[1];
|
|
73914
|
+
// vertical force: spring-damper when ground is detected, gravity when airborne
|
|
73915
|
+
if (hasGround && !this._jumping) {
|
|
73916
|
+
const targetY = groundY + this.hoverHeight + this.eyeHeight;
|
|
73917
|
+
const displacement = this._position.y - targetY;
|
|
73918
|
+
if (displacement > 0.1) {
|
|
73919
|
+
// well above target (jump/ledge): freefall, snap to rest height on arrival
|
|
73920
|
+
this._velocity.y -= this.gravity * dt;
|
|
73921
|
+
const nextY = this._position.y + this._velocity.y * dt;
|
|
73922
|
+
if (nextY <= targetY) {
|
|
73923
|
+
this._position.y = targetY;
|
|
73924
|
+
this._velocity.y = 0;
|
|
73925
|
+
}
|
|
73926
|
+
this._grounded = false;
|
|
73927
|
+
}
|
|
73928
|
+
else {
|
|
73929
|
+
// at or near target (walking/slopes): spring tracks terrain
|
|
73930
|
+
const springForce = -this.springStiffness * displacement - this.springDamping * this._velocity.y;
|
|
73931
|
+
this._velocity.y += springForce * dt;
|
|
73932
|
+
this._grounded = true;
|
|
73933
|
+
}
|
|
73934
|
+
}
|
|
73935
|
+
else {
|
|
73936
|
+
this._velocity.y -= this.gravity * dt;
|
|
73937
|
+
this._grounded = false;
|
|
73938
|
+
}
|
|
73803
73939
|
// move
|
|
73804
73940
|
rotation.setFromEulerAngles(0, this._angles.y, 0);
|
|
73805
73941
|
rotation.transformVector(Vec3.FORWARD, forward);
|
|
@@ -73808,15 +73944,16 @@ class WalkController {
|
|
|
73808
73944
|
offset.add(forward.mulScalar(move[2]));
|
|
73809
73945
|
offset.add(right$1.mulScalar(move[0]));
|
|
73810
73946
|
this._velocity.add(offset.mulScalar(this._grounded ? this.moveGroundSpeed : this.moveAirSpeed));
|
|
73811
|
-
|
|
73947
|
+
// horizontal damping: aggressive when grounded with no input to prevent slope drift
|
|
73948
|
+
const dampFactor = this._grounded ?
|
|
73949
|
+
(hasInput ? this.velocityDampingGround : this.velocityDampingIdle) :
|
|
73950
|
+
this.velocityDampingAir;
|
|
73951
|
+
const alpha = damp(dampFactor, dt);
|
|
73812
73952
|
this._velocity.x = math.lerp(this._velocity.x, 0, alpha);
|
|
73813
73953
|
this._velocity.z = math.lerp(this._velocity.z, 0, alpha);
|
|
73814
|
-
this._position.add(v.copy(this._velocity).mulScalar(
|
|
73815
|
-
// collision
|
|
73954
|
+
this._position.add(v.copy(this._velocity).mulScalar(dt));
|
|
73955
|
+
// capsule collision: walls, ceiling, and fallback floor contact
|
|
73816
73956
|
this._checkCollision(this._position, d);
|
|
73817
|
-
// update camera
|
|
73818
|
-
camera.position.copy(this._position);
|
|
73819
|
-
camera.angles.set(this._angles.x, this._angles.y, 0);
|
|
73820
73957
|
}
|
|
73821
73958
|
onExit(_camera) {
|
|
73822
73959
|
// nothing to clean up
|
|
@@ -73829,24 +73966,58 @@ class WalkController {
|
|
|
73829
73966
|
goto(camera) {
|
|
73830
73967
|
// position
|
|
73831
73968
|
this._position.copy(camera.position);
|
|
73969
|
+
this._prevPosition.copy(this._position);
|
|
73832
73970
|
// angles (clamp pitch to avoid gimbal lock)
|
|
73833
73971
|
this._angles.set(camera.angles.x, camera.angles.y, 0);
|
|
73834
73972
|
// reset velocity and state
|
|
73835
73973
|
this._velocity.set(0, 0, 0);
|
|
73836
73974
|
this._grounded = false;
|
|
73837
73975
|
this._jumping = false;
|
|
73976
|
+
this._accumulator = 0;
|
|
73838
73977
|
}
|
|
73839
73978
|
/**
|
|
73840
|
-
*
|
|
73979
|
+
* Cast multiple rays downward to find the average ground surface height.
|
|
73980
|
+
* Uses 5 rays (center + 4 cardinal at capsule radius) to spatially filter
|
|
73981
|
+
* noisy voxel heights, giving the spring a smoother target.
|
|
73841
73982
|
*
|
|
73842
|
-
* @param pos -
|
|
73843
|
-
* @
|
|
73844
|
-
|
|
73983
|
+
* @param pos - Eye position in PlayCanvas world space.
|
|
73984
|
+
* @returns Average ground surface Y in PlayCanvas space, or null if no ground found.
|
|
73985
|
+
*/
|
|
73986
|
+
_probeGround(pos) {
|
|
73987
|
+
if (!this.collider)
|
|
73988
|
+
return null;
|
|
73989
|
+
const vy = -(pos.y - this.eyeHeight);
|
|
73990
|
+
const r = this.capsuleRadius;
|
|
73991
|
+
const range = this.groundProbeRange;
|
|
73992
|
+
let totalY = 0;
|
|
73993
|
+
let hitCount = 0;
|
|
73994
|
+
for (let i = 0; i < 5; i++) {
|
|
73995
|
+
let vx = -pos.x;
|
|
73996
|
+
let vz = pos.z;
|
|
73997
|
+
if (i === 1)
|
|
73998
|
+
vx -= r;
|
|
73999
|
+
else if (i === 2)
|
|
74000
|
+
vx += r;
|
|
74001
|
+
else if (i === 3)
|
|
74002
|
+
vz += r;
|
|
74003
|
+
else if (i === 4)
|
|
74004
|
+
vz -= r;
|
|
74005
|
+
const hit = this.collider.queryRay(vx, vy, vz, 0, 1, 0, range);
|
|
74006
|
+
if (hit) {
|
|
74007
|
+
totalY += -hit.y;
|
|
74008
|
+
hitCount++;
|
|
74009
|
+
}
|
|
74010
|
+
}
|
|
74011
|
+
return hitCount > 0 ? totalY / hitCount : null;
|
|
74012
|
+
}
|
|
74013
|
+
/**
|
|
74014
|
+
* Check for capsule collision and apply push-out displacement.
|
|
74015
|
+
* Handles walls, ceiling hits, and fallback floor contact when airborne.
|
|
74016
|
+
*
|
|
74017
|
+
* @param pos - Eye position in PlayCanvas world space.
|
|
74018
|
+
* @param disp - Pre-allocated vector to receive the collision push-out displacement.
|
|
73845
74019
|
*/
|
|
73846
74020
|
_checkCollision(pos, disp) {
|
|
73847
|
-
// derive capsule center from eye position in PlayCanvas space:
|
|
73848
|
-
// bottom of capsule = eyePos.y - eyeHeight
|
|
73849
|
-
// capsule center = eyePos.y - eyeHeight + capsuleHeight / 2
|
|
73850
74021
|
const center = pos.y - this.eyeHeight + this.capsuleHeight * 0.5;
|
|
73851
74022
|
const half = this.capsuleHeight * 0.5 - this.capsuleRadius;
|
|
73852
74023
|
// convert to voxel space (negate X, negate Y, keep Z)
|
|
@@ -73854,21 +74025,18 @@ class WalkController {
|
|
|
73854
74025
|
const vy = -center;
|
|
73855
74026
|
const vz = pos.z;
|
|
73856
74027
|
if (this.collider.queryCapsule(vx, vy, vz, half, this.capsuleRadius, out)) {
|
|
73857
|
-
// push out vector to playcanvas space
|
|
73858
74028
|
disp.set(-out.x, -out.y, out.z);
|
|
73859
|
-
// apply displacement
|
|
73860
74029
|
pos.add(disp);
|
|
73861
|
-
//
|
|
73862
|
-
if (disp.y
|
|
74030
|
+
// ceiling collision: cancel upward velocity
|
|
74031
|
+
if (disp.y < 0 && this._velocity.y > 0) {
|
|
73863
74032
|
this._velocity.y = 0;
|
|
73864
|
-
this._grounded = true;
|
|
73865
74033
|
}
|
|
73866
|
-
//
|
|
73867
|
-
if (disp.y
|
|
74034
|
+
// airborne floor collision: transition to grounded as a fallback safety net
|
|
74035
|
+
if (!this._grounded && disp.y > 0 && this._velocity.y < 0) {
|
|
73868
74036
|
this._velocity.y = 0;
|
|
74037
|
+
this._grounded = true;
|
|
73869
74038
|
}
|
|
73870
74039
|
}
|
|
73871
|
-
return disp;
|
|
73872
74040
|
}
|
|
73873
74041
|
}
|
|
73874
74042
|
|
|
@@ -74023,6 +74191,8 @@ class CameraManager {
|
|
|
74023
74191
|
walk: new WalkController(),
|
|
74024
74192
|
anim: animTrack ? new AnimController(animTrack) : null
|
|
74025
74193
|
};
|
|
74194
|
+
controllers.orbit.fov = resetCamera.fov;
|
|
74195
|
+
controllers.fly.fov = resetCamera.fov;
|
|
74026
74196
|
controllers.fly.collider = collider;
|
|
74027
74197
|
controllers.walk.collider = collider;
|
|
74028
74198
|
const walkSource = new WalkSource();
|
|
@@ -74036,13 +74206,14 @@ class CameraManager {
|
|
|
74036
74206
|
state.hasAnimation = !!controllers.anim;
|
|
74037
74207
|
state.animationDuration = controllers.anim ? controllers.anim.animState.cursor.duration : 0;
|
|
74038
74208
|
// initialize camera mode and initial camera position
|
|
74039
|
-
state.cameraMode = state.hasAnimation ? 'anim' : (isObjectExperience ? 'orbit' : 'fly');
|
|
74209
|
+
state.cameraMode = state.hasAnimation ? 'anim' : (isObjectExperience ? 'orbit' : (collider ? 'walk' : 'fly'));
|
|
74040
74210
|
this.camera.copy(resetCamera);
|
|
74041
74211
|
const target = new Camera(this.camera); // the active controller updates this
|
|
74042
74212
|
const from = new Camera(this.camera); // stores the previous camera state during transition
|
|
74043
|
-
|
|
74044
|
-
|
|
74045
|
-
|
|
74213
|
+
const defaultMode = isObjectExperience ? 'orbit' : (collider ? 'walk' : 'fly');
|
|
74214
|
+
let fromMode = defaultMode;
|
|
74215
|
+
// tracks the mode to restore when exiting walk
|
|
74216
|
+
let preWalkMode = isObjectExperience ? 'orbit' : 'fly';
|
|
74046
74217
|
// enter the initial controller
|
|
74047
74218
|
getController(state.cameraMode).onEnter(this.camera);
|
|
74048
74219
|
// transition state
|
|
@@ -74172,7 +74343,6 @@ class CameraManager {
|
|
|
74172
74343
|
tmpCamera.fov = initial.fov;
|
|
74173
74344
|
tmpCamera.look(new Vec3(initial.position), new Vec3(initial.target));
|
|
74174
74345
|
controllers.orbit.goto(tmpCamera);
|
|
74175
|
-
target.fov = tmpCamera.fov;
|
|
74176
74346
|
startTransition();
|
|
74177
74347
|
});
|
|
74178
74348
|
// tap-to-walk: start auto-walking toward a picked 3D position
|
|
@@ -74618,11 +74788,9 @@ class InputController {
|
|
|
74618
74788
|
case 'h':
|
|
74619
74789
|
events.fire('inputEvent', 'toggleHelp');
|
|
74620
74790
|
break;
|
|
74621
|
-
|
|
74622
|
-
|
|
74623
|
-
|
|
74624
|
-
case 'd':
|
|
74625
|
-
if (state.cameraMode === 'walk' && state.inputMode === 'desktop' && !state.gamingControls) {
|
|
74791
|
+
default:
|
|
74792
|
+
if ((event.code === 'KeyW' || event.code === 'KeyA' || event.code === 'KeyS' || event.code === 'KeyD') &&
|
|
74793
|
+
state.cameraMode === 'walk' && state.inputMode === 'desktop' && !state.gamingControls) {
|
|
74626
74794
|
state.gamingControls = true;
|
|
74627
74795
|
}
|
|
74628
74796
|
break;
|
|
@@ -75480,8 +75648,8 @@ class VoxelDebugOverlay {
|
|
|
75480
75648
|
|
|
75481
75649
|
const SVGNS = 'http://www.w3.org/2000/svg';
|
|
75482
75650
|
const NUM_SAMPLES = 12;
|
|
75483
|
-
const CIRCLE_OUTER_RADIUS = 0.
|
|
75484
|
-
const CIRCLE_INNER_RADIUS = 0.
|
|
75651
|
+
const CIRCLE_OUTER_RADIUS = 0.2;
|
|
75652
|
+
const CIRCLE_INNER_RADIUS = 0.17;
|
|
75485
75653
|
const BEZIER_K = 1 / 6;
|
|
75486
75654
|
const NORMAL_SMOOTH_FACTOR = 0.25;
|
|
75487
75655
|
const tmpV = new Vec3();
|
|
@@ -77945,7 +78113,7 @@ const initXr = (global) => {
|
|
|
77945
78113
|
});
|
|
77946
78114
|
};
|
|
77947
78115
|
|
|
77948
|
-
var version = "1.
|
|
78116
|
+
var version = "1.17.1";
|
|
77949
78117
|
|
|
77950
78118
|
const loadGsplat = async (app, config, progressCallback) => {
|
|
77951
78119
|
const { contents, contentUrl, unified, aa } = config;
|