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 @@
|
|
|
1
|
+
!function(e,t){"use strict";class r{get source(){return this._source}set source(e){this._source=e,e?t.ILaya.loader.load(e,t.Loader.SPINE).then(e=>{!this._source||e&&!e.isCreateFromURL(this._source)||(this.templet=e)}):this.templet=null}get items(){return this._items}set items(e){this._items=e}get templet(){return this._templet}set templet(e){this.init(e)}init(e){this._templet=e,this._templet&&this.flush()}flush(){var e;let t=null===(e=this.target)||void 0===e?void 0:e.templet;if(this._items&&this._templet&&t&&t._textures){if(!this._templet.optimize)return;for(let e=this._items.length-1;e>=0;e--){let t=this._items[e];this.target.setTempletAttachment(this._templet,t.slot,t.skin,t.attachment)}}}}class i{get skin(){return this._skin}set skin(e){this._skin=e}get slot(){return this._slot}set slot(e){this._slot=e}get attachment(){return this._attachment}set attachment(e){this._attachment=e}}var n,a,s;class o{static SetSpineBlendMode(e,r,i=!0){switch(e){case 1:r.blend=t.RenderState.BLEND_ENABLE_ALL,r.blendSrc=t.RenderState.BLENDPARAM_SRC_ALPHA,r.blendDst=t.RenderState.BLENDPARAM_ONE;break;case 3:r.blend=t.RenderState.BLEND_ENABLE_SEPERATE,r.blendSrcRGB=t.RenderState.BLENDPARAM_ONE,r.blendSrcAlpha=t.RenderState.BLENDPARAM_ONE,r.blendDstRGB=t.RenderState.BLENDPARAM_ONE_MINUS_SRC_COLOR,r.blendDstAlpha=t.RenderState.BLENDPARAM_ONE;break;case 2:r.blend=t.RenderState.BLEND_ENABLE_ALL,r.blendSrc=t.RenderState.BLENDPARAM_DST_COLOR,r.blendDst=t.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA;break;default:r.blend=t.RenderState.BLEND_ENABLE_ALL,r.blendSrc=i?t.RenderState.BLENDPARAM_ONE:t.RenderState.BLENDPARAM_SRC_ALPHA,r.blendDst=t.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA}}static initSpineMaterial(e){e.alphaTest=!1,e.depthWrite=!1,e.cull=t.RenderState.CULL_NONE,e.blend=t.RenderState.BLEND_ENABLE_ALL,e.blendSrc=t.RenderState.BLENDPARAM_SRC_ALPHA,e.blendDst=t.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA,e.depthTest=t.RenderState.DEPTHTEST_OFF}static init(){t.Shader3D.addInclude("SpineFragment.glsl",'#if !defined(SpineFragment_lib)\n#define SpineFragment_lib\n#include "Sprite2DFrag.glsl";\nvec4 getColor(){vec4 color=texture2D(u_spineTexture,v_texcoord.xy);\n#ifndef GAMMATEXTURE\n#ifdef GAMMASPACE\ncolor.xyz=linearToGamma(color.xyz);\n#endif\n#else\n#ifndef GAMMASPACE\ncolor.xyz=gammaToLinear(color.xyz);\n#endif\n#endif\nvec4 final;\n#ifdef TWOCOLORTINT\nfinal.a=color.a*v_color.a;final.xyz=((color.a-1.0)*v_color2.a+1.0-color.xyz)*v_color2.xyz+color.xyz*v_color.xyz;\n#else\nfinal=color*v_color;\n#endif\nreturn final;}\n#endif\n'),t.Shader3D.addInclude("Spine2DVertex.glsl","#if !defined(SpineVertex_lib)\n#define SpineVertex_lib\nvoid transfrom_spine(vec2 pos,vec3 xDir,vec3 yDir,out vec2 outPos){outPos.x=xDir.x*pos.x-xDir.y*pos.y+xDir.z;outPos.y=yDir.x*pos.x-yDir.y*pos.y+yDir.z;}void getGlobalPos(vec4 pos,out vec2 globalPos){\n#ifdef GPU_INSTANCE\nvec3 down=a_NMatrix_1;vec3 up=a_NMatrix_0;\n#else\nvec3 down=u_NMatrix_1;vec3 up=u_NMatrix_0;\n#endif\n#ifdef SPINE_NORMAL_2D\nglobalPos.xy=pos.xy;\n#else\ntransfrom_spine(pos.xy,up,down,globalPos);\n#endif\n}vec4 getScreenPos(vec4 pos){vec2 globalPos;\n#ifdef GPU_INSTANCE\nvec3 down=a_NMatrix_1;vec3 up=a_NMatrix_0;\n#else\nvec3 down=u_NMatrix_1;vec3 up=u_NMatrix_0;\n#endif\n#ifdef SPINE_NORMAL_2D\nglobalPos.xy=pos.xy;\n#else\ntransfrom_spine(pos.xy,up,down,globalPos);\n#endif\nclip(globalPos);vec2 viewPos;getViewPos(globalPos,viewPos);vec4 outPos;getProjectPos(viewPos,outPos);return outPos;}void getVertexInfo(vec4 pos,inout vertexInfo info){info.pos=pos.xy;info.color=vec4(1.0);\n#ifdef COLOR\ninfo.color=a_color;\n#endif\ninfo.color*=u_baseRenderColor;\n#ifdef PREMULTIPLYALPHA\ninfo.color.rgb=info.color.rgb*info.color.a;\n#endif\n#ifdef UV\ninfo.uv=a_uv;\n#endif\n#ifdef LIGHT2D_ENABLE\nvec2 global;getGlobalPos(pos,global);info.lightUV.x=(global.x-u_LightAndShadow2DParam.x)/u_LightAndShadow2DParam.z;info.lightUV.y=1.0-(global.y-u_LightAndShadow2DParam.y)/u_LightAndShadow2DParam.w;\n#endif\n}\n#endif\n"),t.Shader3D.addInclude("SpineVertexCommon.glsl","#if !defined(SpineVertexCommon_lib)\n#define SpineVertexCommon_lib\n#ifdef SPINE_RB\nuniform vec4 u_sBone0;uniform vec4 u_sBone1;\n#endif\nvoid transfrom(vec2 pos,vec4 xDir,vec4 yDir,out vec2 outPos){outPos.x=xDir.x*pos.x+xDir.y*pos.y+xDir.z;outPos.y=yDir.x*pos.x+yDir.y*pos.y+yDir.z;}\n#ifdef SPINE_SIMPLE\nuniform vec4 u_SimpleAnimatorParams;uniform sampler2D u_SimpleAnimatorTexture;uniform float u_SimpleAnimatorTextureSize;vec4 getBonePosBake(float FramePos,float boneIndices,float weight,vec2 pos,float offset){vec2 uv=vec2(0.0,0.0);float PixelPos=FramePos+boneIndices*2.0;float halfOffset=offset*0.5;float uvoffset=PixelPos/u_SimpleAnimatorTextureSize;uv.y=floor(uvoffset)*offset+halfOffset;uv.x=mod(PixelPos,u_SimpleAnimatorTextureSize)*offset+halfOffset;vec4 up=texture2D(u_SimpleAnimatorTexture,uv);uv.x+=offset;vec4 down=texture2D(u_SimpleAnimatorTexture,uv);vec2 outPos;transfrom(pos,up,down,outPos);outPos=outPos*weight;return vec4(outPos,0.,1.0);}\n#endif\n#ifdef SPINE_FAST\nuniform vec4 u_sBone[200];vec4 getBonePos(float fboneId,float weight,vec2 pos){int boneId=int(fboneId);vec4 up=u_sBone[boneId*2];vec4 down=u_sBone[boneId*2+1];vec2 outPos;transfrom(pos,up,down,outPos);outPos=outPos*weight;return vec4(outPos,0.,1.0);}\n#endif\nvec4 getSpinePos(){\n#ifdef SPINE_SIMPLE\n#ifdef GPU_INSTANCE\nfloat currentPixelPos=a_SimpleTextureParams.x+a_SimpleTextureParams.y;\n#else\nfloat currentPixelPos=u_SimpleAnimatorParams.x+u_SimpleAnimatorParams.y;\n#endif\nfloat offset=1.0/u_SimpleAnimatorTextureSize;\n#ifdef SPINE_RB\nreturn getBonePosBake(currentPixelPos,a_BoneId,a_weight,a_position,offset);\n#else\nreturn getBonePosBake(currentPixelPos,a_BoneId,a_weight,a_position,offset)+getBonePosBake(currentPixelPos,a_PosWeightBoneID_2.w,a_PosWeightBoneID_2.z,a_PosWeightBoneID_2.xy,offset)+getBonePosBake(currentPixelPos,a_PosWeightBoneID_3.w,a_PosWeightBoneID_3.z,a_PosWeightBoneID_3.xy,offset)+getBonePosBake(currentPixelPos,a_PosWeightBoneID_4.w,a_PosWeightBoneID_4.z,a_PosWeightBoneID_4.xy,offset);\n#endif\n#else\n#ifdef SPINE_FAST\nreturn getBonePos(a_BoneId,a_weight,a_position)+getBonePos(a_PosWeightBoneID_2.w,a_PosWeightBoneID_2.z,a_PosWeightBoneID_2.xy)+getBonePos(a_PosWeightBoneID_3.w,a_PosWeightBoneID_3.z,a_PosWeightBoneID_3.xy)+getBonePos(a_PosWeightBoneID_4.w,a_PosWeightBoneID_4.z,a_PosWeightBoneID_4.xy);\n#endif\n#ifdef SPINE_RB\nvec2 pos;transfrom(a_position,u_sBone0,u_sBone1,pos);pos*=a_weight;return vec4(pos,0.,1.);\n#endif\n#endif\nreturn vec4(a_position.x,a_position.y,0.,1.);}\n#endif\n"),o.BONEMAT=t.Shader3D.propertyNameToID("u_sBone"),o.BONEMAT_0=t.Shader3D.propertyNameToID("u_sBone0"),o.BONEMAT_1=t.Shader3D.propertyNameToID("u_sBone1"),o.SpineTexture=t.Shader3D.propertyNameToID("u_spineTexture"),o.COLOR=t.Shader3D.propertyNameToID("u_color"),o.SPINE_RENDER_SIZE=t.Shader3D.propertyNameToID("u_spineRenderSize"),o.SPINE_FAST=t.Shader3D.getDefineByName("SPINE_FAST"),o.SPINE_RB=t.Shader3D.getDefineByName("SPINE_RB"),o.SPINE_UV=t.Shader3D.getDefineByName("UV"),o.SPINE_COLOR=t.Shader3D.getDefineByName("COLOR"),o.SPINE_NORMAL_2D=t.Shader3D.getDefineByName("SPINE_NORMAL_2D"),o.SPINE_PREMULTIPLYALPHA=t.Shader3D.getDefineByName("PREMULTIPLYALPHA"),o.SIMPLE_SIMPLEANIMATORPARAMS=t.Shader3D.propertyNameToID("u_SimpleAnimatorParams"),o.SIMPLE_SIMPLEANIMATORTEXTURE=t.Shader3D.propertyNameToID("u_SimpleAnimatorTexture"),o.SIMPLE_SIMPLEANIMATORTEXTURESIZE=t.Shader3D.propertyNameToID("u_SimpleAnimatorTextureSize"),o.SPINE_SIMPLE=t.Shader3D.getDefineByName("SPINE_SIMPLE"),o.SPINE_GPU_INSTANCE=t.Shader3D.getDefineByName("GPU_INSTANCE"),o.SPINE_TWOCOLORTINT=t.Shader3D.getDefineByName("TWOCOLORTINT"),o.SPINE_COLOR2=t.Shader3D.getDefineByName("COLOR2");const e=t.LayaGL.renderDeviceFactory.createGlobalUniformMap("Spine2D");e.addShaderUniformArray(o.BONEMAT,"u_sBone",t.ShaderDataType.Vector4,200),e.addShaderUniform(o.BONEMAT_0,"u_sBone0",t.ShaderDataType.Vector4),e.addShaderUniform(o.BONEMAT_1,"u_sBone1",t.ShaderDataType.Vector4),e.addShaderUniform(o.COLOR,"u_color",t.ShaderDataType.Vector4),e.addShaderUniform(o.SIMPLE_SIMPLEANIMATORPARAMS,"u_SimpleAnimatorParams",t.ShaderDataType.Vector4),e.addShaderUniform(o.SIMPLE_SIMPLEANIMATORTEXTURE,"u_SimpleAnimatorTexture",t.ShaderDataType.Texture2D),e.addShaderUniform(o.SIMPLE_SIMPLEANIMATORTEXTURESIZE,"u_SimpleAnimatorTextureSize",t.ShaderDataType.Float),e.addShaderUniform(o.SPINE_RENDER_SIZE,"u_spineRenderSize",t.ShaderDataType.Vector2);let r=t.Shader3D.add("SpineStandard",!0,!1);r.shaderType=t.ShaderFeatureType.D2_BaseRenderNode2D;let i={u_spineTexture:t.ShaderDataType.Texture2D},n=new t.SubShader(o.textureSpineAttribute,i);r.addSubShader(n),n.addShaderPass('#define SHADER_NAME SpineStandardVS\nvarying vec4 v_color2;\n#include "Sprite2DVertex.glsl";\n#include "SpineVertexCommon.glsl";\n#include "Spine2DVertex.glsl";\nvoid main(){vec4 pos=getSpinePos();vertexInfo info;getVertexInfo(pos,info);v_texcoord=info.uv;v_color=info.color;\n#ifdef COLOR2\nv_color2=a_color2;\n#else\nv_color2=vec4(0.0,0.0,0.0,1.0);\n#endif\n#ifdef PREMULTIPLYALPHA\nv_color2.xyz=v_color2.xyz*v_color.a;\n#endif\n#ifdef LIGHT2D_ENABLE\nlightAndShadow(info);\n#endif\ngl_Position=getScreenPos(pos);}','#define SHADER_NAME SpineStandardFS\nvarying vec4 v_color2;\n#include "SpineFragment.glsl";\nvoid main(){clip();gl_FragColor=getColor();\n#ifdef LIGHT2D_ENABLE\nlightAndShadow(gl_FragColor);\n#endif\n}'),o.SpineNormalVertexDeclaration=o.getVertexDeclaration("UV,COLOR,POSITION,COLOR2"),o.instanceNMatrixDeclaration=new t.VertexDeclaration(24,[new t.VertexElement(0,t.VertexElementFormat.Vector3,8),new t.VertexElement(12,t.VertexElementFormat.Vector3,9)]),o.instanceSimpleAnimatorDeclaration=new t.VertexDeclaration(16,[new t.VertexElement(0,t.VertexElementFormat.Vector4,10)])}static getVertexDeclaration(e){var r=o._vertexDeclarationMap[e];if(!r){for(var i=e.split(","),n=[],a=0,s=0,h=i.length;s<h;s++){var l;switch(i[s]){case"COLOR2":l=new t.VertexElement(a,t.VertexElementFormat.Vector4,11),a+=16;break;case"BONE":l=new t.VertexElement(a,t.VertexElementFormat.Single,3),n.push(l),a+=4,l=new t.VertexElement(a,t.VertexElementFormat.Single,4),n.push(l),a+=4,l=new t.VertexElement(a,t.VertexElementFormat.Vector4,5),n.push(l),a+=16,l=new t.VertexElement(a,t.VertexElementFormat.Vector4,6),n.push(l),a+=16,l=new t.VertexElement(a,t.VertexElementFormat.Vector4,7),a+=16;break;case"RIGIDBODY":l=new t.VertexElement(a,t.VertexElementFormat.Single,3),n.push(l),a+=4,l=new t.VertexElement(a,t.VertexElementFormat.Single,4),a+=4;break;case"UV":l=new t.VertexElement(a,t.VertexElementFormat.Vector2,0),a+=8;break;case"COLOR":l=new t.VertexElement(a,t.VertexElementFormat.Vector4,1),a+=16;break;case"POSITION":l=new t.VertexElement(a,t.VertexElementFormat.Vector2,2),a+=8;break;default:throw new Error("unknown vertex flag.")}n.push(l)}r=new t.VertexDeclaration(a,n),o._vertexDeclarationMap[e]=r}return r}static getAllVertexDeclarations(){if(this._declarations)return this._declarations;this._declarations={};let e=["UV,COLOR,POSITION","UV,COLOR,POSITION,COLOR2","UV,COLOR,POSITION,BONE","UV,COLOR,POSITION,BONE,COLOR2","UV,COLOR,POSITION,RIGIDBODY","UV,COLOR,POSITION,RIGIDBODY,COLOR2"];for(const t of e)this._declarations[t]=o.getVertexDeclaration(t);return this._declarations.instanceMatrix=o.instanceNMatrixDeclaration,this._declarations.simpleAnimation=o.instanceSimpleAnimatorDeclaration,this._declarations}static getIndexFormat(e){let r=t.IndexFormat.UInt32;return e<256&&t.LayaGL.renderEngine.getCapable(t.RenderCapable.Element_Index_Uint8)?r=t.IndexFormat.UInt8:e<65536&&(r=t.IndexFormat.UInt16),r}}o._vertexDeclarationMap={},o.textureSpineAttribute={a_uv:[0,t.ShaderDataType.Vector2],a_color:[1,t.ShaderDataType.Vector4],a_position:[2,t.ShaderDataType.Vector2],a_weight:[3,t.ShaderDataType.Float],a_BoneId:[4,t.ShaderDataType.Float],a_PosWeightBoneID_2:[5,t.ShaderDataType.Vector4],a_PosWeightBoneID_3:[6,t.ShaderDataType.Vector4],a_PosWeightBoneID_4:[7,t.ShaderDataType.Vector4],a_NMatrix_0:[8,t.ShaderDataType.Vector3],a_NMatrix_1:[9,t.ShaderDataType.Vector3],a_SimpleTextureParams:[10,t.ShaderDataType.Vector4],a_color2:[11,t.ShaderDataType.Vector4]};class h extends t.Resource{constructor(){super(),this.materialMap=new Map,this._spineMaterials2D={},this._spineMaterials3D={},this._spineMaterialTextures={},this._spineMaterialTextureKeys={},this.x=0,this.y=0,this.offsetX=0,this.offsetY=0,this._premultipliedAlpha=!0}get premultipliedAlpha(){return this._premultipliedAlpha}get spineMaterials2D(){return this._spineMaterials2D}set spineMaterials2D(e){this._spineMaterials2D=e||{},this.onSpineMaterialsChanged()}get spineMaterials3D(){return this._spineMaterials3D}set spineMaterials3D(e){this._spineMaterials3D=e||{},this.onSpineMaterialsChanged()}get spineMaterialTextures(){return this._spineMaterialTextures}set spineMaterialTextures(e){this._spineMaterialTextures=e||{},this._refreshSpineMaterialTextureKeys(),this.onSpineMaterialsChanged()}onSpineMaterialsChanged(){this.event(h.EVENT_SPINE_MATERIAL_CHANGE)}_getSpineMaterial(e,t,r,i){if(!e)return null;let n=i?"3D":"2D",a=i?this._spineMaterials3D:this._spineMaterials2D,s=this._getSpineMaterialByKey(a,this._getSpineMaterialKey(e,t,r,n),i);if(s)return s;let o=this._spineMaterialTextureKeys[e.id];if(o)for(let e of o)if(s=this._getSpineMaterialByKey(a,`${e}_${t}_${r}_${n}`,i),s)return s;return null}_getSpineMaterialByKey(e,r,i){let n=e[r];return n instanceof t.Material&&n.checkType(i?t.ShaderFeatureType.D3:t.ShaderFeatureType.D2_BaseRenderNode2D)?n:null}_getSpineMaterialKey(e,t,r,i){return`${e.id}_${t}_${r}_${i}`}getMaterial(e,r,i,n=!1){e||(console.warn("SpineError:cant Find Main Texture"),e=t.Texture2D.whiteTexture);let a=this._getSpineMaterial(e,r,i,n);if(a)return a;let s=this._getSpineMaterialKey(e,r,i,n?"3D":"2D"),h=this.materialMap.get(s);return h||(h=new t.Material,h.setShaderName(n?"Spine3D":"SpineStandard"),h.renderQueue=n?3e3:2e3,o.initSpineMaterial(h),h.setTextureByIndex(o.SpineTexture,e),1!=e.gammaCorrection?h.addDefine(t.ShaderDefines2D.GAMMATEXTURE):h.removeDefine(t.ShaderDefines2D.GAMMATEXTURE),o.SetSpineBlendMode(r,h,i),i?h.addDefine(o.SPINE_PREMULTIPLYALPHA):h.removeDefine(o.SPINE_PREMULTIPLYALPHA),h._addReference(),this.materialMap.set(s,h)),h}getTexture(e){return this._textures[e]}setTexture(e,t){this._textures||(this._textures={}),this._textures[e]=t,this._registerSpineMaterialTexture(e,t),this.onSpineMaterialsChanged()}registerTexture(e){if(!e)return;let t=e.bitmap;t&&(this._registerTextureByName(e.url,t),this._registerTextureByName(t.url,t))}_registerTextureByName(e,t){if(!e)return;let r=this._textures&&this._textures[e];r!==t&&(r&&r._removeReference(),t._addReference(),this.setTexture(e,t))}_refreshSpineMaterialTextureKeys(){if(this._spineMaterialTextureKeys={},this._textures)for(let e in this._textures)this._registerSpineMaterialTexture(e,this._textures[e])}_registerSpineMaterialTexture(e,t){if(!t)return;let r=this._spineMaterialTextureKeys[t.id];r||(r=this._spineMaterialTextureKeys[t.id]=[]),this._addSpineMaterialTextureKey(r,e),this._addSpineMaterialTextureKey(r,t.uuid),this._addSpineMaterialTextureKey(r,t.url);for(let t in this._spineMaterialTextures)this._spineMaterialTextures[t]===e&&this._addSpineMaterialTextureKey(r,t)}_addSpineMaterialTextureKey(e,t){t&&-1===e.indexOf(t)&&e.push(t)}getAniNameByIndex(e){return this.optimize.getAniNameByIndex(e)}getAnimationCount(){return this.optimize.getAnimationCount()}findAnimation(e){return this.optimize.findAnimation(e)}hasAnimation(e){return this.optimize.hasAnimation(e)}getSkinIndexByName(e){return this.optimize.getSkinIndexByName(e)}checkPremultipliedAlpha(){let e=!0,t=this._textures;for(const r in t){e=t[r]._premultiplyAlpha&&e}return e}_disposeResource(){this.optimize.destroy(),this._parser.destroy();for(let e in this._textures){let t=this._textures[e];t&&t._removeReference()}this._referenceCount<=0?(this.materialMap.forEach(e=>{e._removeReference()}),this.materialMap.clear()):console.error("SpineTemplet is using"),this._parser=null}}h.EVENT_SPINE_MATERIAL_CHANGE="spineMaterialChange";class l{}l.SPLIT_REGEX=/\r?\n/,l.PMA_REGEX=/^pma:\s*(true|false)$/i,l.PREMULTIPLIED_ALPHA_DEFAULT=!0,l.VERSION="3.8",l.VersionFirst=3,l.VersionSecond=8,l.normalRenderSwitch=!1,l.MAX_BONES=100,l.cacheSwitch=!1,l.factory=null,l.VERTEXSIZE=8,l.VERTEX_TWOCOLOR=12,l.VERTEX_INITIAL_CAPACITY=128,l.NORMAL_VERTEX_LENGTH=1024,l.NORMAL_MAX_VERTEX=10922,l.VERTEX_BONE=22,l.VERTEX_RIGIDBODY=10,l.SPINE_STEP=1/30,l.NEED_SLOT=!1,l.ENABLE_WEB_BATCH=!1,e.ESpineRenderMode=void 0,(n=e.ESpineRenderMode||(e.ESpineRenderMode={}))[n.None=0]="None",n[n.Normal=1]="Normal",n[n.Optimize=2]="Optimize",n[n.Bake=3]="Bake",e.ESpineRenderState=void 0,(a=e.ESpineRenderState||(e.ESpineRenderState={}))[a.Stopped=0]="Stopped",a[a.Paused=1]="Paused",a[a.Playing=2]="Playing",t.Laya.addAfterInitCallback(()=>{const e=/^(\d+)\.(\d+)/.exec(l.VERSION),t=Number(e[1]),r=Number(e[2]);l.VersionFirst=t,l.VersionSecond=r,(t>4||4===t&&r>=1)&&(l.NEED_SLOT=!0),l.ENABLE_WEB_BATCH=null!=window.Laya.BatchManager,o.init()});class d extends t.BaseRenderNode2D{get boneMap(){return this._boneMap}constructor(){super(),this._createBone=!1,this.physicsUpdate=0,this._maxDeltaTime=.1,this._pause=!0,this._needUpdate=!1,this._leakReleased=!1,this._releasedTemplet=null,this._playbackRate=1,this._playAudio=!0,this._soundChannelArr=[],this.trackIndex=0,this._skinName="default",this._loop=!0,this._playState=e.ESpineRenderState.Stopped,this._renderOffset=new t.Vector2,this._offset=new t.Vector2,this._transformDirty=!0,this._skinRenderDirty=!1,this._setPreAlphaFlag=!1,this._premultipliedAlpha=!0,this._useFastRender=!0,this._autoAdjust=!1,this._enableCache=!1,this._renderElements=[],this._materials=[]}_isMaterialVaild(e){return e.checkType(t.ShaderFeatureType.D2_BaseRenderNode2D)}_getcommonUniformMap(){return["BaseRender2D","Spine2D"]}_createRenderHandle(){return l.factory.createSpineRenderDataHandle()}get createBone(){return this._createBone}set createBone(e){this._createBone!==e&&(this._createBone=e,e?this._createBones():(this._rootBone.destroy(),this._rootBone=null))}_createBones(){if(this._rootBone||!this._templet)return;this._bones=[];let e=this._spineRender.getBones();if(!e||0===e.length)return;let r=new Map;this._rootBone=new t.Sprite,this._rootBone.name="__bone_root__",this.owner.addChild(this._rootBone);let i=this._spineRender.getSkeletonTransform(),n=-i.x+this._renderOffset.x,a=-i.y-this._renderOffset.y;for(let i=0;i<e.length;i++){let s=e[i],o=new t.Sprite;o.name=s.data.name;let h=new t.Sprite;h.name=s.data.name+"__attach",h.scaleY=-1,o.x=s.worldX+n,o.y=-(s.worldY+a),o.addChild(h),this._rootBone.addChild(o),this._bones.push(o),r.set(s.data.name,h)}this._boneMap=r}getBone(e){return this._boneMap.get(e)}get externalSkins(){return this._externalSkins}set externalSkins(e){if(e)for(let t=e.length-1;t>=0;t--)e[t].target=this;this._externalSkins=e}renderUpdate(e){this._updateLight()}resetExternalSkin(){var e;this._spineRender&&(this._spineRender.resetExternalSkin(),this._flushExtSkin(),this._skinRenderDirty=!0,null===(e=this.owner)||void 0===e||e.repaint(t.RepaintFlag.UpdateRT))}get premultipliedAlpha(){return!this._templet||this._setPreAlphaFlag?this._premultipliedAlpha:this._templet.premultipliedAlpha}set premultipliedAlpha(e){this._premultipliedAlpha=e,this._spineRender&&(this._setPreAlphaFlag||!this._templet?this._spineRender.premultipliedAlpha=e:this._spineRender.premultipliedAlpha=this._templet.premultipliedAlpha)}setPremultipliedAlpha(e){this._premultipliedAlpha=e,this._spineRender.premultipliedAlpha=e,this._setPreAlphaFlag=!0}get source(){return this._source}set source(e){if(this._source=e,e){let r=t.ILaya.loader.getRes(e,t.Loader.SPINE);r?this.templet=r:t.ILaya.loader.load(e,t.Loader.SPINE).then(e=>{!this._source||e&&!e.isCreateFromURL(this._source)||this.destroyed||(this.templet=e)})}else this.templet=null}get skinName(){return this._skinName}set skinName(e){this._skinName=e,this._templet&&this.showSkinByName(e)}get animationName(){return this._animationName}set animationName(e){this._animationName=e,this._templet&&this.play(e,this._loop,!0)}get maxDetlaTime(){return this._maxDeltaTime}set maxDetlaTime(e){this._maxDeltaTime=e}get loop(){return this._loop}set loop(e){this._loop=e,this._templet&&this.play(this._animationName,this._loop,!0)}get url(){return this._skin}set url(e){this._skin!=e&&(this._skin=e,t.Laya.loader.load(e,t.Loader.SPINE).then(e=>{this.init(e)}))}get twoColorTint(){return this._spriteShaderData.hasDefine(o.SPINE_TWOCOLORTINT)}set twoColorTint(e){e?this._spriteShaderData.addDefine(o.SPINE_TWOCOLORTINT):this._spriteShaderData.removeDefine(o.SPINE_TWOCOLORTINT)}get templet(){return this._templet}set templet(e){this.init(e)}set currentTime(e){if(this._templet){if((e/=1e3)<this._playStart||this._playEnd&&e>this._playEnd||e>this._duration)throw new Error("AnimationPlayer: value must large than playStartTime,small than playEndTime.");this._spineRender.currentTime=e}}get currentTime(){return this._templet?this._spineRender.currentTime:0}get playState(){return this._playState}get useFastRender(){return this._useFastRender}set useFastRender(t){this._useFastRender!==t&&(this._useFastRender=t,this._templet&&(this._spineRender.mode=!l.normalRenderSwitch&&t?e.ESpineRenderMode.Optimize:e.ESpineRenderMode.Normal))}get offset(){return this._offset}set offset(r){this._offset=r,this._templet&&(r?(this._renderOffset.x=r.x+this._templet.offsetX,this._renderOffset.y=r.y-this._templet.offsetY):(this._renderOffset.x=this._templet.offsetX,this._renderOffset.y=-this._templet.offsetY),this._renderHandle.offset=this._renderOffset),this.boundsChange=!0,this.playState!==e.ESpineRenderState.Playing&&this.owner.repaint(t.RepaintFlag.UpdateRT)}get autoAdjust(){return this._autoAdjust}set autoAdjust(e){this._autoAdjust!==e&&(this._autoAdjust=e,e&&this._doAutoAdjust())}get enableCache(){return this._enableCache}set enableCache(e){this._enableCache!==e&&(this._enableCache=e,this._spineRender&&(e?this._spineRender.enableCache():this._spineRender.disableCache()),this._animationName&&this.play(this._animationName,this._loop,!0,this._playStart,this._playEnd,!1,this._playAudio))}_doAutoAdjust(){if(!this._templet)return;let e=this._templet.width,t=this._templet.height;if(void 0===e||void 0===t)return console.warn("Spine.SkeletonData: width or height is undefined"),void(this._autoAdjust=!1);e<1&&(e=100),t<1&&(t=100),this.owner.size(Math.round(e),Math.round(t)),this.owner.pivot(Math.round(this._templet.offsetX),Math.round(-this._templet.offsetY))}onEnable(){this._transformDirty=!0,this.owner.on(t.Event.TRANSFORM_CHANGED,this,this.onTransformChanged),!this._leakReleased||!this._releasedTemplet||this._releasedTemplet.destroyed||this._spineRender||this.destroyed||this.init(this._releasedTemplet),this._spineRender&&t.LayaEnv.isPlaying&&void 0!==this._animationName&&this.play(this._animationName,this._loop,!0)}onDisable(){this.owner.off(t.Event.TRANSFORM_CHANGED,this,this.onTransformChanged),!this.destroyed&&this._templet&&this._spineRender&&!this._leakReleased&&(this._leakReleased=!0,this._releasedTemplet=this._templet,this._renderHandle&&(this._renderHandle.skeleton=null),this.clear(),this._rootBone&&(this._rootBone.destroy(),this._rootBone=null,this._bones=null))}init(r){if(this.destroyed)return;if(this._leakReleased=!1,this._releasedTemplet=null,(this._templet||this._spineRender)&&this.clear(),this._templet=r,!this._templet)return;this._templet._addReference(),this._templet.on(h.EVENT_SPINE_MATERIAL_CHANGE,this,this.onSpineMaterialChange),this._struct.renderElements=[],this._struct.setRepaint(),this._spineRender=l.factory.createSpineRender2D(this),this._spineRender.init(r),this._spineRender.mode=!l.normalRenderSwitch&&this._useFastRender?e.ESpineRenderMode.Optimize:e.ESpineRenderMode.Normal,this._spineRender.premultipliedAlpha=this._setPreAlphaFlag?this._premultipliedAlpha:this._templet.premultipliedAlpha,this._enableCache&&this._spineRender.enableCache(),this._autoAdjust&&this._doAutoAdjust(),this._renderOffset.x=this._offset.x+this._templet.offsetX,this._renderOffset.y=this._offset.y-this._templet.offsetY,this._renderHandle.offset=this._renderOffset,this._createBone&&this._createBones(),this.onTransformChanged(),this.boundsChange=!0;let i=this._templet.getSkinIndexByName(this._skinName);-1!=i&&this.showSkinByIndex(i),this.onTransformChanged(),this._spineRender.setEventListener({start:e=>{},interrupt:e=>{},end:e=>{},dispose:e=>{},complete:e=>{const r=this._spineRender;this.owner.event(t.Event.END),r===this._spineRender&&(e.loop?(r.complete(),this.owner.event(t.Event.COMPLETE)):this.stop())},event:(e,r)=>{let i={audioValue:r.data.audioPath,audioPath:r.data.audioPath,floatValue:r.floatValue,intValue:r.intValue,name:r.data.name,stringValue:r.stringValue,time:1e3*r.time,balance:r.balance,volume:r.volume};const n=this._spineRender;if(this.owner.event(t.Event.LABEL,i),n===this._spineRender&&this._playAudio&&i.audioValue){let e=t.SoundManager.playSound(i.audioValue,1,t.Handler.create(this,this._onAniSoundStoped),null,(1e3*n.currentTime-i.time)/1e3);t.SoundManager.playbackRate=this._playbackRate,e&&this._soundChannelArr.push(e)}}}),this._flushExtSkin(),this.owner.event(t.Event.READY),t.LayaEnv.isPlaying&&this.enabled&&void 0!==this._animationName&&this.play(this._animationName,this._loop,!0)}play(r,i,n=!0,a=0,s=0,o=!0,h=!0){if(this._templet){if(this._playAudio=h,a/=1e3,s/=1e3,this._loop=i,a<0||s<0)throw new Error("SpineSkeleton: start and end must large than zero.");if(0!==s&&a>s)throw new Error("SpineSkeleton: start must less than end.");if("number"==typeof r)r=this.getAniNameByIndex(r);else if(!this.templet.hasAnimation(r))return;if(n||this._pause||this._animationName!=r){this._animationName=r,this._spineRender.play(r,i,this.trackIndex,a,s);let n=this._spineRender.trackEntry.animation.duration;this._duration=n,this._playStart=a,this._playEnd=s<=n?s:n,this._pause&&(this._pause=!1,this._needUpdate=!0),this._playState=e.ESpineRenderState.Playing,this._update(),this.owner.event(t.Event.PLAYED)}}else console.warn("Spine2DRenderNode.play: templet is not ready, animation:",r)}_update(){this.owner.repaint(t.RepaintFlag.UpdateRT)}onPreRender(){if(this._needUpdate||this._skinRenderDirty){this._skinRenderDirty=!1;const e=this._spineRender;if(!e)return;if(this._transformDirty){let t=this.owner.globalTrans.getMatrix();e.setSkeletonPosition(t.tx,t.ty),this._transformDirty=!1}let r=t.Laya.timer.delta/1e3;r>this._maxDeltaTime&&(r=this._maxDeltaTime);let i=r*this._playbackRate;if(this._needUpdate&&e.update(i),this.destroyed||e!==this._spineRender)return;e.render(this._needUpdate?e.currentTime:0,this._needUpdate?this.physicsUpdate:0),this._updateBones()}}_updateBones(){if(!this._createBone||!this._bones)return;let e=this._spineRender.getBones();if(!e||0===e.length)return;let r=this._spineRender.getSkeletonTransform(),i=this._renderOffset,n=-r.x+i.x,a=-r.y-i.y;for(let r=0;r<e.length&&r<this._bones.length;r++){let i=e[r],s=this._bones[r],o=s.transform;o||(o=new t.Matrix,s.transform=o),o.a=i.a,o.b=i.b,o.c=-i.c,o.d=-i.d,o.tx=i.worldX+n,o.ty=-(i.worldY+a),s.transform=o}}_flushExtSkin(){let e=this._externalSkins;if(e&&e.length>0){this.useFastRender=!1;for(let t=e.length-1;t>=0;t--)e[t].flush()}}getAnimNum(){return this._templet.getAnimationCount()}getAniNameByIndex(e){return this._templet.getAniNameByIndex(e)}getSlotByName(e){return this._spineRender.findSlot(e)}playbackRate(e){this._playbackRate=e}showSkinByName(e){this.showSkinByIndex(this._templet.getSkinIndexByName(e))}showSkinByIndex(e){var r;this._spineRender.showSkinByIndex(e),this._flushExtSkin(),this._skinRenderDirty=!0,null===(r=this.owner)||void 0===r||r.repaint(t.RepaintFlag.UpdateRT)}stop(){this._playState!==e.ESpineRenderState.Stopped&&(this._pause=!0,this._needUpdate=!1,this._playState=e.ESpineRenderState.Stopped,this.owner.event(t.Event.STOPPED),this._soundChannelArr.length>0&&this._onAniSoundStoped(!0))}onUpdate(){this._needUpdate&&this._update()}paused(){if(!this._pause&&(this._pause=!0,this._needUpdate=!1,this._playState=e.ESpineRenderState.Paused,this.owner.event(t.Event.PAUSED),this._soundChannelArr.length>0))for(let e=this._soundChannelArr.length,t=0;t<e;t++){let e=this._soundChannelArr[t];e.isStopped||e.pause()}}resume(){if(this._playState===e.ESpineRenderState.Paused&&(this._pause=!1,this._needUpdate=!0,this._playState=e.ESpineRenderState.Playing,this._soundChannelArr.length>0))for(let e=this._soundChannelArr.length,t=0;t<e;t++){let e=this._soundChannelArr[t];e.audioBuffer&&e.resume()}}_onAniSoundStoped(e){for(let t=this._soundChannelArr.length,r=0;r<t;r++){let i=this._soundChannelArr[r];(i.isStopped||e)&&(!i.isStopped&&i.stop(),this._soundChannelArr.splice(r,1),t--,r--)}}onSpineMaterialChange(){this._spineRender&&this._spineRender.clearCacheMaterials()}reset(){var t;null===(t=this._spineRender)||void 0===t||t.reset(),this._templet&&(this._templet.off(h.EVENT_SPINE_MATERIAL_CHANGE,this,this.onSpineMaterialChange),this._templet._removeReference(1),this._templet=null),this._pause=!0,this._needUpdate=!1,this._playState=e.ESpineRenderState.Stopped,this._soundChannelArr.length>0&&this._onAniSoundStoped(!0),this.owner.repaint()}addAnimation(e,t=!1,r=0){r/=1e3;let i=e;"number"==typeof i&&(i=this.getAniNameByIndex(i)),this._animationName=i,this._spineRender.addAnimation(i,t,r,this.trackIndex)}setSlotTexture(e,t,r=!0,i=!0){this._useFastRender?console.log("setSlotTexture: useFastRender is true, return"):this._spineRender.setSlotTexture(e,t,r,i)}restoreSlotTexture(e){var t,r;return this._useFastRender?(console.log("restoreSlotTexture: useFastRender is true, return"),!1):null!==(r=null===(t=this._spineRender)||void 0===t?void 0:t.restoreSlotTexture(e))&&void 0!==r&&r}setTempletAttachment(e,r,i,n){var a;this._useFastRender?console.log("setTempletAttachment: useFastRender is true, return"):(this._spineRender.setTempletAttachment(e,r,i,n),this._skinRenderDirty=!0,null===(a=this.owner)||void 0===a||a.repaint(t.RepaintFlag.UpdateRT))}setMix(e,t,r){r/=1e3;let i=e;"number"==typeof i&&(i=this.getAniNameByIndex(i));let n=t;"number"==typeof n&&(n=this.getAniNameByIndex(n)),this._spineRender.setMix(i,n,r)}getBoneByName(e){return this._spineRender.findBone(e)}getSkeleton(){return this._spineRender?this._spineRender.getSkeleton():null}updateWorldTransform(e=this.physicsUpdate){this._spineRender&&this._spineRender.updateWorldTransform(e)}physicsTranslate(e,t){this._spineRender.physicsTranslate(e,t)}onTransformChanged(){this._transformDirty=!0}setSlotAttachment(e,t){this.useFastRender=!1,this._spineRender.setAttachment(e,t)}clear(){var e;this._needUpdate=!1,this._pause=!0;const t=this._spineRender;this._spineRender=null,this._struct.renderElements=this._renderElements,null===(e=this.owner)||void 0===e||e.repaint(),null==t||t.destroy(),this.reset()}onDestroy(){this._releasedTemplet=null,(this._templet||this._spineRender)&&this.clear(),this._rootBone&&(this._rootBone.destroy(),this._rootBone=null,this._bones=null)}get rect(){return this._boundsChange&&(this._templet?(this._rect.z=this._templet.width+this._renderOffset.x,this._rect.w=this._templet.height+this._renderOffset.y):(this._rect.z=this.owner.width+this._renderOffset.x,this._rect.w=this.owner.height+this._renderOffset.y),this._rect.x=this._renderOffset.x,this._rect.y=this._renderOffset.y,this._boundsChange=!1),this._rect}}d.STOPPED=0,d.PAUSED=1,d.PLAYING=2;class u extends t.Sprite{constructor(){super(),this._spineComponent=this.addComponent(d)}get externalSkins(){return this._spineComponent.externalSkins}set externalSkins(e){this._spineComponent.externalSkins=e}resetExternalSkin(){this._spineComponent.resetExternalSkin()}get source(){return this._spineComponent.source}set source(e){this._spineComponent.source=e}get skinName(){return this._spineComponent.skinName}set skinName(e){this._spineComponent.skinName=e}get animationName(){return this._spineComponent.animationName}set animationName(e){this._spineComponent.animationName=e}get loop(){return this._spineComponent.loop}set loop(e){this._spineComponent.loop=e}get templet(){return this._spineComponent.templet}set templet(e){this._spineComponent.templet=e}set currentTime(e){this._spineComponent.currentTime=e}get playState(){return this._spineComponent.playState}play(e,t,r=!0,i=0,n=0,a=!0,s=!0){this._spineComponent.play(e,t,r,i,n,a,s)}getAnimNum(){return this._spineComponent.getAnimNum()}getAniNameByIndex(e){return this._spineComponent.getAniNameByIndex(e)}getSlotByName(e){return this._spineComponent.getSlotByName(e)}playbackRate(e){this._spineComponent.playbackRate(e)}showSkinByName(e){this._spineComponent.showSkinByName(e)}showSkinByIndex(e){this._spineComponent.showSkinByIndex(e)}stop(){this._spineComponent.stop()}paused(){this._spineComponent.paused()}resume(){this._spineComponent.resume()}destroy(e=!0){this._spineComponent.templet&&this._spineComponent.clear(),super.destroy(e)}addAnimation(e,t=!1,r=0){this._spineComponent.addAnimation(e,t,r)}setMix(e,t,r){this._spineComponent.setMix(e,t,r)}getBoneByName(e){return this._spineComponent.getBoneByName(e)}getSkeleton(){return this._spineComponent.getSkeleton()}updateWorldTransform(e=this._spineComponent.physicsUpdate){this._spineComponent.updateWorldTransform(e)}setSlotAttachment(e,t){this._spineComponent.setSlotAttachment(e,t)}}e.ESpineRenderType=void 0,(s=e.ESpineRenderType||(e.ESpineRenderType={}))[s.boneGPU=0]="boneGPU",s[s.normal=1]="normal",s[s.rigidBody=2]="rigidBody";let _=t.ClassUtils.regClass;_("SpineSkeleton",u),_("ExternalSkin",r),_("ExternalSkinItem",i),_("Spine2DRenderNode",d),t.Laya.addBeforeInitCallback(()=>{t.PlayerConfig.spineVersion&&(l.VERSION=t.PlayerConfig.spineVersion)});class c{constructor(){this._recoverList=new t.FastSinglelist}batch(e,t,r,i){if(t>r)return;let n=e.elements;if(1===r-t+1)return void e.add(n[t]);let a=t;for(let i=t;i<r;i++){let t=n[i],r=n[i+1];this.check(t,r)||(i>a?this._batchInternal(e,a,i-a+1):e.add(n[a]),a=i+1)}a<=r&&(r>a?this._batchInternal(e,a,r-a+1):e.add(n[a]))}reset(){this.recover()}destroy(){this.recover(),this._recoverList.length=0}check(e,t){return e.materialShaderData===t.materialShaderData&&(!e.geometry.instanceCount&&!t.geometry.instanceCount)}batchRenderElement(e,t,r,i=1){let n=e.elements,a=-1;for(let i=0;i<r-1;i++){let r=t+i,s=n[r],o=n[r+1];this.check(s,o)?-1==a&&(a=i):(-1!=a?this._batchInternal(e,a+t,i-a):e.add(n[t+i]),a=-1)}-1!=a?this._batchInternal(e,a+t,r-a):r>0&&e.add(n[t+r-1])}updateBuffer(e,t,r,i){let n=e.nMatrixInstanceVB,a=e.simpleAnimatorVB;n.setData(t.buffer,0,0,6*i*4),a.setData(r.buffer,0,0,4*i*4)}_batchInternal(e,r,i){let n,a,s,h=e.elements,l=p._instanceBufferCreate(6*p.MaxInstanceCount),d=p._instanceBufferCreate(4*p.MaxInstanceCount),u=null,_=0;for(let c=0;c<i;c++){let i=h[r+c],m=i.value2DShaderData,f=i.geometry;if(!n||u!==f){n&&_>0&&(this.updateBuffer(s,l,d,_),a.instanceCount=_,e.add(n),n=null,_=0),s=p.getInstanceInfo(),n=s.element,this._recoverList.add(s),a=n.geometry,u=f;let t=f.bufferState,r=t._vertexBuffers.slice();r.push(s.nMatrixInstanceVB),r.push(s.simpleAnimatorVB),s.state.applyState(r,t._bindedIndexBuffer),a.bufferState=s.state,a.drawParams.elements=f.drawParams.elements.slice(),a.drawParams.length=f.drawParams.length,a.indexFormat=f.indexFormat,n.subShader=i.subShader,n.materialShaderData=i.materialShaderData,n.value2DShaderData=i.value2DShaderData,n.renderStateIsBySprite=i.renderStateIsBySprite,n.nodeCommonMap=i.nodeCommonMap,n.value2DShaderData.addDefine(o.SPINE_GPU_INSTANCE)}let x=m.getVector3(t.ShaderDefines2D.UNIFORM_NMATRIX_0),g=m.getVector3(t.ShaderDefines2D.UNIFORM_NMATRIX_1),S=6*_;l[S]=x.x,l[S+1]=x.y,l[S+2]=x.z,l[S+3]=g.x,l[S+4]=g.y,l[S+5]=g.z;let y=m.getVector(o.SIMPLE_SIMPLEANIMATORPARAMS),D=4*_;d[D]=y.x,d[D+1]=y.y,d[D+2]=y.z,d[D+3]=y.w,_++,a.instanceCount=_,a.instanceCount==p.MaxInstanceCount&&(this.updateBuffer(s,l,d,a.instanceCount),e.add(n),n=null,u=null,_=0)}n&&_>0&&(this.updateBuffer(s,l,d,_),a.instanceCount=_,e.add(n)),p._instanceBufferRecover(l),p._instanceBufferRecover(d)}recover(){let e=this._recoverList.length,t=this._recoverList.elements;for(let r=0;r<e;r++){let e=t[r];p.recover(e)}this._recoverList.length=0}}class p{static getInstanceInfo(){return p._instanceInfoPool.pop()||p.createInstanceInfo()}static createInstanceInfo(){let e=t.LayaGL.render2DRenderPassFactory.createRenderElement2D();e.geometry=t.LayaGL.renderDeviceFactory.createRenderGeometryElement(t.MeshTopology.Triangles,t.DrawType.DrawElementInstance);let r=t.LayaGL.renderDeviceFactory.createBufferState(),i=t.LayaGL.renderDeviceFactory.createVertexBuffer(t.BufferUsage.Dynamic);i.setDataLength(6*p.MaxInstanceCount*4),i.vertexDeclaration=o.instanceNMatrixDeclaration,i.instanceBuffer=!0;let n=t.LayaGL.renderDeviceFactory.createVertexBuffer(t.BufferUsage.Dynamic);return n.setDataLength(4*p.MaxInstanceCount*4),n.vertexDeclaration=o.instanceSimpleAnimatorDeclaration,n.instanceBuffer=!0,{state:r,element:e,nMatrixInstanceVB:i,simpleAnimatorVB:n}}static recover(e){let t=e.element;t.value2DShaderData&&t.value2DShaderData.removeDefine(o.SPINE_GPU_INSTANCE),t.value2DShaderData=null,t.materialShaderData=null,t.subShader=null,t.nodeCommonMap=null,t.geometry.bufferState=null,t.geometry.drawParams.elements=[],t.geometry.drawParams.length=0,p._instanceInfoPool.push(e)}static _instanceBufferCreate(e){let t=p._bufferPool[e];return t||(t=p._bufferPool[e]=[]),t.pop()||new Float32Array(e)}static _instanceBufferRecover(e){let t=e.length,r=p._bufferPool[t];r||(r=p._bufferPool[t]=[]),r.push(e)}}p.MaxInstanceCount=2048,p._instanceInfoPool=[],p._bufferPool=[];class m{static _growGlobalArraysIfNeeded(e,t){if(e>m._globalTempVertexData.length){const t=Math.ceil(e/m.ARRAY_GROWTH_STEP_VERTEX)*m.ARRAY_GROWTH_STEP_VERTEX;m._globalTempVertexData=new Float32Array(t)}if(t>m._globalTempIndexData.length){const e=Math.ceil(t/m.ARRAY_GROWTH_STEP_INDEX)*m.ARRAY_GROWTH_STEP_INDEX;m._globalTempIndexData=new Uint16Array(e)}}constructor(e,t){this.currentVertexCount=0,this._vertexCapacity=0,this._indexCapacity=0,this._vertexFloatCount=0,this._indexCount=0,this._needResetData=!1,this._inPass=!1,this._num=0,this.vertexBuffer=e,this.indexBuffer=t}resetCapacity(e,t){e>this._vertexCapacity&&(this._vertexCapacity=e,this.vertexBuffer.setDataLength(4*e));const r=2*Math.ceil(t/2);r>this._indexCapacity&&(this._indexCapacity=r,this.indexBuffer._setIndexDataLength(2*r)),this._needResetData=!0}_ensureCapacityForViews(){if(m._growGlobalArraysIfNeeded(this._vertexFloatCount,this._indexCount),this._vertexFloatCount>this._vertexCapacity||this._indexCount>this._indexCapacity){const e=this._vertexFloatCount>this._vertexCapacity?Math.max(this._vertexFloatCount,2*this._vertexCapacity):this._vertexCapacity,t=this._indexCount>this._indexCapacity?Math.max(this._indexCount,2*this._indexCapacity):this._indexCapacity;this.resetCapacity(e,t)}}addDataView(e){e._next=null,e._prev=null,this._first||(this._first=e),this._last&&(this._last._next=e,e._prev=this._last),e.owner=this,this._last=e,this._num++,this.currentVertexCount+=e.vertexCount,this._vertexFloatCount+=e.vertexBufferLength,this._indexCount+=e.indexBufferLength,this._needResetData=!0,t.WebRender2DPass.setBuffer(this)}removeDataView(e){e.owner=null,e._prev&&(e._prev._next=e._next),e._next&&(e._next._prev=e._prev),e==this._first&&(this._first=e._next),e==this._last&&(this._last=e._prev),e._next=null,e._prev=null,this._num--,this.currentVertexCount-=e.vertexCount,this._vertexFloatCount-=e.vertexBufferLength,this._indexCount-=e.indexBufferLength,this._needResetData=!0,t.WebRender2DPass.setBuffer(this)}clearDataViews(){let e=this._first;for(;e;){const t=e._next;e.owner=null,e._prev=null,e._next=null,e=t}this._first=null,this._last=null,this._num=0,this.currentVertexCount=0,this._vertexFloatCount=0,this._indexCount=0,this._needResetData=!0,t.WebRender2DPass.setBuffer(this)}canFit(e){return this.currentVertexCount+e<=m.MAX_VERTICES}_modifyOneView(e){this._needResetData=!0}_upload(){if(!this._needResetData)return;if(!this._first)return;const e=this._vertexFloatCount,t=this._indexCount;if(0===e||0===t)return void(this._needResetData=!1);this._ensureCapacityForViews();const r=m._globalTempVertexData,i=m._globalTempIndexData;let n=0,a=0,s=0,o=this._first;for(;o;){if(o.vertexBufferLength>0){let e=o.cacheIndex||o.indexData;r.set(o.getUploadVertexData(),n);for(let t=0;t<o.indexCount;t++)i[a+t]=e[t]+s;o.geometry&&(o.geometry.clearRenderParams(),o.geometry.bufferState=this.bufferState,o.geometry.setDrawElemenParams(o.indexCount,2*a)),n+=o.vertexBufferLength,a+=o.indexBufferLength,s+=o.vertexCount}o=o._next}this.vertexBuffer.setData(m._globalTempVertexData.buffer,0,0,4*e);const h=2*Math.ceil(t/2);h!==t&&(m._globalTempIndexData[t]=0),this.indexBuffer.setData(m._globalTempIndexData.buffer,0,0,2*h),this._needResetData=!1}destroy(){var e,t;this._first=null,this._last=null,null===(e=this.vertexBuffer)||void 0===e||e.destroy(),null===(t=this.indexBuffer)||void 0===t||t.destroy(),this.vertexBuffer=null,this.indexBuffer=null}}m.MAX_VERTICES=65535,m.ARRAY_GROWTH_STEP_VERTEX=l.NORMAL_VERTEX_LENGTH*l.VERTEX_TWOCOLOR,m.ARRAY_GROWTH_STEP_INDEX=3*l.NORMAL_VERTEX_LENGTH,m._globalTempVertexData=new Float32Array(m.ARRAY_GROWTH_STEP_VERTEX),m._globalTempIndexData=new Uint16Array(m.ARRAY_GROWTH_STEP_INDEX);class f{constructor(){this.element=null,this.materialShaderData=null,this.ownerStruct=null,this.subShader=null,this.stencilClipState=null}setHead(e){return this.element=e,this.ownerStruct=e.owner,this.materialShaderData=e.materialShaderData,this.subShader=e.subShader,this.stencilClipState=e.stencilClipState,!0}isCompatible(e){return e.subShader===this.subShader&&(e.materialShaderData===this.materialShaderData&&e.stencilClipState===this.stencilClipState)}getViewFromGeometry(e){return this.element=e,this.ownerStruct=e.owner,this.materialShaderData=e.materialShaderData,e.owner.renderDataHandler.normalUpdater.getViewForGeometry(e.geometry)}}class x{constructor(){this._batchBufferPool=[],this._retiredBatchBuffers=[],this._activeBatchBuffers=[],this._activeBatchBufferCount=0,this._context=new f,this._merged=[],this._mergedCount=0}batch(e,t,r,i){if(t>r)return;let n=e.elements,a=this._context,s=n[t];if(!a.setHead(s)){if(e.add(s),t===r)return;if(s=n[++t],!a.setHead(s))return void e.add(s)}let o=t,h=t,l=a.getViewFromGeometry(s);if(!l){if(e.add(s),t===r)return;if(s=n[++t],!a.setHead(s))return void e.add(s);if(l=a.getViewFromGeometry(s),!l)return void e.add(s)}let d=l.vertexCount;for(let i=t+1;i<=r;i++){let t=n[i];if(a.isCompatible(t)){let r=a.getViewFromGeometry(t);if(!r)continue;let s=r.vertexCount;if(d+s<=x.MAX_VERTICES_PER_BATCH){h=i,d+=s;continue}h>o?this._createBatchedElement(e,n,o,h):e.add(n[o]),o=i,h=i,d=s;continue}if(h>o?this._createBatchedElement(e,n,o,h):o>=0&&e.add(n[o]),a.setHead(t)){let e=a.getViewFromGeometry(t);o=i,h=i,d=e?e.vertexCount:0}else e.add(t),o=-1,d=0}o>=0&&(h>o?this._createBatchedElement(e,n,o,h):e.add(n[o]))}_createBatchedElement(e,t,r,i){let n=this._getBatchBuffer(),a=0,s=0;for(let e=r;e<=i;e++){let r=t[e],i=r.owner.renderDataHandler.normalUpdater.getViewForGeometry(r.geometry);i&&(a+=i.vertexBufferLength,s+=i.indexBufferLength)}n.wholeBuffer.resetCapacity(a,s);for(let e=r;e<=i;e++){let r=t[e],i=r.owner.renderDataHandler.normalUpdater.getViewForGeometry(r.geometry);i&&i.transferToBuffer(n.wholeBuffer)}let o=t[r],h=x._pool.take();this._merged[this._mergedCount++]=h;let l=h.geometry;l.bufferState=n.bufferState,l.setDrawElemenParams(s,0),l.indexFormat=o.geometry.indexFormat,h.subShader=o.subShader,h.materialShaderData=o.materialShaderData,h.value2DShaderData=o.value2DShaderData,h.renderStateIsBySprite=o.renderStateIsBySprite,h.nodeCommonMap=o.nodeCommonMap,e.add(h)}_getBatchBuffer(){let e=this._batchBufferPool.pop();if(!e){let r=t.LayaGL.renderDeviceFactory.createVertexBuffer(t.BufferUsage.Dynamic);r.vertexDeclaration=o.SpineNormalVertexDeclaration;let i=t.LayaGL.renderDeviceFactory.createIndexBuffer(t.BufferUsage.Dynamic),n=new m(r,i);n.resetCapacity(4096*l.VERTEX_TWOCOLOR,12288);let a=t.LayaGL.renderDeviceFactory.createBufferState();a.applyState([r],i),n.bufferState=a,e={wholeBuffer:n,bufferState:a}}return this._activeBatchBuffers[this._activeBatchBufferCount++]=e,e}reset(){let e=0;for(let t=0;t<this._retiredBatchBuffers.length;t++){let r=this._retiredBatchBuffers[t];r.wholeBuffer._first?this._retiredBatchBuffers[e++]=r:this._batchBufferPool.push(r)}this._retiredBatchBuffers.length=e;for(let e=0;e<this._activeBatchBufferCount;e++)this._retiredBatchBuffers.push(this._activeBatchBuffers[e]);this._activeBatchBufferCount=0;for(let e=0;e<this._mergedCount;e++)x._pool.recover(this._merged[e]);this._mergedCount=0}destroy(){for(let e of this._batchBufferPool)e.wholeBuffer.destroy(),e.bufferState.destroy();for(let e=0;e<this._activeBatchBufferCount;e++){let t=this._activeBatchBuffers[e];t.wholeBuffer.destroy(),t.bufferState.destroy()}for(let e of this._retiredBatchBuffers)e.wholeBuffer.destroy(),e.bufferState.destroy();this._batchBufferPool=[],this._activeBatchBuffers=[],this._retiredBatchBuffers=[];for(let e=0;e<this._mergedCount;e++)x._pool.recover(this._merged[e]);this._merged.length=0,this._mergedCount=0}}x.MAX_VERTICES_PER_BATCH=65535,x._pool=t.Pool.createPool2(()=>{let e=t.LayaGL.render2DRenderPassFactory.createRenderElement2D();return e.geometry=t.LayaGL.renderDeviceFactory.createRenderGeometryElement(t.MeshTopology.Triangles,t.DrawType.DrawElement),e.geometry.indexFormat=t.IndexFormat.UInt16,e.nodeCommonMap=["Sprite2D"],e},null,e=>{e.geometry.clearRenderParams(),e.geometry.bufferState=null,e.materialShaderData=null,e.value2DShaderData=null,e.subShader=null,e.owner=null});const g=[0,1,2,2,3,0];class S{constructor(){this.clipper=new spine.SkeletonClipping,this.batches=[],this._currentBatchIndex=-1,this._internalMaterials=[],this.materials=[],this._materialIndex=0,this.needUpdate=!1,this.subMeshes=[],this.autoCacheEnabled=!1}static __init__(){S.positions=new Float32Array(2*l.NORMAL_MAX_VERTEX),S._TEMP_COLOR=new spine.Color,S._TEMP_COLOR2=new spine.Color}restoreFromCache(e,r=0,i=0){if(!e)return;const n=e.renderBlocks.length;if(this.batches.length<n)for(let r=this.batches.length;r<n;r++){const i=o.SpineNormalVertexDeclaration,n=t.LayaGL.renderDeviceFactory.createVertexBuffer(t.BufferUsage.Dynamic);n.vertexDeclaration=i;const a=t.LayaGL.renderDeviceFactory.createIndexBuffer(t.BufferUsage.Dynamic),s=t.LayaGL.renderDeviceFactory.createBufferState();s.applyState([n],a);const h={vertexData:new Float32Array(l.VERTEX_INITIAL_CAPACITY*l.VERTEX_TWOCOLOR),indexData:new Uint16Array(3*l.VERTEX_INITIAL_CAPACITY),vertexLength:0,indexLength:0,bufferState:s,cacheVertex:null,cacheIndex:null,offsetX:0,offsetY:0},d=t.LayaGL.renderDeviceFactory.createRenderGeometryElement(t.MeshTopology.Triangles,t.DrawType.DrawElement);d.indexFormat=t.IndexFormat.UInt16,d.bufferState=s;const u=r<e.materials.length?r:e.materials.length-1,_=e.materials[u]||null;this.batches[r]={geometry:d,buffer:h,material:_,materialIndex:u}}for(let t=0;t<n;t++){const n=e.renderBlocks[t],a=this.batches[t],s=a.buffer,o=a.geometry;s.cacheVertex=n.vertexData,s.vertexLength=n.vertexLength,s.offsetX=r,s.offsetY=i,s.cacheIndex=n.indexData,s.indexLength=n.indexLength,this.uploadBuffer(s,!0),o.clearRenderParams(),o.setDrawElemenParams(n.indexLength,0),t<e.materials.length&&(a.material=e.materials[t],a.materialIndex=t)}this._currentBatchIndex=n-1,this._syncRenderBatches(n),this._materialIndex=n,this.needUpdate=!0}getCurrentBatch(){let e=this.batches[this._currentBatchIndex];if(!e){const r=o.SpineNormalVertexDeclaration,i=t.LayaGL.renderDeviceFactory.createVertexBuffer(t.BufferUsage.Dynamic);i.vertexDeclaration=r;const n=t.LayaGL.renderDeviceFactory.createIndexBuffer(t.BufferUsage.Dynamic),a=t.LayaGL.renderDeviceFactory.createBufferState();a.applyState([i],n);const s={vertexData:new Float32Array(l.NORMAL_VERTEX_LENGTH*l.VERTEX_TWOCOLOR),indexData:new Uint16Array(3*l.NORMAL_VERTEX_LENGTH),vertexLength:0,indexLength:0,bufferState:a,cacheVertex:null,cacheIndex:null,offsetX:0,offsetY:0},h=t.LayaGL.renderDeviceFactory.createRenderGeometryElement(t.MeshTopology.Triangles,t.DrawType.DrawElement);h.indexFormat=t.IndexFormat.UInt16,h.bufferState=a;const d=this._materialIndex-1;e={geometry:h,buffer:s,material:d>=0?this._internalMaterials[d]:null,materialIndex:d},this.batches[this._currentBatchIndex]=e}return e}_syncRenderBatches(e){this.subMeshes.length=0,this.materials.length=0;for(let t=0;t<e;t++){const e=this.batches[t];e&&e.material&&0!==e.buffer.vertexLength&&0!==e.buffer.indexLength&&(this.subMeshes.push(e.geometry),this.materials.push(e.material))}}getCurrentSubMeshBuffer(){return this.getCurrentBatch().buffer}ensureVerticesCapacity(e,t){if(t>e.vertexData.length){const r=Math.max(t,2*e.vertexData.length),i=new Float32Array(r);i.set(e.vertexData),e.vertexData=i}}ensureIndicesCapacity(e,t){if(t>e.indexData.length){const r=Math.max(t,2*e.indexData.length),i=new Uint16Array(r);i.set(e.indexData),e.indexData=i}}renderUpdate(e,t,r,i,n,a=0,s=0){let o,h,d,u,_=this.clipper,c=null,p=t.drawOrder,m=t.color,f=l.VERTEX_TWOCOLOR,x=!1;-1==i&&(x=!0);let y=S.positions,D=S._TEMP_COLOR,E=S._TEMP_COLOR2;this._materialIndex=0,this._currentBatchIndex=-1;const R=()=>{if(this._currentBatchIndex>=0){const e=this.batches[this._currentBatchIndex];e&&e.buffer.vertexLength>0&&(e.geometry.clearRenderParams(),e.geometry.setDrawElemenParams(e.buffer.indexLength,0),this.uploadBuffer(e.buffer))}this._currentBatchIndex++;const e=this.getCurrentBatch();e.buffer.vertexLength=0,e.buffer.indexLength=0,e.buffer.cacheVertex=null,e.buffer.cacheIndex=null,e.buffer.offsetX=a,e.buffer.offsetY=s;const t=this._materialIndex-1;e.material=t>=0?this._internalMaterials[t]:null,e.materialIndex=t};for(let e=0,t=p.length;e<t;e++){let t=_.isClipping()?2:f,I=p[e],B=l.NEED_SLOT?I:I.bone;if(!I.bone.active){_.clipEndWithSlot(I);continue}if(i>=0&&i==I.data.index&&(x=!0),!x){_.clipEndWithSlot(I);continue}n>=0&&n==I.data.index&&(x=!1);let v,A=I.getAttachment(),C=0;if(A instanceof window.spine.RegionAttachment){let e=A;C=t<<2,null!=A.sequence&&A.sequence.apply(I,A),e.computeWorldVertices(B,y,0,t),h=g,o=e.uvs,v=e.region.page.texture,d=e.color}else{if(!(A instanceof window.spine.MeshAttachment)){if(A instanceof window.spine.ClippingAttachment){this.clipper.clipStart(I,A);continue}_.clipEndWithSlot(I);continue}{let e=A;C=(e.worldVerticesLength>>1)*t,C>y.length&&(y=new Float32Array(C),S.positions=y),e.computeWorldVertices(I,0,e.worldVerticesLength,y,0,t),h=e.triangles,v=e.region.page.texture,o=e.uvs,d=e.color}}if(v){let e=I.color,t=D;t.r=m.r*e.r*d.r,t.g=m.g*e.g*d.g,t.b=m.b*e.b*d.b,t.a=m.a*e.a*d.a;let i=E;I.darkColor?i.setFromColor(I.darkColor):i.set(0,0,0,1);let n=I.data.blendMode,l=!1;if(n!=c&&(c=n,l=!0),u!=v&&(u=v,l=!0),l){const e=this._currentBatchIndex<0||this.batches[this._currentBatchIndex].buffer.vertexLength>0;if(this.addMaterial(r.owner._getMaterial(v.realTexture,c)),e)R();else{const e=this.batches[this._currentBatchIndex];e.material=this._internalMaterials[this._materialIndex-1],e.materialIndex=this._materialIndex-1}}_.isClipping()?(_.clipTriangles(y,C,h,h.length,o,t,i,true),this.canAppend(_.clippedVertices.length)||R(),this.appendVerticesClip(_.clippedVertices,_.clippedTriangles,f,a,s)):(this.canAppend(C)||R(),0!=t.a&&this.appendVertices(y,o,t,i,C,h,h.length,f,a,s))}_.clipEndWithSlot(I)}if(_.clipEnd(),this._currentBatchIndex>=0){const e=this.batches[this._currentBatchIndex];e.buffer.vertexLength>0&&(e.geometry.clearRenderParams(),e.geometry.setDrawElemenParams(e.buffer.indexLength,0),this.uploadBuffer(e.buffer))}const I=this._currentBatchIndex+1;if(I<this.batches.length)for(let e=I;e<this.batches.length;e++)this.destroyBatch(this.batches[e]);if(this.batches.length=I,this._syncRenderBatches(I),this.needUpdate=!0,this.autoCacheEnabled&&r&&!r.owner._hasExternalSkin){let e=r.cacheFrameIndex,t=r.currentData;if(e>=0&&!t.renderCache[e]){let r=[];for(let e=0;e<I;e++){const t=this.batches[e];t&&t.material&&t.buffer.vertexLength>0&&t.buffer.indexLength>0&&r.push({vertexData:t.buffer.vertexData.slice(0,t.buffer.vertexLength),vertexLength:t.buffer.vertexLength,indexData:t.buffer.indexData.slice(0,t.buffer.indexLength),indexLength:t.buffer.indexLength})}let i={renderBlocks:r,materials:this.materials.slice()};t.renderCache[e]=i}}}destroyBatch(e){let t=e.buffer.bufferState._vertexBuffers;for(let e=0;e<t.length;e++)t[e].destroy();e.buffer.bufferState._bindedIndexBuffer.destroy(),e.buffer.bufferState.destroy(),e.geometry.destroy()}addMaterial(e){this._internalMaterials[this._materialIndex]!==e?(this._internalMaterials[this._materialIndex]=e,this._materialIndex++,this.needUpdate=!0):this._materialIndex++}canAppend(e){if(this._currentBatchIndex<0)return!0;const t=this.batches[this._currentBatchIndex];if(!t)return!0;return t.buffer.vertexLength/l.VERTEX_TWOCOLOR+e/l.VERTEX_TWOCOLOR<S.MAX_VERTICES_PER_BUFFER}uploadBuffer(e,t=!1){if(!e||!e.bufferState)return;const r=4*e.vertexLength,i=2*e.indexLength;let n=e.bufferState._vertexBuffers[0];n.setDataLength(r),t&&e.cacheVertex?n.setData(e.cacheVertex.buffer,0,0,r):n.setData(e.vertexData.buffer,0,0,r);let a=e.bufferState._bindedIndexBuffer;a._setIndexDataLength(i),t&&e.cacheIndex?a.setData(e.cacheIndex.buffer,0,0,i):a.setData(e.indexData.buffer,0,0,i)}appendVerticesClip(e,t,r,i,n){let a=e.length;if(0==a)return;let s=t.length;const o=this.getCurrentSubMeshBuffer();this.ensureVerticesCapacity(o,o.vertexLength+a),this.ensureIndicesCapacity(o,o.indexLength+s);let h=o.vertexData,l=o.indexData,d=o.vertexLength,u=d/r,_=d;for(let t=0;t<a;_+=r,t+=r)h[_]=e[t+6],h[_+1]=e[t+7],h[_+2]=e[t+2],h[_+3]=e[t+3],h[_+4]=e[t+4],h[_+5]=e[t+5],h[_+6]=e[t]+i,h[_+7]=e[t+1]+n,h[_+8]=e[t+8],h[_+9]=e[t+9],h[_+10]=e[t+10],h[_+11]=e[t+11];o.vertexLength=d+a;for(let e=o.indexLength,r=0;r<s;e++,r++)l[e]=t[r]+u;o.indexLength+=s}appendVertices(e,t,r,i,n,a,s,o,h,l){if(0==n)return;const d=this.getCurrentSubMeshBuffer();this.ensureVerticesCapacity(d,d.vertexLength+n),this.ensureIndicesCapacity(d,d.indexLength+s);let u=d.vertexData,_=d.indexData,c=d.vertexLength,p=c/o;for(let a=0,s=0,d=n;s<d;s+=o,a+=2){let n=c+s;u[n]=t[a],u[n+1]=t[a+1],u[n+2]=r.r,u[n+3]=r.g,u[n+4]=r.b,u[n+5]=r.a,u[n+6]=e[s]+h,u[n+7]=e[s+1]+l,u[n+8]=i.r,u[n+9]=i.g,u[n+10]=i.b,u[n+11]=i.a}for(let e=d.indexLength,t=0;t<s;e++,t++)_[e]=a[t]+p;d.vertexLength=c+n,d.indexLength+=s}exportToCache(){let e=[];for(let t=0;t<=this._currentBatchIndex;t++){const r=this.batches[t];r&&e.push({vertexData:new Float32Array(r.buffer.vertexData.subarray(0,r.buffer.vertexLength)),vertexLength:r.buffer.vertexLength,indexData:new Uint16Array(r.buffer.indexData.subarray(0,r.buffer.indexLength)),indexLength:r.buffer.indexLength})}return{renderBlocks:e,materials:this.materials.slice(0,this._materialIndex)}}destroy(){this.batches.forEach(e=>{this.destroyBatch(e)}),this.subMeshes.forEach(e=>{e.destroy()}),this.subMeshes.length=0,this.batches.length=0}}S.MAX_VERTICES_PER_BUFFER=65536;class y{static createMesh(e,r,i,n=!1,a=!0){let s=new t.Mesh2D,o=[],h=n?t.BufferUsage.Dynamic:t.BufferUsage.Static,l=t.LayaGL.renderDeviceFactory.createVertexBuffer(h),d=r.vertexDeclaration,u=d.vertexStride;l.vertexDeclaration=d;let _=r.maxVertexCount*u,c=r.vbLength*Float32Array.BYTES_PER_ELEMENT;l.setDataLength(_),a&&l.setData(r.vb.buffer,0,0,c),o.push(l),s._vertexCount=_/u,s._vertexBuffers=o;let p=i.maxIndexCount*i.size;i.ibLength;let m=t.LayaGL.renderDeviceFactory.createIndexBuffer(h);m.indexType=i.type,m.indexCount=i.maxIndexCount,m._setIndexDataLength(p),a&&m._setIndexData(i.ib,0),s._indexBuffer=m;let f=s._bufferState;f.applyState(o,m);let x=[],g=i.outRenderData;for(let e=0,r=g.renderData.length;e<r;e++){let r=g.renderData[e],n=t.LayaGL.renderDeviceFactory.createRenderGeometryElement(t.MeshTopology.Triangles,t.DrawType.DrawElement);n.bufferState=f,n.setDrawElemenParams(r.length,r.offset*i.size),n.indexFormat=i.type,x.push(n)}s._setSubMeshes(x);var S=_+p;return s._setCPUMemory(S),s._setGPUMemory(S),s}static createMeshDynamic(e){let r=new t.Mesh2D,i=[],n=t.BufferUsage.Dynamic,a=t.LayaGL.renderDeviceFactory.createVertexBuffer(n);a.vertexDeclaration=e,a._byteLength=0,i.push(a),r._vertexBuffers=i;let s=t.LayaGL.renderDeviceFactory.createIndexBuffer(n);return r._indexBuffer=s,s._byteLength=0,r._bufferState.applyState(i,s),r.lock=!0,r}static _updateSpineSubMesh(e,r){let i=e.subMeshCount,n=r.mulitRenderData;if(!n)return!1;let a=n.renderData,s=a.length,o=i!=s,h=e._subMeshes;if(o){let n=Math.max(s,i),o=e._bufferState;for(let e=0;e<n;e++){let i=h[e],n=a[e];n?(i||(i=t.LayaGL.renderDeviceFactory.createRenderGeometryElement(t.MeshTopology.Triangles,t.DrawType.DrawElement),i.bufferState=o,h[e]=i),i.indexFormat=r.type,i.clearRenderParams(),i.setDrawElemenParams(n.length,n.offset*r.size)):i.destroy()}h.length=s}else for(let e=0;e<i;e++){let t=h[e],i=a[e];t.indexFormat=r.type,t.clearRenderParams(),t.setDrawElemenParams(i.length,i.offset*r.size)}return o}}class D{getSubMeshes(){return this._mesh?this._mesh._subMeshes:[]}constructor(e){this.currentMaterials=[],this.cacheMaterials=[],this.materialCacheVersion=0,this.vChanges=[],this._animator=null,this.cacheFrameIndex=0,this.currentFrameIndex=-1,this.currentData=null,this.state=null,this._skinAttach=null,this.needUpdate=!0,this.owner=e,this.reset()}set skinAttach(e){this._skinAttach!==e&&(this._skinAttach=e,this._updateData())}get skinAttach(){return this._skinAttach}set animator(e){this._animator!==e&&(this._animator=e,this._updateData())}get animator(){return this._animator}_updateData(){this._animator&&this._skinAttach&&(this.currentData=this._animator.skinDataArray[this._skinAttach.index],this.updateBones=this._animator.isCache?this.updateBoneMatrixCache:this.updateBoneMatrix)}get animationName(){return this.animator?this.animator.name:this.name}reset(){this.currentFrameIndex=-1}clear(){this.cacheMaterials.length=0,this.currentFrameIndex=-1,this.currentData=null,this.state=null,this._skinAttach=null,this._animator=null,this.vChanges.length=0,this._updateMaterials(null),this._mesh=null}renderUpdate(e,t,r,i){let n=!1;n=t.isDynamic?this.updateDynamicRender(e,t,r,i):this.handleRender(t,r,t.getMesh()),this.needUpdate=this.needUpdate||n}updateDynamicRender(e,t,r,i){let n=this.owner.getDynamicMesh(t.vb.vertexDeclaration),a=this.vChanges,s=t.getFrameData(r),o=i<0,h=!1,l=o&&!s.ib?this._getPreviousIndexFrameData(t,r):s;o&&(this._resetVertexBuffers(e,t),a.length=0);for(let e=i+1;e<=r;e++){let r=t.getFrameData(e).vChanges;if(r)for(const e of r)a.includes(e)||a.push(e)}for(let i=a.length-1;i>=0;i--){a[i].apply(r,t.vb,e)?h=!0:a.splice(i,1)}(h||o)&&this.uploadVertexBuffer(t.vb,n),(s.ib||o)&&this.uploadIndexBuffer(l,n);let d=y._updateSpineSubMesh(n,l);return d=this.handleRender(t,r,n,l)||d,d}_getPreviousIndexFrameData(e,t){for(let r=t-1;r>=0;r--){let t=e.getFrameData(r);if(t.ib)return t}return e._defaultFrameData}handleRender(e,t,r,i=e.getFrameData(t)){let n=!1,a=i.mulitRenderData;if(a){let e=this.cacheMaterials[a.id]||this.createMaterials(a);this.currentMaterials!==e&&(this._updateMaterials(e),n=!0)}return this._mesh!==r&&(this._mesh=r,n=!0),n}createMaterials(e){let t=e.renderData.map(e=>this.owner._getMaterialByName(e.textureName,e.blendMode));if(this.currentMaterials){for(let r=0;r<t.length;r++)if(this.currentMaterials[r]!==t[r])return this.cacheMaterials[e.id]=t,t;return this.cacheMaterials[e.id]=this.currentMaterials,this.currentMaterials}return this.cacheMaterials[e.id]=t,t}getDynamicMesh(e,t=0){return this.owner.getDynamicMesh(e,!0,t)}uploadIndexBuffer(e,t){let r=e.ib,i=t._indexBuffer;i.indexType=e.type,i.indexCount=r.length,i._setIndexDataLength(r.byteLength),i._setIndexData(r,0)}uploadVertexBuffer(e,t){let r=t.vertexBuffers[0],i=4*e.vbLength;r.setDataLength(e.maxVertexCount*e.vertexSize*4),r.setData(e.vb.buffer,0,0,i)}renderWithOutMat(e,t){let r=this.currentFrameIndex,i=this.animator.getFrameIndex(t,r);this.renderUpdate(e,this.currentData,i,r),this.currentFrameIndex=i}renderWithMat(e,t,r,i,n,a){this.renderWithOutMat(t,r),this.updateBones(r,e,i,n,a)}_resetVertexBuffers(e,t){let r=t.vb.slotVBMap,i=t.renderDatas,n=new Set;i.forEach(e=>{if(e&&e.vChanges)for(const t of e.vChanges)n.add(t.slotId)}),n.forEach(i=>{if(e[i]){let e=r.get(i);e&&e.forEach((e,r)=>{t.vb.resetVB(e.attachment)})}})}updateBoneMatrix(e,t,r,i=0,n=0){this.writeBoneBuffer(t,r,i,n)}updateBoneMatrixCache(e,t,r,i=0,n=0){this.writeBoneBufferCache(this._animator.boneFrames,e/l.SPINE_STEP,r,i,n)}writeBoneBuffer(e,t,r=0,i=0){let n=this.currentData.vb.localBoneIdIndexPairs;for(let a=0,s=n.length;a<s;a+=2){let s=8*n[a],o=e[n[a+1]];t[s]=o.a,t[s+1]=o.b,t[s+2]=o.worldX+r,t[s+3]=0,t[s+4]=o.c,t[s+5]=o.d,t[s+6]=o.worldY+i,t[s+7]=0}}writeBoneBufferCache(e,t,r,i=0,n=0){let a,s=this.currentData.vb.localBoneIdIndexPairs,o=Math.floor(t);a=o==e.length-1?0:t-o;let h=e[o],l=e[o+1];if(a>1e-4)for(let e=0,t=s.length;e<t;e+=2){let t=8*s[e],i=h[s[e+1]],n=l[s[e+1]];r[t]=i[0]+(n[0]-i[0])*a,r[t+1]=i[1]+(n[1]-i[1])*a,r[t+2]=i[2]+(n[2]-i[2])*a,r[t+3]=0,r[t+4]=i[4]+(n[4]-i[4])*a,r[t+5]=i[5]+(n[5]-i[5])*a,r[t+6]=i[6]+(n[6]-i[6])*a,r[t+7]=0}else for(let e=0,t=s.length;e<t;e+=2){let t=8*s[e],i=h[s[e+1]];r.set(i,t)}}_updateMaterials(e){if(this.currentMaterials)for(let e=0,t=this.currentMaterials.length;e<t;e++)this.currentMaterials[e]._removeReference();if(e)for(let t=0,r=e.length;t<r;t++)e[t]._addReference();this.currentMaterials=e}_clearCacheMaterials(){this.cacheMaterials.length=0,this.materialCacheVersion++}destroy(){this.clear(),this.owner=null}}var E;!function(e){e[e.RenderNormal=0]="RenderNormal",e[e.RenderRigidBody=1]="RenderRigidBody",e[e.RenderOptimize=2]="RenderOptimize",e[e.RenderBake=3]="RenderBake"}(E||(E={}));class R{get mode(){return this._mode}set mode(t){var r;this._mode!==t&&(t!==e.ESpineRenderMode.Normal&&this._optimize.maxBoneNumber>l.MAX_BONES&&(console.warn("The number of Bones :",this._optimize.maxBoneNumber," > ",l.MAX_BONES,", use CPU caculation"),t=e.ESpineRenderMode.Normal),this._mode=t,this._curAnimationName&&(this._enableCache&&(null===(r=this.updater.currentData)||void 0===r?void 0:r.renderCache[this.updater.cacheFrameIndex])&&this._applyCurrentPose(),this._clearRenderElements(),this._updateRenderProxy()))}get premultipliedAlpha(){return this._premultipliedAlpha}set premultipliedAlpha(e){this._premultipliedAlpha!==e&&(this.clearCacheMaterials(),this._premultipliedAlpha=e)}constructor(){this._skinIndex=0,this._skinAttach=null,this._currentAnimator=null,this._transform=new t.Vector2,this._enableCache=!1,this._hasExternalSkin=!1,this._destroyed=!1,this._mode=e.ESpineRenderMode.None,this._bakeVertexAnimationWarnings=new Set,this.state=e.ESpineRenderState.Stopped,this.currentTime=0,this.trackEntry=null,this._premultipliedAlpha=!0,this.spineColor=new t.Color,this.updater=new D(this)}init(e){this._templet=e;let t=this._optimize=this._templet.optimize;this._skeleton=new spine.Skeleton(t.data),this._stateData=new spine.AnimationStateData(t.data),this._state=new spine.AnimationState(this._stateData);let r=this._skeleton.color;this.spineColor.setValue(r.r,r.g,r.b,r.a),this.initRenderProxies(),this._updateSkinShaderDefines()}getSkeleton(){return this._skeleton}showSkinByIndex(e){this.setSkinIndex(e),this._skeleton.setSkin(this._optimize.getSkin(e)),this._skeleton.setSlotsToSetupPose(),this._currentAnimator&&this._applyCurrentPose()}setAttachment(e,t){this._skeleton&&this._skeleton.setAttachment(e,t)}update(r){var i;if(!t.Stat.enableSpine||this._destroyed)return;this._state.update(r),this.currentTime=this.trackEntry.getAnimationTime();let n=Math.floor(this.currentTime/l.SPINE_STEP);if(this.updater.cacheFrameIndex=n,this.renderProxy.type===e.ESpineRenderMode.Bake&&this._currentAnimator.hasVertexAnimation||(!this._enableCache||this._hasExternalSkin||!this.updater.currentData.renderCache[n])&&this.renderProxy.type!==e.ESpineRenderMode.Bake)this._state.apply(this._skeleton);else{let e=this.trackEntry,t=e.animationStart,n=e.animationEnd,a=n-t;e.trackLast=e.nextTrackLast;let s=e.trackLast%a,o=e.getAnimationTime(),h=!1;h=e.loop?0==a||s>e.trackTime%a:o>=n&&e.animationLast<n,h?(null===(i=this._listeners)||void 0===i||i.complete(e),e.nextAnimationLast=-1,e.nextTrackLast=-1):(e.nextAnimationLast=o,e.nextTrackLast=e.trackTime),this._currentAnimator.hasEvent&&this._updateCacheEvent(r)}}updateWorldTransform(e){this._skeleton&&this._skeleton.updateWorldTransform(e)}_updateCacheEvent(e){let t=this._currentAnimator,r=e/l.SPINE_STEP,i=Math.round(r),n=this.trackEntry,a=n.lastEventFrame;if(a!=i){if((a>i||null==a)&&(a=-1),i-a<=1){let e=t.eventsFrames[i];if(e)for(let t=0,r=e.length;t<r;t++)this.dispatchEvent(null,"event",e[t])}else for(let e=a+1;e<=i;e++){let r=t.eventsFrames[e];if(r)for(let e=0,t=r.length;e<t;e++)this.dispatchEvent(null,"event",r[e])}n.lastEventFrame=i}}render(r,i){if(!t.Stat.enableSpine||!this.renderProxy||this._destroyed)return;this._skeleton.update(r),this._enableCache&&!this._hasExternalSkin&&this.updater.currentData.renderCache[this.updater.cacheFrameIndex]||this.renderProxy.type===e.ESpineRenderMode.Bake||this.updateWorldTransform(i);let n=-this._skeleton.x,a=-this._skeleton.y;this.renderProxy&&(this.renderProxy.render(this.currentTime,n,a),this.renderProxy.afterRender&&this.renderProxy.afterRender(this))}getSpineColor(){return this.spineColor}initRenderProxies(){this._templet&&this._optimize&&(this.renderProxyMap=new Map,this._dynamicMap=new Map,this.updater.clear(),this._createRenderProxies(),this.renderProxyMap.forEach(e=>{e.bind(this.updater,this._skeleton)}),this._skinAttach=this._optimize.skinAttachArray[this._skinIndex],this.updater.skinAttach=this._skinAttach)}destroy(){this.reset(),this._dynamicMap&&(this._dynamicMap.forEach(e=>e.forEach(e=>e.destroy())),this._dynamicMap.clear()),this.updater.destroy(),this.updater=null,this._destroyed=!0}initBake(t){if(this.bakeData=t,t){let e=this.renderProxyMap.get(E.RenderBake);e||(e=this._createBakedRenderer(),e.bind(this.updater,this._skeleton),this.renderProxyMap.set(E.RenderBake,e)),e&&(e.simpleAnimatorTexture=t.texture2d,e._bonesNums=t.bonesNums,e.aniOffsetMap=t.aniOffsetMap)}this._mode=e.ESpineRenderMode.Bake,this._curAnimationName&&(this._clearRenderElements(),this.trackEntry?this.play(this._curAnimationName,this.trackEntry.loop,this.trackEntry.trackIndex,this.trackEntry.animationStart,this.trackEntry.animationEnd):this.play(this._curAnimationName))}changeSkeleton(e){this._skeleton=e,this.renderProxyMap.forEach(t=>{t.bind(this.updater,e)}),e.setSkin(this._optimize.getSkin(this._skinIndex)),this._skeleton.setSlotsToSetupPose()}setSkinIndex(e){e!=this._skinIndex&&this._optimize&&(this._skinIndex=e,this._skinAttach=this._optimize.skinAttachArray[e],this.updater.skinAttach=this._skinAttach,this._updateSkinShaderDefines(),this._currentAnimator&&(this._clearRenderElements(),this._updateRenderProxy()))}getDynamicMesh(e,t=!0,r=0){let i=e.id,n=this._dynamicMap.get(i);n||(n=[],this._dynamicMap.set(i,n));let a=n[r];return!a&&t&&(a=y.createMeshDynamic(e),n[r]=a),a}reset(){this._skinIndex=0,this._curAnimationName=null,this._currentAnimator=null,this._skinAttach=null,this.updater.clear(),this.renderProxyMap.forEach(e=>{e.destroy()}),this.renderProxyMap.clear(),this.renderProxy=null,this._skeleton=null,this._optimize=null,this._bakeVertexAnimationWarnings.clear(),this._state&&this._state.clearListeners(),this._state=null,this._stateData=null,this._clearRenderElements()}_applyCurrentPose(){const e=this._state.queue,t=e.objects.length,r=e.drainDisabled;e.drainDisabled=!0;try{this._state.apply(this._skeleton)}finally{e.objects.length=t,e.drainDisabled=r}}play(t,r=!0,i=0,n=0,a=0){let s=this._state.setAnimation(i,t,r);if(!s)return null;this.trackEntry=s,s.animationStart=n,a>0&&a<s.animationEnd&&(s.animationEnd=a),this._curAnimationName=t,this._updateRenderProxy(),this.renderProxy.type!==e.ESpineRenderMode.Optimize&&this._skeleton.setBonesToSetupPose()}_updateRenderProxy(){var t;const r=this._curAnimationName;let i=this.renderProxy;this.updater.reset();let n=this._skinAttach,a=this._optimize.animators.find(e=>e.name===r),s=a.skinDataArray[n.index];if(n.isNormalRender||a.hasClip||s&&s.isNormalRender||this.mode!==e.ESpineRenderMode.Optimize&&this.mode!==e.ESpineRenderMode.Bake)this.renderProxy=this.renderProxyMap.get(E.RenderNormal);else if(n.vertexBones>4&&console.warn(`In FastRender mode - Current skin: ${n.name} has ${n.vertexBones} bones influencing each vertex. This exceeds the recommended limit of 4 bones per vertex.`),this.bakeData&&null!=this.bakeData.aniOffsetMap[r])this.renderProxy=this.renderProxyMap.get(E.RenderBake);else{switch(n.type){case e.ESpineRenderType.boneGPU:this.renderProxy=this.renderProxyMap.get(E.RenderOptimize);break;case e.ESpineRenderType.rigidBody:this.renderProxy=this.renderProxyMap.get(E.RenderRigidBody);break;case e.ESpineRenderType.normal:this.renderProxy=this.renderProxyMap.get(E.RenderNormal)}this._enableCache&&(a.isCache||this._optimize.cacheBone())}i&&i.leave(),(null===(t=this.renderProxy)||void 0===t?void 0:t.type)===e.ESpineRenderMode.Bake&&a.hasVertexAnimation&&!this._bakeVertexAnimationWarnings.has(r)&&(this._bakeVertexAnimationWarnings.add(r),console.warn(`Spine Bake mode: animation "${r}" contains vertex animation. Vertex data will be updated on the CPU while bone matrices continue to use baked data.`)),this.renderProxy&&a&&(this.updater.animator=a,this._currentAnimator=a,this.renderProxy.change())}addAnimation(e,t=!1,r=0,i=0){this._state.addAnimation(i,e,t,r)}setMix(e,t,r){this._stateData.setMix(e,t,r)}findBone(e){return this._skeleton?this._skeleton.findBone(e):null}findSlot(e){if(!this._skeleton)return null;let t=this._skeleton.findSlot(e);return t?{name:t.data.name}:null}setSkeletonPosition(e,t){this._skeleton&&(this._skeleton.x=e,this._skeleton.y=t)}physicsTranslate(e,t){this._skeleton&&this._optimize.hasPhysics&&this._skeleton.physicsTranslate(e,t)}getBones(){return this._skeleton?this._skeleton.bones:[]}getSkeletonTransform(){return this._skeleton&&this._templet?(this._transform.x=this._skeleton.x,this._transform.y=this._skeleton.y,this._transform):this._transform}resetExternalSkin(){if(!this._skeleton||!this._templet)return;this._hasExternalSkin=!1;let e=this._templet.optimize;if(e&&e.data)for(const e of this._skeleton.slots){const t=e.data.attachmentName;e.setAttachment(t?this._skeleton.getAttachment(e.data.index,t):null)}}setEventListener(e){this._listeners=e,this._state&&this._state.addListener(e)}dispatchEvent(e,t,r){this._listeners[t](e,r)}complete(){this.updater.currentFrameIndex=-1}enableCache(){if(this._mode!==e.ESpineRenderMode.Normal&&console.log("enableCache: mode is not Normal"),this.renderProxyMap){const e=this.renderProxyMap.get(E.RenderNormal);e&&(e.normalUpdater.autoCacheEnabled=!0)}this._enableCache=!0}disableCache(){if(this._mode!==e.ESpineRenderMode.Normal&&console.log("disableCache: mode is not Normal"),this.renderProxyMap){const e=this.renderProxyMap.get(E.RenderNormal);e&&(e.normalUpdater.autoCacheEnabled=!1)}this._enableCache=!1}clearCacheMaterials(){var e,t;if(this._hasExternalSkin)for(const r of this._skeleton.slots){const i=null===(t=null===(e=r.getAttachment())||void 0===e?void 0:e.region)||void 0===t?void 0:t.page;i&&this._templet._registerSpineMaterialTexture(i.name,i.texture.realTexture)}this.updater._clearCacheMaterials()}setSlotTexture(t,r,i,n=!0){if(this._mode!==e.ESpineRenderMode.Normal)return void console.log("setSlotTexture: mode is not Normal, return");if(!this._skeleton||!r)return;let a=this._skeleton.findSlot(t);if(!a)return;let s=a.getAttachment();if(!s)return;this._templet.registerTexture(r);let o=this._optimize.registerTexture(r);o&&(i&&(s=s.copy(),a.setAttachment(s)),s instanceof spine.RegionAttachment?(s.region=o,n&&(s.width=o.width,s.height=o.height),s.updateRegion?s.updateRegion():s.updateOffset&&s.updateOffset()):s instanceof spine.MeshAttachment&&(s.region=o,n&&(s.width=o.width,s.height=o.height),s.updateRegion?s.updateRegion():s.updateUVs&&s.updateUVs()))}restoreSlotTexture(t){if(this._mode!==e.ESpineRenderMode.Normal||!this._skeleton)return!1;let r=this._skeleton.findSlot(t);if(!r)return!1;let i=r.data.attachmentName;if(!i)return r.setAttachment(null),!0;let n=this._skeleton.getAttachment(r.data.index,i);return!!n&&(r.setAttachment(n),!0)}setTempletAttachment(t,r,i,n){var a;if(this._mode!==e.ESpineRenderMode.Normal)return void console.log("setSlotAttachment: mode is not Normal");let s=t.optimize;if(n&&r&&i){let e=null,t=s.data.skins;for(let r=t.length-1;r>=0;r--)if(t[r].name==i){let i=t[r].attachments;for(let t=i.length-1;t>=0&&(e=null===(a=i[t])||void 0===a?void 0:a[n],!e);t--);break}if(e&&e.region){let t=this._skeleton.findSlot(r);if(t){t.setAttachment(e),this._hasExternalSkin=!0;const r=e.region.page;this._templet._registerSpineMaterialTexture(r.name,r.texture.realTexture),this.updater._clearCacheMaterials()}}}}}e.ERenderProxyType=void 0,function(e){e[e.RenderNormal=0]="RenderNormal",e[e.RenderRigidBody=1]="RenderRigidBody",e[e.RenderOptimize=2]="RenderOptimize",e[e.RenderBake=3]="RenderBake"}(e.ERenderProxyType||(e.ERenderProxyType={}));class I{constructor(t){this.type=e.ESpineRenderMode.Optimize,this._shaderData=t}destroy(){}bind(e,t){this.updater=e,this._skeleton=t,this.bones=t.bones,this.slots=t.slots}}class B extends I{constructor(){super(...arguments),this._matrix_0=new t.Vector4(1,0,0),this._matrix_1=new t.Vector4(0,1,0)}leave(){this._shaderData.removeDefine(o.SPINE_RB)}change(){this._shaderData.addDefine(o.SPINE_RB),this.updater.needUpdate=!0,this._shaderData.setVector(o.BONEMAT_0,this._matrix_0),this._shaderData.setVector(o.BONEMAT_1,this._matrix_1)}render(e,t=0,r=0){if(!this.updater)return;this.updater.renderWithOutMat(this.slots,e);let i=this.bones[this.updater.skinAttach.rbBoneIndex];if(!i)return;let n=i.worldX+t,a=i.worldY+r;i.a===this._matrix_0.x&&i.b===this._matrix_0.y&&i.c===this._matrix_1.x&&i.d===this._matrix_1.y&&n===this._matrix_0.z&&a===this._matrix_1.z||(this._matrix_0.x=i.a,this._matrix_0.y=i.b,this._matrix_0.z=n,this._matrix_1.x=i.c,this._matrix_1.y=i.d,this._matrix_1.z=a,this._shaderData.setVector(o.BONEMAT_0,this._matrix_0),this._shaderData.setVector(o.BONEMAT_1,this._matrix_1))}afterRender(e){this.updater.needUpdate&&(e._updateRenderElements(this.updater.getSubMeshes(),this.updater.currentMaterials),this.updater.needUpdate=!1)}}class v extends I{constructor(e){super(e),this._boneMat=new Float32Array(8*l.MAX_BONES)}change(){this._shaderData.addDefine(o.SPINE_FAST),this.updater.needUpdate=!0}leave(){this._shaderData.removeDefine(o.SPINE_FAST)}render(e,t=0,r=0){this.updater.renderWithMat(this.bones,this.slots,e,this._boneMat,t,r),this._shaderData.setBuffer(o.BONEMAT,this._boneMat)}afterRender(e){this.updater.needUpdate&&(e._updateRenderElements(this.updater.getSubMeshes(),this.updater.currentMaterials),this.updater.needUpdate=!1)}}class A extends I{constructor(t){super(t),this.type=e.ESpineRenderMode.Normal}leave(){this._shaderData.removeDefine(o.SPINE_COLOR2)}change(){this._shaderData.addDefine(o.SPINE_COLOR2),this.normalUpdater.needUpdate=!0}render(e,t=0,r=0){var i;let n=null===(i=this.updater)||void 0===i?void 0:i.currentData;if(n&&!this.updater.owner._hasExternalSkin&&(n.hasRenderCache||this.normalUpdater.autoCacheEnabled)){let e=n.renderCache[this.updater.cacheFrameIndex];if(e)return void this.normalUpdater.restoreFromCache(e)}this.normalUpdater.renderUpdate(e,this._skeleton,this.updater,-1,-1,t,r)}afterRender(e){this.normalUpdater.needUpdate&&(e._updateRenderElements(this.normalUpdater.subMeshes,this.normalUpdater.materials),this.normalUpdater.needUpdate=!1)}destroy(){this.normalUpdater&&(this.normalUpdater.destroy(),this.normalUpdater=null)}}class C extends I{constructor(){super(...arguments),this.type=e.ESpineRenderMode.Bake,this._simpleAnimatorParams=new t.Vector4,this._simpleAnimatorOffset=new t.Vector2,this.step=1/60}get simpleAnimatorTexture(){return this._simpleAnimatorTexture}set simpleAnimatorTexture(e){this._simpleAnimatorTexture&&this._simpleAnimatorTexture._removeReference(),this._simpleAnimatorTexture=e,this._simpleAnimatorTextureSize=e.width,this._shaderData.setTexture(o.SIMPLE_SIMPLEANIMATORTEXTURE,e),e._addReference(),this._shaderData.setNumber(o.SIMPLE_SIMPLEANIMATORTEXTURESIZE,this._simpleAnimatorTextureSize)}get simpleAnimatorOffset(){return this._simpleAnimatorOffset}set simpleAnimatorOffset(e){e.cloneTo(this._simpleAnimatorOffset)}leave(){this._shaderData.removeDefine(o.SPINE_SIMPLE),this._shaderData.removeDefine(o.SPINE_GPU_INSTANCE),this._shaderData.removeDefine(o.SPINE_RB)}change(){this._shaderData.addDefine(o.SPINE_SIMPLE),this.updater.skinAttach.type===e.ESpineRenderType.rigidBody?this._shaderData.addDefine(o.SPINE_RB):this._shaderData.removeDefine(o.SPINE_RB),this._simpleAnimatorOffset.x=this.aniOffsetMap[this.updater.animationName],this.updater.needUpdate=!0}_computeAnimatorParamsData(){this._simpleAnimatorParams.x=this._simpleAnimatorOffset.x,this._simpleAnimatorParams.y=Math.round(this._simpleAnimatorOffset.y)*this._bonesNums*2}setCustomData(e,t=0){this._simpleAnimatorParams.z=e,this._simpleAnimatorParams.w=t}render(e,t=0,r=0){this.updater.renderWithOutMat(this.slots,e),this._simpleAnimatorOffset.y=e/this.step,this._computeAnimatorParamsData(),this._shaderData.setVector(o.SIMPLE_SIMPLEANIMATORPARAMS,this._simpleAnimatorParams),this.updater.needUpdate=!0}afterRender(e){e._updateRenderElements(this.updater.getSubMeshes(),this.updater.currentMaterials)}}class T extends C{constructor(e){super(e.spriteShaderData),this._struct=e}change(){super.change(),this.updater.currentData&&this.updater.currentData.canInstance?this._struct.renderType=t.BaseRender2DType.spineSimple:this._struct.renderType=t.BaseRender2DType.spine}leave(){super.leave(),this._struct.renderType=t.BaseRender2DType.spine}}class M extends A{constructor(e){super(e.spriteShaderData),this._struct=e}change(){super.change(),this._struct.renderType=t.BaseRender2DType.spinenormal,this._shaderData.addDefine(o.SPINE_NORMAL_2D);let e=this._struct.renderDataHandler;e.needUseMatrix=!1,e.renderMatrixVersion=-1}leave(){super.leave(),this._struct.renderType=t.BaseRender2DType.spine,this._shaderData.removeDefine(o.SPINE_NORMAL_2D);let e=this._struct.renderDataHandler;e.needUseMatrix=!0,e.renderMatrixVersion=-1}updateRenderMatrix(e,t,r){let i=this.normalUpdater.matrix;e.copyTo(i),t&&(i.tx+=i.a*t.x+i.c*t.y,i.ty+=i.b*t.x+i.d*t.y),this._struct.renderDataHandler.renderMatrixVersion=this._struct.getRenderMatrixVersion(),r&&this.normalUpdater.applyRenderMatrixToViews()}render(e,t=0,r=0){var i;let n=null===(i=this.updater)||void 0===i?void 0:i.currentData,a=this._struct.renderDataHandler,s=this._struct.getRenderMatrixVersion();if((s<0||a.renderMatrixVersion!==s)&&this.updateRenderMatrix(this._struct.renderMatrix,a.offset,!1),n&&!this.updater.owner._hasExternalSkin&&(n.hasRenderCache||this.normalUpdater.autoCacheEnabled)){let e=n.renderCache[this.updater.cacheFrameIndex];if(e)return void this.normalUpdater.restoreFromCache(e)}this.normalUpdater.renderUpdate(e,this._skeleton,this.updater,-1,-1,t,r)}afterRender(e){this.normalUpdater.needUpdate&&(e._updateRenderElements(this.normalUpdater.subMeshes,this.normalUpdater.materials),this.normalUpdater.needUpdate=!1)}destroy(){this._shaderData.removeDefine(o.SPINE_NORMAL_2D),super.destroy()}}class b{constructor(e,t){this.vertexCount=0,this.vertexBufferLength=0,this.indexCount=0,this.indexBufferLength=0,this._uploadVertexSource=null,this._uploadVertexLength=-1,this._uploadVertexView=null,this.cacheIndex=null,this.vertexCapacity=e,this.indexCapacity=t,this.vertexData=new Float32Array(e),this.localPositionCapacity=2*Math.ceil(e/l.VERTEX_TWOCOLOR),this.localPositions=new Float32Array(this.localPositionCapacity),this.indexData=new Uint16Array(t)}getVertexData(){return this.vertexData}getIndexData(){return this.indexData}getUploadVertexData(){let e=this.vertexData;return e.length===this.vertexBufferLength?e:(this._uploadVertexSource===e&&this._uploadVertexLength===this.vertexBufferLength||(this._uploadVertexSource=e,this._uploadVertexLength=this.vertexBufferLength,this._uploadVertexView=e.subarray(0,this.vertexBufferLength)),this._uploadVertexView)}markModified(){this.owner&&(this.owner._modifyOneView(this),t.WebRender2DPass.setBuffer(this.owner))}reset(){this.owner&&this.owner.removeDataView(this),this.vertexCount=0,this.vertexBufferLength=0,this.indexCount=0,this.indexBufferLength=0,this.cacheIndex=null}transferToBuffer(e){this.owner&&this.owner.removeDataView(this),e.addDataView(this)}ensureVertexCapacity(e){if(e>this.vertexCapacity){const t=Math.ceil(e/b.ARRAY_GROWTH_STEP_VERTEX)*b.ARRAY_GROWTH_STEP_VERTEX;let r=new Float32Array(t);r.set(this.vertexData),this.vertexData=r,this.vertexCapacity=t}this.ensureLocalPositionCapacity(2*Math.ceil(e/l.VERTEX_TWOCOLOR))}ensureLocalPositionCapacity(e){if(e>this.localPositionCapacity){const t=Math.ceil(e/b.ARRAY_GROWTH_STEP_LOCAL_POSITION)*b.ARRAY_GROWTH_STEP_LOCAL_POSITION;let r=new Float32Array(t);r.set(this.localPositions),this.localPositions=r,this.localPositionCapacity=t}}ensureIndexCapacity(e){if(e>this.indexCapacity){const t=Math.ceil(e/b.ARRAY_GROWTH_STEP_INDEX)*b.ARRAY_GROWTH_STEP_INDEX;let r=new Uint16Array(t);r.set(this.indexData),this.indexData=r,this.indexCapacity=t}}destroy(){this.vertexData=null,this.localPositions=null,this.indexData=null,this.cacheIndex=null,this._uploadVertexSource=null,this._uploadVertexView=null,this.geometry=null,this.owner=null,this._next=null,this._prev=null}}b.ARRAY_GROWTH_STEP_VERTEX=l.NORMAL_VERTEX_LENGTH*l.VERTEX_TWOCOLOR,b.ARRAY_GROWTH_STEP_INDEX=3*l.NORMAL_VERTEX_LENGTH,b.ARRAY_GROWTH_STEP_LOCAL_POSITION=2*l.NORMAL_VERTEX_LENGTH;class w{constructor(){this._buffers=[]}static get instance(){return this._instance||(this._instance=new w),this._instance}assignViewToBuffer(e,t){let r=this._findOrCreateBuffer(t);r.addDataView(e),this.outBufferState=r.bufferState,this.outBufferIndex=this._buffers.indexOf(r)}_findOrCreateBuffer(e){for(let t of this._buffers)if(t.canFit(e))return t;let t=this._createBuffer();return this._buffers.push(t),t}allocateView(e,t){let r=null,i=-1;for(let t=0;t<this._buffers.length;t++){let n=this._buffers[t];if(n.canFit(e)){r=n,i=t;break}}r||(r=this._createBuffer(),i=this._buffers.length,this._buffers.push(r));let n=e*l.VERTEX_TWOCOLOR,a=Math.max(w.INITIAL_VERTEX_CAPACITY,n),s=Math.max(w.INITIAL_INDEX_CAPACITY,t);this.outView=new b(a,s),r.addDataView(this.outView),this.outBufferState=r.bufferState,this.outBufferIndex=i}releaseView(e){e&&e.owner&&e.owner.removeDataView(e)}_createBuffer(){let e=t.LayaGL.renderDeviceFactory.createVertexBuffer(t.BufferUsage.Dynamic);e.vertexDeclaration=o.SpineNormalVertexDeclaration;let r=t.LayaGL.renderDeviceFactory.createIndexBuffer(t.BufferUsage.Dynamic),i=new m(e,r);return i.resetCapacity(w.INITIAL_VERTEX_CAPACITY,w.INITIAL_INDEX_CAPACITY),i.bufferState=t.LayaGL.renderDeviceFactory.createBufferState(),i.bufferState.applyState([e],r),i}clear(){this._buffers.forEach(e=>{e.destroy()}),this._buffers=[]}}w.INITIAL_VERTEX_CAPACITY=1024*l.VERTEX_TWOCOLOR,w.INITIAL_INDEX_CAPACITY=3072;const P=[0,1,2,2,3,0];class N{constructor(){this.clipper=new spine.SkeletonClipping,this._internalMaterials=[],this._materialTextures=[],this._materialBlendModes=[],this._materialCacheVersion=-1,this.materials=[],this._materialIndex=0,this.needUpdate=!1,this.subMeshes=[],this.autoCacheEnabled=!1,this.batches=[],this._currentBatchIndex=-1,this._currentGeometryVertexCount=0,this._viewPool=[],this._allocatedViewsThisFrame=[],this._allocatedViewCount=0,this.matrix=new t.Matrix}applyRenderMatrixToViews(){var e;let t=this.matrix,r=t.a,i=t.b,n=t.c,a=t.d,s=t.tx,o=t.ty;for(let t=0;t<=this._currentBatchIndex;t++){let h=null===(e=this.batches[t])||void 0===e?void 0:e.view;if(h){let e=h.vertexData,t=h.localPositions;for(let d=0,u=0,_=0;d<h.vertexCount;d++,u+=l.VERTEX_TWOCOLOR,_+=2){let h=t[_],l=t[_+1];e[u+6]=r*h-n*l+s,e[u+7]=i*h-a*l+o}h.markModified()}}}renderUpdate(e,t,r,i,n,a=0,s=0){this._materialCacheVersion!==r.materialCacheVersion&&(this._materialCacheVersion=r.materialCacheVersion,this._internalMaterials.length=0,this._materialTextures.length=0,this._materialBlendModes.length=0,this.needUpdate=!0);let o,h,d,u,_=this.clipper,c=null,p=t.drawOrder,m=t.color,f=l.VERTEX_TWOCOLOR,x=!1;-1==i&&(x=!0);let g=S.positions,y=S._TEMP_COLOR,D=S._TEMP_COLOR2;this._materialIndex=0,this._currentBatchIndex=-1,this._currentGeometryVertexCount=0;for(let e=0,t=this._allocatedViewCount;e<t;e++){let t=this._allocatedViewsThisFrame[e];t.reset(),this._viewPool.push(t)}this._allocatedViewCount=0,c=null,u=null;for(let e=0,t=p.length;e<t;e++){let t=_.isClipping()?2:f,E=p[e],R=l.NEED_SLOT?E:E.bone;if(!E.bone.active){_.clipEndWithSlot(E);continue}if(i>=0&&i==E.data.index&&(x=!0),!x){_.clipEndWithSlot(E);continue}n>=0&&n==E.data.index&&(x=!1);let I,B=E.getAttachment(),v=0;if(B instanceof window.spine.RegionAttachment){let e=B;v=t<<2,null!=B.sequence&&B.sequence.apply(E,B),e.computeWorldVertices(R,g,0,t),h=P,o=e.uvs,I=e.region.page.texture,d=e.color}else{if(!(B instanceof window.spine.MeshAttachment)){if(B instanceof window.spine.ClippingAttachment){this.clipper.clipStart(E,B);continue}_.clipEndWithSlot(E);continue}{let e=B;v=(e.worldVerticesLength>>1)*t,v>g.length&&(g=new Float32Array(v),S.positions=g),e.computeWorldVertices(E,0,e.worldVerticesLength,g,0,t),h=e.triangles,I=e.region.page.texture,o=e.uvs,d=e.color}}if(I){let e=E.color,t=y;t.r=m.r*e.r*d.r,t.g=m.g*e.g*d.g,t.b=m.b*e.b*d.b,t.a=m.a*e.a*d.a;let i=D;E.darkColor?i.setFromColor(E.darkColor):i.set(0,0,0,1);let n=E.data.blendMode,l=!1;if(n!=c&&(c=n,l=!0),u!=I&&(u=I,l=!0),l){let e=this._materialIndex,t=I.realTexture,i=this._internalMaterials[e];this._materialTextures[e]===t&&this._materialBlendModes[e]===c&&i||(i=r.owner._getMaterial(t,c),this._materialTextures[e]=t,this._materialBlendModes[e]=c),this.addMaterial(i),this.createBatch()}_.isClipping()?(_.clipTriangles(g,v,h,h.length,o,t,i,true),this.appendVerticesClip(_.clippedVertices,_.clippedTriangles,f,a,s)):0!=t.a&&this.appendVertices(g,o,t,i,v,h,h.length,f,a,s)}_.clipEndWithSlot(E)}_.clipEnd(),this._bindViewsToBuffers();const E=this._currentBatchIndex+1;let R=0;for(let e=0;e<E;e++){const t=this.batches[e];t&&t.view&&t.view.vertexCount>0&&t.view.indexCount>0?(this.subMeshes[R]=t.geometry,this.materials[R]=t.material,R++):t&&t.geometry&&t.geometry.clearRenderParams()}if(this.subMeshes.length=R,this.materials.length=R,this._materialIndex=R,this.needUpdate=!0,this.autoCacheEnabled&&!r.owner._hasExternalSkin){let e=r.cacheFrameIndex,t=r.currentData;if(e>=0&&!t.renderCache[e]){let r=this._generateCacheData(E);t.renderCache[e]=r}}}_generateCacheData(e){let t=[];for(let r=0;r<e;r++){const e=this.batches[r];if(e&&e.view&&e.view.vertexCount>0&&e.view.indexCount>0){let r=e.view.vertexData,i=e.view.vertexBufferLength,n=new Float32Array(i);n.set(r.subarray(0,i));let a=e.view.localPositions;for(let t=0,r=0,i=0;t<e.view.vertexCount;t++,r+=l.VERTEX_TWOCOLOR,i+=2)n[r+6]=a[i],n[r+7]=a[i+1];t.push({vertexData:n,vertexLength:i,indexData:new Uint16Array(e.view.indexData.slice(0,e.view.indexBufferLength)),indexLength:e.view.indexBufferLength,vertexCount:e.view.vertexCount,indexCount:e.view.indexCount,vertexBufferLength:i,indexBufferLength:e.view.indexBufferLength})}}return{renderBlocks:t,materials:this.materials.slice()}}addMaterial(e){this._internalMaterials[this._materialIndex]!==e?(this._internalMaterials[this._materialIndex]=e,this._materialIndex++,this.needUpdate=!0):this._materialIndex++}createBatch(){this._currentBatchIndex++;let e,r,i=this.batches[this._currentBatchIndex],n=this._materialIndex-1,a=n>=0?this._internalMaterials[n]:null;if(i?(e=i.geometry,i.material===a&&i.materialIndex===n||(i.material=a,i.materialIndex=n,this.needUpdate=!0)):(e=t.LayaGL.renderDeviceFactory.createRenderGeometryElement(t.MeshTopology.Triangles,t.DrawType.DrawElement),e.indexFormat=t.IndexFormat.UInt16,this.needUpdate=!0,i={geometry:e,view:null,material:a,materialIndex:n},this.batches[this._currentBatchIndex]=i),this._viewPool.length>0)r=this._viewPool.pop(),r.reset();else{let e=l.VERTEX_INITIAL_CAPACITY*l.VERTEX_TWOCOLOR,t=3*l.VERTEX_INITIAL_CAPACITY;r=new b(e,t)}return r.cacheIndex=null,r.geometry=e,i.view=r,this._allocatedViewsThisFrame[this._allocatedViewCount++]=r,this._currentGeometryVertexCount=0,!0}appendVerticesClip(e,t,r,i,n){let a=e.length;if(0==a)return;let s=t.length,o=a/r;(this._currentBatchIndex<0||this._currentGeometryVertexCount+o>65535)&&this.createBatch();let h=this.batches[this._currentBatchIndex];if(!h)return;let l=h.view;l.ensureVertexCapacity(l.vertexBufferLength+a),l.ensureIndexCapacity(l.indexBufferLength+s);let d=l.vertexData,u=l.localPositions,_=l.indexData,c=l.vertexBufferLength,p=2*l.vertexCount,m=l.indexBufferLength,f=l.vertexCount,x=this.matrix,g=x.a,S=x.b,y=x.c,D=x.d,E=x.tx,R=x.ty;for(let t=0,s=c,o=p;t<a;s+=r,t+=r,o+=2){d[s]=e[t+6],d[s+1]=e[t+7],d[s+2]=e[t+2],d[s+3]=e[t+3],d[s+4]=e[t+4],d[s+5]=e[t+5];let r=e[t]+i,a=e[t+1]+n;u[o]=r,u[o+1]=a,d[s+6]=g*r-y*a+E,d[s+7]=S*r-D*a+R,d[s+8]=e[t+8],d[s+9]=e[t+9],d[s+10]=e[t+10],d[s+11]=e[t+11]}for(let e=0;e<s;e++)_[m+e]=t[e]+f;l.vertexBufferLength+=a,l.indexBufferLength+=s,l.vertexCount+=o,l.indexCount+=s,this._currentGeometryVertexCount+=o}appendVertices(e,t,r,i,n,a,s,o,h,l){if(0==n)return;let d=n/o;(this._currentBatchIndex<0||this._currentGeometryVertexCount+d>65535)&&this.createBatch();const u=this.batches[this._currentBatchIndex];if(!u)return;let _=u.view;_.ensureVertexCapacity(_.vertexBufferLength+n),_.ensureIndexCapacity(_.indexBufferLength+s);let c=_.vertexData,p=_.localPositions,m=_.indexData,f=_.vertexBufferLength,x=2*_.vertexCount,g=_.indexBufferLength,S=_.vertexCount,y=this.matrix,D=y.a,E=y.b,R=y.c,I=y.d,B=y.tx,v=y.ty;for(let a=0,s=0,d=n,u=x;s<d;s+=o,a+=2,u+=2){let n=f+s;c[n]=t[a],c[n+1]=t[a+1],c[n+2]=r.r,c[n+3]=r.g,c[n+4]=r.b,c[n+5]=r.a;let o=e[s]+h,d=e[s+1]+l;p[u]=o,p[u+1]=d,c[n+6]=D*o-R*d+B,c[n+7]=E*o-I*d+v,c[n+8]=i.r,c[n+9]=i.g,c[n+10]=i.b,c[n+11]=i.a}for(let e=0;e<s;e++)m[g+e]=a[e]+S;_.vertexBufferLength+=n,_.indexBufferLength+=s,_.vertexCount+=d,_.indexCount+=s,this._currentGeometryVertexCount+=d}_bindViewsToBuffers(){let e=w.instance;for(let t=0;t<=this._currentBatchIndex;t++){const r=this.batches[t];r&&r.view&&(r.view.vertexCount>0&&r.view.indexCount>0?(e.assignViewToBuffer(r.view,r.view.vertexCount),r.geometry.bufferState=e.outBufferState):r.geometry.clearRenderParams())}}getViewForGeometry(e){for(let t=0;t<=this._currentBatchIndex;t++){const r=this.batches[t];if(r&&r.geometry===e)return r.view}}destroy(){for(let e=0;e<this._allocatedViewCount;e++)this._allocatedViewsThisFrame[e].reset();this.batches.forEach(e=>{e&&e.geometry&&e.geometry.destroy()}),this.batches.length=0,this.subMeshes.length=0,this._internalMaterials.length=0,this._materialTextures.length=0,this._materialBlendModes.length=0,this._allocatedViewsThisFrame.length=0,this._allocatedViewCount=0,this._allocatedViewsThisFrame=null,this._viewPool=null}restoreFromCache(e,r=0,i=0){if(!e)return;for(let e=0;e<this._allocatedViewCount;e++){let t=this._allocatedViewsThisFrame[e];t.reset(),this._viewPool.push(t)}this._allocatedViewCount=0,this.materials.length=e.materials.length;for(let t=0;t<e.materials.length;t++)this.materials[t]=e.materials[t];this._currentBatchIndex=-1;for(let r=0;r<e.renderBlocks.length;r++){const i=e.renderBlocks[r],n=i.vertexBufferLength,a=i.indexBufferLength;this._currentBatchIndex++;let s,o,h=this.batches[this._currentBatchIndex];h&&h.geometry?s=h.geometry:(s=t.LayaGL.renderDeviceFactory.createRenderGeometryElement(t.MeshTopology.Triangles,t.DrawType.DrawElement),s.indexFormat=t.IndexFormat.UInt16,this.needUpdate=!0),this._viewPool.length>0?(o=this._viewPool.pop(),o.reset()):o=new b(i.vertexData.length,i.indexData.length),o.ensureVertexCapacity(n),o.ensureIndexCapacity(a),o.vertexData.set(i.vertexData.subarray(0,n),0),o.cacheIndex=i.indexData,o.vertexBufferLength=n,o.indexBufferLength=a,o.vertexCount=i.vertexCount,o.indexCount=i.indexCount,o.geometry=s;let d=this.matrix,u=d.a,_=d.b,c=d.c,p=d.d,m=d.tx,f=d.ty,x=o.vertexData,g=o.localPositions;for(let e=0,t=0,r=0;e<o.vertexCount;e++,t+=l.VERTEX_TWOCOLOR,r+=2){let e=x[t+6],i=x[t+7];g[r]=e,g[r+1]=i,x[t+6]=u*e-c*i+m,x[t+7]=_*e-p*i+f}const S=r<e.materials.length?r:e.materials.length-1,y=e.materials[S]||null;let D=h;D?(D.geometry=s,D.view=o,D.material=y,D.materialIndex=S):(D={geometry:s,view:o,material:y,materialIndex:S},this.batches[this._currentBatchIndex]=D),this._allocatedViewsThisFrame[this._allocatedViewCount++]=o}this._bindViewsToBuffers();const n=this._currentBatchIndex+1;let a=0;for(let e=0;e<n;e++){const t=this.batches[e];t&&t.view&&t.view.vertexCount>0&&t.view.indexCount>0?(this.subMeshes[a]=t.geometry,this.materials[a]=t.material,a++):t&&t.geometry&&t.geometry.clearRenderParams()}this.subMeshes.length=a,this.materials.length=a,this.needUpdate=!0}}class L extends R{static createRenderElement2D(){let e;return e=this._pool.length>0?this._pool.pop():t.LayaGL.render2DRenderPassFactory.createRenderElement2D(),e.renderStateIsBySprite=!1,e.nodeCommonMap=L._NODE_COMMONMAP_,e}static recoverRenderElement2D(e){e.canotPool||(e.materialShaderData=null,e.geometry=null,e.subShader=null,e.owner=null,this._pool.length<this._maxPoolSize?this._pool.push(e):e.destroy())}constructor(e){super(),this.is3D=!1,this._renderElements=[],this._owner=e,this._handle=this._owner._getRenderHandle(),this._handle.baseColor=this.spineColor}init(e){super.init(e),this._handle.skeleton=this._skeleton}_createRenderProxies(){let t=this._owner._struct.spriteShaderData,r=new v(t),i=new B(t);if(l.ENABLE_WEB_BATCH){let t=new M(this._owner._struct);t.normalUpdater=new N,t.normalUpdater.autoCacheEnabled=this._enableCache,this._handle.bindNormalRender(t),this.renderProxyMap.set(e.ERenderProxyType.RenderNormal,t)}else{let r=new A(t);r.normalUpdater=new S,r.normalUpdater.autoCacheEnabled=this._enableCache,this.renderProxyMap.set(e.ERenderProxyType.RenderNormal,r)}this.renderProxyMap.set(e.ERenderProxyType.RenderOptimize,r),this.renderProxyMap.set(e.ERenderProxyType.RenderRigidBody,i)}_createBakedRenderer(){return new T(this._owner._struct)}_updateSkinShaderDefines(){this._skinAttach.twoColorTint?this._owner._spriteShaderData.addDefine(o.SPINE_COLOR2):this._owner._spriteShaderData.removeDefine(o.SPINE_COLOR2)}changeSkeleton(e){super.changeSkeleton(e),this._handle.skeleton=e}reset(){const e=this._handle;e.skeleton=null,e.bindNormalRender(null),e.needUseMatrix=!0,super.reset()}_updateRenderElements(e,t){if(!this._owner||!this._owner._struct)return;const r=this._owner._struct,i=this._owner._spriteShaderData;this._updateRenderElementsFromData(r,i,e,t)}_updateRenderElementsFromData(e,t,r,i){if(!r||!i||0===r.length||0===i.length)return void this._clearRenderElements();const n=r.length,a=i.length,s=Math.max(n,a);let o=!l.ENABLE_WEB_BATCH&&n!=this._renderElements.length;for(let n=0;n<s;n++){let a=this._renderElements[n];const s=r[n],h=i[n];if(s&&h){let r=!1;a?a.geometry===s&&a.materialShaderData===h.shaderData&&a.value2DShaderData===t&&a.owner===e||(r=!0):(a=L.createRenderElement2D(),this._renderElements[n]=a,r=!0),r&&(a.geometry=s,a.materialShaderData=h.shaderData,a.subShader=h._shader.getSubShaderAt(0),a.value2DShaderData=t,a.owner=e,a._index=n,o=!0)}else a&&L.recoverRenderElement2D(a)}this._renderElements.length=n,o&&(e.renderElements=this._renderElements)}_clearRenderElements(){for(let e=0,t=this._renderElements.length;e<t;e++){const t=this._renderElements[e];t&&L.recoverRenderElement2D(t)}this._renderElements.length=0,this._owner&&this._owner._struct&&(this._owner._struct.renderElements=L._emptyList)}_getMaterialByName(e,t){return this._templet.getMaterial(this._templet.getTexture(e),t,this._premultipliedAlpha,!1)}_getMaterial(e,t){return this._templet.getMaterial(e,t,this._premultipliedAlpha,!1)}_getRenderHandle(){return this._handle}}L._emptyList=[],L._NODE_COMMONMAP_=["BaseRender2D","Spine2D"],L._pool=[],L._maxPoolSize=64;const V=new t.Color(1,1,1,1);class O{constructor(){this._nMatrix_0=new t.Vector3,this._nMatrix_1=new t.Vector3,this._needUseMatrix=!0,this._lightReceive=!1,this._renderAlpha=-1,this._baseColor=new t.Color(1,1,1,1),this._renderMatrixVersion=-1,this._normalRender=null}get needUseMatrix(){return this._needUseMatrix}set needUseMatrix(e){var r;this._needUseMatrix!==e&&(this._needUseMatrix=e,this._renderMatrixVersion=-1,!e&&(null===(r=this._owner)||void 0===r?void 0:r.spriteShaderData)&&(this._nMatrix_0.set(1,0,0),this._nMatrix_1.set(0,1,0),this._owner.spriteShaderData.setVector3(t.ShaderDefines2D.UNIFORM_NMATRIX_0,this._nMatrix_0),this._owner.spriteShaderData.setVector3(t.ShaderDefines2D.UNIFORM_NMATRIX_1,this._nMatrix_1)))}get lightReceive(){return this._lightReceive}set lightReceive(e){this._lightReceive!==e&&(this._lightReceive=e,e?this._owner.spriteShaderData.addDefine(t.BaseRenderNode2D.SHADERDEFINE_LIGHT2D_ENABLE):this._owner.spriteShaderData.removeDefine(t.BaseRenderNode2D.SHADERDEFINE_LIGHT2D_ENABLE))}bindNormalRender(e){this._normalRender=e,this._renderMatrixVersion=-1}get renderMatrixVersion(){return this._renderMatrixVersion}set renderMatrixVersion(e){this._renderMatrixVersion=e}get normalUpdater(){var e;return null===(e=this._normalRender)||void 0===e?void 0:e.normalUpdater}get baseColor(){return this._baseColor}set baseColor(e){e!==this._baseColor&&this._baseColor.equal(e)||((e=e||t.Color.BLACK).cloneTo(this._baseColor),this._renderAlpha=-1,this._owner.spriteShaderData.setColor(t.BaseRenderNode2D.BASERENDER2DCOLOR,this._baseColor))}get owner(){return this._owner}set owner(e){if(e!==this._owner){if(this._owner&&this._owner.spriteShaderData){let e=this._owner.spriteShaderData;e.removeDefine(t.BaseRenderNode2D.SHADERDEFINE_BASERENDER2D),e.removeDefine(o.SPINE_UV),e.removeDefine(o.SPINE_COLOR),e.removeDefine(t.BaseRenderNode2D.SHADERDEFINE_LIGHT2D_ENABLE)}if(this._owner=e,this._renderMatrixVersion=-1,this._owner){let e=this._owner.spriteShaderData;e.addDefine(t.BaseRenderNode2D.SHADERDEFINE_BASERENDER2D),e.addDefine(o.SPINE_UV),e.addDefine(o.SPINE_COLOR),this._lightReceive&&e.addDefine(t.BaseRenderNode2D.SHADERDEFINE_LIGHT2D_ENABLE)}}}get offset(){return this._offset}set offset(e){this._offset=e,this._renderMatrixVersion=-1}inheriteRenderData(e){var r;if(!this._owner||!this._owner.spriteShaderData||!this.skeleton)return;let i=this._owner.getRenderMatrixVersion();if(i<0||this._renderMatrixVersion!==i){let e=this._owner.spriteShaderData,n=this._owner.renderMatrix;if(this._needUseMatrix){if(this._renderMatrixVersion=i,this._offset){let e=this._offset.x,t=this._offset.y;this._nMatrix_0.setValue(n.a,n.c,n.tx+n.a*e+n.c*t),this._nMatrix_1.setValue(n.b,n.d,n.ty+n.b*e+n.d*t)}else this._nMatrix_0.setValue(n.a,n.c,n.tx),this._nMatrix_1.setValue(n.b,n.d,n.ty);e.setVector3(t.ShaderDefines2D.UNIFORM_NMATRIX_0,this._nMatrix_0),e.setVector3(t.ShaderDefines2D.UNIFORM_NMATRIX_1,this._nMatrix_1)}else null===(r=this._normalRender)||void 0===r||r.updateRenderMatrix(n,this._offset,!0)}if(this._renderAlpha!==this._owner.globalAlpha){let e=this._owner.globalAlpha*this._baseColor.a;V.setValue(this._baseColor.r,this._baseColor.g,this._baseColor.b,e),this._owner.spriteShaderData.setColor(t.BaseRenderNode2D.BASERENDER2DCOLOR,V),this._renderAlpha=this._owner.globalAlpha}}destroy(){this._normalRender=null,this.skeleton=null,this.owner=null}}class k extends R{static createRenderElement3D(){let e;return this._pool.length>0?e=this._pool.pop():(e=t.Laya3DRender.Render3DPassFactory.createRenderElement3D(),e.isRender=!0),e}static recoverRenderElement3D(e){e.canotPool||(e.materialShaderData=null,e.geometry=null,e.subShader=null,e.owner=null,this._pool.push(e))}constructor(e){super(),this.is3D=!0,this._renderElements=[],this._owner=e}_createRenderProxies(){let t=this._owner.shaderData,r=new v(t),i=new A(t);i.normalUpdater=new S,i.normalUpdater.autoCacheEnabled=this._enableCache;let n=new B(t);this.renderProxyMap.set(e.ERenderProxyType.RenderNormal,i),this.renderProxyMap.set(e.ERenderProxyType.RenderOptimize,r),this.renderProxyMap.set(e.ERenderProxyType.RenderRigidBody,n)}_createBakedRenderer(){return new C(this._owner.shaderData)}_updateSkinShaderDefines(){this._skinAttach.twoColorTint?this._owner.shaderData.addDefine(o.SPINE_COLOR2):this._owner.shaderData.removeDefine(o.SPINE_COLOR2)}_updateRenderElements(e,t){if(!this._owner)return;const r=this._owner.shaderData;this._updateRenderElementsFromData(r,e,t)}_updateRenderElementsFromData(e,t,r){if(!t||!r||0===t.length||0===r.length)return void this._clearRenderElements();const i=t.length,n=r.length,a=Math.max(i,n);let s=!l.ENABLE_WEB_BATCH&&i!=this._renderElements.length;for(let i=0;i<a;i++){let n=this._renderElements[i];const a=t[i],o=r[i];if(a&&o){let t=!1;n?n.geometry===a&&n.materialShaderData===o.shaderData&&n.renderShaderData===e&&n.owner===this._owner||(t=!0):(n=k.createRenderElement3D(),this._renderElements[i]=n,t=!0),t&&(n.geometry=a,n.materialShaderData=o.shaderData,n.subShader=o._shader.getSubShaderAt(0),n.renderShaderData=e,n.owner=this._owner,n.materialRenderQueue=o.renderQueue,s=!0)}else n&&k.recoverRenderElement3D(n)}this._renderElements.length=i,s&&this._owner.setRenderelements(this._renderElements)}_clearRenderElements(){for(let e=0,t=this._renderElements.length;e<t;e++){const t=this._renderElements[e];t&&k.recoverRenderElement3D(t)}this._renderElements.length=0,this._owner&&this._owner.setRenderelements(k._emptyList)}_getMaterialByName(e,t){return this._templet.getMaterial(this._templet.getTexture(e),t,this._premultipliedAlpha,!0)}_getMaterial(e,t){return this._templet.getMaterial(e,t,this._premultipliedAlpha,!0)}}k._emptyList=[],k._pool=[];const F=[0,1,2,2,3,0];class U{constructor(){this.vertexCount=0,this.indexCount=0,this.isNormalRender=!1,this.vertexBones=0,this.bones=new Set}init(e,r,i,n,a){this.slotId=i,this.sourceData=e,this.attachment=e.name,this.boneIndex=r;let s=a.color;this.blendMode=a.blendMode;let o,h=this.color=new t.Color,d=a.darkColor;if(e instanceof spine.RegionAttachment){o=e.color;let t=e;this.vertexArray=t.offset,this.stride=2,this.indexArray=F,this.uvs=t.uvs,t.region&&(this.textureName=t.region.page.name),this.vertexBones=1,this.bones.add(r)}else if(e instanceof spine.MeshAttachment){o=e.color;let t=l.VERTEX_BONE,i=e;if(this.textureName=i.region.page.name,i.bones&&0!=i.bones.length){n&&n.length,this.stride=t-6;let e=i.uvs.length/2,r=this.vertexArray=new Float32Array(e*this.stride);this.indexArray=i.triangles,this.uvs=i.uvs;let a=i.vertices,s=i.bones,o=0,h=(t-6)/4;this.vertexBones=h;for(let t=0,i=0;t<e;t++){let e=s[o++];e+=o;let n=[],l=t*this.stride,d=0;for(;o<e;o++,i+=3,d++){let e=s[o];n.push([a[i],a[i+1],a[i+2],e]),this.bones.add(e)}n.length>h&&(this.vertexBones=Math.max(this.vertexBones,n.length),n.length=h,this.isNormalRender=!0);for(let e=0;e<h;e++){let t=n[e];t&&(r[l+4*e]=t[0],r[l+4*e+1]=t[1],r[l+4*e+2]=t[2],r[l+4*e+3]=t[3])}}}else n&&n.length>1?this.vertexArray=new Float32Array(n):this.vertexArray=i.vertices,this.stride=2,this.indexArray=i.triangles,this.uvs=i.uvs,this.bones.add(r)}else e instanceof spine.ClippingAttachment?(this.attachment=null,this.isClip=!0):e instanceof spine.PathAttachment?(this.attachment=e.name,this.vertexArray=new Float32Array(e.vertices),this.isPath=!0):this.attachment=null;return this.textureName&&(this.vertexCount=this.vertexArray.length/this.stride,this.indexCount=this.indexArray.length),o&&(this.lightColor=o,h.r=s.r*o.r,h.g=s.g*o.g,h.b=s.b*o.b,h.a=s.a*o.a),this.darkColor=d,!0}}class G{constructor(){this.renderData=[],this.id=G.ID++}addData(e,t,r,i,n){this.currentData={textureName:e,blendMode:t,offset:r,length:i,attachment:n},this.renderData.push(this.currentData)}endData(e){this.currentData.length=e-this.currentData.offset}}G.ID=0;class z{constructor(){this.ibLength=0,this.maxIndexCount=0}updateFormat(e){let t=o.getIndexFormat(e);this.type!==t&&(this.type=t,this._updateBuffer())}setBufferLength(e){e<=this.maxIndexCount||(this.maxIndexCount=e,this._updateBuffer())}_updateBuffer(){let e=this.ib;switch(this.type){case t.IndexFormat.UInt16:this.size=2,this.ib=new Uint16Array(this.maxIndexCount);break;case t.IndexFormat.UInt8:this.size=1,this.ib=new Uint8Array(this.maxIndexCount);break;case t.IndexFormat.UInt32:this.size=4,this.ib=new Uint32Array(this.maxIndexCount)}e&&this.ib.set(e)}createIB(e,t,r){let i,n,a=0,s=t.slotVBMap;r?(i=r,n=function(t){return e[t]}):(i=e,n=function(e){return e});let h,l,d=new G,u=[],_=-1;for(let e=0,t=i.length;e<t;e++){let t=n(i[e]);if(t.attachment&&!t.isPath){let e=!1;h!=t.textureName&&(h=t.textureName,e=!0),l!=t.blendMode&&(l=t.blendMode,e=!0),e&&(d.currentData&&d.endData(a),d.addData(t.textureName,t.blendMode,a,0,t.attachment));let r=s.get(t.slotId).get(t.attachment);t.attachment&&t.indexArray&&(u.push({data:t.indexArray,offset:r.offset,start:a}),a+=t.indexArray.length,_=Math.max(_,a))}}let c=t.maxVertexCount,p=o.getIndexFormat(c),m=!1;p!==this.type&&(this.type=p,m=!0),_>this.maxIndexCount&&(this.maxIndexCount=_,m=!0),m&&this._updateBuffer();let f=this.ib;for(let e=0,t=u.length;e<t;e++){let t=u[e],r=t.offset,i=t.start;for(let e=0,n=t.data.length;e<n;e++)f[i+e]=t.data[e]+r}h&&d.endData(a),this.outRenderData=d,this.ibLength=a}}class W{constructor(){this._nextBoneId=0,this._boneIndexToId=new Map,this._boneIdIndexPairs=[]}getOrRegisterBoneId(e){let t=this._boneIndexToId.get(e);return void 0===t&&(t=this._nextBoneId,this._boneIndexToId.set(e,t),this._boneIdIndexPairs.push(t,e),this._nextBoneId++),t}getBoneId(e){return this._boneIndexToId.get(e)}get boneCount(){return this._nextBoneId}get boneIdIndexPairs(){return this._boneIdIndexPairs}get boneIndexToIdMap(){return this._boneIndexToId}clear(){this._nextBoneId=0,this._boneIndexToId.clear(),this._boneIdIndexPairs.length=0}}class X{constructor(e,t=0,r=!0,i){this._vertexSize=0,this._baseVtxCount=6,this._boneVtxCount=4,this.twoColorTint=!1,this.maxVertexCount=t,this.vertexFlag=e,this.boneRegistry=i||new W,this.localBoneIndexToId=new Map,this.localBoneIdIndexPairs=[],this.slotVBMap=new Map,this.vbLength=0,r&&(this._vertexDeclaration=o.getVertexDeclaration(this.vertexFlag),this.twoColorTint=-1!=e.indexOf("COLOR2"),this.twoColorTint&&(this._baseVtxCount+=4),this._vertexSize=this._vertexDeclaration.vertexStride/4,this._boneVtxCount=this._vertexSize-this._baseVtxCount,this._updateBuffer())}setBufferLength(e){e<=this.maxVertexCount||(this.maxVertexCount=e,this._updateBuffer())}_updateBuffer(){let e=this.vb;this.vb=new Float32Array(this.maxVertexCount*this.vertexSize),e&&this.vb.set(e)}get vertexSize(){return this._vertexSize}get vertexDeclaration(){return this._vertexDeclaration}appendAndCreateIB(e){this.appendVB(e)}getBoneId(e){let t=this.localBoneIndexToId.get(e);return void 0!==t||(t=this.boneRegistry.getOrRegisterBoneId(e),this.localBoneIndexToId.set(e,t),this.localBoneIdIndexPairs.push(t,e)),t}appendVB(e){let t,r=this.slotVBMap.get(e.slotId);if(r){let t=r.get(e.attachment);if(null!=t)return t}else r=new Map,this.slotVBMap.set(e.slotId,r);return t=this.vbLength/this.vertexSize,r.set(e.attachment,{offset:t,attachment:e}),e.vertexCount?(t+e.vertexCount>=this.maxVertexCount&&this.setBufferLength(t+e.vertexCount),this.vbLength=this.appendVertexArray(e,this.vb,this.vbLength,this),t):t}resetVB(e){var t;if(e.isPath)return;let r=null===(t=this.slotVBMap.get(e.slotId))||void 0===t?void 0:t.get(e.attachment);r&&this.appendVertexArray(e,this.vb,r.offset*this.vertexSize,this)}_cloneTo(e){e.vb=new Float32Array(this.vb),e.vbLength=this.vbLength,e.boneRegistry=this.boneRegistry,e.localBoneIndexToId=new Map(this.localBoneIndexToId),e.localBoneIdIndexPairs=this.localBoneIdIndexPairs.slice(),e._vertexDeclaration=this._vertexDeclaration,e._vertexSize=this._vertexSize,e.twoColorTint=this.twoColorTint,e._baseVtxCount=this._baseVtxCount,e._boneVtxCount=this._boneVtxCount,e.vertexFlag=this.vertexFlag,this.slotVBMap.forEach((t,r)=>{e.slotVBMap.set(r,new Map(t))})}clone(){let e=this._create();return this._cloneTo(e),e}}class H extends X{_create(){return new H(this.vertexFlag,this.maxVertexCount,!1,this.boneRegistry)}appendVertexArray(e,t,r,i){if(!e.attachment)return i.getBoneId(e.boneIndex),r;let n=this.vertexSize,a=e.vertexArray,s=e.uvs,o=e.color,h=o.r,l=o.g,d=o.b,u=o.a,_=this._boneVtxCount/4,c=e.darkColor,p=0,m=0,f=0,x=1;if(c&&(p=c.r,m=c.g,f=c.b,x=c.a),2==e.stride){let o=i.getBoneId(e.boneIndex);for(let i=0,c=a.length;i<c;i+=e.stride){t[r]=s[i],t[r+1]=s[i+1],t[r+2]=h,t[r+3]=l,t[r+4]=d,t[r+5]=u,t[r+6]=a[i],t[r+7]=a[i+1],t[r+8]=1,t[r+9]=o;let e=r+10;for(let r=0,i=_-1;r<i;r++){let i=e+4*r;t[i]=0,t[i+1]=0,t[i+2]=0,t[i+3]=0}if(this.twoColorTint){let e=r+6+this._boneVtxCount;t[e]=p,t[e+1]=m,t[e+2]=f,t[e+3]=x}r+=n}}else for(let o=0,c=0,g=a.length;o<g;o+=e.stride,c+=2){t[r]=s[c],t[r+1]=s[c+1],t[r+2]=h,t[r+3]=l,t[r+4]=d,t[r+5]=u;let e=r+6;for(let r=0;r<_;r++){let n=e+4*r,s=o+4*r;t[n]=a[s],t[n+1]=a[s+1],t[n+2]=a[s+2],t[n+3]=i.getBoneId(a[s+3])}if(this.twoColorTint){let r=e+this._boneVtxCount;t[r]=p,t[r+1]=m,t[r+2]=f,t[r+3]=x}r+=n}return r}appendDeform(e,t,r,i){if(!e.attachment)return;let n=this.vertexSize,a=e.vertexArray;if(2==e.stride)for(let s=0,o=a.length;s<o;s+=e.stride)i[r+6]=t[s],i[r+7]=t[s+1],r+=n;else{let s=e.sourceData.bones,o=e.vertexCount,h=this._boneVtxCount/4,l=0,d=0;for(let e=0;e<o;e++){let o=s[d++],u=e*this._boneVtxCount,_=r+e*n+6;for(let e=0;e<o&&!(e>=h);e++){let r=l+2*e,n=u+4*e,s=_+4*e;i[s]=a[n]+t[r],i[s+1]=a[n+1]+t[r+1]}d+=o,l+=2*o}}}}class Y extends X{_create(){return new Y(this.vertexFlag,this.maxVertexCount,!1,this.boneRegistry)}appendVertexArray(e,t,r,i){let n=e.vertexArray,a=e.uvs,s=e.color,o=e.darkColor,h=this.vertexSize,l=s.r,d=s.g,u=s.b,_=s.a,c=0,p=0,m=0,f=1;if(o&&(c=o.r,p=o.g,m=o.b,f=o.a),2==e.stride){let s=i.getBoneId(e.boneIndex);for(let i=0,o=n.length;i<o;i+=e.stride){if(t[r+0]=a[i],t[r+1]=a[i+1],t[r+2]=l,t[r+3]=d,t[r+4]=u,t[r+5]=_,t[r+6]=n[i],t[r+7]=n[i+1],t[r+8]=1,t[r+9]=s,this.twoColorTint){let e=r+10;t[e]=c,t[e+1]=p,t[e+2]=m,t[e+3]=f}r+=h}}return r}appendDeform(e,t,r,i){if(!e.attachment)return;let n=this.vertexSize,a=e.vertexArray;if(2==e.stride)for(let s=0,o=a.length;s<o;s+=e.stride)i[r+6]=t[s],i[r+7]=t[s+1],r+=n}}class j{constructor(){}apply(e,t,r){return e>=this.startFrame&&(!(this._lastFrame>=this.endFrame&&e>=this.endFrame)&&(this._lastFrame=e,this.updateVB(t,r)))}initChange(e){return this.sizeMap=e.slotVBMap.get(this.slotId),!0}updateVB(e,t){if(!this.sizeMap&&(this.sizeMap=e.slotVBMap.get(this.slotId),!this.sizeMap))return!1;let r=t[this.slotId];if(r.attachment){let t=r.deform;if(!t||!t.length)return!1;let i=e.vertexSize,n=this.sizeMap.get(r.attachment.name),a=n.offset*i,s=e.vb,o=n.attachment;e.appendDeform(o,t,a,s)}return!0}clone(){let e=new j;return e.slotId=this.slotId,e.startFrame=this.startFrame,e.endFrame=this.endFrame,e}}class K{changeOrder(e){return this.order}change(e,t){return!0}}class ${constructor(e){this.slotId=e}apply(e,t,r){return this.updateVB(t,r),e>=this.startFrame}initChange(e){return this.sizeMap=e.slotVBMap.get(this.slotId),!0}updateVB(e,t){if(!this.sizeMap&&(this.sizeMap=e.slotVBMap.get(this.slotId),!this.sizeMap))return!1;let r=t[this.slotId],i=r.color;if(r.attachment){let t,n,a,s,o=e.vertexSize,h=this.sizeMap.get(r.attachment.name),l=e.vb,d=h.offset*o,u=h.attachment,_=u.lightColor,c=e.twoColorTint,p=e.vertexDeclaration.getVertexElementByUsage(1).offset/4,m=0;if(c){m=e.vertexDeclaration.getVertexElementByUsage(11).offset/4}_?(t=i.r*_.r,n=i.g*_.g,a=i.b*_.b,s=i.a*_.a):(t=i.r,n=i.g,a=i.b,s=i.a);let f=r.darkColor,x=0,g=0,S=0,y=1;f&&(x=f.r,g=f.g,S=f.b,y=f.a);let D=u.vertexCount;for(let e=0;e<D;e++){let r=d+e*o+p;if(l[r]=t,l[r+1]=n,l[r+2]=a,l[r+3]=s,c){let t=d+e*o+m;l[t]=x,l[t+1]=g,l[t+2]=S,l[t+3]=y}}}return!0}clone(){let e=new $(this.slotId);return e.startFrame=this.startFrame,e.endFrame=this.endFrame,e}}class q{change(e,t){let r=t.get(this.slotId),i=r.get(this.attachment);return i?e.appendVB(i):i=r.get(null),this.attachmentParse=i,!this.attachmentParse.isClip}changeOrder(e){return e[this.slotId]=this.attachmentParse,null}}class Z{constructor(){this.isDynamic=!1,this.hasEvent=!1,this.hasVertexAnimation=!1,this.isCache=!1,this.hasClip=!1,this.hasRenderCache=!1,this.changeMap=new Map,this.frames=[],this.skinDataArray=[],this.boneFrames=[],this.eventsFrames=[]}getFrameIndex(e,t){let r=this.frames,i=r.length;for(let t=1;t<i;t++)if(r[t]>e)return t-1;return i-1}check(e,t){this.name=e.name;let r=e.timelines,i=this.changeMap,n=this.frames,a=window.spine,s=!1,o=!1;n.push(0),i.set(0,{});let h=!1;for(let e=0,t=r.length;e<t;e++){let t=r[e],n=t.frames;if(t instanceof spine.AttachmentTimeline){let e=t.attachmentNames,r=t.slotIndex;for(let t=0,a=n.length;t<a;t++){let a=n[t],s=new q;s.slotId=r,s.attachment=e[t]||null;let o=i.get(a);o||(-1==this.frames.indexOf(a)&&this.frames.push(a),o={iChanges:[]},i.set(a,o)),(o.iChanges=o.iChanges||[]).push(s)}h=!0}else if(t instanceof spine.DrawOrderTimeline){let e=t.drawOrders;for(let t=0,r=n.length;t<r;t++){let r=n[t],a=new K;a.order=e[t];let s=i.get(r);s||(-1==this.frames.indexOf(r)&&this.frames.push(r),s={iChanges:[]},i.set(r,s)),(s.iChanges=s.iChanges||[]).push(a),h=!0}}else if(a.ColorTimeline&&t instanceof a.ColorTimeline||a.RGBATimeline&&t instanceof a.RGBATimeline||a.RGBTimeline&&t instanceof a.RGBTimeline||a.AlphaTimeline&&t instanceof a.AlphaTimeline||a.TwoColorTimeline&&t instanceof a.TwoColorTimeline||a.RGBA2Timeline&&t instanceof a.RGBA2Timeline||a.RGB2Timeline&&t instanceof a.RGB2Timeline){let e=t.slotIndex;this.hasVertexAnimation=!0;let r=new $(e),s=n[0],o="function"==typeof t.getFrameEntries?t.getFrameEntries():a.TwoColorTimeline&&t instanceof a.TwoColorTimeline?8:5,l=n[((n.length/o|0)-1)*o];r.startFrame=s,r.endFrame=l;let d=i.get(s);d||(-1==this.frames.indexOf(s)&&this.frames.push(s),d={vChanges:[]},i.set(s,d)),-1==this.frames.indexOf(l)&&this.frames.push(l),(d.vChanges=d.vChanges||[]).push(r),h=!0}else if(t instanceof window.spine.ClippingAttachment)s=!0;else if(t instanceof window.spine.EventTimeline){let e=t.events;for(let t=0,r=n.length;t<r;t++){let r=n[t],i=e[t];(this.eventsFrames[Math.round(r/l.SPINE_STEP)]=this.eventsFrames[r]||[]).push(i)}o=!0}else if(t instanceof spine.DeformTimeline){this.hasVertexAnimation=!0;let e=t.slotIndex,r=new j;r.slotId=e;let a=n[0],s=n[n.length-1];r.startFrame=a,r.endFrame=s;let o=i.get(a);o||(-1==this.frames.indexOf(a)&&this.frames.push(a),o={vChanges:[]},i.set(a,o)),-1==this.frames.indexOf(s)&&this.frames.push(s),(o.vChanges=o.vChanges||[]).push(r),h=!0}}this.isDynamic=h,n.sort(),this.hasClip=s,this.hasEvent=o,this.frameNumber=n.length}createSkinData(e,t,r,i,n,a){let s=new J;s.type=a;let o=this.frames;return s.init(this.changeMap,e,t,r,o,i,n,this.isDynamic),this.skinDataArray.push(s),s}destroy(){for(let e=0,t=this.skinDataArray.length;e<t;e++)this.skinDataArray[e].destroy();this.skinDataArray.length=0,this.frames.length=0,this.changeMap.clear()}}class J{constructor(){this.maxVertexCount=0,this.maxIndexCount=0,this.isDynamic=!1,this.renderCache=[],this.hasRenderCache=!1,this.renderDatas=[]}getMesh(){return this._defaultMesh}getFrameData(e){return this.renderDatas[e]||this._defaultFrameData}init(e,t,r,i,n,a,s,o){if(this.mainIB=r,this.isDynamic=o,this.canInstance=!this.isDynamic,o){this.vb=t.clone();let o,h,l=s.slice(),d=n.length;for(let t=0;t<d;t++){let s=n[t],d=e.get(s);if(!d){this.renderDatas[t]=h;continue}let u=d.iChanges,_={};if(u){for(let e=0,t=u.length;e<t;e++){let t=u[e];t.change(this.vb,a)||(this.isNormalRender=!0);let r=t.changeOrder(l);r&&(o=r)}i.createIB(l,this.vb,o),_.ib=i.ib.slice(0,i.ibLength),_.mulitRenderData=i.outRenderData,_.type=i.type,_.size=i.size}let c=d.vChanges;if(c){let e=[];for(let r=0,i=c.length;r<i;r++){let i=c[r].clone();i.initChange(this.vb)&&(i.startFrame=t,i.endFrame=n.indexOf(i.endFrame),e.push(i))}_.vChanges=e}this.renderDatas[t]=_,h=_,s||(_.ib||(_.mulitRenderData=r.outRenderData,_.ib=r.ib.slice(0,this.mainIB.ibLength),_.type=r.type,_.size=r.size),this._defaultFrameData=_)}this.maxIndexCount=Math.max(i.maxIndexCount,this.mainIB.maxIndexCount)}else this.vb=t,this._defaultMesh=y.createMesh(this.type,this.vb,r,this.isDynamic),this._defaultMesh.lock=!0,this.maxIndexCount=r.maxIndexCount;this.maxVertexCount=this.vb.maxVertexCount,this._defaultFrameData||(this._defaultFrameData={mulitRenderData:r.outRenderData,ib:r.ib.slice(0,this.mainIB.ibLength),type:r.type,size:r.size})}destroy(){this._defaultMesh&&this._defaultMesh.destroy(),this._defaultMesh=null,this._defaultFrameData=null,this.renderDatas=null,this.renderCache=null,this.hasRenderCache=!1}}class Q{constructor(e){this.realTexture=e}getImage(){var e,t,r,i;return{width:null!==(t=null===(e=this.realTexture)||void 0===e?void 0:e.width)&&void 0!==t?t:16,height:null!==(i=null===(r=this.realTexture)||void 0===r?void 0:r.height)&&void 0!==i?i:16}}setFilters(e,r){if(!this.realTexture)return;let i;i=r===window.spine.TextureFilter.Nearest?t.FilterMode.Point:t.FilterMode.Bilinear,this.realTexture.filterMode=i}convertWrapMode(e){return e==spine.TextureWrap.ClampToEdge?t.WrapMode.Clamp:e==spine.TextureWrap.MirroredRepeat?t.WrapMode.Mirrored:t.WrapMode.Repeat}setWraps(e,t){this.realTexture&&(this.realTexture.wrapModeU=this.convertWrapMode(e),this.realTexture.wrapModeV=this.convertWrapMode(t))}}class ee{constructor(){this._registTextures={},this.hasPhysics=!1,this.blendModeMap=new Map,this.animators=[],this.skinAttachArray=[],this._skinNames=[]}getAllSkinNames(){return this._skinNames}getAnimationCount(){return this.data.animations.length}getAniNameByIndex(e){let t=this.data.animations[e];return t?t.name:null}findAnimation(e){return this.data.findAnimation(e)}hasAnimation(e){return!!this.data.findAnimation(e)}getSkinIndexByName(e){let t=this.data.skins;for(let r=0,i=t.length;r<i;r++)if(t[r].name==e)return r;return-1}_getBounds(){let e=this.skeleton,t=this.data,r=new spine.Vector2,i=new spine.Vector2,n=t.skins,a=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,h=Number.NEGATIVE_INFINITY;for(let t=0;t<n.length;t++){const l=n[t];e.setSkin(l),e.setToSetupPose(),e.updateWorldTransform(0),e.getBounds(r,i),a=Math.min(a,r.x),s=Math.min(s,r.y),o=Math.max(o,r.x+i.x),h=Math.max(h,r.y+i.y)}return a==Number.POSITIVE_INFINITY||s==Number.POSITIVE_INFINITY||o==Number.NEGATIVE_INFINITY||h==Number.NEGATIVE_INFINITY?ee.emptyBounds:{x:a,y:s,width:o-a,height:h-s}}getSkin(e){return this.data.skins[e]}_updateState(e){return this._state.update(e),this._state.getCurrent(0),this._state.apply(this.skeleton),this.skeleton.updateWorldTransform(2),this.skeleton.bones}_play(e){let t=this._state.setAnimation(0,e,!0);return t.animationStart=0,t.animation.duration}checkMainAttach(e,t){this.skeleton=e,this.data=t,this._stateData=new spine.AnimationStateData(t),this._state=new spine.AnimationState(this._stateData),this._bones=new W,this.attachMentParse(t),this.initAnimation(t.animations)}attachMentParse(e){let t,r=e.skins,i=e.slots;this._tempIbCreate=new z,this._skinNames.length=0;for(let e=0,n=r.length;e<n;e++){let n=r[e],a=new te;a.index=e,a.name=n.name,a._tempIbCreate=this._tempIbCreate,0!=e&&a.copyFrom(t),a.attachMentParse(n,i,this._bones),this.skinAttachArray.push(a),a.init(i),0==e&&(t=a),this._skinNames.push(n.name)}}registerTexture(e){let t=e.bitmap;if(!t)return null;let r=t.url||"texture",i=new Q(t),n=this._registTextures[r];n||(n=new spine.TextureAtlasPage(r),n.name=r,n.texture=i,n.width=t.width,n.height=t.height,this._registTextures[r]=n);let a=this._getTextureName(e),s=null;return s||(s=new spine.TextureAtlasRegion(n,a),s.page=n,s.name=a),s.width=e.width,s.height=e.height,s.originalWidth=e.sourceWidth,s.originalHeight=e.sourceHeight,s.offsetX=e.offsetX,s.offsetY=s.originalHeight-e.offsetY-s.height,e.uv&&e.uv.length>=8?(s.u=e.uv[0],s.v=e.uv[1],s.u2=e.uv[4],s.v2=e.uv[5]):(s.u=0,s.v=0,s.u2=1,s.v2=1),s.texture=i,s}_getTextureName(e){let t=e.name;return!t&&e.url&&(t=e.url.split("/").pop().split("\\").pop()),t||"texture"}getTextureRegion(e,t){let r=this._registTextures[e];return r?r.regions.find(e=>e.name===t):null}initAnimation(e){for(let t=0,r=e.length;t<r;t++){let r=e[t],i=new Z;i.check(r,this),this.animators.push(i),this.skinAttachArray.forEach(e=>{e.initAnimator(i)}),this.canCache&&this._initBoneFrame(i)}this.maxBoneNumber=this._bones.boneCount}_initBoneFrame(e){let t=this._play(e.name),r=Math.round(t/l.SPINE_STEP)||1;for(let t=0;t<=r;t++){let r=this._updateState(0==t?0:l.SPINE_STEP),i=[];e.boneFrames.push(i);for(let e=0;e<r.length;e++){let t=r[e],n=new Float32Array(8);n[0]=t.a,n[1]=t.b,n[2]=t.worldX+0,n[3]=0,n[4]=t.c,n[5]=t.d,n[6]=t.worldY+0,n[7]=0,i.push(n)}}e.isCache=!0}cacheBone(){let e=this._bones.boneIdIndexPairs,t=new Set,r=new Map;for(let i=1,n=e.length;i<n;i+=2){let n=e[i];t.add(n);let a=this.skeleton.bones[n];a&&a.data&&(r.set(n,a.data.skinRequired),a.data.skinRequired=!1)}this.skeleton.updateCache();for(let e=0,t=this.animators.length;e<t;e++){let t=this.animators[e];0!=t.boneFrames.length||t.hasClip||this._initBoneFrame(t)}r.forEach((e,t)=>{let r=this.skeleton.bones[t];r&&r.data&&(r.data.skinRequired=e)})}cacheRender(){if(!l.cacheSwitch)for(let e=0,t=this.animators.length;e<t;e++){let t=this.animators[e];if(!t.hasRenderCache){for(let e of t.skinDataArray)this._cacheRenderForSkin(t,e);t.hasRenderCache=!0}}}_cacheRenderForSkin(e,t){let r=this._play(e.name),i=Math.round(r/l.SPINE_STEP)||1,n=new S;t.renderCache=[];for(let e=0;e<=i;e++){this._updateState(0==e?0:l.SPINE_STEP),this.skeleton.updateWorldTransform(2),n.renderUpdate(e*l.SPINE_STEP,this.skeleton,null,-1,-1,0,0);let r=n.exportToCache();t.renderCache[e]=r}t.hasRenderCache=!0}destroy(){for(let e=0,t=this.animators.length;e<t;e++)this.animators[e].destroy();this.animators.length=0}}ee.emptyBounds={x:0,y:0,width:0,height:0};class te{constructor(){this.vertexBones=0,this.rbBoneIndex=-1,this.twoColorTint=!1,this.slotAttachMap=new Map,this.mainAttachMentOrder=[]}copyFrom(e){e.slotAttachMap.forEach((e,t)=>{this.slotAttachMap.set(t,new Map(e))})}attachMentParse(t,r,i){let n=0,a=t.attachments,s=0,o=0,h=!1,l=new Set;for(let e=0,t=r.length;e<t;e++){let t=a[e],i=r[e],d=i.boneData.index,u=this.slotAttachMap.get(e),_=i.attachmentName;if(u||(u=new Map,this.slotAttachMap.set(e,u)),t)for(let r in t){let a=t[r],_=null,c=new U;c.init(a,d,e,_,i),n=Math.max(n,c.vertexBones),o+=c.indexCount,s+=c.vertexCount,h=h||!!c.darkColor,u.set(r,c),c.bones.forEach(e=>{l.add(e)})}else if(_){let e=u.get(_);e&&(o+=e.indexCount,s+=e.vertexCount,n=Math.max(n,e.vertexBones),h=h||!!e.darkColor,e.bones.forEach(e=>{l.add(e)}))}if(!u.get(null)){let t=new U;t.slotId=e,t.color=i.color,t.boneIndex=d,t.attachment=null,u.set(t.attachment,t)}}let d,u=l.size;switch(u>1?this.type=e.ESpineRenderType.boneGPU:1===u?(this.type=e.ESpineRenderType.rigidBody,this.rbBoneIndex=l.values().next().value):this.type=e.ESpineRenderType.normal,this.vertexBones=n,this.twoColorTint=h,this.type){case e.ESpineRenderType.normal:case e.ESpineRenderType.boneGPU:d="UV,COLOR,POSITION,BONE",h&&(d+=",COLOR2"),this.mainVB=new H(d,s,!0,i);break;case e.ESpineRenderType.rigidBody:d="UV,COLOR,POSITION,RIGIDBODY",h&&(d+=",COLOR2"),this.mainVB=new Y(d,s,!0,i)}this.mainIB=new z,this.mainIB.updateFormat(s),this.mainIB.setBufferLength(o)}init(e){let t=this.mainAttachMentOrder;e.forEach((e,r)=>{let i=e.attachmentName;if(i){let e=this.slotAttachMap.get(r).get(i);e?this.mainVB.appendVB(e):e=this.slotAttachMap.get(r).get(null),e.isClip&&(this.isNormalRender=!0),t.push(e)}else{let e=this.slotAttachMap.get(r).get(null);t.push(e)}}),this.mainIB.createIB(t,this.mainVB)}initAnimator(e){let t=e.createSkinData(this.mainVB,this.mainIB,this._tempIbCreate,this.slotAttachMap,this.mainAttachMentOrder,this.type);return t.name=this.name+"_"+e.name,t}}class re{constructor(){this._premultipliedAlpha=l.PREMULTIPLIED_ALPHA_DEFAULT,this._cachedAtlasText=null,this._basePath=""}parse(e,t){let r=new h,i=new spine.AtlasAttachmentLoader(this._atlas),n=null;if(e instanceof ArrayBuffer){n=new spine.SkeletonBinary(i,!1).readSkeletonData(new Uint8Array(e))}else{n=new spine.SkeletonJson(i,!1).readSkeletonData(e)}let a=new ee,s=new spine.Skeleton(n);if(r._textures=t,r._premultipliedAlpha=this._premultipliedAlpha,a.hasPhysics=this._premultipliedAlpha&&n.physicsConstraints&&n.physicsConstraints.length>0,a.canCache=l.cacheSwitch&&!a.hasPhysics,a.checkMainAttach(s,n),null==n.x||null==n.y||null==n.width||null==n.height){let e=a._getBounds();r.x=e.x,r.y=e.y,r.width=e.width,r.height=e.height,r.offsetX=e.x+e.width,r.offsetY=-(e.y+e.height)}else r.x=n.x||0,r.y=n.y||0,r.width=n.width||0,r.height=n.height||0,r.offsetX=(n.x||0)+r.width,r.offsetY=-((n.y||0)+r.height);return r.optimize=a,r._parser=this,r}collectTextures(e,r){const i=e.split(l.SPLIT_REGEX),n=[];let a=this._premultipliedAlpha;for(let e=0;e<i.length;e++){const t=i[e].trim();if(!t)continue;const r=t.match(l.PMA_REGEX);if(r)a="true"===r[1].toLowerCase();else if(-1!==t.indexOf(".png")||-1!==t.indexOf(".jpg")||-1!==t.indexOf(".jpeg")||-1!==t.indexOf(".webp")){const e=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\")),r=-1!==e?t.substring(e+1):t;n.push({path:r,pma:a}),this._premultipliedAlpha=a&&this._premultipliedAlpha,a=!0}}return this._cachedAtlasText=e,this._basePath=t.URL.getPath(r.url),n.map(e=>({url:this._basePath+e.path,type:t.Loader.TEXTURE2D,propertyParams:{premultiplyAlpha:e.pma},constructParams:[0,0,t.TextureFormat.R8G8B8A8,!1,!1,!0,e.pma]}))}create(e,r){const i=this._cachedAtlasText||"";l.VersionFirst>=4?this._atlas=new spine.TextureAtlas(i):this._atlas=new spine.TextureAtlas(i,e=>new Q(t.Laya.loader.getRes(this._basePath+e,t.Loader.TEXTURE2D)));let n={},a=this._premultipliedAlpha,s=this._atlas;for(var o=0;o<r.length;o++){let e=r[o];e&&e._addReference();let t=s.pages[o];n[t.name]=e,a=a&&e._premultiplyAlpha,t.setTexture&&t.setTexture(new Q(e))}return this._premultipliedAlpha=a,this.parse(e,n)}destroy(){}}class ie{constructor(){this._needUseMatrix=!0,this._lightReceive=!1,this._offset=new t.Vector2,this._baseColor=new t.Color(1,1,1,1),this.renderMatrixVersion=-1,this._nativeObj=new window.conchRTSpineRenderDataHandle,this._nativeObj.needUseMatrix=!0}get needUseMatrix(){return this._needUseMatrix}set needUseMatrix(e){this._needUseMatrix!==e&&(this._needUseMatrix=e,this._nativeObj.needUseMatrix=e)}get lightReceive(){return this._lightReceive}set lightReceive(e){this._lightReceive!==e&&(this._lightReceive=e,e?this._owner.spriteShaderData.addDefine(t.BaseRenderNode2D.SHADERDEFINE_LIGHT2D_ENABLE):this._owner.spriteShaderData.removeDefine(t.BaseRenderNode2D.SHADERDEFINE_LIGHT2D_ENABLE))}get baseColor(){return this._baseColor}set baseColor(e){e!==this._baseColor&&this._baseColor.equal(e)||((e=e||t.Color.BLACK).cloneTo(this._baseColor),this._owner.spriteShaderData.setColor(t.BaseRenderNode2D.BASERENDER2DCOLOR,this._baseColor),this._nativeObj.setBaseColor(this._baseColor))}get owner(){return this._owner}set owner(e){e!==this._owner&&(this._setOwnerLocal(e),this._nativeObj.setOwner(e?e._nativeObj:null))}_setOwnerLocal(e){if(e!==this._owner){if(this._owner&&this._owner.spriteShaderData){let e=this._owner.spriteShaderData;e.removeDefine(t.BaseRenderNode2D.SHADERDEFINE_BASERENDER2D),e.removeDefine(o.SPINE_UV),e.removeDefine(o.SPINE_COLOR),e.removeDefine(t.BaseRenderNode2D.SHADERDEFINE_LIGHT2D_ENABLE)}if(this._owner=e,this._owner){let e=this._owner.spriteShaderData;e.addDefine(t.BaseRenderNode2D.SHADERDEFINE_BASERENDER2D),e.addDefine(o.SPINE_UV),e.addDefine(o.SPINE_COLOR),this._lightReceive&&e.addDefine(t.BaseRenderNode2D.SHADERDEFINE_LIGHT2D_ENABLE)}}}get offset(){return this._offset}set offset(e){this._offset=e,this._nativeObj.setOffset(e)}inheriteRenderData(e){this._nativeObj.inheriteRenderData(e._nativeObj)}destroy(){var e;this.owner=null,this.skeleton=null,null===(e=this._nativeObj)||void 0===e||e.destroy(),this._nativeObj=null}}class ne{createSpineTempletParser(){return new re}createSpineRenderDataHandle(){return t.LayaEnv.isConch&&2!==window.conchConfig.getGraphicsAPI()?new ie:new O}createSpineRender2D(e){return new L(e)}createSpineRender3D(e){return new k(e)}}class ae{static adaptJS(){let e=window.spine;if(e){let t=e.AnimationState.prototype;if(t.getCurrentOld=t.getCurrent,t.getCurrent=function(e){let t=this.getCurrentOld(e);return this.currentTrack=t,t},"4.1"===l.VERSION&&"function"!=typeof e.Skeleton.prototype.update&&(e.Skeleton.prototype.update=function(e){}),"3.7"==l.VERSION){e.Bone.prototype.active=!0}}}}ae.stateMap={0:"start",1:"interrupt",2:"end",3:"complete",4:"dispose",5:"event"},t.Laya.addAfterInitCallback(()=>{l.factory=new ne,S.__init__(),ae.adaptJS(),l.ENABLE_WEB_BATCH&&(t.BatchManager.registerProvider(t.BaseRender2DType.spineSimple,c),t.BatchManager.registerProvider(t.BaseRender2DType.spinenormal,x))});class se extends t.Script{constructor(){super()}onEnable(){this.bakeData&&this.initBake(JSON.parse(this.bakeData))}onDisable(){let e=this.owner.getComponent(d);e._spineRender&&e._spineRender.initBake(null)}async initBake(e){const r=e.aniOffsetMap.textureWidth||256;let i=await t.Laya.loader.load({url:e.simpPath,type:t.Loader.TEXTURE2D,constructParams:[r,r,t.TextureFormat.R32G32B32A32,!1,!1,!1,!1]});e.texture2d=i;let n=this.owner.getComponent(d);n.templet?n._spineRender.initBake(e):this.owner.on(t.Event.READY,this,()=>{n._spineRender.initBake(e)})}}t.ClassUtils.regClass("SpineBakeScript",se);class oe{load(e){return"json"===t.Utils.getFileExtension(e.url)?e.loader.fetch(e.url,"json",e.progress.createCallback()).then(t=>this.loadSpineSource(e,e.url,t)):this.loadSpineSource(e,e.url)}loadSpineSource(e,r,i){return t.AssetDb.inst.resolveURL(r).then(t=>this.loadSpineSourceResolved(e,t||r,i))}loadSpineSourceResolved(e,r,i){let n=t.Utils.replaceFileExtension(r,"atlas"),a=t.Utils.getFileExtension(r);return Promise.all([void 0!==i?Promise.resolve(i):e.loader.fetch(r,"skel"==a||"bin"==a?"arraybuffer":"json",e.progress.createCallback()),e.loader.fetch(n,"text",e.progress.createCallback())]).then(i=>{if(!i[0]||!i[1])return null;let n=l.factory.createSpineTempletParser(),a=r===e.url?e:Object.assign(Object.create(e),{url:r}),s=n.collectTextures(i[1],a);return t.Laya.loader.load(s,null,e.progress.createCallback()).then(t=>{let a=n.create(i[0],t);return this.loadRuntimeMeta(e,r).then(t=>oe.applyRuntimeData(a,t,e))})})}async loadRuntimeMeta(e,r){let i=t.AssetDb.inst.metaMap[e.url]||t.AssetDb.inst.metaMap[r];return!i&&e.uuid&&(i=await t.AssetDb.inst.getMeta(e.url,e.uuid)),i}static async applyRuntimeData(e,t,r){if(!e)return e;if(!t)return e.spineMaterialTextures={},e.spineMaterials2D={},e.spineMaterials3D={},e;e.spineMaterialTextures=t.spineMaterialTextures||{};let[i,n]=await Promise.all([oe.loadMaterialMap(t.spineMaterials2D,e,r),oe.loadMaterialMap(t.spineMaterials3D,e,r)]);return e.spineMaterials2D=i||{},e.spineMaterials3D=n||{},e}static async loadMaterialMap(e,r,i){var n;if(!e)return null;let a={},s=[];for(let o in e){if(0===o.indexOf("_$"))continue;let h=oe.getRuntimeMaterialKey(o,r),l=oe.getMaterialURL(e[o]);l?s.push(t.Laya.loader.load(l,t.Loader.MATERIAL,null===(n=null==i?void 0:i.progress)||void 0===n?void 0:n.createCallback()).then(e=>{a[h]=e||null})):a[h]=null}return await Promise.all(s),a}static getRuntimeMaterialKey(e,t){let r=/^(.*)_([0-3])_(true|false)_(2D|3D)$/.exec(e);if(!r)return e;let i=oe.getTextureByStorageKey(r[1],t);return i?`${i.id}_${r[2]}_${r[3]}_${r[4]}`:e}static getTextureByStorageKey(e,t){var r;let i=null==t?void 0:t._textures;if(!i)return null;let n=null===(r=t.spineMaterialTextures)||void 0===r?void 0:r[e];if(n&&i[n])return i[n];for(let t in i){let r=i[t];if(r&&(t===e||r.url===e||r.uuid===e||String(r.id)===e))return r}return null}static getMaterialURL(e){if(!e)return null;let t="string"==typeof e?e:e._$uuid;return t?(-1==t.indexOf("://")&&-1==t.indexOf("/")&&-1==t.indexOf(".")&&(t="res://"+t),t):null}}t.Loader.registerLoader(["skel","json"],oe,t.Loader.SPINE),e.AnimationRender=Z,e.AttachmentParse=U,e.BakedSpine2DRenderer=T,e.BakedSpineRenderer=C,e.BaseOptimizeRender=R,e.ChangeDeform=j,e.ChangeDrawOrder=K,e.ChangeRGBA=$,e.ChangeSlot=q,e.ExternalSkin=r,e.ExternalSkinItem=i,e.IBCreator=z,e.JSSpineFactory=ne,e.MultiRenderData=G,e.NativeSpineRenderDataHandle=ie,e.OptimizedSpineRenderer=v,e.RigidBodySpineRenderer=B,e.SkeletonOptimise=ee,e.SkinAniRenderData=J,e.SkinAttach=te,e.Spine2DNormalRenderUpdater=N,e.Spine2DRenderNode=d,e.SpineAdapter=ae,e.SpineBakeScript=se,e.SpineBaseRenderer=I,e.SpineBoneRegistry=W,e.SpineBufferView=b,e.SpineConst=l,e.SpineGlobalMeshManager=w,e.SpineInstanceBatch=c,e.SpineInstanceElement2DTool=p,e.SpineMeshUtils=y,e.SpineNormalBatch=x,e.SpineNormalRenderUpdater=S,e.SpineOptimizeRender2D=L,e.SpineOptimizeRender3D=k,e.SpineRenderUpdater=D,e.SpineShaderInit=o,e.SpineSkeleton=u,e.SpineTemplet=h,e.SpineTempletLoader=oe,e.SpineTexture=Q,e.SpineWholeBuffer=m,e.StandardSpine2DRenderer=M,e.StandardSpineRenderer=A,e.VBBoneCreator=H,e.VBCreator=X,e.VBRigBodyCreator=Y,e.WebSpineRenderDataHandle=O,e.WebSpineTempletParser=re}(window.Laya=window.Laya||{},Laya);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,t){"use strict";class i{static init(){t.Shader3D.addInclude("Spine3DVertex.glsl",'#if !defined(SpineVertex_lib)\n#define SpineVertex_lib\n#include "SpineVertexCommon.glsl";\nuniform mat4 u_WorldMat;uniform vec4 u_WorldInvertFront;struct Vertex{vec3 positionOS;vec3 normalOS;vec2 texCoord0;\n#ifdef UV1\nvec2 texCoord1;\n#endif\nvec4 vertexColor;\n#ifdef LIGHTMAP\nvec4 lightmapScaleOffset;\n#endif LIGHTMAP\n};\n#ifdef LIGHTMAP\n#ifndef GPU_INSTANCE\nuniform vec4 u_LightmapScaleOffset;\n#endif\nvec4 getLightmapScaleOffset(){\n#ifdef GPU_INSTANCE\nreturn a_LightmapScaleOffset;\n#else\nreturn u_LightmapScaleOffset;\n#endif\n}\n#endif\nvoid getVertexParams(inout Vertex vertex){vec4 spinePos2D=getSpinePos();vertex.positionOS=vec3(spinePos2D.xy,0.0);vertex.normalOS=vec3(0.0,0.0,1.0);vertex.vertexColor=vec4(1.0,1.0,1.0,1.0);vertex.vertexColor=a_color;vertex.vertexColor.rgb=pow(vertex.vertexColor.rgb,vec3(2.2));vertex.vertexColor.rgb*=a_color.a;vertex.texCoord0=a_uv;\n#ifdef LIGHTMAP\nvertex.lightmapScaleOffset=getLightmapScaleOffset();\n#endif LIGHTMAP\n}\n#endif\n'),i.SPINE_BILLBOARD=t.Shader3D.getDefineByName("SPINE_BILLBOARD"),i.SPINE_BILLBOARD_MATRIX=t.Shader3D.propertyNameToID("u_spineBillboardMatrix");const e=t.LayaGL.renderDeviceFactory.createGlobalUniformMap("Spine3D");e.addShaderUniformArray(t.SpineShaderInit.BONEMAT,"u_sBone",t.ShaderDataType.Vector4,200),e.addShaderUniform(t.SpineShaderInit.COLOR,"u_color",t.ShaderDataType.Vector4),e.addShaderUniform(t.SpineShaderInit.BONEMAT_0,"u_sBone0",t.ShaderDataType.Vector4),e.addShaderUniform(t.SpineShaderInit.BONEMAT_1,"u_sBone1",t.ShaderDataType.Vector4),e.addShaderUniform(t.SpineShaderInit.SIMPLE_SIMPLEANIMATORPARAMS,"u_SimpleAnimatorParams",t.ShaderDataType.Vector4),e.addShaderUniform(t.SpineShaderInit.SIMPLE_SIMPLEANIMATORTEXTURE,"u_SimpleAnimatorTexture",t.ShaderDataType.Texture2D),e.addShaderUniform(t.SpineShaderInit.SIMPLE_SIMPLEANIMATORTEXTURESIZE,"u_SimpleAnimatorTextureSize",t.ShaderDataType.Float),e.addShaderUniform(t.SpineShaderInit.SPINE_RENDER_SIZE,"u_spineRenderSize",t.ShaderDataType.Vector2),e.addShaderUniform(i.SPINE_BILLBOARD_MATRIX,"u_spineBillboardMatrix",t.ShaderDataType.Matrix4x4);let n=t.Shader3D.add("Spine3D",!0,!1);n.shaderType=t.ShaderFeatureType.D3;let a={u_spineTexture:t.ShaderDataType.Texture2D},s=new t.SubShader(t.SpineShaderInit.textureSpineAttribute,a);n.addSubShader(s),s.addShaderPass('#define SHADER_NAME Spine3DVS\n#include "Math.glsl";\n#include "Scene.glsl";\n#include "SceneFogInput.glsl";\n#include "Camera.glsl";\n#include "Spine3DVertex.glsl";\n#ifdef SPINE_BILLBOARD\nuniform mat4 u_spineBillboardMatrix;\n#endif\nvarying vec2 v_texcoord;varying vec4 v_color;varying vec4 v_color2;mat4 getWorldMatrix(){\n#ifdef SPINE_BILLBOARD\nreturn u_spineBillboardMatrix;\n#else\n#ifdef GPU_INSTANCE\nmat4 worldMat=a_WorldMat;\n#else\nmat4 worldMat=u_WorldMat;\n#endif\nreturn worldMat;\n#endif\n}void main(){Vertex vertex;getVertexParams(vertex);v_texcoord=vertex.texCoord0;v_color=vertex.vertexColor;\n#ifdef COLOR2\nv_color2=a_color2;v_color2.rgb=pow(v_color2.rgb,vec3(2.2));\n#else\nv_color2=vec4(0.0,0.0,0.0,1.0);\n#endif\n#ifdef PREMULTIPLYALPHA\nv_color2.xyz=v_color2.xyz*v_color.a;\n#endif\nmat4 worldMat=getWorldMatrix();vec4 pos=worldMat*vec4(vertex.positionOS,1.0);vec3 positionWS=pos.xyz/pos.w;gl_Position=getPositionCS(positionWS);gl_Position=remapPositionZ(gl_Position);\n#ifdef FOG\nFogHandle(gl_Position.z);\n#endif\n}','#define SHADER_NAME Spine3DFS\n#include "Color.glsl";\n#include "Scene.glsl";\n#include "SceneFog.glsl";\n#include "Camera.glsl";\nvarying vec2 v_texcoord;varying vec4 v_color;varying vec4 v_color2;vec4 getColor(){vec4 color=texture2D(u_spineTexture,v_texcoord.xy);\n#ifdef Gamma_u_spineTexture\ncolor=gammaToLinear(color);\n#endif\nvec4 final;\n#ifdef TWOCOLORTINT\nfinal.a=color.a*v_color.a;final.xyz=((color.a-1.0)*v_color2.a+1.0-color.xyz)*v_color2.xyz+color.xyz*v_color.xyz;\n#else\nfinal=color*v_color;\n#endif\nreturn final;}void main(){gl_FragColor=getColor();gl_FragColor=outputTransform(gl_FragColor);\n#ifdef FOG\ngl_FragColor.rgb=sceneLitFog(gl_FragColor.rgb);\n#endif\n}')}}class n extends t.BaseRender{get renderSize(){return this._renderSize}set renderSize(e){e.cloneTo(this._renderSize),this._baseRenderNode.shaderData.setVector2(t.SpineShaderInit.SPINE_RENDER_SIZE,this._renderSize)}get billboard(){return this._billboard}set billboard(e){this._billboard!==e&&(this._billboard=e,this._billboard?this._baseRenderNode.shaderData.addDefine(i.SPINE_BILLBOARD):this._baseRenderNode.shaderData.removeDefine(i.SPINE_BILLBOARD))}constructor(){super(),this.physicsUpdate=0,this._maxDeltaTime=.1,this._pause=!0,this._needUpdate=!1,this._playbackRate=1,this.trackIndex=0,this._skinName="default",this._loop=!0,this._playState=t.ESpineRenderState.Stopped,this._useFastRender=!0,this._billboard=!1,this._enableCache=!1,this._renderSize=new t.Vector2(0,0),this._billboardMatrix=new t.Matrix4x4,this._cacheMoved=new t.Vector2(-1,-1),this._worldParams=new t.Vector4,this._playAudio=!1,this._skeletonPosition=new t.Vector2,this._lastSkeletonWorldPosition=new t.Vector3,this._hasSkeletonWorldPosition=!1,this._geometryBounds=new t.Bounds,this._premultipliedAlpha=!0,this._setPreAlphaFlag=!1,this._baseRenderNode.baseGeometryBounds=this._geometryBounds}_createBaseRenderNode(){return t.Laya3DRender.Render3DModuleDataFactory.createMeshRenderNode()}_isMaterialVaild(e){return e.checkType(t.ShaderFeatureType.D3)}_getcommonUniformMap(){return["Sprite3D","Spine3D"]}get premultipliedAlpha(){return!this._templet||this._setPreAlphaFlag?this._premultipliedAlpha:this._templet.premultipliedAlpha}set premultipliedAlpha(e){this._premultipliedAlpha=e,this._spineRender&&(this._setPreAlphaFlag||!this._templet?this._spineRender.premultipliedAlpha=e:this._spineRender.premultipliedAlpha=this._templet._premultipliedAlpha)}setPremultipliedAlpha(e){this._premultipliedAlpha=e,this._spineRender.premultipliedAlpha=e,this._setPreAlphaFlag=!0}_renderUpdate(e){let i=this._baseRenderNode;if(i._applyReflection(),i._applyLightProb(),i.ismoved.x>this._cacheMoved.x||i.ismoved.x==this._cacheMoved.x&&i.ismoved.y>this._cacheMoved.y){let e=i.transform;i.shaderData.setMatrix4x4(t.Sprite3D.WORLDMATRIX,e.worldMatrix),this._worldParams.x=e.getFrontFaceValue(),i.shaderData.setVector(t.Sprite3D.WORLDINVERTFRONT,this._worldParams),i.ismoved.cloneTo(this._cacheMoved)}this._updateBillboardMatrix(i,e)}_updateBillboardMatrix(e,a){var s;if(!this._billboard||!a)return;let r=null===(s=a.cameraModuleData)||void 0===s?void 0:s.transform;if(!r)return;let o=e.transform,l=n._tempCameraUp,d=n._tempCameraForward;r.getUp(l),r.getForward(d),t.Matrix4x4.billboard(o.position,r.position,l,d,this._billboardMatrix);const h=o.getWorldLossyScale(),_=this._billboardMatrix.elements;_[0]*=-h.x,_[1]*=-h.x,_[2]*=-h.x,_[4]*=h.y,_[5]*=h.y,_[6]*=h.y,_[8]*=h.z,_[9]*=h.z,_[10]*=h.z,e.shaderData.setMatrix4x4(i.SPINE_BILLBOARD_MATRIX,this._billboardMatrix)}_onWorldMatNeedChange(e){super._onWorldMatNeedChange(e),this._baseRenderNode.ismoved.setValue(t.Stat.loopCount,t.LayaGL.renderEngine._framePassCount),this._baseRenderNode.ismoved=this._baseRenderNode.ismoved}get source(){return this._source}set source(e){if(this._source=e,e){let i=t.ILaya.loader.getRes(e,t.Loader.SPINE);i?this.templet=i:t.ILaya.loader.load(e,t.Loader.SPINE).then(e=>{!this._source||e&&!e.isCreateFromURL(this._source)||this.destroyed||(this.templet=e)})}else this.templet=null}get skinName(){return this._skinName}set skinName(e){this._skinName=e,this._templet&&this.showSkinByName(e)}get animationName(){return this._animationName}set animationName(e){this._animationName=e,this._templet&&this.play(e,this._loop,!0)}get maxDetlaTime(){return this._maxDeltaTime}set maxDetlaTime(e){this._maxDeltaTime=e}get loop(){return this._loop}set loop(e){this._loop=e,this._templet&&this.play(this._animationName,this._loop,!0)}get templet(){return this._templet}set templet(e){this.init(e)}set currentTime(e){if(this._templet){if((e/=1e3)<this._playStart||this._playEnd&&e>this._playEnd||e>this._duration)throw new Error("AnimationPlayer: value must large than playStartTime,small than playEndTime.");this._spineRender.currentTime=e}}get currentTime(){return this._templet?this._spineRender.currentTime:0}get playState(){return this._playState}get useFastRender(){return this._useFastRender}set useFastRender(e){this._useFastRender!==e&&(this._useFastRender=e,this._templet&&(this._spineRender.mode=e?t.ESpineRenderMode.Optimize:t.ESpineRenderMode.Normal))}get enableCache(){return this._enableCache}set enableCache(e){this._enableCache!==e&&(this._enableCache=e,this._spineRender&&(e?this._spineRender.enableCache():this._spineRender.disableCache()),this._animationName&&this.play(this._animationName,this._loop,!0,this._playStart,this._playEnd,this._playAudio))}onEnable(){super.onEnable(),this.owner.on(t.Event.TRANSFORM_CHANGED,this,this.onTransformChanged),this._spineRender&&t.LayaEnv.isPlaying&&void 0!==this._animationName&&this.play(this._animationName,this._loop,!0)}onDisable(){super.onDisable(),this.owner.off(t.Event.TRANSFORM_CHANGED,this,this.onTransformChanged)}init(e){if(this.destroyed)return;if((this._templet||this._spineRender)&&this.clear(),this._templet=e,!this._templet)return;this._templet._addReference(),this._templet.on(t.SpineTemplet.EVENT_SPINE_MATERIAL_CHANGE,this,this.onSpineMaterialChange),this._spineRender=t.SpineConst.factory.createSpineRender3D(this._baseRenderNode),this._spineRender.init(e),this._spineRender.mode=this._useFastRender?t.ESpineRenderMode.Optimize:t.ESpineRenderMode.Normal,this._spineRender.premultipliedAlpha=this._setPreAlphaFlag?this._premultipliedAlpha:this._templet.premultipliedAlpha,this._resetSkeletonPosition(),this._enableCache&&this._spineRender.enableCache(),0!==this._renderSize.x&&0!==this._renderSize.y?this._baseRenderNode.shaderData.setVector2(t.SpineShaderInit.SPINE_RENDER_SIZE,this._renderSize):this._baseRenderNode.shaderData.setVector2(t.SpineShaderInit.SPINE_RENDER_SIZE,t.Vector2.TEMP.setValue(e.width,e.height)),this.boundsChange=!0;let i=this._templet.getSkinIndexByName(this._skinName);-1!=i&&this.showSkinByIndex(i),this._initBounds(),this.onTransformChanged(),this._spineRender.setEventListener({start:e=>{},interrupt:e=>{},end:e=>{},dispose:e=>{},complete:e=>{this.owner.event(t.Event.END),e.loop?(this._spineRender.complete(),this.owner.event(t.Event.COMPLETE)):this.stop()},event:(e,i)=>{let n={audioValue:i.data.audioPath,audioPath:i.data.audioPath,floatValue:i.floatValue,intValue:i.intValue,name:i.data.name,stringValue:i.stringValue,time:1e3*i.time,balance:i.balance,volume:i.volume};this.owner.event(t.Event.LABEL,n)}}),this.owner.event(t.Event.READY),t.LayaEnv.isPlaying&&this.enabled&&void 0!==this._animationName&&this.play(this._animationName,this._loop,!0)}_initBounds(){let e=this._templet.x,t=this._templet.y,i=this._templet.width,n=this._templet.height,a=this._geometryBounds.getMin(),s=this._geometryBounds.getMax();a.x=e,a.y=t,a.z=0,s.x=i+e,s.y=n+t,s.z=0,this._geometryBounds.setMin(a),this._geometryBounds.setMax(s),this._baseRenderNode.baseGeometryBounds=this._geometryBounds}play(e,i,n=!0,a=0,s=0,r=!1){if(this._templet){if(this._playAudio=r,a/=1e3,s/=1e3,this._loop=i,a<0||s<0)throw new Error("SpineSkeleton: start and end must large than zero.");if(0!==s&&a>s)throw new Error("SpineSkeleton: start must less than end.");if("number"==typeof e)e=this.getAniNameByIndex(e);else if(!this.templet.hasAnimation(e))return;if(n||this._pause||this._animationName!=e){this._animationName=e,this._spineRender.play(e,i,this.trackIndex,a,s);let n=this._spineRender.trackEntry.animation.duration;this._duration=n,this._playStart=a,this._playEnd=s<=n?s:n,this._pause&&(this._pause=!1,this._needUpdate=!0),this._playState=t.ESpineRenderState.Playing,this._update()}}else console.warn("Spine2DRenderNode.play: templet is not ready, animation:",e)}_update(){const e=this._spineRender;if(this.destroyed||!e)return;let i=this._enableCache?t.SpineConst.SPINE_STEP:t.Laya.timer.delta/1e3;i>this._maxDeltaTime&&(i=this._maxDeltaTime);let n=i*this._playbackRate,a=e.currentTime;this._syncSkeletonPosition(),e.update(n),this.destroyed||e!==this._spineRender||e.render(a,this.physicsUpdate)}getAnimNum(){return this._templet.getAnimationCount()}getAniNameByIndex(e){return this._templet.getAniNameByIndex(e)}getSlotByName(e){return this._spineRender.findSlot(e)}playbackRate(e){this._playbackRate=e}showSkinByName(e){this.showSkinByIndex(this._templet.getSkinIndexByName(e))}showSkinByIndex(e){this._spineRender.showSkinByIndex(e)}stop(){this._playState!==t.ESpineRenderState.Stopped&&(this._pause=!0,this._needUpdate=!1,this._playState=t.ESpineRenderState.Stopped,this.owner.event(t.Event.STOPPED))}onUpdate(){this._needUpdate&&this._update()}paused(){this._pause||(this._pause=!0,this._needUpdate=!1,this._playState=t.ESpineRenderState.Paused,this.owner.event(t.Event.PAUSED))}resume(){this._playState===t.ESpineRenderState.Paused&&(this._pause=!1,this._needUpdate=!0,this._playState=t.ESpineRenderState.Playing)}onTransformChanged(){this._syncSkeletonPosition()}_resetSkeletonPosition(){this._skeletonPosition.setValue(0,0),this._lastSkeletonWorldPosition.setValue(0,0,0),this._hasSkeletonWorldPosition=!1}_syncSkeletonPosition(){if(!this._spineRender)return;let e=this.owner.transform.worldMatrix.elements,t=e[12],i=e[13],n=e[14];if(!this._isPhysicsSyncEnabled())return this._lastSkeletonWorldPosition.setValue(t,i,n),void(this._hasSkeletonWorldPosition=!0);if(!this._hasSkeletonWorldPosition)return this._lastSkeletonWorldPosition.setValue(t,i,n),this._hasSkeletonWorldPosition=!0,void this._spineRender.setSkeletonPosition(this._skeletonPosition.x,this._skeletonPosition.y);let a=t-this._lastSkeletonWorldPosition.x,s=i-this._lastSkeletonWorldPosition.y,r=n-this._lastSkeletonWorldPosition.z;if(0!==a||0!==s||0!==r){let t=0,i=0,n=e[0],o=e[1],l=e[2],d=e[4],h=e[5],_=e[6],p=n*n+o*o+l*l,m=d*d+h*h+_*_;p>0&&(t=(a*n+s*o+r*l)/p),m>0&&(i=(a*d+s*h+r*_)/m),0===t&&0===i||(this._skeletonPosition.x+=t,this._skeletonPosition.y+=i,this._spineRender.physicsTranslate(t,i))}this._lastSkeletonWorldPosition.setValue(t,i,n),this._spineRender.setSkeletonPosition(this._skeletonPosition.x,this._skeletonPosition.y)}_isPhysicsSyncEnabled(){return 1===this.physicsUpdate||2===this.physicsUpdate}setSlotAttachment(e,t){this.useFastRender=!1,this._spineRender.setAttachment(e,t)}clear(){this._needUpdate=!1,this._pause=!0;const e=this._spineRender;this._spineRender=null,null==e||e.destroy(),this.reset()}onSpineMaterialChange(){this._spineRender&&this._spineRender.clearCacheMaterials()}reset(){var e;null===(e=this._spineRender)||void 0===e||e.reset(),this._templet&&(this._templet.off(t.SpineTemplet.EVENT_SPINE_MATERIAL_CHANGE,this,this.onSpineMaterialChange),this._templet._removeReference(1),this._templet=null),this._resetSkeletonPosition(),this._pause=!0,this._needUpdate=!1,this._playState=t.ESpineRenderState.Stopped}_onDestroy(){(this._templet||this._spineRender)&&this.clear(),super._onDestroy()}addAnimation(e,t=!1,i=0){i/=1e3;let n=e;"number"==typeof n&&(n=this.getAniNameByIndex(n)),this._animationName=n,this._spineRender.addAnimation(n,t,i,this.trackIndex)}setMix(e,t,i){i/=1e3;let n=e;"number"==typeof n&&(n=this.getAniNameByIndex(n));let a=t;"number"==typeof a&&(a=this.getAniNameByIndex(a)),this._spineRender.setMix(n,a,i)}getBoneByName(e){return this._spineRender.findBone(e)}getSkeleton(){return this._spineRender.getSkeleton()}updateWorldTransform(e=this.physicsUpdate){this._spineRender&&this._spineRender.updateWorldTransform(e)}physicsTranslate(e,t){this._spineRender.physicsTranslate(e,t)}}n._tempCameraUp=new t.Vector3,n._tempCameraForward=new t.Vector3,(0,t.ClassUtils.regClass)("Spine3DRenderer",n),t.Laya.addAfterInitCallback(()=>{i.init()}),e.Spine3DRenderer=n,e.Spine3DShaderInit=i}(window.Laya=window.Laya||{},Laya);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,t){"use strict";class i{}class a{constructor(){}}class r{constructor(){this.layerMask=1}}class l{constructor(){this._density=10,this._friction=.2,this._restitution=0,this.group=0,this.category=1,this.mask=-1}get density(){return this._density}set density(e){this._density!=e&&(this._density=e)}get friction(){return this._friction}set friction(e){this._friction!=e&&(this._friction=e)}get restitution(){return this._restitution}set restitution(e){this._restitution!=e&&(this._restitution=e)}}var s,n,h,_,o,g;e.TileMapCellNeighbor=void 0,(s=e.TileMapCellNeighbor||(e.TileMapCellNeighbor={}))[s.RIGHT_SIDE=0]="RIGHT_SIDE",s[s.RIGHT_CORNER=1]="RIGHT_CORNER",s[s.BOTTOM_RIGHT_SIDE=2]="BOTTOM_RIGHT_SIDE",s[s.BOTTOM_RIGHT_CORNER=3]="BOTTOM_RIGHT_CORNER",s[s.BOTTOM_SIDE=4]="BOTTOM_SIDE",s[s.BOTTOM_CORNER=5]="BOTTOM_CORNER",s[s.BOTTOM_LEFT_SIDE=6]="BOTTOM_LEFT_SIDE",s[s.BOTTOM_LEFT_CORNER=7]="BOTTOM_LEFT_CORNER",s[s.LEFT_SIDE=8]="LEFT_SIDE",s[s.LEFT_CORNER=9]="LEFT_CORNER",s[s.TOP_LEFT_SIDE=10]="TOP_LEFT_SIDE",s[s.TOP_LEFT_CORNER=11]="TOP_LEFT_CORNER",s[s.TOP_SIDE=12]="TOP_SIDE",s[s.TOP_CORNER=13]="TOP_CORNER",s[s.TOP_RIGHT_SIDE=14]="TOP_RIGHT_SIDE",s[s.TOP_RIGHT_CORNER=15]="TOP_RIGHT_CORNER",s[s.MAX=16]="MAX",e.TileMapTerrainMode=void 0,(n=e.TileMapTerrainMode||(e.TileMapTerrainMode={}))[n.MATCH_CORNERS_AND_SIDES=0]="MATCH_CORNERS_AND_SIDES",n[n.MATCH_CORNERS=1]="MATCH_CORNERS",n[n.MATCH_SIDES=2]="MATCH_SIDES",e.TileShape=void 0,(h=e.TileShape||(e.TileShape={}))[h.TILE_SHAPE_SQUARE=0]="TILE_SHAPE_SQUARE",h[h.TILE_SHAPE_ISOMETRIC=1]="TILE_SHAPE_ISOMETRIC",h[h.TILE_SHAPE_HALF_OFFSET_SQUARE=2]="TILE_SHAPE_HALF_OFFSET_SQUARE",h[h.TILE_SHAPE_HEXAGON=3]="TILE_SHAPE_HEXAGON",e.TileLayerSortMode=void 0,(_=e.TileLayerSortMode||(e.TileLayerSortMode={}))[_.YSort=0]="YSort",_[_.ZINDEXSORT=1]="ZINDEXSORT",_[_.XSort=2]="XSort",e.TileMapDirtyFlag=void 0,(o=e.TileMapDirtyFlag||(e.TileMapDirtyFlag={}))[o.CELL_CHANGE=1]="CELL_CHANGE",o[o.CELL_COLOR=2]="CELL_COLOR",o[o.CELL_QUAD=4]="CELL_QUAD",o[o.CELL_QUADUV=8]="CELL_QUADUV",o[o.CELL_UVTRAN=16]="CELL_UVTRAN",o[o.CELL_PHYSICS=32]="CELL_PHYSICS",o[o.CELL_TERRAIN=64]="CELL_TERRAIN",o[o.CELL_LIGHTSHADOW=128]="CELL_LIGHTSHADOW",o[o.CELL_NAVIGATION=256]="CELL_NAVIGATION",o[o.CELL_SORTCHANGE=512]="CELL_SORTCHANGE",o[o.TILESET_SAZE=1024]="TILESET_SAZE",o[o.LAYER_COLOR=2048]="LAYER_COLOR",o[o.LAYER_PHYSICS=4096]="LAYER_PHYSICS",e.DirtyFlagType=void 0,(g=e.DirtyFlagType||(e.DirtyFlagType={}))[g.ALL=-1]="ALL",g[g.RENDER=0]="RENDER",g[g.PHYSICS=1]="PHYSICS",g[g.OCCLUSION=2]="OCCLUSION";class c{static initSquare(){let t=new Map,i=[e.TileMapCellNeighbor.RIGHT_SIDE,e.TileMapCellNeighbor.BOTTOM_RIGHT_CORNER,e.TileMapCellNeighbor.BOTTOM_SIDE,e.TileMapCellNeighbor.BOTTOM_LEFT_CORNER,e.TileMapCellNeighbor.LEFT_SIDE,e.TileMapCellNeighbor.TOP_LEFT_CORNER,e.TileMapCellNeighbor.TOP_SIDE,e.TileMapCellNeighbor.TOP_RIGHT_CORNER],a=i;t.set(e.TileMapTerrainMode.MATCH_CORNERS_AND_SIDES,i),i=[e.TileMapCellNeighbor.RIGHT_SIDE,e.TileMapCellNeighbor.BOTTOM_SIDE,e.TileMapCellNeighbor.LEFT_SIDE,e.TileMapCellNeighbor.TOP_SIDE],t.set(e.TileMapTerrainMode.MATCH_SIDES,i),i=[e.TileMapCellNeighbor.BOTTOM_RIGHT_CORNER,e.TileMapCellNeighbor.BOTTOM_LEFT_CORNER,e.TileMapCellNeighbor.TOP_LEFT_CORNER,e.TileMapCellNeighbor.TOP_RIGHT_CORNER],t.set(e.TileMapTerrainMode.MATCH_CORNERS,i),this.shape_mode_map.set(e.TileShape.TILE_SHAPE_SQUARE,{neighbors:t,getOverlap:c.getOverlap_Square,getNeighborGird:c.getNeighborGird_Square,getRuleInfo:c.getRuleInfo_Square,links:a})}static initIsometric(){let t=new Map,i=[e.TileMapCellNeighbor.RIGHT_CORNER,e.TileMapCellNeighbor.BOTTOM_RIGHT_SIDE,e.TileMapCellNeighbor.BOTTOM_CORNER,e.TileMapCellNeighbor.BOTTOM_LEFT_SIDE,e.TileMapCellNeighbor.LEFT_CORNER,e.TileMapCellNeighbor.TOP_LEFT_SIDE,e.TileMapCellNeighbor.TOP_CORNER,e.TileMapCellNeighbor.TOP_RIGHT_SIDE],a=i;t.set(e.TileMapTerrainMode.MATCH_CORNERS_AND_SIDES,i),i=[e.TileMapCellNeighbor.BOTTOM_RIGHT_SIDE,e.TileMapCellNeighbor.BOTTOM_LEFT_SIDE,e.TileMapCellNeighbor.TOP_LEFT_SIDE,e.TileMapCellNeighbor.TOP_RIGHT_SIDE],t.set(e.TileMapTerrainMode.MATCH_SIDES,i),i=[e.TileMapCellNeighbor.RIGHT_CORNER,e.TileMapCellNeighbor.BOTTOM_CORNER,e.TileMapCellNeighbor.LEFT_CORNER,e.TileMapCellNeighbor.TOP_CORNER],t.set(e.TileMapTerrainMode.MATCH_CORNERS,i),this.shape_mode_map.set(e.TileShape.TILE_SHAPE_ISOMETRIC,{neighbors:t,getNeighborGird:c.getNeighborGird_Isometric,getRuleInfo:c.getRuleInfo_Isometric,getOverlap:c.getOverlap_Isometric,links:a})}static initHalfOffset(){let t=new Map,i=[e.TileMapCellNeighbor.RIGHT_SIDE,e.TileMapCellNeighbor.BOTTOM_RIGHT_SIDE,e.TileMapCellNeighbor.BOTTOM_RIGHT_CORNER,e.TileMapCellNeighbor.BOTTOM_CORNER,e.TileMapCellNeighbor.BOTTOM_LEFT_SIDE,e.TileMapCellNeighbor.BOTTOM_LEFT_CORNER,e.TileMapCellNeighbor.LEFT_SIDE,e.TileMapCellNeighbor.TOP_LEFT_SIDE,e.TileMapCellNeighbor.TOP_LEFT_CORNER,e.TileMapCellNeighbor.TOP_CORNER,e.TileMapCellNeighbor.TOP_RIGHT_SIDE,e.TileMapCellNeighbor.TOP_RIGHT_CORNER];t.set(e.TileMapTerrainMode.MATCH_CORNERS_AND_SIDES,i),i=[e.TileMapCellNeighbor.RIGHT_SIDE,e.TileMapCellNeighbor.BOTTOM_RIGHT_SIDE,e.TileMapCellNeighbor.BOTTOM_LEFT_SIDE,e.TileMapCellNeighbor.LEFT_SIDE,e.TileMapCellNeighbor.TOP_LEFT_SIDE,e.TileMapCellNeighbor.TOP_RIGHT_SIDE],t.set(e.TileMapTerrainMode.MATCH_SIDES,i);let a=i;i=[e.TileMapCellNeighbor.BOTTOM_RIGHT_CORNER,e.TileMapCellNeighbor.BOTTOM_CORNER,e.TileMapCellNeighbor.BOTTOM_LEFT_CORNER,e.TileMapCellNeighbor.TOP_LEFT_CORNER,e.TileMapCellNeighbor.TOP_CORNER,e.TileMapCellNeighbor.TOP_RIGHT_CORNER],t.set(e.TileMapTerrainMode.MATCH_CORNERS,i),this.shape_mode_map.set(e.TileShape.TILE_SHAPE_HALF_OFFSET_SQUARE,{neighbors:t,getNeighborGird:c.getNeighborGird_HalfOffset,getRuleInfo:c.getRuleInfo_HalfOffset,getOverlap:c.getOverlap_HalfOffset,links:a}),this.shape_mode_map.set(e.TileShape.TILE_SHAPE_HEXAGON,{getNeighborGird:c.getNeighborGird_HalfOffset,getRuleInfo:c.getRuleInfo_HalfOffset,getOverlap:c.getOverlap_HalfOffset,neighbors:t,links:a})}static __init__(){this.initSquare(),this.initIsometric(),this.initHalfOffset()}static getNeighborObject(e){return c.shape_mode_map.get(e)}static getNeighborGird_Isometric(t,i,a,r){let l=!!(1&i);a==e.TileMapCellNeighbor.TOP_CORNER?(r.x=t,r.y=i-2):a==e.TileMapCellNeighbor.TOP_RIGHT_SIDE?(r.x=t+(l?1:0),r.y=i-1):a==e.TileMapCellNeighbor.RIGHT_CORNER?(r.x=t+1,r.y=i):a==e.TileMapCellNeighbor.BOTTOM_RIGHT_SIDE?(r.x=t+(l?1:0),r.y=i+1):a==e.TileMapCellNeighbor.BOTTOM_CORNER?(r.x=t,r.y=i+2):a==e.TileMapCellNeighbor.BOTTOM_LEFT_SIDE?(r.x=t-(l?0:1),r.y=i+1):a==e.TileMapCellNeighbor.LEFT_CORNER?(r.x=t-1,r.y=i):a==e.TileMapCellNeighbor.TOP_LEFT_SIDE&&(r.x=t-(l?0:1),r.y=i-1)}static getNeighborGird_Square(t,i,a,r){a==e.TileMapCellNeighbor.TOP_SIDE?(r.x=t,r.y=i-1):a==e.TileMapCellNeighbor.TOP_RIGHT_CORNER?(r.x=t+1,r.y=i-1):a==e.TileMapCellNeighbor.RIGHT_SIDE?(r.x=t+1,r.y=i):a==e.TileMapCellNeighbor.BOTTOM_RIGHT_CORNER?(r.x=t+1,r.y=i+1):a==e.TileMapCellNeighbor.BOTTOM_SIDE?(r.x=t,r.y=i+1):a==e.TileMapCellNeighbor.BOTTOM_LEFT_CORNER?(r.x=t-1,r.y=i+1):a==e.TileMapCellNeighbor.LEFT_SIDE?(r.x=t-1,r.y=i):a==e.TileMapCellNeighbor.TOP_LEFT_CORNER&&(r.x=t-1,r.y=i-1)}static getNeighborGird_HalfOffset(t,i,a,r){let l=!!(1&i);a==e.TileMapCellNeighbor.RIGHT_SIDE?(r.x=t+1,r.y=i):a==e.TileMapCellNeighbor.LEFT_SIDE?(r.x=t-1,r.y=i):a==e.TileMapCellNeighbor.TOP_RIGHT_SIDE?(r.x=t+(l?1:0),r.y=i-1):a==e.TileMapCellNeighbor.BOTTOM_RIGHT_SIDE?(r.x=t+(l?1:0),r.y=i+1):a==e.TileMapCellNeighbor.BOTTOM_LEFT_SIDE?(r.x=t-(l?0:1),r.y=i+1):a==e.TileMapCellNeighbor.TOP_LEFT_SIDE&&(r.x=t-(l?0:1),r.y=i-1)}static getRuleInfo_Square(t,i){i==e.TileMapCellNeighbor.TOP_SIDE?(t.data=3,c.getNeighborGird_Square(t.x,t.y,i,t)):i==e.TileMapCellNeighbor.TOP_RIGHT_CORNER?(t.data=2,c.getNeighborGird_Square(t.x,t.y,e.TileMapCellNeighbor.TOP_SIDE,t)):i==e.TileMapCellNeighbor.RIGHT_SIDE?t.data=1:i==e.TileMapCellNeighbor.BOTTOM_RIGHT_CORNER?t.data=2:i==e.TileMapCellNeighbor.BOTTOM_SIDE?t.data=3:i==e.TileMapCellNeighbor.BOTTOM_LEFT_CORNER?(t.data=2,c.getNeighborGird_Square(t.x,t.y,e.TileMapCellNeighbor.LEFT_SIDE,t)):i==e.TileMapCellNeighbor.LEFT_SIDE?(t.data=1,c.getNeighborGird_Square(t.x,t.y,i,t)):i==e.TileMapCellNeighbor.TOP_LEFT_CORNER&&(t.data=2,c.getNeighborGird_Square(t.x,t.y,e.TileMapCellNeighbor.TOP_LEFT_CORNER,t))}static getRuleInfo_Isometric(t,i){i==e.TileMapCellNeighbor.TOP_CORNER?(t.data=2,c.getNeighborGird_Isometric(t.x,t.y,i,t)):i==e.TileMapCellNeighbor.TOP_RIGHT_SIDE?(t.data=3,c.getNeighborGird_Isometric(t.x,t.y,i,t)):i==e.TileMapCellNeighbor.RIGHT_CORNER?(t.data=2,c.getNeighborGird_Isometric(t.x,t.y,e.TileMapCellNeighbor.TOP_RIGHT_SIDE,t)):i==e.TileMapCellNeighbor.BOTTOM_RIGHT_SIDE?t.data=1:i==e.TileMapCellNeighbor.BOTTOM_CORNER?t.data=2:i==e.TileMapCellNeighbor.BOTTOM_LEFT_SIDE?t.data=3:i==e.TileMapCellNeighbor.LEFT_CORNER?(t.data=2,c.getNeighborGird_Isometric(t.x,t.y,e.TileMapCellNeighbor.TOP_LEFT_SIDE,t)):i==e.TileMapCellNeighbor.TOP_LEFT_SIDE&&(t.data=1,c.getNeighborGird_Isometric(t.x,t.y,i,t))}static getRuleInfo_HalfOffset(t,i){i==e.TileMapCellNeighbor.RIGHT_SIDE?t.data=1:i==e.TileMapCellNeighbor.BOTTOM_RIGHT_CORNER?t.data=2:i==e.TileMapCellNeighbor.BOTTOM_RIGHT_SIDE?t.data=3:i==e.TileMapCellNeighbor.BOTTOM_CORNER?t.data=4:i==e.TileMapCellNeighbor.BOTTOM_LEFT_SIDE?t.data=5:i==e.TileMapCellNeighbor.BOTTOM_LEFT_CORNER?(t.data=2,c.getNeighborGird_HalfOffset(t.x,t.y,e.TileMapCellNeighbor.LEFT_SIDE,t)):i==e.TileMapCellNeighbor.LEFT_SIDE?(t.data=1,c.getNeighborGird_HalfOffset(t.x,t.y,i,t)):i==e.TileMapCellNeighbor.TOP_LEFT_CORNER?(t.data=4,c.getNeighborGird_HalfOffset(t.x,t.y,e.TileMapCellNeighbor.TOP_LEFT_SIDE,t)):i==e.TileMapCellNeighbor.TOP_LEFT_SIDE?(t.data=3,c.getNeighborGird_HalfOffset(t.x,t.y,i,t)):i==e.TileMapCellNeighbor.TOP_CORNER?(t.data=2,c.getNeighborGird_HalfOffset(t.x,t.y,e.TileMapCellNeighbor.TOP_LEFT_SIDE,t)):i==e.TileMapCellNeighbor.TOP_RIGHT_SIDE?(t.data=5,c.getNeighborGird_HalfOffset(t.x,t.y,i,t)):i==e.TileMapCellNeighbor.TOP_RIGHT_CORNER&&(t.data=4,c.getNeighborGird_HalfOffset(t.x,t.y,e.TileMapCellNeighbor.TOP_RIGHT_SIDE,t))}static getOverlap_Square(t,i,a,r,l){let s=c.temp_vec2;1==a?(l.set(r.get(t,i,!0),e.TileMapCellNeighbor.RIGHT_SIDE),c.getNeighborGird_Square(t,i,e.TileMapCellNeighbor.RIGHT_SIDE,s),l.set(r.get(s.x,s.y,!0),e.TileMapCellNeighbor.LEFT_SIDE)):2==a?(l.set(r.get(t,i,!0),e.TileMapCellNeighbor.BOTTOM_RIGHT_CORNER),c.getNeighborGird_Square(t,i,e.TileMapCellNeighbor.RIGHT_SIDE,s),l.set(r.get(s.x,s.y,!0),e.TileMapCellNeighbor.BOTTOM_LEFT_CORNER),c.getNeighborGird_Square(t,i,e.TileMapCellNeighbor.BOTTOM_RIGHT_CORNER,s),l.set(r.get(s.x,s.y,!0),e.TileMapCellNeighbor.TOP_LEFT_CORNER),c.getNeighborGird_Square(t,i,e.TileMapCellNeighbor.BOTTOM_SIDE,s),l.set(r.get(s.x,s.y,!0),e.TileMapCellNeighbor.TOP_RIGHT_CORNER)):(l.set(r.get(t,i,!0),e.TileMapCellNeighbor.BOTTOM_SIDE),c.getNeighborGird_Square(t,i,e.TileMapCellNeighbor.BOTTOM_SIDE,s),l.set(r.get(s.x,s.y,!0),e.TileMapCellNeighbor.TOP_SIDE))}static getOverlap_Isometric(t,i,a,r,l){let s=c.temp_vec2;1==a?(l.set(r.get(t,i,!0),e.TileMapCellNeighbor.BOTTOM_RIGHT_SIDE),c.getNeighborGird_Isometric(t,i,e.TileMapCellNeighbor.BOTTOM_RIGHT_SIDE,s),l.set(r.get(s.x,s.y,!0),e.TileMapCellNeighbor.TOP_LEFT_SIDE)):2==a?(l.set(r.get(t,i,!0),e.TileMapCellNeighbor.BOTTOM_CORNER),c.getNeighborGird_Isometric(t,i,e.TileMapCellNeighbor.BOTTOM_RIGHT_SIDE,s),l.set(r.get(s.x,s.y,!0),e.TileMapCellNeighbor.LEFT_CORNER),c.getNeighborGird_Isometric(t,i,e.TileMapCellNeighbor.BOTTOM_CORNER,s),l.set(r.get(s.x,s.y,!0),e.TileMapCellNeighbor.TOP_CORNER),c.getNeighborGird_Isometric(t,i,e.TileMapCellNeighbor.BOTTOM_LEFT_SIDE,s),l.set(r.get(s.x,s.y,!0),e.TileMapCellNeighbor.RIGHT_CORNER)):(l.set(r.get(t,i,!0),e.TileMapCellNeighbor.BOTTOM_LEFT_SIDE),c.getNeighborGird_Isometric(t,i,e.TileMapCellNeighbor.BOTTOM_LEFT_SIDE,s),l.set(r.get(s.x,s.y,!0),e.TileMapCellNeighbor.TOP_RIGHT_SIDE))}static getOverlap_HalfOffset(t,i,a,r,l){let s=c.temp_vec2;1==a?(l.set(r.get(t,i,!0),e.TileMapCellNeighbor.RIGHT_SIDE),c.getNeighborGird_HalfOffset(t,i,e.TileMapCellNeighbor.RIGHT_SIDE,s),l.set(r.get(s.x,s.y,!0),e.TileMapCellNeighbor.LEFT_SIDE)):2==a?(l.set(r.get(t,i,!0),e.TileMapCellNeighbor.BOTTOM_RIGHT_CORNER),c.getNeighborGird_HalfOffset(t,i,e.TileMapCellNeighbor.RIGHT_SIDE,s),l.set(r.get(s.x,s.y,!0),e.TileMapCellNeighbor.BOTTOM_LEFT_CORNER),c.getNeighborGird_HalfOffset(t,i,e.TileMapCellNeighbor.BOTTOM_RIGHT_SIDE,s),l.set(r.get(s.x,s.y,!0),e.TileMapCellNeighbor.TOP_CORNER)):3==a?(l.set(r.get(t,i,!0),e.TileMapCellNeighbor.BOTTOM_RIGHT_SIDE),c.getNeighborGird_HalfOffset(t,i,e.TileMapCellNeighbor.BOTTOM_RIGHT_SIDE,s),l.set(r.get(s.x,s.y,!0),e.TileMapCellNeighbor.TOP_LEFT_SIDE)):4==a?(l.set(r.get(t,i,!0),e.TileMapCellNeighbor.BOTTOM_CORNER),c.getNeighborGird_HalfOffset(t,i,e.TileMapCellNeighbor.BOTTOM_RIGHT_SIDE,s),l.set(r.get(s.x,s.y,!0),e.TileMapCellNeighbor.TOP_LEFT_CORNER),c.getNeighborGird_HalfOffset(t,i,e.TileMapCellNeighbor.BOTTOM_LEFT_SIDE,s),l.set(r.get(s.x,s.y,!0),e.TileMapCellNeighbor.TOP_RIGHT_CORNER)):(l.set(r.get(t,i,!0),e.TileMapCellNeighbor.BOTTOM_LEFT_SIDE),c.getNeighborGird_HalfOffset(t,i,e.TileMapCellNeighbor.BOTTOM_LEFT_SIDE,s),l.set(r.get(s.x,s.y,!0),e.TileMapCellNeighbor.TOP_RIGHT_SIDE))}static getChunkCellInfo(e,t){-1==t.index&&(e._chunk._getChunkPosByCell(t.x,t.y,c.temp_vec3),t.chunkX=c.temp_vec3.x,t.chunkY=c.temp_vec3.y,t.index=c.temp_vec3.z);let i=e.chunkDatas[t.chunkY];if(i){let e=i[t.chunkX];if(e)return e.getCell(t.index)}return null}}c.shape_mode_map=new Map,c.temp_vec2=new t.Vector2,c.temp_vec3=new t.Vector3;class d{constructor(e,t,i,a){this.data=-1,this.x=0,this.y=0,this.terrain=-1,this.priority=1,this.x=e,this.y=t,this.terrain=i,this.neighborObject=a}setCellNeighbor(e){this.neighborObject.getRuleInfo(this,e)}clone(){let e=new d(this.x,this.y,this.terrain,this.neighborObject);return e.data=this.data,e.priority=this.priority,e}}class u{constructor(){this.list=[]}}class T extends u{constructor(){super(...arguments),this.map=[]}add(e){let t=this.map[e.y];t||(t=this.map[e.y]=[]);let i=t[e.x];return i||(i=t[e.x]=[]),i[e.data]?i[e.data]:(i[e.data]=e,this.list.push(e),e)}get(e,t,i){return this.map[t]&&this.map[t][e]?this.map[t][e][i]:null}delete(e,t,i){let a=this.map[t]&&this.map[t][e]?this.map[t][e][i]:null;return a&&(delete this.map[t][e][i],this.list.splice(this.list.indexOf(a),1)),a}}class p extends u{constructor(){super(...arguments),this.map=[],this.list=[]}add(e){let t=this.map[e.y];t||(t=this.map[e.y]=[]);let i=t[e.x];return i||(t[e.x]=e,this.list.push(e),e)}get(e,t,i=!1){let a=this.map[t]?this.map[t][e]:null;return!a&&i&&(a={x:e,y:t,index:-1},this.add(a)),a}delete(e,t){let i=this.map[t]?this.map[t][e]:null;return i&&(delete this.map[t][e],this.list.splice(this.list.indexOf(i),1)),i}}class y{constructor(){this._terrainBatchMode=e.TileMapTerrainMode.MATCH_CORNERS_AND_SIDES}set terrainPatchMode(e){this._terrainBatchMode=e}get terrainPatchMode(){return this._terrainBatchMode}updateShape(e){let t=c.getNeighborObject(e);this._neighbors=t.neighbors.get(this._terrainBatchMode)}getTerrain(e){for(let t=0,i=this._terrains.length;t<i;t++)if(e==this._terrains[t].id)return this._terrains[t];return null}get terrains(){return this._terrains}set terrains(e){this._terrains=e}}class f{}class C{static getRotateCount(e){return 7&e}static getFlipH(e){return!!(8&e)}static getFlipV(e){return!!(16&e)}static getTranspose(e){return!!(32&e)}static parseCellIndex(e){return(-16777216&e)>>24}static parseGroupId(e){return(16711680&e)>>16}static parseNativeIndex(e){return 65535&e}static getNativeId(e,t){return(e<<16)+t}static getGid(e,t){return(e<<24)+t}static quickFoundIndex(e,t){let i=0,a=0,r=e.length-1;if(t<e[a]||t>=e[r])return-1;for(;a+1<r;){if(i=Math.floor((a+r)/2),e[i]==t)return i;e[i]>t?r=i:a=i}return a}static getRotateAngle(t,i){let a=i==e.TileShape.TILE_SHAPE_HEXAGON?6:4;return(t=Math.floor(t)%a)<0&&(t+=a),2*Math.PI*t/a}static getTransFlag(e,t,i,a){return e|(t?1:0)<<3|(i?1:0)<<4|(a?1:0)<<5}static parseTransFlag(e,i,a){let r=a.transFlag,l=i+"_"+r+"_"+e,s=this.CACHE_UVs.get(l);if(s)return s;let n=-8&i^-8&r,h=(this.getRotateCount(i)+a.rotateCount)%4,_=this.getFlipH(n),o=this.getFlipV(n),g=this.getTranspose(n);return s=new t.Vector4,this.getUvRotate(e,_,o,g,h,s),this.CACHE_UVs.set(l,s),s}static getUvRotate(e,i=!1,a=!1,r=!1,l=0,s=t.Vector4.TEMP){let n=1,h=r?-1:1;const _=.5*(n+h),o=.5*(n-h);n=i?-1:1,h=a?-1:1;let g=-this.getRotateAngle(l,e);const c=Math.cos(g),d=Math.sin(g);return s.x=c*n*_-d*n*o,s.y=c*h*o-d*h*_,s.z=d*n*_+c*n*o,s.w=d*h*o+c*h*_,s}static transfromPointByValue(e,t,i,a){a.x=e.a*t+e.c*i+e.tx,a.y=e.b*t+e.d*i+e.ty}static transfromPointNByValue(e,t,i,a){a.x=e.a*t+e.c*i,a.y=e.b*t+e.d*i}static getCellDataIndex(e){let t=Object.keys(e._tileDatas).map(Number);t.sort((e,t)=>e-t);for(let e=0;e<t.length;e++)if(t[e]!==e)return e;return t.length>0?t[t.length-1]+1:0}static tiledTLayer(e,i,a=new t.Vector2){const r=e+i,l=e-i-(1&r)>>1;return a.x=l,a.y=r,a}static layerToTiled(e,i,a=new t.Vector2){const r=(e=Math.floor(e))+((i=Math.floor(i))+(1&i)>>1),l=i-r;return a.x=r,a.y=l,a}static compareYSort(e,t){return e.sortY!==t.sortY?e.sortY-t.sortY:e.zOrderValue!==t.zOrderValue?e.zOrderValue-t.zOrderValue:e.cellx!==t.cellx?e.cellx-t.cellx:e.chuckLocalindex-t.chuckLocalindex}static compareZSort(e,t){return e.zOrderValue!==t.zOrderValue?e.zOrderValue-t.zOrderValue:e.sortY!==t.sortY?e.sortY-t.sortY:e.cellx!==t.cellx?e.cellx-t.cellx:e.chuckLocalindex-t.chuckLocalindex}static compareXSort(e,t){return e.cellx!==t.cellx?e.cellx-t.cellx:e.sortY!==t.sortY?e.sortY-t.sortY:e.zOrderValue!==t.zOrderValue?e.zOrderValue-t.zOrderValue:e.chuckLocalindex-t.chuckLocalindex}}C.CACHE_UVs=new Map;class E{constructor(){this.terrain=-1,this.terrain_peering_bits=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1],this.links=new Set,this._modified=!1}link(e){this.links.add(e),this._modified=!0}get arr(){return this._modified&&(this._arr=Array.from(this.links)),this._arr}_getDebugs(){this._debugs=[];for(let t=0,i=this.terrain_peering_bits.length;t<i;t++)this.terrain_peering_bits[t]>-1&&this._debugs.push(e.TileMapCellNeighbor[t])}clearLinks(){this.links.clear()}}class M{}class D{}class S{}class x{get index(){return this._index}get transFlag(){return this._transChange&&(this._transFlag=C.getTransFlag(this.rotateCount,this._flip_h,this._flip_v,this._transpose),this._transChange=!1),this._transFlag}get cellowner(){return this._cellowner}set cellowner(e){this._cellowner=e}get flip_h(){return this._flip_h}set flip_h(t){this._flip_h=t,this._transChange=!0,this._notifyDataChange(e.TileMapDirtyFlag.CELL_UVTRAN,e.DirtyFlagType.RENDER)}get flip_v(){return this._flip_v}set flip_v(t){this._flip_v=t,this._transChange=!0,this._notifyDataChange(e.TileMapDirtyFlag.CELL_UVTRAN,e.DirtyFlagType.RENDER)}get transpose(){return this._transpose}set transpose(t){this._transpose=t,this._transChange=!0,this._notifyDataChange(e.TileMapDirtyFlag.CELL_UVTRAN,e.DirtyFlagType.RENDER)}get rotateCount(){return this._rotateCount}set rotateCount(t){this._rotateCount=t,this._transChange=!0,this._notifyDataChange(e.TileMapDirtyFlag.CELL_UVTRAN,e.DirtyFlagType.RENDER)}get texture_origin(){return this._texture_origin}set texture_origin(t){t.cloneTo(this._texture_origin),this._notifyDataChange(e.TileMapDirtyFlag.CELL_QUAD,e.DirtyFlagType.RENDER)}get material(){return this._material}set material(t){this._material=t,this._notifyDataChange(e.TileMapDirtyFlag.CELL_CHANGE,e.DirtyFlagType.RENDER)}get colorModulate(){return this._colorModulate}set colorModulate(t){this._colorModulate=t,this._notifyDataChange(e.TileMapDirtyFlag.CELL_COLOR,e.DirtyFlagType.RENDER)}get probability(){return this._probability}set probability(e){this._probability=e}get z_index(){return this._z_index}set z_index(e){this._z_index!=e&&(this._z_index=e,this._refreshCellSort())}get y_sort_origin(){return this._y_sort_origin}set y_sort_origin(e){this._y_sort_origin!=e&&(this._y_sort_origin=e,this._refreshCellSort())}get terrainSet(){return this._terrainSet}set terrainSet(e){this._terrainSet=e}get terrain(){return this._terrain}set terrain(e){this._terrain=e}get physicsDatas(){return this._physicsDatas}set physicsDatas(t){this._physicsDatas=t,this._notifyDataChange(e.TileMapDirtyFlag.CELL_PHYSICS,e.DirtyFlagType.PHYSICS)}get lightOccluderDatas(){return this._lightOccluderDatas}set lightOccluderDatas(e){this._lightOccluderDatas=e}get customDatas(){return this._customDatas}set customDatas(e){this._customDatas=e}get navigationDatas(){return this._navigationDatas}set navigationDatas(e){this._navigationDatas=e}constructor(){this._index=0,this._flip_h=!1,this._flip_v=!1,this._transpose=!1,this._rotateCount=0,this._transChange=!1,this._transFlag=0,this._terrainSet=-1,this._terrain=-1,this._terrain_peering_bits=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1],this._probability=1,this._destroyed=!1,this.gid=-1,this._notiveRenderTile=[],this._flip_h=!1,this._flip_v=!1,this._transpose=!1,this._rotateCount=0,this._texture_origin=new t.Vector2(0,0),this._colorModulate=new t.Color(1,1,1,1),this._z_index=0,this._y_sort_origin=0}__init(e,t){this._index=t,this._cellowner=e,this.gid=C.getGid(this._index,this._cellowner.nativeId)}_notifyDataChange(e,t){this.cellowner&&this._notiveRenderTile.forEach(i=>{i._setDirtyFlag(this.gid,e,t)})}_noticeRenderChange(){this.cellowner&&this._notiveRenderTile.forEach(e=>{e._modifyData()})}_refreshCellSort(){this.cellowner&&this._notiveRenderTile.forEach(e=>{e._refreshCellSort(this)})}_removeNoticeRenderTile(e){let t=this._notiveRenderTile.indexOf(e);-1!=t&&this._notiveRenderTile.splice(t,1)}_addNoticeRenderTile(e){-1==this._notiveRenderTile.indexOf(e)&&this._notiveRenderTile.push(e)}set_lightOccluder(e,t){this._lightOccluderDatas[e]=t}get_lightOccluder(e){return this._lightOccluderDatas[e]}set_terrainPeeringBit(e,t){this._terrain_peering_bits[e]=t,this._cellowner.owner._owner._terrainsDirty=!0}get_terrainPeeringBit(e){return this._terrain_peering_bits[e]}set_physicsData(e,t){this._physicsDatas[e]=t}get_physicsData(e){return this._physicsDatas[e]}getTerrainsParams(){let e=new E;return e.terrainSet=this.terrainSet,e.terrain=this.terrain,e.terrain_peering_bits=this._terrain_peering_bits.slice(0,16),e}_getTerrainPeeringBits(){return this._terrain_peering_bits}set_navigationData(e,t){this._navigationDatas[e]=t}get_navigationData(e){return this._navigationDatas[e]}set_customData(e,t){let i=this._cellowner._owner._owner.getCustomDataLayer(e);i&&(this._customDatas[i.id]=t)}get_customData(e){let t=this._cellowner._owner._owner.getCustomDataLayer(e);return t?this._customDatas[t.id]:null}set_customDataById(e,t){this._customDatas[e]=t}get_customDataById(e){return this._customDatas[e]}cloneTo(e){e._material=this._material,e._cellowner=this._cellowner,e._z_index=this._z_index,e._y_sort_origin=this._y_sort_origin}destroy(){this._notiveRenderTile.slice().forEach(e=>{e._clearOneCell(this)}),this._destroyed=!0}}var L;x._EMPTY=new x,e.TileAnimationMode=void 0,(L=e.TileAnimationMode||(e.TileAnimationMode={}))[L.DEFAULT=0]="DEFAULT",L[L.RANDOM_START_TIMES=1]="RANDOM_START_TIMES";class O{get localPos(){return this._localPos}set localPos(e){this._localPos=e}get sizeByAtlas(){return this._sizeByAtlas}set sizeByAtlas(e){this._sizeByAtlas.setValue(e.x,e.y),this._init()}get owner(){return this._owner}set owner(e){e!==this._owner&&(this._owner=e,this._init())}get tileDatas(){return this._tileDatas}set tileDatas(e){if(this._owner&&e)for(let t in e)e[t].__init(this,parseInt(t));this._tileDatas=e}get animation_columns(){return this._animation_columns}set animation_columns(e){this._animation_columns=e}get animation_separation(){return this._animation_separation}set animation_separation(e){this._animation_separation=e}get animation_speed(){return this._animation_speed}set animation_speed(e){this._animation_speed=e}get animationMode(){return this._animationNode}set animationMode(e){this._animationNode=e}set animationFrams(e){e||(e=[]);let t=this._animationFrams.length,i=e.length;this._animationFrams=e,this._animationFramsTime=[],this._animationFramsTime.length=e.length,this._totalAnimatorTime=0;for(var a=0;a<e.length;a++)this._animationFramsTime[a]=this._totalAnimatorTime,this._totalAnimatorTime+=e[a];if(t!=i&&(t>1||i>1))for(let e in this._tileDatas)this._tileDatas[e]._noticeRenderChange()}get animationFrams(){return this._animationFrams}constructor(){this._animation_columns=0,this._animation_separation=new t.Vector2,this._animation_speed=1,this._animationFrams=[],this._frameIndex=0,this._animatorUpdateMask=0,this._localPos=new t.Vector2,this._sizeByAtlas=new t.Vector2,this._uvOri=new t.Vector2,this._uvExtends=new t.Vector2,this._regionSize=new t.Vector2,this._tileDatas={},this._sizeByAtlas.setValue(1,1)}_initialIndexFIrstCellData(){const e=new x;e.__init(this,0),this._tileDatas[0]=e}_hasAni(){return this._animationFrams.length>1}_init(){if(!this._owner)return;this._owner._getTileUVExtends(this._sizeByAtlas,this._regionSize);let t=this._owner.atlasSize;if(this._uvExtends.x=Math.max(this._regionSize.x-1,0)/t.x,this._uvExtends.y=Math.max(this._regionSize.y-1,0)/t.y,this._updateOriginUV(0,0,e.TileMapDirtyFlag.CELL_QUAD|e.TileMapDirtyFlag.CELL_QUADUV),this.nativeId=this._owner._getGlobalAlternativesId(this._localPos.x,this._localPos.y),this._tileDatas)for(let e in this._tileDatas)this._tileDatas[e].__init(this,parseInt(e))}_updateOriginUV(t,i,a){this._uvOri.setValue(this._localPos.x+t,this._localPos.y+i),this._owner._getTilePixelOrgin(this._uvOri,this._uvOri);let r=this._owner.atlasSize;this._uvOri.x=(this._uvOri.x+.5*this._regionSize.x)/r.x,this._uvOri.y=(this._uvOri.y+.5*this._regionSize.y)/r.y;for(let t in this._tileDatas)this._tileDatas[t]._notifyDataChange(a,e.DirtyFlagType.RENDER)}_getTextureUVOri(){return this._uvOri}_getTextureUVExtends(){return this._uvExtends}_getRegionSize(){return this._regionSize}_updateAnimator(){if(this._animationFrams.length<=1||t.Laya.timer.currFrame==this._animatorUpdateMask)return;this._animatorUpdateMask=t.Laya.timer.currFrame;let i=this._frameIndex,a=t.Laya.timer.totalTime/1e3*this._animation_speed%this._totalAnimatorTime;a<this._animationFramsTime[this._frameIndex]&&(this._frameIndex=0);let r,l;for(var s=this._frameIndex,n=this._animationFrams.length;s<n;s++)a>=this._animationFramsTime[s]&&(this._frameIndex=s);this._frameIndex+=0,i!=this._frameIndex&&(0!=this._animation_columns?(r=this._frameIndex%this._animation_columns,l=Math.floor(this._frameIndex/this._animation_columns)):(r=this._frameIndex,l=0),this._updateOriginUV(r*(this._sizeByAtlas.x+this._animation_separation.x),l*(this._sizeByAtlas.y+this._animation_separation.y),e.TileMapDirtyFlag.CELL_QUADUV))}getCelldata(e){return this._tileDatas[e]}removeCellData(e){let t=this._tileDatas[e];t&&(t.destroy(),delete this._tileDatas[e])}addCellData(e){let t=this._tileDatas[e];return t||(t=new x,t.__init(this,e),this._tileDatas[e]=t,t)}destroy(){}}class m{static __init__(){let e={a_position:[0,t.ShaderDataType.Vector2],a_texcoord:[1,t.ShaderDataType.Vector2],a_color:[2,t.ShaderDataType.Vector4],a_cellColor:[3,t.ShaderDataType.Vector4],a_cellPosScale:[4,t.ShaderDataType.Vector4],a_cellUVOriScale:[5,t.ShaderDataType.Vector4],a_celluvTrans:[6,t.ShaderDataType.Vector4]};t.Shader3D.addInclude("TileMapCommon.glsl","varying vec2 v_pos;"),t.Shader3D.addInclude("TileMapVertex.glsl",'\n#include "Sprite2DVertex.glsl";\n#include "TileMapCommon.glsl";\nvec2 getVertexPos(){float x=a_cellPosScale.x+a_position.x*a_cellPosScale.z;float y=a_cellPosScale.y+a_position.y*a_cellPosScale.w;return vec2(x,y);}vec2 getVertexUv(){float u=a_cellUVOriScale.z*dot(a_texcoord,a_celluvTrans.xy)+a_cellUVOriScale.x;float v=a_cellUVOriScale.w*dot(a_texcoord,a_celluvTrans.zw)+a_cellUVOriScale.y;return vec2(u,v);}vec4 getVertexColor(){return a_color*a_cellColor;}void getVertexInfoTileMap(inout vertexInfo info){info.pos=getVertexPos();info.color=getVertexColor();info.uv=getVertexUv();\n#ifdef LIGHT2D_ENABLE\nvec2 global;getGlobalPos(info.pos,global);info.lightUV.x=(global.x-u_LightAndShadow2DParam.x)/u_LightAndShadow2DParam.z;info.lightUV.y=1.0-(global.y-u_LightAndShadow2DParam.y)/u_LightAndShadow2DParam.w;\n#endif\n}void setVertexInfo(in vertexInfo info){v_texcoord=info.uv;v_color=info.color;v_pos=info.pos;}'),t.Shader3D.addInclude("TileMapFragment.glsl",'#include "TileMapCommon.glsl"\n#include "Sprite2DFrag.glsl";\nvec4 getTextureColor(in vec2 uv){return texture2D(u_render2DTexture,uv);}');let i={u_render2DTexture:t.ShaderDataType.Texture2D,u_TileSize:t.ShaderDataType.Vector2},a=t.Shader3D.add("TileMapLayer",!1,!1);a.shaderType=t.ShaderFeatureType.D2_BaseRenderNode2D;let r=new t.SubShader(e,i,{});a.addSubShader(r),r.addShaderPass('#define SHADER_NAME TileMap2DVS\n#include "TileMapVertex.glsl"\nvoid main(){vertexInfo info;getVertexInfoTileMap(info);vec4 wordpos=getPosition(info.pos);setVertexInfo(info);\n#ifdef LIGHT2D_ENABLE\nlightAndShadow(info);\n#endif\ngl_Position=wordpos;}','#define SHADER_NAME TileMap2DFS\n#include "TileMapFragment.glsl"\nvoid main(){clip();vec4 textureColor=getTextureColor(v_texcoord);textureColor=transspaceColor(textureColor);vec4 transV=v_color;\n#ifndef GAMMASPACE\ntransV=gammaToLinear(v_color);\n#endif\nvec4 finalColor=textureColor*transV;\n#ifdef LIGHT2D_ENABLE\nlightAndShadow(finalColor);\n#endif\ngl_FragColor=finalColor;}'),m._tileMapPositionUVColorDec=new t.VertexDeclaration(32,[new t.VertexElement(0,t.VertexElementFormat.Vector2,0),new t.VertexElement(8,t.VertexElementFormat.Vector2,1),new t.VertexElement(16,t.VertexElementFormat.Vector4,2)]),m._tileMapCellColorInstanceDec=new t.VertexDeclaration(16,[new t.VertexElement(0,t.VertexElementFormat.Vector4,3)]),m._tileMapCellPosScaleDec=new t.VertexDeclaration(16,[new t.VertexElement(0,t.VertexElementFormat.Vector4,4)]),m._tileMapCellUVOriScaleDec=new t.VertexDeclaration(16,[new t.VertexElement(0,t.VertexElementFormat.Vector4,5)]),m._tileMapCellUVTrans=new t.VertexDeclaration(16,[new t.VertexElement(0,t.VertexElementFormat.Vector4,6)])}}class R{constructor(){this._transFlag=0,this.updateTransFlag=!0}}class I{constructor(){this._reCreateRenderData=!0,this._refGids=[],this._dirtyFlags=[],this._transFlags={},this._cellDataMap={},this._chuckCellList=[],this._animatorAlterArray=new Map,this._needUpdateRange=!0,this._cellDataRefMap=[],this._tileSize=new t.Vector2,this._oriCellIndex=new t.Vector2(0,0),this._renderElementArray=[],this._sortMode=e.TileLayerSortMode.ZINDEXSORT;for(let e=0;e<3;e++)this._dirtyFlags[e]=new Map}get cellDataRefMap(){return this._cellDataRefMap}set cellDataRefMap(e){if(e&&Object.keys(e).length){for(let t=0,i=e.length;t<i;t++)e[t]?this._refGids.push(t):delete e[t];this._cellDataRefMap=e,this._modifyData()}}get compressData(){let e={};return this._refGids.forEach(t=>{this._cellDataRefMap[t]&&(e[t]=this._cellDataRefMap[t])}),e}set compressData(e){if(!e||!Object.keys(e).length)return;let t=[];for(const i in e){let a=parseInt(i);t[a]=e[i],this._refGids.push(a)}this._cellDataRefMap=t,this._modifyData()}get transFlags(){return this._transFlags={},this._chuckCellList.forEach(e=>{this._transFlags[e.chuckLocalindex]=e._transFlag}),this._transFlags}set transFlags(e){this._transFlags=e||{}}_parseCellDataRefMap(){if(this._chuckCellList.length)return;let i=this._tileLayer.tileSet;if(!i)return;let a=this._tileLayer._chunk,r=t.Vector2.TEMP;for(let t=this._refGids.length-1;t>-1;t--){let l=this._refGids[t],s=this._cellDataRefMap[l];if(s){let n=i.getCellDataByGid(l);if(n){n._addNoticeRenderTile(this);for(let e=0,t=s.length;e<t;e++){let t=s[e];a._getCellPosByChunkPosAndIndex(0,0,t,r);let i=new R;i.chuckLocalindex=t,i.zOrderValue=n.z_index,i.cellx=r.x,i.celly=r.y,i.cell=n,i._transFlag=this._transFlags[t]||0,i.sortY=r.y+n.y_sort_origin,this._cellDataMap[t]=i,this._chuckCellList.push(i)}this._setDirtyFlag(l,e.TileMapDirtyFlag.CELL_CHANGE)}else delete this._cellDataRefMap[l],this._refGids.splice(t,1)}}this._modifyData()}_mergeBuffer(e,i,a){const r=t.Vector2.TEMP;let l=this._chuckCellList;for(let t=0,s=l.length;t<s;t++){let s=l[t];this._tileLayer._chunk._getCellPosByChunkPosAndIndex(0,0,s.chuckLocalindex,r);let n=r.x+this._oriCellIndex.x,h=r.y+this._oriCellIndex.y;i.x=Math.min(i.x,n),i.y=Math.min(i.y,h),a.x=Math.max(a.x,n),a.y=Math.max(a.y,h);let _=e.get(h);_||(_=new Map,e.set(h,_)),_.set(n,{cell:s.cell,transFlag:s._transFlag})}}_setBuffer(e,t,i,a){this._clearCell();const r=this._tileLayer._chunk;let l=this._oriCellIndex.x,s=this._oriCellIndex.y,n=Math.max(t.x,l),h=Math.max(t.y,s),_=Math.min(i.x,l+a-1),o=Math.min(i.y,s+a-1),g=0;for(var c=h;c<=o;c++){let t=e.get(c);if(t)for(var d=n;d<=_;d++){let e=t.get(d);if(e){const t=r._getChunkIndexByCellPos(d-l,c-s);this._setCell(t,e.cell,e.transFlag),g++}}}return this._modifyData(),g}_updateChunkData(e,t){this.chunkX=e,this.chunkY=t,this._tileLayer._chunk._getCellPosByChunkPosAndIndex(e,t,0,this._oriCellIndex);let i=this._tileLayer.tileSet;i&&(i.tileSize.cloneTo(this._tileSize),this._gridShape=i.tileShape)}_upeateGridData(){this._animatorAlterArray.size>0&&this._animatorAlterArray.forEach((e,t)=>{e._updateAnimator()}),this._sortMode!=this._tileLayer.sortMode&&(this._sortMode=this._tileLayer.sortMode,this._modifyData());let i=this._tileLayer.tileSet,a=i.tileShape;this._gridShape!=a&&(this._gridShape=a,this._refGids.forEach(t=>{this._setDirtyFlag(t,e.TileMapDirtyFlag.CELL_QUAD,e.DirtyFlagType.RENDER)}),this._modifyData()),t.Vector2.equals(this._tileSize,i.tileSize)||(i.tileSize.cloneTo(this._tileSize),this._refGids.forEach(t=>{this._setDirtyFlag(t,e.TileMapDirtyFlag.CELL_QUAD|e.TileMapDirtyFlag.CELL_QUADUV,e.DirtyFlagType.RENDER)}))}_updateRenderData(){if(this._reCreateRenderData){if(this._reCreateRenderData=!1,this._clearRenderElement(),0==this._chuckCellList.length)return;let t,a;switch(this._sortMode){case e.TileLayerSortMode.YSort:t=C.compareYSort;break;case e.TileLayerSortMode.ZINDEXSORT:t=C.compareZSort;break;case e.TileLayerSortMode.XSort:t=C.compareXSort;break;default:t=C.compareZSort}this._chuckCellList.sort(t);let r=[];this._animatorAlterArray.clear();for(var i=0;i<this._chuckCellList.length;i++){let e=this._chuckCellList[i],t=e.cell;t&&(t.cellowner._hasAni()&&this._animatorAlterArray.set(t.cellowner.nativeId,t.cellowner),a?(this._breakBatch(a,t)&&(a=t,this._createRenderElement(r)),r.push(e)):(a=t,r.push(e)))}this._createRenderElement(r)}else{let i=this._dirtyFlags[e.DirtyFlagType.RENDER];if(i.size>0){let a=t.Vector2.TEMP;i.forEach((t,i)=>{let r=this._cellDataRefMap[i];r&&r.forEach(i=>{let r=this._cellDataMap[i],l=r.cell,s=l.cellowner,n=this._renderElementArray[r._renderElementIndex];if(t&e.TileMapDirtyFlag.CELL_CHANGE||t&e.TileMapDirtyFlag.CELL_QUAD){let e=n.cacheData[I.instanceposScalBufferIndex];n.updateFlag[I.instanceposScalBufferIndex]=!0,this._getCellPos(r,a);let t=l.texture_origin,i=4*r._cellPosInRenderData;e[i]=a.x+t.x,e[i+1]=a.y+t.y;let h=s._getRegionSize();e[i+2]=h.x,e[i+3]=h.y}if(t&e.TileMapDirtyFlag.CELL_CHANGE||t&e.TileMapDirtyFlag.CELL_QUADUV){let e=n.cacheData[I.instanceuvOriScalBufferIndex];n.updateFlag[I.instanceuvOriScalBufferIndex]=!0;let t=4*r._cellPosInRenderData,i=s._getTextureUVOri(),a=s._getTextureUVExtends();e[t]=i.x,e[t+1]=i.y,e[t+2]=a.x,e[t+3]=a.y}if(t&e.TileMapDirtyFlag.CELL_CHANGE||t&e.TileMapDirtyFlag.CELL_COLOR){let e=n.cacheData[I.instanceColorBufferIndex];n.updateFlag[I.instanceColorBufferIndex]=!0;let t=4*r._cellPosInRenderData,i=l.colorModulate;e[t]=i.r,e[t+1]=i.g,e[t+2]=i.b,e[t+3]=i.a}if(r.updateTransFlag||t&e.TileMapDirtyFlag.CELL_UVTRAN||t&e.TileMapDirtyFlag.CELL_CHANGE){r.updateTransFlag=!1;let e=n.cacheData[I.instanceuvTransBufferIndex];n.updateFlag[I.instanceuvTransBufferIndex]=!0;let t=4*r._cellPosInRenderData,i=C.parseTransFlag(this._gridShape,r._transFlag,l);e[t]=i.x,e[t+1]=i.y,e[t+2]=i.z,e[t+3]=i.w}})}),this._renderElementArray.forEach(e=>{for(var t=0;t<4;t++)if(e.updateFlag[t]){let i=e.cacheData[t];e.renderElement.geometry.bufferState._vertexBuffers[t+1].setData(i.buffer,0,0,i.byteLength),e.updateFlag[t]=!1}}),i.clear()}}}_updatePhysicsData(){if(!this._tileLayer.tileMapPhysics.enable||!this._tileLayer.owner.scene||!this._dirtyFlags[e.DirtyFlagType.PHYSICS].size)return;let i=this._tileLayer.tileSet.physicsLayers;if(!i||!i.length)return;let a=this._tileLayer.tileMapPhysics,r=this._dirtyFlags[e.DirtyFlagType.PHYSICS],l=this._rigidBody;l||(l=a.createRigidBody());let s=i.length,n=this._tileLayer._chunk,h=t.Vector2.TEMP,_=this._tileLayer.owner.scaleX,o=this._tileLayer.owner.scaleY;r.forEach((t,r)=>{let g=this._cellDataRefMap[r];g&&g.forEach(r=>{let g=this._cellDataMap[r],c=g.cell.physicsDatas;if(c&&t&e.TileMapDirtyFlag.CELL_CHANGE||t&e.TileMapDirtyFlag.CELL_PHYSICS){n._getPixelByChunkPosAndIndex(this.chunkX,this.chunkY,g.chuckLocalindex,h);let e=h.x,t=h.y,r=g._physicsDatas;r||(r=[],g._physicsDatas=r);for(let n=0;n<s;n++){let s=i[n],h=s.id;if(!c[h])continue;let g=r[h];g&&a.destroyFixture(l,g);let d=c[h].shape;if(!d)continue;let u=d.length,T=new Array(u);for(let i=0;i<u;i+=2)T[i]=(d[i]+e)*_,T[i+1]=(d[i+1]+t)*o;g=a.createFixture(l,s,T)}}})}),r.clear()}_updateLightShadowData(){if(!this._tileLayer.tileMapOccluder.enable||!this._dirtyFlags[e.DirtyFlagType.OCCLUSION].size)return;let i=this._tileLayer.tileSet.lightInfoLayers;if(!i||!i.length)return;let a=this._tileLayer.tileMapOccluder,r=this._dirtyFlags[e.DirtyFlagType.OCCLUSION],l=i.length,s=this._tileLayer._chunk,n=t.Vector2.TEMP;r.forEach((r,h)=>{let _=this._cellDataRefMap[h];_&&_.forEach(h=>{let _=this._cellDataMap[h],o=_.cell.lightOccluderDatas;if(o&&r&e.TileMapDirtyFlag.CELL_CHANGE||r&e.TileMapDirtyFlag.CELL_LIGHTSHADOW){s._getPixelByChunkPosAndIndex(this.chunkX,this.chunkY,_.chuckLocalindex,n);let e=n.x,r=n.y,h=_._occluderDatas;h||(h=[],_._occluderDatas=h);for(let s=0;s<l;s++){let l=i[s],n=l.id;if(!o[n])continue;let _=o[n].shape;if(!_)continue;let g=_.length,c=new t.PolygonPoint2D,d=h[n];d||(d=a.addOccluder(c,l.layerMask),h[n]=d);for(let t=0;t<g;t+=2)c.addPoint(_[t]+e,_[t+1]+r);d.polygonPoint=c}}})}),r.clear()}_updateNavigationData(){}_breakBatch(e,t){return null==e&&null==t||(e.cellowner.owner.id!=t.cellowner.owner.id||(null!=e.material||null!=t.material)&&e.material!=t.material)}_createRenderElement(e){if(0==e.length)return;let i=e.length,a=e[0].cell,r=a.material,l=a.cellowner.owner.atlas;r||(r=this._material),null==r&&(r=this._tileLayer.getDefalutMaterial(l));let s=b._getTileRenderElement(i),n=s.renderElement;n.owner=this._tileLayer.owner._struct;let h=s.cacheData,_=h[I.instanceColorBufferIndex],o=h[I.instanceposScalBufferIndex],g=h[I.instanceuvOriScalBufferIndex],c=h[I.instanceuvTransBufferIndex],d=t.Vector2.TEMP,u=this._renderElementArray.length;for(var T=0;T<i;T++){let t=e[T],i=t.cell,r=i.cellowner;t._cellPosInRenderData=T,t._renderElementIndex=u,this._getCellPos(t,d);let l=i.colorModulate,s=4*T;_[s]=l.r,_[s+1]=l.g,_[s+2]=l.b,_[s+3]=l.a;let n=i.texture_origin;o[s]=d.x+n.x,o[s+1]=d.y+n.y;let h=r._getRegionSize();o[s+2]=h.x,o[s+3]=h.y;let p=r._getTextureUVOri(),y=r._getTextureUVExtends();g[s]=p.x,g[s+1]=p.y,g[s+2]=y.x,g[s+3]=y.y;const f=C.parseTransFlag(this._gridShape,t._transFlag,a);c[s]=f.x,c[s+1]=f.y,c[s+2]=f.z,c[s+3]=f.w,t.updateTransFlag=!1}let p=b._getVertexBuffer(m._tileMapCellColorInstanceDec,_),y=b._getVertexBuffer(m._tileMapCellPosScaleDec,o),f=b._getVertexBuffer(m._tileMapCellUVOriScaleDec,g),E=b._getVertexBuffer(m._tileMapCellUVTrans,c),M=n.geometry;M.setDrawElemenParams(this._tileLayer._grid._getBaseIndexCount(),0),n.materialShaderData=r.shaderData,n.subShader=r.shader.getSubShaderAt(0),n.value2DShaderData=this._tileLayer._spriteShaderData;let D=[this._tileLayer._grid._getBaseVertexBuffer(),p,y,f,E],S=this._tileLayer._grid._getBaseIndexBuffer();M.bufferState.applyState(D,S),M.instanceCount=i,e.length=0,this._renderElementArray.push(s)}_clearRenderElement(){for(var e=0,t=this._renderElementArray.length;e<t;e++)b._recoverTileRenderElement(this._renderElementArray[e]);this._renderElementArray.length=0}_setRenderData(e){let t=this._tileLayer._chunk.maxCell;if(e.length>t)return void console.error("setRenderData error");this._updateChunkData(e.x,e.y);let i=this._tileLayer.tileSet,a=e.tiles,r={};for(let e=0,t=a.length;e<t;e+=3){let t=a[e+1],l=a[e+2],s=r[t];s||(s=i.getCellDataByGid(t),r[t]=s),this._setCell(a[e],s,l)}}_clearnRefTileCellData(){let e=this._tileLayer.tileSet;this._cellDataRefMap.forEach((t,i)=>{e.getCellDataByGid(i)._removeNoticeRenderTile(this)}),this._cellDataRefMap=[],this._refGids.length=0}_clearAllChunkCellInfo(){for(let e=0,t=this._chuckCellList.length;e<t;e++)this._clearChunkCellInfo(this._chuckCellList[e]);this._chuckCellList=[],this._cellDataMap=[]}_update(){this._upeateGridData(),this._updateRenderData(),this._updatePhysicsData(),this._updateLightShadowData(),this._updateNavigationData()}_getCellPos(e,t){t.x=this._oriCellIndex.x+e.cellx,t.y=this._oriCellIndex.y+e.celly,this._tileLayer._grid._gridToPixel(t.x,t.y,t)}_mergeToElement(e){this._renderElementArray.forEach(t=>{e.push(t.renderElement)})}_setCell(i,a,r){let l=a.gid;if(l<0)return;this._cellDataRefMap[l]||(this._cellDataRefMap[l]=[],this._refGids.push(l),a._addNoticeRenderTile(this));let s=this._cellDataMap[i];if(null==s){let e=this._tileLayer._chunk,s=t.Vector2.TEMP;e._getCellPosByChunkPosAndIndex(0,0,i,s);let n=new R;n.chuckLocalindex=i,n.zOrderValue=a.z_index,n.cellx=s.x,n.celly=s.y,n.cell=a,n._transFlag=r,n.sortY=s.y+a.y_sort_origin,this._cellDataRefMap[l].push(i),this._cellDataMap[i]=n,this._chuckCellList.push(n),this._modifyData()}else if(s.cell!=a){let e=s.cell,t=e.gid,i=this._cellDataRefMap[t];i.splice(i.indexOf(s.chuckLocalindex),1),0==i.length&&(delete this._cellDataRefMap[t],this._refGids.splice(this._refGids.indexOf(t),1),e._removeNoticeRenderTile(this)),s.cell=a,s.zOrderValue=a.z_index,s.sortY=s.celly+a.y_sort_origin,i=this._cellDataRefMap[l],i.push(s.chuckLocalindex),s._transFlag=r,s.updateTransFlag=!0,this._breakBatch(e,a)&&this._modifyData()}else s._transFlag!=r&&(s._transFlag=r,s.updateTransFlag=!0);this._setDirtyFlag(l,e.TileMapDirtyFlag.CELL_CHANGE)}_clearChunkCellInfo(e){let t=e._physicsDatas;if(t){let e=this._tileLayer.tileMapPhysics;for(let i=0,a=t.length;i<a;i++)e.destroyFixture(this._rigidBody,t[i])}let i=e._occluderDatas;if(i){let e=this._tileLayer.tileMapOccluder;for(let t=0,a=i.length;t<a;t++)e.removeOccluder(i[t])}}_removeCell(e){let t=this._cellDataMap[e];if(!t)return;this._clearChunkCellInfo(t);let i=this._chuckCellList.indexOf(t);this._chuckCellList.splice(i,1),delete this._cellDataMap[t.chuckLocalindex];let a=t.cell.gid,r=this._cellDataRefMap[a];r.splice(r.indexOf(e),1),0==r.length&&(delete this._cellDataRefMap[a],this._refGids.splice(this._refGids.indexOf(a),1),t.cell._removeNoticeRenderTile(this)),this._modifyData()}_modifyData(){this._needUpdateRange=!0,this._reCreateRenderData=!0}getRange(){return this._needUpdateRange&&(this._range||(this._range=new t.Rectangle),this._needUpdateRange=!1,this._calculateRange()),this._range}_calculateRange(){if(!this._chuckCellList.length||!this._tileSize||this._tileSize.x<=0||this._tileSize.y<=0)return void this._range.setTo(0,0,0,0);let t=Number.MAX_VALUE,i=Number.MAX_VALUE,a=-Number.MAX_VALUE,r=-Number.MAX_VALUE,l=0,s=0;if(this._chuckCellList.length>0){for(let e of this._chuckCellList){let l=e.cell.cellowner.sizeByAtlas,s=.5*l.x,n=.5*l.y,h=e.cellx-s,_=e.celly-n,o=e.cellx+s,g=e.celly+n;t=Math.min(t,h),i=Math.min(i,_),a=Math.max(a,o),r=Math.max(r,g)}l=a-t,s=r-i}let n=0,h=0;switch(this._gridShape){case e.TileShape.TILE_SHAPE_SQUARE:n=l*this._tileSize.x,h=s*this._tileSize.y;break;case e.TileShape.TILE_SHAPE_ISOMETRIC:case e.TileShape.TILE_SHAPE_HALF_OFFSET_SQUARE:case e.TileShape.TILE_SHAPE_HEXAGON:n=l*this._tileSize.x,s>1&&s%2==1&&(n+=.5*this._tileSize.x),h=s*this._tileSize.y;break;default:n=l*this._tileSize.x,h=s*this._tileSize.y}let _=(this._oriCellIndex.x+t+.5)*this._tileSize.x,o=(this._oriCellIndex.y+i+.5)*this._tileSize.y;this._range.setTo(_,o,n,h)}getCell(e){return this._cellDataMap[e]}_refreshCellSort(e){if(!e)return;let t=e.gid;if(t<0)return;let i=this._cellDataRefMap[t];if(i&&i.length){for(let t=0,a=i.length;t<a;t++){const a=i[t],r=this._cellDataMap[a];r&&(r.sortY=r.celly+e.y_sort_origin,r.zOrderValue=e.z_index)}this._modifyData()}}_clearOneCell(e){let t=e.gid,i=this._cellDataRefMap[t];if(i)for(const e of i.slice())this._removeCell(e);this._modifyData(),this._dirtyFlags.forEach(e=>e.delete(t))}_setDirtyFlag(t,i,a=e.DirtyFlagType.ALL){if(a==e.DirtyFlagType.ALL)for(let e=0,a=3;e<a;e++){let a=this._dirtyFlags[e];a.set(t,a.get(t)|i)}else{let e=this._dirtyFlags[a];e.set(t,e.get(t)|i)}}_forceUpdateDrity(t){this._cellDataRefMap.forEach((i,a)=>{for(let i=0,r=3;i<r;i++)t[i]&&this._dirtyFlags[i].set(a,e.TileMapDirtyFlag.CELL_CHANGE)})}_clearCell(){this._clearAllChunkCellInfo(),this._clearnRefTileCellData(),this._dirtyFlags.forEach(e=>e.clear()),this._modifyData()}_destroy(){this._rigidBody&&(this._tileLayer.tileMapPhysics.destroyRigidBody(this._rigidBody),this._rigidBody=null),this._clearCell(),this._clearRenderElement(),this._cellDataRefMap=null,this._dirtyFlags=null,this._tileLayer=null}_debugDrawLines(e,t){let i=t[0],a=t[1];for(let r=2,l=t.length;r<l;r+=2){let l=t[r],s=t[r+1];e.graphics.drawLine(i,a,l,s,"#ff0000"),i=l,a=s}}}I.instanceColorBufferIndex=0,I.instanceposScalBufferIndex=1,I.instanceuvOriScalBufferIndex=2,I.instanceuvTransBufferIndex=3;class b{static _getVertexBuffer(e,i){let a=b._instanceBufferPool.pop();return a||(a=t.LayaGL.renderDeviceFactory.createVertexBuffer(t.BufferUsage.Dynamic),a.instanceBuffer=!0),a.setDataLength(i.byteLength),a.setData(i.buffer,0,0,i.byteLength),a.vertexDeclaration=e,a}static _recoverVertexBuffer(e){this._instanceBufferPool.push(e)}static _getTileRenderElement(e){let i=b._renderElementPool.pop();if(!i){let e=t.LayaGL.renderDeviceFactory.createRenderGeometryElement(t.MeshTopology.Triangles,t.DrawType.DrawElementInstance),a=t.LayaGL.render2DRenderPassFactory.createRenderElement2D();a.geometry=e,e.bufferState=t.LayaGL.renderDeviceFactory.createBufferState(),e.indexFormat=t.IndexFormat.UInt16,a.renderStateIsBySprite=!1,a.nodeCommonMap=["BaseRender2D"],i={renderElement:a,cacheData:null,updateFlag:[!1,!1,!1,!1],maxCell:0}}return i.cacheData=[new Float32Array(4*e),new Float32Array(4*e),new Float32Array(4*e),new Float32Array(4*e)],i}static _recoverTileRenderElement(e){e.cacheData=null;let t=e.renderElement;t.materialShaderData=null,t.value2DShaderData=null,t.subShader=null;let i=t.geometry;for(let e=2,t=i.bufferState._vertexBuffers.length;e<t;e++)b._recoverVertexBuffer(i.bufferState._vertexBuffers[e]);let a=e.updateFlag;for(let e=0;e<4;e++)a[e]=!1;b._renderElementPool.push(e)}}b._instanceBufferPool=[],b._renderElementPool=[];class N{constructor(){this._width=0,this._height=0,this._vbData=[],this._ibData=[],this._outline=[],this._matrix=new t.Matrix,this._origMatix=new t.Matrix,this._reverseMatrix=new t.Matrix,this._initData(),this.setTileSize(1,1)}getMatrix(){return this._matrix}getInverseMatrix(){return this._reverseMatrix}getTileWidth(){return this._width}getTileHeight(){return this._height}getTileBaseOutline(){return this._outline}_initData(){}setTileSize(e,i){(e<1||i<1)&&console.error(" value must bigger than 1."),this._width==e&&this._height==i||(this._width=e,this._height=i,this._matrix.setTo(this._width,0,0,this._height,0,0),t.Matrix.mul(this._origMatix,this._matrix,this._matrix),this._matrix.copyTo(this._reverseMatrix),this._reverseMatrix.invert())}getvbs(){return this._vbData}getibs(){return this._ibData}pixelToGrid(e,t,i){C.transfromPointByValue(this._reverseMatrix,e,t,i)}gridToPixel(e,t,i){C.transfromPointByValue(this._matrix,e,t,i)}_getChunkSize(e,t,i){}_getChunkLeftTop(e,t,i,a,r){}}class P extends N{constructor(e=-1){super(),this._offset=0,this._offset=e}_initData(){this._origMatix.setTo(1,0,0,1,.5,.5),this._ibData=[0,1,2,0,2,3],this._vbData=[1,1,0,1,0,0,1,0],this._outline=[0,0,1,0,1,1,0,1]}pixelToGrid(e,t,i){super.pixelToGrid(e,t,i);let a=i.y=Math.round(i.y);i.x=Math.round(i.x+this._offset*(1&Math.abs(a))*.5)}gridToPixel(e,t,i){e-=this._offset*(1&Math.abs(t))*.5,super.gridToPixel(e,t,i)}_getChunkSize(e,t,i){e=Math.max(e-1,0),t=Math.max(t-1,0),this.gridToPixel(e,t,i);let a=this._width;t%2==1&&(a+=.5*this._width),i.x+=a,i.y+=this._height}_getChunkLeftTop(e,t,i,a,r){this.gridToPixel(e,t,r),r.x-=1==a||t%2==0?.5*this._width:this._width,r.y-=.5*this._height}}class A extends N{constructor(e=-1){super(),this._offset=0,this._offset=e}_initData(){this._origMatix.setTo(1,0,.5,.75,.5,.5),this._ibData=[0,1,2,0,2,3],this._vbData=[1,1,0,1,0,0,1,0],this._outline=[.5,0,1,.25,1,.75,.5,1,0,.75,0,.25]}prixToGrid(e,t){const i=e.x,a=e.y,r=-i-a;var l=Math.round(i),s=Math.round(a),n=Math.round(r),h=Math.abs(l-i),_=Math.abs(s-a),o=Math.abs(n-r);h>_&&h>o?l=-s-n:_>o&&(s=-l-n),e.x=l+(s+t*(1&s))/2,e.y=s}pixelToGrid(e,t,i){super.pixelToGrid(e,t,i),this.prixToGrid(i,this._offset)}gridToPixel(e,t,i){e-=(t+this._offset*(1&t))/2,super.gridToPixel(e,t,i)}_getChunkSize(e,t,i){e=Math.max(e-1,0),t=Math.max(t-1,0),this.gridToPixel(e,t,i);let a=this._width;t%2==1&&(a+=.5*this._width),i.x+=a,i.y+=this._height}_getChunkLeftTop(e,t,i,a,r){this.gridToPixel(e,t,r),r.x-=1==a||t%2==0?.5*this._width:this._width,r.y-=.5*this._height}}class w extends N{constructor(e=1){super(),this._offset=0,this._offset=e}_initData(){this._origMatix.setTo(1,0,0,1,.5,.5),this._ibData=[0,1,2,0,2,3],this._vbData=[1,1,0,1,0,0,1,0],this._outline=[0,.5,.5,0,1,.5,.5,1]}pixelToGrid(e,t,i){super.pixelToGrid(e,t,i);let a=Math.round(i.x),r=Math.round(i.y),l=0,s=0;Math.abs(i.x-a)+Math.abs(i.y-r)>.5&&(l=i.x<a?-1:0,s=i.y<r?-1:1,-1==this._offset&&(l+=1)),i.x=a+l,i.y=2*r+s}gridToPixel(e,t,i){e=Math.floor(e),1&(t=Math.floor(t))&&(e+=.5*this._offset),super.gridToPixel(e,.5*t,i)}_getChunkSize(e,t,i){e=Math.max(e-1,0),t=Math.max(t-1,0),this.gridToPixel(e,t,i);let a=this._width;t%2==1&&(a+=.5*this._width),i.x+=a,i.y+=this._height}_getChunkLeftTop(e,t,i,a,r){this.gridToPixel(e,t,r),r.x-=1==a||t%2==0?.5*this._width:this._width,r.y-=.5*this._height}}class F extends N{constructor(){super()}_initData(){this._origMatix.setTo(1,0,0,1,.5,.5),this._ibData=[0,1,2,0,2,3],this._vbData=[1,1,0,1,0,0,1,0],this._outline=[0,0,1,0,1,1,0,1]}gridToPixel(e,t,i){super.gridToPixel(e,t,i),i.x=Math.round(i.x),i.y=Math.round(i.y)}_getChunkSize(e,t,i){e=Math.max(e-1,0),t=Math.max(t-1,0),this.gridToPixel(e,t,i),i.x+=this._width,i.y+=this._height}_getChunkLeftTop(e,t,i,a,r){this.gridToPixel(e,t,r),r.x-=.5*this._width,r.y-=.5*this._height}}class v{constructor(){this._offset=new t.Vector2,this._color=new t.Color(0,0,0,0),this._vbLength=0;let e=this._vbs=t.LayaGL.renderDeviceFactory.createVertexBuffer(t.BufferUsage.Dynamic);e.vertexDeclaration=m._tileMapPositionUVColorDec,e.instanceBuffer=!1,this._ibs=t.LayaGL.renderDeviceFactory.createIndexBuffer(t.BufferUsage.Dynamic)}_updateTileShape(t,i){if(this._tileShape==t)return!1;switch(this._tileShape=t,this._tileShape){case e.TileShape.TILE_SHAPE_SQUARE:this._sheet=new F,this._offset.setValue(0,0);break;case e.TileShape.TILE_SHAPE_HALF_OFFSET_SQUARE:this._sheet=new P,this._offset.setValue(0,-1);break;case e.TileShape.TILE_SHAPE_HEXAGON:this._sheet=new A,this._offset.setValue(1,-1);break;case e.TileShape.TILE_SHAPE_ISOMETRIC:this._sheet=new w,this._offset.setValue(0,0);break;default:throw Error("unknow the type .")}return this._setTileSize(i.x,i.y),!0}_updateColor(e){return!e.equal(this._color)&&(e.cloneTo(this._color),!0)}_updateBufferData(){let e=this._sheet.getvbs(),t=e.length/2;for(var i=new Float32Array(8*t),a=0;a<t;a++){let t=8*a;var r=2*a;let l=e[r],s=e[r+1];i[t]=i[t+2]=l-.5,i[t+1]=i[t+3]=s-.5,i[t+4]=this._color.r,i[t+5]=this._color.g,i[t+6]=this._color.b,i[t+7]=this._color.a}this._vbs.setDataLength(i.byteLength),this._vbs.setData(i.buffer,0,0,i.buffer.byteLength);let l=new Uint16Array(this._sheet.getibs()),s=this._ibs;s._setIndexDataLength(l.buffer.byteLength),s._setIndexData(l,0),this._vbLength=l.length}_setTileSize(e,t){this._sheet.setTileSize(e,t)}_pixelToGrid(e,t,i){this._sheet.pixelToGrid(e,t,i)}_gridToPixel(e,t,i){this._sheet.gridToPixel(e,t,i)}_getBaseVertexBuffer(){return this._vbs}_getBaseIndexBuffer(){return this._ibs}_getBaseIndexCount(){return this._vbLength}}const B=new t.Vector2;class V{constructor(e){this._grid=e,this._maxCell=0,this._setChunkSize(1,1)}get maxCell(){return this._maxCell}_setChunkSize(e,t){this._chunkWidth=e,this._chunkHeight=t,this._maxCell=e*t}_getChunkPosByPixel(e,t,i){this._grid._pixelToGrid(e,t,B),this._getChunkPosByCell(Math.round(B.x),Math.round(B.y),i)}_getChunkPosByCell(e,t,i){i.x=Math.floor(e/this._chunkWidth),i.y=Math.floor(t/this._chunkHeight),i.z=this._getChunkIndexByCellPos(e,t)}_getChunkIndexByCellPos(e,t){let i=e%this._chunkWidth;i<0&&(i+=this._chunkWidth);let a=t%this._chunkHeight;return a<0&&(a+=this._chunkHeight),i+a*this._chunkWidth}_getCellPosByChunkPosAndIndex(e,t,i,a){e=Math.floor(e),t=Math.floor(t),i%=this._maxCell,a.x=e*this._chunkWidth+i%this._chunkWidth,a.y=t*this._chunkHeight+Math.floor(i/this._chunkWidth)}_getPixelByChunkPosAndIndex(e,t,i,a){e=Math.floor(e),t=Math.floor(t),i%=this._maxCell;let r=e*this._chunkWidth+i%this._chunkWidth,l=t*this._chunkHeight+Math.floor(i/this._chunkWidth);this._grid._gridToPixel(r,l,a)}_getChunkSize(e){this._grid._sheet._getChunkSize(this._chunkWidth,this._chunkHeight,e)}_getChunkLeftTop(e,t,i){this._grid._sheet._getChunkLeftTop(e*this._chunkWidth,t*this._chunkHeight,this._chunkWidth,this._chunkHeight,i)}}class k{static __init__(){k._tempDef=new t.Box2DShapeDef}constructor(e){this.enable=!1,this._rigidBodys=[],this._layer=e}updateState(e){let i=!!t.Laya.physics2D&&e;i!=this.enable&&(i?this.enableRigidBodys():this.disableRigidBodys(),this.enable=i)}createRigidBody(){let e=t.Laya.physics2D,i=this._layer.owner.scene.getComponentElementManager(t.Physics2DWorldManager.__managerName);var a=new t.RigidBody2DInfo;a.angle=0,a.allowSleep=!1,a.angularDamping=0,a.bullet=!1,a.fixedRotation=!1,a.gravityScale=0,a.linearDamping=0,a.angularVelocity=0,a.linearVelocity.setValue(0,0);let r=e.createBodyDef(i,a),l=e.createBody(i.box2DWorld,r),s=this._layer.owner.globalTrans,n=s.x,h=s.y,_=t.Utils.toRadian(s.rotation);return t.Laya.physics2D.set_RigibBody_Transform(l,n,h,_),this._rigidBodys.push(l),l}enableRigidBodys(){for(let e=0,t=this._rigidBodys.length;e<t;e++)this._enableRigidBody(this._rigidBodys[e])}disableRigidBodys(){for(let e=0,t=this._rigidBodys.length;e<t;e++)this._disableRigidBody(this._rigidBodys[e])}_enableRigidBody(e){t.Laya.physics2D.set_RigibBody_Enable(e,!0)}_disableRigidBody(e){t.Laya.physics2D.set_RigibBody_Enable(e,!1)}destroyRigidBody(e){let i=this._rigidBodys.indexOf(e);-1!==i&&this._rigidBodys.splice(i,1);let a=this._layer.owner.scene.getComponentElementManager(t.Physics2DWorldManager.__managerName);t.Laya.physics2D.removeBody(a,e)}createFixture(e,i,a){let r=t.Laya.physics2D,l=this._layer.owner.scene.getComponentElementManager(t.Physics2DWorldManager.__managerName);var s=k._tempDef;s.density=i.density,s.friction=i.friction,s.isSensor=!1,s.restitution=i.restitution,s.shapeType=t.EPhysics2DShape.PolygonShape;let n=r.createFilter(),h=r.createShapeDef(l.box2DWorld,s,n);r.set_PolygonShape_data(h._shape,0,0,a,1,1);let _=r.createShape(l,e,t.EPhysics2DShape.PolygonShape,h);return r.set_shapeDef_GroupIndex(_,i.group),r.set_shapeDef_CategoryBits(_,i.category),r.set_shapeDef_maskBits(_,i.mask),r.set_shape_collider(_,this),_}_updateTransfrom(){let e=this._rigidBodys.length;if(!e)return;let i=this._layer.owner.globalTrans,a=i.x,r=i.y,l=t.Utils.toRadian(i.rotation);for(let i=0;i<e;i++)t.Laya.physics2D.set_RigibBody_Transform(this._rigidBodys[i],a,r,l)}destroyFixture(e,i){t.Laya.physics2D.rigidBody_DestroyShape(e,i)}destroy(){this._rigidBodys=[]}}class G{constructor(){this._x=0,this._y=0,this._rectValueMin=0,this._rectValueMax=0}_dotValue(e,t){return this._x*e+this._y*t}_getDotMinMax(e,t){t.x=Number.MAX_VALUE,t.y=-Number.MAX_VALUE;for(var i=0;i<e.length;i+=2){let a=this._dotValue(e[i],e[i+1]);t.x=Math.min(t.x,a),t.y=Math.max(t.y,a)}}setAlex(e,t){let i=Math.hypot(e,t);this._x=-t/i,this._y=e/i}updateVerter(e,i){let a=t.Vector2.TEMP;this._getDotMinMax(e,a),this._rectValueMin=a.x,this._rectValueMax=a.y,this._getDotMinMax(i,a);let r=.5*(a.y-a.x);this._rectValueMin-=r,this._rectValueMax+=r}testCollider(e,t){let i=this._dotValue(e,t);return i<this._rectValueMin||i>this._rectValueMax}}class H{constructor(){this._clipperRect=new t.Rectangle,this._polygonSize=new t.Vector2,this._polygonTransform=new t.Matrix,this._ploygRect=new t.Vector4,this._matrix=new t.Matrix,this._axis=[],this._axis.push(new G),this._axis.push(new G),this._axis.push(new G),this._axis.push(new G),this._axis[0].setAlex(1,0),this._axis[1].setAlex(0,1)}_mrgePoint(e,i,a){let r=t.Point.TEMP;r.setTo(e,i),this._matrix.invertTransformPoint(r),a.x=Math.min(a.x,r.x),a.y=Math.min(a.y,r.y),a.z=Math.max(a.z,r.x),a.w=Math.max(a.w,r.y)}_updateCliperInPolygonRect(){this._ploygRect.setValue(Number.MAX_VALUE,Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);let e=.5*this._clipperRect.width,t=.5*this._clipperRect.height;this._mrgePoint(-e,-t,this._ploygRect),this._mrgePoint(e,-t,this._ploygRect),this._mrgePoint(e,t,this._ploygRect),this._mrgePoint(-e,t,this._ploygRect)}_updateAxiDatas(){if(null==this._rectDatas)return;let e=this._polygonW,i=this._polygonH;this._polygons=[];const a=t.Vector2.TEMP;C.transfromPointNByValue(this._matrix,-e,-i,a),this._polygons.push(a.x,a.y),C.transfromPointNByValue(this._matrix,e,-i,a),this._polygons.push(a.x,a.y),C.transfromPointNByValue(this._matrix,e,i,a),this._polygons.push(a.x,a.y),C.transfromPointNByValue(this._matrix,-e,i,a),this._polygons.push(a.x,a.y);let r=this._polygons[2]-this._polygons[0],l=this._polygons[3]-this._polygons[1];this._axis[2].setAlex(r,l),r=this._polygons[4]-this._polygons[2],l=this._polygons[5]-this._polygons[3],this._axis[3].setAlex(r,l),this._axis[0].updateVerter(this._rectDatas,this._polygons),this._axis[1].updateVerter(this._rectDatas,this._polygons),this._axis[2].updateVerter(this._rectDatas,this._polygons),this._axis[3].updateVerter(this._rectDatas,this._polygons)}_updateClipRect(e){if(e.equals(this._clipperRect))return!1;e.cloneTo(this._clipperRect);let t=.5*e.width,i=.5*e.height;return this._rectDatas=[-t,-i,t,-i,t,i,-t,i],!0}_updatePolygonSize(e){return!t.Vector2.equals(e,this._polygonSize)&&(e.cloneTo(this._polygonSize),!0)}_updatePolygonTransform(e){return(e.a!=this._polygonTransform.a||e.b!=this._polygonTransform.b||e.c!=this._polygonTransform.c||e.d!=this._polygonTransform.d||e.tx!=this._polygonTransform.tx||e.ty!=this._polygonTransform.ty)&&(e.copyTo(this._polygonTransform),!0)}getploygRect(){return this._ploygRect}setClipper(e,i,a,r=0,l=0,s=0){let n=this._updateClipRect(e),h=this._updatePolygonSize(i),_=this._updatePolygonTransform(a);return(n||_)&&(r||l||s?(this._matrix.setMatrix(r,l,1,1,s,0,0,0,0),this._matrix.invert()):this._matrix.identity(),t.Matrix.mul(a,this._matrix,this._matrix),this._updateCliperInPolygonRect()),(n||h||_)&&this._updateAxiDatas(),this._ploygRect}isClipper(e,i){const a=t.Vector2.TEMP;return C.transfromPointByValue(this._matrix,e,i,a),!!this._axis[0].testCollider(a.x,a.y)||(!!this._axis[1].testCollider(a.x,a.y)||(!!this._axis[2].testCollider(a.x,a.y)||!!this._axis[3].testCollider(a.x,a.y)))}}class z extends t.Resource{constructor(){super(),this._defalutMaterials={},this._ownerList=[],this._terrainsDirty=!0,this._paramsLists=[],this._tileSize=new t.Vector2(16,16),this._tileShape=e.TileShape.TILE_SHAPE_SQUARE,this._groups=[],this._groupIds=[]}get tileShape(){return this._tileShape}set tileShape(e){this._tileShape!==e&&(this._tileShape=e,this._ownerList.forEach(e=>{e._grid._updateTileShape(this._tileShape,this._tileSize),e._grid._updateBufferData()}))}get tileSize(){return this._tileSize}set tileSize(e){t.Vector2.equals(e,this._tileSize)||(e.cloneTo(this._tileSize),this._ownerList.forEach(e=>{e._grid._setTileSize(this._tileSize.x,this._tileSize.y)}))}_disposeResource(){for(const e in this._defalutMaterials)this._defalutMaterials[e]&&this._defalutMaterials[e].destroy()}getCellDataByGid(e){if(e<0)return null;const t=C.parseGroupId(e),i=this._groups.find(e=>e.id==t);if(i){const t=C.parseCellIndex(e),a=C.parseNativeIndex(e);return i.getCellDataByIndex(a,t)}return null}_addOwner(e){-1==this._ownerList.indexOf(e)&&this._ownerList.push(e)}_removeOwner(e){let t=this._ownerList.indexOf(e);-1!=t&&this._ownerList.splice(t,1)}_notifyTileSetCellGroupsChange(){this._groupIds.length=0;for(let e=0,t=this._groups.length;e<t;e++){const t=this._groups[e];t._recaculateUVOriProperty(!1),this._groupIds.push(t.id)}}_notifyCustomDataLayerChange(){}_notifyRenderLayerChange(){}_notifyTerrainSetChange(){}_notifyNavigationLayerChange(){}_notifyPhysicsLayerChange(){this._terrainsDirty=!0}addTileSetCellGroup(e){e&&(e._owner=this,this._groups.push(e),this._notifyTileSetCellGroupsChange())}getTileSetCellGroup(e){let t=this._groupIds.indexOf(e);return this._groups[t]}removeTileSetCellGroup(e){let t=this._groupIds.indexOf(e);this._groups.splice(t,1),this._notifyTileSetCellGroupsChange()}get customLayers(){return this._customDataLayers}set customLayers(e){this._customDataLayers=e}addCustomDataLayer(e){this._customDataLayers||(this._customDataLayers=[]);let t=this._addLayer(this._customDataLayers,"name",e);return t&&this._notifyCustomDataLayerChange(),t}getCustomDataLayer(e){return this._getLayer(this._customDataLayers,"name",e)}removeCustomDataLayer(e){let t=this._removeLayer(this._customDataLayers,"name",e);return t&&this._notifyCustomDataLayerChange(),t}get navigationLayers(){return this._navigationLayers}set navigationLayers(e){this._navigationLayers=e}addNavigationLayers(e){}getNavigationLayers(e){return null}removeNavigationLayers(e){}get lightInfoLayers(){return this._lightOcclusion}set lightInfoLayers(e){this._lightOcclusion=e}addLightInfoLayer(e){this._lightOcclusion||(this._lightOcclusion=[]);let t=this._addLayer(this._lightOcclusion,"id",e);return t&&this._notifyRenderLayerChange(),t}getLightInfoLayer(e){return this._getLayer(this._lightOcclusion,"id",e)}removeLightInfoLayer(e){let t=this._removeLayer(this._lightOcclusion,"id",e);return t&&this._notifyRenderLayerChange(),t}get physicsLayers(){return this._physicsLayers}set physicsLayers(e){this._physicsLayers=e}addPhysicsLayer(e){this._physicsLayers||(this._physicsLayers=[]);let t=this._addLayer(this._physicsLayers,"id",e);return t&&this._notifyPhysicsLayerChange(),t}getPhysicsLayer(e){return this._getLayer(this._physicsLayers,"id",e)}removePhysicsLayer(e){let t=this._removeLayer(this._physicsLayers,"id",e);return t&&this._notifyPhysicsLayerChange(),t}_addLayer(e,t,i){for(let a=0,r=e.length;a<r;a++)if(i[t]==e[a][t])return!1;return e.push(i),!0}_getLayer(e,t,i){if(!e||!e.length)return null;for(let a=0,r=e.length;a<r;a++)if(i==e[a][t])return e[a];return null}_removeLayer(e,t,i){if(!e||!e.length)return null;for(let a=0,r=e.length;a<r;a++)if(i==e[a][t])return e.splice(a,1)[0];return null}get terrainSets(){return this._terrainSets}set terrainSets(e){if(e)for(let t=0,i=e.length;t<i;t++)e[t]&&e[t].updateShape(this._tileShape);this._terrainSets=e}addTerrainSet(e){this._physicsLayers||(this._terrainSets=[]);let t=this._addLayer(this._terrainSets,"id",e);e.updateShape(this._tileShape),t&&this._notifyPhysicsLayerChange()}getTerrainSet(e){let t=this._getLayer(this._terrainSets,"id",e);return t&&this._notifyTerrainSetChange(),t}removeTerrainSet(e){let t=this._removeLayer(this._terrainSets,"id",e);return t&&this._notifyPhysicsLayerChange(),t}updateTerrains(){if(this._terrainsDirty){this._clearTerrainParams(),this._terrainsDirty=!1,this._groups.forEach(e=>{let t=e.tiles;for(let e in t){let i=t[e];for(let e in i){let t=i[e];for(let e in t._tileDatas){let i=t._tileDatas[e],a=i.terrainSet;if(a>-1){let e=this.getTerrainSet(a);i.terrain>-1&&this.addTerrainParams(i);let t=e._neighbors;for(let e=0,a=t.length;e<a;e++){let a=t[e];i.get_terrainPeeringBit(a)>-1&&this.addTerrainParams(i)}}}}}});for(let e=0,t=this._terrainSets.length;e<t;e++)this._addEmptyParams(this._terrainSets[e])}}_getParamsList(e){return this.updateTerrains(),this._paramsLists[e]}_clearTerrainParams(){let e=this._paramsLists;for(let t=0,i=e.length;t<i;t++){let i=e[t];if(i)for(let e=0,t=i.length;e<t;e++){let t=i[e];if(t)for(let e=0,i=t.length;e<i;e++)t[e]&&t[e].clearLinks()}}}addTerrainParams(e){let t,i=this._paramsLists[e.terrainSet]&&this._paramsLists[e.terrainSet][e.terrain]?this._paramsLists[e.terrainSet][e.terrain]:null;if(i){let a=e._getTerrainPeeringBits(),r=this.getTerrainSet(e.terrainSet)._neighbors,l=r.length;for(let e=0,s=i.length;e<s;e++){let s=i[e],n=!0;for(let e=0;e<l;e++){let t=r[e];if(s.terrain_peering_bits[t]!=a[t]){n=!1;break}}if(n){t=s;break}}}else t=this._addTerrainParams(e);return t||(t=e.getTerrainsParams(),i.push(t)),t.link(e),t}_addTerrainParams(e){let t=this._paramsLists[e.terrainSet];t||(t=this._paramsLists[e.terrainSet]=[]);let i=t[e.terrain];i||(i=t[e.terrain]=[]);let a=e.getTerrainsParams();return i.push(a),a}_addEmptyParams(e){let t,i=this._paramsLists[e.id]&&this._paramsLists[e.id][-1]?this._paramsLists[e.id][-1]:null;if(i){let a=e._neighbors,r=a.length;for(let e=0,l=i.length;e<l;e++){let l=i[e],s=!0;for(let e=0;e<r;e++){let t=a[e];if(-1!=l.terrain_peering_bits[t]){s=!1;break}}if(s){t=l;break}}}else{let t=this._paramsLists[e.id]=this._paramsLists[e.id]||[];i=t[-1]=t[-1]||[]}return t||(t=new E,t.terrainSet=e.id,i.push(t)),t.link(x._EMPTY),t}getDefalutMaterial(e){let i=e.url,a=this._defalutMaterials[i];return a||(a=new t.Material,a.setShaderName("TileMapLayer"),a.setColor("u_Color",new t.Color(1,1,1,1)),a.setBoolByIndex(t.Shader3D.DEPTH_WRITE,!1),a.setIntByIndex(t.Shader3D.DEPTH_TEST,t.RenderState.DEPTHTEST_OFF),a.setIntByIndex(t.Shader3D.BLEND,t.RenderState.BLEND_ENABLE_ALL),a.setIntByIndex(t.Shader3D.BLEND_EQUATION,t.RenderState.BLENDEQUATION_ADD),a.setIntByIndex(t.Shader3D.BLEND_SRC,t.RenderState.BLENDPARAM_ONE),a.setIntByIndex(t.Shader3D.BLEND_DST,t.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA),a.setFloatByIndex(t.ShaderDefines2D.UNIFORM_VERTALPHA,1),a.setIntByIndex(t.Shader3D.CULL,t.RenderState.CULL_NONE),a.setTexture("u_render2DTexture",e),1!=e.gammaCorrection?a.addDefine(t.ShaderDefines2D.GAMMATEXTURE):a.removeDefine(t.ShaderDefines2D.GAMMATEXTURE),a.lock=!0,this._defalutMaterials[i]=a),a}}class U{get tiles(){return this._tiles}set tiles(e){if(e)for(let t in e)for(let i in e[t])e[t][i].owner=this;this._tiles=e}get atlas(){return this._atlas}set atlas(e){this._atlas!==e&&(e._addReference(),this._atlas=e,this._atlasSize.setValue(e.width,e.height),this._recaculateUVOriProperty(!0))}get atlasSize(){return this._atlasSize}set atlasSize(e){e.cloneTo(this._atlasSize),this._recaculateUVOriProperty(!0)}get margin(){return this._margin}set margin(e){e.cloneTo(this._margin),this._recaculateUVOriProperty(!0)}get separation(){return this._separation}set separation(e){e.cloneTo(this._separation),this._recaculateUVOriProperty(!0)}get textureRegionSize(){return this._textureRegionSize}set textureRegionSize(e){e.cloneTo(this._textureRegionSize),this._recaculateUVOriProperty(!0)}constructor(){this._maxAlternativesCount=0,this._maxCellCount=new t.Vector2,this._tileMatrix=new t.Matrix,this._tiles={},this._separation=new t.Vector2,this._margin=new t.Vector2,this._textureRegionSize=new t.Vector2,this._atlasSize=new t.Vector2}get owner(){return this._owner}set owner(e){null!=this._owner&&console.error("owner is not null"),this._owner=e,this._owner.addTileSetCellGroup(this)}_recaculateUVOriProperty(e){this._tileMatrix.identity(),this._tileMatrix.scale(this._textureRegionSize.x+this._separation.x,this._textureRegionSize.y+this._separation.y),this._tileMatrix.translate(this._margin.x,this._margin.y),this._tileMatrix.invert();let t=Math.floor((this._atlasSize.x-this._margin.x)/(this._textureRegionSize.x+this._separation.x)),i=Math.floor((this._atlasSize.y-this._margin.y)/(this._textureRegionSize.y+this._separation.y));for(var a in this._maxAlternativesCount=t*i,this._maxCellCount.setValue(t,i),this._tiles){let e=this._tiles[a];for(var r in e)e[r]._init()}e&&this._owner&&this._owner._notifyTileSetCellGroupsChange()}onAtlasSizeChange(){this._owner&&this._owner._notifyTileSetCellGroupsChange()}_getGlobalAlternativesId(e,t){return C.getNativeId(this.id,t*this._maxCellCount.x+e)}_getCellPosByAlternativesId(e,t){t.x=e%this._maxCellCount.x,t.y=Math.floor(e/this._maxCellCount.x)}_getTilePixelOrgin(e,t){let i=e.x*(this._textureRegionSize.x+this._separation.x)+this._margin.x,a=e.y*(this._textureRegionSize.y+this._separation.y)+this._margin.y;return t.setValue(i,a),t}_getTileUVExtends(e,t){return t.x=(e.x-1)*this._separation.x+this._textureRegionSize.x*e.x,t.y=(e.y-1)*this._separation.y+this._textureRegionSize.y*e.y,t}getAlternative(e,t){return this._tiles[t]?this._tiles[t][e]:null}addAlternaltive(e,i,a){let r=this.getAlternative(e,i);if(r)return r;let l=t.Vector2.TEMP;if(this._getTileUVExtends(a,l),l.x+e>this._atlasSize.x||l.y+i>this._atlasSize.y)return null;let s=new O;s.localPos=new t.Vector2(e,i),s.sizeByAtlas=a,s.owner=this,s._initialIndexFIrstCellData();for(var n=0,h=a.y;n<h;n++){let t=this._tiles[n+i];t||(t=this._tiles[n+i]={});for(var _=0,o=a.x;_<o;_++)t[_+e]=s}return s}removeAlternaltive(e){if(!this._tiles[e.y])return;let t=this._tiles[e.y];t[e.x]&&delete t[e.x]}getCellData(e,t){let i=this.getAlternative(e.x,e.y);return null==i?null:i.getCelldata(t)}getCellDataByIndex(e,i){const a=t.Vector2.TEMP;this._getCellPosByAlternativesId(e,a);let r=this.getAlternative(a.x,a.y);return null==r?null:r.getCelldata(i)}removeCellData(e,t){let i=this.getAlternative(e.x,e.y);return null==i?null:i.removeCellData(t)}release(){}}class Y{static read(e){let i=new t.Byte(e);if(i.pos=0,!i.readUTFString().startsWith("TILEMAPLAYER_DATA"))return null;let a=i.readUint32(),r=[];for(let e=0;e<a;e++){let e=i.readFloat32(),t=i.readFloat32(),a=i.readUint32(),l=[];for(let e=0;e<a;e++){let e=i.readUint32(),t=i.readUint32(),a=i.readUint32();l.push(e,t,a)}let s={x:e,y:t,length:a,tiles:l};r.push(s)}return r}}t.Loader.registerLoader(["tres"],class{load(e){return e.loader.fetch(e.url,"json",e.progress.createCallback(.2),e.options).then(i=>{if(!i)return null;i.groups||(i.groups=[]);const a=i.groups;let r=[];for(let e=0,i=a.length;e<i;e++){let i=a[e].atlas._$uuid;t.Utils.isUUID(i)&&(i="res://"+i),r.push({url:i,type:t.Loader.TEXTURE2D})}return this.load2(e,i,r)})}load2(e,i,a){let r=Object.assign({},e.options);return r.initiator=e,delete r.cache,delete r.ignoreCache,e.loader.load(a,r,e.progress.createCallback()).then(()=>{let e=new z;e.tileShape=i.tileShape?i.tileShape:0;for(let t=0,a=i.groups.length;t<a;t++)this.createGroup(e,i.groups[t]);return i.tileSize&&(e.tileSize=t.ObjDecoder.decodeObj(i.tileSize)),e.physicsLayers=t.ObjDecoder.decodeObj(i.physicsLayers),e.lightInfoLayers=t.ObjDecoder.decodeObj(i.lightInfoLayers),e.customLayers=t.ObjDecoder.decodeObj(i.customLayers),e.navigationLayers=t.ObjDecoder.decodeObj(i.navigationLayers),e.terrainSets=t.ObjDecoder.decodeObj(i.terrainSets),e._notifyTileSetCellGroupsChange(),e})}createGroup(e,i){let a=new U;a.id=i.id,a.name=i.name,e.addTileSetCellGroup(a),t.ObjDecoder.decodeObj(i,a),i.atlas.path&&(a.atlas=t.Loader.getBaseTexture(i.atlas.path))}},"tres");class X{get layerMask(){return this._core.layerMask}set layerMask(e){this._core.layerMask=e}set manager(e){this._core.manager=e}get canInLight(){return this._core.canInLight}set canInLight(e){this._core.canInLight=e}get polygonPoint(){return this._core.polygonPoint}set polygonPoint(e){this._core.polygonPoint=e}get outside(){return this._core.outside}set outside(e){this._core.outside=e}constructor(){this._core=new t.LightOccluder2DCore}_onEnable(){this._core.owner=this.owner,this.owner.on(t.Event.TRANSFORM_CHANGED,this._core,this._core._transformChange),this._core._onEnable()}_onDisable(){this.owner.off(t.Event.TRANSFORM_CHANGED,this._core,this._core._transformChange),this._core._onDisable()}destroy(){this._onDisable(),this._core.destroy(),this._core=null}}class Q{constructor(e){this.enable=!1,this._occluders=[],this._layer=e}_updateManager(){var e,t;let i=null===(t=null===(e=this._layer.owner)||void 0===e?void 0:e.scene)||void 0===t?void 0:t._light2DManager;this._manager=i}updateState(e){e!=this.enable&&(this.enable=e,e?this.enableAllOccluders():this.disableAllOccluders())}enableAllOccluders(){if(this._manager&&this._occluders.length)for(let e=0,t=this._occluders.length;e<t;e++)this._occluders[e].manager=this._manager,this._occluders[e]._onEnable()}disableAllOccluders(){if(this._manager&&this._occluders.length)for(let e=0,t=this._occluders.length;e<t;e++)this._occluders[e]._onDisable()}_removeAllOccluders(){if(this._manager)for(let e=this._occluders.length-1;e>-1;e--)this.removeOccluder(this._occluders[e])}addOccluder(e,t){let i=new X;return i.owner=this._layer.owner,i.manager=this._manager,i.polygonPoint=e,i.layerMask=t,i._onEnable(),this._occluders.push(i),i}removeOccluder(e){if(!e)return!1;let t=this._occluders.indexOf(e);return this._occluders.splice(t,1),e.destroy(),!0}destroy(){this._removeAllOccluders()}}var W;e.TILEMAPLAYERDIRTYFLAG=void 0,(W=e.TILEMAPLAYERDIRTYFLAG||(e.TILEMAPLAYERDIRTYFLAG={}))[W.CELL_CHANGE=1]="CELL_CHANGE",W[W.CELL_COLOR=2]="CELL_COLOR",W[W.CELL_QUAD=4]="CELL_QUAD",W[W.CELL_QUADUV=8]="CELL_QUADUV",W[W.CELL_UVTRAN=16]="CELL_UVTRAN",W[W.CELL_PHYSICS=32]="CELL_PHYSICS",W[W.CELL_TERRAIN=64]="CELL_TERRAIN",W[W.CELL_LIGHTSHADOW=128]="CELL_LIGHTSHADOW",W[W.CELL_NAVIGATION=256]="CELL_NAVIGATION",W[W.CELL_SORTCHANGE=512]="CELL_SORTCHANGE",W[W.TILESET_SAZE=1024]="TILESET_SAZE",W[W.LAYER_COLOR=2048]="LAYER_COLOR",W[W.LAYER_PHYSICS=4096]="LAYER_PHYSICS";const j=new t.Rectangle,q=new t.Matrix,Z=new t.Vector2,$=new t.Vector2;class J extends t.BaseRenderNode2D{static __init__(){J._inited||(this._inited=!0,m.__init__(),k.__init__(),c.__init__())}get chunkDatas(){return this._chunkDatas}set chunkDatas(e){if(this._chunkDatas=e,e)for(const t in e){let i=e[t];for(const e in i){let t=i[e];t._tileLayer=this,t._updateChunkData(t.chunkX,t.chunkY),t._parseCellDataRefMap()}}this._boundsChange=!0}get layerColor(){return this._layerColor}set layerColor(e){e.cloneTo(this._layerColor),this._grid._updateColor(e)&&this._tileSet&&this._grid._updateBufferData()}get sortMode(){return this._sortMode}set sortMode(e){this._sortMode=e}get navigationEnable(){return this._navigationEnable}set navigationEnable(e){this._navigationEnable=e}get physicsEnable(){return this._physicsEnable}set physicsEnable(e){this._tileMapPhysics.updateState(e),this._physicsEnable=e}get lightOccluderEnable(){return this._lightOccluderEnable}set lightOccluderEnable(e){this._tileMapOccluder.updateState(e),this._lightOccluderEnable=e}get tileSet(){return this._tileSet}set tileSet(e){this._tileSet!=e&&(this._tileSet&&(this._tileSet._removeOwner(this),this._tileSet._removeReference()),this._tileSet=e,e&&(this._tileSet._addOwner(this),this._tileSet._addReference(),this._initialTileSet()))}get renderTileSize(){return this._renderTileSize}set renderTileSize(e){this._renderTileSize!==e&&(this._renderTileSize=e,this._updateChunkData())}get tileMapDatas(){return this._tileMapDatas}set tileMapDatas(e){this._tileMapDatas=e}get tileMapPhysics(){return this._tileMapPhysics}get tileMapOccluder(){return this._tileMapOccluder}constructor(){super(),this._layerColor=new t.Color,this._renderTileSize=32,this._needUpdateDirtys=[],this._layerColor=new t.Color(1,1,1,1),this._chunkDatas=[],this._grid=new v,this._chunk=new V(this._grid),this._chunk._setChunkSize(this._renderTileSize,this._renderTileSize),this._tileMapPhysics=new k(this),this._tileMapOccluder=new Q(this),this._cliper=new H,this._renderElements=[],this._materials=[],this.sortMode=e.TileLayerSortMode.ZINDEXSORT}_isMaterialVaild(e){return e.checkType(t.ShaderFeatureType.Effect)}_initialTileSet(){this._grid._updateTileShape(this._tileSet.tileShape,this._tileSet.tileSize),this._grid._updateColor(this._layerColor),this._grid._updateBufferData()}_updateChunkData(){var e;const i=Z;i.setValue(Number.MAX_VALUE,Number.MAX_VALUE);const a=$;a.setValue(-Number.MIN_VALUE,-Number.MIN_VALUE);let r=new Map,l=[];for(const e in this._chunkDatas){let t=this._chunkDatas[e];for(const e in t){let s=t[e];s._mergeBuffer(r,i,a),l.push(s)}}let s=this._renderTileSize;if(this._chunk._setChunkSize(s,s),i.x>a.x||i.y>a.y)return;this._chunkDatas=[];const n=t.Vector3.TEMP;this._chunk._getChunkPosByCell(i.x,i.y,n);let h=n.x,_=n.y;this._chunk._getChunkPosByCell(a.x,a.y,n);let o=n.x,g=n.y;for(var c=_;c<=g;c++)for(var d=h;d<=o;d++){let e=l.pop()||new I;e._tileLayer=this,e._updateChunkData(d,c),e._setBuffer(r,i,a,s)?this._setLayerDataByPos(e):l.push(e)}l.forEach(e=>e._destroy()),this._boundsChange=!0,null===(e=this.owner)||void 0===e||e.repaint()}_updateMapDatas(){var e;if(null==this._tileMapDatas||!this._tileMapDatas.length)return;let t=Y.read(this._tileMapDatas.buffer);for(var i=0,a=t.length;i<a;i++){let e=new I;e._tileLayer=this,e._setRenderData(t[i]),this._setLayerDataByPos(e)}null===(e=this.owner)||void 0===e||e.repaint()}_setLayerDataByPos(e){const t=e.chunkX,i=e.chunkY;let a=this._chunkDatas[i];a||(a=[],this._chunkDatas[i]=a),a[t]=e,this._boundsChange=!0}_getLayerDataTileByPos(e,t){let i=this._chunkDatas[t];i||(i=[],this._chunkDatas[t]=i);let a=i[e];return a||(a=new I,a._tileLayer=this,a._updateChunkData(e,t),i[e]=a,this._boundsChange=!0),a}onAwake(){super.onAwake(),this._updateMapDatas()}onEnable(){super.onEnable(),this.owner.globalTrans.cache=!0,this._tileMapOccluder._updateManager(),this._tileMapPhysics.enable&&this._tileMapPhysics.enableRigidBodys(),this._tileMapOccluder.enable&&this._tileMapOccluder.enableAllOccluders(),this.owner.on(t.Event.TRANSFORM_CHANGED,this,this._globalChangeHandler)}onDisable(){super.onDisable(),this._tileMapPhysics.enable&&this._tileMapPhysics.disableRigidBodys(),this._tileMapOccluder.enable&&this._tileMapOccluder._removeAllOccluders(),this.owner.off(t.Event.TRANSFORM_CHANGED,this,this._globalChangeHandler)}onDestroy(){super.onDestroy(),this._tileMapPhysics.destroy(),this._tileMapOccluder.destroy(),this.tileSet=null}_globalChangeHandler(){this._needUpdateDirtys[e.DirtyFlagType.PHYSICS]=!0}_globalTransfrom(){return this.owner.globalTrans.getMatrix()}addCMDCall(e,t){}get rect(){return this._boundsChange&&(this._calculateLayerRect(),this._boundsChange=!1),this._rect}_calculateLayerRect(){if(!this._chunkDatas||0===Object.keys(this._chunkDatas).length)return void this._rect.setValue(0,0,0,0);let e=Number.MAX_VALUE,t=Number.MAX_VALUE,i=Number.MIN_VALUE,a=Number.MIN_VALUE,r=!1;for(const l in this._chunkDatas){let s=this._chunkDatas[l];if(s)for(const l in s){let n=s[l];if(!n)continue;let h=n.getRange();h&&h.width>0&&h.height>0&&(r=!0,e=Math.min(e,h.x),t=Math.min(t,h.y),i=Math.max(i,h.x+h.width),a=Math.max(a,h.y+h.height))}}r?this._rect.setValue(e,t,i,a):this._rect.setValue(0,0,0,0)}renderUpdate(i){if(null==this._tileSet)return;const a=q,r=j;let l=this._globalTransfrom(),s=this.owner._ownerArea,n=null==s?void 0:s.mainCamera,h=0,_=0;if(null==n)r.setTo(0,0,t.RenderState2D.width,t.RenderState2D.height),l.copyTo(a),h=r.width/2,_=r.height/2;else{let e=n._rect;r.setTo(e.x,e.z,e.y-e.x,e.w-e.z);var o=n._getCameraTransform().elements;a.a=o[0],a.b=o[1],a.c=o[3],a.d=o[4],a.tx=o[6],a.ty=o[7],t.Matrix.mul(l,a,a)}let g=t.Vector2.TEMP;this._chunk._getChunkSize(g);let c=this._cliper.setClipper(r,g,a,h,_,0);this._renderElements.length=0;let d=this.tileSet.tileSize,u=t.Vector2.TEMP,T=t.Vector3.TEMP;this._chunk._getChunkPosByPixel(c.x-d.x,c.y-d.y,T);let p=T.x,y=T.y;this._chunk._getChunkPosByPixel(c.z+d.x,c.w+d.y,T);let f=T.x,C=T.y,E=!1;for(let e=y;e<=C;e++){if(!this._chunkDatas[e])continue;let t=this._chunkDatas[e];for(let i=p;i<=f;i++){let a=t[i];a&&(this._chunk._getChunkLeftTop(i,e,u),this._cliper.isClipper(u.x,u.y)||(E=E||a._needUpdateRange,a._update(),a._mergeToElement(this._renderElements)))}}this._boundsChange=E,this._tileMapPhysics.enable&&this._needUpdateDirtys[e.DirtyFlagType.PHYSICS]&&(this._tileMapPhysics._updateTransfrom(),this._needUpdateDirtys[e.DirtyFlagType.PHYSICS]=!1),this.owner._struct.renderElements=this._renderElements,this._updateLight()}setCellData(e,t,i,a=!0,r=0,l=!1,s=!1,n=!1){this._setCellData(e,t,i,C.getTransFlag(r,l,s,n),a)}_setCellData(e,i,a,r=0,l=!0){var s;if(null==a)return;let n=t.Vector3.TEMP;l?this._chunk._getChunkPosByPixel(e,i,n):this._chunk._getChunkPosByCell(e,i,n),this._getLayerDataTileByPos(n.x,n.y)._setCell(n.z,a,r),null===(s=this.owner)||void 0===s||s.repaint()}getCellData(e,i,a=!0){let r=t.Vector3.TEMP;a?this._chunk._getChunkPosByPixel(e,i,r):this._chunk._getChunkPosByCell(e,i,r);let l=this._chunkDatas[r.y];if(!l)return null;let s=l[r.x];return s?s.getCell(r.z):null}removeCell(e,i,a=!0){var r;let l=t.Vector3.TEMP;a?this._chunk._getChunkPosByPixel(e,i,l):this._chunk._getChunkPosByCell(e,i,l),this._getLayerDataTileByPos(l.x,l.y)._removeCell(l.z),null===(r=this.owner)||void 0===r||r.repaint()}pixelToGrid(e,t,i){this._grid._pixelToGrid(e,t,i)}gridToPixel(e,t,i){this._grid._gridToPixel(e,t,i)}getDefalutMaterial(e){return this.tileSet.getDefalutMaterial(e)}}J._inited=!1,t.Laya.addInitCallback(()=>J.__init__());let K=t.ClassUtils.regClass;K("TileSet",z),K("TileSetCellGroup",U),K("TileAlternativesData",O),K("TileSetCellData",x),K("TileMapLayer",J),K("TileMapChunkData",I),K("TileMapPhysics",k),K("TileSetPhysicsLayer",l),K("TileSetOcclusionLayer",r),K("TileSetTerrainSet",y),K("TileSetTerrain",f),K("TileMapNavigationLayer",a),K("TileSetCustomDataLayer",i),K("TileSetCellPhysicsInfo",D),K("TileSetCellNavigationInfo",S),K("TileSetCellOcclusionInfo",M),e.BaseSheet=N,e.ChunkCellInfo=R,e.DIRTY_TYPES=3,e.Grid=v,e.HalfOffSquareSheet=P,e.HeixSheet=A,e.IsometricSheet=w,e.RectClipper=H,e.RectSheet=F,e.TerrainRuleSet=T,e.TerrainVector2Set=p,e.TerrainsParams=E,e.TileAlternativesData=O,e.TileMapChunk=V,e.TileMapChunkData=I,e.TileMapDatasParse=Y,e.TileMapLayer=J,e.TileMapNavigationLayer=a,e.TileMapOccluder=X,e.TileMapOccluderAgent=Q,e.TileMapPhysics=k,e.TileMapShaderInit=m,e.TileMapTerrain=class{static fillConnect(e,t,i,a,r=!1){let l=e.tileSet,s=l.getTerrainSet(i);if(!s)return null;if(!s.getTerrain(a))return null;let n=c.getNeighborObject(l.tileShape),h=n.links,_=h.length,o=c.temp_vec2,g=new p,u=new p,y=new p,f=t.length;for(let e=f-1;e>-1;e--){let i=t[e].x,a=t[e].y,r=g.get(i,a,!0);u.get(i,a)||u.add(r),y.add(r)}for(let e=0;e<f;e++){let i=t[e].x,a=t[e].y;for(let e=0;e<_;e++){let t=h[e];n.getNeighborGird(i,a,t,o);let r=o.x,l=o.y;u.get(r,l)||u.add(g.get(r,l,!0))}}let C=new p;u.list.forEach(t=>{let r=t.x,l=t.y;if(y.get(r,l))C.add(g.get(r,l,!0));else{let s=c.getChunkCellInfo(e,t);if(s){let e=s.cell;e.terrainSet==i&&e.terrain==a&&C.add(g.get(r,l,!0))}}});let E=new T,M=s._neighbors,D=M.length;for(let e=0;e<f;e++){let i=t[e].x,r=t[e].y,l=new d(i,r,a,n);l.priority=10,E.add(l);for(let e=0;e<D;e++){let t=M[e],a=l.clone();if(a.setCellNeighbor(t),t%2==0)n.getNeighborGird(i,r,t,o),C.get(o.x,o.y)&&E.add(a);else{let e=new Map;n.getOverlap(a.x,a.y,a.data,g,e);let t=!0;e.forEach((e,i)=>{C.get(i.x,i.y)||(t=!1)}),t&&E.add(a)}}}return this.getReady2FillRule(e,n,i,M,y,g,r).list.forEach(e=>{E.add(e)}),this._fillRules(e,i,n,u,E)}static getReady2FillRule(e,t,i,a,r,l,s=!0){let n=a.length,h=new T;r.list.forEach(e=>{for(let i=0;i<n;i++){let r=new d(e.x,e.y,-1,t);r.setCellNeighbor(a[i]),h.add(r)}});let _=new T;return h.list.forEach(a=>{let r=[],n=new Map;t.getOverlap(a.x,a.y,a.data,l,n),n.forEach((t,a)=>{let l=null,n=c.getChunkCellInfo(e,a);if(n){let e=n.cell;e.terrainSet==i&&(l=e)}let h=l?l.terrain:-1;(!s||h>-1)&&(r[h]||(r[h]=0),r[h]++)});let h=0,o=-1;for(let e=-1,t=r.length;e<t;e++)r[e]>h&&(h=r[e],o=e);h>0&&(a.terrain=o,_.add(a))}),r.list.forEach(a=>{let r=c.getChunkCellInfo(e,a);if(s){if(r){let e=r.cell;if(e.terrainSet==i&&e.terrain>-1){let i=new d(a.x,a.y,e.terrain,t);_.add(i)}}}else{let e=new d(a.x,a.y,-1,t);_.add(e)}}),_}static _fillRules(e,t,i,a,r){let l=new Map;return a.list.forEach(a=>{let s=this._getBestTerrainParams(e,a,t,i,r);l.set(a,s)}),l.forEach((a,l)=>{let s=this._getRulesByParams(e,a,l,t,i);for(let e=0,t=s.list.length;e<t;e++){let t=s.list[e];r.delete(t.x,t.y,t.data),t.priority=5,r.add(t)}}),l}static _getBestTerrainParams(e,t,i,a,r){let l=e.tileSet.getTerrainSet(i);if(!l)return null;let s,n=c.getChunkCellInfo(e,t);n&&n.cell&&n.cell.terrainSet==i?s=n.cell.getTerrainsParams():(s=new E,s.terrainSet=i);let h=l._neighbors,_=h.length,o=e.tileSet._getParamsList(i),g=new Map,u=o.length;for(let e=-1;e<u;e++){let i=o[e];if(!i)continue;let l=i.length;for(let e=0;e<l;e++){let l=0,n=i[e],o=new d(t.x,t.y,n.terrain,a),c=r.get(t.x,t.y,o.data);if(c)c.terrain!=n.terrain&&(l+=c.priority);else if(n.terrain!=s.terrain)continue;let u=!1;for(let e=0;e<_;e++){let i=h[e],_=n.terrain_peering_bits[i],o=new d(t.x,t.y,_,a);o.setCellNeighbor(i);let g=r.get(o.x,o.y,o.data);if(g)g.terrain!=_&&(l+=g.priority);else if(_!=s.terrain_peering_bits[i]){u=!0;break}}u||g.set(n,l)}}let T,p=Number.MAX_VALUE;return g.forEach((e,t)=>{e<p&&(p=e,T=t)}),T||(T=o[-1][0]),T}static _getRulesByParams(e,t,i,a,r){let l=new T,s=new d(i.x,i.y,t.terrain,r);l.add(s);let n=e.tileSet.getTerrainSet(a),h=n._neighbors.length;for(let e=0;e<h;e++){let i=s.clone();i.terrain=t.terrain_peering_bits[n._neighbors[e]],i.setCellNeighbor(n._neighbors[e]),l.add(i)}return l}},e.TileMapTerrainRule=d,e.TileMapTerrainUtil=c,e.TileMapUtils=C,e.TileSet=z,e.TileSetCellData=x,e.TileSetCellGroup=U,e.TileSetCellNavigationInfo=S,e.TileSetCellOcclusionInfo=M,e.TileSetCellPhysicsInfo=D,e.TileSetCustomDataLayer=i,e.TileSetOcclusionLayer=r,e.TileSetPhysicsLayer=l,e.TileSetTerrain=f,e.TileSetTerrainSet=y,e.Vector2LikeSet=u}(window.Laya=window.Laya||{},Laya);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,t){"use strict";class r{static init(){t.TrailShaderCommon.init();let e=t.Shader3D.add("Trail2D",!1,!1);e.shaderType=t.ShaderFeatureType.D2_BaseRenderNode2D;let r=new t.SubShader(t.TrailShaderCommon.attributeMap,t.TrailShaderCommon.uniformMap,t.TrailShaderCommon.defaultValue);e.addSubShader(r),r.addShaderPass('#define SHADER_NAME Trail2DVS\n#include "Sprite2DVertex.glsl"\n#include "TrailVertexUtil.glsl"\nvoid main(){float normalizeTime=(u_CurTime-a_BirthTime)/u_LifeTime;v_Texcoord0=vec2(a_Texcoord0X,1.0-a_Texcoord0Y)*u_TilingOffset.xy+u_TilingOffset.zw;v_Color=a_Color;vec4 glPos;vec2 globalPos;vec2 trailPos=a_position.xy+a_OffsetVector.xy*getCurWidth(normalizeTime);getGlobalPos(trailPos,globalPos);vec2 viewPos;getViewPos(globalPos,viewPos);clip(viewPos);getProjectPos(viewPos,glPos);gl_Position=glPos;}','#define SHADER_NAME Trail2DFS\nvarying vec2 v_Texcoord0;varying vec4 v_Color;\n#include "Sprite2DFrag.glsl";\nvoid main(){vec4 color=v_Color;vec4 textureColor=texture2D(u_baseRender2DTexture,v_Texcoord0);textureColor=transspaceColor(textureColor);vec4 renderColor=u_baseRenderColor;\n#ifdef GAMMASPACE\nrenderColor=linearToGamma(renderColor);\n#endif\ncolor*=textureColor*renderColor;gl_FragColor=color;}');let a=i.defaultTrail2DMaterial=new t.Material;a.lock=!0,a.setShaderName("Trail2D"),a.alphaTest=!1,a.depthTest=t.RenderState.DEPTHTEST_OFF,a.cull=t.RenderState.CULL_NONE,a.blend=t.RenderState.BLEND_ENABLE_ALL,a.setIntByIndex(t.Shader3D.BLEND_SRC,t.RenderState.BLENDPARAM_SRC_ALPHA),a.setIntByIndex(t.Shader3D.BLEND_DST,t.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA)}}class i extends t.BaseRenderNode2D{get time(){return this._time}set time(e){this._time=e,this._trailFilter&&(this._trailFilter.time=e)}get minVertexDistance(){return this._trailFilter.minVertexDistance}set minVertexDistance(e){this._trailFilter.minVertexDistance=e}get widthMultiplier(){return this._widthMultiplier}set widthMultiplier(e){this._widthMultiplier=e,this._trailFilter&&(this._trailFilter.widthMultiplier=e)}get widthCurve(){return this._trailFilter.widthCurve}set widthCurve(e){this._trailFilter.widthCurve=e}get colorGradient(){return this._trailFilter.colorGradient}set colorGradient(e){this._trailFilter.colorGradient=e}get textureMode(){return this._trailFilter.textureMode}set textureMode(e){this._trailFilter.textureMode=e}set texture(e){e||(e=t.Texture2D.whiteTexture),e!=this._baseRender2DTexture&&(this._baseRender2DTexture&&this._baseRender2DTexture._removeReference(1),e._addReference(),this._baseRender2DTexture=e,this._spriteShaderData.setTexture(t.BaseRenderNode2D.BASERENDER2DTEXTURE,e),1!=e.gammaCorrection?this._spriteShaderData.addDefine(t.ShaderDefines2D.GAMMATEXTURE):this._spriteShaderData.removeDefine(t.ShaderDefines2D.GAMMATEXTURE))}get texture(){return this._baseRender2DTexture}set color(e){e!=this._color&&this._color.equal(e)||((e=e||t.Color.BLACK).cloneTo(this._color),this._spriteShaderData.setColor(t.BaseRenderNode2D.BASERENDER2DCOLOR,this._color))}get color(){return this._color}_isMaterialVaild(e){return e.checkType(t.ShaderFeatureType.Effect)}_getcommonUniformMap(){return["BaseRender2D","TrailRender"]}_onAdded(){super._onAdded(),this._trailFilter=new t.TrailBaseFilter(this._spriteShaderData),this._trailFilter.time=this._time,this._trailFilter.widthMultiplier=this._widthMultiplier,this._initRender()}_initRender(){let e=t.LayaGL.render2DRenderPassFactory.createRenderElement2D();e.geometry=this._trailFilter._trialGeometry._geometryElementOBj,e.value2DShaderData=this._spriteShaderData,e.renderStateIsBySprite=!1,e.nodeCommonMap=this._getcommonUniformMap(),e.owner=this.owner._struct,t.BaseRenderNode2D._setRenderElement2DMaterial(e,this._getElementMaterial(0)),this._renderElements[0]=e,this.owner._struct.renderElements=this._renderElements,this._renderHandle.needUseMatrix=!1}_getElementMaterial(e){return this._materials[e]||i.defaultTrail2DMaterial}onPreRender(){let e=this._trailFilter._curtime+=Math.min(t.Laya.timer.delta/1e3,.016),r=this._trailFilter._trialGeometry;this._spriteShaderData.setNumber(t.TrailShaderCommon.CURTIME,e);let i=t.Point.TEMP;this.owner.globalTrans.getPos(i);let a=t.Vector3.TEMP;a.set(i.x,i.y,0);let l=Math.max(Math.abs(this.owner.globalTrans.scaleX),Math.abs(this.owner.globalTrans.scaleY))||1;if(r._updateDisappear(e,this.time),!t.Vector3.equals(this._trailFilter._lastPosition,a))if(r._endIndex-r._activeIndex===0)r._addTrailByFirstPosition(a,e);else{var s=t.TrailGeometry._tempVector36,o=t.TrailGeometry._tempVector35;t.Vector3.subtract(a,r._lastFixedVertexPosition,s);var n=t.TrailGeometry._tempVector33;n.setValue(0,0,1),t.Vector3.cross(s,n,o),t.Vector3.normalize(o,o),t.Vector3.scale(o,this.widthMultiplier*l/2,o);var d=t.Vector3.scalarLength(s);r._addTrailByNextPosition(a,e,this.minVertexDistance*l,o,d)}r._updateVertexBufferUV(this.colorGradient,this.textureMode,50),a.cloneTo(this._trailFilter._lastPosition),r._disappearBoundsMode,r._updateRenderParams()}clear(){this._trailFilter.clear()}_initDefaultRenderData(){this._time=.5,this._widthMultiplier=50,this._spriteShaderData.setColor(t.BaseRenderNode2D.BASERENDER2DCOLOR,this._color),this._spriteShaderData.addDefine(t.BaseRenderNode2D.SHADERDEFINE_BASERENDER2D),this.texture=t.Texture2D.whiteTexture}constructor(){super(),this._color=new t.Color(1,1,1,1),this._renderElements=[],this._materials=[]}}t.Laya.addAfterInitCallback(()=>{i.defaultTrail2DMaterial||r.init()}),(0,t.ClassUtils.regClass)("Trail2DRender",i),e.Trail2DRender=i,e.Trail2DShaderInit=r}(window.Laya=window.Laya||{},Laya);
|