@woosh/meep-engine 2.36.16 → 2.36.17
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.
|
@@ -71,4 +71,16 @@ export class SurfacePoint3 {
|
|
|
71
71
|
this.position.copy(other.position);
|
|
72
72
|
this.normal.copy(other.normal);
|
|
73
73
|
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
*
|
|
77
|
+
* @returns {SurfacePoint3}
|
|
78
|
+
*/
|
|
79
|
+
clone() {
|
|
80
|
+
const r = new SurfacePoint3();
|
|
81
|
+
|
|
82
|
+
r.copy(this);
|
|
83
|
+
|
|
84
|
+
return r;
|
|
85
|
+
}
|
|
74
86
|
}
|
|
@@ -275,6 +275,91 @@ export class ShadedGeometrySystem extends System {
|
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
277
|
|
|
278
|
+
/**
|
|
279
|
+
*
|
|
280
|
+
* @param {number} origin_x
|
|
281
|
+
* @param {number} origin_y
|
|
282
|
+
* @param {number} origin_z
|
|
283
|
+
* @param {number} direction_x
|
|
284
|
+
* @param {number} direction_y
|
|
285
|
+
* @param {number} direction_z
|
|
286
|
+
* @param {function(entity:number, mesh:ShadedGeometry):boolean} [filter_function]
|
|
287
|
+
* @param {*} [filter_function_context]
|
|
288
|
+
* @returns {{entity:number, mesh:ShadedGeometry, contact: SurfacePoint3}[]}
|
|
289
|
+
*/
|
|
290
|
+
raycast(
|
|
291
|
+
origin_x, origin_y, origin_z,
|
|
292
|
+
direction_x, direction_y, direction_z,
|
|
293
|
+
filter_function = returnTrue, filter_function_context
|
|
294
|
+
) {
|
|
295
|
+
const result = [];
|
|
296
|
+
|
|
297
|
+
const hits = [];
|
|
298
|
+
|
|
299
|
+
const hit_count = bvh_query_leaves_generic(hits, 0, this.__bvh_binary, BVHQueryIntersectsRay.from([origin_x, origin_y, origin_z, direction_x, direction_y, direction_z]));
|
|
300
|
+
|
|
301
|
+
const ecd = this.entityManager.dataset;
|
|
302
|
+
|
|
303
|
+
if (ecd === null) {
|
|
304
|
+
// no ECD set
|
|
305
|
+
return result;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
const sg_component_index = ecd.computeComponentTypeIndex(ShadedGeometry);
|
|
309
|
+
|
|
310
|
+
for (let i = 0; i < hit_count; i++) {
|
|
311
|
+
const node_id = hits[i];
|
|
312
|
+
|
|
313
|
+
const entity = this.__bvh_binary.node_get_user_data(node_id);
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
*
|
|
317
|
+
* @type {ShadedGeometry}
|
|
318
|
+
*/
|
|
319
|
+
const sg = ecd.getComponentByIndex(entity, sg_component_index);
|
|
320
|
+
|
|
321
|
+
if (!filter_function.call(filter_function_context, entity, sg)) {
|
|
322
|
+
// filtered out
|
|
323
|
+
continue;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
const m4 = sg.transform;
|
|
327
|
+
|
|
328
|
+
// get transform in local space
|
|
329
|
+
mat4.invert(scratch_m4, m4);
|
|
330
|
+
|
|
331
|
+
ray3_array_compose(
|
|
332
|
+
scratch_ray_0,
|
|
333
|
+
origin_x, origin_y, origin_z,
|
|
334
|
+
direction_x, direction_y, direction_z
|
|
335
|
+
);
|
|
336
|
+
|
|
337
|
+
// transform ray to local space
|
|
338
|
+
ray3_array_apply_matrix4(scratch_ray_0, scratch_ray_0, scratch_m4);
|
|
339
|
+
|
|
340
|
+
const geometry_hit_found = GeometrySpatialQueryAccelerator.INSTANCE.queryRaycastNearest_array(
|
|
341
|
+
scratch_point,
|
|
342
|
+
sg.geometry,
|
|
343
|
+
scratch_ray_0
|
|
344
|
+
);
|
|
345
|
+
|
|
346
|
+
if (!geometry_hit_found) {
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// transform hit contact into global space
|
|
351
|
+
scratch_point.applyMatrix4(m4);
|
|
352
|
+
|
|
353
|
+
result.push({
|
|
354
|
+
entity,
|
|
355
|
+
mesh: sg,
|
|
356
|
+
contact: scratch_point.clone()
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
return result;
|
|
361
|
+
}
|
|
362
|
+
|
|
278
363
|
/**
|
|
279
364
|
*
|
|
280
365
|
* @param {SurfacePoint3} contact
|
|
@@ -327,6 +412,10 @@ export class ShadedGeometrySystem extends System {
|
|
|
327
412
|
continue;
|
|
328
413
|
}
|
|
329
414
|
|
|
415
|
+
/**
|
|
416
|
+
*
|
|
417
|
+
* @type {number[]|mat4|null}
|
|
418
|
+
*/
|
|
330
419
|
const m4 = sg.transform;
|
|
331
420
|
|
|
332
421
|
// get transform in local space
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"productName": "Meep",
|
|
6
6
|
"description": "production-ready JavaScript game engine based on Entity Component System Architecture",
|
|
7
7
|
"author": "Alexander Goldring",
|
|
8
|
-
"version": "2.36.
|
|
8
|
+
"version": "2.36.17",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"gl-matrix": "3.4.3",
|
|
11
11
|
"fast-levenshtein": "2.0.6",
|