@ac-kit/math-geometry 0.2.3 → 0.4.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.
- package/CHANGELOG.md +321 -0
- package/README.md +363 -52
- package/dist/_brand.d.ts +14 -0
- package/dist/_brand.d.ts.map +1 -0
- package/dist/_brand.js +2 -0
- package/dist/_brand.js.map +1 -0
- package/dist/_ear-clipping.d.ts +20 -0
- package/dist/_ear-clipping.d.ts.map +1 -0
- package/dist/_ear-clipping.js +360 -0
- package/dist/_ear-clipping.js.map +1 -0
- package/dist/_polygon3-cross.d.ts +23 -0
- package/dist/_polygon3-cross.d.ts.map +1 -0
- package/dist/_polygon3-cross.js +418 -0
- package/dist/_polygon3-cross.js.map +1 -0
- package/dist/_ray3-intersect.d.ts +19 -0
- package/dist/_ray3-intersect.d.ts.map +1 -0
- package/dist/_ray3-intersect.js +122 -0
- package/dist/_ray3-intersect.js.map +1 -0
- package/dist/_triangle3-cross.d.ts +66 -0
- package/dist/_triangle3-cross.d.ts.map +1 -0
- package/dist/_triangle3-cross.js +396 -0
- package/dist/_triangle3-cross.js.map +1 -0
- package/dist/box2-array-boundary.d.ts +50 -0
- package/dist/box2-array-boundary.d.ts.map +1 -0
- package/dist/box2-array-boundary.js +97 -0
- package/dist/box2-array-boundary.js.map +1 -0
- package/dist/box2-array.d.ts +42 -0
- package/dist/box2-array.d.ts.map +1 -0
- package/dist/box2-array.js +134 -0
- package/dist/box2-array.js.map +1 -0
- package/dist/box2-componentwise.d.ts +110 -0
- package/dist/box2-componentwise.d.ts.map +1 -0
- package/dist/box2-componentwise.js +325 -0
- package/dist/box2-componentwise.js.map +1 -0
- package/dist/box2-grid-index.d.ts +67 -0
- package/dist/box2-grid-index.d.ts.map +1 -0
- package/dist/box2-grid-index.js +198 -0
- package/dist/box2-grid-index.js.map +1 -0
- package/dist/box2-record.d.ts +83 -0
- package/dist/box2-record.d.ts.map +1 -0
- package/dist/box2-record.js +124 -0
- package/dist/box2-record.js.map +1 -0
- package/dist/box2.d.ts +38 -0
- package/dist/box2.d.ts.map +1 -0
- package/dist/box2.js +97 -0
- package/dist/box2.js.map +1 -0
- package/dist/box3-array-boundary.d.ts +50 -0
- package/dist/box3-array-boundary.d.ts.map +1 -0
- package/dist/box3-array-boundary.js +107 -0
- package/dist/box3-array-boundary.js.map +1 -0
- package/dist/box3-componentwise.d.ts +110 -0
- package/dist/box3-componentwise.d.ts.map +1 -0
- package/dist/box3-componentwise.js +392 -0
- package/dist/box3-componentwise.js.map +1 -0
- package/dist/box3-record.d.ts +92 -0
- package/dist/box3-record.d.ts.map +1 -0
- package/dist/box3-record.js +147 -0
- package/dist/box3-record.js.map +1 -0
- package/dist/box3.d.ts +19 -16
- package/dist/box3.d.ts.map +1 -1
- package/dist/box3.js +73 -76
- package/dist/box3.js.map +1 -1
- package/dist/box4-array-boundary.d.ts +50 -0
- package/dist/box4-array-boundary.d.ts.map +1 -0
- package/dist/box4-array-boundary.js +117 -0
- package/dist/box4-array-boundary.js.map +1 -0
- package/dist/box4-componentwise.d.ts +110 -0
- package/dist/box4-componentwise.d.ts.map +1 -0
- package/dist/box4-componentwise.js +459 -0
- package/dist/box4-componentwise.js.map +1 -0
- package/dist/box4-record.d.ts +96 -0
- package/dist/box4-record.d.ts.map +1 -0
- package/dist/box4-record.js +167 -0
- package/dist/box4-record.js.map +1 -0
- package/dist/box4.d.ts +13 -8
- package/dist/box4.d.ts.map +1 -1
- package/dist/box4.js +27 -5
- package/dist/box4.js.map +1 -1
- package/dist/circle2-array-boundary.d.ts +51 -0
- package/dist/circle2-array-boundary.d.ts.map +1 -0
- package/dist/circle2-array-boundary.js +93 -0
- package/dist/circle2-array-boundary.js.map +1 -0
- package/dist/circle2-array.d.ts +17 -0
- package/dist/circle2-array.d.ts.map +1 -0
- package/dist/circle2-array.js +44 -0
- package/dist/circle2-array.js.map +1 -0
- package/dist/circle2-record.d.ts +81 -0
- package/dist/circle2-record.d.ts.map +1 -0
- package/dist/circle2-record.js +114 -0
- package/dist/circle2-record.js.map +1 -0
- package/dist/circle2.d.ts +27 -82
- package/dist/circle2.d.ts.map +1 -1
- package/dist/circle2.js +59 -104
- package/dist/circle2.js.map +1 -1
- package/dist/coordinates/cylindrical-record.d.ts +86 -0
- package/dist/coordinates/cylindrical-record.d.ts.map +1 -0
- package/dist/coordinates/cylindrical-record.js +114 -0
- package/dist/coordinates/cylindrical-record.js.map +1 -0
- package/dist/coordinates/horizontal-record.d.ts +86 -0
- package/dist/coordinates/horizontal-record.d.ts.map +1 -0
- package/dist/coordinates/horizontal-record.js +114 -0
- package/dist/coordinates/horizontal-record.js.map +1 -0
- package/dist/coordinates/horizontal.d.ts +48 -0
- package/dist/coordinates/horizontal.d.ts.map +1 -0
- package/dist/coordinates/horizontal.js +100 -0
- package/dist/coordinates/horizontal.js.map +1 -0
- package/dist/coordinates/index.d.ts +10 -0
- package/dist/coordinates/index.d.ts.map +1 -0
- package/dist/coordinates/index.js +10 -0
- package/dist/coordinates/index.js.map +1 -0
- package/dist/coordinates/longitude-latitude-record.d.ts +81 -0
- package/dist/coordinates/longitude-latitude-record.d.ts.map +1 -0
- package/dist/coordinates/longitude-latitude-record.js +104 -0
- package/dist/coordinates/longitude-latitude-record.js.map +1 -0
- package/dist/coordinates/longitude-latitude.d.ts +33 -0
- package/dist/coordinates/longitude-latitude.d.ts.map +1 -0
- package/dist/coordinates/longitude-latitude.js +78 -0
- package/dist/coordinates/longitude-latitude.js.map +1 -0
- package/dist/coordinates/polar-record.d.ts +77 -0
- package/dist/coordinates/polar-record.d.ts.map +1 -0
- package/dist/coordinates/polar-record.js +104 -0
- package/dist/coordinates/polar-record.js.map +1 -0
- package/dist/coordinates/polar.d.ts +28 -0
- package/dist/coordinates/polar.d.ts.map +1 -0
- package/dist/coordinates/polar.js +68 -0
- package/dist/coordinates/polar.js.map +1 -0
- package/dist/coordinates/spherical-cylindrical.d.ts +49 -0
- package/dist/coordinates/spherical-cylindrical.d.ts.map +1 -0
- package/dist/coordinates/spherical-cylindrical.js +110 -0
- package/dist/coordinates/spherical-cylindrical.js.map +1 -0
- package/dist/coordinates/spherical-record.d.ts +86 -0
- package/dist/coordinates/spherical-record.d.ts.map +1 -0
- package/dist/coordinates/spherical-record.js +114 -0
- package/dist/coordinates/spherical-record.js.map +1 -0
- package/dist/frustum3-record.d.ts +132 -0
- package/dist/frustum3-record.d.ts.map +1 -0
- package/dist/frustum3-record.js +333 -0
- package/dist/frustum3-record.js.map +1 -0
- package/dist/frustum3.d.ts +60 -0
- package/dist/frustum3.d.ts.map +1 -0
- package/dist/frustum3.js +186 -0
- package/dist/frustum3.js.map +1 -0
- package/dist/index.d.ts +36 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -16
- package/dist/index.js.map +1 -1
- package/dist/line2-record.d.ts +87 -0
- package/dist/line2-record.d.ts.map +1 -0
- package/dist/line2-record.js +123 -0
- package/dist/line2-record.js.map +1 -0
- package/dist/line2.d.ts +24 -33
- package/dist/line2.d.ts.map +1 -1
- package/dist/line2.js +78 -52
- package/dist/line2.js.map +1 -1
- package/dist/line3-record.d.ts +91 -0
- package/dist/line3-record.d.ts.map +1 -0
- package/dist/line3-record.js +146 -0
- package/dist/line3-record.js.map +1 -0
- package/dist/line3.d.ts +11 -24
- package/dist/line3.d.ts.map +1 -1
- package/dist/line3.js +32 -36
- package/dist/line3.js.map +1 -1
- package/dist/mesh/_generator-kit.d.ts +14 -0
- package/dist/mesh/_generator-kit.d.ts.map +1 -0
- package/dist/mesh/_generator-kit.js +39 -0
- package/dist/mesh/_generator-kit.js.map +1 -0
- package/dist/mesh/_index-kernels-u16.d.ts +85 -0
- package/dist/mesh/_index-kernels-u16.d.ts.map +1 -0
- package/dist/mesh/_index-kernels-u16.js +1045 -0
- package/dist/mesh/_index-kernels-u16.js.map +1 -0
- package/dist/mesh/_index-kernels-u32.d.ts +85 -0
- package/dist/mesh/_index-kernels-u32.d.ts.map +1 -0
- package/dist/mesh/_index-kernels-u32.js +1045 -0
- package/dist/mesh/_index-kernels-u32.js.map +1 -0
- package/dist/mesh/generate-box.d.ts +16 -0
- package/dist/mesh/generate-box.d.ts.map +1 -0
- package/dist/mesh/generate-box.js +79 -0
- package/dist/mesh/generate-box.js.map +1 -0
- package/dist/mesh/generate-cylinder.d.ts +25 -0
- package/dist/mesh/generate-cylinder.d.ts.map +1 -0
- package/dist/mesh/generate-cylinder.js +117 -0
- package/dist/mesh/generate-cylinder.js.map +1 -0
- package/dist/mesh/generate-heightfield.d.ts +24 -0
- package/dist/mesh/generate-heightfield.d.ts.map +1 -0
- package/dist/mesh/generate-heightfield.js +48 -0
- package/dist/mesh/generate-heightfield.js.map +1 -0
- package/dist/mesh/generate-plane.d.ts +18 -0
- package/dist/mesh/generate-plane.d.ts.map +1 -0
- package/dist/mesh/generate-plane.js +39 -0
- package/dist/mesh/generate-plane.js.map +1 -0
- package/dist/mesh/generate-sphere.d.ts +50 -0
- package/dist/mesh/generate-sphere.d.ts.map +1 -0
- package/dist/mesh/generate-sphere.js +244 -0
- package/dist/mesh/generate-sphere.js.map +1 -0
- package/dist/mesh/index.d.ts +8 -0
- package/dist/mesh/index.d.ts.map +1 -0
- package/dist/mesh/index.js +8 -0
- package/dist/mesh/index.js.map +1 -0
- package/dist/mesh/mesh3-kernels.d.ts +122 -0
- package/dist/mesh/mesh3-kernels.d.ts.map +1 -0
- package/dist/mesh/mesh3-kernels.js +220 -0
- package/dist/mesh/mesh3-kernels.js.map +1 -0
- package/dist/mesh/mesh3.d.ts +66 -0
- package/dist/mesh/mesh3.d.ts.map +1 -0
- package/dist/mesh/mesh3.js +128 -0
- package/dist/mesh/mesh3.js.map +1 -0
- package/dist/plane3-record.d.ts +88 -0
- package/dist/plane3-record.d.ts.map +1 -0
- package/dist/plane3-record.js +123 -0
- package/dist/plane3-record.js.map +1 -0
- package/dist/plane3.d.ts +43 -28
- package/dist/plane3.d.ts.map +1 -1
- package/dist/plane3.js +149 -48
- package/dist/plane3.js.map +1 -1
- package/dist/polygon2.d.ts +132 -29
- package/dist/polygon2.d.ts.map +1 -1
- package/dist/polygon2.js +529 -96
- package/dist/polygon2.js.map +1 -1
- package/dist/polygon3.d.ts +56 -21
- package/dist/polygon3.d.ts.map +1 -1
- package/dist/polygon3.js +239 -91
- package/dist/polygon3.js.map +1 -1
- package/dist/polyline2.d.ts +37 -0
- package/dist/polyline2.d.ts.map +1 -0
- package/dist/polyline2.js +146 -0
- package/dist/polyline2.js.map +1 -0
- package/dist/polyline3.d.ts +35 -0
- package/dist/polyline3.d.ts.map +1 -0
- package/dist/polyline3.js +159 -0
- package/dist/polyline3.js.map +1 -0
- package/dist/quadtree.d.ts +255 -0
- package/dist/quadtree.d.ts.map +1 -0
- package/dist/quadtree.js +1096 -0
- package/dist/quadtree.js.map +1 -0
- package/dist/ray2-record.d.ts +86 -0
- package/dist/ray2-record.d.ts.map +1 -0
- package/dist/ray2-record.js +123 -0
- package/dist/ray2-record.js.map +1 -0
- package/dist/ray2.d.ts +38 -13
- package/dist/ray2.d.ts.map +1 -1
- package/dist/ray2.js +85 -22
- package/dist/ray2.js.map +1 -1
- package/dist/ray3-array.d.ts +27 -0
- package/dist/ray3-array.d.ts.map +1 -0
- package/dist/ray3-array.js +89 -0
- package/dist/ray3-array.js.map +1 -0
- package/dist/ray3-record.d.ts +90 -0
- package/dist/ray3-record.d.ts.map +1 -0
- package/dist/ray3-record.js +146 -0
- package/dist/ray3-record.js.map +1 -0
- package/dist/ray3.d.ts +72 -25
- package/dist/ray3.d.ts.map +1 -1
- package/dist/ray3.js +233 -64
- package/dist/ray3.js.map +1 -1
- package/dist/segment2-record.d.ts +80 -0
- package/dist/segment2-record.d.ts.map +1 -0
- package/dist/segment2-record.js +122 -0
- package/dist/segment2-record.js.map +1 -0
- package/dist/segment2.d.ts +39 -19
- package/dist/segment2.d.ts.map +1 -1
- package/dist/segment2.js +104 -42
- package/dist/segment2.js.map +1 -1
- package/dist/segment3-record.d.ts +90 -0
- package/dist/segment3-record.d.ts.map +1 -0
- package/dist/segment3-record.js +146 -0
- package/dist/segment3-record.js.map +1 -0
- package/dist/segment3.d.ts +24 -12
- package/dist/segment3.d.ts.map +1 -1
- package/dist/segment3.js +67 -30
- package/dist/segment3.js.map +1 -1
- package/dist/size.d.ts +40 -0
- package/dist/size.d.ts.map +1 -0
- package/dist/size.js +72 -0
- package/dist/size.js.map +1 -0
- package/dist/sphere3-array-boundary.d.ts +51 -0
- package/dist/sphere3-array-boundary.d.ts.map +1 -0
- package/dist/sphere3-array-boundary.js +98 -0
- package/dist/sphere3-array-boundary.js.map +1 -0
- package/dist/sphere3-record.d.ts +88 -0
- package/dist/sphere3-record.d.ts.map +1 -0
- package/dist/sphere3-record.js +123 -0
- package/dist/sphere3-record.js.map +1 -0
- package/dist/sphere3.d.ts +55 -12
- package/dist/sphere3.d.ts.map +1 -1
- package/dist/sphere3.js +233 -24
- package/dist/sphere3.js.map +1 -1
- package/dist/spherical/cap.d.ts +56 -0
- package/dist/spherical/cap.d.ts.map +1 -0
- package/dist/spherical/cap.js +363 -0
- package/dist/spherical/cap.js.map +1 -0
- package/dist/spherical/great-circle.d.ts +39 -0
- package/dist/spherical/great-circle.d.ts.map +1 -0
- package/dist/spherical/great-circle.js +158 -0
- package/dist/spherical/great-circle.js.map +1 -0
- package/dist/spherical/index.d.ts +3 -0
- package/dist/spherical/index.d.ts.map +1 -0
- package/dist/spherical/index.js +3 -0
- package/dist/spherical/index.js.map +1 -0
- package/dist/triangle2-record.d.ts +91 -0
- package/dist/triangle2-record.d.ts.map +1 -0
- package/dist/triangle2-record.js +146 -0
- package/dist/triangle2-record.js.map +1 -0
- package/dist/triangle2.d.ts +29 -14
- package/dist/triangle2.d.ts.map +1 -1
- package/dist/triangle2.js +86 -22
- package/dist/triangle2.js.map +1 -1
- package/dist/triangle3-record.d.ts +97 -0
- package/dist/triangle3-record.d.ts.map +1 -0
- package/dist/triangle3-record.js +178 -0
- package/dist/triangle3-record.js.map +1 -0
- package/dist/triangle3.d.ts +60 -17
- package/dist/triangle3.d.ts.map +1 -1
- package/dist/triangle3.js +287 -38
- package/dist/triangle3.js.map +1 -1
- package/package.json +15 -8
- package/dist/angles.d.ts +0 -31
- package/dist/angles.d.ts.map +0 -1
- package/dist/angles.js +0 -53
- package/dist/angles.js.map +0 -1
- package/dist/coordinate-spaces.d.ts +0 -39
- package/dist/coordinate-spaces.d.ts.map +0 -1
- package/dist/coordinate-spaces.js +0 -52
- package/dist/coordinate-spaces.js.map +0 -1
- package/dist/coordinates-vec2.d.ts +0 -7
- package/dist/coordinates-vec2.d.ts.map +0 -1
- package/dist/coordinates-vec2.js +0 -35
- package/dist/coordinates-vec2.js.map +0 -1
- package/dist/coordinates-vec3.d.ts +0 -11
- package/dist/coordinates-vec3.d.ts.map +0 -1
- package/dist/coordinates-vec3.js +0 -61
- package/dist/coordinates-vec3.js.map +0 -1
- package/dist/coordinates.d.ts +0 -54
- package/dist/coordinates.d.ts.map +0 -1
- package/dist/coordinates.js +0 -2
- package/dist/coordinates.js.map +0 -1
- package/dist/euler-angles-quaternion.d.ts +0 -7
- package/dist/euler-angles-quaternion.d.ts.map +0 -1
- package/dist/euler-angles-quaternion.js +0 -100
- package/dist/euler-angles-quaternion.js.map +0 -1
- package/dist/euler-angles.d.ts +0 -33
- package/dist/euler-angles.d.ts.map +0 -1
- package/dist/euler-angles.js +0 -35
- package/dist/euler-angles.js.map +0 -1
- package/dist/geometry-vectors.d.ts +0 -11
- package/dist/geometry-vectors.d.ts.map +0 -1
- package/dist/geometry-vectors.js +0 -19
- package/dist/geometry-vectors.js.map +0 -1
- package/dist/mesh3.d.ts +0 -32
- package/dist/mesh3.d.ts.map +0 -1
- package/dist/mesh3.js +0 -142
- package/dist/mesh3.js.map +0 -1
- package/dist/point2.d.ts +0 -41
- package/dist/point2.d.ts.map +0 -1
- package/dist/point2.js +0 -92
- package/dist/point2.js.map +0 -1
- package/dist/point3.d.ts +0 -43
- package/dist/point3.d.ts.map +0 -1
- package/dist/point3.js +0 -103
- package/dist/point3.js.map +0 -1
- package/dist/point4.d.ts +0 -12
- package/dist/point4.d.ts.map +0 -1
- package/dist/point4.js +0 -28
- package/dist/point4.js.map +0 -1
- package/dist/rect2.d.ts +0 -54
- package/dist/rect2.d.ts.map +0 -1
- package/dist/rect2.js +0 -149
- package/dist/rect2.js.map +0 -1
- package/dist/size2.d.ts +0 -33
- package/dist/size2.d.ts.map +0 -1
- package/dist/size2.js +0 -81
- package/dist/size2.js.map +0 -1
- package/dist/size3.d.ts +0 -21
- package/dist/size3.d.ts.map +0 -1
- package/dist/size3.js +0 -59
- package/dist/size3.js.map +0 -1
- package/dist/size4.d.ts +0 -10
- package/dist/size4.d.ts.map +0 -1
- package/dist/size4.js +0 -16
- package/dist/size4.js.map +0 -1
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { assertInteger, clamp } from "@ac-kit/core";
|
|
2
|
+
import { allocateMesh_, assertExtent_, assertSegments_, } from "./_generator-kit.js";
|
|
3
|
+
const SQRT_3_ = Math.sqrt(3);
|
|
4
|
+
/**
|
|
5
|
+
* An octahedron of the given `radius` (default 1): vertices at `±radius` on
|
|
6
|
+
* each axis, 8 faces with their own vertices so that the normals are flat (24
|
|
7
|
+
* vertices, 8 triangles, uvs `(0, 0)`, `(1, 0)`, `(½, 1)` on each face),
|
|
8
|
+
* counter-clockwise from outside. A zero radius gives zero-area faces whose
|
|
9
|
+
* normals are still the face directions. O(1).
|
|
10
|
+
*
|
|
11
|
+
* @throws {RangeError} When `radius` is negative or not finite.
|
|
12
|
+
*/
|
|
13
|
+
export function mesh3Octahedron(options) {
|
|
14
|
+
const radius = options?.radius ?? 1;
|
|
15
|
+
assertExtent_("mesh3Octahedron", "radius", radius);
|
|
16
|
+
const mesh = allocateMesh_(24, 8);
|
|
17
|
+
for (let face = 0; face < 8; face++) {
|
|
18
|
+
const signX = face & 1 ? -1 : 1;
|
|
19
|
+
const signY = face & 2 ? -1 : 1;
|
|
20
|
+
const signZ = face & 4 ? -1 : 1;
|
|
21
|
+
// Vertices on X, Y and Z, in the order that is counter-clockwise from
|
|
22
|
+
// outside for this octant.
|
|
23
|
+
const flipped = signX * signY * signZ < 0;
|
|
24
|
+
const first = face * 3;
|
|
25
|
+
for (let corner = 0; corner < 3; corner++) {
|
|
26
|
+
const axis = flipped && corner > 0 ? 3 - corner : corner;
|
|
27
|
+
const vertex = first + corner;
|
|
28
|
+
mesh.positions[vertex * 3 + axis] =
|
|
29
|
+
radius * (axis === 0 ? signX : axis === 1 ? signY : signZ);
|
|
30
|
+
mesh.normals[vertex * 3] = signX / SQRT_3_;
|
|
31
|
+
mesh.normals[vertex * 3 + 1] = signY / SQRT_3_;
|
|
32
|
+
mesh.normals[vertex * 3 + 2] = signZ / SQRT_3_;
|
|
33
|
+
mesh.uvs[vertex * 2] = corner === 0 ? 0 : corner === 1 ? 1 : 0.5;
|
|
34
|
+
mesh.uvs[vertex * 2 + 1] = corner === 2 ? 1 : 0;
|
|
35
|
+
mesh.indices[vertex] = vertex;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return mesh;
|
|
39
|
+
}
|
|
40
|
+
const GOLDEN_RATIO_ = (1 + Math.sqrt(5)) / 2;
|
|
41
|
+
/**
|
|
42
|
+
* The icosahedron's 12 vertices, not normalised, and its 20 counter-clockwise
|
|
43
|
+
* faces.
|
|
44
|
+
*/
|
|
45
|
+
const ICOSAHEDRON_VERTICES_ = [
|
|
46
|
+
-1,
|
|
47
|
+
GOLDEN_RATIO_,
|
|
48
|
+
0,
|
|
49
|
+
1,
|
|
50
|
+
GOLDEN_RATIO_,
|
|
51
|
+
0,
|
|
52
|
+
-1,
|
|
53
|
+
-GOLDEN_RATIO_,
|
|
54
|
+
0,
|
|
55
|
+
1,
|
|
56
|
+
-GOLDEN_RATIO_,
|
|
57
|
+
0,
|
|
58
|
+
0,
|
|
59
|
+
-1,
|
|
60
|
+
GOLDEN_RATIO_,
|
|
61
|
+
0,
|
|
62
|
+
1,
|
|
63
|
+
GOLDEN_RATIO_,
|
|
64
|
+
0,
|
|
65
|
+
-1,
|
|
66
|
+
-GOLDEN_RATIO_,
|
|
67
|
+
0,
|
|
68
|
+
1,
|
|
69
|
+
-GOLDEN_RATIO_,
|
|
70
|
+
GOLDEN_RATIO_,
|
|
71
|
+
0,
|
|
72
|
+
-1,
|
|
73
|
+
GOLDEN_RATIO_,
|
|
74
|
+
0,
|
|
75
|
+
1,
|
|
76
|
+
-GOLDEN_RATIO_,
|
|
77
|
+
0,
|
|
78
|
+
-1,
|
|
79
|
+
-GOLDEN_RATIO_,
|
|
80
|
+
0,
|
|
81
|
+
1,
|
|
82
|
+
];
|
|
83
|
+
const ICOSAHEDRON_FACES_ = [
|
|
84
|
+
0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 0, 10, 11, 1, 5, 9, 5, 11, 4, 11, 10, 2,
|
|
85
|
+
10, 7, 6, 7, 1, 8, 3, 9, 4, 3, 4, 2, 3, 2, 6, 3, 6, 8, 3, 8, 9, 4, 9, 5, 2, 4,
|
|
86
|
+
11, 6, 2, 10, 8, 6, 7, 9, 8, 1,
|
|
87
|
+
];
|
|
88
|
+
/**
|
|
89
|
+
* The largest subdivision count: the edge keys of the last level
|
|
90
|
+
* (`vertexCount²`) stay below 2⁵³.
|
|
91
|
+
*/
|
|
92
|
+
const MAX_SUBDIVISIONS_ = 11;
|
|
93
|
+
/**
|
|
94
|
+
* A sphere of the given `radius` (default 1) from an icosahedron whose faces
|
|
95
|
+
* are split in four `subdivisions` times (default 2) and projected onto the
|
|
96
|
+
* sphere: `10·4^subdivisions + 2` vertices (12 for 0, 42, 162, 642, …) shared
|
|
97
|
+
* between faces, `20·4^subdivisions` triangles of nearly equal size,
|
|
98
|
+
* counter-clockwise from outside, with smooth normals (the direction of the
|
|
99
|
+
* vertex, exact at any radius, a zero radius included) and equirectangular uvs
|
|
100
|
+
* (`u = ½ + atan2(z, x)/2π`, `v = ½ + asin(y)/π`; a vertex is shared across the
|
|
101
|
+
* seam, so the uvs of the triangles that cross it wrap). O(4^subdivisions).
|
|
102
|
+
*
|
|
103
|
+
* @throws {RangeError} When `radius` is negative or not finite, or
|
|
104
|
+
* `subdivisions` is not an integer in `[0, 11]`.
|
|
105
|
+
*/
|
|
106
|
+
export function mesh3IcoSphere(options) {
|
|
107
|
+
const radius = options?.radius ?? 1;
|
|
108
|
+
const subdivisions = options?.subdivisions ?? 2;
|
|
109
|
+
assertExtent_("mesh3IcoSphere", "radius", radius);
|
|
110
|
+
assertInteger(subdivisions, "mesh3IcoSphere: subdivisions", 0, MAX_SUBDIVISIONS_);
|
|
111
|
+
const factor = 4 ** subdivisions;
|
|
112
|
+
const vertexCount = 10 * factor + 2;
|
|
113
|
+
const mesh = allocateMesh_(vertexCount, 20 * factor);
|
|
114
|
+
// The unit directions go to `normals`; `positions` and `uvs` follow.
|
|
115
|
+
const directions = mesh.normals;
|
|
116
|
+
for (let vertex = 0; vertex < 12; vertex++) {
|
|
117
|
+
const x = ICOSAHEDRON_VERTICES_[vertex * 3];
|
|
118
|
+
const y = ICOSAHEDRON_VERTICES_[vertex * 3 + 1];
|
|
119
|
+
const z = ICOSAHEDRON_VERTICES_[vertex * 3 + 2];
|
|
120
|
+
const inverse = 1 / Math.sqrt(x * x + y * y + z * z);
|
|
121
|
+
directions[vertex * 3] = x * inverse;
|
|
122
|
+
directions[vertex * 3 + 1] = y * inverse;
|
|
123
|
+
directions[vertex * 3 + 2] = z * inverse;
|
|
124
|
+
}
|
|
125
|
+
let faces = Uint32Array.from(ICOSAHEDRON_FACES_);
|
|
126
|
+
let count = 12;
|
|
127
|
+
for (let level = 0; level < subdivisions; level++) {
|
|
128
|
+
const midpoints = new Map();
|
|
129
|
+
const midpoint = (from, to) => {
|
|
130
|
+
const key = from < to ? from * vertexCount + to : to * vertexCount + from;
|
|
131
|
+
const known = midpoints.get(key);
|
|
132
|
+
if (known !== undefined) {
|
|
133
|
+
return known;
|
|
134
|
+
}
|
|
135
|
+
const x = directions[from * 3] + directions[to * 3];
|
|
136
|
+
const y = directions[from * 3 + 1] + directions[to * 3 + 1];
|
|
137
|
+
const z = directions[from * 3 + 2] + directions[to * 3 + 2];
|
|
138
|
+
const inverse = 1 / Math.sqrt(x * x + y * y + z * z);
|
|
139
|
+
directions[count * 3] = x * inverse;
|
|
140
|
+
directions[count * 3 + 1] = y * inverse;
|
|
141
|
+
directions[count * 3 + 2] = z * inverse;
|
|
142
|
+
midpoints.set(key, count);
|
|
143
|
+
return count++;
|
|
144
|
+
};
|
|
145
|
+
const next = new Uint32Array(faces.length * 4);
|
|
146
|
+
for (let corner = 0, out = 0; corner < faces.length; corner += 3) {
|
|
147
|
+
const a = faces[corner];
|
|
148
|
+
const b = faces[corner + 1];
|
|
149
|
+
const c = faces[corner + 2];
|
|
150
|
+
const ab = midpoint(a, b);
|
|
151
|
+
const bc = midpoint(b, c);
|
|
152
|
+
const ca = midpoint(c, a);
|
|
153
|
+
next.set([a, ab, ca, b, bc, ab, c, ca, bc, ab, bc, ca], out);
|
|
154
|
+
out += 12;
|
|
155
|
+
}
|
|
156
|
+
faces = next;
|
|
157
|
+
}
|
|
158
|
+
mesh.indices.set(faces);
|
|
159
|
+
for (let vertex = 0; vertex < vertexCount; vertex++) {
|
|
160
|
+
const x = directions[vertex * 3];
|
|
161
|
+
const y = directions[vertex * 3 + 1];
|
|
162
|
+
const z = directions[vertex * 3 + 2];
|
|
163
|
+
mesh.positions[vertex * 3] = x * radius;
|
|
164
|
+
mesh.positions[vertex * 3 + 1] = y * radius;
|
|
165
|
+
mesh.positions[vertex * 3 + 2] = z * radius;
|
|
166
|
+
mesh.uvs[vertex * 2] = 0.5 + Math.atan2(z, x) / (2 * Math.PI);
|
|
167
|
+
mesh.uvs[vertex * 2 + 1] = 0.5 + Math.asin(clamp(y, -1, 1)) / Math.PI;
|
|
168
|
+
}
|
|
169
|
+
return mesh;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* A sphere of the given `radius` (default 1) in latitude–longitude bands, the
|
|
173
|
+
* poles on ±Y: `widthSegments` (default 32) around and `heightSegments`
|
|
174
|
+
* (default 16) from the +Y pole to the −Y pole. `(widthSegments + 1) ×
|
|
175
|
+
* (heightSegments + 1)` vertices (the seam and each pole are repeated, so every
|
|
176
|
+
* vertex has its own uv: `u` around, from +X toward +Z, `v` from 0 at +Y to 1
|
|
177
|
+
* at −Y), `2·widthSegments·(heightSegments − 1)` triangles (the pole bands are
|
|
178
|
+
* single triangles), counter-clockwise from outside, with smooth normals (the
|
|
179
|
+
* direction of the vertex, a zero radius included). O(vertices).
|
|
180
|
+
*
|
|
181
|
+
* @throws {RangeError} When `radius` is negative or not finite, `widthSegments`
|
|
182
|
+
* is not an integer of at least 3 or `heightSegments` not an integer of at
|
|
183
|
+
* least 2.
|
|
184
|
+
*/
|
|
185
|
+
export function mesh3UvSphere(options) {
|
|
186
|
+
const radius = options?.radius ?? 1;
|
|
187
|
+
const widthSegments = options?.widthSegments ?? 32;
|
|
188
|
+
const heightSegments = options?.heightSegments ?? 16;
|
|
189
|
+
assertExtent_("mesh3UvSphere", "radius", radius);
|
|
190
|
+
assertSegments_("mesh3UvSphere", "widthSegments", widthSegments, 3);
|
|
191
|
+
assertSegments_("mesh3UvSphere", "heightSegments", heightSegments, 2);
|
|
192
|
+
const columns = widthSegments + 1;
|
|
193
|
+
const mesh = allocateMesh_(columns * (heightSegments + 1), 2 * widthSegments * (heightSegments - 1));
|
|
194
|
+
// The seam repeats the first column bit for bit.
|
|
195
|
+
const cosines = new Float64Array(columns);
|
|
196
|
+
const sines = new Float64Array(columns);
|
|
197
|
+
for (let column = 0; column < widthSegments; column++) {
|
|
198
|
+
const angle = (column / widthSegments) * 2 * Math.PI;
|
|
199
|
+
cosines[column] = Math.cos(angle);
|
|
200
|
+
sines[column] = Math.sin(angle);
|
|
201
|
+
}
|
|
202
|
+
cosines[widthSegments] = cosines[0];
|
|
203
|
+
sines[widthSegments] = sines[0];
|
|
204
|
+
for (let row = 0; row <= heightSegments; row++) {
|
|
205
|
+
const v = row / heightSegments;
|
|
206
|
+
const inclination = v * Math.PI;
|
|
207
|
+
const ring = row === 0 || row === heightSegments ? 0 : Math.sin(inclination);
|
|
208
|
+
const up = row === 0 ? 1 : row === heightSegments ? -1 : Math.cos(inclination);
|
|
209
|
+
for (let column = 0; column < columns; column++) {
|
|
210
|
+
const vertex = row * columns + column;
|
|
211
|
+
const x = ring * cosines[column];
|
|
212
|
+
const z = ring * sines[column];
|
|
213
|
+
mesh.positions[vertex * 3] = x * radius;
|
|
214
|
+
mesh.positions[vertex * 3 + 1] = up * radius;
|
|
215
|
+
mesh.positions[vertex * 3 + 2] = z * radius;
|
|
216
|
+
mesh.normals[vertex * 3] = x;
|
|
217
|
+
mesh.normals[vertex * 3 + 1] = up;
|
|
218
|
+
mesh.normals[vertex * 3 + 2] = z;
|
|
219
|
+
mesh.uvs[vertex * 2] = column / widthSegments;
|
|
220
|
+
mesh.uvs[vertex * 2 + 1] = v;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
let corner = 0;
|
|
224
|
+
for (let row = 0; row < heightSegments; row++) {
|
|
225
|
+
for (let column = 0; column < widthSegments; column++) {
|
|
226
|
+
const a = row * columns + column;
|
|
227
|
+
const b = a + 1;
|
|
228
|
+
const c = a + columns;
|
|
229
|
+
const d = c + 1;
|
|
230
|
+
if (row > 0) {
|
|
231
|
+
mesh.indices[corner++] = a;
|
|
232
|
+
mesh.indices[corner++] = b;
|
|
233
|
+
mesh.indices[corner++] = c;
|
|
234
|
+
}
|
|
235
|
+
if (row < heightSegments - 1) {
|
|
236
|
+
mesh.indices[corner++] = b;
|
|
237
|
+
mesh.indices[corner++] = d;
|
|
238
|
+
mesh.indices[corner++] = c;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return mesh;
|
|
243
|
+
}
|
|
244
|
+
//# sourceMappingURL=generate-sphere.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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2
|
+
export * from "./generate-cylinder.js";
|
|
3
|
+
export * from "./generate-heightfield.js";
|
|
4
|
+
export * from "./generate-plane.js";
|
|
5
|
+
export * from "./generate-sphere.js";
|
|
6
|
+
export * from "./mesh3-kernels.js";
|
|
7
|
+
export * from "./mesh3.js";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mesh/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./generate-box.js";
|
|
2
|
+
export * from "./generate-cylinder.js";
|
|
3
|
+
export * from "./generate-heightfield.js";
|
|
4
|
+
export * from "./generate-plane.js";
|
|
5
|
+
export * from "./generate-sphere.js";
|
|
6
|
+
export * from "./mesh3-kernels.js";
|
|
7
|
+
export * from "./mesh3.js";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mesh/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type { ReadonlyMat4x4, Vec3 } from "@ac-kit/math-linear";
|
|
2
|
+
import type { ReadonlyRay3 } from "../ray3-record.js";
|
|
3
|
+
import type { IndexArray } from "./mesh3.js";
|
|
4
|
+
/**
|
|
5
|
+
* Writes one unit normal per vertex into `out`: the sum of the normals of the
|
|
6
|
+
* triangles around it, weighted by their areas (a degenerate triangle weighs
|
|
7
|
+
* nothing). A vertex no triangle uses, or whose triangles cancel out exactly,
|
|
8
|
+
* gets the zero vector. Right at any size and anywhere up to
|
|
9
|
+
* ±`Number.MAX_VALUE`: each face's cross product is `triangle3Normal`'s, within
|
|
10
|
+
* 2^−49 of its largest component and zero only for a degenerate face, and each
|
|
11
|
+
* vertex's normal is the direction of the exact sum of those products, within
|
|
12
|
+
* 2^−48 per component (normwise), however they cancel — two opposite faces of
|
|
13
|
+
* 2^2000 beside one of `Number.MIN_VALUE²` leave that one's normal. Where a
|
|
14
|
+
* plain product could overflow or underflow, each vertex sums its faces'
|
|
15
|
+
* products scaled by the power of two that brings its largest to [1, 2); every
|
|
16
|
+
* sum keeps a running error bound, and a vertex whose bound does not settle its
|
|
17
|
+
* normal is summed again exactly, from its faces alone. O(vertices +
|
|
18
|
+
* triangles); no allocation once a per-vertex scratch has grown to the largest
|
|
19
|
+
* mesh.
|
|
20
|
+
*
|
|
21
|
+
* @throws {RangeError} When a length is not a multiple of 3, `out.length` is
|
|
22
|
+
* not `positions.length`, or `out` shares memory with an input.
|
|
23
|
+
*/
|
|
24
|
+
export declare function mesh3VertexNormals<T extends Float64Array>(out: T, positions: Float64Array, indices: IndexArray): T;
|
|
25
|
+
/**
|
|
26
|
+
* Writes one unit normal per triangle into `out` (3 numbers each),
|
|
27
|
+
* `triangle3Normal`'s: the direction of the exact cross product, within 2^−48
|
|
28
|
+
* per component, for any finite coordinates; the zero vector exactly for a
|
|
29
|
+
* degenerate triangle (collinear or repeated vertices). O(triangles), no
|
|
30
|
+
* allocation.
|
|
31
|
+
*
|
|
32
|
+
* @throws {RangeError} When a length is not a multiple of 3, `out.length` is
|
|
33
|
+
* not `indices.length`, or `out` shares memory with an input.
|
|
34
|
+
*/
|
|
35
|
+
export declare function mesh3FaceNormals<T extends Float64Array>(out: T, positions: Float64Array, indices: IndexArray): T;
|
|
36
|
+
/**
|
|
37
|
+
* The total area of the triangles. Each face's area is taken from its edges
|
|
38
|
+
* scaled per axis by powers of two, so no square overflows or underflows at any
|
|
39
|
+
* size or distance from the origin (a face spanning ±`Number.MAX_VALUE`
|
|
40
|
+
* included), rounded once, and the faces are summed exactly: the same result in
|
|
41
|
+
* every face order. The result is `Infinity` only when the true area exceeds
|
|
42
|
+
* `Number.MAX_VALUE`. O(triangles); allocates nothing but, where the call is
|
|
43
|
+
* not inlined, its result.
|
|
44
|
+
*
|
|
45
|
+
* @throws {RangeError} When a length is not a multiple of 3.
|
|
46
|
+
*/
|
|
47
|
+
export declare function mesh3SurfaceArea(positions: Float64Array, indices: IndexArray): number;
|
|
48
|
+
/**
|
|
49
|
+
* The signed volume of a closed, consistently wound mesh: positive when the
|
|
50
|
+
* counter-clockwise faces point outward, negative when inside out. Each face's
|
|
51
|
+
* term is taken over its own edge differences, relative to a corner of the
|
|
52
|
+
* mesh's bounding box, each axis scaled by its own power of two and all by a
|
|
53
|
+
* common one chosen from the faces, and every product and sum is exact. So the
|
|
54
|
+
* result is six times the volume rounded once, then divided by 6: the same in
|
|
55
|
+
* every face order (merging meshes in any order gives the same volume), at any
|
|
56
|
+
* distance from the origin up to ±`Number.MAX_VALUE`, and for a mesh however
|
|
57
|
+
* thin, wide or small, with no intermediate overflow; `Infinity` only when the
|
|
58
|
+
* true volume exceeds `Number.MAX_VALUE`. The face-local edge differences must
|
|
59
|
+
* be exact, as they are wherever a face is small beside its distance from the
|
|
60
|
+
* origin (Sterbenz); a face whose term is some 2¹⁹⁰⁰ times smaller than the
|
|
61
|
+
* largest, or a volume that small beside it, may lose digits to the subnormal
|
|
62
|
+
* range. A vertex no triangle uses does not count. An open mesh gives a number
|
|
63
|
+
* that means nothing. An ordinary mesh (no extent from 2³⁰⁰ up) is first summed
|
|
64
|
+
* in doubled precision with a rigorous error bound, which certifies the same
|
|
65
|
+
* rounded result in about 40 ns per triangle; the exact sums run only where it
|
|
66
|
+
* cannot. O(triangles); allocates nothing but, where the call is not inlined,
|
|
67
|
+
* its result.
|
|
68
|
+
*
|
|
69
|
+
* @throws {RangeError} When a length is not a multiple of 3.
|
|
70
|
+
*/
|
|
71
|
+
export declare function mesh3Volume(positions: Float64Array, indices: IndexArray): number;
|
|
72
|
+
/**
|
|
73
|
+
* Writes the area-weighted centroid of the surface into `out`. Its weights are
|
|
74
|
+
* the faces' areas (as {@link mesh3SurfaceArea} takes them) scaled by one power
|
|
75
|
+
* of two, its sums exact and taken relative to a corner of the mesh's bounding
|
|
76
|
+
* box, each axis scaled by its own power of two, so the result is the same in
|
|
77
|
+
* every face order and nothing overflows at any size or distance from the
|
|
78
|
+
* origin up to ±`Number.MAX_VALUE`: each component is within a few units in the
|
|
79
|
+
* last place of the mesh's extent along its axis, exact where the mean is
|
|
80
|
+
* representable relative to the corner. A mesh of zero area (none, or all
|
|
81
|
+
* degenerate triangles) gives `NaN` components. O(triangles), no allocation.
|
|
82
|
+
*
|
|
83
|
+
* @throws {RangeError} When a length is not a multiple of 3.
|
|
84
|
+
*/
|
|
85
|
+
export declare function mesh3Centroid(out: Vec3, positions: Float64Array, indices: IndexArray): Vec3;
|
|
86
|
+
/**
|
|
87
|
+
* Finds the triangle the ray hits first: its index, or `−1` for a miss. `out`
|
|
88
|
+
* receives `[t, u, v]`, the ray parameter and the barycentric coordinates of
|
|
89
|
+
* the hit (`a·(1 − u − v) + b·u + c·v`), `NaN` for a miss. With `cullBackFaces`
|
|
90
|
+
* a triangle seen from behind is a miss ({@link ray3IntersectTriangle3}). Of
|
|
91
|
+
* equal hits the first triangle wins. Brute force, O(triangles).
|
|
92
|
+
*
|
|
93
|
+
* @throws {RangeError} When a length is not a multiple of 3.
|
|
94
|
+
*/
|
|
95
|
+
export declare function mesh3IntersectRay3(out: Vec3, ray: ReadonlyRay3, positions: Float64Array, indices: IndexArray, cullBackFaces: boolean): number;
|
|
96
|
+
/**
|
|
97
|
+
* Writes the clip-space depth, `z / w`, of each triangle's centroid under
|
|
98
|
+
* `viewProjection` into `out` (one number per triangle), to sort translucent
|
|
99
|
+
* triangles back to front. A centroid on the `w = 0` plane gives a non-finite
|
|
100
|
+
* depth. A triangle next to ±`Number.MAX_VALUE` has a finite depth wherever `z
|
|
101
|
+
* / w` is: its centroid is averaged from quarters when the sum overflows, and
|
|
102
|
+
* the homogeneous point scaled by a power of two when z or w does.
|
|
103
|
+
* O(triangles), no allocation.
|
|
104
|
+
*
|
|
105
|
+
* @throws {RangeError} When a length is not a multiple of 3, `out.length` is
|
|
106
|
+
* not the triangle count, or `out` shares memory with an input.
|
|
107
|
+
*/
|
|
108
|
+
export declare function mesh3TriangleDepths<T extends Float64Array>(out: T, positions: Float64Array, indices: IndexArray, viewProjection: ReadonlyMat4x4): T;
|
|
109
|
+
/**
|
|
110
|
+
* Writes the triangles of `indices` in the order `order` gives into `out`:
|
|
111
|
+
* triangle `k` of `out` is triangle `order[k]` of `indices`. `order` is a
|
|
112
|
+
* permutation of the triangle numbers (what sorting the depths by
|
|
113
|
+
* `Uint32Array.prototype.sort` gives); an entry past the last triangle writes
|
|
114
|
+
* zeros. `out` has the type of `indices`. O(triangles).
|
|
115
|
+
*
|
|
116
|
+
* @throws {RangeError} When a length is not a multiple of 3 or does not match
|
|
117
|
+
* (`out` and `indices` have the same length, `order` one entry per triangle),
|
|
118
|
+
* `out` is not of the type of `indices`, or shares memory with `indices` or
|
|
119
|
+
* `order`.
|
|
120
|
+
*/
|
|
121
|
+
export declare function mesh3ReorderTriangles<T extends IndexArray>(out: T, indices: IndexArray, order: Uint32Array): T;
|
|
122
|
+
//# sourceMappingURL=mesh3-kernels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mesh3-kernels.d.ts","sourceRoot":"","sources":["../../src/mesh/mesh3-kernels.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAEhE,OA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GAAG,EAAE,CAAC,EACN,OAAO,EAAE,UAAU,EACnB,KAAK,EAAE,WAAW,GAChB,CAAC,CA2BH"}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { isUint16Array, viewsMayOverlap } from "@ac-kit/core";
|
|
2
|
+
import { mesh3CentroidU16, mesh3FaceNormalsU16, mesh3IntersectRay3U16, mesh3ReorderTrianglesU16, mesh3SurfaceAreaU16, mesh3TriangleDepthsU16, mesh3VertexNormalsU16, mesh3VolumeU16, } from "./_index-kernels-u16.js";
|
|
3
|
+
import { mesh3CentroidU32, mesh3FaceNormalsU32, mesh3IntersectRay3U32, mesh3ReorderTrianglesU32, mesh3SurfaceAreaU32, mesh3TriangleDepthsU32, mesh3VertexNormalsU32, mesh3VolumeU32, } from "./_index-kernels-u32.js";
|
|
4
|
+
/**
|
|
5
|
+
* The kernels below take a packed mesh, `positions` (3 numbers per vertex) and
|
|
6
|
+
* `indices` (3 per triangle), and run once through the generated twin for the
|
|
7
|
+
* index type (`Uint16Array` or `Uint32Array`, M6: a kernel that sees both is
|
|
8
|
+
* 2.3–2.6× slower). They check the lengths once and nothing per element: an
|
|
9
|
+
* index past the last vertex reads `NaN` coordinates and gives a `NaN` result,
|
|
10
|
+
* checking indices before an upload is the checked layer's job. An `out` buffer
|
|
11
|
+
* must not share a byte with an input, whatever the buffer (a
|
|
12
|
+
* `SharedArrayBuffer` and its clones included): `RangeError`, as in
|
|
13
|
+
* `math-linear`.
|
|
14
|
+
*/
|
|
15
|
+
function assertMesh_(name, positions, indices) {
|
|
16
|
+
if (positions.length % 3 !== 0 || indices.length % 3 !== 0) {
|
|
17
|
+
throw new RangeError(`${name}: positions has ${positions.length} numbers and indices ${indices.length}, which are not both multiples of 3.`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function assertOut_(name, out, length, positions, indices) {
|
|
21
|
+
if (out.length !== length) {
|
|
22
|
+
throw new RangeError(`${name}: out has ${out.length} numbers, not the ${length} needed.`);
|
|
23
|
+
}
|
|
24
|
+
if (viewsMayOverlap(out, positions) || viewsMayOverlap(out, indices)) {
|
|
25
|
+
throw new RangeError(`${name}: out shares memory with an input.`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Writes one unit normal per vertex into `out`: the sum of the normals of the
|
|
30
|
+
* triangles around it, weighted by their areas (a degenerate triangle weighs
|
|
31
|
+
* nothing). A vertex no triangle uses, or whose triangles cancel out exactly,
|
|
32
|
+
* gets the zero vector. Right at any size and anywhere up to
|
|
33
|
+
* ±`Number.MAX_VALUE`: each face's cross product is `triangle3Normal`'s, within
|
|
34
|
+
* 2^−49 of its largest component and zero only for a degenerate face, and each
|
|
35
|
+
* vertex's normal is the direction of the exact sum of those products, within
|
|
36
|
+
* 2^−48 per component (normwise), however they cancel — two opposite faces of
|
|
37
|
+
* 2^2000 beside one of `Number.MIN_VALUE²` leave that one's normal. Where a
|
|
38
|
+
* plain product could overflow or underflow, each vertex sums its faces'
|
|
39
|
+
* products scaled by the power of two that brings its largest to [1, 2); every
|
|
40
|
+
* sum keeps a running error bound, and a vertex whose bound does not settle its
|
|
41
|
+
* normal is summed again exactly, from its faces alone. O(vertices +
|
|
42
|
+
* triangles); no allocation once a per-vertex scratch has grown to the largest
|
|
43
|
+
* mesh.
|
|
44
|
+
*
|
|
45
|
+
* @throws {RangeError} When a length is not a multiple of 3, `out.length` is
|
|
46
|
+
* not `positions.length`, or `out` shares memory with an input.
|
|
47
|
+
*/
|
|
48
|
+
export function mesh3VertexNormals(out, positions, indices) {
|
|
49
|
+
assertMesh_("mesh3VertexNormals", positions, indices);
|
|
50
|
+
assertOut_("mesh3VertexNormals", out, positions.length, positions, indices);
|
|
51
|
+
if (isUint16Array(indices)) {
|
|
52
|
+
mesh3VertexNormalsU16(out, positions, indices);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
mesh3VertexNormalsU32(out, positions, indices);
|
|
56
|
+
}
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Writes one unit normal per triangle into `out` (3 numbers each),
|
|
61
|
+
* `triangle3Normal`'s: the direction of the exact cross product, within 2^−48
|
|
62
|
+
* per component, for any finite coordinates; the zero vector exactly for a
|
|
63
|
+
* degenerate triangle (collinear or repeated vertices). O(triangles), no
|
|
64
|
+
* allocation.
|
|
65
|
+
*
|
|
66
|
+
* @throws {RangeError} When a length is not a multiple of 3, `out.length` is
|
|
67
|
+
* not `indices.length`, or `out` shares memory with an input.
|
|
68
|
+
*/
|
|
69
|
+
export function mesh3FaceNormals(out, positions, indices) {
|
|
70
|
+
assertMesh_("mesh3FaceNormals", positions, indices);
|
|
71
|
+
assertOut_("mesh3FaceNormals", out, indices.length, positions, indices);
|
|
72
|
+
if (isUint16Array(indices)) {
|
|
73
|
+
mesh3FaceNormalsU16(out, positions, indices);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
mesh3FaceNormalsU32(out, positions, indices);
|
|
77
|
+
}
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The total area of the triangles. Each face's area is taken from its edges
|
|
82
|
+
* scaled per axis by powers of two, so no square overflows or underflows at any
|
|
83
|
+
* size or distance from the origin (a face spanning ±`Number.MAX_VALUE`
|
|
84
|
+
* included), rounded once, and the faces are summed exactly: the same result in
|
|
85
|
+
* every face order. The result is `Infinity` only when the true area exceeds
|
|
86
|
+
* `Number.MAX_VALUE`. O(triangles); allocates nothing but, where the call is
|
|
87
|
+
* not inlined, its result.
|
|
88
|
+
*
|
|
89
|
+
* @throws {RangeError} When a length is not a multiple of 3.
|
|
90
|
+
*/
|
|
91
|
+
export function mesh3SurfaceArea(positions, indices) {
|
|
92
|
+
assertMesh_("mesh3SurfaceArea", positions, indices);
|
|
93
|
+
return isUint16Array(indices)
|
|
94
|
+
? mesh3SurfaceAreaU16(positions, indices)
|
|
95
|
+
: mesh3SurfaceAreaU32(positions, indices);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* The signed volume of a closed, consistently wound mesh: positive when the
|
|
99
|
+
* counter-clockwise faces point outward, negative when inside out. Each face's
|
|
100
|
+
* term is taken over its own edge differences, relative to a corner of the
|
|
101
|
+
* mesh's bounding box, each axis scaled by its own power of two and all by a
|
|
102
|
+
* common one chosen from the faces, and every product and sum is exact. So the
|
|
103
|
+
* result is six times the volume rounded once, then divided by 6: the same in
|
|
104
|
+
* every face order (merging meshes in any order gives the same volume), at any
|
|
105
|
+
* distance from the origin up to ±`Number.MAX_VALUE`, and for a mesh however
|
|
106
|
+
* thin, wide or small, with no intermediate overflow; `Infinity` only when the
|
|
107
|
+
* true volume exceeds `Number.MAX_VALUE`. The face-local edge differences must
|
|
108
|
+
* be exact, as they are wherever a face is small beside its distance from the
|
|
109
|
+
* origin (Sterbenz); a face whose term is some 2¹⁹⁰⁰ times smaller than the
|
|
110
|
+
* largest, or a volume that small beside it, may lose digits to the subnormal
|
|
111
|
+
* range. A vertex no triangle uses does not count. An open mesh gives a number
|
|
112
|
+
* that means nothing. An ordinary mesh (no extent from 2³⁰⁰ up) is first summed
|
|
113
|
+
* in doubled precision with a rigorous error bound, which certifies the same
|
|
114
|
+
* rounded result in about 40 ns per triangle; the exact sums run only where it
|
|
115
|
+
* cannot. O(triangles); allocates nothing but, where the call is not inlined,
|
|
116
|
+
* its result.
|
|
117
|
+
*
|
|
118
|
+
* @throws {RangeError} When a length is not a multiple of 3.
|
|
119
|
+
*/
|
|
120
|
+
export function mesh3Volume(positions, indices) {
|
|
121
|
+
assertMesh_("mesh3Volume", positions, indices);
|
|
122
|
+
return isUint16Array(indices)
|
|
123
|
+
? mesh3VolumeU16(positions, indices)
|
|
124
|
+
: mesh3VolumeU32(positions, indices);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Writes the area-weighted centroid of the surface into `out`. Its weights are
|
|
128
|
+
* the faces' areas (as {@link mesh3SurfaceArea} takes them) scaled by one power
|
|
129
|
+
* of two, its sums exact and taken relative to a corner of the mesh's bounding
|
|
130
|
+
* box, each axis scaled by its own power of two, so the result is the same in
|
|
131
|
+
* every face order and nothing overflows at any size or distance from the
|
|
132
|
+
* origin up to ±`Number.MAX_VALUE`: each component is within a few units in the
|
|
133
|
+
* last place of the mesh's extent along its axis, exact where the mean is
|
|
134
|
+
* representable relative to the corner. A mesh of zero area (none, or all
|
|
135
|
+
* degenerate triangles) gives `NaN` components. O(triangles), no allocation.
|
|
136
|
+
*
|
|
137
|
+
* @throws {RangeError} When a length is not a multiple of 3.
|
|
138
|
+
*/
|
|
139
|
+
export function mesh3Centroid(out, positions, indices) {
|
|
140
|
+
assertMesh_("mesh3Centroid", positions, indices);
|
|
141
|
+
if (isUint16Array(indices)) {
|
|
142
|
+
mesh3CentroidU16(out, positions, indices);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
mesh3CentroidU32(out, positions, indices);
|
|
146
|
+
}
|
|
147
|
+
return out;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Finds the triangle the ray hits first: its index, or `−1` for a miss. `out`
|
|
151
|
+
* receives `[t, u, v]`, the ray parameter and the barycentric coordinates of
|
|
152
|
+
* the hit (`a·(1 − u − v) + b·u + c·v`), `NaN` for a miss. With `cullBackFaces`
|
|
153
|
+
* a triangle seen from behind is a miss ({@link ray3IntersectTriangle3}). Of
|
|
154
|
+
* equal hits the first triangle wins. Brute force, O(triangles).
|
|
155
|
+
*
|
|
156
|
+
* @throws {RangeError} When a length is not a multiple of 3.
|
|
157
|
+
*/
|
|
158
|
+
export function mesh3IntersectRay3(out, ray, positions, indices, cullBackFaces) {
|
|
159
|
+
assertMesh_("mesh3IntersectRay3", positions, indices);
|
|
160
|
+
return isUint16Array(indices)
|
|
161
|
+
? mesh3IntersectRay3U16(out, ray, positions, indices, cullBackFaces)
|
|
162
|
+
: mesh3IntersectRay3U32(out, ray, positions, indices, cullBackFaces);
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Writes the clip-space depth, `z / w`, of each triangle's centroid under
|
|
166
|
+
* `viewProjection` into `out` (one number per triangle), to sort translucent
|
|
167
|
+
* triangles back to front. A centroid on the `w = 0` plane gives a non-finite
|
|
168
|
+
* depth. A triangle next to ±`Number.MAX_VALUE` has a finite depth wherever `z
|
|
169
|
+
* / w` is: its centroid is averaged from quarters when the sum overflows, and
|
|
170
|
+
* the homogeneous point scaled by a power of two when z or w does.
|
|
171
|
+
* O(triangles), no allocation.
|
|
172
|
+
*
|
|
173
|
+
* @throws {RangeError} When a length is not a multiple of 3, `out.length` is
|
|
174
|
+
* not the triangle count, or `out` shares memory with an input.
|
|
175
|
+
*/
|
|
176
|
+
export function mesh3TriangleDepths(out, positions, indices, viewProjection) {
|
|
177
|
+
assertMesh_("mesh3TriangleDepths", positions, indices);
|
|
178
|
+
assertOut_("mesh3TriangleDepths", out, indices.length / 3, positions, indices);
|
|
179
|
+
if (isUint16Array(indices)) {
|
|
180
|
+
mesh3TriangleDepthsU16(out, positions, indices, viewProjection);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
mesh3TriangleDepthsU32(out, positions, indices, viewProjection);
|
|
184
|
+
}
|
|
185
|
+
return out;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Writes the triangles of `indices` in the order `order` gives into `out`:
|
|
189
|
+
* triangle `k` of `out` is triangle `order[k]` of `indices`. `order` is a
|
|
190
|
+
* permutation of the triangle numbers (what sorting the depths by
|
|
191
|
+
* `Uint32Array.prototype.sort` gives); an entry past the last triangle writes
|
|
192
|
+
* zeros. `out` has the type of `indices`. O(triangles).
|
|
193
|
+
*
|
|
194
|
+
* @throws {RangeError} When a length is not a multiple of 3 or does not match
|
|
195
|
+
* (`out` and `indices` have the same length, `order` one entry per triangle),
|
|
196
|
+
* `out` is not of the type of `indices`, or shares memory with `indices` or
|
|
197
|
+
* `order`.
|
|
198
|
+
*/
|
|
199
|
+
export function mesh3ReorderTriangles(out, indices, order) {
|
|
200
|
+
if (indices.length % 3 !== 0 ||
|
|
201
|
+
out.length !== indices.length ||
|
|
202
|
+
order.length !== indices.length / 3) {
|
|
203
|
+
throw new RangeError(`mesh3ReorderTriangles: out has ${out.length} indices, indices ${indices.length} and order ${order.length} triangles, which do not agree.`);
|
|
204
|
+
}
|
|
205
|
+
const narrow = isUint16Array(indices);
|
|
206
|
+
if (isUint16Array(out) !== narrow) {
|
|
207
|
+
throw new RangeError("mesh3ReorderTriangles: out is not of the type of indices.");
|
|
208
|
+
}
|
|
209
|
+
if (viewsMayOverlap(out, indices) || viewsMayOverlap(out, order)) {
|
|
210
|
+
throw new RangeError("mesh3ReorderTriangles: out shares memory with an input.");
|
|
211
|
+
}
|
|
212
|
+
if (narrow) {
|
|
213
|
+
mesh3ReorderTrianglesU16(out, indices, order);
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
mesh3ReorderTrianglesU32(out, indices, order);
|
|
217
|
+
}
|
|
218
|
+
return out;
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=mesh3-kernels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mesh3-kernels.js","sourceRoot":"","sources":["../../src/mesh/mesh3-kernels.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAI9D,OAAO,EACN,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,EACxB,mBAAmB,EACnB,sBAAsB,EACtB,qBAAqB,EACrB,cAAc,GACd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACN,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,EACxB,mBAAmB,EACnB,sBAAsB,EACtB,qBAAqB,EACrB,cAAc,GACd,MAAM,yBAAyB,CAAC;AAGjC;;;;;;;;;;GAUG;AAEH,SAAS,WAAW,CACnB,IAAY,EACZ,SAAuB,EACvB,OAAmB;IAEnB,IA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