@woosh/meep-engine 2.78.0 → 2.79.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.
- package/build/meep.cjs +87 -63
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +87 -63
- package/package.json +1 -1
- package/src/core/{graph → geom/3d/topology}/build_face_graph_from_mesh.js +5 -5
- package/src/core/geom/Quaternion.js +1 -1
- package/src/core/geom/vec3/v3_angle_between.js +15 -4
- package/src/core/geom/vec3/{v3_computeOffsetVector.js → v3_displace_in_direction.js} +11 -2
- package/src/core/graph/Edge.js +10 -22
- package/src/core/graph/Edge.spec.js +35 -0
- package/src/core/graph/MultiNode.js +6 -7
- package/src/core/graph/v2/Graph.js +20 -8
- package/src/core/graph/v2/NodeContainer.js +1 -0
- package/src/engine/ecs/ik/OneBoneSurfaceAlignmentSolver.js +2 -2
- package/src/engine/ecs/ik/TwoBoneInverseKinematicsSolver.js +2 -2
- package/src/engine/ecs/transform-attachment/TransformAttachment.js +2 -1
- package/src/engine/ecs/transform-attachment/TransformAttachmentSystem.js +45 -33
- package/src/core/graph/EdgeDirection.js +0 -11
- package/src/core/primitives/strings/prefixTree/PrefixTree.js +0 -225
- package/src/core/primitives/strings/prefixTree/PrefixTree.spec.js +0 -39
- package/src/core/primitives/strings/prefixTree/PrefixTreeLeaf.js +0 -25
- package/src/core/primitives/strings/prefixTree/PrefixTreeNode.js +0 -16
package/build/meep.cjs
CHANGED
|
@@ -1980,10 +1980,15 @@ function v3_length(x, y, z) {
|
|
|
1980
1980
|
* @param {number} z1
|
|
1981
1981
|
* @returns {number}
|
|
1982
1982
|
*/
|
|
1983
|
-
function v3_angle_between(
|
|
1983
|
+
function v3_angle_between(
|
|
1984
|
+
x0, y0, z0,
|
|
1985
|
+
x1, y1, z1
|
|
1986
|
+
) {
|
|
1987
|
+
|
|
1984
1988
|
const theta = v3_angle_cos_between(x0, y0, z0, x1, y1, z1);
|
|
1985
1989
|
|
|
1986
1990
|
return Math.acos(theta);
|
|
1991
|
+
|
|
1987
1992
|
}
|
|
1988
1993
|
|
|
1989
1994
|
/**
|
|
@@ -1994,9 +1999,13 @@ function v3_angle_between(x0, y0, z0, x1, y1, z1) {
|
|
|
1994
1999
|
* @param {number} x1
|
|
1995
2000
|
* @param {number} y1
|
|
1996
2001
|
* @param {number} z1
|
|
1997
|
-
* @returns {number}
|
|
2002
|
+
* @returns {number} value between -1 and 1, cosine of the angle between vectors
|
|
1998
2003
|
*/
|
|
1999
|
-
function v3_angle_cos_between(
|
|
2004
|
+
function v3_angle_cos_between(
|
|
2005
|
+
x0, y0, z0,
|
|
2006
|
+
x1, y1, z1
|
|
2007
|
+
) {
|
|
2008
|
+
|
|
2000
2009
|
const d = v3_dot(x0, y0, z0, x1, y1, z1);
|
|
2001
2010
|
|
|
2002
2011
|
const magnitude_0 = v3_length(x0, y0, z0);
|
|
@@ -2006,10 +2015,12 @@ function v3_angle_cos_between(x0, y0, z0, x1, y1, z1){
|
|
|
2006
2015
|
|
|
2007
2016
|
if (l === 0) {
|
|
2008
2017
|
// collective magnitude is 0, provide arbitrary angle
|
|
2018
|
+
// avoid division by 0
|
|
2009
2019
|
return 0;
|
|
2010
2020
|
}
|
|
2011
2021
|
|
|
2012
2022
|
return clamp$1(d / l, -1, 1);
|
|
2023
|
+
|
|
2013
2024
|
}
|
|
2014
2025
|
|
|
2015
2026
|
/**
|
|
@@ -4708,7 +4719,7 @@ let Quaternion$1 = class Quaternion {
|
|
|
4708
4719
|
* @param {Quaternion} result
|
|
4709
4720
|
* @param {Quaternion} from
|
|
4710
4721
|
* @param {Quaternion} to
|
|
4711
|
-
* @param {number} max_delta
|
|
4722
|
+
* @param {number} max_delta in radians
|
|
4712
4723
|
*/
|
|
4713
4724
|
static rotateTowards(result, from, to, max_delta) {
|
|
4714
4725
|
|
|
@@ -70585,10 +70596,19 @@ class Edge {
|
|
|
70585
70596
|
return this.first === node || this.second === node;
|
|
70586
70597
|
}
|
|
70587
70598
|
|
|
70599
|
+
/**
|
|
70600
|
+
*
|
|
70601
|
+
* @param {N} source
|
|
70602
|
+
* @param {N} target
|
|
70603
|
+
* @returns {boolean} True iff the edge contains both source and target and allows transition from source to target
|
|
70604
|
+
*/
|
|
70588
70605
|
validateTransition(source, target) {
|
|
70589
70606
|
const a = this.first;
|
|
70590
70607
|
const b = this.second;
|
|
70591
|
-
|
|
70608
|
+
|
|
70609
|
+
return (a === source && b === target && this.traversableForward())
|
|
70610
|
+
|| (b === source && a === target && this.traversableBackward())
|
|
70611
|
+
;
|
|
70592
70612
|
}
|
|
70593
70613
|
|
|
70594
70614
|
/**
|
|
@@ -70636,16 +70656,6 @@ class Edge {
|
|
|
70636
70656
|
|| (this.second === node && this.direction === EdgeDirectionType.Backward)
|
|
70637
70657
|
}
|
|
70638
70658
|
|
|
70639
|
-
/**
|
|
70640
|
-
* @deprecated
|
|
70641
|
-
* @returns {number}
|
|
70642
|
-
*/
|
|
70643
|
-
angle() {
|
|
70644
|
-
|
|
70645
|
-
const delta = this.second.clone().sub(this.first);
|
|
70646
|
-
return Math.atan2(delta.y, delta.x);
|
|
70647
|
-
}
|
|
70648
|
-
|
|
70649
70659
|
/**
|
|
70650
70660
|
*
|
|
70651
70661
|
* @returns {N[]}
|
|
@@ -70654,15 +70664,6 @@ class Edge {
|
|
|
70654
70664
|
return [this.first, this.second];
|
|
70655
70665
|
}
|
|
70656
70666
|
|
|
70657
|
-
|
|
70658
|
-
/**
|
|
70659
|
-
* @deprecated
|
|
70660
|
-
* @returns {number}
|
|
70661
|
-
*/
|
|
70662
|
-
get length() {
|
|
70663
|
-
|
|
70664
|
-
return this.first.distanceTo(this.second);
|
|
70665
|
-
}
|
|
70666
70667
|
}
|
|
70667
70668
|
|
|
70668
70669
|
/**
|
|
@@ -70693,6 +70694,7 @@ class NodeContainer {
|
|
|
70693
70694
|
/**
|
|
70694
70695
|
*
|
|
70695
70696
|
* @type {Map<N,number>}
|
|
70697
|
+
* Maps neighbour node to number of edges to that node from this one
|
|
70696
70698
|
* @private
|
|
70697
70699
|
*/
|
|
70698
70700
|
__neighbors = new Map();
|
|
@@ -71086,6 +71088,7 @@ class Graph {
|
|
|
71086
71088
|
/**
|
|
71087
71089
|
*
|
|
71088
71090
|
* @param {N} node
|
|
71091
|
+
* @returns {boolean}
|
|
71089
71092
|
*/
|
|
71090
71093
|
removeNode(node) {
|
|
71091
71094
|
|
|
@@ -71159,7 +71162,7 @@ class Graph {
|
|
|
71159
71162
|
}
|
|
71160
71163
|
|
|
71161
71164
|
/**
|
|
71162
|
-
*
|
|
71165
|
+
* Node degree is the number of attached edges
|
|
71163
71166
|
* @param {N} node
|
|
71164
71167
|
* @return {number}
|
|
71165
71168
|
*/
|
|
@@ -71201,13 +71204,18 @@ class Graph {
|
|
|
71201
71204
|
*
|
|
71202
71205
|
* @param {N} source
|
|
71203
71206
|
* @param {N} target
|
|
71204
|
-
* @param {EdgeDirectionType} [
|
|
71207
|
+
* @param {EdgeDirectionType} [direction] Undirected by default
|
|
71205
71208
|
* @returns {Edge<N>}
|
|
71206
71209
|
*/
|
|
71207
|
-
createEdge(
|
|
71210
|
+
createEdge(
|
|
71211
|
+
source,
|
|
71212
|
+
target,
|
|
71213
|
+
direction = EdgeDirectionType.Undirected
|
|
71214
|
+
) {
|
|
71215
|
+
|
|
71208
71216
|
const edge = new Edge(source, target);
|
|
71209
71217
|
|
|
71210
|
-
edge.direction =
|
|
71218
|
+
edge.direction = direction;
|
|
71211
71219
|
|
|
71212
71220
|
this.addEdge(edge);
|
|
71213
71221
|
|
|
@@ -71215,9 +71223,10 @@ class Graph {
|
|
|
71215
71223
|
}
|
|
71216
71224
|
|
|
71217
71225
|
/**
|
|
71218
|
-
*
|
|
71226
|
+
* Both nodes that the edge is attached to must be present
|
|
71219
71227
|
* @param {Edge<N>} edge
|
|
71220
|
-
* @returns {boolean}
|
|
71228
|
+
* @returns {boolean} true if edge was added, false if edge was already present
|
|
71229
|
+
* @throws if one or both nodes are not contained in the graph
|
|
71221
71230
|
*/
|
|
71222
71231
|
addEdge(edge) {
|
|
71223
71232
|
if (this.hasEdge(edge)) {
|
|
@@ -71419,10 +71428,10 @@ class Graph {
|
|
|
71419
71428
|
}
|
|
71420
71429
|
|
|
71421
71430
|
/**
|
|
71422
|
-
*
|
|
71431
|
+
* Find a path through the graph
|
|
71423
71432
|
* @param {N} start
|
|
71424
71433
|
* @param {N} goal
|
|
71425
|
-
* @returns {null|N[]}
|
|
71434
|
+
* @returns {null|N[]} null if no path exists
|
|
71426
71435
|
*/
|
|
71427
71436
|
findPath(start, goal) {
|
|
71428
71437
|
const start_node_container = this.__nodes.get(start);
|
|
@@ -71462,6 +71471,7 @@ class Graph {
|
|
|
71462
71471
|
const b = edge.second;
|
|
71463
71472
|
|
|
71464
71473
|
let other = null;
|
|
71474
|
+
|
|
71465
71475
|
if (a === current_node && (edge.direction === EdgeDirectionType.Forward || edge.direction === EdgeDirectionType.Undirected)) {
|
|
71466
71476
|
other = b;
|
|
71467
71477
|
} else if (b === current_node && (edge.direction === EdgeDirectionType.Backward || edge.direction === EdgeDirectionType.Undirected)) {
|
|
@@ -71490,6 +71500,9 @@ class Graph {
|
|
|
71490
71500
|
return null;
|
|
71491
71501
|
}
|
|
71492
71502
|
|
|
71503
|
+
/**
|
|
71504
|
+
* Remove all data from the graph, resetting it to empty state
|
|
71505
|
+
*/
|
|
71493
71506
|
clear() {
|
|
71494
71507
|
this.__nodes.clear();
|
|
71495
71508
|
this.__edges.clear();
|
|
@@ -72958,6 +72971,7 @@ class TransformAttachment {
|
|
|
72958
72971
|
|
|
72959
72972
|
/**
|
|
72960
72973
|
* transform relative to the attachment target
|
|
72974
|
+
* Think of it as "local transform"
|
|
72961
72975
|
* @type {Transform}
|
|
72962
72976
|
*/
|
|
72963
72977
|
transform = new Transform();
|
|
@@ -73571,7 +73585,10 @@ class UpdateContext {
|
|
|
73571
73585
|
}
|
|
73572
73586
|
|
|
73573
73587
|
update() {
|
|
73574
|
-
this.transform.multiplyTransforms(
|
|
73588
|
+
this.transform.multiplyTransforms(
|
|
73589
|
+
this.parent_transform,
|
|
73590
|
+
this.attachment.transform
|
|
73591
|
+
);
|
|
73575
73592
|
}
|
|
73576
73593
|
|
|
73577
73594
|
/**
|
|
@@ -73594,51 +73611,51 @@ class UpdateContext {
|
|
|
73594
73611
|
link() {
|
|
73595
73612
|
const t_parent = this.parent_transform;
|
|
73596
73613
|
|
|
73597
|
-
t_parent.
|
|
73598
|
-
t_parent.rotation.onChanged.add(this.update, this);
|
|
73599
|
-
t_parent.scale.onChanged.add(this.update, this);
|
|
73614
|
+
t_parent.subscribe(this.update, this);
|
|
73600
73615
|
|
|
73601
73616
|
const t_attachment = this.attachment.transform;
|
|
73602
|
-
|
|
73603
|
-
t_attachment.
|
|
73604
|
-
t_attachment.scale.onChanged.add(this.update,this);
|
|
73617
|
+
|
|
73618
|
+
t_attachment.subscribe(this.update, this);
|
|
73605
73619
|
}
|
|
73606
73620
|
|
|
73607
73621
|
unlink() {
|
|
73608
73622
|
const transform = this.parent_transform;
|
|
73609
73623
|
|
|
73610
|
-
transform.
|
|
73611
|
-
transform.rotation.onChanged.remove(this.update, this);
|
|
73612
|
-
transform.scale.onChanged.remove(this.update, this);
|
|
73624
|
+
transform.unsubscribe(this.update, this);
|
|
73613
73625
|
|
|
73614
73626
|
const t_attachment = this.attachment.transform;
|
|
73615
|
-
|
|
73616
|
-
t_attachment.
|
|
73617
|
-
t_attachment.scale.onChanged.remove(this.update,this);
|
|
73627
|
+
|
|
73628
|
+
t_attachment.unsubscribe(this.update, this);
|
|
73618
73629
|
}
|
|
73619
73630
|
}
|
|
73620
73631
|
|
|
73621
73632
|
class TransformAttachmentSystem extends System {
|
|
73633
|
+
|
|
73634
|
+
/**
|
|
73635
|
+
*
|
|
73636
|
+
* @type {UpdateContext[]}
|
|
73637
|
+
* @private
|
|
73638
|
+
*/
|
|
73639
|
+
__contexts = [];
|
|
73640
|
+
|
|
73641
|
+
/**
|
|
73642
|
+
*
|
|
73643
|
+
* @type {UpdateContext[]}
|
|
73644
|
+
* @private
|
|
73645
|
+
*/
|
|
73646
|
+
__queue = [];
|
|
73647
|
+
__queue_size = 0;
|
|
73648
|
+
__queue_cursor = 0;
|
|
73649
|
+
|
|
73622
73650
|
constructor() {
|
|
73623
73651
|
super();
|
|
73624
73652
|
|
|
73625
73653
|
this.dependencies = [TransformAttachment, Transform];
|
|
73626
73654
|
|
|
73627
|
-
|
|
73628
|
-
|
|
73629
|
-
|
|
73630
|
-
|
|
73631
|
-
*/
|
|
73632
|
-
this.__contexts = [];
|
|
73633
|
-
|
|
73634
|
-
/**
|
|
73635
|
-
*
|
|
73636
|
-
* @type {UpdateContext[]}
|
|
73637
|
-
* @private
|
|
73638
|
-
*/
|
|
73639
|
-
this.__queue = [];
|
|
73640
|
-
this.__queue_size = 0;
|
|
73641
|
-
this.__queue_cursor = 0;
|
|
73655
|
+
this.components_used = [
|
|
73656
|
+
ResourceAccessSpecification.from(TransformAttachment, ResourceAccessKind.Read),
|
|
73657
|
+
ResourceAccessSpecification.from(Transform, ResourceAccessKind.Read | ResourceAccessKind.Write),
|
|
73658
|
+
];
|
|
73642
73659
|
}
|
|
73643
73660
|
|
|
73644
73661
|
/**
|
|
@@ -73666,6 +73683,12 @@ class TransformAttachmentSystem extends System {
|
|
|
73666
73683
|
this.__queue[this.__queue_size++] = ctx;
|
|
73667
73684
|
}
|
|
73668
73685
|
|
|
73686
|
+
/**
|
|
73687
|
+
*
|
|
73688
|
+
* @param {number} entity
|
|
73689
|
+
* @returns {boolean}
|
|
73690
|
+
* @private
|
|
73691
|
+
*/
|
|
73669
73692
|
__dequeue_entity(entity) {
|
|
73670
73693
|
for (let i = 0; i < this.__queue_size; i++) {
|
|
73671
73694
|
const ctx = this.__queue[i];
|
|
@@ -73694,9 +73717,7 @@ class TransformAttachmentSystem extends System {
|
|
|
73694
73717
|
ctx.entity = entity;
|
|
73695
73718
|
|
|
73696
73719
|
|
|
73697
|
-
|
|
73698
|
-
|
|
73699
|
-
ctx.ecd = ecd;
|
|
73720
|
+
ctx.ecd = this.entityManager.dataset;
|
|
73700
73721
|
|
|
73701
73722
|
if (ctx.bind_parent()) {
|
|
73702
73723
|
this.__finalize_link(ctx);
|
|
@@ -73731,12 +73752,14 @@ class TransformAttachmentSystem extends System {
|
|
|
73731
73752
|
|
|
73732
73753
|
update(timeDelta) {
|
|
73733
73754
|
const step_count = min2(this.__queue_size, QUEUE_ITERATION_COUNT);
|
|
73755
|
+
|
|
73734
73756
|
for (let i = 0; i < step_count; i++) {
|
|
73735
73757
|
const index = this.__queue_cursor % this.__queue_size;
|
|
73736
73758
|
|
|
73737
73759
|
const ctx = this.__queue[index];
|
|
73738
73760
|
|
|
73739
73761
|
if (ctx.bind_parent()) {
|
|
73762
|
+
// parent obtained
|
|
73740
73763
|
this.__finalize_link(ctx);
|
|
73741
73764
|
|
|
73742
73765
|
this.__queue.splice(index, 1);
|
|
@@ -73746,6 +73769,7 @@ class TransformAttachmentSystem extends System {
|
|
|
73746
73769
|
this.__queue_cursor++;
|
|
73747
73770
|
}
|
|
73748
73771
|
}
|
|
73772
|
+
|
|
73749
73773
|
}
|
|
73750
73774
|
}
|
|
73751
73775
|
|