@sepveneto/dao 0.0.5 → 0.1.1
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 +58 -0
- package/dist/Loader.d.ts +3 -3
- package/dist/ResourceManager.d.ts +8 -2
- package/dist/app/Application.d.ts +18 -0
- package/dist/app/ResizePlugin.d.ts +16 -0
- package/dist/app/__tests__/Application.test.d.ts +1 -0
- package/dist/app/index.d.ts +1 -0
- package/dist/assets/Assets.d.ts +1 -0
- package/dist/dao.cjs +2 -2
- package/dist/dao.cjs.map +1 -0
- package/dist/dao.js +2203 -429
- package/dist/dao.js.map +1 -0
- package/dist/events/FederatedEvent.d.ts +15 -0
- package/dist/events/FederatedEventMap.d.ts +13 -0
- package/dist/events/__tests__/EventSystem.test.d.ts +1 -0
- package/dist/main.d.ts +8 -28
- package/dist/maths/Bounds.d.ts +31 -0
- package/dist/maths/Matrix.d.ts +85 -0
- package/dist/maths/Point.d.ts +17 -0
- package/dist/maths/const.d.ts +14 -0
- package/dist/maths/index.d.ts +18 -0
- package/dist/maths/shapes/Polygon.d.ts +10 -0
- package/dist/maths/shapes/Rectangle.d.ts +11 -0
- package/dist/renderer/CanvasPool.d.ts +11 -0
- package/dist/renderer/InstructionSet.d.ts +18 -0
- package/dist/renderer/index.d.ts +66 -0
- package/dist/renderer/texture/RenderTexture.d.ts +7 -0
- package/dist/renderer/texture/Texture.d.ts +25 -0
- package/dist/renderer/texture/TextureSource.d.ts +50 -0
- package/dist/scene/ViewContainer.d.ts +24 -0
- package/dist/scene/batcher/Batcher.d.ts +10 -0
- package/dist/scene/batcher/BatcherPipe.d.ts +34 -0
- package/dist/scene/batcher/index.d.ts +2 -0
- package/dist/scene/container/Container.d.ts +200 -0
- package/dist/scene/container/RenderGroup.d.ts +31 -0
- package/dist/scene/container/__tests__/Container.Sort.test.d.ts +1 -0
- package/dist/scene/container/__tests__/RenderGroup.test.d.ts +1 -0
- package/dist/scene/container/__tests__/transform-visibility.test.d.ts +1 -0
- package/dist/scene/container/__tests__/transform.test.d.ts +1 -0
- package/dist/scene/container/destroyTypes.d.ts +9 -0
- package/dist/scene/container/mixins/childrenHelperMixin.d.ts +5 -0
- package/dist/scene/container/mixins/effectMixin.d.ts +16 -0
- package/dist/scene/container/mixins/measureMixin.d.ts +14 -0
- package/dist/scene/container/mixins/sortMixin.d.ts +13 -0
- package/dist/scene/container/utils/updateRenderGroupTransform.d.ts +4 -0
- package/dist/scene/container/utils/validateRenderables.d.ts +2 -0
- package/dist/scene/container/utils.d.ts +2 -0
- package/dist/scene/graphics/Graphics.d.ts +19 -0
- package/dist/scene/graphics/GraphicsContext.d.ts +61 -0
- package/dist/scene/graphics/GraphicsPipe.d.ts +15 -0
- package/dist/scene/graphics/index.d.ts +3 -0
- package/dist/scene/graphics/path/GraphicsPath.d.ts +25 -0
- package/dist/scene/graphics/path/ShapePath.d.ts +27 -0
- package/dist/scene/graphics/path/buildAdaptiveBezier.d.ts +14 -0
- package/dist/scene/index.d.ts +6 -0
- package/dist/scene/mask/StencilMask.d.ts +14 -0
- package/dist/scene/mask/StencilMaskPipe.d.ts +16 -0
- package/dist/scene/sprite/Sprite.d.ts +22 -0
- package/dist/scene/sprite/SpritePipe.d.ts +12 -0
- package/dist/scene/sprite/index.d.ts +2 -0
- package/dist/scene/text/Text.d.ts +40 -0
- package/dist/scene/text/TextPipe.d.ts +25 -0
- package/dist/scene/text/TextStyle.d.ts +632 -0
- package/dist/scene/text/TextSystem.d.ts +19 -0
- package/dist/scene/text/__tests__/Text.test.d.ts +1 -0
- package/dist/scene/text/index.d.ts +2 -0
- package/dist/scene/text/utils.d.ts +74 -0
- package/dist/system/CanvasContextSystem.d.ts +15 -0
- package/dist/system/EventSystem.d.ts +49 -5
- package/dist/system/ExtractSystem.d.ts +18 -0
- package/dist/system/RenderGroupSystem.d.ts +16 -0
- package/dist/system/ViewSystem.d.ts +22 -0
- package/dist/system/index.d.ts +2 -0
- package/dist/ticker/Ticker.d.ts +290 -0
- package/dist/ticker/TickerListener.d.ts +21 -0
- package/dist/ticker/index.d.ts +2 -0
- package/dist/utils/index.d.ts +12 -0
- package/dist/utils/type.d.ts +16 -0
- package/dist/utils/uid.d.ts +19 -0
- package/package.json +19 -3
- package/dist/Camera.d.ts +0 -46
- package/dist/Container.d.ts +0 -17
- package/dist/Display.d.ts +0 -60
- package/dist/Factory.d.ts +0 -7
- package/dist/GameObject.d.ts +0 -17
- package/dist/Projection.d.ts +0 -25
- package/dist/Renderer.d.ts +0 -6
- package/dist/Scene.d.ts +0 -27
- package/dist/SortStragety.d.ts +0 -10
- package/dist/World.d.ts +0 -7
- package/dist/system/InputSystem.d.ts +0 -37
- package/dist/system/SortSystem.d.ts +0 -8
- package/dist/system/TweenManager.d.ts +0 -49
- package/dist/utils.d.ts +0 -5
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { CanvasAndContext } from '../../renderer/CanvasPool';
|
|
2
|
+
import { TextStyle } from './TextStyle';
|
|
3
|
+
import { Rectangle } from '../../maths/shapes/Rectangle';
|
|
4
|
+
export declare const NEWLINE_MATCH_REGEX: RegExp;
|
|
5
|
+
/**
|
|
6
|
+
* A number, or a string containing a number.
|
|
7
|
+
* @category text
|
|
8
|
+
* @typedef {object} FontMetrics
|
|
9
|
+
* @property {number} ascent - Font ascent
|
|
10
|
+
* @property {number} descent - Font descent
|
|
11
|
+
* @property {number} fontSize - Font size
|
|
12
|
+
* @advanced
|
|
13
|
+
*/
|
|
14
|
+
export interface FontMetrics {
|
|
15
|
+
ascent: number;
|
|
16
|
+
descent: number;
|
|
17
|
+
fontSize: number;
|
|
18
|
+
}
|
|
19
|
+
export declare class TextMetrics {
|
|
20
|
+
text: string;
|
|
21
|
+
style: TextStyle;
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
lines: string[];
|
|
25
|
+
lineWidths: number[];
|
|
26
|
+
lineHeight: number;
|
|
27
|
+
maxLineWidth: number;
|
|
28
|
+
fontProperties: FontMetrics;
|
|
29
|
+
/**
|
|
30
|
+
* String used for calculate font metrics.
|
|
31
|
+
* These characters are all tall to help calculate the height required for text.
|
|
32
|
+
*/
|
|
33
|
+
static METRICS_STRING: string;
|
|
34
|
+
/** Baseline symbol for calculate font metrics. */
|
|
35
|
+
static BASELINE_SYMBOL: string;
|
|
36
|
+
private static _canvas;
|
|
37
|
+
private static _context;
|
|
38
|
+
private static readonly _measurementCache;
|
|
39
|
+
/** Cache of {@link TextMetrics.FontMetrics} objects. */
|
|
40
|
+
private static _fonts;
|
|
41
|
+
constructor(text: string, style: TextStyle, width: number, height: number, lines: string[], lineWidths: number[], lineHeight: number, maxLineWidth: number, fontProperties: FontMetrics);
|
|
42
|
+
static get canvas(): HTMLCanvasElement | OffscreenCanvas;
|
|
43
|
+
static get context(): CanvasRenderingContext2D;
|
|
44
|
+
static measureText(text: string, style: TextStyle): TextMetrics;
|
|
45
|
+
static _measureText(text: string, letterSpacing: number): number;
|
|
46
|
+
/**
|
|
47
|
+
* A Unicode "character", or "grapheme cluster", can be composed of multiple Unicode code points,
|
|
48
|
+
* such as letters with diacritical marks (e.g. `'\u0065\u0301'`, letter e with acute)
|
|
49
|
+
* or emojis with modifiers (e.g. `'\uD83E\uDDD1\u200D\uD83D\uDCBB'`, technologist).
|
|
50
|
+
* The new `Intl.Segmenter` API in ES2022 can split the string into grapheme clusters correctly. If it is not available,
|
|
51
|
+
* PixiJS will fallback to use the iterator of String, which can only spilt the string into code points.
|
|
52
|
+
* If you want to get full functionality in environments that don't support `Intl.Segmenter` (such as Firefox),
|
|
53
|
+
* you can use other libraries such as [grapheme-splitter]{@link https://www.npmjs.com/package/grapheme-splitter}
|
|
54
|
+
* or [graphemer]{@link https://www.npmjs.com/package/graphemer} to create a polyfill. Since these libraries can be
|
|
55
|
+
* relatively large in size to handle various Unicode grapheme clusters properly, PixiJS won't use them directly.
|
|
56
|
+
*/
|
|
57
|
+
static graphemeSegmenter: (s: string) => string[];
|
|
58
|
+
/**
|
|
59
|
+
* Calculates the ascent, descent and fontSize of a given font-style
|
|
60
|
+
* @param font - String representing the style of the font
|
|
61
|
+
* @returns Font properties object
|
|
62
|
+
*/
|
|
63
|
+
static measureFont(font: string): FontMetrics;
|
|
64
|
+
}
|
|
65
|
+
export declare function createCanvas(width?: number, height?: number): HTMLCanvasElement;
|
|
66
|
+
export declare function generateTextTexture(options: {
|
|
67
|
+
text: string;
|
|
68
|
+
style: TextStyle;
|
|
69
|
+
resolution?: number;
|
|
70
|
+
padding?: number;
|
|
71
|
+
}): {
|
|
72
|
+
canvasAndContext: CanvasAndContext;
|
|
73
|
+
frame: Rectangle;
|
|
74
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Matrix } from '../maths';
|
|
2
|
+
import { CanvasRenderer } from '../renderer';
|
|
3
|
+
export declare class CanvasContextSystem {
|
|
4
|
+
static desc: {
|
|
5
|
+
readonly name: "canvasContext";
|
|
6
|
+
};
|
|
7
|
+
private _renderer;
|
|
8
|
+
rootContext: CanvasRenderingContext2D;
|
|
9
|
+
activeConext: CanvasRenderingContext2D;
|
|
10
|
+
activeResolution: number;
|
|
11
|
+
globalTransform: Matrix;
|
|
12
|
+
constructor(renderer: CanvasRenderer);
|
|
13
|
+
init(): void;
|
|
14
|
+
setContextTransform(transform: Matrix, roundPixels?: boolean, localResolution?: number): void;
|
|
15
|
+
}
|
|
@@ -1,8 +1,52 @@
|
|
|
1
|
-
|
|
1
|
+
import { Container } from '../scene/container/Container';
|
|
2
|
+
import { CanvasRenderer } from '../renderer';
|
|
3
|
+
import { Vector2 } from '../maths';
|
|
4
|
+
import { FederatedEventMap } from '../events/FederatedEventMap';
|
|
5
|
+
import { FederatedEvent } from '../events/FederatedEvent';
|
|
6
|
+
export type EventMode = 'none' | 'static' | 'passive';
|
|
7
|
+
type EmitterListener = {
|
|
8
|
+
fn(...args: any[]): any;
|
|
9
|
+
context: any;
|
|
10
|
+
once: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type EmitterListeners = Record<string, EmitterListener | EmitterListener[]>;
|
|
2
13
|
export declare class EventSystem {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
14
|
+
renderer: CanvasRenderer;
|
|
15
|
+
domElement: HTMLElement;
|
|
16
|
+
rootTarget: Container;
|
|
17
|
+
resolution: number;
|
|
18
|
+
private readonly _allInteractiveElements;
|
|
19
|
+
private _hitElements;
|
|
20
|
+
private _isPointerMoveEvent;
|
|
21
|
+
private mappingState;
|
|
22
|
+
static desc: {
|
|
23
|
+
readonly name: "events";
|
|
24
|
+
};
|
|
25
|
+
constructor(renderer: CanvasRenderer);
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @param id pointerId
|
|
29
|
+
*/
|
|
30
|
+
private trackingData;
|
|
31
|
+
init(): void;
|
|
32
|
+
setTargetElement(element: HTMLElement): void;
|
|
33
|
+
dispatchEvent(e: FederatedEvent, type: keyof FederatedEventMap): void;
|
|
34
|
+
private _notifyTarget;
|
|
35
|
+
propagationPath(target: Container): Container<import('../scene/container/Container').ContainerChild>[];
|
|
36
|
+
_removeEvents(): void;
|
|
37
|
+
_addEvents(): void;
|
|
38
|
+
_onPointerMove(event: PointerEvent): void;
|
|
39
|
+
_onPointerDown(event: PointerEvent): void;
|
|
40
|
+
_onPointerOverOut(event: PointerEvent): void;
|
|
41
|
+
_onPointerUp(event: PointerEvent): void;
|
|
42
|
+
_isInteractive(eventMode: EventMode): eventMode is "static";
|
|
43
|
+
createPointEvent(from: PointerEvent, type?: string, target?: Container): FederatedEvent;
|
|
44
|
+
clonePointEvent(from: FederatedEvent, type?: string): FederatedEvent;
|
|
45
|
+
mapPositionToPoint(x: number, y: number): Vector2;
|
|
46
|
+
hitTest(x: number, y: number): Container<import('../scene/container/Container').ContainerChild>;
|
|
47
|
+
private _interactivePrune;
|
|
48
|
+
hitTestMoveRecursive(currentTarget: Container, eventMode: EventMode, location: Vector2): Container[];
|
|
49
|
+
hitTestRecursive(currentTarget: Container, eventMode: EventMode, location: Vector2): Container[];
|
|
50
|
+
hitTestFn(container: Container, pos: Vector2): boolean;
|
|
7
51
|
}
|
|
8
52
|
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Rectangle } from '../maths';
|
|
2
|
+
import { CanvasRenderer } from '../renderer';
|
|
3
|
+
import { RenderTexture } from '../renderer/texture/RenderTexture';
|
|
4
|
+
import { Container } from '../scene';
|
|
5
|
+
export type GenerateTextureOptions = {
|
|
6
|
+
target: Container;
|
|
7
|
+
frame?: Rectangle;
|
|
8
|
+
resolution?: number;
|
|
9
|
+
};
|
|
10
|
+
export declare class ExtractSystem {
|
|
11
|
+
static desc: {
|
|
12
|
+
readonly name: "extract";
|
|
13
|
+
};
|
|
14
|
+
private _renderer;
|
|
15
|
+
constructor(renderer: CanvasRenderer);
|
|
16
|
+
texture(options: Container): RenderTexture;
|
|
17
|
+
private _generateTexture;
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Matrix } from '../maths';
|
|
2
|
+
import { CanvasRenderer } from '../renderer';
|
|
3
|
+
import { Container, RenderGroup } from '../scene';
|
|
4
|
+
export declare class RenderGroupSystem {
|
|
5
|
+
renderer: CanvasRenderer;
|
|
6
|
+
static desc: {
|
|
7
|
+
readonly name: "renderGroup";
|
|
8
|
+
};
|
|
9
|
+
constructor(renderer: CanvasRenderer);
|
|
10
|
+
private _updateRenderGroup;
|
|
11
|
+
render({ container, transform }: {
|
|
12
|
+
container: Container;
|
|
13
|
+
transform: Matrix;
|
|
14
|
+
}): void;
|
|
15
|
+
_buildInstructions(renderGroup: RenderGroup, renderer: CanvasRenderer): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Rectangle } from '../maths';
|
|
2
|
+
import { Texture } from '../renderer/texture/Texture';
|
|
3
|
+
import { CanvasSource } from '../renderer/texture/TextureSource';
|
|
4
|
+
export type ViewSystemOptions = {
|
|
5
|
+
width?: number;
|
|
6
|
+
height?: number;
|
|
7
|
+
resolution?: number;
|
|
8
|
+
autoDensity?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare class ViewSystem {
|
|
11
|
+
static desc: {
|
|
12
|
+
readonly name: "view";
|
|
13
|
+
};
|
|
14
|
+
static defaultOptions: ViewSystemOptions;
|
|
15
|
+
canvas: HTMLCanvasElement;
|
|
16
|
+
screen: Rectangle;
|
|
17
|
+
texture: Texture<CanvasSource>;
|
|
18
|
+
get resolution(): number;
|
|
19
|
+
set resolution(value: number);
|
|
20
|
+
init(options: ViewSystemOptions): void;
|
|
21
|
+
resize(width: number, height: number, resolution: number): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
export type TickerCallback<T> = (this: T, ticker: Ticker) => any;
|
|
2
|
+
export declare class Ticker {
|
|
3
|
+
/**
|
|
4
|
+
* Target frame rate in frames per millisecond.
|
|
5
|
+
* Used for converting deltaTime to a scalar time delta.
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* // Default is 0.06 (60 FPS)
|
|
9
|
+
* console.log(Ticker.targetFPMS); // 0.06
|
|
10
|
+
*
|
|
11
|
+
* // Calculate target frame duration
|
|
12
|
+
* const frameDuration = 1 / Ticker.targetFPMS; // ≈ 16.67ms
|
|
13
|
+
*
|
|
14
|
+
* // Use in custom timing calculations
|
|
15
|
+
* const deltaTime = elapsedMS * Ticker.targetFPMS;
|
|
16
|
+
* ```
|
|
17
|
+
* @remarks
|
|
18
|
+
* - Default is 0.06 (equivalent to 60 FPS)
|
|
19
|
+
* - Used in deltaTime calculations
|
|
20
|
+
* - Affects all ticker instances
|
|
21
|
+
* @default 0.06
|
|
22
|
+
* @see {@link Ticker#deltaTime} For time scaling
|
|
23
|
+
* @see {@link Ticker#FPS} For actual frame rate
|
|
24
|
+
*/
|
|
25
|
+
static targetFPMS: number;
|
|
26
|
+
/**
|
|
27
|
+
* Whether or not this ticker should invoke the method {@link Ticker#start|start}
|
|
28
|
+
* automatically when a listener is added.
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* // Default behavior (manual start)
|
|
32
|
+
* const ticker = new Ticker();
|
|
33
|
+
* ticker.autoStart = false;
|
|
34
|
+
* ticker.add(() => {
|
|
35
|
+
* // Won't run until ticker.start() is called
|
|
36
|
+
* });
|
|
37
|
+
*
|
|
38
|
+
* // Auto-start behavior
|
|
39
|
+
* const autoTicker = new Ticker();
|
|
40
|
+
* autoTicker.autoStart = true;
|
|
41
|
+
* autoTicker.add(() => {
|
|
42
|
+
* // Runs immediately when added
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
* @default false
|
|
46
|
+
* @see {@link Ticker#start} For manually starting the ticker
|
|
47
|
+
* @see {@link Ticker#stop} For manually stopping the ticker
|
|
48
|
+
*/
|
|
49
|
+
autoStart: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Scalar representing the delta time factor.
|
|
52
|
+
* This is a dimensionless value representing the fraction of a frame at the target framerate.
|
|
53
|
+
* At 60 FPS, this value is typically around 1.0.
|
|
54
|
+
*
|
|
55
|
+
* This is NOT in milliseconds - it's a scalar multiplier for frame-independent animations.
|
|
56
|
+
* For actual milliseconds, use {@link Ticker#deltaMS}.
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* // Frame-independent animation using deltaTime scalar
|
|
60
|
+
* ticker.add((ticker) => {
|
|
61
|
+
* // Rotate sprite by 0.1 radians per frame, scaled by deltaTime
|
|
62
|
+
* sprite.rotation += 0.1 * ticker.deltaTime;
|
|
63
|
+
* });
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
deltaTime: number;
|
|
67
|
+
/**
|
|
68
|
+
* Scalar time elapsed in milliseconds from last frame to this frame.
|
|
69
|
+
* Provides precise timing for animations and updates.
|
|
70
|
+
*
|
|
71
|
+
* This value is capped by setting {@link Ticker#minFPS|minFPS}
|
|
72
|
+
* and is scaled with {@link Ticker#speed|speed}.
|
|
73
|
+
*
|
|
74
|
+
* If the platform supports DOMHighResTimeStamp,
|
|
75
|
+
* this value will have a precision of 1 µs.
|
|
76
|
+
*
|
|
77
|
+
* Defaults to target frame time
|
|
78
|
+
*
|
|
79
|
+
* > [!NOTE] The cap may be exceeded by scaling.
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* // Animation timing
|
|
83
|
+
* ticker.add((ticker) => {
|
|
84
|
+
* // Use millisecond timing for precise animations
|
|
85
|
+
* const progress = (ticker.deltaMS / animationDuration);
|
|
86
|
+
* sprite.alpha = Math.min(1, progress);
|
|
87
|
+
* });
|
|
88
|
+
* ```
|
|
89
|
+
* @default 16.66
|
|
90
|
+
*/
|
|
91
|
+
deltaMS: number;
|
|
92
|
+
/**
|
|
93
|
+
* Time elapsed in milliseconds from the last frame to this frame.
|
|
94
|
+
* This value is not capped or scaled and provides raw timing information.
|
|
95
|
+
*
|
|
96
|
+
* Unlike {@link Ticker#deltaMS}, this value is unmodified by speed scaling or FPS capping.
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* ticker.add((ticker) => {
|
|
100
|
+
* console.log(`Raw frame time: ${ticker.elapsedMS}ms`);
|
|
101
|
+
* });
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
elapsedMS: number;
|
|
105
|
+
/**
|
|
106
|
+
* The last time update was invoked, in milliseconds since epoch.
|
|
107
|
+
* Similar to performance.now() timestamp format.
|
|
108
|
+
*
|
|
109
|
+
* Used internally for calculating time deltas between frames.
|
|
110
|
+
* @example
|
|
111
|
+
* ```ts
|
|
112
|
+
* ticker.add((ticker) => {
|
|
113
|
+
* const currentTime = performance.now();
|
|
114
|
+
* const timeSinceLastFrame = currentTime - ticker.lastTime;
|
|
115
|
+
* console.log(`Time since last frame: ${timeSinceLastFrame}ms`);
|
|
116
|
+
* });
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
lastTime: number;
|
|
120
|
+
/**
|
|
121
|
+
* Factor of current {@link Ticker#deltaTime|deltaTime}.
|
|
122
|
+
* Used to scale time for slow motion or fast-forward effects.
|
|
123
|
+
* @example
|
|
124
|
+
* ```ts
|
|
125
|
+
* // Basic speed adjustment
|
|
126
|
+
* ticker.speed = 0.5; // Half speed (slow motion)
|
|
127
|
+
* ticker.speed = 2.0; // Double speed (fast forward)
|
|
128
|
+
*
|
|
129
|
+
* // Temporary speed changes
|
|
130
|
+
* function slowMotion() {
|
|
131
|
+
* const normalSpeed = ticker.speed;
|
|
132
|
+
* ticker.speed = 0.2;
|
|
133
|
+
* setTimeout(() => {
|
|
134
|
+
* ticker.speed = normalSpeed;
|
|
135
|
+
* }, 1000);
|
|
136
|
+
* }
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
speed: number;
|
|
140
|
+
/**
|
|
141
|
+
* Whether or not this ticker has been started.
|
|
142
|
+
*
|
|
143
|
+
* `true` if {@link Ticker#start|start} has been called.
|
|
144
|
+
* `false` if {@link Ticker#stop|Stop} has been called.
|
|
145
|
+
*
|
|
146
|
+
* While `false`, this value may change to `true` in the
|
|
147
|
+
* event of {@link Ticker#autoStart|autoStart} being `true`
|
|
148
|
+
* and a listener is added.
|
|
149
|
+
* @example
|
|
150
|
+
* ```ts
|
|
151
|
+
* // Check ticker state
|
|
152
|
+
* const ticker = new Ticker();
|
|
153
|
+
* console.log(ticker.started); // false
|
|
154
|
+
*
|
|
155
|
+
* // Start and verify
|
|
156
|
+
* ticker.start();
|
|
157
|
+
* console.log(ticker.started); // true
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
started: boolean;
|
|
161
|
+
/**
|
|
162
|
+
* Internal tick method bound to ticker instance.
|
|
163
|
+
* This is because in early 2015, Function.bind
|
|
164
|
+
* is still 60% slower in high performance scenarios.
|
|
165
|
+
* Also separating frame requests from update method
|
|
166
|
+
* so listeners may be called at any time and with
|
|
167
|
+
* any animation API, just invoke ticker.update(time).
|
|
168
|
+
* @param time - Time since last tick.
|
|
169
|
+
*/
|
|
170
|
+
private readonly _tick;
|
|
171
|
+
/** Internal current frame request ID */
|
|
172
|
+
private _requestId;
|
|
173
|
+
/**
|
|
174
|
+
* Internal value managed by minFPS property setter and getter.
|
|
175
|
+
* This is the maximum allowed milliseconds between updates.
|
|
176
|
+
*/
|
|
177
|
+
private _maxElapsedMS;
|
|
178
|
+
/**
|
|
179
|
+
* Internal value managed by maxFPS property setter and getter.
|
|
180
|
+
* This is the minimum allowed milliseconds between updates.
|
|
181
|
+
*/
|
|
182
|
+
private _minElapsedMS;
|
|
183
|
+
/** The last time keyframe was executed. Maintains a relatively fixed interval with the previous value. */
|
|
184
|
+
private _lastFrame;
|
|
185
|
+
private _head;
|
|
186
|
+
constructor();
|
|
187
|
+
/**
|
|
188
|
+
* Triggers an update.
|
|
189
|
+
*
|
|
190
|
+
* An update entails setting the
|
|
191
|
+
* current {@link Ticker#elapsedMS|elapsedMS},
|
|
192
|
+
* the current {@link Ticker#deltaTime|deltaTime},
|
|
193
|
+
* invoking all listeners with current deltaTime,
|
|
194
|
+
* and then finally setting {@link Ticker#lastTime|lastTime}
|
|
195
|
+
* with the value of currentTime that was provided.
|
|
196
|
+
*
|
|
197
|
+
* This method will be called automatically by animation
|
|
198
|
+
* frame callbacks if the ticker instance has been started
|
|
199
|
+
* and listeners are added.
|
|
200
|
+
* @example
|
|
201
|
+
* ```ts
|
|
202
|
+
* // Basic manual update
|
|
203
|
+
* const ticker = new Ticker();
|
|
204
|
+
* ticker.update(performance.now());
|
|
205
|
+
* ```
|
|
206
|
+
* @param currentTime - The current time of execution (defaults to performance.now())
|
|
207
|
+
* @see {@link Ticker#deltaTime} For frame delta value
|
|
208
|
+
* @see {@link Ticker#elapsedMS} For raw elapsed time
|
|
209
|
+
*/
|
|
210
|
+
update(currentTime?: number): void;
|
|
211
|
+
/**
|
|
212
|
+
* The frames per second at which this ticker is running.
|
|
213
|
+
* The default is approximately 60 in most modern browsers.
|
|
214
|
+
* > [!NOTE] This does not factor in the value of
|
|
215
|
+
* > {@link Ticker#speed|speed}, which is specific
|
|
216
|
+
* > to scaling {@link Ticker#deltaTime|deltaTime}.
|
|
217
|
+
* @example
|
|
218
|
+
* ```ts
|
|
219
|
+
* // Basic FPS monitoring
|
|
220
|
+
* ticker.add(() => {
|
|
221
|
+
* console.log(`Current FPS: ${Math.round(ticker.FPS)}`);
|
|
222
|
+
* });
|
|
223
|
+
* ```
|
|
224
|
+
* @readonly
|
|
225
|
+
*/
|
|
226
|
+
get FPS(): number;
|
|
227
|
+
/**
|
|
228
|
+
* Manages the minimum amount of milliseconds required to
|
|
229
|
+
* elapse between invoking {@link Ticker#update|update}.
|
|
230
|
+
*
|
|
231
|
+
* This will effect the measured value of {@link Ticker#FPS|FPS}.
|
|
232
|
+
*
|
|
233
|
+
* If it is set to `0`, then there is no limit; PixiJS will render as many frames as it can.
|
|
234
|
+
* Otherwise it will be at least `minFPS`.
|
|
235
|
+
*
|
|
236
|
+
* If `maxFPS` is set below the current `minFPS`, `minFPS` is automatically lowered to match.
|
|
237
|
+
* This keeps the two limits consistent.
|
|
238
|
+
* @example
|
|
239
|
+
* ```ts
|
|
240
|
+
* // Cap the frame rate
|
|
241
|
+
* const ticker = new Ticker();
|
|
242
|
+
* ticker.maxFPS = 60; // Never go above 60 FPS
|
|
243
|
+
*
|
|
244
|
+
* // Use with minFPS for frame rate clamping
|
|
245
|
+
* ticker.minFPS = 30;
|
|
246
|
+
* ticker.maxFPS = 60;
|
|
247
|
+
*
|
|
248
|
+
* // maxFPS below minFPS pushes minFPS down
|
|
249
|
+
* ticker.maxFPS = 20; // minFPS is now also 20
|
|
250
|
+
* ```
|
|
251
|
+
* @default 0
|
|
252
|
+
*/
|
|
253
|
+
get maxFPS(): number;
|
|
254
|
+
set maxFPS(value: number);
|
|
255
|
+
/**
|
|
256
|
+
* Manages the maximum amount of milliseconds allowed to
|
|
257
|
+
* elapse between invoking {@link Ticker#update|update}.
|
|
258
|
+
*
|
|
259
|
+
* This value is used to cap {@link Ticker#deltaTime|deltaTime},
|
|
260
|
+
* but does not effect the measured value of {@link Ticker#FPS|FPS}.
|
|
261
|
+
*
|
|
262
|
+
* When setting this property it is clamped to a value between
|
|
263
|
+
* `0` and `Ticker.targetFPMS * 1000` (typically 60).
|
|
264
|
+
*
|
|
265
|
+
* If `maxFPS` is currently set (non-zero) and `minFPS` is set above it,
|
|
266
|
+
* `maxFPS` is automatically raised to match. This keeps the two limits consistent.
|
|
267
|
+
* @example
|
|
268
|
+
* ```ts
|
|
269
|
+
* // Set minimum acceptable frame rate
|
|
270
|
+
* const ticker = new Ticker();
|
|
271
|
+
* ticker.minFPS = 30; // Never go below 30 FPS
|
|
272
|
+
*
|
|
273
|
+
* // Use with maxFPS for frame rate clamping
|
|
274
|
+
* ticker.minFPS = 30;
|
|
275
|
+
* ticker.maxFPS = 60;
|
|
276
|
+
*
|
|
277
|
+
* // minFPS above maxFPS pushes maxFPS up
|
|
278
|
+
* ticker.minFPS = 50; // maxFPS is raised to 50
|
|
279
|
+
* ```
|
|
280
|
+
* @default 10
|
|
281
|
+
*/
|
|
282
|
+
get minFPS(): number;
|
|
283
|
+
set minFPS(value: number);
|
|
284
|
+
add<T = any>(fn: TickerCallback<T>, context?: T, priority?: number): this;
|
|
285
|
+
start(): void;
|
|
286
|
+
remove<T>(fn: TickerCallback<T>, context?: T): this;
|
|
287
|
+
private _startIfPossible;
|
|
288
|
+
private _requestIfNeeded;
|
|
289
|
+
private _cancelIfNeeded;
|
|
290
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Ticker, TickerCallback } from './Ticker';
|
|
2
|
+
export declare class TickerListener<T = any> {
|
|
3
|
+
next: TickerListener;
|
|
4
|
+
previous: TickerListener;
|
|
5
|
+
priority: number;
|
|
6
|
+
private _fn;
|
|
7
|
+
private _context;
|
|
8
|
+
private _once;
|
|
9
|
+
private _destroyed;
|
|
10
|
+
constructor(fn: TickerCallback<T>, context: T, priority?: number, once?: boolean);
|
|
11
|
+
match(fn: TickerCallback<T>, context?: any): boolean;
|
|
12
|
+
emit(ticker: Ticker): TickerListener<any>;
|
|
13
|
+
/**
|
|
14
|
+
* Destroy and don't use after this.
|
|
15
|
+
* @param hard - `true` to remove the `next` reference, this
|
|
16
|
+
* is considered a hard destroy. Soft destroy maintains the next reference.
|
|
17
|
+
* @returns The listener to redirect while emitting or removing.
|
|
18
|
+
*/
|
|
19
|
+
destroy(hard?: boolean): TickerListener<any>;
|
|
20
|
+
connect(previous: TickerListener): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Bounds } from '../maths/Bounds';
|
|
2
|
+
import { ObservablePoint } from '../maths/Point';
|
|
3
|
+
import { Texture } from '../renderer/texture/Texture';
|
|
4
|
+
export * from './uid';
|
|
5
|
+
export declare function loadImage(url: string): Promise<{
|
|
6
|
+
image: HTMLImageElement;
|
|
7
|
+
w: number;
|
|
8
|
+
h: number;
|
|
9
|
+
}>;
|
|
10
|
+
export declare function createDebug(ns: string): (...args: any[]) => void;
|
|
11
|
+
export declare function updateBounds(bounds: Bounds, anchor: ObservablePoint, texture: Texture): void;
|
|
12
|
+
export declare function applyMixins(base: any, ...mixins: Parameters<typeof Object.getOwnPropertyDescriptors>[0][]): void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
interface System {
|
|
2
|
+
desc: {
|
|
3
|
+
name: string;
|
|
4
|
+
};
|
|
5
|
+
defaultOptions?: any;
|
|
6
|
+
new (...args: any): any;
|
|
7
|
+
}
|
|
8
|
+
type NameType<T extends System[]> = T[number]['desc']['name'];
|
|
9
|
+
export type ExtractSystemTypes<T extends System[]> = {
|
|
10
|
+
[K in NameType<T>]: InstanceType<Extract<T[number], {
|
|
11
|
+
desc: {
|
|
12
|
+
name: K;
|
|
13
|
+
};
|
|
14
|
+
}>>;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The names of the unique identifiers. These are used to create unique identifiers for different types of objects.
|
|
3
|
+
* @category utils
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export type UIDNames = 'default' | 'resource' | 'texture' | 'textureSource' | 'textureResource' | 'batcher' | 'graphicsContext' | 'graphicsView' | 'graphicsPath' | 'fillGradient' | 'fillPattern' | 'meshView' | 'renderable' | 'buffer' | 'bufferResource' | 'geometry' | 'instructionSet' | 'renderTarget' | 'uniform' | 'spriteView' | 'textView' | 'tilingSpriteView' | 'shader' | 'renderer' | 'textStyle' | (string & {});
|
|
7
|
+
/**
|
|
8
|
+
* Gets the next unique identifier
|
|
9
|
+
* @param name - The name of the identifier.
|
|
10
|
+
* @returns {number} The next unique identifier to use.
|
|
11
|
+
* @category utils
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export declare function uid(name?: UIDNames): number;
|
|
15
|
+
/**
|
|
16
|
+
* Resets the next unique identifier to 0. This is used for some tests, dont touch or things WILL explode :)
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export declare function resetUids(): void;
|
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sepveneto/dao",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
|
+
"docs:dev": "vitepress dev docs",
|
|
6
7
|
"dev": "vite",
|
|
7
8
|
"build": "vite build",
|
|
8
9
|
"release": "bumpp",
|
|
9
|
-
"preview": "vite preview"
|
|
10
|
+
"preview": "vite preview",
|
|
11
|
+
"test": "vitest"
|
|
10
12
|
},
|
|
11
13
|
"files": [
|
|
12
14
|
"dist"
|
|
@@ -22,19 +24,33 @@
|
|
|
22
24
|
}
|
|
23
25
|
},
|
|
24
26
|
"devDependencies": {
|
|
27
|
+
"@test/utils": "workspace: *",
|
|
25
28
|
"@types/node": "^24.10.1",
|
|
29
|
+
"@types/stats.js": "^0.17.4",
|
|
26
30
|
"@vitejs/plugin-vue": "^6.0.1",
|
|
27
31
|
"@vue/tsconfig": "^0.8.1",
|
|
28
32
|
"bumpp": "^10.3.2",
|
|
33
|
+
"canvas": "3.2.3",
|
|
34
|
+
"jsdom": "^29.1.1",
|
|
35
|
+
"stats.js": "^0.17.0",
|
|
29
36
|
"typescript": "~5.9.3",
|
|
30
37
|
"vite": "npm:rolldown-vite@7.2.5",
|
|
31
38
|
"vite-plugin-dts": "^4.5.4",
|
|
39
|
+
"vitepress": "2.0.0-alpha.17",
|
|
40
|
+
"vitest": "^4.1.6",
|
|
32
41
|
"vue": "^3.5.24",
|
|
33
42
|
"vue-tsc": "^3.1.4"
|
|
34
43
|
},
|
|
35
44
|
"pnpm": {
|
|
36
45
|
"overrides": {
|
|
37
46
|
"vite": "npm:rolldown-vite@7.2.5"
|
|
38
|
-
}
|
|
47
|
+
},
|
|
48
|
+
"onlyBuiltDependencies": [
|
|
49
|
+
"canvas"
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@tweenjs/tween.js": "^25.0.0",
|
|
54
|
+
"eventemitter3": "^5.0.4"
|
|
39
55
|
}
|
|
40
56
|
}
|
package/dist/Camera.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { GameObject } from './GameObject';
|
|
2
|
-
import { Projection } from './Projection';
|
|
3
|
-
import { InputSystem } from './system/InputSystem';
|
|
4
|
-
export declare class Camera {
|
|
5
|
-
viewport: {
|
|
6
|
-
x: number;
|
|
7
|
-
y: number;
|
|
8
|
-
width: number;
|
|
9
|
-
height: number;
|
|
10
|
-
};
|
|
11
|
-
x: number;
|
|
12
|
-
y: number;
|
|
13
|
-
zoom: number;
|
|
14
|
-
projection: Projection;
|
|
15
|
-
private _followTarget?;
|
|
16
|
-
private _followLerp;
|
|
17
|
-
private _offsetX;
|
|
18
|
-
private _offsetY;
|
|
19
|
-
private originX;
|
|
20
|
-
private originY;
|
|
21
|
-
get width(): number;
|
|
22
|
-
get height(): number;
|
|
23
|
-
constructor(proj: Projection);
|
|
24
|
-
setOrigin(x: number, y: number): void;
|
|
25
|
-
setViewport(x: number, y: number, width: number, height: number): void;
|
|
26
|
-
apply(ctx: CanvasRenderingContext2D): void;
|
|
27
|
-
restore(ctx: CanvasRenderingContext2D): void;
|
|
28
|
-
project(worldX: number, worldY: number, worldZ?: number): {
|
|
29
|
-
px: number;
|
|
30
|
-
py: number;
|
|
31
|
-
};
|
|
32
|
-
follow(target: GameObject, options?: {
|
|
33
|
-
lerp?: number;
|
|
34
|
-
offsetX?: number;
|
|
35
|
-
offsetY?: number;
|
|
36
|
-
}): void;
|
|
37
|
-
stopFollow(): void;
|
|
38
|
-
update(): void;
|
|
39
|
-
}
|
|
40
|
-
export declare class CameraController {
|
|
41
|
-
private camera;
|
|
42
|
-
private input;
|
|
43
|
-
speed: number;
|
|
44
|
-
constructor(camera: Camera, input: InputSystem);
|
|
45
|
-
update(delta: number): void;
|
|
46
|
-
}
|