@waica/engine 0.27.0 → 0.29.0

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 (43) hide show
  1. package/README.md +30 -8
  2. package/dist/anchored-pieces.js +21 -5
  3. package/dist/archetype.d.ts +15 -0
  4. package/dist/archetype.js +41 -1
  5. package/dist/assets/glb-clip-names.d.ts +8 -0
  6. package/dist/assets/glb-clip-names.js +49 -0
  7. package/dist/camera-projection.d.ts +6 -5
  8. package/dist/camera-projection.js +8 -7
  9. package/dist/camera-rig.d.ts +54 -4
  10. package/dist/camera-rig.js +116 -6
  11. package/dist/components/animator.d.ts +6 -0
  12. package/dist/components/animator.js +12 -0
  13. package/dist/entity-update-schedules.d.ts +21 -0
  14. package/dist/entity-update-schedules.js +67 -0
  15. package/dist/game.d.ts +14 -12
  16. package/dist/game.js +41 -75
  17. package/dist/index.d.ts +10 -2
  18. package/dist/index.js +4 -0
  19. package/dist/input-mouse.d.ts +83 -0
  20. package/dist/input-mouse.js +205 -0
  21. package/dist/input.d.ts +26 -5
  22. package/dist/input.js +58 -10
  23. package/dist/orbit-camera.d.ts +68 -0
  24. package/dist/orbit-camera.js +92 -0
  25. package/dist/physics-3d/world-queries.d.ts +10 -1
  26. package/dist/physics-3d/world-queries.js +6 -2
  27. package/dist/pointer-raycast.d.ts +24 -6
  28. package/dist/pointer-raycast.js +44 -14
  29. package/dist/runtime-bridge.d.ts +12 -2
  30. package/dist/runtime-bridge.js +12 -1
  31. package/dist/runtime-inspection.js +3 -2
  32. package/dist/runtime-view-snapshot.d.ts +5 -8
  33. package/dist/runtime-view-snapshot.js +15 -11
  34. package/dist/scene-camera-3d.d.ts +14 -15
  35. package/dist/scene-camera-3d.js +14 -10
  36. package/dist/scene-camera-orbit.d.ts +72 -0
  37. package/dist/scene-camera-orbit.js +155 -0
  38. package/dist/scene-field-issues.d.ts +16 -0
  39. package/dist/scene-field-issues.js +11 -0
  40. package/dist/scene.js +5 -3
  41. package/dist/spatial-query-3d.d.ts +2 -2
  42. package/dist/spatial-query-3d.js +13 -4
  43. package/package.json +1 -1
@@ -3,7 +3,7 @@ import type { Entity } from './entity.js';
3
3
  import type { Game } from './game.js';
4
4
  import { type Point3d, type QueryVolume3d } from './physics-3d/world-queries.js';
5
5
  import type { ComponentClasses, NearestSpatialQueryFilter, SpatialQueryFilter } from './spatial-query.js';
6
- export type { Point3d, QueryVolume3d } from './physics-3d/world-queries.js';
6
+ export type { Point3d, QueryColliders3d, QueryVolume3d } from './physics-3d/world-queries.js';
7
7
  /** The first solid collider a 3D ray reached, with its entity and the crossing (issue #159 CA-21). */
8
8
  export interface RayHit3d<T extends Entity = Entity> {
9
9
  readonly entity: T;
@@ -18,7 +18,7 @@ type NearestFilter = NearestSpatialQueryFilter<ComponentClasses> | undefined;
18
18
  export interface EntityRules {
19
19
  matchesCommon(entity: Entity, filter: NearestFilter): boolean;
20
20
  }
21
- /** The 3D forms of `game.query` (ADR 0015's domains kept): `ray` reads solids, `area` and `point` read sensors, `nearest` reads transforms. */
21
+ /** The 3D forms of `game.query` (ADR 0015's domains kept): `ray` reads solids, `area` and `point` read sensors (`area` every collider on request), `nearest` reads transforms. */
22
22
  export declare class SpatialQuery3d {
23
23
  private readonly game;
24
24
  private readonly rules;
@@ -1,9 +1,16 @@
1
1
  import { recordsAtPoint, recordsInVolume, worldRayHits } from './physics-3d/world-queries.js';
2
2
  const isPoint3d = (value) => typeof value === 'object' && value !== null && ['x', 'y', 'z'].every((axis) => Number.isFinite(Reflect.get(value, axis)));
3
3
  const isExtent = (value) => typeof value === 'number' && Number.isFinite(value) && value > 0;
4
+ /** An absent or known collider domain, and an absent or finite box yaw: the optional parts of a volume. */
5
+ function hasValidOptions(value) {
6
+ const colliders = Reflect.get(value, 'colliders');
7
+ const yaw = Reflect.get(value, 'yaw');
8
+ const knownDomain = colliders === undefined || colliders === 'sensors' || colliders === 'all';
9
+ return knownDomain && (yaw === undefined || (typeof yaw === 'number' && Number.isFinite(yaw)));
10
+ }
4
11
  /** A finite box or sphere with a place: anything else is a volume Rapier cannot test. */
5
12
  function isVolume3d(value) {
6
- if (typeof value !== 'object' || value === null || !isPoint3d(Reflect.get(value, 'center')))
13
+ if (typeof value !== 'object' || value === null || !isPoint3d(Reflect.get(value, 'center')) || !hasValidOptions(value))
7
14
  return false;
8
15
  const shape = Reflect.get(value, 'shape');
9
16
  if (shape === 'sphere')
@@ -13,7 +20,7 @@ function isVolume3d(value) {
13
20
  }
14
21
  /** The farthest a nearest query looks: its `maxDistance`, or no limit. */
15
22
  const rangeOf = (filter) => filter?.maxDistance ?? Infinity;
16
- /** The 3D forms of `game.query` (ADR 0015's domains kept): `ray` reads solids, `area` and `point` read sensors, `nearest` reads transforms. */
23
+ /** The 3D forms of `game.query` (ADR 0015's domains kept): `ray` reads solids, `area` and `point` read sensors (`area` every collider on request), `nearest` reads transforms. */
17
24
  export class SpatialQuery3d {
18
25
  game;
19
26
  rules;
@@ -40,7 +47,8 @@ export class SpatialQuery3d {
40
47
  const world = this.worldNow();
41
48
  if (!world || !isVolume3d(volume))
42
49
  return [];
43
- return this.inEntityOrder(recordsInVolume(world, volume, (record) => this.eligible(record, filter, true)), filter);
50
+ const domain = volume.colliders === 'all' ? 'all' : true;
51
+ return this.inEntityOrder(recordsInVolume(world, volume, (record) => this.eligible(record, filter, domain)), filter);
44
52
  }
45
53
  point(at, filter) {
46
54
  const world = this.worldNow();
@@ -82,7 +90,8 @@ export class SpatialQuery3d {
82
90
  * Rapier's callback, so it reads the record and nothing else.
83
91
  */
84
92
  eligible(record, filter, sensors) {
85
- return record.sensor === sensors && record.entity.alive && this.rules.matchesCommon(record.entity, filter);
93
+ const inDomain = sensors === 'all' || record.sensor === sensors;
94
+ return inDomain && record.entity.alive && this.rules.matchesCommon(record.entity, filter);
86
95
  }
87
96
  /** The user's `where`, run after Rapier has answered: it may throw, spawn or destroy without the world mid-query. */
88
97
  wanted(record, filter) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@waica/engine",
3
- "version": "0.27.0",
3
+ "version": "0.29.0",
4
4
  "description": "Waica game engine core — archetype-driven, web-first, 2D & 3D",
5
5
  "license": "MIT",
6
6
  "type": "module",