@woosh/meep-engine 2.43.38 → 2.43.40

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 (60) hide show
  1. package/core/bvh2/aabb3/AABB3.js +72 -85
  2. package/core/bvh2/aabb3/serializeAABB3Encoded_v0.js +75 -0
  3. package/core/bvh2/serialization/serializeBinaryNodeToBinaryBuffer.js +1 -1
  4. package/core/collection/HashMap.js +16 -8
  5. package/core/color/Color.js +1 -1
  6. package/core/geom/3d/aabb/aabb3_matrix4_project.js +4 -0
  7. package/core/geom/ConicRay.js +1 -1
  8. package/core/geom/Quaternion.d.ts +7 -2
  9. package/core/geom/Quaternion.js +19 -3
  10. package/core/geom/Vector1.d.ts +19 -1
  11. package/core/geom/Vector1.js +11 -3
  12. package/core/geom/Vector2.d.ts +7 -0
  13. package/core/geom/Vector2.js +21 -4
  14. package/core/geom/Vector3.d.ts +4 -4
  15. package/core/geom/Vector3.js +29 -4
  16. package/core/geom/Vector4.d.ts +7 -2
  17. package/core/geom/Vector4.js +8 -8
  18. package/core/math/hash/computeHashFloatArray.js +1 -1
  19. package/core/math/hash/computeObjectHash.js +22 -22
  20. package/core/math/hash/computeObjectHash.spec.js +42 -0
  21. package/core/math/interval/NumericInterval.js +1 -1
  22. package/core/model/BoundedValue.js +1 -1
  23. package/core/model/node-graph/Connection.js +6 -6
  24. package/core/model/node-graph/DataType.js +13 -12
  25. package/core/model/node-graph/NodeGraph.js +30 -5
  26. package/core/model/node-graph/node/NodeDescription.js +14 -11
  27. package/core/model/node-graph/node/NodeDescription.spec.js +14 -0
  28. package/core/model/node-graph/node/NodeInstance.js +2 -2
  29. package/core/model/node-graph/node/parameter/NodeParameterDescription.js +1 -1
  30. package/core/model/reactive/model/terminal/ReactiveLiteralNumber.js +1 -1
  31. package/core/model/stat/LinearModifier.js +1 -1
  32. package/core/{math/hash → primitives/numbers}/computeHashFloat.js +0 -0
  33. package/core/{math/hash → primitives/numbers}/computeHashFloat.spec.js +0 -0
  34. package/engine/Engine.d.ts +1 -1
  35. package/engine/asset/loaders/material/computeMaterialHash.js +1 -1
  36. package/engine/asset/loaders/material/computeTextureHash.js +1 -1
  37. package/engine/ecs/animation/Animation.js +1 -1
  38. package/engine/ecs/animation/InverseKinematics.js +1 -1
  39. package/engine/ecs/dynamic_actions/actions/definition/WeightedRandomActionDescription.js +1 -1
  40. package/engine/ecs/gui/position/ViewportPosition.js +1 -1
  41. package/engine/ecs/transform/Transform.js +20 -8
  42. package/engine/graphics/ecs/animation/animator/AnimationClip.js +1 -1
  43. package/engine/graphics/ecs/animation/animator/AnimationNotification.js +1 -1
  44. package/engine/graphics/ecs/animation/animator/graph/AnimationGraph.js +1 -1
  45. package/engine/graphics/ecs/animation/animator/graph/definition/AnimationTransitionDefinition.js +1 -1
  46. package/engine/graphics/ecs/highlight/HighlightDefinition.js +1 -1
  47. package/engine/graphics/ecs/mesh/Mesh.js +1 -1
  48. package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +2 -2
  49. package/engine/graphics/ecs/mesh-v2/render/adapters/InstancedRendererAdapter.js +4 -1
  50. package/engine/graphics/geometry/MikkT/GenerateSharedVerticesIndexList.js +1 -1
  51. package/engine/graphics/micron/render/PatchCacheKey.js +1 -1
  52. package/engine/graphics/particles/particular/engine/emitter/ParticleLayer.js +1 -1
  53. package/engine/graphics/render/buffer/slot/parameter/ProgramValueSlotParameter.js +1 -1
  54. package/engine/intelligence/behavior/Behavior.js +2 -35
  55. package/engine/intelligence/behavior/selector/WeightedElement.js +1 -1
  56. package/engine/plugin/EnginePlugin.js +6 -0
  57. package/engine/sound/ecs/emitter/SoundEmitter.js +1 -1
  58. package/engine/sound/ecs/emitter/SoundTrack.js +1 -1
  59. package/engine/ui/bindings/{DomElementManager.js → DomElementProcessorManager.js} +43 -18
  60. package/package.json +1 -1
@@ -15,6 +15,11 @@ export default class Vector4 {
15
15
  z: number
16
16
  w: number
17
17
 
18
+ 0: number
19
+ 1: number
20
+ 2: number
21
+ 3: number
22
+
18
23
  public readonly onChanged: Signal<number, number, number, number, number, number, number, number>;
19
24
 
20
25
  constructor()
@@ -25,9 +30,9 @@ export default class Vector4 {
25
30
 
26
31
  copy(other: Vector4Like): void
27
32
 
28
- readFromArray(array:ArrayLike<number>, offset:number):void
33
+ readFromArray(array:ArrayLike<number>, offset?:number):void
29
34
 
30
- writeToArray(array:ArrayLike<number>, offset:number):void
35
+ writeToArray(array:ArrayLike<number>, offset?:number):void
31
36
 
32
37
  asArray(): number[]
33
38
 
@@ -6,7 +6,7 @@ import { assert } from "../assert.js";
6
6
  import { Signal } from "../events/signal/Signal.js";
7
7
  import { lerp } from "../math/lerp.js";
8
8
  import { computeHashIntegerArray } from "../collection/array/computeHashIntegerArray.js";
9
- import { computeHashFloat } from "../math/hash/computeHashFloat.js";
9
+ import { computeHashFloat } from "../primitives/numbers/computeHashFloat.js";
10
10
 
11
11
  /**
12
12
  *
@@ -105,11 +105,11 @@ class Vector4 {
105
105
  * @constructor
106
106
  * @class
107
107
  */
108
- constructor(x, y, z, w) {
109
- this.x = (typeof x === "number") ? x : 0;
110
- this.y = (typeof x === "number") ? y : 0;
111
- this.z = (typeof z === "number") ? z : 0;
112
- this.w = (typeof w === "number") ? w : 1;
108
+ constructor(x = 0, y = 0, z = 0, w = 0) {
109
+ this.x = x;
110
+ this.y = y;
111
+ this.z = z;
112
+ this.w = w;
113
113
 
114
114
  this.onChanged = new Signal();
115
115
  }
@@ -135,7 +135,7 @@ class Vector4 {
135
135
  * @param {number[]} array
136
136
  * @param {number} offset
137
137
  */
138
- readFromArray(array, offset) {
138
+ readFromArray(array, offset = 0) {
139
139
  this.set(
140
140
  array[offset],
141
141
  array[offset + 1],
@@ -149,7 +149,7 @@ class Vector4 {
149
149
  * @param {number[]} array
150
150
  * @param {number} offset
151
151
  */
152
- writeToArray(array, offset) {
152
+ writeToArray(array, offset = 0) {
153
153
  array[offset] = this.x;
154
154
  array[offset + 1] = this.y;
155
155
  array[offset + 2] = this.z;
@@ -1,4 +1,4 @@
1
- import { computeHashFloat } from "./computeHashFloat.js";
1
+ import { computeHashFloat } from "../../primitives/numbers/computeHashFloat.js";
2
2
 
3
3
  /**
4
4
  *
@@ -1,5 +1,5 @@
1
1
  import { computeStringHash } from "../../primitives/strings/computeStringHash.js";
2
- import { computeHashFloat } from "./computeHashFloat.js";
2
+ import { computeHashFloat } from "../../primitives/numbers/computeHashFloat.js";
3
3
 
4
4
  /**
5
5
  * Recursively computes object hash
@@ -18,37 +18,37 @@ export function computeObjectHash(value, depth = 3) {
18
18
 
19
19
  let hash = 0;
20
20
 
21
- for (let p in value) {
21
+ const pType = typeof value;
22
22
 
23
- hash = ((hash << 5) - hash) + computeStringHash(p);
23
+ if (pType === "string") {
24
+ hash = computeStringHash(value);
25
+ } else if (pType === "number") {
26
+ hash = computeHashFloat(value);
27
+ } else if (pType === "boolean") {
28
+ hash = value ? 1 : 0;
29
+ } else if (pType === "object") {
24
30
 
25
- const pValue = value[p];
31
+ if (depth <= 0) {
32
+ hash = 3;
33
+ } else {
34
+
35
+ for (let p in value) {
36
+
37
+ const pNameHash = computeStringHash(p);
38
+
39
+ const pValue = value[p];
26
40
 
27
- const pType = typeof pValue;
41
+ const pHash = pNameHash ^ computeObjectHash(pValue, depth - 1);
28
42
 
29
- let pHash;
30
- if (pType === "string") {
31
- pHash = computeStringHash(pValue);
32
- } else if (pType === "number") {
33
- pHash = computeHashFloat(pValue);
34
- } else if (pType === "boolean") {
35
- pHash = pValue ? 1 : 0;
36
- } else if (pType === "object") {
43
+ hash = ((hash << 5) - hash) + pHash;
37
44
 
38
- if (depth <= 0) {
39
- pHash = 3;
40
- } else {
41
- pHash = computeObjectHash(pValue, depth - 1);
45
+ hash |= 0; // Convert to 32bit integer
42
46
  }
43
47
 
44
- } else {
45
- pHash = 0;
46
48
  }
47
49
 
48
- hash = ((hash << 5) - hash) + pHash;
49
-
50
- hash |= 0; // Convert to 32bit integer
51
50
  }
52
51
 
52
+
53
53
  return hash;
54
54
  }
@@ -0,0 +1,42 @@
1
+ import { computeObjectHash } from "./computeObjectHash.js";
2
+
3
+ /**
4
+ *
5
+ * @param {number} hash
6
+ */
7
+ function validateHash(hash){
8
+ expect(typeof hash).toBe('number');
9
+ expect(hash).not.toBeNaN();
10
+ expect(Number.isFinite(hash)).toBe(true);
11
+ expect(Number.isInteger(hash)).toBe(true);
12
+ }
13
+
14
+ test('primitives produce valid hash',()=>{
15
+ validateHash( computeObjectHash(undefined));
16
+ validateHash( computeObjectHash(null));
17
+ validateHash( computeObjectHash(0));
18
+ validateHash( computeObjectHash(1));
19
+ validateHash( computeObjectHash(""));
20
+ validateHash( computeObjectHash("hello"));
21
+ validateHash( computeObjectHash(false));
22
+ validateHash( computeObjectHash(true));
23
+ validateHash( computeObjectHash({}));
24
+ });
25
+
26
+ test('nested object hash is stable',()=>{
27
+ const test_object = {
28
+ a:{
29
+ b:7
30
+ },
31
+ c: "hello"
32
+ };
33
+
34
+ expect(computeObjectHash(test_object)).toEqual(computeObjectHash(test_object));
35
+
36
+ expect(computeObjectHash(test_object)).not.toEqual(computeObjectHash({
37
+ a:{
38
+ b:5
39
+ },
40
+ c: "hello"
41
+ }));
42
+ });
@@ -7,7 +7,7 @@
7
7
  import { assert } from "../../assert.js";
8
8
  import Signal from "../../events/signal/Signal.js";
9
9
  import { inverseLerp } from "../inverseLerp.js";
10
- import { computeHashFloat } from "../hash/computeHashFloat.js";
10
+ import { computeHashFloat } from "../../primitives/numbers/computeHashFloat.js";
11
11
 
12
12
  export class NumericInterval {
13
13
  /**
@@ -5,7 +5,7 @@
5
5
 
6
6
  import Signal from "../events/signal/Signal.js";
7
7
  import { inverseLerp } from "../math/inverseLerp.js";
8
- import { computeHashFloat } from "../math/hash/computeHashFloat.js";
8
+ import { computeHashFloat } from "../primitives/numbers/computeHashFloat.js";
9
9
 
10
10
  /**
11
11
  *
@@ -65,8 +65,8 @@ export class Connection {
65
65
  * @param {NodeInstancePortReference} endpoint
66
66
  */
67
67
  setSource(endpoint) {
68
- assert.notEqual(endpoint, undefined, 'endpoint is undefined');
69
- assert.notEqual(endpoint, null, 'endpoint is null');
68
+ assert.defined(endpoint, 'endpoint');
69
+ assert.notNull(endpoint, 'endpoint');
70
70
 
71
71
  this.source = endpoint;
72
72
  }
@@ -76,8 +76,8 @@ export class Connection {
76
76
  * @param {NodeInstancePortReference} endpoint
77
77
  */
78
78
  setTarget(endpoint) {
79
- assert.notEqual(endpoint, undefined, 'endpoint is undefined');
80
- assert.notEqual(endpoint, null, 'endpoint is null');
79
+ assert.defined(endpoint, 'endpoint');
80
+ assert.notNull(endpoint, 'endpoint');
81
81
 
82
82
  this.target = endpoint;
83
83
  }
@@ -88,8 +88,8 @@ export class Connection {
88
88
  * @returns {boolean}
89
89
  */
90
90
  isAttachedToNode(id) {
91
- assert.typeOf(id, 'number', 'id');
92
- assert.ok(Number.isInteger(id), `id must be an integer, instead was '${id}'`);
91
+ assert.isNumber(id, 'id');
92
+ assert.isInteger(id, 'id');
93
93
 
94
94
  return this.source.instance.id === id || this.target.instance.id === id;
95
95
  }
@@ -25,18 +25,19 @@ export class DataType {
25
25
  equals(other) {
26
26
  return this.id === other.id && this.name === other.name;
27
27
  }
28
- }
29
28
 
30
- /**
31
- *
32
- * @param {number} id
33
- * @param {string} name
34
- */
35
- DataType.from = function (id, name) {
36
- const r = new DataType();
29
+ /**
30
+ *
31
+ * @param {number} id
32
+ * @param {string} name
33
+ * @returns {DataType}
34
+ */
35
+ static from(id, name) {
36
+ const r = new DataType();
37
37
 
38
- r.id = id;
39
- r.name = name;
38
+ r.id = id;
39
+ r.name = name;
40
40
 
41
- return r;
42
- };
41
+ return r;
42
+ }
43
+ }
@@ -62,19 +62,43 @@ export class NodeGraph {
62
62
  /**
63
63
  *
64
64
  * @param {number} id
65
- * @returns {NodeInstance}
65
+ * @returns {NodeInstance|undefined}
66
66
  */
67
67
  getNode(id) {
68
- return this.nodes.find(node => node.id === id);
68
+ const nodes = this.nodes;
69
+ const n = nodes.length;
70
+
71
+ for (let i = 0; i < n; i++) {
72
+ const node = nodes[i];
73
+
74
+ if (node.id === id) {
75
+ return node;
76
+ }
77
+ }
78
+
79
+ // node not found, return undefined
80
+ return undefined;
69
81
  }
70
82
 
71
83
  /**
72
84
  *
73
85
  * @param {number} id
74
- * @returns {Connection}
86
+ * @returns {Connection|undefined}
75
87
  */
76
88
  getConnection(id) {
77
- return this.connections.find(connection => connection.id === id);
89
+ const connections = this.connections;
90
+ const n = connections.length;
91
+
92
+ for (let i = 0; i < n; i++) {
93
+ const connection = connections[i];
94
+
95
+ if (connection.id === id) {
96
+ return connection;
97
+ }
98
+ }
99
+
100
+ // nothing found, undefined will be returned
101
+ return undefined;
78
102
  }
79
103
 
80
104
  /**
@@ -123,7 +147,7 @@ export class NodeGraph {
123
147
 
124
148
  const id_obtained = this.__idpNodes.getSpecific(node.id);
125
149
 
126
- if (!id_obtained) {
150
+ if (id_obtained === false) {
127
151
  throw new Error(`Node with id '${node.id}' already exists`);
128
152
  }
129
153
 
@@ -241,6 +265,7 @@ export class NodeGraph {
241
265
  *
242
266
  * @param {number} id
243
267
  * @param {number[]} result IDs of attached connections
268
+ * @returns {number} number of found connections
244
269
  */
245
270
  getConnectionsAttachedToNode(id, result) {
246
271
  let count = 0;
@@ -1,5 +1,4 @@
1
1
  import { assert } from "../../../assert.js";
2
- import { BitSet } from "../../../binary/BitSet.js";
3
2
  import { NodeParameterDataType } from "./parameter/NodeParameterDataType.js";
4
3
  import { NodeParameterDescription } from "./parameter/NodeParameterDescription.js";
5
4
  import { Port } from "./Port.js";
@@ -11,17 +10,22 @@ import { Port } from "./Port.js";
11
10
  * @returns {number}
12
11
  */
13
12
  function pickNewSetId(things) {
14
- const ids = new BitSet();
15
13
 
16
- things.forEach((v, id) => ids.set(id, true));
17
14
 
18
- const id = ids.nextClearBit(0);
15
+ const n = things.length;
16
+
17
+ let r = n;
18
+
19
+ for (let i = 0; i < n; i++) {
20
+
21
+ if (things[i] === undefined) {
22
+ r = i;
23
+ break;
24
+ }
19
25
 
20
- if (id === -1) {
21
- return 0;
22
- } else {
23
- return id;
24
26
  }
27
+
28
+ return r;
25
29
  }
26
30
 
27
31
  export class NodeDescription {
@@ -61,15 +65,14 @@ export class NodeDescription {
61
65
  createParameter(name, type, defaultValue) {
62
66
 
63
67
  assert.typeOf(name, 'string', 'name');
64
- assert.ok(Object.values(NodeParameterDataType).includes(type), `Unknown type '${type}'`);
68
+ assert.enum(type, NodeParameterDataType, 'type');
65
69
 
66
70
 
67
71
  //if default value is not given, pick one
68
72
  if (defaultValue === undefined) {
69
73
  switch (type) {
70
- case NodeParameterDataType.Integer:
71
74
  //intended fallthrough
72
- case NodeParameterDataType.Float:
75
+ case NodeParameterDataType.Number:
73
76
  defaultValue = 0;
74
77
  break;
75
78
  case NodeParameterDataType.Boolean:
@@ -0,0 +1,14 @@
1
+ import { NodeDescription } from "./NodeDescription.js";
2
+ import { DataType } from "../DataType.js";
3
+ import { PortDirection } from "./PortDirection.js";
4
+
5
+ const DUMMY_TYPE = DataType.from(0, 'dummy');
6
+
7
+ test('ports are assigned unique IDs', () => {
8
+ const node = new NodeDescription();
9
+
10
+ const id_a = node.createPort(DUMMY_TYPE, 'a', PortDirection.Unspecified);
11
+ const id_b = node.createPort(DUMMY_TYPE, 'b', PortDirection.Unspecified);
12
+
13
+ expect(id_a).not.toEqual(id_b);
14
+ });
@@ -148,8 +148,8 @@ export class NodeInstance {
148
148
 
149
149
  /**
150
150
  *
151
- * @param {number} port Port Id
152
- * @returns {ConnectionEndpoint|null}
151
+ * @param {number} port Port ID
152
+ * @returns {NodeInstancePortReference|null}
153
153
  */
154
154
  getEndpoint(port) {
155
155
  const endpoints = this.endpoints;
@@ -5,7 +5,7 @@ export class NodeParameterDescription {
5
5
  constructor() {
6
6
  this.name = "";
7
7
  this.id = 0;
8
- this.type = NodeParameterDataType.Float;
8
+ this.type = NodeParameterDataType.Number;
9
9
 
10
10
  /**
11
11
  *
@@ -2,7 +2,7 @@ import { assert } from "../../../../assert.js";
2
2
  import Signal from "../../../../events/signal/Signal.js";
3
3
  import DataType from "../../../../parser/simple/DataType.js";
4
4
  import { ReactiveExpression } from "../ReactiveExpression.js";
5
- import { computeHashFloat } from "../../../../math/hash/computeHashFloat.js";
5
+ import { computeHashFloat } from "../../../../primitives/numbers/computeHashFloat.js";
6
6
 
7
7
  const dummySignal = new Signal();
8
8
 
@@ -1,5 +1,5 @@
1
1
  import { assert } from "../../assert.js";
2
- import { computeHashFloat } from "../../math/hash/computeHashFloat.js";
2
+ import { computeHashFloat } from "../../primitives/numbers/computeHashFloat.js";
3
3
 
4
4
 
5
5
  /**
@@ -18,7 +18,7 @@ export interface IEngineInitializationOptions {
18
18
  export default class Engine {
19
19
  constructor(platform: EnginePlatform, options?: IEngineInitializationOptions);
20
20
 
21
- public get viewStack(): View
21
+ readonly viewStack: View
22
22
 
23
23
  public readonly entityManager: EntityManager
24
24
  public readonly sceneManager: SceneManager
@@ -2,7 +2,7 @@ import { planeHash } from "./planeHash.js";
2
2
  import { computeStringHash } from "../../../../core/primitives/strings/computeStringHash.js";
3
3
  import { computeHashArray } from "../../../../core/collection/array/computeHashArray.js";
4
4
  import { computeHashIntegerArray } from "../../../../core/collection/array/computeHashIntegerArray.js";
5
- import { computeHashFloat } from "../../../../core/math/hash/computeHashFloat.js";
5
+ import { computeHashFloat } from "../../../../core/primitives/numbers/computeHashFloat.js";
6
6
  import { textureHashById } from "./textureHashById.js";
7
7
  import { computeHashColor } from "./computeHashColor.js";
8
8
 
@@ -1,6 +1,6 @@
1
1
  import { computeImageBitmapHash } from "./computeImageBitmapHash.js";
2
2
  import { computeHashIntegerArray } from "../../../../core/collection/array/computeHashIntegerArray.js";
3
- import { computeHashFloat } from "../../../../core/math/hash/computeHashFloat.js";
3
+ import { computeHashFloat } from "../../../../core/primitives/numbers/computeHashFloat.js";
4
4
  import { murmur3_32 } from "../../../../core/math/hash/murmur3_32.js";
5
5
  import { computeStringHash } from "../../../../core/primitives/strings/computeStringHash.js";
6
6
 
@@ -9,7 +9,7 @@ import ObservedInteger from "../../../core/model/ObservedInteger.js";
9
9
  import Vector1 from "../../../core/geom/Vector1.js";
10
10
  import { BinaryClassSerializationAdapter } from "../storage/binary/BinaryClassSerializationAdapter.js";
11
11
  import { computeHashIntegerArray } from "../../../core/collection/array/computeHashIntegerArray.js";
12
- import { computeHashFloat } from "../../../core/math/hash/computeHashFloat.js";
12
+ import { computeHashFloat } from "../../../core/primitives/numbers/computeHashFloat.js";
13
13
 
14
14
  /**
15
15
  *
@@ -2,7 +2,7 @@ import { BinaryClassSerializationAdapter } from "../storage/binary/BinaryClassSe
2
2
  import { NumericInterval } from "../../../core/math/interval/NumericInterval.js";
3
3
  import { computeStringHash } from "../../../core/primitives/strings/computeStringHash.js";
4
4
  import { computeHashIntegerArray } from "../../../core/collection/array/computeHashIntegerArray.js";
5
- import { computeHashFloat } from "../../../core/math/hash/computeHashFloat.js";
5
+ import { computeHashFloat } from "../../../core/primitives/numbers/computeHashFloat.js";
6
6
 
7
7
  class IKConstraint {
8
8
  constructor() {
@@ -1,7 +1,7 @@
1
1
  import { AbstractActionDescription } from "./AbstractActionDescription.js";
2
2
  import { WeightedRandomBehavior } from "../../../../intelligence/behavior/selector/WeightedRandomBehavior.js";
3
3
  import { WeightedElement } from "../../../../intelligence/behavior/selector/WeightedElement.js";
4
- import { computeHashFloat } from "../../../../../core/math/hash/computeHashFloat.js";
4
+ import { computeHashFloat } from "../../../../../core/primitives/numbers/computeHashFloat.js";
5
5
 
6
6
  export class WeightedRandomActionDescription extends AbstractActionDescription {
7
7
  constructor() {
@@ -6,7 +6,7 @@ import Vector2 from "../../../../core/geom/Vector2.js";
6
6
  import ObservedBoolean from "../../../../core/model/ObservedBoolean.js";
7
7
  import { BinaryClassSerializationAdapter } from "../../storage/binary/BinaryClassSerializationAdapter.js";
8
8
  import { computeHashIntegerArray } from "../../../../core/collection/array/computeHashIntegerArray.js";
9
- import { computeHashFloat } from "../../../../core/math/hash/computeHashFloat.js";
9
+ import { computeHashFloat } from "../../../../core/primitives/numbers/computeHashFloat.js";
10
10
 
11
11
  /**
12
12
  * @readonly
@@ -28,33 +28,35 @@ export class Transform {
28
28
  constructor() {
29
29
 
30
30
  /**
31
- *
31
+ * World-space position
32
32
  * @type {Vector3}
33
33
  * @readonly
34
34
  */
35
35
  this.position = new Vector3(0, 0, 0);
36
36
 
37
37
  /**
38
- *
38
+ * World-space rotation
39
39
  * @type {Quaternion}
40
40
  * @readonly
41
41
  */
42
42
  this.rotation = new Quaternion(0, 0, 0, 1);
43
43
 
44
44
  /**
45
- *
45
+ * World-space scale
46
46
  * @type {Vector3}
47
47
  * @readonly
48
48
  */
49
49
  this.scale = new Vector3(1, 1, 1);
50
50
 
51
51
  /**
52
+ * World-space transform matrix, position, rotation and scale must match, but shear can be different
52
53
  * @readonly
53
54
  * @type {Float32Array}
54
55
  */
55
56
  this.matrix = allocate_transform_m4();
56
57
 
57
58
  /**
59
+ * Various bit flags, see {@link TransformFlags}
58
60
  * @protected
59
61
  * @type {number}
60
62
  */
@@ -136,7 +138,6 @@ export class Transform {
136
138
  return (this.flags & flag) === flag;
137
139
  }
138
140
 
139
-
140
141
  updateMatrix() {
141
142
  compose_matrix4_array(this.matrix, this.position, this.rotation, this.scale);
142
143
  }
@@ -275,7 +276,7 @@ export class Transform {
275
276
  }
276
277
 
277
278
  /**
278
- *
279
+ * @deprecated use `fromMatrix4` directly instead
279
280
  * @param {THREE.Matrix4} matrix
280
281
  */
281
282
  fromThreeMatrix4(matrix) {
@@ -283,7 +284,7 @@ export class Transform {
283
284
  }
284
285
 
285
286
  /**
286
- *
287
+ * @deprecated use `toMatrix4` directly instead
287
288
  * @param {Matrix4} matrix
288
289
  */
289
290
  toThreeMatrix(matrix) {
@@ -314,6 +315,12 @@ export class Transform {
314
315
  compose_matrix4_array(result, this.position, this.rotation, this.scale);
315
316
  }
316
317
 
318
+ /**
319
+ * reset transform, resulting transform is an identity matrix
320
+ * - position: [0,0,0]
321
+ * - rotation: [0,0,0,1]
322
+ * - scale: [1,1,1]
323
+ */
317
324
  makeIdentity() {
318
325
  this.position.copy(Vector3.zero);
319
326
  this.rotation.copy(Quaternion.identity);
@@ -335,11 +342,16 @@ Transform.prototype.isTransform = true;
335
342
 
336
343
 
337
344
  /**
345
+ * @deprecated use {@link Quaternion.rotateTowards} instead
338
346
  * @param {Quaternion} sourceQuaternion
339
347
  * @param {Vector3} targetVector
340
348
  * @param {Number} limit
341
349
  */
342
- Transform.adjustRotation = function (sourceQuaternion, targetVector, limit) {
343
- sourceQuaternion.lookRotation(targetVector, Vector3.up);
350
+ Transform.adjustRotation = function (sourceQuaternion, targetVector, limit = Infinity) {
351
+ const q = new Quaternion();
352
+
353
+ q.lookRotation(targetVector);
354
+
355
+ sourceQuaternion.rotateTowards(q, limit);
344
356
  };
345
357
 
@@ -3,7 +3,7 @@ import { AnimationClipFlag } from "./AnimationClipFlag.js";
3
3
  import { LoopOnce, LoopRepeat } from "three";
4
4
  import { AnimationEventTypes } from "./AnimationEventTypes.js";
5
5
  import { computeHashIntegerArray } from "../../../../../core/collection/array/computeHashIntegerArray.js";
6
- import { computeHashFloat } from "../../../../../core/math/hash/computeHashFloat.js";
6
+ import { computeHashFloat } from "../../../../../core/primitives/numbers/computeHashFloat.js";
7
7
 
8
8
  export class AnimationClip {
9
9
  constructor() {
@@ -1,5 +1,5 @@
1
1
  import { computeHashIntegerArray } from "../../../../../core/collection/array/computeHashIntegerArray.js";
2
- import { computeHashFloat } from "../../../../../core/math/hash/computeHashFloat.js";
2
+ import { computeHashFloat } from "../../../../../core/primitives/numbers/computeHashFloat.js";
3
3
 
4
4
  export class AnimationNotification {
5
5
  constructor() {
@@ -10,7 +10,7 @@ import {
10
10
  import { assert } from "../../../../../../core/assert.js";
11
11
  import { threeUpdateTransform } from "../../../../util/threeUpdateTransform.js";
12
12
  import { computeHashIntegerArray } from "../../../../../../core/collection/array/computeHashIntegerArray.js";
13
- import { computeHashFloat } from "../../../../../../core/math/hash/computeHashFloat.js";
13
+ import { computeHashFloat } from "../../../../../../core/primitives/numbers/computeHashFloat.js";
14
14
 
15
15
  export class AnimationGraph {
16
16
  constructor() {
@@ -1,6 +1,6 @@
1
1
  import { computeStringHash } from "../../../../../../../core/primitives/strings/computeStringHash.js";
2
2
  import { computeHashIntegerArray } from "../../../../../../../core/collection/array/computeHashIntegerArray.js";
3
- import { computeHashFloat } from "../../../../../../../core/math/hash/computeHashFloat.js";
3
+ import { computeHashFloat } from "../../../../../../../core/primitives/numbers/computeHashFloat.js";
4
4
 
5
5
  export class AnimationTransitionDefinition {
6
6
  constructor() {