@woosh/meep-engine 2.48.1 → 2.48.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 (74) hide show
  1. package/package.json +1 -1
  2. package/src/core/binary/32BitEncoder.js +11 -3
  3. package/src/core/binary/BinaryBuffer.js +80 -59
  4. package/src/core/binary/int32_to_binary_string.js +32 -7
  5. package/src/core/binary/to_half_float_uint16.js +6 -4
  6. package/src/core/bvh2/visual/convert_bvh_to_dot_format_string.js +1 -1
  7. package/src/core/collection/list/List.js +3 -0
  8. package/src/core/geom/3d/CircleMath.js +13 -2
  9. package/src/core/geom/3d/triangle/computeTrianglePlaneSide.js +4 -13
  10. package/src/core/geom/Vector3.spec.js +10 -0
  11. package/src/core/graph/convertGraphToDotString.js +13 -3
  12. package/src/core/graph/v2/Graph.js +17 -1
  13. package/src/core/graph/v2/NodeContainer.js +58 -0
  14. package/src/core/model/ModuleRegistry.js +44 -10
  15. package/src/core/model/ResourceAccessKind.js +11 -0
  16. package/src/core/model/ResourceAccessSpecification.js +41 -0
  17. package/src/engine/Engine.js +1 -1
  18. package/src/engine/ecs/EntityEventBinding.js +74 -0
  19. package/src/engine/ecs/EntityManager.js +143 -0
  20. package/src/engine/ecs/System.js +53 -5
  21. package/src/engine/ecs/animation/InverseKinematicsSystem.js +6 -0
  22. package/src/engine/ecs/attachment/AttachmentSystem.js +8 -0
  23. package/src/engine/ecs/dynamic_actions/DynamicActorSystem.js +5 -0
  24. package/src/engine/ecs/fow/FogOfWarRevealerSystem.js +7 -3
  25. package/src/engine/ecs/fow/FogOfWarSystem.js +6 -0
  26. package/src/engine/ecs/gui/GUIElementSystem.js +1 -1
  27. package/src/engine/ecs/gui/hud/HeadsUpDisplaySystem.js +8 -0
  28. package/src/engine/ecs/gui/position/ViewportPositionSystem.js +6 -0
  29. package/src/engine/ecs/speaker/VoiceSystem.js +13 -0
  30. package/src/engine/ecs/storage/binary/object/BinaryObjectSerializationAdapter2.js +451 -12
  31. package/src/engine/ecs/storage/binary/object/BinaryObjectSerializationAdapter2.spec.js +123 -0
  32. package/src/engine/ecs/system/computeSystemComponentDependencyGraph.js +71 -0
  33. package/src/engine/ecs/systems/RenderSystem.js +6 -0
  34. package/src/engine/ecs/terrain/ecs/Terrain.js +26 -44
  35. package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSystem.js +9 -0
  36. package/src/engine/ecs/terrain/tiles/TerrainTile.js +5 -0
  37. package/src/engine/ecs/terrain/tiles/TerrainTileManager.js +26 -6
  38. package/src/engine/ecs/tooltip/TooltipComponentSystem.js +7 -0
  39. package/src/engine/graphics/ecs/animation/animator/AnimationGraphSystem.js +6 -0
  40. package/src/engine/graphics/ecs/camera/CameraSystem.js +6 -0
  41. package/src/engine/graphics/ecs/camera/pp/PerfectPanner.js +4 -0
  42. package/src/engine/graphics/ecs/camera/topdown/TopDownCameraControllerSystem.js +5 -0
  43. package/src/engine/graphics/ecs/camera/topdown/TopDownCameraLanderSystem.js +6 -0
  44. package/src/engine/graphics/ecs/light/LightSystem.js +8 -0
  45. package/src/engine/graphics/ecs/mesh/MeshSystem.js +8 -1
  46. package/src/engine/graphics/ecs/path/PathDisplaySystem.js +7 -1
  47. package/src/engine/graphics/ecs/trail2d/Trail2DSystem.js +7 -0
  48. package/src/engine/graphics/geometry/instancing/InstancedMeshGroup.js +34 -7
  49. package/src/engine/graphics/particles/ecs/ParticleEmitterSystem.js +6 -0
  50. package/src/engine/grid/systems/GridPosition2TransformSystem.js +6 -0
  51. package/src/engine/grid/transform2grid/Transform2GridPositionSystem.js +6 -0
  52. package/src/engine/intelligence/behavior/Behavior.js +11 -0
  53. package/src/engine/intelligence/behavior/composite/CompositeBehavior.js +10 -4
  54. package/src/engine/intelligence/behavior/decorator/AbstractDecoratorBehavior.js +1 -0
  55. package/src/engine/intelligence/behavior/util/behavior_traverse_tree.js +8 -0
  56. package/src/engine/navigation/ecs/path_following/PathFollowingSystem.js +8 -0
  57. package/src/engine/network/RemoteController.js +60 -84
  58. package/src/engine/network/remoteEditor.js +108 -2
  59. package/src/engine/sound/SoundEngine.js +81 -79
  60. package/src/engine/sound/ecs/SoundControllerSystem.js +8 -0
  61. package/src/engine/sound/ecs/SoundListenerSystem.js +7 -0
  62. package/src/engine/sound/ecs/emitter/SoundEmitterComponentContext.js +42 -46
  63. package/src/engine/sound/ecs/emitter/SoundEmitterSystem.js +15 -2
  64. package/src/engine/sound/ecs/emitter/SoundTrack.js +137 -35
  65. package/src/engine/sound/ecs/emitter/SoundTrackFlags.js +17 -1
  66. package/src/engine/sound/ecs/emitter/SoundTrackNodes.js +2 -4
  67. package/src/engine/sound/ecs/emitter/loadSoundTrackAsset.js +1 -2
  68. package/src/generation/theme/ThemeEngine.js +20 -3
  69. package/src/view/{elements/image → common}/HTMLElementCacheKey.js +5 -5
  70. package/src/view/elements/button/ButtonView.js +10 -2
  71. package/src/view/elements/image/ImageView.js +1 -1
  72. package/src/view/elements/video/VideoView.js +1 -1
  73. package/src/view/interaction/CommandButtonView.js +16 -153
  74. package/src/view/interaction/createInterfaceCommandButton.js +124 -0
@@ -1,159 +1,22 @@
1
- import View from "../View.js";
2
- import dom from "../DOM.js";
3
- import { globalMetrics } from "../../engine/metrics/GlobalMetrics.js";
4
- import { MetricsCategory } from "../../engine/metrics/MetricsCategory.js";
5
- import EntityBuilder from "../../engine/ecs/EntityBuilder.js";
6
- import { SoundEmitter } from "../../engine/sound/ecs/emitter/SoundEmitter.js";
7
- import { Transform } from "../../engine/ecs/transform/Transform.js";
8
- import { SoundEmitterChannels } from "../../engine/sound/ecs/emitter/SoundEmitterSystem.js";
9
- import { SerializationMetadata } from "../../engine/ecs/components/SerializationMetadata.js";
10
- import { BehaviorComponent } from "../../engine/intelligence/behavior/ecs/BehaviorComponent.js";
11
- import { DelayBehavior } from "../../engine/intelligence/behavior/util/DelayBehavior.js";
12
- import { SequenceBehavior } from "../../engine/intelligence/behavior/composite/SequenceBehavior.js";
13
- import { DieBehavior } from "../../engine/intelligence/behavior/ecs/DieBehavior.js";
1
+ import { createInterfaceCommandButton } from "./createInterfaceCommandButton.js";
14
2
 
15
- class CommandButtonView extends View {
16
- /**
17
- *
18
- * @param {InterfaceCommand} prop
19
- * @param {GUIEngine} gui
20
- * @param {EntityComponentDataset} ecd
21
- * @constructor
22
- * @extends {View}
23
- */
24
- constructor(prop, gui, ecd) {
25
- super();
3
+ /**
4
+ *
5
+ * @param {InterfaceCommand} prop
6
+ * @param {GUIEngine} gui
7
+ * @param {EntityComponentDataset} ecd
8
+ * @extends {View}
9
+ */
10
+ export function makeCommandButtonView(prop, gui, ecd) {
26
11
 
27
- /**
28
- *
29
- * @type {InteractionCommand}
30
- */
31
- const command = prop.command;
32
12
 
13
+ const buttonView = createInterfaceCommandButton({
14
+ command: prop,
15
+ gui,
16
+ ecd
17
+ });
33
18
 
34
- const dButton = dom('button').css(prop.style).addClass('command-button-view');
19
+ buttonView.addClass('command-button-view');
35
20
 
36
- dButton.addClass('command-' + command.id);
37
-
38
- this.el = dButton.el;
39
-
40
-
41
- prop.tags.forEach(tag => {
42
- this.addClass(`tag-${tag}`);
43
- });
44
-
45
- /**
46
- *
47
- * @param {SoundTrack} sound
48
- */
49
- function playSound(sound) {
50
- if (sound === null) {
51
- return;
52
- }
53
-
54
- const soundEmitter = new SoundEmitter();
55
- soundEmitter.isPositioned = false;
56
- soundEmitter.channel = SoundEmitterChannels.Effects;
57
-
58
- const track = sound.clone();
59
-
60
- track.startWhenReady = true;
61
- track.channel = SoundEmitterChannels.Effects;
62
-
63
- const eb = new EntityBuilder();
64
-
65
- track.on.ended.add(() => eb.destroy());
66
-
67
- soundEmitter.tracks.add(track);
68
-
69
- eb
70
- .add(soundEmitter)
71
- .add(BehaviorComponent.fromOne(SequenceBehavior.from([
72
- DelayBehavior.fromJSON({ value: 5 }),
73
- new DieBehavior()
74
- ])))
75
- .add(new Transform())
76
- .add(SerializationMetadata.Transient)
77
- .build(ecd);
78
-
79
-
80
- track.on.ended.add(console.log);
81
- }
82
-
83
- dButton.el.onclick = function () {
84
- if (command.enabled.getValue()) {
85
- command.action();
86
-
87
- playSound(prop.actionSound);
88
-
89
- globalMetrics.record("command-used", {
90
- category: MetricsCategory.Interaction,
91
- label: command.id
92
- });
93
- }
94
- };
95
-
96
- dButton.on('mouseenter', () => {
97
-
98
- if (command.enabled.getValue()) {
99
- //only play the sound if the button is enabled
100
- playSound(prop.hoverSound);
101
- }
102
- });
103
-
104
- dButton.createChild('div').addClass('background');
105
- dButton.createChild('div').addClass('foreground');
106
-
107
- function updateEnableStatus() {
108
- const v = command.enabled.getValue();
109
-
110
- dButton.disabled = !v;
111
- dButton.setClass('disabled', !v);
112
- dButton.setClass('enabled', v);
113
- }
114
-
115
- function featureClassName(f) {
116
- return "feature-" + f;
117
- }
118
-
119
- function addCommandFeature(f) {
120
- dButton.addClass(featureClassName(f));
121
- }
122
-
123
- function removeCommandFeature(f) {
124
- dButton.removeClass(featureClassName(f));
125
- }
126
-
127
- if (command.features !== undefined) {
128
- command.features.forEach(addCommandFeature);
129
- command.features.on.added.add(addCommandFeature);
130
- command.features.on.removed.add(removeCommandFeature);
131
- }
132
-
133
- this.bindSignal(command.enabled.onChanged, updateEnableStatus);
134
- this.bindSignal(command.features.on.added, addCommandFeature);
135
- this.bindSignal(command.features.on.removed, removeCommandFeature);
136
-
137
- const tooltip = prop.tooltip;
138
-
139
- function tooltipFactory() {
140
- return gui.localization.getString(tooltip);
141
- }
142
-
143
- if (tooltip !== undefined) {
144
- gui.viewTooltips.manage(this, tooltipFactory);
145
- }
146
-
147
- this.on.linked.add(() => {
148
- command.features.forEach(addCommandFeature);
149
- updateEnableStatus();
150
- });
151
-
152
- this.on.unlinked.add(() => {
153
- command.features.forEach(removeCommandFeature);
154
- });
155
- }
21
+ return buttonView;
156
22
  }
157
-
158
-
159
- export default CommandButtonView;
@@ -0,0 +1,124 @@
1
+ import { createSound } from "../../engine/EntityCreator.js";
2
+ import { SoundEmitterChannels } from "../../engine/sound/ecs/emitter/SoundEmitterSystem.js";
3
+ import ButtonView from "../elements/button/ButtonView.js";
4
+ import { globalMetrics } from "../../engine/metrics/GlobalMetrics.js";
5
+ import { MetricsCategory } from "../../engine/metrics/MetricsCategory.js";
6
+
7
+ /**
8
+ *
9
+ * @param {InterfaceCommand} command
10
+ * @param {GUIEngine} gui
11
+ * @param {EntityComponentDataset} ecd
12
+ * @returns {View}
13
+ */
14
+ export function createInterfaceCommandButton({
15
+ command,
16
+ gui,
17
+ ecd
18
+ }) {
19
+
20
+ /**
21
+ *
22
+ * @type {InteractionCommand}
23
+ */
24
+ const interaction = command.command;
25
+
26
+ /**
27
+ *
28
+ * @param {SoundTrack} sound
29
+ */
30
+ function playSound(sound) {
31
+ if (sound === null) {
32
+ return;
33
+ }
34
+
35
+ createSound({
36
+ timeout: 5,
37
+ track: sound,
38
+ positioned: false,
39
+ channel: SoundEmitterChannels.Effects
40
+ }).build(ecd);
41
+
42
+ // track.on.ended.add(console.log);
43
+ }
44
+
45
+ const button = new ButtonView({
46
+ action() {
47
+ if (interaction.enabled.getValue()) {
48
+ interaction.action();
49
+
50
+ playSound(command.actionSound);
51
+
52
+ globalMetrics.record("command-used", {
53
+ category: MetricsCategory.Interaction,
54
+ label: interaction.id
55
+ });
56
+ }
57
+ },
58
+ classList: [
59
+ `command-${interaction.id}`
60
+ ],
61
+ css: command.style
62
+ });
63
+
64
+ button.el.addEventListener('mouseenter', () => {
65
+
66
+ if (interaction.enabled.getValue()) {
67
+ //only play the sound if the button is enabled
68
+ playSound(command.hoverSound);
69
+ }
70
+ });
71
+
72
+
73
+ function updateEnableStatus() {
74
+ const v = interaction.enabled.getValue();
75
+
76
+ button.enabled = v;
77
+ }
78
+
79
+ function featureClassName(f) {
80
+ return "feature-" + f;
81
+ }
82
+
83
+ function addCommandFeature(f) {
84
+ button.addClass(featureClassName(f));
85
+ }
86
+
87
+ function removeCommandFeature(f) {
88
+ button.removeClass(featureClassName(f));
89
+ }
90
+
91
+ if (interaction.features !== undefined) {
92
+ interaction.features.forEach(addCommandFeature);
93
+ interaction.features.on.added.add(addCommandFeature);
94
+ interaction.features.on.removed.add(removeCommandFeature);
95
+ }
96
+
97
+ button.bindSignal(interaction.enabled.onChanged, updateEnableStatus);
98
+ button.bindSignal(interaction.features.on.added, addCommandFeature);
99
+ button.bindSignal(interaction.features.on.removed, removeCommandFeature);
100
+
101
+ function tooltipFactory() {
102
+ return gui.localization.getString(command.tooltip);
103
+ }
104
+
105
+ if (command.tooltip !== undefined) {
106
+ gui.viewTooltips.manage(button, tooltipFactory);
107
+ }
108
+
109
+ button.on.linked.add(() => {
110
+ interaction.features.forEach(addCommandFeature);
111
+ updateEnableStatus();
112
+ });
113
+
114
+ button.on.unlinked.add(() => {
115
+ interaction.features.forEach(removeCommandFeature);
116
+ });
117
+
118
+
119
+ command.tags.forEach(tag => {
120
+ button.addClass(`tag-${tag}`);
121
+ });
122
+
123
+ return button;
124
+ }