@driftengine/assets 3.61.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.
Files changed (100) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +9 -0
  3. package/README.md +9 -0
  4. package/dist/assetPath.d.ts +51 -0
  5. package/dist/assetPath.js +59 -0
  6. package/dist/coarseLevel.d.ts +94 -0
  7. package/dist/coarseLevel.js +606 -0
  8. package/dist/dds.d.ts +41 -0
  9. package/dist/dds.js +425 -0
  10. package/dist/drawKey.d.ts +64 -0
  11. package/dist/drawKey.js +42 -0
  12. package/dist/drftLoader.d.ts +420 -0
  13. package/dist/drftLoader.js +996 -0
  14. package/dist/drftTextures.d.ts +87 -0
  15. package/dist/drftTextures.js +138 -0
  16. package/dist/fbx.d.ts +86 -0
  17. package/dist/fbx.js +792 -0
  18. package/dist/fbxHarness.d.ts +68 -0
  19. package/dist/fbxHarness.js +185 -0
  20. package/dist/fbxInflate.d.ts +60 -0
  21. package/dist/fbxInflate.js +204 -0
  22. package/dist/fbxMaterial.d.ts +87 -0
  23. package/dist/fbxMaterial.js +345 -0
  24. package/dist/fbxRig.d.ts +130 -0
  25. package/dist/fbxRig.js +601 -0
  26. package/dist/gltf.d.ts +242 -0
  27. package/dist/gltf.js +904 -0
  28. package/dist/gltfAccessor.d.ts +2 -0
  29. package/dist/gltfAccessor.js +106 -0
  30. package/dist/gltfSkin.d.ts +32 -0
  31. package/dist/gltfSkin.js +144 -0
  32. package/dist/iesPhotometry.d.ts +44 -0
  33. package/dist/iesPhotometry.js +94 -0
  34. package/dist/imageInfo.d.ts +31 -0
  35. package/dist/imageInfo.js +119 -0
  36. package/dist/index.d.ts +58 -0
  37. package/dist/index.js +132 -0
  38. package/dist/kn5.d.ts +158 -0
  39. package/dist/kn5.js +557 -0
  40. package/dist/loadProgress.d.ts +118 -0
  41. package/dist/loadProgress.js +1 -0
  42. package/dist/localise.d.ts +35 -0
  43. package/dist/localise.js +253 -0
  44. package/dist/obj.d.ts +54 -0
  45. package/dist/obj.js +335 -0
  46. package/dist/orient.d.ts +104 -0
  47. package/dist/orient.js +241 -0
  48. package/dist/radianceHdr.d.ts +36 -0
  49. package/dist/radianceHdr.js +172 -0
  50. package/dist/readModel.d.ts +153 -0
  51. package/dist/readModel.js +386 -0
  52. package/dist/recognise.d.ts +38 -0
  53. package/dist/recognise.js +97 -0
  54. package/dist/stl.d.ts +22 -0
  55. package/dist/stl.js +131 -0
  56. package/dist/tangentOrder.d.ts +24 -0
  57. package/dist/tangentOrder.js +31 -0
  58. package/dist/threemf.d.ts +46 -0
  59. package/dist/threemf.js +254 -0
  60. package/dist/uploadBudget.d.ts +82 -0
  61. package/dist/uploadBudget.js +86 -0
  62. package/dist/usd.d.ts +49 -0
  63. package/dist/usd.js +542 -0
  64. package/dist/weld.d.ts +44 -0
  65. package/dist/weld.js +237 -0
  66. package/dist/zip.d.ts +35 -0
  67. package/dist/zip.js +110 -0
  68. package/package.json +61 -0
  69. package/src/assetPath.ts +79 -0
  70. package/src/coarseLevel.ts +720 -0
  71. package/src/dds.ts +507 -0
  72. package/src/drawKey.ts +91 -0
  73. package/src/drftLoader.ts +1197 -0
  74. package/src/drftTextures.ts +153 -0
  75. package/src/fbx.ts +934 -0
  76. package/src/fbxHarness.ts +215 -0
  77. package/src/fbxInflate.ts +258 -0
  78. package/src/fbxMaterial.ts +410 -0
  79. package/src/fbxRig.ts +652 -0
  80. package/src/gltf.ts +1161 -0
  81. package/src/gltfAccessor.ts +127 -0
  82. package/src/gltfSkin.ts +210 -0
  83. package/src/iesPhotometry.ts +136 -0
  84. package/src/imageInfo.ts +130 -0
  85. package/src/index.ts +162 -0
  86. package/src/kn5.ts +705 -0
  87. package/src/loadProgress.ts +131 -0
  88. package/src/localise.ts +275 -0
  89. package/src/obj.ts +386 -0
  90. package/src/orient.ts +262 -0
  91. package/src/radianceHdr.ts +195 -0
  92. package/src/readModel.ts +515 -0
  93. package/src/recognise.ts +124 -0
  94. package/src/stl.ts +147 -0
  95. package/src/tangentOrder.ts +32 -0
  96. package/src/threemf.ts +303 -0
  97. package/src/uploadBudget.ts +90 -0
  98. package/src/usd.ts +642 -0
  99. package/src/weld.ts +264 -0
  100. package/src/zip.ts +130 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Drift Technologies
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,9 @@
1
+ DriftEngine
2
+ Copyright 2026 Drift Technologies
3
+
4
+ This product includes software developed at Drift Technologies
5
+ (https://github.com/drftrun/driftengine).
6
+
7
+ Licensed under the Apache License, Version 2.0. Section 4(d) of that licence
8
+ requires this NOTICE to be reproduced in any derivative work you distribute,
9
+ in the source, the documentation, or a display generated by the work.
package/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # @driftengine/assets
2
+
3
+ Model readers for seven formats, and the streaming loader that uploads them.
4
+
5
+ **Cost: 12.5 KB gzipped on top of core.** Measured by `scripts/size-gate.test.mjs`, which fails if it drifts more than
6
+ 3% — the number is a fact about the build rather than a claim in a document.
7
+
8
+ Part of [DriftEngine](../../README.md). See [`docs/ARCHITECTURE.md`](../../docs/ARCHITECTURE.md)
9
+ for how the packages divide, and why some features are compiled into core on demand instead.
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Turning a path a model file wrote into paths worth trying. One responsibility: candidates.
3
+ *
4
+ * **No filesystem, no network, no opinion about either.** This is string work only, and it
5
+ * exists because every format has the same problem and none of them solve it: a model names
6
+ * its textures with a path that was true on the machine that exported it, and is true almost
7
+ * nowhere else. Deciding *how* to look is the host's job, because only the host knows
8
+ * whether it is reading a folder, a zip, a URL or a bundle somebody dragged in. Deciding
9
+ * *what to look for* is the same everywhere, so it is written once, here.
10
+ *
11
+ * What goes wrong without it, from the asset this was built against:
12
+ *
13
+ * - `textures\carbon.jpg` uses backslashes, which are a path separator on one platform and
14
+ * an ordinary filename character on the others.
15
+ * - the absolute path beside it is `G:\SketchfabRipper_v1.18.0-b2\tools\blender-292\...`,
16
+ * a drive on somebody else's computer. Trying it cannot succeed and, on a host that maps
17
+ * unknown roots, is the one candidate that could succeed *wrongly*.
18
+ * - the file may have been moved since export, so the basename alone, beside the model or
19
+ * in the folder next to it, is worth trying after the declared path and never before it.
20
+ *
21
+ * Order matters and is the whole value: most specific first, so an asset carrying two
22
+ * `wheel.jpg` files in different folders resolves each to its own rather than to whichever
23
+ * the search happened to reach.
24
+ */
25
+ /**
26
+ * A texture a model named, with its bytes when the model carried them inline.
27
+ *
28
+ * One type for both cases because the difference is the *format's* business and not the
29
+ * baker's: glTF may embed an image in its binary chunk or in a data URI, and may equally
30
+ * point at a file beside itself, while FBX and OBJ only ever name a path. A reader reports
31
+ * whichever it has, and the resolver looks up only what arrived without bytes.
32
+ */
33
+ export interface AssetReference {
34
+ /** What the source called it. Used to address the texture later, and to find it now. */
35
+ readonly name: string;
36
+ /** Present when the model carried the image itself, so nothing needs resolving. */
37
+ readonly bytes?: Uint8Array;
38
+ }
39
+ /** Everything after the last separator. */
40
+ export declare function basenameOf(declared: string): string;
41
+ /**
42
+ * Paths to try for a reference, best first, relative to the folder holding the model.
43
+ *
44
+ * Deduplicated, because a texture declared as plain `carbon.jpg` would otherwise produce the
45
+ * same candidate three times, and a host that logs its attempts would report three failures
46
+ * for one missing file.
47
+ *
48
+ * `subfolders` are the conventional places a bundle puts its images. They are tried with the
49
+ * basename only, and last, so they can never outrank a path the file actually stated.
50
+ */
51
+ export declare function assetCandidates(declared: string, subfolders?: readonly string[]): string[];
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Turning a path a model file wrote into paths worth trying. One responsibility: candidates.
3
+ *
4
+ * **No filesystem, no network, no opinion about either.** This is string work only, and it
5
+ * exists because every format has the same problem and none of them solve it: a model names
6
+ * its textures with a path that was true on the machine that exported it, and is true almost
7
+ * nowhere else. Deciding *how* to look is the host's job, because only the host knows
8
+ * whether it is reading a folder, a zip, a URL or a bundle somebody dragged in. Deciding
9
+ * *what to look for* is the same everywhere, so it is written once, here.
10
+ *
11
+ * What goes wrong without it, from the asset this was built against:
12
+ *
13
+ * - `textures\carbon.jpg` uses backslashes, which are a path separator on one platform and
14
+ * an ordinary filename character on the others.
15
+ * - the absolute path beside it is `G:\SketchfabRipper_v1.18.0-b2\tools\blender-292\...`,
16
+ * a drive on somebody else's computer. Trying it cannot succeed and, on a host that maps
17
+ * unknown roots, is the one candidate that could succeed *wrongly*.
18
+ * - the file may have been moved since export, so the basename alone, beside the model or
19
+ * in the folder next to it, is worth trying after the declared path and never before it.
20
+ *
21
+ * Order matters and is the whole value: most specific first, so an asset carrying two
22
+ * `wheel.jpg` files in different folders resolves each to its own rather than to whichever
23
+ * the search happened to reach.
24
+ */
25
+ /** Backslashes to forward slashes, and any drive letter or leading root removed. */
26
+ function normalise(declared) {
27
+ const forward = declared.replace(/\\/g, '/');
28
+ /* `C:/x`, `//host/x` and `/x` are all absolute somewhere; keep only the part below them. */
29
+ return forward.replace(/^[a-zA-Z]:\//, '').replace(/^\/+/, '');
30
+ }
31
+ /** Everything after the last separator. */
32
+ export function basenameOf(declared) {
33
+ const normalised = normalise(declared);
34
+ return normalised.slice(normalised.lastIndexOf('/') + 1);
35
+ }
36
+ /**
37
+ * Paths to try for a reference, best first, relative to the folder holding the model.
38
+ *
39
+ * Deduplicated, because a texture declared as plain `carbon.jpg` would otherwise produce the
40
+ * same candidate three times, and a host that logs its attempts would report three failures
41
+ * for one missing file.
42
+ *
43
+ * `subfolders` are the conventional places a bundle puts its images. They are tried with the
44
+ * basename only, and last, so they can never outrank a path the file actually stated.
45
+ */
46
+ export function assetCandidates(declared, subfolders = ['textures', 'Textures', 'tex', 'maps', 'images']) {
47
+ const normalised = normalise(declared);
48
+ if (normalised === '')
49
+ return [];
50
+ const base = basenameOf(declared);
51
+ const out = [normalised];
52
+ /* A declared path with folders in it may have lost them; the basename beside the model
53
+ is the single most common way an asset arrives after being repacked. */
54
+ if (base !== normalised)
55
+ out.push(base);
56
+ for (const folder of subfolders)
57
+ out.push(`${folder}/${base}`);
58
+ return [...new Set(out)];
59
+ }
@@ -0,0 +1,94 @@
1
+ /**
2
+ * One coarse mesh standing in for a whole asset, so a load can start with an outline.
3
+ *
4
+ * docs/FORMAT.md §4.6 argues for this and states the two things that make it worth building:
5
+ * a coarse whole model has to *exist as geometry* before it can be drawn, so it is baked
6
+ * rather than derived at load; and **level 0 for the whole asset is worth more than level 0
7
+ * for each of 187 parts**, because a single decimated body reads as a car while 187 coarse
8
+ * fragments read as a mess. So this takes every mesh and returns exactly one.
9
+ *
10
+ * **The surface of an occupancy grid, not a cluster of vertices.** The first version of this
11
+ * clustered vertices onto a grid and connected three clusters wherever a source triangle
12
+ * spanned three cells, which is the classic Rossignac-Borrel decimation and was wrong for
13
+ * this job in a way that only showed on screen: nothing stops the three clusters of a
14
+ * triangle from lying on *different surfaces* of the model, so a car whose seats and engine
15
+ * bay share cells with its shell grew triangles straight through the bodywork. It was
16
+ * reported, correctly, as white cliffs.
17
+ *
18
+ * This marks every cell any surface passes through, then emits the boundary between the
19
+ * occupied cells and the empty ones. That boundary is **closed by construction** and cannot
20
+ * contain a triangle joining two sides of the model, because it is the outside of a solid
21
+ * rather than a decimation of a surface. Interior geometry disappears into cells that are
22
+ * already occupied, which is exactly what should happen to it in an outline.
23
+ *
24
+ * The blocky result is then pulled onto the model: each corner of the boundary sits at the
25
+ * average of the real surface inside the cells around it. So a cube grid becomes a shape
26
+ * that follows the car, at the resolution the caller asked for.
27
+ *
28
+ * Offline work in the baker, so it may allocate freely. Nothing here runs per frame.
29
+ */
30
+ import type { MeshData } from '@driftengine/drft';
31
+ export interface CoarseLevelOptions {
32
+ /**
33
+ * Cells along the asset's longest axis. Higher is finer and larger.
34
+ *
35
+ * The whole point of the level is that it arrives before the model, so it is measured in
36
+ * kilobytes rather than in fidelity: at 40 a five-metre car resolves to about twelve
37
+ * centimetres, which is a recognisable car for a few hundred kilobytes against seventy
38
+ * megabytes of file.
39
+ */
40
+ readonly cells?: number;
41
+ /**
42
+ * How far the outline is held below the surface, as a fraction of a cell.
43
+ *
44
+ * **This is what lets it stay on screen while the real parts land on top of it**, which is
45
+ * the reveal §4.6 describes: an outline, then its elements. A corner of the boundary sits at
46
+ * the average of the surface around it, so it is already close; this is the margin that
47
+ * keeps it from landing in the same plane as the part covering it and showing through in
48
+ * patches. Being a little inside the model costs nothing, because the model is about to
49
+ * cover it.
50
+ */
51
+ readonly inset?: number;
52
+ }
53
+ /**
54
+ * The grid this uses when nobody names a resolution, exported because two other places used
55
+ * to carry their own copy of the number and disagreed with it.
56
+ *
57
+ * The baker printed 32 and the browser's converter passed nothing, so one path wrote an
58
+ * outline at 32 cells and the other at 40, and the same model taken through the two arrived
59
+ * differently for no stated reason. A default that callers restate is a default in name only.
60
+ */
61
+ export declare const DEFAULT_COARSE_CELLS = 40;
62
+ /**
63
+ * Build the coarse level, or `null` when there is nothing to build one from.
64
+ *
65
+ * `null` rather than an empty mesh: an asset with no extent, or one whose geometry all falls
66
+ * inside a single cell, has no outline worth a chunk in the file, and every caller would
67
+ * otherwise have to check the vertex count to find that out.
68
+ *
69
+ * Whether the result is *worth writing* is a separate question with a separate answer:
70
+ * `isOutlineWorthWriting`.
71
+ */
72
+ export declare function buildCoarseLevel(meshes: readonly MeshData[], options?: CoarseLevelOptions): MeshData | null;
73
+ /**
74
+ * Whether a built level is worth writing into a file as an outline.
75
+ *
76
+ * **A level of detail that is bigger than the model is not one.** The grid is a fixed number of
77
+ * cells across whatever it is given, so its cost follows the *shape* rather than the detail: four
78
+ * hand-written triangles come back as a 9,840-triangle shell, which is 308 KB of outline arriving
79
+ * ahead of a model measured in bytes. Everything an outline is for, being on screen before the
80
+ * geometry at a fraction of the download, is inverted.
81
+ *
82
+ * Found the day the default flipped from off to on, by a fixture. While an outline was asked for
83
+ * per asset by somebody who had looked, the case could not arise. A default has to hold for the
84
+ * assets nobody looks at, which is what makes it a default.
85
+ *
86
+ * **Separate from `buildCoarseLevel`, which stays a geometry function.** This is a budget, and a
87
+ * caller that wants the hull of a small mesh for some other purpose is entitled to it. It lives
88
+ * here rather than in the two callers because the baker and the browser's converter have to agree
89
+ * about what a file carries, and a rule stated twice is a rule until somebody edits one copy.
90
+ *
91
+ * Half rather than merely smaller: an outline that saves a few per cent is a chunk, an upload and
92
+ * a swap for no visible gain.
93
+ */
94
+ export declare function isOutlineWorthWriting(level: MeshData, meshes: readonly MeshData[]): boolean;