@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,391 @@
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 { Transform2DComponent, TransformChangeFlagsObserver, TransformFlag } from '@cyclonium/core/2d';
8
+ import { designType, editable, idem, requiresComponent, serializable } from '@cyclonium/core/legacy-decorator';
9
+ import { Vec2 } from '@cyclonium/core/math/vec2';
10
+ import { fromPx2ImplVec2, toPx2ImplVec2 } from './exchange.js';
11
+ import { px2Impl } from './px2-impl.js';
12
+ import { PhysicsComponent2DBase } from './physics-component-2d-base.js';
13
+ import { markEnum } from '@cyclonium/core/utils';
14
+ import { createCollisionEventEmitter, ContactEventListenerFlagIndex } from './shared.js';
15
+ import { CCString } from 'cc';
16
+ import { EDITOR_NOT_IN_PREVIEW } from 'cc/env';
17
+ import { cycloBuiltinClass } from '@cyclonium/core/internal';
18
+ import { approxEqual } from '@cyclonium/core/math/number';
19
+ import { to0ToPI2 } from '@cyclonium/core/math/trigonometry';
20
+ export var RigidBody2DType;
21
+ (function (RigidBody2DType) {
22
+ RigidBody2DType["fixed"] = "fixed";
23
+ RigidBody2DType["dynamic"] = "dynamic";
24
+ RigidBody2DType["kinematicPositionBased"] = "kinematicPositionBased";
25
+ RigidBody2DType["kinematicVelocityBased"] = "kinematicVelocityBased";
26
+ })(RigidBody2DType || (RigidBody2DType = {}));
27
+ markEnum(RigidBody2DType);
28
+ var CollisionTargetTypeFilterIndex;
29
+ (function (CollisionTargetTypeFilterIndex) {
30
+ CollisionTargetTypeFilterIndex[CollisionTargetTypeFilterIndex["fixed"] = 0] = "fixed";
31
+ CollisionTargetTypeFilterIndex[CollisionTargetTypeFilterIndex["dynamic"] = 1] = "dynamic";
32
+ CollisionTargetTypeFilterIndex[CollisionTargetTypeFilterIndex["kinematic"] = 2] = "kinematic";
33
+ })(CollisionTargetTypeFilterIndex || (CollisionTargetTypeFilterIndex = {}));
34
+ const defaultBodyType = RigidBody2DType.dynamic;
35
+ function getDefaultCollisionTargetTypeFilterOf(bodyType) {
36
+ return bodyType === RigidBody2DType.dynamic
37
+ ? ((1 << CollisionTargetTypeFilterIndex.dynamic) | (1 << CollisionTargetTypeFilterIndex.fixed) | (1 << CollisionTargetTypeFilterIndex.kinematic))
38
+ : 0;
39
+ }
40
+ const SYNC_POSITION_THRESHOLD = 1e-6;
41
+ const SYNC_ROTATION_THRESHOLD = 1e-6;
42
+ let RigidBody2D = class RigidBody2D extends PhysicsComponent2DBase {
43
+ onContactBegin = createCollisionEventEmitter((hasAnyListener) => {
44
+ this._updateListenerFlag(ContactEventListenerFlagIndex.begin, hasAnyListener);
45
+ });
46
+ onContactStay = createCollisionEventEmitter((hasAnyListener) => {
47
+ this._updateListenerFlag(ContactEventListenerFlagIndex.stay, hasAnyListener);
48
+ });
49
+ onContactEnd = createCollisionEventEmitter((hasAnyListener) => {
50
+ this._updateListenerFlag(ContactEventListenerFlagIndex.end, hasAnyListener);
51
+ });
52
+ get tags() {
53
+ return this._tags;
54
+ }
55
+ set tags(value) {
56
+ this._tags = value.slice();
57
+ this._rigidBodyControlBlock?.setTags(value);
58
+ }
59
+ get type() {
60
+ return this._type;
61
+ }
62
+ set type(value) {
63
+ this._type = value;
64
+ if (EDITOR_NOT_IN_PREVIEW) {
65
+ this._collisionTargetTypeFilter = getDefaultCollisionTargetTypeFilterOf(value);
66
+ }
67
+ this._updateActiveCollisionTypes();
68
+ this._rigidBodyControlBlock?.impl.setBodyType(toPx2ImplRigidBodyType(value), true);
69
+ }
70
+ get collisionWithDynamic() {
71
+ return this._getCollisionTargetTypeFilter(CollisionTargetTypeFilterIndex.dynamic);
72
+ }
73
+ set collisionWithDynamic(value) {
74
+ this._setCollisionTargetTypeFilter(CollisionTargetTypeFilterIndex.dynamic, value);
75
+ }
76
+ get collisionWithFixed() {
77
+ return this._getCollisionTargetTypeFilter(CollisionTargetTypeFilterIndex.fixed);
78
+ }
79
+ set collisionWithFixed(value) {
80
+ this._setCollisionTargetTypeFilter(CollisionTargetTypeFilterIndex.fixed, value);
81
+ }
82
+ get collisionWithKinematic() {
83
+ return this._getCollisionTargetTypeFilter(CollisionTargetTypeFilterIndex.kinematic);
84
+ }
85
+ set collisionWithKinematic(value) {
86
+ this._setCollisionTargetTypeFilter(CollisionTargetTypeFilterIndex.kinematic, value);
87
+ }
88
+ get ccd() {
89
+ return this._ccd;
90
+ }
91
+ set ccd(value) {
92
+ this._ccd = value;
93
+ this._rigidBodyControlBlock?.impl.enableCcd(value);
94
+ }
95
+ get gravityScale() {
96
+ return this._gravityScale;
97
+ }
98
+ set gravityScale(value) {
99
+ this._gravityScale = value;
100
+ this._rigidBodyControlBlock?.impl.setGravityScale(value, true);
101
+ }
102
+ get position() {
103
+ return this._physicsPosition;
104
+ }
105
+ set position(value) {
106
+ this._setPhysicsPosition(value);
107
+ }
108
+ get rotation() {
109
+ return this._physicsRotation;
110
+ }
111
+ set rotation(value) {
112
+ this._setPhysicsRotation(to0ToPI2(value));
113
+ }
114
+ get linearVelocity() {
115
+ if (this._rigidBodyControlBlock) {
116
+ return fromPx2ImplVec2(this._rigidBodyControlBlock.impl.linvel(), this._linearVelocity);
117
+ }
118
+ else {
119
+ return this._linearVelocity.set(0, 0);
120
+ }
121
+ }
122
+ set linearVelocity(value) {
123
+ Vec2.assign(this._linearVelocity, value);
124
+ switch (this._type) {
125
+ default:
126
+ break;
127
+ case RigidBody2DType.dynamic:
128
+ case RigidBody2DType.kinematicVelocityBased: {
129
+ if (this._rigidBodyControlBlock) {
130
+ this._rigidBodyControlBlock.impl.setLinvel(toPx2ImplVec2(value), true);
131
+ }
132
+ break;
133
+ }
134
+ }
135
+ }
136
+ hasTag(tag) {
137
+ return this._tags.includes(tag);
138
+ }
139
+ addTag(tag) {
140
+ if (!this._tags.includes(tag)) {
141
+ this._tags.push(tag);
142
+ }
143
+ }
144
+ setNextKinematicPosition(position) {
145
+ this._rigidBodyControlBlock?.impl.setNextKinematicTranslation(position);
146
+ }
147
+ setNextKinematicRotation(rotation) {
148
+ this._rigidBodyControlBlock?.impl.setNextKinematicRotation(rotation);
149
+ }
150
+ get impl() {
151
+ return this._rigidBodyControlBlock?.impl;
152
+ }
153
+ onDestroy() {
154
+ super.onDestroy();
155
+ this._destroyImplBody();
156
+ }
157
+ onAttachToWorld(world) {
158
+ const transform = this._transform;
159
+ this._transformChangeFlagsObserver.observe(transform);
160
+ this._physicsPosition.copyFrom(transform.position);
161
+ this._physicsRotation = transform.rotation;
162
+ const desc = new px2Impl.RigidBodyDesc(toPx2ImplRigidBodyType(this._type))
163
+ .setEnabled(this.enabled)
164
+ .setTranslation(this._physicsPosition.x, this._physicsPosition.y)
165
+ .setRotation(this._physicsRotation)
166
+ .setCcdEnabled(this._ccd)
167
+ .setLinvel(this._linearVelocity.x, this._linearVelocity.y)
168
+ .setGravityScale(this._gravityScale);
169
+ const body = world._createRigidBody(this, desc);
170
+ body.setTags(this._tags);
171
+ this._rigidBodyControlBlock = body;
172
+ this._updateActiveCollisionTypes();
173
+ body.impl.setEnabled(this.enabledInHierarchy);
174
+ }
175
+ onDetachFromWorld(_world) {
176
+ this._destroyImplBody();
177
+ }
178
+ onEnabled() {
179
+ super.onEnabled();
180
+ this._rigidBodyControlBlock?.impl.setEnabled(true);
181
+ }
182
+ onDisabled() {
183
+ this._rigidBodyControlBlock?.impl.setEnabled(false);
184
+ }
185
+ onStart() {
186
+ super.onStart();
187
+ }
188
+ onSyncTransforms(forceTransform, _forceScale) {
189
+ this._syncToPhysics(forceTransform);
190
+ }
191
+ onAfterPhysicsStep() {
192
+ this._syncFromPhysics();
193
+ }
194
+ _rigidBodyControlBlock = null;
195
+ _tags = [];
196
+ _type = defaultBodyType;
197
+ _ccd = false;
198
+ _gravityScale = 1.0;
199
+ _collisionTargetTypeFilter = getDefaultCollisionTargetTypeFilterOf(defaultBodyType);
200
+ _physicsPosition = new Vec2();
201
+ _physicsRotation = 0.0;
202
+ _linearVelocity = new Vec2();
203
+ _listenerFlags = 0;
204
+ _transformChangeFlagsObserver = new TransformChangeFlagsObserver();
205
+ get _transform() { return undefined; }
206
+ _getCollisionTargetTypeFilter(filterIndex) {
207
+ return !!(this._collisionTargetTypeFilter & (1 << filterIndex));
208
+ }
209
+ _setCollisionTargetTypeFilter(filterIndex, value) {
210
+ if (value) {
211
+ this._collisionTargetTypeFilter |= 1 << filterIndex;
212
+ }
213
+ else {
214
+ this._collisionTargetTypeFilter &= ~(1 << filterIndex);
215
+ }
216
+ this._updateActiveCollisionTypes();
217
+ }
218
+ _updateActiveCollisionTypes() {
219
+ let combined = 0;
220
+ switch (this._type) {
221
+ case RigidBody2DType.dynamic:
222
+ if (this._getCollisionTargetTypeFilter(CollisionTargetTypeFilterIndex.dynamic)) {
223
+ combined |= px2Impl.ActiveCollisionTypes.DYNAMIC_DYNAMIC;
224
+ }
225
+ if (this._getCollisionTargetTypeFilter(CollisionTargetTypeFilterIndex.fixed)) {
226
+ combined |= px2Impl.ActiveCollisionTypes.DYNAMIC_FIXED;
227
+ }
228
+ if (this._getCollisionTargetTypeFilter(CollisionTargetTypeFilterIndex.kinematic)) {
229
+ combined |= px2Impl.ActiveCollisionTypes.DYNAMIC_KINEMATIC;
230
+ }
231
+ break;
232
+ case RigidBody2DType.fixed:
233
+ if (this._getCollisionTargetTypeFilter(CollisionTargetTypeFilterIndex.dynamic)) {
234
+ combined |= px2Impl.ActiveCollisionTypes.DYNAMIC_FIXED;
235
+ }
236
+ if (this._getCollisionTargetTypeFilter(CollisionTargetTypeFilterIndex.fixed)) {
237
+ combined |= px2Impl.ActiveCollisionTypes.FIXED_FIXED;
238
+ }
239
+ if (this._getCollisionTargetTypeFilter(CollisionTargetTypeFilterIndex.kinematic)) {
240
+ combined |= px2Impl.ActiveCollisionTypes.KINEMATIC_FIXED;
241
+ }
242
+ break;
243
+ case RigidBody2DType.kinematicPositionBased:
244
+ case RigidBody2DType.kinematicVelocityBased:
245
+ if (this._getCollisionTargetTypeFilter(CollisionTargetTypeFilterIndex.dynamic)) {
246
+ combined |= px2Impl.ActiveCollisionTypes.DYNAMIC_KINEMATIC;
247
+ }
248
+ if (this._getCollisionTargetTypeFilter(CollisionTargetTypeFilterIndex.fixed)) {
249
+ combined |= px2Impl.ActiveCollisionTypes.KINEMATIC_FIXED;
250
+ }
251
+ if (this._getCollisionTargetTypeFilter(CollisionTargetTypeFilterIndex.kinematic)) {
252
+ combined |= px2Impl.ActiveCollisionTypes.KINEMATIC_KINEMATIC;
253
+ }
254
+ break;
255
+ }
256
+ this._rigidBodyControlBlock?.setActiveCollisionTypes(combined);
257
+ }
258
+ _updateListenerFlag(flagIndex, hasAny) {
259
+ if (hasAny) {
260
+ this._listenerFlags |= 1 << flagIndex;
261
+ }
262
+ else {
263
+ this._listenerFlags &= ~(1 << flagIndex);
264
+ }
265
+ if (this._rigidBodyControlBlock) {
266
+ this._rigidBodyControlBlock.enableCollisionEvents(this._listenerFlags !== 0);
267
+ }
268
+ }
269
+ _destroyImplBody() {
270
+ const impl = this._rigidBodyControlBlock?.impl;
271
+ const world = this.world;
272
+ if (impl) {
273
+ world?._removeRigidBody(impl);
274
+ }
275
+ this._rigidBodyControlBlock = null;
276
+ this._physicsPosition.set(0, 0);
277
+ this._physicsRotation = 0.0;
278
+ }
279
+ _setPhysicsPosition(position) {
280
+ this._physicsPosition.copyFrom(position);
281
+ this._rigidBodyControlBlock?.impl.setTranslation(toPx2ImplVec2(position), true);
282
+ }
283
+ _setPhysicsRotation(rotation) {
284
+ this._physicsRotation = rotation;
285
+ this._rigidBodyControlBlock?.impl.setRotation(rotation, true);
286
+ }
287
+ _syncToPhysics(outdated) {
288
+ const implBody = this._rigidBodyControlBlock?.impl;
289
+ if (!implBody) {
290
+ return;
291
+ }
292
+ const transform = this._transform;
293
+ const changeFlags = this._transformChangeFlagsObserver.sync();
294
+ if (outdated || changeFlags & TransformFlag.position) {
295
+ if (!Vec2.equals(transform.position, this._physicsPosition, SYNC_POSITION_THRESHOLD)) {
296
+ this._setPhysicsPosition(transform.position);
297
+ }
298
+ }
299
+ if (outdated || changeFlags & TransformFlag.rotation) {
300
+ if (!approxEqual(transform.rotation, this._physicsRotation, SYNC_ROTATION_THRESHOLD)) {
301
+ this._setPhysicsRotation(transform.rotation);
302
+ }
303
+ }
304
+ }
305
+ _syncFromPhysics() {
306
+ if (this._type === RigidBody2DType.fixed) {
307
+ return;
308
+ }
309
+ const implBody = this._rigidBodyControlBlock?.impl;
310
+ if (!implBody) {
311
+ return;
312
+ }
313
+ const transform = this._transform;
314
+ const pxPosition = implBody.translation();
315
+ const positionCache = fromPx2ImplVec2(pxPosition, this._physicsPosition);
316
+ if (!Vec2.equals(positionCache, transform.position, SYNC_POSITION_THRESHOLD)) {
317
+ transform.position = positionCache;
318
+ }
319
+ const pxRotation = to0ToPI2(implBody.rotation());
320
+ this._physicsRotation = pxRotation;
321
+ if (!approxEqual(pxRotation, transform.rotation, SYNC_ROTATION_THRESHOLD)) {
322
+ transform.rotation = pxRotation;
323
+ }
324
+ }
325
+ };
326
+ __decorate([
327
+ editable(CCString)
328
+ ], RigidBody2D.prototype, "tags", null);
329
+ __decorate([
330
+ designType(RigidBody2DType),
331
+ idem
332
+ ], RigidBody2D.prototype, "type", null);
333
+ __decorate([
334
+ editable
335
+ ], RigidBody2D.prototype, "collisionWithDynamic", null);
336
+ __decorate([
337
+ editable
338
+ ], RigidBody2D.prototype, "collisionWithFixed", null);
339
+ __decorate([
340
+ editable
341
+ ], RigidBody2D.prototype, "collisionWithKinematic", null);
342
+ __decorate([
343
+ editable,
344
+ idem
345
+ ], RigidBody2D.prototype, "ccd", null);
346
+ __decorate([
347
+ editable({
348
+ visible() {
349
+ return this._type === RigidBody2DType.dynamic;
350
+ },
351
+ }),
352
+ idem
353
+ ], RigidBody2D.prototype, "gravityScale", null);
354
+ __decorate([
355
+ idem
356
+ ], RigidBody2D.prototype, "linearVelocity", null);
357
+ __decorate([
358
+ serializable
359
+ ], RigidBody2D.prototype, "_tags", void 0);
360
+ __decorate([
361
+ serializable
362
+ ], RigidBody2D.prototype, "_type", void 0);
363
+ __decorate([
364
+ serializable
365
+ ], RigidBody2D.prototype, "_ccd", void 0);
366
+ __decorate([
367
+ serializable
368
+ ], RigidBody2D.prototype, "_gravityScale", void 0);
369
+ __decorate([
370
+ serializable
371
+ ], RigidBody2D.prototype, "_collisionTargetTypeFilter", void 0);
372
+ __decorate([
373
+ requiresComponent(Transform2DComponent)
374
+ ], RigidBody2D.prototype, "_transform", null);
375
+ RigidBody2D = __decorate([
376
+ cycloBuiltinClass('RigidBody2D')
377
+ ], RigidBody2D);
378
+ export { RigidBody2D };
379
+ function toPx2ImplRigidBodyType(type) {
380
+ switch (type) {
381
+ case RigidBody2DType.fixed:
382
+ return px2Impl.RigidBodyType.Fixed;
383
+ case RigidBody2DType.dynamic:
384
+ return px2Impl.RigidBodyType.Dynamic;
385
+ case RigidBody2DType.kinematicPositionBased:
386
+ return px2Impl.RigidBodyType.KinematicPositionBased;
387
+ case RigidBody2DType.kinematicVelocityBased:
388
+ return px2Impl.RigidBodyType.KinematicVelocityBased;
389
+ }
390
+ }
391
+ //# sourceMappingURL=rigid-body-2d.js.map
@@ -0,0 +1,102 @@
1
+ import { Vec2 } from '@cyclonium/core/math/vec2';
2
+ import { PhysicsComponent2DBase } from './physics-component-2d-base.js';
3
+ import { SceneQueryFilter, type ColliderShapeCastHit } from './scene-query.js';
4
+ import type { Collider2D } from './collider-2d.js';
5
+ import type { PhysicsWorld2D, ShapeTransformDesc } from './physics-world-2d.js';
6
+ /**
7
+ * Options applied when a SceneQueryProbe2D performs a shape cast.
8
+ */
9
+ export interface SceneQueryProbeSweepOptions {
10
+ /**
11
+ * The allowed distance between the swept shape and a hit at the target position.
12
+ */
13
+ targetDistance?: number;
14
+ /**
15
+ * Whether the sweep should stop immediately when the start shape already overlaps a collider.
16
+ */
17
+ stopAtPenetration?: boolean;
18
+ /**
19
+ * Colliders skipped by the sweep, usually the querying object's own collider.
20
+ */
21
+ excludeColliders?: Iterable<Collider2D>;
22
+ }
23
+ /**
24
+ * Query-only 2D physics probe used for authoring reusable scene queries.
25
+ *
26
+ * It does not create a collider, participate in simulation, or emit contact events.
27
+ */
28
+ export declare abstract class SceneQueryProbe2D extends PhysicsComponent2DBase {
29
+ /**
30
+ * Physics tags this probe can hit.
31
+ *
32
+ * Tags are resolved through the current PhysicsWorld2D and cached until the filter config changes.
33
+ * Assign a new array to change tags; in-place mutations are not supported.
34
+ */
35
+ get targetTags(): readonly string[];
36
+ set targetTags(value: readonly string[]);
37
+ /**
38
+ * Whether dynamic rigid bodies are included in this probe's queries.
39
+ */
40
+ get dynamics(): boolean;
41
+ set dynamics(value: boolean);
42
+ /**
43
+ * Whether fixed rigid bodies are included in this probe's queries.
44
+ */
45
+ get fixed(): boolean;
46
+ set fixed(value: boolean);
47
+ /**
48
+ * Whether kinematic rigid bodies are included in this probe's queries.
49
+ */
50
+ get kinematics(): boolean;
51
+ set kinematics(value: boolean);
52
+ /**
53
+ * Whether sensor colliders are included in this probe's queries.
54
+ */
55
+ get sensors(): boolean;
56
+ set sensors(value: boolean);
57
+ /**
58
+ * Whether solid colliders are included in this probe's queries.
59
+ */
60
+ get solids(): boolean;
61
+ set solids(value: boolean);
62
+ /**
63
+ * Finds colliders overlapping this probe's current world transform and filter.
64
+ */
65
+ intersect(): Collider2D[];
66
+ /**
67
+ * Casts this probe from its current world transform.
68
+ *
69
+ * `direction` is normalized internally; `maxDistance` defines the sweep length.
70
+ */
71
+ sweep(direction: Vec2, maxDistance: number, opts?: SceneQueryProbeSweepOptions): ColliderShapeCastHit | undefined;
72
+ /**
73
+ * Casts this probe from an explicit transform without moving the node.
74
+ *
75
+ * Useful for previous-to-current authority sweeps.
76
+ */
77
+ sweepFrom(transform: ShapeTransformDesc, direction: Vec2, maxDistance: number, opts?: SceneQueryProbeSweepOptions): ColliderShapeCastHit | undefined;
78
+ protected get queryPosition(): Vec2;
79
+ protected get queryRotation(): number;
80
+ protected get queryScale(): Vec2;
81
+ protected abstract intersectWithWorld(world: PhysicsWorld2D, filter: SceneQueryFilter): Iterable<Collider2D>;
82
+ protected abstract sweepWithWorld(world: PhysicsWorld2D, transform: ShapeTransformDesc, direction: Vec2, maxDistance: number, opts: SceneQueryProbeSweepOptions, filter: SceneQueryFilter): ColliderShapeCastHit | undefined;
83
+ protected abstract drawGizmo(): void;
84
+ protected onAttachToWorld(_world: PhysicsWorld2D): void;
85
+ protected onDetachFromWorld(_world: PhysicsWorld2D): void;
86
+ protected onUpdate(): void;
87
+ private _getFilter;
88
+ private _createFilter;
89
+ private _invalidateFilter;
90
+ private _clearFilterCache;
91
+ private _targetTags;
92
+ private _dynamics;
93
+ private _fixed;
94
+ private _kinematics;
95
+ private _sensors;
96
+ private _solids;
97
+ private _filterCache;
98
+ private _filterWorld;
99
+ private _filterDirty;
100
+ private get _transform();
101
+ }
102
+ //# sourceMappingURL=scene-query-probe-2d.d.ts.map