@woosh/meep-engine 2.47.42 → 2.48.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.
Files changed (91) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/build/meep.cjs +44161 -44112
  3. package/build/meep.min.js +1 -1
  4. package/build/meep.module.js +44162 -44112
  5. package/editor/ecs/component/editors/ecs/ParticleEmitterLayerEditor.js +3 -3
  6. package/editor/view/node-graph/NodeGraphView.js +1 -1
  7. package/package.json +1 -1
  8. package/samples/terrain/editor.js +4 -4
  9. package/src/core/{collection/table/DataType.js → binary/type/BinaryDataType.js} +1 -1
  10. package/src/core/binary/type/DataType2TypedArrayConstructorMapping.js +34 -0
  11. package/src/core/binary/type/DataTypeByteSizes.js +37 -0
  12. package/src/core/binary/type/DataTypeIndices.js +17 -0
  13. package/src/core/{collection/table → binary/type}/computeDataTypeByIndex.js +1 -1
  14. package/src/core/binary/type/dataTypeFromTypedArray.js +31 -0
  15. package/src/core/collection/array/typedArrayToDataType.js +10 -10
  16. package/src/core/collection/table/RowFirstTable.js +1 -1
  17. package/src/core/collection/table/RowFirstTable.spec.js +16 -16
  18. package/src/core/collection/table/RowFirstTableSpec.js +9 -9
  19. package/src/core/collection/table/deserializeRowFirstTable.js +1 -1
  20. package/src/core/collection/table/serializeRowFirstTable.js +1 -1
  21. package/src/core/geom/3d/matrix/MATRIX_4_IDENTITY.js +2 -1
  22. package/src/core/geom/3d/matrix/m4_multiply.js +67 -0
  23. package/src/core/geom/Quaternion.js +0 -85
  24. package/src/core/graph/SquareMatrix.js +3 -3
  25. package/src/core/graph/SquareMatrix.spec.js +5 -5
  26. package/src/core/graph/eigen/eigen.spec.js +2 -2
  27. package/src/core/graph/graph_k_means_cluster.js +2 -2
  28. package/src/core/graph/graph_laplacian_matrix.js +3 -3
  29. package/src/core/model/node-graph/node/NodeDescription.js +1 -1
  30. package/src/engine/asset/loaders/GLTFAssetLoader.js +1 -1
  31. package/src/engine/ecs/foliage/InstancedFoliage.js +4 -4
  32. package/src/engine/ecs/fow/FogOfWar.js +4 -4
  33. package/src/engine/ecs/terrain/ecs/PromiseSamplerHeight.js +1 -1
  34. package/src/engine/ecs/transform/Transform.d.ts +2 -0
  35. package/src/engine/ecs/transform/Transform.js +51 -58
  36. package/src/engine/ecs/transform/Transform.spec.js +22 -0
  37. package/src/engine/graphics/ecs/light/binding/three/applyRotation.js +1 -1
  38. package/src/engine/graphics/ecs/mesh/applyTransformToThreeObject.js +3 -1
  39. package/src/engine/graphics/ecs/mesh-v2/allocate_transform_m4.js +3 -12
  40. package/src/engine/graphics/geometry/AttributeSpec.js +5 -5
  41. package/src/engine/graphics/material/optimization/MaterialOptimizationContext.js +8 -8
  42. package/src/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +4 -4
  43. package/src/engine/graphics/micron/build/compute_micron_buffer_array_constructor.js +7 -7
  44. package/src/engine/graphics/micron/build/fill_patch_geometry_data.js +6 -6
  45. package/src/engine/graphics/micron/build/hierarchy/merge_patches.js +4 -4
  46. package/src/engine/graphics/micron/format/micron_build_proxy_geometry.js +1 -1
  47. package/src/engine/graphics/micron/format/serialization/MicronGeometryBinarySerializationAdapter.spec.js +2 -2
  48. package/src/engine/graphics/micron/format/serialization/deserialize_attribute_spec.js +1 -1
  49. package/src/engine/graphics/micron/format/serialization/deserialize_patch.js +2 -2
  50. package/src/engine/graphics/micron/format/serialization/serialize_attribute_spec.js +1 -1
  51. package/src/engine/graphics/micron/format/serialization/serialize_patch.js +1 -1
  52. package/src/engine/graphics/micron/render/instanced/AttributeDataTexture.js +1 -1
  53. package/src/engine/graphics/micron/render/instanced/shader/shader_rewrite_standard.js +2 -2
  54. package/src/engine/graphics/micron/render/v1/ThreeVirtualGeometryAdapter.js +1 -1
  55. package/src/engine/graphics/particles/node-based/codegen/modules/FunctionParameterSpecification.js +2 -2
  56. package/src/engine/graphics/particles/node-based/codegen/modules/FunctionSignature.js +2 -2
  57. package/src/engine/graphics/particles/particular/engine/MovingBoundingBox.js +4 -4
  58. package/src/engine/graphics/particles/particular/engine/emitter/PARTICULAR_PARTICLE_SPECIFICATION.js +13 -13
  59. package/src/engine/graphics/particles/particular/engine/emitter/ParticlePool.js +1 -1
  60. package/src/engine/graphics/particles/particular/engine/emitter/ParticlePool.spec.js +3 -3
  61. package/src/engine/graphics/particles/particular/engine/renderers/billboard/BILLBOARD_PARTICLE_SPECIFICATION.js +8 -8
  62. package/src/engine/graphics/particles/particular/engine/utils/volume/AttributeValue.js +1 -1
  63. package/src/engine/graphics/render/forward_plus/LightManager.js +1 -1
  64. package/src/engine/graphics/render/forward_plus/data/TextureBackedMemoryRegion.js +5 -5
  65. package/src/engine/graphics/render/forward_plus/data/computeDataType.js +10 -10
  66. package/src/engine/graphics/render/forward_plus/data/computeThreeTextureInternalFormatFromDataType.js +11 -11
  67. package/src/engine/graphics/render/forward_plus/data/computeThreeTextureTypeFromDataType.js +11 -11
  68. package/src/engine/graphics/render/frame_graph/TextureDescriptor.js +4 -4
  69. package/src/engine/graphics/render/frame_graph/sample/meep-v1/ColorDepthPass.js +3 -3
  70. package/src/engine/graphics/texture/atlas/TextureAtlas.js +5 -5
  71. package/src/engine/graphics/texture/normalized_internal_format.js +5 -5
  72. package/src/engine/graphics/texture/sampler/Sampler2D.js +25 -51
  73. package/src/engine/graphics/texture/sampler/sampler2DToFloat32Texture.js +2 -2
  74. package/src/engine/graphics/texture/sampler/sampler2d_compute_texel_value_conversion_scale_to_uint8.js +3 -3
  75. package/src/engine/graphics/texture/sampler/{TextureBinaryBufferSerializer.js → serialization/TextureBinaryBufferSerializer.js} +17 -46
  76. package/src/engine/graphics/texture/sampler/{TextureBinaryBufferSerializer.spec.js → serialization/TextureBinaryBufferSerializer.spec.js} +2 -2
  77. package/src/engine/graphics/trail/TemporalPath.js +3 -3
  78. package/src/engine/graphics/trail/x/ribbon_attributes_spec.js +18 -18
  79. package/src/engine/navigation/ecs/components/Path.js +5 -5
  80. package/src/generation/example/grid/configureMirGrid.js +6 -6
  81. package/src/generation/filtering/numeric/process/computeCellFilterGradient.spec.js +10 -10
  82. package/src/generation/grid/layers/GridDataLayer.js +4 -4
  83. package/src/generation/placement/action/GridCellActionPlaceTags.spec.js +2 -2
  84. package/src/generation/rules/CellMatcherContainsTag.spec.js +2 -2
  85. package/src/generation/rules/cell/GridPatternMatcher.spec.js +8 -8
  86. package/src/view/elements/image/HTMLElementCacheKey.js +111 -2
  87. package/src/view/elements/image/ImageView.js +1 -1
  88. package/src/view/elements/video/VideoView.js +1 -1
  89. package/src/core/collection/table/DataType2TypedArrayConstructorMapping.js +0 -34
  90. package/src/core/collection/table/DataTypeByteSizes.js +0 -37
  91. package/src/core/collection/table/DataTypeIndices.js +0 -17
@@ -3,7 +3,6 @@
3
3
  */
4
4
 
5
5
 
6
- import { Matrix4 as ThreeMatrix4 } from "three";
7
6
  import { assert } from "../assert.js";
8
7
  import Signal from "../events/signal/Signal.js";
9
8
  import { clamp } from "../math/clamp.js";
@@ -15,82 +14,11 @@ import { computeHashFloat } from "../primitives/numbers/computeHashFloat.js";
15
14
  import { epsilonEquals } from "../math/epsilonEquals.js";
16
15
  import { EPSILON } from "../math/EPSILON.js";
17
16
 
18
- const matrix = new ThreeMatrix4();
19
17
 
20
18
  const forward = new Vector3();
21
19
  const up = new Vector3();
22
20
  const right = new Vector3();
23
21
 
24
- /**
25
- *
26
- * @param {number[]|Float32Array} out
27
- * @param {number} fx
28
- * @param {number} fy
29
- * @param {number} fz
30
- * @param {number} ux
31
- * @param {number} uy
32
- * @param {number} uz
33
- */
34
- export function quat_array_from_look(out, fx, fy, fz, ux, uy, uz) {
35
- forward.set(fx, fy, fz);
36
- forward.normalize();
37
-
38
- right._crossVectors(ux, uy, uz, forward.x, forward.y, forward.z);
39
- right.normalize();
40
-
41
- up.crossVectors(forward, right);
42
-
43
- var m00 = right.x;
44
- var m01 = right.y;
45
- var m02 = right.z;
46
- var m10 = up.x;
47
- var m11 = up.y;
48
- var m12 = up.z;
49
- var m20 = forward.x;
50
- var m21 = forward.y;
51
- var m22 = forward.z;
52
-
53
-
54
- const num8 = (m00 + m11) + m22;
55
-
56
- let _x, _y, _z, _w;
57
-
58
- if (num8 > 0) {
59
- let num = Math.sqrt(num8 + 1);
60
- _w = num * 0.5;
61
- num = 0.5 / num;
62
- _x = (m12 - m21) * num;
63
- _y = (m20 - m02) * num;
64
- _z = (m01 - m10) * num;
65
- } else if ((m00 >= m11) && (m00 >= m22)) {
66
- var num7 = Math.sqrt(((1 + m00) - m11) - m22);
67
- var num4 = 0.5 / num7;
68
- _x = 0.5 * num7;
69
- _y = (m01 + m10) * num4;
70
- _z = (m02 + m20) * num4;
71
- _w = (m12 - m21) * num4;
72
- } else if (m11 > m22) {
73
- var num6 = Math.sqrt(((1 + m11) - m00) - m22);
74
- var num3 = 0.5 / num6;
75
- _x = (m10 + m01) * num3;
76
- _y = 0.5 * num6;
77
- _z = (m21 + m12) * num3;
78
- _w = (m20 - m02) * num3;
79
- } else {
80
- var num5 = Math.sqrt(((1 + m22) - m00) - m11);
81
- var num2 = 0.5 / num5;
82
- _x = (m20 + m02) * num2;
83
- _y = (m21 + m12) * num2;
84
- _z = 0.5 * num5;
85
- _w = (m01 - m10) * num2;
86
- }
87
-
88
- out[0] = _x;
89
- out[1] = _y;
90
- out[2] = _z;
91
- out[3] = _w;
92
- }
93
-
94
22
  /**
95
23
  * just in case you need that function also
96
24
  * @param {Vector3} axis
@@ -268,19 +196,6 @@ class Quaternion {
268
196
  this._lookRotation(vForward.x, vForward.y, vForward.z, vUp.x, vUp.y, vUp.z);
269
197
  }
270
198
 
271
- /**
272
- *
273
- * @param {Euler} euler
274
- * @return {void|Quaternion|Euler}
275
- * @private
276
- */
277
- __setThreeEuler(euler) {
278
-
279
- this.__setRotationMatrix(matrix.elements);
280
-
281
- return euler.setFromRotationMatrix(matrix);
282
- }
283
-
284
199
 
285
200
  /**
286
201
  *
@@ -1,11 +1,11 @@
1
- import { DataType2TypedArrayConstructorMapping } from "../collection/table/DataType2TypedArrayConstructorMapping.js";
1
+ import { DataType2TypedArrayConstructorMapping } from "../binary/type/DataType2TypedArrayConstructorMapping.js";
2
2
  import { assert } from "../assert.js";
3
3
 
4
4
  export class SquareMatrix {
5
5
  /**
6
6
  *
7
7
  * @param {number} size
8
- * @param {DataType|string} type
8
+ * @param {BinaryDataType|string} type
9
9
  */
10
10
  constructor(size, type) {
11
11
  const TypedArray = DataType2TypedArrayConstructorMapping[type];
@@ -22,7 +22,7 @@ export class SquareMatrix {
22
22
 
23
23
  /**
24
24
  *
25
- * @type {DataType}
25
+ * @type {BinaryDataType}
26
26
  */
27
27
  this.type = type;
28
28
 
@@ -1,8 +1,8 @@
1
1
  import { SquareMatrix } from "./SquareMatrix.js";
2
- import { DataType } from "../collection/table/DataType.js";
2
+ import { BinaryDataType } from "../binary/type/BinaryDataType.js";
3
3
 
4
4
  test('set/get cell', () => {
5
- const m = new SquareMatrix(2, DataType.Uint8);
5
+ const m = new SquareMatrix(2, BinaryDataType.Uint8);
6
6
 
7
7
  m.setCellValue(0, 0, 7);
8
8
  m.setCellValue(1, 0, 11);
@@ -17,7 +17,7 @@ test('set/get cell', () => {
17
17
 
18
18
 
19
19
  test('transpose', () => {
20
- const m = new SquareMatrix(2, DataType.Uint8);
20
+ const m = new SquareMatrix(2, BinaryDataType.Uint8);
21
21
 
22
22
  m.setCellValue(0, 0, 7);
23
23
  m.setCellValue(1, 0, 11);
@@ -34,14 +34,14 @@ test('transpose', () => {
34
34
 
35
35
 
36
36
  test('copy', ()=>{
37
- const m = new SquareMatrix(2, DataType.Uint8);
37
+ const m = new SquareMatrix(2, BinaryDataType.Uint8);
38
38
 
39
39
  m.setCellValue(0, 0, 7);
40
40
  m.setCellValue(1, 0, 11);
41
41
  m.setCellValue(0, 1, 13);
42
42
  m.setCellValue(1, 1, 19);
43
43
 
44
- const b = new SquareMatrix(2,DataType.Uint8);
44
+ const b = new SquareMatrix(2,BinaryDataType.Uint8);
45
45
 
46
46
  b.copy(m);
47
47
 
@@ -1,5 +1,5 @@
1
1
  import { SquareMatrix } from "../SquareMatrix.js";
2
- import { DataType } from "../../collection/table/DataType.js";
2
+ import { BinaryDataType } from "../../binary/type/BinaryDataType.js";
3
3
  import { matrix_eigenvalues_in_place } from "./eigen.js";
4
4
 
5
5
  function roughly_equal_array_vectors(actual, expected) {
@@ -13,7 +13,7 @@ function roughly_equal_array_vectors(actual, expected) {
13
13
  test("sample", () => {
14
14
 
15
15
 
16
- const t = new SquareMatrix(3, DataType.Float32);
16
+ const t = new SquareMatrix(3, BinaryDataType.Float32);
17
17
  t.fromArray([
18
18
  4, -6, 5,
19
19
  -6, 3, 4,
@@ -1,7 +1,7 @@
1
1
  //
2
2
  import { seededRandom } from "../math/random/seededRandom.js";
3
3
  import { SquareMatrix } from "./SquareMatrix.js";
4
- import { DataType } from "../collection/table/DataType.js";
4
+ import { BinaryDataType } from "../binary/type/BinaryDataType.js";
5
5
  import { BitSet } from "../binary/BitSet.js";
6
6
  import FastBinaryHeap from "../collection/heap/FastBinaryHeap.js";
7
7
  import { randomIntegerBetween } from "../math/random/randomIntegerBetween.js";
@@ -36,7 +36,7 @@ function node_distance(n0, n1, graph) {
36
36
  function build_distance_matrix(graph, node_array, targets, node_index_map) {
37
37
  const node_count = node_array.length;
38
38
 
39
- const m_distances = new SquareMatrix(node_count, DataType.Float32);
39
+ const m_distances = new SquareMatrix(node_count, BinaryDataType.Float32);
40
40
 
41
41
  const flags = BitSet.fixedSize(node_count);
42
42
 
@@ -1,6 +1,6 @@
1
1
  import { graph_degree_matrix } from "./graph_degree_matrix.js";
2
2
  import { SquareMatrix } from "./SquareMatrix.js";
3
- import { DataType } from "../collection/table/DataType.js";
3
+ import { BinaryDataType } from "../binary/type/BinaryDataType.js";
4
4
  import { graph_adjacency_matrix } from "./graph_adjacency_matrix.js";
5
5
 
6
6
  /**
@@ -12,8 +12,8 @@ import { graph_adjacency_matrix } from "./graph_adjacency_matrix.js";
12
12
  * @param {Map<T,number>} node_indices
13
13
  */
14
14
  export function graph_laplacian_matrix(graph, result, node_indices) {
15
- const degree = new SquareMatrix(result.size, DataType.Uint8);
16
- const adjacency = new SquareMatrix(result.size, DataType.Uint8);
15
+ const degree = new SquareMatrix(result.size, BinaryDataType.Uint8);
16
+ const adjacency = new SquareMatrix(result.size, BinaryDataType.Uint8);
17
17
 
18
18
  graph_degree_matrix(graph, degree, node_indices);
19
19
  graph_adjacency_matrix(graph, adjacency, node_indices);
@@ -183,7 +183,7 @@ export class NodeDescription {
183
183
 
184
184
  /**
185
185
  *
186
- * @param {DataType} type
186
+ * @param {BinaryDataType} type
187
187
  * @param {String} name
188
188
  * @param {PortDirection} direction
189
189
  */
@@ -80,7 +80,7 @@ function transferRootTransform(root, result) {
80
80
 
81
81
  // record transformation matrix on the root
82
82
  root.updateMatrix();
83
- result.fromThreeMatrix4(root.matrix);
83
+ result.fromMatrix4(root.matrix.elements);
84
84
 
85
85
  return true;
86
86
  }
@@ -4,7 +4,7 @@ import { LeafNode } from "../../../core/bvh2/LeafNode.js";
4
4
  import Vector4 from "../../../core/geom/Vector4.js";
5
5
 
6
6
  import { BufferGeometry } from 'three';
7
- import { DataType } from "../../../core/collection/table/DataType.js";
7
+ import { BinaryDataType } from "../../../core/binary/type/BinaryDataType.js";
8
8
  import { RowFirstTableSpec } from "../../../core/collection/table/RowFirstTableSpec.js";
9
9
  import {
10
10
  serializeBinaryNodeToBinaryBuffer
@@ -26,9 +26,9 @@ import { compose_matrix4_array } from "../../../core/geom/3d/compose_matrix4_arr
26
26
  * @type {RowFirstTableSpec}
27
27
  */
28
28
  const dataSpec = new RowFirstTableSpec([
29
- DataType.Float32, DataType.Float32, DataType.Float32, //position
30
- DataType.Uint32, //rotation
31
- DataType.Float32, DataType.Float32, DataType.Float32 //scale
29
+ BinaryDataType.Float32, BinaryDataType.Float32, BinaryDataType.Float32, //position
30
+ BinaryDataType.Uint32, //rotation
31
+ BinaryDataType.Float32, BinaryDataType.Float32, BinaryDataType.Float32 //scale
32
32
  ]);
33
33
 
34
34
  export class InstancedFoliage {
@@ -11,7 +11,7 @@ import Vector4 from "../../../core/geom/Vector4.js";
11
11
  import Signal from "../../../core/events/signal/Signal.js";
12
12
  import { RowFirstTable } from "../../../core/collection/table/RowFirstTable.js";
13
13
  import { RowFirstTableSpec } from "../../../core/collection/table/RowFirstTableSpec.js";
14
- import { DataType } from "../../../core/collection/table/DataType.js";
14
+ import { BinaryDataType } from "../../../core/binary/type/BinaryDataType.js";
15
15
  import { writeSample2DDataToDataTexture } from "../../graphics/texture/sampler/writeSampler2DDataToDataTexture.js";
16
16
 
17
17
  const samplePosition = [];
@@ -38,9 +38,9 @@ const INITIAL_FADE_VALUE = 254;
38
38
  * @type {RowFirstTableSpec}
39
39
  */
40
40
  const revealMaskTableSpec = new RowFirstTableSpec([
41
- DataType.Int32, // Index
42
- DataType.Float32, // Precise current value
43
- DataType.Float32 // Fade speed
41
+ BinaryDataType.Int32, // Index
42
+ BinaryDataType.Float32, // Precise current value
43
+ BinaryDataType.Float32 // Fade speed
44
44
  ]);
45
45
 
46
46
  const fadeRow = [];
@@ -1,5 +1,5 @@
1
1
  import { BinaryBuffer } from "../../../../core/binary/BinaryBuffer.js";
2
- import { deserializeTexture } from "../../../graphics/texture/sampler/TextureBinaryBufferSerializer.js";
2
+ import { deserializeTexture } from "../../../graphics/texture/sampler/serialization/TextureBinaryBufferSerializer.js";
3
3
  import { Sampler2D } from "../../../graphics/texture/sampler/Sampler2D.js";
4
4
  import { GameAssetType } from "../../../asset/GameAssetType.js";
5
5
  import rgbaData2valueSampler2D from "../../../graphics/texture/sampler/rgbaData2valueSampler2D.js";
@@ -6,6 +6,8 @@ export class Transform {
6
6
  public readonly rotation: Quaternion
7
7
  public readonly scale: Vector3
8
8
 
9
+ public readonly matrix:ArrayLike<number>
10
+
9
11
  public lookAt(target: Vector3): void
10
12
 
11
13
  static fromJSON(json: {
@@ -5,63 +5,69 @@
5
5
  import Vector3 from "../../../core/geom/Vector3.js";
6
6
  import Quaternion from "../../../core/geom/Quaternion.js";
7
7
  import { decompose_matrix_4_array } from "../../../core/geom/3d/decompose_matrix_4_array.js";
8
- import { mat4 } from "gl-matrix";
9
8
  import { compose_matrix4_array } from "../../../core/geom/3d/compose_matrix4_array.js";
10
9
  import { TransformFlags } from "./TransformFlags.js";
11
10
  import { allocate_transform_m4 } from "../../graphics/ecs/mesh-v2/allocate_transform_m4.js";
12
11
  import { assert } from "../../../core/assert.js";
12
+ import { m4_multiply } from "../../../core/geom/3d/matrix/m4_multiply.js";
13
13
 
14
- const scratch_buffer = new ArrayBuffer(16 * 4);
15
-
16
- const m4_0 = new Float32Array(scratch_buffer, 0, 16);
14
+ /**
15
+ *
16
+ * @type {Float32Array}
17
+ */
18
+ const scratch_matrix = new Float32Array(16);
17
19
 
20
+ /**
21
+ * Default set of flags for any {@link Transform}
22
+ * @type {TransformFlags|number}
23
+ */
18
24
  const FLAGS_DEFAULT = TransformFlags.AutomaticChangeDetection;
19
25
 
20
26
  /**
21
27
  * @class
22
28
  */
23
29
  export class Transform {
30
+
31
+ /**
32
+ * World-space position
33
+ * @type {Vector3}
34
+ * @readonly
35
+ */
36
+ position = new Vector3(0, 0, 0);
37
+
38
+ /**
39
+ * World-space rotation
40
+ * @type {Quaternion}
41
+ * @readonly
42
+ */
43
+ rotation = new Quaternion(0, 0, 0, 1);
44
+
45
+ /**
46
+ * World-space scale
47
+ * @type {Vector3}
48
+ * @readonly
49
+ */
50
+ scale = new Vector3(1, 1, 1);
51
+
52
+ /**
53
+ * World-space transform matrix, position, rotation and scale must match, but shear can be different
54
+ * @readonly
55
+ * @type {Float32Array}
56
+ */
57
+ matrix = allocate_transform_m4();
58
+
59
+ /**
60
+ * Various bit flags, see {@link TransformFlags}
61
+ * @protected
62
+ * @type {number}
63
+ */
64
+ flags = FLAGS_DEFAULT;
65
+
24
66
  /**
25
67
  *
26
68
  * @constructor
27
69
  */
28
70
  constructor() {
29
-
30
- /**
31
- * World-space position
32
- * @type {Vector3}
33
- * @readonly
34
- */
35
- this.position = new Vector3(0, 0, 0);
36
-
37
- /**
38
- * World-space rotation
39
- * @type {Quaternion}
40
- * @readonly
41
- */
42
- this.rotation = new Quaternion(0, 0, 0, 1);
43
-
44
- /**
45
- * World-space scale
46
- * @type {Vector3}
47
- * @readonly
48
- */
49
- this.scale = new Vector3(1, 1, 1);
50
-
51
- /**
52
- * World-space transform matrix, position, rotation and scale must match, but shear can be different
53
- * @readonly
54
- * @type {Float32Array}
55
- */
56
- this.matrix = allocate_transform_m4();
57
-
58
- /**
59
- * Various bit flags, see {@link TransformFlags}
60
- * @protected
61
- * @type {number}
62
- */
63
- this.flags = FLAGS_DEFAULT;
64
-
65
71
  // watch changes
66
72
  this.subscribeAllChanges(this.__handle_component_change, this);
67
73
  }
@@ -138,6 +144,9 @@ export class Transform {
138
144
  return (this.flags & flag) === flag;
139
145
  }
140
146
 
147
+ /**
148
+ * Update {@link matrix} attribute from current position/rotation/scale
149
+ */
141
150
  updateMatrix() {
142
151
  compose_matrix4_array(this.matrix, this.position, this.rotation, this.scale);
143
152
  }
@@ -270,25 +279,9 @@ export class Transform {
270
279
  * @param {Transform} b
271
280
  */
272
281
  multiplyTransforms(a, b) {
273
- mat4.multiply(m4_0, a.matrix, b.matrix);
282
+ m4_multiply(scratch_matrix, a.matrix, b.matrix);
274
283
 
275
- this.fromMatrix4(m4_0);
276
- }
277
-
278
- /**
279
- * @deprecated use `fromMatrix4` directly instead
280
- * @param {THREE.Matrix4} matrix
281
- */
282
- fromThreeMatrix4(matrix) {
283
- this.fromMatrix4(matrix.elements);
284
- }
285
-
286
- /**
287
- * @deprecated use `toMatrix4` directly instead
288
- * @param {Matrix4} matrix
289
- */
290
- toThreeMatrix(matrix) {
291
- this.toMatrix4(matrix.elements);
284
+ this.fromMatrix4(scratch_matrix);
292
285
  }
293
286
 
294
287
  /**
@@ -0,0 +1,22 @@
1
+ import { Transform } from "./Transform.js";
2
+ import Vector3 from "../../../core/geom/Vector3.js";
3
+ import Quaternion from "../../../core/geom/Quaternion.js";
4
+ import { MATRIX_4_IDENTITY } from "../../../core/geom/3d/matrix/MATRIX_4_IDENTITY.js";
5
+
6
+ test("constructor does not throw", () => {
7
+
8
+ expect(() => new Transform()).not.toThrow();
9
+
10
+ });
11
+
12
+ test("new transform has identity transform", () => {
13
+
14
+ const t = new Transform();
15
+
16
+
17
+ expect(t.position.equals(Vector3.zero)).toBe(true);
18
+ expect(t.rotation.equals(Quaternion.identity)).toBe(true);
19
+ expect(t.scale.equals(Vector3.one)).toBe(true);
20
+
21
+ expect(t.matrix).toEqual(MATRIX_4_IDENTITY);
22
+ });
@@ -8,7 +8,7 @@ import { threeUpdateTransform } from "../../../../util/threeUpdateTransform.js";
8
8
  export function applyRotation(component, r) {
9
9
  const l = component.__threeObject;
10
10
 
11
- r.__setThreeEuler(l.rotation);
11
+ r.toEulerAnglesXYZ(l.rotation);
12
12
 
13
13
  if (l.target !== undefined) {
14
14
 
@@ -7,7 +7,9 @@ import { rootObject3DFastMatrixUpdate } from "./rootObject3DFastMatrixUpdate.js"
7
7
  */
8
8
  export function applyTransformToThreeObject(m, t) {
9
9
  m.position.copy(t.position);
10
- t.rotation.__setThreeEuler(m.rotation);
10
+
11
+ t.rotation.toEulerAnglesXYZ(m.rotation);
12
+
11
13
  m.scale.copy(t.scale);
12
14
 
13
15
  rootObject3DFastMatrixUpdate(m);
@@ -1,3 +1,5 @@
1
+ import { MATRIX_4_IDENTITY } from "../../../../core/geom/3d/matrix/MATRIX_4_IDENTITY.js";
2
+
1
3
  /**
2
4
  * Larger bucket sizes provide better cache locality
3
5
  * Larger bucket sizes also cause more hanging GC references, as if one matrix element is still held - ENTIRE bucket is still referenced
@@ -19,17 +21,6 @@ let transform_bucket_cursor = TRANSFORM_ALLOCATOR_BUCKET_CAPACITY;
19
21
 
20
22
  const MATRIX_BYTE_SIZE = 4 * 16;
21
23
 
22
- /**
23
- *
24
- * @type {Float32Array}
25
- */
26
- const MATRIX_IDENTITY = new Float32Array([
27
- 1, 0, 0, 0,
28
- 0, 1, 0, 0,
29
- 0, 0, 1, 0,
30
- 0, 0, 0, 1
31
- ]);
32
-
33
24
  /**
34
25
  * custom Float32Array allocator, allocated memory in continuous chunks
35
26
  * @returns {Float32Array}
@@ -43,7 +34,7 @@ export function allocate_transform_m4() {
43
34
  const result = new Float32Array(transform_bucket, transform_bucket_cursor * MATRIX_BYTE_SIZE, 16);
44
35
 
45
36
  // initialize matrix
46
- result.set(MATRIX_IDENTITY);
37
+ result.set(MATRIX_4_IDENTITY);
47
38
 
48
39
  transform_bucket_cursor++;
49
40
 
@@ -1,6 +1,6 @@
1
- import { DataType } from "../../../core/collection/table/DataType.js";
1
+ import { BinaryDataType } from "../../../core/binary/type/BinaryDataType.js";
2
2
  import { computeStringHash } from "../../../core/primitives/strings/computeStringHash.js";
3
- import { DataTypeByteSizes } from "../../../core/collection/table/DataTypeByteSizes.js";
3
+ import { DataTypeByteSizes } from "../../../core/binary/type/DataTypeByteSizes.js";
4
4
  import { assert } from "../../../core/assert.js";
5
5
 
6
6
  /**
@@ -17,9 +17,9 @@ export class AttributeSpec {
17
17
 
18
18
  /**
19
19
  * How the attribute is stored in memory and interpreted
20
- * @type {DataType}
20
+ * @type {BinaryDataType}
21
21
  */
22
- this.type = DataType.Float32;
22
+ this.type = BinaryDataType.Float32;
23
23
 
24
24
  /**
25
25
  * How many elements the attribute uses. This is cardinality of a vector.
@@ -54,7 +54,7 @@ export class AttributeSpec {
54
54
  }) {
55
55
 
56
56
  assert.isString(name, 'name');
57
- assert.enum(type, DataType, 'type');
57
+ assert.enum(type, BinaryDataType, 'type');
58
58
 
59
59
  assert.isNumber(itemSize, 'itemSize');
60
60
  assert.isNonNegativeInteger(itemSize, 'itemSize');
@@ -25,10 +25,10 @@ import {
25
25
  computeThreeTextureTypeFromDataType
26
26
  } from "../../render/forward_plus/data/computeThreeTextureTypeFromDataType.js";
27
27
  import { typedArrayToDataType } from "../../../../core/collection/array/typedArrayToDataType.js";
28
- import { DataType } from "../../../../core/collection/table/DataType.js";
28
+ import { BinaryDataType } from "../../../../core/binary/type/BinaryDataType.js";
29
29
  import {
30
30
  compute_typed_array_constructor_from_data_type
31
- } from "../../../../core/collection/table/DataType2TypedArrayConstructorMapping.js";
31
+ } from "../../../../core/binary/type/DataType2TypedArrayConstructorMapping.js";
32
32
  import { copy_Sampler2D_channel_data } from "../../texture/sampler/copy_Sampler2D_channel_data.js";
33
33
  import { channelCountToThreeTextureFormat } from "../../texture/channelCountToThreeTextureFormat.js";
34
34
  import { prepare_atlas_texture } from "./prepare_atlas_texture.js";
@@ -325,7 +325,7 @@ function compute_default_texture_value(destination, source_material, texture_nam
325
325
  /**
326
326
  *
327
327
  * @param {string} texture_name
328
- * @returns {{type:DataType,itemSize:number, default_value:[]}}
328
+ * @returns {{type:BinaryDataType,itemSize:number, default_value:[]}}
329
329
  */
330
330
  function build_atlas_sampler_options_texture_name(texture_name) {
331
331
  let type;
@@ -334,27 +334,27 @@ function build_atlas_sampler_options_texture_name(texture_name) {
334
334
 
335
335
  switch (texture_name) {
336
336
  case 'normal':
337
- type = DataType.Uint8;
337
+ type = BinaryDataType.Uint8;
338
338
  itemSize = 3;
339
339
  default_value = [127, 127, 255];
340
340
  break;
341
341
  case 'ao':
342
- type = DataType.Uint8;
342
+ type = BinaryDataType.Uint8;
343
343
  itemSize = 1;
344
344
  default_value = [255];
345
345
  break;
346
346
  case "metalness":
347
- type = DataType.Uint8;
347
+ type = BinaryDataType.Uint8;
348
348
  itemSize = 1;
349
349
  default_value = [0];
350
350
  break;
351
351
  case "roughness":
352
- type = DataType.Uint8;
352
+ type = BinaryDataType.Uint8;
353
353
  itemSize = 1;
354
354
  default_value = [255];
355
355
  break;
356
356
  default:
357
- type = DataType.Uint8;
357
+ type = BinaryDataType.Uint8;
358
358
  itemSize = 4;
359
359
  default_value = [255, 255, 255, 255];
360
360
  break;
@@ -4,7 +4,7 @@ import { MicronGeometry } from "../format/MicronGeometry.js";
4
4
  import { buildAbstractPatchHierarchy } from "./hierarchy/buildAbstractPatchHierarchy.js";
5
5
  import { AttributeSpec } from "../../geometry/AttributeSpec.js";
6
6
  import { typedArrayToDataType } from "../../../../core/collection/array/typedArrayToDataType.js";
7
- import { DataType } from "../../../../core/collection/table/DataType.js";
7
+ import { BinaryDataType } from "../../../../core/binary/type/BinaryDataType.js";
8
8
  import { MicronGeometryPatch } from "../format/MicronGeometryPatch.js";
9
9
  import { build_clustering_info } from "./debug/build_clustering_info.js";
10
10
  import { build_graph_info } from "./debug/build_graph_info.js";
@@ -36,7 +36,7 @@ function current_time_millis() {
36
36
  function custom_attribute_format_normal(spec, source) {
37
37
  // compress normals
38
38
  spec.normalized = true;
39
- spec.type = DataType.Int8;
39
+ spec.type = BinaryDataType.Int8;
40
40
  }
41
41
 
42
42
  /**
@@ -46,7 +46,7 @@ function custom_attribute_format_normal(spec, source) {
46
46
  */
47
47
  function custom_attribute_format_uv(spec, source) {
48
48
  // TODO make sure we only do this when source actually fits in half-float
49
- spec.type = DataType.Float16;
49
+ spec.type = BinaryDataType.Float16;
50
50
  }
51
51
 
52
52
  /**
@@ -56,7 +56,7 @@ function custom_attribute_format_uv(spec, source) {
56
56
  */
57
57
  function custom_attribute_format_color(spec, source) {
58
58
  // crush color data to 8 bit
59
- spec.type = DataType.Uint8;
59
+ spec.type = BinaryDataType.Uint8;
60
60
  spec.normalized = true;
61
61
  }
62
62