@math.gl/geometry 4.2.0-alpha.5
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/LICENSE +140 -0
- package/README.md +15 -0
- package/dist/geometries/box-geometry.d.ts +17 -0
- package/dist/geometries/box-geometry.d.ts.map +1 -0
- package/dist/geometries/box-geometry.js +60 -0
- package/dist/geometries/box-geometry.js.map +1 -0
- package/dist/geometries/capsule-geometry.d.ts +15 -0
- package/dist/geometries/capsule-geometry.d.ts.map +1 -0
- package/dist/geometries/capsule-geometry.js +92 -0
- package/dist/geometries/capsule-geometry.js.map +1 -0
- package/dist/geometries/cylinder-geometry.d.ts +17 -0
- package/dist/geometries/cylinder-geometry.d.ts.map +1 -0
- package/dist/geometries/cylinder-geometry.js +27 -0
- package/dist/geometries/cylinder-geometry.js.map +1 -0
- package/dist/geometries/geometry-helpers.d.ts +16 -0
- package/dist/geometries/geometry-helpers.d.ts.map +1 -0
- package/dist/geometries/geometry-helpers.js +19 -0
- package/dist/geometries/geometry-helpers.js.map +1 -0
- package/dist/geometries/ico-sphere-geometry.d.ts +11 -0
- package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -0
- package/dist/geometries/ico-sphere-geometry.js +87 -0
- package/dist/geometries/ico-sphere-geometry.js.map +1 -0
- package/dist/geometries/plane-geometry.d.ts +13 -0
- package/dist/geometries/plane-geometry.d.ts.map +1 -0
- package/dist/geometries/plane-geometry.js +51 -0
- package/dist/geometries/plane-geometry.js.map +1 -0
- package/dist/geometries/sphere-geometry.d.ts +12 -0
- package/dist/geometries/sphere-geometry.d.ts.map +1 -0
- package/dist/geometries/sphere-geometry.js +35 -0
- package/dist/geometries/sphere-geometry.js.map +1 -0
- package/dist/geometries/surface-of-revolution.d.ts +11 -0
- package/dist/geometries/surface-of-revolution.d.ts.map +1 -0
- package/dist/geometries/surface-of-revolution.js +37 -0
- package/dist/geometries/surface-of-revolution.js.map +1 -0
- package/dist/geometries/truncated-cone-geometry.d.ts +17 -0
- package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -0
- package/dist/geometries/truncated-cone-geometry.js +92 -0
- package/dist/geometries/truncated-cone-geometry.js.map +1 -0
- package/dist/index.cjs +601 -0
- package/dist/index.cjs.map +6 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/geometry-utils.d.ts +9 -0
- package/dist/lib/geometry-utils.d.ts.map +1 -0
- package/dist/lib/geometry-utils.js +29 -0
- package/dist/lib/geometry-utils.js.map +1 -0
- package/dist/lib/geometry.d.ts +36 -0
- package/dist/lib/geometry.d.ts.map +1 -0
- package/dist/lib/geometry.js +89 -0
- package/dist/lib/geometry.js.map +1 -0
- package/package.json +40 -0
- package/src/geometries/box-geometry.ts +70 -0
- package/src/geometries/capsule-geometry.ts +120 -0
- package/src/geometries/cylinder-geometry.ts +41 -0
- package/src/geometries/geometry-helpers.ts +34 -0
- package/src/geometries/ico-sphere-geometry.ts +96 -0
- package/src/geometries/plane-geometry.ts +64 -0
- package/src/geometries/sphere-geometry.ts +42 -0
- package/src/geometries/surface-of-revolution.ts +43 -0
- package/src/geometries/truncated-cone-geometry.ts +129 -0
- package/src/index.ts +28 -0
- package/src/lib/geometry-utils.ts +35 -0
- package/src/lib/geometry.ts +140 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Uber Technologies, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
Some primitive tessellation approaches were originally inspired by the TDL WebGL samples under
|
|
26
|
+
the New BSD License:
|
|
27
|
+
|
|
28
|
+
Copyright (c) 2011, Google Inc. All rights reserved.
|
|
29
|
+
|
|
30
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted
|
|
31
|
+
provided that the following conditions are met:
|
|
32
|
+
|
|
33
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions
|
|
34
|
+
and the following disclaimer.
|
|
35
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of
|
|
36
|
+
conditions and the following disclaimer in the documentation and/or other materials provided
|
|
37
|
+
with the distribution.
|
|
38
|
+
3. Neither the name of Google Inc. nor the names of its contributors may be used to endorse or
|
|
39
|
+
promote products derived from this software without specific prior written permission.
|
|
40
|
+
|
|
41
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
|
42
|
+
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
43
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
44
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
45
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
46
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
|
47
|
+
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
|
48
|
+
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
math.gl builds on docs and code from "gl-matrix", which is MIT licensed as follows:
|
|
53
|
+
|
|
54
|
+
Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV.
|
|
55
|
+
|
|
56
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
57
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
58
|
+
in the Software without restriction, including without limitation the rights
|
|
59
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
60
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
61
|
+
furnished to do so, subject to the following conditions:
|
|
62
|
+
|
|
63
|
+
The above copyright notice and this permission notice shall be included in
|
|
64
|
+
all copies or substantial portions of the Software.
|
|
65
|
+
|
|
66
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
67
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
68
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
69
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
70
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
71
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
72
|
+
THE SOFTWARE.
|
|
73
|
+
|
|
74
|
+
--
|
|
75
|
+
|
|
76
|
+
math.gl builds on docs and code from THREE.js, which is MIT licensed as follows:
|
|
77
|
+
|
|
78
|
+
The MIT License
|
|
79
|
+
|
|
80
|
+
Copyright © 2010-2017 three.js authors
|
|
81
|
+
|
|
82
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
83
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
84
|
+
in the Software without restriction, including without limitation the rights
|
|
85
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
86
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
87
|
+
furnished to do so, subject to the following conditions:
|
|
88
|
+
|
|
89
|
+
The above copyright notice and this permission notice shall be included in
|
|
90
|
+
all copies or substantial portions of the Software.
|
|
91
|
+
|
|
92
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
93
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
94
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
95
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
96
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
97
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
98
|
+
THE SOFTWARE.
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
math.gl includes certain files from Cesium (https://github.com/AnalyticalGraphicsInc/cesium) under the Apache 2 License:
|
|
103
|
+
|
|
104
|
+
Copyright 2011-2018 CesiumJS Contributors
|
|
105
|
+
|
|
106
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
107
|
+
you may not use this file except in compliance with the License.
|
|
108
|
+
You may obtain a copy of the License at
|
|
109
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
110
|
+
|
|
111
|
+
Unless required by applicable law or agreed to in writing, software
|
|
112
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
113
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
114
|
+
See the License for the specific language governing permissions and limitations under the License.
|
|
115
|
+
|
|
116
|
+
Cesium-derived code can be found in the submodule: modules/3d-tiles
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
The @math.gl/geometry primitive tessellators are adapted from luma.gl under the MIT License:
|
|
121
|
+
|
|
122
|
+
Copyright (c) 2020 vis.gl contributors
|
|
123
|
+
|
|
124
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
125
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
126
|
+
in the Software without restriction, including without limitation the rights
|
|
127
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
128
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
129
|
+
furnished to do so, subject to the following conditions:
|
|
130
|
+
|
|
131
|
+
The above copyright notice and this permission notice shall be included in
|
|
132
|
+
all copies or substantial portions of the Software.
|
|
133
|
+
|
|
134
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
135
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
136
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
137
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
138
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
139
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
140
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @math.gl/geometry
|
|
2
|
+
|
|
3
|
+
CPU-side geometry primitives and tessellation for 3D applications. The built-in box, capsule,
|
|
4
|
+
cylinder, plane and sphere follow the glTF 2.1 draft shape dimensions and coordinate conventions.
|
|
5
|
+
Infinite and partially infinite planes are represented analytically by `PlaneShape` in
|
|
6
|
+
`@math.gl/culling`; `PlaneGeometry` requires finite `sizeX` and `sizeZ` values.
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
import {CapsuleGeometry} from '@math.gl/geometry';
|
|
10
|
+
|
|
11
|
+
const capsule = new CapsuleGeometry({height: 2, radiusBottom: 0.5, radiusTop: 0.25});
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Every generated mesh uses `triangle-list` topology and the glTF attribute semantics `POSITION`,
|
|
15
|
+
`NORMAL` and `TEXCOORD_0`. This package contains no GPU or renderer abstractions.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Geometry } from "../lib/geometry.js";
|
|
2
|
+
import { type PrimitiveGeometryProps } from "./geometry-helpers.js";
|
|
3
|
+
export type BoxGeometryProps = PrimitiveGeometryProps & {
|
|
4
|
+
size?: readonly [number, number, number];
|
|
5
|
+
};
|
|
6
|
+
/** Tessellates the glTF box shape: centered at the origin with total axis lengths `size`. */
|
|
7
|
+
export declare class BoxGeometry extends Geometry {
|
|
8
|
+
constructor(props?: BoxGeometryProps);
|
|
9
|
+
}
|
|
10
|
+
export type CubeGeometryProps = PrimitiveGeometryProps & {
|
|
11
|
+
size?: number;
|
|
12
|
+
};
|
|
13
|
+
/** Convenience alias for an equal-sided box. */
|
|
14
|
+
export declare class CubeGeometry extends BoxGeometry {
|
|
15
|
+
constructor(props?: CubeGeometryProps);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=box-geometry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"box-geometry.d.ts","sourceRoot":"","sources":["../../src/geometries/box-geometry.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,QAAQ,EAA8B,2BAAwB;AACtE,OAAO,EAA8B,KAAK,sBAAsB,EAAC,8BAA2B;AAE5F,MAAM,MAAM,gBAAgB,GAAG,sBAAsB,GAAG;IAAC,IAAI,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;CAAC,CAAC;AAEnG,6FAA6F;AAC7F,qBAAa,WAAY,SAAQ,QAAQ;gBAC3B,KAAK,GAAE,gBAAqB;CAgDzC;AAED,MAAM,MAAM,iBAAiB,GAAG,sBAAsB,GAAG;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAC,CAAC;AAEzE,gDAAgD;AAChD,qBAAa,YAAa,SAAQ,WAAW;gBAC/B,KAAK,GAAE,iBAAsB;CAI1C"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { Geometry } from "../lib/geometry.js";
|
|
5
|
+
import { assertPositive, makeIndices } from "./geometry-helpers.js";
|
|
6
|
+
/** Tessellates the glTF box shape: centered at the origin with total axis lengths `size`. */
|
|
7
|
+
export class BoxGeometry extends Geometry {
|
|
8
|
+
constructor(props = {}) {
|
|
9
|
+
const size = props.size || [1, 1, 1];
|
|
10
|
+
assertPositive(size[0], 'size[0]');
|
|
11
|
+
assertPositive(size[1], 'size[1]');
|
|
12
|
+
assertPositive(size[2], 'size[2]');
|
|
13
|
+
const half = [size[0] / 2, size[1] / 2, size[2] / 2];
|
|
14
|
+
const positions = [];
|
|
15
|
+
const normals = [];
|
|
16
|
+
const texCoords = [];
|
|
17
|
+
const indices = [];
|
|
18
|
+
const faces = [
|
|
19
|
+
{ n: [1, 0, 0], u: [0, 0, -1], v: [0, 1, 0], h1: half[2], h2: half[1] },
|
|
20
|
+
{ n: [-1, 0, 0], u: [0, 0, 1], v: [0, 1, 0], h1: half[2], h2: half[1] },
|
|
21
|
+
{ n: [0, 1, 0], u: [1, 0, 0], v: [0, 0, -1], h1: half[0], h2: half[2] },
|
|
22
|
+
{ n: [0, -1, 0], u: [1, 0, 0], v: [0, 0, 1], h1: half[0], h2: half[2] },
|
|
23
|
+
{ n: [0, 0, 1], u: [1, 0, 0], v: [0, 1, 0], h1: half[0], h2: half[1] },
|
|
24
|
+
{ n: [0, 0, -1], u: [-1, 0, 0], v: [0, 1, 0], h1: half[0], h2: half[1] }
|
|
25
|
+
];
|
|
26
|
+
for (const face of faces) {
|
|
27
|
+
const base = positions.length / 3;
|
|
28
|
+
for (const [s, t, u, v] of [
|
|
29
|
+
[-1, -1, 0, 0],
|
|
30
|
+
[1, -1, 1, 0],
|
|
31
|
+
[1, 1, 1, 1],
|
|
32
|
+
[-1, 1, 0, 1]
|
|
33
|
+
]) {
|
|
34
|
+
positions.push(face.n[0] * half[0] + face.u[0] * face.h1 * s + face.v[0] * face.h2 * t, face.n[1] * half[1] + face.u[1] * face.h1 * s + face.v[1] * face.h2 * t, face.n[2] * half[2] + face.u[2] * face.h1 * s + face.v[2] * face.h2 * t);
|
|
35
|
+
normals.push(...face.n);
|
|
36
|
+
texCoords.push(u, v);
|
|
37
|
+
}
|
|
38
|
+
indices.push(base, base + 1, base + 2, base, base + 2, base + 3);
|
|
39
|
+
}
|
|
40
|
+
super({
|
|
41
|
+
id: props.id,
|
|
42
|
+
topology: 'triangle-list',
|
|
43
|
+
indices: makeIndices(24, indices),
|
|
44
|
+
attributes: {
|
|
45
|
+
POSITION: { size: 3, value: new Float32Array(positions) },
|
|
46
|
+
NORMAL: { size: 3, value: new Float32Array(normals) },
|
|
47
|
+
TEXCOORD_0: { size: 2, value: new Float32Array(texCoords) },
|
|
48
|
+
...props.attributes
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** Convenience alias for an equal-sided box. */
|
|
54
|
+
export class CubeGeometry extends BoxGeometry {
|
|
55
|
+
constructor(props = {}) {
|
|
56
|
+
const size = props.size ?? 1;
|
|
57
|
+
super({ ...props, size: [size, size, size] });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=box-geometry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"box-geometry.js","sourceRoot":"","sources":["../../src/geometries/box-geometry.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,QAAQ,EAA8B,2BAAwB;AACtE,OAAO,EAAC,cAAc,EAAE,WAAW,EAA8B,8BAA2B;AAI5F,6FAA6F;AAC7F,MAAM,OAAO,WAAY,SAAQ,QAAQ;IACvC,YAAY,QAA0B,EAAE;QACtC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACrC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;QACnC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;QACnC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;QACnC,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACr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,CAAC,OAAO,CAAC,EAAC;gBACnD,UAAU,EAAE,EAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,YAAY,CAAC,SAAS,CAAC,EAAC;gBACzD,GAAG,KAAK,CAAC,UAAU;aACsB;SAC5C,CAAC,CAAC;IACL,CAAC;CACF;AAID,gDAAgD;AAChD,MAAM,OAAO,YAAa,SAAQ,WAAW;IAC3C,YAAY,QAA2B,EAAE;QACvC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC;QAC7B,KAAK,CAAC,EAAC,GAAG,KAAK,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,EAAC,CAAC,CAAC;IAC9C,CAAC;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Geometry } from "../lib/geometry.js";
|
|
2
|
+
import { type PrimitiveGeometryProps } from "./geometry-helpers.js";
|
|
3
|
+
export type CapsuleGeometryProps = PrimitiveGeometryProps & {
|
|
4
|
+
height?: number;
|
|
5
|
+
radiusBottom?: number;
|
|
6
|
+
radiusTop?: number;
|
|
7
|
+
nradial?: number;
|
|
8
|
+
ncap?: number;
|
|
9
|
+
nvertical?: number;
|
|
10
|
+
};
|
|
11
|
+
/** Tessellates the convex hull of two endpoint spheres described by the glTF capsule shape. */
|
|
12
|
+
export declare class CapsuleGeometry extends Geometry {
|
|
13
|
+
constructor(props?: CapsuleGeometryProps);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=capsule-geometry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capsule-geometry.d.ts","sourceRoot":"","sources":["../../src/geometries/capsule-geometry.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,QAAQ,EAAC,2BAAwB;AACzC,OAAO,EAIL,KAAK,sBAAsB,EAC5B,8BAA2B;AAG5B,MAAM,MAAM,oBAAoB,GAAG,sBAAsB,GAAG;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,+FAA+F;AAC/F,qBAAa,eAAgB,SAAQ,QAAQ;gBAC/B,KAAK,GAAE,oBAAyB;CA4E7C"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { Geometry } from "../lib/geometry.js";
|
|
5
|
+
import { assertNonNegative, assertPositive, assertSegments } from "./geometry-helpers.js";
|
|
6
|
+
import { makeSurfaceOfRevolution } from "./surface-of-revolution.js";
|
|
7
|
+
/** Tessellates the convex hull of two endpoint spheres described by the glTF capsule shape. */
|
|
8
|
+
export class CapsuleGeometry extends Geometry {
|
|
9
|
+
constructor(props = {}) {
|
|
10
|
+
const { height = 1, radiusBottom = 0.5, radiusTop = 0.5, nradial = 10, ncap = 5, nvertical = 1 } = props;
|
|
11
|
+
assertPositive(height, 'height');
|
|
12
|
+
assertNonNegative(radiusBottom, 'radiusBottom');
|
|
13
|
+
assertNonNegative(radiusTop, 'radiusTop');
|
|
14
|
+
if (radiusBottom === 0 && radiusTop === 0)
|
|
15
|
+
throw new Error('At least one radius must be greater than zero');
|
|
16
|
+
assertSegments(nradial, 'nradial', 3);
|
|
17
|
+
assertSegments(ncap, 'ncap', 1);
|
|
18
|
+
assertSegments(nvertical, 'nvertical', 1);
|
|
19
|
+
const rings = [];
|
|
20
|
+
const deltaRadius = radiusTop - radiusBottom;
|
|
21
|
+
if (Math.abs(deltaRadius) >= height) {
|
|
22
|
+
const topWins = radiusTop >= radiusBottom;
|
|
23
|
+
const radius = topWins ? radiusTop : radiusBottom;
|
|
24
|
+
const center = topWins ? height / 2 : -height / 2;
|
|
25
|
+
addSphereRings(rings, center, radius, ncap * 2);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
const sinSlope = deltaRadius / height;
|
|
29
|
+
const radialNormal = Math.sqrt(1 - sinSlope * sinSlope);
|
|
30
|
+
const sideNormalY = -sinSlope;
|
|
31
|
+
const bottomCenter = -height / 2;
|
|
32
|
+
const topCenter = height / 2;
|
|
33
|
+
for (let i = 0; i <= ncap; i++) {
|
|
34
|
+
const normalY = -1 + ((sideNormalY + 1) * i) / ncap;
|
|
35
|
+
const normalRadius = Math.sqrt(Math.max(0, 1 - normalY * normalY));
|
|
36
|
+
rings.push({
|
|
37
|
+
radius: radiusBottom * normalRadius,
|
|
38
|
+
y: bottomCenter + radiusBottom * normalY,
|
|
39
|
+
normalRadius,
|
|
40
|
+
normalY
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
for (let i = 1; i <= nvertical; i++) {
|
|
44
|
+
const t = i / nvertical;
|
|
45
|
+
const radius = radiusBottom + deltaRadius * t;
|
|
46
|
+
const center = bottomCenter + height * t;
|
|
47
|
+
rings.push({
|
|
48
|
+
radius: radius * radialNormal,
|
|
49
|
+
y: center + radius * sideNormalY,
|
|
50
|
+
normalRadius: radialNormal,
|
|
51
|
+
normalY: sideNormalY
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
for (let i = 1; i <= ncap; i++) {
|
|
55
|
+
const normalY = sideNormalY + ((1 - sideNormalY) * i) / ncap;
|
|
56
|
+
const normalRadius = Math.sqrt(Math.max(0, 1 - normalY * normalY));
|
|
57
|
+
rings.push({
|
|
58
|
+
radius: radiusTop * normalRadius,
|
|
59
|
+
y: topCenter + radiusTop * normalY,
|
|
60
|
+
normalRadius,
|
|
61
|
+
normalY
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const mesh = makeSurfaceOfRevolution(rings, nradial);
|
|
66
|
+
super({
|
|
67
|
+
id: props.id,
|
|
68
|
+
topology: 'triangle-list',
|
|
69
|
+
indices: mesh.indexArray,
|
|
70
|
+
attributes: {
|
|
71
|
+
POSITION: { size: 3, value: new Float32Array(mesh.positions) },
|
|
72
|
+
NORMAL: { size: 3, value: new Float32Array(mesh.normals) },
|
|
73
|
+
TEXCOORD_0: { size: 2, value: new Float32Array(mesh.texCoords) },
|
|
74
|
+
...props.attributes
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function addSphereRings(rings, center, radius, segments) {
|
|
80
|
+
for (let i = 0; i <= segments; i++) {
|
|
81
|
+
const angle = -Math.PI / 2 + (i / segments) * Math.PI;
|
|
82
|
+
const normalRadius = Math.cos(angle);
|
|
83
|
+
const normalY = Math.sin(angle);
|
|
84
|
+
rings.push({
|
|
85
|
+
radius: radius * normalRadius,
|
|
86
|
+
y: center + radius * normalY,
|
|
87
|
+
normalRadius,
|
|
88
|
+
normalY
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=capsule-geometry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capsule-geometry.js","sourceRoot":"","sources":["../../src/geometries/capsule-geometry.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,QAAQ,EAAC,2BAAwB;AACzC,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,cAAc,EAEf,8BAA2B;AAC5B,OAAO,EAAC,uBAAuB,EAAmB,mCAAgC;AAWlF,+FAA+F;AAC/F,MAAM,OAAO,eAAgB,SAAQ,QAAQ;IAC3C,YAAY,QAA8B,EAAE;QAC1C,MAAM,EACJ,MAAM,GAAG,CAAC,EACV,YAAY,GAAG,GAAG,EAClB,SAAS,GAAG,GAAG,EACf,OAAO,GAAG,EAAE,EACZ,IAAI,GAAG,CAAC,EACR,SAAS,GAAG,CAAC,EACd,GAAG,KAAK,CAA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AM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAChC,KAAK,CAAC,IAAI,CAAC;YACT,MAAM,EAAE,MAAM,GAAG,YAAY;YAC7B,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO;YAC5B,YAAY;YACZ,OAAO;SACR,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TruncatedConeGeometry, type TruncatedConeGeometryProps } from "./truncated-cone-geometry.js";
|
|
2
|
+
export type CylinderGeometryProps = Omit<TruncatedConeGeometryProps, 'topRadius' | 'bottomRadius' | 'topCap' | 'bottomCap' | 'verticalAxis'> & {
|
|
3
|
+
radiusTop?: number;
|
|
4
|
+
radiusBottom?: number;
|
|
5
|
+
};
|
|
6
|
+
/** Tessellates the closed, Y-aligned glTF cylinder shape, including tapered cylinders. */
|
|
7
|
+
export declare class CylinderGeometry extends TruncatedConeGeometry {
|
|
8
|
+
constructor(props?: CylinderGeometryProps);
|
|
9
|
+
}
|
|
10
|
+
export type ConeGeometryProps = Omit<TruncatedConeGeometryProps, 'topRadius' | 'bottomRadius'> & {
|
|
11
|
+
radius?: number;
|
|
12
|
+
};
|
|
13
|
+
/** Convenience closed cone with its point at +Y. */
|
|
14
|
+
export declare class ConeGeometry extends TruncatedConeGeometry {
|
|
15
|
+
constructor(props?: ConeGeometryProps);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=cylinder-geometry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cylinder-geometry.d.ts","sourceRoot":"","sources":["../../src/geometries/cylinder-geometry.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,qBAAqB,EAAE,KAAK,0BAA0B,EAAC,qCAAkC;AAEjG,MAAM,MAAM,qBAAqB,GAAG,IAAI,CACtC,0BAA0B,EAC1B,WAAW,GAAG,cAAc,GAAG,QAAQ,GAAG,WAAW,GAAG,cAAc,CACvE,GAAG;IACF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,0FAA0F;AAC1F,qBAAa,gBAAiB,SAAQ,qBAAqB;gBAC7C,KAAK,GAAE,qBAA0B;CAY9C;AAED,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,0BAA0B,EAAE,WAAW,GAAG,cAAc,CAAC,GAAG;IAC/F,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,oDAAoD;AACpD,qBAAa,YAAa,SAAQ,qBAAqB;gBACzC,KAAK,GAAE,iBAAsB;CAI1C"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { TruncatedConeGeometry } from "./truncated-cone-geometry.js";
|
|
5
|
+
/** Tessellates the closed, Y-aligned glTF cylinder shape, including tapered cylinders. */
|
|
6
|
+
export class CylinderGeometry extends TruncatedConeGeometry {
|
|
7
|
+
constructor(props = {}) {
|
|
8
|
+
const { height = 2, radiusTop = 0.5, radiusBottom = 0.5 } = props;
|
|
9
|
+
super({
|
|
10
|
+
...props,
|
|
11
|
+
height,
|
|
12
|
+
topRadius: radiusTop,
|
|
13
|
+
bottomRadius: radiusBottom,
|
|
14
|
+
topCap: true,
|
|
15
|
+
bottomCap: true,
|
|
16
|
+
verticalAxis: 'y'
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/** Convenience closed cone with its point at +Y. */
|
|
21
|
+
export class ConeGeometry extends TruncatedConeGeometry {
|
|
22
|
+
constructor(props = {}) {
|
|
23
|
+
const { radius = 0.5, topCap = false, bottomCap = true } = props;
|
|
24
|
+
super({ ...props, topRadius: 0, bottomRadius: radius, topCap, bottomCap });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=cylinder-geometry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cylinder-geometry.js","sourceRoot":"","sources":["../../src/geometries/cylinder-geometry.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,qBAAqB,EAAkC,qCAAkC;AAUjG,0FAA0F;AAC1F,MAAM,OAAO,gBAAiB,SAAQ,qBAAqB;IACzD,YAAY,QAA+B,EAAE;QAC3C,MAAM,EAAC,MAAM,GAAG,CAAC,EAAE,SAAS,GAAG,GAAG,EAAE,YAAY,GAAG,GAAG,EAAC,GAAG,KAAK,CAAC;QAChE,KAAK,CAAC;YACJ,GAAG,KAAK;YACR,MAAM;YACN,SAAS,EAAE,SAAS;YACpB,YAAY,EAAE,YAAY;YAC1B,MAAM,EAAE,IAAI;YACZ,SAAS,EAAE,IAAI;YACf,YAAY,EAAE,GAAG;SAClB,CAAC,CAAC;IACL,CAAC;CACF;AAMD,oDAAoD;AACpD,MAAM,OAAO,YAAa,SAAQ,qBAAqB;IACrD,YAAY,QAA2B,EAAE;QACvC,MAAM,EAAC,MAAM,GAAG,GAAG,EAAE,MAAM,GAAG,KAAK,EAAE,SAAS,GAAG,IAAI,EAAC,GAAG,KAAK,CAAC;QAC/D,KAAK,CAAC,EAAC,GAAG,KAAK,EAAE,SAAS,EAAE,CAAC,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAC,CAAC,CAAC;IAC3E,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { GeometryAttributeInput } from "../lib/geometry.js";
|
|
2
|
+
export type PrimitiveGeometryProps = {
|
|
3
|
+
id?: string;
|
|
4
|
+
attributes?: Record<string, GeometryAttributeInput>;
|
|
5
|
+
};
|
|
6
|
+
export declare function assertPositive(value: number, name: string): void;
|
|
7
|
+
export declare function assertNonNegative(value: number, name: string): void;
|
|
8
|
+
export declare function assertSegments(value: number, name: string, minimum?: number): void;
|
|
9
|
+
export declare function makeIndices(vertexCount: number, values: number[]): Uint16Array | Uint32Array;
|
|
10
|
+
export type MeshData = {
|
|
11
|
+
positions: number[];
|
|
12
|
+
normals: number[];
|
|
13
|
+
texCoords: number[];
|
|
14
|
+
indices: number[];
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=geometry-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry-helpers.d.ts","sourceRoot":"","sources":["../../src/geometries/geometry-helpers.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,sBAAsB,EAAC,2BAAwB;AAE5D,MAAM,MAAM,sBAAsB,GAAG;IACnC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;CACrD,CAAC;AAEF,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAEhE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAEnE;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,SAAI,GAAG,IAAI,CAG7E;AAED,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,WAAW,GAAG,WAAW,CAE5F;AAED,MAAM,MAAM,QAAQ,GAAG;IACrB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
export function assertPositive(value, name) {
|
|
5
|
+
if (!Number.isFinite(value) || value <= 0)
|
|
6
|
+
throw new Error(`${name} must be greater than zero`);
|
|
7
|
+
}
|
|
8
|
+
export function assertNonNegative(value, name) {
|
|
9
|
+
if (!Number.isFinite(value) || value < 0)
|
|
10
|
+
throw new Error(`${name} must be non-negative`);
|
|
11
|
+
}
|
|
12
|
+
export function assertSegments(value, name, minimum = 1) {
|
|
13
|
+
if (!Number.isInteger(value) || value < minimum)
|
|
14
|
+
throw new Error(`${name} must be an integer >= ${minimum}`);
|
|
15
|
+
}
|
|
16
|
+
export function makeIndices(vertexCount, values) {
|
|
17
|
+
return vertexCount > 0xffff ? new Uint32Array(values) : new Uint16Array(values);
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=geometry-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry-helpers.js","sourceRoot":"","sources":["../../src/geometries/geometry-helpers.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AASpC,MAAM,UAAU,cAAc,CAAC,KAAa,EAAE,IAAY;IACxD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,4BAA4B,CAAC,CAAC;AAClG,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,KAAa,EAAE,IAAY;IAC3D,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,uBAAuB,CAAC,CAAC;AAC5F,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAa,EAAE,IAAY,EAAE,OAAO,GAAG,CAAC;IACrE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,OAAO;QAC7C,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,0BAA0B,OAAO,EAAE,CAAC,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,WAAmB,EAAE,MAAgB;IAC/D,OAAO,WAAW,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;AAClF,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Geometry } from "../lib/geometry.js";
|
|
2
|
+
import { type PrimitiveGeometryProps } from "./geometry-helpers.js";
|
|
3
|
+
export type IcoSphereGeometryProps = PrimitiveGeometryProps & {
|
|
4
|
+
radius?: number;
|
|
5
|
+
iterations?: number;
|
|
6
|
+
};
|
|
7
|
+
/** Subdivided icosahedron projected onto a sphere. Returned as a non-indexed triangle list. */
|
|
8
|
+
export declare class IcoSphereGeometry extends Geometry {
|
|
9
|
+
constructor(props?: IcoSphereGeometryProps);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=ico-sphere-geometry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ico-sphere-geometry.d.ts","sourceRoot":"","sources":["../../src/geometries/ico-sphere-geometry.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,QAAQ,EAAC,2BAAwB;AACzC,OAAO,EAAiC,KAAK,sBAAsB,EAAC,8BAA2B;AAE/F,MAAM,MAAM,sBAAsB,GAAG,sBAAsB,GAAG;IAC5D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,+FAA+F;AAC/F,qBAAa,iBAAkB,SAAQ,QAAQ;gBACjC,KAAK,GAAE,sBAA2B;CA4E/C"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { Geometry } from "../lib/geometry.js";
|
|
5
|
+
import { assertPositive, assertSegments } from "./geometry-helpers.js";
|
|
6
|
+
/** Subdivided icosahedron projected onto a sphere. Returned as a non-indexed triangle list. */
|
|
7
|
+
export class IcoSphereGeometry extends Geometry {
|
|
8
|
+
constructor(props = {}) {
|
|
9
|
+
const { radius = 0.5, iterations = 0 } = props;
|
|
10
|
+
assertPositive(radius, 'radius');
|
|
11
|
+
assertSegments(iterations, 'iterations', 0);
|
|
12
|
+
if (iterations > 8)
|
|
13
|
+
throw new Error('iterations must be <= 8');
|
|
14
|
+
const t = (1 + Math.sqrt(5)) / 2;
|
|
15
|
+
const vertices = [
|
|
16
|
+
[-1, t, 0],
|
|
17
|
+
[1, t, 0],
|
|
18
|
+
[-1, -t, 0],
|
|
19
|
+
[1, -t, 0],
|
|
20
|
+
[0, -1, t],
|
|
21
|
+
[0, 1, t],
|
|
22
|
+
[0, -1, -t],
|
|
23
|
+
[0, 1, -t],
|
|
24
|
+
[t, 0, -1],
|
|
25
|
+
[t, 0, 1],
|
|
26
|
+
[-t, 0, -1],
|
|
27
|
+
[-t, 0, 1]
|
|
28
|
+
].map(normalize);
|
|
29
|
+
let faces = [
|
|
30
|
+
[0, 11, 5],
|
|
31
|
+
[0, 5, 1],
|
|
32
|
+
[0, 1, 7],
|
|
33
|
+
[0, 7, 10],
|
|
34
|
+
[0, 10, 11],
|
|
35
|
+
[1, 5, 9],
|
|
36
|
+
[5, 11, 4],
|
|
37
|
+
[11, 10, 2],
|
|
38
|
+
[10, 7, 6],
|
|
39
|
+
[7, 1, 8],
|
|
40
|
+
[3, 9, 4],
|
|
41
|
+
[3, 4, 2],
|
|
42
|
+
[3, 2, 6],
|
|
43
|
+
[3, 6, 8],
|
|
44
|
+
[3, 8, 9],
|
|
45
|
+
[4, 9, 5],
|
|
46
|
+
[2, 4, 11],
|
|
47
|
+
[6, 2, 10],
|
|
48
|
+
[8, 6, 7],
|
|
49
|
+
[9, 8, 1]
|
|
50
|
+
].map(face => face.map(index => vertices[index]));
|
|
51
|
+
for (let iteration = 0; iteration < iterations; iteration++) {
|
|
52
|
+
const subdivided = [];
|
|
53
|
+
for (const [a, b, c] of faces) {
|
|
54
|
+
const ab = normalize([a[0] + b[0], a[1] + b[1], a[2] + b[2]]);
|
|
55
|
+
const bc = normalize([b[0] + c[0], b[1] + c[1], b[2] + c[2]]);
|
|
56
|
+
const ca = normalize([c[0] + a[0], c[1] + a[1], c[2] + a[2]]);
|
|
57
|
+
subdivided.push([a, ab, ca], [b, bc, ab], [c, ca, bc], [ab, bc, ca]);
|
|
58
|
+
}
|
|
59
|
+
faces = subdivided;
|
|
60
|
+
}
|
|
61
|
+
const positions = [];
|
|
62
|
+
const normals = [];
|
|
63
|
+
const texCoords = [];
|
|
64
|
+
for (const face of faces) {
|
|
65
|
+
for (const normal of face) {
|
|
66
|
+
positions.push(normal[0] * radius, normal[1] * radius, normal[2] * radius);
|
|
67
|
+
normals.push(...normal);
|
|
68
|
+
texCoords.push(0.5 + Math.atan2(normal[0], normal[2]) / (2 * Math.PI), 0.5 - Math.asin(normal[1]) / Math.PI);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
super({
|
|
72
|
+
id: props.id,
|
|
73
|
+
topology: 'triangle-list',
|
|
74
|
+
attributes: {
|
|
75
|
+
POSITION: { size: 3, value: new Float32Array(positions) },
|
|
76
|
+
NORMAL: { size: 3, value: new Float32Array(normals) },
|
|
77
|
+
TEXCOORD_0: { size: 2, value: new Float32Array(texCoords) },
|
|
78
|
+
...props.attributes
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function normalize(vector) {
|
|
84
|
+
const length = Math.hypot(...vector);
|
|
85
|
+
return vector.map(component => component / length);
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=ico-sphere-geometry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ico-sphere-geometry.js","sourceRoot":"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GAAG,MAAM,CAAC,CAAC;IACrC,OAAO,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,GAAG,MAAM,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Geometry } from "../lib/geometry.js";
|
|
2
|
+
import { type PrimitiveGeometryProps } from "./geometry-helpers.js";
|
|
3
|
+
export type PlaneGeometryProps = PrimitiveGeometryProps & {
|
|
4
|
+
sizeX: number;
|
|
5
|
+
sizeZ: number;
|
|
6
|
+
nx?: number;
|
|
7
|
+
nz?: number;
|
|
8
|
+
};
|
|
9
|
+
/** Tessellates a finite glTF plane in XZ with its front face and normal pointing +Y. */
|
|
10
|
+
export declare class PlaneGeometry extends Geometry {
|
|
11
|
+
constructor(props: PlaneGeometryProps);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=plane-geometry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plane-geometry.d.ts","sourceRoot":"","sources":["../../src/geometries/plane-geometry.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,QAAQ,EAAC,2BAAwB;AACzC,OAAO,EAIL,KAAK,sBAAsB,EAC5B,8BAA2B;AAE5B,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,GAAG;IACxD,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,wFAAwF;AACxF,qBAAa,aAAc,SAAQ,QAAQ;gBAC7B,KAAK,EAAE,kBAAkB;CA0CtC"}
|