Derived from the cocosair-gltf skill and its canonical docs/source pointers; reorganized on 2026-10-11. Source annotations below identify repository inputs, not files guaranteed to ship to npm consumers.
Contracts
- Two entry points, one pipeline.
loadAsync(url)(src/air/assets/gltf/loader.ts:108-113) resolves the URL againstdocument.baseURI(:39-41), derivesextfrom/\.(gltf|glb)$/ion the query-stripped path and falls back to.glbwhen there is no suffix (:36-38,:112), then hands off toassetManager.loadRemotewith the resolved options under thegltfkey.parseAsync(:115-184) is the same work in memory with no cache and an abortsignal. It validates every accessor up front (:136) before any image decode or GPU allocation, snapshots handler data atresolveData(:138) beforereleaseDecodedData()drops the buffers (:181), and on any failure runscontext.dispose(); asset.destroy(); throw(:183) so nothing half-built survives. Importing the glTF module registers all of this automatically:src/air/assets/gltf/index.ts:25-26callsregisterGLTFLoader()at import time, and that function is idempotent through a module flag (src/air/assets/gltf/loader.ts:187-189). For both.gltfand.glbit installs afetchdownloader honoringoptions.headerandwithCredentials(:191-196), a parser that runsdecodeContainerpurely as validation (:197-199), and a factory callingparseAsyncwith a base ofnew URL('.', absoluteURL(url)).href- orundefinedfordata:andblob:URLs (:200-202). On factory failure it evicts${url}@nativefrom thefilesandparsedcaches (:205) so a transient error is not cached permanently. CallregisterGLTFLoader()yourself only when importing the loader module directly. - Decoders ship beside the bundle, never inside it.
build/gltf-decoders/holds draco3d 1.5.7, meshoptimizer 1.2.0 and the three r168 Basis files with byte counts and sha256 inbuild/gltf-decoders/MANIFEST.md;tools/verify/decoder-audit.cjsfails the build if the bundle contains WASM magic bytes or a decoder file name. The only application-side entry is the three setters (src/air/assets/gltf/loader.ts:82-90), each acceptingnullto clear. With nothing injected and a required compression extension in use, the asset is rejected withGLTF_DECODER_MISSING(src/air/assets/gltf/extensions/geometry/draco.ts:75-77). The shipped Draco entry is Node/CommonJS by deliberate ruling, not oversight: browser Draco decode requires an app-supplied browser build (decoders.md). getExtensionSupport()reports a live value, not a build constant. It builds a throwaway probe context (src/air/assets/gltf/loader.ts:95-106) and computeshandler.support?.() ?? { name, status: 'supported' }, so a handler with nosupport()-KHR_materials_unlitandKHR_texture_transform- is unconditionallysupported(:100). The same loader reportsdecoder-requiredbefore injection andsupportedafter;examples/gltf-meshopt/src/main.ts:94-97proves the flip by asserting the handler-levelsupport?.().status === 'supported'once the shipped meshopt decoder is wired in.KNOWN_UNIMPLEMENTEDis an empty array (:49-51), so the returned list is exactly the 21 handler entries in registration order. Of the five statuses onlysupportedanddecoder-requiredcarry browser evidence;device-dependentis reachable from foursupport()implementations behind five extension names but appears in no tracked record, andfallbackandunsupportedare emitted by nothing shipped (extensions-matrix.md).- Required and optional extensions behave differently.
validateRequired(src/air/assets/gltf/extension-registry.ts:104-124) throws for an unknown or non-supportedextension listed inextensionsRequired, mappingdecoder-requiredtoGLTF_DECODER_MISSING,device-dependenttoGLTF_DEVICE_UNSUPPORTEDandfallbacktoGLTF_EXTENSION_UNSUPPORTED(:55-59,:118-121); the same condition on an optional extension only warns and continues on the core fallback (:122). An unknown optional extension is fully silent -continuewith no warning and no report entry (:114). GLTFAssetexposes five read-only collections, not nine.meshes,materials,textures,skeletonsandanimationsare getters over the@internalmutable builderowned(src/air/assets/gltf/asset.ts:52-58);sceneNames,document(the original JSON, including camera and light descriptions and original node names) andwarningsare separate members (:59-62), andimagesplusmeshMaterialsare@internal(:63-64).- Instantiating shares assets and isolates state.
instantiate(sceneIndex = json.scene ?? 0)(src/air/assets/gltf/asset.ts:76) computes avisibleset by child walk and anincludedset that additionally pulls in every ancestor of every skin joint (:84-89), rebuilds each clip keeping only tracks whose hierarchy root is included and caches the result per scene index (:90-101), then builds fresh nodes. Skin nodes get aSkinnedMeshRendererwithsetUseBakedAnimation(false),skinningRoot = rootand the shared skeleton (:139-141) after JOINTS_0 values are range-checked (:135-138); everything else gets aMeshRenderer(:143). The root also carriesGLTFWinding(:126), a nativeAnimationwithplayOnLoad = false, and the privateGLTFAnimationPolicyat@executionOrder(100)- one past nativeAnimation's 99 - whoseonLoadreapplies per-instance wrap modes that the native rebuild would otherwise drop (:25-38,:159-163). - Release is deferred by design.
instantiatetakes oneaddRefand one instance count (src/air/assets/gltf/asset.ts:164) and hooksroot.once(Node.EventType.NODE_DESTROYED, ...)which decrements in a microtask, because that event precedes child and component teardown (:168-175).destroy()setsdestroyRequested, deregisters the uuid fromassets, and callsreleaseResources()immediately only wheninstances === 0(:198-204); otherwise the last instance's hook does it.releaseResources()destroys theSetunion of materials, meshes, skeletons, animations, textures, images and every cached scene clip exactly once, thensuper.destroy()(:205-212). AfterdestroyRequested,instantiate()rejects withasset is destroyedwhile live instances keep running (:77). GLTFInstanceis a plain object, not a class. It is the literal returned atsrc/air/assets/gltf/asset.ts:176withroot,animations,setAnimationLoopanddisposeas closure properties, so no prototype, static, export-wrapper or namespace mechanism can bind to it - which is why neither method has any instrumentation evidence and their proof is the passing examples that call them (loader-api.md).- Only some failures are
GLTFError.GLTFErrorCodeis the closed five-member union atsrc/air/assets/gltf/diagnostics.ts:2-3; the class setsname = 'GLTFError'and prefixes the message with[glTF](:6-11), socodeis the only reliable discriminator - the registry throws plainErrors with the same prefix for a duplicate handler name (src/air/assets/gltf/extension-registry.ts:86) and a missing dependency (:93),schema.tscheck/item/integerthrow plain prefix-onlyErrors for every structural rule (src/air/assets/gltf/schema.ts:55-65), a cancelled load throwsDOMException('glTF load aborted', 'AbortError')from bothsrc/air/assets/gltf/loader.ts:117andsrc/air/assets/gltf/parser-context.ts:84-85, andsetAnimationLoopthrows aTypeErrortaggedAIR_E_GLTF_ANIMATION_OPTIONS(src/air/assets/gltf/asset.ts:177-179) which noinstanceof GLTFErrorcheck will ever see. - Warnings are a second channel.
context.warnboth records andconsole.warns with the[glTF]prefix (src/air/assets/gltf/parser-context.ts:90), andasset.warningsexposes the list afterwards. Cameras are kept as descriptions rather than instantiated, andKHR_lights_punctualinnerConeAngleis retained as metadata with no engine plateau input - both surface as warnings (src/air/assets/gltf/nodes.ts:16,src/air/assets/gltf/extensions/scene/lights.ts:117). - Progress is advisory and uneven.
containerandobjectsare always(1, 1);decodeandtexturesreport the accessor and texture counts, soloaded === total === 0means an empty document, not a stall;dependenciesis emitted only from insideloadBuffersand never carries aurl(src/air/assets/gltf/parser-context.ts:159,:168), whileurlis populated only whenparseAsyncgot a string (src/air/assets/gltf/loader.ts:120-121). Every emission sits inside theparseAsynctry block, so a throwingonProgressfails the load through the normal teardown (diagnostics.md). - Keep the three capability layers apart.
GLTFLoader,GLTFAsset,GLTFError,GLTFExtensionRegistry,registerGLTFLoader,configureGLTFLoaderDefaults,createDracoDecoder,createMeshoptDecoder,createKTX2Transcoder,isMeshoptAvailable,isKTX2Available,detectImageMime,SUPPORTED_IMAGE_MIMES,KTX2_RAW_MIME, the three geometry factories and the four extension-name constants all resolve by symbol in the singleexport { ... }block ofbuild/cocosair.module.js(currently:161574);MAX_KTX2_DIMENSION,GLTFParserContextandgltfPhysicalEffectdo not.GLTFParserContextdoes appear 15 times inbuild/cocosair.module.d.tsbut only as the mangled__private._air_assets_gltf_parser_context__GLTFParserContext(:72760), so a TypeScript consumer writing a custom factory cannot name its context parameter and must useParameters<GLTFExtensionFactory>[0]. - Browser evidence, stated plainly. At candidate fingerprint
2f089f6ce25eaccd(docs/evidence/examples-verified.json, file-levelmeasuredAt2026-10-04T05:52:32.537Z), 18 gltf-touching ids areresult: PASSand 17 of them carry gltf bindings. Strong:GLTFLoader(scene-ready x10),parseAsync(asset-loaded x10, visible-frame x3),instantiate(asset-loaded x5, visible-frame x2, node-exists x2, scene-ready x2, resource-released x1),destroy(resource-released x10). Real meshopt decode is browser-proven bygltf-meshopt(visible-frame litRatio=0.1606,resource-released held=3 leaked=0,assets/meshopt-khr.glb=1728Bfetched). Real Draco decode and real KTX2 transcode are proven nowhere:gltf-dracohas novisible-framevalidator because what it proves is the refusal path, and no example imports the Basis transcoder.GLTFInstance.setAnimationLoop,GLTFInstance.dispose,configureGLTFLoaderDefaultsandregisterGLTFLoaderhave zero bindings.