@moku-labs/game 0.15.119 → 0.15.120
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/README.md +10 -0
- package/dist/app/page.d.mts +1 -1
- package/dist/app/page.mjs +1 -1
- package/dist/app/system.d.mts +3 -3
- package/dist/app.d.mts +3 -3
- package/dist/app.mjs +1 -1
- package/dist/assets.d.mts +1 -1
- package/dist/{commands-CzT9eYnf.d.mts → commands-Cwxtb672.d.mts} +5 -5
- package/dist/control.d.mts +4 -4
- package/dist/{define-OPEOQ5MS.d.mts → define-BLFk9wyQ.d.mts} +2 -2
- package/dist/{headless-C5kxf9oU.d.mts → headless-DjvkUuv6.d.mts} +1 -1
- package/dist/{index-CKF3qS2-.d.mts → index-DSTbAOZZ.d.mts} +3 -3
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +2 -2
- package/dist/inspect.d.mts +6 -6
- package/dist/inspect.mjs +1 -1
- package/dist/jsx-dev-runtime.d.mts +1 -1
- package/dist/jsx-runtime.d.mts +1 -1
- package/dist/{runtime-BbZtyfgH.d.mts → runtime-Dl3k95wc.d.mts} +1 -1
- package/dist/{sources-CdWn7B5r.mjs → sources-CuG-Vma9.mjs} +1 -1
- package/dist/{src-_nn6V6aX.mjs → src-CvDV2vqI.mjs} +143 -44
- package/dist/testing.d.mts +4 -4
- package/dist/testing.mjs +1 -1
- package/dist/{types-XygtsVg3.d.mts → types-CKCNyjAI.d.mts} +4 -4
- package/dist/{types-BHEOjYV3.d.mts → types-DOsd3uSB.d.mts} +12 -4
- package/dist/{types-cEAJaK0D.d.mts → types-DmOnlY66.d.mts} +14 -8
- package/dist/{types-BUR4LWSa.d.mts → types-TmWmx6Ca.d.mts} +51 -6
- package/dist/{types-CATC2vK8.d.mts → types-ohTEXbrA.d.mts} +2 -2
- package/dist/{visual-CVHirfkU.d.mts → visual-DFxSs-Vp.d.mts} +6 -6
- package/dist/{visual-CYq-xUqz.mjs → visual-x0TPowBE.mjs} +143 -41
- package/dist/visual.d.mts +1 -1
- package/dist/visual.mjs +1 -1
- package/package.json +1 -1
|
@@ -3473,14 +3473,16 @@ type MotionCause = "mount" | "change" | "discard";
|
|
|
3473
3473
|
*/
|
|
3474
3474
|
type ReducedMotion = "cut" | "keep";
|
|
3475
3475
|
/**
|
|
3476
|
-
* Only the numeric fields of a component value: what a tween can interpolate.
|
|
3476
|
+
* Only the numeric fields of a component value: what a tween can interpolate. An optional number counts too, and its
|
|
3477
|
+
* entry is a plain required `number`, so a tween names it with a number and never with `undefined`.
|
|
3477
3478
|
*
|
|
3478
3479
|
* @example
|
|
3479
3480
|
* ```ts
|
|
3480
3481
|
* type Numbers = NumericFields<{ x: number; texture: string }>; // { x: number }
|
|
3482
|
+
* type Stretch = NumericFields<{ x: number; scaleX?: number }>; // { x: number; scaleX: number }
|
|
3481
3483
|
* ```
|
|
3482
3484
|
*/
|
|
3483
|
-
type NumericFields<Value extends object> = { [Key in keyof Value as Value[Key] extends number ? Key : never]
|
|
3485
|
+
type NumericFields<Value extends object> = { [Key in keyof Value as Exclude<Value[Key], undefined> extends number ? Key : never]-?: Exclude<Value[Key], undefined> };
|
|
3484
3486
|
/**
|
|
3485
3487
|
* One keyframe segment of a track: the fraction of the track's `ms` it ends at (`0..1`), the
|
|
3486
3488
|
* curve it eases with (the track's `ease` when left out) and the numeric fields it reaches. A
|
|
@@ -10998,6 +11000,8 @@ type TeardownScope = {
|
|
|
10998
11000
|
* const value: TransformValue = {
|
|
10999
11001
|
* x: 640, y: 340, rotation: 0, scale: 1.1, pivot: { x: 100, y: 40 }
|
|
11000
11002
|
* };
|
|
11003
|
+
* // A ribbon title that unfurls: 1 % of its width, full height, around its centre.
|
|
11004
|
+
* const ribbon: TransformValue = { ...value, scale: 1, scaleX: 0.01, pivot: { x: 100, y: 40 } };
|
|
11001
11005
|
* ```
|
|
11002
11006
|
*/
|
|
11003
11007
|
type TransformValue = {
|
|
@@ -11005,6 +11009,31 @@ type TransformValue = {
|
|
|
11005
11009
|
y: number;
|
|
11006
11010
|
rotation: number;
|
|
11007
11011
|
scale: number;
|
|
11012
|
+
/**
|
|
11013
|
+
* A factor on `scale` along X alone: the view draws `scale × scaleX` wide. Absent by default and read as 1, so a view
|
|
11014
|
+
* that never sets it is stored, snapshotted and described exactly as before. A tween, a motion or `toRest` of it starts
|
|
11015
|
+
* from 1 while it is absent. A child under a parent that turns and stretches on one axis is not sheared: the factors
|
|
11016
|
+
* compose per axis, and the rotation adds.
|
|
11017
|
+
*
|
|
11018
|
+
* @example
|
|
11019
|
+
* ```ts
|
|
11020
|
+
* // The ribbon unfurls to its full width, 260 ms after the screen opened.
|
|
11021
|
+
* world.ecs.spawn(owner, [Layer({ name: "ui" }), Transform({ x: 540, y: 300, scaleX: 0.01, pivot: { x: 200, y: 40 } })]);
|
|
11022
|
+
* view.tween(Transform, { scaleX: 1 }, { ms: 260 }); // drawn 400 wide at the end, 80 high throughout
|
|
11023
|
+
* ```
|
|
11024
|
+
*/
|
|
11025
|
+
scaleX?: number;
|
|
11026
|
+
/**
|
|
11027
|
+
* A factor on `scale` along Y alone: the view draws `scale × scaleY` high. Absent by default and read as 1, like
|
|
11028
|
+
* `scaleX`.
|
|
11029
|
+
*
|
|
11030
|
+
* @example
|
|
11031
|
+
* ```ts
|
|
11032
|
+
* // A squash on landing: wider and shorter for a beat.
|
|
11033
|
+
* world.ecs.set(blob, Transform, { scaleX: 1.2, scaleY: 0.8 });
|
|
11034
|
+
* ```
|
|
11035
|
+
*/
|
|
11036
|
+
scaleY?: number;
|
|
11008
11037
|
pivot: Point;
|
|
11009
11038
|
};
|
|
11010
11039
|
/**
|
|
@@ -11290,8 +11319,8 @@ type OverlayLevelValue = {
|
|
|
11290
11319
|
landed: boolean;
|
|
11291
11320
|
};
|
|
11292
11321
|
/**
|
|
11293
|
-
* Where a view sits: reference units, radians, uniform scale, and the local point it
|
|
11294
|
-
* around.
|
|
11322
|
+
* Where a view sits: reference units, radians, uniform scale (with an optional factor per axis), and the local point it
|
|
11323
|
+
* turns around.
|
|
11295
11324
|
*/
|
|
11296
11325
|
declare const Transform: ComponentType<TransformValue>;
|
|
11297
11326
|
/**
|
|
@@ -11525,6 +11554,22 @@ type CoverFrame = {
|
|
|
11525
11554
|
texture: PixiTexture;
|
|
11526
11555
|
users: Set<Entity>;
|
|
11527
11556
|
};
|
|
11557
|
+
/**
|
|
11558
|
+
* The scratch pose of a hot loop: a `TransformValue` whose per-axis factors are always there. `rootPoseInto` writes both
|
|
11559
|
+
* on every call (1 when the entity has none), so a reused object never carries the factor of the entity before. A pose
|
|
11560
|
+
* that may reach the ECS stays a `TransformValue`, which carries a factor only when it is not 1.
|
|
11561
|
+
*
|
|
11562
|
+
* @example
|
|
11563
|
+
* ```ts
|
|
11564
|
+
* // A reader that asks every frame keeps one pose and passes it in again.
|
|
11565
|
+
* const pose: AxisPose = { x: 0, y: 0, rotation: 0, scale: 1, scaleX: 1, scaleY: 1, pivot: { x: 0, y: 0 } };
|
|
11566
|
+
* rootPoseInto(ctx.require(worldPlugin).ecs, host, pose); // pose.scaleX is 1 for a host without the field
|
|
11567
|
+
* ```
|
|
11568
|
+
*/
|
|
11569
|
+
type AxisPose = TransformValue & {
|
|
11570
|
+
scaleX: number;
|
|
11571
|
+
scaleY: number;
|
|
11572
|
+
};
|
|
11528
11573
|
/**
|
|
11529
11574
|
* One layer of the scene: its container, the sort rule its children follow, the reasons that hide the container
|
|
11530
11575
|
* (`hidden.ts`), and whether it is the scene's HUD layer (`above: "overlays"`).
|
|
@@ -13024,7 +13069,7 @@ type HitWalk = {
|
|
|
13024
13069
|
* handed to a call that is not inlined is boxed, once per view.
|
|
13025
13070
|
*/
|
|
13026
13071
|
alphas: Float64Array; /** The root pose of the entity whose box is tested, written in place. */
|
|
13027
|
-
pose:
|
|
13072
|
+
pose: AxisPose; /** The reference point brought into an entity's own space, written in place. */
|
|
13028
13073
|
local: Point; /** The reference x. */
|
|
13029
13074
|
x: number; /** The reference y. */
|
|
13030
13075
|
y: number; /** The filter of `hitTest`; `undefined` while `hitAll` collects. */
|
|
@@ -14828,4 +14873,4 @@ type BundleCompanion = {
|
|
|
14828
14873
|
unload(bundle: string): void;
|
|
14829
14874
|
};
|
|
14830
14875
|
//#endregion
|
|
14831
|
-
export {
|
|
14876
|
+
export { Config$2 as $, ChangeHook as $n, Snapshot as $r, PerfSampleLine as $t, FilterSlotInputs as A, type as An, Api$3 as Ar, MonitorSections as At, OverlayValue as B, NodeTable as Bn, types_d_exports$5 as Br, PerfChange as Bt, SceneSpec as C, TextStylesOf as Cn, Mut as Cr, FrameColumns as Ct, AxisPose as D, exit as Dn, SystemDefinition as Dr, FrameRing as Dt, types_d_exports$1 as E, defineFlow as En, ResourceType as Er, FrameRecord as Et, HudPart as F, Bookmark as Fn, Api$4 as Fr, PERF_LOG_VERSION as Ft, SpriteBlend as G, Effect as Gn, Root as Gr, PerfEventLine as Gt, Shape as H, SceneIdOf as Hn, Config$6 as Hr, PerfCollectorLine as Ht, HudPartValue as I, DefineNode as In, ClockSource as Ir, PROBLEM_RULES as It, Transform as J, Hint as Jn, Patch as Jr, PerfHeaderLine as Jt, SpriteOptions as K, EffectOptions as Kn, State$6 as Kr, PerfEventName as Kt, NineSlice$1 as L, FlowGraph as Ln, Config$5 as Lr, PassKind as Lt, SyncApi as M, FeaturePlugin as Mn, Explained as Mr, OverlayWhat as Mt, WhyEntry as N, FeatureTree as Nn, State$4 as Nr, PERF_CAUSES as Nt, DebugSwitches as O, slot as On, SystemFor as Or, LongFrameEntry as Ot, Display as P, AnyFlow as Pn, types_d_exports$4 as Pr, PERF_GAP_BUCKETS as Pt, Api$1 as Q, AnchorTarget as Qn, SaveUnreadableError as Qr, PerfMeasured as Qt, NineSliceValue as R, FlowState as Rn, FakeClock as Rr, PassRecord as Rt, SceneDefinition as S, TextFormatsOf as Sn, FrameDiff as Sr, WhyLive as St, State$1 as T, contribution as Tn, QueryTerm as Tr, FrameReadout as Tt, ShapeValue as U, TypeTag as Un, Events$5 as Ur, PerfCounts as Ut, Parent as V, RouteStep as Vn, Api$5 as Vr, PerfChangeEntry as Vt, Sprite as W, Descriptor as Wn, Json as Wr, PerfDisplay as Wt, sprite as X, Answer as Xn, ProviderCall as Xr, PerfLongFrameLine as Xt, TransformValue as Y, NodeFx as Yn, PlayerStateProvider as Yr, PerfLogLine as Yt, AdaptiveScale as Z, Answered as Zn, SaveDoc as Zr, PerfMarkLine as Zt, AnySceneProjection as _, types_d_exports$8 as _i, EmitterIdOf as _n, ComponentSchema as _r, Orientation as _t, Config as a, Config$7 as ai, ProblemEventDetail as an, NumericFields as ar, PixiSprite as at, Events$1 as b, Require as bi, Position as bn, Entity as br, FilterCache as bt, LoadBundles as c, State$7 as ci, ShaderEventDetail as cn, ReducedMotion as cr, PoolTrim as ct, Manifest as d, Config$8 as di, CANVAS_RESTARTS as dn, TrackSegment as dr, types_d_exports$2 as dt, SnapshotOf as ei, PerfSpikeLine as en, DescriptionNode as er, MonitorConfig as et, ReadyBundles as f, FrameRate as fi, CanvasRestart as fn, ViewHandle as fr, ShotsApi as ft, types_d_exports as g, Time as gi, Config$3 as gn, ComponentHandle as gr, RenderStats as gt, Usage as h, ThermalReading as hi, BundlesOf as hn, AnyComponentValue as hr, MonitorCounts as ht, BundleSpec as i, Api$6 as ii, PoolTrimDetail as in, MotionHandle as ir, PixiModule as it, FilterSlotQuad as j, FeatureDescription as jn, Config$4 as jr, OverlayEventDetail as jt, FilterSlot as k, to as kn, TagType as kr, MONITOR_SECTIONS as kt, LoadReason as l, types_d_exports$7 as li, ShaderWhat as ln, SceneSwitch as lr, State$2 as lt, Tier as m, State$8 as mi, Api$2 as mn, AnyComponentType as mr, Captured as mt, AssetsIo as n, RngApi as ni, PerfTelemetryLine as nn, Motion as nr, PixiFilter as nt, DefineBundles as o, Events$6 as oi, ProblemRule as on, ProjectionMotion as or, PixiTexture as ot, State as p, RateChange as pi, DEMAND_REASONS as pn, AnyComponent as pr, ShotsConfig as pt, SpriteValue as q, GuideOptions as qn, types_d_exports$6 as qr, PerfGapLine as qt, BundleMap as r, RngState as ri, PerfThermalLine as rn, MotionCause as rr, PixiGpuProgram as rt, Events as s, PauseReason as si, SHADER_WHATS as sn, ProjectionSpec as sr, PixiUniformGroup as st, Api as t, StoreApi as ti, PerfStartupLine as tn, Ease as tr, PixiContainer as tt, LoadResult as u, Api$7 as ui, WarmDetail as un, TrackOptions as ur, Under as ut, Config$1 as v, Config$9 as vi, GameTypes as vn, ComponentType as vr, Point as vt, ScenesApi as w, types_d_exports$3 as wn, Narrowed as wr, FrameReadResult as wt, LayerMap as x, State$3 as xn, EntitySnapshot as xr, RetakeWhy as xt, DefineScene as y, Events$8 as yi, HudKeysOf as yn, ComponentValue as yr, ViewportSize as yt, Overlay as z, JournalEntry as zn, State$5 as zr, PerfCause as zt };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as HeadlessApp } from "./headless-
|
|
1
|
+
import { $r as Snapshot, Wr as Json } from "./types-TmWmx6Ca.mjs";
|
|
2
|
+
import { t as HeadlessApp } from "./headless-DjvkUuv6.mjs";
|
|
3
3
|
import { Log } from "@moku-labs/common/browser";
|
|
4
4
|
|
|
5
5
|
//#region src/plugins/flow/doors/types.d.ts
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { W as AnimApi, r as UiApi } from "./types-
|
|
3
|
-
import { R as InputApi } from "./types-
|
|
4
|
-
import { r as Repro } from "./headless-
|
|
5
|
-
import { i as ControlApp, o as InputOf } from "./types-
|
|
6
|
-
import { t as commands } from "./commands-
|
|
1
|
+
import { Ar as Api$1, Fr as Api$4, Q as Api, Vr as Api$2, ii as Api$3 } from "./types-TmWmx6Ca.mjs";
|
|
2
|
+
import { W as AnimApi, r as UiApi } from "./types-DmOnlY66.mjs";
|
|
3
|
+
import { R as InputApi } from "./types-DOsd3uSB.mjs";
|
|
4
|
+
import { r as Repro } from "./headless-DjvkUuv6.mjs";
|
|
5
|
+
import { i as ControlApp, o as InputOf } from "./types-ohTEXbrA.mjs";
|
|
6
|
+
import { t as commands } from "./commands-Cwxtb672.mjs";
|
|
7
7
|
|
|
8
8
|
//#region src/visual/types.d.ts
|
|
9
9
|
/** The base commands of the `/control` door, keyed by their short names. */
|
|
@@ -1,4 +1,35 @@
|
|
|
1
1
|
import { t as defineComponent } from "./component-DGg5DqKK.mjs";
|
|
2
|
+
//#region src/plugins/world/neutral.ts
|
|
3
|
+
/** The key under which a component type holds the neutral value of its optional numeric fields. Engine-internal. */
|
|
4
|
+
const NEUTRAL = Symbol("moku.neutral");
|
|
5
|
+
/**
|
|
6
|
+
* Gives a component type the neutral value of its optional numeric fields: the number a field means while a stored value
|
|
7
|
+
* leaves it out (`Transform`'s `scaleX` is 1). Engine-internal, not a root export: a tween that starts from a missing
|
|
8
|
+
* field and `toRest` read it through `neutralOf`. The value hangs on the type object under a symbol, so it is neither
|
|
9
|
+
* enumerable nor part of the type's public shape.
|
|
10
|
+
*
|
|
11
|
+
* @param type - The component type.
|
|
12
|
+
* @param neutral - The neutral value of each field.
|
|
13
|
+
* @returns The same type.
|
|
14
|
+
*/
|
|
15
|
+
function withNeutral(type, neutral) {
|
|
16
|
+
Object.defineProperty(type, NEUTRAL, { value: Object.freeze({ ...neutral }) });
|
|
17
|
+
return type;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The neutral value of a field of a component type, set by `withNeutral`.
|
|
21
|
+
*
|
|
22
|
+
* @param type - The component type, or any handle.
|
|
23
|
+
* @param field - The field name.
|
|
24
|
+
* @returns The neutral value, or `undefined` when the type declares none for the field.
|
|
25
|
+
*/
|
|
26
|
+
function neutralOf(type, field) {
|
|
27
|
+
const held = Reflect.get(type, NEUTRAL);
|
|
28
|
+
if (typeof held !== "object" || held === null) return void 0;
|
|
29
|
+
const value = Reflect.get(held, field);
|
|
30
|
+
return typeof value === "number" ? value : void 0;
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
2
33
|
//#region src/plugins/world/ecs/define.ts
|
|
3
34
|
/**
|
|
4
35
|
* Declares a component type. The defaults give the TypeScript type, the JSON shape and the
|
|
@@ -254,10 +285,13 @@ const spriteDefaults = {
|
|
|
254
285
|
fit: "fill"
|
|
255
286
|
};
|
|
256
287
|
/**
|
|
257
|
-
* Where a view sits: reference units, radians, uniform scale, and the local point it
|
|
258
|
-
* around.
|
|
288
|
+
* Where a view sits: reference units, radians, uniform scale (with an optional factor per axis), and the local point it
|
|
289
|
+
* turns around.
|
|
259
290
|
*/
|
|
260
|
-
const Transform = /*#__PURE__*/ component("Transform", transformDefaults)
|
|
291
|
+
const Transform = /*#__PURE__*/ withNeutral(component("Transform", transformDefaults), {
|
|
292
|
+
scaleX: 1,
|
|
293
|
+
scaleY: 1
|
|
294
|
+
});
|
|
261
295
|
/**
|
|
262
296
|
* One textured quad. `texture` is an asset key, resolved through the texture providers; a size
|
|
263
297
|
* and a `fit` draw it into a box. `blend: "add"` or `"screen"` lays it over what is under it.
|
|
@@ -423,17 +457,37 @@ function isLeaving(ecs, entity) {
|
|
|
423
457
|
return false;
|
|
424
458
|
}
|
|
425
459
|
/**
|
|
460
|
+
* Gives a fresh pose the per-axis factors a pose that may reach the ECS carries: a key only when the factor is not 1 or
|
|
461
|
+
* the stored value already has it, so a merge never leaves a stale factor and a plain view gains no key.
|
|
462
|
+
*
|
|
463
|
+
* @param pose - The fresh pose, written in place.
|
|
464
|
+
* @param factorX - The composed X factor.
|
|
465
|
+
* @param factorY - The composed Y factor.
|
|
466
|
+
* @param keepX - Whether the stored value already has `scaleX`.
|
|
467
|
+
* @param keepY - Whether the stored value already has `scaleY`.
|
|
468
|
+
* @returns The same pose.
|
|
469
|
+
* @example
|
|
470
|
+
* ```ts
|
|
471
|
+
* withFactors({ x: 0, y: 0, rotation: 0, scale: 1, pivot: { x: 0, y: 0 } }, 2, 1, false, false).scaleX; // 2
|
|
472
|
+
* ```
|
|
473
|
+
*/
|
|
474
|
+
function withFactors(pose, factorX, factorY, keepX, keepY) {
|
|
475
|
+
if (factorX !== 1 || keepX) pose.scaleX = factorX;
|
|
476
|
+
if (factorY !== 1 || keepY) pose.scaleY = factorY;
|
|
477
|
+
return pose;
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
426
480
|
* A fresh copy of a pose, so a caller may change what it got without touching the world.
|
|
427
481
|
*
|
|
428
482
|
* @param pose - The pose to copy.
|
|
429
|
-
* @returns The same numbers in new objects.
|
|
483
|
+
* @returns The same numbers in new objects; a factor only where the pose has one.
|
|
430
484
|
* @example
|
|
431
485
|
* ```ts
|
|
432
486
|
* copyPose({ x: 1, y: 2, rotation: 0, scale: 1, pivot: { x: 0, y: 0 } }).pivot.x; // 0
|
|
433
487
|
* ```
|
|
434
488
|
*/
|
|
435
489
|
function copyPose(pose) {
|
|
436
|
-
return {
|
|
490
|
+
return withFactors({
|
|
437
491
|
x: pose.x,
|
|
438
492
|
y: pose.y,
|
|
439
493
|
rotation: pose.rotation,
|
|
@@ -442,7 +496,7 @@ function copyPose(pose) {
|
|
|
442
496
|
x: pose.pivot.x,
|
|
443
497
|
y: pose.pivot.y
|
|
444
498
|
}
|
|
445
|
-
};
|
|
499
|
+
}, pose.scaleX ?? 1, pose.scaleY ?? 1, pose.scaleX !== void 0, pose.scaleY !== void 0);
|
|
446
500
|
}
|
|
447
501
|
/**
|
|
448
502
|
* Moves a point out of the local space of a pose, into the space the pose sits in.
|
|
@@ -454,13 +508,16 @@ function copyPose(pose) {
|
|
|
454
508
|
* ```ts
|
|
455
509
|
* applyPose({ x: 10, y: 0, rotation: 0, scale: 2, pivot: { x: 5, y: 0 } }, { x: 5, y: 1 });
|
|
456
510
|
* // { x: 10, y: 2 }
|
|
511
|
+
* // The same pose stretched 3 times on X: a point 4 right of the pivot lands 24 right of the position.
|
|
512
|
+
* applyPose({ x: 10, y: 0, rotation: 0, scale: 2, scaleX: 3, pivot: { x: 5, y: 0 } }, { x: 9, y: 0 });
|
|
513
|
+
* // { x: 34, y: 0 }
|
|
457
514
|
* ```
|
|
458
515
|
*/
|
|
459
516
|
function applyPose(pose, point) {
|
|
460
517
|
const cos = Math.cos(pose.rotation);
|
|
461
518
|
const sin = Math.sin(pose.rotation);
|
|
462
|
-
const dx = point.x - pose.pivot.x;
|
|
463
|
-
const dy = point.y - pose.pivot.y;
|
|
519
|
+
const dx = (point.x - pose.pivot.x) * (pose.scaleX ?? 1);
|
|
520
|
+
const dy = (point.y - pose.pivot.y) * (pose.scaleY ?? 1);
|
|
464
521
|
return {
|
|
465
522
|
x: pose.x + pose.scale * (dx * cos - dy * sin),
|
|
466
523
|
y: pose.y + pose.scale * (dx * sin + dy * cos)
|
|
@@ -473,7 +530,8 @@ function applyPose(pose, point) {
|
|
|
473
530
|
*
|
|
474
531
|
* @param above - The parent pose.
|
|
475
532
|
* @param local - The pose under it.
|
|
476
|
-
* @returns The composed pose; it keeps the local pivot.
|
|
533
|
+
* @returns The composed pose; it keeps the local pivot. The factors multiply per axis; a key is there only when the
|
|
534
|
+
* product is not 1 or `local` has it.
|
|
477
535
|
* @example
|
|
478
536
|
* ```ts
|
|
479
537
|
* poseUnder(
|
|
@@ -484,7 +542,7 @@ function applyPose(pose, point) {
|
|
|
484
542
|
*/
|
|
485
543
|
function poseUnder(above, local) {
|
|
486
544
|
const landed = applyPose(above, local);
|
|
487
|
-
return {
|
|
545
|
+
return withFactors({
|
|
488
546
|
x: landed.x,
|
|
489
547
|
y: landed.y,
|
|
490
548
|
rotation: local.rotation + above.rotation,
|
|
@@ -493,12 +551,13 @@ function poseUnder(above, local) {
|
|
|
493
551
|
x: local.pivot.x,
|
|
494
552
|
y: local.pivot.y
|
|
495
553
|
}
|
|
496
|
-
};
|
|
554
|
+
}, (local.scaleX ?? 1) * (above.scaleX ?? 1), (local.scaleY ?? 1) * (above.scaleY ?? 1), local.scaleX !== void 0, local.scaleY !== void 0);
|
|
497
555
|
}
|
|
498
556
|
/**
|
|
499
557
|
* Where an entity really is, written into the caller's pose: its `Transform` composed through the `Parent` chain,
|
|
500
558
|
* every pivot on the way applied, the numbers of `rootPoseOf` (the same steps in the same order). The answer keeps the
|
|
501
|
-
* entity's own pivot. Allocates nothing: a reader that asks every frame passes the same object.
|
|
559
|
+
* entity's own pivot. Allocates nothing: a reader that asks every frame passes the same object. Both per-axis factors
|
|
560
|
+
* are written on every call, 1 for an entity without them, so a reused pose never keeps the factor of the entity before.
|
|
502
561
|
*
|
|
503
562
|
* @param ecs - The world read, `world.ecs`.
|
|
504
563
|
* @param entity - The entity to place.
|
|
@@ -508,9 +567,9 @@ function poseUnder(above, local) {
|
|
|
508
567
|
* @example
|
|
509
568
|
* ```ts
|
|
510
569
|
* // `effects` follows a host every frame: the slot sits at (40, 60) scaled 0.5, the host at (100, 200) inside it.
|
|
511
|
-
* const pose = { x: 0, y: 0, rotation: 0, scale: 1, pivot: { x: 0, y: 0 } };
|
|
570
|
+
* const pose = { x: 0, y: 0, rotation: 0, scale: 1, scaleX: 1, scaleY: 1, pivot: { x: 0, y: 0 } };
|
|
512
571
|
* rootPoseInto(ctx.require(worldPlugin).ecs, host, pose);
|
|
513
|
-
* // pose is { x: 90, y: 160, rotation: 0, scale: 0.5, pivot: { x: 0, y: 0 } }
|
|
572
|
+
* // pose is { x: 90, y: 160, rotation: 0, scale: 0.5, scaleX: 1, scaleY: 1, pivot: { x: 0, y: 0 } }
|
|
514
573
|
* ```
|
|
515
574
|
*/
|
|
516
575
|
function rootPoseInto(ecs, entity, out, own) {
|
|
@@ -519,6 +578,8 @@ function rootPoseInto(ecs, entity, out, own) {
|
|
|
519
578
|
out.y = start.y;
|
|
520
579
|
out.rotation = start.rotation;
|
|
521
580
|
out.scale = start.scale;
|
|
581
|
+
out.scaleX = "scaleX" in start ? start.scaleX ?? 1 : 1;
|
|
582
|
+
out.scaleY = "scaleY" in start ? start.scaleY ?? 1 : 1;
|
|
522
583
|
out.pivot.x = start.pivot.x;
|
|
523
584
|
out.pivot.y = start.pivot.y;
|
|
524
585
|
let current = entity;
|
|
@@ -528,16 +589,33 @@ function rootPoseInto(ecs, entity, out, own) {
|
|
|
528
589
|
const above = ecs.get(parent, Transform) ?? Transform.defaults;
|
|
529
590
|
const cos = Math.cos(above.rotation);
|
|
530
591
|
const sin = Math.sin(above.rotation);
|
|
531
|
-
const
|
|
532
|
-
const
|
|
592
|
+
const factorX = "scaleX" in above ? above.scaleX ?? 1 : 1;
|
|
593
|
+
const factorY = "scaleY" in above ? above.scaleY ?? 1 : 1;
|
|
594
|
+
const dx = (out.x - above.pivot.x) * factorX;
|
|
595
|
+
const dy = (out.y - above.pivot.y) * factorY;
|
|
533
596
|
out.x = above.x + above.scale * (dx * cos - dy * sin);
|
|
534
597
|
out.y = above.y + above.scale * (dx * sin + dy * cos);
|
|
535
598
|
out.rotation = out.rotation + above.rotation;
|
|
536
599
|
out.scale = out.scale * above.scale;
|
|
600
|
+
out.scaleX = out.scaleX * factorX;
|
|
601
|
+
out.scaleY = out.scaleY * factorY;
|
|
537
602
|
current = parent;
|
|
538
603
|
}
|
|
539
604
|
return out;
|
|
540
605
|
}
|
|
606
|
+
/** The scratch of `rootPoseOf`: one walk at a time, nothing of it leaves, so the call needs no pose of its own. */
|
|
607
|
+
const walked = {
|
|
608
|
+
x: 0,
|
|
609
|
+
y: 0,
|
|
610
|
+
rotation: 0,
|
|
611
|
+
scale: 1,
|
|
612
|
+
scaleX: 1,
|
|
613
|
+
scaleY: 1,
|
|
614
|
+
pivot: {
|
|
615
|
+
x: 0,
|
|
616
|
+
y: 0
|
|
617
|
+
}
|
|
618
|
+
};
|
|
541
619
|
/**
|
|
542
620
|
* Where an entity really is: its `Transform` composed through the `Parent` chain, every pivot on
|
|
543
621
|
* the way applied. The answer keeps the entity's own pivot, so it can be written straight into the
|
|
@@ -546,7 +624,9 @@ function rootPoseInto(ecs, entity, out, own) {
|
|
|
546
624
|
* @param ecs - The world read, `world.ecs`.
|
|
547
625
|
* @param entity - The entity to place.
|
|
548
626
|
* @param own - A pose to use in place of the entity's own `Transform`, such as its rest pose.
|
|
549
|
-
* @returns The pose in root space, a fresh object. An entity without a `Transform` sits at the identity pose.
|
|
627
|
+
* @returns The pose in root space, a fresh object. An entity without a `Transform` sits at the identity pose. It has
|
|
628
|
+
* `scaleX` / `scaleY` only where the composed factor is not 1 or the entity's own pose has the key, so a plain view
|
|
629
|
+
* gains no key when this is written back.
|
|
550
630
|
* @example
|
|
551
631
|
* ```ts
|
|
552
632
|
* // `input` lifts a board cell out of its slot: the slot sits at (40, 60) scaled 0.5,
|
|
@@ -556,16 +636,18 @@ function rootPoseInto(ecs, entity, out, own) {
|
|
|
556
636
|
* ```
|
|
557
637
|
*/
|
|
558
638
|
function rootPoseOf(ecs, entity, own) {
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
639
|
+
const start = own ?? ecs.get(entity, Transform);
|
|
640
|
+
const pose = rootPoseInto(ecs, entity, walked, own);
|
|
641
|
+
return withFactors({
|
|
642
|
+
x: pose.x,
|
|
643
|
+
y: pose.y,
|
|
644
|
+
rotation: pose.rotation,
|
|
645
|
+
scale: pose.scale,
|
|
564
646
|
pivot: {
|
|
565
|
-
x:
|
|
566
|
-
y:
|
|
647
|
+
x: pose.pivot.x,
|
|
648
|
+
y: pose.pivot.y
|
|
567
649
|
}
|
|
568
|
-
},
|
|
650
|
+
}, pose.scaleX, pose.scaleY, start?.scaleX !== void 0, start?.scaleY !== void 0);
|
|
569
651
|
}
|
|
570
652
|
/**
|
|
571
653
|
* The inverse of `rootPoseOf`: the local pose under `parent` that puts an entity at a root pose.
|
|
@@ -574,8 +656,8 @@ function rootPoseOf(ecs, entity, own) {
|
|
|
574
656
|
* @param ecs - The world read, `world.ecs`.
|
|
575
657
|
* @param parent - The entity to hang under; `0` for none, which answers the root pose itself.
|
|
576
658
|
* @param root - The pose in root space.
|
|
577
|
-
* @returns The local pose. A parent collapsed to scale 0 counts as
|
|
578
|
-
*
|
|
659
|
+
* @returns The local pose. A parent collapsed to scale 0, or a factor of 0, counts as 1, so the answer stays finite. The
|
|
660
|
+
* per-axis factors divide per axis; a key is there only where the result is not 1 or `root` has it.
|
|
579
661
|
* @example
|
|
580
662
|
* ```ts
|
|
581
663
|
* // `input` drops the cell back into the slot at (40, 60) scaled 0.5, where the finger left it.
|
|
@@ -589,20 +671,22 @@ function localPoseOf(ecs, parent, root) {
|
|
|
589
671
|
if (parent === 0) return copyPose(root);
|
|
590
672
|
const above = rootPoseOf(ecs, parent);
|
|
591
673
|
const scale = above.scale === 0 ? 1 : above.scale;
|
|
674
|
+
const factorX = above.scaleX === void 0 || above.scaleX === 0 ? 1 : above.scaleX;
|
|
675
|
+
const factorY = above.scaleY === void 0 || above.scaleY === 0 ? 1 : above.scaleY;
|
|
592
676
|
const cos = Math.cos(-above.rotation);
|
|
593
677
|
const sin = Math.sin(-above.rotation);
|
|
594
678
|
const dx = root.x - above.x;
|
|
595
679
|
const dy = root.y - above.y;
|
|
596
|
-
return {
|
|
597
|
-
x: above.pivot.x + (dx * cos - dy * sin) / scale,
|
|
598
|
-
y: above.pivot.y + (dx * sin + dy * cos) / scale,
|
|
680
|
+
return withFactors({
|
|
681
|
+
x: above.pivot.x + (dx * cos - dy * sin) / (scale * factorX),
|
|
682
|
+
y: above.pivot.y + (dx * sin + dy * cos) / (scale * factorY),
|
|
599
683
|
rotation: root.rotation - above.rotation,
|
|
600
684
|
scale: root.scale / scale,
|
|
601
685
|
pivot: {
|
|
602
686
|
x: root.pivot.x,
|
|
603
687
|
y: root.pivot.y
|
|
604
688
|
}
|
|
605
|
-
};
|
|
689
|
+
}, (root.scaleX ?? 1) / factorX, (root.scaleY ?? 1) / factorY, root.scaleX !== void 0, root.scaleY !== void 0);
|
|
606
690
|
}
|
|
607
691
|
/**
|
|
608
692
|
* Where a local point of an entity lands in root (reference) space: the point posed through the
|
|
@@ -1891,7 +1975,7 @@ function visualRectOf(element, lookup) {
|
|
|
1891
1975
|
return scaleByFits(element.rect, chainOf(element, lookup));
|
|
1892
1976
|
}
|
|
1893
1977
|
/**
|
|
1894
|
-
* Tells whether two transforms put a view in the same place.
|
|
1978
|
+
* Tells whether two transforms put a view in the same place. A missing `scaleX` or `scaleY` counts as 1.
|
|
1895
1979
|
*
|
|
1896
1980
|
* @param first - One pose.
|
|
1897
1981
|
* @param second - The other.
|
|
@@ -1900,16 +1984,25 @@ function visualRectOf(element, lookup) {
|
|
|
1900
1984
|
* ```ts
|
|
1901
1985
|
* samePose(
|
|
1902
1986
|
* { x: 1, y: 2, rotation: 0, scale: 1, pivot: { x: 0, y: 0 } },
|
|
1903
|
-
* { x: 1, y: 2, rotation: 0, scale: 1, pivot: { x: 0, y: 0 } }
|
|
1987
|
+
* { x: 1, y: 2, rotation: 0, scale: 1, scaleX: 1, pivot: { x: 0, y: 0 } }
|
|
1904
1988
|
* ); // true
|
|
1989
|
+
* samePose(
|
|
1990
|
+
* { x: 1, y: 2, rotation: 0, scale: 1, pivot: { x: 0, y: 0 } },
|
|
1991
|
+
* { x: 1, y: 2, rotation: 0, scale: 1, scaleX: 0.5, pivot: { x: 0, y: 0 } }
|
|
1992
|
+
* ); // false
|
|
1905
1993
|
* ```
|
|
1906
1994
|
*/
|
|
1907
1995
|
function samePose(first, second) {
|
|
1908
|
-
|
|
1996
|
+
const firstX = "scaleX" in first ? first.scaleX ?? 1 : 1;
|
|
1997
|
+
const secondX = "scaleX" in second ? second.scaleX ?? 1 : 1;
|
|
1998
|
+
const firstY = "scaleY" in first ? first.scaleY ?? 1 : 1;
|
|
1999
|
+
const secondY = "scaleY" in second ? second.scaleY ?? 1 : 1;
|
|
2000
|
+
return first.x === second.x && first.y === second.y && first.rotation === second.rotation && first.scale === second.scale && firstX === secondX && firstY === secondY && first.pivot.x === second.pivot.x && first.pivot.y === second.pivot.y;
|
|
1909
2001
|
}
|
|
1910
2002
|
/**
|
|
1911
|
-
* Where a local box of a view lands in root space: moved by the pose, scaled around its pivot
|
|
1912
|
-
* A guide hole is axis-aligned, so the rotation is left out.
|
|
2003
|
+
* Where a local box of a view lands in root space: moved by the pose, scaled around its pivot, per axis
|
|
2004
|
+
* (`scale × scaleX` wide, `scale × scaleY` tall). A guide hole is axis-aligned, so the rotation is left out. A size is
|
|
2005
|
+
* a magnitude: a view flipped by a negative factor keeps its width and starts at its left edge.
|
|
1913
2006
|
*
|
|
1914
2007
|
* @param pose - The root pose of the view, `rootPoseOf` of `renderer`.
|
|
1915
2008
|
* @param local - The box in the view's local units.
|
|
@@ -1918,15 +2011,24 @@ function samePose(first, second) {
|
|
|
1918
2011
|
* ```ts
|
|
1919
2012
|
* drawnRect({ x: 200, y: 200, rotation: 0, scale: 0.8, pivot: { x: 250, y: 250 } },
|
|
1920
2013
|
* { x: 50, y: 50, w: 100, h: 100 }); // { x: 40, y: 40, w: 80, h: 80 }
|
|
2014
|
+
* // A ribbon of 200 x 40 squeezed to half its width about its left edge.
|
|
2015
|
+
* drawnRect({ x: 0, y: 0, rotation: 0, scale: 1, scaleX: 0.5, pivot: { x: 0, y: 0 } },
|
|
2016
|
+
* { x: 0, y: 0, w: 200, h: 40 }); // { x: 0, y: 0, w: 100, h: 40 }
|
|
1921
2017
|
* ```
|
|
1922
2018
|
*/
|
|
1923
2019
|
function drawnRect(pose, local) {
|
|
2020
|
+
const factorX = pose.scale * (pose.scaleX ?? 1);
|
|
2021
|
+
const factorY = pose.scale * (pose.scaleY ?? 1);
|
|
2022
|
+
const w = local.w * Math.abs(factorX);
|
|
2023
|
+
const h = local.h * Math.abs(factorY);
|
|
2024
|
+
const left = pose.x + factorX * (local.x - pose.pivot.x);
|
|
2025
|
+
const top = pose.y + factorY * (local.y - pose.pivot.y);
|
|
1924
2026
|
return {
|
|
1925
|
-
x:
|
|
1926
|
-
y:
|
|
1927
|
-
w
|
|
1928
|
-
h
|
|
2027
|
+
x: factorX < 0 ? left - w : left,
|
|
2028
|
+
y: factorY < 0 ? top - h : top,
|
|
2029
|
+
w,
|
|
2030
|
+
h
|
|
1929
2031
|
};
|
|
1930
2032
|
}
|
|
1931
2033
|
//#endregion
|
|
1932
|
-
export { Overlay as $, unitOf as A, readStyle as B, UiCounters as C, defineStyle as D, defineTokens as E, boldLookOf as F, parentOf as G, applyPose as H, builtInStyles as I, rootPoseInto as J, poseUnder as K, defineTextFormats as L, Countdown as M, Text as N, formatBound as O, bind as P, NineSlice as Q, defineTextStyles as R, UI_OWNER as S, uiFor as T, isLeaving as U, textFor as V, localPoseOf as W, Display as X, rootPoseOf as Y, HudPart as Z, DebugTrigger as _, systemsFor as _t, fieldsLeftAlone as a, arcDefaults as at, Scroll as b, namedKeyOf as c, Exiting as ct, samePose as d, Order as dt, OverlayLevel as et, visualOf as f, Tree as ft, Covered as g, system as gt, Box as h, resource as ht, drawnRect as i, Transform as it, wholeValue as j, isTextFormat as k, namesFormat as l, Layer as lt, writtenKeyOf as m, mut as mt, CONTENT as n, Shape as nt, fitScaleOf as o, componentsFor as ot, visualRectOf as p, component as pt, rootPointOf as q, bindOf as r, Sprite as rt, livePatch as s, sprite as st, ANCHOR as t, Parent as tt, restValueOf as u, Now as ut, Escapable as v, tag as vt, popup as w, ScrollState as x, LocalWrite as y, label as z };
|
|
2034
|
+
export { Overlay as $, unitOf as A, readStyle as B, UiCounters as C, defineStyle as D, defineTokens as E, boldLookOf as F, parentOf as G, applyPose as H, builtInStyles as I, rootPoseInto as J, poseUnder as K, defineTextFormats as L, Countdown as M, Text as N, formatBound as O, bind as P, NineSlice as Q, defineTextStyles as R, UI_OWNER as S, uiFor as T, isLeaving as U, textFor as V, localPoseOf as W, Display as X, rootPoseOf as Y, HudPart as Z, DebugTrigger as _, systemsFor as _t, fieldsLeftAlone as a, arcDefaults as at, Scroll as b, namedKeyOf as c, Exiting as ct, samePose as d, Order as dt, OverlayLevel as et, visualOf as f, Tree as ft, Covered as g, system as gt, Box as h, resource as ht, drawnRect as i, Transform as it, wholeValue as j, isTextFormat as k, namesFormat as l, Layer as lt, writtenKeyOf as m, mut as mt, CONTENT as n, Shape as nt, fitScaleOf as o, componentsFor as ot, visualRectOf as p, component as pt, rootPointOf as q, bindOf as r, Sprite as rt, livePatch as s, sprite as st, ANCHOR as t, Parent as tt, restValueOf as u, Now as ut, Escapable as v, tag as vt, popup as w, ScrollState as x, LocalWrite as y, neutralOf as yt, label as z };
|
package/dist/visual.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as VisualApp, c as VisualRenderer, d as VisualStart, f as VisualStep, h as VisualTolerance, i as CheckpointResult, l as VisualReport, m as VisualTestResult, n as runVisualTests, o as VisualOptions, p as VisualTest, r as defineVisualTest, s as VisualPage, t as parseVisualArgv, u as VisualSetup } from "./visual-
|
|
1
|
+
import { a as VisualApp, c as VisualRenderer, d as VisualStart, f as VisualStep, h as VisualTolerance, i as CheckpointResult, l as VisualReport, m as VisualTestResult, n as runVisualTests, o as VisualOptions, p as VisualTest, r as defineVisualTest, s as VisualPage, t as parseVisualArgv, u as VisualSetup } from "./visual-DFxSs-Vp.mjs";
|
|
2
2
|
export { type CheckpointResult, type VisualApp, type VisualOptions, type VisualPage, type VisualRenderer, type VisualReport, type VisualSetup, type VisualStart, type VisualStep, type VisualTest, type VisualTestResult, type VisualTolerance, defineVisualTest, parseVisualArgv, runVisualTests };
|
package/dist/visual.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as VISUAL_CLOCK } from "./fake-hnJcJeYf.mjs";
|
|
2
|
-
import { n as read, t as sources } from "./sources-
|
|
2
|
+
import { n as read, t as sources } from "./sources-CuG-Vma9.mjs";
|
|
3
3
|
import { n as commands, t as run } from "./run-CeZj5UAg.mjs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { createBrandConsole } from "@moku-labs/common/cli";
|