frenet-serret-frames 2.0.1 → 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 ADDED
File without changes
package/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
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
+
21
+ # [2.1.0](https://github.com/dmnsgn/frenet-serret-frames/compare/v2.0.1...v2.1.0) (2021-10-02)
22
+
23
+
24
+ ### Features
25
+
26
+ * add exports field to package.json ([945cbd5](https://github.com/dmnsgn/frenet-serret-frames/commit/945cbd556f7035ace5c4083d74e15cccc9307611))
27
+
28
+
29
+
5
30
  ## [2.0.1](https://github.com/dmnsgn/frenet-serret-frames/compare/v2.0.0...v2.0.1) (2021-06-15)
6
31
 
7
32
 
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)
@@ -45,8 +45,8 @@ const frames = frenetSerretFrames(path, tangents, {
45
45
  ## Functions
46
46
 
47
47
  <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>
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.&lt;number&gt;</code></dt>
57
57
  <dd></dd>
58
- <dt><a href="#Options">Options</a> : <code>Object</code></dt>
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(points, tangents, [options]) ⇒ [<code>Array.&lt;Frame&gt;</code>](#Frame)
71
+ ## frenetSerretFrames(geometry, [options]) ⇒ [<code>SimplicialComplexWithTNB</code>](#SimplicialComplexWithTNB)
68
72
 
69
- Compute Frenet-Serret frames for a path of 3D points and tangents
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 | 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> | |
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.&lt;number&gt;</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.&lt;vec3&gt;</code>](#vec3) |
100
+ | [tangents] | <code>Float32Array</code> \| [<code>Array.&lt;vec3&gt;</code>](#vec3) |
101
+ | [normals] | <code>Float32Array</code> \| [<code>Array.&lt;vec3&gt;</code>](#vec3) |
102
+ | [uvs] | <code>Float32Array</code> \| [<code>Array.&lt;vec3&gt;</code>](#vec3) |
103
+ | [cells] | <code>Uint8Array</code> \| <code>Uint16Array</code> \| <code>Uint32Array</code> \| [<code>Array.&lt;vec3&gt;</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.&lt;vec3&gt;</code>](#vec3) |
117
+ | tangents | <code>Float32Array</code> \| [<code>Array.&lt;vec3&gt;</code>](#vec3) |
118
+ | normals | <code>Float32Array</code> \| [<code>Array.&lt;vec3&gt;</code>](#vec3) |
119
+ | binormals | <code>Float32Array</code> \| [<code>Array.&lt;vec3&gt;</code>](#vec3) |
120
+ | [uvs] | <code>Float32Array</code> \| [<code>Array.&lt;vec3&gt;</code>](#vec3) |
121
+ | [cells] | <code>Uint8Array</code> \| <code>Uint16Array</code> \| <code>Uint32Array</code> \| [<code>Array.&lt;vec3&gt;</code>](#vec3) |
122
+
85
123
  <a name="Options"></a>
86
124
 
87
- ## Options : <code>Object</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 "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.0.1",
4
- "description": "Compute Frenet-Serret frames for a path of 3D points and tangents.",
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",
@@ -29,23 +29,21 @@
29
29
  "author": "Damien Seguin (https://github.com/dmnsgn)",
30
30
  "sideEffects": false,
31
31
  "type": "module",
32
+ "exports": "./index.js",
32
33
  "main": "index.js",
33
34
  "types": "types/index.d.ts",
34
35
  "dependencies": {
35
- "clamp": "^1.0.1",
36
- "gl-matrix": "^3.3.0"
36
+ "pex-math": "^4.0.0-alpha.3"
37
37
  },
38
38
  "devDependencies": {
39
- "assert": "^2.0.0",
40
- "core-js": "^3.14.0",
41
- "es-module-shims": "^0.10.7",
42
- "path-tangents": "^2.0.1",
43
- "pex-cam": "^2.8.0",
44
- "pex-context": "^2.10.4",
45
- "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"
46
44
  },
47
45
  "engines": {
48
- "node": ">=15.0.0",
49
- "npm": ">=7.0.0"
46
+ "node": ">=18.0.0",
47
+ "npm": ">=8.6.0"
50
48
  }
51
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,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 {};