@shapediver/viewer.shared.math 3.16.8 → 3.16.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.
- package/dist/implementation/Box.d.ts +24 -24
- package/dist/implementation/Box.js +200 -200
- package/dist/implementation/Box.js.map +1 -1
- package/dist/implementation/Plane.d.ts +27 -27
- package/dist/implementation/Plane.js +102 -102
- package/dist/implementation/Plane.js.map +1 -1
- package/dist/implementation/Sphere.d.ts +19 -19
- package/dist/implementation/Sphere.js +95 -95
- package/dist/implementation/Sphere.js.map +1 -1
- package/dist/implementation/Spherical.d.ts +17 -17
- package/dist/implementation/Spherical.js +51 -51
- package/dist/implementation/Spherical.js.map +1 -1
- package/dist/implementation/Triangle.d.ts +12 -12
- package/dist/implementation/Triangle.js +50 -50
- package/dist/index.d.ts +7 -7
- package/dist/index.js +13 -13
- package/package.json +5 -5
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { ITriangle } from "@shapediver/viewer.shared.types";
|
|
2
|
-
import { mat4, vec3 } from "gl-matrix";
|
|
3
|
-
export declare class Triangle implements ITriangle {
|
|
4
|
-
private _v0;
|
|
5
|
-
private _v1;
|
|
6
|
-
private _v2;
|
|
7
|
-
constructor(_v0?: vec3, _v1?: vec3, _v2?: vec3);
|
|
8
|
-
applyMatrix(matrix: mat4): ITriangle;
|
|
9
|
-
clone(): ITriangle;
|
|
10
|
-
intersect(origin: vec3, direction: vec3): vec3 | null;
|
|
11
|
-
reset(): void;
|
|
12
|
-
}
|
|
1
|
+
import { ITriangle } from "@shapediver/viewer.shared.types";
|
|
2
|
+
import { mat4, vec3 } from "gl-matrix";
|
|
3
|
+
export declare class Triangle implements ITriangle {
|
|
4
|
+
private _v0;
|
|
5
|
+
private _v1;
|
|
6
|
+
private _v2;
|
|
7
|
+
constructor(_v0?: vec3, _v1?: vec3, _v2?: vec3);
|
|
8
|
+
applyMatrix(matrix: mat4): ITriangle;
|
|
9
|
+
clone(): ITriangle;
|
|
10
|
+
intersect(origin: vec3, direction: vec3): vec3 | null;
|
|
11
|
+
reset(): void;
|
|
12
|
+
}
|
|
13
13
|
//# sourceMappingURL=Triangle.d.ts.map
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Triangle = void 0;
|
|
4
|
-
const gl_matrix_1 = require("gl-matrix");
|
|
5
|
-
class Triangle {
|
|
6
|
-
constructor(_v0 = gl_matrix_1.vec3.create(), _v1 = gl_matrix_1.vec3.create(), _v2 = gl_matrix_1.vec3.create()) {
|
|
7
|
-
this._v0 = _v0;
|
|
8
|
-
this._v1 = _v1;
|
|
9
|
-
this._v2 = _v2;
|
|
10
|
-
}
|
|
11
|
-
applyMatrix(matrix) {
|
|
12
|
-
gl_matrix_1.vec3.transformMat4(this._v0, this._v0, matrix);
|
|
13
|
-
gl_matrix_1.vec3.transformMat4(this._v1, this._v1, matrix);
|
|
14
|
-
gl_matrix_1.vec3.transformMat4(this._v2, this._v2, matrix);
|
|
15
|
-
return this;
|
|
16
|
-
}
|
|
17
|
-
clone() {
|
|
18
|
-
return new Triangle(gl_matrix_1.vec3.clone(this._v0), gl_matrix_1.vec3.clone(this._v1), gl_matrix_1.vec3.clone(this._v2));
|
|
19
|
-
}
|
|
20
|
-
// Möller–Trumbore intersection algorithm
|
|
21
|
-
intersect(origin, direction) {
|
|
22
|
-
const EPSILON = 0.0000001;
|
|
23
|
-
const edge1 = gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), this._v1, this._v0);
|
|
24
|
-
const edge2 = gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), this._v2, this._v0);
|
|
25
|
-
const h = gl_matrix_1.vec3.cross(gl_matrix_1.vec3.create(), direction, edge2);
|
|
26
|
-
const a = gl_matrix_1.vec3.dot(edge1, h);
|
|
27
|
-
if (a > -EPSILON && a < EPSILON)
|
|
28
|
-
return null; // This ray is parallel to this triangle.
|
|
29
|
-
const f = 1.0 / a;
|
|
30
|
-
const s = gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), origin, this._v0);
|
|
31
|
-
const u = f * gl_matrix_1.vec3.dot(s, h);
|
|
32
|
-
if (u < 0.0 || u > 1.0)
|
|
33
|
-
return null;
|
|
34
|
-
const q = gl_matrix_1.vec3.cross(gl_matrix_1.vec3.create(), s, edge1);
|
|
35
|
-
const v = f * gl_matrix_1.vec3.dot(direction, q);
|
|
36
|
-
if (v < 0.0 || u + v > 1.0)
|
|
37
|
-
return null;
|
|
38
|
-
// At this stage we can compute t to find out where the intersection point is on the line.
|
|
39
|
-
const t = f * gl_matrix_1.vec3.dot(edge2, q);
|
|
40
|
-
return t > EPSILON
|
|
41
|
-
? gl_matrix_1.vec3.add(gl_matrix_1.vec3.create(), gl_matrix_1.vec3.multiply(gl_matrix_1.vec3.create(), direction, gl_matrix_1.vec3.fromValues(t, t, t)), origin)
|
|
42
|
-
: null;
|
|
43
|
-
}
|
|
44
|
-
reset() {
|
|
45
|
-
this._v0 = gl_matrix_1.vec3.create();
|
|
46
|
-
this._v1 = gl_matrix_1.vec3.create();
|
|
47
|
-
this._v2 = gl_matrix_1.vec3.create();
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
exports.Triangle = Triangle;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Triangle = void 0;
|
|
4
|
+
const gl_matrix_1 = require("gl-matrix");
|
|
5
|
+
class Triangle {
|
|
6
|
+
constructor(_v0 = gl_matrix_1.vec3.create(), _v1 = gl_matrix_1.vec3.create(), _v2 = gl_matrix_1.vec3.create()) {
|
|
7
|
+
this._v0 = _v0;
|
|
8
|
+
this._v1 = _v1;
|
|
9
|
+
this._v2 = _v2;
|
|
10
|
+
}
|
|
11
|
+
applyMatrix(matrix) {
|
|
12
|
+
gl_matrix_1.vec3.transformMat4(this._v0, this._v0, matrix);
|
|
13
|
+
gl_matrix_1.vec3.transformMat4(this._v1, this._v1, matrix);
|
|
14
|
+
gl_matrix_1.vec3.transformMat4(this._v2, this._v2, matrix);
|
|
15
|
+
return this;
|
|
16
|
+
}
|
|
17
|
+
clone() {
|
|
18
|
+
return new Triangle(gl_matrix_1.vec3.clone(this._v0), gl_matrix_1.vec3.clone(this._v1), gl_matrix_1.vec3.clone(this._v2));
|
|
19
|
+
}
|
|
20
|
+
// Möller–Trumbore intersection algorithm
|
|
21
|
+
intersect(origin, direction) {
|
|
22
|
+
const EPSILON = 0.0000001;
|
|
23
|
+
const edge1 = gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), this._v1, this._v0);
|
|
24
|
+
const edge2 = gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), this._v2, this._v0);
|
|
25
|
+
const h = gl_matrix_1.vec3.cross(gl_matrix_1.vec3.create(), direction, edge2);
|
|
26
|
+
const a = gl_matrix_1.vec3.dot(edge1, h);
|
|
27
|
+
if (a > -EPSILON && a < EPSILON)
|
|
28
|
+
return null; // This ray is parallel to this triangle.
|
|
29
|
+
const f = 1.0 / a;
|
|
30
|
+
const s = gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), origin, this._v0);
|
|
31
|
+
const u = f * gl_matrix_1.vec3.dot(s, h);
|
|
32
|
+
if (u < 0.0 || u > 1.0)
|
|
33
|
+
return null;
|
|
34
|
+
const q = gl_matrix_1.vec3.cross(gl_matrix_1.vec3.create(), s, edge1);
|
|
35
|
+
const v = f * gl_matrix_1.vec3.dot(direction, q);
|
|
36
|
+
if (v < 0.0 || u + v > 1.0)
|
|
37
|
+
return null;
|
|
38
|
+
// At this stage we can compute t to find out where the intersection point is on the line.
|
|
39
|
+
const t = f * gl_matrix_1.vec3.dot(edge2, q);
|
|
40
|
+
return t > EPSILON
|
|
41
|
+
? gl_matrix_1.vec3.add(gl_matrix_1.vec3.create(), gl_matrix_1.vec3.multiply(gl_matrix_1.vec3.create(), direction, gl_matrix_1.vec3.fromValues(t, t, t)), origin)
|
|
42
|
+
: null;
|
|
43
|
+
}
|
|
44
|
+
reset() {
|
|
45
|
+
this._v0 = gl_matrix_1.vec3.create();
|
|
46
|
+
this._v1 = gl_matrix_1.vec3.create();
|
|
47
|
+
this._v2 = gl_matrix_1.vec3.create();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.Triangle = Triangle;
|
|
51
51
|
//# sourceMappingURL=Triangle.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { IBox, IGeometry, IPlane, ISphere, ISpherical, ITriangle } from "@shapediver/viewer.shared.types";
|
|
2
|
-
import { Box } from "./implementation/Box";
|
|
3
|
-
import { Plane } from "./implementation/Plane";
|
|
4
|
-
import { Sphere } from "./implementation/Sphere";
|
|
5
|
-
import { Spherical } from "./implementation/Spherical";
|
|
6
|
-
import { Triangle } from "./implementation/Triangle";
|
|
7
|
-
export { IBox, ISphere, ISpherical, IPlane, ITriangle, IGeometry, Box, Sphere, Spherical, Plane, Triangle, };
|
|
1
|
+
import { IBox, IGeometry, IPlane, ISphere, ISpherical, ITriangle } from "@shapediver/viewer.shared.types";
|
|
2
|
+
import { Box } from "./implementation/Box";
|
|
3
|
+
import { Plane } from "./implementation/Plane";
|
|
4
|
+
import { Sphere } from "./implementation/Sphere";
|
|
5
|
+
import { Spherical } from "./implementation/Spherical";
|
|
6
|
+
import { Triangle } from "./implementation/Triangle";
|
|
7
|
+
export { IBox, ISphere, ISpherical, IPlane, ITriangle, IGeometry, Box, Sphere, Spherical, Plane, Triangle, };
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Triangle = exports.Plane = exports.Spherical = exports.Sphere = exports.Box = void 0;
|
|
4
|
-
const Box_1 = require("./implementation/Box");
|
|
5
|
-
Object.defineProperty(exports, "Box", { enumerable: true, get: function () { return Box_1.Box; } });
|
|
6
|
-
const Plane_1 = require("./implementation/Plane");
|
|
7
|
-
Object.defineProperty(exports, "Plane", { enumerable: true, get: function () { return Plane_1.Plane; } });
|
|
8
|
-
const Sphere_1 = require("./implementation/Sphere");
|
|
9
|
-
Object.defineProperty(exports, "Sphere", { enumerable: true, get: function () { return Sphere_1.Sphere; } });
|
|
10
|
-
const Spherical_1 = require("./implementation/Spherical");
|
|
11
|
-
Object.defineProperty(exports, "Spherical", { enumerable: true, get: function () { return Spherical_1.Spherical; } });
|
|
12
|
-
const Triangle_1 = require("./implementation/Triangle");
|
|
13
|
-
Object.defineProperty(exports, "Triangle", { enumerable: true, get: function () { return Triangle_1.Triangle; } });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Triangle = exports.Plane = exports.Spherical = exports.Sphere = exports.Box = void 0;
|
|
4
|
+
const Box_1 = require("./implementation/Box");
|
|
5
|
+
Object.defineProperty(exports, "Box", { enumerable: true, get: function () { return Box_1.Box; } });
|
|
6
|
+
const Plane_1 = require("./implementation/Plane");
|
|
7
|
+
Object.defineProperty(exports, "Plane", { enumerable: true, get: function () { return Plane_1.Plane; } });
|
|
8
|
+
const Sphere_1 = require("./implementation/Sphere");
|
|
9
|
+
Object.defineProperty(exports, "Sphere", { enumerable: true, get: function () { return Sphere_1.Sphere; } });
|
|
10
|
+
const Spherical_1 = require("./implementation/Spherical");
|
|
11
|
+
Object.defineProperty(exports, "Spherical", { enumerable: true, get: function () { return Spherical_1.Spherical; } });
|
|
12
|
+
const Triangle_1 = require("./implementation/Triangle");
|
|
13
|
+
Object.defineProperty(exports, "Triangle", { enumerable: true, get: function () { return Triangle_1.Triangle; } });
|
|
14
14
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shapediver/viewer.shared.math",
|
|
3
|
-
"version": "3.16.
|
|
3
|
+
"version": "3.16.9",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "Michael Oppitz <michael@shapediver.com>",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"testEnvironment": "node"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@shapediver/viewer.shared.services": "3.16.
|
|
42
|
-
"@shapediver/viewer.shared.types": "3.16.
|
|
43
|
-
"gl-matrix": "3.
|
|
41
|
+
"@shapediver/viewer.shared.services": "3.16.9",
|
|
42
|
+
"@shapediver/viewer.shared.types": "3.16.9",
|
|
43
|
+
"gl-matrix": "3.4.4"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "a0c09ebab3b0b75f36130a56d9ed81436846e3c7"
|
|
46
46
|
}
|