@woosh/meep-engine 2.39.7 → 2.39.9
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { v3_dot } from "../../v3_dot.js";
|
|
2
|
+
import { assert } from "../../../assert.js";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* NOTE: adapted from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteIntrRay3Triangle3.h
|
|
@@ -29,6 +30,44 @@ export function computeTriangleRayIntersection(
|
|
|
29
30
|
bx, by, bz,
|
|
30
31
|
cx, cy, cz
|
|
31
32
|
) {
|
|
33
|
+
assert.isNumber(ax,'ax');
|
|
34
|
+
assert.isNumber(ay,'ay');
|
|
35
|
+
assert.isNumber(az,'az');
|
|
36
|
+
|
|
37
|
+
assert.isNumber(bx,'bx');
|
|
38
|
+
assert.isNumber(by,'by');
|
|
39
|
+
assert.isNumber(bz,'bz');
|
|
40
|
+
|
|
41
|
+
assert.isNumber(cx,'cx');
|
|
42
|
+
assert.isNumber(cy,'cy');
|
|
43
|
+
assert.isNumber(cz,'cz');
|
|
44
|
+
|
|
45
|
+
// nan checks
|
|
46
|
+
assert.notNaN(ax,'ax');
|
|
47
|
+
assert.notNaN(ay,'ay');
|
|
48
|
+
assert.notNaN(az,'az');
|
|
49
|
+
|
|
50
|
+
assert.notNaN(bx,'bx');
|
|
51
|
+
assert.notNaN(by,'by');
|
|
52
|
+
assert.notNaN(bz,'bz');
|
|
53
|
+
|
|
54
|
+
assert.notNaN(cx,'cx');
|
|
55
|
+
assert.notNaN(cy,'cy');
|
|
56
|
+
assert.notNaN(cz,'cz');
|
|
57
|
+
|
|
58
|
+
// finate number check
|
|
59
|
+
assert.isFiniteNumber(ax,'ax');
|
|
60
|
+
assert.isFiniteNumber(ay,'ay');
|
|
61
|
+
assert.isFiniteNumber(az,'az');
|
|
62
|
+
|
|
63
|
+
assert.isFiniteNumber(bx,'bx');
|
|
64
|
+
assert.isFiniteNumber(by,'by');
|
|
65
|
+
assert.isFiniteNumber(bz,'bz');
|
|
66
|
+
|
|
67
|
+
assert.isFiniteNumber(cx,'cx');
|
|
68
|
+
assert.isFiniteNumber(cy,'cy');
|
|
69
|
+
assert.isFiniteNumber(cz,'cz');
|
|
70
|
+
|
|
32
71
|
|
|
33
72
|
// edge1 = a - b
|
|
34
73
|
const edge1_x = bx - ax;
|
package/engine/Engine.js
CHANGED
|
@@ -148,7 +148,7 @@ export class TubePathStyle {
|
|
|
148
148
|
assert.greaterThanOrEqual(path_mask.length, 2, 'path_mask length bust be at least 2');
|
|
149
149
|
assert.ok(path_mask.length % 2 === 0, 'path_mask length bust be multiple of 2');
|
|
150
150
|
assert.enum(cap_type, CapType, 'cap_type');
|
|
151
|
-
assert.enum(path_normal_type, 'path_normal_type');
|
|
151
|
+
assert.enum(path_normal_type, PathNormalType, 'path_normal_type');
|
|
152
152
|
|
|
153
153
|
if (shape === undefined) {
|
|
154
154
|
// legacy API, using circle
|
|
@@ -4,6 +4,7 @@ import Vector3 from "../../../../../core/geom/Vector3.js";
|
|
|
4
4
|
import { computeTriangleRayIntersection } from "../../../../../core/geom/3d/triangle/computeTriangleRayIntersection.js";
|
|
5
5
|
import { GeometrySpatialAcceleratorVisitor } from "./GeometryVisitor.js";
|
|
6
6
|
import { aabb3_intersects_ray } from "../../../../../core/bvh2/aabb3/aabb3_intersects_ray.js";
|
|
7
|
+
import { assert } from "../../../../../core/assert.js";
|
|
7
8
|
|
|
8
9
|
export class RaycastNearestHitComputingVisitor extends GeometrySpatialAcceleratorVisitor {
|
|
9
10
|
constructor() {
|
|
@@ -18,14 +19,14 @@ export class RaycastNearestHitComputingVisitor extends GeometrySpatialAccelerato
|
|
|
18
19
|
this.__nearest_distance = Number.POSITIVE_INFINITY;
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
|
-
*
|
|
22
|
+
* @readonly
|
|
22
23
|
* @type {SurfacePoint3}
|
|
23
24
|
* @private
|
|
24
25
|
*/
|
|
25
26
|
this.__nearest_hit = new SurfacePoint3();
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
|
-
*
|
|
29
|
+
* @readonly
|
|
29
30
|
* @type {SurfacePoint3}
|
|
30
31
|
* @private
|
|
31
32
|
*/
|
|
@@ -39,7 +40,18 @@ export class RaycastNearestHitComputingVisitor extends GeometrySpatialAccelerato
|
|
|
39
40
|
*/
|
|
40
41
|
this.__hit_found = false;
|
|
41
42
|
|
|
43
|
+
/**
|
|
44
|
+
* @readonly
|
|
45
|
+
* @type {Vector3}
|
|
46
|
+
* @private
|
|
47
|
+
*/
|
|
42
48
|
this.__ray_origin = new Vector3();
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @readonly
|
|
52
|
+
* @type {Vector3}
|
|
53
|
+
* @private
|
|
54
|
+
*/
|
|
43
55
|
this.__ray_direction = new Vector3();
|
|
44
56
|
}
|
|
45
57
|
|
|
@@ -98,6 +110,8 @@ export class RaycastNearestHitComputingVisitor extends GeometrySpatialAccelerato
|
|
|
98
110
|
|
|
99
111
|
const indices = this.__buffer_indices;
|
|
100
112
|
|
|
113
|
+
assert.lessThan(index3 + 2, indices.length, 'triangle index overflow, possibly geometry changed but tree was not rebuilt?');
|
|
114
|
+
|
|
101
115
|
const a = indices[index3];
|
|
102
116
|
const b = indices[index3 + 1];
|
|
103
117
|
const c = indices[index3 + 2];
|
|
@@ -111,6 +125,10 @@ export class RaycastNearestHitComputingVisitor extends GeometrySpatialAccelerato
|
|
|
111
125
|
const b_address = b * stride + offset;
|
|
112
126
|
const c_address = c * stride + offset;
|
|
113
127
|
|
|
128
|
+
assert.lessThan(a_address + 2, vertices.length, 'a-vertex overflow');
|
|
129
|
+
assert.lessThan(b_address + 2, vertices.length, 'b-vertex overflow');
|
|
130
|
+
assert.lessThan(c_address + 2, vertices.length, 'c-vertex overflow');
|
|
131
|
+
|
|
114
132
|
const ax = vertices[a_address];
|
|
115
133
|
const ay = vertices[a_address + 1];
|
|
116
134
|
const az = vertices[a_address + 2];
|
|
@@ -123,8 +141,10 @@ export class RaycastNearestHitComputingVisitor extends GeometrySpatialAccelerato
|
|
|
123
141
|
const cy = vertices[c_address + 1];
|
|
124
142
|
const cz = vertices[c_address + 2];
|
|
125
143
|
|
|
144
|
+
const temp_hit = this.__temp_hit;
|
|
145
|
+
|
|
126
146
|
if (computeTriangleRayIntersection(
|
|
127
|
-
|
|
147
|
+
temp_hit,
|
|
128
148
|
rayOrigin.x,
|
|
129
149
|
rayOrigin.y,
|
|
130
150
|
rayOrigin.z,
|
|
@@ -135,10 +155,10 @@ export class RaycastNearestHitComputingVisitor extends GeometrySpatialAccelerato
|
|
|
135
155
|
bx, by, bz,
|
|
136
156
|
cx, cy, cz
|
|
137
157
|
)) {
|
|
138
|
-
const d =
|
|
158
|
+
const d = temp_hit.position.distanceSqrTo(rayOrigin);
|
|
139
159
|
|
|
140
160
|
if (d < this.__nearest_distance) {
|
|
141
|
-
this.__nearest_hit.copy(
|
|
161
|
+
this.__nearest_hit.copy(temp_hit);
|
|
142
162
|
this.__nearest_distance = d;
|
|
143
163
|
|
|
144
164
|
this.__hit_found = true;
|
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.39.
|
|
8
|
+
"version": "2.39.9",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"gl-matrix": "3.4.3",
|
|
11
11
|
"fast-levenshtein": "2.0.6",
|