frenet-serret-frames 2.1.0 → 3.0.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/.nojekyll +0 -0
- package/CHANGELOG.md +16 -0
- package/README.md +57 -33
- package/index.js +104 -89
- package/package.json +10 -13
- package/types/index.d.ts +5 -27
- package/types/types.d.ts +35 -0
- package/types.js +30 -0
package/.nojekyll
ADDED
|
File without changes
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
# [3.0.0](https://github.com/dmnsgn/frenet-serret-frames/compare/v2.1.0...v3.0.0) (2023-07-31)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* add typed array support ([d766f7c](https://github.com/dmnsgn/frenet-serret-frames/commit/d766f7c1beafcd23130d95f4bc6faa591ae07f10))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### BREAKING CHANGES
|
|
14
|
+
|
|
15
|
+
* use pex-math
|
|
16
|
+
* use geometry as first argument
|
|
17
|
+
* return augmented geometry and not frames
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
5
21
|
# [2.1.0](https://github.com/dmnsgn/frenet-serret-frames/compare/v2.0.1...v2.1.0) (2021-10-02)
|
|
6
22
|
|
|
7
23
|
|
package/README.md
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/frenet-serret-frames)
|
|
4
4
|
[](https://www.npmjs.com/package/frenet-serret-frames)
|
|
5
|
-
[](https://
|
|
6
|
-
[](https://bundlephobia.com/package/frenet-serret-frames)
|
|
6
|
+
[](https://github.com/dmnsgn/frenet-serret-frames/blob/main/package.json)
|
|
7
7
|
[](https://github.com/microsoft/TypeScript)
|
|
8
8
|
[](https://conventionalcommits.org)
|
|
9
9
|
[](https://github.com/prettier/prettier)
|
|
10
10
|
[](https://github.com/eslint/eslint)
|
|
11
11
|
[](https://github.com/dmnsgn/frenet-serret-frames/blob/main/LICENSE.md)
|
|
12
12
|
|
|
13
|
-
Compute Frenet-Serret frames for a
|
|
13
|
+
Compute Frenet-Serret frames for a geometry of 3D positions and optionally provided tangents.
|
|
14
14
|
|
|
15
15
|
[](https://paypal.me/dmnsgn)
|
|
16
16
|
[](https://commerce.coinbase.com/checkout/56cbdf28-e323-48d8-9c98-7019e72c97f3)
|
|
@@ -45,8 +45,8 @@ const frames = frenetSerretFrames(path, tangents, {
|
|
|
45
45
|
## Functions
|
|
46
46
|
|
|
47
47
|
<dl>
|
|
48
|
-
<dt><a href="#frenetSerretFrames">frenetSerretFrames(
|
|
49
|
-
<dd><p>Compute Frenet-Serret frames for a
|
|
48
|
+
<dt><a href="#frenetSerretFrames">frenetSerretFrames(geometry, [options])</a> ⇒ <code><a href="#SimplicialComplexWithTNB">SimplicialComplexWithTNB</a></code></dt>
|
|
49
|
+
<dd><p>Compute Frenet-Serret frames for a geometry of 3D positions and optionally provided tangents.</p>
|
|
50
50
|
</dd>
|
|
51
51
|
</dl>
|
|
52
52
|
|
|
@@ -55,40 +55,78 @@ const frames = frenetSerretFrames(path, tangents, {
|
|
|
55
55
|
<dl>
|
|
56
56
|
<dt><a href="#vec3">vec3</a> : <code>Array.<number></code></dt>
|
|
57
57
|
<dd></dd>
|
|
58
|
-
<dt><a href="#
|
|
58
|
+
<dt><a href="#SimplicialComplex">SimplicialComplex</a> : <code>object</code></dt>
|
|
59
|
+
<dd><p>Geometry definition.</p>
|
|
60
|
+
</dd>
|
|
61
|
+
<dt><a href="#SimplicialComplexWithTNB">SimplicialComplexWithTNB</a> : <code>object</code></dt>
|
|
62
|
+
<dd><p>Geometry definition augmented with tangent, normals and binormals.</p>
|
|
63
|
+
</dd>
|
|
64
|
+
<dt><a href="#Options">Options</a> : <code>object</code></dt>
|
|
59
65
|
<dd><p>Options for frames computation. All optional.</p>
|
|
60
66
|
</dd>
|
|
61
|
-
<dt><a href="#Frame">Frame</a> : <code>Object</code></dt>
|
|
62
|
-
<dd></dd>
|
|
63
67
|
</dl>
|
|
64
68
|
|
|
65
69
|
<a name="frenetSerretFrames"></a>
|
|
66
70
|
|
|
67
|
-
## frenetSerretFrames(
|
|
71
|
+
## frenetSerretFrames(geometry, [options]) ⇒ [<code>SimplicialComplexWithTNB</code>](#SimplicialComplexWithTNB)
|
|
68
72
|
|
|
69
|
-
Compute Frenet-Serret frames for a
|
|
73
|
+
Compute Frenet-Serret frames for a geometry of 3D positions and optionally provided tangents.
|
|
70
74
|
|
|
71
|
-
**Kind**: global function
|
|
75
|
+
**Kind**: global function
|
|
72
76
|
**See**: [Frenet–Serret formulas](https://en.wikipedia.org/wiki/Frenet%E2%80%93Serret_formulas)
|
|
73
77
|
|
|
74
|
-
| Param | Type
|
|
75
|
-
| --------- |
|
|
76
|
-
|
|
|
77
|
-
|
|
|
78
|
-
| [options] | [<code>Options</code>](#Options) | <code>{}</code> | |
|
|
78
|
+
| Param | Type | Default |
|
|
79
|
+
| --------- | ---------------------------------------------------- | --------------- |
|
|
80
|
+
| geometry | [<code>SimplicialComplex</code>](#SimplicialComplex) | |
|
|
81
|
+
| [options] | [<code>Options</code>](#Options) | <code>{}</code> |
|
|
79
82
|
|
|
80
83
|
<a name="vec3"></a>
|
|
81
84
|
|
|
82
85
|
## vec3 : <code>Array.<number></code>
|
|
83
86
|
|
|
84
|
-
**Kind**: global typedef
|
|
87
|
+
**Kind**: global typedef
|
|
88
|
+
<a name="SimplicialComplex"></a>
|
|
89
|
+
|
|
90
|
+
## SimplicialComplex : <code>object</code>
|
|
91
|
+
|
|
92
|
+
Geometry definition.
|
|
93
|
+
|
|
94
|
+
**Kind**: global typedef
|
|
95
|
+
**Properties**
|
|
96
|
+
|
|
97
|
+
| Name | Type |
|
|
98
|
+
| ---------- | --------------------------------------------------------------------------------------------------------------------------- |
|
|
99
|
+
| positions | <code>Float32Array</code> \| [<code>Array.<vec3></code>](#vec3) |
|
|
100
|
+
| [tangents] | <code>Float32Array</code> \| [<code>Array.<vec3></code>](#vec3) |
|
|
101
|
+
| [normals] | <code>Float32Array</code> \| [<code>Array.<vec3></code>](#vec3) |
|
|
102
|
+
| [uvs] | <code>Float32Array</code> \| [<code>Array.<vec3></code>](#vec3) |
|
|
103
|
+
| [cells] | <code>Uint8Array</code> \| <code>Uint16Array</code> \| <code>Uint32Array</code> \| [<code>Array.<vec3></code>](#vec3) |
|
|
104
|
+
|
|
105
|
+
<a name="SimplicialComplexWithTNB"></a>
|
|
106
|
+
|
|
107
|
+
## SimplicialComplexWithTNB : <code>object</code>
|
|
108
|
+
|
|
109
|
+
Geometry definition augmented with tangent, normals and binormals.
|
|
110
|
+
|
|
111
|
+
**Kind**: global typedef
|
|
112
|
+
**Properties**
|
|
113
|
+
|
|
114
|
+
| Name | Type |
|
|
115
|
+
| --------- | --------------------------------------------------------------------------------------------------------------------------- |
|
|
116
|
+
| positions | <code>Float32Array</code> \| [<code>Array.<vec3></code>](#vec3) |
|
|
117
|
+
| tangents | <code>Float32Array</code> \| [<code>Array.<vec3></code>](#vec3) |
|
|
118
|
+
| normals | <code>Float32Array</code> \| [<code>Array.<vec3></code>](#vec3) |
|
|
119
|
+
| binormals | <code>Float32Array</code> \| [<code>Array.<vec3></code>](#vec3) |
|
|
120
|
+
| [uvs] | <code>Float32Array</code> \| [<code>Array.<vec3></code>](#vec3) |
|
|
121
|
+
| [cells] | <code>Uint8Array</code> \| <code>Uint16Array</code> \| <code>Uint32Array</code> \| [<code>Array.<vec3></code>](#vec3) |
|
|
122
|
+
|
|
85
123
|
<a name="Options"></a>
|
|
86
124
|
|
|
87
|
-
## Options : <code>
|
|
125
|
+
## Options : <code>object</code>
|
|
88
126
|
|
|
89
127
|
Options for frames computation. All optional.
|
|
90
128
|
|
|
91
|
-
**Kind**: global typedef
|
|
129
|
+
**Kind**: global typedef
|
|
92
130
|
**Properties**
|
|
93
131
|
|
|
94
132
|
| Name | Type | Default | Description |
|
|
@@ -96,20 +134,6 @@ Options for frames computation. All optional.
|
|
|
96
134
|
| [closed] | <code>boolean</code> | <code>false</code> | Specify is the path is closed. |
|
|
97
135
|
| [initialNormal] | [<code>vec3</code>](#vec3) | <code></code> | Specify a starting normal for the frames. Default to the direction of the minimum tangent component. |
|
|
98
136
|
|
|
99
|
-
<a name="Frame"></a>
|
|
100
|
-
|
|
101
|
-
## Frame : <code>Object</code>
|
|
102
|
-
|
|
103
|
-
**Kind**: global typedef
|
|
104
|
-
**Properties**
|
|
105
|
-
|
|
106
|
-
| Name | Type |
|
|
107
|
-
| -------- | -------------------------- |
|
|
108
|
-
| position | [<code>vec3</code>](#vec3) |
|
|
109
|
-
| normal | [<code>vec3</code>](#vec3) |
|
|
110
|
-
| binormal | [<code>vec3</code>](#vec3) |
|
|
111
|
-
| tangent | [<code>vec3</code>](#vec3) |
|
|
112
|
-
|
|
113
137
|
<!-- api-end -->
|
|
114
138
|
|
|
115
139
|
## License
|
package/index.js
CHANGED
|
@@ -1,132 +1,147 @@
|
|
|
1
|
-
import { vec3, quat } from "
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @typedef {number[]} vec3
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @typedef {Object} Options Options for frames computation. All optional.
|
|
10
|
-
* @property {boolean} [closed=false] Specify is the path is closed.
|
|
11
|
-
* @property {vec3} [initialNormal=null] Specify a starting normal for the frames. Default to the direction of the minimum tangent component.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @typedef {Object} Frame
|
|
16
|
-
* @property {vec3} position
|
|
17
|
-
* @property {vec3} normal
|
|
18
|
-
* @property {vec3} binormal
|
|
19
|
-
* @property {vec3} tangent
|
|
20
|
-
*/
|
|
1
|
+
import { avec3, vec3, quat, utils } from "pex-math";
|
|
2
|
+
import computePathTangents from "path-tangents";
|
|
21
3
|
|
|
22
4
|
const X_UP = [1, 0, 0];
|
|
23
5
|
const Y_UP = [0, 1, 0];
|
|
24
6
|
const Z_UP = [0, 0, 1];
|
|
25
7
|
|
|
26
8
|
/**
|
|
27
|
-
* Compute Frenet-Serret frames for a
|
|
9
|
+
* Compute Frenet-Serret frames for a geometry of 3D positions and optionally provided tangents.
|
|
28
10
|
*
|
|
29
|
-
* @param {
|
|
30
|
-
* @param {
|
|
31
|
-
* @
|
|
32
|
-
* @returns {Frame[]}
|
|
11
|
+
* @param {import("./types.js").SimplicialComplex} geometry
|
|
12
|
+
* @param {import("./types.js").Options} [options={}]
|
|
13
|
+
* @returns {import("./types.js").SimplicialComplexWithTNB}
|
|
33
14
|
*
|
|
34
15
|
* @see [Frenet–Serret formulas]{@link https://en.wikipedia.org/wiki/Frenet%E2%80%93Serret_formulas}
|
|
35
16
|
*/
|
|
36
|
-
function frenetSerretFrames(
|
|
17
|
+
function frenetSerretFrames(geometry, options) {
|
|
18
|
+
const isTypedArray = !Array.isArray(geometry.positions);
|
|
19
|
+
|
|
37
20
|
// Extends options
|
|
38
|
-
const { closed = false, initialNormal = null } = {
|
|
39
|
-
...options,
|
|
40
|
-
};
|
|
21
|
+
const { closed = false, initialNormal = null } = { ...options };
|
|
41
22
|
|
|
42
|
-
const
|
|
43
|
-
|
|
23
|
+
const size = geometry.positions.length / (isTypedArray ? 3 : 1);
|
|
24
|
+
geometry.tangents ||= computePathTangents(geometry.positions, closed);
|
|
25
|
+
geometry.normals ||= isTypedArray ? new Float32Array(size * 3) : [];
|
|
26
|
+
geometry.binormals ||= isTypedArray ? new Float32Array(size * 3) : [];
|
|
44
27
|
|
|
45
|
-
|
|
46
|
-
let tangent = tangents[0];
|
|
47
|
-
let normal = initialNormal || vec3.create();
|
|
28
|
+
let v = vec3.create();
|
|
48
29
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
30
|
+
// Compute initial frame
|
|
31
|
+
let tangent = isTypedArray
|
|
32
|
+
? geometry.tangents.slice(0, 3)
|
|
33
|
+
: geometry.tangents[0];
|
|
34
|
+
let normal;
|
|
35
|
+
|
|
36
|
+
if (initialNormal) {
|
|
37
|
+
normal = [...initialNormal];
|
|
38
|
+
} else {
|
|
39
|
+
const atx = Math.abs(tangent[0]);
|
|
40
|
+
const aty = Math.abs(tangent[1]);
|
|
41
|
+
const atz = Math.abs(tangent[2]);
|
|
52
42
|
|
|
53
|
-
if (!initialNormal) {
|
|
54
43
|
if (aty > atx && aty >= atz) {
|
|
55
|
-
vec3.cross(
|
|
44
|
+
v = vec3.cross([...tangent], X_UP);
|
|
56
45
|
} else if (atz > atx && atz >= aty) {
|
|
57
|
-
vec3.cross(
|
|
46
|
+
v = vec3.cross([...tangent], Y_UP);
|
|
58
47
|
} else {
|
|
59
|
-
vec3.cross(
|
|
48
|
+
v = vec3.cross([...tangent], Z_UP);
|
|
60
49
|
}
|
|
61
50
|
|
|
62
|
-
vec3.cross(
|
|
63
|
-
vec3.normalize(normal, normal);
|
|
51
|
+
normal = vec3.normalize(vec3.cross([...tangent], v));
|
|
64
52
|
}
|
|
65
53
|
|
|
66
|
-
let binormal = vec3.
|
|
67
|
-
vec3.normalize(binormal, binormal);
|
|
54
|
+
let binormal = vec3.normalize(vec3.cross([...tangent], normal));
|
|
68
55
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
56
|
+
if (isTypedArray) {
|
|
57
|
+
geometry.normals.set(normal);
|
|
58
|
+
geometry.binormals.set(binormal);
|
|
59
|
+
} else {
|
|
60
|
+
geometry.normals.push(normal);
|
|
61
|
+
geometry.binormals.push(binormal);
|
|
62
|
+
}
|
|
75
63
|
|
|
76
64
|
// Compute the rest of the frames
|
|
77
65
|
const rotation = quat.create();
|
|
78
|
-
let previousTangent;
|
|
66
|
+
let previousTangent = vec3.create();
|
|
67
|
+
|
|
68
|
+
for (let i = 1; i < size; i++) {
|
|
69
|
+
if (isTypedArray) {
|
|
70
|
+
avec3.set(previousTangent, 0, geometry.tangents, i - 1);
|
|
71
|
+
avec3.set(tangent, 0, geometry.tangents, i);
|
|
72
|
+
} else {
|
|
73
|
+
previousTangent = geometry.tangents[i - 1];
|
|
74
|
+
tangent = geometry.tangents[i];
|
|
75
|
+
}
|
|
79
76
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
previousTangent = tangents[i - 1];
|
|
83
|
-
tangent = tangents[i];
|
|
84
|
-
normal = vec3.clone(normal);
|
|
85
|
-
binormal = vec3.clone(binormal);
|
|
77
|
+
normal = vec3.copy(normal);
|
|
78
|
+
binormal = vec3.copy(binormal);
|
|
86
79
|
|
|
87
|
-
vec3.cross(
|
|
80
|
+
v = vec3.cross([...previousTangent], tangent);
|
|
88
81
|
|
|
89
82
|
if (vec3.length(v) > Number.EPSILON) {
|
|
90
|
-
vec3.normalize(v
|
|
83
|
+
vec3.normalize(v);
|
|
91
84
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
85
|
+
const theta = Math.acos(
|
|
86
|
+
utils.clamp(vec3.dot(previousTangent, tangent), -1, 1),
|
|
87
|
+
);
|
|
88
|
+
quat.fromAxisAngle(rotation, v, theta);
|
|
89
|
+
vec3.multQuat(normal, rotation);
|
|
90
|
+
}
|
|
91
|
+
binormal = vec3.cross([...tangent], normal);
|
|
92
|
+
|
|
93
|
+
if (isTypedArray) {
|
|
94
|
+
avec3.set(geometry.normals, i, normal, 0);
|
|
95
|
+
avec3.set(geometry.binormals, i, binormal, 0);
|
|
96
|
+
} else {
|
|
97
|
+
geometry.normals.push(normal);
|
|
98
|
+
geometry.binormals.push(binormal);
|
|
95
99
|
}
|
|
96
|
-
vec3.cross(binormal, tangent, normal);
|
|
97
|
-
|
|
98
|
-
frames.push({
|
|
99
|
-
position: [...position],
|
|
100
|
-
normal: vec3.clone(normal),
|
|
101
|
-
binormal: vec3.clone(binormal),
|
|
102
|
-
tangent: vec3.clone(tangent),
|
|
103
|
-
});
|
|
104
100
|
}
|
|
105
101
|
|
|
106
102
|
if (closed) {
|
|
107
|
-
const firstNormal =
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
103
|
+
const firstNormal = isTypedArray
|
|
104
|
+
? geometry.normals.slice(0, 3)
|
|
105
|
+
: geometry.normals[0];
|
|
106
|
+
const lastNormal = isTypedArray
|
|
107
|
+
? geometry.normals.slice(-3)
|
|
108
|
+
: geometry.normals.at(-1);
|
|
109
|
+
const firstTangent = isTypedArray
|
|
110
|
+
? geometry.tangents.slice(0, 3)
|
|
111
|
+
: geometry.tangents[0];
|
|
112
|
+
|
|
113
|
+
let theta = Math.acos(
|
|
114
|
+
utils.clamp(vec3.dot(firstNormal, lastNormal), -1, 1),
|
|
115
|
+
);
|
|
116
|
+
theta /= size - 1;
|
|
117
|
+
|
|
118
|
+
if (vec3.dot(firstTangent, vec3.cross([...firstNormal], lastNormal)) > 0) {
|
|
119
119
|
theta = -theta;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
122
|
+
for (let i = 0; i < size; i++) {
|
|
123
|
+
if (isTypedArray) {
|
|
124
|
+
avec3.set(tangent, 0, geometry.tangents, i);
|
|
125
|
+
avec3.set(normal, 0, geometry.normals, i);
|
|
126
|
+
avec3.set(binormal, 0, geometry.binormals, i);
|
|
127
|
+
|
|
128
|
+
quat.fromAxisAngle(rotation, tangent, theta * i);
|
|
129
|
+
vec3.multQuat(normal, rotation);
|
|
130
|
+
binormal = vec3.cross([...tangent], normal);
|
|
131
|
+
|
|
132
|
+
avec3.set(geometry.normals, i, normal, 0);
|
|
133
|
+
avec3.set(geometry.binormals, i, binormal, 0);
|
|
134
|
+
} else {
|
|
135
|
+
const tangent = geometry.tangents[i];
|
|
136
|
+
const normal = geometry.normals[i];
|
|
137
|
+
quat.fromAxisAngle(rotation, tangent, theta * i);
|
|
138
|
+
vec3.multQuat(normal, rotation);
|
|
139
|
+
geometry.binormals[i] = vec3.cross([...tangent], normal);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
127
142
|
}
|
|
128
143
|
|
|
129
|
-
return
|
|
144
|
+
return geometry;
|
|
130
145
|
}
|
|
131
146
|
|
|
132
147
|
export default frenetSerretFrames;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "frenet-serret-frames",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Compute Frenet-Serret frames for a
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "Compute Frenet-Serret frames for a geometry of 3D positions and optionally provided tangents.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"path",
|
|
7
7
|
"spline",
|
|
@@ -33,20 +33,17 @@
|
|
|
33
33
|
"main": "index.js",
|
|
34
34
|
"types": "types/index.d.ts",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"
|
|
37
|
-
"gl-matrix": "^3.3.0"
|
|
36
|
+
"pex-math": "^4.0.0-alpha.3"
|
|
38
37
|
},
|
|
39
38
|
"devDependencies": {
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"pex-context": "^2.10.4",
|
|
46
|
-
"tweakpane": "^3.0.2"
|
|
39
|
+
"es-module-shims": "^1.8.0",
|
|
40
|
+
"path-tangents": "^3.0.0",
|
|
41
|
+
"pex-cam": "^3.0.0-alpha.1",
|
|
42
|
+
"pex-context": "^3.0.0-alpha.7",
|
|
43
|
+
"tweakpane": "^3.1.10"
|
|
47
44
|
},
|
|
48
45
|
"engines": {
|
|
49
|
-
"node": ">=
|
|
50
|
-
"npm": ">=
|
|
46
|
+
"node": ">=18.0.0",
|
|
47
|
+
"npm": ">=8.6.0"
|
|
51
48
|
}
|
|
52
49
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,33 +1,11 @@
|
|
|
1
1
|
export default frenetSerretFrames;
|
|
2
|
-
export type vec3 = number[];
|
|
3
2
|
/**
|
|
4
|
-
*
|
|
5
|
-
*/
|
|
6
|
-
export type Options = {
|
|
7
|
-
/**
|
|
8
|
-
* Specify is the path is closed.
|
|
9
|
-
*/
|
|
10
|
-
closed?: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Specify a starting normal for the frames. Default to the direction of the minimum tangent component.
|
|
13
|
-
*/
|
|
14
|
-
initialNormal?: vec3;
|
|
15
|
-
};
|
|
16
|
-
export type Frame = {
|
|
17
|
-
position: vec3;
|
|
18
|
-
normal: vec3;
|
|
19
|
-
binormal: vec3;
|
|
20
|
-
tangent: vec3;
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Compute Frenet-Serret frames for a path of 3D points and tangents
|
|
3
|
+
* Compute Frenet-Serret frames for a geometry of 3D positions and optionally provided tangents.
|
|
24
4
|
*
|
|
25
|
-
* @param {
|
|
26
|
-
* @param {
|
|
27
|
-
* @
|
|
28
|
-
* @returns {Frame[]}
|
|
5
|
+
* @param {import("./types.js").SimplicialComplex} geometry
|
|
6
|
+
* @param {import("./types.js").Options} [options={}]
|
|
7
|
+
* @returns {import("./types.js").SimplicialComplexWithTNB}
|
|
29
8
|
*
|
|
30
9
|
* @see [Frenet–Serret formulas]{@link https://en.wikipedia.org/wiki/Frenet%E2%80%93Serret_formulas}
|
|
31
10
|
*/
|
|
32
|
-
declare function frenetSerretFrames(
|
|
33
|
-
import { vec3 } from "gl-matrix";
|
|
11
|
+
declare function frenetSerretFrames(geometry: import("./types.js").SimplicialComplex, options?: import("./types.js").Options): import("./types.js").SimplicialComplexWithTNB;
|
package/types/types.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type vec3 = number[];
|
|
2
|
+
/**
|
|
3
|
+
* Geometry definition.
|
|
4
|
+
*/
|
|
5
|
+
export type SimplicialComplex = {
|
|
6
|
+
positions: Float32Array | vec3[];
|
|
7
|
+
tangents?: Float32Array | vec3[];
|
|
8
|
+
normals?: Float32Array | vec3[];
|
|
9
|
+
uvs?: Float32Array | vec3[];
|
|
10
|
+
cells?: (Uint8Array | Uint16Array | Uint32Array | vec3[]);
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Geometry definition augmented with tangent, normals and binormals.
|
|
14
|
+
*/
|
|
15
|
+
export type SimplicialComplexWithTNB = {
|
|
16
|
+
positions: Float32Array | vec3[];
|
|
17
|
+
tangents: Float32Array | vec3[];
|
|
18
|
+
normals: Float32Array | vec3[];
|
|
19
|
+
binormals: Float32Array | vec3[];
|
|
20
|
+
uvs?: Float32Array | vec3[];
|
|
21
|
+
cells?: (Uint8Array | Uint16Array | Uint32Array | vec3[]);
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Options for frames computation. All optional.
|
|
25
|
+
*/
|
|
26
|
+
export type Options = {
|
|
27
|
+
/**
|
|
28
|
+
* Specify is the path is closed.
|
|
29
|
+
*/
|
|
30
|
+
closed?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Specify a starting normal for the frames. Default to the direction of the minimum tangent component.
|
|
33
|
+
*/
|
|
34
|
+
initialNormal?: vec3;
|
|
35
|
+
};
|
package/types.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {number[]} vec3
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {object} SimplicialComplex Geometry definition.
|
|
7
|
+
* @property {Float32Array | vec3[]} positions
|
|
8
|
+
* @property {Float32Array | vec3[]} [tangents]
|
|
9
|
+
* @property {Float32Array | vec3[]} [normals]
|
|
10
|
+
* @property {Float32Array | vec3[]} [uvs]
|
|
11
|
+
* @property {(Uint8Array | Uint16Array | Uint32Array | vec3[])} [cells]
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {object} SimplicialComplexWithTNB Geometry definition augmented with tangent, normals and binormals.
|
|
16
|
+
* @property {Float32Array | vec3[]} positions
|
|
17
|
+
* @property {Float32Array | vec3[]} tangents
|
|
18
|
+
* @property {Float32Array | vec3[]} normals
|
|
19
|
+
* @property {Float32Array | vec3[]} binormals
|
|
20
|
+
* @property {Float32Array | vec3[]} [uvs]
|
|
21
|
+
* @property {(Uint8Array | Uint16Array | Uint32Array | vec3[])} [cells]
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @typedef {object} Options Options for frames computation. All optional.
|
|
26
|
+
* @property {boolean} [closed=false] Specify is the path is closed.
|
|
27
|
+
* @property {vec3} [initialNormal=null] Specify a starting normal for the frames. Default to the direction of the minimum tangent component.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
export {};
|