@woosh/meep-engine 2.37.18 → 2.37.19

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 (111) hide show
  1. package/core/assert.js +1 -1
  2. package/core/collection/array/typed/isTypedArray.js +20 -0
  3. package/core/collection/array/typedArrayToDataType.js +1 -0
  4. package/core/collection/table/RowFirstTable.js +34 -0
  5. package/core/collection/table/RowFirstTable.spec.js +59 -1
  6. package/core/color/Color.js +14 -0
  7. package/core/color/rgb2hex.js +1 -1
  8. package/core/events/signal/Signal.spec.js +16 -0
  9. package/core/geom/Quaternion.d.ts +5 -0
  10. package/core/geom/Quaternion.js +152 -137
  11. package/core/geom/Quaternion.spec.js +47 -2
  12. package/core/geom/Vector3.schema.json +16 -0
  13. package/core/json/JsonUtils.js +2 -20
  14. package/core/model/ObservedEnum.js +8 -0
  15. package/editor/Editor.js +97 -1
  16. package/editor/actions/concrete/PatchTerrainHeightAction.js +1 -1
  17. package/editor/ecs/component/FieldDescriptor.js +34 -0
  18. package/editor/ecs/component/FieldValueAdapter.js +20 -0
  19. package/editor/ecs/component/TypeEditor.js +33 -0
  20. package/editor/ecs/component/TypeSchema.d.ts +38 -0
  21. package/editor/ecs/component/createFieldEditor.js +90 -0
  22. package/editor/ecs/component/createObjectEditor.js +242 -60
  23. package/editor/ecs/component/editors/ColorEditor.js +39 -0
  24. package/editor/ecs/component/editors/HTMLElementEditor.js +17 -0
  25. package/editor/ecs/component/editors/ImagePathEditor.js +50 -0
  26. package/editor/ecs/component/editors/NumericIntervalEditor.js +86 -0
  27. package/editor/ecs/component/editors/ObservedBooleanEditor.js +13 -0
  28. package/editor/ecs/component/editors/ObservedEnumEditor.js +32 -0
  29. package/editor/ecs/component/editors/ObservedIntegerEditor.js +43 -0
  30. package/editor/ecs/component/editors/ObservedStringEditor.js +51 -0
  31. package/editor/ecs/component/editors/Sampler2DEditor.js +60 -0
  32. package/editor/ecs/component/editors/collection/ListEditor.js +83 -0
  33. package/editor/ecs/component/editors/common/BitFlagsEditor.js +80 -0
  34. package/editor/ecs/component/editors/common/EnumEditor.js +41 -0
  35. package/editor/ecs/component/editors/common/makeV3_editor.js +85 -0
  36. package/editor/ecs/component/editors/common/noEditor.js +9 -0
  37. package/editor/ecs/component/editors/ecs/GridObstacleEditor.js +17 -0
  38. package/editor/ecs/component/editors/ecs/MinimapMarkerEditor.js +16 -0
  39. package/editor/ecs/component/editors/ecs/ParameterLookupTableEditor.js +44 -0
  40. package/editor/ecs/component/editors/ecs/ParameterTrackEditor.js +17 -0
  41. package/editor/ecs/component/editors/ecs/ParticleEmitterEditor.js +58 -0
  42. package/editor/ecs/component/editors/ecs/ParticleEmitterLayerEditor.js +54 -0
  43. package/editor/ecs/component/editors/ecs/SimulationStepDefinitionEditor.js +21 -0
  44. package/editor/ecs/component/editors/ecs/Trail2DEditor.js +33 -0
  45. package/editor/ecs/component/editors/ecs/TransformEditor.js +23 -0
  46. package/editor/ecs/component/editors/ecs/terrain/SplatMappingEditor.js +21 -0
  47. package/editor/ecs/component/editors/ecs/terrain/TerrainEditor.js +42 -0
  48. package/editor/ecs/component/editors/ecs/terrain/TerrainLayerEditor.js +18 -0
  49. package/editor/ecs/component/editors/ecs/terrain/TerrainLayersEditor.js +22 -0
  50. package/editor/ecs/component/editors/ecs/terrain/TerrainOverlayEditor.js +20 -0
  51. package/editor/ecs/component/editors/geom/QuaternionEditor.js +56 -0
  52. package/editor/ecs/component/editors/geom/Vector1Editor.js +57 -0
  53. package/editor/ecs/component/editors/geom/Vector2Editor.js +11 -0
  54. package/editor/ecs/component/editors/geom/Vector3Editor.js +13 -0
  55. package/editor/ecs/component/editors/geom/Vector4Editor.js +12 -0
  56. package/editor/ecs/component/editors/primitive/ArrayEditor.js +46 -0
  57. package/editor/ecs/component/editors/primitive/BooleanEditor.js +27 -0
  58. package/editor/ecs/component/editors/primitive/FunctionEditor.js +25 -0
  59. package/editor/ecs/component/editors/primitive/NumberEditor.js +60 -0
  60. package/editor/ecs/component/editors/primitive/ObjectEditor.js +12 -0
  61. package/editor/ecs/component/editors/primitive/StringEditor.js +31 -0
  62. package/editor/ecs/component/editors/three/BufferGeometryEditor.js +28 -0
  63. package/editor/ecs/component/editors/three/MaterialEditor.js +27 -0
  64. package/editor/ecs/component/editors/three/MeshEditor.js +35 -0
  65. package/editor/ecs/component/editors/three/TextureEditor.js +32 -0
  66. package/editor/ecs/component/findNearestRegisteredType.js +59 -0
  67. package/editor/ecs/component/prototypeObjectEditor.js +379 -0
  68. package/editor/view/EditorView.js +1 -1
  69. package/editor/view/ecs/ComponentControlView.js +2 -30
  70. package/editor/view/ecs/EntityEditor.js +61 -139
  71. package/editor/view/ecs/components/GridObstacleController.js +4 -4
  72. package/editor/view/ecs/components/TerrainController.js +1 -1
  73. package/editor/view/ecs/components/common/NumberController.js +19 -7
  74. package/engine/animation/keyed2/AnimationTrack.js +1 -1
  75. package/engine/ecs/components/TagEditor.js +15 -0
  76. package/engine/ecs/terrain/ecs/Terrain.js +23 -42
  77. package/engine/ecs/terrain/ecs/TerrainSystem.js +2 -2
  78. package/engine/ecs/terrain/ecs/layers/TerrainLayer.js +1 -1
  79. package/engine/ecs/terrain/util/loadVisibleTerrainTiles.js +1 -1
  80. package/engine/ecs/transform/Transform.editor.schema.json +16 -0
  81. package/engine/graphics/ecs/highlight/HighlightEditor.js +17 -0
  82. package/engine/graphics/ecs/mesh/MeshEditor.js +28 -0
  83. package/engine/graphics/ecs/mesh-v2/aggregate/prototypeSGMesh.js +3 -3
  84. package/engine/graphics/micron/render/instanced/shader/shader_rewrite_standard.js +15 -15
  85. package/engine/graphics/particles/particular/engine/ParticularEngine.js +5 -0
  86. package/engine/graphics/texture/sampler/Sampler2D.js +16 -0
  87. package/engine/graphics/util/ScaleObject3ToBox.js +14 -1
  88. package/engine/graphics/util/makeMeshPreviewScene.js +2 -1
  89. package/engine/grid/components/GridObstacle.js +0 -44
  90. package/engine/grid/components/GridObstacleSerializationAdapter.js +46 -0
  91. package/engine/navigation/ecs/components/Path.d.ts +2 -0
  92. package/engine/navigation/ecs/components/Path.js +6 -1
  93. package/generation/example/SampleGenerator0.js +33 -29
  94. package/generation/example/generators/interactive/mir_generator_place_buff_objects.js +7 -6
  95. package/generation/example/generators/mir_generator_place_bases.js +7 -3
  96. package/generation/example/generators/mir_generator_place_road_decorators.js +3 -3
  97. package/generation/example/generators/mir_generator_place_starting_point.js +3 -2
  98. package/generation/markers/GridCellActionPlaceMarker.js +9 -3
  99. package/generation/markers/transform/MarkerNodeTransformerOffsetPosition.js +1 -1
  100. package/generation/placement/GridCellPlacementRule.js +22 -23
  101. package/generation/theme/ThemeEngine.js +1 -1
  102. package/package.json +1 -1
  103. package/samples/terrain/main.js +1 -1
  104. package/view/View.js +23 -1
  105. package/view/common/LabelView.js +1 -1
  106. package/view/compose3x3transform.js +32 -8
  107. package/view/controller/dat/DatGuiUtils.js +1 -1
  108. package/view/elements/DropDownSelectionView.js +11 -3
  109. package/view/elements/image/ImageView.js +3 -1
  110. package/core/model/ObservedReal.js +0 -55
  111. package/editor/ecs/component/ObjectEditor.js +0 -0
@@ -0,0 +1,16 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-04/schema",
3
+ "title": "Vector3",
4
+ "type": "object",
5
+ "properties": {
6
+ "x": {
7
+ "type": "number"
8
+ },
9
+ "y": {
10
+ "type": "number"
11
+ },
12
+ "z": {
13
+ "type": "number"
14
+ }
15
+ }
16
+ }
@@ -2,24 +2,7 @@
2
2
  * Created by Alex on 03/11/2016.
3
3
  */
4
4
 
5
- /**
6
- *
7
- * @param o
8
- * @returns {boolean}
9
- */
10
- function isTypedArray(o) {
11
- return (
12
- o instanceof Int8Array ||
13
- o instanceof Uint8Array ||
14
- o instanceof Uint8ClampedArray ||
15
- o instanceof Int16Array ||
16
- o instanceof Uint16Array ||
17
- o instanceof Int32Array ||
18
- o instanceof Uint32Array ||
19
- o instanceof Float32Array ||
20
- o instanceof Float64Array
21
- );
22
- }
5
+ import { isTypedArray } from "../collection/array/typed/isTypedArray.js";
23
6
 
24
7
  /**
25
8
  *
@@ -114,6 +97,5 @@ function stringify(json) {
114
97
 
115
98
  export {
116
99
  stringify,
117
- stringifyStream,
118
- isTypedArray
100
+ stringifyStream
119
101
  };
@@ -22,6 +22,14 @@ function ObservedEnum(value, validSet) {
22
22
  this.onChanged = new Signal();
23
23
  }
24
24
 
25
+ /**
26
+ *
27
+ * @returns {Object<string, T>}
28
+ */
29
+ ObservedEnum.prototype.getValidValueSet = function () {
30
+ return this.__validSet;
31
+ }
32
+
25
33
  /**
26
34
  *
27
35
  * @param {T} value
package/editor/Editor.js CHANGED
@@ -23,7 +23,9 @@ import EditorEntitySystem from "./ecs/EditorEntitySystem.js";
23
23
  import EditorEntity from "./ecs/EditorEntity.js";
24
24
  import TopDownCameraController from "../engine/graphics/ecs/camera/topdown/TopDownCameraController.js";
25
25
  import { Transform } from "../engine/ecs/transform/Transform.js";
26
- import TopDownCameraControllerSystem, { setCameraControllerFromTransform } from "../engine/graphics/ecs/camera/topdown/TopDownCameraControllerSystem.js";
26
+ import TopDownCameraControllerSystem, {
27
+ setCameraControllerFromTransform
28
+ } from "../engine/graphics/ecs/camera/topdown/TopDownCameraControllerSystem.js";
27
29
  import { downloadAsFile } from "../core/binary/ByteArrayTools.js";
28
30
  import BinaryBufferSerializer from "../engine/ecs/storage/BinaryBufferSerializer.js";
29
31
  import { EncodingBinaryBuffer } from "../core/binary/EncodingBinaryBuffer.js";
@@ -31,6 +33,41 @@ import { EntityComponentDataset } from "../engine/ecs/EntityComponentDataset.js"
31
33
  import InputControllerSystem from "../engine/input/ecs/systems/InputControllerSystem.js";
32
34
  import { assert } from "../core/assert.js";
33
35
  import { resetSoundEmitterTracks } from "../../model/game/options/resetSoundEmitterTracks.js";
36
+ import { NumberEditor } from "./ecs/component/editors/primitive/NumberEditor.js";
37
+ import { BooleanEditor } from "./ecs/component/editors/primitive/BooleanEditor.js";
38
+ import { StringEditor } from "./ecs/component/editors/primitive/StringEditor.js";
39
+ import { FunctionEditor } from "./ecs/component/editors/primitive/FunctionEditor.js";
40
+ import { ArrayEditor } from "./ecs/component/editors/primitive/ArrayEditor.js";
41
+ import { ObjectEditor } from "./ecs/component/editors/primitive/ObjectEditor.js";
42
+ import { NumericInterval } from "../core/math/interval/NumericInterval.js";
43
+ import { NumericIntervalEditor } from "./ecs/component/editors/NumericIntervalEditor.js";
44
+ import { ListEditor } from "./ecs/component/editors/collection/ListEditor.js";
45
+ import ObservedBoolean from "../core/model/ObservedBoolean.js";
46
+ import { ObservedBooleanEditor } from "./ecs/component/editors/ObservedBooleanEditor.js";
47
+ import ObservedEnum from "../core/model/ObservedEnum.js";
48
+ import { ObservedEnumEditor } from "./ecs/component/editors/ObservedEnumEditor.js";
49
+ import { Color } from "../core/color/Color.js";
50
+ import { ColorEditor } from "./ecs/component/editors/ColorEditor.js";
51
+ import Vector4 from "../core/geom/Vector4.js";
52
+ import { Vector4Editor } from "./ecs/component/editors/geom/Vector4Editor.js";
53
+ import Vector3 from "../core/geom/Vector3.js";
54
+ import { Vector3Editor } from "./ecs/component/editors/geom/Vector3Editor.js";
55
+ import Vector2 from "../core/geom/Vector2.js";
56
+ import { Vector2Editor } from "./ecs/component/editors/geom/Vector2Editor.js";
57
+ import Vector1 from "../core/geom/Vector1.js";
58
+ import { Vector1Editor } from "./ecs/component/editors/geom/Vector1Editor.js";
59
+ import ObservedString from "../core/model/ObservedString.js";
60
+ import { ObservedStringEditor } from "./ecs/component/editors/ObservedStringEditor.js";
61
+ import Quaternion from "../core/geom/Quaternion.js";
62
+ import { QuaternionEditor } from "./ecs/component/editors/geom/QuaternionEditor.js";
63
+ import { Sampler2D } from "../engine/graphics/texture/sampler/Sampler2D.js";
64
+ import { Sampler2DEditor } from "./ecs/component/editors/Sampler2DEditor.js";
65
+ import { HTMLElementEditor } from "./ecs/component/editors/HTMLElementEditor.js";
66
+ import WorkerProxy from "../core/process/worker/WorkerProxy.js";
67
+ import { noEditor } from "./ecs/component/editors/common/noEditor.js";
68
+ import Signal from "../core/events/signal/Signal.js";
69
+ import ObservedInteger from "../core/model/ObservedInteger.js";
70
+ import { ObservedIntegerEditor } from "./ecs/component/editors/ObservedIntegerEditor.js";
34
71
 
35
72
 
36
73
  /**
@@ -301,6 +338,57 @@ function activateEditorCamera(cameraEntity, dataset, editor) {
301
338
  camera.active.set(true);
302
339
  }
303
340
 
341
+ /**
342
+ *
343
+ * @param {Map<any, TypeEditor>} registry
344
+ */
345
+ function initialize_basic_registry(registry) {
346
+
347
+ registry.set(Number, new NumberEditor());
348
+ registry.set(Boolean, new BooleanEditor());
349
+ registry.set(String, new StringEditor());
350
+ registry.set(Function, new FunctionEditor());
351
+ registry.set(Array, new ArrayEditor());
352
+ registry.set(Object, new ObjectEditor());
353
+
354
+ registry.set(ObservedInteger, new ObservedIntegerEditor());
355
+ registry.set(ObservedBoolean, new ObservedBooleanEditor());
356
+ registry.set(ObservedEnum, new ObservedEnumEditor());
357
+ registry.set(ObservedString, new ObservedStringEditor());
358
+
359
+ registry.set(NumericInterval, new NumericIntervalEditor());
360
+ registry.set(List, new ListEditor());
361
+ registry.set(Color, new ColorEditor());
362
+
363
+ registry.set(Vector4, new Vector4Editor());
364
+ registry.set(Vector3, new Vector3Editor());
365
+ registry.set(Vector2, new Vector2Editor());
366
+ registry.set(Vector1, new Vector1Editor());
367
+ registry.set(Quaternion, new QuaternionEditor());
368
+
369
+ registry.set(Sampler2D, new Sampler2DEditor());
370
+
371
+ registry.set(HTMLElement, new HTMLElementEditor());
372
+ registry.set(HTMLCanvasElement, new HTMLElementEditor());
373
+
374
+ registry.set(WorkerProxy, noEditor());
375
+ registry.set(Signal, noEditor());
376
+
377
+ registry.set(Uint8Array, noEditor());
378
+ registry.set(Uint16Array, noEditor());
379
+ registry.set(Uint32Array, noEditor());
380
+
381
+ registry.set(Int8Array, noEditor());
382
+ registry.set(Int16Array, noEditor());
383
+ registry.set(Int32Array, noEditor());
384
+
385
+ registry.set(Float32Array, noEditor());
386
+ registry.set(Float64Array, noEditor());
387
+
388
+ registry.set(CanvasRenderingContext2D, noEditor());
389
+
390
+ }
391
+
304
392
  /**
305
393
  *
306
394
  * @constructor
@@ -315,6 +403,14 @@ function Editor() {
315
403
  this.selectionVistualizer = new SelectionVisualizer(this);
316
404
  this.meshLibrary = new MeshLibrary();
317
405
 
406
+ /**
407
+ *
408
+ * @type {Map<any, TypeEditor>}
409
+ */
410
+ this.type_editor_registry = new Map();
411
+
412
+ initialize_basic_registry(this.type_editor_registry);
413
+
318
414
  this.cameraEntity = buildEditorCamera();
319
415
 
320
416
  this.editorEntitySystem = new EditorEntitySystem();
@@ -79,7 +79,7 @@ export class PatchTerrainHeightAction extends Action {
79
79
  *
80
80
  * @type {TerrainTileManager}
81
81
  */
82
- const tiles = terrain.tiles;
82
+ const tiles = terrain.__tiles;
83
83
 
84
84
  tiles.buildWorker.setHeightSampler(heightMap.data, heightMap.itemSize, heightMap.width, heightMap.height);
85
85
 
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @template T
3
+ */
4
+ export class FieldDescriptor {
5
+ constructor() {
6
+ /**
7
+ *
8
+ * @type {string}
9
+ */
10
+ this.name = "";
11
+
12
+ /**
13
+ * typeof field
14
+ * @type {Class<T>}
15
+ */
16
+ this.type = null;
17
+
18
+ /**
19
+ *
20
+ * @type {FieldValueAdapter|null}
21
+ */
22
+ this.adapter = null;
23
+
24
+ /**
25
+ *
26
+ * @type {{}|undefined}
27
+ */
28
+ this.schema = undefined;
29
+ }
30
+
31
+ toString() {
32
+ return `FieldDescriptor[name='${this.name}']`;
33
+ }
34
+ }
@@ -0,0 +1,20 @@
1
+ import { assert } from "../../../core/assert.js";
2
+
3
+ export class FieldValueAdapter {
4
+ constructor() {
5
+ this.writable = true;
6
+ this.readable = true;
7
+
8
+ }
9
+
10
+ read(object, field_name) {
11
+ assert.isString(field_name, 'field_name');
12
+
13
+
14
+ return object[field_name];
15
+ }
16
+
17
+ write(object, field_name, value) {
18
+ object[field_name] = value;
19
+ }
20
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @class
3
+ * @template T
4
+ */
5
+ export class TypeEditor {
6
+ inline = true;
7
+
8
+ /**
9
+ * Class is hidden and editor should not be displayed
10
+ * @returns {boolean}
11
+ */
12
+ get hidden() {
13
+ return false;
14
+ }
15
+
16
+ /**
17
+ *
18
+ * @returns {TypeSchema|undefined}
19
+ */
20
+ get schema() {
21
+ return undefined;
22
+ }
23
+
24
+ /**
25
+ * @param {*} parent
26
+ * @param {FieldDescriptor} field
27
+ * @param {Map<*, TypeEditor>} registry
28
+ * @returns {View|void}
29
+ */
30
+ build(parent, field, registry) {
31
+ throw new Error('Not Implemented');
32
+ }
33
+ }
@@ -0,0 +1,38 @@
1
+ import {DataType} from "../../../core/parser/simple/DataType";
2
+
3
+ interface Type<T> extends Function {
4
+ new(...args: any[]): T;
5
+ }
6
+
7
+ interface PropertiesSchema {
8
+ [key: string]: FieldSchema<any>;
9
+ }
10
+
11
+ export interface TypeSchema {
12
+ additionalProperties?: boolean
13
+ properties: PropertiesSchema
14
+ }
15
+
16
+ interface TypeEditor {
17
+
18
+ }
19
+
20
+ export interface FieldSchema<T> {
21
+ type: Type<T>
22
+ type_parameters?: any[]
23
+ transient?: boolean
24
+ description?: string,
25
+ editor?: TypeEditor
26
+ deprecated?: boolean,
27
+ enum?: T[],
28
+ numeric_type: DataType,
29
+ /**
30
+ * Small image to be displayed next to field name
31
+ */
32
+ thumbnail: string,
33
+ /**
34
+ * @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#section-6.2.2
35
+ */
36
+ maximum?: number,
37
+ minimum?: number
38
+ }
@@ -0,0 +1,90 @@
1
+ import EmptyView from "../../../view/elements/EmptyView.js";
2
+ import LabelView from "../../../view/common/LabelView.js";
3
+
4
+ function format_field_name(name) {
5
+ return name
6
+ .replace(/([a-z])([A-Z])/g, '$1 $2') // break up camel case
7
+ .replace(/([^.])_([^.])/g, '$1 $2') // break up underscore case
8
+ .replace(/(^\w{1})|(\s+\w{1})/g, letter => letter.toUpperCase()); // capitalize every word
9
+ }
10
+
11
+ /**
12
+ * @template CTX
13
+ * @param {Object} object
14
+ * @param {FieldDescriptor} field
15
+ * @param {Map<*, TypeEditor>} registry
16
+ */
17
+ export function createFieldEditor(object, field, registry) {
18
+
19
+ const field_schema = field.schema;
20
+
21
+ let vValue;
22
+
23
+ /**
24
+ * @type {TypeEditor}
25
+ */
26
+ let factory;
27
+ if (field_schema !== undefined) {
28
+ const specific_field_editor = field_schema.editor;
29
+
30
+ if (specific_field_editor !== undefined) {
31
+ // field has a dedicated editor
32
+ factory = specific_field_editor;
33
+ }
34
+ }
35
+
36
+ if (factory === undefined) {
37
+ factory = registry.get(field.type);
38
+ }
39
+
40
+ let orientation_inline = true;
41
+
42
+ if (factory !== undefined) {
43
+ if (factory.hidden) {
44
+ // hidden class
45
+ return null;
46
+ }
47
+
48
+ vValue = factory.build(object, field, registry);
49
+
50
+ if (vValue) {
51
+ orientation_inline = factory.inline;
52
+ }
53
+ }
54
+
55
+ if (vValue === null || vValue === undefined) {
56
+ // no view
57
+ return null;
58
+ }
59
+
60
+ const vResult = new EmptyView({
61
+ classList: ['auto-field-editor']
62
+ });
63
+
64
+ if (orientation_inline) {
65
+ vResult.addClass('orientation-inline');
66
+ }
67
+
68
+ const field_formatted_name = format_field_name(field.name);
69
+
70
+ const vLabel = new LabelView(field_formatted_name, { classList: ['field-name'] });
71
+
72
+ vResult.addChild(vLabel);
73
+ vResult.addChild(vValue);
74
+
75
+
76
+ if (field_schema !== undefined) {
77
+ if (field_schema.description !== undefined && field_schema.description.length > 0) {
78
+ // add tooltip
79
+ vLabel.attr({
80
+ title: field_schema.description
81
+ });
82
+ }
83
+
84
+ if (field_schema.deprecated) {
85
+ vResult.addClass('field-deprecated');
86
+ }
87
+ }
88
+
89
+ return vResult;
90
+ }