@woosh/meep-engine 2.119.39 → 2.119.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.
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "description": "Fully featured ECS game engine written in JavaScript",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.119.39",
8
+ "version": "2.119.40",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -1 +1 @@
1
- {"version":3,"file":"computeTriangleClosestPointToPointBarycentric.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/triangle/computeTriangleClosestPointToPointBarycentric.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,sEAhBW,MAAM,EAAE,iBACR,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,IAAI,CAgIhB"}
1
+ {"version":3,"file":"computeTriangleClosestPointToPointBarycentric.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/triangle/computeTriangleClosestPointToPointBarycentric.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,sEAhBW,MAAM,EAAE,iBACR,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,IAAI,CAoJhB"}
@@ -24,7 +24,7 @@ export function computeTriangleClosestPointToPointBarycentric(
24
24
  ax, ay, az,
25
25
  bx, by, bz,
26
26
  cx, cy, cz
27
- ){
27
+ ) {
28
28
  // adapted from https://github.com/mrdoob/three.js/blob/676e85dc7cd5971a6565c4152e9e6d8bdd20a2b7/src/math/Triangle.js#L222
29
29
 
30
30
  let v, w;
@@ -48,15 +48,15 @@ export function computeTriangleClosestPointToPointBarycentric(
48
48
  const _vap_y = py - ay;
49
49
  const _vap_z = pz - az;
50
50
 
51
- const d1 = v3_dot(_vab_x, _vab_y, _vab_z, _vap_x, _vap_y, _vap_z );
52
- const d2 = v3_dot(_vac_x, _vac_y, _vac_z, _vap_x, _vap_y, _vap_z );
51
+ const d1 = v3_dot(_vab_x, _vab_y, _vab_z, _vap_x, _vap_y, _vap_z);
52
+ const d2 = v3_dot(_vac_x, _vac_y, _vac_z, _vap_x, _vap_y, _vap_z);
53
53
 
54
- if ( d1 <= 0 && d2 <= 0 ) {
54
+ if (d1 <= 0 && d2 <= 0) {
55
55
 
56
56
  // vertex region of A; barycentric coords (1, 0, 0)
57
57
 
58
58
  result[result_offset] = 1;
59
- result[result_offset+1] = 0;
59
+ result[result_offset + 1] = 0;
60
60
 
61
61
  return;
62
62
 
@@ -66,28 +66,34 @@ export function computeTriangleClosestPointToPointBarycentric(
66
66
  const _vbp_y = py - by;
67
67
  const _vbp_z = pz - bz;
68
68
 
69
- const d3 = v3_dot(_vab_x, _vab_y, _vab_z, _vbp_x, _vbp_y, _vbp_z );
70
- const d4 = v3_dot(_vac_x, _vac_y, _vac_z, _vbp_x, _vbp_y, _vbp_z );
69
+ const d3 = v3_dot(_vab_x, _vab_y, _vab_z, _vbp_x, _vbp_y, _vbp_z);
70
+ const d4 = v3_dot(_vac_x, _vac_y, _vac_z, _vbp_x, _vbp_y, _vbp_z);
71
71
 
72
- if ( d3 >= 0 && d4 <= d3 ) {
72
+ if (d3 >= 0 && d4 <= d3) {
73
73
 
74
74
  // vertex region of B; barycentric coords (0, 1, 0)
75
75
 
76
76
  result[result_offset] = 0;
77
- result[result_offset+1] = 1;
77
+ result[result_offset + 1] = 1;
78
78
 
79
79
  return;
80
80
 
81
81
  }
82
82
 
83
83
  const vc = d1 * d4 - d3 * d2;
84
- if ( vc <= 0 && d1 >= 0 && d3 <= 0 && d1 !== d3) {
84
+ if (vc <= 0 && d1 >= 0 && d3 <= 0) {
85
85
 
86
- v = d1 / ( d1 - d3 );
86
+ const s = d1 - d3;
87
+
88
+ if (s !== 0) {
89
+ v = d1 / s;
90
+ } else {
91
+ v = 0;
92
+ }
87
93
  // edge region of AB; barycentric coords (1-v, v, 0)
88
94
 
89
- result[result_offset] = 1-v;
90
- result[result_offset+1] = v;
95
+ result[result_offset] = 1 - v;
96
+ result[result_offset + 1] = v;
91
97
 
92
98
  return;
93
99
 
@@ -97,52 +103,65 @@ export function computeTriangleClosestPointToPointBarycentric(
97
103
  const _vcp_y = py - cy;
98
104
  const _vcp_z = pz - cz;
99
105
 
100
- const d5 = v3_dot(_vab_x, _vab_y, _vab_z, _vcp_x, _vcp_y, _vcp_z );
101
- const d6 = v3_dot(_vac_x, _vac_y, _vac_z, _vcp_x, _vcp_y, _vcp_z );
106
+ const d5 = v3_dot(_vab_x, _vab_y, _vab_z, _vcp_x, _vcp_y, _vcp_z);
107
+ const d6 = v3_dot(_vac_x, _vac_y, _vac_z, _vcp_x, _vcp_y, _vcp_z);
102
108
 
103
- if ( d6 >= 0 && d5 <= d6 ) {
109
+ if (d6 >= 0 && d5 <= d6) {
104
110
 
105
111
  // vertex region of C; barycentric coords (0, 0, 1)
106
112
 
107
113
  result[result_offset] = 0;
108
- result[result_offset+1] = 0;
114
+ result[result_offset + 1] = 0;
109
115
 
110
116
  return;
111
117
 
112
118
  }
113
119
 
114
120
  const vb = d5 * d2 - d1 * d6;
115
- if ( vb <= 0 && d2 >= 0 && d6 <= 0 && d2 !== d6 ) {
121
+ if (vb <= 0 && d2 >= 0 && d6 <= 0) {
122
+
123
+ const s = d2 - d6;
116
124
 
117
- w = d2 / ( d2 - d6 );
125
+ if (s !== 0) {
126
+ w = d2 / s;
127
+ } else {
128
+ w = 0;
129
+ }
118
130
 
119
131
  // edge region of AC; barycentric coords (1-w, 0, w)
120
132
 
121
- result[result_offset] = 1-w;
122
- result[result_offset+1] = 0;
133
+ result[result_offset] = 1 - w;
134
+ result[result_offset + 1] = 0;
123
135
 
124
136
  return;
125
137
 
126
138
  }
127
139
 
128
140
  const va = d3 * d6 - d5 * d4;
129
- if ( va <= 0 && ( d4 - d3 ) >= 0 && ( d5 - d6 ) >= 0 ) {
141
+ if (va <= 0 && (d4 - d3) >= 0 && (d5 - d6) >= 0) {
142
+
143
+ const s = (d4 - d3) + (d5 - d6);
144
+
145
+ if(s !== 0) {
146
+ w = (d4 - d3) / s;
147
+ }else{
148
+ w = 1;
149
+ }
130
150
 
131
- w = ( d4 - d3 ) / ( ( d4 - d3 ) + ( d5 - d6 ) );
132
151
  // edge region of BC; barycentric coords (0, 1-w, w)
133
152
 
134
153
  result[result_offset] = 0;
135
- result[result_offset+1] = 1-w;
154
+ result[result_offset + 1] = 1 - w;
136
155
 
137
156
  return;
138
157
 
139
158
  }
140
159
 
141
160
  // face region
142
- const denom = 1 / ( va + vb + vc );
161
+ const denom = 1 / (va + vb + vc);
143
162
  const u = va * denom
144
163
  v = vb * denom;
145
164
 
146
165
  result[result_offset] = u;
147
- result[result_offset+1] = v;
166
+ result[result_offset + 1] = v;
148
167
  }
@@ -1 +1 @@
1
- {"version":3,"file":"query_bvh_geometry_nearest.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/geometry/buffered/query/query_bvh_geometry_nearest.js"],"names":[],"mappings":"AAwBA;;;;;;;;;;;GAWG;AACH,uFARW,MAAM,EAAE,GAAC,YAAY,WACrB,MAAM,EAAE,GAAC,WAAW,GAAC,WAAW,KAChC,MAAM,KACN,MAAM,KACN,MAAM,gBACN,MAAM,GACL,OAAO,CA2KlB"}
1
+ {"version":3,"file":"query_bvh_geometry_nearest.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/geometry/buffered/query/query_bvh_geometry_nearest.js"],"names":[],"mappings":"AAwBA;;;;;;;;;;;GAWG;AACH,uFARW,MAAM,EAAE,GAAC,YAAY,WACrB,MAAM,EAAE,GAAC,WAAW,GAAC,WAAW,KAChC,MAAM,KACN,MAAM,KACN,MAAM,gBACN,MAAM,GACL,OAAO,CA8KlB"}
@@ -180,7 +180,10 @@ export function query_bvh_geometry_nearest(
180
180
  const contact_y = (by - ay) * v + (cy - ay) * w + ay;
181
181
  const contact_z = (bz - az) * v + (cz - az) * w + az;
182
182
 
183
- const distance_to_triangle_sqr = v3_distance_sqr(contact_x, contact_y, contact_z, x, y, z);
183
+ const distance_to_triangle_sqr = v3_distance_sqr(
184
+ contact_x, contact_y, contact_z,
185
+ x, y, z
186
+ );
184
187
 
185
188
  if (distance_to_triangle_sqr >= nearest_distance_sqr) {
186
189
  continue;