zhuda-laya-engine 0.0.0-stage → 2.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.
- package/AGENTS.md +236 -0
- package/CHANGELOG.md +431 -0
- package/LICENSE +41 -0
- package/README.md +247 -2
- package/assets/branding/layaair-tribute-mark.svg +5 -0
- package/assets/branding/zhuda-layaair-mark.svg +34 -0
- package/assets/prefabs/CoinFountainVfx.lh +197 -0
- package/assets/prefabs/ConfirmActionButton.lh +87 -0
- package/assets/prefabs/LevelUpAuraVfx.lh +136 -0
- package/assets/prefabs/MineExplosionParticle.lh +352 -0
- package/assets/prefabs/NineSliceDialogFrame.lh +171 -0
- package/assets/prefabs/SwordSlashTrailVfx.lh +117 -0
- package/assets/prefabs/TacticalHudBar.lh +134 -0
- package/assets/prefabs/TelemetryDashboard.lh +87 -0
- package/assets/prefabs/UnityCrystalGuardian.lh +144 -0
- package/assets/prefabs/ZhudaSpine42Mascot.lh +183 -0
- package/assets/scenes/MinesweeperStage.ls +1180 -0
- package/dist/asset-calibration-report.json +969 -0
- package/dist/build-manifest.json +254 -0
- package/dist/sdk/zhuda-laya-csg.cjs +710 -0
- package/dist/sdk/zhuda-laya-csg.esm.js +683 -0
- package/dist/sdk/zhuda-laya-csg.min.cjs +7 -0
- package/dist/sdk/zhuda-laya-csg.min.esm.js +7 -0
- package/dist/sdk/zhuda-laya-demo.cjs +5990 -0
- package/dist/sdk/zhuda-laya-demo.esm.js +5956 -0
- package/dist/sdk/zhuda-laya-demo.min.cjs +12 -0
- package/dist/sdk/zhuda-laya-demo.min.esm.js +12 -0
- package/dist/sdk/zhuda-laya-engine.cjs +52628 -0
- package/dist/sdk/zhuda-laya-engine.esm.js +51848 -0
- package/dist/sdk/zhuda-laya-engine.min.cjs +2710 -0
- package/dist/sdk/zhuda-laya-engine.min.esm.js +2710 -0
- package/docs/3d-acceptance.md +47 -0
- package/docs/3d-integration.md +190 -0
- package/docs/README.md +112 -0
- package/docs/SUPPORT.md +21 -0
- package/docs/agent-development.md +219 -0
- package/docs/animation-control.md +213 -0
- package/docs/asset-loading.md +97 -0
- package/docs/assets/reference-games.jpg +0 -0
- package/docs/assets/solana-qr.png +0 -0
- package/docs/assets/sponsor-pass.svg +32 -0
- package/docs/audio.md +319 -0
- package/docs/backend-delivery.md +218 -0
- package/docs/basis-textures.md +94 -0
- package/docs/browser-sdk-releases.json +204 -0
- package/docs/browser-sdk.md +187 -0
- package/docs/cinematics.md +267 -0
- package/docs/cloth.md +280 -0
- package/docs/combat-runtime.md +82 -0
- package/docs/consumer-route.md +169 -0
- package/docs/consumer-tooling.md +518 -0
- package/docs/crowd-runtime.md +195 -0
- package/docs/developer-tooling.md +191 -0
- package/docs/film-scenes.md +1504 -0
- package/docs/filmic-rendering.md +743 -0
- package/docs/flythrough.md +89 -0
- package/docs/gpu-depth.md +207 -0
- package/docs/grass.md +127 -0
- package/docs/hdr-environment.md +76 -0
- package/docs/instanced-meshes.md +137 -0
- package/docs/layout-and-media.md +37 -0
- package/docs/layout-wireframe.md +80 -0
- package/docs/lighting-depth.md +185 -0
- package/docs/minigame-packaging.md +79 -0
- package/docs/model-editor.md +66 -0
- package/docs/model-lod.md +122 -0
- package/docs/model-pipeline.md +74 -0
- package/docs/model-showcase.md +365 -0
- package/docs/overview.md +183 -0
- package/docs/plans/README.md +133 -0
- package/docs/plans/TASK-TEMPLATE.md +64 -0
- package/docs/plans/TASK-spine38-isolated-topology-20261106.md +89 -0
- package/docs/plans/TEMPLATE.md +44 -0
- package/docs/plans/VERIFICATION-TEMPLATE.md +45 -0
- package/docs/plans/asset-packaging.md +140 -0
- package/docs/plans/cinematic-production/task.md +97 -0
- package/docs/plans/cinematic-production/verification.md +49 -0
- package/docs/plans/consumer-delivery-followups.md +129 -0
- package/docs/plans/desktop-and-agent-gates/hardening-task.md +85 -0
- package/docs/plans/desktop-and-agent-gates/hardening-verification.md +109 -0
- package/docs/plans/desktop-and-agent-gates/task.md +94 -0
- package/docs/plans/desktop-and-agent-gates/verification.md +60 -0
- package/docs/plans/prefab-toolchain.md +73 -0
- package/docs/plans/preview-runtime-hardening.md +68 -0
- package/docs/platform-adapters.md +113 -0
- package/docs/post-quality.md +242 -0
- package/docs/prefab-editor.md +194 -0
- package/docs/prefab-library.md +94 -0
- package/docs/prefab-workflow.md +75 -0
- package/docs/procedural-assets.md +463 -0
- package/docs/procedural-prefabs.md +133 -0
- package/docs/quality-route.md +386 -0
- package/docs/release-policy.md +79 -0
- package/docs/routes/README.md +180 -0
- package/docs/routes/TEMPLATE.md +54 -0
- package/docs/routes/action-adventure-3d-minigame.md +238 -0
- package/docs/routes/apocalypse-survival-3d.md +219 -0
- package/docs/routes/aqua-freeze-2d-minigame.md +183 -0
- package/docs/routes/astral-minimal-film-look.md +141 -0
- package/docs/routes/cascade-slot.md +93 -0
- package/docs/routes/clip-free-garments.md +229 -0
- package/docs/routes/drop-merge-2d-minigame.md +200 -0
- package/docs/routes/dungeon-line-slot.md +87 -0
- package/docs/routes/film-as-data.md +131 -0
- package/docs/routes/film-fight-that-lands.md +198 -0
- package/docs/routes/film-ink-lines.md +120 -0
- package/docs/routes/floating-island.md +229 -0
- package/docs/routes/game-2d.md +168 -0
- package/docs/routes/game-rules-first.md +89 -0
- package/docs/routes/game-to-prefabs.md +249 -0
- package/docs/routes/go-game-server.md +95 -0
- package/docs/routes/good-looking-3d-scene.md +99 -0
- package/docs/routes/high-quality-character.md +263 -0
- package/docs/routes/humanoid-from-shapes.md +97 -0
- package/docs/routes/hunting-action-3d.md +76 -0
- package/docs/routes/idle-gacha-2d.md +67 -0
- package/docs/routes/interactive-film-viewer.md +141 -0
- package/docs/routes/isometric-mystery-2d.md +217 -0
- package/docs/routes/key-art-to-animated-title.md +132 -0
- package/docs/routes/laya-ide-project-cli-web.md +125 -0
- package/docs/routes/layered-cloth-on-body.md +240 -0
- package/docs/routes/low-poly-character-from-shapes.md +475 -0
- package/docs/routes/match-three-2d.md +64 -0
- package/docs/routes/merge-2d.md +59 -0
- package/docs/routes/mini-game-build.md +80 -0
- package/docs/routes/mobile-always-landscape.md +149 -0
- package/docs/routes/mobile-web-fullscreen.md +255 -0
- package/docs/routes/model-from-dcc.md +106 -0
- package/docs/routes/new-game-project.md +100 -0
- package/docs/routes/onboarding-tutorial-2d.md +54 -0
- package/docs/routes/online-lockstep-match.md +473 -0
- package/docs/routes/outdoor-landscape.md +134 -0
- package/docs/routes/outfit-swap-3d.md +144 -0
- package/docs/routes/papercraft-diorama.md +186 -0
- package/docs/routes/platform-fighter-2d.md +235 -0
- package/docs/routes/platformer-2d.md +69 -0
- package/docs/routes/pole-rescue-arcade-3d.md +198 -0
- package/docs/routes/pose-atlas-motion.md +188 -0
- package/docs/routes/prototype-to-center.md +162 -0
- package/docs/routes/raft-brawl-3d-minigame.md +205 -0
- package/docs/routes/rhythm-2d.md +82 -0
- package/docs/routes/rigged-phone-character.md +120 -0
- package/docs/routes/screen-fit-game-box.md +127 -0
- package/docs/routes/shared-islands.md +195 -0
- package/docs/routes/side-view-duel.md +266 -0
- package/docs/routes/single-html-page.md +83 -0
- package/docs/routes/smooth-character-motion.md +162 -0
- package/docs/routes/spine-character.md +175 -0
- package/docs/routes/story-counting-2d.md +219 -0
- package/docs/routes/survivors-2d.md +60 -0
- package/docs/routes/third-person-town-3d.md +240 -0
- package/docs/routes/tower-defence-3d.md +67 -0
- package/docs/routes/ui-test-by-probe.md +219 -0
- package/docs/routes/underwater.md +138 -0
- package/docs/routes/visual-content-prefab.md +101 -0
- package/docs/runtime-hardening.md +108 -0
- package/docs/shader-warm-up.md +125 -0
- package/docs/spring-bones.md +79 -0
- package/docs/stylized-shading.md +171 -0
- package/docs/terrain-shader.md +130 -0
- package/docs/vrm.md +128 -0
- package/docs/walking.md +97 -0
- package/docs/webgpu.md +225 -0
- package/docs/white-label-themes.md +212 -0
- package/docs/zh-CN/README.md +130 -0
- package/examples/browser-sdk/2d-webgpu.html +46 -0
- package/examples/browser-sdk/2d.html +46 -0
- package/examples/browser-sdk/3d-gltf-webgpu.html +50 -0
- package/examples/browser-sdk/3d-gltf.html +50 -0
- package/examples/browser-sdk/3d-webgpu.html +46 -0
- package/examples/browser-sdk/3d.html +46 -0
- package/examples/cinematic-capture/Main.ts +294 -0
- package/examples/cinematic-capture/README.md +27 -0
- package/examples/model-inspector/README.md +15 -0
- package/examples/model-inspector/asset.gltf +158 -0
- package/examples/windows-webgpu/README.md +57 -0
- package/examples/windows-webgpu/bundle.mjs +122 -0
- package/examples/windows-webgpu/main.mjs +302 -0
- package/examples/windows-webgpu/package-lock.json +2353 -0
- package/examples/windows-webgpu/package.json +40 -0
- package/examples/windows-webgpu/squirrel.mjs +66 -0
- package/package.json +259 -4
- package/packages/ci-gate/export-film.mjs +347 -0
- package/packages/ci-gate/verify-sequence.mjs +285 -0
- package/packages/compiler/agent-contract.mjs +545 -0
- package/packages/compiler/ast-scanner.mjs +254 -0
- package/packages/compiler/backend-loader.mjs +62 -0
- package/packages/compiler/branding-assets.mjs +32 -0
- package/packages/compiler/branding.mjs +324 -0
- package/packages/compiler/browser-auto-example.mjs +31 -0
- package/packages/compiler/browser-model-example.mjs +53 -0
- package/packages/compiler/browser-process.mjs +344 -0
- package/packages/compiler/browser-sdk-example.mjs +50 -0
- package/packages/compiler/browser-sdk.mjs +342 -0
- package/packages/compiler/chrome-host.mjs +196 -0
- package/packages/compiler/cli.mjs +22 -0
- package/packages/compiler/compiler-runtime.mjs +41 -0
- package/packages/compiler/consumer-accept.mjs +89 -0
- package/packages/compiler/consumer-build.mjs +641 -0
- package/packages/compiler/consumer-guards.mjs +422 -0
- package/packages/compiler/consumer-publication.mjs +56 -0
- package/packages/compiler/consumer-scripts.mjs +134 -0
- package/packages/compiler/consumer-starter-2d.mjs +54 -0
- package/packages/compiler/consumer-starter-minigame.mjs +30 -0
- package/packages/compiler/editor-http.mjs +210 -0
- package/packages/compiler/editor-request.ts +12 -0
- package/packages/compiler/film-host-client.ts +249 -0
- package/packages/compiler/flythrough-file.mjs +144 -0
- package/packages/compiler/json-locate.mjs +85 -0
- package/packages/compiler/layout-contract.mjs +472 -0
- package/packages/compiler/minigame-bootstrap.mjs +24 -0
- package/packages/compiler/minigame-bridge.mjs +66 -0
- package/packages/compiler/minigame-guards.mjs +107 -0
- package/packages/compiler/minigame-toolchain.mjs +241 -0
- package/packages/compiler/model-crown.mjs +173 -0
- package/packages/compiler/model-editor-client.ts +809 -0
- package/packages/compiler/model-editor.mjs +242 -0
- package/packages/compiler/model-lod.mjs +547 -0
- package/packages/compiler/prefab-check.mjs +288 -0
- package/packages/compiler/prefab-checks.mjs +74 -0
- package/packages/compiler/prefab-dependencies.mjs +102 -0
- package/packages/compiler/prefab-editor-client.ts +950 -0
- package/packages/compiler/prefab-editor-preview.ts +89 -0
- package/packages/compiler/prefab-editor-server.mjs +585 -0
- package/packages/compiler/prefab-editor.mjs +43 -0
- package/packages/compiler/prefab-environment.mjs +107 -0
- package/packages/compiler/prefab-lifecycle.mjs +60 -0
- package/packages/compiler/prefab-preview.mjs +159 -0
- package/packages/compiler/prefab-watch.mjs +459 -0
- package/packages/compiler/runtime3d-types.mjs +91 -0
- package/packages/compiler/stage-probe.mjs +557 -0
- package/packages/compiler/visual-asset-audit.mjs +609 -0
- package/packages/compiler/visual-contract-audit.mjs +173 -0
- package/packages/compiler/webgpu-loader.mjs +153 -0
- package/packages/compiler/zhuda-build.mjs +714 -0
- package/packages/compiler/zhuda-doctor.mjs +186 -0
- package/packages/compiler/zhuda-init.mjs +353 -0
- package/packages/compiler/zhuda-layout.mjs +163 -0
- package/packages/compiler/zhuda-minigame.mjs +636 -0
- package/packages/core/BenchmarkEngine.ts +2 -0
- package/packages/core/BitmapFontContract.ts +159 -0
- package/packages/core/DeclarativeSDK.ts +686 -0
- package/packages/core/IframeSoundAdapter.ts +1824 -0
- package/packages/core/NoSleepAdapter.ts +302 -0
- package/packages/core/PixelCalibrationEngine.ts +602 -0
- package/packages/core/Prefab.ts +314 -0
- package/packages/core/RealmGuards.ts +111 -0
- package/packages/core/ResponsiveLayout.ts +149 -0
- package/packages/core/RuntimeGuards.ts +261 -0
- package/packages/core/SpineCharacter.ts +243 -0
- package/packages/core/SpineVisualContract.ts +238 -0
- package/packages/core/SplashSignal.ts +72 -0
- package/packages/core/StaticAssetPipeline.ts +3 -0
- package/packages/core/TopologyGraph.ts +693 -0
- package/packages/core/UnityBridgePipeline.ts +2 -0
- package/packages/core/VideoSurface.ts +75 -0
- package/packages/core/ViewportMatrixEngine.ts +237 -0
- package/packages/core/VisualFocusContract.ts +76 -0
- package/packages/core/VisualMigrationPipeline.ts +245 -0
- package/packages/core/WebViewSurface.ts +116 -0
- package/packages/core/audio/OfflineMix.ts +186 -0
- package/packages/core/audio/Spatial.ts +312 -0
- package/packages/core/audio/StreamVoice.ts +161 -0
- package/packages/core/csg/Bsp.ts +310 -0
- package/packages/core/csg/index.ts +589 -0
- package/packages/core/effects/Effect2D.ts +286 -0
- package/packages/core/effects/Effect3D.ts +213 -0
- package/packages/core/effects/EffectBudget.ts +695 -0
- package/packages/core/effects/EffectDirector.ts +254 -0
- package/packages/core/effects/EffectPresets.ts +843 -0
- package/packages/core/effects/EffectPresets2D.ts +1011 -0
- package/packages/core/effects/EffectSprites.ts +143 -0
- package/packages/core/effects/ParticleEventLink.ts +53 -0
- package/packages/core/effects/README.md +108 -0
- package/packages/core/effects/VfxMaterial.ts +253 -0
- package/packages/core/film/BakeKey.ts +21 -0
- package/packages/core/film/ColorValues.ts +44 -0
- package/packages/core/film/FilmLint.ts +353 -0
- package/packages/core/film/FilmPrefab.ts +82 -0
- package/packages/core/film/FilmReview.ts +84 -0
- package/packages/core/film/FilmScene.ts +3442 -0
- package/packages/core/film/FilmStage.ts +2148 -0
- package/packages/core/film/Flythrough.ts +169 -0
- package/packages/core/film/FlythroughReport.ts +326 -0
- package/packages/core/film/FrameMetrics.ts +167 -0
- package/packages/core/film/LiveLook.ts +242 -0
- package/packages/core/film/LookQuality.ts +94 -0
- package/packages/core/film/Projection.ts +74 -0
- package/packages/core/film/SceneLook.ts +363 -0
- package/packages/core/film/index.ts +12 -0
- package/packages/core/index.ts +48 -0
- package/packages/core/particles/EffectEnvelope.ts +52 -0
- package/packages/core/particles/LayaParticleRenderer.ts +182 -0
- package/packages/core/particles/LayaParticleRenderer3D.ts +218 -0
- package/packages/core/particles/ParticleExtras.ts +163 -0
- package/packages/core/particles/ParticleMesh3D.ts +156 -0
- package/packages/core/particles/ParticleSystem.ts +324 -0
- package/packages/core/particles/ParticleSystem3D.ts +411 -0
- package/packages/core/particles/ParticleTypes.ts +230 -0
- package/packages/core/particles/ParticleTypes3D.ts +115 -0
- package/packages/core/particles/README.md +181 -0
- package/packages/core/particles/RibbonPath3D.ts +234 -0
- package/packages/core/particles/RibbonTrail.ts +145 -0
- package/packages/core/particles/RibbonTrail3D.ts +166 -0
- package/packages/core/particles/index.ts +12 -0
- package/packages/core/prefabs/PrefabLibrary.ts +692 -0
- package/packages/core/prefabs/PrefabTree3D.ts +291 -0
- package/packages/core/prefabs/index.ts +10 -0
- package/packages/core/procedural/Geometry.ts +1871 -0
- package/packages/core/procedural/Hand.ts +1510 -0
- package/packages/core/procedural/Isosurface.ts +1035 -0
- package/packages/core/procedural/ModuleHarness.ts +180 -0
- package/packages/core/procedural/Noise.ts +123 -0
- package/packages/core/procedural/PhotoMaterial.ts +283 -0
- package/packages/core/procedural/ProceduralAssetProvider.ts +105 -0
- package/packages/core/procedural/ProceduralMaterial.ts +184 -0
- package/packages/core/procedural/PropFactory.ts +307 -0
- package/packages/core/procedural/Random.ts +70 -0
- package/packages/core/procedural/SynthAudio.ts +221 -0
- package/packages/core/procedural/TerrainMesh.ts +207 -0
- package/packages/core/procedural/TextureRecipe.ts +464 -0
- package/packages/core/procedural/TriplanarMaterial.ts +169 -0
- package/packages/core/procedural/Variation.ts +94 -0
- package/packages/core/procedural/index.ts +15 -0
- package/packages/core/runtime3d/ActionFrames.ts +245 -0
- package/packages/core/runtime3d/AnimationBlend.ts +282 -0
- package/packages/core/runtime3d/AnimationBlendMath.ts +98 -0
- package/packages/core/runtime3d/AssetProvider.ts +775 -0
- package/packages/core/runtime3d/AssetShowcase.ts +190 -0
- package/packages/core/runtime3d/Assets.ts +801 -0
- package/packages/core/runtime3d/AsyncDeadline.ts +53 -0
- package/packages/core/runtime3d/AsyncOperation.ts +39 -0
- package/packages/core/runtime3d/BackendChoice.ts +359 -0
- package/packages/core/runtime3d/BakedCrowd.ts +575 -0
- package/packages/core/runtime3d/BasisTexture.ts +657 -0
- package/packages/core/runtime3d/CameraCollision.ts +69 -0
- package/packages/core/runtime3d/CameraEffects.ts +752 -0
- package/packages/core/runtime3d/CameraRig.ts +70 -0
- package/packages/core/runtime3d/CharacterController.ts +272 -0
- package/packages/core/runtime3d/CinematicCapture.ts +457 -0
- package/packages/core/runtime3d/Clocks.ts +724 -0
- package/packages/core/runtime3d/Cloth.ts +183 -0
- package/packages/core/runtime3d/Clouds.ts +462 -0
- package/packages/core/runtime3d/ColorLut.ts +351 -0
- package/packages/core/runtime3d/CombatQueries.ts +240 -0
- package/packages/core/runtime3d/ComputePass.ts +582 -0
- package/packages/core/runtime3d/CrowdPresentation.ts +368 -0
- package/packages/core/runtime3d/DebugDraw.ts +567 -0
- package/packages/core/runtime3d/DebugStats.ts +35 -0
- package/packages/core/runtime3d/Decals.ts +309 -0
- package/packages/core/runtime3d/DensityVolume.ts +238 -0
- package/packages/core/runtime3d/DistanceBricks.ts +349 -0
- package/packages/core/runtime3d/Dither.ts +199 -0
- package/packages/core/runtime3d/DrawWarmUp.ts +217 -0
- package/packages/core/runtime3d/EdgeSmoothing.ts +108 -0
- package/packages/core/runtime3d/EnvironmentProbe.ts +656 -0
- package/packages/core/runtime3d/Filmic.ts +973 -0
- package/packages/core/runtime3d/Foliage.ts +367 -0
- package/packages/core/runtime3d/GltfIntake.ts +914 -0
- package/packages/core/runtime3d/GltfSecondUv.ts +153 -0
- package/packages/core/runtime3d/GraphicsGuard.ts +171 -0
- package/packages/core/runtime3d/Grass.ts +1080 -0
- package/packages/core/runtime3d/GroundTruthAO.ts +360 -0
- package/packages/core/runtime3d/HalfFloat.ts +44 -0
- package/packages/core/runtime3d/HdrEnvironment.ts +588 -0
- package/packages/core/runtime3d/Ik.ts +392 -0
- package/packages/core/runtime3d/InputBuffer.ts +165 -0
- package/packages/core/runtime3d/InstancedMesh.ts +460 -0
- package/packages/core/runtime3d/Laya342Adapters.ts +1095 -0
- package/packages/core/runtime3d/Laya342GltfAdapter.ts +751 -0
- package/packages/core/runtime3d/LensFinish.ts +153 -0
- package/packages/core/runtime3d/LensFlare.ts +490 -0
- package/packages/core/runtime3d/LightFog.ts +1008 -0
- package/packages/core/runtime3d/LightingDepth.ts +544 -0
- package/packages/core/runtime3d/Lightmap.ts +238 -0
- package/packages/core/runtime3d/Math3D.ts +84 -0
- package/packages/core/runtime3d/MeshQuery.ts +547 -0
- package/packages/core/runtime3d/MeshoptModelDecoder.ts +354 -0
- package/packages/core/runtime3d/MiniGameSplash.ts +70 -0
- package/packages/core/runtime3d/ModelAnimationSampler.ts +97 -0
- package/packages/core/runtime3d/ModelCompatibility.ts +890 -0
- package/packages/core/runtime3d/ModelDecoder.ts +294 -0
- package/packages/core/runtime3d/ModelInspector.ts +226 -0
- package/packages/core/runtime3d/ModelLod.ts +163 -0
- package/packages/core/runtime3d/ModelPlacements.ts +426 -0
- package/packages/core/runtime3d/ObjectMotion.ts +217 -0
- package/packages/core/runtime3d/PhysicalCamera.ts +190 -0
- package/packages/core/runtime3d/PointShadow.ts +500 -0
- package/packages/core/runtime3d/PointShadowSchedule.ts +201 -0
- package/packages/core/runtime3d/Pool.ts +120 -0
- package/packages/core/runtime3d/ProbeVolume.ts +695 -0
- package/packages/core/runtime3d/QualityGovernor.ts +385 -0
- package/packages/core/runtime3d/QualityMemory.ts +200 -0
- package/packages/core/runtime3d/RenderScale.ts +356 -0
- package/packages/core/runtime3d/RenderSpaces.ts +105 -0
- package/packages/core/runtime3d/Renderer.ts +377 -0
- package/packages/core/runtime3d/ResultPlayback.ts +239 -0
- package/packages/core/runtime3d/Runtime.ts +507 -0
- package/packages/core/runtime3d/RuntimeDriver.ts +127 -0
- package/packages/core/runtime3d/SceneLifecycle.ts +211 -0
- package/packages/core/runtime3d/SceneMutation.ts +107 -0
- package/packages/core/runtime3d/SceneQueries.ts +191 -0
- package/packages/core/runtime3d/ScreenReflections.ts +595 -0
- package/packages/core/runtime3d/SelectionOutline.ts +389 -0
- package/packages/core/runtime3d/ShaderErrors.ts +104 -0
- package/packages/core/runtime3d/ShaderRegistry.ts +34 -0
- package/packages/core/runtime3d/ShaderWarmUp.ts +473 -0
- package/packages/core/runtime3d/ShadowUpdates.ts +287 -0
- package/packages/core/runtime3d/SkinBinding.ts +235 -0
- package/packages/core/runtime3d/Smaa.ts +386 -0
- package/packages/core/runtime3d/SmaaTables.ts +244 -0
- package/packages/core/runtime3d/SpringBones.ts +184 -0
- package/packages/core/runtime3d/SurfaceBuffer.ts +76 -0
- package/packages/core/runtime3d/Surfaces.ts +1105 -0
- package/packages/core/runtime3d/Themes.ts +344 -0
- package/packages/core/runtime3d/Timeline.ts +362 -0
- package/packages/core/runtime3d/ToneCurves.ts +292 -0
- package/packages/core/runtime3d/TransformGizmo.ts +539 -0
- package/packages/core/runtime3d/TriangleMask.ts +250 -0
- package/packages/core/runtime3d/Underwater.ts +778 -0
- package/packages/core/runtime3d/Utf8.ts +87 -0
- package/packages/core/runtime3d/Vrm.ts +773 -0
- package/packages/core/runtime3d/VrmDocument.ts +1830 -0
- package/packages/core/runtime3d/WalkGrid.ts +471 -0
- package/packages/core/runtime3d/WebGPU342Adapters.ts +280 -0
- package/packages/core/runtime3d/index.ts +147 -0
- package/packages/core/shaders/Laya342ShaderTemplates.ts +6 -0
- package/packages/core/shaders/LitSurfaceMaterial.ts +1076 -0
- package/packages/core/shaders/LitSurfaceTemplates.ts +13 -0
- package/packages/core/shaders/ReflectiveSurface.ts +285 -0
- package/packages/core/shaders/ShaderMaterials.ts +387 -0
- package/packages/core/shaders/ToonMaterial.ts +559 -0
- package/packages/core/shaders/WaterRipples.ts +170 -0
- package/packages/core/shaders/WaterSurface.ts +480 -0
- package/packages/core/shaders/ZhudaCommon.ts +109 -0
- package/packages/core/shaders/index.ts +6 -0
- package/packages/core/simulation/Cloth.ts +1541 -0
- package/packages/core/simulation/ParticleCore.ts +498 -0
- package/packages/core/simulation/SpringBones.ts +553 -0
- package/packages/core/simulation/index.ts +3 -0
- package/packages/core/terrain/Heightfield.ts +385 -0
- package/packages/core/terrain/Terrain2D.ts +324 -0
- package/packages/core/terrain/Terrain3D.ts +452 -0
- package/packages/core/terrain/TerrainShell.ts +94 -0
- package/packages/core/terrain/index.ts +3 -0
- package/packages/demo/BenchmarkEngine.ts +184 -0
- package/packages/demo/PixelCalibrationEngine.ts +36 -0
- package/packages/demo/ProceduralStarter.ts +312 -0
- package/packages/demo/StaticAssetPipeline.ts +1631 -0
- package/packages/demo/UnityBridgePipeline.ts +485 -0
- package/packages/demo/index.ts +6 -0
- package/packages/mcp-server/arguments.mjs +81 -0
- package/packages/mcp-server/corpus.mjs +627 -0
- package/packages/mcp-server/film-host.mjs +627 -0
- package/packages/mcp-server/film-session.mjs +95 -0
- package/packages/mcp-server/film-tools.mjs +460 -0
- package/packages/mcp-server/index.mjs +931 -0
- package/packages/mcp-server/quality-route.mjs +332 -0
- package/packages/mcp-server/roots.mjs +72 -0
- package/packages/mcp-server/runtime.mjs +81 -0
- package/packages/types/BitmapFontContract.d.ts +19 -0
- package/packages/types/DeclarativeSDK.d.ts +137 -0
- package/packages/types/IframeSoundAdapter.d.ts +173 -0
- package/packages/types/NoSleepAdapter.d.ts +50 -0
- package/packages/types/PixelCalibrationEngine.d.ts +83 -0
- package/packages/types/Prefab.d.ts +11 -0
- package/packages/types/RealmGuards.d.ts +26 -0
- package/packages/types/ResponsiveLayout.d.ts +10 -0
- package/packages/types/RuntimeGuards.d.ts +55 -0
- package/packages/types/SpineCharacter.d.ts +94 -0
- package/packages/types/SpineVisualContract.d.ts +50 -0
- package/packages/types/SplashSignal.d.ts +27 -0
- package/packages/types/TopologyGraph.d.ts +76 -0
- package/packages/types/VideoSurface.d.ts +21 -0
- package/packages/types/ViewportMatrixEngine.d.ts +27 -0
- package/packages/types/VisualFocusContract.d.ts +32 -0
- package/packages/types/VisualMigrationPipeline.d.ts +53 -0
- package/packages/types/WebViewSurface.d.ts +26 -0
- package/packages/types/audio/OfflineMix.d.ts +10 -0
- package/packages/types/audio/Spatial.d.ts +63 -0
- package/packages/types/audio/StreamVoice.d.ts +31 -0
- package/packages/types/browser.d.ts +44 -0
- package/packages/types/csg/Bsp.d.ts +85 -0
- package/packages/types/csg/index.d.ts +81 -0
- package/packages/types/demo/BenchmarkEngine.d.ts +61 -0
- package/packages/types/demo/PixelCalibrationEngine.d.ts +13 -0
- package/packages/types/demo/ProceduralStarter.d.ts +11 -0
- package/packages/types/demo/StaticAssetPipeline.d.ts +87 -0
- package/packages/types/demo/UnityBridgePipeline.d.ts +49 -0
- package/packages/types/demo/index.d.ts +7 -0
- package/packages/types/editor-preview.d.ts +27 -0
- package/packages/types/effects/Effect2D.d.ts +65 -0
- package/packages/types/effects/Effect3D.d.ts +42 -0
- package/packages/types/effects/EffectBudget.d.ts +179 -0
- package/packages/types/effects/EffectDirector.d.ts +68 -0
- package/packages/types/effects/EffectPresets.d.ts +27 -0
- package/packages/types/effects/EffectPresets2D.d.ts +32 -0
- package/packages/types/effects/EffectSprites.d.ts +23 -0
- package/packages/types/effects/ParticleEventLink.d.ts +16 -0
- package/packages/types/effects/VfxMaterial.d.ts +52 -0
- package/packages/types/film/BakeKey.d.ts +9 -0
- package/packages/types/film/ColorValues.d.ts +25 -0
- package/packages/types/film/FilmLint.d.ts +40 -0
- package/packages/types/film/FilmPrefab.d.ts +22 -0
- package/packages/types/film/FilmReview.d.ts +27 -0
- package/packages/types/film/FilmScene.d.ts +1214 -0
- package/packages/types/film/FilmStage.d.ts +237 -0
- package/packages/types/film/Flythrough.d.ts +44 -0
- package/packages/types/film/FlythroughReport.d.ts +132 -0
- package/packages/types/film/FrameMetrics.d.ts +49 -0
- package/packages/types/film/LiveLook.d.ts +60 -0
- package/packages/types/film/LookQuality.d.ts +24 -0
- package/packages/types/film/Projection.d.ts +20 -0
- package/packages/types/film/SceneLook.d.ts +122 -0
- package/packages/types/film/index.d.ts +13 -0
- package/packages/types/index.d.ts +49 -0
- package/packages/types/particles/EffectEnvelope.d.ts +18 -0
- package/packages/types/particles/LayaParticleRenderer.d.ts +30 -0
- package/packages/types/particles/LayaParticleRenderer3D.d.ts +29 -0
- package/packages/types/particles/ParticleExtras.d.ts +50 -0
- package/packages/types/particles/ParticleMesh3D.d.ts +24 -0
- package/packages/types/particles/ParticleSystem.d.ts +52 -0
- package/packages/types/particles/ParticleSystem3D.d.ts +69 -0
- package/packages/types/particles/ParticleTypes.d.ts +89 -0
- package/packages/types/particles/ParticleTypes3D.d.ts +56 -0
- package/packages/types/particles/RibbonPath3D.d.ts +32 -0
- package/packages/types/particles/RibbonTrail.d.ts +38 -0
- package/packages/types/particles/RibbonTrail3D.d.ts +22 -0
- package/packages/types/particles/index.d.ts +13 -0
- package/packages/types/prefabs/PrefabLibrary.d.ts +176 -0
- package/packages/types/prefabs/PrefabTree3D.d.ts +59 -0
- package/packages/types/prefabs/index.d.ts +4 -0
- package/packages/types/procedural/Geometry.d.ts +252 -0
- package/packages/types/procedural/Hand.d.ts +150 -0
- package/packages/types/procedural/Isosurface.d.ts +181 -0
- package/packages/types/procedural/ModuleHarness.d.ts +90 -0
- package/packages/types/procedural/Noise.d.ts +15 -0
- package/packages/types/procedural/PhotoMaterial.d.ts +49 -0
- package/packages/types/procedural/ProceduralAssetProvider.d.ts +31 -0
- package/packages/types/procedural/ProceduralMaterial.d.ts +63 -0
- package/packages/types/procedural/PropFactory.d.ts +94 -0
- package/packages/types/procedural/Random.d.ts +26 -0
- package/packages/types/procedural/SynthAudio.d.ts +49 -0
- package/packages/types/procedural/TerrainMesh.d.ts +55 -0
- package/packages/types/procedural/TextureRecipe.d.ts +125 -0
- package/packages/types/procedural/TriplanarMaterial.d.ts +27 -0
- package/packages/types/procedural/Variation.d.ts +23 -0
- package/packages/types/procedural/index.d.ts +16 -0
- package/packages/types/runtime3d/ActionFrames.d.ts +62 -0
- package/packages/types/runtime3d/AnimationBlend.d.ts +57 -0
- package/packages/types/runtime3d/AnimationBlendMath.d.ts +27 -0
- package/packages/types/runtime3d/AssetProvider.d.ts +167 -0
- package/packages/types/runtime3d/AssetShowcase.d.ts +44 -0
- package/packages/types/runtime3d/Assets.d.ts +166 -0
- package/packages/types/runtime3d/AsyncDeadline.d.ts +6 -0
- package/packages/types/runtime3d/AsyncOperation.d.ts +3 -0
- package/packages/types/runtime3d/BackendChoice.d.ts +130 -0
- package/packages/types/runtime3d/BakedCrowd.d.ts +156 -0
- package/packages/types/runtime3d/BasisTexture.d.ts +169 -0
- package/packages/types/runtime3d/CameraCollision.d.ts +20 -0
- package/packages/types/runtime3d/CameraEffects.d.ts +134 -0
- package/packages/types/runtime3d/CameraRig.d.ts +27 -0
- package/packages/types/runtime3d/CharacterController.d.ts +71 -0
- package/packages/types/runtime3d/CinematicCapture.d.ts +103 -0
- package/packages/types/runtime3d/Clocks.d.ts +200 -0
- package/packages/types/runtime3d/Cloth.d.ts +57 -0
- package/packages/types/runtime3d/Clouds.d.ts +69 -0
- package/packages/types/runtime3d/ColorLut.d.ts +73 -0
- package/packages/types/runtime3d/CombatQueries.d.ts +50 -0
- package/packages/types/runtime3d/ComputePass.d.ts +134 -0
- package/packages/types/runtime3d/CrowdPresentation.d.ts +104 -0
- package/packages/types/runtime3d/DebugDraw.d.ts +161 -0
- package/packages/types/runtime3d/DebugStats.d.ts +24 -0
- package/packages/types/runtime3d/Decals.d.ts +65 -0
- package/packages/types/runtime3d/DensityVolume.d.ts +39 -0
- package/packages/types/runtime3d/DistanceBricks.d.ts +97 -0
- package/packages/types/runtime3d/Dither.d.ts +78 -0
- package/packages/types/runtime3d/DrawWarmUp.d.ts +93 -0
- package/packages/types/runtime3d/EdgeSmoothing.d.ts +10 -0
- package/packages/types/runtime3d/EnvironmentProbe.d.ts +139 -0
- package/packages/types/runtime3d/Filmic.d.ts +243 -0
- package/packages/types/runtime3d/Foliage.d.ts +95 -0
- package/packages/types/runtime3d/GltfIntake.d.ts +236 -0
- package/packages/types/runtime3d/GltfSecondUv.d.ts +54 -0
- package/packages/types/runtime3d/GraphicsGuard.d.ts +18 -0
- package/packages/types/runtime3d/Grass.d.ts +226 -0
- package/packages/types/runtime3d/GroundTruthAO.d.ts +64 -0
- package/packages/types/runtime3d/HalfFloat.d.ts +13 -0
- package/packages/types/runtime3d/HdrEnvironment.d.ts +144 -0
- package/packages/types/runtime3d/Ik.d.ts +123 -0
- package/packages/types/runtime3d/InputBuffer.d.ts +49 -0
- package/packages/types/runtime3d/InstancedMesh.d.ts +116 -0
- package/packages/types/runtime3d/Laya342Adapters.d.ts +306 -0
- package/packages/types/runtime3d/Laya342GltfAdapter.d.ts +105 -0
- package/packages/types/runtime3d/LensFinish.d.ts +38 -0
- package/packages/types/runtime3d/LensFlare.d.ts +114 -0
- package/packages/types/runtime3d/LightFog.d.ts +190 -0
- package/packages/types/runtime3d/LightingDepth.d.ts +128 -0
- package/packages/types/runtime3d/Lightmap.d.ts +55 -0
- package/packages/types/runtime3d/Math3D.d.ts +19 -0
- package/packages/types/runtime3d/MeshQuery.d.ts +107 -0
- package/packages/types/runtime3d/MeshoptModelDecoder.d.ts +34 -0
- package/packages/types/runtime3d/MiniGameSplash.d.ts +4 -0
- package/packages/types/runtime3d/ModelAnimationSampler.d.ts +26 -0
- package/packages/types/runtime3d/ModelCompatibility.d.ts +169 -0
- package/packages/types/runtime3d/ModelDecoder.d.ts +66 -0
- package/packages/types/runtime3d/ModelInspector.d.ts +77 -0
- package/packages/types/runtime3d/ModelLod.d.ts +61 -0
- package/packages/types/runtime3d/ModelPlacements.d.ts +77 -0
- package/packages/types/runtime3d/ObjectMotion.d.ts +43 -0
- package/packages/types/runtime3d/PhysicalCamera.d.ts +51 -0
- package/packages/types/runtime3d/PointShadow.d.ts +71 -0
- package/packages/types/runtime3d/PointShadowSchedule.d.ts +74 -0
- package/packages/types/runtime3d/Pool.d.ts +33 -0
- package/packages/types/runtime3d/ProbeVolume.d.ts +123 -0
- package/packages/types/runtime3d/QualityGovernor.d.ts +201 -0
- package/packages/types/runtime3d/QualityMemory.d.ts +83 -0
- package/packages/types/runtime3d/RenderScale.d.ts +69 -0
- package/packages/types/runtime3d/RenderSpaces.d.ts +44 -0
- package/packages/types/runtime3d/Renderer.d.ts +62 -0
- package/packages/types/runtime3d/ResultPlayback.d.ts +70 -0
- package/packages/types/runtime3d/Runtime.d.ts +136 -0
- package/packages/types/runtime3d/RuntimeDriver.d.ts +42 -0
- package/packages/types/runtime3d/SceneLifecycle.d.ts +84 -0
- package/packages/types/runtime3d/SceneMutation.d.ts +34 -0
- package/packages/types/runtime3d/SceneQueries.d.ts +71 -0
- package/packages/types/runtime3d/ScreenReflections.d.ts +78 -0
- package/packages/types/runtime3d/SelectionOutline.d.ts +68 -0
- package/packages/types/runtime3d/ShaderErrors.d.ts +27 -0
- package/packages/types/runtime3d/ShaderRegistry.d.ts +10 -0
- package/packages/types/runtime3d/ShaderWarmUp.d.ts +162 -0
- package/packages/types/runtime3d/ShadowUpdates.d.ts +125 -0
- package/packages/types/runtime3d/SkinBinding.d.ts +53 -0
- package/packages/types/runtime3d/Smaa.d.ts +60 -0
- package/packages/types/runtime3d/SmaaTables.d.ts +12 -0
- package/packages/types/runtime3d/SpringBones.d.ts +69 -0
- package/packages/types/runtime3d/SurfaceBuffer.d.ts +28 -0
- package/packages/types/runtime3d/Surfaces.d.ts +326 -0
- package/packages/types/runtime3d/Themes.d.ts +70 -0
- package/packages/types/runtime3d/Timeline.d.ts +88 -0
- package/packages/types/runtime3d/ToneCurves.d.ts +59 -0
- package/packages/types/runtime3d/TransformGizmo.d.ts +139 -0
- package/packages/types/runtime3d/TriangleMask.d.ts +84 -0
- package/packages/types/runtime3d/Underwater.d.ts +120 -0
- package/packages/types/runtime3d/Utf8.d.ts +12 -0
- package/packages/types/runtime3d/Vrm.d.ts +120 -0
- package/packages/types/runtime3d/VrmDocument.d.ts +381 -0
- package/packages/types/runtime3d/WalkGrid.d.ts +94 -0
- package/packages/types/runtime3d/WebGPU342Adapters.d.ts +27 -0
- package/packages/types/runtime3d/index.d.ts +102 -0
- package/packages/types/shaders/Laya342ShaderTemplates.d.ts +3 -0
- package/packages/types/shaders/LitSurfaceMaterial.d.ts +257 -0
- package/packages/types/shaders/LitSurfaceTemplates.d.ts +7 -0
- package/packages/types/shaders/ReflectiveSurface.d.ts +58 -0
- package/packages/types/shaders/ShaderMaterials.d.ts +60 -0
- package/packages/types/shaders/ToonMaterial.d.ts +176 -0
- package/packages/types/shaders/WaterRipples.d.ts +48 -0
- package/packages/types/shaders/WaterSurface.d.ts +110 -0
- package/packages/types/shaders/ZhudaCommon.d.ts +31 -0
- package/packages/types/shaders/index.d.ts +7 -0
- package/packages/types/simulation/Cloth.d.ts +381 -0
- package/packages/types/simulation/ParticleCore.d.ts +125 -0
- package/packages/types/simulation/SpringBones.d.ts +107 -0
- package/packages/types/simulation/index.d.ts +4 -0
- package/packages/types/terrain/Heightfield.d.ts +67 -0
- package/packages/types/terrain/Terrain2D.d.ts +81 -0
- package/packages/types/terrain/Terrain3D.d.ts +80 -0
- package/packages/types/terrain/TerrainShell.d.ts +8 -0
- package/packages/types/terrain/index.d.ts +4 -0
- package/packages/types/vendor/LayaAir.runtime.d.ts +97440 -0
- package/packages/types/vendor/REPAIRS.md +30 -0
- package/packages/types/vendor/restored-3.4.2.json +142 -0
- package/packages/types/vendor/spine.runtime.d.ts +1507 -0
- package/packages/types/vendor/wechat-media.d.ts +877 -0
- package/packages/types/zhuda-2d-ui.d.ts +244 -0
- package/packages/types/zhuda-3d-physics.d.ts +34 -0
- package/packages/types/zhuda-audio.d.ts +128 -0
- package/packages/types/zhuda-bootstrap.d.ts +100 -0
- package/packages/types/zhuda-branding.d.ts +6 -0
- package/packages/types/zhuda-core.d.ts +46 -0
- package/packages/types/zhuda-declarative.d.ts +81 -0
- package/packages/types/zhuda-effects.d.ts +302 -0
- package/packages/types/zhuda-layout.d.ts +96 -0
- package/packages/types/zhuda-particles.d.ts +477 -0
- package/packages/types/zhuda-spine42.d.ts +23 -0
- package/packages/types/zhuda-static-assets.d.ts +389 -0
- package/packages/types/zhuda-video.d.ts +24 -0
- package/packages/types/zhuda-visual-contract.d.ts +52 -0
- package/packages/types/zhuda-webview.d.ts +43 -0
- package/vendor/basis/LICENSE.txt +55 -0
- package/vendor/basis/README.md +25 -0
- package/vendor/basis/basis_transcoder.js +19 -0
- package/vendor/basis/basis_transcoder.wasm +0 -0
- package/vendor/laya-3.4.2/WEBGPU-LICENSES.txt +1259 -0
- package/vendor/laya-3.4.2/libs/laya.ani.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.box2D.js +1209 -0
- package/vendor/laya-3.4.2/libs/laya.bridge.js +2273 -0
- package/vendor/laya-3.4.2/libs/laya.bullet.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.core.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.d3.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.device.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.gltf.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.ik.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.light2D.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.line2D.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.native-spine42.js +7672 -0
- package/vendor/laya-3.4.2/libs/laya.navMesh2d.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.navMesh3d.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.navMeshCommon.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.particle.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.particle3D.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.particleCommon.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.physics2D.js +3774 -0
- package/vendor/laya-3.4.2/libs/laya.physics3D.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.postProcess.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.spine.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.spine3D.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.tilemap.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.trail2D.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.trail3D.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.trailCommon.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.ui.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.ui2.js +9904 -0
- package/vendor/laya-3.4.2/libs/laya.vfx.js +6754 -0
- package/vendor/laya-3.4.2/libs/laya.webgl_2D.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.webgl_3D.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.webgpu_2D.js +18576 -0
- package/vendor/laya-3.4.2/libs/laya.webgpu_3D.js +6729 -0
- package/vendor/laya-3.4.2/libs/nagabind.js +395 -0
- package/vendor/laya-3.4.2/libs/nagabind_bg.wasm +0 -0
- package/vendor/laya-3.4.2/libs/shader_compiler_web.js +22 -0
- package/vendor/laya-3.4.2/libs/shader_compiler_web.wasm +0 -0
- package/vendor/laya-3.4.2/libs/spine-core-3.8.js +1 -0
- package/vendor/laya-3.4.2/libs/spine-core-4.2.js +10216 -0
- package/vendor/laya-3.4.2/webgpu-provenance.json +41 -0
- package/vendor/meshoptimizer/LICENSE.txt +21 -0
- package/vendor/meshoptimizer/README.md +13 -0
- package/vendor/threejs-post/LICENSE.txt +53 -0
- package/vendor/threejs-post/README.md +54 -0
- package/zhuda.config.json +22 -0
|
@@ -0,0 +1,890 @@
|
|
|
1
|
+
import {
|
|
2
|
+
externalZhudaGltfBuffers,
|
|
3
|
+
quantizedZhudaGltfAccessors,
|
|
4
|
+
readZhudaGltfCameras,
|
|
5
|
+
readZhudaGltfInstancing,
|
|
6
|
+
readZhudaGltfLights,
|
|
7
|
+
resolveZhudaGltfTextureSource,
|
|
8
|
+
type ZhudaImageDecodeSupport,
|
|
9
|
+
} from './GltfIntake.ts';
|
|
10
|
+
import { zhudaUtf8Decode } from './Utf8.ts';
|
|
11
|
+
/** Import diagnostics describe the shipped importer, not complete glTF conformance. */
|
|
12
|
+
export interface ModelDiagnostic {
|
|
13
|
+
code:
|
|
14
|
+
| 'INVALID_DOCUMENT'
|
|
15
|
+
| 'INVALID_EXTENSION_DECLARATION'
|
|
16
|
+
| 'UNDECLARED_EXTENSION'
|
|
17
|
+
| 'UNSUPPORTED_REQUIRED_EXTENSION'
|
|
18
|
+
| 'UNSUPPORTED_OPTIONAL_EXTENSION'
|
|
19
|
+
| 'REQUIRED_RENDER_INPUT'
|
|
20
|
+
| 'INVALID_MORPH_WEIGHTS'
|
|
21
|
+
/** Meshopt data: only a registered decoder (ZhudaMeshoptModelDecoder) reads it. */
|
|
22
|
+
| 'DECODER_REQUIRED'
|
|
23
|
+
/** Integer vertex attributes the engine turns into floats before LayaAir parses them. */
|
|
24
|
+
| 'DEQUANTIZED_ATTRIBUTES'
|
|
25
|
+
/** Integer vertex attributes in a buffer outside the file: there are no bytes to turn into floats. */
|
|
26
|
+
| 'EMBEDDED_BUFFER_REQUIRED'
|
|
27
|
+
/** This device cannot decode a texture's WebP/AVIF image: its fallback loads, or nothing. */
|
|
28
|
+
| 'IMAGE_DECODE_UNAVAILABLE'
|
|
29
|
+
/** A texture's KTX 2 image and no Basis transcoder to read it: its fallback loads, or nothing. */
|
|
30
|
+
| 'BASIS_TRANSCODER_MISSING'
|
|
31
|
+
/** The device's decoder gave the probe no answer in time: as unavailable for this load; the next asks again. */
|
|
32
|
+
| 'IMAGE_DECODE_UNANSWERED'
|
|
33
|
+
/** A WebP/AVIF image without a fallback, inspected without a device answer. */
|
|
34
|
+
| 'IMAGE_DECODE_UNCHECKED'
|
|
35
|
+
/** Set by ZhudaModelLibrary after loading: a texture's picture did not load or decode; its slots are empty. */
|
|
36
|
+
| 'IMAGE_DECODE_FAILED'
|
|
37
|
+
/** A punctual light LayaAir can only approximate (falloff, spot cone). */
|
|
38
|
+
| 'LIGHT_APPROXIMATED'
|
|
39
|
+
| 'INVALID_LIGHT'
|
|
40
|
+
| 'INVALID_CAMERA'
|
|
41
|
+
/** A node's `EXT_mesh_gpu_instancing` cannot be drawn as copies: its mesh is drawn once, where the node is. */
|
|
42
|
+
| 'INVALID_INSTANCING'
|
|
43
|
+
/** Set by ZhudaModelLibrary after loading: copies whose scale turns the mesh inside out are not drawn. */
|
|
44
|
+
| 'INSTANCES_MIRRORED'
|
|
45
|
+
/** A texture asks for texture coordinates the importer does not read for that slot: it is drawn with the first set. */
|
|
46
|
+
| 'TEXCOORD_IGNORED';
|
|
47
|
+
severity: 'error' | 'warning';
|
|
48
|
+
path: string;
|
|
49
|
+
extension?: string;
|
|
50
|
+
message: string;
|
|
51
|
+
hint: string;
|
|
52
|
+
}
|
|
53
|
+
export interface GltfExtensionCapability {
|
|
54
|
+
name: string;
|
|
55
|
+
/** `native`: LayaAir's importer; `engine`: this engine before or around it. */
|
|
56
|
+
implementation: 'native' | 'engine';
|
|
57
|
+
requiredRenderInputs: readonly 'opaqueColor'[];
|
|
58
|
+
/** An implemented parser is not a visual conformance certificate. */
|
|
59
|
+
visualConformance: 'not-certified';
|
|
60
|
+
}
|
|
61
|
+
export interface GltfAssetCapability {
|
|
62
|
+
name: string;
|
|
63
|
+
kind: 'container' | 'delivery' | 'geometry-compression' | 'image-compression';
|
|
64
|
+
status: 'supported' | 'adapter-required' | 'unsupported';
|
|
65
|
+
message: string;
|
|
66
|
+
hint: string;
|
|
67
|
+
}
|
|
68
|
+
/** Machine-readable import/delivery boundary for agents and model tooling. */
|
|
69
|
+
export const gltfAssetCapabilities: readonly GltfAssetCapability[] = Object.freeze([
|
|
70
|
+
Object.freeze({
|
|
71
|
+
name: 'glTF 2.0 JSON',
|
|
72
|
+
kind: 'container' as const,
|
|
73
|
+
status: 'supported' as const,
|
|
74
|
+
message: 'glTF 2.0 JSON can be inspected and loaded when its resources are self-contained.',
|
|
75
|
+
hint: 'Prefer a single GLB for consumer delivery.',
|
|
76
|
+
}),
|
|
77
|
+
Object.freeze({
|
|
78
|
+
name: 'GLB 2.0',
|
|
79
|
+
kind: 'container' as const,
|
|
80
|
+
status: 'supported' as const,
|
|
81
|
+
message: 'GLB 2.0 with an embedded JSON and binary payload is supported.',
|
|
82
|
+
hint: 'Pass the complete GLB through AssetProvider.',
|
|
83
|
+
}),
|
|
84
|
+
Object.freeze({
|
|
85
|
+
name: 'embedded buffers/images',
|
|
86
|
+
kind: 'delivery' as const,
|
|
87
|
+
status: 'supported' as const,
|
|
88
|
+
message: 'Embedded data is deterministic and provider-verifiable.',
|
|
89
|
+
hint: 'Record the logical asset SHA.',
|
|
90
|
+
}),
|
|
91
|
+
Object.freeze({
|
|
92
|
+
name: 'external buffers/images',
|
|
93
|
+
kind: 'delivery' as const,
|
|
94
|
+
status: 'unsupported' as const,
|
|
95
|
+
message: 'The provider model loader does not fetch undeclared relative resource URLs.',
|
|
96
|
+
hint: 'Package buffers and images into a GLB or explicit provider assets.',
|
|
97
|
+
}),
|
|
98
|
+
Object.freeze({
|
|
99
|
+
name: 'KHR_draco_mesh_compression',
|
|
100
|
+
kind: 'geometry-compression' as const,
|
|
101
|
+
status: 'unsupported' as const,
|
|
102
|
+
message: 'No pinned Draco decoder is shipped in this release.',
|
|
103
|
+
hint: 'Export an uncompressed GLB or add a separately verified decoder adapter.',
|
|
104
|
+
}),
|
|
105
|
+
Object.freeze({
|
|
106
|
+
name: 'EXT_meshopt_compression',
|
|
107
|
+
kind: 'geometry-compression' as const,
|
|
108
|
+
status: 'adapter-required' as const,
|
|
109
|
+
message:
|
|
110
|
+
'Embedded glTF/GLB can be decoded by the optional pinned Meshopt adapter before native parsing.',
|
|
111
|
+
hint: 'Register ZhudaMeshoptModelDecoder with ZhudaModelDecoderRegistry and pass decoders plus provider to ZhudaModelLibrary; verify the model on target devices.',
|
|
112
|
+
}),
|
|
113
|
+
Object.freeze({
|
|
114
|
+
name: 'KHR_meshopt_compression',
|
|
115
|
+
kind: 'geometry-compression' as const,
|
|
116
|
+
status: 'adapter-required' as const,
|
|
117
|
+
message:
|
|
118
|
+
'The ratified Meshopt name, with its COLOR filter, is decoded by the same optional adapter before native parsing.',
|
|
119
|
+
hint: 'Register ZhudaMeshoptModelDecoder with ZhudaModelDecoderRegistry and pass decoders plus provider to ZhudaModelLibrary; verify the model on target devices.',
|
|
120
|
+
}),
|
|
121
|
+
Object.freeze({
|
|
122
|
+
name: 'KHR_mesh_quantization',
|
|
123
|
+
kind: 'geometry-compression' as const,
|
|
124
|
+
status: 'supported' as const,
|
|
125
|
+
message:
|
|
126
|
+
'Integer vertex attributes are turned into floats before native parsing; node transforms are kept.',
|
|
127
|
+
hint: 'Download size stays small; GPU vertex memory is that of an unquantized export.',
|
|
128
|
+
}),
|
|
129
|
+
Object.freeze({
|
|
130
|
+
name: 'EXT_texture_webp',
|
|
131
|
+
kind: 'image-compression' as const,
|
|
132
|
+
status: 'supported' as const,
|
|
133
|
+
message: 'A texture loads its WebP image when the device decodes it, else its fallback source.',
|
|
134
|
+
hint: 'ModelLibrary asks the device first; keep a PNG/JPEG fallback for hosts without WebP.',
|
|
135
|
+
}),
|
|
136
|
+
Object.freeze({
|
|
137
|
+
name: 'EXT_texture_avif',
|
|
138
|
+
kind: 'image-compression' as const,
|
|
139
|
+
status: 'supported' as const,
|
|
140
|
+
message:
|
|
141
|
+
'A texture loads its AVIF image when the device decodes it (preferred over WebP), else its fallback.',
|
|
142
|
+
hint: 'AVIF decoding varies by device: keep a PNG/JPEG or WebP fallback (optional extension).',
|
|
143
|
+
}),
|
|
144
|
+
Object.freeze({
|
|
145
|
+
name: 'KHR_texture_basisu',
|
|
146
|
+
kind: 'image-compression' as const,
|
|
147
|
+
status: 'supported' as const,
|
|
148
|
+
message:
|
|
149
|
+
'A texture loads its KTX 2 image as ASTC, ETC2 or S3TC when the library has a Basis transcoder, else its fallback source.',
|
|
150
|
+
hint: 'Give ZhudaModelLibrary a basisTranscoder; keep a PNG/JPEG fallback for builds without one. Embedded images only.',
|
|
151
|
+
}),
|
|
152
|
+
]);
|
|
153
|
+
const extensionNames = [
|
|
154
|
+
'KHR_materials_anisotropy',
|
|
155
|
+
'KHR_materials_clearcoat',
|
|
156
|
+
'KHR_materials_emissive_strength',
|
|
157
|
+
'KHR_materials_ior',
|
|
158
|
+
'KHR_materials_iridescence',
|
|
159
|
+
'KHR_materials_sheen',
|
|
160
|
+
'KHR_materials_specular',
|
|
161
|
+
'KHR_materials_transmission',
|
|
162
|
+
'KHR_materials_unlit',
|
|
163
|
+
'KHR_materials_volume',
|
|
164
|
+
'KHR_texture_transform',
|
|
165
|
+
'KHR_mesh_quantization',
|
|
166
|
+
'EXT_texture_webp',
|
|
167
|
+
'EXT_texture_avif',
|
|
168
|
+
'KHR_texture_basisu',
|
|
169
|
+
'KHR_lights_punctual',
|
|
170
|
+
'EXT_mesh_gpu_instancing',
|
|
171
|
+
// VRM 1.0: read into `instance.vrm` by the model library, applied by `ZhudaVrm`.
|
|
172
|
+
'VRMC_vrm',
|
|
173
|
+
'VRMC_springBone',
|
|
174
|
+
'VRMC_materials_mtoon',
|
|
175
|
+
'VRMC_node_constraint',
|
|
176
|
+
] as const;
|
|
177
|
+
const engineExtensions: readonly string[] = [
|
|
178
|
+
'KHR_mesh_quantization',
|
|
179
|
+
'EXT_texture_webp',
|
|
180
|
+
'EXT_texture_avif',
|
|
181
|
+
'KHR_texture_basisu',
|
|
182
|
+
'KHR_lights_punctual',
|
|
183
|
+
'EXT_mesh_gpu_instancing',
|
|
184
|
+
'VRMC_vrm',
|
|
185
|
+
'VRMC_springBone',
|
|
186
|
+
'VRMC_materials_mtoon',
|
|
187
|
+
'VRMC_node_constraint',
|
|
188
|
+
];
|
|
189
|
+
// Read by a registered decoder before the native parser, never by the parser.
|
|
190
|
+
const decoderExtensions: readonly string[] = ['EXT_meshopt_compression', 'KHR_meshopt_compression'];
|
|
191
|
+
export const gltfExtensionCapabilities: readonly GltfExtensionCapability[] = Object.freeze(
|
|
192
|
+
extensionNames.map((name) =>
|
|
193
|
+
Object.freeze({
|
|
194
|
+
name,
|
|
195
|
+
implementation: engineExtensions.includes(name) ? ('engine' as const) : ('native' as const),
|
|
196
|
+
requiredRenderInputs: Object.freeze(
|
|
197
|
+
name === 'KHR_materials_transmission' ? ['opaqueColor' as const] : [],
|
|
198
|
+
),
|
|
199
|
+
visualConformance: 'not-certified' as const,
|
|
200
|
+
}),
|
|
201
|
+
),
|
|
202
|
+
);
|
|
203
|
+
/** Options for a compatibility inspection. */
|
|
204
|
+
export interface GltfInspectOptions {
|
|
205
|
+
/** This device's WebP/AVIF decoding (`probeZhudaImageDecode`). Without it no device answer is assumed. */
|
|
206
|
+
imageDecode?: ZhudaImageDecodeSupport;
|
|
207
|
+
}
|
|
208
|
+
export interface ModelSourceInventory {
|
|
209
|
+
/** Source complexity only; this does not predict native/GPU upload time. */
|
|
210
|
+
summary: {
|
|
211
|
+
nodes: number;
|
|
212
|
+
meshes: number;
|
|
213
|
+
primitives: number;
|
|
214
|
+
vertices: number;
|
|
215
|
+
indices: number;
|
|
216
|
+
triangles: number;
|
|
217
|
+
materials: number;
|
|
218
|
+
textures: number;
|
|
219
|
+
images: number;
|
|
220
|
+
animations: number;
|
|
221
|
+
};
|
|
222
|
+
nodes: readonly {
|
|
223
|
+
index: number;
|
|
224
|
+
name: string;
|
|
225
|
+
mesh: number | null;
|
|
226
|
+
skin: number | null;
|
|
227
|
+
children: readonly number[];
|
|
228
|
+
morphWeights: readonly number[];
|
|
229
|
+
/** glTF camera index, or null. */
|
|
230
|
+
camera: number | null;
|
|
231
|
+
/** `KHR_lights_punctual` light index, or null. */
|
|
232
|
+
light: number | null;
|
|
233
|
+
}[];
|
|
234
|
+
meshes: readonly {
|
|
235
|
+
index: number;
|
|
236
|
+
name: string;
|
|
237
|
+
primitives: readonly {
|
|
238
|
+
mode: number;
|
|
239
|
+
vertices: number;
|
|
240
|
+
indices: number;
|
|
241
|
+
triangles: number | null;
|
|
242
|
+
material: number | null;
|
|
243
|
+
morphTargets: number;
|
|
244
|
+
attributes: readonly string[];
|
|
245
|
+
}[];
|
|
246
|
+
}[];
|
|
247
|
+
materials: readonly {
|
|
248
|
+
index: number;
|
|
249
|
+
name: string;
|
|
250
|
+
alphaMode: string;
|
|
251
|
+
doubleSided: boolean;
|
|
252
|
+
baseColor: readonly number[];
|
|
253
|
+
metallic: number;
|
|
254
|
+
roughness: number;
|
|
255
|
+
extensions: readonly string[];
|
|
256
|
+
textures: readonly {
|
|
257
|
+
slot: string;
|
|
258
|
+
texture: number;
|
|
259
|
+
texCoord: number;
|
|
260
|
+
colorSpace: 'srgb' | 'linear';
|
|
261
|
+
}[];
|
|
262
|
+
}[];
|
|
263
|
+
textures: readonly {
|
|
264
|
+
index: number;
|
|
265
|
+
/** The core `source` image (the fallback when an extension image is offered). */
|
|
266
|
+
image: number | null;
|
|
267
|
+
sampler: number | null;
|
|
268
|
+
/** `EXT_texture_webp` / `EXT_texture_avif` / `KHR_texture_basisu` images, or null. */
|
|
269
|
+
webp: number | null;
|
|
270
|
+
avif: number | null;
|
|
271
|
+
basisu: number | null;
|
|
272
|
+
}[];
|
|
273
|
+
images: readonly {
|
|
274
|
+
index: number;
|
|
275
|
+
name: string;
|
|
276
|
+
delivery: 'embedded' | 'external';
|
|
277
|
+
mimeType: string | null;
|
|
278
|
+
}[];
|
|
279
|
+
animations: readonly {
|
|
280
|
+
index: number;
|
|
281
|
+
name: string;
|
|
282
|
+
channels: readonly {
|
|
283
|
+
node: number | null;
|
|
284
|
+
path: string;
|
|
285
|
+
interpolation: string;
|
|
286
|
+
}[];
|
|
287
|
+
}[];
|
|
288
|
+
}
|
|
289
|
+
export interface ModelCompatibilityReport {
|
|
290
|
+
schemaVersion: 1;
|
|
291
|
+
status: 'supported' | 'conditional' | 'degraded' | 'unsupported';
|
|
292
|
+
/** Known importer gates only. Does not replace Khronos Validator or pixel acceptance. */
|
|
293
|
+
validationScope: 'importer-capabilities';
|
|
294
|
+
extensions: readonly { name: string; required: boolean; implemented: boolean }[];
|
|
295
|
+
requiredRenderInputs: readonly 'opaqueColor'[];
|
|
296
|
+
diagnostics: readonly ModelDiagnostic[];
|
|
297
|
+
inventory: ModelSourceInventory;
|
|
298
|
+
}
|
|
299
|
+
type RecordValue = Record<string, unknown>;
|
|
300
|
+
const record = (v: unknown): RecordValue =>
|
|
301
|
+
v !== null && typeof v === 'object' && !Array.isArray(v) ? (v as RecordValue) : {};
|
|
302
|
+
const list = (v: unknown): unknown[] => (Array.isArray(v) ? v : []);
|
|
303
|
+
const records = (v: unknown): RecordValue[] => list(v).map(record);
|
|
304
|
+
const numeric = (v: unknown, fallback = 0): number =>
|
|
305
|
+
typeof v === 'number' && Number.isFinite(v) ? v : fallback;
|
|
306
|
+
const indexOf = (v: unknown): number | null =>
|
|
307
|
+
Number.isInteger(v) && (v as number) >= 0 ? (v as number) : null;
|
|
308
|
+
const label = (v: unknown): string => (typeof v === 'string' ? v : '');
|
|
309
|
+
const numbers = (v: unknown): number[] => list(v).map((x) => numeric(x));
|
|
310
|
+
function freeze<T>(value: T): T {
|
|
311
|
+
if (value && typeof value === 'object' && !Object.isFrozen(value)) {
|
|
312
|
+
for (const child of Object.values(value)) freeze(child);
|
|
313
|
+
Object.freeze(value);
|
|
314
|
+
}
|
|
315
|
+
return value;
|
|
316
|
+
}
|
|
317
|
+
function inventory(d: RecordValue): ModelSourceInventory {
|
|
318
|
+
const meshes = records(d.meshes),
|
|
319
|
+
accessors = records(d.accessors);
|
|
320
|
+
const nodes = records(d.nodes).map((n, index) => ({
|
|
321
|
+
index,
|
|
322
|
+
name: label(n.name),
|
|
323
|
+
mesh: indexOf(n.mesh),
|
|
324
|
+
skin: indexOf(n.skin),
|
|
325
|
+
children: numbers(n.children),
|
|
326
|
+
morphWeights: numbers(n.weights ?? meshes[indexOf(n.mesh) ?? -1]?.weights),
|
|
327
|
+
camera: indexOf(n.camera),
|
|
328
|
+
light: indexOf(record(record(n.extensions).KHR_lights_punctual).light),
|
|
329
|
+
})),
|
|
330
|
+
meshInventory = meshes.map((m, index) => ({
|
|
331
|
+
index,
|
|
332
|
+
name: label(m.name),
|
|
333
|
+
primitives: records(m.primitives).map((p) => {
|
|
334
|
+
const attributes = record(p.attributes),
|
|
335
|
+
vertices = numeric(accessors[indexOf(attributes.POSITION) ?? -1]?.count);
|
|
336
|
+
const indices =
|
|
337
|
+
p.indices === undefined ? vertices : numeric(accessors[indexOf(p.indices) ?? -1]?.count);
|
|
338
|
+
const mode = numeric(p.mode, 4);
|
|
339
|
+
return {
|
|
340
|
+
mode,
|
|
341
|
+
vertices,
|
|
342
|
+
indices,
|
|
343
|
+
triangles:
|
|
344
|
+
mode === 4 ? indices / 3 : mode === 5 || mode === 6 ? Math.max(0, indices - 2) : null,
|
|
345
|
+
material: indexOf(p.material),
|
|
346
|
+
morphTargets: list(p.targets).length,
|
|
347
|
+
attributes: Object.keys(attributes),
|
|
348
|
+
};
|
|
349
|
+
}),
|
|
350
|
+
})),
|
|
351
|
+
materials = records(d.materials).map((m, index) => {
|
|
352
|
+
const pbr = record(m.pbrMetallicRoughness),
|
|
353
|
+
textures: {
|
|
354
|
+
slot: string;
|
|
355
|
+
texture: number;
|
|
356
|
+
texCoord: number;
|
|
357
|
+
colorSpace: 'srgb' | 'linear';
|
|
358
|
+
}[] = [];
|
|
359
|
+
const add = (slot: string, v: unknown, colorSpace: 'srgb' | 'linear') => {
|
|
360
|
+
const info = record(v),
|
|
361
|
+
texture = indexOf(info.index);
|
|
362
|
+
if (texture !== null)
|
|
363
|
+
textures.push({
|
|
364
|
+
slot,
|
|
365
|
+
texture,
|
|
366
|
+
texCoord: numeric(
|
|
367
|
+
record(record(info.extensions).KHR_texture_transform).texCoord,
|
|
368
|
+
numeric(info.texCoord),
|
|
369
|
+
),
|
|
370
|
+
colorSpace,
|
|
371
|
+
});
|
|
372
|
+
};
|
|
373
|
+
add('baseColor', pbr.baseColorTexture, 'srgb');
|
|
374
|
+
add('metallicRoughness', pbr.metallicRoughnessTexture, 'linear');
|
|
375
|
+
add('normal', m.normalTexture, 'linear');
|
|
376
|
+
add('occlusion', m.occlusionTexture, 'linear');
|
|
377
|
+
add('emissive', m.emissiveTexture, 'srgb');
|
|
378
|
+
for (const [extension, value] of Object.entries(record(m.extensions)))
|
|
379
|
+
for (const [name, texture] of Object.entries(record(value)))
|
|
380
|
+
if (name.endsWith('Texture'))
|
|
381
|
+
add(
|
|
382
|
+
`${extension}.${name}`,
|
|
383
|
+
texture,
|
|
384
|
+
name === 'sheenColorTexture' || name === 'specularColorTexture' ? 'srgb' : 'linear',
|
|
385
|
+
);
|
|
386
|
+
return {
|
|
387
|
+
index,
|
|
388
|
+
name: label(m.name),
|
|
389
|
+
alphaMode: label(m.alphaMode) || 'OPAQUE',
|
|
390
|
+
doubleSided: m.doubleSided === true,
|
|
391
|
+
baseColor: pbr.baseColorFactor === undefined ? [1, 1, 1, 1] : numbers(pbr.baseColorFactor),
|
|
392
|
+
metallic: numeric(pbr.metallicFactor, 1),
|
|
393
|
+
roughness: numeric(pbr.roughnessFactor, 1),
|
|
394
|
+
extensions: Object.keys(record(m.extensions)),
|
|
395
|
+
textures,
|
|
396
|
+
};
|
|
397
|
+
}),
|
|
398
|
+
textures = records(d.textures).map((t, index) => ({
|
|
399
|
+
index,
|
|
400
|
+
image: indexOf(t.source),
|
|
401
|
+
sampler: indexOf(t.sampler),
|
|
402
|
+
webp: indexOf(record(record(t.extensions).EXT_texture_webp).source),
|
|
403
|
+
avif: indexOf(record(record(t.extensions).EXT_texture_avif).source),
|
|
404
|
+
basisu: indexOf(record(record(t.extensions).KHR_texture_basisu).source),
|
|
405
|
+
})),
|
|
406
|
+
images: {
|
|
407
|
+
index: number;
|
|
408
|
+
name: string;
|
|
409
|
+
delivery: 'embedded' | 'external';
|
|
410
|
+
mimeType: string | null;
|
|
411
|
+
}[] = records(d.images).map((i, index) => ({
|
|
412
|
+
index,
|
|
413
|
+
name: label(i.name),
|
|
414
|
+
delivery: (typeof i.uri === 'string' && !i.uri.startsWith('data:')
|
|
415
|
+
? 'external'
|
|
416
|
+
: 'embedded') as 'embedded' | 'external',
|
|
417
|
+
mimeType: typeof i.mimeType === 'string' ? i.mimeType : null,
|
|
418
|
+
})),
|
|
419
|
+
animations = records(d.animations).map((a, index) => ({
|
|
420
|
+
index,
|
|
421
|
+
name: label(a.name),
|
|
422
|
+
channels: records(a.channels).map((c) => {
|
|
423
|
+
const target = record(c.target),
|
|
424
|
+
sampler = records(a.samplers)[indexOf(c.sampler) ?? -1];
|
|
425
|
+
return {
|
|
426
|
+
node: indexOf(target.node),
|
|
427
|
+
path: label(target.path),
|
|
428
|
+
interpolation: label(sampler?.interpolation) || 'LINEAR',
|
|
429
|
+
};
|
|
430
|
+
}),
|
|
431
|
+
}));
|
|
432
|
+
const primitives = meshInventory.flatMap((mesh) => mesh.primitives);
|
|
433
|
+
return {
|
|
434
|
+
summary: {
|
|
435
|
+
nodes: nodes.length,
|
|
436
|
+
meshes: meshInventory.length,
|
|
437
|
+
primitives: primitives.length,
|
|
438
|
+
vertices: primitives.reduce((sum, primitive) => sum + primitive.vertices, 0),
|
|
439
|
+
indices: primitives.reduce((sum, primitive) => sum + primitive.indices, 0),
|
|
440
|
+
triangles: primitives.reduce((sum, primitive) => sum + (primitive.triangles ?? 0), 0),
|
|
441
|
+
materials: materials.length,
|
|
442
|
+
textures: textures.length,
|
|
443
|
+
images: images.length,
|
|
444
|
+
animations: animations.length,
|
|
445
|
+
},
|
|
446
|
+
nodes,
|
|
447
|
+
meshes: meshInventory,
|
|
448
|
+
materials,
|
|
449
|
+
textures,
|
|
450
|
+
images,
|
|
451
|
+
animations,
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
export function inspectGltfDocument(
|
|
455
|
+
document: unknown,
|
|
456
|
+
options: GltfInspectOptions = {},
|
|
457
|
+
): ModelCompatibilityReport {
|
|
458
|
+
const d = record(document),
|
|
459
|
+
diagnostics: ModelDiagnostic[] = [];
|
|
460
|
+
const add = (issue: ModelDiagnostic) => diagnostics.push(issue);
|
|
461
|
+
if (record(d.asset).version !== '2.0')
|
|
462
|
+
add({
|
|
463
|
+
code: 'INVALID_DOCUMENT',
|
|
464
|
+
severity: 'error',
|
|
465
|
+
path: '$.asset.version',
|
|
466
|
+
message: 'Expected a glTF 2.0 document.',
|
|
467
|
+
hint: 'Export glTF 2.0 / GLB and run Khronos Validator.',
|
|
468
|
+
});
|
|
469
|
+
if (record(d.asset).minVersion !== undefined && record(d.asset).minVersion !== '2.0')
|
|
470
|
+
add({
|
|
471
|
+
code: 'INVALID_DOCUMENT',
|
|
472
|
+
severity: 'error',
|
|
473
|
+
path: '$.asset.minVersion',
|
|
474
|
+
message: 'The minimum glTF version is not supported.',
|
|
475
|
+
hint: 'Export for the shipped glTF 2.0 importer.',
|
|
476
|
+
});
|
|
477
|
+
const extensionList = (key: string): string[] => {
|
|
478
|
+
const value = d[key];
|
|
479
|
+
if (value === undefined) return [];
|
|
480
|
+
if (
|
|
481
|
+
!Array.isArray(value) ||
|
|
482
|
+
value.some((x) => typeof x !== 'string' || !x) ||
|
|
483
|
+
new Set(value).size !== value.length
|
|
484
|
+
) {
|
|
485
|
+
add({
|
|
486
|
+
code: 'INVALID_EXTENSION_DECLARATION',
|
|
487
|
+
severity: 'error',
|
|
488
|
+
path: `$.${key}`,
|
|
489
|
+
message: 'Extensions must be a unique array of nonempty names.',
|
|
490
|
+
hint: 'Repair the exported extension declaration.',
|
|
491
|
+
});
|
|
492
|
+
return [];
|
|
493
|
+
}
|
|
494
|
+
return value as string[];
|
|
495
|
+
};
|
|
496
|
+
const used = extensionList('extensionsUsed'),
|
|
497
|
+
required = extensionList('extensionsRequired');
|
|
498
|
+
for (const [i, name] of required.entries())
|
|
499
|
+
if (!used.includes(name))
|
|
500
|
+
add({
|
|
501
|
+
code: 'INVALID_EXTENSION_DECLARATION',
|
|
502
|
+
severity: 'error',
|
|
503
|
+
extension: name,
|
|
504
|
+
path: `$.extensionsRequired[${i}]`,
|
|
505
|
+
message: 'Required extension is missing from extensionsUsed.',
|
|
506
|
+
hint: 'Declare every required extension in both arrays.',
|
|
507
|
+
});
|
|
508
|
+
const seen = new WeakSet<object>();
|
|
509
|
+
const collect = (v: unknown, path: string) => {
|
|
510
|
+
if (!v || typeof v !== 'object' || seen.has(v)) return;
|
|
511
|
+
seen.add(v);
|
|
512
|
+
for (const [key, child] of Object.entries(v)) {
|
|
513
|
+
if (key === 'extras') continue;
|
|
514
|
+
if (key === 'extensions')
|
|
515
|
+
for (const name of Object.keys(record(child)))
|
|
516
|
+
if (!used.includes(name))
|
|
517
|
+
add({
|
|
518
|
+
code: 'UNDECLARED_EXTENSION',
|
|
519
|
+
severity: 'error',
|
|
520
|
+
extension: name,
|
|
521
|
+
path: `${path}.extensions.${name}`,
|
|
522
|
+
message: 'Extension payload is not declared in extensionsUsed.',
|
|
523
|
+
hint: 'Repair the export; missing declarations can silently omit a material feature.',
|
|
524
|
+
});
|
|
525
|
+
collect(child, `${path}.${key}`);
|
|
526
|
+
}
|
|
527
|
+
};
|
|
528
|
+
collect(d, '$');
|
|
529
|
+
const extensions = [...new Set([...used, ...required])].map((name) => ({
|
|
530
|
+
name,
|
|
531
|
+
required: required.includes(name),
|
|
532
|
+
implemented: extensionNames.includes(name as (typeof extensionNames)[number]),
|
|
533
|
+
}));
|
|
534
|
+
for (const e of extensions)
|
|
535
|
+
if (decoderExtensions.includes(e.name))
|
|
536
|
+
add({
|
|
537
|
+
code: 'DECODER_REQUIRED',
|
|
538
|
+
severity: e.required ? 'error' : 'warning',
|
|
539
|
+
extension: e.name,
|
|
540
|
+
path: `$.${e.required ? 'extensionsRequired' : 'extensionsUsed'}[${(e.required ? required : used).indexOf(e.name)}]`,
|
|
541
|
+
message: `${e.name} data is read only by a registered Meshopt decoder, before native parsing.`,
|
|
542
|
+
hint: 'Register ZhudaMeshoptModelDecoder with a ZhudaModelDecoderRegistry and pass it with a provider to ZhudaModelLibrary.',
|
|
543
|
+
});
|
|
544
|
+
else if (!e.implemented)
|
|
545
|
+
add({
|
|
546
|
+
code: e.required ? 'UNSUPPORTED_REQUIRED_EXTENSION' : 'UNSUPPORTED_OPTIONAL_EXTENSION',
|
|
547
|
+
severity: e.required ? 'error' : 'warning',
|
|
548
|
+
extension: e.name,
|
|
549
|
+
path: `$.${e.required ? 'extensionsRequired' : 'extensionsUsed'}[${(e.required ? required : used).indexOf(e.name)}]`,
|
|
550
|
+
message: `The shipped importer does not implement ${e.name}.`,
|
|
551
|
+
hint: e.required
|
|
552
|
+
? 'Export a supported representation. Do not remove required declarations to force acceptance.'
|
|
553
|
+
: 'The fallback may omit this feature; inspect the result and record the accepted downgrade.',
|
|
554
|
+
});
|
|
555
|
+
const needsOpaque = used.includes('KHR_materials_transmission');
|
|
556
|
+
if (needsOpaque)
|
|
557
|
+
add({
|
|
558
|
+
code: 'REQUIRED_RENDER_INPUT',
|
|
559
|
+
severity: 'warning',
|
|
560
|
+
extension: 'KHR_materials_transmission',
|
|
561
|
+
path: '$.extensionsUsed',
|
|
562
|
+
message: 'Transmission requires the camera opaque-color pass.',
|
|
563
|
+
hint: 'Use configureSurfacePasses or a showcase mode with opaqueColor enabled, then verify transparent materials.',
|
|
564
|
+
});
|
|
565
|
+
// Integer vertex attributes: LayaAir copies them into floats unscaled.
|
|
566
|
+
try {
|
|
567
|
+
const quantized = quantizedZhudaGltfAccessors(d),
|
|
568
|
+
external = quantized.length ? externalZhudaGltfBuffers(d) : [];
|
|
569
|
+
if (external.length)
|
|
570
|
+
add({
|
|
571
|
+
code: 'EMBEDDED_BUFFER_REQUIRED',
|
|
572
|
+
severity: 'error',
|
|
573
|
+
...(used.includes('KHR_mesh_quantization') ? { extension: 'KHR_mesh_quantization' } : {}),
|
|
574
|
+
path: `$.buffers[${external[0]}].uri`,
|
|
575
|
+
message: `${quantized.length} integer vertex attribute accessor(s) must become floats before native parsing, and buffers[${external.join(', ')}] ${external.length > 1 ? 'are' : 'is'} outside the file: there are no bytes to convert.`,
|
|
576
|
+
hint: 'Pack the model as a self-contained GLB (or embed its buffers), or export float vertex attributes.',
|
|
577
|
+
});
|
|
578
|
+
else if (quantized.length) {
|
|
579
|
+
const accessors = records(d.accessors);
|
|
580
|
+
const floats = quantized.reduce(
|
|
581
|
+
(sum, i) =>
|
|
582
|
+
sum +
|
|
583
|
+
numeric(accessors[i].count) *
|
|
584
|
+
({ VEC2: 2, VEC3: 3, VEC4: 4 }[label(accessors[i].type)] ?? 0) *
|
|
585
|
+
4,
|
|
586
|
+
0,
|
|
587
|
+
);
|
|
588
|
+
add({
|
|
589
|
+
code: 'DEQUANTIZED_ATTRIBUTES',
|
|
590
|
+
severity: 'warning',
|
|
591
|
+
...(used.includes('KHR_mesh_quantization') ? { extension: 'KHR_mesh_quantization' } : {}),
|
|
592
|
+
path: `$.accessors[${quantized[0]}]`,
|
|
593
|
+
message: `${quantized.length} integer vertex attribute accessor(s) become ${floats} bytes of 32-bit floats before native parsing.`,
|
|
594
|
+
hint: 'Download size stays small; GPU vertex memory is that of an unquantized export.',
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
} catch (error) {
|
|
598
|
+
add({
|
|
599
|
+
code: 'INVALID_DOCUMENT',
|
|
600
|
+
severity: 'error',
|
|
601
|
+
path: '$.meshes',
|
|
602
|
+
message: error instanceof Error ? error.message : 'Invalid vertex attribute.',
|
|
603
|
+
hint: 'Repair the export; run Khronos Validator.',
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
// WebP and AVIF texture sources, against this device when it was asked.
|
|
607
|
+
records(d.textures).forEach((texture, i) => {
|
|
608
|
+
const source = resolveZhudaGltfTextureSource(texture, options.imageDecode);
|
|
609
|
+
const offered = ['KHR_texture_basisu', 'EXT_texture_avif', 'EXT_texture_webp'].filter(
|
|
610
|
+
(name) => indexOf(record(record(record(texture).extensions)[name]).source) !== null,
|
|
611
|
+
);
|
|
612
|
+
if (!offered.length) return;
|
|
613
|
+
if (options.imageDecode && source.extension === null) {
|
|
614
|
+
// A KTX 2 image needs a transcoder the game brings, not a decoder of the device.
|
|
615
|
+
const others = source.unavailable.filter((name) => name !== 'KHR_texture_basisu');
|
|
616
|
+
// No answer from a decoder is not a no: say which it was.
|
|
617
|
+
const silent = others.filter((name) =>
|
|
618
|
+
options.imageDecode!.unanswered?.includes(name === 'EXT_texture_avif' ? 'avif' : 'webp'),
|
|
619
|
+
);
|
|
620
|
+
const outcome =
|
|
621
|
+
source.image === null
|
|
622
|
+
? 'the texture has no fallback source'
|
|
623
|
+
: `the fallback image ${source.image} loads`;
|
|
624
|
+
if (source.unavailable.includes('KHR_texture_basisu'))
|
|
625
|
+
add({
|
|
626
|
+
code: 'BASIS_TRANSCODER_MISSING',
|
|
627
|
+
severity: source.image === null && !others.length ? 'error' : 'warning',
|
|
628
|
+
extension: 'KHR_texture_basisu',
|
|
629
|
+
path: `$.textures[${i}]`,
|
|
630
|
+
message: `No Basis transcoder was given for the KTX 2 image of this texture; ${outcome}.`,
|
|
631
|
+
hint: 'Give ZhudaModelLibrary a basisTranscoder (ZhudaBasisTranscoder), or keep a PNG/JPEG fallback source.',
|
|
632
|
+
});
|
|
633
|
+
if (!others.length) return;
|
|
634
|
+
add(
|
|
635
|
+
silent.length
|
|
636
|
+
? {
|
|
637
|
+
code: 'IMAGE_DECODE_UNANSWERED',
|
|
638
|
+
severity: source.image === null ? 'error' : 'warning',
|
|
639
|
+
extension: silent[0],
|
|
640
|
+
path: `$.textures[${i}]`,
|
|
641
|
+
message: `This device's decoder gave no answer for ${silent.join(' or ')} in time; ${outcome}.`,
|
|
642
|
+
hint: 'Load the model again: probeZhudaImageDecode asks an unanswered decoder again on its next call.',
|
|
643
|
+
}
|
|
644
|
+
: {
|
|
645
|
+
code: 'IMAGE_DECODE_UNAVAILABLE',
|
|
646
|
+
severity: source.image === null ? 'error' : 'warning',
|
|
647
|
+
extension: others[0],
|
|
648
|
+
path: `$.textures[${i}]`,
|
|
649
|
+
message:
|
|
650
|
+
source.image === null
|
|
651
|
+
? `This device cannot decode ${others.join(' or ')} and ${outcome}.`
|
|
652
|
+
: `This device cannot decode ${others.join(' or ')}; ${outcome}.`,
|
|
653
|
+
hint: 'Keep a PNG/JPEG fallback source and leave the extension optional for devices without the format.',
|
|
654
|
+
},
|
|
655
|
+
);
|
|
656
|
+
} else if (!options.imageDecode && indexOf(record(texture).source) === null)
|
|
657
|
+
add({
|
|
658
|
+
code: 'IMAGE_DECODE_UNCHECKED',
|
|
659
|
+
severity: 'warning',
|
|
660
|
+
extension: offered[0],
|
|
661
|
+
path: `$.textures[${i}]`,
|
|
662
|
+
message: `The texture has only a ${offered.join('/')} image; whether a device decodes it was not checked.`,
|
|
663
|
+
hint: 'ZhudaModelLibrary asks the device before parsing; pass imageDecode from probeZhudaImageDecode to check here.',
|
|
664
|
+
});
|
|
665
|
+
});
|
|
666
|
+
const lightProblems = readZhudaGltfLights(d);
|
|
667
|
+
for (const problem of lightProblems.problems)
|
|
668
|
+
add({
|
|
669
|
+
code: 'INVALID_LIGHT',
|
|
670
|
+
severity: 'warning',
|
|
671
|
+
extension: 'KHR_lights_punctual',
|
|
672
|
+
path: `$.extensions.KHR_lights_punctual.lights[${problem.index}]`,
|
|
673
|
+
message: `Light ${problem.index}: ${problem.message}; it is not created.`,
|
|
674
|
+
hint: 'Repair the export; the other lights still load.',
|
|
675
|
+
});
|
|
676
|
+
lightProblems.lights.forEach((light, i) => {
|
|
677
|
+
if (!light || light.type === 'directional') return;
|
|
678
|
+
add({
|
|
679
|
+
code: 'LIGHT_APPROXIMATED',
|
|
680
|
+
severity: 'warning',
|
|
681
|
+
extension: 'KHR_lights_punctual',
|
|
682
|
+
path: `$.extensions.KHR_lights_punctual.lights[${i}]`,
|
|
683
|
+
message:
|
|
684
|
+
`A ${light.type} light falls off along LayaAir's range curve, not the inverse square` +
|
|
685
|
+
(light.range === null ? '; its range is derived from its intensity' : '') +
|
|
686
|
+
(light.type === 'spot' ? "; the cone's inner edge is fixed at half its outer angle" : '') +
|
|
687
|
+
'.',
|
|
688
|
+
hint: 'See zhudaGltfLightToLaya for the mapping; lights are created only when instantiate asks for them.',
|
|
689
|
+
});
|
|
690
|
+
});
|
|
691
|
+
for (const problem of readZhudaGltfInstancing(d).problems)
|
|
692
|
+
add({
|
|
693
|
+
code: 'INVALID_INSTANCING',
|
|
694
|
+
severity: 'warning',
|
|
695
|
+
extension: 'EXT_mesh_gpu_instancing',
|
|
696
|
+
path: `$.nodes[${problem.index}].extensions.EXT_mesh_gpu_instancing`,
|
|
697
|
+
message: `Node ${problem.index}: ${problem.message}; its mesh is drawn once, where the node is.`,
|
|
698
|
+
hint: 'Export TRANSLATION and SCALE as VEC3 floats and ROTATION as a VEC4 of floats or normalized bytes or shorts, all of one count, on a node with a mesh and no skin.',
|
|
699
|
+
});
|
|
700
|
+
// The second set of texture coordinates is read for occlusion and for what
|
|
701
|
+
// a surface gives off (a baked map laid out on its own). Anything else is
|
|
702
|
+
// drawn with the first set, which LayaAir says only on the console.
|
|
703
|
+
for (const material of inventory(d).materials)
|
|
704
|
+
for (const texture of material.textures)
|
|
705
|
+
if (
|
|
706
|
+
texture.texCoord !== 0 &&
|
|
707
|
+
!(texture.texCoord === 1 && ['occlusion', 'emissive'].includes(texture.slot))
|
|
708
|
+
)
|
|
709
|
+
add({
|
|
710
|
+
code: 'TEXCOORD_IGNORED',
|
|
711
|
+
severity: 'warning',
|
|
712
|
+
path: `$.materials[${material.index}].${texture.slot}`,
|
|
713
|
+
message: `Material ${material.index}: the ${texture.slot} texture asks for texture coordinates ${texture.texCoord}; it is drawn with the first set.`,
|
|
714
|
+
hint: 'Only occlusion and emissive textures may use TEXCOORD_1. Lay the texture out on TEXCOORD_0, or bake it into one of those two slots.',
|
|
715
|
+
});
|
|
716
|
+
const cameraProblems = readZhudaGltfCameras(d);
|
|
717
|
+
for (const problem of cameraProblems.problems)
|
|
718
|
+
add({
|
|
719
|
+
code: 'INVALID_CAMERA',
|
|
720
|
+
severity: 'warning',
|
|
721
|
+
path: `$.cameras[${problem.index}]`,
|
|
722
|
+
message: `Camera ${problem.index}: ${problem.message}; it is not attached.`,
|
|
723
|
+
hint: 'Repair the export; nodes and other cameras still load.',
|
|
724
|
+
});
|
|
725
|
+
// A node that names a light or camera the file does not have. (One that names
|
|
726
|
+
// an invalid light or camera is covered by that entry's own diagnostic.)
|
|
727
|
+
records(d.nodes).forEach((node, i) => {
|
|
728
|
+
const punctual = record(node.extensions).KHR_lights_punctual;
|
|
729
|
+
if (
|
|
730
|
+
punctual !== undefined &&
|
|
731
|
+
lightProblems.lights[indexOf(record(punctual).light) ?? -1] === undefined
|
|
732
|
+
)
|
|
733
|
+
add({
|
|
734
|
+
code: 'INVALID_LIGHT',
|
|
735
|
+
severity: 'warning',
|
|
736
|
+
extension: 'KHR_lights_punctual',
|
|
737
|
+
path: `$.nodes[${i}].extensions.KHR_lights_punctual.light`,
|
|
738
|
+
message: `Node ${i} names light ${JSON.stringify(record(punctual).light) ?? 'none'}, which the file does not have; no light is created on it.`,
|
|
739
|
+
hint: 'Repair the export; the other lights still load.',
|
|
740
|
+
});
|
|
741
|
+
if (
|
|
742
|
+
node.camera !== undefined &&
|
|
743
|
+
cameraProblems.cameras[indexOf(node.camera) ?? -1] === undefined
|
|
744
|
+
)
|
|
745
|
+
add({
|
|
746
|
+
code: 'INVALID_CAMERA',
|
|
747
|
+
severity: 'warning',
|
|
748
|
+
path: `$.nodes[${i}].camera`,
|
|
749
|
+
message: `Node ${i} names camera ${JSON.stringify(node.camera)}, which the file does not have; none is attached.`,
|
|
750
|
+
hint: 'Repair the export; nodes and other cameras still load.',
|
|
751
|
+
});
|
|
752
|
+
});
|
|
753
|
+
const meshes = records(d.meshes);
|
|
754
|
+
const checkWeights = (v: unknown, count: number, path: string) => {
|
|
755
|
+
if (
|
|
756
|
+
v !== undefined &&
|
|
757
|
+
(!Array.isArray(v) ||
|
|
758
|
+
v.length !== count ||
|
|
759
|
+
v.some((x) => typeof x !== 'number' || !Number.isFinite(x)))
|
|
760
|
+
)
|
|
761
|
+
add({
|
|
762
|
+
code: 'INVALID_MORPH_WEIGHTS',
|
|
763
|
+
severity: 'error',
|
|
764
|
+
path,
|
|
765
|
+
message: 'Morph weights must be finite and match the mesh target count.',
|
|
766
|
+
hint: 'Fix the exporter; node weights override mesh weights and are not clamped.',
|
|
767
|
+
});
|
|
768
|
+
};
|
|
769
|
+
meshes.forEach((m, i) =>
|
|
770
|
+
checkWeights(
|
|
771
|
+
m.weights,
|
|
772
|
+
list(records(m.primitives)[0]?.targets).length,
|
|
773
|
+
`$.meshes[${i}].weights`,
|
|
774
|
+
),
|
|
775
|
+
);
|
|
776
|
+
records(d.nodes).forEach((n, i) =>
|
|
777
|
+
checkWeights(
|
|
778
|
+
n.weights,
|
|
779
|
+
list(records(meshes[indexOf(n.mesh) ?? -1]?.primitives)[0]?.targets).length,
|
|
780
|
+
`$.nodes[${i}].weights`,
|
|
781
|
+
),
|
|
782
|
+
);
|
|
783
|
+
return freeze({
|
|
784
|
+
schemaVersion: 1,
|
|
785
|
+
status: statusOf(diagnostics, needsOpaque),
|
|
786
|
+
validationScope: 'importer-capabilities',
|
|
787
|
+
extensions,
|
|
788
|
+
requiredRenderInputs: needsOpaque ? ['opaqueColor'] : [],
|
|
789
|
+
diagnostics,
|
|
790
|
+
inventory: inventory(d),
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
// A feature the file offers that will not reach the screen.
|
|
794
|
+
const lost: readonly ModelDiagnostic['code'][] = [
|
|
795
|
+
'UNSUPPORTED_OPTIONAL_EXTENSION',
|
|
796
|
+
'DECODER_REQUIRED',
|
|
797
|
+
'IMAGE_DECODE_UNAVAILABLE',
|
|
798
|
+
'BASIS_TRANSCODER_MISSING',
|
|
799
|
+
'IMAGE_DECODE_UNANSWERED',
|
|
800
|
+
'IMAGE_DECODE_FAILED',
|
|
801
|
+
'INVALID_LIGHT',
|
|
802
|
+
'INVALID_CAMERA',
|
|
803
|
+
'INVALID_INSTANCING',
|
|
804
|
+
'INSTANCES_MIRRORED',
|
|
805
|
+
'TEXCOORD_IGNORED',
|
|
806
|
+
];
|
|
807
|
+
function statusOf(
|
|
808
|
+
diagnostics: readonly ModelDiagnostic[],
|
|
809
|
+
needsOpaque: boolean,
|
|
810
|
+
): ModelCompatibilityReport['status'] {
|
|
811
|
+
return diagnostics.some((x) => x.severity === 'error')
|
|
812
|
+
? 'unsupported'
|
|
813
|
+
: diagnostics.some((x) => lost.includes(x.code))
|
|
814
|
+
? 'degraded'
|
|
815
|
+
: needsOpaque
|
|
816
|
+
? 'conditional'
|
|
817
|
+
: 'supported';
|
|
818
|
+
}
|
|
819
|
+
/** Internal: a report with what loading the file found added to it. */
|
|
820
|
+
export function addModelDiagnostics(
|
|
821
|
+
report: ModelCompatibilityReport,
|
|
822
|
+
found: readonly ModelDiagnostic[],
|
|
823
|
+
): ModelCompatibilityReport {
|
|
824
|
+
if (!found.length) return report;
|
|
825
|
+
const diagnostics = [...report.diagnostics, ...found];
|
|
826
|
+
return freeze({
|
|
827
|
+
...report,
|
|
828
|
+
status: statusOf(diagnostics, report.requiredRenderInputs.includes('opaqueColor')),
|
|
829
|
+
diagnostics,
|
|
830
|
+
});
|
|
831
|
+
}
|
|
832
|
+
export class ZhudaModelCompatibilityError extends Error {
|
|
833
|
+
readonly report: ModelCompatibilityReport;
|
|
834
|
+
readonly assetId?: string;
|
|
835
|
+
constructor(report: ModelCompatibilityReport, assetId?: string) {
|
|
836
|
+
super(
|
|
837
|
+
report.diagnostics
|
|
838
|
+
.filter((x) => x.severity === 'error')
|
|
839
|
+
.map((x) => `${x.code} ${x.path}: ${x.message}`)
|
|
840
|
+
.join('; '),
|
|
841
|
+
);
|
|
842
|
+
this.name = 'ZhudaModelCompatibilityError';
|
|
843
|
+
this.report = report;
|
|
844
|
+
this.assetId = assetId;
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
/** Internal shared decode seam. No fetching or native resource allocation. */
|
|
848
|
+
export function readGltfAssetDocument(input: ArrayBuffer | Uint8Array): {
|
|
849
|
+
binary: boolean;
|
|
850
|
+
document: RecordValue;
|
|
851
|
+
} {
|
|
852
|
+
const bytes = input instanceof Uint8Array ? input : new Uint8Array(input);
|
|
853
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
854
|
+
const binary = bytes.byteLength >= 12 && view.getUint32(0, true) === 0x46546c67;
|
|
855
|
+
let json = bytes;
|
|
856
|
+
if (binary) {
|
|
857
|
+
if (
|
|
858
|
+
bytes.byteLength < 20 ||
|
|
859
|
+
view.getUint32(4, true) !== 2 ||
|
|
860
|
+
view.getUint32(8, true) !== bytes.byteLength ||
|
|
861
|
+
view.getUint32(16, true) !== 0x4e4f534a ||
|
|
862
|
+
view.getUint32(12, true) > bytes.byteLength - 20
|
|
863
|
+
)
|
|
864
|
+
throw Error('Invalid GLB header or JSON chunk');
|
|
865
|
+
json = bytes.subarray(20, 20 + view.getUint32(12, true));
|
|
866
|
+
}
|
|
867
|
+
return { binary, document: record(JSON.parse(zhudaUtf8Decode(json))) };
|
|
868
|
+
}
|
|
869
|
+
export function inspectGltfAsset(
|
|
870
|
+
bytes: ArrayBuffer | Uint8Array,
|
|
871
|
+
options: GltfInspectOptions = {},
|
|
872
|
+
): ModelCompatibilityReport {
|
|
873
|
+
try {
|
|
874
|
+
return inspectGltfDocument(readGltfAssetDocument(bytes).document, options);
|
|
875
|
+
} catch (error) {
|
|
876
|
+
const base = inspectGltfDocument({});
|
|
877
|
+
return freeze({
|
|
878
|
+
...base,
|
|
879
|
+
diagnostics: [
|
|
880
|
+
{
|
|
881
|
+
code: 'INVALID_DOCUMENT',
|
|
882
|
+
severity: 'error',
|
|
883
|
+
path: '$',
|
|
884
|
+
message: error instanceof Error ? error.message : 'Invalid model bytes.',
|
|
885
|
+
hint: 'Verify the glTF JSON / GLB container and run Khronos Validator.',
|
|
886
|
+
},
|
|
887
|
+
],
|
|
888
|
+
});
|
|
889
|
+
}
|
|
890
|
+
}
|