@woosh/meep-engine 3.60.0 → 3.60.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/shade/playground/sh_exponential/main.js +2 -2
- package/src/shade/renderer/global_illumination/probe_clipmap/PROBE_CLIPMAP_PROPOSAL_2026_10_27.md +4 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_shade.d.ts +6 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_shade.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_shade.js +12 -4
- package/src/shade/renderer/light/GPULightCollection.d.ts.map +1 -1
- package/src/shade/renderer/light/GPULightCollection.js +3 -5
- package/src/shade/renderer/light/environment/execute_filter_environment_map.d.ts +13 -5
- package/src/shade/renderer/light/environment/execute_filter_environment_map.d.ts.map +1 -1
- package/src/shade/renderer/light/environment/execute_filter_environment_map.js +133 -7
- package/src/shade/renderer/light/environment/graph_filter_environment_map.d.ts +9 -0
- package/src/shade/renderer/light/environment/graph_filter_environment_map.d.ts.map +1 -1
- package/src/shade/renderer/light/environment/graph_filter_environment_map.js +33 -4
- package/src/shade/renderer/light/environment/shader_convolve_reflection_map_from_averages.d.ts +13 -0
- package/src/shade/renderer/light/environment/shader_convolve_reflection_map_from_averages.d.ts.map +1 -0
- package/src/shade/renderer/light/environment/shader_convolve_reflection_map_from_averages.js +169 -0
- package/src/shade/renderer/light/environment/shader_downsample_environment_map.d.ts +3 -0
- package/src/shade/renderer/light/environment/shader_downsample_environment_map.d.ts.map +1 -0
- package/src/shade/renderer/light/environment/shader_downsample_environment_map.js +105 -0
- package/src/shade/renderer/light/environment/sphere_probe_lod_to_roughness.d.ts +10 -0
- package/src/shade/renderer/light/environment/sphere_probe_lod_to_roughness.d.ts.map +1 -0
- package/src/shade/renderer/light/environment/sphere_probe_lod_to_roughness.js +23 -0
- package/src/shade/renderer/shader/chunk/light/probe/chunk_probe_visibility_weight.d.ts +8 -4
- package/src/shade/renderer/shader/chunk/light/probe/chunk_probe_visibility_weight.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/light/probe/chunk_probe_visibility_weight.js +9 -5
- package/src/shade/wgsl/emulator/WGSLLanguageCore.d.ts.map +1 -1
- package/src/shade/wgsl/emulator/WGSLLanguageCore.js +26 -1
- package/src/view/elements/progress/segmented/GhostTrail.d.ts +78 -12
- package/src/view/elements/progress/segmented/GhostTrail.d.ts.map +1 -1
- package/src/view/elements/progress/segmented/GhostTrail.js +294 -98
- package/src/view/elements/progress/segmented/SegmentedResourceBarView.d.ts +68 -24
- package/src/view/elements/progress/segmented/SegmentedResourceBarView.d.ts.map +1 -1
- package/src/view/elements/progress/segmented/SegmentedResourceBarView.js +196 -128
- package/src/view/elements/progress/segmented/playground/main.js +18 -11
- package/src/view/elements/progress/segmented/segment_cell_extent.d.ts +14 -0
- package/src/view/elements/progress/segmented/segment_cell_extent.d.ts.map +1 -0
- package/src/view/elements/progress/segmented/segment_cell_extent.js +44 -0
- package/src/view/elements/progress/segmented/segment_mask_url.d.ts +24 -0
- package/src/view/elements/progress/segmented/segment_mask_url.d.ts.map +1 -0
- package/src/view/elements/progress/segmented/segment_mask_url.js +74 -0
- package/src/view/elements/progress/segmented/segment_mask_width.d.ts +18 -0
- package/src/view/elements/progress/segmented/segment_mask_width.d.ts.map +1 -0
- package/src/view/elements/progress/segmented/segment_mask_width.js +46 -0
- package/src/view/elements/progress/segmented/segmented-resource-bar.css +6 -10
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import {
|
|
2
|
+
chunk_texture_octahedral_skirt_texel_uv
|
|
3
|
+
} from "../../shader/chunk/texture/octahedral/chunk_texture_octahedral_skirt_texel_uv.js";
|
|
4
|
+
import {
|
|
5
|
+
chunk_uv_octahedral_unit_decode
|
|
6
|
+
} from "../../shader/chunk/geometry/octahedron/chunk_uv_octahedral_unit_decode.js";
|
|
7
|
+
import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
|
|
8
|
+
import { ComputeShader } from "../../shader/ComputeShader.js";
|
|
9
|
+
import { ShaderResourceSetDescriptor } from "../../shader/resource/ShaderResourceSetDescriptor.js";
|
|
10
|
+
import { ShaderDescriptor } from "../../shader/ShaderDescriptor.js";
|
|
11
|
+
|
|
12
|
+
const resources = new ShaderResourceSetDescriptor();
|
|
13
|
+
|
|
14
|
+
resources.createGroup()
|
|
15
|
+
.addTexture("input", "float")
|
|
16
|
+
.addStorageTexture("output", "rgba16float")
|
|
17
|
+
;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* One level of a skirted octahedral map, half the side of the level it reads: the plain average the
|
|
21
|
+
* prefilter's filtered importance sampling picks its source texels from.
|
|
22
|
+
*
|
|
23
|
+
* Each output texel is the solid-angle-weighted mean of the source texels its footprint overlaps.
|
|
24
|
+
* A skirted level's interior is not half the one above (1022 → 510, 6 → 2), so the footprint is
|
|
25
|
+
* 2 + 2/n source texels wide rather than 2, up to 3 at the last level: taps at fixed offsets drift
|
|
26
|
+
* across the source grid and skip texels, which a bright sun then goes missing through. Weighting
|
|
27
|
+
* each overlap by its solid angle keeps a level's energy that of the one above. The solid angle is
|
|
28
|
+
* integrated from the density |d|_1^3 rather than taken from a texel's corners
|
|
29
|
+
* (chunk_octahedral_solid_angle): a texel the octahedral fold crosses is no pair of spherical
|
|
30
|
+
* triangles, and a bright one came out 4.7% dim.
|
|
31
|
+
*
|
|
32
|
+
* @see https://github.com/EpicGames/UnrealEngine/blob/5.4/Engine/Shaders/Private/ReflectionEnvironmentShaders.usf DownsamplePS
|
|
33
|
+
* @type {CodeChunk}
|
|
34
|
+
*/
|
|
35
|
+
const body = CodeChunk.from(
|
|
36
|
+
//language=WGSL
|
|
37
|
+
`
|
|
38
|
+
@compute @workgroup_size(16,16,1)
|
|
39
|
+
fn main(
|
|
40
|
+
@builtin(global_invocation_id) global_invocation_id : vec3<u32>,
|
|
41
|
+
){
|
|
42
|
+
let output_size = textureDimensions(output);
|
|
43
|
+
|
|
44
|
+
let output_texel_i = global_invocation_id.xy;
|
|
45
|
+
|
|
46
|
+
if(any(output_texel_i >= output_size)){
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// the skirt too: a skirt texel takes its interior twin's uv, so it is that texel, computed again
|
|
51
|
+
let out_uv = texture_octahedral_skirt_texel_uv(output_texel_i, output_size.x);
|
|
52
|
+
|
|
53
|
+
let output_interior = f32(output_size.x - 2u);
|
|
54
|
+
let input_interior = f32(textureDimensions(input).x - 2u);
|
|
55
|
+
|
|
56
|
+
// the footprint in the source's interior texels: [lo, lo + span), span = 2 + 2/n <= 3, so it overlaps at most 4 a side
|
|
57
|
+
let span = input_interior / output_interior;
|
|
58
|
+
let lo = floor(out_uv * output_interior) * span;
|
|
59
|
+
let first = floor(lo);
|
|
60
|
+
|
|
61
|
+
var sum = vec4(0.0);
|
|
62
|
+
var weight_sum = 0.0;
|
|
63
|
+
|
|
64
|
+
for (var y = 0u; y < 4u; y++) {
|
|
65
|
+
let texel_y = first.y + f32(y);
|
|
66
|
+
let overlap_y = min(texel_y + 1.0, lo.y + span) - max(texel_y, lo.y);
|
|
67
|
+
|
|
68
|
+
for (var x = 0u; x < 4u; x++) {
|
|
69
|
+
let texel_x = first.x + f32(x);
|
|
70
|
+
let overlap_x = min(texel_x + 1.0, lo.x + span) - max(texel_x, lo.x);
|
|
71
|
+
|
|
72
|
+
if (overlap_x <= 0.0 || overlap_y <= 0.0) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// the overlap's solid angle: the octahedron's solid angle per unit area is |d|_1^3 along unit d,
|
|
77
|
+
// across the folds too, integrated at 2x2 points of the overlap
|
|
78
|
+
let overlap_lo = vec2(max(texel_x, lo.x), max(texel_y, lo.y));
|
|
79
|
+
let overlap = vec2(overlap_x, overlap_y);
|
|
80
|
+
var density = 0.0;
|
|
81
|
+
for (var k = 0u; k < 4u; k++) {
|
|
82
|
+
let at = overlap_lo + overlap * (vec2<f32>(f32(k & 1u), f32(k >> 1u)) * 0.5 + 0.25);
|
|
83
|
+
let l1 = dot(abs(uv_octahedral_unit_decode(at / input_interior)), vec3(1.0));
|
|
84
|
+
density += l1 * l1 * l1;
|
|
85
|
+
}
|
|
86
|
+
let weight = overlap_x * overlap_y * density;
|
|
87
|
+
|
|
88
|
+
sum += textureLoad(input, vec2<u32>(vec2(texel_x, texel_y)) + 1u, 0) * weight;
|
|
89
|
+
weight_sum += weight;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
textureStore(output, output_texel_i, sum / weight_sum);
|
|
94
|
+
}
|
|
95
|
+
`, [
|
|
96
|
+
chunk_texture_octahedral_skirt_texel_uv,
|
|
97
|
+
chunk_uv_octahedral_unit_decode,
|
|
98
|
+
]
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
export const shader_downsample_environment_map = new ComputeShader(ShaderDescriptor.from({
|
|
102
|
+
label: 'Downsample environment map',
|
|
103
|
+
body,
|
|
104
|
+
resources
|
|
105
|
+
}));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host twin of `chunk_sphere_probe_lod_to_roughness`: the linear roughness (blender's "UI roughness")
|
|
3
|
+
* a filtered level of the environment map is convolved at.
|
|
4
|
+
*
|
|
5
|
+
* @see https://projects.blender.org/blender/blender/src/commit/866ef5b468589587395b1ee7480ea75b4c0fbc26/source/blender/draw/engines/eevee_next/shaders/eevee_lightprobe_sphere_mapping_lib.glsl#L113
|
|
6
|
+
* @param {number} lod in [0, SPHERE_PROBE_MIPMAP_LEVELS - 1]
|
|
7
|
+
* @returns {number}
|
|
8
|
+
*/
|
|
9
|
+
export function sphere_probe_lod_to_roughness(lod: number): number;
|
|
10
|
+
//# sourceMappingURL=sphere_probe_lod_to_roughness.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sphere_probe_lod_to_roughness.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/light/environment/sphere_probe_lod_to_roughness.js"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,mDAHW,MAAM,GACJ,MAAM,CAclB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SPHERE_PROBE_MIP_MAX_ROUGHNESS, SPHERE_PROBE_MIPMAP_LEVELS } from "./DEFINES.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Host twin of `chunk_sphere_probe_lod_to_roughness`: the linear roughness (blender's "UI roughness")
|
|
5
|
+
* a filtered level of the environment map is convolved at.
|
|
6
|
+
*
|
|
7
|
+
* @see https://projects.blender.org/blender/blender/src/commit/866ef5b468589587395b1ee7480ea75b4c0fbc26/source/blender/draw/engines/eevee_next/shaders/eevee_lightprobe_sphere_mapping_lib.glsl#L113
|
|
8
|
+
* @param {number} lod in [0, SPHERE_PROBE_MIPMAP_LEVELS - 1]
|
|
9
|
+
* @returns {number}
|
|
10
|
+
*/
|
|
11
|
+
export function sphere_probe_lod_to_roughness(lod) {
|
|
12
|
+
const a = lod / (SPHERE_PROBE_MIPMAP_LEVELS - 1);
|
|
13
|
+
|
|
14
|
+
// factors of the ratio and of its square root, see chunk_roughness_to_mip_ratio
|
|
15
|
+
const b = 0.6;
|
|
16
|
+
const c = 0.4;
|
|
17
|
+
|
|
18
|
+
const c2 = c * c;
|
|
19
|
+
|
|
20
|
+
const ratio = (-Math.sqrt(4.0 * a * b * c2 + c2 * c2) + 2.0 * a * b + c2) / (2.0 * b * b);
|
|
21
|
+
|
|
22
|
+
return ratio * SPHERE_PROBE_MIP_MAX_ROUGHNESS;
|
|
23
|
+
}
|
|
@@ -11,10 +11,14 @@
|
|
|
11
11
|
* - `probe_visibility_chebyshev`: the chance the point is not occluded from the probe, by Chebyshev's
|
|
12
12
|
* inequality over the probe's depth moments (mean, mean of squares) toward it, the distance in the
|
|
13
13
|
* moments' own units; 1 nearer than the mean. The variance is held off zero.
|
|
14
|
-
* - `probe_visibility_weight`: a smooth back-face term, a "wrap shading" ((n·d + 1)/2)
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
14
|
+
* - `probe_visibility_weight`: a smooth back-face term, a "wrap shading" ((n·d + 1)/2)², times the
|
|
15
|
+
* visibility; then held off zero, and crushed below 0.2 along a continuous cubic, since a little light
|
|
16
|
+
* reads as more than it is. The trilinear weight is the caller's, after the crush.
|
|
17
|
+
* - DDGI adds 0.2 to the wrap term to keep probes behind small details in play. That floor is left out:
|
|
18
|
+
* a probe behind a thin wall, past its depth's mean at a grazing angle, passes Chebyshev at 0.94–0.97,
|
|
19
|
+
* and the floor alone held it at ≈0.25, just above the crush. On Sponza's outer wall such probes took
|
|
20
|
+
* 11% of the pick, 32% where the wall sits 0.15 of a spacing past a lattice plane, a dark lattice of
|
|
21
|
+
* blotches; without the floor 0.1% and 0.6%.
|
|
18
22
|
*
|
|
19
23
|
* @type {CodeChunk}
|
|
20
24
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunk_probe_visibility_weight.d.ts","sourceRoot":"","sources":["../../../../../../../../src/shade/renderer/shader/chunk/light/probe/chunk_probe_visibility_weight.js"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"chunk_probe_visibility_weight.d.ts","sourceRoot":"","sources":["../../../../../../../../src/shade/renderer/shader/chunk/light/probe/chunk_probe_visibility_weight.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,4CAFU,SAAS,CAiChB;0BAzDuB,gCAAgC"}
|
|
@@ -13,10 +13,14 @@ import { CodeChunk } from "../../../compiler/CodeChunk.js";
|
|
|
13
13
|
* - `probe_visibility_chebyshev`: the chance the point is not occluded from the probe, by Chebyshev's
|
|
14
14
|
* inequality over the probe's depth moments (mean, mean of squares) toward it, the distance in the
|
|
15
15
|
* moments' own units; 1 nearer than the mean. The variance is held off zero.
|
|
16
|
-
* - `probe_visibility_weight`: a smooth back-face term, a "wrap shading" ((n·d + 1)/2)
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
16
|
+
* - `probe_visibility_weight`: a smooth back-face term, a "wrap shading" ((n·d + 1)/2)², times the
|
|
17
|
+
* visibility; then held off zero, and crushed below 0.2 along a continuous cubic, since a little light
|
|
18
|
+
* reads as more than it is. The trilinear weight is the caller's, after the crush.
|
|
19
|
+
* - DDGI adds 0.2 to the wrap term to keep probes behind small details in play. That floor is left out:
|
|
20
|
+
* a probe behind a thin wall, past its depth's mean at a grazing angle, passes Chebyshev at 0.94–0.97,
|
|
21
|
+
* and the floor alone held it at ≈0.25, just above the crush. On Sponza's outer wall such probes took
|
|
22
|
+
* 11% of the pick, 32% where the wall sits 0.15 of a spacing past a lattice plane, a dark lattice of
|
|
23
|
+
* blotches; without the floor 0.1% and 0.6%.
|
|
20
24
|
*
|
|
21
25
|
* @type {CodeChunk}
|
|
22
26
|
*/
|
|
@@ -39,7 +43,7 @@ fn probe_visibility_weight(direction_to_probe: vec3<f32>, normal: vec3<f32>, vis
|
|
|
39
43
|
// the small offset keeps a probe exactly behind the surface from going to zero
|
|
40
44
|
let backface = max(0.0001, (dot(direction_to_probe, normal) + 1.0) * 0.5);
|
|
41
45
|
|
|
42
|
-
var weight =
|
|
46
|
+
var weight = backface * backface * visibility;
|
|
43
47
|
|
|
44
48
|
weight = max(1e-6, weight);
|
|
45
49
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WGSLLanguageCore.d.ts","sourceRoot":"","sources":["../../../../../src/shade/wgsl/emulator/WGSLLanguageCore.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"WGSLLanguageCore.d.ts","sourceRoot":"","sources":["../../../../../src/shade/wgsl/emulator/WGSLLanguageCore.js"],"names":[],"mappings":";IAg3DA;;;;;;;;;;;;;OAaG;IACH,+DAyFC"}
|
|
@@ -1260,7 +1260,9 @@ export const WGSLLanguageCore = {
|
|
|
1260
1260
|
*
|
|
1261
1261
|
* Filtered sample at normalised UV coords. Honours the sampler's
|
|
1262
1262
|
* address modes and `magFilter`. `coords` length matches the texture
|
|
1263
|
-
* dimensionality. The `level`
|
|
1263
|
+
* dimensionality. The `level` reads that level of a bitmap carrying its levels, as `textureLoad`
|
|
1264
|
+
* does, and zero past them; between two levels, a `linear` `mipmapFilter` blends them and any other
|
|
1265
|
+
* takes the nearer. A bitmap carrying none serves every level from itself.
|
|
1264
1266
|
*
|
|
1265
1267
|
* @param {import("./CPUBitmapData.js").CPUBitmapData} t
|
|
1266
1268
|
* @param {import("../../descriptor/texture/SamplerDescriptor.js").SamplerDescriptor | null} sampler
|
|
@@ -1275,21 +1277,44 @@ export const WGSLLanguageCore = {
|
|
|
1275
1277
|
|
|
1276
1278
|
let array_index = undefined;
|
|
1277
1279
|
let offset = undefined;
|
|
1280
|
+
let level = p3;
|
|
1278
1281
|
|
|
1279
1282
|
if (p5 !== undefined) {
|
|
1280
1283
|
// (t, s, coords, array_index, level, offset)
|
|
1281
1284
|
array_index = p3;
|
|
1285
|
+
level = p4;
|
|
1282
1286
|
offset = p5;
|
|
1283
1287
|
} else if (p4 === undefined) {
|
|
1284
1288
|
// (t, s, coords, level)
|
|
1285
1289
|
} else if (typeof p4 === 'number') {
|
|
1286
1290
|
// (t, s, coords, array_index, level)
|
|
1287
1291
|
array_index = p3;
|
|
1292
|
+
level = p4;
|
|
1288
1293
|
} else {
|
|
1289
1294
|
// (t, s, coords, level, offset)
|
|
1290
1295
|
offset = p4;
|
|
1291
1296
|
}
|
|
1292
1297
|
|
|
1298
|
+
if (t.levels?.length > 0 && level !== 0) {
|
|
1299
|
+
const below = Math.max(Math.floor(level), 0);
|
|
1300
|
+
const fraction = level - below;
|
|
1301
|
+
|
|
1302
|
+
if (fraction > 0 && sampler?.mipmapFilter === 'linear') {
|
|
1303
|
+
const a = WGSLLanguageCore.textureSampleLevel(t, sampler, coords, ...(array_index === undefined ? [below] : [array_index, below]), ...(offset === undefined ? [] : [offset]));
|
|
1304
|
+
const b = WGSLLanguageCore.textureSampleLevel(t, sampler, coords, ...(array_index === undefined ? [below + 1] : [array_index, below + 1]), ...(offset === undefined ? [] : [offset]));
|
|
1305
|
+
|
|
1306
|
+
return a.map((v, i) => v + (b[i] - v) * fraction);
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
const source = texture_level(t, fraction > 0.5 ? below + 1 : below);
|
|
1310
|
+
|
|
1311
|
+
if (source === undefined) {
|
|
1312
|
+
return new Float32Array(4);
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
t = source;
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1293
1318
|
const dim = t.dimensionality;
|
|
1294
1319
|
// Convert UV (normalised) to texel-space coords expected by
|
|
1295
1320
|
// cpu_texture_sample. coords for a 1D texture is a scalar in WGSL.
|
|
@@ -1,39 +1,99 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A value that trails another one down: the "ghost" behind a bar's fill that shows how much was just lost.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* The knobs are the three Dota 2 exposes for its hero bars as console variables: a short hold after a drop
|
|
5
|
+
* (`dota_health_hurt_delay`) and a decay whose length sits between a floor and a ceiling
|
|
6
|
+
* (`dota_health_hurt_decay_time_min` / `_max`). The defaults, 0.1 s / 0.3 s / 0.8 s, are the values players'
|
|
7
|
+
* published configs list as Dota's own; Valve does not document them. Everything else here is this class's own
|
|
8
|
+
* choice, not known Dota behaviour: the decay's length growing linearly with the loss (the whole bar takes the
|
|
9
|
+
* ceiling), the ease-out curve, and how losses that overlap combine.
|
|
10
|
+
*
|
|
11
|
+
* Every drop is a loss with a trail of its own: it holds at the value from before the drop for {@link delay_ms},
|
|
12
|
+
* then eases down over a length sized by that loss alone. The trail shows the highest of the live losses' trails,
|
|
13
|
+
* and never less than the target. Because no loss looks at another, a drop is drawn the same whether the trail
|
|
14
|
+
* was at rest or still moving when it came: a damage tick that lands just before or just after the previous one
|
|
15
|
+
* has faded looks the same, where a single trail that re-plans has to pick one side of that line.
|
|
16
|
+
*
|
|
17
|
+
* Each loss eases toward the lowest the target has been since it happened, never toward the target itself, so a
|
|
18
|
+
* rise that stays under the trail (regeneration after a hit) cannot lift it. When a later drop lowers that floor,
|
|
19
|
+
* the rest of the loss's ease is rescaled toward the new floor from where it is, so it does not jump. The trail
|
|
20
|
+
* is continuous in time and never rises unless the target rises above it; when it does, the trail jumps to the
|
|
21
|
+
* target and every loss is forgotten.
|
|
22
|
+
*
|
|
23
|
+
* A target that is not a finite number is ignored: the trail carries on with what it had, so one bad value cannot
|
|
24
|
+
* leave it NaN, and its owner animating it forever, for every value after.
|
|
25
|
+
*
|
|
26
|
+
* Each loss's start and length are fixed when it happens, so changing the knobs never revives or reshapes a trail
|
|
27
|
+
* already under way.
|
|
7
28
|
*
|
|
8
29
|
* Time is passed in, in milliseconds on any monotonic clock, so the trail can be driven and checked without one.
|
|
9
30
|
*/
|
|
10
31
|
export class GhostTrail {
|
|
11
32
|
/**
|
|
12
|
-
* How long
|
|
33
|
+
* How long a loss's trail holds before it starts to ease down
|
|
13
34
|
* @type {number}
|
|
14
35
|
*/
|
|
15
36
|
delay_ms: number;
|
|
16
37
|
/**
|
|
17
|
-
*
|
|
38
|
+
* Length of the ease for the smallest loss; 0 with {@link duration_max_ms} 0 snaps once the hold ends
|
|
18
39
|
* @type {number}
|
|
19
40
|
*/
|
|
20
|
-
|
|
41
|
+
duration_min_ms: number;
|
|
21
42
|
/**
|
|
43
|
+
* Length of the ease for a loss of the whole bar (1); smaller losses take proportionally less, down to
|
|
44
|
+
* {@link duration_min_ms}
|
|
22
45
|
* @type {number}
|
|
23
|
-
* @private
|
|
24
46
|
*/
|
|
25
|
-
|
|
47
|
+
duration_max_ms: number;
|
|
26
48
|
/**
|
|
49
|
+
* The target, as last set
|
|
27
50
|
* @type {number}
|
|
28
51
|
* @private
|
|
29
52
|
*/
|
|
30
53
|
private __to;
|
|
31
54
|
/**
|
|
32
|
-
*
|
|
55
|
+
* Live losses, {@link LOSS_STRIDE} floats each: when the ease starts (after the hold), the ease's length, the
|
|
56
|
+
* lowest the target has been since the loss, and how far above that the trail is while u is 1
|
|
57
|
+
* @type {Float64Array}
|
|
58
|
+
* @private
|
|
59
|
+
*/
|
|
60
|
+
private __losses;
|
|
61
|
+
/**
|
|
33
62
|
* @type {number}
|
|
34
63
|
* @private
|
|
35
64
|
*/
|
|
36
|
-
private
|
|
65
|
+
private __loss_count;
|
|
66
|
+
/**
|
|
67
|
+
* Length of the ease for a loss of `gap`, a fraction of the bar
|
|
68
|
+
* @param {number} gap
|
|
69
|
+
* @returns {number}
|
|
70
|
+
* @private
|
|
71
|
+
*/
|
|
72
|
+
private __duration_for;
|
|
73
|
+
/**
|
|
74
|
+
* How much of one loss's ease is left at `time_ms`: 1 while it holds, falling to 0 when the ease is over
|
|
75
|
+
* @param {number} index
|
|
76
|
+
* @param {number} time_ms
|
|
77
|
+
* @returns {number}
|
|
78
|
+
* @private
|
|
79
|
+
*/
|
|
80
|
+
private __loss_u;
|
|
81
|
+
/**
|
|
82
|
+
* Where one loss's trail is at `time_ms`; an ease-out, fastest at the start of the ease
|
|
83
|
+
* @param {number} index
|
|
84
|
+
* @param {number} time_ms
|
|
85
|
+
* @returns {number}
|
|
86
|
+
* @private
|
|
87
|
+
*/
|
|
88
|
+
private __loss_at;
|
|
89
|
+
/**
|
|
90
|
+
* @param {number} start
|
|
91
|
+
* @param {number} duration
|
|
92
|
+
* @param {number} low
|
|
93
|
+
* @param {number} amplitude
|
|
94
|
+
* @private
|
|
95
|
+
*/
|
|
96
|
+
private __add_loss;
|
|
37
97
|
/**
|
|
38
98
|
* Tell the trail its target's new value.
|
|
39
99
|
* @param {number} target
|
|
@@ -41,13 +101,19 @@ export class GhostTrail {
|
|
|
41
101
|
*/
|
|
42
102
|
set(target: number, time_ms: number): void;
|
|
43
103
|
/**
|
|
44
|
-
*
|
|
104
|
+
* Stand the trail at `target` with nothing lost: every loss forgotten, whatever was showing. For a target that
|
|
105
|
+
* moved without anything being lost, such as the same amount out of a raised maximum.
|
|
106
|
+
* @param {number} target
|
|
107
|
+
*/
|
|
108
|
+
reset(target: number): void;
|
|
109
|
+
/**
|
|
110
|
+
* Where the trail is at a given time: the highest of the live losses' trails, and never below the target.
|
|
45
111
|
* @param {number} time_ms
|
|
46
112
|
* @returns {number}
|
|
47
113
|
*/
|
|
48
114
|
sample(time_ms: number): number;
|
|
49
115
|
/**
|
|
50
|
-
* Whether the trail
|
|
116
|
+
* Whether the trail shows the target and will not move until {@link set} is called again
|
|
51
117
|
* @param {number} time_ms
|
|
52
118
|
* @returns {boolean}
|
|
53
119
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GhostTrail.d.ts","sourceRoot":"","sources":["../../../../../../src/view/elements/progress/segmented/GhostTrail.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GhostTrail.d.ts","sourceRoot":"","sources":["../../../../../../src/view/elements/progress/segmented/GhostTrail.js"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH;IACI;;;OAGG;IACH,UAFU,MAAM,CAED;IAEf;;;OAGG;IACH,iBAFU,MAAM,CAEM;IAEtB;;;;OAIG;IACH,iBAFU,MAAM,CAEM;IAEtB;;;;OAIG;IACH,aAAS;IAET;;;;;OAKG;IACH,iBAA6C;IAE7C;;;OAGG;IACH,qBAAiB;IAEjB;;;;;OAKG;IACH,uBAIC;IAED;;;;;;OAMG;IACH,iBAgBC;IAED;;;;;;OAMG;IACH,kBAKC;IAED;;;;;;OAMG;IACH,mBAoBC;IAED;;;;OAIG;IACH,YAHW,MAAM,WACN,MAAM,QAsEhB;IAED;;;;OAIG;IACH,cAFW,MAAM,QAShB;IAED;;;;OAIG;IACH,gBAHW,MAAM,GACJ,MAAM,CAgBlB;IAED;;;;OAIG;IACH,oBAHW,MAAM,GACJ,OAAO,CAkBnB;CACJ"}
|