frenet-serret-frames 2.1.0 → 3.0.1

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 ADDED
File without changes
package/CHANGELOG.md CHANGED
@@ -2,6 +2,26 @@
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.1](https://github.com/dmnsgn/frenet-serret-frames/compare/v3.0.0...v3.0.1) (2023-07-31)
6
+
7
+
8
+
9
+ # [3.0.0](https://github.com/dmnsgn/frenet-serret-frames/compare/v2.1.0...v3.0.0) (2023-07-31)
10
+
11
+
12
+ ### Features
13
+
14
+ * add typed array support ([d766f7c](https://github.com/dmnsgn/frenet-serret-frames/commit/d766f7c1beafcd23130d95f4bc6faa591ae07f10))
15
+
16
+
17
+ ### BREAKING CHANGES
18
+
19
+ * use pex-math
20
+ * use geometry as first argument
21
+ * return augmented geometry and not frames
22
+
23
+
24
+
5
25
  # [2.1.0](https://github.com/dmnsgn/frenet-serret-frames/compare/v2.0.1...v2.1.0) (2021-10-02)
6
26
 
7
27
 
package/README.md CHANGED
@@ -2,15 +2,15 @@
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/frenet-serret-frames)](https://www.npmjs.com/package/frenet-serret-frames)
4
4
  [![stability-stable](https://img.shields.io/badge/stability-stable-green.svg)](https://www.npmjs.com/package/frenet-serret-frames)
5
- [![npm minzipped size](https://img.shields.io/bundlephobia/minzip/frenet-serret-frames)](https://www.npmjs.com/package/frenet-serret-frames)
6
- [![dependencies](https://img.shields.io/david/dmnsgn/frenet-serret-frames)](https://github.com/dmnsgn/frenet-serret-frames/blob/main/package.json)
5
+ [![npm minzipped size](https://img.shields.io/bundlephobia/minzip/frenet-serret-frames)](https://bundlephobia.com/package/frenet-serret-frames)
6
+ [![dependencies](https://img.shields.io/librariesio/release/npm/frenet-serret-frames)](https://github.com/dmnsgn/frenet-serret-frames/blob/main/package.json)
7
7
  [![types](https://img.shields.io/npm/types/frenet-serret-frames)](https://github.com/microsoft/TypeScript)
8
8
  [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-fa6673.svg)](https://conventionalcommits.org)
9
9
  [![styled with prettier](https://img.shields.io/badge/styled_with-Prettier-f8bc45.svg?logo=prettier)](https://github.com/prettier/prettier)
10
10
  [![linted with eslint](https://img.shields.io/badge/linted_with-ES_Lint-4B32C3.svg?logo=eslint)](https://github.com/eslint/eslint)
11
11
  [![license](https://img.shields.io/github/license/dmnsgn/frenet-serret-frames)](https://github.com/dmnsgn/frenet-serret-frames/blob/main/LICENSE.md)
12
12
 
13
- Compute Frenet-Serret frames for a path of 3D points and tangents.
13
+ Compute Frenet-Serret frames for a geometry of 3D positions and optionally provided tangents.
14
14
 
15
15
  [![paypal](https://img.shields.io/badge/donate-paypal-informational?logo=paypal)](https://paypal.me/dmnsgn)
16
16
  [![coinbase](https://img.shields.io/badge/donate-coinbase-informational?logo=coinbase)](https://commerce.coinbase.com/checkout/56cbdf28-e323-48d8-9c98-7019e72c97f3)
@@ -28,12 +28,9 @@ npm install frenet-serret-frames
28
28
 
29
29
  ```js
30
30
  import frenetSerretFrames from "frenet-serret-frames";
31
- import pathTangents from "path-tangents";
32
31
 
33
- const isClosed = true;
34
- const tangents = pathTangents(path, isClosed);
35
- const frames = frenetSerretFrames(path, tangents, {
36
- closed: isClosed,
32
+ const frames = frenetSerretFrames({ positions }, {
33
+ closed: true,
37
34
  initialNormal: [0, 1, 0],
38
35
  });
39
36
  ```
@@ -45,50 +42,95 @@ const frames = frenetSerretFrames(path, tangents, {
45
42
  ## Functions
46
43
 
47
44
  <dl>
48
- <dt><a href="#frenetSerretFrames">frenetSerretFrames(points, tangents, [options])</a> ⇒ <code><a href="#Frame">Array.&lt;Frame&gt;</a></code></dt>
49
- <dd><p>Compute Frenet-Serret frames for a path of 3D points and tangents</p>
45
+ <dt><a href="#frenetSerretFrames">frenetSerretFrames(geometry, [options])</a> ⇒ <code><a href="#SimplicialComplexWithTNB">SimplicialComplexWithTNB</a></code></dt>
46
+ <dd><p>Compute Frenet-Serret frames for a geometry of 3D positions and optionally provided tangents.</p>
50
47
  </dd>
51
48
  </dl>
52
49
 
53
50
  ## Typedefs
54
51
 
55
52
  <dl>
53
+ <dt><a href="#vec2">vec2</a> : <code>Array.&lt;number&gt;</code></dt>
54
+ <dd></dd>
56
55
  <dt><a href="#vec3">vec3</a> : <code>Array.&lt;number&gt;</code></dt>
57
56
  <dd></dd>
58
- <dt><a href="#Options">Options</a> : <code>Object</code></dt>
57
+ <dt><a href="#SimplicialComplex">SimplicialComplex</a> : <code>object</code></dt>
58
+ <dd><p>Geometry definition.</p>
59
+ </dd>
60
+ <dt><a href="#SimplicialComplexWithTNB">SimplicialComplexWithTNB</a> : <code>object</code></dt>
61
+ <dd><p>Geometry definition augmented with tangent, normals and binormals.</p>
62
+ </dd>
63
+ <dt><a href="#Options">Options</a> : <code>object</code></dt>
59
64
  <dd><p>Options for frames computation. All optional.</p>
60
65
  </dd>
61
- <dt><a href="#Frame">Frame</a> : <code>Object</code></dt>
62
- <dd></dd>
63
66
  </dl>
64
67
 
65
68
  <a name="frenetSerretFrames"></a>
66
69
 
67
- ## frenetSerretFrames(points, tangents, [options]) ⇒ [<code>Array.&lt;Frame&gt;</code>](#Frame)
70
+ ## frenetSerretFrames(geometry, [options]) ⇒ [<code>SimplicialComplexWithTNB</code>](#SimplicialComplexWithTNB)
68
71
 
69
- Compute Frenet-Serret frames for a path of 3D points and tangents
72
+ Compute Frenet-Serret frames for a geometry of 3D positions and optionally provided tangents.
70
73
 
71
- **Kind**: global function
74
+ **Kind**: global function
72
75
  **See**: [Frenet–Serret formulas](https://en.wikipedia.org/wiki/Frenet%E2%80%93Serret_formulas)
73
76
 
74
- | Param | Type | Default | Description |
75
- | --------- | ---------------------------------------- | --------------- | ----------------------------------------------------------------------- |
76
- | points | [<code>Array.&lt;vec3&gt;</code>](#vec3) | | Array of 3D points [x, y, z]. |
77
- | tangents | [<code>Array.&lt;vec3&gt;</code>](#vec3) | | Array of 3D points [x, y, z] corresponding to the tangents of the path. |
78
- | [options] | [<code>Options</code>](#Options) | <code>{}</code> | |
77
+ | Param | Type | Default |
78
+ | --------- | ---------------------------------------------------- | --------------- |
79
+ | geometry | [<code>SimplicialComplex</code>](#SimplicialComplex) | |
80
+ | [options] | [<code>Options</code>](#Options) | <code>{}</code> |
81
+
82
+ <a name="vec2"></a>
83
+
84
+ ## vec2 : <code>Array.&lt;number&gt;</code>
79
85
 
86
+ **Kind**: global typedef
80
87
  <a name="vec3"></a>
81
88
 
82
89
  ## vec3 : <code>Array.&lt;number&gt;</code>
83
90
 
84
- **Kind**: global typedef
91
+ **Kind**: global typedef
92
+ <a name="SimplicialComplex"></a>
93
+
94
+ ## SimplicialComplex : <code>object</code>
95
+
96
+ Geometry definition.
97
+
98
+ **Kind**: global typedef
99
+ **Properties**
100
+
101
+ | Name | Type |
102
+ | ---------- | --------------------------------------------------------------------------------------------------------------------------- |
103
+ | positions | <code>Float32Array</code> \| [<code>Array.&lt;vec3&gt;</code>](#vec3) |
104
+ | [tangents] | <code>Float32Array</code> \| [<code>Array.&lt;vec3&gt;</code>](#vec3) |
105
+ | [normals] | <code>Float32Array</code> \| [<code>Array.&lt;vec3&gt;</code>](#vec3) |
106
+ | [uvs] | <code>Float32Array</code> \| [<code>Array.&lt;vec2&gt;</code>](#vec2) |
107
+ | [cells] | <code>Uint8Array</code> \| <code>Uint16Array</code> \| <code>Uint32Array</code> \| [<code>Array.&lt;vec3&gt;</code>](#vec3) |
108
+
109
+ <a name="SimplicialComplexWithTNB"></a>
110
+
111
+ ## SimplicialComplexWithTNB : <code>object</code>
112
+
113
+ Geometry definition augmented with tangent, normals and binormals.
114
+
115
+ **Kind**: global typedef
116
+ **Properties**
117
+
118
+ | Name | Type |
119
+ | --------- | --------------------------------------------------------------------------------------------------------------------------- |
120
+ | positions | <code>Float32Array</code> \| [<code>Array.&lt;vec3&gt;</code>](#vec3) |
121
+ | tangents | <code>Float32Array</code> \| [<code>Array.&lt;vec3&gt;</code>](#vec3) |
122
+ | normals | <code>Float32Array</code> \| [<code>Array.&lt;vec3&gt;</code>](#vec3) |
123
+ | binormals | <code>Float32Array</code> \| [<code>Array.&lt;vec3&gt;</code>](#vec3) |
124
+ | [uvs] | <code>Float32Array</code> \| [<code>Array.&lt;vec2&gt;</code>](#vec2) |
125
+ | [cells] | <code>Uint8Array</code> \| <code>Uint16Array</code> \| <code>Uint32Array</code> \| [<code>Array.&lt;vec3&gt;</code>](#vec3) |
126
+
85
127
  <a name="Options"></a>
86
128
 
87
- ## Options : <code>Object</code>
129
+ ## Options : <code>object</code>
88
130
 
89
131
  Options for frames computation. All optional.
90
132
 
91
- **Kind**: global typedef
133
+ **Kind**: global typedef
92
134
  **Properties**
93
135
 
94
136
  | Name | Type | Default | Description |
@@ -96,20 +138,6 @@ Options for frames computation. All optional.
96
138
  | [closed] | <code>boolean</code> | <code>false</code> | Specify is the path is closed. |
97
139
  | [initialNormal] | [<code>vec3</code>](#vec3) | <code></code> | Specify a starting normal for the frames. Default to the direction of the minimum tangent component. |
98
140
 
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
141
  <!-- api-end -->
114
142
 
115
143
  ## License
package/index.js CHANGED
@@ -1,132 +1,147 @@
1
- import { vec3, quat } from "gl-matrix";
2
- import clamp from "clamp";
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 path of 3D points and tangents
9
+ * Compute Frenet-Serret frames for a geometry of 3D positions and optionally provided tangents.
28
10
  *
29
- * @param {vec3[]} points Array of 3D points [x, y, z].
30
- * @param {vec3[]} tangents Array of 3D points [x, y, z] corresponding to the tangents of the path.
31
- * @param {Options} [options={}]
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(points, tangents, options) {
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 frames = [];
43
- const v = vec3.create();
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
- // Compute initial frame
46
- let tangent = tangents[0];
47
- let normal = initialNormal || vec3.create();
28
+ let v = vec3.create();
48
29
 
49
- const atx = Math.abs(tangent[0]);
50
- const aty = Math.abs(tangent[1]);
51
- const atz = Math.abs(tangent[2]);
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(v, tangent, X_UP);
44
+ v = vec3.cross([...tangent], X_UP);
56
45
  } else if (atz > atx && atz >= aty) {
57
- vec3.cross(v, tangent, Y_UP);
46
+ v = vec3.cross([...tangent], Y_UP);
58
47
  } else {
59
- vec3.cross(v, tangent, Z_UP);
48
+ v = vec3.cross([...tangent], Z_UP);
60
49
  }
61
50
 
62
- vec3.cross(normal, tangent, v);
63
- vec3.normalize(normal, normal);
51
+ normal = vec3.normalize(vec3.cross([...tangent], v));
64
52
  }
65
53
 
66
- let binormal = vec3.cross(vec3.create(), tangent, normal);
67
- vec3.normalize(binormal, binormal);
54
+ let binormal = vec3.normalize(vec3.cross([...tangent], normal));
68
55
 
69
- frames.push({
70
- position: [...points[0]],
71
- normal: vec3.clone(normal),
72
- binormal: vec3.clone(binormal),
73
- tangent: vec3.clone(tangent),
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
- for (let i = 1; i < points.length; i++) {
81
- const position = points[i];
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(v, previousTangent, tangent);
80
+ v = vec3.cross([...previousTangent], tangent);
88
81
 
89
82
  if (vec3.length(v) > Number.EPSILON) {
90
- vec3.normalize(v, v);
83
+ vec3.normalize(v);
91
84
 
92
- let theta = Math.acos(clamp(vec3.dot(previousTangent, tangent), -1, 1));
93
- quat.setAxisAngle(rotation, v, theta);
94
- vec3.transformQuat(normal, normal, rotation);
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 = frames[0].normal;
108
- const lastNormal = frames[frames.length - 1].normal;
109
-
110
- let theta = Math.acos(clamp(vec3.dot(firstNormal, lastNormal), 0, 1));
111
- theta /= frames.length - 1;
112
-
113
- if (
114
- vec3.dot(
115
- vec3.clone(tangents[0]),
116
- vec3.cross(v, firstNormal, lastNormal)
117
- ) > 0
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
- frames.forEach(({ normal, binormal, tangent }, index) => {
123
- quat.setAxisAngle(rotation, tangent, theta * index);
124
- vec3.transformQuat(normal, normal, rotation);
125
- vec3.cross(binormal, tangent, normal);
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 frames;
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": "2.1.0",
4
- "description": "Compute Frenet-Serret frames for a path of 3D points and tangents.",
3
+ "version": "3.0.1",
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
- "clamp": "^1.0.1",
37
- "gl-matrix": "^3.3.0"
36
+ "pex-math": "^4.0.0-alpha.3"
38
37
  },
39
38
  "devDependencies": {
40
- "assert": "^2.0.0",
41
- "core-js": "^3.14.0",
42
- "es-module-shims": "^0.10.7",
43
- "path-tangents": "^2.0.1",
44
- "pex-cam": "^2.8.0",
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": ">=15.0.0",
50
- "npm": ">=7.0.0"
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
- * Options for frames computation. All optional.
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 {vec3[]} points Array of 3D points [x, y, z].
26
- * @param {vec3[]} tangents Array of 3D points [x, y, z] corresponding to the tangents of the path.
27
- * @param {Options} [options={}]
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(points: vec3[], tangents: vec3[], options?: Options): Frame[];
33
- import { vec3 } from "gl-matrix";
11
+ declare function frenetSerretFrames(geometry: import("./types.js").SimplicialComplex, options?: import("./types.js").Options): import("./types.js").SimplicialComplexWithTNB;
@@ -0,0 +1,36 @@
1
+ export type vec2 = number[];
2
+ export type vec3 = number[];
3
+ /**
4
+ * Geometry definition.
5
+ */
6
+ export type SimplicialComplex = {
7
+ positions: Float32Array | vec3[];
8
+ tangents?: Float32Array | vec3[];
9
+ normals?: Float32Array | vec3[];
10
+ uvs?: Float32Array | vec2[];
11
+ cells?: (Uint8Array | Uint16Array | Uint32Array | vec3[]);
12
+ };
13
+ /**
14
+ * Geometry definition augmented with tangent, normals and binormals.
15
+ */
16
+ export type SimplicialComplexWithTNB = {
17
+ positions: Float32Array | vec3[];
18
+ tangents: Float32Array | vec3[];
19
+ normals: Float32Array | vec3[];
20
+ binormals: Float32Array | vec3[];
21
+ uvs?: Float32Array | vec2[];
22
+ cells?: (Uint8Array | Uint16Array | Uint32Array | vec3[]);
23
+ };
24
+ /**
25
+ * Options for frames computation. All optional.
26
+ */
27
+ export type Options = {
28
+ /**
29
+ * Specify is the path is closed.
30
+ */
31
+ closed?: boolean;
32
+ /**
33
+ * Specify a starting normal for the frames. Default to the direction of the minimum tangent component.
34
+ */
35
+ initialNormal?: vec3;
36
+ };
package/types.js ADDED
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @typedef {number[]} vec2
3
+ */
4
+ /**
5
+ * @typedef {number[]} vec3
6
+ */
7
+
8
+ /**
9
+ * @typedef {object} SimplicialComplex Geometry definition.
10
+ * @property {Float32Array | vec3[]} positions
11
+ * @property {Float32Array | vec3[]} [tangents]
12
+ * @property {Float32Array | vec3[]} [normals]
13
+ * @property {Float32Array | vec2[]} [uvs]
14
+ * @property {(Uint8Array | Uint16Array | Uint32Array | vec3[])} [cells]
15
+ */
16
+
17
+ /**
18
+ * @typedef {object} SimplicialComplexWithTNB Geometry definition augmented with tangent, normals and binormals.
19
+ * @property {Float32Array | vec3[]} positions
20
+ * @property {Float32Array | vec3[]} tangents
21
+ * @property {Float32Array | vec3[]} normals
22
+ * @property {Float32Array | vec3[]} binormals
23
+ * @property {Float32Array | vec2[]} [uvs]
24
+ * @property {(Uint8Array | Uint16Array | Uint32Array | vec3[])} [cells]
25
+ */
26
+
27
+ /**
28
+ * @typedef {object} Options Options for frames computation. All optional.
29
+ * @property {boolean} [closed=false] Specify is the path is closed.
30
+ * @property {vec3} [initialNormal=null] Specify a starting normal for the frames. Default to the direction of the minimum tangent component.
31
+ */
32
+
33
+ export {};