dacha 0.16.1 → 0.17.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/build/contrib/components/index.d.ts +11 -20
- package/build/contrib/components/index.js +2 -1
- package/build/contrib/components/mesh/index.d.ts +107 -0
- package/build/contrib/components/mesh/index.js +115 -0
- package/build/contrib/components/sprite/index.d.ts +0 -4
- package/build/contrib/components/sprite/index.js +0 -5
- package/build/contrib/components/transform/index.d.ts +43 -61
- package/build/contrib/components/transform/index.js +89 -92
- package/build/contrib/components/transform/local-point.d.ts +11 -0
- package/build/contrib/components/transform/local-point.js +24 -0
- package/build/contrib/components/transform/local-transform.d.ts +25 -0
- package/build/contrib/components/transform/local-transform.js +39 -0
- package/build/contrib/components/transform/world-position.d.ts +9 -0
- package/build/contrib/components/transform/world-position.js +42 -0
- package/build/contrib/components/transform/world-scale.d.ts +9 -0
- package/build/contrib/components/transform/world-scale.js +34 -0
- package/build/contrib/components/transform/world-transform.d.ts +25 -0
- package/build/contrib/components/transform/world-transform.js +45 -0
- package/build/contrib/systems/behavior-system/system.js +1 -1
- package/build/contrib/systems/index.d.ts +1 -1
- package/build/contrib/systems/index.js +1 -1
- package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-box-geometry.js +9 -10
- package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-circle-geometry.js +4 -4
- package/build/contrib/systems/physics-system/subsystems/collision-detection/index.js +5 -5
- package/build/contrib/systems/physics-system/subsystems/collision-detection/reorientation-checkers/check-transform.js +5 -5
- package/build/contrib/systems/physics-system/subsystems/collision-detection/types.d.ts +2 -2
- package/build/contrib/systems/physics-system/subsystems/constraint-solver/index.js +4 -4
- package/build/contrib/systems/physics-system/subsystems/physics/index.js +2 -2
- package/build/contrib/systems/renderer/actor-render-tree.d.ts +35 -0
- package/build/contrib/systems/renderer/actor-render-tree.js +190 -0
- package/build/contrib/systems/renderer/assets/index.d.ts +22 -0
- package/build/contrib/systems/renderer/assets/index.js +101 -0
- package/build/contrib/systems/renderer/assets/utils.d.ts +5 -0
- package/build/contrib/systems/renderer/assets/utils.js +47 -0
- package/build/contrib/systems/renderer/builders/bitmap-text-builder/index.d.ts +12 -4
- package/build/contrib/systems/renderer/builders/bitmap-text-builder/index.js +10 -51
- package/build/contrib/systems/renderer/builders/builder.d.ts +6 -4
- package/build/contrib/systems/renderer/builders/index.d.ts +1 -0
- package/build/contrib/systems/renderer/builders/index.js +1 -0
- package/build/contrib/systems/renderer/builders/mesh-builder/consts.d.ts +2 -0
- package/build/contrib/systems/renderer/builders/mesh-builder/consts.js +2 -0
- package/build/contrib/systems/renderer/builders/mesh-builder/index.d.ts +22 -0
- package/build/contrib/systems/renderer/builders/mesh-builder/index.js +114 -0
- package/build/contrib/systems/renderer/builders/pixi-view-builder/index.d.ts +4 -3
- package/build/contrib/systems/renderer/builders/pixi-view-builder/index.js +2 -12
- package/build/contrib/systems/renderer/builders/shape-builder/index.d.ts +5 -4
- package/build/contrib/systems/renderer/builders/shape-builder/index.js +5 -45
- package/build/contrib/systems/renderer/builders/sprite-builder/index.d.ts +10 -12
- package/build/contrib/systems/renderer/builders/sprite-builder/index.js +17 -101
- package/build/contrib/systems/renderer/builders/texture-array-store/index.d.ts +13 -0
- package/build/contrib/systems/renderer/builders/texture-array-store/index.js +61 -0
- package/build/contrib/systems/renderer/builders/{sprite-builder → texture-array-store}/utils.d.ts +3 -2
- package/build/contrib/systems/renderer/builders/{sprite-builder → texture-array-store}/utils.js +3 -3
- package/build/contrib/systems/renderer/consts.d.ts +2 -0
- package/build/contrib/systems/renderer/consts.js +12 -0
- package/build/contrib/systems/renderer/filters/filter-effect.d.ts +14 -0
- package/build/contrib/systems/renderer/filters/filter-effect.js +3 -0
- package/build/contrib/systems/renderer/filters/index.d.ts +21 -0
- package/build/contrib/systems/renderer/filters/index.js +62 -0
- package/build/contrib/systems/renderer/index.d.ts +2 -0
- package/build/contrib/systems/renderer/index.js +2 -0
- package/build/contrib/systems/renderer/material/consts.d.ts +2 -0
- package/build/contrib/systems/renderer/material/consts.js +36 -0
- package/build/contrib/systems/renderer/material/index.d.ts +20 -0
- package/build/contrib/systems/renderer/material/index.js +94 -0
- package/build/contrib/systems/renderer/material/shader.d.ts +25 -0
- package/build/contrib/systems/renderer/material/shader.js +3 -0
- package/build/contrib/systems/renderer/renderer.d.ts +9 -14
- package/build/contrib/systems/renderer/renderer.js +57 -167
- package/build/contrib/systems/renderer/service/index.d.ts +42 -3
- package/build/contrib/systems/renderer/service/index.js +68 -19
- package/build/contrib/systems/renderer/service/utils.d.ts +3 -0
- package/build/contrib/systems/renderer/service/utils.js +14 -0
- package/build/contrib/systems/renderer/sort/sort-by-x-axis.js +2 -2
- package/build/contrib/systems/renderer/sort/sort-by-y-axis.js +2 -2
- package/build/contrib/systems/renderer/types.d.ts +14 -6
- package/build/contrib/systems/renderer/utils.d.ts +1 -5
- package/build/contrib/systems/renderer/utils.js +3 -41
- package/build/contrib/utils/coordinates-projection.js +4 -4
- package/build/engine/actor/actor-query.d.ts +1 -1
- package/build/engine/actor/actor.d.ts +1 -1
- package/build/engine/actor/actor.js +26 -5
- package/build/engine/component/component.js +5 -7
- package/build/engine/events/index.d.ts +9 -4
- package/build/engine/math-lib/index.d.ts +1 -0
- package/build/engine/math-lib/index.js +1 -0
- package/build/engine/math-lib/matrix/index.d.ts +22 -0
- package/build/engine/math-lib/matrix/index.js +112 -0
- package/build/engine/system/system.d.ts +2 -2
- package/build/engine/system/system.js +2 -2
- package/build/types/global.d.ts +22 -4
- package/package.json +3 -3
|
@@ -1,23 +1,14 @@
|
|
|
1
|
-
export { Camera } from './camera';
|
|
2
|
-
export type
|
|
3
|
-
export {
|
|
4
|
-
export type
|
|
5
|
-
export {
|
|
6
|
-
export type
|
|
7
|
-
export {
|
|
8
|
-
export type
|
|
9
|
-
export {
|
|
10
|
-
export type
|
|
11
|
-
export { Sprite } from './sprite';
|
|
12
|
-
export type { SpriteConfig } from './sprite';
|
|
13
|
-
export { Transform } from './transform';
|
|
14
|
-
export type { TransformConfig } from './transform';
|
|
15
|
-
export { MouseControl } from './mouse-control';
|
|
16
|
-
export type { MouseControlConfig } from './mouse-control';
|
|
17
|
-
export { Behaviors } from './behaviors';
|
|
18
|
-
export type { BehaviorsConfig } from './behaviors';
|
|
19
|
-
export { AudioSource } from './audio-source';
|
|
20
|
-
export type { AudioSourceConfig } from './audio-source';
|
|
1
|
+
export { Camera, type CameraConfig } from './camera';
|
|
2
|
+
export { KeyboardControl, type KeyboardControlConfig, } from './keyboard-control';
|
|
3
|
+
export { Collider, type ColliderConfig } from './collider';
|
|
4
|
+
export { RigidBody, type RigidBodyConfig } from './rigid-body';
|
|
5
|
+
export { Animatable, type AnimatableConfig } from './animatable';
|
|
6
|
+
export { Sprite, type SpriteConfig } from './sprite';
|
|
7
|
+
export { Transform, type TransformConfig } from './transform';
|
|
8
|
+
export { MouseControl, type MouseControlConfig } from './mouse-control';
|
|
9
|
+
export { Behaviors, type BehaviorsConfig } from './behaviors';
|
|
10
|
+
export { AudioSource, type AudioSourceConfig } from './audio-source';
|
|
21
11
|
export { Shape, type ShapeConfig } from './shape';
|
|
22
12
|
export { PixiView } from './pixi-view';
|
|
23
13
|
export { BitmapText, type BitmapTextConfig } from './bitmap-text';
|
|
14
|
+
export { Mesh, type MeshConfig } from './mesh';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { Camera } from './camera';
|
|
2
|
-
export { KeyboardControl } from './keyboard-control';
|
|
2
|
+
export { KeyboardControl, } from './keyboard-control';
|
|
3
3
|
export { Collider } from './collider';
|
|
4
4
|
export { RigidBody } from './rigid-body';
|
|
5
5
|
export { Animatable } from './animatable';
|
|
@@ -11,3 +11,4 @@ export { AudioSource } from './audio-source';
|
|
|
11
11
|
export { Shape } from './shape';
|
|
12
12
|
export { PixiView } from './pixi-view';
|
|
13
13
|
export { BitmapText } from './bitmap-text';
|
|
14
|
+
export { Mesh } from './mesh';
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { Mesh as PixiMesh } from 'pixi.js';
|
|
2
|
+
import { Component } from '../../../engine/component';
|
|
3
|
+
import { type BlendingMode } from '../../types/view';
|
|
4
|
+
interface RenderData {
|
|
5
|
+
view: PixiMesh;
|
|
6
|
+
textureSourceKey?: string;
|
|
7
|
+
textureArrayKey?: string;
|
|
8
|
+
}
|
|
9
|
+
export { type BlendingMode } from '../../types/view';
|
|
10
|
+
export interface MaterialConfig {
|
|
11
|
+
name: string;
|
|
12
|
+
options: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
export interface MeshConfig {
|
|
15
|
+
src: string;
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
slice: number;
|
|
19
|
+
flipX: boolean;
|
|
20
|
+
flipY: boolean;
|
|
21
|
+
sortingLayer: string;
|
|
22
|
+
sortCenter: [number, number];
|
|
23
|
+
color: string;
|
|
24
|
+
blending: BlendingMode;
|
|
25
|
+
opacity: number;
|
|
26
|
+
material?: MaterialConfig;
|
|
27
|
+
disabled: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Mesh component for rendering 2D textures with a custom shader.
|
|
31
|
+
*
|
|
32
|
+
* Handles the visual representation of an actor using a texture.
|
|
33
|
+
* The material field specifies a shader and its options for the mesh.
|
|
34
|
+
* Similar to Sprite component,
|
|
35
|
+
* it can render a single texture or a frame from a sprite sheet.
|
|
36
|
+
* When a material is not provided, the default shader is used.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* // Create a mesh with a custom material shader
|
|
41
|
+
* const mesh = new Mesh({
|
|
42
|
+
* src: 'assets/flame.png',
|
|
43
|
+
* width: 64,
|
|
44
|
+
* height: 64,
|
|
45
|
+
* slice: 4,
|
|
46
|
+
* flipX: false,
|
|
47
|
+
* flipY: false,
|
|
48
|
+
* sortingLayer: 'units',
|
|
49
|
+
* sortCenter: [0, 0],
|
|
50
|
+
* color: '#ffffff',
|
|
51
|
+
* blending: 'normal',
|
|
52
|
+
* opacity: 1,
|
|
53
|
+
* disabled: false,
|
|
54
|
+
* material: {
|
|
55
|
+
* name: 'HeatDistort',
|
|
56
|
+
* options: { strength: 0.2 }
|
|
57
|
+
* }
|
|
58
|
+
* });
|
|
59
|
+
*
|
|
60
|
+
* // Add to actor
|
|
61
|
+
* actor.setComponent(mesh);
|
|
62
|
+
*
|
|
63
|
+
* // Modify properties
|
|
64
|
+
* mesh.material = undefined; // Remove the heat-distort shader and apply the default one instead
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* @category Components
|
|
68
|
+
*/
|
|
69
|
+
export declare class Mesh extends Component {
|
|
70
|
+
/** Path to the texture image file */
|
|
71
|
+
src: string;
|
|
72
|
+
/** Width of the mesh in pixels */
|
|
73
|
+
width: number;
|
|
74
|
+
/** Height of the mesh in pixels */
|
|
75
|
+
height: number;
|
|
76
|
+
/** Amount of frames in the sprite sheet */
|
|
77
|
+
slice: number;
|
|
78
|
+
/** Whether to flip the mesh horizontally */
|
|
79
|
+
flipX: boolean;
|
|
80
|
+
/** Whether to flip the mesh vertically */
|
|
81
|
+
flipY: boolean;
|
|
82
|
+
/** Whether the mesh is disabled and should not render */
|
|
83
|
+
disabled: boolean;
|
|
84
|
+
/** Sorting layer name for rendering order */
|
|
85
|
+
sortingLayer: string;
|
|
86
|
+
/** Center point for sorting calculations */
|
|
87
|
+
sortCenter: [number, number];
|
|
88
|
+
/** Current frame to render */
|
|
89
|
+
currentFrame: number;
|
|
90
|
+
/** Color tint applied to the mesh */
|
|
91
|
+
color: string;
|
|
92
|
+
/** Blending mode for rendering */
|
|
93
|
+
blending: BlendingMode;
|
|
94
|
+
/** Opacity from 0 (transparent) to 1 (opaque) */
|
|
95
|
+
opacity: number;
|
|
96
|
+
/** Material describes a shader and its options applied to a texture (optional). */
|
|
97
|
+
material?: MaterialConfig;
|
|
98
|
+
/** Internal rendering data */
|
|
99
|
+
renderData?: RenderData;
|
|
100
|
+
/**
|
|
101
|
+
* Creates a new Mesh component.
|
|
102
|
+
*
|
|
103
|
+
* @param config - Configuration for the sprite
|
|
104
|
+
*/
|
|
105
|
+
constructor(config: MeshConfig);
|
|
106
|
+
clone(): Mesh;
|
|
107
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { Component } from '../../../engine/component';
|
|
2
|
+
/**
|
|
3
|
+
* Mesh component for rendering 2D textures with a custom shader.
|
|
4
|
+
*
|
|
5
|
+
* Handles the visual representation of an actor using a texture.
|
|
6
|
+
* The material field specifies a shader and its options for the mesh.
|
|
7
|
+
* Similar to Sprite component,
|
|
8
|
+
* it can render a single texture or a frame from a sprite sheet.
|
|
9
|
+
* When a material is not provided, the default shader is used.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* // Create a mesh with a custom material shader
|
|
14
|
+
* const mesh = new Mesh({
|
|
15
|
+
* src: 'assets/flame.png',
|
|
16
|
+
* width: 64,
|
|
17
|
+
* height: 64,
|
|
18
|
+
* slice: 4,
|
|
19
|
+
* flipX: false,
|
|
20
|
+
* flipY: false,
|
|
21
|
+
* sortingLayer: 'units',
|
|
22
|
+
* sortCenter: [0, 0],
|
|
23
|
+
* color: '#ffffff',
|
|
24
|
+
* blending: 'normal',
|
|
25
|
+
* opacity: 1,
|
|
26
|
+
* disabled: false,
|
|
27
|
+
* material: {
|
|
28
|
+
* name: 'HeatDistort',
|
|
29
|
+
* options: { strength: 0.2 }
|
|
30
|
+
* }
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* // Add to actor
|
|
34
|
+
* actor.setComponent(mesh);
|
|
35
|
+
*
|
|
36
|
+
* // Modify properties
|
|
37
|
+
* mesh.material = undefined; // Remove the heat-distort shader and apply the default one instead
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @category Components
|
|
41
|
+
*/
|
|
42
|
+
export class Mesh extends Component {
|
|
43
|
+
/** Path to the texture image file */
|
|
44
|
+
src;
|
|
45
|
+
/** Width of the mesh in pixels */
|
|
46
|
+
width;
|
|
47
|
+
/** Height of the mesh in pixels */
|
|
48
|
+
height;
|
|
49
|
+
/** Amount of frames in the sprite sheet */
|
|
50
|
+
slice;
|
|
51
|
+
/** Whether to flip the mesh horizontally */
|
|
52
|
+
flipX;
|
|
53
|
+
/** Whether to flip the mesh vertically */
|
|
54
|
+
flipY;
|
|
55
|
+
/** Whether the mesh is disabled and should not render */
|
|
56
|
+
disabled;
|
|
57
|
+
/** Sorting layer name for rendering order */
|
|
58
|
+
sortingLayer;
|
|
59
|
+
/** Center point for sorting calculations */
|
|
60
|
+
sortCenter;
|
|
61
|
+
/** Current frame to render */
|
|
62
|
+
currentFrame;
|
|
63
|
+
/** Color tint applied to the mesh */
|
|
64
|
+
color;
|
|
65
|
+
/** Blending mode for rendering */
|
|
66
|
+
blending;
|
|
67
|
+
/** Opacity from 0 (transparent) to 1 (opaque) */
|
|
68
|
+
opacity;
|
|
69
|
+
/** Material describes a shader and its options applied to a texture (optional). */
|
|
70
|
+
material;
|
|
71
|
+
/** Internal rendering data */
|
|
72
|
+
renderData;
|
|
73
|
+
/**
|
|
74
|
+
* Creates a new Mesh component.
|
|
75
|
+
*
|
|
76
|
+
* @param config - Configuration for the sprite
|
|
77
|
+
*/
|
|
78
|
+
constructor(config) {
|
|
79
|
+
super();
|
|
80
|
+
this.src = config.src;
|
|
81
|
+
this.width = config.width;
|
|
82
|
+
this.height = config.height;
|
|
83
|
+
this.slice = config.slice;
|
|
84
|
+
this.currentFrame = 0;
|
|
85
|
+
this.flipX = config.flipX;
|
|
86
|
+
this.flipY = config.flipY;
|
|
87
|
+
this.disabled = config.disabled;
|
|
88
|
+
this.sortingLayer = config.sortingLayer;
|
|
89
|
+
this.sortCenter = config.sortCenter;
|
|
90
|
+
this.color = config.color ?? '#ffffff';
|
|
91
|
+
this.blending = config.blending ?? 'normal';
|
|
92
|
+
this.opacity = config.opacity ?? 1;
|
|
93
|
+
this.material = config.material;
|
|
94
|
+
}
|
|
95
|
+
clone() {
|
|
96
|
+
return new Mesh({
|
|
97
|
+
src: this.src,
|
|
98
|
+
width: this.width,
|
|
99
|
+
height: this.height,
|
|
100
|
+
slice: this.slice,
|
|
101
|
+
flipX: this.flipX,
|
|
102
|
+
flipY: this.flipY,
|
|
103
|
+
disabled: this.disabled,
|
|
104
|
+
sortingLayer: this.sortingLayer,
|
|
105
|
+
sortCenter: this.sortCenter.slice(0),
|
|
106
|
+
color: this.color,
|
|
107
|
+
blending: this.blending,
|
|
108
|
+
opacity: this.opacity,
|
|
109
|
+
material: this.material
|
|
110
|
+
? { name: this.material.name, options: { ...this.material.options } }
|
|
111
|
+
: undefined,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
Mesh.componentName = 'Mesh';
|
|
@@ -13,7 +13,6 @@ export interface SpriteConfig {
|
|
|
13
13
|
width: number;
|
|
14
14
|
height: number;
|
|
15
15
|
slice: number;
|
|
16
|
-
rotation: number;
|
|
17
16
|
flipX: boolean;
|
|
18
17
|
flipY: boolean;
|
|
19
18
|
sortingLayer: string;
|
|
@@ -38,7 +37,6 @@ export interface SpriteConfig {
|
|
|
38
37
|
* width: 64,
|
|
39
38
|
* height: 64,
|
|
40
39
|
* slice: 0,
|
|
41
|
-
* rotation: 0,
|
|
42
40
|
* flipX: false,
|
|
43
41
|
* flipY: false,
|
|
44
42
|
* sortingLayer: 'units',
|
|
@@ -69,8 +67,6 @@ export declare class Sprite extends Component {
|
|
|
69
67
|
height: number;
|
|
70
68
|
/** Amount of frames in the sprite sheet */
|
|
71
69
|
slice: number;
|
|
72
|
-
/** Rotation of the sprite in degrees */
|
|
73
|
-
rotation: number;
|
|
74
70
|
/** Whether to flip the sprite horizontally */
|
|
75
71
|
flipX: boolean;
|
|
76
72
|
/** Whether to flip the sprite vertically */
|
|
@@ -13,7 +13,6 @@ import { Component } from '../../../engine/component';
|
|
|
13
13
|
* width: 64,
|
|
14
14
|
* height: 64,
|
|
15
15
|
* slice: 0,
|
|
16
|
-
* rotation: 0,
|
|
17
16
|
* flipX: false,
|
|
18
17
|
* flipY: false,
|
|
19
18
|
* sortingLayer: 'units',
|
|
@@ -44,8 +43,6 @@ export class Sprite extends Component {
|
|
|
44
43
|
height;
|
|
45
44
|
/** Amount of frames in the sprite sheet */
|
|
46
45
|
slice;
|
|
47
|
-
/** Rotation of the sprite in degrees */
|
|
48
|
-
rotation;
|
|
49
46
|
/** Whether to flip the sprite horizontally */
|
|
50
47
|
flipX;
|
|
51
48
|
/** Whether to flip the sprite vertically */
|
|
@@ -80,7 +77,6 @@ export class Sprite extends Component {
|
|
|
80
77
|
this.height = config.height;
|
|
81
78
|
this.slice = config.slice;
|
|
82
79
|
this.currentFrame = 0;
|
|
83
|
-
this.rotation = config.rotation;
|
|
84
80
|
this.flipX = config.flipX;
|
|
85
81
|
this.flipY = config.flipY;
|
|
86
82
|
this.disabled = config.disabled;
|
|
@@ -97,7 +93,6 @@ export class Sprite extends Component {
|
|
|
97
93
|
width: this.width,
|
|
98
94
|
height: this.height,
|
|
99
95
|
slice: this.slice,
|
|
100
|
-
rotation: this.rotation,
|
|
101
96
|
flipX: this.flipX,
|
|
102
97
|
flipY: this.flipY,
|
|
103
98
|
disabled: this.disabled,
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { Component } from '../../../engine/component';
|
|
2
|
+
import { Matrix } from '../../../engine/math-lib';
|
|
3
|
+
import { LocalTransform } from './local-transform';
|
|
4
|
+
import { WorldTransform } from './world-transform';
|
|
2
5
|
export interface TransformConfig {
|
|
3
6
|
offsetX: number;
|
|
4
7
|
offsetY: number;
|
|
@@ -7,11 +10,11 @@ export interface TransformConfig {
|
|
|
7
10
|
scaleY: number;
|
|
8
11
|
}
|
|
9
12
|
/**
|
|
10
|
-
*
|
|
13
|
+
* Component responsible for handling local and world-space transforms.
|
|
11
14
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
+
* A Transform manages position, rotation, and scale, and computes
|
|
16
|
+
* corresponding transformation matrices. It supports hierarchical
|
|
17
|
+
* parent-child relationships via world matrix composition.
|
|
15
18
|
*
|
|
16
19
|
* @example
|
|
17
20
|
* ```typescript
|
|
@@ -28,90 +31,69 @@ export interface TransformConfig {
|
|
|
28
31
|
* actor.setComponent(transform);
|
|
29
32
|
*
|
|
30
33
|
* // Access world coordinates
|
|
31
|
-
* console.log(`Position: ${transform.
|
|
32
|
-
* console.log(`Rotation: ${transform.rotation}`);
|
|
33
|
-
* console.log(`Scale: ${transform.
|
|
34
|
+
* console.log(`Position: ${transform.world.position.x}, ${transform.world.position.y}`);
|
|
35
|
+
* console.log(`Rotation (in radians): ${transform.world.rotation}`);
|
|
36
|
+
* console.log(`Scale: ${transform.world.scale.x}, ${transform.world.scale.y}`);
|
|
34
37
|
* ```
|
|
35
38
|
*
|
|
36
39
|
* @category Components
|
|
37
40
|
*/
|
|
38
41
|
export declare class Transform extends Component {
|
|
39
42
|
/**
|
|
40
|
-
*
|
|
43
|
+
* Local-space transform values (position, rotation, scale).
|
|
44
|
+
* These values are relative to the parent transform.
|
|
41
45
|
*/
|
|
42
|
-
|
|
46
|
+
local: LocalTransform;
|
|
43
47
|
/**
|
|
44
|
-
*
|
|
48
|
+
* World-space transform values derived from the local transform
|
|
49
|
+
* and the parent hierarchy.
|
|
45
50
|
*/
|
|
46
|
-
|
|
51
|
+
world: WorldTransform;
|
|
47
52
|
/**
|
|
48
|
-
*
|
|
53
|
+
* Matrix representing the local-space transformation.
|
|
49
54
|
*/
|
|
50
|
-
|
|
55
|
+
localMatrix: Matrix;
|
|
51
56
|
/**
|
|
52
|
-
*
|
|
57
|
+
* Matrix representing the world-space transformation.
|
|
53
58
|
*/
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
relativeScaleY: number;
|
|
59
|
+
worldMatrix: Matrix;
|
|
60
|
+
private _invertedWorldMatrix;
|
|
61
|
+
private dirty;
|
|
62
|
+
private invertedDirty;
|
|
59
63
|
/**
|
|
60
64
|
* Creates a new Transform component.
|
|
61
65
|
*
|
|
62
|
-
* @param config -
|
|
66
|
+
* @param config - Initial configuration for position, rotation, and scale.
|
|
63
67
|
*/
|
|
64
68
|
constructor(config: TransformConfig);
|
|
65
|
-
_getPropertyFromParent(name: string, defaultValue: number): number;
|
|
66
|
-
/**
|
|
67
|
-
* Sets the world X position of the actor.
|
|
68
|
-
* @param offsetX - World X position
|
|
69
|
-
*/
|
|
70
|
-
set offsetX(offsetX: number);
|
|
71
|
-
/**
|
|
72
|
-
* Gets the world X position of the actor.
|
|
73
|
-
* @returns World X position
|
|
74
|
-
*/
|
|
75
|
-
get offsetX(): number;
|
|
76
|
-
/**
|
|
77
|
-
* Sets the world Y position of the actor.
|
|
78
|
-
* @param offsetY - World Y position
|
|
79
|
-
*/
|
|
80
|
-
set offsetY(offsetY: number);
|
|
81
69
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
|
|
85
|
-
get offsetY(): number;
|
|
86
|
-
/**
|
|
87
|
-
* Sets the world rotation of the actor in degrees.
|
|
88
|
-
* @param rotation - World rotation in degrees
|
|
89
|
-
*/
|
|
90
|
-
set rotation(rotation: number);
|
|
91
|
-
/**
|
|
92
|
-
* Gets the world rotation of the actor in degrees.
|
|
93
|
-
* @returns World rotation in degrees
|
|
70
|
+
* Returns the parent Transform component, if one exists.
|
|
71
|
+
*
|
|
72
|
+
* @returns The parent Transform or `undefined` if this transform has no parent.
|
|
94
73
|
*/
|
|
95
|
-
|
|
74
|
+
getParentComponent(): Transform | undefined;
|
|
96
75
|
/**
|
|
97
|
-
*
|
|
98
|
-
*
|
|
76
|
+
* Marks this transform and all descendant transforms as dirty.
|
|
77
|
+
*
|
|
78
|
+
* This signals that their matrices must be recalculated before use.
|
|
99
79
|
*/
|
|
100
|
-
|
|
80
|
+
markDirty(): void;
|
|
101
81
|
/**
|
|
102
|
-
*
|
|
103
|
-
*
|
|
82
|
+
* Recomputes the local transformation matrix from local position,
|
|
83
|
+
* rotation, and scale.
|
|
104
84
|
*/
|
|
105
|
-
|
|
85
|
+
updateLocalMatrix(): void;
|
|
106
86
|
/**
|
|
107
|
-
*
|
|
108
|
-
*
|
|
87
|
+
* Recomputes the world transformation matrix if the transform is dirty.
|
|
88
|
+
*
|
|
89
|
+
* This method ensures parent transforms are updated first and then
|
|
90
|
+
* composes the local matrix with the parent world matrix.
|
|
109
91
|
*/
|
|
110
|
-
|
|
92
|
+
updateWorldMatrix(): void;
|
|
111
93
|
/**
|
|
112
|
-
*
|
|
113
|
-
*
|
|
94
|
+
* Inverse of the world transformation matrix.
|
|
95
|
+
* Useful for converting world-space coordinates to local space.
|
|
114
96
|
*/
|
|
115
|
-
get
|
|
97
|
+
get invertedWorldMatrix(): Matrix;
|
|
116
98
|
clone(): Transform;
|
|
117
99
|
}
|