canvasengine 2.0.0-beta.39 → 2.0.0-beta.40
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/dist/{DebugRenderer-Rrw9FlTd.js → DebugRenderer-DgECR3yZ.js} +2 -2
- package/dist/{DebugRenderer-Rrw9FlTd.js.map → DebugRenderer-DgECR3yZ.js.map} +1 -1
- package/dist/components/Canvas.d.ts.map +1 -1
- package/dist/directives/Controls.d.ts +3 -1
- package/dist/directives/Controls.d.ts.map +1 -1
- package/dist/engine/animation.d.ts +19 -5
- package/dist/engine/animation.d.ts.map +1 -1
- package/dist/engine/reactive.d.ts +10 -0
- package/dist/engine/reactive.d.ts.map +1 -1
- package/dist/engine/signal.d.ts.map +1 -1
- package/dist/engine/trigger.d.ts.map +1 -1
- package/dist/{index-BQ99FClW.js → index-gb763Hyx.js} +4460 -4245
- package/dist/index-gb763Hyx.js.map +1 -0
- package/dist/index.global.js +6 -6
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +40 -37
- package/package.json +2 -2
- package/src/components/Canvas.ts +5 -0
- package/src/components/Container.ts +2 -0
- package/src/components/DisplayObject.ts +33 -12
- package/src/components/Sprite.ts +14 -1
- package/src/directives/Controls.ts +45 -7
- package/src/engine/animation.ts +137 -19
- package/src/engine/reactive.ts +123 -3
- package/src/engine/signal.ts +5 -0
- package/src/engine/trigger.ts +19 -2
- package/dist/components/Container.d.ts +0 -84
- package/dist/components/Container.d.ts.map +0 -1
- package/dist/components/DOMContainer.d.ts +0 -81
- package/dist/components/DOMContainer.d.ts.map +0 -1
- package/dist/components/DisplayObject.d.ts +0 -86
- package/dist/components/DisplayObject.d.ts.map +0 -1
- package/dist/components/Mesh.d.ts +0 -206
- package/dist/components/Mesh.d.ts.map +0 -1
- package/dist/components/Sprite.d.ts +0 -240
- package/dist/components/Sprite.d.ts.map +0 -1
- package/dist/components/Viewport.d.ts +0 -110
- package/dist/components/Viewport.d.ts.map +0 -1
- package/dist/index-BQ99FClW.js.map +0 -1
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
import { Geometry, Shader, Texture } from 'pixi.js';
|
|
2
|
-
import { Element } from '../engine/reactive';
|
|
3
|
-
import { ComponentInstance } from './DisplayObject';
|
|
4
|
-
import { DisplayObjectProps } from './types/DisplayObject';
|
|
5
|
-
import { SignalOrPrimitive } from './types';
|
|
6
|
-
import { ComponentFunction } from '../engine/signal';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Interface defining the properties for a Mesh component.
|
|
10
|
-
* Extends DisplayObjectProps to inherit common display object properties.
|
|
11
|
-
*/
|
|
12
|
-
interface MeshProps extends DisplayObjectProps {
|
|
13
|
-
/** The geometry defining the mesh structure (vertices, indices, UVs, etc.) */
|
|
14
|
-
geometry?: Geometry;
|
|
15
|
-
/** The shader to render the mesh with */
|
|
16
|
-
shader?: Shader;
|
|
17
|
-
/** The texture to apply to the mesh */
|
|
18
|
-
texture?: Texture | string;
|
|
19
|
-
/** The image URL to load as texture */
|
|
20
|
-
image?: string;
|
|
21
|
-
/** The tint color to apply to the mesh */
|
|
22
|
-
tint?: SignalOrPrimitive<number>;
|
|
23
|
-
/** Whether to round pixels for sharper rendering */
|
|
24
|
-
roundPixels?: SignalOrPrimitive<boolean>;
|
|
25
|
-
}
|
|
26
|
-
declare const CanvasMesh_base: {
|
|
27
|
-
new (): {
|
|
28
|
-
[x: string]: any;
|
|
29
|
-
"__#1@#canvasContext": {
|
|
30
|
-
[key: string]: any;
|
|
31
|
-
} | null;
|
|
32
|
-
isFlex: boolean;
|
|
33
|
-
fullProps: import('..').Props;
|
|
34
|
-
isMounted: boolean;
|
|
35
|
-
_anchorPoints: import('pixi.js').ObservablePoint;
|
|
36
|
-
isCustomAnchor: boolean;
|
|
37
|
-
displayWidth: import('@signe/reactive').WritableSignal<number>;
|
|
38
|
-
displayHeight: import('@signe/reactive').WritableSignal<number>;
|
|
39
|
-
overrideProps: string[];
|
|
40
|
-
layout: any;
|
|
41
|
-
onBeforeDestroy: import('./DisplayObject').OnHook | null;
|
|
42
|
-
onAfterMount: import('./DisplayObject').OnHook | null;
|
|
43
|
-
subjectInit: import('rxjs').BehaviorSubject<any>;
|
|
44
|
-
disableLayout: boolean;
|
|
45
|
-
"__#1@#registeredEvents": Map<string, Function>;
|
|
46
|
-
"__#1@#computedLayoutBox": {
|
|
47
|
-
width?: number;
|
|
48
|
-
height?: number;
|
|
49
|
-
} | null;
|
|
50
|
-
readonly deltaRatio: any;
|
|
51
|
-
readonly parentIsFlex: any;
|
|
52
|
-
onInit(props: import('..').Props): void;
|
|
53
|
-
onMount({ parent, props }: Element</*elided*/ any>, index?: number): Promise<void>;
|
|
54
|
-
onUpdate(props: import('..').Props): void;
|
|
55
|
-
onDestroy(parent: Element, afterDestroy?: () => void): Promise<void>;
|
|
56
|
-
setFlexDirection(direction: import('./types/DisplayObject').FlexDirection): void;
|
|
57
|
-
setFlexWrap(wrap: "wrap" | "nowrap" | "wrap-reverse"): void;
|
|
58
|
-
setAlignContent(align: import('./types/DisplayObject').AlignContent): void;
|
|
59
|
-
setAlignSelf(align: import('./types/DisplayObject').AlignContent): void;
|
|
60
|
-
setAlignItems(align: import('./types/DisplayObject').AlignContent): void;
|
|
61
|
-
setJustifyContent(justifyContent: "flex-start" | "flex-end" | "center" | "space-between" | "space-around"): void;
|
|
62
|
-
setPosition(position: import('./types/DisplayObject').EdgeSize): void;
|
|
63
|
-
setX(x: number): void;
|
|
64
|
-
setY(y: number): void;
|
|
65
|
-
setPadding(padding: import('./types/DisplayObject').EdgeSize): void;
|
|
66
|
-
setMargin(margin: import('./types/DisplayObject').EdgeSize): void;
|
|
67
|
-
setGap(gap: import('./types/DisplayObject').EdgeSize): void;
|
|
68
|
-
setBorder(border: import('./types/DisplayObject').EdgeSize): void;
|
|
69
|
-
setPositionType(positionType: "relative" | "absolute"): void;
|
|
70
|
-
setWidth(width: number): void;
|
|
71
|
-
setHeight(height: number): void;
|
|
72
|
-
getWidth(): number;
|
|
73
|
-
getHeight(): number;
|
|
74
|
-
setMinWidth(minWidth: number | string): void;
|
|
75
|
-
setMinHeight(minHeight: number | string): void;
|
|
76
|
-
setMaxWidth(maxWidth: number | string): void;
|
|
77
|
-
setMaxHeight(maxHeight: number | string): void;
|
|
78
|
-
setAspectRatio(aspectRatio: number): void;
|
|
79
|
-
setFlexGrow(flexGrow: number): void;
|
|
80
|
-
setFlexShrink(flexShrink: number): void;
|
|
81
|
-
setFlexBasis(flexBasis: number | string): void;
|
|
82
|
-
setRowGap(rowGap: number): void;
|
|
83
|
-
setColumnGap(columnGap: number): void;
|
|
84
|
-
setTop(top: number | string): void;
|
|
85
|
-
setLeft(left: number | string): void;
|
|
86
|
-
setRight(right: number | string): void;
|
|
87
|
-
setBottom(bottom: number | string): void;
|
|
88
|
-
setObjectFit(objectFit: import('./types/DisplayObject').ObjectFit): void;
|
|
89
|
-
setObjectPosition(objectPosition: import('./types/DisplayObject').ObjectPosition): void;
|
|
90
|
-
setTransformOrigin(transformOrigin: import('./types/DisplayObject').TransformOrigin): void;
|
|
91
|
-
};
|
|
92
|
-
[x: string]: any;
|
|
93
|
-
};
|
|
94
|
-
/**
|
|
95
|
-
* Canvas Mesh component class that extends DisplayObject with PixiMesh functionality.
|
|
96
|
-
* This component allows rendering of custom 3D meshes with shaders and textures.
|
|
97
|
-
*
|
|
98
|
-
* @example
|
|
99
|
-
* ```typescript
|
|
100
|
-
* // Basic mesh with geometry and texture
|
|
101
|
-
* const mesh = Mesh({
|
|
102
|
-
* geometry: myGeometry,
|
|
103
|
-
* texture: "path/to/texture.png",
|
|
104
|
-
* tint: 0xff0000
|
|
105
|
-
* });
|
|
106
|
-
*
|
|
107
|
-
* // Mesh with custom shader
|
|
108
|
-
* const customMesh = Mesh({
|
|
109
|
-
* geometry: myGeometry,
|
|
110
|
-
* shader: myCustomShader,
|
|
111
|
-
* draw: (mesh) => {
|
|
112
|
-
* // Custom mesh manipulation
|
|
113
|
-
* mesh.rotation += 0.01;
|
|
114
|
-
* }
|
|
115
|
-
* });
|
|
116
|
-
* ```
|
|
117
|
-
*/
|
|
118
|
-
declare class CanvasMesh extends CanvasMesh_base {
|
|
119
|
-
/**
|
|
120
|
-
* Constructor for the CanvasMesh component.
|
|
121
|
-
* Initializes the PixiMesh with default geometry and shader to prevent errors.
|
|
122
|
-
*
|
|
123
|
-
* @example
|
|
124
|
-
* ```typescript
|
|
125
|
-
* // This constructor is called internally by the engine
|
|
126
|
-
* const mesh = new CanvasMesh();
|
|
127
|
-
* ```
|
|
128
|
-
*/
|
|
129
|
-
constructor();
|
|
130
|
-
/**
|
|
131
|
-
* Initializes the mesh component with the provided properties.
|
|
132
|
-
* This method is called before onUpdate to set up initial state.
|
|
133
|
-
*
|
|
134
|
-
* @param props - The initial properties
|
|
135
|
-
* @example
|
|
136
|
-
* ```typescript
|
|
137
|
-
* // This method is called internally when the component is created
|
|
138
|
-
* mesh.onInit({
|
|
139
|
-
* geometry: myGeometry,
|
|
140
|
-
* texture: "texture.png"
|
|
141
|
-
* });
|
|
142
|
-
* ```
|
|
143
|
-
*/
|
|
144
|
-
onInit(props: MeshProps): void;
|
|
145
|
-
/**
|
|
146
|
-
* Updates the mesh component when properties change.
|
|
147
|
-
* Handles texture loading, shader updates, and other property changes.
|
|
148
|
-
*
|
|
149
|
-
* @param props - The updated properties
|
|
150
|
-
* @example
|
|
151
|
-
* ```typescript
|
|
152
|
-
* // This method is called internally when props change
|
|
153
|
-
* mesh.onUpdate({
|
|
154
|
-
* tint: 0x00ff00,
|
|
155
|
-
* texture: "new-texture.png"
|
|
156
|
-
* });
|
|
157
|
-
* ```
|
|
158
|
-
*/
|
|
159
|
-
onUpdate(props: MeshProps): Promise<void>;
|
|
160
|
-
/**
|
|
161
|
-
* Called when the component is about to be destroyed.
|
|
162
|
-
* Cleans up the draw effect subscription and calls the parent destroy method.
|
|
163
|
-
*
|
|
164
|
-
* @param parent - The parent element
|
|
165
|
-
* @param afterDestroy - Callback function to execute after destruction
|
|
166
|
-
* @example
|
|
167
|
-
* ```typescript
|
|
168
|
-
* // This method is typically called by the engine internally
|
|
169
|
-
* await mesh.onDestroy(parentElement, () => console.log('Mesh destroyed'));
|
|
170
|
-
* ```
|
|
171
|
-
*/
|
|
172
|
-
onDestroy(parent: Element<ComponentInstance>, afterDestroy: () => void): Promise<void>;
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Creates a Mesh component with the specified properties.
|
|
176
|
-
* This is the main function used to create mesh instances in your application.
|
|
177
|
-
*
|
|
178
|
-
* @param props - The properties for the mesh component
|
|
179
|
-
* @returns A mesh component element
|
|
180
|
-
* @example
|
|
181
|
-
* ```typescript
|
|
182
|
-
* import { Mesh } from 'canvasengine';
|
|
183
|
-
*
|
|
184
|
-
* // Create a basic textured mesh
|
|
185
|
-
* const myMesh = Mesh({
|
|
186
|
-
* geometry: triangleGeometry,
|
|
187
|
-
* texture: "assets/texture.png",
|
|
188
|
-
* x: 100,
|
|
189
|
-
* y: 100,
|
|
190
|
-
* tint: 0xff0000
|
|
191
|
-
* });
|
|
192
|
-
*
|
|
193
|
-
* // Create a mesh with custom shader
|
|
194
|
-
* const shaderMesh = Mesh({
|
|
195
|
-
* geometry: planeGeometry,
|
|
196
|
-
* shader: customShader,
|
|
197
|
-
* draw: (mesh) => {
|
|
198
|
-
* mesh.rotation += 0.01;
|
|
199
|
-
* }
|
|
200
|
-
* });
|
|
201
|
-
* ```
|
|
202
|
-
*/
|
|
203
|
-
export declare const Mesh: ComponentFunction<MeshProps>;
|
|
204
|
-
export { CanvasMesh };
|
|
205
|
-
export type { MeshProps };
|
|
206
|
-
//# sourceMappingURL=Mesh.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Mesh.d.ts","sourceRoot":"","sources":["../../src/components/Mesh.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAuB,MAAM,SAAS,CAAC;AAC3F,OAAO,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,CAAC,SAAS,CAE7C,CAAC;AAGF,OAAO,EAAE,UAAU,EAAE,CAAC;AAGtB,YAAY,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
import { Signal } from '@signe/reactive';
|
|
2
|
-
import { Sprite as PixiSprite, Texture } from 'pixi.js';
|
|
3
|
-
import { Element } from '../engine/reactive';
|
|
4
|
-
import { AnimationFrames, FrameOptions, SpritesheetOptions, TextureOptions, TransformOptions } from './types/Spritesheet';
|
|
5
|
-
import { ComponentFunction } from '../engine/signal';
|
|
6
|
-
import { DisplayObjectProps } from './types/DisplayObject';
|
|
7
|
-
import { Layout } from '@pixi/layout';
|
|
8
|
-
|
|
9
|
-
type Image = {
|
|
10
|
-
image: string;
|
|
11
|
-
};
|
|
12
|
-
type TextureOptionsMerging = TextureOptions & {
|
|
13
|
-
spriteWidth: number;
|
|
14
|
-
spriteHeight: number;
|
|
15
|
-
sound?: string;
|
|
16
|
-
} & Image & TransformOptions;
|
|
17
|
-
type FrameOptionsMerging = TextureOptionsMerging & FrameOptions;
|
|
18
|
-
type SpritesheetOptionsMerging = TextureOptionsMerging & SpritesheetOptions;
|
|
19
|
-
type AnimationDataFrames = {
|
|
20
|
-
sprites: FrameOptionsMerging[];
|
|
21
|
-
frames: Texture[][];
|
|
22
|
-
name: string;
|
|
23
|
-
animations: AnimationFrames;
|
|
24
|
-
params: any[];
|
|
25
|
-
data: TextureOptionsMerging;
|
|
26
|
-
};
|
|
27
|
-
export declare enum StandardAnimation {
|
|
28
|
-
Stand = "stand",
|
|
29
|
-
Walk = "walk"
|
|
30
|
-
}
|
|
31
|
-
declare const CanvasSprite_base: {
|
|
32
|
-
new (): {
|
|
33
|
-
[x: string]: any;
|
|
34
|
-
"__#1@#canvasContext": {
|
|
35
|
-
[key: string]: any;
|
|
36
|
-
} | null;
|
|
37
|
-
isFlex: boolean;
|
|
38
|
-
fullProps: import('..').Props;
|
|
39
|
-
isMounted: boolean;
|
|
40
|
-
_anchorPoints: import('pixi.js').ObservablePoint;
|
|
41
|
-
isCustomAnchor: boolean;
|
|
42
|
-
displayWidth: import('@signe/reactive').WritableSignal<number>;
|
|
43
|
-
displayHeight: import('@signe/reactive').WritableSignal<number>;
|
|
44
|
-
overrideProps: string[];
|
|
45
|
-
layout: any;
|
|
46
|
-
onBeforeDestroy: import('./DisplayObject').OnHook | null;
|
|
47
|
-
onAfterMount: import('./DisplayObject').OnHook | null;
|
|
48
|
-
subjectInit: import('rxjs').BehaviorSubject<any>;
|
|
49
|
-
disableLayout: boolean;
|
|
50
|
-
"__#1@#registeredEvents": Map<string, Function>;
|
|
51
|
-
"__#1@#computedLayoutBox": {
|
|
52
|
-
width?: number;
|
|
53
|
-
height?: number;
|
|
54
|
-
} | null;
|
|
55
|
-
readonly deltaRatio: any;
|
|
56
|
-
readonly parentIsFlex: any;
|
|
57
|
-
onInit(props: import('..').Props): void;
|
|
58
|
-
onMount({ parent, props }: Element</*elided*/ any>, index?: number): Promise<void>;
|
|
59
|
-
onUpdate(props: import('..').Props): void;
|
|
60
|
-
onDestroy(parent: Element, afterDestroy?: () => void): Promise<void>;
|
|
61
|
-
setFlexDirection(direction: import('./types/DisplayObject').FlexDirection): void;
|
|
62
|
-
setFlexWrap(wrap: "wrap" | "nowrap" | "wrap-reverse"): void;
|
|
63
|
-
setAlignContent(align: import('./types/DisplayObject').AlignContent): void;
|
|
64
|
-
setAlignSelf(align: import('./types/DisplayObject').AlignContent): void;
|
|
65
|
-
setAlignItems(align: import('./types/DisplayObject').AlignContent): void;
|
|
66
|
-
setJustifyContent(justifyContent: "flex-start" | "flex-end" | "center" | "space-between" | "space-around"): void;
|
|
67
|
-
setPosition(position: import('./types/DisplayObject').EdgeSize): void;
|
|
68
|
-
setX(x: number): void;
|
|
69
|
-
setY(y: number): void;
|
|
70
|
-
setPadding(padding: import('./types/DisplayObject').EdgeSize): void;
|
|
71
|
-
setMargin(margin: import('./types/DisplayObject').EdgeSize): void;
|
|
72
|
-
setGap(gap: import('./types/DisplayObject').EdgeSize): void;
|
|
73
|
-
setBorder(border: import('./types/DisplayObject').EdgeSize): void;
|
|
74
|
-
setPositionType(positionType: "relative" | "absolute"): void;
|
|
75
|
-
setWidth(width: number): void;
|
|
76
|
-
setHeight(height: number): void;
|
|
77
|
-
getWidth(): number;
|
|
78
|
-
getHeight(): number;
|
|
79
|
-
setMinWidth(minWidth: number | string): void;
|
|
80
|
-
setMinHeight(minHeight: number | string): void;
|
|
81
|
-
setMaxWidth(maxWidth: number | string): void;
|
|
82
|
-
setMaxHeight(maxHeight: number | string): void;
|
|
83
|
-
setAspectRatio(aspectRatio: number): void;
|
|
84
|
-
setFlexGrow(flexGrow: number): void;
|
|
85
|
-
setFlexShrink(flexShrink: number): void;
|
|
86
|
-
setFlexBasis(flexBasis: number | string): void;
|
|
87
|
-
setRowGap(rowGap: number): void;
|
|
88
|
-
setColumnGap(columnGap: number): void;
|
|
89
|
-
setTop(top: number | string): void;
|
|
90
|
-
setLeft(left: number | string): void;
|
|
91
|
-
setRight(right: number | string): void;
|
|
92
|
-
setBottom(bottom: number | string): void;
|
|
93
|
-
setObjectFit(objectFit: import('./types/DisplayObject').ObjectFit): void;
|
|
94
|
-
setObjectPosition(objectPosition: import('./types/DisplayObject').ObjectPosition): void;
|
|
95
|
-
setTransformOrigin(transformOrigin: import('./types/DisplayObject').TransformOrigin): void;
|
|
96
|
-
};
|
|
97
|
-
[x: string]: any;
|
|
98
|
-
};
|
|
99
|
-
export declare class CanvasSprite extends CanvasSprite_base {
|
|
100
|
-
hitbox: {
|
|
101
|
-
w: number;
|
|
102
|
-
h: number;
|
|
103
|
-
};
|
|
104
|
-
applyTransform: (frame: FrameOptionsMerging, data: TextureOptionsMerging, spritesheet: SpritesheetOptionsMerging) => Partial<FrameOptionsMerging>;
|
|
105
|
-
private spritesheet;
|
|
106
|
-
private currentAnimation;
|
|
107
|
-
private time;
|
|
108
|
-
private frameIndex;
|
|
109
|
-
private animations;
|
|
110
|
-
private subscriptionTick;
|
|
111
|
-
private subscriptionSheet;
|
|
112
|
-
private sheetParams;
|
|
113
|
-
private sheetCurrentAnimation;
|
|
114
|
-
private app;
|
|
115
|
-
onFinish: () => void;
|
|
116
|
-
private globalLoader;
|
|
117
|
-
private trackedAssetIds;
|
|
118
|
-
get renderer(): import('pixi.js').Renderer;
|
|
119
|
-
private currentAnimationContainer;
|
|
120
|
-
/**
|
|
121
|
-
* Auto-detects image dimensions by loading the image and reading its natural size
|
|
122
|
-
* This is used when width/height are not explicitly provided in the spritesheet definition
|
|
123
|
-
*
|
|
124
|
-
* @param imagePath - Path to the image file
|
|
125
|
-
* @returns Object containing the detected width and height of the image
|
|
126
|
-
*
|
|
127
|
-
* @example
|
|
128
|
-
* ```typescript
|
|
129
|
-
* const { width, height } = await sprite.detectImageDimensions('path/to/image.png');
|
|
130
|
-
* // width: 256, height: 128
|
|
131
|
-
* ```
|
|
132
|
-
*/
|
|
133
|
-
private detectImageDimensions;
|
|
134
|
-
/**
|
|
135
|
-
* Creates textures from a spritesheet image by cutting it into frames
|
|
136
|
-
* Automatically detects image dimensions if width/height are not provided
|
|
137
|
-
*
|
|
138
|
-
* @param options - Texture options containing image path, dimensions, and frame configuration
|
|
139
|
-
* @returns A 2D array of textures organized by rows and columns
|
|
140
|
-
*
|
|
141
|
-
* @example
|
|
142
|
-
* ```typescript
|
|
143
|
-
* // With explicit dimensions
|
|
144
|
-
* const textures = await sprite.createTextures({
|
|
145
|
-
* image: 'path/to/image.png',
|
|
146
|
-
* width: 256,
|
|
147
|
-
* height: 128,
|
|
148
|
-
* framesWidth: 4,
|
|
149
|
-
* framesHeight: 2,
|
|
150
|
-
* spriteWidth: 64,
|
|
151
|
-
* spriteHeight: 64
|
|
152
|
-
* });
|
|
153
|
-
*
|
|
154
|
-
* // Without dimensions (automatically detected)
|
|
155
|
-
* const textures = await sprite.createTextures({
|
|
156
|
-
* image: 'path/to/image.png',
|
|
157
|
-
* framesWidth: 4,
|
|
158
|
-
* framesHeight: 2,
|
|
159
|
-
* spriteWidth: 64,
|
|
160
|
-
* spriteHeight: 64
|
|
161
|
-
* });
|
|
162
|
-
* ```
|
|
163
|
-
*/
|
|
164
|
-
private createTextures;
|
|
165
|
-
private createAnimations;
|
|
166
|
-
onMount(params: Element<CanvasSprite>): Promise<void>;
|
|
167
|
-
onUpdate(props: any): Promise<void>;
|
|
168
|
-
onDestroy(parent: Element, afterDestroy: () => void): Promise<void>;
|
|
169
|
-
has(name: string): boolean;
|
|
170
|
-
get(name: string): AnimationDataFrames;
|
|
171
|
-
isPlaying(name?: string): boolean;
|
|
172
|
-
stop(): void;
|
|
173
|
-
play(name: string, params?: any[]): void;
|
|
174
|
-
/**
|
|
175
|
-
* Resets the sprite by destroying and recreating all animations
|
|
176
|
-
* This method clears the current animation state, destroys existing textures,
|
|
177
|
-
* and recreates all animations from the spritesheet
|
|
178
|
-
*
|
|
179
|
-
* @example
|
|
180
|
-
* ```typescript
|
|
181
|
-
* // Reset all animations to their initial state
|
|
182
|
-
* sprite.resetAnimations();
|
|
183
|
-
*
|
|
184
|
-
* // Reset and then play a specific animation
|
|
185
|
-
* await sprite.resetAnimations();
|
|
186
|
-
* sprite.play('walk');
|
|
187
|
-
* ```
|
|
188
|
-
*/
|
|
189
|
-
resetAnimations(): Promise<void>;
|
|
190
|
-
update({ deltaRatio }: {
|
|
191
|
-
deltaRatio: any;
|
|
192
|
-
}): void;
|
|
193
|
-
}
|
|
194
|
-
export interface CanvasSprite extends PixiSprite {
|
|
195
|
-
layout: Layout | null;
|
|
196
|
-
}
|
|
197
|
-
export interface SpriteProps extends DisplayObjectProps {
|
|
198
|
-
sheet?: {
|
|
199
|
-
definition?: SpritesheetOptionsMerging;
|
|
200
|
-
playing?: string;
|
|
201
|
-
params?: any;
|
|
202
|
-
onFinish?: () => void;
|
|
203
|
-
};
|
|
204
|
-
scaleMode?: number;
|
|
205
|
-
image?: string;
|
|
206
|
-
rectangle?: {
|
|
207
|
-
x: number;
|
|
208
|
-
y: number;
|
|
209
|
-
width: number;
|
|
210
|
-
height: number;
|
|
211
|
-
};
|
|
212
|
-
context?: {
|
|
213
|
-
tick: Signal;
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
export interface SpritePropsWithImage extends Omit<SpriteProps, "sheet"> {
|
|
217
|
-
image: string;
|
|
218
|
-
rectangle?: {
|
|
219
|
-
x: number;
|
|
220
|
-
y: number;
|
|
221
|
-
width: number;
|
|
222
|
-
height: number;
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
export interface SpritePropsWithSheet extends Omit<SpriteProps, "image" | "rectangle"> {
|
|
226
|
-
sheet: {
|
|
227
|
-
definition: SpritesheetOptionsMerging;
|
|
228
|
-
playing?: string;
|
|
229
|
-
params?: any;
|
|
230
|
-
onFinish?: () => void;
|
|
231
|
-
};
|
|
232
|
-
loader?: {
|
|
233
|
-
onProgress?: (progress: number) => void;
|
|
234
|
-
onComplete?: (texture: Texture) => void;
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
export type SpritePropTypes = SpritePropsWithImage | SpritePropsWithSheet;
|
|
238
|
-
export declare const Sprite: ComponentFunction<SpritePropTypes>;
|
|
239
|
-
export {};
|
|
240
|
-
//# sourceMappingURL=Sprite.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Sprite.d.ts","sourceRoot":"","sources":["../../src/components/Sprite.ts"],"names":[],"mappings":"AACA,OAAO,EAA8B,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAIL,MAAM,IAAI,UAAU,EAEpB,OAAO,EACR,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,OAAO,EAIR,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAA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,110 +0,0 @@
|
|
|
1
|
-
import { Element, Props } from '../engine/reactive';
|
|
2
|
-
import { ComponentInstance } from './DisplayObject';
|
|
3
|
-
|
|
4
|
-
export interface ViewportProps extends Props {
|
|
5
|
-
screenWidth?: number;
|
|
6
|
-
screenHeight?: number;
|
|
7
|
-
worldWidth?: number;
|
|
8
|
-
worldHeight?: number;
|
|
9
|
-
clamp?: boolean | {
|
|
10
|
-
left?: number;
|
|
11
|
-
right?: number;
|
|
12
|
-
top?: number;
|
|
13
|
-
bottom?: number;
|
|
14
|
-
};
|
|
15
|
-
context?: any;
|
|
16
|
-
[key: string]: any;
|
|
17
|
-
}
|
|
18
|
-
declare const CanvasViewport_base: {
|
|
19
|
-
new (): {
|
|
20
|
-
[x: string]: any;
|
|
21
|
-
"__#1@#canvasContext": {
|
|
22
|
-
[key: string]: any;
|
|
23
|
-
} | null;
|
|
24
|
-
isFlex: boolean;
|
|
25
|
-
fullProps: Props;
|
|
26
|
-
isMounted: boolean;
|
|
27
|
-
_anchorPoints: import('pixi.js').ObservablePoint;
|
|
28
|
-
isCustomAnchor: boolean;
|
|
29
|
-
displayWidth: import('@signe/reactive').WritableSignal<number>;
|
|
30
|
-
displayHeight: import('@signe/reactive').WritableSignal<number>;
|
|
31
|
-
overrideProps: string[];
|
|
32
|
-
layout: any;
|
|
33
|
-
onBeforeDestroy: import('./DisplayObject').OnHook | null;
|
|
34
|
-
onAfterMount: import('./DisplayObject').OnHook | null;
|
|
35
|
-
subjectInit: import('rxjs').BehaviorSubject<any>;
|
|
36
|
-
disableLayout: boolean;
|
|
37
|
-
"__#1@#registeredEvents": Map<string, Function>;
|
|
38
|
-
"__#1@#computedLayoutBox": {
|
|
39
|
-
width?: number;
|
|
40
|
-
height?: number;
|
|
41
|
-
} | null;
|
|
42
|
-
readonly deltaRatio: any;
|
|
43
|
-
readonly parentIsFlex: any;
|
|
44
|
-
onInit(props: Props): void;
|
|
45
|
-
onMount({ parent, props }: Element</*elided*/ any>, index?: number): Promise<void>;
|
|
46
|
-
onUpdate(props: Props): void;
|
|
47
|
-
onDestroy(parent: Element, afterDestroy?: () => void): Promise<void>;
|
|
48
|
-
setFlexDirection(direction: import('./types/DisplayObject').FlexDirection): void;
|
|
49
|
-
setFlexWrap(wrap: "wrap" | "nowrap" | "wrap-reverse"): void;
|
|
50
|
-
setAlignContent(align: import('./types/DisplayObject').AlignContent): void;
|
|
51
|
-
setAlignSelf(align: import('./types/DisplayObject').AlignContent): void;
|
|
52
|
-
setAlignItems(align: import('./types/DisplayObject').AlignContent): void;
|
|
53
|
-
setJustifyContent(justifyContent: "flex-start" | "flex-end" | "center" | "space-between" | "space-around"): void;
|
|
54
|
-
setPosition(position: import('./types/DisplayObject').EdgeSize): void;
|
|
55
|
-
setX(x: number): void;
|
|
56
|
-
setY(y: number): void;
|
|
57
|
-
setPadding(padding: import('./types/DisplayObject').EdgeSize): void;
|
|
58
|
-
setMargin(margin: import('./types/DisplayObject').EdgeSize): void;
|
|
59
|
-
setGap(gap: import('./types/DisplayObject').EdgeSize): void;
|
|
60
|
-
setBorder(border: import('./types/DisplayObject').EdgeSize): void;
|
|
61
|
-
setPositionType(positionType: "relative" | "absolute"): void;
|
|
62
|
-
setWidth(width: number): void;
|
|
63
|
-
setHeight(height: number): void;
|
|
64
|
-
getWidth(): number;
|
|
65
|
-
getHeight(): number;
|
|
66
|
-
setMinWidth(minWidth: number | string): void;
|
|
67
|
-
setMinHeight(minHeight: number | string): void;
|
|
68
|
-
setMaxWidth(maxWidth: number | string): void;
|
|
69
|
-
setMaxHeight(maxHeight: number | string): void;
|
|
70
|
-
setAspectRatio(aspectRatio: number): void;
|
|
71
|
-
setFlexGrow(flexGrow: number): void;
|
|
72
|
-
setFlexShrink(flexShrink: number): void;
|
|
73
|
-
setFlexBasis(flexBasis: number | string): void;
|
|
74
|
-
setRowGap(rowGap: number): void;
|
|
75
|
-
setColumnGap(columnGap: number): void;
|
|
76
|
-
setTop(top: number | string): void;
|
|
77
|
-
setLeft(left: number | string): void;
|
|
78
|
-
setRight(right: number | string): void;
|
|
79
|
-
setBottom(bottom: number | string): void;
|
|
80
|
-
setObjectFit(objectFit: import('./types/DisplayObject').ObjectFit): void;
|
|
81
|
-
setObjectPosition(objectPosition: import('./types/DisplayObject').ObjectPosition): void;
|
|
82
|
-
setTransformOrigin(transformOrigin: import('./types/DisplayObject').TransformOrigin): void;
|
|
83
|
-
};
|
|
84
|
-
[x: string]: any;
|
|
85
|
-
};
|
|
86
|
-
export declare class CanvasViewport extends CanvasViewport_base {
|
|
87
|
-
private tickSubscription;
|
|
88
|
-
overrideProps: string[];
|
|
89
|
-
constructor();
|
|
90
|
-
onInit(props: any): void;
|
|
91
|
-
/**
|
|
92
|
-
* Called when the component is mounted to the scene graph.
|
|
93
|
-
* Initializes viewport settings and subscriptions.
|
|
94
|
-
* @param {Element<CanvasViewport>} element - The element being mounted. Its `props` property (of type ViewportProps) contains component properties and context.
|
|
95
|
-
* @param {number} [index] - The index of the component among its siblings.
|
|
96
|
-
*/
|
|
97
|
-
onMount(element: Element<CanvasViewport>, index?: number): Promise<void>;
|
|
98
|
-
onUpdate(props: any): void;
|
|
99
|
-
private updateViewportSettings;
|
|
100
|
-
/**
|
|
101
|
-
* Called when the component is about to be destroyed.
|
|
102
|
-
* Unsubscribes from the tick observable.
|
|
103
|
-
* @param {Element<any>} parent - The parent element.
|
|
104
|
-
* @param {() => void} [afterDestroy] - An optional callback function to be executed after the component's own destruction logic.
|
|
105
|
-
*/
|
|
106
|
-
onDestroy(parent: Element<any>, afterDestroy?: () => void): Promise<void>;
|
|
107
|
-
}
|
|
108
|
-
export declare function Viewport(props: ViewportProps): Element<ComponentInstance>;
|
|
109
|
-
export {};
|
|
110
|
-
//# sourceMappingURL=Viewport.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Viewport.d.ts","sourceRoot":"","sources":["../../src/components/Viewport.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsC,OAAO,EAAE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