@woosh/meep-engine 2.60.1 → 2.61.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 (63) hide show
  1. package/build/meep.cjs +20117 -20157
  2. package/build/meep.min.js +1 -1
  3. package/build/meep.module.js +20117 -20157
  4. package/package.json +1 -1
  5. package/src/core/binary/BitSet.js +1 -1
  6. package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js +30 -182
  7. package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.spec.js +27 -1
  8. package/src/core/geom/ConicRay.js +16 -21
  9. package/src/core/geom/ConicRay.spec.js +24 -0
  10. package/src/core/geom/packing/miniball/Miniball.js +68 -117
  11. package/src/core/geom/packing/miniball/Miniball.spec.js +3 -3
  12. package/src/core/geom/packing/miniball/Subspan.js +47 -34
  13. package/src/core/geom/packing/miniball/miniball_compute_quality.js +64 -0
  14. package/src/core/math/bessel_3.js +1 -0
  15. package/src/core/math/random/randomBytes.js +2 -2
  16. package/src/core/math/sqr.js +8 -0
  17. package/src/core/model/node-graph/Connection.js +21 -23
  18. package/src/core/model/node-graph/DataType.js +16 -17
  19. package/src/core/model/node-graph/NodeGraph.js +49 -50
  20. package/src/core/model/node-graph/node/NodeDescription.js +42 -44
  21. package/src/core/model/node-graph/node/NodeInstance.js +59 -60
  22. package/src/core/model/node-graph/node/NodeInstancePortReference.js +27 -29
  23. package/src/core/model/node-graph/node/NodeRegistry.js +16 -18
  24. package/src/core/model/node-graph/node/Port.js +35 -37
  25. package/src/core/model/node-graph/node/parameter/NodeParameterDescription.js +27 -13
  26. package/src/core/path/computePathDirectory.spec.js +8 -0
  27. package/src/core/process/BaseProcess.d.ts +5 -0
  28. package/src/core/process/WatchDog.js +76 -75
  29. package/src/core/process/action/AsynchronousAction.js +24 -22
  30. package/src/core/process/executor/profile/Profile.js +34 -24
  31. package/src/core/process/executor/profile/TraceEvent.js +75 -75
  32. package/src/core/process/worker/OnDemandWorkerManager.js +27 -30
  33. package/src/core/process/worker/WorkerBuilder.js +149 -149
  34. package/src/core/process/worker/WorkerProxy.js +25 -21
  35. package/src/core/process/worker/extractTransferables.js +2 -2
  36. package/src/engine/Engine.js +58 -53
  37. package/src/engine/EngineConfiguration.d.ts +4 -4
  38. package/src/engine/ecs/EntityManager.js +517 -614
  39. package/src/engine/ecs/System.js +2 -2
  40. package/src/engine/ecs/transform/Transform.d.ts +7 -5
  41. package/src/engine/ecs/transform/Transform.js +30 -16
  42. package/src/engine/ecs/validateSystem.js +89 -0
  43. package/src/engine/graphics/GraphicsEngine.js +433 -483
  44. package/src/engine/graphics/camera/testClippingPlaneComputation.js +46 -48
  45. package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +2 -2
  46. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +2 -2
  47. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshSystem.js +2 -2
  48. package/src/engine/graphics/ecs/path/tube/prototypeAnimatedPathMask.js +60 -62
  49. package/src/engine/graphics/ecs/water2/shader/testWaterShader.js +20 -22
  50. package/src/engine/graphics/particles/particular/engine/ParticularEngine.js +156 -180
  51. package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +69 -71
  52. package/src/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +51 -53
  53. package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +67 -69
  54. package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +56 -58
  55. package/src/engine/graphics/shadows/testShadowMapRendering.js +30 -34
  56. package/src/engine/graphics/texture/sampler/resize/sampler2d_scale_down_lanczos.spec.js +22 -20
  57. package/src/engine/graphics/texture/sampler/resize/sampler2d_scale_down_linear.js +10 -13
  58. package/src/engine/graphics/texture/virtual/VirtualTexture.spec.js +1 -1
  59. package/src/engine/plugin/EnginePluginManager.d.ts +6 -1
  60. package/src/engine/ecs/components/ClingToHeightMap.js +0 -19
  61. package/src/engine/ecs/components/SynchronizePosition.js +0 -15
  62. package/src/engine/ecs/systems/ClingToHeightMapSystem.js +0 -170
  63. package/src/engine/ecs/systems/SynchronizePositionSystem.js +0 -43
@@ -23,9 +23,9 @@ class System {
23
23
 
24
24
  /**
25
25
  * @readonly
26
- * @type {ObservedValue.<System.State>}
26
+ * @type {ObservedValue.<SystemState>}
27
27
  */
28
- state = new ObservedValue(System.State.INITIAL);
28
+ state = new ObservedValue(SystemState.INITIAL);
29
29
 
30
30
  /**
31
31
  * Other components which have to be present before the system links component
@@ -1,16 +1,18 @@
1
- import Vector3 from "../../../core/geom/Vector3";
2
1
  import Quaternion from "../../../core/geom/Quaternion";
2
+ import Vector3 from "../../../core/geom/Vector3";
3
3
 
4
4
  export class Transform {
5
- public readonly position: Vector3
6
- public readonly rotation: Quaternion
7
- public readonly scale: Vector3
5
+ readonly position: Vector3
6
+ readonly rotation: Quaternion
7
+ readonly scale: Vector3
8
+
9
+ readonly forward: Vector3
8
10
 
9
11
  flags: number
10
12
 
11
13
  public readonly matrix: ArrayLike<number>
12
14
 
13
- public lookAt(target: Vector3): void
15
+ public lookAt(target: Vector3, up?: Vector3): void
14
16
 
15
17
  static fromJSON(json: {
16
18
  position?: { x: number, y: number, z: number },
@@ -2,15 +2,15 @@
2
2
  * Created by Alex on 02/04/2014.
3
3
  */
4
4
 
5
- import Vector3 from "../../../core/geom/Vector3.js";
5
+ import {assert} from "../../../core/assert.js";
6
+ import {compose_matrix4_array} from "../../../core/geom/3d/compose_matrix4_array.js";
7
+ import {decompose_matrix_4_array} from "../../../core/geom/3d/decompose_matrix_4_array.js";
8
+ import {allocate_transform_m4} from "../../../core/geom/3d/matrix/allocate_transform_m4.js";
9
+ import {m4_multiply} from "../../../core/geom/3d/matrix/m4_multiply.js";
10
+ import {MATRIX_4_IDENTITY} from "../../../core/geom/3d/matrix/MATRIX_4_IDENTITY.js";
6
11
  import Quaternion from "../../../core/geom/Quaternion.js";
7
- import { decompose_matrix_4_array } from "../../../core/geom/3d/decompose_matrix_4_array.js";
8
- import { compose_matrix4_array } from "../../../core/geom/3d/compose_matrix4_array.js";
9
- import { TransformFlags } from "./TransformFlags.js";
10
- import { allocate_transform_m4 } from "../../../core/geom/3d/matrix/allocate_transform_m4.js";
11
- import { assert } from "../../../core/assert.js";
12
- import { m4_multiply } from "../../../core/geom/3d/matrix/m4_multiply.js";
13
- import { MATRIX_4_IDENTITY } from "../../../core/geom/3d/matrix/MATRIX_4_IDENTITY.js";
12
+ import Vector3 from "../../../core/geom/Vector3.js";
13
+ import {TransformFlags} from "./TransformFlags.js";
14
14
 
15
15
  /**
16
16
  *
@@ -71,26 +71,39 @@ export class Transform {
71
71
  */
72
72
  constructor() {
73
73
  // watch changes
74
- this.subscribeAllChanges(this.__handle_component_change, this);
74
+ this.subscribe(this.#handle_component_change, this);
75
75
  }
76
76
 
77
77
  /**
78
- *
78
+ * Current "forward" direction in world-space
79
+ * NOTE that this vector is not live, meaning that if you modify transform, previously-obtained result will no longer be valid
80
+ * @returns {Vector3}
81
+ */
82
+ get forward() {
83
+ const result = Vector3.forward.clone();
84
+
85
+ result.applyMatrix4(this.matrix);
86
+
87
+ return result;
88
+ }
89
+
90
+ /**
91
+ * Attach change listener
79
92
  * @param {function} handler
80
93
  * @param {*} [thisArg]
81
94
  */
82
- subscribeAllChanges(handler, thisArg) {
95
+ subscribe(handler, thisArg) {
83
96
  this.position.onChanged.add(handler, thisArg);
84
97
  this.rotation.onChanged.add(handler, thisArg);
85
98
  this.scale.onChanged.add(handler, thisArg);
86
99
  }
87
100
 
88
101
  /**
89
- *
102
+ * Disconnect change listener
90
103
  * @param {function} handler
91
104
  * @param {*} [thisArg]
92
105
  */
93
- unsubscribeAllChanges(handler, thisArg) {
106
+ unsubscribe(handler, thisArg) {
94
107
  this.position.onChanged.remove(handler, thisArg);
95
108
  this.rotation.onChanged.remove(handler, thisArg);
96
109
  this.scale.onChanged.remove(handler, thisArg);
@@ -100,7 +113,7 @@ export class Transform {
100
113
  *
101
114
  * @private
102
115
  */
103
- __handle_component_change() {
116
+ #handle_component_change() {
104
117
  if (this.getFlag(TransformFlags.AutomaticChangeDetection)) {
105
118
  this.updateMatrix();
106
119
  }
@@ -156,8 +169,9 @@ export class Transform {
156
169
  /**
157
170
  *
158
171
  * @param {Vector3} target
172
+ * @param {Vector3} [up]
159
173
  */
160
- lookAt(target) {
174
+ lookAt(target, up = Vector3.up) {
161
175
 
162
176
  const position = this.position;
163
177
 
@@ -172,7 +186,7 @@ export class Transform {
172
186
 
173
187
  this.rotation._lookRotation(
174
188
  delta_x, delta_y, delta_z,
175
- Vector3.up.x, Vector3.up.y, Vector3.up.z
189
+ up.x, up.y, up.z
176
190
  );
177
191
  }
178
192
 
@@ -0,0 +1,89 @@
1
+ import {System} from "./System.js";
2
+
3
+ /**
4
+ * Utility method for making sure that the system is properly constructed, used internally by the engine itself
5
+ * @param {System} system
6
+ * @throws if system fails validation
7
+ */
8
+ export function validateSystem(system) {
9
+ if (system === undefined) {
10
+ throw new Error("System is undefined");
11
+ }
12
+
13
+ if (system === null) {
14
+ throw new Error("System is null");
15
+ }
16
+
17
+ if (!(system instanceof System)) {
18
+ throw new TypeError("System does not inherit from \"System\" class");
19
+ }
20
+
21
+ if (typeof system.add === "function") {
22
+ throw new Error(`uses deprecated 'add' method, should use 'link' instead`);
23
+ }
24
+
25
+ if (typeof system.remove === "function") {
26
+ throw new Error(`uses deprecated 'remove' method, should use 'unlink' instead`);
27
+ }
28
+
29
+ // validate 'components_used' section
30
+ const components_used = system.components_used;
31
+ const components_used_count = components_used.length;
32
+
33
+ for (let i = 0; i < components_used_count; i++) {
34
+ const spec = components_used[i];
35
+
36
+ if (spec === undefined || spec === null || spec.isResourceAccessSpecification !== true) {
37
+ throw new Error(`Invalid access specification[${i}], expected an instance of ResourceAccessSpecification, but got something else`);
38
+ }
39
+
40
+ if (spec.resource === null) {
41
+ throw new Error(`No component specified for element [${i}]`);
42
+ }
43
+
44
+ if (spec.access === 0) {
45
+ throw new Error('No access modifiers specified, must have at least one (such as Read, Write, Create)');
46
+ }
47
+
48
+ // backtrace to make sure there are no duplicates
49
+ for (let j = 0; j < i - 1; j++) {
50
+ const spec_other = components_used[j];
51
+
52
+ if (spec_other.resource === spec.resource) {
53
+ throw new Error(`Duplicate specification of component [${j}] and [${i}]`);
54
+ }
55
+ }
56
+ }
57
+
58
+ //validate dependencies
59
+ const dependencies = system.dependencies;
60
+
61
+ const numDependencies = dependencies.length;
62
+
63
+ if (numDependencies < 1) {
64
+ throw new Error(`A system must declare at least one dependency`);
65
+ }
66
+
67
+ if (numDependencies > 1) {
68
+ //check for duplicates
69
+ for (let i = 0; i < numDependencies; i++) {
70
+ const dependencyA = dependencies[i];
71
+ for (let j = i + 1; j < numDependencies; j++) {
72
+ if (dependencyA === dependencies[j]) {
73
+ throw new Error(`Detected duplicate dependency: ${dependencyA.constructor.typeName}`);
74
+ }
75
+ }
76
+ }
77
+ }
78
+
79
+
80
+ const linkArgumentCount = numDependencies + 1;
81
+
82
+ if (system.link !== System.prototype.link && system.link.length !== linkArgumentCount && system.__validation_ignore_link_argument_count !== true) {
83
+ throw new Error(`'link' method declares ${system.link.length} instead of expected ${linkArgumentCount} based on it's ${numDependencies} dependencies`);
84
+ }
85
+
86
+ if (system.unlink !== System.prototype.unlink && system.unlink.length !== linkArgumentCount && system.__validation_ignore_link_argument_count !== true) {
87
+ throw new Error(`'unlink' method declares ${system.unlink.length} instead of expected ${linkArgumentCount} based on it's ${numDependencies} dependencies`);
88
+ }
89
+ }