@woosh/meep-engine 2.119.129 → 2.119.131

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.
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "description": "Fully featured ECS game engine written in JavaScript",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.119.129",
8
+ "version": "2.119.131",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -1 +1 @@
1
- {"version":3,"file":"ebvh_optimize_treelet.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/ebvh_optimize_treelet.js"],"names":[],"mappings":"AAoNA;;;;;;;GAOG;AACH,2CAJW,GAAG,QACH,MAAM,iBACN,MAAM,QA0IhB"}
1
+ {"version":3,"file":"ebvh_optimize_treelet.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/ebvh_optimize_treelet.js"],"names":[],"mappings":"AAgNA;;;;;;;GAOG;AACH,2CAJW,GAAG,QACH,MAAM,iBACN,MAAM,QA0IhB"}
@@ -85,13 +85,9 @@ function optimize_treelet(bvh, root, leaves, leaf_count) {
85
85
 
86
86
  // Initialize costs of individual leaves
87
87
  for (let i = 0; i < leaf_count; i++) {
88
- // TODO implement a full cost heuristic
89
88
  const leaf = leaves[i];
90
89
 
91
- // we use height, which is available, as a proxy for triangle count
92
- const triangle_count = bvh.node_get_height(leaf);
93
-
94
- scratch_cost[1 << i] = SAH_COST_TRIANGLE * bvh.node_get_surface_area(leaf) * triangle_count;
90
+ scratch_cost[1 << i] = SAH_COST_TRIANGLE * bvh.node_get_surface_area(leaf) ;
95
91
  }
96
92
 
97
93
  // Optimize every subset of leaves
@@ -1,6 +1,9 @@
1
1
  /**
2
- * Compute factorial of X
3
- * @param {number} x
2
+ * Compute factorial of X (X!)
3
+ * Note that factorial of 13 is already 6,227,020,800 which exceeds 32bit integer limit
4
+ * Note that this implementation is intended for small inputs only
5
+ * @example factorial(5) == 5 * 4 * 3 * 2 * 1 == 120
6
+ * @param {number} x must be an integer
4
7
  * @return {number}
5
8
  */
6
9
  export function factorial(x: number): number;
@@ -1 +1 @@
1
- {"version":3,"file":"factorial.d.ts","sourceRoot":"","sources":["../../../../src/core/math/factorial.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,6BAHW,MAAM,GACL,MAAM,CAWjB"}
1
+ {"version":3,"file":"factorial.d.ts","sourceRoot":"","sources":["../../../../src/core/math/factorial.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,6BAHW,MAAM,GACL,MAAM,CAejB"}
@@ -1,10 +1,17 @@
1
1
  /**
2
- * Compute factorial of X
3
- * @param {number} x
2
+ * Compute factorial of X (X!)
3
+ * Note that factorial of 13 is already 6,227,020,800 which exceeds 32bit integer limit
4
+ * Note that this implementation is intended for small inputs only
5
+ * @example factorial(5) == 5 * 4 * 3 * 2 * 1 == 120
6
+ * @param {number} x must be an integer
4
7
  * @return {number}
5
8
  */
6
9
  export function factorial(x) {
7
10
 
11
+ // NOTE: implementation is naive and pretty slow, consider following for improvements:
12
+ // * http://www.luschny.de/math/factorial/FastFactorialFunctions.htm
13
+ // * https://stackoverflow.com/questions/1751334/fast-algorithms-for-computing-the-factorial
14
+
8
15
  let result = 1;
9
16
 
10
17
  for (let i = x; i > 0; --i) {
@@ -1,5 +1,7 @@
1
1
  /**
2
- * Return solutions for a quadratic equation
2
+ * Return solutions for a quadratic polynomial: ax² + bx + c
3
+ * Typically there will be 2 solution, in some cases we will have 0, having 1 solution is impossible
4
+ * This solver only deals with real numbers, so imaginary solution are not provided. In case solution would be imaginary - we return 0 roots
3
5
  * @param {number} a
4
6
  * @param {number} b
5
7
  * @param {number} c
@@ -1 +1 @@
1
- {"version":3,"file":"solveQuadratic.d.ts","sourceRoot":"","sources":["../../../../src/core/math/solveQuadratic.js"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,uCAJW,MAAM,EAAE,iBACR,MAAM,KAJN,MAAM,KACN,MAAM,KACN,MAAM,GAGJ,MAAM,CAoDlB"}
1
+ {"version":3,"file":"solveQuadratic.d.ts","sourceRoot":"","sources":["../../../../src/core/math/solveQuadratic.js"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AACH,uCAJW,MAAM,EAAE,iBACR,MAAM,KAJN,MAAM,KACN,MAAM,KACN,MAAM,GAGJ,MAAM,CAsDlB"}
@@ -2,7 +2,9 @@ import { assert } from "../assert.js";
2
2
  import { EPSILON } from "./EPSILON.js";
3
3
 
4
4
  /**
5
- * Return solutions for a quadratic equation
5
+ * Return solutions for a quadratic polynomial: ax² + bx + c
6
+ * Typically there will be 2 solution, in some cases we will have 0, having 1 solution is impossible
7
+ * This solver only deals with real numbers, so imaginary solution are not provided. In case solution would be imaginary - we return 0 roots
6
8
  * @param {number} a
7
9
  * @param {number} b
8
10
  * @param {number} c
@@ -47,6 +49,8 @@ export function solveQuadratic(
47
49
  const disc_sqr = b * b - 4 * a * c;
48
50
 
49
51
  if (disc_sqr >= 0) {
52
+ // if discriminant square is negative, solution can only be imaginary, we don't deal with that
53
+
50
54
  const disc = Math.sqrt(disc_sqr);
51
55
  const a2 = 2 * a;
52
56
 
@@ -161,6 +161,11 @@ export class Transform {
161
161
  * - scale: [1,1,1]
162
162
  */
163
163
  makeIdentity(): void;
164
+ /**
165
+ * Identity Transform is where position is 0, rotation is 0 (un-rotated) and scale is 1
166
+ * @returns {boolean}
167
+ */
168
+ isIdentity(): boolean;
164
169
  toString(): string;
165
170
  /**
166
171
  * @readonly
@@ -1 +1 @@
1
- {"version":3,"file":"Transform.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/transform/Transform.js"],"names":[],"mappings":"AAsBA;;;GAGG;AACH;IAwQI;;;;OAIG;IACH,4BAFa,SAAS,CAQrB;IAED;;;;OAIG;IACH,uBAHW,MAAM,EAAE,GAAC,YAAY,GACnB,SAAS,CAQrB;IAuDD;;;;;OAKG;IACH,wCAJW,UAA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AD5B,kCAAkC;+BAE1B,qBAAqB"}
1
+ {"version":3,"file":"Transform.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/transform/Transform.js"],"names":[],"mappings":"AAsBA;;;GAGG;AACH;IAwQI;;;;OAIG;IACH,4BAFa,SAAS,CAQrB;IAED;;;;OAIG;IACH,uBAHW,MAAM,EAAE,GAAC,YAAY,GACnB,SAAS,CAQrB;IAiED;;;;;OAKG;IACH,wCAJW,UAAU,gBACV,OAAO,wBAajB;IA/WD;;;OAGG;IACH,mBAHU,OAAO,CAGe;IAEhC;;;OAGG;IACH,mBAHU,UAAU,CAGkB;IAEtC;;;OAGG;IACH,gBAHU,OAAO,CAGY;IAE7B;;;;OAIG;IACH,iBAFU,YAAY,CAEC;IAEvB;;;;OAIG;IACH,OAFU,MAAM,CAEM;IAOtB;;;;OAIG;IACH,eAFa,OAAO,CAQnB;IAED;;;OAGG;IACH,UAFY,OAAO,CAQlB;IAED;;;OAGG;IACH,aAFY,OAAO,CAQlB;IAED;;;;OAIG;IACH,uCAFW,GAAC,QAMX;IAED;;;;OAIG;IACH,yCAFW,GAAC,QAMX;IAYD;;;;OAIG;IACH,cAHW,MAAM,GAAC,cAAc,GACnB,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM,GAAC,cAAc,GACnB,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM,GAAC,cAAc,SACrB,OAAO,QAQjB;IAED;;;;OAIG;IACH,cAHW,MAAM,GAAC,cAAc,GACnB,OAAO,CAInB;IAED;;OAEG;IACH,qBAEC;IAED;;;;OAIG;IACH,eAHW,OAAO,OACP,OAAO,QAmBjB;IAED,0BAwBC;IAED;;;;MAMC;IAED;;;OAGG;IACH,YAFW,SAAS,QAenB;IAED;;;OAGG;IACH,SAFa,SAAS,CAQrB;IAED;;;;OAIG;IACH,cAHW,SAAS,GACP,OAAO,CAMnB;IAED;;;OAGG;IACH,QAFa,MAAM,CAKlB;IA4BD;;;;OAIG;IACH,sBAHW,SAAS,KACT,SAAS,QAMnB;IAED;;;OAGG;IACH,oBAFW,IAAI,GAAC,MAAM,EAAE,GAAC,YAAY,QAgBpC;IAED;;;OAGG;IACH,kBAFW,MAAM,EAAE,GAAC,YAAY,QAI/B;IAED;;;;;OAKG;IACH,qBAEC;IAED;;;OAGG;IACH,cAFa,OAAO,CAMnB;IAED,mBAEC;IA2BL;;;OAGG;IACH,sBAFU,OAAO,CAEc;;CAZ9B;;kBAIS,MAAM;;oBAzYI,+BAA+B;uBAD5B,kCAAkC;+BAE1B,qBAAqB"}
@@ -363,6 +363,16 @@ export class Transform {
363
363
  this.fromMatrix4(MATRIX_4_IDENTITY);
364
364
  }
365
365
 
366
+ /**
367
+ * Identity Transform is where position is 0, rotation is 0 (un-rotated) and scale is 1
368
+ * @returns {boolean}
369
+ */
370
+ isIdentity() {
371
+ return this.position.equals(Vector3.zero)
372
+ && this.rotation.equals(Quaternion.identity)
373
+ && this.scale.equals(Vector3.one);
374
+ }
375
+
366
376
  toString() {
367
377
  return `{ position: ${this.position}, rotation: ${this.rotation}, scale: ${this.scale} }`;
368
378
  }
@@ -1,5 +1,15 @@
1
1
  export default EmptyView;
2
2
  declare class EmptyView extends View<HTMLElement> {
3
+ /**
4
+ *
5
+ * @param {string[]} [classList]
6
+ * @param {Object<string>} [css]
7
+ * @param {Object} [attr]
8
+ * @param {Element} [el]
9
+ * @param {string} [tag]
10
+ * @returns {EmptyView}
11
+ */
12
+ static absolute({ classList, css, attr, el, tag }?: string[]): EmptyView;
3
13
  /**
4
14
  *
5
15
  * @param {View[]} elements
@@ -1 +1 @@
1
- {"version":3,"file":"EmptyView.d.ts","sourceRoot":"","sources":["../../../../src/view/elements/EmptyView.js"],"names":[],"mappings":";AAEA;IAiCI;;;;;OAKG;IACH,uBAJW,IAAI,EAAE,YACN;QAAC,SAAS,EAAC,MAAM,EAAE,CAAC;QAAA,GAAG,EAAC,MAAM,CAAC;QAAA,GAAG,EAAC,EAAE,CAAA;KAAC,GACrC,SAAS,CAQpB;IAED,2BAEC;IAhDD;;;;;;;;;OASG;IACH,8DATW,MAAM,EAAE,EA6BlB;IAhBO,QAAY;CAmCvB;iBApDgB,YAAY"}
1
+ {"version":3,"file":"EmptyView.d.ts","sourceRoot":"","sources":["../../../../src/view/elements/EmptyView.js"],"names":[],"mappings":";AAGA;IAyCI;;;;;;;;OAQG;IACH,oDAPW,MAAM,EAAE,GAKN,SAAS,CAoBrB;IAED;;;;;OAKG;IACH,uBAJW,IAAI,EAAE,YACN;QAAC,SAAS,EAAC,MAAM,EAAE,CAAC;QAAA,GAAG,EAAC,MAAM,CAAC;QAAA,GAAG,EAAC,EAAE,CAAA;KAAC,GACrC,SAAS,CAQpB;IAED,2BAEC;IArFD;;;;;;;;;OASG;IACH,8DATW,MAAM,EAAE,EAqClB;IAhBO,QAAY;CAgEvB;iBAzFgB,YAAY"}
@@ -1,3 +1,4 @@
1
+ import { CSS_ABSOLUTE_POSITIONING } from "../CSS_ABSOLUTE_POSITIONING.js";
1
2
  import View from "../View.js";
2
3
 
3
4
  class EmptyView extends View {
@@ -11,7 +12,15 @@ class EmptyView extends View {
11
12
  * @extends {View}
12
13
  * @constructor
13
14
  */
14
- constructor({ classList = [], el, tag = 'div', tagNamespace = undefined, css, attr } = {}) {
15
+ constructor({
16
+ classList = [],
17
+ el,
18
+ tag = 'div',
19
+ tagNamespace = undefined,
20
+ css,
21
+ attr
22
+ } = {}) {
23
+
15
24
  super();
16
25
 
17
26
  if (el !== undefined) {
@@ -33,6 +42,35 @@ class EmptyView extends View {
33
42
  }
34
43
  }
35
44
 
45
+ /**
46
+ *
47
+ * @param {string[]} [classList]
48
+ * @param {Object<string>} [css]
49
+ * @param {Object} [attr]
50
+ * @param {Element} [el]
51
+ * @param {string} [tag]
52
+ * @returns {EmptyView}
53
+ */
54
+ static absolute({
55
+ classList=[],
56
+ css,
57
+ attr,
58
+ el,
59
+ tag
60
+ } = {}) {
61
+
62
+ return new EmptyView({
63
+ classList,
64
+ css: {
65
+ css,
66
+ ...CSS_ABSOLUTE_POSITIONING
67
+ },
68
+ attr,
69
+ el,
70
+ tag
71
+ });
72
+ }
73
+
36
74
  /**
37
75
  *
38
76
  * @param {View[]} elements