@woosh/meep-engine 2.48.23 → 2.49.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 (142) hide show
  1. package/editor/tools/GridPaintTool.js +1 -1
  2. package/editor/tools/paint/TerrainPaintTool.js +1 -1
  3. package/editor/view/GridPickCoordinateView.js +1 -1
  4. package/package.json +1 -1
  5. package/src/core/UUID.js +2 -0
  6. package/src/core/assert.js +4 -1
  7. package/src/core/binary/ctz32.js +1 -1
  8. package/src/core/binary/operations/bitCount.spec.js +19 -0
  9. package/src/core/binary/uint82float.spec.js +7 -0
  10. package/src/core/bvh2/bvh3/EBBVHLeafProxy.js +3 -0
  11. package/src/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.js +5 -4
  12. package/src/core/bvh2/transform/RotationOptimizer.spec.js +161 -155
  13. package/src/core/codegen/LineBuilder.js +12 -3
  14. package/src/core/codegen/LineBuilder.spec.js +7 -0
  15. package/src/core/collection/HashMap.js +486 -237
  16. package/src/core/collection/HashMap.spec.js +110 -1
  17. package/src/core/collection/array/{typedArrayToDataType.js → typed/typedArrayToDataType.js} +1 -1
  18. package/src/core/collection/array/weightedRandomFromArray.spec.js +20 -0
  19. package/src/core/debug/matchers/AnyOf.js +1 -2
  20. package/src/core/geom/2d/aabb/AABB2.spec.js +1 -1
  21. package/src/core/geom/2d/aabb/aabb2_compute_center_from_multiple.js +19 -0
  22. package/src/core/geom/2d/quad-tree/qt_collect_by_circle.js +3 -3
  23. package/src/core/geom/2d/quad-tree/qt_query_data_nearest_to_point.js +7 -9
  24. package/src/core/geom/3d/aabb/aabb3_compute_plane_side.js +17 -15
  25. package/src/core/geom/3d/aabb/aabb3_compute_plane_side.spec.js +25 -0
  26. package/src/core/geom/3d/aabb/aabb3_detailed_volume_intersection.js +1 -1
  27. package/src/core/geom/3d/aabb/aabb3_from_v3_array.js +3 -0
  28. package/src/core/geom/3d/aabb/aabb3_from_v3_array.spec.js +32 -0
  29. package/src/core/geom/3d/aabb/aabb3_intersects_aabb3.spec.js +115 -0
  30. package/src/core/geom/3d/aabb/aabb3_raycast.js +6 -1
  31. package/src/core/geom/3d/aabb/serializeAABB3Encoded_v0.js +6 -6
  32. package/src/core/geom/3d/{CircleMath.js → compute_circle_bounding_box.js} +1 -1
  33. package/src/core/geom/3d/decompose_matrix_4_array.js +18 -19
  34. package/src/core/geom/3d/frustum/frustum3_computeNearestPointToPoint.js +1 -1
  35. package/src/{engine/graphics/ecs/mesh-v2 → core/geom/3d/matrix}/allocate_transform_m4.js +1 -1
  36. package/src/core/geom/3d/normal/hemioct/decode_hemioct_to_unit.js +26 -0
  37. package/src/core/geom/3d/normal/hemioct/encode_unit3_hemioct.js +0 -26
  38. package/src/core/geom/3d/normal/hemioct/unit_hemioct.spec.js +2 -1
  39. package/src/core/geom/3d/plane/computePlaneLineIntersection.js +51 -0
  40. package/src/core/geom/3d/plane/computePlanePlaneIntersection.js +77 -0
  41. package/src/core/geom/3d/plane/computePlaneRayIntersection.js +55 -0
  42. package/src/core/geom/3d/plane/plane3_computeLineSegmentIntersection.js +50 -0
  43. package/src/core/geom/3d/plane/planeRayIntersection.js +14 -0
  44. package/src/core/geom/3d/{tetrahedra/in_sphere_fast.js → sphere/in_sphere3d_fast.js} +1 -1
  45. package/src/core/geom/3d/{tetrahedra/in_sphere_robust.js → sphere/in_sphere3d_robust.js} +1 -1
  46. package/src/core/geom/3d/sphere/sphere_array_intersects_point.js +2 -2
  47. package/src/core/geom/3d/sphere/{sphereIntersectsPoint.js → sphere_intersects_point.js} +7 -4
  48. package/src/core/geom/3d/sphere/sphere_intersects_point.spec.js +134 -0
  49. package/src/core/geom/3d/sphere/sphere_intersects_ray.spec.js +49 -0
  50. package/src/core/geom/3d/sphere/sphere_radius_sqr_from_v3_array_transformed.js +11 -7
  51. package/src/core/geom/3d/tetrahedra/delaunay/{debug_validate_mesh.js → debug/debug_validate_mesh.js} +1 -1
  52. package/src/core/geom/3d/tetrahedra/delaunay/{push_boundary_with_validation.js → debug/push_boundary_with_validation.js} +1 -1
  53. package/src/core/geom/3d/tetrahedra/delaunay/{validate_cavity_boundary.js → debug/validate_cavity_boundary.js} +2 -2
  54. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_compute_cavity.js +2 -2
  55. package/src/core/geom/3d/triangle/computeTriangleRayIntersection.js +0 -164
  56. package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentric.js +87 -0
  57. package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricEdge.js +81 -0
  58. package/src/core/geom/{rayTriangleIntersection.js → 3d/triangle/rayTriangleIntersection.js} +2 -2
  59. package/src/core/geom/ConicRay.js +160 -152
  60. package/src/core/geom/Matrix4.js +2 -0
  61. package/src/core/geom/Quaternion.js +19 -1
  62. package/src/core/geom/packing/max-rect/MaxRectangles.js +4 -214
  63. package/src/core/geom/packing/max-rect/cost/costByBestShortSide.js +11 -0
  64. package/src/core/geom/packing/max-rect/cost/costByRemainingArea.js +14 -0
  65. package/src/core/geom/packing/max-rect/cutArea.js +79 -0
  66. package/src/core/geom/packing/max-rect/findBestContainer.js +58 -0
  67. package/src/core/geom/packing/max-rect/packOneBox.js +49 -0
  68. package/src/core/geom/v3_dot.js +1 -1
  69. package/src/core/graph/layout/CircleLayout.js +1 -1
  70. package/src/core/graph/layout/{BoxLayouter.js → box/BoxLayouter.js} +6 -50
  71. package/src/core/graph/layout/box/applyCentralGravityAABB2.js +29 -0
  72. package/src/core/json/resolvePath.spec.js +14 -0
  73. package/src/core/land/reactive/{compiler/ReactiveCompiler.spec.js → compileReactiveExpression.spec.js} +17 -17
  74. package/src/core/math/random/MersenneTwister.spec.js +19 -0
  75. package/src/core/math/random/randomGaussian.spec.js +9 -0
  76. package/src/core/math/statistics/computeStatisticalMean.js +2 -2
  77. package/src/core/model/reactive/model/arithmetic/ReactiveAdd.js +1 -1
  78. package/src/core/model/reactive/model/arithmetic/ReactiveDivide.js +3 -1
  79. package/src/core/model/reactive/model/arithmetic/ReactiveMultiply.js +1 -1
  80. package/src/core/model/reactive/model/arithmetic/ReactiveNegate.js +3 -1
  81. package/src/core/model/reactive/model/arithmetic/ReactiveSubtract.js +1 -1
  82. package/src/core/model/reactive/model/comparative/ReactiveEquals.js +1 -1
  83. package/src/core/model/reactive/model/comparative/ReactiveGreaterThan.js +3 -1
  84. package/src/core/model/reactive/model/comparative/ReactiveGreaterThanOrEqual.js +3 -1
  85. package/src/core/model/reactive/model/comparative/ReactiveLessThan.js +3 -1
  86. package/src/core/model/reactive/model/comparative/ReactiveLessThanOrEqual.js +3 -1
  87. package/src/core/model/reactive/model/comparative/ReactiveNotEquals.js +1 -1
  88. package/src/core/model/reactive/model/logic/ReactiveAnd.js +1 -1
  89. package/src/core/model/reactive/model/logic/ReactiveNot.js +3 -1
  90. package/src/core/model/reactive/model/logic/ReactiveOr.js +1 -1
  91. package/src/core/primitives/numbers/computeHashFloat.spec.js +7 -0
  92. package/src/core/process/task/util/iteratorTask.js +3 -1
  93. package/src/engine/animation/curve/AnimationCurve.js +34 -5
  94. package/src/engine/animation/curve/AnimationCurve.spec.js +100 -0
  95. package/src/engine/asset/AssetTransformer.js +1 -0
  96. package/src/engine/computeStridedIntegerArrayHash.js +4 -2
  97. package/src/engine/ecs/components/Renderable.d.ts +1 -1
  98. package/src/{ecs → engine/ecs}/grid/pick.js +4 -4
  99. package/src/engine/ecs/parent/entity_node_compute_bounding_box.js +1 -1
  100. package/src/engine/ecs/storage/binary/collection/BinaryCollectionSerializer.js +1 -18
  101. package/src/engine/ecs/systems/MotionSystem.js +7 -1
  102. package/src/engine/ecs/systems/SynchronizePositionSystem.js +8 -2
  103. package/src/engine/ecs/transform/Transform.js +1 -1
  104. package/src/engine/graphics/camera/makeScreenScissorFrustum.js +3 -3
  105. package/src/engine/graphics/camera/testClippingPlaneComputation.js +13 -13
  106. package/src/engine/graphics/ecs/camera/Camera.js +1 -1
  107. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMesh.js +1 -1
  108. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshSystem.js +9 -0
  109. package/src/engine/graphics/geometry/MikkT/MikkTSpace.js +1 -1
  110. package/src/engine/graphics/geometry/MikkT/STSpace.js +1 -1
  111. package/src/engine/graphics/geometry/bvh/buffered/BVHGeometryRaycaster.js +1 -1
  112. package/src/engine/graphics/material/optimization/MaterialOptimizationContext.js +1 -1
  113. package/src/engine/graphics/particles/particular/engine/MovingBoundingBox.js +1 -1
  114. package/src/engine/graphics/particles/particular/engine/parameter/ParameterLookupTable.js +1 -0
  115. package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +1 -1
  116. package/src/engine/graphics/postprocess/threejs/postprocessing/TexturePass.js +2 -2
  117. package/src/engine/graphics/sh3/path_tracer/GeometryBVHBatched.js +2 -2
  118. package/src/engine/graphics/texture/sampler/Sampler2D.js +1 -1
  119. package/src/engine/graphics/texture/sampler/sampler2d_compute_texel_value_conversion_scale_to_uint8.js +1 -1
  120. package/src/engine/intelligence/behavior/Behavior.spec.js +15 -0
  121. package/src/engine/intelligence/mcts/MoveEdge.js +1 -1
  122. package/src/engine/reference/v1/ReferenceManager.js +3 -0
  123. package/src/engine/reference/v2/Reference.js +33 -37
  124. package/src/engine/sound/sopra/README.md +6 -0
  125. package/src/generation/automata/CaveGeneratorCellularAutomata.js +10 -7
  126. package/src/generation/automata/CaveGeneratorCellularAutomata.spec.js +12 -0
  127. package/src/generation/automata/CellularAutomata.js +5 -4
  128. package/src/generation/filtering/numeric/complex/CellFilterGaussianBlur.js +25 -9
  129. package/src/view/minimap/dom/MinimapCameraView.js +1 -1
  130. package/src/core/geom/Plane.js +0 -250
  131. package/src/core/land/reactive/ReactiveLexer.js +0 -158
  132. package/src/core/land/reactive/ReactiveLexer.ts +0 -181
  133. package/src/core/land/reactive/ReactiveListener.ts +0 -323
  134. package/src/core/land/reactive/ReactiveParser.js +0 -1573
  135. package/src/core/land/reactive/ReactiveParser.ts +0 -1776
  136. package/src/core/land/reactive/ReactiveVisitor.js +0 -1
  137. package/src/core/land/reactive/ReactiveVisitor.ts +0 -218
  138. package/src/core/land/reactive/compiler/ReactiveCompiler.js +0 -350
  139. package/src/core/land/reactive/compiler/ReactiveNearlyCompiler.js +0 -166
  140. package/src/core/land/reactive/compiler/ReactiveParser.js +0 -34
  141. package/src/core/land/reactive/nearley/ReactiveNearley.js +0 -187
  142. /package/src/{engine/graphics/ecs/mesh-v2 → core/geom/3d/vector}/allocate_v3.js +0 -0
@@ -6,39 +6,34 @@ import Signal from "../../../core/events/signal/Signal.js";
6
6
  export class Reference {
7
7
 
8
8
  /**
9
- * @template T
9
+ *
10
+ * @type {Signal<this,T>}
11
+ * @private
10
12
  */
11
- constructor() {
12
-
13
- /**
14
- *
15
- * @type {Signal}
16
- * @private
17
- */
18
- this.__onReleased = new Signal();
19
-
20
- /**
21
- *
22
- * @type {T}
23
- * @private
24
- */
25
- this.__value = null;
26
-
27
-
28
- /**
29
- *
30
- * @type {boolean}
31
- * @private
32
- */
33
- this.__is_bound = false;
34
- }
13
+ #onReleased = new Signal();
14
+
15
+ /**
16
+ *
17
+ * @type {T}
18
+ * @private
19
+ */
20
+ #value = null;
21
+
22
+
23
+ /**
24
+ *
25
+ * @type {boolean}
26
+ * @private
27
+ */
28
+ #is_bound = false;
29
+
35
30
 
36
31
  /**
37
32
  *
38
- * @returns {Signal}
33
+ * @returns {Signal<this,T>}
39
34
  */
40
35
  get onReleased() {
41
- return this.__onReleased;
36
+ return this.#onReleased;
42
37
  }
43
38
 
44
39
  /**
@@ -46,17 +41,17 @@ export class Reference {
46
41
  * @param {T} value
47
42
  */
48
43
  bind(value) {
49
- if (value === this.__value) {
44
+ if (value === this.#value) {
50
45
  return;
51
46
  }
52
47
 
53
- if (this.__is_bound) {
48
+ if (this.#is_bound) {
54
49
  throw new Error(`Reference is already bound, must release before binding to a new value`);
55
50
  }
56
51
 
57
- this.__value = value;
52
+ this.#value = value;
58
53
 
59
- this.__is_bound = true;
54
+ this.#is_bound = true;
60
55
  }
61
56
 
62
57
  /**
@@ -64,27 +59,28 @@ export class Reference {
64
59
  * @returns {T}
65
60
  */
66
61
  getValue() {
67
- return this.__value;
62
+ return this.#value;
68
63
  }
69
64
 
70
65
  release() {
71
- if (!this.__is_bound) {
66
+ if (!this.#is_bound) {
72
67
  // not bound
73
68
  return;
74
69
  }
75
70
 
76
- const v = this.__value;
71
+ const v = this.#value;
77
72
 
78
73
  // prevent further usage of the reference
79
- this.__value = null;
74
+ this.#value = null;
80
75
 
81
- this.__is_bound = false;
76
+ this.#is_bound = false;
82
77
 
83
- this.__onReleased.send2(this,v);
78
+ this.#onReleased.send2(this, v);
84
79
  }
85
80
  }
86
81
 
87
82
  /**
83
+ * Special NULL reference that can be used to indicate lack of reference
88
84
  * @readonly
89
85
  * @type {Readonly<Reference>}
90
86
  */
@@ -1 +1,7 @@
1
+ ## Sopra
2
+
3
+ Object-oriented sound engine
4
+
5
+ ---
6
+
1
7
  Loosely based on concepts from FMOD and Wwise
@@ -5,7 +5,6 @@ import { CellularAutomata } from "./CellularAutomata.js";
5
5
  export class CaveGeneratorCellularAutomata extends CellularAutomata {
6
6
  step(data, width, height) {
7
7
 
8
-
9
8
  const maxY = height - 1;
10
9
  const maxX = width - 1;
11
10
 
@@ -21,20 +20,24 @@ export class CaveGeneratorCellularAutomata extends CellularAutomata {
21
20
  const columnLeft = max2(x - 1, 0);
22
21
  const columnRight = min2(x + 1, maxX);
23
22
 
24
- //
23
+ // read top row
24
+ const topLeft = data[rowIndexTop + columnLeft];
25
25
  const top = data[rowIndexTop + x];
26
- const bottom = data[rowIndexBottom + x];
26
+ const topRight = data[rowIndexTop + columnRight];
27
+
28
+ // read middle row
27
29
  const left = data[rowIndex + columnLeft];
30
+ const cellValue = data[cellIndex];
28
31
  const right = data[rowIndex + columnRight];
29
- //
30
- const topLeft = data[rowIndexTop + columnLeft];
31
- const topRight = data[rowIndexTop + columnRight];
32
+
33
+ // read bottom row
32
34
  const bottomLeft = data[rowIndexBottom + columnLeft];
35
+ const bottom = data[rowIndexBottom + x];
33
36
  const bottomRight = data[rowIndexBottom + columnRight];
34
37
 
35
38
  //count neighbours
36
39
  const neighbourSum = top + bottom + left + right + topLeft + topRight + bottomLeft + bottomRight;
37
- const cellValue = data[cellIndex];
40
+
38
41
 
39
42
  if (cellValue > 0) {
40
43
  //cell is alive
@@ -0,0 +1,12 @@
1
+ import { CaveGeneratorCellularAutomata } from "./CaveGeneratorCellularAutomata.js";
2
+
3
+ test("single cell execution", () => {
4
+ const automata = new CaveGeneratorCellularAutomata();
5
+
6
+ const array = new Uint8Array([0]);
7
+
8
+ automata.step(array, 1, 1);
9
+
10
+ // cell should stay dead, no live neighbours
11
+ expect(array[0]).toBe(0);
12
+ });
@@ -1,10 +1,11 @@
1
1
  import { seededRandom } from "../../core/math/random/seededRandom.js";
2
2
 
3
3
  export class CellularAutomata {
4
- constructor() {
5
-
6
- this.random = seededRandom(1);
7
- }
4
+ /**
5
+ *
6
+ * @type {function(): number}
7
+ */
8
+ random = seededRandom(1);
8
9
 
9
10
  /**
10
11
  *
@@ -86,6 +86,20 @@ export class CellFilterGaussianBlur extends CellFilter {
86
86
  * @private
87
87
  */
88
88
  this.__inv_kernel_total_power = 0;
89
+
90
+ /**
91
+ * Written by 'initialize' stage
92
+ * @type {number}
93
+ * @private
94
+ */
95
+ this.__local_u_scale = 0;
96
+
97
+ /**
98
+ * Written by 'initialize' stage
99
+ * @type {number}
100
+ * @private
101
+ */
102
+ this.__local_v_scale = 0;
89
103
  }
90
104
 
91
105
  initialize(grid, seed) {
@@ -105,6 +119,11 @@ export class CellFilterGaussianBlur extends CellFilter {
105
119
  // store inverse, to be able to use multiply instead of division in execution
106
120
  this.__inv_kernel_total_power = 1 / this.__kernel_total_power;
107
121
 
122
+
123
+ // precompute scaling for the sampling(execute) stage
124
+ this.__local_u_scale = this.size_x / (this.samples_x - 1);
125
+ this.__local_v_scale = this.size_y / (this.samples_y - 1);
126
+
108
127
  super.initialize(grid, seed);
109
128
  }
110
129
 
@@ -140,11 +159,8 @@ export class CellFilterGaussianBlur extends CellFilter {
140
159
  const half_samples_x = (samplesX - 1) * 0.5;
141
160
  const half_samples_y = (samplesY - 1) * 0.5;
142
161
 
143
- const sizeX = this.size_x;
144
- const sizeY = this.size_y;
145
-
146
- const local_u_scale = sizeX / (samplesX - 1);
147
- const local_v_scale = sizeY / (samplesY - 1);
162
+ const local_u_scale = this.__local_u_scale;
163
+ const local_v_scale = this.__local_v_scale;
148
164
 
149
165
  let sum = 0;
150
166
  let ix, iy = 0;
@@ -157,7 +173,7 @@ export class CellFilterGaussianBlur extends CellFilter {
157
173
  for (; iy < samplesY; iy++) {
158
174
  const local_y = iy - half_samples_y;
159
175
 
160
- const offset_y = y + local_y * local_v_scale;
176
+ const sample_y = y + local_y * local_v_scale;
161
177
 
162
178
  const row_address = iy * i_samples_x;
163
179
 
@@ -165,13 +181,13 @@ export class CellFilterGaussianBlur extends CellFilter {
165
181
 
166
182
  const local_x = ix - half_samples_x;
167
183
 
168
- const offset_x = local_x * local_u_scale;
184
+ const sample_x = x + local_x * local_u_scale;
169
185
 
170
186
  const power = kernel[row_address + ix];
171
187
 
172
- const sourceValue = source.execute(grid, x + offset_x, offset_y, 0);
188
+ const source_value = source.execute(grid, sample_x, sample_y, 0);
173
189
 
174
- const sample_contribution = sourceValue * power;
190
+ const sample_contribution = source_value * power;
175
191
 
176
192
  sum += sample_contribution;
177
193
 
@@ -1,9 +1,9 @@
1
1
  import View from "../../View.js";
2
2
  import Vector3 from "../../../core/geom/Vector3.js";
3
- import { computePlaneRayIntersection } from "../../../core/geom/Plane.js";
4
3
  import ObservedValue from "../../../core/model/ObservedValue.js";
5
4
  import { SurfacePoint3 } from "../../../core/geom/3d/SurfacePoint3.js";
6
5
  import SVG from "../../SVG.js";
6
+ import { computePlaneRayIntersection } from "../../../core/geom/3d/plane/computePlaneRayIntersection.js";
7
7
 
8
8
 
9
9
  const rayContact = new SurfacePoint3();
@@ -1,250 +0,0 @@
1
- /**
2
- * Created by Alex on 20/02/2017.
3
- */
4
-
5
-
6
- import { v3_dot } from "./v3_dot.js";
7
-
8
- /**
9
-
10
- Algorithm taken from http://geomalgorithms.com/a05-_intersect-1.html. See the
11
- section 'Intersection of 2 Planes' and specifically the subsection
12
- (A) Direct Linear Equation
13
- @param {Plane} p1
14
- @param {Plane} p2
15
- @param {Vector3} point
16
- @param {Vector3} direction
17
- @returns {boolean}
18
- */
19
- export function computePlanePlaneIntersection(p1, p2, point, direction) {
20
-
21
- // the cross product gives us the direction of the line at the intersection
22
- // of the two planes, and gives us an easy way to check if the two planes
23
- // are parallel - the cross product will have zero magnitude
24
-
25
- direction.crossVectors(p1.normal, p2.normal);
26
-
27
- const magnitude = direction.lengthSqr();
28
-
29
- if (magnitude === 0) {
30
- return false;
31
- }
32
-
33
- // now find a point on the intersection. We use the 'Direct Linear Equation'
34
- // method described in the linked page, and we choose which coordinate
35
- // to set as zero by seeing which has the largest absolute value in the
36
- // directional vector
37
-
38
- const X = Math.abs(direction.x);
39
- const Y = Math.abs(direction.y);
40
- const Z = Math.abs(direction.z);
41
-
42
- if (Z >= X && Z >= Y) {
43
- solveIntersectingPoint('z', 'x', 'y', p1, p2, point);
44
- } else if (Y >= Z && Y >= X) {
45
- solveIntersectingPoint('y', 'z', 'x', p1, p2, point);
46
- } else {
47
- solveIntersectingPoint('x', 'y', 'z', p1, p2, point);
48
- }
49
-
50
- return true;
51
- }
52
-
53
- /**
54
- *
55
- * @param {Vector3} out Result will be written here
56
- * @param {Vector3} origin Ray origin
57
- * @param {Vector3} direction Ray direction
58
- * @param {Vector3} normal Plane normal
59
- * @param {number} dist Plane distance
60
- * @returns {boolean} true if intersection is found, false otherwise
61
- */
62
- export function planeRayIntersection(out, origin, direction, normal, dist) {
63
- return computePlaneRayIntersection(out, origin.x, origin.y, origin.z, direction.x, direction.y, direction.z, normal.x, normal.y, normal.z, dist)
64
- }
65
-
66
- /**
67
- *
68
- * @param {Vector3} out Result will be written here
69
- * @param {number} originX Ray origin
70
- * @param {number} originY Ray origin
71
- * @param {number} originZ Ray origin
72
- * @param {number} directionX Ray direction
73
- * @param {number} directionY Ray direction
74
- * @param {number} directionZ Ray direction
75
- * @param {number} normalX Plane normal
76
- * @param {number} normalY Plane normal
77
- * @param {number} normalZ Plane normal
78
- * @param {number} dist Plane distance
79
- * @returns {boolean} true if intersection is found, false otherwise
80
- */
81
- export function computePlaneRayIntersection(out, originX, originY, originZ, directionX, directionY, directionZ, normalX, normalY, normalZ, dist) {
82
- const denom = v3_dot(directionX, directionY, directionZ, normalX, normalY, normalZ);
83
-
84
- const p = v3_dot(normalX, normalY, normalZ, originX, originY, originZ) + dist;
85
-
86
- if (denom !== 0) {
87
-
88
- const t = -p / denom;
89
-
90
- if (t < 0) {
91
- return false;
92
- }
93
-
94
- out.set(
95
- directionX * t + originX,
96
- directionY * t + originY,
97
- directionZ * t + originZ
98
- );
99
-
100
- return true;
101
-
102
- } else {
103
-
104
- if (p === 0) {
105
-
106
- out.set(originX, originY, originZ);
107
-
108
- return true;
109
-
110
- } else {
111
-
112
- //no intersection
113
- return false;
114
-
115
- }
116
-
117
- }
118
- }
119
-
120
- /**
121
- *
122
- * @param {Vector3} out Result will be written here
123
- * @param {number} originX Ray origin
124
- * @param {number} originY Ray origin
125
- * @param {number} originZ Ray origin
126
- * @param {number} directionX Ray direction
127
- * @param {number} directionY Ray direction
128
- * @param {number} directionZ Ray direction
129
- * @param {number} normalX Plane normal
130
- * @param {number} normalY Plane normal
131
- * @param {number} normalZ Plane normal
132
- * @param {number} dist Plane distance
133
- * @returns {boolean} true if intersection is found, false otherwise
134
- */
135
- export function computePlaneLineIntersection(out, originX, originY, originZ, directionX, directionY, directionZ, normalX, normalY, normalZ, dist) {
136
- const denom = v3_dot(directionX, directionY, directionZ, normalX, normalY, normalZ);
137
-
138
- const p = v3_dot(normalX, normalY, normalZ, originX, originY, originZ) + dist;
139
-
140
- if (denom !== 0) {
141
-
142
- const t = -p / denom;
143
-
144
- out.set(
145
- directionX * t + originX,
146
- directionY * t + originY,
147
- directionZ * t + originZ
148
- );
149
-
150
- return true;
151
-
152
- } else {
153
-
154
- if (p === 0) {
155
-
156
- out.set(originX, originY, originZ);
157
-
158
- return true;
159
-
160
- } else {
161
-
162
- //no intersection
163
- return false;
164
-
165
- }
166
-
167
- }
168
- }
169
-
170
- /**
171
- *
172
- * @param {Float32Array|number[]|vec3} result
173
- * @param {number} result_offset
174
- * @param {number} x0
175
- * @param {number} y0
176
- * @param {number} z0
177
- * @param {number} x1
178
- * @param {number} y1
179
- * @param {number} z1
180
- * @param {number} normalX
181
- * @param {number} normalY
182
- * @param {number} normalZ
183
- * @param {number} dist
184
- * @returns {boolean}
185
- */
186
- export function plane3_computeLineSegmentIntersection(
187
- result, result_offset,
188
- x0, y0, z0,
189
- x1, y1, z1,
190
- normalX, normalY, normalZ, dist
191
- ) {
192
-
193
- const directionX = x1 - x0;
194
- const directionY = y1 - y0;
195
- const directionZ = z1 - z0;
196
-
197
- const denom = v3_dot(directionX, directionY, directionZ, normalX, normalY, normalZ);
198
-
199
- if (denom === 0) {
200
- return false;
201
- }
202
-
203
- const p = v3_dot(normalX, normalY, normalZ, x0, y0, z0) + dist;
204
-
205
- const t = -p / denom;
206
-
207
- if (t < 0 || t > 1) {
208
- return false;
209
- }
210
-
211
- result[result_offset] = directionX * t + x0;
212
- result[result_offset + 1] = directionY * t + y0;
213
- result[result_offset + 2] = directionZ * t + z0;
214
-
215
- return true;
216
-
217
- }
218
-
219
- /**
220
-
221
- This method helps finding a point on the intersection between two planes.
222
- Depending on the orientation of the planes, the problem could solve for the
223
- zero point on either the x, y or z axis
224
- * @param {string} zeroCoord
225
- * @param {string} A
226
- * @param {string} B
227
- * @param {THREE.Plane} p1
228
- * @param {THREE.Plane} p2
229
- * @param {Vector3} result
230
- */
231
- function solveIntersectingPoint(zeroCoord, A, B, p1, p2, result) {
232
- const nP1 = p1.normal;
233
-
234
- const a1 = nP1[A];
235
- const b1 = nP1[B];
236
- const d1 = p1.constant;
237
-
238
- const nP2 = p2.normal;
239
-
240
- const a2 = nP2[A];
241
- const b2 = nP2[B];
242
- const d2 = p2.constant;
243
-
244
- const A0 = ((b2 * d1) - (b1 * d2)) / ((a1 * b2 - a2 * b1));
245
- const B0 = ((a1 * d2) - (a2 * d1)) / ((a1 * b2 - a2 * b1));
246
-
247
- result[zeroCoord] = 0;
248
- result[A] = A0;
249
- result[B] = B0;
250
- }
@@ -1,158 +0,0 @@
1
- // Generated from app/src/lang/Reactive.g4 by ANTLR 4.6-SNAPSHOT
2
- import { ATNDeserializer } from "antlr4ts/atn/ATNDeserializer";
3
- import { LexerATNSimulator } from "antlr4ts/atn/LexerATNSimulator";
4
- import { Lexer } from "antlr4ts/Lexer";
5
- import * as Utils from "antlr4ts/misc/Utils";
6
- import { VocabularyImpl } from "antlr4ts/VocabularyImpl";
7
-
8
- export class ReactiveLexer extends Lexer {
9
- // tslint:enable:no-trailing-whitespace
10
- constructor(input) {
11
- super(input);
12
- this._interp = new LexerATNSimulator(ReactiveLexer._ATN, this);
13
- }
14
- // @Override
15
- // @NotNull
16
- get vocabulary() {
17
- return ReactiveLexer.VOCABULARY;
18
- }
19
- // @Override
20
- get grammarFileName() {
21
- return "Reactive.g4";
22
- }
23
- // @Override
24
- get ruleNames() {
25
- return ReactiveLexer.ruleNames;
26
- }
27
- // @Override
28
- get serializedATN() {
29
- return ReactiveLexer._serializedATN;
30
- }
31
- // @Override
32
- get modeNames() {
33
- return ReactiveLexer.modeNames;
34
- }
35
- static get _ATN() {
36
- if (!ReactiveLexer.__ATN) {
37
- ReactiveLexer.__ATN = new ATNDeserializer().deserialize(Utils.toCharArray(ReactiveLexer._serializedATN));
38
- }
39
- return ReactiveLexer.__ATN;
40
- }
41
- }
42
- ReactiveLexer.T__0 = 1;
43
- ReactiveLexer.T__1 = 2;
44
- ReactiveLexer.T__2 = 3;
45
- ReactiveLexer.Identifier = 4;
46
- ReactiveLexer.NonzeroDigit = 5;
47
- ReactiveLexer.DigitSequence = 6;
48
- ReactiveLexer.FractionalConstant = 7;
49
- ReactiveLexer.ExponentPart = 8;
50
- ReactiveLexer.PLUS = 9;
51
- ReactiveLexer.MINUS = 10;
52
- ReactiveLexer.MULTIPLY = 11;
53
- ReactiveLexer.DIVIDE = 12;
54
- ReactiveLexer.NOT = 13;
55
- ReactiveLexer.GT = 14;
56
- ReactiveLexer.GTE = 15;
57
- ReactiveLexer.LT = 16;
58
- ReactiveLexer.LTE = 17;
59
- ReactiveLexer.EQUALS = 18;
60
- ReactiveLexer.NOT_EQUALS = 19;
61
- ReactiveLexer.AND = 20;
62
- ReactiveLexer.OR = 21;
63
- ReactiveLexer.DOT = 22;
64
- ReactiveLexer.OPEN_BRACKET = 23;
65
- ReactiveLexer.CLOSED_BRACKET = 24;
66
- ReactiveLexer.Whitespace = 25;
67
- // tslint:disable:no-trailing-whitespace
68
- ReactiveLexer.modeNames = [
69
- "DEFAULT_MODE",
70
- ];
71
- ReactiveLexer.ruleNames = [
72
- "T__0", "T__1", "T__2", "Identifier", "IdentifierNondigit", "Nondigit",
73
- "Digit", "NonzeroDigit", "DigitSequence", "FractionalConstant", "Sign",
74
- "ExponentPart", "PLUS", "MINUS", "MULTIPLY", "DIVIDE", "NOT", "GT", "GTE",
75
- "LT", "LTE", "EQUALS", "NOT_EQUALS", "AND", "OR", "DOT", "OPEN_BRACKET",
76
- "CLOSED_BRACKET", "Whitespace",
77
- ];
78
- ReactiveLexer._LITERAL_NAMES = [
79
- undefined, "'0'", "'true'", "'false'", undefined, undefined, undefined,
80
- undefined, undefined, "'+'", "'-'", "'*'", "'/'", "'!'", "'>'", "'>='",
81
- "'<'", "'<='", "'=='", "'!='", "'&&'", "'||'", "'.'", "'('", "')'",
82
- ];
83
- ReactiveLexer._SYMBOLIC_NAMES = [
84
- undefined, undefined, undefined, undefined, "Identifier", "NonzeroDigit",
85
- "DigitSequence", "FractionalConstant", "ExponentPart", "PLUS", "MINUS",
86
- "MULTIPLY", "DIVIDE", "NOT", "GT", "GTE", "LT", "LTE", "EQUALS", "NOT_EQUALS",
87
- "AND", "OR", "DOT", "OPEN_BRACKET", "CLOSED_BRACKET", "Whitespace",
88
- ];
89
- ReactiveLexer.VOCABULARY = new VocabularyImpl(ReactiveLexer._LITERAL_NAMES, ReactiveLexer._SYMBOLIC_NAMES, []);
90
- ReactiveLexer._serializedATN = "\x03\uAF6F\u8320\u479D\uB75C\u4880\u1605\u191C\uAB37\x02\x1B\xA4\b\x01" +
91
- "\x04\x02\t\x02\x04\x03\t\x03\x04\x04\t\x04\x04\x05\t\x05\x04\x06\t\x06" +
92
- "\x04\x07\t\x07\x04\b\t\b\x04\t\t\t\x04\n\t\n\x04\v\t\v\x04\f\t\f\x04\r" +
93
- "\t\r\x04\x0E\t\x0E\x04\x0F\t\x0F\x04\x10\t\x10\x04\x11\t\x11\x04\x12\t" +
94
- "\x12\x04\x13\t\x13\x04\x14\t\x14\x04\x15\t\x15\x04\x16\t\x16\x04\x17\t" +
95
- "\x17\x04\x18\t\x18\x04\x19\t\x19\x04\x1A\t\x1A\x04\x1B\t\x1B\x04\x1C\t" +
96
- "\x1C\x04\x1D\t\x1D\x04\x1E\t\x1E\x03\x02\x03\x02\x03\x03\x03\x03\x03\x03" +
97
- "\x03\x03\x03\x03\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x05" +
98
- "\x03\x05\x03\x05\x07\x05N\n\x05\f\x05\x0E\x05Q\v\x05\x03\x06\x03\x06\x03" +
99
- "\x07\x03\x07\x03\b\x03\b\x03\t\x03\t\x03\n\x06\n\\\n\n\r\n\x0E\n]\x03" +
100
- "\v\x05\va\n\v\x03\v\x03\v\x03\v\x03\v\x03\v\x05\vh\n\v\x03\f\x03\f\x03" +
101
- "\r\x03\r\x05\rn\n\r\x03\r\x03\r\x03\r\x05\rs\n\r\x03\r\x05\rv\n\r\x03" +
102
- "\x0E\x03\x0E\x03\x0F\x03\x0F\x03\x10\x03\x10\x03\x11\x03\x11\x03\x12\x03" +
103
- "\x12\x03\x13\x03\x13\x03\x14\x03\x14\x03\x14\x03\x15\x03\x15\x03\x16\x03" +
104
- "\x16\x03\x16\x03\x17\x03\x17\x03\x17\x03\x18\x03\x18\x03\x18\x03\x19\x03" +
105
- "\x19\x03\x19\x03\x1A\x03\x1A\x03\x1A\x03\x1B\x03\x1B\x03\x1C\x03\x1C\x03" +
106
- "\x1D\x03\x1D\x03\x1E\x06\x1E\x9F\n\x1E\r\x1E\x0E\x1E\xA0\x03\x1E\x03\x1E" +
107
- "\x02\x02\x02\x1F\x03\x02\x03\x05\x02\x04\x07\x02\x05\t\x02\x06\v\x02\x02" +
108
- "\r\x02\x02\x0F\x02\x02\x11\x02\x07\x13\x02\b\x15\x02\t\x17\x02\x02\x19" +
109
- "\x02\n\x1B\x02\v\x1D\x02\f\x1F\x02\r!\x02\x0E#\x02\x0F%\x02\x10\'\x02" +
110
- "\x11)\x02\x12+\x02\x13-\x02\x14/\x02\x151\x02\x163\x02\x175\x02\x187\x02" +
111
- "\x199\x02\x1A;\x02\x1B\x03\x02\x07\x05\x02C\\aac|\x03\x022;\x03\x023;" +
112
- "\x04\x02--//\x05\x02\v\f\x0E\x0F\"\"\xA8\x02\x03\x03\x02\x02\x02\x02\x05" +
113
- "\x03\x02\x02\x02\x02\x07\x03\x02\x02\x02\x02\t\x03\x02\x02\x02\x02\x11" +
114
- "\x03\x02\x02\x02\x02\x13\x03\x02\x02\x02\x02\x15\x03\x02\x02\x02\x02\x19" +
115
- "\x03\x02\x02\x02\x02\x1B\x03\x02\x02\x02\x02\x1D\x03\x02\x02\x02\x02\x1F" +
116
- "\x03\x02\x02\x02\x02!\x03\x02\x02\x02\x02#\x03\x02\x02\x02\x02%\x03\x02" +
117
- "\x02\x02\x02\'\x03\x02\x02\x02\x02)\x03\x02\x02\x02\x02+\x03\x02\x02\x02" +
118
- "\x02-\x03\x02\x02\x02\x02/\x03\x02\x02\x02\x021\x03\x02\x02\x02\x023\x03" +
119
- "\x02\x02\x02\x025\x03\x02\x02\x02\x027\x03\x02\x02\x02\x029\x03\x02\x02" +
120
- "\x02\x02;\x03\x02\x02\x02\x03=\x03\x02\x02\x02\x05?\x03\x02\x02\x02\x07" +
121
- "D\x03\x02\x02\x02\tJ\x03\x02\x02\x02\vR\x03\x02\x02\x02\rT\x03\x02\x02" +
122
- "\x02\x0FV\x03\x02\x02\x02\x11X\x03\x02\x02\x02\x13[\x03\x02\x02\x02\x15" +
123
- "g\x03\x02\x02\x02\x17i\x03\x02\x02\x02\x19u\x03\x02\x02\x02\x1Bw\x03\x02" +
124
- "\x02\x02\x1Dy\x03\x02\x02\x02\x1F{\x03\x02\x02\x02!}\x03\x02\x02\x02#" +
125
- "\x7F\x03\x02\x02\x02%\x81\x03\x02\x02\x02\'\x83\x03\x02\x02\x02)\x86\x03" +
126
- "\x02\x02\x02+\x88\x03\x02\x02\x02-\x8B\x03\x02\x02\x02/\x8E\x03\x02\x02" +
127
- "\x021\x91\x03\x02\x02\x023\x94\x03\x02\x02\x025\x97\x03\x02\x02\x027\x99" +
128
- "\x03\x02\x02\x029\x9B\x03\x02\x02\x02;\x9E\x03\x02\x02\x02=>\x072\x02" +
129
- "\x02>\x04\x03\x02\x02\x02?@\x07v\x02\x02@A\x07t\x02\x02AB\x07w\x02\x02" +
130
- "BC\x07g\x02\x02C\x06\x03\x02\x02\x02DE\x07h\x02\x02EF\x07c\x02\x02FG\x07" +
131
- "n\x02\x02GH\x07u\x02\x02HI\x07g\x02\x02I\b\x03\x02\x02\x02JO\x05\r\x07" +
132
- "\x02KN\x05\r\x07\x02LN\x05\x0F\b\x02MK\x03\x02\x02\x02ML\x03\x02\x02\x02" +
133
- "NQ\x03\x02\x02\x02OM\x03\x02\x02\x02OP\x03\x02\x02\x02P\n\x03\x02\x02" +
134
- "\x02QO\x03\x02\x02\x02RS\x05\r\x07\x02S\f\x03\x02\x02\x02TU\t\x02\x02" +
135
- "\x02U\x0E\x03\x02\x02\x02VW\t\x03\x02\x02W\x10\x03\x02\x02\x02XY\t\x04" +
136
- "\x02\x02Y\x12\x03\x02\x02\x02Z\\\x05\x0F\b\x02[Z\x03\x02\x02\x02\\]\x03" +
137
- "\x02\x02\x02][\x03\x02\x02\x02]^\x03\x02\x02\x02^\x14\x03\x02\x02\x02" +
138
- "_a\x05\x13\n\x02`_\x03\x02\x02\x02`a\x03\x02\x02\x02ab\x03\x02\x02\x02" +
139
- "bc\x070\x02\x02ch\x05\x13\n\x02de\x05\x13\n\x02ef\x070\x02\x02fh\x03\x02" +
140
- "\x02\x02g`\x03\x02\x02\x02gd\x03\x02\x02\x02h\x16\x03\x02\x02\x02ij\t" +
141
- "\x05\x02\x02j\x18\x03\x02\x02\x02km\x07g\x02\x02ln\x05\x17\f\x02ml\x03" +
142
- "\x02\x02\x02mn\x03\x02\x02\x02no\x03\x02\x02\x02ov\x05\x13\n\x02pr\x07" +
143
- "G\x02\x02qs\x05\x17\f\x02rq\x03\x02\x02\x02rs\x03\x02\x02\x02st\x03\x02" +
144
- "\x02\x02tv\x05\x13\n\x02uk\x03\x02\x02\x02up\x03\x02\x02\x02v\x1A\x03" +
145
- "\x02\x02\x02wx\x07-\x02\x02x\x1C\x03\x02\x02\x02yz\x07/\x02\x02z\x1E\x03" +
146
- "\x02\x02\x02{|\x07,\x02\x02| \x03\x02\x02\x02}~\x071\x02\x02~\"\x03\x02" +
147
- "\x02\x02\x7F\x80\x07#\x02\x02\x80$\x03\x02\x02\x02\x81\x82\x07@\x02\x02" +
148
- "\x82&\x03\x02\x02\x02\x83\x84\x07@\x02\x02\x84\x85\x07?\x02\x02\x85(\x03" +
149
- "\x02\x02\x02\x86\x87\x07>\x02\x02\x87*\x03\x02\x02\x02\x88\x89\x07>\x02" +
150
- "\x02\x89\x8A\x07?\x02\x02\x8A,\x03\x02\x02\x02\x8B\x8C\x07?\x02\x02\x8C" +
151
- "\x8D\x07?\x02\x02\x8D.\x03\x02\x02\x02\x8E\x8F\x07#\x02\x02\x8F\x90\x07" +
152
- "?\x02\x02\x900\x03\x02\x02\x02\x91\x92\x07(\x02\x02\x92\x93\x07(\x02\x02" +
153
- "\x932\x03\x02\x02\x02\x94\x95\x07~\x02\x02\x95\x96\x07~\x02\x02\x964\x03" +
154
- "\x02\x02\x02\x97\x98\x070\x02\x02\x986\x03\x02\x02\x02\x99\x9A\x07*\x02" +
155
- "\x02\x9A8\x03\x02\x02\x02\x9B\x9C\x07+\x02\x02\x9C:\x03\x02\x02\x02\x9D" +
156
- "\x9F\t\x06\x02\x02\x9E\x9D\x03\x02\x02\x02\x9F\xA0\x03\x02\x02\x02\xA0" +
157
- "\x9E\x03\x02\x02\x02\xA0\xA1\x03\x02\x02\x02\xA1\xA2\x03\x02\x02\x02\xA2" +
158
- "\xA3\b\x1E\x02\x02\xA3<\x03\x02\x02\x02\f\x02MO]`gmru\xA0\x03\b\x02\x02";