@forgeax/engine-gltf 0.0.0-dev.8d955ade1c79
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/LICENSE +202 -0
- package/README.md +204 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/__tests__/animation-target-errors.unit.test.d.ts +2 -0
- package/dist/__tests__/animation-target-errors.unit.test.d.ts.map +1 -0
- package/dist/__tests__/bridge-material-samplers.unit.test.d.ts +2 -0
- package/dist/__tests__/bridge-material-samplers.unit.test.d.ts.map +1 -0
- package/dist/__tests__/bridge-material-values.unit.test.d.ts +2 -0
- package/dist/__tests__/bridge-material-values.unit.test.d.ts.map +1 -0
- package/dist/__tests__/bridge-mixed-color.unit.test.d.ts +2 -0
- package/dist/__tests__/bridge-mixed-color.unit.test.d.ts.map +1 -0
- package/dist/__tests__/bridge-sampler-required.test-d.d.ts +2 -0
- package/dist/__tests__/bridge-sampler-required.test-d.d.ts.map +1 -0
- package/dist/__tests__/bridge-skin-shader-route.unit.test.d.ts +2 -0
- package/dist/__tests__/bridge-skin-shader-route.unit.test.d.ts.map +1 -0
- package/dist/__tests__/bridge-skin-stride.unit.test.d.ts +2 -0
- package/dist/__tests__/bridge-skin-stride.unit.test.d.ts.map +1 -0
- package/dist/__tests__/bridge-test-helpers.d.ts +5 -0
- package/dist/__tests__/bridge-test-helpers.d.ts.map +1 -0
- package/dist/__tests__/bridge.unit.test.d.ts +2 -0
- package/dist/__tests__/bridge.unit.test.d.ts.map +1 -0
- package/dist/__tests__/cli-gltf.integration.test.d.ts +2 -0
- package/dist/__tests__/cli-gltf.integration.test.d.ts.map +1 -0
- package/dist/__tests__/color-0-accessor.unit.test.d.ts +2 -0
- package/dist/__tests__/color-0-accessor.unit.test.d.ts.map +1 -0
- package/dist/__tests__/data-uri-surface.unit.test.d.ts +2 -0
- package/dist/__tests__/data-uri-surface.unit.test.d.ts.map +1 -0
- package/dist/__tests__/extension-admission.unit.test.d.ts +2 -0
- package/dist/__tests__/extension-admission.unit.test.d.ts.map +1 -0
- package/dist/__tests__/gltf-error-derived-views.test-d.d.ts +2 -0
- package/dist/__tests__/gltf-error-derived-views.test-d.d.ts.map +1 -0
- package/dist/__tests__/gltf-error-migration.test.d.ts +2 -0
- package/dist/__tests__/gltf-error-migration.test.d.ts.map +1 -0
- package/dist/__tests__/gltf-error-policy-owner.unit.test.d.ts +2 -0
- package/dist/__tests__/gltf-error-policy-owner.unit.test.d.ts.map +1 -0
- package/dist/__tests__/gltf-importer.test.d.ts +2 -0
- package/dist/__tests__/gltf-importer.test.d.ts.map +1 -0
- package/dist/__tests__/gltf-local-artifacts.test.d.ts +2 -0
- package/dist/__tests__/gltf-local-artifacts.test.d.ts.map +1 -0
- package/dist/__tests__/gltf.unit.test.d.ts +2 -0
- package/dist/__tests__/gltf.unit.test.d.ts.map +1 -0
- package/dist/__tests__/malformed-buffer-data-uri.integration.test.d.ts +2 -0
- package/dist/__tests__/malformed-buffer-data-uri.integration.test.d.ts.map +1 -0
- package/dist/__tests__/material-missing-uv.unit.test.d.ts +2 -0
- package/dist/__tests__/material-missing-uv.unit.test.d.ts.map +1 -0
- package/dist/__tests__/material-pack-refs.integration.test.d.ts +2 -0
- package/dist/__tests__/material-pack-refs.integration.test.d.ts.map +1 -0
- package/dist/__tests__/material-per-slot-ir.unit.test.d.ts +2 -0
- package/dist/__tests__/material-per-slot-ir.unit.test.d.ts.map +1 -0
- package/dist/__tests__/material-texture-transform.unit.test.d.ts +2 -0
- package/dist/__tests__/material-texture-transform.unit.test.d.ts.map +1 -0
- package/dist/__tests__/material-unused-uv.unit.test.d.ts +2 -0
- package/dist/__tests__/material-unused-uv.unit.test.d.ts.map +1 -0
- package/dist/__tests__/meshopt-decode.unit.test.d.ts +2 -0
- package/dist/__tests__/meshopt-decode.unit.test.d.ts.map +1 -0
- package/dist/__tests__/meshopt-falsifier.unit.test.d.ts +2 -0
- package/dist/__tests__/meshopt-falsifier.unit.test.d.ts.map +1 -0
- package/dist/__tests__/meshopt-mode-filter-owner.test-d.d.ts +2 -0
- package/dist/__tests__/meshopt-mode-filter-owner.test-d.d.ts.map +1 -0
- package/dist/__tests__/meshopt-real-matrix.integration.test.d.ts +2 -0
- package/dist/__tests__/meshopt-real-matrix.integration.test.d.ts.map +1 -0
- package/dist/__tests__/morph-import.integration.test.d.ts +2 -0
- package/dist/__tests__/morph-import.integration.test.d.ts.map +1 -0
- package/dist/__tests__/morph-import.unit.test.d.ts +2 -0
- package/dist/__tests__/morph-import.unit.test.d.ts.map +1 -0
- package/dist/__tests__/parse-decode.unit.test.d.ts +2 -0
- package/dist/__tests__/parse-decode.unit.test.d.ts.map +1 -0
- package/dist/__tests__/parse-gltf-multi-uv.test.d.ts +2 -0
- package/dist/__tests__/parse-gltf-multi-uv.test.d.ts.map +1 -0
- package/dist/__tests__/parse-gltf-skin-attrs.unit.test.d.ts +2 -0
- package/dist/__tests__/parse-gltf-skin-attrs.unit.test.d.ts.map +1 -0
- package/dist/__tests__/parse-gltf.unit.test.d.ts +2 -0
- package/dist/__tests__/parse-gltf.unit.test.d.ts.map +1 -0
- package/dist/__tests__/pick-e2e.integration.test.d.ts +2 -0
- package/dist/__tests__/pick-e2e.integration.test.d.ts.map +1 -0
- package/dist/__tests__/public-surface.unit.test.d.ts +2 -0
- package/dist/__tests__/public-surface.unit.test.d.ts.map +1 -0
- package/dist/__tests__/source-key-diagnostics.integration.test.d.ts +2 -0
- package/dist/__tests__/source-key-diagnostics.integration.test.d.ts.map +1 -0
- package/dist/__tests__/source-key-producer.integration.test.d.ts +2 -0
- package/dist/__tests__/source-key-producer.integration.test.d.ts.map +1 -0
- package/dist/__tests__/source-key.unit.test.d.ts +2 -0
- package/dist/__tests__/source-key.unit.test.d.ts.map +1 -0
- package/dist/accessor/decode-accessor.d.ts +75 -0
- package/dist/accessor/decode-accessor.d.ts.map +1 -0
- package/dist/accessor/decode-color.d.ts +15 -0
- package/dist/accessor/decode-color.d.ts.map +1 -0
- package/dist/accessor/index.d.ts +3 -0
- package/dist/accessor/index.d.ts.map +1 -0
- package/dist/bridge.d.ts +103 -0
- package/dist/bridge.d.ts.map +1 -0
- package/dist/check-extensions.d.ts +29 -0
- package/dist/check-extensions.d.ts.map +1 -0
- package/dist/cli-gltf.d.ts +8 -0
- package/dist/cli-gltf.d.ts.map +1 -0
- package/dist/cli-gltf.mjs +2435 -0
- package/dist/cli-gltf.mjs.map +1 -0
- package/dist/data-uri.d.ts +6 -0
- package/dist/data-uri.d.ts.map +1 -0
- package/dist/errors.d.ts +201 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/extract-image-bytes.d.ts +42 -0
- package/dist/extract-image-bytes.d.ts.map +1 -0
- package/dist/gltf-importer.d.ts +21 -0
- package/dist/gltf-importer.d.ts.map +1 -0
- package/dist/image-color-space.d.ts +35 -0
- package/dist/image-color-space.d.ts.map +1 -0
- package/dist/importer-entry.d.ts +10 -0
- package/dist/importer-entry.d.ts.map +1 -0
- package/dist/importer-entry.mjs +3378 -0
- package/dist/importer-entry.mjs.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +3673 -0
- package/dist/index.mjs.map +1 -0
- package/dist/meshopt-decode.d.ts +39 -0
- package/dist/meshopt-decode.d.ts.map +1 -0
- package/dist/node-file-entry.d.ts +14 -0
- package/dist/node-file-entry.d.ts.map +1 -0
- package/dist/node-file-entry.mjs +1946 -0
- package/dist/node-file-entry.mjs.map +1 -0
- package/dist/node-path.d.ts +14 -0
- package/dist/node-path.d.ts.map +1 -0
- package/dist/parse-animation.d.ts +70 -0
- package/dist/parse-animation.d.ts.map +1 -0
- package/dist/parse-glb-chunks.d.ts +25 -0
- package/dist/parse-glb-chunks.d.ts.map +1 -0
- package/dist/parse-glb.d.ts +3 -0
- package/dist/parse-glb.d.ts.map +1 -0
- package/dist/parse-gltf-header.d.ts +18 -0
- package/dist/parse-gltf-header.d.ts.map +1 -0
- package/dist/parse-gltf.d.ts +263 -0
- package/dist/parse-gltf.d.ts.map +1 -0
- package/dist/parse-skin.d.ts +70 -0
- package/dist/parse-skin.d.ts.map +1 -0
- package/dist/reimport-reuse-meta.d.ts +48 -0
- package/dist/reimport-reuse-meta.d.ts.map +1 -0
- package/dist/serialize-meta.d.ts +2 -0
- package/dist/serialize-meta.d.ts.map +1 -0
- package/dist/source-key.d.ts +44 -0
- package/dist/source-key.d.ts.map +1 -0
- package/dist/sub-asset-key.d.ts +12 -0
- package/dist/sub-asset-key.d.ts.map +1 -0
- package/dist/to-asset-pack.d.ts +2 -0
- package/dist/to-asset-pack.d.ts.map +1 -0
- package/dist/transform.d.ts +37 -0
- package/dist/transform.d.ts.map +1 -0
- package/package.json +92 -0
- package/src/__tests__/animation-target-errors.unit.test.ts +51 -0
- package/src/__tests__/bridge-material-samplers.unit.test.ts +67 -0
- package/src/__tests__/bridge-material-values.unit.test.ts +106 -0
- package/src/__tests__/bridge-mixed-color.unit.test.ts +100 -0
- package/src/__tests__/bridge-sampler-required.test-d.ts +59 -0
- package/src/__tests__/bridge-skin-shader-route.unit.test.ts +42 -0
- package/src/__tests__/bridge-skin-stride.unit.test.ts +115 -0
- package/src/__tests__/bridge-test-helpers.ts +9 -0
- package/src/__tests__/bridge.unit.test.ts +1227 -0
- package/src/__tests__/cli-gltf.integration.test.ts +122 -0
- package/src/__tests__/color-0-accessor.unit.test.ts +174 -0
- package/src/__tests__/data-uri-surface.unit.test.ts +26 -0
- package/src/__tests__/extension-admission.unit.test.ts +19 -0
- package/src/__tests__/fixtures/color-0/float-vec3.gltf +13 -0
- package/src/__tests__/fixtures/color-0/interleaved-vec3.gltf +6 -0
- package/src/__tests__/fixtures/color-0/normalized-ubyte.gltf +6 -0
- package/src/__tests__/fixtures/color-0/normalized-ushort.gltf +6 -0
- package/src/__tests__/gltf-error-derived-views.test-d.ts +152 -0
- package/src/__tests__/gltf-error-migration.test.ts +147 -0
- package/src/__tests__/gltf-error-policy-owner.unit.test.ts +185 -0
- package/src/__tests__/gltf-importer.test.ts +12 -0
- package/src/__tests__/gltf-local-artifacts.test.ts +11 -0
- package/src/__tests__/gltf.unit.test.ts +2975 -0
- package/src/__tests__/malformed-buffer-data-uri.integration.test.ts +140 -0
- package/src/__tests__/material-missing-uv.unit.test.ts +29 -0
- package/src/__tests__/material-pack-refs.integration.test.ts +58 -0
- package/src/__tests__/material-per-slot-ir.unit.test.ts +90 -0
- package/src/__tests__/material-texture-transform.unit.test.ts +105 -0
- package/src/__tests__/material-unused-uv.unit.test.ts +44 -0
- package/src/__tests__/meshopt-decode.unit.test.ts +87 -0
- package/src/__tests__/meshopt-falsifier.unit.test.ts +92 -0
- package/src/__tests__/meshopt-mode-filter-owner.test-d.ts +79 -0
- package/src/__tests__/meshopt-real-matrix.integration.test.ts +370 -0
- package/src/__tests__/morph-import.integration.test.ts +115 -0
- package/src/__tests__/morph-import.unit.test.ts +62 -0
- package/src/__tests__/parse-decode.unit.test.ts +919 -0
- package/src/__tests__/parse-gltf-multi-uv.test.ts +238 -0
- package/src/__tests__/parse-gltf-skin-attrs.unit.test.ts +191 -0
- package/src/__tests__/parse-gltf.unit.test.ts +133 -0
- package/src/__tests__/pick-e2e.integration.test.ts +238 -0
- package/src/__tests__/public-surface.unit.test.ts +10 -0
- package/src/__tests__/source-key-diagnostics.integration.test.ts +140 -0
- package/src/__tests__/source-key-producer.integration.test.ts +171 -0
- package/src/__tests__/source-key.unit.test.ts +159 -0
- package/src/accessor/decode-accessor.ts +309 -0
- package/src/accessor/decode-color.ts +128 -0
- package/src/accessor/index.ts +15 -0
- package/src/bridge.ts +928 -0
- package/src/check-extensions.ts +85 -0
- package/src/cli-gltf.ts +339 -0
- package/src/data-uri.ts +29 -0
- package/src/errors.ts +386 -0
- package/src/extract-image-bytes.ts +343 -0
- package/src/gltf-importer.ts +976 -0
- package/src/image-color-space.ts +104 -0
- package/src/importer-entry.ts +24 -0
- package/src/index.ts +148 -0
- package/src/meshopt-decode.ts +200 -0
- package/src/node-file-entry.ts +98 -0
- package/src/node-path.ts +41 -0
- package/src/parse-animation.ts +286 -0
- package/src/parse-glb-chunks.ts +167 -0
- package/src/parse-glb.ts +16 -0
- package/src/parse-gltf-header.ts +58 -0
- package/src/parse-gltf.ts +1731 -0
- package/src/parse-skin.ts +238 -0
- package/src/reimport-reuse-meta.ts +134 -0
- package/src/serialize-meta.ts +24 -0
- package/src/source-key.ts +106 -0
- package/src/sub-asset-key.ts +61 -0
- package/src/to-asset-pack.ts +8 -0
- package/src/transform.ts +117 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type GltfError, type Result } from './errors.js';
|
|
2
|
+
import { parseGltfHeader } from './parse-gltf-header.js';
|
|
3
|
+
export type { GltfHeaderJson } from './parse-gltf-header.js';
|
|
4
|
+
export { parseGltfHeader };
|
|
5
|
+
/** Result payload of {@link parseGlbChunks}. */
|
|
6
|
+
export interface GlbChunks {
|
|
7
|
+
readonly version: number;
|
|
8
|
+
readonly length: number;
|
|
9
|
+
readonly jsonChunk: Uint8Array;
|
|
10
|
+
readonly binChunk?: Uint8Array;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Split a GLB 2.0 binary container into its `JSON` chunk and optional
|
|
14
|
+
* `BIN` chunk. Returns the declared `version` and `length` for the caller
|
|
15
|
+
* to surface in diagnostics.
|
|
16
|
+
*
|
|
17
|
+
* Failure path returns one of:
|
|
18
|
+
* - `gltf-malformed-header` (magic / chunk shape / declared length / missing JSON)
|
|
19
|
+
* - `gltf-version-unsupported` (version != 2)
|
|
20
|
+
*
|
|
21
|
+
* The function is pure: no fs / network access; the caller passes the
|
|
22
|
+
* already-loaded ArrayBuffer.
|
|
23
|
+
*/
|
|
24
|
+
export declare function parseGlbChunks(buffer: ArrayBuffer, filePath: string): Result<GlbChunks, GltfError>;
|
|
25
|
+
//# sourceMappingURL=parse-glb-chunks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-glb-chunks.d.ts","sourceRoot":"","sources":["../src/parse-glb-chunks.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAO,KAAK,SAAS,EAAe,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,YAAY,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,CAAC;AAQ3B,gDAAgD;AAChD,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC;IAC/B,QAAQ,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC;CAChC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,WAAW,EACnB,QAAQ,EAAE,MAAM,GACf,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,CA4G9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-glb.d.ts","sourceRoot":"","sources":["../src/parse-glb.ts"],"names":[],"mappings":"AAcA,YAAY,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { GltfError } from './errors.js';
|
|
2
|
+
import { type Result } from './errors.js';
|
|
3
|
+
/** Minimal JSON shape touched by the version gate. */
|
|
4
|
+
export interface GltfHeaderJson {
|
|
5
|
+
readonly asset?: {
|
|
6
|
+
readonly version?: string;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Validate the top-level `asset.version` field of a parsed glTF document.
|
|
11
|
+
*
|
|
12
|
+
* On success the JSON object is echoed back unchanged (caller already owns
|
|
13
|
+
* the parsed representation). On failure, the closed `GltfErrorCode`
|
|
14
|
+
* surface narrows to either `gltf-malformed-header` (asset block missing)
|
|
15
|
+
* or `gltf-version-unsupported` (version != "2.0").
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseGltfHeader(json: unknown, filePath: string): Result<GltfHeaderJson, GltfError>;
|
|
18
|
+
//# sourceMappingURL=parse-gltf-header.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-gltf-header.d.ts","sourceRoot":"","sources":["../src/parse-gltf-header.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAoB,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAE5D,sDAAsD;AACtD,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,KAAK,CAAC,EAAE;QAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAChD;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,OAAO,EACb,QAAQ,EAAE,MAAM,GACf,MAAM,CAAC,cAAc,EAAE,SAAS,CAAC,CA2BnC"}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { ImportError } from '@forgeax/engine-types';
|
|
2
|
+
import { COMPONENT_TYPE } from './accessor/decode-accessor.js';
|
|
3
|
+
import { type GltfError, type Result } from './errors.js';
|
|
4
|
+
import { type GltfBufferViewDecodeCapability } from './meshopt-decode.js';
|
|
5
|
+
import { type GltfAnimationClipRecord } from './parse-animation.js';
|
|
6
|
+
import { type GltfSkeletonRecord } from './parse-skin.js';
|
|
7
|
+
import { type GltfMetaJson, type GltfSubAssetEntry } from './reimport-reuse-meta.js';
|
|
8
|
+
import type { GltfSourceKeyError } from './source-key.js';
|
|
9
|
+
import { type DecomposedTransform } from './transform.js';
|
|
10
|
+
export interface MeshPrimitiveJson {
|
|
11
|
+
readonly attributes?: Record<string, number>;
|
|
12
|
+
readonly indices?: number;
|
|
13
|
+
readonly material?: number;
|
|
14
|
+
readonly mode?: number;
|
|
15
|
+
readonly targets?: ReadonlyArray<Record<string, number>>;
|
|
16
|
+
}
|
|
17
|
+
export interface MeshJson {
|
|
18
|
+
readonly name?: string;
|
|
19
|
+
readonly weights?: readonly number[];
|
|
20
|
+
readonly primitives: readonly MeshPrimitiveJson[];
|
|
21
|
+
}
|
|
22
|
+
export interface GltfMeshIr {
|
|
23
|
+
readonly name?: string;
|
|
24
|
+
readonly positions: Float32Array;
|
|
25
|
+
readonly normals?: Float32Array;
|
|
26
|
+
readonly texcoord0?: Float32Array;
|
|
27
|
+
/** TEXCOORD_1 per-vertex UV set 1 (Float32Array, 2 per vertex). feat-20260629-multi-uv-set-support m1-w2. */
|
|
28
|
+
readonly texcoord1?: Float32Array;
|
|
29
|
+
/** TEXCOORD_2 per-vertex UV set 2 (Float32Array, 2 per vertex). */
|
|
30
|
+
readonly texcoord2?: Float32Array;
|
|
31
|
+
/** TEXCOORD_3 per-vertex UV set 3 (Float32Array, 2 per vertex). */
|
|
32
|
+
readonly texcoord3?: Float32Array;
|
|
33
|
+
/** TEXCOORD_4 per-vertex UV set 4 (Float32Array, 2 per vertex). */
|
|
34
|
+
readonly texcoord4?: Float32Array;
|
|
35
|
+
/** TEXCOORD_5 per-vertex UV set 5 (Float32Array, 2 per vertex). */
|
|
36
|
+
readonly texcoord5?: Float32Array;
|
|
37
|
+
/** TEXCOORD_6 per-vertex UV set 6 (Float32Array, 2 per vertex). */
|
|
38
|
+
readonly texcoord6?: Float32Array;
|
|
39
|
+
/** TEXCOORD_7 per-vertex UV set 7 (Float32Array, 2 per vertex). */
|
|
40
|
+
readonly texcoord7?: Float32Array;
|
|
41
|
+
readonly tangents?: Float32Array;
|
|
42
|
+
/** COLOR_0 importer carrier; bridge projects it to the canonical color attribute. */
|
|
43
|
+
readonly colors0?: Float32Array;
|
|
44
|
+
/** JOINTS_0 per-vertex joint indices (Uint16Array, 4 per vertex). UBYTE source is width-converted to U16 at parse time (D-3). */
|
|
45
|
+
readonly joints0?: Uint16Array;
|
|
46
|
+
/** WEIGHTS_0 per-vertex skin weights (Float32Array, 4 per vertex). */
|
|
47
|
+
readonly weights0?: Float32Array;
|
|
48
|
+
readonly morphTargets?: readonly {
|
|
49
|
+
readonly position?: Float32Array;
|
|
50
|
+
readonly normal?: Float32Array;
|
|
51
|
+
readonly tangent?: Float32Array;
|
|
52
|
+
}[];
|
|
53
|
+
readonly morphWeights?: Float32Array;
|
|
54
|
+
/**
|
|
55
|
+
* Optional per-glTF-spec: when omitted, primitive declares non-indexed
|
|
56
|
+
* geometry (vertex buffer is consumed in vertex order, every 3 verts =
|
|
57
|
+
* 1 triangle for triangle-list). bridge.ts handles undefined by routing
|
|
58
|
+
* MeshAsset.indices to undefined and submesh.indexCount=0 (vertexCount
|
|
59
|
+
* carries the draw count for `pass.draw(vertexCount)`).
|
|
60
|
+
* bug-20260612 hello-skin visual layered gate: prior shape coerced
|
|
61
|
+
* undefined into Uint16Array(0) and tripped MeshAsset.indices !==
|
|
62
|
+
* undefined branches downstream into drawIndexed(0).
|
|
63
|
+
* U16 (incl. widened U8) or U32 — width preserved from the source accessor;
|
|
64
|
+
* bridge.ts narrows U32 to U16 when the merged maxIndex fits.
|
|
65
|
+
*/
|
|
66
|
+
readonly indices?: Uint16Array | Uint32Array;
|
|
67
|
+
readonly materialIndex: number | null;
|
|
68
|
+
/**
|
|
69
|
+
* Owning glTF mesh index in the original document (`gltf.meshes[meshIndex]`).
|
|
70
|
+
* After OOS-7 flattening, multiple GltfMeshIr entries may share the same
|
|
71
|
+
* meshIndex (one per primitive). Bridge layer uses this to filter material
|
|
72
|
+
* collection per node, fixing the verify-r1 charter-defect where multi
|
|
73
|
+
* glTF-mesh documents would silently misalign materials across nodes.
|
|
74
|
+
*/
|
|
75
|
+
readonly meshIndex: number;
|
|
76
|
+
}
|
|
77
|
+
export interface GltfTextureIr {
|
|
78
|
+
readonly sampler?: number;
|
|
79
|
+
readonly source: number;
|
|
80
|
+
readonly name?: string;
|
|
81
|
+
}
|
|
82
|
+
export interface GltfTextureTransformIr {
|
|
83
|
+
readonly offset?: readonly [number, number];
|
|
84
|
+
readonly rotation?: number;
|
|
85
|
+
readonly scale?: readonly [number, number];
|
|
86
|
+
}
|
|
87
|
+
export interface GltfTextureInfoIr {
|
|
88
|
+
readonly texture: number;
|
|
89
|
+
readonly sampler?: number;
|
|
90
|
+
readonly texCoord?: number;
|
|
91
|
+
readonly transform?: GltfTextureTransformIr;
|
|
92
|
+
}
|
|
93
|
+
export interface GltfNormalTextureInfoIr extends GltfTextureInfoIr {
|
|
94
|
+
readonly scale?: number;
|
|
95
|
+
}
|
|
96
|
+
export interface GltfOcclusionTextureInfoIr extends GltfTextureInfoIr {
|
|
97
|
+
readonly strength?: number;
|
|
98
|
+
}
|
|
99
|
+
export interface GltfImageIr {
|
|
100
|
+
readonly uri?: string;
|
|
101
|
+
readonly mimeType?: string;
|
|
102
|
+
readonly bufferView?: number;
|
|
103
|
+
readonly name?: string;
|
|
104
|
+
}
|
|
105
|
+
export interface GltfSamplerIr {
|
|
106
|
+
readonly magFilter?: number;
|
|
107
|
+
readonly minFilter?: number;
|
|
108
|
+
readonly wrapS: number;
|
|
109
|
+
readonly wrapT: number;
|
|
110
|
+
readonly name?: string;
|
|
111
|
+
}
|
|
112
|
+
export interface GltfMaterialIr {
|
|
113
|
+
readonly name?: string;
|
|
114
|
+
readonly baseColorFactor: readonly [number, number, number, number];
|
|
115
|
+
/** glTF emissiveFactor; omitted means the glTF default [0, 0, 0]. */
|
|
116
|
+
readonly emissiveFactor?: readonly [number, number, number];
|
|
117
|
+
readonly baseColorTexture?: GltfTextureInfoIr | number;
|
|
118
|
+
/** Texture binding for the emissive map. */
|
|
119
|
+
readonly emissiveTexture?: GltfTextureInfoIr | number;
|
|
120
|
+
readonly metallicFactor: number;
|
|
121
|
+
readonly roughnessFactor: number;
|
|
122
|
+
readonly metallicRoughnessTexture?: GltfTextureInfoIr | number;
|
|
123
|
+
readonly normalTexture?: GltfNormalTextureInfoIr | number;
|
|
124
|
+
readonly occlusionTexture?: GltfOcclusionTextureInfoIr | number;
|
|
125
|
+
/**
|
|
126
|
+
* glTF `alphaMode` (`'OPAQUE'` | `'MASK'` | `'BLEND'`). Absent -> `'OPAQUE'`
|
|
127
|
+
* (glTF spec default). Drives the bridge's transparent / alpha-test routing.
|
|
128
|
+
*/
|
|
129
|
+
readonly alphaMode?: 'OPAQUE' | 'MASK' | 'BLEND';
|
|
130
|
+
/** glTF `alphaCutoff` (MASK-mode threshold; glTF spec default 0.5). */
|
|
131
|
+
readonly alphaCutoff?: number;
|
|
132
|
+
/**
|
|
133
|
+
* glTF `doubleSided`. Absent -> false (the glTF spec default). The bridge
|
|
134
|
+
* maps this to a no-cull material pass so reverse-facing glass and cards
|
|
135
|
+
* remain visible without changing their authored winding.
|
|
136
|
+
*/
|
|
137
|
+
readonly doubleSided?: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* baseColorTexture UV-set index (glTF `baseColorTexture.texCoord`). Absent
|
|
140
|
+
* -> 0. Selects which interleaved UV set the base-color sampler reads.
|
|
141
|
+
*/
|
|
142
|
+
readonly baseColorTexCoord?: number;
|
|
143
|
+
}
|
|
144
|
+
export interface NodeInstancingIr {
|
|
145
|
+
/** Number of instances. All TRS attribute accessors share this count. */
|
|
146
|
+
readonly count: number;
|
|
147
|
+
/** N column-major mat4 transforms packed into one Float32Array (length = N*16). */
|
|
148
|
+
readonly transforms: Float32Array;
|
|
149
|
+
}
|
|
150
|
+
export type GltfPunctualLightType = 'directional' | 'point' | 'spot';
|
|
151
|
+
export interface GltfPunctualLightIr {
|
|
152
|
+
readonly type: GltfPunctualLightType;
|
|
153
|
+
readonly color: readonly [number, number, number];
|
|
154
|
+
readonly intensity: number;
|
|
155
|
+
readonly range?: number;
|
|
156
|
+
readonly spot?: {
|
|
157
|
+
readonly innerConeAngle: number;
|
|
158
|
+
readonly outerConeAngle: number;
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
export interface GltfNodeIr {
|
|
162
|
+
readonly name?: string;
|
|
163
|
+
readonly transform: DecomposedTransform;
|
|
164
|
+
readonly meshIndex: number | null;
|
|
165
|
+
/** Node-authored morph weights override mesh defaults at instantiation. */
|
|
166
|
+
readonly morphWeights?: Float32Array;
|
|
167
|
+
/** Valid when node carries `skin` reference. Null when no skin. */
|
|
168
|
+
readonly skinIndex: number | null;
|
|
169
|
+
readonly children: readonly number[];
|
|
170
|
+
/** Present when node carries EXT_mesh_gpu_instancing (feat-20260518). */
|
|
171
|
+
readonly instancing?: NodeInstancingIr;
|
|
172
|
+
/** glTF camera index. Null when the node does not reference a camera. */
|
|
173
|
+
readonly camera: number | null;
|
|
174
|
+
/** KHR_lights_punctual light index. Null when the node has no light. */
|
|
175
|
+
readonly lightIndex?: number | null;
|
|
176
|
+
}
|
|
177
|
+
export interface GltfSceneIr {
|
|
178
|
+
readonly name?: string;
|
|
179
|
+
readonly nodes: readonly number[];
|
|
180
|
+
}
|
|
181
|
+
export interface GltfDiagnosticsIr {
|
|
182
|
+
readonly nodeNames: readonly string[];
|
|
183
|
+
readonly unsupportedExtensions: readonly string[];
|
|
184
|
+
readonly matrixTrsCoexistNodes: readonly number[];
|
|
185
|
+
}
|
|
186
|
+
export interface GltfDoc {
|
|
187
|
+
readonly meshes: readonly GltfMeshIr[];
|
|
188
|
+
readonly materials: readonly GltfMaterialIr[];
|
|
189
|
+
readonly nodes: readonly GltfNodeIr[];
|
|
190
|
+
readonly scenes: readonly GltfSceneIr[];
|
|
191
|
+
readonly textures: readonly GltfTextureIr[] | undefined;
|
|
192
|
+
readonly images: readonly GltfImageIr[] | undefined;
|
|
193
|
+
readonly samplers: readonly GltfSamplerIr[] | undefined;
|
|
194
|
+
readonly skeletons: readonly GltfSkeletonRecord[];
|
|
195
|
+
readonly animationClips: readonly GltfAnimationClipRecord[];
|
|
196
|
+
readonly defaultSceneIndex: number;
|
|
197
|
+
readonly diagnostics: GltfDiagnosticsIr;
|
|
198
|
+
/** KHR_lights_punctual author facts, kept in source units for the bridge. */
|
|
199
|
+
readonly lights?: readonly GltfPunctualLightIr[];
|
|
200
|
+
/** Raw extension projection retained for bridge-only hand-constructed docs. */
|
|
201
|
+
readonly extensions?: {
|
|
202
|
+
readonly KHR_lights_punctual?: {
|
|
203
|
+
readonly lights?: readonly GltfPunctualLightIr[];
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
/**
|
|
207
|
+
* Original glTF-mesh-index -> number of primitives that mesh expanded into
|
|
208
|
+
* (feat-20260608 round-2). parseGltf flattens N glTF meshes with M_i
|
|
209
|
+
* primitives into sum(M_i) GltfMeshIr entries; this map preserves the M_i so
|
|
210
|
+
* downstream consumers (gltfDocToSceneAsset's `meshPrimitiveCount` param)
|
|
211
|
+
* can map a glTF mesh index back to the flat-GltfMeshIr offset range without
|
|
212
|
+
* re-parsing JSON.
|
|
213
|
+
*
|
|
214
|
+
* Optional for backwards compatibility with hand-constructed test
|
|
215
|
+
* fixtures; producers from parseGltf / parseGlb always populate it.
|
|
216
|
+
*/
|
|
217
|
+
readonly meshPrimitiveCount?: ReadonlyMap<number, number>;
|
|
218
|
+
}
|
|
219
|
+
export type ExternalLoader = (uri: string) => Promise<ArrayBuffer>;
|
|
220
|
+
type GltfParseError = GltfError | ImportError;
|
|
221
|
+
export interface GltfParseOptions {
|
|
222
|
+
readonly meshopt?: GltfBufferViewDecodeCapability;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Parse a glTF 2.0 JSON document. The `externalLoader` resolves
|
|
226
|
+
* `buffers[].uri` references that are NOT data: URIs (callers in Node
|
|
227
|
+
* land typically wrap fs.readFile; browser callers wrap fetch).
|
|
228
|
+
*
|
|
229
|
+
* Pure function modulo `externalLoader` (caller-provided I/O is the
|
|
230
|
+
* only side effect). No global state, no fs / network direct call.
|
|
231
|
+
*/
|
|
232
|
+
export declare function parseGltfForImporter(json: unknown, externalLoader: ExternalLoader, filePath: string, options?: GltfParseOptions): Promise<Result<GltfDoc, GltfParseError>>;
|
|
233
|
+
export declare function parseGltf(json: unknown, externalLoader: ExternalLoader, filePath: string, options?: GltfParseOptions): Promise<Result<GltfDoc, GltfError>>;
|
|
234
|
+
/**
|
|
235
|
+
* Parse a GLB 2.0 binary container: split into JSON + BIN chunks via
|
|
236
|
+
* `parseGlbChunks`, then run the JSON document through `parseGltf` with
|
|
237
|
+
* the BIN chunk wired in as buffer-0 backing storage.
|
|
238
|
+
*/
|
|
239
|
+
export declare function parseGlbForImporter(buffer: ArrayBuffer, filePath: string, options?: GltfParseOptions): Promise<Result<GltfDoc, GltfParseError>>;
|
|
240
|
+
export declare function parseGlb(buffer: ArrayBuffer, filePath: string, options?: GltfParseOptions): Promise<Result<GltfDoc, GltfError>>;
|
|
241
|
+
export interface GltfAssetPack {
|
|
242
|
+
readonly meta: GltfMetaJson;
|
|
243
|
+
readonly subAssets: readonly GltfSubAssetEntry[];
|
|
244
|
+
}
|
|
245
|
+
export type GltfAssetPackResult = Result<GltfAssetPack, GltfSourceKeyError>;
|
|
246
|
+
/**
|
|
247
|
+
* Project a parsed `GltfDoc` into the disk-shape `<source>.meta.json` plus
|
|
248
|
+
* the freshly minted `subAssets[]` list (UUIDv7 + reimport-reuse-meta
|
|
249
|
+
* two-stage match per plan-strategy section 2.4). Source-key conflicts are
|
|
250
|
+
* returned before GUID minting or serialization.
|
|
251
|
+
*
|
|
252
|
+
* `existingMeta` is the previously-written `<source>.meta.json` parsed back
|
|
253
|
+
* into memory (callers typically read + JSON.parse it before invoking).
|
|
254
|
+
* `undefined` triggers first-pass full-fresh GUID minting.
|
|
255
|
+
*
|
|
256
|
+
* Sub-asset ordering: meshes first, then materials, then scenes - the
|
|
257
|
+
* order is stable across reimports so AC-13 byte-identical holds when
|
|
258
|
+
* source content does not change. Stable semantic sourceKey values are
|
|
259
|
+
* assigned by the producer reuse boundary; sourceIndex remains a locator.
|
|
260
|
+
*/
|
|
261
|
+
export declare function toAssetPack(doc: GltfDoc, existingMeta: GltfMetaJson | undefined, source: string): GltfAssetPackResult;
|
|
262
|
+
export { COMPONENT_TYPE };
|
|
263
|
+
//# sourceMappingURL=parse-gltf.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-gltf.d.ts","sourceRoot":"","sources":["../src/parse-gltf.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,WAAW,EAIZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAGL,cAAc,EAEf,MAAM,+BAA+B,CAAC;AAIvC,OAAO,EAAO,KAAK,SAAS,EAAe,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EACL,KAAK,8BAA8B,EAGpC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,uBAAuB,EAAkB,MAAM,sBAAsB,CAAC;AAGpF,OAAO,EAAE,KAAK,kBAAkB,EAAa,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,iBAAiB,EAEvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,KAAK,mBAAmB,EAA0B,MAAM,gBAAgB,CAAC;AAElF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7C,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAC1D;AAED,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAA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M,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,SAAS,iBAAiB,EAAE,CAAC;CAClD;AAED,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC;AAE5E;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CACzB,GAAG,EAAE,OAAO,EACZ,YAAY,EAAE,YAAY,GAAG,SAAS,EACtC,MAAM,EAAE,MAAM,GACb,mBAAmB,CAwLrB;AAKD,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type GltfError, type Result } from './errors.js';
|
|
2
|
+
/** Maximum joints per skin (glTF spec practical limit). */
|
|
3
|
+
declare const MAX_JOINTS = 256;
|
|
4
|
+
/**
|
|
5
|
+
* Skeleton intermediate representation produced by parseSkin.
|
|
6
|
+
*
|
|
7
|
+
* Each entry corresponds to one glTF skin[] index. `jointPaths` is a
|
|
8
|
+
* parallel array to the skeleton's joints; each path is the sequence of
|
|
9
|
+
* Name-component values from the scene root to the joint node.
|
|
10
|
+
*/
|
|
11
|
+
export interface GltfSkeletonRecord {
|
|
12
|
+
/** Number of joints in this skeleton (= IBM length / 16). */
|
|
13
|
+
readonly jointCount: number;
|
|
14
|
+
/** Inverse bind matrices, Float32Array of length jointCount * 16. */
|
|
15
|
+
readonly inverseBindMatrices: Float32Array;
|
|
16
|
+
/** Per-joint Name path from scene root (parallel to joints array). */
|
|
17
|
+
readonly jointPaths: readonly string[];
|
|
18
|
+
}
|
|
19
|
+
interface SkinJson {
|
|
20
|
+
readonly name?: string;
|
|
21
|
+
readonly joints: readonly number[];
|
|
22
|
+
readonly inverseBindMatrices?: number;
|
|
23
|
+
}
|
|
24
|
+
interface NodeJson {
|
|
25
|
+
readonly name?: string;
|
|
26
|
+
readonly mesh?: number;
|
|
27
|
+
readonly children?: readonly number[];
|
|
28
|
+
readonly skin?: number;
|
|
29
|
+
}
|
|
30
|
+
interface AccessorJson {
|
|
31
|
+
readonly bufferView?: number;
|
|
32
|
+
readonly componentType: number;
|
|
33
|
+
readonly type: string;
|
|
34
|
+
readonly count: number;
|
|
35
|
+
readonly byteOffset?: number;
|
|
36
|
+
}
|
|
37
|
+
interface BufferViewJson {
|
|
38
|
+
readonly buffer: number;
|
|
39
|
+
readonly byteOffset?: number;
|
|
40
|
+
readonly byteLength: number;
|
|
41
|
+
readonly byteStride?: number;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Parse glTF skins[] array into GltfSkeletonRecord[].
|
|
45
|
+
*
|
|
46
|
+
* For each skin:
|
|
47
|
+
* 1. Decode IBM accessor (or fill identity if absent)
|
|
48
|
+
* 2. Resolve jointPaths from scene node hierarchy
|
|
49
|
+
* 3. Fail-fast on joint count > MAX_JOINTS or missing joint names
|
|
50
|
+
*/
|
|
51
|
+
export declare function parseSkin(skinsJson: readonly SkinJson[] | undefined, nodesJson: readonly NodeJson[], accessors: readonly AccessorJson[], bufferViews: readonly BufferViewJson[], buffers: readonly Uint8Array[]): Result<readonly GltfSkeletonRecord[], GltfError>;
|
|
52
|
+
/**
|
|
53
|
+
* Compute the BindPose static AABB for a skinned mesh's vertex positions.
|
|
54
|
+
*
|
|
55
|
+
* At bind pose, joint_bind = IBM^{-1}, so skinning collapses:
|
|
56
|
+
* world_pos = Sum(w_i * joint_bind_i * IBM_i * local_pos) = local_pos
|
|
57
|
+
* Therefore the BindPose AABB is simply the local position bounds.
|
|
58
|
+
*
|
|
59
|
+
* Per-frame zero cost: stored in mesh asset metadata at importer time.
|
|
60
|
+
* Dynamic AABB for animated poses is deferred to OOS-skin-dyn-bounds.
|
|
61
|
+
*
|
|
62
|
+
* Returns { min: [x,y,z], max: [x,y,z] } or undefined if positions is empty.
|
|
63
|
+
*/
|
|
64
|
+
export declare function computeBindPoseAABB(positions: Float32Array): {
|
|
65
|
+
readonly min: readonly [number, number, number];
|
|
66
|
+
readonly max: readonly [number, number, number];
|
|
67
|
+
} | undefined;
|
|
68
|
+
/** Re-export MAX_JOINTS for use by downstream modules. */
|
|
69
|
+
export { MAX_JOINTS };
|
|
70
|
+
//# sourceMappingURL=parse-skin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-skin.d.ts","sourceRoot":"","sources":["../src/parse-skin.ts"],"names":[],"mappings":"AAeA,OAAO,EAAO,KAAK,SAAS,EAAe,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAG5E,2DAA2D;AAC3D,QAAA,MAAM,UAAU,MAAM,CAAC;AAEvB;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC,6DAA6D;IAC7D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,qEAAqE;IACrE,QAAQ,CAAC,mBAAmB,EAAE,YAAY,CAAC;IAC3C,sEAAsE;IACtE,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;CACxC;AAED,UAAU,QAAQ;IAChB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;CACvC;AAED,UAAU,QAAQ;IAChB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,UAAU,YAAY;IACpB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,UAAU,cAAc;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AA6CD;;;;;;;GAOG;AACH,wBAAgB,SAAS,CACvB,SAAS,EAAE,SAAS,QAAQ,EAAE,GAAG,SAAS,EAC1C,SAAS,EAAE,SAAS,QAAQ,EAAE,EAC9B,SAAS,EAAE,SAAS,YAAY,EAAE,EAClC,WAAW,EAAE,SAAS,cAAc,EAAE,EACtC,OAAO,EAAE,SAAS,UAAU,EAAE,GAC7B,MAAM,CAAC,SAAS,kBAAkB,EAAE,EAAE,SAAS,CAAC,CAyElD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,YAAY,GACvD;IACE,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAChD,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CACjD,GACD,SAAS,CAoBZ;AAED,0DAA0D;AAC1D,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type Result } from './errors.js';
|
|
2
|
+
import { type GltfSourceKeyError } from './source-key.js';
|
|
3
|
+
import { type GltfDocItemLike, subAssetKey } from './sub-asset-key.js';
|
|
4
|
+
export type { SubAssetKey } from './sub-asset-key.js';
|
|
5
|
+
export { subAssetKey };
|
|
6
|
+
export type GltfDocItem = GltfDocItemLike;
|
|
7
|
+
/** Subset of `<source>.meta.json` fields (importer=gltf arm) touched by the reuse algorithm. */
|
|
8
|
+
export interface GltfSubAssetEntry {
|
|
9
|
+
readonly guid: string;
|
|
10
|
+
readonly sourceIndex: number;
|
|
11
|
+
readonly kind: string;
|
|
12
|
+
readonly sourceKey?: string;
|
|
13
|
+
/** Optional display name copied from the current glTF output. */
|
|
14
|
+
readonly name?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface GltfMetaJson {
|
|
17
|
+
readonly schemaVersion: 1;
|
|
18
|
+
readonly kind: 'external-asset-package';
|
|
19
|
+
readonly importer: 'gltf';
|
|
20
|
+
readonly source: string;
|
|
21
|
+
readonly subAssets: readonly GltfSubAssetEntry[];
|
|
22
|
+
readonly sourceOverrides?: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
|
|
23
|
+
readonly sourceOverrideDescriptors?: readonly import('@forgeax/engine-types').SourceOverrideDescriptor[];
|
|
24
|
+
readonly importSettings: {
|
|
25
|
+
readonly defaultSceneIndex: number;
|
|
26
|
+
readonly standardMaterialGuid?: string;
|
|
27
|
+
readonly downscaleMaxDimension?: number;
|
|
28
|
+
readonly diagnostics: {
|
|
29
|
+
readonly nodeNames: readonly string[];
|
|
30
|
+
readonly unsupportedExtensions: readonly string[];
|
|
31
|
+
readonly matrixTrsCoexistNodes: readonly number[];
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export interface ReimportReuseValue {
|
|
36
|
+
readonly subAssets: readonly GltfSubAssetEntry[];
|
|
37
|
+
}
|
|
38
|
+
export type ReimportReuseResult = Result<ReimportReuseValue, GltfSourceKeyError>;
|
|
39
|
+
/**
|
|
40
|
+
* Apply the two-stage reuse algorithm to a freshly parsed item list.
|
|
41
|
+
* Returns the new `subAssets[]` array (preserving item order), or a
|
|
42
|
+
* structured source-key conflict before any output is published.
|
|
43
|
+
*
|
|
44
|
+
* Pure function: no fs / network / global state. `AssetGuid.random()` is
|
|
45
|
+
* the only entropy source; deterministic in absence of new items.
|
|
46
|
+
*/
|
|
47
|
+
export declare function reimportReuseMeta(items: readonly GltfDocItem[], existingMeta: GltfMetaJson | undefined): ReimportReuseResult;
|
|
48
|
+
//# sourceMappingURL=reimport-reuse-meta.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reimport-reuse-meta.d.ts","sourceRoot":"","sources":["../src/reimport-reuse-meta.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAEL,KAAK,kBAAkB,EAExB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,KAAK,eAAe,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEvE,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,CAAC;AACvB,MAAM,MAAM,WAAW,GAAG,eAAe,CAAC;AAE1C,gGAAgG;AAChG,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,iEAAiE;IACjE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,wBAAwB,CAAC;IACxC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACjD,QAAQ,CAAC,eAAe,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACvF,QAAQ,CAAC,yBAAyB,CAAC,EAAE,SAAS,OAAO,uBAAuB,EAAE,wBAAwB,EAAE,CAAC;IACzG,QAAQ,CAAC,cAAc,EAAE;QACvB,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;QACnC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC;QACvC,QAAQ,CAAC,qBAAqB,CAAC,EAAE,MAAM,CAAC;QACxC,QAAQ,CAAC,WAAW,EAAE;YACpB,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;YACtC,QAAQ,CAAC,qBAAqB,EAAE,SAAS,MAAM,EAAE,CAAC;YAClD,QAAQ,CAAC,qBAAqB,EAAE,SAAS,MAAM,EAAE,CAAC;SACnD,CAAC;KACH,CAAC;CACH;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,SAAS,EAAE,SAAS,iBAAiB,EAAE,CAAC;CAClD;AAED,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC;AAEjF;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,YAAY,EAAE,YAAY,GAAG,SAAS,GACrC,mBAAmB,CAmDrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialize-meta.d.ts","sourceRoot":"","sources":["../src/serialize-meta.ts"],"names":[],"mappings":"AAqBA,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAEvD"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { GltfDocItemLike } from './sub-asset-key.js';
|
|
2
|
+
interface GltfSourceKeyErrorBase {
|
|
3
|
+
readonly expected: string;
|
|
4
|
+
readonly hint: string;
|
|
5
|
+
}
|
|
6
|
+
export interface GltfSourceKeyConflictEntry {
|
|
7
|
+
readonly kind: string;
|
|
8
|
+
readonly name: string | null;
|
|
9
|
+
readonly sourceIndex: number;
|
|
10
|
+
}
|
|
11
|
+
export type GltfSourceKeyError = (GltfSourceKeyErrorBase & {
|
|
12
|
+
readonly code: 'missing-source-key';
|
|
13
|
+
readonly detail: {
|
|
14
|
+
readonly sourceIndices: readonly number[];
|
|
15
|
+
};
|
|
16
|
+
}) | (GltfSourceKeyErrorBase & {
|
|
17
|
+
readonly code: 'duplicate-source-key' | 'ambiguous-source-key';
|
|
18
|
+
readonly detail: {
|
|
19
|
+
readonly key: string;
|
|
20
|
+
readonly sourceIndices: readonly number[];
|
|
21
|
+
readonly entries: readonly GltfSourceKeyConflictEntry[];
|
|
22
|
+
};
|
|
23
|
+
}) | (GltfSourceKeyErrorBase & {
|
|
24
|
+
readonly code: 'mesh-material-slot-topology-change';
|
|
25
|
+
readonly detail: {
|
|
26
|
+
readonly sourceIndices: readonly number[];
|
|
27
|
+
readonly previousIndices: readonly number[];
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
export type GltfSourceKeyErrorCode = GltfSourceKeyError['code'];
|
|
31
|
+
export type GltfSourceKeyResult = {
|
|
32
|
+
readonly ok: true;
|
|
33
|
+
readonly keys: readonly string[];
|
|
34
|
+
readonly conflicts: readonly [];
|
|
35
|
+
} | {
|
|
36
|
+
readonly ok: false;
|
|
37
|
+
readonly error: GltfSourceKeyError;
|
|
38
|
+
};
|
|
39
|
+
/** Derive a semantic glTF key; sourceIndex and source path are never inputs. */
|
|
40
|
+
export declare function sourceKeyForGltfOutput(item: Pick<GltfDocItemLike, 'kind' | 'name'>): string | undefined;
|
|
41
|
+
/** Require every output in a multi-output declaration to carry a unique key. */
|
|
42
|
+
export declare function deriveGltfSourceKeys(items: readonly GltfDocItemLike[]): GltfSourceKeyResult;
|
|
43
|
+
export {};
|
|
44
|
+
//# sourceMappingURL=source-key.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-key.d.ts","sourceRoot":"","sources":["../src/source-key.ts"],"names":[],"mappings":"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AAI,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,SAAS,EAAE,CAAA;CAAE,GACxF;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAE/D,gFAAgF;AAChF,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,IAAI,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,CAAC,GAC3C,MAAM,GAAG,SAAS,CAKpB;AAED,gFAAgF;AAChF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,SAAS,eAAe,EAAE,GAAG,mBAAmB,CAsD3F"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface GltfDocItemLike {
|
|
2
|
+
readonly kind: string;
|
|
3
|
+
readonly sourceIndex: number;
|
|
4
|
+
readonly name?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface SubAssetKey {
|
|
7
|
+
readonly kind: string;
|
|
8
|
+
readonly name: string | null;
|
|
9
|
+
readonly indexFallback: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function subAssetKey(item: GltfDocItemLike): SubAssetKey;
|
|
12
|
+
//# sourceMappingURL=sub-asset-key.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sub-asset-key.d.ts","sourceRoot":"","sources":["../src/sub-asset-key.ts"],"names":[],"mappings":"AAiBA,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC;AA2BD,wBAAgB,WAAW,CAAC,IAAI,EAAE,eAAe,GAAG,WAAW,CAM9D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to-asset-pack.d.ts","sourceRoot":"","sources":["../src/to-asset-pack.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** glTF VEC3 literal accepted by node.translation / node.scale. */
|
|
2
|
+
export type Vec3Tuple = readonly [number, number, number];
|
|
3
|
+
/** glTF VEC4 quaternion literal accepted by node.rotation. */
|
|
4
|
+
export type Vec4Tuple = readonly [number, number, number, number];
|
|
5
|
+
/** Minimal node JSON shape touched by the decomposer. */
|
|
6
|
+
export interface NodeTransformJson {
|
|
7
|
+
readonly matrix?: readonly number[];
|
|
8
|
+
readonly translation?: readonly number[];
|
|
9
|
+
readonly rotation?: readonly number[];
|
|
10
|
+
readonly scale?: readonly number[];
|
|
11
|
+
}
|
|
12
|
+
/** Mutable diagnostics accumulator (writes to .matrixTrsCoexistNodes only). */
|
|
13
|
+
export interface TransformDiagnostics {
|
|
14
|
+
matrixTrsCoexistNodes: number[];
|
|
15
|
+
}
|
|
16
|
+
export interface DecomposedTransform {
|
|
17
|
+
readonly translation: Vec3Tuple;
|
|
18
|
+
readonly rotation: Vec4Tuple;
|
|
19
|
+
readonly scale: Vec3Tuple;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Decompose a glTF node's transform into a POD readonly TRS triple.
|
|
23
|
+
*
|
|
24
|
+
* Decision tree:
|
|
25
|
+
* 1. matrix present -> mat4.decompose 3-arg in-place; if
|
|
26
|
+
* any TRS field is also present,
|
|
27
|
+
* stderr warn + push nodeIndex into
|
|
28
|
+
* diagnostics.matrixTrsCoexistNodes.
|
|
29
|
+
* 2. only TRS fields present -> use them verbatim (defaults filled).
|
|
30
|
+
* 3. nothing present -> identity (0/0/0, 0/0/0/1, 1/1/1).
|
|
31
|
+
*
|
|
32
|
+
* Return type is `readonly` POD tuple, deliberately not Vec3/Quat from
|
|
33
|
+
* @forgeax/engine-math, so the importer's IR stays brand-free
|
|
34
|
+
* (plan-strategy decision section 2.7 / OQ-2).
|
|
35
|
+
*/
|
|
36
|
+
export declare function decomposeNodeTransform(node: NodeTransformJson, nodeIndex: number, diagnostics: TransformDiagnostics): DecomposedTransform;
|
|
37
|
+
//# sourceMappingURL=transform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../src/transform.ts"],"names":[],"mappings":"AAmBA,mEAAmE;AACnE,MAAM,MAAM,SAAS,GAAG,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAC1D,8DAA8D;AAC9D,MAAM,MAAM,SAAS,GAAG,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAElE,yDAAyD;AACzD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC;AAED,+EAA+E;AAC/E,MAAM,WAAW,oBAAoB;IACnC,qBAAqB,EAAE,MAAM,EAAE,CAAC;CACjC;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,WAAW,EAAE,SAAS,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;CAC3B;AAuBD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,iBAAiB,EACvB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,oBAAoB,GAChC,mBAAmB,CAiCrB"}
|