@woosh/meep-engine 2.92.22 → 2.92.23
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.module.js
CHANGED
|
@@ -4709,28 +4709,25 @@ const FLAGS_DEFAULT = TransformFlags.AutomaticChangeDetection;
|
|
|
4709
4709
|
class Transform {
|
|
4710
4710
|
|
|
4711
4711
|
/**
|
|
4712
|
-
* World-space position
|
|
4713
4712
|
* @type {Vector3}
|
|
4714
4713
|
* @readonly
|
|
4715
4714
|
*/
|
|
4716
4715
|
position = new Vector3$1(0, 0, 0);
|
|
4717
4716
|
|
|
4718
4717
|
/**
|
|
4719
|
-
* World-space rotation
|
|
4720
4718
|
* @type {Quaternion}
|
|
4721
4719
|
* @readonly
|
|
4722
4720
|
*/
|
|
4723
4721
|
rotation = new Quaternion$1(0, 0, 0, 1);
|
|
4724
4722
|
|
|
4725
4723
|
/**
|
|
4726
|
-
* World-space scale
|
|
4727
4724
|
* @type {Vector3}
|
|
4728
4725
|
* @readonly
|
|
4729
4726
|
*/
|
|
4730
4727
|
scale = new Vector3$1(1, 1, 1);
|
|
4731
4728
|
|
|
4732
4729
|
/**
|
|
4733
|
-
*
|
|
4730
|
+
* transform matrix, position, rotation and scale must match, but shear can be different
|
|
4734
4731
|
* @readonly
|
|
4735
4732
|
* @type {Float32Array}
|
|
4736
4733
|
*/
|
|
@@ -4738,22 +4735,18 @@ class Transform {
|
|
|
4738
4735
|
|
|
4739
4736
|
/**
|
|
4740
4737
|
* Various bit flags, see {@link TransformFlags}
|
|
4741
|
-
*
|
|
4738
|
+
* This should generally be accessed through getFlag/setFlag instead of modifying the value directly
|
|
4742
4739
|
* @type {number}
|
|
4743
4740
|
*/
|
|
4744
4741
|
flags = FLAGS_DEFAULT;
|
|
4745
4742
|
|
|
4746
|
-
/**
|
|
4747
|
-
*
|
|
4748
|
-
* @constructor
|
|
4749
|
-
*/
|
|
4750
4743
|
constructor() {
|
|
4751
4744
|
// watch changes
|
|
4752
4745
|
this.subscribe(this.#handle_component_change, this);
|
|
4753
4746
|
}
|
|
4754
4747
|
|
|
4755
4748
|
/**
|
|
4756
|
-
* Current "forward" direction
|
|
4749
|
+
* Current "forward" direction
|
|
4757
4750
|
* NOTE that this vector is not live, meaning that if you modify transform, previously-obtained result will no longer be valid
|
|
4758
4751
|
* @returns {Vector3}
|
|
4759
4752
|
*/
|
|
@@ -4765,6 +4758,30 @@ class Transform {
|
|
|
4765
4758
|
return result;
|
|
4766
4759
|
}
|
|
4767
4760
|
|
|
4761
|
+
/**
|
|
4762
|
+
* Current "up" direction
|
|
4763
|
+
* @return {Vector3}
|
|
4764
|
+
*/
|
|
4765
|
+
get up() {
|
|
4766
|
+
const result = Vector3$1.up.clone();
|
|
4767
|
+
|
|
4768
|
+
result.applyDirectionMatrix4(this.matrix);
|
|
4769
|
+
|
|
4770
|
+
return result;
|
|
4771
|
+
}
|
|
4772
|
+
|
|
4773
|
+
/**
|
|
4774
|
+
* Current "right" direction
|
|
4775
|
+
* @return {Vector3}
|
|
4776
|
+
*/
|
|
4777
|
+
get right() {
|
|
4778
|
+
const result = Vector3$1.right.clone();
|
|
4779
|
+
|
|
4780
|
+
result.applyDirectionMatrix4(this.matrix);
|
|
4781
|
+
|
|
4782
|
+
return result;
|
|
4783
|
+
}
|
|
4784
|
+
|
|
4768
4785
|
/**
|
|
4769
4786
|
* Attach change listener
|
|
4770
4787
|
* @param {function} handler
|
|
@@ -4980,6 +4997,7 @@ class Transform {
|
|
|
4980
4997
|
* @param {mat4|number[]|Float32Array} m
|
|
4981
4998
|
*/
|
|
4982
4999
|
fromMatrix4(m) {
|
|
5000
|
+
// we know we are changing the matrix, so we're going to need to disable the flag that sets matrix from position/rotation/scale changes
|
|
4983
5001
|
const ad = this.getFlag(TransformFlags.AutomaticChangeDetection);
|
|
4984
5002
|
|
|
4985
5003
|
this.clearFlag(TransformFlags.AutomaticChangeDetection);
|
|
@@ -4988,6 +5006,7 @@ class Transform {
|
|
|
4988
5006
|
|
|
4989
5007
|
decompose_matrix_4_array(m, this.position, this.rotation, this.scale);
|
|
4990
5008
|
|
|
5009
|
+
// restore value of the flag
|
|
4991
5010
|
this.writeFlag(TransformFlags.AutomaticChangeDetection, ad);
|
|
4992
5011
|
}
|
|
4993
5012
|
|
package/package.json
CHANGED
|
@@ -6,7 +6,9 @@ export class Transform {
|
|
|
6
6
|
readonly rotation: Quaternion
|
|
7
7
|
readonly scale: Vector3
|
|
8
8
|
|
|
9
|
-
readonly forward: Vector3
|
|
9
|
+
readonly forward: Readonly<Vector3>
|
|
10
|
+
readonly up: Readonly<Vector3>
|
|
11
|
+
readonly right: Readonly<Vector3>
|
|
10
12
|
|
|
11
13
|
flags: number
|
|
12
14
|
|
|
@@ -15,8 +17,8 @@ export class Transform {
|
|
|
15
17
|
public lookAt(target: Vector3, up?: Vector3): void
|
|
16
18
|
|
|
17
19
|
static fromJSON(json: {
|
|
18
|
-
position?: { x: number, y: number, z: number },
|
|
19
|
-
scale?: { x: number, y: number, z: number },
|
|
20
|
+
position?: number | { x: number, y: number, z: number },
|
|
21
|
+
scale?: number | { x: number, y: number, z: number },
|
|
20
22
|
rotation?: { x: number, y: number, z: number, w: number },
|
|
21
23
|
}): Transform
|
|
22
24
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transform.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/transform/Transform.js"],"names":[],"mappings":"AA0BA;;;GAGG;AACH;
|
|
1
|
+
{"version":3,"file":"Transform.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/transform/Transform.js"],"names":[],"mappings":"AA0BA;;;GAGG;AACH;IAwQI;;;;OAIG;IACH,4BAFa,SAAS,CAQrB;IAjRD;;;OAGG;IACH,mBAHU,OAAO,CAGe;IAEhC;;;OAGG;IACH,mBAHU,UAAU,CAGkB;IAEtC;;;OAGG;IACH,gBAHU,OAAO,CAGY;IAE7B;;;;OAIG;IACH,iBAFU,YAAY,CAEW;IAEjC;;;;OAIG;IACH,OAFU,MAAM,CAEM;IAOtB;;;;OAIG;IACH,uBAMC;IAED;;;OAGG;IACH,kBAMC;IAED;;;OAGG;IACH,qBAMC;IAED;;;;OAIG;IACH,kDAIC;IAED;;;;OAIG;IACH,oDAIC;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;IAeD;;;;OAIG;IACH,sBAHW,SAAS,KACT,SAAS,QAMnB;IAED;;;OAGG;IACH,eAFW,OAAK,MAAM,EAAE,GAAC,YAAY,QAcpC;IAED;;;OAGG;IACH,kBAFW,MAAM,EAAE,GAAC,YAAY,QAI/B;IAED;;;;;OAKG;IACH,qBAEC;IAED,mBAEC;IASL;;;OAGG;IACH,sBAFU,OAAO,CAEc;;CAZ9B;;kBAIS,MAAM;IAWhB;;;;;OAKG;IACH,mGAMC;;oBArXmB,+BAA+B;uBAD5B,kCAAkC;+BAE1B,qBAAqB"}
|
|
@@ -31,28 +31,25 @@ const FLAGS_DEFAULT = TransformFlags.AutomaticChangeDetection;
|
|
|
31
31
|
export class Transform {
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
* World-space position
|
|
35
34
|
* @type {Vector3}
|
|
36
35
|
* @readonly
|
|
37
36
|
*/
|
|
38
37
|
position = new Vector3(0, 0, 0);
|
|
39
38
|
|
|
40
39
|
/**
|
|
41
|
-
* World-space rotation
|
|
42
40
|
* @type {Quaternion}
|
|
43
41
|
* @readonly
|
|
44
42
|
*/
|
|
45
43
|
rotation = new Quaternion(0, 0, 0, 1);
|
|
46
44
|
|
|
47
45
|
/**
|
|
48
|
-
* World-space scale
|
|
49
46
|
* @type {Vector3}
|
|
50
47
|
* @readonly
|
|
51
48
|
*/
|
|
52
49
|
scale = new Vector3(1, 1, 1);
|
|
53
50
|
|
|
54
51
|
/**
|
|
55
|
-
*
|
|
52
|
+
* transform matrix, position, rotation and scale must match, but shear can be different
|
|
56
53
|
* @readonly
|
|
57
54
|
* @type {Float32Array}
|
|
58
55
|
*/
|
|
@@ -60,22 +57,18 @@ export class Transform {
|
|
|
60
57
|
|
|
61
58
|
/**
|
|
62
59
|
* Various bit flags, see {@link TransformFlags}
|
|
63
|
-
*
|
|
60
|
+
* This should generally be accessed through getFlag/setFlag instead of modifying the value directly
|
|
64
61
|
* @type {number}
|
|
65
62
|
*/
|
|
66
63
|
flags = FLAGS_DEFAULT;
|
|
67
64
|
|
|
68
|
-
/**
|
|
69
|
-
*
|
|
70
|
-
* @constructor
|
|
71
|
-
*/
|
|
72
65
|
constructor() {
|
|
73
66
|
// watch changes
|
|
74
67
|
this.subscribe(this.#handle_component_change, this);
|
|
75
68
|
}
|
|
76
69
|
|
|
77
70
|
/**
|
|
78
|
-
* Current "forward" direction
|
|
71
|
+
* Current "forward" direction
|
|
79
72
|
* NOTE that this vector is not live, meaning that if you modify transform, previously-obtained result will no longer be valid
|
|
80
73
|
* @returns {Vector3}
|
|
81
74
|
*/
|
|
@@ -87,6 +80,30 @@ export class Transform {
|
|
|
87
80
|
return result;
|
|
88
81
|
}
|
|
89
82
|
|
|
83
|
+
/**
|
|
84
|
+
* Current "up" direction
|
|
85
|
+
* @return {Vector3}
|
|
86
|
+
*/
|
|
87
|
+
get up() {
|
|
88
|
+
const result = Vector3.up.clone();
|
|
89
|
+
|
|
90
|
+
result.applyDirectionMatrix4(this.matrix);
|
|
91
|
+
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Current "right" direction
|
|
97
|
+
* @return {Vector3}
|
|
98
|
+
*/
|
|
99
|
+
get right() {
|
|
100
|
+
const result = Vector3.right.clone();
|
|
101
|
+
|
|
102
|
+
result.applyDirectionMatrix4(this.matrix);
|
|
103
|
+
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
|
|
90
107
|
/**
|
|
91
108
|
* Attach change listener
|
|
92
109
|
* @param {function} handler
|
|
@@ -304,6 +321,7 @@ export class Transform {
|
|
|
304
321
|
* @param {mat4|number[]|Float32Array} m
|
|
305
322
|
*/
|
|
306
323
|
fromMatrix4(m) {
|
|
324
|
+
// we know we are changing the matrix, so we're going to need to disable the flag that sets matrix from position/rotation/scale changes
|
|
307
325
|
const ad = this.getFlag(TransformFlags.AutomaticChangeDetection);
|
|
308
326
|
|
|
309
327
|
this.clearFlag(TransformFlags.AutomaticChangeDetection);
|
|
@@ -312,6 +330,7 @@ export class Transform {
|
|
|
312
330
|
|
|
313
331
|
decompose_matrix_4_array(m, this.position, this.rotation, this.scale);
|
|
314
332
|
|
|
333
|
+
// restore value of the flag
|
|
315
334
|
this.writeFlag(TransformFlags.AutomaticChangeDetection, ad);
|
|
316
335
|
}
|
|
317
336
|
|