dacha 0.18.0-alpha.2 → 0.18.0-alpha.4

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.
Files changed (191) hide show
  1. package/build/contrib/components/animatable/index.d.ts +0 -1
  2. package/build/contrib/components/animatable/index.js +0 -6
  3. package/build/contrib/components/audio-source/index.d.ts +0 -1
  4. package/build/contrib/components/audio-source/index.js +0 -9
  5. package/build/contrib/components/behaviors/index.d.ts +0 -1
  6. package/build/contrib/components/behaviors/index.js +4 -9
  7. package/build/contrib/components/bitmap-text/index.d.ts +6 -4
  8. package/build/contrib/components/bitmap-text/index.js +4 -17
  9. package/build/contrib/components/camera/index.d.ts +0 -1
  10. package/build/contrib/components/camera/index.js +0 -6
  11. package/build/contrib/components/collider/index.d.ts +56 -24
  12. package/build/contrib/components/collider/index.js +38 -48
  13. package/build/contrib/components/index.d.ts +2 -2
  14. package/build/contrib/components/index.js +2 -2
  15. package/build/contrib/components/keyboard-control/index.d.ts +0 -1
  16. package/build/contrib/components/keyboard-control/index.js +0 -31
  17. package/build/contrib/components/mesh/index.d.ts +6 -4
  18. package/build/contrib/components/mesh/index.js +7 -23
  19. package/build/contrib/components/mouse-control/index.d.ts +0 -1
  20. package/build/contrib/components/mouse-control/index.js +0 -19
  21. package/build/contrib/components/pixi-view/index.d.ts +6 -4
  22. package/build/contrib/components/pixi-view/index.js +4 -10
  23. package/build/contrib/components/rigid-body/index.d.ts +53 -8
  24. package/build/contrib/components/rigid-body/index.js +62 -15
  25. package/build/contrib/components/shape/index.d.ts +44 -38
  26. package/build/contrib/components/shape/index.js +41 -59
  27. package/build/contrib/components/sprite/index.d.ts +6 -4
  28. package/build/contrib/components/sprite/index.js +4 -20
  29. package/build/contrib/components/transform/index.d.ts +0 -1
  30. package/build/contrib/components/transform/index.js +1 -10
  31. package/build/contrib/systems/audio-system/index.js +3 -3
  32. package/build/contrib/systems/audio-system/utils.d.ts +3 -2
  33. package/build/contrib/systems/audio-system/utils.js +12 -0
  34. package/build/contrib/systems/physics-system/api.d.ts +15 -15
  35. package/build/contrib/systems/physics-system/api.js +15 -15
  36. package/build/contrib/systems/physics-system/physics-system.js +1 -0
  37. package/build/contrib/systems/physics-system/subsystems/collision-detection/aabb-builders/build-box-cast-aabb.d.ts +2 -0
  38. package/build/contrib/systems/physics-system/subsystems/collision-detection/aabb-builders/build-box-cast-aabb.js +18 -0
  39. package/build/contrib/systems/physics-system/subsystems/collision-detection/aabb-builders/build-capsule-cast-aabb.d.ts +2 -0
  40. package/build/contrib/systems/physics-system/subsystems/collision-detection/aabb-builders/build-capsule-cast-aabb.js +21 -0
  41. package/build/contrib/systems/physics-system/subsystems/collision-detection/aabb-builders/build-circle-cast-aabb.d.ts +2 -0
  42. package/build/contrib/systems/physics-system/subsystems/collision-detection/aabb-builders/build-circle-cast-aabb.js +15 -0
  43. package/build/contrib/systems/physics-system/subsystems/collision-detection/aabb-builders/index.js +6 -0
  44. package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-box-cast-geometry.d.ts +3 -0
  45. package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-box-cast-geometry.js +24 -0
  46. package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-box-geometry.js +8 -5
  47. package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-capsule-cast-geometry.d.ts +3 -0
  48. package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-capsule-cast-geometry.js +43 -0
  49. package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-capsule-geometry.d.ts +2 -0
  50. package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-capsule-geometry.js +42 -18
  51. package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-circle-cast-geometry.d.ts +3 -0
  52. package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-circle-cast-geometry.js +9 -0
  53. package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-circle-geometry.js +7 -4
  54. package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-point-geometry.js +1 -1
  55. package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-segment-geometry.js +12 -13
  56. package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/index.d.ts +6 -0
  57. package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/index.js +6 -0
  58. package/build/contrib/systems/physics-system/subsystems/collision-detection/index.d.ts +7 -7
  59. package/build/contrib/systems/physics-system/subsystems/collision-detection/index.js +35 -44
  60. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/box-box/check-boxes-intersection.d.ts +2 -2
  61. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/box-box/check-boxes-intersection.js +1 -3
  62. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/box-capsule/check-box-and-capsule-intersection.d.ts +2 -2
  63. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/box-capsule/check-box-and-capsule-intersection.js +1 -3
  64. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/box-capsule/utils.js +10 -10
  65. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/box-circle/check-box-and-circle-intersection.d.ts +2 -2
  66. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/box-circle/check-box-and-circle-intersection.js +3 -6
  67. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/box-segment/check-box-and-segment-intersection.d.ts +2 -2
  68. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/box-segment/check-box-and-segment-intersection.js +2 -4
  69. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/box-segment/utils.js +8 -8
  70. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/capsule-capsule/check-capsules-intersection.d.ts +2 -2
  71. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/capsule-capsule/check-capsules-intersection.js +1 -3
  72. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/circle-capsule/check-circle-and-capsule-intersection.d.ts +2 -2
  73. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/circle-capsule/check-circle-and-capsule-intersection.js +3 -5
  74. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/circle-circle/check-circles-intersection.d.ts +2 -2
  75. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/circle-circle/check-circles-intersection.js +5 -5
  76. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/circle-segment/check-circle-and-segment-intersection.d.ts +2 -2
  77. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/circle-segment/check-circle-and-segment-intersection.js +3 -5
  78. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/common/capsule.js +2 -2
  79. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/common/cast.d.ts +3 -0
  80. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/common/cast.js +9 -0
  81. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/common/points.js +2 -3
  82. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/common/projections.js +2 -2
  83. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/common/segment-distance.js +6 -6
  84. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/index.d.ts +2 -2
  85. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/index.js +0 -10
  86. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/point-box/check-point-and-box-intersection.d.ts +2 -2
  87. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/point-box/check-point-and-box-intersection.js +4 -6
  88. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/point-capsule/check-point-and-capsule-intersection.d.ts +2 -2
  89. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/point-capsule/check-point-and-capsule-intersection.js +3 -5
  90. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/point-circle/check-point-and-circle-intersection.d.ts +2 -2
  91. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/point-circle/check-point-and-circle-intersection.js +3 -5
  92. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/point-segment/check-point-and-segment-intersection.d.ts +2 -2
  93. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/point-segment/check-point-and-segment-intersection.js +3 -5
  94. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/segment-capsule/check-segment-and-capsule-intersection.d.ts +2 -2
  95. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/segment-capsule/check-segment-and-capsule-intersection.js +1 -3
  96. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/tests/helpers.d.ts +3 -2
  97. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/tests/helpers.js +40 -30
  98. package/build/contrib/systems/physics-system/subsystems/collision-detection/query-utils.d.ts +11 -6
  99. package/build/contrib/systems/physics-system/subsystems/collision-detection/query-utils.js +74 -14
  100. package/build/contrib/systems/physics-system/subsystems/collision-detection/raycast-checkers/index.d.ts +2 -0
  101. package/build/contrib/systems/physics-system/subsystems/collision-detection/raycast-checkers/index.js +12 -0
  102. package/build/contrib/systems/physics-system/subsystems/collision-detection/{intersection-checkers → raycast-checkers}/ray-box/check-ray-and-box-intersection.d.ts +3 -2
  103. package/build/contrib/systems/physics-system/subsystems/collision-detection/{intersection-checkers → raycast-checkers}/ray-box/check-ray-and-box-intersection.js +8 -12
  104. package/build/contrib/systems/physics-system/subsystems/collision-detection/raycast-checkers/ray-capsule/check-ray-and-capsule-intersection.d.ts +20 -0
  105. package/build/contrib/systems/physics-system/subsystems/collision-detection/{intersection-checkers → raycast-checkers}/ray-capsule/check-ray-and-capsule-intersection.js +27 -39
  106. package/build/contrib/systems/physics-system/subsystems/collision-detection/{intersection-checkers → raycast-checkers}/ray-circle/check-ray-and-circle-intersection.d.ts +3 -2
  107. package/build/contrib/systems/physics-system/subsystems/collision-detection/{intersection-checkers → raycast-checkers}/ray-circle/check-ray-and-circle-intersection.js +8 -10
  108. package/build/contrib/systems/physics-system/subsystems/collision-detection/{intersection-checkers → raycast-checkers}/ray-segment/check-ray-and-segment-intersection.d.ts +3 -2
  109. package/build/contrib/systems/physics-system/subsystems/collision-detection/{intersection-checkers → raycast-checkers}/ray-segment/check-ray-and-segment-intersection.js +9 -13
  110. package/build/contrib/systems/physics-system/subsystems/collision-detection/raycast-checkers/types.d.ts +4 -0
  111. package/build/contrib/systems/physics-system/subsystems/collision-detection/raycast-checkers/types.js +1 -0
  112. package/build/contrib/systems/physics-system/subsystems/collision-detection/reorientation-checkers/check-collider.js +16 -12
  113. package/build/contrib/systems/physics-system/subsystems/collision-detection/reorientation-checkers/get-orientation-data.d.ts +3 -0
  114. package/build/contrib/systems/physics-system/subsystems/collision-detection/reorientation-checkers/get-orientation-data.js +42 -0
  115. package/build/contrib/systems/physics-system/subsystems/collision-detection/reorientation-checkers/index.d.ts +1 -0
  116. package/build/contrib/systems/physics-system/subsystems/collision-detection/reorientation-checkers/index.js +1 -0
  117. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/box-box/check-box-cast-and-box.d.ts +3 -0
  118. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/box-box/check-box-cast-and-box.js +12 -0
  119. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/box-capsule/check-box-cast-and-capsule.d.ts +3 -0
  120. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/box-capsule/check-box-cast-and-capsule.js +12 -0
  121. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/box-circle/check-box-cast-and-circle.d.ts +3 -0
  122. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/box-circle/check-box-cast-and-circle.js +12 -0
  123. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/box-segment/check-box-cast-and-segment.d.ts +3 -0
  124. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/box-segment/check-box-cast-and-segment.js +15 -0
  125. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/box-utils.d.ts +7 -0
  126. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/box-utils.js +146 -0
  127. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/capsule-box/check-capsule-cast-and-box.d.ts +3 -0
  128. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/capsule-box/check-capsule-cast-and-box.js +22 -0
  129. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/capsule-capsule/check-capsule-cast-and-capsule.d.ts +3 -0
  130. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/capsule-capsule/check-capsule-cast-and-capsule.js +21 -0
  131. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/capsule-circle/check-capsule-cast-and-circle.d.ts +3 -0
  132. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/capsule-circle/check-capsule-cast-and-circle.js +20 -0
  133. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/capsule-segment/check-capsule-cast-and-segment.d.ts +3 -0
  134. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/capsule-segment/check-capsule-cast-and-segment.js +21 -0
  135. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/capsule-utils.d.ts +3 -0
  136. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/capsule-utils.js +16 -0
  137. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/circle-box/check-circle-cast-and-box.d.ts +3 -0
  138. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/circle-box/check-circle-cast-and-box.js +22 -0
  139. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/circle-capsule/check-circle-cast-and-capsule.d.ts +3 -0
  140. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/circle-capsule/check-circle-cast-and-capsule.js +18 -0
  141. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/circle-circle/check-circle-cast-and-circle.d.ts +3 -0
  142. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/circle-circle/check-circle-cast-and-circle.js +22 -0
  143. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/circle-segment/check-circle-cast-and-segment.d.ts +3 -0
  144. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/circle-segment/check-circle-cast-and-segment.js +18 -0
  145. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/index.d.ts +2 -0
  146. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/index.js +32 -0
  147. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/tests/helpers.d.ts +6 -0
  148. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/tests/helpers.js +39 -0
  149. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/types.d.ts +4 -0
  150. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/types.js +1 -0
  151. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/utils.d.ts +4 -0
  152. package/build/contrib/systems/physics-system/subsystems/collision-detection/shape-cast-checkers/utils.js +11 -0
  153. package/build/contrib/systems/physics-system/subsystems/collision-detection/types.d.ts +18 -5
  154. package/build/contrib/systems/physics-system/subsystems/collision-detection/utils.d.ts +5 -0
  155. package/build/contrib/systems/physics-system/subsystems/collision-detection/utils.js +6 -0
  156. package/build/contrib/systems/physics-system/subsystems/constraint-solver/index.d.ts +6 -0
  157. package/build/contrib/systems/physics-system/subsystems/constraint-solver/index.js +65 -4
  158. package/build/contrib/systems/physics-system/subsystems/physics/index.d.ts +2 -0
  159. package/build/contrib/systems/physics-system/subsystems/physics/index.js +43 -5
  160. package/build/contrib/systems/physics-system/tests/helpers.d.ts +20 -0
  161. package/build/contrib/systems/physics-system/tests/helpers.js +129 -0
  162. package/build/contrib/systems/physics-system/types.d.ts +53 -6
  163. package/build/contrib/systems/renderer/assets/index.js +4 -4
  164. package/build/contrib/systems/renderer/assets/utils.d.ts +5 -3
  165. package/build/contrib/systems/renderer/assets/utils.js +25 -0
  166. package/build/contrib/systems/renderer/builders/shape-builder/index.d.ts +2 -0
  167. package/build/contrib/systems/renderer/builders/shape-builder/index.js +69 -29
  168. package/build/contrib/systems/renderer/builders/shape-builder/utils.js +31 -21
  169. package/build/contrib/systems/renderer/sort/sort-by-x-axis.js +2 -2
  170. package/build/contrib/systems/renderer/sort/sort-by-y-axis.js +2 -2
  171. package/build/engine/actor/actor-creator.d.ts +1 -0
  172. package/build/engine/actor/actor-creator.js +6 -8
  173. package/build/engine/component/component.d.ts +0 -1
  174. package/build/engine/engine.js +1 -1
  175. package/build/engine/entity/utils.d.ts +6 -3
  176. package/build/engine/math-lib/vector/ops.d.ts +9 -1
  177. package/build/engine/math-lib/vector/ops.js +15 -0
  178. package/build/engine/template/index.d.ts +0 -1
  179. package/build/engine/template/index.js +0 -1
  180. package/build/engine/template/template-collection.d.ts +4 -8
  181. package/build/engine/template/template-collection.js +25 -29
  182. package/build/engine/types/config.d.ts +4 -4
  183. package/build/types/global.d.ts +4 -1
  184. package/package.json +1 -1
  185. package/build/contrib/systems/physics-system/consts.d.ts +0 -4
  186. package/build/contrib/systems/physics-system/consts.js +0 -4
  187. package/build/contrib/systems/physics-system/subsystems/collision-detection/intersection-checkers/ray-capsule/check-ray-and-capsule-intersection.d.ts +0 -11
  188. package/build/engine/template/template.d.ts +0 -18
  189. package/build/engine/template/template.js +0 -46
  190. /package/build/contrib/systems/physics-system/subsystems/collision-detection/{intersection-checkers → raycast-checkers}/ray-segment/utils.d.ts +0 -0
  191. /package/build/contrib/systems/physics-system/subsystems/collision-detection/{intersection-checkers → raycast-checkers}/ray-segment/utils.js +0 -0
@@ -18,7 +18,8 @@ import { Component } from '../../../engine/component';
18
18
  * return graphics;
19
19
  * },
20
20
  * sortingLayer: 'units',
21
- * sortCenter: [0, 0],
21
+ * sortOffsetX: 0,
22
+ * sortOffsetY: 0,
22
23
  * });
23
24
  *
24
25
  * // Add to actor
@@ -33,7 +34,7 @@ export class PixiView extends Component {
33
34
  /** Sorting layer of the pixi view */
34
35
  sortingLayer;
35
36
  /** Center point of the pixi view */
36
- sortCenter;
37
+ sortOffset;
37
38
  /** Internal rendering data */
38
39
  renderData;
39
40
  /**
@@ -45,18 +46,11 @@ export class PixiView extends Component {
45
46
  super();
46
47
  this.createView = config.createView;
47
48
  this.sortingLayer = config.sortingLayer;
48
- this.sortCenter = config.sortCenter;
49
+ this.sortOffset = { x: config.sortOffsetX, y: config.sortOffsetY };
49
50
  }
50
51
  /** Get the pixi.js view. It's only available after the actor with this component is added to a scene */
51
52
  get view() {
52
53
  return this.renderData?.view;
53
54
  }
54
- clone() {
55
- return new PixiView({
56
- createView: this.createView,
57
- sortingLayer: this.sortingLayer,
58
- sortCenter: this.sortCenter.slice(0),
59
- });
60
- }
61
55
  }
62
56
  PixiView.componentName = 'PixiView';
@@ -1,12 +1,15 @@
1
1
  import { Component } from '../../../engine/component';
2
2
  import { Vector2 } from '../../../engine/math-lib';
3
- export type RigidBodyType = 'dynamic' | 'static';
3
+ export type RigidBodyType = 'dynamic' | 'static' | 'kinematic';
4
4
  export interface RigidBodyConfig {
5
5
  type: RigidBodyType;
6
- mass: number;
7
- gravityScale: number;
8
- linearDamping: number;
6
+ mass?: number;
7
+ gravityScale?: number;
8
+ linearDamping?: number;
9
9
  disabled: boolean;
10
+ oneWay: boolean;
11
+ oneWayNormalX?: number;
12
+ oneWayNormalY?: number;
10
13
  }
11
14
  /**
12
15
  * RigidBody component for defining rigid body physics.
@@ -37,9 +40,10 @@ export interface RigidBodyConfig {
37
40
  export declare class RigidBody extends Component {
38
41
  private _mass;
39
42
  private _inverseMass;
40
- /** Type of the rigid body */
41
- type: RigidBodyType;
42
- /** Mass of the rigid body */
43
+ /** @internal Pending one-step kinematic movement target */
44
+ _movementTarget: Vector2 | null;
45
+ /** Body type that defines how the rigid body participates in simulation */
46
+ readonly type: RigidBodyType;
43
47
  /** Gravity scale of the rigid body */
44
48
  gravityScale: number;
45
49
  /** Linear damping value used to slow down movement over time */
@@ -50,20 +54,61 @@ export declare class RigidBody extends Component {
50
54
  disabled: boolean;
51
55
  /** Whether rigid body is sleeping */
52
56
  sleeping: boolean;
57
+ /** Force applied to the rigid body */
53
58
  force: Vector2;
59
+ /** Impulse applied to the rigid body */
54
60
  impulse: Vector2;
61
+ /** Whether contacts should only be resolved from one side */
62
+ oneWay: boolean;
63
+ /** Local-space normal that points toward the blocking side */
64
+ oneWayNormal?: Vector2;
55
65
  /**
56
66
  * Creates a new RigidBody component.
57
67
  * @param config - Configuration for the rigid body
58
68
  */
59
69
  constructor(config: RigidBodyConfig);
60
70
  get mass(): number;
71
+ /**
72
+ * Sets the mass used by dynamic bodies.
73
+ *
74
+ * Non-positive values make the body immovable by forces and impulses.
75
+ */
61
76
  set mass(value: number);
77
+ /**
78
+ * Returns the inverse mass.
79
+ *
80
+ * Bodies with zero or negative mass return `0`.
81
+ */
62
82
  get inverseMass(): number;
83
+ /**
84
+ * Adds a continuous force to a dynamic body for the next physics step.
85
+ *
86
+ * Affects only active dynamic bodies.
87
+ */
63
88
  applyForce(force: Vector2): void;
89
+ /**
90
+ * Adds an instantaneous impulse to a dynamic body for the next physics step.
91
+ *
92
+ * Affects only active dynamic bodies.
93
+ */
64
94
  applyImpulse(impulse: Vector2): void;
95
+ /**
96
+ * Marks the rigid body as awake so it can be simulated.
97
+ */
65
98
  wakeUp(): void;
99
+ /**
100
+ * Marks the rigid body as sleeping so dynamic integration can skip it.
101
+ */
66
102
  sleep(): void;
103
+ /**
104
+ * Clears all accumulated force and impulse values.
105
+ */
67
106
  clearForces(): void;
68
- clone(): RigidBody;
107
+ /**
108
+ * Moves a kinematic body to a target position on the next physics step.
109
+ *
110
+ * The physics system computes a one-step velocity from the current position
111
+ * to this target so contacts can react to the kinematic movement.
112
+ */
113
+ movePosition(position: Vector2): void;
69
114
  }
@@ -29,9 +29,10 @@ import { Vector2 } from '../../../engine/math-lib';
29
29
  export class RigidBody extends Component {
30
30
  _mass;
31
31
  _inverseMass;
32
- /** Type of the rigid body */
32
+ /** @internal Pending one-step kinematic movement target */
33
+ _movementTarget;
34
+ /** Body type that defines how the rigid body participates in simulation */
33
35
  type;
34
- /** Mass of the rigid body */
35
36
  /** Gravity scale of the rigid body */
36
37
  gravityScale;
37
38
  /** Linear damping value used to slow down movement over time */
@@ -42,8 +43,14 @@ export class RigidBody extends Component {
42
43
  disabled;
43
44
  /** Whether rigid body is sleeping */
44
45
  sleeping;
46
+ /** Force applied to the rigid body */
45
47
  force;
48
+ /** Impulse applied to the rigid body */
46
49
  impulse;
50
+ /** Whether contacts should only be resolved from one side */
51
+ oneWay;
52
+ /** Local-space normal that points toward the blocking side */
53
+ oneWayNormal;
47
54
  /**
48
55
  * Creates a new RigidBody component.
49
56
  * @param config - Configuration for the rigid body
@@ -52,58 +59,98 @@ export class RigidBody extends Component {
52
59
  super();
53
60
  this._mass = 0;
54
61
  this._inverseMass = 0;
62
+ this._movementTarget = null;
55
63
  this.type = config.type;
56
- this.mass = config.mass;
57
- this.gravityScale = config.gravityScale;
58
- this.linearDamping = config.linearDamping;
64
+ this.mass = config.mass ?? 0;
65
+ this.gravityScale = config.gravityScale ?? 0;
66
+ this.linearDamping = config.linearDamping ?? 0;
59
67
  this.linearVelocity = new Vector2(0, 0);
60
68
  this.disabled = config.disabled;
61
69
  this.sleeping = false;
62
70
  this.force = new Vector2(0, 0);
63
71
  this.impulse = new Vector2(0, 0);
72
+ this.oneWay = config.oneWay ?? false;
73
+ if (this.oneWay) {
74
+ this.oneWayNormal = new Vector2(config.oneWayNormalX ?? 0, config.oneWayNormalY ?? 0).normalize();
75
+ if (this.oneWayNormal.magnitude === 0) {
76
+ throw new Error('One-way rigid body normal must be non-zero');
77
+ }
78
+ }
64
79
  }
65
80
  get mass() {
66
81
  return this._mass;
67
82
  }
83
+ /**
84
+ * Sets the mass used by dynamic bodies.
85
+ *
86
+ * Non-positive values make the body immovable by forces and impulses.
87
+ */
68
88
  set mass(value) {
69
89
  this._mass = value;
70
90
  this._inverseMass = value > 0 ? 1 / value : 0;
71
91
  }
92
+ /**
93
+ * Returns the inverse mass.
94
+ *
95
+ * Bodies with zero or negative mass return `0`.
96
+ */
72
97
  get inverseMass() {
73
98
  return this._inverseMass;
74
99
  }
100
+ /**
101
+ * Adds a continuous force to a dynamic body for the next physics step.
102
+ *
103
+ * Affects only active dynamic bodies.
104
+ */
75
105
  applyForce(force) {
76
- if (this.disabled || this.type === 'static') {
106
+ if (this.disabled || this.type !== 'dynamic') {
77
107
  return;
78
108
  }
79
109
  this.wakeUp();
80
110
  this.force.add(force);
81
111
  }
112
+ /**
113
+ * Adds an instantaneous impulse to a dynamic body for the next physics step.
114
+ *
115
+ * Affects only active dynamic bodies.
116
+ */
82
117
  applyImpulse(impulse) {
83
- if (this.disabled || this.type === 'static') {
118
+ if (this.disabled || this.type !== 'dynamic') {
84
119
  return;
85
120
  }
86
121
  this.wakeUp();
87
122
  this.impulse.add(impulse);
88
123
  }
124
+ /**
125
+ * Marks the rigid body as awake so it can be simulated.
126
+ */
89
127
  wakeUp() {
90
128
  this.sleeping = false;
91
129
  }
130
+ /**
131
+ * Marks the rigid body as sleeping so dynamic integration can skip it.
132
+ */
92
133
  sleep() {
93
134
  this.sleeping = true;
94
135
  }
136
+ /**
137
+ * Clears all accumulated force and impulse values.
138
+ */
95
139
  clearForces() {
96
140
  this.force.multiplyNumber(0);
97
141
  this.impulse.multiplyNumber(0);
98
142
  }
99
- clone() {
100
- return new RigidBody({
101
- mass: this.mass,
102
- gravityScale: this.gravityScale,
103
- linearDamping: this.linearDamping,
104
- disabled: this.disabled,
105
- type: this.type,
106
- });
143
+ /**
144
+ * Moves a kinematic body to a target position on the next physics step.
145
+ *
146
+ * The physics system computes a one-step velocity from the current position
147
+ * to this target so contacts can react to the kinematic movement.
148
+ */
149
+ movePosition(position) {
150
+ if (this.disabled || this.type !== 'kinematic') {
151
+ return;
152
+ }
153
+ this._movementTarget = position.clone();
107
154
  }
108
155
  }
109
156
  RigidBody.componentName = 'RigidBody';
@@ -1,13 +1,13 @@
1
1
  import type { Graphics } from 'pixi.js';
2
2
  import { Component } from '../../../engine/component';
3
+ import type { Point } from '../../../engine/math-lib';
3
4
  import { type BlendingMode } from '../../types/view';
4
5
  interface RenderData {
5
6
  view: Graphics;
6
7
  graphicsContextKey?: string;
7
8
  }
8
9
  export type ShapeType = 'rectangle' | 'roundRectangle' | 'circle' | 'ellipse' | 'line';
9
- export interface BaseShape {
10
- type: ShapeType;
10
+ export interface BaseShapeConfig {
11
11
  strokeColor?: string;
12
12
  strokeWidth: number;
13
13
  strokeAlignment: number;
@@ -17,36 +17,60 @@ export interface BaseShape {
17
17
  blending: BlendingMode;
18
18
  disabled: boolean;
19
19
  sortingLayer: string;
20
- sortCenter: [number, number];
20
+ sortOffsetX: number;
21
+ sortOffsetY: number;
21
22
  }
22
- export interface Rectangle extends BaseShape {
23
+ export interface RectangleShapeConfig extends BaseShapeConfig {
23
24
  type: 'rectangle';
24
- width: number;
25
- height: number;
25
+ sizeX: number;
26
+ sizeY: number;
26
27
  }
27
- export interface RoundRectangle extends BaseShape {
28
+ export interface RoundRectangleShapeConfig extends BaseShapeConfig {
28
29
  type: 'roundRectangle';
29
- width: number;
30
- height: number;
30
+ sizeX: number;
31
+ sizeY: number;
31
32
  radius: number;
32
33
  }
33
- export interface Circle extends BaseShape {
34
+ export interface CircleShapeConfig extends BaseShapeConfig {
34
35
  type: 'circle';
35
36
  radius: number;
36
37
  }
37
- export interface Ellipse extends BaseShape {
38
+ export interface EllipseShapeConfig extends BaseShapeConfig {
38
39
  type: 'ellipse';
39
40
  radiusX: number;
40
41
  radiusY: number;
41
42
  }
42
- export interface Line extends BaseShape {
43
+ export interface LineShapeConfig extends BaseShapeConfig {
43
44
  type: 'line';
44
45
  point1X: number;
45
46
  point1Y: number;
46
47
  point2X: number;
47
48
  point2Y: number;
48
49
  }
49
- export type ShapeConfig = BaseShape & Partial<Rectangle | RoundRectangle | Circle | Ellipse | Line>;
50
+ export type ShapeConfig = RectangleShapeConfig | RoundRectangleShapeConfig | CircleShapeConfig | EllipseShapeConfig | LineShapeConfig;
51
+ export interface RectangleShapeGeometry {
52
+ type: 'rectangle';
53
+ size: Point;
54
+ }
55
+ export interface RoundRectangleShapeGeometry {
56
+ type: 'roundRectangle';
57
+ size: Point;
58
+ radius: number;
59
+ }
60
+ export interface CircleShapeGeometry {
61
+ type: 'circle';
62
+ radius: number;
63
+ }
64
+ export interface EllipseShapeGeometry {
65
+ type: 'ellipse';
66
+ radius: Point;
67
+ }
68
+ export interface LineShapeGeometry {
69
+ type: 'line';
70
+ point1: Point;
71
+ point2: Point;
72
+ }
73
+ export type ShapeGeometry = RectangleShapeGeometry | RoundRectangleShapeGeometry | CircleShapeGeometry | EllipseShapeGeometry | LineShapeGeometry;
50
74
  /**
51
75
  * Shape component for rendering 2D geometry.
52
76
  *
@@ -58,8 +82,8 @@ export type ShapeConfig = BaseShape & Partial<Rectangle | RoundRectangle | Circl
58
82
  * // Create a basic shape
59
83
  * const shape = new Shape({
60
84
  * type: 'rectangle',
61
- * width: 100,
62
- * height: 100,
85
+ * sizeX: 100,
86
+ * sizeY: 50,
63
87
  * strokeWidth: 2,
64
88
  * strokeColor: '#000',
65
89
  * strokeAlignment: 0.5,
@@ -68,7 +92,8 @@ export type ShapeConfig = BaseShape & Partial<Rectangle | RoundRectangle | Circl
68
92
  * blending: 'normal',
69
93
  * disabled: false,
70
94
  * sortingLayer: 'units',
71
- * sortCenter: [0, 0],
95
+ * sortOffsetX: 0,
96
+ * sortOffsetY: 0,
72
97
  * });
73
98
  *
74
99
  * // Add to actor
@@ -82,8 +107,8 @@ export type ShapeConfig = BaseShape & Partial<Rectangle | RoundRectangle | Circl
82
107
  * @category Components
83
108
  */
84
109
  export declare class Shape extends Component {
85
- /** Type of the shape */
86
- type: ShapeType;
110
+ /** Geometry of the shape */
111
+ geometry: ShapeGeometry;
87
112
  /** Color of the stroke */
88
113
  strokeColor?: string;
89
114
  /** Width of the stroke */
@@ -108,25 +133,7 @@ export declare class Shape extends Component {
108
133
  /** Sorting layer of the shape */
109
134
  sortingLayer: string;
110
135
  /** Center point of the shape */
111
- sortCenter: [number, number];
112
- /** Width of the shape */
113
- width?: number;
114
- /** Height of the shape */
115
- height?: number;
116
- /** Radius of the shape */
117
- radius?: number;
118
- /** Radius X of the shape */
119
- radiusX?: number;
120
- /** Radius Y of the shape */
121
- radiusY?: number;
122
- /** Start point X coordinate for line shape */
123
- point1X?: number;
124
- /** Start point Y coordinate for line shape */
125
- point1Y?: number;
126
- /** End point X coordinate for line shape */
127
- point2X?: number;
128
- /** End point Y coordinate for line shape */
129
- point2Y?: number;
136
+ sortOffset: Point;
130
137
  /** Internal rendering data */
131
138
  renderData?: RenderData;
132
139
  /**
@@ -135,6 +142,5 @@ export declare class Shape extends Component {
135
142
  * @param config - Configuration for the shape
136
143
  */
137
144
  constructor(config: ShapeConfig);
138
- clone(): Shape;
139
145
  }
140
146
  export {};
@@ -10,8 +10,8 @@ import { Component } from '../../../engine/component';
10
10
  * // Create a basic shape
11
11
  * const shape = new Shape({
12
12
  * type: 'rectangle',
13
- * width: 100,
14
- * height: 100,
13
+ * sizeX: 100,
14
+ * sizeY: 50,
15
15
  * strokeWidth: 2,
16
16
  * strokeColor: '#000',
17
17
  * strokeAlignment: 0.5,
@@ -20,7 +20,8 @@ import { Component } from '../../../engine/component';
20
20
  * blending: 'normal',
21
21
  * disabled: false,
22
22
  * sortingLayer: 'units',
23
- * sortCenter: [0, 0],
23
+ * sortOffsetX: 0,
24
+ * sortOffsetY: 0,
24
25
  * });
25
26
  *
26
27
  * // Add to actor
@@ -34,8 +35,8 @@ import { Component } from '../../../engine/component';
34
35
  * @category Components
35
36
  */
36
37
  export class Shape extends Component {
37
- /** Type of the shape */
38
- type;
38
+ /** Geometry of the shape */
39
+ geometry;
39
40
  /** Color of the stroke */
40
41
  strokeColor;
41
42
  /** Width of the stroke */
@@ -60,25 +61,7 @@ export class Shape extends Component {
60
61
  /** Sorting layer of the shape */
61
62
  sortingLayer;
62
63
  /** Center point of the shape */
63
- sortCenter;
64
- /** Width of the shape */
65
- width;
66
- /** Height of the shape */
67
- height;
68
- /** Radius of the shape */
69
- radius;
70
- /** Radius X of the shape */
71
- radiusX;
72
- /** Radius Y of the shape */
73
- radiusY;
74
- /** Start point X coordinate for line shape */
75
- point1X;
76
- /** Start point Y coordinate for line shape */
77
- point1Y;
78
- /** End point X coordinate for line shape */
79
- point2X;
80
- /** End point Y coordinate for line shape */
81
- point2Y;
64
+ sortOffset;
82
65
  /** Internal rendering data */
83
66
  renderData;
84
67
  /**
@@ -88,7 +71,6 @@ export class Shape extends Component {
88
71
  */
89
72
  constructor(config) {
90
73
  super();
91
- this.type = config.type;
92
74
  this.strokeColor = config.strokeColor;
93
75
  this.strokeWidth = config.strokeWidth;
94
76
  this.strokeAlignment = config.strokeAlignment;
@@ -98,40 +80,40 @@ export class Shape extends Component {
98
80
  this.blending = config.blending;
99
81
  this.disabled = config.disabled;
100
82
  this.sortingLayer = config.sortingLayer;
101
- this.sortCenter = config.sortCenter;
102
- this.width = config.width;
103
- this.height = config.height;
104
- this.radius = config.radius;
105
- this.radiusX = config.radiusX;
106
- this.radiusY = config.radiusY;
107
- this.point1X = config.point1X;
108
- this.point1Y = config.point1Y;
109
- this.point2X = config.point2X;
110
- this.point2Y = config.point2Y;
111
- }
112
- clone() {
113
- return new Shape({
114
- type: this.type,
115
- strokeColor: this.strokeColor,
116
- strokeWidth: this.strokeWidth,
117
- strokeAlignment: this.strokeAlignment,
118
- pixelLine: this.pixelLine,
119
- opacity: this.opacity,
120
- blending: this.blending,
121
- disabled: this.disabled,
122
- sortingLayer: this.sortingLayer,
123
- sortCenter: this.sortCenter.slice(0),
124
- width: this.width,
125
- height: this.height,
126
- radius: this.radius,
127
- radiusX: this.radiusX,
128
- radiusY: this.radiusY,
129
- point1X: this.point1X,
130
- point1Y: this.point1Y,
131
- point2X: this.point2X,
132
- point2Y: this.point2Y,
133
- fill: this.fill,
134
- });
83
+ this.sortOffset = { x: config.sortOffsetX, y: config.sortOffsetY };
84
+ switch (config.type) {
85
+ case 'rectangle':
86
+ this.geometry = {
87
+ type: config.type,
88
+ size: { x: config.sizeX, y: config.sizeY },
89
+ };
90
+ break;
91
+ case 'roundRectangle':
92
+ this.geometry = {
93
+ type: config.type,
94
+ size: { x: config.sizeX, y: config.sizeY },
95
+ radius: config.radius,
96
+ };
97
+ break;
98
+ case 'circle':
99
+ this.geometry = {
100
+ type: config.type,
101
+ radius: config.radius,
102
+ };
103
+ break;
104
+ case 'ellipse':
105
+ this.geometry = {
106
+ type: config.type,
107
+ radius: { x: config.radiusX, y: config.radiusY },
108
+ };
109
+ break;
110
+ case 'line':
111
+ this.geometry = {
112
+ type: config.type,
113
+ point1: { x: config.point1X, y: config.point1Y },
114
+ point2: { x: config.point2X, y: config.point2Y },
115
+ };
116
+ }
135
117
  }
136
118
  }
137
119
  Shape.componentName = 'Shape';
@@ -1,5 +1,6 @@
1
1
  import type { Sprite as PixiSprite, TilingSprite } from 'pixi.js';
2
2
  import { Component } from '../../../engine/component';
3
+ import type { Point } from '../../../engine/math-lib';
3
4
  import { type BlendingMode } from '../../types/view';
4
5
  interface RenderData {
5
6
  view: PixiSprite | TilingSprite;
@@ -16,7 +17,8 @@ export interface SpriteConfig {
16
17
  flipX: boolean;
17
18
  flipY: boolean;
18
19
  sortingLayer: string;
19
- sortCenter: [number, number];
20
+ sortOffsetX: number;
21
+ sortOffsetY: number;
20
22
  fit: FitType;
21
23
  color: string;
22
24
  blending: BlendingMode;
@@ -40,7 +42,8 @@ export interface SpriteConfig {
40
42
  * flipX: false,
41
43
  * flipY: false,
42
44
  * sortingLayer: 'units',
43
- * sortCenter: [0, 0],
45
+ * sortOffsetX: 0,
46
+ * sortOffsetY: 0,
44
47
  * fit: 'stretch',
45
48
  * color: '#ffffff',
46
49
  * blending: 'normal',
@@ -76,7 +79,7 @@ export declare class Sprite extends Component {
76
79
  /** Sorting layer name for rendering order */
77
80
  sortingLayer: string;
78
81
  /** Center point for sorting calculations */
79
- sortCenter: [number, number];
82
+ sortOffset: Point;
80
83
  /** Current frame to render */
81
84
  currentFrame?: number;
82
85
  /** How the texture should fit within the sprite bounds */
@@ -95,5 +98,4 @@ export declare class Sprite extends Component {
95
98
  * @param config - Configuration for the sprite
96
99
  */
97
100
  constructor(config: SpriteConfig);
98
- clone(): Sprite;
99
101
  }
@@ -16,7 +16,8 @@ import { Component } from '../../../engine/component';
16
16
  * flipX: false,
17
17
  * flipY: false,
18
18
  * sortingLayer: 'units',
19
- * sortCenter: [0, 0],
19
+ * sortOffsetX: 0,
20
+ * sortOffsetY: 0,
20
21
  * fit: 'stretch',
21
22
  * color: '#ffffff',
22
23
  * blending: 'normal',
@@ -52,7 +53,7 @@ export class Sprite extends Component {
52
53
  /** Sorting layer name for rendering order */
53
54
  sortingLayer;
54
55
  /** Center point for sorting calculations */
55
- sortCenter;
56
+ sortOffset;
56
57
  /** Current frame to render */
57
58
  currentFrame;
58
59
  /** How the texture should fit within the sprite bounds */
@@ -81,28 +82,11 @@ export class Sprite extends Component {
81
82
  this.flipY = config.flipY;
82
83
  this.disabled = config.disabled;
83
84
  this.sortingLayer = config.sortingLayer;
84
- this.sortCenter = config.sortCenter;
85
+ this.sortOffset = { x: config.sortOffsetX, y: config.sortOffsetY };
85
86
  this.fit = config.fit;
86
87
  this.color = config.color ?? '#ffffff';
87
88
  this.blending = config.blending ?? 'normal';
88
89
  this.opacity = config.opacity ?? 1;
89
90
  }
90
- clone() {
91
- return new Sprite({
92
- src: this.src,
93
- width: this.width,
94
- height: this.height,
95
- slice: this.slice,
96
- flipX: this.flipX,
97
- flipY: this.flipY,
98
- disabled: this.disabled,
99
- sortingLayer: this.sortingLayer,
100
- sortCenter: this.sortCenter.slice(0),
101
- fit: this.fit,
102
- color: this.color,
103
- blending: this.blending,
104
- opacity: this.opacity,
105
- });
106
- }
107
91
  }
108
92
  Sprite.componentName = 'Sprite';
@@ -95,5 +95,4 @@ export declare class Transform extends Component {
95
95
  * Useful for converting world-space coordinates to local space.
96
96
  */
97
97
  get invertedWorldMatrix(): Matrix;
98
- clone(): Transform;
99
98
  }