@playcanvas/supersplat-viewer 1.16.5 → 1.16.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/public/index.js +394 -22
- package/public/index.js.map +1 -1
package/package.json
CHANGED
package/public/index.js
CHANGED
|
@@ -72736,6 +72736,7 @@ class VoxelDebugOverlay {
|
|
|
72736
72736
|
}
|
|
72737
72737
|
}
|
|
72738
72738
|
|
|
72739
|
+
// ── gsplat fragment shader overrides (GLSL) ─────────────────────────────────
|
|
72739
72740
|
const gsplatPSGlsl = /* glsl */ `
|
|
72740
72741
|
|
|
72741
72742
|
#ifndef DITHER_NONE
|
|
@@ -72847,22 +72848,36 @@ void main(void) {
|
|
|
72847
72848
|
vec3 walkWorldPos = walkReconstructWorldPos();
|
|
72848
72849
|
float xzDist = length(walkWorldPos.xz - walk_target.xz);
|
|
72849
72850
|
|
|
72850
|
-
float
|
|
72851
|
+
float nd = xzDist / walk_radius;
|
|
72852
|
+
float lightFalloff = 1.0 / (1.0 + nd * nd * 8.0);
|
|
72853
|
+
float coreBoost = 1.0 / (1.0 + nd * nd * 200.0);
|
|
72851
72854
|
|
|
72852
|
-
float
|
|
72853
|
-
float ringDist = abs(xzDist / walk_radius - ringPhase);
|
|
72854
|
-
float ring = smoothstep(0.12, 0.0, ringDist) * 0.4;
|
|
72855
|
-
|
|
72856
|
-
float glow = (columnFade * 0.3 + ring) * alpha;
|
|
72855
|
+
float pulse = 1.0 + 0.1 * sin(walk_time * 3.0);
|
|
72857
72856
|
|
|
72858
|
-
|
|
72859
|
-
|
|
72857
|
+
float ringPhase = fract(walk_time * 0.5);
|
|
72858
|
+
float ringPos = nd - ringPhase;
|
|
72859
|
+
float ringFade = 1.0 - ringPhase;
|
|
72860
|
+
float crest = smoothstep(0.1, 0.0, abs(ringPos)) * 1.0 * ringFade * (1.0 + lightFalloff);
|
|
72861
|
+
float trough = smoothstep(0.25, 0.0, abs(ringPos + 0.15)) * -1.0 * ringFade;
|
|
72862
|
+
float ring = crest + trough;
|
|
72863
|
+
|
|
72864
|
+
float intensity = (lightFalloff * 0.8 + coreBoost * 1.5 + ring) * pulse;
|
|
72865
|
+
|
|
72866
|
+
float lum = dot(gaussianColor.rgb, vec3(0.299, 0.587, 0.114));
|
|
72867
|
+
float adaptiveIntensity = intensity * (1.0 - lum * 0.7);
|
|
72868
|
+
vec3 litColor = gaussianColor.xyz * (1.0 + vec3(0.85, 0.92, 1.0) * adaptiveIntensity);
|
|
72869
|
+
float spatialFalloff = normExp(A);
|
|
72870
|
+
float boostedBase = mix(gaussianColor.a, 1.0, min(intensity * 0.3, 1.0));
|
|
72871
|
+
float glowAlpha = spatialFalloff * boostedBase;
|
|
72872
|
+
|
|
72873
|
+
gl_FragColor = vec4(litColor * glowAlpha, glowAlpha);
|
|
72860
72874
|
} else {
|
|
72861
72875
|
gl_FragColor = vec4(gaussianColor.xyz * alpha, alpha);
|
|
72862
72876
|
}
|
|
72863
72877
|
#endif
|
|
72864
72878
|
}
|
|
72865
72879
|
`;
|
|
72880
|
+
// ── gsplat fragment shader overrides (WGSL) ─────────────────────────────────
|
|
72866
72881
|
const gsplatPSWgsl = /* wgsl */ `
|
|
72867
72882
|
|
|
72868
72883
|
#ifndef DITHER_NONE
|
|
@@ -72917,7 +72932,7 @@ fn walkReconstructWorldPos(fragCoord: vec4f) -> vec3f {
|
|
|
72917
72932
|
let ndc = fragCoord.xy * uniform.viewport_size.zw * 2.0 - 1.0;
|
|
72918
72933
|
let viewPos = vec3f(
|
|
72919
72934
|
ndc.x * linearDepth / uniform.matrix_projection[0][0],
|
|
72920
|
-
ndc.y * linearDepth / uniform.matrix_projection[1][1],
|
|
72935
|
+
-ndc.y * linearDepth / uniform.matrix_projection[1][1],
|
|
72921
72936
|
-linearDepth
|
|
72922
72937
|
);
|
|
72923
72938
|
return (uniform.walk_viewInverse * vec4f(viewPos, 1.0)).xyz;
|
|
@@ -72978,16 +72993,29 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
|
|
|
72978
72993
|
let walkWorldPos = walkReconstructWorldPos(pcPosition);
|
|
72979
72994
|
let xzDist = length(walkWorldPos.xz - uniform.walk_target.xz);
|
|
72980
72995
|
|
|
72981
|
-
let
|
|
72996
|
+
let nd = xzDist / uniform.walk_radius;
|
|
72997
|
+
let lightFalloff = 1.0 / (1.0 + nd * nd * 8.0);
|
|
72998
|
+
let coreBoost = 1.0 / (1.0 + nd * nd * 200.0);
|
|
72982
72999
|
|
|
72983
|
-
let
|
|
72984
|
-
let ringDist = abs(xzDist / uniform.walk_radius - ringPhase);
|
|
72985
|
-
let ring = smoothstep(0.12, 0.0, ringDist) * 0.4;
|
|
72986
|
-
|
|
72987
|
-
let glow = (columnFade * 0.3 + ring) * alpha;
|
|
73000
|
+
let pulse = 1.0 + 0.1 * sin(uniform.walk_time * 3.0);
|
|
72988
73001
|
|
|
72989
|
-
let
|
|
72990
|
-
|
|
73002
|
+
let ringPhase = fract(uniform.walk_time * 0.5);
|
|
73003
|
+
let ringPos = nd - ringPhase;
|
|
73004
|
+
let ringFade = 1.0 - ringPhase;
|
|
73005
|
+
let crest = smoothstep(0.1, 0.0, abs(ringPos)) * 1.0 * ringFade * (1.0 + lightFalloff);
|
|
73006
|
+
let trough = smoothstep(0.25, 0.0, abs(ringPos + 0.15)) * -1.0 * ringFade;
|
|
73007
|
+
let ring = crest + trough;
|
|
73008
|
+
|
|
73009
|
+
let intensity = (lightFalloff * 0.8 + coreBoost * 1.5 + ring) * pulse;
|
|
73010
|
+
|
|
73011
|
+
let lum = dot(gc, vec3f(0.299, 0.587, 0.114));
|
|
73012
|
+
let adaptiveIntensity = intensity * (1.0 - lum * 0.7);
|
|
73013
|
+
let litColor = gc * (1.0 + vec3f(0.85, 0.92, 1.0) * adaptiveIntensity);
|
|
73014
|
+
let spatialFalloff = normExp(A);
|
|
73015
|
+
let boostedBase = mix(f32(gaussianColor.a), 1.0, min(intensity * 0.3, 1.0));
|
|
73016
|
+
let glowAlpha = spatialFalloff * boostedBase;
|
|
73017
|
+
|
|
73018
|
+
output.color = vec4f(litColor * glowAlpha, glowAlpha);
|
|
72991
73019
|
} else {
|
|
72992
73020
|
output.color = vec4f(gc * alpha, alpha);
|
|
72993
73021
|
}
|
|
@@ -72995,14 +73023,244 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
|
|
|
72995
73023
|
|
|
72996
73024
|
return output;
|
|
72997
73025
|
}`;
|
|
73026
|
+
// ── Core billboard shaders ──────────────────────────────────────────────────
|
|
73027
|
+
const coreVS = /* glsl */ `
|
|
73028
|
+
attribute vec3 vertex_position;
|
|
73029
|
+
|
|
73030
|
+
uniform mat4 matrix_viewProjection;
|
|
73031
|
+
uniform mat4 walk_viewInverse;
|
|
73032
|
+
uniform vec3 walk_target;
|
|
73033
|
+
uniform vec4 viewport_size;
|
|
73034
|
+
|
|
73035
|
+
varying vec2 vUV;
|
|
73036
|
+
|
|
73037
|
+
void main() {
|
|
73038
|
+
vec3 camRight = normalize(vec3(walk_viewInverse[0][0], 0.0, walk_viewInverse[0][2]));
|
|
73039
|
+
vec3 up = vec3(0.0, 1.0, 0.0);
|
|
73040
|
+
|
|
73041
|
+
float halfWidth = 0.0075;
|
|
73042
|
+
float halfHeight = 10000.0;
|
|
73043
|
+
|
|
73044
|
+
vec3 centerWorld = walk_target + up * vertex_position.y * halfHeight;
|
|
73045
|
+
|
|
73046
|
+
vec4 targetClip = matrix_viewProjection * vec4(walk_target, 1.0);
|
|
73047
|
+
float minPixelHalf = 1.0 / viewport_size.x * targetClip.w;
|
|
73048
|
+
float effectiveHalfWidth = max(halfWidth, minPixelHalf);
|
|
73049
|
+
|
|
73050
|
+
vec3 worldPos = centerWorld + camRight * vertex_position.x * effectiveHalfWidth;
|
|
73051
|
+
|
|
73052
|
+
gl_Position = matrix_viewProjection * vec4(worldPos, 1.0);
|
|
73053
|
+
vUV = vertex_position.xy;
|
|
73054
|
+
}
|
|
73055
|
+
`;
|
|
73056
|
+
const coreVS_WGSL = /* wgsl */ `
|
|
73057
|
+
attribute vertex_position: vec3f;
|
|
73058
|
+
uniform matrix_viewProjection: mat4x4f;
|
|
73059
|
+
uniform walk_viewInverse: mat4x4f;
|
|
73060
|
+
uniform walk_target: vec3f;
|
|
73061
|
+
uniform viewport_size: vec4f;
|
|
73062
|
+
varying vUV: vec2f;
|
|
73063
|
+
|
|
73064
|
+
@vertex fn vertexMain(input: VertexInput) -> VertexOutput {
|
|
73065
|
+
var output: VertexOutput;
|
|
73066
|
+
|
|
73067
|
+
let camRight = normalize(vec3f(uniform.walk_viewInverse[0][0], 0.0, uniform.walk_viewInverse[0][2]));
|
|
73068
|
+
let up = vec3f(0.0, 1.0, 0.0);
|
|
73069
|
+
|
|
73070
|
+
let halfWidth = 0.0075;
|
|
73071
|
+
let halfHeight = 10000.0;
|
|
73072
|
+
|
|
73073
|
+
let centerWorld = uniform.walk_target + up * input.vertex_position.y * halfHeight;
|
|
73074
|
+
|
|
73075
|
+
let targetClip = uniform.matrix_viewProjection * vec4f(uniform.walk_target, 1.0);
|
|
73076
|
+
let minPixelHalf = 1.0 / uniform.viewport_size.x * targetClip.w;
|
|
73077
|
+
let effectiveHalfWidth = max(halfWidth, minPixelHalf);
|
|
73078
|
+
|
|
73079
|
+
let worldPos = centerWorld + camRight * input.vertex_position.x * effectiveHalfWidth;
|
|
73080
|
+
|
|
73081
|
+
output.position = uniform.matrix_viewProjection * vec4f(worldPos, 1.0);
|
|
73082
|
+
output.vUV = input.vertex_position.xy;
|
|
73083
|
+
return output;
|
|
73084
|
+
}
|
|
73085
|
+
`;
|
|
73086
|
+
const coreFS = /* glsl */ `
|
|
73087
|
+
precision highp float;
|
|
73088
|
+
|
|
73089
|
+
uniform float walk_time;
|
|
73090
|
+
|
|
73091
|
+
varying vec2 vUV;
|
|
73092
|
+
|
|
73093
|
+
void main() {
|
|
73094
|
+
if (abs(vUV.y) > 0.95) discard;
|
|
73095
|
+
|
|
73096
|
+
float pulse = 1.0 + 0.08 * sin(walk_time * 3.0);
|
|
73097
|
+
vec3 color = vec3(2.55, 2.76, 3.0) * pulse;
|
|
73098
|
+
|
|
73099
|
+
gl_FragColor = vec4(color, 1.0);
|
|
73100
|
+
}
|
|
73101
|
+
`;
|
|
73102
|
+
const coreFS_WGSL = /* wgsl */ `
|
|
73103
|
+
uniform walk_time: f32;
|
|
73104
|
+
varying vUV: vec2f;
|
|
73105
|
+
|
|
73106
|
+
@fragment fn fragmentMain(input: FragmentInput) -> FragmentOutput {
|
|
73107
|
+
var output: FragmentOutput;
|
|
73108
|
+
|
|
73109
|
+
if (abs(input.vUV.y) > 0.95) {
|
|
73110
|
+
discard;
|
|
73111
|
+
return output;
|
|
73112
|
+
}
|
|
73113
|
+
|
|
73114
|
+
let pulse = 1.0 + 0.08 * sin(uniform.walk_time * 3.0);
|
|
73115
|
+
let color = vec3f(2.55, 2.76, 3.0) * pulse;
|
|
73116
|
+
|
|
73117
|
+
output.color = vec4f(color, 1.0);
|
|
73118
|
+
return output;
|
|
73119
|
+
}
|
|
73120
|
+
`;
|
|
73121
|
+
// ── Particle shaders ────────────────────────────────────────────────────────
|
|
73122
|
+
const particleVS = /* glsl */ `
|
|
73123
|
+
attribute vec3 vertex_position;
|
|
73124
|
+
attribute vec2 aQuadCorner;
|
|
73125
|
+
|
|
73126
|
+
uniform mat4 matrix_viewProjection;
|
|
73127
|
+
uniform mat4 walk_viewInverse;
|
|
73128
|
+
uniform vec3 walk_target;
|
|
73129
|
+
uniform float walk_time;
|
|
73130
|
+
|
|
73131
|
+
varying vec2 vUV;
|
|
73132
|
+
varying float vFade;
|
|
73133
|
+
|
|
73134
|
+
void main() {
|
|
73135
|
+
float rand0 = vertex_position.x;
|
|
73136
|
+
float rand1 = vertex_position.y;
|
|
73137
|
+
float rand2 = vertex_position.z;
|
|
73138
|
+
|
|
73139
|
+
float baseAngle = rand0 * 6.28318530718;
|
|
73140
|
+
float rBase = sqrt(rand2) * 0.4;
|
|
73141
|
+
float r = rBase * smoothstep(0.0, 0.5, walk_time);
|
|
73142
|
+
|
|
73143
|
+
float riseSpeed = 0.3 + rand2 * 0.4;
|
|
73144
|
+
float t = fract(max(walk_time - rand1 * 2.0, 0.0) * riseSpeed);
|
|
73145
|
+
float y = t * t * 1.5 - 0.1;
|
|
73146
|
+
|
|
73147
|
+
float swirl = baseAngle + t * (0.5 + rand1);
|
|
73148
|
+
float swirlR = r + 0.01;
|
|
73149
|
+
vec3 center = walk_target + vec3(swirlR * cos(swirl), y, swirlR * sin(swirl));
|
|
73150
|
+
|
|
73151
|
+
vec3 camRight = walk_viewInverse[0].xyz;
|
|
73152
|
+
vec3 camUp = walk_viewInverse[1].xyz;
|
|
73153
|
+
float halfSize = 0.00625;
|
|
73154
|
+
|
|
73155
|
+
vec3 worldPos = center
|
|
73156
|
+
+ camRight * aQuadCorner.x * halfSize
|
|
73157
|
+
+ camUp * aQuadCorner.y * halfSize;
|
|
73158
|
+
|
|
73159
|
+
gl_Position = matrix_viewProjection * vec4(worldPos, 1.0);
|
|
73160
|
+
vUV = aQuadCorner;
|
|
73161
|
+
float maxT = 1.0 - rBase;
|
|
73162
|
+
vFade = smoothstep(0.0, 0.1, t) * smoothstep(maxT, maxT - 0.15, t);
|
|
73163
|
+
}
|
|
73164
|
+
`;
|
|
73165
|
+
const particleVS_WGSL = /* wgsl */ `
|
|
73166
|
+
attribute vertex_position: vec3f;
|
|
73167
|
+
attribute aQuadCorner: vec2f;
|
|
73168
|
+
|
|
73169
|
+
uniform matrix_viewProjection: mat4x4f;
|
|
73170
|
+
uniform walk_viewInverse: mat4x4f;
|
|
73171
|
+
uniform walk_target: vec3f;
|
|
73172
|
+
uniform walk_time: f32;
|
|
73173
|
+
|
|
73174
|
+
varying vUV: vec2f;
|
|
73175
|
+
varying vFade: f32;
|
|
73176
|
+
|
|
73177
|
+
@vertex fn vertexMain(input: VertexInput) -> VertexOutput {
|
|
73178
|
+
var output: VertexOutput;
|
|
73179
|
+
|
|
73180
|
+
let rand0 = input.vertex_position.x;
|
|
73181
|
+
let rand1 = input.vertex_position.y;
|
|
73182
|
+
let rand2 = input.vertex_position.z;
|
|
73183
|
+
|
|
73184
|
+
let baseAngle = rand0 * 6.28318530718;
|
|
73185
|
+
let rBase = sqrt(rand2) * 0.4;
|
|
73186
|
+
let r = rBase * smoothstep(0.0, 0.5, uniform.walk_time);
|
|
73187
|
+
|
|
73188
|
+
let riseSpeed = 0.3 + rand2 * 0.4;
|
|
73189
|
+
let t = fract(max(uniform.walk_time - rand1 * 2.0, 0.0) * riseSpeed);
|
|
73190
|
+
let y = t * t * 1.5 - 0.1;
|
|
73191
|
+
|
|
73192
|
+
let swirl = baseAngle + t * (0.5 + rand1);
|
|
73193
|
+
let swirlR = r + 0.01;
|
|
73194
|
+
let center = uniform.walk_target + vec3f(swirlR * cos(swirl), y, swirlR * sin(swirl));
|
|
73195
|
+
|
|
73196
|
+
let camRight = uniform.walk_viewInverse[0].xyz;
|
|
73197
|
+
let camUp = uniform.walk_viewInverse[1].xyz;
|
|
73198
|
+
let halfSize = 0.00625;
|
|
73199
|
+
|
|
73200
|
+
let worldPos = center
|
|
73201
|
+
+ camRight * input.aQuadCorner.x * halfSize
|
|
73202
|
+
+ camUp * input.aQuadCorner.y * halfSize;
|
|
73203
|
+
|
|
73204
|
+
output.position = uniform.matrix_viewProjection * vec4f(worldPos, 1.0);
|
|
73205
|
+
output.vUV = input.aQuadCorner;
|
|
73206
|
+
let maxT = 1.0 - rBase;
|
|
73207
|
+
output.vFade = smoothstep(0.0, 0.1, t) * smoothstep(maxT, maxT - 0.15, t);
|
|
73208
|
+
return output;
|
|
73209
|
+
}
|
|
73210
|
+
`;
|
|
73211
|
+
const particleFS = /* glsl */ `
|
|
73212
|
+
precision highp float;
|
|
73213
|
+
|
|
73214
|
+
varying vec2 vUV;
|
|
73215
|
+
varying float vFade;
|
|
73216
|
+
|
|
73217
|
+
void main() {
|
|
73218
|
+
float r = length(vUV);
|
|
73219
|
+
if (r > 1.0 || vFade < 0.5) discard;
|
|
73220
|
+
gl_FragColor = vec4(2.55, 2.76, 3.0, 1.0);
|
|
73221
|
+
}
|
|
73222
|
+
`;
|
|
73223
|
+
const particleFS_WGSL = /* wgsl */ `
|
|
73224
|
+
varying vUV: vec2f;
|
|
73225
|
+
varying vFade: f32;
|
|
73226
|
+
|
|
73227
|
+
@fragment fn fragmentMain(input: FragmentInput) -> FragmentOutput {
|
|
73228
|
+
var output: FragmentOutput;
|
|
73229
|
+
|
|
73230
|
+
let r = length(input.vUV);
|
|
73231
|
+
if (r > 1.0 || input.vFade < 0.5) {
|
|
73232
|
+
discard;
|
|
73233
|
+
return output;
|
|
73234
|
+
}
|
|
73235
|
+
output.color = vec4f(2.55, 2.76, 3.0, 1.0);
|
|
73236
|
+
return output;
|
|
73237
|
+
}
|
|
73238
|
+
`;
|
|
73239
|
+
// ── Constants & helpers ─────────────────────────────────────────────────────
|
|
73240
|
+
const PARTICLE_COUNT = 250;
|
|
73241
|
+
const QUAD_CORNERS = [-1, -1, 1, -1, 1, 1, -1, 1];
|
|
72998
73242
|
const viewMat = new Mat4();
|
|
72999
73243
|
const invViewMat = new Mat4();
|
|
73244
|
+
const targetVec = new Float32Array(3);
|
|
73245
|
+
const mulberry32 = (seed) => {
|
|
73246
|
+
return () => {
|
|
73247
|
+
seed |= 0;
|
|
73248
|
+
seed = seed + 0x6D2B79F5 | 0;
|
|
73249
|
+
let t = Math.imul(seed ^ seed >>> 15, 1 | seed);
|
|
73250
|
+
t ^= t + Math.imul(t ^ t >>> 7, 61 | t);
|
|
73251
|
+
return ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
73252
|
+
};
|
|
73253
|
+
};
|
|
73254
|
+
// ── WalkIndicator ───────────────────────────────────────────────────────────
|
|
73000
73255
|
class WalkIndicator {
|
|
73001
73256
|
app;
|
|
73002
73257
|
target = null;
|
|
73003
73258
|
startTime = 0;
|
|
73259
|
+
visible = false;
|
|
73004
73260
|
origGlsl;
|
|
73005
73261
|
origWgsl;
|
|
73262
|
+
coreEntity;
|
|
73263
|
+
particleEntity;
|
|
73006
73264
|
constructor(app) {
|
|
73007
73265
|
this.app = app;
|
|
73008
73266
|
const device = app.graphicsDevice;
|
|
@@ -73012,6 +73270,104 @@ class WalkIndicator {
|
|
|
73012
73270
|
this.origWgsl = wgsl.get('gsplatPS');
|
|
73013
73271
|
glsl.set('gsplatPS', gsplatPSGlsl);
|
|
73014
73272
|
wgsl.set('gsplatPS', gsplatPSWgsl);
|
|
73273
|
+
this.coreEntity = this.createCoreEntity();
|
|
73274
|
+
this.particleEntity = this.createParticleEntity();
|
|
73275
|
+
app.on('framerender', () => {
|
|
73276
|
+
if (this.target && this.visible) {
|
|
73277
|
+
app.renderNextFrame = true;
|
|
73278
|
+
}
|
|
73279
|
+
});
|
|
73280
|
+
}
|
|
73281
|
+
createCoreEntity() {
|
|
73282
|
+
const device = this.app.graphicsDevice;
|
|
73283
|
+
const mesh = new Mesh(device);
|
|
73284
|
+
mesh.setPositions([-1, -1, 0, 1, -1, 0, 1, 1, 0, -1, 1, 0], 3);
|
|
73285
|
+
mesh.setIndices([0, 1, 2, 0, 2, 3]);
|
|
73286
|
+
mesh.update(PRIMITIVE_TRIANGLES);
|
|
73287
|
+
const material = new ShaderMaterial({
|
|
73288
|
+
uniqueName: 'walkCoreMaterial',
|
|
73289
|
+
vertexGLSL: coreVS,
|
|
73290
|
+
fragmentGLSL: coreFS,
|
|
73291
|
+
vertexWGSL: coreVS_WGSL,
|
|
73292
|
+
fragmentWGSL: coreFS_WGSL,
|
|
73293
|
+
attributes: {
|
|
73294
|
+
vertex_position: SEMANTIC_POSITION
|
|
73295
|
+
}
|
|
73296
|
+
});
|
|
73297
|
+
material.blendType = BLEND_NONE;
|
|
73298
|
+
material.depthWrite = true;
|
|
73299
|
+
material.depthTest = true;
|
|
73300
|
+
material.cull = CULLFACE_NONE;
|
|
73301
|
+
material.update();
|
|
73302
|
+
const mi = new MeshInstance(mesh, material);
|
|
73303
|
+
mi.cull = false;
|
|
73304
|
+
const entity = new Entity('walkCore');
|
|
73305
|
+
entity.addComponent('render', {
|
|
73306
|
+
meshInstances: [mi]
|
|
73307
|
+
});
|
|
73308
|
+
entity.enabled = false;
|
|
73309
|
+
this.app.root.addChild(entity);
|
|
73310
|
+
return entity;
|
|
73311
|
+
}
|
|
73312
|
+
createParticleEntity() {
|
|
73313
|
+
const device = this.app.graphicsDevice;
|
|
73314
|
+
const rng = mulberry32(42);
|
|
73315
|
+
const totalVerts = PARTICLE_COUNT * 4;
|
|
73316
|
+
const totalIndices = PARTICLE_COUNT * 6;
|
|
73317
|
+
const particleData = new Float32Array(totalVerts * 3);
|
|
73318
|
+
const corners = new Float32Array(totalVerts * 2);
|
|
73319
|
+
const indices = new Uint16Array(totalIndices);
|
|
73320
|
+
for (let i = 0; i < PARTICLE_COUNT; i++) {
|
|
73321
|
+
const rand0 = i / PARTICLE_COUNT;
|
|
73322
|
+
const rand1 = rng();
|
|
73323
|
+
const rand2 = rng();
|
|
73324
|
+
const base = i * 4;
|
|
73325
|
+
for (let j = 0; j < 4; j++) {
|
|
73326
|
+
const vi = base + j;
|
|
73327
|
+
particleData[vi * 3] = rand0;
|
|
73328
|
+
particleData[vi * 3 + 1] = rand1;
|
|
73329
|
+
particleData[vi * 3 + 2] = rand2;
|
|
73330
|
+
corners[vi * 2] = QUAD_CORNERS[j * 2];
|
|
73331
|
+
corners[vi * 2 + 1] = QUAD_CORNERS[j * 2 + 1];
|
|
73332
|
+
}
|
|
73333
|
+
const ii = i * 6;
|
|
73334
|
+
indices[ii] = base;
|
|
73335
|
+
indices[ii + 1] = base + 1;
|
|
73336
|
+
indices[ii + 2] = base + 2;
|
|
73337
|
+
indices[ii + 3] = base;
|
|
73338
|
+
indices[ii + 4] = base + 2;
|
|
73339
|
+
indices[ii + 5] = base + 3;
|
|
73340
|
+
}
|
|
73341
|
+
const mesh = new Mesh(device);
|
|
73342
|
+
mesh.setPositions(particleData, 3);
|
|
73343
|
+
mesh.setVertexStream(SEMANTIC_TEXCOORD1, corners, 2);
|
|
73344
|
+
mesh.setIndices(indices);
|
|
73345
|
+
mesh.update(PRIMITIVE_TRIANGLES);
|
|
73346
|
+
const material = new ShaderMaterial({
|
|
73347
|
+
uniqueName: 'walkParticleMaterial',
|
|
73348
|
+
vertexGLSL: particleVS,
|
|
73349
|
+
fragmentGLSL: particleFS,
|
|
73350
|
+
vertexWGSL: particleVS_WGSL,
|
|
73351
|
+
fragmentWGSL: particleFS_WGSL,
|
|
73352
|
+
attributes: {
|
|
73353
|
+
vertex_position: SEMANTIC_POSITION,
|
|
73354
|
+
aQuadCorner: SEMANTIC_TEXCOORD1
|
|
73355
|
+
}
|
|
73356
|
+
});
|
|
73357
|
+
material.blendType = BLEND_NONE;
|
|
73358
|
+
material.depthWrite = true;
|
|
73359
|
+
material.depthTest = true;
|
|
73360
|
+
material.cull = CULLFACE_NONE;
|
|
73361
|
+
material.update();
|
|
73362
|
+
const mi = new MeshInstance(mesh, material);
|
|
73363
|
+
mi.cull = false;
|
|
73364
|
+
const entity = new Entity('walkParticles');
|
|
73365
|
+
entity.addComponent('render', {
|
|
73366
|
+
meshInstances: [mi]
|
|
73367
|
+
});
|
|
73368
|
+
entity.enabled = false;
|
|
73369
|
+
this.app.root.addChild(entity);
|
|
73370
|
+
return entity;
|
|
73015
73371
|
}
|
|
73016
73372
|
/**
|
|
73017
73373
|
* Set or clear the walk target position.
|
|
@@ -73020,9 +73376,13 @@ class WalkIndicator {
|
|
|
73020
73376
|
*/
|
|
73021
73377
|
setTarget(pos) {
|
|
73022
73378
|
this.target = pos ? pos.clone() : null;
|
|
73379
|
+
this.visible = !!pos;
|
|
73023
73380
|
if (pos) {
|
|
73024
73381
|
this.startTime = performance.now() / 1000;
|
|
73025
73382
|
}
|
|
73383
|
+
this.coreEntity.enabled = this.visible;
|
|
73384
|
+
this.particleEntity.enabled = this.visible;
|
|
73385
|
+
this.app.renderNextFrame = true;
|
|
73026
73386
|
}
|
|
73027
73387
|
/**
|
|
73028
73388
|
* Update uniforms for the walk highlight effect. Call from a prerender hook.
|
|
@@ -73037,14 +73397,24 @@ class WalkIndicator {
|
|
|
73037
73397
|
invViewMat.copy(viewMat).invert();
|
|
73038
73398
|
scope.resolve('walk_viewInverse').setValue(invViewMat.data);
|
|
73039
73399
|
if (this.target) {
|
|
73400
|
+
const camPos = camera.getPosition();
|
|
73401
|
+
const dist = camPos.distance(this.target);
|
|
73402
|
+
this.visible = dist > 2.0;
|
|
73403
|
+
this.coreEntity.enabled = this.visible;
|
|
73404
|
+
this.particleEntity.enabled = this.visible;
|
|
73040
73405
|
const elapsed = performance.now() / 1000 - this.startTime;
|
|
73041
|
-
|
|
73042
|
-
|
|
73406
|
+
targetVec[0] = this.target.x;
|
|
73407
|
+
targetVec[1] = this.target.y;
|
|
73408
|
+
targetVec[2] = this.target.z;
|
|
73409
|
+
scope.resolve('walk_target').setValue(targetVec);
|
|
73410
|
+
scope.resolve('walk_radius').setValue(this.visible ? 1.5 : 0);
|
|
73043
73411
|
scope.resolve('walk_time').setValue(elapsed);
|
|
73044
|
-
this.app.renderNextFrame = true;
|
|
73045
73412
|
}
|
|
73046
73413
|
else {
|
|
73047
|
-
|
|
73414
|
+
targetVec[0] = 0;
|
|
73415
|
+
targetVec[1] = 0;
|
|
73416
|
+
targetVec[2] = 0;
|
|
73417
|
+
scope.resolve('walk_target').setValue(targetVec);
|
|
73048
73418
|
scope.resolve('walk_radius').setValue(0);
|
|
73049
73419
|
scope.resolve('walk_time').setValue(0);
|
|
73050
73420
|
}
|
|
@@ -73053,6 +73423,8 @@ class WalkIndicator {
|
|
|
73053
73423
|
const device = this.app.graphicsDevice;
|
|
73054
73424
|
ShaderChunks.get(device, 'glsl').set('gsplatPS', this.origGlsl);
|
|
73055
73425
|
ShaderChunks.get(device, 'wgsl').set('gsplatPS', this.origWgsl);
|
|
73426
|
+
this.coreEntity.destroy();
|
|
73427
|
+
this.particleEntity.destroy();
|
|
73056
73428
|
}
|
|
73057
73429
|
}
|
|
73058
73430
|
|
|
@@ -75008,7 +75380,7 @@ const initXr = (global) => {
|
|
|
75008
75380
|
});
|
|
75009
75381
|
};
|
|
75010
75382
|
|
|
75011
|
-
var version = "1.16.
|
|
75383
|
+
var version = "1.16.6";
|
|
75012
75384
|
|
|
75013
75385
|
const loadGsplat = async (app, config, progressCallback) => {
|
|
75014
75386
|
const { contents, contentUrl, unified, aa } = config;
|