@woosh/meep-engine 2.118.12 → 2.119.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 (99) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/package.json +1 -5
  3. package/src/core/bvh2/bvh3/BVH.d.ts.map +1 -1
  4. package/src/core/bvh2/bvh3/BVH.js +13 -8
  5. package/src/core/geom/3d/compute_triangle_normal.d.ts +16 -4
  6. package/src/core/geom/3d/compute_triangle_normal.d.ts.map +1 -1
  7. package/src/core/geom/3d/compute_triangle_normal.js +3 -3
  8. package/src/core/geom/3d/mat4/m4_multiply.d.ts +4 -4
  9. package/src/core/geom/3d/mat4/m4_multiply.d.ts.map +1 -1
  10. package/src/core/geom/3d/mat4/m4_multiply.js +3 -3
  11. package/src/core/geom/3d/topology/computeTopoMeshVertexDuplicates.d.ts.map +1 -1
  12. package/src/core/geom/3d/topology/computeTopoMeshVertexDuplicates.js +10 -5
  13. package/src/core/geom/3d/topology/query/query_edge_is_boundary.d.ts +1 -0
  14. package/src/core/geom/3d/topology/query/query_edge_is_boundary.d.ts.map +1 -1
  15. package/src/core/geom/3d/topology/query/query_edge_is_boundary.js +1 -0
  16. package/src/core/geom/3d/topology/{isVertexConnectedToOutline.d.ts → query/query_vertex_is_boundary.d.ts} +2 -2
  17. package/src/core/geom/3d/topology/query/query_vertex_is_boundary.d.ts.map +1 -0
  18. package/src/core/geom/3d/topology/{isVertexConnectedToOutline.js → query/query_vertex_is_boundary.js} +2 -2
  19. package/src/core/geom/3d/topology/samples/prototypeFloodFill.d.ts +2 -0
  20. package/src/core/geom/3d/topology/samples/prototypeFloodFill.d.ts.map +1 -0
  21. package/src/core/geom/3d/topology/samples/{sampleFloodFill.js → prototypeFloodFill.js} +3 -3
  22. package/src/core/geom/3d/topology/simplify/EdgeCollapseCandidate.d.ts.map +1 -1
  23. package/src/core/geom/3d/topology/simplify/EdgeCollapseCandidate.js +2 -32
  24. package/src/core/geom/3d/topology/simplify/computeEdgeCollapseCost.js +3 -3
  25. package/src/core/geom/3d/topology/simplify/decimate_edge_collapse_snap.d.ts.map +1 -1
  26. package/src/core/geom/3d/topology/simplify/decimate_edge_collapse_snap.js +9 -15
  27. package/src/core/geom/3d/topology/simplify/edge_collapse_quadratic.d.ts.map +1 -1
  28. package/src/core/geom/3d/topology/simplify/edge_collapse_quadratic.js +2 -57
  29. package/src/core/geom/3d/topology/simplify/prototypeMeshSimplification.js +2 -2
  30. package/src/core/geom/3d/topology/simplify/quadratic/Quadratic3.d.ts.map +1 -1
  31. package/src/core/geom/3d/topology/simplify/quadratic/Quadratic3.js +18 -18
  32. package/src/core/geom/3d/topology/simplify/simplifyTopoMesh.d.ts.map +1 -1
  33. package/src/core/geom/3d/topology/simplify/simplifyTopoMesh.js +1 -0
  34. package/src/core/geom/3d/topology/simplify/tm_edge_collapse_is_degenerate_flip.d.ts.map +1 -1
  35. package/src/core/geom/3d/topology/simplify/tm_edge_collapse_is_degenerate_flip.js +2 -18
  36. package/src/core/geom/3d/topology/struct/TopoTriangle.d.ts +17 -1
  37. package/src/core/geom/3d/topology/struct/TopoTriangle.d.ts.map +1 -1
  38. package/src/core/geom/3d/topology/struct/TopoTriangle.js +60 -1
  39. package/src/core/geom/3d/topology/struct/TopoVertex.d.ts +8 -0
  40. package/src/core/geom/3d/topology/struct/TopoVertex.d.ts.map +1 -1
  41. package/src/core/geom/3d/topology/struct/TopoVertex.js +22 -1
  42. package/src/core/geom/3d/topology/{three_buffer_geometry_to_topo_mesh.d.ts → three/three_buffer_geometry_to_topo_mesh.d.ts} +1 -1
  43. package/src/core/geom/3d/topology/three/three_buffer_geometry_to_topo_mesh.d.ts.map +1 -0
  44. package/src/core/geom/3d/topology/{three_buffer_geometry_to_topo_mesh.js → three/three_buffer_geometry_to_topo_mesh.js} +1 -1
  45. package/src/core/geom/3d/topology/three/topo_mesh_to_three_buffer_geometry.d.ts.map +1 -0
  46. package/src/core/geom/3d/topology/tm_weld_duplicate_vertices.d.ts +9 -0
  47. package/src/core/geom/3d/topology/tm_weld_duplicate_vertices.d.ts.map +1 -0
  48. package/src/core/geom/3d/topology/{weld_duplicate_vertices.js → tm_weld_duplicate_vertices.js} +4 -5
  49. package/src/core/math/GOLDEN_RATIO.d.ts +1 -0
  50. package/src/core/math/GOLDEN_RATIO.d.ts.map +1 -1
  51. package/src/core/math/GOLDEN_RATIO.js +1 -0
  52. package/src/core/math/matrix/mat4x4_transpose_copy_to_mat4x3.d.ts +9 -0
  53. package/src/core/math/matrix/mat4x4_transpose_copy_to_mat4x3.d.ts.map +1 -0
  54. package/src/core/math/matrix/mat4x4_transpose_copy_to_mat4x3.js +26 -0
  55. package/src/engine/graphics/ecs/light/LightContext.d.ts.map +1 -1
  56. package/src/engine/graphics/ecs/light/LightContext.js +7 -10
  57. package/src/engine/graphics/ecs/light/binding/three/ThreeLightBinding.d.ts.map +1 -1
  58. package/src/engine/graphics/ecs/light/binding/three/ThreeLightBinding.js +4 -6
  59. package/src/engine/graphics/ecs/light/shadow/ShadowManager.d.ts.map +1 -1
  60. package/src/engine/graphics/ecs/light/shadow/ShadowManager.js +14 -15
  61. package/src/engine/graphics/geometry/AttributeGroupSpec.d.ts.map +1 -1
  62. package/src/engine/graphics/geometry/AttributeGroupSpec.js +15 -6
  63. package/src/engine/graphics/geometry/skining/computeSkinnedMeshVertices.d.ts.map +1 -1
  64. package/src/engine/graphics/geometry/skining/computeSkinnedMeshVertices.js +23 -109
  65. package/src/engine/graphics/geometry/skining/mesh_apply_skeletal_vertex_skinning.d.ts +15 -0
  66. package/src/engine/graphics/geometry/skining/mesh_apply_skeletal_vertex_skinning.d.ts.map +1 -0
  67. package/src/engine/graphics/geometry/skining/mesh_apply_skeletal_vertex_skinning.js +85 -0
  68. package/src/engine/graphics/trail/x/RibbonXPlugin.d.ts +1 -1
  69. package/src/engine/graphics/trail/x/RibbonXPlugin.d.ts.map +1 -1
  70. package/src/engine/graphics/trail/x/RibbonXPlugin.js +2 -14
  71. package/src/engine/intelligence/blackboard/BlackboardValue.d.ts +2 -2
  72. package/src/engine/intelligence/blackboard/BlackboardValue.d.ts.map +1 -1
  73. package/build/meep.cjs +0 -118564
  74. package/build/meep.min.js +0 -1
  75. package/build/meep.module.js +0 -118529
  76. package/src/__module.d.ts +0 -3
  77. package/src/__module.d.ts.map +0 -1
  78. package/src/__module.js +0 -6
  79. package/src/core/__module.d.ts +0 -21
  80. package/src/core/__module.d.ts.map +0 -1
  81. package/src/core/__module.js +0 -22
  82. package/src/core/geom/3d/topology/isEdgeConnectedToOutline.d.ts +0 -7
  83. package/src/core/geom/3d/topology/isEdgeConnectedToOutline.d.ts.map +0 -1
  84. package/src/core/geom/3d/topology/isEdgeConnectedToOutline.js +0 -13
  85. package/src/core/geom/3d/topology/isVertexConnectedToOutline.d.ts.map +0 -1
  86. package/src/core/geom/3d/topology/samples/sampleFloodFill.d.ts +0 -2
  87. package/src/core/geom/3d/topology/samples/sampleFloodFill.d.ts.map +0 -1
  88. package/src/core/geom/3d/topology/three_buffer_geometry_to_topo_mesh.d.ts.map +0 -1
  89. package/src/core/geom/3d/topology/topo_mesh_to_three_buffer_geometry.d.ts.map +0 -1
  90. package/src/core/geom/3d/topology/weld_duplicate_vertices.d.ts +0 -9
  91. package/src/core/geom/3d/topology/weld_duplicate_vertices.d.ts.map +0 -1
  92. package/src/engine/__module.d.ts +0 -18
  93. package/src/engine/__module.d.ts.map +0 -1
  94. package/src/engine/__module.js +0 -20
  95. package/src/engine/intelligence/__module.d.ts +0 -7
  96. package/src/engine/intelligence/__module.d.ts.map +0 -1
  97. package/src/engine/intelligence/__module.js +0 -6
  98. /package/src/core/geom/3d/topology/{topo_mesh_to_three_buffer_geometry.d.ts → three/topo_mesh_to_three_buffer_geometry.d.ts} +0 -0
  99. /package/src/core/geom/3d/topology/{topo_mesh_to_three_buffer_geometry.js → three/topo_mesh_to_three_buffer_geometry.js} +0 -0
@@ -2,6 +2,7 @@ import { assert } from "../../../core/assert.js";
2
2
  import { computeHashArray } from "../../../core/collection/array/computeHashArray.js";
3
3
  import { isArrayEqual } from "../../../core/collection/array/isArrayEqual.js";
4
4
  import { invokeObjectHash } from "../../../core/model/object/invokeObjectHash.js";
5
+ import { invokeObjectToJSON } from "../../../core/model/object/invokeObjectToJSON.js";
5
6
  import { AttributeSpec } from "./AttributeSpec.js";
6
7
 
7
8
  /**
@@ -17,7 +18,7 @@ const RESERVED_HASH = 1234567;
17
18
  export class AttributeGroupSpec {
18
19
 
19
20
  /**
20
- *
21
+ * @readonly
21
22
  * @type {AttributeSpec[]}
22
23
  */
23
24
  attributes = [];
@@ -80,27 +81,32 @@ export class AttributeGroupSpec {
80
81
  }
81
82
  }
82
83
 
83
- return undefined;
84
+ return -1;
84
85
  }
85
86
 
86
87
  /**
87
88
  *
88
89
  * @param {AttributeSpec[]} attributes
90
+ * @throws {Error} if any there are any name collisions
89
91
  */
90
92
  addMany(attributes) {
91
93
  const n = attributes.length;
94
+
92
95
  for (let i = 0; i < n; i++) {
93
96
  this.add(attributes[i]);
94
97
  }
98
+
95
99
  }
96
100
 
97
101
  /**
98
102
  *
99
103
  * @param {AttributeSpec} attribute
100
104
  * @return {AttributeGroupSpec}
105
+ * @throws {Error} if attribute with that name is already present
101
106
  */
102
107
  add(attribute) {
103
108
 
109
+ assert.defined(attribute, 'attribute');
104
110
  assert.equal(attribute.isAttributeSpec, true, 'attribute.isAttributeSpec !== true');
105
111
 
106
112
  //check uniqueness of name
@@ -130,8 +136,10 @@ export class AttributeGroupSpec {
130
136
  }
131
137
 
132
138
  clear() {
133
- const count = this.attributes.length;
134
- this.attributes.splice(0, count);
139
+ const attributes = this.attributes;
140
+
141
+ const count = attributes.length;
142
+ attributes.splice(0, count);
135
143
 
136
144
  // reset hash to trigger hash update
137
145
  this.#hash = RESERVED_HASH;
@@ -171,7 +179,7 @@ export class AttributeGroupSpec {
171
179
 
172
180
  toJSON() {
173
181
  return {
174
- attributes: JSON.stringify(this.attributes)
182
+ attributes: this.attributes.map(invokeObjectToJSON)
175
183
  };
176
184
  }
177
185
 
@@ -196,7 +204,8 @@ export class AttributeGroupSpec {
196
204
  }
197
205
 
198
206
  /**
199
- *
207
+ * Size of a single element of all attributes.
208
+ * @example 2 attributes float32 and uin8 will produce result of 5 ( = (32 + 8) / 8 )
200
209
  * @returns {number}
201
210
  */
202
211
  getByteSize() {
@@ -1 +1 @@
1
- {"version":3,"file":"computeSkinnedMeshVertices.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/geometry/skining/computeSkinnedMeshVertices.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wDAJW,YAAY,0CAEZ,MAAM,QAqIhB"}
1
+ {"version":3,"file":"computeSkinnedMeshVertices.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/geometry/skining/computeSkinnedMeshVertices.js"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,wDAJW,YAAY,0CAEZ,MAAM,QA6ChB"}
@@ -1,4 +1,6 @@
1
- import { Matrix4 as ThreeMatrix4 } from "three";
1
+ import { m4_multiply } from "../../../../core/geom/3d/mat4/m4_multiply.js";
2
+ import { mat4x4_transpose_copy_to_mat4x3 } from "../../../../core/math/matrix/mat4x4_transpose_copy_to_mat4x3.js";
3
+ import { mesh_apply_skeletal_vertex_skinning } from "./mesh_apply_skeletal_vertex_skinning.js";
2
4
 
3
5
  /**
4
6
  * NOTE: the method is completely inlined for better performance. 0 function calls within the skinning loop
@@ -6,21 +8,27 @@ import { Matrix4 as ThreeMatrix4 } from "three";
6
8
  * @param {SkinnedMesh} mesh
7
9
  * @param {number} [destination_offset=0]
8
10
  */
9
- export function computeSkinnedMeshVertices(destination, mesh, destination_offset = 0) {
11
+ export function computeSkinnedMeshVertices(
12
+ destination,
13
+ mesh,
14
+ destination_offset = 0
15
+ ) {
16
+
10
17
  const geometry = mesh.geometry;
11
18
  const skeleton = mesh.skeleton;
12
19
 
13
- const tempMatrix = new ThreeMatrix4();
20
+ const tempMatrix = new Float32Array(16);
14
21
 
15
22
  const attributes = geometry.attributes;
16
23
 
17
24
  const positions = attributes.position.array;
18
- const skinIndicesArray = attributes.skinIndex.array;
19
- const skinWeightsArray = attributes.skinWeight.array;
25
+ const skin_indices_array = attributes.skinIndex.array;
26
+ const skin_weights_array = attributes.skinWeight.array;
20
27
 
21
- const vertexCount = attributes.position.count;
28
+ const vertex_count = attributes.position.count;
22
29
 
23
- const boneCount = skeleton.bones.length;
30
+ const bones = skeleton.bones;
31
+ const boneCount = bones.length;
24
32
 
25
33
  //pre-build transform matrices for bones
26
34
  const boneMatrixData = new Float32Array(boneCount * 12);
@@ -28,113 +36,19 @@ export function computeSkinnedMeshVertices(destination, mesh, destination_offset
28
36
  for (let boneIndex = 0; boneIndex < boneCount; boneIndex++) {
29
37
  const targetIndex = boneIndex * 12;
30
38
 
31
- tempMatrix.multiplyMatrices(skeleton.bones[boneIndex].matrixWorld, skeleton.boneInverses[boneIndex]);
32
-
33
- const el = tempMatrix.elements;
34
-
35
- //write matrix data in transposed form, to conform to access order when applied to Vector3 transformation
36
- boneMatrixData[targetIndex] = el[0];
37
- boneMatrixData[targetIndex + 1] = el[4];
38
- boneMatrixData[targetIndex + 2] = el[8];
39
- boneMatrixData[targetIndex + 3] = el[12];
39
+ m4_multiply(tempMatrix, bones[boneIndex].matrixWorld.elements, skeleton.boneInverses[boneIndex].elements);
40
40
 
41
- boneMatrixData[targetIndex + 4] = el[1];
42
- boneMatrixData[targetIndex + 5] = el[5];
43
- boneMatrixData[targetIndex + 6] = el[9];
44
- boneMatrixData[targetIndex + 7] = el[13];
45
-
46
- boneMatrixData[targetIndex + 8] = el[2];
47
- boneMatrixData[targetIndex + 9] = el[6];
48
- boneMatrixData[targetIndex + 10] = el[10];
49
- boneMatrixData[targetIndex + 11] = el[14];
41
+ // write matrix data in transposed form, to conform to access order when applied to Vector3 transformation
42
+ mat4x4_transpose_copy_to_mat4x3(
43
+ boneMatrixData, targetIndex,
44
+ tempMatrix, 0
45
+ );
50
46
  }
51
47
 
52
48
  const m4_bind = mesh.bindMatrix.elements;
53
49
 
54
- const m4_bind_0 = m4_bind[0];
55
- const m4_bind_1 = m4_bind[1];
56
- const m4_bind_2 = m4_bind[2];
57
- const m4_bind_4 = m4_bind[4];
58
- const m4_bing_5 = m4_bind[5];
59
- const m4_bing_6 = m4_bind[6];
60
- const m4_bing_8 = m4_bind[8];
61
- const m4_bing_9 = m4_bind[9];
62
- const m4_bing_10 = m4_bind[10];
63
- const m4_bing_12 = m4_bind[12];
64
- const m4_bing_13 = m4_bind[13];
65
- const m4_bing_14 = m4_bind[14];
66
-
50
+ // inverse of bind matrix
67
51
  const m4_bind_inv = mesh.bindMatrixInverse.elements;
68
52
 
69
- const m4_bind_inv_0 = m4_bind_inv[0];
70
- const m4_bind_inv_1 = m4_bind_inv[1];
71
- const m4_bind_inv_2 = m4_bind_inv[2];
72
- const m4_bind_inv_4 = m4_bind_inv[4];
73
- const m4_bind_inv_5 = m4_bind_inv[5];
74
- const m4_bind_inv_6 = m4_bind_inv[6];
75
- const m4_bind_inv_8 = m4_bind_inv[8];
76
- const m4_bind_inv_9 = m4_bind_inv[9];
77
- const m4_bind_inv_10 = m4_bind_inv[10];
78
- const m4_bind_inv_12 = m4_bind_inv[12];
79
- const m4_bind_inv_13 = m4_bind_inv[13];
80
- const m4_bind_inv_14 = m4_bind_inv[14];
81
-
82
- let index, i, x, y, z;
83
-
84
- for (index = 0; index < vertexCount; index++) {
85
-
86
- const index3 = index * 3;
87
- const index4 = index << 2;
88
-
89
- //read vertex position
90
- const px = positions[index3];
91
- const py = positions[index3 + 1];
92
- const pz = positions[index3 + 2];
93
-
94
- //apply bind matrix transform to vertex
95
- const bx = m4_bind_0 * px + m4_bind_4 * py + m4_bing_8 * pz + m4_bing_12;
96
- const by = m4_bind_1 * px + m4_bing_5 * py + m4_bing_9 * pz + m4_bing_13;
97
- const bz = m4_bind_2 * px + m4_bing_6 * py + m4_bing_10 * pz + m4_bing_14;
98
-
99
- x = 0;
100
- y = 0;
101
- z = 0;
102
-
103
- for (i = 0; i < 4; i++) {
104
- const skinIndex = index4 + i;
105
-
106
- const skinWeight = skinWeightsArray[skinIndex];
107
-
108
- if (skinWeight !== 0) {
109
-
110
- const boneIndex = skinIndicesArray[skinIndex];
111
-
112
- const bdIndex = boneIndex * 12;
113
-
114
- const sx = boneMatrixData[bdIndex] * bx + boneMatrixData[bdIndex + 1] * by + boneMatrixData[bdIndex + 2] * bz + boneMatrixData[bdIndex + 3];
115
- const sy = boneMatrixData[bdIndex + 4] * bx + boneMatrixData[bdIndex + 5] * by + boneMatrixData[bdIndex + 6] * bz + boneMatrixData[bdIndex + 7];
116
- const sz = boneMatrixData[bdIndex + 8] * bx + boneMatrixData[bdIndex + 9] * by + boneMatrixData[bdIndex + 10] * bz + boneMatrixData[bdIndex + 11];
117
-
118
- const tx = sx * skinWeight;
119
- const ty = sy * skinWeight;
120
- const tz = sz * skinWeight;
121
-
122
- x += tx;
123
- y += ty;
124
- z += tz;
125
-
126
- }
127
- }
128
-
129
- //apply inverse bind matrix
130
- const wx = m4_bind_inv_0 * x + m4_bind_inv_4 * y + m4_bind_inv_8 * z + m4_bind_inv_12;
131
- const wy = m4_bind_inv_1 * x + m4_bind_inv_5 * y + m4_bind_inv_9 * z + m4_bind_inv_13;
132
- const wz = m4_bind_inv_2 * x + m4_bind_inv_6 * y + m4_bind_inv_10 * z + m4_bind_inv_14;
133
-
134
- const destination_address = destination_offset + index3;
135
-
136
- destination[destination_address] = wx;
137
- destination[destination_address + 1] = wy;
138
- destination[destination_address + 2] = wz;
139
- }
53
+ mesh_apply_skeletal_vertex_skinning(destination, destination_offset, positions, vertex_count, skin_weights_array, skin_indices_array, boneMatrixData, m4_bind, m4_bind_inv);
140
54
  }
@@ -0,0 +1,15 @@
1
+ /**
2
+ *
3
+ * @param {number[]|Float32Array} destination
4
+ * @param {number} destination_offset
5
+ * @param {number[]|Float32Array} positions
6
+ * @param {number} vertex_count
7
+ * @param {number[]|Float32Array} skin_weights_array
8
+ * @param {number[]|Uint32Array} skin_indices_array
9
+ * @param {number[]|Float32Array} bone_matrices 4x3 transform matrices
10
+ * @param {number[]|Float32Array} m4_bind
11
+ * @param {number[]|Float32Array} m4_bind_inv
12
+ * @param {number} [bones_per_vertex]
13
+ */
14
+ export function mesh_apply_skeletal_vertex_skinning(destination: number[] | Float32Array, destination_offset: number, positions: number[] | Float32Array, vertex_count: number, skin_weights_array: number[] | Float32Array, skin_indices_array: number[] | Uint32Array, bone_matrices: number[] | Float32Array, m4_bind: number[] | Float32Array, m4_bind_inv: number[] | Float32Array, bones_per_vertex?: number): void;
15
+ //# sourceMappingURL=mesh_apply_skeletal_vertex_skinning.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mesh_apply_skeletal_vertex_skinning.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/geometry/skining/mesh_apply_skeletal_vertex_skinning.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,iEAXW,MAAM,EAAE,GAAC,YAAY,sBACrB,MAAM,aACN,MAAM,EAAE,GAAC,YAAY,gBACrB,MAAM,sBACN,MAAM,EAAE,GAAC,YAAY,sBACrB,MAAM,EAAE,GAAC,WAAW,iBACpB,MAAM,EAAE,GAAC,YAAY,WACrB,MAAM,EAAE,GAAC,YAAY,eACrB,MAAM,EAAE,GAAC,YAAY,qBACrB,MAAM,QAyEhB"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ *
3
+ * @param {number[]|Float32Array} destination
4
+ * @param {number} destination_offset
5
+ * @param {number[]|Float32Array} positions
6
+ * @param {number} vertex_count
7
+ * @param {number[]|Float32Array} skin_weights_array
8
+ * @param {number[]|Uint32Array} skin_indices_array
9
+ * @param {number[]|Float32Array} bone_matrices 4x3 transform matrices
10
+ * @param {number[]|Float32Array} m4_bind
11
+ * @param {number[]|Float32Array} m4_bind_inv
12
+ * @param {number} [bones_per_vertex]
13
+ */
14
+ export function mesh_apply_skeletal_vertex_skinning(
15
+ destination,
16
+ destination_offset,
17
+ positions,
18
+ vertex_count,
19
+ skin_weights_array,
20
+ skin_indices_array,
21
+ bone_matrices,
22
+ m4_bind,
23
+ m4_bind_inv,
24
+ bones_per_vertex = 4
25
+ ) {
26
+
27
+ let index, i, x, y, z;
28
+
29
+ for (index = 0; index < vertex_count; index++) {
30
+
31
+ const index3 = index * 3;
32
+
33
+ //read vertex position
34
+ const px = positions[index3];
35
+ const py = positions[index3 + 1];
36
+ const pz = positions[index3 + 2];
37
+
38
+ //apply bind matrix transform to vertex
39
+ const bx = m4_bind[0] * px + m4_bind[4] * py + m4_bind[8] * pz + m4_bind[12];
40
+ const by = m4_bind[1] * px + m4_bind[5] * py + m4_bind[9] * pz + m4_bind[13];
41
+ const bz = m4_bind[2] * px + m4_bind[6] * py + m4_bind[10] * pz + m4_bind[14];
42
+
43
+ x = 0;
44
+ y = 0;
45
+ z = 0;
46
+
47
+ for (i = 0; i < bones_per_vertex; i++) {
48
+
49
+ const skin_index = index * bones_per_vertex + i;
50
+
51
+ const skin_weight = skin_weights_array[skin_index];
52
+
53
+ if (skin_weight !== 0) {
54
+
55
+ const boneIndex = skin_indices_array[skin_index];
56
+
57
+ const bdIndex = boneIndex * 12;
58
+
59
+ const sx = bone_matrices[bdIndex] * bx + bone_matrices[bdIndex + 1] * by + bone_matrices[bdIndex + 2] * bz + bone_matrices[bdIndex + 3];
60
+ const sy = bone_matrices[bdIndex + 4] * bx + bone_matrices[bdIndex + 5] * by + bone_matrices[bdIndex + 6] * bz + bone_matrices[bdIndex + 7];
61
+ const sz = bone_matrices[bdIndex + 8] * bx + bone_matrices[bdIndex + 9] * by + bone_matrices[bdIndex + 10] * bz + bone_matrices[bdIndex + 11];
62
+
63
+ const tx = sx * skin_weight;
64
+ const ty = sy * skin_weight;
65
+ const tz = sz * skin_weight;
66
+
67
+ x += tx;
68
+ y += ty;
69
+ z += tz;
70
+
71
+ }
72
+ }
73
+
74
+ //apply inverse bind matrix
75
+ const wx = m4_bind_inv[0] * x + m4_bind_inv[4] * y + m4_bind_inv[8] * z + m4_bind_inv[12];
76
+ const wy = m4_bind_inv[1] * x + m4_bind_inv[5] * y + m4_bind_inv[9] * z + m4_bind_inv[13];
77
+ const wz = m4_bind_inv[2] * x + m4_bind_inv[6] * y + m4_bind_inv[10] * z + m4_bind_inv[14];
78
+
79
+ const destination_address = destination_offset + index3;
80
+
81
+ destination[destination_address] = wx;
82
+ destination[destination_address + 1] = wy;
83
+ destination[destination_address + 2] = wz;
84
+ }
85
+ }
@@ -4,7 +4,7 @@ export class RibbonXPlugin extends EnginePlugin {
4
4
  /**
5
5
  * @private
6
6
  * @readonly
7
- * @type {Cache<RibbonXMaterialSpec, Material>}
7
+ * @type {Cache<RibbonXMaterialSpec, RibbonMaterialX>}
8
8
  */
9
9
  private readonly materialCache;
10
10
  __shared_uniforms: {
@@ -1 +1 @@
1
- {"version":3,"file":"RibbonXPlugin.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/trail/x/RibbonXPlugin.js"],"names":[],"mappings":"AASA;IACI,8BA6BC;IA1BG,WAA2B;IAE3B;;;;OAIG;IACH,+BAKE;IAEF;;;;MAIC;IAED;;;;OAIG;IACH,oBAAwC;IAG5C,sCAIC;IAED,wBAMC;IAED,yBAKC;IAED;;;;OAIG;IACH,0EAIC;IAED;;;;OAIG;IACH,8CAFa,eAAe,CAe3B;IAGD;;;;;OAKG;IACH,yBAsCC;CACJ;6BAtI4B,iCAAiC;wBAL1B,OAAO;gCAOX,sBAAsB"}
1
+ {"version":3,"file":"RibbonXPlugin.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/trail/x/RibbonXPlugin.js"],"names":[],"mappings":"AASA;IACI,8BA6BC;IA1BG,WAA2B;IAE3B;;;;OAIG;IACH,+BAKE;IAEF;;;;MAIC;IAED;;;;OAIG;IACH,oBAAwC;IAG5C,sCAIC;IAED,wBAMC;IAED,yBAKC;IAED;;;;OAIG;IACH,0EAIC;IAED;;;;OAIG;IACH,8CAFa,eAAe,CAI3B;IAED;;;;;OAKG;IACH,yBAsCC;CACJ;6BA1H4B,iCAAiC;wBAL1B,OAAO;gCAOX,sBAAsB"}
@@ -16,7 +16,7 @@ export class RibbonXPlugin extends EnginePlugin {
16
16
  /**
17
17
  * @private
18
18
  * @readonly
19
- * @type {Cache<RibbonXMaterialSpec, Material>}
19
+ * @type {Cache<RibbonXMaterialSpec, RibbonMaterialX>}
20
20
  */
21
21
  this.materialCache = new Cache({
22
22
  maxWeight: 128,
@@ -77,21 +77,9 @@ export class RibbonXPlugin extends EnginePlugin {
77
77
  * @returns {RibbonMaterialX}
78
78
  */
79
79
  obtain_material_x(spec) {
80
- const existing = this.materialCache.get(spec);
81
-
82
- if (existing !== null) {
83
- return existing;
84
- }
85
-
86
- // material not found in cache
87
- const material = this.__build_material(spec);
88
-
89
- this.materialCache.put(spec, material);
90
-
91
- return material;
80
+ return this.materialCache.getOrCompute(spec, this.__build_material, this);
92
81
  }
93
82
 
94
-
95
83
  /**
96
84
  *
97
85
  * @param {RibbonXMaterialSpec} spec
@@ -14,8 +14,8 @@ export class BlackboardValue {
14
14
  * @type {DataType}
15
15
  */
16
16
  type: DataType;
17
- value: ObservedBoolean | Vector1;
17
+ value: Vector1 | ObservedBoolean;
18
18
  }
19
- import ObservedBoolean from "../../../core/model/ObservedBoolean.js";
20
19
  import Vector1 from "../../../core/geom/Vector1.js";
20
+ import ObservedBoolean from "../../../core/model/ObservedBoolean.js";
21
21
  //# sourceMappingURL=BlackboardValue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BlackboardValue.d.ts","sourceRoot":"","sources":["../../../../../src/engine/intelligence/blackboard/BlackboardValue.js"],"names":[],"mappings":"AA+BA;IACI;;;OAGG;IACH,4BAYC;IAXG;;;OAGG;IACH,gBAFU,MAAM,CAEO;IACvB;;;OAGG;IACH,eAAgB;IAChB,iCAAoC;CAE3C;4BA/C2B,wCAAwC;oBADhD,+BAA+B"}
1
+ {"version":3,"file":"BlackboardValue.d.ts","sourceRoot":"","sources":["../../../../../src/engine/intelligence/blackboard/BlackboardValue.js"],"names":[],"mappings":"AA+BA;IACI;;;OAGG;IACH,4BAYC;IAXG;;;OAGG;IACH,gBAFU,MAAM,CAEO;IACvB;;;OAGG;IACH,eAAgB;IAChB,iCAAoC;CAE3C;oBAhDmB,+BAA+B;4BACvB,wCAAwC"}