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 extends t.Material{static __initDefine__(){r.SHADERDEFINE_DIFFUSEMAP=t.Shader3D.getDefineByName("DIFFUSEMAP"),r.SHADERDEFINE_NORMALMAP=t.Shader3D.getDefineByName("NORMALMAP"),r.SHADERDEFINE_SPECULARMAP=t.Shader3D.getDefineByName("SPECULARMAP"),r.SHADERDEFINE_ENABLEVERTEXCOLOR=t.Shader3D.getDefineByName("ENABLEVERTEXCOLOR"),r.SHADERDEFINE_ENABLETRANSMISSION=t.Shader3D.getDefineByName("ENABLETRANSMISSION"),r.SHADERDEFINE_THICKNESSMAP=t.Shader3D.getDefineByName("THICKNESSMAP"),r.ALBEDOTEXTURE=t.Shader3D.propertyNameToID("u_DiffuseTexture"),r.NORMALTEXTURE=t.Shader3D.propertyNameToID("u_NormalTexture"),r.SPECULARTEXTURE=t.Shader3D.propertyNameToID("u_SpecularTexture"),r.ALBEDOCOLOR=t.Shader3D.propertyNameToID("u_DiffuseColor"),r.MATERIALSPECULAR=t.Shader3D.propertyNameToID("u_MaterialSpecular"),r.SHININESS=t.Shader3D.propertyNameToID("u_Shininess"),r.TILINGOFFSET=t.Shader3D.propertyNameToID("u_TilingOffset"),r.TRANSMISSIONRATE=t.Shader3D.propertyNameToID("u_TransmissionRate"),r.IBACKDIFFUSE=t.Shader3D.propertyNameToID("u_BackDiffuse"),r.IBACKSCALE=t.Shader3D.propertyNameToID("u_BackScale"),r.THINKNESSTEXTURE=t.Shader3D.propertyNameToID("u_ThinknessTexture"),r.TRANSMISSIONCOLOR=t.Shader3D.propertyNameToID("u_TransmissionColor"),r.AlbedoIntensity=t.Shader3D.propertyNameToID("u_AlbedoIntensity")}set renderMode(e){switch(e){case r.RENDERMODE_OPAQUE:this.alphaTest=!1,this.renderQueue=t.Material.RENDERQUEUE_OPAQUE,this.depthWrite=!0,this.cull=t.RenderState.CULL_BACK,this.blend=t.RenderState.BLEND_DISABLE,this.depthTest=t.RenderState.DEPTHTEST_LESS;break;case r.RENDERMODE_CUTOUT:this.renderQueue=t.Material.RENDERQUEUE_ALPHATEST,this.alphaTest=!0,this.depthWrite=!0,this.cull=t.RenderState.CULL_BACK,this.blend=t.RenderState.BLEND_DISABLE,this.depthTest=t.RenderState.DEPTHTEST_LESS;break;case r.RENDERMODE_TRANSPARENT:this.renderQueue=t.Material.RENDERQUEUE_TRANSPARENT,this.alphaTest=!1,this.depthWrite=!1,this.cull=t.RenderState.CULL_BACK,this.blend=t.RenderState.BLEND_ENABLE_ALL,this.blendSrc=t.RenderState.BLENDPARAM_SRC_ALPHA,this.blendDst=t.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA,this.depthTest=t.RenderState.DEPTHTEST_LESS;break;default:throw new Error("unknown renderMode: "+e)}}get enableVertexColor(){return this.hasDefine(r.SHADERDEFINE_ENABLEVERTEXCOLOR)}set enableVertexColor(e){e?this.addDefine(r.SHADERDEFINE_ENABLEVERTEXCOLOR):this.removeDefine(r.SHADERDEFINE_ENABLEVERTEXCOLOR)}get tilingOffset(){return this.getVector4ByIndex(r.TILINGOFFSET)}set tilingOffset(e){e?this.setVector4ByIndex(r.TILINGOFFSET,e):this.getVector4ByIndex(r.TILINGOFFSET).setValue(1,1,0,0)}get albedoColor(){return this.getColorByIndex(r.ALBEDOCOLOR)}set albedoColor(e){this.setColorByIndex(r.ALBEDOCOLOR,e)}get albedoIntensity(){return this.getFloatByIndex(r.AlbedoIntensity)}set albedoIntensity(e){this.setFloatByIndex(r.AlbedoIntensity,e)}get specularColor(){return this.getColorByIndex(r.MATERIALSPECULAR)}set specularColor(e){this.setColorByIndex(r.MATERIALSPECULAR,e)}get shininess(){return this.getFloatByIndex(r.SHININESS)}set shininess(e){e=Math.max(0,Math.min(1,e)),this.setFloatByIndex(r.SHININESS,e)}get albedoTexture(){return this.getTextureByIndex(r.ALBEDOTEXTURE)}set albedoTexture(e){e?this.addDefine(r.SHADERDEFINE_DIFFUSEMAP):this.removeDefine(r.SHADERDEFINE_DIFFUSEMAP),this.setTextureByIndex(r.ALBEDOTEXTURE,e)}get normalTexture(){return this.getTextureByIndex(r.NORMALTEXTURE)}set normalTexture(e){e?this.addDefine(r.SHADERDEFINE_NORMALMAP):this.removeDefine(r.SHADERDEFINE_NORMALMAP),this.setTextureByIndex(r.NORMALTEXTURE,e)}get specularTexture(){return this.getTextureByIndex(r.SPECULARTEXTURE)}set specularTexture(e){e?this.addDefine(r.SHADERDEFINE_SPECULARMAP):this.removeDefine(r.SHADERDEFINE_SPECULARMAP),this.setTextureByIndex(r.SPECULARTEXTURE,e)}get enableTransmission(){return this.hasDefine(r.SHADERDEFINE_ENABLETRANSMISSION)}set enableTransmission(e){e?this.addDefine(r.SHADERDEFINE_ENABLETRANSMISSION):this.removeDefine(r.SHADERDEFINE_ENABLETRANSMISSION)}get transmissionRata(){return this.getFloatByIndex(r.TRANSMISSIONRATE)}set transmissionRata(e){this.setFloatByIndex(r.TRANSMISSIONRATE,e)}get backDiffuse(){return this.getFloatByIndex(r.IBACKDIFFUSE)}set backDiffuse(e){this.setFloatByIndex(r.IBACKDIFFUSE,Math.max(e,1))}get backScale(){return this.getFloatByIndex(r.IBACKSCALE)}set backScale(e){this.setFloatByIndex(r.IBACKSCALE,e)}get thinknessTexture(){return this.getTextureByIndex(r.THINKNESSTEXTURE)}set thinknessTexture(e){e?this.addDefine(r.SHADERDEFINE_THICKNESSMAP):this.removeDefine(r.SHADERDEFINE_THICKNESSMAP),this.setTextureByIndex(r.THINKNESSTEXTURE,e)}get transmissionColor(){return this.getColorByIndex(r.TRANSMISSIONCOLOR)}set transmissionColor(e){this.setColorByIndex(r.TRANSMISSIONCOLOR,e)}get transmissionRate(){return this.getFloatByIndex(r.TRANSMISSIONRATE)}constructor(){super(),this.setShaderName("BLINNPHONG"),this.renderMode=r.RENDERMODE_OPAQUE}clone(){var e=new r;return this.cloneTo(e),e}cloneTo(e){super.cloneTo(e),e.albedoIntensity=this.albedoIntensity,e.enableVertexColor=this.enableVertexColor,this.albedoColor.cloneTo(e.albedoColor)}}var a;r.RENDERMODE_OPAQUE=0,r.RENDERMODE_CUTOUT=1,r.RENDERMODE_TRANSPARENT=2,e.PBRRenderQuality=void 0,(a=e.PBRRenderQuality||(e.PBRRenderQuality={}))[a.High=0]="High",a[a.Low=1]="Low";class i{static get defaultDFG(){return i._defaultDFG}static set defaultDFG(e){i._defaultDFG=e}static DefaultDfgTexture(){let e,r=t.Base64Tool.decode("Iz9SQURJQU5DRQojIGNtZ2VuCkZPUk1BVD0zMi1iaXRfcmxlX3JnYmUKR0FNTUE9MQpFWFBPU1VSRT0wCgotWSAxMjggK1ggMTI4CgICAIAJCwoKCQkICAcHAwcGBgMGBQUEBQUEBIQEhwOKAosBhwKQAbYAgPnz7ujj3djTzsvIxcK/vLq3tbOwrqyqqKakoqCenZuZl5aVk5KQj42Mi4mIh4aEg4KBgP78+vj29fPx7+3r6efl4+Lg393c2tnX1tTT0dDPzczKycjHxcTDwsG/vr28u7q5t7a1tLOysbCvrq2srKuqqainpqWkpKOioaCgn56dgJ+alpOQjYuIhoSCgH59e3l4dnV0cnFvbm1samloZ2ZlZGNiYWBfXl1cW1pZWFdXVlVUU6WkoqGfnpybmZiWlZOSkI+OjIuKiIeGhIOCgH9+fXt6eXh3dXRzcnFvbm1sa2ppZ2ZlZGNiYWBfXVxbWllYV1ZVVFNSUVBPTk1LSklIs4DNfwICAIAJCwoKCQkICAcHAwcGBgMGBQWDBYUEiAOKAosBhgKQAbYAgPnz7unj3tjTz8vIxcK/vbq4tbOxr6yqqKalo6GfnZuamJeVlJKRkI6Ni4qJh4aFhIOCgYD+/Pr49vTy8O7s6unn5ePi4N/d3NrZ19bU09LQz87My8rIx8bFxMLBwL++vby6ubi3trW0s7KxsK+ura2sq6qpqKempqWko6KioaCfgJ+al5OQjYuJhoSCgH99e3p4dnV0cnFwbm1sa2loZ2ZlZGNiYWBfXl1cW1pZWFdXVlVUU1KkoqGfnpybmZiWlZOSkI+OjIuKiIeGhIOCgH9+fXt6eXh2dXRzcnBvbm1sa2loZ2ZlZGNiYF9eXVxbWllYV1ZVVFJRUE9OTUxLSklItID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ine.getCapable(t.RenderCapable.Texture_FloatLinearFiltering);if(i&&n)e=new t.Texture2D(a.width,a.height,a.format,!1,!1,!1),e.setHDRData(a);else{e=new t.Texture2D(a.width,a.height,t.TextureFormat.R8G8B8A8,!1,!1,!1);let r=a.width*a.height,i=a.readScanLine(),n=new Uint8Array(4*r);for(let e=0;e<r;e++){let t=i[4*e],r=i[4*e+1],a=i[4*e+2],s=Math.max(t,r,a,1e-5),o=Math.max(1,255/s);o=Math.min(1,Math.max(0,o/255)),n[4*e]=255*Math.min(1,Math.max(0,t*o)),n[4*e+1]=255*Math.min(1,Math.max(0,r*o)),n[4*e+2]=255*Math.min(1,Math.max(0,a*o)),n[4*e+3]=255*o}e.setPixelsData(n,!1,!1)}e.lock=!0,e.wrapModeU=t.WrapMode.Clamp,e.wrapModeV=t.WrapMode.Clamp,e.anisoLevel=1,this._defaultDFG=e}}class n{static init(){n.DEFINE_EMISSION=t.Shader3D.getDefineByName("EMISSION"),n.DEFINE_CLEARCOAT=t.Shader3D.getDefineByName("CLEARCOAT"),n.DEFINE_CLEARCOAT_NORMAL=t.Shader3D.getDefineByName("CLEARCOAT_NORMAL"),n.DEFINE_ANISOTROPY=t.Shader3D.getDefineByName("ANISOTROPIC"),n.DEFINE_IOR=t.Shader3D.getDefineByName("IOR"),n.DEFINE_IRIDESCENCE=t.Shader3D.getDefineByName("IRIDESCENCE"),n.DEFINE_SHEEN=t.Shader3D.getDefineByName("SHEEN"),n.DEFINE_TRANSMISSION=t.Shader3D.getDefineByName("TRANSMISSION"),n.DEFINE_THICKNESS=t.Shader3D.getDefineByName("THICKNESS"),t.Shader3D.addInclude("BRDF.glsl","#if !defined(BRDF)\n#define BRDF\nfloat D_GGX(float roughness,float NoH,vec3 h,vec3 n){\n#if !defined(GL_FRAGMENT_PRECISION_HIGH)\nvec3 NxH=cross(n,h);float oneMinusNoHSquared=dot(NxH,NxH);\n#else\nfloat oneMinusNoHSquared=1.0-NoH*NoH;\n#endif\nfloat a=NoH*roughness;float k=roughness/(oneMinusNoHSquared+a*a);float d=k*k*INVERT_PI;return saturateMediump(d);}float D_GGX_Anisotropic(float NoH,const vec3 h,const vec3 t,const vec3 b,float at,float ab){float ToH=dot(t,h);float BoH=dot(b,h);float a2=at*ab;highp vec3 v=vec3(ab*ToH,at*BoH,a2*NoH);highp float v2=dot(v,v);float w2=a2/v2;return a2*w2*w2*INVERT_PI;}float D_Charlie(float roughness,float NoH){float invR=1.0/roughness;float cos2h=NoH*NoH;float sin2h=max(1.0-cos2h,0.0078125);return(2.0+invR)*pow(sin2h,invR*0.5)*0.5*INVERT_PI;}float V_SmithGGXCorrelated(float roughness,float NoV,float NoL){float a2=roughness*roughness;float lambdaV=NoL*sqrt((NoV-a2*NoV)*NoV+a2);float lambdaL=NoV*sqrt((NoL-a2*NoL)*NoL+a2);float v=0.5/(lambdaV+lambdaL);return saturateMediump(v);}float V_SmithGGXCorrelated_Fast(float roughness,float NoV,float NoL){float v=0.5/mix(2.0*NoL*NoV,NoL+NoV,roughness);return saturateMediump(v);}float V_kelemen(float LoH){return saturateMediump(0.25/(LoH*LoH));}float lCharlieNumericHelper(float x,float alphaG){float oneMinusAlphaSq=(1.0-alphaG)*(1.0-alphaG);float a=mix(21.5473,25.3245,oneMinusAlphaSq);float b=mix(3.82987,3.32435,oneMinusAlphaSq);float c=mix(0.19823,0.16801,oneMinusAlphaSq);float d=mix(-1.97760,-1.27393,oneMinusAlphaSq);float e=mix(-4.32054,-4.85967,oneMinusAlphaSq);return a/(1.0+b*pow(x,c))+d*x+e;}float lCharlie(float cosTheta,float alphaG){if(abs(cosTheta)<0.5){return exp(lCharlieNumericHelper(cosTheta,alphaG));}else{return exp(2.0*lCharlieNumericHelper(0.5,alphaG)-lCharlieNumericHelper(1.0-cosTheta,alphaG));}}float V_Charlie(float NoL,float NoV,float roughness){float alphaG=roughness*roughness;return clamp(1.0/((1.0+lCharlie(NoV,alphaG)+lCharlie(NoL,alphaG))*(4.0*NoV*NoL)),0.0,1.0);}float V_Neubelt(float NoV,float NoL){return saturateMediump(1.0/(4.0*(NoL+NoV-NoL*NoV)));}float V_SmithGGXCorrelated_Anisotropic(float at,float ab,float ToV,float BoV,float ToL,float BoL,float NoV,float NoL){float lambdaV=NoL*length(vec3(at*ToV,ab*BoV,NoV));float lambdaL=NoV*length(vec3(at*ToL,ab*BoL,NoL));float v=0.5/(lambdaV+lambdaL);return saturateMediump(v);}vec3 F_Schlick(vec3 f0,float f90,float VoH){return f0+(f90-f0)*pow5(1.0-VoH);}vec3 F_Schlick(vec3 f0,float VoH){return f0+(1.0-f0)*pow5(1.0-VoH);}float F_Schlick(float f0,float f90,float VoH){return f0+(f90-f0)*pow5(1.0-VoH);}float F_Schlick(float f0,float VoH){return f0+(1.0-f0)*pow5(1.0-VoH);}vec3 F_Schlick(vec3 f0,vec3 f90,float VoH){return f0+(f90-f0)*pow5(1.0-VoH);}\n#ifdef IRIDESCENCE\nconst mat3 XYZ_to_REC709_MAT=mat3(vec3(3.2409699419,-0.9692436363,0.0556300797),vec3(-1.5373831776,1.8759675015,-0.2039769589),vec3(-0.498610760,0.0415550574,1.0569715142));float IorToFresnel0(float iorT,float iorI){return pow2((iorT-iorI)/(iorT+iorI));}vec3 IorToFresnel0(vec3 iorT,float iorI){return pow2((iorT-vec3(iorI))/(iorT+vec3(iorI)));}vec3 Fresnel0ToIor(vec3 f0){vec3 sqrtF0=sqrt(f0);return(1.0+sqrtF0)/(1.0-sqrtF0);}vec3 evalSensitivity(float OPD,vec3 shift){float phase=2.0*PI*OPD*1.0e-9;vec3 val=vec3(5.4856e-13,4.4201e-13,5.2481e-13);vec3 pos=vec3(1.6810e+06,1.7953e+06,2.2084e+06);vec3 var=vec3(4.3278e+09,9.3046e+09,6.6121e+09);vec3 xyz=val*sqrt(2.0*PI*var)*cos(pos*phase+shift)*exp(-pow2(phase)*var);xyz.x+=9.7470e-14*sqrt(2.0*PI*4.5282e+09)*cos(2.2399e+06*phase+shift[0])*exp(-4.5282e+09*pow2(phase));xyz/=1.0685e-7;vec3 srgb=XYZ_to_REC709_MAT*xyz;return srgb;}vec3 evalIridescence(float outsideIOR,float eta2,float cosTheta1,float thinFilmThickness,vec3 baseF0){vec3 I;float iridescenceIor=mix(outsideIOR,eta2,smoothstep(0.0,0.03,thinFilmThickness));float sinTheta2Sq=pow2(outsideIOR/iridescenceIor)*(1.0-pow2(cosTheta1));float cosTheta2Sq=1.0-sinTheta2Sq;if(cosTheta2Sq<0.0){return vec3(1.0);}float cosTheta2=sqrt(cosTheta2Sq);float R0=IorToFresnel0(iridescenceIor,outsideIOR);float R12=F_Schlick(R0,cosTheta1);float R21=R12;float T121=1.0-R12;float phi12=0.0;if(iridescenceIor<outsideIOR)phi12=PI;float phi21=PI-phi12;vec3 baseIOR=Fresnel0ToIor(clamp(baseF0,0.0,0.9999));vec3 R1=IorToFresnel0(baseIOR,iridescenceIor);vec3 R23=F_Schlick(R1,cosTheta2);vec3 phi23=vec3(0.0);if(baseIOR[0]<iridescenceIor)phi23[0]=PI;if(baseIOR[1]<iridescenceIor)phi23[1]=PI;if(baseIOR[2]<iridescenceIor)phi23[2]=PI;float OPD=2.0*iridescenceIor*thinFilmThickness*cosTheta2;vec3 phi=vec3(phi21)+phi23;vec3 R123=clamp(R12*R23,1e-5,0.9999);vec3 r123=sqrt(R123);vec3 Rs=pow2(T121)*R23/(vec3(1.0)-R123);vec3 C0=R12+Rs;I=C0;vec3 Cm=Rs-T121;for(int m=1;m<=2;++m){Cm*=r123;vec3 Sm=2.0*evalSensitivity(float(m)*OPD,float(m)*phi);I+=Cm*Sm;}return max(I,vec3(0.0));}\n#endif\nfloat distribution(float roughness,float NoH,vec3 h,vec3 n){return D_GGX(roughness,NoH,h,n);}float visibility(float roughness,float NoV,float NoL){return V_SmithGGXCorrelated(roughness,NoV,NoL);}vec3 fresnel(vec3 f0,float LoH){float f90=saturate(dot(f0,vec3(50.0*0.33)));return F_Schlick(f0,f90,LoH);}vec3 fresnel(vec3 f0,vec3 f90,float LoH){return F_Schlick(f0,f90,LoH);}float Fd_Lambert(){return 1.0;}float Fd_Burley(float roughness,float NoV,float NoL,float LoH){float f90=0.5+2.0*roughness*LoH*LoH;float lightScatter=F_Schlick(1.0,f90,NoL);float veiwScatter=F_Schlick(1.0,f90,NoV);return lightScatter*veiwScatter*INVERT_PI;}\n#ifdef IRIDESCENCE\nvec3 Fd_IridescenceLambert(vec3 f0,vec3 f90,vec3 iridescenceFresnel,float iridescenceFactor,float VoH){vec3 iridescenceFresnelMax=vec3(vecmax(iridescenceFresnel));vec3 schlickFresnel=F_Schlick(f0,f90,VoH);vec3 F=mix(schlickFresnel,iridescenceFresnelMax,iridescenceFactor);return(1.0-F)*Fd_Lambert();}\n#endif\n#endif\n"),t.Shader3D.addInclude("PBRGI.glsl",'#if !defined(pbrGI_lib)\n#define pbrGI_lib\n#include "globalIllumination.glsl";\n#ifdef ANISOTROPIC\nvec3 anisotropyBentNormal(const in Surface surface,const in PixelInfo info){float anisotropy=surface.anisotropy;vec3 anisotropyDirection=info.anisotropicB;vec3 n=info.normalWS;vec3 v=info.viewDir;float roughness=surface.perceptualRoughness;vec3 anisotropicTangent=cross(anisotropyDirection,v);vec3 anisotropicNormal=cross(anisotropicTangent,anisotropyDirection);float bendFactor=1.0-anisotropy*(1.0-roughness);float bendFactorPow4=pow2(bendFactor)*pow2(bendFactor);vec3 bentNormal=normalize(mix(anisotropicNormal,n,bendFactorPow4));return bentNormal;}\n#endif\nvec3 getReflectedVector(const in vec3 n,const in vec3 v,const in vec3 positionWS){vec3 r;r=reflect(-v,n);\n#ifdef SPECCUBE_BOX_PROJECTION\nr=getBoxProjectionReflectedVector(r,positionWS);\n#endif\nreturn r;}\n#ifdef IRIDESCENCE\nvoid iridescenceIBL(const in Surface surface,const in PixelInfo info,in vec3 E,inout vec3 Fd,inout vec3 Fr){vec3 dfg=info.dfg;float NoV=info.NoV;vec3 n=info.normalWS;vec3 v=info.viewDir;vec3 positionWS=info.positionWS;vec3 iridescenceFresnel=info.iridescenceFresnel;vec3 diffuseColor=surface.diffuseColor;float roughness=surface.perceptualRoughness;float occlusion=surface.occlusion;float iridescenceFactor=surface.iridescence;vec3 irradiance=diffuseIrradiance(n,positionWS,info.viewDir);Fd+=diffuseColor*irradiance*(1.0-E)*occlusion;vec3 iridescenceF0=mix(surface.f0,iridescenceFresnel,vec3(iridescenceFactor));vec3 Er=mix(dfg.xxx,dfg.yyy,iridescenceF0);\n#ifdef ANISOTROPIC\nvec3 bentNormal=anisotropyBentNormal(surface,info);vec3 r=getReflectedVector(bentNormal,v,positionWS);\n#else\nvec3 r=getReflectedVector(n,v,positionWS);\n#endif\nvec3 indirectSpecular=specularRadiance(r,roughness);Fr+=Er*indirectSpecular*occlusion*(1.0+Er*(1.0/dfg.y-1.0));}\n#endif\n#ifdef SHEEN\nvoid sheenIBL(const in Surface surface,const in PixelInfo info,inout vec3 Fd,inout vec3 Fr){vec3 v=info.viewDir;vec3 n=info.normalWS;vec3 positionWS=info.positionWS;float occlusion=surface.occlusion;float roughness=surface.sheenPerceptualRoughness;Fd*=info.sheenScaling;Fr*=info.sheenScaling;vec3 r=getReflectedVector(n,v,positionWS);vec3 indirectSpecular=specularRadiance(r,roughness);Fr+=indirectSpecular*info.sheenDfg*surface.sheenColor*occlusion;}\n#endif\n#ifdef CLEARCOAT\nvoid clearCoatIBL(const in Surface surface,const in PixelInfo info,inout vec3 Fd,inout vec3 Fr){vec3 v=info.viewDir;vec3 n=info.clearCoatNormal;float NoV=info.clearCoatNoV;vec3 positionWS=info.positionWS;float clearCoat=surface.clearCoat;float roughness=surface.clearCoatPerceptualRoughness;float occlusion=surface.occlusion;float Fc=F_Schlick(0.04,1.0,NoV)*clearCoat;float attenuation=1.0-Fc;Fd*=attenuation;Fr*=attenuation;vec3 r=getReflectedVector(n,v,positionWS);vec3 indirectSpecular=specularRadiance(r,roughness);Fr+=indirectSpecular*Fc*occlusion;}\n#endif\n#ifdef TRANSMISSION\nvec3 getRefraction(const in Surface surface,const in PixelInfo info){vec3 position=info.positionWS;\n#ifdef THICKNESS\nvec3 n=info.normalWS;vec3 r=-info.viewDir;float airIOR=1.0;float etaIR=airIOR/surface.ior;vec3 refractionV=normalize(refract(r,n,etaIR))*surface.thickness*info.worldScale.xyz;position+=refractionV;\n#endif\nvec4 p=u_ViewProjection*vec4(position,1.0);vec2 refractionUV=(p.xy/p.w)*0.5+0.5;float refractionLOD=u_OpaqueTextureParams.z*surface.perceptualRoughness*saturate(surface.ior*2.0-2.0);vec3 refraction=texture2DLodEXT(u_CameraOpaqueTexture,refractionUV,refractionLOD).xyz;return refraction;}vec3 transmissionIBL(const in Surface surface,const in PixelInfo info,in vec3 E){vec3 refraction=getRefraction(surface,info);\n#ifndef THICKNESS\nE*=1.0+surface.transmission*(1.0-E.g)/(1.0+E.g);\n#endif\n#ifdef THICKNESS\nvec3 attenuationColor=surface.attenuationColor;float attenuationDistance=surface.attenuationDistance;vec3 absorption=-log(attenuationColor)/(attenuationDistance);vec3 T=exp(-absorption*info.worldScale.xyz*surface.thickness);\n#endif\nvec3 Ft=refraction;Ft*=surface.diffuseColor;Ft*=1.0-E;\n#ifdef THICKNESS\nFt*=T;\n#endif\nreturn Ft*surface.transmission;}\n#endif\nvoid baseIBL(const in Surface surface,const in PixelInfo info,in vec3 E,inout vec3 Fd,inout vec3 Fr){vec3 dfg=info.dfg;float NoV=info.NoV;vec3 n=info.normalWS;vec3 v=info.viewDir;vec3 positionWS=info.positionWS;vec3 diffuseColor=surface.diffuseColor;float roughness=surface.perceptualRoughness;float occlusion=surface.occlusion;\n#ifdef ANISOTROPIC\nvec3 bentNormal=anisotropyBentNormal(surface,info);vec3 r=getReflectedVector(bentNormal,v,positionWS);\n#else\nvec3 r=getReflectedVector(n,v,positionWS);\n#endif\nvec3 indirectSpecular=specularRadiance(r,roughness);float specularAO=occlusion;Fr+=E*indirectSpecular*specularAO*info.energyCompensation;\n#if defined(USELIGHTMAP)\nvec2 lightmapUV=info.lightmapUV;vec3 bakedlight=getBakedLightmapColor(lightmapUV,n);Fd+=bakedlight*diffuseColor;\n#else\nvec3 irradiance=diffuseIrradiance(n,positionWS,info.viewDir);Fd+=diffuseColor*irradiance*(1.0-E)*occlusion;\n#endif\n}vec3 getE(const in Surface surface,const in PixelInfo info){\n#ifdef IRIDESCENCE\nvec3 dfg=info.dfg;float NoV=info.NoV;vec3 iridescenceFresnel=info.iridescenceFresnel;vec3 f0=surface.f0;float iridescenceFactor=surface.iridescence;vec3 iridescenceFresnelMax=vec3(vecmax(iridescenceFresnel));vec3 schlickFresnel=F_Schlick(f0,vec3(1.0),NoV);vec3 F=mix(schlickFresnel,iridescenceFresnelMax,iridescenceFactor);vec3 E=mix(dfg.xxx,dfg.yyy,F);\n#else\nvec3 dfg=info.dfg;vec3 f0=surface.f0;vec3 f90=surface.f90;vec3 E=(f90-f0)*dfg.x+f0*dfg.y;\n#endif\nreturn E;}vec3 PBRGI(const in Surface surface,const in PixelInfo info){vec3 Fd=vec3(0.0);vec3 Fr=vec3(0.0);vec3 E=getE(surface,info);\n#ifdef IRIDESCENCE\niridescenceIBL(surface,info,E,Fd,Fr);\n#else\nbaseIBL(surface,info,E,Fd,Fr);\n#endif\n#ifdef SHEEN\nsheenIBL(surface,info,Fd,Fr);\n#endif\n#ifdef CLEARCOAT\nclearCoatIBL(surface,info,Fd,Fr);\n#endif\n#ifdef TRANSMISSION\nFd*=(1.0-surface.transmission);vec3 Ft=transmissionIBL(surface,info,E);\n#endif\nvec3 gi=Fd+Fr;\n#ifdef TRANSMISSION\ngi+=Ft;\n#endif\nreturn gi;}\n#endif\n'),t.Shader3D.addInclude("PBRCommon.glsl","#if !defined(pbrCommon_lib)\n#define pbrCommon_lib\nvarying vec3 v_PositionWS;varying vec3 v_NormalWS;varying vec3 v_TangentWS;varying vec3 v_BiNormalWS;\n#ifdef UV\nvarying vec2 v_Texcoord0;\n#endif\n#ifdef UV1\n#ifdef LIGHTMAP\nvarying vec2 v_Texcoord1;\n#endif\n#endif\n#ifdef COLOR\nvarying vec4 v_VertexColor;\n#endif\nstruct PixelParams{vec3 positionWS;vec3 normalWS;vec3 tangentWS;vec3 biNormalWS;mat3 TBN;\n#ifdef UV\nvec2 uv0;\n#endif\n#ifdef UV1\n#ifdef LIGHTMAP\nvec2 uv1;\n#endif\n#endif\n#ifdef COLOR\nvec4 vertexColor;\n#endif\n};\n#endif\n"),t.Shader3D.addInclude("PBRVertex.glsl",'#if !defined(pbrVertex_lib)\n#define pbrVertex_lib\n#include "ShadingVertex.glsl";\n#ifdef THICKNESS\nvarying vec4 v_WorldScale;\n#endif\nvoid initPixelParams(inout PixelParams params,in Vertex vertex){shadingPixelParams(params,vertex);sharePixelParams(params);\n#ifdef THICKNESS\nmat4 worldMat=getWorldMatrix();v_WorldScale.x=length(vec3(worldMat[0].xyz));v_WorldScale.y=length(vec3(worldMat[1].xyz));v_WorldScale.z=length(vec3(worldMat[2].xyz));v_WorldScale.w=length(v_WorldScale.xyz);\n#endif\n}\n#endif\n'),t.Shader3D.addInclude("PBRFrag.glsl",'\n#if !defined(pbrFrag_lib)\n#define pbrFrag_lib\n#include "PBRLighting.glsl";\n#ifdef THICKNESS\nvarying vec4 v_WorldScale;\n#endif\nvoid getPixelInfo(inout PixelInfo info,const in PixelParams pixel,const in Surface surface){info.positionWS=pixel.positionWS;info.vertexNormalWS=pixel.normalWS;\n#ifdef TANGENT\ninfo.normalWS=normalize(pixel.TBN*surface.normalTS);\n#else\ninfo.normalWS=pixel.normalWS;\n#endif\ninfo.tangentWS=pixel.tangentWS;info.biNormalWS=pixel.biNormalWS;info.viewDir=normalize(u_CameraPos-info.positionWS);info.NoV=min(max(dot(info.normalWS,info.viewDir),MIN_N_DOT_V),1.0);info.dfg=prefilteredDFG_LUT(surface.perceptualRoughness,info.NoV);\n#ifdef SHEEN\ninfo.energyCompensation=vec3(1.0);\n#else\ninfo.energyCompensation=(1.0+surface.f0*(1.0/info.dfg.y-1.0));\n#endif\n#ifdef IRIDESCENCE\ninfo.iridescenceFresnel=evalIridescence(1.0,surface.iridescenceIor,info.NoV,surface.iridescenceThickness,surface.f0);\n#endif\n#ifdef SHEEN\ninfo.sheenDfg=prefilteredDFG_LUT(surface.sheenPerceptualRoughness,info.NoV).z;info.sheenScaling=1.0-vecmax(surface.sheenColor)*info.sheenDfg;\n#endif\n#ifdef CLEARCOAT\n#ifdef CLEARCOAT_NORMAL\ninfo.clearCoatNormal=normalize(pixel.TBN*surface.clearCoatNormalTS);\n#else\ninfo.clearCoatNormal=info.vertexNormalWS;\n#endif\ninfo.clearCoatNoV=min(max(dot(info.clearCoatNormal,info.viewDir),MIN_N_DOT_V),1.0);\n#endif\n#ifdef ANISOTROPIC\nmat3 anisotropyTBN=mat3(info.tangentWS,info.biNormalWS*-1.0,info.normalWS);info.anisotropicT=anisotropyTBN*normalize(vec3(surface.anisotropyDirection,0.0));info.anisotropicB=cross(info.vertexNormalWS,info.anisotropicT);info.ToV=dot(info.anisotropicT,info.viewDir);info.BoV=dot(info.anisotropicB,info.viewDir);info.at=mix(surface.roughness,1.0,pow2(surface.anisotropy));info.ab=surface.roughness;\n#endif\n#ifdef THICKNESS\ninfo.worldScale=v_WorldScale;\n#endif\n#ifdef LIGHTMAP\n#ifdef UV1\ninfo.lightmapUV=pixel.uv1;\n#endif\n#endif\n}vec3 PBRLighting(const in Surface surface,const in PixelInfo info){vec3 lightColor=vec3(0.0);\n#ifdef DIRECTIONLIGHT\nfor(int i=0;i<CalculateLightCount;i++){if(i>=DirectionCount)break;DirectionLight directionLight=getDirectionLight(i,info.positionWS);if(directionLight.lightMode==LightMode_Mix){continue;}Light light=getLight(directionLight);lightColor+=PBRLighting(surface,info,light)*light.attenuation;}\n#endif\n#if defined(POINTLIGHT) || defined(SPOTLIGHT)\nivec4 clusterInfo=getClusterInfo(u_View,u_Viewport,info.positionWS,gl_FragCoord,u_ProjectionParams);\n#endif\n#ifdef POINTLIGHT\nfor(int i=0;i<CalculateLightCount;i++){if(i>=clusterInfo.x)break;PointLight pointLight=getPointLight(i,clusterInfo,info.positionWS);if(pointLight.lightMode==LightMode_Mix){continue;}Light light=getLight(pointLight,info.normalWS,info.positionWS);lightColor+=PBRLighting(surface,info,light)*light.attenuation;}\n#endif\n#ifdef SPOTLIGHT\nfor(int i=0;i<CalculateLightCount;i++){if(i>=clusterInfo.y)break;SpotLight spotLight=getSpotLight(i,clusterInfo,info.positionWS);if(spotLight.lightMode==LightMode_Mix){continue;}Light light=getLight(spotLight,info.normalWS,info.positionWS);lightColor+=PBRLighting(surface,info,light)*light.attenuation;}\n#endif\nvec3 giColor=PBRGI(surface,info);vec3 color=lightColor+giColor;\n#ifdef EMISSION\ncolor+=surface.emissionColor;\n#endif\nreturn color;}\n#endif\n'),i.DefaultDfgTexture(),t.SubShader.regIncludeBindUnifrom("PBRGI.glsl",{u_IBLDFG:t.ShaderDataType.Texture2D},{u_IBLDFG:i.defaultDFG}),t.Shader3D.addInclude("PBRMetallicFrag.glsl",'#if !defined(PBRMetallic_lib)\n#define PBRMetallic_lib\n#include "ShadingFrag.glsl";\n#include "PBRFrag.glsl";\n#ifdef LAYA_MRT\n#if !defined(GBUFFER_OUTPUTS_CONFIGURED)\n#define GBUFFER_NORMAL\n#define GBUFFER_ALBEDO\n#define GBUFFER_SURFACE\n#endif\n#include "GBuffer.glsl";\n#endif\nstruct SurfaceInputs{vec3 diffuseColor;float alpha;float alphaTest;float metallic;float smoothness;float occlusion;vec3 emissionColor;vec3 normalTS;\n#ifdef CLEARCOAT\nfloat clearCoat;float clearCoatRoughness;\n#ifdef CLEARCOAT_NORMAL\nvec3 clearCoatNormalTS;\n#endif\n#endif\n#ifdef ANISOTROPIC\nfloat anisotropy;vec2 anisotropyDirection;\n#endif\n};void initSurface(inout Surface surface,const in SurfaceInputs inputs,const in PixelParams pixel){surface.alpha=inputs.alpha;surface.normalTS=inputs.normalTS;vec3 baseColor=inputs.diffuseColor;float metallic=inputs.metallic;float perceptualRoughness=1.0-inputs.smoothness;float ior=1.5;surface.ior=1.5;vec3 f0=vec3(0.04,0.04,0.04);surface.perceptualRoughness=clamp(perceptualRoughness,MIN_PERCEPTUAL_ROUGHNESS,1.0);surface.roughness=surface.perceptualRoughness*surface.perceptualRoughness;surface.diffuseColor=computeDiffuse(baseColor,metallic);surface.f0=computeF0(f0,baseColor,metallic);surface.f90=computeF90(surface.f0);surface.occlusion=inputs.occlusion;\n#ifdef EMISSION\nsurface.emissionColor=inputs.emissionColor;\n#endif\n#ifdef CLEARCOAT\nsurface.clearCoat=inputs.clearCoat;surface.clearCoatPerceptualRoughness=clamp(inputs.clearCoatRoughness,MIN_PERCEPTUAL_ROUGHNESS,1.0);surface.clearCoatRoughness=surface.clearCoatPerceptualRoughness*surface.clearCoatPerceptualRoughness;\n#ifdef CLEARCOAT_NORMAL\nsurface.clearCoatNormalTS=inputs.clearCoatNormalTS;\n#endif\n#endif\n#ifdef ANISOTROPIC\nsurface.anisotropy=inputs.anisotropy;surface.anisotropyDirection=inputs.anisotropyDirection;\n#endif\n}vec4 PBR_Metallic_Flow(const in SurfaceInputs inputs,in PixelParams pixel){\n#ifdef ALPHATEST\nif(inputs.alpha<inputs.alphaTest){discard;}\n#endif\nSurface surface;initSurface(surface,inputs,pixel);PixelInfo info;getPixelInfo(info,pixel,surface);\n#ifdef LAYA_MRT\nwriteGBuffer(info.normalWS,inputs.diffuseColor,inputs.metallic,surface.perceptualRoughness,surface.occlusion);\n#endif\nvec3 surfaceColor=vec3(0.0);surfaceColor+=PBRLighting(surface,info);return vec4(surfaceColor,surface.alpha);}\n#endif\n')}}var s,o,l,h,d,c,u;e.PBRRenderMode=void 0,(s=e.PBRRenderMode||(e.PBRRenderMode={}))[s.Opaque=0]="Opaque",s[s.Cutout=1]="Cutout",s[s.Fade=2]="Fade",s[s.Transparent=3]="Transparent";class _ extends t.Material{static __init__(){_.SHADERDEFINE_ALBEDOTEXTURE=t.Shader3D.getDefineByName("ALBEDOTEXTURE"),_.SHADERDEFINE_NORMALTEXTURE=t.Shader3D.getDefineByName("NORMALTEXTURE"),_.SHADERDEFINE_PARALLAXTEXTURE=t.Shader3D.getDefineByName("PARALLAXTEXTURE"),_.SHADERDEFINE_OCCLUSIONTEXTURE=t.Shader3D.getDefineByName("OCCLUSIONTEXTURE"),_.SHADERDEFINE_EMISSIONTEXTURE=t.Shader3D.getDefineByName("EMISSIONTEXTURE"),_.SHADERDEFINE_TRANSPARENTBLEND=t.Shader3D.getDefineByName("TRANSPARENTBLEND"),_.SHADERDEFINE_LAYA_PBR_BRDF_HIGH=t.Shader3D.getDefineByName("LAYA_PBR_BRDF_HIGH"),_.SHADERDEFINE_LAYA_PBR_BRDF_LOW=t.Shader3D.getDefineByName("LAYA_PBR_BRDF_LOW"),_.SHADERDEFINE_DETAILALBEDO=t.Shader3D.getDefineByName("DETAILTEXTURE"),_.SHADERDEFINE_DETAILNORMAL=t.Shader3D.getDefineByName("DETAILNORMAL"),_.SHADERDEFINE_ENABLEVERTEXCOLOR=t.Shader3D.getDefineByName("ENABLEVERTEXCOLOR"),_.ALBEDOTEXTURE=t.Shader3D.propertyNameToID("u_AlbedoTexture"),_.ALBEDOCOLOR=t.Shader3D.propertyNameToID("u_AlbedoColor"),_.TILINGOFFSET=t.Shader3D.propertyNameToID("u_TilingOffset"),_.NORMALTEXTURE=t.Shader3D.propertyNameToID("u_NormalTexture"),_.NORMALSCALE=t.Shader3D.propertyNameToID("u_NormalScale"),_.SMOOTHNESS=t.Shader3D.propertyNameToID("u_Smoothness"),_.OCCLUSIONTEXTURE=t.Shader3D.propertyNameToID("u_OcclusionTexture"),_.OCCLUSIONSTRENGTH=t.Shader3D.propertyNameToID("u_OcclusionStrength"),_.PARALLAXTEXTURE=t.Shader3D.propertyNameToID("u_ParallaxTexture"),_.PARALLAXSCALE=t.Shader3D.propertyNameToID("u_ParallaxScale"),_.EMISSIONTEXTURE=t.Shader3D.propertyNameToID("u_EmissionTexture"),_.EMISSIONCOLOR=t.Shader3D.propertyNameToID("u_EmissionColor"),_.EMISSIONIntensity=t.Shader3D.propertyNameToID("u_EmissionIntensity"),_.DETAILALBEDOTEXTURE=t.Shader3D.propertyNameToID("u_DetailAlbedoTexture"),_.DETAILNORMALTEXTURE=t.Shader3D.propertyNameToID("u_DetailNormalTexture"),_.DETAILTILLINGOFFSET=t.Shader3D.propertyNameToID("u_DetailTillingOffset"),_.DETAILNORMALSCALE=t.Shader3D.propertyNameToID("u_DetailNormalScale"),_.CLEARCOAT=t.Shader3D.propertyNameToID("u_ClearCoatFactor"),_.SHADERDEFINE_CLEARCOATTEXTURE=t.Shader3D.getDefineByName("CLEARCOATMAP"),_.CLEARCOATTEXTURE=t.Shader3D.propertyNameToID("u_ClearCoatTexture"),_.CLEARCOATROUGHNESS=t.Shader3D.propertyNameToID("u_ClearCoatRoughness"),_.SHADERDEFINE_CLEARCOATROUGHNESSTEXTURE=t.Shader3D.getDefineByName("CLEARCOAT_ROUGHNESSMAP"),_.CLEARCOATROUGHNESSTEXTURE=t.Shader3D.propertyNameToID("u_ClearCoatRoughnessTexture"),_.CLEARCOATNORMALTEXTURE=t.Shader3D.propertyNameToID("u_ClearCoatNormalTexture"),_.ANISOTROPY=t.Shader3D.propertyNameToID("u_AnisotropyStrength"),_.SHADERDEFINE_ANISOTROPYTEXTURE=t.Shader3D.getDefineByName("ANISOTROPYMAP"),_.ANISOTROPYTEXTURE=t.Shader3D.propertyNameToID("u_AnisotropyTexture"),_.ANISOTROPYROTATION=t.Shader3D.propertyNameToID("u_AnisotropyRotation")}get albedoColor(){return this._shaderValues.getColor(_.ALBEDOCOLOR)}set albedoColor(e){this._shaderValues.setColor(_.ALBEDOCOLOR,e)}get albedoTexture(){return this.hasDefine(_.SHADERDEFINE_ALBEDOTEXTURE)?this._shaderValues.getTexture(_.ALBEDOTEXTURE):null}set albedoTexture(e){e?this._shaderValues.addDefine(_.SHADERDEFINE_ALBEDOTEXTURE):this._shaderValues.removeDefine(_.SHADERDEFINE_ALBEDOTEXTURE),this.setTextureByIndex(_.ALBEDOTEXTURE,e)}get normalTexture(){return this.hasDefine(_.SHADERDEFINE_NORMALTEXTURE)?this._shaderValues.getTexture(_.NORMALTEXTURE):null}set normalTexture(e){e?this._shaderValues.addDefine(_.SHADERDEFINE_NORMALTEXTURE):this._shaderValues.removeDefine(_.SHADERDEFINE_NORMALTEXTURE),this.setTextureByIndex(_.NORMALTEXTURE,e)}get normalTextureScale(){return this._shaderValues.getNumber(_.NORMALSCALE)}set normalTextureScale(e){this._shaderValues.setNumber(_.NORMALSCALE,e)}get parallaxTexture(){return this._shaderValues.getTexture(_.PARALLAXTEXTURE)}set parallaxTexture(e){e?this._shaderValues.addDefine(_.SHADERDEFINE_PARALLAXTEXTURE):this._shaderValues.removeDefine(_.SHADERDEFINE_PARALLAXTEXTURE),this.setTextureByIndex(_.PARALLAXTEXTURE,e)}get parallaxTextureScale(){return this._shaderValues.getNumber(_.PARALLAXSCALE)}set parallaxTextureScale(e){this._shaderValues.setNumber(_.PARALLAXSCALE,Math.max(.005,Math.min(.08,e)))}get occlusionTexture(){return this._shaderValues.getTexture(_.OCCLUSIONTEXTURE)}set occlusionTexture(e){e?this._shaderValues.addDefine(_.SHADERDEFINE_OCCLUSIONTEXTURE):this._shaderValues.removeDefine(_.SHADERDEFINE_OCCLUSIONTEXTURE),this.setTextureByIndex(_.OCCLUSIONTEXTURE,e)}get occlusionTextureStrength(){return this._shaderValues.getNumber(_.OCCLUSIONSTRENGTH)}set occlusionTextureStrength(e){this._shaderValues.setNumber(_.OCCLUSIONSTRENGTH,Math.max(0,Math.min(1,e)))}get smoothness(){return this._shaderValues.getNumber(_.SMOOTHNESS)}set smoothness(e){this._shaderValues.setNumber(_.SMOOTHNESS,Math.max(0,Math.min(1,e)))}get enableVertexColor(){return this.hasDefine(_.SHADERDEFINE_ENABLEVERTEXCOLOR)}set enableVertexColor(e){e?this.addDefine(_.SHADERDEFINE_ENABLEVERTEXCOLOR):this.removeDefine(_.SHADERDEFINE_ENABLEVERTEXCOLOR)}get enableEmission(){return this._shaderValues.hasDefine(n.DEFINE_EMISSION)}set enableEmission(e){e?this._shaderValues.addDefine(n.DEFINE_EMISSION):this._shaderValues.removeDefine(n.DEFINE_EMISSION)}get emissionColor(){return this._shaderValues.getColor(_.EMISSIONCOLOR)}set emissionColor(e){this._shaderValues.setColor(_.EMISSIONCOLOR,e)}get emissionIntensity(){return this._shaderValues.getNumber(_.EMISSIONIntensity)}set emissionIntensity(e){this._shaderValues.setNumber(_.EMISSIONIntensity,e)}get emissionTexture(){return this._shaderValues.getTexture(_.EMISSIONTEXTURE)}set emissionTexture(e){e?this._shaderValues.addDefine(_.SHADERDEFINE_EMISSIONTEXTURE):this._shaderValues.removeDefine(_.SHADERDEFINE_EMISSIONTEXTURE),this.setTextureByIndex(_.EMISSIONTEXTURE,e)}get tilingOffset(){return this._shaderValues.getVector(_.TILINGOFFSET)}set tilingOffset(e){e?this._shaderValues.setVector(_.TILINGOFFSET,e):this._shaderValues.getVector(_.TILINGOFFSET).setValue(1,1,0,0)}get detailAlbedoTexture(){return this._shaderValues.getTexture(_.DETAILALBEDOTEXTURE)}set detailAlbedoTexture(e){e?this._shaderValues.addDefine(_.SHADERDEFINE_DETAILALBEDO):this._shaderValues.removeDefine(_.SHADERDEFINE_DETAILALBEDO),this.setTextureByIndex(_.DETAILALBEDOTEXTURE,e)}get detailNormalTexture(){return this._shaderValues.getTexture(_.DETAILNORMALTEXTURE)}set detailNormalTexture(e){e?this._shaderValues.addDefine(_.SHADERDEFINE_DETAILNORMAL):this._shaderValues.removeDefine(_.SHADERDEFINE_DETAILNORMAL),this.setTextureByIndex(_.DETAILNORMALTEXTURE,e)}get detailTilingOffset(){return this._shaderValues.getVector(_.DETAILTILLINGOFFSET)}set detailTilingOffset(e){e?this._shaderValues.setVector(_.DETAILTILLINGOFFSET,e):this._shaderValues.getVector(_.DETAILTILLINGOFFSET).setValue(1,1,0,0)}get detailNormalScale(){return this._shaderValues.getNumber(_.DETAILNORMALSCALE)}set detailNormalScale(e){this._shaderValues.setNumber(_.DETAILNORMALSCALE,e)}set renderMode(r){switch(r){case e.PBRRenderMode.Opaque:this.alphaTest=!1,this.renderQueue=t.Material.RENDERQUEUE_OPAQUE,this.depthWrite=!0,this.cull=t.RenderState.CULL_BACK,this.blend=t.RenderState.BLEND_DISABLE,this.depthTest=t.RenderState.DEPTHTEST_LESS,this._shaderValues.removeDefine(_.SHADERDEFINE_TRANSPARENTBLEND);break;case e.PBRRenderMode.Cutout:this.renderQueue=t.Material.RENDERQUEUE_ALPHATEST,this.alphaTest=!0,this.depthWrite=!0,this.cull=t.RenderState.CULL_BACK,this.blend=t.RenderState.BLEND_DISABLE,this.depthTest=t.RenderState.DEPTHTEST_LESS,this._shaderValues.removeDefine(_.SHADERDEFINE_TRANSPARENTBLEND);break;case e.PBRRenderMode.Fade:this.renderQueue=t.Material.RENDERQUEUE_TRANSPARENT,this.alphaTest=!1,this.depthWrite=!1,this.cull=t.RenderState.CULL_BACK,this.blend=t.RenderState.BLEND_ENABLE_ALL,this.blendSrc=t.RenderState.BLENDPARAM_SRC_ALPHA,this.blendDst=t.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA,this.depthTest=t.RenderState.DEPTHTEST_LESS,this._shaderValues.removeDefine(_.SHADERDEFINE_TRANSPARENTBLEND);break;case e.PBRRenderMode.Transparent:this.renderQueue=t.Material.RENDERQUEUE_TRANSPARENT,this.alphaTest=!1,this.depthWrite=!1,this.cull=t.RenderState.CULL_BACK,this.blend=t.RenderState.BLEND_ENABLE_ALL,this.blendSrc=t.RenderState.BLENDPARAM_ONE,this.blendDst=t.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA,this.depthTest=t.RenderState.DEPTHTEST_LESS,this._shaderValues.addDefine(_.SHADERDEFINE_TRANSPARENTBLEND);break;default:throw new Error("unknown renderMode: "+r)}}get anisotropyEnable(){return this.shaderData.hasDefine(n.DEFINE_ANISOTROPY)}set anisotropyEnable(e){e?this.shaderData.addDefine(n.DEFINE_ANISOTROPY):this.shaderData.removeDefine(n.DEFINE_ANISOTROPY)}get anisotropy(){return this.getFloatByIndex(_.ANISOTROPY)}set anisotropy(e){this.setFloatByIndex(_.ANISOTROPY,Math.min(1,Math.max(-1,e)))}get anisotropyTexture(){return this.getTextureByIndex(_.ANISOTROPYTEXTURE)}set anisotropyTexture(e){this.setTextureByIndex(_.ANISOTROPYTEXTURE,e),e?this.addDefine(_.SHADERDEFINE_ANISOTROPYTEXTURE):this.removeDefine(_.SHADERDEFINE_ANISOTROPYTEXTURE)}get anisotropyRotation(){return this.getFloatByIndex(_.ANISOTROPYROTATION)}set anisotropyRotation(e){e=Math.max(Math.min(e,1),0),this.setFloatByIndex(_.ANISOTROPYROTATION,e)}get clearCoatEnable(){return this.shaderData.hasDefine(n.DEFINE_CLEARCOAT)}set clearCoatEnable(e){e?this.shaderData.addDefine(n.DEFINE_CLEARCOAT):this.shaderData.removeDefine(n.DEFINE_CLEARCOAT)}get clearCoat(){return this.shaderData.getNumber(_.CLEARCOAT)}set clearCoat(e){this.shaderData.setNumber(_.CLEARCOAT,e)}get clearCoatTexture(){return this.shaderData.getTexture(_.CLEARCOATTEXTURE)}set clearCoatTexture(e){e?this.shaderData.addDefine(_.SHADERDEFINE_CLEARCOATTEXTURE):this.shaderData.removeDefine(_.SHADERDEFINE_CLEARCOATTEXTURE),this.setTextureByIndex(_.CLEARCOATTEXTURE,e)}get clearCoatRoughness(){return this.shaderData.getNumber(_.CLEARCOATROUGHNESS)}set clearCoatRoughness(e){this.shaderData.setNumber(_.CLEARCOATROUGHNESS,e)}get clearCoatRoughnessTexture(){return this.shaderData.getTexture(_.CLEARCOATROUGHNESSTEXTURE)}set clearCoatRoughnessTexture(e){e?this.shaderData.addDefine(_.SHADERDEFINE_CLEARCOATROUGHNESSTEXTURE):this.shaderData.removeDefine(_.SHADERDEFINE_CLEARCOATROUGHNESSTEXTURE),this.setTextureByIndex(_.CLEARCOATROUGHNESSTEXTURE,e)}get clearCoatNormalTexture(){return this.shaderData.getTexture(_.CLEARCOATNORMALTEXTURE)}set clearCoatNormalTexture(e){e?this.shaderData.addDefine(n.DEFINE_CLEARCOAT_NORMAL):this.shaderData.removeDefine(n.DEFINE_CLEARCOAT_NORMAL),this.setTextureByIndex(_.CLEARCOATNORMALTEXTURE,e)}constructor(){super(),this._shaderValues.setColor(_.ALBEDOCOLOR,new t.Color(1,1,1,1)),this._shaderValues.setColor(_.EMISSIONCOLOR,new t.Color(1,1,1,1)),this._shaderValues.setVector(_.TILINGOFFSET,new t.Vector4(1,1,0,0)),this._shaderValues.setNumber(_.SMOOTHNESS,.5),this._shaderValues.setNumber(_.OCCLUSIONSTRENGTH,1),this._shaderValues.setNumber(_.NORMALSCALE,1),this._shaderValues.setNumber(_.PARALLAXSCALE,.001),this._shaderValues.setNumber(t.Material.ALPHATESTVALUE,.5),this.renderMode=e.PBRRenderMode.Opaque}get smoothnessTextureScale(){return this._shaderValues.getNumber(_.SMOOTHNESS)}set smoothnessTextureScale(e){this._shaderValues.setNumber(_.SMOOTHNESS,Math.max(0,Math.min(1,e)))}}_.renderQuality=e.PBRRenderQuality.High,e.GBufferOutput=void 0,(o=e.GBufferOutput||(e.GBufferOutput={}))[o.None=0]="None",o[o.Normal=1]="Normal",o[o.Albedo=2]="Albedo",o[o.Surface=4]="Surface",o[o.All=7]="All",e.GBufferLocation=void 0,(l=e.GBufferLocation||(e.GBufferLocation={}))[l.Color=0]="Color",l[l.Normal=1]="Normal",l[l.Albedo=2]="Albedo",l[l.Surface=3]="Surface",l[l.MotionVectors=4]="MotionVectors",l[l.CustomStart=5]="CustomStart",e.GBufferAttachment=void 0,(h=e.GBufferAttachment||(e.GBufferAttachment={})).Normal="normal",h.Albedo="albedo",h.Surface="surface",h.MotionVectors="MotionVectors",e.GBufferShaderDefine=void 0,(d=e.GBufferShaderDefine||(e.GBufferShaderDefine={})).Configured="GBUFFER_OUTPUTS_CONFIGURED",d.Normal="GBUFFER_NORMAL",d.Albedo="GBUFFER_ALBEDO",d.Surface="GBUFFER_SURFACE";class f{static createCameraOptions(t=e.GBufferOutput.All,r=[]){this._validateOutputs(t);const a=[t&e.GBufferOutput.Normal?this.Normal:null,t&e.GBufferOutput.Albedo?this.Albedo:null,t&e.GBufferOutput.Surface?this.Surface:null,null,...r];for(;a.length&&null==a[a.length-1];)a.pop();return a.length?{auxiliaryAttachments:a}:null}static createColorFormats(t,r=e.GBufferOutput.All,a=[]){const i=this.createCameraOptions(r,a.map(e=>null==e?null:{format:e}));return[t,...(null==i?void 0:i.auxiliaryAttachments.map(e=>{var t;return null!==(t=null==e?void 0:e.format)&&void 0!==t?t:null}))||[]]}static _validateOutputs(t){if(!Number.isInteger(t)||t<e.GBufferOutput.None||t>e.GBufferOutput.All)throw new RangeError("GBuffer outputs must contain only Normal, Albedo and Surface flags.")}static applyShaderOutputs(r,a){this._validateOutputs(a),r.addDefine(t.Shader3D.getDefineByName(e.GBufferShaderDefine.Configured));const i=[e.GBufferOutput.Normal,e.GBufferOutput.Albedo,e.GBufferOutput.Surface],n=[e.GBufferShaderDefine.Normal,e.GBufferShaderDefine.Albedo,e.GBufferShaderDefine.Surface];for(let e=0;e<i.length;e++){const s=t.Shader3D.getDefineByName(n[e]);a&i[e]?r.addDefine(s):r.removeDefine(s)}}static getShaderOutputs(r){if(!r.hasDefine(t.Shader3D.getDefineByName(e.GBufferShaderDefine.Configured)))return e.GBufferOutput.All;let a=e.GBufferOutput.None;return r.hasDefine(t.Shader3D.getDefineByName(e.GBufferShaderDefine.Normal))&&(a|=e.GBufferOutput.Normal),r.hasDefine(t.Shader3D.getDefineByName(e.GBufferShaderDefine.Albedo))&&(a|=e.GBufferOutput.Albedo),r.hasDefine(t.Shader3D.getDefineByName(e.GBufferShaderDefine.Surface))&&(a|=e.GBufferOutput.Surface),a}}f.Normal=Object.freeze({index:e.GBufferLocation.Normal-1,name:e.GBufferAttachment.Normal,format:t.RenderTargetFormat.R16G16B16A16,clearColor:Object.freeze(new t.Color(0,0,0,0))}),f.Albedo=Object.freeze({index:e.GBufferLocation.Albedo-1,name:e.GBufferAttachment.Albedo,format:t.RenderTargetFormat.R8G8B8A8,clearColor:Object.freeze(new t.Color(0,0,0,0))}),f.Surface=Object.freeze({index:e.GBufferLocation.Surface-1,name:e.GBufferAttachment.Surface,format:t.RenderTargetFormat.R8G8B8A8,clearColor:Object.freeze(new t.Color(0,0,0,0))}),e.PBRMetallicSmoothnessSource=void 0,(c=e.PBRMetallicSmoothnessSource||(e.PBRMetallicSmoothnessSource={}))[c.MetallicGlossTextureAlpha=0]="MetallicGlossTextureAlpha",c[c.AlbedoTextureAlpha=1]="AlbedoTextureAlpha";class m extends _{static __init__(){m.SHADERDEFINE_METALLICGLOSSTEXTURE=t.Shader3D.getDefineByName("METALLICGLOSSTEXTURE"),m.SHADERDEFINE_SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA=t.Shader3D.getDefineByName("SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA"),m.METALLICGLOSSTEXTURE=t.Shader3D.propertyNameToID("u_MetallicGlossTexture"),m.METALLIC=t.Shader3D.propertyNameToID("u_Metallic")}get gBufferOutputs(){return f.getShaderOutputs(this._shaderValues)}set gBufferOutputs(e){f.applyShaderOutputs(this._shaderValues,e)}get metallicGlossTexture(){return this._shaderValues.getTexture(m.METALLICGLOSSTEXTURE)}set metallicGlossTexture(e){e?this._shaderValues.addDefine(m.SHADERDEFINE_METALLICGLOSSTEXTURE):this._shaderValues.removeDefine(m.SHADERDEFINE_METALLICGLOSSTEXTURE),this._shaderValues.setTexture(m.METALLICGLOSSTEXTURE,e)}get metallic(){return this._shaderValues.getNumber(m.METALLIC)}set metallic(e){this._shaderValues.setNumber(m.METALLIC,Math.max(0,Math.min(1,e)))}get smoothnessSource(){return this._smoothnessSource}set smoothnessSource(e){e?this._shaderValues.addDefine(m.SHADERDEFINE_SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA):this._shaderValues.removeDefine(m.SHADERDEFINE_SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA),this._smoothnessSource=e}constructor(){super(),this._smoothnessSource=0,this.setShaderName("PBR")}clone(){var e=new m;return this.cloneTo(e),e}}class g extends t.Material{static __initDefine__(){g.TINTCOLOR=t.Shader3D.propertyNameToID("u_TintColor"),g.EXPOSURE=t.Shader3D.propertyNameToID("u_Exposure"),g.ROTATION=t.Shader3D.propertyNameToID("u_Rotation"),g.TEXTURECUBE=t.Shader3D.propertyNameToID("u_CubeTexture")}get tintColor(){return this._shaderValues.getColor(g.TINTCOLOR)}set tintColor(e){this._shaderValues.setColor(g.TINTCOLOR,e)}get exposure(){return this._shaderValues.getNumber(g.EXPOSURE)}set exposure(e){this._shaderValues.setNumber(g.EXPOSURE,e)}get rotation(){return this._shaderValues.getNumber(g.ROTATION)}set rotation(e){this._shaderValues.setNumber(g.ROTATION,e)}get textureCube(){return this._shaderValues.getTexture(g.TEXTURECUBE)}set textureCube(e){this._shaderValues.setTexture(g.TEXTURECUBE,e)}clone(){var e=new g;return this.cloneTo(e),e}constructor(){super(),this.setShaderName("SkyBox")}}class p extends t.Material{static __initDefine__(){p.SHADERDEFINE_SUN_HIGH_QUALITY=t.Shader3D.getDefineByName("SUN_HIGH_QUALITY"),p.SHADERDEFINE_SUN_SIMPLE=t.Shader3D.getDefineByName("SUN_SIMPLE"),p.SUNSIZE=t.Shader3D.propertyNameToID("u_SunSize"),p.SUNSIZECONVERGENCE=t.Shader3D.propertyNameToID("u_SunSizeConvergence"),p.ATMOSPHERETHICKNESS=t.Shader3D.propertyNameToID("u_AtmosphereThickness"),p.SKYTINT=t.Shader3D.propertyNameToID("u_SkyTint"),p.GROUNDTINT=t.Shader3D.propertyNameToID("u_GroundTint"),p.EXPOSURE=t.Shader3D.propertyNameToID("u_Exposure")}get sunDisk(){return this._sunDisk}set sunDisk(e){switch(e){case p.SUN_HIGH_QUALITY:this._shaderValues.removeDefine(p.SHADERDEFINE_SUN_SIMPLE),this._shaderValues.addDefine(p.SHADERDEFINE_SUN_HIGH_QUALITY);break;case p.SUN_SIMPLE:this._shaderValues.removeDefine(p.SHADERDEFINE_SUN_HIGH_QUALITY),this._shaderValues.addDefine(p.SHADERDEFINE_SUN_SIMPLE);break;case p.SUN_NODE:this._shaderValues.removeDefine(p.SHADERDEFINE_SUN_HIGH_QUALITY),this._shaderValues.removeDefine(p.SHADERDEFINE_SUN_SIMPLE);break;default:throw"SkyBoxProceduralMaterial: unknown sun value."}this._sunDisk=e}get sunSize(){return this._shaderValues.getNumber(p.SUNSIZE)}set sunSize(e){e=Math.min(Math.max(0,e),1),this._shaderValues.setNumber(p.SUNSIZE,e)}get sunSizeConvergence(){return this._shaderValues.getNumber(p.SUNSIZECONVERGENCE)}set sunSizeConvergence(e){e=Math.min(Math.max(0,e),20),this._shaderValues.setNumber(p.SUNSIZECONVERGENCE,e)}get atmosphereThickness(){return this._shaderValues.getNumber(p.ATMOSPHERETHICKNESS)}set atmosphereThickness(e){e=Math.min(Math.max(0,e),5),this._shaderValues.setNumber(p.ATMOSPHERETHICKNESS,e)}get skyTint(){return this._shaderValues.getColor(p.SKYTINT)}set skyTint(e){this._shaderValues.setColor(p.SKYTINT,e)}get groundTint(){return this._shaderValues.getColor(p.GROUNDTINT)}set groundTint(e){this._shaderValues.setColor(p.GROUNDTINT,e)}get exposure(){return this._shaderValues.getNumber(p.EXPOSURE)}set exposure(e){e=Math.min(Math.max(0,e),8),this._shaderValues.setNumber(p.EXPOSURE,e)}constructor(){super(),this.setShaderName("SkyProcedural"),this.sunDisk=p.SUN_HIGH_QUALITY,this.sunSize=.04,this.sunSizeConvergence=5,this.atmosphereThickness=1,this.skyTint=new t.Color(.5,.5,.5,1),this.groundTint=new t.Color(.369,.349,.341,1),this.exposure=1.3}clone(){var e=new p;return this.cloneTo(e),e}}p.SUN_NODE=0,p.SUN_SIMPLE=1,p.SUN_HIGH_QUALITY=2;class S extends t.Material{static __initDefine__(){S.SHADERDEFINE_ALBEDOTEXTURE=t.Shader3D.getDefineByName("ALBEDOTEXTURE"),S.SHADERDEFINE_ENABLEVERTEXCOLOR=t.Shader3D.getDefineByName("ENABLEVERTEXCOLOR"),S.ALBEDOTEXTURE=t.Shader3D.propertyNameToID("u_AlbedoTexture"),S.ALBEDOCOLOR=t.Shader3D.propertyNameToID("u_AlbedoColor"),S.TILINGOFFSET=t.Shader3D.propertyNameToID("u_TilingOffset")}get albedoColor(){return this.getColorByIndex(S.ALBEDOCOLOR)}set albedoColor(e){this.setColorByIndex(S.ALBEDOCOLOR,e.scale(this._albedoIntensity))}get albedoIntensity(){return this._albedoIntensity}set albedoIntensity(e){this._albedoIntensity=e}get albedoTexture(){return this.getTextureByIndex(S.ALBEDOTEXTURE)}set albedoTexture(e){e?this.addDefine(S.SHADERDEFINE_ALBEDOTEXTURE):this.removeDefine(S.SHADERDEFINE_ALBEDOTEXTURE),this.setTextureByIndex(S.ALBEDOTEXTURE,e)}get tilingOffset(){return this.getVector4ByIndex(S.TILINGOFFSET)}set tilingOffset(e){e?this.setVector4ByIndex(S.TILINGOFFSET,e):this.setVector4ByIndex(S.TILINGOFFSET,new t.Vector4(1,1,0,0))}get enableVertexColor(){return this.hasDefine(S.SHADERDEFINE_ENABLEVERTEXCOLOR)}set enableVertexColor(e){e?this.addDefine(S.SHADERDEFINE_ENABLEVERTEXCOLOR):this.removeDefine(S.SHADERDEFINE_ENABLEVERTEXCOLOR)}constructor(){super(),this.setShaderName("Unlit"),this.renderMode=S.RENDERMODE_OPAQUE,this.albedoIntensity=1}clone(){var e=new S;return this.cloneTo(e),e}set renderMode(e){switch(e){case S.RENDERMODE_OPAQUE:this.alphaTest=!1,this.renderQueue=t.Material.RENDERQUEUE_OPAQUE,this.depthWrite=!0,this.cull=t.RenderState.CULL_BACK,this.blend=t.RenderState.BLEND_DISABLE,this.depthTest=t.RenderState.DEPTHTEST_LESS;break;case S.RENDERMODE_CUTOUT:this.renderQueue=t.Material.RENDERQUEUE_ALPHATEST,this.alphaTest=!0,this.depthWrite=!0,this.cull=t.RenderState.CULL_BACK,this.blend=t.RenderState.BLEND_DISABLE,this.depthTest=t.RenderState.DEPTHTEST_LESS;break;case S.RENDERMODE_TRANSPARENT:this.renderQueue=t.Material.RENDERQUEUE_TRANSPARENT,this.alphaTest=!1,this.depthWrite=!1,this.cull=t.RenderState.CULL_BACK,this.blend=t.RenderState.BLEND_ENABLE_ALL,this.blendSrc=t.RenderState.BLENDPARAM_SRC_ALPHA,this.blendDst=t.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA,this.depthTest=t.RenderState.DEPTHTEST_LESS;break;default:throw new Error("unknown renderMode: "+e)}}}S.RENDERMODE_OPAQUE=0,S.RENDERMODE_CUTOUT=1,S.RENDERMODE_TRANSPARENT=2,S.RENDERMODE_ADDTIVE=3;class T{}class A{}class E{static getMeshDefine(e,r){r.length=0;let a=e._vertexBuffer.vertexDeclaration._vertexElements;for(const e of a)switch(e.elementUsage){case t.VertexMesh.MESH_COLOR0:r.push(A.SHADERDEFINE_COLOR);break;case t.VertexMesh.MESH_TEXTURECOORDINATE0:r.push(A.SHADERDEFINE_UV0);break;case t.VertexMesh.MESH_TEXTURECOORDINATE1:r.push(A.SHADERDEFINE_UV1);break;case t.VertexMesh.MESH_TANGENT0:r.push(A.SHADERDEFINE_TANGENT);break;case t.VertexMesh.MESH_BLENDWEIGHT0:r.push(A.SHADERDEFINE_BONEW);break;case t.VertexMesh.MESH_BLENDINDICES0:r.push(A.SHADERDEFINE_BONEI)}}}class D extends t.Component{constructor(){super(),this.runInEditor=!0}_onEnable(){const e=this.owner.getComponent(Y);e&&e._enabled&&e._onMeshChange(this._sharedMesh)}_onDisable(){this.owner.getComponent(Y)}get sharedMesh(){return this._sharedMesh}set sharedMesh(e){if(this._sharedMesh!==e){var t=this._sharedMesh;t&&t._removeReference(),e&&e._addReference(),this._sharedMesh=e;const r=this.owner.getComponent(Y);if(!r)return;r._onMeshChange(e),this._sharedMesh=e}}_onDestroy(){this._sharedMesh&&(this._sharedMesh._removeReference(),this._sharedMesh=null)}_cloneTo(e){e.sharedMesh=this.sharedMesh,super._cloneTo(e)}}D._meshVerticeDefine=[],e.StaticFlag=void 0,(u=e.StaticFlag||(e.StaticFlag={}))[u.Normal=1]="Normal",u[u.StaticBatch=2]="StaticBatch";class R extends t.Node{static __init__(){R.WORLDMATRIX=t.Shader3D.propertyNameToID("u_WorldMat"),R.WORLDINVERTFRONT=t.Shader3D.propertyNameToID("u_WorldInvertFront"),R.sprite3DCommandUniformMap=t.LayaGL.renderDeviceFactory.createGlobalUniformMap("Sprite3D"),R.sprite3DCommandUniformMap.addShaderUniform(R.WORLDMATRIX,"u_WorldMat",t.ShaderDataType.Matrix4x4),R.sprite3DCommandUniformMap.addShaderUniform(R.WORLDINVERTFRONT,"u_WorldInvertFront",t.ShaderDataType.Vector4)}static instantiate(e,t=null,r=!0,a=null,i=null){var n=e.clone();t&&t.addChild(n);var s=n.transform;if(r){var o=s.worldMatrix;e.transform.worldMatrix.cloneTo(o),s.worldMatrix=o}else a&&(s.position=a),i&&(s.rotation=i);return n}static load(e,r){t.ILaya.loader.load(e).then(e=>{r&&r.runWith([null==e?void 0:e.create()])})}get id(){return this._id}get layer(){return this._layer}set layer(e){if(this._layer!==e){if(!(e>=0&&e<=30))throw new Error("Layer value must be 0-30.");this._layer=e,this.event(t.Event.LAYER_CHANGE,e)}}get isStatic(){return!!(this._isStatic>>1)}set isStatic(r){this._isStatic=r?e.StaticFlag.StaticBatch:e.StaticFlag.Normal,this.event(t.Event.STATIC_MASK,this._isStatic)}get transform(){return this._transform}get scene(){return this._scene}constructor(t,r){super(),this._isRenderNode=0,this._nodeType=1,this._id=++x,this._transform=T.Render3DModuleDataFactory.createTransform(this),this._isStatic=r?e.StaticFlag.StaticBatch:e.StaticFlag.Normal,this.layer=0,null!=t&&(this.name=t)}_onActive(){super._onActive(),t.LayaGL.statAgent.recordCountData(t.StatElement.C_Sprite3DCount,1)}_onInActive(){super._onInActive(),t.LayaGL.statAgent.recordCountData(t.StatElement.C_Sprite3DCount,-1)}_onActiveInScene(){this._transform.activeInScene()}_onInActiveInScene(){this._transform.inActiveInScene()}getRenderersInChildren(){if(!this._renderers){const e=[];R._collectRenderers(this,e),this._renderers=e}return this._renderers}static _collectRenderers(e,r){e._setBit(t.NodeFlags.RENDERERS_CACHE,!0);for(const t of e.components){const e=t;!0!==e._is3DRender||e.destroyed||r.push(e)}for(let t=0,a=e.numChildren;t<a;t++)R._collectRenderers(e.getChildAt(t),r)}_invalidateRenderers(){for(let e=this;e&&e._getBit(t.NodeFlags.RENDERERS_CACHE);e=e.parent)e._setBit(t.NodeFlags.RENDERERS_CACHE,!1),e instanceof R&&e._renderers&&(e._renderers=null)}_childChanged(e){super._childChanged(e),this._getBit(t.NodeFlags.RENDERERS_CACHE)&&this._invalidateRenderers()}_componentsChanged(e,r){!this._getBit(t.NodeFlags.RENDERERS_CACHE)||e&&!0!==e._is3DRender||this._invalidateRenderers()}_onAdded(){if(this._parent instanceof R){var e=this._parent;this.transform._setParent(e.transform)}else this.transform._onWorldTransform();super._onAdded()}_onRemoved(){super._onRemoved(),this._parent instanceof R&&this.transform._setParent(null)}onStartListeningToType(e){super.onStartListeningToType(e),(e.startsWith("collision")||e.startsWith("trigger"))&&this.event(t.Event.UPDATE_PHY_EVENT_FILTER,e)}_cloneTo(e,t,r){if(this._destroyed)throw new Error("Sprite3D: Can't be cloned if the Sprite3D has destroyed.");var a=this._transform,i=e._transform;e.name=this.name,e.tag=this.tag,e._destroyed=this._destroyed,e.active=this.active,i.localPosition=a.localPosition,i.localRotation=a.localRotation,i.localScale=a.localScale,e._isStatic=this._isStatic,e.layer=this.layer,super._cloneTo(e,t,r)}static _createSprite3DInstance(e){let t=new(Object.getPrototypeOf(e).constructor),r=e._children;for(let e=0,a=r.length;e<a;e++){let a=R._createSprite3DInstance(r[e]);t.addChild(a)}return t}static _parseSprite3DInstance(e,t,r,a){let i=r._children,n=a._children;for(let r=0,a=i.length;r<a;r++)R._parseSprite3DInstance(e,t,i[r],n[r]);r._cloneTo(a,e,t)}clone(){let e=R._createSprite3DInstance(this);return R._parseSprite3DInstance(this,e,this,e),e}destroy(e=!0){this._destroyed||(super.destroy(e),this._renderers=null,this._transform=null)}}var x=0;class y extends R{static __init__(){y.SHADERDEFINE_RECEIVE_SHADOW=t.Shader3D.getDefineByName("RECEIVESHADOW"),y.SAHDERDEFINE_LIGHTMAP=t.Shader3D.getDefineByName("LIGHTMAP"),y.SHADERDEFINE_LIGHTMAP_DIRECTIONAL=t.Shader3D.getDefineByName("LIGHTMAP_DIRECTIONAL"),y.LIGHTMAPSCALEOFFSET=t.Shader3D.propertyNameToID("u_LightmapScaleOffset"),y.LIGHTMAP=t.Shader3D.propertyNameToID("u_LightMap"),y.LIGHTMAP_DIRECTION=t.Shader3D.propertyNameToID("u_LightMapDirection"),y.PICKCOLOR=t.Shader3D.propertyNameToID("u_PickColor");const e=t.LayaGL.renderDeviceFactory.createGlobalUniformMap("Sprite3D");y.SHADERDEFINE_MORPHTARGET=t.Shader3D.getDefineByName("MORPHTARGETS"),y.SHADERDEFINE_MORPHTARGET_POSITION=t.Shader3D.getDefineByName("MORPHTARGETS_POSITION"),y.SHADERDEFINE_MORPHTARGET_NORMAL=t.Shader3D.getDefineByName("MORPHTARGETS_NORMAL"),y.SHADERDEFINE_MORPHTARGET_TANGENT=t.Shader3D.getDefineByName("MORPHTARGETS_TANGENT"),y.MorphTex=t.Shader3D.propertyNameToID("u_MorphTargetsTex"),y.MorphParams=t.Shader3D.propertyNameToID("u_MorphParams"),y.MorphAttriOffset=t.Shader3D.propertyNameToID("u_MorphAttrOffset"),y.MorphActiceTargets=t.Shader3D.propertyNameToID("u_MorphActiveTargets"),y.MorphActiveCount=t.Shader3D.propertyNameToID("u_MorphTargetActiveCount");const r=t.LayaGL.renderDeviceFactory.createGlobalUniformMap("MorphTarget");r.addShaderUniform(y.MorphTex,"u_MorphTargetsTex",t.ShaderDataType.Texture2D),r.addShaderUniform(y.MorphParams,"u_MorphParams",t.ShaderDataType.Vector4),r.addShaderUniform(y.MorphAttriOffset,"u_MorphAttrOffset",t.ShaderDataType.Vector4),r.addShaderUniformArray(y.MorphActiceTargets,"u_MorphActiveTargets",t.ShaderDataType.Vector4,t.Config3D.maxMorphTargetCount),r.addShaderUniform(y.MorphActiveCount,"u_MorphTargetActiveCount",t.ShaderDataType.Int),e.addShaderUniform(y.LIGHTMAPSCALEOFFSET,"u_LightmapScaleOffset",t.ShaderDataType.Vector4),e.addShaderUniform(y.LIGHTMAP,"u_LightMap",t.ShaderDataType.Texture2D),e.addShaderUniform(y.LIGHTMAP_DIRECTION,"u_LightMapDirection",t.ShaderDataType.Texture2D),e.addShaderUniform(y.PICKCOLOR,"u_PickColor",t.ShaderDataType.Vector3);const a=t.LayaGL.renderDeviceFactory.createGlobalUniformMap("LegacyReflection");y.REFLECTIONTEXTURE=t.Shader3D.propertyNameToID("u_ReflectTexture"),y.REFLECTIONCUBE_HDR_PARAMS=t.Shader3D.propertyNameToID("u_ReflectCubeHDRParams"),a.addShaderUniform(y.REFLECTIONTEXTURE,"u_ReflectTexture",t.ShaderDataType.TextureCube),a.addShaderUniform(y.REFLECTIONCUBE_HDR_PARAMS,"u_ReflectCubeHDRParams",t.ShaderDataType.Vector4),y.AMBIENTSHAR=t.Shader3D.propertyNameToID("u_AmbientSHAr"),a.addShaderUniform(y.AMBIENTSHAR,"u_AmbientSHAr",t.ShaderDataType.Vector4),y.AMBIENTSHAG=t.Shader3D.propertyNameToID("u_AmbientSHAg"),a.addShaderUniform(y.AMBIENTSHAG,"u_AmbientSHAg",t.ShaderDataType.Vector4),y.AMBIENTSHAB=t.Shader3D.propertyNameToID("u_AmbientSHAb"),a.addShaderUniform(y.AMBIENTSHAB,"u_AmbientSHAb",t.ShaderDataType.Vector4),y.AMBIENTSHBR=t.Shader3D.propertyNameToID("u_AmbientSHBr"),a.addShaderUniform(y.AMBIENTSHBR,"u_AmbientSHBr",t.ShaderDataType.Vector4),y.AMBIENTSHBG=t.Shader3D.propertyNameToID("u_AmbientSHBg"),a.addShaderUniform(y.AMBIENTSHBG,"u_AmbientSHBg",t.ShaderDataType.Vector4),y.AMBIENTSHBB=t.Shader3D.propertyNameToID("u_AmbientSHBb"),a.addShaderUniform(y.AMBIENTSHBB,"u_AmbientSHBb",t.ShaderDataType.Vector4),y.AMBIENTSHC=t.Shader3D.propertyNameToID("u_AmbientSHC"),a.addShaderUniform(y.AMBIENTSHC,"u_AmbientSHC",t.ShaderDataType.Vector4)}constructor(e){super(e)}_onInActive(){super._onInActive()}_onActive(){super._onActive()}_onActiveInScene(){super._onActiveInScene()}_addToInitStaticBatchManager(){}_setBelongScene(e){super._setBelongScene(e)}_setUnBelongScene(){super._setUnBelongScene()}}class M{static setMinMaxBatch(e,r,a=e.length){var i;if(!Number.isSafeInteger(a)||a<0||a>e.length||!(r instanceof Float64Array)||a>Math.floor(r.length/6))throw new RangeError("Invalid Bounds batch range");for(let t=0;t<a;t++)if(!(e[t]instanceof M))throw new TypeError("Invalid Bounds batch target");if(0===a)return;const n=T.Render3DModuleDataFactory;if(null===(i=n.setBoundsMinMaxBatch)||void 0===i?void 0:i.call(n,e,r,a))return;const s=new t.Vector3,o=new t.Vector3;for(let t=0;t<a;t++){const a=6*t;s.setValue(r[a],r[a+1],r[a+2]),o.setValue(r[a+3],r[a+4],r[a+5]),e[t].setMin(s),e[t].setMax(o)}}static merge(e,r,a){t.Vector3.min(e.min,r.min,C),t.Vector3.max(e.max,r.max,v),a.min=C,a.max=v}static containPoint(e,t){let r=e._imp.getMax(),a=e._imp.getMin();return!(t.x>r.x||t.x<a.x)&&(!(t.y>r.y||t.y<a.y)&&!(t.z>r.z||t.z<a.z))}get min(){return this.getMin()}set min(e){this.setMin(e)}get max(){return this.getMax()}set max(e){this.setMax(e)}setMin(e){this._imp.setMin(e)}getMin(){return this._imp.getMin()}setMax(e){this._imp.setMax(e)}getMax(){return this._imp.getMax()}setCenter(e){this._imp.setCenter(e)}getCenter(){return this._imp.getCenter()}setExtent(e){this._imp.setExtent(e)}getExtent(){return this._imp.getExtent()}constructor(e,t){this._imp=T.Render3DModuleDataFactory.createBounds(e,t)}_getUpdateFlag(e){return this._imp._getUpdateFlag(e)}_setUpdateFlag(e,t){this._imp._setUpdateFlag(e,t)}_getCenter(e,r,a){t.Vector3.add(e,r,a),t.Vector3.scale(a,.5,a)}_getExtent(e,r,a){t.Vector3.subtract(r,e,a),t.Vector3.scale(a,.5,a)}_getMin(e,r,a){t.Vector3.subtract(e,r,a)}_getMax(e,r,a){t.Vector3.add(e,r,a)}_rotateExtents(e,t,r){var a=e.x,i=e.y,n=e.z,s=t.elements;r.x=Math.abs(s[0]*a)+Math.abs(s[4]*i)+Math.abs(s[8]*n),r.y=Math.abs(s[1]*a)+Math.abs(s[5]*i)+Math.abs(s[9]*n),r.z=Math.abs(s[2]*a)+Math.abs(s[6]*i)+Math.abs(s[10]*n)}_tranform(e,t){this._imp._tranform(e,t._imp)}getCorners(e){this._imp.getCorners(e)}getBoundBox(e){this._imp._getBoundBox().cloneTo(e)}calculateBoundsintersection(e){return this._imp.calculateBoundsintersection(e._imp)}cloneTo(e){this._imp.cloneTo(e._imp)}clone(){var e=new M(new t.Vector3,new t.Vector3);return this.cloneTo(e),e}}M._UPDATE_MIN=1,M._UPDATE_MAX=2,M._UPDATE_CENTER=4,M._UPDATE_EXTENT=8;const C=new t.Vector3,v=new t.Vector3;var I,w,B,P,L,F,N;e.volumeIntersectType=void 0,(I=e.volumeIntersectType||(e.volumeIntersectType={}))[I.contain=0]="contain",I[I.intersect=1]="intersect",I[I.Disjoint=2]="Disjoint";class O extends t.Component{constructor(){super(),this._aroundVolumeCacheNum=0,this._bounds=new M,this._primitiveBounds=new M,this._importance=0,this.runInEditor=!0}get type(){return this._type}get bounds(){return this._bounds}get boundsMax(){return this._primitiveBounds.getMax()}set boundsMax(e){this._primitiveBounds.setMax(e),this._reCaculateBoundBox()}get boundsMin(){return this._primitiveBounds.getMin()}set boundsMin(e){this._primitiveBounds.setMin(e),this._reCaculateBoundBox()}get probePosition(){return this.owner.transform.position}get importance(){return this._importance}set importance(e){this._importance=e}_onEnable(){this.owner.transform.on(t.Event.TRANSFORM_CHANGED,this,this._VolumeChange),this._volumeManager=this.owner.scene._volumeManager,this._volumeManager.add(this),this._reCaculateBoundBox()}_onDisable(){this.owner.transform.off(t.Event.TRANSFORM_CHANGED,this,this._VolumeChange),this._volumeManager.remove(this)}_VolumeChange(){this._volumeManager._needUpdateAllRender=!0;let e=this._volumeManager._regVolumeManager[this.type];e&&(e._needUpdateAllRender=!0),this._reCaculateBoundBox()}_reCaculateBoundBox(){this.owner&&this._primitiveBounds._tranform(this.owner.transform.worldMatrix,this._bounds)}}class b{constructor(){this._reflectionProbes=new t.SingletonList,this._needUpdateAllRender=!1,this._sceneReflectionProbe=new G,this._sceneReflectionProbe.boxProjection=!1,this._sceneReflectionProbe._isScene=!0}get sceneReflectionProbe(){return this._sceneReflectionProbe}hasUserProbe(){return this._reflectionProbes.length>0}set sceneReflectionProbe(e){this._sceneReflectionProbe=e,this._needUpdateAllRender=!0}_updateRenderObject(e){if(0!=this._reflectionProbes.length){for(var t,r,a=this._reflectionProbes.elements,i=0,n=e.bounds,s=0,o=this._reflectionProbes.length;s<o;s++){let e=a[s];if(t){if(t.importance>e.importance)continue;if((r=n.calculateBoundsintersection(e.bounds))<i&&t.importance==e.importance)continue}else if((r=n.calculateBoundsintersection(e.bounds))<i)continue;t=e,i=r}!t&&this._sceneReflectionProbe&&(t=this._sceneReflectionProbe),e.probReflection=t}else e.probReflection=this._sceneReflectionProbe}add(e){this._reflectionProbes.add(e),this._needUpdateAllRender=!0}remove(e){this._reflectionProbes.remove(e),this._needUpdateAllRender=!0}handleMotionlist(e){var t=e.elements;let r;for(var a=0,i=e.length;a<i;a++)r=t[a],r._surportReflectionProbe&&1==r.reflectionMode&&this._updateRenderObject(t[a])}reCaculateAllRenderObjects(e){var t=e.elements;let r;for(var a=0,i=e.length;a<i;a++)r=t[a],r._surportReflectionProbe&&1==r.reflectionMode&&this._updateRenderObject(r),this._needUpdateAllRender=!1}destroy(){for(let e=0;e<this._reflectionProbes.length;e++){this._reflectionProbes.elements[e].destroy()}this._reflectionProbes.length=0;const e=this._sceneReflectionProbe;this._sceneReflectionProbe=null,null==e||e._destroyByManager()}}class V extends O{static init(){V.SHADERDEFINE_VOLUMETRICGI=t.Shader3D.getDefineByName("VOLUMETRICGI"),V.VOLUMETRICGI_PROBECOUNTS=t.Shader3D.propertyNameToID("u_VolGIProbeCounts"),V.VOLUMETRICGI_PROBESTEPS=t.Shader3D.propertyNameToID("u_VolGIProbeStep"),V.VOLUMETRICGI_PROBESTARTPOS=t.Shader3D.propertyNameToID("u_VolGIProbeStartPosition"),V.VOLUMETRICGI_PROBEPARAMS=t.Shader3D.propertyNameToID("u_VolGIProbeParams"),V.VOLUMETRICGI_IRRADIANCE=t.Shader3D.propertyNameToID("u_ProbeIrradiance"),V.VOLUMETRICGI_DISTANCE=t.Shader3D.propertyNameToID("u_ProbeDistance");let e=t.LayaGL.renderDeviceFactory.createGlobalUniformMap(V.BlockName);e.addShaderUniform(V.VOLUMETRICGI_PROBECOUNTS,"u_VolGIProbeCounts",t.ShaderDataType.Vector3),e.addShaderUniform(V.VOLUMETRICGI_PROBESTEPS,"u_VolGIProbeStep",t.ShaderDataType.Vector3),e.addShaderUniform(V.VOLUMETRICGI_PROBESTARTPOS,"u_VolGIProbeStartPosition",t.ShaderDataType.Vector3),e.addShaderUniform(V.VOLUMETRICGI_PROBEPARAMS,"u_VolGIProbeParams",t.ShaderDataType.Vector4),e.addShaderUniform(V.VOLUMETRICGI_IRRADIANCE,"u_ProbeIrradiance",t.ShaderDataType.Texture2D),e.addShaderUniform(V.VOLUMETRICGI_DISTANCE,"u_ProbeDistance",t.ShaderDataType.Texture2D)}static getID(){return V.volumetricCount++}get shaderData(){return this._dataModule.shaderData}constructor(){super(),this._type=H.VolumetricGIType,this._probeCounts=new t.Vector3,this._probeStep=new t.Vector3,this._params=new t.Vector4(8,16,0,0),this._dataModule=T.Render3DModuleDataFactory.createVolumetricGI(),this._dataModule.setParams(this._params),this._volumetricProbeID=V.getID(),this._dataModule.intensity=1}_onEnable(){super._onEnable(),this._dataModule.updateMark=t.ILaya.Scene3D._updateMark}get irradiance(){return this._irradiance}set irradiance(e){this._irradiance!=e&&(this._irradiance&&this._irradiance._removeReference(),e?(e._addReference(),this._dataModule.irradiance=e._texture):this._dataModule.irradiance=null,this._irradiance=e,this._irradiance=e,this._dataModule.updateMark=t.ILaya.Scene3D._updateMark)}get distance(){return this._distance}set distance(e){this._distance!=e&&(this._distance&&this._distance._removeReference(),e?(e._addReference(),this._dataModule.distance=e._texture):this._dataModule.distance=null,this._distance=e,this._dataModule.updateMark=t.ILaya.Scene3D._updateMark)}get normalBias(){return this._params.z}set normalBias(e){this._params.z=e,this._dataModule.setParams(this._params),this._dataModule.updateMark=t.ILaya.Scene3D._updateMark}get viewBias(){return this._params.w}set viewBias(e){this._params.w=e,this._dataModule.setParams(this._params),this._dataModule.updateMark=t.ILaya.Scene3D._updateMark}get irradianceTexel(){return this._params.x}get distanceTexel(){return this._params.y}get intensity(){return this._dataModule.intensity}set intensity(e){e!=this._dataModule.intensity&&(e=Math.max(e,0),this._dataModule.updateMark=t.ILaya.Scene3D._updateMark)}get probeCounts(){return this._probeCounts}set probeCounts(e){e.equal(this._probeCounts)||(e.cloneTo(this._probeCounts),this._dataModule.setProbeCounts(e),this._dataModule.updateMark=t.ILaya.Scene3D._updateMark)}get probeStep(){return this._probeStep}set probeStep(e){e.equal(this._probeStep)||(e.cloneTo(this._probeStep),this._dataModule.setProbeStep(e),this._dataModule.updateMark=t.ILaya.Scene3D._updateMark)}_reCaculateBoundBox(){super._reCaculateBoundBox(),this.bounds.cloneTo(this._dataModule.bound)}_onDestroy(){this.irradiance=null,this.distance=null,this._dataModule.destroy(),this._dataModule=null}_cloneTo(e){e.irradiance=this.irradiance,e.distance=this.distance,this._probeCounts.cloneTo(e._probeCounts),this.probeStep.cloneTo(e.probeStep),e.normalBias=this.normalBias,e.viewBias=this.viewBias,e.intensity=this.intensity}}V.BlockName="VolumetricGIProbe",V.volumetricCount=0;class U{constructor(){this._GIVolumes=new t.SingletonList,this._needUpdateAllRender=!0}hasVolume(){return this._GIVolumes.length>0}removeVolumetricGI(e){e._baseRenderNode.shaderData.removeDefine(V.SHADERDEFINE_VOLUMETRICGI),e.lightProbe=null}add(e){this._GIVolumes.add(e),this._needUpdateAllRender=!0}remove(e){this._GIVolumes.remove(e),this._needUpdateAllRender=!0}_updateRenderObject(e){if(0==this._GIVolumes.length)return void this.removeVolumetricGI(e);let t,r=e.bounds,a=0,i=0,n=this._GIVolumes.elements;for(let e=0;e<this._GIVolumes.length;e++){let s=n[e];if(t){if(t.importance>s.importance)continue;if(i=r.calculateBoundsintersection(s.bounds),i<a&&t.importance==s.importance)continue}else if(i=r.calculateBoundsintersection(s.bounds),i<a)continue;t=s,a=i}t?e.lightProbe=t:this.removeVolumetricGI(e)}handleMotionlist(e){for(let t=0;t<e.length;t++){let r=e.elements[t];r._supportVolumetricGI&&this._updateRenderObject(r)}this._needUpdateAllRender=!1}reCaculateAllRenderObjects(e){for(let t=0;t<e.length;t++){let r=e.elements[t];r._supportVolumetricGI&&this._updateRenderObject(r)}this._needUpdateAllRender=!1}destroy(){let e=this._GIVolumes.length;for(var t=0;t<e;t++)this._GIVolumes.elements[t].destroy()}}class H{constructor(){this._motionObjects=new t.SingletonList,this._volumeList=new t.SingletonList,this._needUpdateAllRender=!1,this._regVolumeManager={},this._reflectionProbeManager=new b,this._regVolumeManager[H.ReflectionProbeVolumeType]=this._reflectionProbeManager,this._volumetricGIManager=new U,this._regVolumeManager[H.VolumetricGIType]=this._volumetricGIManager}get reflectionProbeManager(){return this._reflectionProbeManager}get volumetricGIManager(){return this._volumetricGIManager}add(e){let t=this._regVolumeManager[e.type];t?t.add(e):(this._volumeList.add(e),this._needUpdateAllRender=!0)}remove(e){let t=this._regVolumeManager[e.type];t?t.remove(e):(this._volumeList.remove(e),this._needUpdateAllRender=!0)}addMotionObject(e){this._motionObjects.add(e)}needUpdateMotionObject(e){return this._volumeList.length>0||(!(!e._surportReflectionProbe||1!=e.reflectionMode||!this._reflectionProbeManager.hasUserProbe()&&e.probReflection)||!!e._supportVolumetricGI&&this._volumetricGIManager.hasVolume())}removeMotionObject(e){this._motionObjects.remove(e)}_updateRenderObject(e){if(0==this._volumeList.length)return void(e.volume=null);let t=this._volumeList.elements,r=e.bounds.getCenter(),a=null;for(var i=0,n=this._volumeList.length;i<n;i++){let e=t[i],n=e.bounds;M.containPoint(n,r)&&(a=e)}e.volume=a}handleMotionlist(){if(0!=this._motionObjects.length){var e=this._motionObjects.elements;if(this._volumeList.length>0)for(var t=0,r=this._motionObjects.length;t<r;t++)this._updateRenderObject(e[t]);this.reflectionProbeManager._needUpdateAllRender||this.reflectionProbeManager.handleMotionlist(this._motionObjects),this.volumetricGIManager._needUpdateAllRender||this.volumetricGIManager.handleMotionlist(this._motionObjects),this.clearMotionObjects()}}reCaculateAllRenderObjects(e){if(this._needUpdateAllRender){for(var t=e.elements,r=0,a=e.length;r<a;r++)this._updateRenderObject(t[r]);this._needUpdateAllRender=!1}else this.handleMotionlist();this.reflectionProbeManager._needUpdateAllRender?this.reflectionProbeManager.reCaculateAllRenderObjects(e):this.reflectionProbeManager.handleMotionlist(this._motionObjects),this.volumetricGIManager._needUpdateAllRender?this.volumetricGIManager.reCaculateAllRenderObjects(e):this.volumetricGIManager.handleMotionlist(this._motionObjects)}needreCaculateAllRenderObjects(){return this._needUpdateAllRender||this.reflectionProbeManager._needUpdateAllRender||this.volumetricGIManager._needUpdateAllRender}clearMotionObjects(){this._motionObjects.length=0,this._motionObjects.elements.length>100&&(this._motionObjects.elements.length=100),this._motionObjects.elements.fill(null)}destroy(){this._reflectionProbeManager.destroy(),this._volumetricGIManager.destroy()}}H.ReflectionProbeVolumeType=1,H.VolumetricGIType=2,e.AmbientMode=void 0,(w=e.AmbientMode||(e.AmbientMode={}))[w.SolidColor=0]="SolidColor",w[w.SphericalHarmonics=1]="SphericalHarmonics",e.ReflectionProbeMode=void 0,(B=e.ReflectionProbeMode||(e.ReflectionProbeMode={}))[B.off=0]="off",B[B.simple=1]="simple";class G extends O{static getID(){return G.reflectionCount++}static init(){G.SHADERDEFINE_GI_IBL=t.Shader3D.getDefineByName("GI_IBL");let e=G.CommandMap=t.LayaGL.renderDeviceFactory.createGlobalUniformMap(G.BlockName);const r=(r,a,i=0)=>{let n=t.Shader3D.propertyNameToID(r);return i>0?e.addShaderUniformArray(n,r,a,i):e.addShaderUniform(n,r,a),n};G.AMBIENTCOLOR=r("u_AmbientColor",t.ShaderDataType.Vector4),G.AMBIENTSH=r("u_IblSH",t.ShaderDataType.Vector3,9),G.IBLTEX=r("u_IBLTex",t.ShaderDataType.TextureCube),G.IBLROUGHNESSLEVEL=r("u_IBLRoughnessLevel",t.ShaderDataType.Float),G.AMBIENTINTENSITY=r("u_AmbientIntensity",t.ShaderDataType.Float),G.REFLECTIONINTENSITY=r("u_ReflectionIntensity",t.ShaderDataType.Float),G.REFLECTIONCUBE_PROBEPOSITION=r("u_SpecCubeProbePosition",t.ShaderDataType.Vector3),G.REFLECTIONCUBE_PROBEBOXMAX=r("u_SpecCubeBoxMax",t.ShaderDataType.Vector3),G.REFLECTIONCUBE_PROBEBOXMIN=r("u_SpecCubeBoxMin",t.ShaderDataType.Vector3)}constructor(){super(),this._ambientColor=new t.Color,this._isScene=!1,this._destroyedByManager=!1,this._importance=0,this._type=H.ReflectionProbeVolumeType,this._dataModule=T.Render3DModuleDataFactory.createReflectionProbe(),this._dataModule.bound=this._bounds,this.ambientIntensity=1,this.reflectionIntensity=1,this.boundsMax=new t.Vector3(5,5,5),this.boundsMin=new t.Vector3(-5,-5,-5),this._reflectionProbeID=G.getID(),this.ambientMode=e.AmbientMode.SolidColor,this._dataModule.updateMark=-1}get shaderData(){return this._dataModule.shaderData}get boxProjection(){return this._dataModule.boxProjection}set boxProjection(e){e!=this._dataModule.boxProjection&&(this._dataModule.updateMark=t.ILaya.Scene3D._updateMark),this._dataModule.boxProjection=e}get importance(){return this._importance}set importance(e){this._importance=e}get ambientIntensity(){return this._dataModule.ambientIntensity}set ambientIntensity(e){e!=this._dataModule.ambientIntensity&&(this._dataModule.ambientIntensity=e,this._dataModule.updateMark=t.ILaya.Scene3D._updateMark)}get reflectionIntensity(){return this._dataModule.reflectionIntensity}set reflectionIntensity(e){e!=this._dataModule.reflectionIntensity&&(e=Math.max(e,0),this._dataModule.reflectionIntensity=e,this._dataModule.updateMark=t.ILaya.Scene3D._updateMark)}_reCaculateBoundBox(){super._reCaculateBoundBox(),this.owner&&this._dataModule.setProbePosition(this.owner.transform.position),this.bounds.cloneTo(this._dataModule.bound)}get bounds(){return this._bounds}get boundsMax(){return this._primitiveBounds.getMax()}set boundsMax(e){super.boundsMax=e,this.boxProjection&&(this._dataModule.updateMark=t.ILaya.Scene3D._updateMark)}get boundsMin(){return this._primitiveBounds.getMin()}set boundsMin(e){super.boundsMin=e,this.boxProjection&&(this._dataModule.updateMark=t.ILaya.Scene3D._updateMark)}get probePosition(){return this.owner.transform.position}get ambientColor(){return this._ambientColor}set ambientColor(r){r.cloneTo(this._ambientColor),this._dataModule.setAmbientColor(this._ambientColor),this.ambientMode==e.AmbientMode.SolidColor&&(this._dataModule.updateMark=t.ILaya.Scene3D._updateMark)}get ambientSH(){return this._ambientSH}set ambientSH(r){this.ambientMode==e.AmbientMode.SphericalHarmonics&&(this._dataModule.updateMark=t.ILaya.Scene3D._updateMark),this._ambientSH=r,this._dataModule.setAmbientSH(this._ambientSH)}get ambientMode(){return this._dataModule.ambientMode}set ambientMode(e){e!=this.ambientMode&&(this._dataModule.ambientMode=e,this._dataModule.updateMark=t.ILaya.Scene3D._updateMark)}get iblTex(){return this._iblTex}set iblTex(e){this._iblTex!=e&&(this._iblTex&&this._iblTex._removeReference(),this._iblTex=e,this._dataModule.iblTex=null,e&&(e._addReference(),this._dataModule.iblTex=e._texture),this._dataModule.updateMark=t.ILaya.Scene3D._updateMark)}get iblTexRGBD(){return this._dataModule.iblTexRGBD}set iblTexRGBD(e){e!=this._dataModule.iblTexRGBD&&(this._dataModule.iblTexRGBD=e,this._dataModule.updateMark=t.ILaya.Scene3D._updateMark)}_onEnable(){super._onEnable(),this._dataModule.updateMark=t.ILaya.Scene3D._updateMark}destroy(){this._isScene?console.warn("Scene reflection probe can not be destroyed directly."):super.destroy()}_destroyByManager(){this._destroyedByManager||(this._destroyedByManager=!0,super.destroy())}_onDestroy(){this.iblTex=null,this._dataModule.destroy()}}G.BlockName="ReflectionProbe",G.reflectionCount=0,G.defaultTextureHDRDecodeValues=new t.Vector4(1,1,0,0);class k{}e.RenderBitFlag=void 0,(P=e.RenderBitFlag||(e.RenderBitFlag={}))[P.RenderBitFlag_Batch=0]="RenderBitFlag_Batch",P[P.RenderBitFlag_Editor=1]="RenderBitFlag_Editor",P[P.RenderBitFlag_InstanceBatch=2]="RenderBitFlag_InstanceBatch",P[P.RenderBitFlag_VertexMergeBatch=3]="RenderBitFlag_VertexMergeBatch",e.VisibalRangeFlag=void 0,(L=e.VisibalRangeFlag||(e.VisibalRangeFlag={}))[L.None=0]="None",L[L.BASERENDERSET=1]="BASERENDERSET",L[L.LOD=2]="LOD",e.IrradianceMode=void 0,(F=e.IrradianceMode||(e.IrradianceMode={}))[F.LightMap=0]="LightMap",F[F.VolumetricGI=1]="VolumetricGI",F[F.Common=2]="Common",e.propertyChangeFlag=void 0,(N=e.propertyChangeFlag||(e.propertyChangeFlag={}))[N.material=0]="material",N[N.renderELement=1]="renderELement",N[N.geometry=2]="geometry",N[N.lightmap=3]="lightmap",N[N.invertY=4]="invertY",N[N.reflection=5]="reflection",N[N.volumGI=6]="volumGI",N[N.castShadow=7]="castShadow",N[N.receiveShadow=8]="receiveShadow",N[N.transform=9]="transform",N[N.lightmapData=10]="lightmapData",N[N.RenderCustomData=11]="RenderCustomData",N[N.VisibalRange=12]="VisibalRange",N[N.SimpleSkineParam=13]="SimpleSkineParam";class z extends t.Component{static __init__(){z.shaderValueInit()}static getMeshDefine(e,r){r.length=0;for(var a=0,i=e._subMeshes.length;a<i;a++)for(var n=e.getSubMesh(a)._vertexBuffer.vertexDeclaration._vertexElements,s=0,o=n.length;s<o;s++){switch(n[s]._elementUsage){case t.VertexMesh.MESH_COLOR0:r.push(A.SHADERDEFINE_COLOR);break;case t.VertexMesh.MESH_TEXTURECOORDINATE0:r.push(A.SHADERDEFINE_UV0);break;case t.VertexMesh.MESH_TEXTURECOORDINATE1:r.push(A.SHADERDEFINE_UV1);break;case t.VertexMesh.MESH_TANGENT0:r.push(A.SHADERDEFINE_TANGENT);break;case t.VertexMesh.MESH_BLENDINDICES0:r.push(A.SHADERDEFINE_BONEI);break;case t.VertexMesh.MESH_BLENDWEIGHT0:r.push(A.SHADERDEFINE_BONEW)}}}static changeVertexDefine(e,t,r){var a=e;if(a){z.getMeshDefine(a,z._meshVerticeDefine);for(var i=0,n=z._meshVerticeDefine.length;i<n;i++)r.removeDefine(z._meshVerticeDefine[i])}if(t){z.getMeshDefine(t,z._meshVerticeDefine);for(i=0,n=z._meshVerticeDefine.length;i<n;i++)r.addDefine(z._meshVerticeDefine[i])}}static shaderValueInit(){k.SHADERDEFINE_GI_LEGACYIBL=t.Shader3D.getDefineByName("GI_LEGACYIBL"),k.SHADERDEFINE_IBL_RGBD=t.Shader3D.getDefineByName("IBL_RGBD"),k.SHADERDEFINE_SPECCUBE_BOX_PROJECTION=t.Shader3D.getDefineByName("SPECCUBE_BOX_PROJECTION")}get enabled(){return super.enabled}set enabled(e){super.enabled=e,this._baseRenderNode.enable=e}set visibalMin(t){e.VisibalRangeFlag.BASERENDERSET>=this._baseRenderNode.visibalRangeBit&&(this._baseRenderNode.visibalMin=t,this._batchRender&&this._batchRender.updateProperty(this,e.propertyChangeFlag.VisibalRange))}get visibalMin(){return this._baseRenderNode.visibalMin}set visibalMax(t){e.VisibalRangeFlag.BASERENDERSET>=this._baseRenderNode.visibalRangeBit&&(this._baseRenderNode.visibalMax=t,this._batchRender&&this._batchRender.updateProperty(this,e.propertyChangeFlag.VisibalRange))}get visibalMax(){return this._baseRenderNode.visibalMax}get renderOrder(){return this._baseRenderNode.renderOrder}set renderOrder(e){this._baseRenderNode.renderOrder=e}get sortingFudge(){return this._baseRenderNode.sortingFudge}set sortingFudge(e){this._baseRenderNode.sortingFudge=e}get renderbitFlag(){return this._baseRenderNode.renderbitFlag}get boundsChange(){return this._baseRenderNode.boundsChange}set boundsChange(e){this._baseRenderNode.boundsChange=e}get renderNode(){return this._baseRenderNode}get geometryBounds(){return this._baseRenderNode.baseGeometryBounds}set geometryBounds(e){this._baseRenderNode.baseGeometryBounds=e}get lightmapIndex(){return this._baseRenderNode.lightmapIndex}set lightmapIndex(e){this._baseRenderNode.lightmapIndex=e}setLightmapIndex(t){let r=this._scene;-1!=t&&r.lightmaps[t]?this._baseRenderNode.lightmap=r.lightmaps[t]._dataModule:this._baseRenderNode.lightmap=null,this._baseRenderNode._applyLightMapParams&&this._baseRenderNode._applyLightMapParams(),this._getIrradientMode(),this._batchRender&&this._batchRender.updateProperty(this,e.propertyChangeFlag.lightmap)}get irradientMode(){return this._baseRenderNode.irradientMode}get lightmapScaleOffset(){return this._lightmapScaleOffset}set lightmapScaleOffset(e){e.cloneTo(this._lightmapScaleOffset),this._baseRenderNode.setLightmapScaleOffset(this._lightmapScaleOffset)}get sharedMaterial(){return this._sharedMaterials[0]}set sharedMaterial(t){if(t&&!this._isMaterialVaild(t))return;var r=this._sharedMaterials[0];this._changeMaterialReference(r,t),this._sharedMaterials[0]=t;let a=this._renderElements[0];a&&a.material!=t&&(this._materialsInstance[0]=!1,a.material=t),this._isSupportRenderFeature(),this._batchRender&&this._batchRender.updateProperty(this,e.propertyChangeFlag.material)}get sharedMaterials(){return this._sharedMaterials.slice()}set sharedMaterials(e){var t=this._materialsInstance,r=this._sharedMaterials;if(e){let a=e.length;for(let i=0;i<a;i++){let a=e[i];if(a&&!this._isMaterialVaild(a))continue;let n=r[i];this._changeMaterialReference(n,a),r[i]=a;let s=this._renderElements[i];s&&s.material!=a&&(t[i]=!1,s.material=a)}for(let e=a,t=r.length;e<t;e++){let t=r[e];t&&t._removeReference();let a=this._renderElements[e];a&&(a.material=null)}t.length=a,r.length=a}else{for(let e=0,t=r.length;e<t;e++){let t=r[e];t&&t._removeReference()}this._sharedMaterials=[]}this._isSupportRenderFeature()}get bounds(){return this._baseRenderNode.bounds}get receiveShadow(){return this._receiveShadow}set receiveShadow(t){this._receiveShadow!==t&&(this._receiveShadow=t,t?this._baseRenderNode.shaderData.addDefine(y.SHADERDEFINE_RECEIVE_SHADOW):this._baseRenderNode.shaderData.removeDefine(y.SHADERDEFINE_RECEIVE_SHADOW),this._batchRender&&this._batchRender.updateProperty(this,e.propertyChangeFlag.receiveShadow)),this._baseRenderNode.receiveShadow=t}get castShadow(){return this._baseRenderNode.castShadow}set castShadow(t){this._baseRenderNode.castShadow=t,this._batchRender&&this._batchRender.updateProperty(this,e.propertyChangeFlag.castShadow)}get reflectionMode(){return this._baseRenderNode.reflectionMode}set reflectionMode(e){this._baseRenderNode.reflectionMode=e}get volume(){return this._volume}set volume(e){if(e)return this._volume!=e?(e._addRenderNode&&e._addRenderNode(this),void(this._volume=e)):void(e._motionInVolume&&e._motionInVolume(this));this._volume&&(this._volume._removeRenderNode&&this._volume._removeRenderNode(this),this._volume=null)}get probReflection(){return this._probReflection}set probReflection(t){if(this._probReflection==t)return;this._probReflection=t;const r=G.BlockName;t?(this._baseRenderNode.probeReflection=t._dataModule,this._baseRenderNode.additionShaderData.set(r,t.shaderData)):(this._baseRenderNode.probeReflection=null,this._baseRenderNode.additionShaderData.delete(r)),this._baseRenderNode.additionShaderData=this._baseRenderNode.additionShaderData,this._batchRender&&this._batchRender.updateProperty(this,e.propertyChangeFlag.reflection),this._getIrradientMode()}get lightProbe(){return this._lightProb}set lightProbe(t){if(this._lightProb==t)return;this._baseRenderNode.lightProbUpdateMark=-1,this._lightProb=t;const r=V.BlockName;t?(this._baseRenderNode.volumetricGI=t._dataModule,this._baseRenderNode.additionShaderData.set(r,t.shaderData)):(this._baseRenderNode.volumetricGI=null,this._baseRenderNode.additionShaderData.delete(r)),this._baseRenderNode.additionShaderData=this._baseRenderNode.additionShaderData,this._batchRender&&this._batchRender.updateProperty(this,e.propertyChangeFlag.volumGI),this._getIrradientMode()}setNodeCustomData(e,t){this.renderNode.setNodeCustomData(e,t)}constructor(){super(),this._sharedMaterials=[],this._surportReflectionProbe=!1,this._supportVolumetricGI=!1,this._lightmapScaleOffset=new t.Vector4,this._renderElements=[],this._baseRenderNode=this._createBaseRenderNode(),this._baseRenderNode.visibalRangeBit=0,this._baseRenderNode.shaderData=t.LayaGL.renderDeviceFactory.createShaderData(null),this._baseRenderNode.setCommonUniformMap(this._getcommonUniformMap()),this._baseRenderNode.bounds=this._bounds=new M(t.Vector3.ZERO,t.Vector3.ZERO),this._enabled=!0,this._baseRenderNode.enable=!0,this._materialsInstance=[],this.lightmapIndex=-1,this.receiveShadow=!1,this._baseRenderNode.sortingFudge=0,this._baseRenderNode.renderOrder=0,this.reflectionMode=e.ReflectionProbeMode.simple,this._calculateBoundingBox&&this._baseRenderNode.set_caculateBoundingBox(this,this._calculateBoundingBox),this._renderUpdate&&this._baseRenderNode.set_renderUpdatePreCall(this,this._renderUpdate),this.runInEditor=!0,this.boundsChange=!0,this._baseRenderNode.renderbitFlag=0,this._baseRenderNode.staticMask=1,this.castShadow=!1,this._baseRenderNode.renderNodeType=0}_setRenderElements(){var t,r,a;let i=[];0==this._renderElements.length&&this._inRenderList&&(null===(t=this.owner)||void 0===t||t.scene._removeRenderObject(this)),(null===(r=this.owner)||void 0===r?void 0:r.activeInHierarchy)&&this.enabled&&(null===(a=this.owner)||void 0===a?void 0:a.scene)&&this._renderElements.length>0&&!this._inRenderList&&this.owner.scene._addRenderObject(this),this._renderElements.forEach(e=>{i.push(e._renderElementOBJ)}),this._baseRenderNode.setRenderelements(i,!this._batchRender),this._batchRender&&this._batchRender.updateProperty(this,e.propertyChangeFlag.renderELement)}_onWorldMatNeedChange(t){this.boundsChange=!0,this._addReflectionProbeUpdate(),this._batchRender&&(this._transform.getScaleChangeFlag()&&this._batchRender.updateProperty(this,e.propertyChangeFlag.invertY),this._batchRender.updateProperty(this,e.propertyChangeFlag.transform))}_getcommonUniformMap(){return["Sprite3D"]}_createBaseRenderNode(){return T.Render3DModuleDataFactory.createBaseRenderNode()}renderUpdate(e){}get _is3DRender(){return!0}_onAdded(){this._transform=this.owner.transform,this.owner._isRenderNode++,this.setRenderbitFlag(e.RenderBitFlag.RenderBitFlag_Editor,this.owner._getBit(t.NodeFlags.HIDE_BY_EDITOR)),this._baseRenderNode.transform=this._transform,this._changeLayer(this.owner.layer),this._changeStaticMask(this.owner._isStatic)}_onEnable(){super._onEnable(),this.owner.transform.on(t.Event.TRANSFORM_CHANGED,this,this._onWorldMatNeedChange),this.owner.on(t.Event.LAYER_CHANGE,this,this._changeLayer),this.owner.on(t.Event.STATIC_MASK,this,this._changeStaticMask),this._changeLayer(this.owner.layer),this._changeStaticMask(this.owner._isStatic),this.owner.scene._addRenderObject(this),this._setBelongScene(this.owner.scene)}_onDisable(){this.owner.transform.off(t.Event.TRANSFORM_CHANGED,this,this._onWorldMatNeedChange),this.owner.off(t.Event.LAYER_CHANGE,this,this._changeLayer),this.owner.off(t.Event.STATIC_MASK,this,this._changeStaticMask),this.owner.scene._removeRenderObject(this),this._setUnBelongScene(),this.volume=null}_onDestroy(){this.owner&&this.owner._isRenderNode--,this._scene&&this._scene.sceneRenderableManager.removeRenderObject(this),this._baseRenderNode.destroy(),this._baseRenderNode=null,this._renderElements.forEach(e=>{e.destroy()}),this._renderElements=null;for(let e=0,t=this._sharedMaterials.length;e<t;e++){let t=this._sharedMaterials[e];t&&!t.destroyed&&t._removeReference()}this._sharedMaterials=null,this._bounds=null,this._lightmapScaleOffset=null,this._scene=null,this._transform=null,this._batchRender=null}_getIrradientMode(){this.lightmapIndex>=0?this._baseRenderNode.irradientMode=e.IrradianceMode.LightMap:this.lightProbe?this._baseRenderNode.irradientMode=e.IrradianceMode.VolumetricGI:this._baseRenderNode.irradientMode=e.IrradianceMode.Common}_changeLayer(e){this._baseRenderNode.layer=e}_changeStaticMask(e){this._baseRenderNode.staticMask=e}_changeMaterialReference(e,t){e&&e._removeReference(),t&&t._addReference()}_getInstanceMaterial(e,t){var r=e.clone();return r.name=r.name+"(Instance)",this._materialsInstance[t]=!0,this._changeMaterialReference(this._sharedMaterials[t],r),this._sharedMaterials[t]=r,r}_isSupportRenderFeature(){let e=this._surportReflectionProbe,t=this._supportVolumetricGI;this._surportReflectionProbe=!1,this._supportVolumetricGI=!1;for(var r=this._sharedMaterials,a=0,i=r.length;a<i;a++){var n=r[a];this._surportReflectionProbe||(this._surportReflectionProbe=this._surportReflectionProbe||n&&n._shader._supportReflectionProbe),this._supportVolumetricGI||(this._supportVolumetricGI=this._supportVolumetricGI||n&&n._shader._supportVolumetricGI)}(!e&&this._surportReflectionProbe||!t&&this._supportVolumetricGI)&&this._addReflectionProbeUpdate()}_addReflectionProbeUpdate(){let e=this._scene&&this._scene._volumeManager;e&&e.needUpdateMotionObject(this)&&e.addMotionObject(this)}_setBelongScene(e){this._scene=e,this._onWorldMatNeedChange(1),this._isSupportRenderFeature(),this.setLightmapIndex(this.lightmapIndex),this._statAdd()}_statAdd(){t.LayaGL.statAgent.recordCountData(t.StatElement.C_BaseRenderCount,1)}_statRemove(){t.LayaGL.statAgent.recordCountData(t.StatElement.C_BaseRenderCount,-1)}_setUnBelongScene(){this._statRemove(),this._scene._volumeManager.removeMotionObject(this),this.probReflection=null,this.lightProbe=null;let e=this._batchRender;this._batchRender=e,this._scene=null}_needRender(e,t){return!e||e.intersects(this.bounds)}_cloneTo(e){super._cloneTo(e),e.receiveShadow=this.receiveShadow,e.sharedMaterials=this.sharedMaterials,e.reflectionMode=this.reflectionMode,e.castShadow=this.castShadow,e.sortingFudge=this.sortingFudge,e.renderOrder=this.renderOrder}setRenderbitFlag(e,t){t?this._baseRenderNode.renderbitFlag|=1<<e:this._baseRenderNode.renderbitFlag&=~(1<<e)}get material(){var e=this._sharedMaterials[0];if(e&&!this._materialsInstance[0]){var t=this._getInstanceMaterial(e,0),r=this._renderElements[0];r&&(r.material=t)}return this._sharedMaterials[0]}_isMaterialVaild(e){return!0}set material(e){e&&!this._isMaterialVaild(e)||(this.sharedMaterial=e,this._isSupportRenderFeature())}get materials(){for(var e=0,t=this._sharedMaterials.length;e<t;e++)if(!this._materialsInstance[e]){var r=this._getInstanceMaterial(this._sharedMaterials[e],e),a=this._renderElements[e];a&&(a.material=r)}return this._sharedMaterials.slice()}set materials(e){this.sharedMaterials=e,this._isSupportRenderFeature()}get distanceForSort(){return this._baseRenderNode.sortingFudge}set distanceForSort(e){this._baseRenderNode.sortingFudge=e}}z._meshVerticeDefine=[],z._uniqueIDCounter=0,z._tempBoundBoxCorners=[new t.Vector3,new t.Vector3,new t.Vector3,new t.Vector3,new t.Vector3,new t.Vector3,new t.Vector3,new t.Vector3],z._defaultLightmapScaleOffset=new t.Vector4(1,1,0,0);class W{get transform(){return this._renderElementOBJ.transform}set transform(e){this._transform=e,this._renderElementOBJ.transform=e}get material(){return this._material}set material(e){this._material&&this._material._removeOwnerElement(this._renderElementOBJ),e?(this._material=e,this.material._setOwner3DElement(this._renderElementOBJ)):(this._material=null,this._renderElementOBJ.materialShaderData=null,this._renderElementOBJ.materialRenderQueue=0,this._renderElementOBJ.subShader=this._subShader=null,this._renderElementOBJ.materialId=-1)}get renderSubShader(){return this._subShader}set renderSubShader(e){this._subShader=e,this._renderElementOBJ.subShader=e}get subShaderIndex(){return this._subShaderIndex}set subShaderIndex(e){this._subShaderIndex=e}get render(){return this._baseRender}set render(e){this._baseRender=e,this._renderElementOBJ.renderShaderData=e._baseRenderNode.shaderData}constructor(){this._subShaderIndex=0,this._createRenderElementOBJ()}_createRenderElementOBJ(){this._renderElementOBJ=T.Render3DPassFactory.createRenderElement3D()}setTransform(e){this.transform=e,this._renderElementOBJ.transform=e}setGeometry(e){this._geometry=e,this._renderElementOBJ.geometry=e._geometryElementOBj}destroy(){this.material=null,this._renderElementOBJ=null,this._geometry=null,this._baseRender=null,this._baseRender=null,this._subShader=null}}class Q extends W{constructor(){super(),this._dynamicWorldPositionNormalNeedUpdate=!0,this._renderElementOBJ.canDynamicBatch=!0}_onWorldMatrixChanged(){this._dynamicWorldPositionNormalNeedUpdate=!0}setTransform(e){this.transform!==e&&(this.transform&&this.transform.off(t.Event.TRANSFORM_CHANGED,this,this._onWorldMatrixChanged),e&&e.on(t.Event.TRANSFORM_CHANGED,this,this._onWorldMatrixChanged),this._dynamicWorldPositionNormalNeedUpdate=!0,this.transform=e)}setGeometry(e){this._geometry!==e&&(this._geometry=e,this._renderElementOBJ.geometry=e._geometryElementOBj)}destroy(){this._renderElementOBJ&&(this._transform&&(this._transform.off(t.Event.TRANSFORM_CHANGED,this,this._onWorldMatrixChanged),this._transform=null),super.destroy(),this.instanceSubMesh=null,this.staticBatchElementList&&this.staticBatchElementList.destroy(),this.instanceBatchElementList&&this.instanceBatchElementList.destroy(),this.vertexBatchElementList&&this.vertexBatchElementList.destroy(),this.vertexBatchVertexDeclaration=null)}}class Y extends z{static __init__(){A.SHADERDEFINE_UV0=t.Shader3D.getDefineByName("UV"),A.SHADERDEFINE_COLOR=t.Shader3D.getDefineByName("COLOR"),A.SHADERDEFINE_UV1=t.Shader3D.getDefineByName("UV1"),A.SHADERDEFINE_TANGENT=t.Shader3D.getDefineByName("TANGENT"),A.SHADERDEFINE_BONEW=t.Shader3D.getDefineByName("VBONEW"),A.SHADERDEFINE_BONEI=t.Shader3D.getDefineByName("VBONEI"),A.SHADERDEFINE_GPU_INSTANCE=t.Shader3D.getDefineByName("GPU_INSTANCE")}constructor(){super(),this._revertStaticBatchDefineUV1=!1,this.morphTargetActiveCount=0,this._morphWeightChange=!0,this._morphTargetValues={},this._meshChange=!1,this._projectionViewWorldMatrix=new t.Matrix4x4,this._baseRenderNode.renderNodeType=t.BaseRenderType.MeshRender}_createBaseRenderNode(){return T.Render3DModuleDataFactory.createMeshRenderNode()}_isMaterialVaild(e){return e.checkType(t.ShaderFeatureType.D3)}_createRenderElement(){return new Q}getMesh(){return this._mesh}_onEnable(){super._onEnable();const e=this.owner.getComponent(D);e&&e._enabled&&this._onMeshChange(e.sharedMesh)}_getMeshDefine(e,t){t.length=0,E.getMeshDefine(e,t)}_changeVertexDefine(e){var t=this._baseRenderNode.shaderData,r=this._mesh;if(r){this._getMeshDefine(r,D._meshVerticeDefine);for(var a=0,i=D._meshVerticeDefine.length;a<i;a++)t.removeDefine(D._meshVerticeDefine[a])}if(e){this._getMeshDefine(e,D._meshVerticeDefine);for(a=0,i=D._meshVerticeDefine.length;a<i;a++)t.addDefine(D._meshVerticeDefine[a])}}get morphTargetValues(){return this._morphTargetValues}set morphTargetValues(e){this._morphTargetValues=e}_changeMorphTargetValue(e){this._morphWeightChange=!0}setMorphChannelWeight(e,t){let r=this._mesh;if(r&&r.morphTargetData){let a=r.morphTargetData.getMorphChannel(e);this.morphTargetValues[a.name]=t,this._morphWeightChange=!0}}_applyMorphdata(){let e=this._mesh,r=this._baseRenderNode.shaderData;if(this._morphWeightChange&&e){let a=e.morphTargetData,i=a.channelCount;for(let e=0;e<i;e++){let t=a.getMorphChannelbyIndex(e),r=this.morphTargetValues[t.name],i=0;t.targets.forEach(e=>{r<=e.fullWeight?this.morphTargetWeight[e._index]=(r-i)/(e.fullWeight-i):this.morphTargetWeight[e._index]=1,i=e.fullWeight})}let n=0;this.morphTargetWeight.forEach((e,t)=>{if(e>0){let r=4*n;this.morphTargetActiveData[r]=t,this.morphTargetActiveData[r+1]=e,n++}}),this.morphTargetActiveCount=Math.min(n,t.Config3D.maxMorphTargetCount),t.LayaGL.renderEngine.getCapable(t.RenderCapable.Texture3D)&&(r.setInt(y.MorphActiveCount,this.morphTargetActiveCount),r.setBuffer(y.MorphActiceTargets,this.morphTargetActiveData)),r.update("MorphTarget"),this._morphWeightChange=!1}}_setBelongScene(e){super._setBelongScene(e)}_setUnBelongScene(){super._setUnBelongScene()}_statAdd(){super._statAdd(),t.LayaGL.statAgent.recordCountData(t.StatElement.C_MeshRenderCount,1)}_statRemove(){super._statRemove(),t.LayaGL.statAgent.recordCountData(t.StatElement.C_MeshRenderCount,-1)}_changeMorphData(e){let r=this._baseRenderNode.shaderData,a=this._mesh;let i=t.Config3D.maxMorphTargetCount;if(this.morphTargetActiveData=new Float32Array(4*i),t.LayaGL.renderEngine.getCapable(t.RenderCapable.Texture3D)){if(a&&a.morphTargetData){let e=a.morphTargetData;r.removeDefine(y.SHADERDEFINE_MORPHTARGET),e.vertexDec._vertexElements.forEach(e=>{switch(e.elementUsage){case t.VertexMesh.MESH_POSITION0:r.removeDefine(y.SHADERDEFINE_MORPHTARGET_POSITION);break;case t.VertexMesh.MESH_NORMAL0:r.removeDefine(y.SHADERDEFINE_MORPHTARGET_NORMAL);break;case t.VertexMesh.MESH_TANGENT0:r.removeDefine(y.SHADERDEFINE_MORPHTARGET_TANGENT)}})}if(e&&e.morphTargetData){let a=e.morphTargetData;r.addDefine(y.SHADERDEFINE_MORPHTARGET),a.vertexDec._vertexElements.forEach(e=>{switch(e.elementUsage){case t.VertexMesh.MESH_POSITION0:r.addDefine(y.SHADERDEFINE_MORPHTARGET_POSITION);break;case t.VertexMesh.MESH_NORMAL0:r.addDefine(y.SHADERDEFINE_MORPHTARGET_NORMAL);break;case t.VertexMesh.MESH_TANGENT0:r.addDefine(y.SHADERDEFINE_MORPHTARGET_TANGENT)}}),r.setVector(y.MorphAttriOffset,e.morphTargetData.attributeOffset),r.setTexture(y.MorphTex,e.morphTargetData.targetTexture),r.setVector(y.MorphParams,a.params),r.setBuffer(y.MorphActiceTargets,this.morphTargetActiveData)}}if(a&&a.morphTargetData&&(this.morphTargetWeight=null,this.morphtargetChannels=null,this._morphTargetValues={}),e&&e.morphTargetData&&t.LayaGL.renderEngine.getCapable(t.RenderCapable.Texture3D)){let t=e.morphTargetData,a=t.channelCount;this.morphTargetWeight=new Float32Array(t.targetCount),this.morphtargetChannels=new Array(a);for(let e=0;e<a;e++){let r=t.getMorphChannelbyIndex(e);this.morphtargetChannels[e]=r,this._morphTargetValues[r.name]=0}let i=this._baseRenderNode.additionShaderData;i.set("MorphTarget",r),this._baseRenderNode.additionShaderData=i}else{let e=this._baseRenderNode.additionShaderData;e.delete("MorphTarget"),this._baseRenderNode.additionShaderData=e}}_onMeshChange(e){if(e&&this._mesh!=e){this._changeVertexDefine(e),this._changeMorphData(e),this._mesh=e,e.morphTargetData?this.geometryBounds=e.morphTargetData.bounds:this.geometryBounds=e.bounds;var t=e.subMeshCount;this._renderElements.length=t;let n=this.sharedMaterials;n.length=t;for(var a=0;a<t;a++){var i=this._renderElements[a];i||(i=this._renderElements[a]=this._renderElements[a]?this._renderElements[a]:this._createRenderElement(),this.owner&&i.setTransform(this.owner._transform),i.render=this),n[a]=n[a]||r.defaultMaterial,i.setGeometry(e.getSubMesh(a))}this.sharedMaterials=n,this.boundsChange=!0}else e||(this._renderElements.forEach(e=>{e._renderElementOBJ.destroy(),e.destroy()}),this._renderElements.length=0,this._mesh=null,this._changeVertexDefine(null),this._changeMorphData(null),this.boundsChange=!1);this._setRenderElements(),this._meshChange=!0}_onWorldMatNeedChange(e){super._onWorldMatNeedChange(e),this._mesh||(this.boundsChange=!1),this._baseRenderNode.ismoved.setValue(t.Stat.loopCount,t.LayaGL.renderEngine._framePassCount),this._baseRenderNode.ismoved=this._baseRenderNode.ismoved}renderUpdate(e){if(this._mesh&&(this._mesh.morphTargetData&&t.LayaGL.renderEngine.getCapable(t.RenderCapable.Texture3D)&&this._applyMorphdata(),this._meshChange)){if(1==this._renderElements.length){this._renderElements[0]._renderElementOBJ.isRender=this._renderElements[0]._geometry._prepareRender(e),this._renderElements[0]._geometry._updateRenderParams(e);let t=this.sharedMaterial;this._renderElements[0].material=t}else for(var r=0,a=this._renderElements.length;r<a;r++){this._renderElements[r]._renderElementOBJ.isRender=this._renderElements[r]._geometry._prepareRender(e),this._renderElements[r]._geometry._updateRenderParams(e);let t=this.sharedMaterials[r];this._renderElements[r].material=t}this._meshChange=!1}}_onDestroy(){super._onDestroy(),this._morphTargetValues=null}_cloneTo(e){super._cloneTo(e),e._onMeshChange(this._mesh),this.morphTargetWeight&&(e.morphTargetWeight=new Float32Array(this.morphTargetWeight));for(const t in this._morphTargetValues)e._morphTargetValues[t]=this._morphTargetValues[t]}}class X extends y{get meshFilter(){return this._meshFilter}get meshRenderer(){return this._render}constructor(e=null,t=null){super(t),this._meshFilter=this.addComponent(D),this._render=this.addComponent(Y),e&&(this._meshFilter.sharedMesh=e)}}class K{static get vertexDeclaration(){return K._vertexDeclaration}static __init__(){K._vertexDeclaration=new t.VertexDeclaration(40,[new t.VertexElement(0,t.VertexElementFormat.Vector3,t.VertexMesh.MESH_POSITION0),new t.VertexElement(12,t.VertexElementFormat.Vector4,t.VertexMesh.MESH_COLOR0),new t.VertexElement(28,t.VertexElementFormat.Vector3,t.VertexMesh.MESH_NORMAL0)])}get vertexDeclaration(){return K._vertexDeclaration}constructor(){}}class j{static __init__(){j._screenShader=t.Shader3D.find("BlitScreen"),j.SCREENTEXTURE_ID=t.Shader3D.propertyNameToID(j.SCREENTEXTURE_NAME),j.SCREENTEXTUREOFFSETSCALE_ID=t.Shader3D.propertyNameToID(j.SCREENTEXTUREOFFSETSCALE_NAME),j.MAINTEXTURE_TEXELSIZE_ID=t.Shader3D.propertyNameToID(j.MAINTEXTURE_TEXELSIZE_NAME)}constructor(){this._commandBuffer=null}recover(){this._commandBuffer=null}destroy(){this._commandBuffer=null,this._context=null}}j.SCREENTEXTURE_NAME="u_MainTex",j.SCREENTEXTUREOFFSETSCALE_NAME="u_OffsetScale",j.MAINTEXTURE_TEXELSIZE_NAME="u_MainTex_TexelSize";class J{static __init__(){J._instance=new J,this.GammaCorrect=t.Shader3D.getDefineByName("GAMMACORRECT")}get camera(){return this._camera}set camera(e){this._camera=e,this._contextOBJ.cameraModuleData=e?e._renderDataModule:null}set destTarget(e){this._contextOBJ.setRenderTarget(e?e._renderTarget:null,t.RenderClearFlag.Nothing)}set viewport(e){this._contextOBJ.setViewPort(e)}set scissor(e){this._contextOBJ.setScissor(e)}get invertY(){return this._contextOBJ.invertY}set invertY(e){this._contextOBJ.invertY=e}get pipelineMode(){return this._contextOBJ.pipelineMode}set pipelineMode(e){this._contextOBJ.pipelineMode=e}get cameraShaderValue(){return this._contextOBJ.cameraData}set cameraShaderValue(e){this._contextOBJ.cameraData=e}get scene(){return this._scene}set scene(e){e?(this._contextOBJ.sceneData=e._shaderValues,this._scene=e,this._contextOBJ.sceneModuleData=e._sceneModuleData):(this._contextOBJ.sceneModuleData=null,this._contextOBJ.sceneData=null,this._scene=null)}changeViewport(e,r,a,i){t.Viewport.TEMP.set(e,r,a,i),this.viewport=t.Viewport.TEMP}changeScissor(e,r,a,i){t.Vector4.TEMP.setValue(e,r,a,i),this.scissor=t.Vector4.TEMP}applyContext(e){this._contextOBJ.cameraUpdateMask=e}drawRenderElement(e){this._contextOBJ.drawRenderElementOne(e)}constructor(){this.configPipeLineMode="Forward",this._contextOBJ=T.Render3DPassFactory.createRenderContext3D()}}class q{constructor(){}static lightAttenTexture(e,t,r,a,i,n){var s=e/r,o=1/(1+25*s);s>=.64&&(s>1?o=0:o*=1-(s-.64)/.36),n[i]=Math.floor(255*o+.5)}static haloTexture(e,t,r,a,i,n){var s=(e-(r>>=1))/r,o=(t-(a>>=1))/a,l=s*s+o*o;l>1&&(l=1),n[i]=Math.floor(255*(1-l)+.5)}static _generateTexture2D(e,r,a,i){var n=0,s=0;switch(e.format){case t.TextureFormat.R8G8B8:s=3;break;case t.TextureFormat.R8G8B8A8:s=4;break;case t.TextureFormat.Alpha8:s=1;break;default:throw"GeneratedTexture._generateTexture: unkonw texture format."}for(var o=new Uint8Array(r*a*s),l=0;l<a;l++)for(var h=0;h<r;h++)i(h,l,r,a,n,o),n+=s;e.setPixelsData(o,!1,!1)}}class Z{static _createFloatTextureBuffer(e,r){var a=new t.Texture2D(e,r,t.TextureFormat.R32G32B32A32,!1,!1);return a.setPixelsData(null,!1,!1),a.filterMode=t.FilterMode.Point,a.wrapModeU=t.WrapMode.Clamp,a.wrapModeV=t.WrapMode.Clamp,a.anisoLevel=1,a}static _rotationTransformScaleSkinAnimation(e,t,r,a,i,n,s,o,l,h,d,c){var u,_,f,m,g,p=ae,S=ie,T=ne,A=a+a,E=i+i,D=n+n,R=a*A,x=i*A,y=i*E,M=n*A,C=n*E,v=n*D,I=s*A,w=s*E,B=s*D;for(p[15]=1,p[0]=1-y-v,p[1]=x+B,p[2]=M-w,p[4]=x-B,p[5]=1-R-v,p[6]=C+I,p[8]=M+w,p[9]=C-I,p[10]=1-R-y,S[15]=1,S[0]=o,S[5]=l,S[10]=h,u=0;u<4;u++)_=p[u],f=p[u+4],m=p[u+8],g=p[u+12],T[u]=_,T[u+4]=f,T[u+8]=m,T[u+12]=_*e+f*t+m*r+g;for(u=0;u<4;u++)_=T[u],f=T[u+4],m=T[u+8],g=T[u+12],d[u+c]=_*S[0]+f*S[1]+m*S[2]+g*S[3],d[u+c+4]=_*S[4]+f*S[5]+m*S[6]+g*S[7],d[u+c+8]=_*S[8]+f*S[9]+m*S[10]+g*S[11],d[u+c+12]=_*S[12]+f*S[13]+m*S[14]+g*S[15]}static billboardTrans(e,r,a,i){t.Vector3.normalize(a,te),t.Vector3.cross(r,a,ee),t.Vector3.normalize(ee,ee),t.Vector3.scale(ee,e.x,i),t.Vector3.scale(a,e.y,te),t.Vector3.add(i,te,i)}static PointinTriangle(e,t,r,a){let i=r.vsub(e,ee),n=t.vsub(e,te),s=a.vsub(e,re),o=i.dot(i),l=i.dot(n),h=i.dot(s),d=n.dot(n),c=n.dot(s),u=1/(o*d-l*l),_=(d*h-l*c)*u;if(_<0||_>1)return!1;let f=(o*c-l*h)*u;return!(f<0||f>1)&&_+f<=1}static _computeBoneAndAnimationDatasByBindPoseMatrxix(e,t,r,a,i,n){var s,o,l=0,h=0,d=e.length;for(s=0;s<d;l+=e[s].keyframeWidth,h+=16,s++)Z._rotationTransformScaleSkinAnimation(t[l+0],t[l+1],t[l+2],t[l+3],t[l+4],t[l+5],t[l+6],t[l+7],t[l+8],t[l+9],a,h),0!=s&&(o=16*e[s].parentIndex,Z.mulMatrixByArray(a,o,a,h,a,h));var c=r.length;for(s=0;s<c;s++)Z.mulMatrixByArrayAndMatrixFast(a,16*n[s],r[s],i,16*s)}static _computeAnimationDatasByArrayAndMatrixFast(e,t,r,a){for(var i=0,n=e.length;i<n;i++)Z.mulMatrixByArrayAndMatrixFast(t,16*a[i],e[i],r,16*i)}static _computeBoneAndAnimationDatasByBindPoseMatrxixOld(e,t,r,a,i){var n,s,o=0,l=0,h=e.length;for(n=0;n<h;o+=e[n].keyframeWidth,l+=16,n++)Z._rotationTransformScaleSkinAnimation(t[o+7],t[o+8],t[o+9],t[o+3],t[o+4],t[o+5],t[o+6],t[o+0],t[o+1],t[o+2],a,l),0!=n&&(s=16*e[n].parentIndex,Z.mulMatrixByArray(a,s,a,l,a,l));var d=r.length;for(n=0;n<d;n++){var c=16*n;Z.mulMatrixByArrayAndMatrixFast(a,c,r[n],i,c)}}static _computeAnimationDatasByArrayAndMatrixFastOld(e,t,r){for(var a=e.length,i=0;i<a;i++){var n=16*i;Z.mulMatrixByArrayAndMatrixFast(t,n,e[i],r,n)}}static _computeRootAnimationData(e,t,r){for(var a=0,i=0,n=0,s=e.length;a<s;i+=e[a].keyframeWidth,n+=16,a++)Z.createAffineTransformationArray(t[i+0],t[i+1],t[i+2],t[i+3],t[i+4],t[i+5],t[i+6],t[i+7],t[i+8],t[i+9],r,n)}static transformVector3ArrayByQuat(e,t,r,a,i){var n=e[t],s=e[t+1],o=e[t+2],l=r.x,h=r.y,d=r.z,c=r.w,u=c*n+h*o-d*s,_=c*s+d*n-l*o,f=c*o+l*s-h*n,m=-l*n-h*s-d*o;a[i]=u*c+m*-l+_*-d-f*-h,a[i+1]=_*c+m*-h+f*-l-u*-d,a[i+2]=f*c+m*-d+u*-h-_*-l}static mulMatrixByArray(e,t,r,a,i,n){var s,o,l,h,d;if(i===r){for(r=se,s=0;s<16;++s)r[s]=i[n+s];a=0}for(s=0;s<4;s++)o=e[t+s],l=e[t+s+4],h=e[t+s+8],d=e[t+s+12],i[n+s]=o*r[a+0]+l*r[a+1]+h*r[a+2]+d*r[a+3],i[n+s+4]=o*r[a+4]+l*r[a+5]+h*r[a+6]+d*r[a+7],i[n+s+8]=o*r[a+8]+l*r[a+9]+h*r[a+10]+d*r[a+11],i[n+s+12]=o*r[a+12]+l*r[a+13]+h*r[a+14]+d*r[a+15]}static mulMatrixByArrayFast(e,t,r,a,i,n){var s,o,l,h,d;for(s=0;s<4;s++)o=e[t+s],l=e[t+s+4],h=e[t+s+8],d=e[t+s+12],i[n+s]=o*r[a+0]+l*r[a+1]+h*r[a+2]+d*r[a+3],i[n+s+4]=o*r[a+4]+l*r[a+5]+h*r[a+6]+d*r[a+7],i[n+s+8]=o*r[a+8]+l*r[a+9]+h*r[a+10]+d*r[a+11],i[n+s+12]=o*r[a+12]+l*r[a+13]+h*r[a+14]+d*r[a+15]}static mulMatrixByArrayAndMatrixFast(e,t,r,a,i){var n,s,o,l,h,d=r.elements,c=d[0],u=d[1],_=d[2],f=d[3],m=d[4],g=d[5],p=d[6],S=d[7],T=d[8],A=d[9],E=d[10],D=d[11],R=d[12],x=d[13],y=d[14],M=d[15],C=t,v=t+4,I=t+8,w=t+12,B=i,P=i+4,L=i+8,F=i+12;for(n=0;n<4;n++)s=e[C+n],o=e[v+n],l=e[I+n],h=e[w+n],a[B+n]=s*c+o*u+l*_+h*f,a[P+n]=s*m+o*g+l*p+h*S,a[L+n]=s*T+o*A+l*E+h*D,a[F+n]=s*R+o*x+l*y+h*M}static createAffineTransformationArray(e,t,r,a,i,n,s,o,l,h,d,c){var u=a+a,_=i+i,f=n+n,m=a*u,g=a*_,p=a*f,S=i*_,T=i*f,A=n*f,E=s*u,D=s*_,R=s*f;d[c+0]=(1-(S+A))*o,d[c+1]=(g+R)*o,d[c+2]=(p-D)*o,d[c+3]=0,d[c+4]=(g-R)*l,d[c+5]=(1-(m+A))*l,d[c+6]=(T+E)*l,d[c+7]=0,d[c+8]=(p+D)*h,d[c+9]=(T-E)*h,d[c+10]=(1-(m+S))*h,d[c+11]=0,d[c+12]=e,d[c+13]=t,d[c+14]=r,d[c+15]=1}static transformVector3ArrayToVector3ArrayCoordinate(e,t,r,a,i){var n=e[t+0],s=e[t+1],o=e[t+2],l=r.elements,h=n*l[3]+s*l[7]+o*l[11]+l[15];a[i]=n*l[0]+s*l[4]+o*l[8]+l[12]/h,a[i+1]=n*l[1]+s*l[5]+o*l[9]+l[13]/h,a[i+2]=n*l[2]+s*l[6]+o*l[10]+l[14]/h}static transformVector3ArrayToVector3ArrayNormal(e,t,r,a,i){var n=e[t+0],s=e[t+1],o=e[t+2],l=r.elements;a[i]=n*l[0]+s*l[4]+o*l[8],a[i+1]=n*l[1]+s*l[5]+o*l[9],a[i+2]=n*l[2]+s*l[6]+o*l[10]}static transformLightingMapTexcoordArray(e,t,r,a,i){a[i+0]=e[t+0]*r.x+r.z,a[i+1]=1-((1-e[t+1])*r.y+r.w)}static getURLVerion(e){var t=e.indexOf("?");return t>=0?e.substr(t):null}static _createAffineTransformationArray(e,t,r,a){var i=t.x,n=t.y,s=t.z,o=t.w,l=i+i,h=n+n,d=s+s,c=i*l,u=i*h,_=i*d,f=n*h,m=n*d,g=s*d,p=o*l,S=o*h,T=o*d,A=r.x,E=r.y,D=r.z;a[0]=(1-(f+g))*A,a[1]=(u+T)*A,a[2]=(_-S)*A,a[3]=0,a[4]=(u-T)*E,a[5]=(1-(c+g))*E,a[6]=(m+p)*E,a[7]=0,a[8]=(_+S)*D,a[9]=(m-p)*D,a[10]=(1-(c+f))*D,a[11]=0,a[12]=e.x,a[13]=e.y,a[14]=e.z,a[15]=1}static _mulMatrixArray(e,t,r,a,i){var n=t,s=e,o=a,l=n[r],h=n[r+1],d=n[r+2],c=n[r+3],u=n[r+4],_=n[r+5],f=n[r+6],m=n[r+7],g=n[r+8],p=n[r+9],S=n[r+10],T=n[r+11],A=n[r+12],E=n[r+13],D=n[r+14],R=n[r+15],x=s[0],y=s[1],M=s[2],C=s[3],v=s[4],I=s[5],w=s[6],B=s[7],P=s[8],L=s[9],F=s[10],N=s[11],O=s[12],b=s[13],V=s[14],U=s[15];o[i]=l*x+h*v+d*P+c*O,o[i+1]=l*y+h*I+d*L+c*b,o[i+2]=l*M+h*w+d*F+c*V,o[i+3]=l*C+h*B+d*N+c*U,o[i+4]=u*x+_*v+f*P+m*O,o[i+5]=u*y+_*I+f*L+m*b,o[i+6]=u*M+_*w+f*F+m*V,o[i+7]=u*C+_*B+f*N+m*U,o[i+8]=g*x+p*v+S*P+T*O,o[i+9]=g*y+p*I+S*L+T*b,o[i+10]=g*M+p*w+S*F+T*V,o[i+11]=g*C+p*B+S*N+T*U,o[i+12]=A*x+E*v+D*P+R*O,o[i+13]=A*y+E*I+D*L+R*b,o[i+14]=A*M+E*w+D*F+R*V,o[i+15]=A*C+E*B+D*N+R*U}static arcTanAngle(e,t){return 0==e?1==t?Math.PI/2:-Math.PI/2:e>0?Math.atan(t/e):e<0?t>0?Math.atan(t/e)+Math.PI:Math.atan(t/e)-Math.PI:0}static angleTo(e,r,a){t.Vector3.subtract(r,e,$),t.Vector3.normalize($,$),a.x=Math.asin($.y),a.y=Z.arcTanAngle(-$.z,-$.x)}static transformQuat(e,t,r){var a=t,i=e.x,n=e.y,s=e.z,o=a[0],l=a[1],h=a[2],d=a[3],c=d*i+l*s-h*n,u=d*n+h*i-o*s,_=d*s+o*n-l*i,f=-o*i-l*n-h*s;r.x=c*d+f*-o+u*-h-_*-l,r.y=u*d+f*-l+_*-o-c*-h,r.z=_*d+f*-h+c*-l-u*-o}static quaternionWeight(e,t,r){r.x=e.x*t,r.y=e.y*t,r.z=e.z*t,r.w=e.w}static quaternionConjugate(e,t){t.x=-e.x,t.y=-e.y,t.z=-e.z,t.w=e.w}static scaleWeight(e,t,r){var a=e.x,i=e.y,n=e.z;r.x=a>0?Math.pow(Math.abs(a),t):-Math.pow(Math.abs(a),t),r.y=i>0?Math.pow(Math.abs(i),t):-Math.pow(Math.abs(i),t),r.z=n>0?Math.pow(Math.abs(n),t):-Math.pow(Math.abs(n),t)}static scaleBlend(e,t,r,a){var i=ee,n=te;Z.scaleWeight(e,1-r,i),Z.scaleWeight(t,r,n);var s=r>.5?t:e;a.x=s.x>0?Math.abs(i.x*n.x):-Math.abs(i.x*n.x),a.y=s.y>0?Math.abs(i.y*n.y):-Math.abs(i.y*n.y),a.z=s.z>0?Math.abs(i.z*n.z):-Math.abs(i.z*n.z)}static matrix4x4MultiplyFFF(e,t,r){var a,i,n,s,o;if(r===t)for(t=new Float32Array(16),a=0;a<16;++a)t[a]=r[a];var l=t[0],h=t[1],d=t[2],c=t[3],u=t[4],_=t[5],f=t[6],m=t[7],g=t[8],p=t[9],S=t[10],T=t[11],A=t[12],E=t[13],D=t[14],R=t[15];for(a=0;a<4;a++)i=e[a],n=e[a+4],s=e[a+8],o=e[a+12],r[a]=i*l+n*h+s*d+o*c,r[a+4]=i*u+n*_+s*f+o*m,r[a+8]=i*g+n*p+s*S+o*T,r[a+12]=i*A+n*E+s*D+o*R}static matrix4x4MultiplyMFM(e,t,r){Z.matrix4x4MultiplyFFF(e.elements,t,r.elements)}static _buildTexture2D(e,r,a,i,n=!1){var s=new t.Texture2D(e,r,a,n,!0);return s.anisoLevel=1,s.filterMode=t.FilterMode.Point,q._generateTexture2D(s,e,r,i),s}static _drawBound(e,t,r){e.lineCount+12>e.maxLineCount&&(e.maxLineCount+=12);var a=ee,i=te,n=t.min,s=t.max;a.setValue(n.x,n.y,n.z),i.setValue(s.x,n.y,n.z),e.addLine(a,i,r,r),a.setValue(n.x,n.y,n.z),i.setValue(n.x,n.y,s.z),e.addLine(a,i,r,r),a.setValue(s.x,n.y,n.z),i.setValue(s.x,n.y,s.z),e.addLine(a,i,r,r),a.setValue(n.x,n.y,s.z),i.setValue(s.x,n.y,s.z),e.addLine(a,i,r,r),a.setValue(n.x,n.y,n.z),i.setValue(n.x,s.y,n.z),e.addLine(a,i,r,r),a.setValue(n.x,n.y,s.z),i.setValue(n.x,s.y,s.z),e.addLine(a,i,r,r),a.setValue(s.x,n.y,n.z),i.setValue(s.x,s.y,n.z),e.addLine(a,i,r,r),a.setValue(s.x,n.y,s.z),i.setValue(s.x,s.y,s.z),e.addLine(a,i,r,r),a.setValue(n.x,s.y,n.z),i.setValue(s.x,s.y,n.z),e.addLine(a,i,r,r),a.setValue(n.x,s.y,n.z),i.setValue(n.x,s.y,s.z),e.addLine(a,i,r,r),a.setValue(s.x,s.y,n.z),i.setValue(s.x,s.y,s.z),e.addLine(a,i,r,r),a.setValue(n.x,s.y,s.z),i.setValue(s.x,s.y,s.z),e.addLine(a,i,r,r)}static _getHierarchyPath(e,t,r){r.length=0;for(var a=t;a!==e;){var i=a._parent;if(!i)return null;r.push(i.getChildIndex(a)),a=i}return r}static _getNodeByHierarchyPath(e,t){for(var r=e,a=t.length-1;a>=0;a--)r=r.getChildAt(t[a]);return r}static _getParentNodeByHierarchyPath(e,t){let r=t.length,a=e;for(let e=0;e<r;e++){if(!a)return null;a=a.parent}return a}static uint8ArrayToArrayBuffer(e){return t.Utils.uint8ArrayToArrayBuffer(e)}static uint8ArrayToArrayBufferAsync(e){return t.Utils.uint8ArrayToArrayBufferAsync(e)}}window.getRTBase64=Z.uint8ArrayToArrayBuffer;const $=new t.Vector3,ee=new t.Vector3,te=new t.Vector3,re=new t.Vector3,ae=new Float32Array(16),ie=new Float32Array(16),ne=new Float32Array(16),se=new Float32Array(16);class oe{constructor(){this.updateMark=-1,this.pointLightCount=0,this.spotLightCount=0,this.indices=[]}}class le{constructor(e,r,a,i){this._updateMark=0,this._depthSliceParam=new t.Vector2,this._xSlices=e,this._ySlices=r,this._zSlices=a;var n=e*r,s=a*(1+Math.ceil(i/4));this._clusterTexture=Z._createFloatTextureBuffer(n,s),this._clusterTexture.lock=!0,this._clusterPixels=new Float32Array(n*s*4);for(var o=new Array(this._zSlices),l=0;l<this._zSlices;l++){o[l]=new Array(this._ySlices);for(var h=0;h<this._ySlices;h++){o[l][h]=new Array(this._xSlices);for(var d=0;d<this._xSlices;d++)o[l][h][d]=new oe}}this._clusterDatas=o}_placePointLightToClusters(e,t){for(var r=this._clusterDatas,a=this._updateMark,i=t.zMin,n=t.zMax;i<n;i++)for(var s=t.yMin,o=t.yMax;s<o;s++)for(var l=t.xMin,h=t.xMax;l<h;l++){var d=r[i][s][l];d.updateMark!=a&&(d.pointLightCount=0,d.spotLightCount=0,d.updateMark=a);var c=d.indices,u=d.pointLightCount++;u<c.length?c[u]=e:c.push(e)}}_placeSpotLightToClusters(e,t){for(var r=this._clusterDatas,a=this._updateMark,i=t.zMin,n=t.zMax;i<n;i++)for(var s=t.yMin,o=t.yMax;s<o;s++)for(var l=t.xMin,h=t.xMax;l<h;l++){var d=r[i][s][l];d.updateMark!=a&&(d.pointLightCount=0,d.spotLightCount=0,d.updateMark=a);var c=d.indices,u=d.pointLightCount+d.spotLightCount++;u<c.length?c[u]=e:c.push(e)}}_insertConePlane(e,r,a,i,n){var s=fe,o=me;t.Vector3.cross(n,r,s),t.Vector3.cross(s,r,o),t.Vector3.normalize(o,o);var l=a*Math.tan(i),h=e.x+a*r.x+l*o.x,d=e.y+a*r.y+l*o.y,c=e.z+a*r.z+l*o.z;return h*n.x+d*n.y+c*n.z<=0||e.x*n.x+e.y*n.y+e.z*n.z<=0}_shrinkSphereLightZPerspective(e,t,r,a,i){var n=r.z,s=n-a,o=n+a;if(s>t||o<=e)return!1;var l=this._depthSliceParam;return i.zMin=Math.floor(Math.log2(Math.max(s,e))*l.x-l.y),i.zMax=Math.min(Math.ceil(Math.log2(o)*l.x-l.y),this._zSlices),!0}_shrinkSpotLightZPerspective(e,t,r,a,i,n,s){var o=a.x,l=a.y,h=a.z,d=Math.tan(n)*i,c=r.x,u=r.y,_=r.z,f=o-c,m=l-u,g=h-_,p=f*f+m*m+g*g,S=Math.sqrt(1-g*g/p),T=Math.max(Math.min(_,h-S*d),r.z-i),A=Math.min(Math.max(_,h+S*d),r.z+i);if(T>t||A<=e)return!1;var E=this._depthSliceParam;return s.zMin=Math.floor(Math.log2(Math.max(T,e))*E.x-E.y),s.zMax=Math.min(Math.ceil(Math.log2(A)*E.x-E.y),this._zSlices),!0}_shrinkSphereLightByBoundOrth(e,t,r,a,i,n,s){var o=i.z,l=o-n,h=o+n;if(l>a||h<=r)return!1;var d=i.x,c=d-n,u=d+n;if(c>e||u<=-e)return!1;var _=i.y,f=_-n,m=_+n;if(f>t||m<=-t)return!1;var g=this._xSlices,p=this._ySlices,S=this._depthSliceParam,T=2*e/g,A=2*t/p;return s.xMin=Math.max(Math.floor((c+e)/T),0),s.xMax=Math.min(Math.ceil((u+e)/T),g),s.yMin=Math.max(Math.floor((t-m)/A),0),s.yMax=Math.min(Math.ceil((t-f)/A),p),s.zMin=Math.floor(Math.log2(Math.max(l,r))*S.x-S.y),s.zMax=Math.min(Math.ceil(Math.log2(h)*S.x-S.y),this._zSlices),!0}_shrinkSpotLightByBoundOrth(e,t,r,a,i,n,s,o,l){var h=n.x,d=n.y,c=n.z,u=Math.tan(o)*s,_=i.x,f=i.y,m=i.z,g=h-_,p=d-f,S=c-m,T=g*g+p*p+S*S,A=Math.sqrt(1-S*S/T),E=Math.max(Math.min(m,c-A*u),i.z-s),D=Math.min(Math.max(m,c+A*u),i.z+s);if(E>a||D<=r)return!1;var R=Math.sqrt(1-g*g/T),x=Math.max(Math.min(_,h-R*u),i.x-s),y=Math.min(Math.max(_,h+R*u),i.x+s);if(x>e||y<=-e)return!1;var M=Math.sqrt(1-p*p/T),C=Math.max(Math.min(f,d-M*u),i.y-s),v=Math.min(Math.max(f,d+M*u),i.y+s);if(C>t||v<=-t)return!1;var I=this._xSlices,w=this._ySlices,B=this._depthSliceParam,P=2*e/I,L=2*t/w;return l.xMin=Math.max(Math.floor((x+e)/P),0),l.xMax=Math.min(Math.ceil((y+e)/P),I),l.yMin=Math.max(Math.floor((t-v)/L),0),l.yMax=Math.min(Math.ceil((t-C)/L),w),l.zMin=Math.floor(Math.log2(Math.max(E,r))*B.x-B.y),l.zMax=Math.min(Math.ceil(Math.log2(D)*B.x-B.y),this._zSlices),!0}_shrinkXYByRadiusPerspective(e,t,r,a,i){var n,s,o,l,h,d=e.x,c=e.y,u=e.z,_=this._ySlices+1;for(h=0;h<_;h++){if(c*(f=i[h]).y+u*f.z<t){s=Math.max(0,h-1);break}}if(h==_)return!1;for(l=this._ySlices,h=s+1;h<_;h++){if(c*(f=i[h]).y+u*f.z<=-t){l=Math.max(0,h);break}}for(_=this._xSlices+1,h=0;h<_;h++){if(d*(f=a[h]).x+u*f.z<t){n=Math.max(0,h-1);break}}for(o=this._xSlices,h=n+1;h<_;h++){var f;if(d*(f=a[h]).x+u*f.z<=-t){o=Math.max(0,h);break}}return r.xMin=n,r.xMax=o,r.yMin=s,r.yMax=l,!0}_shrinkSpotXYByConePerspective(e,t,r,a,i,n,s){for(var o,l,h,d,c=ce,u=i.yMax+1,_=i.yMin+1;_<u;_++)if(this._insertConePlane(e,t,r,a,s[_])){l=Math.max(0,_-1);break}d=i.yMax;for(_=l+1;_<u;_++){var f=s[_];if(c.setValue(0,-f.y,-f.z),!this._insertConePlane(e,t,r,a,c)){d=Math.max(0,_);break}}u=i.xMax+1;for(_=i.xMin+1;_<u;_++)if(this._insertConePlane(e,t,r,a,n[_])){o=Math.max(0,_-1);break}h=i.xMax;for(_=o+1;_<u;_++){f=n[_];if(c.setValue(-f.x,0,-f.z),!this._insertConePlane(e,t,r,a,c)){h=Math.max(0,_);break}}i.xMin=o,i.xMax=h,i.yMin=l,i.yMax=d}_updatePointLightPerspective(e,r,a,i,n,s,o){var l=ge,h=he;t.Vector3.transformV3ToV3(i.owner._transform.position,a,h),h.z*=-1,this._shrinkSphereLightZPerspective(e,r,h,i.range,l)&&this._shrinkXYByRadiusPerspective(h,i.range,l,s,o)&&this._placePointLightToClusters(n,l)}_updateSpotLightPerspective(e,r,a,i,n,s,o){var l=ge,h=he,d=de,c=_e,u=i.owner._transform.position,_=i.range;i.owner._transform.worldMatrix.getForward(d),t.Vector3.normalize(d,d),t.Vector3.scale(d,_,c),t.Vector3.add(u,c,c),t.Vector3.transformV3ToV3(u,a,h),t.Vector3.transformV3ToV3(c,a,c),h.z*=-1,c.z*=-1;var f=i.spotAngle/2*Math.PI/180;if(this._shrinkSpotLightZPerspective(e,r,h,c,_,f,l)&&this._shrinkXYByRadiusPerspective(h,_,l,s,o)){var m=ue;m.x=c.x-h.x,m.y=c.y-h.y,m.z=c.z-h.z,t.Vector3.normalize(m,m),this._shrinkSpotXYByConePerspective(h,m,_,f,l,s,o),this._placeSpotLightToClusters(n,l)}}_updatePointLightOrth(e,r,a,i,n,s,o){var l=ge,h=he;t.Vector3.transformV3ToV3(s.owner._transform.position,n,h),h.z*=-1,this._shrinkSphereLightByBoundOrth(e,r,a,i,h,s.range,l)&&this._placePointLightToClusters(o,l)}_updateSpotLightOrth(e,r,a,i,n,s,o){var l=ge,h=he,d=de,c=_e,u=s.owner._transform.position,_=s.range;s.owner._transform.worldMatrix.getForward(d),t.Vector3.normalize(d,d),t.Vector3.scale(d,_,c),t.Vector3.add(u,c,c),t.Vector3.transformV3ToV3(u,n,h),t.Vector3.transformV3ToV3(c,n,c),h.z*=-1,c.z*=-1;var f=s.spotAngle/2*Math.PI/180;this._shrinkSpotLightByBoundOrth(e,r,a,i,h,c,_,f,l)&&this._placeSpotLightToClusters(o,l)}update(e,r){this._updateMark++;var a=e.nearPlane;this._depthSliceParam.x=t.Config3D.lightClusterCount.z/Math.log2(e.farPlane/a),this._depthSliceParam.y=Math.log2(a)*this._depthSliceParam.x;var i=e.nearPlane,n=e.farPlane,s=e.viewMatrix,o=r._directionLights._length,l=r._pointLights,h=l._length,d=l._elements,c=r._spotLights,u=c._length,_=c._elements;if(e.orthographic){for(var f=e.orthographicVerticalSize/2,m=f*e.aspectRatio,g=0;g<h;g++,o++)this._updatePointLightOrth(m,f,i,n,s,d[g],o);for(g=0;g<u;g++,o++)this._updateSpotLightOrth(m,f,i,n,s,_[g],o)}else{e._updateClusterPlaneXY();var p=e._clusterXPlanes,S=e._clusterYPlanes;for(g=0;g<h;g++,o++)this._updatePointLightPerspective(i,n,s,d[g],o,p,S);for(g=0;g<u;g++,o++)this._updateSpotLightPerspective(i,n,s,_[g],o,p,S)}if(h+u>0){for(var T=this._xSlices,A=this._ySlices,E=this._zSlices,D=T*A*4,R=D*E,x=this._clusterPixels,y=x.length,M=this._clusterDatas,C=this._updateMark,v=!0,I=0;I<E;I++)for(var w=0;w<A;w++)for(var B=0;B<T;B++){var P=M[I][w][B],L=4*(B+w*T+I*T*A);if(P.updateMark!==C)x[L]=0,x[L+1]=0;else if(v){var F=P.indices,N=P.pointLightCount,O=P.spotLightCount,b=N+O;if(R+b<y){x[L]=N,x[L+1]=O,x[L+2]=Math.floor(R/D),x[L+3]=R%D;for(g=0;g<b;g++)x[R++]=F[g]}else{b=y-(R+b),N=Math.min(N,b),x[L]=N,x[L+1]=Math.min(O,b-N),x[L+2]=Math.floor(R/D),x[L+3]=R%D;for(g=0;g<b;g++)x[R++]=F[g];v=!1}}}var V=this._clusterTexture.width;this._clusterTexture.setSubPixelsData(0,0,V,Math.ceil(R/(4*V)),x,0,!1,!1,!1)}}}const he=new t.Vector3,de=new t.Vector3,ce=new t.Vector3,ue=new t.Vector3,_e=new t.Vector3;new t.Vector3;const fe=new t.Vector3,me=new t.Vector3,ge=new class{};class pe{constructor(){this.flags=0,this.maxSubSteps=1,this.fixedTimeStep=1/60,this.enableCCD=!1,this.ccdThreshold=1e-4,this.ccdSphereRadius=1e-4}}class Se extends t.EventDispatcher{onStartListeningToType(e){e===t.Event.TRANSFORM_CHANGED&&(this._hasTransformChangedListener=!0)}static _beginAnimatorBatch(e){this._currentAnimatorFrame++,this._animatorEventCollector=e,this._inAnimatorBatch=!0}static _endAnimatorBatch(){this._inAnimatorBatch=!1,this._animatorEventCollector=null}_notifyTransformChanged(){var e;if(!this._hasTransformChangedListener)return;const r=this._getTransformChangeFlag();Se._inAnimatorBatch?null===(e=Se._animatorEventCollector)||void 0===e||e._addAnimatorTransformEvent(this,r):this.event(t.Event.TRANSFORM_CHANGED,r)}_getAnimatorTransformChangeFlag(){return this._getTransformChangeFlag()}_dispatchAnimatorTransformChanged(e){this._hasTransformChangedListener&&this.event(t.Event.TRANSFORM_CHANGED,e)}get isDefaultMatrix(){return this._getTransformFlag(Se.TRANSFORM_LOCALMATRIX)&&this.localMatrix,this._isDefaultMatrix}get _isFrontFaceInvert(){if(this._getTransformFlag(Se.TRANSFORM_WORLDSCALE)){var e=this.getWorldLossyScale();this._updateFaceInvertFromScale(e)}return this._faceInvert}getFrontFaceValue(){return this._getTransformFlag(Se.TRANSFORM_WORLDSCALE)&&this._isFrontFaceInvert,this._frontFaceValue}getScaleChangeFlag(){return this._getTransformFlag(Se.TRANSFORM_WORLDSCALE)}get owner(){return this._owner}get worldNeedUpdate(){return this._getTransformFlag(Se.TRANSFORM_WORLDMATRIX)}get localPositionX(){return this._localPosition.x}set localPositionX(e){this._localPosition.x=e,this.localPosition=this._localPosition}get localPositionY(){return this._localPosition.y}set localPositionY(e){this._localPosition.y=e,this.localPosition=this._localPosition}get localPositionZ(){return this._localPosition.z}set localPositionZ(e){this._localPosition.z=e,this.localPosition=this._localPosition}get localPosition(){return this._localPosition}set localPosition(e){this._localPosition!==e&&e.cloneTo(this._localPosition),this._setTransformFlag(Se.TRANSFORM_LOCALMATRIX,!0),this._onWorldPositionTransform()}get localRotationX(){return this.localRotation.x}set localRotationX(e){let t=this.localRotation;t.x=e,this.localRotation=t}get localRotationY(){return this.localRotation.y}set localRotationY(e){let t=this.localRotation;t.y=e,this.localRotation=t}get localRotationZ(){return this.localRotation.z}set localRotationZ(e){let t=this.localRotation;t.z=e,this.localRotation=t}get localRotationW(){return this.localRotation.w}set localRotationW(e){let t=this.localRotation;t.w=e,this.localRotation=t}get localRotation(){if(this._getTransformFlag(Se.TRANSFORM_LOCALQUATERNION)){var e=this._localRotationEuler;t.Quaternion.createFromYawPitchRoll(e.y/Se._angleToRandin,e.x/Se._angleToRandin,e.z/Se._angleToRandin,this._localRotation),this._setTransformFlag(Se.TRANSFORM_LOCALQUATERNION,!1)}return this._localRotation}set localRotation(e){this._localRotation!==e&&e.cloneTo(this._localRotation),this._localRotation.normalize(this._localRotation),this._setTransformFlag(Se.TRANSFORM_LOCALEULER|Se.TRANSFORM_LOCALMATRIX,!0),this._setTransformFlag(Se.TRANSFORM_LOCALQUATERNION,!1),this._onWorldRotationTransform()}get localScaleX(){return this._localScale.x}set localScaleX(e){this._localScale.x=e,this.localScale=this._localScale}get localScaleY(){return this._localScale.y}set localScaleY(e){this._localScale.y=e,this.localScale=this._localScale}get localScaleZ(){return this._localScale.z}set localScaleZ(e){this._localScale.z=e,this.localScale=this._localScale}get localScale(){return this._localScale}set localScale(e){this._localScale!==e&&e.cloneTo(this._localScale),this._setTransformFlag(Se.TRANSFORM_LOCALMATRIX,!0),this._onWorldScaleTransform()}get localRotationEulerX(){return this.localRotationEuler.x}set localRotationEulerX(e){let t=this.localRotationEuler;t.x=e,this.localRotationEuler=t}get localRotationEulerY(){return this.localRotationEuler.y}set localRotationEulerY(e){let t=this.localRotationEuler;t.y=e,this.localRotationEuler=t}get localRotationEulerZ(){return this.localRotationEuler.z}set localRotationEulerZ(e){let t=this.localRotationEuler;t.z=e,this.localRotationEuler=t}get localRotationEuler(){if(this._getTransformFlag(Se.TRANSFORM_LOCALEULER)){this._localRotation.getYawPitchRoll(Te);var e=Te,t=this._localRotationEuler;t.x=e.y*Se._angleToRandin,t.y=e.x*Se._angleToRandin,t.z=e.z*Se._angleToRandin,this._setTransformFlag(Se.TRANSFORM_LOCALEULER,!1)}return this._localRotationEuler}set localRotationEuler(e){this._localRotationEuler!==e&&e.cloneTo(this._localRotationEuler),this._setTransformFlag(Se.TRANSFORM_LOCALEULER,!1),this._setTransformFlag(Se.TRANSFORM_LOCALQUATERNION|Se.TRANSFORM_LOCALMATRIX,!0),this._onWorldRotationTransform()}get localMatrix(){return this._getTransformFlag(Se.TRANSFORM_LOCALMATRIX)&&(t.Matrix4x4.createAffineTransformation(this._localPosition,this.localRotation,this._localScale,this._localMatrix),this._isDefaultMatrix=this._localMatrix.isIdentity(),this._setTransformFlag(Se.TRANSFORM_LOCALMATRIX,!1)),this._localMatrix}set localMatrix(e){this._localMatrix!==e&&e.cloneTo(this._localMatrix),this._isDefaultMatrix=this._localMatrix.isIdentity(),this._localMatrix.decomposeTransRotScale(this._localPosition,this._localRotation,this._localScale),this._setTransformFlag(Se.TRANSFORM_LOCALEULER,!0),this._setTransformFlag(Se.TRANSFORM_LOCALMATRIX,!1),this._onWorldTransform()}get position(){if(this._getTransformFlag(Se.TRANSFORM_WORLDPOSITION)){if(null!=this._parent){var e=this.worldMatrix.elements;this._position.x=e[12],this._position.y=e[13],this._position.z=e[14]}else this._localPosition.cloneTo(this._position);this._setTransformFlag(Se.TRANSFORM_WORLDPOSITION,!1)}return this._position}set position(e){if(null!=this._parent){var r=Ee;this._parent.worldMatrix.invert(r),t.Vector3.transformCoordinate(e,r,this._localPosition)}else e.cloneTo(this._localPosition);this.localPosition=this._localPosition,this._position!==e&&e.cloneTo(this._position),this._setTransformFlag(Se.TRANSFORM_WORLDPOSITION,!1)}get rotation(){return this._getTransformFlag(Se.TRANSFORM_WORLDQUATERNION)&&(null!=this._parent?t.Quaternion.multiply(this._parent.rotation,this.localRotation,this._rotation):this.localRotation.cloneTo(this._rotation),this._setTransformFlag(Se.TRANSFORM_WORLDQUATERNION,!1)),this._rotation}set rotation(e){null!=this._parent?(this._parent.rotation.invert(Ae),t.Quaternion.multiply(Ae,e,this._localRotation)):e.cloneTo(this._localRotation),this.localRotation=this._localRotation,e!==this._rotation&&e.cloneTo(this._rotation),this._setTransformFlag(Se.TRANSFORM_WORLDQUATERNION,!1)}get rotationEuler(){if(this._getTransformFlag(Se.TRANSFORM_WORLDEULER)){this.rotation.getYawPitchRoll(Te);var e=Te,t=this._rotationEuler;t.x=e.y*Se._angleToRandin,t.y=e.x*Se._angleToRandin,t.z=e.z*Se._angleToRandin,this._setTransformFlag(Se.TRANSFORM_WORLDEULER,!1)}return this._rotationEuler}set rotationEuler(e){t.Quaternion.createFromYawPitchRoll(e.y/Se._angleToRandin,e.x/Se._angleToRandin,e.z/Se._angleToRandin,this._rotation),this.rotation=this._rotation,this._rotationEuler!==e&&e.cloneTo(this._rotationEuler),this._setTransformFlag(Se.TRANSFORM_WORLDEULER,!1)}get worldMatrix(){if(this._getTransformFlag(Se.TRANSFORM_WORLDMATRIX)){if(null!=this._parent){let e=this._parent;for(;e._parent&&e.isDefaultMatrix;)e=e._parent;t.Matrix4x4.multiply(e.worldMatrix,this.localMatrix,this._worldMatrix)}else this.localMatrix.cloneTo(this._worldMatrix);this._setTransformFlag(Se.TRANSFORM_WORLDMATRIX,!1)}return this._worldMatrix}set worldMatrix(e){null===this._parent?e.cloneTo(this._localMatrix):(this._parent.worldMatrix.invert(this._localMatrix),t.Matrix4x4.multiply(this._localMatrix,e,this._localMatrix)),this.localMatrix=this._localMatrix,this._worldMatrix!==e&&e.cloneTo(this._worldMatrix),this._setTransformFlag(Se.TRANSFORM_WORLDMATRIX,!1)}constructor(e){super(),this._lastAnimatorFrame=-1,this._lastAnimatorNotifyFrame=-1,this._animatorNotifyIndex=-1,this._localPosition=new t.Vector3(0,0,0),this._localRotation=new t.Quaternion(0,0,0,1),this._localScale=new t.Vector3(1,1,1),this._localRotationEuler=new t.Vector3(0,0,0),this._localMatrix=new t.Matrix4x4,this._position=new t.Vector3(0,0,0),this._rotation=new t.Quaternion(0,0,0,1),this._scale=new t.Vector3(1,1,1),this._rotationEuler=new t.Vector3(0,0,0),this._worldMatrix=new t.Matrix4x4,this._children=null,this._isDefaultMatrix=!1,this._faceInvert=!1,this._frontFaceValue=1,this._parent=null,this._transformFlag=0,this._hasTransformChangedListener=!1,this._owner=e,this._children=[],this._initProperty()}_initProperty(){this._setTransformFlag(Se.TRANSFORM_LOCALQUATERNION|Se.TRANSFORM_LOCALEULER|Se.TRANSFORM_LOCALMATRIX,!1),this._setTransformFlag(Se.TRANSFORM_WORLDPOSITION|Se.TRANSFORM_WORLDQUATERNION|Se.TRANSFORM_WORLDEULER|Se.TRANSFORM_WORLDSCALE|Se.TRANSFORM_WORLDMATRIX,!0)}_getScaleMatrix(){var e=Ae,r=De,a=Re,i=xe;return t.Matrix3x3.createFromMatrix4x4(this.worldMatrix,a),this.rotation.invert(e),t.Matrix3x3.createRotationQuaternion(e,r),t.Matrix3x3.multiply(r,a,i),i}_setTransformFlag(e,t){t?this._transformFlag|=e:this._transformFlag&=~e}_getTransformFlag(e){return 0!=(this._transformFlag&e)}_getTransformChangeFlag(){return this._transformFlag}_setParent(e){if(this._parent!==e){if(this._parent){var t=this._parent._children,r=t.indexOf(this);t.splice(r,1)}e&&(e._children.push(this),e&&this._onWorldTransform()),this._parent=e}}_onWorldPositionRotationTransform(){this._getTransformFlag(Se.TRANSFORM_WORLDMATRIX)&&this._getTransformFlag(Se.TRANSFORM_WORLDPOSITION)&&this._getTransformFlag(Se.TRANSFORM_WORLDQUATERNION)&&this._getTransformFlag(Se.TRANSFORM_WORLDEULER)||(this._setTransformFlag(Se.TRANSFORM_WORLDMATRIX|Se.TRANSFORM_WORLDPOSITION|Se.TRANSFORM_WORLDQUATERNION|Se.TRANSFORM_WORLDEULER,!0),this._notifyTransformChanged());for(var e=0,t=this._children.length;e<t;e++)this._children[e]._onWorldPositionRotationTransform()}_onWorldPositionScaleTransform(){this._getTransformFlag(Se.TRANSFORM_WORLDMATRIX)&&this._getTransformFlag(Se.TRANSFORM_WORLDPOSITION)&&this._getTransformFlag(Se.TRANSFORM_WORLDSCALE)||(this._setTransformFlag(Se.TRANSFORM_WORLDMATRIX|Se.TRANSFORM_WORLDPOSITION|Se.TRANSFORM_WORLDSCALE,!0),this._notifyTransformChanged());for(var e=0,t=this._children.length;e<t;e++)this._children[e]._onWorldPositionScaleTransform()}_onWorldPositionTransform(){if(this._getTransformFlag(Se.TRANSFORM_WORLDMATRIX)&&this._getTransformFlag(Se.TRANSFORM_WORLDPOSITION)||(this._setTransformFlag(Se.TRANSFORM_WORLDMATRIX|Se.TRANSFORM_WORLDPOSITION,!0),this._notifyTransformChanged()),Se._inAnimatorBatch){if(this._lastAnimatorFrame===Se._currentAnimatorFrame)return;this._lastAnimatorFrame=Se._currentAnimatorFrame;for(var e=0,t=this._children.length;e<t;e++)this._children[e]._onWorldTransform()}else for(var r=0,a=this._children.length;r<a;r++)this._children[r]._onWorldPositionTransform()}_onWorldRotationTransform(){if(this._getTransformFlag(Se.TRANSFORM_WORLDMATRIX)&&this._getTransformFlag(Se.TRANSFORM_WORLDQUATERNION)&&this._getTransformFlag(Se.TRANSFORM_WORLDEULER)||(this._setTransformFlag(Se.TRANSFORM_WORLDMATRIX|Se.TRANSFORM_WORLDQUATERNION|Se.TRANSFORM_WORLDEULER,!0),this._notifyTransformChanged()),Se._inAnimatorBatch){if(this._lastAnimatorFrame===Se._currentAnimatorFrame)return;this._lastAnimatorFrame=Se._currentAnimatorFrame;for(var e=0,t=this._children.length;e<t;e++)this._children[e]._onWorldTransform()}else for(var r=0,a=this._children.length;r<a;r++)this._children[r]._onWorldPositionRotationTransform()}_onWorldScaleTransform(){if(this._getTransformFlag(Se.TRANSFORM_WORLDMATRIX)&&this._getTransformFlag(Se.TRANSFORM_WORLDSCALE)||(this._setTransformFlag(Se.TRANSFORM_WORLDMATRIX|Se.TRANSFORM_WORLDSCALE,!0),this._notifyTransformChanged()),Se._inAnimatorBatch){if(this._lastAnimatorFrame===Se._currentAnimatorFrame)return;this._lastAnimatorFrame=Se._currentAnimatorFrame;for(var e=0,t=this._children.length;e<t;e++)this._children[e]._onWorldTransform()}else for(var r=0,a=this._children.length;r<a;r++)this._children[r]._onWorldPositionScaleTransform()}_onWorldTransform(){if(this._getTransformFlag(Se.TRANSFORM_WORLDMATRIX)&&this._getTransformFlag(Se.TRANSFORM_WORLDPOSITION)&&this._getTransformFlag(Se.TRANSFORM_WORLDQUATERNION)&&this._getTransformFlag(Se.TRANSFORM_WORLDEULER)&&this._getTransformFlag(Se.TRANSFORM_WORLDSCALE)||(this._setTransformFlag(Se.TRANSFORM_WORLDMATRIX|Se.TRANSFORM_WORLDPOSITION|Se.TRANSFORM_WORLDQUATERNION|Se.TRANSFORM_WORLDEULER|Se.TRANSFORM_WORLDSCALE,!0),this._notifyTransformChanged()),Se._inAnimatorBatch){if(this._lastAnimatorFrame===Se._currentAnimatorFrame)return;this._lastAnimatorFrame=Se._currentAnimatorFrame}for(var e=0,t=this._children.length;e<t;e++)this._children[e]._onWorldTransform()}translate(e,r=!0){r?(t.Matrix4x4.createFromQuaternion(this.localRotation,Ee),t.Vector3.transformCoordinate(e,Ee,Te),t.Vector3.add(this.localPosition,Te,this._localPosition),this.localPosition=this._localPosition):(t.Vector3.add(this.position,e,this._position),this.position=this._position)}rotate(e,r=!0,a=!0){var i;a?i=e:(t.Vector3.scale(e,Math.PI/180,Te),i=Te),t.Quaternion.createFromYawPitchRoll(i.y,i.x,i.z,Ae),r?(t.Quaternion.multiply(this.localRotation,Ae,this._localRotation),this.localRotation=this._localRotation):(t.Quaternion.multiply(Ae,this.rotation,this._rotation),this.rotation=this._rotation)}getForward(e){var t=this.worldMatrix.elements;e.x=-t[8],e.y=-t[9],e.z=-t[10]}getUp(e){var t=this.worldMatrix.elements;e.x=t[4],e.y=t[5],e.z=t[6]}getRight(e){var t=this.worldMatrix.elements;e.x=t[0],e.y=t[1],e.z=t[2]}lookAt(e,r,a=!1,i=!0){var n;if(a){if(n=this.localPosition,Math.abs(n.x-e.x)<t.MathUtils3D.zeroTolerance&&Math.abs(n.y-e.y)<t.MathUtils3D.zeroTolerance&&Math.abs(n.z-e.z)<t.MathUtils3D.zeroTolerance)return;i?(t.Quaternion.lookAt(this.localPosition,e,r,this._localRotation),this._localRotation.invert(this._localRotation)):(t.Vector3.subtract(this.localPosition,e,Te),t.Quaternion.rotationLookAt(Te,r,this._localRotation),this._localRotation.invert(this._localRotation)),this.localRotation=this._localRotation}else{var s=this.position;if(n=s,Math.abs(n.x-e.x)<t.MathUtils3D.zeroTolerance&&Math.abs(n.y-e.y)<t.MathUtils3D.zeroTolerance&&Math.abs(n.z-e.z)<t.MathUtils3D.zeroTolerance)return;i?(t.Quaternion.lookAt(s,e,r,this._rotation),this._rotation.invert(this._rotation)):(t.Vector3.subtract(this.position,e,Te),t.Quaternion.rotationLookAt(Te,r,this._rotation),this._rotation.invert(this._rotation)),this.rotation=this._rotation}}objLookat(e,t,r=!1){this.lookAt(e,t,r,!1)}getWorldLossyScale(){if(this._getTransformFlag(Se.TRANSFORM_WORLDSCALE)){if(null!==this._parent){var e=this._getScaleMatrix().elements;this._scale.x=e[0],this._scale.y=e[4],this._scale.z=e[8]}else this._localScale.cloneTo(this._scale);this._updateFaceInvertFromScale(this._scale),this._setTransformFlag(Se.TRANSFORM_WORLDSCALE,!1)}return this._scale}_updateFaceInvertFromScale(e){var t=e.x<0;e.y<0&&(t=!t),e.z<0&&(t=!t),this._faceInvert=t,this._frontFaceValue=this._faceInvert?-1:1}setWorldLossyScale(e){if(null!==this._parent){var r=ye,a=ye,i=a.elements,n=this._parent._getScaleMatrix();n.invert(n),t.Matrix3x3.createFromScaling(e,r),t.Matrix3x3.multiply(n,r,a),this._localScale.x=i[0],this._localScale.y=i[4],this._localScale.z=i[8]}else e.cloneTo(this._localScale);this.localScale=this._localScale,this._scale!==e&&e.cloneTo(this._scale),this._updateFaceInvertFromScale(e),this._setTransformFlag(Se.TRANSFORM_WORLDSCALE,!1)}localToGlobal(e,r){t.Vector3.transformV3ToV3(e,this.worldMatrix,r)}globalToLocal(e,r){this.worldMatrix.invert(Ee),t.Vector3.transformV3ToV3(e,Ee,r)}toLocalNormal(e,r){this.worldMatrix.invert(Ee),t.Vector3.TransformNormal(e,Ee,r)}toDir(e,t){this.rotationTo(this.rotation,e,t),this.rotation=this.rotation}rotationTo(e,r,a){var i=t.Vector3.dot(r,a);return i<-.999999?(t.Vector3.cross(t.Vector3.UnitX,r,Me),t.Vector3.scalarLength(Me)<1e-6&&t.Vector3.cross(t.Vector3.UnitY,r,Me),t.Vector3.normalize(Me,Me),t.Quaternion.createFromAxisAngle(Me,Math.PI,e),!0):i>.999999?(e.x=0,e.y=0,e.z=0,e.w=1,!1):(t.Vector3.cross(r,a,Me),e.x=Me.x,e.y=Me.y,e.z=Me.z,e.w=1+i,e.normalize(e),!0)}activeInScene(){}inActiveInScene(){}get scale(){return console.warn("Transfrm3D: discard function,please use getWorldLossyScale instead."),this.getWorldLossyScale()}set scale(e){console.warn("Transfrm3D: discard function,please use setWorldLossyScale instead."),this.setWorldLossyScale(e)}}Se.TRANSFORM_LOCALQUATERNION=1,Se.TRANSFORM_LOCALEULER=2,Se.TRANSFORM_LOCALMATRIX=4,Se.TRANSFORM_WORLDPOSITION=8,Se.TRANSFORM_WORLDQUATERNION=16,Se.TRANSFORM_WORLDSCALE=32,Se.TRANSFORM_WORLDMATRIX=64,Se.TRANSFORM_WORLDEULER=128,Se.TRANSFORM_LOCALPOS=256,Se.TRANSFORM_LOCALSCALE=512,Se._angleToRandin=180/Math.PI,Se._inAnimatorBatch=!1,Se._animatorEventCollector=null,Se._currentAnimatorFrame=0;const Te=new t.Vector3,Ae=new t.Quaternion,Ee=new t.Matrix4x4,De=new t.Matrix3x3,Re=new t.Matrix3x3,xe=new t.Matrix3x3,ye=new t.Matrix3x3,Me=new t.Vector3;class Ce{set bufferState(e){this._geometryElementOBj.bufferState=e._deviceBufferState,this._bufferState=e}get bufferState(){return this._bufferState}set mode(e){this._geometryElementOBj.mode=e}get mode(){return this._geometryElementOBj.mode}set drawType(e){this._geometryElementOBj.drawType=e}get drawType(){return this._geometryElementOBj.drawType}setDrawArrayParams(e,t){this._geometryElementOBj.setDrawArrayParams(e,t)}setDrawElemenParams(e,t){this._geometryElementOBj.setDrawElemenParams(e,t)}set instanceCount(e){this._geometryElementOBj.instanceCount=e}get instanceCount(){return this._geometryElementOBj.instanceCount}set indexFormat(e){this._geometryElementOBj.indexFormat=e}get indexFormat(){return this._geometryElementOBj.indexFormat}get destroyed(){return this._destroyed}constructor(e,r){this._destroyed=!1,this._geometryElementOBj=t.LayaGL.renderDeviceFactory.createRenderGeometryElement(e,r),this._id=++Ce._uniqueIDCounter}_getType(){throw new Error("GeometryElement:must override it.")}_prepareRender(e){return!0}_updateRenderParams(e){throw new Error("GeometryElement:must override it.")}destroy(){this._destroyed||(this._destroyed=!0,this._geometryElementOBj.destroy())}clearRenderParams(){this._geometryElementOBj.clearRenderParams()}}Ce._uniqueIDCounter=0,Ce._typeCounter=0;class ve extends Ce{static __init__(){ve.instance=new ve}constructor(){super(t.MeshTopology.Triangles,t.DrawType.DrawElement);var e=new Float32Array([-1,1,-1,1,1,-1,1,1,1,-1,1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1]),r=new Uint16Array([0,2,1,2,0,3,4,6,7,6,4,5,0,7,3,7,0,4,1,6,5,6,1,2,3,6,2,6,3,7,0,5,4,5,0,1]),a=t.VertexMesh.getVertexDeclaration("POSITION");let i=T.renderOBJCreate.createVertexBuffer3D(8*a.vertexStride,t.BufferUsage.Static,!1);i.vertexDeclaration=a;let n=T.renderOBJCreate.createIndexBuffer3D(t.IndexFormat.UInt16,36,t.BufferUsage.Static,!1);i.setData(e),n.setData(r),this.bufferState=new t.BufferState,this.bufferState.applyState([i],n),this._geometryElementOBj.setDrawElemenParams(36,0),this.indexFormat=t.IndexFormat.UInt16}_updateRenderParams(e){}}class Ie{static get vertexDeclaration(){return Ie._vertexDeclaration}static __init__(){Ie._vertexDeclaration=new t.VertexDeclaration(20,[new t.VertexElement(0,t.VertexElementFormat.Vector3,t.VertexMesh.MESH_POSITION0),new t.VertexElement(12,t.VertexElementFormat.Vector2,t.VertexMesh.MESH_TEXTURECOORDINATE0)])}get position(){return this._position}get textureCoordinate0(){return this._textureCoordinate0}get vertexDeclaration(){return Ie._vertexDeclaration}constructor(e,t){this._position=e,this._textureCoordinate0=t}}class we extends Ce{static __init__(){we.instance=new we}get stacks(){return this._stacks}get slices(){return this._slices}constructor(e=48,r=48){super(t.MeshTopology.Triangles,t.DrawType.DrawElement),this._stacks=e,this._slices=r;for(var a=Ie.vertexDeclaration,i=a.vertexStride/4,n=(this._stacks+1)*(this._slices+1),s=3*this._stacks*(this._slices+1)*2,o=new Float32Array(n*i),l=new Uint16Array(s),h=Math.PI/this._stacks,d=2*Math.PI/this._slices,c=0,u=0,_=0,f=0;f<this._stacks+1;f++)for(var m=Math.sin(f*h),g=Math.cos(f*h),p=0;p<this._slices+1;p++){var S=m*Math.sin(p*d),A=m*Math.cos(p*d);o[u+0]=S*we._radius,o[u+1]=g*we._radius,o[u+2]=A*we._radius,o[u+3]=-p/this._slices+.75,o[u+4]=f/this._stacks,u+=i,f!=this._stacks-1&&(l[_++]=c+1,l[_++]=c,l[_++]=c+(this._slices+1),l[_++]=c+(this._slices+1),l[_++]=c,l[_++]=c+this._slices,c++)}let E=T.renderOBJCreate.createVertexBuffer3D(4*o.length,t.BufferUsage.Static,!1);E.vertexDeclaration=a;let D=T.renderOBJCreate.createIndexBuffer3D(t.IndexFormat.UInt16,l.length,t.BufferUsage.Static,!1);E.setData(o.buffer),D.setData(l);var R=new t.BufferState;R.applyState([E],D),this.bufferState=R,this.indexFormat=t.IndexFormat.UInt16,this._geometryElementOBj.setDrawElemenParams(D.indexCount,0)}_updateRenderParams(e){}}we._radius=1;class Be{static __init__(){Be.SUNLIGHTDIRECTION=t.Shader3D.propertyNameToID("u_SunLight_direction"),Be.SUNLIGHTDIRCOLOR=t.Shader3D.propertyNameToID("u_SunLight_color"),Be.SKYVIEWMATRIX=t.Shader3D.propertyNameToID("u_SkyViewMat"),Be.SKYPROJECTIONMATRIX=t.Shader3D.propertyNameToID("u_SkyProjectionMat"),Be.SKYPROJECTIONVIEWMATRIX=t.Shader3D.propertyNameToID("u_SkyProjectionViewMat");const e=t.LayaGL.renderDeviceFactory.createGlobalUniformMap("SkyRenderer");e.addShaderUniform(Be.SUNLIGHTDIRECTION,"u_SunLight_direction",t.ShaderDataType.Vector3),e.addShaderUniform(Be.SUNLIGHTDIRCOLOR,"u_SunLight_color",t.ShaderDataType.Color),e.addShaderUniform(Be.SKYVIEWMATRIX,"u_SkyViewMat",t.ShaderDataType.Matrix4x4),e.addShaderUniform(Be.SKYPROJECTIONMATRIX,"u_SkyProjectionMat",t.ShaderDataType.Matrix4x4),e.addShaderUniform(Be.SKYPROJECTIONVIEWMATRIX,"u_SkyProjectionViewMat",t.ShaderDataType.Matrix4x4)}get material(){return this._material}set material(e){e&&!this._isMaterialVaild(e)||this._material!==e&&(this._material&&this._material._removeReference(),this._material=e,this._cacheRenderElement&&(this._cacheRenderElement.material=e),e&&e._addReference())}get mesh(){return this._mesh}set mesh(e){this._mesh!==e&&(this._mesh=e,this._cacheRenderElement&&this._cacheRenderElement.setGeometry(this.mesh))}get meshType(){return this.mesh==ve.instance?"box":this.mesh==we.instance?"dome":""}set meshType(e){this.mesh="dome"==e?we.instance:ve.instance}constructor(){this.mesh=we.instance,this._renderData=new z,this._baseRenderNode=T.Render3DModuleDataFactory.createBaseRenderNode(),this._baseRenderNode.transform=new Se(null)}_isMaterialVaild(e){return e.checkType(t.ShaderFeatureType.Sky)}_isAvailable(){return!(!this._material||!this._mesh)}renderUpdate(e){let t=this.mesh;this._renderGeometry=t._prepareRender(e),t._updateRenderParams(e)}setRenderElement(e){e&&(this._cacheRenderElement!=e?(e.setGeometry(this.mesh),e.material=this._material,e.render=this._renderData,e._renderElementOBJ.isRender=this._renderGeometry,this._baseRenderNode.shaderData=this._renderData._baseRenderNode.shaderData,this._baseRenderNode.setRenderelements([e._renderElementOBJ]),this._baseRenderNode.setCommonUniformMap(["Sprite3D","SkyRenderer"]),this._cacheRenderElement=e):(e.setGeometry(this.mesh),e.material=this._material,e.render=this._renderData,e._renderElementOBJ.isRender=this._renderGeometry))}destroy(){this._material&&(this._material._removeReference(),this._material=null),this._renderData.destroy(),this._cacheRenderElement=null,this._baseRenderNode.setRenderelements([]),this._baseRenderNode.destroy()}}const Pe=new t.Matrix4x4(1,0,0,0,0,-1,0,0,0,0,1,0,0,0,0,1);class Le extends W{constructor(){super(),this._viewMatrix=new t.Matrix4x4,this._projectionMatrix=new t.Matrix4x4,this._projectViewMatrix=new t.Matrix4x4}calculateViewMatrix(e){e.cloneTo(this._viewMatrix),this._viewMatrix.setTranslationVector(t.Vector3.ZERO)}caluclateProjectionMatrix(e,r,a,i,n,s){if(s){let e=.2,r=e;t.Matrix4x4.createOrthoOffCenter(-e,e,-r,r,a,i,this._projectionMatrix)}else{e.cloneTo(this._projectionMatrix);let t=1e-6,a=1/Math.tan(Math.PI*n/180*.5);this._projectionMatrix.elements[0]=a/r,this._projectionMatrix.elements[5]=a,this._projectionMatrix.elements[10]=t-1,this._projectionMatrix.elements[11]=-1,this._projectionMatrix.elements[14]=-0}}renderpre(e){e.invertY?(t.Matrix4x4.multiply(Pe,this._projectionMatrix,t.Matrix4x4.TEMP),t.Matrix4x4.multiply(t.Matrix4x4.TEMP,this._viewMatrix,Fe),this._renderElementOBJ.renderShaderData.setMatrix4x4(Be.SKYPROJECTIONMATRIX,t.Matrix4x4.TEMP),this._renderElementOBJ.renderShaderData.setMatrix4x4(Be.SKYPROJECTIONVIEWMATRIX,Fe)):(t.Matrix4x4.multiply(this._projectionMatrix,this._viewMatrix,this._projectViewMatrix),this._renderElementOBJ.renderShaderData.setMatrix4x4(Be.SKYPROJECTIONMATRIX,this._projectionMatrix),this._renderElementOBJ.renderShaderData.setMatrix4x4(Be.SKYPROJECTIONVIEWMATRIX,this._projectViewMatrix)),this._renderElementOBJ.renderShaderData.setMatrix4x4(Be.SKYVIEWMATRIX,this._viewMatrix),this._renderElementOBJ.renderShaderData.setColor(Be.SUNLIGHTDIRCOLOR,e.scene._sunColor),this._renderElementOBJ.renderShaderData.setVector3(Be.SUNLIGHTDIRECTION,e.scene._sundir)}}const Fe=new t.Matrix4x4;class Ne extends R{static shaderValueInit(){Ne.SHADERDEFINE_FXAA=t.Shader3D.getDefineByName("FXAA"),Ne.CAMERAPOS=t.Shader3D.propertyNameToID("u_CameraPos"),Ne.VIEWMATRIX=t.Shader3D.propertyNameToID("u_View"),Ne.VIEWPROJECTMATRIX=t.Shader3D.propertyNameToID("u_ViewProjection"),Ne.PROJECTMATRIX=t.Shader3D.propertyNameToID("u_Projection"),Ne.CAMERADIRECTION=t.Shader3D.propertyNameToID("u_CameraDirection"),Ne.CAMERAUP=t.Shader3D.propertyNameToID("u_CameraUp"),Ne.VIEWPORT=t.Shader3D.propertyNameToID("u_Viewport"),Ne.PROJECTION_PARAMS=t.Shader3D.propertyNameToID("u_ProjectionParams"),Ne.DEPTHTEXTURE=t.Shader3D.propertyNameToID("u_CameraDepthTexture"),Ne.DEPTHNORMALSTEXTURE=t.Shader3D.propertyNameToID("u_CameraDepthNormalsTexture"),Ne.OPAQUETEXTURE=t.Shader3D.propertyNameToID("u_CameraOpaqueTexture"),Ne.OPAQUETEXTUREPARAMS=t.Shader3D.propertyNameToID("u_OpaqueTextureParams"),Ne.DEPTHZBUFFERPARAMS=t.Shader3D.propertyNameToID("u_ZBufferParams"),Ne.TAAVIEWPROJECTION=t.Shader3D.propertyNameToID("u_TaaViewProjection"),Ne.TAAPREVIOUSVIEWPROJECTION=t.Shader3D.propertyNameToID("u_TaaPreviousViewProjection"),Ne.TAAMOTIONPARAMS=t.Shader3D.propertyNameToID("u_TaaMotionParams");let e=Ne.cameraUniformMap=t.LayaGL.renderDeviceFactory.createGlobalUniformMap(Ne.cameraBlockName);e.addShaderUniform(Ne.CAMERAPOS,"u_CameraPos",t.ShaderDataType.Vector3),e.addShaderUniform(Ne.VIEWMATRIX,"u_View",t.ShaderDataType.Matrix4x4),e.addShaderUniform(Ne.PROJECTMATRIX,"u_Projection",t.ShaderDataType.Matrix4x4),e.addShaderUniform(Ne.VIEWPROJECTMATRIX,"u_ViewProjection",t.ShaderDataType.Matrix4x4),e.addShaderUniform(Ne.CAMERADIRECTION,"u_CameraDirection",t.ShaderDataType.Vector3),e.addShaderUniform(Ne.CAMERAUP,"u_CameraUp",t.ShaderDataType.Vector3),e.addShaderUniform(Ne.VIEWPORT,"u_Viewport",t.ShaderDataType.Vector4),e.addShaderUniform(Ne.PROJECTION_PARAMS,"u_ProjectionParams",t.ShaderDataType.Vector4),e.addShaderUniform(Ne.DEPTHTEXTURE,"u_CameraDepthTexture",t.ShaderDataType.Texture2D),e.addShaderUniform(Ne.DEPTHNORMALSTEXTURE,"u_CameraDepthNormalsTexture",t.ShaderDataType.Texture2D),e.addShaderUniform(Ne.OPAQUETEXTURE,"u_CameraOpaqueTexture",t.ShaderDataType.Texture2D),e.addShaderUniform(Ne.OPAQUETEXTUREPARAMS,"u_OpaqueTextureParams",t.ShaderDataType.Vector4),e.addShaderUniform(Ne.DEPTHZBUFFERPARAMS,"u_ZBufferParams",t.ShaderDataType.Vector4),e.addShaderUniform(Ne.TAAVIEWPROJECTION,"u_TaaViewProjection",t.ShaderDataType.Matrix4x4),e.addShaderUniform(Ne.TAAPREVIOUSVIEWPROJECTION,"u_TaaPreviousViewProjection",t.ShaderDataType.Matrix4x4),e.addShaderUniform(Ne.TAAMOTIONPARAMS,"u_TaaMotionParams",t.ShaderDataType.Vector4)}static __init__(){Ne.shaderValueInit()}get clearColor(){return this._clearColor}set clearColor(e){this._clearColor=e,e.toLinear(this._linearClearColor)}get skyRenderElement(){return this._skyRenderElement}get fieldOfView(){return this._fieldOfView}set fieldOfView(e){this._fieldOfView=e,this._calculateProjectionMatrix(),this._caculateMaxLocalYRange()}get maxlocalYDistance(){return this._yrange}get nearPlane(){return this._nearPlane}set nearPlane(e){this._nearPlane=e,this._calculateProjectionMatrix()}get farPlane(){return this._farPlane}set farPlane(e){this._farPlane=e,this._calculateProjectionMatrix(),this._caculateMaxLocalYRange()}get orthographic(){return this._orthographic}set orthographic(e){this._orthographic=e,this._calculateProjectionMatrix()}get orthographicVerticalSize(){return this._orthographicVerticalSize}set orthographicVerticalSize(e){this._orthographicVerticalSize=e,this._calculateProjectionMatrix()}get cullingMask(){return this._cullingMask}set cullingMask(e){this._cullingMask=e}get renderingOrder(){return this._renderingOrder}set renderingOrder(e){this._renderingOrder=e,this._sortCamerasByRenderingOrder()}constructor(e=.3,r=1e3){super(),this._forward=new t.Vector3,this._up=new t.Vector3,this._shaderValues=t.LayaGL.renderDeviceFactory.createShaderData(null),this._linearClearColor=new t.Color,this.clearColor=new t.Color(100/255,149/255,237/255,1),this._fieldOfView=60,this._useUserProjectionMatrix=!1,this._orthographicVerticalSize=10,this.renderingOrder=0,this._nearPlane=e,this._farPlane=r,this.cullingMask=2147483647,this.staticMask=4294967295,this.useOcclusionCulling=!0,this._renderEngine=t.LayaGL.renderEngine,this._orthographic=!1,this._skyRenderElement=new Le}_caculateMaxLocalYRange(){let e=3.1416*this.fieldOfView/180/2,t=this.farPlane;this._yrange=Math.tan(e)*t*2}_calculateProjectionMatrix(){}_onScreenSizeChanged(){this._calculateProjectionMatrix()}_sortCamerasByRenderingOrder(){if(this.displayedInStage)for(var e=this._scene._cameraPool,t=e.length-1,r=0;r<t;r++)if(e[r].renderingOrder>e[t].renderingOrder){var a=e[r];e[r]=e[t],e[t]=a}}_prepareCameraToRender(){this.transform.getForward(this._forward),this.transform.getUp(this._up),this._shaderValues.setVector3(Ne.CAMERAPOS,this.transform.position),this._shaderValues.setVector3(Ne.CAMERADIRECTION,this._forward),this._shaderValues.setVector3(Ne.CAMERAUP,this._up)}render(e){}addLayer(e){this.cullingMask|=Math.pow(2,e)}removeLayer(e){this.cullingMask&=~Math.pow(2,e)}addAllLayers(){this.cullingMask=2147483647}removeAllLayers(){this.cullingMask=0}resetProjectionMatrix(){this._useUserProjectionMatrix=!1,this._calculateProjectionMatrix()}_onActive(){this._scene._addCamera(this),super._onActive()}_onInActive(){this._scene._removeCamera(this),super._onInActive()}destroy(e=!0){this._skyRenderElement.destroy(),this._skyRenderElement=null,t.ILaya.stage.off(t.Event.RESIZE,this,this._onScreenSizeChanged),super.destroy(e)}}Ne.cameraBlockName="BaseCamera",Ne.RENDERINGTYPE_SHADERDEFINE_FXAA="FXAA",Ne.RENDERINGTYPE_DEFERREDLIGHTING="DEFERREDLIGHTING",Ne.RENDERINGTYPE_FORWARDRENDERING="FORWARDRENDERING",Ne._invertYScaleMatrix=new t.Matrix4x4(1,0,0,0,0,-1,0,0,0,0,1,0,0,0,0,1),Ne._invertYProjectionMatrix=new t.Matrix4x4,Ne._invertYProjectionViewMatrix=new t.Matrix4x4;class Oe{constructor(){this._length=0,this._elements=[]}add(e){let t=this._elements.indexOf(e);-1!=t&&t<this._length||(this._length===this._elements.length?this._elements.push(e):this._elements[this._length]=e,this._length++)}remove(e){var t=this._elements.indexOf(e);if(-1!=t&&(this._length--,t!==this._length)){var r=this._elements[this._length];this._elements[t]=r}}shift(){return this._length--,this._elements.shift()}getBrightestLight(){for(var e,t=-1,r=this._elements,a=0;a<this._length;a++){var i=r[a]._intensity;t<i&&(t=i,e=a)}return e}normalLightOrdering(e){var t=this._elements[0];this._elements[0]=this._elements[e],this._elements[e]=t}}class be extends Oe{remove(e){var t=this._elements.indexOf(e);this._elements.splice(t,1),this._length--}}class Ve{get lightmapColor(){return this._lightmapColor}set lightmapColor(e){this._lightmapColor!=e&&(this._lightmapColor&&this._lightmapColor._removeReference(),this._lightmapColor=e,e?(e._addReference(),this._dataModule.lightmapColor=e._texture):this._dataModule.lightmapColor=null)}get lightmapDirection(){return this._lightmapDirection}set lightmapDirection(e){this._lightmapDirection!=e&&(this._lightmapDirection&&this._lightmapDirection._removeReference(),this._lightmapDirection=e,e?(e._addReference(),this._dataModule.lightmapDirection=e._texture):this._dataModule.lightmapDirection=null)}constructor(){this._dataModule=T.Render3DModuleDataFactory.createLightmapData()}}Ve.ApplyLightmapEvent="ApplyLightmap";class Ue{}var He;e.ShadowCascadesMode=void 0,(He=e.ShadowCascadesMode||(e.ShadowCascadesMode={}))[He.NoCascades=0]="NoCascades",He[He.TwoCascades=1]="TwoCascades",He[He.FourCascades=2]="FourCascades";class Ge{constructor(e=new t.Vector3,r=0){this.normal=e,this.distance=r}static createPlaneBy3P(e,t,r,a){var i=t.x-e.x,n=t.y-e.y,s=t.z-e.z,o=r.x-e.x,l=r.y-e.y,h=r.z-e.z,d=n*h-s*l,c=s*o-i*h,u=i*l-n*o,_=1/Math.sqrt(d*d+c*c+u*u),f=d*_,m=c*_,g=u*_,p=a.normal;p.x=f,p.y=m,p.z=g,a.normal=p.normalize(),a.distance=-(f*e.x+m*e.y+g*e.z)}normalize(){var e=this.normal.x,t=this.normal.y,r=this.normal.z,a=1/Math.sqrt(e*e+t*t+r*r);this.normal.x=e*a,this.normal.y=t*a,this.normal.z=r*a,this.distance*=a}cloneTo(e){this.normal.cloneTo(e.normal),e.distance=this.distance}clone(){var e=new Ge;return this.cloneTo(e),e}}Ge.PlaneIntersectionType_Back=0,Ge.PlaneIntersectionType_Front=1,Ge.PlaneIntersectionType_Intersecting=2;class ke{constructor(e,t){this.origin=e,this.direction=t}at(e,r){t.Vector3.scale(this.direction,e,r),t.Vector3.add(this.origin,r,r)}}class ze{}ze.Disjoint=0,ze.Contains=1,ze.Intersects=2;class We{constructor(){}static distancePlaneToPoint(e,r){return t.Vector3.dot(e.normal,r)+e.distance}static distanceBoxToPoint(e,t){var r=e.min,a=r.x,i=r.y,n=r.z,s=e.max,o=s.x,l=s.y,h=s.z,d=t.x,c=t.y,u=t.z,_=0;return d<a&&(_+=(a-d)*(a-d)),d>o&&(_+=(o-d)*(o-d)),c<i&&(_+=(i-c)*(i-c)),c>l&&(_+=(l-c)*(l-c)),u<n&&(_+=(n-u)*(n-u)),u>h&&(_+=(h-u)*(h-u)),Math.sqrt(_)}static distanceBoxToBox(e,t){var r,a=e.min,i=a.x,n=a.y,s=a.z,o=e.max,l=o.x,h=o.y,d=o.z,c=t.min,u=c.x,_=c.y,f=c.z,m=t.max,g=m.x,p=m.y,S=m.z,T=0;return i>g?T+=(r=i-g)*r:u>l&&(T+=(r=u-l)*r),n>p?T+=(r=n-p)*r:_>h&&(T+=(r=_-h)*r),s>S?T+=(r=s-S)*r:f>d&&(T+=(r=f-d)*r),Math.sqrt(T)}static distanceSphereToPoint(e,r){var a=Math.sqrt(t.Vector3.distanceSquared(e.center,r));return a-=e.radius,Math.max(a,0)}static distanceSphereToSphere(e,r){var a=Math.sqrt(t.Vector3.distanceSquared(e.center,r.center));return a-=e.radius+r.radius,Math.max(a,0)}static intersectsRayAndTriangleRD(e,r,a,i,n){var s=e.origin,o=s.x,l=s.y,h=s.z,d=e.direction,c=d.x,u=d.y,_=d.z,f=r.x,m=r.y,g=r.z,p=a.x,S=a.y,T=a.z,A=i.x,E=i.y,D=i.z,R=Qe.x,x=Qe.y,y=Qe.z;R=p-f,x=S-m,y=T-g;var M=Ye.x,C=Ye.y,v=Ye.z;M=A-f,C=E-m,v=D-g;var I=Xe.x,w=Xe.y,B=Xe.z,P=R*(I=u*v-_*C)+x*(w=_*M-c*v)+y*(B=c*C-u*M);if(t.MathUtils3D.isZero(P))return!1;var L=1/P,F=Ke.x,N=Ke.y,O=Ke.z,b=(F=o-f)*I+(N=l-m)*w+(O=h-g)*B;if((b*=L)<0||b>1)return!1;var V=je.x,U=je.y,H=je.z,G=c*(V=N*y-O*x)+u*(U=O*R-F*y)+_*(H=F*x-N*R);if((G*=L)<0||b+G>1)return!1;var k=M*V+C*U+v*H;return!((k*=L)<0)}static intersectsRayAndTriangleRP(e,r,a,i,n){var s;return We.intersectsRayAndTriangleRD(e,r,a,i,s)?(t.Vector3.scale(e.direction,s,Qe),t.Vector3.add(e.origin,Qe,n),!0):(t.Vector3.ZERO.cloneTo(n),!1)}static intersectsRayAndPoint(e,r){t.Vector3.subtract(e.origin,r,Qe);var a=t.Vector3.dot(Qe,e.direction),i=t.Vector3.dot(Qe,Qe)-t.MathUtils3D.zeroTolerance;return!(i>0&&a>0)&&!(a*a-i<0)}static intersectsRayAndRay(e,r,a){var i=e.origin,n=i.x,s=i.y,o=i.z,l=e.direction,h=l.x,d=l.y,c=l.z,u=r.origin,_=u.x,f=u.y,m=u.z,g=r.direction,p=g.x,S=g.y,T=g.z;t.Vector3.cross(l,g,Qe);var A=Qe,E=t.Vector3.scalarLength(Qe);if(t.MathUtils3D.isZero(E)&&t.MathUtils3D.nearEqual(_,n)&&t.MathUtils3D.nearEqual(f,s)&&t.MathUtils3D.nearEqual(m,o))return t.Vector3.ZERO.cloneTo(a),!0;E*=E;var D=_-n,R=f-s,x=m-o,y=p,M=S,C=T,v=A.x,I=A.y,w=A.z,B=D*M*w+R*C*v+x*y*I-D*C*I-R*y*w-x*M*v;y=h,M=d,C=c;var P=B/E;t.Vector3.scale(l,P,Qe),t.Vector3.scale(g,P,Ye),t.Vector3.add(i,Qe,Xe),t.Vector3.add(u,Ye,Ke);var L=Xe,F=Ke;return t.MathUtils3D.nearEqual(F.x,L.x)&&t.MathUtils3D.nearEqual(F.y,L.y)&&t.MathUtils3D.nearEqual(F.z,L.z)?(a=Xe,!0):(t.Vector3.ZERO.cloneTo(a),!1)}static intersectsPlaneAndTriangle(e,t,r,a){var i=We.intersectsPlaneAndPoint(e,t),n=We.intersectsPlaneAndPoint(e,r),s=We.intersectsPlaneAndPoint(e,a);return i==Ge.PlaneIntersectionType_Front&&n==Ge.PlaneIntersectionType_Front&&s==Ge.PlaneIntersectionType_Front?Ge.PlaneIntersectionType_Front:i==Ge.PlaneIntersectionType_Back&&n==Ge.PlaneIntersectionType_Back&&s==Ge.PlaneIntersectionType_Back?Ge.PlaneIntersectionType_Back:Ge.PlaneIntersectionType_Intersecting}static intersectsRayAndPlaneRD(e,r){var a=r.normal,i=t.Vector3.dot(a,e.direction);if(Math.abs(i)<t.MathUtils3D.zeroTolerance)return-1;var n=t.Vector3.dot(a,e.origin),s=(-r.distance-n)/i;if(s<0){if(s<-t.MathUtils3D.zeroTolerance)return-1;s=0}return s}static intersectsRayAndPlaneRP(e,r,a){var i=We.intersectsRayAndPlaneRD(e,r);if(-1==i)return a.setValue(0,0,0),!1;var n=Qe;return t.Vector3.scale(e.direction,i,n),t.Vector3.add(e.origin,n,a),!0}static intersectsRayAndBoxRD(e,r){var a=e.origin,i=a.x,n=a.y,s=a.z,o=e.direction,l=o.x,h=o.y,d=o.z,c=r.min,u=c.x,_=c.y,f=c.z,m=r.max,g=m.x,p=m.y,S=m.z,T=0,A=t.MathUtils3D.MaxValue;if(t.MathUtils3D.isZero(l)){if(i<u||i>g)return-1}else{var E=1/l,D=(u-i)*E,R=(g-i)*E;if(D>R){var x=D;D=R,R=x}if((T=Math.max(D,T))>(A=Math.min(R,A)))return-1}if(t.MathUtils3D.isZero(h)){if(n<_||n>p)return-1}else{var y=1/h,M=(_-n)*y,C=(p-n)*y;if(M>C){var v=M;M=C,C=v}if((T=Math.max(M,T))>(A=Math.min(C,A)))return-1}if(t.MathUtils3D.isZero(d)){if(s<f||s>S)return-1}else{var I=1/d,w=(f-s)*I,B=(S-s)*I;if(w>B){var P=w;w=B,B=P}if((T=Math.max(w,T))>(A=Math.min(B,A)))return-1}return T}static intersectsRayAndBoxRP(e,r,a){var i=We.intersectsRayAndBoxRD(e,r);return-1===i?(t.Vector3.ZERO.cloneTo(a),i):(t.Vector3.scale(e.direction,i,Qe),t.Vector3.add(e.origin,Qe,Ye),Ye.cloneTo(a),i)}static intersectsRayAndSphereRD(e,r){var a=r.radius;t.Vector3.subtract(e.origin,r.center,Qe);var i=t.Vector3.dot(Qe,e.direction),n=t.Vector3.dot(Qe,Qe)-a*a;if(n>0&&i>0)return-1;var s=i*i-n;if(s<0)return-1;var o=-i-Math.sqrt(s);return o<0&&(o=0),o}static intersectsRayAndSphereRP(e,r,a){var i=We.intersectsRayAndSphereRD(e,r);return-1===i?(t.Vector3.ZERO.cloneTo(a),i):(t.Vector3.scale(e.direction,i,Qe),t.Vector3.add(e.origin,Qe,Ye),Ye.cloneTo(a),i)}static intersectsSphereAndTriangle(e,r,a,i){var n=e.center,s=e.radius;return We.closestPointPointTriangle(n,r,a,i,Qe),t.Vector3.subtract(Qe,n,Ye),t.Vector3.dot(Ye,Ye)<=s*s}static intersectsPlaneAndPoint(e,r){var a=t.Vector3.dot(e.normal,r)+e.distance;return a>0?Ge.PlaneIntersectionType_Front:a<0?Ge.PlaneIntersectionType_Back:Ge.PlaneIntersectionType_Intersecting}static intersectsPlaneAndPlane(e,r){t.Vector3.cross(e.normal,r.normal,Qe);var a=t.Vector3.dot(Qe,Qe);return!t.MathUtils3D.isZero(a)}static intersectsPlaneAndPlaneRL(e,r,a){var i=e.normal,n=r.normal;t.Vector3.cross(i,n,je);var s=t.Vector3.dot(je,je);return!t.MathUtils3D.isZero(s)&&(t.Vector3.scale(n,e.distance,Qe),t.Vector3.scale(i,r.distance,Ye),t.Vector3.subtract(Qe,Ye,Xe),t.Vector3.cross(Xe,je,Ke),t.Vector3.normalize(je,je),new ke(Ke,je),!0)}static intersectsPlaneAndBox(e,r){var a=e.distance,i=e.normal,n=i.x,s=i.y,o=i.z,l=r.min,h=l.x,d=l.y,c=l.z,u=r.max,_=u.x,f=u.y,m=u.z;Qe.x=n>0?h:_,Qe.y=s>0?d:f,Qe.z=o>0?c:m,Ye.x=n>0?_:h,Ye.y=s>0?f:d,Ye.z=o>0?m:c;var g=t.Vector3.dot(i,Qe);return g+a>0?Ge.PlaneIntersectionType_Front:(g=t.Vector3.dot(i,Ye))+a<0?Ge.PlaneIntersectionType_Back:Ge.PlaneIntersectionType_Intersecting}static intersectsPlaneAndSphere(e,r){var a=r.radius,i=t.Vector3.dot(e.normal,r.center)+e.distance;return i>a?Ge.PlaneIntersectionType_Front:i<-a?Ge.PlaneIntersectionType_Back:Ge.PlaneIntersectionType_Intersecting}static intersectsBoxAndBox(e,t){var r=e.min,a=e.max,i=t.min,n=t.max;return!(r.x>n.x||i.x>a.x)&&(!(r.y>n.y||i.y>a.y)&&!(r.z>n.z||i.z>a.z))}static intersectsBoxAndSphere(e,r){var a=r.center,i=r.radius,n=Qe;return t.Vector3.Clamp(a,e.min,e.max,n),t.Vector3.distanceSquared(a,n)<=i*i}static intersectsSphereAndSphere(e,r){var a=e.radius+r.radius;return t.Vector3.distanceSquared(e.center,r.center)<=a*a}static boxContainsPoint(e,t){var r=e.min,a=e.max;return r.x<=t.x&&a.x>=t.x&&r.y<=t.y&&a.y>=t.y&&r.z<=t.z&&a.z>=t.z?ze.Contains:ze.Disjoint}static boxContainsBox(e,t){var r=e.min,a=r.x,i=r.y,n=r.z,s=e.max,o=s.x,l=s.y,h=s.z,d=t.min,c=d.x,u=d.y,_=d.z,f=t.max,m=f.x,g=f.y,p=f.z;return o<c||a>m||l<u||i>g||h<_||n>p?ze.Disjoint:a<=c&&m<=o&&i<=u&&g<=l&&n<=_&&p<=h?ze.Contains:ze.Intersects}static boxContainsSphere(e,r){var a=e.min,i=a.x,n=a.y,s=a.z,o=e.max,l=o.x,h=o.y,d=o.z,c=r.center,u=c.x,_=c.y,f=c.z,m=r.radius;return t.Vector3.Clamp(c,a,o,Qe),t.Vector3.distanceSquared(c,Qe)>m*m?ze.Disjoint:i+m<=u&&u<=l-m&&l-i>m&&n+m<=_&&_<=h-m&&h-n>m&&s+m<=f&&f<=d-m&&d-s>m?ze.Contains:ze.Intersects}static sphereContainsPoint(e,r){return t.Vector3.distanceSquared(r,e.center)<=e.radius*e.radius?ze.Contains:ze.Disjoint}static sphereContainsTriangle(e,t,r,a){var i=We.sphereContainsPoint(e,t),n=We.sphereContainsPoint(e,r),s=We.sphereContainsPoint(e,a);return i==ze.Contains&&n==ze.Contains&&s==ze.Contains?ze.Contains:We.intersectsSphereAndTriangle(e,t,r,a)?ze.Intersects:ze.Disjoint}static sphereContainsBox(e,r){var a=e.center;a.x,a.y,a.z;var i=e.radius,n=r.min;n.x,n.y,n.z;var s=r.max;s.x,s.y,s.z;var o=Qe;if(o.x,o.y,o.z,!We.intersectsBoxAndSphere(r,e))return ze.Disjoint;var l=i*i;return t.Vector3.scalarLengthSquared(Qe)>l||t.Vector3.scalarLengthSquared(Qe)>l||t.Vector3.scalarLengthSquared(Qe)>l||t.Vector3.scalarLengthSquared(Qe)>l||t.Vector3.scalarLengthSquared(Qe)>l||t.Vector3.scalarLengthSquared(Qe)>l||t.Vector3.scalarLengthSquared(Qe)>l||t.Vector3.scalarLengthSquared(Qe)>l?ze.Intersects:ze.Contains}static sphereContainsSphere(e,r){var a=e.radius,i=r.radius,n=t.Vector3.distance(e.center,r.center);return a+i<n?ze.Disjoint:a-i<n?ze.Intersects:ze.Contains}static closestPointPointTriangle(e,r,a,i,n){t.Vector3.subtract(a,r,Qe),t.Vector3.subtract(i,r,Ye),t.Vector3.subtract(e,r,Xe),t.Vector3.subtract(e,a,Ke),t.Vector3.subtract(e,i,je);var s=t.Vector3.dot(Qe,Xe),o=t.Vector3.dot(Ye,Xe),l=t.Vector3.dot(Qe,Ke),h=t.Vector3.dot(Ye,Ke),d=t.Vector3.dot(Qe,je),c=t.Vector3.dot(Ye,je);if(s<=0&&o<=0)r.cloneTo(n);else if(l>=0&&h<=l)a.cloneTo(n);else{var u=s*h-l*o;if(u<=0&&s>=0&&l<=0){var _=s/(s-l);return t.Vector3.scale(Qe,_,n),void t.Vector3.add(r,n,n)}if(c>=0&&d<=c)i.cloneTo(n);else{var f=d*o-s*c;if(f<=0&&o>=0&&c<=0){var m=o/(o-c);return t.Vector3.scale(Ye,m,n),void t.Vector3.add(r,n,n)}var g=l*c-d*h;if(g<=0&&h-l>=0&&d-c>=0){var p=(h-l)/(h-l+(d-c));return t.Vector3.subtract(i,a,n),t.Vector3.scale(n,p,n),void t.Vector3.add(a,n,n)}var S=1/(g+f+u),T=f*S,A=u*S;t.Vector3.scale(Qe,T,Je),t.Vector3.scale(Ye,A,qe),t.Vector3.add(Je,qe,n),t.Vector3.add(r,n,n)}}}static closestPointPlanePoint(e,r,a){var i=e.normal,n=t.Vector3.dot(i,r)-e.distance;t.Vector3.scale(i,n,Qe),t.Vector3.subtract(r,Qe,a)}static closestPointBoxPoint(e,r,a){t.Vector3.max(r,e.min,Qe),t.Vector3.min(Qe,e.max,a)}static closestPointSpherePoint(e,r,a){var i=e.center;t.Vector3.subtract(r,i,a),t.Vector3.normalize(a,a),t.Vector3.scale(a,e.radius,a),t.Vector3.add(a,i,a)}static closestPointSphereSphere(e,r,a){var i=e.center;t.Vector3.subtract(r.center,i,a),t.Vector3.normalize(a,a),t.Vector3.scale(a,e.radius,a),t.Vector3.add(a,i,a)}}const Qe=new t.Vector3,Ye=new t.Vector3,Xe=new t.Vector3,Ke=new t.Vector3,je=new t.Vector3,Je=new t.Vector3,qe=new t.Vector3;var Ze;e.FrustumCorner=void 0,(Ze=e.FrustumCorner||(e.FrustumCorner={}))[Ze.FarBottomLeft=0]="FarBottomLeft",Ze[Ze.FarTopLeft=1]="FarTopLeft",Ze[Ze.FarTopRight=2]="FarTopRight",Ze[Ze.FarBottomRight=3]="FarBottomRight",Ze[Ze.nearBottomLeft=4]="nearBottomLeft",Ze[Ze.nearTopLeft=5]="nearTopLeft",Ze[Ze.nearTopRight=6]="nearTopRight",Ze[Ze.nearBottomRight=7]="nearBottomRight",Ze[Ze.unknown=8]="unknown";class $e{static getPlanesFromMatrix(e,t,r,a,i,n,s){var o=e.elements,l=o[0],h=o[1],d=o[2],c=o[3],u=o[4],_=o[5],f=o[6],m=o[7],g=o[8],p=o[9],S=o[10],T=o[11],A=o[12],E=o[13],D=o[14],R=o[15],x=t.normal;x.x=d,x.y=f,x.z=S,t.distance=D,t.normal=x,t.normalize();var y=r.normal;y.x=c-d,y.y=m-f,y.z=T-S,r.distance=R-D,r.normal=y,r.normalize();var M=a.normal;M.x=c+l,M.y=m+u,M.z=T+g,a.distance=R+A,a.normal=M,a.normalize();var C=i.normal;C.x=c-l,C.y=m-u,C.z=T-g,i.distance=R-A,i.normal=C,i.normalize();var v=n.normal;v.x=c-h,v.y=m-_,v.z=T-p,n.distance=R-E,n.normal=v,n.normalize();var I=s.normal;I.x=c+h,I.y=m+_,I.z=T+p,s.distance=R+E,s.normal=I,s.normalize()}constructor(e){this._matrix=e,this.initBoundingPlane()}initBoundingPlane(){this._near=new Ge,this._far=new Ge,this._left=new Ge,this._right=new Ge,this._top=new Ge,this._bottom=new Ge,$e.getPlanesFromMatrix(this._matrix,this._near,this._far,this._left,this._right,this._top,this._bottom)}get matrix(){return this._matrix}set matrix(e){e.cloneTo(this._matrix),$e.getPlanesFromMatrix(this._matrix,this._near,this._far,this._left,this._right,this._top,this._bottom)}get near(){return this._near}get far(){return this._far}get left(){return this._left}get right(){return this._right}get top(){return this._top}get bottom(){return this._bottom}equalsBoundFrustum(e){return this._matrix.equalsOtherMatrix(e.matrix)}equalsObj(e){if(e instanceof $e){var t=e;return this.equalsBoundFrustum(t)}return!1}getPlane(e){switch(e){case 0:return this._near;case 1:return this._far;case 2:return this._left;case 3:return this._right;case 4:return this._top;case 5:return this._bottom;default:return null}}static get3PlaneInterPoint(e,r,a,i){var n=e.normal,s=r.normal,o=a.normal;t.Vector3.cross(s,o,et),t.Vector3.cross(o,n,tt),t.Vector3.cross(n,s,rt);var l=t.Vector3.dot(n,et),h=t.Vector3.dot(s,tt),d=t.Vector3.dot(o,rt);t.Vector3.scale(et,-e.distance/l,at),t.Vector3.scale(tt,-r.distance/h,it),t.Vector3.scale(rt,-a.distance/d,nt),t.Vector3.add(at,it,st),t.Vector3.add(nt,st,i)}getCorners(t){$e.get3PlaneInterPoint(this._near,this._bottom,this._right,t[e.FrustumCorner.nearBottomRight]),$e.get3PlaneInterPoint(this._near,this._top,this._right,t[e.FrustumCorner.nearTopRight]),$e.get3PlaneInterPoint(this._near,this._top,this._left,t[e.FrustumCorner.nearTopLeft]),$e.get3PlaneInterPoint(this._near,this._bottom,this._left,t[e.FrustumCorner.nearBottomLeft]),$e.get3PlaneInterPoint(this._far,this._bottom,this._right,t[e.FrustumCorner.FarBottomRight]),$e.get3PlaneInterPoint(this._far,this._top,this._right,t[e.FrustumCorner.FarTopRight]),$e.get3PlaneInterPoint(this._far,this._top,this._left,t[e.FrustumCorner.FarTopLeft]),$e.get3PlaneInterPoint(this._far,this._bottom,this._left,t[e.FrustumCorner.FarBottomLeft])}containsPoint(e){for(var t=Ge.PlaneIntersectionType_Front,r=Ge.PlaneIntersectionType_Front,a=0;a<6;a++){switch(a){case 0:r=We.intersectsPlaneAndPoint(this._near,e);break;case 1:r=We.intersectsPlaneAndPoint(this._far,e);break;case 2:r=We.intersectsPlaneAndPoint(this._left,e);break;case 3:r=We.intersectsPlaneAndPoint(this._right,e);break;case 4:r=We.intersectsPlaneAndPoint(this._top,e);break;case 5:r=We.intersectsPlaneAndPoint(this._bottom,e)}switch(r){case Ge.PlaneIntersectionType_Back:return ze.Disjoint;case Ge.PlaneIntersectionType_Intersecting:t=Ge.PlaneIntersectionType_Intersecting}}return t===Ge.PlaneIntersectionType_Intersecting?ze.Intersects:ze.Contains}intersects(e){var t=e.min,r=e.max,a=t.x,i=t.y,n=t.z,s=r.x,o=r.y,l=r.z,h=this._near.normal;if(this._near.distance+h.x*(h.x<0?a:s)+h.y*(h.y<0?i:o)+h.z*(h.z<0?n:l)<0)return!1;var d=this._left.normal;if(this._left.distance+d.x*(d.x<0?a:s)+d.y*(d.y<0?i:o)+d.z*(d.z<0?n:l)<0)return!1;var c=this._right.normal;if(this._right.distance+c.x*(c.x<0?a:s)+c.y*(c.y<0?i:o)+c.z*(c.z<0?n:l)<0)return!1;var u=this._bottom.normal;if(this._bottom.distance+u.x*(u.x<0?a:s)+u.y*(u.y<0?i:o)+u.z*(u.z<0?n:l)<0)return!1;var _=this._top.normal;if(this._top.distance+_.x*(_.x<0?a:s)+_.y*(_.y<0?i:o)+_.z*(_.z<0?n:l)<0)return!1;var f=this._far.normal;return!(this._far.distance+f.x*(f.x<0?a:s)+f.y*(f.y<0?i:o)+f.z*(f.z<0?n:l)<0)}containsBoundBox(e){for(var t=et,r=tt,a=e.min,i=e.max,n=ze.Contains,s=0;s<6;s++){var o=this.getPlane(s),l=o.normal;if(l.x>=0?(t.x=i.x,r.x=a.x):(t.x=a.x,r.x=i.x),l.y>=0?(t.y=i.y,r.y=a.y):(t.y=a.y,r.y=i.y),l.z>=0?(t.z=i.z,r.z=a.z):(t.z=a.z,r.z=i.z),We.intersectsPlaneAndPoint(o,t)===Ge.PlaneIntersectionType_Back)return ze.Disjoint;We.intersectsPlaneAndPoint(o,r)===Ge.PlaneIntersectionType_Back&&(n=ze.Intersects)}return n}containsBoundSphere(e){for(var t=Ge.PlaneIntersectionType_Front,r=Ge.PlaneIntersectionType_Front,a=0;a<6;a++){switch(a){case 0:r=We.intersectsPlaneAndSphere(this._near,e);break;case 1:r=We.intersectsPlaneAndSphere(this._far,e);break;case 2:r=We.intersectsPlaneAndSphere(this._left,e);break;case 3:r=We.intersectsPlaneAndSphere(this._right,e);break;case 4:r=We.intersectsPlaneAndSphere(this._top,e);break;case 5:r=We.intersectsPlaneAndSphere(this._bottom,e)}switch(r){case Ge.PlaneIntersectionType_Back:return ze.Disjoint;case Ge.PlaneIntersectionType_Intersecting:t=Ge.PlaneIntersectionType_Intersecting}}return t===Ge.PlaneIntersectionType_Intersecting?ze.Intersects:ze.Contains}cloneTo(e){e.matrix=this.matrix}clone(){let e=new $e(new t.Matrix4x4);return this.cloneTo(e),e}}const et=new t.Vector3,tt=new t.Vector3,rt=new t.Vector3,at=new t.Vector3,it=new t.Vector3,nt=new t.Vector3,st=new t.Vector3;var ot,lt,ht,dt,ct;e.ShadowMode=void 0,(ot=e.ShadowMode||(e.ShadowMode={}))[ot.None=0]="None",ot[ot.Hard=1]="Hard",ot[ot.SoftLow=2]="SoftLow",ot[ot.SoftHigh=3]="SoftHigh",e.LightType=void 0,(lt=e.LightType||(e.LightType={}))[lt.Directional=0]="Directional",lt[lt.Spot=1]="Spot",lt[lt.Point=2]="Point",lt[lt.Area=3]="Area",e.LightMode=void 0,(ht=e.LightMode||(e.LightMode={}))[ht.mix=0]="mix",ht[ht.realTime=1]="realTime",ht[ht.bakeOnly=2]="bakeOnly";class ut extends t.Component{get intensity(){return this._intensity}set intensity(e){this._intensity=e}get shadowMode(){return this._dataModule.shadowMode}set shadowMode(e){this._dataModule.shadowMode=e}get shadowDistance(){return this._dataModule.shadowDistance}set shadowDistance(e){this._dataModule.shadowDistance=e}get shadowResolution(){return this._dataModule.shadowResolution}set shadowResolution(e){this._dataModule.shadowResolution=e}get shadowDepthBias(){return this._dataModule.shadowDepthBias}set shadowDepthBias(e){this._dataModule.shadowDepthBias=e}get shadowNormalBias(){return this._dataModule.shadowNormalBias}set shadowNormalBias(e){this._dataModule.shadowNormalBias=e}get shadowStrength(){return this._dataModule.shadowStrength}set shadowStrength(e){this._dataModule.shadowStrength=e}get shadowNearPlane(){return this._dataModule.shadowNearPlane}set shadowNearPlane(e){this._dataModule.shadowNearPlane=e}get lightmapBakedType(){return this._lightmapBakedType}set lightmapBakedType(t){let r=this._lightmapBakedType;this._lightmapBakedType!==t&&(this._lightmapBakedType=t,this._enabled&&(t==e.LightMode.bakeOnly?this._removeFromScene():r==e.LightMode.bakeOnly&&this._addToScene()))}get lightWorldMatrix(){var e=this.owner.transform.position,r=this.owner.transform.rotation;return t.Matrix4x4.createAffineTransformation(e,r,t.Vector3.ONE,this._lightWoldMatrix),this._lightWoldMatrix}get lightType(){return this._lightType}constructor(){super(),this._shadowMode=e.ShadowMode.None,this._isAlternate=!1,this._lightWoldMatrix=new t.Matrix4x4,this._creatModuleData(),this.runInEditor=!0,this._intensity=1,this._intensityColor=new t.Vector3,this.color=new t.Color(1,1,1,1),this._lightmapBakedType=e.LightMode.realTime,this.shadowResolution=2048,this.shadowDistance=50,this.shadowDepthBias=1,this.shadowNormalBias=1,this.shadowNearPlane=.1,this.shadowStrength=1,this.shadowMode=e.ShadowMode.None}_creatModuleData(){}_setOwner(e){super._setOwner(e),this._dataModule.transform=this.owner.transform}_getRenderDataModule(){return this._dataModule}_cloneTo(e){super._cloneTo(e),e.color=this.color.clone(),e.intensity=this.intensity,e.lightmapBakedType=this.lightmapBakedType}_addToScene(){var e=this.owner.scene,r=t.Config3D.maxLightCount;e._lightCount<r?(e._lightCount++,this._addToLightQueue(),this._isAlternate=!1):(e._alternateLights.add(this),this._isAlternate=!0,console.warn("LightSprite:light count has large than maxLightCount,the latest added light will be ignore."))}_removeFromScene(){var e=this.owner._scene;if(e)if(this._isAlternate)e._alternateLights.remove(this);else if(e._lightCount--,this._removeFromLightQueue(),e._alternateLights._length>0){var t=e._alternateLights.shift();t._addToLightQueue(),t._isAlternate=!1,e._lightCount++}}_addToLightQueue(){}_removeFromLightQueue(){}_onEnable(){this.lightmapBakedType!==e.LightMode.bakeOnly&&this._addToScene()}_onDisable(){this.lightmapBakedType!==e.LightMode.bakeOnly&&this._removeFromScene()}}!function(e){e[e.Near=0]="Near",e[e.Far=1]="Far",e[e.Left=2]="Left",e[e.Right=3]="Right",e[e.Bottom=4]="Bottom",e[e.Top=5]="Top"}(dt||(dt={})),e.ShadowMapFormat=void 0,(ct=e.ShadowMapFormat||(e.ShadowMapFormat={}))[ct.bit16=0]="bit16",ct[ct.bit24_8=1]="bit24_8",ct[ct.bit32=2]="bit32";class _t{static init(){_t._adjustNearPlane=new Ge(new t.Vector3,0),_t._adjustFarPlane=new Ge(new t.Vector3,0)}static supportShadow(){return t.LayaGL.renderEngine.getCapable(t.RenderCapable.RenderTextureFormat_Depth)}static getTemporaryShadowTexture(r,a,i){let n=t.RenderTargetFormat.DEPTH_16;switch(i){case e.ShadowMapFormat.bit16:n=t.RenderTargetFormat.DEPTH_16;break;case e.ShadowMapFormat.bit24_8:n=t.RenderTargetFormat.DEPTHSTENCIL_24_8;break;case e.ShadowMapFormat.bit32:n=t.RenderTargetFormat.DEPTH_32}var s=t.RenderTexture.createFromPool(r,a,n,t.RenderTargetFormat.None,!1,1);return s.compareMode=t.TextureCompareMode.LESS,s.filterMode=t.FilterMode.Bilinear,s.wrapModeU=t.WrapMode.Clamp,s.wrapModeV=t.WrapMode.Clamp,s}static getShadowBias(r,a,i,n){var s;r._lightType==e.LightType.Directional?s=2/a.elements[0]:r._lightType==e.LightType.Spot?s=Math.tan(.5*r.spotAngle*t.MathUtils3D.Deg2Rad)*r.range:(console.warn("ShadowUtils:Only spot and directional shadow casters are supported now."),s=0);var o=s/i,l=-r.shadowDepthBias*o,h=-r.shadowNormalBias*o;if(r.shadowMode==e.ShadowMode.SoftHigh){const e=2.5;l*=e,h*=e}n.setValue(l,h,0,0)}static getCameraFrustumPlanes(e,t){$e.getPlanesFromMatrix(e,t[dt.Near],t[dt.Far],t[dt.Left],t[dt.Right],t[dt.Top],t[dt.Bottom])}static getFarWithRadius(e,t){return Math.sqrt(e*e/t)}static getCascadesSplitDistance(t,r,a,i,n,s,o,l){l[0]=a;var h=i-a,d=Math.tan(.5*n),c=1+d*d*(s*s+1);switch(o){case e.ShadowCascadesMode.NoCascades:l[1]=_t.getFarWithRadius(i,c);break;case e.ShadowCascadesMode.TwoCascades:l[1]=_t.getFarWithRadius(a+h*t,c),l[2]=_t.getFarWithRadius(i,c);break;case e.ShadowCascadesMode.FourCascades:l[1]=_t.getFarWithRadius(a+h*r.x,c),l[2]=_t.getFarWithRadius(a+h*r.y,c),l[3]=_t.getFarWithRadius(a+h*r.z,c),l[4]=_t.getFarWithRadius(i,c)}}static applySliceTransform(e,t,r,a,i){var n=ft.elements,s=1/t,o=1/r;n[0]=e.resolution*s,n[5]=e.resolution*o,n[12]=e.offsetX*s,n[13]=e.offsetY*o,n[1]=n[2]=n[2]=n[4]=n[6]=n[7]=n[8]=n[9]=n[11]=n[14]=0,n[10]=n[15]=1;var l=16*a;Z._mulMatrixArray(n,i,l,i,l)}static getDirectionLightShadowCullPlanes(r,a,i,n,s,o){var l=gt,h=_t._backPlaneFaces,d=pt,c=St,u=_t._edgePlanePoint2,_=o.cullPlanes,f=r[dt.Near],m=r[dt.Far],g=r[dt.Left],p=r[dt.Right],S=r[dt.Bottom],T=r[dt.Top],A=i[a]-n,E=_t._adjustNearPlane,D=_t._adjustFarPlane;E.normal=f.normal,D.normal=m.normal,E.distance=f.distance-A,D.distance=Math.min(-f.distance+o.sphereCenterZ+o.splitBoundSphere.radius,m.distance),$e.get3PlaneInterPoint(E,S,p,l[e.FrustumCorner.nearBottomRight]),$e.get3PlaneInterPoint(E,T,p,l[e.FrustumCorner.nearTopRight]),$e.get3PlaneInterPoint(E,T,g,l[e.FrustumCorner.nearTopLeft]),$e.get3PlaneInterPoint(E,S,g,l[e.FrustumCorner.nearBottomLeft]),$e.get3PlaneInterPoint(D,S,p,l[e.FrustumCorner.FarBottomRight]),$e.get3PlaneInterPoint(D,T,p,l[e.FrustumCorner.FarTopRight]),$e.get3PlaneInterPoint(D,T,g,l[e.FrustumCorner.FarTopLeft]),$e.get3PlaneInterPoint(D,S,g,l[e.FrustumCorner.FarBottomLeft]);for(var R=0,x=0;x<6;x++){var y;switch(x){case dt.Near:y=E;break;case dt.Far:y=D;break;default:y=r[x]}t.Vector3.dot(y.normal,s)<0&&(y.cloneTo(_[R]),h[R]=x,R++)}var M=R;for(x=0;x<R;x++)for(var C=h[x],v=d[C],I=0;I<4;I++){for(var w=v[I],B=!0,P=0;P<R;P++)if(w==h[P]){B=!1;break}if(B){var L=c[C][w],F=l[L[0]],N=l[L[1]];t.Vector3.add(F,s,u),Ge.createPlaneBy3P(F,N,u,_[M++])}}o.cullPlaneCount=M}static getBoundSphereByFrustum(e,r,a,i,n,s,o){var l,h,d=Math.sqrt(1+i*i)*Math.tan(a/2),c=d*d,u=r-e,_=r+e;c>u/_?(l=r,h=r*d):(l=.5*_*(1+c),h=.5*Math.sqrt(u*u+2*(r*r+e*e)*c+_*_*c*c));var f=o.center;return o.radius=h,t.Vector3.scale(s,l,f),t.Vector3.add(n,f,f),o.center=f,l}static getMaxTileResolutionInAtlas(e,t,r){for(var a=Math.min(e,t),i=Math.floor(e/a)*Math.floor(t/a);i<r;)a=Math.floor(a>>1),i=Math.floor(e/a)*Math.floor(t/a);return a}static getDirectionalLightMatrices(e,r,a,i,n,s,o,l){var h=o.splitBoundSphere,d=h.center,c=h.radius,u=s/2,_=c*u/(u-_t.atlasBorderSize),f=2*_,m=s/f,g=f/s,p=Math.ceil(t.Vector3.dot(d,e)*m)*g,S=Math.ceil(t.Vector3.dot(d,r)*m)*g,T=t.Vector3.dot(d,a);d.x=e.x*p+r.x*S+a.x*T,d.y=e.y*p+r.y*S+a.y*T,d.z=e.z*p+r.z*S+a.z*T,h.center=d;var A=o.position,E=o.viewMatrix,D=o.projectionMatrix,R=o.viewProjectMatrix;o.resolution=s,o.offsetX=i%2*s,o.offsetY=Math.floor(i/2)*s,t.Vector3.scale(a,c+n,A),t.Vector3.subtract(d,A,A),t.Matrix4x4.createLookAt(A,d,e,E),t.Matrix4x4.createOrthoOffCenter(-_,_,-_,_,0,2*c+n,D),t.Matrix4x4.multiply(D,E,R);let x=mt.elements;Z._mulMatrixArray(x,R.elements,0,l,16*i)}static prepareShadowReceiverShaderValues(e,t,r,a,i,n,s){if(i.setValue(1/e,1/t,e,t),a>1){const e=16;for(var o=a*e,l=4*e;o<l;o++)n[o]=0;for(o=0;o<a;o++){var h=r[o].splitBoundSphere,d=h.center,c=h.radius,u=4*o;s[u]=d.x,s[u+1]=d.y,s[u+2]=d.z,s[u+3]=c*c}const t=4;for(o=a*t,l=4*t;o<l;o++)s[o]=0}}}_t._backPlaneFaces=new Array(5),_t._edgePlanePoint2=new t.Vector3,_t.atlasBorderSize=4;const ft=new t.Matrix4x4,mt=new t.Matrix4x4(.5,0,0,0,0,.5,0,0,0,0,1,0,.5,.5,0,1);new t.Matrix4x4(.5,0,0,0,0,-.5,0,0,0,0,1,0,.5,.5,0,1);const gt=[new t.Vector3,new t.Vector3,new t.Vector3,new t.Vector3,new t.Vector3,new t.Vector3,new t.Vector3,new t.Vector3],pt=[[dt.Left,dt.Right,dt.Top,dt.Bottom],[dt.Left,dt.Right,dt.Top,dt.Bottom],[dt.Near,dt.Far,dt.Top,dt.Bottom],[dt.Near,dt.Far,dt.Top,dt.Bottom],[dt.Near,dt.Far,dt.Left,dt.Right],[dt.Near,dt.Far,dt.Left,dt.Right]],St=[[[e.FrustumCorner.unknown,e.FrustumCorner.unknown],[e.FrustumCorner.unknown,e.FrustumCorner.unknown],[e.FrustumCorner.nearBottomLeft,e.FrustumCorner.nearTopLeft],[e.FrustumCorner.nearTopRight,e.FrustumCorner.nearBottomRight],[e.FrustumCorner.nearBottomRight,e.FrustumCorner.nearBottomLeft],[e.FrustumCorner.nearTopLeft,e.FrustumCorner.nearTopRight]],[[e.FrustumCorner.unknown,e.FrustumCorner.unknown],[e.FrustumCorner.unknown,e.FrustumCorner.unknown],[e.FrustumCorner.FarTopLeft,e.FrustumCorner.FarBottomLeft],[e.FrustumCorner.FarBottomRight,e.FrustumCorner.FarTopRight],[e.FrustumCorner.FarBottomLeft,e.FrustumCorner.FarBottomRight],[e.FrustumCorner.FarTopRight,e.FrustumCorner.FarTopLeft]],[[e.FrustumCorner.nearTopLeft,e.FrustumCorner.nearBottomLeft],[e.FrustumCorner.FarBottomLeft,e.FrustumCorner.FarTopLeft],[e.FrustumCorner.unknown,e.FrustumCorner.unknown],[e.FrustumCorner.unknown,e.FrustumCorner.unknown],[e.FrustumCorner.nearBottomLeft,e.FrustumCorner.FarBottomLeft],[e.FrustumCorner.FarTopLeft,e.FrustumCorner.nearTopLeft]],[[e.FrustumCorner.nearBottomRight,e.FrustumCorner.nearTopRight],[e.FrustumCorner.FarTopRight,e.FrustumCorner.FarBottomRight],[e.FrustumCorner.unknown,e.FrustumCorner.unknown],[e.FrustumCorner.unknown,e.FrustumCorner.unknown],[e.FrustumCorner.FarBottomRight,e.FrustumCorner.nearBottomRight],[e.FrustumCorner.nearTopRight,e.FrustumCorner.FarTopRight]],[[e.FrustumCorner.nearBottomLeft,e.FrustumCorner.nearBottomRight],[e.FrustumCorner.FarBottomRight,e.FrustumCorner.FarBottomLeft],[e.FrustumCorner.FarBottomLeft,e.FrustumCorner.nearBottomLeft],[e.FrustumCorner.nearBottomRight,e.FrustumCorner.FarBottomRight],[e.FrustumCorner.unknown,e.FrustumCorner.unknown],[e.FrustumCorner.unknown,e.FrustumCorner.unknown]],[[e.FrustumCorner.nearTopRight,e.FrustumCorner.nearTopLeft],[e.FrustumCorner.FarTopLeft,e.FrustumCorner.FarTopRight],[e.FrustumCorner.nearTopLeft,e.FrustumCorner.FarTopLeft],[e.FrustumCorner.FarTopRight,e.FrustumCorner.nearTopRight],[e.FrustumCorner.unknown,e.FrustumCorner.unknown],[e.FrustumCorner.unknown,e.FrustumCorner.unknown]]];class Tt{static __init__(){Tt.SHADOW_BIAS=t.Shader3D.propertyNameToID("u_ShadowBias"),Tt.SHADOW_LIGHT_DIRECTION=t.Shader3D.propertyNameToID("u_ShadowLightDirection"),Tt.SHADOW_SPLIT_SPHERES=t.Shader3D.propertyNameToID("u_ShadowSplitSpheres"),Tt.SHADOW_MATRICES=t.Shader3D.propertyNameToID("u_ShadowMatrices"),Tt.SHADOW_MAP_SIZE=t.Shader3D.propertyNameToID("u_ShadowMapSize"),Tt.SHADOW_MAP=t.Shader3D.propertyNameToID("u_ShadowMap"),Tt.SHADOW_PARAMS=t.Shader3D.propertyNameToID("u_ShadowParams"),Tt.SHADOW_SPOTMAP_SIZE=t.Shader3D.propertyNameToID("u_SpotShadowMapSize"),Tt.SHADOW_SPOTMAP=t.Shader3D.propertyNameToID("u_SpotShadowMap"),Tt.SHADOW_SPOTMATRICES=t.Shader3D.propertyNameToID("u_SpotViewProjectMatrix");const e=t.LayaGL.renderDeviceFactory.createGlobalUniformMap("Shadow");e.addShaderUniform(Tt.SHADOW_LIGHT_DIRECTION,"u_ShadowLightDirection",t.ShaderDataType.Vector3),e.addShaderUniform(Tt.SHADOW_BIAS,"u_ShadowBias",t.ShaderDataType.Vector4),e.addShaderUniformArray(Tt.SHADOW_SPLIT_SPHERES,"u_ShadowSplitSpheres",t.ShaderDataType.Vector4,4),e.addShaderUniformArray(Tt.SHADOW_MATRICES,"u_ShadowMatrices",t.ShaderDataType.Matrix4x4,4),e.addShaderUniform(Tt.SHADOW_MAP_SIZE,"u_ShadowMapSize",t.ShaderDataType.Vector4),e.addShaderUniform(Tt.SHADOW_MAP,"u_ShadowMap",t.ShaderDataType.Texture2D),e.addShaderUniform(Tt.SHADOW_PARAMS,"u_ShadowParams",t.ShaderDataType.Vector4),e.addShaderUniform(Tt.SHADOW_SPOTMAP_SIZE,"u_SpotShadowMapSize",t.ShaderDataType.Vector4),e.addShaderUniform(Tt.SHADOW_SPOTMAP,"u_SpotShadowMap",t.ShaderDataType.Texture2D),e.addShaderUniform(Tt.SHADOW_SPOTMATRICES,"u_SpotViewProjectMatrix",t.ShaderDataType.Matrix4x4),this.ShadowUniformMap=e}constructor(){}getDirectLightShadowMap(r){var a,i,n,s,o=r.shadowResolution,l=r.shadowCascadesMode;return l==e.ShadowCascadesMode.NoCascades?(s=o,a=o,i=o):(n=l==e.ShadowCascadesMode.TwoCascades?2:4,a=2*(s=_t.getMaxTileResolutionInAtlas(o,o,n)),i=l==e.ShadowCascadesMode.TwoCascades?s:2*s),this._shadowDirectLightMap&&t.RenderTexture.recoverToPool(this._shadowDirectLightMap),this._shadowDirectLightMap=_t.getTemporaryShadowTexture(a,i,e.ShadowMapFormat.bit16),this._shadowDirectLightMap}getSpotLightShadowPassData(r){this._shadowSpotLightMap&&t.RenderTexture.recoverToPool(this._shadowSpotLightMap);var a=r.shadowResolution,i=a,n=a;return this._shadowSpotLightMap=_t.getTemporaryShadowTexture(i,n,e.ShadowMapFormat.bit16),this._shadowSpotLightMap}getPointLightShadowPassData(){}cleanUp(){this._shadowDirectLightMap&&t.RenderTexture.recoverToPool(this._shadowDirectLightMap),this._shadowSpotLightMap&&t.RenderTexture.recoverToPool(this._shadowSpotLightMap),this._shadowDirectLightMap=null,this._shadowSpotLightMap=null}}class At{static __init__(){At.DEPTHPASS=t.Shader3D.getDefineByName("DEPTHPASS"),At.DEFINE_SHADOW_BIAS=t.Shader3D.propertyNameToID("u_ShadowBias"),At.DEPTHTEXTURE=t.Shader3D.propertyNameToID("u_CameraDepthTexture"),At.DEPTHNORMALSTEXTURE=t.Shader3D.propertyNameToID("u_CameraDepthNormalsTexture"),At.DEPTHZBUFFERPARAMS=t.Shader3D.propertyNameToID("u_ZBufferParams")}constructor(){this._zBufferParams=new t.Vector4,this._borrowedDepthCamera=null}getTarget(e,r,a){switch(this._viewPort=e.viewport,r){case t.DepthTextureMode.Depth:e.canblitDepth&&e._internalRenderTexture.depthStencilTexture?(e.depthTexture=this._depthTexture=e._cacheDepthTexture.depthStencilTexture,this._borrowedDepthCamera=e):(e.depthTexture=this._depthTexture=t.RenderTexture.createFromPool(this._viewPort.width,this._viewPort.height,a,t.RenderTargetFormat.None,!1,1),this._borrowedDepthCamera=null);break;case t.DepthTextureMode.DepthNormals:e.depthNormalTexture=this._depthNormalsTexture=t.RenderTexture.createFromPool(this._viewPort.width,this._viewPort.height,t.RenderTargetFormat.R8G8B8A8,a,!1,1);break;case t.DepthTextureMode.MotionVectors:break;default:throw"there is UnDefined type of DepthTextureMode"}}_setupDepthModeShaderValue(e,r){switch(e){case t.DepthTextureMode.Depth:var a=r.farPlane,i=r.nearPlane;this._zBufferParams.setValue(1-a/i,a/i,(i-a)/(i*a),1/i),r._shaderValues.setVector(At.DEFINE_SHADOW_BIAS,At.SHADOW_BIAS),r._shaderValues.setTexture(At.DEPTHTEXTURE,this._depthTexture),r._shaderValues.setVector(At.DEPTHZBUFFERPARAMS,this._zBufferParams);break;case t.DepthTextureMode.DepthNormals:r._shaderValues.setTexture(At.DEPTHNORMALSTEXTURE,this._depthNormalsTexture);break;default:throw"there is UnDefined type of DepthTextureMode"}}releaseCachedDepth(e){this._borrowedDepthCamera===e&&(e._shaderValues.getTexture(At.DEPTHTEXTURE)===this._depthTexture&&(e._shaderValues.setTexture(At.DEPTHTEXTURE,null),e.depthTexture=null),this._depthTexture=null,this._borrowedDepthCamera=null)}cleanUp(e){if(this._borrowedDepthCamera)this.releaseCachedDepth(this._borrowedDepthCamera);else if(this._depthTexture){e._shaderValues.getTexture(At.DEPTHTEXTURE)==this._depthTexture&&(e._shaderValues.setTexture(At.DEPTHTEXTURE,null),e.depthTexture=null),t.RenderTexture.recoverToPool(this._depthTexture),this._depthTexture=null}if(this._depthNormalsTexture){e._shaderValues.getTexture(At.DEPTHNORMALSTEXTURE)==this._depthNormalsTexture&&(e._shaderValues.setTexture(At.DEPTHNORMALSTEXTURE,null),e.depthNormalTexture=null),t.RenderTexture.recoverToPool(this._depthNormalsTexture),this._depthNormalsTexture=null}}}At.SHADOW_BIAS=new t.Vector4;class Et{constructor(){}static calculateCursorRay(e,r,a,i,n,s){var o=e.x,l=e.y,h=Dt,d=h;d.x=o,d.y=l,d.z=r.minDepth;var c=Rt,u=c;u.x=o,u.y=l,u.z=r.maxDepth;var _=s.origin,f=xt;r.unprojectFromWVP(h,a,i,n,_),r.unprojectFromWVP(c,a,i,n,f);var m=s.direction;m.x=f.x-_.x,m.y=f.y-_.y,m.z=f.z-_.z,t.Vector3.normalize(s.direction,s.direction)}static rayIntersectsTriangle(e,r,a,i){var n=Dt,s=Rt;t.Vector3.subtract(a,r,n),t.Vector3.subtract(i,r,s);var o,l=xt;if(t.Vector3.cross(e.direction,s,l),(o=t.Vector3.dot(n,l))>-Number.MIN_VALUE&&o<Number.MIN_VALUE)return Number.NaN;var h,d=1/o,c=yt;if(t.Vector3.subtract(e.origin,r,c),h=t.Vector3.dot(c,l),(h*=d)<0||h>1)return Number.NaN;var u,_,f=Mt;return t.Vector3.cross(c,n,f),u=t.Vector3.dot(e.direction,f),(u*=d)<0||h+u>1?Number.NaN:(_=t.Vector3.dot(s,f),(_*=d)<0?Number.NaN:_)}static rayPlaneIntersection(e,r){let a=new t.Vector3,i=t.Vector3.dot(e.direction.normalize(),r.normal.normalize());if(0==i)return null;let n=(-r.distance-t.Vector3.dot(e.origin,r.normal))/i;return n<0?null:(e.at(n,a),a)}}const Dt=new t.Vector3,Rt=new t.Vector3,xt=new t.Vector3,yt=new t.Vector3,Mt=new t.Vector3,Ct=new Float32Array([1,1,1,1,1,-1,1,0,-1,1,0,1,-1,-1,0,0]),vt=new Float32Array([1,1,1,0,1,-1,1,1,-1,1,0,0,-1,-1,0,1]);var It;class wt extends Ce{static __init__(){It=new t.VertexDeclaration(16,[new t.VertexElement(0,t.VertexElementFormat.Vector4,0)]),wt.instance=new wt,wt.instance.invertY=!0,wt.InvertInstance=new wt,wt.InvertInstance.invertY=!1}constructor(){super(t.MeshTopology.TriangleStrip,t.DrawType.DrawArray),this._bufferState=new t.BufferState,this._bufferStateInvertUV=new t.BufferState,this.setDrawArrayParams(0,4),this._vertexBuffer=T.renderOBJCreate.createVertexBuffer3D(64,t.BufferUsage.Static,!1),this._vertexBuffer.vertexDeclaration=It,this._vertexBuffer.setData(Ct.buffer),this._bufferState.applyState([this._vertexBuffer],null),this._vertexBufferInvertUV=T.renderOBJCreate.createVertexBuffer3D(64,t.BufferUsage.Static,!1),this._vertexBufferInvertUV.vertexDeclaration=It,this._vertexBufferInvertUV.setData(vt.buffer),this._bufferStateInvertUV.applyState([this._vertexBufferInvertUV],null),this.invertY=!1}set invertY(e){this.bufferState=e?this._bufferStateInvertUV:this._bufferState}_updateRenderParams(e){}destroy(){super.destroy(),this._bufferState.destroy(),this._vertexBuffer.destroy(),this._bufferStateInvertUV.destroy(),this._vertexBufferInvertUV.destroy()}}const Bt=new t.Vector4(0,0,1,1);class Pt extends j{static create(e,t,r=null,a=null,i=null,n=0,s=Pt.SCREENTYPE_QUAD,o=null,l=!1){let h=Pt._pool.take();return h._source=e,h._color0Only=l,h.dest=t,h.offsetScale=r||Bt,h.setshader(a,n,i),h._commandBuffer=o,h}constructor(){super(),this._source=null,this._dest=null,this._color0Only=!1,this._offsetScale=new t.Vector4,this._shader=null,this._shaderData=null,this._internalShaderData=null,this._subShader=0,this._blitQuadCMDData=T.Render3DPassFactory.createBlitQuadCMDData(),this._transform3D=T.Render3DModuleDataFactory.createTransform(null),this._renderElement=new W,this._renderElement.setTransform(this._transform3D),this._renderElement.setGeometry(wt.instance),this._blitQuadCMDData.element=this._renderElement._renderElementOBJ,this._blitQuadCMDData.element.isRender=!0}get offsetScale(){return this._offsetScale}set offsetScale(e){e.cloneTo(this._offsetScale),this._blitQuadCMDData.offsetScale=e}get dest(){return this._dest}set dest(e){this._dest=e,this._blitQuadCMDData.dest=e?e._getRenderTarget(this._color0Only):null}set shaderData(e){e?this._shaderData=e:(this._internalShaderData||(this._internalShaderData=t.LayaGL.renderDeviceFactory.createShaderData()),this._internalShaderData.clearData(),this._shaderData=this._internalShaderData),this._renderElement._renderElementOBJ.materialShaderData=this._shaderData}getRenderCMD(){return this._blitQuadCMDData}setshader(e,t,r){this._shader=e||j._screenShader,this._subShader=t||0,this.shaderData=r,this._renderElement.renderSubShader=this._shader.getSubShaderAt(this._subShader),this._renderElement._subShaderIndex=t}run(){var e,r;if(this._source)r=this._source;else{if(!this._commandBuffer._camera._internalRenderTexture)throw"camera internalRenderTexture is null,please set camera enableBuiltInRenderTexture";r=this._commandBuffer._camera._internalRenderTexture}this._blitQuadCMDData.source=r._texture;var a=this._dest?this._dest:this._commandBuffer._camera._internalRenderTexture;if(this._blitQuadCMDData.dest=a?a._getRenderTarget(this._color0Only):null,a)t.Viewport.TEMP.set(0,0,a.width,a.height),t.Vector4.TEMP.setValue(0,0,a.width,a.height),this._blitQuadCMDData.viewport=t.Viewport.TEMP,this._blitQuadCMDData.scissor=t.Vector4.TEMP;else{let e=this._commandBuffer._camera.viewport,r=e.height,a=J.clientHeight-e.y-r;t.Viewport.TEMP.set(e.x,a,e.width,r),t.Vector4.TEMP.setValue(e.x,a,e.width,r),this._blitQuadCMDData.viewport=t.Viewport.TEMP,this._blitQuadCMDData.scissor=t.Vector4.TEMP}let i=!!a;t.LayaGL.renderEngine._screenInvertY&&i&&a._isCameraTarget&&(i=!1),this._renderElement.setGeometry(i?wt.InvertInstance:wt.instance),r&&(null===(e=this._blitQuadCMDData._nativeObj)||void 0===e?void 0:e.setTexelSize)&&this._blitQuadCMDData._nativeObj.setTexelSize(1/r.width,1/r.height,r.width,r.height)}recover(){Pt._pool.recover(this),this._source=null,this._dest=null,this._color0Only=!1,Bt.cloneTo(this._offsetScale),this._shader=null,this._shaderData=null,super.recover()}destroy(){this._source=null,this.dest=null,this._offsetScale=null,this._shader=null,this._shaderData=null,this._internalShaderData&&this._internalShaderData.destroy(),this._internalShaderData=null,this._renderElement.destroy()}}Pt.SCREENTYPE_QUAD=0,Pt.SCREENTYPE_TRIANGLE=1,Pt._pool=t.Pool.createPool(Pt);class Lt extends j{static create(e,t,r,a,i){var n;return(n=Lt._pool.take())._setRenderDataCMD.dest=e,n._setRenderDataCMD.propertyID=t,n._setRenderDataCMD.dataType=a,n._setRenderDataCMD.value=r,n._commandBuffer=i,n}constructor(){super(),this._setRenderDataCMD=T.Render3DPassFactory.createSetRenderDataCMD()}getRenderCMD(){return this._setRenderDataCMD}recover(){Lt._pool.recover(this)}}Lt.ShaderDataType_define=-2,Lt._pool=t.Pool.createPool(Lt);class Ft extends j{static create(e,t,r,a){var i;return(i=Ft._pool.take())._setRenderDefineCMD.dest=e,i._setRenderDefineCMD.add=r,i._setRenderDefineCMD.define=t,i._commandBuffer=a,i}constructor(){super(),this._setRenderDefineCMD=T.Render3DPassFactory.createSetShaderDefineCMD()}getRenderCMD(){return this._setRenderDefineCMD}recover(){Ft._pool.recover(this)}}Ft._pool=t.Pool.createPool(Ft);class Nt extends j{static create(e,t,r,a,i,n){var s;return(s=Nt._pool.take())._matrix=t,s._transform.worldMatrix=s._matrix,s.material=r,s.subMeshIndex=a,s._subShaderIndex=i,s.mesh=e,s._commandBuffer=n,s}get subMeshIndex(){return this._subMeshIndex}set subMeshIndex(e){this._subMeshIndex=e,this._drawRenderCMDDData.subMeshIndex=e}constructor(){super(),this._drawRenderCMDDData=T.Render3DPassFactory.createDrawNodeCMDData(),this._transform=T.Render3DModuleDataFactory.createTransform(null),this._transform.activeInScene(),this._meshRender=new Y,this._meshRender._baseRenderNode.transform=this._transform}set material(e){this._material&&this._material._removeReference(1),this._material=e,this._material&&this._material._addReference(1)}get material(){return this._material}set mesh(e){this._mesh!=e&&(this._meshRender._onMeshChange(e),this._mesh=e,this._renderElemnts=this._meshRender._renderElements,this._renderElemnts.forEach(e=>{e.material=this._material,e.setTransform(this._transform),e.renderSubShader=this._material._shader.getSubShaderAt(this._subShaderIndex),e._subShaderIndex=this._subShaderIndex}))}getRenderCMD(){return this._drawRenderCMDDData}run(){this._meshRender.sharedMaterial=this.material,this._meshRender._baseRenderNode.transform=this._transform,this._meshRender._baseRenderNode.ismoved.setValue(t.Stat.loopCount,t.LayaGL.renderEngine._framePassCount),this._meshRender.renderUpdate(J._instance),this._meshRender.probReflection=J._instance.scene&&J._instance.scene.sceneReflectionProb,this._drawRenderCMDDData.destSubShader=this.material.shader.getSubShaderAt(this._subShaderIndex),this._drawRenderCMDDData.destShaderData=this.material.shaderData,this._drawRenderCMDDData.node=this._meshRender._baseRenderNode}recover(){Nt._pool.recover(this),super.recover(),this._material&&(this.material=null),this._meshRender.probReflection=null,this._meshRender.lightProbe=null,this._mesh&&(this.mesh=null)}destroy(){super.destroy(),this._renderElemnts.forEach(e=>{e.destroy()}),this._material&&this._material._removeReference(1),this._material=null,this._renderElemnts=null,this._transform=null,this._material=null,this._matrix=null}}Nt._pool=t.Pool.createPool(Nt);class Ot extends j{static create(e,t,r,a){var i;return(i=Ot._pool.take()).render=e,i.material=t,i.subMeshIndex=r,i._commandBuffer=a,i}get render(){return this._render}set render(e){this._drawNodeCMDData.node=e._baseRenderNode,this._render=e}get material(){return this._material}set material(e){this._material&&this._material._removeReference(1),e?(e._addReference(1),this._drawNodeCMDData.destShaderData=e.shaderData,this._drawNodeCMDData.destSubShader=e.shader.getSubShaderAt(0)):(this._drawNodeCMDData.destShaderData=null,this._drawNodeCMDData.destSubShader=null),this._material=e}get subMeshIndex(){return this._subMeshIndex}set subMeshIndex(e){this._subMeshIndex=e,this._drawNodeCMDData.subMeshIndex=e}constructor(){super(),this._drawNodeCMDData=T.Render3DPassFactory.createDrawNodeCMDData()}getRenderCMD(){return this._drawNodeCMDData}run(){this.render&&(this.render._baseRenderNode.ismoved.setValue(t.Stat.loopCount,t.LayaGL.renderEngine._framePassCount),this.render.renderUpdate(this._context),this._prematerial=this.render.sharedMaterials[this.subMeshIndex])}recover(){Ot._pool.recover(this),super.recover(),this.material=null,this.render.sharedMaterials[this.subMeshIndex]=this._prematerial,this._render=null,this.subMeshIndex=0}destroy(){super.destroy(),this.material=null}}Ot._pool=t.Pool.createPool(Ot);class bt extends j{static create(e,r,a,i){let n=J._instance,s=n._contextOBJ.globalShaderData;return s||(s=n._contextOBJ.globalShaderData=t.LayaGL.renderDeviceFactory.createShaderData(null)),Lt.create(s,e,r,a,i)}}class Vt extends Ce{constructor(e){super(e?e._geometryElementOBj.mode:t.MeshTopology.Triangles,t.DrawType.DrawElementInstance),this._subMesh=e,e&&(this.indexFormat=e._mesh.indexFormat)}set subMesh(e){this._subMesh=e,e&&(this.indexFormat=e._mesh.indexFormat),this.mode=e._geometryElementOBj.mode}get subMesh(){return this._subMesh}_updateRenderParams(e){let r;switch(this.clearRenderParams(),this.indexFormat){case t.IndexFormat.UInt32:r=4;break;case t.IndexFormat.UInt16:r=2;break;case t.IndexFormat.UInt8:r=1}this.setDrawElemenParams(this._subMesh.indexCount,this._subMesh._indexStart*r)}}class Ut extends j{static create(e,r,a,i,n,s,o,l){var h;if(a&&a.length>Ut.maxInstanceCount||o>Ut.maxInstanceCount)throw new Error("the number of renderings exceeds the maximum number of merges");return(h=Ut._pool.take())._matrixs=a,h.material=i,h._subMeshIndex=r,h._subShaderIndex=n,h._commandBuffer=l,h._instanceProperty=s,h._drawnums=o,h._instanceBufferState||(h._instanceBufferState=new t.BufferState),h.mesh=e,a&&h._updateWorldMatrixBuffer(),h._setInstanceBuffer(),h}constructor(){super(),this._subShaderIndex=0,this._transform=T.Render3DModuleDataFactory.createTransform(null),this._instanceRenderElementArray=[],this._instanceGeometryArray=[],this._instanceWorldMatrixData=new Float32Array(20*Ut.maxInstanceCount),this._instanceWorldMatrixBuffer=T.renderOBJCreate.createVertexBuffer3D(4*this._instanceWorldMatrixData.length,t.BufferUsage.Dynamic,!1),this._instanceWorldMatrixBuffer.vertexDeclaration=t.VertexMesh.instanceWorldMatrixDeclaration,this._instanceWorldMatrixBuffer.instanceBuffer=!0,this._render=new z,this._render._baseRenderNode.shaderData.addDefine(A.SHADERDEFINE_GPU_INSTANCE),this._instanceBufferState=new t.BufferState,this._drawElementCMDData=T.Render3DPassFactory.createDrawElementCMDData()}set material(e){this._material&&this._material._removeReference(1),this._material=e,this._material&&this._material._addReference(1)}get bufferState(){return this._instanceWorldMatrixBuffer}get mesh(){return this._mesh}set mesh(e){if(this._mesh==e)return;if(z.changeVertexDefine(this._mesh,e,this._render._baseRenderNode.shaderData),this._mesh&&this._mesh._removeReference(),e&&e._addReference(),this._mesh=e,!this._mesh)return;let t=this._mesh._subMeshes;if(-1==this._subMeshIndex)for(let e=0,r=t.length;e<r;e++){let r=this._instanceRenderElementArray[e]=this._instanceRenderElementArray[e]?this._instanceRenderElementArray[e]:new W,a=this._instanceGeometryArray[e];a?a.subMesh=t[e]:a=this._instanceGeometryArray[e]=new Vt(t[e]),a.bufferState=this._instanceBufferState,a.instanceCount=this._drawnums,r.setGeometry(a),r.transform=this._transform,r.material=this._material,r._subShaderIndex=this._subShaderIndex,r.render=this._render,r._renderElementOBJ.owner=this._render._baseRenderNode}else{let e=this._instanceRenderElementArray[0]=this._instanceRenderElementArray[0]?this._instanceRenderElementArray[0]:new W,r=this._instanceGeometryArray[0];r?r.subMesh=t[this._subMeshIndex]:r=this._instanceGeometryArray[0]=new Vt(t[this._subMeshIndex]),r.bufferState=this._instanceBufferState,r.instanceCount=this._drawnums,e.setGeometry(r),e.transform=this._transform,e.material=this._material,e.render=this._render,e._renderElementOBJ.owner=this._render._baseRenderNode}}_setInstanceBuffer(){let e=this._instanceBufferState,t=[];this._mesh._bufferState._vertexBuffers.forEach(e=>{t.push(e)}),t.push(this._instanceWorldMatrixBuffer);let r=this._instanceProperty._propertyMap;for(let e in r)t.push(r[e]._vertexBuffer);e.applyState(t,this._mesh._indexBuffer),this._instanceGeometryArray.forEach(t=>{t.bufferState=e})}_updateWorldMatrixBuffer(){let e=this._instanceWorldMatrixData,t=this._drawnums;for(let r=0;r<t;r++)e.set(this._matrixs[r].elements,20*r);this._instanceWorldMatrixBuffer.setData(e.buffer,0,0,80*t)}setWorldMatrix(e){if(e.length<this._drawnums)throw"worldMatrixArray length is less then drawnums";this._matrixs=e,this._matrixs&&this._updateWorldMatrixBuffer()}setDrawNums(e){if(this._matrixs&&this._matrixs.length<e)throw"worldMatrixArray length is less then drawnums";this._drawnums=e;let t=this._mesh._subMeshes;if(-1==this._subMeshIndex)for(let e=0,r=t.length;e<r;e++){(this._instanceGeometryArray[e]?this._instanceGeometryArray[e]:new Vt(t[e])).instanceCount=this._drawnums}else{(this._instanceGeometryArray[0]?this._instanceGeometryArray[0]:new Vt(t[0])).instanceCount=this._drawnums}this._matrixs&&this._updateWorldMatrixBuffer()}getRenderCMD(){return this._drawElementCMDData}renderUpdateElement(e,t){let r=e._renderElementOBJ;return r.owner.probeReflection=t.scene.sceneReflectionProb._dataModule,r.owner.additionShaderData.set(G.BlockName,t.scene.sceneReflectionProb.shaderData),r.owner.additionShaderData=r.owner.additionShaderData,r.owner._applyReflection(),r.isRender=e._geometry._prepareRender(t),e._geometry._updateRenderParams(t),r}run(){let e=J._instance;e._contextOBJ.cameraUpdateMask=tr._updateMark;let t=this._instanceProperty._propertyMap;for(let e in t)t[e].updateVertexBufferData(this._drawnums);let r=this.mesh._subMeshes;if(-1==this._subMeshIndex){let t=[];for(let a=0,i=r.length;a<i;a++){let r=this._instanceRenderElementArray[a],i=this.renderUpdateElement(r,e);t.push(i)}this._drawElementCMDData.setRenderelements(t)}else{let t=this._instanceRenderElementArray[this._subMeshIndex],r=this.renderUpdateElement(t,e);this._drawElementCMDData.setRenderelements([r])}}recover(){Ut._pool.recover(this),super.recover(),this._material&&this._material._removeReference(),this._material=null,this._instanceBufferState.destroy(),this._instanceBufferState=null,this._drawElementCMDData.setRenderelements([]),this.mesh=null}destroy(){super.destroy(),this._material&&this._material._removeReference(1),this._material=null,this._instanceBufferState.destroy(),this._instanceBufferState=null;for(let e=0,t=this._instanceRenderElementArray.length;e<t;e++){let t=this._instanceRenderElementArray[e];t&&(t._renderElementOBJ.destroy(),t.destroy())}this._instanceRenderElementArray.length=0;for(let e=0,t=this._instanceGeometryArray.length;e<t;e++){let t=this._instanceGeometryArray[e];t&&t.destroy()}this._instanceGeometryArray.length=0,this.mesh=null}}Ut._pool=t.Pool.createPool(Ut),Ut.maxInstanceCount=1024;class Ht extends j{static create(e,r,a,i,n,s=1,o=0,l){var h,d;if(!e||e.destroyed)throw new Error("SetRenderTarget requires a live RenderTexture.");let c=n,u=null;if(r&&Array.isArray(n)){const a=null!==(h=e.colorAttachmentCount)&&void 0!==h?h:1;if(n.length!==a)throw new RangeError("Clear color count must match the render target color attachment count.");for(let e=0;e<a;e++)if(null!=n[e]&&!(n[e]instanceof t.Color))throw new TypeError("Clear colors must contain a Color or null for every slot.");c=null!==(d=n[0])&&void 0!==d?d:t.Color.BLACK,a>1?u=n:null==n[0]&&(r=!1)}let _=Ht._pool.take();_._setRenderTargetCMD.clearColorValues=null,r&&(_._setRenderTargetCMD.clearColorValue=c,_._setRenderTargetCMD.clearColorValues=u),_.renderTexture=e,_._commandBuffer=l;let f=0;return r&&(f|=t.RenderClearFlag.Color),a&&(f|=t.RenderClearFlag.Depth,_._setRenderTargetCMD.clearDepthValue=s),i&&(f|=t.RenderClearFlag.Stencil,_._setRenderTargetCMD.clearStencilValue=o),_._setRenderTargetCMD.clearFlag=f,_}get renderTexture(){return this._renderTexture}set renderTexture(e){var t;if(e===this._renderTexture)return;if(e&&e.destroyed)throw new Error("Cannot record a destroyed render target.");const r=this._setRenderTargetCMD.clearColorValues;if(e&&r&&r.length!==(null!==(t=e.colorAttachmentCount)&&void 0!==t?t:1))throw new RangeError("Clear color count must match the render target color attachment count.");const a=this._renderTexture;this._setRenderTargetCMD.rt=e?e._renderTarget:null,e&&e._addReference(),this._renderTexture=e,a&&a._removeReference()}constructor(){super(),this._renderTexture=null,this._setRenderTargetCMD=T.Render3DPassFactory.createSetRenderTargetCMD()}getRenderCMD(){return this._setRenderTargetCMD}run(){if(!this._renderTexture||this._renderTexture.destroyed)throw new Error("Cannot execute a command with a destroyed render target.")}recover(){this.renderTexture=null,this._setRenderTargetCMD.clearColorValues=null,super.recover(),Ht._pool.recover(this)}destroy(){this.renderTexture=null,this._setRenderTargetCMD.clearColorValues=null,super.destroy()}}Ht._pool=t.Pool.createPool(Ht);class Gt extends j{static create(e){var t;return(t=Gt._pool.take()).renderElement=e,t}get renderElement(){return this._renderElement}set renderElement(e){this._renderElement=e,this._drawElementCMDData.setRenderelements([this._renderElement._renderElementOBJ])}constructor(){super(),this._drawElementCMDData=T.Render3DPassFactory.createDrawElementCMDData()}recover(){super.recover(),Gt._pool.recover(this)}getRenderCMD(){return this._drawElementCMDData}destroy(){this._renderElement=null,this._drawElementCMDData=null}}Gt._pool=t.Pool.createPool(Gt);class kt extends j{static create(e){if(!t.LayaGL.renderEngine.getCapable(t.RenderCapable.ComputeShader))throw"device cant surpport computeBuffer function";var r;return(r=kt._pool.take()).computeBuffer=e,r}constructor(){super(),this._computeCMD=T.Render3DPassFactory.createComputeCommandAppatchCMD()}set computeBuffer(e){this._computeCMD.computeContext=e.getResource(),this._computeBuffer=e}getRenderCMD(){return this._computeCMD}recover(){kt._pool.recover(this),super.recover(),this._computeCMD.computeContext=null}}kt._pool=t.Pool.createPool(kt);class zt{constructor(e=null,t=!1){this._shadow=!1,this._camera=null,this._commands=[],this._renderCMDs=[],this._name=e,this._shadow=t}get name(){return this._name}get casterShadow(){return this._shadow}get context(){return this._context}set context(e){this._context=e}_apply(e=!1){for(var t=0,r=this._commands.length;t<r;t++){let e=this._commands[t];e.run&&e.run()}e&&this.context._contextOBJ.runCMDList(this._renderCMDs)}_applyOne(){if(this._commands.length){var e=this._commands.shift();e.run&&e.run(),e.getRenderCMD&&this.context._contextOBJ.runOneCMD(this._renderCMDs.shift()),e.recover()}return this._commands.length>0}getCommandsSize(){return this._commands.length}setShaderDataTexture(e,r,a){let i=Lt.create(e,r,a,t.ShaderDataType.Texture2D,this);this._commands.push(i),i.getRenderCMD&&this._renderCMDs.push(i.getRenderCMD())}setGlobalTexture(e,r){let a=bt.create(e,r,t.ShaderDataType.Texture2D,this);this._commands.push(a),a.getRenderCMD&&this._renderCMDs.push(a.getRenderCMD())}setShaderDataColor(e,r,a){let i=Lt.create(e,r,a,t.ShaderDataType.Color,this);this._commands.push(i),i.getRenderCMD&&this._renderCMDs.push(i.getRenderCMD())}setGlobalColor(e,r){let a=bt.create(e,r,t.ShaderDataType.Color,this);this._commands.push(a),a.getRenderCMD&&this._renderCMDs.push(a.getRenderCMD())}setShaderDataVector(e,r,a){let i=Lt.create(e,r,a,t.ShaderDataType.Vector4,this);this._commands.push(i),i.getRenderCMD&&this._renderCMDs.push(i.getRenderCMD())}setGlobalVector(e,r){let a=bt.create(e,r,t.ShaderDataType.Vector4,this);this._commands.push(a),a.getRenderCMD&&this._renderCMDs.push(a.getRenderCMD())}setShaderDataVector3(e,r,a){let i=Lt.create(e,r,a,t.ShaderDataType.Vector3,this);this._commands.push(i),i.getRenderCMD&&this._renderCMDs.push(i.getRenderCMD())}setGlobalVector3(e,r){let a=bt.create(e,r,t.ShaderDataType.Vector3,this);this._commands.push(a),a.getRenderCMD&&this._renderCMDs.push(a.getRenderCMD())}setShaderDataVector2(e,r,a){let i=Lt.create(e,r,a,t.ShaderDataType.Vector2,this);this._commands.push(i),i.getRenderCMD&&this._renderCMDs.push(i.getRenderCMD())}setGlobalVector2(e,r){let a=bt.create(e,r,t.ShaderDataType.Vector2,this);this._commands.push(a),a.getRenderCMD&&this._renderCMDs.push(a.getRenderCMD())}setShaderDataNumber(e,r,a){let i=Lt.create(e,r,a,t.ShaderDataType.Float,this);this._commands.push(i),i.getRenderCMD&&this._renderCMDs.push(i.getRenderCMD())}setGlobalNumber(e,r){let a=bt.create(e,r,t.ShaderDataType.Float,this);this._commands.push(a),a.getRenderCMD&&this._renderCMDs.push(a.getRenderCMD())}setShaderDataInt(e,r,a){let i=Lt.create(e,r,a,t.ShaderDataType.Int,this);this._commands.push(i),i.getRenderCMD&&this._renderCMDs.push(i.getRenderCMD())}setGlobalInt(e,r){let a=bt.create(e,r,t.ShaderDataType.Int,this);this._commands.push(a),a.getRenderCMD&&this._renderCMDs.push(a.getRenderCMD())}setShaderDataMatrix(e,r,a){let i=Lt.create(e,r,a,t.ShaderDataType.Matrix4x4,this);this._commands.push(i),i.getRenderCMD&&this._renderCMDs.push(i.getRenderCMD())}setShaderDefine(e,t,r){let a=Ft.create(e,t,r,this);this._commands.push(a),a.getRenderCMD&&this._renderCMDs.push(a.getRenderCMD())}setGlobalMatrix(e,r){let a=bt.create(e,r,t.ShaderDataType.Matrix4x4,this);this._commands.push(a),a.getRenderCMD&&this._renderCMDs.push(a.getRenderCMD())}blitScreenQuad(e,t,r=null,a=null,i=null,n=0,s=null==t){let o=Pt.create(e,t,r,a,i,n,Pt.SCREENTYPE_QUAD,this,s);this._commands.push(o),o.getRenderCMD&&this._renderCMDs.push(o.getRenderCMD())}blitScreenQuadByMaterial(e,t,r=null,a=null,i=0,n=null==t){var s,o;a&&(s=a._shader,o=a.shaderData);let l=Pt.create(e,t,r,s,o,i,Pt.SCREENTYPE_QUAD,this,n);this._commands.push(l),l.getRenderCMD&&this._renderCMDs.push(l.getRenderCMD())}blitScreenTriangle(e,t,r=null,a=null,i=null,n=0,s=null==t){let o=Pt.create(e,t,r,a,i,n,Pt.SCREENTYPE_TRIANGLE,this,s);this._commands.push(o),o.getRenderCMD&&this._renderCMDs.push(o.getRenderCMD())}appatchComputeCommand(e){let t=kt.create(e);this._commands.push(t),t.getRenderCMD&&this._renderCMDs.push(t.getRenderCMD())}setRenderTarget(e,r,a,i=t.Color.BLACK,n=1){let s=Ht.create(e,r,a,!1,i,n,0,this);this._commands.push(s),s.getRenderCMD&&this._renderCMDs.push(s.getRenderCMD())}drawMesh(e,t,r,a,i){let n=Nt.create(e,t,r,a,i,this);this._commands.push(n),n.getRenderCMD&&this._renderCMDs.push(n.getRenderCMD())}drawRender(e,t,r=0){let a=Ot.create(e,t,r,this);this._commands.push(a),a.getRenderCMD&&this._renderCMDs.push(a.getRenderCMD())}drawRenderElement(e){let t=Gt.create(e);this._commands.push(t),t.getRenderCMD&&this._renderCMDs.push(t.getRenderCMD())}drawMeshInstance(e,r=0,a,i,n=0,s,o){if(!t.LayaGL.renderEngine.getCapable(t.RenderCapable.DrawElement_Instance))return null;var l=Ut.create(e,r,a,i,n,s,o,this);return this._commands.push(l),l.getRenderCMD&&this._renderCMDs.push(l.getRenderCMD()),l}addCustomCMD(e){e._commandBuffer=this,this._commands.push(e),e.getRenderCMD&&this._renderCMDs.push(e.getRenderCMD())}clear(){for(var e=0,t=this._commands.length;e<t;e++)this._commands[e].recover();this._commands.length=0,this._renderCMDs.length=0}}class Wt{constructor(){this.source=null,this.indirectTarget=null,this.destination=null,this.camera=null,this.compositeShaderData=null,this.command=null,this.deferredReleaseTextures=[]}createRTByContextReleaseTexture(e,t,r,a,i=!1,n=1,s=!1,o=!1){let l=this.deferredReleaseTextures.length;for(let h=0;h<l;h++){let d=this.deferredReleaseTextures[h];if(d.width==e&&d.height==t&&d.colorFormat==r&&d.depthStencilFormat==a&&d._generateMipmap==i&&d.multiSamples==n&&d.generateDepthTexture==s&&d._gammaSpace==o){d._inPool=!1;let e=this.deferredReleaseTextures[l-1];return this.deferredReleaseTextures[h]=e,this.deferredReleaseTextures.length-=1,d}}return null}}class Qt{static __init__(){Qt.SHADERDEFINE_BLOOM_LOW=t.Shader3D.getDefineByName("BLOOM_LOW"),Qt.SHADERDEFINE_BLOOM=t.Shader3D.getDefineByName("BLOOM"),Qt.SHADERDEFINE_FINALPASS=t.Shader3D.getDefineByName("FINALPASS"),Qt.SHADERVALUE_MAINTEX=t.Shader3D.propertyNameToID("u_MainTex"),Qt.SHADERVALUE_BLOOMTEX=t.Shader3D.propertyNameToID("u_BloomTex"),Qt.SHADERVALUE_AUTOEXPOSURETEX=t.Shader3D.propertyNameToID("u_AutoExposureTex"),Qt.SHADERVALUE_BLOOM_DIRTTEX=t.Shader3D.propertyNameToID("u_Bloom_DirtTex"),Qt.SHADERVALUE_BLOOMTEX_TEXELSIZE=t.Shader3D.propertyNameToID("u_BloomTex_TexelSize"),Qt.SHADERVALUE_BLOOM_DIRTTILEOFFSET=t.Shader3D.propertyNameToID("u_Bloom_DirtTileOffset"),Qt.SHADERVALUE_BLOOM_SETTINGS=t.Shader3D.propertyNameToID("u_Bloom_Settings"),Qt.SHADERVALUE_BLOOM_COLOR=t.Shader3D.propertyNameToID("u_Bloom_Color")}get temporalEffect(){return this._temporalEffect}recaculateCameraFlag(){this._depthtextureFlag=t.DepthTextureMode.None;let e=this.effects.length;for(let t=0;t<e;t++)this._depthtextureFlag|=this.effects[t].getCameraDepthTextureModeFlag()}_rebuildTAAEffectOrder(){const e=this._effects,r=this._taaEffects;r.length=0;const a=this._temporalEffect=this.getEffect(t.TemporalAAEffect);if(a){for(const t of e)t!==a&&t.renderBeforeTAA&&r.push(t);r.push(a);for(const t of e)t===a||t.renderBeforeTAA||r.push(t)}}constructor(){this._effects=[],this._taaEffects=[],this._temporalEffect=null,this._enable=!0,this._enableColorGrad=!1,this._context=new Wt,this._context.compositeShaderData=this._compositeShaderData=t.LayaGL.renderDeviceFactory.createShaderData(null),this._context.command=new zt,this._depthtextureFlag=0}get enable(){return this._enable}set enable(e){this._enable=e}set commandContext(e){this._context.command._context=e}get effects(){return this._effects}set effects(e){this.clearEffect();for(var t=0,r=e.length;t<r;t++)e[t]&&this.addEffect(e[t])}get cameraDepthTextureMode(){return this._depthtextureFlag}_collectCameraMRTRequirements(e){if(!e||!this._enable)return null;let t=null;for(const e of this._effects){if(!e.active)continue;const r=e.getCameraOpaqueMRTRequirements();if(null!=r){if(!Array.isArray(r))throw new TypeError("Post-process MRT requirements must be an array or null.");r.length&&(t=t||[],t.push(...r))}}return t}_init(e){this._context.camera=e,this._context.command._camera=e}_render(e){this._init(e);let r=this._context;var a=(e=r.camera).viewport,i=e._needInternalRenderTexture(),n=i?e._internalRenderTexture:t.RenderTexture.createFromPool(e._offScreenRenderTexture.width,e._offScreenRenderTexture.height,e._getRenderTextureFormat(),t.RenderTargetFormat.None,!1,1,!1,!0),s=t.RenderTexture.createFromPool(n.width,n.height,e._getRenderTextureFormat(),t.RenderTargetFormat.None,!1,1,!1,!0),o=[t.RenderTexture.createFromPool(n.width,n.height,e._getRenderTextureFormat(),t.RenderTargetFormat.None,!1,1,!1,!0),t.RenderTexture.createFromPool(n.width,n.height,e._getRenderTextureFormat(),t.RenderTargetFormat.None,!1,1,!1,!0)];r.command.clear(),r.source=s,r.indirectTarget=s,r.destination=o[0],r.compositeShaderData.clearDefine(),i?r.command.blitScreenTriangle(e._internalRenderTexture,s):r.command.blitScreenTriangle(e._offScreenRenderTexture,s),r.compositeShaderData.setTexture(Qt.SHADERVALUE_AUTOEXPOSURETEX,t.Texture2D.whiteTexture),this._enableColorGrad&&this._ColorGradEffect._buildLUT();let l=0;const h=e._taa,d=null==h?void 0:h.effect,c=d?this._taaEffects:this._effects;let u=!1;for(let t=0,a=c.length;t<a;t++){const a=c[t];a===this._temporalEffect&&a!==d||(a!==d||(null==h?void 0:h.preparedHistory)&&e.depthTexture&&!e.depthTexture.destroyed)&&a.active&&e._hasOpaqueMRTRequirements(a.getCameraOpaqueMRTRequirements())&&(a.render(r),a===d&&(u=!0),r.indirectTarget=r.destination,l++,r.destination=o[l%2])}if(u&&(null==h?void 0:h.preparedHistory)&&h.sharpening>0&&(d._renderSharpen(r),r.indirectTarget=r.destination,r.destination=o[++l%2]),r.indirectTarget!==n&&r.command.blitScreenTriangle(r.indirectTarget,n,null,null,null,0,!0),this._compositeShaderData.addDefine(Qt.SHADERDEFINE_FINALPASS),e._offScreenRenderTexture&&i){r.destination=e._offScreenRenderTexture;var _=e._getCanvasWidth(),f=e._getCanvasHeight();t.LayaGL.renderEngine._screenInvertY?e._screenOffsetScale.setValue(a.x/_,a.y/f,a.width/_,a.height/f):e._screenOffsetScale.setValue(a.x/_,1-a.y/f,a.width/_,-a.height/f),r.command.blitScreenTriangle(n,e._offScreenRenderTexture,e._screenOffsetScale,null,this._compositeShaderData,0)}i||t.RenderTexture.recoverToPool(n),t.RenderTexture.recoverToPool(s),t.RenderTexture.recoverToPool(o[0]),t.RenderTexture.recoverToPool(o[1]);var m=r.deferredReleaseTextures;for(let e=0,r=m.length;e<r;e++)t.RenderTexture.recoverToPool(m[e]);m.length=0}addEffect(e){return e.singleton&&this.getEffect(e.constructor)?(console.error("the target effect is a singleton",e),null):(!this._enableColorGrad||e instanceof t.ColorGradEffect?this._effects.push(e):this._effects.splice(this._effects.length-1,0,e),this._rebuildTAAEffectOrder(),this.recaculateCameraFlag(),e.effectInit(this),e)}getEffect(e){return this._effects.find(t=>t instanceof e)||null}removeEffect(e){var t=this._effects.indexOf(e);-1!==t&&(this._effects.splice(t,1),e.release(this),this._rebuildTAAEffectOrder(),this.recaculateCameraFlag())}clearEffect(){let e=this.effects.length-1;for(;e>=0;e--)this.removeEffect(this.effects[e]);this._effects.length=0}_applyPostProcessCommandBuffers(){this._context.command._apply()}}const Yt=e.GBufferLocation.MotionVectors,Xt=Yt-1,Kt=t.RenderTargetFormat.R16G16B16A16,jt=Object.freeze({index:Xt,name:e.GBufferAttachment.MotionVectors,format:Kt,clearColor:Object.freeze(new t.Color(0,0,0,0))}),Jt=Object.freeze([jt]);class qt{constructor(e){this._camera=e,this.effect=null,this.frameIndex=-1,this.newFrame=!0,this.jitter=new t.Vector2,this.viewProjection=new t.Matrix4x4,this.previousViewProjection=new t.Matrix4x4,this.invViewProjection=new t.Matrix4x4,this.renderProjection=new t.Matrix4x4,this.renderViewProjection=new t.Matrix4x4,this._gpuProjection=new t.Matrix4x4,this._lastViewProjection=new t.Matrix4x4,this._committedFrame=-1,this._descriptor={width:-1,height:-1,format:t.RenderTargetFormat.None,invertY:!1,viewportX:0,viewportY:0,outputId:-1,scene:null},this._motionOutputDefined=!1,this._warning="",this._motionParams=new t.Vector4(1,0,0,0),this._budgetFormats=[],this._enabled=!1,this._quality=t.TemporalAAQuality.High,this._sharpening=0,this._history=null,this._prepared=!1,this._registeredPostProcess=null,this._registeredEffect=null}get active(){return!!this.effect}get preparedHistory(){return this._prepared?this._history:null}get history(){return this._history}get enabled(){return this._enabled}set enabled(e){e=!!e,this._enabled!==e&&(e?(this._camera.msaa=!1,this._camera.postProcess||(this._camera.postProcess=new Qt)):this._unregisterEffect(),this.resetHistory(),this._enabled=e,e?this._bindPostProcess():this._prepared||(this.effect=null,this.jitter.setValue(0,0),this._setDefines(!1),this._releaseHistory()))}get quality(){return this._quality}set quality(e){const r=Number.isFinite(e)?Math.min(t.TemporalAAQuality.VeryHigh,Math.max(t.TemporalAAQuality.VeryLow,0|e)):t.TemporalAAQuality.High;this._quality!==r&&(this._quality=r,this.resetHistory())}get sharpening(){return this._sharpening}set sharpening(e){this._sharpening=Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}cloneTo(e){e.quality=this.quality,e.sharpening=this.sharpening,e.enabled=this.enabled}resetHistory(){this._history&&(this._history.valid=!1,this._history.pendingCopy=!1),this._committedFrame=-1}_getOrCreateEffect(){const e=this._camera.postProcess;let r=e.temporalEffect,a=qt._registrations.get(e);return r?a?a.effect!==r&&(a.effect=r,a.created=!1):(a={effect:r,owners:new Set,created:!1},qt._registrations.set(e,a)):(r=new t.TemporalAAEffect,e.addEffect(r),a?(a.effect=r,a.created=!0):a={effect:r,owners:new Set,created:!0},qt._registrations.set(e,a)),a.owners.add(this),this._registeredPostProcess=e,r}_bindPostProcess(){this._camera.postProcess.enable=!0;const e=this._getOrCreateEffect();e.active=!0,this._registeredEffect=e}onPostProcessChanged(){const e=this._prepared;this.resetHistory(),this._prepared=!1,this._unregisterEffect(),this._bindPostProcess(),e||(this.effect=null,this.jitter.setValue(0,0),this._setDefines(!1))}_unregisterEffect(){this._registeredEffect=null;const e=this._registeredPostProcess;if(this._registeredPostProcess=null,!e)return;const t=qt._registrations.get(e);t&&(t.owners.delete(this),t.owners.size||(t.created&&e.temporalEffect===t.effect&&e.removeEffect(t.effect),qt._registrations.delete(e)))}collectRequirements(e,r){var a;this._prepared&&(this._finishHistory(!1),this.resetHistory()),this.effect=null,this.jitter.setValue(0,0);const i=this._camera,n=i.postProcess;if(!(this._enabled&&t.Stat.enablePostprocess&&(null==n?void 0:n.enable)&&(null===(a=this._registeredEffect)||void 0===a?void 0:a.active)&&n.temporalEffect===this._registeredEffect))return this._setDefines(!1),this._releaseHistory(),this._committedFrame=-1,e;let s="";if(i.msaa?s="MSAA must be disabled":this._clearsColorAndDepth()||(s="TAA requires a camera that clears its own color and depth"),s||t.LayaGL.renderEngine.getCapable(t.RenderCapable.MRT)&&t.LayaGL.renderEngine.getCapable(t.RenderCapable.RenderTextureFormat_R16G16B16A16)||(s="MRT and half-float render targets are required"),s||t.LayaGL.renderEngine.getCapable(t.RenderCapable.RenderTextureFormat_Depth)&&i.depthTextureFormat!==t.RenderTargetFormat.None&&i.depthTextureFormat!==t.RenderTargetFormat.STENCIL_8||(s="a sampleable camera depth texture is required"),!s){const e=i._getRenderTextureFormat(),r=e===t.RenderTargetFormat.R16G16B16||e===t.RenderTargetFormat.R16G16B16A16,a=e===t.RenderTargetFormat.R32G32B32||e===t.RenderTargetFormat.R32G32B32A32;(r&&!t.LayaGL.renderEngine.getCapable(t.RenderCapable.Texture_HalfFloatLinearFiltering)||a&&!t.LayaGL.renderEngine.getCapable(t.RenderCapable.Texture_FloatLinearFiltering))&&(s="the camera color format requires linear texture filtering")}return!s&&t.LayaGL.renderEngine.getParams(t.RenderParams.Max_Color_Attachment_Count)<=Yt&&(s="motion vectors at location 4 require five color attachments"),s||this._fitsMotionBudget(e,r)||(s="the motion attachment exceeds the device color-attachment byte budget"),s?(this._warn(s),this._setDefines(!1),this._releaseHistory(),this._committedFrame=-1,e):(this.effect=this._registeredEffect,(null==e?void 0:e.length)?[...e,jt]:Jt)}setupFrame(e){if(this.prepare(e),!this.active)return!1;const r=this._camera,a=r.viewMatrix;let i=this.renderProjection;if(e.invertY){i.cloneTo(this._gpuProjection);const e=this._gpuProjection.elements;for(let t=0;t<4;t++)e[4*t+1]*=-1;i=this._gpuProjection}t.Matrix4x4.multiply(i,a,this.renderViewProjection),this.renderViewProjection.invert(this.invViewProjection);const n=r.projectionViewMatrix;return r._shaderValues.setMatrix4x4(Ne.VIEWMATRIX,a),r._shaderValues.setMatrix4x4(Ne.PROJECTMATRIX,i),r._shaderValues.setMatrix4x4(Ne.VIEWPROJECTMATRIX,this.renderViewProjection),e.viewMatrix=a,e.projectionMatrix=r.projectionMatrix,e.projectionViewMatrix=n,!0}prepare(e){var r,a;if(!this.effect)return;const i=this._camera,n=i._internalRenderTexture,s=i.projectionMatrix;this.frameIndex=t.Stat.loopCount,this.newFrame=this._committedFrame!==this.frameIndex;const o=this._descriptor,l=null!==(a=null===(r=i._offScreenRenderTexture)||void 0===r?void 0:r.id)&&void 0!==a?a:-1;(o.width!==n.width||o.height!==n.height||o.format!==n.colorFormat||o.invertY!==e.invertY||o.viewportX!==i.viewport.x||o.viewportY!==i.viewport.y||o.outputId!==l||o.scene!==e.scene||this._committedFrame<0||this.frameIndex>this._committedFrame+1)&&(this.resetHistory(),this.newFrame=!0),o.width=n.width,o.height=n.height,o.format=n.colorFormat,o.invertY=e.invertY,o.viewportX=i.viewport.x,o.viewportY=i.viewport.y,o.outputId=l,o.scene=e.scene,this._prepareHistory(this.frameIndex),this._warning="";const h=1+(1023&this.frameIndex);if(this.jitter.setValue(qt._halton(h,2)-.5,qt._halton(h,3)-.5),this.jitterProjection(s,this.renderProjection,e.invertY),s.cloneTo(this._gpuProjection),e.invertY){const e=this._gpuProjection.elements;for(let t=0;t<4;t++)e[4*t+1]*=-1}t.Matrix4x4.multiply(this._gpuProjection,i.viewMatrix,this.viewProjection),this.newFrame&&(this._committedFrame<0?this.viewProjection.cloneTo(this.previousViewProjection):this._lastViewProjection.cloneTo(this.previousViewProjection)),this._motionParams.setValue(t.LayaGL.renderEngine._screenInvertY?-1:1,0,0,0),i._shaderValues.setMatrix4x4(Ne.TAAVIEWPROJECTION,this.viewProjection),i._shaderValues.setMatrix4x4(Ne.TAAPREVIOUSVIEWPROJECTION,this.previousViewProjection),i._shaderValues.setVector(Ne.TAAMOTIONPARAMS,this._motionParams),this._setDefines(!0)}jitterProjection(e,r,a){if(!this.active)return e;e.cloneTo(r);const i=this._camera._internalRenderTexture,n=2*this.jitter.x/i.width,s=2*this.jitter.y/i.height*(t.LayaGL.renderEngine._screenInvertY?-1:1)*(a?-1:1),o=r.elements;for(let e=0;e<4;e++)o[4*e]+=n*o[4*e+3],o[4*e+1]+=s*o[4*e+3];return r}beforeRender(r){var a;const i=this._camera;!this.effect||this._enabled&&t.Stat.enablePostprocess&&(null===(a=i.postProcess)||void 0===a?void 0:a.enable)&&this.effect.active&&i.postProcess.temporalEffect===this.effect&&this._prepared&&!i.msaa&&this._clearsColorAndDepth()||(this._releaseHistory(),this.effect=null,this._committedFrame=-1,this.jitter.setValue(0,0),this._setDefines(!1),i._applyViewProject(i.viewMatrix,i.projectionMatrix,r.invertY),i._contextApply(r),i.clearFlag===e.CameraClearFlags.Sky&&i.skyRenderElement.renderpre(r))}afterRender(e){let t=!1;this.effect&&(t=this._finishHistory(e),t?(this.viewProjection.cloneTo(this._lastViewProjection),this._committedFrame=this.frameIndex):e||(this._committedFrame=-1))}_prepareHistory(e){this._prepared=!1;const t=this._camera,r=t._internalRenderTexture;if(!r||r.destroyed||1!==r.multiSamples||r.width<1||r.height<1||!t.getOpaqueAuxiliaryTexture(Xt))throw this.resetHistory(),new Error("Camera TAA target is missing its single-sampled motion attachment.");const a=r.colorFormat;let i=this._history;i&&(i.texture.destroyed||i.texture.width!==r.width||i.texture.height!==r.height||i.texture.colorFormat!==a||i.sourceGamma!==r._gammaSpace)&&(this._releaseHistory(),i=null),i||(this._history=i=this._createHistory(r,e)),i.frameIndex!==e&&i.frameIndex!==e-1&&(i.valid=!1),i.preparedFrameIndex=e,i.pendingCopy=!1,this._prepared=!0}_createHistory(e,r){let a=null,i=null,n=null,s=null;try{return a=new t.RenderTexture(e.width,e.height,e.colorFormat,t.RenderTargetFormat.None,!1,1,!1,!1),a.name="TemporalAAHistory",a.lock=!0,a.filterMode=t.FilterMode.Bilinear,a.wrapModeU=a.wrapModeV=t.WrapMode.Clamp,a.anisoLevel=1,i=t.LayaGL.renderDeviceFactory.createShaderData(null),n=t.LayaGL.renderDeviceFactory.createShaderData(null),s=t.LayaGL.renderDeviceFactory.createShaderData(null),{texture:a,valid:!1,frameIndex:-1,preparedFrameIndex:r,pendingCopy:!1,sourceGamma:e._gammaSpace,resolveData:i,copyData:n,sharpenData:s}}catch(e){throw null==s||s.destroy(),null==n||n.destroy(),null==i||i.destroy(),null==a||a.destroy(),e}}_finishHistory(e){const t=this.preparedHistory;let r=!1;return t&&(e&&t.pendingCopy?(t.frameIndex=t.preparedFrameIndex,t.valid=!0,r=!0):e||(t.valid=!1),t.pendingCopy=!1),this._prepared=!1,r}_releaseHistory(){const e=this._history;this._history=null,this._prepared=!1,e&&(e.texture.destroy(),e.resolveData.destroy(),e.copyData.destroy(),e.sharpenData.destroy())}release(){const e=this._prepared;this._releaseHistory(),this._unregisterEffect(),this._committedFrame=-1,e||(this.effect=null,this.jitter.setValue(0,0),this._setDefines(!1))}destroy(){this.release(),this.effect=null}_clearsColorAndDepth(){return this._camera.clearFlag===e.CameraClearFlags.SolidColor||this._camera.clearFlag===e.CameraClearFlags.Sky}_fitsMotionBudget(e,r){var a,i;const n=t.LayaGL.renderEngine.getParams(t.RenderParams.Max_Color_Attachment_Bytes_Per_Sample);if(!n)return!0;const s=this._budgetFormats;s.length=1,s[0]=this._camera._getRenderTextureFormat();const o=null==r?void 0:r.auxiliaryAttachments;if(o)for(let e=0;e<o.length;e++)s[e+1]=null!==(i=null===(a=o[e])||void 0===a?void 0:a.format)&&void 0!==i?i:null;const l=t.LayaGL.renderEngine.getParams(t.RenderParams.Max_Color_Attachment_Count);if(e)for(const t of e)t&&Number.isInteger(t.index)&&t.index>=0&&t.index+2<=l&&(s[t.index+1]=t.format);return s[Yt]=Kt,qt._fitsColorAttachmentBudget(s,n)}static _fitsColorAttachmentBudget(e,r){let a=0;for(const r of e){if(null==r)continue;let e,i;switch(r){case t.RenderTargetFormat.R16:e=2,i=2;break;case t.RenderTargetFormat.R16G16:e=4,i=2;break;case t.RenderTargetFormat.R8G8B8:case t.RenderTargetFormat.R8G8B8A8:e=8,i=1;break;case t.RenderTargetFormat.R16G16B16:case t.RenderTargetFormat.R16G16B16A16:e=8,i=2;break;case t.RenderTargetFormat.R32G32B32:case t.RenderTargetFormat.R32G32B32A32:e=16,i=4;break;default:return!0}a=Math.ceil(a/i)*i+e}return a<=r}_warn(e){this._warning!==e&&console.warn(`Camera: TAA disabled: ${e}.`),this._warning=e}_setDefines(e){if(e===this._motionOutputDefined)return;const r=this._camera._shaderValues;e?r.addDefine(t.Shader3D.getDefineByName("MOTION_VECTOR_OUTPUT")):r.removeDefine(t.Shader3D.getDefineByName("MOTION_VECTOR_OUTPUT")),this._motionOutputDefined=e}static _halton(e,t){let r=0,a=1;for(;e>0;)a/=t,r+=a*(e%t),e=Math.floor(e/t);return r}}qt._registrations=new WeakMap;const Zt=e.GBufferLocation.MotionVectors-1;var $t,er;e.CameraClearFlags=void 0,($t=e.CameraClearFlags||(e.CameraClearFlags={}))[$t.SolidColor=0]="SolidColor",$t[$t.Sky=1]="Sky",$t[$t.DepthOnly=2]="DepthOnly",$t[$t.Nothing=3]="Nothing",$t[$t.ColorOnly=4]="ColorOnly",e.CameraEventFlags=void 0,(er=e.CameraEventFlags||(e.CameraEventFlags={}))[er.BeforeForwardOpaque=0]="BeforeForwardOpaque",er[er.BeforeSkyBox=2]="BeforeSkyBox",er[er.BeforeTransparent=4]="BeforeTransparent",er[er.BeforeImageEffect=6]="BeforeImageEffect",er[er.AfterEveryThing=8]="AfterEveryThing";class tr extends Ne{static get _updateMark(){return J._instance._contextOBJ.cameraUpdateMask}static set _updateMark(e){J._instance._contextOBJ.cameraUpdateMask=e}static drawRenderTextureByScene(e,t,r){if(!r)return null;hr._updateMark++,t.parent?(t.sceneRenderableManager.renderUpdate(),t.skyRenderer.renderUpdate(J._instance)):t._update(),t._prepareSceneToRender(),t._setCullCamera(e);let a=e.renderTarget;e.renderTarget=r;let i=e.scene;return e._scene=t,e.render(t),e.renderTarget=a,t.recaculateCullCamera(),e._aftRenderMainPass(),e._scene=i,r}static getTexturePixel(e){let r=e.filterMode;e.filterMode=t.FilterMode.Point;let a,i=t.RenderTargetFormat.R8G8B8,n=e.width*e.height;switch(e.format){case t.TextureFormat.R32G32B32A32:case t.TextureFormat.R16G16B16A16:i=t.RenderTargetFormat.R32G32B32A32,a=new Float32Array(4*n);break;case t.TextureFormat.R32G32B32:case t.TextureFormat.R16G16B16:i=t.RenderTargetFormat.R32G32B32,a=new Float32Array(3*n);break;case t.TextureFormat.R5G6B5:case t.TextureFormat.R8G8B8:i=t.RenderTargetFormat.R8G8B8,a=new Uint8Array(3*n);break;default:i=t.RenderTargetFormat.R8G8B8A8,a=new Uint8Array(4*n)}let s=t.RenderTexture.createFromPool(e.width,e.height,i,t.RenderTargetFormat.None,!1,0,!1),o=new zt;return o.blitScreenQuad(e,s),o.context=J._instance,o._applyOne(),e.filterMode=r,s.getData(0,0,e.width,e.height,a),s.destroy(),a}static getTexturePixelAsync(e){let r=e.filterMode;e.filterMode=t.FilterMode.Point;let a,i=t.RenderTargetFormat.R8G8B8,n=e.width*e.height;switch(e.format){case t.TextureFormat.R32G32B32A32:case t.TextureFormat.R16G16B16A16:i=t.RenderTargetFormat.R32G32B32A32,a=new Float32Array(4*n);break;case t.TextureFormat.R32G32B32:case t.TextureFormat.R16G16B16:i=t.RenderTargetFormat.R32G32B32,a=new Float32Array(3*n);break;case t.TextureFormat.R5G6B5:case t.TextureFormat.R8G8B8:i=t.RenderTargetFormat.R8G8B8,a=new Uint8Array(3*n);break;default:i=t.RenderTargetFormat.R8G8B8A8,a=new Uint8Array(4*n)}let s=t.RenderTexture.createFromPool(e.width,e.height,i,t.RenderTargetFormat.None,!1,0,!1),o=new zt;o.blitScreenQuad(e,s),o.context=J._instance,o._applyOne(),e.filterMode=r;const l=s.getDataAsync(0,0,e.width,e.height,a);return s.destroy(),l}static drawTextureCubePixelByScene(e,r,a,i,n){let s,o,l=t.RenderTargetFormat.R8G8B8,h=a*a;switch(i){case t.TextureFormat.R32G32B32A32:case t.TextureFormat.R16G16B16A16:l=t.RenderTargetFormat.R32G32B32A32,h*=4,o=4;break;case t.TextureFormat.R32G32B32:case t.TextureFormat.R16G16B16:l=t.RenderTargetFormat.R32G32B32,h*=3,o=4;break;case t.TextureFormat.R5G6B5:case t.TextureFormat.R8G8B8:l=t.RenderTargetFormat.R8G8B8,h*=3,o=1;break;case t.TextureFormat.R8G8B8A8:l=t.RenderTargetFormat.R8G8B8A8,s=new Uint8Array(4*h),h*=4,o=1;break;default:throw new Error("Type is not supported")}let d=new t.RenderTexture(a,a,l,t.RenderTargetFormat.DEPTH_16,!1,0,!1,!1);e.fieldOfView=90,e.cullingMask=n;let c=[],u=[new t.Quaternion(0,1,0,0),new t.Quaternion(0,0,0,1),new t.Quaternion(0,.7071068,0,.7071068),new t.Quaternion(0,.7071068,0,-.7071068),new t.Quaternion(0,.7071068,-.7071068,0),new t.Quaternion(0,-.7071068,-.7071068,0)];for(var _=0;_<6;_++)e.transform.rotation=u[_],this.drawRenderTextureByScene(e,r,d),s=4==o?new Float32Array(h):new Uint8Array(h),c[_]=d.getData(0,0,a,a,s);return d.destroy(),c}static drawTextureCubeByScene(e,r,a,i,n,s=0){e.transform.position=r;let o=this.drawTextureCubePixelByScene(e,a,i,n,s);switch(n){case t.TextureFormat.R32G32B32A32:case t.TextureFormat.R16G16B16A16:t.TextureFormat.R32G32B32A32;break;case t.TextureFormat.R32G32B32:case t.TextureFormat.R16G16B16:t.TextureFormat.R32G32B32;break;case t.TextureFormat.R5G6B5:case t.TextureFormat.R8G8B8:t.TextureFormat.R8G8B8;break;case t.TextureFormat.R8G8B8A8:t.TextureFormat.R8G8B8A8;break;default:throw new Error("Type is not supported")}let l=new t.TextureCube(i,n,!0,!1);return l.setPixelsData(o,!1,!1),l}static __init__(){tr.depthPass=new At}set nearPlane(e){super.nearPlane=e,this._renderDataModule.nearplane=e}get nearPlane(){return this._nearPlane}set farPlane(e){super.farPlane=e,this._renderDataModule.farplane=e}get farPlane(){return this._farPlane}set fieldOfView(e){super.fieldOfView=e,this._renderDataModule.fieldOfView=e}get fieldOfView(){return this._fieldOfView}get aspectRatio(){if(0===this._aspectRatio){var e=this.viewport;return e.width/e.height}return this._aspectRatio}set aspectRatio(e){if(e<0)throw new Error("Camera: the aspect ratio has to be a positive real number.");this._aspectRatio=e,this._renderDataModule.aspectRatio=e,this._calculateProjectionMatrix()}get viewport(){return this._offScreenRenderTexture?this._calculationViewport(this._normalizedViewport,this._offScreenRenderTexture.width,this._offScreenRenderTexture.height):this._calculationViewport(this._normalizedViewport,this.clientWidth,this.clientHeight),this._viewport}set viewport(e){var t,r;this._offScreenRenderTexture?(t=this._offScreenRenderTexture.width,r=this._offScreenRenderTexture.height):(t=this.clientWidth,r=this.clientHeight),this._normalizedViewport.x=e.x/t,this._normalizedViewport.y=e.y/r,this._normalizedViewport.width=e.width/t,this._normalizedViewport.height=e.height/r,this._calculationViewport(this._normalizedViewport,t,r),this._calculateProjectionMatrix()}get clientWidth(){return t.ILaya.stage.needUpdateCanvasSize(),t.Config3D.customResolution?t.Config3D.pixelRatio*t.Config3D._resoluWidth|0:J.clientWidth*t.Config3D.pixelRatio|0}get clientHeight(){return t.ILaya.stage.needUpdateCanvasSize(),t.Config3D.customResolution?t.Config3D.pixelRatio*t.Config3D._resoluHeight|0:J.clientHeight*t.Config3D.pixelRatio|0}set msaa(e){if(e&&this._manualOpaqueMRTOptions)throw new Error("Camera opaque MRT does not support MSAA.");t.LayaGL.renderEngine.getCapable(t.RenderCapable.MSAA)?this._msaa=e:this._msaa=!1}get msaa(){return this._msaa&&t.Stat.enablemsaa}get opaqueMRT(){return this._manualOpaqueMRTOptions}set opaqueMRT(e){var r;const a=this._normalizeOpaqueMRTOptions(e),i=(null===(r=this.postProcess)||void 0===r?void 0:r._collectCameraMRTRequirements(t.Stat.enablePostprocess))||null;this._mergeOpaqueMRTOptions(a,i),this._manualOpaqueMRTOptions=a}get effectiveOpaqueMRT(){return this._opaqueMRTOptions}_createOpaqueMRTAttachment(e,r,a){if(void 0!==a&&("string"!=typeof a||0===a.length))throw new Error("Camera opaque MRT attachment names must be non-empty strings.");const i=r?r.clone():new t.Color(0,0,0,0);return Object.freeze({format:e,name:a,clearColor:Object.freeze(i)})}_normalizeOpaqueMRTOptions(t){if(!t)return null;if(!Array.isArray(t.auxiliaryAttachments))throw new Error("Camera opaque MRT auxiliaryAttachments must be an array.");const r=[];for(let a=0;a<t.auxiliaryAttachments.length;a++){const i=t.auxiliaryAttachments[a];if(a===Zt&&null!=i)throw new Error("Camera opaque MRT location 4 is reserved for MotionVectors.");if((null==i?void 0:i.name)===e.GBufferAttachment.MotionVectors)throw new Error("MotionVectors is managed by the camera, not a manual MRT attachment.");r.push(null==i?null:this._createOpaqueMRTAttachment(i.format,i.clearColor,i.name))}for(;r.length&&null==r[r.length-1];)r.pop();return r.length?Object.freeze({auxiliaryAttachments:Object.freeze(r)}):null}_sameOpaqueMRTClearColor(e,r){const a=r||t.Color.CLEAR;return e.r===a.r&&e.g===a.g&&e.b===a.b&&e.a===a.a}_mergeOpaqueMRTOptions(r,a){var i,n;if(a&&!Array.isArray(a))throw new Error("Camera opaque MRT requirements must be an array.");if(!r&&!(null==a?void 0:a.length))return null;if(this.msaa)throw new Error("Camera opaque MRT does not support MSAA.");if(!t.LayaGL.renderEngine.getCapable(t.RenderCapable.MRT))throw new Error("Camera opaque MRT requires MRT support.");const s=t.LayaGL.renderEngine.getParams(t.RenderParams.Max_Color_Attachment_Count),o=r?r.auxiliaryAttachments.slice():[];if(o.length+1>s)throw new Error(`Camera opaque MRT requires 1 to ${s-1} auxiliary attachments.`);const l=new Map;for(let e=0;e<o.length;e++){const t=null===(i=o[e])||void 0===i?void 0:i.name;if(void 0!==t){if(l.has(t))throw new Error(`Camera opaque MRT name ${t} maps to multiple indices.`);l.set(t,e)}}if(a)for(const r of a){if(!r||!Number.isInteger(r.index)||r.index<0)throw new Error("Camera opaque MRT requirement indices must be non-negative integers.");if("string"!=typeof r.name||0===r.name.length)throw new Error("Camera opaque MRT requirements need non-empty names.");const a=r.index;if(a===Zt){if(r.name!==e.GBufferAttachment.MotionVectors||r.format!==t.RenderTargetFormat.R16G16B16A16||!this._sameOpaqueMRTClearColor(t.Color.CLEAR,r.clearColor))throw new Error("Camera opaque MRT location 4 is reserved for RGBA16F MotionVectors.")}else if(r.name===e.GBufferAttachment.MotionVectors)throw new Error("MotionVectors must use camera opaque MRT location 4.");if(a+2>s)throw new Error(`Camera opaque MRT auxiliary index ${a} exceeds the device limit.`);if(l.has(r.name)&&l.get(r.name)!==a)throw new Error(`Camera opaque MRT name ${r.name} maps to multiple indices.`);const i=o[a];if(i){if(i.format!==r.format||!this._sameOpaqueMRTClearColor(i.clearColor,r.clearColor))throw new Error(`Camera opaque MRT format or clear value conflicts at auxiliary index ${a}.`);if(void 0!==i.name&&i.name!==r.name)throw new Error(`Camera opaque MRT name conflicts at auxiliary index ${a}.`)}if(!i||void 0===i.name){const e=null===(n=this._opaqueMRTOptions)||void 0===n?void 0:n.auxiliaryAttachments[a];o[a]=e&&e.name===r.name&&e.format===r.format&&this._sameOpaqueMRTClearColor(e.clearColor,r.clearColor)?e:this._createOpaqueMRTAttachment(r.format,r.clearColor,r.name)}l.set(r.name,a)}for(let e=0;e<o.length;e++)null==o[e]&&(o[e]=null);return Object.freeze({auxiliaryAttachments:Object.freeze(o)})}_setEffectiveOpaqueMRT(e){var r;const a=null===(r=this._opaqueMRTOptions)||void 0===r?void 0:r.auxiliaryAttachments,i=null==e?void 0:e.auxiliaryAttachments,n=!a&&!i||a&&i&&a.length===i.length&&a.every((e,t)=>{var r,a,n;return(null!==(r=null==e?void 0:e.format)&&void 0!==r?r:null)===(null!==(n=null===(a=i[t])||void 0===a?void 0:a.format)&&void 0!==n?n:null)});n&&(!a||a.every((e,t)=>{const r=i[t];return e&&r?e.name===r.name&&this._sameOpaqueMRTClearColor(e.clearColor,r.clearColor):e===r}))||(n||(this._releaseOpaqueMRT(),e&&this._internalRenderTexture&&(t.RenderTexture.recoverToPool(this._internalRenderTexture),this._internalRenderTexture=null)),this._opaqueMRTOptions=e,this._opaqueMRTClearColors=e?[null,...e.auxiliaryAttachments.map(e=>{var t;return null!==(t=null==e?void 0:e.clearColor)&&void 0!==t?t:null})]:null)}_updateOpaqueMRTRequirements(e){this._setEffectiveOpaqueMRT(this._mergeOpaqueMRTOptions(this._manualOpaqueMRTOptions,e))}_hasOpaqueMRTRequirements(e){var t;if(!e)return!0;if(!Array.isArray(e))return!1;if(!e.length)return!0;const r=this._opaqueMRT,a=null===(t=this._opaqueMRTOptions)||void 0===t?void 0:t.auxiliaryAttachments;if(!a||!r||r!==this._internalRenderTexture||r.destroyed||r._inPool)return!1;for(const t of e){if(!t||!Number.isInteger(t.index)||t.index<0||"string"!=typeof t.name||!t.name.length)return!1;const e=a[t.index];if(!e||e.name!==t.name||e.format!==t.format||!this._sameOpaqueMRTClearColor(e.clearColor,t.clearColor)||!r.getColorTexture(t.index+1))return!1}return!0}getOpaqueAuxiliaryTexture(e){var t;const r=null===(t=this._opaqueMRTOptions)||void 0===t?void 0:t.auxiliaryAttachments,a="string"==typeof e?null==r?void 0:r.findIndex(t=>(null==t?void 0:t.name)===e):e;return!Number.isInteger(a)||a<0||!(null==r?void 0:r[a])||!this._opaqueMRT||this._opaqueMRT._inPool?null:this._opaqueMRT.getColorTexture(a+1)}_getOpaqueMRTClearColors(e){return this._opaqueMRTClearColors&&(this._opaqueMRTClearColors[0]=e),this._opaqueMRTClearColors}_releaseOpaqueMRT(){tr.depthPass.releaseCachedDepth(this);const e=this._opaqueMRT,r=this._cacheDepthTexture instanceof t.RenderTextureMRT?this._cacheDepthTexture:null;(this._internalRenderTexture===e||r&&this._internalRenderTexture===r)&&(this._internalRenderTexture=null),r&&(this._cacheDepthTexture=null),this._opaqueMRT=null,this._opaqueMRTKey=null,e&&t.RenderTexture.recoverToPool(e),r&&r!==e&&t.RenderTexture.recoverToPool(r)}_createInternalRenderTexture(e,r){const a=this._getRenderTextureFormat(),i=this.depthTextureFormat,n=this._needRenderGamma(a);if(!this._opaqueMRTOptions)return t.RenderTexture.createFromPool(e,r,a,i,!1,this.msaa?4:1,this._canBlitDepth,n);const s=[a,...this._opaqueMRTOptions.auxiliaryAttachments.map(e=>{var t;return null!==(t=null==e?void 0:e.format)&&void 0!==t?t:null})],o=[e,r,i,+!!this._canBlitDepth,+n,...s.map(e=>null!=e?e:"null")].join(",");this._opaqueMRTKey!==o&&this._releaseOpaqueMRT();let l=this._opaqueMRT;return(!l||l.destroyed||l._inPool||this._cacheDepth&&l===this._cacheDepthTexture)&&(l=t.RenderTextureMRT.createFromPool({width:e,height:r,colorFormats:s,depthStencilFormat:i,depthTexture:this._canBlitDepth,sRGB:n}),this._opaqueMRT=l,this._opaqueMRTKey=o),l}set fxaa(e){this._fxaa=e}get fxaa(){return this._fxaa}set taa(e){e?this.taaSettings.enabled=!0:this._taa&&(this._taa.enabled=!1)}get taa(){var e,t;return null!==(t=null===(e=this._taa)||void 0===e?void 0:e.enabled)&&void 0!==t&&t}get taaSettings(){return this._taa||(this._taa=new qt(this))}get normalizedViewport(){return this._normalizedViewport}set normalizedViewport(e){var t,r;this._offScreenRenderTexture?(t=this._offScreenRenderTexture.width,r=this._offScreenRenderTexture.height):(t=this.clientWidth,r=this.clientHeight),this._normalizedViewport!==e&&e.cloneTo(this._normalizedViewport),this._calculationViewport(e,t,r),this._calculateProjectionMatrix()}get viewMatrix(){if(this._updateViewMatrix){var e=this.transform.getWorldLossyScale(),t=e.x,r=e.y,a=e.z,i=this._viewMatrix.elements;this.transform.worldMatrix.cloneTo(this._viewMatrix),i[0]/=t,i[1]/=t,i[2]/=t,i[4]/=r,i[5]/=r,i[6]/=r,i[8]/=a,i[9]/=a,i[10]/=a,this._viewMatrix.invert(this._viewMatrix),this._updateViewMatrix=!1,this.skyRenderElement._renderElementOBJ&&this.skyRenderElement.calculateViewMatrix(this._viewMatrix),this._updateViewProjectionMatrix=!0}return this._viewMatrix}get projectionMatrix(){return this._projectionMatrix}set projectionMatrix(e){this._projectionMatrix=e,this._useUserProjectionMatrix=!0,this._updateViewProjectionMatrix=!0}get projectionViewMatrix(){return this.updateViewProjectionMatrix(),this._projectionViewMatrix}updateViewProjectionMatrix(){let e=this.viewMatrix,r=this.projectionMatrix;this._updateViewProjectionMatrix&&(t.Matrix4x4.multiply(r,e,this._projectionViewMatrix),this._updateViewProjectionMatrix=!1,this._boundFrustum.matrix=this._projectionViewMatrix),this._renderDataModule.setProjectionViewMatrix(this._projectionViewMatrix),this._renderDataModule.setForward&&(this.transform.getForward(t.Vector3.TEMP),this._renderDataModule.setForward(t.Vector3.TEMP.x,t.Vector3.TEMP.y,t.Vector3.TEMP.z))}get boundFrustum(){return this.updateViewProjectionMatrix(),this._boundFrustum}get renderTarget(){return this._offScreenRenderTexture}set renderTarget(e){var t=this._offScreenRenderTexture;t!==e&&(t&&(t._isCameraTarget=!1),e&&(e._isCameraTarget=!0),this._offScreenRenderTexture=e,this._calculateProjectionMatrix())}get postProcess(){return this._postProcess}set postProcess(e){const t=this._taa;!e&&(null==t?void 0:t.enabled)&&(e=new Qt),this._postProcess!==e&&(this._postProcess=e,(null==t?void 0:t.enabled)&&t.onPostProcessChanged())}get enableHDR(){return this._enableHDR}set enableHDR(e){!e||t.LayaGL.renderEngine.getCapable(t.RenderCapable.RenderTextureFormat_R16G16B16A16)?this._enableHDR=e:console.warn("Camera:can't enable HDR in this device.")}get enableBuiltInRenderTexture(){return this._needBuiltInRenderTexture}set enableBuiltInRenderTexture(e){this._needBuiltInRenderTexture=e}get depthTextureMode(){return this._depthTextureMode}set depthTextureMode(e){this._depthTextureMode=e,t.LayaGL.renderEngine.getCapable(t.RenderCapable.RenderTextureFormat_Depth)||(this._depthTextureMode&=~t.DepthTextureMode.Depth)}set opaquePass(e){e!=this._opaquePass&&(e||(this._shaderValues.setTexture(Ne.OPAQUETEXTURE,t.Texture2D.blackTexture),this._shaderValues.setVector(Ne.OPAQUETEXTUREPARAMS,t.Vector4.ONE),this._opaqueTexture&&t.RenderTexture.recoverToPool(this._opaqueTexture),this._opaqueTexture=null),this._opaquePass=e)}get opaquePass(){return this._opaquePass}get depthTextureFormat(){return this._depthTextureFormat}set depthTextureFormat(e){this._depthTextureFormat=e}set enableBlitDepth(e){e!=this._canBlitDepth&&(this._canBlitDepth=e,this._cacheDepth=e)}get enableBlitDepth(){return this._canBlitDepth}get canblitDepth(){return this._canBlitDepth&&this._internalRenderTexture&&this._cacheDepthTexture&&!this._cacheDepthTexture._inPool&&!!this._cacheDepthTexture.depthStencilTexture&&this._cacheDepthTexture.width===this._internalRenderTexture.width&&this._cacheDepthTexture.height===this._internalRenderTexture.height&&this._cacheDepthTexture.depthStencilFormat===this._internalRenderTexture.depthStencilFormat}constructor(r=0,a=.3,i=1e3){super(a,i),this.isEditorCamera=!1,this._updateViewMatrix=!0,this._updateViewProjectionMatrix=!0,this._postProcess=null,this._enableHDR=!1,this._viewportParams=new t.Vector4,this._projectionParams=new t.Vector4,this._needBuiltInRenderTexture=!1,this._msaa=!1,this._fxaa=!1,this._taa=null,this._offScreenRenderTexture=null,this._internalRenderTexture=null,this._canBlitDepth=!1,this._internalCommandBuffer=new zt,this._depthTextureFormat=t.RenderTargetFormat.DEPTH_32,this._cameraEventCommandBuffer={},this._shadowCasterCommanBuffer=[],this._clusterPlaneCacheFlag=new t.Vector2(-1,-1),this._screenOffsetScale=new t.Vector4,this.enableRender=!0,this.clearFlag=e.CameraClearFlags.SolidColor,this._opaqueMRT=null,this._manualOpaqueMRTOptions=null,this._opaqueMRTOptions=null,this._opaqueMRTKey=null,this._opaqueMRTClearColors=null,this.opaqueTextureSize=512,this._renderDataModule=T.Render3DModuleDataFactory.createCameraModuleData(),this._Render3DProcess=T.Render3DPassFactory.createRender3DProcess(),this._renderDataModule.transform=this.transform,this._viewMatrix=new t.Matrix4x4,this._projectionMatrix=new t.Matrix4x4,this._projectionViewMatrix=new t.Matrix4x4,this._viewport=new t.Viewport(0,0,0,0),this._normalizedViewport=new t.Viewport(0,0,1,1),this._rayViewport=new t.Viewport(0,0,0,0),this._aspectRatio=r,this._boundFrustum=new $e(new t.Matrix4x4),this.depthTextureMode=0,this.opaquePass=!1,this._calculateProjectionMatrix(),t.ILaya.stage.on(t.Event.RESIZE,this,this._onScreenSizeChanged),this.transform.on(t.Event.TRANSFORM_CHANGED,this,this._onTransformChanged),this.opaquePass=!1,this._internalCommandBuffer.context=J._instance,this._internalCommandBuffer._camera=this,this._renderDataModule.farplane=this.farPlane,this._renderDataModule.nearplane=this.nearPlane,this._renderDataModule.fieldOfView=this.fieldOfView,this._renderDataModule.aspectRatio=this.aspectRatio}_calculationViewport(e,t,r){var a=e.x*t,i=e.y*r,n=a+Math.max(e.width*t,0),s=i+Math.max(e.height*r,0),o=Math.ceil(a),l=Math.ceil(i),h=Math.floor(n),d=Math.floor(s),c=o-a>=.5?Math.floor(a):o,u=l-i>=.5?Math.floor(i):l,_=n-h>=.5?Math.ceil(n):h,f=s-d>=.5?Math.ceil(s):d;this._viewport.x=c,this._viewport.y=u,this._viewport.width=_-c,this._viewport.height=f-u}_calculateProjectionMatrix(){if(!this._useUserProjectionMatrix){if(this._orthographic){var e=.5*this.orthographicVerticalSize,r=e*this.aspectRatio;t.Matrix4x4.createOrthoOffCenter(-r,r,-e,e,this.nearPlane,this.farPlane,this._projectionMatrix)}else t.Matrix4x4.createPerspective(3.1416*this.fieldOfView/180,this.aspectRatio,this.nearPlane,this.farPlane,this._projectionMatrix);this.skyRenderElement._renderElementOBJ&&this.skyRenderElement.caluclateProjectionMatrix(this._projectionMatrix,this.aspectRatio,this.nearPlane,this.farPlane,this.fieldOfView,this.orthographic),this._updateViewProjectionMatrix=!0}}_isLayerVisible(e){return 0!=(Math.pow(2,e)&this.cullingMask)}_onTransformChanged(e){(e&=Se.TRANSFORM_WORLDMATRIX)&&(this._updateViewMatrix=!0)}clone(){let e=super.clone();return e.clearFlag=this.clearFlag,this.clearColor.cloneTo(e.clearColor),e.clearColor=e.clearColor,e.viewport=this.viewport,this.normalizedViewport.cloneTo(e.normalizedViewport),e.enableHDR=this.enableHDR,e.farPlane=this.farPlane,e.nearPlane=this.nearPlane,e.fieldOfView=this.fieldOfView,e.orthographic=this.orthographic,e.orthographicVerticalSize=this.orthographicVerticalSize,e.opaquePass=this.opaquePass,e.opaqueMRT=this.opaqueMRT,this._taa&&this._taa.cloneTo(e.taaSettings),e._cameraEventCommandBuffer=this._cameraEventCommandBuffer,e.opaquePass=this.opaquePass,e}_getCanvasWidth(){return this._offScreenRenderTexture?this._offScreenRenderTexture.width:this.clientWidth}_getCanvasHeight(){return this._offScreenRenderTexture?this._offScreenRenderTexture.height:this.clientHeight}_getRenderTexture(){return this._internalRenderTexture||this._offScreenRenderTexture}_needRenderGamma(e){switch(e){case t.RenderTargetFormat.R8G8B8:case t.RenderTargetFormat.R8G8B8A8:return!0;default:return!1}}_needInternalRenderTexture(){let e=this.enableBuiltInRenderTexture||!!this._opaqueMRTOptions;if(this.renderTarget){if(this.msaa&&(e=e||!(this.renderTarget.samples>1)),this.enableHDR)switch(this.renderTarget.format){case t.TextureFormat.R16G16B16A16:case t.TextureFormat.R16G16B16:case t.TextureFormat.R32G32B32A32:case t.TextureFormat.R32G32B32:break;default:e=!0}this.postProcess&&this.postProcess.enable&&this.postProcess.effects.length>0&&(e=!0),1==this.normalizedViewport.width&&1==this.normalizedViewport.height&&0==this.normalizedViewport.x&&0==this.normalizedViewport.y||(e=!0)}return e}_getRenderTextureFormat(){return this._enableHDR?t.RenderTargetFormat.R16G16B16A16:t.RenderTargetFormat.R8G8B8A8}_updateCameraRenderData(e){this._prepareCameraToRender(),this._applyViewProject(this.viewMatrix,this._projectionMatrix,e.invertY),this._contextApply(e)}_prepareCameraToRender(){super._prepareCameraToRender();var e=this.viewport;this._viewportParams.setValue(e.x,e.y,e.width,e.height);let t=J._instance.invertY;this._projectionParams.setValue(this._nearPlane,this._farPlane,t?-1:1,1/this.farPlane),this._shaderValues.setVector(Ne.VIEWPORT,this._viewportParams),this._shaderValues.setVector(Ne.PROJECTION_PARAMS,this._projectionParams)}_contextApply(e){e.viewMatrix=this.viewMatrix,e.projectionMatrix=this.projectionMatrix,e.projectionViewMatrix=this.projectionViewMatrix}_applyViewProject(e,r,a){var i;a?(t.Matrix4x4.multiply(Ne._invertYScaleMatrix,r,Ne._invertYProjectionMatrix),t.Matrix4x4.multiply(Ne._invertYProjectionMatrix,e,Ne._invertYProjectionViewMatrix),r=Ne._invertYProjectionMatrix,i=Ne._invertYProjectionViewMatrix):(t.Matrix4x4.multiply(r,e,this._projectionViewMatrix),i=this._projectionViewMatrix),this._renderDataModule.setProjectionViewMatrix(i),this._shaderValues.setMatrix4x4(Ne.VIEWMATRIX,e),this._shaderValues.setMatrix4x4(Ne.PROJECTMATRIX,r),this._shaderValues.setMatrix4x4(Ne.VIEWPROJECTMATRIX,i)}_updateClusterPlaneXY(){var e=this.fieldOfView,r=this.aspectRatio;if(this._clusterPlaneCacheFlag.x!==e||this._clusterPlaneCacheFlag.y!==r){var a=t.Config3D.lightClusterCount,i=a.x,n=a.y,s=i+1,o=n+1,l=this._clusterXPlanes,h=this._clusterYPlanes;if(!l){l=this._clusterXPlanes=new Array(s),h=this._clusterYPlanes=new Array(o);for(var d=0;d<s;d++)l[d]=new t.Vector3;for(d=0;d<o;d++)h[d]=new t.Vector3}var c=Math.tan(this.fieldOfView/2*Math.PI/180),u=this.aspectRatio*c,_=2*c/n,f=2*u/i;for(d=0;d<s;d++){var m=f*d-u,g=1/Math.sqrt(1+m*m);l[d].setValue(g,0,-m*g)}for(d=0;d<o;d++){m=c-_*d;var p=-1/Math.sqrt(1+m*m);h[d].setValue(0,p,-m*p)}this._clusterPlaneCacheFlag.x=e,this._clusterPlaneCacheFlag.y=r}}_addCasterShadowCommandBuffer(e){this._shadowCasterCommanBuffer.indexOf(e)<0&&this._shadowCasterCommanBuffer.push(e)}_removeCasterShadowCommandBuffer(e){var t=this._shadowCasterCommanBuffer.indexOf(e);-1!=t&&this._shadowCasterCommanBuffer.splice(t,1)}_preRenderMainPass(r,a,i,n){if(r.camera=this,r.cameraShaderValue=this._shaderValues,tr._updateMark++,i&&!this._offScreenRenderTexture&&(this.clearFlag==e.CameraClearFlags.DepthOnly||this.clearFlag==e.CameraClearFlags.Nothing))if(t.RenderTexture.bindCanvasRender)t.RenderTexture.bindCanvasRender!=this._internalRenderTexture&&(this._internalCommandBuffer.clear(),this._internalCommandBuffer.blitScreenQuad(t.RenderTexture.bindCanvasRender,this._internalRenderTexture,null,null,null,0,!0),this._internalCommandBuffer._applyOne());else if(this._enableHDR){var s=t.RenderTexture.createFromPool(n.width,n.height,t.RenderTargetFormat.R8G8B8,t.RenderTargetFormat.DEPTH_16,!1,1);s.filterMode=t.FilterMode.Bilinear,this._renderEngine.copySubFrameBuffertoTex(s._texture,0,0,0,n.x,J.clientHeight-(n.y+n.height),n.width,n.height),this._internalCommandBuffer.clear(),this._internalCommandBuffer.blitScreenQuad(s,this._internalRenderTexture,null,null,null,0,!0),this._internalCommandBuffer._apply(!0),t.RenderTexture.recoverToPool(s)}}get depthTexture(){return this._depthTexture}set depthTexture(e){this._depthTexture=e}get depthNormalTexture(){return this._depthNormalsTexture}set depthNormalTexture(e){this._depthNormalsTexture=e}_aftRenderMainPass(){this._cacheDepth&&this._internalRenderTexture?(this._opaqueMRT&&tr.depthPass.releaseCachedDepth(this),this._cacheDepthTexture&&!this._cacheDepthTexture._inPool&&t.RenderTexture.recoverToPool(this._cacheDepthTexture),this._cacheDepthTexture=this._internalRenderTexture,this._internalRenderTexture=null):this._internalRenderTexture!==this._opaqueMRT&&this._internalRenderTexture&&!this._internalRenderTexture._inPool&&t.RenderTexture.recoverToPool(this._internalRenderTexture)}_createOpaqueTexture(){if(!this._opaqueTexture){let e=this._getRenderTexture(),r=this.opaqueTextureSize;this._opaqueTexture=t.RenderTexture.createFromPool(r,r,e.colorFormat,t.RenderTargetFormat.None,!0,1,!1,!0),this._opaqueTexture.filterMode=t.FilterMode.Bilinear,this._opaqueTexture.wrapModeU=t.WrapMode.Clamp,this._opaqueTexture.wrapModeV=t.WrapMode.Clamp,this._shaderValues.setTexture(Ne.OPAQUETEXTURE,this._opaqueTexture);let a=new t.Vector4;a.x=this._opaqueTexture.width,a.y=this._opaqueTexture.height,a.z=this._opaqueTexture.maxMipmapLevel,this._shaderValues.setVector(Ne.OPAQUETEXTUREPARAMS,a)}}render(r){var a,i;const n=(null===(a=this.postProcess)||void 0===a?void 0:a._collectCameraMRTRequirements(t.Stat.enablePostprocess))||null,s=this._taa;this._updateOpaqueMRTRequirements(s?s.collectRequirements(n,this.opaqueMRT):n),!this._cacheDepth&&this._cacheDepthTexture&&(tr.depthPass.releaseCachedDepth(this),t.RenderTexture.recoverToPool(this._cacheDepthTexture),this._cacheDepthTexture=null);let o=J._instance;o.scene=r,o.camera=this,r._setCullCamera(this),this._Render3DProcess.render3DManager=r.sceneRenderableManager._sceneManagerOBJ;let l=this.viewport,h=this._needInternalRenderTexture();if(h){let e=this._createInternalRenderTexture(l.width,l.height);e.filterMode=t.FilterMode.Bilinear,this._internalRenderTexture=e}else this._internalRenderTexture=null;this.opaquePass&&!this._opaqueTexture&&this._createOpaqueTexture(),o.invertY=!1;let d=this._getRenderTexture();d&&(o.invertY=d._isCameraTarget),this._prepareCameraToRender();const c=null!==(i=null==s?void 0:s.setupFrame(o))&&void 0!==i&&i;c||(this._applyViewProject(this.viewMatrix,this.projectionMatrix,o.invertY),this._contextApply(o)),this.clearFlag==e.CameraClearFlags.Sky&&(r.skyRenderer.setRenderElement(this.skyRenderElement),this.skyRenderElement.renderpre(o)),r._componentDriver.callPreRender(),c&&s.beforeRender(o),this._preRenderMainPass(o,r,h,l),t.Config3D._multiLighting&&le.instance.update(this,r),this._Render3DProcess.fowardRender(o._contextOBJ,this),c&&s.afterRender(!0),r._componentDriver.callPostRender()}viewportPointToRay(e,r){rr.setValue(e.x*t.ILaya.stage.clientScaleX*t.Config3D.pixelRatio,e.y*t.ILaya.stage.clientScaleY*t.Config3D.pixelRatio),this._rayViewport.x=this.viewport.x,this._rayViewport.y=this.viewport.y,this._rayViewport.width=this.viewport.width,this._rayViewport.height=this.viewport.height,Et.calculateCursorRay(rr,this._rayViewport,this._projectionMatrix,this.viewMatrix,null,r)}normalizedViewportPointToRay(e,r){var a=this.normalizedViewport;rr.x=e.x*t.Config3D.pixelRatio*a.width,rr.y=e.y*t.Config3D.pixelRatio*a.height,Et.calculateCursorRay(rr,this.viewport,this._projectionMatrix,this.viewMatrix,null,r)}worldToViewportPoint(e,r){t.Matrix4x4.multiply(this._projectionMatrix,this._viewMatrix,this._projectionViewMatrix),this.viewport.project(e,this._projectionViewMatrix,r);var a=t.Config3D.pixelRatio;let i=(r.x-this.viewport.x)/a,n=(r.y-this.viewport.y)/a;r.x=i+this.viewport.x,r.y=n+this.viewport.y,r.x=r.x/t.ILaya.stage.clientScaleX|0,r.y=r.y/t.ILaya.stage.clientScaleY|0}worldToNormalizedViewportPoint(e,r){this.worldToViewportPoint(e,r),r.x=r.x/t.ILaya.stage.width,r.y=r.y/t.ILaya.stage.height}convertScreenCoordToOrthographicCoord(e,r){if(this._orthographic){var a=this.clientWidth,i=this.clientHeight,n=this.orthographicVerticalSize*this.aspectRatio/a,s=this.orthographicVerticalSize/i;return r.x=(-a/2+e.x*t.ILaya.stage.clientScaleX*t.Config3D.pixelRatio)*n,r.y=(i/2-e.y*t.ILaya.stage.clientScaleY*t.Config3D.pixelRatio)*s,r.z=(this.nearPlane-this.farPlane)*(e.z+1)/2-this.nearPlane,t.Vector3.transformCoordinate(r,this.transform.worldMatrix,r),!0}return!1}destroy(e=!0){var r;null===(r=this._taa)||void 0===r||r.destroy(),this._taa=null,this._releaseOpaqueMRT(),this._shaderValues.destroy(),this._cacheDepthTexture&&(t.RenderTexture.recoverToPool(this._cacheDepthTexture),this._cacheDepthTexture=null),this._internalRenderTexture&&!this._internalRenderTexture._inPool&&t.RenderTexture.recoverToPool(this._internalRenderTexture),this._offScreenRenderTexture=null,this._opaqueTexture&&t.RenderTexture.recoverToPool(this._opaqueTexture),this._renderDataModule&&this._renderDataModule.destroy&&this._renderDataModule.destroy(),this._Render3DProcess.destroy(),this.transform.off(t.Event.TRANSFORM_CHANGED,this,this._onTransformChanged),t.ILaya.stage.off(t.Event.RESIZE,this,this._onScreenSizeChanged),this._cameraEventCommandBuffer={},J._instance.camera==this&&(J._instance.cameraShaderValue=null,J._instance.camera=null),super.destroy(e)}addCommandBuffer(e,t){var r=this._cameraEventCommandBuffer[e];r||(r=this._cameraEventCommandBuffer[e]=[]),r.indexOf(t)<0&&r.push(t),t._camera=this,t.casterShadow&&this._addCasterShadowCommandBuffer(t)}removeCommandBuffer(e,t){var r=this._cameraEventCommandBuffer[e];if(!r)throw"Camera:unknown event.";var a=r.indexOf(t);-1!=a&&r.splice(a,1),t.casterShadow&&this._removeCasterShadowCommandBuffer(t)}removeCommandBuffers(e){this._cameraEventCommandBuffer[e]&&(this._cameraEventCommandBuffer[e].length=0)}}tr._context3DViewPortCatch=new t.Viewport(0,0,0,0),tr._contextScissorPortCatch=new t.Vector4(0,0,0,0);const rr=new t.Vector2,ar=new t.Vector4(0,0,1,1);class ir{static __init__(){ir.shaderdata=t.LayaGL.renderDeviceFactory.createShaderData(null)}static create(e,t,r,a=null,i=null,n=null,s=0){var o;return(o=ir._pool.take())._source=e,o._dest=t,o._offsetScale=a,o.setshader(i,s,n),o._source&&o._texture_size.setValue(e.width,e.height,1/e.width,1/e.height),o._viewPort=r,o}constructor(){this._source=null,this._dest=null,this._offsetScale=null,this._texture_size=null,this._shader=null,this._shaderData=null,this._subShader=0,this._viewPort=null,this._transform3D=T.Render3DModuleDataFactory.createTransform(null),this._renderElement=new W,this._renderElement.setTransform(this._transform3D),this._renderElement.setGeometry(wt.instance),this._renderElement._renderElementOBJ.isRender=!0,this._texture_size=new t.Vector4}set shaderData(e){this._shaderData=e||ir.shaderdata,this._renderElement._renderElementOBJ.materialShaderData=this._shaderData}setshader(e,t,r){this._shader=e||j._screenShader,this._subShader=t||0,this.shaderData=r,this._renderElement.renderSubShader=this._shader.getSubShaderAt(this._subShader)}run(){if(!this._source||!this._viewPort)return;var e=this._source,r=this._dest,a=this._shaderData;let i=J._instance;var n=this._viewPort;let s=J.clientHeight-n.y-n.height;t.LayaGL.renderEngine._screenInvertY?(i.changeViewport(n.x,n.y,n.width,n.height),i.changeScissor(n.x,n.y,n.width,n.height)):(i.changeViewport(n.x,s,n.width,n.height),i.changeScissor(n.x,s,n.width,n.height)),a.setTexture(j.SCREENTEXTURE_ID,e),a.setVector(j.SCREENTEXTUREOFFSETSCALE_ID,this._offsetScale||ar),e&&a.setVector(j.MAINTEXTURE_TEXELSIZE_ID,this._texture_size),r?a.removeDefine(J.GammaCorrect):a.addDefine(J.GammaCorrect),this._renderElement.setGeometry(wt.InvertInstance),t.LayaGL.renderEngine._screenInvertY&&this._renderElement.setGeometry(wt.instance),i.destTarget=r,i._contextOBJ.cameraUpdateMask=tr._updateMark,i.drawRenderElement(this._renderElement._renderElementOBJ)}recover(){ir._pool.recover(this),this._source=null,this._dest=null,this._offsetScale=null,this._shader=null,this._shaderData=null,this._viewPort=null}}ir._pool=t.Pool.createPool(ir);class nr{constructor(){this._list=new t.SingletonList,this._sceneManagerOBJ=T.Render3DPassFactory.createSceneRenderManager(),T.Render3DPassFactory.createMeshRenderBatchModule&&this._sceneManagerOBJ.registerBatchModuleAgent(t.BaseRenderType.MeshRender,T.Render3DPassFactory.createMeshRenderBatchModule()),T.Render3DPassFactory.createSimpleSkinRenderBatchModule&&this._sceneManagerOBJ.registerBatchModuleAgent(t.BaseRenderType.SimpleSkinRender,T.Render3DPassFactory.createSimpleSkinRenderBatchModule())}get list(){return this._list}set list(e){this._list=e,this._sceneManagerOBJ.list=e}addRenderObject(e){this._list.add(e),this._sceneManagerOBJ.addRenderObject(e)}removeRenderObject(e){this._list.remove(e),this._sceneManagerOBJ.removeRenderObject(e)}removeMotionObject(e){this._sceneManagerOBJ.removeMotionObject(e)}updateMotionObjects(){this._sceneManagerOBJ.updateMotionObjects()}renderUpdate(){var e=J._instance;let t=this._list.elements;for(let r=0,a=this._list.length;r<a;r++)t[r].renderUpdate(e)}addMotionObject(e){this._sceneManagerOBJ.addMotionObject(e)}destroy(){this._list.clear(),this._sceneManagerOBJ.destroy()}}if(t.Profiler.enabled){const e=nr.prototype.renderUpdate;nr.prototype.renderUpdate=function(){let r=t.Profiler.start("scene/render_update");try{e.call(this)}finally{t.Profiler.end(r)}}}class sr{constructor(){this._UI3Dlist=new t.FastSinglelist}add(e){this._UI3Dlist.add(e)}remove(e){this._UI3Dlist.remove(e)}update(){let e=this._UI3Dlist.elements;for(var t=0,r=this._UI3Dlist.length;t<r;t++)e[t]._submitRT()}rayCast(e){let t=e.origin;this._UI3Dlist.clean(),this._UI3Dlist.elements.sort((e,r)=>e._getCameraDistance(t)-r._getCameraDistance(t));let r=this._UI3Dlist.elements;for(var a=0,i=this._UI3Dlist.length;a<i;a++){let t=r[a]._checkUIPos(e);if(t)return t}return null}destory(){this._UI3Dlist.destroy()}}var or,lr;e.FogMode=void 0,(or=e.FogMode||(e.FogMode={}))[or.Linear=0]="Linear",or[or.EXP=1]="EXP",or[or.EXP2=2]="EXP2";class hr extends t.Sprite{static get _updateMark(){return J._instance._contextOBJ.sceneUpdateMask}static set _updateMark(e){J._instance._contextOBJ.sceneUpdateMask=e}static regManager(e,t){hr.componentManagerMap.set(e,t)}static shaderValueInit(){Ue.SHADERDEFINE_FOG=t.Shader3D.getDefineByName("FOG"),Ue.SHADERDEFINE_FOG_LINEAR=t.Shader3D.getDefineByName("FOG_LINEAR"),Ue.SHADERDEFINE_FOG_EXP=t.Shader3D.getDefineByName("FOG_EXP"),Ue.SHADERDEFINE_FOG_EXP2=t.Shader3D.getDefineByName("FOG_EXP2"),Ue.SHADERDEFINE_DIRECTIONLIGHT=t.Shader3D.getDefineByName("DIRECTIONLIGHT"),Ue.SHADERDEFINE_POINTLIGHT=t.Shader3D.getDefineByName("POINTLIGHT"),Ue.SHADERDEFINE_SPOTLIGHT=t.Shader3D.getDefineByName("SPOTLIGHT"),Ue.SHADERDEFINE_SHADOW=t.Shader3D.getDefineByName("SHADOW"),Ue.SHADERDEFINE_SHADOW_CASCADE=t.Shader3D.getDefineByName("SHADOW_CASCADE"),Ue.SHADERDEFINE_SHADOW_SOFT_SHADOW_LOW=t.Shader3D.getDefineByName("SHADOW_SOFT_SHADOW_LOW"),Ue.SHADERDEFINE_SHADOW_SOFT_SHADOW_HIGH=t.Shader3D.getDefineByName("SHADOW_SOFT_SHADOW_HIGH"),Ue.SHADERDEFINE_SHADOW_SPOT=t.Shader3D.getDefineByName("SHADOW_SPOT"),Ue.SHADERDEFINE_SHADOW_SPOT_SOFT_SHADOW_LOW=t.Shader3D.getDefineByName("SHADOW_SPOT_SOFT_SHADOW_LOW"),Ue.SHADERDEFINE_SHADOW_SPOT_SOFT_SHADOW_HIGH=t.Shader3D.getDefineByName("SHADOW_SPOT_SOFT_SHADOW_HIGH"),hr.FOGCOLOR=t.Shader3D.propertyNameToID("u_FogColor"),hr.FOGPARAMS=t.Shader3D.propertyNameToID("u_FogParams"),hr.DIRECTIONLIGHTCOUNT=t.Shader3D.propertyNameToID("u_DirationLightCount"),hr.LIGHTBUFFER=t.Shader3D.propertyNameToID("u_LightBuffer"),hr.CLUSTERBUFFER=t.Shader3D.propertyNameToID("u_LightClusterBuffer"),hr.TIME=t.Shader3D.propertyNameToID("u_Time"),hr.GIRotate=t.Shader3D.propertyNameToID("u_GIRotate");let e=hr.sceneUniformMap=t.LayaGL.renderDeviceFactory.createGlobalUniformMap("Scene3D");e.addShaderUniform(hr.TIME,"u_Time",t.ShaderDataType.Float),e.addShaderUniform(hr.FOGPARAMS,"u_FogParams",t.ShaderDataType.Vector4),e.addShaderUniform(hr.FOGCOLOR,"u_FogColor",t.ShaderDataType.Color),e.addShaderUniform(hr.LIGHTBUFFER,"u_LightBuffer",t.ShaderDataType.Texture2D),e.addShaderUniform(hr.CLUSTERBUFFER,"u_LightClusterBuffer",t.ShaderDataType.Texture2D),e.addShaderUniform(hr.GIRotate,"u_GIRotate",t.ShaderDataType.Float),e.addShaderUniform(hr.DIRECTIONLIGHTCOUNT,"u_DirationLightCount",t.ShaderDataType.Int),G.init(),V.init()}static legacyLightingValueInit(){hr.LIGHTDIRECTION=t.Shader3D.propertyNameToID("u_DirLightDirection"),hr.sceneUniformMap.addShaderUniform(hr.LIGHTDIRECTION,"u_DirLightDirection",t.ShaderDataType.Vector3),hr.LIGHTDIRCOLOR=t.Shader3D.propertyNameToID("u_DirLightColor"),hr.sceneUniformMap.addShaderUniform(hr.LIGHTDIRCOLOR,"u_DirLightColor",t.ShaderDataType.Vector3),hr.LIGHTMODE=t.Shader3D.propertyNameToID("u_DirLightMode"),hr.sceneUniformMap.addShaderUniform(hr.LIGHTMODE,"u_DirLightMode",t.ShaderDataType.Int),hr.POINTLIGHTPOS=t.Shader3D.propertyNameToID("u_PointLightPos"),hr.sceneUniformMap.addShaderUniform(hr.POINTLIGHTPOS,"u_PointLightPos",t.ShaderDataType.Vector3),hr.POINTLIGHTRANGE=t.Shader3D.propertyNameToID("u_PointLightRange"),hr.sceneUniformMap.addShaderUniform(hr.POINTLIGHTRANGE,"u_PointLightRange",t.ShaderDataType.Float),hr.POINTLIGHTCOLOR=t.Shader3D.propertyNameToID("u_PointLightColor"),hr.sceneUniformMap.addShaderUniform(hr.POINTLIGHTCOLOR,"u_PointLightColor",t.ShaderDataType.Vector3),hr.POINTLIGHTMODE=t.Shader3D.propertyNameToID("u_PointLightMode"),hr.sceneUniformMap.addShaderUniform(hr.POINTLIGHTMODE,"u_PointLightMode",t.ShaderDataType.Int),hr.SPOTLIGHTPOS=t.Shader3D.propertyNameToID("u_SpotLightPos"),hr.sceneUniformMap.addShaderUniform(hr.SPOTLIGHTPOS,"u_SpotLightPos",t.ShaderDataType.Vector3),hr.SPOTLIGHTDIRECTION=t.Shader3D.propertyNameToID("u_SpotLightDirection"),hr.sceneUniformMap.addShaderUniform(hr.SPOTLIGHTDIRECTION,"u_SpotLightDirection",t.ShaderDataType.Vector3),hr.SPOTLIGHTSPOTANGLE=t.Shader3D.propertyNameToID("u_SpotLightSpot"),hr.sceneUniformMap.addShaderUniform(hr.SPOTLIGHTSPOTANGLE,"u_SpotLightSpot",t.ShaderDataType.Float),hr.SPOTLIGHTRANGE=t.Shader3D.propertyNameToID("u_SpotLightRange"),hr.sceneUniformMap.addShaderUniform(hr.SPOTLIGHTRANGE,"u_SpotLightRange",t.ShaderDataType.Float),hr.SPOTLIGHTCOLOR=t.Shader3D.propertyNameToID("u_SpotLightColor"),hr.sceneUniformMap.addShaderUniform(hr.SPOTLIGHTCOLOR,"u_SpotLightColor",t.ShaderDataType.Vector3),hr.SPOTLIGHTMODE=t.Shader3D.propertyNameToID("u_SpotLightMode"),hr.sceneUniformMap.addShaderUniform(hr.SPOTLIGHTMODE,"u_SpotLightMode",t.ShaderDataType.Int)}static __init__(){if(t.Config3D._multiLighting){const a=4;var e=t.Config3D.maxLightCount,r=t.Config3D.lightClusterCount;le.instance=new le(r.x,r.y,r.z,Math.min(t.Config3D.maxLightCount,t.Config3D._maxAreaLightCountPerClusterAverage)),hr._lightTexture=Z._createFloatTextureBuffer(a,e),hr._lightTexture.lock=!0,hr._lightPixles=new Float32Array(e*a*4)}hr.shaderValueInit();var a=t.Shader3D._configDefineValues;t.Config3D._multiLighting||(a.add(t.Shader3D.SHADERDEFINE_LEGACYSINGALLIGHTING),hr.legacyLightingValueInit()),hr._shadowCasterPass=new Tt,t.Config._uniformBlock&&a.add(t.Shader3D.SHADERDEFINE_ENUNIFORMBLOCK),t.LayaGL.renderEngine.getCapable(t.RenderCapable.TextureFormat_R32G32B32A32)&&a.add(t.Shader3D.SHADERDEFINE_FLOATTEXTURE),t.LayaGL.renderEngine.getCapable(t.RenderCapable.Texture_FloatLinearFiltering)&&a.add(t.Shader3D.SHADERDEFINE_FLOATTEXTURE_FIL_LINEAR),t.LayaGL.renderEngine.getCapable(t.RenderCapable.StorageBuffer)&&a.add(t.Shader3D.SHADERDEFINE_STORAGEBUFFER)}static load(e,r){t.ILaya.loader.load(e).then(e=>{if(r){let a;if(e){let r=e.create();a=r instanceof t.Scene?r._scene3D:r}r.runWith([a])}})}get scene2D(){return this._scene2D}get sceneRenderableManager(){return this._sceneRenderManager}set sceneRenderableManager(e){e.list=this._sceneRenderManager.list,this._sceneRenderManager=e}get enableFog(){return this._enableFog}set enableFog(e){this._enableFog!==e&&(this._enableFog=e,e?this._shaderValues.addDefine(Ue.SHADERDEFINE_FOG):this._shaderValues.removeDefine(Ue.SHADERDEFINE_FOG))}get fogMode(){return this._fogMode}set fogMode(t){switch(this._fogMode=t,t){case e.FogMode.Linear:this._shaderValues.addDefine(Ue.SHADERDEFINE_FOG_LINEAR),this._shaderValues.removeDefine(Ue.SHADERDEFINE_FOG_EXP),this._shaderValues.removeDefine(Ue.SHADERDEFINE_FOG_EXP2);break;case e.FogMode.EXP:this._shaderValues.addDefine(Ue.SHADERDEFINE_FOG_EXP),this._shaderValues.removeDefine(Ue.SHADERDEFINE_FOG_LINEAR),this._shaderValues.removeDefine(Ue.SHADERDEFINE_FOG_EXP2);break;case e.FogMode.EXP2:this._shaderValues.addDefine(Ue.SHADERDEFINE_FOG_EXP2),this._shaderValues.removeDefine(Ue.SHADERDEFINE_FOG_LINEAR),this._shaderValues.removeDefine(Ue.SHADERDEFINE_FOG_EXP)}}get fogColor(){return this._shaderValues.getColor(hr.FOGCOLOR)}set fogColor(e){this._shaderValues.setColor(hr.FOGCOLOR,e)}get fogStart(){return this._fogParams.x}set fogStart(e){this._fogParams.x=e,this.fogParams=this._fogParams}get fogEnd(){return this._fogParams.y}set fogEnd(e){this._fogParams.y=e,this.fogParams=this._fogParams}get fogDensity(){return this._fogParams.z}set fogDensity(e){this._fogParams.z=e,this.fogParams=this._fogParams}get fogParams(){return this._shaderValues.getVector(hr.FOGPARAMS)}set fogParams(e){this._shaderValues.setVector(hr.FOGPARAMS,e)}get GIRotate(){return this._shaderValues.getNumber(hr.GIRotate)}set GIRotate(e){this._shaderValues.setNumber(hr.GIRotate,e)}get ambientMode(){return this._sceneReflectionProb.ambientMode}set ambientMode(e){this._sceneReflectionProb.ambientMode=e}get sceneReflectionProb(){return this._sceneReflectionProb}set sceneReflectionProb(e){this._sceneReflectionProb=e}get ambientColor(){return this._sceneReflectionProb.ambientColor}set ambientColor(e){this._sceneReflectionProb.ambientColor=e}get ambientIntensity(){return this._sceneReflectionProb.ambientIntensity}set ambientIntensity(e){this._sceneReflectionProb.ambientIntensity=e}get reflectionIntensity(){return this._sceneReflectionProb.reflectionIntensity}set reflectionIntensity(e){this._sceneReflectionProb.reflectionIntensity=e}get ambientSH(){return this._sceneReflectionProb.ambientSH}set ambientSH(e){this._sceneReflectionProb.ambientSH=e}get iblTex(){return this._sceneReflectionProb.iblTex}set iblTex(e){this._sceneReflectionProb.iblTex=e}get iblTexRGBD(){return this._sceneReflectionProb.iblTexRGBD}set iblTexRGBD(e){this._sceneReflectionProb.iblTexRGBD=e}get skyRenderer(){return this._skyRenderer}get physicsSimulation(){return this._physicsManager}get timer(){return this._timer}set timer(e){this._timer=e}get lightmaps(){return this._lightmaps.slice()}set lightmaps(e){var t=this._lightmaps;if(t)for(var r=0,a=t.length;r<a;r++){(n=t[r]).lightmapColor&&n.lightmapColor._removeReference(),n.lightmapDirection&&n.lightmapDirection._removeReference()}if(e){var i=e.length;for(t.length=i,r=0;r<i;r++){var n;(n=e[r]).lightmapColor&&n.lightmapColor._addReference(),n.lightmapDirection&&n.lightmapDirection._addReference(),t[r]=n}}else t.length=0;this._sceneModuleData.lightmapDirtyFlag=hr._updateMark}get shadowMapFrequency(){return this._ShadowMapupdateFrequency}set shadowMapFrequency(e){this._ShadowMapupdateFrequency=e}constructor(){super(),this._reflectionsSource=0,this._reflectionsResolution="256",this._reflectionsIblSamples=128,this._lightCount=0,this._pointLights=new Oe,this._spotLights=new Oe,this._directionLights=new Oe,this._alternateLights=new be,this._lightmaps=[],this._skyRenderer=new Be,this._time=0,this._physicsStepTime=0,this._sunColor=new t.Color(1,1,1),this._sundir=new t.Vector3,this._collsionTestList=[],this._key=new t.SubmitKey,this._cameraPool=[],this._UI3DManager=new sr,this.currentCreationLayer=Math.pow(2,0),this.enableLight=!0,this._ShadowMapupdateFrequency=1,this.componentElementMap=new Map,this._componentElementDatasMap={},this._nodeType=1,this._componentDriver=new t.ComponentDriver,this._timer=t.ILaya.timer,this._sceneModuleData=T.Render3DModuleDataFactory.createSceneModuleData(),t.LayaEnv.isConch&&2!=window.conchConfig.getGraphicsAPI()&&(this._nativeObj=new window.conchSubmitScene3D(this.renderSubmit.bind(this))),t.ILaya.Laya3D.enablePhysics&&(this._physicsManager=t.ILaya.Laya3D.PhysicsCreateUtil.createPhysicsManger(hr.physicsSettings)),this._shaderValues=t.LayaGL.renderDeviceFactory.createShaderData(null),this._shaderValues.addDefines(t.Shader3D._configDefineValues),this._fogParams=new t.Vector4(300,1e3,.01,0),this.enableFog=!1,this.fogStart=300,this.fogEnd=1e3,this.fogDensity=.01,this.fogColor=new t.Color(.7,.7,.7),this.fogMode=e.FogMode.Linear,this.GIRotate=0,this._scene=this,this._sceneRenderManager=new nr,t.Config3D.debugFrustumCulling,this._volumeManager=new H,this._UI3DManager=new sr,this.sceneReflectionProb=this._volumeManager.reflectionProbeManager.sceneReflectionProbe,this._sceneReflectionProb.reflectionIntensity=1,this.ambientColor=new t.Color(.212,.227,.259),hr.componentManagerMap.forEach((e,t)=>{this.componentElementMap.set(t,new e)})}get componentElementDatasMap(){return this._componentElementDatasMap}set componentElementDatasMap(e){this._componentElementDatasMap=e,this.componentElementMap.forEach((e,t)=>{e.Init(this._componentElementDatasMap[t])})}_setStructParent(e){let t=this._struct;if(t.parent&&(t.parent.removeChild(t),t.parent=null),e&&e._struct)if(e.is3D)e._struct.addChild(t,e._struct.children.length);else{let r=e._children.indexOf(this);e._struct.addChild(t,r)}}_update(){var e=this.timer.delta/1e3;if(this._time+=e,this._shaderValues.setNumber(hr.TIME,this._time),t.LayaEnv.isPlaying){this._physicsStepTime+=e;let r=Math.floor(this._physicsStepTime/hr.physicsSettings.fixedTimeStep);if(r=Math.min(r,hr.physicsSettings.maxSubSteps),r>0){let e=this._physicsManager;t.ILaya.Laya3D.enablePhysics&&t.Stat.enablePhysicsUpdate&&e.update(r*hr.physicsSettings.fixedTimeStep),this._physicsStepTime-=r*hr.physicsSettings.fixedTimeStep}}this._componentDriver.callStart(),this._componentDriver.callUpdate(),this._componentDriver.callLateUpdate(),this._componentDriver.callDestroy(),this._volumeManager.needreCaculateAllRenderObjects()?this._volumeManager.reCaculateAllRenderObjects(this._sceneRenderManager.list):this._volumeManager.handleMotionlist(),this.componentElementMap.forEach(t=>{t.update(e)}),this._componentDriver.callAfterSceneUpdate(),this._sceneRenderManager.renderUpdate(),this.skyRenderer.renderUpdate(J._instance),this._renderByEditor||this._UI3DManager.update()}_binarySearchIndexInCameraPool(e){for(var t,r=0,a=this._cameraPool.length-1;r<=a;){t=Math.floor((r+a)/2);var i=this._cameraPool[t]._renderingOrder;if(i==e._renderingOrder)return t;i>e._renderingOrder?a=t-1:r=t+1}return r}_getGroup(){return this._group}_setGroup(e){this._group=e}_onActive(){super._onActive(),t.ILaya.stage._scene3Ds.push(this)}_onInActive(){super._onInActive();var e=t.ILaya.stage._scene3Ds;e.splice(e.indexOf(this),1)}_getLightTexture(){return hr._lightTexture}_getLightPixels(){return hr._lightPixles}_prepareSceneToRender(){var e=this._shaderValues;if(t.Config3D._multiLighting&&t.Stat.enableMulLight){var r=this._getLightTexture(),a=this._getLightPixels();const D=r.width,R=4*D;var i=0,n=t.Stat.enableLight?this._directionLights._length:0,s=this._directionLights._elements;if(n>0){var o=this._directionLights.getBrightestLight();this._mainDirectionLight=s[o],this._directionLights.normalLightOrdering(o);for(var l=0;l<n;l++,i++){var h=(A=s[l]).direction,d=R*i;(S=A._intensityColor).x=t.Color.gammaToLinearSpace(A.color.r),S.y=t.Color.gammaToLinearSpace(A.color.g),S.z=t.Color.gammaToLinearSpace(A.color.b),t.Vector3.scale(S,A._intensity,S),A.owner.transform.worldMatrix.getForward(h),t.Vector3.normalize(h,h),a[d]=S.x,a[d+1]=S.y,a[d+2]=S.z,a[d+3]=A._lightmapBakedType,a[d+4]=h.x,a[d+5]=h.y,a[d+6]=h.z,0===l&&(this._sunColor=A.color,this._sundir=h)}e.addDefine(Ue.SHADERDEFINE_DIRECTIONLIGHT)}else e.removeDefine(Ue.SHADERDEFINE_DIRECTIONLIGHT),this._mainDirectionLight=null;var c=t.Stat.enableLight?this._pointLights._length:0;if(c>0){var u=this._pointLights._elements,_=this._pointLights.getBrightestLight();this._mainPointLight=u[_],this._pointLights.normalLightOrdering(_);for(l=0;l<c;l++,i++){var f=(E=u[l]).owner.transform.position;d=R*i;(S=E._intensityColor).x=t.Color.gammaToLinearSpace(E.color.r),S.y=t.Color.gammaToLinearSpace(E.color.g),S.z=t.Color.gammaToLinearSpace(E.color.b),t.Vector3.scale(S,E._intensity,S),a[d]=S.x,a[d+1]=S.y,a[d+2]=S.z,a[d+3]=E.range,a[d+4]=f.x,a[d+5]=f.y,a[d+6]=f.z,a[d+7]=E._lightmapBakedType}e.addDefine(Ue.SHADERDEFINE_POINTLIGHT)}else e.removeDefine(Ue.SHADERDEFINE_POINTLIGHT),this._mainPointLight=null;var m=t.Stat.enableLight?this._spotLights._length:0;if(m>0){var g=this._spotLights._elements,p=this._spotLights.getBrightestLight();this._mainSpotLight=g[p],this._spotLights.normalLightOrdering(p);for(l=0;l<m;l++,i++){var S,T=g[l];h=T.direction,f=T.owner.transform.position,d=R*i;(S=T._intensityColor).x=t.Color.gammaToLinearSpace(T.color.r),S.y=t.Color.gammaToLinearSpace(T.color.g),S.z=t.Color.gammaToLinearSpace(T.color.b),t.Vector3.scale(S,T._intensity,S),T.owner.transform.worldMatrix.getForward(h),t.Vector3.normalize(h,h),a[d]=S.x,a[d+1]=S.y,a[d+2]=S.z,a[d+3]=T.range,a[d+4]=f.x,a[d+5]=f.y,a[d+6]=f.z,a[d+7]=T.spotAngle*Math.PI/180,a[d+8]=h.x,a[d+9]=h.y,a[d+10]=h.z,a[d+11]=T._lightmapBakedType}e.addDefine(Ue.SHADERDEFINE_SPOTLIGHT)}else e.removeDefine(Ue.SHADERDEFINE_SPOTLIGHT),this._mainSpotLight=null;i>0&&r.setSubPixelsData(0,0,D,i,a,0,!1,!1,!1),e.setTexture(hr.LIGHTBUFFER,r),e.setInt(hr.DIRECTIONLIGHTCOUNT,this._directionLights._length),e.setTexture(hr.CLUSTERBUFFER,le.instance._clusterTexture)}else{if(hr.LIGHTDIRECTION||hr.legacyLightingValueInit(),this._directionLights._length>0&&t.Stat.enableLight){var A=this._directionLights._elements[0];this._mainDirectionLight=A,A._intensityColor.x=t.Color.gammaToLinearSpace(A.color.r),A._intensityColor.y=t.Color.gammaToLinearSpace(A.color.g),A._intensityColor.z=t.Color.gammaToLinearSpace(A.color.b),t.Vector3.scale(A._intensityColor,A._intensity,A._intensityColor),A.owner.transform.worldMatrix.getForward(A.direction),t.Vector3.normalize(A.direction,A.direction),e.setVector3(hr.LIGHTDIRCOLOR,A._intensityColor),e.setVector3(hr.LIGHTDIRECTION,A.direction),e.setInt(hr.LIGHTMODE,A._lightmapBakedType),0===l&&(this._sunColor=A.color,this._sundir=A.direction),e.addDefine(Ue.SHADERDEFINE_DIRECTIONLIGHT)}else e.removeDefine(Ue.SHADERDEFINE_DIRECTIONLIGHT);if(this._pointLights._length>0&&t.Stat.enableLight){var E=this._pointLights._elements[0];this._mainPointLight=E,E._intensityColor.x=t.Color.gammaToLinearSpace(E.color.r),E._intensityColor.y=t.Color.gammaToLinearSpace(E.color.g),E._intensityColor.z=t.Color.gammaToLinearSpace(E.color.b),t.Vector3.scale(E._intensityColor,E._intensity,E._intensityColor),e.setVector3(hr.POINTLIGHTCOLOR,E._intensityColor),e.setVector3(hr.POINTLIGHTPOS,E.owner.transform.position),e.setNumber(hr.POINTLIGHTRANGE,E.range),e.setInt(hr.POINTLIGHTMODE,E._lightmapBakedType),e.addDefine(Ue.SHADERDEFINE_POINTLIGHT)}else e.removeDefine(Ue.SHADERDEFINE_POINTLIGHT);if(this._spotLights._length>0&&t.Stat.enableLight){var D=this._spotLights._elements[0];this._mainSpotLight=D,D._intensityColor.x=t.Color.gammaToLinearSpace(D.color.r),D._intensityColor.y=t.Color.gammaToLinearSpace(D.color.g),D._intensityColor.z=t.Color.gammaToLinearSpace(D.color.b),t.Vector3.scale(D._intensityColor,D._intensity,D._intensityColor),e.setVector3(hr.SPOTLIGHTCOLOR,D._intensityColor),e.setVector3(hr.SPOTLIGHTPOS,D.owner.transform.position),D.owner.transform.worldMatrix.getForward(D.direction),t.Vector3.normalize(D.direction,D.direction),e.setVector3(hr.SPOTLIGHTDIRECTION,D.direction),e.setNumber(hr.SPOTLIGHTRANGE,D.range),e.setNumber(hr.SPOTLIGHTSPOTANGLE,D.spotAngle*Math.PI/180),e.setInt(hr.SPOTLIGHTMODE,D._lightmapBakedType),e.addDefine(Ue.SHADERDEFINE_SPOTLIGHT)}else e.removeDefine(Ue.SHADERDEFINE_SPOTLIGHT)}}get cullInfoCamera(){return this._cullInfoCamera}_setCullCamera(e){this._cullInfoCamera=e,e?this.skyRenderer.setRenderElement(e.skyRenderElement):this.skyRenderer.setRenderElement(null)}recaculateCullCamera(){this._setCullCamera(this._cameraPool[0]),this._cameraPool.forEach(e=>{this.cullInfoCamera.maxlocalYDistance<e.maxlocalYDistance&&this._setCullCamera(e)})}_addCamera(e){for(var t=this._binarySearchIndexInCameraPool(e),r=e._renderingOrder,a=this._cameraPool.length;t<a&&this._cameraPool[t]._renderingOrder<=r;)t++;this._cameraPool.splice(t,0,e)}_removeCamera(e){this._cameraPool.splice(this._cameraPool.indexOf(e),1)}_addRenderObject(e){this._sceneRenderManager.addRenderObject(e),e._inRenderList=!0,e._addReflectionProbeUpdate()}_removeRenderObject(e){e._inRenderList=!1,this._sceneRenderManager.removeRenderObject(e)}_setBelongScene(e){}destroy(e=!0){if(!this._destroyed){super.destroy(e),this._skyRenderer.destroy(),this._skyRenderer=null,this._directionLights=null,this._pointLights=null,this._spotLights=null,this._alternateLights=null,J._instance.scene==this&&(J._instance.scene=null),this._shaderValues.destroy(),this._shaderValues=null,this.sceneRenderableManager.destroy(),this._sceneRenderManager=null,this._cameraPool=null,this._physicsManager&&this._physicsManager.destroy();var t=this._lightmaps;if(t)for(var r=0,a=t.length;r<a;r++){var i=t[r];i.lightmapColor&&i.lightmapColor._removeReference(),i.lightmapDirection&&i.lightmapDirection._removeReference()}this._lightmaps=null,this._volumeManager.destroy(),this._componentDriver.callDestroy(),this.componentElementMap.forEach(e=>{e.destroy()}),this.componentElementMap.clear()}}getComponentElementManager(e){return this.componentElementMap.get(e)}renderSubmit(){if(!(this._children.length<=0||this._renderByEditor)){var e,r;for(this._prepareSceneToRender(),hr._updateMark++,t.LayaEnv.isModernAPIs&&this._prepareLayaXActiveCameras(),e=0,r=this._cameraPool.length;e<r;e++){var a=this._cameraPool[e];a.enableRender&&a.activeInHierarchy&&(a.renderTarget?a.enableBuiltInRenderTexture||(a.enableBuiltInRenderTexture=!1):a.enableBuiltInRenderTexture||(a.enableBuiltInRenderTexture=!0),a.render(this),a._offScreenRenderTexture||this.blitMainCanvas(a._internalRenderTexture,a.normalizedViewport,a),a._aftRenderMainPass())}t.RenderTexture.clearPool()}}_prepareLayaXActiveCameras(){const e=window.conchLayaXCameraNodeData;if(!e||!e.prepareActiveCameras)return;let t=hr._layaxActiveCameraHandles,r=0;for(let e=0,a=this._cameraPool.length;e<a;e++){const a=this._cameraPool[e];if(!a.enableRender||!a.activeInHierarchy)continue;const i=a._renderDataModule,n=i?i.handle:0;if(n){if(r>=t.length){const e=new Float64Array(t.length<<1);e.set(t),t=e,hr._layaxActiveCameraHandles=t}t[r++]=n}}r>0&&e.prepareActiveCameras(t.buffer,r)}blitMainCanvas(e,r,a){if(e){hr.mainCavansViewPort.x=J.clientWidth*r.x|0,hr.mainCavansViewPort.y=J.clientHeight*r.y|0,hr.mainCavansViewPort.width=J.clientWidth*r.width|0,hr.mainCavansViewPort.height=J.clientHeight*r.height|0,e.filterMode=t.FilterMode.Bilinear,a.fxaa&&ir.shaderdata.addDefine(Ne.SHADERDEFINE_FXAA);var i=ir.create(e,null,hr.mainCavansViewPort,null,null,ir.shaderdata);i.run(),i.recover(),t.RenderTexture2D._clear=!1,ir.shaderdata.removeDefine(Ne.SHADERDEFINE_FXAA)}}setGlobalShaderValue(e,r,a){var i=t.Shader3D.propertyNameToID(e);this._shaderValues.setShaderData(i,r,a)}get fogRange(){return this._fogParams.y-this.fogParams.x}set fogRange(e){this._fogParams.y=e+this.fogParams.x,this.fogParams=this._fogParams}setlightmaps(e){for(var t=this._lightmaps,r=0,a=t.length;r<a;r++)t[r].lightmapColor._removeReference();if(!e)throw new Error("lightmap can't be null.");var i=e.length;for(t.length=i,r=0;r<i;r++){var n=e[r];n._addReference(),t[r]||(t[r]=new Ve),t[r].lightmapColor=n}}getlightmaps(){for(var e=new Array(this._lightmaps.length),t=0;t<this._lightmaps.length;t++)e[t]=this._lightmaps[t].lightmapColor;return e}}hr.physicsSettings=new pe,hr._layaxActiveCameraHandles=new Float64Array(8),hr.mainCavansViewPort=new t.Viewport(0,0,1,1),hr.componentManagerMap=new Map,t.Profiler.enabled&&(hr.prototype._update=function(){var e=this.timer.delta/1e3;if(this._time+=e,this._shaderValues.setNumber(hr.TIME,this._time),t.LayaEnv.isPlaying){this._physicsStepTime+=e;let r=Math.floor(this._physicsStepTime/hr.physicsSettings.fixedTimeStep);if(r=Math.min(r,hr.physicsSettings.maxSubSteps),r>0){let e=this._physicsManager;t.ILaya.Laya3D.enablePhysics&&t.Stat.enablePhysicsUpdate&&e.update(r*hr.physicsSettings.fixedTimeStep),this._physicsStepTime-=r*hr.physicsSettings.fixedTimeStep}}let r=t.Profiler.start("scene/component_driver");try{this._componentDriver.callStart(),this._componentDriver.callUpdate(),this._componentDriver.callLateUpdate(),this._componentDriver.callDestroy()}finally{t.Profiler.end(r)}r=t.Profiler.start("scene/volume_update");try{this._volumeManager.needreCaculateAllRenderObjects()?this._volumeManager.reCaculateAllRenderObjects(this._sceneRenderManager.list):this._volumeManager.handleMotionlist()}finally{t.Profiler.end(r)}r=t.Profiler.start("scene/component_elements_update");try{this.componentElementMap.forEach(t=>{t.update(e)}),this._componentDriver.callAfterSceneUpdate()}finally{t.Profiler.end(r)}this._sceneRenderManager.renderUpdate(),this.skyRenderer.renderUpdate(J._instance),this._renderByEditor||this._UI3DManager.update()});class dr extends Ce{static __init__(){dr.instance=new dr}constructor(){super(t.MeshTopology.Triangles,t.DrawType.DrawElementInstance),this.instanceWorldMatrixData=new Float32Array(20*dr.maxInstanceCount),this.instanceSimpleAnimatorData=new Float32Array(4*dr.maxInstanceCount),this.indexFormat=t.IndexFormat.UInt16,this.instanceWorldMatrixBuffer=T.renderOBJCreate.createVertexBuffer3D(4*this.instanceWorldMatrixData.length,t.BufferUsage.Dynamic,!1),this.instanceWorldMatrixBuffer.vertexDeclaration=t.VertexMesh.instanceWorldMatrixDeclaration,this.instanceWorldMatrixBuffer.instanceBuffer=!0,this.instanceSimpleAnimatorBuffer=T.renderOBJCreate.createVertexBuffer3D(4*this.instanceSimpleAnimatorData.length,t.BufferUsage.Dynamic,!1),this.instanceSimpleAnimatorBuffer.vertexDeclaration=t.VertexMesh.instanceSimpleAnimatorDeclaration,this.instanceSimpleAnimatorBuffer.instanceBuffer=!0}_updateRenderParams(e){}}dr.maxInstanceCount=1024;class cr{get indexType(){return this._indexType}get indexTypeByteCount(){return this._indexTypeByteCount}get indexCount(){return this._indexCount}get canRead(){return this._canRead}constructor(e,r,a=t.BufferUsage.Static,i=!1){switch(this._indexType=t.IndexFormat.UInt16,this._deviceBuffer=t.LayaGL.renderDeviceFactory.createIndexBuffer(a),this._deviceBuffer.indexType=this._indexType=e,this._deviceBuffer.indexCount=this._indexCount=r,this._canRead=i,this.bufferUsage=a,e){case t.IndexFormat.UInt32:this._indexTypeByteCount=4;break;case t.IndexFormat.UInt16:this._indexTypeByteCount=2;break;case t.IndexFormat.UInt8:this._indexTypeByteCount=1;break;default:throw new Error("unknown index type: "+e)}var n=this._indexTypeByteCount*r;if(this._byteLength=n,this._deviceBuffer._setIndexDataLength(n),i)switch(e){case t.IndexFormat.UInt32:this._buffer=new Uint32Array(r);break;case t.IndexFormat.UInt16:this._buffer=new Uint16Array(r);break;case t.IndexFormat.UInt8:this._buffer=new Uint8Array(r)}}setData(e,r=0,a=0,i=4294967295){var n=this._indexTypeByteCount;const s=0!==a||4294967295!==i;if(s)switch(this._indexType){case t.IndexFormat.UInt32:e=new Uint32Array(e.buffer,(e.byteOffset||0)+a*n,i);break;case t.IndexFormat.UInt16:e=new Uint16Array(e.buffer,(e.byteOffset||0)+a*n,i);break;case t.IndexFormat.UInt8:e=new Uint8Array(e.buffer,(e.byteOffset||0)+a*n,i)}if(this._canRead){let t;if(0!==r||s||e.length!==this._buffer.length){var o=this._buffer.length-r;if(t=s?i:e.length,t>o&&(t=o),typeof e==typeof this._buffer&&e.length==t)this._buffer.set(e,r);else for(var l=0;l<t;l++)this._buffer[r+l]=e[l]}else this._buffer=e,t=e.length;const a=r*n,h=a+t*n,d=4*Math.floor(a/4),c=Math.min(4*Math.ceil(h/4),this._byteLength);this._deviceBuffer.setData(this._buffer.buffer,d,this._buffer.byteOffset+d,c-d)}else this._deviceBuffer._setIndexData(e,r*n)}getData(){if(this._canRead)return this._buffer;throw new t.NotReadableError}destroy(){this._deviceBuffer.destroy(),this._buffer=null,this._byteLength=0,this._indexCount=0}}class ur{get vertexDeclaration(){return this._deviceBuffer.vertexDeclaration}set vertexDeclaration(e){this._deviceBuffer.vertexDeclaration=e}get instanceBuffer(){return this._deviceBuffer.instanceBuffer}set instanceBuffer(e){this._deviceBuffer.instanceBuffer=e}get canRead(){return this._canRead}constructor(e,r,a=!1){this._float32Reader=null,this._deviceBuffer=t.LayaGL.renderDeviceFactory.createVertexBuffer(r),this._canRead=a,this._byteLength=e,this._deviceBuffer.setDataLength(e),this.bufferUsage=r,this._canRead&&(this._buffer=new Uint8Array(e),this._float32Reader=new Float32Array(this._buffer.buffer))}setData(e,t=0,r=0,a=Number.MAX_SAFE_INTEGER){if(this._deviceBuffer.setData(e,t,r,a),0!==r||a!==Number.MAX_SAFE_INTEGER){var i=new Uint8Array(e,r,a);this._canRead&&this._buffer.set(i,t)}else this._canRead&&this._buffer.set(new Uint8Array(e),t)}getUint8Data(){if(this._canRead)return this._buffer;throw new t.NotReadableError}getFloat32Data(){if(this._canRead)return this._float32Reader;throw new t.NotReadableError}markAsUnreadbale(){this._canRead=!1,this._buffer=null,this._float32Reader=null}destroy(){this._deviceBuffer.destroy(),this._buffer=null,this._float32Reader=null,this._byteLength=0}}class _r extends W{static create(){let e=_r._pool.take();return e._isInPool=!1,e.clear(),e}constructor(){super(),this._InvertFront=!1,this.setGeometry(new Vt(null)),this._instanceBatchElementList=new t.FastSinglelist,this._isUpdataData=!0,this._invertFrontFace=!1}getInvertFront(){return this._invertFrontFace}set InvertFront(e){this._InvertFront=e}_createRenderElementOBJ(){}compileShader(e){this._subShader._passes}_renderUpdatePre(e){}updateInstanceData(e){}clear(){this._instanceBatchElementList.length=0}recover(){}}_r.maxInstanceCount=1024,_r._pool=t.Pool.createPool(_r);class fr extends Ce{get indexCount(){return this._indexCount}constructor(e){super(t.MeshTopology.Triangles,t.DrawType.DrawElement),this.indexFormat=e.indexFormat,e.indexFormat!==t.IndexFormat.UInt32||t.LayaGL.renderEngine.getCapable(t.RenderCapable.Element_Index_Uint32)?(this._mesh=e,this._boneIndicesList=[],this._subIndexBufferStart=[],this._subIndexBufferCount=[],this.bufferState=e._bufferState):console.warn("SubMesh:this device do not support IndexFormat.UInt32.")}_setIndexRange(e,r,a=t.IndexFormat.UInt16){this._indexStart=e,this._indexCount=r,this._indexBuffer.canRead&&(a==t.IndexFormat.UInt16?this._indices=new Uint16Array(this._indexBuffer.getData().buffer,2*e,r):this._indices=new Uint32Array(this._indexBuffer.getData().buffer,4*e,r))}_getType(){return fr._type}_prepareRender(e){return this._mesh._uploadVerticesData(),!0}_updateRenderParams(e){var r;switch(this._mesh._indexFormat){case t.IndexFormat.UInt32:r=4;break;case t.IndexFormat.UInt16:r=2;break;case t.IndexFormat.UInt8:r=1}if(this.clearRenderParams(),this._boneIndicesList&&this._boneIndicesList.length>1)for(var a=0,i=this._boneIndicesList.length;a<i;a++)this.setDrawElemenParams(this._subIndexBufferCount[a],this._subIndexBufferStart[a]*r);else this.setDrawElemenParams(this._indexCount,this._indexStart*r)}getIndices(){if(this._mesh._isReadable)return this._indices.slice();throw new t.NotReadableError}setIndices(e){this._indexBuffer.setData(e,this._indexStart,0,this._indexCount)}destroy(){this._destroyed||(super.destroy(),this._indexBuffer=null,this._vertexBuffer=null,this._mesh=null,this._boneIndicesList=null,this._subIndexBufferStart=null,this._subIndexBufferCount=null)}}fr._type=Ce._typeCounter++,e.EPhysicsCapable=void 0,(lr=e.EPhysicsCapable||(e.EPhysicsCapable={}))[lr.Physics_Gravity=0]="Physics_Gravity",lr[lr.Physics_StaticCollider=1]="Physics_StaticCollider",lr[lr.Physics_DynamicCollider=2]="Physics_DynamicCollider",lr[lr.Physics_CharacterCollider=3]="Physics_CharacterCollider",lr[lr.Physics_BoxColliderShape=4]="Physics_BoxColliderShape",lr[lr.Physics_SphereColliderShape=5]="Physics_SphereColliderShape",lr[lr.Physics_CapsuleColliderShape=6]="Physics_CapsuleColliderShape",lr[lr.Physics_CylinderColliderShape=7]="Physics_CylinderColliderShape",lr[lr.Physics_ConeColliderShape=8]="Physics_ConeColliderShape",lr[lr.Physics_MeshColliderShape=9]="Physics_MeshColliderShape",lr[lr.Physics_CompoundColliderShape=10]="Physics_CompoundColliderShape",lr[lr.Physics_CreateCorveMesh=11]="Physics_CreateCorveMesh",lr[lr.physics_heightFieldColliderShape=12]="physics_heightFieldColliderShape",lr[lr.Physics_Joint=13]="Physics_Joint",lr[lr.Physics_FixedJoint=14]="Physics_FixedJoint",lr[lr.Physics_SpringJoint=15]="Physics_SpringJoint",lr[lr.Physics_HingeJoint=16]="Physics_HingeJoint",lr[lr.Physics_D6Joint=17]="Physics_D6Joint",lr[lr.Physics_VehicleSystem=18]="Physics_VehicleSystem";class mr{constructor(e,t,r){this.subMeshIndex=e,this.batchIndex=t,this.batchBoneIndex=r}}class gr extends t.Resource{static load(e,r){t.ILaya.loader.load(e,r,null,t.Loader.MESH)}get inverseAbsoluteBindPoses(){return this._inverseBindPoses}get vertexCount(){return this._vertexCount}get indexCount(){return this._indexBuffer.indexCount}get subMeshCount(){return this._subMeshes.length}get bounds(){return this._bounds}set bounds(e){this._bounds!==e&&e.cloneTo(this._bounds)}get indexFormat(){return this._indexFormat}get vertexBuffer(){return this._vertexBuffer}get indexBuffer(){return this._indexBuffer}set indexFormat(e){this._indexFormat=e,this._subMeshes.forEach(t=>{t.indexFormat=e})}constructor(e=!0){super(),this._minVerticesUpdate=-1,this._maxVerticesUpdate=-1,this._needUpdateBounds=!0,this._bufferState=new t.BufferState,this._instanceBufferStateType=0,this._vertexBuffer=null,this._indexBuffer=null,this._skinnedMatrixCaches=[],this._vertexCount=0,this._indexFormat=t.IndexFormat.UInt16,this._bounds=new M(new t.Vector3,new t.Vector3),this._isReadable=e,this._subMeshes=[],this.destroyedImmediately=t.Config.destroyResourceImmediatelyDefault}_getPositionElement(e){for(var r=e.vertexDeclaration._vertexElements,a=0,i=r.length;a<i;a++){var n=r[a];if(n._elementFormat===t.VertexElementFormat.Vector3&&n._elementUsage===t.VertexMesh.MESH_POSITION0)return n}return null}_getVerticeElementData(e,r){e.length=this._vertexCount;var a=this._vertexBuffer.vertexDeclaration,i=a.getVertexElementByUsage(r);if(i){var n=this._vertexBuffer.getUint8Data(),s=this._vertexBuffer.getFloat32Data(),o=a.vertexStride,l=o/4,h=i._offset,d=h/4;switch(r){case t.VertexMesh.MESH_TEXTURECOORDINATE0:case t.VertexMesh.MESH_TEXTURECOORDINATE1:for(var c=0;c<this._vertexCount;c++){var u=l*c+d;e[c]=new t.Vector2(s[u],s[u+1])}break;case t.VertexMesh.MESH_POSITION0:case t.VertexMesh.MESH_NORMAL0:for(c=0;c<this._vertexCount;c++){u=l*c+d;e[c]=new t.Vector3(s[u],s[u+1],s[u+2])}break;case t.VertexMesh.MESH_TANGENT0:case t.VertexMesh.MESH_BLENDWEIGHT0:for(c=0;c<this._vertexCount;c++){u=l*c+d;e[c]=new t.Vector4(s[u],s[u+1],s[u+2],s[u+3])}break;case t.VertexMesh.MESH_COLOR0:for(c=0;c<this._vertexCount;c++){u=l*c+d;e[c]=new t.Color(s[u],s[u+1],s[u+2],s[u+3])}break;case t.VertexMesh.MESH_BLENDINDICES0:for(c=0;c<this._vertexCount;c++){u=o*c+h;e[c]=new t.Vector4(n[u],n[u+1],n[u+2],n[u+3])}break;default:throw"Mesh:Unknown elementUsage."}}}_setVerticeElementData(e,r){var a=this._vertexBuffer.vertexDeclaration,i=a.getVertexElementByUsage(r);if(i){var n=this._vertexBuffer.getUint8Data(),s=this._vertexBuffer.getFloat32Data(),o=a.vertexStride,l=o/4,h=i._offset,d=h/4;switch(r){case t.VertexMesh.MESH_TEXTURECOORDINATE0:case t.VertexMesh.MESH_TEXTURECOORDINATE1:for(var c=0,u=e.length;c<u;c++){var _=l*c+d,f=e[c];s[_]=f.x,s[_+1]=f.y}break;case t.VertexMesh.MESH_POSITION0:case t.VertexMesh.MESH_NORMAL0:for(c=0,u=e.length;c<u;c++){_=l*c+d;var m=e[c];s[_]=m.x,s[_+1]=m.y,s[_+2]=m.z}break;case t.VertexMesh.MESH_TANGENT0:case t.VertexMesh.MESH_BLENDWEIGHT0:for(c=0,u=e.length;c<u;c++){_=l*c+d;var g=e[c];s[_]=g.x,s[_+1]=g.y,s[_+2]=g.z,s[_+3]=g.w}break;case t.VertexMesh.MESH_COLOR0:for(c=0,u=e.length;c<u;c++){_=l*c+d;var p=e[c];s[_]=p.r,s[_+1]=p.g,s[_+2]=p.b,s[_+3]=p.a}break;case t.VertexMesh.MESH_BLENDINDICES0:for(c=0,u=e.length;c<u;c++){_=o*c+h,g=e[c];n[_]=g.x,n[_+1]=g.y,n[_+2]=g.z,n[_+3]=g.w}break;default:throw"Mesh:Unknown elementUsage."}this._minVerticesUpdate=0,this._maxVerticesUpdate=Number.MAX_SAFE_INTEGER,this._vertexBuffer.setData(s.buffer,0,0,s.byteLength)}else console.warn("Mesh: the mesh don't have this VertexElement.")}_disposeResource(){for(var e=0,t=this._subMeshes.length;e<t;e++)this._subMeshes[e].destroy();this._vertexBuffer&&this._vertexBuffer.destroy(),this._indexBuffer&&this._indexBuffer.destroy(),this._bufferState.destroy(),this._instanceBufferState&&this._instanceBufferState.destroy(),this._instanceWorldVertexBuffer&&this._instanceWorldVertexBuffer.destroy(),this._instanceSimpleAniVertexBuffer&&this._instanceSimpleAniVertexBuffer.destroy(),this._instanceLightMapVertexBuffer&&this._instanceLightMapVertexBuffer.destroy(),this.instanceLightMapScaleOffsetData&&(this.instanceLightMapScaleOffsetData=null),this._setCPUMemory(0),this._setGPUMemory(0),this._bufferState=null,this._instanceBufferState=null,this._vertexBuffer=null,this._indexBuffer=null,this._subMeshes=null,this._btTriangleMesh=null,this._indexBuffer=null,this._boneNames=null,this._inverseBindPoses=null,this.morphTargetData&&this.morphTargetData.destroy(),this.__convexMesh&&this.__convexMesh.destroy()}_setSubMeshes(e){this._subMeshes=e;for(var t=0,r=e.length;t<r;t++)e[t]._indexInMesh=t}_setBuffer(e,t){this._bufferState.applyState([e],t)}_setInstanceBuffer(){if(this._instanceBufferState)return;var e=this._instanceBufferState=new t.BufferState,r=this._instanceBufferStateType;let a=[];a.push(this._vertexBuffer);let i=this._instanceWorldVertexBuffer=T.renderOBJCreate.createVertexBuffer3D(16*_r.maxInstanceCount*4,t.BufferUsage.Dynamic,!1);switch(i.vertexDeclaration=t.VertexMesh.instanceWorldMatrixDeclaration,i.instanceBuffer=!0,a.push(i),r){case gr.MESH_INSTANCEBUFFER_TYPE_SIMPLEANIMATOR:let e=this._instanceSimpleAniVertexBuffer=T.renderOBJCreate.createVertexBuffer3D(4*_r.maxInstanceCount*4,t.BufferUsage.Dynamic,!1);e.vertexDeclaration=t.VertexMesh.instanceSimpleAnimatorDeclaration,e.instanceBuffer=!0,a.push(e);break;case gr.MESH_INSTANCEBUFFER_TYPE_NORMAL:if(this.getVertexDeclaration().getVertexElementByUsage(t.VertexMesh.MESH_TEXTURECOORDINATE1)){let e=this._instanceLightMapVertexBuffer=T.renderOBJCreate.createVertexBuffer3D(4*_r.maxInstanceCount*4,t.BufferUsage.Dynamic,!1);e.vertexDeclaration=t.VertexMesh.instanceLightMapScaleOffsetDeclaration,e.instanceBuffer=!0,this.instanceLightMapScaleOffsetData=new Float32Array(4*_r.maxInstanceCount),a.push(e)}}e.applyState(a,this._indexBuffer)}_uploadVerticesData(){var e=this._minVerticesUpdate,t=this._maxVerticesUpdate;if(-1!==e&&-1!==t){var r=e;this._vertexBuffer.setData(this._vertexBuffer.getUint8Data().buffer,r,r,t-e),this._minVerticesUpdate=-1,this._maxVerticesUpdate=-1}}getSubMesh(e){return this._subMeshes[e]}getPositions(e){if(!this._isReadable)throw new t.NotReadableError;this._getVerticeElementData(e,t.VertexMesh.MESH_POSITION0)}setPositions(e){if(!this._isReadable)throw new t.NotReadableError;this._setVerticeElementData(e,t.VertexMesh.MESH_POSITION0),this._needUpdateBounds=!0}getColors(e){if(!this._isReadable)throw new t.NotReadableError;this._getVerticeElementData(e,t.VertexMesh.MESH_COLOR0)}setColors(e){if(!this._isReadable)throw new t.NotReadableError;this._setVerticeElementData(e,t.VertexMesh.MESH_COLOR0)}getUVs(e,r=0){if(!this._isReadable)throw new t.NotReadableError;switch(r){case 0:this._getVerticeElementData(e,t.VertexMesh.MESH_TEXTURECOORDINATE0);break;case 1:this._getVerticeElementData(e,t.VertexMesh.MESH_TEXTURECOORDINATE1);break;default:throw"Mesh:Invalid channel."}}setUVs(e,r=0){if(!this._isReadable)throw new t.NotReadableError;switch(r){case 0:this._setVerticeElementData(e,t.VertexMesh.MESH_TEXTURECOORDINATE0);break;case 1:this._setVerticeElementData(e,t.VertexMesh.MESH_TEXTURECOORDINATE1);break;default:throw"Mesh:Invalid channel."}}getNormals(e){if(!this._isReadable)throw new t.NotReadableError;this._getVerticeElementData(e,t.VertexMesh.MESH_NORMAL0)}setNormals(e){if(!this._isReadable)throw new t.NotReadableError;this._setVerticeElementData(e,t.VertexMesh.MESH_NORMAL0)}getTangents(e){if(!this._isReadable)throw new t.NotReadableError;this._getVerticeElementData(e,t.VertexMesh.MESH_TANGENT0)}setTangents(e){if(!this._isReadable)throw new t.NotReadableError;this._setVerticeElementData(e,t.VertexMesh.MESH_TANGENT0)}getBoneWeights(e){if(!this._isReadable)throw new t.NotReadableError;this._getVerticeElementData(e,t.VertexMesh.MESH_BLENDWEIGHT0)}setBoneWeights(e){if(!this._isReadable)throw new t.NotReadableError;this._setVerticeElementData(e,t.VertexMesh.MESH_BLENDWEIGHT0)}getBoneIndices(e){if(!this._isReadable)throw new t.NotReadableError;this._getVerticeElementData(e,t.VertexMesh.MESH_BLENDINDICES0)}setBoneIndices(e){if(!this._isReadable)throw new t.NotReadableError;this._setVerticeElementData(e,t.VertexMesh.MESH_BLENDINDICES0)}markAsUnreadbale(){this._uploadVerticesData(),this._vertexBuffer.markAsUnreadbale(),this._isReadable=!1}getVertexDeclaration(){return this._vertexBuffer.vertexDeclaration}getVertices(){if(this._isReadable)return this._vertexBuffer.getUint8Data().buffer.slice(0);throw new t.NotReadableError}setVertices(e){this._vertexBuffer.setData(e),this._needUpdateBounds=!0}getIndices(){if(this._isReadable)return this._indexBuffer.getData().slice();throw new t.NotReadableError}setIndices(e){var r;e instanceof Uint32Array?r=t.IndexFormat.UInt32:e instanceof Uint16Array?r=t.IndexFormat.UInt16:e instanceof Uint8Array&&(r=t.IndexFormat.UInt8);var a=this._indexBuffer;this._indexFormat===r&&a.indexCount===e.length||(a.destroy(),this._indexBuffer=a=T.renderOBJCreate.createIndexBuffer3D(r,e.length,t.BufferUsage.Static,this._isReadable)),a.setData(e),this.indexFormat=r}calculateBounds(){if(!this._isReadable)throw new t.NotReadableError;if(this._needUpdateBounds){var e=pr,r=Sr;e.x=e.y=e.z=Number.MAX_VALUE,r.x=r.y=r.z=-Number.MAX_VALUE;for(var a=this._vertexBuffer,i=this._getPositionElement(a),n=a.getFloat32Data(),s=a.vertexDeclaration.vertexStride/4,o=i._offset/4,l=0,h=n.length;l<h;l+=s){var d=l+o,c=n[d],u=n[d+1],_=n[d+2];e.x=Math.min(e.x,c),e.y=Math.min(e.y,u),e.z=Math.min(e.z,_),r.x=Math.max(r.x,c),r.y=Math.max(r.y,u),r.z=Math.max(r.z,_)}this._bounds.setMin(e),this._bounds.setMax(r),this._needUpdateBounds=!1}}getCorveMesh(){if(null==this._convexMesh)return null;let r=t.ILaya.Laya3D._PhysicsCreateUtil;return null==this.__convexMesh&&r&&r.getPhysicsCapable(e.EPhysicsCapable.Physics_CreateCorveMesh)&&(this.__convexMesh=r.createCorveMesh(this)),this.__convexMesh}cloneTo(e){var r=this._vertexBuffer,a=T.renderOBJCreate.createVertexBuffer3D(r._byteLength,r.bufferUsage,r.canRead);a.vertexDeclaration=r.vertexDeclaration,a.setData(r.getUint8Data().slice().buffer),e._vertexBuffer=a,e._vertexCount=this._vertexCount;var i,n=this._indexBuffer,s=T.renderOBJCreate.createIndexBuffer3D(t.IndexFormat.UInt16,n.indexCount,n.bufferUsage,n.canRead);s.setData(n.getData().slice()),e._indexBuffer=s,e._setBuffer(e._vertexBuffer,s),e._instanceBufferStateType=this._instanceBufferStateType,e._setCPUMemory(this.cpuMemory),e._setGPUMemory(this.gpuMemory);var o=this._boneNames;if(o){var l=e._boneNames=[];for(i=0;i<o.length;i++)l[i]=o[i]}var h=this._inverseBindPoses;if(h){var d=e._inverseBindPoses=[];for(i=0;i<h.length;i++)d[i]=h[i]}if(this._inverseBindPosesBuffer){let t=this._inverseBindPosesBuffer.byteLength;e._inverseBindPosesBuffer=new ArrayBuffer(t),new Uint8Array(e._inverseBindPosesBuffer).set(new Uint8Array(this._inverseBindPosesBuffer))}var c=this._skinnedMatrixCaches.length;for(e._skinnedMatrixCaches.length=c,i=0;i<c;i++){var u=this._skinnedMatrixCaches[i];u&&(e._skinnedMatrixCaches[i]=new mr(u.subMeshIndex,u.batchIndex,u.batchBoneIndex))}for(i=0;i<this.subMeshCount;i++){var _=this._subMeshes[i],f=_._subIndexBufferStart,m=_._subIndexBufferCount,g=_._boneIndicesList,p=new fr(e);p._subIndexBufferStart.length=f.length,p._subIndexBufferCount.length=m.length,p._boneIndicesList.length=g.length;for(var S=0;S<f.length;S++)p._subIndexBufferStart[S]=f[S];for(S=0;S<m.length;S++)p._subIndexBufferCount[S]=m[S];for(S=0;S<g.length;S++)p._boneIndicesList[S]=new Uint16Array(g[S]);p._indexBuffer=s,p._indexStart=_._indexStart,p._indexCount=_._indexCount,p._indices=new Uint16Array(s.getData().buffer,2*_._indexStart,_._indexCount);var A=e._vertexBuffer;p._vertexBuffer=A,e._subMeshes.push(p)}e._setSubMeshes(e._subMeshes),this.morphTargetData&&(e.morphTargetData=this.morphTargetData.clone())}clone(){var e=new gr;return this.cloneTo(e),e}}gr.MESH_INSTANCEBUFFER_TYPE_NORMAL=0,gr.MESH_INSTANCEBUFFER_TYPE_SIMPLEANIMATOR=1;const pr=new t.Vector3,Sr=new t.Vector3;class Tr{static __init__(){}static _createMesh(e,r,a){var i=new gr,n=new fr(i),s=new ur(4*r.length,t.BufferUsage.Static,!0);s.vertexDeclaration=e,s.setData(r.buffer),i._vertexBuffer=s,i._vertexCount=s._byteLength/e.vertexStride;var o=new cr(t.IndexFormat.UInt16,a.length,t.BufferUsage.Static,!0);o.setData(a),i._indexBuffer=o,i._setBuffer(s,o),n._vertexBuffer=s,n._indexBuffer=o,n._setIndexRange(0,o.indexCount);var l=n._subIndexBufferStart,h=n._subIndexBufferCount,d=n._boneIndicesList;l.length=1,h.length=1,d.length=1,l[0]=0,h[0]=o.indexCount;var c=[];c.push(n),i._setSubMeshes(c),i.calculateBounds();var u=s._byteLength+o._byteLength;return i._setCPUMemory(u),i._setGPUMemory(u),i}static createBox(e=1,r=1,a=1){var i=t.VertexMesh.getVertexDeclaration("POSITION,NORMAL,UV"),n=e/2,s=r/2,o=a/2,l=new Float32Array([-n,s,-o,0,1,0,0,0,n,s,-o,0,1,0,1,0,n,s,o,0,1,0,1,1,-n,s,o,0,1,0,0,1,-n,-s,-o,0,-1,0,0,1,n,-s,-o,0,-1,0,1,1,n,-s,o,0,-1,0,1,0,-n,-s,o,0,-1,0,0,0,-n,s,-o,-1,0,0,0,0,-n,s,o,-1,0,0,1,0,-n,-s,o,-1,0,0,1,1,-n,-s,-o,-1,0,0,0,1,n,s,-o,1,0,0,1,0,n,s,o,1,0,0,0,0,n,-s,o,1,0,0,0,1,n,-s,-o,1,0,0,1,1,-n,s,o,0,0,1,0,0,n,s,o,0,0,1,1,0,n,-s,o,0,0,1,1,1,-n,-s,o,0,0,1,0,1,-n,s,-o,0,0,-1,1,0,n,s,-o,0,0,-1,0,0,n,-s,-o,0,0,-1,0,1,-n,-s,-o,0,0,-1,1,1]),h=new Uint16Array([0,1,2,2,3,0,4,7,6,6,5,4,8,9,10,10,11,8,12,15,14,14,13,12,16,17,18,18,19,16,20,23,22,22,21,20]);return Tr._createMesh(i,l,h)}static createCapsule(e=.5,r=2,a=16,i=32){var n,s,o=(a+1)*(i+1)*2+2*(i+1),l=3*a*(i+1)*2*2+2*i*3,h=t.VertexMesh.getVertexDeclaration("POSITION,NORMAL,UV"),d=h.vertexStride/4,c=new Float32Array(o*d),u=new Uint16Array(l),_=Math.PI/2/a,f=2*Math.PI/i,m=r/2-e,g=0,p=0,S=0,T=0,A=0,E=0;for(n=0;n<=a;n++)for(s=0;s<=i;s++)g=e*Math.cos(n*_)*Math.cos(s*f+Math.PI),p=e*Math.sin(n*_),S=e*Math.cos(n*_)*Math.sin(s*f+Math.PI),c[T++]=g,c[T++]=p+m,c[T++]=S,c[T++]=g,c[T++]=p,c[T++]=S,c[T++]=1-s/i,c[T++]=(1-n/a)*(Math.PI*e/2/(r+Math.PI*e)),n<a&&(u[A++]=n*(i+1)+s+(i+1),u[A++]=n*(i+1)+s,u[A++]=n*(i+1)+s+1,u[A++]=n*(i+1)+s+i,u[A++]=n*(i+1)+s,u[A++]=n*(i+1)+s+(i+1));for(E+=(a+1)*(i+1),n=0;n<=a;n++)for(s=0;s<=i;s++)g=e*Math.cos(n*_)*Math.cos(s*f+Math.PI),p=e*Math.sin(-n*_),S=e*Math.cos(n*_)*Math.sin(s*f+Math.PI),c[T++]=g,c[T++]=p-m,c[T++]=S,c[T++]=g,c[T++]=p,c[T++]=S,c[T++]=1-s/i,c[T++]=(n/a*(Math.PI*e/2)+(r+Math.PI*e/2))/(r+Math.PI*e),n<a&&(u[A++]=E+n*(i+1)+s,u[A++]=E+n*(i+1)+s+(i+1),u[A++]=E+n*(i+1)+s+1,u[A++]=E+n*(i+1)+s,u[A++]=E+n*(i+1)+s+i,u[A++]=E+n*(i+1)+s+(i+1));for(E+=(a+1)*(i+1),s=0;s<=i;s++)g=e*Math.cos(s*f+Math.PI),p=m,S=e*Math.sin(s*f+Math.PI),c[T++]=g,c[T+8*(i+1)-1]=g,c[T++]=p,c[T+8*(i+1)-1]=-p,c[T++]=S,c[T+8*(i+1)-1]=S,c[T++]=g,c[T+8*(i+1)-1]=g,c[T++]=0,c[T+8*(i+1)-1]=0,c[T++]=S,c[T+8*(i+1)-1]=S,c[T++]=1-1*s/i,c[T+8*(i+1)-1]=1-1*s/i,c[T++]=Math.PI*e/2/(r+Math.PI*e),c[T+8*(i+1)-1]=(Math.PI*e/2+r)/(r+Math.PI*e);for(s=0;s<i;s++)u[A++]=s+E+(i+1),u[A++]=s+E+1,u[A++]=s+E,u[A++]=s+E+(i+1),u[A++]=s+E+(i+1)+1,u[A++]=s+E+1;return E+=2*(i+1),Tr._createMesh(h,c,u)}static createCone(e=.5,r=1,a=32){for(var i,n=a+1+1+2*(a+1),s=6*a+3*a,o=t.VertexMesh.getVertexDeclaration("POSITION,NORMAL,UV"),l=o.vertexStride/4,h=new Float32Array(n*l),d=new Uint16Array(s),c=2*Math.PI/a,u=r/2,_=0,f=0,m=0,g=0,p=0,S=new t.Vector3,T=new t.Vector3(0,-1,0),A=new t.Vector3(0,u,0),E=new t.Vector3,D=new t.Vector3,R=new t.Quaternion,x=new t.Vector3,y=0,M=0,C=0;C<=a;C++)_=C*c,m=Math.cos(_+Math.PI)*e,g=u,p=Math.sin(_+Math.PI)*e,h[y++]=0,h[y+8*(a+1)-1]=m,h[y++]=g,h[y+8*(a+1)-1]=-g,h[y++]=0,h[y+8*(a+1)-1]=p,S.x=m,S.y=0,S.z=p,E.x=m,E.y=-g,E.z=p,t.Vector3.subtract(E,A,D),t.Vector3.normalize(D,D),i=Math.acos(t.Vector3.dot(T,D)),t.Vector3.cross(T,D,x),t.Vector3.normalize(x,x),t.Quaternion.createFromAxisAngle(x,i,R),t.Vector3.normalize(S,S),t.Vector3.transformQuat(S,R,S),t.Vector3.normalize(S,S),h[y++]=S.x,h[y+8*(a+1)-1]=S.x,h[y++]=S.y,h[y+8*(a+1)-1]=S.y,h[y++]=S.z,h[y+8*(a+1)-1]=S.z,h[y++]=1-1*C/a,h[y+8*(a+1)-1]=1-1*C/a,h[y++]=0,h[y+8*(a+1)-1]=1;y+=8*(a+1);for(var v=0;v<a;v++)d[M++]=v+f+(a+1),d[M++]=v+f+1,d[M++]=v+f,d[M++]=v+f+(a+1),d[M++]=v+f+(a+1)+1,d[M++]=v+f+1;f+=2*(a+1);for(var I=0;I<=a;I++)0===I&&(h[y++]=0,h[y++]=-u,h[y++]=0,h[y++]=0,h[y++]=-1,h[y++]=0,h[y++]=.5,h[y++]=.5),_=I*c,m=Math.cos(_+Math.PI)*e,g=-u,p=Math.sin(_+Math.PI)*e,h[y++]=m,h[y++]=g,h[y++]=p,h[y++]=0,h[y++]=-1,h[y++]=0,h[y++]=.5+.5*Math.cos(_),h[y++]=.5+.5*Math.sin(_);for(var w=0;w<a;w++)d[M++]=0+f,d[M++]=w+2+f,d[M++]=w+1+f;return f+=a+1+1,Tr._createMesh(o,h,d)}static createCylinder(e=.5,r=2,a=32){for(var i=a+1+1+2*(a+1)+(a+1+1),n=3*a+6*a+3*a,s=t.VertexMesh.getVertexDeclaration("POSITION,NORMAL,UV"),o=s.vertexStride/4,l=new Float32Array(i*o),h=new Uint16Array(n),d=2*Math.PI/a,c=r/2,u=0,_=0,f=0,m=0,g=0,p=0,S=0,T=0;T<=a;T++)0===T&&(l[p++]=0,l[p++]=c,l[p++]=0,l[p++]=0,l[p++]=1,l[p++]=0,l[p++]=.5,l[p++]=.5),u=T*d,f=Math.cos(u)*e,m=c,g=Math.sin(u)*e,l[p++]=f,l[p++]=m,l[p++]=g,l[p++]=0,l[p++]=1,l[p++]=0,l[p++]=.5+.5*Math.cos(u),l[p++]=.5+.5*Math.sin(u);for(var A=0;A<a;A++)h[S++]=0,h[S++]=A+1,h[S++]=A+2;_+=a+1+1;for(var E=0;E<=a;E++)u=E*d,f=Math.cos(u+Math.PI)*e,m=c,g=Math.sin(u+Math.PI)*e,l[p++]=f,l[p+8*(a+1)-1]=f,l[p++]=m,l[p+8*(a+1)-1]=-m,l[p++]=g,l[p+8*(a+1)-1]=g,l[p++]=f,l[p+8*(a+1)-1]=f,l[p++]=0,l[p+8*(a+1)-1]=0,l[p++]=g,l[p+8*(a+1)-1]=g,l[p++]=1-1*E/a,l[p+8*(a+1)-1]=1-1*E/a,l[p++]=0,l[p+8*(a+1)-1]=1;p+=8*(a+1);for(var D=0;D<a;D++)h[S++]=D+_+(a+1),h[S++]=D+_+1,h[S++]=D+_,h[S++]=D+_+(a+1),h[S++]=D+_+(a+1)+1,h[S++]=D+_+1;_+=2*(a+1);for(var R=0;R<=a;R++)0===R&&(l[p++]=0,l[p++]=-c,l[p++]=0,l[p++]=0,l[p++]=-1,l[p++]=0,l[p++]=.5,l[p++]=.5),u=R*d,f=Math.cos(u+Math.PI)*e,m=-c,g=Math.sin(u+Math.PI)*e,l[p++]=f,l[p++]=m,l[p++]=g,l[p++]=0,l[p++]=-1,l[p++]=0,l[p++]=.5+.5*Math.cos(u),l[p++]=.5+.5*Math.sin(u);for(var x=0;x<a;x++)h[S++]=0+_,h[S++]=x+2+_,h[S++]=x+1+_;return _+=a+1+1,Tr._createMesh(s,l,h)}static createPlane(e=10,r=10,a=10,i=10){for(var n=(a+1)*(i+1),s=new Uint16Array(a*i*2*3),o=t.VertexMesh.getVertexDeclaration("POSITION,NORMAL,UV"),l=o.vertexStride/4,h=new Float32Array(n*l),d=e/2,c=r/2,u=e/a,_=r/i,f=0,m=0;m<=i;m++)for(var g=0;g<=a;g++)h[f++]=g*u-d,h[f++]=0,h[f++]=m*_-c,h[f++]=0,h[f++]=1,h[f++]=0,h[f++]=1*g/a,h[f++]=1*m/i;var p=0;for(m=0;m<i;m++)for(g=0;g<a;g++)s[p++]=(m+1)*(a+1)+g,s[p++]=m*(a+1)+g,s[p++]=(m+1)*(a+1)+g+1,s[p++]=m*(a+1)+g,s[p++]=m*(a+1)+g+1,s[p++]=(m+1)*(a+1)+g+1;return Tr._createMesh(o,h,s)}static createQuad(e=1,r=1){var a=t.VertexMesh.getVertexDeclaration("POSITION,NORMAL,UV,TANGENT"),i=e/2,n=r/2,s=new Float32Array([-i,n,0,0,0,1,0,0,1,0,0,1,i,n,0,0,0,1,1,0,1,0,0,1,-i,-n,0,0,0,1,0,1,1,0,0,1,i,-n,0,0,0,1,1,1,1,0,0,1]),o=new Uint16Array([0,1,2,3,2,1]);return Tr._createMesh(a,s,o)}static createTriangle(e=1,r=1){var a=t.VertexMesh.getVertexDeclaration("POSITION,NORMAL,UV,TANGENT"),i=e/2,n=r/2,s=new Float32Array([0,3*n,0,0,0,1,.5,-1,1,0,0,1,2*-i,-n,0,0,0,1,-.5,1,1,0,0,1,2*i,-n,0,0,0,1,1.5,1,1,0,0,1]),o=new Uint16Array([0,1,2]);return Tr._createMesh(a,s,o)}static createSphere(e=.5,r=32,a=32){var i=(r+1)*(a+1),n=3*r*(a+1)*2,s=new Uint16Array(n),o=t.VertexMesh.getVertexDeclaration("POSITION,NORMAL,UV"),l=o.vertexStride/4,h=new Float32Array(i*l),d=Math.PI/r,c=2*Math.PI/a,u=0;i=0,n=0;for(var _=0;_<r+1;_++)for(var f=Math.sin(_*d),m=Math.cos(_*d),g=0;g<a+1;g++){var p=f*Math.sin(g*c+1*Math.PI/2),S=f*Math.cos(g*c+1*Math.PI/2);h[i+0]=p*e,h[i+1]=m*e,h[i+2]=S*e,h[i+3]=p,h[i+4]=m,h[i+5]=S,h[i+6]=g/a,h[i+7]=_/r,i+=l,_!=r-1&&(s[n++]=u+(a+1),s[n++]=u,s[n++]=u+1,s[n++]=u+a,s[n++]=u,s[n++]=u+(a+1),u++)}return Tr._createMesh(o,h,s)}}var Ar="#define SHADER_NAME BlitVS\nvarying vec2 v_Texcoord0;void main(){gl_Position=vec4(u_OffsetScale.x*2.0-1.0+(a_PositionTexcoord.x+1.0)*u_OffsetScale.z,(1.0-((u_OffsetScale.y*2.0-1.0+(-a_PositionTexcoord.y+1.0)*u_OffsetScale.w)+1.0)/2.0)*2.0-1.0,0.0,1.0);v_Texcoord0=a_PositionTexcoord.zw;}",Er='#define SHADER_NAME BlitFS\n#include "Color.glsl";\n#include "FastApproximateAntiAliasing.glsl";\nvarying vec2 v_Texcoord0;void main(){\n#ifdef FXAA\ngl_FragColor=FXAAMain(v_Texcoord0,u_MainTex_TexelSize.zw);\n#else\nvec4 mainColor=texture2D(u_MainTex,v_Texcoord0);\n#ifdef Gamma_u_MainTex\nmainColor=gammaToLinear(mainColor);\n#endif\ngl_FragColor=mainColor;\n#endif\ngl_FragColor=outputTransform(gl_FragColor);}';class Dr{static init(){t.Shader3D.addInclude("FastApproximateAntiAliasing.glsl","#if !defined(FXAA_lib)\n#define FXAA_lib\n#ifdef FXAA\n#define EDGE_THRESHOLD_MIN 0.0312\n#define EDGE_THRESHOLD_MAX 0.125\n#define QUALITY(q) ((q) < 5 ? 1.0 : ((q) > 5 ? ((q) < 10 ? 2.0 : ((q) < 11 ? 4.0 : 8.0)) : 1.5))\n#define ITERATIONS 12\n#define SUBPIXEL_QUALITY 0.75\nfloat rgb2luma(in vec3 rgb){return dot(rgb,vec3(0.299,0.587,0.114));}vec3 textureOffsetbyScreenSize(in vec2 uv,in vec2 offset,in vec2 inverseScreenSize){vec2 sampleruv=uv+inverseScreenSize*offset;return texture2DLodEXT(u_MainTex,sampleruv,0.0).rgb;}vec4 FXAAMain(in vec2 texuv,in vec2 inverseScreenSize){vec4 mainColor=texture2DLodEXT(u_MainTex,texuv,0.0);vec3 colorCenter=mainColor.rgb;float lumaCenter=rgb2luma(colorCenter);float lumaDown=rgb2luma(textureOffsetbyScreenSize(texuv,vec2(0,-1),inverseScreenSize));float lumaUp=rgb2luma(textureOffsetbyScreenSize(texuv,vec2(0,1),inverseScreenSize));float lumaLeft=rgb2luma(textureOffsetbyScreenSize(texuv,vec2(-1,0),inverseScreenSize));float lumaRight=rgb2luma(textureOffsetbyScreenSize(texuv,vec2(1,0),inverseScreenSize));float lumaMin=min(lumaCenter,min(min(lumaDown,lumaUp),min(lumaLeft,lumaRight)));float lumaMax=max(lumaCenter,max(max(lumaDown,lumaUp),max(lumaLeft,lumaRight)));float lumaRange=lumaMax-lumaMin;if(lumaRange<max(EDGE_THRESHOLD_MIN,lumaMax*EDGE_THRESHOLD_MAX)){return mainColor;}float lumaDownLeft=rgb2luma(textureOffsetbyScreenSize(texuv,vec2(-1,-1),inverseScreenSize));float lumaUpRight=rgb2luma(textureOffsetbyScreenSize(texuv,vec2(1,1),inverseScreenSize));float lumaUpLeft=rgb2luma(textureOffsetbyScreenSize(texuv,vec2(-1,1),inverseScreenSize));float lumaDownRight=rgb2luma(textureOffsetbyScreenSize(texuv,vec2(1,-1),inverseScreenSize));float lumaDownUp=lumaDown+lumaUp;float lumaLeftRight=lumaLeft+lumaRight;float lumaLeftCorners=lumaDownLeft+lumaUpLeft;float lumaDownCorners=lumaDownLeft+lumaDownRight;float lumaRightCorners=lumaDownRight+lumaUpRight;float lumaUpCorners=lumaUpRight+lumaUpLeft;float edgeHorizontal=abs(-2.0*lumaLeft+lumaLeftCorners)+abs(-2.0*lumaCenter+lumaDownUp)*2.0+abs(-2.0*lumaRight+lumaRightCorners);float edgeVertical=abs(-2.0*lumaUp+lumaUpCorners)+abs(-2.0*lumaCenter+lumaLeftRight)*2.0+abs(-2.0*lumaDown+lumaDownCorners);bool isHorizontal=(edgeHorizontal>=edgeVertical);float stepLength=isHorizontal ? inverseScreenSize.y : inverseScreenSize.x;float luma1=isHorizontal ? lumaDown : lumaLeft;float luma2=isHorizontal ? lumaUp : lumaRight;float gradient1=luma1-lumaCenter;float gradient2=luma2-lumaCenter;bool is1Steepest=abs(gradient1)>=abs(gradient2);float gradientScaled=0.25*max(abs(gradient1),abs(gradient2));float lumaLocalAverage=0.0;if(is1Steepest){stepLength=-stepLength;lumaLocalAverage=0.5*(luma1+lumaCenter);}else{lumaLocalAverage=0.5*(luma2+lumaCenter);}vec2 currentUv=texuv;if(isHorizontal){currentUv.y+=stepLength*0.5;}else{currentUv.x+=stepLength*0.5;}vec2 offset=isHorizontal ? vec2(inverseScreenSize.x,0.0): vec2(0.0,inverseScreenSize.y);vec2 uv1=currentUv-offset*QUALITY(0);vec2 uv2=currentUv+offset*QUALITY(0);float lumaEnd1=rgb2luma(textureOffsetbyScreenSize(uv1,vec2(0.0,0.0),inverseScreenSize));float lumaEnd2=rgb2luma(textureOffsetbyScreenSize(uv2,vec2(0.0,0.0),inverseScreenSize));lumaEnd1-=lumaLocalAverage;lumaEnd2-=lumaLocalAverage;bool reached1=abs(lumaEnd1)>=gradientScaled;bool reached2=abs(lumaEnd2)>=gradientScaled;bool reachedBoth=reached1&&reached2;if(!reached1){uv1-=offset*QUALITY(1);}if(!reached2){uv2+=offset*QUALITY(1);}if(!reachedBoth){for(int i=2;i<ITERATIONS;i++){if(!reached1){lumaEnd1=rgb2luma(textureOffsetbyScreenSize(uv1,vec2(0.0,0.0),inverseScreenSize));lumaEnd1=lumaEnd1-lumaLocalAverage;}if(!reached2){lumaEnd2=rgb2luma(textureOffsetbyScreenSize(uv2,vec2(0.0,0.0),inverseScreenSize));lumaEnd2=lumaEnd2-lumaLocalAverage;}reached1=abs(lumaEnd1)>=gradientScaled;reached2=abs(lumaEnd2)>=gradientScaled;reachedBoth=reached1&&reached2;if(!reached1){uv1-=offset*QUALITY(i);}if(!reached2){uv2+=offset*QUALITY(i);}if(reachedBoth){break;}}}float distance1=isHorizontal ?(texuv.x-uv1.x):(texuv.y-uv1.y);float distance2=isHorizontal ?(uv2.x-texuv.x):(uv2.y-texuv.y);bool isDirection1=distance1<distance2;float distanceFinal=min(distance1,distance2);float edgeThickness=(distance1+distance2);bool isLumaCenterSmaller=lumaCenter<lumaLocalAverage;bool correctVariation1=(lumaEnd1<0.0)!=isLumaCenterSmaller;bool correctVariation2=(lumaEnd2<0.0)!=isLumaCenterSmaller;bool correctVariation=isDirection1 ? correctVariation1 : correctVariation2;float pixelOffset=-distanceFinal/edgeThickness+0.5;float finalOffset=correctVariation ? pixelOffset : 0.0;float lumaAverage=(1.0/12.0)*(2.0*(lumaDownUp+lumaLeftRight)+lumaLeftCorners+lumaRightCorners);float subPixelOffset1=clamp(abs(lumaAverage-lumaCenter)/lumaRange,0.0,1.0);float subPixelOffset2=(-2.0*subPixelOffset1+3.0)*subPixelOffset1*subPixelOffset1;float subPixelOffsetFinal=subPixelOffset2*subPixelOffset2*SUBPIXEL_QUALITY;finalOffset=max(finalOffset,subPixelOffsetFinal);vec2 finalUv=texuv;if(isHorizontal){finalUv.y+=finalOffset*stepLength;}else{finalUv.x+=finalOffset*stepLength;}return texture2DLodEXT(u_MainTex,finalUv,0.0);}\n#endif\n#endif\n");let e={a_PositionTexcoord:[t.VertexMesh.MESH_POSITION0,t.ShaderDataType.Vector4]},r={u_OffsetScale:t.ShaderDataType.Vector4,u_MainTex:t.ShaderDataType.Texture2D,u_MainTex_TexelSize:t.ShaderDataType.Vector4},a=t.Shader3D.add("BlitScreen");a.shaderType=t.ShaderFeatureType.PostProcess;let i=new t.SubShader(e,r);a.addSubShader(i);let n=i.addShaderPass(Ar,Er);n.statefirst=!0;let s=n.renderState;s.depthTest=t.RenderState.DEPTHTEST_ALWAYS,s.depthWrite=!1,s.cull=t.RenderState.CULL_NONE,s.blend=t.RenderState.BLEND_DISABLE;let o=t.Shader3D.add("BlitScreen_Transparnet");a.shaderType=t.ShaderFeatureType.PostProcess;let l=new t.SubShader(e,r);o.addSubShader(l);let h=l.addShaderPass(Ar,Er);n.statefirst=!0,s=h.renderState,s.depthTest=t.RenderState.DEPTHTEST_ALWAYS,s.depthWrite=!1,s.cull=t.RenderState.CULL_NONE,s.blend=t.RenderState.BLEND_ENABLE_ALL,s.srcBlend=t.RenderState.BLENDPARAM_SRC_ALPHA,s.dstBlend=t.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA}}var Rr='#define SHADER_NAME DepthVS\n#include "DepthVertex.glsl";\n#ifdef ALPHATEST\nvarying vec2 v_AlphaTestUV;varying float v_AlphaTestVertexAlpha;\n#endif\nvoid main(){Vertex vertex;getVertexParams(vertex);\n#ifdef ALPHATEST\n#ifdef UV\nv_AlphaTestUV=vertex.texCoord0;\n#else\nv_AlphaTestUV=vec2(0.0);\n#endif\n#if defined(COLOR) && defined(ENABLEVERTEXCOLOR)\nv_AlphaTestVertexAlpha=vertex.vertexColor.a;\n#else\nv_AlphaTestVertexAlpha=1.0;\n#endif\n#endif\nmat4 worldMat=getWorldMatrix();vec4 pos=(worldMat*vec4(vertex.positionOS,1.0));vec3 positionWS=pos.xyz/pos.w;mat4 normalMat=transpose(inverse(worldMat));vec3 normalWS=normalize((normalMat*vec4(vertex.normalOS,0.0)).xyz);vec4 positionCS=DepthPositionCS(positionWS,normalWS);gl_Position=remapPositionZ(positionCS);}';class xr{static init(){let e={UnlitBlock:{u_AlbedoColor:t.ShaderDataType.Color,u_TilingOffset:t.ShaderDataType.Vector4},u_AlbedoTexture:t.ShaderDataType.Texture2D,u_AlphaTestValue:t.ShaderDataType.Float},r={u_AlbedoColor:t.Color.WHITE,u_TilingOffset:new t.Vector4(1,1,0,0),u_AlphaTestValue:.5},a=t.Shader3D.add("Unlit",!0,!1);a.shaderType=t.ShaderFeatureType.D3;let i=new t.SubShader(t.SubShader.DefaultAttributeMap,e,r);a.addSubShader(i),i.addShaderPass('\n#define SHADER_NAME UnlitVS\n#include "Math.glsl";\n#include "Scene.glsl";\n#include "SceneFogInput.glsl";\n#include "Camera.glsl";\n#include "Sprite3DVertex.glsl";\n#include "VertexCommon.glsl";\n#ifdef UV\nvarying vec2 v_Texcoord0;\n#endif\n#ifdef COLOR\nvarying vec4 v_VertexColor;\n#endif\nvoid main(){Vertex vertex;getVertexParams(vertex);\n#ifdef UV\nv_Texcoord0=transformUV(vertex.texCoord0,u_TilingOffset);\n#endif\n#ifdef COLOR\nv_VertexColor=vertex.vertexColor;\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}','\n#define SHADER_NAME UNLITFS\n#include "Color.glsl";\n#include "Scene.glsl";\n#include "SceneFog.glsl";\n#include "Camera.glsl";\n#include "Sprite3DFrag.glsl";\n#ifdef UV\nvarying vec2 v_Texcoord0;\n#endif\n#ifdef COLOR\nvarying vec4 v_VertexColor;\n#endif\nvoid main(){vec3 color=u_AlbedoColor.rgb;float alpha=u_AlbedoColor.a;\n#ifdef COLOR\n#ifdef ENABLEVERTEXCOLOR\nvec4 vertexColor=v_VertexColor;color*=vertexColor.rgb;alpha*=vertexColor.a;\n#endif\n#endif\n#ifdef UV\nvec2 uv=v_Texcoord0;\n#ifdef ALBEDOTEXTURE\nvec4 albedoSampler=texture2D(u_AlbedoTexture,uv);\n#ifdef Gamma_u_AlbedoTexture\nalbedoSampler=gammaToLinear(albedoSampler);\n#endif\ncolor*=albedoSampler.rgb;alpha*=albedoSampler.a;\n#endif\n#endif\n#ifdef ALPHATEST\nif(alpha<u_AlphaTestValue)discard;\n#endif\n#ifdef FOG\ncolor=scenUnlitFog(color);\n#endif\ngl_FragColor=vec4(color,alpha);gl_FragColor=outputTransform(gl_FragColor);}'),i.addShaderPass(Rr,'#define SHADER_NAME UnlitDepthFS\n#include "DepthFrag.glsl";\n#include "Sprite3DFrag.glsl";\n#ifdef ALPHATEST\nvarying vec2 v_AlphaTestUV;varying float v_AlphaTestVertexAlpha;\n#endif\nvoid main(){\n#ifdef ALPHATEST\nfloat alpha=u_AlbedoColor.a*v_AlphaTestVertexAlpha;\n#if defined(UV) && defined(ALBEDOTEXTURE)\nvec2 uv=transformUV(v_AlphaTestUV,u_TilingOffset);alpha*=texture2D(u_AlbedoTexture,uv).a;\n#endif\nif(alpha<u_AlphaTestValue)discard;\n#endif\ngl_FragColor=getDepthColor();}',"ShadowCaster")}}class yr{static init(){t.Shader3D.addInclude("BlinnPhongCommon.glsl","#if !defined(BlinnPhongCommon_lib)\n#define BlinnPhongCommon_lib\nvarying vec3 v_PositionWS;varying vec3 v_NormalWS;varying vec3 v_TangentWS;varying vec3 v_BiNormalWS;\n#ifdef UV\nvarying vec2 v_Texcoord0;\n#endif\n#ifdef UV1\n#ifdef LIGHTMAP\nvarying vec2 v_Texcoord1;\n#endif\n#endif\n#ifdef COLOR\nvarying vec4 v_VertexColor;\n#endif\nstruct PixelParams{vec3 positionWS;vec3 normalWS;vec3 tangentWS;vec3 biNormalWS;mat3 TBN;\n#ifdef UV\nvec2 uv0;\n#endif\n#ifdef UV1\n#ifdef LIGHTMAP\nvec2 uv1;\n#endif\n#endif\n#ifdef COLOR\nvec4 vertexColor;\n#endif\n};\n#endif\n"),t.Shader3D.addInclude("BlinnPhongVertex.glsl",'#if !defined(BlinnPhongVertex_lib)\n#define BlinnPhongVertex_lib\n#include "ShadingVertex.glsl";\nvoid initPixelParams(inout PixelParams params,in Vertex vertex){shadingPixelParams(params,vertex);sharePixelParams(params);}\n#endif\n'),t.Shader3D.addInclude("BlinnPhongFrag.glsl",'#if !defined(BlinnPhongFrag_lib)\n#define BlinnPhongFrag_lib\n#include "BlinnPhongLighting.glsl";\n#include "ShadingFrag.glsl";\nvoid getPixelInfo(inout PixelInfo info,const in PixelParams pixel,const in Surface surface){info.positionWS=pixel.positionWS;info.vertexNormalWS=pixel.normalWS;\n#ifdef TANGENT\ninfo.normalWS=normalize(pixel.TBN*surface.normalTS);\n#else\ninfo.normalWS=pixel.normalWS;\n#endif\ninfo.viewDir=normalize(u_CameraPos-info.positionWS);\n#ifdef LIGHTMAP\n#ifdef UV1\ninfo.lightmapUV=pixel.uv1;\n#endif\n#endif\n}vec3 BlinnPhongLighting(const in Surface surface,const in PixelParams pixel){PixelInfo info;getPixelInfo(info,pixel,surface);vec3 positionWS=info.positionWS;vec3 normalWS=info.normalWS;vec3 v=info.viewDir;vec3 lightColor=vec3(0.0,0.0,0.0);\n#ifdef DIRECTIONLIGHT\nfor(int i=0;i<CalculateLightCount;i++){if(i>=DirectionCount)break;DirectionLight directionLight=getDirectionLight(i,positionWS);if(directionLight.lightMode==LightMode_Mix){continue;}Light light=getLight(directionLight);lightColor+=BlinnPhongLighting(surface,light,info)*light.attenuation;}\n#endif\n#if defined(POINTLIGHT) || defined(SPOTLIGHT)\nivec4 clusterInfo=getClusterInfo(u_View,u_Viewport,positionWS,gl_FragCoord,u_ProjectionParams);\n#endif\n#ifdef POINTLIGHT\nfor(int i=0;i<CalculateLightCount;i++){if(i>=clusterInfo.x)break;PointLight pointLight=getPointLight(i,clusterInfo,positionWS);if(pointLight.lightMode==LightMode_Mix){continue;}Light light=getLight(pointLight,normalWS,positionWS);lightColor+=BlinnPhongLighting(surface,light,info)*light.attenuation;}\n#endif\n#ifdef SPOTLIGHT\nfor(int i=0;i<CalculateLightCount;i++){if(i>=clusterInfo.y)break;SpotLight spotLight=getSpotLight(i,clusterInfo,positionWS);if(spotLight.lightMode==LightMode_Mix){continue;}Light light=getLight(spotLight,normalWS,positionWS);lightColor+=BlinnPhongLighting(surface,light,info)*light.attenuation;}\n#endif\nvec3 giColor=BlinnPhongGI(surface,info);return lightColor+giColor;}\n#endif\n');let e={u_AlphaTestValue:t.ShaderDataType.Float,u_TilingOffset:t.ShaderDataType.Vector4,u_DiffuseColor:t.ShaderDataType.Color,u_DiffuseTexture:t.ShaderDataType.Texture2D,u_AlbedoIntensity:t.ShaderDataType.Float,u_MaterialSpecular:t.ShaderDataType.Color,u_SpecularTexture:t.ShaderDataType.Texture2D,u_Shininess:t.ShaderDataType.Float,u_NormalTexture:t.ShaderDataType.Texture2D},r={u_AlbedoIntensity:1,u_DiffuseColor:t.Color.WHITE,u_MaterialSpecular:t.Color.WHITE,u_Shininess:.078125,u_AlphaTestValue:.5,u_TilingOffset:new t.Vector4(1,1,0,0)},a=t.Shader3D.add("BLINNPHONG",!0,!0);a.shaderType=t.ShaderFeatureType.D3;let i=new t.SubShader(t.SubShader.DefaultAttributeMap,e,r);a.addSubShader(i),i.addShaderPass('#define SHADER_NAME BlinnPhongVS\n#include "Math.glsl";\n#include "Scene.glsl";\n#include "SceneFogInput.glsl";\n#include "Camera.glsl";\n#include "Sprite3DVertex.glsl";\n#include "VertexCommon.glsl";\n#include "BlinnPhongVertex.glsl";\nvoid main(){Vertex vertex;getVertexParams(vertex);PixelParams pixel;initPixelParams(pixel,vertex);gl_Position=getPositionCS(pixel.positionWS);gl_Position=remapPositionZ(gl_Position);\n#ifdef FOG\nFogHandle(gl_Position.z);\n#endif\n}','#define SHADER_NAME BlinnPhongFS\n#include "Color.glsl";\n#include "Scene.glsl";\n#include "SceneFog.glsl";\n#include "Camera.glsl";\n#include "Sprite3DFrag.glsl";\n#include "BlinnPhongFrag.glsl";\nvoid getBinnPhongSurfaceParams(inout Surface surface,in PixelParams pixel){\n#ifdef UV\nvec2 uv=transformUV(pixel.uv0,u_TilingOffset);\n#else\nvec2 uv=vec2(0.0);\n#endif\nsurface.diffuseColor=u_DiffuseColor.rgb;surface.alpha=u_DiffuseColor.a;\n#ifdef COLOR\n#ifdef ENABLEVERTEXCOLOR\nsurface.diffuseColor*=pixel.vertexColor.xyz;surface.alpha*=pixel.vertexColor.a;\n#endif\n#endif\n#ifdef DIFFUSEMAP\nvec4 diffuseSampler=texture2D(u_DiffuseTexture,uv);\n#ifdef Gamma_u_DiffuseTexture\ndiffuseSampler=gammaToLinear(diffuseSampler);\n#endif\nsurface.diffuseColor*=u_DiffuseColor.rgb*diffuseSampler.rgb*u_AlbedoIntensity;surface.alpha*=diffuseSampler.a;\n#endif\nsurface.diffuseColor*=u_AlbedoIntensity;surface.normalTS=vec3(0.0,0.0,1.0);\n#ifdef NORMALMAP\nvec3 normalSampler=texture2D(u_NormalTexture,uv).rgb;normalSampler=normalize(normalSampler*2.0-1.0);normalSampler.y*=-1.0;surface.normalTS=normalSampler;\n#endif\n#ifdef SPECULARMAP\nvec4 specularSampler=texture2D(u_SpecularTexture,uv);\n#ifdef Gamma_u_SpecularTexture\nspecularSampler=gammaToLinear(specularSampler);\n#endif\nsurface.gloss=specularSampler.rgb;\n#else\n#ifdef DIFFUSEMAP\nsurface.gloss=vec3(diffuseSampler.a);\n#else\nsurface.gloss=vec3(1.0,1.0,1.0);\n#endif\n#endif\nsurface.specularColor=u_MaterialSpecular.rgb;surface.shininess=u_Shininess;}void main(){PixelParams pixel;getPixelParams(pixel);Surface surface;getBinnPhongSurfaceParams(surface,pixel);\n#ifdef ALPHATEST\nif(surface.alpha<u_AlphaTestValue){discard;}\n#endif\nvec3 surfaceColor=vec3(0.0);surfaceColor=BlinnPhongLighting(surface,pixel);\n#ifdef FOG\nsurfaceColor=sceneLitFog(surfaceColor);\n#endif\ngl_FragColor=vec4(surfaceColor,surface.alpha);gl_FragColor=outputTransform(gl_FragColor);}'),i.addShaderPass(Rr,'#define SHADER_NAME BlinnPhongDepthFS\n#include "DepthFrag.glsl";\n#include "Sprite3DFrag.glsl";\n#ifdef ALPHATEST\nvarying vec2 v_AlphaTestUV;varying float v_AlphaTestVertexAlpha;\n#endif\nvoid main(){\n#ifdef ALPHATEST\nfloat alpha=u_DiffuseColor.a*v_AlphaTestVertexAlpha;\n#ifdef DIFFUSEMAP\n#ifdef UV\nvec2 uv=transformUV(v_AlphaTestUV,u_TilingOffset);\n#else\nvec2 uv=vec2(0.0);\n#endif\nalpha*=texture2D(u_DiffuseTexture,uv).a;\n#endif\nif(alpha<u_AlphaTestValue)discard;\n#endif\ngl_FragColor=getDepthColor();}',"ShadowCaster"),i.addShaderPass('#define SHADER_NAME BlinnPhongDephtNormalVS\n#include "Math.glsl";\n#include "Camera.glsl";\n#include "Sprite3DVertex.glsl";\n#include "VertexCommon.glsl";\n#include "BlinnPhongVertex.glsl";\nvarying vec4 v_PositionCS;void main(){Vertex vertex;getVertexParams(vertex);PixelParams pixel;initPixelParams(pixel,vertex);vec4 positionCS=getPositionCS(pixel.positionWS);v_PositionCS=positionCS;gl_Position=positionCS;gl_Position=remapPositionZ(gl_Position);}','#define SHADER_NAME BlinnPhongDephtNormalFS\n#include "Color.glsl";\n#include "Scene.glsl";\n#include "Camera.glsl";\n#include "Sprite3DFrag.glsl";\n#include "ShadingFrag.glsl";\n#include "DepthNormalFrag.glsl";\nvarying vec4 v_PositionCS;void main(){PixelParams pixel;getPixelParams(pixel);\n#ifdef ALPHATEST\nfloat alpha=u_DiffuseColor.a;\n#if defined(COLOR) && defined(ENABLEVERTEXCOLOR)\nalpha*=pixel.vertexColor.a;\n#endif\n#ifdef DIFFUSEMAP\n#ifdef UV\nvec2 alphaUV=transformUV(pixel.uv0,u_TilingOffset);\n#else\nvec2 alphaUV=vec2(0.0);\n#endif\nalpha*=texture2D(u_DiffuseTexture,alphaUV).a;\n#endif\nif(alpha<u_AlphaTestValue)discard;\n#endif\nvec3 normalWS=pixel.normalWS;\n#ifdef NORMALMAP\n#ifdef UV\nvec2 uv=transformUV(pixel.uv0,u_TilingOffset);vec3 normalSampler=texture2D(u_NormalTexture,uv).rgb;normalSampler=normalize(normalSampler*2.0-1.0);normalSampler.y*=-1.0;vec3 normalTS=normalSampler;normalWS=normalize(pixel.TBN*normalTS);\n#endif\n#endif\nvec4 positionCS=v_PositionCS;vec4 dephtNormal=encodeDepthNormal(positionCS,normalWS);gl_FragColor=dephtNormal;}',"DepthNormal")}}class Mr{static init(){let e={u_AlbedoColor:t.ShaderDataType.Color,u_TilingOffset:t.ShaderDataType.Vector4,u_NormalScale:t.ShaderDataType.Float,u_Metallic:t.ShaderDataType.Float,u_Smoothness:t.ShaderDataType.Float,u_OcclusionStrength:t.ShaderDataType.Float,u_AlphaTestValue:t.ShaderDataType.Float,u_EmissionColor:t.ShaderDataType.Color,u_EmissionIntensity:t.ShaderDataType.Float,u_AlbedoTexture:t.ShaderDataType.Texture2D,u_NormalTexture:t.ShaderDataType.Texture2D,u_OcclusionTexture:t.ShaderDataType.Texture2D,u_EmissionTexture:t.ShaderDataType.Texture2D,u_MetallicGlossTexture:t.ShaderDataType.Texture2D,u_AnisotropyStrength:t.ShaderDataType.Float,u_AnisotropyTexture:t.ShaderDataType.Texture2D,u_AnisotropyRotation:t.ShaderDataType.Float,u_ClearCoatFactor:t.ShaderDataType.Float,u_ClearCoatTexture:t.ShaderDataType.Texture2D,u_ClearCoatRoughness:t.ShaderDataType.Float,u_ClearCoatRoughnessTexture:t.ShaderDataType.Texture2D,u_ClearCoatNormalTexture:t.ShaderDataType.Texture2D,u_DetailAlbedoTexture:t.ShaderDataType.Texture2D,u_DetailNormalTexture:t.ShaderDataType.Texture2D,u_DetailNormalScale:t.ShaderDataType.Float,u_DetailTillingOffset:t.ShaderDataType.Vector4},r={u_AlbedoColor:t.Color.WHITE,u_TilingOffset:new t.Vector4(1,1,0,0),u_DetailTillingOffset:new t.Vector4(1,1,0,0),u_NormalScale:1,u_DetailNormalScale:1,u_Metallic:0,u_Smoothness:.5,u_OcclusionStrength:1,u_EmissionColor:t.Color.WHITE,u_EmissionIntensity:1,u_AlphaTestValue:.5,u_AnisotropyStrength:0,u_AnisotropyRotation:0,u_ClearCoatFactor:0,u_ClearCoatRoughness:0},a=t.Shader3D.add("PBR",!0,!0);a.shaderType=t.ShaderFeatureType.D3,a._supportVolumetricGI=!0;let i=new t.SubShader(t.SubShader.DefaultAttributeMap,e,r);a.addSubShader(i),i.addShaderPass('#define SHADER_NAME PBRStandardVS\n#include "Math.glsl";\n#include "Scene.glsl";\n#include "SceneFogInput.glsl";\n#include "Camera.glsl";\n#include "Sprite3DVertex.glsl";\n#include "VertexCommon.glsl";\n#include "PBRVertex.glsl";\n#if defined(DETAILTEXTURE) || defined(DETAILNORMAL)\nvarying vec2 v_DetailUV;\n#endif\nvoid main(){Vertex vertex;getVertexParams(vertex);PixelParams pixel;initPixelParams(pixel,vertex);\n#if defined(DETAILTEXTURE) || defined(DETAILNORMAL)\n#ifdef UV\nv_DetailUV=transformUV(vertex.texCoord0,u_DetailTillingOffset);\n#else\nv_DetailUV=vec2(0.0);\n#endif\n#endif\ngl_Position=getPositionCS(pixel.positionWS);gl_Position=remapPositionZ(gl_Position);\n#ifdef FOG\nFogHandle(gl_Position.z);\n#endif\n}','#define SHADER_NAME PBRStandardFS\n#include "Color.glsl";\n#include "Scene.glsl";\n#include "SceneFog.glsl";\n#include "Camera.glsl";\n#include "Sprite3DFrag.glsl";\n#include "PBRMetallicFrag.glsl";\n#if defined(DETAILTEXTURE) || defined(DETAILNORMAL)\nvarying vec2 v_DetailUV;\n#define ColorSpaceDouble vec3(4.59479380, 4.59479380, 4.59479380);\nvec3 BlendNormals(vec3 n1,vec3 n2){return normalize(vec3(n1.xy+n2.xy,n1.z*n2.z));}\n#endif\nvoid initSurfaceInputs(inout SurfaceInputs inputs,const in PixelParams pixel){\n#ifdef UV\nvec2 uv=transformUV(pixel.uv0,u_TilingOffset);\n#else\nvec2 uv=vec2(0.0);\n#endif\ninputs.diffuseColor=u_AlbedoColor.rgb;inputs.alpha=u_AlbedoColor.a;\n#ifdef COLOR\n#ifdef ENABLEVERTEXCOLOR\ninputs.diffuseColor*=pixel.vertexColor.xyz;inputs.alpha*=pixel.vertexColor.a;\n#endif\n#endif\ninputs.alphaTest=u_AlphaTestValue;\n#ifdef ALBEDOTEXTURE\nvec4 albedoSampler=texture2D(u_AlbedoTexture,uv);\n#ifdef Gamma_u_AlbedoTexture\nalbedoSampler=gammaToLinear(albedoSampler);\n#endif\ninputs.diffuseColor*=albedoSampler.rgb;inputs.alpha*=albedoSampler.a;\n#endif\n#ifdef DETAILTEXTURE\nvec3 detailSampler=texture2D(u_DetailAlbedoTexture,v_DetailUV).rgb;\n#ifdef Gamma_u_DetailAlbedoTexture\ndetailSampler=gammaToLinear(detailSampler);\n#endif\ndetailSampler*=ColorSpaceDouble;inputs.diffuseColor*=detailSampler;\n#endif\ninputs.normalTS=vec3(0.0,0.0,1.0);\n#ifdef NORMALTEXTURE\nvec3 normalSampler=texture2D(u_NormalTexture,uv).rgb;normalSampler=normalize(normalSampler*2.0-1.0);normalSampler.y*=-1.0;inputs.normalTS=normalScale(normalSampler,u_NormalScale);\n#endif\n#ifdef DETAILNORMAL\nvec3 detailnormalSampler=texture2D(u_DetailNormalTexture,v_DetailUV).rgb;detailnormalSampler=normalize(detailnormalSampler*2.0-1.0);detailnormalSampler.y*=-1.0;detailnormalSampler=normalScale(detailnormalSampler,u_DetailNormalScale);inputs.normalTS=BlendNormals(inputs.normalTS,detailnormalSampler);\n#endif\ninputs.metallic=u_Metallic;inputs.smoothness=u_Smoothness;\n#ifdef METALLICGLOSSTEXTURE\nvec4 metallicSampler=texture2D(u_MetallicGlossTexture,uv);\n#ifdef Gamma_u_MetallicGlossTexture\nmetallicSampler=gammaToLinear(metallicSampler);\n#endif\ninputs.metallic=metallicSampler.x;\n#ifdef SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA\n#ifdef ALBEDOTEXTURE\ninputs.smoothness=(albedoSampler.a*u_Smoothness);\n#endif\n#else\ninputs.smoothness=(metallicSampler.a*u_Smoothness);\n#endif\n#endif\ninputs.occlusion=1.0;\n#ifdef OCCLUSIONTEXTURE\nvec4 occlusionSampler=texture2D(u_OcclusionTexture,uv);\n#ifdef Gamma_u_OcclusionTexture\nocclusionSampler=gammaToLinear(occlusionSampler);\n#endif\nfloat occlusion=occlusionSampler.g;inputs.occlusion=(1.0-u_OcclusionStrength)+occlusion*u_OcclusionStrength;\n#endif\ninputs.emissionColor=vec3(0.0);\n#ifdef EMISSION\ninputs.emissionColor=u_EmissionColor.rgb*u_EmissionIntensity;\n#ifdef EMISSIONTEXTURE\nvec4 emissionSampler=texture2D(u_EmissionTexture,uv);\n#ifdef Gamma_u_EmissionTexture\nemissionSampler=gammaToLinear(emissionSampler);\n#endif\ninputs.emissionColor*=emissionSampler.rgb;\n#endif\n#endif\n#ifdef CLEARCOAT\ninputs.clearCoat=u_ClearCoatFactor;inputs.clearCoatRoughness=u_ClearCoatRoughness;\n#ifdef CLEARCOATMAP\nvec4 clearCoatSampler=texture2D(u_ClearCoatTexture,uv);inputs.clearCoat*=clearCoatSampler.r;\n#endif\n#ifdef CLEARCOAT_ROUGHNESSMAP\nvec4 clearcoatSampleRoughness=texture2D(u_ClearCoatRoughnessTexture,uv);inputs.clearCoatRoughness*=clearcoatSampleRoughness.g;\n#endif\n#ifdef CLEARCOAT_NORMAL\nvec3 clearCoatNormalSampler=texture2D(u_ClearCoatNormalTexture,uv).rgb;clearCoatNormalSampler=normalize(clearCoatNormalSampler*2.0-1.0);clearCoatNormalSampler.y*=-1.0;inputs.clearCoatNormalTS=clearCoatNormalSampler;\n#endif\n#endif\n#ifdef ANISOTROPIC\ninputs.anisotropy=u_AnisotropyStrength;vec2 direction=vec2(1.0,0.0);\n#ifdef ANISOTROPYMAP\nvec3 anisotropySampler=texture2D(u_AnisotropyTexture,uv).rgb;inputs.anisotropy*=anisotropySampler.b;direction=anisotropySampler.xy*2.0-1.0;\n#endif\nvec2 anisotropyRotation=vec2(cos(u_AnisotropyRotation),sin(u_AnisotropyRotation));mat2 rotationMatrix=mat2(anisotropyRotation.x,anisotropyRotation.y,-anisotropyRotation.y,anisotropyRotation.x);inputs.anisotropyDirection=rotationMatrix*direction;\n#endif\n}void main(){PixelParams pixel;getPixelParams(pixel);SurfaceInputs inputs;initSurfaceInputs(inputs,pixel);vec4 surfaceColor=PBR_Metallic_Flow(inputs,pixel);\n#ifdef FOG\nsurfaceColor.rgb=sceneLitFog(surfaceColor.rgb);\n#endif\ngl_FragColor=surfaceColor;gl_FragColor=outputTransform(gl_FragColor);}'),i.addShaderPass(Rr,'#define SHADER_NAME PBRDepthFS\n#include "DepthFrag.glsl";\n#include "Sprite3DFrag.glsl";\n#ifdef ALPHATEST\nvarying vec2 v_AlphaTestUV;varying float v_AlphaTestVertexAlpha;\n#endif\nvoid main(){\n#ifdef ALPHATEST\nfloat alpha=u_AlbedoColor.a*v_AlphaTestVertexAlpha;\n#ifdef ALBEDOTEXTURE\n#ifdef UV\nvec2 uv=transformUV(v_AlphaTestUV,u_TilingOffset);\n#else\nvec2 uv=vec2(0.0);\n#endif\nalpha*=texture2D(u_AlbedoTexture,uv).a;\n#endif\nif(alpha<u_AlphaTestValue)discard;\n#endif\ngl_FragColor=getDepthColor();}',"ShadowCaster"),i.addShaderPass('#define SHADER_NAME PBRStandardDepthNormalVS\n#include "Math.glsl";\n#include "Camera.glsl";\n#include "Sprite3DVertex.glsl";\n#include "VertexCommon.glsl";\n#include "PBRVertex.glsl";\nvarying vec4 v_PositionCS;void main(){Vertex vertex;getVertexParams(vertex);PixelParams pixel;initPixelParams(pixel,vertex);sharePixelParams(pixel);vec4 positionCS=getPositionCS(pixel.positionWS);v_PositionCS=positionCS;gl_Position=positionCS;gl_Position=remapPositionZ(gl_Position);}','#define SHADER_NAME PBRStandardDepthNormalFS\n#include "Color.glsl";\n#include "Scene.glsl";\n#include "Camera.glsl";\n#include "Sprite3DFrag.glsl";\n#include "ShadingFrag.glsl";\n#include "DepthNormalFrag.glsl";\nvarying vec4 v_PositionCS;void main(){PixelParams pixel;getPixelParams(pixel);\n#ifdef ALPHATEST\nfloat alpha=u_AlbedoColor.a;\n#if defined(COLOR) && defined(ENABLEVERTEXCOLOR)\nalpha*=pixel.vertexColor.a;\n#endif\n#ifdef ALBEDOTEXTURE\n#ifdef UV\nvec2 alphaUV=transformUV(pixel.uv0,u_TilingOffset);\n#else\nvec2 alphaUV=vec2(0.0);\n#endif\nalpha*=texture2D(u_AlbedoTexture,alphaUV).a;\n#endif\nif(alpha<u_AlphaTestValue)discard;\n#endif\nvec3 normalWS=pixel.normalWS;\n#ifdef NORMALTEXTURE\n#ifdef UV\nvec2 uv=transformUV(pixel.uv0,u_TilingOffset);vec3 normalSampler=texture2D(u_NormalTexture,uv).rgb;normalSampler=normalize(normalSampler*2.0-1.0);normalSampler.y*=-1.0;vec3 normalTS=normalScale(normalSampler,u_NormalScale);normalWS=normalize(pixel.TBN*normalTS);\n#endif\n#endif\nvec4 positionCS=v_PositionCS;vec4 dephtNormal=encodeDepthNormal(positionCS,normalWS);gl_FragColor=dephtNormal;}',"DepthNormal")}}class Cr{static init(){let e={a_Position:[t.VertexMesh.MESH_POSITION0,t.ShaderDataType.Vector4]},r={u_TintColor:t.ShaderDataType.Color,u_Exposure:t.ShaderDataType.Float,u_Rotation:t.ShaderDataType.Float,u_CubeTexture:t.ShaderDataType.TextureCube},a={u_TintColor:new t.Color(.5,.5,.5,.5),u_Exposure:1,u_Rotation:0},i=t.Shader3D.add("SkyBox");i.shaderType=t.ShaderFeatureType.Sky;let n=new t.SubShader(e,r,a);i.addSubShader(n);let s=n.addShaderPass('#define SHADER_NAME SkyBoxVS\n#include "SkyCommon.glsl";\nvarying vec3 v_Texcoord;void main(){v_Texcoord=vec3(-a_Position.x,a_Position.yz);vec4 position=rotateAroundYInDegrees(a_Position,u_Rotation);gl_Position=u_SkyProjectionViewMat*position;gl_Position=remapSkyPositionZ(gl_Position);}','#define SHADER_NAME SkyBoxFS\n#include "Color.glsl";\nvarying vec3 v_Texcoord;const vec4 c_ColorSpace=vec4(4.59479380,4.59479380,4.59479380,2.0);void main(){vec3 uv=v_Texcoord;vec4 cubeSampler=textureCube(u_CubeTexture,uv);\n#ifdef Gamma_u_CubeTexture\ncubeSampler=gammaToLinear(cubeSampler);\n#endif\nvec3 color=cubeSampler.rgb*u_TintColor.rgb*pow(u_Exposure,2.2)*c_ColorSpace.rgb;gl_FragColor=vec4(color,1.0);gl_FragColor=outputTransform(gl_FragColor);}');s.renderState.depthTest=t.RenderState.DEPTHTEST_LEQUAL,s.renderState.cull=t.CullMode.Back,s.renderState.depthWrite=!1,s.renderState.stencilWrite=!1,s.statefirst=!0}}class vr{static init(){let e={a_Position:[t.VertexMesh.MESH_POSITION0,t.ShaderDataType.Vector4]},r={u_SunSize:t.ShaderDataType.Float,u_SunSizeConvergence:t.ShaderDataType.Float,u_AtmosphereThickness:t.ShaderDataType.Float,u_SkyTint:t.ShaderDataType.Color,u_GroundTint:t.ShaderDataType.Color,u_Exposure:t.ShaderDataType.Float},a={u_SunSize:.04,u_SunSizeConvergence:5,u_AtmosphereThickness:1,u_SkyTint:new t.Color(.5,.5,.5,1),u_GroundTint:new t.Color(.369,.349,.341,1),u_Exposure:1.3},i=t.Shader3D.add("SkyProcedural");i.shaderType=t.ShaderFeatureType.Sky;let n=new t.SubShader(e,r,a);i.addSubShader(n);let s=n.addShaderPass('#define SHADER_NAME SkyProceduralVS\n#include "SkyCommon.glsl";\n#define OUTER_RADIUS 1.025\n#define RAYLEIGH (mix(0.0, 0.0025, pow(u_AtmosphereThickness,2.5)))\n#define MIE 0.0010\n#define SUN_BRIGHTNESS 20.0\n#define MAX_SCATTER 50.0\nconst float SKY_GROUND_THRESHOLD=0.02;const float outerRadius=OUTER_RADIUS;const float outerRadius2=OUTER_RADIUS*OUTER_RADIUS;const float innerRadius=1.0;const float innerRadius2=1.0;const float cameraHeight=0.0001;const float HDSundiskIntensityFactor=15.0;const float simpleSundiskIntensityFactor=27.0;const float sunScale=400.0*SUN_BRIGHTNESS;const float kmESun=MIE*SUN_BRIGHTNESS;const float km4PI=MIE*4.0*3.14159265;const float scale=1.0/(OUTER_RADIUS-1.0);const float scaleDepth=0.25;const float scaleOverScaleDepth=(1.0/(OUTER_RADIUS-1.0))/0.25;const float samples=2.0;const vec3 c_DefaultScatteringWavelength=vec3(0.65,0.57,0.475);const vec3 c_VariableRangeForScatteringWavelength=vec3(0.15,0.15,0.15);varying vec3 v_GroundColor;varying vec3 v_SkyColor;\n#ifdef SUN_HIGH_QUALITY\nvarying vec3 v_Vertex;\n#elif defined(SUN_SIMPLE)\nvarying vec3 v_RayDir;\n#else\nvarying float v_SkyGroundFactor;\n#endif\n#if defined(SUN_HIGH_QUALITY)||defined(SUN_SIMPLE)\nvarying vec3 v_SunColor;\n#endif\nfloat getRayleighPhase(vec3 light,vec3 ray){float eyeCos=dot(light,ray);return 0.75+0.75*eyeCos*eyeCos;}float scaleAngle(float inCos){float x=1.0-inCos;return 0.25*exp(-0.00287+x*(0.459+x*(3.83+x*(-6.80+x*5.25))));}void main(){gl_Position=u_SkyProjectionViewMat*a_Position;vec3 skyTintInGammaSpace=pow(u_SkyTint.xyz,vec3(0.45));vec3 scatteringWavelength=mix(c_DefaultScatteringWavelength-c_VariableRangeForScatteringWavelength,c_DefaultScatteringWavelength+c_VariableRangeForScatteringWavelength,vec3(1.0)-skyTintInGammaSpace);vec3 invWavelength=1.0/pow(scatteringWavelength,vec3(4.0));float krESun=RAYLEIGH*SUN_BRIGHTNESS;float kr4PI=RAYLEIGH*4.0*3.14159265;vec3 cameraPos=vec3(0.0,innerRadius+cameraHeight,0.0);vec3 eyeRay=normalize(a_Position.xyz);float far=0.0;vec3 cIn,cOut;if(eyeRay.y>=0.0){far=sqrt(outerRadius2+innerRadius2*eyeRay.y*eyeRay.y-innerRadius2)-innerRadius*eyeRay.y;float height=innerRadius+cameraHeight;float depth=exp(scaleOverScaleDepth*-cameraHeight);float startAngle=dot(eyeRay,cameraPos)/height;float startOffset=depth*scaleAngle(startAngle);float sampleLength=far/samples;float scaledLength=sampleLength*scale;vec3 sampleRay=eyeRay*sampleLength;vec3 samplePoint=cameraPos+sampleRay*0.5;vec3 frontColor=vec3(0.0);{float height=length(samplePoint);float depth=exp(scaleOverScaleDepth*(innerRadius-height));float lightAngle=dot(-u_SunLight_direction,samplePoint)/height;float cameraAngle=dot(eyeRay,samplePoint)/height;float scatter=(startOffset+depth*(scaleAngle(lightAngle)-scaleAngle(cameraAngle)));vec3 attenuate=exp(-clamp(scatter,0.0,MAX_SCATTER)*(invWavelength*kr4PI+km4PI));frontColor+=attenuate*(depth*scaledLength);samplePoint+=sampleRay;}{float height=length(samplePoint);float depth=exp(scaleOverScaleDepth*(innerRadius-height));float lightAngle=dot(-u_SunLight_direction,samplePoint)/height;float cameraAngle=dot(eyeRay,samplePoint)/height;float scatter=(startOffset+depth*(scaleAngle(lightAngle)-scaleAngle(cameraAngle)));vec3 attenuate=exp(-clamp(scatter,0.0,MAX_SCATTER)*(invWavelength*kr4PI+km4PI));frontColor+=attenuate*(depth*scaledLength);samplePoint+=sampleRay;}cIn=frontColor*(invWavelength*krESun);cOut=frontColor*kmESun;}else{far=(-cameraHeight)/(min(-0.001,eyeRay.y));vec3 pos=cameraPos+far*eyeRay;float depth=exp((-cameraHeight)*(1.0/scaleDepth));float cameraAngle=dot(-eyeRay,pos);float lightAngle=dot(-u_SunLight_direction,pos);float cameraScale=scaleAngle(cameraAngle);float lightScale=scaleAngle(lightAngle);float cameraOffset=depth*cameraScale;float temp=lightScale+cameraScale;float sampleLength=far/samples;float scaledLength=sampleLength*scale;vec3 sampleRay=eyeRay*sampleLength;vec3 samplePoint=cameraPos+sampleRay*0.5;vec3 frontColor=vec3(0.0,0.0,0.0);vec3 attenuate;{float height=length(samplePoint);float depth=exp(scaleOverScaleDepth*(innerRadius-height));float scatter=depth*temp-cameraOffset;attenuate=exp(-clamp(scatter,0.0,MAX_SCATTER)*(invWavelength*kr4PI+km4PI));frontColor+=attenuate*(depth*scaledLength);samplePoint+=sampleRay;}cIn=frontColor*(invWavelength*krESun+kmESun);cOut=clamp(attenuate,0.0,1.0);}\n#ifdef SUN_HIGH_QUALITY\nv_Vertex=-a_Position.xyz;\n#elif defined(SUN_SIMPLE)\nv_RayDir=-eyeRay;\n#else\nv_SkyGroundFactor=-eyeRay.y/SKY_GROUND_THRESHOLD;\n#endif\nv_GroundColor=u_Exposure*(cIn+u_GroundTint.xyz*cOut);v_SkyColor=u_Exposure*(cIn*getRayleighPhase(-u_SunLight_direction,-eyeRay));float lightColorIntensity=clamp(length(u_SunLight_color.xyz),0.25,1.0);\n#ifdef SUN_HIGH_QUALITY\nv_SunColor=HDSundiskIntensityFactor*clamp(cOut,0.0,1.0)*u_SunLight_color.xyz/lightColorIntensity;\n#elif defined(SUN_SIMPLE)\nv_SunColor=simpleSundiskIntensityFactor*clamp(cOut*sunScale,0.0,1.0)*u_SunLight_color.xyz/lightColorIntensity;\n#endif\ngl_Position=remapSkyPositionZ(gl_Position);}','#define SHADER_NAME SkyProceduralFS\n#include "Color.glsl";\nconst float MIE_G=-0.990;const float MIE_G2=0.9801;const float SKY_GROUND_THRESHOLD=0.02;uniform vec3 u_SunLight_direction;varying vec3 v_GroundColor;varying vec3 v_SkyColor;\n#ifdef SUN_HIGH_QUALITY\nvarying vec3 v_Vertex;\n#elif defined(SUN_SIMPLE)\nvarying vec3 v_RayDir;\n#else\nvarying float v_SkyGroundFactor;\n#endif\n#if defined(SUN_HIGH_QUALITY) || defined(SUN_SIMPLE)\nvarying vec3 v_SunColor;\n#endif\nfloat getMiePhase(float eyeCos,float eyeCos2){float temp=1.0+MIE_G2-2.0*MIE_G*eyeCos;temp=pow(temp,pow(u_SunSize,0.65)*10.0);temp=max(temp,1.0e-4);temp=1.5*((1.0-MIE_G2)/(2.0+MIE_G2))*(1.0+eyeCos2)/temp;return temp;}float calcSunAttenuation(vec3 lightPos,vec3 ray){\n#ifdef SUN_HIGH_QUALITY\nfloat focusedEyeCos=pow(clamp(dot(lightPos,ray),0.0,1.0),u_SunSizeConvergence);return getMiePhase(-focusedEyeCos,focusedEyeCos*focusedEyeCos);\n#else\nvec3 delta=lightPos-ray;float dist=length(delta);float spot=1.0-smoothstep(0.0,u_SunSize,dist);return spot*spot;\n#endif\n}void main(){vec3 col=vec3(0.0,0.0,0.0);\n#ifdef SUN_HIGH_QUALITY\nvec3 ray=normalize(v_Vertex);float y=ray.y/SKY_GROUND_THRESHOLD;\n#elif defined(SUN_SIMPLE)\nvec3 ray=v_RayDir;float y=ray.y/SKY_GROUND_THRESHOLD;\n#else\nfloat y=v_SkyGroundFactor;\n#endif\ncol=mix(v_SkyColor,v_GroundColor,clamp(y,0.0,1.0));\n#if defined(SUN_HIGH_QUALITY) || defined(SUN_SIMPLE)\nif(y<0.0)col+=v_SunColor*calcSunAttenuation(-u_SunLight_direction,-ray);\n#endif\ngl_FragColor=vec4(col,1.0);gl_FragColor=outputTransform(gl_FragColor);}');s.renderState.depthTest=t.RenderState.DEPTHTEST_LEQUAL,s.renderState.cull=t.CullMode.Back,s.renderState.depthWrite=!1,s.renderState.stencilWrite=!1,s.statefirst=!0}}var Ir,wr,Br,Pr,Lr,Fr,Nr,Or,br,Vr;class Ur{static init(){let e={a_Position:[t.VertexMesh.MESH_POSITION0,t.ShaderDataType.Vector4]},r={u_TintColor:t.ShaderDataType.Color,u_Rotation:t.ShaderDataType.Float,u_Texture:t.ShaderDataType.Texture2D,u_Exposure:t.ShaderDataType.Float},a={u_TintColor:new t.Color(.5,.5,.5,1),u_Exposure:1.3,u_Rotation:0,u_Texture:t.Texture2D.grayTexture},i=t.Shader3D.add("SkyPanoramic");i.shaderType=t.ShaderFeatureType.Sky;let n=new t.SubShader(e,r,a);i.addSubShader(n);let s=n.addShaderPass('#define SHADER_NAME SkyPanoramicVS\n#include "SkyCommon.glsl";\nvarying vec3 v_Texcoord;varying vec2 v_Image180ScaleAndCutoff;varying vec4 v_Layout3DScaleAndOffset;void main(){vec4 position=rotateAroundYInDegrees(a_Position,u_Rotation);v_Texcoord=vec3(-a_Position.x,-a_Position.y,a_Position.z);v_Image180ScaleAndCutoff=vec2(1.0,1.0);v_Layout3DScaleAndOffset=vec4(0,0,1,1);gl_Position=u_SkyProjectionViewMat*position;gl_Position=remapSkyPositionZ(gl_Position);}','#define SHADER_NAME SkyPanoramicVS\n#include "Color.glsl";\nvarying vec3 v_Texcoord;varying vec2 v_Image180ScaleAndCutoff;varying vec4 v_Layout3DScaleAndOffset;const vec4 c_ColorSpace=vec4(4.59479380,4.59479380,4.59479380,2.0);vec2 ToRadialCoords(vec3 coords){vec3 normalizedCoords=normalize(coords);float latitude=acos(normalizedCoords.y);float longitude=atan(normalizedCoords.z,normalizedCoords.x);vec2 sphereCoords=vec2(longitude,latitude)*vec2(0.5/PI,1.0/PI);return vec2(0.5,1.0)-sphereCoords;}void main(){vec2 tc=ToRadialCoords(v_Texcoord);if(tc.x>v_Image180ScaleAndCutoff.y)gl_FragColor=vec4(0,0,0,1);tc.x=mod(tc.x*v_Image180ScaleAndCutoff.x,1.0);tc=(tc+v_Layout3DScaleAndOffset.xy)*v_Layout3DScaleAndOffset.zw;mediump vec4 tex=texture2D(u_Texture,tc);\n#ifdef Gamma_u_Texture\ntex=gammaToLinear(tex);\n#endif\nmediump vec3 c=tex.xyz;c=c*u_TintColor.rgb*c_ColorSpace.rgb;c*=pow(u_Exposure,2.2);gl_FragColor=vec4(c,1.0);gl_FragColor=outputTransform(gl_FragColor);}');s.renderState.depthTest=t.RenderState.DEPTHTEST_LEQUAL,s.renderState.cull=t.CullMode.Back,s.renderState.depthWrite=!1,s.renderState.stencilWrite=!1,s.statefirst=!0}}class Hr{static __init__(){t.Shader3D.addInclude("Utils.glsl","#if !defined(Utils_lib)\n#define Utils_lib\n#endif\n"),t.Shader3D.addInclude("BakedBoneMatrixSampler.glsl","#if !defined(BakeBoneAnimSampler_lib)\n#define BakeBoneAnimSampler_lib\nmat4 loadBakedMatMatrix(float FramePos,float boneIndices,float offset){vec2 uv;float PixelPos=FramePos+boneIndices*4.0;float halfOffset=offset*0.5;float uvoffset=PixelPos/u_SimpleAnimatorTextureSize;uv.y=floor(uvoffset)*offset+halfOffset;uv.x=mod(float(PixelPos),u_SimpleAnimatorTextureSize)*offset+halfOffset;vec4 mat0row=texture2D(u_SimpleAnimatorTexture,uv);uv.x+=offset;vec4 mat1row=texture2D(u_SimpleAnimatorTexture,uv);uv.x+=offset;vec4 mat2row=texture2D(u_SimpleAnimatorTexture,uv);uv.x+=offset;vec4 mat3row=texture2D(u_SimpleAnimatorTexture,uv);mat4 m=mat4(mat0row.x,mat0row.y,mat0row.z,mat0row.w,mat1row.x,mat1row.y,mat1row.z,mat1row.w,mat2row.x,mat2row.y,mat2row.z,mat2row.w,mat3row.x,mat3row.y,mat3row.z,mat3row.w);return m;}\n#endif\n"),t.Shader3D.addInclude("MorphTarget.glsl","#if !defined(MorphTarget_lib)\n#define MorphTarget_lib\n#ifdef GRAPHICS_API_GLES3\nuniform sampler2DArray u_MorphTargetsTex;uniform vec4 u_MorphParams;uniform vec4 u_MorphAttrOffset;\n#define Morph_TexWidth u_MorphParams.x\n#define Morph_TexHeight u_MorphParams.y\n#define Morph_AttributeNum u_MorphParams.z\n#define Morph_TargetNum u_MorphParams.w\n#define Morph_PositionOffset u_MorphAttrOffset.x\n#define Morph_NormalOffset u_MorphAttrOffset.y\n#define Morph_TangentOffset u_MorphAttrOffset.z\nuniform vec4 u_MorphActiveTargets[MORPH_MAX_COUNT];uniform int u_MorphTargetActiveCount;\n#define MORPH_ACTIVE_COUNT u_MorphTargetActiveCount\nvec4 sampleMorphTargets(in int vertexID,in float targetID){int v=vertexID/int(Morph_TexWidth);int u=vertexID-v*int(Morph_TexWidth);vec3 uvw=vec3((float(u)+0.5)/Morph_TexWidth,(float(v)+0.5)/Morph_TexHeight,targetID);return texture(u_MorphTargetsTex,uvw);}vec3 positionMorph(in vec3 position){int vertexID=gl_VertexID*int(Morph_AttributeNum)+int(Morph_PositionOffset);for(int i=0;i<MORPH_ACTIVE_COUNT;i++){float index=u_MorphActiveTargets[i].x;float weight=u_MorphActiveTargets[i].y;position+=sampleMorphTargets(vertexID,index).xyz*weight;}return position;}vec3 normalMorph(in vec3 normal){int vertexID=gl_VertexID*int(Morph_AttributeNum)+int(Morph_NormalOffset);for(int i=0;i<MORPH_ACTIVE_COUNT;i++){float index=u_MorphActiveTargets[i].x;float weight=u_MorphActiveTargets[i].y;normal+=sampleMorphTargets(vertexID,index).xyz*weight;}return normal;}vec4 tangentMorph(in vec4 tangent){int vertexID=gl_VertexID*int(Morph_AttributeNum)+int(Morph_TangentOffset);for(int i=0;i<MORPH_ACTIVE_COUNT;i++){float index=u_MorphActiveTargets[i].x;float weight=u_MorphActiveTargets[i].y;vec4 sampleTangent=sampleMorphTargets(vertexID,index);tangent.xyz+=sampleTangent.xyz*weight*tangent.w*sampleTangent.w;}return tangent;}\n#endif\n#endif\n"),t.Shader3D.addInclude("VertexCommon.glsl",'#if !defined(VertexCommon_lib)\n#define VertexCommon_lib\n#ifdef MORPHTARGETS\n#include "MorphTarget.glsl";\n#endif\nstruct Vertex{vec3 positionOS;vec3 normalOS;\n#ifdef TANGENT\nvec4 tangentOS;\n#endif\n#ifdef UV\nvec2 texCoord0;\n#endif\n#ifdef UV1\nvec2 texCoord1;\n#endif\n#ifdef COLOR\nvec4 vertexColor;\n#endif\n#ifdef LIGHTMAP\nvec4 lightmapScaleOffset;\n#endif LIGHTMAP\n};vec4 getVertexPosition(){vec4 position=a_Position;\n#ifdef MORPHTARGETS\n#ifdef MORPHTARGETS_POSITION\n#ifdef GRAPHICS_API_GLES3\nposition.xyz=positionMorph(position.xyz);\n#endif\n#endif\n#endif\nreturn position;}vec3 getVertexNormal(){vec3 normal=a_Normal.xyz;\n#ifdef MORPHTARGETS\n#ifdef MORPHTARGETS_NORMAL\n#ifdef GRAPHICS_API_GLES3\nnormal.xyz=normalMorph(normal);\n#endif\n#endif\n#endif\nreturn normal;}\n#ifdef TANGENT\nvec4 getVertexTangent(){vec4 tangent=a_Tangent0;\n#ifdef MORPHTARGETS\n#ifdef MORPHTARGETS_TANGENT\n#ifdef GRAPHICS_API_GLES3\ntangent=tangentMorph(tangent);\n#endif\n#endif\n#endif\nreturn tangent;}\n#endif\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){vertex.positionOS=getVertexPosition().xyz;vertex.normalOS=getVertexNormal();\n#ifdef TANGENT\nvertex.tangentOS=getVertexTangent();\n#endif\n#ifdef UV\nvertex.texCoord0=a_Texcoord0;\n#endif\n#ifdef UV1\nvertex.texCoord1=a_Texcoord1;\n#endif\n#ifdef COLOR\nvertex.vertexColor=vec4(pow(a_Color.rgb,vec3(2.2)),a_Color.a);\n#endif\n#ifdef LIGHTMAP\nvertex.lightmapScaleOffset=getLightmapScaleOffset();\n#endif LIGHTMAP\n}\n#endif\n'),t.Shader3D.addInclude("ShadingCommon.glsl","#if !defined(ShadingCommon_lib)\n#define ShadingCommon_lib\nvarying vec3 v_PositionWS;varying vec3 v_NormalWS;varying vec3 v_TangentWS;varying vec3 v_BiNormalWS;\n#ifdef UV\nvarying vec2 v_Texcoord0;\n#endif\n#ifdef UV1\n#ifdef LIGHTMAP\nvarying vec2 v_Texcoord1;\n#endif\n#endif\n#ifdef COLOR\nvarying vec4 v_VertexColor;\n#endif\nstruct PixelParams{vec3 positionWS;vec3 normalWS;vec3 tangentWS;vec3 biNormalWS;mat3 TBN;\n#ifdef UV\nvec2 uv0;\n#endif\n#ifdef UV1\n#ifdef LIGHTMAP\nvec2 uv1;\n#endif\n#endif\n#ifdef COLOR\nvec4 vertexColor;\n#endif\n};\n#endif\n"),t.Shader3D.addInclude("ShadingVertex.glsl",'#if !defined(ShadingVertex_lib)\n#define ShadingVertex_lib\n#include "ShadingCommon.glsl";\nvoid sharePixelParams(const in PixelParams params){v_PositionWS=params.positionWS;v_NormalWS=params.normalWS;v_TangentWS=params.tangentWS;v_BiNormalWS=params.biNormalWS;\n#ifdef UV\nv_Texcoord0=params.uv0;\n#endif\n#ifdef UV1\n#ifdef LIGHTMAP\nv_Texcoord1=params.uv1;\n#endif LIGHTMAP\n#endif\n#ifdef COLOR\nv_VertexColor=params.vertexColor;\n#endif\n}void shadingPixelParams(inout PixelParams params,in Vertex vertex){mat4 worldMat=getWorldMatrix();vec4 pos=(worldMat*vec4(vertex.positionOS,1.0));params.positionWS=pos.xyz/pos.w;mat3 normalMat=transpose(inverse(mat3(worldMat)));params.normalWS=normalize((normalMat*vertex.normalOS).xyz);\n#ifdef TANGENT\nparams.tangentWS=normalize((normalMat*vertex.tangentOS.xyz).xyz);params.tangentWS*=WorldInvertFront;params.biNormalWS=normalize(cross(params.normalWS,params.tangentWS)*sign(vertex.tangentOS.w));\n#else\nparams.tangentWS=vec3(1.0,0.0,0.0);params.tangentWS*=WorldInvertFront;params.biNormalWS=normalize(cross(params.normalWS,params.tangentWS));\n#endif\n#ifdef UV\nparams.uv0=vertex.texCoord0;\n#endif\n#ifdef UV1\n#ifdef LIGHTMAP\nparams.uv1=tranformLightMapUV(vertex.texCoord1,vertex.lightmapScaleOffset);\n#endif LIGHTMAP\n#endif\n#ifdef COLOR\nparams.vertexColor=vertex.vertexColor;\n#endif\n}\n#endif\n'),t.Shader3D.addInclude("ShadingFrag.glsl",'#if !defined(ShadingFrag_lib)\n#define ShadingFrag_lib\n#include "ShadingCommon.glsl";\n#define _InvertNormal (float(gl_FrontFacing) * 2.0 - 1.0);\nvoid getPixelParams(inout PixelParams params){params.positionWS=v_PositionWS;float invertN=_InvertNormal;params.normalWS=normalize(v_NormalWS*invertN);params.tangentWS=normalize(v_TangentWS*invertN);params.biNormalWS=normalize(v_BiNormalWS*invertN);params.TBN=mat3(params.tangentWS,params.biNormalWS,params.normalWS);\n#ifdef UV\nparams.uv0=v_Texcoord0;\n#endif\n#ifdef UV1\n#ifdef LIGHTMAP\nparams.uv1=v_Texcoord1;\n#endif\n#endif\n#ifdef COLOR\nparams.vertexColor=v_VertexColor;\n#endif\n}\n#endif\n'),t.Shader3D.addInclude("GBuffer.glsl","#if !defined(GBuffer_lib)\n#define GBuffer_lib\n#define GBUFFER_NORMAL_LOCATION 1\n#define GBUFFER_ALBEDO_LOCATION 2\n#define GBUFFER_SURFACE_LOCATION 3\n#define GBUFFER_CUSTOM_START 5\n#ifdef LAYA_MRT\n#if !defined(LAYA_MRT_TARGET_1) && !defined(LAYA_MRT_TARGET_2) && !defined(LAYA_MRT_TARGET_3) && !defined(LAYA_MRT_TARGET_4) && !defined(LAYA_MRT_TARGET_5)\n#define GBUFFER_CUSTOM_OUTPUTS\n#endif\n#if defined(GBUFFER_NORMAL) && !defined(LAYA_MRT_TARGET_1)\nlayout(location=GBUFFER_NORMAL_LOCATION)out highp vec4 laya_GBufferNormal;\n#endif\n#if defined(GBUFFER_ALBEDO) && !defined(LAYA_MRT_TARGET_1) && !defined(LAYA_MRT_TARGET_2)\nlayout(location=GBUFFER_ALBEDO_LOCATION)out highp vec4 laya_GBufferAlbedo;\n#endif\n#if defined(GBUFFER_SURFACE) && !defined(LAYA_MRT_TARGET_1) && !defined(LAYA_MRT_TARGET_2) && !defined(LAYA_MRT_TARGET_3)\nlayout(location=GBUFFER_SURFACE_LOCATION)out highp vec4 laya_GBufferSurface;\n#endif\nvoid writeGBuffer(vec3 normalWS,vec3 baseColor,float metallic,float perceptualRoughness,float occlusion){\n#if defined(GBUFFER_NORMAL) && !defined(LAYA_MRT_TARGET_1)\nlaya_GBufferNormal=vec4(normalize(normalWS)*0.5+0.5,1.0);\n#endif\n#if defined(GBUFFER_ALBEDO) && !defined(LAYA_MRT_TARGET_1) && !defined(LAYA_MRT_TARGET_2)\nlaya_GBufferAlbedo=vec4(baseColor,1.0);\n#endif\n#if defined(GBUFFER_SURFACE) && !defined(LAYA_MRT_TARGET_1) && !defined(LAYA_MRT_TARGET_2) && !defined(LAYA_MRT_TARGET_3)\nlaya_GBufferSurface=vec4(clamp(vec3(metallic,perceptualRoughness,occlusion),0.0,1.0),1.0);\n#endif\n}\n#endif\n#endif\n"),t.Shader3D.addInclude("MotionVectorCommon.glsl","#if !defined(MotionVectorCommon_lib)\n#define MotionVectorCommon_lib\n#if defined(MOTION_VECTOR_OUTPUT) && defined(LAYA_MRT)\n#define LAYA_MOTION_VECTOR_OUTPUT\n#if !defined(BONE) && !defined(GPU_INSTANCE)\n#define LAYA_MOTION_VECTOR_STATIC_MESH\nvarying highp vec4 v_TaaCurrentClip;varying highp vec4 v_TaaPreviousClip;\n#endif\n#endif\n#endif\n"),t.Shader3D.addInclude("MotionVectorVertex.glsl",'#if !defined(MotionVectorVertex_lib)\n#define MotionVectorVertex_lib\n#include "MotionVectorCommon.glsl";\n#if defined(LAYA_MOTION_VECTOR_STATIC_MESH)\nuniform mat4 u_TaaViewProjection;uniform mat4 u_TaaPreviousViewProjection;vec4 layaGetPositionCSWithMotion(vec3 positionWS){v_TaaCurrentClip=u_TaaViewProjection*vec4(positionWS,1.0);v_TaaPreviousClip=u_TaaPreviousViewProjection*vec4(positionWS,1.0);return getPositionCS(positionWS);}\n#define getPositionCS(positionWS) layaGetPositionCSWithMotion(positionWS)\n#endif\n#endif\n'),t.Shader3D.addInclude("MotionVectorFrag.glsl",'#if !defined(MotionVectorFrag_lib)\n#define MotionVectorFrag_lib\n#include "MotionVectorCommon.glsl";\n#if defined(LAYA_MOTION_VECTOR_OUTPUT)\nlayout(location=4)out highp vec4 laya_MotionVector;\n#define LAYA_MRT_POST_MAIN_HOOK writeMotionVector\n#if defined(LAYA_MOTION_VECTOR_STATIC_MESH)\nuniform vec4 u_TaaMotionParams;\n#endif\nvoid writeMotionVector(){laya_MotionVector=vec4(0.0);\n#if defined(LAYA_MOTION_VECTOR_STATIC_MESH)\nlaya_MotionVector=vec4(2.0,2.0,0.0,1.0);if(v_TaaCurrentClip.w>0.00001&&v_TaaPreviousClip.w>0.00001){vec2 currentNDC=v_TaaCurrentClip.xy/v_TaaCurrentClip.w;vec2 previousNDC=v_TaaPreviousClip.xy/v_TaaPreviousClip.w;vec2 velocity=(currentNDC-previousNDC)*vec2(0.5,0.5*u_TaaMotionParams.x);if(all(lessThan(abs(velocity),vec2(65504.0))))laya_MotionVector=vec4(velocity,0.0,1.0);}\n#endif\n}\n#endif\n#endif\n'),t.Shader3D.addInclude("Scene.glsl","#if !defined(SceneCommon_lib)\n#define SceneCommon_lib\n#ifdef ENUNIFORMBLOCK\nuniform Scene3D{float u_Time;vec4 u_FogParams;vec4 u_FogColor;float u_GIRotate;int u_DirationLightCount;};\n#else\nuniform float u_Time;uniform vec4 u_FogParams;uniform vec4 u_FogColor;uniform float u_GIRotate;uniform mediump int u_DirationLightCount;\n#endif\n#endif\n"),t.Shader3D.addInclude("Camera.glsl","#if !defined(CameraCommon_lib)\n#define CameraCommon_lib\n#ifdef ENUNIFORMBLOCK\nuniform BaseCamera{vec3 u_CameraPos;mat4 u_View;mat4 u_Projection;mat4 u_ViewProjection;vec3 u_CameraDirection;vec3 u_CameraUp;vec4 u_Viewport;vec4 u_ProjectionParams;vec4 u_OpaqueTextureParams;vec4 u_ZBufferParams;};\n#else\nuniform vec3 u_CameraPos;uniform mat4 u_View;uniform mat4 u_Projection;uniform mat4 u_ViewProjection;uniform vec3 u_CameraDirection;uniform vec3 u_CameraUp;uniform vec4 u_Viewport;uniform vec4 u_ProjectionParams;uniform vec4 u_OpaqueTextureParams;uniform vec4 u_ZBufferParams;\n#endif\nuniform sampler2D u_CameraDepthTexture;uniform sampler2D u_CameraDepthNormalsTexture;uniform sampler2D u_CameraOpaqueTexture;vec4 getPositionCS(in vec3 positionWS){return u_ViewProjection*vec4(positionWS,1.0);}vec3 getViewDirection(in vec3 positionWS){return normalize(u_CameraPos-positionWS);}vec4 remapPositionZ(vec4 position){\n#ifdef REMAP_Z\nposition.z=position.z*2.0-position.w;\n#endif\nreturn position;}\n#endif\n"),t.Shader3D.addInclude("SkyCommon.glsl","#if !defined(SkyCommon_lib)\n#define SkyCommon_lib\nuniform vec3 u_SunLight_direction;uniform vec4 u_SunLight_color;uniform mat4 u_SkyViewMat;uniform mat4 u_SkyProjectionMat;uniform mat4 u_SkyProjectionViewMat;vec4 remapSkyPositionZ(in vec4 position){position.z=position.w;return position;}const float c_deg2ang=3.141593/180.0;vec4 rotateAroundYInDegrees(vec4 vertex,float deg){float angle=deg*c_deg2ang;float sina=sin(angle);float cosa=cos(angle);mat2 m=mat2(cosa,-sina,sina,cosa);return vec4(m*vertex.xz,vertex.yw).xzyw;}\n#endif\n"),t.Shader3D.addInclude("Sprite3DCommon.glsl","#if !defined(Sprite3DCommon_lib)\n#define Sprite3DCommon_lib\nuniform mat4 u_WorldMat;uniform vec4 u_WorldInvertFront;\n#ifdef GPU_INSTANCE\n#define WorldInvertFront a_WorldInvertFront.x\n#define NodeCustomData0 a_WorldInvertFront.y\n#define NodeCustomData1 a_WorldInvertFront.z\n#define NodeCustomData2 a_WorldInvertFront.w\n#else\n#define WorldInvertFront u_WorldInvertFront.x\n#define NodeCustomData0 u_WorldInvertFront.y\n#define NodeCustomData1 u_WorldInvertFront.z\n#define NodeCustomData2 u_WorldInvertFront.w\n#endif\nvec2 tranformLightMapUV(in vec2 texcoord,in vec4 tilingOffset){vec2 lightMapUV=vec2(texcoord.x,1.0-texcoord.y)*tilingOffset.xy+tilingOffset.zw;lightMapUV.y=1.0-lightMapUV.y;return lightMapUV;}vec2 transformUV(in vec2 texcoord,in vec4 tilingOffset){vec2 uv=texcoord*tilingOffset.xy+tilingOffset.zw*vec2(1.0,-1.0)+vec2(0.0,1.0-tilingOffset.y);return uv;}\n#endif\n"),t.Shader3D.addInclude("Sprite3DVertex.glsl",'#if !defined(Sprite3DVertex_lib)\n#define Sprite3DVertex_lib\n#include "Sprite3DCommon.glsl";\n#ifdef BONE\n#ifdef SIMPLEBONE\nuniform vec4 u_SimpleAnimatorParams;uniform sampler2D u_SimpleAnimatorTexture;uniform float u_SimpleAnimatorTextureSize;\n#include "BakedBoneMatrixSampler.glsl";\n#else\nuniform mat4 u_Bones[24];\n#endif\n#endif\nmat4 getWorldMatrix(){\n#ifdef GPU_INSTANCE\nmat4 worldMat=a_WorldMat;\n#else\nmat4 worldMat=u_WorldMat;\n#endif\n#ifdef BONE\n#ifdef SIMPLEBONE\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;mat4 skinTrans=loadBakedMatMatrix(currentPixelPos,a_BoneIndices.x,offset)*a_BoneWeights.x;skinTrans+=loadBakedMatMatrix(currentPixelPos,a_BoneIndices.y,offset)*a_BoneWeights.y;skinTrans+=loadBakedMatMatrix(currentPixelPos,a_BoneIndices.z,offset)*a_BoneWeights.z;skinTrans+=loadBakedMatMatrix(currentPixelPos,a_BoneIndices.w,offset)*a_BoneWeights.w;worldMat=worldMat*skinTrans;\n#else\nivec4 boneIndex=ivec4(a_BoneIndices);mat4 skinTrans=u_Bones[boneIndex.x]*a_BoneWeights.x;skinTrans+=u_Bones[boneIndex.y]*a_BoneWeights.y;skinTrans+=u_Bones[boneIndex.z]*a_BoneWeights.z;skinTrans+=u_Bones[boneIndex.w]*a_BoneWeights.w;worldMat=worldMat*skinTrans;\n#endif\n#endif\nreturn worldMat;}vec2 getSimpleBoneCustomData(){vec2 custom;\n#ifdef BONE\n#ifdef SIMPLEBONE\n#ifdef GPU_INSTANCE\ncustom=a_SimpleTextureParams.zw;\n#else\ncustom=u_SimpleAnimatorParams.zw;\n#endif\n#endif\n#endif\nreturn custom;}\n#include "MotionVectorVertex.glsl";\n#endif\n'),t.Shader3D.addInclude("Sprite3DFrag.glsl",'#if !defined(Sprite3DFrag_lib)\n#define Sprite3DFrag_lib\n#include "Sprite3DCommon.glsl";\n#include "MotionVectorFrag.glsl";\n#endif\n'),t.Shader3D.addInclude("DepthVertex.glsl",'#if !defined(DepthVertex_lib)\n#define DepthVertex_lib\n#include "Math.glsl";\n#include "Scene.glsl";\n#include "Camera.glsl";\n#include "Sprite3DVertex.glsl";\n#include "VertexCommon.glsl";\n#if defined(SHADOW) || defined(SHADOW_SPOT)\n#ifndef DEPTHPASS\n#include "ShadowCommon.glsl"\nvec3 applyShadowBias(vec3 positionWS,vec3 normalWS,vec3 lightDirection){float invNdotL=1.0-clamp(dot(-lightDirection,normalWS),0.0,1.0);float scale=invNdotL*u_ShadowBias.y;positionWS+=-lightDirection*u_ShadowBias.xxx;positionWS+=normalWS*vec3(scale);return positionWS;}\n#endif\n#endif\nvec4 DepthPositionCS(in vec3 positionWS,in vec3 normalWS){\n#ifdef DEPTHPASS\nvec4 positionCS=u_ViewProjection*vec4(positionWS,1.0);\n#endif\n#ifdef SHADOW\n#ifndef DEPTHPASS\npositionWS=applyShadowBias(positionWS,normalWS,u_ShadowLightDirection);vec4 positionCS=u_ViewProjection*vec4(positionWS,1.0);positionCS.z=max(positionCS.z,0.0);\n#endif\n#endif\n#ifdef SHADOW_SPOT\n#ifndef DEPTHPASS\nvec4 positionCS=u_ViewProjection*vec4(positionWS,1.0);positionCS.z=positionCS.z-u_ShadowBias.x/positionCS.w;positionCS.z=max(positionCS.z,0.0);\n#endif\n#endif\nreturn positionCS;}\n#endif\n'),t.Shader3D.addInclude("DepthFrag.glsl","#if !defined(DepthFrag_lib)\n#define DepthFrag_lib\nvec4 getDepthColor(){return vec4(0.0);}\n#endif\n"),t.Shader3D.addInclude("DepthNormalUtil.glsl","#define SAMPLE_DEPTH_TEXTURE(textureName, coord2) (texture2D(textureName, coord2).r)\nvec2 EncodeViewNormalStereo(vec3 n){n.z=abs(n.z);float kScale=1.7777;vec2 enc;enc=n.xy/(n.z+1.0);enc/=kScale;enc=enc*0.5+0.5;return enc;}vec3 DecodeViewNormalStereo(vec4 enc4){float kScale=1.7777;vec3 nn=enc4.xyz*vec3(2.0*kScale,2.0*kScale,0.0)+vec3(-kScale,-kScale,1.0);float g=2.0/dot(nn.xyz,nn.xyz);vec3 n;n.xy=g*nn.xy;n.z=g-1.0;return n;}vec2 EncodeFloatRG(float v){vec2 kEncodeMul=vec2(1.0,255.0);float kEncodeBit=1.0/255.0;vec2 enc=kEncodeMul*v;enc=fract(enc);enc.x-=enc.y*kEncodeBit;return enc;}float DecodeFloatRG(vec2 enc){vec2 kDecodeDot=vec2(1.0,1.0/255.0);return dot(enc,kDecodeDot);}vec4 EncodeDepthNormal(float depth,vec3 normals){vec4 encode;encode.xy=EncodeViewNormalStereo(normals);encode.zw=EncodeFloatRG(depth);return encode;}void DecodeDepthNormal(vec4 enc,out float depth,out vec3 normal){depth=DecodeFloatRG(enc.zw);normal=DecodeViewNormalStereo(enc);}vec4 depthNormalsFragment(vec4 depthNormal){return EncodeDepthNormal(depthNormal.w,depthNormal.xyz);}float Linear01Depth(float z,vec4 zbufferParams){return 1.0/(zbufferParams.x*z+zbufferParams.y);}float LinearEyeDepth(float z,vec4 zbufferParams){return 1.0/(zbufferParams.z*z+zbufferParams.w);}"),t.Shader3D.addInclude("DepthNormalFrag.glsl",'#if !defined(DepthNormalFrag_lib)\n#define DepthNormalFrag_lib\n#include "DepthNormalUtil.glsl";\nvec4 encodeDepthNormal(const in vec4 positionCS,const in vec3 normalWS){float depth=(positionCS.z*2.0-positionCS.w)*u_ProjectionParams.w;vec3 normalVS=mat3(u_View)*normalWS;return EncodeDepthNormal(depth,normalVS);}\n#endif\n'),t.Shader3D.addInclude("SceneFog.glsl","#if !defined(SceneFog_lib)\n#define SceneFog_lib\n#ifdef FOG\nvarying float v_fogFactor;float getFogFactor(){return v_fogFactor;}vec3 scenUnlitFog(in vec3 color){float lerpFact=getFogFactor();\n#ifdef ADDTIVEFOG\nlerpFact=clamp(lerpFact,0.0,1.0);return mix(vec3(0.0),color,lerpFact);\n#else\nlerpFact=clamp(lerpFact,0.0,1.0);return mix(u_FogColor.rgb,color,lerpFact);\n#endif\n}vec3 sceneLitFog(in vec3 color){float lerpFact=getFogFactor();lerpFact=clamp(lerpFact,0.0,1.0);return mix(u_FogColor.rgb,color,lerpFact);}\n#endif\n#endif\n"),t.Shader3D.addInclude("SceneFogInput.glsl","#if !defined(SceneFog_lib)\n#define SceneFog_lib\n#ifdef FOG\nvarying float v_fogFactor;void FogHandle(in float fact){float lerpFact=0.0;\n#ifdef FOG_EXP\nlerpFact=fact*(u_FogParams.z/log(2.0));lerpFact=exp2(-lerpFact);\n#elif defined(FOG_EXP2)\nlerpFact=fact*(u_FogParams.z/sqrt(log(2.0)));lerpFact=exp2(-lerpFact);\n#else\nlerpFact=(-1.0*fact/(u_FogParams.y-u_FogParams.x)+u_FogParams.y/(u_FogParams.y-u_FogParams.x));\n#endif\nv_fogFactor=lerpFact;}\n#endif\n#endif\n"),t.Shader3D.addInclude("ShadowCommon.glsl","#if !defined(ShadowCommon_lib)\n#define ShadowCommon_lib\n#ifndef GRAPHICS_API_GLES3\n#define NO_NATIVE_SHADOWMAP\n#endif\n#if defined(NO_NATIVE_SHADOWMAP)\n#define TEXTURE2D_SHADOW(textureName) uniform mediump sampler2D textureName\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) (texture2D(textureName, coord3.xy).r < coord3.z ? 0.0 : 1.0)\n#define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2D shadowMap\n#else\n#define TEXTURE2D_SHADOW(textureName) uniform mediump sampler2DShadow textureName\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) texture2DLodEXT(textureName, coord3, 0.0)\n#define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2DShadow shadowMap\n#endif\n#if defined(SHADOW) || defined(SHADOW_SPOT)\n#ifdef ENUNIFORMBLOCK\nuniform Shadow{vec3 u_ShadowLightDirection;vec4 u_ShadowBias;vec4 u_ShadowSplitSpheres[4];mat4 u_ShadowMatrices[4];vec4 u_ShadowMapSize;vec4 u_ShadowParams;vec4 u_SpotShadowMapSize;mat4 u_SpotViewProjectMatrix;};TEXTURE2D_SHADOW(u_ShadowMap);TEXTURE2D_SHADOW(u_SpotShadowMap);\n#else\nuniform vec3 u_ShadowLightDirection;uniform vec4 u_ShadowBias;uniform vec4 u_ShadowSplitSpheres[4];uniform mat4 u_ShadowMatrices[4];uniform vec4 u_ShadowMapSize;uniform vec4 u_ShadowParams;uniform vec4 u_SpotShadowMapSize;uniform mat4 u_SpotViewProjectMatrix;TEXTURE2D_SHADOW(u_ShadowMap);TEXTURE2D_SHADOW(u_SpotShadowMap);\n#endif\n#endif\n#endif\n"),t.Shader3D.addInclude("ShadowSampleTent.glsl","float sampleShadowGetIRTriangleTexelArea(float triangleHeight){return triangleHeight-0.5;}void sampleShadowGetTexelAreasTent3x3(float offset,out vec4 computedArea,out vec4 computedAreaUncut){float a=offset+0.5;float offsetSquaredHalved=a*a*0.5;computedAreaUncut.x=computedArea.x=offsetSquaredHalved-offset;computedAreaUncut.w=computedArea.w=offsetSquaredHalved;computedAreaUncut.y=sampleShadowGetIRTriangleTexelArea(1.5-offset);float clampedOffsetLeft=min(offset,0.0);float areaOfSmallLeftTriangle=clampedOffsetLeft*clampedOffsetLeft;computedArea.y=computedAreaUncut.y-areaOfSmallLeftTriangle;computedAreaUncut.z=sampleShadowGetIRTriangleTexelArea(1.5+offset);float clampedOffsetRight=max(offset,0.0);float areaOfSmallRightTriangle=clampedOffsetRight*clampedOffsetRight;computedArea.z=computedAreaUncut.z-areaOfSmallRightTriangle;}void sampleShadowGetTexelWeightsTent5x5(float offset,out vec3 texelsWeightsA,out vec3 texelsWeightsB){vec4 areaFrom3texelTriangle;vec4 areaUncutFrom3texelTriangle;sampleShadowGetTexelAreasTent3x3(offset,areaFrom3texelTriangle,areaUncutFrom3texelTriangle);texelsWeightsA.x=0.16*(areaFrom3texelTriangle.x);texelsWeightsA.y=0.16*(areaUncutFrom3texelTriangle.y);texelsWeightsA.z=0.16*(areaFrom3texelTriangle.y+1.0);texelsWeightsB.x=0.16*(areaFrom3texelTriangle.z+1.0);texelsWeightsB.y=0.16*(areaUncutFrom3texelTriangle.z);texelsWeightsB.z=0.16*(areaFrom3texelTriangle.w);}void sampleShadowComputeSamplesTent5x5(vec4 shadowMapTextureTexelSize,vec2 coord,out float fetchesWeights[9],out vec2 fetchesUV[9]){vec2 tentCenterInTexelSpace=coord.xy*shadowMapTextureTexelSize.zw;vec2 centerOfFetchesInTexelSpace=floor(tentCenterInTexelSpace+0.5);vec2 offsetFromTentCenterToCenterOfFetches=tentCenterInTexelSpace-centerOfFetchesInTexelSpace;vec3 texelsWeightsUA,texelsWeightsUB;vec3 texelsWeightsVA,texelsWeightsVB;sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.x,texelsWeightsUA,texelsWeightsUB);sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.y,texelsWeightsVA,texelsWeightsVB);vec3 fetchesWeightsU=vec3(texelsWeightsUA.xz,texelsWeightsUB.y)+vec3(texelsWeightsUA.y,texelsWeightsUB.xz);vec3 fetchesWeightsV=vec3(texelsWeightsVA.xz,texelsWeightsVB.y)+vec3(texelsWeightsVA.y,texelsWeightsVB.xz);vec3 fetchesOffsetsU=vec3(texelsWeightsUA.y,texelsWeightsUB.xz)/fetchesWeightsU.xyz+vec3(-2.5,-0.5,1.5);vec3 fetchesOffsetsV=vec3(texelsWeightsVA.y,texelsWeightsVB.xz)/fetchesWeightsV.xyz+vec3(-2.5,-0.5,1.5);fetchesOffsetsU*=shadowMapTextureTexelSize.xxx;fetchesOffsetsV*=shadowMapTextureTexelSize.yyy;vec2 bilinearFetchOrigin=centerOfFetchesInTexelSpace*shadowMapTextureTexelSize.xy;fetchesUV[0]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.x);fetchesUV[1]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.x);fetchesUV[2]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.x);fetchesUV[3]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.y);fetchesUV[4]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.y);fetchesUV[5]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.y);fetchesUV[6]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.z);fetchesUV[7]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.z);fetchesUV[8]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.z);fetchesWeights[0]=fetchesWeightsU.x*fetchesWeightsV.x;fetchesWeights[1]=fetchesWeightsU.y*fetchesWeightsV.x;fetchesWeights[2]=fetchesWeightsU.z*fetchesWeightsV.x;fetchesWeights[3]=fetchesWeightsU.x*fetchesWeightsV.y;fetchesWeights[4]=fetchesWeightsU.y*fetchesWeightsV.y;fetchesWeights[5]=fetchesWeightsU.z*fetchesWeightsV.y;fetchesWeights[6]=fetchesWeightsU.x*fetchesWeightsV.z;fetchesWeights[7]=fetchesWeightsU.y*fetchesWeightsV.z;fetchesWeights[8]=fetchesWeightsU.z*fetchesWeightsV.z;}"),t.Shader3D.addInclude("ShadowSampler.glsl",'\n#if !defined(ShadowSampler_lib)\n#define ShadowSampler_lib\n#ifdef RECEIVESHADOW\n#include "ShadowSampleTent.glsl";\n#include "ShadowCommon.glsl"\n#define ShadowStrength u_ShadowParams.x\n#define SpotShadowStrength u_ShadowParams.y\n#ifdef SHADOW\n#define CALCULATE_SHADOWS\nvarying vec4 v_ShadowCoord;float sampleShdowMapFiltered4(vec3 shadowCoord,vec4 shadowMapSize){float attenuation;vec4 attenuation4;vec2 offset=shadowMapSize.xy/2.0;vec3 shadowCoord0=shadowCoord+vec3(-offset,0.0);vec3 shadowCoord1=shadowCoord+vec3(offset.x,-offset.y,0.0);vec3 shadowCoord2=shadowCoord+vec3(-offset.x,offset.y,0.0);vec3 shadowCoord3=shadowCoord+vec3(offset,0.0);attenuation4.x=SAMPLE_TEXTURE2D_SHADOW(u_ShadowMap,shadowCoord0);attenuation4.y=SAMPLE_TEXTURE2D_SHADOW(u_ShadowMap,shadowCoord1);attenuation4.z=SAMPLE_TEXTURE2D_SHADOW(u_ShadowMap,shadowCoord2);attenuation4.w=SAMPLE_TEXTURE2D_SHADOW(u_ShadowMap,shadowCoord3);attenuation=dot(attenuation4,vec4(0.25));return attenuation;}float sampleShdowMapFiltered9(vec3 shadowCoord,vec4 shadowmapSize){float attenuation;float fetchesWeights[9];vec2 fetchesUV[9];sampleShadowComputeSamplesTent5x5(shadowmapSize,shadowCoord.xy,fetchesWeights,fetchesUV);attenuation=fetchesWeights[0]*SAMPLE_TEXTURE2D_SHADOW(u_ShadowMap,vec3(fetchesUV[0].xy,shadowCoord.z));attenuation+=fetchesWeights[1]*SAMPLE_TEXTURE2D_SHADOW(u_ShadowMap,vec3(fetchesUV[1].xy,shadowCoord.z));attenuation+=fetchesWeights[2]*SAMPLE_TEXTURE2D_SHADOW(u_ShadowMap,vec3(fetchesUV[2].xy,shadowCoord.z));attenuation+=fetchesWeights[3]*SAMPLE_TEXTURE2D_SHADOW(u_ShadowMap,vec3(fetchesUV[3].xy,shadowCoord.z));attenuation+=fetchesWeights[4]*SAMPLE_TEXTURE2D_SHADOW(u_ShadowMap,vec3(fetchesUV[4].xy,shadowCoord.z));attenuation+=fetchesWeights[5]*SAMPLE_TEXTURE2D_SHADOW(u_ShadowMap,vec3(fetchesUV[5].xy,shadowCoord.z));attenuation+=fetchesWeights[6]*SAMPLE_TEXTURE2D_SHADOW(u_ShadowMap,vec3(fetchesUV[6].xy,shadowCoord.z));attenuation+=fetchesWeights[7]*SAMPLE_TEXTURE2D_SHADOW(u_ShadowMap,vec3(fetchesUV[7].xy,shadowCoord.z));attenuation+=fetchesWeights[8]*SAMPLE_TEXTURE2D_SHADOW(u_ShadowMap,vec3(fetchesUV[8].xy,shadowCoord.z));return attenuation;}\n#endif\n#ifdef SHADOW_SPOT\n#define CALCULATE_SPOTSHADOWS\nvarying vec4 v_SpotShadowCoord;float sampleSpotShdowMapFiltered4(vec3 shadowCoord,vec4 shadowMapSize){float attenuation;vec4 attenuation4;vec2 offset=shadowMapSize.xy/2.0;vec3 shadowCoord0=shadowCoord+vec3(-offset,0.0);vec3 shadowCoord1=shadowCoord+vec3(offset.x,-offset.y,0.0);vec3 shadowCoord2=shadowCoord+vec3(-offset.x,offset.y,0.0);vec3 shadowCoord3=shadowCoord+vec3(offset,0.0);attenuation4.x=SAMPLE_TEXTURE2D_SHADOW(u_SpotShadowMap,shadowCoord0);attenuation4.y=SAMPLE_TEXTURE2D_SHADOW(u_SpotShadowMap,shadowCoord1);attenuation4.z=SAMPLE_TEXTURE2D_SHADOW(u_SpotShadowMap,shadowCoord2);attenuation4.w=SAMPLE_TEXTURE2D_SHADOW(u_SpotShadowMap,shadowCoord3);attenuation=dot(attenuation4,vec4(0.25));return attenuation;}float sampleSpotShdowMapFiltered9(vec3 shadowCoord,vec4 shadowmapSize){float attenuation;float fetchesWeights[9];vec2 fetchesUV[9];sampleShadowComputeSamplesTent5x5(shadowmapSize,shadowCoord.xy,fetchesWeights,fetchesUV);attenuation=fetchesWeights[0]*SAMPLE_TEXTURE2D_SHADOW(u_SpotShadowMap,vec3(fetchesUV[0].xy,shadowCoord.z));attenuation+=fetchesWeights[1]*SAMPLE_TEXTURE2D_SHADOW(u_SpotShadowMap,vec3(fetchesUV[1].xy,shadowCoord.z));attenuation+=fetchesWeights[2]*SAMPLE_TEXTURE2D_SHADOW(u_SpotShadowMap,vec3(fetchesUV[2].xy,shadowCoord.z));attenuation+=fetchesWeights[3]*SAMPLE_TEXTURE2D_SHADOW(u_SpotShadowMap,vec3(fetchesUV[3].xy,shadowCoord.z));attenuation+=fetchesWeights[4]*SAMPLE_TEXTURE2D_SHADOW(u_SpotShadowMap,vec3(fetchesUV[4].xy,shadowCoord.z));attenuation+=fetchesWeights[5]*SAMPLE_TEXTURE2D_SHADOW(u_SpotShadowMap,vec3(fetchesUV[5].xy,shadowCoord.z));attenuation+=fetchesWeights[6]*SAMPLE_TEXTURE2D_SHADOW(u_SpotShadowMap,vec3(fetchesUV[6].xy,shadowCoord.z));attenuation+=fetchesWeights[7]*SAMPLE_TEXTURE2D_SHADOW(u_SpotShadowMap,vec3(fetchesUV[7].xy,shadowCoord.z));attenuation+=fetchesWeights[8]*SAMPLE_TEXTURE2D_SHADOW(u_SpotShadowMap,vec3(fetchesUV[8].xy,shadowCoord.z));return attenuation;}\n#endif\n#endif\n#if defined(CALCULATE_SHADOWS)\n#ifdef SHADOW_CASCADE\nmediump int computeCascadeIndex(in vec3 positionWS){vec3 fromCenter0=positionWS-u_ShadowSplitSpheres[0].xyz;vec3 fromCenter1=positionWS-u_ShadowSplitSpheres[1].xyz;vec3 fromCenter2=positionWS-u_ShadowSplitSpheres[2].xyz;vec3 fromCenter3=positionWS-u_ShadowSplitSpheres[3].xyz;mediump vec4 comparison=vec4(dot(fromCenter0,fromCenter0)<u_ShadowSplitSpheres[0].w,dot(fromCenter1,fromCenter1)<u_ShadowSplitSpheres[1].w,dot(fromCenter2,fromCenter2)<u_ShadowSplitSpheres[2].w,dot(fromCenter3,fromCenter3)<u_ShadowSplitSpheres[3].w);comparison.yzw=clamp(comparison.yzw-comparison.xyz,0.0,1.0);mediump vec4 indexCoefficient=vec4(4.0,3.0,2.0,1.0);mediump int index=4-int(dot(comparison,indexCoefficient));return int(clamp(float(index),0.0,4.0));}\n#endif\nvec4 getShadowCoord(in vec3 positionWS){vec4 shadowCoord;vec2 tileMin=vec2(0.0);vec2 tileMax=vec2(1.0);\n#ifdef SHADOW_CASCADE\nmediump int cascadeIndex=computeCascadeIndex(positionWS);if(cascadeIndex>=4){return vec4(0.0,0.0,-1.0,1.0);}\n#ifdef GRAPHICS_API_GLES3\nmat4 shadowMat=u_ShadowMatrices[cascadeIndex];\n#else\nmat4 shadowMat;if(cascadeIndex==0){shadowMat=u_ShadowMatrices[0];}else if(cascadeIndex==1){shadowMat=u_ShadowMatrices[1];}else if(cascadeIndex==2){shadowMat=u_ShadowMatrices[2];}else{shadowMat=u_ShadowMatrices[3];}\n#endif\nshadowCoord=shadowMat*vec4(positionWS,1.0);vec2 tileSize=vec2(0.5,0.5*u_ShadowMapSize.z/u_ShadowMapSize.w);tileMin=vec2(mod(float(cascadeIndex),2.0),floor(float(cascadeIndex)/2.0))*tileSize;tileMax=tileMin+tileSize;\n#else\nshadowCoord=u_ShadowMatrices[0]*vec4(positionWS,1.0);\n#endif\nif(shadowCoord.w<=0.0){return vec4(0.0,0.0,-1.0,1.0);}vec2 uv=shadowCoord.xy/shadowCoord.w;if(any(lessThan(uv,tileMin))||any(greaterThan(uv,tileMax))){return vec4(0.0,0.0,-1.0,1.0);}vec2 guard=u_ShadowMapSize.xy*0.5;\n#if defined(SHADOW_SOFT_SHADOW_HIGH)\nguard=u_ShadowMapSize.xy*3.0;\n#elif defined(SHADOW_SOFT_SHADOW_LOW)\nguard=u_ShadowMapSize.xy;\n#endif\nshadowCoord.xy=clamp(shadowCoord.xy,(tileMin+guard)*shadowCoord.w,(tileMax-guard)*shadowCoord.w);return shadowCoord;}float sampleShadowmap(in vec4 shadowCoord){float attenuation=1.0;if(shadowCoord.w<=0.0){return 1.0;}vec3 coord=shadowCoord.xyz/shadowCoord.w;if(any(lessThan(coord.xy,vec2(0.0)))||any(greaterThan(coord.xy,vec2(1.0)))||coord.z<=0.0||coord.z>=1.0){return 1.0;}vec4 shadowmapSize=u_ShadowMapSize;{\n#if defined(SHADOW_SOFT_SHADOW_HIGH)\nattenuation=sampleShdowMapFiltered9(coord,shadowmapSize);\n#elif defined(SHADOW_SOFT_SHADOW_LOW)\nattenuation=sampleShdowMapFiltered4(coord,shadowmapSize);\n#else\nattenuation=SAMPLE_TEXTURE2D_SHADOW(u_ShadowMap,coord);\n#endif\nattenuation=mix(1.0,attenuation,ShadowStrength);}return attenuation;}\n#endif\n#if defined(CALCULATE_SPOTSHADOWS)\nvec4 getSpotShadowCoord(in vec3 positionWS){vec4 coordinate=u_SpotViewProjectMatrix*vec4(positionWS,1.0);return coordinate;}float sampleSpotShadowmap(vec4 shadowCoord){float attenuation=1.0;vec3 coord=shadowCoord.xyz/shadowCoord.w;coord.xy=coord.xy*0.5+0.5;vec4 shadowmapSize=u_SpotShadowMapSize;\n#if defined(SHADOW_SPOT_SOFT_SHADOW_HIGH)\nattenuation=sampleSpotShdowMapFiltered9(coord,shadowmapSize);\n#elif defined(SHADOW_SPOT_SOFT_SHADOW_LOW)\nattenuation=sampleSpotShdowMapFiltered4(coord,shadowmapSize);\n#else\nattenuation=SAMPLE_TEXTURE2D_SHADOW(u_SpotShadowMap,coord);\n#endif\nattenuation=mix(1.0,attenuation,SpotShadowStrength);if(coord.z>0.0&&coord.z<1.0)return attenuation;return 1.0;}\n#endif\n#endif\n'),t.Shader3D.addInclude("Lighting.glsl",'#if !defined(Lighting_lib)\n#define Lighting_lib\n#include "ShadowSampler.glsl";\nstruct Light{vec3 color;vec3 dir;float attenuation;};struct DirectionLight{vec3 color;vec3 direction;float attenuation;int lightMode;};struct PointLight{vec3 color;vec3 position;float range;float attenuation;int lightMode;};struct SpotLight{vec3 color;vec3 position;float range;vec3 direction;float spot;float attenuation;int lightMode;};\n#define LightMode_Mix 0\n#define LightMode_RealTime 1\nint getAttenuationByMode(float lightMapMode){\n#ifdef LIGHTMAP\nreturn int(lightMapMode);\n#else\n#ifdef VOLUMETRICGI\nreturn int(lightMapMode);\n#endif\n#endif\nreturn LightMode_RealTime;}\n#if defined(DIRECTIONLIGHT) || defined(POINTLIGHT) || defined(SPOTLIGHT)\n#define LIGHTING\nfloat attenuation(in vec3 L,in float invLightRadius){float fRatio=clamp(length(L)*invLightRadius,0.0,1.0);fRatio*=fRatio;return 1.0/(1.0+25.0*fRatio)*clamp(4.0*(1.0-fRatio),0.0,1.0);}Light getLight(in DirectionLight directionLight){Light light;light.color=directionLight.color;light.dir=directionLight.direction;light.attenuation=directionLight.attenuation;return light;}Light getLight(in PointLight pointLight,in vec3 normalWS,in vec3 positionWS){vec3 lightDirection=positionWS-pointLight.position;float rangeAttenuate=attenuation(lightDirection,1.0/pointLight.range);Light light;light.color=pointLight.color*rangeAttenuate;light.dir=normalize(lightDirection);light.attenuation=pointLight.attenuation;return light;}Light getLight(in SpotLight spotLight,in vec3 normalWS,in vec3 positionWS){vec3 lightDirection=positionWS-spotLight.position;vec3 normalizeLightDir=normalize(lightDirection);vec2 cosAngles=cos(vec2(spotLight.spot,spotLight.spot*0.5)*0.5);float dirAttenuate=dot(spotLight.direction,normalizeLightDir);dirAttenuate*=smoothstep(cosAngles.x,cosAngles.y,dirAttenuate);float rangeAttenuate=attenuation(lightDirection,1.0/spotLight.range);Light light;light.color=spotLight.color*rangeAttenuate*dirAttenuate;light.dir=normalizeLightDir;light.attenuation=spotLight.attenuation;return light;}\n#ifdef LEGACYSINGLELIGHTING\n#define CalculateLightCount 1\n#define DirectionCount 1\n#ifdef DIRECTIONLIGHT\nuniform vec3 u_DirLightColor;uniform vec3 u_DirLightDirection;uniform int u_DirLightMode;\n#endif\n#ifdef POINTLIGHT\nuniform vec3 u_PointLightColor;uniform vec3 u_PointLightPos;uniform float u_PointLightRange;uniform int u_PointLightMode;\n#endif\n#ifdef SPOTLIGHT\nuniform vec3 u_SpotLightPos;uniform vec3 u_SpotLightColor;uniform vec3 u_SpotLightDirection;uniform float u_SpotLightRange;uniform float u_SpotLightSpot;uniform int u_SpotLightMode;\n#endif\n#else\n#define CalculateLightCount MAX_LIGHT_COUNT\n#define DirectionCount u_DirationLightCount\nuniform sampler2D u_LightBuffer;\n#if defined(POINTLIGHT) || defined(SPOTLIGHT)\nconst int c_ClusterBufferWidth=CLUSTER_X_COUNT*CLUSTER_Y_COUNT;int c_ClusterBufferHeight=CLUSTER_Z_COUNT*(1+int(ceil(float(MAX_LIGHT_COUNT_PER_CLUSTER)/4.0)));const int c_ClusterBufferFloatWidth=c_ClusterBufferWidth*4;uniform sampler2D u_LightClusterBuffer;int getLightIndex(in int offset,in int index){int totalOffset=offset+index;int row=totalOffset/c_ClusterBufferFloatWidth;int lastRowFloat=totalOffset-row*c_ClusterBufferFloatWidth;int col=lastRowFloat/4;\n#ifdef GRAPHICS_API_GLES3\nvec4 texPixel=texelFetch(u_LightClusterBuffer,ivec2(col,row),0);int pixelComponent=lastRowFloat-col*4;return int(texPixel[pixelComponent]);\n#else\nvec2 uv=vec2((float(col)+0.5)/float(c_ClusterBufferWidth),(float(row)+0.5)/float(c_ClusterBufferHeight));vec4 texPixel=texture2DLodEXT(u_LightClusterBuffer,uv,0.0);int pixelComponent=lastRowFloat-col*4;if(pixelComponent==0)return int(texPixel.x);else if(pixelComponent==1)return int(texPixel.y);else if(pixelComponent==2)return int(texPixel.z);else return int(texPixel.w);\n#endif\n}\n#endif\n#endif\n#ifdef DIRECTIONLIGHT\nDirectionLight getDirectionLight(in int index,in vec3 positionWS){DirectionLight light;\n#ifdef LEGACYSINGLELIGHTING\nlight.color=u_DirLightColor;light.direction=u_DirLightDirection;light.attenuation=1.0;light.lightMode=getAttenuationByMode(float(u_DirLightMode));\n#else\n#ifdef GRAPHICS_API_GLES3\nvec4 p1=texelFetch(u_LightBuffer,ivec2(0,index),0);vec4 p2=texelFetch(u_LightBuffer,ivec2(1,index),0);\n#else\nfloat v=(float(index)+0.5)/float(CalculateLightCount);vec4 p1=texture2DLodEXT(u_LightBuffer,vec2(0.125,v),0.0);vec4 p2=texture2DLodEXT(u_LightBuffer,vec2(0.375,v),0.0);\n#endif\nlight.color=p1.rgb;light.direction=p2.rgb;light.attenuation=1.0;light.lightMode=getAttenuationByMode(p1.a);\n#endif\n#if defined(CALCULATE_SHADOWS)\nif(index==0){vec4 shadowCoord=getShadowCoord(positionWS);float shadowAttenuation=sampleShadowmap(shadowCoord);light.attenuation=shadowAttenuation;}\n#endif\nreturn light;}\n#endif\n#if defined(POINTLIGHT) || defined(SPOTLIGHT)\nivec4 getClusterInfo(mat4 viewMatrix,vec4 viewport,vec3 positionWS,vec4 fragCoord,vec4 projectParams){\n#ifdef LEGACYSINGLELIGHTING\nreturn ivec4(1,1,0,0);\n#else\nvec3 viewPos=vec3(viewMatrix*vec4(positionWS,1.0));int clusterXIndex=int(floor(fragCoord.x/(float(viewport.z)/float(CLUSTER_X_COUNT))));int clusterYIndex=int(floor((viewport.w*(projectParams.z<0.0 ? 0.0 : 1.0)-fragCoord.y*projectParams.z)/(float(viewport.w)/float(CLUSTER_Y_COUNT))));float zSliceParam=float(CLUSTER_Z_COUNT)/log2(projectParams.y/projectParams.x);int clusterZIndex=int(floor(log2(-viewPos.z)*zSliceParam-log2(projectParams.x)*zSliceParam));\n#ifdef GRAPHICS_API_GLES3\nvec4 clusterPixel=texelFetch(u_LightClusterBuffer,ivec2(clusterXIndex+clusterYIndex*CLUSTER_X_COUNT,clusterZIndex),0);\n#else\nvec2 uv=vec2((float(clusterXIndex+clusterYIndex*CLUSTER_X_COUNT)+0.5)/float(c_ClusterBufferWidth),(float(clusterZIndex)+0.5)/float(c_ClusterBufferHeight));vec4 clusterPixel=texture2DLodEXT(u_LightClusterBuffer,uv,0.0);\n#endif\nreturn ivec4(clusterPixel);\n#endif\n}\n#endif\n#ifdef POINTLIGHT\nPointLight getPointLight(in int index,in ivec4 clusterInfo,in vec3 positionWS){PointLight light;\n#ifdef LEGACYSINGLELIGHTING\nlight.color=u_PointLightColor;light.position=u_PointLightPos;light.range=u_PointLightRange;light.attenuation=1.0;light.lightMode=getAttenuationByMode(float(u_PointLightMode));\n#else\nint indexOffset=clusterInfo.z*c_ClusterBufferFloatWidth+clusterInfo.w;int pointIndex=getLightIndex(indexOffset,index);\n#ifdef GRAPHICS_API_GLES3\nvec4 p1=texelFetch(u_LightBuffer,ivec2(0,pointIndex),0);vec4 p2=texelFetch(u_LightBuffer,ivec2(1,pointIndex),0);\n#else\nfloat v=(float(pointIndex)+0.5)/float(CalculateLightCount);vec4 p1=texture2DLodEXT(u_LightBuffer,vec2(0.125,v),0.0);vec4 p2=texture2DLodEXT(u_LightBuffer,vec2(0.375,v),0.0);\n#endif\nlight.color=p1.rgb;light.range=p1.a;light.position=p2.rgb;light.attenuation=1.0;light.lightMode=getAttenuationByMode(p2.a);\n#endif\nreturn light;}\n#endif\n#ifdef SPOTLIGHT\nSpotLight getSpotLight(in int index,in ivec4 clusterInfo,in vec3 positionWS){SpotLight light;\n#ifdef LEGACYSINGLELIGHTING\nlight.color=u_SpotLightColor;light.position=u_SpotLightPos;light.range=u_SpotLightRange;light.direction=u_SpotLightDirection;light.spot=u_SpotLightSpot;light.attenuation=1.0;light.lightMode=getAttenuationByMode(float(u_SpotLightMode));\n#else\nint indexOffset=clusterInfo.z*c_ClusterBufferFloatWidth+clusterInfo.w;int spotIndex=getLightIndex(indexOffset,index+clusterInfo.x);\n#ifdef GRAPHICS_API_GLES3\nvec4 p1=texelFetch(u_LightBuffer,ivec2(0,spotIndex),0);vec4 p2=texelFetch(u_LightBuffer,ivec2(1,spotIndex),0);vec4 p3=texelFetch(u_LightBuffer,ivec2(2,spotIndex),0);\n#else\nfloat v=(float(spotIndex)+0.5)/float(CalculateLightCount);vec4 p1=texture2DLodEXT(u_LightBuffer,vec2(0.125,v),0.0);vec4 p2=texture2DLodEXT(u_LightBuffer,vec2(0.375,v),0.0);vec4 p3=texture2DLodEXT(u_LightBuffer,vec2(0.625,v),0.0);\n#endif\nlight.color=p1.rgb;light.range=p1.a;light.position=p2.rgb;light.spot=p2.a;light.direction=p3.rgb;light.attenuation=1.0;light.lightMode=getAttenuationByMode(p3.a);\n#endif\n#if defined(CALCULATE_SPOTSHADOWS)\nif(index==0){vec4 shadowCoord=getSpotShadowCoord(positionWS);float shadowAttenuation=sampleSpotShadowmap(shadowCoord);light.attenuation=shadowAttenuation;}\n#endif\nreturn light;}\n#endif\n#endif\n#endif\n'),t.Shader3D.addInclude("globalIllumination.glsl",'#if !defined(globalIllumination_lib)\n#define globalIllumination_lib\n#ifdef ENUNIFORMBLOCK\nuniform ReflectionProbe{vec4 u_AmbientColor;vec3 u_IblSH[9];float u_IBLRoughnessLevel;float u_AmbientIntensity;float u_ReflectionIntensity;};uniform samplerCube u_IBLTex;\n#else\nuniform vec4 u_AmbientColor;uniform vec3 u_IblSH[9];uniform samplerCube u_IBLTex;uniform float u_IBLRoughnessLevel;uniform float u_AmbientIntensity;uniform float u_ReflectionIntensity;\n#endif\n#ifdef VOLUMETRICGI\n#include "VolumetricGI.glsl";\n#endif\nvec3 rotateByYAixs(in vec3 normal){float co=cos(u_GIRotate);float si=sin(u_GIRotate);float x=normal.x*co-normal.z*si;float z=normal.x*si+normal.z*co;return vec3(x,normal.y,z);}vec4 rotateByYAixs(in vec4 normal){float co=cos(u_GIRotate);float si=sin(u_GIRotate);float x=normal.x*co-normal.z*si;float z=normal.x*si+normal.z*co;return vec4(x,normal.y,z,normal.w);}\n#ifdef GI_IBL\nvec3 diffuseIrradiance(in vec3 normalWS){vec3 n=normalWS*vec3(-1.0,1.0,1.0);n=rotateByYAixs(n);return max(u_IblSH[0]+u_IblSH[1]*n.y+u_IblSH[2]*n.z+u_IblSH[3]*n.x+u_IblSH[4]*(n.y*n.x)+u_IblSH[5]*(n.y*n.z)+u_IblSH[6]*(3.0*n.z*n.z-1.0)+u_IblSH[7]*(n.z*n.x)+u_IblSH[8]*(n.x*n.x-n.y*n.y),0.0)*u_AmbientIntensity;}vec3 diffuseIrradiance(in vec3 normalWS,in vec3 positionWS,in vec3 viewDir){\n#ifdef VOLUMETRICGI\nvec3 surfaceBias=VolumetricGISurfaceBias(normalWS,viewDir);return VolumetricGIVolumeIrradiance(positionWS,surfaceBias,normalWS)*u_AmbientIntensity;\n#else\nreturn diffuseIrradiance(normalWS);\n#endif\n}vec3 specularRadiance(in vec3 r,in float perceptualRoughness){float lod=u_IBLRoughnessLevel*perceptualRoughness*(2.0-perceptualRoughness);vec3 reflectDir=r*vec3(-1.0,1.0,1.0);reflectDir=rotateByYAixs(reflectDir);vec4 reflectSampler=textureCubeLodEXT(u_IBLTex,reflectDir,lod);\n#ifdef IBL_RGBD\nreturn decodeRGBD(reflectSampler)*u_ReflectionIntensity;\n#else\nreturn reflectSampler.rgb*u_ReflectionIntensity;\n#endif\n}\n#endif\n#ifdef GI_LEGACYIBL\nuniform vec4 u_AmbientSHAr;uniform vec4 u_AmbientSHAg;uniform vec4 u_AmbientSHAb;uniform vec4 u_AmbientSHBr;uniform vec4 u_AmbientSHBg;uniform vec4 u_AmbientSHBb;uniform vec4 u_AmbientSHC;\n#define LAYA_SPECCUBE_LOD_STEPS 6.0\nuniform samplerCube u_ReflectTexture;uniform vec4 u_ReflectCubeHDRParams;vec3 shEvalLinearL0L1(in vec4 normal){vec3 x;x.r=dot(u_AmbientSHAr,normal);x.g=dot(u_AmbientSHAg,normal);x.b=dot(u_AmbientSHAb,normal);return x;}vec3 shEvalLinearL2(in vec4 normal){vec3 x1,x2;vec4 vB=normal.xyzz*normal.yzzx;x1.r=dot(u_AmbientSHBr,vB);x1.g=dot(u_AmbientSHBg,vB);x1.b=dot(u_AmbientSHBb,vB);float vC=normal.x*normal.x-normal.y*normal.y;x2=u_AmbientSHC.rgb*vC;return x1+x2;}vec3 diffuseIrradiance(in vec3 normalWS){vec4 normal=vec4(-normalWS.x,normalWS.yz,1.0);normal=rotateByYAixs(normal);vec3 ambientContrib=shEvalLinearL0L1(normal);ambientContrib+=shEvalLinearL2(normal);vec3 ambient=max(vec3(0.0),ambientContrib);return ambient*u_AmbientIntensity;}vec3 diffuseIrradiance(in vec3 normalWS,in vec3 positionWS,in vec3 viewDir){\n#ifdef VOLUMETRICGI\nvec3 surfaceBias=VolumetricGISurfaceBias(normalWS,viewDir);return VolumetricGIVolumeIrradiance(positionWS,surfaceBias,normalWS)*u_AmbientIntensity;\n#else\nreturn diffuseIrradiance(normalWS);\n#endif\n}vec3 specularRadiance(in vec3 r,in float perceptualRoughness){float roughness=perceptualRoughness*(1.7-0.7*perceptualRoughness);r*=vec3(-1.0,1.0,1.0);r=rotateByYAixs(r);float lod=roughness*LAYA_SPECCUBE_LOD_STEPS;vec4 rgbm=textureCubeLodEXT(u_ReflectTexture,r,lod);float range=u_ReflectCubeHDRParams.x;vec3 color=decodeRGBM(rgbm,range);color=gammaToLinear(color);return color*u_ReflectionIntensity;}\n#endif\n#ifndef GI_IBL\n#ifndef GI_LEGACYIBL\nvec3 diffuseIrradiance(in vec3 normalWS){return u_AmbientColor.rgb*u_AmbientIntensity;}vec3 diffuseIrradiance(in vec3 normalWS,in vec3 positionWS,in vec3 viewDir){return diffuseIrradiance(normalWS);}vec3 specularRadiance(in vec3 r,in float perceptualRoughness){return u_AmbientColor.rgb*u_ReflectionIntensity;}\n#endif\n#endif\n#ifdef LIGHTMAP\n#ifdef UV1\n#define USELIGHTMAP\n#endif\nuniform sampler2D u_LightMap;\n#ifdef LIGHTMAP_DIRECTIONAL\nuniform sampler2D u_LightMapDirection;vec3 DecodeDirectionalLightmap(in vec2 lightmapUV,in vec3 bakeColor,in vec3 normalWS){vec4 dirLightmap=texture2D(u_LightMapDirection,lightmapUV);vec3 lightdir=normalize(dirLightmap.xyz-vec3(0.5));float halfLambert=clamp(dot(normalWS,lightdir),0.0,1.0)*0.5+0.5;return bakeColor*halfLambert/max(dirLightmap.w,0.001);}\n#endif\nvec3 getBakedLightmapColor(in vec2 lightmapUV,in vec3 normalWS){vec4 lightmapSampler=texture2D(u_LightMap,lightmapUV);lightmapSampler.rgb=decodeRGBM(lightmapSampler,5.0);lightmapSampler=gammaToLinear(lightmapSampler);\n#ifdef LIGHTMAP_DIRECTIONAL\nlightmapSampler.rgb=DecodeDirectionalLightmap(lightmapUV,lightmapSampler.rgb,normalWS);\n#endif\nreturn lightmapSampler.rgb;}\n#endif\n#ifdef SPECCUBE_BOX_PROJECTION\nuniform vec3 u_SpecCubeProbePosition;uniform vec3 u_SpecCubeBoxMax;uniform vec3 u_SpecCubeBoxMin;vec3 getBoxProjectionReflectedVector(vec3 r,vec3 positionWS){vec3 boxCenter=u_SpecCubeProbePosition;vec3 boxMin=u_SpecCubeBoxMin;vec3 boxMax=u_SpecCubeBoxMax;vec3 nr=normalize(r);vec3 rbmax=boxMax-positionWS;vec3 rbmin=boxMin-positionWS;vec3 select=step(vec3(0.0),r);vec3 rbminmax=mix(rbmin,rbmax,select)/nr;float scalar=vecmin(rbminmax);vec3 boxr=nr*scalar+positionWS-boxCenter;return boxr;}\n#endif\n#endif\n'),t.Shader3D.addInclude("Oct.glsl","#if !defined(Oct_lib)\n#define Oct_lib\nfloat signNotZero(in float k){return k>=0.0 ? 1.0 :-1.0;}vec2 signNotZero(in vec2 v){return vec2(signNotZero(v.x),signNotZero(v.y));}vec2 octEncode(in vec3 v){float l1norm=abs(v.x)+abs(v.y)+abs(v.z);vec2 result=v.xy*(1.0/l1norm);if(v.z<0.0){result=(1.0-abs(result.yx))*signNotZero(result.xy);}return result;}vec3 finalDecode(float x,float y){vec3 v=vec3(x,y,1.0-abs(x)-abs(y));if(v.z<0.0){v.xy=(1.0-abs(v.yx))*signNotZero(v.xy);}return normalize(v);}vec2 textureCoordFromDirection(in vec3 dir,vec4 outSize,vec4 gridSize){vec2 uv=(octEncode(normalize(dir)))*0.5+0.5;uv=uv*(outSize.xy-vec2(2.0,2.0))*outSize.zw+outSize.zw;uv=gridSize.xy*(1.0/gridSize.zw)+uv*(1.0/gridSize.zw);return uv;}\n#endif\n"),t.Shader3D.addInclude("GridHelpers.glsl","#if !defined(GridHelpers_lib)\n#define GridHelpers_lib\nint imod(int x,int y){\n#ifdef GRAPHICS_API_GLES3\nreturn x % y;\n#else\nreturn x-(x/y)*y;\n#endif\n}int gridCoordToProbeIndex(in ivec3 probeCoords,const in ivec3 probeCounts){return probeCoords.x+probeCoords.y*probeCounts.x+probeCoords.z*probeCounts.x*probeCounts.y;}ivec3 probeIndexToGridcoord(in int probeIndex,const in ivec3 probeCounts){ivec3 iPos;iPos.x=imod(probeIndex,probeCounts.x);iPos.y=imod(probeIndex,(probeCounts.x*probeCounts.y))/probeCounts.x;iPos.z=probeIndex/(probeCounts.x*probeCounts.y);return iPos;}vec3 gridCoordToPosition(in ivec3 coord,const in vec3 probeStep,const in vec3 probeStartPosition){return(vec3(coord)+0.5)*probeStep+probeStartPosition;}ivec3 baseGridCoord(in vec3 position,in vec3 probeStep,in vec3 probeStartPosition,in ivec3 probeCounts){probeStartPosition+=0.5*probeStep;return ivec3(clamp(vec3((position-probeStartPosition)/probeStep),vec3(0,0,0),vec3(probeCounts)-vec3(1,1,1)));}\n#endif\n"),t.Shader3D.addInclude("VolumetricGI.glsl",'\n#if !defined(VolumetricGI_lib)\n#define VolumetricGI_lib\n#include "Oct.glsl";\n#include "GridHelpers.glsl";\n#ifdef ENUNIFORMBLOCK\nuniform VolumetricGIProbe{vec3 u_VolGIProbeCounts;vec3 u_VolGIProbeStep;vec3 u_VolGIProbeStartPosition;vec4 u_VolGIProbeParams;};uniform sampler2D u_ProbeIrradiance;uniform sampler2D u_ProbeDistance;\n#else\nuniform vec3 u_VolGIProbeCounts;uniform vec3 u_VolGIProbeStep;uniform vec3 u_VolGIProbeStartPosition;uniform vec4 u_VolGIProbeParams;uniform sampler2D u_ProbeIrradiance;uniform sampler2D u_ProbeDistance;\n#endif\nstruct VolumetricGI{vec3 probeCounts;vec3 probeStep;vec3 probeStartPosition;vec4 probeParams;};vec2 porbeGridCoordToTextureGridCoord(in ivec3 porbeGridCoord,in ivec3 probeCounts,in vec2 textureGridSize){int probeIndex=gridCoordToProbeIndex(porbeGridCoord,probeCounts);ivec2 index;index.x=imod(probeIndex,(probeCounts.x*probeCounts.y));index.y=probeIndex/(probeCounts.x*probeCounts.y);vec2 textureGridCoord=vec2(index);textureGridCoord.y=textureGridCoord.y;return textureGridCoord;}vec3 VolumetricGISurfaceBias(in vec3 surfaceNormal,in vec3 cameraDirection){return surfaceNormal*u_VolGIProbeParams.z+cameraDirection*u_VolGIProbeParams.w;}vec3 VolumetricGIVolumeIrradiance(in vec3 worldPosition,in vec3 surfaceBias,in vec3 direction){ivec3 porbeCounts=ivec3(u_VolGIProbeCounts);vec3 probeStep=u_VolGIProbeStep;vec3 probeStartPosition=u_VolGIProbeStartPosition;vec2 volumeCounts=vec2(porbeCounts.x*porbeCounts.y,porbeCounts.z);vec4 irradianceTexels=vec4(u_VolGIProbeParams.x,u_VolGIProbeParams.x,1.0/u_VolGIProbeParams.x,1.0/u_VolGIProbeParams.x);vec4 distanceTexels=vec4(u_VolGIProbeParams.y,u_VolGIProbeParams.y,1.0/u_VolGIProbeParams.y,1.0/u_VolGIProbeParams.y);ivec3 maxGridCoord=porbeCounts-ivec3(1);vec3 irradiance=vec3(0.0);float accumulatedWeights=0.0;vec3 biasedWorldPosition=worldPosition+surfaceBias;ivec3 baseProbeCoords=baseGridCoord(biasedWorldPosition,probeStep,probeStartPosition,porbeCounts);vec3 baseProbeWorldPosition=gridCoordToPosition(baseProbeCoords,probeStep,probeStartPosition);vec3 gridSpaceDistance=biasedWorldPosition-baseProbeWorldPosition;vec3 alpha=clamp(gridSpaceDistance/probeStep,vec3(0.0),vec3(1.0));for(int probeIndex=0;probeIndex<8;probeIndex++){ivec3 adjacentProbeOffset=ivec3(imod(probeIndex,2),imod((probeIndex/2),2),imod((probeIndex/4),2));ivec3 adjacentProbeCoords=ivec3(clamp(vec3(baseProbeCoords+adjacentProbeOffset),vec3(0),vec3(maxGridCoord)));vec3 adjacentProbeWorldPosition=gridCoordToPosition(adjacentProbeCoords,probeStep,probeStartPosition);vec3 worldPosToAdjProbe=normalize(adjacentProbeWorldPosition-worldPosition);vec3 biasedPosToAdjProbe=normalize(adjacentProbeWorldPosition-biasedWorldPosition);float biasedPosToAdjProbeDist=distance(adjacentProbeWorldPosition,biasedWorldPosition);vec3 trilinear=max(vec3(0.001),mix(1.0-alpha,alpha,vec3(adjacentProbeOffset)));float trilinearWeight=trilinear.x*trilinear.y*trilinear.z;float weight=1.0;float warpShading=(dot(worldPosToAdjProbe,direction)+1.0)*0.5;weight*=(warpShading*warpShading)*0.2;vec2 textureGridCoord=porbeGridCoordToTextureGridCoord(adjacentProbeCoords,porbeCounts,volumeCounts);vec2 probeTextureUV=textureCoordFromDirection(-biasedPosToAdjProbe,distanceTexels,vec4(textureGridCoord,volumeCounts));vec3 filteredDistance=texture2D(u_ProbeDistance,probeTextureUV).xyz;float variance=abs(filteredDistance.x*filteredDistance.x-filteredDistance.y);float chebyshevWeight=1.0;if(biasedPosToAdjProbeDist>filteredDistance.x){float v=biasedPosToAdjProbeDist-filteredDistance.x;chebyshevWeight=variance/(variance+(v*v));chebyshevWeight=max(chebyshevWeight*chebyshevWeight*chebyshevWeight,0.0);}if(filteredDistance.z<1.0){chebyshevWeight=1.0;}weight*=max(0.05,chebyshevWeight);weight=max(0.000001,weight);const float crushThreshold=0.2;if(weight<crushThreshold){weight*=(weight*weight)*(1.0/(crushThreshold*crushThreshold));}weight*=trilinearWeight;probeTextureUV=textureCoordFromDirection(direction,irradianceTexels,vec4(textureGridCoord,volumeCounts));vec3 probeIrradiance=linearToGamma(texture2D(u_ProbeIrradiance,probeTextureUV).rgb);irradiance+=(probeIrradiance*weight);accumulatedWeights+=weight;}if(accumulatedWeights==0.0){return vec3(0.0);}irradiance*=(1.0/accumulatedWeights);irradiance=gammaToLinear(irradiance);return irradiance;}\n#endif\n'),t.Shader3D.addInclude("BlinnPhongLighting.glsl",'#if !defined(BlinnPhongLighting_lib)\n#define BlinnPhongLighting_lib\n#include "Lighting.glsl";\n#include "globalIllumination.glsl";\nstruct PixelInfo{vec3 positionWS;vec3 vertexNormalWS;vec3 normalWS;vec3 viewDir;\n#ifdef LIGHTMAP\n#ifdef UV1\nvec2 lightmapUV;\n#endif\n#endif\n};struct Surface{vec3 diffuseColor;vec3 specularColor;float shininess;vec3 gloss;vec3 normalTS;float alpha;float alphaClip;};vec3 BlinnPhongLighting(in Surface surface,in Light light,in PixelInfo pixel){vec3 l=normalize(-light.dir);vec3 v=pixel.viewDir;vec3 normalWS=pixel.normalWS;vec3 diffuseColor=surface.diffuseColor;float shininess=surface.shininess;vec3 specularColor=surface.specularColor;vec3 gloss=surface.gloss;float ndl=max(0.0,dot(normalWS,l));vec3 lightDiffuse=light.color*diffuseColor*ndl;mediump vec3 h=normalize(v+l);lowp float ndh=max(0.0,dot(h,normalWS));float specularIntensity=pow(ndh,shininess*128.0);vec3 lightSpecular=light.color*specularColor*specularIntensity*gloss;return lightDiffuse+lightSpecular;}vec3 BlinnPhongGI(const in Surface surface,const in PixelInfo info){vec3 indirect=vec3(0.0);\n#ifdef LIGHTMAP\n#ifdef UV1\nvec2 lightmapUV=info.lightmapUV;vec3 bakedColor=getBakedLightmapColor(lightmapUV,info.normalWS);indirect=bakedColor*surface.diffuseColor;\n#endif\n#else\nvec3 n=info.normalWS;indirect=diffuseIrradiance(n)*surface.diffuseColor;\n#endif\nreturn indirect;}\n#endif\n'),t.Shader3D.addInclude("PBRLighting.glsl",'#if !defined(PBRLighting_lib)\n#define PBRLighting_lib\n#include "Lighting.glsl";\n#if !defined(GL_FRAGMENT_PRECISION_HIGH)\n#define MIN_PERCEPTUAL_ROUGHNESS 0.089\n#define MIN_ROUGHNESS 0.007921\n#else\n#define MIN_PERCEPTUAL_ROUGHNESS 0.045\n#define MIN_ROUGHNESS 0.002025\n#endif\n#define MIN_N_DOT_V 1e-4\n#include "BRDF.glsl";\nstruct PixelInfo{vec3 positionWS;vec3 vertexNormalWS;vec3 normalWS;vec3 tangentWS;vec3 biNormalWS;vec3 viewDir;float NoV;vec3 dfg;vec3 energyCompensation;\n#ifdef IRIDESCENCE\nvec3 iridescenceFresnel;\n#endif\n#ifdef CLEARCOAT\nvec3 clearCoatNormal;float clearCoatNoV;\n#endif\n#ifdef SHEEN\nfloat sheenScaling;float sheenDfg;\n#endif\n#ifdef ANISOTROPIC\nvec3 anisotropicT;vec3 anisotropicB;float ToV;float BoV;float at;float ab;\n#endif\n#ifdef THICKNESS\nvec4 worldScale;\n#endif\n#ifdef LIGHTMAP\n#ifdef UV1\nvec2 lightmapUV;\n#endif\n#endif\n};struct Surface{vec3 diffuseColor;float alpha;vec3 f0;vec3 f90;float roughness;float perceptualRoughness;float occlusion;\n#ifdef EMISSION\nvec3 emissionColor;\n#endif\nvec3 normalTS;float ior;\n#ifdef CLEARCOAT\nfloat clearCoat;float clearCoatRoughness;float clearCoatPerceptualRoughness;\n#ifdef CLEARCOAT_NORMAL\nvec3 clearCoatNormalTS;\n#endif\n#endif\n#ifdef ANISOTROPIC\nfloat anisotropy;vec2 anisotropyDirection;\n#endif\n#ifdef IRIDESCENCE\nfloat iridescence;float iridescenceIor;float iridescenceThickness;\n#endif\n#ifdef SHEEN\nvec3 sheenColor;float sheenRoughness;float sheenPerceptualRoughness;\n#endif\n#ifdef TRANSMISSION\nfloat transmission;\n#endif\n#ifdef THICKNESS\nfloat thickness;vec3 attenuationColor;float attenuationDistance;\n#endif\n};struct LightParams{vec3 l;vec3 h;float NoL;float NoH;float LoH;float VoH;\n#ifdef CLEARCOAT\nfloat clearCoatNoH;float clearCoatNoL;\n#endif\n#ifdef ANISOTROPIC\nfloat ToL;float BoL;\n#endif\n};void initLightParams(inout LightParams params,const in PixelInfo pixel,const in Light light){vec3 v=pixel.viewDir;vec3 n=pixel.normalWS;vec3 l=normalize(-light.dir);params.l=l;vec3 h=SafeNormalize(v+l);params.h=h;params.NoL=saturate(dot(n,l));params.NoH=saturate(dot(n,h));params.LoH=saturate(dot(l,h));params.VoH=saturate(dot(v,h));\n#ifdef CLEARCOAT\nparams.clearCoatNoL=saturate(dot(pixel.clearCoatNormal,l));params.clearCoatNoH=saturate(dot(pixel.clearCoatNormal,h));\n#endif\n#ifdef ANISOTROPIC\nvec3 t=pixel.anisotropicT;vec3 b=pixel.anisotropicB;params.ToL=dot(t,l);params.BoL=dot(b,l);\n#endif\n}vec3 prefilteredDFG_LUT(float roughness,float NoV){vec2 samplePoint=clamp(vec2(NoV,roughness),vec2(0.0,0.0),vec2(1.0,1.0));samplePoint.y=1.0-samplePoint.y;\n#if defined(FLOATTEXTURE) && defined(FLOATTEXTURE_FIL_LINEAR)\nreturn(texture2D(u_IBLDFG,samplePoint)).rgb;\n#else\nreturn decodeRGBD(texture2D(u_IBLDFG,samplePoint));\n#endif\n}vec2 EnvBRDFApproxLazarov(float roughness,float NoV){vec4 c0=vec4(-1,-0.0275,-0.572,0.022);vec4 c1=vec4(1,0.0425,1.04,-0.04);vec4 r=roughness*c0+c1;float a004=min(r.x*r.x,exp2(-9.28*NoV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return AB;}float dielectricSpecularToF0(float specular){return 0.08*specular;}float dielectricF0ToIor(float f0){return 2.0/(1.0-sqrt(min(f0,0.99)))-1.0;}float dielectricIorToF0(float ior){return pow2((ior-1.0)/(ior+1.0));}vec3 computeF0(vec3 f0,vec3 baseColor,float metallic){return mix(f0,baseColor,metallic);}vec3 computeF90(vec3 f0){return vec3(saturate(dot(f0,vec3(50.0*0.33))));}vec3 computeDiffuse(vec3 baseColor,float metallic){return(1.0-metallic)*baseColor;}float specularAA(float roughness,in vec3 normalWS){\n#if !defined(GRAPHICS_API_GLES3) && !defined(GL_OES_standard_derivatives)\nreturn roughness;\n#else\nvec3 du=dFdx(normalWS);vec3 dv=dFdy(normalWS);float specularAAVariance=0.15;float specularAAThreshold=0.04;float variance=specularAAVariance*(dot(du,du)+dot(dv,dv));float kernelRoughness=min(2.0*variance,specularAAThreshold);float squareRoughness=saturate(roughness*roughness+kernelRoughness);return sqrt(squareRoughness);\n#endif\n}vec3 diffuseLobe(in Surface surface,const in PixelInfo pixel,const in LightParams lightParams){return surface.diffuseColor*Fd_Lambert();}vec3 specularLobe(const in Surface surface,const in PixelInfo pixel,const in LightParams lightParams){float roughness=surface.roughness;float D=distribution(roughness,lightParams.NoH,lightParams.h,pixel.normalWS);float V=visibility(roughness,pixel.NoV,lightParams.NoL);vec3 F=fresnel(surface.f0,surface.f90,lightParams.LoH);return(D*V)*F;}\n#ifdef IRIDESCENCE\nvec3 iridescenceDiffuseLobe(in Surface surface,const in PixelInfo pixel,const in LightParams lightParams){vec3 f0=surface.f0;vec3 f90=vec3(1.0);vec3 iridescenceFresnel=pixel.iridescenceFresnel;float iridescence=surface.iridescence;float VoH=lightParams.VoH;return surface.diffuseColor*Fd_IridescenceLambert(f0,f90,iridescenceFresnel,iridescence,VoH);}vec3 iridescenceSpecularLobe(const in Surface surface,const in PixelInfo pixel,const in LightParams lightParams){float roughness=surface.roughness;float D=distribution(roughness,lightParams.NoH,lightParams.h,pixel.normalWS);float V=visibility(roughness,pixel.NoV,lightParams.NoL);float iridescenceFactor=surface.iridescence;vec3 iridescenceFresnel=pixel.iridescenceFresnel;vec3 F=mix(fresnel(surface.f0,lightParams.LoH),iridescenceFresnel,vec3(iridescenceFactor));return(D*V)*F;}\n#endif\n#ifdef CLEARCOAT\nfloat clearCoatLobe(const in Surface surface,const in PixelInfo pixel,const in LightParams lightParams){float roughness=surface.clearCoatRoughness;float clearCoat=surface.clearCoat;vec3 n=pixel.clearCoatNormal;vec3 h=lightParams.h;float LoH=lightParams.LoH;float clearCoatNoH=lightParams.clearCoatNoH;float D=distribution(roughness,clearCoatNoH,h,n);float V=V_kelemen(LoH);return D*V;}\n#endif\n#ifdef SHEEN\nvec3 sheenLobe(const in Surface surface,const in PixelInfo pixel,const in LightParams lightParams){float roughness=surface.sheenRoughness;float NoV=pixel.NoV;float NoH=lightParams.NoH;float NoL=lightParams.NoL;float D=D_Charlie(roughness,NoH);float V=V_Neubelt(NoV,NoL);return D*V*surface.sheenColor;}\n#endif\n#ifdef ANISOTROPIC\nvec3 anisotropyLobe(const in Surface surface,const in PixelInfo pixel,const in LightParams lightParams){float anisotropy=surface.anisotropy;float at=pixel.at;float ab=pixel.ab;vec3 anisotropicT=pixel.anisotropicT;vec3 anisotropicB=pixel.anisotropicB;float NoV=pixel.NoV;float ToV=pixel.ToV;float BoV=pixel.BoV;vec3 h=lightParams.h;float NoL=lightParams.NoL;float NoH=lightParams.NoH;float VoH=lightParams.VoH;float ToL=lightParams.ToL;float BoL=lightParams.BoL;float V=V_SmithGGXCorrelated_Anisotropic(at,ab,ToV,BoV,ToL,BoL,NoV,NoL);float D=D_GGX_Anisotropic(NoH,h,anisotropicT,anisotropicB,at,ab);vec3 F=fresnel(surface.f0,surface.f90,lightParams.LoH);return V*D*F;}\n#endif\nvec3 PBRLighting(const in Surface surface,const in PixelInfo pixel,const in Light light){LightParams lightParams;initLightParams(lightParams,pixel,light);float NoL=lightParams.NoL;\n#ifdef IRIDESCENCE\nvec3 Fd=iridescenceDiffuseLobe(surface,pixel,lightParams);vec3 Fr=iridescenceSpecularLobe(surface,pixel,lightParams);\n#elif defined(ANISOTROPIC)\nvec3 Fd=diffuseLobe(surface,pixel,lightParams);vec3 Fr=anisotropyLobe(surface,pixel,lightParams);\n#else\nvec3 Fd=diffuseLobe(surface,pixel,lightParams);vec3 Fr=specularLobe(surface,pixel,lightParams);\n#endif\n#ifdef TRANSMISSION\nFd*=1.0-surface.transmission;\n#endif\nvec3 shading=(Fd+Fr*pixel.energyCompensation);\n#ifdef SHEEN\nvec3 fSheen=sheenLobe(surface,pixel,lightParams);shading*=pixel.sheenScaling;shading+=fSheen;\n#endif\n#ifdef CLEARCOAT\nfloat clearCoatNoL=lightParams.clearCoatNoL;float LoH=lightParams.LoH;float FccClearCoat=F_Schlick(0.04,1.0,LoH)*surface.clearCoat;float attenuation=1.0-FccClearCoat;shading*=attenuation*NoL;float clearcoat=clearCoatLobe(surface,pixel,lightParams)*FccClearCoat;shading+=clearcoat*clearCoatNoL;NoL=1.0;\n#endif\nreturn shading*light.color*NoL;}\n#include "PBRGI.glsl";\n#endif\n'),n.init(),Dr.init(),xr.init(),Mr.init(),yr.init(),Cr.init(),vr.init(),Ur.init(),t.Shader3D.SHADERDEFINE_LEGACYSINGALLIGHTING=t.Shader3D.getDefineByName("LEGACYSINGLELIGHTING"),t.Shader3D.SHADERDEFINE_ENUNIFORMBLOCK=t.Shader3D.getDefineByName("ENUNIFORMBLOCK"),t.Shader3D.SHADERDEFINE_FLOATTEXTURE=t.Shader3D.getDefineByName("FLOATTEXTURE"),t.Shader3D.SHADERDEFINE_FLOATTEXTURE_FIL_LINEAR=t.Shader3D.getDefineByName("FLOATTEXTURE_FIL_LINEAR"),t.Shader3D.SHADERDEFINE_REMAP_POSITIONZ=t.Shader3D.getDefineByName("REMAP_Z"),t.Shader3D.SHADERDEFINE_LOD_TEXTURE_SAMPLE=t.Shader3D.getDefineByName("LOD_TEXTURE_SAMPLE"),t.Shader3D.SHADERDEFINE_STORAGEBUFFER=t.Shader3D.getDefineByName("STORAGEBUFFER")}}class Gr{}class kr extends W{setSkinData(e){this._renderElementOBJ.skinnedData=e}constructor(){super()}_createRenderElementOBJ(){this._renderElementOBJ=T.Render3DPassFactory.createSkinRenderElement()}_render(e){}}class zr extends Y{static __init__(){Gr.SHADERDEFINE_BONE=t.Shader3D.getDefineByName("BONE"),Gr.SHADERDEFINE_SIMPLEBONE=t.Shader3D.getDefineByName("SIMPLEBONE");const e=t.LayaGL.renderDeviceFactory.createGlobalUniformMap("SkinSprite3D");zr.BONES=t.Shader3D.propertyNameToID("u_Bones"),e.addShaderUniformArray(zr.BONES,"u_Bones",t.ShaderDataType.Matrix4x4,24)}get _bones(){return this.__bones}set _bones(e){this.__bones=e,this._isISkinRenderNode()&&this._ownerSkinRenderNode.setBones(e)}get localBounds(){return this._localBounds}set localBounds(e){this._localBounds=e,this._baseRenderNode.boundsChange=!0,this.geometryBounds=this._localBounds}get rootBone(){return this._cacheRootBone}set rootBone(e){if(this._cacheRootBone!=e){this._cacheRootBone?this._cacheRootBone.transform.off(t.Event.TRANSFORM_CHANGED,this,this._onWorldMatNeedChange):this.owner.transform.off(t.Event.TRANSFORM_CHANGED,this,this._onWorldMatNeedChange),e?(e.transform.on(t.Event.TRANSFORM_CHANGED,this,this._onWorldMatNeedChange),this._baseRenderNode.transform=e.transform):(this.owner.transform.on(t.Event.TRANSFORM_CHANGED,this,this._onWorldMatNeedChange),this._baseRenderNode.transform=this.owner.transform),this._cacheRootBone=e,this._onWorldMatNeedChange(Se.TRANSFORM_WORLDPOSITION|Se.TRANSFORM_WORLDQUATERNION|Se.TRANSFORM_WORLDSCALE);let a=this._renderElements.length;for(var r=0;r<a;r++){this._renderElements[r].setTransform(e.transform)}this._isISkinRenderNode()&&this._ownerSkinRenderNode.setRootBoneTransfom(this._cacheRootBone)}this._baseRenderNode.transform=this.rootBone?this.rootBone.transform:this.owner.transform}get bones(){return this._bones}set bones(e){this._bones=e}constructor(){super(),this.__bones=[],this._worldParams=new t.Vector4,this.localBounds=new M(t.Vector3.ZERO,t.Vector3.ZERO),this._baseRenderNode.shaderData.addDefine(Gr.SHADERDEFINE_BONE),this._baseRenderNode.renderNodeType=t.BaseRenderType.SkinnedMeshRender}_createBaseRenderNode(){return this._ownerSkinRenderNode=T.Render3DModuleDataFactory.createSkinRenderNode(),this._ownerSkinRenderNode}_getcommonUniformMap(){return["Sprite3D","SkinSprite3D"]}_needRender(e,r){return!!t.Stat.enableSkin&&super._needRender(e,r)}_createRenderElement(){return new kr}_isISkinRenderNode(){return this._ownerSkinRenderNode.setCacheMesh}_onSkinMeshChange(e){if(e&&this._mesh!=e){this._changeVertexDefine(e),this._changeMorphData(e),this._mesh=e,this._isISkinRenderNode()&&this._ownerSkinRenderNode.setCacheMesh(e);var t=e.subMeshCount;this._renderElements.length=t;let i=this.sharedMaterials;i.length=t;for(var a=0;a<t;a++){let t=this._renderElements[a];t||(t=this._renderElements[a]=this._createRenderElement(),this._cacheRootBone?t.setTransform(this._cacheRootBone.transform):t.setTransform(this.owner._transform),t.render=this),i[a]=i[a]||r.defaultMaterial,t.setGeometry(e.getSubMesh(a))}this.sharedMaterials=i,this.boundsChange=!0}else e||(this._renderElements.length=0,this._mesh=null,this._changeVertexDefine(null),this._changeMorphData(null),this.boundsChange=!1);this._meshChange=!0}_onMeshChange(e){if(this._onSkinMeshChange(e),this._setRenderElements(),e){this._cacheMesh=e;var t=e.subMeshCount;this._skinnedData=[];for(var r=0;r<t;r++){for(var a=e.getSubMesh(r)._boneIndicesList,i=a.length,n=this._skinnedData[r]=[],s=0;s<i;s++)n[s]=new Float32Array(16*a[s].length);this._renderElements[r].setSkinData(n)}this._isISkinRenderNode()&&this._ownerSkinRenderNode.setSkinnedData(this._skinnedData)}}_setBelongScene(e){super._setBelongScene(e),this._isISkinRenderNode()&&this._ownerSkinRenderNode.setOwnerTransform(this.owner)}_setUnBelongScene(){super._setUnBelongScene()}_statAdd(){super._statAdd(),t.LayaGL.statAgent.recordCountData(t.StatElement.C_SkinnedMeshRenderCount,1)}_statRemove(){super._statRemove(),t.LayaGL.statAgent.recordCountData(t.StatElement.C_SkinnedMeshRenderCount,-1)}renderUpdate(e){super.renderUpdate(e),this._isISkinRenderNode()&&this._ownerSkinRenderNode.computeSkinnedData()}_cloneTo(e){let t=(e,t,r)=>{let a=((e,t)=>{let r=[],a=e;for(;a;)a instanceof R&&r.push(a),a=a.parent;let i=t;for(;i&&-1==r.indexOf(i);)i=i.parent;return i})(e,t);if(!a)return null;let i=[];Z._getHierarchyPath(a,e,i);let n=[];Z._getHierarchyPath(a,t,n);let s=Z._getParentNodeByHierarchyPath(r,i);return s?Z._getNodeByHierarchyPath(s,n):null};var r=this.rootBone;if(r){let a=t(this.owner,this.rootBone,e.owner);e.rootBone=a||r}var a=this.bones,i=e.bones;let n=i.length=a.length;for(var s=0;s<n;s++){let r=a[s];i[s]=t(this.owner,r,e.owner)}e.bones=e.bones;var o=this.localBounds;o&&o.cloneTo(e.localBounds),e.localBounds&&(e.localBounds=e.localBounds),super._cloneTo(e)}_onDestroy(){this._cacheRootBone?!this._cacheRootBone._destroyed&&this._cacheRootBone.transform.off(t.Event.TRANSFORM_CHANGED,this,this._onWorldMatNeedChange):this.owner&&!this.owner._destroyed&&this.owner.transform.off(t.Event.TRANSFORM_CHANGED,this,this._onWorldMatNeedChange),super._onDestroy()}}class Wr extends zr{get simpleAnimatorTexture(){return this._simpleAnimatorTexture}set simpleAnimatorTexture(e){this._simpleAnimatorTexture=e,this._simpleAnimatorTextureSize=e.width,this._baseRenderNode.shaderData.setTexture(Qr.SIMPLE_SIMPLEANIMATORTEXTURE,e),this._baseRenderNode.shaderData.setNumber(Qr.SIMPLE_SIMPLEANIMATORTEXTURESIZE,this._simpleAnimatorTextureSize)}get simpleAnimatorOffset(){return this._simpleAnimatorOffset}set simpleAnimatorOffset(e){e.cloneTo(this._simpleAnimatorOffset)}_isISkinRenderNode(){return null}constructor(){super(),this._simpleAnimatorParams=new t.Vector4,this._simpleAnimatorOffset=new t.Vector2,this._baseRenderNode.shaderData.addDefine(Gr.SHADERDEFINE_SIMPLEBONE),this._baseRenderNode.shaderData.addDefine(Gr.SHADERDEFINE_BONE),this._baseRenderNode.renderNodeType=t.BaseRenderType.SimpleSkinRender,this._baseRenderNode.shaderData.setVector(Qr.SIMPLE_SIMPLEANIMATORPARAMS,new t.Vector4)}_createBaseRenderNode(){return this._ownerSimpleRenderNode=T.Render3DModuleDataFactory.createSimpleSkinRenderNode(),this._ownerSimpleRenderNode}_getcommonUniformMap(){return["Sprite3D","SimpleSkinnedMesh"]}_computeSkinnedData(){this._computeAnimatorParamsData()}renderUpdate(e){let r=performance.now();super.renderUpdate(e),this._computeSkinnedData(),t.LayaGL.statAgent.recordTimeData(t.StatElement.T_SkinBoneUpdate,performance.now()-r)}_createRenderElement(){return new Q}_computeAnimatorParamsData(){this._cacheMesh&&(this._simpleAnimatorParams.x=this._simpleAnimatorOffset.x,this._simpleAnimatorParams.y=Math.round(this._simpleAnimatorOffset.y)*this._bonesNums*4,this._ownerSimpleRenderNode.setSimpleAnimatorParams(this._simpleAnimatorParams),this._batchRender&&this._batchRender.updateProperty(this,e.propertyChangeFlag.SimpleSkineParam))}setCustomData(e,t=0){this._simpleAnimatorParams.z=e,this._simpleAnimatorParams.w=t,this._ownerSimpleRenderNode.setSimpleAnimatorParams(this._simpleAnimatorParams)}_onMeshChange(e){this._onSkinMeshChange(e),e&&(this._cacheMesh=e,this._setRenderElements())}_cloneTo(e){e.simpleAnimatorOffset=this.simpleAnimatorOffset,e.simpleAnimatorTexture=this.simpleAnimatorTexture,e._bonesNums=this._bonesNums,super._cloneTo(e)}_onDestroy(){this._cacheRootBone&&!this._cacheRootBone._destroyed&&this._cacheRootBone.transform.off(t.Event.TRANSFORM_CHANGED,this,this._onWorldMatNeedChange),this._simpleAnimatorTexture=null,super._onDestroy()}}class Qr extends y{static __init__(){Qr.SIMPLE_SIMPLEANIMATORTEXTURE=t.Shader3D.propertyNameToID("u_SimpleAnimatorTexture"),Qr.SIMPLE_SIMPLEANIMATORPARAMS=t.Shader3D.propertyNameToID("u_SimpleAnimatorParams"),Qr.SIMPLE_SIMPLEANIMATORTEXTURESIZE=t.Shader3D.propertyNameToID("u_SimpleAnimatorTextureSize");const e=t.LayaGL.renderDeviceFactory.createGlobalUniformMap("SimpleSkinnedMesh");e.addShaderUniform(Qr.SIMPLE_SIMPLEANIMATORTEXTURE,"u_SimpleAnimatorTexture",t.ShaderDataType.Texture2D),e.addShaderUniform(Qr.SIMPLE_SIMPLEANIMATORPARAMS,"u_SimpleAnimatorParams",t.ShaderDataType.Vector4),e.addShaderUniform(Qr.SIMPLE_SIMPLEANIMATORTEXTURESIZE,"u_SimpleAnimatorTextureSize",t.ShaderDataType.Float)}get meshFilter(){return this._meshFilter}get simpleSkinnedMeshRenderer(){return this._render}constructor(e=null,t=null){super(t),this._meshFilter=this.addComponent(D),this._render=this.addComponent(Wr),e&&(this._meshFilter.sharedMesh=e)}destroy(e=!0){this._destroyed||(super.destroy(e),this._meshFilter.destroy())}}Qr._tempArray0=[];class Yr extends t.Material{static __init__(){Yr.TINTCOLOR=t.Shader3D.propertyNameToID("u_TintColor"),Yr.EXPOSURE=t.Shader3D.propertyNameToID("u_Exposure"),Yr.ROTATION=t.Shader3D.propertyNameToID("u_Rotation"),Yr.TEXTURE=t.Shader3D.propertyNameToID("u_Texture"),Yr.TEXTURE_HDR_PARAMS=t.Shader3D.propertyNameToID("u_Texture_HDR_params")}get tintColor(){return this.getColorByIndex(Yr.TINTCOLOR)}set tintColor(e){this.setColorByIndex(Yr.TINTCOLOR,e)}get exposure(){return this.getFloatByIndex(Yr.EXPOSURE)}set exposure(e){this.setFloatByIndex(Yr.EXPOSURE,e)}get rotation(){return this.getFloatByIndex(Yr.ROTATION)}set rotation(e){this.setFloatByIndex(Yr.ROTATION,e)}get panoramicTexture(){return this.getTextureByIndex(Yr.TEXTURE)}set panoramicTexture(e){this.setTextureByIndex(Yr.TEXTURE,e)}constructor(){super(),this._textureHDRParams=new t.Vector4(1,0,0,1),this.setShaderName("SkyPanoramic"),this.setColorByIndex(Yr.TINTCOLOR,new t.Color(.5,.5,.5,.5)),this.setFloatByIndex(Yr.ROTATION,0),this.setVector4ByIndex(Yr.TEXTURE_HDR_PARAMS,this._textureHDRParams),this.exposure=1.3}}class Xr extends t.Material{static __initDefine__(){Xr.COLOR=t.Shader3D.propertyNameToID("u_Color")}get color(){return this._shaderValues.getVector(Xr.COLOR)}set color(e){this._shaderValues.setVector(Xr.COLOR,e)}constructor(){super(),this.setShaderName("LineShader"),this._shaderValues.setVector(Xr.COLOR,new t.Vector4(1,1,1,1))}clone(){var e=new Xr;return this.cloneTo(e),e}}e.EPhysicsStatisticsInfo=void 0,(Ir=e.EPhysicsStatisticsInfo||(e.EPhysicsStatisticsInfo={}))[Ir.C_PhysicsEventCount=0]="C_PhysicsEventCount",Ir[Ir.FrameClearCount=1]="FrameClearCount",Ir[Ir.C_PhysicaDynamicRigidBody=2]="C_PhysicaDynamicRigidBody",Ir[Ir.C_PhysicaStaticRigidBody=3]="C_PhysicaStaticRigidBody",Ir[Ir.C_PhysicaKinematicRigidBody=4]="C_PhysicaKinematicRigidBody",Ir[Ir.C_PhysicaCharacterController=5]="C_PhysicaCharacterController",Ir[Ir.C_PhysicsJoint=6]="C_PhysicsJoint",Ir[Ir.Count=7]="Count";class Kr{static initStatisticsInfo(){for(let t=0;t<e.EPhysicsStatisticsInfo.Count;t++)this._PhysicsStatisticsInfo.set(t,0);Kr.enableStatistics&&Kr.autoFrameClear&&t.ILaya.timer.frameLoop(1,null,Kr.clearStatisticsInfo)}static addStatisticsInfo(e,t){Kr.enableStatistics&&Kr._PhysicsStatisticsInfo.set(e,Kr._PhysicsStatisticsInfo.get(e)+t)}static getStatisticsInfo(e){let t=0;return Kr.enableStatistics&&(t=Kr._PhysicsStatisticsInfo.get(e)),t}static clearStatisticsInfo(){if(Kr.enableStatistics)for(let t=0;t<e.EPhysicsStatisticsInfo.FrameClearCount;t++)Kr._PhysicsStatisticsInfo.set(t,0)}static stopAndClearAllStatisticsInfo(){for(let t=0;t<e.EPhysicsStatisticsInfo.Count;t++)this._PhysicsStatisticsInfo.set(t,0);Kr.enableStatistics&&Kr.autoFrameClear&&t.ILaya.timer.clear(null,Kr.clearStatisticsInfo)}}Kr._PhysicsStatisticsInfo=new Map,Kr.enableStatistics=!1,Kr.autoFrameClear=!1;class jr{static get PhysicsCreateUtil(){return this._PhysicsCreateUtil}static set PhysicsCreateUtil(e){e&&!jr._PhysicsCreateUtil&&(jr._PhysicsCreateUtil=e,jr._enablePhysics=!0)}static get enablePhysics(){return jr._enablePhysics}static _changeWebGLSize(e,t){J.clientWidth=e,J.clientHeight=t}static __init__(){t.Config3D._multiLighting=t.Config3D.enableMultiLight&&t.LayaGL.renderEngine.getCapable(t.RenderCapable.TextureFormat_R32G32B32A32),t.Config3D.maxLightCount>2048&&(t.Config3D.maxLightCount=2048,console.warn("Config3D: maxLightCount must less equal 2048."));let e=t.Config3D.lightClusterCount;(e.x>128||e.y>128||e.z>128)&&(e.setValue(Math.min(e.x,128),Math.min(e.y,128),Math.min(e.z,128)),console.warn("Config3D: lightClusterCount X and Y、Z must less equal 128."));let a=4*Math.floor(2048/t.Config3D.lightClusterCount.z-1);a<t.Config3D.maxLightCount&&console.warn("Config3D: if the area light(PointLight、SpotLight) count is large than "+a+",maybe the far away culster will ingonre some light."),t.Config3D._maxAreaLightCountPerClusterAverage=Math.min(a,t.Config3D.maxLightCount),t.ILaya.Scene3D=hr,t.ILaya.Laya3D=jr,Ie.__init__(),K.__init__(),dr.__init__(),Hr.__init__(),_.__init__(),m.__init__(),Yr.__init__(),Tr.__init__(),R.__init__(),y.__init__(),X.__init__(),zr.__init__(),At.__init__(),Qr.__init__(),Qt.__init__(),hr.__init__(),Tt.__init__(),Ne.__init__(),z.__init__(),Y.__init__(),Be.__init__(),tr.__init__(),_t.init(),J.__init__(),r.__initDefine__(),p.__initDefine__(),S.__initDefine__(),g.__initDefine__(),j.__init__(),ir.__init__(),r.defaultMaterial=new r,r.defaultMaterial.lock=!0,S.defaultMaterial=new S,S.defaultMaterial.lock=!0;let i=new S;i.lock=!0,i.enableVertexColor=!0,Xr.defaultMaterial=i,ve.__init__(),we.__init__(),wt.__init__()}static __initPhysics__(){return jr._PhysicsCreateUtil?(jr._enablePhysics=!0,Kr.initStatisticsInfo(),t.PlayerConfig.physics3D&&Object.assign(hr.physicsSettings,t.PlayerConfig.physics3D),jr._PhysicsCreateUtil.initialize()):(jr._enablePhysics=!1,Promise.resolve())}}jr._enablePhysics=!1,window.Laya3D=jr,t.Laya.addInitCallback(()=>jr.__initPhysics__());e.VehicleChangeFlags=void 0,(wr=e.VehicleChangeFlags||(e.VehicleChangeFlags={}))[wr.None=0]="None",wr[wr.ChassisMass=1]="ChassisMass",wr[wr.WheelConfig=2]="WheelConfig",e.VehicleApplyResult=void 0,(Br=e.VehicleApplyResult||(e.VehicleApplyResult={}))[Br.Applied=0]="Applied",Br[Br.RebuildRequired=1]="RebuildRequired",Br[Br.Unsupported=2]="Unsupported",Br[Br.Invalid=3]="Invalid",e.D6MotionType=void 0,(Pr=e.D6MotionType||(e.D6MotionType={}))[Pr.eX=0]="eX",Pr[Pr.eY=1]="eY",Pr[Pr.eZ=2]="eZ",Pr[Pr.eTWIST=3]="eTWIST",Pr[Pr.eSWING1=4]="eSWING1",Pr[Pr.eSWING2=5]="eSWING2",e.D6Axis=void 0,(Lr=e.D6Axis||(e.D6Axis={}))[Lr.eLOCKED=0]="eLOCKED",Lr[Lr.eLIMITED=1]="eLIMITED",Lr[Lr.eFREE=2]="eFREE",e.D6Drive=void 0,(Fr=e.D6Drive||(e.D6Drive={}))[Fr.eX=0]="eX",Fr[Fr.eY=1]="eY",Fr[Fr.eZ=2]="eZ",Fr[Fr.eSWING=3]="eSWING",Fr[Fr.eTWIST=4]="eTWIST",Fr[Fr.eSLERP=5]="eSLERP",e.ECharacterCapable=void 0,(Nr=e.ECharacterCapable||(e.ECharacterCapable={}))[Nr.Charcater_Gravity=0]="Charcater_Gravity",Nr[Nr.Charcater_CollisionGroup=1]="Charcater_CollisionGroup",Nr[Nr.Charcater_WorldPosition=2]="Charcater_WorldPosition",Nr[Nr.Charcater_Move=3]="Charcater_Move",Nr[Nr.Charcater_Jump=4]="Charcater_Jump",Nr[Nr.Charcater_StepOffset=5]="Charcater_StepOffset",Nr[Nr.Character_UpDirection=6]="Character_UpDirection",Nr[Nr.Character_FallSpeed=7]="Character_FallSpeed",Nr[Nr.Character_SlopeLimit=8]="Character_SlopeLimit",Nr[Nr.Character_PushForce=9]="Character_PushForce",Nr[Nr.Character_Radius=10]="Character_Radius",Nr[Nr.Character_Height=11]="Character_Height",Nr[Nr.Character_offset=12]="Character_offset",Nr[Nr.Character_Skin=13]="Character_Skin",Nr[Nr.Character_minDistance=14]="Character_minDistance",Nr[Nr.Character_EventFilter=15]="Character_EventFilter",Nr[Nr.Character_SimulateGravity=16]="Character_SimulateGravity",Nr[Nr.Character_IsOnGround=17]="Character_IsOnGround",e.EColliderCapable=void 0,(Or=e.EColliderCapable||(e.EColliderCapable={}))[Or.Collider_CollisionGroup=0]="Collider_CollisionGroup",Or[Or.Collider_Friction=1]="Collider_Friction",Or[Or.Collider_RollingFriction=2]="Collider_RollingFriction",Or[Or.Collider_Restitution=3]="Collider_Restitution",Or[Or.Collider_AllowTrigger=4]="Collider_AllowTrigger",Or[Or.Collider_DynamicFriction=5]="Collider_DynamicFriction",Or[Or.Collider_StaticFriction=6]="Collider_StaticFriction",Or[Or.Collider_BounceCombine=7]="Collider_BounceCombine",Or[Or.Collider_FrictionCombine=8]="Collider_FrictionCombine",Or[Or.Collider_EventFilter=9]="Collider_EventFilter",Or[Or.Collider_CollisionDetectionMode=10]="Collider_CollisionDetectionMode",Or[Or.RigidBody_CanKinematic=11]="RigidBody_CanKinematic",Or[Or.RigidBody_AllowSleep=12]="RigidBody_AllowSleep",Or[Or.RigidBody_Gravity=13]="RigidBody_Gravity",Or[Or.RigidBody_LinearDamp=14]="RigidBody_LinearDamp",Or[Or.RigidBody_AngularDamp=15]="RigidBody_AngularDamp",Or[Or.RigidBody_LinearVelocity=16]="RigidBody_LinearVelocity",Or[Or.RigidBody_AngularVelocity=17]="RigidBody_AngularVelocity",Or[Or.RigidBody_Mass=18]="RigidBody_Mass",Or[Or.RigidBody_WorldPosition=19]="RigidBody_WorldPosition",Or[Or.RigidBody_WorldOrientation=20]="RigidBody_WorldOrientation",Or[Or.RigidBody_InertiaTensor=21]="RigidBody_InertiaTensor",Or[Or.RigidBody_MassCenter=22]="RigidBody_MassCenter",Or[Or.RigidBody_MaxAngularVelocity=23]="RigidBody_MaxAngularVelocity",Or[Or.RigidBody_MaxDepenetrationVelocity=24]="RigidBody_MaxDepenetrationVelocity",Or[Or.RigidBody_SleepThreshold=25]="RigidBody_SleepThreshold",Or[Or.RigidBody_SleepAngularVelocity=26]="RigidBody_SleepAngularVelocity",Or[Or.RigidBody_SolverIterations=27]="RigidBody_SolverIterations",Or[Or.RigidBody_AllowDetectionMode=28]="RigidBody_AllowDetectionMode",Or[Or.RigidBody_AllowKinematic=29]="RigidBody_AllowKinematic",Or[Or.RigidBody_AllowCharacter=30]="RigidBody_AllowCharacter",Or[Or.RigidBody_LinearFactor=31]="RigidBody_LinearFactor",Or[Or.RigidBody_AngularFactor=32]="RigidBody_AngularFactor",Or[Or.RigidBody_ApplyForce=33]="RigidBody_ApplyForce",Or[Or.RigidBody_ClearForce=34]="RigidBody_ClearForce",Or[Or.RigidBody_ApplyForceWithOffset=35]="RigidBody_ApplyForceWithOffset",Or[Or.RigidBody_ApplyTorque=36]="RigidBody_ApplyTorque",Or[Or.RigidBody_ApplyImpulse=37]="RigidBody_ApplyImpulse",Or[Or.RigidBody_ApplyTorqueImpulse=38]="RigidBody_ApplyTorqueImpulse",e.EJointCapable=void 0,(br=e.EJointCapable||(e.EJointCapable={}))[br.Joint_Anchor=0]="Joint_Anchor",br[br.Joint_ConnectAnchor=1]="Joint_ConnectAnchor",e.BatchCullMode=void 0,(Vr=e.BatchCullMode||(e.BatchCullMode={}))[Vr.None=0]="None",Vr[Vr.Camera=1]="Camera",Vr[Vr.DirectLight=2]="DirectLight",Vr[Vr.Spot=3]="Spot";class Jr{createVertexBuffer3D(e,t,r=!1){return new ur(e,t,r)}createIndexBuffer3D(e,r,a=t.BufferUsage.Static,i=!1){return new cr(e,r,a,i)}}t.Laya.addBeforeInitCallback(()=>{T.renderOBJCreate||(T.renderOBJCreate=new Jr)});class qr{constructor(){this._ownerPath=[],this._propertys=[],this._keyFrames=[],this._isPlainHermite=!1,this._isPlainHermiteResolved=!1}get ownerPathCount(){return this._ownerPath.length}get propertyCount(){return this._propertys.length}get keyFramesCount(){return this._keyFrames.length}_setOwnerPathCount(e){this._ownerPath.length=e}_setOwnerPathByIndex(e,t){this._ownerPath[e]=t}_joinOwnerPath(e){return this._ownerPath.join(e)}_setPropertyCount(e){this._propertys.length=e}_setPropertyByIndex(e,t){this._propertys[e]=t}_joinProperty(e){return this._propertys.join(e)}_setKeyframeCount(e){this._keyFrames.length=e}_setKeyframeByIndex(e,t){this._keyFrames[e]=t}getOwnerPathByIndex(e){return this._ownerPath[e]}getPropertyByIndex(e){return this._propertys[e]}getMaterialPropertyId(e){return null==this._materialId&&(this._materialId=t.Shader3D.propertyNameToID(this._propertys[e])),this._materialId}getKeyframeByIndex(e){return this._keyFrames[e]}}class Zr{constructor(){}}class $r{static READ_DATA(){$r._DATA.offset=$r._reader.readUint32(),$r._DATA.size=$r._reader.readUint32()}static READ_BLOCK(){for(var e=$r._BLOCK.count=$r._reader.readUint16(),t=$r._BLOCK.blockStarts=[],r=$r._BLOCK.blockLengths=[],a=0;a<e;a++)t.push($r._reader.readUint32()),r.push($r._reader.readUint32())}static READ_STRINGS(){var e=$r._reader.readUint32(),t=$r._reader.readUint16(),r=$r._reader.pos;$r._reader.pos=e+$r._DATA.offset;for(var a=0;a<t;a++)$r._strings[a]=$r._reader.readUTFString();$r._reader.pos=r}static parse(e,t){$r._animationClip=e,$r._reader=t,$r.READ_DATA(),$r.READ_BLOCK(),$r.READ_STRINGS();for(var r=0,a=$r._BLOCK.count;r<a;r++){var i=t.readUint16(),n=$r._strings[i],s=$r["READ_"+n];if(null==s)throw new Error("model file err,no this function:"+i+" "+n);s.call(null)}}static READ_ANIMATIONS(){var e,r,a,i=$r._reader,n=[],s=i.readUint16();for(n.length=s,e=0;e<s;e++)n[e]=i.readFloat32();var o=$r._animationClip;o.name=$r._strings[i.readUint16()];var l=o._duration=i.readFloat32();o.islooping=!!i.readByte(),o._frameRate=i.readInt16();var h=i.readInt16(),d=o._nodes;d.count=h;var c=o._nodesMap={},u=o._nodesDic={};for(e=0;e<h;e++){a=new qr,d.setNodeByIndex(e,a),a._indexInList=e;var _=a.type=i.readUint8(),f=i.readUint16();for(a._setOwnerPathCount(f),r=0;r<f;r++)a._setOwnerPathByIndex(r,$r._strings[i.readUint16()]);var m=a._joinOwnerPath("/"),g=c[m];g||(c[m]=g=[]),g.push(a),a.propertyOwner=$r._strings[i.readUint16()];var p=i.readUint16();for(a._setPropertyCount(p),r=0;r<p;r++)a._setPropertyByIndex(r,$r._strings[i.readUint16()]);var S=m+"."+a.propertyOwner+"."+a._joinProperty(".");u[S]=a,a.fullPath=S;var T=i.readUint16();for(a._setKeyframeCount(T),r=0;r<T;r++)switch(_){case 0:var A=new t.FloatKeyframe;a._setKeyframeByIndex(r,A),A.time=n[i.readUint16()],A.inTangent=i.readFloat32(),A.outTangent=i.readFloat32(),A.value=i.readFloat32();break;case 1:case 3:case 4:var E=new t.Vector3Keyframe;a._setKeyframeByIndex(r,E),E.time=n[i.readUint16()];var D=E.inTangent,R=E.outTangent,x=E.value;D.x=i.readFloat32(),D.y=i.readFloat32(),D.z=i.readFloat32(),R.x=i.readFloat32(),R.y=i.readFloat32(),R.z=i.readFloat32(),x.x=i.readFloat32(),x.y=i.readFloat32(),x.z=i.readFloat32();break;case 2:var y=new t.QuaternionKeyframe;a._setKeyframeByIndex(r,y),y.time=n[i.readUint16()];var M=y.inTangent,C=y.outTangent,v=y.value;M.x=i.readFloat32(),M.y=i.readFloat32(),M.z=i.readFloat32(),M.w=i.readFloat32(),C.x=i.readFloat32(),C.y=i.readFloat32(),C.z=i.readFloat32(),C.w=i.readFloat32(),v.x=i.readFloat32(),v.y=i.readFloat32(),v.z=i.readFloat32(),v.w=i.readFloat32();break;default:throw new Error("AnimationClipParser03:unknown type.")}}var I=i.readUint16();for(e=0;e<I;e++){var w=new Zr;w.time=Math.min(l,i.readFloat32()),w.eventName=$r._strings[i.readUint16()];var B=[],P=i.readUint16();for(P>0&&(w.params=B=[]),r=0;r<P;r++){switch(i.readByte()){case 0:B.push(!!i.readByte());break;case 1:B.push(i.readInt32());break;case 2:B.push(i.readFloat32());break;case 3:B.push($r._strings[i.readUint16()]);break;default:throw new Error("unknown type.")}}o.addEvent(w)}}}$r._strings=[],$r._BLOCK={count:0},$r._DATA={offset:0,size:0};let ea=null;function ta(e){ea=e}function ra(){return ea?ea():new aa}class aa{constructor(){this.value=null,this.defaultValue=null,this.crossFixedValue=null,this.maskActive=!0}}const ia=new Set;function na(e){return ia.add(e),()=>{ia.delete(e)}}function sa(e){ia.forEach(t=>t(e))}var oa;e.KeyFrameValueType=void 0,(oa=e.KeyFrameValueType||(e.KeyFrameValueType={}))[oa.None=-1]="None",oa[oa.Float=0]="Float",oa[oa.Position=1]="Position",oa[oa.Rotation=2]="Rotation",oa[oa.Scale=3]="Scale",oa[oa.RotationEuler=4]="RotationEuler",oa[oa.Vector2=5]="Vector2",oa[oa.Vector3=6]="Vector3",oa[oa.Vector4=7]="Vector4",oa[oa.Color=8]="Color",oa[oa.Boolean=9]="Boolean",oa[oa.PathPoint=10]="PathPoint",oa[oa.MaterialRef=11]="MaterialRef";class la{get defaultValue(){return this._data.defaultValue}set defaultValue(e){this._data.defaultValue=e}get value(){return this._data.value}set value(e){this._data.value=e}get crossFixedValue(){return this._data.crossFixedValue}set crossFixedValue(e){this._data.crossFixedValue=e}get maskActive(){return this._data.maskActive}set maskActive(e){this._data.maskActive=e}constructor(){this.indexInList=-1,this.referenceCount=0,this.updateMark=-1,this.type=-1,this.fullPath=null,this.nodePath=null,this.propertyOwner=null,this.property=null,this._data=ra(),this.isMaterial=!1}saveCrossFixedValue(){if(this.propertyOwner)switch(this.type){case e.KeyFrameValueType.Float:case e.KeyFrameValueType.Boolean:this.crossFixedValue=this.value;break;case e.KeyFrameValueType.Position:case e.KeyFrameValueType.Scale:case e.KeyFrameValueType.RotationEuler:case e.KeyFrameValueType.Vector3:case e.KeyFrameValueType.Rotation:case e.KeyFrameValueType.Vector2:case e.KeyFrameValueType.Vector4:case e.KeyFrameValueType.Color:this.value.cloneTo(this.crossFixedValue);break;case e.KeyFrameValueType.MaterialRef:this.crossFixedValue=this.value;break;default:throw new Error("Animator:unknown type.")}}animatorDataSetCallBack(){this.callBackOwner[this.callbackFun].apply(this.callBackOwner,this.callParams)}getCallbackNode(){if(this.propertyOwner&&this.callbackFunData){let e=this.callbackFunData.split(".");this.callBackOwner=this.propertyOwner;for(let t=0,r=e.length-1;t<r;t++)this.callBackOwner=this.callBackOwner[e[t]];this.callbackFun=e[e.length-1]}}}class ha{static READ_DATA(){ha._DATA.offset=ha._reader.readUint32(),ha._DATA.size=ha._reader.readUint32()}static READ_BLOCK(){for(var e=ha._BLOCK.count=ha._reader.readUint16(),t=ha._BLOCK.blockStarts=[],r=ha._BLOCK.blockLengths=[],a=0;a<e;a++)t.push(ha._reader.readUint32()),r.push(ha._reader.readUint32())}static READ_STRINGS(){var e=ha._reader.readUint32(),t=ha._reader.readUint16(),r=ha._reader.pos;ha._reader.pos=e+ha._DATA.offset;for(var a=0;a<t;a++)ha._strings[a]=ha._reader.readUTFString();ha._reader.pos=r}static parse(e,t,r){ha._animationClip=e,ha._reader=t,ha._version=r,ha.READ_DATA(),ha.READ_BLOCK(),ha.READ_STRINGS();for(var a=0,i=ha._BLOCK.count;a<i;a++){var n=t.readUint16(),s=ha._strings[n],o=ha["READ_"+s];if(null==o)throw new Error("model file err,no this function:"+n+" "+s);o.call(null)}ha._version=null,ha._reader=null,ha._animationClip=null}static createPathPoints(e){const r=[];for(var a=0,i=e.length;a<i;a++){const i=e[a],n=new t.PathPoint;n.pos.x=i.pos.x,n.pos.y=i.pos.y,n.pos.z=i.pos.z,n.c1.x=i.c1.x,n.c1.y=i.c1.y,n.c1.z=i.c1.z,n.c2.x=i.c2.x,n.c2.y=i.c2.y,n.c2.z=i.c2.z,n.curve=i.curve,n.rotationType=i.rotationType,r.push(n)}return r}static READ_ANIMATIONS(){var r,a,i,n=ha._reader,s=[],o=n.readUint16();for(s.length=o,r=0;r<o;r++)s[r]=n.readFloat32();var l=ha._animationClip;l.name=ha._strings[n.readUint16()];var h=l._duration=n.readFloat32();l.islooping=!!n.readByte(),l._frameRate=n.readInt16();var d=n.readInt16(),c=l._nodes;c.count=d;var u=l._nodesMap={},_=l._nodesDic={};for(r=0;r<d;r++){if(i=new qr,"LAYAANIMATION:WEIGHT_05"==ha._version){1==n.readByte()&&(i.propertyChangePath=ha._strings[n.readUint16()]),1==n.readByte()&&(i.callbackFunData=ha._strings[n.readUint16()]);let e=n.readUint8(),t=null;for(a=0;a<e;a++)null==t&&(t=[]),t.push(ha._strings[n.readUint16()]);i.callParams=t}c.setNodeByIndex(r,i),i._indexInList=r;var f=i.type=n.readUint8(),m=n.readUint16();for(i._setOwnerPathCount(m),a=0;a<m;a++)i._setOwnerPathByIndex(a,ha._strings[n.readUint16()]);var g=i._joinOwnerPath("/"),p=u[g];p||(u[g]=p=[]),p.push(i),i.propertyOwner=ha._strings[n.readUint16()];var S=n.readUint16();for(i._setPropertyCount(S),a=0;a<S;a++)i._setPropertyByIndex(a,ha._strings[n.readUint16()]);var T=g+"."+i.propertyOwner+"."+i._joinProperty(".");_[T]=i,i.fullPath=T,i.nodePath=g;var A=n.readUint16();switch(i._setKeyframeCount(A),ha._version){case"LAYAANIMATION:04":for(a=0;a<A;a++)switch(f){case e.KeyFrameValueType.Float:var E=new t.FloatKeyframe;i._setKeyframeByIndex(a,E),E.time=s[n.readUint16()],E.inTangent=n.readFloat32(),E.outTangent=n.readFloat32(),E.value=n.readFloat32();break;case e.KeyFrameValueType.Position:case e.KeyFrameValueType.Scale:case e.KeyFrameValueType.RotationEuler:case e.KeyFrameValueType.Vector3:var D=new t.Vector3Keyframe;i._setKeyframeByIndex(a,D),D.time=s[n.readUint16()];var R=D.inTangent,x=D.outTangent,y=D.value;R.x=n.readFloat32(),R.y=n.readFloat32(),R.z=n.readFloat32(),x.x=n.readFloat32(),x.y=n.readFloat32(),x.z=n.readFloat32(),y.x=n.readFloat32(),y.y=n.readFloat32(),y.z=n.readFloat32();break;case e.KeyFrameValueType.Rotation:var M=new t.QuaternionKeyframe;i._setKeyframeByIndex(a,M),M.time=s[n.readUint16()];var C=M.inTangent,v=M.outTangent,I=M.value;C.x=n.readFloat32(),C.y=n.readFloat32(),C.z=n.readFloat32(),C.w=n.readFloat32(),v.x=n.readFloat32(),v.y=n.readFloat32(),v.z=n.readFloat32(),v.w=n.readFloat32(),I.x=n.readFloat32(),I.y=n.readFloat32(),I.z=n.readFloat32(),I.w=n.readFloat32();break;case e.KeyFrameValueType.Vector2:var w=new t.Vector2Keyframe;i._setKeyframeByIndex(a,w),w.time=s[n.readUint16()];var B=w.inTangent,P=w.outTangent,L=w.value;B.x=n.readFloat32(),B.y=n.readFloat32(),P.x=n.readFloat32(),P.y=n.readFloat32(),L.x=n.readFloat32(),L.y=n.readFloat32();break;case e.KeyFrameValueType.Vector4:case e.KeyFrameValueType.Color:var F=new t.Vector4Keyframe;i._setKeyframeByIndex(a,F),F.time=s[n.readUint16()];var N=F.inTangent,O=F.outTangent,b=F.value;N.x=n.readFloat32(),N.y=n.readFloat32(),N.z=n.readFloat32(),N.w=n.readFloat32(),O.x=n.readFloat32(),O.y=n.readFloat32(),O.z=n.readFloat32(),O.w=n.readFloat32(),b.x=n.readFloat32(),b.y=n.readFloat32(),b.z=n.readFloat32(),b.w=n.readFloat32();break;case e.KeyFrameValueType.MaterialRef:{const e=new t.StringKeyframe;e.time=s[n.readUint16()],e.value=ha._strings[n.readUint16()],i._setKeyframeByIndex(a,e);break}default:throw new Error("AnimationClipParser04:unknown type.")}break;case"LAYAANIMATION:WEIGHT_04":case"LAYAANIMATION:WEIGHT_05":for(a=0;a<A;a++){let r=1;switch(f){case e.KeyFrameValueType.PathPoint:const o=new t.PathPointKeyframe;i._setKeyframeByIndex(a,o),o.time=s[n.readUint16()];const l=JSON.parse(n.readUTFString()),h=new t.CurvePath;o.value=h,h._$data=l,h.create(...ha.createPathPoints(l));break;case e.KeyFrameValueType.Boolean:let d=new t.BooleanKeyframe;i._setKeyframeByIndex(a,d),d.time=s[n.readUint16()],d.value=1==n.readByte();break;case e.KeyFrameValueType.MaterialRef:{const e=new t.StringKeyframe;e.time=s[n.readUint16()],e.value=ha._strings[n.readUint16()],i._setKeyframeByIndex(a,e);break}case e.KeyFrameValueType.Float:E=new t.FloatKeyframe;i._setKeyframeByIndex(a,E),E.time=s[n.readUint16()],E.inTangent=n.readFloat32(),E.outTangent=n.readFloat32(),E.value=n.readFloat32(),E.weightedMode=n.readUint8(),"LAYAANIMATION:WEIGHT_05"==ha._version?(t.WeightedMode.In!=E.weightedMode&&t.WeightedMode.Both!=E.weightedMode||(E.inWeight=n.readFloat32()),t.WeightedMode.Out!=E.weightedMode&&t.WeightedMode.Both!=E.weightedMode||(E.outWeight=n.readFloat32())):(E.inWeight=n.readFloat32(),E.outWeight=n.readFloat32());break;case e.KeyFrameValueType.Position:case e.KeyFrameValueType.Scale:case e.KeyFrameValueType.RotationEuler:case e.KeyFrameValueType.Vector3:D=new t.Vector3Keyframe(!0);i._setKeyframeByIndex(a,D),D.time=s[n.readUint16()];R=D.inTangent,x=D.outTangent,y=D.value;let c=D.weightedMode,u=D.inWeight,_=D.outWeight;R.x=n.readFloat32(),R.y=n.readFloat32(),R.z=n.readFloat32(),x.x=n.readFloat32(),x.y=n.readFloat32(),x.z=n.readFloat32(),y.x=n.readFloat32(),y.y=n.readFloat32(),y.z=n.readFloat32(),"LAYAANIMATION:WEIGHT_05"==ha._version&&(r=n.readByte()),1==r&&(c.x=n.readUint8(),c.y=n.readUint8(),c.z=n.readUint8(),u.x=n.readFloat32(),u.y=n.readFloat32(),u.z=n.readFloat32(),_.x=n.readFloat32(),_.y=n.readFloat32(),_.z=n.readFloat32());break;case e.KeyFrameValueType.Rotation:M=new t.QuaternionKeyframe(!0);i._setKeyframeByIndex(a,M),M.time=s[n.readUint16()];C=M.inTangent,v=M.outTangent,I=M.value;let f=M.weightedMode,m=M.inWeight,g=M.outWeight;C.x=n.readFloat32(),C.y=n.readFloat32(),C.z=n.readFloat32(),C.w=n.readFloat32(),v.x=n.readFloat32(),v.y=n.readFloat32(),v.z=n.readFloat32(),v.w=n.readFloat32(),I.x=n.readFloat32(),I.y=n.readFloat32(),I.z=n.readFloat32(),I.w=n.readFloat32(),"LAYAANIMATION:WEIGHT_05"==ha._version&&(r=n.readByte()),1==r&&(f.x=n.readUint8(),f.y=n.readUint8(),f.z=n.readUint8(),f.w=n.readUint8(),m.x=n.readFloat32(),m.y=n.readFloat32(),m.z=n.readFloat32(),m.w=n.readFloat32(),g.x=n.readFloat32(),g.y=n.readFloat32(),g.z=n.readFloat32(),g.w=n.readFloat32());break;case e.KeyFrameValueType.Vector2:w=new t.Vector2Keyframe(!0);i._setKeyframeByIndex(a,w),w.time=s[n.readUint16()];B=w.inTangent,P=w.outTangent,L=w.value;let p=w.weightedMode,S=w.inWeight,T=w.outWeight;B.x=n.readFloat32(),B.y=n.readFloat32(),P.x=n.readFloat32(),P.y=n.readFloat32(),L.x=n.readFloat32(),L.y=n.readFloat32(),"LAYAANIMATION:WEIGHT_05"==ha._version&&(r=n.readByte()),1==r&&(p.x=n.readUint8(),p.y=n.readUint8(),S.x=n.readFloat32(),S.y=n.readFloat32(),T.x=n.readFloat32(),T.y=n.readFloat32());break;case e.KeyFrameValueType.Vector4:case e.KeyFrameValueType.Color:F=new t.Vector4Keyframe(!0);i._setKeyframeByIndex(a,F),F.time=s[n.readUint16()];N=F.inTangent,O=F.outTangent,b=F.value;var V=F.weightedMode,U=F.inWeight,H=F.outWeight;N.x=n.readFloat32(),N.y=n.readFloat32(),N.z=n.readFloat32(),N.w=n.readFloat32(),O.x=n.readFloat32(),O.y=n.readFloat32(),O.z=n.readFloat32(),O.w=n.readFloat32(),b.x=n.readFloat32(),b.y=n.readFloat32(),b.z=n.readFloat32(),b.w=n.readFloat32(),"LAYAANIMATION:WEIGHT_05"==ha._version&&(r=n.readByte()),1==r&&(V.x=n.readUint8(),V.y=n.readUint8(),V.z=n.readUint8(),V.w=n.readUint8(),U.x=n.readFloat32(),U.y=n.readFloat32(),U.z=n.readFloat32(),U.w=n.readFloat32(),H.x=n.readFloat32(),H.y=n.readFloat32(),H.z=n.readFloat32(),H.w=n.readFloat32());break;default:throw"AnimationClipParser04:unknown type."}}break;case"LAYAANIMATION:COMPRESSION_04":for(a=0;a<A;a++)switch(f){case e.KeyFrameValueType.Float:E=new t.FloatKeyframe,i._setKeyframeByIndex(a,E),E.time=s[n.readUint16()],E.inTangent=t.HalfFloatUtils.convertToNumber(n.readUint16()),E.outTangent=t.HalfFloatUtils.convertToNumber(n.readUint16()),E.value=t.HalfFloatUtils.convertToNumber(n.readUint16());break;case e.KeyFrameValueType.Position:case e.KeyFrameValueType.Scale:case e.KeyFrameValueType.RotationEuler:case e.KeyFrameValueType.Vector3:D=new t.Vector3Keyframe,i._setKeyframeByIndex(a,D),D.time=s[n.readUint16()],R=D.inTangent,x=D.outTangent,y=D.value,R.x=t.HalfFloatUtils.convertToNumber(n.readUint16()),R.y=t.HalfFloatUtils.convertToNumber(n.readUint16()),R.z=t.HalfFloatUtils.convertToNumber(n.readUint16()),x.x=t.HalfFloatUtils.convertToNumber(n.readUint16()),x.y=t.HalfFloatUtils.convertToNumber(n.readUint16()),x.z=t.HalfFloatUtils.convertToNumber(n.readUint16()),y.x=t.HalfFloatUtils.convertToNumber(n.readUint16()),y.y=t.HalfFloatUtils.convertToNumber(n.readUint16()),y.z=t.HalfFloatUtils.convertToNumber(n.readUint16());break;case e.KeyFrameValueType.Rotation:M=new t.QuaternionKeyframe,i._setKeyframeByIndex(a,M),M.time=s[n.readUint16()],C=M.inTangent,v=M.outTangent,I=M.value,C.x=t.HalfFloatUtils.convertToNumber(n.readUint16()),C.y=t.HalfFloatUtils.convertToNumber(n.readUint16()),C.z=t.HalfFloatUtils.convertToNumber(n.readUint16()),C.w=t.HalfFloatUtils.convertToNumber(n.readUint16()),v.x=t.HalfFloatUtils.convertToNumber(n.readUint16()),v.y=t.HalfFloatUtils.convertToNumber(n.readUint16()),v.z=t.HalfFloatUtils.convertToNumber(n.readUint16()),v.w=t.HalfFloatUtils.convertToNumber(n.readUint16()),I.x=t.HalfFloatUtils.convertToNumber(n.readUint16()),I.y=t.HalfFloatUtils.convertToNumber(n.readUint16()),I.z=t.HalfFloatUtils.convertToNumber(n.readUint16()),I.w=t.HalfFloatUtils.convertToNumber(n.readUint16());break;case e.KeyFrameValueType.Vector2:w=new t.Vector2Keyframe;i._setKeyframeByIndex(a,w),w.time=s[n.readUint16()];B=w.inTangent,P=w.outTangent,L=w.value;B.x=t.HalfFloatUtils.convertToNumber(n.readUint16()),B.y=t.HalfFloatUtils.convertToNumber(n.readUint16()),P.x=t.HalfFloatUtils.convertToNumber(n.readUint16()),P.y=t.HalfFloatUtils.convertToNumber(n.readUint16()),L.x=t.HalfFloatUtils.convertToNumber(n.readUint16()),L.y=t.HalfFloatUtils.convertToNumber(n.readUint16());break;case e.KeyFrameValueType.Vector4:case e.KeyFrameValueType.Color:F=new t.Vector4Keyframe;i._setKeyframeByIndex(a,F),F.time=s[n.readUint16()];N=F.inTangent,O=F.outTangent,b=F.value;N.x=t.HalfFloatUtils.convertToNumber(n.readUint16()),N.y=t.HalfFloatUtils.convertToNumber(n.readUint16()),N.z=t.HalfFloatUtils.convertToNumber(n.readUint16()),N.w=t.HalfFloatUtils.convertToNumber(n.readUint16()),O.x=t.HalfFloatUtils.convertToNumber(n.readUint16()),O.y=t.HalfFloatUtils.convertToNumber(n.readUint16()),O.z=t.HalfFloatUtils.convertToNumber(n.readUint16()),O.w=t.HalfFloatUtils.convertToNumber(n.readUint16()),b.x=t.HalfFloatUtils.convertToNumber(n.readUint16()),b.y=t.HalfFloatUtils.convertToNumber(n.readUint16()),b.z=t.HalfFloatUtils.convertToNumber(n.readUint16()),b.w=t.HalfFloatUtils.convertToNumber(n.readUint16());break;case e.KeyFrameValueType.MaterialRef:{const e=new t.StringKeyframe;e.time=s[n.readUint16()],e.value=ha._strings[n.readUint16()],i._setKeyframeByIndex(a,e);break}default:throw"AnimationClipParser04:unknown type."}}}var G=n.readUint16();for(r=0;r<G;r++){var k=new Zr;k.time=Math.min(h,n.readFloat32()),k.eventName=ha._strings[n.readUint16()];var z=[],W=n.readUint16();for(W>0&&(k.params=z=[]),a=0;a<W;a++){switch(n.readByte()){case 0:z.push(!!n.readByte());break;case 1:z.push(n.readInt32());break;case 2:z.push(n.readFloat32());break;case 3:z.push(ha._strings[n.readUint16()]);break;default:throw new Error("unknown type.")}}l.addEvent(k)}}}ha._strings=[],ha._BLOCK={count:0},ha._DATA={offset:0,size:0};class da{get count(){return this._nodes.length}set count(e){this._nodes.length=e}constructor(){this._nodes=[]}getNodeByIndex(e){return this._nodes[e]}setNodeByIndex(e,t){this._nodes[e]=t}}class ca extends t.Resource{static _parse(e){var r=new ca,a=new t.Byte(e),i=a.readUTFString();switch(i){case"LAYAANIMATION:03":$r.parse(r,a);break;case"LAYAANIMATION:04":case"LAYAANIMATION:COMPRESSION_04":case"LAYAANIMATION:WEIGHT_04":case"LAYAANIMATION:WEIGHT_05":ha.parse(r,a,i);break;default:throw new Error("unknown animationClip version.")}return r}static load(e,r){t.ILaya.loader.load(e,r,null,t.Loader.ANIMATIONCLIP)}duration(){return this._duration}constructor(){super(),this._duration=0,this._frameRate=0,this._nodes=new da,this.islooping=!1,this._animationEvents=[]}_weightModeHermite(e,r){return 0==(e&t.WeightedMode.Out)&&0==(r&t.WeightedMode.In)}static _resolvePlainHermite(t){if(t._isPlainHermiteResolved)return;t._isPlainHermiteResolved=!0;const r=t.type;if(r===e.KeyFrameValueType.Boolean||r===e.KeyFrameValueType.PathPoint)return void(t._isPlainHermite=!0);const a=t._keyFrames;let i=!0;for(let e=0,t=a.length;e<t&&i;e++){const t=a[e],r=t.weightedMode;if(null!=r)if("number"==typeof r){if(0!==r){i=!1;break}}else if(0|r.x||0|r.y||void 0!==r.z&&0|r.z||void 0!==r.w&&0|r.w){i=!1;break}const n=t.inTangent,s=t.outTangent;if("number"==typeof n){if(!Number.isFinite(n)||!Number.isFinite(s)){i=!1;break}}else if(n){if(!Number.isFinite(n.x)||!Number.isFinite(s.x)){i=!1;break}if(!(void 0===n.y||Number.isFinite(n.y)&&Number.isFinite(s.y))){i=!1;break}if(!(void 0===n.z||Number.isFinite(n.z)&&Number.isFinite(s.z))){i=!1;break}if(!(void 0===n.w||Number.isFinite(n.w)&&Number.isFinite(s.w))){i=!1;break}}}t._isPlainHermite=i}_hermiteInterpolateV3Plain(e,t,r,a,i){const n=e.value,s=t.value,o=e.outTangent,l=t.inTangent,h=r*r,d=h*r,c=2*d-3*h+1,u=d-2*h+r,_=d-h,f=-2*d+3*h;i.x=c*n.x+u*o.x*a+_*l.x*a+f*s.x,i.y=c*n.y+u*o.y*a+_*l.y*a+f*s.y,i.z=c*n.z+u*o.z*a+_*l.z*a+f*s.z}_hermiteInterpolateQuaternionPlain(e,t,r,a,i){const n=e.value,s=t.value,o=e.outTangent,l=t.inTangent,h=r*r,d=h*r,c=2*d-3*h+1,u=d-2*h+r,_=d-h,f=-2*d+3*h;i.x=c*n.x+u*o.x*a+_*l.x*a+f*s.x,i.y=c*n.y+u*o.y*a+_*l.y*a+f*s.y,i.z=c*n.z+u*o.z*a+_*l.z*a+f*s.z,i.w=c*n.w+u*o.w*a+_*l.w*a+f*s.w}_hermiteInterpolate(e,t,r,a){var i=e.outTangent,n=t.inTangent;if(Number.isFinite(i)&&Number.isFinite(n)){var s=r*r,o=s*r,l=o-2*s+r,h=o-s,d=-2*o+3*s;return(2*o-3*s+1)*e.value+l*i*a+h*n*a+d*t.value}return e.value}_hermiteInterpolateVector3(e,t,r,a,i){var n=e.value,s=e.outTangent,o=t.value,l=t.inTangent,h=r*r,d=h*r,c=2*d-3*h+1,u=d-2*h+r,_=d-h,f=-2*d+3*h,m=s.x,g=l.x;!e.weightedMode||this._weightModeHermite(e.weightedMode.x,t.weightedMode.x)?Number.isFinite(m)&&Number.isFinite(g)?i.x=c*n.x+u*m*a+_*g*a+f*o.x:i.x=n.x:i.x=this._hermiteCurveSplineWeight(e.value.x,e.time,e.outWeight.x,e.outTangent.x,t.value.x,t.time,t.inWeight.x,t.inTangent.x,r),m=s.y,g=l.y,!e.weightedMode||this._weightModeHermite(e.weightedMode.y,t.weightedMode.y)?Number.isFinite(m)&&Number.isFinite(g)?i.y=c*n.y+u*m*a+_*g*a+f*o.y:i.y=n.y:i.y=this._hermiteCurveSplineWeight(e.value.y,e.time,e.outWeight.y,e.outTangent.y,t.value.y,t.time,t.inWeight.y,t.inTangent.y,r),m=s.z,g=l.z,!e.weightedMode||this._weightModeHermite(e.weightedMode.z,t.weightedMode.z)?Number.isFinite(m)&&Number.isFinite(g)?i.z=c*n.z+u*m*a+_*g*a+f*o.z:i.z=n.z:i.z=this._hermiteCurveSplineWeight(e.value.z,e.time,e.outWeight.z,e.outTangent.z,t.value.z,t.time,t.inWeight.z,t.inTangent.z,r)}_hermiteInterpolateQuaternion(e,t,r,a,i){var n=e.value,s=e.outTangent,o=t.value,l=t.inTangent,h=r*r,d=h*r,c=2*d-3*h+1,u=d-2*h+r,_=d-h,f=-2*d+3*h,m=s.x,g=l.x;!e.weightedMode||this._weightModeHermite(e.weightedMode.x,t.weightedMode.x)?Number.isFinite(m)&&Number.isFinite(g)?i.x=c*n.x+u*m*a+_*g*a+f*o.x:i.x=n.x:i.x=this._hermiteCurveSplineWeight(e.value.x,e.time,e.outWeight.x,e.outTangent.x,t.value.x,t.time,t.inWeight.x,t.inTangent.x,r),m=s.y,g=l.y,!e.weightedMode||this._weightModeHermite(e.weightedMode.y,t.weightedMode.y)?Number.isFinite(m)&&Number.isFinite(g)?i.y=c*n.y+u*m*a+_*g*a+f*o.y:i.y=n.y:i.y=this._hermiteCurveSplineWeight(e.value.y,e.time,e.outWeight.y,e.outTangent.y,t.value.y,t.time,t.inWeight.y,t.inTangent.y,r),m=s.z,g=l.z,!e.weightedMode||this._weightModeHermite(e.weightedMode.z,t.weightedMode.z)?Number.isFinite(m)&&Number.isFinite(g)?i.z=c*n.z+u*m*a+_*g*a+f*o.z:i.z=n.z:i.z=this._hermiteCurveSplineWeight(e.value.z,e.time,e.outWeight.z,e.outTangent.z,t.value.z,t.time,t.inWeight.z,t.inTangent.z,r),m=s.w,g=l.w,!e.weightedMode||this._weightModeHermite(e.weightedMode.w,t.weightedMode.w)?Number.isFinite(m)&&Number.isFinite(g)?i.w=c*n.w+u*m*a+_*g*a+f*o.w:i.w=n.w:i.w=this._hermiteCurveSplineWeight(e.value.w,e.time,e.outWeight.w,e.outTangent.w,t.value.w,t.time,t.inWeight.w,t.inTangent.w,r)}_hermiteInterpolateVector4(e,t,r,a,i){var n=e.value,s=e.outTangent,o=t.value,l=t.inTangent,h=r*r,d=h*r,c=2*d-3*h+1,u=d-2*h+r,_=d-h,f=-2*d+3*h,m=s.x,g=l.x;!e.weightedMode||this._weightModeHermite(e.weightedMode.x,t.weightedMode.x)?Number.isFinite(m)&&Number.isFinite(g)?i.x=c*n.x+u*m*a+_*g*a+f*o.x:i.x=n.x:i.x=this._hermiteCurveSplineWeight(e.value.x,e.time,e.outWeight.x,e.outTangent.x,t.value.x,t.time,t.inWeight.x,t.inTangent.x,r),m=s.y,g=l.y,!e.weightedMode||this._weightModeHermite(e.weightedMode.y,t.weightedMode.y)?Number.isFinite(m)&&Number.isFinite(g)?i.y=c*n.y+u*m*a+_*g*a+f*o.y:i.y=n.y:i.y=this._hermiteCurveSplineWeight(e.value.y,e.time,e.outWeight.y,e.outTangent.y,t.value.y,t.time,t.inWeight.y,t.inTangent.y,r),m=s.z,g=l.z,!e.weightedMode||this._weightModeHermite(e.weightedMode.z,t.weightedMode.z)?Number.isFinite(m)&&Number.isFinite(g)?i.z=c*n.z+u*m*a+_*g*a+f*o.z:i.z=n.z:i.z=this._hermiteCurveSplineWeight(e.value.z,e.time,e.outWeight.z,e.outTangent.z,t.value.z,t.time,t.inWeight.z,t.inTangent.z,r),m=s.w,g=l.w,!e.weightedMode||this._weightModeHermite(e.weightedMode.w,t.weightedMode.w)?Number.isFinite(m)&&Number.isFinite(g)?i.w=c*n.w+u*m*a+_*g*a+f*o.w:i.w=n.w:i.w=this._hermiteCurveSplineWeight(e.value.w,e.time,e.outWeight.w,e.outTangent.w,t.value.w,t.time,t.inWeight.w,t.inTangent.w,r)}_hermiteInterpolateVector2(e,t,r,a,i){var n=e.value,s=e.outTangent,o=t.value,l=t.inTangent,h=r*r,d=h*r,c=2*d-3*h+1,u=d-2*h+r,_=d-h,f=-2*d+3*h,m=s.x,g=l.x;!e.weightedMode||this._weightModeHermite(e.weightedMode.x,t.weightedMode.x)?Number.isFinite(m)&&Number.isFinite(g)?i.x=c*n.x+u*m*a+_*g*a+f*o.x:i.x=n.x:i.x=this._hermiteCurveSplineWeight(e.value.x,e.time,e.outWeight.x,e.outTangent.x,t.value.x,t.time,t.inWeight.x,t.inTangent.x,r),m=s.y,g=l.y,!e.weightedMode||this._weightModeHermite(e.weightedMode.y,t.weightedMode.y)?Number.isFinite(m)&&Number.isFinite(g)?i.y=c*n.y+u*m*a+_*g*a+f*o.y:i.y=n.y:i.y=this._hermiteCurveSplineWeight(e.value.y,e.time,e.outWeight.y,e.outTangent.y,t.value.y,t.time,t.inWeight.y,t.inTangent.y,r)}_hermiteCurveSplineWeight(e,t,r,a,i,n,s,o,l){let h=222e-18,d=l,c=e,u=r,_=s,f=n-t,m=i-c;m=Math.max(Math.abs(m),h)*(m<0?-1:1);let g=a,p=o;if(!Number.isFinite(g)||!Number.isFinite(p))return e;g=g*f/m,p=p*f/m;let S=1-_,T=.5,A=0;if(Math.abs(u-.33333334)<1e-4&&Math.abs(_-.33333334)<1e-4)T=d,A=1-T;else for(;;){A=1-T;let e=3*A*A*T*u+3*A*T*T*S+T*T*T-d;if(Math.abs(e)<=2.5*h)break;let t=3*A*A*u+6*A*T*(S-u)+3*T*T*(1-S),r=6*A*(S-2*u)+6*T*(1-2*S+u);T-=(6*e*t*t-3*e*e*r)/(6*t*t*t-6*e*t*r+e*e*(18*u-18*S+6))}return(3*A*A*T*u*g+3*A*T*T*(1-_*p)+T*T*T)*m+c}_curveInterpolate(e,t,r,a){return!e.weightedMode||this._weightModeHermite(e.weightedMode,t.weightedMode)?this._hermiteInterpolate(e,t,r,a):this._hermiteCurveSplineWeight(e.value,e.time,e.outWeight,e.outTangent,t.value,t.time,t.inWeight,t.inTangent,r)}_evaluateClipDatasRealTime(r,a,i,n,s,o,l,h=!1){for(var d=0,c=r.count;d<c;d++){var u,_=r.getNodeByIndex(d),f=_.type,m=_._keyFrames,g=m.length,p=i[d];if((!l||l.getTransformActive(_.nodePath))&&(!h||f!==e.KeyFrameValueType.Position&&f!==e.KeyFrameValueType.Rotation&&f!==e.KeyFrameValueType.Scale&&f!==e.KeyFrameValueType.RotationEuler)){if(s)for(-1!==p&&a<m[p].time&&(p=-1,i[d]=p),u=p+1;u<g&&!(m[u].time>a);)p++,u++,i[d]=p;else for((u=p+1)!==g&&a>m[u].time&&(p=g-1,i[d]=p),u=p+1;p>-1&&!(m[p].time<a);)p--,u--,i[d]=p;var S=u===g;switch(f){case e.KeyFrameValueType.PathPoint:var T=m[p];let r=m[0].value;if(-1!==p&&(r=m[p].value),S)o[d]={pos:r.getPointAt(1),rotation:r.getRotationAt(1)};else D=0!==(E=(A=m[u]).time-T.time)?(a-T.time)/E:0,o[d]={pos:r.getPointAt(D),rotation:r.getRotationAt(D)};break;case e.KeyFrameValueType.Boolean:case e.KeyFrameValueType.MaterialRef:o[d]=-1!==p?m[p].value:m[0].value;break;case e.KeyFrameValueType.Float:if(-1!==p){var A,E,D;T=m[p];if(S)o[d]=T.value;else D=0!==(E=(A=m[u]).time-T.time)?(a-T.time)/E:0,o[d]=this._curveInterpolate(T,A,D,E)}else o[d]=m[0].value;n&&(o[d]=o[d]-m[0].value);break;case e.KeyFrameValueType.Position:case e.KeyFrameValueType.RotationEuler:case e.KeyFrameValueType.Vector3:var R=o[d];if(_._isPlainHermiteResolved||ca._resolvePlainHermite(_),this._evaluateFrameNodeVector3DatasRealTime(m,p,S,a,R,_._isPlainHermite),n){var x=m[0].value;R.x-=x.x,R.y-=x.y,R.z-=x.z}break;case e.KeyFrameValueType.Rotation:var y=o[d];if(_._isPlainHermiteResolved||ca._resolvePlainHermite(_),this._evaluateFrameNodeQuaternionDatasRealTime(m,p,S,a,y,_._isPlainHermite),n){var M=ca._tempQuaternion0,C=m[0].value;Z.quaternionConjugate(C,M),t.Quaternion.multiply(M,y,y)}break;case e.KeyFrameValueType.Scale:R=o[d],_._isPlainHermiteResolved||ca._resolvePlainHermite(_),this._evaluateFrameNodeVector3DatasRealTime(m,p,S,a,R,_._isPlainHermite),n&&(x=m[0].value,R.x/=x.x,R.y/=x.y,R.z/=x.z);break;case e.KeyFrameValueType.Vector2:var v=o[d];if(this._evaluateFrameNodeVector2DatasRealTime(m,p,S,a,v),n){var I=m[0].value;v.x-=I.x,v.y-=I.y}break;case e.KeyFrameValueType.Vector4:case e.KeyFrameValueType.Color:var w=o[d];if(this._evaluateFrameNodeVector4DatasRealTime(m,p,S,a,w),n){var B=m[0].value;w.x-=B.x,w.y-=B.y,w.z-=B.z,w.w-=B.w}break;default:throw new Error("AnimationClip:unknown node type.")}}}}_evaluateFrameNodeVector3DatasRealTime(e,t,r,a,i,n){if(-1!==t){var s=e[t];if(r){var o=s.value;i.x=o.x,i.y=o.y,i.z=o.z}else{var l,h=e[t+1],d=s.time,c=h.time-d;l=0!==c?(a-d)/c:0,n?this._hermiteInterpolateV3Plain(s,h,l,c,i):this._hermiteInterpolateVector3(s,h,l,c,i)}}else{var u=e[0].value;i.x=u.x,i.y=u.y,i.z=u.z}}_evaluateFrameNodeVector2DatasRealTime(e,t,r,a,i){if(-1!==t){var n=e[t];if(r){var s=n.value;i.x=s.x,i.y=s.y}else{var o,l=e[t+1],h=n.time,d=l.time-h;o=0!==d?(a-h)/d:0,this._hermiteInterpolateVector2(n,l,o,d,i)}}else{var c=e[0].value;i.x=c.x,i.y=c.y}}_evaluateFrameNodeVector4DatasRealTime(e,t,r,a,i){if(-1!==t){var n=e[t];if(r){var s=n.value;i.x=s.x,i.y=s.y,i.z=s.z,i.w=s.w}else{var o,l=e[t+1],h=n.time,d=l.time-h;o=0!==d?(a-h)/d:0,this._hermiteInterpolateVector4(n,l,o,d,i)}}else{var c=e[0].value;i.x=c.x,i.y=c.y,i.z=c.z,i.w=c.w}}_evaluateFrameNodeQuaternionDatasRealTime(e,t,r,a,i,n){if(-1!==t){var s=e[t];if(r){var o=s.value;i.x=o.x,i.y=o.y,i.z=o.z,i.w=o.w}else{var l,h=e[t+1],d=s.time,c=h.time-d;l=0!==c?(a-d)/c:0,n?this._hermiteInterpolateQuaternionPlain(s,h,l,c,i):this._hermiteInterpolateQuaternion(s,h,l,c,i)}}else{var u=e[0].value;i.x=u.x,i.y=u.y,i.z=u.z,i.w=u.w}}_binarySearchEventIndex(e){for(var t,r=0,a=this._animationEvents.length-1;r<=a;){t=Math.floor((r+a)/2);var i=this._animationEvents[t].time;if(i==e)return t;i>e?a=t-1:r=t+1}return r}addEvent(e){var t=this._binarySearchEventIndex(e.time);this._animationEvents.splice(t,0,e)}_disposeResource(){sa(this._id),this._nodes=null,this._nodesMap=null}}ca._tempQuaternion0=new t.Quaternion;class ua extends R{get color(){return this._light.color}set color(e){this._light.color=e}get mode(){return this._light.lightmapBakedType}set mode(e){this._light.lightmapBakedType=e}get intensity(){return this._light.intensity}set intensity(e){this._light.intensity=e}get shadowMode(){return this._light.shadowMode}set shadowMode(e){this._light.shadowMode=e}get shadowDistance(){return this._light.shadowDistance}set shadowDistance(e){this._light.shadowDistance=e}get shadowResolution(){return this._light.shadowResolution}set shadowResolution(e){this._light.shadowResolution=e}get shadowDepthBias(){return this._light.shadowDepthBias}set shadowDepthBias(e){this._light.shadowDepthBias=e}get shadowNormalBias(){return this._light.shadowNormalBias}set shadowNormalBias(e){this._light.shadowNormalBias=e}get shadowStrength(){return this._light.shadowStrength}set shadowStrength(e){this._light.shadowStrength=e}get shadowNearPlane(){return this._light.shadowNearPlane}set shadowNearPlane(e){this._light.shadowNearPlane=e}get lightmapBakedType(){return this._light.lightmapBakedType}set lightmapBakedType(e){this._light.lightmapBakedType=e}get lightWorldMatrix(){return this._light.lightWorldMatrix}constructor(){super()}_cloneTo(e,t,r){super._cloneTo(e,t,r),e.color=this.color.clone(),e.intensity=this.intensity,e.lightmapBakedType=this.lightmapBakedType}_addToLightQueue(){}_removeFromLightQueue(){}}class _a extends t.Material{get color(){return this.getColorByIndex(S.ALBEDOCOLOR)}set color(e){this.setColorByIndex(S.ALBEDOCOLOR,e)}get texture(){return this.getTextureByIndex(S.ALBEDOTEXTURE)}set texture(e){e?this.addDefine(S.SHADERDEFINE_ALBEDOTEXTURE):this.removeDefine(S.SHADERDEFINE_ALBEDOTEXTURE),this.setTextureByIndex(S.ALBEDOTEXTURE,e)}get tilingOffset(){return this.getVector4ByIndex(S.TILINGOFFSET)}set tilingOffset(e){e?this.setVector4ByIndex(S.TILINGOFFSET,e):this.getVector4ByIndex(S.TILINGOFFSET).setValue(1,1,0,0)}constructor(){super(),this.setShaderName("Unlit"),this.setVector4ByIndex(S.TILINGOFFSET,new t.Vector4(1,1,0,0)),this.setColorByIndex(S.ALBEDOCOLOR,new t.Color(1,1,1,1)),this.renderMode=_a.RENDERMODE_ADDTIVE}clone(){var e=new _a;return this.cloneTo(e),e}set renderMode(e){switch(e){case _a.RENDERMODE_ADDTIVE:this.renderQueue=t.Material.RENDERQUEUE_TRANSPARENT,this.alphaTest=!1,this.depthWrite=!1,this.cull=t.RenderState.CULL_NONE,this.blend=t.RenderState.BLEND_ENABLE_ALL,this.blendSrc=t.RenderState.BLENDPARAM_SRC_ALPHA,this.blendDst=t.RenderState.BLENDPARAM_ONE,this.depthTest=t.RenderState.DEPTHTEST_LEQUAL,this.addDefine(t.Material.SHADERDEFINE_ADDTIVEFOG);break;case _a.RENDERMODE_ALPHABLENDED:this.renderQueue=t.Material.RENDERQUEUE_TRANSPARENT,this.alphaTest=!1,this.depthWrite=!1,this.cull=t.RenderState.CULL_NONE,this.blend=t.RenderState.BLEND_ENABLE_ALL,this.blendSrc=t.RenderState.BLENDPARAM_SRC_ALPHA,this.blendDst=t.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA,this.depthTest=t.RenderState.DEPTHTEST_LEQUAL,this.removeDefine(t.Material.SHADERDEFINE_ADDTIVEFOG);break;default:throw new Error("unknown renderMode: "+e)}}}_a.RENDERMODE_ADDTIVE=0,_a.RENDERMODE_ALPHABLENDED=1;class fa extends t.Material{static __initDefine__(){fa.SHADERDEFINE_DETAIL_NUM1=t.Shader3D.getDefineByName("ExtendTerrain_DETAIL_NUM1"),fa.SHADERDEFINE_DETAIL_NUM2=t.Shader3D.getDefineByName("ExtendTerrain_DETAIL_NUM2"),fa.SHADERDEFINE_DETAIL_NUM3=t.Shader3D.getDefineByName("ExtendTerrain_DETAIL_NUM3"),fa.SHADERDEFINE_DETAIL_NUM4=t.Shader3D.getDefineByName("ExtendTerrain_DETAIL_NUM4"),fa.SHADERDEFINE_DETAIL_NUM5=t.Shader3D.getDefineByName("ExtendTerrain_DETAIL_NUM5"),fa.SPLATALPHATEXTURE=t.Shader3D.propertyNameToID("u_SplatAlphaTexture"),fa.DIFFUSETEXTURE1=t.Shader3D.propertyNameToID("u_DiffuseTexture1"),fa.DIFFUSETEXTURE2=t.Shader3D.propertyNameToID("u_DiffuseTexture2"),fa.DIFFUSETEXTURE3=t.Shader3D.propertyNameToID("u_DiffuseTexture3"),fa.DIFFUSETEXTURE4=t.Shader3D.propertyNameToID("u_DiffuseTexture4"),fa.DIFFUSETEXTURE5=t.Shader3D.propertyNameToID("u_DiffuseTexture5"),fa.DIFFUSESCALEOFFSET1=t.Shader3D.propertyNameToID("u_DiffuseScaleOffset1"),fa.DIFFUSESCALEOFFSET2=t.Shader3D.propertyNameToID("u_DiffuseScaleOffset2"),fa.DIFFUSESCALEOFFSET3=t.Shader3D.propertyNameToID("u_DiffuseScaleOffset3"),fa.DIFFUSESCALEOFFSET4=t.Shader3D.propertyNameToID("u_DiffuseScaleOffset4"),fa.DIFFUSESCALEOFFSET5=t.Shader3D.propertyNameToID("u_DiffuseScaleOffset5")}get splatAlphaTexture(){return this._shaderValues.getTexture(fa.SPLATALPHATEXTURE)}set splatAlphaTexture(e){this._shaderValues.setTexture(fa.SPLATALPHATEXTURE,e)}get diffuseTexture1(){return this._shaderValues.getTexture(fa.DIFFUSETEXTURE1)}set diffuseTexture1(e){this._shaderValues.setTexture(fa.DIFFUSETEXTURE1,e),this._setDetailNum(1)}get diffuseTexture2(){return this._shaderValues.getTexture(fa.DIFFUSETEXTURE2)}set diffuseTexture2(e){this._shaderValues.setTexture(fa.DIFFUSETEXTURE2,e),this._setDetailNum(2)}get diffuseTexture3(){return this._shaderValues.getTexture(fa.DIFFUSETEXTURE3)}set diffuseTexture3(e){this._shaderValues.setTexture(fa.DIFFUSETEXTURE3,e),this._setDetailNum(3)}get diffuseTexture4(){return this._shaderValues.getTexture(fa.DIFFUSETEXTURE4)}set diffuseTexture4(e){this._shaderValues.setTexture(fa.DIFFUSETEXTURE4,e),this._setDetailNum(4)}get diffuseTexture5(){return this._shaderValues.getTexture(fa.DIFFUSETEXTURE5)}set diffuseTexture5(e){this._shaderValues.setTexture(fa.DIFFUSETEXTURE5,e),this._setDetailNum(5)}set diffuseScaleOffset1(e){this._shaderValues.setVector(fa.DIFFUSESCALEOFFSET1,e)}set diffuseScaleOffset2(e){this._shaderValues.setVector(fa.DIFFUSESCALEOFFSET2,e)}set diffuseScaleOffset3(e){this._shaderValues.setVector(fa.DIFFUSESCALEOFFSET3,e)}set diffuseScaleOffset4(e){this._shaderValues.setVector(fa.DIFFUSESCALEOFFSET4,e)}set diffuseScaleOffset5(e){this._shaderValues.setVector(fa.DIFFUSESCALEOFFSET5,e)}set renderMode(e){switch(e){case fa.RENDERMODE_OPAQUE:this.renderQueue=t.Material.RENDERQUEUE_OPAQUE,this.depthWrite=!0,this.cull=t.RenderState.CULL_BACK,this.blend=t.RenderState.BLEND_DISABLE,this.depthTest=t.RenderState.DEPTHTEST_LESS;break;case fa.RENDERMODE_TRANSPARENT:this.renderQueue=t.Material.RENDERQUEUE_OPAQUE,this.depthWrite=!1,this.cull=t.RenderState.CULL_BACK,this.blend=t.RenderState.BLEND_ENABLE_ALL,this.blendSrc=t.RenderState.BLENDPARAM_SRC_ALPHA,this.blendDst=t.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA,this.depthTest=t.RenderState.DEPTHTEST_LEQUAL;break;default:throw new Error("unknown renderMode: "+e)}}constructor(){super(),this.setShaderName("ExtendTerrain"),this.renderMode=fa.RENDERMODE_OPAQUE}_setDetailNum(e){switch(e){case 1:this._shaderValues.addDefine(fa.SHADERDEFINE_DETAIL_NUM1),this._shaderValues.removeDefine(fa.SHADERDEFINE_DETAIL_NUM2),this._shaderValues.removeDefine(fa.SHADERDEFINE_DETAIL_NUM3),this._shaderValues.removeDefine(fa.SHADERDEFINE_DETAIL_NUM4),this._shaderValues.removeDefine(fa.SHADERDEFINE_DETAIL_NUM5);break;case 2:this._shaderValues.addDefine(fa.SHADERDEFINE_DETAIL_NUM2),this._shaderValues.removeDefine(fa.SHADERDEFINE_DETAIL_NUM1),this._shaderValues.removeDefine(fa.SHADERDEFINE_DETAIL_NUM3),this._shaderValues.removeDefine(fa.SHADERDEFINE_DETAIL_NUM4),this._shaderValues.removeDefine(fa.SHADERDEFINE_DETAIL_NUM5);break;case 3:this._shaderValues.addDefine(fa.SHADERDEFINE_DETAIL_NUM3),this._shaderValues.removeDefine(fa.SHADERDEFINE_DETAIL_NUM1),this._shaderValues.removeDefine(fa.SHADERDEFINE_DETAIL_NUM2),this._shaderValues.removeDefine(fa.SHADERDEFINE_DETAIL_NUM4),this._shaderValues.removeDefine(fa.SHADERDEFINE_DETAIL_NUM5);break;case 4:this._shaderValues.addDefine(fa.SHADERDEFINE_DETAIL_NUM4),this._shaderValues.removeDefine(fa.SHADERDEFINE_DETAIL_NUM1),this._shaderValues.removeDefine(fa.SHADERDEFINE_DETAIL_NUM2),this._shaderValues.removeDefine(fa.SHADERDEFINE_DETAIL_NUM3),this._shaderValues.removeDefine(fa.SHADERDEFINE_DETAIL_NUM5);break;case 5:this._shaderValues.addDefine(fa.SHADERDEFINE_DETAIL_NUM5),this._shaderValues.removeDefine(fa.SHADERDEFINE_DETAIL_NUM1),this._shaderValues.removeDefine(fa.SHADERDEFINE_DETAIL_NUM2),this._shaderValues.removeDefine(fa.SHADERDEFINE_DETAIL_NUM3),this._shaderValues.removeDefine(fa.SHADERDEFINE_DETAIL_NUM4)}}clone(){var e=new fa;return this.cloneTo(e),e}}fa.RENDERMODE_OPAQUE=1,fa.RENDERMODE_TRANSPARENT=2;class ma extends y{get meshFilter(){return this._meshFilter}get skinnedMeshRenderer(){return this._render}constructor(e=null,t=null){super(t),this._meshFilter=this.addComponent(D),this._render=this.addComponent(zr),e&&(this._meshFilter.sharedMesh=e)}destroy(e=!0){this._destroyed||(super.destroy(e),this._meshFilter.destroy())}}ma._tempArray0=[];class ga{constructor(){this._coefficients=new Float32Array(27)}getCoefficient(e,t){return this._coefficients[9*e+t]}setCoefficient(e,t,r){this._coefficients[9*e+t]=r}setCoefficients(e,t,r,a,i,n,s,o,l,h){var d=9*e;this._coefficients[d]=t,this._coefficients[++d]=r,this._coefficients[++d]=a,this._coefficients[++d]=i,this._coefficients[++d]=n,this._coefficients[++d]=s,this._coefficients[++d]=o,this._coefficients[++d]=l,this._coefficients[++d]=h}cloneTo(e){if(this!==e)for(var t=this._coefficients,r=e._coefficients,a=0;a<27;a++)r[a]=t[a]}}ga._default=new ga;const pa=new Float32Array(9),Sa=new Float32Array(9),Ta=new Float32Array(9);class Aa{static surfaceArea(e,t){return Math.atan2(e*t,Math.sqrt(e*e+t*t+1))}static uv2Dir(e,r,a,i){switch(a){case t.TextureCubeFace.PositiveX:i.x=1,i.y=-r,i.z=-e;break;case t.TextureCubeFace.NegativeX:i.x=-1,i.y=-r,i.z=e;break;case t.TextureCubeFace.PositiveY:i.x=e,i.y=1,i.z=r;break;case t.TextureCubeFace.NegativeY:i.x=e,i.y=-1,i.z=-r;break;case t.TextureCubeFace.PositiveZ:i.x=e,i.y=-r,i.z=1;break;case t.TextureCubeFace.NegativeZ:i.x=-e,i.y=-r,i.z=-1}}static sh_eval_9(e,t,r,a){const i=Math.sqrt,n=Math.PI;switch(e){case 0:return.5*i(1/n);case 1:return.5*-r*i(3/n);case 2:return.5*a*i(3/n);case 3:return.5*-t*i(3/n);case 4:return t*r*.5*i(15/n);case 5:return-r*a*.5*i(15/n);case 6:return.25*(3*a*a-1)*i(5/n);case 7:return-t*a*.5*i(15/n);case 8:return.25*(t*t-r*r)*i(15/n);default:return 0}}static CalCubemapSH(e,r,a,i=!0){let n=a,s=a,o=pa.fill(0),l=Sa.fill(0),h=Ta.fill(0),d=new t.Vector3;for(let a=0;a<6;a++){let c=e[a];for(let e=0;e<s;e++)for(let u=0;u<n;u++){let _=(u+.5)/n*2-1,f=(e+.5)/s*2-1,m=1/n,g=1/s,p=_-m,S=f-g,T=_+m,A=f+g,E=this.surfaceArea(p,S)-this.surfaceArea(p,A)-this.surfaceArea(T,S)+this.surfaceArea(T,A);this.uv2Dir(_,f,a,d),t.Vector3.normalize(d,d);let D=(u+e*n)*r,R=c[D],x=c[D+1],y=c[D+2];i&&(R=t.Color.gammaToLinearSpace(R),x=t.Color.gammaToLinearSpace(x),y=t.Color.gammaToLinearSpace(y));for(let e=0;e<this.SH_Count;e++){let t=this.sh_eval_9(e,d.x,d.y,d.z);o[e]+=R*t*E,l[e]+=x*t*E,h[e]+=y*t*E}}}let c=new ga;for(let e=0;e<this.SH_Count;e++){let t=this.k[e],r=o[e];c.setCoefficient(0,e,r*t);let a=l[e];c.setCoefficient(1,e,a*t);let i=h[e];c.setCoefficient(2,e,i*t)}return c}static CalGradientSH(e,r,a,i=!0){console.time("Gradient SH");let n=this._tempSkyPixels,s=this._tempEquatorPixels,o=this._tempGroundPixels;const l=(e,r,a)=>{let i=new t.Color(r.x,r.y,r.z,1);a&&i.toLinear(i);let n=Math.min(i.r,1),s=Math.min(i.g,1),o=Math.min(i.b,1);for(let t=0;t<e.length;t+=3)e[t]=n,e[t+1]=s,e[t+2]=o};l(n,e,i),l(s,r,i),l(o,a,i);let h=[];h[t.TextureCubeFace.PositiveY]=n,h[t.TextureCubeFace.NegativeY]=o,h[t.TextureCubeFace.PositiveX]=s,h[t.TextureCubeFace.NegativeX]=s,h[t.TextureCubeFace.PositiveZ]=s,h[t.TextureCubeFace.NegativeZ]=s;let d=Aa.CalCubemapSH(h,3,this.GradientSimulateSize,!1);return console.timeEnd("Gradient SH"),d}}Aa.k=[.28209479177387814,-.32573500793527993,.32573500793527993,-.32573500793527993,.2731371076480198,-.2731371076480198,.07884789131313,-.2731371076480198,.1365685538240099],Aa.GradientSimulateSize=3,Aa.SH_Count=9,Aa._tempSkyPixels=new Float32Array(Aa.GradientSimulateSize*Aa.GradientSimulateSize*3),Aa._tempEquatorPixels=new Float32Array(Aa.GradientSimulateSize*Aa.GradientSimulateSize*3),Aa._tempGroundPixels=new Float32Array(Aa.GradientSimulateSize*Aa.GradientSimulateSize*3);class Ea{constructor(e,t){this.min=e,this.max=t}_rotateExtents(e,t,r){var a=e.x,i=e.y,n=e.z,s=t.elements;r.x=Math.abs(s[0]*a)+Math.abs(s[4]*i)+Math.abs(s[8]*n),r.y=Math.abs(s[1]*a)+Math.abs(s[5]*i)+Math.abs(s[9]*n),r.z=Math.abs(s[2]*a)+Math.abs(s[6]*i)+Math.abs(s[10]*n)}getCorners(e){e.length=8;var r=this.min.x,a=this.min.y,i=this.min.z,n=this.max.x,s=this.max.y,o=this.max.z;e[0]=new t.Vector3(r,s,o),e[1]=new t.Vector3(n,s,o),e[2]=new t.Vector3(n,a,o),e[3]=new t.Vector3(r,a,o),e[4]=new t.Vector3(r,s,i),e[5]=new t.Vector3(n,s,i),e[6]=new t.Vector3(n,a,i),e[7]=new t.Vector3(r,a,i)}getCenter(e){t.Vector3.add(this.min,this.max,e),t.Vector3.scale(e,.5,e)}getExtent(e){t.Vector3.subtract(this.max,this.min,e),t.Vector3.scale(e,.5,e)}setCenterAndExtent(e,r){t.Vector3.subtract(e,r,this.min),t.Vector3.add(e,r,this.max)}tranform(e,r){var a=Da,i=Ra;this.getCenter(a),this.getExtent(i),t.Vector3.transformCoordinate(a,e,a),this._rotateExtents(i,e,i),r.setCenterAndExtent(a,i)}toDefault(){this.min.toDefault(),this.max.toDefault()}static createfromPoints(e,r){if(null==e)throw new Error("points");var a=r.min,i=r.max;a.x=Number.MAX_VALUE,a.y=Number.MAX_VALUE,a.z=Number.MAX_VALUE,i.x=-Number.MAX_VALUE,i.y=-Number.MAX_VALUE,i.z=-Number.MAX_VALUE;for(var n=0,s=e.length;n<s;++n)t.Vector3.min(a,e[n],a),t.Vector3.max(i,e[n],i)}static merge(e,r,a){t.Vector3.min(e.min,r.min,a.min),t.Vector3.max(e.max,r.max,a.max)}cloneTo(e){this.min.cloneTo(e.min),this.max.cloneTo(e.max)}clone(){var e=new Ea(new t.Vector3,new t.Vector3);return this.cloneTo(e),e}}const Da=new t.Vector3,Ra=new t.Vector3;class xa extends ut{get direction(){return this._direction}set direction(e){e.cloneTo(this.direction),this._dataModule.setDirection(this._direction)}get shadowCascadesMode(){return this._dataModule.shadowCascadesMode}set shadowCascadesMode(e){this._dataModule.shadowCascadesMode=e}get shadowTwoCascadeSplits(){return this._dataModule.shadowTwoCascadeSplits}set shadowTwoCascadeSplits(e){this._dataModule.shadowTwoCascadeSplits=e}get shadowFourCascadeSplits(){return this._shadowFourCascadeSplits}set shadowFourCascadeSplits(e){if(e.x>e.y||e.y>e.z||e.z>1)throw"DiretionLight:Invalid value.";e.cloneTo(this._shadowFourCascadeSplits),this._dataModule.setShadowFourCascadeSplits(this._shadowFourCascadeSplits)}constructor(){super(),this._direction=new t.Vector3,this._shadowTwoCascadeSplits=1/3,this._shadowFourCascadeSplits=new t.Vector3,this._lightType=e.LightType.Directional,this.shadowCascadesMode=e.ShadowCascadesMode.NoCascades,this.shadowFourCascadeSplits=new t.Vector3(1/15,.2,7/15),this.shadowTwoCascadeSplits=1/3}_creatModuleData(){this._dataModule=T.Render3DModuleDataFactory.createDirectLight()}_addToLightQueue(){this.owner.scene._directionLights.add(this)}_removeFromLightQueue(){this.owner.scene._directionLights.remove(this)}}class ya extends ut{get range(){return this._range}set range(e){this._range=e,this._dataModule.range=e}constructor(){super(),this._lightType=e.LightType.Point,this.range=6}_creatModuleData(){this._dataModule=T.Render3DModuleDataFactory.createPointLight()}_addToLightQueue(){this.owner.scene._pointLights.add(this)}_removeFromLightQueue(){this.owner.scene._pointLights.remove(this)}_cloneTo(t){super._cloneTo(t),t.range=this.range,t._lightType=e.LightType.Point}}class Ma extends ut{get direction(){return this._direction}set direction(e){e.cloneTo(this.direction),this._dataModule.setDirection(this._direction)}get spotAngle(){return this._dataModule.spotAngle}set spotAngle(e){this._dataModule.spotAngle=Math.max(Math.min(e,179),0)}get range(){return this._dataModule.spotRange}set range(e){this._dataModule.spotRange=e}constructor(){super(),this.spotAngle=30,this.range=10,this._direction=new t.Vector3,this._lightType=e.LightType.Spot}_creatModuleData(){this._dataModule=T.Render3DModuleDataFactory.createSpotLight()}_addToLightQueue(){this.owner.scene._spotLights.add(this)}_removeFromLightQueue(){this.owner.scene._spotLights.remove(this)}_cloneTo(e){super._cloneTo(e),e.range=this.range,e.spotAngle=this.spotAngle}}var Ca;e.AreaShape=void 0,(Ca=e.AreaShape||(e.AreaShape={}))[Ca.rectangle=0]="rectangle",Ca[Ca.ellipse=1]="ellipse";class va extends ut{constructor(){super(),this._lightType=e.LightType.Area,this._lightmapBakedType=e.LightMode.bakeOnly,this._spread=90,this._maxBounces=1024,this._size=new t.Vector2(1,1),this._areaShape=e.AreaShape.rectangle,this._power=100}_creatModuleData(){this._dataModule={transform:null,range:0,shadowResolution:1,shadowDistance:1,shadowMode:null,shadowStrength:1,shadowDepthBias:1,shadowNormalBias:1,shadowNearPlane:1}}get lightmapBakedType(){return e.LightMode.bakeOnly}set lightmapBakedType(t){this._lightmapBakedType=e.LightMode.bakeOnly}get shape(){return this._areaShape}set shape(e){this._areaShape=e}get power(){return this._power}set power(e){this._power=e}get size(){return this._size}set size(e){e&&e.cloneTo(this._size)}get spread(){return this._spread}set spread(e){this._spread=Math.min(Math.max(0,e),180)}get maxBounces(){return this._maxBounces}set maxBounces(e){this._maxBounces=e}_addToLightQueue(){}_removeFromLightQueue(){}}const Ia=new t.Vector3;class wa{constructor(e){this._mincullRate=e,this._renders=[],this._cachSprite3D=[]}get mincullRate(){return this._mincullRate}set mincullRate(e){this._mincullRate=e}set maxVisibalDistance(t){for(var r=0;r<this._renders.length;r++){let a=this._renders[r];a._baseRenderNode.visibalMax=t,a._batchRender&&a._batchRender.updateProperty(a,e.propertyChangeFlag.VisibalRange)}}set minVisibalDistance(t){for(var r=0;r<this._renders.length;r++){let a=this._renders[r];a._baseRenderNode.visibalMin=t,a._batchRender&&a._batchRender.updateProperty(a,e.propertyChangeFlag.VisibalRange)}}set group(e){if(e!=this._group){if(this._group)for(let e=0,r=this._renders.length;e<r;e++){this._renders[e].owner.transform.off(t.Event.TRANSFORM_CHANGED,this._group._updateRecaculateFlag)}this._group=e;for(let e=0,r=this._renders.length;e<r;e++){this._renders[e].owner.transform.on(t.Event.TRANSFORM_CHANGED,this._group,this._group._updateRecaculateFlag)}}}get renders(){return this._cachSprite3D}set renders(e){this._cachSprite3D=e;for(var t=0,r=e.length;t<r;t++)this.addNode(e[t])}addNode(r){if(!r)return;let a=r;if(a._isRenderNode>0){let i=a.components;for(let t of i)t instanceof z&&-1==this._renders.indexOf(t)&&(this._renders.push(t),t._baseRenderNode.visibalRangeBit=e.VisibalRangeFlag.LOD);this._group&&r.transform.on(t.Event.TRANSFORM_CHANGED,this._group,this._group._updateRecaculateFlag)}for(var i=0,n=r.numChildren;i<n;i++)this.addNode(r.getChildAt(i))}removeNode(r){let a=r;if(a._isRenderNode>0){let i,n=a.components;for(let a of n)a instanceof z&&-1==(i=this._renders.indexOf(a))&&(this._renders.splice(i,1),a._baseRenderNode.visibalRangeBit=e.VisibalRangeFlag.None,this._group&&r.transform.off(t.Event.TRANSFORM_CHANGED,this._group._updateRecaculateFlag))}for(var i=0,n=r.numChildren;i<n;i++)this.removeNode(r.getChildAt(i))}removeAllRender(){this._renders.forEach(t=>{t._baseRenderNode.visibalRangeBit=e.VisibalRangeFlag.None})}}class Ba extends t.Component{constructor(){super(),this._needcaculateBounds=!1,this._lods=[],this._visialIndex=-1,this._needChangeLODVisibal=!1,this._bounds=new M,this._lodPosition=new t.Vector3,this.runInEditor=!0}shadowCullPass(){return!1}get visialIndex(){return this._visialIndex}get lods(){return this._lods}set lods(e){this._lods=e;for(var t=0,r=this._lods.length;t<r;t++){let e=this._lods[t];e._lodIndex=t,e.group=this}this._updateRecaculateFlag(),this._notifyChangeLODVisibal(),this._lodCount=this._lods.length}get nowRate(){return this._nowRate}get bounds(){return this.recalculateBounds(),this._bounds}_onEnable(){super._onEnable(),this._notifyChangeLODVisibal()}_onDisable(){super._onDisable(),this._lods.forEach(e=>{e.removeAllRender()})}onDestroy(){this._lods.forEach(e=>{let t=e._renders;for(var r=0;r<t.length;r++)e.removeNode(t[r].owner)})}_updateRecaculateFlag(){this._needcaculateBounds=!0}_cloneTo(e){super._cloneTo(e);let t=(e,t,r)=>{let a=((e,t)=>{let r=[],a=e;for(;a;)a instanceof R&&r.push(a),a=a.parent;let i=t;for(;i&&-1==r.indexOf(i);)i=i.parent;return i})(e,t);if(!a)return null;let i=[];Z._getHierarchyPath(a,e,i);let n=[];Z._getHierarchyPath(a,t,n);let s=Z._getParentNodeByHierarchyPath(r,i);return s?Z._getNodeByHierarchyPath(s,n):null},r=[];for(let a=0,i=this._lodCount;a<i;a++){let i=this._lods[a],n=new wa(i.mincullRate);r.push(n),i._renders.forEach(r=>{let a=t(this.owner,r.owner,e.owner);a&&n.addNode(a)})}e.lods=r}recalculateBounds(){if(!this._needcaculateBounds)return;let e=!0;for(let t=0,r=this._lods.length;t<r;t++){this._lods[t]._renders.forEach(t=>{e?(t.bounds.cloneTo(this._bounds),e=!1):M.merge(this._bounds,t.bounds,this._bounds)})}this._lodPosition=this._bounds._imp.getCenter();let t=this._bounds.getExtent();this._size=2*Math.max(t.x,t.y,t.z),this._needcaculateBounds=!1,this._notifyChangeLODVisibal()}_notifyChangeLODVisibal(){this._needChangeLODVisibal=!0}_changeLODVisibal(){let e,t=this.owner.scene.cullInfoCamera,r=t.farPlane,a=t.maxlocalYDistance;t.boundFrustum;for(var i=0;i<this._lods.length;i++){let t=this._lods[i];t.minVisibalDistance=0==i?0:e,e=this._size/t.mincullRate/a*r,e*=e,t.maxVisibalDistance=e}}onPreRender(){if(this.recalculateBounds(),this._needChangeLODVisibal&&(this._needChangeLODVisibal=!1,this._changeLODVisibal()),t.LayaEnv.isEditor){let e=this.owner.scene.cullInfoCamera;if(!t.LayaEnv.isPlaying&&!e.isEditorCamera)return;let r=e.maxlocalYDistance,a=e.boundFrustum;t.Vector3.subtract(this._lodPosition,e.transform.position,Ia);let i=Ia.length();if(i>e.farPlane||0==a.containsPoint(this._lodPosition))return;let n=i/e.farPlane*r,s=this._size/n;this._nowRate=s}}}class Pa{constructor(){this.startPosition=new t.Vector3,this.endPosition=new t.Vector3,this.startColor=new t.Color,this.endColor=new t.Color,this.startNormal=new t.Vector3,this.endNormal=new t.Vector3}cloneTo(e){this.startPosition.cloneTo(e.startPosition),this.endPosition.cloneTo(e.endPosition),this.startColor.cloneTo(e.startColor),this.endColor.cloneTo(e.endColor),this.startNormal.cloneTo(e.startNormal),this.endNormal.cloneTo(e.endNormal)}}class La extends Ce{constructor(e,r){super(t.MeshTopology.Lines,t.DrawType.DrawArray),this._floatCountPerVertices=10,this._minUpdate=Number.MAX_VALUE,this._maxUpdate=Number.MIN_VALUE,this._floatBound=new Float32Array(6),this._calculateBound=!0,this._maxLineCount=0,this._lineCount=0;var a=2*r;this._ownerRender=e,this._maxLineCount=r,this._vertices=new Float32Array(a*this._floatCountPerVertices),this._vertexBuffer=T.renderOBJCreate.createVertexBuffer3D(K.vertexDeclaration.vertexStride*a,t.BufferUsage.Static,!1),this._vertexBuffer.vertexDeclaration=K.vertexDeclaration;var i=new t.BufferState;this.bufferState=i,this.bufferState.applyState([this._vertexBuffer],null);var n=Fa,s=Na;n.setValue(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),s.setValue(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),this._bounds=new M(n,s)}_getType(){return La._type}_resizeLineData(e){var r=2*e,a=this._vertices;this._vertexBuffer.destroy(),this._maxLineCount=e;var i=r*this._floatCountPerVertices;this._vertices=new Float32Array(i),this._vertexBuffer=T.renderOBJCreate.createVertexBuffer3D(K.vertexDeclaration.vertexStride*r,t.BufferUsage.Static,!1),this._vertexBuffer.vertexDeclaration=K.vertexDeclaration,i<a.length?(this._vertices.set(new Float32Array(a.buffer,0,i)),this._vertexBuffer.setData(this._vertices.buffer,0,0,4*i)):(this._vertices.set(a),this._vertexBuffer.setData(this._vertices.buffer,0,0,4*a.length)),this.bufferState.applyState([this._vertexBuffer],null),this._minUpdate=Number.MAX_VALUE,this._maxUpdate=Number.MIN_VALUE,this._calculateBound=!0,this._ownerRender.boundsChange=!0}_updateLineVertices(e,r,a,i,n,s=null,o=null){r&&(this._vertices[e+0]=r.x,this._vertices[e+1]=r.y,this._vertices[e+2]=r.z),i&&(this._vertices[e+3]=i.r,this._vertices[e+4]=i.g,this._vertices[e+5]=i.b,this._vertices[e+6]=i.a),s&&(this._vertices[e+7]=s.x,this._vertices[e+8]=s.y,this._vertices[e+9]=s.z),a&&(this._vertices[e+10]=a.x,this._vertices[e+11]=a.y,this._vertices[e+12]=a.z),n&&(this._vertices[e+13]=n.r,this._vertices[e+14]=n.g,this._vertices[e+15]=n.b,this._vertices[e+16]=n.a),o&&(this._vertices[e+17]=o.x,this._vertices[e+18]=o.y,this._vertices[e+19]=o.z),this._minUpdate=Math.min(this._minUpdate,e),this._maxUpdate=Math.max(this._maxUpdate,e+2*this._floatCountPerVertices);var l=this._bounds,h=this._floatBound,d=l.getMin(),c=l.getMax();t.Vector3.min(d,r,d),t.Vector3.min(d,a,d),t.Vector3.max(c,r,c),t.Vector3.max(c,a,c),l.setMin(d),l.setMax(c),h[0]=d.x,h[1]=d.y,h[2]=d.z,h[3]=c.x,h[4]=c.y,h[5]=c.z,this._ownerRender.boundsChange=!0}_reCalculateBound(){if(this._calculateBound){var e=this._vertices,t=Fa,r=Na;t.setValue(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),r.setValue(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);for(var a=0;a<2*this._lineCount;++a){var i=this._floatCountPerVertices*a,n=e[i+0],s=e[i+1],o=e[i+2];t.x=Math.min(n,t.x),t.y=Math.min(s,t.y),t.z=Math.min(o,t.z),r.x=Math.max(n,r.x),r.y=Math.max(s,r.y),r.z=Math.max(o,r.z)}this._bounds.setMin(t),this._bounds.setMax(r);var l=this._floatBound;l[0]=t.x,l[1]=t.y,l[2]=t.z,l[3]=r.x,l[4]=r.y,l[5]=r.z,this._calculateBound=!1}}_removeLineData(e){var t=2*this._floatCountPerVertices,r=e+1,a=e*t,i=this._vertices,n=new Float32Array(i.buffer,r*t*4,(this._lineCount-r)*t);i.set(n,a),this._minUpdate=Math.min(this._minUpdate,a),this._maxUpdate=Math.max(this._maxUpdate,a+n.length),this._lineCount--;var s=this._floatBound,o=i[a],l=i[a+1],h=i[a+2],d=i[a+7],c=i[a+8],u=i[a+9],_=s[0],f=s[1],m=s[2],g=s[3],p=s[4],S=s[5];o!==_&&o!==g&&l!==f&&l!==p&&h!==m&&h!==S&&d!==_&&d!==g&&c!==f&&c!==p&&u!==m&&u!==S||(this._calculateBound=!0)}_updateLineData(e,t,r,a,i,n=null,s=null){var o=2*this._floatCountPerVertices;this._updateLineVertices(e*o,t,r,a,i,n,s),this._calculateBound=!0}_updateLineDatas(e,t){for(var r=2*this._floatCountPerVertices,a=t.length,i=0;i<a;i++){var n=t[i];this._updateLineVertices((e+i)*r,n.startPosition,n.endPosition,n.startColor,n.endColor,n.startNormal,n.endNormal)}this._calculateBound=t.length>0}_getLineData(e,t){var r=t.startPosition,a=t.startColor,i=t.endPosition,n=t.endColor,s=t.startNormal,o=t.endNormal,l=this._vertices,h=e*this._floatCountPerVertices*2;r.x=l[h+0],r.y=l[h+1],r.z=l[h+2],a.r=l[h+3],a.g=l[h+4],a.b=l[h+5],a.a=l[h+6],s.x=l[h+7],s.y=l[h+8],s.z=l[h+9],i.x=l[h+10],i.y=l[h+11],i.z=l[h+12],n.r=l[h+13],n.g=l[h+14],n.b=l[h+15],n.a=l[h+16],o.x=l[h+17],o.y=l[h+18],o.z=l[h+19]}_prepareRender(e){return!0}_updateRenderParams(e){this.clearRenderParams(),this._minUpdate!==Number.MAX_VALUE&&this._maxUpdate!==Number.MIN_VALUE&&(this._vertexBuffer.setData(this._vertices.buffer,4*this._minUpdate,4*this._minUpdate,4*(this._maxUpdate-this._minUpdate)),this._minUpdate=Number.MAX_VALUE,this._maxUpdate=Number.MIN_VALUE),this._lineCount>0&&this.setDrawArrayParams(0,2*this._lineCount)}destroy(){this._destroyed||(super.destroy(),this.bufferState.destroy(),this._vertexBuffer.destroy(),this._bufferState=null,this._vertexBuffer=null,this._vertices=null)}}La._type=Ce._typeCounter++;const Fa=new t.Vector3,Na=new t.Vector3;class Oa extends z{constructor(){super(),this._isRenderActive=!1,this._isInRenders=!1,this._needUpdatelines=!1,this._lines=[],this._projectionViewWorldMatrix=new t.Matrix4x4,this._pixelLineFilter=new La(this,20),this._baseRenderNode.shaderData.addDefine(A.SHADERDEFINE_COLOR),this.geometryBounds=this._pixelLineFilter._bounds}get bounds(){return this._pixelLineFilter._reCalculateBound(),super.bounds}get pixelLinesDatas(){return this._needUpdatelines&&this._updateLineDatas(),this._lines}set pixelLinesDatas(e){this.clear(),e.length>this._pixelLineFilter._maxLineCount&&(e=e.slice(0,this._pixelLineFilter._maxLineCount),console.warn("reach max line count")),this.addLines(e)}get maxLineCount(){return this._pixelLineFilter._maxLineCount}set maxLineCount(e){this._pixelLineFilter._resizeLineData(e),this._pixelLineFilter._lineCount=Math.min(this._pixelLineFilter._lineCount,e),this._needUpdatelines=!0}get lineCount(){return this._pixelLineFilter._lineCount}_onAdded(){super._onAdded(),this._changeRenderObjects(0,Xr.defaultMaterial)}_onEnable(){super._onEnable(),this._isRenderActive=!0,0!=this._pixelLineFilter._lineCount&&(this.owner.scene._addRenderObject(this),this._isInRenders=!0),this._setBelongScene(this.owner.scene)}_onDisable(){this._pixelLineFilter&&0!=this._pixelLineFilter._lineCount&&this._isRenderActive&&(this.owner.scene._removeRenderObject(this),this._isInRenders=!1),this._isRenderActive=!1,this._setUnBelongScene()}_createBaseRenderNode(){return T.Render3DModuleDataFactory.createMeshRenderNode()}_isMaterialVaild(e){return e.checkType(t.ShaderFeatureType.D3)}_onWorldMatNeedChange(e){super._onWorldMatNeedChange(e),this._baseRenderNode.ismoved.setValue(t.Stat.loopCount,t.LayaGL.renderEngine._framePassCount),this._baseRenderNode.ismoved=this._baseRenderNode.ismoved}renderUpdate(e){this._renderElements.forEach((t,r)=>{var a,i;t._renderElementOBJ.isRender=t._geometry._prepareRender(e),t._geometry._updateRenderParams(e);let n=null!==(a=this.sharedMaterial)&&void 0!==a?a:Xr.defaultMaterial;n=null!==(i=this.sharedMaterials[r])&&void 0!==i?i:n,t.material=n,t._renderElementOBJ.materialRenderQueue=n.renderQueue})}_changeRenderObjects(e,t){var r=this._renderElements;t||(t=Xr.defaultMaterial);var a=r[e];a||(a=r[e]=new W),a.setTransform(this.owner._transform),a.setGeometry(this._pixelLineFilter),a.render=this,a.material=t,this._setRenderElements()}_pixelLinesDataChange(e){if(null!=e){let t=parseInt(e),r=this._lines[t];r&&this.setLine(t,r.startPosition,r.endPosition,r.startColor,r.endColor)}}addLine(e,t,r,a){if(this._pixelLineFilter._lineCount===this._pixelLineFilter._maxLineCount)throw new Error("reach max line count");this._pixelLineFilter._updateLineData(this._pixelLineFilter._lineCount++,e,t,r,a),this._isRenderActive&&!this._isInRenders&&this._pixelLineFilter._lineCount>0&&(this.owner.scene&&this.owner.scene._addRenderObject(this),this._isInRenders=!0),this._needUpdatelines=!0}addLineWithNormal(e,t,r,a,i,n){if(this._pixelLineFilter._lineCount===this._pixelLineFilter._maxLineCount)throw new Error("reach max line count");this._pixelLineFilter._updateLineData(this._pixelLineFilter._lineCount++,e,t,r,a,i,n),this._isRenderActive&&!this._isInRenders&&this._pixelLineFilter._lineCount>0&&(this.owner.scene&&this.owner.scene._addRenderObject(this),this._isInRenders=!0),this._needUpdatelines=!0}addLines(e){var t=this._pixelLineFilter._lineCount,r=e.length;if(t+r>this._pixelLineFilter._maxLineCount)throw new Error("reach max line count");this._pixelLineFilter._updateLineDatas(t,e),this._pixelLineFilter._lineCount+=r,this.boundsChange=!0,this._isRenderActive&&!this._isInRenders&&this._pixelLineFilter._lineCount>0&&(this.owner.scene&&this.owner.scene._addRenderObject(this),this._isInRenders=!0),this._needUpdatelines=!0}removeLine(e){if(!(e<this._pixelLineFilter._lineCount))throw new t.OutOfRangeError(e);this._pixelLineFilter._removeLineData(e),this._isRenderActive&&this._isInRenders&&0==this._pixelLineFilter._lineCount&&(this.owner.scene&&this.owner.scene._removeRenderObject(this),this._isInRenders=!1),this._needUpdatelines=!0}setLine(e,r,a,i,n){if(!(e<this._pixelLineFilter._lineCount))throw new t.OutOfRangeError(e);{this._pixelLineFilter._updateLineData(e,r,a,i,n);let t=this._lines[e];t&&(i.cloneTo(t.startColor),n.cloneTo(t.endColor),r.cloneTo(t.startPosition),a.cloneTo(t.endPosition))}}setLineWithNormal(e,r,a,i,n,s,o){if(!(e<this._pixelLineFilter._lineCount))throw new t.OutOfRangeError(e);{this._pixelLineFilter._updateLineData(e,r,a,i,n,s,o);let t=this._lines[e];t&&(i.cloneTo(t.startColor),n.cloneTo(t.endColor),r.cloneTo(t.startPosition),a.cloneTo(t.endPosition),s&&s.cloneTo(t.startNormal),o&&o.cloneTo(t.endNormal))}}getLine(e,r){if(!(e<this.lineCount))throw new t.OutOfRangeError(e);this._pixelLineFilter._getLineData(e,r)}_updateLineDatas(){let e=this.lineCount;this._lines=[];for(let t=0;t<e;t++){let e=new Pa;this.getLine(t,e),this._lines.push(e)}this._needUpdatelines=!1}clear(){this._pixelLineFilter._lineCount=0,this._lines=[],this._needUpdatelines=!1,this._isRenderActive&&this._isInRenders&&(this.owner.scene&&this.owner.scene._removeRenderObject(this),this._isInRenders=!1)}_onDestroy(){this._pixelLineFilter.destroy(),this._pixelLineFilter=null,super._onDestroy()}_cloneTo(e){super._cloneTo(e),e.maxLineCount=this.maxLineCount;const t=this.lineCount;let r=new Pa;for(let a=0,i=t;a<i;a++)this.getLine(a,r),e.addLine(r.startPosition,r.endPosition,r.startColor,r.endColor)}}class ba{get currentState(){return this._currentState}set currentState(e){this._currentState=e,this._currentState.curTransition=null}get normalizedTime(){return this._normalizedTime}get duration(){return this._duration}get animatorState(){return this._currentState}constructor(){this._currentState=null}_resetPlayState(e,t){this._finish=!1,this._playEventIndex=0,this._startPlayTime=e,this._elapsedTime=e,this._lastIsFront=!0,this._parentPlayTime=null,this._normalizedTime=this._elapsedTime/t;var r=this._normalizedTime%1;this._normalizedPlayTime=r<0?r+1:r}_cloneTo(e){e._finish=this._finish,e._startPlayTime=this._startPlayTime,e._playEventIndex=this._playEventIndex,e._elapsedTime=this._elapsedTime,e._normalizedTime=this._normalizedTime,e._normalizedPlayTime=this._normalizedPlayTime,e._lastIsFront=this._lastIsFront}}class Va{get defaultState(){return this._defaultState}set defaultState(e){this._defaultState=e}get avatarMask(){return this._avatarMask}set avatarMask(e){var t;this._avatarMask=e,null===(t=this._animator)||void 0===t||t._refreshLayerAvatarMask(this)}get defaultStateName(){return this._defaultState?this._defaultState.name:null}set defaultStateName(e){if(this._defaultState=this.getAnimatorState(e),null==this._defaultState)if(0==this._states.length)this._defaultStateNameCatch=e;else for(var t=this._states.length-1;t>=0;t--)if(this._states[t].name==e){this._defaultState=this._states[t];break}}get states(){return this._states}set states(e){if(this._states!==e){if(this._states.length>0){let t=this._states.filter(t=>-1==e.indexOf(t));for(let e of t)this.removeState(e)}if(e.length>0){let t=e.filter(e=>-1==this._states.indexOf(e));for(let e of t)this.addState(e)}this._states.length=0,this._states.push(...e)}}constructor(e){this._referenceCount=0,this._playType=-1,this._crossDuration=-1,this._crossMark=0,this._crossNodesOwnersCount=0,this._crossNodesOwners=[],this._crossNodesOwnersIndicesMap={},this._srcCrossClipNodeIndices=[],this._destCrossClipNodeIndices=[],this._states=[],this._playStateInfo=new ba,this._crossPlayStateInfo=new ba,this.blendingMode=Va.BLENDINGMODE_OVERRIDE,this.defaultWeight=1,this.playOnWake=!0,this.enable=!0,this.name=e}_removeClip(e,t,r){var a=r._clip,i=e[t];if(e.splice(t,1),this._animator){var n=a._nodes,s=i._nodeOwners;a._removeReference();for(var o=0,l=n.count;o<l;o++)this._animator._removeKeyframeNodeOwner(s,n.getNodeByIndex(o))}}_getReferenceCount(){return this._referenceCount}_addReference(e=1){for(var t=0,r=this._states.length;t<r;t++)this._states[t]._addReference(e);this._referenceCount+=e}_removeReference(e=1){for(var t=0,r=this._states.length;t<r;t++)this._states[t]._removeReference(e);this._referenceCount-=e}_clearReference(){this._removeReference(-this._referenceCount)}getCurrentPlayState(){return this._playStateInfo}getAnimatorState(e){var t;for(let r=0;r<this._states.length;r++)if(this._states[r].name==e){t=this._states[r];break}return t||null}addState(e){var t=e.name;if(this.getAnimatorState(t))throw new Error("AnimatorControllerLayer:this stat's name has exist.");this._states.push(e),t==this._defaultStateNameCatch&&(this._defaultState=e,this._defaultStateNameCatch=null),this._animator&&(e._clip&&e._clip._addReference(),this._animator._getOwnersByClip(e))}removeState(e){for(var t=this._states,r=-1,a=0,i=t.length;a<i;a++)if(t[a]===e){r=a;break}-1!==r&&this._removeClip(t,r,e)}destroy(){this._clearReference(),this._states=[],this._playStateInfo=null,this._crossPlayStateInfo=null,this._defaultState=null}cloneTo(e){e.name=this.name,e.blendingMode=this.blendingMode,e.defaultWeight=this.defaultWeight,e.playOnWake=this.playOnWake,this.avatarMask&&(e.avatarMask=this._avatarMask.clone())}clone(){var e=new Va(this.name);return this.cloneTo(e),e}}var Ua;Va.BLENDINGMODE_OVERRIDE=0,Va.BLENDINGMODE_ADDTIVE=1,e.LayerTaskType=void 0,(Ua=e.LayerTaskType||(e.LayerTaskType={}))[Ua.Idle=0]="Idle",Ua[Ua.Normal=1]="Normal",Ua[Ua.Cross=2]="Cross",Ua[Ua.FixedCross=3]="FixedCross";class Ha{constructor(){this.type=e.LayerTaskType.Idle,this.state=null,this.destState=null,this.weight=1,this.playState=null,this.crossPlayState=null,this.crossWeight=0}}class Ga{constructor(e,t,r){this._updateMark=0,this._layers=[],this._activeLayerCount=0,this._inActive=!1,this._inDirty=!1,this._slotHandle=0,this._onResize=null,this._ctx=e,this._activeList=t,this._dirtyList=r}resizeLayers(t){const r=this._layers,a=r.length;if(a!==t){if(a<t)for(let e=a;e<t;e++)r.push(new Ha);else{for(let i=t;i<a;i++)r[i].type!==e.LayerTaskType.Idle&&this._activeLayerCount--;r.length=t,this._syncListMembership(this._activeLayerCount>0)}this._onResize&&this._onResize(t)}}submitAllIdle(){const t=this._layers;let r=!1;for(let a=0,i=t.length;a<i;a++){const i=t[a];i.type!==e.LayerTaskType.Idle&&(i.type=e.LayerTaskType.Idle,i.state=null,i.destState=null,i.playState=null,i.crossPlayState=null,i.weight=1,i.crossWeight=0,r=!0)}r&&this._markDirty(),this._activeLayerCount=0,this._syncListMembership(!1)}submitLayerIdle(t){const r=this._layers[t];if(!r)return;r.type!==e.LayerTaskType.Idle&&(this._markDirty(),this._activeLayerCount--),r.type=e.LayerTaskType.Idle,r.state=null,r.destState=null,r.playState=null,r.crossPlayState=null,r.weight=1,r.crossWeight=0,this._syncListMembership(this._activeLayerCount>0)}submitLayerNormal(t,r,a,i){const n=this._layers[t];if(!n)return;const s=n.type===e.LayerTaskType.Idle;let o=!1;n.type!==e.LayerTaskType.Normal&&(n.type=e.LayerTaskType.Normal,o=!0),n.state!==r&&(n.state=r,o=!0),null!==n.destState&&(n.destState=null,o=!0),n.weight!==i&&(n.weight=i,o=!0),n.playState=a,n.crossPlayState=null,n.crossWeight=0,s&&this._activeLayerCount++,o&&this._markDirty(),this._syncListMembership(!0)}submitLayerCross(t,r,a,i,n,s){const o=this._layers[t];if(!o)return;const l=o.type===e.LayerTaskType.Idle;let h=!1;o.type!==e.LayerTaskType.Cross&&(o.type=e.LayerTaskType.Cross,h=!0),o.state!==r&&(o.state=r,h=!0),o.destState!==i&&(o.destState=i,h=!0),o.playState=a,o.crossPlayState=n,o.crossWeight=s,l&&this._activeLayerCount++,h&&this._markDirty(),this._syncListMembership(!0)}submitLayerFixedCross(t,r,a,i){const n=this._layers[t];if(!n)return;const s=n.type===e.LayerTaskType.Idle;let o=!1;n.type!==e.LayerTaskType.FixedCross&&(n.type=e.LayerTaskType.FixedCross,o=!0),null!==n.state&&(n.state=null,o=!0),n.destState!==r&&(n.destState=r,o=!0),n.playState=null,n.crossPlayState=a,n.crossWeight=i,s&&this._activeLayerCount++,o&&this._markDirty(),this._syncListMembership(!0)}_clearDirty(){this._inDirty=!1}_markDirty(){this._inDirty||(this._dirtyList.add(this),this._inDirty=!0)}_syncListMembership(e){e&&!this._inActive?(this._activeList.add(this),this._inActive=!0):!e&&this._inActive&&(this._activeList.remove(this),this._inActive=!1)}}class ka{constructor(){this._scope="all"}evaluateLayer(t,r){const a="non-transform-only"===this._scope;switch(t.type){case e.LayerTaskType.Normal:this._sample(t.state,t.playState,r,a);break;case e.LayerTaskType.Cross:this._sample(t.state,t.playState,r,a),this._sample(t.destState,t.crossPlayState,r,a);break;case e.LayerTaskType.FixedCross:this._sample(t.destState,t.crossPlayState,r,a)}}_sample(e,t,r,a){const i=e._clip,n=i._duration,s=e.clipStart*n+t._normalizedPlayTime*t._duration,o=r.blendingMode!==Va.BLENDINGMODE_OVERRIDE,l=t._elapsedTime>t._lastElapsedTime;i._evaluateClipDatasRealTime(i._nodes,s,e._currentFrameIndices,o,l,e._realtimeDatas,r.avatarMask,a)}}function za(t){return t===e.KeyFrameValueType.Position||t===e.KeyFrameValueType.Rotation||t===e.KeyFrameValueType.Scale||t===e.KeyFrameValueType.RotationEuler}const Wa=new t.Vector3,Qa=new t.Color,Ya=new t.Quaternion;class Xa{constructor(){this._scope="all",this._currentUpdateMark=0,this._applyIndicesCache=new WeakMap,this._crossApplyIndicesCache=new WeakMap}_getApplyIndices(e){let t=this._applyIndicesCache.get(e);if(t)return t;const r=[],a=[];let i=0,n=0;const s=e._nodes;if(s){const e=s.count;for(let t=0;t<e;t++)za(s.getNodeByIndex(t).type)?r[i++]=t:a[n++]=t}return t={transform:new Int32Array(r),nonTransform:new Int32Array(a)},this._applyIndicesCache.set(e,t),t}_getScopedIndices(e,t){if("all"===t)return null;const r=this._getApplyIndices(e);return"transform-only"===t?r.transform:r.nonTransform}_getCrossScopedIndices(e,t){if("all"===t)return null;const r=e._crossNodesOwnersCount;let a=this._crossApplyIndicesCache.get(e);if(!a||a.crossMark!==e._crossMark||a.ownerCount!==r){const t=[],i=[];let n=0,s=0;const o=e._crossNodesOwners;for(let e=0;e<r;e++){const r=o[e];r&&za(r.type)?t[n++]=e:i[s++]=e}a={crossMark:e._crossMark,ownerCount:r,transform:new Int32Array(t),nonTransform:new Int32Array(i)},this._crossApplyIndicesCache.set(e,a)}return"transform-only"===t?a.transform:a.nonTransform}applyNormal(e,t,r,a,i=this._scope){this._applyNormal(t,e.state,t.blendingMode!==Va.BLENDINGMODE_OVERRIDE,e.weight,r,a,i)}applyCross(e,t,r,a,i=this._scope){this._applyCross(t,e.state,e.destState,e.crossWeight,r,a,i)}applyFixedCross(e,t,r,a,i=this._scope){this._applyFixedCross(t,e.destState,e.crossWeight,r,a,i)}updateDefaultValues(t){for(let n=0,s=t.length;n<s;n++){const s=t[n];if(!s||!s.propertyOwner||!s.property)continue;const o=za(s.type);if("transform-only"===this._scope?!o:"non-transform-only"===this._scope&&o)continue;let l=s.propertyOwner;switch(s.type){case e.KeyFrameValueType.Float:case e.KeyFrameValueType.Boolean:for(var r=s.property,a=r.length-1,i=0;i<a&&(l=l[r[i]],l);i++);l&&!s.isMaterial&&(s.defaultValue=l[r[a]]);break;case e.KeyFrameValueType.Position:l.localPosition&&s.defaultValue&&l.localPosition.cloneTo(s.defaultValue);break;case e.KeyFrameValueType.Rotation:l.localRotation&&s.defaultValue&&l.localRotation.cloneTo(s.defaultValue);break;case e.KeyFrameValueType.Scale:l.localScale&&s.defaultValue&&l.localScale.cloneTo(s.defaultValue);break;case e.KeyFrameValueType.RotationEuler:l.localRotationEuler&&s.defaultValue&&l.localRotationEuler.cloneTo(s.defaultValue);break;case e.KeyFrameValueType.Vector2:case e.KeyFrameValueType.Vector3:case e.KeyFrameValueType.Vector4:case e.KeyFrameValueType.Color:for(a=(r=s.property).length-1,i=0;i<a&&(l=l[r[i]],l);i++);if(l&&!s.isMaterial&&s.defaultValue){let e=l[r[a]];e&&e.cloneTo&&e.cloneTo(s.defaultValue)}}}}revertDefaultKeyframeNodes(t){const r=t._nodeOwners,a=t._clip,i=a?this._getScopedIndices(a,this._scope):null,n=null!==i?i.length:r.length;for(let t=0;t<n;t++){const a=r[null!==i?i[t]:t];if(!a)continue;if(null===i&&"all"!==this._scope){const e=za(a.type);if("transform-only"===this._scope?!e:e)continue}let n,m=a.propertyOwner;if(m)switch(a.type){case e.KeyFrameValueType.PathPoint:case e.KeyFrameValueType.Boolean:break;case e.KeyFrameValueType.Float:for(var s=a.property,o=s.length-1,l=0;l<o&&(m=m[s[l]],m);l++);let t=s[o];a.isMaterial?m&&m.setFloat(t,a.defaultValue):(m&&(m[t]=a.defaultValue),a.callbackFun&&a.animatorDataSetCallBack());break;case e.KeyFrameValueType.Position:var h=m.localPosition,d=a.defaultValue;h.x=d.x,h.y=d.y,h.z=d.z,m.localPosition=h;break;case e.KeyFrameValueType.Rotation:var c=m.localRotation,u=a.defaultValue;c.x=u.x,c.y=u.y,c.z=u.z,c.w=u.w,m.localRotation=c;break;case e.KeyFrameValueType.Scale:var _=m.localScale;d=a.defaultValue,_.x=d.x,_.y=d.y,_.z=d.z,m.localScale=_;break;case e.KeyFrameValueType.RotationEuler:var f=m.localRotationEuler;d=a.defaultValue,f.x=d.x,f.y=d.y,f.z=d.z,m.localRotationEuler=f;break;case e.KeyFrameValueType.Vector2:for(o=(s=a.property).length-1,l=0;l<o&&(m=m[s[l]],m);l++);n=s[o],a.isMaterial?m&&m.getVector2(n)&&m.setVector2(n,a.defaultValue):(m&&(m[n]=a.defaultValue),a.callbackFun&&a.animatorDataSetCallBack());break;case e.KeyFrameValueType.Vector3:for(o=(s=a.property).length-1,l=0;l<o&&(m=m[s[l]],m);l++);n=s[o],a.isMaterial?m&&m.getVector3(n)&&m.setVector3(n,a.defaultValue):(m&&(m[n]=a.defaultValue),a.callbackFun&&a.animatorDataSetCallBack());break;case e.KeyFrameValueType.Vector4:for(o=(s=a.property).length-1,l=0;l<o&&(m=m[s[l]],m);l++);n=s[o],a.isMaterial?m&&m.getVector3(n)&&m.setVector3(n,a.defaultValue):(m&&(m[n]=a.defaultValue),a.callbackFun&&a.animatorDataSetCallBack());break;case e.KeyFrameValueType.Color:for(o=(s=a.property).length-1,l=0;l<o&&(m=m[s[l]],m);l++);if(n=s[o],!a.defaultValue)break;Qa.r=a.defaultValue.x,Qa.g=a.defaultValue.y,Qa.b=a.defaultValue.z,Qa.a=a.defaultValue.w,a.isMaterial?m&&m.getColor(n)&&m.setColor(n,Qa):(m&&(m[n]=Qa),a.callbackFun&&a.animatorDataSetCallBack());break;default:throw"Animator:unknown type."}}}_applyNormal(t,r,a,i,n,s,o){this._currentUpdateMark=s;const l=r._realtimeDatas,h=r._clip,d=h._nodes,c=r._nodeOwners,u=this._getScopedIndices(h,o),_=null!==u?u.length:d.count;for(let r=0;r<_;r++){const s=null!==u?u[r]:r,o=c[s];if(!o)continue;const h=d.getNodeByIndex(s);if(t.avatarMask&&!t.avatarMask.getTransformActive(h.nodePath))continue;let _,f=o.propertyOwner;if(f){switch(o.type){case e.KeyFrameValueType.PathPoint:const t=l[s],r=t.pos,h=t.rotation;if(h){const e=f.transform.localRotationEuler;e.x=h.x,e.y=h.y,e.z=h.z,f.transform.localRotationEuler=e}const d=f.transform.position;d.x=r.x,d.y=r.y,d.z=r.z,f.transform.position=d;break;case e.KeyFrameValueType.Boolean:{const e=o.property,t=e.length-1;for(let r=0;r<t&&(f=f[e[r]],f);r++);const r=e[t];o.isMaterial||f&&(f[r]=l[s]);break}case e.KeyFrameValueType.Float:{const e=o.property,t=e.length-1;for(let r=0;r<t&&(f=f[e[r]],f);r++);const r=e[t];o.isMaterial?f&&f.setFloat(r,this._applyFloat(0,o,a,i,n,l[s])):(f&&(f[r]=this._applyFloat(f[r],o,a,i,n,l[s])),o.callbackFun&&o.animatorDataSetCallBack());break}case e.KeyFrameValueType.Position:{const e=f.localPosition;this._applyPositionAndRotationEuler(o,a,i,n,l[s],e),f.localPosition=e;break}case e.KeyFrameValueType.Rotation:{const e=f.localRotation;this._applyRotation(o,a,i,n,l[s],e),f.localRotation=e;break}case e.KeyFrameValueType.Scale:{const e=f.localScale;this._applyScale(o,a,i,n,l[s],e),f.localScale=e;break}case e.KeyFrameValueType.RotationEuler:{const e=f.localRotationEuler;this._applyPositionAndRotationEuler(o,a,i,n,l[s],e),f.localRotationEuler=e;break}case e.KeyFrameValueType.Vector2:{const e=o.property,t=e.length-1;for(let r=0;r<t&&(f=f[e[r]],f);r++);_=e[t],o.isMaterial?f&&f.getVector2(_)&&f.setVector2(_,this._applyVec2(f.getVector2(_),o,a,i,n,l[s])):(f&&(f[_]=this._applyVec2(f[_],o,a,i,n,l[s])),o.callbackFun&&o.animatorDataSetCallBack());break}case e.KeyFrameValueType.Vector3:{const e=o.property,t=e.length-1;for(let r=0;r<t&&(f=f[e[r]],f);r++);_=e[t],o.isMaterial?f&&f.getVector3(_)&&f.setVector3(_,this._applyVec3(f.getVector3(_),o,a,i,n,l[s])):(f&&(f[_]=this._applyVec3(f[_],o,a,i,n,l[s])),o.callbackFun&&o.animatorDataSetCallBack());break}case e.KeyFrameValueType.Vector4:{const e=o.property,t=e.length-1;for(let r=0;r<t&&(f=f[e[r]],f);r++);_=e[t],o.isMaterial?f&&f.getVector4(_)&&f.setVector4(_,this._applyVec4(f.getVector4(_),o,a,i,n,l[s])):(f&&(f[_]=this._applyVec4(f[_],o,a,i,n,l[s])),o.callbackFun&&o.animatorDataSetCallBack());break}case e.KeyFrameValueType.Color:{const e=o.property,t=e.length-1;for(let r=0;r<t&&(f=f[e[r]],f);r++);if(_=e[t],o.isMaterial){const e=f.getColor(_);f&&e&&(Qa.r=e.r,Qa.g=e.g,Qa.b=e.b,Qa.a=e.a,f.setColor(_,this._applyColor(Qa,o,a,i,n,l[s])))}else f&&(f[_]=this._applyColor(f[_],o,a,i,n,l[s])),o.callbackFun&&o.animatorDataSetCallBack();break}}o.updateMark=this._currentUpdateMark}}}_applyCross(e,t,r,a,i,n,s){var o,l;this._currentUpdateMark=n;const h=e._crossNodesOwners,d=e._crossNodesOwnersCount,c=e.blendingMode!==Va.BLENDINGMODE_OVERRIDE,u=e.defaultWeight,_=r._realtimeDatas,f=e._destCrossClipNodeIndices,m=t._realtimeDatas,g=e._srcCrossClipNodeIndices,p=this._getCrossScopedIndices(e,s),S=null!==p?p.length:d;for(let t=0;t<S;t++){const r=null!==p?p[t]:t,n=h[r];if(!n)continue;const s=g[r],d=f[r];if(-1==s&&-1==d)continue;const S=-1!==s&&null!==(o=m[s])&&void 0!==o?o:n.defaultValue,T=-1!==d&&null!==(l=_[d])&&void 0!==l?l:n.defaultValue;null!=S&&null!=T&&(e.avatarMask&&!e.avatarMask.getTransformActive(n.nodePath)||this._applyCrossData(n,c,u,i,S,T,a))}}_applyFixedCross(e,t,r,a,i,n){var s;this._currentUpdateMark=i;const o=e._crossNodesOwners,l=e._crossNodesOwnersCount,h=e.blendingMode!==Va.BLENDINGMODE_OVERRIDE,d=e.defaultWeight,c=t._realtimeDatas,u=e._destCrossClipNodeIndices,_=this._getCrossScopedIndices(e,n),f=null!==_?_.length:l;for(let e=0;e<f;e++){const t=null!==_?_[e]:e,i=o[t];if(!i)continue;const n=u[t],l=i.crossFixedValue,f=-1!==n&&null!==(s=c[n])&&void 0!==s?s:i.defaultValue;null!=l&&null!=f&&this._applyCrossData(i,h,d,a,l,f,r)}}_applyFloat(e,t,r,a,i,n){if(t.updateMark===this._currentUpdateMark)if(r)e+=a*n;else{e=e+a*(n-e)}else if(i)e=r?t.defaultValue+n:n;else if(r)e=t.defaultValue+a*n;else{var s=t.defaultValue;e=s+a*(n-s)}return e}_applyVec2(e,t,r,a,i,n){if(!e)return null;if(t.updateMark===this._currentUpdateMark)if(r)e.x+=a*n.x,e.y+=a*n.y;else{var s=e;e.x=s.x+a*(n.x-s.x),e.y=s.y+a*(n.y-s.y)}else if(i)r?(e.x=t.defaultValue.x+n.x,e.y=t.defaultValue.y+n.y):n.cloneTo(e);else if(r)e.x=t.defaultValue.x+a*n.x,e.y=t.defaultValue.y+a*n.y;else{var o=t.defaultValue;e.x=o.x+a*(n.x-o.x),e.y=o.y+a*(n.y-o.y)}return e}_applyVec3(e,t,r,a,i,n){if(!e)return null;if(t.updateMark===this._currentUpdateMark)if(r)e.x+=a*n.x,e.y+=a*n.y,e.z+=a*n.z;else{var s=e;e.x=s.x+a*(n.x-s.x),e.y=s.y+a*(n.y-s.y),e.z=s.z+a*(n.z-s.z)}else if(i)r?(e.x=t.defaultValue.x+n.x,e.y=t.defaultValue.y+n.y,e.z=t.defaultValue.z+n.z):n.cloneTo(e);else if(r)e.x=t.defaultValue.x+a*n.x,e.y=t.defaultValue.y+a*n.y,e.z=t.defaultValue.z+a*n.z;else{var o=t.defaultValue;e.x=o.x+a*(n.x-o.x),e.y=o.y+a*(n.y-o.y),e.z=o.z+a*(n.z-o.z)}return e}_applyVec4(e,t,r,a,i,n){if(!e)return null;if(t.updateMark===this._currentUpdateMark)if(r)e.x+=a*n.x,e.y+=a*n.y,e.z+=a*n.z,e.w+=a*n.w;else{var s=e;e.x=s.x+a*(n.x-s.x),e.y=s.y+a*(n.y-s.y),e.z=s.z+a*(n.z-s.z),e.w=s.w+a*(n.w-s.w)}else if(i)r?(e.x=t.defaultValue.x+n.x,e.y=t.defaultValue.y+n.y,e.z=t.defaultValue.z+n.z,e.w=t.defaultValue.w+n.w):n.cloneTo(e);else if(r)e.x=t.defaultValue.x+a*n.x,e.y=t.defaultValue.y+a*n.y,e.z=t.defaultValue.z+a*n.z,e.w=t.defaultValue.w+a*n.w;else{var o=t.defaultValue;e.x=o.x+a*(n.x-o.x),e.y=o.y+a*(n.y-o.y),e.z=o.z+a*(n.z-o.z),e.w=o.w+a*(n.w-o.w)}return e}_applyColor(e,r,a,i,n,s){if(!e)return null;if(r.defaultValue||(r.defaultValue=new t.Vector4(e.r,e.g,e.b,e.a)),r.updateMark===this._currentUpdateMark)if(a)e.r+=i*s.x,e.g+=i*s.y,e.b+=i*s.z,e.a+=i*s.w;else{var o=e;e.r=o.r+i*(s.x-o.r),e.g=o.g+i*(s.y-o.g),e.b=o.b+i*(s.z-o.b),e.a=o.a+i*(s.w-o.a)}else if(n)a?(e.r=r.defaultValue.x+s.x,e.g=r.defaultValue.y+s.y,e.b=r.defaultValue.z+s.z,e.a=r.defaultValue.w+s.w):e.setValue(s.x,s.y,s.z,s.w);else if(a)e.r=r.defaultValue.x+i*s.x,e.g=r.defaultValue.y+i*s.y,e.b=r.defaultValue.z+i*s.z,e.a=r.defaultValue.w+i*s.w;else{var l=r.defaultValue;e.r=l.x+i*(s.x-l.x),e.g=l.y+i*(s.y-l.y),e.b=l.z+i*(s.z-l.z),e.a=l.w+i*(s.w-l.w)}return e}_applyPositionAndRotationEuler(e,t,r,a,i,n){if(e.updateMark===this._currentUpdateMark)if(t)n.x+=r*i.x,n.y+=r*i.y,n.z+=r*i.z;else{var s=n.x,o=n.y,l=n.z;n.x=s+r*(i.x-s),n.y=o+r*(i.y-o),n.z=l+r*(i.z-l)}else if(a)if(t){var h=e.defaultValue;n.x=h.x+i.x,n.y=h.y+i.y,n.z=h.z+i.z}else n.x=i.x,n.y=i.y,n.z=i.z;else if(h=e.defaultValue,t)n.x=h.x+r*i.x,n.y=h.y+r*i.y,n.z=h.z+r*i.z;else{var d=h.x,c=h.y,u=h.z;n.x=d+r*(i.x-d),n.y=c+r*(i.y-c),n.z=u+r*(i.z-u)}}_applyRotation(e,r,a,i,n,s){if(e.updateMark===this._currentUpdateMark)r?(Z.quaternionWeight(n,a,Ya),Ya.normalize(Ya),t.Quaternion.multiply(s,Ya,s)):t.Quaternion.lerp(s,n,a,s);else if(i)if(r){var o=e.defaultValue;t.Quaternion.multiply(o,n,s)}else s.x=n.x,s.y=n.y,s.z=n.z,s.w=n.w;else o=e.defaultValue,r?(Z.quaternionWeight(n,a,Ya),Ya.normalize(Ya),t.Quaternion.multiply(o,Ya,s)):t.Quaternion.lerp(o,n,a,s)}_applyScale(e,t,r,a,i,n){if(e.updateMark===this._currentUpdateMark)t?(Z.scaleWeight(i,r,Wa),n.x=n.x*Wa.x,n.y=n.y*Wa.y,n.z=n.z*Wa.z):Z.scaleBlend(n,i,r,n);else if(a)if(t){var s=e.defaultValue;n.x=s.x*i.x,n.y=s.y*i.y,n.z=s.z*i.z}else n.x=i.x,n.y=i.y,n.z=i.z;else s=e.defaultValue,t?(Z.scaleWeight(i,r,Wa),n.x=s.x*Wa.x,n.y=s.y*Wa.y,n.z=s.z*Wa.z):Z.scaleBlend(s,i,r,n)}_applyCrossData(r,a,i,n,s,o,l){var h=r.propertyOwner;let d;if(h){switch(r.type){case e.KeyFrameValueType.PathPoint:case e.KeyFrameValueType.Boolean:break;case e.KeyFrameValueType.Float:for(var c=r.property,u=c.length-1,_=0;_<u&&(h=h[c[_]]);_++);var f=s+l*(o-s);r.value=f,d=c[u],r.isMaterial?h&&h.setFloat(d,this._applyFloat(h.getFloat(d),r,a,i,n,f)):h&&(h[d]=this._applyFloat(h[d],r,a,i,n,f)),r.callbackFun&&r.animatorDataSetCallBack();break;case e.KeyFrameValueType.Position:var m=h.localPosition,g=r.value,p=s.x,S=s.y,T=s.z;g.x=p+l*(o.x-p),g.y=S+l*(o.y-S),g.z=T+l*(o.z-T),this._applyPositionAndRotationEuler(r,a,i,n,g,m),h.localPosition=m;break;case e.KeyFrameValueType.Rotation:var A=h.localRotation,E=r.value;t.Quaternion.lerp(s,o,l,E),this._applyRotation(r,a,i,n,E,A),h.localRotation=A;break;case e.KeyFrameValueType.Scale:var D=h.localScale,R=r.value;Z.scaleBlend(s,o,l,R),this._applyScale(r,a,i,n,R,D),h.localScale=D;break;case e.KeyFrameValueType.RotationEuler:var x=h.localRotationEuler,y=r.value;p=s.x,S=s.y,T=s.z,y.x=p+l*(o.x-p),y.y=S+l*(o.y-S),y.z=T+l*(o.z-T),this._applyPositionAndRotationEuler(r,a,i,n,y,x),h.localRotationEuler=x;break;case e.KeyFrameValueType.Color:for(u=(c=r.property).length-1,_=0;_<u&&(h=h[c[_]]);_++);let M=r.value;M.x=s.x+l*(o.x-s.x),M.y=s.y+l*(o.y-s.y),M.z=s.z+l*(o.z-s.z),M.w=s.w+l*(o.w-s.w),r.value=M,d=c[u],r.isMaterial?h&&h.setColor(d,this._applyColor(h.getColor(d),r,a,i,n,M)):h&&(h[d]=this._applyColor(h[d],r,a,i,n,M)),r.callbackFun&&r.animatorDataSetCallBack();break;case e.KeyFrameValueType.Vector2:for(u=(c=r.property).length-1,_=0;_<u&&(h=h[c[_]]);_++);let C=r.value;C.x=s.x+l*(o.x-s.x),C.y=s.y+l*(o.y-s.y),r.value=C,d=c[u],r.isMaterial?h&&h.setVector2(d,this._applyVec2(h.getVector2(d),r,a,i,n,C)):h&&(h[d]=this._applyVec2(h[d],r,a,i,n,C)),r.callbackFun&&r.animatorDataSetCallBack();break;case e.KeyFrameValueType.Vector4:for(u=(c=r.property).length-1,_=0;_<u&&(h=h[c[_]]);_++);let v=r.value;v.x=s.x+l*(o.x-s.x),v.y=s.y+l*(o.y-s.y),v.z=s.z+l*(o.z-s.z),v.w=s.w+l*(o.w-s.w),r.value=v,d=c[u],r.isMaterial?h&&h.setVector4(d,this._applyVec4(h.getVector4(d),r,a,i,n,v)):h&&(h[d]=this._applyVec4(h[d],r,a,i,n,v)),r.callbackFun&&r.animatorDataSetCallBack();break;case e.KeyFrameValueType.Vector3:for(u=(c=r.property).length-1,_=0;_<u&&(h=h[c[_]]);_++);let I=r.value;I.x=s.x+l*(o.x-s.x),I.y=s.y+l*(o.y-s.y),I.z=s.z+l*(o.z-s.z),r.value=I,d=c[u],r.isMaterial?h&&h.setVector3(d,this._applyVec3(h.getVector3(d),r,a,i,n,I)):h&&(h[d]=this._applyVec3(h[d],r,a,i,n,I)),r.callbackFun&&r.animatorDataSetCallBack()}r.updateMark=this._currentUpdateMark}}}class Ka{static getAnimatorResource(e,r){return"simpleSkinnedMeshRenderer"===r?e.getComponent(Wr):e.getComponent(t.ClassUtils.getClass(r))}}function ja(r,a,i,n){const s=i._indexInList,o=i.fullPath,l=r.ownerMap,h=r.owners;let d=l[o],c=!1;if(d)return d.referenceCount++,void(a[s]=d);let u=n;for(let r=0,a=i.propertyCount;r<a;r++){if(c){const a=i.getMaterialPropertyId(r);switch(i.type){case e.KeyFrameValueType.Color:const r=u.shaderData.getColor(a);u=new t.Vector4(r.r,r.g,r.b,r.a);break;case e.KeyFrameValueType.Vector2:u=u.shaderData.getVector2(a);break;case e.KeyFrameValueType.Vector3:u=u.shaderData.getVector3(a);break;case e.KeyFrameValueType.Vector4:u=u.shaderData.getVector(a);break;case e.KeyFrameValueType.Float:u=u.shaderData.getNumber(a);break;case e.KeyFrameValueType.Boolean:u=u.shaderData.getBool(a)}}else u=u[i.getPropertyByIndex(r)];if(u instanceof t.Material&&(c=!0),!u)break}d=l[o]=new la,d.isMaterial=c,d.fullPath=o,d.indexInList=h.length,d.referenceCount=1,d.propertyOwner=n,d.nodePath=i.nodePath,d.callbackFunData=i.callbackFunData,d.callParams=i.callParams,d.getCallbackNode();const _=i.propertyCount,f=[];for(let e=0;e<_;e++)f[e]=i.getPropertyByIndex(e);if(d.property=f,d.type=i.type,u)if(i.type===e.KeyFrameValueType.Float||i.type===e.KeyFrameValueType.Boolean||i.type===e.KeyFrameValueType.PathPoint)d.defaultValue=u;else{const e=new u.constructor;u.cloneTo(e),d.defaultValue=e,d.value=new u.constructor,d.crossFixedValue=new u.constructor}h.push(d),a[s]=d}function Ja(e,t,r){const a=r.fullPath,i=e.ownerMap,n=e.owners,s=i[a];s&&(s.referenceCount--,0===s.referenceCount&&(delete i[a],n.splice(n.indexOf(s),1)),t[r._indexInList]=null)}function qa(e,t){if(!t._clip)return;const r=t._clip._nodes,a=r.count,i=t._nodeOwners;i.length=a;for(let t=0;t<a;t++){const a=r.getNodeByIndex(t);let n=e.sprite;for(let e=0,t=a.ownerPathCount;e<t;e++){const t=a.getOwnerPathByIndex(e);if(""===t)break;if(n=n.getChild(t),!n)break}if(n){const t=a.propertyOwner,r=n;t&&(n=n[t]),n||(n=Ka.getAnimatorResource(r,t)),n&&ja(e,i,a,n)}}}function Za(e,t,r,a){const i=e.layers,n=r.join("/");for(let r=0,s=i.length;r<s;r++){if(!i[r].enable)continue;const s=i[r]._states;for(let r=0,i=s.length;r<i;r++){const i=s[r]._clip._nodesMap[n];if(!i)continue;const o=s[r]._nodeOwners;for(let r=0,n=i.length;r<n;r++)t?ja(e,o,i[r],a):Ja(e,o,i[r])}}}let $a=0;class ei{constructor(){this._stateTransformOwnersCache=new WeakMap,this._nodeOwnersStateMap=new WeakMap,this._buffers=[{frame:0,transforms:new t.FastSinglelist,flags:new t.FastSinglelist}],this._trackStateOwners=!1,this._depth=0}registerState(e){this._trackStateOwners&&(this._nodeOwnersStateMap.set(e._nodeOwners,e),this.rebuildState(e))}rebuildContext(e){if(!this._trackStateOwners)return;const t=e.layers;for(let e=0,r=t.length;e<r;e++){const r=t[e]._states;for(let e=0,t=r.length;e<t;e++)this.registerState(r[e])}}rebuildByNodeOwners(e){if(!this._trackStateOwners)return;const t=this._nodeOwnersStateMap.get(e);t&&this.rebuildState(t)}rebuildState(e){const r=e._nodeOwners,a=new Set;let i=this._stateTransformOwnersCache.get(e);i?i.clear():i=new t.FastSinglelist;for(let e=0,t=r.length;e<t;e++){const t=r[e];if(!t||!za(t.type))continue;const n=t.propertyOwner;n&&!a.has(n)&&(a.add(n),i.add(n))}this._stateTransformOwnersCache.set(e,i)}begin(){const e=this._getBuffer();e.frame=++$a,e.transforms.clear(),e.flags.clear()}abort(){const e=this._getBuffer();e.transforms.clear(),e.flags.clear()}_addAnimatorTransformEvent(e,t){const r=this._getBuffer();if(e._lastAnimatorNotifyFrame===r.frame){const a=e._animatorNotifyIndex;if(a>=0)return void(r.flags.elements[a]|=t)}else e._lastAnimatorNotifyFrame=r.frame;e._animatorNotifyIndex=r.transforms.length,r.transforms.add(e),r.flags.add(t)}notifyActiveSlots(t){if(0===t.length)return;this._trackStateOwners=!0,this.begin();const r=this._getBuffer(),a=t.elements;for(let i=0,n=t.length;i<n;i++){const t=a[i]._layers;for(let a=0,i=t.length;a<i;a++){const i=t[a];i.type!==e.LayerTaskType.Idle&&(i.state&&this._collectStateSubtrees(i.state,r),i.destState&&this._collectStateSubtrees(i.destState,r))}}this.flush()}flush(){const e=this._getBuffer();this._depth++;try{for(let t=0,r=e.transforms.length;t<r;t++)e.transforms.elements[t]._dispatchAnimatorTransformChanged(e.flags.elements[t])}finally{this._depth--,e.transforms.clear(),e.flags.clear()}}_collectStateSubtrees(e,t){let r=this._stateTransformOwnersCache.get(e);r||(this.registerState(e),r=this._stateTransformOwnersCache.get(e));for(let e=0,a=r.length;e<a;e++)this._collectSubtree(r.elements[e],t)}_collectSubtree(e,t){if(e._lastAnimatorNotifyFrame===t.frame)return;e._lastAnimatorNotifyFrame=t.frame,e._animatorNotifyIndex=-1,e._hasTransformChangedListener&&(e._animatorNotifyIndex=t.transforms.length,t.transforms.add(e),t.flags.add(e._getAnimatorTransformChangeFlag()));const r=e._children;if(r)for(let e=0,a=r.length;e<a;e++)this._collectSubtree(r[e],t)}_getBuffer(){let e=this._buffers[this._depth];return e||(e={frame:0,transforms:new t.FastSinglelist,flags:new t.FastSinglelist},this._buffers[this._depth]=e),e}}class ti{constructor(){this._evaluator=new ka,this._applier=new Xa,this._activeList=new t.FastSinglelist,this._dirtyList=new t.FastSinglelist,this._slotMap=new WeakMap,this._transformEventDispatcher=new ei,ta(()=>new aa)}bindAnimator(e){let t=this._slotMap.get(e);return t||(t=new Ga(e,this._activeList,this._dirtyList),t.resizeLayers(e.layers.length),this._slotMap.set(e,t)),t}unbindAnimator(e){const t=this._slotMap.get(e);t&&(t._inActive&&(this._activeList.remove(t),t._inActive=!1),t._inDirty&&(this._dirtyList.remove(t),t._inDirty=!1),this._slotMap.delete(e))}prepareStateOwners(e,t){qa(e,t),this._transformEventDispatcher.registerState(t)}handleSpriteOwnersBySprite(e,t,r,a){Za(e,t,r,a),this._transformEventDispatcher.rebuildContext(e)}addKeyframeNodeOwner(e,t,r,a){ja(e,t,r,a),this._transformEventDispatcher.rebuildByNodeOwners(t)}removeKeyframeNodeOwner(e,t,r){Ja(e,t,r),this._transformEventDispatcher.rebuildByNodeOwners(t)}flushEvaluate(){const t=this._activeList.elements,r=this._evaluator;for(let a=0,i=this._activeList.length;a<i;a++){const i=t[a],n=i._layers,s=i._ctx.layers;for(let t=0,a=n.length;t<a;t++){const a=n[t];a.type!==e.LayerTaskType.Idle&&r.evaluateLayer(a,s[t])}}}_flushApplyScope(t){const r=this._activeList.elements,a=this._applier;for(let i=0,n=this._activeList.length;i<n;i++){const n=r[i],s=n._layers,o=n._ctx.layers,l=n._updateMark;for(let r=0,i=s.length;r<i;r++){const i=s[r];if(i.type===e.LayerTaskType.Idle)continue;const n=o[r],h=0===r;switch(i.type){case e.LayerTaskType.Normal:a.applyNormal(i,n,h,l,t);break;case e.LayerTaskType.Cross:a.applyCross(i,n,h,l,t);break;case e.LayerTaskType.FixedCross:a.applyFixedCross(i,n,h,l,t)}}}}flushApply(){const e=this._applier._scope;if("all"!==e)return this._flushApplyScope(e),void this._clearDirty();const t=this._transformEventDispatcher;let r=!1;t.begin(),Se._beginAnimatorBatch(t);try{this._flushApplyScope("transform-only"),r=!0}finally{Se._endAnimatorBatch(),r||t.abort()}t.flush(),this._flushApplyScope("non-transform-only"),this._clearDirty()}_notifyAnimatorTransformChanged(){this._transformEventDispatcher.notifyActiveSlots(this._activeList)}_clearDirty(){const e=this._dirtyList.elements;for(let t=0,r=this._dirtyList.length;t<r;t++)e[t]._clearDirty();this._dirtyList.clear()}updateDefaultValues(e){this._applier.updateDefaultValues(e)}revertDefaultKeyframeNodes(e){this._applier.revertDefaultKeyframeNodes(e)}destroy(){this._activeList.clear(),this._dirtyList.clear()}}class ri{constructor(){this.name=ri.__managerName,this._activeAnimators=[],this._pendingSwitches=[],this._factory=ri.factoryCreator()}Init(e){}update(e){const t=this._activeAnimators;for(let e=0,r=t.length;e<r;e++)this.tickOne(t[e]);this._factory.flushEvaluate(),this._factory.flushApply(),this._drainPendingSwitches(),this._drainLateUpdates(t)}addAnimator(e){-1===this._activeAnimators.indexOf(e)&&this._activeAnimators.push(e)}removeAnimator(e){const t=this._activeAnimators.indexOf(e);t>=0&&this._activeAnimators.splice(t,1)}destroy(){this._activeAnimators.length=0,this._pendingSwitches.length=0,this._factory.destroy()}tickOne(e){const r=e._taskSlot;let a=e.owner._scene.timer.delta/1e3;if(a=this._applyUpdateMode(e,a),0===e._speed||0===a||!t.Stat.enableAnimatorUpdate||this._isCulled(e))return void r.submitAllIdle();r._updateMark++;const i=e._controllerLayers;for(let t=0,n=i.length;t<n;t++){const n=i[t];if(!n.enable){r.submitLayerIdle(t);continue}const s=n._playStateInfo;if(e.sleep&&s._finish&&0==n._playType){r.submitLayerIdle(t);continue}const o=n._crossPlayStateInfo;switch(n._playType){case 0:this._tickPlayTypeNormal(e,n,s,a,t);break;case 1:this._tickPlayTypeCross(e,n,s,o,a,t);break;case 2:this._tickPlayTypeFixedCross(e,n,s,o,a,t)}}}_isCulled(e){if(e.cullingMode!==ai.CULLINGMODE_CULLCOMPLETELY)return!1;const t=e.owner,r=t._scene._cameraPool;let a=!1;for(const e of t.getRenderersInChildren()){if(e.destroyed)continue;a=!0;const t=e.owner;if(t.activeInHierarchy&&e.enabled&&0===e.renderbitFlag&&0!==e._renderElements.length)for(let a=0,i=r.length;a<i;a++){const i=r[a];if(i.activeInHierarchy&&i.enableRender&&i.cullingMask&1<<t.layer&&i.boundFrustum.intersects(e.bounds))return!1}}return a}_tickPlayTypeNormal(e,t,r,a,i){const n=e._taskSlot,s=t.defaultWeight,o=r.currentState,l=e._speed*o.speed,h=r._finish;h?this._applyTransition(e,o,i,o._eventtransition(r._normalizedPlayTime,e.animatorParams)):this._updatePlayer(e,o,r,a*l,o.islooping,i),n.submitLayerNormal(i,o,r,s),h||(this._updateEventScript(e,o,r),this._updateStateFinish(o,r))}_tickPlayTypeCross(e,t,r,a,i,n){const s=e._taskSlot,o=t.defaultWeight,l=r.currentState,h=t._crossPlayState,d=h._clip,c=t._crossDuration,u=a._startPlayTime,_=d._duration-u,f=c>_&&0!=_?_/c:1,m=e._speed*h.speed;this._updatePlayer(e,h,a,i*f*m,d.islooping,n);const g=(a._elapsedTime-u)/f/c;let p=!1;if(g>=1)s.submitLayerNormal(n,h,a,o),this._pendingSwitches.push({controllerLayer:t,fromState:l,toState:h,playStateInfo:r,crossPlayStateInfo:a});else{if(!r._finish){const t=e._speed*l.speed;p=!0,this._updatePlayer(e,l,r,i*t,l.islooping,n)}s.submitLayerCross(n,l,r,h,a,g)}this._updateEventScript(e,l,r),this._updateEventScript(e,h,a),this._updateStateFinish(h,a),p&&this._updateStateFinish(r.currentState,r)}_tickPlayTypeFixedCross(e,t,r,a,i,n){const s=e._taskSlot,o=r.currentState,l=t._crossPlayState,h=l._clip,d=t._crossDuration,c=a._startPlayTime,u=h._duration-c,_=d>u?u/d:1,f=e._speed*l.speed;this._updatePlayer(e,l,a,i*_*f,l.islooping,n);const m=(a._elapsedTime-c)/_/d;m>=1?(s.submitLayerNormal(n,l,a,1),this._pendingSwitches.push({controllerLayer:t,fromState:o,toState:l,playStateInfo:r,crossPlayStateInfo:a})):s.submitLayerFixedCross(n,l,a,m),this._updateEventScript(e,l,a),this._updateStateFinish(l,a)}_drainPendingSwitches(){const e=this._pendingSwitches;for(let t=0,r=e.length;t<r;t++){const r=e[t];r.controllerLayer._playType=0,r.playStateInfo.currentState=r.toState,r.fromState&&r.fromState._eventSwitch(r.toState),r.crossPlayStateInfo._cloneTo(r.playStateInfo)}e.length=0}_drainLateUpdates(e){for(let t=0,r=e.length;t<r;t++){const r=e[t];r._LateUpdateEvents.invoke(),r._LateUpdateEvents.clear()}}_applyUpdateMode(e,r){switch(e._updateMode){case t.AnimatorUpdateMode.Normal:return r;case t.AnimatorUpdateMode.LowFrame:return t.Stat.loopCount%e._lowUpdateDelty==0?r*e._lowUpdateDelty:0;case t.AnimatorUpdateMode.UnScaleTime:return 0}return r}_updatePlayer(e,t,r,a,i,n){const s=t._clip._duration*(t.clipEnd-t.clipStart),o=r._elapsedTime,l=o+a;r._lastElapsedTime=o,r._elapsedTime=l;const h=l/s;r._normalizedTime=h;const d=h%1,c=d<0?d+1:d;if(r._normalizedPlayTime=c,r._duration=s,l>=s)if(i){const r=Math.floor(l/s);Math.floor(o/s)!=r&&(e._controllerLayers[n].blendingMode===Va.BLENDINGMODE_ADDTIVE&&this._factory.updateDefaultValues(e._keyframeNodeOwners),t._eventLoop())}else r._finish=!0,r._elapsedTime=s,r._normalizedPlayTime=t.clipEnd;!r._finish&&t._eventStateUpdate(r._normalizedPlayTime),this._applyTransition(e,t,n,t._eventtransition(r._normalizedPlayTime,e.animatorParams))}_applyTransition(e,t,r,a){a?a!=t.curTransition&&(t.curTransition=a,e._LateUpdateEvents.add(e.crossFade,e,[a.destState.name,a.transduration,r,a.transstartoffset])):t.curTransition&&(t.curTransition=null)}_updateStateFinish(e,t){t._finish&&e._eventExit()}_updateEventScript(e,r,a){if(!e.owner._getBit(t.NodeFlags.HAS_SCRIPT))return;const i=r._clip._animationEvents;if(!i||0==i.length||null==a.animatorState)return;const n=a._duration,s=a.animatorState.clipStart*n+a._normalizedPlayTime*n;let o=a._parentPlayTime;null==o&&(o=n*a.animatorState.clipStart),s<o&&(this._eventScript(e,i,o,n*a.animatorState.clipEnd),o=n*a.animatorState.clipStart),this._eventScript(e,i,o,s),a._parentPlayTime=s}_eventScript(e,t,r,a){const i=e.owner.components;for(let e=0,n=t.length;e<n;e++){const n=t[e];if(n.time>r&&n.time<=a)for(let e=0,t=i.length;e<t;e++){const t=i[e];if(t._isScript()){const e=t[n.eventName];e&&e.apply(t,n.params)}}else if(n.time>a)break}}}ri.__managerName="AnimatorManager",ri.factoryCreator=()=>new ti,hr.regManager(ri.__managerName,ri);class ai extends t.Component{get controller(){return this._controller}set controller(e){this._controller&&this._controller._removeReference(),this._controller=e,e&&(e._addReference(),e.updateTo(this))}get speed(){return this._speed}set speed(e){this._speed=e}set updateMode(e){this._updateMode=e}set lowUpdateDelty(e){this._lowUpdateDelty=e}get controllerLayerCount(){return this._controllerLayers.length}get animatorParams(){return this._animatorParams}set animatorParams(e){this._animatorParams=e}get sleep(){return this._finishSleep}set sleep(e){this._finishSleep=e}constructor(){super(),this._keyframeNodeOwners=[],this._updateMode=t.AnimatorUpdateMode.Normal,this._lowUpdateDelty=20,this._LateUpdateEvents=new t.Delegate,this._taskSlot=null,this._animatorParams={},this._finishSleep=!1,this._manager=null,this._pendingPrepareStates=[],this.cullingMode=ai.CULLINGMODE_CULLCOMPLETELY,this._controllerLayers=[],this._speed=1,this._keyframeNodeOwnerMap={}}get _bindContext(){let e=this._cachedBindContext;return e||(e=this._cachedBindContext={sprite:this.owner,ownerMap:this._keyframeNodeOwnerMap,owners:this._keyframeNodeOwners,layers:this._controllerLayers}),e.sprite=this.owner,e}_removeKeyframeNodeOwner(e,t){var r;null===(r=this._manager)||void 0===r||r._factory.removeKeyframeNodeOwner(this._bindContext,e,t)}_getOwnersByClip(e){var t;const r=null===(t=this._manager)||void 0===t?void 0:t._factory;r?r.prepareStateOwners(this._bindContext,e):this._pendingPrepareStates.push(e)}_handleSpriteOwnersBySprite(e,t,r){var a;null===(a=this._manager)||void 0===a||a._factory.handleSpriteOwnersBySprite(this._bindContext,e,t,r)}_refreshLayerAvatarMask(e){var t,r,a;null===(a=null===(t=this._manager)||void 0===t?void 0:(r=t._factory).refreshLayerMask)||void 0===a||a.call(r,this._bindContext,e)}_saveCrossFixedValues(e,t){var r,a,i;null===(i=null===(r=this._manager)||void 0===r?void 0:(a=r._factory).saveCrossFixedValues)||void 0===i||i.call(a,e,t)}_updateDefaultValues(){var e;null===(e=this._manager)||void 0===e||e._factory.updateDefaultValues(this._keyframeNodeOwners)}_hasAdditiveLayer(){const e=this._controllerLayers;for(let t=0,r=e.length;t<r;t++){const r=e[t];if(r&&r.enable&&r.blendingMode!==Va.BLENDINGMODE_OVERRIDE)return!0}return!1}_revertDefaultKeyframeNodes(e){var t;null===(t=this._manager)||void 0===t||t._factory.revertDefaultKeyframeNodes(e)}onAfterDeserialize(){let e=this.controllerLayers;if(e&&null==this.controller){delete this.controllerLayers,this._controllerLayers.length=0;for(let t of e)this.addControllerLayer(t)}}_onEnable(){if(this._resolveManager(),this._manager){if(this._manager.addAnimator(this),this._taskSlot=this._manager._factory.bindAnimator(this._bindContext),this._taskSlot.resizeLayers(this._controllerLayers.length),this._pendingPrepareStates.length>0){const e=this._manager._factory,t=this._bindContext,r=this._pendingPrepareStates;for(let a=0,i=r.length;a<i;a++)e.prepareStateOwners(t,r[a]);r.length=0}for(let e=0,t=this._controllerLayers.length;e<t;e++)if(this._controllerLayers[e].playOnWake){let t=this.getDefaultState(e);t&&this.play(null,e,t.cycleOffset)}}}_onDisable(){var e;this._manager&&this._manager.removeAnimator(this),null===(e=this._taskSlot)||void 0===e||e.submitAllIdle()}_onDestroy(){this._manager&&(this._manager.removeAnimator(this),this._manager._factory.unbindAnimator(this._bindContext),this._manager=null),this._taskSlot=null,this._controller&&(this._controller._removeReference(),this._controller=null);for(let e=0,t=this._controllerLayers.length;e<t;e++)this._controllerLayers[e]._removeReference()}_resolveManager(){var e;if(this._manager)return;const t=null===(e=this.owner)||void 0===e?void 0:e.scene;t&&(this._manager=t.getComponentElementManager(ri.__managerName))}_cloneTo(e){e.cullingMode=this.cullingMode;for(var t=0,r=this._controllerLayers.length;t<r;t++){var a=this._controllerLayers[t];e.addControllerLayer(a.clone());for(var i=a._states,n=0,s=i.length;n<s;n++){var o=i[n].clone(),l=e.getControllerLayer(t);l.addState(o),0===n&&(l.defaultState=o)}}e.controller=this._controller}resetAdditiveBaseValues(){this._updateDefaultValues()}getDefaultState(e=0){return this._controllerLayers[e].defaultState}addState(e,t=0){this._controllerLayers[t].addState(e),console.warn("Animator:this function is discard,please use animatorControllerLayer.addState() instead.")}removeState(e,t=0){this._controllerLayers[t].removeState(e),console.warn("Animator:this function is discard,please use animatorControllerLayer.removeState() instead.")}addControllerLayer(e){var t;this._controllerLayers.push(e),e._animator=this,e._addReference(),null===(t=this._taskSlot)||void 0===t||t.resizeLayers(this._controllerLayers.length);for(var r=e._states,a=0,i=r.length;a<i;a++)this._getOwnersByClip(r[a])}getControllerLayer(e=0){return this._controllerLayers[e]}play(e=null,t=0,r=Number.NEGATIVE_INFINITY){var a=this._controllerLayers[t];if(a){var i=a.defaultState;if(!e&&!i)throw new Error("Animator:must have default clip value,please set clip property.");var n=a._playStateInfo,s=n.currentState,o=e?a.getAnimatorState(e):i;if(!o||!o._clip)return void console.warn("Animator:must have clip value,please set clip property.");this._hasAdditiveLayer()&&this._updateDefaultValues();var l=o._clip._duration,h=o._clip._duration*(o.clipEnd-o.clipStart);s!==o?(r!==Number.NEGATIVE_INFINITY?n._resetPlayState(l*r,h):n._resetPlayState(0,h),null!==s&&s!==o&&this._revertDefaultKeyframeNodes(s),a._playType=0,n.currentState=o):r!==Number.NEGATIVE_INFINITY?(n._resetPlayState(l*r,h),a._playType=0):n._resetPlayState(l*o.clipStart,h),s&&s._eventSwitch(o),o._eventStart(this,t)}else console.warn("Invalid layerIndex "+t+".")}crossFade(e,t,r=0,a=Number.NEGATIVE_INFINITY){var i=this._controllerLayers[r];if(i){var n=i.getAnimatorState(e);if(n){var s=i._playType;if(-1===s)return void this.play(e,r,a);this._hasAdditiveLayer()&&this._updateDefaultValues();var o=i._crossPlayStateInfo,l=i._crossNodesOwners,h=i._crossNodesOwnersIndicesMap,d=i._playStateInfo.currentState,c=n._nodeOwners,u=i._destCrossClipNodeIndices,_=n._clip,f=_._nodes,m=_._nodesDic,g=0;switch(s){case 0:var p=d._nodeOwners,S=i._srcCrossClipNodeIndices,T=d._clip,A=T._nodes,E=T._nodesDic;i._playType=1;var D=++i._crossMark;g=i._crossNodesOwnersCount=0;for(var R=0,x=A.count;R<x;R++){var y=A.getNodeByIndex(R),M=y._indexInList,C=p[M];if(C){var v=y.fullPath;S[g]=M;var I=m[v];u[g]=I?I._indexInList:-1,h[v]=D,l[g]=C,g++}}for(R=0,x=f.count;R<x;R++){var w=(I=f.getNodeByIndex(R))._indexInList,B=c[w];if(B){var P=I.fullPath;E[P]||(S[g]=-1,u[g]=w,h[P]=D,l[g]=B,g++)}}break;case 1:case 2:for(i._playType=2,R=0,x=l.length;R<x;R++){var L=l[R];L.saveCrossFixedValue(),I=m[L.fullPath],u[R]=I?I._indexInList:-1}for(g=i._crossNodesOwnersCount,D=i._crossMark,R=0,x=f.count;R<x;R++)(B=c[w=(I=f.getNodeByIndex(R))._indexInList])&&h[P=I.fullPath]!==D&&(u[g]=w,h[P]=D,L=c[w],l[g]=L,L.saveCrossFixedValue(),g++);this._saveCrossFixedValues(l,g)}i._crossNodesOwnersCount=g,i._crossPlayState=n,i._crossDuration=d._clip._duration*t,a!==Number.NEGATIVE_INFINITY?o._resetPlayState(_._duration*a,i._crossDuration):o._resetPlayState(0,i._crossDuration),n._eventStart(this,r)}else console.warn("Invalid name "+r+".")}else console.warn("Invalid layerIndex "+r+".")}setParamsTrigger(e){let r;r="number"==typeof e?e:t.AnimatorStateCondition.conditionNameToID(e),this._animatorParams[r]=!0}setParamsNumber(e,r){let a;a="number"==typeof e?e:t.AnimatorStateCondition.conditionNameToID(e),this._animatorParams[a]=r}setParamsBool(e,r){let a;a="number"==typeof e?e:t.AnimatorStateCondition.conditionNameToID(e),this._animatorParams[a]=r}getParamsvalue(e){let r;return r="number"==typeof e?e:t.AnimatorStateCondition.conditionNameToID(e),this._animatorParams[r]}getCurrentAnimatorPlayState(e=0){return this._controllerLayers[e]._playStateInfo}}ai.CULLINGMODE_ALWAYSANIMATE=0,ai.CULLINGMODE_CULLCOMPLETELY=2;class ii extends t.EventDispatcher{get clip(){return this._clip}set clip(r){if(this._clip!==r){if(this._clip&&this._referenceCount>0&&this._clip._removeReference(this._referenceCount),r){var a=this._realtimeDatas,i=r._nodes,n=i.count;this._currentFrameIndices=new Int16Array(n),this._resetFrameIndices(),this._referenceCount>0&&r._addReference(this._referenceCount),this._realtimeDatas.length=n;for(var s=0;s<n;s++)switch(i.getNodeByIndex(s).type){case e.KeyFrameValueType.Boolean:case e.KeyFrameValueType.Float:break;case e.KeyFrameValueType.Position:case e.KeyFrameValueType.Scale:case e.KeyFrameValueType.RotationEuler:case e.KeyFrameValueType.Vector3:a[s]=new t.Vector3;break;case e.KeyFrameValueType.Rotation:a[s]=new t.Quaternion;break;case e.KeyFrameValueType.Vector2:a[s]=new t.Vector2;break;case e.KeyFrameValueType.Vector4:case e.KeyFrameValueType.Color:a[s]=new t.Vector4;break;case e.KeyFrameValueType.PathPoint:break;case e.KeyFrameValueType.MaterialRef:a[s]="";break;default:throw new Error("AnimationClipParser04:unknown type.")}}this._clip=r}}get islooping(){return this._isLooping?1==this._isLooping:this._clip.islooping}get transitions(){return this._transitions}set transitions(e){this._transitions=e}get soloTransitions(){return this._soloTransitions}set soloTransitions(e){this._soloTransitions=e}constructor(){super(),this._referenceCount=0,this._clip=null,this._nodeOwners=[],this._currentFrameIndices=null,this._isLooping=0,this._realtimeDatas=[],this._scripts=null,this._transitions=[],this._soloTransitions=[],this.speed=1,this.clipStart=0,this.clipEnd=1,this.cycleOffset=0}_eventStart(e,t){if(this.event(ii.EVENT_OnStateEnter),this._scripts)for(var r=0,a=this._scripts.length;r<a;r++)this._scripts[r].setPlayScriptInfo(e,t,this),this._scripts[r].onStateEnter()}_eventExit(){if(this.event(ii.EVENT_OnStateExit),this.curTransition=null,this._scripts)for(let e=0,t=this._scripts.length;e<t;e++)this._scripts[e].onStateExit()}_eventSwitch(e){if(this.event(ii.EVENT_OnStateSwitch,e),this._scripts)for(let t=0,r=this._scripts.length;t<r;t++)this._scripts[t].onStateSwitch&&this._scripts[t].onStateSwitch(e)}_eventStateUpdate(e){if(this.event(ii.EVENT_OnStateUpdate,e),this._scripts)for(var t=0,r=this._scripts.length;t<r;t++)this._scripts[t].onStateUpdate(e)}_eventLoop(){if(this.event(ii.EVENT_OnStateLoop),this._scripts)for(let e=0,t=this._scripts.length;e<t;e++)this._scripts[e].onStateLoop&&this._scripts[e].onStateLoop()}_eventtransition(e,t){let r=this._soloTransitions.length;if(r>0){for(var a=0;a<r;a++)if(this._soloTransitions[a].check(e,t))return this._soloTransitions[a];return null}let i=this._transitions.length;for(a=0;a<i;a++)if(this._transitions[a].check(e,t))return this._transitions[a];return null}_getReferenceCount(){return this._referenceCount}_addReference(e=1){this._clip&&this._clip._addReference(e),this._referenceCount+=e}_removeReference(e=1){this._clip&&this._clip._removeReference(e),this._referenceCount-=e}_clearReference(){this._removeReference(-this._referenceCount)}_resetFrameIndices(){for(var e=0,t=this._currentFrameIndices.length;e<t;e++)this._currentFrameIndices[e]=-1}addScript(e){var t=new e;return this._scripts=this._scripts||[],this._scripts.push(t),t}getScript(e){if(this._scripts)for(var t=0,r=this._scripts.length;t<r;t++){var a=this._scripts[t];if(a instanceof e)return a}return null}getScripts(e){var t=null;if(this._scripts)for(var r=0,a=this._scripts.length;r<a;r++){var i=this._scripts[r];i instanceof e&&(t=t||[]).push(i)}return t}cloneTo(e){e.name=this.name,e.speed=this.speed,e.clipStart=this.clipStart,e.clipEnd=this.clipEnd,e.clip=this._clip}clone(){var e=new ii;return this.cloneTo(e),e}}ii.EVENT_OnStateEnter="OnStartEnter",ii.EVENT_OnStateUpdate="OnStateUpdate",ii.EVENT_OnStateLoop="OnStateLoop",ii.EVENT_OnStateExit="OnStateExit",ii.EVENT_OnStateSwitch="OnStateSwitch";class ni{constructor(e){this._avatarPathMap=(null==e?void 0:e._avatarPathMap)||{}}getTransformActive(e){return this._avatarPathMap[e]}setTransformActive(e,t){this._avatarPathMap[e]=t}getAllTranfromPath(){return this._avatarPathMap}clone(){var e=new ni;return this.cloneTo(e),e}cloneTo(e){for(var t in this._avatarPathMap)e.setTransformActive(t,this._avatarPathMap[t])}}class si{constructor(){this._active=!0,this._singleton=!0}get singleton(){return this._singleton}get renderBeforeTAA(){return!1}get active(){return this._active}set active(e){this._active=e}getCameraDepthTextureModeFlag(){return 0}getCameraOpaqueMRTRequirements(){return null}effectInit(e){}release(e){}render(e){}}class oi{constructor(){this._conditions=[],this._exitByTime=!0,this._exitTime=.85,this._transduration=.15,this._transstartoffset=0,this._mute=!1}get name(){return this._name}set name(e){this._name=e}get mute(){return this._mute}set mute(e){this._mute=e}get destState(){return this._destState}set destState(e){this._destState=e}get conditions(){return this._conditions}set conditions(e){for(var t=this._conditions.length-1;t>=0;t--)this.removeCondition(this._conditions[t]);for(t=0;t<e.length;t++)this.addCondition(e[t])}get exitByTime(){return this._exitByTime}set exitByTime(e){this._exitByTime=e}set transduration(e){this._transduration=Math.max(0,Math.min(e,1))}get transduration(){return this._transduration}set transstartoffset(e){this._transstartoffset=Math.max(0,Math.min(e,1))}get transstartoffset(){return this._transstartoffset}get exitTime(){return this._exitTime}set exitTime(e){this._exitTime=Math.max(0,Math.min(e,1))}addCondition(e){-1==this._conditions.indexOf(e)&&this._conditions.push(e)}removeCondition(e){let t=this._conditions.indexOf(e);-1!=t&&this._conditions.splice(t,0)}get isAndOperEnabled(){return this._isAndOperEnabled}set isAndOperEnabled(e){this._isAndOperEnabled=e}check(e,r){if(this._mute)return!1;if(0==this._conditions.length){if(e>=this._exitTime)return!0}else{if(this._exitByTime&&e<this._exitTime)return!1;if(this._isAndOperEnabled){for(var a=0;a<this._conditions.length;a++){let e=this._conditions[a];if(!e.checkState(r[e.id]))return!1;e.type==t.AniStateConditionType.Trigger&&(r[e.id]=!1)}return!0}for(a=0;a<this._conditions.length;a++){let e=this._conditions[a];if(e.checkState(r[e.id]))return e.type==t.AniStateConditionType.Trigger&&(r[e.id]=!1),!0}}return!1}}class li extends t.Resource{constructor(e){super();let r=t.AnimatorControllerParse.parse(e);this.data=r.ret,this.clipsID=r.clipsID}getLayers(){let e=this.data.controllerLayers,t=[];for(let r=e.length-1;r>=0;r--){let a=e[r],i=new Va(a.name);a.avatarMask&&(i.avatarMask=a.avatarMask),t.unshift(i);for(let e in a)if("avatarMask"!=e&&"name"!=e&&"states"!=e&&null!=a[e])try{i[e]=a[e]}catch(e){}this.getState(a.states,i,this.data)}return t}updateTo(e){let r=e._controllerLayers;for(let e=0,t=r.length;e<t;e++)r[e]._removeReference();r.length=0;let a=this.getLayers();for(let t=0,r=a.length;t<r;t++)e.addControllerLayer(a[t]);let i=this.data.animatorParams;if(i)for(let r=i.length-1;r>=0;r--){let a=i[r];if(t.AniParmType.Bool==a.type)e.setParamsBool(a.name,Boolean(a.val));else if(t.AniParmType.Float==a.type){let t=Number(a.val);isNaN(t)&&(t=0),e.setParamsNumber(a.name,t)}else t.AniParmType.Trigger==a.type&&a.val&&e.setParamsTrigger(a.name)}}createState(e,r,a){if(!e)return null;let i={},n=null;for(let s=e.length-1;s>=0;s--){let o=e[s],l=o.states;if(l){let e=this.createState(l,r,a);e&&(r[o.id]=e.states[e.id]);continue}if(0>Number(o.id)){if("-1"==o.id){let e=o.soloTransitions;e&&0<e.length&&(n=e[0].id)}continue}let h=new ii;r[o.id]=h,i[o.id]=h;for(let e in o)try{if("scripts"==e){let r=o[e];if(r&&Array.isArray(r))for(let e=r.length-1;e>=0;e--){let a=r[e];a&&0==a.indexOf("res://")&&(a=a.substring(6));let i=t.ClassUtils.getClass(a);i&&h.addScript(i)}continue}if("soloTransitions"==e)continue;null!=o[e]&&(h[e]=o[e])}catch(e){}a.addState(h)}return{id:n,states:i}}setExitTransition(e,t,r,a,i){for(let n in e){let s=r[n];if(s){let o=s.transitions,l=s.soloTransitions,h=e[n];for(let e=t.length-1;e>=0;e--){let s=t[e];if("-3"!=s.id)for(let e=h.length-1;e>=0;e--){let t=h[e],i=new oi;i.destState=r[s.id],s.conditions&&this.addConditions(s.conditions,i,a),t.conditions&&this.addConditions(t.conditions,i,a);for(let e in s)"solo"!=e&&"id"!=e&&"conditions"!=e&&(i[e]=s[e]);s.solo?l.unshift(i):o.unshift(i)}else null==i[n]&&(i[n]=[]),i[n].push(s)}}}}setTransitions(e,t,r,a,i){if(!e)return null;let n={};for(let i=e.length-1;i>=0;i--){let s=e[i];if(s.states){let e=this.setTransitions(s.states,t,r,a,s);if(e){let r=s.soloTransitions;r&&this.setExitTransition(e,r,t,a,n)}}}for(let s=e.length-1;s>=0;s--){let o=e[s];if(o.states)continue;if("-1"==o.id){if(o.soloTransitions&&0<o.soloTransitions.length){null==i?r.defaultState=t[o.soloTransitions[0].id]:t[i.id]=t[o.soloTransitions[0].id];continue}}else{if("-2"==o.id){let e=o.soloTransitions;if(e)for(let r=e.length-1;r>=0;r--){let i=e[r],n=t[i.id];if(n)for(let e in t){let r=t[e],s=new oi;s.destState=n,i.conditions&&this.addConditions(i.conditions,s,a);for(let e in i)"solo"!=e&&"id"!=e&&"conditions"!=e&&(s[e]=i[e]);i.solo?r.soloTransitions.unshift(s):r.transitions.unshift(s)}}continue}if("-3"==o.id)continue}let l=o.soloTransitions;if(l&&t[o.id]){let e=t[o.id].transitions,r=t[o.id].soloTransitions;for(let i=l.length-1;i>=0;i--){let s=l[i];if("-3"==s.id){null==n[o.id]&&(n[o.id]=[]),n[o.id].push(s);continue}let h=new oi;t[s.id]&&(h.destState=t[s.id]),s.conditions&&this.addConditions(s.conditions,h,a);for(let e in s)"solo"!=e&&"id"!=e&&"conditions"!=e&&(h[e]=s[e]);s.solo?r.unshift(h):e.unshift(h)}}}return n}getState(e,t,r){if(e){let a={};this.createState(e,a,t),this.setTransitions(e,a,t,r)}}addConditions(e,r,a){let i=a.animatorParams;if(null!=i&&0!=i.length)for(let a=0,n=e.length;a<n;a++){let n,s=e[a],o=null;for(let e=i.length-1;e>=0;e--)if(i[e].id==s.id){o=i[e];break}if(null==o)return;if(o.type==t.AniParmType.Bool){let e=new t.AnimatorStateBoolCondition(o.name);e.compareFlag=Boolean(s.checkValue),n=e}else if(o.type==t.AniParmType.Float){let e=new t.AnimatorStateNumberCondition(o.name);e.numberValue=Number(s.checkValue),e.compareFlag=s.type,n=e}else if(o.type==t.AniParmType.Trigger){n=new t.AnimatorStateTriggerCondition(o.name)}r.addCondition(n)}}}class hi extends Ce{constructor(e){super(t.MeshTopology.Triangles,t.DrawType.DrawElement),this._owner=e,this.bufferState=new t.BufferState,this._bound=new M,this._createBuffer(),this.indexFormat=t.IndexFormat.UInt16}get bounds(){return this._bound}_createBuffer(){var e=t.VertexMesh.getVertexDeclaration("POSITION,NORMAL,UV"),r=.5,a=.5;this._vertex=new Float32Array([-.5,a,0,0,0,1,0,0,r,a,0,0,0,1,1,0,-.5,-.5,0,0,0,1,0,1,r,-.5,0,0,0,1,1,1]),this._index=new Uint16Array([0,1,2,3,2,1]),this._vertexBuffer=T.renderOBJCreate.createVertexBuffer3D(4*this._vertex.length,t.BufferUsage.Dynamic,!1),this._vertexBuffer.vertexDeclaration=e,this._vertexBuffer.setData(this._vertex.buffer),this._indexBuffer=T.renderOBJCreate.createIndexBuffer3D(t.IndexFormat.UInt16,this._index.length,t.BufferUsage.Static,!1),this._indexBuffer.setData(this._index),this.bufferState=new t.BufferState,this.bufferState.applyState([this._vertexBuffer],this._indexBuffer),this._bound.setExtent(new t.Vector3(r,a,r)),this._bound.setCenter(new t.Vector3(0,0,0)),this._positionArray=[new t.Vector3,new t.Vector3,new t.Vector3,new t.Vector3],this._positionArray[0].set(-.5,r,0),this._positionArray[1].set(a,r,0),this._positionArray[2].set(-.5,-.5,0),this._positionArray[3].set(a,-.5,0)}_updateRenderParams(e){this.clearRenderParams(),this.setDrawElemenParams(6,0)}destroy(){super.destroy(),this.bufferState.destroy(),this._vertexBuffer.destroy(),this._indexBuffer.destroy(),this.bufferState=null,this._vertexBuffer=null,this._indexBuffer=null,delete this._vertex,delete this._index}}hi._type=Ce._typeCounter++,new t.Vector3;class di extends t.Sprite{get genMipMap(){return this._genMipMap}set genMipMap(e){this._genMipMap=e}get rtWidth(){return this._rtWidth}set rtWidth(e){this._rtWidth=e}get rtHeight(){return this._rtHeight}set rtHeight(e){this._rtHeight=e}get invertY(){return this._invertY}set invertY(e){this._invertY=e}constructor(){super(),this.updateRT=!1,this._contentOffsetX=0,this._contentOffsetY=0,this._genMipMap=!1}updateRenderTexture(){let e=t.Rectangle.TEMP;e.setTo(this._contentOffsetX,this._contentOffsetY,this._rtWidth,this._rtHeight),this._subStructRender._updateRenderOffset(e,e,1,1);let r,a=this._drawOriRT;if(a){if(this._rtWidth===a.width&&this._rtHeight===a.height)return!1;a!==this.displayRT&&a.destroy()}return this._genMipMap?(r=new t.RenderTexture2D(this._rtWidth,this._rtHeight,t.RenderTargetFormat.R8G8B8A8),r._renderTarget&&r._renderTarget.dispose(),r._renderTarget=t.LayaGL.textureContext.createRenderTargetInternal(r.width,r.height,r.getColorFormat(),r.depthStencilFormat,!0,!1,1,!1),r._texture=r._renderTarget._textures[0],r._texture.gammaCorrection=2.2):r=new t.RenderTexture2D(this._rtWidth,this._rtHeight,t.RenderTargetFormat.R8G8B8A8),r._invertY=this._invertY,this._drawOriRT=r,this.updateRT=!0,!0}}class ci extends z{get genMipMap(){return this._genMipMap}set genMipMap(e){this._genMipMap=e,this._shellSprite.genMipMap=e,this._shellSprite.repaint(t.RepaintFlag.UpdateRT)}get sprite(){return this._uisprite}set sprite(e){e!=this._uisprite&&(this._uisprite=e,this._shellSprite.removeChildren(0,this._shellSprite.numChildren-1),e?(this._shellSprite.addChild(e),this._updateContentOffset(e)):(this._shellSprite._contentOffsetX=0,this._shellSprite._contentOffsetY=0),this._resizeRT(),this._shellSprite.repaint(),this.setRenderbitFlag(4,!e||!this._shellSprite.displayRT),this.boundsChange=!0)}_updateContentOffset(e){let r=t.Rectangle.TEMP;t.SpriteUtils.getRect(e,!1,r),e.transform&&r.transform(e.transform,r),this._shellSprite._contentOffsetX=r.x+e.x,this._shellSprite._contentOffsetY=r.y+e.y}get prefab(){return this._prefab}set prefab(e){this._prefab=e,this.sprite=e?e.create():null}get scale(){return this._size}set scale(e){e.x<=0||e.y<=0||t.Vector2.equals(e,this._size)||(e.cloneTo(this._size),this._resizeRT(),this.boundsChange=!0,this._sizeChange=!0,this._scale.setValue(e.x,e.y,1))}get renderMode(){return this.sharedMaterial||(this.sharedMaterial=this._ui3DMat),this.sharedMaterial.materialRenderMode}set renderMode(e){this.sharedMaterial.materialRenderMode=e,this.boundsChange=!0}get cull(){let e=this.sharedMaterial;return e||(e=this._ui3DMat),e.cull}set cull(e){this.sharedMaterial&&(this.sharedMaterial.cull=e)}get resolutionRate(){return this._resolutionRate}set resolutionRate(e){e<=0||this._resolutionRate!=e&&(this._resolutionRate=e,this._resizeRT())}get billboard(){return this._view}set billboard(e){this._view=e,this._sizeChange=!0,this.boundsChange=!0}get enableHit(){return this._hit}set enableHit(e){this._hit=e}set cameraSpace(e){this._cameraSpace!=e&&(this._cameraSpace=e,this._camera&&this._resizeRT())}get cameraSpace(){return this._cameraSpace}set cameraPlaneDistance(e){e=Math.max(0,e),this._cameraPlaneDistance=e}get cameraPlaneDistance(){return this._cameraPlaneDistance}set attachCamera(e){this._camera!=e&&(this._camera=e,this._cameraSpace&&this._resizeRT())}get attachCamera(){return this._camera}constructor(){var e,r,a,i;super(),this._sizeChange=!0,this._view=!0,this._bindPropertyName="u_AlbedoTexture",this._hit=!1,this._cameraSpace=!1,this._worldParams=new t.Vector4,this._genMipMap=!1,this._size=new t.Vector2(1,1),this._resolutionRate=128,this._shellSprite=new di,this._shellSprite.name="UI3D",this._shellSprite._parent=t.ILaya.stage,this._shellSprite._syncTransParent(),this._shellSprite._setBit(t.NodeFlags.DISPLAYED_INSTAGE,!0),this._shellSprite._setBit(t.NodeFlags.ACTIVE_INHIERARCHY,!0),this._shellSprite.cacheAs="bitmap",this._shellSprite._struct.renderMatrix=this._shellSprite.globalTrans.getMatrix(),this._baseRenderNode.shaderData.addDefine(A.SHADERDEFINE_UV0),this.setRenderbitFlag(4,!0),this._matrix=new t.Matrix4x4,this._scale=new t.Vector3(1,1,1),null===(r=(e=this._baseRenderNode).disableNativeBoundsCallback)||void 0===r||r.call(e),null===(i=(a=this._baseRenderNode).setBoundsMode)||void 0===i||i.call(a,1)}_pushWorldBoundsToNative(){if(!this._baseRenderNode.setWorldBounds)return;this._calculateBoundingBox();const e=this._bounds.getMin(),t=this._bounds.getMax();this._baseRenderNode.setWorldBounds(e.x,e.y,e.z,t.x,t.y,t.z)}_isMaterialVaild(e){return e.checkType(t.ShaderFeatureType.D3)}_creatDefaultMat(){this._ui3DMat||(this._ui3DMat=new S,this._ui3DMat.materialRenderMode=t.MaterialRenderMode.RENDERMODE_OPAQUE,this._ui3DMat.cull=t.RenderState.CULL_BACK)}_addRenderElement(){var e=this._renderElements;this.sharedMaterial||(this._creatDefaultMat(),this.sharedMaterial=this._ui3DMat);var t=this.sharedMaterial,r=new W;r.setTransform(this.owner._transform),r.render=this,r.material=t,r.renderSubShader=r.material.shader.getSubShaderAt(0),this._geometry=new hi(this),r.setGeometry(this._geometry),e.push(r),this._setRenderElements(),this.geometryBounds=this._geometry.bounds}_isCameraSpaceMode(){return this._cameraSpace&&this._camera}_parseHit(e){let r,a,i=ci._ray;const n=this._shellSprite.displayRT;if(!this._uisprite||!n||!t.LayaEnv.isPlaying)return null;if(n.width!==this._shellSprite.rtWidth||n.height!==this._shellSprite.rtHeight)return null;this._matrix.invert(ui),t.Vector3.transformCoordinate(e.origin,ui,i.origin),t.Vector3.TransformNormal(e.direction,ui,i.direction),i.direction.normalize();let s=0,o=0,l=-i.origin.z/i.direction.z;if(l<0)return null;r=i.origin.x+l*i.direction.x,a=i.origin.y+l*i.direction.y,s=r+.5,o=a+.5;let h=s*n.width,d=(1-o)*n.height;const c=t.Point.TEMP.setTo(h+this._shellSprite._contentOffsetX,d+this._shellSprite._contentOffsetY);this._uisprite.fromParentPoint(c);let u=t.InputManager.inst.getSpriteUnderPoint(this._uisprite,c.x,c.y);return u||null}_resizeRT(){let e,r;this._isCameraSpaceMode()?(e=this._camera.viewport.width,r=this._camera.viewport.height):(e=this._size.x*this._resolutionRate,r=this._size.y*this._resolutionRate),!this._shellSprite||this._shellSprite.rtWidth===e&&this._shellSprite.rtHeight===r||(this._shellSprite&&(this._shellSprite.rtWidth=e),this._shellSprite&&(this._shellSprite.rtHeight=r),this._shellSprite&&(this._shellSprite.invertY=!t.LayaGL.renderEngine._screenInvertY),this._shellSprite&&this._shellSprite.repaint(t.RepaintFlag.UpdateRT))}onPreRender(){let e=!0;if(this._isCameraSpaceMode()){this.boundsChange=!0;let e=t.Vector3.TEMP,r=t.Quaternion.TEMP,a=_i,i=this._camera;if(i.transform.getForward(e),e=e.normalize(),t.Vector3.scale(e,this._cameraPlaneDistance,e),t.Vector3.add(i.transform.position,e,e),i.transform.rotation.cloneTo(r),i.orthographic)a.setValue(i.orthographicVerticalSize*i.aspectRatio,i.orthographicVerticalSize,1);else{let e=Math.tan(t.Utils.toRadian(i.fieldOfView/2))*this._cameraPlaneDistance*2;a.setValue(e*i.aspectRatio,e,1)}t.Matrix4x4.createAffineTransformation(e,r,a,this._matrix)}else if(this.billboard){this._sizeChange=!1,this.boundsChange=!0;let e=this.owner.scene.cullInfoCamera,r=this._transform.worldMatrix.elements,a=Math.sqrt(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]),i=Math.sqrt(r[4]*r[4]+r[5]*r[5]+r[6]*r[6]),n=_i;n.setValue(this._scale.x*a,this._scale.y*i,1),t.Matrix4x4.createAffineTransformation(this._transform.position,e.transform.rotation,n,this._matrix)}else this._sizeChange?(this._sizeChange=!1,this.boundsChange=!0,t.Matrix4x4.createScaling(this._scale,ui),t.Matrix4x4.multiply(this._transform.worldMatrix,ui,this._matrix)):e=!1;e&&this._pushWorldBoundsToNative()}getUITexture(){return this._shellSprite.displayRT}_getCameraDistance(e){return t.Vector3.distance(e,this.owner.transform.position)}_renderUpdate(e){let t=this._baseRenderNode.shaderData;t.setMatrix4x4(R.WORLDMATRIX,this._matrix);let r=this.owner.transform,a=this._worldParams;a.x=r.getFrontFaceValue(),t.setVector(R.WORLDINVERTFRONT,a)}renderUpdate(e){this._renderElements.forEach(t=>{let r=t._geometry;t._renderElementOBJ.isRender=r._prepareRender(e),r._updateRenderParams(e)})}_submitRT(){if(this._shellSprite.updateRT){const e=this._shellSprite.displayRT;this._shellSprite.updateRT=!1,this._setMaterialTexture(),this.setRenderbitFlag(4,!this._uisprite||!this._shellSprite.displayRT),e&&e!==this._shellSprite.displayRT&&e.destroy()}}_setMaterialTexture(){this._shellSprite._drawOriRT?(this.sharedMaterial.addDefine(S.SHADERDEFINE_ALBEDOTEXTURE),this.sharedMaterial.setTexture(this._bindPropertyName,this._shellSprite._drawOriRT),this._shellSprite.displayRT=this._shellSprite._drawOriRT):(this.sharedMaterial.removeDefine(S.SHADERDEFINE_ALBEDOTEXTURE),this._shellSprite.displayRT=null)}_checkUIPos(e){return!!this.enableHit&&this._parseHit(e)}_calculateBoundingBox(){this._geometry.bounds._tranform(this._matrix,this._bounds)}_onAdded(){super._onAdded(),this._addRenderElement()}_onDisable(){super._onDisable(),this.owner.transform.off(t.Event.TRANSFORM_CHANGED,this,this._transByRotate),this.owner.scene._UI3DManager.remove(this)}_onEnable(){super._onEnable(),this.owner.scene._UI3DManager.add(this),this.owner.transform.on(t.Event.TRANSFORM_CHANGED,this,this._transByRotate),this._transByRotate()}_onDestroy(){super._onDestroy();const e=this._shellSprite.displayRT;e&&e.destroy();const t=this._shellSprite._drawOriRT;t&&t!==e&&t.destroy(),this._shellSprite&&(this._shellSprite._parent=null,this._shellSprite._syncTransParent()),this._uisprite&&this._uisprite.destroy(),this._shellSprite&&this._shellSprite.destroy(),this._ui3DMat&&this._ui3DMat.destroy(),this._resolutionRate=null,this._size=null,this._scale=null,this._matrix=null}_transByRotate(){this.billboard||(this._sizeChange=!0),this.boundsChange=!0}}ci.DEBUG=!1,ci._ray=new ke(new t.Vector3,new t.Vector3);const ui=new t.Matrix4x4,_i=new t.Vector3;var fi;t.Loader.registerLoader(["lani"],class{load(e){let r=t.AssetDb.inst.getSubAssetURL(e.url,e.uuid,null,"lani");return e.loader.fetch(r,"arraybuffer",e.progress.createCallback(),e.options).then(e=>e?ca._parse(e):null)}},t.Loader.ANIMATIONCLIP);class mi{constructor(){fi||(fi={"WhiteTextureCube.ltc":t.TextureCube.whiteTexture,"BlackTextureCube.ltc":t.TextureCube.blackTexture,"GrayTextureCube.ltc":t.TextureCube.grayTexture})}load(e){if(-1!=e.url.indexOf("internal/")){let r=fi[t.Utils.getBaseName(e.url)];if(r)return Promise.resolve(r)}if("ktx"==e.ext||"cubemap"==e.ext){let r=e.url;return"cubemap"==e.ext&&(r=t.AssetDb.inst.getSubAssetURL(r,e.uuid,"0","ktx")),e.loader.fetch(r,"arraybuffer",e.progress.createCallback(),e.options).then(r=>{var a,i,n;if(!r)return null;let s=t.KTXTextureInfo.getKTXTextureInfo(r);if(s.dimension!=t.TextureDimension.Cube)return t.Loader.warn("ktxInfo.dimension != TextureDimension.Cube! "+e.url),null;let o=e.options.constructParams,l=e.options.propertyParams,h=(null===(a=null==o?void 0:o[3])||void 0===a||a)&&s.mipmapCount>1,d=null!==(i=null==o?void 0:o[5])&&void 0!==i?i:s.sRGB,c=!!l&&l.premultiplyAlpha,u=new t.TextureCube(s.width,s.format,h,d,c);l&&(null!=l.wrapModeU&&(u.wrapModeU=l.wrapModeU),null!=l.wrapModeV&&(u.wrapModeV=l.wrapModeV),null==l.wrapModeV&&null==l.wrapModeU||(u.wrapModeW=null!==(n=l.wrapModeV)&&void 0!==n?n:l.wrapModeU),null!=l.filterMode&&(u.filterMode=l.filterMode),null!=l.anisoLevel&&(u.anisoLevel=l.anisoLevel)),u.setKTXData(s);let _=e.obsoluteInst;return _&&_ instanceof t.TextureCube&&(u=this.move(_,u)),u})}return"ltcb"==e.ext||"ltcb.ls"==e.ext?e.loader.fetch(e.url,"arraybuffer",e.progress.createCallback(),e.options).then(r=>{if(!r)return null;let a=new t.Byte(r),i=a.readUTFString();if("LAYATEXTURECUBE:0000"!==i)return console.warn(`CubemapBinLoader: unknow version. ${i}`),null;let n=a.readUint8(),s=a.readUint8(),o=a.readUint16(),l=a.readUint8(),h=a.readUint8(),d=a.readUint8(),c=a.readUint8(),u=new t.TextureCube(o,n,s>1);u.setPixelsData(null,!1,!1),u.filterMode=l,u.wrapModeU=h,u.wrapModeV=d,u.anisoLevel=c;let _=a.pos,f=o;for(let e=0;e<s;e++){let t=new Array(6),a=f*f*u._getFormatByteCount();for(let e=0;e<6;e++)t[e]=new Uint8Array(r,_,a),_+=a;u.updateSubPixelsData(t,0,0,f,f,e,!1,!1,!1),f/=2}let m=e.obsoluteInst;return m&&m instanceof t.TextureCube&&(u=this.move(m,u)),u}):e.loader.fetch(e.url,"json",e.progress.createCallback(.2),e.options).then(r=>{if(!r)return null;let a=t.URL.getPath(e.url),i=[t.URL.join(a,r.front),t.URL.join(a,r.back),t.URL.join(a,r.left),t.URL.join(a,r.right),t.URL.join(a,r.up),t.URL.join(a,r.down)];return Promise.all(i.map(t=>t?e.loader.fetch(t,"image",e.progress.createCallback(),e.options):Promise.resolve(null))).then(r=>{var a,i;let n=e.options.constructParams,s=n?n[0]:null!==(i=null===(a=r[0])||void 0===a?void 0:a.width)&&void 0!==i?i:1,o=n?n[1]:t.TextureFormat.R8G8B8A8,l=!!n&&n[3],h=!n||n[5],d=new t.TextureCube(s,o,l,h);d.setImageData(r,!1,!1);let c=e.obsoluteInst;return c&&c instanceof t.TextureCube&&(d=this.move(c,d)),d})})}move(e,r){return e._texture=r._texture,e._format=r.format,e.width=r.width,e.height=r.height,e.obsolute=!1,delete t.Resource._idResourcesMap[r.id],e}}t.Loader.registerLoader(["ltc","ltcb","ltcb.ls","cubemap"],mi,t.Loader.TEXTURECUBE);var gi={};class pi{constructor(){gi||(gi={default:t.Texture2DArray.defaultTexture})}load(e){if(-1!=e.url.indexOf("internal/")){const r=gi[t.Utils.getBaseName(e.url)];if(r)return Promise.resolve(r)}return e.loader.fetch(e.url,"json",e.progress.createCallback(),e.options).then(r=>{if(!r)return null;let a=r.width,i=r.height,n=r.depth,s=r.format,o=r.mipmap,l=r.sRGB,h=!!r.premultiplyAlpha,d=!!r.invertY,c=r.textures,u=[],_=t.URL.getPath(e.url);for(let e=c.length-1;e>=0;e--)u.unshift(t.URL.join(_,c[e]));let f=e.options;return Promise.all(u.map(r=>r?e.loader.fetch(r,"image",e.progress.createCallback(),e.options).then(e=>t.LayaGL.textureContext.needBitmap?e instanceof ImageBitmap?e:createImageBitmap(e,f.workerLoaderOptions||{premultiplyAlpha:h?"premultiply":"none"}):e):Promise.resolve(null))).then(e=>{if(t.LayaGL.renderEngine.getCapable(t.RenderCapable.Texture3D)){let r=new t.Texture2DArray(a,i,n,s,o,l);return r.setImageData(e,h,d),r}return null})})}}t.Loader.registerLoader(["tex2darray"],pi,t.Loader.TEXTURE2DARRAY);t.Loader.registerLoader(["lavm"],class{load(e){return e.loader.fetch(e.url,"json",e.progress.createCallback(),e.options).then(e=>e?new ni(e):null)}});t.Loader.registerLoader(["controller"],class{load(e){return e.loader.fetch(e.url,"json",e.progress.createCallback(.2),e.options).then(t=>{let r=new li(t);if(r.data&&r.data.controllerLayers){let t=r.data.controllerLayers,a=[];for(let r=t.length-1;r>=0;r--){t[r].avatarMask&&this.loadAvatarMask(t[r],a,e);let i=t[r].states;this.loadStates(i,a,e)}return Promise.all(a).then(e=>(r.addDeps(e),r))}return r})}loadAvatarMask(e,r,a){let i=t.URL.getPath(a.url);if(e.avatarMask&&e.avatarMask._$uuid&&""!=e.avatarMask._$uuid){let n=t.URL.getResURLByUUID(e.avatarMask._$uuid);n.startsWith("res://")||(n=t.URL.join(i,n)),r.push(a.loader.load(n).then(t=>(e.avatarMask=t,t)))}else e.avatarMask=null}loadStates(e,r,a){let i=t.URL.getPath(a.url);for(let n=e.length-1;n>=0;n--){if(e[n].clip&&e[n].clip._$uuid){let s=t.URL.getResURLByUUID(e[n].clip._$uuid);s.startsWith("res://")||(s=t.URL.join(i,s)),r.push(a.loader.load(s).then(t=>(e[n].clip=t,t)))}e[n].states&&this.loadStates(e[n].states,r,a)}}});class Si{constructor(){this.succeeded=!1,this.collider=null,this.point=new t.Vector3,this.normal=new t.Vector3,this.hitFraction=0,this._inPool=!1}}const Ti=new t.Vector2,Ai=new ke(new t.Vector3,new t.Vector3),Ei=new Si;t.InputManager.prototype.getSprite3DUnderPoint=function(r,a){Ei.succeeded=!1;var i=r*=this._stage.clientScaleX,n=a*=this._stage.clientScaleY,s=r/t.Browser.mainCanvas.source.width,o=a/t.Browser.mainCanvas.source.height;r=this._stage.width*s,a=this._stage.height*o,Ti.setValue(r,a);for(let r of this._stage._scene3Ds){let a=r._physicsManager,s=r._UI3DManager,o=r._cameraPool;for(let r=o.length-1;r>=0;r--){let l=o[r],h=l.viewport,d=t.Config3D.pixelRatio;if(i>=h.x&&n>=h.y&&i<=h.width/d+h.x&&n<=h.height/d+h.y){l.viewportPointToRay(Ti,Ai);let t=s.rayCast(Ai);if(t)return t;if(!a)continue;if(a.rayCast(Ai,Ei)||l.clearFlag===e.CameraClearFlags.SolidColor||l.clearFlag===e.CameraClearFlags.Sky)break}}if(Ei.succeeded)return Ei.collider.owner}return null};class Di{static parse(e,t,r,a){Di._mesh=r,Di._subMeshes=a,Di._version=t,Di._readData=e,Di.READ_DATA(),Di.READ_BLOCK(),Di.READ_STRINGS();for(var i=0,n=Di._BLOCK.count;i<n;i++){Di._readData.pos=Di._BLOCK.blockStarts[i];var s=Di._readData.readUint16(),o=Di._strings[s],l=Di["READ_"+o];if(null==l)throw new Error("model file err,no this function:"+s+" "+o);l.call(null)}Di._strings.length=0,Di._readData=null,Di._version=null,Di._mesh=null,Di._subMeshes=null}static _readString(){return Di._strings[Di._readData.readUint16()]}static READ_DATA(){Di._DATA.offset=Di._readData.readUint32(),Di._DATA.size=Di._readData.readUint32()}static READ_BLOCK(){for(var e=Di._BLOCK.count=Di._readData.readUint16(),t=Di._BLOCK.blockStarts=[],r=Di._BLOCK.blockLengths=[],a=0;a<e;a++)t.push(Di._readData.readUint32()),r.push(Di._readData.readUint32())}static READ_STRINGS(){var e=Di._readData.readUint32(),t=Di._readData.readUint16(),r=Di._readData.pos;Di._readData.pos=e+Di._DATA.offset;for(var a=0;a<t;a++)Di._strings[a]=Di._readData.readUTFString();Di._readData.pos=r}static READ_MESH(){Di._readString();var e,r=Di._readData.rawBuffer,a=0,i=Di._readData.readInt16(),n=Di._DATA.offset;for(e=0;e<i;e++){var s,o=n+Di._readData.readUint32(),l=Di._readData.readUint32(),h=r.slice(o,o+l),d=new Float32Array(h),c=Di._readString();switch(Di._version){case"LAYAMODEL:0301":case"LAYAMODEL:0400":s=t.VertexMesh.getVertexDeclaration(c);break;case"LAYAMODEL:0401":s=t.VertexMesh.getVertexDeclaration(c,!1);break;default:throw new Error("LoadModelV03: unknown version.")}if(!s)throw new Error("LoadModelV03: unknown vertexDeclaration.");var u=T.renderOBJCreate.createVertexBuffer3D(4*d.length,t.BufferUsage.Static,!0);u.vertexDeclaration=s,u.setData(d.buffer),Di._mesh._vertexBuffer=u,Di._mesh._vertexCount+=u._byteLength/s.vertexStride,a+=4*d.length}var _=n+Di._readData.readUint32(),f=Di._readData.readUint32(),m=new Uint16Array(r.slice(_,_+f)),g=T.renderOBJCreate.createIndexBuffer3D(t.IndexFormat.UInt16,f/2,t.BufferUsage.Static,!0);g.setData(m),Di._mesh._indexBuffer=g,a+=2*g.indexCount,Di._mesh._setBuffer(Di._mesh._vertexBuffer,g),Di._mesh._setCPUMemory(a),Di._mesh._setGPUMemory(a);var p=Di._mesh._boneNames=[],S=Di._readData.readUint16();for(p.length=S,e=0;e<S;e++)p[e]=Di._strings[Di._readData.readUint16()];Di._readData.pos+=8;var A=Di._readData.readUint32(),E=Di._readData.readUint32(),D=new Float32Array(r.slice(n+A,n+A+E)),R=D.length,x=Di._mesh._inverseBindPosesBuffer=new ArrayBuffer(4*R);for(Di._mesh._inverseBindPoses=[],Di._mesh._instanceBufferStateType=0!=R?gr.MESH_INSTANCEBUFFER_TYPE_SIMPLEANIMATOR:gr.MESH_INSTANCEBUFFER_TYPE_NORMAL,e=0;e<R;e+=16){var y=new t.Matrix4x4(D[e+0],D[e+1],D[e+2],D[e+3],D[e+4],D[e+5],D[e+6],D[e+7],D[e+8],D[e+9],D[e+10],D[e+11],D[e+12],D[e+13],D[e+14],D[e+15],new Float32Array(x,4*e,16));Di._mesh._inverseBindPoses[e/16]=y}return!0}static READ_SUBMESH(){var e=Di._readData.rawBuffer,t=new fr(Di._mesh);Di._readData.readInt16(),Di._readData.readUint32(),Di._readData.readUint32();var r=Di._readData.readUint32(),a=Di._readData.readUint32(),i=Di._mesh._indexBuffer;t._indexBuffer=i,t._setIndexRange(r,a);var n=Di._mesh._vertexBuffer;t._vertexBuffer=n;var s=Di._DATA.offset,o=t._subIndexBufferStart,l=t._subIndexBufferCount,h=t._boneIndicesList,d=Di._readData.readUint16();o.length=d,l.length=d,h.length=d;var c=Di._mesh._skinnedMatrixCaches,u=Di._subMeshes.length;c.length=Di._mesh._inverseBindPoses.length;for(var _=0;_<d;_++){o[_]=Di._readData.readUint32(),l[_]=Di._readData.readUint32();for(var f=Di._readData.readUint32(),m=Di._readData.readUint32(),g=h[_]=new Uint16Array(e.slice(s+f,s+f+m)),p=g.length,S=0;S<p;S++){var T=g[S];c[T]||(c[T]=new mr(u,_,S))}}return Di._subMeshes.push(t),!0}}Di._BLOCK={count:0},Di._DATA={offset:0,size:0},Di._strings=[];class Ri{constructor(){this.fullWeight=1}}class xi{constructor(){this.targetCount=0,this.targets=new Array}getTargetByIndex(e){return this.targets[e]}addTarget(e){this.targetCount++,this.targets.push(e),this.targets.sort((e,t)=>e.fullWeight-t.fullWeight)}}class yi{constructor(){this.targets=new Array,this.channels=new Array,this.bounds=new M,this.params=new t.Vector4}addMorphChannel(e){e._index=this.channels.length,this.channels.push(e),e.targets.forEach(e=>{e._index=this.targets.length,this.targets.push(e)})}getMorphChannel(e){return this.channels.find(t=>t.name==e)}getMorphChannelbyIndex(e){return this.channels[e]}get targetCount(){return this.targets.length}get channelCount(){return this.channels.length}initData(){if(t.LayaGL.renderEngine.getCapable(t.RenderCapable.Texture3D)){let e=this.targets.length,r=t.LayaGL.renderEngine.getParams(t.RenderParams.MAX_Texture_Size),a=this.vertexCount,i=this.vertexDec,n=i.vertexStride/4,s=i.vertexElementCount;this.elementCount=s;let o=Math.floor(s*a/r)+1,l=4;this.targetTexture=new t.Texture2DArray(r,o,e,t.TextureFormat.R32G32B32A32,!1,!1,!1),this.targetTexture.filterMode=t.FilterMode.Point,this.targetTexture.anisoLevel=1,this.targetTexture.lock=!0;let h=new Float32Array(r*o*e*l).fill(0),d=this.attributeOffset=new t.Vector4(0,0,0,0);d.x=i._vertexElements.indexOf(i.getVertexElementByUsage(t.VertexMesh.MESH_POSITION0)),d.y=i._vertexElements.indexOf(i.getVertexElementByUsage(t.VertexMesh.MESH_NORMAL0)),d.z=i._vertexElements.indexOf(i.getVertexElementByUsage(t.VertexMesh.MESH_TANGENT0));let c=r*o;for(let r=0;r<e;r++){let e=this.targets[r];for(let o=0;o<a;o++){let a=(r*c+o*s)*l;i._vertexElements.forEach((r,i)=>{let s=a+4*i,l=r.offset/4,d=o*n+l;switch(r.elementUsage){case t.VertexMesh.MESH_POSITION0:case t.VertexMesh.MESH_NORMAL0:h[s]=e.data[d],h[s+1]=e.data[d+1],h[s+2]=e.data[d+2];break;case t.VertexMesh.MESH_TANGENT0:h[s]=e.data[d],h[s+1]=e.data[d+1],h[s+2]=e.data[d+2],h[s+3]=e.data[d+3]}})}}this.targetTexture.setPixelsData(h,!1,!1),this.params.setValue(this.targetTexture.width,this.targetTexture.height,this.elementCount,this.channelCount)}}destroy(){this.targetTexture&&(this.targetTexture.lock=!1,this.targetTexture.destroy(),this.targetTexture=null),this.targets=null,this.channels=null}clone(){let e=new yi;e.bounds.setMin(this.bounds.getMin()),e.bounds.setMax(this.bounds.getMax()),e.vertexCount=this.vertexCount,e.vertexDec=this.vertexDec;let t=this.channelCount;for(let r=0;r<t;r++){let t=this.getMorphChannelbyIndex(r),a=new xi;a.name=t.name;let i=t.targetCount;for(let e=0;e<i;e++){let r=t.getTargetByIndex(e),i=new Ri;i.name=r.name,i.fullWeight=r.fullWeight,i.data=new Float32Array(r.data),a.addTarget(i)}e.addMorphChannel(a)}return e.initData(),e}}class Mi{static parse(e,t,r,a){Mi._mesh=r,Mi._subMeshes=a,Mi._version=t,Mi._readData=e,Mi.READ_DATA(),Mi.READ_BLOCK(),Mi.READ_STRINGS();for(var i=0,n=Mi._BLOCK.count;i<n;i++){Mi._readData.pos=Mi._BLOCK.blockStarts[i];var s=Mi._readData.readUint16(),o=Mi._strings[s],l=Mi["READ_"+o];null==l?console.warn("model file err,no this function:"+s+" "+o):l.call(null)}Mi._strings.length=0,Mi._readData=null,Mi._version=null,Mi._mesh=null,Mi._subMeshes=null}static _readString(){return Mi._strings[Mi._readData.readUint16()]}static READ_DATA(){Mi._DATA.offset=Mi._readData.readUint32(),Mi._DATA.size=Mi._readData.readUint32()}static READ_BLOCK(){for(var e=Mi._BLOCK.count=Mi._readData.readUint16(),t=Mi._BLOCK.blockStarts=[],r=Mi._BLOCK.blockLengths=[],a=0;a<e;a++)t.push(Mi._readData.readUint32()),r.push(Mi._readData.readUint32())}static READ_STRINGS(){var e=Mi._readData.readUint32(),t=Mi._readData.readUint16(),r=Mi._readData.pos;Mi._readData.pos=e+Mi._DATA.offset;for(var a=0;a<t;a++)Mi._strings[a]=Mi._readData.readUTFString();Mi._readData.pos=r}static READ_MESH(){var e,r=0;Mi._readString();var a=Mi._readData,i=a.rawBuffer,n=a.readInt16(),s=Mi._DATA.offset;for(e=0;e<n;e++){var o,l,h,d=s+a.readUint32(),c=a.readUint32(),u=Mi._readString(),_=t.VertexMesh.getVertexDeclaration(u,!1),f=_.vertexStride,m=u.split(","),g=m.length,p=Mi._mesh;switch(Mi._version){case"LAYAMODEL:05":case"LAYAMODEL:0501":case"LAYAMODEL:0502":o=i.slice(d,d+c*f),l=new Float32Array(o),h=new Uint8Array(o);break;case"LAYAMODEL:COMPRESSION_05":case"LAYAMODEL:COMPRESSION_0501":o=new ArrayBuffer(f*c),l=new Float32Array(o),h=new Uint8Array(o);var S=a.pos;a.pos=d;for(var A=0;A<c;A++)for(var E,D=A*f,R=0;R<g;R++)switch(m[R]){case"POSITION":l[E=D/4]=t.HalfFloatUtils.convertToNumber(a.readUint16()),l[E+1]=t.HalfFloatUtils.convertToNumber(a.readUint16()),l[E+2]=t.HalfFloatUtils.convertToNumber(a.readUint16()),D+=12;break;case"NORMAL":l[E=D/4]=a.readUint8()/127.5-1,l[E+1]=a.readUint8()/127.5-1,l[E+2]=a.readUint8()/127.5-1,D+=12;break;case"COLOR":case"BLENDWEIGHT":l[E=D/4]=a.readUint8()/255,l[E+1]=a.readUint8()/255,l[E+2]=a.readUint8()/255,l[E+3]=a.readUint8()/255,D+=16;break;case"UV":case"UV1":l[E=D/4]=t.HalfFloatUtils.convertToNumber(a.readUint16()),l[E+1]=t.HalfFloatUtils.convertToNumber(a.readUint16()),D+=8;break;case"BLENDINDICES":h[D]=a.readUint8(),h[D+1]=a.readUint8(),h[D+2]=a.readUint8(),h[D+3]=a.readUint8(),D+=4;break;case"TANGENT":l[E=D/4]=a.readUint8()/127.5-1,l[E+1]=a.readUint8()/127.5-1,l[E+2]=a.readUint8()/127.5-1,l[E+3]=a.readUint8()/127.5-1,D+=16}a.pos=S}var x=T.renderOBJCreate.createVertexBuffer3D(o.byteLength,t.BufferUsage.Static,!0);x.vertexDeclaration=_,x.setData(o);c=x._byteLength/_.vertexStride;p._indexFormat=c>65535?t.IndexFormat.UInt32:t.IndexFormat.UInt16,p._vertexBuffer=x,p._vertexCount+=c,r+=4*l.length}var y,M=s+a.readUint32(),C=a.readUint32();y=p.indexFormat==t.IndexFormat.UInt32?new Uint32Array(i.slice(M,M+C)):new Uint16Array(i.slice(M,M+C));var v=T.renderOBJCreate.createIndexBuffer3D(p.indexFormat,y.length,t.BufferUsage.Static,!0);if(v.setData(y),p._indexBuffer=v,p._setBuffer(p._vertexBuffer,v),r+=y.byteLength,p._setCPUMemory(r),p._setGPUMemory(r),"LAYAMODEL:0501"==Mi._version||"LAYAMODEL:COMPRESSION_0501"==Mi._version||"LAYAMODEL:0502"==Mi._version){var I=p.bounds,w=I.getMin(),B=I.getMax();w.setValue(a.readFloat32(),a.readFloat32(),a.readFloat32()),B.setValue(a.readFloat32(),a.readFloat32(),a.readFloat32()),I.setMin(w),I.setMax(B),p.bounds=I}var P=p._boneNames=[],L=a.readUint16();for(P.length=L,e=0;e<L;e++)P[e]=Mi._strings[a.readUint16()];var F=a.readUint32(),N=a.readUint32(),O=new Float32Array(i.slice(s+F,s+F+N)),b=O.length,V=p._inverseBindPosesBuffer=new ArrayBuffer(4*b);for(p._inverseBindPoses=[],p._instanceBufferStateType=0!=b?gr.MESH_INSTANCEBUFFER_TYPE_SIMPLEANIMATOR:gr.MESH_INSTANCEBUFFER_TYPE_NORMAL,e=0;e<b;e+=16){var U=new t.Matrix4x4(O[e+0],O[e+1],O[e+2],O[e+3],O[e+4],O[e+5],O[e+6],O[e+7],O[e+8],O[e+9],O[e+10],O[e+11],O[e+12],O[e+13],O[e+14],O[e+15],new Float32Array(V,4*e,16));p._inverseBindPoses[e/16]=U}return!0}static READ_SUBMESH(){var e=Mi._readData,t=e.rawBuffer,r=new fr(Mi._mesh);e.readInt16();var a=e.readUint32(),i=e.readUint32(),n=Mi._mesh._indexBuffer;r._indexBuffer=n,r._setIndexRange(a,i);var s=Mi._mesh._vertexBuffer;r._vertexBuffer=s;var o=Mi._DATA.offset,l=r._subIndexBufferStart,h=r._subIndexBufferCount,d=r._boneIndicesList,c=e.readUint16();l.length=c,h.length=c,d.length=c;var u=Mi._mesh._skinnedMatrixCaches,_=Mi._subMeshes.length;u.length=Mi._mesh._inverseBindPoses.length;for(var f=0;f<c;f++){l[f]=e.readUint32(),h[f]=e.readUint32();for(var m=e.readUint32(),g=e.readUint32(),p=d[f]=new Uint16Array(t.slice(o+m,o+m+g)),S=0,T=p.length;S<T;S++){var A=p[S];u[A]||(u[A]=new mr(_,f,S))}}return Mi._subMeshes.push(r),!0}static READ_MORPH(){let e=Mi._readData,r=e.rawBuffer,a=Mi._DATA.offset,i=Mi._mesh,n=i.morphTargetData=new yi,s=Mi._strings[e.readUint16()];n.vertexDec=t.VertexMesh.getVertexDeclaration(s);let o=n.bounds,l=o.getMin(),h=o.getMax();l.set(e.readFloat32(),e.readFloat32(),e.readFloat32()),h.set(e.readFloat32(),e.readFloat32(),e.readFloat32()),o.setMin(l),o.setMax(h);let d=e.readUint16();for(let t=0;t<d;t++){let t=new xi;t.name=Mi._strings[e.readUint16()];let i=e.readUint16();for(let n=0;n<i;n++){let i=new Ri,n=Mi._strings[e.readUint16()];i.name=n,i.fullWeight=e.readFloat32();let s=e.readUint32(),o=e.readUint32();i.data=new Float32Array(r.slice(a+s,a+s+o)),t.addTarget(i)}n.addMorphChannel(t)}return n.vertexCount=i.vertexCount,n.initData(),!0}static READ_UVSIZE(){Mi._mesh._width=Mi._readData.readUint16(),Mi._mesh._height=Mi._readData.readUint16()}}Mi._BLOCK={count:0},Mi._DATA={offset:0,size:0},Mi._strings=[];class Ci{static parse(e,t){var r=new gr;let a=r._subMeshes;switch(t){case"LAYAMODEL:0301":case"LAYAMODEL:0400":case"LAYAMODEL:0401":Di.parse(e,t,r,a);break;case"LAYAMODEL:05":case"LAYAMODEL:COMPRESSION_05":case"LAYAMODEL:0501":case"LAYAMODEL:COMPRESSION_0501":case"LAYAMODEL:0502":Mi.parse(e,t,r,a);break;default:throw new Error("unknown mesh version: "+t)}return r._setSubMeshes(a),"LAYAMODEL:0501"!=t&&"LAYAMODEL:COMPRESSION_0501"!=t&&"LAYAMODEL:0502"!=t&&r.calculateBounds(),r}static _parse(e){var t=new gr;return Ci.read(e,t,t._subMeshes),t}static read(e,r,a){var i=new t.Byte(e);i.pos=0;var n=i.readUTFString();switch(n){case"LAYAMODEL:0301":case"LAYAMODEL:0400":case"LAYAMODEL:0401":Di.parse(i,n,r,a);break;case"LAYAMODEL:05":case"LAYAMODEL:COMPRESSION_05":case"LAYAMODEL:0501":case"LAYAMODEL:COMPRESSION_0501":case"LAYAMODEL:0502":Mi.parse(i,n,r,a);break;default:throw new Error("unknown mesh version: "+n)}r._setSubMeshes(a),"LAYAMODEL:0501"!=n&&"LAYAMODEL:COMPRESSION_0501"!=n&&"LAYAMODEL:0502"!=n&&r.calculateBounds()}}t.MeshLoader.v3d=Ci;let vi=t.ClassUtils.regClass;vi("Sprite3D",R),vi("Scene3D",hr),vi("Camera",tr),vi("LightSprite",ua),vi("AreaLightCom",va),vi("DirectionLightCom",xa),vi("PointLightCom",ya),vi("SpotLightCom",Ma),vi("RenderableSprite3D",y),vi("MeshSprite3D",X),vi("MeshFilter",D),vi("BaseRender",z),vi("MeshRenderer",Y),vi("SimpleSkinnedMeshSprite3D",Qr),vi("SkinnedMeshSprite3D",ma),vi("SkinnedMeshRenderer",zr),vi("SimpleSkinnedMeshRenderer",Wr),vi("SkyRenderer",Be),vi("PixelLineRenderer",Oa),vi("PixelLineData",Pa),vi("Transform3D",Se),vi("Lightmap",Ve),vi("ReflectionProbe",G),vi("VolumetricGI",V),vi("SphericalHarmonicsL2",ga),vi("Viewport",t.Viewport),vi("Bounds",M),vi("BoundBox",Ea),vi("TextureCube",t.TextureCube),vi("Mesh",gr),vi("RenderTexture",t.RenderTexture),vi("Animator",ai),vi("AnimatorController",li),vi("AnimatorControllerLayer",Va),vi("AnimatorState",ii),vi("AnimationClip",ca),vi("AvatarMask",ni),vi("UI3D",ci),vi("Material",t.Material),vi("BlinnPhongMaterial",r),vi("EffectMaterial",_a),vi("ExtendTerrainMaterial",fa),vi("PBRStandardMaterial",m),vi("SkyBoxMaterial",g),vi("SkyPanoramicMaterial",Yr),vi("SkyProceduralMaterial",p),vi("UnlitMaterial",S),vi("LODInfo",wa),vi("LODGroup",Ba),vi("DirectionLightCom",xa),vi("MeshRenderer",Y),vi("MeshFilter",D),vi("MeshRenderer",Y),vi("SkinnedMeshRenderer",zr),vi("SimpleSkinnedMeshRenderer",Wr),vi("SkyRenderer",Be),vi("PostProcess",Qt),vi("PostProcessEffect",si),ri.__managerName;class Ii extends tr{constructor(){super(...arguments),this.isWebXR=!0}get renderTarget(){return this._internalRenderTexture}set renderTarget(e){this._internalRenderTexture=e}set clientWidth(e){this._clientWidth=e}set clientHeight(e){this._clientHeight=e}get clientWidth(){return this._clientWidth}get clientHeight(){return this._clientHeight}_restoreView(e){var t,r,a=this.viewport,i=a.width,n=a.height;this._needInternalRenderTexture()?(t=0,r=0):(t=a.x,r=this._getCanvasHeight()-a.y-n),e.viewport(t,r,i,n)}render(){if(this.activeInHierarchy){this.viewport;var e=J._instance;e.scene=this._scene,e.pipelineMode=e.configPipeLineMode}}_renderMainPass(e,t,r,a,i,n){}_calculateProjectionMatrix(){}clear(e){e.viewport(0,0,this._clientWidth,this._clientHeight),e.scissor(0,0,this._clientWidth,this._clientHeight),e.clearColor(this.clearColor.r,this.clearColor.g,this.clearColor.b,this.clearColor.a),e.depthMask(!0),e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT)}destroy(){super.destroy(!0)}}class wi extends t.RenderTexture{constructor(){super(1,1,1,t.RenderTargetFormat.STENCIL_8,!1,1),this.frameLoop=-1}set frameBuffer(e){this._frameBuffer=e}_create(e,t){}}class Bi extends t.EventDispatcher{constructor(){super(),this.currentTimestamp=-1,this.defaultHeightCompensation=1.7,this._sessionEnded=!1}get referenceSpace(){return this._referenceSpace}set referenceSpace(e){this._referenceSpace=e}get sessionMode(){return this._sessionMode}exitXR(){this.endXRRenderLoop(),this.event(Bi.EVENT_MANAGER_END)}initializeXRGL(e,t){return t.makeXRCompatible().then(()=>!0)}initializeAsync(){return this._xrNavigator=navigator,this._xrNavigator.xr?Promise.resolve():Promise.reject("WebXR not available")}isSessionSupportedAsync(e){if(!navigator.xr)return Promise.resolve(!1);this._xrNavigator=navigator;return navigator.xr.isSessionSupported||navigator.xr.supportsSession?navigator.xr.isSessionSupported(e):Promise.resolve(!1)}initializeSessionAsync(e="immersive-vr",t={}){return this._xrNavigator.xr.requestSession("immersive-vr").then(t=>(this.session=t,this._sessionMode=e,this._sessionEnded=!1,this.session.addEventListener("end",()=>{this._sessionEnded=!0,this.exitXR()},{once:!0}),this.session))}resetReferenceSpace(){this.referenceSpace=this.baseReferenceSpace}runXRRenderLoop(){this.session.requestAnimationFrame.bind(this.session);let e=(r,a)=>{this._updateByXrFrame(a,r),this.event(Bi.EVENT_FRAME_LOOP,[a]),t.Render.loop(r),this.session.requestAnimationFrame(e)};this.session.requestAnimationFrame(e)}endXRRenderLoop(){}_updateByXrFrame(e,t){this.currentFrame=e,this.currentTimestamp=t}setReferenceSpaceTypeAsync(e="local-floor"){return this.session.requestReferenceSpace(e).then(e=>e,e=>this.session.requestReferenceSpace("viewer").then(e=>{const t=new XRRigidTransform({x:0,y:-this.defaultHeightCompensation,z:0});return e.getOffsetReferenceSpace(t)},e=>{throw'XR initialization failed: required "viewer" reference space type not supported.'})).then(e=>(this.referenceSpace=this.baseReferenceSpace=e,this.referenceSpace))}updateRenderStateAsync(e){return e.baseLayer&&(this._baseLayer=e.baseLayer),this.session.updateRenderState(e)}get currentFrameRate(){var e;return null===(e=this.session)||void 0===e?void 0:e.frameRate}get supportedFrameRates(){var e;return null===(e=this.session)||void 0===e?void 0:e.supportedFrameRates}updateTargetFrameRate(e){return this.session.updateTargetFrameRate(e)}destroy(){this._sessionEnded||this.exitXR()}}Bi.EVENT_MANAGER_END="xrManagerDestory",Bi.EVENT_FRAME_LOOP="xrFrameLoop";class Pi{get position(){return this._position}set position(e){e.cloneTo(this._position)}get rotationQuaternion(){return this._referenceQuaternion}set rotationQuaternion(e){e.cloneTo(this._referenceQuaternion)}get rigCameras(){return this._rigCameras}constructor(e,r=null){this._referenceQuaternion=new t.Quaternion,this._referencedPosition=new t.Vector3,this._firstFrame=!0,this._XRRenderTexture=new wi,this._rigCameras=new Array,this._position=new t.Vector3,this.owner=e,this.owner.enableRender=!1,this.owner.aspectRatio||console.warn("owner is not Camera"),this._webXRSessionManager=r,this._webXRSessionManager.on(Bi.EVENT_FRAME_LOOP,this,this._updateFromXRSession),this._webXRSessionManager.on(Bi.EVENT_FRAME_LOOP,this,this._updateReferenceSpace),this._webXRSessionManager.on(Bi.EVENT_MANAGER_END,this,this.destroy)}_updateFromXRSession(){let e=this._webXRSessionManager.currentFrame&&this._webXRSessionManager.currentFrame.getViewerPose(this._webXRSessionManager.referenceSpace);const t=e.transform.position,r=e.transform.orientation;this._referenceQuaternion.setValue(r.x,r.y,r.z,r.w),this._referencedPosition.setValue(t.x,t.y,t.z),this._firstFrame?(this._firstFrame=!1,this.position.y+=this._referencedPosition.y,this._referenceQuaternion.setValue(0,0,0,1)):(this.rotationQuaternion=this._referenceQuaternion,this.position=this._referencedPosition),this.rigCameras.length!==e.views.length&&this._updateNumberOfRigCameras(e.views.length),e.views.forEach((e,t)=>{const r=this.rigCameras[t];"right"===e.eye?r.name="right":"left"===e.eye&&(r.name="left");const a=e.transform.position,i=e.transform.orientation;if(r.transform.position.setValue(a.x,a.y,a.z),r.transform.rotation.setValue(i.x,i.y,i.z,i.w),r.transform.position=r.transform.position,r.transform.rotation=r.transform.rotation,this._webXRSessionManager.session.renderState.baseLayer){var n=this._webXRSessionManager.session.renderState.baseLayer.getViewport(e),s=this._webXRSessionManager.session.renderState.baseLayer.framebufferWidth,o=this._webXRSessionManager.session.renderState.baseLayer.framebufferHeight;this._XRRenderTexture.frameBuffer=this._webXRSessionManager.session.renderState.baseLayer.framebuffer,r.renderTarget=this._XRRenderTexture,r.clientWidth=s,r.clientHeight=o;var l=r.viewport;l.x=n.x,l.y=n.y,l.width=n.width,l.height=n.height,r.viewport=l,r.projectionMatrix.cloneByArray(e.projectionMatrix)}})}_updateNumberOfRigCameras(e=1){for(;this.rigCameras.length<e;){var t=new Ii(this.owner.aspectRatio,this.owner.nearPlane,this.owner.farPlane);t.clearFlag=this.owner.clearFlag,t.clearColor=this.owner.clearColor,this.owner.addChild(t),this.rigCameras.push(t)}for(;this.rigCameras.length>e;){let e=this.rigCameras.pop();this.owner.removeChild(e)}}_updateReferenceSpace(){}destroy(){this.owner.enableRender=!0,this._webXRSessionManager.off(Bi.EVENT_FRAME_LOOP,this,this._updateFromXRSession),this._webXRSessionManager.off(Bi.EVENT_FRAME_LOOP,this,this._updateReferenceSpace),this._webXRSessionManager.off(Bi.EVENT_MANAGER_END,this,this.destroy),this._rigCameras.forEach(e=>{e.destroy()}),this._rigCameras=null,this._XRRenderTexture.destroy()}}class Li extends t.EventDispatcher{constructor(e,t){super(),this.axisData=new Array,this.handness=e,this.axisData.length=t,this.axisLength=t}update(e){for(let r=0,a=0;r<e.axes.length;r+=2,++a)this.axisData[a]||(this.axisData[a]=new t.Vector2),this.axisData[a].setValue(e.axes[r],e.axes[r+1]),this.outPutStickValue(this.axisData[a],a)}outPutStickValue(e,t){const r=Li.EVENT_OUTPUT+t.toString();this.event(r,[e])}destroy(){for(let e=0;e<this.axisLength;e++){let t=Li.EVENT_OUTPUT+e.toString();this.offAll(t)}}}Li.EVENT_OUTPUT="outputAxi_id";class Fi extends t.EventDispatcher{constructor(e,t){super(),this.lastTouch=!1,this.lastPress=!1,this.lastPressValue=0,this.touch=!1,this.press=!1,this.pressValue=0,this.handness=e,this.index=t}update(e){this.lastTouch=this.touch,this.lastPress=this.press,this.lastPressValue=this.pressValue,this.touch=e.touched,this.press=e.pressed,this.pressValue=e.value,(this.lastTouch||this.touch)&&(this.lastTouch!=this.touch&&this.touch?this.touchEnter():this.lastTouch==this.touch&&this.touch?this.touchStay():this.lastTouch==this.touch||this.touch||this.touchOut(),this.lastPress!=this.press&&this.press?this.pressEnter():this.lastPress==this.press&&this.press?this.pressStay():this.lastPress==this.press||this.press||this.pressOut(),this.touch&&this.outpressed())}touchEnter(){this.event(Fi.EVENT_TOUCH_ENTER)}touchStay(){this.event(Fi.EVENT_TOUCH_STAY)}touchOut(){this.event(Fi.EVENT_TOUCH_OUT)}pressEnter(){this.event(Fi.EVENT_PRESS_ENTER)}pressStay(){this.event(Fi.EVENT_PRESS_STAY)}pressOut(){this.event(Fi.EVENT_PRESS_OUT)}outpressed(){this.event(Fi.EVENT_PRESS_VALUE,[this.pressValue])}destroy(){this.offAll(Fi.EVENT_PRESS_ENTER),this.offAll(Fi.EVENT_PRESS_STAY),this.offAll(Fi.EVENT_PRESS_OUT),this.offAll(Fi.EVENT_PRESS_ENTER),this.offAll(Fi.EVENT_PRESS_STAY),this.offAll(Fi.EVENT_PRESS_OUT),this.offAll(Fi.EVENT_PRESS_VALUE)}}Fi.EVENT_TOUCH_ENTER="touchEnter",Fi.EVENT_TOUCH_STAY="touchStay",Fi.EVENT_TOUCH_OUT="touchOut",Fi.EVENT_PRESS_ENTER="pressEnter",Fi.EVENT_PRESS_STAY="pressStay",Fi.EVENT_PRESS_OUT="pressOut",Fi.EVENT_PRESS_VALUE="outpressed";class Ni extends t.EventDispatcher{constructor(e){super(),this.preButtonEventList=[],this.preAxisEventList=[],this.handness=e,this.position=new t.Vector3,this.rotation=new t.Quaternion,this.ray=new ke(new t.Vector3,new t.Vector3)}_updateByXRPose(e,r){const a=e.getPose(this._inputSource.targetRaySpace,r);if(this._lastXRPose=a,a){const e=a.transform.position,r=a.transform.orientation;Ni.tempQua.setValue(r.x,r.y,r.z,r.w),this.ray.origin.setValue(e.x,e.y,e.z),t.Vector3.transformQuat(t.Vector3.UnitZ,Ni.tempQua,this.ray.direction),t.Vector3.scale(this.ray.direction,-1,this.ray.direction)}if(this._inputSource.gripSpace){let t=e.getPose(this._inputSource.gripSpace,r);if(t){const e=t.transform.position,r=t.transform.orientation;this.position.setValue(e.x,e.y,e.z),this.rotation.setValue(r.x,r.y,r.z,r.w)}}this.event(Ni.EVENT_FRAMEUPDATA_WEBXRINPUT,[this]),this._handleProcessGamepad()}_handleProcessGamepad(){const e=this._inputSource.gamepad;if(this.gamepadAxis||(this.gamepadAxis=new Li(this.handness,e.axes.length),this.preAxisEventList.forEach(e=>{this.gamepadAxis.on(e.eventnam,e.caller,e.listener)})),!this.gamepadButton){this.gamepadButton=[];for(let t=0;t<e.buttons.length;++t)this.gamepadButton.push(new Fi(this.handness,t));this.preButtonEventList.forEach(e=>{this.addButtonEvent(e.index,e.type,e.caller,e.listener)})}this.gamepadAxis.update(e);for(let t=0;t<e.buttons.length;++t){this.gamepadButton[t].update(e.buttons[t])}}addButtonEvent(e,t,r,a){if(this.gamepadButton){this.gamepadButton[e].on(t,r,a)}else this.preButtonEventList.push({index:e,type:t,caller:r,listener:a})}addAxisEvent(e,t,r,a){if(this.gamepadAxis){const i=t+e.toString();this.gamepadAxis.on(i,r,a)}else this.preAxisEventList.push({eventnam:t+e.toString(),caller:r,listener:a})}offAxisEvent(e,t,r,a){if(this.gamepadAxis){const i=t+e.toString();this.gamepadAxis.off(i,r,a)}}offButtonEvent(e,t,r,a){if(this.gamepadButton){this.gamepadButton[e].off(t,r,a)}}destroy(){this.preButtonEventList=null,this.ray=null,this.position=null,this.rotation=null,this.gamepadAxis.destroy(),this.gamepadButton.forEach(e=>{e.destroy()})}}Ni.HANDNESS_LEFT="left",Ni.HANDNESS_RIGHT="right",Ni.EVENT_FRAMEUPDATA_WEBXRINPUT="frameXRInputUpdate",Ni.tempQua=new t.Quaternion;class Oi{constructor(e,r){this.controllers=new Map,this.controllerHandMesh=new Map,this.controllerLineRender=new Map,this.lineColor=t.Color.RED,this.rayLength=2,this.webXRSessionManager=e,this.webXRCameraManager=r,this.webXRSessionManager.on(Bi.EVENT_MANAGER_END,this,this.destory),this.webXRSessionManager.on(Bi.EVENT_FRAME_LOOP,this,this._updateFromXRFrame)}_updateMeshRender(e){const r=e.handness;if(this.controllerHandMesh.has(r)){let t=this.controllerHandMesh.get(r);t.transform.position=e.position,t.transform.rotation=e.rotation}if(this.controllerLineRender.has(r)){let a=this.controllerLineRender.get(r);a.clear();let i=e.ray;bi.setValue(i.origin.x,i.origin.y,i.origin.z),t.Vector3.scale(i.direction,this.rayLength,Vi),t.Vector3.add(bi,Vi,Vi),a.addLine(bi,Vi,this.lineColor,this.lineColor)}}_updateFromXRFrame(e){const t=this.webXRSessionManager.session,r=this.webXRSessionManager.referenceSpace;for(let a of t.inputSources){const t=a.handedness;let i;i=this.controllers.has(t)?this.controllers.get(t):this.getController(t),i&&(i=this.controllers.get(t),i._inputSource=a,i._updateByXRPose(e,r))}}bindMeshNode(e,t){this.controllerHandMesh.set(t,e)}bindRayNode(e,t){this.controllerLineRender.set(t,e)}getController(e){if("left"!=e&&"right"!=e)return null;if(!this.controllers.has(e)){let t=new Ni(e);this.controllers.set(e,t),t.on(Ni.EVENT_FRAMEUPDATA_WEBXRINPUT,this,this._updateMeshRender)}return this.controllers.get(e)}destory(){this.webXRSessionManager.off(Bi.EVENT_FRAME_LOOP,this,this._updateFromXRFrame);for(let e in this.controllers)this.controllers.get(e).off("frameXRInputUpdate",this,this._updateMeshRender),this.controllers.get(e).destroy();this.controllers=null,this.controllerHandMesh=null,this.controllerLineRender=null}}const bi=new t.Vector3,Vi=new t.Vector3;class Ui{static supportXR(e){return Ui.xr_Manager.isSessionSupportedAsync(e).then(e=>(Ui.supported=e,e))}static enterXRAsync(e,r,a){return"immersive-ar"===e&&"unbounded"!==r&&console.warn("We recommend using 'unbounded' reference space type when using 'immersive-ar' session mode"),Ui.xr_Manager.initializeSessionAsync(e).then(()=>Ui.xr_Manager.setReferenceSpaceTypeAsync(r)).then(()=>Ui.xr_Manager.initializeXRGL(e,t.LayaGL.renderEngine.gl)).then(()=>(Ui.glInstance=t.LayaGL.renderEngine.gl,Ui.xr_Manager.updateRenderStateAsync({depthFar:a.depthFar,depthNear:a.depthNear,baseLayer:new XRWebGLLayer(Ui.xr_Manager.session,t.LayaGL.renderEngine.gl)}))).then(()=>(Ui.xr_Manager.runXRRenderLoop(),Ui.xr_Manager))}static setWebXRCamera(e,t){return new Pi(e,t)}static setWebXRInput(e,t){return new Oi(e,t)}}Ui.xr_Manager=new Bi,Ui.supported=!1,Ui.canvasOptions={antialias:!0,depth:!0,stencil:!1,alpha:!0,multiview:!1,framebufferScaleFactor:1};class Hi{constructor(e){this._ptTime=0,this._ptFront=!0,this._nativeEvaluator=e;const t=this._allocLayerBuffer(64);this._layerBufferI32=t.i32,this._layerBufferF32=t.f32,this._layerBufferCapRecords=t.cap;const r=this._allocSlotBuffer(32);this._slotBufferI32=r.i32,this._slotBufferCapRecords=r.cap}sync(t,r){var a,i;const n=t.length;if(0===n)return void this._nativeEvaluator.syncBatch(this._layerBufferI32,0,this._slotBufferI32,0);let s=0;for(let e=0;e<n;e++)s+=t.elements[e]._layers.length;if(s>this._layerBufferCapRecords){const e=Math.max(s,2*this._layerBufferCapRecords),t=this._allocLayerBuffer(e);this._layerBufferI32=t.i32,this._layerBufferF32=t.f32,this._layerBufferCapRecords=t.cap}if(n>this._slotBufferCapRecords){const e=Math.max(n,2*this._slotBufferCapRecords),t=this._allocSlotBuffer(e);this._slotBufferI32=t.i32,this._slotBufferCapRecords=t.cap}const o=this._layerBufferI32,l=this._layerBufferF32,h=this._slotBufferI32,d=Hi.LAYER_RECORD_WORDS,c=Hi.SLOT_RECORD_WORDS;let u=0,_=0;for(let s=0;s<n;s++){const n=t.elements[s],f=n._slotHandle;if(!f)continue;const m=r.get(n._ctx),g=n._layers;let p=!1;for(let t=0,r=g.length;t<r;t++){const r=g[t];r.type!==e.LayerTaskType.Idle&&(p=!0);const s=r.state&&m&&null!==(a=m.get(r.state))&&void 0!==a?a:0,h=r.destState&&m&&null!==(i=m.get(r.destState))&&void 0!==i?i:0;this._computePlayTime(r.state,r.playState);const c=this._ptTime,_=this._ptFront;this._computePlayTime(r.destState,r.crossPlayState);const S=this._ptTime,T=this._ptFront,A=n._ctx.layers[t],E=!(!A||A.blendingMode!==Va.BLENDINGMODE_ADDTIVE);o[u+0]=f,o[u+1]=t,o[u+2]=r.type,o[u+3]=s,o[u+4]=h,l[u+5]=r.weight,l[u+6]=r.crossWeight,l[u+7]=c,l[u+8]=S,o[u+9]=E?1:0,o[u+10]=_?1:0,o[u+11]=T?1:0,u+=d}h[_+0]=f,h[_+1]=p?1:0,_+=c}this._nativeEvaluator.syncBatch(o,u/d,h,_/c)}_computePlayTime(e,t){var r,a,i,n,s,o;if(!e||!t)return this._ptTime=0,void(this._ptFront=!0);const l=e._clip,h=null!==(r=null==l?void 0:l._duration)&&void 0!==r?r:0,d=null!==(a=e.clipStart)&&void 0!==a?a:0,c=null!==(i=t._normalizedPlayTime)&&void 0!==i?i:0,u=null!==(n=t._duration)&&void 0!==n?n:0;this._ptTime=d*h+c*u,this._ptFront=(null!==(s=t._elapsedTime)&&void 0!==s?s:0)>(null!==(o=t._lastElapsedTime)&&void 0!==o?o:0)}_allocLayerBuffer(e){const t=new ArrayBuffer(e*Hi.LAYER_RECORD_WORDS*4);return{i32:new Int32Array(t),f32:new Float32Array(t),cap:e}}_allocSlotBuffer(e){return{i32:new Int32Array(e*Hi.SLOT_RECORD_WORDS),cap:e}}}Hi.LAYER_RECORD_WORDS=12,Hi.SLOT_RECORD_WORDS=2;class Gi{constructor(){this._next=0,this._free=[]}alloc(){return this._free.length>0?this._free.pop():++this._next}free(e){e>0&&this._free.push(e)}}const ki=new Gi,zi=new Gi,Wi=new Gi,Qi=new Gi,Yi={slot:new Map,owner:new Map,binding:new Map,clip:new Map};let Xi=0;function Ki(e,t,r){const a=Yi[e],i=a.get(t);void 0!==i&&i!==r&&console.warn(`[RTAnimatorFactory] ${e} handle collision: handle=${t}, ownerFactory=${i}, newFactory=${r}`),a.set(t,r)}function ji(e,t,r){const a=Yi[e],i=a.get(t);void 0!==i&&i!==r&&console.warn(`[RTAnimatorFactory] ${e} handle release mismatch: handle=${t}, ownerFactory=${i}, releaseFactory=${r}`),a.delete(t)}class Ji{constructor(){this._factoryId=++Xi,this._slotPool=ki,this._ownerPool=zi,this._bindingPool=Wi,this._clipPool=Qi,this._slotHandles=new Set,this._ownerHandleSet=new Set,this._bindingHandles=new Set,this._clipHandles=new Set,this._ctxToSlotHandle=new WeakMap,this._clipHandleMap=new Map,this._ownerHandles=new WeakMap,this._bindingMap=new WeakMap,this._stateBindings=new WeakMap,this._syncBuffer=null,this._unregisterClipDestroyCallback=null,this._destroyed=!1,this._web=new ti;const e=window.conchRTAnimatorPreparer;"function"==typeof e?this._nativePreparer=new e:(console.warn("[RTAnimatorFactory] window.conchRTAnimatorPreparer not implemented; falling back to Web."),this._nativePreparer=null);const t=window.conchRTAnimatorEvaluator;"function"==typeof t?this._nativeEvaluator=new t:(console.warn("[RTAnimatorFactory] window.conchRTAnimatorEvaluator not implemented; falling back to Web."),this._nativeEvaluator=null);const r=window.conchRTAnimatorApplier;"function"==typeof r?this._nativeApplier=new r:(console.warn("[RTAnimatorFactory] window.conchRTAnimatorApplier not implemented; falling back to Web."),this._nativeApplier=null);const a=window.conchRTAnimatorOwnerData;ta("function"==typeof a?()=>new a:()=>new aa),window.conchLayaXTransform?this._transformBackend="layax":window.conchRTTransform?this._transformBackend="jsrt":this._transformBackend=null,this._nativeEvaluator&&(this._web._evaluator._scope="non-transform-only"),this._nativeApplier&&(this._web._applier._scope="non-transform-only"),this._unregisterClipDestroyCallback=na(e=>{this._releaseClipById(e)}),this._nativeEvaluator&&(this._syncBuffer=new Hi(this._nativeEvaluator))}bindAnimator(e){const t=this._web.bindAnimator(e);if(this._nativePreparer&&!this._ctxToSlotHandle.has(e)){const r=this._slotPool.alloc();this._ctxToSlotHandle.set(e,r),this._slotHandles.add(r),Ki("slot",r,this._factoryId),t._slotHandle=r,this._nativePreparer.uploadSlot(r),this._nativePreparer.resizeSlot(r,e.layers.length),t._onResize=e=>{this._nativePreparer.resizeSlot(r,e)}}return t}unbindAnimator(e){const t=this._ctxToSlotHandle.get(e);if(this._nativePreparer&&void 0!==t){const r=this._bindingMap.get(e);if(r){for(const[e,t]of r)this._releaseBinding(t,e);this._bindingMap.delete(e)}for(const t of e.owners.slice())this._releaseOwner(t);e.owners.length=0;for(const t in e.ownerMap)delete e.ownerMap[t];this._releaseSlot(t),this._ctxToSlotHandle.delete(e)}this._web.unbindAnimator(e)}prepareStateOwners(e,t){this._web.prepareStateOwners(e,t);const r=t._clip;if(r&&this._nativePreparer){const a=this._ensureClipUploaded(r);this._syncOwnersToNative(e,t),this._ensureBindingUploaded(e,t,a)}}_syncOwnersToNative(e,t){const r=t._nodeOwners;if(r)for(let e=0;e<r.length;e++){const t=r[e];if(!t)continue;if(!za(t.type))continue;if(this._ownerHandles.has(t))continue;const a=this._ownerPool.alloc();this._ownerHandles.set(t,a),this._ownerHandleSet.add(a),Ki("owner",a,this._factoryId),this._uploadOwner(a,t,t.propertyOwner)}}_ensureBindingUploaded(e,t,r){var a;let i=this._bindingMap.get(e);if(i||(i=new Map,this._bindingMap.set(e,i)),i.has(t))return;const n=t._nodeOwners;if(!n)return;const s=this._bindingPool.alloc();i.set(t,s),this._bindingHandles.add(s),Ki("binding",s,this._factoryId);let o=this._stateBindings.get(t);o||(o=new Set,this._stateBindings.set(t,o)),o.add(s);const l=new Uint32Array(n.length);for(let e=0;e<n.length;e++){const t=n[e];l[e]=null!==(a=t&&this._ownerHandles.get(t))&&void 0!==a?a:0}this._nativePreparer.uploadBinding(s,r,l);const h=this._findLayerAvatarMask(e,t);this._nativePreparer.uploadBindingMask(s,this._buildBindingMaskBytes(n,h))}_buildBindingMaskBytes(e,t){const r=new Uint8Array(e.length);for(let a=0;a<e.length;a++){if(!t){r[a]=1;continue}const i=e[a];r[a]=i&&null!=i.nodePath&&t.getTransformActive(i.nodePath)?1:0}return r}_findLayerAvatarMask(e,t){var r;const a=e.layers;for(let e=0,i=a.length;e<i;e++)if(a[e]._states.indexOf(t)>=0)return null!==(r=a[e].avatarMask)&&void 0!==r?r:null;return null}_ensureClipUploaded(e){var t,r;const a=this._clipHandleMap.get(e._id);if(void 0!==a)return a;const i=this._clipPool.alloc();this._clipHandleMap.set(e._id,i),this._clipHandles.add(i),Ki("clip",i,this._factoryId);const n=this._nativePreparer,s=e._nodes,o=s?s.count:0;if(n.beginUploadClip(i,null!==(t=e._duration)&&void 0!==t?t:0,null!==(r=e._frameRate)&&void 0!==r?r:0,e.islooping,o),s)for(let e=0;e<o;e++)this._uploadCurve(i,e,s.getNodeByIndex(e));return i}_uploadCurve(e,t,r){const a=this._nativePreparer,i=r._joinOwnerPath("/"),n=r._joinProperty("/"),s=r.keyFramesCount;let o=!1;if(s>0){const e=r.getKeyframeByIndex(0);o=e&&null!=e.weightedMode}a.uploadCurveHeader(e,t,r.type,i,n,s,o);for(let a=0;a<s;a++)this._uploadKeyframe(e,t,a,r.type,r.getKeyframeByIndex(a),o)}_uploadKeyframe(t,r,a,i,n,s){var o,l,h,d,c,u;const _=this._nativePreparer;switch(i){case e.KeyFrameValueType.Float:case e.KeyFrameValueType.Boolean:_.uploadKfFloat(t,r,a,n.time,null!==(o=n.value)&&void 0!==o?o:0,null!==(l=n.inTangent)&&void 0!==l?l:0,null!==(h=n.outTangent)&&void 0!==h?h:0,null!==(d=n.weightedMode)&&void 0!==d?d:0,null!==(c=n.inWeight)&&void 0!==c?c:.33333,null!==(u=n.outWeight)&&void 0!==u?u:.33333);break;case e.KeyFrameValueType.Vector2:{const e=n.value,i=n.inTangent,o=n.outTangent;if(_.uploadKfV2(t,r,a,n.time,e.x,e.y,i.x,i.y,o.x,o.y),s&&n.weightedMode){const e=n.inWeight,i=n.outWeight,s=n.weightedMode;_.uploadKfV2Weight(t,r,a,e.x,e.y,i.x,i.y,s.x,s.y)}break}case e.KeyFrameValueType.Position:case e.KeyFrameValueType.Scale:case e.KeyFrameValueType.RotationEuler:case e.KeyFrameValueType.Vector3:{const e=n.value,i=n.inTangent,o=n.outTangent;if(_.uploadKfV3(t,r,a,n.time,e.x,e.y,e.z,i.x,i.y,i.z,o.x,o.y,o.z),s&&n.weightedMode){const e=n.inWeight,i=n.outWeight,s=n.weightedMode;_.uploadKfV3Weight(t,r,a,e.x,e.y,e.z,i.x,i.y,i.z,s.x,s.y,s.z)}break}case e.KeyFrameValueType.Vector4:case e.KeyFrameValueType.Color:{const e=n.value,i=n.inTangent,o=n.outTangent;if(_.uploadKfV4(t,r,a,n.time,e.x,e.y,e.z,e.w,i.x,i.y,i.z,i.w,o.x,o.y,o.z,o.w),s&&n.weightedMode){const e=n.inWeight,i=n.outWeight,s=n.weightedMode;_.uploadKfV4Weight(t,r,a,e.x,e.y,e.z,e.w,i.x,i.y,i.z,i.w,s.x,s.y,s.z,s.w)}break}case e.KeyFrameValueType.Rotation:{const e=n.value,i=n.inTangent,o=n.outTangent;if(_.uploadKfQuat(t,r,a,n.time,e.x,e.y,e.z,e.w,i.x,i.y,i.z,i.w,o.x,o.y,o.z,o.w),s&&n.weightedMode){const e=n.inWeight,i=n.outWeight,s=n.weightedMode;_.uploadKfQuatWeight(t,r,a,e.x,e.y,e.z,e.w,i.x,i.y,i.z,i.w,s.x,s.y,s.z,s.w)}break}}}handleSpriteOwnersBySprite(e,t,r,a){if(this._web.handleSpriteOwnersBySprite(e,t,r,a),!this._nativePreparer&&!this._nativeApplier)return;const i=this._bindingMap.get(e);if(i)for(const t of i.keys())this._nativePreparer&&this._syncOwnersToNative(e,t)}addKeyframeNodeOwner(e,t,r,a){if(this._web.addKeyframeNodeOwner(e,t,r,a),!this._nativePreparer)return;if(!za(r.type))return;const i=t[r._indexInList];if(!i)return;if(this._ownerHandles.has(i))return;const n=this._ownerPool.alloc();this._ownerHandles.set(i,n),this._ownerHandleSet.add(n),Ki("owner",n,this._factoryId),this._uploadOwner(n,i,a)}_uploadOwner(t,r,a){var i,n;const s=this._nativePreparer,o=null!==(i=r.nodePath)&&void 0!==i?i:"",l=(null!==(n=r.property)&&void 0!==n?n:[]).join("/");s.uploadOwnerHeader(t,r.type,!!r.maskActive,o,l);const h=a?a._nativeObj:null;h&&"layax"===this._transformBackend?s.bindOwnerLayaXTransform(t,h):h&&"jsrt"===this._transformBackend&&s.bindOwnerJSRTTransform(t,h);const d=r.defaultValue;if(null!=d)switch(r.type){case e.KeyFrameValueType.Position:case e.KeyFrameValueType.Scale:case e.KeyFrameValueType.RotationEuler:s.setOwnerDefaultV3(t,d.x,d.y,d.z);break;case e.KeyFrameValueType.Rotation:s.setOwnerDefaultQuat(t,d.x,d.y,d.z,d.w)}}removeKeyframeNodeOwner(e,t,r){const a=r.fullPath,i=e.ownerMap[a];if(this._web.removeKeyframeNodeOwner(e,t,r),!this._nativePreparer)return;if(!i||!za(i.type))return;if(0!==i.referenceCount)return;void 0!==this._ownerHandles.get(i)&&this._releaseOwner(i)}_releaseSlot(e){var t;this._slotHandles.has(e)&&(null===(t=this._nativePreparer)||void 0===t||t.releaseSlot(e),this._slotHandles.delete(e),ji("slot",e,this._factoryId),this._slotPool.free(e))}_releaseBinding(e,t){var r;if(this._bindingHandles.has(e)&&(null===(r=this._nativePreparer)||void 0===r||r.releaseBinding(e),this._bindingHandles.delete(e),ji("binding",e,this._factoryId),this._bindingPool.free(e),t)){const r=this._stateBindings.get(t);r&&(r.delete(e),0===r.size&&this._stateBindings.delete(t))}}_releaseOwner(e){const t=this._ownerHandles.get(e);void 0!==t&&(this._ownerHandles.delete(e),this._releaseOwnerHandle(t))}_releaseOwnerHandle(e){var t,r;this._ownerHandleSet.has(e)&&(null===(t=this._nativePreparer)||void 0===t||t.unbindOwnerTransform(e),null===(r=this._nativePreparer)||void 0===r||r.releaseOwner(e),this._ownerHandleSet.delete(e),ji("owner",e,this._factoryId),this._ownerPool.free(e))}_releaseClipById(e){const t=this._clipHandleMap.get(e);void 0!==t&&(this._clipHandleMap.delete(e),this._releaseClipHandle(t))}_releaseClipHandle(e){var t;this._clipHandles.has(e)&&(null===(t=this._nativePreparer)||void 0===t||t.releaseClip(e),this._clipHandles.delete(e),ji("clip",e,this._factoryId),this._clipPool.free(e))}flushEvaluate(){this._nativeEvaluator&&this._syncBuffer&&(this._syncBuffer.sync(this._web._activeList,this._bindingMap),this._nativeEvaluator.flush()),this._web.flushEvaluate()}flushApply(){this._nativeApplier&&(this._nativeApplier.flush(),this._web._notifyAnimatorTransformChanged()),this._web.flushApply()}refreshLayerMask(e,t){var r;if(!this._nativePreparer)return;const a=this._bindingMap.get(e);if(!a)return;const i=null!==(r=t.avatarMask)&&void 0!==r?r:null,n=t._states;for(let e=0,t=n.length;e<t;e++){const t=a.get(n[e]);if(void 0===t)continue;const r=n[e]._nodeOwners;r&&this._nativePreparer.uploadBindingMask(t,this._buildBindingMaskBytes(r,i))}}saveCrossFixedValues(e,t){if(!this._nativePreparer)return;const r=new Uint32Array(t);let a=0;for(let i=0;i<t;i++){const t=this._ownerHandles.get(e[i]);void 0!==t&&(r[a++]=t)}a>0&&this._nativePreparer.saveCrossFixedValue(r.subarray(0,a))}updateDefaultValues(e){if(this._nativeApplier){const t=new Uint32Array(e.length);let r=0;for(const a of e){const e=this._ownerHandles.get(a);void 0!==e&&(t[r++]=e)}r>0&&this._nativeApplier.updateDefaultValues(t.subarray(0,r))}this._web.updateDefaultValues(e)}revertDefaultKeyframeNodes(e){if(this._nativeApplier){const t=this._stateBindings.get(e);if(t)for(const e of t)this._nativeApplier.revertDefaultByBinding(e)}this._web.revertDefaultKeyframeNodes(e)}destroy(){var e;if(!this._destroyed){this._destroyed=!0,null===(e=this._unregisterClipDestroyCallback)||void 0===e||e.call(this),this._unregisterClipDestroyCallback=null;for(const e of Array.from(this._bindingHandles))this._releaseBinding(e);for(const e of Array.from(this._slotHandles))this._releaseSlot(e);for(const e of Array.from(this._ownerHandleSet))this._releaseOwnerHandle(e);for(const e of Array.from(this._clipHandleMap.keys()))this._releaseClipById(e);for(const e of Array.from(this._clipHandles))this._releaseClipHandle(e);this._clipHandleMap.clear(),this._syncBuffer=null,this._web.destroy()}}}function qi(){const e=!!window.conchLayaXTransform||!!window.conchRTTransform,t=!!window.conchRTAnimatorPreparer||!!window.conchRTAnimatorEvaluator||!!window.conchRTAnimatorApplier;t&&e?ri.factoryCreator=()=>new Ji:t&&!e&&console.log("[RTAnimatorFactory] Native animator components detected but no native transform backend; using WebAnimatorFactory for full JS evaluation.")}t.Laya.addBeforeInitCallback(()=>{qi()});class Zi extends z{constructor(){var e,t;super(),this._singleton=!1,null===(t=(e=this._baseRenderNode).disableNativeBoundsCallback)||void 0===t||t.call(e)}get curHLODRS(){return this._curHLODRS}set curHLODRS(e){this._curHLODRS||(this._renderElements=[],this._renderElements.push(new W),this._renderElements[0].render=this),e!=this._curHLODRS&&(this._changeMesh(e.HLODMesh),this._curHLODRS=e,this._createRenderelementByHLODElement(this._curHLODRS,this._renderElements[0]))}_createRenderelementByHLODElement(e,t){t.setGeometry(e.HLODMesh),t.material=e.material}_changeMesh(e){var t=this._baseRenderNode.shaderData;this.boundsChange=!0;let r=D._meshVerticeDefine;if(this.curHLODRS){E.getMeshDefine(this.curHLODRS.HLODMesh.batchMesh,r);for(var a=0,i=r.length;a<i;a++)t.removeDefine(D._meshVerticeDefine[a])}if(e){E.getMeshDefine(e.batchMesh,r);for(a=0,i=D._meshVerticeDefine.length;a<i;a++)t.addDefine(D._meshVerticeDefine[a])}this._curSubBatchMeshBounds.length=e.batchSubMeshInfo.length;for(let t=0,r=e.batchSubMeshInfo.length;t<r;t++)this._curSubBatchMeshBounds[t]=this._curSubBatchMeshBounds[t]?this._curSubBatchMeshBounds[t]:new M;this.geometryBounds=e.batchMesh.bounds}_applyLightMapParams(){if(this._scene){var e=this._baseRenderNode.shaderData,t=this._curHLODRS.lightmap;t&&t.lightmapColor?(e.setTexture(y.LIGHTMAP,t.lightmapColor),e.addDefine(y.SAHDERDEFINE_LIGHTMAP),t.lightmapDirection?(e.setTexture(y.LIGHTMAP_DIRECTION,t.lightmapDirection),e.addDefine(y.SHADERDEFINE_LIGHTMAP_DIRECTIONAL)):e.removeDefine(y.SHADERDEFINE_LIGHTMAP_DIRECTIONAL)):(e.removeDefine(y.SAHDERDEFINE_LIGHTMAP),e.removeDefine(y.SHADERDEFINE_LIGHTMAP_DIRECTIONAL))}}_calculateBoundingBox(){if(this._curHLODRS){var e=this._curHLODRS.HLODMesh;if(e){var t=this._transform.worldMatrix;e.batchMesh.bounds._tranform(t,this._bounds)}for(let r=0,a=this._curSubBatchMeshBounds.length;r<a;r++)e.batchSubMeshInfo[r].bounds._tranform(t,this._curSubBatchMeshBounds[r])}}_renderUpdate(e){this._applyLightMapParams(),this._baseRenderNode.shaderData.setMatrix4x4(R.WORLDMATRIX,this._transform.worldMatrix)}_needRender(e,t){if(e){if(e.intersects(this.bounds)){let t=this.curHLODRS.HLODMesh.drawSubMeshs,r=this._curHLODRS.HLODMesh.batchSubMeshInfo;t.length=0;for(let a=0,i=this._curSubBatchMeshBounds.length;a<i;a++)e.intersects(this._curSubBatchMeshBounds[a])&&t.push(r[a]);return this._curHLODRS.HLODMesh.drawSubMeshs=t,!0}return!1}return!0}onDestroy(){super.onDestroy(),this._renderElements.forEach(e=>{e.material._removeReference(),e.destroy()}),this._renderElements=null}}const $i=new t.Vector3;class en extends t.Component{constructor(){super(),this._singleton=!0}get bounds(){return this._bounds}set bounds(e){this._bounds=e,this.recalculateBounds()}get lodResource(){return this._resourceList}set lodResource(e){this._resourceList=e}get lodCullRateArray(){return this._lodRateArray}set lodCullRateArray(e){e.sort((e,t)=>t-e),this._lodRateArray=e}_applyLODResource(e){this._curLODSource=e;let t=e.resources;for(let e=0,r=t.length;e<r;e++){let r=this.owner.addComponent(Zi);this._curRender.push(r),r.curHLODRS=t[e]}}_releaseGroupRender(){this._curRender.forEach(e=>{e.destroy()}),this._curRender=[]}recalculateBounds(){let e=this._bounds.getExtent();this._size=2*Math.max(e.x,e.y,e.z)}onPreRender(){let e=this.owner.scene.cullInfoCamera,r=e.maxlocalYDistance,a=e.boundFrustum;t.Vector3.subtract(this.owner.transform.position,e.transform.position,$i);let i=$i.length();if(i>e.farPlane||0==a.containsPoint(this.owner.transform.position))return;let n=i/e.farPlane*r,s=this._size/n;for(let e=0;e<this._lodRateArray.length;e++)if(!(s<this._lodRateArray[e])){this.applyResource(this._resourceList[e]);break}}onUpdate(){this._curLODSource.updateMark=tr._updateMark}applyResource(e){e!=this._curLODSource&&(e.loaded?this._curLODSource&&(this._releaseGroupRender(),this._applyLODResource(e)):e.load(this.applyResource,this))}}var tn=t.Script;class rn{constructor(){this.indexStart=0,this.indexCount=0,this.meshBounds=new M(new t.Vector3,new t.Vector3),this.needRender=!1}}class an extends Ce{constructor(){super(t.MeshTopology.Triangles,t.DrawType.DrawElement),this.subInfos=[]}addSubMesh(e,t,r){let a=new rn;a.indexCount=e,a.indexStart=t,r.cloneTo(a.meshBounds),this.subInfos.push(a)}_getType(){return an._type}_updateRenderParams(e){this.clearRenderParams();let r=e.camera.transform.position;this.subInfos.sort((e,a)=>{let i=e.meshBounds.getCenter(),n=t.Vector3.distanceSquared(i,r),s=a.meshBounds.getCenter();return n-t.Vector3.distanceSquared(s,r)});for(const e of this.subInfos)e.needRender&&this.setDrawElemenParams(e.indexCount,e.indexStart*this.indexByteCount)}_prepareRender(e){return!!this.subInfos.find(e=>e.needRender)}destroy(){for(const e of this.subInfos);this.subInfos=null}}an._type=Ce._typeCounter++;const nn=new t.Matrix4x4,sn=[0,1,2],on=[0,2,1];class ln{static create(e){let a,i=new ln,n=e.vertexCount,s=e.indexCount,o=e.vertexDec,l=o.vertexStride/4,h=new ArrayBuffer(o.vertexStride*n),d=new Float32Array(h),c=t.IndexFormat.UInt16,u=2;n>65535?(c=t.IndexFormat.UInt32,u=4,a=new Uint32Array(s)):a=new Uint16Array(s);let _,f=0,m=0,g=0;for(const n of e.renders){let e=n.lightmapScaleOffset;_||(_=i.bounds,n.bounds.cloneTo(_)),M.merge(_,n.bounds,_);let s=n.owner,h=s.transform._isFrontFaceInvert,p=s.transform.worldMatrix,S=nn;p.invert(S),S.transpose();let T=n.getMesh(),A=T.vertexCount,E=T.indexCount,D=T._vertexBuffer.getFloat32Data();d.set(D,f);for(let r=0;r<A;r++){let a=r*l;for(const r of o._vertexElements)switch(a+=r.offset/4,r.elementUsage){case t.VertexMesh.MESH_POSITION0:Z.transformVector3ArrayToVector3ArrayCoordinate(D,a,p,d,f+a);break;case t.VertexMesh.MESH_NORMAL0:case t.VertexMesh.MESH_TANGENT0:Z.transformVector3ArrayToVector3ArrayNormal(D,a,S,d,f+a);break;case t.VertexMesh.MESH_TEXTURECOORDINATE1:Z.transformLightingMapTexcoordArray(D,a,e,d,f+a)}}let R=T._indexBuffer.getData(),x=h?on:sn;for(let e=0;e<E;e+=3)a[g+e]=R[e+x[0]]+m,a[g+e+1]=R[e+x[1]]+m,a[g+e+2]=R[e+x[2]]+m;let y=T.subMeshCount;for(let e=0;e<y;e++){let t=n.sharedMaterials[e]||r.defaultMaterial,a=i._staticSubMeshes.get(t);a||(a=new an,a.indexByteCount=u,i._staticSubMeshes.set(t,a),a.bufferState=i._bufferState,a.indexFormat=c);let s=T.getSubMesh(e);a.addSubMesh(s.indexCount,s._indexStart+g,n.bounds)}f+=D.length,m+=A,g+=R.length}let p=T.renderOBJCreate.createVertexBuffer3D(h.byteLength,t.BufferUsage.Static,!1);p.vertexDeclaration=o,p.setData(h);let S=T.renderOBJCreate.createIndexBuffer3D(c,s,t.BufferUsage.Static,!1);return S.setData(a),i.setBuffer(p,S),i}constructor(){this._bufferState=new t.BufferState,this._staticSubMeshes=new Map,this.bounds=new M}setBuffer(e,t){let r=this._bufferState;this._vertexBuffer=e,this._indexBuffer=t,r.applyState([e],t)}destroy(){this._staticSubMeshes.forEach(e=>{e.destroy()}),this._staticSubMeshes.clear(),this._staticSubMeshes=null,this._bufferState.destroy()}}class hn extends W{constructor(){super()}getInvertFront(){return!1}}class dn extends z{static create(e){let t=new dn;return t.mergeInfo=e,t}get staticMesh(){return this._staticMesh}get mergeInfo(){return this._mergeInfo}set mergeInfo(e){this._mergeInfo=e;let t=ln.create(e);this._staticMesh=t,this.lightmapIndex=e.lightmapIndex,this._staticMesh=t,this.geometryBounds=t.bounds;let r=D._meshVerticeDefine,a=this._baseRenderNode.shaderData;this._getMeshDefine(t,r);for(const e of r)a.addDefine(e);this._renderElements.forEach(e=>{e.material._removeReference(),e.destroy()}),this._renderElements=[],t._staticSubMeshes.forEach((e,t)=>{let r=new hn;this._renderElements.push(r),r.render=this,r.material=t,r.setGeometry(e),t._addReference()}),t.bounds.cloneTo(this.bounds)}constructor(){var e,t;super(),this._singleton=!1,null===(t=(e=this._baseRenderNode).disableNativeBoundsCallback)||void 0===t||t.call(e)}_calculateBoundingBox(){}_renderUpdate(e){}_getMeshDefine(e,r){let a=e._vertexBuffer.vertexDeclaration._vertexElements;for(const e of a)switch(e.elementUsage){case t.VertexMesh.MESH_COLOR0:r.push(A.SHADERDEFINE_COLOR);break;case t.VertexMesh.MESH_TEXTURECOORDINATE0:r.push(A.SHADERDEFINE_UV0);break;case t.VertexMesh.MESH_TEXTURECOORDINATE1:r.push(A.SHADERDEFINE_UV1);break;case t.VertexMesh.MESH_TANGENT0:r.push(A.SHADERDEFINE_TANGENT)}}_needRender(e,t){if(e){if(e.intersects(this.bounds)){let t=!1;return this.staticMesh._staticSubMeshes.forEach(r=>{for(const a of r.subInfos)a.needRender=e.intersects(a.meshBounds),t=t||a.needRender}),t}return!1}return!0}onEnable(){super.onEnable(),this.mergeInfo.renders.forEach(t=>{t.setRenderbitFlag(e.RenderBitFlag.RenderBitFlag_Batch,!0)})}onDisable(){super.onDisable(),this.mergeInfo.renders.forEach(t=>{t.setRenderbitFlag(e.RenderBitFlag.RenderBitFlag_Batch,!1)})}onDestroy(){super.onDestroy(),this._renderElements.forEach(e=>{e.material._removeReference(),e.destroy()}),this._renderElements=null,this._staticMesh.destroy(),this._staticMesh=null}_cloneTo(e){e.mergeInfo=this.mergeInfo}}class cn{static create(e){let t=e.getMesh(),r=new cn;return r.lightmapIndex=e.lightmapIndex,r.receiveShadow=e.receiveShadow,r.vertexDec=t?t.getVertexDeclaration():null,r}get renders(){return this._renders}constructor(){this._renders=[],this.vertexCount=0,this.indexCount=0}match(e){let t=e.getMesh();e.owner;let r=!0;return r=r&&this.lightmapIndex==e.lightmapIndex,r=r&&this.receiveShadow==e.receiveShadow,r=r&&this.vertexDec==t.getVertexDeclaration(),r}addElement(e){this.renders.push(e);let t=e.getMesh();this.vertexCount+=t.vertexCount,this.indexCount+=t.indexCount}destroy(){this._renders=null}}class un{constructor(){this._isNeedUpdate=!1}createInstanceVertexBuffer3D(){this._instanceData=new Float32Array(Ut.maxInstanceCount*this._vertexStride),this._vertexBuffer=T.renderOBJCreate.createVertexBuffer3D(4*this._instanceData.length,t.BufferUsage.Dynamic,!1),this._vertexBuffer.vertexDeclaration=this._vertexDeclaration,this._vertexBuffer.instanceBuffer=!0}updateVertexBufferData(e){if(!this._isNeedUpdate)return;let t,r=this._instanceData,a=this._value,i=this._value.length,n=this._vertexStride,s=0;switch(this._value instanceof Float32Array||(s=1),s){case 0:r.set(a,0);break;case 1:for(let e=0;e<i;e++)t=a[e],t.writeTo(r,e*n)}this._vertexBuffer._deviceBuffer.setDataLength(this._vertexBuffer._byteLength),this._vertexBuffer.setData(r.buffer,0,0,4*e*n)}destroy(){delete this._value,delete this._instanceData,this._vertexDeclaration=null,this._vertexBuffer.destroy()}}var _n;e.InstanceLocation=void 0,(_n=e.InstanceLocation||(e.InstanceLocation={}))[_n.CUSTOME0=12]="CUSTOME0",_n[_n.CUSTOME1=13]="CUSTOME1",_n[_n.CUSTOME2=14]="CUSTOME2",_n[_n.CUSTOME3=15]="CUSTOME3";class fn{constructor(){this._type=0,this._propertyMap={}}_checkPropertyLegal(e,t,r,a){if(a._vertexDeclaration._vertexElements[0]._elementFormat!==e)throw"Data exists and format does not match";if(a._name!==t)throw"You cannot add a new property to an existing attributeLocation,Please use another attributeLocation"}_creatProperty(e,r,a,i,n){var s=this._propertyMap[n]=new un;s._name=e,s._value=r,s._vertexDeclaration=new t.VertexDeclaration(a,[new t.VertexElement(0,i,n)]),s._isNeedUpdate=!0,s._vertexStride=a/4,s.createInstanceVertexBuffer3D()}setVectorArray(e,r,a){var i=this._propertyMap[a];i?(this._checkPropertyLegal(t.VertexElementFormat.Vector4,e,a,i),i._value=r,i._isNeedUpdate=!0):this._creatProperty(e,r,16,t.VertexElementFormat.Vector4,a)}setVector3Array(e,r,a){var i=this._propertyMap[a];i?(this._checkPropertyLegal(t.VertexElementFormat.Vector3,e,a,i),i._value=r,i._isNeedUpdate=!0):this._creatProperty(e,r,12,t.VertexElementFormat.Vector3,a)}setVector2Array(e,r,a){var i=this._propertyMap[a];i?(this._checkPropertyLegal(t.VertexElementFormat.Vector2,e,a,i),i._value=r,i._isNeedUpdate=!0):this._creatProperty(e,r,8,t.VertexElementFormat.Vector2,a)}setNumberArray(e,r,a){var i=this._propertyMap[a];i?(this._checkPropertyLegal(t.VertexElementFormat.Single,e,a,i),i._value=r,i._isNeedUpdate=!0):this._creatProperty(e,r,4,t.VertexElementFormat.Single,a)}getPropertyArray(e){var t=this._propertyMap[e];return t?t._value:null}clear(){for(var e in this._propertyMap)this._propertyMap[e].destroy();this._propertyMap={}}}fn.INSTANCETYPE_ATTRIBUTE=0,fn.INSTANCETYPE_UNIFORMBUFFER=1;class mn{get center(){return this._center}set center(e){e.cloneTo(this._center)}get radius(){return this._radius}set radius(e){this._radius=e}constructor(e=new t.Vector3,r=0){this._center=e,this._radius=r}toDefault(){this._center.toDefault(),this._radius=0}static createFromSubPoints(e,r,a,i){if(null==e)throw new Error("points");if(r<0||r>=e.length)throw new Error("start"+r+"Must be in the range [0, "+(e.length-1)+"]");if(a<0||r+a>e.length)throw new Error("count"+a+"Must be in the range <= "+e.length+"}");var n=r+a,s=gn;s.x=0,s.y=0,s.z=0;for(var o=r;o<n;++o)t.Vector3.add(e[o],s,s);var l=i.center;t.Vector3.scale(s,1/a,l);var h=0;for(o=r;o<n;++o){var d=t.Vector3.distanceSquared(l,e[o]);d>h&&(h=d)}i.radius=Math.sqrt(h)}static createfromPoints(e,t){if(null==e)throw new Error("points");mn.createFromSubPoints(e,0,e.length,t)}intersectsRayDistance(e){return We.intersectsRayAndSphereRD(e,this)}intersectsRayPoint(e,t){return We.intersectsRayAndSphereRP(e,this,t)}cloneTo(e){this._center.cloneTo(e._center),e._radius=this._radius}clone(){var e=new mn(new t.Vector3,0);return this.cloneTo(e),e}}const gn=new t.Vector3;class pn{get min(){return this.getMin()}set min(e){this.setMin(e)}get max(){return this.getMax()}set max(e){this.setMax(e)}setMin(e){var t=this._boundBox.min;e!==t&&e.cloneTo(t),this._setUpdateFlag(pn._UPDATE_CENTER|pn._UPDATE_EXTENT,!0),this._setUpdateFlag(pn._UPDATE_MIN,!1)}getMin(){var e=this._boundBox.min;return this._getUpdateFlag(pn._UPDATE_MIN)&&(this._getMin(this.getCenter(),this.getExtent(),e),this._setUpdateFlag(pn._UPDATE_MIN,!1)),e}setMax(e){var t=this._boundBox.max;e!==t&&e.cloneTo(t),this._setUpdateFlag(pn._UPDATE_CENTER|pn._UPDATE_EXTENT,!0),this._setUpdateFlag(pn._UPDATE_MAX,!1)}getMax(){var e=this._boundBox.max;return this._getUpdateFlag(pn._UPDATE_MAX)&&(this._getMax(this.getCenter(),this.getExtent(),e),this._setUpdateFlag(pn._UPDATE_MAX,!1)),e}setCenter(e){e!==this._center&&e.cloneTo(this._center),this._getMin(this._center,this._extent,this._boundBox.min),this._getMax(this._center,this._extent,this._boundBox.max),this._setUpdateFlag(pn._UPDATE_CENTER|pn._UPDATE_MIN|pn._UPDATE_MAX,!1)}getCenter(){return this._getUpdateFlag(pn._UPDATE_CENTER)&&(this._getCenter(this.getMin(),this.getMax(),this._center),this._setUpdateFlag(pn._UPDATE_CENTER,!1)),this._center}setExtent(e){e!==this._extent&&e.cloneTo(this._extent),this._getMin(this._center,this._extent,this._boundBox.min),this._getMax(this._center,this._extent,this._boundBox.max),this._setUpdateFlag(pn._UPDATE_CENTER|pn._UPDATE_MIN|pn._UPDATE_MAX,!1)}getExtent(){return this._getUpdateFlag(pn._UPDATE_EXTENT)&&(this._getExtent(this.getMin(),this.getMax(),this._extent),this._setUpdateFlag(pn._UPDATE_EXTENT,!1)),this._extent}constructor(e,r){this._updateFlag=0,this._center=new t.Vector3,this._extent=new t.Vector3,this._boundBox=new Ea(new t.Vector3,new t.Vector3),e&&e.cloneTo(this._boundBox.min),r&&r.cloneTo(this._boundBox.max),this._setUpdateFlag(pn._UPDATE_MIN|pn._UPDATE_MAX,!1),this._setUpdateFlag(pn._UPDATE_CENTER|pn._UPDATE_EXTENT,!0)}_getUpdateFlag(e){return 0!=(this._updateFlag&e)}_setUpdateFlag(e,t){t?this._updateFlag|=e:this._updateFlag&=~e}_getCenter(e,r,a){t.Vector3.add(e,r,a),t.Vector3.scale(a,.5,a)}_getExtent(e,r,a){t.Vector3.subtract(r,e,a),t.Vector3.scale(a,.5,a)}_getMin(e,r,a){t.Vector3.subtract(e,r,a)}_getMax(e,r,a){t.Vector3.add(e,r,a)}_rotateExtents(e,t,r){var a=e.x,i=e.y,n=e.z,s=t.elements;r.x=Math.abs(s[0]*a)+Math.abs(s[4]*i)+Math.abs(s[8]*n),r.y=Math.abs(s[1]*a)+Math.abs(s[5]*i)+Math.abs(s[9]*n),r.z=Math.abs(s[2]*a)+Math.abs(s[6]*i)+Math.abs(s[10]*n)}_tranform(e,r){var a=r._center,i=r._extent;t.Vector3.transformCoordinate(this.getCenter(),e,a),this._rotateExtents(this.getExtent(),e,i),r._boundBox.setCenterAndExtent(a,i),r._updateFlag=0}_getBoundBox(){if(this._updateFlag&pn._UPDATE_MIN){var e=this._boundBox.min;this._getMin(this.getCenter(),this.getExtent(),e),this._setUpdateFlag(pn._UPDATE_MIN,!1)}if(this._updateFlag&pn._UPDATE_MAX){var t=this._boundBox.max;this._getMax(this.getCenter(),this.getExtent(),t),this._setUpdateFlag(pn._UPDATE_MAX,!1)}return this._boundBox}calculateBoundsintersection(e){var t=this.getMax(),r=this.getMin(),a=e.getMax(),i=e.getMin(),n=Sn,s=Tn,o=this.getExtent(),l=e.getExtent();return n.setValue(Math.max(t.x,a.x)-Math.min(r.x,i.x),Math.max(t.y,a.y)-Math.min(r.y,i.y),Math.max(t.z,a.z)-Math.min(r.z,i.z)),s.setValue(2*(o.x+l.x),2*(o.y+l.y),2*(o.z+l.z)),n.x>s.x||n.y>s.y||n.z>s.z?-1:(s.x-n.x)*(s.y-n.y)*(s.z-n.z)}cloneTo(e){this.getMin().cloneTo(e._boundBox.min),this.getMax().cloneTo(e._boundBox.max),this.getCenter().cloneTo(e._center),this.getExtent().cloneTo(e._extent),e._updateFlag=0}clone(){var e=new pn(new t.Vector3,new t.Vector3);return this.cloneTo(e),e}}pn._UPDATE_MIN=1,pn._UPDATE_MAX=2,pn._UPDATE_CENTER=4,pn._UPDATE_EXTENT=8;const Sn=new t.Vector3,Tn=new t.Vector3;class An{constructor(e){if(!(e instanceof Array)||4!==e.length)throw new Error("Rand:Seed must be an array with 4 numbers");this._state0U=0|e[0],this._state0L=0|e[1],this._state1U=0|e[2],this._state1L=0|e[3]}randomint(){var e=this._state0U,t=this._state0L,r=this._state1U,a=this._state1L,i=(a>>>0)+(t>>>0),n=r+e+(i/2>>>31)>>>0,s=i>>>0;this._state0U=r,this._state0L=a;var o=0,l=0;o=(e^=o=e<<23|(-512&t)>>>9)^r,l=(t^=l=t<<23)^a;o^=e>>>18,l^=t>>>18|(262143&e)<<14;return o^=r>>>5,l^=a>>>5|(31&r)<<27,this._state1U=o,this._state1L=l,[n,s]}random(){var e=this.randomint(),t=e[0],r=1023<<20|t>>>12,a=0|(e[1]>>>12|(4095&t)<<20);return An._CONVERTION_BUFFER.setUint32(0,r,!1),An._CONVERTION_BUFFER.setUint32(4,a,!1),An._CONVERTION_BUFFER.getFloat64(0,!1)-1}}An._CONVERTION_BUFFER=new DataView(new ArrayBuffer(8)),An.defaultRand=new An([0,Date.now()/65536,0,Date.now()%65536]);var En;e.ShadowLightType=void 0,(En=e.ShadowLightType||(e.ShadowLightType={}))[En.DirectionLight=0]="DirectionLight",En[En.SpotLight=1]="SpotLight",En[En.PointLight=2]="PointLight";class Dn{constructor(){this.boundFrustum=new $e(new t.Matrix4x4)}}class Rn{}Rn.COLLISIONFILTERGROUP_DEFAULTFILTER=1,Rn.COLLISIONFILTERGROUP_STATICFILTER=2,Rn.COLLISIONFILTERGROUP_KINEMATICFILTER=4,Rn.COLLISIONFILTERGROUP_DEBRISFILTER=8,Rn.COLLISIONFILTERGROUP_SENSORTRIGGER=16,Rn.COLLISIONFILTERGROUP_CHARACTERFILTER=32,Rn.COLLISIONFILTERGROUP_CUSTOMFILTER1=64,Rn.COLLISIONFILTERGROUP_CUSTOMFILTER2=128,Rn.COLLISIONFILTERGROUP_CUSTOMFILTER3=256,Rn.COLLISIONFILTERGROUP_CUSTOMFILTER4=512,Rn.COLLISIONFILTERGROUP_CUSTOMFILTER5=1024,Rn.COLLISIONFILTERGROUP_CUSTOMFILTER6=2048,Rn.COLLISIONFILTERGROUP_CUSTOMFILTER7=4096,Rn.COLLISIONFILTERGROUP_CUSTOMFILTER8=8192,Rn.COLLISIONFILTERGROUP_CUSTOMFILTER9=16384,Rn.COLLISIONFILTERGROUP_CUSTOMFILTER10=32768,Rn.COLLISIONFILTERGROUP_ALLFILTER=-1,Rn.PHYSXDEFAULTMASKVALUE=4294967295;class xn{static get fullScreen(){return new xn(-1,-1)}get width(){return-1===this._width?J.clientWidth:this._width}get height(){return-1===this._height?J.clientHeight:this._height}constructor(e,t){this._width=0,this._height=0,this._width=e,this._height=t}}e.AlternateLightQueue=be,e.AnimationClip=ca,e.AnimationClipParser03=$r,e.AnimationClipParser04=ha,e.AnimationEvent=Zr,e.Animator=ai,e.AnimatorController=li,e.AnimatorControllerLayer=Va,e.AnimatorManager=ri,e.AnimatorPlayState=ba,e.AnimatorResource=Ka,e.AnimatorState=ii,e.AnimatorStateScript=class{setPlayScriptInfo(e,t,r){this.playStateInfo.animator=e,this.playStateInfo.layerindex=t,this.playStateInfo.playState=r}constructor(){this.playStateInfo={animator:null,layerindex:-1,playState:null}}onStateEnter(){}onStateUpdate(e){}onStateExit(){}onStateSwitch(e){}onStateLoop(){}},e.AnimatorTransformEventDispatcher=ei,e.AnimatorTransition=oi,e.AreaLightCom=va,e.AvatarMask=ni,e.AxiGamepad=Li,e.BaseCamera=Ne,e.BaseRender=z,e.BatchMark=class{constructor(){this.updateMark=-1,this.indexInList=-1,this.batched=!1,this._curBindElementIndex=0,this._cacheRenderElement=[]}},e.BlinnPhongMaterial=r,e.BlinnPhongShaderInit=yr,e.BlitFrameBufferCMD=ir,e.BlitQuadCMDData=class{get element(){return this._element}set element(e){this._element=e}get dest(){return this._dest}set dest(e){this._dest=e}get viewport(){return this._viewport}set viewport(e){this._viewport=e}get scissor(){return this._scissor}set scissor(e){this._scissor=e}get source(){return this._source}set source(e){this._source=e}get offsetScale(){return this._offsetScale}set offsetScale(e){this._offsetScale=e}apply(e){throw new t.NotImplementedError}},e.BlitScreenQuadCMD=Pt,e.BlitScreenShaderInit=Dr,e.BoundBox=Ea,e.BoundFrustum=$e,e.BoundSphere=mn,e.Bounds=M,e.BoundsImpl=pn,e.ButtonGamepad=Fi,e.Camera=tr,e.CameraCullInfo=Dn,e.CameraTAA=qt,e.Cluster=le,e.Collision=class{constructor(){this._lastUpdateFrame=-2147483648,this._updateFrame=-2147483648,this._isTrigger=!1,this.contacts=[],this._inPool=!1}_setUpdateFrame(e){this._lastUpdateFrame=this._updateFrame,this._updateFrame=e}},e.CollisionUtils=We,e.Command=j,e.CommandBuffer=zt,e.ComputeCommandBufferCMD=kt,e.ContactPoint=class{constructor(){this._idCounter=0,this._colliderA=null,this._colliderB=null,this.distance=0,this.normal=new t.Vector3,this.positionOnA=new t.Vector3,this.positionOnB=new t.Vector3,this._id=++this._idCounter}},e.ContainmentType=ze,e.CubemapLoader=mi,e.DepthPass=At,e.DeviceBuffer=class{get deviceBuffer(){return this._deviceBuffer}get vertexBuffer(){return this._vertexBuffer3D}constructor(e,r){t.LayaGL.renderEngine.getCapable(t.RenderCapable.ComputeShader)&&(r&t.EDeviceBufferUsage.VERTEX?(this._vertexBuffer=t.LayaGL.renderDeviceFactory.createDeviceVertexBuffer(r),this._deviceBuffer=this._vertexBuffer.getStorageBuffer(),this._vertexBuffer.setDataLength(e),this._vertexBuffer3D=new ur(0,t.BufferUsage.Dynamic,!1),this._vertexBuffer3D.destroy(),this._vertexBuffer3D._deviceBuffer=this._vertexBuffer,this._vertexBuffer3D._byteLength=e):(this._deviceBuffer=t.LayaGL.renderDeviceFactory.createDeviceBuffer(r),this._deviceBuffer.setDataLength(e)))}destroy(){var e;null===(e=this.vertexBuffer)||void 0===e||e.destroy(),this._deviceBuffer.destroy()}},e.DirectionLightCom=xa,e.DrawElementCMDData=class{setRenderelements(e){throw new t.NotImplementedError}apply(e){throw new t.NotImplementedError}},e.DrawMeshCMD=Nt,e.DrawMeshInstancedCMD=Ut,e.DrawNodeCMDData=class{get node(){return this._node}set node(e){this._node=e}get destShaderData(){return this._destShaderData}set destShaderData(e){this._destShaderData=e}get destSubShader(){return this._destSubShader}set destSubShader(e){this._destSubShader=e}get subMeshIndex(){return this._subMeshIndex}set subMeshIndex(e){this._subMeshIndex=e}apply(e){throw new t.NotImplementedError}},e.DrawRenderCMD=Ot,e.DrawRenderElementCMD=Gt,e.EffectMaterial=_a,e.ExtendTerrainMaterial=fa,e.FrustumCulling=class{static cullingRenderBounds(e,t){for(var r=t.cullPlaneCount,a=t.cullPlanes,i=e._imp.getMin(),n=e._imp.getMax(),s=i.x,o=i.y,l=i.z,h=n.x,d=n.y,c=n.z,u=!0,_=0;_<r;_++){var f=a[_],m=f.normal;if(f.distance+m.x*(m.x<0?s:h)+m.y*(m.y<0?o:d)+m.z*(m.z<0?l:c)<0){u=!1;break}}if(!u)return!1;const g=t.receiverSphereCullingRadius;if(!(g>=0))return!0;const p=.5*(s+h),S=.5*(o+d),T=.5*(l+c),A=t.cullSphere.center,E=t.receiverSphereCullingDirection;let D=p-A.x,R=S-A.y,x=T-A.z;const y=D*E.x+R*E.y+x*E.z;y<0&&(D-=y*E.x,R-=y*E.y,x-=y*E.z);const M=D*D+R*R+x*x;if(M<=g*g)return!0;const C=.5*(h-s),v=.5*(d-o),I=.5*(c-l);if(C<0||v<0||I<0)return!0;const w=C*C+v*v+I*I,B=g+1e-6*Math.max(1,Math.abs(p),Math.abs(S),Math.abs(T),Math.abs(A.x),Math.abs(A.y),Math.abs(A.z),C+v+I,g),P=B*B,L=P+w;if(!(Number.isFinite(M)&&M>L))return!0;const F=M-L;return!(F*F>4*P*w)}},e.GBuffer=f,e.GeometryElement=Ce,e.HLOD=en,e.HLODBatchMesh=class extends Ce{constructor(){super(t.MeshTopology.Triangles,t.DrawType.DrawElement)}get batchMesh(){return this._mesh}set batchMesh(e){this._mesh!=e&&(this._mesh&&this._mesh._removeReference(),this.indexFormat=e.indexFormat,this._mesh=e,this._mesh._addReference())}get batchSubMeshInfo(){return this._batchSubMeshInfos}set batchSubMeshInfo(e){this._batchSubMeshInfos=e}get drawSubMeshs(){return this._drawSubMeshs}set drawSubMeshs(e){this._drawSubMeshs=e}_prepareRender(e){return this._mesh._uploadVerticesData(),!0}_updateRenderParams(e){var r,a=this._mesh;switch(a.indexFormat){case t.IndexFormat.UInt32:r=4;break;case t.IndexFormat.UInt16:r=2;break;case t.IndexFormat.UInt8:r=1}this.clearRenderParams(),this.bufferState=a._bufferState,this._drawSubMeshs&&this._drawSubMeshs.forEach(e=>{this.setDrawElemenParams(e.drawPramas.y,e.drawPramas.x*r)})}destroy(){this._mesh&&this._mesh._removeReference(),delete this._batchSubMeshInfos,delete this._drawSubMeshs}},e.HLODBatchSubMesh=class{},e.HLODConfig=class{},e.HLODElement=class{get material(){return this._material}set material(e){this._material!=e&&(this._material&&this._material._removeReference(),this._material=e,this._material._addReference())}get lightmap(){return this._lightmap}set lightmap(e){this._lightmap!=e&&(this._lightmap&&(this._lightmap.lightmapColor._removeReference(),this._lightmap.lightmapDirection._removeReference()),this._lightmap=e,this._lightmap.lightmapColor._addReference(),this._lightmap.lightmapDirection._addReference()),this._lightmap=e}release(){this.HLODMesh.destroy(),this.material.destroy(),this.lightmap&&(this._lightmap.lightmapColor.destroy(),this._lightmap.lightmapDirection.destroy())}},e.HLODRender=Zi,e.HLODResourceGroup=class{load(e,r){this.loaded||t.Laya.loader.load(this.url).then(t=>{e.apply(r,[this]),this.loaded=!0})}release(){this.resources.forEach(e=>{e.release()}),this.loaded=!1}},e.HitResult=Si,e.IndexBuffer3D=cr,e.InstanceRenderElement=_r,e.KeyframeNode=qr,e.KeyframeNodeList=da,e.KeyframeNodeOwner=la,e.LODGroup=Ba,e.LODInfo=wa,e.Laya3D=jr,e.Laya3DRender=T,e.LayerTask=Ha,e.LengencyRenderEngine3DFactory=Jr,e.Light=ut,e.LightQueue=Oe,e.LightSprite=ua,e.Lightmap=Ve,e.LoadModelV04=Di,e.LoadModelV05=Mi,e.MaterialInstanceProperty=un,e.MaterialInstancePropertyBlock=fn,e.Mesh=gr,e.MeshFilter=D,e.MeshInstanceGeometry=Vt,e.MeshReader=Ci,e.MeshRenderer=Y,e.MeshSprite3D=X,e.MeshSprite3DShaderDeclaration=A,e.MeshUtil=E,e.MorphTarget=Ri,e.MorphTargetChannel=xi,e.MorphTargetData=yi,e.PBRDefaultDFG=i,e.PBRMaterial=_,e.PBRShaderLib=n,e.PBRStandardMaterial=m,e.PBRStandardShaderInit=Mr,e.Physics3DStatInfo=Kr,e.Physics3DUtils=Rn,e.PhysicsSettings=pe,e.Picker=Et,e.PixelLineData=Pa,e.PixelLineFilter=La,e.PixelLineMaterial=Xr,e.PixelLineRenderer=Oa,e.PixelLineSprite3D=class extends y{get maxLineCount(){return this._render.maxLineCount}set maxLineCount(e){this._render.maxLineCount=e}get lineCount(){return this._render.lineCount}get pixelLineRenderer(){return this._render}constructor(e=2,t=null){super(t),this._isRenderActive=!1,this._isInRenders=!1,this._render=this.addComponent(Oa),this._geometryFilter=this._render._pixelLineFilter,this._render.maxLineCount=e,(this._render.material=new S).enableVertexColor=!0}addLine(e,t,r,a){this._render.addLine(e,t,r,a)}addLines(e){this._render.addLines(e)}removeLine(e){this._render.removeLine(e)}setLine(e,t,r,a,i){this._render.setLine(e,t,r,a,i)}getLine(e,t){this._render.getLine(e,t)}clear(){this._render.clear()}},e.PixelLineVertex=K,e.PlainOwnerData=aa,e.Plane=Ge,e.PointLightCom=ya,e.PostProcess=Qt,e.PostProcessEffect=si,e.PostProcessRenderContext=Wt,e.PrimitiveMesh=Tr,e.RTAnimatorFactory=Ji,e.RTBatchSyncBuffer=Hi,e.RandX=An,e.Ray=ke,e.ReflectionProbe=G,e.ReflectionProbeManager=b,e.RenderContext3D=J,e.RenderElement=W,e.RenderableSprite3D=y,e.Scene3D=hr,e.Scene3DShaderDeclaration=Ue,e.SceneRenderManager=nr,e.ScreenQuad=wt,e.Script3D=tn,e.SetDefineCMD=Ft,e.SetGlobalShaderDataCMD=bt,e.SetRTCMD=Ht,e.SetRenderTargetCMD=class{constructor(){this._clearColorValues=null}get rt(){return this._rt}set rt(e){this._rt=e}get clearFlag(){return this._clearFlag}set clearFlag(e){this._clearFlag=e}get clearDepthValue(){return this._clearDepthValue}set clearDepthValue(e){this._clearDepthValue=e}get clearStencilValue(){return this._clearStencilValue}set clearStencilValue(e){this._clearStencilValue=e}get clearColorValue(){return this._clearColorValue}set clearColorValue(e){this._clearColorValue=e,this._clearColorValues=null}get clearColorValues(){return this._clearColorValues}set clearColorValues(e){this._clearColorValues=e?Array.from(e,e=>{var t;return null!==(t=null==e?void 0:e.clone())&&void 0!==t?t:null}):null}apply(e){throw new t.NotImplementedError}},e.SetShaderDataCMD=Lt,e.SetViewportCMD=class{get viewport(){return this._viewport}set viewport(e){this._viewport=e}get scissor(){return this._scissor}set scissor(e){this._scissor=e}apply(e){throw new t.NotImplementedError}},e.ShaderInit3D=Hr,e.ShadowCasterPass=Tt,e.ShadowCullInfo=class{constructor(){this.receiverSphereCullingRadius=-1,this.receiverSphereCullingDirection=new t.Vector3}prepareReceiverSphereCulling(e,t=0){this.receiverSphereCullingRadius=-1;const r=this.cullSphere,a=this.direction;if(!(e&&r&&r.center&&a))return;const i=r.center,n=r.radius+t,s=a.x*a.x+a.y*a.y+a.z*a.z;if(!(r.radius>0&&t>=0&&Number.isFinite(n)&&Number.isFinite(i.x)&&Number.isFinite(i.y)&&Number.isFinite(i.z)&&s>1e-12&&Number.isFinite(s)))return;const o=1/Math.sqrt(s);this.receiverSphereCullingDirection.setValue(a.x*o,a.y*o,a.z*o),this.receiverSphereCullingRadius=n}},e.ShadowSliceData=class{constructor(){this.position=new t.Vector3,this.viewMatrix=new t.Matrix4x4,this.projectionMatrix=new t.Matrix4x4,this.viewProjectMatrix=new t.Matrix4x4,this.cullPlanes=[new Ge(new t.Vector3,0),new Ge(new t.Vector3,0),new Ge(new t.Vector3,0),new Ge(new t.Vector3,0),new Ge(new t.Vector3,0),new Ge(new t.Vector3,0),new Ge(new t.Vector3,0),new Ge(new t.Vector3,0),new Ge(new t.Vector3,0),new Ge(new t.Vector3,0)],this.splitBoundSphere=new mn(new t.Vector3,0),this.cameraShaderValue=t.LayaGL.renderDeviceFactory.createShaderData(null)}destroy(){this.cameraShaderValue.destroy(),this.cameraShaderValue=null,this.cullPlanes=null}},e.ShadowSpotData=class{constructor(){this.position=new t.Vector3,this.viewMatrix=new t.Matrix4x4,this.projectionMatrix=new t.Matrix4x4,this.viewProjectMatrix=new t.Matrix4x4,this.cameraShaderValue=t.LayaGL.renderDeviceFactory.createShaderData(null),this.cameraCullInfo=new Dn}destroy(){this.cameraShaderValue.destroy(),this.cameraShaderValue=null,this.cameraCullInfo=null}},e.ShadowUtils=_t,e.SimpleSkinnedMeshRenderer=Wr,e.SimpleSkinnedMeshSprite3D=Qr,e.Size=xn,e.SkinRenderElement=kr,e.SkinnedMeshRenderer=zr,e.SkinnedMeshSprite3D=ma,e.SkinnedMeshSprite3DShaderDeclaration=Gr,e.SkyBox=ve,e.SkyBoxMaterial=g,e.SkyBoxShaderInit=Cr,e.SkyDome=we,e.SkyPanoramicMaterial=Yr,e.SkyPanoramicShaderInit=Ur,e.SkyProceduralMaterial=p,e.SkyProceduralShaderInit=vr,e.SkyRenderElement=Le,e.SkyRenderer=Be,e.SphericalHarmonicsL2=ga,e.SphericalHarmonicsL2Generater=Aa,e.SpotLightCom=Ma,e.Sprite3D=R,e.Sprite3DRenderDeclaration=k,e.StaticBatchMesh=ln,e.StaticBatchMeshRender=dn,e.StaticBatchMeshRenderElement=hn,e.StaticBatchSubInfo=rn,e.StaticBatchSubMesh=an,e.StaticMeshBatchManager=class{constructor(){this.meshVertexDecSet=new Set}combine(e){for(const t of e){let e=!1;for(const r of this.meshVertexDecSet)r.match(t)&&(e=!0,r.addElement(t));if(!e){let e=cn.create(t);e.addElement(t),this.meshVertexDecSet.add(e)}}let t=[];for(const e of this.meshVertexDecSet)t.push(dn.create(e));return this.meshVertexDecSet.clear(),t}merge(e){return dn.create(e)}},e.StaticMeshMergeInfo=cn,e.SubMesh=fr,e.SubMeshInstanceBatch=dr,e.SubMeshRenderElement=Q,e.TaskSlot=Ga,e.TextMesh=class{get text(){return this._text}set text(e){this._text=e}get fontSize(){return this._fontSize}set fontSize(e){this._fontSize=e}get color(){return this._color}set color(e){this._color=e}constructor(){}},e.Texture2DArrayLoader=pi,e.TextureGenerator=q,e.Transform3D=Se,e.UI3D=ci,e.UI3DGeometry=hi,e.UI3DManager=sr,e.UnlitMaterial=S,e.UnlitShaderInit=xr,e.Utils3D=Z,e.VehicleWheelState=class{constructor(){this.otherCollider=null,this.contactPos=new t.Vector3,this.contactNormal=new t.Vector3(0,1,0),this.isContact=!1,this.currentSuspensionLength=0,this.suspensionForce=0,this.skidInfo=1,this.rotation=0,this.angularSpeed=0,this.rpm=0,this.worldPosition=new t.Vector3,this.worldRotation=new t.Quaternion(0,0,0,1)}},e.VertexBuffer3D=ur,e.VertexPositionTexture=Ie,e.Volume=O,e.VolumeManager=H,e.VolumetricGI=V,e.VolumetricGIManager=U,e.WebAnimatorApplier=Xa,e.WebAnimatorEvaluator=ka,e.WebAnimatorFactory=ti,e.WebXRCamera=Ii,e.WebXRCameraInfo=class{},e.WebXRCameraManager=Pi,e.WebXRExperienceHelper=Ui,e.WebXRInput=Ni,e.WebXRInputManager=Oi,e.WebXRRenderTexture=wi,e.WebXRSessionManager=Bi,e.addKeyframeNodeOwner=ja,e.createConchAnimatorFactory=qi,e.createOwnerData=ra,e.handleSpriteOwnersBySprite=Za,e.isTransformType=za,e.notifyClipDestroyed=sa,e.prepareStateOwners=qa,e.registerClipDestroyCallback=na,e.registerOwnerDataCreator=ta,e.removeKeyframeNodeOwner=Ja,e.skinnedMatrixCache=mr,e.volumeIntersectInfo=class{}}(window.Laya=window.Laya||{},Laya);
|