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,115 @@
|
|
|
1
|
+
import { validateVfxMaterial } from '../effects/VfxMaterial.ts';
|
|
2
|
+
import type { VfxMaterialSpec } from '../effects/VfxMaterial.ts';
|
|
3
|
+
import { validateParticleExtras } from './ParticleExtras.ts';
|
|
4
|
+
import { validateParticleEffect } from './ParticleTypes.ts';
|
|
5
|
+
import type { ParticleEmitterSpec, ParticleState } from './ParticleTypes.ts';
|
|
6
|
+
|
|
7
|
+
export interface ParticleVector3 {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
z: number;
|
|
11
|
+
}
|
|
12
|
+
export interface ParticleQuaternion {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
z: number;
|
|
16
|
+
w: number;
|
|
17
|
+
}
|
|
18
|
+
export interface ParticleTransform3D extends ParticleVector3 {
|
|
19
|
+
rotation: ParticleQuaternion;
|
|
20
|
+
}
|
|
21
|
+
export interface ParticleView3D {
|
|
22
|
+
position: ParticleVector3;
|
|
23
|
+
right: ParticleVector3;
|
|
24
|
+
up: ParticleVector3;
|
|
25
|
+
forward: ParticleVector3;
|
|
26
|
+
}
|
|
27
|
+
export interface ParticleState3D extends ParticleState {
|
|
28
|
+
z: number;
|
|
29
|
+
vz: number;
|
|
30
|
+
}
|
|
31
|
+
export type ParticleShape3D =
|
|
32
|
+
| { type: 'point' }
|
|
33
|
+
| { type: 'box'; width: number; height: number; depth: number }
|
|
34
|
+
| { type: 'sphere'; radius: number; surface?: boolean };
|
|
35
|
+
export interface ParticleEmitterSpec3D
|
|
36
|
+
extends Omit<ParticleEmitterSpec, 'shape' | 'angle' | 'acceleration'> {
|
|
37
|
+
material?: VfxMaterialSpec;
|
|
38
|
+
shape: ParticleShape3D;
|
|
39
|
+
direction: ParticleVector3;
|
|
40
|
+
/** Half-angle in radians. Directions are sampled uniformly within this cone. */
|
|
41
|
+
spread: number;
|
|
42
|
+
acceleration?: ParticleVector3;
|
|
43
|
+
velocityInheritance?: number;
|
|
44
|
+
billboard?: 'camera' | 'velocity' | 'ground';
|
|
45
|
+
}
|
|
46
|
+
export interface ParticleEffectSpec3D {
|
|
47
|
+
schemaVersion: 1;
|
|
48
|
+
dimension: 3;
|
|
49
|
+
emitters: ParticleEmitterSpec3D[];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function rotateParticleVector3(
|
|
53
|
+
v: ParticleVector3,
|
|
54
|
+
q: ParticleQuaternion,
|
|
55
|
+
out: ParticleVector3,
|
|
56
|
+
): void {
|
|
57
|
+
const tx = 2 * (q.y * v.z - q.z * v.y),
|
|
58
|
+
ty = 2 * (q.z * v.x - q.x * v.z),
|
|
59
|
+
tz = 2 * (q.x * v.y - q.y * v.x);
|
|
60
|
+
out.x = v.x + q.w * tx + q.y * tz - q.z * ty;
|
|
61
|
+
out.y = v.y + q.w * ty + q.z * tx - q.x * tz;
|
|
62
|
+
out.z = v.z + q.w * tz + q.x * ty - q.y * tx;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function validateParticleEffect3D(value: unknown): string[] {
|
|
66
|
+
const spec = value as ParticleEffectSpec3D;
|
|
67
|
+
if (
|
|
68
|
+
!spec ||
|
|
69
|
+
spec.dimension !== 3 ||
|
|
70
|
+
spec.schemaVersion !== 1 ||
|
|
71
|
+
!Array.isArray(spec.emitters) ||
|
|
72
|
+
!spec.emitters.length
|
|
73
|
+
) {
|
|
74
|
+
return ['Expected dimension: 3, schemaVersion: 1 and a non-empty emitters array.'];
|
|
75
|
+
}
|
|
76
|
+
// Reuse the shared timing, pool, range and lifetime-curve contract.
|
|
77
|
+
const issues = validateParticleEffect({
|
|
78
|
+
schemaVersion: 1,
|
|
79
|
+
emitters: spec.emitters.map(
|
|
80
|
+
(e) => e && { ...e, collision: undefined, angle: 0, shape: { type: 'point' } },
|
|
81
|
+
),
|
|
82
|
+
});
|
|
83
|
+
const vector = (v: ParticleVector3) => v && [v.x, v.y, v.z].every(Number.isFinite);
|
|
84
|
+
for (const e of spec.emitters) {
|
|
85
|
+
if (!e || typeof e !== 'object') continue;
|
|
86
|
+
issues.push(...validateParticleExtras(e, 3).map((message) => `${e.id}: ${message}`));
|
|
87
|
+
if (!vector(e.direction) || Math.hypot(e.direction.x, e.direction.y, e.direction.z) < 1e-8)
|
|
88
|
+
issues.push(`${e.id}: direction must be a finite non-zero vector.`);
|
|
89
|
+
if (!Number.isFinite(e.spread) || e.spread < 0 || e.spread > Math.PI)
|
|
90
|
+
issues.push(`${e.id}: spread must be 0..PI radians.`);
|
|
91
|
+
if (e.acceleration && !vector(e.acceleration))
|
|
92
|
+
issues.push(`${e.id}: acceleration must have finite XYZ components.`);
|
|
93
|
+
if (
|
|
94
|
+
e.velocityInheritance !== undefined &&
|
|
95
|
+
(!Number.isFinite(e.velocityInheritance) ||
|
|
96
|
+
e.velocityInheritance < 0 ||
|
|
97
|
+
e.velocityInheritance > 2)
|
|
98
|
+
)
|
|
99
|
+
issues.push(`${e.id}: velocityInheritance must be 0..2.`);
|
|
100
|
+
if (e.billboard !== undefined && !['camera', 'velocity', 'ground'].includes(e.billboard))
|
|
101
|
+
issues.push(`${e.id}: invalid billboard mode.`);
|
|
102
|
+
if (e.material) issues.push(...validateVfxMaterial(e.material));
|
|
103
|
+
const shape = e.shape;
|
|
104
|
+
if (!shape || !['point', 'box', 'sphere'].includes(shape.type))
|
|
105
|
+
issues.push(`${e.id}: invalid 3D shape.`);
|
|
106
|
+
else if (
|
|
107
|
+
shape.type === 'box' &&
|
|
108
|
+
![shape.width, shape.height, shape.depth].every((v) => Number.isFinite(v) && v >= 0)
|
|
109
|
+
)
|
|
110
|
+
issues.push(`${e.id}: invalid 3D box dimensions.`);
|
|
111
|
+
else if (shape.type === 'sphere' && (!Number.isFinite(shape.radius) || shape.radius < 0))
|
|
112
|
+
issues.push(`${e.id}: invalid sphere radius.`);
|
|
113
|
+
}
|
|
114
|
+
return issues;
|
|
115
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# 2D / 3D particles and ribbon trails
|
|
2
|
+
|
|
3
|
+
The public ESM/CJS SDK exports a renderer-independent CPU simulator, Laya 3.4.2 textured mesh renderers, world-space trail history and an attack/sustain/release envelope. Ready effects are built on them: twenty 2D presets (`ZHUDA_EFFECT_PRESETS_2D`, played by `ZhudaEffect2D`) and eighteen 3D ones (`ZHUDA_EFFECT_PRESETS_3D`, `ZhudaEffect3D`), on sprites made by a program; see the [effects README](../effects/README.md). Scenes, the application's own textures and presets, and gameplay belong to the consuming application.
|
|
4
|
+
|
|
5
|
+
## Minimal integration
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import {
|
|
9
|
+
ZhudaParticleSystem,
|
|
10
|
+
ZhudaLayaParticleRenderer,
|
|
11
|
+
validateParticleEffect,
|
|
12
|
+
} from 'zhuda-laya-engine';
|
|
13
|
+
import type { ParticleEffectSpec } from 'zhuda-laya-engine';
|
|
14
|
+
|
|
15
|
+
const effect: ParticleEffectSpec = {
|
|
16
|
+
schemaVersion: 1,
|
|
17
|
+
emitters: [
|
|
18
|
+
{
|
|
19
|
+
id: 'example',
|
|
20
|
+
texture: 'external-texture-key',
|
|
21
|
+
maxParticles: 256,
|
|
22
|
+
seed: 42,
|
|
23
|
+
space: 'world',
|
|
24
|
+
blend: 'alpha',
|
|
25
|
+
shape: { type: 'point' },
|
|
26
|
+
rate: 30,
|
|
27
|
+
lifetime: [0.5, 1],
|
|
28
|
+
speed: [20, 50],
|
|
29
|
+
angle: [-1.8, -1.3],
|
|
30
|
+
size: [8, 16],
|
|
31
|
+
sizeOverLife: [
|
|
32
|
+
{ time: 0, value: 0.5 },
|
|
33
|
+
{ time: 1, value: 1.5 },
|
|
34
|
+
],
|
|
35
|
+
alphaOverLife: [
|
|
36
|
+
{ time: 0, value: 0 },
|
|
37
|
+
{ time: 0.1, value: 0.8 },
|
|
38
|
+
{ time: 1, value: 0 },
|
|
39
|
+
],
|
|
40
|
+
colorOverLife: [
|
|
41
|
+
{ time: 0, color: '#ffffff' },
|
|
42
|
+
{ time: 1, color: '#8899aa' },
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
};
|
|
47
|
+
const issues = validateParticleEffect(effect);
|
|
48
|
+
if (issues.length) throw new Error(issues.join('\n'));
|
|
49
|
+
|
|
50
|
+
// Boot Laya and load textures before constructing renderers.
|
|
51
|
+
const system = new ZhudaParticleSystem(effect.emitters[0]);
|
|
52
|
+
const renderer = new ZhudaLayaParticleRenderer(system, parentSprite, (key) =>
|
|
53
|
+
loadedTextures.get(key),
|
|
54
|
+
);
|
|
55
|
+
system.setTransform(100, 200, 0);
|
|
56
|
+
system.play();
|
|
57
|
+
// In the application's update loop:
|
|
58
|
+
system.update(deltaSeconds);
|
|
59
|
+
renderer.render();
|
|
60
|
+
// Graceful stop: continue update/render until aliveCount is zero.
|
|
61
|
+
system.stop();
|
|
62
|
+
// Immediate teardown: system.stop(true); renderer.dispose();
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
The application owns scheduling. Update each simulator once per application tick and submit each renderer once per rendered frame. `dispose()` destroys only its own sprite, never shared textures or the parent. Detach/dispose renderers when leaving a scene.
|
|
66
|
+
|
|
67
|
+
## Descriptor contract
|
|
68
|
+
|
|
69
|
+
Units are pixels, seconds and radians. Angles follow canvas axes: +X right, +Y down. Ranges are a number or `[min, max]`; curves linearly interpolate ordered keys with normalized life `time` in 0..1. Color keys use `#rrggbb`. Size curves multiply the initial size; alpha curves stay within 0..1.
|
|
70
|
+
|
|
71
|
+
Shapes are `point`, `box` (width/height), and `circle` (radius, optional edge). `rate` emits per second; `rateOverDistance` emits per pixel along interpolated emitter movement. Optional `bursts: [{time,count}]` are relative to `play()`. Optional `duration` stops emission; `loop` repeats that duration. Looping durations must be at least 1/120 second. Bursts beyond duration are rejected. No duration means indefinite emission, regardless of `loop`.
|
|
72
|
+
|
|
73
|
+
Other optional controls: rotation/angularVelocity ranges, acceleration, exponential drag, deterministic sinusoidal turbulence, stretch along the quad's X axis, velocity alignment, size/alpha/color over life. `intensity` scales emission (clamped 0..2), without changing already emitted particles. Use independent seeds for independent emitters.
|
|
74
|
+
|
|
75
|
+
`space: 'world'` leaves old particles at their world positions when the emitter moves or turns. `local` particles follow the current emitter transform. Coordinates in both modes are relative to the renderer parent's coordinate system; the parent is responsible for camera transforms. Acceleration and turbulence use the chosen simulation space.
|
|
76
|
+
|
|
77
|
+
`play()` starts a new emission cycle while retaining living particles and PRNG state. `play(true)` clears the simulation and resets its seed. `clear()` resets pool/time/seed while preserving the emitting flag. `stop()` drains naturally; `stop(true)` clears immediately. Update stopped systems to age out their particles. `forEach` borrows pooled state; use `snapshot()` only when a retained copy is needed.
|
|
78
|
+
|
|
79
|
+
Validation checks descriptor structure and numeric constraints. It does not resolve texture keys or verify appearance. MCP `validate_particle_effect` accepts `{effect: descriptor}` with the same validation and has no scene or filesystem dependency.
|
|
80
|
+
|
|
81
|
+
## Timing, capacity and rendering
|
|
82
|
+
|
|
83
|
+
Simulation uses a fixed 1/120 second step. Identical seeds and sampled input sequences produce repeatable simulation; a moving emitter's path must also be sampled consistently. Each `update` accepts at most 0.25 seconds; `droppedSeconds` reports excess elapsed time. This bounds catch-up work after a suspended tab and intentionally does not fast-forward missed time.
|
|
84
|
+
|
|
85
|
+
Each emitter preallocates at most `maxParticles` (1..16383) objects. Excess emissions increment `droppedParticles`. Capacity bounds CPU work for oversized bursts as well as memory. Integrators should bound aggregate emitter budgets for their target devices.
|
|
86
|
+
|
|
87
|
+
The Laya renderer groups particles into lifetime bands (default 12, configurable 1..64), without a sprite per particle. Position, rotation and size update per particle; alpha and color use each band's midpoint, so these curves are quantized. More bands trade CPU/storage for smoother color/alpha. Buffers cost approximately `76 × capacity × lifeBands` bytes, plus the particle pool and runtime mesh storage. A submitted mesh is not necessarily a WebGL draw call; Laya may combine compatible meshes. `submittedBatches` reports submissions only.
|
|
88
|
+
|
|
89
|
+
Texture resolution is supplied externally. Particle renderers use the texture UV rectangle and render a square quad before stretch; author transparent margins and aspect into the texture or the stretch parameter. Do not mutate a live descriptor; construct a new simulator/renderer after editing it. Pool storage and precomputed bands are sized at construction.
|
|
90
|
+
|
|
91
|
+
This module implements 2D and 3D CPU particles, billboards, mesh trails, bounded admission limits, atlas flipbooks and plane collisions with collision/death callbacks. The effects package adds dissolve/mask/noise, UV distortion/refraction, soft-particle camera passes and bloom configuration; `EffectDirector` adds timelines and attachments, while `EffectBudget` adds global particle/coverage admission. The SDK does not include a graphical node editor or application-specific scene authoring: use the separate Particle Lab as a reference or build your own editor. Large translucent sprites can be GPU fill-rate limited even with few draw calls, and the profiler reports WebGL submissions while GPU completion time remains unmeasured.
|
|
92
|
+
|
|
93
|
+
## World-space ribbons and envelopes
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
import { ZhudaRibbonTrail, ZhudaLayaRibbonRenderer, ZhudaEffectEnvelope } from 'zhuda-laya-engine';
|
|
97
|
+
const trail = new ZhudaRibbonTrail({
|
|
98
|
+
maxPoints: 128,
|
|
99
|
+
lifetime: 0.8,
|
|
100
|
+
width: 20,
|
|
101
|
+
minDistance: 2,
|
|
102
|
+
teleportDistance: 200,
|
|
103
|
+
});
|
|
104
|
+
const ribbon = new ZhudaLayaRibbonRenderer(trail, parentSprite, fullRibbonTexture);
|
|
105
|
+
const envelope = new ZhudaEffectEnvelope(0.15, 0.45);
|
|
106
|
+
envelope.start();
|
|
107
|
+
envelope.update(deltaSeconds);
|
|
108
|
+
system.intensity = envelope.value;
|
|
109
|
+
trail.update(deltaSeconds, emitterX, emitterY, shouldAddPoints);
|
|
110
|
+
ribbon.render();
|
|
111
|
+
// On stop: envelope.stop(); system.stop(); continue updating particles and trail.
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Trail history uses a bounded ring buffer. Points expire by age; short movements are ignored; teleports break the path. The mesh follows the stored path with bounded width, preventing unbounded spikes at sharp turns. The optional width curve multiplies width; its default tapers from 1 to 0. Use a full, untrimmed texture: U is normalized point age (0 fresh, 1 expired), V crosses the width. Transparent edges and an age fade belong in that texture. Ribbon textures currently do not support atlas regions. Continue `update(..., false)` after stopping so old points expire. `clear()` resets immediately; `dispose()` releases the renderer sprite.
|
|
115
|
+
|
|
116
|
+
`ZhudaEffectEnvelope` exposes idle/attack/sustain/release. `start(strength)` and `stop()` can interrupt a transition; `setStrength(0..2)` adjusts the sustain target. It controls intensity or other application parameters; it does not implicitly stop or clear simulators.
|
|
117
|
+
|
|
118
|
+
## Verification
|
|
119
|
+
|
|
120
|
+
`tests/particles.test.mjs` checks 30/60/120 fps replay, capacity/recycling, moving emitter spaces, distance emission, non-integral duration loops, graceful drain, invalid input, bounded catch-up, curved trails/teleports/expiry, envelopes and renderer ownership. Public SDK integration tests check ESM and CJS exports. `npm run verify:effects-2d` is the first real draw of `ZhudaLayaParticleRenderer` in this repository (WebGL, the `2d` browser profile, through the ready 2D presets): its pictures must be premultiplied, and sRGB as Laya's own 2D pictures are, or a soft sprite shows a square halo with `lighter` or brighter edges than its alpha. Scene validation of an application's own effects belongs in the consuming application.
|
|
121
|
+
|
|
122
|
+
## 3D simulation and rendering
|
|
123
|
+
|
|
124
|
+
`ZhudaParticleSystem3D` uses XYZ scene units, seconds and radians. A descriptor has `schemaVersion: 1, dimension: 3`, a `direction: {x,y,z}` and cone half-angle `spread` (0..PI). Shapes are point, XYZ box and sphere (optional surface sampling). Directions are sampled uniformly within the cone. The timing, curves, pool capacity and stop/replay rules above also apply in 3D. `validateParticleEffect3D` checks the 3D descriptor; MCP selects it when `dimension` is 3.
|
|
125
|
+
|
|
126
|
+
`setTransform(x,y,z,quaternion?,velocity?)` normalizes a finite nonzero quaternion. World particles receive the emitter orientation at birth; local particles retain local coordinates and follow the current transform during rendering. Acceleration and turbulence operate in the selected simulation space. `velocityInheritance` (0..2) adds supplied world emitter velocity at birth for world particles. The integrator must supply velocity; the simulator does not estimate it from noisy transforms. `billboard` selects camera, projected velocity or world XZ ground alignment. For 3D use `billboard: 'velocity'` instead of the inherited 2D `alignToVelocity` setting.
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
import { ZhudaParticleSystem3D, ZhudaLayaParticleRenderer3D } from 'zhuda-laya-engine';
|
|
130
|
+
const system = new ZhudaParticleSystem3D({
|
|
131
|
+
id: 'xyz',
|
|
132
|
+
texture: 'external-key',
|
|
133
|
+
seed: 7,
|
|
134
|
+
maxParticles: 256,
|
|
135
|
+
space: 'world',
|
|
136
|
+
blend: 'additive',
|
|
137
|
+
shape: { type: 'sphere', radius: 0.1 },
|
|
138
|
+
direction: { x: 0, y: 0, z: 1 },
|
|
139
|
+
spread: 0.15,
|
|
140
|
+
rate: 40,
|
|
141
|
+
lifetime: [0.2, 0.5],
|
|
142
|
+
speed: [2, 4],
|
|
143
|
+
size: [0.05, 0.2],
|
|
144
|
+
billboard: 'velocity',
|
|
145
|
+
});
|
|
146
|
+
// Boot the core + 3d features and load WebGL 3D modules before construction.
|
|
147
|
+
const renderer = new ZhudaLayaParticleRenderer3D(system, identitySceneRoot, resolveTexture);
|
|
148
|
+
system.play();
|
|
149
|
+
system.setTransform(x, y, z, orientation, velocity);
|
|
150
|
+
system.update(deltaSeconds);
|
|
151
|
+
renderer.render(camera);
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
The scene parent must have an identity world transform: geometry is submitted in world coordinates. The Laya 3.4.2 adapter uses its version-specific `PrimitiveMesh._createMesh` helper and `UnlitMaterial`, depth tests against opaque scene geometry (LEQUAL), disables transparent depth writes and renders both faces. Alpha particles sort back to front within each emitter; sorting across emitters or intersecting translucent surfaces is approximate. Additive particles do not require sorting. Each emitter is one mesh submission; actual draw calls depend on the scene/runtime. `ZhudaParticleMesh3D` also exposes renderer-independent POSITION(3), COLOR(4), UV(2) geometry.
|
|
155
|
+
|
|
156
|
+
Textures must be full, untrimmed `Texture2D` or full 2D textures backed by one. 2D and 3D particle descriptors can select an atlas `textureRect` and flipbook frame layout; the 3D mesh adapter still expects the resolved texture to be a full `Texture2D`. Upload straight alpha textures for SRC_ALPHA blending; repeat U for scrolling paths. Textures remain owned by the application. Each billboard reserves `156 * maxParticles` bytes of typed geometry (144 vertex + 12 index bytes per particle), in addition to the CPU pool, sorting references and native mesh storage. Buffers remain capacity sized; inactive triangles are degenerate. Large transparent surfaces may be limited by GPU fill rate.
|
|
157
|
+
|
|
158
|
+
## 3D historical trails and authored flow paths
|
|
159
|
+
|
|
160
|
+
`ZhudaRibbonTrail3D` stores world XYZ history, uses scene-unit widths and distances, and supports the same expiry and teleport behavior as its 2D counterpart. Call `update(dt,x,y,z,emitting)` and submit through `ZhudaLayaRibbonRenderer3D(trail, identitySceneRoot, texture, color?, blend?)`. Normals face the camera and preserve orientation across neighboring segments. Each historical point uses 72 vertex bytes plus approximately 12 index bytes; unused indices are degenerate to prevent triangles connecting to unused origin vertices.
|
|
161
|
+
|
|
162
|
+
`ZhudaRibbonPath3D` accepts an application-authored XYZ centerline, useful for flows along any moving surface. The application supplies curved world points through `setPoints(points, widthDirections?)`; optional per-point width directions keep the band aligned to an authored surface instead of facing the camera. Directions are projected perpendicular to the tangent and normalized; the engine contains no vehicle or gameplay geometry. Width, alpha and color curves use normalized arc length. `visibleStart` and `visibleEnd` define a normalized reveal window; positive `edgeFade` softens both boundaries. Increasing `visibleEnd` reveals from the first point; increasing `visibleStart` erases in the same direction. `uvTiles` and `uvOffset` animate texture flow independently of reveal. Reuse supplied point objects to avoid application allocations. Clear a path or pass zero renderer opacity when invisible. Authored paths also reserve arc-length storage and optional width direction objects, in addition to the geometry buffers. Renderer disposal detaches shared textures before Laya material destruction so dependency cleanup cannot destroy application textures.
|
|
163
|
+
|
|
164
|
+
```ts
|
|
165
|
+
const flow = new ZhudaRibbonPath3D({
|
|
166
|
+
maxPoints: 64,
|
|
167
|
+
width: 0.4,
|
|
168
|
+
alphaOverPath: [
|
|
169
|
+
{ time: 0, value: 0 },
|
|
170
|
+
{ time: 0.15, value: 1 },
|
|
171
|
+
{ time: 1, value: 0 },
|
|
172
|
+
],
|
|
173
|
+
});
|
|
174
|
+
flow.setPoints(applicationWorldPoints);
|
|
175
|
+
flow.visibleEnd = revealProgress;
|
|
176
|
+
flow.uvOffset = -elapsedSeconds;
|
|
177
|
+
const ribbon = new ZhudaLayaRibbonRenderer3D(flow, identitySceneRoot, fullFlowTexture);
|
|
178
|
+
ribbon.render(camera, strength);
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
`tests/particles3d.test.mjs` checks XYZ replay, quaternion/local/world transforms, inherited velocity, pooling, duration/distance emission, billboard sorting, partial ribbon indices, bounded reveal geometry and renderer ownership. Browser appearance and target-device performance require application verification.
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { sampleParticleColor, sampleParticleCurve } from './ParticleTypes.ts';
|
|
2
|
+
import type { ParticleColorKey, ParticleCurveKey } from './ParticleTypes.ts';
|
|
3
|
+
import type { ParticleGeometry3D } from './ParticleMesh3D.ts';
|
|
4
|
+
import type { ParticleVector3 } from './ParticleTypes3D.ts';
|
|
5
|
+
|
|
6
|
+
export interface RibbonPathSpec3D {
|
|
7
|
+
maxPoints: number;
|
|
8
|
+
width: number;
|
|
9
|
+
widthOverPath?: ParticleCurveKey[];
|
|
10
|
+
alphaOverPath?: ParticleCurveKey[];
|
|
11
|
+
colorOverPath?: ParticleColorKey[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Authored XYZ flow paths. Geometry follows supplied world points, with a fade at either end. */
|
|
15
|
+
export class ZhudaRibbonPath3D {
|
|
16
|
+
readonly spec: RibbonPathSpec3D;
|
|
17
|
+
private readonly points: ParticleVector3[];
|
|
18
|
+
private readonly widthDirections: ParticleVector3[];
|
|
19
|
+
private hasWidthDirections = false;
|
|
20
|
+
private readonly distances: Float32Array;
|
|
21
|
+
private readonly geometry: ParticleGeometry3D;
|
|
22
|
+
private count = 0;
|
|
23
|
+
uvOffset = 0;
|
|
24
|
+
uvTiles = 1;
|
|
25
|
+
visibleStart = 0;
|
|
26
|
+
visibleEnd = 1;
|
|
27
|
+
edgeFade = 0.08;
|
|
28
|
+
constructor(spec: RibbonPathSpec3D) {
|
|
29
|
+
if (
|
|
30
|
+
!Number.isInteger(spec.maxPoints) ||
|
|
31
|
+
spec.maxPoints < 2 ||
|
|
32
|
+
spec.maxPoints > 32767 ||
|
|
33
|
+
!Number.isFinite(spec.width) ||
|
|
34
|
+
spec.width <= 0
|
|
35
|
+
)
|
|
36
|
+
throw new Error('Invalid 3D ribbon path budget or width.');
|
|
37
|
+
for (const keys of [spec.widthOverPath, spec.alphaOverPath])
|
|
38
|
+
if (
|
|
39
|
+
keys &&
|
|
40
|
+
(!keys.length ||
|
|
41
|
+
keys.some(
|
|
42
|
+
(k, i, a) =>
|
|
43
|
+
!k ||
|
|
44
|
+
![k.time, k.value].every(Number.isFinite) ||
|
|
45
|
+
k.time < 0 ||
|
|
46
|
+
k.time > 1 ||
|
|
47
|
+
k.value < 0 ||
|
|
48
|
+
(i > 0 && k.time <= a[i - 1].time),
|
|
49
|
+
))
|
|
50
|
+
)
|
|
51
|
+
throw new Error('Invalid path curve.');
|
|
52
|
+
if (
|
|
53
|
+
spec.colorOverPath &&
|
|
54
|
+
(!spec.colorOverPath.length ||
|
|
55
|
+
spec.colorOverPath.some(
|
|
56
|
+
(k, i, a) =>
|
|
57
|
+
!k ||
|
|
58
|
+
!Number.isFinite(k.time) ||
|
|
59
|
+
k.time < 0 ||
|
|
60
|
+
k.time > 1 ||
|
|
61
|
+
!/^#[0-9a-f]{6}$/i.test(k.color) ||
|
|
62
|
+
(i > 0 && k.time <= a[i - 1].time),
|
|
63
|
+
))
|
|
64
|
+
)
|
|
65
|
+
throw new Error('Invalid path color curve.');
|
|
66
|
+
this.spec = JSON.parse(JSON.stringify(spec));
|
|
67
|
+
this.points = Array.from({ length: spec.maxPoints }, () => ({ x: 0, y: 0, z: 0 }));
|
|
68
|
+
this.widthDirections = Array.from({ length: spec.maxPoints }, () => ({ x: 0, y: 0, z: 0 }));
|
|
69
|
+
this.distances = new Float32Array(spec.maxPoints);
|
|
70
|
+
this.geometry = {
|
|
71
|
+
vertices: new Float32Array(spec.maxPoints * 18),
|
|
72
|
+
indices: new Uint16Array((spec.maxPoints - 1) * 6),
|
|
73
|
+
vertexCount: 0,
|
|
74
|
+
indexCount: 0,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
get pointCount(): number {
|
|
78
|
+
return this.count;
|
|
79
|
+
}
|
|
80
|
+
clear(): void {
|
|
81
|
+
this.count = 0;
|
|
82
|
+
}
|
|
83
|
+
setPoints(
|
|
84
|
+
points: readonly ParticleVector3[],
|
|
85
|
+
widthDirections?: readonly ParticleVector3[],
|
|
86
|
+
): void {
|
|
87
|
+
if (
|
|
88
|
+
points.length > this.points.length ||
|
|
89
|
+
points.some((p) => !p || ![p.x, p.y, p.z].every(Number.isFinite))
|
|
90
|
+
)
|
|
91
|
+
throw new Error('Path points exceed budget or contain invalid XYZ positions.');
|
|
92
|
+
if (
|
|
93
|
+
widthDirections &&
|
|
94
|
+
(widthDirections.length !== points.length ||
|
|
95
|
+
widthDirections.some(
|
|
96
|
+
(v) => !v || ![v.x, v.y, v.z].every(Number.isFinite) || Math.hypot(v.x, v.y, v.z) < 1e-8,
|
|
97
|
+
))
|
|
98
|
+
)
|
|
99
|
+
throw new Error('Width directions must match the path and contain finite non-zero vectors.');
|
|
100
|
+
this.hasWidthDirections = widthDirections !== undefined;
|
|
101
|
+
if (widthDirections)
|
|
102
|
+
for (let i = 0; i < points.length; i++)
|
|
103
|
+
Object.assign(this.widthDirections[i], widthDirections[i]);
|
|
104
|
+
this.count = points.length;
|
|
105
|
+
for (let i = 0; i < points.length; i++) Object.assign(this.points[i], points[i]);
|
|
106
|
+
}
|
|
107
|
+
snapshot(): ParticleVector3[] {
|
|
108
|
+
return this.points.slice(0, this.count).map((p) => ({ ...p }));
|
|
109
|
+
}
|
|
110
|
+
buildMesh(camera: ParticleVector3, opacity = 1): ParticleGeometry3D {
|
|
111
|
+
const g = this.geometry;
|
|
112
|
+
g.vertices.fill(0);
|
|
113
|
+
g.indices.fill(0);
|
|
114
|
+
if (
|
|
115
|
+
![
|
|
116
|
+
this.uvOffset,
|
|
117
|
+
this.uvTiles,
|
|
118
|
+
opacity,
|
|
119
|
+
this.visibleStart,
|
|
120
|
+
this.visibleEnd,
|
|
121
|
+
this.edgeFade,
|
|
122
|
+
].every(Number.isFinite) ||
|
|
123
|
+
this.visibleStart < 0 ||
|
|
124
|
+
this.visibleEnd > 1 ||
|
|
125
|
+
this.visibleStart > this.visibleEnd ||
|
|
126
|
+
this.edgeFade <= 0
|
|
127
|
+
)
|
|
128
|
+
throw new Error('Invalid flow UV/opacity/reveal window.');
|
|
129
|
+
let total = 0;
|
|
130
|
+
for (let i = 0; i < this.count; i++) {
|
|
131
|
+
if (i) {
|
|
132
|
+
const a = this.points[i - 1],
|
|
133
|
+
b = this.points[i];
|
|
134
|
+
total += Math.hypot(b.x - a.x, b.y - a.y, b.z - a.z);
|
|
135
|
+
}
|
|
136
|
+
this.distances[i] = total;
|
|
137
|
+
}
|
|
138
|
+
let px = 0,
|
|
139
|
+
py = 0,
|
|
140
|
+
pz = 0;
|
|
141
|
+
for (let i = 0; i < this.count; i++) {
|
|
142
|
+
const p = this.points[i],
|
|
143
|
+
a = this.points[Math.max(0, i - 1)],
|
|
144
|
+
b = this.points[Math.min(this.count - 1, i + 1)];
|
|
145
|
+
const tx = b.x - a.x,
|
|
146
|
+
ty = b.y - a.y,
|
|
147
|
+
tz = b.z - a.z,
|
|
148
|
+
vx = camera.x - p.x,
|
|
149
|
+
vy = camera.y - p.y,
|
|
150
|
+
vz = camera.z - p.z;
|
|
151
|
+
let nx = ty * vz - tz * vy,
|
|
152
|
+
ny = tz * vx - tx * vz,
|
|
153
|
+
nz = tx * vy - ty * vx,
|
|
154
|
+
length = Math.hypot(nx, ny, nz);
|
|
155
|
+
if (this.hasWidthDirections) {
|
|
156
|
+
const d = this.widthDirections[i],
|
|
157
|
+
tt = tx * tx + ty * ty + tz * tz;
|
|
158
|
+
const projection = tt > 1e-14 ? (d.x * tx + d.y * ty + d.z * tz) / tt : 0;
|
|
159
|
+
nx = d.x - projection * tx;
|
|
160
|
+
ny = d.y - projection * ty;
|
|
161
|
+
nz = d.z - projection * tz;
|
|
162
|
+
length = Math.hypot(nx, ny, nz);
|
|
163
|
+
}
|
|
164
|
+
if (length < 1e-7) {
|
|
165
|
+
nx = -tz;
|
|
166
|
+
ny = 0;
|
|
167
|
+
nz = tx;
|
|
168
|
+
length = Math.hypot(nx, ny, nz);
|
|
169
|
+
}
|
|
170
|
+
if (length < 1e-7) {
|
|
171
|
+
nx = 1;
|
|
172
|
+
ny = 0;
|
|
173
|
+
nz = 0;
|
|
174
|
+
length = 1;
|
|
175
|
+
}
|
|
176
|
+
nx /= length;
|
|
177
|
+
ny /= length;
|
|
178
|
+
nz /= length;
|
|
179
|
+
if (nx * px + ny * py + nz * pz < 0) {
|
|
180
|
+
nx = -nx;
|
|
181
|
+
ny = -ny;
|
|
182
|
+
nz = -nz;
|
|
183
|
+
}
|
|
184
|
+
px = nx;
|
|
185
|
+
py = ny;
|
|
186
|
+
pz = nz;
|
|
187
|
+
const t = total > 1e-7 ? this.distances[i] / total : 0;
|
|
188
|
+
const width = this.spec.width * 0.5 * sampleParticleCurve(this.spec.widthOverPath, t);
|
|
189
|
+
const mask =
|
|
190
|
+
smooth((t - this.visibleStart) / this.edgeFade) *
|
|
191
|
+
smooth((this.visibleEnd - t) / this.edgeFade);
|
|
192
|
+
const alpha =
|
|
193
|
+
Math.max(0, Math.min(1, opacity * sampleParticleCurve(this.spec.alphaOverPath, t))) * mask;
|
|
194
|
+
const color = sampleParticleColor(this.spec.colorOverPath, t),
|
|
195
|
+
r = parseInt(color.slice(1, 3), 16) / 255,
|
|
196
|
+
green = parseInt(color.slice(3, 5), 16) / 255,
|
|
197
|
+
blue = parseInt(color.slice(5, 7), 16) / 255;
|
|
198
|
+
const u = t * this.uvTiles + this.uvOffset;
|
|
199
|
+
for (let side = 0; side < 2; side++) {
|
|
200
|
+
const sign = side ? 1 : -1,
|
|
201
|
+
base = i * 18 + side * 9,
|
|
202
|
+
v = g.vertices;
|
|
203
|
+
v[base] = p.x + sign * nx * width;
|
|
204
|
+
v[base + 1] = p.y + sign * ny * width;
|
|
205
|
+
v[base + 2] = p.z + sign * nz * width;
|
|
206
|
+
v[base + 3] = r;
|
|
207
|
+
v[base + 4] = green;
|
|
208
|
+
v[base + 5] = blue;
|
|
209
|
+
v[base + 6] = alpha;
|
|
210
|
+
v[base + 7] = u;
|
|
211
|
+
v[base + 8] = side;
|
|
212
|
+
}
|
|
213
|
+
if (i < this.count - 1) {
|
|
214
|
+
const v = i * 2,
|
|
215
|
+
offset = i * 6,
|
|
216
|
+
indices = g.indices;
|
|
217
|
+
indices[offset] = v;
|
|
218
|
+
indices[offset + 1] = v + 1;
|
|
219
|
+
indices[offset + 2] = v + 2;
|
|
220
|
+
indices[offset + 3] = v + 1;
|
|
221
|
+
indices[offset + 4] = v + 3;
|
|
222
|
+
indices[offset + 5] = v + 2;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
g.vertexCount = this.count * 2;
|
|
226
|
+
g.indexCount = Math.max(0, this.count - 1) * 6;
|
|
227
|
+
return g;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function smooth(v: number): number {
|
|
232
|
+
const f = Math.max(0, Math.min(1, v));
|
|
233
|
+
return f * f * (3 - 2 * f);
|
|
234
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { sampleParticleCurve } from './ParticleTypes.ts';
|
|
2
|
+
import type { ParticleCurveKey } from './ParticleTypes.ts';
|
|
3
|
+
|
|
4
|
+
export interface RibbonTrailSpec {
|
|
5
|
+
maxPoints: number;
|
|
6
|
+
lifetime: number;
|
|
7
|
+
width: number;
|
|
8
|
+
minDistance: number;
|
|
9
|
+
teleportDistance: number;
|
|
10
|
+
widthOverLife?: ParticleCurveKey[];
|
|
11
|
+
}
|
|
12
|
+
export interface RibbonMesh {
|
|
13
|
+
vertices: Float32Array;
|
|
14
|
+
uvs: Float32Array;
|
|
15
|
+
indices: Uint16Array;
|
|
16
|
+
pointCount: number;
|
|
17
|
+
indexCount: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** World-space path history. Moving an emitter never drags its old trail. */
|
|
21
|
+
export class ZhudaRibbonTrail {
|
|
22
|
+
public readonly spec: RibbonTrailSpec;
|
|
23
|
+
private readonly points: Array<{ x: number; y: number; born: number }>;
|
|
24
|
+
private head = 0;
|
|
25
|
+
private count = 0;
|
|
26
|
+
private time = 0;
|
|
27
|
+
private readonly mesh: RibbonMesh;
|
|
28
|
+
|
|
29
|
+
constructor(spec: RibbonTrailSpec) {
|
|
30
|
+
if (
|
|
31
|
+
!Number.isInteger(spec.maxPoints) ||
|
|
32
|
+
spec.maxPoints < 2 ||
|
|
33
|
+
spec.maxPoints > 32767 ||
|
|
34
|
+
![spec.lifetime, spec.width, spec.minDistance, spec.teleportDistance].every(
|
|
35
|
+
Number.isFinite,
|
|
36
|
+
) ||
|
|
37
|
+
spec.lifetime <= 0 ||
|
|
38
|
+
spec.width <= 0 ||
|
|
39
|
+
spec.minDistance <= 0 ||
|
|
40
|
+
spec.teleportDistance <= spec.minDistance
|
|
41
|
+
) {
|
|
42
|
+
throw new Error(
|
|
43
|
+
'[ZhudaRibbonTrail] Invalid point budget, lifetime, width or distance limits.',
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
if (
|
|
47
|
+
spec.widthOverLife?.some(
|
|
48
|
+
(k, i, a) =>
|
|
49
|
+
!Number.isFinite(k.time) ||
|
|
50
|
+
!Number.isFinite(k.value) ||
|
|
51
|
+
k.time < 0 ||
|
|
52
|
+
k.time > 1 ||
|
|
53
|
+
k.value < 0 ||
|
|
54
|
+
(i > 0 && k.time <= a[i - 1].time),
|
|
55
|
+
)
|
|
56
|
+
)
|
|
57
|
+
throw new Error('[ZhudaRibbonTrail] Invalid width curve.');
|
|
58
|
+
this.spec = JSON.parse(JSON.stringify(spec));
|
|
59
|
+
this.points = Array.from({ length: spec.maxPoints }, () => ({ x: 0, y: 0, born: 0 }));
|
|
60
|
+
this.mesh = {
|
|
61
|
+
vertices: new Float32Array(spec.maxPoints * 4),
|
|
62
|
+
uvs: new Float32Array(spec.maxPoints * 4),
|
|
63
|
+
indices: new Uint16Array((spec.maxPoints - 1) * 6),
|
|
64
|
+
pointCount: 0,
|
|
65
|
+
indexCount: 0,
|
|
66
|
+
};
|
|
67
|
+
for (let i = 0; i < spec.maxPoints - 1; i++) {
|
|
68
|
+
const v = i * 2;
|
|
69
|
+
this.mesh.indices.set([v, v + 1, v + 2, v + 1, v + 3, v + 2], i * 6);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
get pointCount(): number {
|
|
73
|
+
return this.count;
|
|
74
|
+
}
|
|
75
|
+
clear(): void {
|
|
76
|
+
this.head = 0;
|
|
77
|
+
this.count = 0;
|
|
78
|
+
this.time = 0;
|
|
79
|
+
this.mesh.pointCount = 0;
|
|
80
|
+
this.mesh.indexCount = 0;
|
|
81
|
+
}
|
|
82
|
+
update(dt: number, x: number, y: number, emitting = true): void {
|
|
83
|
+
if (![dt, x, y].every(Number.isFinite) || dt < 0)
|
|
84
|
+
throw new Error('Trail delta and position must be finite.');
|
|
85
|
+
this.time += dt;
|
|
86
|
+
while (this.count > 0 && this.time - this.at(0).born >= this.spec.lifetime) {
|
|
87
|
+
this.head = (this.head + 1) % this.points.length;
|
|
88
|
+
this.count--;
|
|
89
|
+
}
|
|
90
|
+
if (!emitting) return;
|
|
91
|
+
if (this.count) {
|
|
92
|
+
const last = this.at(this.count - 1),
|
|
93
|
+
distance = Math.hypot(x - last.x, y - last.y);
|
|
94
|
+
if (distance > this.spec.teleportDistance) {
|
|
95
|
+
this.head = 0;
|
|
96
|
+
this.count = 0;
|
|
97
|
+
} else if (distance < this.spec.minDistance) return;
|
|
98
|
+
}
|
|
99
|
+
if (this.count === this.points.length) {
|
|
100
|
+
this.head = (this.head + 1) % this.points.length;
|
|
101
|
+
this.count--;
|
|
102
|
+
}
|
|
103
|
+
const p = this.at(this.count++);
|
|
104
|
+
p.x = x;
|
|
105
|
+
p.y = y;
|
|
106
|
+
p.born = this.time;
|
|
107
|
+
}
|
|
108
|
+
/** Reuses storage; UV.x encodes age, UV.y crosses the ribbon width. */
|
|
109
|
+
buildMesh(): RibbonMesh {
|
|
110
|
+
const m = this.mesh;
|
|
111
|
+
m.pointCount = this.count;
|
|
112
|
+
m.indexCount = Math.max(0, this.count - 1) * 6;
|
|
113
|
+
for (let i = 0; i < this.count; i++) {
|
|
114
|
+
const p = this.at(i),
|
|
115
|
+
previous = this.at(Math.max(0, i - 1)),
|
|
116
|
+
next = this.at(Math.min(this.count - 1, i + 1));
|
|
117
|
+
let dx = next.x - previous.x,
|
|
118
|
+
dy = next.y - previous.y;
|
|
119
|
+
const length = Math.hypot(dx, dy);
|
|
120
|
+
if (length < 1e-6) {
|
|
121
|
+
dx = 1;
|
|
122
|
+
dy = 0;
|
|
123
|
+
} else {
|
|
124
|
+
dx /= length;
|
|
125
|
+
dy /= length;
|
|
126
|
+
}
|
|
127
|
+
const life = Math.min(1, Math.max(0, (this.time - p.born) / this.spec.lifetime));
|
|
128
|
+
const half =
|
|
129
|
+
this.spec.width * 0.5 * sampleParticleCurve(this.spec.widthOverLife, life, 1 - life);
|
|
130
|
+
m.vertices.set([p.x - dy * half, p.y + dx * half, p.x + dy * half, p.y - dx * half], i * 4);
|
|
131
|
+
m.uvs.set([life, 0, life, 1], i * 4);
|
|
132
|
+
}
|
|
133
|
+
return m;
|
|
134
|
+
}
|
|
135
|
+
snapshot(): Array<{ x: number; y: number; age: number }> {
|
|
136
|
+
return Array.from({ length: this.count }, (_, i) => ({
|
|
137
|
+
x: this.at(i).x,
|
|
138
|
+
y: this.at(i).y,
|
|
139
|
+
age: this.time - this.at(i).born,
|
|
140
|
+
}));
|
|
141
|
+
}
|
|
142
|
+
private at(index: number) {
|
|
143
|
+
return this.points[(this.head + index) % this.points.length];
|
|
144
|
+
}
|
|
145
|
+
}
|