@woosh/meep-engine 2.33.1 → 2.33.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.
Files changed (73) hide show
  1. package/core/bvh2/aabb3/AABB3.js +18 -0
  2. package/core/bvh2/aabb3/aabb3_intersects_frustum.js +38 -0
  3. package/core/collection/array/copyArray.js +2 -2
  4. package/core/collection/table/RowFirstTableSpec.js +8 -0
  5. package/core/geom/3d/aabb/aabb3_compute_projected_area.js +11 -10
  6. package/core/geom/3d/aabb/aabb3_estimate_projected_area2.js +59 -0
  7. package/core/geom/3d/aabb/aabb3_matrix4_project.js +33 -0
  8. package/core/geom/3d/aabb/aabb3_matrix4_project.spec.js +41 -0
  9. package/core/geom/3d/plane/plane3_lerp.js +2 -2
  10. package/core/geom/3d/topology/TopoTriangle.js +2 -2
  11. package/core/geom/AABB2.d.ts +2 -0
  12. package/core/geom/Matrix4.js +4 -4
  13. package/core/geom/Vector3.js +5 -5
  14. package/core/model/reactive/model/terminal/ReactiveReference.js +7 -1
  15. package/engine/asset/loaders/GLTFAssetLoader.js +3 -3
  16. package/engine/asset/loaders/material/TextureAttachmensByMaterialType.js +11 -1
  17. package/engine/asset/loaders/material/TextureAttachment.js +12 -1
  18. package/engine/asset/loaders/material/computeTextureEquality.js +1 -1
  19. package/engine/asset/loaders/material/computeTextureHash.js +16 -14
  20. package/engine/asset/loaders/material/traverseMaterialTextures.js +2 -2
  21. package/engine/ecs/animation/OneBoneSurfaceAlignmentSolver.js +2 -2
  22. package/engine/ecs/animation/TwoBoneInverseKinematicsSolver.js +4 -4
  23. package/engine/graphics/GraphicsEngine.d.ts +2 -2
  24. package/engine/graphics/GraphicsEngine.js +20 -62
  25. package/engine/graphics/filter/FlipArrayInPlace.js +25 -0
  26. package/engine/graphics/filter/FlipArrayViaCanvas.js +13 -0
  27. package/engine/graphics/filter/ImageFilter.js +20 -51
  28. package/engine/graphics/geometry/bvh/buffered/BVHGeometryRaycaster.js +2 -2
  29. package/engine/graphics/material/optimization/MaterialOptimizationContext.js +598 -0
  30. package/engine/graphics/micron/build/PatchRepresentation.js +4 -43
  31. package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +3 -70
  32. package/engine/graphics/micron/build/compute_buffer_geometry_byte_size.js +16 -0
  33. package/engine/graphics/micron/format/MicronGeometryBufferAttributeSpec.js +1 -1
  34. package/engine/graphics/micron/format/MicronGeometryPatch.js +9 -5
  35. package/engine/graphics/micron/prototypeVirtualGeometry.js +19 -12
  36. package/engine/graphics/micron/render/RefinementSpec.js +104 -33
  37. package/engine/graphics/micron/render/VirtualGeometryBuilder.js +12 -21
  38. package/engine/graphics/micron/render/instanced/AttributeDataTexture.js +2 -4
  39. package/engine/graphics/micron/render/instanced/PatchDataTextures.js +1 -0
  40. package/engine/graphics/micron/render/instanced/ThreeInstancedAdapter.js +1 -29
  41. package/engine/graphics/micron/render/refinement/ActivePatchList.js +41 -138
  42. package/engine/graphics/micron/render/refinement/ActivePatchRecord.js +4 -2
  43. package/engine/graphics/micron/render/refinement/is_patch_facing_back.js +43 -0
  44. package/engine/graphics/micron/render/refinement/is_patch_visible.js +37 -0
  45. package/engine/graphics/micron/util/unit_hemioct.spec.js +2 -2
  46. package/engine/graphics/render/buffer/buffers/NormalFrameBuffer.js +12 -2
  47. package/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +8 -10
  48. package/engine/graphics/render/forward_plus/LightManager.js +5 -7
  49. package/engine/graphics/render/forward_plus/data/NumericType.js +9 -0
  50. package/engine/graphics/render/forward_plus/{TextureBackedMemoryRegion.js → data/TextureBackedMemoryRegion.js} +11 -190
  51. package/engine/graphics/render/forward_plus/data/channelCountToThreIntegerTextureType.js +16 -0
  52. package/engine/graphics/render/forward_plus/data/computeDataType.js +36 -0
  53. package/engine/graphics/render/forward_plus/data/computeThreeTextureFormat.js +18 -0
  54. package/engine/graphics/render/forward_plus/data/computeThreeTextureInternalFormatFromDataType.js +63 -0
  55. package/engine/graphics/render/forward_plus/data/computeThreeTextureTypeFromDataType.js +41 -0
  56. package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +1 -1
  57. package/engine/graphics/render/utils/ThreeBypassRenderer.js +1 -3
  58. package/engine/graphics/render/visibility/VisibilityComputer.js +11 -0
  59. package/engine/graphics/render/visibility/hiz/buffer/HierarchicalZBuffer.js +198 -0
  60. package/engine/graphics/render/visibility/hiz/buffer/ReductionShader.js +51 -0
  61. package/engine/graphics/render/visibility/hiz/buildCanvasViewFromTexture.js +179 -0
  62. package/engine/graphics/render/visibility/hiz/prototypeHiZ.js +435 -0
  63. package/engine/graphics/render/visibility/hiz/query/BatchOcclusionQuery.js +174 -0
  64. package/engine/graphics/render/visibility/hiz/query/QueryShader.js +173 -0
  65. package/engine/graphics/texture/atlas/TextureAtlas.js +1 -1
  66. package/engine/graphics/texture/cubemap/buildCubeURLs.js +13 -0
  67. package/engine/graphics/texture/cubemap/load_environment_map.d.ts +8 -0
  68. package/engine/graphics/texture/cubemap/load_environment_map.js +137 -0
  69. package/engine/graphics/texture/sampler/convertTexture2Sampler2D.js +8 -4
  70. package/engine/graphics/texture/virtual/v2/ShaderUsage.js +6 -5
  71. package/engine/graphics/texture/virtual/v2/prototype.js +16 -6
  72. package/package.json +1 -1
  73. package/view/elements/progress/segmented/SegmentedResourceBarView.js +50 -15
@@ -8,6 +8,7 @@ import { computeAABB3PlaneSide } from "../../geom/3d/aabb/computeAABB3PlaneSide.
8
8
  import computeMortonCode from "../../geom/3d/morton/Morton.js";
9
9
  import { _boxSurfaceArea2, intersectRay, intersectSegment } from "./AABB3Math.js";
10
10
  import { aabb3_build_corners } from "../../geom/3d/aabb/aabb3_build_corners.js";
11
+ import { assert } from "../../assert.js";
11
12
 
12
13
 
13
14
  /**
@@ -718,6 +719,23 @@ AABB3.prototype.getCorners = function (result) {
718
719
  );
719
720
  };
720
721
 
722
+ /**
723
+ *
724
+ * @param {number[]|Float32Array|Float64Array} result
725
+ * @param {number} offset
726
+ */
727
+ AABB3.prototype.writeToArray = function (result, offset) {
728
+ assert.isNonNegativeInteger(offset, 'offset');
729
+
730
+ result[offset] = this.x0;
731
+ result[offset + 1] = this.y0;
732
+ result[offset + 2] = this.z0;
733
+
734
+ result[offset + 3] = this.x1;
735
+ result[offset + 4] = this.y1;
736
+ result[offset + 5] = this.z1;
737
+ };
738
+
721
739
  /**
722
740
  * @param {THREE.Plane} plane
723
741
  * @returns {int} 2,0,or -2; 2: above, -2 : below, 0 : intersects plane
@@ -0,0 +1,38 @@
1
+ import { aabb3_computeDistanceAbovePlane } from "../../geom/3d/aabb/aabb3_computeDistanceAbovePlane.js";
2
+
3
+ /**
4
+ *
5
+ * @param {Float32Array|number[]} aabb
6
+ * @param {Float32Array|number[]} frustum
7
+ * @return {boolean}
8
+ */
9
+ export function aabb3_intersects_frustum(aabb, frustum) {
10
+
11
+ const x0 = aabb[0];
12
+ const y0 = aabb[1];
13
+ const z0 = aabb[2];
14
+ const x1 = aabb[3];
15
+ const y1 = aabb[4];
16
+ const z1 = aabb[5];
17
+
18
+ for (let i = 0; i < 24; i += 4) {
19
+
20
+ const plane_n_x = frustum[i];
21
+ const plane_n_y = frustum[i + 1];
22
+ const plane_n_z = frustum[i + 2];
23
+ const plane_constant = frustum[i + 3];
24
+
25
+ const plane_distance = aabb3_computeDistanceAbovePlane(
26
+ plane_n_x, plane_n_y, plane_n_z, plane_constant,
27
+ x0, y0, z0,
28
+ x1, y1, z1
29
+ );
30
+
31
+ if (plane_distance < 0) {
32
+ return false;
33
+ }
34
+
35
+ }
36
+
37
+ return true;
38
+ }
@@ -25,9 +25,9 @@ export function copyArray(source, target) {
25
25
  * Follows Java System.arraycopy interface
26
26
  * Copy data from one array to another
27
27
  * @template T
28
- * @param {T[]|ArrayLike<T>|TypedArray} source The source array
28
+ * @param {T[]|ArrayLike<T>|TypedArray|Uint8ClampedArray|Uint8Array} source The source array
29
29
  * @param {number} source_position Starting position where to copy from inside the source array
30
- * @param {T[]|ArrayLike<T>|TypedArray} destination The destination array
30
+ * @param {T[]|ArrayLike<T>|TypedArray|Uint8ClampedArray|Uint8Array} destination The destination array
31
31
  * @param {number} destination_position Starting position where to copy to inside the destination array
32
32
  * @param {number} length How many elements should be copied
33
33
  */
@@ -234,6 +234,14 @@ export function RowFirstTableSpec(types, endianType = EndianType.BigEndian) {
234
234
  }
235
235
  }
236
236
 
237
+ /**
238
+ *
239
+ * @return {number}
240
+ */
241
+ RowFirstTableSpec.prototype.getColumnCount = function () {
242
+ return this.types.length;
243
+ }
244
+
237
245
  /**
238
246
  *
239
247
  * @param {RowFirstTableSpec} other
@@ -1,5 +1,3 @@
1
- const scratch_corners = new Float32Array(24);
2
-
3
1
  /*
4
2
 
5
3
  one option of Algorithm (problem-orthogonal only, rectangles under perspective projection do not behave this way):
@@ -12,13 +10,13 @@ const scratch_corners = new Float32Array(24);
12
10
 
13
11
 
14
12
  /**
13
+ * NOTE: Consider using an optimized aabb projection method based on Jim Arvo's Graphics Gems algorithm: https://stackoverflow.com/a/58630206/3973586
15
14
  * Almost everything is inlined for speed
16
- * @param {AABB2} result
17
- * @param {AABB3} bounds
15
+ * @param {number[]} aabb_corners
18
16
  * @param {number[]|mat4|Float32Array} projection_matrix
17
+ * @returns {number}
19
18
  */
20
- export function aabb3_project_to_2d(result, bounds, projection_matrix) {
21
- bounds.getCorners(scratch_corners);
19
+ export function aabb3_project_to_2d(aabb_corners, projection_matrix) {
22
20
 
23
21
  // read matrix into local variables for speed
24
22
  const a0 = projection_matrix[0];
@@ -48,9 +46,9 @@ export function aabb3_project_to_2d(result, bounds, projection_matrix) {
48
46
  for (let i = 0; i < 24; i += 3) {
49
47
 
50
48
  // read corner
51
- const _x = scratch_corners[i];
52
- const _y = scratch_corners[i + 1];
53
- const _z = scratch_corners[i + 2];
49
+ const _x = aabb_corners[i];
50
+ const _y = aabb_corners[i + 1];
51
+ const _z = aabb_corners[i + 2];
54
52
 
55
53
  // apply transform
56
54
  const t_x = a0 * _x + b0 * _y + c0 * _z + d0;
@@ -80,5 +78,8 @@ export function aabb3_project_to_2d(result, bounds, projection_matrix) {
80
78
 
81
79
  }
82
80
 
83
- result.set(x0, y0, x1, y1);
81
+ const dx = x1 - x0;
82
+ const dy = y1 - y0;
83
+
84
+ return dx * dy;
84
85
  }
@@ -0,0 +1,59 @@
1
+ const scratch_aabb = new Float32Array(4);
2
+
3
+
4
+ /**
5
+ * NOTE: tends to overestimate the area
6
+ * @param {number[]} aabb
7
+ * @param {number[]} matrix
8
+ * @return {number}
9
+ */
10
+ export function aabb3_estimate_projected_area2(aabb, matrix) {
11
+ // extract translation from matrix
12
+ scratch_aabb[0] = scratch_aabb[2] = matrix[12];
13
+ scratch_aabb[1] = scratch_aabb[3] = matrix[13];
14
+
15
+ // apply 3x3 matrix transform
16
+ for (let i = 0; i < 2; i++) {
17
+ for (let j = 0; j < 3; j++) {
18
+
19
+ const m_a = i * 4 + j;
20
+ const m_v = matrix[m_a];
21
+
22
+ const a = m_v * aabb[j];
23
+ const b = m_v * aabb[j + 3];
24
+
25
+ if (a < b) {
26
+ scratch_aabb[i] += a;
27
+ scratch_aabb[i + 2] += b;
28
+ } else {
29
+ scratch_aabb[i] += b;
30
+ scratch_aabb[i + 2] += a;
31
+ }
32
+ }
33
+ }
34
+
35
+
36
+ const x1 = scratch_aabb[2];
37
+ const x0 = scratch_aabb[0];
38
+
39
+ const dx = x1 - x0;
40
+
41
+ const y1 = scratch_aabb[3];
42
+ const y0 = scratch_aabb[1];
43
+
44
+ const dy = y1 - y0;
45
+ const a = dx * dy;
46
+
47
+ const cx = (aabb[0] + aabb[3]) * 0.5;
48
+ const cy = (aabb[1] + aabb[4]) * 0.5;
49
+ const cz = (aabb[2] + aabb[5]) * 0.5;
50
+
51
+ /* compute W projection value, using conservative estimate
52
+ @see https://twitter.com/SebAaltonen/status/1332332808979832832
53
+ @see https://gist.github.com/slembcke/b2b2af4dede1d5702a635dc2d0e45d54
54
+ */
55
+ const w = matrix[3] * cx + matrix[7] * cy + matrix[11] * cz + matrix[15];
56
+ const d = 0.5 / Math.abs(w);
57
+
58
+ return a * d * d;
59
+ }
@@ -0,0 +1,33 @@
1
+
2
+ /**
3
+ * NOTE: Based on Transforming Axis-Aligned Bounding Boxes by Jim Arvo from "Graphics Gems", Academic Press, 1990
4
+ * @param {number[]} result
5
+ * @param {number[]} aabb
6
+ * @param {number[]} matrix 4x4 matrix
7
+ */
8
+ export function aabb3_matrix4_project(result, aabb, matrix) {
9
+ // extract translation from matrix
10
+ result[0] = result[3] = matrix[12];
11
+ result[1] = result[4] = matrix[13];
12
+ result[2] = result[5] = matrix[14];
13
+
14
+ // apply 3x3 matrix transform
15
+ for (let i = 0; i < 3; i++) {
16
+ for (let j = 0; j < 3; j++) {
17
+
18
+ const m_a = i * 4 + j;
19
+ const m_v = matrix[m_a];
20
+
21
+ const a = m_v * aabb[j];
22
+ const b = m_v * aabb[j + 3];
23
+
24
+ if (a < b) {
25
+ result[i] += a;
26
+ result[i + 3] += b;
27
+ } else {
28
+ result[i] += b;
29
+ result[i + 3] += a;
30
+ }
31
+ }
32
+ }
33
+ }
@@ -0,0 +1,41 @@
1
+ import { aabb3_matrix4_project } from "./aabb3_matrix4_project.js";
2
+
3
+ test('identity', () => {
4
+ const r = [];
5
+
6
+ aabb3_matrix4_project(r, [1, 2, 3, 5, 7, 9], [
7
+ 1, 0, 0, 0,
8
+ 0, 1, 0, 0,
9
+ 0, 0, 1, 0,
10
+ 0, 0, 0, 1
11
+ ]);
12
+
13
+ expect(r).toEqual([1, 2, 3, 5, 7, 9]);
14
+ });
15
+
16
+ test('translation case', () => {
17
+ const r = [];
18
+
19
+ aabb3_matrix4_project(r, [1, 2, 3, 5, 7, 9], [
20
+ 1, 0, 0, 0,
21
+ 0, 1, 0, 0,
22
+ 0, 0, 1, 0,
23
+ 13, -17, 23, 1
24
+ ]);
25
+
26
+ expect(r).toEqual([14, -15, 26, 18, -10, 32]);
27
+ });
28
+
29
+
30
+ test('scale case', () => {
31
+ const r = [];
32
+
33
+ aabb3_matrix4_project(r, [1, 2, 3, 5, 7, 9], [
34
+ -1, 0, 0, 0,
35
+ 0, 2, 0, 0,
36
+ 0, 0, -3, 0,
37
+ 0, 0, 0, 1
38
+ ]);
39
+
40
+ expect(r).toEqual([-5, 4, -27, -1, 14, -9]);
41
+ });
@@ -1,5 +1,5 @@
1
1
  import { lerp } from "../../../math/lerp.js";
2
- import Vector3, { v3_dot, v3Length_i } from "../../Vector3.js";
2
+ import Vector3, { v3_dot, v3_length } from "../../Vector3.js";
3
3
  import { plane3_intersect_plane } from "./plane3_intersect_plane.js";
4
4
 
5
5
  const v0 = new Vector3();
@@ -32,7 +32,7 @@ export function plane3_lerp(
32
32
  let normal_z = lerp(a_normal_z, b_normal_z, t);
33
33
 
34
34
  // normalize the normal vector
35
- const normal_length = v3Length_i(normal_x, normal_y, normal_z);
35
+ const normal_length = v3_length(normal_x, normal_y, normal_z);
36
36
  const normal_length_inv = 1 / normal_length;
37
37
 
38
38
  normal_x *= normal_length_inv;
@@ -1,4 +1,4 @@
1
- import { v3Length_i } from "../../Vector3.js";
1
+ import { v3_length } from "../../Vector3.js";
2
2
  import { array_replace_all } from "../../../collection/array/array_replace_all.js";
3
3
  import { array_push_if_unique } from "../../../collection/array/array_push_if_unique.js";
4
4
  import { assert } from "../../../assert.js";
@@ -40,7 +40,7 @@ export function compute_triangle_normal(result, vA, vB, vC) {
40
40
  const crossY = vCBz * vABx - vCBx * vABz;
41
41
  const crossZ = vCBx * vABy - vCBy * vABx;
42
42
 
43
- const l = v3Length_i(crossX, crossY, crossZ);
43
+ const l = v3_length(crossX, crossY, crossZ);
44
44
 
45
45
  if (l === 0) {
46
46
  // degenerate triangle, provide arbitrary invalid result
@@ -20,5 +20,7 @@ export default class AABB2 {
20
20
 
21
21
  grow(size: number): void
22
22
 
23
+ shrink(size: number): void
24
+
23
25
  setNegativelyInfiniteBounds(): void
24
26
  }
@@ -1,4 +1,4 @@
1
- import Vector3, { v3Length_i } from "./Vector3.js";
1
+ import Vector3, { v3_length } from "./Vector3.js";
2
2
 
3
3
  const _z = new Vector3();
4
4
  const _x = new Vector3();
@@ -192,9 +192,9 @@ export class Matrix4 {
192
192
  decompose(position, rotation, scale) {
193
193
 
194
194
 
195
- var sx = v3Length_i(this.a0, this.a1, this.a2);
196
- var sy = v3Length_i(this.b0, this.b1, this.b2);
197
- var sz = v3Length_i(this.c0, this.c1, this.c2);
195
+ var sx = v3_length(this.a0, this.a1, this.a2);
196
+ var sy = v3_length(this.b0, this.b1, this.b2);
197
+ var sz = v3_length(this.c0, this.c1, this.c2);
198
198
 
199
199
  // if determine is negative, we need to invert one scale
200
200
  var det = this.determinant();
@@ -883,7 +883,7 @@ class Vector3 {
883
883
  * @returns {number}
884
884
  */
885
885
  static distance(a, b) {
886
- return v3Length_i(a.x - b.x, a.y - b.y, a.z - b.z);
886
+ return v3_length(a.x - b.x, a.y - b.y, a.z - b.z);
887
887
  }
888
888
  }
889
889
 
@@ -1008,10 +1008,10 @@ export function v3_distance_sqr(x0, y0, z0, x1, y1, z1) {
1008
1008
 
1009
1009
 
1010
1010
  function v3Length(v) {
1011
- return v3Length_i(v.x, v.y, v.z);
1011
+ return v3_length(v.x, v.y, v.z);
1012
1012
  }
1013
1013
 
1014
- export function v3Length_i(x, y, z) {
1014
+ export function v3_length(x, y, z) {
1015
1015
  return Math.sqrt(v3_length_sqr(x, y, z));
1016
1016
  }
1017
1017
 
@@ -1040,8 +1040,8 @@ export function v3_length_sqr(x, y, z) {
1040
1040
  export function v3_angleBetween(x0, y0, z0, x1, y1, z1) {
1041
1041
  const d = v3_dot(x0, y0, z0, x1, y1, z1);
1042
1042
 
1043
- const magnitude_0 = v3Length_i(x0, y0, z0);
1044
- const magnitude_1 = v3Length_i(x1, y1, z1);
1043
+ const magnitude_0 = v3_length(x0, y0, z0);
1044
+ const magnitude_1 = v3_length(x1, y1, z1);
1045
1045
 
1046
1046
  const l = magnitude_0 * magnitude_1;
1047
1047
 
@@ -64,9 +64,15 @@ export class ReactiveReference extends ReactiveExpression {
64
64
  assert.notEqual(source, null, 'source is null');
65
65
  assert.notEqual(source, undefined, 'source is undefined');
66
66
  assert.typeOf(source.onChanged, 'object', 'source.onChanged');
67
- assert.typeOf(source.onChanged.add, 'function', 'source.onChanged.add');
67
+ assert.isFunction(source.onChanged.add, 'source.onChanged.add');
68
68
 
69
69
  if (this.source !== null) {
70
+
71
+ if (this.source === source) {
72
+ // already connected to this source, do nothing
73
+ return;
74
+ }
75
+
70
76
  throw new Error('source is already set. Already connected');
71
77
  }
72
78
 
@@ -23,6 +23,7 @@ import { convert_three_object_to_micron } from "../../graphics/micron/convert_th
23
23
  import { HashSet } from "../../../core/collection/HashSet.js";
24
24
  import { computeGeometryHash } from "./geometry/geometry/computeGeometryHash.js";
25
25
  import { computeGeometryEquality } from "./geometry/geometry/computeGeometryEquality.js";
26
+ import { traverseThreeObject } from "../../graphics/ecs/highlight/renderer/traverseThreeObject.js";
26
27
 
27
28
  const animationOptimizer = new AnimationOptimizer();
28
29
  const materialCache = StaticMaterialCache.Global;
@@ -287,9 +288,7 @@ export class GLTFAssetLoader extends AssetLoader {
287
288
  root = meshes[0];
288
289
  }
289
290
 
290
- root.traverse(o => {
291
- this.__prepareObjectMaterial(o);
292
- });
291
+ traverseThreeObject(root, this.__prepareObjectMaterial, this);
293
292
 
294
293
  const root_transform = new Transform();
295
294
 
@@ -319,6 +318,7 @@ export class GLTFAssetLoader extends AssetLoader {
319
318
 
320
319
  await async_traverse(root, process_object);
321
320
 
321
+
322
322
  // compute object bounding sphere
323
323
  root.boundingSphere = computeObjectBoundingSphere(root);
324
324
 
@@ -2,6 +2,7 @@ import { TextureAttachment } from "./TextureAttachment.js";
2
2
 
3
3
  const taDiffuse = new TextureAttachment({
4
4
  name: 'diffuse',
5
+ uv_index: 0,
5
6
  read(m) {
6
7
  return m.map;
7
8
  },
@@ -12,6 +13,7 @@ const taDiffuse = new TextureAttachment({
12
13
 
13
14
  const taAlphaMap = new TextureAttachment({
14
15
  name: "alpha",
16
+ uv_index: 0,
15
17
  read(m) {
16
18
  return m.alphaMap;
17
19
  },
@@ -22,6 +24,7 @@ const taAlphaMap = new TextureAttachment({
22
24
 
23
25
  const taDisplacement = new TextureAttachment({
24
26
  name: "displacement",
27
+ uv_index: 0,
25
28
  read(m) {
26
29
  return m.displacementMap;
27
30
  },
@@ -45,6 +48,7 @@ export const TextureAttachmentsByMaterialType = {
45
48
  taAlphaMap,
46
49
  new TextureAttachment({
47
50
  name: "light",
51
+ uv_index: 1,
48
52
  read(m) {
49
53
  return m.lightMap;
50
54
  },
@@ -54,6 +58,7 @@ export const TextureAttachmentsByMaterialType = {
54
58
  }),
55
59
  new TextureAttachment({
56
60
  name: "ao",
61
+ uv_index: 1,
57
62
  read(m) {
58
63
  return m.aoMap;
59
64
  },
@@ -63,6 +68,7 @@ export const TextureAttachmentsByMaterialType = {
63
68
  }),
64
69
  new TextureAttachment({
65
70
  name: "emissive",
71
+ uv_index: 0,
66
72
  read(m) {
67
73
  return m.emissiveMap;
68
74
  },
@@ -72,6 +78,7 @@ export const TextureAttachmentsByMaterialType = {
72
78
  }),
73
79
  new TextureAttachment({
74
80
  name: "bump",
81
+ uv_index: 0,
75
82
  read(m) {
76
83
  return m.bumpMap;
77
84
  },
@@ -81,6 +88,7 @@ export const TextureAttachmentsByMaterialType = {
81
88
  }),
82
89
  new TextureAttachment({
83
90
  name: "normal",
91
+ uv_index: 0,
84
92
  read(m) {
85
93
  return m.normalMap;
86
94
  },
@@ -91,6 +99,7 @@ export const TextureAttachmentsByMaterialType = {
91
99
  taDisplacement,
92
100
  new TextureAttachment({
93
101
  name: "roughness",
102
+ uv_index: 0,
94
103
  read(m) {
95
104
  return m.roughnessMap;
96
105
  },
@@ -100,6 +109,7 @@ export const TextureAttachmentsByMaterialType = {
100
109
  }),
101
110
  new TextureAttachment({
102
111
  name: "metalness",
112
+ uv_index: 0,
103
113
  read(m) {
104
114
  return m.metalnessMap;
105
115
  },
@@ -107,9 +117,9 @@ export const TextureAttachmentsByMaterialType = {
107
117
  m.metalnessMap = t;
108
118
  }
109
119
  }),
110
- taAlphaMap,
111
120
  new TextureAttachment({
112
121
  name: "environment",
122
+ uv_index: 0,
113
123
  read(m) {
114
124
  return m.envMap;
115
125
  },
@@ -4,11 +4,22 @@ export class TextureAttachment {
4
4
  * @param {function(T):Texture} read
5
5
  * @param {function(T, Texture)} write
6
6
  * @param {string} [name]
7
+ * @param {number} [uv_index]
7
8
  */
8
- constructor({ read, write, name }) {
9
+ constructor({ read, write, name, uv_index = 0 }) {
10
+ /**
11
+ *
12
+ * @type {string}
13
+ */
9
14
  this.name = name;
10
15
 
11
16
  this.read = read;
12
17
  this.write = write;
18
+
19
+ /**
20
+ *
21
+ * @type {number}
22
+ */
23
+ this.uv_index = uv_index;
13
24
  }
14
25
  }
@@ -76,7 +76,7 @@ export function computeTextureEquality(a, b) {
76
76
  * @param {Image|[]} b
77
77
  * @returns {boolean}
78
78
  */
79
- function textureImagesEqual(a, b) {
79
+ export function textureImagesEqual(a, b) {
80
80
  if (a === b) {
81
81
  return true;
82
82
  }
@@ -1,4 +1,4 @@
1
- import { computeHashFloat, computeHashIntegerArray} from "../../../../core/math/MathUtils.js";
1
+ import { computeHashFloat, computeHashIntegerArray } from "../../../../core/math/MathUtils.js";
2
2
  import { max2 } from "../../../../core/math/max2.js";
3
3
  import { computeImageBitmapHash } from "./computeImageBitmapHash.js";
4
4
 
@@ -19,7 +19,7 @@ function vector2Hash(v) {
19
19
  */
20
20
  const data_cache = new WeakMap();
21
21
 
22
- function computeImageDataHash(image) {
22
+ export function computeImageDataHash(image) {
23
23
  const cached_value = data_cache.get(image);
24
24
 
25
25
  if (cached_value !== undefined) {
@@ -32,6 +32,19 @@ function computeImageDataHash(image) {
32
32
  result = computeImageBitmapHash(image);
33
33
  }
34
34
 
35
+ let width = 0;
36
+ let height = 0;
37
+
38
+ if (typeof image.width === "number") {
39
+ width = image.width;
40
+ }
41
+
42
+ if (typeof image.height === "number") {
43
+ height = image.height;
44
+ }
45
+
46
+ result = result ^ (((width & 0xFFFF) << 16) | (height & 0xFFFF));
47
+
35
48
  // cache value
36
49
  data_cache.set(image, result);
37
50
 
@@ -44,23 +57,12 @@ function computeImageDataHash(image) {
44
57
  * @return {number}
45
58
  */
46
59
  function computeSpecificHash(texture) {
47
- let width = 0;
48
- let height = 0;
49
-
50
60
  let dataHash = 0;
51
61
 
52
62
  if (texture.image !== null && texture.image !== undefined) {
53
63
 
54
64
  const image = texture.image;
55
65
 
56
- if (typeof image.width === "number") {
57
- width = image.width;
58
- }
59
-
60
- if (typeof image.height === "number") {
61
- height = image.height;
62
- }
63
-
64
66
  dataHash = computeImageDataHash(image);
65
67
 
66
68
  }
@@ -94,7 +96,7 @@ function computeSpecificHash(texture) {
94
96
 
95
97
  }
96
98
 
97
- return computeHashIntegerArray(width, height, dataHash);
99
+ return dataHash;
98
100
  }
99
101
 
100
102
  /**
@@ -3,7 +3,7 @@ import { TextureAttachmentsByMaterialType } from "./TextureAttachmensByMaterialT
3
3
  /**
4
4
  *
5
5
  * @param {Material} material
6
- * @param {function(Texture)} callback
6
+ * @param {function(THREE.Texture, TextureAttachment)} callback
7
7
  * @param {*} [thisArg]
8
8
  */
9
9
  export function traverseMaterialTextures(material, callback, thisArg) {
@@ -30,7 +30,7 @@ export function traverseMaterialTextures(material, callback, thisArg) {
30
30
  continue;
31
31
  }
32
32
 
33
- callback.call(thisArg, texture);
33
+ callback.call(thisArg, texture, attachment);
34
34
 
35
35
  }
36
36
  }
@@ -3,7 +3,7 @@ import { inverseLerp } from "../../../core/math/inverseLerp.js";
3
3
  import { IKSolver } from "./IKSolver.js";
4
4
  import { findSkeletonBoneByType } from "../../graphics/ecs/mesh/SkeletonUtils.js";
5
5
  import Quaternion from "../../../core/geom/Quaternion.js";
6
- import Vector3, { v3_dot, v3Length_i } from "../../../core/geom/Vector3.js";
6
+ import Vector3, { v3_dot, v3_length } from "../../../core/geom/Vector3.js";
7
7
  import { SurfacePoint3 } from "../../../core/geom/3d/SurfacePoint3.js";
8
8
  import { v3_computeOffsetVector } from "./IKMath.js";
9
9
 
@@ -127,7 +127,7 @@ export class OneBoneSurfaceAlignmentSolver extends IKSolver {
127
127
  //check if current effector position is above the contact point
128
128
  const dot_contact_side = v3_dot(directionX, directionY, directionZ, delta_contact_c_x, delta_contact_c_y, delta_contact_c_z);
129
129
 
130
- const delta_contact_c_length = v3Length_i(delta_contact_c_x, delta_contact_c_y, delta_contact_c_z);
130
+ const delta_contact_c_length = v3_length(delta_contact_c_x, delta_contact_c_y, delta_contact_c_z);
131
131
 
132
132
  let influence;
133
133