@multiplekex/shallot 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/extras/text/index.ts
CHANGED
|
@@ -28,7 +28,7 @@ import { Transform } from "../../standard/transforms";
|
|
|
28
28
|
const MAX_GLYPHS = 50000;
|
|
29
29
|
const GLYPH_FLOATS = 16;
|
|
30
30
|
const SDF_SIZE = 96;
|
|
31
|
-
const SDF_EXPONENT =
|
|
31
|
+
const SDF_EXPONENT = 9;
|
|
32
32
|
const fontUrls: string[] = [];
|
|
33
33
|
const loadedFonts: (Font | null)[] = [];
|
|
34
34
|
|
|
@@ -498,12 +498,27 @@ struct FragmentOutput {
|
|
|
498
498
|
@location(1) mask: f32,
|
|
499
499
|
}
|
|
500
500
|
|
|
501
|
+
const SDF_EXPONENT: f32 = 9.0;
|
|
502
|
+
|
|
503
|
+
fn sdfToSignedDistance(sdfValue: f32, maxDimension: f32) -> f32 {
|
|
504
|
+
let alpha = select(sdfValue, 1.0 - sdfValue, sdfValue > 0.5);
|
|
505
|
+
let absDist = (1.0 - pow(2.0 * alpha, 1.0 / SDF_EXPONENT)) * maxDimension;
|
|
506
|
+
return absDist * select(1.0, -1.0, sdfValue > 0.5);
|
|
507
|
+
}
|
|
508
|
+
|
|
501
509
|
@fragment
|
|
502
510
|
fn fs(input: VertexOutput) -> FragmentOutput {
|
|
503
511
|
let sdfValue = textureSample(atlasTexture, atlasSampler, input.uv).r;
|
|
504
512
|
|
|
505
|
-
|
|
506
|
-
let
|
|
513
|
+
// Decode SDF to signed distance (negative = inside, positive = outside)
|
|
514
|
+
let maxDimension = max(input.glyphDimensions.x, input.glyphDimensions.y);
|
|
515
|
+
let signedDist = sdfToSignedDistance(sdfValue, maxDimension);
|
|
516
|
+
|
|
517
|
+
// Screen-space AA distance from UV derivatives
|
|
518
|
+
let aaDist = length(fwidth(input.localUV * input.glyphDimensions)) * 0.5;
|
|
519
|
+
|
|
520
|
+
// Smoothstep with adaptive band
|
|
521
|
+
let alpha = smoothstep(aaDist, -aaDist, signedDist);
|
|
507
522
|
|
|
508
523
|
if alpha < 0.01 {
|
|
509
524
|
discard;
|
|
@@ -206,7 +206,7 @@ export function ensureResolved(state: State, tweenEid: number): void {
|
|
|
206
206
|
const elapsed = Tween.elapsed[tweenEid];
|
|
207
207
|
const duration = Tween.duration[tweenEid];
|
|
208
208
|
|
|
209
|
-
if (elapsed >= duration) return;
|
|
209
|
+
if (duration > 0 && elapsed >= duration) return;
|
|
210
210
|
|
|
211
211
|
const targetEid = state.getFirstRelationTarget(tweenEid, TweenTarget);
|
|
212
212
|
const binding = getFieldAccessor(tweenEid);
|