@woosh/meep-engine 2.120.5 → 2.121.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/README.md +1 -1
  2. package/editor/view/node-graph/NodeGraphEditorView.d.ts.map +1 -1
  3. package/editor/view/node-graph/NodeGraphView.d.ts.map +1 -1
  4. package/editor/view/node-graph/NodeView.d.ts.map +1 -1
  5. package/editor/view/node-graph/PortView.d.ts.map +1 -1
  6. package/package.json +1 -1
  7. package/src/core/codegen/LineBuilder.d.ts +2 -2
  8. package/src/core/codegen/LineBuilder.d.ts.map +1 -1
  9. package/src/core/codegen/LineBuilder.js +14 -9
  10. package/src/core/collection/array/array_set_diff_sorting.d.ts +1 -1
  11. package/src/core/collection/array/array_set_diff_sorting.js +1 -1
  12. package/src/core/collection/map/HashMap.d.ts.map +1 -1
  13. package/src/core/collection/map/HashMap.js +29 -2
  14. package/src/core/color/oklab/find_cusp.d.ts.map +1 -1
  15. package/src/core/color/oklab/find_cusp.js +4 -1
  16. package/src/core/color/oklab/oklab_to_linear_srgb.d.ts.map +1 -1
  17. package/src/core/color/oklab/oklab_to_linear_srgb.js +1 -0
  18. package/src/core/color/operations/color_lighten.d.ts +1 -1
  19. package/src/core/color/operations/color_lighten.d.ts.map +1 -1
  20. package/src/core/color/operations/color_lighten.js +6 -1
  21. package/src/core/geom/2d/aabb/aabb2_intersects_point.d.ts +12 -0
  22. package/src/core/geom/2d/aabb/aabb2_intersects_point.d.ts.map +1 -0
  23. package/src/core/geom/2d/aabb/aabb2_intersects_point.js +17 -0
  24. package/src/core/geom/2d/quad-tree/QuadTreeNode.d.ts +17 -6
  25. package/src/core/geom/2d/quad-tree/QuadTreeNode.d.ts.map +1 -1
  26. package/src/core/geom/2d/quad-tree/QuadTreeNode.js +59 -98
  27. package/src/core/geom/2d/quad-tree/qt_collect_by_box.d.ts +14 -0
  28. package/src/core/geom/2d/quad-tree/qt_collect_by_box.d.ts.map +1 -0
  29. package/src/core/geom/2d/quad-tree/qt_collect_by_box.js +90 -0
  30. package/src/core/geom/2d/quad-tree/qt_collect_by_point.d.ts +11 -0
  31. package/src/core/geom/2d/quad-tree/qt_collect_by_point.d.ts.map +1 -0
  32. package/src/core/geom/2d/quad-tree/qt_collect_by_point.js +85 -0
  33. package/src/core/geom/3d/ray/ray3_distance_to_point.d.ts +14 -1
  34. package/src/core/geom/3d/ray/ray3_distance_to_point.d.ts.map +1 -1
  35. package/src/core/geom/3d/ray/ray3_distance_to_point.js +18 -1
  36. package/src/core/geom/3d/shape/UnionShape3D.d.ts.map +1 -1
  37. package/src/core/geom/3d/shape/UnionShape3D.js +4 -0
  38. package/src/core/geom/3d/shape/UnitCubeShape3D.d.ts.map +1 -1
  39. package/src/core/geom/3d/shape/UnitCubeShape3D.js +4 -0
  40. package/src/core/geom/ConicRay.d.ts +5 -1
  41. package/src/core/geom/ConicRay.d.ts.map +1 -1
  42. package/src/core/geom/ConicRay.js +5 -1
  43. package/src/core/geom/Vector1.d.ts.map +1 -1
  44. package/src/core/geom/Vector1.js +15 -2
  45. package/src/core/geom/Vector3.d.ts.map +1 -1
  46. package/src/core/geom/Vector3.js +10 -2
  47. package/src/core/geom/packing/max-rect/MaxRectanglesPacker.d.ts.map +1 -1
  48. package/src/core/geom/packing/max-rect/MaxRectanglesPacker.js +3 -0
  49. package/src/core/geom/packing/max-rect/cutArea.d.ts.map +1 -1
  50. package/src/core/geom/packing/max-rect/cutArea.js +8 -1
  51. package/src/core/geom/packing/max-rect/findBestContainer.d.ts +4 -4
  52. package/src/core/geom/packing/max-rect/findBestContainer.d.ts.map +1 -1
  53. package/src/core/geom/packing/max-rect/findBestContainer.js +30 -8
  54. package/src/core/geom/packing/max-rect/packOneBox.d.ts.map +1 -1
  55. package/src/core/geom/packing/max-rect/packOneBox.js +7 -2
  56. package/src/core/geom/packing/max-rect/removeRedundantBoxesArray.d.ts.map +1 -1
  57. package/src/core/geom/packing/max-rect/removeRedundantBoxesArray.js +13 -7
  58. package/src/core/geom/packing/miniball/Miniball.d.ts.map +1 -1
  59. package/src/core/geom/packing/miniball/Miniball.js +27 -1
  60. package/src/core/geom/packing/miniball/PointSet.d.ts.map +1 -1
  61. package/src/core/geom/packing/miniball/PointSet.js +25 -4
  62. package/src/core/geom/packing/miniball/Quality.js +1 -3
  63. package/src/core/process/action/AsynchronousDelayAction.js +1 -1
  64. package/src/engine/EntityCreator.js +1 -1
  65. package/src/engine/achievements/AchievementManager.js +1 -1
  66. package/src/engine/animation/AnimationUtils.js +1 -1
  67. package/src/engine/animation/async/prototypeAsyncAnimation.js +2 -2
  68. package/src/engine/animation/behavior/animateProperty.js +1 -1
  69. package/src/engine/animation/playTrackRealTime.js +1 -1
  70. package/src/engine/ecs/Entity.d.ts.map +1 -1
  71. package/src/engine/ecs/Entity.js +12 -7
  72. package/src/engine/ecs/EntityComponentDataset.d.ts.map +1 -1
  73. package/src/engine/ecs/EntityComponentDataset.js +14 -7
  74. package/src/engine/ecs/EntityReference.d.ts +4 -4
  75. package/src/engine/ecs/EntityReference.js +4 -4
  76. package/src/engine/ecs/dynamic_actions/DynamicActorSystem.js +1 -1
  77. package/src/engine/ecs/speaker/VoiceSystem.d.ts +8 -2
  78. package/src/engine/ecs/speaker/VoiceSystem.d.ts.map +1 -1
  79. package/src/engine/ecs/speaker/VoiceSystem.js +1 -1
  80. package/src/engine/ecs/util/hideEntityGracefully.js +3 -3
  81. package/src/engine/graphics/ecs/camera/filter/setup_filtered_camera_controller.d.ts.map +1 -1
  82. package/src/engine/graphics/ecs/camera/filter/setup_filtered_camera_controller.js +6 -6
  83. package/src/engine/graphics/ecs/decal/v2/prototypeDecalSystem.js +1 -1
  84. package/src/engine/graphics/ecs/mesh-v2/aggregate/prototypeSGMesh.js +1 -1
  85. package/src/engine/graphics/ecs/mesh-v2/sample/prototypeShadedGeometry.js +2 -2
  86. package/src/engine/graphics/ecs/mesh-v2/sample/prototype_sg_raycast.js +1 -1
  87. package/src/engine/graphics/ecs/path/tube/prototypeAnimatedPathMask.js +1 -1
  88. package/src/engine/graphics/ecs/trail2d/prototypeTrail2D.js +1 -1
  89. package/src/engine/graphics/impostors/octahedral/prototypeBaker.js +1 -1
  90. package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +2 -2
  91. package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +4 -4
  92. package/src/engine/graphics/sh3/path_tracer/make_one_vector3.d.ts.map +1 -1
  93. package/src/engine/graphics/sh3/path_tracer/make_sky_hosek.d.ts.map +1 -1
  94. package/src/engine/graphics/sh3/path_tracer/make_sky_rtiw.d.ts.map +1 -1
  95. package/src/engine/graphics/sh3/path_tracer/make_zero_vector3.d.ts.map +1 -1
  96. package/src/engine/input/devices/PointerDevice.js +1 -1
  97. package/src/engine/intelligence/behavior/ecs/BehaviorComponent.d.ts +79 -3
  98. package/src/engine/intelligence/behavior/ecs/BehaviorComponent.d.ts.map +1 -1
  99. package/src/engine/intelligence/behavior/ecs/BehaviorComponent.js +24 -8
  100. package/src/engine/intelligence/behavior/ecs/BehaviorComponentSerializationAdapter.d.ts.map +1 -1
  101. package/src/engine/intelligence/behavior/ecs/BehaviorComponentSerializationAdapter.js +2 -2
  102. package/src/engine/intelligence/behavior/ecs/BehaviorSystem.d.ts +33 -7
  103. package/src/engine/intelligence/behavior/primitive/ActionBehavior.d.ts +3 -2
  104. package/src/engine/intelligence/behavior/primitive/ActionBehavior.d.ts.map +1 -1
  105. package/src/engine/intelligence/behavior/primitive/ActionBehavior.js +7 -5
  106. package/src/engine/intelligence/behavior/primitive/SucceedingBehavior.d.ts +10 -9
  107. package/src/engine/intelligence/behavior/primitive/SucceedingBehavior.d.ts.map +1 -1
  108. package/src/engine/intelligence/behavior/primitive/SucceedingBehavior.js +19 -20
  109. package/src/engine/physics/fluid/prototype.js +1 -1
  110. package/src/engine/physics/inverse_kinematics/fabrik/prototype.js +1 -1
  111. package/src/view/View.d.ts.map +1 -1
  112. package/src/view/View.js +14 -1
@@ -678,6 +678,8 @@ export class EntityComponentDataset {
678
678
  }
679
679
 
680
680
  /**
681
+ * Does this dataset have a given component registered?
682
+ * Use {@link registerComponentType}/{@link unregisterComponentType} to alter registered set
681
683
  * @param {Class|Function} type
682
684
  * @return {boolean}
683
685
  */
@@ -719,11 +721,11 @@ export class EntityComponentDataset {
719
721
  /**
720
722
  * Attempt to add a component class to dataset registry
721
723
  * @param {Class|Function} type
722
- * @returns {boolean} true if component successfully added, false otherwise
724
+ * @returns {boolean} true if component successfully added, false if component is already registered
723
725
  */
724
726
  registerComponentType(type) {
725
727
  if (this.isComponentTypeRegistered(type)) {
726
- //already registered
728
+ // already registered
727
729
  return false;
728
730
  }
729
731
 
@@ -737,11 +739,11 @@ export class EntityComponentDataset {
737
739
  /**
738
740
  * Attempt to remove a component class from the registry
739
741
  * @param {Class} type
740
- * @returns {boolean}
742
+ * @returns {boolean} true iff component is removed, false if it was not registered
741
743
  */
742
744
  unregisterComponentType(type) {
743
745
  if (this.isComponentTypeRegistered(type)) {
744
- //not registered
746
+ // not registered
745
747
  return false;
746
748
  }
747
749
 
@@ -771,6 +773,7 @@ export class EntityComponentDataset {
771
773
 
772
774
  const new_generation_table = new Uint32Array(new_size);
773
775
 
776
+ // copy over old data
774
777
  new_generation_table.set(this.entityGeneration);
775
778
 
776
779
  this.entityGeneration = new_generation_table
@@ -783,6 +786,7 @@ export class EntityComponentDataset {
783
786
  */
784
787
  getEntityGeneration(entity_id) {
785
788
  assert.isNonNegativeInteger(entity_id, 'entity_id');
789
+ assert.ok(this.entityExists(entity_id),`Entity ${entity_id} does not exist`);
786
790
 
787
791
  return this.entityGeneration[entity_id];
788
792
  }
@@ -863,6 +867,8 @@ export class EntityComponentDataset {
863
867
  * @returns {boolean} true if entity was removed, false if it doesn't exist
864
868
  */
865
869
  removeEntity(entity_id) {
870
+ assert.isNonNegativeInteger(entity_id, 'entity_id');
871
+
866
872
  if (!this.entityExists(entity_id)) {
867
873
  // entity doesn't exist
868
874
  return false;
@@ -902,6 +908,7 @@ export class EntityComponentDataset {
902
908
 
903
909
  /**
904
910
  * Convenience method for removal of multiple entities
911
+ * Works the same as {@link removeEntity} but for multiple elements
905
912
  * @param {number[]} entityIndices
906
913
  */
907
914
  removeEntities(entityIndices) {
@@ -1030,10 +1037,10 @@ export class EntityComponentDataset {
1030
1037
  *
1031
1038
  * Associate a component with a particular entity
1032
1039
  * @template C
1033
- * @param {number} entityIndex
1040
+ * @param {number} entity_id
1034
1041
  * @param {C} componentInstance
1035
1042
  */
1036
- addComponentToEntity(entityIndex, componentInstance) {
1043
+ addComponentToEntity(entity_id, componentInstance) {
1037
1044
 
1038
1045
  assert.notNull(componentInstance, "componentInstance");
1039
1046
 
@@ -1053,7 +1060,7 @@ export class EntityComponentDataset {
1053
1060
  throw new Error(`Component class not found in this dataset for componentInstance ${stringifyComponent(componentInstance)}`);
1054
1061
  }
1055
1062
 
1056
- this.addComponentToEntityByIndex(entityIndex, componentTypeIndex, componentInstance);
1063
+ this.addComponentToEntityByIndex(entity_id, componentTypeIndex, componentInstance);
1057
1064
  }
1058
1065
 
1059
1066
  /**
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * Uniquely identifies an entity by both its ID and generation.
3
- * Lets us distinguish between two entities with the same ID that were created at different times
3
+ * Lets us uniquely distinguish between two entities, even those with the same ID that were created at different times
4
4
  *
5
5
  * @example
6
6
  * // 1. Get your EntityComponentDataset to where you manager entities.
7
- * const ecd = ... ; //EntityComponentDataset
7
+ * const ecd = ... ; // EntityComponentDataset
8
8
  *
9
- * // 2. Create an entity (we'll get an ID). Or use an existing one.
10
- * const entityId = ecd.createEntity(); // Let's say this returns ID 1, generation 0
9
+ * // 2. Create an entity (we'll get an ID).
10
+ * const entityId = ecd.createEntity();
11
11
  *
12
12
  * // 3. Create an EntityReference and bind it to the entity.
13
13
  * const entityRef = EntityReference.bind(ecd, entityId);
@@ -2,14 +2,14 @@ import { assert } from "../../core/assert.js";
2
2
 
3
3
  /**
4
4
  * Uniquely identifies an entity by both its ID and generation.
5
- * Lets us distinguish between two entities with the same ID that were created at different times
5
+ * Lets us uniquely distinguish between two entities, even those with the same ID that were created at different times
6
6
  *
7
7
  * @example
8
8
  * // 1. Get your EntityComponentDataset to where you manager entities.
9
- * const ecd = ... ; //EntityComponentDataset
9
+ * const ecd = ... ; // EntityComponentDataset
10
10
  *
11
- * // 2. Create an entity (we'll get an ID). Or use an existing one.
12
- * const entityId = ecd.createEntity(); // Let's say this returns ID 1, generation 0
11
+ * // 2. Create an entity (we'll get an ID).
12
+ * const entityId = ecd.createEntity();
13
13
  *
14
14
  * // 3. Create an EntityReference and bind it to the entity.
15
15
  * const entityRef = EntityReference.bind(ecd, entityId);
@@ -264,7 +264,7 @@ export class DynamicActorSystem extends AbstractContextSystem {
264
264
  const behavior = rule.action.execute(entity, ecd, context, this);
265
265
 
266
266
  const entity_builder = new Entity()
267
- .add(BehaviorComponent.fromOne(SequenceBehavior.from([
267
+ .add(BehaviorComponent.from(SequenceBehavior.from([
268
268
  OverrideContextBehavior.from(
269
269
  {
270
270
  entity
@@ -9,7 +9,7 @@ export class VoiceSystem extends AbstractContextSystem<any> {
9
9
  font_size: number;
10
10
  });
11
11
  dependencies: (typeof Voice)[];
12
- components_used: ResourceAccessSpecification<typeof BehaviorComponent>[];
12
+ components_used: (ResourceAccessSpecification<typeof GUIElement> | ResourceAccessSpecification<typeof Transform> | ResourceAccessSpecification<typeof ViewportPosition> | ResourceAccessSpecification<typeof HeadsUpDisplay> | ResourceAccessSpecification<typeof Attachment> | ResourceAccessSpecification<typeof SerializationMetadata> | ResourceAccessSpecification<typeof BehaviorComponent>)[];
13
13
  /**
14
14
  *
15
15
  * @type {Localization}
@@ -100,6 +100,12 @@ export class VoiceSystem extends AbstractContextSystem<any> {
100
100
  }
101
101
  import { AbstractContextSystem } from "../system/AbstractContextSystem.js";
102
102
  import { Voice } from "./Voice.js";
103
- import { BehaviorComponent } from "../../intelligence/behavior/ecs/BehaviorComponent.js";
103
+ import GUIElement from "../gui/GUIElement.js";
104
104
  import { ResourceAccessSpecification } from "../../../core/model/ResourceAccessSpecification.js";
105
+ import { Transform } from "../transform/Transform.js";
106
+ import ViewportPosition from "../gui/position/ViewportPosition.js";
107
+ import HeadsUpDisplay from "../gui/hud/HeadsUpDisplay.js";
108
+ import { Attachment } from "../attachment/Attachment.js";
109
+ import { SerializationMetadata } from "../components/SerializationMetadata.js";
110
+ import { BehaviorComponent } from "../../intelligence/behavior/ecs/BehaviorComponent.js";
105
111
  //# sourceMappingURL=VoiceSystem.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"VoiceSystem.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/speaker/VoiceSystem.js"],"names":[],"mappings":"AA2JA;IACI;;;;OAIG;IACH,oBAHW,MAAM;;;OA8FhB;IArFG,+BAA2B;IAE3B,yEAQC;IAGD;;;OAGG;IACH,aAFU,YAAY,CAEC;IAEvB;;;OAGG;IACH,KAFU,SAAS,CAEJ;IAEf;;;OAGG;IACH,OAFU,oBAAoB,CAEb;IAEjB;;;OAGG;IACH,MAFU,uBAAuB,CAEjB;IAEhB;;;OAGG;IACH,QAFU,MAAM,CAEI;IAEpB;;;;OAIG;IACH,iCAAyC;IAEzC;;;;OAIG;IACH,kBAAkC;IAIlC;;;;OAIG;IACH,eAAkB;IAElB;;;;OAIG;IACH,oBAAgC;IAEhC;;;OAGG;IACH,oBAAqC;IAErC;;;;OAIG;IACH,gBAAoB;IAGxB;;;OAGG;IACH,kBAFY,MAAM,CAIjB;IAED,0EAuBC;IAED;;;;;OAKG;IACH,uBAJW,MAAM,UACN,MAAM,SACN,KAAK,QAsBf;IAED;;;;;OAKG;IACH,wBAoBC;IAED;;;;;OAKG;IACH,gBAJW,MAAM,WACN,MAAM,SACN,KAAK,QAuHf;CACJ;sCAxbqC,oCAAoC;sBAIpD,YAAY;kCAlBA,sDAAsD;4CAR5C,oDAAoD"}
1
+ {"version":3,"file":"VoiceSystem.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/speaker/VoiceSystem.js"],"names":[],"mappings":"AA2JA;IACI;;;;OAIG;IACH,oBAHW,MAAM;;;OA8FhB;IArFG,+BAA2B;IAE3B,qYAQC;IAGD;;;OAGG;IACH,aAFU,YAAY,CAEC;IAEvB;;;OAGG;IACH,KAFU,SAAS,CAEJ;IAEf;;;OAGG;IACH,OAFU,oBAAoB,CAEb;IAEjB;;;OAGG;IACH,MAFU,uBAAuB,CAEjB;IAEhB;;;OAGG;IACH,QAFU,MAAM,CAEI;IAEpB;;;;OAIG;IACH,iCAAyC;IAEzC;;;;OAIG;IACH,kBAAkC;IAIlC;;;;OAIG;IACH,eAAkB;IAElB;;;;OAIG;IACH,oBAAgC;IAEhC;;;OAGG;IACH,oBAAqC;IAErC;;;;OAIG;IACH,gBAAoB;IAGxB;;;OAGG;IACH,kBAFY,MAAM,CAIjB;IAED,0EAuBC;IAED;;;;;OAKG;IACH,uBAJW,MAAM,UACN,MAAM,SACN,KAAK,QAsBf;IAED;;;;;OAKG;IACH,wBAoBC;IAED;;;;;OAKG;IACH,gBAJW,MAAM,WACN,MAAM,SACN,KAAK,QAuHf;CACJ;sCAxbqC,oCAAoC;sBAIpD,YAAY;uBAPX,sBAAsB;4CAnBD,oDAAoD;0BAwBtE,2BAA2B;6BAHxB,qCAAqC;2BADvC,8BAA8B;2BAL9B,6BAA6B;sCAClB,wCAAwC;kCAR5C,sDAAsD"}
@@ -423,7 +423,7 @@ export class VoiceSystem extends AbstractContextSystem {
423
423
  immediate: true
424
424
  }))
425
425
  .add(SerializationMetadata.Transient)
426
- .add(BehaviorComponent.fromOne(SequenceBehavior.from([
426
+ .add(BehaviorComponent.from(SequenceBehavior.from([
427
427
  // play intro animation
428
428
  new AnimationBehavior(new AnimationTrackPlayback(SPEECH_BUBBLE_ANIMATION_INTRO, bubble_animation_update_function, view)),
429
429
  // wait for a certain amount of time
@@ -81,7 +81,7 @@ addShutdown(Mesh, (mesh, builder, createEntity, createEntityThisArg) => {
81
81
 
82
82
  const eb = createEntity.call(createEntityThisArg);
83
83
 
84
- eb.add(BehaviorComponent.fromOne(SequenceBehavior.from([
84
+ eb.add(BehaviorComponent.from(SequenceBehavior.from([
85
85
  scale,
86
86
  DieBehavior.create()
87
87
  ])));
@@ -104,7 +104,7 @@ addShutdown(Light, (light, builder, createEntity, createEntityThisArg) => {
104
104
 
105
105
  const eb = createEntity.call(createEntityThisArg);
106
106
 
107
- eb.add(BehaviorComponent.fromOne(SequenceBehavior.from([
107
+ eb.add(BehaviorComponent.from(SequenceBehavior.from([
108
108
  TransitionPropertyVectorXBehavior.from({
109
109
  component: 'Light',
110
110
  path: 'intensity',
@@ -146,7 +146,7 @@ addShutdown(SoundEmitter, (soundEmitter, builder, createEntity, createEntityThis
146
146
 
147
147
  const eb = createEntity.call(createEntityThisArg);
148
148
 
149
- eb.add(BehaviorComponent.fromOne(SequenceBehavior.from([
149
+ eb.add(BehaviorComponent.from(SequenceBehavior.from([
150
150
  DelayBehavior.from(SHUTDOWN_GRACE_PERIOD - setVolume.duration),
151
151
  setVolume,
152
152
  DieBehavior.create()
@@ -1 +1 @@
1
- {"version":3,"file":"setup_filtered_camera_controller.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/ecs/camera/filter/setup_filtered_camera_controller.js"],"names":[],"mappings":"AAUA;;;;;;;GAOG;AACH,2FANW,uBAAuB,GAIrB;IAAC,UAAU,EAAC,uBAAuB,CAAC;IAAC,MAAM,EAAC,MAAM,CAAA;CAAC,CA6D/D;oCA5EmC,uCAAuC;mBACxD,2BAA2B"}
1
+ {"version":3,"file":"setup_filtered_camera_controller.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/ecs/camera/filter/setup_filtered_camera_controller.js"],"names":[],"mappings":"AAUA;;;;;;;GAOG;AACH,2FANW,uBAAuB,GAIrB;IAAC,UAAU,EAAC,uBAAuB,CAAC;IAAC,MAAM,EAAC,MAAM,CAAA;CAAC,CA6D/D;oCArEmC,uCAAuC;mBAJxD,2BAA2B"}
@@ -1,12 +1,12 @@
1
1
  import { assert } from "../../../../../core/assert.js";
2
- import TopDownCameraController from "../topdown/TopDownCameraController.js";
2
+ import { clamp01 } from "../../../../../core/math/clamp01.js";
3
+ import { lerp } from "../../../../../core/math/lerp.js";
4
+ import { SerializationMetadata } from "../../../../ecs/components/SerializationMetadata.js";
3
5
  import Entity from "../../../../ecs/Entity.js";
4
- import { BehaviorComponent } from "../../../../intelligence/behavior/ecs/BehaviorComponent.js";
5
6
  import { RepeatBehavior } from "../../../../intelligence/behavior/decorator/RepeatBehavior.js";
7
+ import { BehaviorComponent } from "../../../../intelligence/behavior/ecs/BehaviorComponent.js";
6
8
  import { ActionBehavior } from "../../../../intelligence/behavior/primitive/ActionBehavior.js";
7
- import { SerializationMetadata } from "../../../../ecs/components/SerializationMetadata.js";
8
- import { clamp01 } from "../../../../../core/math/clamp01.js";
9
- import { lerp } from "../../../../../core/math/lerp.js";
9
+ import TopDownCameraController from "../topdown/TopDownCameraController.js";
10
10
 
11
11
  /**
12
12
  *
@@ -36,7 +36,7 @@ export function setup_filtered_camera_controller({
36
36
  const entityBuilder = new Entity();
37
37
 
38
38
  entityBuilder
39
- .add(BehaviorComponent.fromOne(
39
+ .add(BehaviorComponent.from(
40
40
  RepeatBehavior.from(
41
41
  new ActionBehavior(time_delta => {
42
42
  if (!remembered_value.equals(target)) {
@@ -372,7 +372,7 @@ function makeNormalTestDecal() {
372
372
  .add(ShadedGeometry.from(DEBUG_BOX, new LineBasicMaterial(), DrawMode.LineSegments))
373
373
  .add(transform)
374
374
  .add(decal)
375
- .add(BehaviorComponent.fromOne(RotationBehavior.fromJSON({ speed: 1, axis: Vector3.left })))
375
+ .add(BehaviorComponent.from(RotationBehavior.fromJSON({ speed: 1, axis: Vector3.left })))
376
376
 
377
377
  return entity;
378
378
  }
@@ -110,7 +110,7 @@ function make_grid(ecd, engine) {
110
110
  new Entity()
111
111
  .add(mesh)
112
112
  .add(transform)
113
- .add(BehaviorComponent.fromOne(
113
+ .add(BehaviorComponent.from(
114
114
  orbitingBehavior
115
115
  // RepeatBehavior.from(
116
116
  // new ActionBehavior((t) => {
@@ -43,7 +43,7 @@ function makeMovingShadedGeometry() {
43
43
  return new Entity()
44
44
  .add(new Transform())
45
45
  .add(sg)
46
- .add(BehaviorComponent.fromOne(b));
46
+ .add(BehaviorComponent.from(b));
47
47
  }
48
48
 
49
49
  /**
@@ -126,7 +126,7 @@ async function main(engine) {
126
126
  let iterator = 0;
127
127
 
128
128
  new Entity()
129
- .add(BehaviorComponent.fromOne(
129
+ .add(BehaviorComponent.from(
130
130
  RepeatBehavior.from(SequenceBehavior.from([
131
131
  DelayBehavior.from(0.001),
132
132
  RepeatBehavior.from(new ActionBehavior(() => {
@@ -50,7 +50,7 @@ function makeMovingShadedGeometry() {
50
50
  return new Entity()
51
51
  .add(new Transform())
52
52
  .add(sg)
53
- .add(BehaviorComponent.fromOne(b));
53
+ .add(BehaviorComponent.from(b));
54
54
  }
55
55
 
56
56
  /**
@@ -371,7 +371,7 @@ function main(engine) {
371
371
 
372
372
  let time = 0;
373
373
  new Entity()
374
- .add(BehaviorComponent.looping_function((delta) => {
374
+ .add(BehaviorComponent.loop((delta) => {
375
375
  time += delta * 0.01;
376
376
 
377
377
  const segment_count = 23;
@@ -38,7 +38,7 @@ async function main(engine) {
38
38
  entity.add(Transform.fromJSON({
39
39
  position: { x, y, z }
40
40
  }));
41
- entity.add(BehaviorComponent.fromOne(OrbitingBehavior.from({
41
+ entity.add(BehaviorComponent.from(OrbitingBehavior.from({
42
42
  center: new Vector3(x,y,z),
43
43
  radius: 0.1-0.02
44
44
  })))
@@ -149,7 +149,7 @@ function make_spin(entity, speed = 1, axis = Vector3.up) {
149
149
  return;
150
150
  }
151
151
 
152
- entity.add(BehaviorComponent.fromOne(RotationBehavior.fromJSON({
152
+ entity.add(BehaviorComponent.from(RotationBehavior.fromJSON({
153
153
  axis, speed
154
154
  })));
155
155
  }
@@ -994,7 +994,7 @@ function make_box_editor(engine, transform = new Transform()) {
994
994
  }
995
995
  }
996
996
  ]))
997
- .add(BehaviorComponent.looping_function(() => {
997
+ .add(BehaviorComponent.loop(() => {
998
998
 
999
999
  threeUpdateTransform(controls);
1000
1000
 
@@ -1210,7 +1210,7 @@ async function make_demo_volume({
1210
1210
  v.attributes.color.lookup = lut;
1211
1211
 
1212
1212
  new Entity()
1213
- .add(BehaviorComponent.fromOne(RepeatBehavior.from(new ActionBehavior((time) => {
1213
+ .add(BehaviorComponent.from(RepeatBehavior.from(new ActionBehavior((time) => {
1214
1214
  time_total += time;
1215
1215
 
1216
1216
  const _t = pingpong(time_total + period_offset, period);
@@ -338,7 +338,7 @@ function setup_scene_0(engine, ecd) {
338
338
  b.offset.copy(transform.position);
339
339
 
340
340
  builder
341
- .add(BehaviorComponent.fromOne(b))
341
+ .add(BehaviorComponent.from(b))
342
342
  .build(ecd);
343
343
  }
344
344
 
@@ -647,8 +647,8 @@ function setup_scene_3(engine, ecd) {
647
647
 
648
648
 
649
649
  builder
650
- .add(BehaviorComponent.fromOne(b))
651
- // .add(BehaviorComponent.looping_function(()=>{
650
+ .add(BehaviorComponent.from(b))
651
+ // .add(BehaviorComponent.loop(()=>{
652
652
  //
653
653
  // }))
654
654
  .build(ecd);
@@ -953,7 +953,7 @@ function setup_scene_2(engine, ecd) {
953
953
  b.offset.copy(transform.position);
954
954
 
955
955
  builder
956
- .add(BehaviorComponent.fromOne(b))
956
+ .add(BehaviorComponent.from(b))
957
957
  .build(ecd);
958
958
  }
959
959
 
@@ -1 +1 @@
1
- {"version":3,"file":"make_one_vector3.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/make_one_vector3.js"],"names":[],"mappings":"AAAA,+GAEC;AACD,iIAMC"}
1
+ {"version":3,"file":"make_one_vector3.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/make_one_vector3.js"],"names":[],"mappings":"AAAA,+GAEC;AACD,uDACY,QAAG,EAAE,eAAU,EAAE,cAAS,EAAE,qBAAgB,UAKvD"}
@@ -1 +1 @@
1
- {"version":3,"file":"make_sky_hosek.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/make_sky_hosek.js"],"names":[],"mappings":"AAQA,2LAmCC"}
1
+ {"version":3,"file":"make_sky_hosek.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/make_sky_hosek.js"],"names":[],"mappings":"AAQA,2GAaY,WAAM,EAAE,kBAAa,EAAE,cAAS,EAAE,qBAAgB,UAsB7D"}
@@ -1 +1 @@
1
- {"version":3,"file":"make_sky_rtiw.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/make_sky_rtiw.js"],"names":[],"mappings":"AAEA,4GAYC"}
1
+ {"version":3,"file":"make_sky_rtiw.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/make_sky_rtiw.js"],"names":[],"mappings":"AAEA,kCAGY,QAAG,EAAE,eAAU,EAAE,cAAS,EAAE,qBAAgB,UASvD"}
@@ -1 +1 @@
1
- {"version":3,"file":"make_zero_vector3.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/make_zero_vector3.js"],"names":[],"mappings":"AAAA,gHAMC"}
1
+ {"version":3,"file":"make_zero_vector3.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/make_zero_vector3.js"],"names":[],"mappings":"AAAA,sCACY,QAAG,EAAE,eAAU,EAAE,cAAS,EAAE,qBAAgB,UAKvD"}
@@ -344,7 +344,7 @@ export class PointerDevice {
344
344
 
345
345
  /**
346
346
  *
347
- * @param {MouseEvent} event
347
+ * @param {PointerEvent} event
348
348
  */
349
349
  #eventHandlerGlobalPointerUp = (event) => {
350
350
  this.readPointerPositionFromEvent(this.position, event);
@@ -1,3 +1,79 @@
1
- export class BehaviorComponent {
2
-
3
- }
1
+ /**
2
+ * ECS wrapper around a {@link Behavior} tree
3
+ */
4
+ export class BehaviorComponent {
5
+ /**
6
+ * Executes input function every update cycle.
7
+ * Will run forever.
8
+ * @param {function(time_delta_seconds:number)} action function to loop over
9
+ * @param {*} [thisArg]
10
+ * @returns {BehaviorComponent}
11
+ */
12
+ static loop(action: any, thisArg?: any): BehaviorComponent;
13
+ /**
14
+ *
15
+ * @param {Behavior} b
16
+ * @returns {BehaviorComponent}
17
+ */
18
+ static from(b: Behavior): BehaviorComponent;
19
+ /**
20
+ * What clock should be used for ticking associated behavior
21
+ * @type {ClockChannelType|number}
22
+ */
23
+ clock: ClockChannelType | number;
24
+ /**
25
+ *
26
+ * @type {number}
27
+ */
28
+ flags: number;
29
+ /**
30
+ * Associated behavior tree
31
+ * @type {Behavior|null}
32
+ * @private
33
+ */
34
+ private __behavior;
35
+ /**
36
+ *
37
+ * @param {number|BehaviorComponentFlag} flag
38
+ * @returns {void}
39
+ */
40
+ setFlag(flag: number | BehaviorComponentFlag): void;
41
+ /**
42
+ *
43
+ * @param {number|BehaviorComponentFlag} flag
44
+ * @returns {void}
45
+ */
46
+ clearFlag(flag: number | BehaviorComponentFlag): void;
47
+ /**
48
+ *
49
+ * @param {number|BehaviorComponentFlag} flag
50
+ * @param {boolean} value
51
+ */
52
+ writeFlag(flag: number | BehaviorComponentFlag, value: boolean): void;
53
+ /**
54
+ *
55
+ * @param {number|BehaviorComponentFlag} flag
56
+ * @returns {boolean}
57
+ */
58
+ getFlag(flag: number | BehaviorComponentFlag): boolean;
59
+ /**
60
+ *
61
+ * @param {Behavior} v
62
+ */
63
+ set behavior(v: Behavior);
64
+ /**
65
+ *
66
+ * @returns {Behavior|null}
67
+ */
68
+ get behavior(): Behavior | null;
69
+ }
70
+ export namespace BehaviorComponent {
71
+ import fromOne = BehaviorComponent.from;
72
+ export { fromOne };
73
+ import looping_function = BehaviorComponent.loop;
74
+ export { looping_function };
75
+ export let serializable: boolean;
76
+ export let typeName: string;
77
+ }
78
+ import { ClockChannelType } from "./ClockChannelType.js";
79
+ //# sourceMappingURL=BehaviorComponent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BehaviorComponent.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/intelligence/behavior/ecs/BehaviorComponent.js"],"names":[],"mappings":"AAKA;IA6EI;;;;;OAKG;IACH,0CAHW,GAAC,GACC,iBAAiB,CAM7B;IAED;;;;OAIG;IACH,kBAHW,QAAQ,GACN,iBAAiB,CAa7B;IAvGD;;;OAGG;IACH,OAFU,gBAAgB,GAAC,MAAM,CAEG;IAEpC;;;OAGG;IACH,OAFU,MAAM,CAEN;IAEV;;;;OAIG;IACH,mBAAkB;IAElB;;;;OAIG;IACH,cAHW,MAAM,GAAC,qBAAqB,GAC1B,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM,GAAC,qBAAqB,GAC1B,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM,GAAC,qBAAqB,SAC5B,OAAO,QAQjB;IAED;;;;OAIG;IACH,cAHW,MAAM,GAAC,qBAAqB,GAC1B,OAAO,CAInB;IAUD;;;OAGG;IACH,gBAFW,QAAQ,EAIlB;IAdD;;;OAGG;IACH,gBAFa,QAAQ,GAAC,IAAI,CAIzB;CAuCJ;;sBAIS,OAAO;kBAMP,MAAM;;iCAtHiB,uBAAuB"}
1
+ {"version":3,"file":"BehaviorComponent.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/intelligence/behavior/ecs/BehaviorComponent.js"],"names":[],"mappings":"AAKA;;GAEG;AACH;IA6EI;;;;;;OAMG;IACH,mCAHW,GAAC,GACC,iBAAiB,CAQ7B;IAED;;;;OAIG;IACH,eAHW,QAAQ,GACN,iBAAiB,CAa7B;IA1GD;;;OAGG;IACH,OAFU,gBAAgB,GAAC,MAAM,CAEG;IAEpC;;;OAGG;IACH,OAFU,MAAM,CAEN;IAEV;;;;OAIG;IACH,mBAAkB;IAElB;;;;OAIG;IACH,cAHW,MAAM,GAAC,qBAAqB,GAC1B,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM,GAAC,qBAAqB,GAC1B,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM,GAAC,qBAAqB,SAC5B,OAAO,QAQjB;IAED;;;;OAIG;IACH,cAHW,MAAM,GAAC,qBAAqB,GAC1B,OAAO,CAInB;IAUD;;;OAGG;IACH,gBAFW,QAAQ,EAIlB;IAdD;;;OAGG;IACH,gBAFa,QAAQ,GAAC,IAAI,CAIzB;CA0CJ;;;;;;6BAcS,OAAO;yBAMP,MAAM;;iCAtIiB,uBAAuB"}
@@ -3,6 +3,9 @@ import { RepeatBehavior } from "../decorator/RepeatBehavior.js";
3
3
  import { ActionBehavior } from "../primitive/ActionBehavior.js";
4
4
  import { ClockChannelType } from "./ClockChannelType.js";
5
5
 
6
+ /**
7
+ * ECS wrapper around a {@link Behavior} tree
8
+ */
6
9
  export class BehaviorComponent {
7
10
 
8
11
  /**
@@ -18,7 +21,7 @@ export class BehaviorComponent {
18
21
  flags = 0;
19
22
 
20
23
  /**
21
- *
24
+ * Associated behavior tree
22
25
  * @type {Behavior|null}
23
26
  * @private
24
27
  */
@@ -81,15 +84,18 @@ export class BehaviorComponent {
81
84
  }
82
85
 
83
86
  /**
84
- * Executes input function every update cycle
85
- * @param {function(time_delta_seconds:number)} f
87
+ * Executes input function every update cycle.
88
+ * Will run forever.
89
+ * @param {function(time_delta_seconds:number)} action function to loop over
86
90
  * @param {*} [thisArg]
87
91
  * @returns {BehaviorComponent}
88
92
  */
89
- static looping_function(f, thisArg) {
90
- return BehaviorComponent.fromOne(RepeatBehavior.from(
91
- new ActionBehavior(f, thisArg)
92
- ));
93
+ static loop(action, thisArg) {
94
+ return BehaviorComponent.from(
95
+ RepeatBehavior.from(
96
+ new ActionBehavior(action, thisArg)
97
+ )
98
+ );
93
99
  }
94
100
 
95
101
  /**
@@ -97,7 +103,7 @@ export class BehaviorComponent {
97
103
  * @param {Behavior} b
98
104
  * @returns {BehaviorComponent}
99
105
  */
100
- static fromOne(b) {
106
+ static from(b) {
101
107
  assert.defined(b, 'behavior');
102
108
  assert.notNull(b, 'behavior');
103
109
  assert.equal(b.isBehavior, true, 'b.isBehavior !== true');
@@ -111,6 +117,16 @@ export class BehaviorComponent {
111
117
  }
112
118
  }
113
119
 
120
+ /**
121
+ * @deprecated use {@link BehaviorComponent.from} instead
122
+ */
123
+ BehaviorComponent.fromOne = BehaviorComponent.from;
124
+
125
+ /**
126
+ * @deprecated use {@link BehaviorComponent.loop} instead
127
+ */
128
+ BehaviorComponent.looping_function = BehaviorComponent.loop;
129
+
114
130
  /**
115
131
  * @readonly
116
132
  * @type {boolean}
@@ -1 +1 @@
1
- {"version":3,"file":"BehaviorComponentSerializationAdapter.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/intelligence/behavior/ecs/BehaviorComponentSerializationAdapter.js"],"names":[],"mappings":"AAKA;IAEI,gCAA0B;IAG1B;;;OAGG;IACH,eAFU,gCAAgC,CAErB;IAErB;;;;OAIG;IACH,mBAHW,cAAc,iBACd,gCAAgC,QAI1C;IAED;;;;OAIG;IACH,kBAHW,YAAY,SACZ,iBAAiB,QAc3B;IAED;;;;OAIG;IACH,oBAHW,YAAY,SACZ,iBAAiB,QA+B3B;CACJ;gDA/E+C,gEAAgE;kCAC9E,wBAAwB"}
1
+ {"version":3,"file":"BehaviorComponentSerializationAdapter.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/intelligence/behavior/ecs/BehaviorComponentSerializationAdapter.js"],"names":[],"mappings":"AAKA;IAEI,gCAA0B;IAG1B;;;OAGG;IACH,eAFU,gCAAgC,CAErB;IAErB;;;;OAIG;IACH,mBAHW,cAAc,iBACd,gCAAgC,QAI1C;IAED;;;;OAIG;IACH,kBAHW,YAAY,SACZ,iBAAiB,QAc3B;IAED;;;;OAIG;IACH,oBAHW,YAAY,SACZ,iBAAiB,QA+B3B;CACJ;gDA/E+C,gEAAgE;kCAG9E,wBAAwB"}
@@ -1,7 +1,7 @@
1
1
  import { BinaryClassSerializationAdapter } from "../../../ecs/storage/binary/BinaryClassSerializationAdapter.js";
2
- import { BehaviorComponent } from "./BehaviorComponent.js";
3
2
  import { SequenceBehavior } from "../composite/SequenceBehavior.js";
4
3
  import { SucceedingBehavior } from "../primitive/SucceedingBehavior.js";
4
+ import { BehaviorComponent } from "./BehaviorComponent.js";
5
5
 
6
6
  export class BehaviorComponentSerializationAdapter extends BinaryClassSerializationAdapter {
7
7
 
@@ -74,7 +74,7 @@ export class BehaviorComponentSerializationAdapter extends BinaryClassSerializat
74
74
  } else if (behaviors.length === 1) {
75
75
  value.behavior = behaviors[0];
76
76
  } else {
77
- value.behavior = SucceedingBehavior.from(0);
77
+ value.behavior = SucceedingBehavior.INSTANCE;
78
78
  }
79
79
  }
80
80
  }
@@ -1,7 +1,33 @@
1
- import {System} from "../../../ecs/System";
2
- import Engine from "../../../Engine";
3
- import {BehaviorComponent} from "./BehaviorComponent";
4
-
5
- export class BehaviorSystem extends System<BehaviorComponent> {
6
- constructor(engine: Engine)
7
- }
1
+ export class BehaviorSystem extends System<any, any, any, any, any> {
2
+ /**
3
+ *
4
+ * @param {Engine} engine
5
+ */
6
+ constructor(engine: Engine);
7
+ dependencies: (typeof BehaviorComponent)[];
8
+ systemClock: Clock;
9
+ /**
10
+ *
11
+ * @type {Engine}
12
+ */
13
+ engine: Engine;
14
+ startup(entityManager: any, readyCallback: any, errorCallback: any): void;
15
+ shutdown(entityManager: any, readyCallback: any, errorCallback: any): void;
16
+ /**
17
+ *
18
+ * @param {BehaviorComponent} component
19
+ * @param {number} entity
20
+ */
21
+ link(component: BehaviorComponent, entity: number): void;
22
+ /**
23
+ *
24
+ * @param {BehaviorComponent} component
25
+ * @param {number} entity
26
+ */
27
+ unlink(component: BehaviorComponent, entity: number): void;
28
+ update(timeDelta: any): void;
29
+ }
30
+ import { System } from "../../../ecs/System.js";
31
+ import { BehaviorComponent } from "./BehaviorComponent.js";
32
+ import Clock from "../../../Clock.js";
33
+ //# sourceMappingURL=BehaviorSystem.d.ts.map
@@ -1,14 +1,15 @@
1
1
  /**
2
+ * Single-shot behavior that executes the given function and resolves {@link BehaviorStatus.SUCCESS}
2
3
  * @template CTX
3
4
  * @extends {Behavior<CTX>}
4
5
  */
5
6
  export class ActionBehavior<CTX> extends Behavior<CTX> {
6
7
  /**
7
8
  *
8
- * @param {function(timeDelta:number, context:CTX)} func
9
+ * @param {function(timeDelta:number, context:CTX)} action
9
10
  * @param {*} [thisArg] defaults to behavior itself if not specified
10
11
  */
11
- constructor(func: any, thisArg?: any);
12
+ constructor(action: any, thisArg?: any);
12
13
  __action: any;
13
14
  __context: any;
14
15
  tick(timeDelta: any): BehaviorStatus.Succeeded | BehaviorStatus.Failed;