@margoengine/loaders 0.0.0-stage → 0.1.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 (184) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +4 -0
  3. package/README.md +1198 -3
  4. package/dist/3dm.d.ts +161 -0
  5. package/dist/3dm.js +289 -0
  6. package/dist/3ds.d.ts +124 -0
  7. package/dist/3ds.js +392 -0
  8. package/dist/acclaim.d.ts +90 -0
  9. package/dist/acclaim.js +312 -0
  10. package/dist/amf.d.ts +45 -0
  11. package/dist/amf.js +256 -0
  12. package/dist/babylon.d.ts +197 -0
  13. package/dist/babylon.js +701 -0
  14. package/dist/common.d.ts +7 -0
  15. package/dist/common.js +6 -0
  16. package/dist/dae-animation.d.ts +66 -0
  17. package/dist/dae-animation.js +266 -0
  18. package/dist/dae-common.d.ts +95 -0
  19. package/dist/dae-common.js +226 -0
  20. package/dist/dae-controllers.d.ts +57 -0
  21. package/dist/dae-controllers.js +164 -0
  22. package/dist/dae-pose.d.ts +131 -0
  23. package/dist/dae-pose.js +381 -0
  24. package/dist/dae-scene.d.ts +203 -0
  25. package/dist/dae-scene.js +279 -0
  26. package/dist/dae.d.ts +161 -0
  27. package/dist/dae.js +633 -0
  28. package/dist/detect.d.ts +20 -0
  29. package/dist/detect.js +72 -0
  30. package/dist/dxf.d.ts +81 -0
  31. package/dist/dxf.js +774 -0
  32. package/dist/engine.d.ts +36 -0
  33. package/dist/engine.js +117 -0
  34. package/dist/font-opentype.d.ts +14 -0
  35. package/dist/font-opentype.js +33 -0
  36. package/dist/font-woff.d.ts +23 -0
  37. package/dist/font-woff.js +293 -0
  38. package/dist/font.d.ts +41 -0
  39. package/dist/font.js +26 -0
  40. package/dist/gcode.d.ts +55 -0
  41. package/dist/gcode.js +278 -0
  42. package/dist/geo-model.d.ts +84 -0
  43. package/dist/geo-model.js +220 -0
  44. package/dist/geo-mvt.d.ts +15 -0
  45. package/dist/geo-mvt.js +302 -0
  46. package/dist/geo-shp.d.ts +15 -0
  47. package/dist/geo-shp.js +234 -0
  48. package/dist/geo-xml.d.ts +6 -0
  49. package/dist/geo-xml.js +165 -0
  50. package/dist/geo.d.ts +8 -0
  51. package/dist/geo.js +59 -0
  52. package/dist/geometry.d.ts +60 -0
  53. package/dist/geometry.js +273 -0
  54. package/dist/index.d.ts +54 -0
  55. package/dist/index.js +28 -0
  56. package/dist/kmz.d.ts +78 -0
  57. package/dist/kmz.js +173 -0
  58. package/dist/las.d.ts +92 -0
  59. package/dist/las.js +110 -0
  60. package/dist/ldraw.d.ts +118 -0
  61. package/dist/ldraw.js +474 -0
  62. package/dist/load.d.ts +72 -0
  63. package/dist/load.js +205 -0
  64. package/dist/lottie.d.ts +154 -0
  65. package/dist/lottie.js +893 -0
  66. package/dist/lwo.d.ts +81 -0
  67. package/dist/lwo.js +454 -0
  68. package/dist/lzf.d.ts +13 -0
  69. package/dist/lzf.js +56 -0
  70. package/dist/materialx.d.ts +120 -0
  71. package/dist/materialx.js +563 -0
  72. package/dist/md2.d.ts +52 -0
  73. package/dist/md2.js +112 -0
  74. package/dist/mmcif.d.ts +14 -0
  75. package/dist/mmcif.js +246 -0
  76. package/dist/mmd.d.ts +244 -0
  77. package/dist/mmd.js +958 -0
  78. package/dist/mocap.d.ts +71 -0
  79. package/dist/mocap.js +178 -0
  80. package/dist/molecule-common.d.ts +4 -0
  81. package/dist/molecule-common.js +54 -0
  82. package/dist/mtl.d.ts +120 -0
  83. package/dist/mtl.js +469 -0
  84. package/dist/normals.d.ts +7 -0
  85. package/dist/normals.js +31 -0
  86. package/dist/nrrd.d.ts +63 -0
  87. package/dist/nrrd.js +743 -0
  88. package/dist/nurbs.d.ts +118 -0
  89. package/dist/nurbs.js +265 -0
  90. package/dist/obj.d.ts +143 -0
  91. package/dist/obj.js +456 -0
  92. package/dist/off.d.ts +10 -0
  93. package/dist/off.js +155 -0
  94. package/dist/outline-font.d.ts +87 -0
  95. package/dist/outline-font.js +110 -0
  96. package/dist/outline.d.ts +20 -0
  97. package/dist/outline.js +215 -0
  98. package/dist/pcd.d.ts +34 -0
  99. package/dist/pcd.js +258 -0
  100. package/dist/pdb.d.ts +67 -0
  101. package/dist/pdb.js +126 -0
  102. package/dist/ply.d.ts +35 -0
  103. package/dist/ply.js +392 -0
  104. package/dist/polygon.d.ts +9 -0
  105. package/dist/polygon.js +49 -0
  106. package/dist/prwm.d.ts +24 -0
  107. package/dist/prwm.js +114 -0
  108. package/dist/render.d.ts +27 -0
  109. package/dist/render.js +153 -0
  110. package/dist/sfnt-cff.d.ts +37 -0
  111. package/dist/sfnt-cff.js +749 -0
  112. package/dist/sfnt-layout.d.ts +24 -0
  113. package/dist/sfnt-layout.js +266 -0
  114. package/dist/sfnt-reader.d.ts +28 -0
  115. package/dist/sfnt-reader.js +87 -0
  116. package/dist/sfnt-variation.d.ts +40 -0
  117. package/dist/sfnt-variation.js +318 -0
  118. package/dist/shared/asset-url.js +82 -0
  119. package/dist/shared/crc32.d.ts +2 -0
  120. package/dist/shared/crc32.js +47 -0
  121. package/dist/shared/errors.js +36 -0
  122. package/dist/shared/inflate.js +284 -0
  123. package/dist/shared/normals.js +26 -0
  124. package/dist/shared/scene-scope.js +56 -0
  125. package/dist/shared/trailing-data.js +42 -0
  126. package/dist/stl.d.ts +64 -0
  127. package/dist/stl.js +309 -0
  128. package/dist/svg.d.ts +90 -0
  129. package/dist/svg.js +1007 -0
  130. package/dist/tds.d.ts +2 -0
  131. package/dist/tds.js +2 -0
  132. package/dist/textures.d.ts +42 -0
  133. package/dist/textures.js +53 -0
  134. package/dist/threemf-lattice.d.ts +139 -0
  135. package/dist/threemf-lattice.js +514 -0
  136. package/dist/threemf-materials.d.ts +75 -0
  137. package/dist/threemf-materials.js +314 -0
  138. package/dist/threemf-mesh.d.ts +60 -0
  139. package/dist/threemf-mesh.js +201 -0
  140. package/dist/threemf.d.ts +101 -0
  141. package/dist/threemf.js +415 -0
  142. package/dist/tilt.d.ts +62 -0
  143. package/dist/tilt.js +186 -0
  144. package/dist/tmx.d.ts +151 -0
  145. package/dist/tmx.js +394 -0
  146. package/dist/ttf.d.ts +78 -0
  147. package/dist/ttf.js +568 -0
  148. package/dist/types.d.ts +90 -0
  149. package/dist/types.js +35 -0
  150. package/dist/usd.d.ts +2 -0
  151. package/dist/usd.js +2 -0
  152. package/dist/usd.worker.d.ts +1 -0
  153. package/dist/usdz.d.ts +50 -0
  154. package/dist/usdz.js +646 -0
  155. package/dist/util.d.ts +75 -0
  156. package/dist/util.js +241 -0
  157. package/dist/vdb.d.ts +111 -0
  158. package/dist/vdb.js +663 -0
  159. package/dist/vrml.d.ts +53 -0
  160. package/dist/vrml.js +532 -0
  161. package/dist/vtk-cells.d.ts +29 -0
  162. package/dist/vtk-cells.js +211 -0
  163. package/dist/vtk-legacy.d.ts +57 -0
  164. package/dist/vtk-legacy.js +439 -0
  165. package/dist/vtk-reader.d.ts +19 -0
  166. package/dist/vtk-reader.js +134 -0
  167. package/dist/vtk-xml.d.ts +96 -0
  168. package/dist/vtk-xml.js +578 -0
  169. package/dist/vtk.d.ts +13 -0
  170. package/dist/vtk.js +234 -0
  171. package/dist/woff-glyf.d.ts +17 -0
  172. package/dist/woff-glyf.js +215 -0
  173. package/dist/worker.d.ts +10 -0
  174. package/dist/worker.js +93 -0
  175. package/dist/workers/usd.js +3 -0
  176. package/dist/xfile.d.ts +99 -0
  177. package/dist/xfile.js +706 -0
  178. package/dist/xml.d.ts +107 -0
  179. package/dist/xml.js +843 -0
  180. package/dist/xyz.d.ts +16 -0
  181. package/dist/xyz.js +110 -0
  182. package/dist/zip.d.ts +38 -0
  183. package/dist/zip.js +150 -0
  184. package/package.json +246 -6
@@ -0,0 +1,197 @@
1
+ import { type LoadedGeometry, type ParseLimits } from './types.js';
2
+ import { type BinaryInput } from './util.js';
3
+ /** Options of {@link parseBabylon}: the shared size limits plus the handedness and byte bounds below. */
4
+ export interface BabylonOptions extends ParseLimits {
5
+ /** Mirror Babylon's left-handed Z into the engine's right-handed space and keep the winding. Default true. */
6
+ rightHanded?: boolean;
7
+ /** Largest file in bytes. Default 256 MiB. */
8
+ maxBytes?: number;
9
+ /** Most nodes (meshes, instances, transform nodes, cameras, lights). Default 100,000. */
10
+ maxNodes?: number;
11
+ /** Most bytes of embedded `base64String` textures, all together. Default 64 MiB. */
12
+ maxTextureBytes?: number;
13
+ }
14
+ /** A texture slot of a material. An embedded image arrives decoded in `data`; otherwise `name` is a path or URL. */
15
+ export interface BabylonTexture {
16
+ name: string;
17
+ level: number;
18
+ offset: [number, number];
19
+ scale: [number, number];
20
+ /** Radians, about the texture centre. */
21
+ angle: number;
22
+ hasAlpha: boolean;
23
+ /** Babylon flips the image on load (true, the default); false means the file's v runs down the image, as glTF's does. */
24
+ invertY: boolean;
25
+ /** UV set: 0 (`uvs`) or 1 (`uvs2`). */
26
+ uvSet: number;
27
+ /** Wrap per axis: 0 clamp, 1 wrap, 2 mirror. */
28
+ wrap: [number, number];
29
+ /** Bytes of an embedded `data:` image (`base64String`). */
30
+ data?: Uint8Array;
31
+ /** Media type of `data`. */
32
+ mimeType?: string;
33
+ }
34
+ /** A material reduced to what an engine material needs. Colours are linear rgb. */
35
+ export interface BabylonMaterial {
36
+ id: string;
37
+ name: string;
38
+ /** `'pbr'` for the PBR classes, `'standard'` for StandardMaterial and anything else. */
39
+ kind: 'standard' | 'pbr';
40
+ /** The `customType` the file named, such as `BABYLON.PBRMetallicRoughnessMaterial`. */
41
+ className: string;
42
+ /** Diffuse or albedo or base colour, with the material's alpha in the fourth value. */
43
+ color: [number, number, number, number];
44
+ emissive: [number, number, number];
45
+ /** Standard materials: specular colour and exponent. */
46
+ specular: [number, number, number];
47
+ specularPower: number;
48
+ /** PBR materials. */
49
+ metallic?: number;
50
+ roughness?: number;
51
+ alpha: number;
52
+ doubleSided: boolean;
53
+ /** `disableLighting`: shade with the colour alone. */
54
+ unlit: boolean;
55
+ textures: Partial<Record<'color' | 'normal' | 'emissive' | 'opacity' | 'metallicRoughness' | 'occlusion' | 'specular', BabylonTexture>>;
56
+ }
57
+ /** A MultiMaterial: submesh `materialIndex` picks `materials[materialIndex]` (material ids). */
58
+ export interface BabylonMultiMaterial {
59
+ id: string;
60
+ name: string;
61
+ materials: string[];
62
+ }
63
+ /** One animation of a node: keys of `values` at `frame` for a property, at `fps` frames a second. */
64
+ export interface BabylonAnimation {
65
+ name: string;
66
+ /** `position`, `rotationQuaternion` or `scaling` (an Euler `rotation` is converted to `rotationQuaternion`). */
67
+ property: string;
68
+ fps: number;
69
+ loop: boolean;
70
+ keys: {
71
+ frame: number;
72
+ values: number[];
73
+ }[];
74
+ }
75
+ /** Fields of every node: placement relative to the parent, in the engine's space. */
76
+ export interface BabylonNode {
77
+ id: string;
78
+ name: string;
79
+ parentId?: string;
80
+ translation: [number, number, number];
81
+ /** Quaternion x, y, z, w. */
82
+ rotation: [number, number, number, number];
83
+ scale: [number, number, number];
84
+ visible: boolean;
85
+ animations: BabylonAnimation[];
86
+ }
87
+ /** A mesh. A mesh made by `instances` shares its source's geometry object and sets `instanceOf`. */
88
+ export interface BabylonMesh extends BabylonNode {
89
+ /** `uvs2` is `attributes.uv1`; each submesh is a group with `properties.materialIndex`. */
90
+ geometry: LoadedGeometry;
91
+ /** A material id, or a multi-material id when the mesh has submeshes with their own `materialIndex`. */
92
+ materialId?: string;
93
+ skeletonId?: string;
94
+ /** Four bone indices per vertex, and their weights; `joints1`/`weights1` hold influences five to eight. */
95
+ joints?: Uint16Array;
96
+ weights?: Float32Array;
97
+ joints1?: Uint16Array;
98
+ weights1?: Float32Array;
99
+ instanceOf?: string;
100
+ }
101
+ /** A TransformNode: a pure parent. */
102
+ export interface BabylonTransformNode extends BabylonNode {
103
+ }
104
+ /** A camera of the scene file, with its look-at point and lens. */
105
+ export interface BabylonCamera {
106
+ id: string;
107
+ name: string;
108
+ parentId?: string;
109
+ /** The file's class: `FreeCamera`, `ArcRotateCamera`, `UniversalCamera`, ... */
110
+ className: string;
111
+ position: [number, number, number];
112
+ /** The point looked at, derived from `target`, from alpha/beta/radius, or from the rotation. */
113
+ target: [number, number, number];
114
+ /** Vertical field of view in radians. */
115
+ fov: number;
116
+ near: number;
117
+ far: number;
118
+ /** Set for orthographic cameras (`mode` 1). */
119
+ orthographic?: {
120
+ left: number;
121
+ right: number;
122
+ top: number;
123
+ bottom: number;
124
+ };
125
+ }
126
+ /** A light of the scene file: point, directional, spot or hemispheric, in linear rgb. */
127
+ export interface BabylonLight {
128
+ id: string;
129
+ name: string;
130
+ parentId?: string;
131
+ kind: 'point' | 'directional' | 'spot' | 'hemispheric';
132
+ /** Linear rgb (`diffuse`). */
133
+ color: [number, number, number];
134
+ intensity: number;
135
+ position?: [number, number, number];
136
+ /** Directional and spot: the way it shines. Hemispheric: the direction of the sky. */
137
+ direction?: [number, number, number];
138
+ range?: number;
139
+ /** Spot: the full cone angle in radians. */
140
+ angle?: number;
141
+ /** Spot: the full inner cone angle in radians, when the file gives it. */
142
+ innerAngle?: number;
143
+ groundColor?: [number, number, number];
144
+ }
145
+ /** One bone of a skeleton: its name, index, parent and bind matrix. */
146
+ export interface BabylonBone {
147
+ name: string;
148
+ index: number;
149
+ parentBoneIndex: number;
150
+ /** Local bind matrix, 16 values column-major, in the engine's space. */
151
+ matrix: number[];
152
+ }
153
+ /** A skeleton of the scene file: its bones in file order. */
154
+ export interface BabylonSkeleton {
155
+ id: string;
156
+ name: string;
157
+ bones: BabylonBone[];
158
+ }
159
+ /** What {@link parseBabylon} returns. Every list is in file order. */
160
+ export interface LoadedBabylon {
161
+ meshes: BabylonMesh[];
162
+ transformNodes: BabylonTransformNode[];
163
+ materials: BabylonMaterial[];
164
+ multiMaterials: BabylonMultiMaterial[];
165
+ cameras: BabylonCamera[];
166
+ lights: BabylonLight[];
167
+ skeletons: BabylonSkeleton[];
168
+ clearColor?: [number, number, number];
169
+ ambientColor?: [number, number, number];
170
+ activeCameraId?: string;
171
+ /** The `producer` block's name and version, when present. */
172
+ producer?: {
173
+ name: string;
174
+ version: string;
175
+ };
176
+ /** Things the loader skipped (delay-loaded meshes, pivot matrices, unknown classes). */
177
+ warnings: string[];
178
+ }
179
+ /**
180
+ * Parses a Babylon.js `.babylon` scene. `input` is the file's bytes, its JSON text or the parsed object. Meshes keep the
181
+ * file's own vertices (`positions`, `normals`, `uvs`, `uvs2`, `colors`, `indices`) or the shared `geometries` they name;
182
+ * `instances` become meshes that share the geometry object. Skeletons, per-vertex bone weights and node animations are
183
+ * read; particle systems, sprites, sounds, post processes, LODs and delay-loaded binary mesh data are skipped with a
184
+ * warning. Bad shapes, out-of-range indices and counts past the limits throw a `LoaderError`.
185
+ */
186
+ export declare function parseBabylon(input: BinaryInput | string | object, options?: BabylonOptions): LoadedBabylon;
187
+ /** Options of {@link flattenBabylon}. */
188
+ export interface FlattenBabylonOptions {
189
+ /** Skip meshes the file hides, and their descendants. Default true. */
190
+ onlyVisible?: boolean;
191
+ }
192
+ /**
193
+ * Bakes every mesh's world transform into one geometry: parents, then the mesh's own placement. Each mesh becomes a
194
+ * group (`name`, its material's colour when the material is a plain one). A mirroring transform (a negative scale)
195
+ * flips the winding so faces keep facing out.
196
+ */
197
+ export declare function flattenBabylon(scene: LoadedBabylon, options?: FlattenBabylonOptions): LoadedGeometry;