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,751 @@
|
|
|
1
|
+
import { destroyLaya342ModelTree } from './Laya342Adapters.ts';
|
|
2
|
+
import {
|
|
3
|
+
readZhudaGltfInstancing,
|
|
4
|
+
resolveZhudaGltfTextureSource,
|
|
5
|
+
zhudaGltfInstanceMatrices,
|
|
6
|
+
type ZhudaImageDecodeSupport,
|
|
7
|
+
type ZhudaLayaLightSettings,
|
|
8
|
+
} from './GltfIntake.ts';
|
|
9
|
+
import { createZhudaBasisTexture, isZhudaKtx2, type ZhudaBasisTranscoder } from './BasisTexture.ts';
|
|
10
|
+
import {
|
|
11
|
+
ZHUDA_EMISSION_UV1_DEFINE,
|
|
12
|
+
ZHUDA_OCCLUSION_UV1_DEFINE,
|
|
13
|
+
ZHUDA_UV1_DEFINE,
|
|
14
|
+
zhudaGltfTexCoord,
|
|
15
|
+
zhudaSecondUvStatus,
|
|
16
|
+
} from './GltfSecondUv.ts';
|
|
17
|
+
const prepared = new WeakSet<object>();
|
|
18
|
+
// The Laya node made for each glTF node by the resource's last create().
|
|
19
|
+
const createdNodes = new WeakMap<object, readonly any[]>();
|
|
20
|
+
// The glTF textures whose picture did not load, per resource.
|
|
21
|
+
const missingTextures = new WeakMap<object, Set<number>>();
|
|
22
|
+
/** The copies a glTF node asks for (`EXT_mesh_gpu_instancing`), read when the file was parsed. */
|
|
23
|
+
export interface Laya342GltfInstances {
|
|
24
|
+
/** Sixteen numbers a copy, column by column, in the node's own space. */
|
|
25
|
+
readonly matrices: Float32Array;
|
|
26
|
+
/** How many copies the file asked for and are not here: their scale turns the mesh inside out. */
|
|
27
|
+
readonly mirrored: number;
|
|
28
|
+
}
|
|
29
|
+
const instances = new WeakMap<object, Map<number, Laya342GltfInstances>>();
|
|
30
|
+
// Textures that asked for the second set of texture coordinates and were not given it, per resource.
|
|
31
|
+
const refusedSecondUv = new WeakMap<object, { material: number; slot: string; reason: string }[]>();
|
|
32
|
+
/** Whether two byte ranges hold the same bytes. */
|
|
33
|
+
function sameBytes(a: Uint8Array, b: Uint8Array): boolean {
|
|
34
|
+
if (a.byteLength !== b.byteLength) return false;
|
|
35
|
+
let i = 0;
|
|
36
|
+
// Whole words first when both ranges start on one (LayaAir's slices do).
|
|
37
|
+
if (a.byteOffset % 4 === 0 && b.byteOffset % 4 === 0) {
|
|
38
|
+
const words = a.byteLength >>> 2,
|
|
39
|
+
wa = new Uint32Array(a.buffer, a.byteOffset, words),
|
|
40
|
+
wb = new Uint32Array(b.buffer, b.byteOffset, words);
|
|
41
|
+
for (let w = 0; w < words; w++) if (wa[w] !== wb[w]) return false;
|
|
42
|
+
i = words * 4;
|
|
43
|
+
}
|
|
44
|
+
for (; i < a.byteLength; i++) if (a[i] !== b[i]) return false;
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
/** Options for one owned glTFResource. */
|
|
48
|
+
export interface Laya342GltfResourceOptions {
|
|
49
|
+
/** This device's WebP/AVIF decoding; picks each texture's image (see resolveZhudaGltfTextureSource). */
|
|
50
|
+
imageDecode?: ZhudaImageDecodeSupport;
|
|
51
|
+
/** Transcodes embedded KTX 2 images (`KHR_texture_basisu`) to a format the graphics card samples. */
|
|
52
|
+
basis?: ZhudaBasisTranscoder;
|
|
53
|
+
}
|
|
54
|
+
/** Version-pinned importer repairs. Applied to one owned glTFResource, never to
|
|
55
|
+
* global prototypes. The native Animator remains the sole pose evaluator. */
|
|
56
|
+
export function prepareLaya342GltfResource(
|
|
57
|
+
resource: any,
|
|
58
|
+
runtime: any,
|
|
59
|
+
options: Laya342GltfResourceOptions = {},
|
|
60
|
+
): void {
|
|
61
|
+
if (prepared.has(resource)) return;
|
|
62
|
+
prepared.add(resource);
|
|
63
|
+
// The embedded pictures this parse has asked for, each with its one load.
|
|
64
|
+
const pictures: { mimeType: string; bytes: Uint8Array; texture: Promise<unknown> }[] = [];
|
|
65
|
+
// EXT_texture_webp / EXT_texture_avif: the native loader reads only
|
|
66
|
+
// textures[i].source. Point it at the image this device decodes, in this
|
|
67
|
+
// resource's own parsed document, before any texture (core or extension slot) loads.
|
|
68
|
+
const loadTextures = resource.loadTextures;
|
|
69
|
+
if (typeof loadTextures === 'function')
|
|
70
|
+
resource.loadTextures = function (...args: any[]) {
|
|
71
|
+
(this._data?.textures ?? []).forEach((texture: any, i: number) => {
|
|
72
|
+
const source = resolveZhudaGltfTextureSource(texture, options.imageDecode);
|
|
73
|
+
if (source.image !== null) texture.source = source.image;
|
|
74
|
+
else if (source.unavailable.length)
|
|
75
|
+
throw Error(`glTF textures[${i}] has no image this device can decode.`);
|
|
76
|
+
});
|
|
77
|
+
// Every slot asks for its picture inside this call: once they have all
|
|
78
|
+
// loaded, the bytes kept to recognise a repeat are let go.
|
|
79
|
+
const forget = () => (pictures.length = 0);
|
|
80
|
+
let loading: unknown;
|
|
81
|
+
try {
|
|
82
|
+
loading = loadTextures.apply(this, args);
|
|
83
|
+
} catch (error) {
|
|
84
|
+
forget();
|
|
85
|
+
throw error;
|
|
86
|
+
}
|
|
87
|
+
if (typeof (loading as any)?.then !== 'function') return (forget(), loading);
|
|
88
|
+
return (loading as Promise<unknown>).then(
|
|
89
|
+
(textures) => (forget(), textures),
|
|
90
|
+
(error) => {
|
|
91
|
+
forget();
|
|
92
|
+
throw error;
|
|
93
|
+
},
|
|
94
|
+
);
|
|
95
|
+
};
|
|
96
|
+
// A picture that does not load leaves its slots empty in LayaAir, which only
|
|
97
|
+
// warns on the console. Remember which textures, for the model's report.
|
|
98
|
+
const fromInfo = resource.loadTextureFromInfo;
|
|
99
|
+
if (typeof fromInfo === 'function')
|
|
100
|
+
resource.loadTextureFromInfo = function (info: any, ...rest: any[]) {
|
|
101
|
+
return Promise.resolve(fromInfo.call(this, info, ...rest)).then((texture: unknown) => {
|
|
102
|
+
if (!texture && Number.isInteger(info?.index)) {
|
|
103
|
+
const missing = missingTextures.get(this) ?? new Set<number>();
|
|
104
|
+
missingTextures.set(this, missing.add(info.index));
|
|
105
|
+
}
|
|
106
|
+
return texture;
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
// Embedded images: the native loader base64-encodes each one into a data URL
|
|
110
|
+
// on the main thread (a string about 1.33 times the picture) for the browser
|
|
111
|
+
// to decode again. Hand the same bytes to the same loader as a Blob URL
|
|
112
|
+
// instead, and revoke it once the picture has loaded.
|
|
113
|
+
const fromBuffer = resource.loadTextureFromBuffer;
|
|
114
|
+
const urls = (globalThis as any).URL;
|
|
115
|
+
const loader = runtime?.ILaya?.loader ?? runtime?.loader;
|
|
116
|
+
if (
|
|
117
|
+
typeof fromBuffer === 'function' &&
|
|
118
|
+
typeof (globalThis as any).Blob === 'function' &&
|
|
119
|
+
typeof urls?.createObjectURL === 'function' &&
|
|
120
|
+
typeof loader?.load === 'function' &&
|
|
121
|
+
runtime?.Loader?.TEXTURE2D
|
|
122
|
+
)
|
|
123
|
+
resource.loadTextureFromBuffer = function (
|
|
124
|
+
buffer: ArrayBuffer | ArrayBufferView,
|
|
125
|
+
mimeType: string,
|
|
126
|
+
constructParams: unknown,
|
|
127
|
+
propertyParams: unknown,
|
|
128
|
+
progress?: { createCallback(): (progress: number) => void },
|
|
129
|
+
) {
|
|
130
|
+
const bytes = ArrayBuffer.isView(buffer)
|
|
131
|
+
? new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength)
|
|
132
|
+
: new Uint8Array(buffer);
|
|
133
|
+
// One picture, one texture. LayaAir asks once per material slot, not once
|
|
134
|
+
// per picture. Its data URL was the same for the same bytes, so its
|
|
135
|
+
// loader answered a repeat with the texture it already had (and with the
|
|
136
|
+
// first slot's sampler and colour space, as here). A Blob URL is new each
|
|
137
|
+
// time: recognise the repeat here, by the bytes themselves.
|
|
138
|
+
const repeat = pictures.find((p) => p.mimeType === mimeType && sameBytes(p.bytes, bytes));
|
|
139
|
+
if (repeat) {
|
|
140
|
+
const done = progress?.createCallback();
|
|
141
|
+
return done ? repeat.texture.then((texture) => (done(1), texture)) : repeat.texture;
|
|
142
|
+
}
|
|
143
|
+
if (mimeType === 'image/ktx2' || isZhudaKtx2(bytes)) {
|
|
144
|
+
// A KTX 2 image: no browser decodes it. Transcoded here and uploaded
|
|
145
|
+
// compressed; a failure leaves the slot empty, as LayaAir's own
|
|
146
|
+
// failed loads do, and the model's report names the texture.
|
|
147
|
+
const done = progress?.createCallback();
|
|
148
|
+
const params = constructParams as unknown[] | null | undefined;
|
|
149
|
+
const made = Promise.resolve().then(() => {
|
|
150
|
+
let made: any = null;
|
|
151
|
+
try {
|
|
152
|
+
if (!options.basis) throw Error('no Basis transcoder was given to the model library');
|
|
153
|
+
made = createZhudaBasisTexture(
|
|
154
|
+
options.basis,
|
|
155
|
+
bytes,
|
|
156
|
+
// LayaAir's construct parameters: index 5 says whether the slot reads sRGB.
|
|
157
|
+
{ role: params?.[5] ? 'color' : 'data' },
|
|
158
|
+
runtime,
|
|
159
|
+
);
|
|
160
|
+
if (propertyParams) made.setProperties?.(propertyParams);
|
|
161
|
+
} catch (error) {
|
|
162
|
+
console.warn(
|
|
163
|
+
`[zhuda] KTX 2 image did not load: ${error instanceof Error ? error.message : String(error)}`,
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
done?.(1);
|
|
167
|
+
return made;
|
|
168
|
+
});
|
|
169
|
+
pictures.push({ mimeType, bytes, texture: made });
|
|
170
|
+
return made;
|
|
171
|
+
}
|
|
172
|
+
const url = urls.createObjectURL(
|
|
173
|
+
new Blob([bytes as Uint8Array<ArrayBuffer>], {
|
|
174
|
+
type: mimeType || 'application/octet-stream',
|
|
175
|
+
}),
|
|
176
|
+
);
|
|
177
|
+
const revoke = () => urls.revokeObjectURL(url);
|
|
178
|
+
let texture: Promise<unknown>;
|
|
179
|
+
try {
|
|
180
|
+
texture = Promise.resolve(
|
|
181
|
+
loader.load(
|
|
182
|
+
// Not kept in LayaAir's URL cache: this URL is revoked and never
|
|
183
|
+
// asked for again, and a failed load would stay there as a null.
|
|
184
|
+
{ url, constructParams, propertyParams, cache: false },
|
|
185
|
+
runtime.Loader.TEXTURE2D,
|
|
186
|
+
progress?.createCallback(),
|
|
187
|
+
),
|
|
188
|
+
).then(
|
|
189
|
+
// LayaAir 3.4.2 answers a failed load with null rather than rejecting.
|
|
190
|
+
(loaded: unknown) => (revoke(), loaded),
|
|
191
|
+
(error: unknown) => {
|
|
192
|
+
revoke();
|
|
193
|
+
throw error;
|
|
194
|
+
},
|
|
195
|
+
);
|
|
196
|
+
} catch (error) {
|
|
197
|
+
revoke();
|
|
198
|
+
throw error;
|
|
199
|
+
}
|
|
200
|
+
pictures.push({ mimeType, bytes, texture });
|
|
201
|
+
return texture;
|
|
202
|
+
};
|
|
203
|
+
const loadNodes = resource.loadNodes;
|
|
204
|
+
if (typeof loadNodes === 'function')
|
|
205
|
+
resource.loadNodes = function (...args: any[]) {
|
|
206
|
+
const result = loadNodes.apply(this, args);
|
|
207
|
+
createdNodes.set(this, [...(this._nodes ?? [])]);
|
|
208
|
+
// EXT_mesh_gpu_instancing: LayaAir makes the node and draws its mesh
|
|
209
|
+
// once. Read where the copies go; whoever mounts the model draws them.
|
|
210
|
+
const found = new Map<number, Laya342GltfInstances>();
|
|
211
|
+
for (const item of readZhudaGltfInstancing(this._data).instancing) {
|
|
212
|
+
const read = (accessor: number | null) =>
|
|
213
|
+
accessor === null ? null : this.getBufferwithAccessorIndex(accessor);
|
|
214
|
+
const component =
|
|
215
|
+
item.rotation === null ? 5126 : this._data.accessors[item.rotation].componentType;
|
|
216
|
+
let made: ReturnType<typeof zhudaGltfInstanceMatrices>;
|
|
217
|
+
try {
|
|
218
|
+
made = zhudaGltfInstanceMatrices(
|
|
219
|
+
item.count,
|
|
220
|
+
read(item.translation),
|
|
221
|
+
read(item.rotation),
|
|
222
|
+
read(item.scale),
|
|
223
|
+
component === 5120 ? 1 / 127 : component === 5122 ? 1 / 32767 : 1,
|
|
224
|
+
);
|
|
225
|
+
} catch (error) {
|
|
226
|
+
throw Error(
|
|
227
|
+
`glTF node ${item.index} (EXT_mesh_gpu_instancing): ${error instanceof Error ? error.message : String(error)}`,
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
// One draw has one facing: a copy turned inside out is left out and reported.
|
|
231
|
+
let matrices = made.matrices;
|
|
232
|
+
if (made.mirrored.length) {
|
|
233
|
+
const skip = new Set(made.mirrored);
|
|
234
|
+
matrices = new Float32Array((item.count - skip.size) * 16);
|
|
235
|
+
let k = 0;
|
|
236
|
+
for (let i = 0; i < item.count; i++)
|
|
237
|
+
if (!skip.has(i)) matrices.set(made.matrices.subarray(i * 16, i * 16 + 16), k++ * 16);
|
|
238
|
+
}
|
|
239
|
+
found.set(item.index, { matrices, mirrored: made.mirrored.length });
|
|
240
|
+
}
|
|
241
|
+
instances.set(this, found);
|
|
242
|
+
return result;
|
|
243
|
+
};
|
|
244
|
+
// The texture references read by the second set of texture coordinates:
|
|
245
|
+
// LayaAir's loader warns of every one that is not the first.
|
|
246
|
+
const secondSet = new WeakSet<object>();
|
|
247
|
+
const withInfo = resource.getTextureWithInfo;
|
|
248
|
+
if (typeof withInfo === 'function')
|
|
249
|
+
resource.getTextureWithInfo = function (info: any, ...rest: unknown[]) {
|
|
250
|
+
if (info && secondSet.has(info)) return this._textures?.[info.index];
|
|
251
|
+
return withInfo.call(this, info, ...rest);
|
|
252
|
+
};
|
|
253
|
+
const createMaterial = resource.createMaterial;
|
|
254
|
+
if (typeof createMaterial === 'function')
|
|
255
|
+
resource.createMaterial = function (definition: any) {
|
|
256
|
+
// Occlusion and emission may be laid out on TEXCOORD_1 (a baked map).
|
|
257
|
+
const slots = [
|
|
258
|
+
{
|
|
259
|
+
info: definition?.occlusionTexture,
|
|
260
|
+
slot: 'occlusion',
|
|
261
|
+
define: ZHUDA_OCCLUSION_UV1_DEFINE,
|
|
262
|
+
},
|
|
263
|
+
{ info: definition?.emissiveTexture, slot: 'emissive', define: ZHUDA_EMISSION_UV1_DEFINE },
|
|
264
|
+
].filter((item) => item.info && zhudaGltfTexCoord(item.info) === 1);
|
|
265
|
+
const status = zhudaSecondUvStatus(runtime);
|
|
266
|
+
if (status.ready) for (const item of slots) secondSet.add(item.info);
|
|
267
|
+
const material = createMaterial.call(this, definition);
|
|
268
|
+
if (slots.length) {
|
|
269
|
+
if (status.ready) {
|
|
270
|
+
const define = (name: string) =>
|
|
271
|
+
material.addDefine(runtime.Shader3D.getDefineByName(name));
|
|
272
|
+
define(ZHUDA_UV1_DEFINE);
|
|
273
|
+
for (const item of slots) define(item.define);
|
|
274
|
+
} else {
|
|
275
|
+
const index = (this._data?.materials ?? []).indexOf(definition);
|
|
276
|
+
const refused = refusedSecondUv.get(this) ?? [];
|
|
277
|
+
refusedSecondUv.set(this, refused);
|
|
278
|
+
for (const item of slots)
|
|
279
|
+
refused.push({ material: index, slot: item.slot, reason: status.reason ?? 'unknown' });
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
// Native KHR_materials_unlit mutates the color returned by its getter, then
|
|
283
|
+
// assigns that same object. WebGPU's equality fast path skips conversion,
|
|
284
|
+
// leaving the linear GPU uniform white. Repair this owned imported material.
|
|
285
|
+
if (
|
|
286
|
+
definition.extensions?.KHR_materials_unlit &&
|
|
287
|
+
definition.pbrMetallicRoughness?.baseColorFactor
|
|
288
|
+
) {
|
|
289
|
+
const linear = new runtime.Color();
|
|
290
|
+
material.albedoColor.toLinear(linear);
|
|
291
|
+
material.setVector4(
|
|
292
|
+
'u_AlbedoColor',
|
|
293
|
+
new runtime.Vector4(linear.r, linear.g, linear.b, linear.a),
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
return material;
|
|
297
|
+
};
|
|
298
|
+
// glTF stores COLOR_0 as three or four components, as floats or as normalized
|
|
299
|
+
// bytes or shorts. The native loader hands the raw array to a four-float
|
|
300
|
+
// vertex element: a 16-bit colour arrives 65535 times too bright and a
|
|
301
|
+
// three-component one is read out of step. Convert to four floats.
|
|
302
|
+
const attribute = resource.getArrributeBuffer;
|
|
303
|
+
if (typeof attribute === 'function')
|
|
304
|
+
resource.getArrributeBuffer = function (index: number, name: string, map: any, names: any) {
|
|
305
|
+
const raw = attribute.call(this, index, name, map, names);
|
|
306
|
+
if (!raw || name !== 'COLOR') return raw;
|
|
307
|
+
const fixed = zhudaGltfColors(raw, this._data?.accessors?.[index]);
|
|
308
|
+
map.set(name, fixed);
|
|
309
|
+
return fixed;
|
|
310
|
+
};
|
|
311
|
+
// A mesh's primitives go into one vertex buffer laid out as the first one's:
|
|
312
|
+
// parseMeshwithSubMeshData takes the first primitive's attribute list and
|
|
313
|
+
// fillMeshBuffers packs each primitive's own attributes in order. A primitive
|
|
314
|
+
// without an attribute the first has (a body with vertex colours, eyes
|
|
315
|
+
// without) is written out of step: its weights land in the colour slot and its
|
|
316
|
+
// skin collapses, its texture coordinates become colours. Give every primitive
|
|
317
|
+
// of the mesh the same attributes first.
|
|
318
|
+
const parseMesh = resource.parseMeshwithSubMeshData;
|
|
319
|
+
if (typeof parseMesh === 'function')
|
|
320
|
+
resource.parseMeshwithSubMeshData = function (subMeshes: any[], mesh: any) {
|
|
321
|
+
unifyLaya342SubMeshAttributes(subMeshes);
|
|
322
|
+
return parseMesh.call(this, subMeshes, mesh);
|
|
323
|
+
};
|
|
324
|
+
// A skin of more than 24 joints is cut into pieces, a draw each in every
|
|
325
|
+
// pass: the loader walks the triangles in the file's order, gathers the
|
|
326
|
+
// joints they name and starts a piece when the next triangle would bring
|
|
327
|
+
// the count past 24. How many pieces that is depends on the order alone (a
|
|
328
|
+
// skin of 36 joints was cut into 1,065). The triangles are put in an order
|
|
329
|
+
// that cuts into few, and the joints a vertex names without weighting it
|
|
330
|
+
// are not counted.
|
|
331
|
+
const split = resource.splitSubMeshByBonesCount;
|
|
332
|
+
if (typeof split === 'function')
|
|
333
|
+
resource.splitSubMeshByBonesCount = function (attributes: any, ...rest: any[]) {
|
|
334
|
+
const indices = rest[1],
|
|
335
|
+
joints = attributes?.get?.('BLENDINDICES'),
|
|
336
|
+
weights = attributes?.get?.('BLENDWEIGHT');
|
|
337
|
+
if (indices?.length && joints?.length && weights?.length === joints.length)
|
|
338
|
+
orderLaya342SkinTriangles(indices, joints, weights);
|
|
339
|
+
return split.call(this, attributes, ...rest);
|
|
340
|
+
};
|
|
341
|
+
for (const method of ['createMeshSprite3D', 'createSkinnedMeshSprite3D']) {
|
|
342
|
+
const original = resource[method];
|
|
343
|
+
if (typeof original !== 'function') continue;
|
|
344
|
+
resource[method] = function (definition: any) {
|
|
345
|
+
const node = original.call(this, definition);
|
|
346
|
+
if (definition.weights !== undefined) {
|
|
347
|
+
const renderer =
|
|
348
|
+
node.getComponent(runtime.SkinnedMeshRenderer) || node.getComponent(runtime.MeshRenderer);
|
|
349
|
+
const morphs = node.getComponent(runtime.MeshFilter)?.sharedMesh?.morphTargetData;
|
|
350
|
+
if (!renderer || !morphs || definition.weights.length !== morphs.channelCount) {
|
|
351
|
+
destroyLaya342ModelTree(node, runtime);
|
|
352
|
+
throw Error('glTF node morph weights do not match its mesh.');
|
|
353
|
+
}
|
|
354
|
+
for (let i = 0; i < morphs.channelCount; i++)
|
|
355
|
+
renderer.setMorphChannelWeight(
|
|
356
|
+
morphs.getMorphChannelbyIndex(i).name,
|
|
357
|
+
definition.weights[i],
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
return node;
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
const createClip = resource.createAnimatorClip;
|
|
364
|
+
if (typeof createClip !== 'function') return;
|
|
365
|
+
resource.createAnimatorClip = function (animation: any, root: any) {
|
|
366
|
+
const tracks: {
|
|
367
|
+
paths: string[];
|
|
368
|
+
owner: string;
|
|
369
|
+
names: string[];
|
|
370
|
+
times: ArrayLike<number>;
|
|
371
|
+
values: ArrayLike<number>;
|
|
372
|
+
}[] = [];
|
|
373
|
+
for (const channel of animation.channels) {
|
|
374
|
+
const sampler = animation.samplers[channel.sampler];
|
|
375
|
+
if (channel.target.path !== 'weights' || sampler.interpolation !== 'CUBICSPLINE') continue;
|
|
376
|
+
const node = this._nodes[channel.target.node];
|
|
377
|
+
const morphs = node?.getComponent(runtime.MeshFilter)?.sharedMesh?.morphTargetData;
|
|
378
|
+
if (!morphs) throw Error('CUBICSPLINE weights require a morph target mesh.');
|
|
379
|
+
const times = this.getBufferwithAccessorIndex(sampler.input),
|
|
380
|
+
values = this.getBufferwithAccessorIndex(sampler.output);
|
|
381
|
+
const count = morphs.channelCount;
|
|
382
|
+
if (
|
|
383
|
+
!count ||
|
|
384
|
+
!times ||
|
|
385
|
+
times.length < 1 ||
|
|
386
|
+
!values ||
|
|
387
|
+
values.length !== times.length * count * 3
|
|
388
|
+
)
|
|
389
|
+
throw Error('Invalid CUBICSPLINE morph sample count.');
|
|
390
|
+
for (let i = 0; i < times.length; i++)
|
|
391
|
+
if (!Number.isFinite(times[i]) || times[i] < 0 || (i > 0 && times[i] <= times[i - 1]))
|
|
392
|
+
throw Error('Invalid CUBICSPLINE morph sample times.');
|
|
393
|
+
for (let i = 0; i < values.length; i++)
|
|
394
|
+
if (!Number.isFinite(values[i])) throw Error('Invalid CUBICSPLINE morph sample value.');
|
|
395
|
+
tracks.push({
|
|
396
|
+
paths: this.getAnimationPath(root, node),
|
|
397
|
+
owner: node.getComponent(runtime.SkinnedMeshRenderer)
|
|
398
|
+
? 'SkinnedMeshRenderer'
|
|
399
|
+
: 'MeshRenderer',
|
|
400
|
+
names: Array.from({ length: count }, (_, i) => morphs.getMorphChannelbyIndex(i).name),
|
|
401
|
+
times,
|
|
402
|
+
values,
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
// The native 3.4.2 path drops these channels. Keep all native transform and
|
|
406
|
+
// LINEAR/STEP paths, then append exact cubic scalar tracks to that same clip.
|
|
407
|
+
const clip = createClip.call(this, animation, root);
|
|
408
|
+
indexLaya342ClipNodes(clip);
|
|
409
|
+
try {
|
|
410
|
+
for (const track of tracks)
|
|
411
|
+
for (let morph = 0; morph < track.names.length; morph++) {
|
|
412
|
+
const name = track.names[morph],
|
|
413
|
+
index = clip._nodes.count,
|
|
414
|
+
node = new runtime.KeyframeNode();
|
|
415
|
+
clip._nodes.count = index + 1;
|
|
416
|
+
clip._nodes.setNodeByIndex(index, node);
|
|
417
|
+
node._indexInList = index;
|
|
418
|
+
node.type = 0;
|
|
419
|
+
node._setOwnerPathCount(track.paths.length);
|
|
420
|
+
track.paths.forEach((p, i) => node._setOwnerPathByIndex(i, p));
|
|
421
|
+
const ownerPath = node._joinOwnerPath('/');
|
|
422
|
+
(clip._nodesMap[ownerPath] ||= []).push(node);
|
|
423
|
+
node.propertyOwner = track.owner;
|
|
424
|
+
node._setPropertyCount(2);
|
|
425
|
+
node._setPropertyByIndex(0, 'morphTargetValues');
|
|
426
|
+
node._setPropertyByIndex(1, name);
|
|
427
|
+
node.fullPath = `${ownerPath}.${track.owner}.morphTargetValues.${name}`;
|
|
428
|
+
clip._nodesDic[node.fullPath] = node;
|
|
429
|
+
node.callbackFunData = '_changeMorphTargetValue';
|
|
430
|
+
node.callParams = [name];
|
|
431
|
+
node.propertyChangePath = 'morphTargetValues';
|
|
432
|
+
for (let key = 0; key < track.times.length; key++) {
|
|
433
|
+
const frame = new runtime.FloatKeyframe(),
|
|
434
|
+
start = key * track.names.length * 3;
|
|
435
|
+
frame.time = track.times[key];
|
|
436
|
+
frame.inTangent = track.values[start + morph];
|
|
437
|
+
frame.value = track.values[start + track.names.length + morph];
|
|
438
|
+
frame.outTangent = track.values[start + track.names.length * 2 + morph];
|
|
439
|
+
node._setKeyframeByIndex(key, frame);
|
|
440
|
+
}
|
|
441
|
+
clip._duration = Math.max(clip._duration, track.times[track.times.length - 1]);
|
|
442
|
+
}
|
|
443
|
+
return clip;
|
|
444
|
+
} catch (error) {
|
|
445
|
+
clip.destroy();
|
|
446
|
+
throw error;
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/** LayaAir 3.4.2's glTF reader files every keyframe node of a clip under its full path as the
|
|
452
|
+
* path string itself; its `.lani` reader files the node. `Animator.crossFade` reads
|
|
453
|
+
* `_indexInList` from that entry to pair the two clips' nodes, finds none on a string, and so
|
|
454
|
+
* blends a glTF model towards its bind pose and back instead of from one clip to the other.
|
|
455
|
+
* File the nodes. Returns how many entries were corrected. */
|
|
456
|
+
export function indexLaya342ClipNodes(clip: any): number {
|
|
457
|
+
const nodes = clip?._nodes,
|
|
458
|
+
index = clip?._nodesDic;
|
|
459
|
+
if (!nodes || !index || typeof nodes.getNodeByIndex !== 'function') return 0;
|
|
460
|
+
let corrected = 0;
|
|
461
|
+
for (let i = 0; i < nodes.count; i++) {
|
|
462
|
+
const node = nodes.getNodeByIndex(i);
|
|
463
|
+
if (!node || typeof node.fullPath !== 'string' || index[node.fullPath] === node) continue;
|
|
464
|
+
index[node.fullPath] = node;
|
|
465
|
+
corrected++;
|
|
466
|
+
}
|
|
467
|
+
return corrected;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/** Native MeshRenderer cloning does not consistently preserve authored weights.
|
|
471
|
+
* Copy values through the public setter to retain independent dirty tracking. */
|
|
472
|
+
export function copyLaya342MorphWeights(source: any, target: any, runtime: any): void {
|
|
473
|
+
const a = source.getComponent?.(runtime.MeshRenderer),
|
|
474
|
+
b = target.getComponent?.(runtime.MeshRenderer);
|
|
475
|
+
if (a && b)
|
|
476
|
+
for (const [name, weight] of Object.entries(a.morphTargetValues ?? {}))
|
|
477
|
+
b.setMorphChannelWeight(name, weight);
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/** Native create() retains its partial trees on failure. Retire their components
|
|
481
|
+
* before the caller releases the parsed resource and its shared dependencies. */
|
|
482
|
+
export function createLaya342ModelTemplate(resource: any, runtime: any): Laya.Sprite3D {
|
|
483
|
+
try {
|
|
484
|
+
return resource.create();
|
|
485
|
+
} catch (error) {
|
|
486
|
+
const nodes = new Set<any>(),
|
|
487
|
+
clips = new Set<any>();
|
|
488
|
+
const collect = (node: any) => {
|
|
489
|
+
if (!node || nodes.has(node)) return;
|
|
490
|
+
nodes.add(node);
|
|
491
|
+
const animator = runtime.Animator && node.getComponent?.(runtime.Animator);
|
|
492
|
+
if (animator)
|
|
493
|
+
for (let layer = 0; layer < animator.controllerLayerCount; layer++)
|
|
494
|
+
for (const state of animator.getControllerLayer(layer).states)
|
|
495
|
+
if (state.clip) clips.add(state.clip);
|
|
496
|
+
for (let i = 0; i < (node.numChildren || 0); i++) collect(node.getChildAt(i));
|
|
497
|
+
};
|
|
498
|
+
for (const node of [...(resource._scenes ?? []), ...(resource._nodes ?? [])]) collect(node);
|
|
499
|
+
for (const node of nodes) if (!node.destroyed) destroyLaya342ModelTree(node, runtime);
|
|
500
|
+
for (const clip of clips) if (!clip.destroyed && clip.referenceCount === 0) clip.destroy();
|
|
501
|
+
if (resource._scenes) resource._scenes.length = 0;
|
|
502
|
+
if (resource._nodes) resource._nodes.length = 0;
|
|
503
|
+
throw error;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* The glTF texture indices whose picture did not load or decode while the
|
|
509
|
+
* resource was parsed: LayaAir left their material slots empty.
|
|
510
|
+
*/
|
|
511
|
+
export function laya342GltfMissingTextures(resource: object): readonly number[] {
|
|
512
|
+
return [...(missingTextures.get(resource) ?? [])].sort((a, b) => a - b);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* The occlusion and emissive textures that asked for the second set of
|
|
517
|
+
* texture coordinates and are drawn with the first, because the shader
|
|
518
|
+
* text that reads it could not be put in place.
|
|
519
|
+
*/
|
|
520
|
+
export function laya342GltfRefusedSecondUv(
|
|
521
|
+
resource: object,
|
|
522
|
+
): readonly { material: number; slot: string; reason: string }[] {
|
|
523
|
+
return refusedSecondUv.get(resource) ?? [];
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
/** The copies each glTF node asks for (`EXT_mesh_gpu_instancing`), by node index. */
|
|
527
|
+
export function laya342GltfInstances(resource: object): ReadonlyMap<number, Laya342GltfInstances> {
|
|
528
|
+
return instances.get(resource) ?? new Map();
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/** The Laya node made for each glTF node index by the resource's last create(). */
|
|
532
|
+
export function laya342GltfNodes(resource: object): readonly any[] {
|
|
533
|
+
return createdNodes.get(resource) ?? [];
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/** Adds a LayaAir light component, set from `zhudaGltfLightToLaya`, to a node.
|
|
537
|
+
* It points down the node's -Z, as glTF's does, and casts no shadow. */
|
|
538
|
+
export function createLaya342GltfLight(
|
|
539
|
+
node: any,
|
|
540
|
+
settings: ZhudaLayaLightSettings,
|
|
541
|
+
runtime: any,
|
|
542
|
+
): any {
|
|
543
|
+
const type =
|
|
544
|
+
settings.kind === 'directional'
|
|
545
|
+
? runtime.DirectionLightCom
|
|
546
|
+
: settings.kind === 'spot'
|
|
547
|
+
? runtime.SpotLightCom
|
|
548
|
+
: runtime.PointLightCom;
|
|
549
|
+
if (!type) throw Error(`LayaAir has no ${settings.kind} light component here`);
|
|
550
|
+
const light = node.addComponent(type);
|
|
551
|
+
light.color = new runtime.Color(...settings.color, 1);
|
|
552
|
+
light.intensity = settings.intensity;
|
|
553
|
+
if (settings.range !== null) light.range = settings.range;
|
|
554
|
+
if (settings.spotAngleDeg !== null) light.spotAngle = settings.spotAngleDeg;
|
|
555
|
+
return light;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/** The most joints LayaAir 3.4.2 gives one draw of a skinned mesh. */
|
|
559
|
+
const LAYA342_JOINTS_A_DRAW = 24;
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* How many pieces LayaAir 3.4.2's glTF loader cuts a skinned primitive into
|
|
563
|
+
* for these triangles in this order: it gathers the joints the triangles
|
|
564
|
+
* name, all four a vertex, and starts a piece when one more triangle would
|
|
565
|
+
* bring them past 24. One for a skin that names 24 joints or fewer. Pure.
|
|
566
|
+
*/
|
|
567
|
+
export function countLaya342SkinPieces(
|
|
568
|
+
indices: ArrayLike<number>,
|
|
569
|
+
joints: ArrayLike<number>,
|
|
570
|
+
): number {
|
|
571
|
+
let pieces = 1,
|
|
572
|
+
held = new Set<number>();
|
|
573
|
+
for (let t = 0; t + 2 < indices.length; t += 3) {
|
|
574
|
+
const triangle = new Set<number>();
|
|
575
|
+
for (let k = 0; k < 3; k++)
|
|
576
|
+
for (let j = 0; j < 4; j++) triangle.add(joints[indices[t + k] * 4 + j]);
|
|
577
|
+
const both = new Set([...held, ...triangle]);
|
|
578
|
+
if (both.size > LAYA342_JOINTS_A_DRAW) {
|
|
579
|
+
pieces++;
|
|
580
|
+
held = triangle;
|
|
581
|
+
} else held = both;
|
|
582
|
+
}
|
|
583
|
+
return pieces;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* Puts a skinned primitive's triangles in an order LayaAir 3.4.2 cuts into
|
|
588
|
+
* few pieces, in place, and returns the pieces before and after. Two things
|
|
589
|
+
* are done, neither of which changes what is drawn:
|
|
590
|
+
*
|
|
591
|
+
* - a joint a vertex names with no weight is replaced by the joint that
|
|
592
|
+
* vertex is weighted to most (`joints` is changed in place): the loader
|
|
593
|
+
* counts a named joint whether it is weighted or not;
|
|
594
|
+
* - the triangles are gathered a piece at a time: every triangle whose
|
|
595
|
+
* joints the piece already holds, then the one that adds the fewest, until
|
|
596
|
+
* no triangle fits in 24.
|
|
597
|
+
*
|
|
598
|
+
* The order is left as it is when it is already cut as little, or when the
|
|
599
|
+
* skin names 24 joints or fewer.
|
|
600
|
+
*/
|
|
601
|
+
export function orderLaya342SkinTriangles(
|
|
602
|
+
indices: { [index: number]: number; readonly length: number },
|
|
603
|
+
joints: { [index: number]: number; readonly length: number },
|
|
604
|
+
weights: ArrayLike<number>,
|
|
605
|
+
): { before: number; after: number } {
|
|
606
|
+
const vertices = Math.floor(joints.length / 4);
|
|
607
|
+
for (let v = 0; v < vertices; v++) {
|
|
608
|
+
let most = 0;
|
|
609
|
+
for (let j = 1; j < 4; j++) if (weights[v * 4 + j] > weights[v * 4 + most]) most = j;
|
|
610
|
+
if (!(weights[v * 4 + most] > 0)) continue;
|
|
611
|
+
for (let j = 0; j < 4; j++)
|
|
612
|
+
if (!(weights[v * 4 + j] > 0)) joints[v * 4 + j] = joints[v * 4 + most];
|
|
613
|
+
}
|
|
614
|
+
const before = countLaya342SkinPieces(indices, joints);
|
|
615
|
+
if (before === 1) return { before, after: 1 };
|
|
616
|
+
let highest = 0;
|
|
617
|
+
for (let i = 0; i < joints.length; i++) if (joints[i] > highest) highest = joints[i];
|
|
618
|
+
const words = (highest >> 5) + 1,
|
|
619
|
+
count = Math.floor(indices.length / 3);
|
|
620
|
+
// Each triangle's joints as bits.
|
|
621
|
+
const bits = new Uint32Array(count * words);
|
|
622
|
+
for (let t = 0; t < count; t++)
|
|
623
|
+
for (let k = 0; k < 3; k++)
|
|
624
|
+
for (let j = 0; j < 4; j++) {
|
|
625
|
+
const joint = joints[indices[t * 3 + k] * 4 + j];
|
|
626
|
+
bits[t * words + (joint >> 5)] |= 1 << (joint & 31);
|
|
627
|
+
}
|
|
628
|
+
const ones = (value: number) => {
|
|
629
|
+
value -= (value >>> 1) & 0x55555555;
|
|
630
|
+
value = (value & 0x33333333) + ((value >>> 2) & 0x33333333);
|
|
631
|
+
return (((value + (value >>> 4)) & 0x0f0f0f0f) * 0x01010101) >>> 24;
|
|
632
|
+
};
|
|
633
|
+
const order = new Uint32Array(count),
|
|
634
|
+
placed = new Uint8Array(count),
|
|
635
|
+
held = new Uint32Array(words);
|
|
636
|
+
let done = 0,
|
|
637
|
+
heldCount = 0;
|
|
638
|
+
while (done < count) {
|
|
639
|
+
// Everything the piece's joints already cover, and the nearest of what is left.
|
|
640
|
+
let nearest = -1,
|
|
641
|
+
fewest = Infinity;
|
|
642
|
+
for (let t = 0; t < count; t++) {
|
|
643
|
+
if (placed[t]) continue;
|
|
644
|
+
let added = 0;
|
|
645
|
+
for (let w = 0; w < words; w++) added += ones(bits[t * words + w] & ~held[w]);
|
|
646
|
+
if (added === 0) {
|
|
647
|
+
placed[t] = 1;
|
|
648
|
+
order[done++] = t;
|
|
649
|
+
} else if (added < fewest) {
|
|
650
|
+
fewest = added;
|
|
651
|
+
nearest = t;
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
if (nearest < 0) break;
|
|
655
|
+
// The nearest joins the piece when it fits; otherwise a new piece starts with it.
|
|
656
|
+
if (heldCount + fewest > LAYA342_JOINTS_A_DRAW) {
|
|
657
|
+
held.fill(0);
|
|
658
|
+
heldCount = 0;
|
|
659
|
+
for (let w = 0; w < words; w++) heldCount += ones(bits[nearest * words + w]);
|
|
660
|
+
} else heldCount += fewest;
|
|
661
|
+
for (let w = 0; w < words; w++) held[w] |= bits[nearest * words + w];
|
|
662
|
+
}
|
|
663
|
+
const sorted = new Uint32Array(count * 3);
|
|
664
|
+
for (let i = 0; i < count; i++)
|
|
665
|
+
for (let k = 0; k < 3; k++) sorted[i * 3 + k] = indices[order[i] * 3 + k];
|
|
666
|
+
const after = countLaya342SkinPieces(sorted, joints);
|
|
667
|
+
if (after >= before) return { before, after: before };
|
|
668
|
+
for (let i = 0; i < sorted.length; i++) indices[i] = sorted[i];
|
|
669
|
+
return { before, after };
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
/** The vertex attributes of LayaAir 3.4.2's glTF loader, in the order it lists and packs them. */
|
|
673
|
+
const LAYA342_ATTRIBUTES = [
|
|
674
|
+
'POSITION',
|
|
675
|
+
'NORMAL',
|
|
676
|
+
'COLOR',
|
|
677
|
+
'UV',
|
|
678
|
+
'UV1',
|
|
679
|
+
'BLENDWEIGHT',
|
|
680
|
+
'BLENDINDICES',
|
|
681
|
+
'TANGENT',
|
|
682
|
+
] as const;
|
|
683
|
+
const repeat = (values: number[], n: number) => {
|
|
684
|
+
const out = new Float32Array(values.length * n);
|
|
685
|
+
for (let i = 0; i < n; i++) out.set(values, i * values.length);
|
|
686
|
+
return out;
|
|
687
|
+
};
|
|
688
|
+
/** What a primitive lacking an attribute its mesh's others have gets, for n vertices. */
|
|
689
|
+
const LAYA342_DEFAULTS: Record<string, (n: number) => ArrayLike<number>> = {
|
|
690
|
+
NORMAL: (n) => repeat([0, 1, 0], n),
|
|
691
|
+
// White: a vertex colour multiplies, so this changes nothing.
|
|
692
|
+
COLOR: (n) => new Float32Array(n * 4).fill(1),
|
|
693
|
+
UV: (n) => new Float32Array(n * 2),
|
|
694
|
+
UV1: (n) => new Float32Array(n * 2),
|
|
695
|
+
// The whole weight on the first joint of its batch.
|
|
696
|
+
BLENDWEIGHT: (n) => repeat([1, 0, 0, 0], n),
|
|
697
|
+
BLENDINDICES: (n) => new Uint8Array(n * 4),
|
|
698
|
+
TANGENT: (n) => repeat([1, 0, 0, 1], n),
|
|
699
|
+
};
|
|
700
|
+
/**
|
|
701
|
+
* Gives every primitive (sub-mesh) of one glTF mesh the same vertex attributes,
|
|
702
|
+
* the union of theirs, before LayaAir 3.4.2 packs them into one buffer laid out
|
|
703
|
+
* as the first one's. A missing attribute gets a value that changes nothing (see
|
|
704
|
+
* LAYA342_DEFAULTS). Returns how many attributes were added; leaves the list as
|
|
705
|
+
* it was when it holds a name this function does not know.
|
|
706
|
+
*/
|
|
707
|
+
export function unifyLaya342SubMeshAttributes(subMeshes: any[]): number {
|
|
708
|
+
if (!Array.isArray(subMeshes) || subMeshes.length < 2) return 0;
|
|
709
|
+
const names = subMeshes.map((s) =>
|
|
710
|
+
String(s?.vertexDecler ?? '')
|
|
711
|
+
.split(',')
|
|
712
|
+
.filter(Boolean),
|
|
713
|
+
);
|
|
714
|
+
const known = new Set<string>(LAYA342_ATTRIBUTES);
|
|
715
|
+
if (names.some((list) => list.some((name) => !known.has(name)))) return 0;
|
|
716
|
+
const union = LAYA342_ATTRIBUTES.filter((name) => names.some((list) => list.includes(name)));
|
|
717
|
+
const declaration = union.join(',');
|
|
718
|
+
let added = 0;
|
|
719
|
+
subMeshes.forEach((s, i) => {
|
|
720
|
+
if (names[i].join(',') === declaration) return;
|
|
721
|
+
for (const name of union)
|
|
722
|
+
if (!s.attributeMap.has(name)) {
|
|
723
|
+
s.attributeMap.set(name, LAYA342_DEFAULTS[name](s.vertexCount));
|
|
724
|
+
added++;
|
|
725
|
+
}
|
|
726
|
+
s.vertexDecler = declaration;
|
|
727
|
+
});
|
|
728
|
+
return added;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
/**
|
|
732
|
+
* A colour accessor's values as RGBA floats in 0..1 (see glTF 2.0, COLOR_0), for
|
|
733
|
+
* LayaAir's vertex colour: glTF's colour is linear, and LayaAir's shader raises
|
|
734
|
+
* the red, green and blue it is given to the power 2.2 (it takes them as display
|
|
735
|
+
* values), so they are handed over raised to 1/2.2. Alpha is passed as it is.
|
|
736
|
+
*/
|
|
737
|
+
export function zhudaGltfColors(
|
|
738
|
+
raw: ArrayLike<number>,
|
|
739
|
+
accessor: { type?: string; componentType?: number; count?: number } | undefined,
|
|
740
|
+
): Float32Array {
|
|
741
|
+
const size = accessor?.type === 'VEC3' ? 3 : 4;
|
|
742
|
+
const scale = { 5121: 1 / 255, 5123: 1 / 65535 }[accessor?.componentType ?? 5126] ?? 1;
|
|
743
|
+
const count = Math.floor(raw.length / size);
|
|
744
|
+
const out = new Float32Array(count * 4);
|
|
745
|
+
for (let i = 0; i < count; i++) {
|
|
746
|
+
for (let c = 0; c < 3; c++)
|
|
747
|
+
out[i * 4 + c] = Math.min(1, Math.max(0, raw[i * size + c] * scale)) ** (1 / 2.2);
|
|
748
|
+
out[i * 4 + 3] = size === 4 ? raw[i * size + 3] * scale : 1;
|
|
749
|
+
}
|
|
750
|
+
return out;
|
|
751
|
+
}
|