retiam 1.0.2 → 1.0.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.
@@ -1,3 +1,4 @@
1
+ import { IndexInfo, ShowIndicesOptions } from '../utils/IndexInspector';
1
2
  import { Entity, EntityOptions } from './Entity';
2
3
  import { Path } from '../entities/primitives/2d/Path';
3
4
  import { Camera } from '../camera/Camera';
@@ -5,6 +6,10 @@ import { Vec2 } from '../math/vector/Vec2';
5
6
  import { Vec3 } from '../math/vector/Vec3';
6
7
  import { ISpatialField, SpatialMappingFunction, HomotopyFunction, ComplexMappingFunction } from '../math/fields/SpatialField';
7
8
  import { SubdivisionOptions } from '../utils/SubdivisionEngine';
9
+ export declare function registerIndexInspector(inspector: {
10
+ inspect: (e: any) => any;
11
+ show: (e: any, opt?: any) => any;
12
+ }): void;
8
13
  /**
9
14
  * Abstract base class for all 2D vector-based entities.
10
15
  * Guarantees support for mathematical path extraction, morphing, and sub-path animations.
@@ -148,4 +153,13 @@ export declare abstract class VectorEntity extends Entity {
148
153
  * @param fn Callback invoked for each leaf Path instance along with its sequential index.
149
154
  */
150
155
  forEachPath(fn: (path: Path, index: number) => void): this;
156
+ /**
157
+ * Inspects all sub-paths and prints a formatted table to console.table.
158
+ */
159
+ inspectIndices(): IndexInfo[];
160
+ /**
161
+ * Generates an overlaid VGroup of numbered badges corresponding to each sub-path index.
162
+ * Add directly to the scene to visually identify path indices.
163
+ */
164
+ showIndices(options?: ShowIndicesOptions): any;
151
165
  }
@@ -3,8 +3,22 @@ import { Entity } from '../../_core/Entity';
3
3
  import { AnimOptions } from '../AnimOptions';
4
4
  import { State } from '../../_core/State';
5
5
  import { VectorEntity } from '../../_core/VectorEntity';
6
+ import { IndexMap, KeyMap } from './TransformMatchingTex';
6
7
  export interface TransformMatchingShapesOptions extends AnimOptions {
7
8
  morphUnmatched?: boolean;
9
+ /**
10
+ * Explicit path/contour index pair mappings [sourceIndex, targetIndex][].
11
+ * Direct surgical control: forces source shape path at sourceIndex to map to targetIndex.
12
+ * Takes highest precedence before geometric/label matching.
13
+ * @example [[0, 2]] or { 0: 2 }
14
+ */
15
+ indexMap?: IndexMap;
16
+ /**
17
+ * Explicit shape label or constructor name mapping.
18
+ * Maps source shape LABEL/name to target shape LABEL/name.
19
+ * @example { "circle": "square", "leftArm": "rightArm" }
20
+ */
21
+ keyMap?: KeyMap;
8
22
  }
9
23
  export declare class TransformMatchingShapes extends Concurrent {
10
24
  private sourceEntity;
@@ -2,8 +2,23 @@ import { Concurrent } from '../Concurrent';
2
2
  import { Tex } from '../../entities/composites/text/Tex';
3
3
  import { Text } from '../../entities/composites/text/Text';
4
4
  import { AnimOptions } from '../AnimOptions';
5
+ export type IndexMap = [number, number][] | Record<number, number> | Map<number, number>;
6
+ export type KeyMap = Record<string, string> | Map<string, string>;
5
7
  export interface TransformMatchingTexOptions extends AnimOptions {
6
8
  morphUnmatched?: boolean;
9
+ /**
10
+ * Explicit index pair mappings [sourceIndex, targetIndex][].
11
+ * Direct surgical control: forces path at sourceIndex to map to targetIndex.
12
+ * Takes highest precedence before key/anchor matching.
13
+ * @example [[2, 5]] or { 2: 5 }
14
+ */
15
+ indexMap?: IndexMap;
16
+ /**
17
+ * Explicit symbol/substring translation map.
18
+ * Maps source symbol/substring to target symbol/substring.
19
+ * @example { "+": "-", "b^2": "b^2", "\\alpha": "\\beta" }
20
+ */
21
+ keyMap?: KeyMap;
7
22
  }
8
23
  export declare class TransformMatchingTex extends Concurrent {
9
24
  /** Resolves the absolute world state matrix mapping. */
@@ -1,8 +1,22 @@
1
1
  import { Concurrent } from '../Concurrent';
2
2
  import { Text } from '../../entities/composites/text/Text';
3
3
  import { AnimOptions } from '../AnimOptions';
4
+ import { IndexMap, KeyMap } from './TransformMatchingTex';
4
5
  export interface TransformMatchingOptions extends AnimOptions {
5
6
  morphUnmatched?: boolean;
7
+ /**
8
+ * Explicit index pair mappings [sourceCharIndex, targetCharIndex][].
9
+ * Direct surgical control: forces char at sourceCharIndex to map to targetCharIndex.
10
+ * Takes highest precedence before key/anchor matching.
11
+ * @example [[0, 3]] or { 0: 3 }
12
+ */
13
+ indexMap?: IndexMap;
14
+ /**
15
+ * Explicit substring or character translation map.
16
+ * Maps source substring/character to target substring/character.
17
+ * @example { "apple": "orange", "A": "B" }
18
+ */
19
+ keyMap?: KeyMap;
6
20
  }
7
21
  export declare class TransformMatchingText extends Concurrent {
8
22
  /**
@@ -5,6 +5,7 @@ import { Vec3 } from '../../../math/vector/Vec3';
5
5
  import { VGroup } from '../../layout/VGroup';
6
6
  import { Path } from '../../primitives/2d/Path';
7
7
  import { PathEffect } from '../../../material/PathEffect';
8
+ import { Arrow, ArrowTipType } from '../geometry/Arrow';
8
9
  /**
9
10
  * Configuration options for the [[Axes]] 2D coordinate system.
10
11
  */
@@ -39,6 +40,16 @@ export interface AxesOptions extends CoordinateSystemOptions {
39
40
  yLabelFormatter?: AxisLabelFormatter;
40
41
  /** Custom formatter callback for 2D coordinate pairs. */
41
42
  labelFormatter?: CoordinateLabelFormatter;
43
+ /** Tip style for the main axis arrows ('stealth' | 'triangle' | 'line' | etc.). Default: 'stealth' */
44
+ tipType?: ArrowTipType;
45
+ /** Physical length of arrowhead along the axis. */
46
+ arrowHeadLength?: number;
47
+ /** Physical total width of arrowhead transverse to the axis. */
48
+ arrowHeadWidth?: number;
49
+ /** Whether to render arrowheads on main axes. Default: true */
50
+ showArrows?: boolean;
51
+ /** Alias for showArrows. Default: true */
52
+ includeArrows?: boolean;
42
53
  }
43
54
  export declare class Axes extends CoordinateSystem {
44
55
  axesGroup: VGroup;
@@ -53,6 +64,14 @@ export declare class Axes extends CoordinateSystem {
53
64
  xLabelFormatter?: AxisLabelFormatter;
54
65
  yLabelFormatter?: AxisLabelFormatter;
55
66
  labelFormatter?: CoordinateLabelFormatter;
67
+ tipType: ArrowTipType;
68
+ arrowHeadLength?: number;
69
+ arrowHeadWidth?: number;
70
+ showArrows: boolean;
71
+ xAxis: Arrow;
72
+ yAxis: Arrow;
73
+ get xAxisArrow(): Arrow;
74
+ get yAxisArrow(): Arrow;
56
75
  rangeVersion: number;
57
76
  private linePool;
58
77
  private activeLineCount;
@@ -83,6 +102,7 @@ export declare class Axes extends CoordinateSystem {
83
102
  * Adds numerical coordinate labels along the X and Y axes.
84
103
  */
85
104
  addCoordinates(options?: CoordinateLabelOptions): this;
105
+ setTipType(type: ArrowTipType): this;
86
106
  toPaths(): Path[];
87
107
  getSubEntities(): VectorEntity[];
88
108
  }
@@ -3,6 +3,10 @@ import { VectorEntity } from '../../../_core/VectorEntity';
3
3
  import { Path } from '../../primitives/2d/Path';
4
4
  import { Vec3, Vec3Type } from '../../../math/vector/Vec3';
5
5
  import { Color } from '../../../math/Color';
6
+ import { Animation } from '../../../animation/Animation';
7
+ import { CreateOptions } from '../../../animation/creation/Create';
8
+ import { TrackBuilder } from '../../../animation/TrackBuilder';
9
+ import { PathEffect } from '../../../material/PathEffect';
6
10
  export type ArrowTipType = 'triangle' | 'stealth' | 'line' | 'circle' | 'dot' | 'diamond' | 'bar' | 'tee' | 'square' | 'none';
7
11
  export interface ArrowOptions extends EntityOptions {
8
12
  points?: Vec3Type[];
@@ -10,6 +14,7 @@ export interface ArrowOptions extends EntityOptions {
10
14
  tension?: number;
11
15
  segments?: number;
12
16
  color?: Color;
17
+ strokeShader?: PathEffect | string;
13
18
  headLength?: number;
14
19
  headWidth?: number;
15
20
  headAngle?: number;
@@ -76,6 +81,7 @@ export declare class Arrow extends VectorEntity {
76
81
  private lastT2;
77
82
  private lastT1;
78
83
  private lastStrokeWidth;
84
+ private lastOpacity;
79
85
  constructor(start?: Vec3Type, end?: Vec3Type, options?: ArrowOptions);
80
86
  setPoints(points: Vec3Type[]): void;
81
87
  putStartAndEndOn(start: Vec3Type, end: Vec3Type): void;
@@ -90,6 +96,7 @@ export declare class Arrow extends VectorEntity {
90
96
  width?: number;
91
97
  color?: Color;
92
98
  }): void;
99
+ setStrokeShader(shader?: PathEffect | string): void;
93
100
  private addLineSegment;
94
101
  private rebuildCurve;
95
102
  private buildTipGeometry;
@@ -98,6 +105,14 @@ export declare class Arrow extends VectorEntity {
98
105
  private rebuildSingleHead;
99
106
  update(t: number, dt: number): void;
100
107
  private syncArrowState;
108
+ /**
109
+ * Creation animation hook for TrackBuilder and `Create(arrow)` / `createAnim(arrow)`.
110
+ */
111
+ createAnim(t?: TrackBuilder, options?: CreateOptions): Animation;
112
+ /**
113
+ * Erase/uncreate animation hook for `Uncreate(arrow)`.
114
+ */
115
+ uncreateAnim(options?: CreateOptions): Animation;
101
116
  /**
102
117
  * Resolves the distinct animatable path structures inside the Arrow (the shaft and the tip(s)).
103
118
  */
@@ -107,3 +122,23 @@ export declare class Arrow extends VectorEntity {
107
122
  */
108
123
  toPaths(): Path[];
109
124
  }
125
+ export declare class ArrowCreateAnimation extends Animation {
126
+ private arrow;
127
+ private targetT1;
128
+ private targetT2;
129
+ private originalStroke;
130
+ private originalStrokeWidth;
131
+ private targetStroke;
132
+ private targetStrokeWidth;
133
+ constructor(arrow: Arrow, options?: CreateOptions);
134
+ prepare(): void;
135
+ update(dt: number): boolean;
136
+ }
137
+ export declare class ArrowUncreateAnimation extends Animation {
138
+ private arrow;
139
+ private startT1;
140
+ private startT2;
141
+ constructor(arrow: Arrow, options?: CreateOptions);
142
+ prepare(): void;
143
+ update(dt: number): boolean;
144
+ }
@@ -5,6 +5,9 @@ import { Vec3Type } from '../../../math/vector/Vec3';
5
5
  import { Color } from '../../../math/Color';
6
6
  import { VectorEntity } from '../../../_core/VectorEntity';
7
7
  import { Path } from '../../primitives/2d/Path';
8
+ import { Animation } from '../../../animation/Animation';
9
+ import { CreateOptions } from '../../../animation/creation/Create';
10
+ import { TrackBuilder } from '../../../animation/TrackBuilder';
8
11
  export interface Arrow3DOptions extends EntityOptions {
9
12
  points?: Vec3Type[];
10
13
  isSmooth?: boolean;
@@ -29,6 +32,34 @@ export declare class Arrow3D extends VectorEntity {
29
32
  private rebuildCurve;
30
33
  update(t: number, dt: number): void;
31
34
  private syncArrowState;
35
+ /**
36
+ * Creation animation hook for TrackBuilder and `Create(arrow3D)` / `createAnim(arrow3D)`.
37
+ */
38
+ createAnim(t?: TrackBuilder, options?: CreateOptions): Animation;
39
+ /**
40
+ * Erase/uncreate animation hook for `Uncreate(arrow3D)`.
41
+ */
42
+ uncreateAnim(options?: CreateOptions): Animation;
32
43
  getSubEntities(): VectorEntity[];
33
44
  toPaths(): Path[];
34
45
  }
46
+ export declare class Arrow3DCreateAnimation extends Animation {
47
+ private arrow;
48
+ private targetT1;
49
+ private targetT2;
50
+ private originalStroke;
51
+ private originalStrokeWidth;
52
+ private targetStroke;
53
+ private targetStrokeWidth;
54
+ constructor(arrow: Arrow3D, options?: CreateOptions);
55
+ prepare(): void;
56
+ update(dt: number): boolean;
57
+ }
58
+ export declare class Arrow3DUncreateAnimation extends Animation {
59
+ private arrow;
60
+ private startT1;
61
+ private startT2;
62
+ constructor(arrow: Arrow3D, options?: CreateOptions);
63
+ prepare(): void;
64
+ update(dt: number): boolean;
65
+ }
@@ -0,0 +1,44 @@
1
+ import { VectorEntity } from '../_core/VectorEntity';
2
+ import { VGroup } from '../entities/layout/VGroup';
3
+ import { Color } from '../math/Color';
4
+ import { Vec3 } from '../math/vector/Vec3';
5
+ export interface IndexInfo {
6
+ index: number;
7
+ symbol?: string;
8
+ label: string;
9
+ center: Vec3;
10
+ bounds: Vec3;
11
+ }
12
+ export interface ShowIndicesOptions {
13
+ /** Font size of the numeric badge labels. Default: 9 */
14
+ fontSize?: number;
15
+ /** Foreground text color. Default: Color.fromHex("#facc15") (amber/yellow) */
16
+ color?: Color;
17
+ /** Overall badge opacity (0 = transparent, 1 = opaque). Default: 0.75 */
18
+ opacity?: number;
19
+ /** Whether to draw a circular badge backdrop behind each number. Default: true */
20
+ background?: boolean;
21
+ /** Badge background circle fill color. Default: Color.fromHex("#111827aa") (semi-transparent dark) */
22
+ backgroundColor?: Color;
23
+ /** Badge background circle stroke outline color. Default: Color.fromHex("#eab308cc") */
24
+ borderColor?: Color;
25
+ /** Badge circle radius in world units. Default: 7.5 */
26
+ radius?: number;
27
+ }
28
+ /**
29
+ * Inspects all sub-paths of a VectorEntity (Tex, Text, SVG, VGroup, etc.)
30
+ * and logs a formatted table to console.table showing their indices, symbols, centers, and bounds.
31
+ *
32
+ * @param entity The vector entity to inspect.
33
+ * @returns Array of metadata objects for each child path.
34
+ */
35
+ export declare function inspectIndices(entity: VectorEntity): IndexInfo[];
36
+ /**
37
+ * Generates an overlaid VGroup of numbered circular badges corresponding to each sub-path index.
38
+ * Useful during scene development to visually identify path indices directly on the canvas.
39
+ *
40
+ * @param entity The vector entity whose sub-path indices to show.
41
+ * @param options Styling options for the index badges.
42
+ * @returns A VGroup containing the visual badges.
43
+ */
44
+ export declare function showIndices(entity: VectorEntity, options?: ShowIndicesOptions): VGroup;
@@ -18,6 +18,16 @@ export declare class PathEqualizer {
18
18
  private static padPaths;
19
19
  private static matchPathsSpatially;
20
20
  private static getCentroid;
21
+ /**
22
+ * Solves minimum-weight bipartite matching.
23
+ * Uses exact permutation search for small N <= 8, or greedy fallback for larger.
24
+ */
25
+ private static solveBipartite;
26
+ /**
27
+ * Hierarchical contour classification and matching.
28
+ * Outer boundaries strictly match Outer boundaries; Holes strictly match Holes.
29
+ * Matching is evaluated in normalized relative space to eliminate translation distortion.
30
+ */
21
31
  private static equalizePathContours;
22
32
  private static padContours;
23
33
  private static getControidOfContour;
@@ -26,6 +36,11 @@ export declare class PathEqualizer {
26
36
  private static getSignedArea;
27
37
  private static reverseContour;
28
38
  private static shiftClosedPath;
39
+ /**
40
+ * Determines optimal cyclic shift for closed contours.
41
+ * Evaluates alignment in zero-centered local coordinates to prevent translation distance
42
+ * from skewing the cyclic dot product.
43
+ */
29
44
  private static findOptimalShift;
30
45
  /**
31
46
  * O(N) Single-Pass Subdivision.
@@ -423,6 +423,7 @@ export * from './engine/utils/Builder';
423
423
  export * from './engine/utils/Builder3D';
424
424
  export * from './engine/utils/CurveSampleUtils';
425
425
  export * from './engine/utils/CurveUtil';
426
+ export * from './engine/utils/IndexInspector';
426
427
  export * from './engine/utils/GeometrySnapshot';
427
428
  export * from './engine/utils/MarchingSquares';
428
429
  export * from './engine/utils/OBJLoader';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "retiam",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "WebGPU powered animation engine",
5
5
  "type": "module",
6
6
  "main": "./dist/retiam.es.js",