@series-inc/stowkit-cli 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 (56) hide show
  1. package/dist/app/blob-store.d.ts +9 -0
  2. package/dist/app/blob-store.js +42 -0
  3. package/dist/app/disk-project.d.ts +84 -0
  4. package/dist/app/disk-project.js +70 -0
  5. package/dist/app/process-cache.d.ts +10 -0
  6. package/dist/app/process-cache.js +126 -0
  7. package/dist/app/state.d.ts +38 -0
  8. package/dist/app/state.js +16 -0
  9. package/dist/app/stowmat-io.d.ts +6 -0
  10. package/dist/app/stowmat-io.js +48 -0
  11. package/dist/app/stowmeta-io.d.ts +14 -0
  12. package/dist/app/stowmeta-io.js +207 -0
  13. package/dist/cleanup.d.ts +3 -0
  14. package/dist/cleanup.js +72 -0
  15. package/dist/cli.d.ts +2 -0
  16. package/dist/cli.js +148 -0
  17. package/dist/core/binary.d.ts +41 -0
  18. package/dist/core/binary.js +118 -0
  19. package/dist/core/constants.d.ts +64 -0
  20. package/dist/core/constants.js +65 -0
  21. package/dist/core/path.d.ts +3 -0
  22. package/dist/core/path.js +27 -0
  23. package/dist/core/types.d.ts +204 -0
  24. package/dist/core/types.js +76 -0
  25. package/dist/encoders/aac-encoder.d.ts +12 -0
  26. package/dist/encoders/aac-encoder.js +179 -0
  27. package/dist/encoders/basis-encoder.d.ts +15 -0
  28. package/dist/encoders/basis-encoder.js +116 -0
  29. package/dist/encoders/draco-encoder.d.ts +11 -0
  30. package/dist/encoders/draco-encoder.js +155 -0
  31. package/dist/encoders/fbx-loader.d.ts +4 -0
  32. package/dist/encoders/fbx-loader.js +540 -0
  33. package/dist/encoders/image-decoder.d.ts +13 -0
  34. package/dist/encoders/image-decoder.js +33 -0
  35. package/dist/encoders/interfaces.d.ts +105 -0
  36. package/dist/encoders/interfaces.js +1 -0
  37. package/dist/encoders/skinned-mesh-builder.d.ts +7 -0
  38. package/dist/encoders/skinned-mesh-builder.js +135 -0
  39. package/dist/format/metadata.d.ts +18 -0
  40. package/dist/format/metadata.js +381 -0
  41. package/dist/format/packer.d.ts +8 -0
  42. package/dist/format/packer.js +87 -0
  43. package/dist/index.d.ts +28 -0
  44. package/dist/index.js +35 -0
  45. package/dist/init.d.ts +1 -0
  46. package/dist/init.js +73 -0
  47. package/dist/node-fs.d.ts +22 -0
  48. package/dist/node-fs.js +148 -0
  49. package/dist/orchestrator.d.ts +20 -0
  50. package/dist/orchestrator.js +301 -0
  51. package/dist/pipeline.d.ts +23 -0
  52. package/dist/pipeline.js +354 -0
  53. package/dist/server.d.ts +9 -0
  54. package/dist/server.js +859 -0
  55. package/package.json +35 -0
  56. package/skill.md +211 -0
@@ -0,0 +1,155 @@
1
+ import draco3d from 'draco3d';
2
+ import { DracoQualityPreset } from '../core/types.js';
3
+ // ─── Preset → Settings ──────────────────────────────────────────────────────
4
+ export function dracoPresetToSettings(preset) {
5
+ switch (preset) {
6
+ case DracoQualityPreset.Fast:
7
+ return { compressionLevel: 3, positionQuantization: 11, normalQuantization: 8, uvQuantization: 10, scaleFactor: 1.0 };
8
+ case DracoQualityPreset.Balanced:
9
+ return { compressionLevel: 7, positionQuantization: 11, normalQuantization: 8, uvQuantization: 10, scaleFactor: 1.0 };
10
+ case DracoQualityPreset.HighQuality:
11
+ return { compressionLevel: 9, positionQuantization: 12, normalQuantization: 10, uvQuantization: 11, scaleFactor: 1.0 };
12
+ case DracoQualityPreset.MaximumQuality:
13
+ return { compressionLevel: 10, positionQuantization: 14, normalQuantization: 10, uvQuantization: 12, scaleFactor: 1.0 };
14
+ }
15
+ }
16
+ // ─── NodeDracoEncoder ─────────────────────────────────────────────────────────
17
+ export class NodeDracoEncoder {
18
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
+ draco = null;
20
+ ready = false;
21
+ isReady() {
22
+ return this.ready;
23
+ }
24
+ async initialize() {
25
+ this.draco = await draco3d.createEncoderModule({});
26
+ this.ready = true;
27
+ }
28
+ async encode(mesh, settings) {
29
+ if (!this.draco || !this.ready) {
30
+ throw new Error('Draco encoder not initialized');
31
+ }
32
+ const compressedBuffers = [];
33
+ const geometries = [];
34
+ let dataOffset = 0;
35
+ for (const sub of mesh.subMeshes) {
36
+ let positions = sub.positions;
37
+ if (settings.scaleFactor !== 1.0) {
38
+ positions = new Float32Array(sub.positions);
39
+ for (let i = 0; i < positions.length; i++) {
40
+ positions[i] *= settings.scaleFactor;
41
+ }
42
+ }
43
+ const compressed = this.encodeSubMesh(positions, sub.normals, sub.uvs, sub.indices, settings);
44
+ const posMin = [Infinity, Infinity, Infinity];
45
+ const posMax = [-Infinity, -Infinity, -Infinity];
46
+ for (let i = 0; i < positions.length; i += 3) {
47
+ if (positions[i] < posMin[0])
48
+ posMin[0] = positions[i];
49
+ if (positions[i + 1] < posMin[1])
50
+ posMin[1] = positions[i + 1];
51
+ if (positions[i + 2] < posMin[2])
52
+ posMin[2] = positions[i + 2];
53
+ if (positions[i] > posMax[0])
54
+ posMax[0] = positions[i];
55
+ if (positions[i + 1] > posMax[1])
56
+ posMax[1] = positions[i + 1];
57
+ if (positions[i + 2] > posMax[2])
58
+ posMax[2] = positions[i + 2];
59
+ }
60
+ geometries.push({
61
+ vertexCount: positions.length / 3,
62
+ indexCount: sub.indices.length,
63
+ hasNormals: sub.normals ? 1 : 0,
64
+ hasUvs: sub.uvs ? 1 : 0,
65
+ compressedBufferOffset: dataOffset,
66
+ compressedBufferSize: compressed.length,
67
+ materialIndex: sub.materialIndex,
68
+ positionMin: posMin,
69
+ positionMax: posMax,
70
+ });
71
+ compressedBuffers.push(compressed);
72
+ dataOffset += compressed.length;
73
+ }
74
+ const totalSize = compressedBuffers.reduce((s, b) => s + b.length, 0);
75
+ const data = new Uint8Array(totalSize);
76
+ let offset = 0;
77
+ for (const buf of compressedBuffers) {
78
+ data.set(buf, offset);
79
+ offset += buf.length;
80
+ }
81
+ const materials = mesh.materials.map((m) => ({
82
+ name: m.name,
83
+ schemaId: '',
84
+ propertyCount: 0,
85
+ properties: [],
86
+ }));
87
+ const meshIndicesFlat = [];
88
+ const sceneNodes = mesh.nodes.map((n) => {
89
+ const firstMeshIndex = meshIndicesFlat.length;
90
+ meshIndicesFlat.push(...n.meshIndices);
91
+ return {
92
+ name: n.name,
93
+ parentIndex: n.parentIndex,
94
+ position: n.position,
95
+ rotation: n.rotation,
96
+ scale: n.scale,
97
+ meshCount: n.meshIndices.length,
98
+ firstMeshIndex,
99
+ };
100
+ });
101
+ const metadata = {
102
+ meshGeometryCount: geometries.length,
103
+ materialCount: materials.length,
104
+ nodeCount: sceneNodes.length,
105
+ stringId: '',
106
+ geometries,
107
+ materials,
108
+ nodes: sceneNodes,
109
+ meshIndices: meshIndicesFlat,
110
+ };
111
+ return { data, metadata };
112
+ }
113
+ encodeSubMesh(positions, normals, uvs, indices, settings) {
114
+ const draco = this.draco;
115
+ const encoder = new draco.Encoder();
116
+ const mesh = new draco.Mesh();
117
+ const builder = new draco.MeshBuilder();
118
+ try {
119
+ const numFaces = indices.length / 3;
120
+ const numPoints = positions.length / 3;
121
+ builder.AddFacesToMesh(mesh, numFaces, indices);
122
+ builder.AddFloatAttributeToMesh(mesh, draco.POSITION, numPoints, 3, positions);
123
+ if (normals) {
124
+ builder.AddFloatAttributeToMesh(mesh, draco.NORMAL, numPoints, 3, normals);
125
+ }
126
+ if (uvs) {
127
+ builder.AddFloatAttributeToMesh(mesh, draco.TEX_COORD, numPoints, 2, uvs);
128
+ }
129
+ encoder.SetEncodingMethod(draco.MESH_SEQUENTIAL_ENCODING);
130
+ encoder.SetAttributeQuantization(draco.POSITION, settings.positionQuantization);
131
+ if (normals)
132
+ encoder.SetAttributeQuantization(draco.NORMAL, settings.normalQuantization);
133
+ if (uvs)
134
+ encoder.SetAttributeQuantization(draco.TEX_COORD, settings.uvQuantization);
135
+ const dracoBuffer = new draco.DracoInt8Array();
136
+ const encodedLen = encoder.EncodeMeshToDracoBuffer(mesh, dracoBuffer);
137
+ if (encodedLen === 0) {
138
+ draco.destroy(dracoBuffer);
139
+ throw new Error(`Draco encoding returned 0 bytes (${numPoints} verts, ${numFaces} faces)`);
140
+ }
141
+ // Copy from EncoderBuffer to Uint8Array
142
+ const result = new Uint8Array(encodedLen);
143
+ for (let i = 0; i < encodedLen; i++) {
144
+ result[i] = dracoBuffer.GetValue(i) & 0xff;
145
+ }
146
+ draco.destroy(dracoBuffer);
147
+ return result;
148
+ }
149
+ finally {
150
+ draco.destroy(mesh);
151
+ draco.destroy(builder);
152
+ draco.destroy(encoder);
153
+ }
154
+ }
155
+ }
@@ -0,0 +1,4 @@
1
+ import type { IMeshImporter, ImportedMesh } from './interfaces.js';
2
+ export declare class NodeFbxImporter implements IMeshImporter {
3
+ import(data: Uint8Array, _fileName: string): Promise<ImportedMesh>;
4
+ }