@woosh/meep-engine 2.118.3 → 2.118.5
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/build/meep.cjs +86 -105
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +86 -105
- package/package.json +5 -5
- package/src/core/binary/EndianType.d.ts +3 -0
- package/src/core/binary/EndianType.d.ts.map +1 -1
- package/src/core/binary/EndianType.js +2 -1
- package/src/core/binary/uint8_to_float.d.ts.map +1 -1
- package/src/core/binary/uint8_to_float.js +5 -0
- package/src/core/collection/queue/Deque.d.ts.map +1 -1
- package/src/core/collection/queue/Deque.js +32 -32
- package/src/core/color/Color.js +3 -3
- package/src/core/color/kelvin/rgb_to_kelvin.d.ts.map +1 -1
- package/src/core/color/kelvin/rgb_to_kelvin.js +16 -7
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.d.ts.map +1 -0
- package/src/core/geom/Vector3.d.ts.map +1 -1
- package/src/core/geom/Vector3.js +5 -19
- package/src/core/geom/packing/computeBoundingSphereOfSpheres.js +1 -1
- package/src/core/math/compute_legendre_polynomial.d.ts +1 -1
- package/src/core/math/compute_legendre_polynomial.d.ts.map +1 -1
- package/src/core/math/compute_legendre_polynomial.js +6 -1
- package/src/core/math/hash/squirrel3.d.ts +1 -0
- package/src/core/math/hash/squirrel3.d.ts.map +1 -1
- package/src/core/math/hash/squirrel3.js +1 -0
- package/src/core/math/max3.d.ts.map +1 -1
- package/src/core/math/max3.js +4 -0
- package/src/core/math/random/seededRandom_MersenneTwister.d.ts +7 -0
- package/src/core/math/random/seededRandom_MersenneTwister.d.ts.map +1 -0
- package/src/core/math/random/{seededRandomMersenneTwister.js → seededRandom_MersenneTwister.js} +4 -2
- package/src/core/math/solveQuadratic.d.ts.map +1 -1
- package/src/core/math/solveQuadratic.js +5 -1
- package/src/core/primitives/boolean/compareBooleans.js +2 -0
- package/src/core/primitives/boolean/computeBooleanHash.d.ts +7 -0
- package/src/core/primitives/boolean/computeBooleanHash.d.ts.map +1 -0
- package/src/core/primitives/boolean/computeBooleanHash.js +8 -0
- package/src/core/primitives/numbers/computeHashFloat.d.ts.map +1 -1
- package/src/core/primitives/numbers/computeHashFloat.js +4 -2
- package/src/engine/ecs/gui/position/ViewportPosition.d.ts +0 -5
- package/src/engine/ecs/gui/position/ViewportPosition.d.ts.map +1 -1
- package/src/engine/ecs/gui/position/ViewportPosition.js +42 -53
- package/src/engine/ecs/speaker/VoiceSystem.d.ts +2 -3
- package/src/engine/ecs/speaker/VoiceSystem.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/find_max_depth_radius_for_point.js +2 -2
- package/src/engine/intelligence/optimization/optimize_cyclic_sequence_pairwise.d.ts +12 -0
- package/src/engine/intelligence/optimization/optimize_cyclic_sequence_pairwise.d.ts.map +1 -0
- package/src/engine/intelligence/optimization/optimize_cyclic_sequence_pairwise.js +90 -0
- package/src/core/geometry/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.d.ts.map +0 -1
- package/src/core/math/random/MersenneTwister.d.ts +0 -19
- package/src/core/math/random/MersenneTwister.d.ts.map +0 -1
- package/src/core/math/random/MersenneTwister.js +0 -212
- package/src/core/math/random/seededRandomMersenneTwister.d.ts +0 -7
- package/src/core/math/random/seededRandomMersenneTwister.d.ts.map +0 -1
- /package/src/core/{geometry → geom}/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.d.ts +0 -0
- /package/src/core/{geometry → geom}/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.js +0 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Useful in Spherical Harmonics coefficient computation
|
|
4
4
|
* @param {number} l band
|
|
5
5
|
* @param {number} m
|
|
6
|
-
* @param {number} x
|
|
6
|
+
* @param {number} x must be between 0 and 1
|
|
7
7
|
* @returns {number}
|
|
8
8
|
*/
|
|
9
9
|
export function compute_legendre_polynomial(l: number, m: number, x: number): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compute_legendre_polynomial.d.ts","sourceRoot":"","sources":["../../../../src/core/math/compute_legendre_polynomial.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compute_legendre_polynomial.d.ts","sourceRoot":"","sources":["../../../../src/core/math/compute_legendre_polynomial.js"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,+CALW,MAAM,KACN,MAAM,KACN,MAAM,GACJ,MAAM,CA0ClB"}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
+
import { assert } from "../assert.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Computes associated Legendre Polynomial P(l,m,x) at x
|
|
3
5
|
* Useful in Spherical Harmonics coefficient computation
|
|
4
6
|
* @param {number} l band
|
|
5
7
|
* @param {number} m
|
|
6
|
-
* @param {number} x
|
|
8
|
+
* @param {number} x must be between 0 and 1
|
|
7
9
|
* @returns {number}
|
|
8
10
|
*/
|
|
9
11
|
export function compute_legendre_polynomial(l, m, x) {
|
|
12
|
+
assert.lessThanOrEqual(x,1,'only valid for X <= 1');
|
|
13
|
+
|
|
14
|
+
// TODO we might be able to do better, see https://github.com/halueda/wavy-orbitals/blob/fe738b0f8de8783cb7886d2c6ee616c2befb363b/legendre.js#L16
|
|
10
15
|
// based on code from https://github.com/jan-van-bergen/SphericalHarmonicLighting/blob/2b214b3451859ded07ea4e41fb2aa8d2a44ab579/SphericalHarmonicsLighting/SphericalHarmonics.cpp#L61
|
|
11
16
|
|
|
12
17
|
// Apply rule 2; P m m
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Based on Squirrel3 hash function by Squirrel Eiserloh
|
|
3
|
+
* Alex: Personally I found it to have low entropy, so I don't see it as very useful
|
|
3
4
|
* @see GDC 2017 presentation on "Math for Game Programmers: Noise-Based RNG"
|
|
4
5
|
* @param {number} value expected to be an integer, if not - it will be truncated to such
|
|
5
6
|
* @returns {number} signed 32-bit integer
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"squirrel3.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/hash/squirrel3.js"],"names":[],"mappings":"AAIA
|
|
1
|
+
{"version":3,"file":"squirrel3.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/hash/squirrel3.js"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,iCAHW,MAAM,GACJ,MAAM,CAYlB"}
|
|
@@ -4,6 +4,7 @@ const BIT_NOISE3 = 0x1B56C4E9;
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Based on Squirrel3 hash function by Squirrel Eiserloh
|
|
7
|
+
* Alex: Personally I found it to have low entropy, so I don't see it as very useful
|
|
7
8
|
* @see GDC 2017 presentation on "Math for Game Programmers: Noise-Based RNG"
|
|
8
9
|
* @param {number} value expected to be an integer, if not - it will be truncated to such
|
|
9
10
|
* @returns {number} signed 32-bit integer
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"max3.d.ts","sourceRoot":"","sources":["../../../../src/core/math/max3.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBALW,MAAM,KACN,MAAM,KACN,MAAM,GACJ,MAAM,
|
|
1
|
+
{"version":3,"file":"max3.d.ts","sourceRoot":"","sources":["../../../../src/core/math/max3.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBALW,MAAM,KACN,MAAM,KACN,MAAM,GACJ,MAAM,CAgBlB"}
|
package/src/core/math/max3.js
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Random number generator based on Mersenne Twister sequence
|
|
3
|
+
* @param {number} seed
|
|
4
|
+
* @returns {function():number} RNG
|
|
5
|
+
*/
|
|
6
|
+
export function seededRandom_MersenneTwister(seed: number): () => number;
|
|
7
|
+
//# sourceMappingURL=seededRandom_MersenneTwister.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seededRandom_MersenneTwister.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/random/seededRandom_MersenneTwister.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,mDAHW,MAAM,SACO,MAAM,CAmF7B"}
|
package/src/core/math/random/{seededRandomMersenneTwister.js → seededRandom_MersenneTwister.js}
RENAMED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Random number generator based on Mersenne Twister sequence
|
|
3
3
|
* @param {number} seed
|
|
4
4
|
* @returns {function():number} RNG
|
|
5
5
|
*/
|
|
6
|
-
export function
|
|
6
|
+
export function seededRandom_MersenneTwister(seed) {
|
|
7
|
+
// see https://gist.github.com/banksean/300494
|
|
8
|
+
|
|
7
9
|
/* Period parameters */
|
|
8
10
|
const N = 624;
|
|
9
11
|
const M = 397;
|
|
@@ -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,
|
|
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"}
|
|
@@ -10,7 +10,11 @@ import { EPSILON } from "./EPSILON.js";
|
|
|
10
10
|
* @param {number} result_offset offset into result array where solutions are written to
|
|
11
11
|
* @returns {number} number of found solutions (roots)
|
|
12
12
|
*/
|
|
13
|
-
export function solveQuadratic(
|
|
13
|
+
export function solveQuadratic(
|
|
14
|
+
result, result_offset,
|
|
15
|
+
a, b, c
|
|
16
|
+
) {
|
|
17
|
+
|
|
14
18
|
assert.isNumber(a, 'a');
|
|
15
19
|
assert.isNumber(b, 'b');
|
|
16
20
|
assert.isNumber(c, 'c');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computeBooleanHash.d.ts","sourceRoot":"","sources":["../../../../../src/core/primitives/boolean/computeBooleanHash.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,sCAHW,OAAO,GACL,MAAM,CAIlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeHashFloat.d.ts","sourceRoot":"","sources":["../../../../../src/core/primitives/numbers/computeHashFloat.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"computeHashFloat.d.ts","sourceRoot":"","sources":["../../../../../src/core/primitives/numbers/computeHashFloat.js"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,oCAHW,MAAM,GACJ,MAAM,CAalB"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { UINT32_MAX } from "../../binary/UINT32_MAX.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
*
|
|
3
5
|
* @param {number} v
|
|
@@ -5,12 +7,12 @@
|
|
|
5
7
|
*/
|
|
6
8
|
export function computeHashFloat(v) {
|
|
7
9
|
//we break the number up into fractional and whole parts
|
|
8
|
-
const whole = v
|
|
10
|
+
const whole = v >> 0;
|
|
9
11
|
|
|
10
12
|
const fraction = v - whole;
|
|
11
13
|
|
|
12
14
|
//fractional part is scaled up into int32 range, this inexact method, as it will produce 0 hash for values below a certain threshold
|
|
13
|
-
const fractionHash = fraction *
|
|
15
|
+
const fractionHash = fraction * UINT32_MAX;
|
|
14
16
|
|
|
15
17
|
//take XOR of both parts
|
|
16
18
|
return fractionHash ^ whole;
|
|
@@ -6,11 +6,6 @@ export namespace ViewportPositionFlags {
|
|
|
6
6
|
export default ViewportPosition;
|
|
7
7
|
declare class ViewportPosition {
|
|
8
8
|
static fromJSON(opt: any): ViewportPosition;
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
* @constructor
|
|
12
|
-
*/
|
|
13
|
-
constructor(options: any);
|
|
14
9
|
/**
|
|
15
10
|
* Clip-scale position, on-screen values are in range of 0 to 1
|
|
16
11
|
* @type {Vector2}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewportPosition.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/ecs/gui/position/ViewportPosition.js"],"names":[],"mappings":"oCAOU,MAAM;;;;;;AAOhB;
|
|
1
|
+
{"version":3,"file":"ViewportPosition.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/ecs/gui/position/ViewportPosition.js"],"names":[],"mappings":"oCAOU,MAAM;;;;;;AAOhB;IAuGI,4CAMC;IA5GD;;;OAGG;IACH,UAFU,OAAO,CAEQ;IAEzB;;;OAGG;IACH,QAFU,OAAO,CAEM;IACvB;;;OAGG;IACH,QAFU,OAAO,CAEU;IAG3B;;;;OAIG;IACH,sBAFU,OAAO,CAEY;IAE7B;;;;OAIG;IACH,iBAFU,MAAM,CAEK;IAGrB;;;OAGG;IACH,mBAFU,OAAO,CAES;IAE1B;;;OAGG;IACH,SAFU,eAAe,CAEW;IAEpC;;;;OAIG;IACH,cAHW,gBAAgB,GACd,OAAO,CAWnB;IAED,eAUC;IAED;;;;;;;aAgBC;IAED;;;;;;;MASC;CASJ;;;;;oBA3HmB,kCAAkC;4BAC1B,2CAA2C"}
|
|
@@ -14,60 +14,49 @@ export const ViewportPositionFlags = {
|
|
|
14
14
|
|
|
15
15
|
class ViewportPosition {
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
* @
|
|
17
|
+
* Clip-scale position, on-screen values are in range of 0 to 1
|
|
18
|
+
* @type {Vector2}
|
|
19
19
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Can be used to enable and disable positioning
|
|
62
|
-
* @type {ObservedBoolean}
|
|
63
|
-
*/
|
|
64
|
-
this.enabled = new ObservedBoolean(true);
|
|
65
|
-
|
|
66
|
-
if (options !== undefined) {
|
|
67
|
-
console.warn("ViewportPosition constructor options is deprecated, please use static fromJSON method instead if you need similar functionality");
|
|
68
|
-
this.fromJSON(options);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
20
|
+
position = new Vector2();
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Fixed offset in pixels
|
|
24
|
+
* @type {Vector2}
|
|
25
|
+
*/
|
|
26
|
+
offset = new Vector2();
|
|
27
|
+
/**
|
|
28
|
+
* ranges from 0..1 in both X and Y, controls anchor point of element positioning
|
|
29
|
+
* @type {Vector2}
|
|
30
|
+
*/
|
|
31
|
+
anchor = new Vector2(0, 0);
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Makes display element avoid overlap with GUI elements
|
|
36
|
+
* @see GUIElement
|
|
37
|
+
* @type {boolean}
|
|
38
|
+
*/
|
|
39
|
+
resolveGuiCollisions = false;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* How far should the HUD stay away from the edge if it's sticky
|
|
43
|
+
* @see stickToScreenEdge
|
|
44
|
+
* @type {number}
|
|
45
|
+
*/
|
|
46
|
+
screenEdgeWidth = 10;
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Controls whenever or not HUD should remain on the screen when it gets to the edge
|
|
51
|
+
* @type {boolean}
|
|
52
|
+
*/
|
|
53
|
+
stickToScreenEdge = false;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Can be used to enable and disable positioning
|
|
57
|
+
* @type {ObservedBoolean}
|
|
58
|
+
*/
|
|
59
|
+
enabled = new ObservedBoolean(true);
|
|
71
60
|
|
|
72
61
|
/**
|
|
73
62
|
*
|
|
@@ -9,7 +9,7 @@ export class VoiceSystem extends AbstractContextSystem<any> {
|
|
|
9
9
|
font_size: number;
|
|
10
10
|
});
|
|
11
11
|
dependencies: (typeof Voice)[];
|
|
12
|
-
components_used:
|
|
12
|
+
components_used: ResourceAccessSpecification<typeof BehaviorComponent>[];
|
|
13
13
|
/**
|
|
14
14
|
*
|
|
15
15
|
* @type {Localization}
|
|
@@ -100,7 +100,6 @@ export class VoiceSystem extends AbstractContextSystem<any> {
|
|
|
100
100
|
}
|
|
101
101
|
import { AbstractContextSystem } from "../system/AbstractContextSystem.js";
|
|
102
102
|
import { Voice } from "./Voice.js";
|
|
103
|
-
import ViewportPosition from "../gui/position/ViewportPosition.js";
|
|
104
|
-
import { ResourceAccessSpecification } from "../../../core/model/ResourceAccessSpecification.js";
|
|
105
103
|
import { BehaviorComponent } from "../../intelligence/behavior/ecs/BehaviorComponent.js";
|
|
104
|
+
import { ResourceAccessSpecification } from "../../../core/model/ResourceAccessSpecification.js";
|
|
106
105
|
//# sourceMappingURL=VoiceSystem.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VoiceSystem.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/speaker/VoiceSystem.js"],"names":[],"mappings":"AA2JA;IACI;;;;OAIG;IACH;;;OA2FC;IArFG,+BAA2B;IAE3B,
|
|
1
|
+
{"version":3,"file":"VoiceSystem.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/speaker/VoiceSystem.js"],"names":[],"mappings":"AA2JA;IACI;;;;OAIG;IACH;;;OA2FC;IArFG,+BAA2B;IAE3B,yEAQC;IAGD;;;OAGG;IACH,0BAAuB;IAEvB;;;OAGG;IACH,eAAe;IAEf;;;OAGG;IACH,4BAAiB;IAEjB;;;OAGG;IACH,8BAAgB;IAEhB;;;OAGG;IACH,eAAoB;IAEpB;;;;OAIG;IACH,iCAAyC;IAEzC;;;;OAIG;IACH,kBAAkC;IAIlC;;;;OAIG;IACH,eAAkB;IAElB;;;;OAIG;IACH,oBAAgC;IAEhC;;;OAGG;IACH,oBAAqC;IAErC;;;;OAIG;IACH,gBAAoB;IAGxB;;;OAGG;IACH,kBAFY,MAAM,CAIjB;IAED,0EAuBC;IAED;;;;;OAKG;IACH,uBAJW,MAAM,UACN,MAAM,SACN,KAAK,QAsBf;IAED;;;;;OAKG;IACH,wBAoBC;IAED;;;;;OAKG;IACH,gBAJW,MAAM,WACN,MAAM,SACN,KAAK,QAuHf;CACJ;sCAxbqC,oCAAoC;sBAIpD,YAAY;kCAlBA,sDAAsD;4CAR5C,oDAAoD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { v3_distance_sqr } from "../../../../core/geom/vec3/v3_distance_sqr.js";
|
|
2
1
|
import {
|
|
3
2
|
tetrahedral_mesh_find_tets_attached_to_vertex
|
|
4
|
-
} from "../../../../core/
|
|
3
|
+
} from "../../../../core/geom/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.js";
|
|
4
|
+
import { v3_distance_sqr } from "../../../../core/geom/vec3/v3_distance_sqr.js";
|
|
5
5
|
import { max2 } from "../../../../core/math/max2.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Was originally written for TAA jitter sequence optimization in order to reduce maximum impulse
|
|
3
|
+
* @template T
|
|
4
|
+
* @param {T[]} sequence
|
|
5
|
+
* @param {number} dimensions
|
|
6
|
+
* @param {number} offset
|
|
7
|
+
* @param {number} count
|
|
8
|
+
* @param {function(address0:number, address1:number, sequence:T[]):number} cost_function
|
|
9
|
+
* @param {*} [cost_function_ctx]
|
|
10
|
+
*/
|
|
11
|
+
export function optimize_cyclic_sequence_pairwise<T>(sequence: T[], dimensions: number, offset: number, count: number, cost_function: any, cost_function_ctx?: any): void;
|
|
12
|
+
//# sourceMappingURL=optimize_cyclic_sequence_pairwise.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optimize_cyclic_sequence_pairwise.d.ts","sourceRoot":"","sources":["../../../../../src/engine/intelligence/optimization/optimize_cyclic_sequence_pairwise.js"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,gFANW,MAAM,UACN,MAAM,SACN,MAAM,qDAiFhB"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { assert } from "../../../core/assert.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Was originally written for TAA jitter sequence optimization in order to reduce maximum impulse
|
|
5
|
+
* @template T
|
|
6
|
+
* @param {T[]} sequence
|
|
7
|
+
* @param {number} dimensions
|
|
8
|
+
* @param {number} offset
|
|
9
|
+
* @param {number} count
|
|
10
|
+
* @param {function(address0:number, address1:number, sequence:T[]):number} cost_function
|
|
11
|
+
* @param {*} [cost_function_ctx]
|
|
12
|
+
*/
|
|
13
|
+
export function optimize_cyclic_sequence_pairwise(
|
|
14
|
+
sequence,
|
|
15
|
+
dimensions,
|
|
16
|
+
offset,
|
|
17
|
+
count,
|
|
18
|
+
cost_function,
|
|
19
|
+
cost_function_ctx
|
|
20
|
+
) {
|
|
21
|
+
|
|
22
|
+
assert.isNonNegativeInteger(dimensions, 'dimensions');
|
|
23
|
+
assert.isNonNegativeInteger(offset, 'offset');
|
|
24
|
+
assert.isNonNegativeInteger(count, 'count');
|
|
25
|
+
|
|
26
|
+
assert.isFunction(cost_function, 'cost_function');
|
|
27
|
+
|
|
28
|
+
let swaps = 0;
|
|
29
|
+
|
|
30
|
+
let distance_max = (count - 1) >>> 1;
|
|
31
|
+
|
|
32
|
+
function index_to_address(index) {
|
|
33
|
+
const wrapped_index = (index + count) % count;
|
|
34
|
+
return offset + wrapped_index * dimensions;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function move(from, to){
|
|
38
|
+
const i0 = index_to_address(from);
|
|
39
|
+
const i1 = index_to_address(to);
|
|
40
|
+
|
|
41
|
+
const clip = sequence.splice(i0, dimensions);
|
|
42
|
+
sequence.splice(i1, 0, ...clip);
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function pair_cost(i0, i1){
|
|
47
|
+
return cost_function.call(cost_function_ctx, index_to_address(i0), index_to_address(i1), sequence)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
main: do {
|
|
51
|
+
swaps = 0;
|
|
52
|
+
|
|
53
|
+
for (let from = 0; from < count; from++) {
|
|
54
|
+
|
|
55
|
+
for (let distance = -distance_max; distance <= distance_max; distance++) {
|
|
56
|
+
if (distance === 0) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// estimate swap benefit
|
|
61
|
+
const to = from+distance;
|
|
62
|
+
|
|
63
|
+
const removal_gain = pair_cost(from-1, from+1) - (
|
|
64
|
+
pair_cost(from-1, from) + pair_cost(from, from+1)
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
move(from, to);
|
|
68
|
+
|
|
69
|
+
const insertion_gain = ( pair_cost(to-1, to) + pair_cost(to, to+1))
|
|
70
|
+
- pair_cost(to -1, to+1);
|
|
71
|
+
|
|
72
|
+
const move_cost =insertion_gain + removal_gain;
|
|
73
|
+
|
|
74
|
+
if (move_cost >= 0) {
|
|
75
|
+
// bad swap, undo
|
|
76
|
+
|
|
77
|
+
move(to, from);
|
|
78
|
+
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
swaps++;
|
|
83
|
+
|
|
84
|
+
continue main;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
} while (swaps > 0);
|
|
89
|
+
|
|
90
|
+
}
|
package/src/core/geometry/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tetrahedral_mesh_find_tets_attached_to_vertex.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geometry/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.js"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,sEANW,MAAM,EAAE,iBACR,MAAM,uCAEN,MAAM,GACJ,MAAM,CAyBlB"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export class MersenneTwister {
|
|
2
|
-
constructor(seed?: number);
|
|
3
|
-
N: number;
|
|
4
|
-
M: number;
|
|
5
|
-
MATRIX_A: number;
|
|
6
|
-
UPPER_MASK: number;
|
|
7
|
-
LOWER_MASK: number;
|
|
8
|
-
mt: any[];
|
|
9
|
-
mti: number;
|
|
10
|
-
init_genrand(s: any): void;
|
|
11
|
-
init_by_array(init_key: any, key_length: any): void;
|
|
12
|
-
genrand_int32(): number;
|
|
13
|
-
genrand_int31(): number;
|
|
14
|
-
genrand_real1(): number;
|
|
15
|
-
random(): number;
|
|
16
|
-
genrand_real3(): number;
|
|
17
|
-
genrand_res53(): number;
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=MersenneTwister.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MersenneTwister.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/random/MersenneTwister.js"],"names":[],"mappings":"AA8DA;IACI,2BAkBC;IAfG,UAAY;IACZ,UAAY;IACZ,iBAA0B;IAE1B,mBAA4B;IAE5B,mBAA4B;IAG5B,UAA2B;IAE3B,YAAqB;IAOzB,2BAaC;IAOD,oDAqCC;IAGD,wBAmCC;IAGD,wBAEC;IAGD,wBAGC;IAGD,iBAGC;IAGD,wBAGC;IAGD,wBAGC;CACJ"}
|