@cyclonium/physics-2d 0.0.100

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 (65) hide show
  1. package/lib/body-collider-link.d.ts +32 -0
  2. package/lib/body-collider-link.js +164 -0
  3. package/lib/character-controller-2d.d.ts +69 -0
  4. package/lib/character-controller-2d.js +399 -0
  5. package/lib/collider-2d.d.ts +81 -0
  6. package/lib/collider-2d.js +364 -0
  7. package/lib/colliders/box-collider-2d.d.ts +20 -0
  8. package/lib/colliders/box-collider-2d.js +84 -0
  9. package/lib/colliders/capsule-collider-2d.d.ts +17 -0
  10. package/lib/colliders/capsule-collider-2d.js +78 -0
  11. package/lib/colliders/circle-collider-2d.d.ts +14 -0
  12. package/lib/colliders/circle-collider-2d.js +59 -0
  13. package/lib/colliders/polygon-collider-2d.d.ts +17 -0
  14. package/lib/colliders/polygon-collider-2d.js +77 -0
  15. package/lib/collision-matrix.d.ts +12 -0
  16. package/lib/collision-matrix.js +70 -0
  17. package/lib/contact.d.ts +7 -0
  18. package/lib/contact.js +2 -0
  19. package/lib/exchange.d.ts +5 -0
  20. package/lib/exchange.js +23 -0
  21. package/lib/gizmo-headless.d.ts +7 -0
  22. package/lib/gizmo-headless.js +7 -0
  23. package/lib/gizmo.d.ts +13 -0
  24. package/lib/gizmo.js +122 -0
  25. package/lib/index.d.ts +20 -0
  26. package/lib/index.js +20 -0
  27. package/lib/physics-2d-debugger-headless.d.ts +6 -0
  28. package/lib/physics-2d-debugger-headless.js +9 -0
  29. package/lib/physics-2d-debugger.d.ts +11 -0
  30. package/lib/physics-2d-debugger.js +146 -0
  31. package/lib/physics-2d-settings.d.ts +13 -0
  32. package/lib/physics-2d-settings.js +53 -0
  33. package/lib/physics-component-2d-base.d.ts +22 -0
  34. package/lib/physics-component-2d-base.js +85 -0
  35. package/lib/physics-world-2d-scene-component.d.ts +20 -0
  36. package/lib/physics-world-2d-scene-component.js +107 -0
  37. package/lib/physics-world-2d.d.ts +103 -0
  38. package/lib/physics-world-2d.js +506 -0
  39. package/lib/physics-world-registry.d.ts +6 -0
  40. package/lib/physics-world-registry.js +26 -0
  41. package/lib/px2-impl.d.ts +4 -0
  42. package/lib/px2-impl.js +18 -0
  43. package/lib/rigid-body-2d.d.ts +72 -0
  44. package/lib/rigid-body-2d.js +391 -0
  45. package/lib/scene-query-probe-2d.d.ts +102 -0
  46. package/lib/scene-query-probe-2d.js +223 -0
  47. package/lib/scene-query-probes/box-scene-query-probe-2d.d.ts +21 -0
  48. package/lib/scene-query-probes/box-scene-query-probe-2d.js +62 -0
  49. package/lib/scene-query-probes/capsule-scene-query-probe-2d.d.ts +27 -0
  50. package/lib/scene-query-probes/capsule-scene-query-probe-2d.js +96 -0
  51. package/lib/scene-query-probes/circle-scene-query-probe-2d.d.ts +20 -0
  52. package/lib/scene-query-probes/circle-scene-query-probe-2d.js +64 -0
  53. package/lib/scene-query.d.ts +67 -0
  54. package/lib/scene-query.js +128 -0
  55. package/lib/shared.d.ts +9 -0
  56. package/lib/shared.js +42 -0
  57. package/lib/utils/3-to-2.d.ts +3 -0
  58. package/lib/utils/3-to-2.js +12 -0
  59. package/lib/wasm-binary-helper/index.d.ts +6 -0
  60. package/lib/wasm-binary-helper/index.js +14 -0
  61. package/lib/wasm-binary-helper/wasm-binary-id.d.ts +2 -0
  62. package/lib/wasm-binary-helper/wasm-binary-id.js +2 -0
  63. package/lib/wasm-binary-helper.d.ts +6 -0
  64. package/lib/wasm-binary-helper.js +6 -0
  65. package/package.json +50 -0
@@ -0,0 +1,223 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { CCString } from 'cc';
8
+ import { EDITOR_NOT_IN_PREVIEW } from 'cc/env';
9
+ import { Transform2DComponent } from '@cyclonium/core/2d';
10
+ import { editable, idem, requiresComponent, serializable } from '@cyclonium/core/legacy-decorator';
11
+ import { cycloBuiltinClass } from '@cyclonium/core/internal';
12
+ import { Vec2 } from '@cyclonium/core/math/vec2';
13
+ import { PhysicsComponent2DBase } from './physics-component-2d-base.js';
14
+ import { SceneQueryFilter } from './scene-query.js';
15
+ /**
16
+ * Query-only 2D physics probe used for authoring reusable scene queries.
17
+ *
18
+ * It does not create a collider, participate in simulation, or emit contact events.
19
+ */
20
+ let SceneQueryProbe2D = class SceneQueryProbe2D extends PhysicsComponent2DBase {
21
+ /**
22
+ * Physics tags this probe can hit.
23
+ *
24
+ * Tags are resolved through the current PhysicsWorld2D and cached until the filter config changes.
25
+ * Assign a new array to change tags; in-place mutations are not supported.
26
+ */
27
+ get targetTags() {
28
+ return this._targetTags;
29
+ }
30
+ set targetTags(value) {
31
+ this._targetTags = value.slice();
32
+ this._invalidateFilter();
33
+ }
34
+ /**
35
+ * Whether dynamic rigid bodies are included in this probe's queries.
36
+ */
37
+ get dynamics() {
38
+ return this._dynamics;
39
+ }
40
+ set dynamics(value) {
41
+ this._dynamics = value;
42
+ this._invalidateFilter();
43
+ }
44
+ /**
45
+ * Whether fixed rigid bodies are included in this probe's queries.
46
+ */
47
+ get fixed() {
48
+ return this._fixed;
49
+ }
50
+ set fixed(value) {
51
+ this._fixed = value;
52
+ this._invalidateFilter();
53
+ }
54
+ /**
55
+ * Whether kinematic rigid bodies are included in this probe's queries.
56
+ */
57
+ get kinematics() {
58
+ return this._kinematics;
59
+ }
60
+ set kinematics(value) {
61
+ this._kinematics = value;
62
+ this._invalidateFilter();
63
+ }
64
+ /**
65
+ * Whether sensor colliders are included in this probe's queries.
66
+ */
67
+ get sensors() {
68
+ return this._sensors;
69
+ }
70
+ set sensors(value) {
71
+ this._sensors = value;
72
+ this._invalidateFilter();
73
+ }
74
+ /**
75
+ * Whether solid colliders are included in this probe's queries.
76
+ */
77
+ get solids() {
78
+ return this._solids;
79
+ }
80
+ set solids(value) {
81
+ this._solids = value;
82
+ this._invalidateFilter();
83
+ }
84
+ /**
85
+ * Finds colliders overlapping this probe's current world transform and filter.
86
+ */
87
+ intersect() {
88
+ const world = this.world;
89
+ if (!world) {
90
+ return [];
91
+ }
92
+ return [...this.intersectWithWorld(world, this._getFilter(world))];
93
+ }
94
+ /**
95
+ * Casts this probe from its current world transform.
96
+ *
97
+ * `direction` is normalized internally; `maxDistance` defines the sweep length.
98
+ */
99
+ sweep(direction, maxDistance, opts = {}) {
100
+ return this.sweepFrom({
101
+ position: this.queryPosition,
102
+ rotation: this.queryRotation,
103
+ }, direction, maxDistance, opts);
104
+ }
105
+ /**
106
+ * Casts this probe from an explicit transform without moving the node.
107
+ *
108
+ * Useful for previous-to-current authority sweeps.
109
+ */
110
+ sweepFrom(transform, direction, maxDistance, opts = {}) {
111
+ const world = this.world;
112
+ if (!world) {
113
+ return;
114
+ }
115
+ return this.sweepWithWorld(world, transform, direction, maxDistance, opts, this._getFilter(world));
116
+ }
117
+ get queryPosition() {
118
+ return this._transform.position;
119
+ }
120
+ get queryRotation() {
121
+ return this._transform.rotation;
122
+ }
123
+ get queryScale() {
124
+ return this._transform.scale;
125
+ }
126
+ onAttachToWorld(_world) {
127
+ }
128
+ onDetachFromWorld(_world) {
129
+ this._clearFilterCache();
130
+ }
131
+ onUpdate() {
132
+ if (EDITOR_NOT_IN_PREVIEW) {
133
+ this.drawGizmo();
134
+ }
135
+ }
136
+ _getFilter(world) {
137
+ if (!this._filterCache || this._filterWorld !== world || this._filterDirty) {
138
+ this._filterCache = this._createFilter(world);
139
+ this._filterWorld = world;
140
+ this._filterDirty = false;
141
+ }
142
+ return this._filterCache;
143
+ }
144
+ _createFilter(world) {
145
+ const filter = new SceneQueryFilter();
146
+ filter.dynamics = this._dynamics;
147
+ filter.fixed = this._fixed;
148
+ filter.kinematics = this._kinematics;
149
+ filter.sensors = this._sensors;
150
+ filter.solids = this._solids;
151
+ for (const tag of this._targetTags) {
152
+ filter.addTargetTag(world.getTagId(tag));
153
+ }
154
+ return filter;
155
+ }
156
+ _invalidateFilter() {
157
+ this._filterDirty = true;
158
+ }
159
+ _clearFilterCache() {
160
+ this._filterCache = undefined;
161
+ this._filterWorld = undefined;
162
+ this._filterDirty = true;
163
+ }
164
+ _targetTags = [];
165
+ _dynamics = true;
166
+ _fixed = true;
167
+ _kinematics = true;
168
+ _sensors = true;
169
+ _solids = true;
170
+ _filterCache = undefined;
171
+ _filterWorld = undefined;
172
+ _filterDirty = true;
173
+ get _transform() { return undefined; }
174
+ };
175
+ __decorate([
176
+ editable(CCString)
177
+ ], SceneQueryProbe2D.prototype, "targetTags", null);
178
+ __decorate([
179
+ editable,
180
+ idem
181
+ ], SceneQueryProbe2D.prototype, "dynamics", null);
182
+ __decorate([
183
+ editable,
184
+ idem
185
+ ], SceneQueryProbe2D.prototype, "fixed", null);
186
+ __decorate([
187
+ editable,
188
+ idem
189
+ ], SceneQueryProbe2D.prototype, "kinematics", null);
190
+ __decorate([
191
+ editable,
192
+ idem
193
+ ], SceneQueryProbe2D.prototype, "sensors", null);
194
+ __decorate([
195
+ editable,
196
+ idem
197
+ ], SceneQueryProbe2D.prototype, "solids", null);
198
+ __decorate([
199
+ serializable
200
+ ], SceneQueryProbe2D.prototype, "_targetTags", void 0);
201
+ __decorate([
202
+ serializable
203
+ ], SceneQueryProbe2D.prototype, "_dynamics", void 0);
204
+ __decorate([
205
+ serializable
206
+ ], SceneQueryProbe2D.prototype, "_fixed", void 0);
207
+ __decorate([
208
+ serializable
209
+ ], SceneQueryProbe2D.prototype, "_kinematics", void 0);
210
+ __decorate([
211
+ serializable
212
+ ], SceneQueryProbe2D.prototype, "_sensors", void 0);
213
+ __decorate([
214
+ serializable
215
+ ], SceneQueryProbe2D.prototype, "_solids", void 0);
216
+ __decorate([
217
+ requiresComponent(Transform2DComponent)
218
+ ], SceneQueryProbe2D.prototype, "_transform", null);
219
+ SceneQueryProbe2D = __decorate([
220
+ cycloBuiltinClass({ abstract: true })
221
+ ], SceneQueryProbe2D);
222
+ export { SceneQueryProbe2D };
223
+ //# sourceMappingURL=scene-query-probe-2d.js.map
@@ -0,0 +1,21 @@
1
+ import { Vec2 } from '@cyclonium/core/math/vec2';
2
+ import { SceneQueryProbe2D, type SceneQueryProbeSweepOptions } from '../scene-query-probe-2d.js';
3
+ import type { SceneQueryFilter } from '../scene-query.js';
4
+ import type { PhysicsWorld2D, ShapeTransformDesc } from '../physics-world-2d.js';
5
+ /**
6
+ * Query-only probe that uses an oriented box shape.
7
+ */
8
+ export declare class BoxSceneQueryProbe2D extends SceneQueryProbe2D {
9
+ /**
10
+ * Half-size of the query box before Transform2D scale is applied.
11
+ */
12
+ get halfExtents(): Vec2;
13
+ set halfExtents(value: Vec2);
14
+ protected intersectWithWorld(world: PhysicsWorld2D, filter: SceneQueryFilter): Generator<import("../collider-2d.js").Collider2D, void, unknown>;
15
+ protected sweepWithWorld(world: PhysicsWorld2D, transform: ShapeTransformDesc, direction: Vec2, maxDistance: number, opts: SceneQueryProbeSweepOptions, filter: SceneQueryFilter): import("../scene-query.js").ColliderShapeCastHit | undefined;
16
+ protected drawGizmo(): void;
17
+ private _getScaledHalfExtents;
18
+ private _halfExtents;
19
+ private _scaledHalfExtents;
20
+ }
21
+ //# sourceMappingURL=box-scene-query-probe-2d.d.ts.map
@@ -0,0 +1,62 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { editable, executeInEditMode, idem, serializable } from '@cyclonium/core/legacy-decorator';
8
+ import { cycloBuiltinClass } from '@cyclonium/core/internal';
9
+ import { Vec2 } from '@cyclonium/core/math/vec2';
10
+ import { drawBoxSceneQueryProbe2DGizmo } from '#gizmo';
11
+ import { SceneQueryProbe2D } from '../scene-query-probe-2d.js';
12
+ /**
13
+ * Query-only probe that uses an oriented box shape.
14
+ */
15
+ let BoxSceneQueryProbe2D = class BoxSceneQueryProbe2D extends SceneQueryProbe2D {
16
+ /**
17
+ * Half-size of the query box before Transform2D scale is applied.
18
+ */
19
+ get halfExtents() {
20
+ return this._halfExtents;
21
+ }
22
+ set halfExtents(value) {
23
+ Vec2.assign(this._halfExtents, value);
24
+ }
25
+ intersectWithWorld(world, filter) {
26
+ return world.intersectWithBox(this.queryPosition, this._getScaledHalfExtents(), filter, this.queryRotation);
27
+ }
28
+ sweepWithWorld(world, transform, direction, maxDistance, opts, filter) {
29
+ return world.castRect({
30
+ halfExtents: this._getScaledHalfExtents(),
31
+ position: transform.position,
32
+ rotation: transform.rotation,
33
+ }, {
34
+ ...opts,
35
+ direction,
36
+ maxDistance,
37
+ filter,
38
+ });
39
+ }
40
+ drawGizmo() {
41
+ drawBoxSceneQueryProbe2DGizmo(this);
42
+ }
43
+ _getScaledHalfExtents() {
44
+ const scale = this.queryScale;
45
+ return Vec2.set(this._scaledHalfExtents, this._halfExtents.x * scale.x, this._halfExtents.y * scale.y);
46
+ }
47
+ _halfExtents = new Vec2(1, 1);
48
+ _scaledHalfExtents = new Vec2();
49
+ };
50
+ __decorate([
51
+ editable,
52
+ idem
53
+ ], BoxSceneQueryProbe2D.prototype, "halfExtents", null);
54
+ __decorate([
55
+ serializable
56
+ ], BoxSceneQueryProbe2D.prototype, "_halfExtents", void 0);
57
+ BoxSceneQueryProbe2D = __decorate([
58
+ cycloBuiltinClass('BoxSceneQueryProbe2D'),
59
+ executeInEditMode
60
+ ], BoxSceneQueryProbe2D);
61
+ export { BoxSceneQueryProbe2D };
62
+ //# sourceMappingURL=box-scene-query-probe-2d.js.map
@@ -0,0 +1,27 @@
1
+ import { Vec2 } from '@cyclonium/core/math/vec2';
2
+ import { SceneQueryProbe2D, type SceneQueryProbeSweepOptions } from '../scene-query-probe-2d.js';
3
+ import type { SceneQueryFilter } from '../scene-query.js';
4
+ import type { PhysicsWorld2D, ShapeTransformDesc } from '../physics-world-2d.js';
5
+ /**
6
+ * Query-only probe that uses a vertical capsule shape.
7
+ */
8
+ export declare class CapsuleSceneQueryProbe2D extends SceneQueryProbe2D {
9
+ /**
10
+ * Radius of the capsule caps before Transform2D scale is applied.
11
+ */
12
+ get radius(): number;
13
+ set radius(value: number);
14
+ /**
15
+ * Half length of the capsule center segment before Transform2D scale is applied.
16
+ */
17
+ get halfHeight(): number;
18
+ set halfHeight(value: number);
19
+ protected intersectWithWorld(world: PhysicsWorld2D, filter: SceneQueryFilter): Generator<import("../collider-2d.js").Collider2D, void, unknown>;
20
+ protected sweepWithWorld(world: PhysicsWorld2D, transform: ShapeTransformDesc, direction: Vec2, maxDistance: number, opts: SceneQueryProbeSweepOptions, filter: SceneQueryFilter): import("../scene-query.js").ColliderShapeCastHit | undefined;
21
+ protected drawGizmo(): void;
22
+ private _getUniformScale;
23
+ private _getScaledShape;
24
+ private _radius;
25
+ private _halfHeight;
26
+ }
27
+ //# sourceMappingURL=capsule-scene-query-probe-2d.d.ts.map
@@ -0,0 +1,96 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { editable, executeInEditMode, idem, serializable } from '@cyclonium/core/legacy-decorator';
8
+ import { cycloBuiltinClass } from '@cyclonium/core/internal';
9
+ import { Vec2 } from '@cyclonium/core/math/vec2';
10
+ import { drawCapsuleSceneQueryProbe2DGizmo } from '#gizmo';
11
+ import { SceneQueryProbe2D } from '../scene-query-probe-2d.js';
12
+ /**
13
+ * Query-only probe that uses a vertical capsule shape.
14
+ */
15
+ let CapsuleSceneQueryProbe2D = class CapsuleSceneQueryProbe2D extends SceneQueryProbe2D {
16
+ /**
17
+ * Radius of the capsule caps before Transform2D scale is applied.
18
+ */
19
+ get radius() {
20
+ return this._radius;
21
+ }
22
+ set radius(value) {
23
+ this._radius = value;
24
+ }
25
+ /**
26
+ * Half length of the capsule center segment before Transform2D scale is applied.
27
+ */
28
+ get halfHeight() {
29
+ return this._halfHeight;
30
+ }
31
+ set halfHeight(value) {
32
+ this._halfHeight = value;
33
+ }
34
+ intersectWithWorld(world, filter) {
35
+ const shape = this._getScaledShape();
36
+ return world.intersectWithCapsule({
37
+ halfHeight: shape.halfHeight,
38
+ radius: shape.radius,
39
+ position: this.queryPosition,
40
+ rotation: this.queryRotation,
41
+ }, filter);
42
+ }
43
+ sweepWithWorld(world, transform, direction, maxDistance, opts, filter) {
44
+ const shape = this._getScaledShape();
45
+ return world.castCapsule({
46
+ halfHeight: shape.halfHeight,
47
+ radius: shape.radius,
48
+ position: transform.position,
49
+ rotation: transform.rotation,
50
+ }, {
51
+ ...opts,
52
+ direction,
53
+ maxDistance,
54
+ filter,
55
+ });
56
+ }
57
+ drawGizmo() {
58
+ drawCapsuleSceneQueryProbe2DGizmo(this);
59
+ }
60
+ _getUniformScale() {
61
+ const scale = this.queryScale;
62
+ if (scale.x !== scale.y) {
63
+ console.warn('CapsuleSceneQueryProbe2D should have uniform scale');
64
+ }
65
+ return scale.x;
66
+ }
67
+ _getScaledShape() {
68
+ const scale = this._getUniformScale();
69
+ return {
70
+ halfHeight: this._halfHeight * scale,
71
+ radius: this._radius * scale,
72
+ };
73
+ }
74
+ _radius = 1;
75
+ _halfHeight = 1;
76
+ };
77
+ __decorate([
78
+ editable({ min: 0 }),
79
+ idem
80
+ ], CapsuleSceneQueryProbe2D.prototype, "radius", null);
81
+ __decorate([
82
+ editable({ min: 0 }),
83
+ idem
84
+ ], CapsuleSceneQueryProbe2D.prototype, "halfHeight", null);
85
+ __decorate([
86
+ serializable
87
+ ], CapsuleSceneQueryProbe2D.prototype, "_radius", void 0);
88
+ __decorate([
89
+ serializable
90
+ ], CapsuleSceneQueryProbe2D.prototype, "_halfHeight", void 0);
91
+ CapsuleSceneQueryProbe2D = __decorate([
92
+ cycloBuiltinClass('CapsuleSceneQueryProbe2D'),
93
+ executeInEditMode
94
+ ], CapsuleSceneQueryProbe2D);
95
+ export { CapsuleSceneQueryProbe2D };
96
+ //# sourceMappingURL=capsule-scene-query-probe-2d.js.map
@@ -0,0 +1,20 @@
1
+ import { Vec2 } from '@cyclonium/core/math/vec2';
2
+ import { SceneQueryProbe2D, type SceneQueryProbeSweepOptions } from '../scene-query-probe-2d.js';
3
+ import type { SceneQueryFilter } from '../scene-query.js';
4
+ import type { PhysicsWorld2D, ShapeTransformDesc } from '../physics-world-2d.js';
5
+ /**
6
+ * Query-only probe that uses a circle shape.
7
+ */
8
+ export declare class CircleSceneQueryProbe2D extends SceneQueryProbe2D {
9
+ /**
10
+ * Radius of the query circle before Transform2D scale is applied.
11
+ */
12
+ get radius(): number;
13
+ set radius(value: number);
14
+ protected intersectWithWorld(world: PhysicsWorld2D, filter: SceneQueryFilter): Generator<import("../collider-2d.js").Collider2D, void, unknown>;
15
+ protected sweepWithWorld(world: PhysicsWorld2D, transform: ShapeTransformDesc, direction: Vec2, maxDistance: number, opts: SceneQueryProbeSweepOptions, filter: SceneQueryFilter): import("../scene-query.js").ColliderShapeCastHit | undefined;
16
+ protected drawGizmo(): void;
17
+ private _getScaledRadius;
18
+ private _radius;
19
+ }
20
+ //# sourceMappingURL=circle-scene-query-probe-2d.d.ts.map
@@ -0,0 +1,64 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { editable, executeInEditMode, idem, serializable } from '@cyclonium/core/legacy-decorator';
8
+ import { cycloBuiltinClass } from '@cyclonium/core/internal';
9
+ import { Vec2 } from '@cyclonium/core/math/vec2';
10
+ import { drawCircleSceneQueryProbe2DGizmo } from '#gizmo';
11
+ import { SceneQueryProbe2D } from '../scene-query-probe-2d.js';
12
+ /**
13
+ * Query-only probe that uses a circle shape.
14
+ */
15
+ let CircleSceneQueryProbe2D = class CircleSceneQueryProbe2D extends SceneQueryProbe2D {
16
+ /**
17
+ * Radius of the query circle before Transform2D scale is applied.
18
+ */
19
+ get radius() {
20
+ return this._radius;
21
+ }
22
+ set radius(value) {
23
+ this._radius = value;
24
+ }
25
+ intersectWithWorld(world, filter) {
26
+ return world.intersectWithCircle(this.queryPosition, this._getScaledRadius(), filter, this.queryRotation);
27
+ }
28
+ sweepWithWorld(world, transform, direction, maxDistance, opts, filter) {
29
+ return world.castCircle({
30
+ radius: this._getScaledRadius(),
31
+ position: transform.position,
32
+ rotation: transform.rotation,
33
+ }, {
34
+ ...opts,
35
+ direction,
36
+ maxDistance,
37
+ filter,
38
+ });
39
+ }
40
+ drawGizmo() {
41
+ drawCircleSceneQueryProbe2DGizmo(this);
42
+ }
43
+ _getScaledRadius() {
44
+ const scale = this.queryScale;
45
+ if (scale.x !== scale.y) {
46
+ console.warn('CircleSceneQueryProbe2D should have uniform scale');
47
+ }
48
+ return this._radius * scale.x;
49
+ }
50
+ _radius = 1;
51
+ };
52
+ __decorate([
53
+ editable({ min: 0 }),
54
+ idem
55
+ ], CircleSceneQueryProbe2D.prototype, "radius", null);
56
+ __decorate([
57
+ serializable
58
+ ], CircleSceneQueryProbe2D.prototype, "_radius", void 0);
59
+ CircleSceneQueryProbe2D = __decorate([
60
+ cycloBuiltinClass('CircleSceneQueryProbe2D'),
61
+ executeInEditMode
62
+ ], CircleSceneQueryProbe2D);
63
+ export { CircleSceneQueryProbe2D };
64
+ //# sourceMappingURL=circle-scene-query-probe-2d.js.map
@@ -0,0 +1,67 @@
1
+ import { Vec2 } from '@cyclonium/core/math/vec2';
2
+ import type { Collider2D } from './collider-2d.js';
3
+ import { px2Impl } from './px2-impl.js';
4
+ export declare class SceneQueryFilter {
5
+ constructor();
6
+ get dynamics(): boolean;
7
+ set dynamics(value: boolean);
8
+ get fixed(): boolean;
9
+ set fixed(value: boolean);
10
+ get kinematics(): boolean;
11
+ set kinematics(value: boolean);
12
+ get sensors(): boolean;
13
+ set sensors(value: boolean);
14
+ get solids(): boolean;
15
+ set solids(value: boolean);
16
+ addTargetTag(tag: number): this;
17
+ get _filterFlags_internal(): number;
18
+ get _filterGroups_internal(): number;
19
+ private _filterGroupFilter;
20
+ private _filterFlags;
21
+ private _getIncludesFlag;
22
+ private _setIncludesFlag;
23
+ }
24
+ export interface ShapeCastQueryOptions {
25
+ direction: Vec2;
26
+ maxDistance: number;
27
+ targetDistance?: number;
28
+ stopAtPenetration?: boolean;
29
+ filter?: SceneQueryFilter;
30
+ /**
31
+ * Colliders skipped by the shape cast, usually the querying object's own collider.
32
+ */
33
+ excludeColliders?: Iterable<Collider2D>;
34
+ }
35
+ export declare class ColliderShapeCastHit {
36
+ constructor(impl: px2Impl.ColliderShapeCastHit, startPosition: Vec2, direction: Vec2, collider: Collider2D);
37
+ get collider(): Collider2D;
38
+ get impl(): px2Impl.ColliderShapeCastHit;
39
+ get point(): Vec2;
40
+ get distance(): number;
41
+ get localPoint1(): Vec2;
42
+ get localPoint2(): Vec2;
43
+ get localNormal1(): Vec2;
44
+ get localNormal2(): Vec2;
45
+ private _impl;
46
+ private _startPosition;
47
+ private _direction;
48
+ private _collider;
49
+ }
50
+ export interface ShapeIntersectionQueryOptions {
51
+ filter?: SceneQueryFilter;
52
+ }
53
+ export declare class ColliderShapeIntersection {
54
+ private _collider;
55
+ constructor(_collider: Collider2D);
56
+ get collider(): Collider2D;
57
+ }
58
+ export declare class RayColliderIntersection {
59
+ constructor(collider: Collider2D, timeOfImpact: number, normal: Vec2);
60
+ get collider(): Collider2D;
61
+ get timeOfImpact(): number;
62
+ get normal(): Vec2;
63
+ private _collider;
64
+ private _timeOfImpact;
65
+ private _normal;
66
+ }
67
+ //# sourceMappingURL=scene-query.d.ts.map