@woosh/meep-engine 2.36.0 → 2.36.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 (32) hide show
  1. package/core/geom/AABB2.d.ts +2 -0
  2. package/core/geom/Vector3.js +5 -1
  3. package/core/process/undo/ActionProcessor.js +31 -3
  4. package/core/process/undo/ActionProcessor.spec.js +1 -1
  5. package/engine/animation/curve/AnimationCurve.js +40 -1
  6. package/engine/animation/curve/Keyframe.js +19 -0
  7. package/engine/animation/curve/compression/animation_curve_to_float_array.js +35 -0
  8. package/engine/animation/curve/compression/downsample_float_array.js +50 -0
  9. package/engine/animation/curve/compression/downsample_float_array_curve_by_error.js +147 -0
  10. package/engine/animation/curve/compression/downsample_float_array_curve_by_error.spec.js +47 -0
  11. package/engine/animation/curve/compression/prototypeCurveCompression.js +154 -0
  12. package/engine/animation/curve/draw/build_curve_editor.js +316 -0
  13. package/engine/animation/curve/draw/build_plot_entity_from_array.js +47 -0
  14. package/engine/animation/curve/draw/build_tangent_editor.js +115 -0
  15. package/engine/animation/curve/draw/draw_grid.js +27 -0
  16. package/engine/animation/curve/draw/draw_label.js +17 -0
  17. package/engine/animation/curve/draw/plot_array.js +76 -0
  18. package/engine/animation/curve/draw/plot_data.js +49 -0
  19. package/engine/ecs/parent/EntityNode.d.ts +7 -3
  20. package/engine/ecs/parent/EntityNode.js +21 -0
  21. package/engine/ecs/parent/entity_node_compute_bounding_box.js +41 -0
  22. package/engine/graphics/ecs/mesh-v2/render/adapters/InstancedRendererAdapter.js +2 -0
  23. package/engine/graphics/geometry/instancing/InstancedMeshGroup.js +34 -3
  24. package/engine/graphics/micron/format/serialization/collection/geometry_collection_serialization.spec.js +24 -0
  25. package/engine/graphics/micron/plugin/shaded_geometry/MicronShadedGeometryRenderAdapter.js +10 -0
  26. package/engine/graphics/micron/prototypeVirtualGeometry.js +5 -3
  27. package/engine/graphics/micron/render/v1/MicronRenderContext.js +0 -6
  28. package/engine/graphics/render/forward_plus/LightManager.js +8 -6
  29. package/engine/graphics/render/forward_plus/data/channelCountToThreIntegerTextureType.js +3 -3
  30. package/engine/graphics/texture/channelCountToThreeTextureFormat.js +2 -2
  31. package/engine/ui/DraggableAspect.js +4 -1
  32. package/package.json +1 -1
@@ -0,0 +1,41 @@
1
+ import { ShadedGeometry } from "../../graphics/ecs/mesh-v2/ShadedGeometry.js";
2
+ import { AABB3 } from "../../../core/bvh2/aabb3/AABB3.js";
3
+
4
+ const scratch_aabb3 = new AABB3();
5
+
6
+ /**
7
+ *
8
+ * @param {AABB3} out
9
+ * @param {EntityNode} root
10
+ */
11
+ export function entity_node_expand_bounding_box_to_fit(out, root) {
12
+ const sg = root.entity.getComponent(ShadedGeometry);
13
+
14
+ if (sg !== null) {
15
+ sg.getBoundingBox(scratch_aabb3);
16
+
17
+ out.expandToFit(scratch_aabb3);
18
+ }
19
+
20
+ const children = root.children;
21
+ const child_count = children.length;
22
+
23
+ for (let i = 0; i < child_count; i++) {
24
+ const child = children[i];
25
+
26
+ entity_node_expand_bounding_box_to_fit(out, child);
27
+ }
28
+ }
29
+
30
+ /**
31
+ *
32
+ * @param {AABB3} out
33
+ * @param {EntityNode} root
34
+ */
35
+ export function entity_node_compute_bounding_box(out, root) {
36
+ // init bounds
37
+ out.setNegativelyInfiniteBounds();
38
+
39
+ // expand bounds to fit the tree
40
+ entity_node_expand_bounding_box_to_fit(out, root);
41
+ }
@@ -3,6 +3,7 @@ import { HashMap } from "../../../../../../core/collection/HashMap.js";
3
3
  import { InstancedMeshGroup } from "../../../../geometry/instancing/InstancedMeshGroup.js";
4
4
  import { ShadedGeometryFlags } from "../../ShadedGeometryFlags.js";
5
5
  import { DrawMode } from "../../DrawMode.js";
6
+ import { StreamDrawUsage } from "three";
6
7
 
7
8
  const INSTANCED_EQUALITY_FLAGS = ShadedGeometryFlags.CastShadow
8
9
  | ShadedGeometryFlags.ReceiveShadow
@@ -89,6 +90,7 @@ export class InstancedRendererAdapter extends AbstractRenderAdapter {
89
90
  }
90
91
 
91
92
  im = new InstancedMeshGroup();
93
+ im.instance_usage = StreamDrawUsage;
92
94
  im.shrinkFactor = 0; // prevent shrinking as we're essentially rebuilding this geometry frame
93
95
 
94
96
  im.setMaterial(sg.material);
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  BufferGeometry,
3
+ DynamicDrawUsage,
3
4
  InstancedBufferAttribute,
4
5
  InstancedBufferGeometry,
5
6
  MeshDepthMaterial,
6
- RGBADepthPacking,
7
- StreamDrawUsage
7
+ RGBADepthPacking
8
8
  } from 'three';
9
9
  import ThreeFactory from "../../three/ThreeFactory.js";
10
10
  import { StaticMaterialCache } from "../../../asset/loaders/material/StaticMaterialCache.js";
@@ -77,6 +77,13 @@ export class InstancedMeshGroup {
77
77
  */
78
78
  this.__attributeTransformArray = null;
79
79
 
80
+ /**
81
+ *
82
+ * @type {Usage}
83
+ * @private
84
+ */
85
+ this.__instanceUsage = DynamicDrawUsage;
86
+
80
87
  /**
81
88
  *
82
89
  * @type {Material}
@@ -90,6 +97,30 @@ export class InstancedMeshGroup {
90
97
  this.mesh = ThreeFactory.createMesh();
91
98
  }
92
99
 
100
+ /**
101
+ *
102
+ * @param {Usage} v
103
+ */
104
+ set instance_usage(v) {
105
+ if (this.__instanceUsage === v) {
106
+ return;
107
+ }
108
+
109
+ this.__instanceUsage = v;
110
+
111
+ if (this.__attributeTransform !== null) {
112
+ this.__attributeTransform.setUsage(v);
113
+ }
114
+ }
115
+
116
+ /**
117
+ *
118
+ * @return {Usage}
119
+ */
120
+ get instance_usage() {
121
+ return this.__instanceUsage;
122
+ }
123
+
93
124
  dispose() {
94
125
  if (this.__threeGeometry !== null) {
95
126
  this.__threeGeometry.dispose();
@@ -367,7 +398,7 @@ export class InstancedMeshGroup {
367
398
  //rewrite old attributes
368
399
  this.__attributeTransformArray = newTransformArray;
369
400
  this.__attributeTransform = new InstancedBufferAttribute(newTransformArray, 16);
370
- this.__attributeTransform.setUsage(StreamDrawUsage);
401
+ this.__attributeTransform.setUsage(this.__instanceUsage);
371
402
 
372
403
  //add attributes to newly created geometry
373
404
  geometry.setAttribute("instanceMatrix", this.__attributeTransform);
@@ -0,0 +1,24 @@
1
+ import { deserialize_geometry_collection, serialize_geometry_collection } from "./geometry_collection_serialization.js";
2
+ import { BinaryBuffer } from "../../../../../../core/binary/BinaryBuffer.js";
3
+
4
+ test('serialize empty', () => {
5
+ const bb = new BinaryBuffer();
6
+
7
+ expect(() => {
8
+ serialize_geometry_collection([], bb);
9
+ }).not.toThrow();
10
+
11
+ });
12
+
13
+ test('serialize/deserialize empty', () => {
14
+ const bb = new BinaryBuffer();
15
+
16
+ serialize_geometry_collection([], bb);
17
+
18
+ bb.position = 0;
19
+
20
+ const destination = [];
21
+ deserialize_geometry_collection(destination, bb);
22
+
23
+ expect(destination.length).toBe(0);
24
+ });
@@ -90,6 +90,16 @@ export class MicronShadedGeometryRenderAdapter extends AbstractRenderAdapter {
90
90
  pixelRatio = renderer.getPixelRatio();
91
91
  }
92
92
 
93
+ // clear context
94
+ const material_contexts = this.ctx.contexts_array;
95
+ const contexts_count = material_contexts.length;
96
+ for (let i = 0; i < contexts_count; i++) {
97
+ const mc = material_contexts[i];
98
+
99
+ mc.instances.clear();
100
+ }
101
+
102
+ // initialize geometry builder
93
103
  const vg_builder = this.ctx.builder;
94
104
 
95
105
  vg_builder.resolution.set(resolution.x * pixelRatio, resolution.y * pixelRatio);
@@ -38,7 +38,9 @@ import { DRACOLoader } from "three/examples/jsm/loaders/DRACOLoader.js";
38
38
  import { TextureAttachmentsByMaterialType } from "../../asset/loaders/material/TextureAttachmensByMaterialType.js";
39
39
  import { distributePointsOnMesh } from "../particles/particular/engine/utils/distrubuteParticlesOnMesh.js";
40
40
  import { BinaryNode } from "../../../core/bvh2/BinaryNode.js";
41
- import { queryBinaryNode_SphereIntersections_Data } from "../../../core/bvh2/traversal/queryBinaryNode_SphereIntersections.js";
41
+ import {
42
+ queryBinaryNode_SphereIntersections_Data
43
+ } from "../../../core/bvh2/traversal/queryBinaryNode_SphereIntersections.js";
42
44
  import { ensureGeometryBoundingSphere } from "../geometry/buffered/ensureGeometryBoundingSphere.js";
43
45
  import { StaticMaterialCache } from "../../asset/loaders/material/StaticMaterialCache.js";
44
46
  import convertSampler2D2Canvas from "../texture/sampler/Sampler2D2Canvas.js";
@@ -461,7 +463,7 @@ function init() {
461
463
 
462
464
  // sample_gltf_sponza();
463
465
  // gltf_sample('data/models/RTS_Buildings_Humans/18/Building_R_18_out/Building_R_18.gltf');
464
- // sample_lucy();
466
+ sample_lucy();
465
467
  // sample_dragon();
466
468
  // sample_gltf_hapro_2();
467
469
  // sample_gltf_hapro_1();
@@ -481,7 +483,7 @@ function init() {
481
483
  // gltf_sample('moicon/03_Jan_22_Demo/8-assets/model.gltf');
482
484
  // gltf_sample('moicon/03_Jan_22_Demo/worker_test/model.gltf');
483
485
  // gltf_sample('moicon/A4/A4/model.gltf');
484
- gltf_sample('moicon/06_04_hapro/08-clickable-assets-new/model.gltf');
486
+ // gltf_sample('moicon/06_04_hapro/08-clickable-assets-new/model.gltf');
485
487
  // gltf_sample('moicon/ztest_object_many_pieces/model.gltf');
486
488
  // gltf_grid('moicon/ztest_object_many_pieces/model.gltf', 3, 3);
487
489
 
@@ -5,12 +5,6 @@ import Signal from "../../../../../core/events/signal/Signal.js";
5
5
  import { MaterialContext } from "./MaterialContext.js";
6
6
  import { MaterialVertexSpec, MaterialVertexSpecFlags } from "./MaterialVertexSpec.js";
7
7
 
8
- /**
9
- *
10
- * @type {MaterialVertexSpec}
11
- */
12
- const scratch_mvc = new MaterialVertexSpec();
13
-
14
8
  export class MicronRenderContext {
15
9
  constructor() {
16
10
 
@@ -9,7 +9,7 @@ import {
9
9
  LinearMipMapLinearFilter,
10
10
  NearestFilter,
11
11
  RGBAFormat,
12
- RGBAIntegerFormat,
12
+ RGBIntegerFormat,
13
13
  UnsignedByteType,
14
14
  UnsignedShortType
15
15
  } from "three";
@@ -25,7 +25,9 @@ import { read_frustum_planes_to_array } from "./cluster/read_frustum_planes_to_a
25
25
  import { compute_cluster_planes_from_points } from "./cluster/compute_cluster_planes_from_points.js";
26
26
  import { TextureBackedMemoryRegion } from "./data/TextureBackedMemoryRegion.js";
27
27
  import { assert } from "../../../../core/assert.js";
28
- import { DataType2TypedArrayConstructorMapping } from "../../../../core/collection/table/DataType2TypedArrayConstructorMapping.js";
28
+ import {
29
+ DataType2TypedArrayConstructorMapping
30
+ } from "../../../../core/collection/table/DataType2TypedArrayConstructorMapping.js";
29
31
  import { NumericType } from "./data/NumericType.js";
30
32
  import { computeDataType } from "./data/computeDataType.js";
31
33
  import { computeThreeTextureTypeFromDataType } from "./data/computeThreeTextureTypeFromDataType.js";
@@ -158,8 +160,8 @@ export class LightManager {
158
160
  this.__cluster_texture.minFilter = NearestFilter;
159
161
 
160
162
  this.__cluster_texture.type = UnsignedShortType;
161
- this.__cluster_texture.format = RGBAIntegerFormat;
162
- this.__cluster_texture.internalFormat = "RGBA16UI";
163
+ this.__cluster_texture.format = RGBIntegerFormat;
164
+ this.__cluster_texture.internalFormat = "RGB16UI";
163
165
 
164
166
  /**
165
167
  *
@@ -347,7 +349,7 @@ export class LightManager {
347
349
 
348
350
  const texture = this.__cluster_texture;
349
351
 
350
- const channelCount = 4;
352
+ const channelCount = 3;
351
353
 
352
354
  texture.dispose();
353
355
 
@@ -826,7 +828,7 @@ export class LightManager {
826
828
 
827
829
  const tile_index = slice_offset + (i_y_0 * tr_x) + i_x_0;
828
830
 
829
- const tile_address = tile_index * 4;
831
+ const tile_address = tile_index * 3;
830
832
 
831
833
 
832
834
  // construct tile data
@@ -1,4 +1,4 @@
1
- import { RedIntegerFormat, RGBAIntegerFormat, RGIntegerFormat } from "three";
1
+ import { RedIntegerFormat, RGBAIntegerFormat, RGBIntegerFormat, RGIntegerFormat } from "three";
2
2
 
3
3
  export function channelCountToThreIntegerTextureType(channel_count) {
4
4
  switch (channel_count) {
@@ -6,10 +6,10 @@ export function channelCountToThreIntegerTextureType(channel_count) {
6
6
  return RedIntegerFormat;
7
7
  case 2:
8
8
  return RGIntegerFormat;
9
+ case 3:
10
+ return RGBIntegerFormat;
9
11
  case 4:
10
12
  return RGBAIntegerFormat;
11
- case 3:
12
- // see https://github.com/mrdoob/three.js/pull/23228
13
13
  default:
14
14
  throw new Error(`Unsupported channel count '${channel_count}'`);
15
15
  }
@@ -1,4 +1,4 @@
1
- import { RedFormat, RGBAFormat, RGFormat } from "three";
1
+ import { RedFormat, RGBAFormat, RGBFormat, RGFormat } from "three";
2
2
 
3
3
  /**
4
4
  *
@@ -12,7 +12,7 @@ export function channelCountToThreeTextureFormat(count) {
12
12
  case 2:
13
13
  return RGFormat;
14
14
  case 3:
15
- // see https://github.com/mrdoob/three.js/pull/23228
15
+ return RGBFormat;
16
16
  case 4:
17
17
  return RGBAFormat;
18
18
  default:
@@ -12,7 +12,7 @@ export class DraggableAspect {
12
12
  *
13
13
  * @param {EventTarget} el
14
14
  * @param {function} [dragStart=noop]
15
- * @param {function} [drag=noop]
15
+ * @param {(position:Vector2,origin:Vector2)=>*} [drag=noop]
16
16
  * @param {function} [dragEnd=noop]
17
17
  * @param {boolean} [stopPropagation=true] prevent propagation of pointer events up the DOM tree
18
18
  */
@@ -34,6 +34,8 @@ export class DraggableAspect {
34
34
  const pointerGlobal = this.pointerGlobal = new PointerDevice(window);
35
35
 
36
36
  const dragOriginalPosition = new Vector2();
37
+ const delta = new Vector2();
38
+ const pointer_position_last = new Vector2();
37
39
 
38
40
  if (stopPropagation) {
39
41
  this.pointerLocal.on.down.add((p, e) => {
@@ -43,6 +45,7 @@ export class DraggableAspect {
43
45
 
44
46
  this.pointerLocal.on.dragStart.add((position) => {
45
47
  dragOriginalPosition.copy(position);
48
+ pointer_position_last.copy(position);
46
49
  pointerGlobal.start();
47
50
 
48
51
  dragStart(position);
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "productName": "Meep",
6
6
  "description": "production-ready JavaScript game engine based on Entity Component System Architecture",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.36.0",
8
+ "version": "2.36.1",
9
9
  "dependencies": {
10
10
  "gl-matrix": "3.4.3",
11
11
  "fast-levenshtein": "2.0.6",