diff --git a/.gitattributes b/.gitattributes
index a6344aac8c09253b3b630fb776ae94478aa0275b..9dd3469a88c6b74d3805ba0203791f8e8d82b5bb 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -33,3 +33,12 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text
*tfevents* filter=lfs diff=lfs merge=lfs -text
+examples/img_to_3d/avatar.png filter=lfs diff=lfs merge=lfs -text
+examples/img_to_3d/lion.png filter=lfs diff=lfs merge=lfs -text
+examples/img_to_3d/sculpture.png filter=lfs diff=lfs merge=lfs -text
+examples/views_to_scene/dtu_1/000000.png filter=lfs diff=lfs merge=lfs -text
+examples/views_to_scene/dtu_1/000002.png filter=lfs diff=lfs merge=lfs -text
+examples/views_to_scene/wild_1/000.jpg filter=lfs diff=lfs merge=lfs -text
+examples/views_to_scene/wild_1/001.jpg filter=lfs diff=lfs merge=lfs -text
+examples/views_to_scene/wild_2/000.jpg filter=lfs diff=lfs merge=lfs -text
+examples/views_to_scene/wild_2/001.jpg filter=lfs diff=lfs merge=lfs -text
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..cda8903f0a6bd8f593b7b18939e77f1244f44de5
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,41 @@
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+build/
+develop-eggs/
+dist/
+eggs/
+.eggs/
+.vscode/
+lib/
+lib64/
+parts/
+sdist/
+var/
+wheels/
+*.egg-info/
+.installed.cfg
+*.egg
+MANIFEST
+
+.DS_Store
+
+.env/
+.trash/
+ckpts/
+logs/
+data/
+outputs/
+figures*/
+examples/
+rebuttal/
+apps/
+*.sh
+run.py
\ No newline at end of file
diff --git a/app.py b/app.py
new file mode 100644
index 0000000000000000000000000000000000000000..fb1f85e583b40d56576c91d9b40facf33d8d5fb7
--- /dev/null
+++ b/app.py
@@ -0,0 +1,88 @@
+import os
+if 'OMP_NUM_THREADS' not in os.environ:
+ os.environ['OMP_NUM_THREADS'] = '16'
+import torch
+import gradio as gr
+from functools import partial
+from huggingface_hub import snapshot_download
+
+from freesplatter.webui.runner import FreeSplatterRunner
+from freesplatter.webui.tab_img_to_3d import create_interface_img_to_3d
+from freesplatter.webui.tab_views_to_3d import create_interface_views_to_3d
+from freesplatter.webui.tab_views_to_scene import create_interface_views_to_scene
+
+
+os.makedirs('./ckpts/Hunyuan3D-1', exist_ok=True)
+snapshot_download('tencent/Hunyuan3D-1', repo_type='model', local_dir='./ckpts/Hunyuan3D-1')
+
+torch.set_grad_enabled(False)
+device = torch.device('cuda')
+runner = FreeSplatterRunner(device)
+
+
+_HEADER_ = '''
+# FreeSplatter 🤗 Gradio Demo
+\n\nOfficial demo of the paper [FreeSplatter: Pose-free Gaussian Splatting for Sparse-view 3D Reconstruction](https://arxiv.org/abs/2404.07191). [[Github]](https://github.com/TencentARC/FreeSplatter)
+**FreeSplatter** is a feed-forward framework capable of generating high-quality 3D Gaussians from **uncalibrated** sparse-view images and recovering their camera parameters in mere seconds.
+'''
+
+_IMG_TO_3D_HELP_ = '''
+💡💡💡**Usage Tips:**
+- This demo supports various multi-view diffusion models, including [Hunyuan3D](https://github.com/Tencent/Hunyuan3D-1) Std and [Zero123++](https://github.com/SUDO-AI-3D/zero123plus) v1.1/v1.2. You can try different models to get the best result.
+- Try clicking the \U0001f3b2\ufe0f button to use a different `Random seed` (default: 42) for diverse outputs.
+- In most cases, using `2DGS` leads to better mesh geometry than `3DGS`. Please refer to the [2DGS paper](https://arxiv.org/abs/2403.17888).
+- You can adjust the views used for reconstruction to alleviate the blurry texture problem caused by multi-view inconsistency.
+'''
+
+_CITE_ = r"""
+If FreeSplatter is helpful, please help to ⭐ the Github Repo. Thanks! [![GitHub Stars](https://img.shields.io/github/stars/TencentARC/FreeSplatter?style=social)](https://github.com/TencentARC/FreeSplatter)
+---
+📝 **Citation**
+If you find our work useful for your research or applications, please cite using this bibtex:
+```bibtex
+@article{xu2024freesplatter,
+ title={FreeSplatter: Pose-free Gaussian Splatting for Sparse-view 3D Reconstruction},
+ author={Xu, Jiale and Gao, Shenghua and Shan, Ying},
+ journal={arXiv preprint},
+ year={2024}
+}
+```
+📋 **License**
+Apache-2.0 LICENSE. Please refer to the [LICENSE file](https://huggingface.co/spaces/TencentARC/FreeSplatter/blob/main/LICENSE) for details.
+📧 **Contact**
+If you have any questions, feel free to open a discussion or contact us at bluestyle928@gmail.com.
+"""
+
+
+with gr.Blocks(analytics_enabled=False, title='FreeSplatter Demo', theme=gr.themes.Ocean()) as demo:
+ gr.Markdown(_HEADER_)
+
+ with gr.Tabs() as main_tabs:
+ with gr.TabItem('Image-to-3D', id='tab_img_to_3d'):
+ gr.Markdown(_IMG_TO_3D_HELP_)
+
+ with gr.Tabs() as sub_tabs_img_to_3d:
+ with gr.TabItem('Hunyuan3D Std', id='tab_hunyuan3d_std'):
+ _, var_img_to_3d_hunyuan3d_std = create_interface_img_to_3d(
+ runner.run_segmentation,
+ runner.run_img_to_3d,
+ model='Hunyuan3D Std')
+ with gr.TabItem('Zero123++ v1.1', id='tab_zero123plus_v11'):
+ _, var_img_to_3d_zero123plus_v11 = create_interface_img_to_3d(
+ runner.run_segmentation,
+ runner.run_img_to_3d,
+ model='Zero123++ v1.1')
+ with gr.TabItem('Zero123++ v1.2', id='tab_zero123plus_v12'):
+ _, var_img_to_3d_zero123plus_v12 = create_interface_img_to_3d(
+ runner.run_segmentation,
+ runner.run_img_to_3d,
+ model='Zero123++ v1.2')
+
+ gr.Markdown(_CITE_)
+
+ demo.queue().launch(
+ share=False,
+ server_name="0.0.0.0",
+ server_port=41137,
+ ssl_verify=False,
+ )
diff --git a/configs/freesplatter-object-2dgs.yaml b/configs/freesplatter-object-2dgs.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..28addc4fb9a0eb44b064a3bb9b397193b1090396
--- /dev/null
+++ b/configs/freesplatter-object-2dgs.yaml
@@ -0,0 +1,22 @@
+model:
+ target: freesplatter.models.model.FreeSplatterModel
+ params:
+ transformer_config:
+ target: freesplatter.models.transformer.Transformer
+ params:
+ patch_size: 8
+ input_dim: 3
+ inner_dim: 1024
+ output_dim: 22
+ depth: 24
+ n_heads: 16
+ renderer_config:
+ sh_degree: 1
+ img_height: 512
+ img_width: 512
+ scaling_activation_type: sigmoid
+ scale_min_act: 0.0001
+ scale_max_act: 0.02
+ scale_multi_act: 0.1
+ sh_residual: false
+ use_2dgs: true
\ No newline at end of file
diff --git a/configs/freesplatter-object.yaml b/configs/freesplatter-object.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..161930dba4b70d8742864ecdd15b6cdc02614a18
--- /dev/null
+++ b/configs/freesplatter-object.yaml
@@ -0,0 +1,21 @@
+model:
+ target: freesplatter.models.model.FreeSplatterModel
+ params:
+ transformer_config:
+ target: freesplatter.models.transformer.Transformer
+ params:
+ patch_size: 8
+ input_dim: 3
+ inner_dim: 1024
+ output_dim: 23
+ depth: 24
+ n_heads: 16
+ renderer_config:
+ sh_degree: 1
+ img_height: 512
+ img_width: 512
+ scaling_activation_type: sigmoid
+ scale_min_act: 0.0001
+ scale_max_act: 0.02
+ scale_multi_act: 0.1
+ sh_residual: false
diff --git a/configs/freesplatter-scene.yaml b/configs/freesplatter-scene.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..336eee14ded4cc2a13729b39f1d0f4e78c75f88e
--- /dev/null
+++ b/configs/freesplatter-scene.yaml
@@ -0,0 +1,22 @@
+model:
+ target: freesplatter.models.model.FreeSplatterModel
+ params:
+ transformer_config:
+ target: freesplatter.models.transformer.Transformer
+ params:
+ patch_size: 8
+ input_dim: 3
+ inner_dim: 1024
+ output_dim: 23
+ depth: 24
+ n_heads: 16
+ renderer_config:
+ sh_degree: 1
+ img_height: 512
+ img_width: 512
+ scaling_activation_type: sigmoid
+ scale_min_act: 0.0001
+ scale_max_act: 0.02
+ scale_multi_act: 0.1
+ bg_color: [0., 0., 0.]
+ sh_residual: true
diff --git a/examples/img_to_3d/avatar.png b/examples/img_to_3d/avatar.png
new file mode 100644
index 0000000000000000000000000000000000000000..88e80fc4d1d727fbedca1daa248a127fecf7876b
--- /dev/null
+++ b/examples/img_to_3d/avatar.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:d49ccccd40fe0317c2886b0d36a11667003d17a49cc49d9244208d250de9fe31
+size 1169069
diff --git a/examples/img_to_3d/backpack.jpg b/examples/img_to_3d/backpack.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..f2aca738641026da09ecae4154999cfacfcef728
Binary files /dev/null and b/examples/img_to_3d/backpack.jpg differ
diff --git a/examples/img_to_3d/basketball.jpg b/examples/img_to_3d/basketball.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..33ee575f165bfda8506aebe98e59de0e97ecb93d
Binary files /dev/null and b/examples/img_to_3d/basketball.jpg differ
diff --git a/examples/img_to_3d/bird.jpg b/examples/img_to_3d/bird.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..a9df5381a26aa58e27cbfac610da58d54d6c86de
Binary files /dev/null and b/examples/img_to_3d/bird.jpg differ
diff --git a/examples/img_to_3d/boy.jpg b/examples/img_to_3d/boy.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..ce7a7e1126113f20deb39ab9136a71292624b5ab
Binary files /dev/null and b/examples/img_to_3d/boy.jpg differ
diff --git a/examples/img_to_3d/bread.jpg b/examples/img_to_3d/bread.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..8493ae28f0c9e30da165a9b016af9861589aa6ea
Binary files /dev/null and b/examples/img_to_3d/bread.jpg differ
diff --git a/examples/img_to_3d/bull.jpg b/examples/img_to_3d/bull.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..5d10657a83b174abe42d97b78e684ffea164b6be
Binary files /dev/null and b/examples/img_to_3d/bull.jpg differ
diff --git a/examples/img_to_3d/camera.jpg b/examples/img_to_3d/camera.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..1ab9fd78356a76770204e5154769296ebec04339
Binary files /dev/null and b/examples/img_to_3d/camera.jpg differ
diff --git a/examples/img_to_3d/censer.jpg b/examples/img_to_3d/censer.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..42664b9ca0e9c46d6cf735eb0f168e61157ea703
Binary files /dev/null and b/examples/img_to_3d/censer.jpg differ
diff --git a/examples/img_to_3d/chair.jpg b/examples/img_to_3d/chair.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..de3c92064306b665010d4048caf129e634b858c7
Binary files /dev/null and b/examples/img_to_3d/chair.jpg differ
diff --git a/examples/img_to_3d/chair2.jpg b/examples/img_to_3d/chair2.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..6939a2923c0c0585ecaef6333bd5bf9e7f77db63
Binary files /dev/null and b/examples/img_to_3d/chair2.jpg differ
diff --git a/examples/img_to_3d/chameleon.jpg b/examples/img_to_3d/chameleon.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..56f8494f0dc3c0adc4a863f754686ffcfb5c2457
Binary files /dev/null and b/examples/img_to_3d/chameleon.jpg differ
diff --git a/examples/img_to_3d/chicken.jpg b/examples/img_to_3d/chicken.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..066ab32be73334b551d5130048259cb63006a865
Binary files /dev/null and b/examples/img_to_3d/chicken.jpg differ
diff --git a/examples/img_to_3d/close.jpg b/examples/img_to_3d/close.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..fd2a24fa3a3eaeb9c60ac90e00eb40780fe6106d
Binary files /dev/null and b/examples/img_to_3d/close.jpg differ
diff --git a/examples/img_to_3d/crab.jpg b/examples/img_to_3d/crab.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..8c4a010c0640f8aad78fbf2fe5b1c8d142b7cc04
Binary files /dev/null and b/examples/img_to_3d/crab.jpg differ
diff --git a/examples/img_to_3d/crocodile.jpg b/examples/img_to_3d/crocodile.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..0a365c097b54b43eb8c48301ff062e1bcb7c3517
Binary files /dev/null and b/examples/img_to_3d/crocodile.jpg differ
diff --git a/examples/img_to_3d/cute_tiger.jpg b/examples/img_to_3d/cute_tiger.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..82e873258d9f3fd6d569205ab75deb8a26918356
Binary files /dev/null and b/examples/img_to_3d/cute_tiger.jpg differ
diff --git a/examples/img_to_3d/cybertruck.jpg b/examples/img_to_3d/cybertruck.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..c5e34a94fd79977c656dc25d1916e9742f3d9f7e
Binary files /dev/null and b/examples/img_to_3d/cybertruck.jpg differ
diff --git a/examples/img_to_3d/dog.jpg b/examples/img_to_3d/dog.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..c46deafb812a5b7fd82b609e7ff38cbaaaa08d1e
Binary files /dev/null and b/examples/img_to_3d/dog.jpg differ
diff --git a/examples/img_to_3d/dog2.jpg b/examples/img_to_3d/dog2.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..7c076d06e6ca84672c1f48c76e50bc4337f94b5c
Binary files /dev/null and b/examples/img_to_3d/dog2.jpg differ
diff --git a/examples/img_to_3d/donkey.jpg b/examples/img_to_3d/donkey.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..87cbb2566cd080e3b496e560c7d9f26aa3380bef
Binary files /dev/null and b/examples/img_to_3d/donkey.jpg differ
diff --git a/examples/img_to_3d/dragon.jpg b/examples/img_to_3d/dragon.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..104dd7f2567c89bed00bd8a34e673734100f5889
Binary files /dev/null and b/examples/img_to_3d/dragon.jpg differ
diff --git a/examples/img_to_3d/fox.jpg b/examples/img_to_3d/fox.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..1f2efc1c3a9c4ad8f36ad93082c124c91a6e9ef7
Binary files /dev/null and b/examples/img_to_3d/fox.jpg differ
diff --git a/examples/img_to_3d/girl.jpg b/examples/img_to_3d/girl.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..effedefd9c62eb130479a0ea059f3c1f2b860831
Binary files /dev/null and b/examples/img_to_3d/girl.jpg differ
diff --git a/examples/img_to_3d/girl2.jpg b/examples/img_to_3d/girl2.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..f7414c1de7bf2d9899602aa282c282d4186b53ed
Binary files /dev/null and b/examples/img_to_3d/girl2.jpg differ
diff --git a/examples/img_to_3d/goat.jpg b/examples/img_to_3d/goat.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..0e7a2debe92985ab4143edec1cf944a8d662cd8f
Binary files /dev/null and b/examples/img_to_3d/goat.jpg differ
diff --git a/examples/img_to_3d/harp.jpg b/examples/img_to_3d/harp.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..60e0d6c278219e6ba90abcf2a815329a6cd3396b
Binary files /dev/null and b/examples/img_to_3d/harp.jpg differ
diff --git a/examples/img_to_3d/head.jpg b/examples/img_to_3d/head.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..a58aa6416159379eca135a5e554945b078f76fd7
Binary files /dev/null and b/examples/img_to_3d/head.jpg differ
diff --git a/examples/img_to_3d/house.jpg b/examples/img_to_3d/house.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..56f5cc0148543223000bd8daf1ea6a22ce7fe035
Binary files /dev/null and b/examples/img_to_3d/house.jpg differ
diff --git a/examples/img_to_3d/house2.jpg b/examples/img_to_3d/house2.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..6f808115c8c97dca6f5399e730e25af45a6a7110
Binary files /dev/null and b/examples/img_to_3d/house2.jpg differ
diff --git a/examples/img_to_3d/king.jpg b/examples/img_to_3d/king.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..cb11ea515f03491c778b8cde8689f3cfb262932b
Binary files /dev/null and b/examples/img_to_3d/king.jpg differ
diff --git a/examples/img_to_3d/lion.png b/examples/img_to_3d/lion.png
new file mode 100644
index 0000000000000000000000000000000000000000..849e3a578a55b6abd0bde372d7ec032c8915e9d9
--- /dev/null
+++ b/examples/img_to_3d/lion.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:cace48d8ecfd3544ad46ced1bd010e4761ce6ef95ff0d5f2831635539b0ca522
+size 1480528
diff --git a/examples/img_to_3d/magician.jpg b/examples/img_to_3d/magician.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..71ccdf68e369e2d2eccef30f7cd13561d8f38ec8
Binary files /dev/null and b/examples/img_to_3d/magician.jpg differ
diff --git a/examples/img_to_3d/peach.jpg b/examples/img_to_3d/peach.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..95025cfe0c01a635b8c42b3b0472e0d416d0e18d
Binary files /dev/null and b/examples/img_to_3d/peach.jpg differ
diff --git a/examples/img_to_3d/robot.jpg b/examples/img_to_3d/robot.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..91f00bc676cd20147012714ff04df6a38973e213
Binary files /dev/null and b/examples/img_to_3d/robot.jpg differ
diff --git a/examples/img_to_3d/robot2.jpg b/examples/img_to_3d/robot2.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..3eb3a1005a70ebee692f40c37ff4fc55fd0490b5
Binary files /dev/null and b/examples/img_to_3d/robot2.jpg differ
diff --git a/examples/img_to_3d/sculpture.png b/examples/img_to_3d/sculpture.png
new file mode 100644
index 0000000000000000000000000000000000000000..6c1e30acfb67a99da531571d2feaf5d3060ffefc
--- /dev/null
+++ b/examples/img_to_3d/sculpture.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:d947e0ef10baf761abb78d2842519ae7428bc6eadab26a159510ddcaf2a47e67
+size 1066046
diff --git a/examples/img_to_3d/sculpture2.jpg b/examples/img_to_3d/sculpture2.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..0e10f7ce7dc5fd51121a804d26c7c5c64f8f71ca
Binary files /dev/null and b/examples/img_to_3d/sculpture2.jpg differ
diff --git a/examples/img_to_3d/sign.jpg b/examples/img_to_3d/sign.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..7a5e671c93c70bd17aa444b16f58c63bb524150b
Binary files /dev/null and b/examples/img_to_3d/sign.jpg differ
diff --git a/examples/img_to_3d/sit.jpg b/examples/img_to_3d/sit.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..840a79c386b482501cc4f19d58acdfd61dce662d
Binary files /dev/null and b/examples/img_to_3d/sit.jpg differ
diff --git a/examples/img_to_3d/skateboard.jpg b/examples/img_to_3d/skateboard.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..9c6fd8fb8cc68f6676d69683c1fd0b97f560efdd
Binary files /dev/null and b/examples/img_to_3d/skateboard.jpg differ
diff --git a/examples/img_to_3d/stitch.jpg b/examples/img_to_3d/stitch.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..1d6edf237f38258bbc46b03f7f10bfee170214bc
Binary files /dev/null and b/examples/img_to_3d/stitch.jpg differ
diff --git a/examples/img_to_3d/stone.jpg b/examples/img_to_3d/stone.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..8ad1bdbf9f318042e1748d6cfd5d28d0c04ebf20
Binary files /dev/null and b/examples/img_to_3d/stone.jpg differ
diff --git a/examples/img_to_3d/teddy_bread.jpg b/examples/img_to_3d/teddy_bread.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..69efb7ce6025660fe1e1aba953b380574c6dd888
Binary files /dev/null and b/examples/img_to_3d/teddy_bread.jpg differ
diff --git a/examples/img_to_3d/tennis.jpg b/examples/img_to_3d/tennis.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..6d0af3553f8cd3c88a33c78fca8b38ed7e93dfcf
Binary files /dev/null and b/examples/img_to_3d/tennis.jpg differ
diff --git a/examples/img_to_3d/vase.jpg b/examples/img_to_3d/vase.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..7dca370f3dfeb3037313557edb71e8eb28dd0b86
Binary files /dev/null and b/examples/img_to_3d/vase.jpg differ
diff --git a/examples/img_to_3d/well.jpg b/examples/img_to_3d/well.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..91f8385bcf93e0a0a47adf683603d76528a8d9ca
Binary files /dev/null and b/examples/img_to_3d/well.jpg differ
diff --git a/examples/img_to_3d/yoga.jpg b/examples/img_to_3d/yoga.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..4f2a2bcb67bd53054ecc4589f62cd16da8f9edca
Binary files /dev/null and b/examples/img_to_3d/yoga.jpg differ
diff --git a/examples/views_to_3d/ABO_B073P1H6KJ/004.png b/examples/views_to_3d/ABO_B073P1H6KJ/004.png
new file mode 100644
index 0000000000000000000000000000000000000000..df2c9dd88bd6277c5bb27adf158a8b19a78b65b0
Binary files /dev/null and b/examples/views_to_3d/ABO_B073P1H6KJ/004.png differ
diff --git a/examples/views_to_3d/ABO_B073P1H6KJ/009.png b/examples/views_to_3d/ABO_B073P1H6KJ/009.png
new file mode 100644
index 0000000000000000000000000000000000000000..00ff2ba0b9435ac972c6aec183b23863920d89a8
Binary files /dev/null and b/examples/views_to_3d/ABO_B073P1H6KJ/009.png differ
diff --git a/examples/views_to_3d/ABO_B073P1H6KJ/014.png b/examples/views_to_3d/ABO_B073P1H6KJ/014.png
new file mode 100644
index 0000000000000000000000000000000000000000..fd9d45fe38e21356e20b9bfbca8ba4c8c78be152
Binary files /dev/null and b/examples/views_to_3d/ABO_B073P1H6KJ/014.png differ
diff --git a/examples/views_to_3d/ABO_B073P1H6KJ/021.png b/examples/views_to_3d/ABO_B073P1H6KJ/021.png
new file mode 100644
index 0000000000000000000000000000000000000000..48e73d9d60a98320fd22ee001eb0e1a0d3cb1ce6
Binary files /dev/null and b/examples/views_to_3d/ABO_B073P1H6KJ/021.png differ
diff --git a/examples/views_to_3d/GSO_CASTLE_BLOCKS/002.png b/examples/views_to_3d/GSO_CASTLE_BLOCKS/002.png
new file mode 100644
index 0000000000000000000000000000000000000000..6c1155b67a05b2b45215905b732822c6162e9064
Binary files /dev/null and b/examples/views_to_3d/GSO_CASTLE_BLOCKS/002.png differ
diff --git a/examples/views_to_3d/GSO_CASTLE_BLOCKS/007.png b/examples/views_to_3d/GSO_CASTLE_BLOCKS/007.png
new file mode 100644
index 0000000000000000000000000000000000000000..81b9db5f7fc8647448fce9ba9ca12968292cb2c1
Binary files /dev/null and b/examples/views_to_3d/GSO_CASTLE_BLOCKS/007.png differ
diff --git a/examples/views_to_3d/GSO_CASTLE_BLOCKS/012.png b/examples/views_to_3d/GSO_CASTLE_BLOCKS/012.png
new file mode 100644
index 0000000000000000000000000000000000000000..5374a91334ced64cdf10ca2cc9aa795734fc2802
Binary files /dev/null and b/examples/views_to_3d/GSO_CASTLE_BLOCKS/012.png differ
diff --git a/examples/views_to_3d/GSO_CASTLE_BLOCKS/018.png b/examples/views_to_3d/GSO_CASTLE_BLOCKS/018.png
new file mode 100644
index 0000000000000000000000000000000000000000..4983e4350e2e5b1b418c901600bf2779408ad82c
Binary files /dev/null and b/examples/views_to_3d/GSO_CASTLE_BLOCKS/018.png differ
diff --git a/examples/views_to_3d/GSO_GEOMETRIC_SORTING_BOARD/002.png b/examples/views_to_3d/GSO_GEOMETRIC_SORTING_BOARD/002.png
new file mode 100644
index 0000000000000000000000000000000000000000..5fe39fa27b01b7d93fbaf9a247500e459eac6e5a
Binary files /dev/null and b/examples/views_to_3d/GSO_GEOMETRIC_SORTING_BOARD/002.png differ
diff --git a/examples/views_to_3d/GSO_GEOMETRIC_SORTING_BOARD/007.png b/examples/views_to_3d/GSO_GEOMETRIC_SORTING_BOARD/007.png
new file mode 100644
index 0000000000000000000000000000000000000000..b4312ea49d16365c2dff0ed92bf09bf6808995d6
Binary files /dev/null and b/examples/views_to_3d/GSO_GEOMETRIC_SORTING_BOARD/007.png differ
diff --git a/examples/views_to_3d/GSO_GEOMETRIC_SORTING_BOARD/014.png b/examples/views_to_3d/GSO_GEOMETRIC_SORTING_BOARD/014.png
new file mode 100644
index 0000000000000000000000000000000000000000..eb078c5af5e12fdc1facb4621fd4ec5ed8882be2
Binary files /dev/null and b/examples/views_to_3d/GSO_GEOMETRIC_SORTING_BOARD/014.png differ
diff --git a/examples/views_to_3d/GSO_GEOMETRIC_SORTING_BOARD/023.png b/examples/views_to_3d/GSO_GEOMETRIC_SORTING_BOARD/023.png
new file mode 100644
index 0000000000000000000000000000000000000000..b8e395f7a46d652493c7f7f6f508c97c196f0b3f
Binary files /dev/null and b/examples/views_to_3d/GSO_GEOMETRIC_SORTING_BOARD/023.png differ
diff --git a/examples/views_to_3d/GSO_MODERN_DOLL_FAMILY/000.png b/examples/views_to_3d/GSO_MODERN_DOLL_FAMILY/000.png
new file mode 100644
index 0000000000000000000000000000000000000000..382bb93f4024a6443d96a350f68848381f47c49f
Binary files /dev/null and b/examples/views_to_3d/GSO_MODERN_DOLL_FAMILY/000.png differ
diff --git a/examples/views_to_3d/GSO_MODERN_DOLL_FAMILY/004.png b/examples/views_to_3d/GSO_MODERN_DOLL_FAMILY/004.png
new file mode 100644
index 0000000000000000000000000000000000000000..386582baca46f3feb28ed0a3521efe29b8f70b6f
Binary files /dev/null and b/examples/views_to_3d/GSO_MODERN_DOLL_FAMILY/004.png differ
diff --git a/examples/views_to_3d/GSO_MODERN_DOLL_FAMILY/013.png b/examples/views_to_3d/GSO_MODERN_DOLL_FAMILY/013.png
new file mode 100644
index 0000000000000000000000000000000000000000..6dabe3199f2802372459d37ad6592c84f6b21bfa
Binary files /dev/null and b/examples/views_to_3d/GSO_MODERN_DOLL_FAMILY/013.png differ
diff --git a/examples/views_to_3d/GSO_MODERN_DOLL_FAMILY/019.png b/examples/views_to_3d/GSO_MODERN_DOLL_FAMILY/019.png
new file mode 100644
index 0000000000000000000000000000000000000000..754088288f4b766b4a24f5d1d8b09297d15b5ab4
Binary files /dev/null and b/examples/views_to_3d/GSO_MODERN_DOLL_FAMILY/019.png differ
diff --git a/examples/views_to_3d/GSO_Transformers_Age_of_Extinction_Mega_1Step_Bumblebee_Figure/001.png b/examples/views_to_3d/GSO_Transformers_Age_of_Extinction_Mega_1Step_Bumblebee_Figure/001.png
new file mode 100644
index 0000000000000000000000000000000000000000..079b9f6fa0a8df8159701ba1464eb8ae422bdfae
Binary files /dev/null and b/examples/views_to_3d/GSO_Transformers_Age_of_Extinction_Mega_1Step_Bumblebee_Figure/001.png differ
diff --git a/examples/views_to_3d/GSO_Transformers_Age_of_Extinction_Mega_1Step_Bumblebee_Figure/005.png b/examples/views_to_3d/GSO_Transformers_Age_of_Extinction_Mega_1Step_Bumblebee_Figure/005.png
new file mode 100644
index 0000000000000000000000000000000000000000..835d81fa6f7ba207927bc040de26165e394cda58
Binary files /dev/null and b/examples/views_to_3d/GSO_Transformers_Age_of_Extinction_Mega_1Step_Bumblebee_Figure/005.png differ
diff --git a/examples/views_to_3d/GSO_Transformers_Age_of_Extinction_Mega_1Step_Bumblebee_Figure/013.png b/examples/views_to_3d/GSO_Transformers_Age_of_Extinction_Mega_1Step_Bumblebee_Figure/013.png
new file mode 100644
index 0000000000000000000000000000000000000000..8825d8f02e966ec289ad1c1ce041f8197aa796fe
Binary files /dev/null and b/examples/views_to_3d/GSO_Transformers_Age_of_Extinction_Mega_1Step_Bumblebee_Figure/013.png differ
diff --git a/examples/views_to_3d/GSO_Transformers_Age_of_Extinction_Mega_1Step_Bumblebee_Figure/019.png b/examples/views_to_3d/GSO_Transformers_Age_of_Extinction_Mega_1Step_Bumblebee_Figure/019.png
new file mode 100644
index 0000000000000000000000000000000000000000..65a7eb73e8396f0e51ac6788ee5a3a7fdc111213
Binary files /dev/null and b/examples/views_to_3d/GSO_Transformers_Age_of_Extinction_Mega_1Step_Bumblebee_Figure/019.png differ
diff --git a/examples/views_to_scene/blendedmvs_1/001.png b/examples/views_to_scene/blendedmvs_1/001.png
new file mode 100644
index 0000000000000000000000000000000000000000..348cba62a056cca956a89f3aa63bd04ac30bf02a
Binary files /dev/null and b/examples/views_to_scene/blendedmvs_1/001.png differ
diff --git a/examples/views_to_scene/blendedmvs_1/002.png b/examples/views_to_scene/blendedmvs_1/002.png
new file mode 100644
index 0000000000000000000000000000000000000000..87384e6c5674b79f9b7b2da607df4144dec81ca2
Binary files /dev/null and b/examples/views_to_scene/blendedmvs_1/002.png differ
diff --git a/examples/views_to_scene/co3d_1/000.jpg b/examples/views_to_scene/co3d_1/000.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..19fd5006300999734f05d3c6eddbefdbab6e250b
Binary files /dev/null and b/examples/views_to_scene/co3d_1/000.jpg differ
diff --git a/examples/views_to_scene/co3d_1/001.jpg b/examples/views_to_scene/co3d_1/001.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..48d4c59dc52b5e4cbb83b0aa7810847c3be1e0c9
Binary files /dev/null and b/examples/views_to_scene/co3d_1/001.jpg differ
diff --git a/examples/views_to_scene/dtu_1/000000.png b/examples/views_to_scene/dtu_1/000000.png
new file mode 100644
index 0000000000000000000000000000000000000000..9c4948a7b2e06838f614b6c1f0b09f636419fedb
--- /dev/null
+++ b/examples/views_to_scene/dtu_1/000000.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:169610796b49c4185b85831ed77afbfe68974cdb4b8352c649f2d5ba4535db2d
+size 3250261
diff --git a/examples/views_to_scene/dtu_1/000002.png b/examples/views_to_scene/dtu_1/000002.png
new file mode 100644
index 0000000000000000000000000000000000000000..25e8656bbc5a7cbc3e5b4c0f2188e90898fb5ee7
--- /dev/null
+++ b/examples/views_to_scene/dtu_1/000002.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:79cef6b58587899f1b2f7e13a55dc4f1a2bee12cf08801c07d164ff37aa62fbe
+size 3096836
diff --git a/examples/views_to_scene/re10k_1/000008.png b/examples/views_to_scene/re10k_1/000008.png
new file mode 100644
index 0000000000000000000000000000000000000000..e9a42931b143f96bc3055b7ab18feff26e665fbd
Binary files /dev/null and b/examples/views_to_scene/re10k_1/000008.png differ
diff --git a/examples/views_to_scene/re10k_1/000071.png b/examples/views_to_scene/re10k_1/000071.png
new file mode 100644
index 0000000000000000000000000000000000000000..a1201b52ddb94d8eb85fb34f90f17c7733d0df61
Binary files /dev/null and b/examples/views_to_scene/re10k_1/000071.png differ
diff --git a/examples/views_to_scene/re10k_2/000064.png b/examples/views_to_scene/re10k_2/000064.png
new file mode 100644
index 0000000000000000000000000000000000000000..61da49c0109e065cebc154d4b834e0fa48695616
Binary files /dev/null and b/examples/views_to_scene/re10k_2/000064.png differ
diff --git a/examples/views_to_scene/re10k_2/000157.png b/examples/views_to_scene/re10k_2/000157.png
new file mode 100644
index 0000000000000000000000000000000000000000..383c35f656e7da7e06b169f6bdb3004f16acae39
Binary files /dev/null and b/examples/views_to_scene/re10k_2/000157.png differ
diff --git a/examples/views_to_scene/scannetpp_1/001.jpg b/examples/views_to_scene/scannetpp_1/001.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..27be069a04080346b01e631c18be0d6b86ca06a1
Binary files /dev/null and b/examples/views_to_scene/scannetpp_1/001.jpg differ
diff --git a/examples/views_to_scene/scannetpp_1/002.jpg b/examples/views_to_scene/scannetpp_1/002.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..3200759f0ee7755c43f04de7f8050fa4737f3e5e
Binary files /dev/null and b/examples/views_to_scene/scannetpp_1/002.jpg differ
diff --git a/examples/views_to_scene/scannetpp_2/000.jpg b/examples/views_to_scene/scannetpp_2/000.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..94202b3593bf4a872d723dfc332d77f363aa1cf1
Binary files /dev/null and b/examples/views_to_scene/scannetpp_2/000.jpg differ
diff --git a/examples/views_to_scene/scannetpp_2/001.jpg b/examples/views_to_scene/scannetpp_2/001.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..9c8ec69c35d7686702a91dc668015988a67a28fe
Binary files /dev/null and b/examples/views_to_scene/scannetpp_2/001.jpg differ
diff --git a/examples/views_to_scene/scannetpp_3/000.jpg b/examples/views_to_scene/scannetpp_3/000.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..d626b6429de9330da509888191fe06901915d4cd
Binary files /dev/null and b/examples/views_to_scene/scannetpp_3/000.jpg differ
diff --git a/examples/views_to_scene/scannetpp_3/001.jpg b/examples/views_to_scene/scannetpp_3/001.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..061c841d5db5cafca9972ea7ae7435e90edcee84
Binary files /dev/null and b/examples/views_to_scene/scannetpp_3/001.jpg differ
diff --git a/examples/views_to_scene/wild_1/000.jpg b/examples/views_to_scene/wild_1/000.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..91633bb60a874a500d5e0244fb1b314694d6e207
--- /dev/null
+++ b/examples/views_to_scene/wild_1/000.jpg
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:1a2f58b53d653f20761183d9150ec373c006f53f6c6a1f9dafc05696b00ede46
+size 2971683
diff --git a/examples/views_to_scene/wild_1/001.jpg b/examples/views_to_scene/wild_1/001.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..78c2875d111566ab06b2a876d4826cdff4f373de
--- /dev/null
+++ b/examples/views_to_scene/wild_1/001.jpg
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:2d0e81efd9be3fce34275e7fcb5a782817abf98bbc96d66c03847cc28b482f0d
+size 2896031
diff --git a/examples/views_to_scene/wild_2/000.jpg b/examples/views_to_scene/wild_2/000.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..1c5a266ea0808ccc6387854467be063ccda972dd
--- /dev/null
+++ b/examples/views_to_scene/wild_2/000.jpg
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:401e1fc9f8153c0cca4cdb25ce317273146e876f0e06d2b566c41c6a33138b55
+size 3636298
diff --git a/examples/views_to_scene/wild_2/001.jpg b/examples/views_to_scene/wild_2/001.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..f5624c29cbb84772dcbeb26e43e9a5ac67767686
--- /dev/null
+++ b/examples/views_to_scene/wild_2/001.jpg
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:cdd036a08304efe8f83bd8028dbaa24d438c96827c74a93abd77e6e7e442f105
+size 3489758
diff --git a/freesplatter/__init__.py b/freesplatter/__init__.py
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/freesplatter/hunyuan/__init__.py b/freesplatter/hunyuan/__init__.py
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/freesplatter/hunyuan/hunyuan3d_mvd_lite_pipeline.py b/freesplatter/hunyuan/hunyuan3d_mvd_lite_pipeline.py
new file mode 100644
index 0000000000000000000000000000000000000000..b35e9d6948d51ca8dbb2bb52b051b3bc6f730ad4
--- /dev/null
+++ b/freesplatter/hunyuan/hunyuan3d_mvd_lite_pipeline.py
@@ -0,0 +1,492 @@
+# Open Source Model Licensed under the Apache License Version 2.0 and Other Licenses of the Third-Party Components therein:
+# The below Model in this distribution may have been modified by THL A29 Limited ("Tencent Modifications"). All Tencent Modifications are Copyright (C) 2024 THL A29 Limited.
+
+# Copyright (C) 2024 THL A29 Limited, a Tencent company. All rights reserved.
+# The below software and/or models in this distribution may have been
+# modified by THL A29 Limited ("Tencent Modifications").
+# All Tencent Modifications are Copyright (C) THL A29 Limited.
+
+# Hunyuan 3D is licensed under the TENCENT HUNYUAN NON-COMMERCIAL LICENSE AGREEMENT
+# except for the third-party components listed below.
+# Hunyuan 3D does not impose any additional limitations beyond what is outlined
+# in the repsective licenses of these third-party components.
+# Users must comply with all terms and conditions of original licenses of these third-party
+# components and must ensure that the usage of the third party components adheres to
+# all relevant laws and regulations.
+
+# For avoidance of doubts, Hunyuan 3D means the large language models and
+# their software and algorithms, including trained model weights, parameters (including
+# optimizer states), machine-learning model code, inference-enabling code, training-enabling code,
+# fine-tuning enabling code and other elements of the foregoing made publicly available
+# by Tencent in accordance with TENCENT HUNYUAN COMMUNITY LICENSE AGREEMENT.
+
+import math
+import numpy
+import torch
+import inspect
+import warnings
+from PIL import Image
+from einops import rearrange
+import torch.nn.functional as F
+from diffusers.utils.torch_utils import randn_tensor
+from diffusers.configuration_utils import FrozenDict
+from diffusers.image_processor import VaeImageProcessor
+from typing import Any, Callable, Dict, List, Optional, Union
+from diffusers.models import AutoencoderKL, UNet2DConditionModel
+from diffusers.schedulers import KarrasDiffusionSchedulers
+from diffusers.pipelines.pipeline_utils import DiffusionPipeline
+from diffusers.pipelines.stable_diffusion import StableDiffusionPipelineOutput
+from diffusers import DDPMScheduler, EulerAncestralDiscreteScheduler, ImagePipelineOutput
+from diffusers.loaders import (
+ FromSingleFileMixin,
+ LoraLoaderMixin,
+ TextualInversionLoaderMixin
+)
+from transformers import (
+ CLIPImageProcessor,
+ CLIPTextModel,
+ CLIPTokenizer,
+ CLIPVisionModelWithProjection
+)
+from diffusers.models.attention_processor import (
+ Attention,
+ AttnProcessor,
+ XFormersAttnProcessor,
+ AttnProcessor2_0
+)
+
+from .utils import to_rgb_image, white_out_background, recenter_img
+
+
+EXAMPLE_DOC_STRING = """
+ Examples:
+ ```py
+ >>> import torch
+ >>> from here import Hunyuan3d_MVD_Qing_Pipeline
+
+ >>> pipe = Hunyuan3d_MVD_Qing_Pipeline.from_pretrained(
+ ... "Tencent-Hunyuan-3D/MVD-Qing", torch_dtype=torch.float16
+ ... )
+ >>> pipe.to("cuda")
+
+ >>> img = Image.open("demo.png")
+ >>> res_img = pipe(img).images[0]
+"""
+
+def unscale_latents(latents): return latents / 0.75 + 0.22
+def unscale_image (image ): return image / 0.50 * 0.80
+
+
+def rescale_noise_cfg(noise_cfg, noise_pred_text, guidance_rescale=0.0):
+ std_text = noise_pred_text.std(dim=list(range(1, noise_pred_text.ndim)), keepdim=True)
+ std_cfg = noise_cfg.std(dim=list(range(1, noise_cfg.ndim)), keepdim=True)
+ noise_pred_rescaled = noise_cfg * (std_text / std_cfg)
+ noise_cfg = guidance_rescale * noise_pred_rescaled + (1 - guidance_rescale) * noise_cfg
+ return noise_cfg
+
+
+
+class ReferenceOnlyAttnProc(torch.nn.Module):
+ # reference attention
+ def __init__(self, chained_proc, enabled=False, name=None):
+ super().__init__()
+ self.enabled = enabled
+ self.chained_proc = chained_proc
+ self.name = name
+
+ def __call__(self, attn, hidden_states, encoder_hidden_states=None, attention_mask=None, mode="w", ref_dict=None):
+ if encoder_hidden_states is None: encoder_hidden_states = hidden_states
+ if self.enabled:
+ if mode == 'w':
+ ref_dict[self.name] = encoder_hidden_states
+ elif mode == 'r':
+ encoder_hidden_states = torch.cat([encoder_hidden_states, ref_dict.pop(self.name)], dim=1)
+ res = self.chained_proc(attn, hidden_states, encoder_hidden_states, attention_mask)
+ return res
+
+
+# class RowWiseAttnProcessor2_0:
+# def __call__(self, attn,
+# hidden_states,
+# encoder_hidden_states=None,
+# attention_mask=None,
+# temb=None,
+# num_views=6,
+# *args,
+# **kwargs):
+# residual = hidden_states
+# if attn.spatial_norm is not None: hidden_states = attn.spatial_norm(hidden_states, temb)
+
+# input_ndim = hidden_states.ndim
+# if input_ndim == 4:
+# batch_size, channel, height, width = hidden_states.shape
+# hidden_states = hidden_states.view(batch_size, channel, height * width).transpose(1, 2)
+
+# if encoder_hidden_states is None:
+# batch_size, sequence_length, _ = hidden_states.shape
+# else:
+# batch_size, sequence_length, _ = encoder_hidden_states.shape
+
+# if attention_mask is not None:
+# attention_mask = attn.prepare_attention_mask(attention_mask, sequence_length, batch_size)
+# attention_mask = attention_mask.view(batch_size, attn.heads, -1, attention_mask.shape[-1])
+# if attn.group_norm is not None: hidden_states = attn.group_norm(hidden_states.transpose(1, 2)).transpose(1, 2)
+
+# query = attn.to_q(hidden_states)
+# if encoder_hidden_states is None: encoder_hidden_states = hidden_states
+# elif attn.norm_cross: encoder_hidden_states = attn.norm_encoder_hidden_states(encoder_hidden_states)
+
+# # encoder_hidden_states [B, 6hw+hw, C] if ref att
+# key = attn.to_k(encoder_hidden_states) # [B, Vhw+hw, C]
+# value = attn.to_v(encoder_hidden_states) # [B, Vhw+hw, C]
+
+# mv_flag = hidden_states.shape[1] < encoder_hidden_states.shape[1] and encoder_hidden_states.shape[1] != 77
+# if mv_flag:
+# target_size = int(math.sqrt(hidden_states.shape[1] // num_views))
+# assert target_size ** 2 * num_views == hidden_states.shape[1]
+
+# gen_key = key[:, :num_views*target_size*target_size, :]
+# ref_key = key[:, num_views*target_size*target_size:, :]
+# gen_value = value[:, :num_views*target_size*target_size, :]
+# ref_value = value[:, num_views*target_size*target_size:, :]
+
+# # rowwise attention
+# query, gen_key, gen_value = \
+# rearrange( query, "b (v1 h v2 w) c -> (b h) (v1 v2 w) c",
+# v1=num_views//2, v2=2, h=target_size, w=target_size), \
+# rearrange( gen_key, "b (v1 h v2 w) c -> (b h) (v1 v2 w) c",
+# v1=num_views//2, v2=2, h=target_size, w=target_size), \
+# rearrange(gen_value, "b (v1 h v2 w) c -> (b h) (v1 v2 w) c",
+# v1=num_views//2, v2=2, h=target_size, w=target_size)
+
+# inner_dim = key.shape[-1]
+# ref_size = int(math.sqrt(ref_key.shape[1]))
+# ref_key_expanded = ref_key.view(batch_size, 1, ref_size * ref_size, inner_dim)
+# ref_key_expanded = ref_key_expanded.expand(-1, target_size, -1, -1).contiguous()
+# ref_key_expanded = ref_key_expanded.view(batch_size * target_size, ref_size * ref_size, inner_dim)
+# key = torch.cat([ gen_key, ref_key_expanded], dim=1)
+
+# ref_value_expanded = ref_value.view(batch_size, 1, ref_size * ref_size, inner_dim)
+# ref_value_expanded = ref_value_expanded.expand(-1, target_size, -1, -1).contiguous()
+# ref_value_expanded = ref_value_expanded.view(batch_size * target_size, ref_size * ref_size, inner_dim)
+# value = torch.cat([gen_value, ref_value_expanded], dim=1)
+# h = target_size
+# else:
+# target_size = int(math.sqrt(hidden_states.shape[1]))
+# h = 1
+# num_views = 1
+
+# inner_dim = key.shape[-1]
+# head_dim = inner_dim // attn.heads
+
+# query = query.view(batch_size * h, -1, attn.heads, head_dim).transpose(1, 2)
+# key = key.view(batch_size * h, -1, attn.heads, head_dim).transpose(1, 2)
+# value = value.view(batch_size * h, -1, attn.heads, head_dim).transpose(1, 2)
+
+# hidden_states = F.scaled_dot_product_attention(query, key, value,
+# attn_mask=attention_mask,
+# dropout_p=0.0,
+# is_causal=False)
+# hidden_states = hidden_states.transpose(1, 2).reshape(batch_size * h,
+# -1,
+# attn.heads * head_dim).to(query.dtype)
+# hidden_states = attn.to_out[1](attn.to_out[0](hidden_states))
+
+# if mv_flag: hidden_states = rearrange(hidden_states, "(b h) (v1 v2 w) c -> b (v1 h v2 w) c",
+# b=batch_size, v1=num_views//2,
+# v2=2, h=target_size, w=target_size)
+
+# if input_ndim == 4:
+# hidden_states = hidden_states.transpose(-1, -2)
+# hidden_states = hidden_states.reshape(batch_size,
+# channel,
+# target_size,
+# target_size)
+# if attn.residual_connection: hidden_states = hidden_states + residual
+# hidden_states = hidden_states / attn.rescale_output_factor
+# return hidden_states
+
+
+class RefOnlyNoisedUNet(torch.nn.Module):
+ def __init__(self, unet, train_sched, val_sched):
+ super().__init__()
+ self.unet = unet
+ self.train_sched = train_sched
+ self.val_sched = val_sched
+
+ unet_lora_attn_procs = dict()
+ for name, _ in unet.attn_processors.items():
+ unet_lora_attn_procs[name] = ReferenceOnlyAttnProc(AttnProcessor2_0(),
+ enabled=name.endswith("attn1.processor"),
+ name=name)
+ unet.set_attn_processor(unet_lora_attn_procs)
+
+ def __getattr__(self, name: str):
+ try:
+ return super().__getattr__(name)
+ except AttributeError:
+ return getattr(self.unet, name)
+
+ def forward(self, sample, timestep, encoder_hidden_states, *args, cross_attention_kwargs, **kwargs):
+ cond_lat = cross_attention_kwargs['cond_lat']
+ noise = torch.randn_like(cond_lat)
+ if self.training:
+ noisy_cond_lat = self.train_sched.add_noise(cond_lat, noise, timestep)
+ noisy_cond_lat = self.train_sched.scale_model_input(noisy_cond_lat, timestep)
+ else:
+ noisy_cond_lat = self.val_sched.add_noise(cond_lat, noise, timestep.reshape(-1))
+ noisy_cond_lat = self.val_sched.scale_model_input(noisy_cond_lat, timestep.reshape(-1))
+
+ ref_dict = {}
+ self.unet(noisy_cond_lat,
+ timestep,
+ encoder_hidden_states,
+ *args,
+ cross_attention_kwargs=dict(mode="w", ref_dict=ref_dict),
+ **kwargs)
+ return self.unet(sample,
+ timestep,
+ encoder_hidden_states,
+ *args,
+ cross_attention_kwargs=dict(mode="r", ref_dict=ref_dict),
+ **kwargs)
+
+
+class Hunyuan3d_MVD_Lite_Pipeline(DiffusionPipeline, TextualInversionLoaderMixin, LoraLoaderMixin, FromSingleFileMixin):
+ def __init__(
+ self,
+ vae: AutoencoderKL,
+ text_encoder: CLIPTextModel,
+ tokenizer: CLIPTokenizer,
+ unet: UNet2DConditionModel,
+ scheduler: KarrasDiffusionSchedulers,
+ vision_encoder: CLIPVisionModelWithProjection,
+ feature_extractor_clip: CLIPImageProcessor,
+ feature_extractor_vae: CLIPImageProcessor,
+ ramping_coefficients: Optional[list] = None,
+ safety_checker=None,
+ ):
+ DiffusionPipeline.__init__(self)
+ self.register_modules(
+ vae=vae,
+ unet=unet,
+ tokenizer=tokenizer,
+ scheduler=scheduler,
+ text_encoder=text_encoder,
+ vision_encoder=vision_encoder,
+ feature_extractor_vae=feature_extractor_vae,
+ feature_extractor_clip=feature_extractor_clip)
+ '''
+ rewrite the stable diffusion pipeline
+ vae: vae
+ unet: unet
+ tokenizer: tokenizer
+ scheduler: scheduler
+ text_encoder: text_encoder
+ vision_encoder: vision_encoder
+ feature_extractor_vae: feature_extractor_vae
+ feature_extractor_clip: feature_extractor_clip
+ '''
+ self.register_to_config(ramping_coefficients=ramping_coefficients)
+ self.vae_scale_factor = 2 ** (len(self.vae.config.block_out_channels) - 1)
+ self.image_processor = VaeImageProcessor(vae_scale_factor=self.vae_scale_factor)
+
+ def prepare_extra_step_kwargs(self, generator, eta):
+ extra_step_kwargs = {}
+ accepts_eta = "eta" in set(inspect.signature(self.scheduler.step).parameters.keys())
+ if accepts_eta: extra_step_kwargs["eta"] = eta
+
+ accepts_generator = "generator" in set(inspect.signature(self.scheduler.step).parameters.keys())
+ if accepts_generator: extra_step_kwargs["generator"] = generator
+ return extra_step_kwargs
+
+ def prepare_latents(self, batch_size, num_channels_latents, height, width, dtype, device, generator, latents=None):
+ shape = (batch_size, num_channels_latents, height // self.vae_scale_factor, width // self.vae_scale_factor)
+ latents = randn_tensor(shape, generator=generator, device=device, dtype=dtype)
+ latents = latents * self.scheduler.init_noise_sigma
+ return latents
+
+ @torch.no_grad()
+ def _encode_prompt(
+ self,
+ prompt,
+ device,
+ num_images_per_prompt,
+ do_classifier_free_guidance,
+ negative_prompt=None,
+ prompt_embeds: Optional[torch.FloatTensor] = None,
+ negative_prompt_embeds: Optional[torch.FloatTensor] = None,
+ lora_scale: Optional[float] = None,
+ ):
+ if lora_scale is not None and isinstance(self, LoraLoaderMixin):
+ self._lora_scale = lora_scale
+
+ if prompt is not None and isinstance(prompt, str):
+ batch_size = 1
+ elif prompt is not None and isinstance(prompt, list):
+ batch_size = len(prompt)
+ else:
+ batch_size = prompt_embeds.shape[0]
+
+ if prompt_embeds is None:
+ if isinstance(self, TextualInversionLoaderMixin):
+ prompt = self.maybe_convert_prompt(prompt, self.tokenizer)
+
+ text_inputs = self.tokenizer(
+ prompt,
+ padding="max_length",
+ max_length=self.tokenizer.model_max_length,
+ truncation=True,
+ return_tensors="pt",
+ )
+ text_input_ids = text_inputs.input_ids
+
+ if hasattr(self.text_encoder.config, "use_attention_mask") and self.text_encoder.config.use_attention_mask:
+ attention_mask = text_inputs.attention_mask.to(device)
+ else:
+ attention_mask = None
+
+ prompt_embeds = self.text_encoder(text_input_ids.to(device), attention_mask=attention_mask)[0]
+
+ if self.text_encoder is not None:
+ prompt_embeds_dtype = self.text_encoder.dtype
+ elif self.unet is not None:
+ prompt_embeds_dtype = self.unet.dtype
+ else:
+ prompt_embeds_dtype = prompt_embeds.dtype
+
+ prompt_embeds = prompt_embeds.to(dtype=prompt_embeds_dtype, device=device)
+ bs_embed, seq_len, _ = prompt_embeds.shape
+ prompt_embeds = prompt_embeds.repeat(1, num_images_per_prompt, 1)
+ prompt_embeds = prompt_embeds.view(bs_embed * num_images_per_prompt, seq_len, -1)
+
+ if do_classifier_free_guidance and negative_prompt_embeds is None:
+ uncond_tokens: List[str]
+ if negative_prompt is None: uncond_tokens = [""] * batch_size
+ elif prompt is not None and type(prompt) is not type(negative_prompt): raise TypeError()
+ elif isinstance(negative_prompt, str): uncond_tokens = [negative_prompt]
+ elif batch_size != len(negative_prompt): raise ValueError()
+ else: uncond_tokens = negative_prompt
+ if isinstance(self, TextualInversionLoaderMixin):
+ uncond_tokens = self.maybe_convert_prompt(uncond_tokens, self.tokenizer)
+
+ max_length = prompt_embeds.shape[1]
+ uncond_input = self.tokenizer(uncond_tokens,
+ padding="max_length",
+ max_length=max_length,
+ truncation=True,
+ return_tensors="pt")
+
+ if hasattr(self.text_encoder.config, "use_attention_mask") and self.text_encoder.config.use_attention_mask:
+ attention_mask = uncond_input.attention_mask.to(device)
+ else:
+ attention_mask = None
+
+ negative_prompt_embeds = self.text_encoder(uncond_input.input_ids.to(device), attention_mask=attention_mask)
+ negative_prompt_embeds = negative_prompt_embeds[0]
+
+ if do_classifier_free_guidance:
+ seq_len = negative_prompt_embeds.shape[1]
+ negative_prompt_embeds = negative_prompt_embeds.to(dtype=prompt_embeds_dtype, device=device)
+ negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
+ negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
+ prompt_embeds = torch.cat([negative_prompt_embeds, prompt_embeds])
+
+ return prompt_embeds
+
+ @torch.no_grad()
+ def encode_condition_image(self, image: torch.Tensor): return self.vae.encode(image).latent_dist.sample()
+
+ @torch.no_grad()
+ def __call__(self, image=None,
+ width=640,
+ height=960,
+ num_inference_steps=75,
+ return_dict=True,
+ generator=None,
+ **kwargs):
+ batch_size = 1
+ num_images_per_prompt = 1
+ output_type = 'pil'
+ do_classifier_free_guidance = True
+ guidance_rescale = 0.
+ if isinstance(self.unet, UNet2DConditionModel):
+ self.unet = RefOnlyNoisedUNet(self.unet, None, self.scheduler).eval()
+
+ cond_image = recenter_img(image)
+ cond_image = to_rgb_image(image)
+ image = cond_image
+ image_1 = self.feature_extractor_vae(images=image, return_tensors="pt").pixel_values
+ image_2 = self.feature_extractor_clip(images=image, return_tensors="pt").pixel_values
+ image_1 = image_1.to(device=self.vae.device, dtype=self.vae.dtype)
+ image_2 = image_2.to(device=self.vae.device, dtype=self.vae.dtype)
+
+ cond_lat = self.encode_condition_image(image_1)
+ negative_lat = self.encode_condition_image(torch.zeros_like(image_1))
+ cond_lat = torch.cat([negative_lat, cond_lat])
+ cross_attention_kwargs = dict(cond_lat=cond_lat)
+
+ global_embeds = self.vision_encoder(image_2, output_hidden_states=False).image_embeds.unsqueeze(-2)
+ encoder_hidden_states = self._encode_prompt('', self.device, num_images_per_prompt, False)
+ ramp = global_embeds.new_tensor(self.config.ramping_coefficients).unsqueeze(-1)
+ prompt_embeds = torch.cat([encoder_hidden_states, encoder_hidden_states + global_embeds * ramp])
+
+ device = self._execution_device
+ self.scheduler.set_timesteps(num_inference_steps, device=device)
+ timesteps = self.scheduler.timesteps
+ num_channels_latents = self.unet.config.in_channels
+ latents = self.prepare_latents(batch_size * num_images_per_prompt,
+ num_channels_latents,
+ height,
+ width,
+ prompt_embeds.dtype,
+ device,
+ generator,
+ None)
+ extra_step_kwargs = self.prepare_extra_step_kwargs(generator, 0.0)
+ num_warmup_steps = len(timesteps) - num_inference_steps * self.scheduler.order
+
+ # set adaptive cfg
+ # the image order is:
+ # [0, 60,
+ # 120, 180,
+ # 240, 300]
+ # the cfg is set as 3, 2.5, 2, 1.5
+
+ tmp_guidance_scale = torch.ones_like(latents)
+ tmp_guidance_scale[:, :, :40, :40] = 3
+ tmp_guidance_scale[:, :, :40, 40:] = 2.5
+ tmp_guidance_scale[:, :, 40:80, :40] = 2
+ tmp_guidance_scale[:, :, 40:80, 40:] = 1.5
+ tmp_guidance_scale[:, :, 80:120, :40] = 2
+ tmp_guidance_scale[:, :, 80:120, 40:] = 2.5
+
+ with self.progress_bar(total=num_inference_steps) as progress_bar:
+ for i, t in enumerate(timesteps):
+ latent_model_input = torch.cat([latents] * 2) if do_classifier_free_guidance else latents
+ latent_model_input = self.scheduler.scale_model_input(latent_model_input, t)
+
+ noise_pred = self.unet(latent_model_input, t,
+ encoder_hidden_states=prompt_embeds,
+ cross_attention_kwargs=cross_attention_kwargs,
+ return_dict=False)[0]
+
+ adaptive_guidance_scale = (2 + 16 * (t / 1000) ** 5) / 3
+ if do_classifier_free_guidance:
+ noise_pred_uncond, noise_pred_text = noise_pred.chunk(2)
+ noise_pred = noise_pred_uncond + \
+ tmp_guidance_scale * adaptive_guidance_scale * \
+ (noise_pred_text - noise_pred_uncond)
+
+ if do_classifier_free_guidance and guidance_rescale > 0.0:
+ noise_pred = rescale_noise_cfg(noise_pred, noise_pred_text, guidance_rescale=guidance_rescale)
+
+ latents = self.scheduler.step(noise_pred, t, latents, **extra_step_kwargs, return_dict=False)[0]
+ if i==len(timesteps)-1 or ((i+1)>num_warmup_steps and (i+1)%self.scheduler.order==0):
+ progress_bar.update()
+
+ latents = unscale_latents(latents)
+ image = unscale_image(self.vae.decode(latents / self.vae.config.scaling_factor, return_dict=False)[0])
+ image = self.image_processor.postprocess(image, output_type='pil')[0]
+ image = [image, cond_image]
+ return ImagePipelineOutput(images=image) if return_dict else (image,)
\ No newline at end of file
diff --git a/freesplatter/hunyuan/hunyuan3d_mvd_std_pipeline.py b/freesplatter/hunyuan/hunyuan3d_mvd_std_pipeline.py
new file mode 100644
index 0000000000000000000000000000000000000000..2cb76fdc33579ceaad42da1e70875b358d97f2a7
--- /dev/null
+++ b/freesplatter/hunyuan/hunyuan3d_mvd_std_pipeline.py
@@ -0,0 +1,471 @@
+# Open Source Model Licensed under the Apache License Version 2.0 and Other Licenses of the Third-Party Components therein:
+# The below Model in this distribution may have been modified by THL A29 Limited ("Tencent Modifications"). All Tencent Modifications are Copyright (C) 2024 THL A29 Limited.
+
+# Copyright (C) 2024 THL A29 Limited, a Tencent company. All rights reserved.
+# The below software and/or models in this distribution may have been
+# modified by THL A29 Limited ("Tencent Modifications").
+# All Tencent Modifications are Copyright (C) THL A29 Limited.
+
+# Hunyuan 3D is licensed under the TENCENT HUNYUAN NON-COMMERCIAL LICENSE AGREEMENT
+# except for the third-party components listed below.
+# Hunyuan 3D does not impose any additional limitations beyond what is outlined
+# in the repsective licenses of these third-party components.
+# Users must comply with all terms and conditions of original licenses of these third-party
+# components and must ensure that the usage of the third party components adheres to
+# all relevant laws and regulations.
+
+# For avoidance of doubts, Hunyuan 3D means the large language models and
+# their software and algorithms, including trained model weights, parameters (including
+# optimizer states), machine-learning model code, inference-enabling code, training-enabling code,
+# fine-tuning enabling code and other elements of the foregoing made publicly available
+# by Tencent in accordance with TENCENT HUNYUAN COMMUNITY LICENSE AGREEMENT.
+
+import inspect
+from typing import Any, Dict, Optional
+from typing import Any, Dict, List, Optional, Tuple, Union
+
+import os
+import torch
+import numpy as np
+from PIL import Image
+
+import diffusers
+from diffusers.image_processor import VaeImageProcessor
+from diffusers.utils.import_utils import is_xformers_available
+from diffusers.schedulers import KarrasDiffusionSchedulers
+from diffusers.utils.torch_utils import randn_tensor
+from diffusers.utils.import_utils import is_xformers_available
+from diffusers.models.attention_processor import (
+ Attention,
+ AttnProcessor,
+ XFormersAttnProcessor,
+ AttnProcessor2_0
+)
+from diffusers import (
+ AutoencoderKL,
+ DDPMScheduler,
+ DiffusionPipeline,
+ EulerAncestralDiscreteScheduler,
+ UNet2DConditionModel,
+ ImagePipelineOutput
+)
+import transformers
+from transformers import (
+ CLIPImageProcessor,
+ CLIPTextModel,
+ CLIPTokenizer,
+ CLIPVisionModelWithProjection,
+ CLIPTextModelWithProjection
+)
+
+from .utils import to_rgb_image, white_out_background, recenter_img
+
+EXAMPLE_DOC_STRING = """
+ Examples:
+ ```py
+ >>> import torch
+ >>> from diffusers import Hunyuan3d_MVD_XL_Pipeline
+
+ >>> pipe = Hunyuan3d_MVD_XL_Pipeline.from_pretrained(
+ ... "Tencent-Hunyuan-3D/MVD-XL", torch_dtype=torch.float16
+ ... )
+ >>> pipe.to("cuda")
+
+ >>> img = Image.open("demo.png")
+ >>> res_img = pipe(img).images[0]
+ ```
+"""
+
+
+
+def scale_latents(latents): return (latents - 0.22) * 0.75
+def unscale_latents(latents): return (latents / 0.75) + 0.22
+def scale_image(image): return (image - 0.5) / 0.5
+def scale_image_2(image): return (image * 0.5) / 0.8
+def unscale_image(image): return (image * 0.5) + 0.5
+def unscale_image_2(image): return (image * 0.8) / 0.5
+
+
+
+
+class ReferenceOnlyAttnProc(torch.nn.Module):
+ def __init__(self, chained_proc, enabled=False, name=None):
+ super().__init__()
+ self.enabled = enabled
+ self.chained_proc = chained_proc
+ self.name = name
+
+ def __call__(self, attn, hidden_states, encoder_hidden_states=None, attention_mask=None, mode="w", ref_dict=None):
+ encoder_hidden_states = hidden_states if encoder_hidden_states is None else encoder_hidden_states
+ if self.enabled:
+ if mode == 'w': ref_dict[self.name] = encoder_hidden_states
+ elif mode == 'r': encoder_hidden_states = torch.cat([encoder_hidden_states, ref_dict.pop(self.name)], dim=1)
+ else: raise Exception(f"mode should not be {mode}")
+ return self.chained_proc(attn, hidden_states, encoder_hidden_states, attention_mask)
+
+
+class RefOnlyNoisedUNet(torch.nn.Module):
+ def __init__(self, unet, scheduler) -> None:
+ super().__init__()
+ self.unet = unet
+ self.scheduler = scheduler
+
+ unet_attn_procs = dict()
+ for name, _ in unet.attn_processors.items():
+ if torch.__version__ >= '2.0': default_attn_proc = AttnProcessor2_0()
+ elif is_xformers_available(): default_attn_proc = XFormersAttnProcessor()
+ else: default_attn_proc = AttnProcessor()
+ unet_attn_procs[name] = ReferenceOnlyAttnProc(
+ default_attn_proc, enabled=name.endswith("attn1.processor"), name=name
+ )
+ unet.set_attn_processor(unet_attn_procs)
+
+ def __getattr__(self, name: str):
+ try:
+ return super().__getattr__(name)
+ except AttributeError:
+ return getattr(self.unet, name)
+
+ def forward(
+ self,
+ sample: torch.FloatTensor,
+ timestep: Union[torch.Tensor, float, int],
+ encoder_hidden_states: torch.Tensor,
+ cross_attention_kwargs: Optional[Dict[str, Any]] = None,
+ class_labels: Optional[torch.Tensor] = None,
+ down_block_res_samples: Optional[Tuple[torch.Tensor]] = None,
+ mid_block_res_sample: Optional[Tuple[torch.Tensor]] = None,
+ added_cond_kwargs: Optional[Dict[str, torch.Tensor]] = None,
+ return_dict: bool = True,
+ **kwargs
+ ):
+
+ dtype = self.unet.dtype
+
+ # cond_lat add same level noise
+ cond_lat = cross_attention_kwargs['cond_lat']
+ noise = torch.randn_like(cond_lat)
+
+ noisy_cond_lat = self.scheduler.add_noise(cond_lat, noise, timestep.reshape(-1))
+ noisy_cond_lat = self.scheduler.scale_model_input(noisy_cond_lat, timestep.reshape(-1))
+
+ ref_dict = {}
+
+ _ = self.unet(
+ noisy_cond_lat,
+ timestep,
+ encoder_hidden_states = encoder_hidden_states,
+ class_labels = class_labels,
+ cross_attention_kwargs = dict(mode="w", ref_dict=ref_dict),
+ added_cond_kwargs = added_cond_kwargs,
+ return_dict = return_dict,
+ **kwargs
+ )
+
+ res = self.unet(
+ sample,
+ timestep,
+ encoder_hidden_states,
+ class_labels=class_labels,
+ cross_attention_kwargs = dict(mode="r", ref_dict=ref_dict),
+ down_block_additional_residuals = [
+ sample.to(dtype=dtype) for sample in down_block_res_samples
+ ] if down_block_res_samples is not None else None,
+ mid_block_additional_residual = (
+ mid_block_res_sample.to(dtype=dtype)
+ if mid_block_res_sample is not None else None),
+ added_cond_kwargs = added_cond_kwargs,
+ return_dict = return_dict,
+ **kwargs
+ )
+ return res
+
+
+
+class HunYuan3D_MVD_Std_Pipeline(diffusers.DiffusionPipeline):
+ def __init__(
+ self,
+ vae: AutoencoderKL,
+ unet: UNet2DConditionModel,
+ scheduler: KarrasDiffusionSchedulers,
+ feature_extractor_vae: CLIPImageProcessor,
+ vision_processor: CLIPImageProcessor,
+ vision_encoder: CLIPVisionModelWithProjection,
+ vision_encoder_2: CLIPVisionModelWithProjection,
+ ramping_coefficients: Optional[list] = None,
+ add_watermarker: Optional[bool] = None,
+ safety_checker = None,
+ ):
+ DiffusionPipeline.__init__(self)
+
+ self.register_modules(
+ vae=vae, unet=unet, scheduler=scheduler, safety_checker=None, feature_extractor_vae=feature_extractor_vae,
+ vision_processor=vision_processor, vision_encoder=vision_encoder, vision_encoder_2=vision_encoder_2,
+ )
+ self.register_to_config( ramping_coefficients = ramping_coefficients)
+ self.vae_scale_factor = 2 ** (len(self.vae.config.block_out_channels) - 1)
+ self.image_processor = VaeImageProcessor(vae_scale_factor=self.vae_scale_factor)
+ self.default_sample_size = self.unet.config.sample_size
+ self.watermark = None
+ self.prepare_init = False
+
+ def prepare(self):
+ assert isinstance(self.unet, UNet2DConditionModel), "unet should be UNet2DConditionModel"
+ self.unet = RefOnlyNoisedUNet(self.unet, self.scheduler).eval()
+ self.prepare_init = True
+
+ def encode_image(self, image: torch.Tensor, scale_factor: bool = False):
+ latent = self.vae.encode(image).latent_dist.sample()
+ return (latent * self.vae.config.scaling_factor) if scale_factor else latent
+
+ # Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.prepare_latents
+ def prepare_latents(self, batch_size, num_channels_latents, height, width, dtype, device, generator, latents=None):
+ shape = (
+ batch_size,
+ num_channels_latents,
+ int(height) // self.vae_scale_factor,
+ int(width) // self.vae_scale_factor,
+ )
+ if isinstance(generator, list) and len(generator) != batch_size:
+ raise ValueError(
+ f"You have passed a list of generators of length {len(generator)}, but requested an effective batch"
+ f" size of {batch_size}. Make sure the batch size matches the length of the generators."
+ )
+
+ if latents is None:
+ latents = randn_tensor(shape, generator=generator, device=device, dtype=dtype)
+ else:
+ latents = latents.to(device)
+
+ # scale the initial noise by the standard deviation required by the scheduler
+ latents = latents * self.scheduler.init_noise_sigma
+ return latents
+
+ def _get_add_time_ids(
+ self, original_size, crops_coords_top_left, target_size, dtype, text_encoder_projection_dim=None
+ ):
+ add_time_ids = list(original_size + crops_coords_top_left + target_size)
+
+ passed_add_embed_dim = (
+ self.unet.config.addition_time_embed_dim * len(add_time_ids) + text_encoder_projection_dim
+ )
+ expected_add_embed_dim = self.unet.add_embedding.linear_1.in_features
+
+ if expected_add_embed_dim != passed_add_embed_dim:
+ raise ValueError(
+ f"Model expects an added time embedding vector of length {expected_add_embed_dim}, " \
+ f"but a vector of {passed_add_embed_dim} was created. The model has an incorrect config." \
+ f" Please check `unet.config.time_embedding_type` and `text_encoder_2.config.projection_dim`."
+ )
+
+ add_time_ids = torch.tensor([add_time_ids], dtype=dtype)
+ return add_time_ids
+
+ def prepare_extra_step_kwargs(self, generator, eta):
+ # prepare extra kwargs for the scheduler step, since not all schedulers have the same signature
+ # eta (η) is only used with the DDIMScheduler, it will be ignored for other schedulers.
+ # eta corresponds to η in DDIM paper: https://arxiv.org/abs/2010.02502
+ # and should be between [0, 1]
+
+ accepts_eta = "eta" in set(inspect.signature(self.scheduler.step).parameters.keys())
+ extra_step_kwargs = {}
+ if accepts_eta: extra_step_kwargs["eta"] = eta
+
+ # check if the scheduler accepts generator
+ accepts_generator = "generator" in set(inspect.signature(self.scheduler.step).parameters.keys())
+ if accepts_generator: extra_step_kwargs["generator"] = generator
+ return extra_step_kwargs
+
+ @property
+ def guidance_scale(self):
+ return self._guidance_scale
+
+ @property
+ def interrupt(self):
+ return self._interrupt
+
+ @property
+ def do_classifier_free_guidance(self):
+ return self._guidance_scale > 1 and self.unet.config.time_cond_proj_dim is None
+
+ @torch.no_grad()
+ def __call__(
+ self,
+ image: Image.Image = None,
+ guidance_scale = 2.0,
+ output_type: Optional[str] = "pil",
+ num_inference_steps: int = 50,
+ return_dict: bool = True,
+ eta: float = 0.0,
+ generator: Optional[Union[torch.Generator, List[torch.Generator]]] = None,
+ crops_coords_top_left: Tuple[int, int] = (0, 0),
+ cross_attention_kwargs: Optional[Dict[str, Any]] = None,
+ latent: torch.Tensor = None,
+ guidance_curve = None,
+ **kwargs
+ ):
+ if not self.prepare_init:
+ self.prepare()
+
+ here = dict(device=self.vae.device, dtype=self.vae.dtype)
+
+ batch_size = 1
+ num_images_per_prompt = 1
+ width, height = 512 * 2, 512 * 3
+ target_size = original_size = (height, width)
+
+ self._guidance_scale = guidance_scale
+ self._cross_attention_kwargs = cross_attention_kwargs
+ self._interrupt = False
+
+ device = self._execution_device
+
+ # Prepare timesteps
+ self.scheduler.set_timesteps(num_inference_steps, device=device)
+ timesteps = self.scheduler.timesteps
+
+ # Prepare latent variables
+ num_channels_latents = self.unet.config.in_channels
+ latents = self.prepare_latents(
+ batch_size * num_images_per_prompt,
+ num_channels_latents,
+ height,
+ width,
+ self.vae.dtype,
+ device,
+ generator,
+ latents=latent,
+ )
+
+ # Prepare extra step kwargs. TODO: Logic should ideally just be moved out of the pipeline
+ extra_step_kwargs = self.prepare_extra_step_kwargs(generator, eta)
+
+
+ # Prepare added time ids & embeddings
+ text_encoder_projection_dim = 1280
+ add_time_ids = self._get_add_time_ids(
+ original_size,
+ crops_coords_top_left,
+ target_size,
+ dtype=self.vae.dtype,
+ text_encoder_projection_dim=text_encoder_projection_dim,
+ )
+ negative_add_time_ids = add_time_ids
+
+ # hw: preprocess
+ cond_image = recenter_img(image)
+ cond_image = to_rgb_image(image)
+ image_vae = self.feature_extractor_vae(images=cond_image, return_tensors="pt").pixel_values.to(**here)
+ image_clip = self.vision_processor(images=cond_image, return_tensors="pt").pixel_values.to(**here)
+
+ # hw: get cond_lat from cond_img using vae
+ cond_lat = self.encode_image(image_vae, scale_factor=False)
+ negative_lat = self.encode_image(torch.zeros_like(image_vae), scale_factor=False)
+ cond_lat = torch.cat([negative_lat, cond_lat])
+
+ # hw: get visual global embedding using clip
+ global_embeds_1 = self.vision_encoder(image_clip, output_hidden_states=False).image_embeds.unsqueeze(-2)
+ global_embeds_2 = self.vision_encoder_2(image_clip, output_hidden_states=False).image_embeds.unsqueeze(-2)
+ global_embeds = torch.concat([global_embeds_1, global_embeds_2], dim=-1)
+
+ ramp = global_embeds.new_tensor(self.config.ramping_coefficients).unsqueeze(-1)
+ prompt_embeds = self.uc_text_emb.to(**here)
+ pooled_prompt_embeds = self.uc_text_emb_2.to(**here)
+
+ prompt_embeds = prompt_embeds + global_embeds * ramp
+ add_text_embeds = pooled_prompt_embeds
+
+ if self.do_classifier_free_guidance:
+ negative_prompt_embeds = torch.zeros_like(prompt_embeds)
+ negative_pooled_prompt_embeds = torch.zeros_like(pooled_prompt_embeds)
+ prompt_embeds = torch.cat([negative_prompt_embeds, prompt_embeds], dim=0)
+ add_text_embeds = torch.cat([negative_pooled_prompt_embeds, add_text_embeds], dim=0)
+ add_time_ids = torch.cat([negative_add_time_ids, add_time_ids], dim=0)
+
+ prompt_embeds = prompt_embeds.to(device)
+ add_text_embeds = add_text_embeds.to(device)
+ add_time_ids = add_time_ids.to(device).repeat(batch_size * num_images_per_prompt, 1)
+
+ # Denoising loop
+ num_warmup_steps = max(len(timesteps) - num_inference_steps * self.scheduler.order, 0)
+ timestep_cond = None
+ self._num_timesteps = len(timesteps)
+
+ if guidance_curve is None:
+ guidance_curve = lambda t: guidance_scale
+
+ with self.progress_bar(total=num_inference_steps) as progress_bar:
+ for i, t in enumerate(timesteps):
+ if self.interrupt:
+ continue
+
+ # expand the latents if we are doing classifier free guidance
+ latent_model_input = torch.cat([latents] * 2) if self.do_classifier_free_guidance else latents
+
+ latent_model_input = self.scheduler.scale_model_input(latent_model_input, t)
+
+ # predict the noise residual
+ added_cond_kwargs = {"text_embeds": add_text_embeds, "time_ids": add_time_ids}
+
+ noise_pred = self.unet(
+ latent_model_input,
+ t,
+ encoder_hidden_states=prompt_embeds,
+ timestep_cond=timestep_cond,
+ cross_attention_kwargs=dict(cond_lat=cond_lat),
+ added_cond_kwargs=added_cond_kwargs,
+ return_dict=False,
+ )[0]
+
+ # perform guidance
+
+ # cur_guidance_scale = self.guidance_scale
+ cur_guidance_scale = guidance_curve(t) # 1.5 + 2.5 * ((t/1000)**2)
+
+ if self.do_classifier_free_guidance:
+ noise_pred_uncond, noise_pred_text = noise_pred.chunk(2)
+ noise_pred = noise_pred_uncond + cur_guidance_scale * (noise_pred_text - noise_pred_uncond)
+
+ # cur_guidance_scale_topleft = (cur_guidance_scale - 1.0) * 4 + 1.0
+ # noise_pred_top_left = noise_pred_uncond +
+ # cur_guidance_scale_topleft * (noise_pred_text - noise_pred_uncond)
+ # _, _, h, w = noise_pred.shape
+ # noise_pred[:, :, :h//3, :w//2] = noise_pred_top_left[:, :, :h//3, :w//2]
+
+ # compute the previous noisy sample x_t -> x_t-1
+ latents_dtype = latents.dtype
+ latents = self.scheduler.step(noise_pred, t, latents, **extra_step_kwargs, return_dict=False)[0]
+
+ # call the callback, if provided
+ if i == len(timesteps) - 1 or ((i + 1) > num_warmup_steps and (i + 1) % self.scheduler.order == 0):
+ progress_bar.update()
+
+ latents = unscale_latents(latents)
+
+ if output_type=="latent":
+ image = latents
+ else:
+ image = self.vae.decode(latents / self.vae.config.scaling_factor, return_dict=False)[0]
+ image = unscale_image(unscale_image_2(image)).clamp(0, 1)
+ image = [
+ Image.fromarray((image[0]*255+0.5).clamp_(0, 255).permute(1, 2, 0).cpu().numpy().astype("uint8")),
+ # self.image_processor.postprocess(image, output_type=output_type)[0],
+ cond_image.resize((512, 512))
+ ]
+
+ if not return_dict: return (image,)
+ return ImagePipelineOutput(images=image)
+
+ def save_pretrained(self, save_directory):
+ # uc_text_emb.pt and uc_text_emb_2.pt are inferenced and saved in advance
+ super().save_pretrained(save_directory)
+ torch.save(self.uc_text_emb, os.path.join(save_directory, "uc_text_emb.pt"))
+ torch.save(self.uc_text_emb_2, os.path.join(save_directory, "uc_text_emb_2.pt"))
+
+ @classmethod
+ def from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs):
+ # uc_text_emb.pt and uc_text_emb_2.pt are inferenced and saved in advance
+ pipeline = super().from_pretrained(pretrained_model_name_or_path, *model_args, **kwargs)
+ pipeline.uc_text_emb = torch.load(os.path.join(pretrained_model_name_or_path, "uc_text_emb.pt"))
+ pipeline.uc_text_emb_2 = torch.load(os.path.join(pretrained_model_name_or_path, "uc_text_emb_2.pt"))
+ return pipeline
\ No newline at end of file
diff --git a/freesplatter/hunyuan/utils.py b/freesplatter/hunyuan/utils.py
new file mode 100644
index 0000000000000000000000000000000000000000..4fef573f675c2e0dee1771e5ef33688e8e9adfca
--- /dev/null
+++ b/freesplatter/hunyuan/utils.py
@@ -0,0 +1,85 @@
+# Open Source Model Licensed under the Apache License Version 2.0 and Other Licenses of the Third-Party Components therein:
+# The below Model in this distribution may have been modified by THL A29 Limited ("Tencent Modifications"). All Tencent Modifications are Copyright (C) 2024 THL A29 Limited.
+
+# Copyright (C) 2024 THL A29 Limited, a Tencent company. All rights reserved.
+# The below software and/or models in this distribution may have been
+# modified by THL A29 Limited ("Tencent Modifications").
+# All Tencent Modifications are Copyright (C) THL A29 Limited.
+
+# Hunyuan 3D is licensed under the TENCENT HUNYUAN NON-COMMERCIAL LICENSE AGREEMENT
+# except for the third-party components listed below.
+# Hunyuan 3D does not impose any additional limitations beyond what is outlined
+# in the repsective licenses of these third-party components.
+# Users must comply with all terms and conditions of original licenses of these third-party
+# components and must ensure that the usage of the third party components adheres to
+# all relevant laws and regulations.
+
+# For avoidance of doubts, Hunyuan 3D means the large language models and
+# their software and algorithms, including trained model weights, parameters (including
+# optimizer states), machine-learning model code, inference-enabling code, training-enabling code,
+# fine-tuning enabling code and other elements of the foregoing made publicly available
+# by Tencent in accordance with TENCENT HUNYUAN COMMUNITY LICENSE AGREEMENT.
+
+import numpy as np
+from PIL import Image
+
+def to_rgb_image(maybe_rgba: Image.Image):
+ '''
+ convert a PIL.Image to rgb mode with white background
+ maybe_rgba: PIL.Image
+ return: PIL.Image
+ '''
+ if maybe_rgba.mode == 'RGB':
+ return maybe_rgba
+ elif maybe_rgba.mode == 'RGBA':
+ rgba = maybe_rgba
+ img = np.random.randint(255, 256, size=[rgba.size[1], rgba.size[0], 3], dtype=np.uint8)
+ img = Image.fromarray(img, 'RGB')
+ img.paste(rgba, mask=rgba.getchannel('A'))
+ return img
+ else:
+ raise ValueError("Unsupported image type.", maybe_rgba.mode)
+
+def white_out_background(pil_img, is_gray_fg=True):
+ data = pil_img.getdata()
+ new_data = []
+ # convert fore-ground white to gray
+ for r, g, b, a in data:
+ if a < 16:
+ new_data.append((255, 255, 255, 0)) # back-ground to be black
+ else:
+ is_white = is_gray_fg and (r>235) and (g>235) and (b>235)
+ new_r = 235 if is_white else r
+ new_g = 235 if is_white else g
+ new_b = 235 if is_white else b
+ new_data.append((new_r, new_g, new_b, a))
+ pil_img.putdata(new_data)
+ return pil_img
+
+def recenter_img(img, size=512, color=(255,255,255)):
+ img = white_out_background(img)
+ mask = np.array(img)[..., 3]
+ image = np.array(img)[..., :3]
+
+ H, W, C = image.shape
+ coords = np.nonzero(mask)
+ x_min, x_max = coords[0].min(), coords[0].max()
+ y_min, y_max = coords[1].min(), coords[1].max()
+ h = x_max - x_min
+ w = y_max - y_min
+ if h == 0 or w == 0: raise ValueError
+ roi = image[x_min:x_max, y_min:y_max]
+
+ border_ratio = 0.15 # 0.2
+ pad_h = int(h * border_ratio)
+ pad_w = int(w * border_ratio)
+
+ result_tmp = np.full((h + pad_h, w + pad_w, C), color, dtype=np.uint8)
+ result_tmp[pad_h // 2: pad_h // 2 + h, pad_w // 2: pad_w // 2 + w] = roi
+
+ cur_h, cur_w = result_tmp.shape[:2]
+ side = max(cur_h, cur_w)
+ result = np.full((side, side, C), color, dtype=np.uint8)
+ result[(side-cur_h)//2:(side-cur_h)//2+cur_h, (side-cur_w)//2:(side - cur_w)//2+cur_w,:] = result_tmp
+ result = Image.fromarray(result)
+ return result.resize((size, size), Image.LANCZOS) if size else result
\ No newline at end of file
diff --git a/freesplatter/models/__init__.py b/freesplatter/models/__init__.py
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/freesplatter/models/model.py b/freesplatter/models/model.py
new file mode 100644
index 0000000000000000000000000000000000000000..680eef0b1585530bcc11df66628d3a0abade0c53
--- /dev/null
+++ b/freesplatter/models/model.py
@@ -0,0 +1,156 @@
+import torch
+import torch.nn as nn
+import torch.nn.functional as F
+from torchvision.transforms import v2
+from einops import rearrange
+
+from freesplatter.models.transformer import Transformer
+from freesplatter.utils.infer_util import instantiate_from_config
+from freesplatter.utils.recon_util import estimate_focal, fast_pnp
+
+
+C0 = 0.28209479177387814
+def RGB2SH(rgb):
+ return (rgb - 0.5) / C0
+
+
+class FreeSplatterModel(nn.Module):
+ def __init__(
+ self,
+ transformer_config=None,
+ renderer_config=None,
+ use_2dgs=False,
+ sh_residual=False,
+ ):
+ super().__init__()
+
+ self.sh_dim = (renderer_config.sh_degree + 1) ** 2 * 3
+ self.sh_residual = sh_residual
+ self.use_2dgs = use_2dgs
+
+ self.transformer = instantiate_from_config(transformer_config)
+
+ if not use_2dgs:
+ from .renderer.gaussian_renderer import GaussianRenderer
+ else:
+ from .renderer_2dgs.gaussian_renderer import GaussianRenderer
+ self.gs_renderer = GaussianRenderer(renderer_config=renderer_config)
+
+ self.register_buffer('pp', torch.tensor([256, 256], dtype=torch.float32), persistent=False)
+
+ def forward_gaussians(self, images, **kwargs):
+ """
+ images: B x N x 3 x H x W
+ """
+ gaussians = self.transformer(images) # B x N x H x W x C
+ if self.sh_residual:
+ residual = torch.zeros_like(gaussians)
+ sh = RGB2SH(rearrange(images, 'b n c h w -> b n h w c'))
+ residual[..., 3:6] = sh
+ gaussians = gaussians + residual
+
+ gaussians = rearrange(gaussians, 'b n h w c -> b (n h w) c')
+
+ return gaussians
+
+ def forward_renderer(self, gaussians, c2ws, fxfycxcy, **kwargs):
+ """
+ gaussians: B x K x 14
+ c2ws: B x N x 4 x 4
+ fxfycxcy: B x N x 4
+ """
+ render_results = self.gs_renderer.render(gaussians, fxfycxcy, c2ws, **kwargs)
+
+ return render_results
+
+ @torch.inference_mode()
+ def estimate_focals(
+ self,
+ images,
+ masks=None,
+ use_first_focal=False,
+ ):
+ """
+ Estimate the focal lengths of N input images.
+
+ images: N x 3 x H x W
+ masks: N x 1 x H x W
+ """
+ assert images.ndim == 4
+ N, _, H, W = images.shape
+ assert H == W, "Non-square images are not supported."
+
+ pp = self.pp.to(images)
+ # pp = torch.tensor([W/2, H/2]).to(images)
+
+ focals = []
+ for i in range(N):
+ if use_first_focal and i > 0:
+ break
+ images_input = torch.cat([images[i:], images[:i]], dim=0)
+ gaussians = self.forward_gaussians(images_input.unsqueeze(0)) # 1 x (N x H x W) x 14
+ points = rearrange(gaussians[0, :H*W, :3], '(h w) c -> h w c', h=H, w=W)
+ mask = masks[i] if masks is not None else None
+ focal = estimate_focal(points, pp=pp, mask=mask)
+ focals.append(focal)
+
+ focals = torch.stack(focals).to(images)
+ focals = focals.mean().reshape(1).repeat(N)
+ return focals
+
+ @torch.inference_mode()
+ def estimate_poses(
+ self,
+ images,
+ gaussians=None,
+ masks=None,
+ focals=None,
+ use_first_focal=True,
+ opacity_threshold=5e-2,
+ pnp_iter=20,
+ ):
+ """
+ Estimate the camera poses of N input images.
+
+ images: N x 3 x h x W
+ gaussians: K x 14 or 1 x K x 14
+ masks: N x 1 x H x W
+ focals: N
+ """
+ assert images.ndim == 4
+ N, _, H, W = images.shape
+ assert H == W, "Non-square images are not supported."
+
+ # predict gaussians from images
+ if gaussians is None:
+ gaussians = self.forward_gaussians(images.unsqueeze(0)) # 1 x (N x H x W) x 14
+ else:
+ if gaussians.ndim == 2:
+ gaussians = gaussians.unsqueeze(0)
+ assert gaussians.shape[1] == N * H * W
+
+ points = gaussians[..., :3].reshape(1, N, H, W, 3).squeeze(0) # N x H x W x 3
+ opacities = gaussians[..., 3+self.sh_dim].reshape(1, N, H, W).squeeze(0)
+ opacities = torch.sigmoid(opacities) # N x H x W
+
+ # estimate focals if not provided
+ if focals is None:
+ focals = self.estimate_focals(images, masks=masks, use_first_focal=use_first_focal)
+
+ # run PnP
+ c2ws = []
+ for i in range(N):
+ pts3d = points[i].float().detach().cpu().numpy()
+ # If masks are not provided, we use Gaussian opacities
+ if masks is None:
+ mask = (opacities[i] > opacity_threshold).detach().cpu().numpy()
+ else:
+ mask = masks[i].reshape(H, W).bool().detach().cpu().numpy()
+
+ focal = focals[i].item()
+ _, c2w = fast_pnp(pts3d, mask, focal=focal, niter_PnP=pnp_iter)
+
+ c2ws.append(torch.from_numpy(c2w))
+
+ c2ws = torch.stack(c2ws, dim=0).to(images)
+ return c2ws, focals
\ No newline at end of file
diff --git a/freesplatter/models/renderer/__init__.py b/freesplatter/models/renderer/__init__.py
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/freesplatter/models/renderer/gaussian_renderer.py b/freesplatter/models/renderer/gaussian_renderer.py
new file mode 100644
index 0000000000000000000000000000000000000000..db301f3e4f932df045f6c989447227dc303d6bdb
--- /dev/null
+++ b/freesplatter/models/renderer/gaussian_renderer.py
@@ -0,0 +1,53 @@
+import torch
+
+from .gaussian_utils import render, GaussianModel
+
+
+class GaussianRenderer:
+ def __init__(self, renderer_config=None):
+ if 'scaling_activation_type' not in renderer_config:
+ renderer_config['scaling_activation_type'] = 'exp'
+ if 'scale_min_act' not in renderer_config:
+ renderer_config['scale_min_act'] = 1
+ renderer_config['scale_max_act'] = 1
+ renderer_config['scale_multi_act'] = 0.1
+
+ self.gaussian_model = GaussianModel(sh_degree=renderer_config.sh_degree,
+ scaling_activation_type=renderer_config.scaling_activation_type,
+ scale_min_act=renderer_config.scale_min_act,
+ scale_max_act=renderer_config.scale_max_act,
+ scale_multi_act=renderer_config.scale_multi_act)
+ self.img_height = renderer_config.img_height
+ self.img_width = renderer_config.img_width
+ self.bg_color = renderer_config.bg_color if 'bg_color' in renderer_config else (1.0, 1.0, 1.0)
+
+ def render(self, latent, output_fxfycxcy, output_c2ws, rescale=None, render_size=None):
+ if render_size is None:
+ img_height, img_width = self.img_height, self.img_width
+ else:
+ img_height, img_width = render_size
+ if rescale is None:
+ rescale = torch.ones(latent.shape[0]).to(latent)
+
+ shs_dim = (self.gaussian_model.sh_degree + 1) ** 2 * 3
+ xyz, features, opacity, scaling, rotation = latent.split([3, shs_dim, 1, 3, 4], dim=-1)
+
+ features = features.reshape(features.shape[0], -1, shs_dim//3, 3)
+
+ bs, vs = output_fxfycxcy.shape[:2]
+ images = torch.zeros(bs, vs, 3, img_height, img_width, dtype=torch.float32, device=output_c2ws.device)
+ alphas = torch.zeros(bs, vs, 1, img_height, img_width, dtype=torch.float32, device=output_c2ws.device)
+ depths = torch.zeros(bs, vs, 1, img_height, img_width, dtype=torch.float32, device=output_c2ws.device)
+
+ for idx in range(bs):
+ pc = self.gaussian_model.set_data(xyz[idx], features[idx], scaling[idx], rotation[idx], opacity[idx], rescale[idx])
+ for vidx in range(vs):
+ render_results = render(pc, img_height, img_width, output_c2ws[idx, vidx], output_fxfycxcy[idx, vidx], self.bg_color)
+ image = render_results['render']
+ alpha = render_results['alpha']
+ depth = render_results['depth']
+ images[idx, vidx] = image
+ alphas[idx, vidx] = alpha
+ depths[idx, vidx] = depth
+ results = {'image': images, 'alpha': alphas, 'depth': depths}
+ return results
diff --git a/freesplatter/models/renderer/gaussian_utils.py b/freesplatter/models/renderer/gaussian_utils.py
new file mode 100644
index 0000000000000000000000000000000000000000..acd7a7d7fcc5c34ddc4a2392dcb06dfd7ba58308
--- /dev/null
+++ b/freesplatter/models/renderer/gaussian_utils.py
@@ -0,0 +1,391 @@
+"""
+Gaussian Splatting.
+Partially borrowed from https://github.com/graphdeco-inria/gaussian-splatting.
+"""
+
+
+import os
+import torch
+from torch import nn
+import numpy as np
+from diff_gaussian_rasterization import (
+ GaussianRasterizationSettings,
+ GaussianRasterizer,
+)
+from plyfile import PlyData, PlyElement
+from scipy.spatial.transform import Rotation as R
+
+
+def strip_lowerdiag(L):
+ uncertainty = torch.zeros((L.shape[0], 6), dtype=torch.float, device=L.device)
+
+ uncertainty[:, 0] = L[:, 0, 0]
+ uncertainty[:, 1] = L[:, 0, 1]
+ uncertainty[:, 2] = L[:, 0, 2]
+ uncertainty[:, 3] = L[:, 1, 1]
+ uncertainty[:, 4] = L[:, 1, 2]
+ uncertainty[:, 5] = L[:, 2, 2]
+ return uncertainty
+
+
+def strip_symmetric(sym):
+ return strip_lowerdiag(sym)
+
+
+def build_rotation(r):
+ norm = torch.sqrt(
+ r[:, 0] * r[:, 0] + r[:, 1] * r[:, 1] + r[:, 2] * r[:, 2] + r[:, 3] * r[:, 3]
+ )
+
+ q = r / norm[:, None]
+
+ R = torch.zeros((q.size(0), 3, 3), device=r.device)
+
+ r = q[:, 0]
+ x = q[:, 1]
+ y = q[:, 2]
+ z = q[:, 3]
+
+ R[:, 0, 0] = 1 - 2 * (y * y + z * z)
+ R[:, 0, 1] = 2 * (x * y - r * z)
+ R[:, 0, 2] = 2 * (x * z + r * y)
+ R[:, 1, 0] = 2 * (x * y + r * z)
+ R[:, 1, 1] = 1 - 2 * (x * x + z * z)
+ R[:, 1, 2] = 2 * (y * z - r * x)
+ R[:, 2, 0] = 2 * (x * z - r * y)
+ R[:, 2, 1] = 2 * (y * z + r * x)
+ R[:, 2, 2] = 1 - 2 * (x * x + y * y)
+ return R
+
+
+def build_scaling_rotation(s, r):
+ L = torch.zeros((s.shape[0], 3, 3), dtype=torch.float, device=s.device)
+ R = build_rotation(r)
+
+ L[:, 0, 0] = s[:, 0]
+ L[:, 1, 1] = s[:, 1]
+ L[:, 2, 2] = s[:, 2]
+
+ L = R @ L
+ return L
+
+
+class Camera(nn.Module):
+ def __init__(self, C2W, fxfycxcy, h, w):
+ """
+ C2W: 4x4 camera-to-world matrix; opencv convention
+ fxfycxcy: 4
+ """
+ super().__init__()
+ self.C2W = C2W.float()
+ self.W2C = self.C2W.inverse()
+
+ self.znear = 0.01
+ self.zfar = 100.0
+ self.h = h
+ self.w = w
+
+ fx, fy, cx, cy = fxfycxcy[0], fxfycxcy[1], fxfycxcy[2], fxfycxcy[3]
+ self.tanfovX = 1 / (2 * fx)
+ self.tanfovY = 1 / (2 * fy)
+ self.fovX = 2 * torch.atan(self.tanfovX)
+ self.fovY = 2 * torch.atan(self.tanfovY)
+ self.shiftX = 2 * cx - 1
+ self.shiftY = 2 * cy - 1
+
+ def getProjectionMatrix(znear, zfar, fovX, fovY, shiftX, shiftY):
+ tanHalfFovY = torch.tan((fovY / 2))
+ tanHalfFovX = torch.tan((fovX / 2))
+
+ top = tanHalfFovY * znear
+ bottom = -top
+ right = tanHalfFovX * znear
+ left = -right
+
+ P = torch.zeros(4, 4, dtype=torch.float32, device=fovX.device)
+
+ z_sign = 1.0
+
+ P[0, 0] = 2.0 * znear / (right - left)
+ P[1, 1] = 2.0 * znear / (top - bottom)
+ P[0, 2] = (right + left) / (right - left) + shiftX
+ P[1, 2] = (top + bottom) / (top - bottom) + shiftY
+ P[3, 2] = z_sign
+ P[2, 2] = z_sign * zfar / (zfar - znear)
+ P[2, 3] = -(zfar * znear) / (zfar - znear)
+ return P
+
+ self.world_view_transform = self.W2C.transpose(0, 1)
+ self.projection_matrix = getProjectionMatrix(
+ znear=self.znear, zfar=self.zfar, fovX=self.fovX, fovY=self.fovY, shiftX=self.shiftX, shiftY=self.shiftY
+ ).transpose(0, 1)
+ self.full_proj_transform = (
+ self.world_view_transform.unsqueeze(0).bmm(
+ self.projection_matrix.unsqueeze(0)
+ )
+ ).squeeze(0)
+ self.camera_center = self.C2W[:3, 3]
+
+
+class GaussianModel:
+ def setup_functions(self, scaling_activation_type='sigmoid', scale_min_act=0.001, scale_max_act=0.3, scale_multi_act=0.1):
+ def build_covariance_from_scaling_rotation(scaling, scaling_modifier, rotation):
+ L = build_scaling_rotation(scaling_modifier * scaling, rotation)
+ actual_covariance = L @ L.transpose(1, 2)
+ symm = strip_symmetric(actual_covariance)
+ return symm
+
+ if scaling_activation_type == 'exp':
+ self.scaling_activation = torch.exp
+ elif scaling_activation_type == 'softplus':
+ self.scaling_activation = torch.nn.functional.softplus
+ self.scale_multi_act = scale_multi_act
+ elif scaling_activation_type == 'sigmoid':
+ self.scale_min_act = scale_min_act
+ self.scale_max_act = scale_max_act
+ self.scaling_activation = torch.sigmoid
+ else:
+ raise NotImplementedError
+ self.scaling_activation_type = scaling_activation_type
+
+ self.rotation_activation = torch.nn.functional.normalize
+ self.opacity_activation = torch.sigmoid
+ self.feature_activation = torch.sigmoid
+ self.covariance_activation = build_covariance_from_scaling_rotation
+
+ def __init__(self, sh_degree: int, scaling_activation_type='exp', scale_min_act=0.001, scale_max_act=0.3, scale_multi_act=0.1):
+ self.sh_degree = sh_degree
+ self._xyz = torch.empty(0)
+ self._features_dc = torch.empty(0)
+ if self.sh_degree > 0:
+ self._features_rest = torch.empty(0)
+ else:
+ self._features_rest = None
+ self._scaling = torch.empty(0)
+ self._rotation = torch.empty(0)
+ self._opacity = torch.empty(0)
+ self.setup_functions(scaling_activation_type=scaling_activation_type, scale_min_act=scale_min_act, scale_max_act=scale_max_act, scale_multi_act=scale_multi_act)
+
+ def set_data(self, xyz, features, scaling, rotation, opacity, rescale=None):
+ self._xyz = xyz
+ self._features_dc = features[:, 0, :].contiguous() if self.sh_degree == 0 else features[:, 0:1, :].contiguous()
+ if self.sh_degree > 0:
+ self._features_rest = features[:, 1:, :].contiguous()
+ else:
+ self._features_rest = None
+ self._scaling = scaling
+ self._rotation = rotation
+ self._opacity = opacity
+ if rescale is None:
+ rescale = torch.ones(1).to(xyz)
+ self._rescale = rescale
+ return self
+
+ def to(self, device):
+ self._xyz = self._xyz.to(device)
+ self._features_dc = self._features_dc.to(device)
+ if self.sh_degree > 0:
+ self._features_rest = self._features_rest.to(device)
+ self._scaling = self._scaling.to(device)
+ self._rotation = self._rotation.to(device)
+ self._opacity = self._opacity.to(device)
+ return self
+
+ @property
+ def get_scaling(self):
+ if self.scaling_activation_type == 'exp':
+ scales = self.scaling_activation(self._scaling)
+ elif self.scaling_activation_type == 'softplus':
+ scales = self.scaling_activation(self._scaling) * self.scale_multi_act
+ elif self.scaling_activation_type == 'sigmoid':
+ scales = self.scale_min_act + (self.scale_max_act - self.scale_min_act) * self.scaling_activation(self._scaling)
+ scales = scales * self._rescale
+ return scales
+
+ @property
+ def get_rotation(self):
+ return self.rotation_activation(self._rotation)
+
+ @property
+ def get_xyz(self):
+ xyz = self._xyz * self._rescale
+ return xyz
+
+ @property
+ def get_features(self):
+ if self.sh_degree > 0:
+ features_dc = self._features_dc
+ features_rest = self._features_rest
+ return torch.cat((features_dc, features_rest), dim=1)
+ else:
+ return self.feature_activation(self._features_dc)
+
+ @property
+ def get_opacity(self):
+ return self.opacity_activation(self._opacity)
+
+ def get_covariance(self, scaling_modifier=1):
+ return self.covariance_activation(
+ self.get_scaling, scaling_modifier, self._rotation
+ )
+
+ def construct_list_of_attributes(self, num_rest=0):
+ l = ['x', 'y', 'z']
+ # All channels except the 3 DC
+ for i in range(3):
+ l.append('f_dc_{}'.format(i))
+ for i in range(num_rest):
+ l.append('f_rest_{}'.format(i))
+ l.append('opacity')
+ for i in range(self._scaling.shape[1]):
+ l.append('scale_{}'.format(i))
+ for i in range(self._rotation.shape[1]):
+ l.append('rot_{}'.format(i))
+ return l
+
+ def save_ply_vis(self, path):
+ os.makedirs(os.path.dirname(path), exist_ok=True)
+
+ xyzs = self._xyz.detach().cpu().numpy()
+ f_dc = self._features_dc.detach().flatten(start_dim=1).contiguous().cpu().numpy()
+ opacities = self._opacity.detach().cpu().numpy()
+
+ scales = torch.log(self.get_scaling)
+ scales = scales.detach().cpu().numpy()
+
+ rot_mat_vis = np.array([[1, 0, 0], [0, 0, -1], [0, 1, 0]])
+ xyzs = xyzs @ rot_mat_vis.T
+ rotations = self._rotation.detach().cpu().numpy()
+ rotations = R.from_quat(rotations[:, [1,2,3,0]]).as_matrix()
+ rotations = rot_mat_vis @ rotations
+ rotations = R.from_matrix(rotations).as_quat()[:, [3,0,1,2]]
+
+ dtype_full = [(attribute, 'f4') for attribute in self.construct_list_of_attributes(0)]
+ elements = np.empty(xyzs.shape[0], dtype=dtype_full)
+ attributes = np.concatenate((xyzs, f_dc, opacities, scales, rotations), axis=1)
+ elements[:] = list(map(tuple, attributes))
+ el = PlyElement.describe(elements, 'vertex')
+ PlyData([el]).write(path)
+
+ def save_ply(self, path):
+ os.makedirs(os.path.dirname(path), exist_ok=True)
+
+ xyzs = self._xyz.detach().cpu().numpy()
+ f_dc = self._features_dc.detach().flatten(start_dim=1).contiguous().cpu().numpy()
+ if self.sh_degree > 0:
+ f_rest = self._features_rest.detach().flatten(start_dim=1).contiguous().cpu().numpy()
+ else:
+ f_rest = np.zeros((f_dc.shape[0], 0), dtype=f_dc.dtype)
+ opacities = self._opacity.detach().cpu().numpy()
+
+ scales = torch.log(self.get_scaling)
+ scales = scales.detach().cpu().numpy()
+
+ rotations = self._rotation.detach().cpu().numpy()
+
+ dtype_full = [(attribute, 'f4') for attribute in self.construct_list_of_attributes(f_rest.shape[-1])]
+ elements = np.empty(xyzs.shape[0], dtype=dtype_full)
+ attributes = np.concatenate((xyzs, f_dc, f_rest, opacities, scales, rotations), axis=1)
+ elements[:] = list(map(tuple, attributes))
+ el = PlyElement.describe(elements, "vertex")
+ PlyData([el]).write(path)
+
+ # def load_ply(self, path):
+ # plydata = PlyData.read(path)
+
+ # xyz = np.stack((np.asarray(plydata.elements[0]["x"]),
+ # np.asarray(plydata.elements[0]["y"]),
+ # np.asarray(plydata.elements[0]["z"])), axis=1)
+ # opacities = np.asarray(plydata.elements[0]["opacity"])[..., np.newaxis]
+
+ # features_dc = np.zeros((xyz.shape[0], 3, 1))
+ # features_dc[:, 0, 0] = np.asarray(plydata.elements[0]["f_dc_0"])
+ # features_dc[:, 1, 0] = np.asarray(plydata.elements[0]["f_dc_1"])
+ # features_dc[:, 2, 0] = np.asarray(plydata.elements[0]["f_dc_2"])
+
+ # scale_names = [p.name for p in plydata.elements[0].properties if p.name.startswith("scale_")]
+ # scale_names = sorted(scale_names, key = lambda x: int(x.split('_')[-1]))
+ # scales = np.zeros((xyz.shape[0], len(scale_names)))
+ # for idx, attr_name in enumerate(scale_names):
+ # scales[:, idx] = np.asarray(plydata.elements[0][attr_name])
+
+ # rot_names = [p.name for p in plydata.elements[0].properties if p.name.startswith("rot")]
+ # rot_names = sorted(rot_names, key=lambda x: int(x.split("_")[-1]))
+ # rots = np.zeros((xyz.shape[0], len(rot_names)))
+ # for idx, attr_name in enumerate(rot_names):
+ # rots[:, idx] = np.asarray(plydata.elements[0][attr_name])
+
+ # self._xyz = torch.from_numpy(xyz.astype(np.float32))
+ # self._features_dc = torch.from_numpy(features_dc.astype(np.float32)).transpose(1, 2).contiguous()
+ # self._opacity = torch.from_numpy(opacities.astype(np.float32)).contiguous()
+ # self._scaling = torch.from_numpy(scales.astype(np.float32)).contiguous()
+ # self._rotation = torch.from_numpy(rots.astype(np.float32)).contiguous()
+
+
+def render(
+ pc: GaussianModel,
+ height: int,
+ width: int,
+ C2W: torch.Tensor,
+ fxfycxcy: torch.Tensor,
+ bg_color=(1.0, 1.0, 1.0),
+ scaling_modifier=1.0,
+):
+ """
+ Render the scene.
+ """
+ screenspace_points = (
+ torch.zeros_like(
+ pc.get_xyz, dtype=pc.get_xyz.dtype, requires_grad=True, device="cuda"
+ )
+ + 0
+ )
+ try:
+ screenspace_points.retain_grad()
+ except:
+ pass
+
+ viewpoint_camera = Camera(C2W=C2W, fxfycxcy=fxfycxcy, h=height, w=width)
+
+ bg_color = torch.tensor(list(bg_color), dtype=torch.float32, device=C2W.device)
+
+ raster_settings = GaussianRasterizationSettings(
+ image_height=int(viewpoint_camera.h),
+ image_width=int(viewpoint_camera.w),
+ tanfovx=viewpoint_camera.tanfovX,
+ tanfovy=viewpoint_camera.tanfovY,
+ bg=bg_color,
+ scale_modifier=scaling_modifier,
+ viewmatrix=viewpoint_camera.world_view_transform,
+ projmatrix=viewpoint_camera.full_proj_transform,
+ sh_degree=pc.sh_degree,
+ campos=viewpoint_camera.camera_center,
+ prefiltered=False,
+ debug=False,
+ )
+
+ rasterizer = GaussianRasterizer(raster_settings=raster_settings)
+
+ means3D = pc.get_xyz
+ means2D = screenspace_points
+ opacity = pc.get_opacity
+ scales = pc.get_scaling
+ rotations = pc.get_rotation
+ shs = pc.get_features
+
+ rendered_image, _, rendered_depth, rendered_alpha = rasterizer(
+ means3D=means3D,
+ means2D=means2D,
+ shs=None if pc.sh_degree == 0 else shs,
+ colors_precomp=shs if pc.sh_degree == 0 else None,
+ opacities=opacity,
+ scales=scales,
+ rotations=rotations,
+ cov3D_precomp=None,
+ )
+
+ return {
+ "render": rendered_image,
+ "alpha": rendered_alpha,
+ "depth": rendered_depth,
+ }
diff --git a/freesplatter/models/renderer_2dgs/__init__.py b/freesplatter/models/renderer_2dgs/__init__.py
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/freesplatter/models/renderer_2dgs/gaussian_renderer.py b/freesplatter/models/renderer_2dgs/gaussian_renderer.py
new file mode 100644
index 0000000000000000000000000000000000000000..72ecbc061df4e66bfdf8e179f16995c7973ef512
--- /dev/null
+++ b/freesplatter/models/renderer_2dgs/gaussian_renderer.py
@@ -0,0 +1,60 @@
+import torch
+
+from .gaussian_utils import render, GaussianModel
+
+
+class GaussianRenderer:
+ def __init__(self, renderer_config=None):
+ if 'scaling_activation_type' not in renderer_config:
+ renderer_config['scaling_activation_type'] = 'exp'
+ if 'scale_min_act' not in renderer_config:
+ renderer_config['scale_min_act'] = 1
+ renderer_config['scale_max_act'] = 1
+ renderer_config['scale_multi_act'] = 0.1
+
+ self.gaussian_model = GaussianModel(sh_degree=renderer_config.sh_degree,
+ scaling_activation_type=renderer_config.scaling_activation_type,
+ scale_min_act=renderer_config.scale_min_act,
+ scale_max_act=renderer_config.scale_max_act,
+ scale_multi_act=renderer_config.scale_multi_act)
+ self.img_height = renderer_config.img_height
+ self.img_width = renderer_config.img_width
+ self.bg_color = renderer_config.bg_color if 'bg_color' in renderer_config else (1.0, 1.0, 1.0)
+
+ def render(self, latent, output_fxfycxcy, output_c2ws, render_size=None):
+ if render_size is None:
+ img_height, img_width = self.img_height, self.img_width
+ else:
+ img_height, img_width = render_size
+
+ shs_dim = (self.gaussian_model.sh_degree + 1) ** 2 * 3
+ xyz, features, opacity, scaling, rotation = latent.split([3, shs_dim, 1, 2, 4], dim=-1)
+
+ features = features.reshape(features.shape[0], -1, shs_dim//3, 3)
+
+ bs, vs = output_fxfycxcy.shape[:2]
+ images = torch.zeros(bs, vs, 3, img_height, img_width, dtype=torch.float32, device=output_c2ws.device)
+ alphas = torch.zeros(bs, vs, 1, img_height, img_width, dtype=torch.float32, device=output_c2ws.device)
+ depths = torch.zeros(bs, vs, 1, img_height, img_width, dtype=torch.float32, device=output_c2ws.device)
+ surf_normals = torch.zeros(bs, vs, 3, img_height, img_width, dtype=torch.float32, device=output_c2ws.device)
+ rend_normals = torch.zeros(bs, vs, 3, img_height, img_width, dtype=torch.float32, device=output_c2ws.device)
+ dists = torch.zeros(bs, vs, 1, img_height, img_width, dtype=torch.float32, device=output_c2ws.device)
+
+ for idx in range(bs):
+ pc = self.gaussian_model.set_data(xyz[idx], features[idx], scaling[idx], rotation[idx], opacity[idx])
+ for vidx in range(vs):
+ render_results = render(pc, img_height, img_width, output_c2ws[idx, vidx], output_fxfycxcy[idx, vidx], self.bg_color)
+ image = render_results['render']
+ alpha = render_results['alpha']
+ depth = render_results['depth']
+ surf_normal = render_results['surf_normal']
+ rend_normal = render_results['rend_normal']
+ dist = render_results['dist']
+ images[idx, vidx] = image
+ alphas[idx, vidx] = alpha
+ depths[idx, vidx] = depth
+ surf_normals[idx, vidx] = surf_normal
+ rend_normals[idx, vidx] = rend_normal
+ dists[idx, vidx] = dist
+ results = {'image': images, 'alpha': alphas, 'depth': depths, 'surf_normals': surf_normals, 'rend_normals': rend_normals, 'dists': dists}
+ return results
diff --git a/freesplatter/models/renderer_2dgs/gaussian_utils.py b/freesplatter/models/renderer_2dgs/gaussian_utils.py
new file mode 100644
index 0000000000000000000000000000000000000000..cd8a267dcaa15b356df5c412b35043c66d20c81c
--- /dev/null
+++ b/freesplatter/models/renderer_2dgs/gaussian_utils.py
@@ -0,0 +1,454 @@
+"""
+Gaussian Splatting.
+Partially borrowed from https://github.com/graphdeco-inria/gaussian-splatting.
+"""
+
+
+import os
+import torch
+from torch import nn
+import numpy as np
+from diff_surfel_rasterization import (
+ GaussianRasterizationSettings,
+ GaussianRasterizer,
+)
+from plyfile import PlyData, PlyElement
+from scipy.spatial.transform import Rotation as R
+
+
+def strip_lowerdiag(L):
+ uncertainty = torch.zeros((L.shape[0], 6), dtype=torch.float, device=L.device)
+
+ uncertainty[:, 0] = L[:, 0, 0]
+ uncertainty[:, 1] = L[:, 0, 1]
+ uncertainty[:, 2] = L[:, 0, 2]
+ uncertainty[:, 3] = L[:, 1, 1]
+ uncertainty[:, 4] = L[:, 1, 2]
+ uncertainty[:, 5] = L[:, 2, 2]
+ return uncertainty
+
+
+def strip_symmetric(sym):
+ return strip_lowerdiag(sym)
+
+
+def build_rotation(r):
+ norm = torch.sqrt(
+ r[:, 0] * r[:, 0] + r[:, 1] * r[:, 1] + r[:, 2] * r[:, 2] + r[:, 3] * r[:, 3]
+ )
+
+ q = r / norm[:, None]
+
+ R = torch.zeros((q.size(0), 3, 3), device=r.device)
+
+ r = q[:, 0]
+ x = q[:, 1]
+ y = q[:, 2]
+ z = q[:, 3]
+
+ R[:, 0, 0] = 1 - 2 * (y * y + z * z)
+ R[:, 0, 1] = 2 * (x * y - r * z)
+ R[:, 0, 2] = 2 * (x * z + r * y)
+ R[:, 1, 0] = 2 * (x * y + r * z)
+ R[:, 1, 1] = 1 - 2 * (x * x + z * z)
+ R[:, 1, 2] = 2 * (y * z - r * x)
+ R[:, 2, 0] = 2 * (x * z - r * y)
+ R[:, 2, 1] = 2 * (y * z + r * x)
+ R[:, 2, 2] = 1 - 2 * (x * x + y * y)
+ return R
+
+
+def build_scaling_rotation(s, r):
+ L = torch.zeros((s.shape[0], 3, 3), dtype=torch.float, device=s.device)
+ R = build_rotation(r)
+
+ L[:, 0, 0] = s[:, 0]
+ L[:, 1, 1] = s[:, 1]
+ L[:, 2, 2] = s[:, 2]
+
+ L = R @ L
+ return L
+
+
+def depths_to_points(view, depthmap):
+ c2w = (view.world_view_transform.T).inverse()
+ W, H = view.w, view.h
+ ndc2pix = torch.tensor([
+ [W / 2, 0, 0, (W) / 2],
+ [0, H / 2, 0, (H) / 2],
+ [0, 0, 0, 1]]).float().cuda().T
+ projection_matrix = c2w.T @ view.full_proj_transform
+ intrins = (projection_matrix @ ndc2pix)[:3,:3].T
+
+ grid_x, grid_y = torch.meshgrid(torch.arange(W, device='cuda').float(), torch.arange(H, device='cuda').float(), indexing='xy')
+ points = torch.stack([grid_x, grid_y, torch.ones_like(grid_x)], dim=-1).reshape(-1, 3)
+ rays_d = points @ intrins.inverse().T @ c2w[:3,:3].T
+ rays_o = c2w[:3,3]
+ points = depthmap.reshape(-1, 1) * rays_d + rays_o
+ return points
+
+
+def depth_to_normal(view, depth):
+ """
+ view: view camera
+ depth: depthmap
+ """
+ points = depths_to_points(view, depth).reshape(*depth.shape[1:], 3)
+ output = torch.zeros_like(points)
+ dx = torch.cat([points[2:, 1:-1] - points[:-2, 1:-1]], dim=0)
+ dy = torch.cat([points[1:-1, 2:] - points[1:-1, :-2]], dim=1)
+ normal_map = torch.nn.functional.normalize(torch.cross(dx, dy, dim=-1), dim=-1)
+ output[1:-1, 1:-1, :] = normal_map
+ return output
+
+
+class Camera(nn.Module):
+ def __init__(self, C2W, fxfycxcy, h, w):
+ """
+ C2W: 4x4 camera-to-world matrix; opencv convention
+ fxfycxcy: 4
+ """
+ super().__init__()
+ self.C2W = C2W.float()
+ self.W2C = self.C2W.inverse()
+
+ self.znear = 0.01
+ self.zfar = 100.0
+ self.h = h
+ self.w = w
+
+ fx, fy, cx, cy = fxfycxcy[0], fxfycxcy[1], fxfycxcy[2], fxfycxcy[3]
+ self.tanfovX = 1 / (2 * fx)
+ self.tanfovY = 1 / (2 * fy)
+ self.fovX = 2 * torch.atan(self.tanfovX)
+ self.fovY = 2 * torch.atan(self.tanfovY)
+ self.shiftX = 2 * cx - 1
+ self.shiftY = 2 * cy - 1
+
+ def getProjectionMatrix(znear, zfar, fovX, fovY, shiftX, shiftY):
+ tanHalfFovY = torch.tan((fovY / 2))
+ tanHalfFovX = torch.tan((fovX / 2))
+
+ top = tanHalfFovY * znear
+ bottom = -top
+ right = tanHalfFovX * znear
+ left = -right
+
+ P = torch.zeros(4, 4, dtype=torch.float32, device=fovX.device)
+
+ z_sign = 1.0
+
+ P[0, 0] = 2.0 * znear / (right - left)
+ P[1, 1] = 2.0 * znear / (top - bottom)
+ P[0, 2] = (right + left) / (right - left) + shiftX
+ P[1, 2] = (top + bottom) / (top - bottom) + shiftY
+ P[3, 2] = z_sign
+ P[2, 2] = z_sign * zfar / (zfar - znear)
+ P[2, 3] = -(zfar * znear) / (zfar - znear)
+ return P
+
+ self.world_view_transform = self.W2C.transpose(0, 1)
+ self.projection_matrix = getProjectionMatrix(
+ znear=self.znear, zfar=self.zfar, fovX=self.fovX, fovY=self.fovY, shiftX=self.shiftX, shiftY=self.shiftY
+ ).transpose(0, 1)
+ self.full_proj_transform = (
+ self.world_view_transform.unsqueeze(0).bmm(
+ self.projection_matrix.unsqueeze(0)
+ )
+ ).squeeze(0)
+ self.camera_center = self.C2W[:3, 3]
+
+
+class GaussianModel:
+ def setup_functions(self, scaling_activation_type='sigmoid', scale_min_act=0.001, scale_max_act=0.3, scale_multi_act=0.1):
+ def build_covariance_from_scaling_rotation(scaling, scaling_modifier, rotation):
+ L = build_scaling_rotation(scaling_modifier * scaling, rotation)
+ actual_covariance = L @ L.transpose(1, 2)
+ symm = strip_symmetric(actual_covariance)
+ return symm
+
+ if scaling_activation_type == 'exp':
+ self.scaling_activation = torch.exp
+ elif scaling_activation_type == 'softplus':
+ self.scaling_activation = torch.nn.functional.softplus
+ self.scale_multi_act = scale_multi_act
+ elif scaling_activation_type == 'sigmoid':
+ self.scale_min_act = scale_min_act
+ self.scale_max_act = scale_max_act
+ self.scaling_activation = torch.sigmoid
+ else:
+ raise NotImplementedError
+ self.scaling_activation_type = scaling_activation_type
+
+ self.rotation_activation = torch.nn.functional.normalize
+ self.opacity_activation = torch.sigmoid
+ self.feature_activation = torch.sigmoid
+ self.covariance_activation = build_covariance_from_scaling_rotation
+
+ def __init__(self, sh_degree: int, scaling_activation_type='exp', scale_min_act=0.001, scale_max_act=0.3, scale_multi_act=0.1):
+ self.sh_degree = sh_degree
+ self._xyz = torch.empty(0)
+ self._features_dc = torch.empty(0)
+ if self.sh_degree > 0:
+ self._features_rest = torch.empty(0)
+ else:
+ self._features_rest = None
+ self._scaling = torch.empty(0)
+ self._rotation = torch.empty(0)
+ self._opacity = torch.empty(0)
+ self.setup_functions(scaling_activation_type=scaling_activation_type, scale_min_act=scale_min_act, scale_max_act=scale_max_act, scale_multi_act=scale_multi_act)
+
+ def set_data(self, xyz, features, scaling, rotation, opacity):
+ self._xyz = xyz
+ self._features_dc = features[:, 0, :].contiguous() if self.sh_degree == 0 else features[:, 0:1, :].contiguous()
+ if self.sh_degree > 0:
+ self._features_rest = features[:, 1:, :].contiguous()
+ else:
+ self._features_rest = None
+ self._scaling = scaling
+ self._rotation = rotation
+ self._opacity = opacity
+ return self
+
+ def to(self, device):
+ self._xyz = self._xyz.to(device)
+ self._features_dc = self._features_dc.to(device)
+ if self.sh_degree > 0:
+ self._features_rest = self._features_rest.to(device)
+ self._scaling = self._scaling.to(device)
+ self._rotation = self._rotation.to(device)
+ self._opacity = self._opacity.to(device)
+ return self
+
+ @property
+ def get_scaling(self):
+ if self.scaling_activation_type == 'exp':
+ scales = self.scaling_activation(self._scaling)
+ elif self.scaling_activation_type == 'softplus':
+ scales = self.scaling_activation(self._scaling) * self.scale_multi_act
+ elif self.scaling_activation_type == 'sigmoid':
+ scales = self.scale_min_act + (self.scale_max_act - self.scale_min_act) * self.scaling_activation(self._scaling)
+ return scales
+
+ @property
+ def get_rotation(self):
+ return self.rotation_activation(self._rotation)
+
+ @property
+ def get_xyz(self):
+ return self._xyz
+
+ @property
+ def get_features(self):
+ if self.sh_degree > 0:
+ features_dc = self._features_dc
+ features_rest = self._features_rest
+ return torch.cat((features_dc, features_rest), dim=1)
+ else:
+ return self.feature_activation(self._features_dc)
+
+ @property
+ def get_opacity(self):
+ return self.opacity_activation(self._opacity)
+
+ def get_covariance(self, scaling_modifier=1):
+ return self.covariance_activation(
+ self.get_scaling, scaling_modifier, self._rotation
+ )
+
+ def construct_list_of_attributes(self, num_rest=0):
+ l = ['x', 'y', 'z']
+ # All channels except the 3 DC
+ for i in range(3):
+ l.append('f_dc_{}'.format(i))
+ for i in range(num_rest):
+ l.append('f_rest_{}'.format(i))
+ l.append('opacity')
+ for i in range(self._scaling.shape[1]):
+ l.append('scale_{}'.format(i))
+ for i in range(self._rotation.shape[1]):
+ l.append('rot_{}'.format(i))
+ return l
+
+ def save_ply_vis(self, path):
+ os.makedirs(os.path.dirname(path), exist_ok=True)
+
+ xyzs = self._xyz.detach().cpu().numpy()
+ f_dc = self._features_dc.detach().flatten(start_dim=1).contiguous().cpu().numpy()
+ opacities = self._opacity.detach().cpu().numpy()
+
+ scales = torch.log(self.get_scaling)
+ scales = scales.detach().cpu().numpy()
+
+ rot_mat_vis = np.array([[1, 0, 0], [0, 0, -1], [0, 1, 0]])
+ xyzs = xyzs @ rot_mat_vis.T
+ rotations = self._rotation.detach().cpu().numpy()
+ rotations = R.from_quat(rotations[:, [1,2,3,0]]).as_matrix()
+ rotations = rot_mat_vis @ rotations
+ rotations = R.from_matrix(rotations).as_quat()[:, [3,0,1,2]]
+
+ dtype_full = [(attribute, 'f4') for attribute in self.construct_list_of_attributes(0)]
+ elements = np.empty(xyzs.shape[0], dtype=dtype_full)
+ attributes = np.concatenate((xyzs, f_dc, opacities, scales, rotations), axis=1)
+ elements[:] = list(map(tuple, attributes))
+ el = PlyElement.describe(elements, 'vertex')
+ PlyData([el]).write(path)
+
+ def save_ply(self, path):
+ os.makedirs(os.path.dirname(path), exist_ok=True)
+
+ xyzs = self._xyz.detach().cpu().numpy()
+ f_dc = self._features_dc.detach().flatten(start_dim=1).contiguous().cpu().numpy()
+ if self.sh_degree > 0:
+ f_rest = self._features_rest.detach().flatten(start_dim=1).contiguous().cpu().numpy()
+ else:
+ f_rest = np.zeros((f_dc.shape[0], 0), dtype=f_dc.dtype)
+ opacities = self._opacity.detach().cpu().numpy()
+
+ scales = torch.log(self.get_scaling)
+ scales = scales.detach().cpu().numpy()
+
+ rotations = self._rotation.detach().cpu().numpy()
+
+ dtype_full = [(attribute, 'f4') for attribute in self.construct_list_of_attributes(f_rest.shape[-1])]
+ elements = np.empty(xyzs.shape[0], dtype=dtype_full)
+ attributes = np.concatenate((xyzs, f_dc, f_rest, opacities, scales, rotations), axis=1)
+ elements[:] = list(map(tuple, attributes))
+ el = PlyElement.describe(elements, "vertex")
+ PlyData([el]).write(path)
+
+ # def load_ply(self, path):
+ # plydata = PlyData.read(path)
+
+ # xyz = np.stack((np.asarray(plydata.elements[0]["x"]),
+ # np.asarray(plydata.elements[0]["y"]),
+ # np.asarray(plydata.elements[0]["z"])), axis=1)
+ # opacities = np.asarray(plydata.elements[0]["opacity"])[..., np.newaxis]
+
+ # features_dc = np.zeros((xyz.shape[0], 3, 1))
+ # features_dc[:, 0, 0] = np.asarray(plydata.elements[0]["f_dc_0"])
+ # features_dc[:, 1, 0] = np.asarray(plydata.elements[0]["f_dc_1"])
+ # features_dc[:, 2, 0] = np.asarray(plydata.elements[0]["f_dc_2"])
+
+ # scale_names = [p.name for p in plydata.elements[0].properties if p.name.startswith("scale_")]
+ # scale_names = sorted(scale_names, key = lambda x: int(x.split('_')[-1]))
+ # scales = np.zeros((xyz.shape[0], len(scale_names)))
+ # for idx, attr_name in enumerate(scale_names):
+ # scales[:, idx] = np.asarray(plydata.elements[0][attr_name])
+
+ # rot_names = [p.name for p in plydata.elements[0].properties if p.name.startswith("rot")]
+ # rot_names = sorted(rot_names, key=lambda x: int(x.split("_")[-1]))
+ # rots = np.zeros((xyz.shape[0], len(rot_names)))
+ # for idx, attr_name in enumerate(rot_names):
+ # rots[:, idx] = np.asarray(plydata.elements[0][attr_name])
+
+ # self._xyz = torch.from_numpy(xyz.astype(np.float32))
+ # self._features_dc = torch.from_numpy(features_dc.astype(np.float32)).transpose(1, 2).contiguous()
+ # self._opacity = torch.from_numpy(opacities.astype(np.float32)).contiguous()
+ # self._scaling = torch.from_numpy(scales.astype(np.float32)).contiguous()
+ # self._rotation = torch.from_numpy(rots.astype(np.float32)).contiguous()
+
+
+def render(
+ pc: GaussianModel,
+ height: int,
+ width: int,
+ C2W: torch.Tensor,
+ fxfycxcy: torch.Tensor,
+ bg_color=(1.0, 1.0, 1.0),
+ scaling_modifier=1.0,
+):
+ """
+ Render the scene.
+ """
+ screenspace_points = (
+ torch.zeros_like(
+ pc.get_xyz, dtype=pc.get_xyz.dtype, requires_grad=True, device="cuda"
+ )
+ + 0
+ )
+ try:
+ screenspace_points.retain_grad()
+ except:
+ pass
+
+ viewpoint_camera = Camera(C2W=C2W, fxfycxcy=fxfycxcy, h=height, w=width)
+
+ bg_color = torch.tensor(list(bg_color), dtype=torch.float32, device=C2W.device)
+
+ raster_settings = GaussianRasterizationSettings(
+ image_height=int(viewpoint_camera.h),
+ image_width=int(viewpoint_camera.w),
+ tanfovx=viewpoint_camera.tanfovX,
+ tanfovy=viewpoint_camera.tanfovY,
+ bg=bg_color,
+ scale_modifier=scaling_modifier,
+ viewmatrix=viewpoint_camera.world_view_transform,
+ projmatrix=viewpoint_camera.full_proj_transform,
+ sh_degree=pc.sh_degree,
+ campos=viewpoint_camera.camera_center,
+ prefiltered=False,
+ debug=False,
+ )
+
+ rasterizer = GaussianRasterizer(raster_settings=raster_settings)
+
+ means3D = pc.get_xyz
+ means2D = screenspace_points
+ opacity = pc.get_opacity
+ scales = pc.get_scaling
+ rotations = pc.get_rotation
+ shs = pc.get_features
+
+ rendered_image, _, allmap = rasterizer(
+ means3D=means3D,
+ means2D=means2D,
+ shs=None if pc.sh_degree == 0 else shs,
+ colors_precomp=shs if pc.sh_degree == 0 else None,
+ opacities=opacity,
+ scales=scales,
+ rotations=rotations,
+ cov3D_precomp=None,
+ )
+
+ # additional regularizations
+ render_alpha = allmap[1:2]
+
+ # get normal map
+ # transform normal from view space to world space
+ render_normal = allmap[2:5]
+ render_normal = (render_normal.permute(1, 2, 0) @ (viewpoint_camera.world_view_transform[:3, :3].T)).permute(2, 0, 1)
+
+ # get median depth map
+ render_depth_median = allmap[5:6]
+ render_depth_median = torch.nan_to_num(render_depth_median, 0, 0)
+
+ # get expected depth map
+ render_depth_expected = allmap[0:1]
+ render_depth_expected = (render_depth_expected / render_alpha)
+ render_depth_expected = torch.nan_to_num(render_depth_expected, 0, 0)
+
+ # get depth distortion map
+ render_dist = allmap[6:7]
+
+ # psedo surface attributes
+ # surf depth is either median or expected by setting depth_ratio to 1 or 0
+ # for bounded scene, use median depth, i.e., depth_ratio = 1;
+ # for unbounded scene, use expected depth, i.e., depth_ration = 0, to reduce disk anliasing.
+ depth_ratio = 0.0
+ surf_depth = render_depth_expected * (1 - depth_ratio) + depth_ratio * render_depth_median
+
+ # assume the depth points form the 'surface' and generate psudo surface normal for regularizations.
+ surf_normal = depth_to_normal(viewpoint_camera, surf_depth)
+ surf_normal = surf_normal.permute(2, 0, 1)
+ # remember to multiply with accum_alpha since render_normal is unnormalized.
+ surf_normal = surf_normal * (render_alpha).detach()
+
+ return {
+ "render": rendered_image,
+ "depth": surf_depth,
+ "alpha": render_alpha,
+ 'surf_normal': surf_normal,
+ 'rend_normal': render_normal,
+ 'dist': render_dist,
+ }
diff --git a/freesplatter/models/transformer.py b/freesplatter/models/transformer.py
new file mode 100644
index 0000000000000000000000000000000000000000..8302b13e7bb42d2db8c979b893360b69fc04facb
--- /dev/null
+++ b/freesplatter/models/transformer.py
@@ -0,0 +1,181 @@
+import math
+import torch
+import torch.nn as nn
+import torch.nn.functional as F
+from inspect import isfunction
+from einops import rearrange, repeat
+import xformers.ops as xops
+
+
+def exists(val):
+ return val is not None
+
+
+def default(val, d):
+ if exists(val):
+ return val
+ return d() if isfunction(d) else d
+
+
+class CrossAttention(nn.Module):
+ def __init__(self, query_dim, context_dim=None, heads=8, dim_head=64, dropout=0.):
+ super().__init__()
+ inner_dim = dim_head * heads
+ context_dim = default(context_dim, query_dim)
+
+ self.heads = heads
+
+ self.to_q = nn.Linear(query_dim, inner_dim, bias=False)
+ self.to_k = nn.Linear(context_dim, inner_dim, bias=False)
+ self.to_v = nn.Linear(context_dim, inner_dim, bias=False)
+
+ self.to_out = nn.Sequential(
+ nn.Linear(inner_dim, query_dim, bias=False),
+ nn.Dropout(dropout)
+ )
+
+ def forward(self, x, context=None, mask=None):
+ h = self.heads
+
+ q = self.to_q(x)
+ context = default(context, x)
+ k = self.to_k(context)
+ v = self.to_v(context)
+
+ q, k, v = map(lambda t: rearrange(t, 'b n (h d) -> (b h) n d', h=h), (q, k, v))
+
+ out = xops.memory_efficient_attention(q, k, v)
+ out = rearrange(out, '(b h) n d -> b n (h d)', h=h)
+
+ return self.to_out(out)
+
+
+class BasicTransformerBlock(nn.Module):
+ def __init__(self, dim, n_heads, d_head, dropout=0., context_dim=None, gated_ff=True):
+ super().__init__()
+
+ self.self_attn = CrossAttention(query_dim=dim, heads=n_heads, dim_head=d_head, dropout=dropout)
+
+ self.ff = nn.Sequential(
+ nn.Linear(dim, dim*4, bias=False),
+ nn.GELU(),
+ nn.Linear(dim*4, dim, bias=False),
+ )
+
+ self.norm1 = nn.LayerNorm(dim, bias=False)
+ self.norm2 = nn.LayerNorm(dim, bias=False)
+
+ def forward(self, x, context=None):
+ before_sa = self.norm1(x)
+ x = x + self.self_attn(before_sa)
+ x = self.ff(self.norm2(x)) + x
+ return x
+
+
+class Transformer(nn.Module):
+ def __init__(
+ self,
+ image_size=512,
+ patch_size=8,
+ input_dim=3,
+ inner_dim=1024,
+ output_dim=14,
+ n_heads=16,
+ depth=24,
+ dropout=0.,
+ ):
+ super().__init__()
+
+ self.patch_size = patch_size
+ self.input_dim = input_dim
+ self.inner_dim = inner_dim
+ self.output_dim = output_dim
+
+ self.patchify = nn.Conv2d(input_dim, inner_dim, kernel_size=patch_size, stride=patch_size, padding=0, bias=False)
+
+ num_patches = (image_size // patch_size) ** 2
+ self.pos_embed = nn.Parameter(torch.zeros(1, num_patches, inner_dim))
+ self.ref_embed = nn.Parameter(torch.zeros(1, 1, inner_dim))
+ self.src_embed = nn.Parameter(torch.zeros(1, 1, inner_dim))
+
+ self.blocks = nn.ModuleList(
+ [BasicTransformerBlock(inner_dim, n_heads, inner_dim//n_heads, dropout=dropout)
+ for _ in range(depth)]
+ )
+
+ self.norm = nn.LayerNorm(inner_dim, bias=False)
+ self.unpatchify = nn.Linear(inner_dim, patch_size ** 2 * output_dim, bias=True)
+
+ nn.init.trunc_normal_(self.pos_embed, std=.02)
+ nn.init.trunc_normal_(self.ref_embed, std=.02)
+ nn.init.trunc_normal_(self.src_embed, std=.02)
+ self.apply(self._init_weights)
+
+ def _init_weights(self, m):
+ if isinstance(m, nn.Linear):
+ nn.init.trunc_normal_(m.weight, std=.02)
+ if m.bias is not None:
+ nn.init.constant_(m.bias, 0)
+ elif isinstance(m, nn.LayerNorm):
+ nn.init.constant_(m.weight, 1.0)
+ if m.bias is not None:
+ nn.init.constant_(m.bias, 0)
+
+ def interpolate_pos_encoding(self, x, w, h):
+ npatch = x.shape[-2]
+ N = self.pos_embed.shape[-2]
+ if npatch == N and w == h:
+ return self.pos_embed
+ patch_pos_embed = self.pos_embed
+ dim = x.shape[-1]
+ w0 = w // self.patch_size
+ h0 = h // self.patch_size
+ # we add a small number to avoid floating point error in the interpolation
+ # see discussion at https://github.com/facebookresearch/dino/issues/8
+ w0, h0 = w0 + 0.1, h0 + 0.1
+ patch_pos_embed = F.interpolate(
+ patch_pos_embed.reshape(1, int(math.sqrt(N)), int(math.sqrt(N)), dim).permute(0, 3, 1, 2).contiguous(),
+ scale_factor=(w0 / math.sqrt(N), h0 / math.sqrt(N)),
+ mode='bicubic',
+ )
+ assert int(w0) == patch_pos_embed.shape[-2] and int(h0) == patch_pos_embed.shape[-1]
+ patch_pos_embed = patch_pos_embed.permute(0, 2, 3, 1).view(1, -1, dim).contiguous()
+ return patch_pos_embed
+
+ def forward(self, images):
+ """
+ images: (B, N, C, H, W)
+ """
+ B, N, _, H, W = images.shape
+
+ # patchify
+ images = rearrange(images, 'b n c h w -> (b n) c h w')
+ tokens = self.patchify(images)
+ tokens = rearrange(tokens, 'bn c h w -> bn (h w) c')
+
+ # add pos encodings
+ tokens = rearrange(tokens, '(b n) hw c -> b n hw c', b=B)
+ tokens = tokens + self.interpolate_pos_encoding(tokens, W, H).unsqueeze(1)
+ view_embeds = torch.cat([self.ref_embed, self.src_embed.repeat(1, N-1, 1)], dim=1)
+ tokens = tokens + view_embeds.unsqueeze(2)
+
+ # tokens = rearrange(tokens, '(b n) hw c -> b n hw c', b=B)
+ # tokens = tokens + self.interpolate_pos_encoding(tokens, W, H).unsqueeze(1)
+ # view_embeds = self.src_embed.repeat(1, N, 1)
+ # view_embeds[:, 0:1] = torch.zeros_like(self.ref_embed)
+ # tokens = tokens + view_embeds.unsqueeze(2)
+
+ # transformer
+ tokens = rearrange(tokens, 'b n hw c -> b (n hw) c')
+ x = tokens
+ for layer in self.blocks:
+ x = layer(x)
+
+ # unpatchify
+ x = self.norm(x)
+ x = self.unpatchify(x)
+ x = rearrange(x, 'b (n h w) c -> b n h w c', n=N, h=H//self.patch_size, w=W//self.patch_size)
+ x = rearrange(x, 'b n h w (p q c) -> b n (h p) (w q) c', p=self.patch_size, q=self.patch_size)
+ out = x
+
+ return out
diff --git a/freesplatter/utils/__init__.py b/freesplatter/utils/__init__.py
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/freesplatter/utils/camera_util.py b/freesplatter/utils/camera_util.py
new file mode 100644
index 0000000000000000000000000000000000000000..206f176bdf1e01047b544d70a1ef9623bec6b35b
--- /dev/null
+++ b/freesplatter/utils/camera_util.py
@@ -0,0 +1,114 @@
+import torch
+import numpy as np
+
+
+def normalize_vecs(vectors: torch.Tensor) -> torch.Tensor:
+ """
+ Normalize vector lengths.
+ """
+ return vectors / (torch.norm(vectors, dim=-1, keepdim=True))
+
+
+def blender_to_opencv(camera_matrix: torch.Tensor):
+ """
+ Convert Blender World-to-Camera matrix into OpenCV space by flipping y and z axes
+ Blender camera system: x-right, y-up, z-backward
+ OpenCV camera system: x-right, y-down, z-forward
+ """
+ flip_yz = torch.tensor([[1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]])
+ if camera_matrix.ndim == 3:
+ flip_yz = flip_yz.unsqueeze(0)
+ camera_matrix_opencv = torch.matmul(flip_yz.to(camera_matrix), camera_matrix)
+ return camera_matrix_opencv
+
+
+def pad_camera_extrinsics_4x4(extrinsics):
+ if extrinsics.shape[-2] == 4:
+ return extrinsics
+ padding = torch.tensor([[0, 0, 0, 1]]).to(extrinsics)
+ if extrinsics.ndim == 3:
+ padding = padding.unsqueeze(0).repeat(extrinsics.shape[0], 1, 1)
+ extrinsics = torch.cat([extrinsics, padding], dim=-2)
+ return extrinsics
+
+
+def create_camera_to_world(camera_position: torch.Tensor, look_at: torch.Tensor = None, up_world: torch.Tensor = None, camera_system: str = 'opencv'):
+ """
+ Create OpenCV or OpenGL camera extrinsics from camera locations and look-at position.
+
+ camera_position: (M, 3) or (3,)
+ look_at: (3)
+ up_world: (3)
+ return: (M, 3, 4) or (3, 4)
+ """
+ # by default, looking at the origin and world up is z-axis
+ if look_at is None:
+ look_at = torch.tensor([0, 0, 0], dtype=torch.float32)
+ if up_world is None:
+ up_world = torch.tensor([0, 0, 1], dtype=torch.float32)
+ if camera_position.ndim == 2:
+ look_at = look_at.unsqueeze(0).repeat(camera_position.shape[0], 1)
+ up_world = up_world.unsqueeze(0).repeat(camera_position.shape[0], 1)
+
+ assert camera_system in ['opencv', 'opengl']
+ if camera_system == 'opencv':
+ # OpenCV camera: z-forward, x-right, y-down
+ z_axis = look_at - camera_position
+ z_axis = normalize_vecs(z_axis).float()
+ x_axis = torch.cross(z_axis, up_world)
+ x_axis = normalize_vecs(x_axis).float()
+ y_axis = torch.cross(z_axis, x_axis)
+ y_axis = normalize_vecs(y_axis).float()
+ else:
+ # OpenGL camera: z-backward, x-right, y-up
+ z_axis = camera_position - look_at
+ z_axis = normalize_vecs(z_axis).float()
+ x_axis = torch.cross(up_world, z_axis)
+ x_axis = normalize_vecs(x_axis).float()
+ y_axis = torch.cross(z_axis, x_axis)
+ y_axis = normalize_vecs(y_axis).float()
+
+ extrinsics = torch.stack([x_axis, y_axis, z_axis, camera_position], dim=-1)
+ extrinsics = pad_camera_extrinsics_4x4(extrinsics)
+ return extrinsics
+
+
+def FOV_to_intrinsics(fov, device='cpu'):
+ """
+ Creates a 3x3 camera intrinsics matrix from the camera field of view, specified in degrees.
+ Note the intrinsics are returned as normalized by image size, rather than in pixel units.
+ Assumes principal point is at image center.
+ """
+ focal_length = 0.5 / np.tan(np.deg2rad(fov) * 0.5)
+ intrinsics = torch.tensor([[focal_length, 0, 0.5], [0, focal_length, 0.5], [0, 0, 1]], device=device)
+ return intrinsics
+
+
+def normalize_cameras(extrinsics, camera_position: torch.Tensor = None, camera_system: str = 'opencv', canonical_index=0):
+ """
+ Normalize the first camera to the canonical camera position, and transform other cameras accordingly.
+
+ extrinsics: (N, 4, 4)
+ """
+ if camera_position is None:
+ camera_position = torch.tensor([[0, -2, 0]]).float()
+ assert camera_system in ['opencv', 'opengl']
+
+ canonical_distance = camera_position.norm()
+
+ # compute conditional camera distances
+ cond_extrinsic = extrinsics[canonical_index]
+ # cond_extrinsic = extrinsics[0]
+ cond_camera_distance = cond_extrinsic[:3, 3].norm(dim=-1, keepdim=False)
+
+ # scale camera distances
+ scale = canonical_distance / cond_camera_distance
+ extrinsics[:, :3, 3] = extrinsics[:, :3, 3] * scale
+
+ # rotate all cameras
+ canonical_extrinsic = create_camera_to_world(camera_position, camera_system=camera_system).to(extrinsics)
+ # transform_matrix = torch.matmul(canonical_extrinsic, torch.linalg.inv(extrinsics[0:1]))
+ transform_matrix = torch.matmul(canonical_extrinsic, torch.linalg.inv(extrinsics[canonical_index:canonical_index+1]))
+ normalized_extrinsics = torch.matmul(transform_matrix, extrinsics)
+
+ return normalized_extrinsics, scale
\ No newline at end of file
diff --git a/freesplatter/utils/geometry_util.py b/freesplatter/utils/geometry_util.py
new file mode 100644
index 0000000000000000000000000000000000000000..d4685a0505253a6f16bb37a90cb8c3b62a59572c
--- /dev/null
+++ b/freesplatter/utils/geometry_util.py
@@ -0,0 +1,203 @@
+import torch
+import torch.nn.functional as F
+from einops import rearrange
+
+
+# --- Intrinsics Transformations ---
+
+def normalize_intrinsics(intrinsics, image_shape):
+ '''Normalize an intrinsics matrix given the image shape'''
+ intrinsics = intrinsics.clone()
+ intrinsics[..., 0, :] /= image_shape[1]
+ intrinsics[..., 1, :] /= image_shape[0]
+ return intrinsics
+
+
+def unnormalize_intrinsics(intrinsics, image_shape):
+ '''Unnormalize an intrinsics matrix given the image shape'''
+ intrinsics = intrinsics.clone()
+ intrinsics[..., 0, :] *= image_shape[1]
+ intrinsics[..., 1, :] *= image_shape[0]
+ return intrinsics
+
+
+# --- Projections ---
+
+def homogenize_points(points):
+ """Append a '1' along the final dimension of the tensor (i.e. convert xyz->xyz1)"""
+ return torch.cat([points, torch.ones_like(points[..., :1])], dim=-1)
+
+
+def normalize_homogenous_points(points):
+ """Normalize the point vectors"""
+ return points / points[..., -1:]
+
+
+def pixel_space_to_camera_space(pixel_space_points, depth, intrinsics):
+ """
+ Convert pixel space points to camera space points.
+
+ Args:
+ pixel_space_points (torch.Tensor): Pixel space points with shape (h, w, 2)
+ depth (torch.Tensor): Depth map with shape (b, v, h, w, 1)
+ intrinsics (torch.Tensor): Camera intrinsics with shape (b, v, 3, 3)
+
+ Returns:
+ torch.Tensor: Camera space points with shape (b, v, h, w, 3).
+ """
+ pixel_space_points = homogenize_points(pixel_space_points)
+ camera_space_points = torch.einsum('b v i j , h w j -> b v h w i', intrinsics.inverse(), pixel_space_points)
+ camera_space_points = camera_space_points * depth
+ return camera_space_points
+
+
+def camera_space_to_world_space(camera_space_points, c2w):
+ """
+ Convert camera space points to world space points.
+
+ Args:
+ camera_space_points (torch.Tensor): Camera space points with shape (b, v, h, w, 3)
+ c2w (torch.Tensor): Camera to world extrinsics matrix with shape (b, v, 4, 4)
+
+ Returns:
+ torch.Tensor: World space points with shape (b, v, h, w, 3).
+ """
+ camera_space_points = homogenize_points(camera_space_points)
+ world_space_points = torch.einsum('b v i j , b v h w j -> b v h w i', c2w, camera_space_points)
+ return world_space_points[..., :3]
+
+
+def camera_space_to_pixel_space(camera_space_points, intrinsics):
+ """
+ Convert camera space points to pixel space points.
+
+ Args:
+ camera_space_points (torch.Tensor): Camera space points with shape (b, v1, v2, h, w, 3)
+ c2w (torch.Tensor): Camera to world extrinsics matrix with shape (b, v2, 3, 3)
+
+ Returns:
+ torch.Tensor: World space points with shape (b, v1, v2, h, w, 2).
+ """
+ camera_space_points = normalize_homogenous_points(camera_space_points)
+ pixel_space_points = torch.einsum('b u i j , b v u h w j -> b v u h w i', intrinsics, camera_space_points)
+ return pixel_space_points[..., :2]
+
+
+def world_space_to_camera_space(world_space_points, c2w):
+ """
+ Convert world space points to pixel space points.
+
+ Args:
+ world_space_points (torch.Tensor): World space points with shape (b, v1, h, w, 3)
+ c2w (torch.Tensor): Camera to world extrinsics matrix with shape (b, v2, 4, 4)
+
+ Returns:
+ torch.Tensor: Camera space points with shape (b, v1, v2, h, w, 3).
+ """
+ world_space_points = homogenize_points(world_space_points)
+ camera_space_points = torch.einsum('b u i j , b v h w j -> b v u h w i', c2w.inverse(), world_space_points)
+ return camera_space_points[..., :3]
+
+
+def unproject_depth(depth, intrinsics, c2w):
+ """
+ Turn the depth map into a 3D point cloud in world space
+
+ Args:
+ depth: (b, v, h, w, 1)
+ intrinsics: (b, v, 3, 3)
+ c2w: (b, v, 4, 4)
+
+ Returns:
+ torch.Tensor: World space points with shape (b, v, h, w, 3).
+ """
+
+ # Compute indices of pixels
+ h, w = depth.shape[-3], depth.shape[-2]
+ x_grid, y_grid = torch.meshgrid(
+ torch.arange(w, device=depth.device, dtype=torch.float32),
+ torch.arange(h, device=depth.device, dtype=torch.float32),
+ indexing='xy'
+ ) # (h, w), (h, w)
+
+ # Compute coordinates of pixels in camera space
+ pixel_space_points = torch.stack((x_grid, y_grid), dim=-1) # (..., h, w, 2)
+ camera_points = pixel_space_to_camera_space(pixel_space_points, depth, intrinsics) # (..., h, w, 3)
+
+ # Convert points to world space
+ world_points = camera_space_to_world_space(camera_points, c2w) # (..., h, w, 3)
+
+ return world_points
+
+
+@torch.no_grad()
+def calculate_in_frustum_mask(depth_1, intrinsics_1, c2w_1, depth_2, intrinsics_2, c2w_2, depth_tolerance=1e-1):
+ """
+ A function that takes in the depth, intrinsics and c2w matrices of two sets
+ of views, and then works out which of the pixels in the first set of views
+ has a direct corresponding pixel in any of views in the second set
+
+ Args:
+ depth_1: (b, v1, h, w)
+ intrinsics_1: (b, v1, 3, 3)
+ c2w_1: (b, v1, 4, 4)
+ depth_2: (b, v2, h, w)
+ intrinsics_2: (b, v2, 3, 3)
+ c2w_2: (b, v2, 4, 4)
+
+ Returns:
+ torch.Tensor: Mask with shape (b, v1, h, w).
+ """
+
+ _, v1, h, w = depth_1.shape
+ _, v2, _, _ = depth_2.shape
+
+ # unnormalize intrinsics if needed
+ if intrinsics_1[0, 0, 0, 2] < 1:
+ intrinsics_1 = unnormalize_intrinsics(intrinsics_1, (h, w))
+ if intrinsics_2[0, 0, 0, 2] < 1:
+ intrinsics_2 = unnormalize_intrinsics(intrinsics_2, (h, w))
+
+ # Unproject the depth to get the 3D points in world space
+ points_3d = unproject_depth(depth_1[..., None], intrinsics_1, c2w_1) # (b, v1, h, w, 3)
+
+ # Project the 3D points into the pixel space of all the second views simultaneously
+ camera_points = world_space_to_camera_space(points_3d, c2w_2) # (b, v1, v2, h, w, 3)
+ points_2d = camera_space_to_pixel_space(camera_points, intrinsics_2) # (b, v1, v2, h, w, 2)
+
+ # Calculate the depth of each point
+ rendered_depth = camera_points[..., 2] # (b, v1, v2, h, w)
+
+ # We use three conditions to determine if a point should be masked
+
+ # Condition 1: Check if the points are in the frustum of any of the v2 views
+ in_frustum_mask = (
+ (points_2d[..., 0] > 0) &
+ (points_2d[..., 0] < w) &
+ (points_2d[..., 1] > 0) &
+ (points_2d[..., 1] < h)
+ ) # (b, v1, v2, h, w)
+ in_frustum_mask = in_frustum_mask.any(dim=-3) # (b, v1, h, w)
+
+ # Condition 2: Check if the points have non-zero (i.e. valid) depth in the input view
+ non_zero_depth = depth_1 > 1e-6
+
+ # Condition 3: Check if the points have matching depth to any of the v2
+ # views F.grid_sample expects the input coordinates to
+ # be normalized to the range [-1, 1], so we normalize first
+ points_2d[..., 0] /= w
+ points_2d[..., 1] /= h
+ points_2d = points_2d * 2 - 1
+ matching_depth = torch.ones_like(rendered_depth, dtype=torch.bool)
+ for b in range(depth_1.shape[0]):
+ for i in range(v1):
+ for j in range(v2):
+ depth = rearrange(depth_2[b, j], 'h w -> 1 1 h w')
+ coords = rearrange(points_2d[b, i, j], 'h w c -> 1 h w c')
+ sampled_depths = F.grid_sample(depth, coords, align_corners=False)[0, 0]
+ matching_depth[b, i, j] = torch.isclose(rendered_depth[b, i, j], sampled_depths, atol=depth_tolerance)
+
+ matching_depth = matching_depth.any(dim=-3) # (..., v1, h, w)
+
+ mask = in_frustum_mask & non_zero_depth & matching_depth
+ return mask
\ No newline at end of file
diff --git a/freesplatter/utils/infer_util.py b/freesplatter/utils/infer_util.py
new file mode 100644
index 0000000000000000000000000000000000000000..981d1f7db241591b59d086070efd2aa30855d157
--- /dev/null
+++ b/freesplatter/utils/infer_util.py
@@ -0,0 +1,157 @@
+import os
+import importlib
+import imageio
+import torch
+import numpy as np
+import PIL.Image
+from PIL import Image
+from typing import Any
+from torchvision import transforms
+
+
+def instantiate_from_config(config):
+ if not "target" in config:
+ if config == '__is_first_stage__':
+ return None
+ elif config == "__is_unconditional__":
+ return None
+ raise KeyError("Expected key `target` to instantiate.")
+ return get_obj_from_str(config["target"])(**config.get("params", dict()))
+
+
+def get_obj_from_str(string, reload=False):
+ module, cls = string.rsplit(".", 1)
+ if reload:
+ module_imp = importlib.import_module(module)
+ importlib.reload(module_imp)
+ return getattr(importlib.import_module(module, package=None), cls)
+
+
+# def resize_without_crop(pil_image, target_width, target_height):
+# resized_image = pil_image.resize((target_width, target_height), Image.LANCZOS)
+# return np.array(resized_image)[:, :, :3]
+
+
+# @torch.inference_mode()
+# def numpy2pytorch(imgs):
+# h = torch.from_numpy(np.stack(imgs, axis=0)).float() / 255.0 * 2.0 - 1.0
+# h = h.movedim(-1, 1)
+# return h
+
+
+# @torch.inference_mode()
+# def remove_background(
+# image: PIL.Image.Image,
+# rembg: Any = None,
+# force: bool = False,
+# **rembg_kwargs,
+# ) -> PIL.Image.Image:
+# do_remove = True
+# if image.mode == "RGBA" and image.getextrema()[3][0] < 255:
+# do_remove = False
+# do_remove = do_remove or force
+# if do_remove:
+# W, H = image.size
+# k = (256.0 / float(H * W)) ** 0.5
+# feed = resize_without_crop(image, int(64 * round(W * k)), int(64 * round(H * k)))
+# feed = numpy2pytorch([feed]).to(device=rembg.device, dtype=torch.float32)
+# alpha = rembg(feed)[0][0]
+# alpha = torch.nn.functional.interpolate(alpha, size=(H, W), mode="bilinear")
+# alpha = alpha.squeeze().clamp(0, 1)
+# alpha = (alpha * 255).cpu().data.numpy().astype(np.uint8)
+# alpha = Image.fromarray(alpha)
+
+# no_bg_image = Image.new("RGBA", alpha.size, (0, 0, 0, 0))
+# no_bg_image.paste(image, mask=alpha)
+# image = no_bg_image
+# return image
+
+
+@torch.inference_mode()
+def remove_background(
+ image: PIL.Image.Image,
+ rembg: Any = None,
+ force: bool = False,
+ **rembg_kwargs,
+) -> PIL.Image.Image:
+ do_remove = True
+ if image.mode == "RGBA" and image.getextrema()[3][0] < 255:
+ do_remove = False
+ do_remove = do_remove or force
+ if do_remove:
+ transform_image = transforms.Compose([
+ transforms.Resize((1024, 1024)),
+ transforms.ToTensor(),
+ transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
+ ])
+ image = image.convert('RGB')
+ input_images = transform_image(image).unsqueeze(0).to(rembg.device)
+ with torch.no_grad():
+ preds = rembg(input_images)[-1].sigmoid().cpu()
+ pred = preds[0].squeeze()
+ pred_pil = transforms.ToPILImage()(pred)
+ mask = pred_pil.resize(image.size)
+ image.putalpha(mask)
+ return image
+
+
+def resize_foreground(
+ image: PIL.Image.Image,
+ ratio: float,
+) -> PIL.Image.Image:
+ image = np.array(image)
+ assert image.shape[-1] == 4
+ alpha = np.where(image[..., 3] > 0)
+ y1, y2, x1, x2 = (
+ alpha[0].min(),
+ alpha[0].max(),
+ alpha[1].min(),
+ alpha[1].max(),
+ )
+ # crop the foreground
+ fg = image[y1:y2, x1:x2]
+ # pad to square
+ size = max(fg.shape[0], fg.shape[1])
+ ph0, pw0 = (size - fg.shape[0]) // 2, (size - fg.shape[1]) // 2
+ ph1, pw1 = size - fg.shape[0] - ph0, size - fg.shape[1] - pw0
+ new_image = np.pad(
+ fg,
+ ((ph0, ph1), (pw0, pw1), (0, 0)),
+ mode="constant",
+ constant_values=((0, 0), (0, 0), (0, 0)),
+ )
+
+ # compute padding according to the ratio
+ new_size = int(new_image.shape[0] / ratio)
+ # pad to size, double side
+ ph0, pw0 = (new_size - size) // 2, (new_size - size) // 2
+ ph1, pw1 = new_size - size - ph0, new_size - size - pw0
+ new_image = np.pad(
+ new_image,
+ ((ph0, ph1), (pw0, pw1), (0, 0)),
+ mode="constant",
+ constant_values=((0, 0), (0, 0), (0, 0)),
+ )
+ new_image = Image.fromarray(new_image)
+ return new_image
+
+
+def rgba_to_white_background(image: PIL.Image.Image) -> torch.Tensor:
+ image = np.asarray(image, dtype=np.float32) / 255.0
+ image = torch.from_numpy(image).movedim(2, 0).float()
+ image, alpha = image.split([3, 1], dim=0)
+ image = image * alpha + torch.ones_like(image) * (1 - alpha)
+ return image, alpha
+
+
+def save_video(
+ frames: torch.Tensor,
+ output_path: str,
+ fps: int = 30,
+) -> None:
+ # images: (N, C, H, W)
+ frames = [(frame.permute(1, 2, 0).cpu().numpy() * 255).astype(np.uint8) for frame in frames]
+ writer = imageio.get_writer(output_path, mode='I', fps=fps, codec='libx264')
+ for frame in frames:
+ writer.append_data(frame)
+ writer.close()
\ No newline at end of file
diff --git a/freesplatter/utils/mesh.py b/freesplatter/utils/mesh.py
new file mode 100644
index 0000000000000000000000000000000000000000..26b346ffde5ff18104f95859026d4e2a2c7c51c5
--- /dev/null
+++ b/freesplatter/utils/mesh.py
@@ -0,0 +1,736 @@
+import os
+import math
+import numpy as np
+import cv2
+import torch
+import trimesh
+import torch.nn.functional as F
+import pygltflib
+import xatlas
+import miniball
+from trimesh.visual import TextureVisuals
+from PIL import Image
+
+
+def dot(x, y):
+ return torch.sum(x * y, -1, keepdim=True)
+
+
+def length(x, eps=1e-20):
+ return torch.sqrt(torch.clamp(dot(x, x), min=eps))
+
+
+def safe_normalize(x, eps=1e-20):
+ return x / length(x, eps)
+
+
+class Mesh:
+ def __init__(
+ self,
+ v=None,
+ f=None,
+ vn=None,
+ fn=None,
+ vt=None,
+ ft=None,
+ vc=None,
+ albedo=None,
+ device=None,
+ textureless=False):
+ self.device = device
+ self.v = v
+ self.vn = vn
+ self.vt = vt
+ self.vc = vc
+ self.f = f
+ self.fn = fn
+ self.ft = ft
+ self.face_normals = None
+ # only support a single albedo
+ self.albedo = albedo
+ self.textureless = textureless
+
+ self.ori_center = 0
+ self.ori_scale = 1
+
+ def detach(self):
+ self.v = self.v.detach() if self.v is not None else None
+ self.vn = self.vn.detach() if self.vn is not None else None
+ self.vt = self.vt.detach() if self.vt is not None else None
+ self.vc = self.vc.detach() if self.vc is not None else None
+ self.f = self.f.detach() if self.f is not None else None
+ self.fn = self.fn.detach() if self.fn is not None else None
+ self.ft = self.ft.detach() if self.ft is not None else None
+ self.face_normals = self.face_normals.detach() if self.face_normals is not None else None
+ self.albedo = self.albedo.detach() if self.albedo is not None else None
+ return self
+
+ @classmethod
+ def load(cls, path=None, resize=False, auto_uv=True, flip_yz=False, **kwargs):
+ # assume init with kwargs
+ if path is None:
+ mesh = cls(**kwargs)
+ # obj supports face uv
+ elif path.endswith(".obj"):
+ mesh = cls.load_obj(path, **kwargs)
+ # trimesh only supports vertex uv, but can load more formats
+ else:
+ mesh = cls.load_trimesh(path, **kwargs)
+
+ print(f"[Mesh loading] v: {mesh.v.shape}, f: {mesh.f.shape}")
+ # auto-normalize
+ if resize:
+ mesh.auto_size()
+ # auto-fix normal
+ if mesh.vn is None:
+ mesh.auto_normal()
+ print(f"[Mesh loading] vn: {mesh.vn.shape}, fn: {mesh.fn.shape}")
+ # auto-fix texture
+ if mesh.vt is None and auto_uv:
+ mesh.auto_uv(cache_path=path)
+ if mesh.vt is not None and mesh.ft is not None:
+ print(f"[Mesh loading] vt: {mesh.vt.shape}, ft: {mesh.ft.shape}")
+
+ if flip_yz:
+ mesh.v[..., [1, 2]] = mesh.v[..., [2, 1]]
+ mesh.vn[..., [1, 2]] = mesh.vn[..., [2, 1]]
+ mesh.v[..., 1] = -mesh.v[..., 1]
+ mesh.vn[..., 1] = -mesh.vn[..., 1]
+
+ return mesh
+
+ # load from obj file
+ @classmethod
+ def load_obj(cls, path, albedo_path=None, device=None):
+ assert os.path.splitext(path)[-1] == ".obj"
+
+ mesh = cls()
+
+ # device
+ if device is None:
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
+
+ mesh.device = device
+
+ # load obj
+ with open(path, "r") as f:
+ lines = f.readlines()
+
+ def parse_f_v(fv):
+ # pass in a vertex term of a face, return {v, vt, vn} (-1 if not provided)
+ # supported forms:
+ # f v1 v2 v3
+ # f v1/vt1 v2/vt2 v3/vt3
+ # f v1/vt1/vn1 v2/vt2/vn2 v3/vt3/vn3
+ # f v1//vn1 v2//vn2 v3//vn3
+ xs = [int(x) - 1 if x != "" else -1 for x in fv.split("/")]
+ xs.extend([-1] * (3 - len(xs)))
+ return xs[0], xs[1], xs[2]
+
+ # NOTE: we ignore usemtl, and assume the mesh ONLY uses one material (first in mtl)
+ vertices, texcoords, normals = [], [], []
+ faces, tfaces, nfaces = [], [], []
+ mtl_path = None
+
+ for line in lines:
+ split_line = line.split()
+ # empty line
+ if len(split_line) == 0:
+ continue
+ prefix = split_line[0].lower()
+ # mtllib
+ if prefix == "mtllib":
+ mtl_path = split_line[1]
+ # usemtl
+ elif prefix == "usemtl":
+ pass # ignored
+ # v/vn/vt
+ elif prefix == "v":
+ vertices.append([float(v) for v in split_line[1:]])
+ elif prefix == "vn":
+ normals.append([float(v) for v in split_line[1:]])
+ elif prefix == "vt":
+ val = [float(v) for v in split_line[1:]]
+ texcoords.append([val[0], 1.0 - val[1]])
+ elif prefix == "f":
+ vs = split_line[1:]
+ nv = len(vs)
+ v0, t0, n0 = parse_f_v(vs[0])
+ for i in range(nv - 2): # triangulate (assume vertices are ordered)
+ v1, t1, n1 = parse_f_v(vs[i + 1])
+ v2, t2, n2 = parse_f_v(vs[i + 2])
+ faces.append([v0, v1, v2])
+ tfaces.append([t0, t1, t2])
+ nfaces.append([n0, n1, n2])
+
+ mesh.v = torch.tensor(vertices, dtype=torch.float32, device=device)
+ mesh.vt = (
+ torch.tensor(texcoords, dtype=torch.float32, device=device)
+ if len(texcoords) > 0
+ else None
+ )
+ mesh.vn = (
+ torch.tensor(normals, dtype=torch.float32, device=device)
+ if len(normals) > 0
+ else None
+ )
+
+ mesh.f = torch.tensor(faces, dtype=torch.int32, device=device)
+ mesh.ft = (
+ torch.tensor(tfaces, dtype=torch.int32, device=device)
+ if len(texcoords) > 0
+ else None
+ )
+ mesh.fn = (
+ torch.tensor(nfaces, dtype=torch.int32, device=device)
+ if len(normals) > 0
+ else None
+ )
+
+ # see if there is vertex color
+ if mesh.v.size(-1) > 3:
+ mesh.vc = mesh.v[:, 3:]
+ mesh.v = mesh.v[:, :3]
+ if mesh.vc.size(-1) == 3:
+ mesh.vc = torch.cat([mesh.vc, torch.ones_like(mesh.vc[:, :1])], dim=-1)
+ print(f"[load_obj] use vertex color: {mesh.vc.shape}")
+
+ # try to retrieve mtl file
+ mtl_path_candidates = []
+ if mtl_path is not None:
+ mtl_path_candidates.append(mtl_path)
+ mtl_path_candidates.append(os.path.join(os.path.dirname(path), mtl_path))
+ mtl_path_candidates.append(path.replace(".obj", ".mtl"))
+
+ mtl_path = None
+ for candidate in mtl_path_candidates:
+ if os.path.exists(candidate):
+ mtl_path = candidate
+ break
+
+ # if albedo_path is not provided, try retrieve it from mtl
+ if mtl_path is not None and albedo_path is None:
+ with open(mtl_path, "r") as f:
+ lines = f.readlines()
+ for line in lines:
+ split_line = line.split()
+ # empty line
+ if len(split_line) == 0:
+ continue
+ prefix = split_line[0]
+ # NOTE: simply use the first map_Kd as albedo!
+ if "map_Kd" in prefix:
+ albedo_path = os.path.join(os.path.dirname(path), split_line[1])
+ print(f"[load_obj] use texture from: {albedo_path}")
+ break
+
+ # still not found albedo_path, or the path doesn't exist
+ if albedo_path is None or not os.path.exists(albedo_path):
+ # init an empty texture
+ print(f"[load_obj] init empty albedo!")
+ # albedo = np.random.rand(1024, 1024, 3).astype(np.float32)
+ albedo = np.ones((1024, 1024, 3), dtype=np.float32) * np.array([0.5, 0.5, 0.5]) # default color
+ mesh.textureless = True
+ else:
+ albedo = cv2.imread(albedo_path, cv2.IMREAD_UNCHANGED)
+ albedo = cv2.cvtColor(albedo, cv2.COLOR_BGR2RGB)
+ albedo = albedo.astype(np.float32) / 255
+ print(f"[load_obj] load texture: {albedo.shape}")
+
+ # import matplotlib.pyplot as plt
+ # plt.imshow(albedo)
+ # plt.show()
+
+ mesh.albedo = torch.tensor(albedo, dtype=torch.float32, device=device)
+
+ return mesh
+
+ @classmethod
+ def load_trimesh(cls, path, device=None):
+ mesh = cls()
+
+ # device
+ if device is None:
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
+
+ mesh.device = device
+
+ # use trimesh to load glb, assume only has one single RootMesh...
+ _data = trimesh.load(path)
+ if isinstance(_data, trimesh.Scene):
+ mesh_keys = list(_data.geometry.keys())
+ assert (
+ len(mesh_keys) == 1
+ ), f"{path} contains more than one meshes, not supported!"
+ _mesh = _data.geometry[mesh_keys[0]]
+
+ elif isinstance(_data, trimesh.Trimesh):
+ _mesh = _data
+
+ else:
+ raise NotImplementedError(f"type {type(_data)} not supported!")
+
+ if hasattr(_mesh.visual, "material"):
+ _material = _mesh.visual.material
+ if isinstance(_material, trimesh.visual.material.PBRMaterial):
+ texture = np.array(_material.baseColorTexture).astype(np.float32) / 255
+ elif isinstance(_material, trimesh.visual.material.SimpleMaterial):
+ texture = (
+ np.array(_material.to_pbr().baseColorTexture).astype(np.float32) / 255
+ )
+ else:
+ raise NotImplementedError(f"material type {type(_material)} not supported!")
+
+ print(f"[load_obj] load texture: {texture.shape}")
+ mesh.albedo = torch.tensor(texture, dtype=torch.float32, device=device)
+
+ if hasattr(_mesh.visual, "uv"):
+ texcoords = _mesh.visual.uv
+ texcoords[:, 1] = 1 - texcoords[:, 1]
+ mesh.vt = (
+ torch.tensor(texcoords, dtype=torch.float32, device=device)
+ if len(texcoords) > 0
+ else None
+ )
+ else:
+ texcoords = None
+
+ if hasattr(_mesh.visual, "vertex_colors"):
+ colors = _mesh.visual.vertex_colors
+ mesh.vc = (
+ torch.tensor(colors, dtype=torch.float32, device=device) / 255
+ if len(colors) > 0
+ else None
+ )
+
+ vertices = _mesh.vertices
+
+ normals = _mesh.vertex_normals
+
+ # trimesh only support vertex uv...
+ faces = tfaces = nfaces = _mesh.faces
+
+ mesh.v = torch.tensor(vertices, dtype=torch.float32, device=device)
+ mesh.vn = (
+ torch.tensor(normals, dtype=torch.float32, device=device)
+ if len(normals) > 0
+ else None
+ )
+
+ mesh.f = torch.tensor(faces, dtype=torch.int32, device=device)
+ mesh.ft = (
+ torch.tensor(tfaces, dtype=torch.int32, device=device)
+ if texcoords is not None
+ else None
+ )
+ mesh.fn = (
+ torch.tensor(nfaces, dtype=torch.int32, device=device)
+ if normals is not None
+ else None
+ )
+
+ return mesh
+
+ # aabb
+ def aabb(self):
+ return torch.min(self.v, dim=0).values, torch.max(self.v, dim=0).values
+
+ # unit size
+ @torch.no_grad()
+ def auto_size(self):
+ vmin, vmax = self.aabb()
+ self.ori_center = (vmax + vmin) / 2
+ self.ori_scale = 1.2 / torch.max(vmax - vmin).item() # to ~ [-0.6, 0.6]
+ self.v = (self.v - self.ori_center) * self.ori_scale
+
+ def auto_normal(self):
+ i0, i1, i2 = self.f[:, 0].long(), self.f[:, 1].long(), self.f[:, 2].long()
+ v0, v1, v2 = self.v[i0, :], self.v[i1, :], self.v[i2, :]
+
+ face_normals = torch.cross(v1 - v0, v2 - v0)
+
+ # Splat face normals to vertices
+ face_normals = F.normalize(face_normals, dim=-1)
+ vn = torch.zeros_like(self.v)
+ vn.scatter_add_(0, i0[:, None].repeat(1, 3), face_normals)
+ vn.scatter_add_(0, i1[:, None].repeat(1, 3), face_normals)
+ vn.scatter_add_(0, i2[:, None].repeat(1, 3), face_normals)
+ vn = F.normalize(vn, dim=-1)
+
+ self.vn = vn
+ self.fn = self.f
+ self.face_normals = face_normals
+
+ def auto_uv(self, cache_path=None, vmap=True):
+ # try to load cache
+ if cache_path is not None:
+ cache_path = os.path.splitext(cache_path)[0] + '_uv.npz'
+
+ if cache_path is not None and os.path.exists(cache_path):
+ data = np.load(cache_path)
+ vt_np, ft_np, vmapping = data['vt'], data['ft'], data['vmapping']
+ else:
+ v_np = self.v.detach().cpu().numpy()
+ f_np = self.f.detach().int().cpu().numpy()
+ atlas = xatlas.Atlas()
+ atlas.add_mesh(v_np, f_np)
+ chart_options = xatlas.ChartOptions()
+ # chart_options.max_iterations = 4
+ atlas.generate(chart_options=chart_options)
+ vmapping, ft_np, vt_np = atlas[0] # [N], [M, 3], [N, 2]
+
+ # save to cache
+ if cache_path is not None:
+ np.savez(cache_path, vt=vt_np, ft=ft_np, vmapping=vmapping)
+
+ vt = torch.from_numpy(vt_np.astype(np.float32)).to(self.device)
+ ft = torch.from_numpy(ft_np.astype(np.int32)).to(self.device)
+ self.vt = vt
+ self.ft = ft
+
+ if vmap:
+ # remap v/f to vt/ft, so each v correspond to a unique vt. (necessary for gltf)
+ vmapping = torch.from_numpy(vmapping.astype(np.int64)).long().to(self.device)
+ self.align_v_to_vt(vmapping)
+
+ def align_v_to_vt(self, vmapping=None):
+ # remap v/f and vn/vn to vt/ft.
+ if vmapping is None:
+ ft = self.ft.view(-1).long()
+ f = self.f.view(-1).long()
+ vmapping = torch.zeros(self.vt.shape[0], dtype=torch.long, device=self.device)
+ vmapping[ft] = f # scatter, randomly choose one if index is not unique
+ if self.vn is not None and (self.f == self.fn).all():
+ self.vn = self.vn[vmapping]
+ self.fn = self.ft
+ self.v = self.v[vmapping]
+ self.f = self.ft
+
+ def align_vn_to_vt(self, vmapping=None):
+ if vmapping is None:
+ ft = self.ft.view(-1).long()
+ fn = self.f.view(-1).long()
+ vmapping = torch.zeros(self.vt.shape[0], dtype=torch.long, device=self.device)
+ vmapping[ft] = fn # scatter, randomly choose one if index is not unique
+ self.vn = self.vn[vmapping]
+ self.fn = self.ft
+
+ def to(self, device):
+ self.device = device
+ for name in ['v', 'f', 'vn', 'fn', 'vt', 'ft', 'albedo', 'vc', 'face_normals']:
+ tensor = getattr(self, name)
+ if tensor is not None:
+ setattr(self, name, tensor.to(device))
+ return self
+
+ def copy(self):
+ return Mesh(
+ v=self.v,
+ f=self.f,
+ vn=self.vn,
+ fn=self.fn,
+ vt=self.vt,
+ ft=self.ft,
+ vc=self.vc,
+ albedo=self.albedo,
+ device=self.device,
+ textureless=self.textureless)
+
+ def write(self, path, flip_yz=False):
+ mesh = self.copy()
+ if flip_yz:
+ mesh.v = mesh.v.clone()
+ mesh.vn = mesh.vn.clone()
+ mesh.v[..., 1] = -mesh.v[..., 1]
+ mesh.vn[..., 1] = -mesh.vn[..., 1]
+ mesh.v[..., [1, 2]] = mesh.v[..., [2, 1]]
+ mesh.vn[..., [1, 2]] = mesh.vn[..., [2, 1]]
+ if path.endswith('.ply'):
+ mesh.write_ply(path)
+ elif path.endswith('.obj'):
+ mesh.write_obj(path)
+ elif path.endswith('.glb') or path.endswith('.gltf'):
+ mesh.write_glb(path)
+ else:
+ raise NotImplementedError(f'format {path} not supported!')
+
+ # write to ply file (only geom)
+ def write_ply(self, path):
+
+ v_np = self.v.detach().cpu().numpy()
+ f_np = self.f.detach().cpu().numpy()
+
+ _mesh = trimesh.Trimesh(vertices=v_np, faces=f_np)
+ _mesh.export(path)
+
+ # write to gltf/glb file (geom + texture)
+ def write_glb(self, path):
+
+ assert self.vn is not None
+ if self.vt is None:
+ self.vt = self.v.new_zeros((self.v.size(0), 2))
+ self.ft = self.f
+ if (self.f != self.ft).any():
+ self.align_v_to_vt()
+ if (self.fn != self.ft).any():
+ self.align_vn_to_vt()
+
+ assert self.v.shape[0] == self.vn.shape[0] and self.v.shape[0] == self.vt.shape[0]
+
+ f_np = self.f.detach().cpu().numpy().astype(np.uint32)
+ v_np = self.v.detach().cpu().numpy().astype(np.float32)
+ vt_np = self.vt.detach().cpu().numpy().astype(np.float32)
+ vn_np = self.vn.detach().cpu().numpy().astype(np.float32)
+
+ albedo = self.albedo.detach().cpu().numpy() if self.albedo is not None \
+ else np.full((1024, 1024, 3), 0.5, dtype=np.float32)
+ albedo = (albedo * 255).astype(np.uint8)
+ albedo = cv2.cvtColor(albedo, cv2.COLOR_RGB2BGR)
+
+ f_np_blob = f_np.flatten().tobytes()
+ v_np_blob = v_np.tobytes()
+ vt_np_blob = vt_np.tobytes()
+ vn_np_blob = vn_np.tobytes()
+ albedo_blob = cv2.imencode('.png', albedo)[1].tobytes()
+
+ gltf = pygltflib.GLTF2(
+ scene=0,
+ scenes=[pygltflib.Scene(nodes=[0])],
+ nodes=[pygltflib.Node(mesh=0)],
+ meshes=[pygltflib.Mesh(primitives=[
+ pygltflib.Primitive(
+ # indices to accessors (0 is triangles)
+ attributes=pygltflib.Attributes(
+ POSITION=1, TEXCOORD_0=2, NORMAL=3
+ ),
+ indices=0, material=0,
+ )
+ ])],
+ materials=[
+ pygltflib.Material(
+ pbrMetallicRoughness=pygltflib.PbrMetallicRoughness(
+ baseColorTexture=pygltflib.TextureInfo(index=0, texCoord=0),
+ metallicFactor=0.0,
+ roughnessFactor=1.0,
+ ),
+ alphaCutoff=0,
+ doubleSided=True,
+ )
+ ],
+ textures=[
+ pygltflib.Texture(sampler=0, source=0),
+ ],
+ samplers=[
+ pygltflib.Sampler(magFilter=pygltflib.LINEAR, minFilter=pygltflib.LINEAR_MIPMAP_LINEAR,
+ wrapS=pygltflib.REPEAT, wrapT=pygltflib.REPEAT),
+ ],
+ images=[
+ # use embedded (buffer) image
+ pygltflib.Image(bufferView=4, mimeType="image/png"),
+ ],
+ buffers=[
+ pygltflib.Buffer(
+ byteLength=len(f_np_blob) + len(v_np_blob) + len(vt_np_blob) + len(vn_np_blob) + len(albedo_blob))
+ ],
+ # buffer view (based on dtype)
+ bufferViews=[
+ # triangles; as flatten (element) array
+ pygltflib.BufferView(
+ buffer=0,
+ byteLength=len(f_np_blob),
+ target=pygltflib.ELEMENT_ARRAY_BUFFER, # GL_ELEMENT_ARRAY_BUFFER (34963)
+ ),
+ # positions; as vec3 array
+ pygltflib.BufferView(
+ buffer=0,
+ byteOffset=len(f_np_blob),
+ byteLength=len(v_np_blob),
+ byteStride=12, # vec3
+ target=pygltflib.ARRAY_BUFFER, # GL_ARRAY_BUFFER (34962)
+ ),
+ # texcoords; as vec2 array
+ pygltflib.BufferView(
+ buffer=0,
+ byteOffset=len(f_np_blob) + len(v_np_blob),
+ byteLength=len(vt_np_blob),
+ byteStride=8, # vec2
+ target=pygltflib.ARRAY_BUFFER,
+ ),
+ # normals; as vec3 array
+ pygltflib.BufferView(
+ buffer=0,
+ byteOffset=len(f_np_blob) + len(v_np_blob) + len(vt_np_blob),
+ byteLength=len(vn_np_blob),
+ byteStride=12, # vec3
+ target=pygltflib.ARRAY_BUFFER,
+ ),
+ # texture; as none target
+ pygltflib.BufferView(
+ buffer=0,
+ byteOffset=len(f_np_blob) + len(v_np_blob) + len(vt_np_blob) + len(vn_np_blob),
+ byteLength=len(albedo_blob),
+ ),
+ ],
+ accessors=[
+ # 0 = triangles
+ pygltflib.Accessor(
+ bufferView=0,
+ componentType=pygltflib.UNSIGNED_INT, # GL_UNSIGNED_INT (5125)
+ count=f_np.size,
+ type=pygltflib.SCALAR,
+ max=[int(f_np.max())],
+ min=[int(f_np.min())],
+ ),
+ # 1 = positions
+ pygltflib.Accessor(
+ bufferView=1,
+ componentType=pygltflib.FLOAT, # GL_FLOAT (5126)
+ count=len(v_np),
+ type=pygltflib.VEC3,
+ max=v_np.max(axis=0).tolist(),
+ min=v_np.min(axis=0).tolist(),
+ ),
+ # 2 = texcoords
+ pygltflib.Accessor(
+ bufferView=2,
+ componentType=pygltflib.FLOAT,
+ count=len(vt_np),
+ type=pygltflib.VEC2,
+ max=vt_np.max(axis=0).tolist(),
+ min=vt_np.min(axis=0).tolist(),
+ ),
+ # 3 = normals
+ pygltflib.Accessor(
+ bufferView=3,
+ componentType=pygltflib.FLOAT,
+ count=len(vn_np),
+ type=pygltflib.VEC3,
+ max=vn_np.max(axis=0).tolist(),
+ min=vn_np.min(axis=0).tolist(),
+ ),
+ ],
+ )
+
+ # set actual data
+ gltf.set_binary_blob(f_np_blob + v_np_blob + vt_np_blob + vn_np_blob + albedo_blob)
+
+ # glb = b"".join(gltf.save_to_bytes())
+ gltf.save(path)
+
+ # write to obj file (geom + texture)
+ def write_obj(self, path):
+
+ mtl_path = path.replace(".obj", ".mtl")
+ albedo_path = path.replace(".obj", "_albedo.png")
+
+ v_np = self.v.detach().cpu().numpy()
+ vt_np = self.vt.detach().cpu().numpy() if self.vt is not None else None
+ vn_np = self.vn.detach().cpu().numpy() if self.vn is not None else None
+ f_np = self.f.detach().cpu().numpy()
+ ft_np = self.ft.detach().cpu().numpy() if self.ft is not None else None
+ fn_np = self.fn.detach().cpu().numpy() if self.fn is not None else None
+
+ with open(path, "w") as fp:
+ fp.write(f"mtllib {os.path.basename(mtl_path)} \n")
+
+ for v in v_np:
+ fp.write(f"v {v[0]:.6f} {v[1]:.6f} {v[2]:.6f} \n")
+
+ if vt_np is not None:
+ for v in vt_np:
+ fp.write(f"vt {v[0]:.4f} {1 - v[1]:.4f} \n")
+
+ if vn_np is not None:
+ for v in vn_np:
+ fp.write(f"vn {v[0]:.4f} {v[1]:.4f} {v[2]:.4f} \n")
+
+ fp.write(f"usemtl defaultMat \n")
+ for i in range(len(f_np)):
+ fp.write(
+ f'f {f_np[i, 0] + 1}/{ft_np[i, 0] + 1 if ft_np is not None else ""}/{fn_np[i, 0] + 1 if fn_np is not None else ""} \
+ {f_np[i, 1] + 1}/{ft_np[i, 1] + 1 if ft_np is not None else ""}/{fn_np[i, 1] + 1 if fn_np is not None else ""} \
+ {f_np[i, 2] + 1}/{ft_np[i, 2] + 1 if ft_np is not None else ""}/{fn_np[i, 2] + 1 if fn_np is not None else ""} \n'
+ )
+
+ with open(mtl_path, "w") as fp:
+ fp.write(f"newmtl defaultMat \n")
+ fp.write(f"Ka 1 1 1 \n")
+ fp.write(f"Kd 1 1 1 \n")
+ fp.write(f"Ks 0 0 0 \n")
+ fp.write(f"Tr 1 \n")
+ fp.write(f"illum 1 \n")
+ fp.write(f"Ns 0 \n")
+ if not self.textureless and self.albedo is not None:
+ fp.write(f"map_Kd {os.path.basename(albedo_path)} \n")
+
+ if not self.textureless and self.albedo is not None:
+ albedo = self.albedo.detach().cpu().numpy()
+ albedo = (albedo * 255).astype(np.uint8)
+ cv2.imwrite(albedo_path, cv2.cvtColor(albedo, cv2.COLOR_RGB2BGR))
+
+
+def normalize_mesh(mesh, tgt_radius=0.9):
+ mb = miniball.Miniball(mesh.v[:, :2].cpu().numpy())
+ center_xy = mb.center()
+ radius_xy_sq = mb.squared_radius()
+ max_z = mesh.v[:, 2].max().item()
+ min_z = mesh.v[:, 2].min().item()
+ center = mesh.v.new_tensor([center_xy[0], center_xy[1], (max_z + min_z) / 2])
+ radius = max(math.sqrt(radius_xy_sq), (max_z - min_z) / 2)
+ scale = tgt_radius / radius
+ mesh.v = (mesh.v - center) * scale
+ return mesh, center.tolist(), scale
+
+
+def check_has_texture_single(geom):
+ return isinstance(geom.visual, TextureVisuals) and geom.visual.material.baseColorTexture is not None
+
+
+def check_has_texture(mesh):
+ if isinstance(mesh, trimesh.Scene):
+ has_texture = []
+ for geom in mesh.geometry.values():
+ has_texture.append(check_has_texture_single(geom))
+ elif isinstance(mesh, trimesh.Trimesh):
+ has_texture = check_has_texture_single(mesh)
+ else:
+ raise NotImplementedError(f"type {type(mesh)} not supported!")
+ return has_texture
+
+
+def create_texture(geom):
+ if hasattr(geom.visual, 'material') and hasattr(geom.visual.material, 'main_color'):
+ main_color = tuple(geom.visual.material.main_color)
+ else:
+ main_color = (128, 128, 128)
+ geom.visual = trimesh.visual.TextureVisuals(
+ uv=np.full((geom.vertices.shape[0], 2), 0.5),
+ material=trimesh.visual.material.PBRMaterial(
+ baseColorTexture=Image.new('RGB', (8, 8), main_color)
+ )
+ )
+
+
+def color_to_texture(mesh):
+ if isinstance(mesh, trimesh.Scene):
+ for geom in mesh.geometry.values():
+ if not check_has_texture_single(geom):
+ create_texture(geom)
+ elif isinstance(mesh, trimesh.Trimesh):
+ if not check_has_texture_single(mesh):
+ create_texture(mesh)
+ else:
+ raise NotImplementedError(f"type {type(mesh)} not supported!")
+ return mesh
+
+
+def purge_scene(scene):
+ update_flag = False
+ delete_list = []
+ for name, geom in scene.geometry.items():
+ if not isinstance(geom, trimesh.Trimesh):
+ update_flag = True
+ delete_list.append(name)
+ for name in delete_list:
+ scene.delete_geometry(name)
+ return update_flag
diff --git a/freesplatter/utils/mesh_renderer.py b/freesplatter/utils/mesh_renderer.py
new file mode 100644
index 0000000000000000000000000000000000000000..d977bd4a39d809bc3ed3180b7fc4ff9385249b38
--- /dev/null
+++ b/freesplatter/utils/mesh_renderer.py
@@ -0,0 +1,607 @@
+import math
+import torch
+import torch.nn as nn
+import torch.nn.functional as F
+import nvdiffrast.torch as dr
+
+
+def get_ray_directions(h, w, intrinsics, norm=False, device=None):
+ """
+ Args:
+ h (int)
+ w (int)
+ intrinsics: (*, 4), in [fx, fy, cx, cy]
+
+ Returns:
+ directions: (*, h, w, 3), the direction of the rays in camera coordinate
+ """
+ batch_size = intrinsics.shape[:-1]
+ x = torch.linspace(0.5, w - 0.5, w, device=device)
+ y = torch.linspace(0.5, h - 0.5, h, device=device)
+ # (*, h, w, 2)
+ directions_xy = torch.stack(
+ [((x - intrinsics[..., 2:3]) / intrinsics[..., 0:1])[..., None, :].expand(*batch_size, h, w),
+ ((y - intrinsics[..., 3:4]) / intrinsics[..., 1:2])[..., :, None].expand(*batch_size, h, w)], dim=-1)
+ # (*, h, w, 3)
+ directions = F.pad(directions_xy, [0, 1], mode='constant', value=1.0)
+ if norm:
+ directions = F.normalize(directions, dim=-1)
+ return directions
+
+
+def edge_dilation(img, mask, radius=3, iter=7):
+ """
+ Args:
+ img (torch.Tensor): (n, c, h, w)
+ mask (torch.Tensor): (n, 1, h, w)
+ radius (float): Radius of dilation.
+
+ Returns:
+ torch.Tensor: Dilated image.
+ """
+ n, c, h, w = img.size()
+ int_radius = round(radius)
+ kernel_size = int(int_radius * 2 + 1)
+ distance1d_sq = torch.linspace(-int_radius, int_radius, kernel_size, dtype=img.dtype, device=img.device).square()
+ kernel_distance = (distance1d_sq.reshape(1, -1) + distance1d_sq.reshape(-1, 1)).sqrt()
+ kernel_neg_distance = kernel_distance.max() - kernel_distance + 1
+
+ for _ in range(iter):
+
+ mask_out = F.max_pool2d(mask, kernel_size, stride=1, padding=int_radius)
+ do_fill_mask = ((mask_out - mask) > 0.5).squeeze(1)
+ # (num_fill, 3) in [ind_n, ind_h, ind_w]
+ do_fill = do_fill_mask.nonzero()
+
+ # unfold the image and mask
+ mask_unfold = F.unfold(mask, kernel_size, padding=int_radius).reshape(
+ n, kernel_size * kernel_size, h, w).permute(0, 2, 3, 1)
+
+ fill_ind = (mask_unfold[do_fill_mask] * kernel_neg_distance.flatten()).argmax(dim=-1)
+ do_fill_h = do_fill[:, 1] + fill_ind // kernel_size - int_radius
+ do_fill_w = do_fill[:, 2] + fill_ind % kernel_size - int_radius
+
+ img_out = img.clone()
+ img_out[do_fill[:, 0], :, do_fill[:, 1], do_fill[:, 2]] = img[
+ do_fill[:, 0], :, do_fill_h, do_fill_w]
+
+ img = img_out
+ mask = mask_out
+
+ return img
+
+
+def depth_to_normal(depth, directions, format='opengl'):
+ """
+ Args:
+ depth: shape (*, h, w), inverse depth defined as 1 / z
+ directions: shape (*, h, w, 3), unnormalized ray directions, under OpenCV coordinate system
+
+ Returns:
+ out_normal: shape (*, h, w, 3), in range [0, 1]
+ """
+ out_xyz = directions / depth.unsqueeze(-1).clamp(min=1e-6)
+ dx = out_xyz[..., :, 1:, :] - out_xyz[..., :, :-1, :]
+ dy = out_xyz[..., 1:, :, :] - out_xyz[..., :-1, :, :]
+ right = F.pad(dx, (0, 0, 0, 1, 0, 0), mode='replicate')
+ up = F.pad(-dy, (0, 0, 0, 0, 1, 0), mode='replicate')
+ left = F.pad(-dx, (0, 0, 1, 0, 0, 0), mode='replicate')
+ down = F.pad(dy, (0, 0, 0, 0, 0, 1), mode='replicate')
+ out_normal = F.normalize(
+ F.normalize(torch.cross(right, up, dim=-1), dim=-1)
+ + F.normalize(torch.cross(up, left, dim=-1), dim=-1)
+ + F.normalize(torch.cross(left, down, dim=-1), dim=-1)
+ + F.normalize(torch.cross(down, right, dim=-1), dim=-1),
+ dim=-1)
+ if format == 'opengl':
+ out_normal[..., 1:3] = -out_normal[..., 1:3] # to opengl coord
+ elif format == 'opencv':
+ out_normal = out_normal
+ else:
+ raise ValueError('format should be opengl or opencv')
+ out_normal = out_normal / 2 + 0.5
+ return out_normal
+
+
+def make_divisible(x, m=8):
+ return int(math.ceil(x / m) * m)
+
+
+def interpolate_hwc(x, scale_factor, mode='area'):
+ batch_dim = x.shape[:-3]
+ y = x.reshape(batch_dim.numel(), *x.shape[-3:]).permute(0, 3, 1, 2)
+ y = F.interpolate(y, scale_factor=scale_factor, mode=mode).permute(0, 2, 3, 1)
+ return y.reshape(*batch_dim, *y.shape[1:])
+
+
+def compute_edge_to_face_mapping(attr_idx):
+ with torch.no_grad():
+ # Get unique edges
+ # Create all edges, packed by triangle
+ all_edges = torch.cat((
+ torch.stack((attr_idx[:, 0], attr_idx[:, 1]), dim=-1),
+ torch.stack((attr_idx[:, 1], attr_idx[:, 2]), dim=-1),
+ torch.stack((attr_idx[:, 2], attr_idx[:, 0]), dim=-1),
+ ), dim=-1).view(-1, 2)
+
+ # Swap edge order so min index is always first
+ order = (all_edges[:, 0] > all_edges[:, 1]).long().unsqueeze(dim=1)
+ sorted_edges = torch.cat((
+ torch.gather(all_edges, 1, order),
+ torch.gather(all_edges, 1, 1 - order)
+ ), dim=-1)
+
+ # Elliminate duplicates and return inverse mapping
+ unique_edges, idx_map = torch.unique(sorted_edges, dim=0, return_inverse=True)
+
+ tris = torch.arange(attr_idx.shape[0]).repeat_interleave(3).cuda()
+
+ tris_per_edge = torch.zeros((unique_edges.shape[0], 2), dtype=torch.int64).cuda()
+
+ # Compute edge to face table
+ mask0 = order[:,0] == 0
+ mask1 = order[:,0] == 1
+ tris_per_edge[idx_map[mask0], 0] = tris[mask0]
+ tris_per_edge[idx_map[mask1], 1] = tris[mask1]
+
+ return tris_per_edge
+
+
+@torch.cuda.amp.autocast(enabled=False)
+def normal_consistency(face_normals, t_pos_idx):
+
+ tris_per_edge = compute_edge_to_face_mapping(t_pos_idx)
+
+ # Fetch normals for both faces sharind an edge
+ n0 = face_normals[tris_per_edge[:, 0], :]
+ n1 = face_normals[tris_per_edge[:, 1], :]
+
+ # Compute error metric based on normal difference
+ term = torch.clamp(torch.sum(n0 * n1, -1, keepdim=True), min=-1.0, max=1.0)
+ term = (1.0 - term)
+
+ return torch.mean(torch.abs(term))
+
+
+def laplacian_uniform(verts, faces):
+
+ V = verts.shape[0]
+ F = faces.shape[0]
+
+ # Neighbor indices
+ ii = faces[:, [1, 2, 0]].flatten()
+ jj = faces[:, [2, 0, 1]].flatten()
+ adj = torch.stack([torch.cat([ii, jj]), torch.cat([jj, ii])], dim=0).unique(dim=1)
+ adj_values = torch.ones(adj.shape[1], device=verts.device, dtype=torch.float)
+
+ # Diagonal indices
+ diag_idx = adj[0]
+
+ # Build the sparse matrix
+ idx = torch.cat((adj, torch.stack((diag_idx, diag_idx), dim=0)), dim=1)
+ values = torch.cat((-adj_values, adj_values))
+
+ # The coalesce operation sums the duplicate indices, resulting in the
+ # correct diagonal
+ return torch.sparse_coo_tensor(idx, values, (V,V)).coalesce()
+
+
+@torch.cuda.amp.autocast(enabled=False)
+def laplacian_smooth_loss(verts, faces):
+ with torch.no_grad():
+ L = laplacian_uniform(verts, faces.long())
+ loss = L.mm(verts)
+ loss = loss.norm(dim=1)
+ loss = loss.mean()
+ return loss
+
+
+class DMTet:
+
+ def __init__(self, device):
+ self.device = device
+ self.triangle_table = torch.tensor([
+ [-1, -1, -1, -1, -1, -1],
+ [1, 0, 2, -1, -1, -1],
+ [4, 0, 3, -1, -1, -1],
+ [1, 4, 2, 1, 3, 4],
+ [3, 1, 5, -1, -1, -1],
+ [2, 3, 0, 2, 5, 3],
+ [1, 4, 0, 1, 5, 4],
+ [4, 2, 5, -1, -1, -1],
+ [4, 5, 2, -1, -1, -1],
+ [4, 1, 0, 4, 5, 1],
+ [3, 2, 0, 3, 5, 2],
+ [1, 3, 5, -1, -1, -1],
+ [4, 1, 2, 4, 3, 1],
+ [3, 0, 4, -1, -1, -1],
+ [2, 0, 1, -1, -1, -1],
+ [-1, -1, -1, -1, -1, -1]
+ ], dtype=torch.long, device=device)
+ self.num_triangles_table = torch.tensor([0, 1, 1, 2, 1, 2, 2, 1, 1, 2, 2, 1, 2, 1, 1, 0], dtype=torch.long,
+ device=device)
+ self.base_tet_edges = torch.tensor([0, 1, 0, 2, 0, 3, 1, 2, 1, 3, 2, 3], dtype=torch.long, device=device)
+
+ def sort_edges(self, edges_ex2):
+ with torch.no_grad():
+ order = (edges_ex2[:, 0] > edges_ex2[:, 1]).long()
+ order = order.unsqueeze(dim=1)
+
+ a = torch.gather(input=edges_ex2, index=order, dim=1)
+ b = torch.gather(input=edges_ex2, index=1 - order, dim=1)
+
+ return torch.stack([a, b], -1)
+
+ def __call__(self, pos_nx3, sdf_n, tet_fx4):
+ # pos_nx3: [N, 3]
+ # sdf_n: [N]
+ # tet_fx4: [F, 4]
+
+ with torch.no_grad():
+ occ_n = sdf_n > 0
+ occ_fx4 = occ_n[tet_fx4.reshape(-1)].reshape(-1, 4)
+ occ_sum = torch.sum(occ_fx4, -1) # [F,]
+ valid_tets = (occ_sum > 0) & (occ_sum < 4)
+ # occ_sum = occ_sum[valid_tets]
+
+ # find all vertices
+ all_edges = tet_fx4[valid_tets][:, self.base_tet_edges].reshape(-1, 2)
+ all_edges = self.sort_edges(all_edges)
+ unique_edges, idx_map = torch.unique(all_edges, dim=0, return_inverse=True)
+
+ unique_edges = unique_edges.long()
+ mask_edges = occ_n[unique_edges.reshape(-1)].reshape(-1, 2).sum(-1) == 1
+ mapping = torch.ones((unique_edges.shape[0]), dtype=torch.long, device=self.device) * -1
+ mapping[mask_edges] = torch.arange(mask_edges.sum(), dtype=torch.long, device=self.device)
+ idx_map = mapping[idx_map] # map edges to verts
+
+ interp_v = unique_edges[mask_edges]
+
+ edges_to_interp = pos_nx3[interp_v.reshape(-1)].reshape(-1, 2, 3)
+ edges_to_interp_sdf = sdf_n[interp_v.reshape(-1)].reshape(-1, 2, 1)
+ edges_to_interp_sdf[:, -1] *= -1
+
+ denominator = edges_to_interp_sdf.sum(1, keepdim=True)
+
+ edges_to_interp_sdf = torch.flip(edges_to_interp_sdf, [1]) / denominator
+ verts = (edges_to_interp * edges_to_interp_sdf).sum(1)
+
+ idx_map = idx_map.reshape(-1, 6)
+
+ v_id = torch.pow(2, torch.arange(4, dtype=torch.long, device=self.device))
+ tetindex = (occ_fx4[valid_tets] * v_id.unsqueeze(0)).sum(-1)
+ num_triangles = self.num_triangles_table[tetindex]
+
+ # Generate triangle indices
+ faces = torch.cat((
+ torch.gather(input=idx_map[num_triangles == 1], dim=1,
+ index=self.triangle_table[tetindex[num_triangles == 1]][:, :3]).reshape(-1, 3),
+ torch.gather(input=idx_map[num_triangles == 2], dim=1,
+ index=self.triangle_table[tetindex[num_triangles == 2]][:, :6]).reshape(-1, 3),
+ ), dim=0)
+
+ return verts, faces
+
+
+class MeshRenderer(nn.Module):
+ def __init__(self,
+ near=0.1,
+ far=10,
+ ssaa=1,
+ texture_filter='linear-mipmap-linear',
+ opengl=False):
+ super().__init__()
+ self.near = near
+ self.far = far
+ assert isinstance(ssaa, int) and ssaa >= 1
+ self.ssaa = ssaa
+ self.texture_filter = texture_filter
+ self.glctx = dr.RasterizeGLContext() if opengl else dr.RasterizeCudaContext()
+
+ def forward(self, meshes, poses, intrinsics, h, w, shading_fun=None,
+ dilate_edges=0, normal_bg=[0.5, 0.5, 1.0], aa=True, render_vc=False):
+ """
+ Args:
+ meshes (list[Mesh]): list of Mesh objects
+ poses: Shape (num_scenes, num_images, 3, 4)
+ intrinsics: Shape (num_scenes, num_images, 4) in [fx, fy, cx, cy]
+ """
+ num_scenes, num_images, _, _ = poses.size()
+
+ if self.ssaa > 1:
+ h = h * self.ssaa
+ w = w * self.ssaa
+ intrinsics = intrinsics * self.ssaa
+
+ r_mat_c2w = torch.cat(
+ [poses[..., :3, :1], -poses[..., :3, 1:3]], dim=-1) # opencv to opengl conversion
+
+ proj = poses.new_zeros([num_scenes, num_images, 4, 4])
+ proj[..., 0, 0] = 2 * intrinsics[..., 0] / w
+ proj[..., 0, 2] = -2 * intrinsics[..., 2] / w + 1
+ proj[..., 1, 1] = -2 * intrinsics[..., 1] / h
+ proj[..., 1, 2] = -2 * intrinsics[..., 3] / h + 1
+ proj[..., 2, 2] = -(self.far + self.near) / (self.far - self.near)
+ proj[..., 2, 3] = -(2 * self.far * self.near) / (self.far - self.near)
+ proj[..., 3, 2] = -1
+
+ # (num_scenes, (num_images, num_vertices, 3))
+ v_cam = [(mesh.v - poses[i, :, :3, 3].unsqueeze(-2)) @ r_mat_c2w[i] for i, mesh in enumerate(meshes)]
+ # (num_scenes, (num_images, num_vertices, 4))
+ v_clip = [F.pad(v, pad=(0, 1), mode='constant', value=1.0) @ proj[i].transpose(-1, -2) for i, v in enumerate(v_cam)]
+
+ if num_scenes == 1:
+ # (num_images, h, w, 4) in [u, v, z/w, triangle_id] & (num_images, h, w, 4 or 0)
+ rast, rast_db = dr.rasterize(
+ self.glctx, v_clip[0], meshes[0].f, (h, w), grad_db=torch.is_grad_enabled())
+
+ fg = (rast[..., 3] > 0).unsqueeze(0) # (num_scenes, num_images, h, w)
+ alpha = fg.float().unsqueeze(-1)
+
+ depth = 1 / dr.interpolate(
+ -v_cam[0][..., 2:3].contiguous(), rast, meshes[0].f)[0].reshape(num_scenes, num_images, h, w)
+ depth.masked_fill_(~fg, 0)
+
+ normal = dr.interpolate(
+ meshes[0].vn.unsqueeze(0).contiguous(), rast, meshes[0].fn)[0].reshape(num_scenes, num_images, h, w, 3)
+ normal = F.normalize(normal, dim=-1)
+ # (num_scenes, num_images, h, w, 3) = (num_scenes, num_images, h, w, 3) @ (num_scenes, num_images, 1, 3, 3)
+ rot_normal = (normal @ r_mat_c2w.unsqueeze(2)) / 2 + 0.5
+ rot_normal[~fg] = rot_normal.new_tensor(normal_bg)
+
+ if meshes[0].vt is not None and meshes[0].albedo is not None:
+ # (num_images, h, w, 2) & (num_images, h, w, 4)
+ texc, texc_db = dr.interpolate(
+ meshes[0].vt.unsqueeze(0).contiguous(), rast, meshes[0].ft, rast_db=rast_db, diff_attrs='all')
+ # (num_scenes, num_images, h, w, 3)
+ albedo = dr.texture(
+ meshes[0].albedo.unsqueeze(0)[..., :3].contiguous(), texc, uv_da=texc_db, filter_mode=self.texture_filter).unsqueeze(0)
+ albedo[~fg] = 0
+ elif meshes[0].vc is not None:
+ rgba = dr.interpolate(
+ meshes[0].vc.contiguous(), rast, meshes[0].f)[0].reshape(num_scenes, num_images, h, w, 4)
+ alpha = alpha * rgba[..., 3:4]
+ albedo = rgba[..., :3] * alpha
+ else:
+ albedo = torch.zeros_like(rot_normal)
+
+ prev_grad_enabled = torch.is_grad_enabled()
+ torch.set_grad_enabled(True)
+ if shading_fun is not None:
+ xyz = dr.interpolate(
+ meshes[0].v.unsqueeze(0).contiguous(), rast, meshes[0].f)[0].reshape(num_scenes, num_images, h, w, 3)
+ rgb_reshade = shading_fun(
+ world_pos=xyz[fg],
+ albedo=albedo[fg],
+ world_normal=normal[fg],
+ fg_mask=fg)
+ albedo = torch.zeros_like(albedo)
+ albedo[fg] = rgb_reshade
+
+ # (num_scenes, num_images, h, w, 4)
+ rgba = torch.cat([albedo, alpha], dim=-1)
+
+ if dilate_edges > 0:
+ rgba = rgba.reshape(num_scenes * num_images, h, w, 4).permute(0, 3, 1, 2)
+ rgba = edge_dilation(rgba, rgba[:, 3:], dilate_edges)
+ rgba = rgba.permute(0, 2, 3, 1).reshape(num_scenes, num_images, h, w, 4)
+
+ if aa:
+ rgba, depth, rot_normal = dr.antialias(
+ torch.cat([rgba, depth.unsqueeze(-1), rot_normal], dim=-1).squeeze(0),
+ rast, v_clip[0], meshes[0].f).unsqueeze(0).split([4, 1, 3], dim=-1)
+ depth = depth.squeeze(-1)
+
+ else: # concat and range mode
+ # v_cat = []
+ v_clip_cat = []
+ v_cam_cat = []
+ vn_cat = []
+ vt_cat = []
+ f_cat = []
+ fn_cat = []
+ ft_cat = []
+ v_count = 0
+ vn_count = 0
+ vt_count = 0
+ f_count = 0
+ f_ranges = []
+ for i, mesh in enumerate(meshes):
+ num_v = v_clip[i].size(1)
+ num_vn = mesh.vn.size(0)
+ num_vt = mesh.vt.size(0)
+ # v_cat.append(mesh.v.unsqueeze(0).expand(num_images, -1, -1).reshape(num_images * num_v, 3))
+ v_clip_cat.append(v_clip[i].reshape(num_images * num_v, 4))
+ v_cam_cat.append(v_cam[i].reshape(num_images * num_v, 3))
+ vn_cat.append(mesh.vn.unsqueeze(0).expand(num_images, -1, -1).reshape(num_images * num_vn, 3))
+ vt_cat.append(mesh.vt.unsqueeze(0).expand(num_images, -1, -1).reshape(num_images * num_vt, 2))
+ for _ in range(num_images):
+ f_cat.append(mesh.f + v_count)
+ fn_cat.append(mesh.fn + vn_count)
+ ft_cat.append(mesh.ft + vt_count)
+ v_count += num_v
+ vn_count += num_vn
+ vt_count += num_vt
+ f_ranges.append([f_count, mesh.f.size(0)])
+ f_count += mesh.f.size(0)
+ # v_cat = torch.cat(v_cat, dim=0)
+ v_clip_cat = torch.cat(v_clip_cat, dim=0)
+ v_cam_cat = torch.cat(v_cam_cat, dim=0)
+ vn_cat = torch.cat(vn_cat, dim=0)
+ f_cat = torch.cat(f_cat, dim=0)
+ f_ranges = torch.tensor(f_ranges, device=poses.device, dtype=torch.int32)
+ # (num_scenes * num_images, h, w, 4) in [u, v, z/w, triangle_id] & (num_scenes * num_images, h, w, 4 or 0)
+ rast, rast_db = dr.rasterize(
+ self.glctx, v_clip_cat, f_cat, (h, w), ranges=f_ranges, grad_db=torch.is_grad_enabled())
+
+ fg = (rast[..., 3] > 0).reshape(num_scenes, num_images, h, w)
+
+ depth = 1 / dr.interpolate(
+ -v_cam_cat[..., 2:3].contiguous(), rast, f_cat)[0].reshape(num_scenes, num_images, h, w)
+ depth.masked_fill_(~fg, 0)
+
+ normal = dr.interpolate(
+ vn_cat, rast, fn_cat)[0].reshape(num_scenes, num_images, h, w, 3)
+ normal = F.normalize(normal, dim=-1)
+ # (num_scenes, num_images, h, w, 3) = (num_scenes, num_images, h, w, 3) @ (num_scenes, num_images, 1, 3, 3)
+ rot_normal = (normal @ r_mat_c2w.unsqueeze(2)) / 2 + 0.5
+ rot_normal[~fg] = rot_normal.new_tensor(normal_bg)
+
+ # (num_scenes * num_images, h, w, 2) & (num_scenes * num_images, h, w, 4)
+ texc, texc_db = dr.interpolate(
+ vt_cat, rast, ft_cat, rast_db=rast_db, diff_attrs='all')
+ albedo = dr.texture(
+ torch.cat([mesh.albedo.unsqueeze(0)[..., :3].expand(num_images, -1, -1, -1) for mesh in meshes], dim=0),
+ texc, uv_da=texc_db, filter_mode=self.texture_filter
+ ).reshape(num_scenes, num_images, h, w, 3)
+
+ prev_grad_enabled = torch.is_grad_enabled()
+ torch.set_grad_enabled(True)
+ if shading_fun is not None:
+ raise NotImplementedError
+
+ # (num_scenes, num_images, h, w, 4)
+ rgba = torch.cat([albedo, fg.float().unsqueeze(-1)], dim=-1)
+
+ if dilate_edges > 0:
+ rgba = rgba.reshape(num_scenes * num_images, h, w, 4).permute(0, 3, 1, 2)
+ rgba = edge_dilation(rgba, rgba[:, 3:], dilate_edges)
+ rgba = rgba.permute(0, 2, 3, 1).reshape(num_scenes, num_images, h, w, 4)
+
+ if aa:
+ # Todo: depth/normal antialiasing
+ rgba = dr.antialias(
+ rgba.reshape(num_scenes * num_images, h, w, 4), rast, v_clip_cat, f_cat
+ ).reshape(num_scenes, num_images, h, w, 4)
+
+ if self.ssaa > 1:
+ rgba = interpolate_hwc(rgba, 1 / self.ssaa)
+ depth = interpolate_hwc(depth.unsqueeze(-1), 1 / self.ssaa).squeeze(-1)
+ rot_normal = interpolate_hwc(rot_normal, 1 / self.ssaa)
+
+ results = dict(
+ rgba=rgba,
+ depth=depth,
+ normal=rot_normal)
+
+ torch.set_grad_enabled(prev_grad_enabled)
+
+ return results
+
+ def bake_xyz_shading_fun(self, meshes, shading_fun, map_size=1024, force_auto_uv=False):
+ assert len(meshes) == 1, 'only support one mesh'
+ mesh = meshes[0]
+
+ if mesh.vt is None or force_auto_uv:
+ mesh.auto_uv()
+ assert len(mesh.ft) == len(mesh.f)
+
+ vt_clip = torch.cat([mesh.vt * 2 - 1, mesh.vt.new_tensor([[0., 1.]]).expand(mesh.vt.size(0), -1)], dim=-1)
+
+ rast = dr.rasterize(self.glctx, vt_clip[None], mesh.ft, (map_size, map_size), grad_db=False)[0]
+ valid = (rast[..., 3] > 0).reshape(map_size, map_size)
+
+ xyz = dr.interpolate(mesh.v[None], rast, mesh.f)[0].reshape(map_size, map_size, 3)
+ rgb_reshade = shading_fun(world_pos=xyz[valid])
+ new_albedo_map = xyz.new_zeros((map_size, map_size, 3))
+ new_albedo_map[valid] = rgb_reshade
+ torch.cuda.empty_cache()
+ new_albedo_map = edge_dilation(
+ new_albedo_map.permute(2, 0, 1)[None], valid[None, None].float(),
+ ).squeeze(0).permute(1, 2, 0)
+ mesh.albedo = torch.cat(
+ [new_albedo_map.clamp(min=0, max=1),
+ torch.ones_like(new_albedo_map[..., :1])], dim=-1)
+
+ mesh.textureless = False
+ return [mesh]
+
+ def bake_multiview(self, meshes, images, alphas, poses, intrinsics, map_size=1024, cos_weight_pow=4.0):
+ assert len(meshes) == 1, 'only support one mesh'
+ mesh = meshes[0]
+ images = images[0] # (n, h, w, 3)
+ alphas = alphas[0] # (n, h, w, 1)
+ n, h, w, _ = images.size()
+
+ r_mat_c2w = torch.cat(
+ [poses[..., :3, :1], -poses[..., :3, 1:3]], dim=-1)[0] # opencv to opengl conversion
+
+ proj = poses.new_zeros([n, 4, 4])
+ proj[..., 0, 0] = 2 * intrinsics[..., 0] / w
+ proj[..., 0, 2] = -2 * intrinsics[..., 2] / w + 1
+ proj[..., 1, 1] = -2 * intrinsics[..., 1] / h
+ proj[..., 1, 2] = -2 * intrinsics[..., 3] / h + 1
+ proj[..., 2, 2] = -(self.far + self.near) / (self.far - self.near)
+ proj[..., 2, 3] = -(2 * self.far * self.near) / (self.far - self.near)
+ proj[..., 3, 2] = -1
+
+ # (num_images, num_vertices, 3)
+ v_cam = (mesh.v.detach() - poses[0, :, :3, 3].unsqueeze(-2)) @ r_mat_c2w
+ # (num_images, num_vertices, 4)
+ v_clip = F.pad(v_cam, pad=(0, 1), mode='constant', value=1.0) @ proj.transpose(-1, -2)
+
+ rast, rast_db = dr.rasterize(self.glctx, v_clip, mesh.f, (h, w), grad_db=False)
+ texc, texc_db = dr.interpolate(
+ mesh.vt.unsqueeze(0).contiguous(), rast, mesh.ft, rast_db=rast_db, diff_attrs='all')
+
+ with torch.enable_grad():
+ dummy_maps = torch.ones((n, map_size, map_size, 1), device=images.device, dtype=images.dtype).requires_grad_(True)
+ # (num_images, h, w, 1)
+ albedo = dr.texture(
+ dummy_maps, texc, uv_da=texc_db, filter_mode=self.texture_filter)
+ visibility_grad = torch.autograd.grad(albedo.sum(), dummy_maps, create_graph=False)[0]
+
+ fg = rast[..., 3] > 0 # (num_images, h, w)
+ depth = 1 / dr.interpolate(
+ -v_cam[..., 2:3].contiguous(), rast, mesh.f)[0].reshape(n, h, w)
+ depth.masked_fill_(~fg, 0)
+
+ # # save all the depth maps for visualization debug
+ # import matplotlib.pyplot as plt
+ # for i in range(n):
+ # plt.imshow(depth[i].cpu().numpy())
+ # plt.savefig(f'depth_{i}.png')
+ # # also save the alphas
+ # for i in range(n):
+ # plt.imshow(alphas[i].cpu().numpy())
+ # plt.savefig(f'alpha_{i}.png')
+
+ directions = get_ray_directions(
+ h, w, intrinsics.squeeze(0), norm=True, device=intrinsics.device)
+
+ normals_opencv = depth_to_normal(
+ depth, directions, format='opencv') * 2 - 1
+ normals_cos_weight = (normals_opencv[..., None, :] @ directions[..., :, None]).squeeze(-1).neg().clamp(min=0)
+
+ img_space_weight = (normals_cos_weight ** cos_weight_pow) * alphas
+ img_space_weight = -F.max_pool2d( # alleviate edge effect
+ -img_space_weight.permute(0, 3, 1, 2), 5, stride=1, padding=2).permute(0, 2, 3, 1)
+
+ # bake texture
+ vt_clip = torch.cat([mesh.vt * 2 - 1, mesh.vt.new_tensor([[0., 1.]]).expand(mesh.vt.size(0), -1)], dim=-1)
+
+ rast, rast_db = dr.rasterize(self.glctx, vt_clip[None], mesh.ft, (map_size, map_size), grad_db=False)
+ valid = (rast[..., 3] > 0).reshape(map_size, map_size)
+ rast = rast.expand(n, -1, -1, -1)
+ rast_db = rast_db.expand(n, -1, -1, -1)
+ v_img = v_clip[..., :2] / v_clip[..., 3:] * 0.5 + 0.5
+ # print(v_img.min(), v_img.max())
+ texc, texc_db = dr.interpolate(
+ v_img.contiguous(), rast.contiguous(), mesh.f, rast_db=rast_db.contiguous(), diff_attrs='all')
+ # (n, map_size, map_size, 4)
+ tex = dr.texture(
+ torch.cat([images, img_space_weight], dim=-1), texc, uv_da=texc_db, filter_mode=self.texture_filter)
+
+ weight = tex[..., 3:4] * visibility_grad
+
+ new_albedo_map = (tex[..., :3] * weight).sum(dim=0) / weight.sum(dim=0).clamp(min=1e-6)
+
+ new_albedo_map = edge_dilation(
+ new_albedo_map.permute(2, 0, 1)[None], valid[None, None].float(),
+ ).squeeze(0).permute(1, 2, 0)
+ mesh.albedo = torch.cat(
+ [new_albedo_map.clamp(min=0, max=1),
+ torch.ones_like(new_albedo_map[..., :1])], dim=-1)
+
+ mesh.textureless = False
+ return [mesh]
diff --git a/freesplatter/utils/recon_util.py b/freesplatter/utils/recon_util.py
new file mode 100644
index 0000000000000000000000000000000000000000..01c27731c1e93a61e81a1e1eda9ba1ae932e7384
--- /dev/null
+++ b/freesplatter/utils/recon_util.py
@@ -0,0 +1,324 @@
+import cv2
+import math
+import scipy
+import numpy as np
+import torch
+import open3d as o3d
+from tqdm import tqdm
+
+from .camera_util import create_camera_to_world
+
+
+###############################################################################
+# Camera Trajectory
+###############################################################################
+
+def fibonacci_sampling_on_sphere(num_samples=1):
+ points = []
+ phi = np.pi * (3.0 - np.sqrt(5.0)) # golden angle in radians
+ for i in range(num_samples):
+ y = 1 - (i / float(num_samples - 1)) * 2 # y goes from 1 to -1
+ radius = np.sqrt(1 - y * y) # radius at y
+
+ theta = phi * i # golden angle increment
+
+ x = np.cos(theta) * radius
+ z = np.sin(theta) * radius
+
+ points.append([x, y, z])
+ points = np.array(points)
+ return points
+
+
+def get_fibonacci_cameras(N=20, radius=2.0, device='cuda'):
+ def normalize_vecs(vectors):
+ return vectors / (torch.norm(vectors, dim=-1, keepdim=True))
+
+ t = torch.linspace(0, 1, N).reshape(-1, 1)
+
+ cam_pos = fibonacci_sampling_on_sphere(N)
+ cam_pos = torch.from_numpy(cam_pos).float().to(device)
+ cam_pos = cam_pos * radius
+
+ forward_vector = normalize_vecs(-cam_pos)
+ up_vector = torch.tensor([0, 0, 1], dtype=torch.float,
+ device=device).reshape(-1).expand_as(forward_vector)
+ right_vector = normalize_vecs(torch.cross(forward_vector, up_vector, dim=-1))
+
+ up_vector = normalize_vecs(torch.cross(right_vector, forward_vector, dim=-1))
+ rotate = torch.stack(
+ (right_vector, -up_vector, forward_vector), dim=-1)
+
+ rotation_matrix = torch.eye(4, device=device).unsqueeze(0).repeat(forward_vector.shape[0], 1, 1)
+ rotation_matrix[:, :3, :3] = rotate
+
+ translation_matrix = torch.eye(4, device=device).unsqueeze(0).repeat(forward_vector.shape[0], 1, 1)
+ translation_matrix[:, :3, 3] = cam_pos
+ cam2world = translation_matrix @ rotation_matrix
+ return cam2world
+
+
+def get_circular_cameras(N=120, elevation=0, radius=2.0, normalize=True, device='cuda'):
+ camera_positions = []
+ for i in range(N):
+ azimuth = 2 * np.pi * i / N - np.pi / 2
+ x = radius * np.cos(elevation) * np.cos(azimuth)
+ y = radius * np.cos(elevation) * np.sin(azimuth)
+ z = radius * np.sin(elevation)
+ camera_positions.append([x, y, z])
+ camera_positions = np.array(camera_positions)
+ camera_positions = torch.from_numpy(camera_positions).float()
+ c2ws = create_camera_to_world(camera_positions, camera_system='opencv')
+
+ if normalize:
+ c2ws_first = create_camera_to_world(torch.tensor([0, -2, 0]), camera_system='opencv').unsqueeze(0)
+ c2ws = torch.linalg.inv(c2ws_first) @ c2ws
+
+ return c2ws
+
+###############################################################################
+# TSDF Fusion
+###############################################################################
+
+def rgbd_to_mesh(images, depths, c2ws, fov, mesh_path, cam_elev_thr=0):
+
+ voxel_length = 2 * 2.0 / 512.0
+ sdf_trunc = 2 * 0.02
+ color_type = o3d.pipelines.integration.TSDFVolumeColorType.RGB8
+
+ volume = o3d.pipelines.integration.ScalableTSDFVolume(
+ voxel_length=voxel_length,
+ sdf_trunc=sdf_trunc,
+ color_type=color_type,
+ )
+
+ for i in tqdm(range(c2ws.shape[0])):
+ camera_to_world = c2ws[i]
+ world_to_camera = np.linalg.inv(camera_to_world)
+ camera_position = camera_to_world[:3, 3]
+ # camera_elevation = np.rad2deg(np.arcsin(camera_position[2]))
+ camera_elevation = np.rad2deg(np.arcsin(camera_position[2] / np.linalg.norm(camera_position)))
+ if camera_elevation < cam_elev_thr:
+ continue
+ color_image = o3d.geometry.Image(np.ascontiguousarray(images[i]))
+ depth_image = o3d.geometry.Image(np.ascontiguousarray(depths[i]))
+ rgbd_image = o3d.geometry.RGBDImage.create_from_color_and_depth(
+ color_image, depth_image, depth_scale=1.0, depth_trunc=4.0, convert_rgb_to_intensity=False
+ )
+ camera_intrinsics = o3d.camera.PinholeCameraIntrinsic()
+
+ fx = fy = images[i].shape[1] / 2. / np.tan(np.deg2rad(fov / 2.0))
+ cx = cy = images[i].shape[1] / 2.
+ h = images[i].shape[0]
+ w = images[i].shape[1]
+ camera_intrinsics.set_intrinsics(
+ w, h, fx, fy, cx, cy
+ )
+ volume.integrate(
+ rgbd_image,
+ camera_intrinsics,
+ world_to_camera,
+ )
+
+ fused_mesh = volume.extract_triangle_mesh()
+
+ triangle_clusters, cluster_n_triangles, cluster_area = (
+ fused_mesh.cluster_connected_triangles())
+ triangle_clusters = np.asarray(triangle_clusters)
+ cluster_n_triangles = np.asarray(cluster_n_triangles)
+ cluster_area = np.asarray(cluster_area)
+
+ triangles_to_remove = cluster_n_triangles[triangle_clusters] < 500
+ fused_mesh.remove_triangles_by_mask(triangles_to_remove)
+ fused_mesh.remove_unreferenced_vertices()
+
+ fused_mesh = fused_mesh.filter_smooth_simple(number_of_iterations=2)
+ fused_mesh = fused_mesh.compute_vertex_normals()
+ o3d.io.write_triangle_mesh(mesh_path, fused_mesh)
+
+###############################################################################
+# Visualization
+###############################################################################
+
+def viewmatrix(lookdir, up, position):
+ """Construct lookat view matrix."""
+ vec2 = normalize(lookdir)
+ vec0 = normalize(np.cross(up, vec2))
+ vec1 = normalize(np.cross(vec2, vec0))
+ m = np.stack([vec0, vec1, vec2, position], axis=1)
+ return m
+
+
+def normalize(x):
+ """Normalization helper function."""
+ return x / np.linalg.norm(x)
+
+
+def generate_interpolated_path(poses, n_interp, spline_degree=5,
+ smoothness=.03, rot_weight=.1):
+ """Creates a smooth spline path between input keyframe camera poses.
+
+ Spline is calculated with poses in format (position, lookat-point, up-point).
+
+ Args:
+ poses: (n, 3, 4) array of input pose keyframes.
+ n_interp: returned path will have n_interp * (n - 1) total poses.
+ spline_degree: polynomial degree of B-spline.
+ smoothness: parameter for spline smoothing, 0 forces exact interpolation.
+ rot_weight: relative weighting of rotation/translation in spline solve.
+
+ Returns:
+ Array of new camera poses with shape (n_interp * (n - 1), 3, 4).
+ """
+
+ def poses_to_points(poses, dist):
+ """Converts from pose matrices to (position, lookat, up) format."""
+ pos = poses[:, :3, -1]
+ lookat = poses[:, :3, -1] - dist * poses[:, :3, 2]
+ up = poses[:, :3, -1] + dist * poses[:, :3, 1]
+ return np.stack([pos, lookat, up], 1)
+
+ def points_to_poses(points):
+ """Converts from (position, lookat, up) format to pose matrices."""
+ return np.array([viewmatrix(p - l, u - p, p) for p, l, u in points])
+
+ def interp(points, n, k, s):
+ """Runs multidimensional B-spline interpolation on the input points."""
+ sh = points.shape
+ pts = np.reshape(points, (sh[0], -1))
+ k = min(k, sh[0] - 1)
+ tck, _ = scipy.interpolate.splprep(pts.T, k=k, s=s)
+ u = np.linspace(0, 1, n, endpoint=False)
+ new_points = np.array(scipy.interpolate.splev(u, tck))
+ new_points = np.reshape(new_points.T, (n, sh[1], sh[2]))
+ return new_points
+
+ points = poses_to_points(poses, dist=rot_weight)
+ new_points = interp(points,
+ n_interp * (points.shape[0] - 1),
+ k=spline_degree,
+ s=smoothness)
+ return points_to_poses(new_points)
+
+###############################################################################
+# Camera Estimation
+###############################################################################
+
+def xy_grid(W, H, device=None, origin=(0, 0), unsqueeze=None, cat_dim=-1, homogeneous=False, **arange_kw):
+ """ Output a (H,W,2) array of int32
+ with output[j,i,0] = i + origin[0]
+ output[j,i,1] = j + origin[1]
+ """
+ if device is None:
+ # numpy
+ arange, meshgrid, stack, ones = np.arange, np.meshgrid, np.stack, np.ones
+ else:
+ # torch
+ arange = lambda *a, **kw: torch.arange(*a, device=device, **kw)
+ meshgrid, stack = torch.meshgrid, torch.stack
+ ones = lambda *a: torch.ones(*a, device=device)
+
+ tw, th = [arange(o, o + s, **arange_kw) for s, o in zip((W, H), origin)]
+ grid = meshgrid(tw, th, indexing='xy')
+ if homogeneous:
+ grid = grid + (ones((H, W)),)
+ if unsqueeze is not None:
+ grid = (grid[0].unsqueeze(unsqueeze), grid[1].unsqueeze(unsqueeze))
+ if cat_dim is not None:
+ grid = stack(grid, cat_dim)
+ return grid
+
+
+def estimate_focal(pts3d, pp=None, mask=None, min_focal=0., max_focal=np.inf):
+ """
+ Reprojection method, for when the absolute depth is known:
+ 1) estimate the camera focal using a robust estimator
+ 2) reproject points onto true rays, minimizing a certain error
+ """
+ H, W, THREE = pts3d.shape
+ assert THREE == 3
+
+ if pp is None:
+ pp = torch.tensor([W/2, H/2]).to(pts3d)
+
+ # centered pixel grid
+ pixels = xy_grid(W, H, device=pts3d.device).view(-1, 2) - pp.view(1, 2) # (HW, 2)
+ pts3d = pts3d.view(H*W, 3).contiguous() # (HW, 3)
+
+ # mask points if provided
+ if mask is not None:
+ mask = mask.to(pts3d.device).ravel().bool()
+ assert len(mask) == pts3d.shape[0]
+ pts3d = pts3d[mask]
+ pixels = pixels[mask]
+
+ # weiszfeld
+ # init focal with l2 closed form
+ # we try to find focal = argmin Sum | pixel - focal * (x,y)/z|
+ xy_over_z = (pts3d[..., :2] / pts3d[..., 2:3]).nan_to_num(posinf=0, neginf=0) # homogeneous (x,y,1)
+
+ dot_xy_px = (xy_over_z * pixels).sum(dim=-1)
+ dot_xy_xy = xy_over_z.square().sum(dim=-1)
+
+ focal = dot_xy_px.mean(dim=0) / dot_xy_xy.mean(dim=0)
+
+ # iterative re-weighted least-squares
+ for iter in range(10):
+ # re-weighting by inverse of distance
+ dis = (pixels - focal.view(-1, 1) * xy_over_z).norm(dim=-1)
+ # print(dis.nanmean(-1))
+ w = dis.clip(min=1e-8).reciprocal()
+ # update the scaling with the new weights
+ focal = (w * dot_xy_px).mean(dim=0) / (w * dot_xy_xy).mean(dim=0)
+
+ focal_base = max(H, W) / (2 * np.tan(np.deg2rad(60) / 2)) # size / 1.1547005383792515
+ focal = focal.clip(min=min_focal*focal_base, max=max_focal*focal_base)
+ return focal.ravel()
+
+
+def fast_pnp(pts3d, mask, focal=None, pp=None, niter_PnP=10):
+ """
+ Estimate camera poses and focals with RANSAC-PnP.
+
+ Inputs:
+ pts3d: H x W x 3
+ focal: 1
+ mask: H x W
+ pp
+ """
+ H, W, _ = pts3d.shape
+ pixels = np.mgrid[:W, :H].T.astype(float)
+
+ if focal is None:
+ S = max(W, H)
+ tentative_focals = np.geomspace(S/2, S*3, 21)
+ else:
+ tentative_focals = [focal]
+
+ if pp is None:
+ pp = (W/2, H/2)
+
+ best = 0,
+ for focal in tentative_focals:
+ K = np.float32([(focal, 0, pp[0]), (0, focal, pp[1]), (0, 0, 1)])
+
+ success, R, T, inliers = cv2.solvePnPRansac(pts3d[mask], pixels[mask], K, None,
+ iterationsCount=niter_PnP, reprojectionError=5, flags=cv2.SOLVEPNP_SQPNP)
+ if not success:
+ continue
+
+ score = len(inliers)
+ if success and score > best[0]:
+ best = score, R, T, focal
+
+ if not best[0]:
+ return None
+
+ _, R, T, best_focal = best
+ R = cv2.Rodrigues(R)[0] # world to cam
+ world2cam = np.eye(4).astype(float)
+ world2cam[:3, :3] = R
+ world2cam[:3, 3] = T.reshape(3)
+ cam2world = np.linalg.inv(world2cam)
+
+ return best_focal, cam2world
diff --git a/freesplatter/webui/__init__.py b/freesplatter/webui/__init__.py
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/freesplatter/webui/camera_viewer/__init__.py b/freesplatter/webui/camera_viewer/__init__.py
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/freesplatter/webui/camera_viewer/utils.py b/freesplatter/webui/camera_viewer/utils.py
new file mode 100644
index 0000000000000000000000000000000000000000..ca01efccd00ae02e32642d192a9982fedfb6ef16
--- /dev/null
+++ b/freesplatter/webui/camera_viewer/utils.py
@@ -0,0 +1,134 @@
+import os
+import numpy as np
+from PIL import Image
+
+
+def load_image(fpath, sz=256):
+ img = Image.open(fpath)
+ img = img.resize((sz, sz))
+ return np.asarray(img)[:, :, :3]
+
+
+def spherical_to_cartesian(sph):
+
+ theta, azimuth, radius = sph
+
+ return np.array([
+ radius * np.sin(theta) * np.cos(azimuth),
+ radius * np.sin(theta) * np.sin(azimuth),
+ radius * np.cos(theta),
+ ])
+
+
+def cartesian_to_spherical(xyz):
+
+ xy = xyz[0]**2 + xyz[1]**2
+ radius = np.sqrt(xy + xyz[2]**2)
+ theta = np.arctan2(np.sqrt(xy), xyz[2])
+ azimuth = np.arctan2(xyz[1], xyz[0])
+
+ return np.array([theta, azimuth, radius])
+
+
+def elu_to_c2w(eye, lookat, up):
+
+ if isinstance(eye, list):
+ eye = np.array(eye)
+ if isinstance(lookat, list):
+ lookat = np.array(lookat)
+ if isinstance(up, list):
+ up = np.array(up)
+
+ l = eye - lookat
+ if np.linalg.norm(l) < 1e-8:
+ l[-1] = 1
+ l = l / np.linalg.norm(l)
+
+ s = np.cross(l, up)
+ if np.linalg.norm(s) < 1e-8:
+ s[0] = 1
+ s = s / np.linalg.norm(s)
+ uu = np.cross(s, l)
+
+ rot = np.eye(3)
+ rot[0, :] = -s
+ rot[1, :] = uu
+ rot[2, :] = l
+
+ c2w = np.eye(4)
+ c2w[:3, :3] = rot.T
+ c2w[:3, 3] = eye
+
+ return c2w
+
+
+def c2w_to_elu(c2w):
+
+ w2c = np.linalg.inv(c2w)
+ eye = c2w[:3, 3]
+ lookat_dir = -w2c[2, :3]
+ lookat = eye + lookat_dir
+ up = w2c[1, :3]
+
+ return eye, lookat, up
+
+
+def qvec_to_rotmat(qvec):
+ return np.array([
+ [
+ 1 - 2 * qvec[2]**2 - 2 * qvec[3]**2,
+ 2 * qvec[1] * qvec[2] - 2 * qvec[0] * qvec[3],
+ 2 * qvec[3] * qvec[1] + 2 * qvec[0] * qvec[2]
+ ], [
+ 2 * qvec[1] * qvec[2] + 2 * qvec[0] * qvec[3],
+ 1 - 2 * qvec[1]**2 - 2 * qvec[3]**2,
+ 2 * qvec[2] * qvec[3] - 2 * qvec[0] * qvec[1]
+ ], [
+ 2 * qvec[3] * qvec[1] - 2 * qvec[0] * qvec[2],
+ 2 * qvec[2] * qvec[3] + 2 * qvec[0] * qvec[1],
+ 1 - 2 * qvec[1]**2 - 2 * qvec[2]**2
+ ]
+ ])
+
+
+def rotmat(a, b):
+ a, b = a / np.linalg.norm(a), b / np.linalg.norm(b)
+ v = np.cross(a, b)
+ c = np.dot(a, b)
+ # handle exception for the opposite direction input
+ if c < -1 + 1e-10:
+ return rotmat(a + np.random.uniform(-1e-2, 1e-2, 3), b)
+ s = np.linalg.norm(v)
+ kmat = np.array([[0, -v[2], v[1]], [v[2], 0, -v[0]], [-v[1], v[0], 0]])
+ return np.eye(3) + kmat + kmat.dot(kmat) * ((1 - c) / (s ** 2 + 1e-10))
+
+
+def recenter_cameras(c2ws):
+
+ is_list = False
+ if isinstance(c2ws, list):
+ is_list = True
+ c2ws = np.stack(c2ws)
+
+ center = c2ws[..., :3, -1].mean(axis=0)
+ c2ws[..., :3, -1] = c2ws[..., :3, -1] - center
+
+ if is_list:
+ c2ws = [ c2w for c2w in c2ws ]
+
+ return c2ws
+
+
+def rescale_cameras(c2ws, scale):
+
+ is_list = False
+ if isinstance(c2ws, list):
+ is_list = True
+ c2ws = np.stack(c2ws)
+
+ c2ws[..., :3, -1] *= scale
+
+ if is_list:
+ c2ws = [ c2w for c2w in c2ws ]
+
+ return c2ws
diff --git a/freesplatter/webui/camera_viewer/visualizer.py b/freesplatter/webui/camera_viewer/visualizer.py
new file mode 100644
index 0000000000000000000000000000000000000000..5abd2b3856a867337ff57f7324209d77dda6b7ba
--- /dev/null
+++ b/freesplatter/webui/camera_viewer/visualizer.py
@@ -0,0 +1,252 @@
+import os
+
+from PIL import Image
+import plotly.graph_objects as go
+import numpy as np
+
+
+def calc_cam_cone_pts_3d(c2w, fov_deg, zoom = 1.0):
+
+ fov_rad = np.deg2rad(fov_deg)
+
+ cam_x = c2w[0, -1]
+ cam_y = c2w[1, -1]
+ cam_z = c2w[2, -1]
+
+ corn1 = [np.tan(fov_rad / 2.0), np.tan(fov_rad / 2.0), -1.0]
+ corn2 = [-np.tan(fov_rad / 2.0), np.tan(fov_rad / 2.0), -1.0]
+ corn3 = [-np.tan(fov_rad / 2.0), -np.tan(fov_rad / 2.0), -1.0]
+ corn4 = [np.tan(fov_rad / 2.0), -np.tan(fov_rad / 2.0), -1.0]
+
+ corn1 = np.dot(c2w[:3, :3], corn1)
+ corn2 = np.dot(c2w[:3, :3], corn2)
+ corn3 = np.dot(c2w[:3, :3], corn3)
+ corn4 = np.dot(c2w[:3, :3], corn4)
+
+ # Now attach as offset to actual 3D camera position:
+ corn1 = np.array(corn1) / np.linalg.norm(corn1, ord=2) * zoom
+ corn_x1 = cam_x + corn1[0]
+ corn_y1 = cam_y + corn1[1]
+ corn_z1 = cam_z + corn1[2]
+ corn2 = np.array(corn2) / np.linalg.norm(corn2, ord=2) * zoom
+ corn_x2 = cam_x + corn2[0]
+ corn_y2 = cam_y + corn2[1]
+ corn_z2 = cam_z + corn2[2]
+ corn3 = np.array(corn3) / np.linalg.norm(corn3, ord=2) * zoom
+ corn_x3 = cam_x + corn3[0]
+ corn_y3 = cam_y + corn3[1]
+ corn_z3 = cam_z + corn3[2]
+ corn4 = np.array(corn4) / np.linalg.norm(corn4, ord=2) * zoom
+ corn_x4 = cam_x + corn4[0]
+ corn_y4 = cam_y + corn4[1]
+ corn_z4 = cam_z + corn4[2]
+
+
+ xs = [cam_x, corn_x1, corn_x2, corn_x3, corn_x4]
+ ys = [cam_y, corn_y1, corn_y2, corn_y3, corn_y4]
+ zs = [cam_z, corn_z1, corn_z2, corn_z3, corn_z4]
+
+ return np.array([xs, ys, zs]).T
+
+
+class CameraVisualizer:
+
+ def __init__(self, poses, legends, colors, images=None, mesh_path=None, pc_path=None, camera_x=1.0):
+ self._fig = None
+
+ self._camera_x = camera_x
+
+ self._poses = poses
+ self._legends = legends
+ self._colors = colors
+
+ self._raw_images = None
+ self._bit_images = None
+ self._image_colorscale = None
+
+ if images is not None:
+ self._raw_images = images
+ self._bit_images = []
+ self._image_colorscale = []
+ for img in images:
+ if img is None:
+ self._bit_images.append(None)
+ self._image_colorscale.append(None)
+ continue
+
+ bit_img, colorscale = self.encode_image(img)
+ self._bit_images.append(bit_img)
+ self._image_colorscale.append(colorscale)
+
+ self._mesh = None
+ if mesh_path is not None and os.path.exists(mesh_path):
+ import trimesh
+ self._mesh = trimesh.load(mesh_path, force='mesh')
+ self._pc = None
+ if pc_path is not None and os.path.exists(pc_path):
+ self._pc = np.load(pc_path)
+
+
+ def encode_image(self, raw_image):
+ '''
+ :param raw_image (H, W, 3) array of uint8 in [0, 255].
+ '''
+ # https://stackoverflow.com/questions/60685749/python-plotly-how-to-add-an-image-to-a-3d-scatter-plot
+
+ dum_img = Image.fromarray(np.ones((3, 3, 3), dtype='uint8')).convert('P', palette='WEB')
+ idx_to_color = np.array(dum_img.getpalette()).reshape((-1, 3))
+
+ bit_image = Image.fromarray(raw_image).convert('P', palette='WEB', dither=None)
+ # bit_image = Image.fromarray(raw_image.clip(0, 254)).convert(
+ # 'P', palette='WEB', dither=None)
+ colorscale = [
+ [i / 255.0, 'rgb({}, {}, {})'.format(*rgb)] for i, rgb in enumerate(idx_to_color)]
+
+ return bit_image, colorscale
+
+
+ def update_figure(
+ self,
+ scene_bounds,
+ height=720,
+ line_width=10,
+ base_radius=0.0,
+ zoom_scale=1.0,
+ fov_deg=50.,
+ mesh_z_shift=0.0,
+ mesh_scale=1.0,
+ show_background=False,
+ show_grid=False,
+ show_ticklabels=False,
+ y_up=False,
+ ):
+
+ fig = go.Figure()
+
+ for i in range(len(self._poses)):
+ pose = self._poses[i]
+ clr = np.array([self._colors[i], self._colors[i]])
+ legend = self._legends[i]
+
+ edges = [(0, 1), (0, 2), (0, 3), (0, 4), (1, 2), (2, 3), (3, 4), (4, 1)]
+
+ if isinstance(fov_deg, float) or len(fov_deg) == 1:
+ fov = fov_deg
+ else:
+ fov = fov_deg[i]
+ cone = calc_cam_cone_pts_3d(pose, fov)
+ radius = np.linalg.norm(pose[:3, -1])
+
+ if self._bit_images and self._bit_images[i]:
+
+ raw_image = self._raw_images[i]
+ bit_image = self._bit_images[i]
+ colorscale = self._image_colorscale[i]
+
+ (H, W, C) = raw_image.shape
+
+ z = np.zeros((H, W)) + base_radius
+ scale = np.linalg.norm(cone[1] - cone[2]) / 2
+ (x, y) = np.meshgrid(np.linspace(-scale, scale, W), np.linspace(scale, -scale, H) * H / W)
+
+ xyz = np.concatenate([x[..., None], y[..., None], z[..., None]], axis=-1)
+
+ rot_xyz = np.matmul(xyz, pose[:3, :3].T) + pose[:3, -1]
+
+ offset = cone[2] - rot_xyz[0, 0, :]
+ rot_xyz += offset.reshape((1, 1, 3))
+
+ x, y, z = rot_xyz[:, :, 0], rot_xyz[:, :, 1], rot_xyz[:, :, 2]
+
+ fig.add_trace(go.Surface(
+ x=x, y=y, z=z,
+ surfacecolor=bit_image,
+ cmin=0,
+ cmax=255,
+ colorscale=colorscale,
+ showscale=False,
+ lighting_diffuse=1.0,
+ lighting_ambient=1.0,
+ lighting_fresnel=1.0,
+ lighting_roughness=1.0,
+ # lighting_specular=0.3))
+ lighting_specular=0,
+ showlegend=False))
+
+ for (j, edge) in enumerate(edges):
+ (x1, x2) = (cone[edge[0], 0], cone[edge[1], 0])
+ (y1, y2) = (cone[edge[0], 1], cone[edge[1], 1])
+ (z1, z2) = (cone[edge[0], 2], cone[edge[1], 2])
+ fig.add_trace(go.Scatter3d(
+ x=[x1, x2],
+ y=[y1, y2],
+ z=[z1, z2],
+ mode='lines',
+ line=dict(color=clr, width=line_width),
+ showlegend=False))
+
+ # Add label.
+ if cone[0, 2] < 0:
+ fig.add_trace(go.Scatter3d(
+ x=[cone[0, 0]], y=[cone[0, 1]], z=[cone[0, 2] - 0.05], showlegend=False,
+ mode='text', text=legend, textposition='bottom center'))
+ else:
+ fig.add_trace(go.Scatter3d(
+ x=[cone[0, 0]], y=[cone[0, 1]], z=[cone[0, 2] + 0.05], showlegend=False,
+ mode='text', text=legend, textposition='top center'))
+
+ # look at the center of scene
+ fig.update_layout(
+ height=height,
+ autosize=True,
+ hovermode=False,
+ margin=go.layout.Margin(l=0, r=0, b=0, t=0),
+ showlegend=True,
+ legend=dict(
+ yanchor='bottom',
+ y=0.01,
+ xanchor='right',
+ x=0.99,
+ ),
+ scene=dict(
+ aspectmode='manual',
+ aspectratio=dict(x=1, y=1, z=1),
+ camera=dict(
+ eye=dict(x=1.5, y=1.5, z=1.0),
+ center=dict(x=0.0, y=0.0, z=0.0),
+ up=dict(x=0.0, y=0.0, z=1.0)),
+ xaxis_title='X',
+ yaxis_title='Z' if y_up else 'Y',
+ zaxis_title='Y' if y_up else 'Z',
+ xaxis=dict(
+ range=[-scene_bounds, scene_bounds],
+ showticklabels=show_ticklabels,
+ showgrid=show_grid,
+ zeroline=False,
+ showbackground=show_background,
+ showspikes=False,
+ showline=False,
+ ticks=''),
+ yaxis=dict(
+ range=[-scene_bounds, scene_bounds],
+ showticklabels=show_ticklabels,
+ showgrid=show_grid,
+ zeroline=False,
+ showbackground=show_background,
+ showspikes=False,
+ showline=False,
+ ticks=''),
+ zaxis=dict(
+ range=[-scene_bounds, scene_bounds],
+ showticklabels=show_ticklabels,
+ showgrid=show_grid,
+ zeroline=False,
+ showbackground=show_background,
+ showspikes=False,
+ showline=False,
+ ticks='')
+ )
+ )
+
+ self._fig = fig
+ return fig
diff --git a/freesplatter/webui/gradio_customgs/__init__.py b/freesplatter/webui/gradio_customgs/__init__.py
new file mode 100644
index 0000000000000000000000000000000000000000..420cd440ea4e5f26ab976525eea42ccc8d556977
--- /dev/null
+++ b/freesplatter/webui/gradio_customgs/__init__.py
@@ -0,0 +1,3 @@
+from .customgs import CustomGS
+
+__all__ = ['CustomGS']
diff --git a/freesplatter/webui/gradio_customgs/customgs.py b/freesplatter/webui/gradio_customgs/customgs.py
new file mode 100644
index 0000000000000000000000000000000000000000..4f1084f6c35f9532084878d7310a7e734c77106d
--- /dev/null
+++ b/freesplatter/webui/gradio_customgs/customgs.py
@@ -0,0 +1,121 @@
+"""gr.Model3D() component."""
+
+from __future__ import annotations
+
+from pathlib import Path
+from typing import Callable
+
+from gradio_client.documentation import document
+
+from gradio.components.base import Component
+from gradio.data_classes import FileData
+from gradio.events import Events
+
+
+class CustomGS(Component):
+ """
+ Creates a component allows users to upload or view 3D Model files (.obj, .glb, .stl, .gltf, .splat, or .ply).
+
+ Demos: model3D
+ Guides: how-to-use-3D-model-component
+ """
+
+ EVENTS = [Events.change, Events.upload, Events.edit, Events.clear]
+
+ data_model = FileData
+
+ def __init__(
+ self,
+ value: str | Callable | None = None,
+ *,
+ clear_color: tuple[float, float, float, float] | None = None,
+ camera_position: tuple[
+ int | float | None, int | float | None, int | float | None
+ ] = (
+ None,
+ None,
+ None,
+ ),
+ zoom_speed: float = 1,
+ pan_speed: float = 1,
+ height: int | str | None = None,
+ label: str | None = None,
+ show_label: bool | None = None,
+ every: float | None = None,
+ container: bool = True,
+ scale: int | None = None,
+ min_width: int = 160,
+ interactive: bool | None = None,
+ visible: bool = True,
+ elem_id: str | None = None,
+ elem_classes: list[str] | str | None = None,
+ render: bool = True,
+ ):
+ """
+ Parameters:
+ value: path to (.obj, .glb, .stl, .gltf, .splat, or .ply) file to show in model3D viewer. If callable, the function will be called whenever the app loads to set the initial value of the component.
+ clear_color: background color of scene, should be a tuple of 4 floats between 0 and 1 representing RGBA values.
+ camera_position: initial camera position of scene, provided as a tuple of `(alpha, beta, radius)`. Each value is optional. If provided, `alpha` and `beta` should be in degrees reflecting the angular position along the longitudinal and latitudinal axes, respectively. Radius corresponds to the distance from the center of the object to the camera.
+ zoom_speed: the speed of zooming in and out of the scene when the cursor wheel is rotated or when screen is pinched on a mobile device. Should be a positive float, increase this value to make zooming faster, decrease to make it slower. Affects the wheelPrecision property of the camera.
+ pan_speed: the speed of panning the scene when the cursor is dragged or when the screen is dragged on a mobile device. Should be a positive float, increase this value to make panning faster, decrease to make it slower. Affects the panSensibility property of the camera.
+ height: The height of the model3D component, specified in pixels if a number is passed, or in CSS units if a string is passed.
+ interactive: if True, will allow users to upload a file; if False, can only be used to display files. If not provided, this is inferred based on whether the component is used as an input or output.
+ label: The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.
+ show_label: if True, will display label.
+ every: If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute.
+ container: If True, will place the component in a container - providing some extra padding around the border.
+ scale: relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.
+ min_width: minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.
+ visible: If False, component will be hidden.
+ elem_id: An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
+ elem_classes: An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.
+ render: If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.
+ """
+ self.clear_color = clear_color or [0, 0, 0, 0]
+ self.camera_position = camera_position
+ self.height = height
+ self.zoom_speed = zoom_speed
+ self.pan_speed = pan_speed
+ super().__init__(
+ label=label,
+ every=every,
+ show_label=show_label,
+ container=container,
+ scale=scale,
+ min_width=min_width,
+ interactive=interactive,
+ visible=visible,
+ elem_id=elem_id,
+ elem_classes=elem_classes,
+ render=render,
+ value=value,
+ )
+
+ def preprocess(self, payload: FileData | None) -> str | None:
+ """
+ Parameters:
+ payload: the uploaded file as an instance of `FileData`.
+ Returns:
+ Passes the uploaded file as a {str} filepath to the function.
+ """
+ if payload is None:
+ return payload
+ return payload.path
+
+ def postprocess(self, value: str | Path | None) -> FileData | None:
+ """
+ Parameters:
+ value: Expects function to return a {str} or {pathlib.Path} filepath of type (.obj, .glb, .stl, or .gltf)
+ Returns:
+ The uploaded file as an instance of `FileData`.
+ """
+ if value is None:
+ return value
+ return FileData(path=str(value), orig_name=Path(value).name)
+
+ def process_example(self, input_data: str | Path | None) -> str:
+ return Path(input_data).name if input_data else ""
+
+ def example_inputs(self):
+ # TODO: Use permanent link
+ return "https://raw.githubusercontent.com/gradio-app/gradio/main/demo/model3D/files/Fox.gltf"
diff --git a/freesplatter/webui/gradio_customgs/customgs.pyi b/freesplatter/webui/gradio_customgs/customgs.pyi
new file mode 100644
index 0000000000000000000000000000000000000000..1dad6496d5b65e06e5c77f79cc9eea45d65dbdfd
--- /dev/null
+++ b/freesplatter/webui/gradio_customgs/customgs.pyi
@@ -0,0 +1,307 @@
+"""gr.Model3D() component."""
+
+from __future__ import annotations
+
+from pathlib import Path
+from typing import Callable
+
+from gradio_client.documentation import document
+
+from gradio.components.base import Component
+from gradio.data_classes import FileData
+from gradio.events import Events
+
+from gradio.events import Dependency
+
+class CustomGS(Component):
+ """
+ Creates a component allows users to upload or view 3D Model files (.obj, .glb, .stl, .gltf, .splat, or .ply).
+
+ Demos: model3D
+ Guides: how-to-use-3D-model-component
+ """
+
+ EVENTS = [Events.change, Events.upload, Events.edit, Events.clear]
+
+ data_model = FileData
+
+ def __init__(
+ self,
+ value: str | Callable | None = None,
+ *,
+ clear_color: tuple[float, float, float, float] | None = None,
+ camera_position: tuple[
+ int | float | None, int | float | None, int | float | None
+ ] = (
+ None,
+ None,
+ None,
+ ),
+ zoom_speed: float = 1,
+ pan_speed: float = 1,
+ height: int | str | None = None,
+ label: str | None = None,
+ show_label: bool | None = None,
+ every: float | None = None,
+ container: bool = True,
+ scale: int | None = None,
+ min_width: int = 160,
+ interactive: bool | None = None,
+ visible: bool = True,
+ elem_id: str | None = None,
+ elem_classes: list[str] | str | None = None,
+ render: bool = True,
+ ):
+ """
+ Parameters:
+ value: path to (.obj, .glb, .stl, .gltf, .splat, or .ply) file to show in model3D viewer. If callable, the function will be called whenever the app loads to set the initial value of the component.
+ clear_color: background color of scene, should be a tuple of 4 floats between 0 and 1 representing RGBA values.
+ camera_position: initial camera position of scene, provided as a tuple of `(alpha, beta, radius)`. Each value is optional. If provided, `alpha` and `beta` should be in degrees reflecting the angular position along the longitudinal and latitudinal axes, respectively. Radius corresponds to the distance from the center of the object to the camera.
+ zoom_speed: the speed of zooming in and out of the scene when the cursor wheel is rotated or when screen is pinched on a mobile device. Should be a positive float, increase this value to make zooming faster, decrease to make it slower. Affects the wheelPrecision property of the camera.
+ pan_speed: the speed of panning the scene when the cursor is dragged or when the screen is dragged on a mobile device. Should be a positive float, increase this value to make panning faster, decrease to make it slower. Affects the panSensibility property of the camera.
+ height: The height of the model3D component, specified in pixels if a number is passed, or in CSS units if a string is passed.
+ interactive: if True, will allow users to upload a file; if False, can only be used to display files. If not provided, this is inferred based on whether the component is used as an input or output.
+ label: The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.
+ show_label: if True, will display label.
+ every: If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute.
+ container: If True, will place the component in a container - providing some extra padding around the border.
+ scale: relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.
+ min_width: minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.
+ visible: If False, component will be hidden.
+ elem_id: An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
+ elem_classes: An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.
+ render: If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.
+ """
+ self.clear_color = clear_color or [0, 0, 0, 0]
+ self.camera_position = camera_position
+ self.height = height
+ self.zoom_speed = zoom_speed
+ self.pan_speed = pan_speed
+ super().__init__(
+ label=label,
+ every=every,
+ show_label=show_label,
+ container=container,
+ scale=scale,
+ min_width=min_width,
+ interactive=interactive,
+ visible=visible,
+ elem_id=elem_id,
+ elem_classes=elem_classes,
+ render=render,
+ value=value,
+ )
+
+ def preprocess(self, payload: FileData | None) -> str | None:
+ """
+ Parameters:
+ payload: the uploaded file as an instance of `FileData`.
+ Returns:
+ Passes the uploaded file as a {str} filepath to the function.
+ """
+ if payload is None:
+ return payload
+ return payload.path
+
+ def postprocess(self, value: str | Path | None) -> FileData | None:
+ """
+ Parameters:
+ value: Expects function to return a {str} or {pathlib.Path} filepath of type (.obj, .glb, .stl, or .gltf)
+ Returns:
+ The uploaded file as an instance of `FileData`.
+ """
+ if value is None:
+ return value
+ return FileData(path=str(value), orig_name=Path(value).name)
+
+ def process_example(self, input_data: str | Path | None) -> str:
+ return Path(input_data).name if input_data else ""
+
+ def example_inputs(self):
+ # TODO: Use permanent link
+ return "https://raw.githubusercontent.com/gradio-app/gradio/main/demo/model3D/files/Fox.gltf"
+ from typing import Callable, Literal, Sequence, Any, TYPE_CHECKING
+ from gradio.blocks import Block
+ if TYPE_CHECKING:
+ from gradio.components import Timer
+
+
+ def change(self,
+ fn: Callable[..., Any] | None = None,
+ inputs: Block | Sequence[Block] | set[Block] | None = None,
+ outputs: Block | Sequence[Block] | None = None,
+ api_name: str | None | Literal[False] = None,
+ scroll_to_output: bool = False,
+ show_progress: Literal["full", "minimal", "hidden"] = "full",
+ queue: bool | None = None,
+ batch: bool = False,
+ max_batch_size: int = 4,
+ preprocess: bool = True,
+ postprocess: bool = True,
+ cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
+ every: Timer | float | None = None,
+ trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
+ js: str | None = None,
+ concurrency_limit: int | None | Literal["default"] = "default",
+ concurrency_id: str | None = None,
+ show_api: bool = True,
+
+ ) -> Dependency:
+ """
+ Parameters:
+ fn: the function to call when this event is triggered. Often a machine learning model's prediction function. Each parameter of the function corresponds to one input component, and the function should return a single value or a tuple of values, with each element in the tuple corresponding to one output component.
+ inputs: list of gradio.components to use as inputs. If the function takes no inputs, this should be an empty list.
+ outputs: list of gradio.components to use as outputs. If the function returns no outputs, this should be an empty list.
+ api_name: defines how the endpoint appears in the API docs. Can be a string, None, or False. If False, the endpoint will not be exposed in the api docs. If set to None, the endpoint will be exposed in the api docs as an unnamed endpoint, although this behavior will be changed in Gradio 4.0. If set to a string, the endpoint will be exposed in the api docs with the given name.
+ scroll_to_output: if True, will scroll to output component on completion
+ show_progress: how to show the progress animation while event is running: "full" shows a spinner which covers the output component area as well as a runtime display in the upper right corner, "minimal" only shows the runtime display, "hidden" shows no progress animation at all
+ queue: if True, will place the request on the queue, if the queue has been enabled. If False, will not put this event on the queue, even if the queue has been enabled. If None, will use the queue setting of the gradio app.
+ batch: if True, then the function should process a batch of inputs, meaning that it should accept a list of input values for each parameter. The lists should be of equal length (and be up to length `max_batch_size`). The function is then *required* to return a tuple of lists (even if there is only 1 output component), with each list in the tuple corresponding to one output component.
+ max_batch_size: maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True)
+ preprocess: if False, will not run preprocessing of component data before running 'fn' (e.g. leaving it as a base64 string if this method is called with the `Image` component).
+ postprocess: if False, will not run postprocessing of component data before returning 'fn' output to the browser.
+ cancels: a list of other events to cancel when this listener is triggered. For example, setting cancels=[click_event] will cancel the click_event, where click_event is the return value of another components .click method. Functions that have not yet run (or generators that are iterating) will be cancelled, but functions that are currently running will be allowed to finish.
+ every: continously calls `value` to recalculate it if `value` is a function (has no effect otherwise). Can provide a Timer whose tick resets `value`, or a float that provides the regular interval for the reset Timer.
+ trigger_mode: if "once" (default for all events except `.change()`) would not allow any submissions while an event is pending. If set to "multiple", unlimited submissions are allowed while pending, and "always_last" (default for `.change()` and `.key_up()` events) would allow a second submission after the pending event is complete.
+ js: optional frontend js method to run before running 'fn'. Input arguments for js method are values of 'inputs' and 'outputs', return should be a list of values for output components.
+ concurrency_limit: if set, this is the maximum number of this event that can be running simultaneously. Can be set to None to mean no concurrency_limit (any number of this event can be running simultaneously). Set to "default" to use the default concurrency limit (defined by the `default_concurrency_limit` parameter in `Blocks.queue()`, which itself is 1 by default).
+ concurrency_id: if set, this is the id of the concurrency group. Events with the same concurrency_id will be limited by the lowest set concurrency_limit.
+ show_api: whether to show this event in the "view API" page of the Gradio app, or in the ".view_api()" method of the Gradio clients. Unlike setting api_name to False, setting show_api to False will still allow downstream apps as well as the Clients to use this event. If fn is None, show_api will automatically be set to False.
+
+ """
+ ...
+
+ def upload(self,
+ fn: Callable[..., Any] | None = None,
+ inputs: Block | Sequence[Block] | set[Block] | None = None,
+ outputs: Block | Sequence[Block] | None = None,
+ api_name: str | None | Literal[False] = None,
+ scroll_to_output: bool = False,
+ show_progress: Literal["full", "minimal", "hidden"] = "full",
+ queue: bool | None = None,
+ batch: bool = False,
+ max_batch_size: int = 4,
+ preprocess: bool = True,
+ postprocess: bool = True,
+ cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
+ every: Timer | float | None = None,
+ trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
+ js: str | None = None,
+ concurrency_limit: int | None | Literal["default"] = "default",
+ concurrency_id: str | None = None,
+ show_api: bool = True,
+
+ ) -> Dependency:
+ """
+ Parameters:
+ fn: the function to call when this event is triggered. Often a machine learning model's prediction function. Each parameter of the function corresponds to one input component, and the function should return a single value or a tuple of values, with each element in the tuple corresponding to one output component.
+ inputs: list of gradio.components to use as inputs. If the function takes no inputs, this should be an empty list.
+ outputs: list of gradio.components to use as outputs. If the function returns no outputs, this should be an empty list.
+ api_name: defines how the endpoint appears in the API docs. Can be a string, None, or False. If False, the endpoint will not be exposed in the api docs. If set to None, the endpoint will be exposed in the api docs as an unnamed endpoint, although this behavior will be changed in Gradio 4.0. If set to a string, the endpoint will be exposed in the api docs with the given name.
+ scroll_to_output: if True, will scroll to output component on completion
+ show_progress: how to show the progress animation while event is running: "full" shows a spinner which covers the output component area as well as a runtime display in the upper right corner, "minimal" only shows the runtime display, "hidden" shows no progress animation at all
+ queue: if True, will place the request on the queue, if the queue has been enabled. If False, will not put this event on the queue, even if the queue has been enabled. If None, will use the queue setting of the gradio app.
+ batch: if True, then the function should process a batch of inputs, meaning that it should accept a list of input values for each parameter. The lists should be of equal length (and be up to length `max_batch_size`). The function is then *required* to return a tuple of lists (even if there is only 1 output component), with each list in the tuple corresponding to one output component.
+ max_batch_size: maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True)
+ preprocess: if False, will not run preprocessing of component data before running 'fn' (e.g. leaving it as a base64 string if this method is called with the `Image` component).
+ postprocess: if False, will not run postprocessing of component data before returning 'fn' output to the browser.
+ cancels: a list of other events to cancel when this listener is triggered. For example, setting cancels=[click_event] will cancel the click_event, where click_event is the return value of another components .click method. Functions that have not yet run (or generators that are iterating) will be cancelled, but functions that are currently running will be allowed to finish.
+ every: continously calls `value` to recalculate it if `value` is a function (has no effect otherwise). Can provide a Timer whose tick resets `value`, or a float that provides the regular interval for the reset Timer.
+ trigger_mode: if "once" (default for all events except `.change()`) would not allow any submissions while an event is pending. If set to "multiple", unlimited submissions are allowed while pending, and "always_last" (default for `.change()` and `.key_up()` events) would allow a second submission after the pending event is complete.
+ js: optional frontend js method to run before running 'fn'. Input arguments for js method are values of 'inputs' and 'outputs', return should be a list of values for output components.
+ concurrency_limit: if set, this is the maximum number of this event that can be running simultaneously. Can be set to None to mean no concurrency_limit (any number of this event can be running simultaneously). Set to "default" to use the default concurrency limit (defined by the `default_concurrency_limit` parameter in `Blocks.queue()`, which itself is 1 by default).
+ concurrency_id: if set, this is the id of the concurrency group. Events with the same concurrency_id will be limited by the lowest set concurrency_limit.
+ show_api: whether to show this event in the "view API" page of the Gradio app, or in the ".view_api()" method of the Gradio clients. Unlike setting api_name to False, setting show_api to False will still allow downstream apps as well as the Clients to use this event. If fn is None, show_api will automatically be set to False.
+
+ """
+ ...
+
+ def edit(self,
+ fn: Callable[..., Any] | None = None,
+ inputs: Block | Sequence[Block] | set[Block] | None = None,
+ outputs: Block | Sequence[Block] | None = None,
+ api_name: str | None | Literal[False] = None,
+ scroll_to_output: bool = False,
+ show_progress: Literal["full", "minimal", "hidden"] = "full",
+ queue: bool | None = None,
+ batch: bool = False,
+ max_batch_size: int = 4,
+ preprocess: bool = True,
+ postprocess: bool = True,
+ cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
+ every: Timer | float | None = None,
+ trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
+ js: str | None = None,
+ concurrency_limit: int | None | Literal["default"] = "default",
+ concurrency_id: str | None = None,
+ show_api: bool = True,
+
+ ) -> Dependency:
+ """
+ Parameters:
+ fn: the function to call when this event is triggered. Often a machine learning model's prediction function. Each parameter of the function corresponds to one input component, and the function should return a single value or a tuple of values, with each element in the tuple corresponding to one output component.
+ inputs: list of gradio.components to use as inputs. If the function takes no inputs, this should be an empty list.
+ outputs: list of gradio.components to use as outputs. If the function returns no outputs, this should be an empty list.
+ api_name: defines how the endpoint appears in the API docs. Can be a string, None, or False. If False, the endpoint will not be exposed in the api docs. If set to None, the endpoint will be exposed in the api docs as an unnamed endpoint, although this behavior will be changed in Gradio 4.0. If set to a string, the endpoint will be exposed in the api docs with the given name.
+ scroll_to_output: if True, will scroll to output component on completion
+ show_progress: how to show the progress animation while event is running: "full" shows a spinner which covers the output component area as well as a runtime display in the upper right corner, "minimal" only shows the runtime display, "hidden" shows no progress animation at all
+ queue: if True, will place the request on the queue, if the queue has been enabled. If False, will not put this event on the queue, even if the queue has been enabled. If None, will use the queue setting of the gradio app.
+ batch: if True, then the function should process a batch of inputs, meaning that it should accept a list of input values for each parameter. The lists should be of equal length (and be up to length `max_batch_size`). The function is then *required* to return a tuple of lists (even if there is only 1 output component), with each list in the tuple corresponding to one output component.
+ max_batch_size: maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True)
+ preprocess: if False, will not run preprocessing of component data before running 'fn' (e.g. leaving it as a base64 string if this method is called with the `Image` component).
+ postprocess: if False, will not run postprocessing of component data before returning 'fn' output to the browser.
+ cancels: a list of other events to cancel when this listener is triggered. For example, setting cancels=[click_event] will cancel the click_event, where click_event is the return value of another components .click method. Functions that have not yet run (or generators that are iterating) will be cancelled, but functions that are currently running will be allowed to finish.
+ every: continously calls `value` to recalculate it if `value` is a function (has no effect otherwise). Can provide a Timer whose tick resets `value`, or a float that provides the regular interval for the reset Timer.
+ trigger_mode: if "once" (default for all events except `.change()`) would not allow any submissions while an event is pending. If set to "multiple", unlimited submissions are allowed while pending, and "always_last" (default for `.change()` and `.key_up()` events) would allow a second submission after the pending event is complete.
+ js: optional frontend js method to run before running 'fn'. Input arguments for js method are values of 'inputs' and 'outputs', return should be a list of values for output components.
+ concurrency_limit: if set, this is the maximum number of this event that can be running simultaneously. Can be set to None to mean no concurrency_limit (any number of this event can be running simultaneously). Set to "default" to use the default concurrency limit (defined by the `default_concurrency_limit` parameter in `Blocks.queue()`, which itself is 1 by default).
+ concurrency_id: if set, this is the id of the concurrency group. Events with the same concurrency_id will be limited by the lowest set concurrency_limit.
+ show_api: whether to show this event in the "view API" page of the Gradio app, or in the ".view_api()" method of the Gradio clients. Unlike setting api_name to False, setting show_api to False will still allow downstream apps as well as the Clients to use this event. If fn is None, show_api will automatically be set to False.
+
+ """
+ ...
+
+ def clear(self,
+ fn: Callable[..., Any] | None = None,
+ inputs: Block | Sequence[Block] | set[Block] | None = None,
+ outputs: Block | Sequence[Block] | None = None,
+ api_name: str | None | Literal[False] = None,
+ scroll_to_output: bool = False,
+ show_progress: Literal["full", "minimal", "hidden"] = "full",
+ queue: bool | None = None,
+ batch: bool = False,
+ max_batch_size: int = 4,
+ preprocess: bool = True,
+ postprocess: bool = True,
+ cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
+ every: Timer | float | None = None,
+ trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
+ js: str | None = None,
+ concurrency_limit: int | None | Literal["default"] = "default",
+ concurrency_id: str | None = None,
+ show_api: bool = True,
+
+ ) -> Dependency:
+ """
+ Parameters:
+ fn: the function to call when this event is triggered. Often a machine learning model's prediction function. Each parameter of the function corresponds to one input component, and the function should return a single value or a tuple of values, with each element in the tuple corresponding to one output component.
+ inputs: list of gradio.components to use as inputs. If the function takes no inputs, this should be an empty list.
+ outputs: list of gradio.components to use as outputs. If the function returns no outputs, this should be an empty list.
+ api_name: defines how the endpoint appears in the API docs. Can be a string, None, or False. If False, the endpoint will not be exposed in the api docs. If set to None, the endpoint will be exposed in the api docs as an unnamed endpoint, although this behavior will be changed in Gradio 4.0. If set to a string, the endpoint will be exposed in the api docs with the given name.
+ scroll_to_output: if True, will scroll to output component on completion
+ show_progress: how to show the progress animation while event is running: "full" shows a spinner which covers the output component area as well as a runtime display in the upper right corner, "minimal" only shows the runtime display, "hidden" shows no progress animation at all
+ queue: if True, will place the request on the queue, if the queue has been enabled. If False, will not put this event on the queue, even if the queue has been enabled. If None, will use the queue setting of the gradio app.
+ batch: if True, then the function should process a batch of inputs, meaning that it should accept a list of input values for each parameter. The lists should be of equal length (and be up to length `max_batch_size`). The function is then *required* to return a tuple of lists (even if there is only 1 output component), with each list in the tuple corresponding to one output component.
+ max_batch_size: maximum number of inputs to batch together if this is called from the queue (only relevant if batch=True)
+ preprocess: if False, will not run preprocessing of component data before running 'fn' (e.g. leaving it as a base64 string if this method is called with the `Image` component).
+ postprocess: if False, will not run postprocessing of component data before returning 'fn' output to the browser.
+ cancels: a list of other events to cancel when this listener is triggered. For example, setting cancels=[click_event] will cancel the click_event, where click_event is the return value of another components .click method. Functions that have not yet run (or generators that are iterating) will be cancelled, but functions that are currently running will be allowed to finish.
+ every: continously calls `value` to recalculate it if `value` is a function (has no effect otherwise). Can provide a Timer whose tick resets `value`, or a float that provides the regular interval for the reset Timer.
+ trigger_mode: if "once" (default for all events except `.change()`) would not allow any submissions while an event is pending. If set to "multiple", unlimited submissions are allowed while pending, and "always_last" (default for `.change()` and `.key_up()` events) would allow a second submission after the pending event is complete.
+ js: optional frontend js method to run before running 'fn'. Input arguments for js method are values of 'inputs' and 'outputs', return should be a list of values for output components.
+ concurrency_limit: if set, this is the maximum number of this event that can be running simultaneously. Can be set to None to mean no concurrency_limit (any number of this event can be running simultaneously). Set to "default" to use the default concurrency limit (defined by the `default_concurrency_limit` parameter in `Blocks.queue()`, which itself is 1 by default).
+ concurrency_id: if set, this is the id of the concurrency group. Events with the same concurrency_id will be limited by the lowest set concurrency_limit.
+ show_api: whether to show this event in the "view API" page of the Gradio app, or in the ".view_api()" method of the Gradio clients. Unlike setting api_name to False, setting show_api to False will still allow downstream apps as well as the Clients to use this event. If fn is None, show_api will automatically be set to False.
+
+ """
+ ...
\ No newline at end of file
diff --git a/freesplatter/webui/gradio_customgs/templates/component/Canvas3D-60a8d213.js b/freesplatter/webui/gradio_customgs/templates/component/Canvas3D-60a8d213.js
new file mode 100644
index 0000000000000000000000000000000000000000..85e5e118dc550dfe1455051c91daf5d04c756afb
--- /dev/null
+++ b/freesplatter/webui/gradio_customgs/templates/component/Canvas3D-60a8d213.js
@@ -0,0 +1,69020 @@
+import { c as Gr, g as av, r as sv } from "./Index-f5583db3.js";
+function cv(an, ln) {
+ for (var Be = 0; Be < ln.length; Be++) {
+ const A = ln[Be];
+ if (typeof A != "string" && !Array.isArray(A)) {
+ for (const f in A)
+ if (f !== "default" && !(f in an)) {
+ const V = Object.getOwnPropertyDescriptor(A, f);
+ V && Object.defineProperty(an, f, V.get ? V : {
+ enumerable: !0,
+ get: () => A[f]
+ });
+ }
+ }
+ }
+ return Object.freeze(Object.defineProperty(an, Symbol.toStringTag, { value: "Module" }));
+}
+var Yc = { exports: {} }, of;
+function sf() {
+ return of || (of = 1, function(an, ln) {
+ (function(Be, A) {
+ an.exports = A();
+ })(typeof self < "u" ? self : typeof Gr < "u" ? Gr : Gr, function() {
+ return function(Be) {
+ var A = {};
+ function f(V) {
+ if (A[V])
+ return A[V].exports;
+ var _ = A[V] = { i: V, l: !1, exports: {} };
+ return Be[V].call(_.exports, _, _.exports, f), _.l = !0, _.exports;
+ }
+ return f.m = Be, f.c = A, f.d = function(V, _, C) {
+ f.o(V, _) || Object.defineProperty(V, _, { enumerable: !0, get: C });
+ }, f.r = function(V) {
+ typeof Symbol < "u" && Symbol.toStringTag && Object.defineProperty(V, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(V, "__esModule", { value: !0 });
+ }, f.t = function(V, _) {
+ if (1 & _ && (V = f(V)), 8 & _ || 4 & _ && typeof V == "object" && V && V.__esModule)
+ return V;
+ var C = /* @__PURE__ */ Object.create(null);
+ if (f.r(C), Object.defineProperty(C, "default", { enumerable: !0, value: V }), 2 & _ && typeof V != "string")
+ for (var u in V)
+ f.d(C, u, (function(I) {
+ return V[I];
+ }).bind(null, u));
+ return C;
+ }, f.n = function(V) {
+ var _ = V && V.__esModule ? function() {
+ return V.default;
+ } : function() {
+ return V;
+ };
+ return f.d(_, "a", _), _;
+ }, f.o = function(V, _) {
+ return Object.prototype.hasOwnProperty.call(V, _);
+ }, f.p = "", f(f.s = 169);
+ }([function(Be, A, f) {
+ f.d(A, "d", function() {
+ return O;
+ }), f.d(A, "e", function() {
+ return x;
+ }), f.d(A, "f", function() {
+ return m;
+ }), f.d(A, "b", function() {
+ return c;
+ }), f.d(A, "a", function() {
+ return T;
+ }), f.d(A, "c", function() {
+ return E;
+ });
+ var V = f(14), _ = f(28), C = f(44), u = f(11), I = f(74), O = function() {
+ function g(l, h) {
+ l === void 0 && (l = 0), h === void 0 && (h = 0), this.x = l, this.y = h;
+ }
+ return g.prototype.toString = function() {
+ return "{X: " + this.x + " Y: " + this.y + "}";
+ }, g.prototype.getClassName = function() {
+ return "Vector2";
+ }, g.prototype.getHashCode = function() {
+ var l = 0 | this.x;
+ return l = 397 * l ^ (0 | this.y);
+ }, g.prototype.toArray = function(l, h) {
+ return h === void 0 && (h = 0), l[h] = this.x, l[h + 1] = this.y, this;
+ }, g.prototype.fromArray = function(l, h) {
+ return h === void 0 && (h = 0), g.FromArrayToRef(l, h, this), this;
+ }, g.prototype.asArray = function() {
+ var l = new Array();
+ return this.toArray(l, 0), l;
+ }, g.prototype.copyFrom = function(l) {
+ return this.x = l.x, this.y = l.y, this;
+ }, g.prototype.copyFromFloats = function(l, h) {
+ return this.x = l, this.y = h, this;
+ }, g.prototype.set = function(l, h) {
+ return this.copyFromFloats(l, h);
+ }, g.prototype.add = function(l) {
+ return new g(this.x + l.x, this.y + l.y);
+ }, g.prototype.addToRef = function(l, h) {
+ return h.x = this.x + l.x, h.y = this.y + l.y, this;
+ }, g.prototype.addInPlace = function(l) {
+ return this.x += l.x, this.y += l.y, this;
+ }, g.prototype.addVector3 = function(l) {
+ return new g(this.x + l.x, this.y + l.y);
+ }, g.prototype.subtract = function(l) {
+ return new g(this.x - l.x, this.y - l.y);
+ }, g.prototype.subtractToRef = function(l, h) {
+ return h.x = this.x - l.x, h.y = this.y - l.y, this;
+ }, g.prototype.subtractInPlace = function(l) {
+ return this.x -= l.x, this.y -= l.y, this;
+ }, g.prototype.multiplyInPlace = function(l) {
+ return this.x *= l.x, this.y *= l.y, this;
+ }, g.prototype.multiply = function(l) {
+ return new g(this.x * l.x, this.y * l.y);
+ }, g.prototype.multiplyToRef = function(l, h) {
+ return h.x = this.x * l.x, h.y = this.y * l.y, this;
+ }, g.prototype.multiplyByFloats = function(l, h) {
+ return new g(this.x * l, this.y * h);
+ }, g.prototype.divide = function(l) {
+ return new g(this.x / l.x, this.y / l.y);
+ }, g.prototype.divideToRef = function(l, h) {
+ return h.x = this.x / l.x, h.y = this.y / l.y, this;
+ }, g.prototype.divideInPlace = function(l) {
+ return this.divideToRef(l, this);
+ }, g.prototype.negate = function() {
+ return new g(-this.x, -this.y);
+ }, g.prototype.negateInPlace = function() {
+ return this.x *= -1, this.y *= -1, this;
+ }, g.prototype.negateToRef = function(l) {
+ return l.copyFromFloats(-1 * this.x, -1 * this.y);
+ }, g.prototype.scaleInPlace = function(l) {
+ return this.x *= l, this.y *= l, this;
+ }, g.prototype.scale = function(l) {
+ var h = new g(0, 0);
+ return this.scaleToRef(l, h), h;
+ }, g.prototype.scaleToRef = function(l, h) {
+ return h.x = this.x * l, h.y = this.y * l, this;
+ }, g.prototype.scaleAndAddToRef = function(l, h) {
+ return h.x += this.x * l, h.y += this.y * l, this;
+ }, g.prototype.equals = function(l) {
+ return l && this.x === l.x && this.y === l.y;
+ }, g.prototype.equalsWithEpsilon = function(l, h) {
+ return h === void 0 && (h = _.a), l && V.a.WithinEpsilon(this.x, l.x, h) && V.a.WithinEpsilon(this.y, l.y, h);
+ }, g.prototype.floor = function() {
+ return new g(Math.floor(this.x), Math.floor(this.y));
+ }, g.prototype.fract = function() {
+ return new g(this.x - Math.floor(this.x), this.y - Math.floor(this.y));
+ }, g.prototype.length = function() {
+ return Math.sqrt(this.x * this.x + this.y * this.y);
+ }, g.prototype.lengthSquared = function() {
+ return this.x * this.x + this.y * this.y;
+ }, g.prototype.normalize = function() {
+ var l = this.length();
+ return l === 0 || (this.x /= l, this.y /= l), this;
+ }, g.prototype.clone = function() {
+ return new g(this.x, this.y);
+ }, g.Zero = function() {
+ return new g(0, 0);
+ }, g.One = function() {
+ return new g(1, 1);
+ }, g.FromArray = function(l, h) {
+ return h === void 0 && (h = 0), new g(l[h], l[h + 1]);
+ }, g.FromArrayToRef = function(l, h, v) {
+ v.x = l[h], v.y = l[h + 1];
+ }, g.CatmullRom = function(l, h, v, b, D) {
+ var w = D * D, N = D * w;
+ return new g(0.5 * (2 * h.x + (-l.x + v.x) * D + (2 * l.x - 5 * h.x + 4 * v.x - b.x) * w + (-l.x + 3 * h.x - 3 * v.x + b.x) * N), 0.5 * (2 * h.y + (-l.y + v.y) * D + (2 * l.y - 5 * h.y + 4 * v.y - b.y) * w + (-l.y + 3 * h.y - 3 * v.y + b.y) * N));
+ }, g.Clamp = function(l, h, v) {
+ var b = l.x;
+ b = (b = b > v.x ? v.x : b) < h.x ? h.x : b;
+ var D = l.y;
+ return new g(b, D = (D = D > v.y ? v.y : D) < h.y ? h.y : D);
+ }, g.Hermite = function(l, h, v, b, D) {
+ var w = D * D, N = D * w, M = 2 * N - 3 * w + 1, U = -2 * N + 3 * w, X = N - 2 * w + D, j = N - w;
+ return new g(l.x * M + v.x * U + h.x * X + b.x * j, l.y * M + v.y * U + h.y * X + b.y * j);
+ }, g.Lerp = function(l, h, v) {
+ return new g(l.x + (h.x - l.x) * v, l.y + (h.y - l.y) * v);
+ }, g.Dot = function(l, h) {
+ return l.x * h.x + l.y * h.y;
+ }, g.Normalize = function(l) {
+ var h = l.clone();
+ return h.normalize(), h;
+ }, g.Minimize = function(l, h) {
+ return new g(l.x < h.x ? l.x : h.x, l.y < h.y ? l.y : h.y);
+ }, g.Maximize = function(l, h) {
+ return new g(l.x > h.x ? l.x : h.x, l.y > h.y ? l.y : h.y);
+ }, g.Transform = function(l, h) {
+ var v = g.Zero();
+ return g.TransformToRef(l, h, v), v;
+ }, g.TransformToRef = function(l, h, v) {
+ var b = h.m, D = l.x * b[0] + l.y * b[4] + b[12], w = l.x * b[1] + l.y * b[5] + b[13];
+ v.x = D, v.y = w;
+ }, g.PointInTriangle = function(l, h, v, b) {
+ var D = 0.5 * (-v.y * b.x + h.y * (-v.x + b.x) + h.x * (v.y - b.y) + v.x * b.y), w = D < 0 ? -1 : 1, N = (h.y * b.x - h.x * b.y + (b.y - h.y) * l.x + (h.x - b.x) * l.y) * w, M = (h.x * v.y - h.y * v.x + (h.y - v.y) * l.x + (v.x - h.x) * l.y) * w;
+ return N > 0 && M > 0 && N + M < 2 * D * w;
+ }, g.Distance = function(l, h) {
+ return Math.sqrt(g.DistanceSquared(l, h));
+ }, g.DistanceSquared = function(l, h) {
+ var v = l.x - h.x, b = l.y - h.y;
+ return v * v + b * b;
+ }, g.Center = function(l, h) {
+ var v = l.add(h);
+ return v.scaleInPlace(0.5), v;
+ }, g.DistanceOfPointFromSegment = function(l, h, v) {
+ var b = g.DistanceSquared(h, v);
+ if (b === 0)
+ return g.Distance(l, h);
+ var D = v.subtract(h), w = Math.max(0, Math.min(1, g.Dot(l.subtract(h), D) / b)), N = h.add(D.multiplyByFloats(w, w));
+ return g.Distance(l, N);
+ }, g;
+ }(), x = function() {
+ function g(l, h, v) {
+ l === void 0 && (l = 0), h === void 0 && (h = 0), v === void 0 && (v = 0), this._isDirty = !0, this._x = l, this._y = h, this._z = v;
+ }
+ return Object.defineProperty(g.prototype, "x", { get: function() {
+ return this._x;
+ }, set: function(l) {
+ this._x = l, this._isDirty = !0;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(g.prototype, "y", { get: function() {
+ return this._y;
+ }, set: function(l) {
+ this._y = l, this._isDirty = !0;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(g.prototype, "z", { get: function() {
+ return this._z;
+ }, set: function(l) {
+ this._z = l, this._isDirty = !0;
+ }, enumerable: !1, configurable: !0 }), g.prototype.toString = function() {
+ return "{X: " + this._x + " Y:" + this._y + " Z:" + this._z + "}";
+ }, g.prototype.getClassName = function() {
+ return "Vector3";
+ }, g.prototype.getHashCode = function() {
+ var l = 0 | this._x;
+ return l = 397 * (l = 397 * l ^ (0 | this._y)) ^ (0 | this._z);
+ }, g.prototype.asArray = function() {
+ var l = [];
+ return this.toArray(l, 0), l;
+ }, g.prototype.toArray = function(l, h) {
+ return h === void 0 && (h = 0), l[h] = this._x, l[h + 1] = this._y, l[h + 2] = this._z, this;
+ }, g.prototype.fromArray = function(l, h) {
+ return h === void 0 && (h = 0), g.FromArrayToRef(l, h, this), this;
+ }, g.prototype.toQuaternion = function() {
+ return c.RotationYawPitchRoll(this._y, this._x, this._z);
+ }, g.prototype.addInPlace = function(l) {
+ return this.addInPlaceFromFloats(l._x, l._y, l._z);
+ }, g.prototype.addInPlaceFromFloats = function(l, h, v) {
+ return this.x += l, this.y += h, this.z += v, this;
+ }, g.prototype.add = function(l) {
+ return new g(this._x + l._x, this._y + l._y, this._z + l._z);
+ }, g.prototype.addToRef = function(l, h) {
+ return h.copyFromFloats(this._x + l._x, this._y + l._y, this._z + l._z);
+ }, g.prototype.subtractInPlace = function(l) {
+ return this.x -= l._x, this.y -= l._y, this.z -= l._z, this;
+ }, g.prototype.subtract = function(l) {
+ return new g(this._x - l._x, this._y - l._y, this._z - l._z);
+ }, g.prototype.subtractToRef = function(l, h) {
+ return this.subtractFromFloatsToRef(l._x, l._y, l._z, h);
+ }, g.prototype.subtractFromFloats = function(l, h, v) {
+ return new g(this._x - l, this._y - h, this._z - v);
+ }, g.prototype.subtractFromFloatsToRef = function(l, h, v, b) {
+ return b.copyFromFloats(this._x - l, this._y - h, this._z - v);
+ }, g.prototype.negate = function() {
+ return new g(-this._x, -this._y, -this._z);
+ }, g.prototype.negateInPlace = function() {
+ return this.x *= -1, this.y *= -1, this.z *= -1, this;
+ }, g.prototype.negateToRef = function(l) {
+ return l.copyFromFloats(-1 * this._x, -1 * this._y, -1 * this._z);
+ }, g.prototype.scaleInPlace = function(l) {
+ return this.x *= l, this.y *= l, this.z *= l, this;
+ }, g.prototype.scale = function(l) {
+ return new g(this._x * l, this._y * l, this._z * l);
+ }, g.prototype.scaleToRef = function(l, h) {
+ return h.copyFromFloats(this._x * l, this._y * l, this._z * l);
+ }, g.prototype.scaleAndAddToRef = function(l, h) {
+ return h.addInPlaceFromFloats(this._x * l, this._y * l, this._z * l);
+ }, g.prototype.projectOnPlane = function(l, h) {
+ var v = g.Zero();
+ return this.projectOnPlaneToRef(l, h, v), v;
+ }, g.prototype.projectOnPlaneToRef = function(l, h, v) {
+ var b = l.normal, D = l.d, w = S.Vector3[0];
+ this.subtractToRef(h, w), w.normalize();
+ var N = g.Dot(w, b), M = -(g.Dot(h, b) + D) / N, U = w.scaleInPlace(M);
+ h.addToRef(U, v);
+ }, g.prototype.equals = function(l) {
+ return l && this._x === l._x && this._y === l._y && this._z === l._z;
+ }, g.prototype.equalsWithEpsilon = function(l, h) {
+ return h === void 0 && (h = _.a), l && V.a.WithinEpsilon(this._x, l._x, h) && V.a.WithinEpsilon(this._y, l._y, h) && V.a.WithinEpsilon(this._z, l._z, h);
+ }, g.prototype.equalsToFloats = function(l, h, v) {
+ return this._x === l && this._y === h && this._z === v;
+ }, g.prototype.multiplyInPlace = function(l) {
+ return this.x *= l._x, this.y *= l._y, this.z *= l._z, this;
+ }, g.prototype.multiply = function(l) {
+ return this.multiplyByFloats(l._x, l._y, l._z);
+ }, g.prototype.multiplyToRef = function(l, h) {
+ return h.copyFromFloats(this._x * l._x, this._y * l._y, this._z * l._z);
+ }, g.prototype.multiplyByFloats = function(l, h, v) {
+ return new g(this._x * l, this._y * h, this._z * v);
+ }, g.prototype.divide = function(l) {
+ return new g(this._x / l._x, this._y / l._y, this._z / l._z);
+ }, g.prototype.divideToRef = function(l, h) {
+ return h.copyFromFloats(this._x / l._x, this._y / l._y, this._z / l._z);
+ }, g.prototype.divideInPlace = function(l) {
+ return this.divideToRef(l, this);
+ }, g.prototype.minimizeInPlace = function(l) {
+ return this.minimizeInPlaceFromFloats(l._x, l._y, l._z);
+ }, g.prototype.maximizeInPlace = function(l) {
+ return this.maximizeInPlaceFromFloats(l._x, l._y, l._z);
+ }, g.prototype.minimizeInPlaceFromFloats = function(l, h, v) {
+ return l < this._x && (this.x = l), h < this._y && (this.y = h), v < this._z && (this.z = v), this;
+ }, g.prototype.maximizeInPlaceFromFloats = function(l, h, v) {
+ return l > this._x && (this.x = l), h > this._y && (this.y = h), v > this._z && (this.z = v), this;
+ }, g.prototype.isNonUniformWithinEpsilon = function(l) {
+ var h = Math.abs(this._x), v = Math.abs(this._y);
+ if (!V.a.WithinEpsilon(h, v, l))
+ return !0;
+ var b = Math.abs(this._z);
+ return !V.a.WithinEpsilon(h, b, l) || !V.a.WithinEpsilon(v, b, l);
+ }, Object.defineProperty(g.prototype, "isNonUniform", { get: function() {
+ var l = Math.abs(this._x);
+ return l !== Math.abs(this._y) || l !== Math.abs(this._z);
+ }, enumerable: !1, configurable: !0 }), g.prototype.floor = function() {
+ return new g(Math.floor(this._x), Math.floor(this._y), Math.floor(this._z));
+ }, g.prototype.fract = function() {
+ return new g(this._x - Math.floor(this._x), this._y - Math.floor(this._y), this._z - Math.floor(this._z));
+ }, g.prototype.length = function() {
+ return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z);
+ }, g.prototype.lengthSquared = function() {
+ return this._x * this._x + this._y * this._y + this._z * this._z;
+ }, g.prototype.normalize = function() {
+ return this.normalizeFromLength(this.length());
+ }, g.prototype.reorderInPlace = function(l) {
+ var h = this;
+ return (l = l.toLowerCase()) === "xyz" || (S.Vector3[0].copyFrom(this), ["x", "y", "z"].forEach(function(v, b) {
+ h[v] = S.Vector3[0][l[b]];
+ })), this;
+ }, g.prototype.rotateByQuaternionToRef = function(l, h) {
+ return l.toRotationMatrix(S.Matrix[0]), g.TransformCoordinatesToRef(this, S.Matrix[0], h), h;
+ }, g.prototype.rotateByQuaternionAroundPointToRef = function(l, h, v) {
+ return this.subtractToRef(h, S.Vector3[0]), S.Vector3[0].rotateByQuaternionToRef(l, S.Vector3[0]), h.addToRef(S.Vector3[0], v), v;
+ }, g.prototype.cross = function(l) {
+ return g.Cross(this, l);
+ }, g.prototype.normalizeFromLength = function(l) {
+ return l === 0 || l === 1 ? this : this.scaleInPlace(1 / l);
+ }, g.prototype.normalizeToNew = function() {
+ var l = new g(0, 0, 0);
+ return this.normalizeToRef(l), l;
+ }, g.prototype.normalizeToRef = function(l) {
+ var h = this.length();
+ return h === 0 || h === 1 ? l.copyFromFloats(this._x, this._y, this._z) : this.scaleToRef(1 / h, l);
+ }, g.prototype.clone = function() {
+ return new g(this._x, this._y, this._z);
+ }, g.prototype.copyFrom = function(l) {
+ return this.copyFromFloats(l._x, l._y, l._z);
+ }, g.prototype.copyFromFloats = function(l, h, v) {
+ return this.x = l, this.y = h, this.z = v, this;
+ }, g.prototype.set = function(l, h, v) {
+ return this.copyFromFloats(l, h, v);
+ }, g.prototype.setAll = function(l) {
+ return this.x = this.y = this.z = l, this;
+ }, g.GetClipFactor = function(l, h, v, b) {
+ var D = g.Dot(l, v) - b;
+ return D / (D - (g.Dot(h, v) - b));
+ }, g.GetAngleBetweenVectors = function(l, h, v) {
+ var b = l.normalizeToRef(S.Vector3[1]), D = h.normalizeToRef(S.Vector3[2]), w = g.Dot(b, D), N = S.Vector3[3];
+ return g.CrossToRef(b, D, N), g.Dot(N, v) > 0 ? Math.acos(w) : -Math.acos(w);
+ }, g.FromArray = function(l, h) {
+ return h === void 0 && (h = 0), new g(l[h], l[h + 1], l[h + 2]);
+ }, g.FromFloatArray = function(l, h) {
+ return g.FromArray(l, h);
+ }, g.FromArrayToRef = function(l, h, v) {
+ v.x = l[h], v.y = l[h + 1], v.z = l[h + 2];
+ }, g.FromFloatArrayToRef = function(l, h, v) {
+ return g.FromArrayToRef(l, h, v);
+ }, g.FromFloatsToRef = function(l, h, v, b) {
+ b.copyFromFloats(l, h, v);
+ }, g.Zero = function() {
+ return new g(0, 0, 0);
+ }, g.One = function() {
+ return new g(1, 1, 1);
+ }, g.Up = function() {
+ return new g(0, 1, 0);
+ }, Object.defineProperty(g, "UpReadOnly", { get: function() {
+ return g._UpReadOnly;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(g, "ZeroReadOnly", { get: function() {
+ return g._ZeroReadOnly;
+ }, enumerable: !1, configurable: !0 }), g.Down = function() {
+ return new g(0, -1, 0);
+ }, g.Forward = function(l) {
+ return l === void 0 && (l = !1), new g(0, 0, l ? -1 : 1);
+ }, g.Backward = function(l) {
+ return l === void 0 && (l = !1), new g(0, 0, l ? 1 : -1);
+ }, g.Right = function() {
+ return new g(1, 0, 0);
+ }, g.Left = function() {
+ return new g(-1, 0, 0);
+ }, g.TransformCoordinates = function(l, h) {
+ var v = g.Zero();
+ return g.TransformCoordinatesToRef(l, h, v), v;
+ }, g.TransformCoordinatesToRef = function(l, h, v) {
+ g.TransformCoordinatesFromFloatsToRef(l._x, l._y, l._z, h, v);
+ }, g.TransformCoordinatesFromFloatsToRef = function(l, h, v, b, D) {
+ var w = b.m, N = l * w[0] + h * w[4] + v * w[8] + w[12], M = l * w[1] + h * w[5] + v * w[9] + w[13], U = l * w[2] + h * w[6] + v * w[10] + w[14], X = 1 / (l * w[3] + h * w[7] + v * w[11] + w[15]);
+ D.x = N * X, D.y = M * X, D.z = U * X;
+ }, g.TransformNormal = function(l, h) {
+ var v = g.Zero();
+ return g.TransformNormalToRef(l, h, v), v;
+ }, g.TransformNormalToRef = function(l, h, v) {
+ this.TransformNormalFromFloatsToRef(l._x, l._y, l._z, h, v);
+ }, g.TransformNormalFromFloatsToRef = function(l, h, v, b, D) {
+ var w = b.m;
+ D.x = l * w[0] + h * w[4] + v * w[8], D.y = l * w[1] + h * w[5] + v * w[9], D.z = l * w[2] + h * w[6] + v * w[10];
+ }, g.CatmullRom = function(l, h, v, b, D) {
+ var w = D * D, N = D * w;
+ return new g(0.5 * (2 * h._x + (-l._x + v._x) * D + (2 * l._x - 5 * h._x + 4 * v._x - b._x) * w + (-l._x + 3 * h._x - 3 * v._x + b._x) * N), 0.5 * (2 * h._y + (-l._y + v._y) * D + (2 * l._y - 5 * h._y + 4 * v._y - b._y) * w + (-l._y + 3 * h._y - 3 * v._y + b._y) * N), 0.5 * (2 * h._z + (-l._z + v._z) * D + (2 * l._z - 5 * h._z + 4 * v._z - b._z) * w + (-l._z + 3 * h._z - 3 * v._z + b._z) * N));
+ }, g.Clamp = function(l, h, v) {
+ var b = new g();
+ return g.ClampToRef(l, h, v, b), b;
+ }, g.ClampToRef = function(l, h, v, b) {
+ var D = l._x;
+ D = (D = D > v._x ? v._x : D) < h._x ? h._x : D;
+ var w = l._y;
+ w = (w = w > v._y ? v._y : w) < h._y ? h._y : w;
+ var N = l._z;
+ N = (N = N > v._z ? v._z : N) < h._z ? h._z : N, b.copyFromFloats(D, w, N);
+ }, g.CheckExtends = function(l, h, v) {
+ h.minimizeInPlace(l), v.maximizeInPlace(l);
+ }, g.Hermite = function(l, h, v, b, D) {
+ var w = D * D, N = D * w, M = 2 * N - 3 * w + 1, U = -2 * N + 3 * w, X = N - 2 * w + D, j = N - w;
+ return new g(l._x * M + v._x * U + h._x * X + b._x * j, l._y * M + v._y * U + h._y * X + b._y * j, l._z * M + v._z * U + h._z * X + b._z * j);
+ }, g.Lerp = function(l, h, v) {
+ var b = new g(0, 0, 0);
+ return g.LerpToRef(l, h, v, b), b;
+ }, g.LerpToRef = function(l, h, v, b) {
+ b.x = l._x + (h._x - l._x) * v, b.y = l._y + (h._y - l._y) * v, b.z = l._z + (h._z - l._z) * v;
+ }, g.Dot = function(l, h) {
+ return l._x * h._x + l._y * h._y + l._z * h._z;
+ }, g.Cross = function(l, h) {
+ var v = g.Zero();
+ return g.CrossToRef(l, h, v), v;
+ }, g.CrossToRef = function(l, h, v) {
+ var b = l._y * h._z - l._z * h._y, D = l._z * h._x - l._x * h._z, w = l._x * h._y - l._y * h._x;
+ v.copyFromFloats(b, D, w);
+ }, g.Normalize = function(l) {
+ var h = g.Zero();
+ return g.NormalizeToRef(l, h), h;
+ }, g.NormalizeToRef = function(l, h) {
+ l.normalizeToRef(h);
+ }, g.Project = function(l, h, v, b) {
+ var D = new g();
+ return g.ProjectToRef(l, h, v, b, D), D;
+ }, g.ProjectToRef = function(l, h, v, b, D) {
+ var w = b.width, N = b.height, M = b.x, U = b.y, X = S.Matrix[1];
+ T.FromValuesToRef(w / 2, 0, 0, 0, 0, -N / 2, 0, 0, 0, 0, 0.5, 0, M + w / 2, N / 2 + U, 0.5, 1, X);
+ var j = S.Matrix[0];
+ return h.multiplyToRef(v, j), j.multiplyToRef(X, j), g.TransformCoordinatesToRef(l, j, D), D;
+ }, g._UnprojectFromInvertedMatrixToRef = function(l, h, v) {
+ g.TransformCoordinatesToRef(l, h, v);
+ var b = h.m, D = l._x * b[3] + l._y * b[7] + l._z * b[11] + b[15];
+ V.a.WithinEpsilon(D, 1) && v.scaleInPlace(1 / D);
+ }, g.UnprojectFromTransform = function(l, h, v, b, D) {
+ var w = S.Matrix[0];
+ b.multiplyToRef(D, w), w.invert(), l.x = l._x / h * 2 - 1, l.y = -(l._y / v * 2 - 1);
+ var N = new g();
+ return g._UnprojectFromInvertedMatrixToRef(l, w, N), N;
+ }, g.Unproject = function(l, h, v, b, D, w) {
+ var N = g.Zero();
+ return g.UnprojectToRef(l, h, v, b, D, w, N), N;
+ }, g.UnprojectToRef = function(l, h, v, b, D, w, N) {
+ g.UnprojectFloatsToRef(l._x, l._y, l._z, h, v, b, D, w, N);
+ }, g.UnprojectFloatsToRef = function(l, h, v, b, D, w, N, M, U) {
+ var X = S.Matrix[0];
+ w.multiplyToRef(N, X), X.multiplyToRef(M, X), X.invert();
+ var j = S.Vector3[0];
+ j.x = l / b * 2 - 1, j.y = -(h / D * 2 - 1), j.z = 2 * v - 1, g._UnprojectFromInvertedMatrixToRef(j, X, U);
+ }, g.Minimize = function(l, h) {
+ var v = l.clone();
+ return v.minimizeInPlace(h), v;
+ }, g.Maximize = function(l, h) {
+ var v = l.clone();
+ return v.maximizeInPlace(h), v;
+ }, g.Distance = function(l, h) {
+ return Math.sqrt(g.DistanceSquared(l, h));
+ }, g.DistanceSquared = function(l, h) {
+ var v = l._x - h._x, b = l._y - h._y, D = l._z - h._z;
+ return v * v + b * b + D * D;
+ }, g.Center = function(l, h) {
+ var v = l.add(h);
+ return v.scaleInPlace(0.5), v;
+ }, g.RotationFromAxis = function(l, h, v) {
+ var b = g.Zero();
+ return g.RotationFromAxisToRef(l, h, v, b), b;
+ }, g.RotationFromAxisToRef = function(l, h, v, b) {
+ var D = S.Quaternion[0];
+ c.RotationQuaternionFromAxisToRef(l, h, v, D), D.toEulerAnglesToRef(b);
+ }, g._UpReadOnly = g.Up(), g._ZeroReadOnly = g.Zero(), g;
+ }(), m = function() {
+ function g(l, h, v, b) {
+ this.x = l, this.y = h, this.z = v, this.w = b;
+ }
+ return g.prototype.toString = function() {
+ return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
+ }, g.prototype.getClassName = function() {
+ return "Vector4";
+ }, g.prototype.getHashCode = function() {
+ var l = 0 | this.x;
+ return l = 397 * (l = 397 * (l = 397 * l ^ (0 | this.y)) ^ (0 | this.z)) ^ (0 | this.w);
+ }, g.prototype.asArray = function() {
+ var l = new Array();
+ return this.toArray(l, 0), l;
+ }, g.prototype.toArray = function(l, h) {
+ return h === void 0 && (h = 0), l[h] = this.x, l[h + 1] = this.y, l[h + 2] = this.z, l[h + 3] = this.w, this;
+ }, g.prototype.fromArray = function(l, h) {
+ return h === void 0 && (h = 0), g.FromArrayToRef(l, h, this), this;
+ }, g.prototype.addInPlace = function(l) {
+ return this.x += l.x, this.y += l.y, this.z += l.z, this.w += l.w, this;
+ }, g.prototype.add = function(l) {
+ return new g(this.x + l.x, this.y + l.y, this.z + l.z, this.w + l.w);
+ }, g.prototype.addToRef = function(l, h) {
+ return h.x = this.x + l.x, h.y = this.y + l.y, h.z = this.z + l.z, h.w = this.w + l.w, this;
+ }, g.prototype.subtractInPlace = function(l) {
+ return this.x -= l.x, this.y -= l.y, this.z -= l.z, this.w -= l.w, this;
+ }, g.prototype.subtract = function(l) {
+ return new g(this.x - l.x, this.y - l.y, this.z - l.z, this.w - l.w);
+ }, g.prototype.subtractToRef = function(l, h) {
+ return h.x = this.x - l.x, h.y = this.y - l.y, h.z = this.z - l.z, h.w = this.w - l.w, this;
+ }, g.prototype.subtractFromFloats = function(l, h, v, b) {
+ return new g(this.x - l, this.y - h, this.z - v, this.w - b);
+ }, g.prototype.subtractFromFloatsToRef = function(l, h, v, b, D) {
+ return D.x = this.x - l, D.y = this.y - h, D.z = this.z - v, D.w = this.w - b, this;
+ }, g.prototype.negate = function() {
+ return new g(-this.x, -this.y, -this.z, -this.w);
+ }, g.prototype.negateInPlace = function() {
+ return this.x *= -1, this.y *= -1, this.z *= -1, this.w *= -1, this;
+ }, g.prototype.negateToRef = function(l) {
+ return l.copyFromFloats(-1 * this.x, -1 * this.y, -1 * this.z, -1 * this.w);
+ }, g.prototype.scaleInPlace = function(l) {
+ return this.x *= l, this.y *= l, this.z *= l, this.w *= l, this;
+ }, g.prototype.scale = function(l) {
+ return new g(this.x * l, this.y * l, this.z * l, this.w * l);
+ }, g.prototype.scaleToRef = function(l, h) {
+ return h.x = this.x * l, h.y = this.y * l, h.z = this.z * l, h.w = this.w * l, this;
+ }, g.prototype.scaleAndAddToRef = function(l, h) {
+ return h.x += this.x * l, h.y += this.y * l, h.z += this.z * l, h.w += this.w * l, this;
+ }, g.prototype.equals = function(l) {
+ return l && this.x === l.x && this.y === l.y && this.z === l.z && this.w === l.w;
+ }, g.prototype.equalsWithEpsilon = function(l, h) {
+ return h === void 0 && (h = _.a), l && V.a.WithinEpsilon(this.x, l.x, h) && V.a.WithinEpsilon(this.y, l.y, h) && V.a.WithinEpsilon(this.z, l.z, h) && V.a.WithinEpsilon(this.w, l.w, h);
+ }, g.prototype.equalsToFloats = function(l, h, v, b) {
+ return this.x === l && this.y === h && this.z === v && this.w === b;
+ }, g.prototype.multiplyInPlace = function(l) {
+ return this.x *= l.x, this.y *= l.y, this.z *= l.z, this.w *= l.w, this;
+ }, g.prototype.multiply = function(l) {
+ return new g(this.x * l.x, this.y * l.y, this.z * l.z, this.w * l.w);
+ }, g.prototype.multiplyToRef = function(l, h) {
+ return h.x = this.x * l.x, h.y = this.y * l.y, h.z = this.z * l.z, h.w = this.w * l.w, this;
+ }, g.prototype.multiplyByFloats = function(l, h, v, b) {
+ return new g(this.x * l, this.y * h, this.z * v, this.w * b);
+ }, g.prototype.divide = function(l) {
+ return new g(this.x / l.x, this.y / l.y, this.z / l.z, this.w / l.w);
+ }, g.prototype.divideToRef = function(l, h) {
+ return h.x = this.x / l.x, h.y = this.y / l.y, h.z = this.z / l.z, h.w = this.w / l.w, this;
+ }, g.prototype.divideInPlace = function(l) {
+ return this.divideToRef(l, this);
+ }, g.prototype.minimizeInPlace = function(l) {
+ return l.x < this.x && (this.x = l.x), l.y < this.y && (this.y = l.y), l.z < this.z && (this.z = l.z), l.w < this.w && (this.w = l.w), this;
+ }, g.prototype.maximizeInPlace = function(l) {
+ return l.x > this.x && (this.x = l.x), l.y > this.y && (this.y = l.y), l.z > this.z && (this.z = l.z), l.w > this.w && (this.w = l.w), this;
+ }, g.prototype.floor = function() {
+ return new g(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z), Math.floor(this.w));
+ }, g.prototype.fract = function() {
+ return new g(this.x - Math.floor(this.x), this.y - Math.floor(this.y), this.z - Math.floor(this.z), this.w - Math.floor(this.w));
+ }, g.prototype.length = function() {
+ return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
+ }, g.prototype.lengthSquared = function() {
+ return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
+ }, g.prototype.normalize = function() {
+ var l = this.length();
+ return l === 0 ? this : this.scaleInPlace(1 / l);
+ }, g.prototype.toVector3 = function() {
+ return new x(this.x, this.y, this.z);
+ }, g.prototype.clone = function() {
+ return new g(this.x, this.y, this.z, this.w);
+ }, g.prototype.copyFrom = function(l) {
+ return this.x = l.x, this.y = l.y, this.z = l.z, this.w = l.w, this;
+ }, g.prototype.copyFromFloats = function(l, h, v, b) {
+ return this.x = l, this.y = h, this.z = v, this.w = b, this;
+ }, g.prototype.set = function(l, h, v, b) {
+ return this.copyFromFloats(l, h, v, b);
+ }, g.prototype.setAll = function(l) {
+ return this.x = this.y = this.z = this.w = l, this;
+ }, g.FromArray = function(l, h) {
+ return h || (h = 0), new g(l[h], l[h + 1], l[h + 2], l[h + 3]);
+ }, g.FromArrayToRef = function(l, h, v) {
+ v.x = l[h], v.y = l[h + 1], v.z = l[h + 2], v.w = l[h + 3];
+ }, g.FromFloatArrayToRef = function(l, h, v) {
+ g.FromArrayToRef(l, h, v);
+ }, g.FromFloatsToRef = function(l, h, v, b, D) {
+ D.x = l, D.y = h, D.z = v, D.w = b;
+ }, g.Zero = function() {
+ return new g(0, 0, 0, 0);
+ }, g.One = function() {
+ return new g(1, 1, 1, 1);
+ }, g.Normalize = function(l) {
+ var h = g.Zero();
+ return g.NormalizeToRef(l, h), h;
+ }, g.NormalizeToRef = function(l, h) {
+ h.copyFrom(l), h.normalize();
+ }, g.Minimize = function(l, h) {
+ var v = l.clone();
+ return v.minimizeInPlace(h), v;
+ }, g.Maximize = function(l, h) {
+ var v = l.clone();
+ return v.maximizeInPlace(h), v;
+ }, g.Distance = function(l, h) {
+ return Math.sqrt(g.DistanceSquared(l, h));
+ }, g.DistanceSquared = function(l, h) {
+ var v = l.x - h.x, b = l.y - h.y, D = l.z - h.z, w = l.w - h.w;
+ return v * v + b * b + D * D + w * w;
+ }, g.Center = function(l, h) {
+ var v = l.add(h);
+ return v.scaleInPlace(0.5), v;
+ }, g.TransformNormal = function(l, h) {
+ var v = g.Zero();
+ return g.TransformNormalToRef(l, h, v), v;
+ }, g.TransformNormalToRef = function(l, h, v) {
+ var b = h.m, D = l.x * b[0] + l.y * b[4] + l.z * b[8], w = l.x * b[1] + l.y * b[5] + l.z * b[9], N = l.x * b[2] + l.y * b[6] + l.z * b[10];
+ v.x = D, v.y = w, v.z = N, v.w = l.w;
+ }, g.TransformNormalFromFloatsToRef = function(l, h, v, b, D, w) {
+ var N = D.m;
+ w.x = l * N[0] + h * N[4] + v * N[8], w.y = l * N[1] + h * N[5] + v * N[9], w.z = l * N[2] + h * N[6] + v * N[10], w.w = b;
+ }, g.FromVector3 = function(l, h) {
+ return h === void 0 && (h = 0), new g(l._x, l._y, l._z, h);
+ }, g;
+ }(), c = function() {
+ function g(l, h, v, b) {
+ l === void 0 && (l = 0), h === void 0 && (h = 0), v === void 0 && (v = 0), b === void 0 && (b = 1), this._isDirty = !0, this._x = l, this._y = h, this._z = v, this._w = b;
+ }
+ return Object.defineProperty(g.prototype, "x", { get: function() {
+ return this._x;
+ }, set: function(l) {
+ this._x = l, this._isDirty = !0;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(g.prototype, "y", { get: function() {
+ return this._y;
+ }, set: function(l) {
+ this._y = l, this._isDirty = !0;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(g.prototype, "z", { get: function() {
+ return this._z;
+ }, set: function(l) {
+ this._z = l, this._isDirty = !0;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(g.prototype, "w", { get: function() {
+ return this._w;
+ }, set: function(l) {
+ this._w = l, this._isDirty = !0;
+ }, enumerable: !1, configurable: !0 }), g.prototype.toString = function() {
+ return "{X: " + this._x + " Y:" + this._y + " Z:" + this._z + " W:" + this._w + "}";
+ }, g.prototype.getClassName = function() {
+ return "Quaternion";
+ }, g.prototype.getHashCode = function() {
+ var l = 0 | this._x;
+ return l = 397 * (l = 397 * (l = 397 * l ^ (0 | this._y)) ^ (0 | this._z)) ^ (0 | this._w);
+ }, g.prototype.asArray = function() {
+ return [this._x, this._y, this._z, this._w];
+ }, g.prototype.equals = function(l) {
+ return l && this._x === l._x && this._y === l._y && this._z === l._z && this._w === l._w;
+ }, g.prototype.equalsWithEpsilon = function(l, h) {
+ return h === void 0 && (h = _.a), l && V.a.WithinEpsilon(this._x, l._x, h) && V.a.WithinEpsilon(this._y, l._y, h) && V.a.WithinEpsilon(this._z, l._z, h) && V.a.WithinEpsilon(this._w, l._w, h);
+ }, g.prototype.clone = function() {
+ return new g(this._x, this._y, this._z, this._w);
+ }, g.prototype.copyFrom = function(l) {
+ return this.x = l._x, this.y = l._y, this.z = l._z, this.w = l._w, this;
+ }, g.prototype.copyFromFloats = function(l, h, v, b) {
+ return this.x = l, this.y = h, this.z = v, this.w = b, this;
+ }, g.prototype.set = function(l, h, v, b) {
+ return this.copyFromFloats(l, h, v, b);
+ }, g.prototype.add = function(l) {
+ return new g(this._x + l._x, this._y + l._y, this._z + l._z, this._w + l._w);
+ }, g.prototype.addInPlace = function(l) {
+ return this._x += l._x, this._y += l._y, this._z += l._z, this._w += l._w, this;
+ }, g.prototype.subtract = function(l) {
+ return new g(this._x - l._x, this._y - l._y, this._z - l._z, this._w - l._w);
+ }, g.prototype.scale = function(l) {
+ return new g(this._x * l, this._y * l, this._z * l, this._w * l);
+ }, g.prototype.scaleToRef = function(l, h) {
+ return h.x = this._x * l, h.y = this._y * l, h.z = this._z * l, h.w = this._w * l, this;
+ }, g.prototype.scaleInPlace = function(l) {
+ return this.x *= l, this.y *= l, this.z *= l, this.w *= l, this;
+ }, g.prototype.scaleAndAddToRef = function(l, h) {
+ return h.x += this._x * l, h.y += this._y * l, h.z += this._z * l, h.w += this._w * l, this;
+ }, g.prototype.multiply = function(l) {
+ var h = new g(0, 0, 0, 1);
+ return this.multiplyToRef(l, h), h;
+ }, g.prototype.multiplyToRef = function(l, h) {
+ var v = this._x * l._w + this._y * l._z - this._z * l._y + this._w * l._x, b = -this._x * l._z + this._y * l._w + this._z * l._x + this._w * l._y, D = this._x * l._y - this._y * l._x + this._z * l._w + this._w * l._z, w = -this._x * l._x - this._y * l._y - this._z * l._z + this._w * l._w;
+ return h.copyFromFloats(v, b, D, w), this;
+ }, g.prototype.multiplyInPlace = function(l) {
+ return this.multiplyToRef(l, this), this;
+ }, g.prototype.conjugateToRef = function(l) {
+ return l.copyFromFloats(-this._x, -this._y, -this._z, this._w), this;
+ }, g.prototype.conjugateInPlace = function() {
+ return this.x *= -1, this.y *= -1, this.z *= -1, this;
+ }, g.prototype.conjugate = function() {
+ return new g(-this._x, -this._y, -this._z, this._w);
+ }, g.prototype.length = function() {
+ return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w);
+ }, g.prototype.normalize = function() {
+ var l = this.length();
+ if (l === 0)
+ return this;
+ var h = 1 / l;
+ return this.x *= h, this.y *= h, this.z *= h, this.w *= h, this;
+ }, g.prototype.toEulerAngles = function(l) {
+ var h = x.Zero();
+ return this.toEulerAnglesToRef(h), h;
+ }, g.prototype.toEulerAnglesToRef = function(l) {
+ var h = this._z, v = this._x, b = this._y, D = this._w, w = D * D, N = h * h, M = v * v, U = b * b, X = b * h - v * D;
+ return X < -0.4999999 ? (l.y = 2 * Math.atan2(b, D), l.x = Math.PI / 2, l.z = 0) : X > 0.4999999 ? (l.y = 2 * Math.atan2(b, D), l.x = -Math.PI / 2, l.z = 0) : (l.z = Math.atan2(2 * (v * b + h * D), -N - M + U + w), l.x = Math.asin(-2 * (h * b - v * D)), l.y = Math.atan2(2 * (h * v + b * D), N - M - U + w)), this;
+ }, g.prototype.toRotationMatrix = function(l) {
+ return T.FromQuaternionToRef(this, l), this;
+ }, g.prototype.fromRotationMatrix = function(l) {
+ return g.FromRotationMatrixToRef(l, this), this;
+ }, g.FromRotationMatrix = function(l) {
+ var h = new g();
+ return g.FromRotationMatrixToRef(l, h), h;
+ }, g.FromRotationMatrixToRef = function(l, h) {
+ var v, b = l.m, D = b[0], w = b[4], N = b[8], M = b[1], U = b[5], X = b[9], j = b[2], ne = b[6], te = b[10], de = D + U + te;
+ de > 0 ? (v = 0.5 / Math.sqrt(de + 1), h.w = 0.25 / v, h.x = (ne - X) * v, h.y = (N - j) * v, h.z = (M - w) * v) : D > U && D > te ? (v = 2 * Math.sqrt(1 + D - U - te), h.w = (ne - X) / v, h.x = 0.25 * v, h.y = (w + M) / v, h.z = (N + j) / v) : U > te ? (v = 2 * Math.sqrt(1 + U - D - te), h.w = (N - j) / v, h.x = (w + M) / v, h.y = 0.25 * v, h.z = (X + ne) / v) : (v = 2 * Math.sqrt(1 + te - D - U), h.w = (M - w) / v, h.x = (N + j) / v, h.y = (X + ne) / v, h.z = 0.25 * v);
+ }, g.Dot = function(l, h) {
+ return l._x * h._x + l._y * h._y + l._z * h._z + l._w * h._w;
+ }, g.AreClose = function(l, h) {
+ return g.Dot(l, h) >= 0;
+ }, g.Zero = function() {
+ return new g(0, 0, 0, 0);
+ }, g.Inverse = function(l) {
+ return new g(-l._x, -l._y, -l._z, l._w);
+ }, g.InverseToRef = function(l, h) {
+ return h.set(-l._x, -l._y, -l._z, l._w), h;
+ }, g.Identity = function() {
+ return new g(0, 0, 0, 1);
+ }, g.IsIdentity = function(l) {
+ return l && l._x === 0 && l._y === 0 && l._z === 0 && l._w === 1;
+ }, g.RotationAxis = function(l, h) {
+ return g.RotationAxisToRef(l, h, new g());
+ }, g.RotationAxisToRef = function(l, h, v) {
+ var b = Math.sin(h / 2);
+ return l.normalize(), v.w = Math.cos(h / 2), v.x = l._x * b, v.y = l._y * b, v.z = l._z * b, v;
+ }, g.FromArray = function(l, h) {
+ return h || (h = 0), new g(l[h], l[h + 1], l[h + 2], l[h + 3]);
+ }, g.FromArrayToRef = function(l, h, v) {
+ v.x = l[h], v.y = l[h + 1], v.z = l[h + 2], v.w = l[h + 3];
+ }, g.FromEulerAngles = function(l, h, v) {
+ var b = new g();
+ return g.RotationYawPitchRollToRef(h, l, v, b), b;
+ }, g.FromEulerAnglesToRef = function(l, h, v, b) {
+ return g.RotationYawPitchRollToRef(h, l, v, b), b;
+ }, g.FromEulerVector = function(l) {
+ var h = new g();
+ return g.RotationYawPitchRollToRef(l._y, l._x, l._z, h), h;
+ }, g.FromEulerVectorToRef = function(l, h) {
+ return g.RotationYawPitchRollToRef(l._y, l._x, l._z, h), h;
+ }, g.RotationYawPitchRoll = function(l, h, v) {
+ var b = new g();
+ return g.RotationYawPitchRollToRef(l, h, v, b), b;
+ }, g.RotationYawPitchRollToRef = function(l, h, v, b) {
+ var D = 0.5 * v, w = 0.5 * h, N = 0.5 * l, M = Math.sin(D), U = Math.cos(D), X = Math.sin(w), j = Math.cos(w), ne = Math.sin(N), te = Math.cos(N);
+ b.x = te * X * U + ne * j * M, b.y = ne * j * U - te * X * M, b.z = te * j * M - ne * X * U, b.w = te * j * U + ne * X * M;
+ }, g.RotationAlphaBetaGamma = function(l, h, v) {
+ var b = new g();
+ return g.RotationAlphaBetaGammaToRef(l, h, v, b), b;
+ }, g.RotationAlphaBetaGammaToRef = function(l, h, v, b) {
+ var D = 0.5 * (v + l), w = 0.5 * (v - l), N = 0.5 * h;
+ b.x = Math.cos(w) * Math.sin(N), b.y = Math.sin(w) * Math.sin(N), b.z = Math.sin(D) * Math.cos(N), b.w = Math.cos(D) * Math.cos(N);
+ }, g.RotationQuaternionFromAxis = function(l, h, v) {
+ var b = new g(0, 0, 0, 0);
+ return g.RotationQuaternionFromAxisToRef(l, h, v, b), b;
+ }, g.RotationQuaternionFromAxisToRef = function(l, h, v, b) {
+ var D = S.Matrix[0];
+ T.FromXYZAxesToRef(l.normalize(), h.normalize(), v.normalize(), D), g.FromRotationMatrixToRef(D, b);
+ }, g.Slerp = function(l, h, v) {
+ var b = g.Identity();
+ return g.SlerpToRef(l, h, v, b), b;
+ }, g.SlerpToRef = function(l, h, v, b) {
+ var D, w, N = l._x * h._x + l._y * h._y + l._z * h._z + l._w * h._w, M = !1;
+ if (N < 0 && (M = !0, N = -N), N > 0.999999)
+ w = 1 - v, D = M ? -v : v;
+ else {
+ var U = Math.acos(N), X = 1 / Math.sin(U);
+ w = Math.sin((1 - v) * U) * X, D = M ? -Math.sin(v * U) * X : Math.sin(v * U) * X;
+ }
+ b.x = w * l._x + D * h._x, b.y = w * l._y + D * h._y, b.z = w * l._z + D * h._z, b.w = w * l._w + D * h._w;
+ }, g.Hermite = function(l, h, v, b, D) {
+ var w = D * D, N = D * w, M = 2 * N - 3 * w + 1, U = -2 * N + 3 * w, X = N - 2 * w + D, j = N - w;
+ return new g(l._x * M + v._x * U + h._x * X + b._x * j, l._y * M + v._y * U + h._y * X + b._y * j, l._z * M + v._z * U + h._z * X + b._z * j, l._w * M + v._w * U + h._w * X + b._w * j);
+ }, g;
+ }(), T = function() {
+ function g() {
+ this._isIdentity = !1, this._isIdentityDirty = !0, this._isIdentity3x2 = !0, this._isIdentity3x2Dirty = !0, this.updateFlag = -1, I.a.MatrixTrackPrecisionChange && I.a.MatrixTrackedMatrices.push(this), this._m = new I.a.MatrixCurrentType(16), this._updateIdentityStatus(!1);
+ }
+ return Object.defineProperty(g, "Use64Bits", { get: function() {
+ return I.a.MatrixUse64Bits;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(g.prototype, "m", { get: function() {
+ return this._m;
+ }, enumerable: !1, configurable: !0 }), g.prototype._markAsUpdated = function() {
+ this.updateFlag = g._updateFlagSeed++, this._isIdentity = !1, this._isIdentity3x2 = !1, this._isIdentityDirty = !0, this._isIdentity3x2Dirty = !0;
+ }, g.prototype._updateIdentityStatus = function(l, h, v, b) {
+ h === void 0 && (h = !1), v === void 0 && (v = !1), b === void 0 && (b = !0), this.updateFlag = g._updateFlagSeed++, this._isIdentity = l, this._isIdentity3x2 = l || v, this._isIdentityDirty = !this._isIdentity && h, this._isIdentity3x2Dirty = !this._isIdentity3x2 && b;
+ }, g.prototype.isIdentity = function() {
+ if (this._isIdentityDirty) {
+ this._isIdentityDirty = !1;
+ var l = this._m;
+ this._isIdentity = l[0] === 1 && l[1] === 0 && l[2] === 0 && l[3] === 0 && l[4] === 0 && l[5] === 1 && l[6] === 0 && l[7] === 0 && l[8] === 0 && l[9] === 0 && l[10] === 1 && l[11] === 0 && l[12] === 0 && l[13] === 0 && l[14] === 0 && l[15] === 1;
+ }
+ return this._isIdentity;
+ }, g.prototype.isIdentityAs3x2 = function() {
+ return this._isIdentity3x2Dirty && (this._isIdentity3x2Dirty = !1, this._m[0] !== 1 || this._m[5] !== 1 || this._m[15] !== 1 || this._m[1] !== 0 || this._m[2] !== 0 || this._m[3] !== 0 || this._m[4] !== 0 || this._m[6] !== 0 || this._m[7] !== 0 || this._m[8] !== 0 || this._m[9] !== 0 || this._m[10] !== 0 || this._m[11] !== 0 || this._m[12] !== 0 || this._m[13] !== 0 || this._m[14] !== 0 ? this._isIdentity3x2 = !1 : this._isIdentity3x2 = !0), this._isIdentity3x2;
+ }, g.prototype.determinant = function() {
+ if (this._isIdentity === !0)
+ return 1;
+ var l = this._m, h = l[0], v = l[1], b = l[2], D = l[3], w = l[4], N = l[5], M = l[6], U = l[7], X = l[8], j = l[9], ne = l[10], te = l[11], de = l[12], pe = l[13], ae = l[14], ee = l[15], K = ne * ee - ae * te, $ = j * ee - pe * te, L = j * ae - pe * ne, G = X * ee - de * te, Q = X * ae - ne * de, oe = X * pe - de * j;
+ return h * +(N * K - M * $ + U * L) + v * -(w * K - M * G + U * Q) + b * +(w * $ - N * G + U * oe) + D * -(w * L - N * Q + M * oe);
+ }, g.prototype.toArray = function() {
+ return this._m;
+ }, g.prototype.asArray = function() {
+ return this._m;
+ }, g.prototype.invert = function() {
+ return this.invertToRef(this), this;
+ }, g.prototype.reset = function() {
+ return g.FromValuesToRef(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, this), this._updateIdentityStatus(!1), this;
+ }, g.prototype.add = function(l) {
+ var h = new g();
+ return this.addToRef(l, h), h;
+ }, g.prototype.addToRef = function(l, h) {
+ for (var v = this._m, b = h._m, D = l.m, w = 0; w < 16; w++)
+ b[w] = v[w] + D[w];
+ return h._markAsUpdated(), this;
+ }, g.prototype.addToSelf = function(l) {
+ for (var h = this._m, v = l.m, b = 0; b < 16; b++)
+ h[b] += v[b];
+ return this._markAsUpdated(), this;
+ }, g.prototype.invertToRef = function(l) {
+ if (this._isIdentity === !0)
+ return g.IdentityToRef(l), this;
+ var h = this._m, v = h[0], b = h[1], D = h[2], w = h[3], N = h[4], M = h[5], U = h[6], X = h[7], j = h[8], ne = h[9], te = h[10], de = h[11], pe = h[12], ae = h[13], ee = h[14], K = h[15], $ = te * K - ee * de, L = ne * K - ae * de, G = ne * ee - ae * te, Q = j * K - pe * de, oe = j * ee - te * pe, re = j * ae - pe * ne, Y = +(M * $ - U * L + X * G), k = -(N * $ - U * Q + X * oe), H = +(N * L - M * Q + X * re), Z = -(N * G - M * oe + U * re), W = v * Y + b * k + D * H + w * Z;
+ if (W === 0)
+ return l.copyFrom(this), this;
+ var q = 1 / W, he = U * K - ee * X, ge = M * K - ae * X, me = M * ee - ae * U, _e = N * K - pe * X, ye = N * ee - pe * U, Pe = N * ae - pe * M, be = U * de - te * X, Fe = M * de - ne * X, ke = M * te - ne * U, We = N * de - j * X, je = N * te - j * U, He = N * ne - j * M, Qe = -(b * $ - D * L + w * G), Ge = +(v * $ - D * Q + w * oe), tt = -(v * L - b * Q + w * re), Je = +(v * G - b * oe + D * re), st = +(b * he - D * ge + w * me), at = -(v * he - D * _e + w * ye), pt = +(v * ge - b * _e + w * Pe), Tt = -(v * me - b * ye + D * Pe), Lt = -(b * be - D * Fe + w * ke), Ot = +(v * be - D * We + w * je), St = -(v * Fe - b * We + w * He), Ct = +(v * ke - b * je + D * He);
+ return g.FromValuesToRef(Y * q, Qe * q, st * q, Lt * q, k * q, Ge * q, at * q, Ot * q, H * q, tt * q, pt * q, St * q, Z * q, Je * q, Tt * q, Ct * q, l), this;
+ }, g.prototype.addAtIndex = function(l, h) {
+ return this._m[l] += h, this._markAsUpdated(), this;
+ }, g.prototype.multiplyAtIndex = function(l, h) {
+ return this._m[l] *= h, this._markAsUpdated(), this;
+ }, g.prototype.setTranslationFromFloats = function(l, h, v) {
+ return this._m[12] = l, this._m[13] = h, this._m[14] = v, this._markAsUpdated(), this;
+ }, g.prototype.addTranslationFromFloats = function(l, h, v) {
+ return this._m[12] += l, this._m[13] += h, this._m[14] += v, this._markAsUpdated(), this;
+ }, g.prototype.setTranslation = function(l) {
+ return this.setTranslationFromFloats(l._x, l._y, l._z);
+ }, g.prototype.getTranslation = function() {
+ return new x(this._m[12], this._m[13], this._m[14]);
+ }, g.prototype.getTranslationToRef = function(l) {
+ return l.x = this._m[12], l.y = this._m[13], l.z = this._m[14], this;
+ }, g.prototype.removeRotationAndScaling = function() {
+ var l = this.m;
+ return g.FromValuesToRef(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, l[12], l[13], l[14], l[15], this), this._updateIdentityStatus(l[12] === 0 && l[13] === 0 && l[14] === 0 && l[15] === 1), this;
+ }, g.prototype.multiply = function(l) {
+ var h = new g();
+ return this.multiplyToRef(l, h), h;
+ }, g.prototype.copyFrom = function(l) {
+ l.copyToArray(this._m);
+ var h = l;
+ return this._updateIdentityStatus(h._isIdentity, h._isIdentityDirty, h._isIdentity3x2, h._isIdentity3x2Dirty), this;
+ }, g.prototype.copyToArray = function(l, h) {
+ h === void 0 && (h = 0);
+ var v = this._m;
+ return l[h] = v[0], l[h + 1] = v[1], l[h + 2] = v[2], l[h + 3] = v[3], l[h + 4] = v[4], l[h + 5] = v[5], l[h + 6] = v[6], l[h + 7] = v[7], l[h + 8] = v[8], l[h + 9] = v[9], l[h + 10] = v[10], l[h + 11] = v[11], l[h + 12] = v[12], l[h + 13] = v[13], l[h + 14] = v[14], l[h + 15] = v[15], this;
+ }, g.prototype.multiplyToRef = function(l, h) {
+ return this._isIdentity ? (h.copyFrom(l), this) : l._isIdentity ? (h.copyFrom(this), this) : (this.multiplyToArray(l, h._m, 0), h._markAsUpdated(), this);
+ }, g.prototype.multiplyToArray = function(l, h, v) {
+ var b = this._m, D = l.m, w = b[0], N = b[1], M = b[2], U = b[3], X = b[4], j = b[5], ne = b[6], te = b[7], de = b[8], pe = b[9], ae = b[10], ee = b[11], K = b[12], $ = b[13], L = b[14], G = b[15], Q = D[0], oe = D[1], re = D[2], Y = D[3], k = D[4], H = D[5], Z = D[6], W = D[7], q = D[8], he = D[9], ge = D[10], me = D[11], _e = D[12], ye = D[13], Pe = D[14], be = D[15];
+ return h[v] = w * Q + N * k + M * q + U * _e, h[v + 1] = w * oe + N * H + M * he + U * ye, h[v + 2] = w * re + N * Z + M * ge + U * Pe, h[v + 3] = w * Y + N * W + M * me + U * be, h[v + 4] = X * Q + j * k + ne * q + te * _e, h[v + 5] = X * oe + j * H + ne * he + te * ye, h[v + 6] = X * re + j * Z + ne * ge + te * Pe, h[v + 7] = X * Y + j * W + ne * me + te * be, h[v + 8] = de * Q + pe * k + ae * q + ee * _e, h[v + 9] = de * oe + pe * H + ae * he + ee * ye, h[v + 10] = de * re + pe * Z + ae * ge + ee * Pe, h[v + 11] = de * Y + pe * W + ae * me + ee * be, h[v + 12] = K * Q + $ * k + L * q + G * _e, h[v + 13] = K * oe + $ * H + L * he + G * ye, h[v + 14] = K * re + $ * Z + L * ge + G * Pe, h[v + 15] = K * Y + $ * W + L * me + G * be, this;
+ }, g.prototype.equals = function(l) {
+ var h = l;
+ if (!h)
+ return !1;
+ if ((this._isIdentity || h._isIdentity) && !this._isIdentityDirty && !h._isIdentityDirty)
+ return this._isIdentity && h._isIdentity;
+ var v = this.m, b = h.m;
+ return v[0] === b[0] && v[1] === b[1] && v[2] === b[2] && v[3] === b[3] && v[4] === b[4] && v[5] === b[5] && v[6] === b[6] && v[7] === b[7] && v[8] === b[8] && v[9] === b[9] && v[10] === b[10] && v[11] === b[11] && v[12] === b[12] && v[13] === b[13] && v[14] === b[14] && v[15] === b[15];
+ }, g.prototype.clone = function() {
+ var l = new g();
+ return l.copyFrom(this), l;
+ }, g.prototype.getClassName = function() {
+ return "Matrix";
+ }, g.prototype.getHashCode = function() {
+ for (var l = 0 | this._m[0], h = 1; h < 16; h++)
+ l = 397 * l ^ (0 | this._m[h]);
+ return l;
+ }, g.prototype.decompose = function(l, h, v) {
+ if (this._isIdentity)
+ return v && v.setAll(0), l && l.setAll(1), h && h.copyFromFloats(0, 0, 0, 1), !0;
+ var b = this._m;
+ if (v && v.copyFromFloats(b[12], b[13], b[14]), (l = l || S.Vector3[0]).x = Math.sqrt(b[0] * b[0] + b[1] * b[1] + b[2] * b[2]), l.y = Math.sqrt(b[4] * b[4] + b[5] * b[5] + b[6] * b[6]), l.z = Math.sqrt(b[8] * b[8] + b[9] * b[9] + b[10] * b[10]), this.determinant() <= 0 && (l.y *= -1), l._x === 0 || l._y === 0 || l._z === 0)
+ return h && h.copyFromFloats(0, 0, 0, 1), !1;
+ if (h) {
+ var D = 1 / l._x, w = 1 / l._y, N = 1 / l._z;
+ g.FromValuesToRef(b[0] * D, b[1] * D, b[2] * D, 0, b[4] * w, b[5] * w, b[6] * w, 0, b[8] * N, b[9] * N, b[10] * N, 0, 0, 0, 0, 1, S.Matrix[0]), c.FromRotationMatrixToRef(S.Matrix[0], h);
+ }
+ return !0;
+ }, g.prototype.getRow = function(l) {
+ if (l < 0 || l > 3)
+ return null;
+ var h = 4 * l;
+ return new m(this._m[h + 0], this._m[h + 1], this._m[h + 2], this._m[h + 3]);
+ }, g.prototype.setRow = function(l, h) {
+ return this.setRowFromFloats(l, h.x, h.y, h.z, h.w);
+ }, g.prototype.transpose = function() {
+ return g.Transpose(this);
+ }, g.prototype.transposeToRef = function(l) {
+ return g.TransposeToRef(this, l), this;
+ }, g.prototype.setRowFromFloats = function(l, h, v, b, D) {
+ if (l < 0 || l > 3)
+ return this;
+ var w = 4 * l;
+ return this._m[w + 0] = h, this._m[w + 1] = v, this._m[w + 2] = b, this._m[w + 3] = D, this._markAsUpdated(), this;
+ }, g.prototype.scale = function(l) {
+ var h = new g();
+ return this.scaleToRef(l, h), h;
+ }, g.prototype.scaleToRef = function(l, h) {
+ for (var v = 0; v < 16; v++)
+ h._m[v] = this._m[v] * l;
+ return h._markAsUpdated(), this;
+ }, g.prototype.scaleAndAddToRef = function(l, h) {
+ for (var v = 0; v < 16; v++)
+ h._m[v] += this._m[v] * l;
+ return h._markAsUpdated(), this;
+ }, g.prototype.toNormalMatrix = function(l) {
+ var h = S.Matrix[0];
+ this.invertToRef(h), h.transposeToRef(l);
+ var v = l._m;
+ g.FromValuesToRef(v[0], v[1], v[2], 0, v[4], v[5], v[6], 0, v[8], v[9], v[10], 0, 0, 0, 0, 1, l);
+ }, g.prototype.getRotationMatrix = function() {
+ var l = new g();
+ return this.getRotationMatrixToRef(l), l;
+ }, g.prototype.getRotationMatrixToRef = function(l) {
+ var h = S.Vector3[0];
+ if (!this.decompose(h))
+ return g.IdentityToRef(l), this;
+ var v = this._m, b = 1 / h._x, D = 1 / h._y, w = 1 / h._z;
+ return g.FromValuesToRef(v[0] * b, v[1] * b, v[2] * b, 0, v[4] * D, v[5] * D, v[6] * D, 0, v[8] * w, v[9] * w, v[10] * w, 0, 0, 0, 0, 1, l), this;
+ }, g.prototype.toggleModelMatrixHandInPlace = function() {
+ var l = this._m;
+ l[2] *= -1, l[6] *= -1, l[8] *= -1, l[9] *= -1, l[14] *= -1, this._markAsUpdated();
+ }, g.prototype.toggleProjectionMatrixHandInPlace = function() {
+ var l = this._m;
+ l[8] *= -1, l[9] *= -1, l[10] *= -1, l[11] *= -1, this._markAsUpdated();
+ }, g.FromArray = function(l, h) {
+ h === void 0 && (h = 0);
+ var v = new g();
+ return g.FromArrayToRef(l, h, v), v;
+ }, g.FromArrayToRef = function(l, h, v) {
+ for (var b = 0; b < 16; b++)
+ v._m[b] = l[b + h];
+ v._markAsUpdated();
+ }, g.FromFloat32ArrayToRefScaled = function(l, h, v, b) {
+ for (var D = 0; D < 16; D++)
+ b._m[D] = l[D + h] * v;
+ b._markAsUpdated();
+ }, Object.defineProperty(g, "IdentityReadOnly", { get: function() {
+ return g._identityReadOnly;
+ }, enumerable: !1, configurable: !0 }), g.FromValuesToRef = function(l, h, v, b, D, w, N, M, U, X, j, ne, te, de, pe, ae, ee) {
+ var K = ee._m;
+ K[0] = l, K[1] = h, K[2] = v, K[3] = b, K[4] = D, K[5] = w, K[6] = N, K[7] = M, K[8] = U, K[9] = X, K[10] = j, K[11] = ne, K[12] = te, K[13] = de, K[14] = pe, K[15] = ae, ee._markAsUpdated();
+ }, g.FromValues = function(l, h, v, b, D, w, N, M, U, X, j, ne, te, de, pe, ae) {
+ var ee = new g(), K = ee._m;
+ return K[0] = l, K[1] = h, K[2] = v, K[3] = b, K[4] = D, K[5] = w, K[6] = N, K[7] = M, K[8] = U, K[9] = X, K[10] = j, K[11] = ne, K[12] = te, K[13] = de, K[14] = pe, K[15] = ae, ee._markAsUpdated(), ee;
+ }, g.Compose = function(l, h, v) {
+ var b = new g();
+ return g.ComposeToRef(l, h, v, b), b;
+ }, g.ComposeToRef = function(l, h, v, b) {
+ var D = b._m, w = h._x, N = h._y, M = h._z, U = h._w, X = w + w, j = N + N, ne = M + M, te = w * X, de = w * j, pe = w * ne, ae = N * j, ee = N * ne, K = M * ne, $ = U * X, L = U * j, G = U * ne, Q = l._x, oe = l._y, re = l._z;
+ D[0] = (1 - (ae + K)) * Q, D[1] = (de + G) * Q, D[2] = (pe - L) * Q, D[3] = 0, D[4] = (de - G) * oe, D[5] = (1 - (te + K)) * oe, D[6] = (ee + $) * oe, D[7] = 0, D[8] = (pe + L) * re, D[9] = (ee - $) * re, D[10] = (1 - (te + ae)) * re, D[11] = 0, D[12] = v._x, D[13] = v._y, D[14] = v._z, D[15] = 1, b._markAsUpdated();
+ }, g.Identity = function() {
+ var l = g.FromValues(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
+ return l._updateIdentityStatus(!0), l;
+ }, g.IdentityToRef = function(l) {
+ g.FromValuesToRef(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, l), l._updateIdentityStatus(!0);
+ }, g.Zero = function() {
+ var l = g.FromValues(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+ return l._updateIdentityStatus(!1), l;
+ }, g.RotationX = function(l) {
+ var h = new g();
+ return g.RotationXToRef(l, h), h;
+ }, g.Invert = function(l) {
+ var h = new g();
+ return l.invertToRef(h), h;
+ }, g.RotationXToRef = function(l, h) {
+ var v = Math.sin(l), b = Math.cos(l);
+ g.FromValuesToRef(1, 0, 0, 0, 0, b, v, 0, 0, -v, b, 0, 0, 0, 0, 1, h), h._updateIdentityStatus(b === 1 && v === 0);
+ }, g.RotationY = function(l) {
+ var h = new g();
+ return g.RotationYToRef(l, h), h;
+ }, g.RotationYToRef = function(l, h) {
+ var v = Math.sin(l), b = Math.cos(l);
+ g.FromValuesToRef(b, 0, -v, 0, 0, 1, 0, 0, v, 0, b, 0, 0, 0, 0, 1, h), h._updateIdentityStatus(b === 1 && v === 0);
+ }, g.RotationZ = function(l) {
+ var h = new g();
+ return g.RotationZToRef(l, h), h;
+ }, g.RotationZToRef = function(l, h) {
+ var v = Math.sin(l), b = Math.cos(l);
+ g.FromValuesToRef(b, v, 0, 0, -v, b, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, h), h._updateIdentityStatus(b === 1 && v === 0);
+ }, g.RotationAxis = function(l, h) {
+ var v = new g();
+ return g.RotationAxisToRef(l, h, v), v;
+ }, g.RotationAxisToRef = function(l, h, v) {
+ var b = Math.sin(-h), D = Math.cos(-h), w = 1 - D;
+ l.normalize();
+ var N = v._m;
+ N[0] = l._x * l._x * w + D, N[1] = l._x * l._y * w - l._z * b, N[2] = l._x * l._z * w + l._y * b, N[3] = 0, N[4] = l._y * l._x * w + l._z * b, N[5] = l._y * l._y * w + D, N[6] = l._y * l._z * w - l._x * b, N[7] = 0, N[8] = l._z * l._x * w - l._y * b, N[9] = l._z * l._y * w + l._x * b, N[10] = l._z * l._z * w + D, N[11] = 0, N[12] = 0, N[13] = 0, N[14] = 0, N[15] = 1, v._markAsUpdated();
+ }, g.RotationAlignToRef = function(l, h, v) {
+ var b = x.Cross(h, l), D = x.Dot(h, l), w = 1 / (1 + D), N = v._m;
+ N[0] = b._x * b._x * w + D, N[1] = b._y * b._x * w - b._z, N[2] = b._z * b._x * w + b._y, N[3] = 0, N[4] = b._x * b._y * w + b._z, N[5] = b._y * b._y * w + D, N[6] = b._z * b._y * w - b._x, N[7] = 0, N[8] = b._x * b._z * w - b._y, N[9] = b._y * b._z * w + b._x, N[10] = b._z * b._z * w + D, N[11] = 0, N[12] = 0, N[13] = 0, N[14] = 0, N[15] = 1, v._markAsUpdated();
+ }, g.RotationYawPitchRoll = function(l, h, v) {
+ var b = new g();
+ return g.RotationYawPitchRollToRef(l, h, v, b), b;
+ }, g.RotationYawPitchRollToRef = function(l, h, v, b) {
+ c.RotationYawPitchRollToRef(l, h, v, S.Quaternion[0]), S.Quaternion[0].toRotationMatrix(b);
+ }, g.Scaling = function(l, h, v) {
+ var b = new g();
+ return g.ScalingToRef(l, h, v, b), b;
+ }, g.ScalingToRef = function(l, h, v, b) {
+ g.FromValuesToRef(l, 0, 0, 0, 0, h, 0, 0, 0, 0, v, 0, 0, 0, 0, 1, b), b._updateIdentityStatus(l === 1 && h === 1 && v === 1);
+ }, g.Translation = function(l, h, v) {
+ var b = new g();
+ return g.TranslationToRef(l, h, v, b), b;
+ }, g.TranslationToRef = function(l, h, v, b) {
+ g.FromValuesToRef(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, l, h, v, 1, b), b._updateIdentityStatus(l === 0 && h === 0 && v === 0);
+ }, g.Lerp = function(l, h, v) {
+ var b = new g();
+ return g.LerpToRef(l, h, v, b), b;
+ }, g.LerpToRef = function(l, h, v, b) {
+ for (var D = b._m, w = l.m, N = h.m, M = 0; M < 16; M++)
+ D[M] = w[M] * (1 - v) + N[M] * v;
+ b._markAsUpdated();
+ }, g.DecomposeLerp = function(l, h, v) {
+ var b = new g();
+ return g.DecomposeLerpToRef(l, h, v, b), b;
+ }, g.DecomposeLerpToRef = function(l, h, v, b) {
+ var D = S.Vector3[0], w = S.Quaternion[0], N = S.Vector3[1];
+ l.decompose(D, w, N);
+ var M = S.Vector3[2], U = S.Quaternion[1], X = S.Vector3[3];
+ h.decompose(M, U, X);
+ var j = S.Vector3[4];
+ x.LerpToRef(D, M, v, j);
+ var ne = S.Quaternion[2];
+ c.SlerpToRef(w, U, v, ne);
+ var te = S.Vector3[5];
+ x.LerpToRef(N, X, v, te), g.ComposeToRef(j, ne, te, b);
+ }, g.LookAtLH = function(l, h, v) {
+ var b = new g();
+ return g.LookAtLHToRef(l, h, v, b), b;
+ }, g.LookAtLHToRef = function(l, h, v, b) {
+ var D = S.Vector3[0], w = S.Vector3[1], N = S.Vector3[2];
+ h.subtractToRef(l, N), N.normalize(), x.CrossToRef(v, N, D);
+ var M = D.lengthSquared();
+ M === 0 ? D.x = 1 : D.normalizeFromLength(Math.sqrt(M)), x.CrossToRef(N, D, w), w.normalize();
+ var U = -x.Dot(D, l), X = -x.Dot(w, l), j = -x.Dot(N, l);
+ g.FromValuesToRef(D._x, w._x, N._x, 0, D._y, w._y, N._y, 0, D._z, w._z, N._z, 0, U, X, j, 1, b);
+ }, g.LookAtRH = function(l, h, v) {
+ var b = new g();
+ return g.LookAtRHToRef(l, h, v, b), b;
+ }, g.LookAtRHToRef = function(l, h, v, b) {
+ var D = S.Vector3[0], w = S.Vector3[1], N = S.Vector3[2];
+ l.subtractToRef(h, N), N.normalize(), x.CrossToRef(v, N, D);
+ var M = D.lengthSquared();
+ M === 0 ? D.x = 1 : D.normalizeFromLength(Math.sqrt(M)), x.CrossToRef(N, D, w), w.normalize();
+ var U = -x.Dot(D, l), X = -x.Dot(w, l), j = -x.Dot(N, l);
+ g.FromValuesToRef(D._x, w._x, N._x, 0, D._y, w._y, N._y, 0, D._z, w._z, N._z, 0, U, X, j, 1, b);
+ }, g.OrthoLH = function(l, h, v, b) {
+ var D = new g();
+ return g.OrthoLHToRef(l, h, v, b, D), D;
+ }, g.OrthoLHToRef = function(l, h, v, b, D) {
+ var w = 2 / l, N = 2 / h, M = 2 / (b - v), U = -(b + v) / (b - v);
+ g.FromValuesToRef(w, 0, 0, 0, 0, N, 0, 0, 0, 0, M, 0, 0, 0, U, 1, D), D._updateIdentityStatus(w === 1 && N === 1 && M === 1 && U === 0);
+ }, g.OrthoOffCenterLH = function(l, h, v, b, D, w) {
+ var N = new g();
+ return g.OrthoOffCenterLHToRef(l, h, v, b, D, w, N), N;
+ }, g.OrthoOffCenterLHToRef = function(l, h, v, b, D, w, N) {
+ var M = 2 / (h - l), U = 2 / (b - v), X = 2 / (w - D), j = -(w + D) / (w - D), ne = (l + h) / (l - h), te = (b + v) / (v - b);
+ g.FromValuesToRef(M, 0, 0, 0, 0, U, 0, 0, 0, 0, X, 0, ne, te, j, 1, N), N._markAsUpdated();
+ }, g.OrthoOffCenterRH = function(l, h, v, b, D, w) {
+ var N = new g();
+ return g.OrthoOffCenterRHToRef(l, h, v, b, D, w, N), N;
+ }, g.OrthoOffCenterRHToRef = function(l, h, v, b, D, w, N) {
+ g.OrthoOffCenterLHToRef(l, h, v, b, D, w, N), N._m[10] *= -1;
+ }, g.PerspectiveLH = function(l, h, v, b) {
+ var D = new g(), w = 2 * v / l, N = 2 * v / h, M = (b + v) / (b - v), U = -2 * b * v / (b - v);
+ return g.FromValuesToRef(w, 0, 0, 0, 0, N, 0, 0, 0, 0, M, 1, 0, 0, U, 0, D), D._updateIdentityStatus(!1), D;
+ }, g.PerspectiveFovLH = function(l, h, v, b) {
+ var D = new g();
+ return g.PerspectiveFovLHToRef(l, h, v, b, D), D;
+ }, g.PerspectiveFovLHToRef = function(l, h, v, b, D, w) {
+ w === void 0 && (w = !0);
+ var N = v, M = b, U = 1 / Math.tan(0.5 * l), X = w ? U / h : U, j = w ? U : U * h, ne = (M + N) / (M - N), te = -2 * M * N / (M - N);
+ g.FromValuesToRef(X, 0, 0, 0, 0, j, 0, 0, 0, 0, ne, 1, 0, 0, te, 0, D), D._updateIdentityStatus(!1);
+ }, g.PerspectiveFovReverseLHToRef = function(l, h, v, b, D, w) {
+ w === void 0 && (w = !0);
+ var N = 1 / Math.tan(0.5 * l), M = w ? N / h : N, U = w ? N : N * h;
+ g.FromValuesToRef(M, 0, 0, 0, 0, U, 0, 0, 0, 0, -v, 1, 0, 0, 1, 0, D), D._updateIdentityStatus(!1);
+ }, g.PerspectiveFovRH = function(l, h, v, b) {
+ var D = new g();
+ return g.PerspectiveFovRHToRef(l, h, v, b, D), D;
+ }, g.PerspectiveFovRHToRef = function(l, h, v, b, D, w) {
+ w === void 0 && (w = !0);
+ var N = v, M = b, U = 1 / Math.tan(0.5 * l), X = w ? U / h : U, j = w ? U : U * h, ne = -(M + N) / (M - N), te = -2 * M * N / (M - N);
+ g.FromValuesToRef(X, 0, 0, 0, 0, j, 0, 0, 0, 0, ne, -1, 0, 0, te, 0, D), D._updateIdentityStatus(!1);
+ }, g.PerspectiveFovReverseRHToRef = function(l, h, v, b, D, w) {
+ w === void 0 && (w = !0);
+ var N = 1 / Math.tan(0.5 * l), M = w ? N / h : N, U = w ? N : N * h;
+ g.FromValuesToRef(M, 0, 0, 0, 0, U, 0, 0, 0, 0, -v, -1, 0, 0, -1, 0, D), D._updateIdentityStatus(!1);
+ }, g.PerspectiveFovWebVRToRef = function(l, h, v, b, D) {
+ D === void 0 && (D = !1);
+ var w = D ? -1 : 1, N = Math.tan(l.upDegrees * Math.PI / 180), M = Math.tan(l.downDegrees * Math.PI / 180), U = Math.tan(l.leftDegrees * Math.PI / 180), X = Math.tan(l.rightDegrees * Math.PI / 180), j = 2 / (U + X), ne = 2 / (N + M), te = b._m;
+ te[0] = j, te[1] = te[2] = te[3] = te[4] = 0, te[5] = ne, te[6] = te[7] = 0, te[8] = (U - X) * j * 0.5, te[9] = -(N - M) * ne * 0.5, te[10] = -v / (h - v), te[11] = 1 * w, te[12] = te[13] = te[15] = 0, te[14] = -2 * v * h / (v - h), b._markAsUpdated();
+ }, g.GetFinalMatrix = function(l, h, v, b, D, w) {
+ var N = l.width, M = l.height, U = l.x, X = l.y, j = g.FromValues(N / 2, 0, 0, 0, 0, -M / 2, 0, 0, 0, 0, w - D, 0, U + N / 2, M / 2 + X, D, 1), ne = S.Matrix[0];
+ return h.multiplyToRef(v, ne), ne.multiplyToRef(b, ne), ne.multiply(j);
+ }, g.GetAsMatrix2x2 = function(l) {
+ var h = l.m, v = [h[0], h[1], h[4], h[5]];
+ return I.a.MatrixUse64Bits ? v : new Float32Array(v);
+ }, g.GetAsMatrix3x3 = function(l) {
+ var h = l.m, v = [h[0], h[1], h[2], h[4], h[5], h[6], h[8], h[9], h[10]];
+ return I.a.MatrixUse64Bits ? v : new Float32Array(v);
+ }, g.Transpose = function(l) {
+ var h = new g();
+ return g.TransposeToRef(l, h), h;
+ }, g.TransposeToRef = function(l, h) {
+ var v = h._m, b = l.m;
+ v[0] = b[0], v[1] = b[4], v[2] = b[8], v[3] = b[12], v[4] = b[1], v[5] = b[5], v[6] = b[9], v[7] = b[13], v[8] = b[2], v[9] = b[6], v[10] = b[10], v[11] = b[14], v[12] = b[3], v[13] = b[7], v[14] = b[11], v[15] = b[15], h._updateIdentityStatus(l._isIdentity, l._isIdentityDirty);
+ }, g.Reflection = function(l) {
+ var h = new g();
+ return g.ReflectionToRef(l, h), h;
+ }, g.ReflectionToRef = function(l, h) {
+ l.normalize();
+ var v = l.normal.x, b = l.normal.y, D = l.normal.z, w = -2 * v, N = -2 * b, M = -2 * D;
+ g.FromValuesToRef(w * v + 1, N * v, M * v, 0, w * b, N * b + 1, M * b, 0, w * D, N * D, M * D + 1, 0, w * l.d, N * l.d, M * l.d, 1, h);
+ }, g.FromXYZAxesToRef = function(l, h, v, b) {
+ g.FromValuesToRef(l._x, l._y, l._z, 0, h._x, h._y, h._z, 0, v._x, v._y, v._z, 0, 0, 0, 0, 1, b);
+ }, g.FromQuaternionToRef = function(l, h) {
+ var v = l._x * l._x, b = l._y * l._y, D = l._z * l._z, w = l._x * l._y, N = l._z * l._w, M = l._z * l._x, U = l._y * l._w, X = l._y * l._z, j = l._x * l._w;
+ h._m[0] = 1 - 2 * (b + D), h._m[1] = 2 * (w + N), h._m[2] = 2 * (M - U), h._m[3] = 0, h._m[4] = 2 * (w - N), h._m[5] = 1 - 2 * (D + v), h._m[6] = 2 * (X + j), h._m[7] = 0, h._m[8] = 2 * (M + U), h._m[9] = 2 * (X - j), h._m[10] = 1 - 2 * (b + v), h._m[11] = 0, h._m[12] = 0, h._m[13] = 0, h._m[14] = 0, h._m[15] = 1, h._markAsUpdated();
+ }, g._updateFlagSeed = 0, g._identityReadOnly = g.Identity(), g;
+ }(), S = function() {
+ function g() {
+ }
+ return g.Vector3 = C.a.BuildArray(6, x.Zero), g.Matrix = C.a.BuildArray(2, T.Identity), g.Quaternion = C.a.BuildArray(3, c.Zero), g;
+ }(), E = function() {
+ function g() {
+ }
+ return g.Vector2 = C.a.BuildArray(3, O.Zero), g.Vector3 = C.a.BuildArray(13, x.Zero), g.Vector4 = C.a.BuildArray(3, m.Zero), g.Quaternion = C.a.BuildArray(2, c.Zero), g.Matrix = C.a.BuildArray(8, T.Identity), g;
+ }();
+ u.a.RegisteredTypes["BABYLON.Vector2"] = O, u.a.RegisteredTypes["BABYLON.Vector3"] = x, u.a.RegisteredTypes["BABYLON.Vector4"] = m, u.a.RegisteredTypes["BABYLON.Matrix"] = T;
+ }, function(Be, A, f) {
+ f.d(A, "d", function() {
+ return _;
+ }), f.d(A, "a", function() {
+ return C;
+ }), f.d(A, "c", function() {
+ return u;
+ }), f.d(A, "b", function() {
+ return I;
+ }), f.d(A, "e", function() {
+ return O;
+ }), f.d(A, "f", function() {
+ return x;
+ });
+ /*! *****************************************************************************
+ Copyright (c) Microsoft Corporation.
+
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted.
+
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ PERFORMANCE OF THIS SOFTWARE.
+ ***************************************************************************** */
+ var V = function(m, c) {
+ return (V = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(T, S) {
+ T.__proto__ = S;
+ } || function(T, S) {
+ for (var E in S)
+ Object.prototype.hasOwnProperty.call(S, E) && (T[E] = S[E]);
+ })(m, c);
+ };
+ function _(m, c) {
+ if (typeof c != "function" && c !== null)
+ throw new TypeError("Class extends value " + String(c) + " is not a constructor or null");
+ function T() {
+ this.constructor = m;
+ }
+ V(m, c), m.prototype = c === null ? Object.create(c) : (T.prototype = c.prototype, new T());
+ }
+ var C = function() {
+ return (C = Object.assign || function(m) {
+ for (var c, T = 1, S = arguments.length; T < S; T++)
+ for (var E in c = arguments[T])
+ Object.prototype.hasOwnProperty.call(c, E) && (m[E] = c[E]);
+ return m;
+ }).apply(this, arguments);
+ };
+ function u(m, c, T, S) {
+ var E, g = arguments.length, l = g < 3 ? c : S === null ? S = Object.getOwnPropertyDescriptor(c, T) : S;
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function")
+ l = Reflect.decorate(m, c, T, S);
+ else
+ for (var h = m.length - 1; h >= 0; h--)
+ (E = m[h]) && (l = (g < 3 ? E(l) : g > 3 ? E(c, T, l) : E(c, T)) || l);
+ return g > 3 && l && Object.defineProperty(c, T, l), l;
+ }
+ function I(m, c, T, S) {
+ return new (T || (T = Promise))(function(E, g) {
+ function l(b) {
+ try {
+ v(S.next(b));
+ } catch (D) {
+ g(D);
+ }
+ }
+ function h(b) {
+ try {
+ v(S.throw(b));
+ } catch (D) {
+ g(D);
+ }
+ }
+ function v(b) {
+ var D;
+ b.done ? E(b.value) : (D = b.value, D instanceof T ? D : new T(function(w) {
+ w(D);
+ })).then(l, h);
+ }
+ v((S = S.apply(m, c || [])).next());
+ });
+ }
+ function O(m, c) {
+ var T, S, E, g, l = { label: 0, sent: function() {
+ if (1 & E[0])
+ throw E[1];
+ return E[1];
+ }, trys: [], ops: [] };
+ return g = { next: h(0), throw: h(1), return: h(2) }, typeof Symbol == "function" && (g[Symbol.iterator] = function() {
+ return this;
+ }), g;
+ function h(v) {
+ return function(b) {
+ return function(D) {
+ if (T)
+ throw new TypeError("Generator is already executing.");
+ for (; l; )
+ try {
+ if (T = 1, S && (E = 2 & D[0] ? S.return : D[0] ? S.throw || ((E = S.return) && E.call(S), 0) : S.next) && !(E = E.call(S, D[1])).done)
+ return E;
+ switch (S = 0, E && (D = [2 & D[0], E.value]), D[0]) {
+ case 0:
+ case 1:
+ E = D;
+ break;
+ case 4:
+ return l.label++, { value: D[1], done: !1 };
+ case 5:
+ l.label++, S = D[1], D = [0];
+ continue;
+ case 7:
+ D = l.ops.pop(), l.trys.pop();
+ continue;
+ default:
+ if (E = l.trys, !((E = E.length > 0 && E[E.length - 1]) || D[0] !== 6 && D[0] !== 2)) {
+ l = 0;
+ continue;
+ }
+ if (D[0] === 3 && (!E || D[1] > E[0] && D[1] < E[3])) {
+ l.label = D[1];
+ break;
+ }
+ if (D[0] === 6 && l.label < E[1]) {
+ l.label = E[1], E = D;
+ break;
+ }
+ if (E && l.label < E[2]) {
+ l.label = E[2], l.ops.push(D);
+ break;
+ }
+ E[2] && l.ops.pop(), l.trys.pop();
+ continue;
+ }
+ D = c.call(m, l);
+ } catch (w) {
+ D = [6, w], S = 0;
+ } finally {
+ T = E = 0;
+ }
+ if (5 & D[0])
+ throw D[1];
+ return { value: D[0] ? D[1] : void 0, done: !0 };
+ }([v, b]);
+ };
+ }
+ }
+ function x() {
+ for (var m = 0, c = 0, T = arguments.length; c < T; c++)
+ m += arguments[c].length;
+ var S = Array(m), E = 0;
+ for (c = 0; c < T; c++)
+ for (var g = arguments[c], l = 0, h = g.length; l < h; l++, E++)
+ S[E] = g[l];
+ return S;
+ }
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return V;
+ });
+ var V = function() {
+ function _() {
+ }
+ return _.ALPHA_DISABLE = 0, _.ALPHA_ADD = 1, _.ALPHA_COMBINE = 2, _.ALPHA_SUBTRACT = 3, _.ALPHA_MULTIPLY = 4, _.ALPHA_MAXIMIZED = 5, _.ALPHA_ONEONE = 6, _.ALPHA_PREMULTIPLIED = 7, _.ALPHA_PREMULTIPLIED_PORTERDUFF = 8, _.ALPHA_INTERPOLATE = 9, _.ALPHA_SCREENMODE = 10, _.ALPHA_ONEONE_ONEONE = 11, _.ALPHA_ALPHATOCOLOR = 12, _.ALPHA_REVERSEONEMINUS = 13, _.ALPHA_SRC_DSTONEMINUSSRCALPHA = 14, _.ALPHA_ONEONE_ONEZERO = 15, _.ALPHA_EXCLUSION = 16, _.ALPHA_EQUATION_ADD = 0, _.ALPHA_EQUATION_SUBSTRACT = 1, _.ALPHA_EQUATION_REVERSE_SUBTRACT = 2, _.ALPHA_EQUATION_MAX = 3, _.ALPHA_EQUATION_MIN = 4, _.ALPHA_EQUATION_DARKEN = 5, _.DELAYLOADSTATE_NONE = 0, _.DELAYLOADSTATE_LOADED = 1, _.DELAYLOADSTATE_LOADING = 2, _.DELAYLOADSTATE_NOTLOADED = 4, _.NEVER = 512, _.ALWAYS = 519, _.LESS = 513, _.EQUAL = 514, _.LEQUAL = 515, _.GREATER = 516, _.GEQUAL = 518, _.NOTEQUAL = 517, _.KEEP = 7680, _.REPLACE = 7681, _.INCR = 7682, _.DECR = 7683, _.INVERT = 5386, _.INCR_WRAP = 34055, _.DECR_WRAP = 34056, _.TEXTURE_CLAMP_ADDRESSMODE = 0, _.TEXTURE_WRAP_ADDRESSMODE = 1, _.TEXTURE_MIRROR_ADDRESSMODE = 2, _.TEXTUREFORMAT_ALPHA = 0, _.TEXTUREFORMAT_LUMINANCE = 1, _.TEXTUREFORMAT_LUMINANCE_ALPHA = 2, _.TEXTUREFORMAT_RGB = 4, _.TEXTUREFORMAT_RGBA = 5, _.TEXTUREFORMAT_RED = 6, _.TEXTUREFORMAT_R = 6, _.TEXTUREFORMAT_RG = 7, _.TEXTUREFORMAT_RED_INTEGER = 8, _.TEXTUREFORMAT_R_INTEGER = 8, _.TEXTUREFORMAT_RG_INTEGER = 9, _.TEXTUREFORMAT_RGB_INTEGER = 10, _.TEXTUREFORMAT_RGBA_INTEGER = 11, _.TEXTURETYPE_UNSIGNED_BYTE = 0, _.TEXTURETYPE_UNSIGNED_INT = 0, _.TEXTURETYPE_FLOAT = 1, _.TEXTURETYPE_HALF_FLOAT = 2, _.TEXTURETYPE_BYTE = 3, _.TEXTURETYPE_SHORT = 4, _.TEXTURETYPE_UNSIGNED_SHORT = 5, _.TEXTURETYPE_INT = 6, _.TEXTURETYPE_UNSIGNED_INTEGER = 7, _.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = 8, _.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = 9, _.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = 10, _.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = 11, _.TEXTURETYPE_UNSIGNED_INT_24_8 = 12, _.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = 13, _.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = 14, _.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = 15, _.TEXTURE_NEAREST_SAMPLINGMODE = 1, _.TEXTURE_NEAREST_NEAREST = 1, _.TEXTURE_BILINEAR_SAMPLINGMODE = 2, _.TEXTURE_LINEAR_LINEAR = 2, _.TEXTURE_TRILINEAR_SAMPLINGMODE = 3, _.TEXTURE_LINEAR_LINEAR_MIPLINEAR = 3, _.TEXTURE_NEAREST_NEAREST_MIPNEAREST = 4, _.TEXTURE_NEAREST_LINEAR_MIPNEAREST = 5, _.TEXTURE_NEAREST_LINEAR_MIPLINEAR = 6, _.TEXTURE_NEAREST_LINEAR = 7, _.TEXTURE_NEAREST_NEAREST_MIPLINEAR = 8, _.TEXTURE_LINEAR_NEAREST_MIPNEAREST = 9, _.TEXTURE_LINEAR_NEAREST_MIPLINEAR = 10, _.TEXTURE_LINEAR_LINEAR_MIPNEAREST = 11, _.TEXTURE_LINEAR_NEAREST = 12, _.TEXTURE_EXPLICIT_MODE = 0, _.TEXTURE_SPHERICAL_MODE = 1, _.TEXTURE_PLANAR_MODE = 2, _.TEXTURE_CUBIC_MODE = 3, _.TEXTURE_PROJECTION_MODE = 4, _.TEXTURE_SKYBOX_MODE = 5, _.TEXTURE_INVCUBIC_MODE = 6, _.TEXTURE_EQUIRECTANGULAR_MODE = 7, _.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = 8, _.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = 9, _.TEXTURE_FILTERING_QUALITY_OFFLINE = 4096, _.TEXTURE_FILTERING_QUALITY_HIGH = 64, _.TEXTURE_FILTERING_QUALITY_MEDIUM = 16, _.TEXTURE_FILTERING_QUALITY_LOW = 8, _.SCALEMODE_FLOOR = 1, _.SCALEMODE_NEAREST = 2, _.SCALEMODE_CEILING = 3, _.MATERIAL_TextureDirtyFlag = 1, _.MATERIAL_LightDirtyFlag = 2, _.MATERIAL_FresnelDirtyFlag = 4, _.MATERIAL_AttributesDirtyFlag = 8, _.MATERIAL_MiscDirtyFlag = 16, _.MATERIAL_PrePassDirtyFlag = 32, _.MATERIAL_AllDirtyFlag = 63, _.MATERIAL_TriangleFillMode = 0, _.MATERIAL_WireFrameFillMode = 1, _.MATERIAL_PointFillMode = 2, _.MATERIAL_PointListDrawMode = 3, _.MATERIAL_LineListDrawMode = 4, _.MATERIAL_LineLoopDrawMode = 5, _.MATERIAL_LineStripDrawMode = 6, _.MATERIAL_TriangleStripDrawMode = 7, _.MATERIAL_TriangleFanDrawMode = 8, _.MATERIAL_ClockWiseSideOrientation = 0, _.MATERIAL_CounterClockWiseSideOrientation = 1, _.ACTION_NothingTrigger = 0, _.ACTION_OnPickTrigger = 1, _.ACTION_OnLeftPickTrigger = 2, _.ACTION_OnRightPickTrigger = 3, _.ACTION_OnCenterPickTrigger = 4, _.ACTION_OnPickDownTrigger = 5, _.ACTION_OnDoublePickTrigger = 6, _.ACTION_OnPickUpTrigger = 7, _.ACTION_OnPickOutTrigger = 16, _.ACTION_OnLongPressTrigger = 8, _.ACTION_OnPointerOverTrigger = 9, _.ACTION_OnPointerOutTrigger = 10, _.ACTION_OnEveryFrameTrigger = 11, _.ACTION_OnIntersectionEnterTrigger = 12, _.ACTION_OnIntersectionExitTrigger = 13, _.ACTION_OnKeyDownTrigger = 14, _.ACTION_OnKeyUpTrigger = 15, _.PARTICLES_BILLBOARDMODE_Y = 2, _.PARTICLES_BILLBOARDMODE_ALL = 7, _.PARTICLES_BILLBOARDMODE_STRETCHED = 8, _.MESHES_CULLINGSTRATEGY_STANDARD = 0, _.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = 1, _.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = 2, _.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = 3, _.SCENELOADER_NO_LOGGING = 0, _.SCENELOADER_MINIMAL_LOGGING = 1, _.SCENELOADER_SUMMARY_LOGGING = 2, _.SCENELOADER_DETAILED_LOGGING = 3, _.PREPASS_IRRADIANCE_TEXTURE_TYPE = 0, _.PREPASS_POSITION_TEXTURE_TYPE = 1, _.PREPASS_VELOCITY_TEXTURE_TYPE = 2, _.PREPASS_REFLECTIVITY_TEXTURE_TYPE = 3, _.PREPASS_COLOR_TEXTURE_TYPE = 4, _.PREPASS_DEPTHNORMAL_TEXTURE_TYPE = 5, _.PREPASS_ALBEDO_TEXTURE_TYPE = 6, _;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "b", function() {
+ return T;
+ }), f.d(A, "c", function() {
+ return S;
+ }), f.d(A, "m", function() {
+ return E;
+ }), f.d(A, "e", function() {
+ return g;
+ }), f.d(A, "h", function() {
+ return l;
+ }), f.d(A, "n", function() {
+ return h;
+ }), f.d(A, "o", function() {
+ return v;
+ }), f.d(A, "k", function() {
+ return b;
+ }), f.d(A, "g", function() {
+ return D;
+ }), f.d(A, "f", function() {
+ return w;
+ }), f.d(A, "i", function() {
+ return N;
+ }), f.d(A, "l", function() {
+ return M;
+ }), f.d(A, "j", function() {
+ return U;
+ }), f.d(A, "d", function() {
+ return X;
+ }), f.d(A, "a", function() {
+ return j;
+ });
+ var V = f(37), _ = f(0), C = f(21), u = f(9), I = {}, O = {}, x = function(ne, te, de) {
+ var pe = ne();
+ V.a && V.a.AddTagsTo(pe, te.tags);
+ var ae = m(pe);
+ for (var ee in ae) {
+ var K = ae[ee], $ = te[ee], L = K.type;
+ if ($ != null && ee !== "uniqueId")
+ switch (L) {
+ case 0:
+ case 6:
+ case 11:
+ pe[ee] = $;
+ break;
+ case 1:
+ pe[ee] = de || $.isRenderTarget ? $ : $.clone();
+ break;
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 7:
+ case 10:
+ case 12:
+ pe[ee] = de ? $ : $.clone();
+ }
+ }
+ return pe;
+ };
+ function m(ne) {
+ var te = ne.getClassName();
+ if (O[te])
+ return O[te];
+ O[te] = {};
+ for (var de = O[te], pe = ne, ae = te; ae; ) {
+ var ee = I[ae];
+ for (var K in ee)
+ de[K] = ee[K];
+ var $ = void 0, L = !1;
+ do {
+ if (!($ = Object.getPrototypeOf(pe)).getClassName) {
+ L = !0;
+ break;
+ }
+ if ($.getClassName() !== ae)
+ break;
+ pe = $;
+ } while ($);
+ if (L)
+ break;
+ ae = $.getClassName(), pe = $;
+ }
+ return de;
+ }
+ function c(ne, te) {
+ return function(de, pe) {
+ var ae = function(ee) {
+ var K = ee.getClassName();
+ return I[K] || (I[K] = {}), I[K];
+ }(de);
+ ae[pe] || (ae[pe] = { type: ne, sourceName: te });
+ };
+ }
+ function T(ne, te) {
+ return te === void 0 && (te = null), function(de, pe) {
+ return pe === void 0 && (pe = null), function(ae, ee) {
+ var K = pe || "_" + ee;
+ Object.defineProperty(ae, ee, { get: function() {
+ return this[K];
+ }, set: function($) {
+ this[K] !== $ && (this[K] = $, ae[de].apply(this));
+ }, enumerable: !0, configurable: !0 });
+ };
+ }(ne, te);
+ }
+ function S(ne) {
+ return c(0, ne);
+ }
+ function E(ne) {
+ return c(1, ne);
+ }
+ function g(ne) {
+ return c(2, ne);
+ }
+ function l(ne) {
+ return c(3, ne);
+ }
+ function h(ne) {
+ return c(4, ne);
+ }
+ function v(ne) {
+ return c(5, ne);
+ }
+ function b(ne) {
+ return c(6, ne);
+ }
+ function D(ne) {
+ return c(7, ne);
+ }
+ function w(ne) {
+ return c(8, ne);
+ }
+ function N(ne) {
+ return c(9, ne);
+ }
+ function M(ne) {
+ return c(10, ne);
+ }
+ function U(ne) {
+ return c(12, ne);
+ }
+ function X(ne) {
+ return c(11, ne);
+ }
+ var j = function() {
+ function ne() {
+ }
+ return ne.AppendSerializedAnimations = function(te, de) {
+ if (te.animations) {
+ de.animations = [];
+ for (var pe = 0; pe < te.animations.length; pe++) {
+ var ae = te.animations[pe];
+ de.animations.push(ae.serialize());
+ }
+ }
+ }, ne.Serialize = function(te, de) {
+ de || (de = {}), V.a && (de.tags = V.a.GetTags(te));
+ var pe = m(te);
+ for (var ae in pe) {
+ var ee = pe[ae], K = ee.sourceName || ae, $ = ee.type, L = te[ae];
+ if (L != null && ae !== "uniqueId")
+ switch ($) {
+ case 0:
+ de[K] = L;
+ break;
+ case 1:
+ de[K] = L.serialize();
+ break;
+ case 2:
+ de[K] = L.asArray();
+ break;
+ case 3:
+ de[K] = L.serialize();
+ break;
+ case 4:
+ case 5:
+ de[K] = L.asArray();
+ break;
+ case 6:
+ de[K] = L.id;
+ break;
+ case 7:
+ de[K] = L.serialize();
+ break;
+ case 8:
+ de[K] = L.asArray();
+ break;
+ case 9:
+ de[K] = L.serialize();
+ break;
+ case 10:
+ de[K] = L.asArray();
+ break;
+ case 11:
+ de[K] = L.id;
+ case 12:
+ de[K] = L.asArray();
+ }
+ }
+ return de;
+ }, ne.Parse = function(te, de, pe, ae) {
+ ae === void 0 && (ae = null);
+ var ee = te();
+ ae || (ae = ""), V.a && V.a.AddTagsTo(ee, de.tags);
+ var K = m(ee);
+ for (var $ in K) {
+ var L = K[$], G = de[L.sourceName || $], Q = L.type;
+ if (G != null && $ !== "uniqueId") {
+ var oe = ee;
+ switch (Q) {
+ case 0:
+ oe[$] = G;
+ break;
+ case 1:
+ pe && (oe[$] = ne._TextureParser(G, pe, ae));
+ break;
+ case 2:
+ oe[$] = u.a.FromArray(G);
+ break;
+ case 3:
+ oe[$] = ne._FresnelParametersParser(G);
+ break;
+ case 4:
+ oe[$] = _.d.FromArray(G);
+ break;
+ case 5:
+ oe[$] = _.e.FromArray(G);
+ break;
+ case 6:
+ pe && (oe[$] = pe.getLastMeshByID(G));
+ break;
+ case 7:
+ oe[$] = ne._ColorCurvesParser(G);
+ break;
+ case 8:
+ oe[$] = u.b.FromArray(G);
+ break;
+ case 9:
+ oe[$] = ne._ImageProcessingConfigurationParser(G);
+ break;
+ case 10:
+ oe[$] = _.b.FromArray(G);
+ break;
+ case 11:
+ pe && (oe[$] = pe.getCameraByID(G));
+ case 12:
+ oe[$] = _.a.FromArray(G);
+ }
+ }
+ }
+ return ee;
+ }, ne.Clone = function(te, de) {
+ return x(te, de, !1);
+ }, ne.Instanciate = function(te, de) {
+ return x(te, de, !0);
+ }, ne._ImageProcessingConfigurationParser = function(te) {
+ throw C.a.WarnImport("ImageProcessingConfiguration");
+ }, ne._FresnelParametersParser = function(te) {
+ throw C.a.WarnImport("FresnelParameters");
+ }, ne._ColorCurvesParser = function(te) {
+ throw C.a.WarnImport("ColorCurves");
+ }, ne._TextureParser = function(te, de, pe) {
+ throw C.a.WarnImport("Texture");
+ }, ne;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return V;
+ }), f.d(A, "b", function() {
+ return _;
+ });
+ var V = function() {
+ function C(u, I, O, x, m, c, T, S) {
+ x === void 0 && (x = 0), m === void 0 && (m = !1), c === void 0 && (c = !1), T === void 0 && (T = !1), this._isAlreadyOwned = !1, u.getScene ? this._engine = u.getScene().getEngine() : this._engine = u, this._updatable = O, this._instanced = c, this._divisor = S || 1, this._data = I, this.byteStride = T ? x : x * Float32Array.BYTES_PER_ELEMENT, m || this.create();
+ }
+ return C.prototype.createVertexBuffer = function(u, I, O, x, m, c, T) {
+ c === void 0 && (c = !1);
+ var S = c ? I : I * Float32Array.BYTES_PER_ELEMENT, E = x ? c ? x : x * Float32Array.BYTES_PER_ELEMENT : this.byteStride;
+ return new _(this._engine, this, u, this._updatable, !0, E, m === void 0 ? this._instanced : m, S, O, void 0, void 0, !0, this._divisor || T);
+ }, C.prototype.isUpdatable = function() {
+ return this._updatable;
+ }, C.prototype.getData = function() {
+ return this._data;
+ }, C.prototype.getBuffer = function() {
+ return this._buffer;
+ }, C.prototype.getStrideSize = function() {
+ return this.byteStride / Float32Array.BYTES_PER_ELEMENT;
+ }, C.prototype.create = function(u) {
+ u === void 0 && (u = null), !u && this._buffer || (u = u || this._data) && (this._buffer ? this._updatable && (this._engine.updateDynamicVertexBuffer(this._buffer, u), this._data = u) : this._updatable ? (this._buffer = this._engine.createDynamicVertexBuffer(u), this._data = u) : this._buffer = this._engine.createVertexBuffer(u));
+ }, C.prototype._rebuild = function() {
+ this._buffer = null, this.create(this._data);
+ }, C.prototype.update = function(u) {
+ this.create(u);
+ }, C.prototype.updateDirectly = function(u, I, O, x) {
+ x === void 0 && (x = !1), this._buffer && this._updatable && (this._engine.updateDynamicVertexBuffer(this._buffer, u, x ? I : I * Float32Array.BYTES_PER_ELEMENT, O ? O * this.byteStride : void 0), this._data = null);
+ }, C.prototype._increaseReferences = function() {
+ this._buffer && (this._isAlreadyOwned ? this._buffer.references++ : this._isAlreadyOwned = !0);
+ }, C.prototype.dispose = function() {
+ this._buffer && this._engine._releaseBuffer(this._buffer) && (this._buffer = null);
+ }, C;
+ }(), _ = function() {
+ function C(u, I, O, x, m, c, T, S, E, g, l, h, v, b) {
+ if (l === void 0 && (l = !1), h === void 0 && (h = !1), v === void 0 && (v = 1), b === void 0 && (b = !1), I instanceof V ? (this._buffer = I, this._ownsBuffer = b, b && this._buffer._increaseReferences()) : (this._buffer = new V(u, I, x, c, m, T, h), this._ownsBuffer = !0), this._kind = O, g == null) {
+ var D = this.getData();
+ this.type = C.FLOAT, D instanceof Int8Array ? this.type = C.BYTE : D instanceof Uint8Array ? this.type = C.UNSIGNED_BYTE : D instanceof Int16Array ? this.type = C.SHORT : D instanceof Uint16Array ? this.type = C.UNSIGNED_SHORT : D instanceof Int32Array ? this.type = C.INT : D instanceof Uint32Array && (this.type = C.UNSIGNED_INT);
+ } else
+ this.type = g;
+ var w = C.GetTypeByteLength(this.type);
+ h ? (this._size = E || (c ? c / w : C.DeduceStride(O)), this.byteStride = c || this._buffer.byteStride || this._size * w, this.byteOffset = S || 0) : (this._size = E || c || C.DeduceStride(O), this.byteStride = c ? c * w : this._buffer.byteStride || this._size * w, this.byteOffset = (S || 0) * w), this.normalized = l, this._instanced = T !== void 0 && T, this._instanceDivisor = T ? v : 0;
+ }
+ return Object.defineProperty(C.prototype, "instanceDivisor", { get: function() {
+ return this._instanceDivisor;
+ }, set: function(u) {
+ this._instanceDivisor = u, this._instanced = u != 0;
+ }, enumerable: !1, configurable: !0 }), C.prototype._rebuild = function() {
+ this._buffer && this._buffer._rebuild();
+ }, C.prototype.getKind = function() {
+ return this._kind;
+ }, C.prototype.isUpdatable = function() {
+ return this._buffer.isUpdatable();
+ }, C.prototype.getData = function() {
+ return this._buffer.getData();
+ }, C.prototype.getBuffer = function() {
+ return this._buffer.getBuffer();
+ }, C.prototype.getStrideSize = function() {
+ return this.byteStride / C.GetTypeByteLength(this.type);
+ }, C.prototype.getOffset = function() {
+ return this.byteOffset / C.GetTypeByteLength(this.type);
+ }, C.prototype.getSize = function() {
+ return this._size;
+ }, C.prototype.getIsInstanced = function() {
+ return this._instanced;
+ }, C.prototype.getInstanceDivisor = function() {
+ return this._instanceDivisor;
+ }, C.prototype.create = function(u) {
+ this._buffer.create(u);
+ }, C.prototype.update = function(u) {
+ this._buffer.update(u);
+ }, C.prototype.updateDirectly = function(u, I, O) {
+ O === void 0 && (O = !1), this._buffer.updateDirectly(u, I, void 0, O);
+ }, C.prototype.dispose = function() {
+ this._ownsBuffer && this._buffer.dispose();
+ }, C.prototype.forEach = function(u, I) {
+ C.ForEach(this._buffer.getData(), this.byteOffset, this.byteStride, this._size, this.type, u, this.normalized, I);
+ }, C.DeduceStride = function(u) {
+ switch (u) {
+ case C.UVKind:
+ case C.UV2Kind:
+ case C.UV3Kind:
+ case C.UV4Kind:
+ case C.UV5Kind:
+ case C.UV6Kind:
+ return 2;
+ case C.NormalKind:
+ case C.PositionKind:
+ return 3;
+ case C.ColorKind:
+ case C.MatricesIndicesKind:
+ case C.MatricesIndicesExtraKind:
+ case C.MatricesWeightsKind:
+ case C.MatricesWeightsExtraKind:
+ case C.TangentKind:
+ return 4;
+ default:
+ throw new Error("Invalid kind '" + u + "'");
+ }
+ }, C.GetTypeByteLength = function(u) {
+ switch (u) {
+ case C.BYTE:
+ case C.UNSIGNED_BYTE:
+ return 1;
+ case C.SHORT:
+ case C.UNSIGNED_SHORT:
+ return 2;
+ case C.INT:
+ case C.UNSIGNED_INT:
+ case C.FLOAT:
+ return 4;
+ default:
+ throw new Error("Invalid type '" + u + "'");
+ }
+ }, C.ForEach = function(u, I, O, x, m, c, T, S) {
+ if (u instanceof Array)
+ for (var E = I / 4, g = O / 4, l = 0; l < c; l += x) {
+ for (var h = 0; h < x; h++)
+ S(u[E + h], l + h);
+ E += g;
+ }
+ else {
+ var v = u instanceof ArrayBuffer ? new DataView(u) : new DataView(u.buffer, u.byteOffset, u.byteLength), b = C.GetTypeByteLength(m);
+ for (l = 0; l < c; l += x) {
+ var D = I;
+ for (h = 0; h < x; h++)
+ S(C._GetFloatValue(v, m, D, T), l + h), D += b;
+ I += O;
+ }
+ }
+ }, C._GetFloatValue = function(u, I, O, x) {
+ switch (I) {
+ case C.BYTE:
+ var m = u.getInt8(O);
+ return x && (m = Math.max(m / 127, -1)), m;
+ case C.UNSIGNED_BYTE:
+ return m = u.getUint8(O), x && (m /= 255), m;
+ case C.SHORT:
+ return m = u.getInt16(O, !0), x && (m = Math.max(m / 32767, -1)), m;
+ case C.UNSIGNED_SHORT:
+ return m = u.getUint16(O, !0), x && (m /= 65535), m;
+ case C.INT:
+ return u.getInt32(O, !0);
+ case C.UNSIGNED_INT:
+ return u.getUint32(O, !0);
+ case C.FLOAT:
+ return u.getFloat32(O, !0);
+ default:
+ throw new Error("Invalid component type " + I);
+ }
+ }, C.BYTE = 5120, C.UNSIGNED_BYTE = 5121, C.SHORT = 5122, C.UNSIGNED_SHORT = 5123, C.INT = 5124, C.UNSIGNED_INT = 5125, C.FLOAT = 5126, C.PositionKind = "position", C.NormalKind = "normal", C.TangentKind = "tangent", C.UVKind = "uv", C.UV2Kind = "uv2", C.UV3Kind = "uv3", C.UV4Kind = "uv4", C.UV5Kind = "uv5", C.UV6Kind = "uv6", C.ColorKind = "color", C.MatricesIndicesKind = "matricesIndices", C.MatricesWeightsKind = "matricesWeights", C.MatricesIndicesExtraKind = "matricesIndicesExtra", C.MatricesWeightsExtraKind = "matricesWeightsExtra", C;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return O;
+ });
+ var V = f(6), _ = f(2), C = f(38), u = f(8), I = f(128), O = function() {
+ function x(m, c, T, S, E, g, l, h, v, b) {
+ var D, w = this;
+ S === void 0 && (S = null), g === void 0 && (g = null), l === void 0 && (l = null), h === void 0 && (h = null), v === void 0 && (v = null), this.name = null, this.defines = "", this.onCompiled = null, this.onError = null, this.onBind = null, this.uniqueId = 0, this.onCompileObservable = new V.c(), this.onErrorObservable = new V.c(), this._onBindObservable = null, this._wasPreviouslyReady = !1, this._bonesComputationForcedToCPU = !1, this._multiTarget = !1, this._uniformBuffersNames = {}, this._samplers = {}, this._isReady = !1, this._compilationError = "", this._allFallbacksProcessed = !1, this._uniforms = {}, this._key = "", this._fallbacks = null, this._vertexSourceCode = "", this._fragmentSourceCode = "", this._vertexSourceCodeOverride = "", this._fragmentSourceCodeOverride = "", this._transformFeedbackVaryings = null, this._rawVertexSourceCode = "", this._rawFragmentSourceCode = "", this._pipelineContext = null, this._valueCache = {}, this.name = m;
+ var N, M, U = null;
+ if (c.attributes) {
+ var X = c;
+ if (this._engine = T, this._attributesNames = X.attributes, this._uniformsNames = X.uniformsNames.concat(X.samplers), this._samplerList = X.samplers.slice(), this.defines = X.defines, this.onError = X.onError, this.onCompiled = X.onCompiled, this._fallbacks = X.fallbacks, this._indexParameters = X.indexParameters, this._transformFeedbackVaryings = X.transformFeedbackVaryings || null, this._multiTarget = !!X.multiTarget, X.uniformBuffersNames) {
+ this._uniformBuffersNamesList = X.uniformBuffersNames.slice();
+ for (var j = 0; j < X.uniformBuffersNames.length; j++)
+ this._uniformBuffersNames[X.uniformBuffersNames[j]] = j;
+ }
+ U = (D = X.processFinalCode) !== null && D !== void 0 ? D : null;
+ } else
+ this._engine = E, this.defines = g ?? "", this._uniformsNames = T.concat(S), this._samplerList = S ? S.slice() : [], this._attributesNames = c, this._uniformBuffersNamesList = [], this.onError = v, this.onCompiled = h, this._indexParameters = b, this._fallbacks = l;
+ this._attributeLocationByName = {}, this.uniqueId = x._uniqueIdSeed++;
+ var ne = C.a.IsWindowObjectExist() ? this._engine.getHostDocument() : null;
+ m.vertexSource ? N = "source:" + m.vertexSource : m.vertexElement ? (N = ne ? ne.getElementById(m.vertexElement) : null) || (N = m.vertexElement) : N = m.vertex || m, m.fragmentSource ? M = "source:" + m.fragmentSource : m.fragmentElement ? (M = ne ? ne.getElementById(m.fragmentElement) : null) || (M = m.fragmentElement) : M = m.fragment || m;
+ var te = { defines: this.defines.split(`
+`), indexParameters: this._indexParameters, isFragment: !1, shouldUseHighPrecisionShader: this._engine._shouldUseHighPrecisionShader, processor: this._engine._shaderProcessor, supportsUniformBuffers: this._engine.supportsUniformBuffers, shadersRepository: x.ShadersRepository, includesShadersStore: x.IncludesShadersStore, version: (100 * this._engine.webGLVersion).toString(), platformName: this._engine.webGLVersion >= 2 ? "WEBGL2" : "WEBGL1" };
+ this._loadShader(N, "Vertex", "", function(de) {
+ w._rawVertexSourceCode = de, w._loadShader(M, "Fragment", "Pixel", function(pe) {
+ w._rawFragmentSourceCode = pe, I.a.Process(de, te, function(ae) {
+ U && (ae = U("vertex", ae)), te.isFragment = !0, I.a.Process(pe, te, function(ee) {
+ U && (ee = U("fragment", ee)), w._useFinalCode(ae, ee, m);
+ }, w._engine);
+ }, w._engine);
+ });
+ });
+ }
+ return Object.defineProperty(x.prototype, "onBindObservable", { get: function() {
+ return this._onBindObservable || (this._onBindObservable = new V.c()), this._onBindObservable;
+ }, enumerable: !1, configurable: !0 }), x.prototype._useFinalCode = function(m, c, T) {
+ if (T) {
+ var S = T.vertexElement || T.vertex || T.spectorName || T, E = T.fragmentElement || T.fragment || T.spectorName || T;
+ this._vertexSourceCode = "#define SHADER_NAME vertex:" + S + `
+` + m, this._fragmentSourceCode = "#define SHADER_NAME fragment:" + E + `
+` + c;
+ } else
+ this._vertexSourceCode = m, this._fragmentSourceCode = c;
+ this._prepareEffect();
+ }, Object.defineProperty(x.prototype, "key", { get: function() {
+ return this._key;
+ }, enumerable: !1, configurable: !0 }), x.prototype.isReady = function() {
+ try {
+ return this._isReadyInternal();
+ } catch {
+ return !1;
+ }
+ }, x.prototype._isReadyInternal = function() {
+ return !!this._isReady || !!this._pipelineContext && this._pipelineContext.isReady;
+ }, x.prototype.getEngine = function() {
+ return this._engine;
+ }, x.prototype.getPipelineContext = function() {
+ return this._pipelineContext;
+ }, x.prototype.getAttributesNames = function() {
+ return this._attributesNames;
+ }, x.prototype.getAttributeLocation = function(m) {
+ return this._attributes[m];
+ }, x.prototype.getAttributeLocationByName = function(m) {
+ return this._attributeLocationByName[m];
+ }, x.prototype.getAttributesCount = function() {
+ return this._attributes.length;
+ }, x.prototype.getUniformIndex = function(m) {
+ return this._uniformsNames.indexOf(m);
+ }, x.prototype.getUniform = function(m) {
+ return this._uniforms[m];
+ }, x.prototype.getSamplers = function() {
+ return this._samplerList;
+ }, x.prototype.getUniformNames = function() {
+ return this._uniformsNames;
+ }, x.prototype.getUniformBuffersNames = function() {
+ return this._uniformBuffersNamesList;
+ }, x.prototype.getIndexParameters = function() {
+ return this._indexParameters;
+ }, x.prototype.getCompilationError = function() {
+ return this._compilationError;
+ }, x.prototype.allFallbacksProcessed = function() {
+ return this._allFallbacksProcessed;
+ }, x.prototype.executeWhenCompiled = function(m) {
+ var c = this;
+ this.isReady() ? m(this) : (this.onCompileObservable.add(function(T) {
+ m(T);
+ }), this._pipelineContext && !this._pipelineContext.isAsync || setTimeout(function() {
+ c._checkIsReady(null);
+ }, 16));
+ }, x.prototype._checkIsReady = function(m) {
+ var c = this;
+ try {
+ if (this._isReadyInternal())
+ return;
+ } catch (T) {
+ return void this._processCompilationErrors(T, m);
+ }
+ setTimeout(function() {
+ c._checkIsReady(m);
+ }, 16);
+ }, x.prototype._loadShader = function(m, c, T, S) {
+ var E;
+ if (typeof HTMLElement < "u" && m instanceof HTMLElement)
+ return void S(C.a.GetDOMTextContent(m));
+ m.substr(0, 7) !== "source:" ? m.substr(0, 7) !== "base64:" ? x.ShadersStore[m + c + "Shader"] ? S(x.ShadersStore[m + c + "Shader"]) : T && x.ShadersStore[m + T + "Shader"] ? S(x.ShadersStore[m + T + "Shader"]) : (E = m[0] === "." || m[0] === "/" || m.indexOf("http") > -1 ? m : x.ShadersRepository + m, this._engine._loadFile(E + "." + c.toLowerCase() + ".fx", S)) : S(window.atob(m.substr(7))) : S(m.substr(7));
+ }, Object.defineProperty(x.prototype, "vertexSourceCode", { get: function() {
+ return this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride ? this._vertexSourceCodeOverride : this._vertexSourceCode;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(x.prototype, "fragmentSourceCode", { get: function() {
+ return this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride ? this._fragmentSourceCodeOverride : this._fragmentSourceCode;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(x.prototype, "rawVertexSourceCode", { get: function() {
+ return this._rawVertexSourceCode;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(x.prototype, "rawFragmentSourceCode", { get: function() {
+ return this._rawFragmentSourceCode;
+ }, enumerable: !1, configurable: !0 }), x.prototype._rebuildProgram = function(m, c, T, S) {
+ var E = this;
+ this._isReady = !1, this._vertexSourceCodeOverride = m, this._fragmentSourceCodeOverride = c, this.onError = function(g, l) {
+ S && S(l);
+ }, this.onCompiled = function() {
+ var g = E.getEngine().scenes;
+ if (g)
+ for (var l = 0; l < g.length; l++)
+ g[l].markAllMaterialsAsDirty(_.a.MATERIAL_AllDirtyFlag);
+ E._pipelineContext._handlesSpectorRebuildCallback(T);
+ }, this._fallbacks = null, this._prepareEffect();
+ }, x.prototype._prepareEffect = function() {
+ var m = this, c = this._attributesNames, T = this.defines;
+ this._valueCache = {};
+ var S = this._pipelineContext;
+ try {
+ var E = this._engine;
+ this._pipelineContext = E.createPipelineContext();
+ var g = this._rebuildProgram.bind(this);
+ this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride ? E._preparePipelineContext(this._pipelineContext, this._vertexSourceCodeOverride, this._fragmentSourceCodeOverride, !0, g, null, this._transformFeedbackVaryings) : E._preparePipelineContext(this._pipelineContext, this._vertexSourceCode, this._fragmentSourceCode, !1, g, T, this._transformFeedbackVaryings), E._executeWhenRenderingStateIsCompiled(this._pipelineContext, function() {
+ if (E.supportsUniformBuffers)
+ for (var l in m._uniformBuffersNames)
+ m.bindUniformBlock(l, m._uniformBuffersNames[l]);
+ var h;
+ if (E.getUniforms(m._pipelineContext, m._uniformsNames).forEach(function(D, w) {
+ m._uniforms[m._uniformsNames[w]] = D;
+ }), m._attributes = E.getAttributes(m._pipelineContext, c), c)
+ for (var v = 0; v < c.length; v++) {
+ var b = c[v];
+ m._attributeLocationByName[b] = m._attributes[v];
+ }
+ for (h = 0; h < m._samplerList.length; h++)
+ m.getUniform(m._samplerList[h]) == null && (m._samplerList.splice(h, 1), h--);
+ m._samplerList.forEach(function(D, w) {
+ m._samplers[D] = w;
+ }), E.bindSamplers(m), m._compilationError = "", m._isReady = !0, m.onCompiled && m.onCompiled(m), m.onCompileObservable.notifyObservers(m), m.onCompileObservable.clear(), m._fallbacks && m._fallbacks.unBindMesh(), S && m.getEngine()._deletePipelineContext(S);
+ }), this._pipelineContext.isAsync && this._checkIsReady(S);
+ } catch (l) {
+ this._processCompilationErrors(l, S);
+ }
+ }, x.prototype._getShaderCodeAndErrorLine = function(m, c, T) {
+ var S = T ? /FRAGMENT SHADER ERROR: 0:(\d+?):/ : /VERTEX SHADER ERROR: 0:(\d+?):/, E = null;
+ if (c && m) {
+ var g = c.match(S);
+ if (g && g.length === 2) {
+ var l = parseInt(g[1]), h = m.split(`
+`, -1);
+ h.length >= l && (E = "Offending line [" + l + "] in " + (T ? "fragment" : "vertex") + " code: " + h[l - 1]);
+ }
+ }
+ return [m, E];
+ }, x.prototype._processCompilationErrors = function(m, c) {
+ var T, S, E, g, l;
+ c === void 0 && (c = null), this._compilationError = m.message;
+ var h = this._attributesNames, v = this._fallbacks;
+ if (u.a.Error("Unable to compile effect:"), u.a.Error("Uniforms: " + this._uniformsNames.map(function(N) {
+ return " " + N;
+ })), u.a.Error("Attributes: " + h.map(function(N) {
+ return " " + N;
+ })), u.a.Error(`Defines:\r
+` + this.defines), x.LogShaderCodeOnCompilationError) {
+ var b = null, D = null, w = null;
+ !((E = this._pipelineContext) === null || E === void 0) && E._getVertexShaderCode() && (w = (T = this._getShaderCodeAndErrorLine(this._pipelineContext._getVertexShaderCode(), this._compilationError, !1))[0], b = T[1], w && (u.a.Error("Vertex code:"), u.a.Error(w))), !((g = this._pipelineContext) === null || g === void 0) && g._getFragmentShaderCode() && (w = (S = this._getShaderCodeAndErrorLine((l = this._pipelineContext) === null || l === void 0 ? void 0 : l._getFragmentShaderCode(), this._compilationError, !0))[0], D = S[1], w && (u.a.Error("Fragment code:"), u.a.Error(w))), b && u.a.Error(b), D && u.a.Error(D);
+ }
+ u.a.Error("Error: " + this._compilationError), c && (this._pipelineContext = c, this._isReady = !0, this.onError && this.onError(this, this._compilationError), this.onErrorObservable.notifyObservers(this)), v ? (this._pipelineContext = null, v.hasMoreFallbacks ? (this._allFallbacksProcessed = !1, u.a.Error("Trying next fallback."), this.defines = v.reduce(this.defines, this), this._prepareEffect()) : (this._allFallbacksProcessed = !0, this.onError && this.onError(this, this._compilationError), this.onErrorObservable.notifyObservers(this), this.onErrorObservable.clear(), this._fallbacks && this._fallbacks.unBindMesh())) : this._allFallbacksProcessed = !0;
+ }, Object.defineProperty(x.prototype, "isSupported", { get: function() {
+ return this._compilationError === "";
+ }, enumerable: !1, configurable: !0 }), x.prototype._bindTexture = function(m, c) {
+ this._engine._bindTexture(this._samplers[m], c);
+ }, x.prototype.setTexture = function(m, c) {
+ this._engine.setTexture(this._samplers[m], this._uniforms[m], c);
+ }, x.prototype.setDepthStencilTexture = function(m, c) {
+ this._engine.setDepthStencilTexture(this._samplers[m], this._uniforms[m], c);
+ }, x.prototype.setTextureArray = function(m, c) {
+ var T = m + "Ex";
+ if (this._samplerList.indexOf(T + "0") === -1) {
+ for (var S = this._samplerList.indexOf(m), E = 1; E < c.length; E++) {
+ var g = T + (E - 1).toString();
+ this._samplerList.splice(S + E, 0, g);
+ }
+ for (var l = 0, h = 0, v = this._samplerList; h < v.length; h++) {
+ var b = v[h];
+ this._samplers[b] = l, l += 1;
+ }
+ }
+ this._engine.setTextureArray(this._samplers[m], this._uniforms[m], c);
+ }, x.prototype.setTextureFromPostProcess = function(m, c) {
+ this._engine.setTextureFromPostProcess(this._samplers[m], c);
+ }, x.prototype.setTextureFromPostProcessOutput = function(m, c) {
+ this._engine.setTextureFromPostProcessOutput(this._samplers[m], c);
+ }, x.prototype._cacheMatrix = function(m, c) {
+ var T = this._valueCache[m], S = c.updateFlag;
+ return (T === void 0 || T !== S) && (this._valueCache[m] = S, !0);
+ }, x.prototype._cacheFloat2 = function(m, c, T) {
+ var S = this._valueCache[m];
+ if (!S || S.length !== 2)
+ return S = [c, T], this._valueCache[m] = S, !0;
+ var E = !1;
+ return S[0] !== c && (S[0] = c, E = !0), S[1] !== T && (S[1] = T, E = !0), E;
+ }, x.prototype._cacheFloat3 = function(m, c, T, S) {
+ var E = this._valueCache[m];
+ if (!E || E.length !== 3)
+ return E = [c, T, S], this._valueCache[m] = E, !0;
+ var g = !1;
+ return E[0] !== c && (E[0] = c, g = !0), E[1] !== T && (E[1] = T, g = !0), E[2] !== S && (E[2] = S, g = !0), g;
+ }, x.prototype._cacheFloat4 = function(m, c, T, S, E) {
+ var g = this._valueCache[m];
+ if (!g || g.length !== 4)
+ return g = [c, T, S, E], this._valueCache[m] = g, !0;
+ var l = !1;
+ return g[0] !== c && (g[0] = c, l = !0), g[1] !== T && (g[1] = T, l = !0), g[2] !== S && (g[2] = S, l = !0), g[3] !== E && (g[3] = E, l = !0), l;
+ }, x.prototype.bindUniformBuffer = function(m, c) {
+ var T = this._uniformBuffersNames[c];
+ T !== void 0 && x._baseCache[T] !== m && (x._baseCache[T] = m, this._engine.bindUniformBufferBase(m, T));
+ }, x.prototype.bindUniformBlock = function(m, c) {
+ this._engine.bindUniformBlock(this._pipelineContext, m, c);
+ }, x.prototype.setInt = function(m, c) {
+ var T = this._valueCache[m];
+ return T !== void 0 && T === c || this._engine.setInt(this._uniforms[m], c) && (this._valueCache[m] = c), this;
+ }, x.prototype.setIntArray = function(m, c) {
+ return this._valueCache[m] = null, this._engine.setIntArray(this._uniforms[m], c), this;
+ }, x.prototype.setIntArray2 = function(m, c) {
+ return this._valueCache[m] = null, this._engine.setIntArray2(this._uniforms[m], c), this;
+ }, x.prototype.setIntArray3 = function(m, c) {
+ return this._valueCache[m] = null, this._engine.setIntArray3(this._uniforms[m], c), this;
+ }, x.prototype.setIntArray4 = function(m, c) {
+ return this._valueCache[m] = null, this._engine.setIntArray4(this._uniforms[m], c), this;
+ }, x.prototype.setFloatArray = function(m, c) {
+ return this._valueCache[m] = null, this._engine.setArray(this._uniforms[m], c), this;
+ }, x.prototype.setFloatArray2 = function(m, c) {
+ return this._valueCache[m] = null, this._engine.setArray2(this._uniforms[m], c), this;
+ }, x.prototype.setFloatArray3 = function(m, c) {
+ return this._valueCache[m] = null, this._engine.setArray3(this._uniforms[m], c), this;
+ }, x.prototype.setFloatArray4 = function(m, c) {
+ return this._valueCache[m] = null, this._engine.setArray4(this._uniforms[m], c), this;
+ }, x.prototype.setArray = function(m, c) {
+ return this._valueCache[m] = null, this._engine.setArray(this._uniforms[m], c), this;
+ }, x.prototype.setArray2 = function(m, c) {
+ return this._valueCache[m] = null, this._engine.setArray2(this._uniforms[m], c), this;
+ }, x.prototype.setArray3 = function(m, c) {
+ return this._valueCache[m] = null, this._engine.setArray3(this._uniforms[m], c), this;
+ }, x.prototype.setArray4 = function(m, c) {
+ return this._valueCache[m] = null, this._engine.setArray4(this._uniforms[m], c), this;
+ }, x.prototype.setMatrices = function(m, c) {
+ return c ? (this._valueCache[m] = null, this._engine.setMatrices(this._uniforms[m], c), this) : this;
+ }, x.prototype.setMatrix = function(m, c) {
+ return this._cacheMatrix(m, c) && (this._engine.setMatrices(this._uniforms[m], c.toArray()) || (this._valueCache[m] = null)), this;
+ }, x.prototype.setMatrix3x3 = function(m, c) {
+ return this._valueCache[m] = null, this._engine.setMatrix3x3(this._uniforms[m], c), this;
+ }, x.prototype.setMatrix2x2 = function(m, c) {
+ return this._valueCache[m] = null, this._engine.setMatrix2x2(this._uniforms[m], c), this;
+ }, x.prototype.setFloat = function(m, c) {
+ var T = this._valueCache[m];
+ return T !== void 0 && T === c || this._engine.setFloat(this._uniforms[m], c) && (this._valueCache[m] = c), this;
+ }, x.prototype.setBool = function(m, c) {
+ var T = this._valueCache[m];
+ return T !== void 0 && T === c || this._engine.setInt(this._uniforms[m], c ? 1 : 0) && (this._valueCache[m] = c), this;
+ }, x.prototype.setVector2 = function(m, c) {
+ return this._cacheFloat2(m, c.x, c.y) && (this._engine.setFloat2(this._uniforms[m], c.x, c.y) || (this._valueCache[m] = null)), this;
+ }, x.prototype.setFloat2 = function(m, c, T) {
+ return this._cacheFloat2(m, c, T) && (this._engine.setFloat2(this._uniforms[m], c, T) || (this._valueCache[m] = null)), this;
+ }, x.prototype.setVector3 = function(m, c) {
+ return this._cacheFloat3(m, c.x, c.y, c.z) && (this._engine.setFloat3(this._uniforms[m], c.x, c.y, c.z) || (this._valueCache[m] = null)), this;
+ }, x.prototype.setFloat3 = function(m, c, T, S) {
+ return this._cacheFloat3(m, c, T, S) && (this._engine.setFloat3(this._uniforms[m], c, T, S) || (this._valueCache[m] = null)), this;
+ }, x.prototype.setVector4 = function(m, c) {
+ return this._cacheFloat4(m, c.x, c.y, c.z, c.w) && (this._engine.setFloat4(this._uniforms[m], c.x, c.y, c.z, c.w) || (this._valueCache[m] = null)), this;
+ }, x.prototype.setFloat4 = function(m, c, T, S, E) {
+ return this._cacheFloat4(m, c, T, S, E) && (this._engine.setFloat4(this._uniforms[m], c, T, S, E) || (this._valueCache[m] = null)), this;
+ }, x.prototype.setColor3 = function(m, c) {
+ return this._cacheFloat3(m, c.r, c.g, c.b) && (this._engine.setFloat3(this._uniforms[m], c.r, c.g, c.b) || (this._valueCache[m] = null)), this;
+ }, x.prototype.setColor4 = function(m, c, T) {
+ return this._cacheFloat4(m, c.r, c.g, c.b, T) && (this._engine.setFloat4(this._uniforms[m], c.r, c.g, c.b, T) || (this._valueCache[m] = null)), this;
+ }, x.prototype.setDirectColor4 = function(m, c) {
+ return this._cacheFloat4(m, c.r, c.g, c.b, c.a) && (this._engine.setFloat4(this._uniforms[m], c.r, c.g, c.b, c.a) || (this._valueCache[m] = null)), this;
+ }, x.prototype.dispose = function() {
+ this._engine._releaseEffect(this);
+ }, x.RegisterShader = function(m, c, T) {
+ c && (x.ShadersStore[m + "PixelShader"] = c), T && (x.ShadersStore[m + "VertexShader"] = T);
+ }, x.ResetCache = function() {
+ x._baseCache = {};
+ }, x.ShadersRepository = "src/Shaders/", x.LogShaderCodeOnCompilationError = !0, x._uniqueIdSeed = 0, x._baseCache = {}, x.ShadersStore = {}, x.IncludesShadersStore = {}, x;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return V;
+ }), f.d(A, "d", function() {
+ return _;
+ }), f.d(A, "b", function() {
+ return C;
+ }), f.d(A, "c", function() {
+ return u;
+ });
+ var V = function() {
+ function I(O, x, m, c) {
+ x === void 0 && (x = !1), this.initalize(O, x, m, c);
+ }
+ return I.prototype.initalize = function(O, x, m, c) {
+ return x === void 0 && (x = !1), this.mask = O, this.skipNextObservers = x, this.target = m, this.currentTarget = c, this;
+ }, I;
+ }(), _ = function(I, O, x) {
+ x === void 0 && (x = null), this.callback = I, this.mask = O, this.scope = x, this._willBeUnregistered = !1, this.unregisterOnNextCall = !1;
+ }, C = function() {
+ function I() {
+ }
+ return I.prototype.dispose = function() {
+ if (this._observers && this._observables)
+ for (var O = 0; O < this._observers.length; O++)
+ this._observables[O].remove(this._observers[O]);
+ this._observers = null, this._observables = null;
+ }, I.Watch = function(O, x, m, c) {
+ m === void 0 && (m = -1), c === void 0 && (c = null);
+ var T = new I();
+ T._observers = new Array(), T._observables = O;
+ for (var S = 0, E = O; S < E.length; S++) {
+ var g = E[S].add(x, m, !1, c);
+ g && T._observers.push(g);
+ }
+ return T;
+ }, I;
+ }(), u = function() {
+ function I(O) {
+ this._observers = new Array(), this._eventState = new V(0), O && (this._onObserverAdded = O);
+ }
+ return Object.defineProperty(I.prototype, "observers", { get: function() {
+ return this._observers;
+ }, enumerable: !1, configurable: !0 }), I.prototype.add = function(O, x, m, c, T) {
+ if (x === void 0 && (x = -1), m === void 0 && (m = !1), c === void 0 && (c = null), T === void 0 && (T = !1), !O)
+ return null;
+ var S = new _(O, x, c);
+ return S.unregisterOnNextCall = T, m ? this._observers.unshift(S) : this._observers.push(S), this._onObserverAdded && this._onObserverAdded(S), S;
+ }, I.prototype.addOnce = function(O) {
+ return this.add(O, void 0, void 0, void 0, !0);
+ }, I.prototype.remove = function(O) {
+ return !!O && this._observers.indexOf(O) !== -1 && (this._deferUnregister(O), !0);
+ }, I.prototype.removeCallback = function(O, x) {
+ for (var m = 0; m < this._observers.length; m++) {
+ var c = this._observers[m];
+ if (!c._willBeUnregistered && c.callback === O && (!x || x === c.scope))
+ return this._deferUnregister(c), !0;
+ }
+ return !1;
+ }, I.prototype._deferUnregister = function(O) {
+ var x = this;
+ O.unregisterOnNextCall = !1, O._willBeUnregistered = !0, setTimeout(function() {
+ x._remove(O);
+ }, 0);
+ }, I.prototype._remove = function(O) {
+ if (!O)
+ return !1;
+ var x = this._observers.indexOf(O);
+ return x !== -1 && (this._observers.splice(x, 1), !0);
+ }, I.prototype.makeObserverTopPriority = function(O) {
+ this._remove(O), this._observers.unshift(O);
+ }, I.prototype.makeObserverBottomPriority = function(O) {
+ this._remove(O), this._observers.push(O);
+ }, I.prototype.notifyObservers = function(O, x, m, c, T) {
+ if (x === void 0 && (x = -1), !this._observers.length)
+ return !0;
+ var S = this._eventState;
+ S.mask = x, S.target = m, S.currentTarget = c, S.skipNextObservers = !1, S.lastReturnValue = O, S.userInfo = T;
+ for (var E = 0, g = this._observers; E < g.length; E++) {
+ var l = g[E];
+ if (!l._willBeUnregistered && (l.mask & x && (l.scope ? S.lastReturnValue = l.callback.apply(l.scope, [O, S]) : S.lastReturnValue = l.callback(O, S), l.unregisterOnNextCall && this._deferUnregister(l)), S.skipNextObservers))
+ return !1;
+ }
+ return !0;
+ }, I.prototype.notifyObserversWithPromise = function(O, x, m, c, T) {
+ var S = this;
+ x === void 0 && (x = -1);
+ var E = Promise.resolve(O);
+ if (!this._observers.length)
+ return E;
+ var g = this._eventState;
+ return g.mask = x, g.target = m, g.currentTarget = c, g.skipNextObservers = !1, g.userInfo = T, this._observers.forEach(function(l) {
+ g.skipNextObservers || l._willBeUnregistered || l.mask & x && (E = l.scope ? E.then(function(h) {
+ return g.lastReturnValue = h, l.callback.apply(l.scope, [O, g]);
+ }) : E.then(function(h) {
+ return g.lastReturnValue = h, l.callback(O, g);
+ }), l.unregisterOnNextCall && S._deferUnregister(l));
+ }), E.then(function() {
+ return O;
+ });
+ }, I.prototype.notifyObserver = function(O, x, m) {
+ m === void 0 && (m = -1);
+ var c = this._eventState;
+ c.mask = m, c.skipNextObservers = !1, O.callback(x, c);
+ }, I.prototype.hasObservers = function() {
+ return this._observers.length > 0;
+ }, I.prototype.clear = function() {
+ this._observers = new Array(), this._onObserverAdded = null;
+ }, I.prototype.clone = function() {
+ var O = new I();
+ return O._observers = this._observers.slice(0), O;
+ }, I.prototype.hasSpecificMask = function(O) {
+ O === void 0 && (O = -1);
+ for (var x = 0, m = this._observers; x < m.length; x++) {
+ var c = m[x];
+ if (c.mask & O || c.mask === O)
+ return !0;
+ }
+ return !1;
+ }, I;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "b", function() {
+ return te;
+ }), f.d(A, "c", function() {
+ return pe;
+ }), f.d(A, "a", function() {
+ return K;
+ });
+ var V = f(1), _ = f(6), C = f(12), u = f(41), I = f(37), O = f(0), x = f(9), m = f(29), c = f(4), T = f(16), S = f(71), E = f(31), g = f(61), l = f(43), h = f(25), v = f(68), b = f(69), D = f(2), w = f(3), N = f(8), M = f(11), U = f(21), X = f(17), j = f(149), ne = f(70), te = function() {
+ }, de = function() {
+ this.visibleInstances = {}, this.batchCache = new pe(), this.instancesBufferSize = 2048;
+ }, pe = function() {
+ this.mustReturn = !1, this.visibleInstances = new Array(), this.renderSelf = new Array(), this.hardwareInstancedRendering = new Array();
+ }, ae = function() {
+ this.instancesCount = 0, this.matrixBuffer = null, this.matrixBufferSize = 512, this.boundingVectors = [], this.worldMatrices = null;
+ }, ee = function() {
+ this._areNormalsFrozen = !1, this._source = null, this.meshMap = null, this._preActivateId = -1, this._LODLevels = new Array(), this._morphTargetManager = null;
+ }, K = function($) {
+ function L(G, Q, oe, re, Y, k) {
+ Q === void 0 && (Q = null), oe === void 0 && (oe = null), re === void 0 && (re = null), k === void 0 && (k = !0);
+ var H = $.call(this, G, Q) || this;
+ if (H._internalMeshDataInfo = new ee(), H.delayLoadState = D.a.DELAYLOADSTATE_NONE, H.instances = new Array(), H._creationDataStorage = null, H._geometry = null, H._instanceDataStorage = new de(), H._thinInstanceDataStorage = new ae(), H._effectiveMaterial = null, H._shouldGenerateFlatShading = !1, H._originalBuilderSideOrientation = L.DEFAULTSIDE, H.overrideMaterialSideOrientation = null, Q = H.getScene(), re) {
+ if (re._geometry && re._geometry.applyToMesh(H), u.a.DeepCopy(re, H, ["name", "material", "skeleton", "instances", "parent", "uniqueId", "source", "metadata", "morphTargetManager", "hasInstances", "source", "worldMatrixInstancedBuffer", "hasLODLevels", "geometry", "isBlocked", "areNormalsFrozen", "facetNb", "isFacetDataEnabled", "lightSources", "useBones", "isAnInstance", "collider", "edgesRenderer", "forward", "up", "right", "absolutePosition", "absoluteScaling", "absoluteRotationQuaternion", "isWorldMatrixFrozen", "nonUniformScaling", "behaviors", "worldMatrixFromCache", "hasThinInstances", "cloneMeshMap"], ["_poseMatrix"]), H._internalMeshDataInfo._source = re, Q.useClonedMeshMap && (re._internalMeshDataInfo.meshMap || (re._internalMeshDataInfo.meshMap = {}), re._internalMeshDataInfo.meshMap[H.uniqueId] = H), H._originalBuilderSideOrientation = re._originalBuilderSideOrientation, H._creationDataStorage = re._creationDataStorage, re._ranges) {
+ var Z = re._ranges;
+ for (var G in Z)
+ Z.hasOwnProperty(G) && Z[G] && H.createAnimationRange(G, Z[G].from, Z[G].to);
+ }
+ var W;
+ if (re.metadata && re.metadata.clone ? H.metadata = re.metadata.clone() : H.metadata = re.metadata, I.a && I.a.HasTags(re) && I.a.AddTagsTo(H, I.a.GetTags(re, !0)), H.setEnabled(re.isEnabled()), H.parent = re.parent, H.setPivotMatrix(re.getPivotMatrix()), H.id = G + "." + re.id, H.material = re.material, !Y)
+ for (var q = re.getDescendants(!0), he = 0; he < q.length; he++) {
+ var ge = q[he];
+ ge.clone && ge.clone(G + "." + ge.name, H);
+ }
+ if (re.morphTargetManager && (H.morphTargetManager = re.morphTargetManager), Q.getPhysicsEngine) {
+ var me = Q.getPhysicsEngine();
+ if (k && me) {
+ var _e = me.getImpostorForPhysicsObject(re);
+ _e && (H.physicsImpostor = _e.clone(H));
+ }
+ }
+ for (W = 0; W < Q.particleSystems.length; W++) {
+ var ye = Q.particleSystems[W];
+ ye.emitter === re && ye.clone(ye.name, H);
+ }
+ H.refreshBoundingInfo(), H.computeWorldMatrix(!0);
+ }
+ return oe !== null && (H.parent = oe), H._instanceDataStorage.hardwareInstancedRendering = H.getEngine().getCaps().instancedArrays, H;
+ }
+ return Object(V.d)(L, $), L._GetDefaultSideOrientation = function(G) {
+ return G || L.FRONTSIDE;
+ }, Object.defineProperty(L.prototype, "computeBonesUsingShaders", { get: function() {
+ return this._internalAbstractMeshDataInfo._computeBonesUsingShaders;
+ }, set: function(G) {
+ this._internalAbstractMeshDataInfo._computeBonesUsingShaders !== G && (G && this._internalMeshDataInfo._sourcePositions && (this.setVerticesData(c.b.PositionKind, this._internalMeshDataInfo._sourcePositions.slice(), !0), this._internalMeshDataInfo._sourceNormals && this.setVerticesData(c.b.NormalKind, this._internalMeshDataInfo._sourceNormals.slice(), !0)), this._internalAbstractMeshDataInfo._computeBonesUsingShaders = G, this._markSubMeshesAsAttributesDirty());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(L.prototype, "onBeforeRenderObservable", { get: function() {
+ return this._internalMeshDataInfo._onBeforeRenderObservable || (this._internalMeshDataInfo._onBeforeRenderObservable = new _.c()), this._internalMeshDataInfo._onBeforeRenderObservable;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(L.prototype, "onBeforeBindObservable", { get: function() {
+ return this._internalMeshDataInfo._onBeforeBindObservable || (this._internalMeshDataInfo._onBeforeBindObservable = new _.c()), this._internalMeshDataInfo._onBeforeBindObservable;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(L.prototype, "onAfterRenderObservable", { get: function() {
+ return this._internalMeshDataInfo._onAfterRenderObservable || (this._internalMeshDataInfo._onAfterRenderObservable = new _.c()), this._internalMeshDataInfo._onAfterRenderObservable;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(L.prototype, "onBeforeDrawObservable", { get: function() {
+ return this._internalMeshDataInfo._onBeforeDrawObservable || (this._internalMeshDataInfo._onBeforeDrawObservable = new _.c()), this._internalMeshDataInfo._onBeforeDrawObservable;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(L.prototype, "onBeforeDraw", { set: function(G) {
+ this._onBeforeDrawObserver && this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver), this._onBeforeDrawObserver = this.onBeforeDrawObservable.add(G);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(L.prototype, "hasInstances", { get: function() {
+ return this.instances.length > 0;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(L.prototype, "hasThinInstances", { get: function() {
+ var G;
+ return ((G = this._thinInstanceDataStorage.instancesCount) !== null && G !== void 0 ? G : 0) > 0;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(L.prototype, "morphTargetManager", { get: function() {
+ return this._internalMeshDataInfo._morphTargetManager;
+ }, set: function(G) {
+ this._internalMeshDataInfo._morphTargetManager !== G && (this._internalMeshDataInfo._morphTargetManager = G, this._syncGeometryWithMorphTargetManager());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(L.prototype, "source", { get: function() {
+ return this._internalMeshDataInfo._source;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(L.prototype, "cloneMeshMap", { get: function() {
+ return this._internalMeshDataInfo.meshMap;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(L.prototype, "isUnIndexed", { get: function() {
+ return this._unIndexed;
+ }, set: function(G) {
+ this._unIndexed !== G && (this._unIndexed = G, this._markSubMeshesAsAttributesDirty());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(L.prototype, "worldMatrixInstancedBuffer", { get: function() {
+ return this._instanceDataStorage.instancesData;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(L.prototype, "manualUpdateOfWorldMatrixInstancedBuffer", { get: function() {
+ return this._instanceDataStorage.manualUpdate;
+ }, set: function(G) {
+ this._instanceDataStorage.manualUpdate = G;
+ }, enumerable: !1, configurable: !0 }), L.prototype.instantiateHierarchy = function(G, Q, oe) {
+ G === void 0 && (G = null);
+ var re = !(this.getTotalVertices() > 0) || Q && Q.doNotInstantiate ? this.clone("Clone of " + (this.name || this.id), G || this.parent, !0) : this.createInstance("instance of " + (this.name || this.id));
+ re && (re.parent = G || this.parent, re.position = this.position.clone(), re.scaling = this.scaling.clone(), this.rotationQuaternion ? re.rotationQuaternion = this.rotationQuaternion.clone() : re.rotation = this.rotation.clone(), oe && oe(this, re));
+ for (var Y = 0, k = this.getChildTransformNodes(!0); Y < k.length; Y++)
+ k[Y].instantiateHierarchy(re, Q, oe);
+ return re;
+ }, L.prototype.getClassName = function() {
+ return "Mesh";
+ }, Object.defineProperty(L.prototype, "_isMesh", { get: function() {
+ return !0;
+ }, enumerable: !1, configurable: !0 }), L.prototype.toString = function(G) {
+ var Q = $.prototype.toString.call(this, G);
+ if (Q += ", n vertices: " + this.getTotalVertices(), Q += ", parent: " + (this._waitingParentId ? this._waitingParentId : this.parent ? this.parent.name : "NONE"), this.animations)
+ for (var oe = 0; oe < this.animations.length; oe++)
+ Q += ", animation[0]: " + this.animations[oe].toString(G);
+ if (G)
+ if (this._geometry) {
+ var re = this.getIndices(), Y = this.getVerticesData(c.b.PositionKind);
+ Y && re && (Q += ", flat shading: " + (Y.length / 3 === re.length ? "YES" : "NO"));
+ } else
+ Q += ", flat shading: UNKNOWN";
+ return Q;
+ }, L.prototype._unBindEffect = function() {
+ $.prototype._unBindEffect.call(this);
+ for (var G = 0, Q = this.instances; G < Q.length; G++)
+ Q[G]._unBindEffect();
+ }, Object.defineProperty(L.prototype, "hasLODLevels", { get: function() {
+ return this._internalMeshDataInfo._LODLevels.length > 0;
+ }, enumerable: !1, configurable: !0 }), L.prototype.getLODLevels = function() {
+ return this._internalMeshDataInfo._LODLevels;
+ }, L.prototype._sortLODLevels = function() {
+ this._internalMeshDataInfo._LODLevels.sort(function(G, Q) {
+ return G.distance < Q.distance ? 1 : G.distance > Q.distance ? -1 : 0;
+ });
+ }, L.prototype.addLODLevel = function(G, Q) {
+ if (Q && Q._masterMesh)
+ return N.a.Warn("You cannot use a mesh as LOD level twice"), this;
+ var oe = new j.a(G, Q);
+ return this._internalMeshDataInfo._LODLevels.push(oe), Q && (Q._masterMesh = this), this._sortLODLevels(), this;
+ }, L.prototype.getLODLevelAtDistance = function(G) {
+ for (var Q = this._internalMeshDataInfo, oe = 0; oe < Q._LODLevels.length; oe++) {
+ var re = Q._LODLevels[oe];
+ if (re.distance === G)
+ return re.mesh;
+ }
+ return null;
+ }, L.prototype.removeLODLevel = function(G) {
+ for (var Q = this._internalMeshDataInfo, oe = 0; oe < Q._LODLevels.length; oe++)
+ Q._LODLevels[oe].mesh === G && (Q._LODLevels.splice(oe, 1), G && (G._masterMesh = null));
+ return this._sortLODLevels(), this;
+ }, L.prototype.getLOD = function(G, Q) {
+ var oe, re = this._internalMeshDataInfo;
+ if (!re._LODLevels || re._LODLevels.length === 0)
+ return this;
+ Q ? oe = Q : oe = this.getBoundingInfo().boundingSphere;
+ var Y = oe.centerWorld.subtract(G.globalPosition).length();
+ if (re._LODLevels[re._LODLevels.length - 1].distance > Y)
+ return this.onLODLevelSelection && this.onLODLevelSelection(Y, this, this), this;
+ for (var k = 0; k < re._LODLevels.length; k++) {
+ var H = re._LODLevels[k];
+ if (H.distance < Y) {
+ if (H.mesh) {
+ if (H.mesh.delayLoadState === D.a.DELAYLOADSTATE_NOTLOADED)
+ return H.mesh._checkDelayState(), this;
+ if (H.mesh.delayLoadState === D.a.DELAYLOADSTATE_LOADING)
+ return this;
+ H.mesh._preActivate(), H.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache);
+ }
+ return this.onLODLevelSelection && this.onLODLevelSelection(Y, this, H.mesh), H.mesh;
+ }
+ }
+ return this.onLODLevelSelection && this.onLODLevelSelection(Y, this, this), this;
+ }, Object.defineProperty(L.prototype, "geometry", { get: function() {
+ return this._geometry;
+ }, enumerable: !1, configurable: !0 }), L.prototype.getTotalVertices = function() {
+ return this._geometry === null || this._geometry === void 0 ? 0 : this._geometry.getTotalVertices();
+ }, L.prototype.getVerticesData = function(G, Q, oe) {
+ return this._geometry ? this._geometry.getVerticesData(G, Q, oe) : null;
+ }, L.prototype.getVertexBuffer = function(G) {
+ return this._geometry ? this._geometry.getVertexBuffer(G) : null;
+ }, L.prototype.isVerticesDataPresent = function(G) {
+ return this._geometry ? this._geometry.isVerticesDataPresent(G) : !!this._delayInfo && this._delayInfo.indexOf(G) !== -1;
+ }, L.prototype.isVertexBufferUpdatable = function(G) {
+ return this._geometry ? this._geometry.isVertexBufferUpdatable(G) : !!this._delayInfo && this._delayInfo.indexOf(G) !== -1;
+ }, L.prototype.getVerticesDataKinds = function() {
+ if (!this._geometry) {
+ var G = new Array();
+ return this._delayInfo && this._delayInfo.forEach(function(Q) {
+ G.push(Q);
+ }), G;
+ }
+ return this._geometry.getVerticesDataKinds();
+ }, L.prototype.getTotalIndices = function() {
+ return this._geometry ? this._geometry.getTotalIndices() : 0;
+ }, L.prototype.getIndices = function(G, Q) {
+ return this._geometry ? this._geometry.getIndices(G, Q) : [];
+ }, Object.defineProperty(L.prototype, "isBlocked", { get: function() {
+ return this._masterMesh !== null && this._masterMesh !== void 0;
+ }, enumerable: !1, configurable: !0 }), L.prototype.isReady = function(G, Q) {
+ var oe, re, Y, k, H, Z;
+ if (G === void 0 && (G = !1), Q === void 0 && (Q = !1), this.delayLoadState === D.a.DELAYLOADSTATE_LOADING || !$.prototype.isReady.call(this, G))
+ return !1;
+ if (!this.subMeshes || this.subMeshes.length === 0 || !G)
+ return !0;
+ var W = this.getEngine(), q = this.getScene(), he = Q || W.getCaps().instancedArrays && (this.instances.length > 0 || this.hasThinInstances);
+ this.computeWorldMatrix();
+ var ge = this.material || q.defaultMaterial;
+ if (ge) {
+ if (ge._storeEffectOnSubMeshes)
+ for (var me = 0, _e = this.subMeshes; me < _e.length; me++) {
+ var ye = (je = _e[me]).getMaterial();
+ if (ye) {
+ if (ye._storeEffectOnSubMeshes) {
+ if (!ye.isReadyForSubMesh(this, je, he))
+ return !1;
+ } else if (!ye.isReady(this, he))
+ return !1;
+ }
+ }
+ else if (!ge.isReady(this, he))
+ return !1;
+ }
+ for (var Pe = 0, be = this.lightSources; Pe < be.length; Pe++) {
+ var Fe = be[Pe].getShadowGenerator();
+ if (Fe && (!(!((oe = Fe.getShadowMap()) === null || oe === void 0) && oe.renderList) || !((re = Fe.getShadowMap()) === null || re === void 0) && re.renderList && ((k = (Y = Fe.getShadowMap()) === null || Y === void 0 ? void 0 : Y.renderList) === null || k === void 0 ? void 0 : k.indexOf(this)) !== -1))
+ for (var ke = 0, We = this.subMeshes; ke < We.length; ke++) {
+ var je = We[ke];
+ if (!Fe.isReady(je, he, (Z = (H = je.getMaterial()) === null || H === void 0 ? void 0 : H.needAlphaBlendingForMesh(this)) !== null && Z !== void 0 && Z))
+ return !1;
+ }
+ }
+ for (var He = 0, Qe = this._internalMeshDataInfo._LODLevels; He < Qe.length; He++) {
+ var Ge = Qe[He];
+ if (Ge.mesh && !Ge.mesh.isReady(he))
+ return !1;
+ }
+ return !0;
+ }, Object.defineProperty(L.prototype, "areNormalsFrozen", { get: function() {
+ return this._internalMeshDataInfo._areNormalsFrozen;
+ }, enumerable: !1, configurable: !0 }), L.prototype.freezeNormals = function() {
+ return this._internalMeshDataInfo._areNormalsFrozen = !0, this;
+ }, L.prototype.unfreezeNormals = function() {
+ return this._internalMeshDataInfo._areNormalsFrozen = !1, this;
+ }, Object.defineProperty(L.prototype, "overridenInstanceCount", { set: function(G) {
+ this._instanceDataStorage.overridenInstanceCount = G;
+ }, enumerable: !1, configurable: !0 }), L.prototype._preActivate = function() {
+ var G = this._internalMeshDataInfo, Q = this.getScene().getRenderId();
+ return G._preActivateId === Q || (G._preActivateId = Q, this._instanceDataStorage.visibleInstances = null), this;
+ }, L.prototype._preActivateForIntermediateRendering = function(G) {
+ return this._instanceDataStorage.visibleInstances && (this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId = G), this;
+ }, L.prototype._registerInstanceForRenderId = function(G, Q) {
+ return this._instanceDataStorage.visibleInstances || (this._instanceDataStorage.visibleInstances = { defaultRenderId: Q, selfDefaultRenderId: this._renderId }), this._instanceDataStorage.visibleInstances[Q] || (this._instanceDataStorage.previousRenderId !== void 0 && this._instanceDataStorage.isFrozen && (this._instanceDataStorage.visibleInstances[this._instanceDataStorage.previousRenderId] = null), this._instanceDataStorage.previousRenderId = Q, this._instanceDataStorage.visibleInstances[Q] = new Array()), this._instanceDataStorage.visibleInstances[Q].push(G), this;
+ }, L.prototype._afterComputeWorldMatrix = function() {
+ $.prototype._afterComputeWorldMatrix.call(this), this.hasThinInstances && (this.doNotSyncBoundingInfo || this.thinInstanceRefreshBoundingInfo(!1));
+ }, L.prototype._postActivate = function() {
+ this.edgesShareWithInstances && this.edgesRenderer && this.edgesRenderer.isEnabled && this._renderingGroup && (this._renderingGroup._edgesRenderers.pushNoDuplicate(this.edgesRenderer), this.edgesRenderer.customInstances.push(this.getWorldMatrix()));
+ }, L.prototype.refreshBoundingInfo = function(G) {
+ if (G === void 0 && (G = !1), this._boundingInfo && this._boundingInfo.isLocked)
+ return this;
+ var Q = this.geometry ? this.geometry.boundingBias : null;
+ return this._refreshBoundingInfo(this._getPositionData(G), Q), this;
+ }, L.prototype._createGlobalSubMesh = function(G) {
+ var Q = this.getTotalVertices();
+ if (!Q || !this.getIndices())
+ return null;
+ if (this.subMeshes && this.subMeshes.length > 0) {
+ var oe = this.getIndices();
+ if (!oe)
+ return null;
+ var re = oe.length, Y = !1;
+ if (G)
+ Y = !0;
+ else
+ for (var k = 0, H = this.subMeshes; k < H.length; k++) {
+ var Z = H[k];
+ if (Z.indexStart + Z.indexCount > re) {
+ Y = !0;
+ break;
+ }
+ if (Z.verticesStart + Z.verticesCount > Q) {
+ Y = !0;
+ break;
+ }
+ }
+ if (!Y)
+ return this.subMeshes[0];
+ }
+ return this.releaseSubMeshes(), new g.a(0, 0, Q, 0, this.getTotalIndices(), this);
+ }, L.prototype.subdivide = function(G) {
+ if (!(G < 1)) {
+ for (var Q = this.getTotalIndices(), oe = Q / G | 0, re = 0; oe % 3 != 0; )
+ oe++;
+ this.releaseSubMeshes();
+ for (var Y = 0; Y < G && !(re >= Q); Y++)
+ g.a.CreateFromIndices(0, re, Y === G - 1 ? Q - re : oe, this), re += oe;
+ this.synchronizeInstances();
+ }
+ }, L.prototype.setVerticesData = function(G, Q, oe, re) {
+ if (oe === void 0 && (oe = !1), this._geometry)
+ this._geometry.setVerticesData(G, Q, oe, re);
+ else {
+ var Y = new T.a();
+ Y.set(Q, G);
+ var k = this.getScene();
+ new S.a(S.a.RandomId(), k, Y, oe, this);
+ }
+ return this;
+ }, L.prototype.removeVerticesData = function(G) {
+ this._geometry && this._geometry.removeVerticesData(G);
+ }, L.prototype.markVerticesDataAsUpdatable = function(G, Q) {
+ Q === void 0 && (Q = !0);
+ var oe = this.getVertexBuffer(G);
+ oe && oe.isUpdatable() !== Q && this.setVerticesData(G, this.getVerticesData(G), Q);
+ }, L.prototype.setVerticesBuffer = function(G) {
+ return this._geometry || (this._geometry = S.a.CreateGeometryForMesh(this)), this._geometry.setVerticesBuffer(G), this;
+ }, L.prototype.updateVerticesData = function(G, Q, oe, re) {
+ return this._geometry ? (re ? (this.makeGeometryUnique(), this.updateVerticesData(G, Q, oe, !1)) : this._geometry.updateVerticesData(G, Q, oe), this) : this;
+ }, L.prototype.updateMeshPositions = function(G, Q) {
+ Q === void 0 && (Q = !0);
+ var oe = this.getVerticesData(c.b.PositionKind);
+ if (!oe)
+ return this;
+ if (G(oe), this.updateVerticesData(c.b.PositionKind, oe, !1, !1), Q) {
+ var re = this.getIndices(), Y = this.getVerticesData(c.b.NormalKind);
+ if (!Y)
+ return this;
+ T.a.ComputeNormals(oe, re, Y), this.updateVerticesData(c.b.NormalKind, Y, !1, !1);
+ }
+ return this;
+ }, L.prototype.makeGeometryUnique = function() {
+ if (!this._geometry)
+ return this;
+ if (this._geometry.meshes.length === 1)
+ return this;
+ var G = this._geometry, Q = this._geometry.copy(S.a.RandomId());
+ return G.releaseForMesh(this, !0), Q.applyToMesh(this), this;
+ }, L.prototype.setIndices = function(G, Q, oe) {
+ if (Q === void 0 && (Q = null), oe === void 0 && (oe = !1), this._geometry)
+ this._geometry.setIndices(G, Q, oe);
+ else {
+ var re = new T.a();
+ re.indices = G;
+ var Y = this.getScene();
+ new S.a(S.a.RandomId(), Y, re, oe, this);
+ }
+ return this;
+ }, L.prototype.updateIndices = function(G, Q, oe) {
+ return oe === void 0 && (oe = !1), this._geometry ? (this._geometry.updateIndices(G, Q, oe), this) : this;
+ }, L.prototype.toLeftHanded = function() {
+ return this._geometry ? (this._geometry.toLeftHanded(), this) : this;
+ }, L.prototype._bind = function(G, Q, oe) {
+ if (!this._geometry)
+ return this;
+ var re, Y = this.getScene().getEngine();
+ if (this._unIndexed)
+ re = null;
+ else
+ switch (oe) {
+ case h.a.PointFillMode:
+ re = null;
+ break;
+ case h.a.WireFrameFillMode:
+ re = G._getLinesIndexBuffer(this.getIndices(), Y);
+ break;
+ default:
+ case h.a.TriangleFillMode:
+ re = this._geometry.getIndexBuffer();
+ }
+ return this._geometry._bind(Q, re), this;
+ }, L.prototype._draw = function(G, Q, oe) {
+ if (!this._geometry || !this._geometry.getVertexBuffers() || !this._unIndexed && !this._geometry.getIndexBuffer())
+ return this;
+ this._internalMeshDataInfo._onBeforeDrawObservable && this._internalMeshDataInfo._onBeforeDrawObservable.notifyObservers(this);
+ var re = this.getScene().getEngine();
+ return this._unIndexed || Q == h.a.PointFillMode ? re.drawArraysType(Q, G.verticesStart, G.verticesCount, oe) : Q == h.a.WireFrameFillMode ? re.drawElementsType(Q, 0, G._linesIndexCount, oe) : re.drawElementsType(Q, G.indexStart, G.indexCount, oe), this;
+ }, L.prototype.registerBeforeRender = function(G) {
+ return this.onBeforeRenderObservable.add(G), this;
+ }, L.prototype.unregisterBeforeRender = function(G) {
+ return this.onBeforeRenderObservable.removeCallback(G), this;
+ }, L.prototype.registerAfterRender = function(G) {
+ return this.onAfterRenderObservable.add(G), this;
+ }, L.prototype.unregisterAfterRender = function(G) {
+ return this.onAfterRenderObservable.removeCallback(G), this;
+ }, L.prototype._getInstancesRenderList = function(G, Q) {
+ if (Q === void 0 && (Q = !1), this._instanceDataStorage.isFrozen && this._instanceDataStorage.previousBatch)
+ return this._instanceDataStorage.previousBatch;
+ var oe = this.getScene(), re = oe._isInIntermediateRendering(), Y = re ? this._internalAbstractMeshDataInfo._onlyForInstancesIntermediate : this._internalAbstractMeshDataInfo._onlyForInstances, k = this._instanceDataStorage.batchCache;
+ if (k.mustReturn = !1, k.renderSelf[G] = Q || !Y && this.isEnabled() && this.isVisible, k.visibleInstances[G] = null, this._instanceDataStorage.visibleInstances && !Q) {
+ var H = this._instanceDataStorage.visibleInstances, Z = oe.getRenderId(), W = re ? H.intermediateDefaultRenderId : H.defaultRenderId;
+ k.visibleInstances[G] = H[Z], !k.visibleInstances[G] && W && (k.visibleInstances[G] = H[W]);
+ }
+ return k.hardwareInstancedRendering[G] = !Q && this._instanceDataStorage.hardwareInstancedRendering && k.visibleInstances[G] !== null && k.visibleInstances[G] !== void 0, this._instanceDataStorage.previousBatch = k, k;
+ }, L.prototype._renderWithInstances = function(G, Q, oe, re, Y) {
+ var k = oe.visibleInstances[G._id];
+ if (!k)
+ return this;
+ for (var H = this._instanceDataStorage, Z = H.instancesBufferSize, W = H.instancesBuffer, q = 16 * (k.length + 1) * 4; H.instancesBufferSize < q; )
+ H.instancesBufferSize *= 2;
+ H.instancesData && Z == H.instancesBufferSize || (H.instancesData = new Float32Array(H.instancesBufferSize / 4));
+ var he = 0, ge = 0, me = oe.renderSelf[G._id], _e = !W || Z !== H.instancesBufferSize;
+ if (this._instanceDataStorage.manualUpdate || H.isFrozen && !_e)
+ ge = (me ? 1 : 0) + k.length;
+ else {
+ var ye = this._effectiveMesh.getWorldMatrix();
+ if (me && (ye.copyToArray(H.instancesData, he), he += 16, ge++), k)
+ for (var Pe = 0; Pe < k.length; Pe++)
+ k[Pe].getWorldMatrix().copyToArray(H.instancesData, he), he += 16, ge++;
+ }
+ return _e ? (W && W.dispose(), W = new c.a(Y, H.instancesData, !0, 16, !1, !0), H.instancesBuffer = W, this.setVerticesBuffer(W.createVertexBuffer("world0", 0, 4)), this.setVerticesBuffer(W.createVertexBuffer("world1", 4, 4)), this.setVerticesBuffer(W.createVertexBuffer("world2", 8, 4)), this.setVerticesBuffer(W.createVertexBuffer("world3", 12, 4))) : this._instanceDataStorage.isFrozen || W.updateDirectly(H.instancesData, 0, ge), this._processInstancedBuffers(k, me), this.getScene()._activeIndices.addCount(G.indexCount * ge, !1), this._bind(G, re, Q), this._draw(G, Q, ge), Y.unbindInstanceAttributes(), this;
+ }, L.prototype._renderWithThinInstances = function(G, Q, oe, re) {
+ var Y, k, H = (k = (Y = this._thinInstanceDataStorage) === null || Y === void 0 ? void 0 : Y.instancesCount) !== null && k !== void 0 ? k : 0;
+ this.getScene()._activeIndices.addCount(G.indexCount * H, !1), this._bind(G, oe, Q), this._draw(G, Q, H), re.unbindInstanceAttributes();
+ }, L.prototype._processInstancedBuffers = function(G, Q) {
+ }, L.prototype._processRendering = function(G, Q, oe, re, Y, k, H, Z) {
+ var W = this.getScene(), q = W.getEngine();
+ if (k && Q.getRenderingMesh().hasThinInstances)
+ return this._renderWithThinInstances(Q, re, oe, q), this;
+ if (k)
+ this._renderWithInstances(Q, re, Y, oe, q);
+ else {
+ var he = 0;
+ Y.renderSelf[Q._id] && (H && H(!1, G._effectiveMesh.getWorldMatrix(), Z), he++, this._draw(Q, re, this._instanceDataStorage.overridenInstanceCount));
+ var ge = Y.visibleInstances[Q._id];
+ if (ge) {
+ var me = ge.length;
+ he += me;
+ for (var _e = 0; _e < me; _e++) {
+ var ye = ge[_e].getWorldMatrix();
+ H && H(!0, ye, Z), this._draw(Q, re);
+ }
+ }
+ W._activeIndices.addCount(Q.indexCount * he, !1);
+ }
+ return this;
+ }, L.prototype._rebuild = function() {
+ this._instanceDataStorage.instancesBuffer && (this._instanceDataStorage.instancesBuffer.dispose(), this._instanceDataStorage.instancesBuffer = null), $.prototype._rebuild.call(this);
+ }, L.prototype._freeze = function() {
+ if (this.subMeshes) {
+ for (var G = 0; G < this.subMeshes.length; G++)
+ this._getInstancesRenderList(G);
+ this._effectiveMaterial = null, this._instanceDataStorage.isFrozen = !0;
+ }
+ }, L.prototype._unFreeze = function() {
+ this._instanceDataStorage.isFrozen = !1, this._instanceDataStorage.previousBatch = null;
+ }, L.prototype.render = function(G, Q, oe) {
+ var re = this.getScene();
+ if (this._internalAbstractMeshDataInfo._isActiveIntermediate ? this._internalAbstractMeshDataInfo._isActiveIntermediate = !1 : this._internalAbstractMeshDataInfo._isActive = !1, this._checkOcclusionQuery())
+ return this;
+ var Y = this._getInstancesRenderList(G._id, !!oe);
+ if (Y.mustReturn)
+ return this;
+ if (!this._geometry || !this._geometry.getVertexBuffers() || !this._unIndexed && !this._geometry.getIndexBuffer())
+ return this;
+ this._internalMeshDataInfo._onBeforeRenderObservable && this._internalMeshDataInfo._onBeforeRenderObservable.notifyObservers(this);
+ var k, H = re.getEngine(), Z = Y.hardwareInstancedRendering[G._id] || G.getRenderingMesh().hasThinInstances, W = this._instanceDataStorage, q = G.getMaterial();
+ if (!q)
+ return this;
+ if (!W.isFrozen || !this._effectiveMaterial || this._effectiveMaterial !== q) {
+ if (q._storeEffectOnSubMeshes) {
+ if (!q.isReadyForSubMesh(this, G, Z))
+ return this;
+ } else if (!q.isReady(this, Z))
+ return this;
+ this._effectiveMaterial = q;
+ }
+ Q && H.setAlphaMode(this._effectiveMaterial.alphaMode), k = this._effectiveMaterial._storeEffectOnSubMeshes ? G.effect : this._effectiveMaterial.getEffect();
+ for (var he = 0, ge = re._beforeRenderingMeshStage; he < ge.length; he++)
+ ge[he].action(this, G, Y, k);
+ if (!k)
+ return this;
+ var me, _e = oe || this._effectiveMesh;
+ if (W.isFrozen || !this._effectiveMaterial.backFaceCulling && this.overrideMaterialSideOrientation === null)
+ me = W.sideOrientation;
+ else {
+ var ye = _e._getWorldMatrixDeterminant();
+ (me = this.overrideMaterialSideOrientation) == null && (me = this._effectiveMaterial.sideOrientation), ye < 0 && (me = me === h.a.ClockWiseSideOrientation ? h.a.CounterClockWiseSideOrientation : h.a.ClockWiseSideOrientation), W.sideOrientation = me;
+ }
+ var Pe = this._effectiveMaterial._preBind(k, me);
+ this._effectiveMaterial.forceDepthWrite && H.setDepthWrite(!0);
+ var be = re.forcePointsCloud ? h.a.PointFillMode : re.forceWireframe ? h.a.WireFrameFillMode : this._effectiveMaterial.fillMode;
+ this._internalMeshDataInfo._onBeforeBindObservable && this._internalMeshDataInfo._onBeforeBindObservable.notifyObservers(this), Z || this._bind(G, k, be);
+ var Fe = _e.getWorldMatrix();
+ this._effectiveMaterial._storeEffectOnSubMeshes ? this._effectiveMaterial.bindForSubMesh(Fe, this, G) : this._effectiveMaterial.bind(Fe, this), !this._effectiveMaterial.backFaceCulling && this._effectiveMaterial.separateCullingPass && (H.setState(!0, this._effectiveMaterial.zOffset, !1, !Pe), this._processRendering(this, G, k, be, Y, Z, this._onBeforeDraw, this._effectiveMaterial), H.setState(!0, this._effectiveMaterial.zOffset, !1, Pe)), this._processRendering(this, G, k, be, Y, Z, this._onBeforeDraw, this._effectiveMaterial), this._effectiveMaterial.unbind();
+ for (var ke = 0, We = re._afterRenderingMeshStage; ke < We.length; ke++)
+ We[ke].action(this, G, Y, k);
+ return this._internalMeshDataInfo._onAfterRenderObservable && this._internalMeshDataInfo._onAfterRenderObservable.notifyObservers(this), this;
+ }, L.prototype._onBeforeDraw = function(G, Q, oe) {
+ G && oe && oe.bindOnlyWorldMatrix(Q);
+ }, L.prototype.cleanMatrixWeights = function() {
+ this.isVerticesDataPresent(c.b.MatricesWeightsKind) && (this.isVerticesDataPresent(c.b.MatricesWeightsExtraKind) ? this.normalizeSkinWeightsAndExtra() : this.normalizeSkinFourWeights());
+ }, L.prototype.normalizeSkinFourWeights = function() {
+ for (var G = this.getVerticesData(c.b.MatricesWeightsKind), Q = G.length, oe = 0; oe < Q; oe += 4) {
+ var re = G[oe] + G[oe + 1] + G[oe + 2] + G[oe + 3];
+ if (re === 0)
+ G[oe] = 1;
+ else {
+ var Y = 1 / re;
+ G[oe] *= Y, G[oe + 1] *= Y, G[oe + 2] *= Y, G[oe + 3] *= Y;
+ }
+ }
+ this.setVerticesData(c.b.MatricesWeightsKind, G);
+ }, L.prototype.normalizeSkinWeightsAndExtra = function() {
+ for (var G = this.getVerticesData(c.b.MatricesWeightsExtraKind), Q = this.getVerticesData(c.b.MatricesWeightsKind), oe = Q.length, re = 0; re < oe; re += 4) {
+ var Y = Q[re] + Q[re + 1] + Q[re + 2] + Q[re + 3];
+ if ((Y += G[re] + G[re + 1] + G[re + 2] + G[re + 3]) === 0)
+ Q[re] = 1;
+ else {
+ var k = 1 / Y;
+ Q[re] *= k, Q[re + 1] *= k, Q[re + 2] *= k, Q[re + 3] *= k, G[re] *= k, G[re + 1] *= k, G[re + 2] *= k, G[re + 3] *= k;
+ }
+ }
+ this.setVerticesData(c.b.MatricesWeightsKind, Q), this.setVerticesData(c.b.MatricesWeightsKind, G);
+ }, L.prototype.validateSkinning = function() {
+ var G = this.getVerticesData(c.b.MatricesWeightsExtraKind), Q = this.getVerticesData(c.b.MatricesWeightsKind);
+ if (Q === null || this.skeleton == null)
+ return { skinned: !1, valid: !0, report: "not skinned" };
+ for (var oe = Q.length, re = 0, Y = 0, k = 0, H = 0, Z = G === null ? 4 : 8, W = new Array(), q = 0; q <= Z; q++)
+ W[q] = 0;
+ for (q = 0; q < oe; q += 4) {
+ for (var he = Q[q], ge = he, me = ge === 0 ? 0 : 1, _e = 1; _e < Z; _e++) {
+ var ye = _e < 4 ? Q[q + _e] : G[q + _e - 4];
+ ye > he && re++, ye !== 0 && me++, ge += ye, he = ye;
+ }
+ if (W[me]++, me > k && (k = me), ge === 0)
+ Y++;
+ else {
+ var Pe = 1 / ge, be = 0;
+ for (_e = 0; _e < Z; _e++)
+ be += _e < 4 ? Math.abs(Q[q + _e] - Q[q + _e] * Pe) : Math.abs(G[q + _e - 4] - G[q + _e - 4] * Pe);
+ be > 1e-3 && H++;
+ }
+ }
+ var Fe = this.skeleton.bones.length, ke = this.getVerticesData(c.b.MatricesIndicesKind), We = this.getVerticesData(c.b.MatricesIndicesExtraKind), je = 0;
+ for (q = 0; q < oe; q += 4)
+ for (_e = 0; _e < Z; _e++) {
+ var He = _e < 4 ? ke[q + _e] : We[q + _e - 4];
+ (He >= Fe || He < 0) && je++;
+ }
+ return { skinned: !0, valid: Y === 0 && H === 0 && je === 0, report: "Number of Weights = " + oe / 4 + `
+Maximum influences = ` + k + `
+Missing Weights = ` + Y + `
+Not Sorted = ` + re + `
+Not Normalized = ` + H + `
+WeightCounts = [` + W + `]
+Number of bones = ` + Fe + `
+Bad Bone Indices = ` + je };
+ }, L.prototype._checkDelayState = function() {
+ var G = this.getScene();
+ return this._geometry ? this._geometry.load(G) : this.delayLoadState === D.a.DELAYLOADSTATE_NOTLOADED && (this.delayLoadState = D.a.DELAYLOADSTATE_LOADING, this._queueLoad(G)), this;
+ }, L.prototype._queueLoad = function(G) {
+ var Q = this;
+ G._addPendingData(this);
+ var oe = this.delayLoadingFile.indexOf(".babylonbinarymeshdata") !== -1;
+ return C.b.LoadFile(this.delayLoadingFile, function(re) {
+ re instanceof ArrayBuffer ? Q._delayLoadingFunction(re, Q) : Q._delayLoadingFunction(JSON.parse(re), Q), Q.instances.forEach(function(Y) {
+ Y.refreshBoundingInfo(), Y._syncSubMeshes();
+ }), Q.delayLoadState = D.a.DELAYLOADSTATE_LOADED, G._removePendingData(Q);
+ }, function() {
+ }, G.offlineProvider, oe), this;
+ }, L.prototype.isInFrustum = function(G) {
+ return this.delayLoadState !== D.a.DELAYLOADSTATE_LOADING && !!$.prototype.isInFrustum.call(this, G) && (this._checkDelayState(), !0);
+ }, L.prototype.setMaterialByID = function(G) {
+ var Q, oe = this.getScene().materials;
+ for (Q = oe.length - 1; Q > -1; Q--)
+ if (oe[Q].id === G)
+ return this.material = oe[Q], this;
+ var re = this.getScene().multiMaterials;
+ for (Q = re.length - 1; Q > -1; Q--)
+ if (re[Q].id === G)
+ return this.material = re[Q], this;
+ return this;
+ }, L.prototype.getAnimatables = function() {
+ var G = new Array();
+ return this.material && G.push(this.material), this.skeleton && G.push(this.skeleton), G;
+ }, L.prototype.bakeTransformIntoVertices = function(G) {
+ if (!this.isVerticesDataPresent(c.b.PositionKind))
+ return this;
+ var Q = this.subMeshes.splice(0);
+ this._resetPointsArrayCache();
+ var oe, re = this.getVerticesData(c.b.PositionKind), Y = new Array();
+ for (oe = 0; oe < re.length; oe += 3)
+ O.e.TransformCoordinates(O.e.FromArray(re, oe), G).toArray(Y, oe);
+ if (this.setVerticesData(c.b.PositionKind, Y, this.getVertexBuffer(c.b.PositionKind).isUpdatable()), this.isVerticesDataPresent(c.b.NormalKind)) {
+ for (re = this.getVerticesData(c.b.NormalKind), Y = [], oe = 0; oe < re.length; oe += 3)
+ O.e.TransformNormal(O.e.FromArray(re, oe), G).normalize().toArray(Y, oe);
+ this.setVerticesData(c.b.NormalKind, Y, this.getVertexBuffer(c.b.NormalKind).isUpdatable());
+ }
+ return G.m[0] * G.m[5] * G.m[10] < 0 && this.flipFaces(), this.releaseSubMeshes(), this.subMeshes = Q, this;
+ }, L.prototype.bakeCurrentTransformIntoVertices = function(G) {
+ return G === void 0 && (G = !0), this.bakeTransformIntoVertices(this.computeWorldMatrix(!0)), this.resetLocalMatrix(G), this;
+ }, Object.defineProperty(L.prototype, "_positions", { get: function() {
+ return this._geometry ? this._geometry._positions : null;
+ }, enumerable: !1, configurable: !0 }), L.prototype._resetPointsArrayCache = function() {
+ return this._geometry && this._geometry._resetPointsArrayCache(), this;
+ }, L.prototype._generatePointsArray = function() {
+ return !!this._geometry && this._geometry._generatePointsArray();
+ }, L.prototype.clone = function(G, Q, oe, re) {
+ return G === void 0 && (G = ""), Q === void 0 && (Q = null), re === void 0 && (re = !0), new L(G, this.getScene(), Q, this, oe, re);
+ }, L.prototype.dispose = function(G, Q) {
+ Q === void 0 && (Q = !1), this.morphTargetManager = null, this._geometry && this._geometry.releaseForMesh(this, !0);
+ var oe = this._internalMeshDataInfo;
+ if (oe._onBeforeDrawObservable && oe._onBeforeDrawObservable.clear(), oe._onBeforeBindObservable && oe._onBeforeBindObservable.clear(), oe._onBeforeRenderObservable && oe._onBeforeRenderObservable.clear(), oe._onAfterRenderObservable && oe._onAfterRenderObservable.clear(), this._scene.useClonedMeshMap) {
+ if (oe.meshMap)
+ for (var re in oe.meshMap)
+ (H = oe.meshMap[re]) && (H._internalMeshDataInfo._source = null, oe.meshMap[re] = void 0);
+ oe._source && oe._source._internalMeshDataInfo.meshMap && (oe._source._internalMeshDataInfo.meshMap[this.uniqueId] = void 0);
+ } else
+ for (var Y = 0, k = this.getScene().meshes; Y < k.length; Y++) {
+ var H;
+ (H = k[Y])._internalMeshDataInfo && H._internalMeshDataInfo._source && H._internalMeshDataInfo._source === this && (H._internalMeshDataInfo._source = null);
+ }
+ oe._source = null, this._disposeInstanceSpecificData(), this._disposeThinInstanceSpecificData(), $.prototype.dispose.call(this, G, Q);
+ }, L.prototype._disposeInstanceSpecificData = function() {
+ }, L.prototype._disposeThinInstanceSpecificData = function() {
+ }, L.prototype.applyDisplacementMap = function(G, Q, oe, re, Y, k, H) {
+ var Z = this;
+ H === void 0 && (H = !1);
+ var W = this.getScene();
+ return C.b.LoadImage(G, function(q) {
+ var he = q.width, ge = q.height, me = ne.a.CreateCanvas(he, ge).getContext("2d");
+ me.drawImage(q, 0, 0);
+ var _e = me.getImageData(0, 0, he, ge).data;
+ Z.applyDisplacementMapFromBuffer(_e, he, ge, Q, oe, Y, k, H), re && re(Z);
+ }, function() {
+ }, W.offlineProvider), this;
+ }, L.prototype.applyDisplacementMapFromBuffer = function(G, Q, oe, re, Y, k, H, Z) {
+ if (Z === void 0 && (Z = !1), !this.isVerticesDataPresent(c.b.PositionKind) || !this.isVerticesDataPresent(c.b.NormalKind) || !this.isVerticesDataPresent(c.b.UVKind))
+ return N.a.Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing"), this;
+ var W = this.getVerticesData(c.b.PositionKind, !0, !0), q = this.getVerticesData(c.b.NormalKind), he = this.getVerticesData(c.b.UVKind), ge = O.e.Zero(), me = O.e.Zero(), _e = O.d.Zero();
+ k = k || O.d.Zero(), H = H || new O.d(1, 1);
+ for (var ye = 0; ye < W.length; ye += 3) {
+ O.e.FromArrayToRef(W, ye, ge), O.e.FromArrayToRef(q, ye, me), O.d.FromArrayToRef(he, ye / 3 * 2, _e);
+ var Pe = 4 * ((Math.abs(_e.x * H.x + k.x % 1) * (Q - 1) % Q | 0) + (Math.abs(_e.y * H.y + k.y % 1) * (oe - 1) % oe | 0) * Q), be = 0.3 * (G[Pe] / 255) + 0.59 * (G[Pe + 1] / 255) + 0.11 * (G[Pe + 2] / 255);
+ me.normalize(), me.scaleInPlace(re + (Y - re) * be), (ge = ge.add(me)).toArray(W, ye);
+ }
+ return T.a.ComputeNormals(W, this.getIndices(), q), Z ? (this.setVerticesData(c.b.PositionKind, W), this.setVerticesData(c.b.NormalKind, q)) : (this.updateVerticesData(c.b.PositionKind, W), this.updateVerticesData(c.b.NormalKind, q)), this;
+ }, L.prototype.convertToFlatShadedMesh = function() {
+ var G, Q, oe = this.getVerticesDataKinds(), re = {}, Y = {}, k = {}, H = !1;
+ for (G = 0; G < oe.length; G++) {
+ Q = oe[G];
+ var Z = this.getVertexBuffer(Q);
+ Q !== c.b.NormalKind ? (re[Q] = Z, Y[Q] = re[Q].getData(), k[Q] = []) : (H = Z.isUpdatable(), oe.splice(G, 1), G--);
+ }
+ var W, q = this.subMeshes.slice(0), he = this.getIndices(), ge = this.getTotalIndices();
+ for (W = 0; W < ge; W++) {
+ var me = he[W];
+ for (G = 0; G < oe.length; G++)
+ for (var _e = re[Q = oe[G]].getStrideSize(), ye = 0; ye < _e; ye++)
+ k[Q].push(Y[Q][me * _e + ye]);
+ }
+ var Pe = [], be = k[c.b.PositionKind];
+ for (W = 0; W < ge; W += 3) {
+ he[W] = W, he[W + 1] = W + 1, he[W + 2] = W + 2;
+ for (var Fe = O.e.FromArray(be, 3 * W), ke = O.e.FromArray(be, 3 * (W + 1)), We = O.e.FromArray(be, 3 * (W + 2)), je = Fe.subtract(ke), He = We.subtract(ke), Qe = O.e.Normalize(O.e.Cross(je, He)), Ge = 0; Ge < 3; Ge++)
+ Pe.push(Qe.x), Pe.push(Qe.y), Pe.push(Qe.z);
+ }
+ for (this.setIndices(he), this.setVerticesData(c.b.NormalKind, Pe, H), G = 0; G < oe.length; G++)
+ Q = oe[G], this.setVerticesData(Q, k[Q], re[Q].isUpdatable());
+ this.releaseSubMeshes();
+ for (var tt = 0; tt < q.length; tt++) {
+ var Je = q[tt];
+ g.a.AddToMesh(Je.materialIndex, Je.indexStart, Je.indexCount, Je.indexStart, Je.indexCount, this);
+ }
+ return this.synchronizeInstances(), this;
+ }, L.prototype.convertToUnIndexedMesh = function() {
+ var G, Q, oe = this.getVerticesDataKinds(), re = {}, Y = {}, k = {};
+ for (G = 0; G < oe.length; G++) {
+ Q = oe[G];
+ var H = this.getVertexBuffer(Q);
+ re[Q] = H, Y[Q] = re[Q].getData(), k[Q] = [];
+ }
+ var Z, W = this.subMeshes.slice(0), q = this.getIndices(), he = this.getTotalIndices();
+ for (Z = 0; Z < he; Z++) {
+ var ge = q[Z];
+ for (G = 0; G < oe.length; G++)
+ for (var me = re[Q = oe[G]].getStrideSize(), _e = 0; _e < me; _e++)
+ k[Q].push(Y[Q][ge * me + _e]);
+ }
+ for (Z = 0; Z < he; Z += 3)
+ q[Z] = Z, q[Z + 1] = Z + 1, q[Z + 2] = Z + 2;
+ for (this.setIndices(q), G = 0; G < oe.length; G++)
+ Q = oe[G], this.setVerticesData(Q, k[Q], re[Q].isUpdatable());
+ this.releaseSubMeshes();
+ for (var ye = 0; ye < W.length; ye++) {
+ var Pe = W[ye];
+ g.a.AddToMesh(Pe.materialIndex, Pe.indexStart, Pe.indexCount, Pe.indexStart, Pe.indexCount, this);
+ }
+ return this._unIndexed = !0, this.synchronizeInstances(), this;
+ }, L.prototype.flipFaces = function(G) {
+ G === void 0 && (G = !1);
+ var Q, oe, re = T.a.ExtractFromMesh(this);
+ if (G && this.isVerticesDataPresent(c.b.NormalKind) && re.normals)
+ for (Q = 0; Q < re.normals.length; Q++)
+ re.normals[Q] *= -1;
+ if (re.indices)
+ for (Q = 0; Q < re.indices.length; Q += 3)
+ oe = re.indices[Q + 1], re.indices[Q + 1] = re.indices[Q + 2], re.indices[Q + 2] = oe;
+ return re.applyToMesh(this, this.isVertexBufferUpdatable(c.b.PositionKind)), this;
+ }, L.prototype.increaseVertices = function(G) {
+ var Q = T.a.ExtractFromMesh(this), oe = Q.uvs, re = Q.indices, Y = Q.positions, k = Q.normals;
+ if (re && Y && k && oe) {
+ for (var H, Z, W = G + 1, q = new Array(), he = 0; he < W + 1; he++)
+ q[he] = new Array();
+ var ge, me = new O.e(0, 0, 0), _e = new O.e(0, 0, 0), ye = new O.d(0, 0), Pe = new Array(), be = new Array(), Fe = new Array(), ke = Y.length, We = oe.length;
+ for (he = 0; he < re.length; he += 3) {
+ be[0] = re[he], be[1] = re[he + 1], be[2] = re[he + 2];
+ for (var je = 0; je < 3; je++)
+ if (H = be[je], Z = be[(je + 1) % 3], Fe[H] === void 0 && Fe[Z] === void 0 ? (Fe[H] = new Array(), Fe[Z] = new Array()) : (Fe[H] === void 0 && (Fe[H] = new Array()), Fe[Z] === void 0 && (Fe[Z] = new Array())), Fe[H][Z] === void 0 && Fe[Z][H] === void 0) {
+ Fe[H][Z] = [], me.x = (Y[3 * Z] - Y[3 * H]) / W, me.y = (Y[3 * Z + 1] - Y[3 * H + 1]) / W, me.z = (Y[3 * Z + 2] - Y[3 * H + 2]) / W, _e.x = (k[3 * Z] - k[3 * H]) / W, _e.y = (k[3 * Z + 1] - k[3 * H + 1]) / W, _e.z = (k[3 * Z + 2] - k[3 * H + 2]) / W, ye.x = (oe[2 * Z] - oe[2 * H]) / W, ye.y = (oe[2 * Z + 1] - oe[2 * H + 1]) / W, Fe[H][Z].push(H);
+ for (var He = 1; He < W; He++)
+ Fe[H][Z].push(Y.length / 3), Y[ke] = Y[3 * H] + He * me.x, k[ke++] = k[3 * H] + He * _e.x, Y[ke] = Y[3 * H + 1] + He * me.y, k[ke++] = k[3 * H + 1] + He * _e.y, Y[ke] = Y[3 * H + 2] + He * me.z, k[ke++] = k[3 * H + 2] + He * _e.z, oe[We++] = oe[2 * H] + He * ye.x, oe[We++] = oe[2 * H + 1] + He * ye.y;
+ Fe[H][Z].push(Z), Fe[Z][H] = new Array(), ge = Fe[H][Z].length;
+ for (var Qe = 0; Qe < ge; Qe++)
+ Fe[Z][H][Qe] = Fe[H][Z][ge - 1 - Qe];
+ }
+ for (q[0][0] = re[he], q[1][0] = Fe[re[he]][re[he + 1]][1], q[1][1] = Fe[re[he]][re[he + 2]][1], He = 2; He < W; He++)
+ for (q[He][0] = Fe[re[he]][re[he + 1]][He], q[He][He] = Fe[re[he]][re[he + 2]][He], me.x = (Y[3 * q[He][He]] - Y[3 * q[He][0]]) / He, me.y = (Y[3 * q[He][He] + 1] - Y[3 * q[He][0] + 1]) / He, me.z = (Y[3 * q[He][He] + 2] - Y[3 * q[He][0] + 2]) / He, _e.x = (k[3 * q[He][He]] - k[3 * q[He][0]]) / He, _e.y = (k[3 * q[He][He] + 1] - k[3 * q[He][0] + 1]) / He, _e.z = (k[3 * q[He][He] + 2] - k[3 * q[He][0] + 2]) / He, ye.x = (oe[2 * q[He][He]] - oe[2 * q[He][0]]) / He, ye.y = (oe[2 * q[He][He] + 1] - oe[2 * q[He][0] + 1]) / He, je = 1; je < He; je++)
+ q[He][je] = Y.length / 3, Y[ke] = Y[3 * q[He][0]] + je * me.x, k[ke++] = k[3 * q[He][0]] + je * _e.x, Y[ke] = Y[3 * q[He][0] + 1] + je * me.y, k[ke++] = k[3 * q[He][0] + 1] + je * _e.y, Y[ke] = Y[3 * q[He][0] + 2] + je * me.z, k[ke++] = k[3 * q[He][0] + 2] + je * _e.z, oe[We++] = oe[2 * q[He][0]] + je * ye.x, oe[We++] = oe[2 * q[He][0] + 1] + je * ye.y;
+ for (q[W] = Fe[re[he + 1]][re[he + 2]], Pe.push(q[0][0], q[1][0], q[1][1]), He = 1; He < W; He++) {
+ for (je = 0; je < He; je++)
+ Pe.push(q[He][je], q[He + 1][je], q[He + 1][je + 1]), Pe.push(q[He][je], q[He + 1][je + 1], q[He][je + 1]);
+ Pe.push(q[He][je], q[He + 1][je], q[He + 1][je + 1]);
+ }
+ }
+ Q.indices = Pe, Q.applyToMesh(this, this.isVertexBufferUpdatable(c.b.PositionKind));
+ } else
+ N.a.Warn("VertexData contains null entries");
+ }, L.prototype.forceSharedVertices = function() {
+ var G = T.a.ExtractFromMesh(this), Q = G.uvs, oe = G.indices, re = G.positions, Y = G.colors;
+ if (oe === void 0 || re === void 0 || oe === null || re === null)
+ N.a.Warn("VertexData contains empty entries");
+ else {
+ for (var k, H, Z = new Array(), W = new Array(), q = new Array(), he = new Array(), ge = new Array(), me = 0, _e = {}, ye = 0; ye < oe.length; ye += 3) {
+ H = [oe[ye], oe[ye + 1], oe[ye + 2]], ge = new Array();
+ for (var Pe = 0; Pe < 3; Pe++) {
+ ge[Pe] = "";
+ for (var be = 0; be < 3; be++)
+ Math.abs(re[3 * H[Pe] + be]) < 1e-8 && (re[3 * H[Pe] + be] = 0), ge[Pe] += re[3 * H[Pe] + be] + "|";
+ }
+ if (ge[0] != ge[1] && ge[0] != ge[2] && ge[1] != ge[2])
+ for (Pe = 0; Pe < 3; Pe++) {
+ if ((k = _e[ge[Pe]]) === void 0) {
+ for (_e[ge[Pe]] = me, k = me++, be = 0; be < 3; be++)
+ Z.push(re[3 * H[Pe] + be]);
+ if (Y != null)
+ for (be = 0; be < 4; be++)
+ he.push(Y[4 * H[Pe] + be]);
+ if (Q != null)
+ for (be = 0; be < 2; be++)
+ q.push(Q[2 * H[Pe] + be]);
+ }
+ W.push(k);
+ }
+ }
+ var Fe = new Array();
+ T.a.ComputeNormals(Z, W, Fe), G.positions = Z, G.indices = W, G.normals = Fe, Q != null && (G.uvs = q), Y != null && (G.colors = he), G.applyToMesh(this, this.isVertexBufferUpdatable(c.b.PositionKind));
+ }
+ }, L._instancedMeshFactory = function(G, Q) {
+ throw U.a.WarnImport("InstancedMesh");
+ }, L._PhysicsImpostorParser = function(G, Q, oe) {
+ throw U.a.WarnImport("PhysicsImpostor");
+ }, L.prototype.createInstance = function(G) {
+ var Q = this.geometry;
+ if (Q && Q.meshes.length > 1)
+ for (var oe = 0, re = Q.meshes.slice(0); oe < re.length; oe++) {
+ var Y = re[oe];
+ Y !== this && Y.makeGeometryUnique();
+ }
+ return L._instancedMeshFactory(G, this);
+ }, L.prototype.synchronizeInstances = function() {
+ this._geometry && this._geometry.meshes.length !== 1 && this.instances.length && this.makeGeometryUnique();
+ for (var G = 0; G < this.instances.length; G++)
+ this.instances[G]._syncSubMeshes();
+ return this;
+ }, L.prototype.optimizeIndices = function(G) {
+ var Q = this, oe = this.getIndices(), re = this.getVerticesData(c.b.PositionKind);
+ if (!re || !oe)
+ return this;
+ for (var Y = new Array(), k = 0; k < re.length; k += 3)
+ Y.push(O.e.FromArray(re, k));
+ var H = new Array();
+ return C.a.SyncAsyncForLoop(Y.length, 40, function(Z) {
+ for (var W = Y.length - 1 - Z, q = Y[W], he = 0; he < W; ++he) {
+ var ge = Y[he];
+ if (q.equals(ge)) {
+ H[W] = he;
+ break;
+ }
+ }
+ }, function() {
+ for (var Z = 0; Z < oe.length; ++Z)
+ oe[Z] = H[oe[Z]] || oe[Z];
+ var W = Q.subMeshes.slice(0);
+ Q.setIndices(oe), Q.subMeshes = W, G && G(Q);
+ }), this;
+ }, L.prototype.serialize = function(G) {
+ G.name = this.name, G.id = this.id, G.uniqueId = this.uniqueId, G.type = this.getClassName(), I.a && I.a.HasTags(this) && (G.tags = I.a.GetTags(this)), G.position = this.position.asArray(), this.rotationQuaternion ? G.rotationQuaternion = this.rotationQuaternion.asArray() : this.rotation && (G.rotation = this.rotation.asArray()), G.scaling = this.scaling.asArray(), this._postMultiplyPivotMatrix ? G.pivotMatrix = this.getPivotMatrix().asArray() : G.localMatrix = this.getPivotMatrix().asArray(), G.isEnabled = this.isEnabled(!1), G.isVisible = this.isVisible, G.infiniteDistance = this.infiniteDistance, G.pickable = this.isPickable, G.receiveShadows = this.receiveShadows, G.billboardMode = this.billboardMode, G.visibility = this.visibility, G.checkCollisions = this.checkCollisions, G.isBlocker = this.isBlocker, G.overrideMaterialSideOrientation = this.overrideMaterialSideOrientation, this.parent && (G.parentId = this.parent.id), G.isUnIndexed = this.isUnIndexed;
+ var Q = this._geometry;
+ if (Q) {
+ var oe = Q.id;
+ G.geometryId = oe, G.subMeshes = [];
+ for (var re = 0; re < this.subMeshes.length; re++) {
+ var Y = this.subMeshes[re];
+ G.subMeshes.push({ materialIndex: Y.materialIndex, verticesStart: Y.verticesStart, verticesCount: Y.verticesCount, indexStart: Y.indexStart, indexCount: Y.indexCount });
+ }
+ }
+ this.material ? this.material.doNotSerialize || (G.materialId = this.material.id) : this.material = null, this.morphTargetManager && (G.morphTargetManagerId = this.morphTargetManager.uniqueId), this.skeleton && (G.skeletonId = this.skeleton.id, G.numBoneInfluencers = this.numBoneInfluencers), this.getScene()._getComponent(X.a.NAME_PHYSICSENGINE) && (Z = this.getPhysicsImpostor()) && (G.physicsMass = Z.getParam("mass"), G.physicsFriction = Z.getParam("friction"), G.physicsRestitution = Z.getParam("mass"), G.physicsImpostor = Z.type), this.metadata && (G.metadata = this.metadata), G.instances = [];
+ for (var k = 0; k < this.instances.length; k++) {
+ var H = this.instances[k];
+ if (!H.doNotSerialize) {
+ var Z, W = { name: H.name, id: H.id, isEnabled: H.isEnabled(!1), isVisible: H.isVisible, isPickable: H.isPickable, checkCollisions: H.checkCollisions, position: H.position.asArray(), scaling: H.scaling.asArray() };
+ H.parent && (W.parentId = H.parent.id), H.rotationQuaternion ? W.rotationQuaternion = H.rotationQuaternion.asArray() : H.rotation && (W.rotation = H.rotation.asArray()), this.getScene()._getComponent(X.a.NAME_PHYSICSENGINE) && (Z = H.getPhysicsImpostor()) && (W.physicsMass = Z.getParam("mass"), W.physicsFriction = Z.getParam("friction"), W.physicsRestitution = Z.getParam("mass"), W.physicsImpostor = Z.type), H.metadata && (W.metadata = H.metadata), G.instances.push(W), w.a.AppendSerializedAnimations(H, W), W.ranges = H.serializeAnimationRanges();
+ }
+ }
+ if (this._thinInstanceDataStorage.instancesCount && this._thinInstanceDataStorage.matrixData && (G.thinInstances = { instancesCount: this._thinInstanceDataStorage.instancesCount, matrixData: C.b.SliceToArray(this._thinInstanceDataStorage.matrixData), matrixBufferSize: this._thinInstanceDataStorage.matrixBufferSize }, this._userThinInstanceBuffersStorage)) {
+ var q = { data: {}, sizes: {}, strides: {} };
+ for (var he in this._userThinInstanceBuffersStorage.data)
+ q.data[he] = C.b.SliceToArray(this._userThinInstanceBuffersStorage.data[he]), q.sizes[he] = this._userThinInstanceBuffersStorage.sizes[he], q.strides[he] = this._userThinInstanceBuffersStorage.strides[he];
+ G.thinInstances.userThinInstance = q;
+ }
+ w.a.AppendSerializedAnimations(this, G), G.ranges = this.serializeAnimationRanges(), G.layerMask = this.layerMask, G.alphaIndex = this.alphaIndex, G.hasVertexAlpha = this.hasVertexAlpha, G.overlayAlpha = this.overlayAlpha, G.overlayColor = this.overlayColor.asArray(), G.renderOverlay = this.renderOverlay, G.applyFog = this.applyFog, this.actionManager && (G.actions = this.actionManager.serialize(this.name));
+ }, L.prototype._syncGeometryWithMorphTargetManager = function() {
+ if (this.geometry) {
+ this._markSubMeshesAsAttributesDirty();
+ var G = this._internalMeshDataInfo._morphTargetManager;
+ if (G && G.vertexCount) {
+ if (G.vertexCount !== this.getTotalVertices())
+ return N.a.Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count."), void (this.morphTargetManager = null);
+ for (var Q = 0; Q < G.numInfluencers; Q++) {
+ var oe = G.getActiveTarget(Q), re = oe.getPositions();
+ if (!re)
+ return void N.a.Error("Invalid morph target. Target must have positions.");
+ this.geometry.setVerticesData(c.b.PositionKind + Q, re, !1, 3);
+ var Y = oe.getNormals();
+ Y && this.geometry.setVerticesData(c.b.NormalKind + Q, Y, !1, 3);
+ var k = oe.getTangents();
+ k && this.geometry.setVerticesData(c.b.TangentKind + Q, k, !1, 3);
+ var H = oe.getUVs();
+ H && this.geometry.setVerticesData(c.b.UVKind + "_" + Q, H, !1, 2);
+ }
+ } else
+ for (Q = 0; this.geometry.isVerticesDataPresent(c.b.PositionKind + Q); )
+ this.geometry.removeVerticesData(c.b.PositionKind + Q), this.geometry.isVerticesDataPresent(c.b.NormalKind + Q) && this.geometry.removeVerticesData(c.b.NormalKind + Q), this.geometry.isVerticesDataPresent(c.b.TangentKind + Q) && this.geometry.removeVerticesData(c.b.TangentKind + Q), this.geometry.isVerticesDataPresent(c.b.UVKind + Q) && this.geometry.removeVerticesData(c.b.UVKind + "_" + Q), Q++;
+ }
+ }, L.Parse = function(G, Q, oe) {
+ var re;
+ if ((re = G.type && G.type === "GroundMesh" ? L._GroundMeshParser(G, Q) : new L(G.name, Q)).id = G.id, I.a && I.a.AddTagsTo(re, G.tags), re.position = O.e.FromArray(G.position), G.metadata !== void 0 && (re.metadata = G.metadata), G.rotationQuaternion ? re.rotationQuaternion = O.b.FromArray(G.rotationQuaternion) : G.rotation && (re.rotation = O.e.FromArray(G.rotation)), re.scaling = O.e.FromArray(G.scaling), G.localMatrix ? re.setPreTransformMatrix(O.a.FromArray(G.localMatrix)) : G.pivotMatrix && re.setPivotMatrix(O.a.FromArray(G.pivotMatrix)), re.setEnabled(G.isEnabled), re.isVisible = G.isVisible, re.infiniteDistance = G.infiniteDistance, re.showBoundingBox = G.showBoundingBox, re.showSubMeshesBoundingBox = G.showSubMeshesBoundingBox, G.applyFog !== void 0 && (re.applyFog = G.applyFog), G.pickable !== void 0 && (re.isPickable = G.pickable), G.alphaIndex !== void 0 && (re.alphaIndex = G.alphaIndex), re.receiveShadows = G.receiveShadows, re.billboardMode = G.billboardMode, G.visibility !== void 0 && (re.visibility = G.visibility), re.checkCollisions = G.checkCollisions, re.overrideMaterialSideOrientation = G.overrideMaterialSideOrientation, G.isBlocker !== void 0 && (re.isBlocker = G.isBlocker), re._shouldGenerateFlatShading = G.useFlatShading, G.freezeWorldMatrix && (re._waitingData.freezeWorldMatrix = G.freezeWorldMatrix), G.parentId && (re._waitingParentId = G.parentId), G.actions !== void 0 && (re._waitingData.actions = G.actions), G.overlayAlpha !== void 0 && (re.overlayAlpha = G.overlayAlpha), G.overlayColor !== void 0 && (re.overlayColor = x.a.FromArray(G.overlayColor)), G.renderOverlay !== void 0 && (re.renderOverlay = G.renderOverlay), re.isUnIndexed = !!G.isUnIndexed, re.hasVertexAlpha = G.hasVertexAlpha, G.delayLoadingFile ? (re.delayLoadState = D.a.DELAYLOADSTATE_NOTLOADED, re.delayLoadingFile = oe + G.delayLoadingFile, re._boundingInfo = new l.a(O.e.FromArray(G.boundingBoxMinimum), O.e.FromArray(G.boundingBoxMaximum)), G._binaryInfo && (re._binaryInfo = G._binaryInfo), re._delayInfo = [], G.hasUVs && re._delayInfo.push(c.b.UVKind), G.hasUVs2 && re._delayInfo.push(c.b.UV2Kind), G.hasUVs3 && re._delayInfo.push(c.b.UV3Kind), G.hasUVs4 && re._delayInfo.push(c.b.UV4Kind), G.hasUVs5 && re._delayInfo.push(c.b.UV5Kind), G.hasUVs6 && re._delayInfo.push(c.b.UV6Kind), G.hasColors && re._delayInfo.push(c.b.ColorKind), G.hasMatricesIndices && re._delayInfo.push(c.b.MatricesIndicesKind), G.hasMatricesWeights && re._delayInfo.push(c.b.MatricesWeightsKind), re._delayLoadingFunction = S.a._ImportGeometry, b.a.ForceFullSceneLoadingForIncremental && re._checkDelayState()) : S.a._ImportGeometry(G, re), G.materialId ? re.setMaterialByID(G.materialId) : re.material = null, G.morphTargetManagerId > -1 && (re.morphTargetManager = Q.getMorphTargetManagerById(G.morphTargetManagerId)), G.skeletonId !== void 0 && G.skeletonId !== null && (re.skeleton = Q.getLastSkeletonByID(G.skeletonId), G.numBoneInfluencers && (re.numBoneInfluencers = G.numBoneInfluencers)), G.animations) {
+ for (var Y = 0; Y < G.animations.length; Y++) {
+ var k = G.animations[Y];
+ (q = M.a.GetClass("BABYLON.Animation")) && re.animations.push(q.Parse(k));
+ }
+ m.a.ParseAnimationRanges(re, G, Q);
+ }
+ if (G.autoAnimate && Q.beginAnimation(re, G.autoAnimateFrom, G.autoAnimateTo, G.autoAnimateLoop, G.autoAnimateSpeed || 1), G.layerMask && !isNaN(G.layerMask) ? re.layerMask = Math.abs(parseInt(G.layerMask)) : re.layerMask = 268435455, G.physicsImpostor && L._PhysicsImpostorParser(Q, re, G), G.lodMeshIds && (re._waitingData.lods = { ids: G.lodMeshIds, distances: G.lodDistances ? G.lodDistances : null, coverages: G.lodCoverages ? G.lodCoverages : null }), G.instances)
+ for (var H = 0; H < G.instances.length; H++) {
+ var Z = G.instances[H], W = re.createInstance(Z.name);
+ if (Z.id && (W.id = Z.id), I.a && (Z.tags ? I.a.AddTagsTo(W, Z.tags) : I.a.AddTagsTo(W, G.tags)), W.position = O.e.FromArray(Z.position), Z.metadata !== void 0 && (W.metadata = Z.metadata), Z.parentId && (W._waitingParentId = Z.parentId), Z.isEnabled !== void 0 && Z.isEnabled !== null && W.setEnabled(Z.isEnabled), Z.isVisible !== void 0 && Z.isVisible !== null && (W.isVisible = Z.isVisible), Z.isPickable !== void 0 && Z.isPickable !== null && (W.isPickable = Z.isPickable), Z.rotationQuaternion ? W.rotationQuaternion = O.b.FromArray(Z.rotationQuaternion) : Z.rotation && (W.rotation = O.e.FromArray(Z.rotation)), W.scaling = O.e.FromArray(Z.scaling), Z.checkCollisions != null && Z.checkCollisions != null && (W.checkCollisions = Z.checkCollisions), Z.pickable != null && Z.pickable != null && (W.isPickable = Z.pickable), Z.showBoundingBox != null && Z.showBoundingBox != null && (W.showBoundingBox = Z.showBoundingBox), Z.showSubMeshesBoundingBox != null && Z.showSubMeshesBoundingBox != null && (W.showSubMeshesBoundingBox = Z.showSubMeshesBoundingBox), Z.alphaIndex != null && Z.showSubMeshesBoundingBox != null && (W.alphaIndex = Z.alphaIndex), Z.physicsImpostor && L._PhysicsImpostorParser(Q, W, Z), Z.animations) {
+ for (Y = 0; Y < Z.animations.length; Y++) {
+ var q;
+ k = Z.animations[Y], (q = M.a.GetClass("BABYLON.Animation")) && W.animations.push(q.Parse(k));
+ }
+ m.a.ParseAnimationRanges(W, Z, Q), Z.autoAnimate && Q.beginAnimation(W, Z.autoAnimateFrom, Z.autoAnimateTo, Z.autoAnimateLoop, Z.autoAnimateSpeed || 1);
+ }
+ }
+ if (G.thinInstances) {
+ var he = G.thinInstances;
+ if (he.matrixData ? (re.thinInstanceSetBuffer("matrix", new Float32Array(he.matrixData), 16, !1), re._thinInstanceDataStorage.matrixBufferSize = he.matrixBufferSize, re._thinInstanceDataStorage.instancesCount = he.instancesCount) : re._thinInstanceDataStorage.matrixBufferSize = he.matrixBufferSize, G.thinInstances.userThinInstance) {
+ var ge = G.thinInstances.userThinInstance;
+ for (var me in ge.data)
+ re.thinInstanceSetBuffer(me, new Float32Array(ge.data[me]), ge.strides[me], !1), re._userThinInstanceBuffersStorage.sizes[me] = ge.sizes[me];
+ }
+ }
+ return re;
+ }, L.CreateRibbon = function(G, Q, oe, re, Y, k, H, Z, W) {
+ throw U.a.WarnImport("MeshBuilder");
+ }, L.CreateDisc = function(G, Q, oe, re, Y, k) {
+ throw U.a.WarnImport("MeshBuilder");
+ }, L.CreateBox = function(G, Q, oe, re, Y) {
+ throw U.a.WarnImport("MeshBuilder");
+ }, L.CreateSphere = function(G, Q, oe, re, Y, k) {
+ throw U.a.WarnImport("MeshBuilder");
+ }, L.CreateHemisphere = function(G, Q, oe, re) {
+ throw U.a.WarnImport("MeshBuilder");
+ }, L.CreateCylinder = function(G, Q, oe, re, Y, k, H, Z, W) {
+ throw U.a.WarnImport("MeshBuilder");
+ }, L.CreateTorus = function(G, Q, oe, re, Y, k, H) {
+ throw U.a.WarnImport("MeshBuilder");
+ }, L.CreateTorusKnot = function(G, Q, oe, re, Y, k, H, Z, W, q) {
+ throw U.a.WarnImport("MeshBuilder");
+ }, L.CreateLines = function(G, Q, oe, re, Y) {
+ throw U.a.WarnImport("MeshBuilder");
+ }, L.CreateDashedLines = function(G, Q, oe, re, Y, k, H, Z) {
+ throw U.a.WarnImport("MeshBuilder");
+ }, L.CreatePolygon = function(G, Q, oe, re, Y, k, H) {
+ throw H === void 0 && (H = earcut), U.a.WarnImport("MeshBuilder");
+ }, L.ExtrudePolygon = function(G, Q, oe, re, Y, k, H, Z) {
+ throw Z === void 0 && (Z = earcut), U.a.WarnImport("MeshBuilder");
+ }, L.ExtrudeShape = function(G, Q, oe, re, Y, k, H, Z, W, q) {
+ throw U.a.WarnImport("MeshBuilder");
+ }, L.ExtrudeShapeCustom = function(G, Q, oe, re, Y, k, H, Z, W, q, he, ge) {
+ throw U.a.WarnImport("MeshBuilder");
+ }, L.CreateLathe = function(G, Q, oe, re, Y, k, H) {
+ throw U.a.WarnImport("MeshBuilder");
+ }, L.CreatePlane = function(G, Q, oe, re, Y) {
+ throw U.a.WarnImport("MeshBuilder");
+ }, L.CreateGround = function(G, Q, oe, re, Y, k) {
+ throw U.a.WarnImport("MeshBuilder");
+ }, L.CreateTiledGround = function(G, Q, oe, re, Y, k, H, Z, W) {
+ throw U.a.WarnImport("MeshBuilder");
+ }, L.CreateGroundFromHeightMap = function(G, Q, oe, re, Y, k, H, Z, W, q, he) {
+ throw U.a.WarnImport("MeshBuilder");
+ }, L.CreateTube = function(G, Q, oe, re, Y, k, H, Z, W, q) {
+ throw U.a.WarnImport("MeshBuilder");
+ }, L.CreatePolyhedron = function(G, Q, oe) {
+ throw U.a.WarnImport("MeshBuilder");
+ }, L.CreateIcoSphere = function(G, Q, oe) {
+ throw U.a.WarnImport("MeshBuilder");
+ }, L.CreateDecal = function(G, Q, oe, re, Y, k) {
+ throw U.a.WarnImport("MeshBuilder");
+ }, L.CreateCapsule = function(G, Q, oe) {
+ throw U.a.WarnImport("MeshBuilder");
+ }, L.prototype.setPositionsForCPUSkinning = function() {
+ var G = this._internalMeshDataInfo;
+ if (!G._sourcePositions) {
+ var Q = this.getVerticesData(c.b.PositionKind);
+ if (!Q)
+ return G._sourcePositions;
+ G._sourcePositions = new Float32Array(Q), this.isVertexBufferUpdatable(c.b.PositionKind) || this.setVerticesData(c.b.PositionKind, Q, !0);
+ }
+ return G._sourcePositions;
+ }, L.prototype.setNormalsForCPUSkinning = function() {
+ var G = this._internalMeshDataInfo;
+ if (!G._sourceNormals) {
+ var Q = this.getVerticesData(c.b.NormalKind);
+ if (!Q)
+ return G._sourceNormals;
+ G._sourceNormals = new Float32Array(Q), this.isVertexBufferUpdatable(c.b.NormalKind) || this.setVerticesData(c.b.NormalKind, Q, !0);
+ }
+ return G._sourceNormals;
+ }, L.prototype.applySkeleton = function(G) {
+ if (!this.geometry)
+ return this;
+ if (this.geometry._softwareSkinningFrameId == this.getScene().getFrameId())
+ return this;
+ if (this.geometry._softwareSkinningFrameId = this.getScene().getFrameId(), !this.isVerticesDataPresent(c.b.PositionKind))
+ return this;
+ if (!this.isVerticesDataPresent(c.b.MatricesIndicesKind))
+ return this;
+ if (!this.isVerticesDataPresent(c.b.MatricesWeightsKind))
+ return this;
+ var Q = this.isVerticesDataPresent(c.b.NormalKind), oe = this._internalMeshDataInfo;
+ if (!oe._sourcePositions) {
+ var re = this.subMeshes.slice();
+ this.setPositionsForCPUSkinning(), this.subMeshes = re;
+ }
+ Q && !oe._sourceNormals && this.setNormalsForCPUSkinning();
+ var Y = this.getVerticesData(c.b.PositionKind);
+ if (!Y)
+ return this;
+ Y instanceof Float32Array || (Y = new Float32Array(Y));
+ var k = this.getVerticesData(c.b.NormalKind);
+ if (Q) {
+ if (!k)
+ return this;
+ k instanceof Float32Array || (k = new Float32Array(k));
+ }
+ var H = this.getVerticesData(c.b.MatricesIndicesKind), Z = this.getVerticesData(c.b.MatricesWeightsKind);
+ if (!Z || !H)
+ return this;
+ for (var W, q = this.numBoneInfluencers > 4, he = q ? this.getVerticesData(c.b.MatricesIndicesExtraKind) : null, ge = q ? this.getVerticesData(c.b.MatricesWeightsExtraKind) : null, me = G.getTransformMatrices(this), _e = O.e.Zero(), ye = new O.a(), Pe = new O.a(), be = 0, Fe = 0; Fe < Y.length; Fe += 3, be += 4) {
+ var ke;
+ for (W = 0; W < 4; W++)
+ (ke = Z[be + W]) > 0 && (O.a.FromFloat32ArrayToRefScaled(me, Math.floor(16 * H[be + W]), ke, Pe), ye.addToSelf(Pe));
+ if (q)
+ for (W = 0; W < 4; W++)
+ (ke = ge[be + W]) > 0 && (O.a.FromFloat32ArrayToRefScaled(me, Math.floor(16 * he[be + W]), ke, Pe), ye.addToSelf(Pe));
+ O.e.TransformCoordinatesFromFloatsToRef(oe._sourcePositions[Fe], oe._sourcePositions[Fe + 1], oe._sourcePositions[Fe + 2], ye, _e), _e.toArray(Y, Fe), Q && (O.e.TransformNormalFromFloatsToRef(oe._sourceNormals[Fe], oe._sourceNormals[Fe + 1], oe._sourceNormals[Fe + 2], ye, _e), _e.toArray(k, Fe)), ye.reset();
+ }
+ return this.updateVerticesData(c.b.PositionKind, Y), Q && this.updateVerticesData(c.b.NormalKind, k), this;
+ }, L.MinMax = function(G) {
+ var Q = null, oe = null;
+ return G.forEach(function(re) {
+ var Y = re.getBoundingInfo().boundingBox;
+ Q && oe ? (Q.minimizeInPlace(Y.minimumWorld), oe.maximizeInPlace(Y.maximumWorld)) : (Q = Y.minimumWorld, oe = Y.maximumWorld);
+ }), Q && oe ? { min: Q, max: oe } : { min: O.e.Zero(), max: O.e.Zero() };
+ }, L.Center = function(G) {
+ var Q = G instanceof Array ? L.MinMax(G) : G;
+ return O.e.Center(Q.min, Q.max);
+ }, L.MergeMeshes = function(G, Q, oe, re, Y, k) {
+ var H;
+ if (Q === void 0 && (Q = !0), !oe) {
+ var Z = 0;
+ for (H = 0; H < G.length; H++)
+ if (G[H] && (Z += G[H].getTotalVertices()) >= 65536)
+ return N.a.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices"), null;
+ }
+ if (k) {
+ var W, q, he = null;
+ Y = !1;
+ }
+ var ge, me = new Array(), _e = new Array(), ye = null, Pe = new Array(), be = null;
+ for (H = 0; H < G.length; H++)
+ if (G[H]) {
+ var Fe = G[H];
+ if (Fe.isAnInstance)
+ return N.a.Warn("Cannot merge instance meshes."), null;
+ var ke = Fe.computeWorldMatrix(!0);
+ if ((ge = T.a.ExtractFromMesh(Fe, !0, !0)).transform(ke), ye ? ye.merge(ge, oe) : (ye = ge, be = Fe), Y && Pe.push(Fe.getTotalIndices()), k)
+ if (Fe.material) {
+ var We = Fe.material;
+ if (We instanceof v.a) {
+ for (q = 0; q < We.subMaterials.length; q++)
+ me.indexOf(We.subMaterials[q]) < 0 && me.push(We.subMaterials[q]);
+ for (W = 0; W < Fe.subMeshes.length; W++)
+ _e.push(me.indexOf(We.subMaterials[Fe.subMeshes[W].materialIndex])), Pe.push(Fe.subMeshes[W].indexCount);
+ } else
+ for (me.indexOf(We) < 0 && me.push(We), W = 0; W < Fe.subMeshes.length; W++)
+ _e.push(me.indexOf(We)), Pe.push(Fe.subMeshes[W].indexCount);
+ } else
+ for (W = 0; W < Fe.subMeshes.length; W++)
+ _e.push(0), Pe.push(Fe.subMeshes[W].indexCount);
+ }
+ if (be = be, re || (re = new L(be.name + "_merged", be.getScene())), ye.applyToMesh(re), re.checkCollisions = be.checkCollisions, re.overrideMaterialSideOrientation = be.overrideMaterialSideOrientation, Q)
+ for (H = 0; H < G.length; H++)
+ G[H] && G[H].dispose();
+ if (Y || k) {
+ re.releaseSubMeshes(), H = 0;
+ for (var je = 0; H < Pe.length; )
+ g.a.CreateFromIndices(0, je, Pe[H], re), je += Pe[H], H++;
+ }
+ if (k) {
+ for ((he = new v.a(be.name + "_merged", be.getScene())).subMaterials = me, W = 0; W < re.subMeshes.length; W++)
+ re.subMeshes[W].materialIndex = _e[W];
+ re.material = he;
+ } else
+ re.material = be.material;
+ return re;
+ }, L.prototype.addInstance = function(G) {
+ G._indexInSourceMeshInstanceArray = this.instances.length, this.instances.push(G);
+ }, L.prototype.removeInstance = function(G) {
+ var Q = G._indexInSourceMeshInstanceArray;
+ if (Q != -1) {
+ if (Q !== this.instances.length - 1) {
+ var oe = this.instances[this.instances.length - 1];
+ this.instances[Q] = oe, oe._indexInSourceMeshInstanceArray = Q;
+ }
+ G._indexInSourceMeshInstanceArray = -1, this.instances.pop();
+ }
+ }, L.FRONTSIDE = T.a.FRONTSIDE, L.BACKSIDE = T.a.BACKSIDE, L.DOUBLESIDE = T.a.DOUBLESIDE, L.DEFAULTSIDE = T.a.DEFAULTSIDE, L.NO_CAP = 0, L.CAP_START = 1, L.CAP_END = 2, L.CAP_ALL = 3, L.NO_FLIP = 0, L.FLIP_TILE = 1, L.ROTATE_TILE = 2, L.FLIP_ROW = 3, L.ROTATE_ROW = 4, L.FLIP_N_ROTATE_TILE = 5, L.FLIP_N_ROTATE_ROW = 6, L.CENTER = 0, L.LEFT = 1, L.RIGHT = 2, L.TOP = 3, L.BOTTOM = 4, L._GroundMeshParser = function(G, Q) {
+ throw U.a.WarnImport("GroundMesh");
+ }, L;
+ }(E.a);
+ M.a.RegisteredTypes["BABYLON.Mesh"] = K;
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return V;
+ });
+ var V = function() {
+ function _() {
+ }
+ return _._AddLogEntry = function(C) {
+ _._LogCache = C + _._LogCache, _.OnNewCacheEntry && _.OnNewCacheEntry(C);
+ }, _._FormatMessage = function(C) {
+ var u = function(O) {
+ return O < 10 ? "0" + O : "" + O;
+ }, I = /* @__PURE__ */ new Date();
+ return "[" + u(I.getHours()) + ":" + u(I.getMinutes()) + ":" + u(I.getSeconds()) + "]: " + C;
+ }, _._LogDisabled = function(C) {
+ }, _._LogEnabled = function(C) {
+ var u = _._FormatMessage(C);
+ console.log("BJS - " + u);
+ var I = "
" + u + "
";
+ _._AddLogEntry(I);
+ }, _._WarnDisabled = function(C) {
+ }, _._WarnEnabled = function(C) {
+ var u = _._FormatMessage(C);
+ console.warn("BJS - " + u);
+ var I = "" + u + "
";
+ _._AddLogEntry(I);
+ }, _._ErrorDisabled = function(C) {
+ }, _._ErrorEnabled = function(C) {
+ _.errorsCount++;
+ var u = _._FormatMessage(C);
+ console.error("BJS - " + u);
+ var I = "" + u + "
";
+ _._AddLogEntry(I);
+ }, Object.defineProperty(_, "LogCache", { get: function() {
+ return _._LogCache;
+ }, enumerable: !1, configurable: !0 }), _.ClearLogCache = function() {
+ _._LogCache = "", _.errorsCount = 0;
+ }, Object.defineProperty(_, "LogLevels", { set: function(C) {
+ (C & _.MessageLogLevel) === _.MessageLogLevel ? _.Log = _._LogEnabled : _.Log = _._LogDisabled, (C & _.WarningLogLevel) === _.WarningLogLevel ? _.Warn = _._WarnEnabled : _.Warn = _._WarnDisabled, (C & _.ErrorLogLevel) === _.ErrorLogLevel ? _.Error = _._ErrorEnabled : _.Error = _._ErrorDisabled;
+ }, enumerable: !1, configurable: !0 }), _.NoneLogLevel = 0, _.MessageLogLevel = 1, _.WarningLogLevel = 2, _.ErrorLogLevel = 4, _.AllLogLevel = 7, _._LogCache = "", _.errorsCount = 0, _.Log = _._LogEnabled, _.Warn = _._WarnEnabled, _.Error = _._ErrorEnabled, _;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return I;
+ }), f.d(A, "b", function() {
+ return O;
+ }), f.d(A, "c", function() {
+ return x;
+ });
+ var V = f(14), _ = f(28), C = f(44), u = f(11), I = function() {
+ function m(c, T, S) {
+ c === void 0 && (c = 0), T === void 0 && (T = 0), S === void 0 && (S = 0), this.r = c, this.g = T, this.b = S;
+ }
+ return m.prototype.toString = function() {
+ return "{R: " + this.r + " G:" + this.g + " B:" + this.b + "}";
+ }, m.prototype.getClassName = function() {
+ return "Color3";
+ }, m.prototype.getHashCode = function() {
+ var c = 255 * this.r | 0;
+ return c = 397 * (c = 397 * c ^ (255 * this.g | 0)) ^ (255 * this.b | 0);
+ }, m.prototype.toArray = function(c, T) {
+ return T === void 0 && (T = 0), c[T] = this.r, c[T + 1] = this.g, c[T + 2] = this.b, this;
+ }, m.prototype.fromArray = function(c, T) {
+ return T === void 0 && (T = 0), m.FromArrayToRef(c, T, this), this;
+ }, m.prototype.toColor4 = function(c) {
+ return c === void 0 && (c = 1), new O(this.r, this.g, this.b, c);
+ }, m.prototype.asArray = function() {
+ var c = new Array();
+ return this.toArray(c, 0), c;
+ }, m.prototype.toLuminance = function() {
+ return 0.3 * this.r + 0.59 * this.g + 0.11 * this.b;
+ }, m.prototype.multiply = function(c) {
+ return new m(this.r * c.r, this.g * c.g, this.b * c.b);
+ }, m.prototype.multiplyToRef = function(c, T) {
+ return T.r = this.r * c.r, T.g = this.g * c.g, T.b = this.b * c.b, this;
+ }, m.prototype.equals = function(c) {
+ return c && this.r === c.r && this.g === c.g && this.b === c.b;
+ }, m.prototype.equalsFloats = function(c, T, S) {
+ return this.r === c && this.g === T && this.b === S;
+ }, m.prototype.scale = function(c) {
+ return new m(this.r * c, this.g * c, this.b * c);
+ }, m.prototype.scaleToRef = function(c, T) {
+ return T.r = this.r * c, T.g = this.g * c, T.b = this.b * c, this;
+ }, m.prototype.scaleAndAddToRef = function(c, T) {
+ return T.r += this.r * c, T.g += this.g * c, T.b += this.b * c, this;
+ }, m.prototype.clampToRef = function(c, T, S) {
+ return c === void 0 && (c = 0), T === void 0 && (T = 1), S.r = V.a.Clamp(this.r, c, T), S.g = V.a.Clamp(this.g, c, T), S.b = V.a.Clamp(this.b, c, T), this;
+ }, m.prototype.add = function(c) {
+ return new m(this.r + c.r, this.g + c.g, this.b + c.b);
+ }, m.prototype.addToRef = function(c, T) {
+ return T.r = this.r + c.r, T.g = this.g + c.g, T.b = this.b + c.b, this;
+ }, m.prototype.subtract = function(c) {
+ return new m(this.r - c.r, this.g - c.g, this.b - c.b);
+ }, m.prototype.subtractToRef = function(c, T) {
+ return T.r = this.r - c.r, T.g = this.g - c.g, T.b = this.b - c.b, this;
+ }, m.prototype.clone = function() {
+ return new m(this.r, this.g, this.b);
+ }, m.prototype.copyFrom = function(c) {
+ return this.r = c.r, this.g = c.g, this.b = c.b, this;
+ }, m.prototype.copyFromFloats = function(c, T, S) {
+ return this.r = c, this.g = T, this.b = S, this;
+ }, m.prototype.set = function(c, T, S) {
+ return this.copyFromFloats(c, T, S);
+ }, m.prototype.toHexString = function() {
+ var c = 255 * this.r | 0, T = 255 * this.g | 0, S = 255 * this.b | 0;
+ return "#" + V.a.ToHex(c) + V.a.ToHex(T) + V.a.ToHex(S);
+ }, m.prototype.toLinearSpace = function() {
+ var c = new m();
+ return this.toLinearSpaceToRef(c), c;
+ }, m.prototype.toHSV = function() {
+ var c = new m();
+ return this.toHSVToRef(c), c;
+ }, m.prototype.toHSVToRef = function(c) {
+ var T = this.r, S = this.g, E = this.b, g = Math.max(T, S, E), l = Math.min(T, S, E), h = 0, v = 0, b = g, D = g - l;
+ g !== 0 && (v = D / g), g != l && (g == T ? (h = (S - E) / D, S < E && (h += 6)) : g == S ? h = (E - T) / D + 2 : g == E && (h = (T - S) / D + 4), h *= 60), c.r = h, c.g = v, c.b = b;
+ }, m.prototype.toLinearSpaceToRef = function(c) {
+ return c.r = Math.pow(this.r, _.c), c.g = Math.pow(this.g, _.c), c.b = Math.pow(this.b, _.c), this;
+ }, m.prototype.toGammaSpace = function() {
+ var c = new m();
+ return this.toGammaSpaceToRef(c), c;
+ }, m.prototype.toGammaSpaceToRef = function(c) {
+ return c.r = Math.pow(this.r, _.b), c.g = Math.pow(this.g, _.b), c.b = Math.pow(this.b, _.b), this;
+ }, m.HSVtoRGBToRef = function(c, T, S, E) {
+ var g = S * T, l = c / 60, h = g * (1 - Math.abs(l % 2 - 1)), v = 0, b = 0, D = 0;
+ l >= 0 && l <= 1 ? (v = g, b = h) : l >= 1 && l <= 2 ? (v = h, b = g) : l >= 2 && l <= 3 ? (b = g, D = h) : l >= 3 && l <= 4 ? (b = h, D = g) : l >= 4 && l <= 5 ? (v = h, D = g) : l >= 5 && l <= 6 && (v = g, D = h);
+ var w = S - g;
+ E.set(v + w, b + w, D + w);
+ }, m.FromHexString = function(c) {
+ if (c.substring(0, 1) !== "#" || c.length !== 7)
+ return new m(0, 0, 0);
+ var T = parseInt(c.substring(1, 3), 16), S = parseInt(c.substring(3, 5), 16), E = parseInt(c.substring(5, 7), 16);
+ return m.FromInts(T, S, E);
+ }, m.FromArray = function(c, T) {
+ return T === void 0 && (T = 0), new m(c[T], c[T + 1], c[T + 2]);
+ }, m.FromArrayToRef = function(c, T, S) {
+ T === void 0 && (T = 0), S.r = c[T], S.g = c[T + 1], S.b = c[T + 2];
+ }, m.FromInts = function(c, T, S) {
+ return new m(c / 255, T / 255, S / 255);
+ }, m.Lerp = function(c, T, S) {
+ var E = new m(0, 0, 0);
+ return m.LerpToRef(c, T, S, E), E;
+ }, m.LerpToRef = function(c, T, S, E) {
+ E.r = c.r + (T.r - c.r) * S, E.g = c.g + (T.g - c.g) * S, E.b = c.b + (T.b - c.b) * S;
+ }, m.Red = function() {
+ return new m(1, 0, 0);
+ }, m.Green = function() {
+ return new m(0, 1, 0);
+ }, m.Blue = function() {
+ return new m(0, 0, 1);
+ }, m.Black = function() {
+ return new m(0, 0, 0);
+ }, Object.defineProperty(m, "BlackReadOnly", { get: function() {
+ return m._BlackReadOnly;
+ }, enumerable: !1, configurable: !0 }), m.White = function() {
+ return new m(1, 1, 1);
+ }, m.Purple = function() {
+ return new m(0.5, 0, 0.5);
+ }, m.Magenta = function() {
+ return new m(1, 0, 1);
+ }, m.Yellow = function() {
+ return new m(1, 1, 0);
+ }, m.Gray = function() {
+ return new m(0.5, 0.5, 0.5);
+ }, m.Teal = function() {
+ return new m(0, 1, 1);
+ }, m.Random = function() {
+ return new m(Math.random(), Math.random(), Math.random());
+ }, m._BlackReadOnly = m.Black(), m;
+ }(), O = function() {
+ function m(c, T, S, E) {
+ c === void 0 && (c = 0), T === void 0 && (T = 0), S === void 0 && (S = 0), E === void 0 && (E = 1), this.r = c, this.g = T, this.b = S, this.a = E;
+ }
+ return m.prototype.addInPlace = function(c) {
+ return this.r += c.r, this.g += c.g, this.b += c.b, this.a += c.a, this;
+ }, m.prototype.asArray = function() {
+ var c = new Array();
+ return this.toArray(c, 0), c;
+ }, m.prototype.toArray = function(c, T) {
+ return T === void 0 && (T = 0), c[T] = this.r, c[T + 1] = this.g, c[T + 2] = this.b, c[T + 3] = this.a, this;
+ }, m.prototype.fromArray = function(c, T) {
+ return T === void 0 && (T = 0), m.FromArrayToRef(c, T, this), this;
+ }, m.prototype.equals = function(c) {
+ return c && this.r === c.r && this.g === c.g && this.b === c.b && this.a === c.a;
+ }, m.prototype.add = function(c) {
+ return new m(this.r + c.r, this.g + c.g, this.b + c.b, this.a + c.a);
+ }, m.prototype.subtract = function(c) {
+ return new m(this.r - c.r, this.g - c.g, this.b - c.b, this.a - c.a);
+ }, m.prototype.subtractToRef = function(c, T) {
+ return T.r = this.r - c.r, T.g = this.g - c.g, T.b = this.b - c.b, T.a = this.a - c.a, this;
+ }, m.prototype.scale = function(c) {
+ return new m(this.r * c, this.g * c, this.b * c, this.a * c);
+ }, m.prototype.scaleToRef = function(c, T) {
+ return T.r = this.r * c, T.g = this.g * c, T.b = this.b * c, T.a = this.a * c, this;
+ }, m.prototype.scaleAndAddToRef = function(c, T) {
+ return T.r += this.r * c, T.g += this.g * c, T.b += this.b * c, T.a += this.a * c, this;
+ }, m.prototype.clampToRef = function(c, T, S) {
+ return c === void 0 && (c = 0), T === void 0 && (T = 1), S.r = V.a.Clamp(this.r, c, T), S.g = V.a.Clamp(this.g, c, T), S.b = V.a.Clamp(this.b, c, T), S.a = V.a.Clamp(this.a, c, T), this;
+ }, m.prototype.multiply = function(c) {
+ return new m(this.r * c.r, this.g * c.g, this.b * c.b, this.a * c.a);
+ }, m.prototype.multiplyToRef = function(c, T) {
+ return T.r = this.r * c.r, T.g = this.g * c.g, T.b = this.b * c.b, T.a = this.a * c.a, T;
+ }, m.prototype.toString = function() {
+ return "{R: " + this.r + " G:" + this.g + " B:" + this.b + " A:" + this.a + "}";
+ }, m.prototype.getClassName = function() {
+ return "Color4";
+ }, m.prototype.getHashCode = function() {
+ var c = 255 * this.r | 0;
+ return c = 397 * (c = 397 * (c = 397 * c ^ (255 * this.g | 0)) ^ (255 * this.b | 0)) ^ (255 * this.a | 0);
+ }, m.prototype.clone = function() {
+ return new m(this.r, this.g, this.b, this.a);
+ }, m.prototype.copyFrom = function(c) {
+ return this.r = c.r, this.g = c.g, this.b = c.b, this.a = c.a, this;
+ }, m.prototype.copyFromFloats = function(c, T, S, E) {
+ return this.r = c, this.g = T, this.b = S, this.a = E, this;
+ }, m.prototype.set = function(c, T, S, E) {
+ return this.copyFromFloats(c, T, S, E);
+ }, m.prototype.toHexString = function(c) {
+ c === void 0 && (c = !1);
+ var T = 255 * this.r | 0, S = 255 * this.g | 0, E = 255 * this.b | 0;
+ if (c)
+ return "#" + V.a.ToHex(T) + V.a.ToHex(S) + V.a.ToHex(E);
+ var g = 255 * this.a | 0;
+ return "#" + V.a.ToHex(T) + V.a.ToHex(S) + V.a.ToHex(E) + V.a.ToHex(g);
+ }, m.prototype.toLinearSpace = function() {
+ var c = new m();
+ return this.toLinearSpaceToRef(c), c;
+ }, m.prototype.toLinearSpaceToRef = function(c) {
+ return c.r = Math.pow(this.r, _.c), c.g = Math.pow(this.g, _.c), c.b = Math.pow(this.b, _.c), c.a = this.a, this;
+ }, m.prototype.toGammaSpace = function() {
+ var c = new m();
+ return this.toGammaSpaceToRef(c), c;
+ }, m.prototype.toGammaSpaceToRef = function(c) {
+ return c.r = Math.pow(this.r, _.b), c.g = Math.pow(this.g, _.b), c.b = Math.pow(this.b, _.b), c.a = this.a, this;
+ }, m.FromHexString = function(c) {
+ if (c.substring(0, 1) !== "#" || c.length !== 9)
+ return new m(0, 0, 0, 0);
+ var T = parseInt(c.substring(1, 3), 16), S = parseInt(c.substring(3, 5), 16), E = parseInt(c.substring(5, 7), 16), g = parseInt(c.substring(7, 9), 16);
+ return m.FromInts(T, S, E, g);
+ }, m.Lerp = function(c, T, S) {
+ var E = new m(0, 0, 0, 0);
+ return m.LerpToRef(c, T, S, E), E;
+ }, m.LerpToRef = function(c, T, S, E) {
+ E.r = c.r + (T.r - c.r) * S, E.g = c.g + (T.g - c.g) * S, E.b = c.b + (T.b - c.b) * S, E.a = c.a + (T.a - c.a) * S;
+ }, m.FromColor3 = function(c, T) {
+ return T === void 0 && (T = 1), new m(c.r, c.g, c.b, T);
+ }, m.FromArray = function(c, T) {
+ return T === void 0 && (T = 0), new m(c[T], c[T + 1], c[T + 2], c[T + 3]);
+ }, m.FromArrayToRef = function(c, T, S) {
+ T === void 0 && (T = 0), S.r = c[T], S.g = c[T + 1], S.b = c[T + 2], S.a = c[T + 3];
+ }, m.FromInts = function(c, T, S, E) {
+ return new m(c / 255, T / 255, S / 255, E / 255);
+ }, m.CheckColors4 = function(c, T) {
+ if (c.length === 3 * T) {
+ for (var S = [], E = 0; E < c.length; E += 3) {
+ var g = E / 3 * 4;
+ S[g] = c[E], S[g + 1] = c[E + 1], S[g + 2] = c[E + 2], S[g + 3] = 1;
+ }
+ return S;
+ }
+ return c;
+ }, m;
+ }(), x = function() {
+ function m() {
+ }
+ return m.Color3 = C.a.BuildArray(3, I.Black), m.Color4 = C.a.BuildArray(3, function() {
+ return new O(0, 0, 0, 0);
+ }), m;
+ }();
+ u.a.RegisteredTypes["BABYLON.Color3"] = I, u.a.RegisteredTypes["BABYLON.Color4"] = O;
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return l;
+ });
+ var V = f(1), _ = f(3), C = f(6), u = f(0), I = f(52), O = f(2), x = f(11), m = f(21), c = f(104), T = f(122), S = f(64), E = f(34), g = f(150), l = function(h) {
+ function v(b, D, w, N, M, U, X, j, ne, te, de, pe) {
+ w === void 0 && (w = !1), N === void 0 && (N = !0), M === void 0 && (M = v.TRILINEAR_SAMPLINGMODE), U === void 0 && (U = null), X === void 0 && (X = null), j === void 0 && (j = null), ne === void 0 && (ne = !1);
+ var ae = h.call(this, D) || this;
+ ae.url = null, ae.uOffset = 0, ae.vOffset = 0, ae.uScale = 1, ae.vScale = 1, ae.uAng = 0, ae.vAng = 0, ae.wAng = 0, ae.uRotationCenter = 0.5, ae.vRotationCenter = 0.5, ae.wRotationCenter = 0.5, ae.homogeneousRotationInUVTransform = !1, ae.inspectableCustomProperties = null, ae._noMipmap = !1, ae._invertY = !1, ae._rowGenerationMatrix = null, ae._cachedTextureMatrix = null, ae._projectionModeMatrix = null, ae._t0 = null, ae._t1 = null, ae._t2 = null, ae._cachedUOffset = -1, ae._cachedVOffset = -1, ae._cachedUScale = 0, ae._cachedVScale = 0, ae._cachedUAng = -1, ae._cachedVAng = -1, ae._cachedWAng = -1, ae._cachedProjectionMatrixId = -1, ae._cachedURotationCenter = -1, ae._cachedVRotationCenter = -1, ae._cachedWRotationCenter = -1, ae._cachedHomogeneousRotationInUVTransform = !1, ae._cachedCoordinatesMode = -1, ae._initialSamplingMode = v.BILINEAR_SAMPLINGMODE, ae._buffer = null, ae._deleteBuffer = !1, ae._format = null, ae._delayedOnLoad = null, ae._delayedOnError = null, ae.onLoadObservable = new C.c(), ae._isBlocking = !0, ae.name = b || "", ae.url = b, ae._noMipmap = w, ae._invertY = N, ae._initialSamplingMode = M, ae._buffer = j, ae._deleteBuffer = ne, ae._mimeType = de, ae._loaderOptions = pe, te && (ae._format = te);
+ var ee = ae.getScene(), K = ae._getEngine();
+ if (!K)
+ return ae;
+ K.onBeforeTextureInitObservable.notifyObservers(ae);
+ var $ = function() {
+ ae._texture && (ae._texture._invertVScale && (ae.vScale *= -1, ae.vOffset += 1), ae._texture._cachedWrapU !== null && (ae.wrapU = ae._texture._cachedWrapU, ae._texture._cachedWrapU = null), ae._texture._cachedWrapV !== null && (ae.wrapV = ae._texture._cachedWrapV, ae._texture._cachedWrapV = null), ae._texture._cachedWrapR !== null && (ae.wrapR = ae._texture._cachedWrapR, ae._texture._cachedWrapR = null)), ae.onLoadObservable.hasObservers() && ae.onLoadObservable.notifyObservers(ae), U && U(), !ae.isBlocking && ee && ee.resetCachedMaterial();
+ };
+ return ae.url ? (ae._texture = ae._getFromCache(ae.url, w, M, N), ae._texture ? ae._texture.isReady ? c.a.SetImmediate(function() {
+ return $();
+ }) : ae._texture.onLoadedObservable.add($) : ee && ee.useDelayedTextureLoading ? (ae.delayLoadState = O.a.DELAYLOADSTATE_NOTLOADED, ae._delayedOnLoad = $, ae._delayedOnError = X) : (ae._texture = K.createTexture(ae.url, w, N, ee, M, $, X, ae._buffer, void 0, ae._format, null, de, pe), ne && (ae._buffer = null)), ae) : (ae._delayedOnLoad = $, ae._delayedOnError = X, ae);
+ }
+ return Object(V.d)(v, h), Object.defineProperty(v.prototype, "noMipmap", { get: function() {
+ return this._noMipmap;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(v.prototype, "mimeType", { get: function() {
+ return this._mimeType;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(v.prototype, "isBlocking", { get: function() {
+ return this._isBlocking;
+ }, set: function(b) {
+ this._isBlocking = b;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(v.prototype, "samplingMode", { get: function() {
+ return this._texture ? this._texture.samplingMode : this._initialSamplingMode;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(v.prototype, "invertY", { get: function() {
+ return this._invertY;
+ }, enumerable: !1, configurable: !0 }), v.prototype.updateURL = function(b, D, w) {
+ D === void 0 && (D = null), this.url && (this.releaseInternalTexture(), this.getScene().markAllMaterialsAsDirty(O.a.MATERIAL_TextureDirtyFlag)), this.name && !E.a.StartsWith(this.name, "data:") || (this.name = b), this.url = b, this._buffer = D, this.delayLoadState = O.a.DELAYLOADSTATE_NOTLOADED, w && (this._delayedOnLoad = w), this.delayLoad();
+ }, v.prototype.delayLoad = function() {
+ if (this.delayLoadState === O.a.DELAYLOADSTATE_NOTLOADED) {
+ var b = this.getScene();
+ b && (this.delayLoadState = O.a.DELAYLOADSTATE_LOADED, this._texture = this._getFromCache(this.url, this._noMipmap, this.samplingMode, this._invertY), this._texture ? this._delayedOnLoad && (this._texture.isReady ? c.a.SetImmediate(this._delayedOnLoad) : this._texture.onLoadedObservable.add(this._delayedOnLoad)) : (this._texture = b.getEngine().createTexture(this.url, this._noMipmap, this._invertY, b, this.samplingMode, this._delayedOnLoad, this._delayedOnError, this._buffer, null, this._format, null, this._mimeType, this._loaderOptions), this._deleteBuffer && (this._buffer = null)), this._delayedOnLoad = null, this._delayedOnError = null);
+ }
+ }, v.prototype._prepareRowForTextureGeneration = function(b, D, w, N) {
+ b *= this._cachedUScale, D *= this._cachedVScale, b -= this.uRotationCenter * this._cachedUScale, D -= this.vRotationCenter * this._cachedVScale, w -= this.wRotationCenter, u.e.TransformCoordinatesFromFloatsToRef(b, D, w, this._rowGenerationMatrix, N), N.x += this.uRotationCenter * this._cachedUScale + this._cachedUOffset, N.y += this.vRotationCenter * this._cachedVScale + this._cachedVOffset, N.z += this.wRotationCenter;
+ }, v.prototype.checkTransformsAreIdentical = function(b) {
+ return b !== null && this.uOffset === b.uOffset && this.vOffset === b.vOffset && this.uScale === b.uScale && this.vScale === b.vScale && this.uAng === b.uAng && this.vAng === b.vAng && this.wAng === b.wAng;
+ }, v.prototype.getTextureMatrix = function(b) {
+ var D = this;
+ if (b === void 0 && (b = 1), this.uOffset === this._cachedUOffset && this.vOffset === this._cachedVOffset && this.uScale * b === this._cachedUScale && this.vScale === this._cachedVScale && this.uAng === this._cachedUAng && this.vAng === this._cachedVAng && this.wAng === this._cachedWAng && this.uRotationCenter === this._cachedURotationCenter && this.vRotationCenter === this._cachedVRotationCenter && this.wRotationCenter === this._cachedWRotationCenter && this.homogeneousRotationInUVTransform === this._cachedHomogeneousRotationInUVTransform)
+ return this._cachedTextureMatrix;
+ this._cachedUOffset = this.uOffset, this._cachedVOffset = this.vOffset, this._cachedUScale = this.uScale * b, this._cachedVScale = this.vScale, this._cachedUAng = this.uAng, this._cachedVAng = this.vAng, this._cachedWAng = this.wAng, this._cachedURotationCenter = this.uRotationCenter, this._cachedVRotationCenter = this.vRotationCenter, this._cachedWRotationCenter = this.wRotationCenter, this._cachedHomogeneousRotationInUVTransform = this.homogeneousRotationInUVTransform, this._cachedTextureMatrix && this._rowGenerationMatrix || (this._cachedTextureMatrix = u.a.Zero(), this._rowGenerationMatrix = new u.a(), this._t0 = u.e.Zero(), this._t1 = u.e.Zero(), this._t2 = u.e.Zero()), u.a.RotationYawPitchRollToRef(this.vAng, this.uAng, this.wAng, this._rowGenerationMatrix), this.homogeneousRotationInUVTransform ? (u.a.TranslationToRef(-this._cachedURotationCenter, -this._cachedVRotationCenter, -this._cachedWRotationCenter, u.c.Matrix[0]), u.a.TranslationToRef(this._cachedURotationCenter, this._cachedVRotationCenter, this._cachedWRotationCenter, u.c.Matrix[1]), u.a.ScalingToRef(this._cachedUScale, this._cachedVScale, 0, u.c.Matrix[2]), u.a.TranslationToRef(this._cachedUOffset, this._cachedVOffset, 0, u.c.Matrix[3]), u.c.Matrix[0].multiplyToRef(this._rowGenerationMatrix, this._cachedTextureMatrix), this._cachedTextureMatrix.multiplyToRef(u.c.Matrix[1], this._cachedTextureMatrix), this._cachedTextureMatrix.multiplyToRef(u.c.Matrix[2], this._cachedTextureMatrix), this._cachedTextureMatrix.multiplyToRef(u.c.Matrix[3], this._cachedTextureMatrix), this._cachedTextureMatrix.setRowFromFloats(2, this._cachedTextureMatrix.m[12], this._cachedTextureMatrix.m[13], this._cachedTextureMatrix.m[14], 1)) : (this._prepareRowForTextureGeneration(0, 0, 0, this._t0), this._prepareRowForTextureGeneration(1, 0, 0, this._t1), this._prepareRowForTextureGeneration(0, 1, 0, this._t2), this._t1.subtractInPlace(this._t0), this._t2.subtractInPlace(this._t0), u.a.FromValuesToRef(this._t1.x, this._t1.y, this._t1.z, 0, this._t2.x, this._t2.y, this._t2.z, 0, this._t0.x, this._t0.y, this._t0.z, 0, 0, 0, 0, 1, this._cachedTextureMatrix));
+ var w = this.getScene();
+ return w ? (w.markAllMaterialsAsDirty(O.a.MATERIAL_TextureDirtyFlag, function(N) {
+ return N.hasTexture(D);
+ }), this._cachedTextureMatrix) : this._cachedTextureMatrix;
+ }, v.prototype.getReflectionTextureMatrix = function() {
+ var b = this, D = this.getScene();
+ if (!D)
+ return this._cachedTextureMatrix;
+ if (this.uOffset === this._cachedUOffset && this.vOffset === this._cachedVOffset && this.uScale === this._cachedUScale && this.vScale === this._cachedVScale && this.coordinatesMode === this._cachedCoordinatesMode) {
+ if (this.coordinatesMode !== v.PROJECTION_MODE)
+ return this._cachedTextureMatrix;
+ if (this._cachedProjectionMatrixId === D.getProjectionMatrix().updateFlag)
+ return this._cachedTextureMatrix;
+ }
+ switch (this._cachedTextureMatrix || (this._cachedTextureMatrix = u.a.Zero()), this._projectionModeMatrix || (this._projectionModeMatrix = u.a.Zero()), this._cachedUOffset = this.uOffset, this._cachedVOffset = this.vOffset, this._cachedUScale = this.uScale, this._cachedVScale = this.vScale, this._cachedCoordinatesMode = this.coordinatesMode, this.coordinatesMode) {
+ case v.PLANAR_MODE:
+ u.a.IdentityToRef(this._cachedTextureMatrix), this._cachedTextureMatrix[0] = this.uScale, this._cachedTextureMatrix[5] = this.vScale, this._cachedTextureMatrix[12] = this.uOffset, this._cachedTextureMatrix[13] = this.vOffset;
+ break;
+ case v.PROJECTION_MODE:
+ u.a.FromValuesToRef(0.5, 0, 0, 0, 0, -0.5, 0, 0, 0, 0, 0, 0, 0.5, 0.5, 1, 1, this._projectionModeMatrix);
+ var w = D.getProjectionMatrix();
+ this._cachedProjectionMatrixId = w.updateFlag, w.multiplyToRef(this._projectionModeMatrix, this._cachedTextureMatrix);
+ break;
+ default:
+ u.a.IdentityToRef(this._cachedTextureMatrix);
+ }
+ return D.markAllMaterialsAsDirty(O.a.MATERIAL_TextureDirtyFlag, function(N) {
+ return N.getActiveTextures().indexOf(b) !== -1;
+ }), this._cachedTextureMatrix;
+ }, v.prototype.clone = function() {
+ var b = this;
+ return _.a.Clone(function() {
+ return new v(b._texture ? b._texture.url : null, b.getScene(), b._noMipmap, b._invertY, b.samplingMode, void 0, void 0, b._texture ? b._texture._buffer : void 0);
+ }, this);
+ }, v.prototype.serialize = function() {
+ var b = this.name;
+ v.SerializeBuffers || E.a.StartsWith(this.name, "data:") && (this.name = ""), E.a.StartsWith(this.name, "data:") && this.url === this.name && (this.url = "");
+ var D = h.prototype.serialize.call(this);
+ return D ? ((v.SerializeBuffers || v.ForceSerializeBuffers) && (typeof this._buffer == "string" && this._buffer.substr(0, 5) === "data:" ? (D.base64String = this._buffer, D.name = D.name.replace("data:", "")) : this.url && E.a.StartsWith(this.url, "data:") && this._buffer instanceof Uint8Array ? D.base64String = "data:image/png;base64," + E.a.EncodeArrayBufferToBase64(this._buffer) : v.ForceSerializeBuffers && (D.base64String = g.a.GenerateBase64StringFromTexture(this))), D.invertY = this._invertY, D.samplingMode = this.samplingMode, this.name = b, D) : null;
+ }, v.prototype.getClassName = function() {
+ return "Texture";
+ }, v.prototype.dispose = function() {
+ h.prototype.dispose.call(this), this.onLoadObservable.clear(), this._delayedOnLoad = null, this._delayedOnError = null;
+ }, v.Parse = function(b, D, w) {
+ if (b.customType) {
+ var N = T.a.Instantiate(b.customType).Parse(b, D, w);
+ return b.samplingMode && N.updateSamplingMode && N._samplingMode && N._samplingMode !== b.samplingMode && N.updateSamplingMode(b.samplingMode), N;
+ }
+ if (b.isCube && !b.isRenderTarget)
+ return v._CubeTextureParser(b, D, w);
+ if (!b.name && !b.isRenderTarget)
+ return null;
+ var M = function() {
+ if (U && U._texture && (U._texture._cachedWrapU = null, U._texture._cachedWrapV = null, U._texture._cachedWrapR = null), b.samplingMode) {
+ var X = b.samplingMode;
+ U && U.samplingMode !== X && U.updateSamplingMode(X);
+ }
+ if (U && b.animations)
+ for (var j = 0; j < b.animations.length; j++) {
+ var ne = b.animations[j], te = x.a.GetClass("BABYLON.Animation");
+ te && U.animations.push(te.Parse(ne));
+ }
+ }, U = _.a.Parse(function() {
+ var X, j = !0;
+ if (b.noMipmap && (j = !1), b.mirrorPlane) {
+ var ne = v._CreateMirror(b.name, b.renderTargetSize, D, j);
+ return ne._waitingRenderList = b.renderList, ne.mirrorPlane = S.a.FromArray(b.mirrorPlane), M(), ne;
+ }
+ if (b.isRenderTarget) {
+ var te = null;
+ if (b.isCube) {
+ if (D.reflectionProbes)
+ for (var de = 0; de < D.reflectionProbes.length; de++) {
+ var pe = D.reflectionProbes[de];
+ if (pe.name === b.name)
+ return pe.cubeTexture;
+ }
+ } else
+ (te = v._CreateRenderTargetTexture(b.name, b.renderTargetSize, D, j))._waitingRenderList = b.renderList;
+ return M(), te;
+ }
+ if (b.base64String)
+ X = v.CreateFromBase64String(b.base64String, b.name, D, !j, b.invertY, void 0, M);
+ else {
+ var ae = void 0;
+ ae = b.name && b.name.indexOf("://") > 0 ? b.name : w + b.name, (E.a.StartsWith(b.url, "data:") || v.UseSerializedUrlIfAny && b.url) && (ae = b.url), X = new v(ae, D, !j, b.invertY, void 0, M);
+ }
+ return X;
+ }, b, D);
+ return U;
+ }, v.CreateFromBase64String = function(b, D, w, N, M, U, X, j, ne) {
+ return U === void 0 && (U = v.TRILINEAR_SAMPLINGMODE), X === void 0 && (X = null), j === void 0 && (j = null), ne === void 0 && (ne = O.a.TEXTUREFORMAT_RGBA), new v("data:" + D, w, N, M, U, X, j, b, !1, ne);
+ }, v.LoadFromDataString = function(b, D, w, N, M, U, X, j, ne, te) {
+ return N === void 0 && (N = !1), M === void 0 && (M = !1), U === void 0 && (U = !0), X === void 0 && (X = v.TRILINEAR_SAMPLINGMODE), j === void 0 && (j = null), ne === void 0 && (ne = null), te === void 0 && (te = O.a.TEXTUREFORMAT_RGBA), b.substr(0, 5) !== "data:" && (b = "data:" + b), new v(b, w, M, U, X, j, ne, D, N, te);
+ }, v.SerializeBuffers = !0, v.ForceSerializeBuffers = !1, v._CubeTextureParser = function(b, D, w) {
+ throw m.a.WarnImport("CubeTexture");
+ }, v._CreateMirror = function(b, D, w, N) {
+ throw m.a.WarnImport("MirrorTexture");
+ }, v._CreateRenderTargetTexture = function(b, D, w, N) {
+ throw m.a.WarnImport("RenderTargetTexture");
+ }, v.NEAREST_SAMPLINGMODE = O.a.TEXTURE_NEAREST_SAMPLINGMODE, v.NEAREST_NEAREST_MIPLINEAR = O.a.TEXTURE_NEAREST_NEAREST_MIPLINEAR, v.BILINEAR_SAMPLINGMODE = O.a.TEXTURE_BILINEAR_SAMPLINGMODE, v.LINEAR_LINEAR_MIPNEAREST = O.a.TEXTURE_LINEAR_LINEAR_MIPNEAREST, v.TRILINEAR_SAMPLINGMODE = O.a.TEXTURE_TRILINEAR_SAMPLINGMODE, v.LINEAR_LINEAR_MIPLINEAR = O.a.TEXTURE_LINEAR_LINEAR_MIPLINEAR, v.NEAREST_NEAREST_MIPNEAREST = O.a.TEXTURE_NEAREST_NEAREST_MIPNEAREST, v.NEAREST_LINEAR_MIPNEAREST = O.a.TEXTURE_NEAREST_LINEAR_MIPNEAREST, v.NEAREST_LINEAR_MIPLINEAR = O.a.TEXTURE_NEAREST_LINEAR_MIPLINEAR, v.NEAREST_LINEAR = O.a.TEXTURE_NEAREST_LINEAR, v.NEAREST_NEAREST = O.a.TEXTURE_NEAREST_NEAREST, v.LINEAR_NEAREST_MIPNEAREST = O.a.TEXTURE_LINEAR_NEAREST_MIPNEAREST, v.LINEAR_NEAREST_MIPLINEAR = O.a.TEXTURE_LINEAR_NEAREST_MIPLINEAR, v.LINEAR_LINEAR = O.a.TEXTURE_LINEAR_LINEAR, v.LINEAR_NEAREST = O.a.TEXTURE_LINEAR_NEAREST, v.EXPLICIT_MODE = O.a.TEXTURE_EXPLICIT_MODE, v.SPHERICAL_MODE = O.a.TEXTURE_SPHERICAL_MODE, v.PLANAR_MODE = O.a.TEXTURE_PLANAR_MODE, v.CUBIC_MODE = O.a.TEXTURE_CUBIC_MODE, v.PROJECTION_MODE = O.a.TEXTURE_PROJECTION_MODE, v.SKYBOX_MODE = O.a.TEXTURE_SKYBOX_MODE, v.INVCUBIC_MODE = O.a.TEXTURE_INVCUBIC_MODE, v.EQUIRECTANGULAR_MODE = O.a.TEXTURE_EQUIRECTANGULAR_MODE, v.FIXED_EQUIRECTANGULAR_MODE = O.a.TEXTURE_FIXED_EQUIRECTANGULAR_MODE, v.FIXED_EQUIRECTANGULAR_MIRRORED_MODE = O.a.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE, v.CLAMP_ADDRESSMODE = O.a.TEXTURE_CLAMP_ADDRESSMODE, v.WRAP_ADDRESSMODE = O.a.TEXTURE_WRAP_ADDRESSMODE, v.MIRROR_ADDRESSMODE = O.a.TEXTURE_MIRROR_ADDRESSMODE, v.UseSerializedUrlIfAny = !1, Object(V.c)([Object(_.c)()], v.prototype, "url", void 0), Object(V.c)([Object(_.c)()], v.prototype, "uOffset", void 0), Object(V.c)([Object(_.c)()], v.prototype, "vOffset", void 0), Object(V.c)([Object(_.c)()], v.prototype, "uScale", void 0), Object(V.c)([Object(_.c)()], v.prototype, "vScale", void 0), Object(V.c)([Object(_.c)()], v.prototype, "uAng", void 0), Object(V.c)([Object(_.c)()], v.prototype, "vAng", void 0), Object(V.c)([Object(_.c)()], v.prototype, "wAng", void 0), Object(V.c)([Object(_.c)()], v.prototype, "uRotationCenter", void 0), Object(V.c)([Object(_.c)()], v.prototype, "vRotationCenter", void 0), Object(V.c)([Object(_.c)()], v.prototype, "wRotationCenter", void 0), Object(V.c)([Object(_.c)()], v.prototype, "homogeneousRotationInUVTransform", void 0), Object(V.c)([Object(_.c)()], v.prototype, "isBlocking", null), v;
+ }(I.a);
+ x.a.RegisteredTypes["BABYLON.Texture"] = l, _.a._TextureParser = l.Parse;
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return V;
+ });
+ var V = function() {
+ function _() {
+ }
+ return _.GetClass = function(C) {
+ return this.RegisteredTypes && this.RegisteredTypes[C] ? this.RegisteredTypes[C] : null;
+ }, _.RegisteredTypes = {}, _;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "b", function() {
+ return l;
+ }), f.d(A, "c", function() {
+ return h;
+ }), f.d(A, "a", function() {
+ return v;
+ });
+ var V = f(6), _ = f(38), C = f(8), u = f(41), I = f(57), O = f(21), x = f(49), m = f(22), c = f(56), T = f(145), S = f(104), E = f(122), g = f(120), l = function() {
+ function b() {
+ }
+ return Object.defineProperty(b, "BaseUrl", { get: function() {
+ return c.a.BaseUrl;
+ }, set: function(D) {
+ c.a.BaseUrl = D;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(b, "DefaultRetryStrategy", { get: function() {
+ return c.a.DefaultRetryStrategy;
+ }, set: function(D) {
+ c.a.DefaultRetryStrategy = D;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(b, "CorsBehavior", { get: function() {
+ return c.a.CorsBehavior;
+ }, set: function(D) {
+ c.a.CorsBehavior = D;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(b, "UseFallbackTexture", { get: function() {
+ return m.a.UseFallbackTexture;
+ }, set: function(D) {
+ m.a.UseFallbackTexture = D;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(b, "RegisteredExternalClasses", { get: function() {
+ return E.a.RegisteredExternalClasses;
+ }, set: function(D) {
+ E.a.RegisteredExternalClasses = D;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(b, "fallbackTexture", { get: function() {
+ return m.a.FallbackTexture;
+ }, set: function(D) {
+ m.a.FallbackTexture = D;
+ }, enumerable: !1, configurable: !0 }), b.FetchToRef = function(D, w, N, M, U, X) {
+ var j = 4 * ((Math.abs(D) * N % N | 0) + (Math.abs(w) * M % M | 0) * N);
+ X.r = U[j] / 255, X.g = U[j + 1] / 255, X.b = U[j + 2] / 255, X.a = U[j + 3] / 255;
+ }, b.Mix = function(D, w, N) {
+ return D * (1 - N) + w * N;
+ }, b.Instantiate = function(D) {
+ return E.a.Instantiate(D);
+ }, b.Slice = function(D, w, N) {
+ return D.slice ? D.slice(w, N) : Array.prototype.slice.call(D, w, N);
+ }, b.SliceToArray = function(D, w, N) {
+ return Array.isArray(D) ? D.slice(w, N) : Array.prototype.slice.call(D, w, N);
+ }, b.SetImmediate = function(D) {
+ S.a.SetImmediate(D);
+ }, b.IsExponentOfTwo = function(D) {
+ var w = 1;
+ do
+ w *= 2;
+ while (w < D);
+ return w === D;
+ }, b.FloatRound = function(D) {
+ return Math.fround ? Math.fround(D) : b._tmpFloatArray[0] = D;
+ }, b.GetFilename = function(D) {
+ var w = D.lastIndexOf("/");
+ return w < 0 ? D : D.substring(w + 1);
+ }, b.GetFolderPath = function(D, w) {
+ w === void 0 && (w = !1);
+ var N = D.lastIndexOf("/");
+ return N < 0 ? w ? D : "" : D.substring(0, N + 1);
+ }, b.ToDegrees = function(D) {
+ return 180 * D / Math.PI;
+ }, b.ToRadians = function(D) {
+ return D * Math.PI / 180;
+ }, b.MakeArray = function(D, w) {
+ return w === !0 || D !== void 0 && D != null ? Array.isArray(D) ? D : [D] : null;
+ }, b.GetPointerPrefix = function(D) {
+ var w = "pointer";
+ return _.a.IsWindowObjectExist() && !window.PointerEvent && _.a.IsNavigatorAvailable() && !navigator.pointerEnabled && (w = "mouse"), !D._badDesktopOS || D._badOS || document && "ontouchend" in document || (w = "mouse"), w;
+ }, b.SetCorsBehavior = function(D, w) {
+ c.a.SetCorsBehavior(D, w);
+ }, b.CleanUrl = function(D) {
+ return D = D.replace(/#/gm, "%23");
+ }, Object.defineProperty(b, "PreprocessUrl", { get: function() {
+ return c.a.PreprocessUrl;
+ }, set: function(D) {
+ c.a.PreprocessUrl = D;
+ }, enumerable: !1, configurable: !0 }), b.LoadImage = function(D, w, N, M, U) {
+ return c.a.LoadImage(D, w, N, M, U);
+ }, b.LoadFile = function(D, w, N, M, U, X) {
+ return c.a.LoadFile(D, w, N, M, U, X);
+ }, b.LoadFileAsync = function(D, w) {
+ return w === void 0 && (w = !0), new Promise(function(N, M) {
+ c.a.LoadFile(D, function(U) {
+ N(U);
+ }, void 0, void 0, w, function(U, X) {
+ M(X);
+ });
+ });
+ }, b.LoadScript = function(D, w, N, M) {
+ if (_.a.IsWindowObjectExist()) {
+ var U = document.getElementsByTagName("head")[0], X = document.createElement("script");
+ X.setAttribute("type", "text/javascript"), X.setAttribute("src", D), M && (X.id = M), X.onload = function() {
+ w && w();
+ }, X.onerror = function(j) {
+ N && N("Unable to load script '" + D + "'", j);
+ }, U.appendChild(X);
+ }
+ }, b.LoadScriptAsync = function(D, w) {
+ var N = this;
+ return new Promise(function(M, U) {
+ N.LoadScript(D, function() {
+ M();
+ }, function(X, j) {
+ U(j);
+ });
+ });
+ }, b.ReadFileAsDataURL = function(D, w, N) {
+ var M = new FileReader(), U = { onCompleteObservable: new V.c(), abort: function() {
+ return M.abort();
+ } };
+ return M.onloadend = function(X) {
+ U.onCompleteObservable.notifyObservers(U);
+ }, M.onload = function(X) {
+ w(X.target.result);
+ }, M.onprogress = N, M.readAsDataURL(D), U;
+ }, b.ReadFile = function(D, w, N, M, U) {
+ return c.a.ReadFile(D, w, N, M, U);
+ }, b.FileAsURL = function(D) {
+ var w = new Blob([D]);
+ return (window.URL || window.webkitURL).createObjectURL(w);
+ }, b.Format = function(D, w) {
+ return w === void 0 && (w = 2), D.toFixed(w);
+ }, b.DeepCopy = function(D, w, N, M) {
+ u.a.DeepCopy(D, w, N, M);
+ }, b.IsEmpty = function(D) {
+ for (var w in D)
+ if (D.hasOwnProperty(w))
+ return !1;
+ return !0;
+ }, b.RegisterTopRootEvents = function(D, w) {
+ for (var N = 0; N < w.length; N++) {
+ var M = w[N];
+ D.addEventListener(M.name, M.handler, !1);
+ try {
+ window.parent && window.parent.addEventListener(M.name, M.handler, !1);
+ } catch {
+ }
+ }
+ }, b.UnregisterTopRootEvents = function(D, w) {
+ for (var N = 0; N < w.length; N++) {
+ var M = w[N];
+ D.removeEventListener(M.name, M.handler);
+ try {
+ D.parent && D.parent.removeEventListener(M.name, M.handler);
+ } catch {
+ }
+ }
+ }, b.DumpFramebuffer = function(D, w, N, M, U, X) {
+ U === void 0 && (U = "image/png");
+ for (var j = 4 * D, ne = w / 2, te = N.readPixels(0, 0, D, w), de = 0; de < ne; de++)
+ for (var pe = 0; pe < j; pe++) {
+ var ae = pe + de * j, ee = pe + (w - de - 1) * j, K = te[ae];
+ te[ae] = te[ee], te[ee] = K;
+ }
+ b._ScreenshotCanvas || (b._ScreenshotCanvas = document.createElement("canvas")), b._ScreenshotCanvas.width = D, b._ScreenshotCanvas.height = w;
+ var $ = b._ScreenshotCanvas.getContext("2d");
+ if ($) {
+ var L = $.createImageData(D, w);
+ L.data.set(te), $.putImageData(L, 0, 0), b.EncodeScreenshotCanvasData(M, U, X);
+ }
+ }, b.ToBlob = function(D, w, N) {
+ N === void 0 && (N = "image/png"), D.toBlob || (D.toBlob = function(M, U, X) {
+ var j = this;
+ setTimeout(function() {
+ for (var ne = atob(j.toDataURL(U, X).split(",")[1]), te = ne.length, de = new Uint8Array(te), pe = 0; pe < te; pe++)
+ de[pe] = ne.charCodeAt(pe);
+ M(new Blob([de]));
+ });
+ }), D.toBlob(function(M) {
+ w(M);
+ }, N);
+ }, b.EncodeScreenshotCanvasData = function(D, w, N) {
+ w === void 0 && (w = "image/png"), D ? D(b._ScreenshotCanvas.toDataURL(w)) : this.ToBlob(b._ScreenshotCanvas, function(M) {
+ if ("download" in document.createElement("a")) {
+ if (!N) {
+ var U = /* @__PURE__ */ new Date(), X = (U.getFullYear() + "-" + (U.getMonth() + 1)).slice(2) + "-" + U.getDate() + "_" + U.getHours() + "-" + ("0" + U.getMinutes()).slice(-2);
+ N = "screenshot_" + X + ".png";
+ }
+ b.Download(M, N);
+ } else {
+ var j = URL.createObjectURL(M), ne = window.open("");
+ if (!ne)
+ return;
+ var te = ne.document.createElement("img");
+ te.onload = function() {
+ URL.revokeObjectURL(j);
+ }, te.src = j, ne.document.body.appendChild(te);
+ }
+ }, w);
+ }, b.Download = function(D, w) {
+ if (navigator && navigator.msSaveBlob)
+ navigator.msSaveBlob(D, w);
+ else {
+ var N = window.URL.createObjectURL(D), M = document.createElement("a");
+ document.body.appendChild(M), M.style.display = "none", M.href = N, M.download = w, M.addEventListener("click", function() {
+ M.parentElement && M.parentElement.removeChild(M);
+ }), M.click(), window.URL.revokeObjectURL(N);
+ }
+ }, b.BackCompatCameraNoPreventDefault = function(D) {
+ return typeof D[0] == "boolean" ? D[0] : typeof D[1] == "boolean" && D[1];
+ }, b.CreateScreenshot = function(D, w, N, M, U) {
+ throw O.a.WarnImport("ScreenshotTools");
+ }, b.CreateScreenshotAsync = function(D, w, N, M) {
+ throw O.a.WarnImport("ScreenshotTools");
+ }, b.CreateScreenshotUsingRenderTarget = function(D, w, N, M, U, X, j, ne) {
+ throw O.a.WarnImport("ScreenshotTools");
+ }, b.CreateScreenshotUsingRenderTargetAsync = function(D, w, N, M, U, X, j) {
+ throw O.a.WarnImport("ScreenshotTools");
+ }, b.RandomId = function() {
+ return g.a.RandomId();
+ }, b.IsBase64 = function(D) {
+ return !(D.length < 5) && D.substr(0, 5) === "data:";
+ }, b.DecodeBase64 = function(D) {
+ for (var w = atob(D.split(",")[1]), N = w.length, M = new Uint8Array(new ArrayBuffer(N)), U = 0; U < N; U++)
+ M[U] = w.charCodeAt(U);
+ return M.buffer;
+ }, b.GetAbsoluteUrl = function(D) {
+ var w = document.createElement("a");
+ return w.href = D, w.href;
+ }, Object.defineProperty(b, "errorsCount", { get: function() {
+ return C.a.errorsCount;
+ }, enumerable: !1, configurable: !0 }), b.Log = function(D) {
+ C.a.Log(D);
+ }, b.Warn = function(D) {
+ C.a.Warn(D);
+ }, b.Error = function(D) {
+ C.a.Error(D);
+ }, Object.defineProperty(b, "LogCache", { get: function() {
+ return C.a.LogCache;
+ }, enumerable: !1, configurable: !0 }), b.ClearLogCache = function() {
+ C.a.ClearLogCache();
+ }, Object.defineProperty(b, "LogLevels", { set: function(D) {
+ C.a.LogLevels = D;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(b, "PerformanceLogLevel", { set: function(D) {
+ return (D & b.PerformanceUserMarkLogLevel) === b.PerformanceUserMarkLogLevel ? (b.StartPerformanceCounter = b._StartUserMark, void (b.EndPerformanceCounter = b._EndUserMark)) : (D & b.PerformanceConsoleLogLevel) === b.PerformanceConsoleLogLevel ? (b.StartPerformanceCounter = b._StartPerformanceConsole, void (b.EndPerformanceCounter = b._EndPerformanceConsole)) : (b.StartPerformanceCounter = b._StartPerformanceCounterDisabled, void (b.EndPerformanceCounter = b._EndPerformanceCounterDisabled));
+ }, enumerable: !1, configurable: !0 }), b._StartPerformanceCounterDisabled = function(D, w) {
+ }, b._EndPerformanceCounterDisabled = function(D, w) {
+ }, b._StartUserMark = function(D, w) {
+ if (w === void 0 && (w = !0), !b._performance) {
+ if (!_.a.IsWindowObjectExist())
+ return;
+ b._performance = window.performance;
+ }
+ w && b._performance.mark && b._performance.mark(D + "-Begin");
+ }, b._EndUserMark = function(D, w) {
+ w === void 0 && (w = !0), w && b._performance.mark && (b._performance.mark(D + "-End"), b._performance.measure(D, D + "-Begin", D + "-End"));
+ }, b._StartPerformanceConsole = function(D, w) {
+ w === void 0 && (w = !0), w && (b._StartUserMark(D, w), console.time && console.time(D));
+ }, b._EndPerformanceConsole = function(D, w) {
+ w === void 0 && (w = !0), w && (b._EndUserMark(D, w), console.timeEnd(D));
+ }, Object.defineProperty(b, "Now", { get: function() {
+ return I.a.Now;
+ }, enumerable: !1, configurable: !0 }), b.GetClassName = function(D, w) {
+ w === void 0 && (w = !1);
+ var N = null;
+ return !w && D.getClassName ? N = D.getClassName() : (D instanceof Object && (N = (w ? D : Object.getPrototypeOf(D)).constructor.__bjsclassName__), N || (N = typeof D)), N;
+ }, b.First = function(D, w) {
+ for (var N = 0, M = D; N < M.length; N++) {
+ var U = M[N];
+ if (w(U))
+ return U;
+ }
+ return null;
+ }, b.getFullClassName = function(D, w) {
+ w === void 0 && (w = !1);
+ var N = null, M = null;
+ if (!w && D.getClassName)
+ N = D.getClassName();
+ else {
+ if (D instanceof Object) {
+ var U = w ? D : Object.getPrototypeOf(D);
+ N = U.constructor.__bjsclassName__, M = U.constructor.__bjsmoduleName__;
+ }
+ N || (N = typeof D);
+ }
+ return N ? (M != null ? M + "." : "") + N : null;
+ }, b.DelayAsync = function(D) {
+ return new Promise(function(w) {
+ setTimeout(function() {
+ w();
+ }, D);
+ });
+ }, b.IsSafari = function() {
+ return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
+ }, b.UseCustomRequestHeaders = !1, b.CustomRequestHeaders = x.a.CustomRequestHeaders, b._tmpFloatArray = new Float32Array(1), b.GetDOMTextContent = _.a.GetDOMTextContent, b.NoneLogLevel = C.a.NoneLogLevel, b.MessageLogLevel = C.a.MessageLogLevel, b.WarningLogLevel = C.a.WarningLogLevel, b.ErrorLogLevel = C.a.ErrorLogLevel, b.AllLogLevel = C.a.AllLogLevel, b.IsWindowObjectExist = _.a.IsWindowObjectExist, b.PerformanceNoneLogLevel = 0, b.PerformanceUserMarkLogLevel = 1, b.PerformanceConsoleLogLevel = 2, b.StartPerformanceCounter = b._StartPerformanceCounterDisabled, b.EndPerformanceCounter = b._EndPerformanceCounterDisabled, b;
+ }();
+ function h(b, D) {
+ return function(w) {
+ w.__bjsclassName__ = b, w.__bjsmoduleName__ = D ?? null;
+ };
+ }
+ var v = function() {
+ function b(D, w, N, M) {
+ M === void 0 && (M = 0), this.iterations = D, this.index = M - 1, this._done = !1, this._fn = w, this._successCallback = N;
+ }
+ return b.prototype.executeNext = function() {
+ this._done || (this.index + 1 < this.iterations ? (++this.index, this._fn(this)) : this.breakLoop());
+ }, b.prototype.breakLoop = function() {
+ this._done = !0, this._successCallback();
+ }, b.Run = function(D, w, N, M) {
+ M === void 0 && (M = 0);
+ var U = new b(D, w, N, M);
+ return U.executeNext(), U;
+ }, b.SyncAsyncForLoop = function(D, w, N, M, U, X) {
+ return X === void 0 && (X = 0), b.Run(Math.ceil(D / w), function(j) {
+ U && U() ? j.breakLoop() : setTimeout(function() {
+ for (var ne = 0; ne < w; ++ne) {
+ var te = j.index * w + ne;
+ if (te >= D)
+ break;
+ if (N(te), U && U()) {
+ j.breakLoop();
+ break;
+ }
+ }
+ j.executeNext();
+ }, X);
+ }, M);
+ }, b;
+ }();
+ m.a.FallbackTexture = "data:image/jpg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4QBmRXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUAAAABAAAARgEoAAMAAAABAAIAAAExAAIAAAAQAAAATgAAAAAAAABgAAAAAQAAAGAAAAABcGFpbnQubmV0IDQuMC41AP/bAEMABAIDAwMCBAMDAwQEBAQFCQYFBQUFCwgIBgkNCw0NDQsMDA4QFBEODxMPDAwSGBITFRYXFxcOERkbGRYaFBYXFv/bAEMBBAQEBQUFCgYGChYPDA8WFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFv/AABEIAQABAAMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/APH6KKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76P//Z", T.a.Apply();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return E;
+ });
+ var V = f(1), _ = f(6), C = f(38), u = f(22), I = f(21), O = f(26), x = f(2), m = f(146), c = f(55), T = f(88), S = f(8), E = (f(123), f(129), f(124), function(g) {
+ function l(h, v, b, D) {
+ D === void 0 && (D = !1);
+ var w = g.call(this, h, v, b, D) || this;
+ if (w.enableOfflineSupport = !1, w.disableManifestCheck = !1, w.scenes = new Array(), w.onNewSceneAddedObservable = new _.c(), w.postProcesses = new Array(), w.isPointerLock = !1, w.onResizeObservable = new _.c(), w.onCanvasBlurObservable = new _.c(), w.onCanvasFocusObservable = new _.c(), w.onCanvasPointerOutObservable = new _.c(), w.onBeginFrameObservable = new _.c(), w.customAnimationFrameRequester = null, w.onEndFrameObservable = new _.c(), w.onBeforeShaderCompilationObservable = new _.c(), w.onAfterShaderCompilationObservable = new _.c(), w._deterministicLockstep = !1, w._lockstepMaxSteps = 4, w._timeStep = 1 / 60, w._fps = 60, w._deltaTime = 0, w._drawCalls = new c.a(), w.canvasTabIndex = 1, w.disablePerformanceMonitorInBackground = !1, w._performanceMonitor = new m.a(), l.Instances.push(w), !h)
+ return w;
+ if (b = w._creationOptions, h.getContext) {
+ var N = h;
+ if (w._onCanvasFocus = function() {
+ w.onCanvasFocusObservable.notifyObservers(w);
+ }, w._onCanvasBlur = function() {
+ w.onCanvasBlurObservable.notifyObservers(w);
+ }, N.addEventListener("focus", w._onCanvasFocus), N.addEventListener("blur", w._onCanvasBlur), w._onBlur = function() {
+ w.disablePerformanceMonitorInBackground && w._performanceMonitor.disable(), w._windowIsBackground = !0;
+ }, w._onFocus = function() {
+ w.disablePerformanceMonitorInBackground && w._performanceMonitor.enable(), w._windowIsBackground = !1;
+ }, w._onCanvasPointerOut = function(X) {
+ w.onCanvasPointerOutObservable.notifyObservers(X);
+ }, N.addEventListener("pointerout", w._onCanvasPointerOut), C.a.IsWindowObjectExist()) {
+ var M = w.getHostWindow();
+ M.addEventListener("blur", w._onBlur), M.addEventListener("focus", w._onFocus);
+ var U = document;
+ w._onFullscreenChange = function() {
+ U.fullscreen !== void 0 ? w.isFullscreen = U.fullscreen : U.mozFullScreen !== void 0 ? w.isFullscreen = U.mozFullScreen : U.webkitIsFullScreen !== void 0 ? w.isFullscreen = U.webkitIsFullScreen : U.msIsFullScreen !== void 0 && (w.isFullscreen = U.msIsFullScreen), w.isFullscreen && w._pointerLockRequested && N && l._RequestPointerlock(N);
+ }, document.addEventListener("fullscreenchange", w._onFullscreenChange, !1), document.addEventListener("mozfullscreenchange", w._onFullscreenChange, !1), document.addEventListener("webkitfullscreenchange", w._onFullscreenChange, !1), document.addEventListener("msfullscreenchange", w._onFullscreenChange, !1), w._onPointerLockChange = function() {
+ w.isPointerLock = U.mozPointerLockElement === N || U.webkitPointerLockElement === N || U.msPointerLockElement === N || U.pointerLockElement === N;
+ }, document.addEventListener("pointerlockchange", w._onPointerLockChange, !1), document.addEventListener("mspointerlockchange", w._onPointerLockChange, !1), document.addEventListener("mozpointerlockchange", w._onPointerLockChange, !1), document.addEventListener("webkitpointerlockchange", w._onPointerLockChange, !1), !l.audioEngine && b.audioEngine && l.AudioEngineFactory && (l.audioEngine = l.AudioEngineFactory(w.getRenderingCanvas()));
+ }
+ w._connectVREvents(), w.enableOfflineSupport = l.OfflineProviderFactory !== void 0, b.doNotHandleTouchAction || w._disableTouchAction(), w._deterministicLockstep = !!b.deterministicLockstep, w._lockstepMaxSteps = b.lockstepMaxSteps || 0, w._timeStep = b.timeStep || 1 / 60;
+ }
+ return w._prepareVRComponent(), b.autoEnableWebVR && w.initWebVR(), w;
+ }
+ return Object(V.d)(l, g), Object.defineProperty(l, "NpmPackage", { get: function() {
+ return O.a.NpmPackage;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(l, "Version", { get: function() {
+ return O.a.Version;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(l, "Instances", { get: function() {
+ return u.a.Instances;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(l, "LastCreatedEngine", { get: function() {
+ return u.a.LastCreatedEngine;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(l, "LastCreatedScene", { get: function() {
+ return u.a.LastCreatedScene;
+ }, enumerable: !1, configurable: !0 }), l.MarkAllMaterialsAsDirty = function(h, v) {
+ for (var b = 0; b < l.Instances.length; b++)
+ for (var D = l.Instances[b], w = 0; w < D.scenes.length; w++)
+ D.scenes[w].markAllMaterialsAsDirty(h, v);
+ }, l.DefaultLoadingScreenFactory = function(h) {
+ throw I.a.WarnImport("LoadingScreen");
+ }, Object.defineProperty(l.prototype, "_supportsHardwareTextureRescaling", { get: function() {
+ return !!l._RescalePostProcessFactory;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(l.prototype, "performanceMonitor", { get: function() {
+ return this._performanceMonitor;
+ }, enumerable: !1, configurable: !0 }), l.prototype.getInputElement = function() {
+ return this._renderingCanvas;
+ }, l.prototype.getAspectRatio = function(h, v) {
+ v === void 0 && (v = !1);
+ var b = h.viewport;
+ return this.getRenderWidth(v) * b.width / (this.getRenderHeight(v) * b.height);
+ }, l.prototype.getScreenAspectRatio = function() {
+ return this.getRenderWidth(!0) / this.getRenderHeight(!0);
+ }, l.prototype.getRenderingCanvasClientRect = function() {
+ return this._renderingCanvas ? this._renderingCanvas.getBoundingClientRect() : null;
+ }, l.prototype.getInputElementClientRect = function() {
+ return this._renderingCanvas ? this.getInputElement().getBoundingClientRect() : null;
+ }, l.prototype.isDeterministicLockStep = function() {
+ return this._deterministicLockstep;
+ }, l.prototype.getLockstepMaxSteps = function() {
+ return this._lockstepMaxSteps;
+ }, l.prototype.getTimeStep = function() {
+ return 1e3 * this._timeStep;
+ }, l.prototype.generateMipMapsForCubemap = function(h, v) {
+ if (v === void 0 && (v = !0), h.generateMipMaps) {
+ var b = this._gl;
+ this._bindTextureDirectly(b.TEXTURE_CUBE_MAP, h, !0), b.generateMipmap(b.TEXTURE_CUBE_MAP), v && this._bindTextureDirectly(b.TEXTURE_CUBE_MAP, null);
+ }
+ }, l.prototype.setState = function(h, v, b, D) {
+ v === void 0 && (v = 0), D === void 0 && (D = !1), (this._depthCullingState.cull !== h || b) && (this._depthCullingState.cull = h);
+ var w = this.cullBackFaces ? this._gl.BACK : this._gl.FRONT;
+ (this._depthCullingState.cullFace !== w || b) && (this._depthCullingState.cullFace = w), this.setZOffset(v);
+ var N = D ? this._gl.CW : this._gl.CCW;
+ (this._depthCullingState.frontFace !== N || b) && (this._depthCullingState.frontFace = N);
+ }, l.prototype.setZOffset = function(h) {
+ this._depthCullingState.zOffset = h;
+ }, l.prototype.getZOffset = function() {
+ return this._depthCullingState.zOffset;
+ }, l.prototype.setDepthBuffer = function(h) {
+ this._depthCullingState.depthTest = h;
+ }, l.prototype.getDepthWrite = function() {
+ return this._depthCullingState.depthMask;
+ }, l.prototype.setDepthWrite = function(h) {
+ this._depthCullingState.depthMask = h;
+ }, l.prototype.getStencilBuffer = function() {
+ return this._stencilState.stencilTest;
+ }, l.prototype.setStencilBuffer = function(h) {
+ this._stencilState.stencilTest = h;
+ }, l.prototype.getStencilMask = function() {
+ return this._stencilState.stencilMask;
+ }, l.prototype.setStencilMask = function(h) {
+ this._stencilState.stencilMask = h;
+ }, l.prototype.getStencilFunction = function() {
+ return this._stencilState.stencilFunc;
+ }, l.prototype.getStencilFunctionReference = function() {
+ return this._stencilState.stencilFuncRef;
+ }, l.prototype.getStencilFunctionMask = function() {
+ return this._stencilState.stencilFuncMask;
+ }, l.prototype.setStencilFunction = function(h) {
+ this._stencilState.stencilFunc = h;
+ }, l.prototype.setStencilFunctionReference = function(h) {
+ this._stencilState.stencilFuncRef = h;
+ }, l.prototype.setStencilFunctionMask = function(h) {
+ this._stencilState.stencilFuncMask = h;
+ }, l.prototype.getStencilOperationFail = function() {
+ return this._stencilState.stencilOpStencilFail;
+ }, l.prototype.getStencilOperationDepthFail = function() {
+ return this._stencilState.stencilOpDepthFail;
+ }, l.prototype.getStencilOperationPass = function() {
+ return this._stencilState.stencilOpStencilDepthPass;
+ }, l.prototype.setStencilOperationFail = function(h) {
+ this._stencilState.stencilOpStencilFail = h;
+ }, l.prototype.setStencilOperationDepthFail = function(h) {
+ this._stencilState.stencilOpDepthFail = h;
+ }, l.prototype.setStencilOperationPass = function(h) {
+ this._stencilState.stencilOpStencilDepthPass = h;
+ }, l.prototype.setDitheringState = function(h) {
+ h ? this._gl.enable(this._gl.DITHER) : this._gl.disable(this._gl.DITHER);
+ }, l.prototype.setRasterizerState = function(h) {
+ h ? this._gl.disable(this._gl.RASTERIZER_DISCARD) : this._gl.enable(this._gl.RASTERIZER_DISCARD);
+ }, l.prototype.getDepthFunction = function() {
+ return this._depthCullingState.depthFunc;
+ }, l.prototype.setDepthFunction = function(h) {
+ this._depthCullingState.depthFunc = h;
+ }, l.prototype.setDepthFunctionToGreater = function() {
+ this._depthCullingState.depthFunc = this._gl.GREATER;
+ }, l.prototype.setDepthFunctionToGreaterOrEqual = function() {
+ this._depthCullingState.depthFunc = this._gl.GEQUAL;
+ }, l.prototype.setDepthFunctionToLess = function() {
+ this._depthCullingState.depthFunc = this._gl.LESS;
+ }, l.prototype.setDepthFunctionToLessOrEqual = function() {
+ this._depthCullingState.depthFunc = this._gl.LEQUAL;
+ }, l.prototype.cacheStencilState = function() {
+ this._cachedStencilBuffer = this.getStencilBuffer(), this._cachedStencilFunction = this.getStencilFunction(), this._cachedStencilMask = this.getStencilMask(), this._cachedStencilOperationPass = this.getStencilOperationPass(), this._cachedStencilOperationFail = this.getStencilOperationFail(), this._cachedStencilOperationDepthFail = this.getStencilOperationDepthFail(), this._cachedStencilReference = this.getStencilFunctionReference();
+ }, l.prototype.restoreStencilState = function() {
+ this.setStencilFunction(this._cachedStencilFunction), this.setStencilMask(this._cachedStencilMask), this.setStencilBuffer(this._cachedStencilBuffer), this.setStencilOperationPass(this._cachedStencilOperationPass), this.setStencilOperationFail(this._cachedStencilOperationFail), this.setStencilOperationDepthFail(this._cachedStencilOperationDepthFail), this.setStencilFunctionReference(this._cachedStencilReference);
+ }, l.prototype.setDirectViewport = function(h, v, b, D) {
+ var w = this._cachedViewport;
+ return this._cachedViewport = null, this._viewport(h, v, b, D), w;
+ }, l.prototype.scissorClear = function(h, v, b, D, w) {
+ this.enableScissor(h, v, b, D), this.clear(w, !0, !0, !0), this.disableScissor();
+ }, l.prototype.enableScissor = function(h, v, b, D) {
+ var w = this._gl;
+ w.enable(w.SCISSOR_TEST), w.scissor(h, v, b, D);
+ }, l.prototype.disableScissor = function() {
+ var h = this._gl;
+ h.disable(h.SCISSOR_TEST);
+ }, l.prototype._reportDrawCall = function() {
+ this._drawCalls.addCount(1, !1);
+ }, l.prototype.initWebVR = function() {
+ throw I.a.WarnImport("WebVRCamera");
+ }, l.prototype._prepareVRComponent = function() {
+ }, l.prototype._connectVREvents = function(h, v) {
+ }, l.prototype._submitVRFrame = function() {
+ }, l.prototype.disableVR = function() {
+ }, l.prototype.isVRPresenting = function() {
+ return !1;
+ }, l.prototype._requestVRFrame = function() {
+ }, l.prototype._loadFileAsync = function(h, v, b) {
+ var D = this;
+ return new Promise(function(w, N) {
+ D._loadFile(h, function(M) {
+ w(M);
+ }, void 0, v, b, function(M, U) {
+ N(U);
+ });
+ });
+ }, l.prototype.getVertexShaderSource = function(h) {
+ var v = this._gl.getAttachedShaders(h);
+ return v ? this._gl.getShaderSource(v[0]) : null;
+ }, l.prototype.getFragmentShaderSource = function(h) {
+ var v = this._gl.getAttachedShaders(h);
+ return v ? this._gl.getShaderSource(v[1]) : null;
+ }, l.prototype.setDepthStencilTexture = function(h, v, b) {
+ h !== void 0 && (v && (this._boundUniforms[h] = v), b && b.depthStencilTexture ? this._setTexture(h, b, !1, !0) : this._setTexture(h, null));
+ }, l.prototype.setTextureFromPostProcess = function(h, v) {
+ this._bindTexture(h, v ? v._textures.data[v._currentRenderTextureInd] : null);
+ }, l.prototype.setTextureFromPostProcessOutput = function(h, v) {
+ this._bindTexture(h, v ? v._outputTexture : null);
+ }, l.prototype._rebuildBuffers = function() {
+ for (var h = 0, v = this.scenes; h < v.length; h++) {
+ var b = v[h];
+ b.resetCachedMaterial(), b._rebuildGeometries(), b._rebuildTextures();
+ }
+ g.prototype._rebuildBuffers.call(this);
+ }, l.prototype._renderFrame = function() {
+ for (var h = 0; h < this._activeRenderLoops.length; h++)
+ (0, this._activeRenderLoops[h])();
+ }, l.prototype._renderLoop = function() {
+ if (!this._contextWasLost) {
+ var h = !0;
+ !this.renderEvenInBackground && this._windowIsBackground && (h = !1), h && (this.beginFrame(), this._renderViews() || this._renderFrame(), this.endFrame());
+ }
+ this._activeRenderLoops.length > 0 ? this.customAnimationFrameRequester ? (this.customAnimationFrameRequester.requestID = this._queueNewFrame(this.customAnimationFrameRequester.renderFunction || this._boundRenderFunction, this.customAnimationFrameRequester), this._frameHandler = this.customAnimationFrameRequester.requestID) : this.isVRPresenting() ? this._requestVRFrame() : this._frameHandler = this._queueNewFrame(this._boundRenderFunction, this.getHostWindow()) : this._renderingQueueLaunched = !1;
+ }, l.prototype._renderViews = function() {
+ return !1;
+ }, l.prototype.switchFullscreen = function(h) {
+ this.isFullscreen ? this.exitFullscreen() : this.enterFullscreen(h);
+ }, l.prototype.enterFullscreen = function(h) {
+ this.isFullscreen || (this._pointerLockRequested = h, this._renderingCanvas && l._RequestFullscreen(this._renderingCanvas));
+ }, l.prototype.exitFullscreen = function() {
+ this.isFullscreen && l._ExitFullscreen();
+ }, l.prototype.enterPointerlock = function() {
+ this._renderingCanvas && l._RequestPointerlock(this._renderingCanvas);
+ }, l.prototype.exitPointerlock = function() {
+ l._ExitPointerlock();
+ }, l.prototype.beginFrame = function() {
+ this._measureFps(), this.onBeginFrameObservable.notifyObservers(this), g.prototype.beginFrame.call(this);
+ }, l.prototype.endFrame = function() {
+ g.prototype.endFrame.call(this), this._submitVRFrame(), this.onEndFrameObservable.notifyObservers(this);
+ }, l.prototype.resize = function() {
+ this.isVRPresenting() || g.prototype.resize.call(this);
+ }, l.prototype.setSize = function(h, v) {
+ if (!this._renderingCanvas || !g.prototype.setSize.call(this, h, v))
+ return !1;
+ if (this.scenes) {
+ for (var b = 0; b < this.scenes.length; b++)
+ for (var D = this.scenes[b], w = 0; w < D.cameras.length; w++)
+ D.cameras[w]._currentRenderId = 0;
+ this.onResizeObservable.hasObservers() && this.onResizeObservable.notifyObservers(this);
+ }
+ return !0;
+ }, l.prototype._deletePipelineContext = function(h) {
+ var v = h;
+ v && v.program && v.transformFeedback && (this.deleteTransformFeedback(v.transformFeedback), v.transformFeedback = null), g.prototype._deletePipelineContext.call(this, h);
+ }, l.prototype.createShaderProgram = function(h, v, b, D, w, N) {
+ N === void 0 && (N = null), w = w || this._gl, this.onBeforeShaderCompilationObservable.notifyObservers(this);
+ var M = g.prototype.createShaderProgram.call(this, h, v, b, D, w, N);
+ return this.onAfterShaderCompilationObservable.notifyObservers(this), M;
+ }, l.prototype._createShaderProgram = function(h, v, b, D, w) {
+ w === void 0 && (w = null);
+ var N = D.createProgram();
+ if (h.program = N, !N)
+ throw new Error("Unable to create program");
+ if (D.attachShader(N, v), D.attachShader(N, b), this.webGLVersion > 1 && w) {
+ var M = this.createTransformFeedback();
+ this.bindTransformFeedback(M), this.setTranformFeedbackVaryings(N, w), h.transformFeedback = M;
+ }
+ return D.linkProgram(N), this.webGLVersion > 1 && w && this.bindTransformFeedback(null), h.context = D, h.vertexShader = v, h.fragmentShader = b, h.isParallelCompiled || this._finalizePipelineContext(h), N;
+ }, l.prototype._releaseTexture = function(h) {
+ g.prototype._releaseTexture.call(this, h), this.scenes.forEach(function(v) {
+ v.postProcesses.forEach(function(b) {
+ b._outputTexture == h && (b._outputTexture = null);
+ }), v.cameras.forEach(function(b) {
+ b._postProcesses.forEach(function(D) {
+ D && D._outputTexture == h && (D._outputTexture = null);
+ });
+ });
+ });
+ }, l.prototype._rescaleTexture = function(h, v, b, D, w) {
+ var N = this;
+ this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, this._gl.LINEAR), this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, this._gl.LINEAR), this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._gl.CLAMP_TO_EDGE), this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._gl.CLAMP_TO_EDGE);
+ var M = this.createRenderTargetTexture({ width: v.width, height: v.height }, { generateMipMaps: !1, type: x.a.TEXTURETYPE_UNSIGNED_INT, samplingMode: x.a.TEXTURE_BILINEAR_SAMPLINGMODE, generateDepthBuffer: !1, generateStencilBuffer: !1 });
+ !this._rescalePostProcess && l._RescalePostProcessFactory && (this._rescalePostProcess = l._RescalePostProcessFactory(this)), this._rescalePostProcess.getEffect().executeWhenCompiled(function() {
+ N._rescalePostProcess.onApply = function(X) {
+ X._bindTexture("textureSampler", h);
+ };
+ var U = b;
+ U || (U = N.scenes[N.scenes.length - 1]), U.postProcessManager.directRender([N._rescalePostProcess], M, !0), N._bindTextureDirectly(N._gl.TEXTURE_2D, v, !0), N._gl.copyTexImage2D(N._gl.TEXTURE_2D, 0, D, 0, 0, v.width, v.height, 0), N.unBindFramebuffer(M), N._releaseTexture(M), w && w();
+ });
+ }, l.prototype.getFps = function() {
+ return this._fps;
+ }, l.prototype.getDeltaTime = function() {
+ return this._deltaTime;
+ }, l.prototype._measureFps = function() {
+ this._performanceMonitor.sampleFrame(), this._fps = this._performanceMonitor.averageFPS, this._deltaTime = this._performanceMonitor.instantaneousFrameTime || 0;
+ }, l.prototype._uploadImageToTexture = function(h, v, b, D) {
+ b === void 0 && (b = 0), D === void 0 && (D = 0);
+ var w = this._gl, N = this._getWebGLTextureType(h.type), M = this._getInternalFormat(h.format), U = this._getRGBABufferInternalSizedFormat(h.type, M), X = h.isCube ? w.TEXTURE_CUBE_MAP : w.TEXTURE_2D;
+ this._bindTextureDirectly(X, h, !0), this._unpackFlipY(h.invertY);
+ var j = w.TEXTURE_2D;
+ h.isCube && (j = w.TEXTURE_CUBE_MAP_POSITIVE_X + b), w.texImage2D(j, D, U, M, N, v), this._bindTextureDirectly(X, null, !0);
+ }, l.prototype.updateRenderTargetTextureSampleCount = function(h, v) {
+ if (this.webGLVersion < 2 || !h)
+ return 1;
+ if (h.samples === v)
+ return v;
+ var b = this._gl;
+ if (v = Math.min(v, this.getCaps().maxMSAASamples), h._depthStencilBuffer && (b.deleteRenderbuffer(h._depthStencilBuffer), h._depthStencilBuffer = null), h._MSAAFramebuffer && (b.deleteFramebuffer(h._MSAAFramebuffer), h._MSAAFramebuffer = null), h._MSAARenderBuffer && (b.deleteRenderbuffer(h._MSAARenderBuffer), h._MSAARenderBuffer = null), v > 1 && b.renderbufferStorageMultisample) {
+ var D = b.createFramebuffer();
+ if (!D)
+ throw new Error("Unable to create multi sampled framebuffer");
+ h._MSAAFramebuffer = D, this._bindUnboundFramebuffer(h._MSAAFramebuffer);
+ var w = b.createRenderbuffer();
+ if (!w)
+ throw new Error("Unable to create multi sampled framebuffer");
+ b.bindRenderbuffer(b.RENDERBUFFER, w), b.renderbufferStorageMultisample(b.RENDERBUFFER, v, this._getRGBAMultiSampleBufferFormat(h.type), h.width, h.height), b.framebufferRenderbuffer(b.FRAMEBUFFER, b.COLOR_ATTACHMENT0, b.RENDERBUFFER, w), h._MSAARenderBuffer = w;
+ } else
+ this._bindUnboundFramebuffer(h._framebuffer);
+ return h.samples = v, h._depthStencilBuffer = this._setupFramebufferDepthAttachments(h._generateStencilBuffer, h._generateDepthBuffer, h.width, h.height, v), this._bindUnboundFramebuffer(null), v;
+ }, l.prototype.updateTextureComparisonFunction = function(h, v) {
+ if (this.webGLVersion !== 1) {
+ var b = this._gl;
+ h.isCube ? (this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, h, !0), v === 0 ? (b.texParameteri(b.TEXTURE_CUBE_MAP, b.TEXTURE_COMPARE_FUNC, x.a.LEQUAL), b.texParameteri(b.TEXTURE_CUBE_MAP, b.TEXTURE_COMPARE_MODE, b.NONE)) : (b.texParameteri(b.TEXTURE_CUBE_MAP, b.TEXTURE_COMPARE_FUNC, v), b.texParameteri(b.TEXTURE_CUBE_MAP, b.TEXTURE_COMPARE_MODE, b.COMPARE_REF_TO_TEXTURE)), this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null)) : (this._bindTextureDirectly(this._gl.TEXTURE_2D, h, !0), v === 0 ? (b.texParameteri(b.TEXTURE_2D, b.TEXTURE_COMPARE_FUNC, x.a.LEQUAL), b.texParameteri(b.TEXTURE_2D, b.TEXTURE_COMPARE_MODE, b.NONE)) : (b.texParameteri(b.TEXTURE_2D, b.TEXTURE_COMPARE_FUNC, v), b.texParameteri(b.TEXTURE_2D, b.TEXTURE_COMPARE_MODE, b.COMPARE_REF_TO_TEXTURE)), this._bindTextureDirectly(this._gl.TEXTURE_2D, null)), h._comparisonFunction = v;
+ } else
+ S.a.Error("WebGL 1 does not support texture comparison.");
+ }, l.prototype.createInstancesBuffer = function(h) {
+ var v = this._gl.createBuffer();
+ if (!v)
+ throw new Error("Unable to create instance buffer");
+ var b = new T.a(v);
+ return b.capacity = h, this.bindArrayBuffer(b), this._gl.bufferData(this._gl.ARRAY_BUFFER, h, this._gl.DYNAMIC_DRAW), b;
+ }, l.prototype.deleteInstancesBuffer = function(h) {
+ this._gl.deleteBuffer(h);
+ }, l.prototype._clientWaitAsync = function(h, v, b) {
+ v === void 0 && (v = 0), b === void 0 && (b = 10);
+ var D = this._gl;
+ return new Promise(function(w, N) {
+ var M = function() {
+ var U = D.clientWaitSync(h, v, 0);
+ U != D.WAIT_FAILED ? U != D.TIMEOUT_EXPIRED ? w() : setTimeout(M, b) : N();
+ };
+ M();
+ });
+ }, l.prototype._readPixelsAsync = function(h, v, b, D, w, N, M) {
+ if (this._webGLVersion < 2)
+ throw new Error("_readPixelsAsync only work on WebGL2+");
+ var U = this._gl, X = U.createBuffer();
+ U.bindBuffer(U.PIXEL_PACK_BUFFER, X), U.bufferData(U.PIXEL_PACK_BUFFER, M.byteLength, U.STREAM_READ), U.readPixels(h, v, b, D, w, N, 0), U.bindBuffer(U.PIXEL_PACK_BUFFER, null);
+ var j = U.fenceSync(U.SYNC_GPU_COMMANDS_COMPLETE, 0);
+ return j ? (U.flush(), this._clientWaitAsync(j, 0, 10).then(function() {
+ return U.deleteSync(j), U.bindBuffer(U.PIXEL_PACK_BUFFER, X), U.getBufferSubData(U.PIXEL_PACK_BUFFER, 0, M), U.bindBuffer(U.PIXEL_PACK_BUFFER, null), U.deleteBuffer(X), M;
+ })) : null;
+ }, l.prototype.dispose = function() {
+ for (this.hideLoadingUI(), this.onNewSceneAddedObservable.clear(); this.postProcesses.length; )
+ this.postProcesses[0].dispose();
+ for (this._rescalePostProcess && this._rescalePostProcess.dispose(); this.scenes.length; )
+ this.scenes[0].dispose();
+ l.Instances.length === 1 && l.audioEngine && l.audioEngine.dispose(), this.disableVR(), C.a.IsWindowObjectExist() && (window.removeEventListener("blur", this._onBlur), window.removeEventListener("focus", this._onFocus), this._renderingCanvas && (this._renderingCanvas.removeEventListener("focus", this._onCanvasFocus), this._renderingCanvas.removeEventListener("blur", this._onCanvasBlur), this._renderingCanvas.removeEventListener("pointerout", this._onCanvasPointerOut)), C.a.IsDocumentAvailable() && (document.removeEventListener("fullscreenchange", this._onFullscreenChange), document.removeEventListener("mozfullscreenchange", this._onFullscreenChange), document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange), document.removeEventListener("msfullscreenchange", this._onFullscreenChange), document.removeEventListener("pointerlockchange", this._onPointerLockChange), document.removeEventListener("mspointerlockchange", this._onPointerLockChange), document.removeEventListener("mozpointerlockchange", this._onPointerLockChange), document.removeEventListener("webkitpointerlockchange", this._onPointerLockChange))), g.prototype.dispose.call(this);
+ var h = l.Instances.indexOf(this);
+ h >= 0 && l.Instances.splice(h, 1), this.onResizeObservable.clear(), this.onCanvasBlurObservable.clear(), this.onCanvasFocusObservable.clear(), this.onCanvasPointerOutObservable.clear(), this.onBeginFrameObservable.clear(), this.onEndFrameObservable.clear();
+ }, l.prototype._disableTouchAction = function() {
+ this._renderingCanvas && this._renderingCanvas.setAttribute && (this._renderingCanvas.setAttribute("touch-action", "none"), this._renderingCanvas.style.touchAction = "none", this._renderingCanvas.style.msTouchAction = "none");
+ }, l.prototype.displayLoadingUI = function() {
+ if (C.a.IsWindowObjectExist()) {
+ var h = this.loadingScreen;
+ h && h.displayLoadingUI();
+ }
+ }, l.prototype.hideLoadingUI = function() {
+ if (C.a.IsWindowObjectExist()) {
+ var h = this._loadingScreen;
+ h && h.hideLoadingUI();
+ }
+ }, Object.defineProperty(l.prototype, "loadingScreen", { get: function() {
+ return !this._loadingScreen && this._renderingCanvas && (this._loadingScreen = l.DefaultLoadingScreenFactory(this._renderingCanvas)), this._loadingScreen;
+ }, set: function(h) {
+ this._loadingScreen = h;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(l.prototype, "loadingUIText", { set: function(h) {
+ this.loadingScreen.loadingUIText = h;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(l.prototype, "loadingUIBackgroundColor", { set: function(h) {
+ this.loadingScreen.loadingUIBackgroundColor = h;
+ }, enumerable: !1, configurable: !0 }), l._RequestPointerlock = function(h) {
+ h.requestPointerLock = h.requestPointerLock || h.msRequestPointerLock || h.mozRequestPointerLock || h.webkitRequestPointerLock, h.requestPointerLock && h.requestPointerLock();
+ }, l._ExitPointerlock = function() {
+ var h = document;
+ document.exitPointerLock = document.exitPointerLock || h.msExitPointerLock || h.mozExitPointerLock || h.webkitExitPointerLock, document.exitPointerLock && document.exitPointerLock();
+ }, l._RequestFullscreen = function(h) {
+ var v = h.requestFullscreen || h.msRequestFullscreen || h.webkitRequestFullscreen || h.mozRequestFullScreen;
+ v && v.call(h);
+ }, l._ExitFullscreen = function() {
+ var h = document;
+ document.exitFullscreen ? document.exitFullscreen() : h.mozCancelFullScreen ? h.mozCancelFullScreen() : h.webkitCancelFullScreen ? h.webkitCancelFullScreen() : h.msCancelFullScreen && h.msCancelFullScreen();
+ }, l.ALPHA_DISABLE = x.a.ALPHA_DISABLE, l.ALPHA_ADD = x.a.ALPHA_ADD, l.ALPHA_COMBINE = x.a.ALPHA_COMBINE, l.ALPHA_SUBTRACT = x.a.ALPHA_SUBTRACT, l.ALPHA_MULTIPLY = x.a.ALPHA_MULTIPLY, l.ALPHA_MAXIMIZED = x.a.ALPHA_MAXIMIZED, l.ALPHA_ONEONE = x.a.ALPHA_ONEONE, l.ALPHA_PREMULTIPLIED = x.a.ALPHA_PREMULTIPLIED, l.ALPHA_PREMULTIPLIED_PORTERDUFF = x.a.ALPHA_PREMULTIPLIED_PORTERDUFF, l.ALPHA_INTERPOLATE = x.a.ALPHA_INTERPOLATE, l.ALPHA_SCREENMODE = x.a.ALPHA_SCREENMODE, l.DELAYLOADSTATE_NONE = x.a.DELAYLOADSTATE_NONE, l.DELAYLOADSTATE_LOADED = x.a.DELAYLOADSTATE_LOADED, l.DELAYLOADSTATE_LOADING = x.a.DELAYLOADSTATE_LOADING, l.DELAYLOADSTATE_NOTLOADED = x.a.DELAYLOADSTATE_NOTLOADED, l.NEVER = x.a.NEVER, l.ALWAYS = x.a.ALWAYS, l.LESS = x.a.LESS, l.EQUAL = x.a.EQUAL, l.LEQUAL = x.a.LEQUAL, l.GREATER = x.a.GREATER, l.GEQUAL = x.a.GEQUAL, l.NOTEQUAL = x.a.NOTEQUAL, l.KEEP = x.a.KEEP, l.REPLACE = x.a.REPLACE, l.INCR = x.a.INCR, l.DECR = x.a.DECR, l.INVERT = x.a.INVERT, l.INCR_WRAP = x.a.INCR_WRAP, l.DECR_WRAP = x.a.DECR_WRAP, l.TEXTURE_CLAMP_ADDRESSMODE = x.a.TEXTURE_CLAMP_ADDRESSMODE, l.TEXTURE_WRAP_ADDRESSMODE = x.a.TEXTURE_WRAP_ADDRESSMODE, l.TEXTURE_MIRROR_ADDRESSMODE = x.a.TEXTURE_MIRROR_ADDRESSMODE, l.TEXTUREFORMAT_ALPHA = x.a.TEXTUREFORMAT_ALPHA, l.TEXTUREFORMAT_LUMINANCE = x.a.TEXTUREFORMAT_LUMINANCE, l.TEXTUREFORMAT_LUMINANCE_ALPHA = x.a.TEXTUREFORMAT_LUMINANCE_ALPHA, l.TEXTUREFORMAT_RGB = x.a.TEXTUREFORMAT_RGB, l.TEXTUREFORMAT_RGBA = x.a.TEXTUREFORMAT_RGBA, l.TEXTUREFORMAT_RED = x.a.TEXTUREFORMAT_RED, l.TEXTUREFORMAT_R = x.a.TEXTUREFORMAT_R, l.TEXTUREFORMAT_RG = x.a.TEXTUREFORMAT_RG, l.TEXTUREFORMAT_RED_INTEGER = x.a.TEXTUREFORMAT_RED_INTEGER, l.TEXTUREFORMAT_R_INTEGER = x.a.TEXTUREFORMAT_R_INTEGER, l.TEXTUREFORMAT_RG_INTEGER = x.a.TEXTUREFORMAT_RG_INTEGER, l.TEXTUREFORMAT_RGB_INTEGER = x.a.TEXTUREFORMAT_RGB_INTEGER, l.TEXTUREFORMAT_RGBA_INTEGER = x.a.TEXTUREFORMAT_RGBA_INTEGER, l.TEXTURETYPE_UNSIGNED_BYTE = x.a.TEXTURETYPE_UNSIGNED_BYTE, l.TEXTURETYPE_UNSIGNED_INT = x.a.TEXTURETYPE_UNSIGNED_INT, l.TEXTURETYPE_FLOAT = x.a.TEXTURETYPE_FLOAT, l.TEXTURETYPE_HALF_FLOAT = x.a.TEXTURETYPE_HALF_FLOAT, l.TEXTURETYPE_BYTE = x.a.TEXTURETYPE_BYTE, l.TEXTURETYPE_SHORT = x.a.TEXTURETYPE_SHORT, l.TEXTURETYPE_UNSIGNED_SHORT = x.a.TEXTURETYPE_UNSIGNED_SHORT, l.TEXTURETYPE_INT = x.a.TEXTURETYPE_INT, l.TEXTURETYPE_UNSIGNED_INTEGER = x.a.TEXTURETYPE_UNSIGNED_INTEGER, l.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = x.a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4, l.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = x.a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1, l.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = x.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5, l.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = x.a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV, l.TEXTURETYPE_UNSIGNED_INT_24_8 = x.a.TEXTURETYPE_UNSIGNED_INT_24_8, l.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = x.a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV, l.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = x.a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV, l.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = x.a.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV, l.TEXTURE_NEAREST_SAMPLINGMODE = x.a.TEXTURE_NEAREST_SAMPLINGMODE, l.TEXTURE_BILINEAR_SAMPLINGMODE = x.a.TEXTURE_BILINEAR_SAMPLINGMODE, l.TEXTURE_TRILINEAR_SAMPLINGMODE = x.a.TEXTURE_TRILINEAR_SAMPLINGMODE, l.TEXTURE_NEAREST_NEAREST_MIPLINEAR = x.a.TEXTURE_NEAREST_NEAREST_MIPLINEAR, l.TEXTURE_LINEAR_LINEAR_MIPNEAREST = x.a.TEXTURE_LINEAR_LINEAR_MIPNEAREST, l.TEXTURE_LINEAR_LINEAR_MIPLINEAR = x.a.TEXTURE_LINEAR_LINEAR_MIPLINEAR, l.TEXTURE_NEAREST_NEAREST_MIPNEAREST = x.a.TEXTURE_NEAREST_NEAREST_MIPNEAREST, l.TEXTURE_NEAREST_LINEAR_MIPNEAREST = x.a.TEXTURE_NEAREST_LINEAR_MIPNEAREST, l.TEXTURE_NEAREST_LINEAR_MIPLINEAR = x.a.TEXTURE_NEAREST_LINEAR_MIPLINEAR, l.TEXTURE_NEAREST_LINEAR = x.a.TEXTURE_NEAREST_LINEAR, l.TEXTURE_NEAREST_NEAREST = x.a.TEXTURE_NEAREST_NEAREST, l.TEXTURE_LINEAR_NEAREST_MIPNEAREST = x.a.TEXTURE_LINEAR_NEAREST_MIPNEAREST, l.TEXTURE_LINEAR_NEAREST_MIPLINEAR = x.a.TEXTURE_LINEAR_NEAREST_MIPLINEAR, l.TEXTURE_LINEAR_LINEAR = x.a.TEXTURE_LINEAR_LINEAR, l.TEXTURE_LINEAR_NEAREST = x.a.TEXTURE_LINEAR_NEAREST, l.TEXTURE_EXPLICIT_MODE = x.a.TEXTURE_EXPLICIT_MODE, l.TEXTURE_SPHERICAL_MODE = x.a.TEXTURE_SPHERICAL_MODE, l.TEXTURE_PLANAR_MODE = x.a.TEXTURE_PLANAR_MODE, l.TEXTURE_CUBIC_MODE = x.a.TEXTURE_CUBIC_MODE, l.TEXTURE_PROJECTION_MODE = x.a.TEXTURE_PROJECTION_MODE, l.TEXTURE_SKYBOX_MODE = x.a.TEXTURE_SKYBOX_MODE, l.TEXTURE_INVCUBIC_MODE = x.a.TEXTURE_INVCUBIC_MODE, l.TEXTURE_EQUIRECTANGULAR_MODE = x.a.TEXTURE_EQUIRECTANGULAR_MODE, l.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = x.a.TEXTURE_FIXED_EQUIRECTANGULAR_MODE, l.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = x.a.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE, l.SCALEMODE_FLOOR = x.a.SCALEMODE_FLOOR, l.SCALEMODE_NEAREST = x.a.SCALEMODE_NEAREST, l.SCALEMODE_CEILING = x.a.SCALEMODE_CEILING, l._RescalePostProcessFactory = null, l;
+ }(O.a));
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return V;
+ });
+ var V = function() {
+ function _() {
+ }
+ return _.WithinEpsilon = function(C, u, I) {
+ I === void 0 && (I = 1401298e-51);
+ var O = C - u;
+ return -I <= O && O <= I;
+ }, _.ToHex = function(C) {
+ var u = C.toString(16);
+ return C <= 15 ? ("0" + u).toUpperCase() : u.toUpperCase();
+ }, _.Sign = function(C) {
+ return (C = +C) == 0 || isNaN(C) ? C : C > 0 ? 1 : -1;
+ }, _.Clamp = function(C, u, I) {
+ return u === void 0 && (u = 0), I === void 0 && (I = 1), Math.min(I, Math.max(u, C));
+ }, _.Log2 = function(C) {
+ return Math.log(C) * Math.LOG2E;
+ }, _.Repeat = function(C, u) {
+ return C - Math.floor(C / u) * u;
+ }, _.Normalize = function(C, u, I) {
+ return (C - u) / (I - u);
+ }, _.Denormalize = function(C, u, I) {
+ return C * (I - u) + u;
+ }, _.DeltaAngle = function(C, u) {
+ var I = _.Repeat(u - C, 360);
+ return I > 180 && (I -= 360), I;
+ }, _.PingPong = function(C, u) {
+ var I = _.Repeat(C, 2 * u);
+ return u - Math.abs(I - u);
+ }, _.SmoothStep = function(C, u, I) {
+ var O = _.Clamp(I);
+ return u * (O = -2 * O * O * O + 3 * O * O) + C * (1 - O);
+ }, _.MoveTowards = function(C, u, I) {
+ return Math.abs(u - C) <= I ? u : C + _.Sign(u - C) * I;
+ }, _.MoveTowardsAngle = function(C, u, I) {
+ var O = _.DeltaAngle(C, u), x = 0;
+ return -I < O && O < I ? x = u : (u = C + O, x = _.MoveTowards(C, u, I)), x;
+ }, _.Lerp = function(C, u, I) {
+ return C + (u - C) * I;
+ }, _.LerpAngle = function(C, u, I) {
+ var O = _.Repeat(u - C, 360);
+ return O > 180 && (O -= 360), C + O * _.Clamp(I);
+ }, _.InverseLerp = function(C, u, I) {
+ return C != u ? _.Clamp((I - C) / (u - C)) : 0;
+ }, _.Hermite = function(C, u, I, O, x) {
+ var m = x * x, c = x * m;
+ return C * (2 * c - 3 * m + 1) + I * (-2 * c + 3 * m) + u * (c - 2 * m + x) + O * (c - m);
+ }, _.RandomRange = function(C, u) {
+ return C === u ? C : Math.random() * (u - C) + C;
+ }, _.RangeToPercent = function(C, u, I) {
+ return (C - u) / (I - u);
+ }, _.PercentToRange = function(C, u, I) {
+ return (I - u) * C + u;
+ }, _.NormalizeRadians = function(C) {
+ return C -= _.TwoPi * Math.floor((C + Math.PI) / _.TwoPi);
+ }, _.TwoPi = 2 * Math.PI, _;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return c;
+ });
+ var V = f(8), _ = f(20), C = f(22), u = f(4), I = f(48), O = f(2), x = f(9), m = f(119), c = function() {
+ function T() {
+ }
+ return T.BindEyePosition = function(S, E, g) {
+ if (g === void 0 && (g = "vEyePosition"), E._forcedViewPosition)
+ S.setVector3(g, E._forcedViewPosition);
+ else {
+ var l = E.activeCamera.globalPosition;
+ l || (l = E.activeCamera.devicePosition), S.setVector3(g, E._mirroredCameraPosition ? E._mirroredCameraPosition : l);
+ }
+ }, T.PrepareDefinesForMergedUV = function(S, E, g) {
+ E._needUVs = !0, E[g] = !0, S.getTextureMatrix().isIdentityAs3x2() ? (E[g + "DIRECTUV"] = S.coordinatesIndex + 1, S.coordinatesIndex === 0 ? E.MAINUV1 = !0 : E.MAINUV2 = !0) : E[g + "DIRECTUV"] = 0;
+ }, T.BindTextureMatrix = function(S, E, g) {
+ var l = S.getTextureMatrix();
+ E.updateMatrix(g + "Matrix", l);
+ }, T.GetFogState = function(S, E) {
+ return E.fogEnabled && S.applyFog && E.fogMode !== _.a.FOGMODE_NONE;
+ }, T.PrepareDefinesForMisc = function(S, E, g, l, h, v, b) {
+ b._areMiscDirty && (b.LOGARITHMICDEPTH = g, b.POINTSIZE = l, b.FOG = h && this.GetFogState(S, E), b.NONUNIFORMSCALING = S.nonUniformScaling, b.ALPHATEST = v);
+ }, T.PrepareDefinesForFrameBoundValues = function(S, E, g, l, h, v) {
+ h === void 0 && (h = null), v === void 0 && (v = !1);
+ var b, D, w, N, M, U, X = !1;
+ b = h ?? (S.clipPlane !== void 0 && S.clipPlane !== null), D = h ?? (S.clipPlane2 !== void 0 && S.clipPlane2 !== null), w = h ?? (S.clipPlane3 !== void 0 && S.clipPlane3 !== null), N = h ?? (S.clipPlane4 !== void 0 && S.clipPlane4 !== null), M = h ?? (S.clipPlane5 !== void 0 && S.clipPlane5 !== null), U = h ?? (S.clipPlane6 !== void 0 && S.clipPlane6 !== null), g.CLIPPLANE !== b && (g.CLIPPLANE = b, X = !0), g.CLIPPLANE2 !== D && (g.CLIPPLANE2 = D, X = !0), g.CLIPPLANE3 !== w && (g.CLIPPLANE3 = w, X = !0), g.CLIPPLANE4 !== N && (g.CLIPPLANE4 = N, X = !0), g.CLIPPLANE5 !== M && (g.CLIPPLANE5 = M, X = !0), g.CLIPPLANE6 !== U && (g.CLIPPLANE6 = U, X = !0), g.DEPTHPREPASS !== !E.getColorWrite() && (g.DEPTHPREPASS = !g.DEPTHPREPASS, X = !0), g.INSTANCES !== l && (g.INSTANCES = l, X = !0), g.THIN_INSTANCES !== v && (g.THIN_INSTANCES = v, X = !0), X && g.markAsUnprocessed();
+ }, T.PrepareDefinesForBones = function(S, E) {
+ if (S.useBones && S.computeBonesUsingShaders && S.skeleton) {
+ E.NUM_BONE_INFLUENCERS = S.numBoneInfluencers;
+ var g = E.BONETEXTURE !== void 0;
+ if (S.skeleton.isUsingTextureForMatrices && g)
+ E.BONETEXTURE = !0;
+ else {
+ E.BonesPerMesh = S.skeleton.bones.length + 1, E.BONETEXTURE = !g && void 0;
+ var l = S.getScene().prePassRenderer;
+ if (l && l.enabled) {
+ var h = l.excludedSkinnedMesh.indexOf(S) === -1;
+ E.BONES_VELOCITY_ENABLED = h;
+ }
+ }
+ } else
+ E.NUM_BONE_INFLUENCERS = 0, E.BonesPerMesh = 0;
+ }, T.PrepareDefinesForMorphTargets = function(S, E) {
+ var g = S.morphTargetManager;
+ g ? (E.MORPHTARGETS_UV = g.supportsUVs && E.UV1, E.MORPHTARGETS_TANGENT = g.supportsTangents && E.TANGENT, E.MORPHTARGETS_NORMAL = g.supportsNormals && E.NORMAL, E.MORPHTARGETS = g.numInfluencers > 0, E.NUM_MORPH_INFLUENCERS = g.numInfluencers) : (E.MORPHTARGETS_UV = !1, E.MORPHTARGETS_TANGENT = !1, E.MORPHTARGETS_NORMAL = !1, E.MORPHTARGETS = !1, E.NUM_MORPH_INFLUENCERS = 0);
+ }, T.PrepareDefinesForAttributes = function(S, E, g, l, h, v) {
+ if (h === void 0 && (h = !1), v === void 0 && (v = !0), !E._areAttributesDirty && E._needNormals === E._normals && E._needUVs === E._uvs)
+ return !1;
+ if (E._normals = E._needNormals, E._uvs = E._needUVs, E.NORMAL = E._needNormals && S.isVerticesDataPresent(u.b.NormalKind), E._needNormals && S.isVerticesDataPresent(u.b.TangentKind) && (E.TANGENT = !0), E._needUVs ? (E.UV1 = S.isVerticesDataPresent(u.b.UVKind), E.UV2 = S.isVerticesDataPresent(u.b.UV2Kind)) : (E.UV1 = !1, E.UV2 = !1), g) {
+ var b = S.useVertexColors && S.isVerticesDataPresent(u.b.ColorKind);
+ E.VERTEXCOLOR = b, E.VERTEXALPHA = S.hasVertexAlpha && b && v;
+ }
+ return l && this.PrepareDefinesForBones(S, E), h && this.PrepareDefinesForMorphTargets(S, E), !0;
+ }, T.PrepareDefinesForMultiview = function(S, E) {
+ if (S.activeCamera) {
+ var g = E.MULTIVIEW;
+ E.MULTIVIEW = S.activeCamera.outputRenderTarget !== null && S.activeCamera.outputRenderTarget.getViewCount() > 1, E.MULTIVIEW != g && E.markAsUnprocessed();
+ }
+ }, T.PrepareDefinesForPrePass = function(S, E, g) {
+ var l = E.PREPASS;
+ if (E._arePrePassDirty) {
+ var h = [{ type: O.a.PREPASS_POSITION_TEXTURE_TYPE, define: "PREPASS_POSITION", index: "PREPASS_POSITION_INDEX" }, { type: O.a.PREPASS_VELOCITY_TEXTURE_TYPE, define: "PREPASS_VELOCITY", index: "PREPASS_VELOCITY_INDEX" }, { type: O.a.PREPASS_REFLECTIVITY_TEXTURE_TYPE, define: "PREPASS_REFLECTIVITY", index: "PREPASS_REFLECTIVITY_INDEX" }, { type: O.a.PREPASS_IRRADIANCE_TEXTURE_TYPE, define: "PREPASS_IRRADIANCE", index: "PREPASS_IRRADIANCE_INDEX" }, { type: O.a.PREPASS_ALBEDO_TEXTURE_TYPE, define: "PREPASS_ALBEDO", index: "PREPASS_ALBEDO_INDEX" }, { type: O.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE, define: "PREPASS_DEPTHNORMAL", index: "PREPASS_DEPTHNORMAL_INDEX" }];
+ if (S.prePassRenderer && S.prePassRenderer.enabled && g) {
+ E.PREPASS = !0, E.SCENE_MRT_COUNT = S.prePassRenderer.mrtCount;
+ for (var v = 0; v < h.length; v++) {
+ var b = S.prePassRenderer.getIndex(h[v].type);
+ b !== -1 ? (E[h[v].define] = !0, E[h[v].index] = b) : E[h[v].define] = !1;
+ }
+ } else
+ for (E.PREPASS = !1, v = 0; v < h.length; v++)
+ E[h[v].define] = !1;
+ E.PREPASS != l && (E.markAsUnprocessed(), E.markAsImageProcessingDirty());
+ }
+ }, T.PrepareDefinesForLight = function(S, E, g, l, h, v, b) {
+ switch (b.needNormals = !0, h["LIGHT" + l] === void 0 && (b.needRebuild = !0), h["LIGHT" + l] = !0, h["SPOTLIGHT" + l] = !1, h["HEMILIGHT" + l] = !1, h["POINTLIGHT" + l] = !1, h["DIRLIGHT" + l] = !1, g.prepareLightSpecificDefines(h, l), h["LIGHT_FALLOFF_PHYSICAL" + l] = !1, h["LIGHT_FALLOFF_GLTF" + l] = !1, h["LIGHT_FALLOFF_STANDARD" + l] = !1, g.falloffType) {
+ case I.a.FALLOFF_GLTF:
+ h["LIGHT_FALLOFF_GLTF" + l] = !0;
+ break;
+ case I.a.FALLOFF_PHYSICAL:
+ h["LIGHT_FALLOFF_PHYSICAL" + l] = !0;
+ break;
+ case I.a.FALLOFF_STANDARD:
+ h["LIGHT_FALLOFF_STANDARD" + l] = !0;
+ }
+ if (v && !g.specular.equalsFloats(0, 0, 0) && (b.specularEnabled = !0), h["SHADOW" + l] = !1, h["SHADOWCSM" + l] = !1, h["SHADOWCSMDEBUG" + l] = !1, h["SHADOWCSMNUM_CASCADES" + l] = !1, h["SHADOWCSMUSESHADOWMAXZ" + l] = !1, h["SHADOWCSMNOBLEND" + l] = !1, h["SHADOWCSM_RIGHTHANDED" + l] = !1, h["SHADOWPCF" + l] = !1, h["SHADOWPCSS" + l] = !1, h["SHADOWPOISSON" + l] = !1, h["SHADOWESM" + l] = !1, h["SHADOWCLOSEESM" + l] = !1, h["SHADOWCUBE" + l] = !1, h["SHADOWLOWQUALITY" + l] = !1, h["SHADOWMEDIUMQUALITY" + l] = !1, E && E.receiveShadows && S.shadowsEnabled && g.shadowEnabled) {
+ var D = g.getShadowGenerator();
+ if (D) {
+ var w = D.getShadowMap();
+ w && w.renderList && w.renderList.length > 0 && (b.shadowEnabled = !0, D.prepareDefines(h, l));
+ }
+ }
+ g.lightmapMode != I.a.LIGHTMAP_DEFAULT ? (b.lightmapMode = !0, h["LIGHTMAPEXCLUDED" + l] = !0, h["LIGHTMAPNOSPECULAR" + l] = g.lightmapMode == I.a.LIGHTMAP_SHADOWSONLY) : (h["LIGHTMAPEXCLUDED" + l] = !1, h["LIGHTMAPNOSPECULAR" + l] = !1);
+ }, T.PrepareDefinesForLights = function(S, E, g, l, h, v) {
+ if (h === void 0 && (h = 4), v === void 0 && (v = !1), !g._areLightsDirty)
+ return g._needNormals;
+ var b = 0, D = { needNormals: !1, needRebuild: !1, lightmapMode: !1, shadowEnabled: !1, specularEnabled: !1 };
+ if (S.lightsEnabled && !v)
+ for (var w = 0, N = E.lightSources; w < N.length; w++) {
+ var M = N[w];
+ if (this.PrepareDefinesForLight(S, E, M, b, g, l, D), ++b === h)
+ break;
+ }
+ g.SPECULARTERM = D.specularEnabled, g.SHADOWS = D.shadowEnabled;
+ for (var U = b; U < h; U++)
+ g["LIGHT" + U] !== void 0 && (g["LIGHT" + U] = !1, g["HEMILIGHT" + U] = !1, g["POINTLIGHT" + U] = !1, g["DIRLIGHT" + U] = !1, g["SPOTLIGHT" + U] = !1, g["SHADOW" + U] = !1, g["SHADOWCSM" + U] = !1, g["SHADOWCSMDEBUG" + U] = !1, g["SHADOWCSMNUM_CASCADES" + U] = !1, g["SHADOWCSMUSESHADOWMAXZ" + U] = !1, g["SHADOWCSMNOBLEND" + U] = !1, g["SHADOWCSM_RIGHTHANDED" + U] = !1, g["SHADOWPCF" + U] = !1, g["SHADOWPCSS" + U] = !1, g["SHADOWPOISSON" + U] = !1, g["SHADOWESM" + U] = !1, g["SHADOWCLOSEESM" + U] = !1, g["SHADOWCUBE" + U] = !1, g["SHADOWLOWQUALITY" + U] = !1, g["SHADOWMEDIUMQUALITY" + U] = !1);
+ var X = S.getEngine().getCaps();
+ return g.SHADOWFLOAT === void 0 && (D.needRebuild = !0), g.SHADOWFLOAT = D.shadowEnabled && (X.textureFloatRender && X.textureFloatLinearFiltering || X.textureHalfFloatRender && X.textureHalfFloatLinearFiltering), g.LIGHTMAPEXCLUDED = D.lightmapMode, D.needRebuild && g.rebuild(), D.needNormals;
+ }, T.PrepareUniformsAndSamplersForLight = function(S, E, g, l, h, v) {
+ h === void 0 && (h = null), v === void 0 && (v = !1), h && h.push("Light" + S), v || (E.push("vLightData" + S, "vLightDiffuse" + S, "vLightSpecular" + S, "vLightDirection" + S, "vLightFalloff" + S, "vLightGround" + S, "lightMatrix" + S, "shadowsInfo" + S, "depthValues" + S), g.push("shadowSampler" + S), g.push("depthSampler" + S), E.push("viewFrustumZ" + S, "cascadeBlendFactor" + S, "lightSizeUVCorrection" + S, "depthCorrection" + S, "penumbraDarkness" + S, "frustumLengths" + S), l && (g.push("projectionLightSampler" + S), E.push("textureProjectionMatrix" + S)));
+ }, T.PrepareUniformsAndSamplersList = function(S, E, g, l) {
+ var h;
+ l === void 0 && (l = 4);
+ var v = null;
+ if (S.uniformsNames) {
+ var b = S;
+ h = b.uniformsNames, v = b.uniformBuffersNames, E = b.samplers, g = b.defines, l = b.maxSimultaneousLights || 0;
+ } else
+ h = S, E || (E = []);
+ for (var D = 0; D < l && g["LIGHT" + D]; D++)
+ this.PrepareUniformsAndSamplersForLight(D, h, E, g["PROJECTEDLIGHTTEXTURE" + D], v);
+ g.NUM_MORPH_INFLUENCERS && h.push("morphTargetInfluences");
+ }, T.HandleFallbacksForShadows = function(S, E, g, l) {
+ g === void 0 && (g = 4), l === void 0 && (l = 0);
+ for (var h = 0, v = 0; v < g && S["LIGHT" + v]; v++)
+ v > 0 && (h = l + v, E.addFallback(h, "LIGHT" + v)), S.SHADOWS || (S["SHADOW" + v] && E.addFallback(l, "SHADOW" + v), S["SHADOWPCF" + v] && E.addFallback(l, "SHADOWPCF" + v), S["SHADOWPCSS" + v] && E.addFallback(l, "SHADOWPCSS" + v), S["SHADOWPOISSON" + v] && E.addFallback(l, "SHADOWPOISSON" + v), S["SHADOWESM" + v] && E.addFallback(l, "SHADOWESM" + v), S["SHADOWCLOSEESM" + v] && E.addFallback(l, "SHADOWCLOSEESM" + v));
+ return h++;
+ }, T.PrepareAttributesForMorphTargetsInfluencers = function(S, E, g) {
+ this._TmpMorphInfluencers.NUM_MORPH_INFLUENCERS = g, this.PrepareAttributesForMorphTargets(S, E, this._TmpMorphInfluencers);
+ }, T.PrepareAttributesForMorphTargets = function(S, E, g) {
+ var l = g.NUM_MORPH_INFLUENCERS;
+ if (l > 0 && C.a.LastCreatedEngine)
+ for (var h = C.a.LastCreatedEngine.getCaps().maxVertexAttribs, v = E.morphTargetManager, b = v && v.supportsNormals && g.NORMAL, D = v && v.supportsTangents && g.TANGENT, w = v && v.supportsUVs && g.UV1, N = 0; N < l; N++)
+ S.push(u.b.PositionKind + N), b && S.push(u.b.NormalKind + N), D && S.push(u.b.TangentKind + N), w && S.push(u.b.UVKind + "_" + N), S.length > h && V.a.Error("Cannot add more vertex attributes for mesh " + E.name);
+ }, T.PrepareAttributesForBones = function(S, E, g, l) {
+ g.NUM_BONE_INFLUENCERS > 0 && (l.addCPUSkinningFallback(0, E), S.push(u.b.MatricesIndicesKind), S.push(u.b.MatricesWeightsKind), g.NUM_BONE_INFLUENCERS > 4 && (S.push(u.b.MatricesIndicesExtraKind), S.push(u.b.MatricesWeightsExtraKind)));
+ }, T.PrepareAttributesForInstances = function(S, E) {
+ (E.INSTANCES || E.THIN_INSTANCES) && this.PushAttributesForInstances(S);
+ }, T.PushAttributesForInstances = function(S) {
+ S.push("world0"), S.push("world1"), S.push("world2"), S.push("world3");
+ }, T.BindLightProperties = function(S, E, g) {
+ S.transferToEffect(E, g + "");
+ }, T.BindLight = function(S, E, g, l, h, v) {
+ v === void 0 && (v = !1), S._bindLight(E, g, l, h, v);
+ }, T.BindLights = function(S, E, g, l, h, v) {
+ h === void 0 && (h = 4), v === void 0 && (v = !1);
+ for (var b = Math.min(E.lightSources.length, h), D = 0; D < b; D++) {
+ var w = E.lightSources[D];
+ this.BindLight(w, D, S, g, typeof l == "boolean" ? l : l.SPECULARTERM, v);
+ }
+ }, T.BindFogParameters = function(S, E, g, l) {
+ l === void 0 && (l = !1), S.fogEnabled && E.applyFog && S.fogMode !== _.a.FOGMODE_NONE && (g.setFloat4("vFogInfos", S.fogMode, S.fogStart, S.fogEnd, S.fogDensity), l ? (S.fogColor.toLinearSpaceToRef(this._tempFogColor), g.setColor3("vFogColor", this._tempFogColor)) : g.setColor3("vFogColor", S.fogColor));
+ }, T.BindBonesParameters = function(S, E, g) {
+ if (E && S && (S.computeBonesUsingShaders && E._bonesComputationForcedToCPU && (S.computeBonesUsingShaders = !1), S.useBones && S.computeBonesUsingShaders && S.skeleton)) {
+ var l = S.skeleton;
+ if (l.isUsingTextureForMatrices && E.getUniformIndex("boneTextureWidth") > -1) {
+ var h = l.getTransformMatrixTexture(S);
+ E.setTexture("boneSampler", h), E.setFloat("boneTextureWidth", 4 * (l.bones.length + 1));
+ } else {
+ var v = l.getTransformMatrices(S);
+ v && (E.setMatrices("mBones", v), g && S.getScene().prePassRenderer && S.getScene().prePassRenderer.getIndex(O.a.PREPASS_VELOCITY_TEXTURE_TYPE) && (g.previousBones[S.uniqueId] && E.setMatrices("mPreviousBones", g.previousBones[S.uniqueId]), T._CopyBonesTransformationMatrices(v, g.previousBones[S.uniqueId])));
+ }
+ }
+ }, T._CopyBonesTransformationMatrices = function(S, E) {
+ return E.set(S), E;
+ }, T.BindMorphTargetParameters = function(S, E) {
+ var g = S.morphTargetManager;
+ S && g && E.setFloatArray("morphTargetInfluences", g.influences);
+ }, T.BindLogDepth = function(S, E, g) {
+ S.LOGARITHMICDEPTH && E.setFloat("logarithmicDepthConstant", 2 / (Math.log(g.activeCamera.maxZ + 1) / Math.LN2));
+ }, T.BindClipPlane = function(S, E) {
+ m.a.BindClipPlane(S, E);
+ }, T._TmpMorphInfluencers = { NUM_MORPH_INFLUENCERS: 0 }, T._tempFogColor = x.a.Black(), T;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return O;
+ });
+ var V = f(0), _ = f(4), C = f(21), u = f(9), I = f(8), O = function() {
+ function x() {
+ }
+ return x.prototype.set = function(m, c) {
+ switch (m.length || I.a.Warn("Setting vertex data kind '" + c + "' with an empty array"), c) {
+ case _.b.PositionKind:
+ this.positions = m;
+ break;
+ case _.b.NormalKind:
+ this.normals = m;
+ break;
+ case _.b.TangentKind:
+ this.tangents = m;
+ break;
+ case _.b.UVKind:
+ this.uvs = m;
+ break;
+ case _.b.UV2Kind:
+ this.uvs2 = m;
+ break;
+ case _.b.UV3Kind:
+ this.uvs3 = m;
+ break;
+ case _.b.UV4Kind:
+ this.uvs4 = m;
+ break;
+ case _.b.UV5Kind:
+ this.uvs5 = m;
+ break;
+ case _.b.UV6Kind:
+ this.uvs6 = m;
+ break;
+ case _.b.ColorKind:
+ this.colors = m;
+ break;
+ case _.b.MatricesIndicesKind:
+ this.matricesIndices = m;
+ break;
+ case _.b.MatricesWeightsKind:
+ this.matricesWeights = m;
+ break;
+ case _.b.MatricesIndicesExtraKind:
+ this.matricesIndicesExtra = m;
+ break;
+ case _.b.MatricesWeightsExtraKind:
+ this.matricesWeightsExtra = m;
+ }
+ }, x.prototype.applyToMesh = function(m, c) {
+ return this._applyTo(m, c), this;
+ }, x.prototype.applyToGeometry = function(m, c) {
+ return this._applyTo(m, c), this;
+ }, x.prototype.updateMesh = function(m) {
+ return this._update(m), this;
+ }, x.prototype.updateGeometry = function(m) {
+ return this._update(m), this;
+ }, x.prototype._applyTo = function(m, c) {
+ return c === void 0 && (c = !1), this.positions && m.setVerticesData(_.b.PositionKind, this.positions, c), this.normals && m.setVerticesData(_.b.NormalKind, this.normals, c), this.tangents && m.setVerticesData(_.b.TangentKind, this.tangents, c), this.uvs && m.setVerticesData(_.b.UVKind, this.uvs, c), this.uvs2 && m.setVerticesData(_.b.UV2Kind, this.uvs2, c), this.uvs3 && m.setVerticesData(_.b.UV3Kind, this.uvs3, c), this.uvs4 && m.setVerticesData(_.b.UV4Kind, this.uvs4, c), this.uvs5 && m.setVerticesData(_.b.UV5Kind, this.uvs5, c), this.uvs6 && m.setVerticesData(_.b.UV6Kind, this.uvs6, c), this.colors && m.setVerticesData(_.b.ColorKind, this.colors, c), this.matricesIndices && m.setVerticesData(_.b.MatricesIndicesKind, this.matricesIndices, c), this.matricesWeights && m.setVerticesData(_.b.MatricesWeightsKind, this.matricesWeights, c), this.matricesIndicesExtra && m.setVerticesData(_.b.MatricesIndicesExtraKind, this.matricesIndicesExtra, c), this.matricesWeightsExtra && m.setVerticesData(_.b.MatricesWeightsExtraKind, this.matricesWeightsExtra, c), this.indices ? m.setIndices(this.indices, null, c) : m.setIndices([], null), this;
+ }, x.prototype._update = function(m, c, T) {
+ return this.positions && m.updateVerticesData(_.b.PositionKind, this.positions, c, T), this.normals && m.updateVerticesData(_.b.NormalKind, this.normals, c, T), this.tangents && m.updateVerticesData(_.b.TangentKind, this.tangents, c, T), this.uvs && m.updateVerticesData(_.b.UVKind, this.uvs, c, T), this.uvs2 && m.updateVerticesData(_.b.UV2Kind, this.uvs2, c, T), this.uvs3 && m.updateVerticesData(_.b.UV3Kind, this.uvs3, c, T), this.uvs4 && m.updateVerticesData(_.b.UV4Kind, this.uvs4, c, T), this.uvs5 && m.updateVerticesData(_.b.UV5Kind, this.uvs5, c, T), this.uvs6 && m.updateVerticesData(_.b.UV6Kind, this.uvs6, c, T), this.colors && m.updateVerticesData(_.b.ColorKind, this.colors, c, T), this.matricesIndices && m.updateVerticesData(_.b.MatricesIndicesKind, this.matricesIndices, c, T), this.matricesWeights && m.updateVerticesData(_.b.MatricesWeightsKind, this.matricesWeights, c, T), this.matricesIndicesExtra && m.updateVerticesData(_.b.MatricesIndicesExtraKind, this.matricesIndicesExtra, c, T), this.matricesWeightsExtra && m.updateVerticesData(_.b.MatricesWeightsExtraKind, this.matricesWeightsExtra, c, T), this.indices && m.setIndices(this.indices, null), this;
+ }, x.prototype.transform = function(m) {
+ var c, T = m.determinant() < 0, S = V.e.Zero();
+ if (this.positions) {
+ var E = V.e.Zero();
+ for (c = 0; c < this.positions.length; c += 3)
+ V.e.FromArrayToRef(this.positions, c, E), V.e.TransformCoordinatesToRef(E, m, S), this.positions[c] = S.x, this.positions[c + 1] = S.y, this.positions[c + 2] = S.z;
+ }
+ if (this.normals) {
+ var g = V.e.Zero();
+ for (c = 0; c < this.normals.length; c += 3)
+ V.e.FromArrayToRef(this.normals, c, g), V.e.TransformNormalToRef(g, m, S), this.normals[c] = S.x, this.normals[c + 1] = S.y, this.normals[c + 2] = S.z;
+ }
+ if (this.tangents) {
+ var l = V.f.Zero(), h = V.f.Zero();
+ for (c = 0; c < this.tangents.length; c += 4)
+ V.f.FromArrayToRef(this.tangents, c, l), V.f.TransformNormalToRef(l, m, h), this.tangents[c] = h.x, this.tangents[c + 1] = h.y, this.tangents[c + 2] = h.z, this.tangents[c + 3] = h.w;
+ }
+ if (T && this.indices)
+ for (c = 0; c < this.indices.length; c += 3) {
+ var v = this.indices[c + 1];
+ this.indices[c + 1] = this.indices[c + 2], this.indices[c + 2] = v;
+ }
+ return this;
+ }, x.prototype.merge = function(m, c) {
+ if (c === void 0 && (c = !1), this._validate(), m._validate(), !this.normals != !m.normals || !this.tangents != !m.tangents || !this.uvs != !m.uvs || !this.uvs2 != !m.uvs2 || !this.uvs3 != !m.uvs3 || !this.uvs4 != !m.uvs4 || !this.uvs5 != !m.uvs5 || !this.uvs6 != !m.uvs6 || !this.colors != !m.colors || !this.matricesIndices != !m.matricesIndices || !this.matricesWeights != !m.matricesWeights || !this.matricesIndicesExtra != !m.matricesIndicesExtra || !this.matricesWeightsExtra != !m.matricesWeightsExtra)
+ throw new Error("Cannot merge vertex data that do not have the same set of attributes");
+ if (m.indices) {
+ this.indices || (this.indices = []);
+ var T = this.positions ? this.positions.length / 3 : 0;
+ if (this.indices.BYTES_PER_ELEMENT !== void 0) {
+ var S = this.indices.length + m.indices.length, E = c || this.indices instanceof Uint32Array ? new Uint32Array(S) : new Uint16Array(S);
+ E.set(this.indices);
+ for (var g = this.indices.length, l = 0; l < m.indices.length; l++)
+ E[g + l] = m.indices[l] + T;
+ this.indices = E;
+ } else
+ for (l = 0; l < m.indices.length; l++)
+ this.indices.push(m.indices[l] + T);
+ }
+ return this.positions = this._mergeElement(this.positions, m.positions), this.normals = this._mergeElement(this.normals, m.normals), this.tangents = this._mergeElement(this.tangents, m.tangents), this.uvs = this._mergeElement(this.uvs, m.uvs), this.uvs2 = this._mergeElement(this.uvs2, m.uvs2), this.uvs3 = this._mergeElement(this.uvs3, m.uvs3), this.uvs4 = this._mergeElement(this.uvs4, m.uvs4), this.uvs5 = this._mergeElement(this.uvs5, m.uvs5), this.uvs6 = this._mergeElement(this.uvs6, m.uvs6), this.colors = this._mergeElement(this.colors, m.colors), this.matricesIndices = this._mergeElement(this.matricesIndices, m.matricesIndices), this.matricesWeights = this._mergeElement(this.matricesWeights, m.matricesWeights), this.matricesIndicesExtra = this._mergeElement(this.matricesIndicesExtra, m.matricesIndicesExtra), this.matricesWeightsExtra = this._mergeElement(this.matricesWeightsExtra, m.matricesWeightsExtra), this;
+ }, x.prototype._mergeElement = function(m, c) {
+ if (!m)
+ return c;
+ if (!c)
+ return m;
+ var T = c.length + m.length, S = m instanceof Float32Array, E = c instanceof Float32Array;
+ if (S) {
+ var g = new Float32Array(T);
+ return g.set(m), g.set(c, m.length), g;
+ }
+ if (E) {
+ var l = m.slice(0), h = 0;
+ for (T = c.length; h < T; h++)
+ l.push(c[h]);
+ return l;
+ }
+ return m.concat(c);
+ }, x.prototype._validate = function() {
+ if (!this.positions)
+ throw new Error("Positions are required");
+ var m = function(S, E) {
+ var g = _.b.DeduceStride(S);
+ if (E.length % g != 0)
+ throw new Error("The " + S + "s array count must be a multiple of " + g);
+ return E.length / g;
+ }, c = m(_.b.PositionKind, this.positions), T = function(S, E) {
+ var g = m(S, E);
+ if (g !== c)
+ throw new Error("The " + S + "s element count (" + g + ") does not match the positions count (" + c + ")");
+ };
+ this.normals && T(_.b.NormalKind, this.normals), this.tangents && T(_.b.TangentKind, this.tangents), this.uvs && T(_.b.UVKind, this.uvs), this.uvs2 && T(_.b.UV2Kind, this.uvs2), this.uvs3 && T(_.b.UV3Kind, this.uvs3), this.uvs4 && T(_.b.UV4Kind, this.uvs4), this.uvs5 && T(_.b.UV5Kind, this.uvs5), this.uvs6 && T(_.b.UV6Kind, this.uvs6), this.colors && T(_.b.ColorKind, this.colors), this.matricesIndices && T(_.b.MatricesIndicesKind, this.matricesIndices), this.matricesWeights && T(_.b.MatricesWeightsKind, this.matricesWeights), this.matricesIndicesExtra && T(_.b.MatricesIndicesExtraKind, this.matricesIndicesExtra), this.matricesWeightsExtra && T(_.b.MatricesWeightsExtraKind, this.matricesWeightsExtra);
+ }, x.prototype.serialize = function() {
+ var m = this.serialize();
+ return this.positions && (m.positions = this.positions), this.normals && (m.normals = this.normals), this.tangents && (m.tangents = this.tangents), this.uvs && (m.uvs = this.uvs), this.uvs2 && (m.uvs2 = this.uvs2), this.uvs3 && (m.uvs3 = this.uvs3), this.uvs4 && (m.uvs4 = this.uvs4), this.uvs5 && (m.uvs5 = this.uvs5), this.uvs6 && (m.uvs6 = this.uvs6), this.colors && (m.colors = this.colors), this.matricesIndices && (m.matricesIndices = this.matricesIndices, m.matricesIndices._isExpanded = !0), this.matricesWeights && (m.matricesWeights = this.matricesWeights), this.matricesIndicesExtra && (m.matricesIndicesExtra = this.matricesIndicesExtra, m.matricesIndicesExtra._isExpanded = !0), this.matricesWeightsExtra && (m.matricesWeightsExtra = this.matricesWeightsExtra), m.indices = this.indices, m;
+ }, x.ExtractFromMesh = function(m, c, T) {
+ return x._ExtractFrom(m, c, T);
+ }, x.ExtractFromGeometry = function(m, c, T) {
+ return x._ExtractFrom(m, c, T);
+ }, x._ExtractFrom = function(m, c, T) {
+ var S = new x();
+ return m.isVerticesDataPresent(_.b.PositionKind) && (S.positions = m.getVerticesData(_.b.PositionKind, c, T)), m.isVerticesDataPresent(_.b.NormalKind) && (S.normals = m.getVerticesData(_.b.NormalKind, c, T)), m.isVerticesDataPresent(_.b.TangentKind) && (S.tangents = m.getVerticesData(_.b.TangentKind, c, T)), m.isVerticesDataPresent(_.b.UVKind) && (S.uvs = m.getVerticesData(_.b.UVKind, c, T)), m.isVerticesDataPresent(_.b.UV2Kind) && (S.uvs2 = m.getVerticesData(_.b.UV2Kind, c, T)), m.isVerticesDataPresent(_.b.UV3Kind) && (S.uvs3 = m.getVerticesData(_.b.UV3Kind, c, T)), m.isVerticesDataPresent(_.b.UV4Kind) && (S.uvs4 = m.getVerticesData(_.b.UV4Kind, c, T)), m.isVerticesDataPresent(_.b.UV5Kind) && (S.uvs5 = m.getVerticesData(_.b.UV5Kind, c, T)), m.isVerticesDataPresent(_.b.UV6Kind) && (S.uvs6 = m.getVerticesData(_.b.UV6Kind, c, T)), m.isVerticesDataPresent(_.b.ColorKind) && (S.colors = m.getVerticesData(_.b.ColorKind, c, T)), m.isVerticesDataPresent(_.b.MatricesIndicesKind) && (S.matricesIndices = m.getVerticesData(_.b.MatricesIndicesKind, c, T)), m.isVerticesDataPresent(_.b.MatricesWeightsKind) && (S.matricesWeights = m.getVerticesData(_.b.MatricesWeightsKind, c, T)), m.isVerticesDataPresent(_.b.MatricesIndicesExtraKind) && (S.matricesIndicesExtra = m.getVerticesData(_.b.MatricesIndicesExtraKind, c, T)), m.isVerticesDataPresent(_.b.MatricesWeightsExtraKind) && (S.matricesWeightsExtra = m.getVerticesData(_.b.MatricesWeightsExtraKind, c, T)), S.indices = m.getIndices(c, T), S;
+ }, x.CreateRibbon = function(m) {
+ throw C.a.WarnImport("ribbonBuilder");
+ }, x.CreateBox = function(m) {
+ throw C.a.WarnImport("boxBuilder");
+ }, x.CreateTiledBox = function(m) {
+ throw C.a.WarnImport("tiledBoxBuilder");
+ }, x.CreateTiledPlane = function(m) {
+ throw C.a.WarnImport("tiledPlaneBuilder");
+ }, x.CreateSphere = function(m) {
+ throw C.a.WarnImport("sphereBuilder");
+ }, x.CreateCylinder = function(m) {
+ throw C.a.WarnImport("cylinderBuilder");
+ }, x.CreateTorus = function(m) {
+ throw C.a.WarnImport("torusBuilder");
+ }, x.CreateLineSystem = function(m) {
+ throw C.a.WarnImport("linesBuilder");
+ }, x.CreateDashedLines = function(m) {
+ throw C.a.WarnImport("linesBuilder");
+ }, x.CreateGround = function(m) {
+ throw C.a.WarnImport("groundBuilder");
+ }, x.CreateTiledGround = function(m) {
+ throw C.a.WarnImport("groundBuilder");
+ }, x.CreateGroundFromHeightMap = function(m) {
+ throw C.a.WarnImport("groundBuilder");
+ }, x.CreatePlane = function(m) {
+ throw C.a.WarnImport("planeBuilder");
+ }, x.CreateDisc = function(m) {
+ throw C.a.WarnImport("discBuilder");
+ }, x.CreatePolygon = function(m, c, T, S, E, g, l) {
+ throw C.a.WarnImport("polygonBuilder");
+ }, x.CreateIcoSphere = function(m) {
+ throw C.a.WarnImport("icoSphereBuilder");
+ }, x.CreatePolyhedron = function(m) {
+ throw C.a.WarnImport("polyhedronBuilder");
+ }, x.CreateCapsule = function(m) {
+ throw m === void 0 && (m = { orientation: V.e.Up(), subdivisions: 2, tessellation: 16, height: 1, radius: 0.25, capSubdivisions: 6 }), C.a.WarnImport("capsuleBuilder");
+ }, x.CreateTorusKnot = function(m) {
+ throw C.a.WarnImport("torusKnotBuilder");
+ }, x.ComputeNormals = function(m, c, T, S) {
+ var E = 0, g = 0, l = 0, h = 0, v = 0, b = 0, D = 0, w = 0, N = 0, M = 0, U = 0, X = 0, j = 0, ne = 0, te = 0, de = 0, pe = 0, ae = 0, ee = 0, K = 0, $ = !1, L = !1, G = !1, Q = !1, oe = 1, re = 0, Y = null;
+ if (S && ($ = !!S.facetNormals, L = !!S.facetPositions, G = !!S.facetPartitioning, oe = S.useRightHandedSystem === !0 ? -1 : 1, re = S.ratio || 0, Q = !!S.depthSort, Y = S.distanceTo, Q)) {
+ Y === void 0 && (Y = V.e.Zero());
+ var k = S.depthSortedFacets;
+ }
+ var H = 0, Z = 0, W = 0, q = 0;
+ if (G && S && S.bbSize) {
+ var he = 0, ge = 0, me = 0, _e = 0, ye = 0, Pe = 0, be = 0, Fe = 0, ke = 0, We = 0, je = 0, He = 0, Qe = 0, Ge = 0, tt = 0, Je = 0, st = S.bbSize.x > S.bbSize.y ? S.bbSize.x : S.bbSize.y;
+ st = st > S.bbSize.z ? st : S.bbSize.z, H = S.subDiv.X * re / S.bbSize.x, Z = S.subDiv.Y * re / S.bbSize.y, W = S.subDiv.Z * re / S.bbSize.z, q = S.subDiv.max * S.subDiv.max, S.facetPartitioning.length = 0;
+ }
+ for (E = 0; E < m.length; E++)
+ T[E] = 0;
+ var at = c.length / 3 | 0;
+ for (E = 0; E < at; E++) {
+ if (j = (X = 3 * c[3 * E]) + 1, ne = X + 2, de = (te = 3 * c[3 * E + 1]) + 1, pe = te + 2, ee = (ae = 3 * c[3 * E + 2]) + 1, K = ae + 2, g = m[X] - m[te], l = m[j] - m[de], h = m[ne] - m[pe], v = m[ae] - m[te], b = m[ee] - m[de], w = oe * (l * (D = m[K] - m[pe]) - h * b), N = oe * (h * v - g * D), M = oe * (g * b - l * v), w /= U = (U = Math.sqrt(w * w + N * N + M * M)) === 0 ? 1 : U, N /= U, M /= U, $ && S && (S.facetNormals[E].x = w, S.facetNormals[E].y = N, S.facetNormals[E].z = M), L && S && (S.facetPositions[E].x = (m[X] + m[te] + m[ae]) / 3, S.facetPositions[E].y = (m[j] + m[de] + m[ee]) / 3, S.facetPositions[E].z = (m[ne] + m[pe] + m[K]) / 3), G && S && (he = Math.floor((S.facetPositions[E].x - S.bInfo.minimum.x * re) * H), ge = Math.floor((S.facetPositions[E].y - S.bInfo.minimum.y * re) * Z), me = Math.floor((S.facetPositions[E].z - S.bInfo.minimum.z * re) * W), _e = Math.floor((m[X] - S.bInfo.minimum.x * re) * H), ye = Math.floor((m[j] - S.bInfo.minimum.y * re) * Z), Pe = Math.floor((m[ne] - S.bInfo.minimum.z * re) * W), be = Math.floor((m[te] - S.bInfo.minimum.x * re) * H), Fe = Math.floor((m[de] - S.bInfo.minimum.y * re) * Z), ke = Math.floor((m[pe] - S.bInfo.minimum.z * re) * W), We = Math.floor((m[ae] - S.bInfo.minimum.x * re) * H), je = Math.floor((m[ee] - S.bInfo.minimum.y * re) * Z), He = Math.floor((m[K] - S.bInfo.minimum.z * re) * W), Ge = _e + S.subDiv.max * ye + q * Pe, tt = be + S.subDiv.max * Fe + q * ke, Je = We + S.subDiv.max * je + q * He, Qe = he + S.subDiv.max * ge + q * me, S.facetPartitioning[Qe] = S.facetPartitioning[Qe] ? S.facetPartitioning[Qe] : new Array(), S.facetPartitioning[Ge] = S.facetPartitioning[Ge] ? S.facetPartitioning[Ge] : new Array(), S.facetPartitioning[tt] = S.facetPartitioning[tt] ? S.facetPartitioning[tt] : new Array(), S.facetPartitioning[Je] = S.facetPartitioning[Je] ? S.facetPartitioning[Je] : new Array(), S.facetPartitioning[Ge].push(E), tt != Ge && S.facetPartitioning[tt].push(E), Je != tt && Je != Ge && S.facetPartitioning[Je].push(E), Qe != Ge && Qe != tt && Qe != Je && S.facetPartitioning[Qe].push(E)), Q && S && S.facetPositions) {
+ var pt = k[E];
+ pt.ind = 3 * E, pt.sqDistance = V.e.DistanceSquared(S.facetPositions[E], Y);
+ }
+ T[X] += w, T[j] += N, T[ne] += M, T[te] += w, T[de] += N, T[pe] += M, T[ae] += w, T[ee] += N, T[K] += M;
+ }
+ for (E = 0; E < T.length / 3; E++)
+ w = T[3 * E], N = T[3 * E + 1], M = T[3 * E + 2], w /= U = (U = Math.sqrt(w * w + N * N + M * M)) === 0 ? 1 : U, N /= U, M /= U, T[3 * E] = w, T[3 * E + 1] = N, T[3 * E + 2] = M;
+ }, x._ComputeSides = function(m, c, T, S, E, g, l) {
+ var h, v, b = T.length, D = S.length;
+ switch (m = m || x.DEFAULTSIDE) {
+ case x.FRONTSIDE:
+ break;
+ case x.BACKSIDE:
+ var w;
+ for (h = 0; h < b; h += 3)
+ w = T[h], T[h] = T[h + 2], T[h + 2] = w;
+ for (v = 0; v < D; v++)
+ S[v] = -S[v];
+ break;
+ case x.DOUBLESIDE:
+ for (var N = c.length, M = N / 3, U = 0; U < N; U++)
+ c[N + U] = c[U];
+ for (h = 0; h < b; h += 3)
+ T[h + b] = T[h + 2] + M, T[h + 1 + b] = T[h + 1] + M, T[h + 2 + b] = T[h] + M;
+ for (v = 0; v < D; v++)
+ S[D + v] = -S[v];
+ var X = E.length, j = 0;
+ for (j = 0; j < X; j++)
+ E[j + X] = E[j];
+ for (g = g || new V.f(0, 0, 1, 1), l = l || new V.f(0, 0, 1, 1), j = 0, h = 0; h < X / 2; h++)
+ E[j] = g.x + (g.z - g.x) * E[j], E[j + 1] = g.y + (g.w - g.y) * E[j + 1], E[j + X] = l.x + (l.z - l.x) * E[j + X], E[j + X + 1] = l.y + (l.w - l.y) * E[j + X + 1], j += 2;
+ }
+ }, x.ImportVertexData = function(m, c) {
+ var T = new x(), S = m.positions;
+ S && T.set(S, _.b.PositionKind);
+ var E = m.normals;
+ E && T.set(E, _.b.NormalKind);
+ var g = m.tangents;
+ g && T.set(g, _.b.TangentKind);
+ var l = m.uvs;
+ l && T.set(l, _.b.UVKind);
+ var h = m.uv2s;
+ h && T.set(h, _.b.UV2Kind);
+ var v = m.uv3s;
+ v && T.set(v, _.b.UV3Kind);
+ var b = m.uv4s;
+ b && T.set(b, _.b.UV4Kind);
+ var D = m.uv5s;
+ D && T.set(D, _.b.UV5Kind);
+ var w = m.uv6s;
+ w && T.set(w, _.b.UV6Kind);
+ var N = m.colors;
+ N && T.set(u.b.CheckColors4(N, S.length / 3), _.b.ColorKind);
+ var M = m.matricesIndices;
+ M && T.set(M, _.b.MatricesIndicesKind);
+ var U = m.matricesWeights;
+ U && T.set(U, _.b.MatricesWeightsKind);
+ var X = m.indices;
+ X && (T.indices = X), c.setAllVerticesData(T, m.updatable);
+ }, x.FRONTSIDE = 0, x.BACKSIDE = 1, x.DOUBLESIDE = 2, x.DEFAULTSIDE = 0, x;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return _;
+ }), f.d(A, "b", function() {
+ return C;
+ });
+ var V = f(1), _ = function() {
+ function u() {
+ }
+ return u.NAME_EFFECTLAYER = "EffectLayer", u.NAME_LAYER = "Layer", u.NAME_LENSFLARESYSTEM = "LensFlareSystem", u.NAME_BOUNDINGBOXRENDERER = "BoundingBoxRenderer", u.NAME_PARTICLESYSTEM = "ParticleSystem", u.NAME_GAMEPAD = "Gamepad", u.NAME_SIMPLIFICATIONQUEUE = "SimplificationQueue", u.NAME_GEOMETRYBUFFERRENDERER = "GeometryBufferRenderer", u.NAME_PREPASSRENDERER = "PrePassRenderer", u.NAME_DEPTHRENDERER = "DepthRenderer", u.NAME_POSTPROCESSRENDERPIPELINEMANAGER = "PostProcessRenderPipelineManager", u.NAME_SPRITE = "Sprite", u.NAME_SUBSURFACE = "SubSurface", u.NAME_OUTLINERENDERER = "Outline", u.NAME_PROCEDURALTEXTURE = "ProceduralTexture", u.NAME_SHADOWGENERATOR = "ShadowGenerator", u.NAME_OCTREE = "Octree", u.NAME_PHYSICSENGINE = "PhysicsEngine", u.NAME_AUDIO = "Audio", u.STEP_ISREADYFORMESH_EFFECTLAYER = 0, u.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER = 0, u.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0, u.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER = 0, u.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER = 1, u.STEP_BEFORECAMERADRAW_EFFECTLAYER = 0, u.STEP_BEFORECAMERADRAW_LAYER = 1, u.STEP_BEFORECAMERADRAW_PREPASS = 2, u.STEP_BEFORERENDERTARGETDRAW_LAYER = 0, u.STEP_BEFORERENDERINGMESH_PREPASS = 0, u.STEP_BEFORERENDERINGMESH_OUTLINE = 1, u.STEP_AFTERRENDERINGMESH_PREPASS = 0, u.STEP_AFTERRENDERINGMESH_OUTLINE = 1, u.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW = 0, u.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER = 1, u.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE = 0, u.STEP_BEFORECAMERAUPDATE_GAMEPAD = 1, u.STEP_BEFORECLEAR_PROCEDURALTEXTURE = 0, u.STEP_AFTERRENDERTARGETDRAW_LAYER = 0, u.STEP_AFTERCAMERADRAW_EFFECTLAYER = 0, u.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM = 1, u.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW = 2, u.STEP_AFTERCAMERADRAW_LAYER = 3, u.STEP_AFTERCAMERADRAW_PREPASS = 4, u.STEP_AFTERRENDER_AUDIO = 0, u.STEP_GATHERRENDERTARGETS_DEPTHRENDERER = 0, u.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER = 1, u.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR = 2, u.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER = 3, u.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER = 0, u.STEP_BEFORECLEARSTAGE_PREPASS = 0, u.STEP_POINTERMOVE_SPRITE = 0, u.STEP_POINTERDOWN_SPRITE = 0, u.STEP_POINTERUP_SPRITE = 0, u;
+ }(), C = function(u) {
+ function I(O) {
+ return u.apply(this, O) || this;
+ }
+ return Object(V.d)(I, u), I.Create = function() {
+ return Object.create(I.prototype);
+ }, I.prototype.registerStep = function(O, x, m) {
+ var c = 0;
+ for (Number.MAX_VALUE; c < this.length && !(O < this[c].index); c++)
+ ;
+ this.splice(c, 0, { index: O, component: x, action: m.bind(x) });
+ }, I.prototype.clear = function() {
+ this.length = 0;
+ }, I;
+ }(Array);
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return C;
+ }), f.d(A, "c", function() {
+ return u;
+ }), f.d(A, "d", function() {
+ return I;
+ }), f.d(A, "b", function() {
+ return O;
+ });
+ var V = f(1), _ = f(0), C = function() {
+ function x() {
+ }
+ return x.POINTERDOWN = 1, x.POINTERUP = 2, x.POINTERMOVE = 4, x.POINTERWHEEL = 8, x.POINTERPICK = 16, x.POINTERTAP = 32, x.POINTERDOUBLETAP = 64, x;
+ }(), u = function(x, m) {
+ this.type = x, this.event = m;
+ }, I = function(x) {
+ function m(c, T, S, E) {
+ var g = x.call(this, c, T) || this;
+ return g.ray = null, g.skipOnPointerObservable = !1, g.localPosition = new _.d(S, E), g;
+ }
+ return Object(V.d)(m, x), m;
+ }(u), O = function(x) {
+ function m(c, T, S) {
+ var E = x.call(this, c, T) || this;
+ return E.pickInfo = S, E;
+ }
+ return Object(V.d)(m, x), m;
+ }(u);
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return C;
+ });
+ var V = f(13), _ = f(2), C = function() {
+ function u() {
+ }
+ return Object.defineProperty(u, "DiffuseTextureEnabled", { get: function() {
+ return this._DiffuseTextureEnabled;
+ }, set: function(I) {
+ this._DiffuseTextureEnabled !== I && (this._DiffuseTextureEnabled = I, V.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(u, "DetailTextureEnabled", { get: function() {
+ return this._DetailTextureEnabled;
+ }, set: function(I) {
+ this._DetailTextureEnabled !== I && (this._DetailTextureEnabled = I, V.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(u, "AmbientTextureEnabled", { get: function() {
+ return this._AmbientTextureEnabled;
+ }, set: function(I) {
+ this._AmbientTextureEnabled !== I && (this._AmbientTextureEnabled = I, V.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(u, "OpacityTextureEnabled", { get: function() {
+ return this._OpacityTextureEnabled;
+ }, set: function(I) {
+ this._OpacityTextureEnabled !== I && (this._OpacityTextureEnabled = I, V.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(u, "ReflectionTextureEnabled", { get: function() {
+ return this._ReflectionTextureEnabled;
+ }, set: function(I) {
+ this._ReflectionTextureEnabled !== I && (this._ReflectionTextureEnabled = I, V.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(u, "EmissiveTextureEnabled", { get: function() {
+ return this._EmissiveTextureEnabled;
+ }, set: function(I) {
+ this._EmissiveTextureEnabled !== I && (this._EmissiveTextureEnabled = I, V.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(u, "SpecularTextureEnabled", { get: function() {
+ return this._SpecularTextureEnabled;
+ }, set: function(I) {
+ this._SpecularTextureEnabled !== I && (this._SpecularTextureEnabled = I, V.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(u, "BumpTextureEnabled", { get: function() {
+ return this._BumpTextureEnabled;
+ }, set: function(I) {
+ this._BumpTextureEnabled !== I && (this._BumpTextureEnabled = I, V.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(u, "LightmapTextureEnabled", { get: function() {
+ return this._LightmapTextureEnabled;
+ }, set: function(I) {
+ this._LightmapTextureEnabled !== I && (this._LightmapTextureEnabled = I, V.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(u, "RefractionTextureEnabled", { get: function() {
+ return this._RefractionTextureEnabled;
+ }, set: function(I) {
+ this._RefractionTextureEnabled !== I && (this._RefractionTextureEnabled = I, V.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(u, "ColorGradingTextureEnabled", { get: function() {
+ return this._ColorGradingTextureEnabled;
+ }, set: function(I) {
+ this._ColorGradingTextureEnabled !== I && (this._ColorGradingTextureEnabled = I, V.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(u, "FresnelEnabled", { get: function() {
+ return this._FresnelEnabled;
+ }, set: function(I) {
+ this._FresnelEnabled !== I && (this._FresnelEnabled = I, V.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_FresnelDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(u, "ClearCoatTextureEnabled", { get: function() {
+ return this._ClearCoatTextureEnabled;
+ }, set: function(I) {
+ this._ClearCoatTextureEnabled !== I && (this._ClearCoatTextureEnabled = I, V.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(u, "ClearCoatBumpTextureEnabled", { get: function() {
+ return this._ClearCoatBumpTextureEnabled;
+ }, set: function(I) {
+ this._ClearCoatBumpTextureEnabled !== I && (this._ClearCoatBumpTextureEnabled = I, V.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(u, "ClearCoatTintTextureEnabled", { get: function() {
+ return this._ClearCoatTintTextureEnabled;
+ }, set: function(I) {
+ this._ClearCoatTintTextureEnabled !== I && (this._ClearCoatTintTextureEnabled = I, V.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(u, "SheenTextureEnabled", { get: function() {
+ return this._SheenTextureEnabled;
+ }, set: function(I) {
+ this._SheenTextureEnabled !== I && (this._SheenTextureEnabled = I, V.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(u, "AnisotropicTextureEnabled", { get: function() {
+ return this._AnisotropicTextureEnabled;
+ }, set: function(I) {
+ this._AnisotropicTextureEnabled !== I && (this._AnisotropicTextureEnabled = I, V.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(u, "ThicknessTextureEnabled", { get: function() {
+ return this._ThicknessTextureEnabled;
+ }, set: function(I) {
+ this._ThicknessTextureEnabled !== I && (this._ThicknessTextureEnabled = I, V.a.MarkAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), u._DiffuseTextureEnabled = !0, u._DetailTextureEnabled = !0, u._AmbientTextureEnabled = !0, u._OpacityTextureEnabled = !0, u._ReflectionTextureEnabled = !0, u._EmissiveTextureEnabled = !0, u._SpecularTextureEnabled = !0, u._BumpTextureEnabled = !0, u._LightmapTextureEnabled = !0, u._RefractionTextureEnabled = !0, u._ColorGradingTextureEnabled = !0, u._FresnelEnabled = !0, u._ClearCoatTextureEnabled = !0, u._ClearCoatBumpTextureEnabled = !0, u._ClearCoatTintTextureEnabled = !0, u._SheenTextureEnabled = !0, u._AnisotropicTextureEnabled = !0, u._ThicknessTextureEnabled = !0, u;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return oe;
+ });
+ var V = f(1), _ = f(12), C = f(57), u = f(6), I = f(33), O = f(112), x = f(37), m = f(0), c = f(46), T = f(31), S = f(24), E = f(35), g = f(42), l = f(85), h = f(48), v = f(54), b = f(47), D = f(95), w = f(96), N = f(17), M = f(2), U = f(38), X = f(8), j = f(22), ne = f(21), te = f(18), de = f(91), pe = f(66), ae = function() {
+ function re() {
+ this._singleClick = !1, this._doubleClick = !1, this._hasSwiped = !1, this._ignore = !1;
+ }
+ return Object.defineProperty(re.prototype, "singleClick", { get: function() {
+ return this._singleClick;
+ }, set: function(Y) {
+ this._singleClick = Y;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(re.prototype, "doubleClick", { get: function() {
+ return this._doubleClick;
+ }, set: function(Y) {
+ this._doubleClick = Y;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(re.prototype, "hasSwiped", { get: function() {
+ return this._hasSwiped;
+ }, set: function(Y) {
+ this._hasSwiped = Y;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(re.prototype, "ignore", { get: function() {
+ return this._ignore;
+ }, set: function(Y) {
+ this._ignore = Y;
+ }, enumerable: !1, configurable: !0 }), re;
+ }(), ee = function() {
+ function re(Y) {
+ this._alreadyAttached = !1, this._wheelEventName = "", this._meshPickProceed = !1, this._currentPickResult = null, this._previousPickResult = null, this._totalPointersPressed = 0, this._doubleClickOccured = !1, this._pointerX = 0, this._pointerY = 0, this._startingPointerPosition = new m.d(0, 0), this._previousStartingPointerPosition = new m.d(0, 0), this._startingPointerTime = 0, this._previousStartingPointerTime = 0, this._pointerCaptures = {}, this._meshUnderPointerId = [], this._keyboardIsAttached = !1, this._scene = Y;
+ }
+ return Object.defineProperty(re.prototype, "meshUnderPointer", { get: function() {
+ return this._pointerOverMesh;
+ }, enumerable: !1, configurable: !0 }), re.prototype.getMeshUnderPointerByPointerId = function(Y) {
+ return this._meshUnderPointerId[Y];
+ }, Object.defineProperty(re.prototype, "unTranslatedPointer", { get: function() {
+ return new m.d(this._unTranslatedPointerX, this._unTranslatedPointerY);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(re.prototype, "pointerX", { get: function() {
+ return this._pointerX;
+ }, set: function(Y) {
+ this._pointerX = Y;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(re.prototype, "pointerY", { get: function() {
+ return this._pointerY;
+ }, set: function(Y) {
+ this._pointerY = Y;
+ }, enumerable: !1, configurable: !0 }), re.prototype._updatePointerPosition = function(Y) {
+ var k = this._scene.getEngine().getInputElementClientRect();
+ k && (this._pointerX = Y.clientX - k.left, this._pointerY = Y.clientY - k.top, this._unTranslatedPointerX = this._pointerX, this._unTranslatedPointerY = this._pointerY);
+ }, re.prototype._processPointerMove = function(Y, k) {
+ var H = this._scene, Z = H.getEngine(), W = Z.getInputElement();
+ if (W) {
+ W.tabIndex = Z.canvasTabIndex, H.doNotHandleCursors || (W.style.cursor = H.defaultCursor);
+ var q = !!(Y && Y.hit && Y.pickedMesh);
+ q ? (H.setPointerOverMesh(Y.pickedMesh, k.pointerId), this._pointerOverMesh && this._pointerOverMesh.actionManager && this._pointerOverMesh.actionManager.hasPointerTriggers && (H.doNotHandleCursors || (this._pointerOverMesh.actionManager.hoverCursor ? W.style.cursor = this._pointerOverMesh.actionManager.hoverCursor : W.style.cursor = H.hoverCursor))) : H.setPointerOverMesh(null, k.pointerId);
+ for (var he = 0, ge = H._pointerMoveStage; he < ge.length; he++)
+ Y = ge[he].action(this._unTranslatedPointerX, this._unTranslatedPointerY, Y, q, W);
+ if (Y) {
+ var me = k.type === this._wheelEventName ? te.a.POINTERWHEEL : te.a.POINTERMOVE;
+ if (H.onPointerMove && H.onPointerMove(k, Y, me), H.onPointerObservable.hasObservers()) {
+ var _e = new te.b(me, k, Y);
+ this._setRayOnPointerInfo(_e), H.onPointerObservable.notifyObservers(_e, me);
+ }
+ }
+ }
+ }, re.prototype._setRayOnPointerInfo = function(Y) {
+ var k = this._scene;
+ Y.pickInfo && !Y.pickInfo._pickingUnavailable && (Y.pickInfo.ray || (Y.pickInfo.ray = k.createPickingRay(Y.event.offsetX, Y.event.offsetY, m.a.Identity(), k.activeCamera)));
+ }, re.prototype._checkPrePointerObservable = function(Y, k, H) {
+ var Z = this._scene, W = new te.d(H, k, this._unTranslatedPointerX, this._unTranslatedPointerY);
+ return Y && (W.ray = Y.ray), Z.onPrePointerObservable.notifyObservers(W, H), !!W.skipOnPointerObservable;
+ }, re.prototype.simulatePointerMove = function(Y, k) {
+ var H = new PointerEvent("pointermove", k);
+ this._checkPrePointerObservable(Y, H, te.a.POINTERMOVE) || this._processPointerMove(Y, H);
+ }, re.prototype.simulatePointerDown = function(Y, k) {
+ var H = new PointerEvent("pointerdown", k);
+ this._checkPrePointerObservable(Y, H, te.a.POINTERDOWN) || this._processPointerDown(Y, H);
+ }, re.prototype._processPointerDown = function(Y, k) {
+ var H = this, Z = this._scene;
+ if (Y && Y.hit && Y.pickedMesh) {
+ this._pickedDownMesh = Y.pickedMesh;
+ var W = Y.pickedMesh._getActionManagerForTrigger();
+ if (W) {
+ if (W.hasPickTriggers)
+ switch (W.processTrigger(M.a.ACTION_OnPickDownTrigger, b.a.CreateNew(Y.pickedMesh, k)), k.button) {
+ case 0:
+ W.processTrigger(M.a.ACTION_OnLeftPickTrigger, b.a.CreateNew(Y.pickedMesh, k));
+ break;
+ case 1:
+ W.processTrigger(M.a.ACTION_OnCenterPickTrigger, b.a.CreateNew(Y.pickedMesh, k));
+ break;
+ case 2:
+ W.processTrigger(M.a.ACTION_OnRightPickTrigger, b.a.CreateNew(Y.pickedMesh, k));
+ }
+ W.hasSpecificTrigger(M.a.ACTION_OnLongPressTrigger) && window.setTimeout(function() {
+ var _e = Z.pick(H._unTranslatedPointerX, H._unTranslatedPointerY, function(ye) {
+ return ye.isPickable && ye.isVisible && ye.isReady() && ye.actionManager && ye.actionManager.hasSpecificTrigger(M.a.ACTION_OnLongPressTrigger) && ye == H._pickedDownMesh;
+ }, !1, Z.cameraToUseForPointers);
+ _e && _e.hit && _e.pickedMesh && W && H._totalPointersPressed !== 0 && Date.now() - H._startingPointerTime > re.LongPressDelay && !H._isPointerSwiping() && (H._startingPointerTime = 0, W.processTrigger(M.a.ACTION_OnLongPressTrigger, b.a.CreateNew(_e.pickedMesh, k)));
+ }, re.LongPressDelay);
+ }
+ } else
+ for (var q = 0, he = Z._pointerDownStage; q < he.length; q++)
+ Y = he[q].action(this._unTranslatedPointerX, this._unTranslatedPointerY, Y, k);
+ if (Y) {
+ var ge = te.a.POINTERDOWN;
+ if (Z.onPointerDown && Z.onPointerDown(k, Y, ge), Z.onPointerObservable.hasObservers()) {
+ var me = new te.b(ge, k, Y);
+ this._setRayOnPointerInfo(me), Z.onPointerObservable.notifyObservers(me, ge);
+ }
+ }
+ }, re.prototype._isPointerSwiping = function() {
+ return Math.abs(this._startingPointerPosition.x - this._pointerX) > re.DragMovementThreshold || Math.abs(this._startingPointerPosition.y - this._pointerY) > re.DragMovementThreshold;
+ }, re.prototype.simulatePointerUp = function(Y, k, H) {
+ var Z = new PointerEvent("pointerup", k), W = new ae();
+ H ? W.doubleClick = !0 : W.singleClick = !0, this._checkPrePointerObservable(Y, Z, te.a.POINTERUP) || this._processPointerUp(Y, Z, W);
+ }, re.prototype._processPointerUp = function(Y, k, H) {
+ var Z = this._scene;
+ if (Y && Y && Y.pickedMesh) {
+ if (this._pickedUpMesh = Y.pickedMesh, this._pickedDownMesh === this._pickedUpMesh && (Z.onPointerPick && Z.onPointerPick(k, Y), H.singleClick && !H.ignore && Z.onPointerObservable.hasObservers())) {
+ var W = te.a.POINTERPICK, q = new te.b(W, k, Y);
+ this._setRayOnPointerInfo(q), Z.onPointerObservable.notifyObservers(q, W);
+ }
+ var he = Y.pickedMesh._getActionManagerForTrigger();
+ if (he && !H.ignore) {
+ he.processTrigger(M.a.ACTION_OnPickUpTrigger, b.a.CreateNew(Y.pickedMesh, k)), !H.hasSwiped && H.singleClick && he.processTrigger(M.a.ACTION_OnPickTrigger, b.a.CreateNew(Y.pickedMesh, k));
+ var ge = Y.pickedMesh._getActionManagerForTrigger(M.a.ACTION_OnDoublePickTrigger);
+ H.doubleClick && ge && ge.processTrigger(M.a.ACTION_OnDoublePickTrigger, b.a.CreateNew(Y.pickedMesh, k));
+ }
+ } else if (!H.ignore)
+ for (var me = 0, _e = Z._pointerUpStage; me < _e.length; me++)
+ Y = _e[me].action(this._unTranslatedPointerX, this._unTranslatedPointerY, Y, k);
+ if (this._pickedDownMesh && this._pickedDownMesh !== this._pickedUpMesh) {
+ var ye = this._pickedDownMesh._getActionManagerForTrigger(M.a.ACTION_OnPickOutTrigger);
+ ye && ye.processTrigger(M.a.ACTION_OnPickOutTrigger, b.a.CreateNew(this._pickedDownMesh, k));
+ }
+ var Pe = 0;
+ Z.onPointerObservable.hasObservers() && (!H.ignore && !H.hasSwiped && (H.singleClick && Z.onPointerObservable.hasSpecificMask(te.a.POINTERTAP) ? Pe = te.a.POINTERTAP : H.doubleClick && Z.onPointerObservable.hasSpecificMask(te.a.POINTERDOUBLETAP) && (Pe = te.a.POINTERDOUBLETAP), Pe) && (q = new te.b(Pe, k, Y), this._setRayOnPointerInfo(q), Z.onPointerObservable.notifyObservers(q, Pe)), H.ignore || (Pe = te.a.POINTERUP, q = new te.b(Pe, k, Y), this._setRayOnPointerInfo(q), Z.onPointerObservable.notifyObservers(q, Pe))), Z.onPointerUp && !H.ignore && Z.onPointerUp(k, Y, Pe);
+ }, re.prototype.isPointerCaptured = function(Y) {
+ return Y === void 0 && (Y = 0), this._pointerCaptures[Y];
+ }, re.prototype.attachControl = function(Y, k, H, Z) {
+ var W = this;
+ Y === void 0 && (Y = !0), k === void 0 && (k = !0), H === void 0 && (H = !0), Z === void 0 && (Z = null);
+ var q = this._scene;
+ if (Z || (Z = q.getEngine().getInputElement()), Z) {
+ this._alreadyAttached && this.detachControl(), this._alreadyAttachedTo = Z;
+ var he = q.getEngine();
+ this._initActionManager = function(ye, Pe) {
+ if (!W._meshPickProceed) {
+ var be = q.pick(W._unTranslatedPointerX, W._unTranslatedPointerY, q.pointerDownPredicate, !1, q.cameraToUseForPointers);
+ W._currentPickResult = be, be && (ye = be.hit && be.pickedMesh ? be.pickedMesh._getActionManagerForTrigger() : null), W._meshPickProceed = !0;
+ }
+ return ye;
+ }, this._delayedSimpleClick = function(ye, Pe, be) {
+ (Date.now() - W._previousStartingPointerTime > re.DoubleClickDelay && !W._doubleClickOccured || ye !== W._previousButtonPressed) && (W._doubleClickOccured = !1, Pe.singleClick = !0, Pe.ignore = !1, be(Pe, W._currentPickResult));
+ }, this._initClickEvent = function(ye, Pe, be, Fe) {
+ var ke = new ae();
+ W._currentPickResult = null;
+ var We = null, je = ye.hasSpecificMask(te.a.POINTERPICK) || Pe.hasSpecificMask(te.a.POINTERPICK) || ye.hasSpecificMask(te.a.POINTERTAP) || Pe.hasSpecificMask(te.a.POINTERTAP) || ye.hasSpecificMask(te.a.POINTERDOUBLETAP) || Pe.hasSpecificMask(te.a.POINTERDOUBLETAP);
+ !je && de.a && (We = W._initActionManager(We, ke)) && (je = We.hasPickTriggers);
+ var He = !1;
+ if (je) {
+ var Qe = be.button;
+ if (ke.hasSwiped = W._isPointerSwiping(), !ke.hasSwiped) {
+ var Ge = !re.ExclusiveDoubleClickMode;
+ Ge || (Ge = !ye.hasSpecificMask(te.a.POINTERDOUBLETAP) && !Pe.hasSpecificMask(te.a.POINTERDOUBLETAP)) && !de.a.HasSpecificTrigger(M.a.ACTION_OnDoublePickTrigger) && (We = W._initActionManager(We, ke)) && (Ge = !We.hasSpecificTrigger(M.a.ACTION_OnDoublePickTrigger)), Ge ? (Date.now() - W._previousStartingPointerTime > re.DoubleClickDelay || Qe !== W._previousButtonPressed) && (ke.singleClick = !0, Fe(ke, W._currentPickResult), He = !0) : (W._previousDelayedSimpleClickTimeout = W._delayedSimpleClickTimeout, W._delayedSimpleClickTimeout = window.setTimeout(W._delayedSimpleClick.bind(W, Qe, ke, Fe), re.DoubleClickDelay));
+ var tt = ye.hasSpecificMask(te.a.POINTERDOUBLETAP) || Pe.hasSpecificMask(te.a.POINTERDOUBLETAP);
+ !tt && de.a.HasSpecificTrigger(M.a.ACTION_OnDoublePickTrigger) && (We = W._initActionManager(We, ke)) && (tt = We.hasSpecificTrigger(M.a.ACTION_OnDoublePickTrigger)), tt && (Qe === W._previousButtonPressed && Date.now() - W._previousStartingPointerTime < re.DoubleClickDelay && !W._doubleClickOccured ? (ke.hasSwiped || W._isPointerSwiping() ? (W._doubleClickOccured = !1, W._previousStartingPointerTime = W._startingPointerTime, W._previousStartingPointerPosition.x = W._startingPointerPosition.x, W._previousStartingPointerPosition.y = W._startingPointerPosition.y, W._previousButtonPressed = Qe, re.ExclusiveDoubleClickMode ? (W._previousDelayedSimpleClickTimeout && clearTimeout(W._previousDelayedSimpleClickTimeout), W._previousDelayedSimpleClickTimeout = W._delayedSimpleClickTimeout, Fe(ke, W._previousPickResult)) : Fe(ke, W._currentPickResult)) : (W._previousStartingPointerTime = 0, W._doubleClickOccured = !0, ke.doubleClick = !0, ke.ignore = !1, re.ExclusiveDoubleClickMode && W._previousDelayedSimpleClickTimeout && clearTimeout(W._previousDelayedSimpleClickTimeout), W._previousDelayedSimpleClickTimeout = W._delayedSimpleClickTimeout, Fe(ke, W._currentPickResult)), He = !0) : (W._doubleClickOccured = !1, W._previousStartingPointerTime = W._startingPointerTime, W._previousStartingPointerPosition.x = W._startingPointerPosition.x, W._previousStartingPointerPosition.y = W._startingPointerPosition.y, W._previousButtonPressed = Qe));
+ }
+ }
+ He || Fe(ke, W._currentPickResult);
+ }, this._onPointerMove = function(ye) {
+ if (ye.pointerId === void 0 && (ye.pointerId = 0), W._updatePointerPosition(ye), !W._checkPrePointerObservable(null, ye, ye.type === W._wheelEventName ? te.a.POINTERWHEEL : te.a.POINTERMOVE) && (q.cameraToUseForPointers || q.activeCamera)) {
+ q.pointerMovePredicate || (q.pointerMovePredicate = function(be) {
+ return be.isPickable && be.isVisible && be.isReady() && be.isEnabled() && (be.enablePointerMoveEvents || q.constantlyUpdateMeshUnderPointer || be._getActionManagerForTrigger() != null) && (!q.cameraToUseForPointers || (q.cameraToUseForPointers.layerMask & be.layerMask) != 0);
+ });
+ var Pe = q.pick(W._unTranslatedPointerX, W._unTranslatedPointerY, q.pointerMovePredicate, !1, q.cameraToUseForPointers);
+ W._processPointerMove(Pe, ye);
+ }
+ }, this._onPointerDown = function(ye) {
+ if (W._totalPointersPressed++, W._pickedDownMesh = null, W._meshPickProceed = !1, ye.pointerId === void 0 && (ye.pointerId = 0), W._updatePointerPosition(ye), q.preventDefaultOnPointerDown && Z && (ye.preventDefault(), Z.focus()), W._startingPointerPosition.x = W._pointerX, W._startingPointerPosition.y = W._pointerY, W._startingPointerTime = Date.now(), !W._checkPrePointerObservable(null, ye, te.a.POINTERDOWN) && (q.cameraToUseForPointers || q.activeCamera)) {
+ W._pointerCaptures[ye.pointerId] = !0, q.pointerDownPredicate || (q.pointerDownPredicate = function(be) {
+ return be.isPickable && be.isVisible && be.isReady() && be.isEnabled() && (!q.cameraToUseForPointers || (q.cameraToUseForPointers.layerMask & be.layerMask) != 0);
+ }), W._pickedDownMesh = null;
+ var Pe = q.pick(W._unTranslatedPointerX, W._unTranslatedPointerY, q.pointerDownPredicate, !1, q.cameraToUseForPointers);
+ W._processPointerDown(Pe, ye);
+ }
+ }, this._onPointerUp = function(ye) {
+ W._totalPointersPressed !== 0 && (W._totalPointersPressed--, W._pickedUpMesh = null, W._meshPickProceed = !1, ye.pointerId === void 0 && (ye.pointerId = 0), W._updatePointerPosition(ye), q.preventDefaultOnPointerUp && Z && (ye.preventDefault(), Z.focus()), W._initClickEvent(q.onPrePointerObservable, q.onPointerObservable, ye, function(Pe, be) {
+ q.onPrePointerObservable.hasObservers() && !Pe.ignore && (!Pe.hasSwiped && (Pe.singleClick && q.onPrePointerObservable.hasSpecificMask(te.a.POINTERTAP) && W._checkPrePointerObservable(null, ye, te.a.POINTERTAP) || Pe.doubleClick && q.onPrePointerObservable.hasSpecificMask(te.a.POINTERDOUBLETAP) && W._checkPrePointerObservable(null, ye, te.a.POINTERDOUBLETAP)) || W._checkPrePointerObservable(null, ye, te.a.POINTERUP)) || W._pointerCaptures[ye.pointerId] && (W._pointerCaptures[ye.pointerId] = !1, (q.cameraToUseForPointers || q.activeCamera) && (q.pointerUpPredicate || (q.pointerUpPredicate = function(Fe) {
+ return Fe.isPickable && Fe.isVisible && Fe.isReady() && Fe.isEnabled() && (!q.cameraToUseForPointers || (q.cameraToUseForPointers.layerMask & Fe.layerMask) != 0);
+ }), !W._meshPickProceed && (de.a && de.a.HasTriggers || q.onPointerObservable.hasObservers()) && W._initActionManager(null, Pe), be || (be = W._currentPickResult), W._processPointerUp(be, ye, Pe), W._previousPickResult = W._currentPickResult));
+ }));
+ }, this._onKeyDown = function(ye) {
+ var Pe = pe.a.KEYDOWN;
+ if (q.onPreKeyboardObservable.hasObservers()) {
+ var be = new pe.c(Pe, ye);
+ if (q.onPreKeyboardObservable.notifyObservers(be, Pe), be.skipOnPointerObservable)
+ return;
+ }
+ q.onKeyboardObservable.hasObservers() && (be = new pe.b(Pe, ye), q.onKeyboardObservable.notifyObservers(be, Pe)), q.actionManager && q.actionManager.processTrigger(M.a.ACTION_OnKeyDownTrigger, b.a.CreateNewFromScene(q, ye));
+ }, this._onKeyUp = function(ye) {
+ var Pe = pe.a.KEYUP;
+ if (q.onPreKeyboardObservable.hasObservers()) {
+ var be = new pe.c(Pe, ye);
+ if (q.onPreKeyboardObservable.notifyObservers(be, Pe), be.skipOnPointerObservable)
+ return;
+ }
+ q.onKeyboardObservable.hasObservers() && (be = new pe.b(Pe, ye), q.onKeyboardObservable.notifyObservers(be, Pe)), q.actionManager && q.actionManager.processTrigger(M.a.ACTION_OnKeyUpTrigger, b.a.CreateNewFromScene(q, ye));
+ };
+ var ge = function() {
+ Z && !W._keyboardIsAttached && (Z.addEventListener("keydown", W._onKeyDown, !1), Z.addEventListener("keyup", W._onKeyUp, !1), W._keyboardIsAttached = !0);
+ };
+ this._onCanvasFocusObserver = he.onCanvasFocusObservable.add((document.activeElement === Z && ge(), ge)), this._onCanvasBlurObserver = he.onCanvasBlurObservable.add(function() {
+ Z && (Z.removeEventListener("keydown", W._onKeyDown), Z.removeEventListener("keyup", W._onKeyUp), W._keyboardIsAttached = !1);
+ }), ge();
+ var me = _.b.GetPointerPrefix(he);
+ if (H && (Z.addEventListener(me + "move", this._onPointerMove, !1), this._wheelEventName = "onwheel" in document.createElement("div") ? "wheel" : document.onmousewheel !== void 0 ? "mousewheel" : "DOMMouseScroll", Z.addEventListener(this._wheelEventName, this._onPointerMove, !1)), k && Z.addEventListener(me + "down", this._onPointerDown, !1), Y) {
+ var _e = q.getEngine().getHostWindow();
+ _e && _e.addEventListener(me + "up", this._onPointerUp, !1);
+ }
+ this._alreadyAttached = !0;
+ }
+ }, re.prototype.detachControl = function() {
+ var Y = this._scene.getEngine(), k = _.b.GetPointerPrefix(Y);
+ this._alreadyAttachedTo && this._alreadyAttached && (this._alreadyAttachedTo.removeEventListener(k + "move", this._onPointerMove), this._alreadyAttachedTo.removeEventListener(this._wheelEventName, this._onPointerMove), this._alreadyAttachedTo.removeEventListener(k + "down", this._onPointerDown), window.removeEventListener(k + "up", this._onPointerUp), this._onCanvasBlurObserver && Y.onCanvasBlurObservable.remove(this._onCanvasBlurObserver), this._onCanvasFocusObserver && Y.onCanvasFocusObservable.remove(this._onCanvasFocusObserver), this._alreadyAttachedTo.removeEventListener("keydown", this._onKeyDown), this._alreadyAttachedTo.removeEventListener("keyup", this._onKeyUp), this._scene.doNotHandleCursors || (this._alreadyAttachedTo.style.cursor = this._scene.defaultCursor), this._alreadyAttached = !1);
+ }, re.prototype.setPointerOverMesh = function(Y, k) {
+ if (k === void 0 && (k = 0), k < 0 && (k = 0), this._meshUnderPointerId[k] !== Y) {
+ var H, Z = this._meshUnderPointerId[k];
+ Z && (H = Z._getActionManagerForTrigger(M.a.ACTION_OnPointerOutTrigger)) && H.processTrigger(M.a.ACTION_OnPointerOutTrigger, b.a.CreateNew(Z, void 0, { pointerId: k })), this._meshUnderPointerId[k] = Y, this._pointerOverMesh = Y, (Z = this._meshUnderPointerId[k]) && (H = Z._getActionManagerForTrigger(M.a.ACTION_OnPointerOverTrigger)) && H.processTrigger(M.a.ACTION_OnPointerOverTrigger, b.a.CreateNew(Z, void 0, { pointerId: k }));
+ }
+ }, re.prototype.getPointerOverMesh = function() {
+ return this._pointerOverMesh;
+ }, re.DragMovementThreshold = 10, re.LongPressDelay = 500, re.DoubleClickDelay = 300, re.ExclusiveDoubleClickMode = !1, re;
+ }(), K = f(55), $ = f(9), L = f(90), G = f(152), Q = f(56), oe = function(re) {
+ function Y(k, H) {
+ var Z = re.call(this) || this;
+ Z._inputManager = new ee(Z), Z.cameraToUseForPointers = null, Z._isScene = !0, Z._blockEntityCollection = !1, Z.autoClear = !0, Z.autoClearDepthAndStencil = !0, Z.clearColor = new $.b(0.2, 0.2, 0.3, 1), Z.ambientColor = new $.a(0, 0, 0), Z._environmentIntensity = 1, Z._forceWireframe = !1, Z._skipFrustumClipping = !1, Z._forcePointsCloud = !1, Z.animationsEnabled = !0, Z._animationPropertiesOverride = null, Z.useConstantAnimationDeltaTime = !1, Z.constantlyUpdateMeshUnderPointer = !1, Z.hoverCursor = "pointer", Z.defaultCursor = "", Z.doNotHandleCursors = !1, Z.preventDefaultOnPointerDown = !0, Z.preventDefaultOnPointerUp = !0, Z.metadata = null, Z.reservedDataStore = null, Z.disableOfflineSupportExceptionRules = new Array(), Z.onDisposeObservable = new u.c(), Z._onDisposeObserver = null, Z.onBeforeRenderObservable = new u.c(), Z._onBeforeRenderObserver = null, Z.onAfterRenderObservable = new u.c(), Z.onAfterRenderCameraObservable = new u.c(), Z._onAfterRenderObserver = null, Z.onBeforeAnimationsObservable = new u.c(), Z.onAfterAnimationsObservable = new u.c(), Z.onBeforeDrawPhaseObservable = new u.c(), Z.onAfterDrawPhaseObservable = new u.c(), Z.onReadyObservable = new u.c(), Z.onBeforeCameraRenderObservable = new u.c(), Z._onBeforeCameraRenderObserver = null, Z.onAfterCameraRenderObservable = new u.c(), Z._onAfterCameraRenderObserver = null, Z.onBeforeActiveMeshesEvaluationObservable = new u.c(), Z.onAfterActiveMeshesEvaluationObservable = new u.c(), Z.onBeforeParticlesRenderingObservable = new u.c(), Z.onAfterParticlesRenderingObservable = new u.c(), Z.onDataLoadedObservable = new u.c(), Z.onNewCameraAddedObservable = new u.c(), Z.onCameraRemovedObservable = new u.c(), Z.onNewLightAddedObservable = new u.c(), Z.onLightRemovedObservable = new u.c(), Z.onNewGeometryAddedObservable = new u.c(), Z.onGeometryRemovedObservable = new u.c(), Z.onNewTransformNodeAddedObservable = new u.c(), Z.onTransformNodeRemovedObservable = new u.c(), Z.onNewMeshAddedObservable = new u.c(), Z.onMeshRemovedObservable = new u.c(), Z.onNewSkeletonAddedObservable = new u.c(), Z.onSkeletonRemovedObservable = new u.c(), Z.onNewMaterialAddedObservable = new u.c(), Z.onNewMultiMaterialAddedObservable = new u.c(), Z.onMaterialRemovedObservable = new u.c(), Z.onMultiMaterialRemovedObservable = new u.c(), Z.onNewTextureAddedObservable = new u.c(), Z.onTextureRemovedObservable = new u.c(), Z.onBeforeRenderTargetsRenderObservable = new u.c(), Z.onAfterRenderTargetsRenderObservable = new u.c(), Z.onBeforeStepObservable = new u.c(), Z.onAfterStepObservable = new u.c(), Z.onActiveCameraChanged = new u.c(), Z.onBeforeRenderingGroupObservable = new u.c(), Z.onAfterRenderingGroupObservable = new u.c(), Z.onMeshImportedObservable = new u.c(), Z.onAnimationFileImportedObservable = new u.c(), Z._registeredForLateAnimationBindings = new I.b(256), Z.onPrePointerObservable = new u.c(), Z.onPointerObservable = new u.c(), Z.onPreKeyboardObservable = new u.c(), Z.onKeyboardObservable = new u.c(), Z._useRightHandedSystem = !1, Z._timeAccumulator = 0, Z._currentStepId = 0, Z._currentInternalStep = 0, Z._fogEnabled = !0, Z._fogMode = Y.FOGMODE_NONE, Z.fogColor = new $.a(0.2, 0.2, 0.3), Z.fogDensity = 0.1, Z.fogStart = 0, Z.fogEnd = 1e3, Z.prePass = !1, Z._shadowsEnabled = !0, Z._lightsEnabled = !0, Z.activeCameras = new Array(), Z._texturesEnabled = !0, Z.physicsEnabled = !0, Z.particlesEnabled = !0, Z.spritesEnabled = !0, Z._skeletonsEnabled = !0, Z.lensFlaresEnabled = !0, Z.collisionsEnabled = !0, Z.gravity = new m.e(0, -9.807, 0), Z.postProcessesEnabled = !0, Z.renderTargetsEnabled = !0, Z.dumpNextRenderTargets = !1, Z.customRenderTargets = new Array(), Z.importedMeshesFiles = new Array(), Z.probesEnabled = !0, Z._meshesForIntersections = new I.b(256), Z.proceduralTexturesEnabled = !0, Z._totalVertices = new K.a(), Z._activeIndices = new K.a(), Z._activeParticles = new K.a(), Z._activeBones = new K.a(), Z._animationTime = 0, Z.animationTimeScale = 1, Z._renderId = 0, Z._frameId = 0, Z._executeWhenReadyTimeoutId = -1, Z._intermediateRendering = !1, Z._viewUpdateFlag = -1, Z._projectionUpdateFlag = -1, Z._toBeDisposed = new Array(256), Z._activeRequests = new Array(), Z._pendingData = new Array(), Z._isDisposed = !1, Z.dispatchAllSubMeshesOfActiveMeshes = !1, Z._activeMeshes = new I.a(256), Z._processedMaterials = new I.a(256), Z._renderTargets = new I.b(256), Z._activeParticleSystems = new I.a(256), Z._activeSkeletons = new I.b(32), Z._softwareSkinnedMeshes = new I.b(32), Z._activeAnimatables = new Array(), Z._transformMatrix = m.a.Zero(), Z.requireLightSorting = !1, Z._components = [], Z._serializableComponents = [], Z._transientComponents = [], Z._beforeCameraUpdateStage = N.b.Create(), Z._beforeClearStage = N.b.Create(), Z._gatherRenderTargetsStage = N.b.Create(), Z._gatherActiveCameraRenderTargetsStage = N.b.Create(), Z._isReadyForMeshStage = N.b.Create(), Z._beforeEvaluateActiveMeshStage = N.b.Create(), Z._evaluateSubMeshStage = N.b.Create(), Z._preActiveMeshStage = N.b.Create(), Z._cameraDrawRenderTargetStage = N.b.Create(), Z._beforeCameraDrawStage = N.b.Create(), Z._beforeRenderTargetDrawStage = N.b.Create(), Z._beforeRenderingGroupDrawStage = N.b.Create(), Z._beforeRenderingMeshStage = N.b.Create(), Z._afterRenderingMeshStage = N.b.Create(), Z._afterRenderingGroupDrawStage = N.b.Create(), Z._afterCameraDrawStage = N.b.Create(), Z._afterRenderTargetDrawStage = N.b.Create(), Z._afterRenderStage = N.b.Create(), Z._pointerMoveStage = N.b.Create(), Z._pointerDownStage = N.b.Create(), Z._pointerUpStage = N.b.Create(), Z.geometriesByUniqueId = null, Z._defaultMeshCandidates = { data: [], length: 0 }, Z._defaultSubMeshCandidates = { data: [], length: 0 }, Z._preventFreeActiveMeshesAndRenderingGroups = !1, Z._activeMeshesFrozen = !1, Z._skipEvaluateActiveMeshesCompletely = !1, Z._allowPostProcessClearColor = !0, Z.getDeterministicFrameTime = function() {
+ return Z._engine.getTimeStep();
+ }, Z._blockMaterialDirtyMechanism = !1;
+ var W = Object(V.a)({ useGeometryUniqueIdsMap: !0, useMaterialMeshMap: !0, useClonedMeshMap: !0, virtual: !1 }, H);
+ return Z._engine = k || j.a.LastCreatedEngine, W.virtual || (j.a._LastCreatedScene = Z, Z._engine.scenes.push(Z)), Z._uid = null, Z._renderingManager = new w.b(Z), D.a && (Z.postProcessManager = new D.a(Z)), U.a.IsWindowObjectExist() && Z.attachControl(), Z._createUbo(), g.a && (Z._imageProcessingConfiguration = new g.a()), Z.setDefaultCandidateProviders(), W.useGeometryUniqueIdsMap && (Z.geometriesByUniqueId = {}), Z.useMaterialMeshMap = W.useMaterialMeshMap, Z.useClonedMeshMap = W.useClonedMeshMap, H && H.virtual || Z._engine.onNewSceneAddedObservable.notifyObservers(Z), Z;
+ }
+ return Object(V.d)(Y, re), Y.DefaultMaterialFactory = function(k) {
+ throw ne.a.WarnImport("StandardMaterial");
+ }, Y.CollisionCoordinatorFactory = function() {
+ throw ne.a.WarnImport("DefaultCollisionCoordinator");
+ }, Object.defineProperty(Y.prototype, "environmentTexture", { get: function() {
+ return this._environmentTexture;
+ }, set: function(k) {
+ this._environmentTexture !== k && (this._environmentTexture = k, this.markAllMaterialsAsDirty(M.a.MATERIAL_TextureDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(Y.prototype, "environmentIntensity", { get: function() {
+ return this._environmentIntensity;
+ }, set: function(k) {
+ this._environmentIntensity !== k && (this._environmentIntensity = k, this.markAllMaterialsAsDirty(M.a.MATERIAL_TextureDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(Y.prototype, "imageProcessingConfiguration", { get: function() {
+ return this._imageProcessingConfiguration;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(Y.prototype, "forceWireframe", { get: function() {
+ return this._forceWireframe;
+ }, set: function(k) {
+ this._forceWireframe !== k && (this._forceWireframe = k, this.markAllMaterialsAsDirty(M.a.MATERIAL_MiscDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(Y.prototype, "skipFrustumClipping", { get: function() {
+ return this._skipFrustumClipping;
+ }, set: function(k) {
+ this._skipFrustumClipping !== k && (this._skipFrustumClipping = k);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(Y.prototype, "forcePointsCloud", { get: function() {
+ return this._forcePointsCloud;
+ }, set: function(k) {
+ this._forcePointsCloud !== k && (this._forcePointsCloud = k, this.markAllMaterialsAsDirty(M.a.MATERIAL_MiscDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(Y.prototype, "animationPropertiesOverride", { get: function() {
+ return this._animationPropertiesOverride;
+ }, set: function(k) {
+ this._animationPropertiesOverride = k;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(Y.prototype, "onDispose", { set: function(k) {
+ this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver), this._onDisposeObserver = this.onDisposeObservable.add(k);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(Y.prototype, "beforeRender", { set: function(k) {
+ this._onBeforeRenderObserver && this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver), k && (this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(k));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(Y.prototype, "afterRender", { set: function(k) {
+ this._onAfterRenderObserver && this.onAfterRenderObservable.remove(this._onAfterRenderObserver), k && (this._onAfterRenderObserver = this.onAfterRenderObservable.add(k));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(Y.prototype, "beforeCameraRender", { set: function(k) {
+ this._onBeforeCameraRenderObserver && this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver), this._onBeforeCameraRenderObserver = this.onBeforeCameraRenderObservable.add(k);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(Y.prototype, "afterCameraRender", { set: function(k) {
+ this._onAfterCameraRenderObserver && this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver), this._onAfterCameraRenderObserver = this.onAfterCameraRenderObservable.add(k);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(Y.prototype, "unTranslatedPointer", { get: function() {
+ return this._inputManager.unTranslatedPointer;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(Y, "DragMovementThreshold", { get: function() {
+ return ee.DragMovementThreshold;
+ }, set: function(k) {
+ ee.DragMovementThreshold = k;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(Y, "LongPressDelay", { get: function() {
+ return ee.LongPressDelay;
+ }, set: function(k) {
+ ee.LongPressDelay = k;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(Y, "DoubleClickDelay", { get: function() {
+ return ee.DoubleClickDelay;
+ }, set: function(k) {
+ ee.DoubleClickDelay = k;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(Y, "ExclusiveDoubleClickMode", { get: function() {
+ return ee.ExclusiveDoubleClickMode;
+ }, set: function(k) {
+ ee.ExclusiveDoubleClickMode = k;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(Y.prototype, "useRightHandedSystem", { get: function() {
+ return this._useRightHandedSystem;
+ }, set: function(k) {
+ this._useRightHandedSystem !== k && (this._useRightHandedSystem = k, this.markAllMaterialsAsDirty(M.a.MATERIAL_MiscDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Y.prototype.setStepId = function(k) {
+ this._currentStepId = k;
+ }, Y.prototype.getStepId = function() {
+ return this._currentStepId;
+ }, Y.prototype.getInternalStep = function() {
+ return this._currentInternalStep;
+ }, Object.defineProperty(Y.prototype, "fogEnabled", { get: function() {
+ return this._fogEnabled;
+ }, set: function(k) {
+ this._fogEnabled !== k && (this._fogEnabled = k, this.markAllMaterialsAsDirty(M.a.MATERIAL_MiscDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(Y.prototype, "fogMode", { get: function() {
+ return this._fogMode;
+ }, set: function(k) {
+ this._fogMode !== k && (this._fogMode = k, this.markAllMaterialsAsDirty(M.a.MATERIAL_MiscDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(Y.prototype, "shadowsEnabled", { get: function() {
+ return this._shadowsEnabled;
+ }, set: function(k) {
+ this._shadowsEnabled !== k && (this._shadowsEnabled = k, this.markAllMaterialsAsDirty(M.a.MATERIAL_LightDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(Y.prototype, "lightsEnabled", { get: function() {
+ return this._lightsEnabled;
+ }, set: function(k) {
+ this._lightsEnabled !== k && (this._lightsEnabled = k, this.markAllMaterialsAsDirty(M.a.MATERIAL_LightDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(Y.prototype, "activeCamera", { get: function() {
+ return this._activeCamera;
+ }, set: function(k) {
+ k !== this._activeCamera && (this._activeCamera = k, this.onActiveCameraChanged.notifyObservers(this));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(Y.prototype, "defaultMaterial", { get: function() {
+ return this._defaultMaterial || (this._defaultMaterial = Y.DefaultMaterialFactory(this)), this._defaultMaterial;
+ }, set: function(k) {
+ this._defaultMaterial = k;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(Y.prototype, "texturesEnabled", { get: function() {
+ return this._texturesEnabled;
+ }, set: function(k) {
+ this._texturesEnabled !== k && (this._texturesEnabled = k, this.markAllMaterialsAsDirty(M.a.MATERIAL_TextureDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(Y.prototype, "skeletonsEnabled", { get: function() {
+ return this._skeletonsEnabled;
+ }, set: function(k) {
+ this._skeletonsEnabled !== k && (this._skeletonsEnabled = k, this.markAllMaterialsAsDirty(M.a.MATERIAL_AttributesDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(Y.prototype, "collisionCoordinator", { get: function() {
+ return this._collisionCoordinator || (this._collisionCoordinator = Y.CollisionCoordinatorFactory(), this._collisionCoordinator.init(this)), this._collisionCoordinator;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(Y.prototype, "frustumPlanes", { get: function() {
+ return this._frustumPlanes;
+ }, enumerable: !1, configurable: !0 }), Y.prototype._registerTransientComponents = function() {
+ if (this._transientComponents.length > 0) {
+ for (var k = 0, H = this._transientComponents; k < H.length; k++)
+ H[k].register();
+ this._transientComponents = [];
+ }
+ }, Y.prototype._addComponent = function(k) {
+ this._components.push(k), this._transientComponents.push(k);
+ var H = k;
+ H.addFromContainer && H.serialize && this._serializableComponents.push(H);
+ }, Y.prototype._getComponent = function(k) {
+ for (var H = 0, Z = this._components; H < Z.length; H++) {
+ var W = Z[H];
+ if (W.name === k)
+ return W;
+ }
+ return null;
+ }, Y.prototype.getClassName = function() {
+ return "Scene";
+ }, Y.prototype._getDefaultMeshCandidates = function() {
+ return this._defaultMeshCandidates.data = this.meshes, this._defaultMeshCandidates.length = this.meshes.length, this._defaultMeshCandidates;
+ }, Y.prototype._getDefaultSubMeshCandidates = function(k) {
+ return this._defaultSubMeshCandidates.data = k.subMeshes, this._defaultSubMeshCandidates.length = k.subMeshes.length, this._defaultSubMeshCandidates;
+ }, Y.prototype.setDefaultCandidateProviders = function() {
+ this.getActiveMeshCandidates = this._getDefaultMeshCandidates.bind(this), this.getActiveSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this), this.getIntersectingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this), this.getCollidingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
+ }, Object.defineProperty(Y.prototype, "meshUnderPointer", { get: function() {
+ return this._inputManager.meshUnderPointer;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(Y.prototype, "pointerX", { get: function() {
+ return this._inputManager.pointerX;
+ }, set: function(k) {
+ this._inputManager.pointerX = k;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(Y.prototype, "pointerY", { get: function() {
+ return this._inputManager.pointerY;
+ }, set: function(k) {
+ this._inputManager.pointerY = k;
+ }, enumerable: !1, configurable: !0 }), Y.prototype.getCachedMaterial = function() {
+ return this._cachedMaterial;
+ }, Y.prototype.getCachedEffect = function() {
+ return this._cachedEffect;
+ }, Y.prototype.getCachedVisibility = function() {
+ return this._cachedVisibility;
+ }, Y.prototype.isCachedMaterialInvalid = function(k, H, Z) {
+ return Z === void 0 && (Z = 1), this._cachedEffect !== H || this._cachedMaterial !== k || this._cachedVisibility !== Z;
+ }, Y.prototype.getEngine = function() {
+ return this._engine;
+ }, Y.prototype.getTotalVertices = function() {
+ return this._totalVertices.current;
+ }, Object.defineProperty(Y.prototype, "totalVerticesPerfCounter", { get: function() {
+ return this._totalVertices;
+ }, enumerable: !1, configurable: !0 }), Y.prototype.getActiveIndices = function() {
+ return this._activeIndices.current;
+ }, Object.defineProperty(Y.prototype, "totalActiveIndicesPerfCounter", { get: function() {
+ return this._activeIndices;
+ }, enumerable: !1, configurable: !0 }), Y.prototype.getActiveParticles = function() {
+ return this._activeParticles.current;
+ }, Object.defineProperty(Y.prototype, "activeParticlesPerfCounter", { get: function() {
+ return this._activeParticles;
+ }, enumerable: !1, configurable: !0 }), Y.prototype.getActiveBones = function() {
+ return this._activeBones.current;
+ }, Object.defineProperty(Y.prototype, "activeBonesPerfCounter", { get: function() {
+ return this._activeBones;
+ }, enumerable: !1, configurable: !0 }), Y.prototype.getActiveMeshes = function() {
+ return this._activeMeshes;
+ }, Y.prototype.getAnimationRatio = function() {
+ return this._animationRatio !== void 0 ? this._animationRatio : 1;
+ }, Y.prototype.getRenderId = function() {
+ return this._renderId;
+ }, Y.prototype.getFrameId = function() {
+ return this._frameId;
+ }, Y.prototype.incrementRenderId = function() {
+ this._renderId++;
+ }, Y.prototype._createUbo = function() {
+ this._sceneUbo = new l.a(this._engine, void 0, !0), this._sceneUbo.addUniform("viewProjection", 16), this._sceneUbo.addUniform("view", 16);
+ }, Y.prototype.simulatePointerMove = function(k, H) {
+ return this._inputManager.simulatePointerMove(k, H), this;
+ }, Y.prototype.simulatePointerDown = function(k, H) {
+ return this._inputManager.simulatePointerDown(k, H), this;
+ }, Y.prototype.simulatePointerUp = function(k, H, Z) {
+ return this._inputManager.simulatePointerUp(k, H, Z), this;
+ }, Y.prototype.isPointerCaptured = function(k) {
+ return k === void 0 && (k = 0), this._inputManager.isPointerCaptured(k);
+ }, Y.prototype.attachControl = function(k, H, Z) {
+ k === void 0 && (k = !0), H === void 0 && (H = !0), Z === void 0 && (Z = !0), this._inputManager.attachControl(k, H, Z);
+ }, Y.prototype.detachControl = function() {
+ this._inputManager.detachControl();
+ }, Y.prototype.isReady = function() {
+ if (this._isDisposed)
+ return !1;
+ var k, H = this.getEngine();
+ if (!H.areAllEffectsReady() || this._pendingData.length > 0)
+ return !1;
+ for (k = 0; k < this.meshes.length; k++) {
+ var Z = this.meshes[k];
+ if (Z.isEnabled() && Z.subMeshes && Z.subMeshes.length !== 0) {
+ if (!Z.isReady(!0))
+ return !1;
+ for (var W = Z.hasThinInstances || Z.getClassName() === "InstancedMesh" || Z.getClassName() === "InstancedLinesMesh" || H.getCaps().instancedArrays && Z.instances.length > 0, q = 0, he = this._isReadyForMeshStage; q < he.length; q++)
+ if (!he[q].action(Z, W))
+ return !1;
+ }
+ }
+ for (k = 0; k < this.geometries.length; k++)
+ if (this.geometries[k].delayLoadState === M.a.DELAYLOADSTATE_LOADING)
+ return !1;
+ if (this.activeCameras && this.activeCameras.length > 0) {
+ for (var ge = 0, me = this.activeCameras; ge < me.length; ge++)
+ if (!me[ge].isReady(!0))
+ return !1;
+ } else if (this.activeCamera && !this.activeCamera.isReady(!0))
+ return !1;
+ for (var _e = 0, ye = this.particleSystems; _e < ye.length; _e++)
+ if (!ye[_e].isReady())
+ return !1;
+ return !0;
+ }, Y.prototype.resetCachedMaterial = function() {
+ this._cachedMaterial = null, this._cachedEffect = null, this._cachedVisibility = null;
+ }, Y.prototype.registerBeforeRender = function(k) {
+ this.onBeforeRenderObservable.add(k);
+ }, Y.prototype.unregisterBeforeRender = function(k) {
+ this.onBeforeRenderObservable.removeCallback(k);
+ }, Y.prototype.registerAfterRender = function(k) {
+ this.onAfterRenderObservable.add(k);
+ }, Y.prototype.unregisterAfterRender = function(k) {
+ this.onAfterRenderObservable.removeCallback(k);
+ }, Y.prototype._executeOnceBeforeRender = function(k) {
+ var H = this, Z = function() {
+ k(), setTimeout(function() {
+ H.unregisterBeforeRender(Z);
+ });
+ };
+ this.registerBeforeRender(Z);
+ }, Y.prototype.executeOnceBeforeRender = function(k, H) {
+ var Z = this;
+ H !== void 0 ? setTimeout(function() {
+ Z._executeOnceBeforeRender(k);
+ }, H) : this._executeOnceBeforeRender(k);
+ }, Y.prototype._addPendingData = function(k) {
+ this._pendingData.push(k);
+ }, Y.prototype._removePendingData = function(k) {
+ var H = this.isLoading, Z = this._pendingData.indexOf(k);
+ Z !== -1 && this._pendingData.splice(Z, 1), H && !this.isLoading && this.onDataLoadedObservable.notifyObservers(this);
+ }, Y.prototype.getWaitingItemsCount = function() {
+ return this._pendingData.length;
+ }, Object.defineProperty(Y.prototype, "isLoading", { get: function() {
+ return this._pendingData.length > 0;
+ }, enumerable: !1, configurable: !0 }), Y.prototype.executeWhenReady = function(k) {
+ var H = this;
+ this.onReadyObservable.add(k), this._executeWhenReadyTimeoutId === -1 && (this._executeWhenReadyTimeoutId = setTimeout(function() {
+ H._checkIsReady();
+ }, 150));
+ }, Y.prototype.whenReadyAsync = function() {
+ var k = this;
+ return new Promise(function(H) {
+ k.executeWhenReady(function() {
+ H();
+ });
+ });
+ }, Y.prototype._checkIsReady = function() {
+ var k = this;
+ return this._registerTransientComponents(), this.isReady() ? (this.onReadyObservable.notifyObservers(this), this.onReadyObservable.clear(), void (this._executeWhenReadyTimeoutId = -1)) : this._isDisposed ? (this.onReadyObservable.clear(), void (this._executeWhenReadyTimeoutId = -1)) : void (this._executeWhenReadyTimeoutId = setTimeout(function() {
+ k._checkIsReady();
+ }, 150));
+ }, Object.defineProperty(Y.prototype, "animatables", { get: function() {
+ return this._activeAnimatables;
+ }, enumerable: !1, configurable: !0 }), Y.prototype.resetLastAnimationTimeFrame = function() {
+ this._animationTimeLast = C.a.Now;
+ }, Y.prototype.getViewMatrix = function() {
+ return this._viewMatrix;
+ }, Y.prototype.getProjectionMatrix = function() {
+ return this._projectionMatrix;
+ }, Y.prototype.getTransformMatrix = function() {
+ return this._transformMatrix;
+ }, Y.prototype.setTransformMatrix = function(k, H, Z, W) {
+ this._viewUpdateFlag === k.updateFlag && this._projectionUpdateFlag === H.updateFlag || (this._viewUpdateFlag = k.updateFlag, this._projectionUpdateFlag = H.updateFlag, this._viewMatrix = k, this._projectionMatrix = H, this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix), this._frustumPlanes ? L.a.GetPlanesToRef(this._transformMatrix, this._frustumPlanes) : this._frustumPlanes = L.a.GetPlanes(this._transformMatrix), this._multiviewSceneUbo && this._multiviewSceneUbo.useUbo ? this._updateMultiviewUbo(Z, W) : this._sceneUbo.useUbo && (this._sceneUbo.updateMatrix("viewProjection", this._transformMatrix), this._sceneUbo.updateMatrix("view", this._viewMatrix), this._sceneUbo.update()));
+ }, Y.prototype.getSceneUniformBuffer = function() {
+ return this._multiviewSceneUbo ? this._multiviewSceneUbo : this._sceneUbo;
+ }, Y.prototype.getUniqueId = function() {
+ return G.a.UniqueId;
+ }, Y.prototype.addMesh = function(k, H) {
+ var Z = this;
+ H === void 0 && (H = !1), this._blockEntityCollection || (this.meshes.push(k), k._resyncLightSources(), k.parent || k._addToSceneRootNodes(), this.onNewMeshAddedObservable.notifyObservers(k), H && k.getChildMeshes().forEach(function(W) {
+ Z.addMesh(W);
+ }));
+ }, Y.prototype.removeMesh = function(k, H) {
+ var Z = this;
+ H === void 0 && (H = !1);
+ var W = this.meshes.indexOf(k);
+ return W !== -1 && (this.meshes[W] = this.meshes[this.meshes.length - 1], this.meshes.pop(), k.parent || k._removeFromSceneRootNodes()), this.onMeshRemovedObservable.notifyObservers(k), H && k.getChildMeshes().forEach(function(q) {
+ Z.removeMesh(q);
+ }), W;
+ }, Y.prototype.addTransformNode = function(k) {
+ this._blockEntityCollection || (k._indexInSceneTransformNodesArray = this.transformNodes.length, this.transformNodes.push(k), k.parent || k._addToSceneRootNodes(), this.onNewTransformNodeAddedObservable.notifyObservers(k));
+ }, Y.prototype.removeTransformNode = function(k) {
+ var H = k._indexInSceneTransformNodesArray;
+ if (H !== -1) {
+ if (H !== this.transformNodes.length - 1) {
+ var Z = this.transformNodes[this.transformNodes.length - 1];
+ this.transformNodes[H] = Z, Z._indexInSceneTransformNodesArray = H;
+ }
+ k._indexInSceneTransformNodesArray = -1, this.transformNodes.pop(), k.parent || k._removeFromSceneRootNodes();
+ }
+ return this.onTransformNodeRemovedObservable.notifyObservers(k), H;
+ }, Y.prototype.removeSkeleton = function(k) {
+ var H = this.skeletons.indexOf(k);
+ return H !== -1 && (this.skeletons.splice(H, 1), this.onSkeletonRemovedObservable.notifyObservers(k)), H;
+ }, Y.prototype.removeMorphTargetManager = function(k) {
+ var H = this.morphTargetManagers.indexOf(k);
+ return H !== -1 && this.morphTargetManagers.splice(H, 1), H;
+ }, Y.prototype.removeLight = function(k) {
+ var H = this.lights.indexOf(k);
+ if (H !== -1) {
+ for (var Z = 0, W = this.meshes; Z < W.length; Z++)
+ W[Z]._removeLightSource(k, !1);
+ this.lights.splice(H, 1), this.sortLightsByPriority(), k.parent || k._removeFromSceneRootNodes();
+ }
+ return this.onLightRemovedObservable.notifyObservers(k), H;
+ }, Y.prototype.removeCamera = function(k) {
+ var H = this.cameras.indexOf(k);
+ if (H !== -1 && (this.cameras.splice(H, 1), k.parent || k._removeFromSceneRootNodes()), this.activeCameras) {
+ var Z = this.activeCameras.indexOf(k);
+ Z !== -1 && this.activeCameras.splice(Z, 1);
+ }
+ return this.activeCamera === k && (this.cameras.length > 0 ? this.activeCamera = this.cameras[0] : this.activeCamera = null), this.onCameraRemovedObservable.notifyObservers(k), H;
+ }, Y.prototype.removeParticleSystem = function(k) {
+ var H = this.particleSystems.indexOf(k);
+ return H !== -1 && this.particleSystems.splice(H, 1), H;
+ }, Y.prototype.removeAnimation = function(k) {
+ var H = this.animations.indexOf(k);
+ return H !== -1 && this.animations.splice(H, 1), H;
+ }, Y.prototype.stopAnimation = function(k, H, Z) {
+ }, Y.prototype.removeAnimationGroup = function(k) {
+ var H = this.animationGroups.indexOf(k);
+ return H !== -1 && this.animationGroups.splice(H, 1), H;
+ }, Y.prototype.removeMultiMaterial = function(k) {
+ var H = this.multiMaterials.indexOf(k);
+ return H !== -1 && this.multiMaterials.splice(H, 1), this.onMultiMaterialRemovedObservable.notifyObservers(k), H;
+ }, Y.prototype.removeMaterial = function(k) {
+ var H = k._indexInSceneMaterialArray;
+ if (H !== -1 && H < this.materials.length) {
+ if (H !== this.materials.length - 1) {
+ var Z = this.materials[this.materials.length - 1];
+ this.materials[H] = Z, Z._indexInSceneMaterialArray = H;
+ }
+ k._indexInSceneMaterialArray = -1, this.materials.pop();
+ }
+ return this.onMaterialRemovedObservable.notifyObservers(k), H;
+ }, Y.prototype.removeActionManager = function(k) {
+ var H = this.actionManagers.indexOf(k);
+ return H !== -1 && this.actionManagers.splice(H, 1), H;
+ }, Y.prototype.removeTexture = function(k) {
+ var H = this.textures.indexOf(k);
+ return H !== -1 && this.textures.splice(H, 1), this.onTextureRemovedObservable.notifyObservers(k), H;
+ }, Y.prototype.addLight = function(k) {
+ if (!this._blockEntityCollection) {
+ this.lights.push(k), this.sortLightsByPriority(), k.parent || k._addToSceneRootNodes();
+ for (var H = 0, Z = this.meshes; H < Z.length; H++) {
+ var W = Z[H];
+ W.lightSources.indexOf(k) === -1 && (W.lightSources.push(k), W._resyncLightSources());
+ }
+ this.onNewLightAddedObservable.notifyObservers(k);
+ }
+ }, Y.prototype.sortLightsByPriority = function() {
+ this.requireLightSorting && this.lights.sort(h.a.CompareLightsPriority);
+ }, Y.prototype.addCamera = function(k) {
+ this._blockEntityCollection || (this.cameras.push(k), this.onNewCameraAddedObservable.notifyObservers(k), k.parent || k._addToSceneRootNodes());
+ }, Y.prototype.addSkeleton = function(k) {
+ this._blockEntityCollection || (this.skeletons.push(k), this.onNewSkeletonAddedObservable.notifyObservers(k));
+ }, Y.prototype.addParticleSystem = function(k) {
+ this._blockEntityCollection || this.particleSystems.push(k);
+ }, Y.prototype.addAnimation = function(k) {
+ this._blockEntityCollection || this.animations.push(k);
+ }, Y.prototype.addAnimationGroup = function(k) {
+ this._blockEntityCollection || this.animationGroups.push(k);
+ }, Y.prototype.addMultiMaterial = function(k) {
+ this._blockEntityCollection || (this.multiMaterials.push(k), this.onNewMultiMaterialAddedObservable.notifyObservers(k));
+ }, Y.prototype.addMaterial = function(k) {
+ this._blockEntityCollection || (k._indexInSceneMaterialArray = this.materials.length, this.materials.push(k), this.onNewMaterialAddedObservable.notifyObservers(k));
+ }, Y.prototype.addMorphTargetManager = function(k) {
+ this._blockEntityCollection || this.morphTargetManagers.push(k);
+ }, Y.prototype.addGeometry = function(k) {
+ this._blockEntityCollection || (this.geometriesByUniqueId && (this.geometriesByUniqueId[k.uniqueId] = this.geometries.length), this.geometries.push(k));
+ }, Y.prototype.addActionManager = function(k) {
+ this.actionManagers.push(k);
+ }, Y.prototype.addTexture = function(k) {
+ this._blockEntityCollection || (this.textures.push(k), this.onNewTextureAddedObservable.notifyObservers(k));
+ }, Y.prototype.switchActiveCamera = function(k, H) {
+ H === void 0 && (H = !0), this._engine.getInputElement() && (this.activeCamera && this.activeCamera.detachControl(), this.activeCamera = k, H && k.attachControl());
+ }, Y.prototype.setActiveCameraByID = function(k) {
+ var H = this.getCameraByID(k);
+ return H ? (this.activeCamera = H, H) : null;
+ }, Y.prototype.setActiveCameraByName = function(k) {
+ var H = this.getCameraByName(k);
+ return H ? (this.activeCamera = H, H) : null;
+ }, Y.prototype.getAnimationGroupByName = function(k) {
+ for (var H = 0; H < this.animationGroups.length; H++)
+ if (this.animationGroups[H].name === k)
+ return this.animationGroups[H];
+ return null;
+ }, Y.prototype.getMaterialByUniqueID = function(k) {
+ for (var H = 0; H < this.materials.length; H++)
+ if (this.materials[H].uniqueId === k)
+ return this.materials[H];
+ return null;
+ }, Y.prototype.getMaterialByID = function(k) {
+ for (var H = 0; H < this.materials.length; H++)
+ if (this.materials[H].id === k)
+ return this.materials[H];
+ return null;
+ }, Y.prototype.getLastMaterialByID = function(k) {
+ for (var H = this.materials.length - 1; H >= 0; H--)
+ if (this.materials[H].id === k)
+ return this.materials[H];
+ return null;
+ }, Y.prototype.getMaterialByName = function(k) {
+ for (var H = 0; H < this.materials.length; H++)
+ if (this.materials[H].name === k)
+ return this.materials[H];
+ return null;
+ }, Y.prototype.getTextureByUniqueID = function(k) {
+ for (var H = 0; H < this.textures.length; H++)
+ if (this.textures[H].uniqueId === k)
+ return this.textures[H];
+ return null;
+ }, Y.prototype.getCameraByID = function(k) {
+ for (var H = 0; H < this.cameras.length; H++)
+ if (this.cameras[H].id === k)
+ return this.cameras[H];
+ return null;
+ }, Y.prototype.getCameraByUniqueID = function(k) {
+ for (var H = 0; H < this.cameras.length; H++)
+ if (this.cameras[H].uniqueId === k)
+ return this.cameras[H];
+ return null;
+ }, Y.prototype.getCameraByName = function(k) {
+ for (var H = 0; H < this.cameras.length; H++)
+ if (this.cameras[H].name === k)
+ return this.cameras[H];
+ return null;
+ }, Y.prototype.getBoneByID = function(k) {
+ for (var H = 0; H < this.skeletons.length; H++)
+ for (var Z = this.skeletons[H], W = 0; W < Z.bones.length; W++)
+ if (Z.bones[W].id === k)
+ return Z.bones[W];
+ return null;
+ }, Y.prototype.getBoneByName = function(k) {
+ for (var H = 0; H < this.skeletons.length; H++)
+ for (var Z = this.skeletons[H], W = 0; W < Z.bones.length; W++)
+ if (Z.bones[W].name === k)
+ return Z.bones[W];
+ return null;
+ }, Y.prototype.getLightByName = function(k) {
+ for (var H = 0; H < this.lights.length; H++)
+ if (this.lights[H].name === k)
+ return this.lights[H];
+ return null;
+ }, Y.prototype.getLightByID = function(k) {
+ for (var H = 0; H < this.lights.length; H++)
+ if (this.lights[H].id === k)
+ return this.lights[H];
+ return null;
+ }, Y.prototype.getLightByUniqueID = function(k) {
+ for (var H = 0; H < this.lights.length; H++)
+ if (this.lights[H].uniqueId === k)
+ return this.lights[H];
+ return null;
+ }, Y.prototype.getParticleSystemByID = function(k) {
+ for (var H = 0; H < this.particleSystems.length; H++)
+ if (this.particleSystems[H].id === k)
+ return this.particleSystems[H];
+ return null;
+ }, Y.prototype.getGeometryByID = function(k) {
+ for (var H = 0; H < this.geometries.length; H++)
+ if (this.geometries[H].id === k)
+ return this.geometries[H];
+ return null;
+ }, Y.prototype._getGeometryByUniqueID = function(k) {
+ if (this.geometriesByUniqueId) {
+ var H = this.geometriesByUniqueId[k];
+ if (H !== void 0)
+ return this.geometries[H];
+ } else
+ for (var Z = 0; Z < this.geometries.length; Z++)
+ if (this.geometries[Z].uniqueId === k)
+ return this.geometries[Z];
+ return null;
+ }, Y.prototype.pushGeometry = function(k, H) {
+ return !(!H && this._getGeometryByUniqueID(k.uniqueId)) && (this.addGeometry(k), this.onNewGeometryAddedObservable.notifyObservers(k), !0);
+ }, Y.prototype.removeGeometry = function(k) {
+ var H;
+ if (this.geometriesByUniqueId) {
+ if ((H = this.geometriesByUniqueId[k.uniqueId]) === void 0)
+ return !1;
+ } else if ((H = this.geometries.indexOf(k)) < 0)
+ return !1;
+ if (H !== this.geometries.length - 1) {
+ var Z = this.geometries[this.geometries.length - 1];
+ Z && (this.geometries[H] = Z, this.geometriesByUniqueId && (this.geometriesByUniqueId[Z.uniqueId] = H, this.geometriesByUniqueId[k.uniqueId] = void 0));
+ }
+ return this.geometries.pop(), this.onGeometryRemovedObservable.notifyObservers(k), !0;
+ }, Y.prototype.getGeometries = function() {
+ return this.geometries;
+ }, Y.prototype.getMeshByID = function(k) {
+ for (var H = 0; H < this.meshes.length; H++)
+ if (this.meshes[H].id === k)
+ return this.meshes[H];
+ return null;
+ }, Y.prototype.getMeshesByID = function(k) {
+ return this.meshes.filter(function(H) {
+ return H.id === k;
+ });
+ }, Y.prototype.getTransformNodeByID = function(k) {
+ for (var H = 0; H < this.transformNodes.length; H++)
+ if (this.transformNodes[H].id === k)
+ return this.transformNodes[H];
+ return null;
+ }, Y.prototype.getTransformNodeByUniqueID = function(k) {
+ for (var H = 0; H < this.transformNodes.length; H++)
+ if (this.transformNodes[H].uniqueId === k)
+ return this.transformNodes[H];
+ return null;
+ }, Y.prototype.getTransformNodesByID = function(k) {
+ return this.transformNodes.filter(function(H) {
+ return H.id === k;
+ });
+ }, Y.prototype.getMeshByUniqueID = function(k) {
+ for (var H = 0; H < this.meshes.length; H++)
+ if (this.meshes[H].uniqueId === k)
+ return this.meshes[H];
+ return null;
+ }, Y.prototype.getLastMeshByID = function(k) {
+ for (var H = this.meshes.length - 1; H >= 0; H--)
+ if (this.meshes[H].id === k)
+ return this.meshes[H];
+ return null;
+ }, Y.prototype.getLastEntryByID = function(k) {
+ var H;
+ for (H = this.meshes.length - 1; H >= 0; H--)
+ if (this.meshes[H].id === k)
+ return this.meshes[H];
+ for (H = this.transformNodes.length - 1; H >= 0; H--)
+ if (this.transformNodes[H].id === k)
+ return this.transformNodes[H];
+ for (H = this.cameras.length - 1; H >= 0; H--)
+ if (this.cameras[H].id === k)
+ return this.cameras[H];
+ for (H = this.lights.length - 1; H >= 0; H--)
+ if (this.lights[H].id === k)
+ return this.lights[H];
+ return null;
+ }, Y.prototype.getNodeByID = function(k) {
+ var H = this.getMeshByID(k);
+ if (H)
+ return H;
+ var Z = this.getTransformNodeByID(k);
+ if (Z)
+ return Z;
+ var W = this.getLightByID(k);
+ if (W)
+ return W;
+ var q = this.getCameraByID(k);
+ if (q)
+ return q;
+ var he = this.getBoneByID(k);
+ return he || null;
+ }, Y.prototype.getNodeByName = function(k) {
+ var H = this.getMeshByName(k);
+ if (H)
+ return H;
+ var Z = this.getTransformNodeByName(k);
+ if (Z)
+ return Z;
+ var W = this.getLightByName(k);
+ if (W)
+ return W;
+ var q = this.getCameraByName(k);
+ if (q)
+ return q;
+ var he = this.getBoneByName(k);
+ return he || null;
+ }, Y.prototype.getMeshByName = function(k) {
+ for (var H = 0; H < this.meshes.length; H++)
+ if (this.meshes[H].name === k)
+ return this.meshes[H];
+ return null;
+ }, Y.prototype.getTransformNodeByName = function(k) {
+ for (var H = 0; H < this.transformNodes.length; H++)
+ if (this.transformNodes[H].name === k)
+ return this.transformNodes[H];
+ return null;
+ }, Y.prototype.getLastSkeletonByID = function(k) {
+ for (var H = this.skeletons.length - 1; H >= 0; H--)
+ if (this.skeletons[H].id === k)
+ return this.skeletons[H];
+ return null;
+ }, Y.prototype.getSkeletonByUniqueId = function(k) {
+ for (var H = 0; H < this.skeletons.length; H++)
+ if (this.skeletons[H].uniqueId === k)
+ return this.skeletons[H];
+ return null;
+ }, Y.prototype.getSkeletonById = function(k) {
+ for (var H = 0; H < this.skeletons.length; H++)
+ if (this.skeletons[H].id === k)
+ return this.skeletons[H];
+ return null;
+ }, Y.prototype.getSkeletonByName = function(k) {
+ for (var H = 0; H < this.skeletons.length; H++)
+ if (this.skeletons[H].name === k)
+ return this.skeletons[H];
+ return null;
+ }, Y.prototype.getMorphTargetManagerById = function(k) {
+ for (var H = 0; H < this.morphTargetManagers.length; H++)
+ if (this.morphTargetManagers[H].uniqueId === k)
+ return this.morphTargetManagers[H];
+ return null;
+ }, Y.prototype.getMorphTargetById = function(k) {
+ for (var H = 0; H < this.morphTargetManagers.length; ++H)
+ for (var Z = this.morphTargetManagers[H], W = 0; W < Z.numTargets; ++W) {
+ var q = Z.getTarget(W);
+ if (q.id === k)
+ return q;
+ }
+ return null;
+ }, Y.prototype.getMorphTargetByName = function(k) {
+ for (var H = 0; H < this.morphTargetManagers.length; ++H)
+ for (var Z = this.morphTargetManagers[H], W = 0; W < Z.numTargets; ++W) {
+ var q = Z.getTarget(W);
+ if (q.name === k)
+ return q;
+ }
+ return null;
+ }, Y.prototype.getPostProcessByName = function(k) {
+ for (var H = 0; H < this.postProcesses.length; ++H) {
+ var Z = this.postProcesses[H];
+ if (Z.name === k)
+ return Z;
+ }
+ return null;
+ }, Y.prototype.isActiveMesh = function(k) {
+ return this._activeMeshes.indexOf(k) !== -1;
+ }, Object.defineProperty(Y.prototype, "uid", { get: function() {
+ return this._uid || (this._uid = _.b.RandomId()), this._uid;
+ }, enumerable: !1, configurable: !0 }), Y.prototype.addExternalData = function(k, H) {
+ return this._externalData || (this._externalData = new O.a()), this._externalData.add(k, H);
+ }, Y.prototype.getExternalData = function(k) {
+ return this._externalData ? this._externalData.get(k) : null;
+ }, Y.prototype.getOrAddExternalDataWithFactory = function(k, H) {
+ return this._externalData || (this._externalData = new O.a()), this._externalData.getOrAddWithFactory(k, H);
+ }, Y.prototype.removeExternalData = function(k) {
+ return this._externalData.remove(k);
+ }, Y.prototype._evaluateSubMesh = function(k, H, Z) {
+ if (Z.hasInstances || Z.isAnInstance || this.dispatchAllSubMeshesOfActiveMeshes || this._skipFrustumClipping || H.alwaysSelectAsActiveMesh || H.subMeshes.length === 1 || k.isInFrustum(this._frustumPlanes)) {
+ for (var W = 0, q = this._evaluateSubMeshStage; W < q.length; W++)
+ q[W].action(H, k);
+ var he = k.getMaterial();
+ he != null && (he.hasRenderTargetTextures && he.getRenderTargetTextures != null && this._processedMaterials.indexOf(he) === -1 && (this._processedMaterials.push(he), this._renderTargets.concatWithNoDuplicate(he.getRenderTargetTextures())), this._renderingManager.dispatch(k, H, he));
+ }
+ }, Y.prototype.freeProcessedMaterials = function() {
+ this._processedMaterials.dispose();
+ }, Object.defineProperty(Y.prototype, "blockfreeActiveMeshesAndRenderingGroups", { get: function() {
+ return this._preventFreeActiveMeshesAndRenderingGroups;
+ }, set: function(k) {
+ this._preventFreeActiveMeshesAndRenderingGroups !== k && (k && (this.freeActiveMeshes(), this.freeRenderingGroups()), this._preventFreeActiveMeshesAndRenderingGroups = k);
+ }, enumerable: !1, configurable: !0 }), Y.prototype.freeActiveMeshes = function() {
+ if (!this.blockfreeActiveMeshesAndRenderingGroups && (this._activeMeshes.dispose(), this.activeCamera && this.activeCamera._activeMeshes && this.activeCamera._activeMeshes.dispose(), this.activeCameras))
+ for (var k = 0; k < this.activeCameras.length; k++) {
+ var H = this.activeCameras[k];
+ H && H._activeMeshes && H._activeMeshes.dispose();
+ }
+ }, Y.prototype.freeRenderingGroups = function() {
+ if (!this.blockfreeActiveMeshesAndRenderingGroups && (this._renderingManager && this._renderingManager.freeRenderingGroups(), this.textures))
+ for (var k = 0; k < this.textures.length; k++) {
+ var H = this.textures[k];
+ H && H.renderList && H.freeRenderingGroups();
+ }
+ }, Y.prototype._isInIntermediateRendering = function() {
+ return this._intermediateRendering;
+ }, Y.prototype.freezeActiveMeshes = function(k, H, Z) {
+ var W = this;
+ return k === void 0 && (k = !1), this.executeWhenReady(function() {
+ if (W.activeCamera) {
+ W._frustumPlanes || W.setTransformMatrix(W.activeCamera.getViewMatrix(), W.activeCamera.getProjectionMatrix()), W._evaluateActiveMeshes(), W._activeMeshesFrozen = !0, W._skipEvaluateActiveMeshesCompletely = k;
+ for (var q = 0; q < W._activeMeshes.length; q++)
+ W._activeMeshes.data[q]._freeze();
+ H && H();
+ } else
+ Z && Z("No active camera found");
+ }), this;
+ }, Y.prototype.unfreezeActiveMeshes = function() {
+ for (var k = 0; k < this.meshes.length; k++) {
+ var H = this.meshes[k];
+ H._internalAbstractMeshDataInfo && (H._internalAbstractMeshDataInfo._isActive = !1);
+ }
+ for (k = 0; k < this._activeMeshes.length; k++)
+ this._activeMeshes.data[k]._unFreeze();
+ return this._activeMeshesFrozen = !1, this;
+ }, Y.prototype._evaluateActiveMeshes = function() {
+ if (this._activeMeshesFrozen && this._activeMeshes.length) {
+ if (!this._skipEvaluateActiveMeshesCompletely)
+ for (var k = this._activeMeshes.length, H = 0; H < k; H++)
+ (me = this._activeMeshes.data[H]).computeWorldMatrix();
+ if (this._activeParticleSystems) {
+ var Z = this._activeParticleSystems.length;
+ for (H = 0; H < Z; H++)
+ this._activeParticleSystems.data[H].animate();
+ }
+ } else if (this.activeCamera) {
+ this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this), this.activeCamera._activeMeshes.reset(), this._activeMeshes.reset(), this._renderingManager.reset(), this._processedMaterials.reset(), this._activeParticleSystems.reset(), this._activeSkeletons.reset(), this._softwareSkinnedMeshes.reset();
+ for (var W = 0, q = this._beforeEvaluateActiveMeshStage; W < q.length; W++)
+ q[W].action();
+ var he = this.getActiveMeshCandidates(), ge = he.length;
+ for (H = 0; H < ge; H++) {
+ var me;
+ if ((me = he.data[H])._internalAbstractMeshDataInfo._currentLODIsUpToDate = !1, !me.isBlocked && (this._totalVertices.addCount(me.getTotalVertices(), !1), me.isReady() && me.isEnabled() && me.scaling.lengthSquared() !== 0)) {
+ me.computeWorldMatrix(), me.actionManager && me.actionManager.hasSpecificTriggers2(M.a.ACTION_OnIntersectionEnterTrigger, M.a.ACTION_OnIntersectionExitTrigger) && this._meshesForIntersections.pushNoDuplicate(me);
+ var _e = this.customLODSelector ? this.customLODSelector(me, this.activeCamera) : me.getLOD(this.activeCamera);
+ if (me._internalAbstractMeshDataInfo._currentLOD = _e, me._internalAbstractMeshDataInfo._currentLODIsUpToDate = !0, _e != null && (_e !== me && _e.billboardMode !== c.a.BILLBOARDMODE_NONE && _e.computeWorldMatrix(), me._preActivate(), me.isVisible && me.visibility > 0 && (me.layerMask & this.activeCamera.layerMask) != 0 && (this._skipFrustumClipping || me.alwaysSelectAsActiveMesh || me.isInFrustum(this._frustumPlanes)))) {
+ this._activeMeshes.push(me), this.activeCamera._activeMeshes.push(me), _e !== me && _e._activate(this._renderId, !1);
+ for (var ye = 0, Pe = this._preActiveMeshStage; ye < Pe.length; ye++)
+ Pe[ye].action(me);
+ me._activate(this._renderId, !1) && (me.isAnInstance ? me._internalAbstractMeshDataInfo._actAsRegularMesh && (_e = me) : _e._internalAbstractMeshDataInfo._onlyForInstances = !1, _e._internalAbstractMeshDataInfo._isActive = !0, this._activeMesh(me, _e)), me._postActivate();
+ }
+ }
+ }
+ if (this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this), this.particlesEnabled) {
+ this.onBeforeParticlesRenderingObservable.notifyObservers(this);
+ for (var be = 0; be < this.particleSystems.length; be++) {
+ var Fe = this.particleSystems[be];
+ if (Fe.isStarted() && Fe.emitter) {
+ var ke = Fe.emitter;
+ ke.position && !ke.isEnabled() || (this._activeParticleSystems.push(Fe), Fe.animate(), this._renderingManager.dispatchParticles(Fe));
+ }
+ }
+ this.onAfterParticlesRenderingObservable.notifyObservers(this);
+ }
+ }
+ }, Y.prototype._activeMesh = function(k, H) {
+ if (this._skeletonsEnabled && H.skeleton !== null && H.skeleton !== void 0 && (this._activeSkeletons.pushNoDuplicate(H.skeleton) && H.skeleton.prepare(), H.computeBonesUsingShaders || this._softwareSkinnedMeshes.pushNoDuplicate(H)), H != null && H.subMeshes !== void 0 && H.subMeshes !== null && H.subMeshes.length > 0)
+ for (var Z = this.getActiveSubMeshCandidates(H), W = Z.length, q = 0; q < W; q++) {
+ var he = Z.data[q];
+ this._evaluateSubMesh(he, H, k);
+ }
+ }, Y.prototype.updateTransformMatrix = function(k) {
+ this.activeCamera && this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(k));
+ }, Y.prototype._bindFrameBuffer = function() {
+ if (this.activeCamera && this.activeCamera._multiviewTexture)
+ this.activeCamera._multiviewTexture._bindFrameBuffer();
+ else if (this.activeCamera && this.activeCamera.outputRenderTarget)
+ if (this.getEngine().getCaps().multiview && this.activeCamera.outputRenderTarget && this.activeCamera.outputRenderTarget.getViewCount() > 1)
+ this.activeCamera.outputRenderTarget._bindFrameBuffer();
+ else {
+ var k = this.activeCamera.outputRenderTarget.getInternalTexture();
+ k ? this.getEngine().bindFramebuffer(k) : X.a.Error("Camera contains invalid customDefaultRenderTarget");
+ }
+ else
+ this.getEngine().restoreDefaultFramebuffer();
+ }, Y.prototype._renderForCamera = function(k, H) {
+ if (!k || !k._skipRendering) {
+ var Z = this._engine;
+ if (this._activeCamera = k, !this.activeCamera)
+ throw new Error("Active camera not set");
+ Z.setViewport(this.activeCamera.viewport), this.resetCachedMaterial(), this._renderId++, this.getEngine().getCaps().multiview && k.outputRenderTarget && k.outputRenderTarget.getViewCount() > 1 ? this.setTransformMatrix(k._rigCameras[0].getViewMatrix(), k._rigCameras[0].getProjectionMatrix(), k._rigCameras[1].getViewMatrix(), k._rigCameras[1].getProjectionMatrix()) : this.updateTransformMatrix(), this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera), this._evaluateActiveMeshes();
+ for (var W = 0; W < this._softwareSkinnedMeshes.length; W++) {
+ var q = this._softwareSkinnedMeshes.data[W];
+ q.applySkeleton(q.skeleton);
+ }
+ this.onBeforeRenderTargetsRenderObservable.notifyObservers(this), k.customRenderTargets && k.customRenderTargets.length > 0 && this._renderTargets.concatWithNoDuplicate(k.customRenderTargets), H && H.customRenderTargets && H.customRenderTargets.length > 0 && this._renderTargets.concatWithNoDuplicate(H.customRenderTargets);
+ for (var he = 0, ge = this._gatherActiveCameraRenderTargetsStage; he < ge.length; he++)
+ ge[he].action(this._renderTargets);
+ var me = !1;
+ if (this.renderTargetsEnabled) {
+ if (this._intermediateRendering = !0, this._renderTargets.length > 0) {
+ _.b.StartPerformanceCounter("Render targets", this._renderTargets.length > 0);
+ for (var _e = 0; _e < this._renderTargets.length; _e++) {
+ var ye = this._renderTargets.data[_e];
+ if (ye._shouldRender()) {
+ this._renderId++;
+ var Pe = ye.activeCamera && ye.activeCamera !== this.activeCamera;
+ ye.render(Pe, this.dumpNextRenderTargets), me = !0;
+ }
+ }
+ _.b.EndPerformanceCounter("Render targets", this._renderTargets.length > 0), this._renderId++;
+ }
+ for (var be = 0, Fe = this._cameraDrawRenderTargetStage; be < Fe.length; be++)
+ me = Fe[be].action(this.activeCamera) || me;
+ this._intermediateRendering = !1, this.activeCamera && this.activeCamera.outputRenderTarget && (me = !0);
+ }
+ me && !this.prePass && this._bindFrameBuffer(), this.onAfterRenderTargetsRenderObservable.notifyObservers(this), !this.postProcessManager || k._multiviewTexture || this.prePass || this.postProcessManager._prepareFrame();
+ for (var ke = 0, We = this._beforeCameraDrawStage; ke < We.length; ke++)
+ We[ke].action(this.activeCamera);
+ this.onBeforeDrawPhaseObservable.notifyObservers(this), this._renderingManager.render(null, null, !0, !0), this.onAfterDrawPhaseObservable.notifyObservers(this);
+ for (var je = 0, He = this._afterCameraDrawStage; je < He.length; je++)
+ He[je].action(this.activeCamera);
+ if (this.postProcessManager && !k._multiviewTexture) {
+ var Qe = k.outputRenderTarget ? k.outputRenderTarget.getInternalTexture() : void 0;
+ this.postProcessManager._finalizeFrame(k.isIntermediate, Qe);
+ }
+ this._renderTargets.reset(), this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera);
+ }
+ }, Y.prototype._processSubCameras = function(k) {
+ if (k.cameraRigMode === S.a.RIG_MODE_NONE || k.outputRenderTarget && k.outputRenderTarget.getViewCount() > 1 && this.getEngine().getCaps().multiview)
+ return this._renderForCamera(k), void this.onAfterRenderCameraObservable.notifyObservers(k);
+ if (k._useMultiviewToSingleView)
+ this._renderMultiviewToSingleView(k);
+ else
+ for (var H = 0; H < k._rigCameras.length; H++)
+ this._renderForCamera(k._rigCameras[H], k);
+ this._activeCamera = k, this.setTransformMatrix(this._activeCamera.getViewMatrix(), this._activeCamera.getProjectionMatrix()), this.onAfterRenderCameraObservable.notifyObservers(k);
+ }, Y.prototype._checkIntersections = function() {
+ for (var k = 0; k < this._meshesForIntersections.length; k++) {
+ var H = this._meshesForIntersections.data[k];
+ if (H.actionManager)
+ for (var Z = 0; H.actionManager && Z < H.actionManager.actions.length; Z++) {
+ var W = H.actionManager.actions[Z];
+ if (W.trigger === M.a.ACTION_OnIntersectionEnterTrigger || W.trigger === M.a.ACTION_OnIntersectionExitTrigger) {
+ var q = W.getTriggerParameter(), he = q instanceof T.a ? q : q.mesh, ge = he.intersectsMesh(H, q.usePreciseIntersection), me = H._intersectionsInProgress.indexOf(he);
+ ge && me === -1 ? W.trigger === M.a.ACTION_OnIntersectionEnterTrigger ? (W._executeCurrent(b.a.CreateNew(H, void 0, he)), H._intersectionsInProgress.push(he)) : W.trigger === M.a.ACTION_OnIntersectionExitTrigger && H._intersectionsInProgress.push(he) : !ge && me > -1 && (W.trigger === M.a.ACTION_OnIntersectionExitTrigger && W._executeCurrent(b.a.CreateNew(H, void 0, he)), H.actionManager.hasSpecificTrigger(M.a.ACTION_OnIntersectionExitTrigger, function(_e) {
+ var ye = _e instanceof T.a ? _e : _e.mesh;
+ return he === ye;
+ }) && W.trigger !== M.a.ACTION_OnIntersectionExitTrigger || H._intersectionsInProgress.splice(me, 1));
+ }
+ }
+ }
+ }, Y.prototype._advancePhysicsEngineStep = function(k) {
+ }, Y.prototype._animate = function() {
+ }, Y.prototype.animate = function() {
+ if (this._engine.isDeterministicLockStep()) {
+ var k = Math.max(Y.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Y.MaxDeltaTime)) + this._timeAccumulator, H = this._engine.getTimeStep(), Z = 1e3 / H / 1e3, W = 0, q = this._engine.getLockstepMaxSteps(), he = Math.floor(k / H);
+ for (he = Math.min(he, q); k > 0 && W < he; )
+ this.onBeforeStepObservable.notifyObservers(this), this._animationRatio = H * Z, this._animate(), this.onAfterAnimationsObservable.notifyObservers(this), this.physicsEnabled && this._advancePhysicsEngineStep(H), this.onAfterStepObservable.notifyObservers(this), this._currentStepId++, W++, k -= H;
+ this._timeAccumulator = k < 0 ? 0 : k;
+ } else
+ k = this.useConstantAnimationDeltaTime ? 16 : Math.max(Y.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Y.MaxDeltaTime)), this._animationRatio = 0.06 * k, this._animate(), this.onAfterAnimationsObservable.notifyObservers(this), this.physicsEnabled && this._advancePhysicsEngineStep(k);
+ }, Y.prototype.render = function(k, H) {
+ if (k === void 0 && (k = !0), H === void 0 && (H = !1), !this.isDisposed) {
+ this.onReadyObservable.hasObservers() && this._executeWhenReadyTimeoutId === -1 && this._checkIsReady(), this._frameId++, this._registerTransientComponents(), this._activeParticles.fetchNewFrame(), this._totalVertices.fetchNewFrame(), this._activeIndices.fetchNewFrame(), this._activeBones.fetchNewFrame(), this._meshesForIntersections.reset(), this.resetCachedMaterial(), this.onBeforeAnimationsObservable.notifyObservers(this), this.actionManager && this.actionManager.processTrigger(M.a.ACTION_OnEveryFrameTrigger), H || this.animate();
+ for (var Z = 0, W = this._beforeCameraUpdateStage; Z < W.length; Z++)
+ W[Z].action();
+ if (k) {
+ if (this.activeCameras && this.activeCameras.length > 0)
+ for (var q = 0; q < this.activeCameras.length; q++) {
+ var he = this.activeCameras[q];
+ if (he.update(), he.cameraRigMode !== S.a.RIG_MODE_NONE)
+ for (var ge = 0; ge < he._rigCameras.length; ge++)
+ he._rigCameras[ge].update();
+ }
+ else if (this.activeCamera && (this.activeCamera.update(), this.activeCamera.cameraRigMode !== S.a.RIG_MODE_NONE))
+ for (ge = 0; ge < this.activeCamera._rigCameras.length; ge++)
+ this.activeCamera._rigCameras[ge].update();
+ }
+ this.onBeforeRenderObservable.notifyObservers(this), this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
+ var me = this.getEngine(), _e = this.activeCamera;
+ if (this.renderTargetsEnabled) {
+ _.b.StartPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0), this._intermediateRendering = !0;
+ for (var ye = 0; ye < this.customRenderTargets.length; ye++) {
+ var Pe = this.customRenderTargets[ye];
+ if (Pe._shouldRender()) {
+ if (this._renderId++, this.activeCamera = Pe.activeCamera || this.activeCamera, !this.activeCamera)
+ throw new Error("Active camera not set");
+ me.setViewport(this.activeCamera.viewport), this.updateTransformMatrix(), Pe.render(_e !== this.activeCamera, this.dumpNextRenderTargets);
+ }
+ }
+ _.b.EndPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0), this._intermediateRendering = !1, this._renderId++;
+ }
+ this.activeCamera = _e, this._activeCamera && this._activeCamera.cameraRigMode !== S.a.RIG_MODE_CUSTOM && !this.prePass && this._bindFrameBuffer(), this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
+ for (var be = 0, Fe = this._beforeClearStage; be < Fe.length; be++)
+ Fe[be].action();
+ !this.autoClearDepthAndStencil && !this.autoClear || this.prePass || this._engine.clear(this.clearColor, this.autoClear || this.forceWireframe || this.forcePointsCloud, this.autoClearDepthAndStencil, this.autoClearDepthAndStencil);
+ for (var ke = 0, We = this._gatherRenderTargetsStage; ke < We.length; ke++)
+ We[ke].action(this._renderTargets);
+ if (this.activeCameras && this.activeCameras.length > 0)
+ for (q = 0; q < this.activeCameras.length; q++)
+ q > 0 && this._engine.clear(null, !1, !0, !0), this._processSubCameras(this.activeCameras[q]);
+ else {
+ if (!this.activeCamera)
+ throw new Error("No camera defined");
+ this._processSubCameras(this.activeCamera);
+ }
+ this._checkIntersections();
+ for (var je = 0, He = this._afterRenderStage; je < He.length; je++)
+ He[je].action();
+ if (this.afterRender && this.afterRender(), this.onAfterRenderObservable.notifyObservers(this), this._toBeDisposed.length) {
+ for (ge = 0; ge < this._toBeDisposed.length; ge++) {
+ var Qe = this._toBeDisposed[ge];
+ Qe && Qe.dispose();
+ }
+ this._toBeDisposed = [];
+ }
+ this.dumpNextRenderTargets && (this.dumpNextRenderTargets = !1), this._activeBones.addCount(0, !0), this._activeIndices.addCount(0, !0), this._activeParticles.addCount(0, !0);
+ }
+ }, Y.prototype.freezeMaterials = function() {
+ for (var k = 0; k < this.materials.length; k++)
+ this.materials[k].freeze();
+ }, Y.prototype.unfreezeMaterials = function() {
+ for (var k = 0; k < this.materials.length; k++)
+ this.materials[k].unfreeze();
+ }, Y.prototype.dispose = function() {
+ this.beforeRender = null, this.afterRender = null, j.a._LastCreatedScene === this && (j.a._LastCreatedScene = null), this.skeletons = [], this.morphTargetManagers = [], this._transientComponents = [], this._isReadyForMeshStage.clear(), this._beforeEvaluateActiveMeshStage.clear(), this._evaluateSubMeshStage.clear(), this._preActiveMeshStage.clear(), this._cameraDrawRenderTargetStage.clear(), this._beforeCameraDrawStage.clear(), this._beforeRenderTargetDrawStage.clear(), this._beforeRenderingGroupDrawStage.clear(), this._beforeRenderingMeshStage.clear(), this._afterRenderingMeshStage.clear(), this._afterRenderingGroupDrawStage.clear(), this._afterCameraDrawStage.clear(), this._afterRenderTargetDrawStage.clear(), this._afterRenderStage.clear(), this._beforeCameraUpdateStage.clear(), this._beforeClearStage.clear(), this._gatherRenderTargetsStage.clear(), this._gatherActiveCameraRenderTargetsStage.clear(), this._pointerMoveStage.clear(), this._pointerDownStage.clear(), this._pointerUpStage.clear();
+ for (var k = 0, H = this._components; k < H.length; k++)
+ H[k].dispose();
+ this.importedMeshesFiles = new Array(), this.stopAllAnimations && this.stopAllAnimations(), this.resetCachedMaterial(), this.activeCamera && (this.activeCamera._activeMeshes.dispose(), this.activeCamera = null), this._activeMeshes.dispose(), this._renderingManager.dispose(), this._processedMaterials.dispose(), this._activeParticleSystems.dispose(), this._activeSkeletons.dispose(), this._softwareSkinnedMeshes.dispose(), this._renderTargets.dispose(), this._registeredForLateAnimationBindings.dispose(), this._meshesForIntersections.dispose(), this._toBeDisposed = [];
+ for (var Z = 0, W = this._activeRequests; Z < W.length; Z++)
+ W[Z].abort();
+ var q;
+ if (this.onDisposeObservable.notifyObservers(this), this.onDisposeObservable.clear(), this.onBeforeRenderObservable.clear(), this.onAfterRenderObservable.clear(), this.onBeforeRenderTargetsRenderObservable.clear(), this.onAfterRenderTargetsRenderObservable.clear(), this.onAfterStepObservable.clear(), this.onBeforeStepObservable.clear(), this.onBeforeActiveMeshesEvaluationObservable.clear(), this.onAfterActiveMeshesEvaluationObservable.clear(), this.onBeforeParticlesRenderingObservable.clear(), this.onAfterParticlesRenderingObservable.clear(), this.onBeforeDrawPhaseObservable.clear(), this.onAfterDrawPhaseObservable.clear(), this.onBeforeAnimationsObservable.clear(), this.onAfterAnimationsObservable.clear(), this.onDataLoadedObservable.clear(), this.onBeforeRenderingGroupObservable.clear(), this.onAfterRenderingGroupObservable.clear(), this.onMeshImportedObservable.clear(), this.onBeforeCameraRenderObservable.clear(), this.onAfterCameraRenderObservable.clear(), this.onReadyObservable.clear(), this.onNewCameraAddedObservable.clear(), this.onCameraRemovedObservable.clear(), this.onNewLightAddedObservable.clear(), this.onLightRemovedObservable.clear(), this.onNewGeometryAddedObservable.clear(), this.onGeometryRemovedObservable.clear(), this.onNewTransformNodeAddedObservable.clear(), this.onTransformNodeRemovedObservable.clear(), this.onNewMeshAddedObservable.clear(), this.onMeshRemovedObservable.clear(), this.onNewSkeletonAddedObservable.clear(), this.onSkeletonRemovedObservable.clear(), this.onNewMaterialAddedObservable.clear(), this.onNewMultiMaterialAddedObservable.clear(), this.onMaterialRemovedObservable.clear(), this.onMultiMaterialRemovedObservable.clear(), this.onNewTextureAddedObservable.clear(), this.onTextureRemovedObservable.clear(), this.onPrePointerObservable.clear(), this.onPointerObservable.clear(), this.onPreKeyboardObservable.clear(), this.onKeyboardObservable.clear(), this.onActiveCameraChanged.clear(), this.detachControl(), this._engine.getInputElement())
+ for (q = 0; q < this.cameras.length; q++)
+ this.cameras[q].detachControl();
+ for (; this.animationGroups.length; )
+ this.animationGroups[0].dispose();
+ for (; this.lights.length; )
+ this.lights[0].dispose();
+ for (; this.meshes.length; )
+ this.meshes[0].dispose(!0);
+ for (; this.transformNodes.length; )
+ this.transformNodes[0].dispose(!0);
+ for (; this.cameras.length; )
+ this.cameras[0].dispose();
+ for (this._defaultMaterial && this._defaultMaterial.dispose(); this.multiMaterials.length; )
+ this.multiMaterials[0].dispose();
+ for (; this.materials.length; )
+ this.materials[0].dispose();
+ for (; this.particleSystems.length; )
+ this.particleSystems[0].dispose();
+ for (; this.postProcesses.length; )
+ this.postProcesses[0].dispose();
+ for (; this.textures.length; )
+ this.textures[0].dispose();
+ this._sceneUbo.dispose(), this._multiviewSceneUbo && this._multiviewSceneUbo.dispose(), this.postProcessManager.dispose(), (q = this._engine.scenes.indexOf(this)) > -1 && this._engine.scenes.splice(q, 1), this._engine.wipeCaches(!0), this._isDisposed = !0;
+ }, Object.defineProperty(Y.prototype, "isDisposed", { get: function() {
+ return this._isDisposed;
+ }, enumerable: !1, configurable: !0 }), Y.prototype.clearCachedVertexData = function() {
+ for (var k = 0; k < this.meshes.length; k++) {
+ var H = this.meshes[k].geometry;
+ if (H)
+ for (var Z in H._indices = [], H._vertexBuffers)
+ H._vertexBuffers.hasOwnProperty(Z) && (H._vertexBuffers[Z]._buffer._data = null);
+ }
+ }, Y.prototype.cleanCachedTextureBuffer = function() {
+ for (var k = 0, H = this.textures; k < H.length; k++) {
+ var Z = H[k];
+ Z._buffer && (Z._buffer = null);
+ }
+ }, Y.prototype.getWorldExtends = function(k) {
+ var H = new m.e(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), Z = new m.e(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
+ return k = k || function() {
+ return !0;
+ }, this.meshes.filter(k).forEach(function(W) {
+ if (W.computeWorldMatrix(!0), W.subMeshes && W.subMeshes.length !== 0 && !W.infiniteDistance) {
+ var q = W.getBoundingInfo(), he = q.boundingBox.minimumWorld, ge = q.boundingBox.maximumWorld;
+ m.e.CheckExtends(he, H, Z), m.e.CheckExtends(ge, H, Z);
+ }
+ }), { min: H, max: Z };
+ }, Y.prototype.createPickingRay = function(k, H, Z, W, q) {
+ throw ne.a.WarnImport("Ray");
+ }, Y.prototype.createPickingRayToRef = function(k, H, Z, W, q, he) {
+ throw ne.a.WarnImport("Ray");
+ }, Y.prototype.createPickingRayInCameraSpace = function(k, H, Z) {
+ throw ne.a.WarnImport("Ray");
+ }, Y.prototype.createPickingRayInCameraSpaceToRef = function(k, H, Z, W) {
+ throw ne.a.WarnImport("Ray");
+ }, Y.prototype.pick = function(k, H, Z, W, q, he) {
+ var ge = new v.a();
+ return ge._pickingUnavailable = !0, ge;
+ }, Y.prototype.pickWithBoundingInfo = function(k, H, Z, W, q) {
+ var he = new v.a();
+ return he._pickingUnavailable = !0, he;
+ }, Y.prototype.pickWithRay = function(k, H, Z, W) {
+ throw ne.a.WarnImport("Ray");
+ }, Y.prototype.multiPick = function(k, H, Z, W, q) {
+ throw ne.a.WarnImport("Ray");
+ }, Y.prototype.multiPickWithRay = function(k, H, Z) {
+ throw ne.a.WarnImport("Ray");
+ }, Y.prototype.setPointerOverMesh = function(k, H) {
+ this._inputManager.setPointerOverMesh(k, H);
+ }, Y.prototype.getPointerOverMesh = function() {
+ return this._inputManager.getPointerOverMesh();
+ }, Y.prototype._rebuildGeometries = function() {
+ for (var k = 0, H = this.geometries; k < H.length; k++)
+ H[k]._rebuild();
+ for (var Z = 0, W = this.meshes; Z < W.length; Z++)
+ W[Z]._rebuild();
+ this.postProcessManager && this.postProcessManager._rebuild();
+ for (var q = 0, he = this._components; q < he.length; q++)
+ he[q].rebuild();
+ for (var ge = 0, me = this.particleSystems; ge < me.length; ge++)
+ me[ge].rebuild();
+ }, Y.prototype._rebuildTextures = function() {
+ for (var k = 0, H = this.textures; k < H.length; k++)
+ H[k]._rebuild();
+ this.markAllMaterialsAsDirty(M.a.MATERIAL_TextureDirtyFlag);
+ }, Y.prototype._getByTags = function(k, H, Z) {
+ if (H === void 0)
+ return k;
+ var W = [];
+ for (var q in Z = Z || function(ge) {
+ }, k) {
+ var he = k[q];
+ x.a && x.a.MatchesQuery(he, H) && (W.push(he), Z(he));
+ }
+ return W;
+ }, Y.prototype.getMeshesByTags = function(k, H) {
+ return this._getByTags(this.meshes, k, H);
+ }, Y.prototype.getCamerasByTags = function(k, H) {
+ return this._getByTags(this.cameras, k, H);
+ }, Y.prototype.getLightsByTags = function(k, H) {
+ return this._getByTags(this.lights, k, H);
+ }, Y.prototype.getMaterialByTags = function(k, H) {
+ return this._getByTags(this.materials, k, H).concat(this._getByTags(this.multiMaterials, k, H));
+ }, Y.prototype.getTransformNodesByTags = function(k, H) {
+ return this._getByTags(this.transformNodes, k, H);
+ }, Y.prototype.setRenderingOrder = function(k, H, Z, W) {
+ H === void 0 && (H = null), Z === void 0 && (Z = null), W === void 0 && (W = null), this._renderingManager.setRenderingOrder(k, H, Z, W);
+ }, Y.prototype.setRenderingAutoClearDepthStencil = function(k, H, Z, W) {
+ Z === void 0 && (Z = !0), W === void 0 && (W = !0), this._renderingManager.setRenderingAutoClearDepthStencil(k, H, Z, W);
+ }, Y.prototype.getAutoClearDepthStencilSetup = function(k) {
+ return this._renderingManager.getAutoClearDepthStencilSetup(k);
+ }, Object.defineProperty(Y.prototype, "blockMaterialDirtyMechanism", { get: function() {
+ return this._blockMaterialDirtyMechanism;
+ }, set: function(k) {
+ this._blockMaterialDirtyMechanism !== k && (this._blockMaterialDirtyMechanism = k, k || this.markAllMaterialsAsDirty(M.a.MATERIAL_AllDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Y.prototype.markAllMaterialsAsDirty = function(k, H) {
+ if (!this._blockMaterialDirtyMechanism)
+ for (var Z = 0, W = this.materials; Z < W.length; Z++) {
+ var q = W[Z];
+ H && !H(q) || q.markAsDirty(k);
+ }
+ }, Y.prototype._loadFile = function(k, H, Z, W, q, he) {
+ var ge = this, me = Q.a.LoadFile(k, H, Z, W ? this.offlineProvider : void 0, q, he);
+ return this._activeRequests.push(me), me.onCompleteObservable.add(function(_e) {
+ ge._activeRequests.splice(ge._activeRequests.indexOf(_e), 1);
+ }), me;
+ }, Y.prototype._loadFileAsync = function(k, H, Z, W) {
+ var q = this;
+ return new Promise(function(he, ge) {
+ q._loadFile(k, function(me) {
+ he(me);
+ }, H, Z, W, function(me, _e) {
+ ge(_e);
+ });
+ });
+ }, Y.prototype._requestFile = function(k, H, Z, W, q, he, ge) {
+ var me = this, _e = Q.a.RequestFile(k, H, Z, W ? this.offlineProvider : void 0, q, he, ge);
+ return this._activeRequests.push(_e), _e.onCompleteObservable.add(function(ye) {
+ me._activeRequests.splice(me._activeRequests.indexOf(ye), 1);
+ }), _e;
+ }, Y.prototype._requestFileAsync = function(k, H, Z, W, q) {
+ var he = this;
+ return new Promise(function(ge, me) {
+ he._requestFile(k, function(_e) {
+ ge(_e);
+ }, H, Z, W, function(_e) {
+ me(_e);
+ }, q);
+ });
+ }, Y.prototype._readFile = function(k, H, Z, W, q) {
+ var he = this, ge = Q.a.ReadFile(k, H, Z, W, q);
+ return this._activeRequests.push(ge), ge.onCompleteObservable.add(function(me) {
+ he._activeRequests.splice(he._activeRequests.indexOf(me), 1);
+ }), ge;
+ }, Y.prototype._readFileAsync = function(k, H, Z) {
+ var W = this;
+ return new Promise(function(q, he) {
+ W._readFile(k, function(ge) {
+ q(ge);
+ }, H, Z, function(ge) {
+ he(ge);
+ });
+ });
+ }, Y.FOGMODE_NONE = 0, Y.FOGMODE_EXP = 1, Y.FOGMODE_EXP2 = 2, Y.FOGMODE_LINEAR = 3, Y.MinDeltaTime = 1, Y.MaxDeltaTime = 1e3, Y;
+ }(E.a);
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return V;
+ });
+ var V = function() {
+ function _() {
+ }
+ return _.WarnImport = function(C) {
+ return C + " needs to be imported before as it contains a side-effect required by your code.";
+ }, _;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return V;
+ });
+ var V = function() {
+ function _() {
+ }
+ return Object.defineProperty(_, "LastCreatedEngine", { get: function() {
+ return this.Instances.length === 0 ? null : this.Instances[this.Instances.length - 1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(_, "LastCreatedScene", { get: function() {
+ return this._LastCreatedScene;
+ }, enumerable: !1, configurable: !0 }), _.Instances = new Array(), _._LastCreatedScene = null, _.UseFallbackTexture = !0, _.FallbackTexture = "", _;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "c", function() {
+ return V;
+ }), f.d(A, "a", function() {
+ return u;
+ }), f.d(A, "b", function() {
+ return C;
+ });
+ var V, _ = f(0);
+ (function(I) {
+ I[I.LOCAL = 0] = "LOCAL", I[I.WORLD = 1] = "WORLD", I[I.BONE = 2] = "BONE";
+ })(V || (V = {}));
+ var C, u = function() {
+ function I() {
+ }
+ return I.X = new _.e(1, 0, 0), I.Y = new _.e(0, 1, 0), I.Z = new _.e(0, 0, 1), I;
+ }();
+ (function(I) {
+ I[I.X = 0] = "X", I[I.Y = 1] = "Y", I[I.Z = 2] = "Z";
+ })(C || (C = {}));
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return g;
+ });
+ var V = f(1), _ = f(3), C = f(33), u = f(12), I = f(6), O = f(0), x = f(29), m = f(8), c = f(11), T = f(21), S = f(58), E = f(90), g = function(l) {
+ function h(v, b, D, w) {
+ w === void 0 && (w = !0);
+ var N = l.call(this, v, D) || this;
+ return N._position = O.e.Zero(), N._upVector = O.e.Up(), N.orthoLeft = null, N.orthoRight = null, N.orthoBottom = null, N.orthoTop = null, N.fov = 0.8, N.minZ = 1, N.maxZ = 1e4, N.inertia = 0.9, N.mode = h.PERSPECTIVE_CAMERA, N.isIntermediate = !1, N.viewport = new S.a(0, 0, 1, 1), N.layerMask = 268435455, N.fovMode = h.FOVMODE_VERTICAL_FIXED, N.cameraRigMode = h.RIG_MODE_NONE, N.customRenderTargets = new Array(), N.outputRenderTarget = null, N.onViewMatrixChangedObservable = new I.c(), N.onProjectionMatrixChangedObservable = new I.c(), N.onAfterCheckInputsObservable = new I.c(), N.onRestoreStateObservable = new I.c(), N.isRigCamera = !1, N._rigCameras = new Array(), N._webvrViewMatrix = O.a.Identity(), N._skipRendering = !1, N._projectionMatrix = new O.a(), N._postProcesses = new Array(), N._activeMeshes = new C.a(256), N._globalPosition = O.e.Zero(), N._computedViewMatrix = O.a.Identity(), N._doNotComputeProjectionMatrix = !1, N._transformMatrix = O.a.Zero(), N._refreshFrustumPlanes = !0, N._isCamera = !0, N._isLeftCamera = !1, N._isRightCamera = !1, N.getScene().addCamera(N), w && !N.getScene().activeCamera && (N.getScene().activeCamera = N), N.position = b, N;
+ }
+ return Object(V.d)(h, l), Object.defineProperty(h.prototype, "position", { get: function() {
+ return this._position;
+ }, set: function(v) {
+ this._position = v;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(h.prototype, "upVector", { get: function() {
+ return this._upVector;
+ }, set: function(v) {
+ this._upVector = v;
+ }, enumerable: !1, configurable: !0 }), h.prototype.storeState = function() {
+ return this._stateStored = !0, this._storedFov = this.fov, this;
+ }, h.prototype._restoreStateValues = function() {
+ return !!this._stateStored && (this.fov = this._storedFov, !0);
+ }, h.prototype.restoreState = function() {
+ return !!this._restoreStateValues() && (this.onRestoreStateObservable.notifyObservers(this), !0);
+ }, h.prototype.getClassName = function() {
+ return "Camera";
+ }, h.prototype.toString = function(v) {
+ var b = "Name: " + this.name;
+ if (b += ", type: " + this.getClassName(), this.animations)
+ for (var D = 0; D < this.animations.length; D++)
+ b += ", animation[0]: " + this.animations[D].toString(v);
+ return b;
+ }, Object.defineProperty(h.prototype, "globalPosition", { get: function() {
+ return this._globalPosition;
+ }, enumerable: !1, configurable: !0 }), h.prototype.getActiveMeshes = function() {
+ return this._activeMeshes;
+ }, h.prototype.isActiveMesh = function(v) {
+ return this._activeMeshes.indexOf(v) !== -1;
+ }, h.prototype.isReady = function(v) {
+ if (v === void 0 && (v = !1), v)
+ for (var b = 0, D = this._postProcesses; b < D.length; b++) {
+ var w = D[b];
+ if (w && !w.isReady())
+ return !1;
+ }
+ return l.prototype.isReady.call(this, v);
+ }, h.prototype._initCache = function() {
+ l.prototype._initCache.call(this), this._cache.position = new O.e(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), this._cache.upVector = new O.e(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), this._cache.mode = void 0, this._cache.minZ = void 0, this._cache.maxZ = void 0, this._cache.fov = void 0, this._cache.fovMode = void 0, this._cache.aspectRatio = void 0, this._cache.orthoLeft = void 0, this._cache.orthoRight = void 0, this._cache.orthoBottom = void 0, this._cache.orthoTop = void 0, this._cache.renderWidth = void 0, this._cache.renderHeight = void 0;
+ }, h.prototype._updateCache = function(v) {
+ v || l.prototype._updateCache.call(this), this._cache.position.copyFrom(this.position), this._cache.upVector.copyFrom(this.upVector);
+ }, h.prototype._isSynchronized = function() {
+ return this._isSynchronizedViewMatrix() && this._isSynchronizedProjectionMatrix();
+ }, h.prototype._isSynchronizedViewMatrix = function() {
+ return !!l.prototype._isSynchronized.call(this) && this._cache.position.equals(this.position) && this._cache.upVector.equals(this.upVector) && this.isSynchronizedWithParent();
+ }, h.prototype._isSynchronizedProjectionMatrix = function() {
+ var v = this._cache.mode === this.mode && this._cache.minZ === this.minZ && this._cache.maxZ === this.maxZ;
+ if (!v)
+ return !1;
+ var b = this.getEngine();
+ return v = this.mode === h.PERSPECTIVE_CAMERA ? this._cache.fov === this.fov && this._cache.fovMode === this.fovMode && this._cache.aspectRatio === b.getAspectRatio(this) : this._cache.orthoLeft === this.orthoLeft && this._cache.orthoRight === this.orthoRight && this._cache.orthoBottom === this.orthoBottom && this._cache.orthoTop === this.orthoTop && this._cache.renderWidth === b.getRenderWidth() && this._cache.renderHeight === b.getRenderHeight();
+ }, h.prototype.attachControl = function(v, b) {
+ }, h.prototype.detachControl = function(v) {
+ }, h.prototype.update = function() {
+ this._checkInputs(), this.cameraRigMode !== h.RIG_MODE_NONE && this._updateRigCameras();
+ }, h.prototype._checkInputs = function() {
+ this.onAfterCheckInputsObservable.notifyObservers(this);
+ }, Object.defineProperty(h.prototype, "rigCameras", { get: function() {
+ return this._rigCameras;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(h.prototype, "rigPostProcess", { get: function() {
+ return this._rigPostProcess;
+ }, enumerable: !1, configurable: !0 }), h.prototype._getFirstPostProcess = function() {
+ for (var v = 0; v < this._postProcesses.length; v++)
+ if (this._postProcesses[v] !== null)
+ return this._postProcesses[v];
+ return null;
+ }, h.prototype._cascadePostProcessesToRigCams = function() {
+ var v = this._getFirstPostProcess();
+ v && v.markTextureDirty();
+ for (var b = 0, D = this._rigCameras.length; b < D; b++) {
+ var w = this._rigCameras[b], N = w._rigPostProcess;
+ N ? (N.getEffectName() === "pass" && (w.isIntermediate = this._postProcesses.length === 0), w._postProcesses = this._postProcesses.slice(0).concat(N), N.markTextureDirty()) : w._postProcesses = this._postProcesses.slice(0);
+ }
+ }, h.prototype.attachPostProcess = function(v, b) {
+ return b === void 0 && (b = null), !v.isReusable() && this._postProcesses.indexOf(v) > -1 ? (m.a.Error("You're trying to reuse a post process not defined as reusable."), 0) : (b == null || b < 0 ? this._postProcesses.push(v) : this._postProcesses[b] === null ? this._postProcesses[b] = v : this._postProcesses.splice(b, 0, v), this._cascadePostProcessesToRigCams(), this._scene.prePassRenderer && this._scene.prePassRenderer.markAsDirty(), this._postProcesses.indexOf(v));
+ }, h.prototype.detachPostProcess = function(v) {
+ var b = this._postProcesses.indexOf(v);
+ b !== -1 && (this._postProcesses[b] = null), this._scene.prePassRenderer && this._scene.prePassRenderer.markAsDirty(), this._cascadePostProcessesToRigCams();
+ }, h.prototype.getWorldMatrix = function() {
+ return this._isSynchronizedViewMatrix() || this.getViewMatrix(), this._worldMatrix;
+ }, h.prototype._getViewMatrix = function() {
+ return O.a.Identity();
+ }, h.prototype.getViewMatrix = function(v) {
+ return !v && this._isSynchronizedViewMatrix() || (this.updateCache(), this._computedViewMatrix = this._getViewMatrix(), this._currentRenderId = this.getScene().getRenderId(), this._childUpdateId++, this._refreshFrustumPlanes = !0, this._cameraRigParams && this._cameraRigParams.vrPreViewMatrix && this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix, this._computedViewMatrix), this.parent && this.parent.onViewMatrixChangedObservable && this.parent.onViewMatrixChangedObservable.notifyObservers(this.parent), this.onViewMatrixChangedObservable.notifyObservers(this), this._computedViewMatrix.invertToRef(this._worldMatrix)), this._computedViewMatrix;
+ }, h.prototype.freezeProjectionMatrix = function(v) {
+ this._doNotComputeProjectionMatrix = !0, v !== void 0 && (this._projectionMatrix = v);
+ }, h.prototype.unfreezeProjectionMatrix = function() {
+ this._doNotComputeProjectionMatrix = !1;
+ }, h.prototype.getProjectionMatrix = function(v) {
+ var b, D, w, N, M, U, X, j;
+ if (this._doNotComputeProjectionMatrix || !v && this._isSynchronizedProjectionMatrix())
+ return this._projectionMatrix;
+ this._cache.mode = this.mode, this._cache.minZ = this.minZ, this._cache.maxZ = this.maxZ, this._refreshFrustumPlanes = !0;
+ var ne = this.getEngine(), te = this.getScene();
+ if (this.mode === h.PERSPECTIVE_CAMERA) {
+ this._cache.fov = this.fov, this._cache.fovMode = this.fovMode, this._cache.aspectRatio = ne.getAspectRatio(this), this.minZ <= 0 && (this.minZ = 0.1);
+ var de = ne.useReverseDepthBuffer;
+ (te.useRightHandedSystem ? de ? O.a.PerspectiveFovReverseRHToRef : O.a.PerspectiveFovRHToRef : de ? O.a.PerspectiveFovReverseLHToRef : O.a.PerspectiveFovLHToRef)(this.fov, ne.getAspectRatio(this), this.minZ, this.maxZ, this._projectionMatrix, this.fovMode === h.FOVMODE_VERTICAL_FIXED);
+ } else {
+ var pe = ne.getRenderWidth() / 2, ae = ne.getRenderHeight() / 2;
+ te.useRightHandedSystem ? O.a.OrthoOffCenterRHToRef((b = this.orthoLeft) !== null && b !== void 0 ? b : -pe, (D = this.orthoRight) !== null && D !== void 0 ? D : pe, (w = this.orthoBottom) !== null && w !== void 0 ? w : -ae, (N = this.orthoTop) !== null && N !== void 0 ? N : ae, this.minZ, this.maxZ, this._projectionMatrix) : O.a.OrthoOffCenterLHToRef((M = this.orthoLeft) !== null && M !== void 0 ? M : -pe, (U = this.orthoRight) !== null && U !== void 0 ? U : pe, (X = this.orthoBottom) !== null && X !== void 0 ? X : -ae, (j = this.orthoTop) !== null && j !== void 0 ? j : ae, this.minZ, this.maxZ, this._projectionMatrix), this._cache.orthoLeft = this.orthoLeft, this._cache.orthoRight = this.orthoRight, this._cache.orthoBottom = this.orthoBottom, this._cache.orthoTop = this.orthoTop, this._cache.renderWidth = ne.getRenderWidth(), this._cache.renderHeight = ne.getRenderHeight();
+ }
+ return this.onProjectionMatrixChangedObservable.notifyObservers(this), this._projectionMatrix;
+ }, h.prototype.getTransformationMatrix = function() {
+ return this._computedViewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix), this._transformMatrix;
+ }, h.prototype._updateFrustumPlanes = function() {
+ this._refreshFrustumPlanes && (this.getTransformationMatrix(), this._frustumPlanes ? E.a.GetPlanesToRef(this._transformMatrix, this._frustumPlanes) : this._frustumPlanes = E.a.GetPlanes(this._transformMatrix), this._refreshFrustumPlanes = !1);
+ }, h.prototype.isInFrustum = function(v, b) {
+ if (b === void 0 && (b = !1), this._updateFrustumPlanes(), b && this.rigCameras.length > 0) {
+ var D = !1;
+ return this.rigCameras.forEach(function(w) {
+ w._updateFrustumPlanes(), D = D || v.isInFrustum(w._frustumPlanes);
+ }), D;
+ }
+ return v.isInFrustum(this._frustumPlanes);
+ }, h.prototype.isCompletelyInFrustum = function(v) {
+ return this._updateFrustumPlanes(), v.isCompletelyInFrustum(this._frustumPlanes);
+ }, h.prototype.getForwardRay = function(v, b, D) {
+ throw T.a.WarnImport("Ray");
+ }, h.prototype.getForwardRayToRef = function(v, b, D, w) {
+ throw T.a.WarnImport("Ray");
+ }, h.prototype.dispose = function(v, b) {
+ for (b === void 0 && (b = !1), this.onViewMatrixChangedObservable.clear(), this.onProjectionMatrixChangedObservable.clear(), this.onAfterCheckInputsObservable.clear(), this.onRestoreStateObservable.clear(), this.inputs && this.inputs.clear(), this.getScene().stopAnimation(this), this.getScene().removeCamera(this); this._rigCameras.length > 0; ) {
+ var D = this._rigCameras.pop();
+ D && D.dispose();
+ }
+ if (this._rigPostProcess)
+ this._rigPostProcess.dispose(this), this._rigPostProcess = null, this._postProcesses = [];
+ else if (this.cameraRigMode !== h.RIG_MODE_NONE)
+ this._rigPostProcess = null, this._postProcesses = [];
+ else
+ for (var w = this._postProcesses.length; --w >= 0; ) {
+ var N = this._postProcesses[w];
+ N && N.dispose(this);
+ }
+ for (w = this.customRenderTargets.length; --w >= 0; )
+ this.customRenderTargets[w].dispose();
+ this.customRenderTargets = [], this._activeMeshes.dispose(), l.prototype.dispose.call(this, v, b);
+ }, Object.defineProperty(h.prototype, "isLeftCamera", { get: function() {
+ return this._isLeftCamera;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(h.prototype, "isRightCamera", { get: function() {
+ return this._isRightCamera;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(h.prototype, "leftCamera", { get: function() {
+ return this._rigCameras.length < 1 ? null : this._rigCameras[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(h.prototype, "rightCamera", { get: function() {
+ return this._rigCameras.length < 2 ? null : this._rigCameras[1];
+ }, enumerable: !1, configurable: !0 }), h.prototype.getLeftTarget = function() {
+ return this._rigCameras.length < 1 ? null : this._rigCameras[0].getTarget();
+ }, h.prototype.getRightTarget = function() {
+ return this._rigCameras.length < 2 ? null : this._rigCameras[1].getTarget();
+ }, h.prototype.setCameraRigMode = function(v, b) {
+ if (this.cameraRigMode !== v) {
+ for (; this._rigCameras.length > 0; ) {
+ var D = this._rigCameras.pop();
+ D && D.dispose();
+ }
+ if (this.cameraRigMode = v, this._cameraRigParams = {}, this._cameraRigParams.interaxialDistance = b.interaxialDistance || 0.0637, this._cameraRigParams.stereoHalfAngle = u.b.ToRadians(this._cameraRigParams.interaxialDistance / 0.0637), this.cameraRigMode !== h.RIG_MODE_NONE) {
+ var w = this.createRigCamera(this.name + "_L", 0);
+ w && (w._isLeftCamera = !0);
+ var N = this.createRigCamera(this.name + "_R", 1);
+ N && (N._isRightCamera = !0), w && N && (this._rigCameras.push(w), this._rigCameras.push(N));
+ }
+ switch (this.cameraRigMode) {
+ case h.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
+ h._setStereoscopicAnaglyphRigMode(this);
+ break;
+ case h.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
+ case h.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
+ case h.RIG_MODE_STEREOSCOPIC_OVERUNDER:
+ case h.RIG_MODE_STEREOSCOPIC_INTERLACED:
+ h._setStereoscopicRigMode(this);
+ break;
+ case h.RIG_MODE_VR:
+ h._setVRRigMode(this, b);
+ break;
+ case h.RIG_MODE_WEBVR:
+ h._setWebVRRigMode(this, b);
+ }
+ this._cascadePostProcessesToRigCams(), this.update();
+ }
+ }, h._setStereoscopicRigMode = function(v) {
+ throw "Import Cameras/RigModes/stereoscopicRigMode before using stereoscopic rig mode";
+ }, h._setStereoscopicAnaglyphRigMode = function(v) {
+ throw "Import Cameras/RigModes/stereoscopicAnaglyphRigMode before using stereoscopic anaglyph rig mode";
+ }, h._setVRRigMode = function(v, b) {
+ throw "Import Cameras/RigModes/vrRigMode before using VR rig mode";
+ }, h._setWebVRRigMode = function(v, b) {
+ throw "Import Cameras/RigModes/WebVRRigMode before using Web VR rig mode";
+ }, h.prototype._getVRProjectionMatrix = function() {
+ return O.a.PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov, this._cameraRigParams.vrMetrics.aspectRatio, this.minZ, this.maxZ, this._cameraRigParams.vrWorkMatrix), this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix, this._projectionMatrix), this._projectionMatrix;
+ }, h.prototype._updateCameraRotationMatrix = function() {
+ }, h.prototype._updateWebVRCameraRotationMatrix = function() {
+ }, h.prototype._getWebVRProjectionMatrix = function() {
+ return O.a.Identity();
+ }, h.prototype._getWebVRViewMatrix = function() {
+ return O.a.Identity();
+ }, h.prototype.setCameraRigParameter = function(v, b) {
+ this._cameraRigParams || (this._cameraRigParams = {}), this._cameraRigParams[v] = b, v === "interaxialDistance" && (this._cameraRigParams.stereoHalfAngle = u.b.ToRadians(b / 0.0637));
+ }, h.prototype.createRigCamera = function(v, b) {
+ return null;
+ }, h.prototype._updateRigCameras = function() {
+ for (var v = 0; v < this._rigCameras.length; v++)
+ this._rigCameras[v].minZ = this.minZ, this._rigCameras[v].maxZ = this.maxZ, this._rigCameras[v].fov = this.fov, this._rigCameras[v].upVector.copyFrom(this.upVector);
+ this.cameraRigMode === h.RIG_MODE_STEREOSCOPIC_ANAGLYPH && (this._rigCameras[0].viewport = this._rigCameras[1].viewport = this.viewport);
+ }, h.prototype._setupInputs = function() {
+ }, h.prototype.serialize = function() {
+ var v = _.a.Serialize(this);
+ return v.type = this.getClassName(), this.parent && (v.parentId = this.parent.id), this.inputs && this.inputs.serialize(v), _.a.AppendSerializedAnimations(this, v), v.ranges = this.serializeAnimationRanges(), v;
+ }, h.prototype.clone = function(v) {
+ return _.a.Clone(h.GetConstructorFromName(this.getClassName(), v, this.getScene(), this.interaxialDistance, this.isStereoscopicSideBySide), this);
+ }, h.prototype.getDirection = function(v) {
+ var b = O.e.Zero();
+ return this.getDirectionToRef(v, b), b;
+ }, Object.defineProperty(h.prototype, "absoluteRotation", { get: function() {
+ var v = O.b.Zero();
+ return this.getWorldMatrix().decompose(void 0, v), v;
+ }, enumerable: !1, configurable: !0 }), h.prototype.getDirectionToRef = function(v, b) {
+ O.e.TransformNormalToRef(v, this.getWorldMatrix(), b);
+ }, h.GetConstructorFromName = function(v, b, D, w, N) {
+ w === void 0 && (w = 0), N === void 0 && (N = !0);
+ var M = x.a.Construct(v, b, D, { interaxial_distance: w, isStereoscopicSideBySide: N });
+ return M || function() {
+ return h._createDefaultParsedCamera(b, D);
+ };
+ }, h.prototype.computeWorldMatrix = function() {
+ return this.getWorldMatrix();
+ }, h.Parse = function(v, b) {
+ var D = v.type, w = h.GetConstructorFromName(D, v.name, b, v.interaxial_distance, v.isStereoscopicSideBySide), N = _.a.Parse(w, v, b);
+ if (v.parentId && (N._waitingParentId = v.parentId), N.inputs && (N.inputs.parse(v), N._setupInputs()), v.upVector && (N.upVector = O.e.FromArray(v.upVector)), N.setPosition && (N.position.copyFromFloats(0, 0, 0), N.setPosition(O.e.FromArray(v.position))), v.target && N.setTarget && N.setTarget(O.e.FromArray(v.target)), v.cameraRigMode) {
+ var M = v.interaxial_distance ? { interaxialDistance: v.interaxial_distance } : {};
+ N.setCameraRigMode(v.cameraRigMode, M);
+ }
+ if (v.animations) {
+ for (var U = 0; U < v.animations.length; U++) {
+ var X = v.animations[U], j = c.a.GetClass("BABYLON.Animation");
+ j && N.animations.push(j.Parse(X));
+ }
+ x.a.ParseAnimationRanges(N, v, b);
+ }
+ return v.autoAnimate && b.beginAnimation(N, v.autoAnimateFrom, v.autoAnimateTo, v.autoAnimateLoop, v.autoAnimateSpeed || 1), N;
+ }, h._createDefaultParsedCamera = function(v, b) {
+ throw T.a.WarnImport("UniversalCamera");
+ }, h.PERSPECTIVE_CAMERA = 0, h.ORTHOGRAPHIC_CAMERA = 1, h.FOVMODE_VERTICAL_FIXED = 0, h.FOVMODE_HORIZONTAL_FIXED = 1, h.RIG_MODE_NONE = 0, h.RIG_MODE_STEREOSCOPIC_ANAGLYPH = 10, h.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL = 11, h.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = 12, h.RIG_MODE_STEREOSCOPIC_OVERUNDER = 13, h.RIG_MODE_STEREOSCOPIC_INTERLACED = 14, h.RIG_MODE_VR = 20, h.RIG_MODE_WEBVR = 21, h.RIG_MODE_CUSTOM = 22, h.ForceAttachControlToAlwaysPreventDefault = !1, Object(V.c)([Object(_.o)("position")], h.prototype, "_position", void 0), Object(V.c)([Object(_.o)("upVector")], h.prototype, "_upVector", void 0), Object(V.c)([Object(_.c)()], h.prototype, "orthoLeft", void 0), Object(V.c)([Object(_.c)()], h.prototype, "orthoRight", void 0), Object(V.c)([Object(_.c)()], h.prototype, "orthoBottom", void 0), Object(V.c)([Object(_.c)()], h.prototype, "orthoTop", void 0), Object(V.c)([Object(_.c)()], h.prototype, "fov", void 0), Object(V.c)([Object(_.c)()], h.prototype, "minZ", void 0), Object(V.c)([Object(_.c)()], h.prototype, "maxZ", void 0), Object(V.c)([Object(_.c)()], h.prototype, "inertia", void 0), Object(V.c)([Object(_.c)()], h.prototype, "mode", void 0), Object(V.c)([Object(_.c)()], h.prototype, "layerMask", void 0), Object(V.c)([Object(_.c)()], h.prototype, "fovMode", void 0), Object(V.c)([Object(_.c)()], h.prototype, "cameraRigMode", void 0), Object(V.c)([Object(_.c)()], h.prototype, "interaxialDistance", void 0), Object(V.c)([Object(_.c)()], h.prototype, "isStereoscopicSideBySide", void 0), h;
+ }(x.a);
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return S;
+ });
+ var V = f(1), _ = f(3), C = f(12), u = f(6), I = f(22), O = f(61), x = f(85), m = f(2), c = f(8), T = f(64), S = function() {
+ function E(g, l, h) {
+ this.shadowDepthWrapper = null, this.allowShaderHotSwapping = !0, this.metadata = null, this.reservedDataStore = null, this.checkReadyOnEveryCall = !1, this.checkReadyOnlyOnce = !1, this.state = "", this._alpha = 1, this._backFaceCulling = !0, this.onCompiled = null, this.onError = null, this.getRenderTargetTextures = null, this.doNotSerialize = !1, this._storeEffectOnSubMeshes = !1, this.animations = null, this.onDisposeObservable = new u.c(), this._onDisposeObserver = null, this._onUnBindObservable = null, this._onBindObserver = null, this._alphaMode = m.a.ALPHA_COMBINE, this._needDepthPrePass = !1, this.disableDepthWrite = !1, this.disableColorWrite = !1, this.forceDepthWrite = !1, this.depthFunction = 0, this.separateCullingPass = !1, this._fogEnabled = !0, this.pointSize = 1, this.zOffset = 0, this._effect = null, this._useUBO = !1, this._fillMode = E.TriangleFillMode, this._cachedDepthWriteState = !1, this._cachedColorWriteState = !1, this._cachedDepthFunctionState = 0, this._indexInSceneMaterialArray = -1, this.meshMap = null, this._forceAlphaTest = !1, this._transparencyMode = null, this.name = g;
+ var v = 1;
+ for (this._scene = l || I.a.LastCreatedScene, this.id = g || C.b.RandomId(); this._scene.getMaterialByID(this.id); )
+ this.id = g + " " + v++;
+ this.uniqueId = this._scene.getUniqueId(), this._scene.useRightHandedSystem ? this.sideOrientation = E.ClockWiseSideOrientation : this.sideOrientation = E.CounterClockWiseSideOrientation, this._uniformBuffer = new x.a(this._scene.getEngine()), this._useUBO = this.getScene().getEngine().supportsUniformBuffers, h || this._scene.addMaterial(this), this._scene.useMaterialMeshMap && (this.meshMap = {});
+ }
+ return Object.defineProperty(E.prototype, "canRenderToMRT", { get: function() {
+ return !1;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(E.prototype, "alpha", { get: function() {
+ return this._alpha;
+ }, set: function(g) {
+ this._alpha !== g && (this._alpha = g, this.markAsDirty(E.MiscDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(E.prototype, "backFaceCulling", { get: function() {
+ return this._backFaceCulling;
+ }, set: function(g) {
+ this._backFaceCulling !== g && (this._backFaceCulling = g, this.markAsDirty(E.TextureDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(E.prototype, "hasRenderTargetTextures", { get: function() {
+ return !1;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(E.prototype, "onDispose", { set: function(g) {
+ this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver), this._onDisposeObserver = this.onDisposeObservable.add(g);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(E.prototype, "onBindObservable", { get: function() {
+ return this._onBindObservable || (this._onBindObservable = new u.c()), this._onBindObservable;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(E.prototype, "onBind", { set: function(g) {
+ this._onBindObserver && this.onBindObservable.remove(this._onBindObserver), this._onBindObserver = this.onBindObservable.add(g);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(E.prototype, "onUnBindObservable", { get: function() {
+ return this._onUnBindObservable || (this._onUnBindObservable = new u.c()), this._onUnBindObservable;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(E.prototype, "onEffectCreatedObservable", { get: function() {
+ return this._onEffectCreatedObservable || (this._onEffectCreatedObservable = new u.c()), this._onEffectCreatedObservable;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(E.prototype, "alphaMode", { get: function() {
+ return this._alphaMode;
+ }, set: function(g) {
+ this._alphaMode !== g && (this._alphaMode = g, this.markAsDirty(E.TextureDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(E.prototype, "needDepthPrePass", { get: function() {
+ return this._needDepthPrePass;
+ }, set: function(g) {
+ this._needDepthPrePass !== g && (this._needDepthPrePass = g, this._needDepthPrePass && (this.checkReadyOnEveryCall = !0));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(E.prototype, "fogEnabled", { get: function() {
+ return this._fogEnabled;
+ }, set: function(g) {
+ this._fogEnabled !== g && (this._fogEnabled = g, this.markAsDirty(E.MiscDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(E.prototype, "wireframe", { get: function() {
+ switch (this._fillMode) {
+ case E.WireFrameFillMode:
+ case E.LineListDrawMode:
+ case E.LineLoopDrawMode:
+ case E.LineStripDrawMode:
+ return !0;
+ }
+ return this._scene.forceWireframe;
+ }, set: function(g) {
+ this.fillMode = g ? E.WireFrameFillMode : E.TriangleFillMode;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(E.prototype, "pointsCloud", { get: function() {
+ switch (this._fillMode) {
+ case E.PointFillMode:
+ case E.PointListDrawMode:
+ return !0;
+ }
+ return this._scene.forcePointsCloud;
+ }, set: function(g) {
+ this.fillMode = g ? E.PointFillMode : E.TriangleFillMode;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(E.prototype, "fillMode", { get: function() {
+ return this._fillMode;
+ }, set: function(g) {
+ this._fillMode !== g && (this._fillMode = g, this.markAsDirty(E.MiscDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), E.prototype.toString = function(g) {
+ return "Name: " + this.name;
+ }, E.prototype.getClassName = function() {
+ return "Material";
+ }, Object.defineProperty(E.prototype, "isFrozen", { get: function() {
+ return this.checkReadyOnlyOnce;
+ }, enumerable: !1, configurable: !0 }), E.prototype.freeze = function() {
+ this.markDirty(), this.checkReadyOnlyOnce = !0;
+ }, E.prototype.unfreeze = function() {
+ this.markDirty(), this.checkReadyOnlyOnce = !1;
+ }, E.prototype.isReady = function(g, l) {
+ return !0;
+ }, E.prototype.isReadyForSubMesh = function(g, l, h) {
+ return !1;
+ }, E.prototype.getEffect = function() {
+ return this._effect;
+ }, E.prototype.getScene = function() {
+ return this._scene;
+ }, Object.defineProperty(E.prototype, "transparencyMode", { get: function() {
+ return this._transparencyMode;
+ }, set: function(g) {
+ this._transparencyMode !== g && (this._transparencyMode = g, this._forceAlphaTest = g === E.MATERIAL_ALPHATESTANDBLEND, this._markAllSubMeshesAsTexturesAndMiscDirty());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(E.prototype, "_disableAlphaBlending", { get: function() {
+ return this._transparencyMode === E.MATERIAL_OPAQUE || this._transparencyMode === E.MATERIAL_ALPHATEST;
+ }, enumerable: !1, configurable: !0 }), E.prototype.needAlphaBlending = function() {
+ return !this._disableAlphaBlending && this.alpha < 1;
+ }, E.prototype.needAlphaBlendingForMesh = function(g) {
+ return !(this._disableAlphaBlending && g.visibility >= 1) && (this.needAlphaBlending() || g.visibility < 1 || g.hasVertexAlpha);
+ }, E.prototype.needAlphaTesting = function() {
+ return !!this._forceAlphaTest;
+ }, E.prototype._shouldTurnAlphaTestOn = function(g) {
+ return !this.needAlphaBlendingForMesh(g) && this.needAlphaTesting();
+ }, E.prototype.getAlphaTestTexture = function() {
+ return null;
+ }, E.prototype.markDirty = function() {
+ for (var g = 0, l = this.getScene().meshes; g < l.length; g++) {
+ var h = l[g];
+ if (h.subMeshes)
+ for (var v = 0, b = h.subMeshes; v < b.length; v++) {
+ var D = b[v];
+ D.getMaterial() === this && D.effect && (D.effect._wasPreviouslyReady = !1);
+ }
+ }
+ }, E.prototype._preBind = function(g, l) {
+ l === void 0 && (l = null);
+ var h = this._scene.getEngine(), v = (l ?? this.sideOrientation) === E.ClockWiseSideOrientation;
+ return h.enableEffect(g || this._effect), h.setState(this.backFaceCulling, this.zOffset, !1, v), v;
+ }, E.prototype.bind = function(g, l) {
+ }, E.prototype.bindForSubMesh = function(g, l, h) {
+ }, E.prototype.bindOnlyWorldMatrix = function(g) {
+ }, E.prototype.bindSceneUniformBuffer = function(g, l) {
+ l.bindToEffect(g, "Scene");
+ }, E.prototype.bindView = function(g) {
+ this._useUBO ? this.bindSceneUniformBuffer(g, this.getScene().getSceneUniformBuffer()) : g.setMatrix("view", this.getScene().getViewMatrix());
+ }, E.prototype.bindViewProjection = function(g) {
+ this._useUBO ? this.bindSceneUniformBuffer(g, this.getScene().getSceneUniformBuffer()) : g.setMatrix("viewProjection", this.getScene().getTransformMatrix());
+ }, E.prototype._afterBind = function(g) {
+ if (this._scene._cachedMaterial = this, this._scene._cachedVisibility = g ? g.visibility : 1, this._onBindObservable && g && this._onBindObservable.notifyObservers(g), this.disableDepthWrite) {
+ var l = this._scene.getEngine();
+ this._cachedDepthWriteState = l.getDepthWrite(), l.setDepthWrite(!1);
+ }
+ this.disableColorWrite && (l = this._scene.getEngine(), this._cachedColorWriteState = l.getColorWrite(), l.setColorWrite(!1)), this.depthFunction !== 0 && (l = this._scene.getEngine(), this._cachedDepthFunctionState = l.getDepthFunction() || 0, l.setDepthFunction(this.depthFunction));
+ }, E.prototype.unbind = function() {
+ this._onUnBindObservable && this._onUnBindObservable.notifyObservers(this), this.depthFunction !== 0 && this._scene.getEngine().setDepthFunction(this._cachedDepthFunctionState), this.disableDepthWrite && this._scene.getEngine().setDepthWrite(this._cachedDepthWriteState), this.disableColorWrite && this._scene.getEngine().setColorWrite(this._cachedColorWriteState);
+ }, E.prototype.getActiveTextures = function() {
+ return [];
+ }, E.prototype.hasTexture = function(g) {
+ return !1;
+ }, E.prototype.clone = function(g) {
+ return null;
+ }, E.prototype.getBindedMeshes = function() {
+ var g = this;
+ if (this.meshMap) {
+ var l = new Array();
+ for (var h in this.meshMap) {
+ var v = this.meshMap[h];
+ v && l.push(v);
+ }
+ return l;
+ }
+ return this._scene.meshes.filter(function(b) {
+ return b.material === g;
+ });
+ }, E.prototype.forceCompilation = function(g, l, h, v) {
+ var b = this, D = Object(V.a)({ clipPlane: !1, useInstances: !1 }, h), w = this.getScene(), N = this.allowShaderHotSwapping;
+ this.allowShaderHotSwapping = !1;
+ var M = function() {
+ if (b._scene && b._scene.getEngine()) {
+ var U = w.clipPlane;
+ if (D.clipPlane && (w.clipPlane = new T.a(0, 0, 0, 1)), b._storeEffectOnSubMeshes) {
+ var X = !0, j = null;
+ if (g.subMeshes) {
+ var ne = new O.a(0, 0, 0, 0, 0, g, void 0, !1, !1);
+ ne._materialDefines && (ne._materialDefines._renderId = -1), b.isReadyForSubMesh(g, ne, D.useInstances) || (ne.effect && ne.effect.getCompilationError() && ne.effect.allFallbacksProcessed() ? j = ne.effect.getCompilationError() : (X = !1, setTimeout(M, 16)));
+ }
+ X && (b.allowShaderHotSwapping = N, j && v && v(j), l && l(b));
+ } else
+ b.isReady() ? (b.allowShaderHotSwapping = N, l && l(b)) : setTimeout(M, 16);
+ D.clipPlane && (w.clipPlane = U);
+ }
+ };
+ M();
+ }, E.prototype.forceCompilationAsync = function(g, l) {
+ var h = this;
+ return new Promise(function(v, b) {
+ h.forceCompilation(g, function() {
+ v();
+ }, l, function(D) {
+ b(D);
+ });
+ });
+ }, E.prototype.markAsDirty = function(g) {
+ this.getScene().blockMaterialDirtyMechanism || (E._DirtyCallbackArray.length = 0, g & E.TextureDirtyFlag && E._DirtyCallbackArray.push(E._TextureDirtyCallBack), g & E.LightDirtyFlag && E._DirtyCallbackArray.push(E._LightsDirtyCallBack), g & E.FresnelDirtyFlag && E._DirtyCallbackArray.push(E._FresnelDirtyCallBack), g & E.AttributesDirtyFlag && E._DirtyCallbackArray.push(E._AttributeDirtyCallBack), g & E.MiscDirtyFlag && E._DirtyCallbackArray.push(E._MiscDirtyCallBack), g & E.PrePassDirtyFlag && E._DirtyCallbackArray.push(E._PrePassDirtyCallBack), E._DirtyCallbackArray.length && this._markAllSubMeshesAsDirty(E._RunDirtyCallBacks), this.getScene().resetCachedMaterial());
+ }, E.prototype._markAllSubMeshesAsDirty = function(g) {
+ if (!this.getScene().blockMaterialDirtyMechanism)
+ for (var l = 0, h = this.getScene().meshes; l < h.length; l++) {
+ var v = h[l];
+ if (v.subMeshes)
+ for (var b = 0, D = v.subMeshes; b < D.length; b++) {
+ var w = D[b];
+ w.getMaterial() === this && w._materialDefines && g(w._materialDefines);
+ }
+ }
+ }, E.prototype._markScenePrePassDirty = function() {
+ if (!this.getScene().blockMaterialDirtyMechanism) {
+ var g = this.getScene().enablePrePassRenderer();
+ g && g.markAsDirty();
+ }
+ }, E.prototype._markAllSubMeshesAsAllDirty = function() {
+ this._markAllSubMeshesAsDirty(E._AllDirtyCallBack);
+ }, E.prototype._markAllSubMeshesAsImageProcessingDirty = function() {
+ this._markAllSubMeshesAsDirty(E._ImageProcessingDirtyCallBack);
+ }, E.prototype._markAllSubMeshesAsTexturesDirty = function() {
+ this._markAllSubMeshesAsDirty(E._TextureDirtyCallBack);
+ }, E.prototype._markAllSubMeshesAsFresnelDirty = function() {
+ this._markAllSubMeshesAsDirty(E._FresnelDirtyCallBack);
+ }, E.prototype._markAllSubMeshesAsFresnelAndMiscDirty = function() {
+ this._markAllSubMeshesAsDirty(E._FresnelAndMiscDirtyCallBack);
+ }, E.prototype._markAllSubMeshesAsLightsDirty = function() {
+ this._markAllSubMeshesAsDirty(E._LightsDirtyCallBack);
+ }, E.prototype._markAllSubMeshesAsAttributesDirty = function() {
+ this._markAllSubMeshesAsDirty(E._AttributeDirtyCallBack);
+ }, E.prototype._markAllSubMeshesAsMiscDirty = function() {
+ this._markAllSubMeshesAsDirty(E._MiscDirtyCallBack);
+ }, E.prototype._markAllSubMeshesAsPrePassDirty = function() {
+ this._markAllSubMeshesAsDirty(E._MiscDirtyCallBack);
+ }, E.prototype._markAllSubMeshesAsTexturesAndMiscDirty = function() {
+ this._markAllSubMeshesAsDirty(E._TextureAndMiscDirtyCallBack);
+ }, E.prototype.setPrePassRenderer = function(g) {
+ return !1;
+ }, E.prototype.dispose = function(g, l, h) {
+ var v = this.getScene();
+ if (v.stopAnimation(this), v.freeProcessedMaterials(), v.removeMaterial(this), h !== !0)
+ if (this.meshMap)
+ for (var b in this.meshMap)
+ (N = this.meshMap[b]) && (N.material = null, this.releaseVertexArrayObject(N, g));
+ else
+ for (var D = 0, w = v.meshes; D < w.length; D++) {
+ var N;
+ (N = w[D]).material !== this || N.sourceMesh || (N.material = null, this.releaseVertexArrayObject(N, g));
+ }
+ this._uniformBuffer.dispose(), g && this._effect && (this._storeEffectOnSubMeshes || this._effect.dispose(), this._effect = null), this.onDisposeObservable.notifyObservers(this), this.onDisposeObservable.clear(), this._onBindObservable && this._onBindObservable.clear(), this._onUnBindObservable && this._onUnBindObservable.clear(), this._onEffectCreatedObservable && this._onEffectCreatedObservable.clear();
+ }, E.prototype.releaseVertexArrayObject = function(g, l) {
+ if (g.geometry) {
+ var h = g.geometry;
+ if (this._storeEffectOnSubMeshes)
+ for (var v = 0, b = g.subMeshes; v < b.length; v++) {
+ var D = b[v];
+ h._releaseVertexArrayObject(D._materialEffect), l && D._materialEffect && D._materialEffect.dispose();
+ }
+ else
+ h._releaseVertexArrayObject(this._effect);
+ }
+ }, E.prototype.serialize = function() {
+ return _.a.Serialize(this);
+ }, E.Parse = function(g, l, h) {
+ if (g.customType) {
+ if (g.customType === "BABYLON.PBRMaterial" && g.overloadedAlbedo && (g.customType = "BABYLON.LegacyPBRMaterial", !BABYLON.LegacyPBRMaterial))
+ return c.a.Error("Your scene is trying to load a legacy version of the PBRMaterial, please, include it from the materials library."), null;
+ } else
+ g.customType = "BABYLON.StandardMaterial";
+ return C.b.Instantiate(g.customType).Parse(g, l, h);
+ }, E.TriangleFillMode = m.a.MATERIAL_TriangleFillMode, E.WireFrameFillMode = m.a.MATERIAL_WireFrameFillMode, E.PointFillMode = m.a.MATERIAL_PointFillMode, E.PointListDrawMode = m.a.MATERIAL_PointListDrawMode, E.LineListDrawMode = m.a.MATERIAL_LineListDrawMode, E.LineLoopDrawMode = m.a.MATERIAL_LineLoopDrawMode, E.LineStripDrawMode = m.a.MATERIAL_LineStripDrawMode, E.TriangleStripDrawMode = m.a.MATERIAL_TriangleStripDrawMode, E.TriangleFanDrawMode = m.a.MATERIAL_TriangleFanDrawMode, E.ClockWiseSideOrientation = m.a.MATERIAL_ClockWiseSideOrientation, E.CounterClockWiseSideOrientation = m.a.MATERIAL_CounterClockWiseSideOrientation, E.TextureDirtyFlag = m.a.MATERIAL_TextureDirtyFlag, E.LightDirtyFlag = m.a.MATERIAL_LightDirtyFlag, E.FresnelDirtyFlag = m.a.MATERIAL_FresnelDirtyFlag, E.AttributesDirtyFlag = m.a.MATERIAL_AttributesDirtyFlag, E.MiscDirtyFlag = m.a.MATERIAL_MiscDirtyFlag, E.PrePassDirtyFlag = m.a.MATERIAL_PrePassDirtyFlag, E.AllDirtyFlag = m.a.MATERIAL_AllDirtyFlag, E.MATERIAL_OPAQUE = 0, E.MATERIAL_ALPHATEST = 1, E.MATERIAL_ALPHABLEND = 2, E.MATERIAL_ALPHATESTANDBLEND = 3, E.MATERIAL_NORMALBLENDMETHOD_WHITEOUT = 0, E.MATERIAL_NORMALBLENDMETHOD_RNM = 1, E._AllDirtyCallBack = function(g) {
+ return g.markAllAsDirty();
+ }, E._ImageProcessingDirtyCallBack = function(g) {
+ return g.markAsImageProcessingDirty();
+ }, E._TextureDirtyCallBack = function(g) {
+ return g.markAsTexturesDirty();
+ }, E._FresnelDirtyCallBack = function(g) {
+ return g.markAsFresnelDirty();
+ }, E._MiscDirtyCallBack = function(g) {
+ return g.markAsMiscDirty();
+ }, E._PrePassDirtyCallBack = function(g) {
+ return g.markAsPrePassDirty();
+ }, E._LightsDirtyCallBack = function(g) {
+ return g.markAsLightDirty();
+ }, E._AttributeDirtyCallBack = function(g) {
+ return g.markAsAttributesDirty();
+ }, E._FresnelAndMiscDirtyCallBack = function(g) {
+ E._FresnelDirtyCallBack(g), E._MiscDirtyCallBack(g);
+ }, E._TextureAndMiscDirtyCallBack = function(g) {
+ E._TextureDirtyCallBack(g), E._MiscDirtyCallBack(g);
+ }, E._DirtyCallbackArray = [], E._RunDirtyCallBacks = function(g) {
+ for (var l = 0, h = E._DirtyCallbackArray; l < h.length; l++)
+ (0, h[l])(g);
+ }, Object(V.c)([Object(_.c)()], E.prototype, "id", void 0), Object(V.c)([Object(_.c)()], E.prototype, "uniqueId", void 0), Object(V.c)([Object(_.c)()], E.prototype, "name", void 0), Object(V.c)([Object(_.c)()], E.prototype, "checkReadyOnEveryCall", void 0), Object(V.c)([Object(_.c)()], E.prototype, "checkReadyOnlyOnce", void 0), Object(V.c)([Object(_.c)()], E.prototype, "state", void 0), Object(V.c)([Object(_.c)("alpha")], E.prototype, "_alpha", void 0), Object(V.c)([Object(_.c)("backFaceCulling")], E.prototype, "_backFaceCulling", void 0), Object(V.c)([Object(_.c)()], E.prototype, "sideOrientation", void 0), Object(V.c)([Object(_.c)("alphaMode")], E.prototype, "_alphaMode", void 0), Object(V.c)([Object(_.c)()], E.prototype, "_needDepthPrePass", void 0), Object(V.c)([Object(_.c)()], E.prototype, "disableDepthWrite", void 0), Object(V.c)([Object(_.c)()], E.prototype, "disableColorWrite", void 0), Object(V.c)([Object(_.c)()], E.prototype, "forceDepthWrite", void 0), Object(V.c)([Object(_.c)()], E.prototype, "depthFunction", void 0), Object(V.c)([Object(_.c)()], E.prototype, "separateCullingPass", void 0), Object(V.c)([Object(_.c)("fogEnabled")], E.prototype, "_fogEnabled", void 0), Object(V.c)([Object(_.c)()], E.prototype, "pointSize", void 0), Object(V.c)([Object(_.c)()], E.prototype, "zOffset", void 0), Object(V.c)([Object(_.c)()], E.prototype, "pointsCloud", null), Object(V.c)([Object(_.c)()], E.prototype, "fillMode", null), Object(V.c)([Object(_.c)()], E.prototype, "transparencyMode", null), E;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return w;
+ });
+ var V = f(22), _ = f(5), C = f(21), u = f(6), I = f(141), O = f(142), x = f(143), m = f(2), c = f(27), T = f(8), S = f(38), E = function() {
+ function N() {
+ }
+ return N.prototype.postProcessor = function(M, U, X, j) {
+ return j.getCaps().drawBuffersExtension || (M = M.replace(/#extension.+GL_EXT_draw_buffers.+(enable|require)/g, "")), M;
+ }, N;
+ }(), g = f(118), l = f(88), h = f(144), v = f(70), b = f(74), D = function() {
+ }, w = function() {
+ function N(M, U, X, j) {
+ var ne = this;
+ j === void 0 && (j = !1), this.forcePOTTextures = !1, this.isFullscreen = !1, this.cullBackFaces = !0, this.renderEvenInBackground = !0, this.preventCacheWipeBetweenFrames = !1, this.validateShaderPrograms = !1, this.useReverseDepthBuffer = !1, this.disableUniformBuffers = !1, this._uniformBuffers = new Array(), this._webGLVersion = 1, this._windowIsBackground = !1, this._highPrecisionShadersAllowed = !0, this._badOS = !1, this._badDesktopOS = !1, this._renderingQueueLaunched = !1, this._activeRenderLoops = new Array(), this.onContextLostObservable = new u.c(), this.onContextRestoredObservable = new u.c(), this._contextWasLost = !1, this._doNotHandleContextLost = !1, this.disableVertexArrayObjects = !1, this._colorWrite = !0, this._colorWriteChanged = !0, this._depthCullingState = new I.a(), this._stencilState = new O.a(), this._alphaState = new x.a(), this._alphaMode = m.a.ALPHA_ADD, this._alphaEquation = m.a.ALPHA_DISABLE, this._internalTexturesCache = new Array(), this._activeChannel = 0, this._currentTextureChannel = -1, this._boundTexturesCache = {}, this._compiledEffects = {}, this._vertexAttribArraysEnabled = [], this._uintIndicesCurrentlySet = !1, this._currentBoundBuffer = new Array(), this._currentFramebuffer = null, this._dummyFramebuffer = null, this._currentBufferPointers = new Array(), this._currentInstanceLocations = new Array(), this._currentInstanceBuffers = new Array(), this._vaoRecordInProgress = !1, this._mustWipeVertexAttributes = !1, this._nextFreeTextureSlots = new Array(), this._maxSimultaneousTextures = 0, this._activeRequests = new Array(), this._transformTextureUrl = null, this.hostInformation = { isMobile: !1 }, this.premultipliedAlpha = !0, this.onBeforeTextureInitObservable = new u.c(), this._viewportCached = { x: 0, y: 0, z: 0, w: 0 }, this._unpackFlipYCached = null, this.enableUnpackFlipYCached = !0, this._getDepthStencilBuffer = function(W, q, he, ge, me, _e) {
+ var ye = ne._gl, Pe = ye.createRenderbuffer();
+ return ye.bindRenderbuffer(ye.RENDERBUFFER, Pe), he > 1 && ye.renderbufferStorageMultisample ? ye.renderbufferStorageMultisample(ye.RENDERBUFFER, he, me, W, q) : ye.renderbufferStorage(ye.RENDERBUFFER, ge, W, q), ye.framebufferRenderbuffer(ye.FRAMEBUFFER, _e, ye.RENDERBUFFER, Pe), ye.bindRenderbuffer(ye.RENDERBUFFER, null), Pe;
+ }, this._boundUniforms = {};
+ var te = null;
+ if (M) {
+ if (X = X || {}, b.a.SetMatrixPrecision(!!X.useHighPrecisionMatrix), M.getContext) {
+ if (te = M, this._renderingCanvas = te, U != null && (X.antialias = U), X.deterministicLockstep === void 0 && (X.deterministicLockstep = !1), X.lockstepMaxSteps === void 0 && (X.lockstepMaxSteps = 4), X.timeStep === void 0 && (X.timeStep = 1 / 60), X.preserveDrawingBuffer === void 0 && (X.preserveDrawingBuffer = !1), X.audioEngine === void 0 && (X.audioEngine = !0), X.stencil === void 0 && (X.stencil = !0), X.premultipliedAlpha === !1 && (this.premultipliedAlpha = !1), X.xrCompatible === void 0 && (X.xrCompatible = !0), this._doNotHandleContextLost = !!X.doNotHandleContextLost, navigator && navigator.userAgent) {
+ var de = navigator.userAgent;
+ this.hostInformation.isMobile = de.indexOf("Mobile") !== -1;
+ for (var pe = 0, ae = N.ExceptionList; pe < ae.length; pe++) {
+ var ee = ae[pe], K = ee.key, $ = ee.targets;
+ if (new RegExp(K).test(de)) {
+ if (ee.capture && ee.captureConstraint) {
+ var L = ee.capture, G = ee.captureConstraint, Q = new RegExp(L).exec(de);
+ if (Q && Q.length > 0 && parseInt(Q[Q.length - 1]) >= G)
+ continue;
+ }
+ for (var oe = 0, re = $; oe < re.length; oe++)
+ switch (re[oe]) {
+ case "uniformBuffer":
+ this.disableUniformBuffers = !0;
+ break;
+ case "vao":
+ this.disableVertexArrayObjects = !0;
+ }
+ }
+ }
+ }
+ if (this._doNotHandleContextLost || (this._onContextLost = function(W) {
+ W.preventDefault(), ne._contextWasLost = !0, T.a.Warn("WebGL context lost."), ne.onContextLostObservable.notifyObservers(ne);
+ }, this._onContextRestored = function() {
+ setTimeout(function() {
+ ne._initGLContext(), ne._rebuildEffects(), ne._rebuildInternalTextures(), ne._rebuildBuffers(), ne.wipeCaches(!0), T.a.Warn("WebGL context successfully restored."), ne.onContextRestoredObservable.notifyObservers(ne), ne._contextWasLost = !1;
+ }, 0);
+ }, te.addEventListener("webglcontextlost", this._onContextLost, !1), te.addEventListener("webglcontextrestored", this._onContextRestored, !1), X.powerPreference = "high-performance"), !X.disableWebGL2Support)
+ try {
+ this._gl = te.getContext("webgl2", X) || te.getContext("experimental-webgl2", X), this._gl && (this._webGLVersion = 2, this._gl.deleteQuery || (this._webGLVersion = 1));
+ } catch {
+ }
+ if (!this._gl) {
+ if (!te)
+ throw new Error("The provided canvas is null or undefined.");
+ try {
+ this._gl = te.getContext("webgl", X) || te.getContext("experimental-webgl", X);
+ } catch {
+ throw new Error("WebGL not supported");
+ }
+ }
+ if (!this._gl)
+ throw new Error("WebGL not supported");
+ } else {
+ this._gl = M, this._renderingCanvas = this._gl.canvas, this._gl.renderbufferStorageMultisample && (this._webGLVersion = 2);
+ var Y = this._gl.getContextAttributes();
+ Y && (X.stencil = Y.stencil);
+ }
+ this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE), X.useHighPrecisionFloats !== void 0 && (this._highPrecisionShadersAllowed = X.useHighPrecisionFloats);
+ var k = S.a.IsWindowObjectExist() && window.devicePixelRatio || 1, H = X.limitDeviceRatio || k;
+ this._hardwareScalingLevel = j ? 1 / Math.min(H, k) : 1, this.resize(), this._isStencilEnable = !!X.stencil, this._initGLContext();
+ for (var Z = 0; Z < this._caps.maxVertexAttribs; Z++)
+ this._currentBufferPointers[Z] = new D();
+ this.webGLVersion > 1 ? this._shaderProcessor = new g.a() : this._shaderProcessor = new E(), this._badOS = /iPad/i.test(navigator.userAgent) || /iPhone/i.test(navigator.userAgent), this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent), this._creationOptions = X, console.log("Babylon.js v" + N.Version + " - " + this.description);
+ }
+ }
+ return Object.defineProperty(N, "NpmPackage", { get: function() {
+ return "babylonjs@4.2.2";
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(N, "Version", { get: function() {
+ return "4.2.2";
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(N.prototype, "description", { get: function() {
+ var M = "WebGL" + this.webGLVersion;
+ return this._caps.parallelShaderCompile && (M += " - Parallel shader compilation"), M;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(N, "ShadersRepository", { get: function() {
+ return _.a.ShadersRepository;
+ }, set: function(M) {
+ _.a.ShadersRepository = M;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(N.prototype, "supportsUniformBuffers", { get: function() {
+ return this.webGLVersion > 1 && !this.disableUniformBuffers;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(N.prototype, "_shouldUseHighPrecisionShader", { get: function() {
+ return !(!this._caps.highPrecisionShaderSupported || !this._highPrecisionShadersAllowed);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(N.prototype, "needPOTTextures", { get: function() {
+ return this._webGLVersion < 2 || this.forcePOTTextures;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(N.prototype, "doNotHandleContextLost", { get: function() {
+ return this._doNotHandleContextLost;
+ }, set: function(M) {
+ this._doNotHandleContextLost = M;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(N.prototype, "_supportsHardwareTextureRescaling", { get: function() {
+ return !1;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(N.prototype, "framebufferDimensionsObject", { set: function(M) {
+ this._framebufferDimensionsObject = M;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(N.prototype, "currentViewport", { get: function() {
+ return this._cachedViewport;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(N.prototype, "emptyTexture", { get: function() {
+ return this._emptyTexture || (this._emptyTexture = this.createRawTexture(new Uint8Array(4), 1, 1, m.a.TEXTUREFORMAT_RGBA, !1, !1, m.a.TEXTURE_NEAREST_SAMPLINGMODE)), this._emptyTexture;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(N.prototype, "emptyTexture3D", { get: function() {
+ return this._emptyTexture3D || (this._emptyTexture3D = this.createRawTexture3D(new Uint8Array(4), 1, 1, 1, m.a.TEXTUREFORMAT_RGBA, !1, !1, m.a.TEXTURE_NEAREST_SAMPLINGMODE)), this._emptyTexture3D;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(N.prototype, "emptyTexture2DArray", { get: function() {
+ return this._emptyTexture2DArray || (this._emptyTexture2DArray = this.createRawTexture2DArray(new Uint8Array(4), 1, 1, 1, m.a.TEXTUREFORMAT_RGBA, !1, !1, m.a.TEXTURE_NEAREST_SAMPLINGMODE)), this._emptyTexture2DArray;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(N.prototype, "emptyCubeTexture", { get: function() {
+ if (!this._emptyCubeTexture) {
+ var M = new Uint8Array(4), U = [M, M, M, M, M, M];
+ this._emptyCubeTexture = this.createRawCubeTexture(U, 1, m.a.TEXTUREFORMAT_RGBA, m.a.TEXTURETYPE_UNSIGNED_INT, !1, !1, m.a.TEXTURE_NEAREST_SAMPLINGMODE);
+ }
+ return this._emptyCubeTexture;
+ }, enumerable: !1, configurable: !0 }), N.prototype._rebuildInternalTextures = function() {
+ for (var M = 0, U = this._internalTexturesCache.slice(); M < U.length; M++)
+ U[M]._rebuild();
+ }, N.prototype._rebuildEffects = function() {
+ for (var M in this._compiledEffects)
+ this._compiledEffects[M]._prepareEffect();
+ _.a.ResetCache();
+ }, N.prototype.areAllEffectsReady = function() {
+ for (var M in this._compiledEffects)
+ if (!this._compiledEffects[M].isReady())
+ return !1;
+ return !0;
+ }, N.prototype._rebuildBuffers = function() {
+ for (var M = 0, U = this._uniformBuffers; M < U.length; M++)
+ U[M]._rebuild();
+ }, N.prototype._initGLContext = function() {
+ this._caps = { maxTexturesImageUnits: this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS), maxCombinedTexturesImageUnits: this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS), maxVertexTextureImageUnits: this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS), maxTextureSize: this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE), maxSamples: this._webGLVersion > 1 ? this._gl.getParameter(this._gl.MAX_SAMPLES) : 1, maxCubemapTextureSize: this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE), maxRenderTextureSize: this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE), maxVertexAttribs: this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS), maxVaryingVectors: this._gl.getParameter(this._gl.MAX_VARYING_VECTORS), maxFragmentUniformVectors: this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS), maxVertexUniformVectors: this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS), parallelShaderCompile: this._gl.getExtension("KHR_parallel_shader_compile"), standardDerivatives: this._webGLVersion > 1 || this._gl.getExtension("OES_standard_derivatives") !== null, maxAnisotropy: 1, astc: this._gl.getExtension("WEBGL_compressed_texture_astc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_astc"), bptc: this._gl.getExtension("EXT_texture_compression_bptc") || this._gl.getExtension("WEBKIT_EXT_texture_compression_bptc"), s3tc: this._gl.getExtension("WEBGL_compressed_texture_s3tc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc"), pvrtc: this._gl.getExtension("WEBGL_compressed_texture_pvrtc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"), etc1: this._gl.getExtension("WEBGL_compressed_texture_etc1") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc1"), etc2: this._gl.getExtension("WEBGL_compressed_texture_etc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc") || this._gl.getExtension("WEBGL_compressed_texture_es3_0"), textureAnisotropicFilterExtension: this._gl.getExtension("EXT_texture_filter_anisotropic") || this._gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic") || this._gl.getExtension("MOZ_EXT_texture_filter_anisotropic"), uintIndices: this._webGLVersion > 1 || this._gl.getExtension("OES_element_index_uint") !== null, fragmentDepthSupported: this._webGLVersion > 1 || this._gl.getExtension("EXT_frag_depth") !== null, highPrecisionShaderSupported: !1, timerQuery: this._gl.getExtension("EXT_disjoint_timer_query_webgl2") || this._gl.getExtension("EXT_disjoint_timer_query"), canUseTimestampForTimerQuery: !1, drawBuffersExtension: !1, maxMSAASamples: 1, colorBufferFloat: this._webGLVersion > 1 && this._gl.getExtension("EXT_color_buffer_float"), textureFloat: !!(this._webGLVersion > 1 || this._gl.getExtension("OES_texture_float")), textureHalfFloat: !!(this._webGLVersion > 1 || this._gl.getExtension("OES_texture_half_float")), textureHalfFloatRender: !1, textureFloatLinearFiltering: !1, textureFloatRender: !1, textureHalfFloatLinearFiltering: !1, vertexArrayObject: !1, instancedArrays: !1, textureLOD: !!(this._webGLVersion > 1 || this._gl.getExtension("EXT_shader_texture_lod")), blendMinMax: !1, multiview: this._gl.getExtension("OVR_multiview2"), oculusMultiview: this._gl.getExtension("OCULUS_multiview"), depthTextureExtension: !1 }, this._glVersion = this._gl.getParameter(this._gl.VERSION);
+ var M = this._gl.getExtension("WEBGL_debug_renderer_info");
+ if (M != null && (this._glRenderer = this._gl.getParameter(M.UNMASKED_RENDERER_WEBGL), this._glVendor = this._gl.getParameter(M.UNMASKED_VENDOR_WEBGL)), this._glVendor || (this._glVendor = "Unknown vendor"), this._glRenderer || (this._glRenderer = "Unknown renderer"), this._gl.HALF_FLOAT_OES !== 36193 && (this._gl.HALF_FLOAT_OES = 36193), this._gl.RGBA16F !== 34842 && (this._gl.RGBA16F = 34842), this._gl.RGBA32F !== 34836 && (this._gl.RGBA32F = 34836), this._gl.DEPTH24_STENCIL8 !== 35056 && (this._gl.DEPTH24_STENCIL8 = 35056), this._caps.timerQuery && (this._webGLVersion === 1 && (this._gl.getQuery = this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery)), this._caps.canUseTimestampForTimerQuery = this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT, this._caps.timerQuery.QUERY_COUNTER_BITS_EXT) > 0), this._caps.maxAnisotropy = this._caps.textureAnisotropicFilterExtension ? this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0, this._caps.textureFloatLinearFiltering = !(!this._caps.textureFloat || !this._gl.getExtension("OES_texture_float_linear")), this._caps.textureFloatRender = !(!this._caps.textureFloat || !this._canRenderToFloatFramebuffer()), this._caps.textureHalfFloatLinearFiltering = !!(this._webGLVersion > 1 || this._caps.textureHalfFloat && this._gl.getExtension("OES_texture_half_float_linear")), this._webGLVersion > 1 && this._gl.HALF_FLOAT_OES !== 5131 && (this._gl.HALF_FLOAT_OES = 5131), this._caps.textureHalfFloatRender = this._caps.textureHalfFloat && this._canRenderToHalfFloatFramebuffer(), this._webGLVersion > 1)
+ this._caps.drawBuffersExtension = !0, this._caps.maxMSAASamples = this._gl.getParameter(this._gl.MAX_SAMPLES);
+ else {
+ var U = this._gl.getExtension("WEBGL_draw_buffers");
+ if (U !== null) {
+ this._caps.drawBuffersExtension = !0, this._gl.drawBuffers = U.drawBuffersWEBGL.bind(U), this._gl.DRAW_FRAMEBUFFER = this._gl.FRAMEBUFFER;
+ for (var X = 0; X < 16; X++)
+ this._gl["COLOR_ATTACHMENT" + X + "_WEBGL"] = U["COLOR_ATTACHMENT" + X + "_WEBGL"];
+ }
+ }
+ if (this._webGLVersion > 1)
+ this._caps.depthTextureExtension = !0;
+ else {
+ var j = this._gl.getExtension("WEBGL_depth_texture");
+ j != null && (this._caps.depthTextureExtension = !0, this._gl.UNSIGNED_INT_24_8 = j.UNSIGNED_INT_24_8_WEBGL);
+ }
+ if (this.disableVertexArrayObjects)
+ this._caps.vertexArrayObject = !1;
+ else if (this._webGLVersion > 1)
+ this._caps.vertexArrayObject = !0;
+ else {
+ var ne = this._gl.getExtension("OES_vertex_array_object");
+ ne != null && (this._caps.vertexArrayObject = !0, this._gl.createVertexArray = ne.createVertexArrayOES.bind(ne), this._gl.bindVertexArray = ne.bindVertexArrayOES.bind(ne), this._gl.deleteVertexArray = ne.deleteVertexArrayOES.bind(ne));
+ }
+ if (this._webGLVersion > 1)
+ this._caps.instancedArrays = !0;
+ else {
+ var te = this._gl.getExtension("ANGLE_instanced_arrays");
+ te != null ? (this._caps.instancedArrays = !0, this._gl.drawArraysInstanced = te.drawArraysInstancedANGLE.bind(te), this._gl.drawElementsInstanced = te.drawElementsInstancedANGLE.bind(te), this._gl.vertexAttribDivisor = te.vertexAttribDivisorANGLE.bind(te)) : this._caps.instancedArrays = !1;
+ }
+ if (this._gl.getShaderPrecisionFormat) {
+ var de = this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER, this._gl.HIGH_FLOAT), pe = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);
+ de && pe && (this._caps.highPrecisionShaderSupported = de.precision !== 0 && pe.precision !== 0);
+ }
+ if (this._webGLVersion > 1)
+ this._caps.blendMinMax = !0;
+ else {
+ var ae = this._gl.getExtension("EXT_blend_minmax");
+ ae != null && (this._caps.blendMinMax = !0, this._gl.MAX = ae.MAX_EXT, this._gl.MIN = ae.MIN_EXT);
+ }
+ this._depthCullingState.depthTest = !0, this._depthCullingState.depthFunc = this._gl.LEQUAL, this._depthCullingState.depthMask = !0, this._maxSimultaneousTextures = this._caps.maxCombinedTexturesImageUnits;
+ for (var ee = 0; ee < this._maxSimultaneousTextures; ee++)
+ this._nextFreeTextureSlots.push(ee);
+ }, Object.defineProperty(N.prototype, "webGLVersion", { get: function() {
+ return this._webGLVersion;
+ }, enumerable: !1, configurable: !0 }), N.prototype.getClassName = function() {
+ return "ThinEngine";
+ }, Object.defineProperty(N.prototype, "isStencilEnable", { get: function() {
+ return this._isStencilEnable;
+ }, enumerable: !1, configurable: !0 }), N.prototype._prepareWorkingCanvas = function() {
+ if (!this._workingCanvas) {
+ this._workingCanvas = v.a.CreateCanvas(1, 1);
+ var M = this._workingCanvas.getContext("2d");
+ M && (this._workingContext = M);
+ }
+ }, N.prototype.resetTextureCache = function() {
+ for (var M in this._boundTexturesCache)
+ this._boundTexturesCache.hasOwnProperty(M) && (this._boundTexturesCache[M] = null);
+ this._currentTextureChannel = -1;
+ }, N.prototype.getGlInfo = function() {
+ return { vendor: this._glVendor, renderer: this._glRenderer, version: this._glVersion };
+ }, N.prototype.setHardwareScalingLevel = function(M) {
+ this._hardwareScalingLevel = M, this.resize();
+ }, N.prototype.getHardwareScalingLevel = function() {
+ return this._hardwareScalingLevel;
+ }, N.prototype.getLoadedTexturesCache = function() {
+ return this._internalTexturesCache;
+ }, N.prototype.getCaps = function() {
+ return this._caps;
+ }, N.prototype.stopRenderLoop = function(M) {
+ if (M) {
+ var U = this._activeRenderLoops.indexOf(M);
+ U >= 0 && this._activeRenderLoops.splice(U, 1);
+ } else
+ this._activeRenderLoops = [];
+ }, N.prototype._renderLoop = function() {
+ if (!this._contextWasLost) {
+ var M = !0;
+ if (!this.renderEvenInBackground && this._windowIsBackground && (M = !1), M) {
+ this.beginFrame();
+ for (var U = 0; U < this._activeRenderLoops.length; U++)
+ (0, this._activeRenderLoops[U])();
+ this.endFrame();
+ }
+ }
+ this._activeRenderLoops.length > 0 ? this._frameHandler = this._queueNewFrame(this._boundRenderFunction, this.getHostWindow()) : this._renderingQueueLaunched = !1;
+ }, N.prototype.getRenderingCanvas = function() {
+ return this._renderingCanvas;
+ }, N.prototype.getHostWindow = function() {
+ return S.a.IsWindowObjectExist() ? this._renderingCanvas && this._renderingCanvas.ownerDocument && this._renderingCanvas.ownerDocument.defaultView ? this._renderingCanvas.ownerDocument.defaultView : window : null;
+ }, N.prototype.getRenderWidth = function(M) {
+ return M === void 0 && (M = !1), !M && this._currentRenderTarget ? this._currentRenderTarget.width : this._framebufferDimensionsObject ? this._framebufferDimensionsObject.framebufferWidth : this._gl.drawingBufferWidth;
+ }, N.prototype.getRenderHeight = function(M) {
+ return M === void 0 && (M = !1), !M && this._currentRenderTarget ? this._currentRenderTarget.height : this._framebufferDimensionsObject ? this._framebufferDimensionsObject.framebufferHeight : this._gl.drawingBufferHeight;
+ }, N.prototype._queueNewFrame = function(M, U) {
+ return N.QueueNewFrame(M, U);
+ }, N.prototype.runRenderLoop = function(M) {
+ this._activeRenderLoops.indexOf(M) === -1 && (this._activeRenderLoops.push(M), this._renderingQueueLaunched || (this._renderingQueueLaunched = !0, this._boundRenderFunction = this._renderLoop.bind(this), this._frameHandler = this._queueNewFrame(this._boundRenderFunction, this.getHostWindow())));
+ }, N.prototype.clear = function(M, U, X, j) {
+ j === void 0 && (j = !1), this.applyStates();
+ var ne = 0;
+ U && M && (this._gl.clearColor(M.r, M.g, M.b, M.a !== void 0 ? M.a : 1), ne |= this._gl.COLOR_BUFFER_BIT), X && (this.useReverseDepthBuffer ? (this._depthCullingState.depthFunc = this._gl.GREATER, this._gl.clearDepth(0)) : this._gl.clearDepth(1), ne |= this._gl.DEPTH_BUFFER_BIT), j && (this._gl.clearStencil(0), ne |= this._gl.STENCIL_BUFFER_BIT), this._gl.clear(ne);
+ }, N.prototype._viewport = function(M, U, X, j) {
+ M === this._viewportCached.x && U === this._viewportCached.y && X === this._viewportCached.z && j === this._viewportCached.w || (this._viewportCached.x = M, this._viewportCached.y = U, this._viewportCached.z = X, this._viewportCached.w = j, this._gl.viewport(M, U, X, j));
+ }, N.prototype.setViewport = function(M, U, X) {
+ var j = U || this.getRenderWidth(), ne = X || this.getRenderHeight(), te = M.x || 0, de = M.y || 0;
+ this._cachedViewport = M, this._viewport(te * j, de * ne, j * M.width, ne * M.height);
+ }, N.prototype.beginFrame = function() {
+ }, N.prototype.endFrame = function() {
+ this._badOS && this.flushFramebuffer();
+ }, N.prototype.resize = function() {
+ var M, U;
+ S.a.IsWindowObjectExist() ? (M = this._renderingCanvas ? this._renderingCanvas.clientWidth || this._renderingCanvas.width : window.innerWidth, U = this._renderingCanvas ? this._renderingCanvas.clientHeight || this._renderingCanvas.height : window.innerHeight) : (M = this._renderingCanvas ? this._renderingCanvas.width : 100, U = this._renderingCanvas ? this._renderingCanvas.height : 100), this.setSize(M / this._hardwareScalingLevel, U / this._hardwareScalingLevel);
+ }, N.prototype.setSize = function(M, U) {
+ return !!this._renderingCanvas && (M |= 0, U |= 0, (this._renderingCanvas.width !== M || this._renderingCanvas.height !== U) && (this._renderingCanvas.width = M, this._renderingCanvas.height = U, !0));
+ }, N.prototype.bindFramebuffer = function(M, U, X, j, ne, te, de) {
+ U === void 0 && (U = 0), te === void 0 && (te = 0), de === void 0 && (de = 0), this._currentRenderTarget && this.unBindFramebuffer(this._currentRenderTarget), this._currentRenderTarget = M, this._bindUnboundFramebuffer(M._MSAAFramebuffer ? M._MSAAFramebuffer : M._framebuffer);
+ var pe = this._gl;
+ M.is2DArray ? pe.framebufferTextureLayer(pe.FRAMEBUFFER, pe.COLOR_ATTACHMENT0, M._webGLTexture, te, de) : M.isCube && pe.framebufferTexture2D(pe.FRAMEBUFFER, pe.COLOR_ATTACHMENT0, pe.TEXTURE_CUBE_MAP_POSITIVE_X + U, M._webGLTexture, te);
+ var ae = M._depthStencilTexture;
+ if (ae) {
+ var ee = ae._generateStencilBuffer ? pe.DEPTH_STENCIL_ATTACHMENT : pe.DEPTH_ATTACHMENT;
+ M.is2DArray ? pe.framebufferTextureLayer(pe.FRAMEBUFFER, ee, ae._webGLTexture, te, de) : M.isCube ? pe.framebufferTexture2D(pe.FRAMEBUFFER, ee, pe.TEXTURE_CUBE_MAP_POSITIVE_X + U, ae._webGLTexture, te) : pe.framebufferTexture2D(pe.FRAMEBUFFER, ee, pe.TEXTURE_2D, ae._webGLTexture, te);
+ }
+ this._cachedViewport && !ne ? this.setViewport(this._cachedViewport, X, j) : (X || (X = M.width, te && (X /= Math.pow(2, te))), j || (j = M.height, te && (j /= Math.pow(2, te))), this._viewport(0, 0, X, j)), this.wipeCaches();
+ }, N.prototype._bindUnboundFramebuffer = function(M) {
+ this._currentFramebuffer !== M && (this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, M), this._currentFramebuffer = M);
+ }, N.prototype.unBindFramebuffer = function(M, U, X) {
+ U === void 0 && (U = !1), this._currentRenderTarget = null;
+ var j = this._gl;
+ if (M._MSAAFramebuffer) {
+ if (M._textureArray)
+ return void this.unBindMultiColorAttachmentFramebuffer(M._textureArray, U, X);
+ j.bindFramebuffer(j.READ_FRAMEBUFFER, M._MSAAFramebuffer), j.bindFramebuffer(j.DRAW_FRAMEBUFFER, M._framebuffer), j.blitFramebuffer(0, 0, M.width, M.height, 0, 0, M.width, M.height, j.COLOR_BUFFER_BIT, j.NEAREST);
+ }
+ !M.generateMipMaps || U || M.isCube || (this._bindTextureDirectly(j.TEXTURE_2D, M, !0), j.generateMipmap(j.TEXTURE_2D), this._bindTextureDirectly(j.TEXTURE_2D, null)), X && (M._MSAAFramebuffer && this._bindUnboundFramebuffer(M._framebuffer), X()), this._bindUnboundFramebuffer(null);
+ }, N.prototype.flushFramebuffer = function() {
+ this._gl.flush();
+ }, N.prototype.restoreDefaultFramebuffer = function() {
+ this._currentRenderTarget ? this.unBindFramebuffer(this._currentRenderTarget) : this._bindUnboundFramebuffer(null), this._cachedViewport && this.setViewport(this._cachedViewport), this.wipeCaches();
+ }, N.prototype._resetVertexBufferBinding = function() {
+ this.bindArrayBuffer(null), this._cachedVertexBuffers = null;
+ }, N.prototype.createVertexBuffer = function(M) {
+ return this._createVertexBuffer(M, this._gl.STATIC_DRAW);
+ }, N.prototype._createVertexBuffer = function(M, U) {
+ var X = this._gl.createBuffer();
+ if (!X)
+ throw new Error("Unable to create vertex buffer");
+ var j = new l.a(X);
+ return this.bindArrayBuffer(j), M instanceof Array ? this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(M), this._gl.STATIC_DRAW) : this._gl.bufferData(this._gl.ARRAY_BUFFER, M, this._gl.STATIC_DRAW), this._resetVertexBufferBinding(), j.references = 1, j;
+ }, N.prototype.createDynamicVertexBuffer = function(M) {
+ return this._createVertexBuffer(M, this._gl.DYNAMIC_DRAW);
+ }, N.prototype._resetIndexBufferBinding = function() {
+ this.bindIndexBuffer(null), this._cachedIndexBuffer = null;
+ }, N.prototype.createIndexBuffer = function(M, U) {
+ var X = this._gl.createBuffer(), j = new l.a(X);
+ if (!X)
+ throw new Error("Unable to create index buffer");
+ this.bindIndexBuffer(j);
+ var ne = this._normalizeIndexData(M);
+ return this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, ne, U ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW), this._resetIndexBufferBinding(), j.references = 1, j.is32Bits = ne.BYTES_PER_ELEMENT === 4, j;
+ }, N.prototype._normalizeIndexData = function(M) {
+ if (M instanceof Uint16Array)
+ return M;
+ if (this._caps.uintIndices) {
+ if (M instanceof Uint32Array)
+ return M;
+ for (var U = 0; U < M.length; U++)
+ if (M[U] >= 65535)
+ return new Uint32Array(M);
+ return new Uint16Array(M);
+ }
+ return new Uint16Array(M);
+ }, N.prototype.bindArrayBuffer = function(M) {
+ this._vaoRecordInProgress || this._unbindVertexArrayObject(), this.bindBuffer(M, this._gl.ARRAY_BUFFER);
+ }, N.prototype.bindUniformBlock = function(M, U, X) {
+ var j = M.program, ne = this._gl.getUniformBlockIndex(j, U);
+ this._gl.uniformBlockBinding(j, ne, X);
+ }, N.prototype.bindIndexBuffer = function(M) {
+ this._vaoRecordInProgress || this._unbindVertexArrayObject(), this.bindBuffer(M, this._gl.ELEMENT_ARRAY_BUFFER);
+ }, N.prototype.bindBuffer = function(M, U) {
+ (this._vaoRecordInProgress || this._currentBoundBuffer[U] !== M) && (this._gl.bindBuffer(U, M ? M.underlyingResource : null), this._currentBoundBuffer[U] = M);
+ }, N.prototype.updateArrayBuffer = function(M) {
+ this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, M);
+ }, N.prototype._vertexAttribPointer = function(M, U, X, j, ne, te, de) {
+ var pe = this._currentBufferPointers[U];
+ if (pe) {
+ var ae = !1;
+ pe.active ? (pe.buffer !== M && (pe.buffer = M, ae = !0), pe.size !== X && (pe.size = X, ae = !0), pe.type !== j && (pe.type = j, ae = !0), pe.normalized !== ne && (pe.normalized = ne, ae = !0), pe.stride !== te && (pe.stride = te, ae = !0), pe.offset !== de && (pe.offset = de, ae = !0)) : (ae = !0, pe.active = !0, pe.index = U, pe.size = X, pe.type = j, pe.normalized = ne, pe.stride = te, pe.offset = de, pe.buffer = M), (ae || this._vaoRecordInProgress) && (this.bindArrayBuffer(M), this._gl.vertexAttribPointer(U, X, j, ne, te, de));
+ }
+ }, N.prototype._bindIndexBufferWithCache = function(M) {
+ M != null && this._cachedIndexBuffer !== M && (this._cachedIndexBuffer = M, this.bindIndexBuffer(M), this._uintIndicesCurrentlySet = M.is32Bits);
+ }, N.prototype._bindVertexBuffersAttributes = function(M, U) {
+ var X = U.getAttributesNames();
+ this._vaoRecordInProgress || this._unbindVertexArrayObject(), this.unbindAllAttributes();
+ for (var j = 0; j < X.length; j++) {
+ var ne = U.getAttributeLocation(j);
+ if (ne >= 0) {
+ var te = M[X[j]];
+ if (!te)
+ continue;
+ this._gl.enableVertexAttribArray(ne), this._vaoRecordInProgress || (this._vertexAttribArraysEnabled[ne] = !0);
+ var de = te.getBuffer();
+ de && (this._vertexAttribPointer(de, ne, te.getSize(), te.type, te.normalized, te.byteStride, te.byteOffset), te.getIsInstanced() && (this._gl.vertexAttribDivisor(ne, te.getInstanceDivisor()), this._vaoRecordInProgress || (this._currentInstanceLocations.push(ne), this._currentInstanceBuffers.push(de))));
+ }
+ }
+ }, N.prototype.recordVertexArrayObject = function(M, U, X) {
+ var j = this._gl.createVertexArray();
+ return this._vaoRecordInProgress = !0, this._gl.bindVertexArray(j), this._mustWipeVertexAttributes = !0, this._bindVertexBuffersAttributes(M, X), this.bindIndexBuffer(U), this._vaoRecordInProgress = !1, this._gl.bindVertexArray(null), j;
+ }, N.prototype.bindVertexArrayObject = function(M, U) {
+ this._cachedVertexArrayObject !== M && (this._cachedVertexArrayObject = M, this._gl.bindVertexArray(M), this._cachedVertexBuffers = null, this._cachedIndexBuffer = null, this._uintIndicesCurrentlySet = U != null && U.is32Bits, this._mustWipeVertexAttributes = !0);
+ }, N.prototype.bindBuffersDirectly = function(M, U, X, j, ne) {
+ if (this._cachedVertexBuffers !== M || this._cachedEffectForVertexBuffers !== ne) {
+ this._cachedVertexBuffers = M, this._cachedEffectForVertexBuffers = ne;
+ var te = ne.getAttributesCount();
+ this._unbindVertexArrayObject(), this.unbindAllAttributes();
+ for (var de = 0, pe = 0; pe < te; pe++)
+ if (pe < X.length) {
+ var ae = ne.getAttributeLocation(pe);
+ ae >= 0 && (this._gl.enableVertexAttribArray(ae), this._vertexAttribArraysEnabled[ae] = !0, this._vertexAttribPointer(M, ae, X[pe], this._gl.FLOAT, !1, j, de)), de += 4 * X[pe];
+ }
+ }
+ this._bindIndexBufferWithCache(U);
+ }, N.prototype._unbindVertexArrayObject = function() {
+ this._cachedVertexArrayObject && (this._cachedVertexArrayObject = null, this._gl.bindVertexArray(null));
+ }, N.prototype.bindBuffers = function(M, U, X) {
+ this._cachedVertexBuffers === M && this._cachedEffectForVertexBuffers === X || (this._cachedVertexBuffers = M, this._cachedEffectForVertexBuffers = X, this._bindVertexBuffersAttributes(M, X)), this._bindIndexBufferWithCache(U);
+ }, N.prototype.unbindInstanceAttributes = function() {
+ for (var M, U = 0, X = this._currentInstanceLocations.length; U < X; U++) {
+ var j = this._currentInstanceBuffers[U];
+ M != j && j.references && (M = j, this.bindArrayBuffer(j));
+ var ne = this._currentInstanceLocations[U];
+ this._gl.vertexAttribDivisor(ne, 0);
+ }
+ this._currentInstanceBuffers.length = 0, this._currentInstanceLocations.length = 0;
+ }, N.prototype.releaseVertexArrayObject = function(M) {
+ this._gl.deleteVertexArray(M);
+ }, N.prototype._releaseBuffer = function(M) {
+ return M.references--, M.references === 0 && (this._deleteBuffer(M), !0);
+ }, N.prototype._deleteBuffer = function(M) {
+ this._gl.deleteBuffer(M.underlyingResource);
+ }, N.prototype.updateAndBindInstancesBuffer = function(M, U, X) {
+ if (this.bindArrayBuffer(M), U && this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, U), X[0].index !== void 0)
+ this.bindInstancesBuffer(M, X, !0);
+ else
+ for (var j = 0; j < 4; j++) {
+ var ne = X[j];
+ this._vertexAttribArraysEnabled[ne] || (this._gl.enableVertexAttribArray(ne), this._vertexAttribArraysEnabled[ne] = !0), this._vertexAttribPointer(M, ne, 4, this._gl.FLOAT, !1, 64, 16 * j), this._gl.vertexAttribDivisor(ne, 1), this._currentInstanceLocations.push(ne), this._currentInstanceBuffers.push(M);
+ }
+ }, N.prototype.bindInstancesBuffer = function(M, U, X) {
+ X === void 0 && (X = !0), this.bindArrayBuffer(M);
+ var j = 0;
+ if (X)
+ for (var ne = 0; ne < U.length; ne++)
+ j += 4 * (te = U[ne]).attributeSize;
+ for (ne = 0; ne < U.length; ne++) {
+ var te;
+ (te = U[ne]).index === void 0 && (te.index = this._currentEffect.getAttributeLocationByName(te.attributeName)), te.index < 0 || (this._vertexAttribArraysEnabled[te.index] || (this._gl.enableVertexAttribArray(te.index), this._vertexAttribArraysEnabled[te.index] = !0), this._vertexAttribPointer(M, te.index, te.attributeSize, te.attributeType || this._gl.FLOAT, te.normalized || !1, j, te.offset), this._gl.vertexAttribDivisor(te.index, te.divisor === void 0 ? 1 : te.divisor), this._currentInstanceLocations.push(te.index), this._currentInstanceBuffers.push(M));
+ }
+ }, N.prototype.disableInstanceAttributeByName = function(M) {
+ if (this._currentEffect) {
+ var U = this._currentEffect.getAttributeLocationByName(M);
+ this.disableInstanceAttribute(U);
+ }
+ }, N.prototype.disableInstanceAttribute = function(M) {
+ for (var U, X = !1; (U = this._currentInstanceLocations.indexOf(M)) !== -1; )
+ this._currentInstanceLocations.splice(U, 1), this._currentInstanceBuffers.splice(U, 1), X = !0, U = this._currentInstanceLocations.indexOf(M);
+ X && (this._gl.vertexAttribDivisor(M, 0), this.disableAttributeByIndex(M));
+ }, N.prototype.disableAttributeByIndex = function(M) {
+ this._gl.disableVertexAttribArray(M), this._vertexAttribArraysEnabled[M] = !1, this._currentBufferPointers[M].active = !1;
+ }, N.prototype.draw = function(M, U, X, j) {
+ this.drawElementsType(M ? m.a.MATERIAL_TriangleFillMode : m.a.MATERIAL_WireFrameFillMode, U, X, j);
+ }, N.prototype.drawPointClouds = function(M, U, X) {
+ this.drawArraysType(m.a.MATERIAL_PointFillMode, M, U, X);
+ }, N.prototype.drawUnIndexed = function(M, U, X, j) {
+ this.drawArraysType(M ? m.a.MATERIAL_TriangleFillMode : m.a.MATERIAL_WireFrameFillMode, U, X, j);
+ }, N.prototype.drawElementsType = function(M, U, X, j) {
+ this.applyStates(), this._reportDrawCall();
+ var ne = this._drawMode(M), te = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT, de = this._uintIndicesCurrentlySet ? 4 : 2;
+ j ? this._gl.drawElementsInstanced(ne, X, te, U * de, j) : this._gl.drawElements(ne, X, te, U * de);
+ }, N.prototype.drawArraysType = function(M, U, X, j) {
+ this.applyStates(), this._reportDrawCall();
+ var ne = this._drawMode(M);
+ j ? this._gl.drawArraysInstanced(ne, U, X, j) : this._gl.drawArrays(ne, U, X);
+ }, N.prototype._drawMode = function(M) {
+ switch (M) {
+ case m.a.MATERIAL_TriangleFillMode:
+ return this._gl.TRIANGLES;
+ case m.a.MATERIAL_PointFillMode:
+ return this._gl.POINTS;
+ case m.a.MATERIAL_WireFrameFillMode:
+ return this._gl.LINES;
+ case m.a.MATERIAL_PointListDrawMode:
+ return this._gl.POINTS;
+ case m.a.MATERIAL_LineListDrawMode:
+ return this._gl.LINES;
+ case m.a.MATERIAL_LineLoopDrawMode:
+ return this._gl.LINE_LOOP;
+ case m.a.MATERIAL_LineStripDrawMode:
+ return this._gl.LINE_STRIP;
+ case m.a.MATERIAL_TriangleStripDrawMode:
+ return this._gl.TRIANGLE_STRIP;
+ case m.a.MATERIAL_TriangleFanDrawMode:
+ return this._gl.TRIANGLE_FAN;
+ default:
+ return this._gl.TRIANGLES;
+ }
+ }, N.prototype._reportDrawCall = function() {
+ }, N.prototype._releaseEffect = function(M) {
+ this._compiledEffects[M._key] && (delete this._compiledEffects[M._key], this._deletePipelineContext(M.getPipelineContext()));
+ }, N.prototype._deletePipelineContext = function(M) {
+ var U = M;
+ U && U.program && (U.program.__SPECTOR_rebuildProgram = null, this._gl.deleteProgram(U.program));
+ }, N.prototype.createEffect = function(M, U, X, j, ne, te, de, pe, ae) {
+ var ee = (M.vertexElement || M.vertex || M.vertexToken || M.vertexSource || M) + "+" + (M.fragmentElement || M.fragment || M.fragmentToken || M.fragmentSource || M) + "@" + (ne || U.defines);
+ if (this._compiledEffects[ee]) {
+ var K = this._compiledEffects[ee];
+ return de && K.isReady() && de(K), K;
+ }
+ var $ = new _.a(M, U, X, j, this, ne, te, de, pe, ae);
+ return $._key = ee, this._compiledEffects[ee] = $, $;
+ }, N._ConcatenateShader = function(M, U, X) {
+ return X === void 0 && (X = ""), X + (U ? U + `
+` : "") + M;
+ }, N.prototype._compileShader = function(M, U, X, j) {
+ return this._compileRawShader(N._ConcatenateShader(M, X, j), U);
+ }, N.prototype._compileRawShader = function(M, U) {
+ var X = this._gl, j = X.createShader(U === "vertex" ? X.VERTEX_SHADER : X.FRAGMENT_SHADER);
+ if (!j)
+ throw new Error("Something went wrong while compile the shader.");
+ return X.shaderSource(j, M), X.compileShader(j), j;
+ }, N.prototype._getShaderSource = function(M) {
+ return this._gl.getShaderSource(M);
+ }, N.prototype.createRawShaderProgram = function(M, U, X, j, ne) {
+ ne === void 0 && (ne = null), j = j || this._gl;
+ var te = this._compileRawShader(U, "vertex"), de = this._compileRawShader(X, "fragment");
+ return this._createShaderProgram(M, te, de, j, ne);
+ }, N.prototype.createShaderProgram = function(M, U, X, j, ne, te) {
+ te === void 0 && (te = null), ne = ne || this._gl;
+ var de = this._webGLVersion > 1 ? `#version 300 es
+#define WEBGL2
+` : "", pe = this._compileShader(U, "vertex", j, de), ae = this._compileShader(X, "fragment", j, de);
+ return this._createShaderProgram(M, pe, ae, ne, te);
+ }, N.prototype.createPipelineContext = function() {
+ var M = new h.a();
+ return M.engine = this, this._caps.parallelShaderCompile && (M.isParallelCompiled = !0), M;
+ }, N.prototype._createShaderProgram = function(M, U, X, j, ne) {
+ var te = j.createProgram();
+ if (M.program = te, !te)
+ throw new Error("Unable to create program");
+ return j.attachShader(te, U), j.attachShader(te, X), j.linkProgram(te), M.context = j, M.vertexShader = U, M.fragmentShader = X, M.isParallelCompiled || this._finalizePipelineContext(M), te;
+ }, N.prototype._finalizePipelineContext = function(M) {
+ var U = M.context, X = M.vertexShader, j = M.fragmentShader, ne = M.program;
+ if (!U.getProgramParameter(ne, U.LINK_STATUS)) {
+ var te, de;
+ if (!this._gl.getShaderParameter(X, this._gl.COMPILE_STATUS) && (te = this._gl.getShaderInfoLog(X)))
+ throw M.vertexCompilationError = te, new Error("VERTEX SHADER " + te);
+ if (!this._gl.getShaderParameter(j, this._gl.COMPILE_STATUS) && (te = this._gl.getShaderInfoLog(j)))
+ throw M.fragmentCompilationError = te, new Error("FRAGMENT SHADER " + te);
+ if (de = U.getProgramInfoLog(ne))
+ throw M.programLinkError = de, new Error(de);
+ }
+ if (this.validateShaderPrograms && (U.validateProgram(ne), !U.getProgramParameter(ne, U.VALIDATE_STATUS) && (de = U.getProgramInfoLog(ne))))
+ throw M.programValidationError = de, new Error(de);
+ U.deleteShader(X), U.deleteShader(j), M.vertexShader = void 0, M.fragmentShader = void 0, M.onCompiled && (M.onCompiled(), M.onCompiled = void 0);
+ }, N.prototype._preparePipelineContext = function(M, U, X, j, ne, te, de) {
+ var pe = M;
+ pe.program = j ? this.createRawShaderProgram(pe, U, X, void 0, de) : this.createShaderProgram(pe, U, X, te, void 0, de), pe.program.__SPECTOR_rebuildProgram = ne;
+ }, N.prototype._isRenderingStateCompiled = function(M) {
+ var U = M;
+ return !!this._gl.getProgramParameter(U.program, this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR) && (this._finalizePipelineContext(U), !0);
+ }, N.prototype._executeWhenRenderingStateIsCompiled = function(M, U) {
+ var X = M;
+ if (X.isParallelCompiled) {
+ var j = X.onCompiled;
+ X.onCompiled = j ? function() {
+ j(), U();
+ } : U;
+ } else
+ U();
+ }, N.prototype.getUniforms = function(M, U) {
+ for (var X = new Array(), j = M, ne = 0; ne < U.length; ne++)
+ X.push(this._gl.getUniformLocation(j.program, U[ne]));
+ return X;
+ }, N.prototype.getAttributes = function(M, U) {
+ for (var X = [], j = M, ne = 0; ne < U.length; ne++)
+ try {
+ X.push(this._gl.getAttribLocation(j.program, U[ne]));
+ } catch {
+ X.push(-1);
+ }
+ return X;
+ }, N.prototype.enableEffect = function(M) {
+ M && M !== this._currentEffect && (this.bindSamplers(M), this._currentEffect = M, M.onBind && M.onBind(M), M._onBindObservable && M._onBindObservable.notifyObservers(M));
+ }, N.prototype.setInt = function(M, U) {
+ return !!M && (this._gl.uniform1i(M, U), !0);
+ }, N.prototype.setIntArray = function(M, U) {
+ return !!M && (this._gl.uniform1iv(M, U), !0);
+ }, N.prototype.setIntArray2 = function(M, U) {
+ return !(!M || U.length % 2 != 0) && (this._gl.uniform2iv(M, U), !0);
+ }, N.prototype.setIntArray3 = function(M, U) {
+ return !(!M || U.length % 3 != 0) && (this._gl.uniform3iv(M, U), !0);
+ }, N.prototype.setIntArray4 = function(M, U) {
+ return !(!M || U.length % 4 != 0) && (this._gl.uniform4iv(M, U), !0);
+ }, N.prototype.setArray = function(M, U) {
+ return !!M && (this._gl.uniform1fv(M, U), !0);
+ }, N.prototype.setArray2 = function(M, U) {
+ return !(!M || U.length % 2 != 0) && (this._gl.uniform2fv(M, U), !0);
+ }, N.prototype.setArray3 = function(M, U) {
+ return !(!M || U.length % 3 != 0) && (this._gl.uniform3fv(M, U), !0);
+ }, N.prototype.setArray4 = function(M, U) {
+ return !(!M || U.length % 4 != 0) && (this._gl.uniform4fv(M, U), !0);
+ }, N.prototype.setMatrices = function(M, U) {
+ return !!M && (this._gl.uniformMatrix4fv(M, !1, U), !0);
+ }, N.prototype.setMatrix3x3 = function(M, U) {
+ return !!M && (this._gl.uniformMatrix3fv(M, !1, U), !0);
+ }, N.prototype.setMatrix2x2 = function(M, U) {
+ return !!M && (this._gl.uniformMatrix2fv(M, !1, U), !0);
+ }, N.prototype.setFloat = function(M, U) {
+ return !!M && (this._gl.uniform1f(M, U), !0);
+ }, N.prototype.setFloat2 = function(M, U, X) {
+ return !!M && (this._gl.uniform2f(M, U, X), !0);
+ }, N.prototype.setFloat3 = function(M, U, X, j) {
+ return !!M && (this._gl.uniform3f(M, U, X, j), !0);
+ }, N.prototype.setFloat4 = function(M, U, X, j, ne) {
+ return !!M && (this._gl.uniform4f(M, U, X, j, ne), !0);
+ }, N.prototype.applyStates = function() {
+ if (this._depthCullingState.apply(this._gl), this._stencilState.apply(this._gl), this._alphaState.apply(this._gl), this._colorWriteChanged) {
+ this._colorWriteChanged = !1;
+ var M = this._colorWrite;
+ this._gl.colorMask(M, M, M, M);
+ }
+ }, N.prototype.setColorWrite = function(M) {
+ M !== this._colorWrite && (this._colorWriteChanged = !0, this._colorWrite = M);
+ }, N.prototype.getColorWrite = function() {
+ return this._colorWrite;
+ }, Object.defineProperty(N.prototype, "depthCullingState", { get: function() {
+ return this._depthCullingState;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(N.prototype, "alphaState", { get: function() {
+ return this._alphaState;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(N.prototype, "stencilState", { get: function() {
+ return this._stencilState;
+ }, enumerable: !1, configurable: !0 }), N.prototype.clearInternalTexturesCache = function() {
+ this._internalTexturesCache = [];
+ }, N.prototype.wipeCaches = function(M) {
+ this.preventCacheWipeBetweenFrames && !M || (this._currentEffect = null, this._viewportCached.x = 0, this._viewportCached.y = 0, this._viewportCached.z = 0, this._viewportCached.w = 0, this._unbindVertexArrayObject(), M && (this._currentProgram = null, this.resetTextureCache(), this._stencilState.reset(), this._depthCullingState.reset(), this._depthCullingState.depthFunc = this._gl.LEQUAL, this._alphaState.reset(), this._alphaMode = m.a.ALPHA_ADD, this._alphaEquation = m.a.ALPHA_DISABLE, this._colorWrite = !0, this._colorWriteChanged = !0, this._unpackFlipYCached = null, this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE), this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0), this._mustWipeVertexAttributes = !0, this.unbindAllAttributes()), this._resetVertexBufferBinding(), this._cachedIndexBuffer = null, this._cachedEffectForVertexBuffers = null, this.bindIndexBuffer(null));
+ }, N.prototype._getSamplingParameters = function(M, U) {
+ var X = this._gl, j = X.NEAREST, ne = X.NEAREST;
+ switch (M) {
+ case m.a.TEXTURE_LINEAR_LINEAR_MIPNEAREST:
+ j = X.LINEAR, ne = U ? X.LINEAR_MIPMAP_NEAREST : X.LINEAR;
+ break;
+ case m.a.TEXTURE_LINEAR_LINEAR_MIPLINEAR:
+ j = X.LINEAR, ne = U ? X.LINEAR_MIPMAP_LINEAR : X.LINEAR;
+ break;
+ case m.a.TEXTURE_NEAREST_NEAREST_MIPLINEAR:
+ j = X.NEAREST, ne = U ? X.NEAREST_MIPMAP_LINEAR : X.NEAREST;
+ break;
+ case m.a.TEXTURE_NEAREST_NEAREST_MIPNEAREST:
+ j = X.NEAREST, ne = U ? X.NEAREST_MIPMAP_NEAREST : X.NEAREST;
+ break;
+ case m.a.TEXTURE_NEAREST_LINEAR_MIPNEAREST:
+ j = X.NEAREST, ne = U ? X.LINEAR_MIPMAP_NEAREST : X.LINEAR;
+ break;
+ case m.a.TEXTURE_NEAREST_LINEAR_MIPLINEAR:
+ j = X.NEAREST, ne = U ? X.LINEAR_MIPMAP_LINEAR : X.LINEAR;
+ break;
+ case m.a.TEXTURE_NEAREST_LINEAR:
+ j = X.NEAREST, ne = X.LINEAR;
+ break;
+ case m.a.TEXTURE_NEAREST_NEAREST:
+ j = X.NEAREST, ne = X.NEAREST;
+ break;
+ case m.a.TEXTURE_LINEAR_NEAREST_MIPNEAREST:
+ j = X.LINEAR, ne = U ? X.NEAREST_MIPMAP_NEAREST : X.NEAREST;
+ break;
+ case m.a.TEXTURE_LINEAR_NEAREST_MIPLINEAR:
+ j = X.LINEAR, ne = U ? X.NEAREST_MIPMAP_LINEAR : X.NEAREST;
+ break;
+ case m.a.TEXTURE_LINEAR_LINEAR:
+ j = X.LINEAR, ne = X.LINEAR;
+ break;
+ case m.a.TEXTURE_LINEAR_NEAREST:
+ j = X.LINEAR, ne = X.NEAREST;
+ }
+ return { min: ne, mag: j };
+ }, N.prototype._createTexture = function() {
+ var M = this._gl.createTexture();
+ if (!M)
+ throw new Error("Unable to create texture");
+ return M;
+ }, N.prototype.createTexture = function(M, U, X, j, ne, te, de, pe, ae, ee, K, $, L) {
+ var G = this;
+ ne === void 0 && (ne = m.a.TEXTURE_TRILINEAR_SAMPLINGMODE), te === void 0 && (te = null), de === void 0 && (de = null), pe === void 0 && (pe = null), ae === void 0 && (ae = null), ee === void 0 && (ee = null), K === void 0 && (K = null);
+ var Q = (M = M || "").substr(0, 5) === "data:", oe = M.substr(0, 5) === "blob:", re = Q && M.indexOf(";base64,") !== -1, Y = ae || new c.a(this, c.b.Url), k = M;
+ !this._transformTextureUrl || re || ae || pe || (M = this._transformTextureUrl(M)), k !== M && (Y._originalUrl = k);
+ var H = M.lastIndexOf("."), Z = K || (H > -1 ? M.substring(H).toLowerCase() : ""), W = null;
+ Z.indexOf("?") > -1 && (Z = Z.split("?")[0]);
+ for (var q = 0, he = N._TextureLoaders; q < he.length; q++) {
+ var ge = he[q];
+ if (ge.canLoad(Z, $)) {
+ W = ge;
+ break;
+ }
+ }
+ j && j._addPendingData(Y), Y.url = M, Y.generateMipMaps = !U, Y.samplingMode = ne, Y.invertY = X, this._doNotHandleContextLost || (Y._buffer = pe);
+ var me = null;
+ te && !ae && (me = Y.onLoadedObservable.add(te)), ae || this._internalTexturesCache.push(Y);
+ var _e = function(be, Fe) {
+ j && j._removePendingData(Y), M === k ? (me && Y.onLoadedObservable.remove(me), V.a.UseFallbackTexture && G.createTexture(V.a.FallbackTexture, U, Y.invertY, j, ne, null, de, pe, Y), de && de((be || "Unknown error") + (V.a.UseFallbackTexture ? " - Fallback texture was used" : ""), Fe)) : (T.a.Warn("Failed to load " + M + ", falling back to " + k), G.createTexture(k, U, Y.invertY, j, ne, te, de, pe, Y, ee, K, $, L));
+ };
+ if (W) {
+ var ye = function(be) {
+ W.loadData(be, Y, function(Fe, ke, We, je, He, Qe) {
+ Qe ? _e("TextureLoader failed to load data") : G._prepareWebGLTexture(Y, j, Fe, ke, Y.invertY, !We, je, function() {
+ return He(), !1;
+ }, ne);
+ }, L);
+ };
+ pe ? pe instanceof ArrayBuffer ? ye(new Uint8Array(pe)) : ArrayBuffer.isView(pe) ? ye(pe) : de && de("Unable to load: only ArrayBuffer or ArrayBufferView is supported", null) : this._loadFile(M, function(be) {
+ return ye(new Uint8Array(be));
+ }, void 0, j ? j.offlineProvider : void 0, !0, function(be, Fe) {
+ _e("Unable to load " + (be && be.responseURL, Fe));
+ });
+ } else {
+ var Pe = function(be) {
+ oe && !G._doNotHandleContextLost && (Y._buffer = be), G._prepareWebGLTexture(Y, j, be.width, be.height, Y.invertY, U, !1, function(Fe, ke, We) {
+ var je = G._gl, He = be.width === Fe && be.height === ke, Qe = ee ? G._getInternalFormat(ee) : Z === ".jpg" ? je.RGB : je.RGBA;
+ if (He)
+ return je.texImage2D(je.TEXTURE_2D, 0, Qe, Qe, je.UNSIGNED_BYTE, be), !1;
+ var Ge = G._caps.maxTextureSize;
+ if (be.width > Ge || be.height > Ge || !G._supportsHardwareTextureRescaling)
+ return G._prepareWorkingCanvas(), !(!G._workingCanvas || !G._workingContext) && (G._workingCanvas.width = Fe, G._workingCanvas.height = ke, G._workingContext.drawImage(be, 0, 0, be.width, be.height, 0, 0, Fe, ke), je.texImage2D(je.TEXTURE_2D, 0, Qe, Qe, je.UNSIGNED_BYTE, G._workingCanvas), Y.width = Fe, Y.height = ke, !1);
+ var tt = new c.a(G, c.b.Temp);
+ return G._bindTextureDirectly(je.TEXTURE_2D, tt, !0), je.texImage2D(je.TEXTURE_2D, 0, Qe, Qe, je.UNSIGNED_BYTE, be), G._rescaleTexture(tt, Y, j, Qe, function() {
+ G._releaseTexture(tt), G._bindTextureDirectly(je.TEXTURE_2D, Y, !0), We();
+ }), !0;
+ }, ne);
+ };
+ !Q || re ? pe && (pe.decoding || pe.close) ? Pe(pe) : N._FileToolsLoadImage(M, Pe, _e, j ? j.offlineProvider : null, $) : typeof pe == "string" || pe instanceof ArrayBuffer || ArrayBuffer.isView(pe) || pe instanceof Blob ? N._FileToolsLoadImage(pe, Pe, _e, j ? j.offlineProvider : null, $) : pe && Pe(pe);
+ }
+ return Y;
+ }, N._FileToolsLoadImage = function(M, U, X, j, ne) {
+ throw C.a.WarnImport("FileTools");
+ }, N.prototype._rescaleTexture = function(M, U, X, j, ne) {
+ }, N.prototype.createRawTexture = function(M, U, X, j, ne, te, de, pe, ae) {
+ throw ae === void 0 && (ae = m.a.TEXTURETYPE_UNSIGNED_INT), C.a.WarnImport("Engine.RawTexture");
+ }, N.prototype.createRawCubeTexture = function(M, U, X, j, ne, te, de, pe) {
+ throw C.a.WarnImport("Engine.RawTexture");
+ }, N.prototype.createRawTexture3D = function(M, U, X, j, ne, te, de, pe, ae, ee) {
+ throw ee === void 0 && (ee = m.a.TEXTURETYPE_UNSIGNED_INT), C.a.WarnImport("Engine.RawTexture");
+ }, N.prototype.createRawTexture2DArray = function(M, U, X, j, ne, te, de, pe, ae, ee) {
+ throw ee === void 0 && (ee = m.a.TEXTURETYPE_UNSIGNED_INT), C.a.WarnImport("Engine.RawTexture");
+ }, N.prototype._unpackFlipY = function(M) {
+ this._unpackFlipYCached !== M && (this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, M ? 1 : 0), this.enableUnpackFlipYCached && (this._unpackFlipYCached = M));
+ }, N.prototype._getUnpackAlignement = function() {
+ return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT);
+ }, N.prototype._getTextureTarget = function(M) {
+ return M.isCube ? this._gl.TEXTURE_CUBE_MAP : M.is3D ? this._gl.TEXTURE_3D : M.is2DArray || M.isMultiview ? this._gl.TEXTURE_2D_ARRAY : this._gl.TEXTURE_2D;
+ }, N.prototype.updateTextureSamplingMode = function(M, U, X) {
+ X === void 0 && (X = !1);
+ var j = this._getTextureTarget(U), ne = this._getSamplingParameters(M, U.generateMipMaps || X);
+ this._setTextureParameterInteger(j, this._gl.TEXTURE_MAG_FILTER, ne.mag, U), this._setTextureParameterInteger(j, this._gl.TEXTURE_MIN_FILTER, ne.min), X && (U.generateMipMaps = !0, this._gl.generateMipmap(j)), this._bindTextureDirectly(j, null), U.samplingMode = M;
+ }, N.prototype.updateTextureWrappingMode = function(M, U, X, j) {
+ X === void 0 && (X = null), j === void 0 && (j = null);
+ var ne = this._getTextureTarget(M);
+ U !== null && (this._setTextureParameterInteger(ne, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(U), M), M._cachedWrapU = U), X !== null && (this._setTextureParameterInteger(ne, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(X), M), M._cachedWrapV = X), (M.is2DArray || M.is3D) && j !== null && (this._setTextureParameterInteger(ne, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(j), M), M._cachedWrapR = j), this._bindTextureDirectly(ne, null);
+ }, N.prototype._setupDepthStencilTexture = function(M, U, X, j, ne) {
+ var te = U.width || U, de = U.height || U, pe = U.layers || 0;
+ M.baseWidth = te, M.baseHeight = de, M.width = te, M.height = de, M.is2DArray = pe > 0, M.depth = pe, M.isReady = !0, M.samples = 1, M.generateMipMaps = !1, M._generateDepthBuffer = !0, M._generateStencilBuffer = X, M.samplingMode = j ? m.a.TEXTURE_BILINEAR_SAMPLINGMODE : m.a.TEXTURE_NEAREST_SAMPLINGMODE, M.type = m.a.TEXTURETYPE_UNSIGNED_INT, M._comparisonFunction = ne;
+ var ae = this._gl, ee = this._getTextureTarget(M), K = this._getSamplingParameters(M.samplingMode, !1);
+ ae.texParameteri(ee, ae.TEXTURE_MAG_FILTER, K.mag), ae.texParameteri(ee, ae.TEXTURE_MIN_FILTER, K.min), ae.texParameteri(ee, ae.TEXTURE_WRAP_S, ae.CLAMP_TO_EDGE), ae.texParameteri(ee, ae.TEXTURE_WRAP_T, ae.CLAMP_TO_EDGE), ne === 0 ? (ae.texParameteri(ee, ae.TEXTURE_COMPARE_FUNC, m.a.LEQUAL), ae.texParameteri(ee, ae.TEXTURE_COMPARE_MODE, ae.NONE)) : (ae.texParameteri(ee, ae.TEXTURE_COMPARE_FUNC, ne), ae.texParameteri(ee, ae.TEXTURE_COMPARE_MODE, ae.COMPARE_REF_TO_TEXTURE));
+ }, N.prototype._uploadCompressedDataToTextureDirectly = function(M, U, X, j, ne, te, de) {
+ te === void 0 && (te = 0), de === void 0 && (de = 0);
+ var pe = this._gl, ae = pe.TEXTURE_2D;
+ M.isCube && (ae = pe.TEXTURE_CUBE_MAP_POSITIVE_X + te), this._gl.compressedTexImage2D(ae, de, U, X, j, 0, ne);
+ }, N.prototype._uploadDataToTextureDirectly = function(M, U, X, j, ne, te) {
+ X === void 0 && (X = 0), j === void 0 && (j = 0), te === void 0 && (te = !1);
+ var de = this._gl, pe = this._getWebGLTextureType(M.type), ae = this._getInternalFormat(M.format), ee = ne === void 0 ? this._getRGBABufferInternalSizedFormat(M.type, M.format) : this._getInternalFormat(ne);
+ this._unpackFlipY(M.invertY);
+ var K = de.TEXTURE_2D;
+ M.isCube && (K = de.TEXTURE_CUBE_MAP_POSITIVE_X + X);
+ var $ = Math.round(Math.log(M.width) * Math.LOG2E), L = Math.round(Math.log(M.height) * Math.LOG2E), G = te ? M.width : Math.pow(2, Math.max($ - j, 0)), Q = te ? M.height : Math.pow(2, Math.max(L - j, 0));
+ de.texImage2D(K, j, ee, G, Q, 0, ae, pe, U);
+ }, N.prototype.updateTextureData = function(M, U, X, j, ne, te, de, pe) {
+ de === void 0 && (de = 0), pe === void 0 && (pe = 0);
+ var ae = this._gl, ee = this._getWebGLTextureType(M.type), K = this._getInternalFormat(M.format);
+ this._unpackFlipY(M.invertY);
+ var $ = ae.TEXTURE_2D;
+ M.isCube && ($ = ae.TEXTURE_CUBE_MAP_POSITIVE_X + de), ae.texSubImage2D($, pe, X, j, ne, te, K, ee, U);
+ }, N.prototype._uploadArrayBufferViewToTexture = function(M, U, X, j) {
+ X === void 0 && (X = 0), j === void 0 && (j = 0);
+ var ne = this._gl, te = M.isCube ? ne.TEXTURE_CUBE_MAP : ne.TEXTURE_2D;
+ this._bindTextureDirectly(te, M, !0), this._uploadDataToTextureDirectly(M, U, X, j), this._bindTextureDirectly(te, null, !0);
+ }, N.prototype._prepareWebGLTextureContinuation = function(M, U, X, j, ne) {
+ var te = this._gl;
+ if (te) {
+ var de = this._getSamplingParameters(ne, !X);
+ te.texParameteri(te.TEXTURE_2D, te.TEXTURE_MAG_FILTER, de.mag), te.texParameteri(te.TEXTURE_2D, te.TEXTURE_MIN_FILTER, de.min), X || j || te.generateMipmap(te.TEXTURE_2D), this._bindTextureDirectly(te.TEXTURE_2D, null), U && U._removePendingData(M), M.onLoadedObservable.notifyObservers(M), M.onLoadedObservable.clear();
+ }
+ }, N.prototype._prepareWebGLTexture = function(M, U, X, j, ne, te, de, pe, ae) {
+ var ee = this;
+ ae === void 0 && (ae = m.a.TEXTURE_TRILINEAR_SAMPLINGMODE);
+ var K = this.getCaps().maxTextureSize, $ = Math.min(K, this.needPOTTextures ? N.GetExponentOfTwo(X, K) : X), L = Math.min(K, this.needPOTTextures ? N.GetExponentOfTwo(j, K) : j), G = this._gl;
+ G && (M._webGLTexture ? (this._bindTextureDirectly(G.TEXTURE_2D, M, !0), this._unpackFlipY(ne === void 0 || !!ne), M.baseWidth = X, M.baseHeight = j, M.width = $, M.height = L, M.isReady = !0, pe($, L, function() {
+ ee._prepareWebGLTextureContinuation(M, U, te, de, ae);
+ }) || this._prepareWebGLTextureContinuation(M, U, te, de, ae)) : U && U._removePendingData(M));
+ }, N.prototype._setupFramebufferDepthAttachments = function(M, U, X, j, ne) {
+ ne === void 0 && (ne = 1);
+ var te = this._gl;
+ if (M && U)
+ return this._getDepthStencilBuffer(X, j, ne, te.DEPTH_STENCIL, te.DEPTH24_STENCIL8, te.DEPTH_STENCIL_ATTACHMENT);
+ if (U) {
+ var de = te.DEPTH_COMPONENT16;
+ return this._webGLVersion > 1 && (de = te.DEPTH_COMPONENT32F), this._getDepthStencilBuffer(X, j, ne, de, de, te.DEPTH_ATTACHMENT);
+ }
+ return M ? this._getDepthStencilBuffer(X, j, ne, te.STENCIL_INDEX8, te.STENCIL_INDEX8, te.STENCIL_ATTACHMENT) : null;
+ }, N.prototype._releaseFramebufferObjects = function(M) {
+ var U = this._gl;
+ M._framebuffer && (U.deleteFramebuffer(M._framebuffer), M._framebuffer = null), M._depthStencilBuffer && (U.deleteRenderbuffer(M._depthStencilBuffer), M._depthStencilBuffer = null), M._MSAAFramebuffer && (U.deleteFramebuffer(M._MSAAFramebuffer), M._MSAAFramebuffer = null), M._MSAARenderBuffer && (U.deleteRenderbuffer(M._MSAARenderBuffer), M._MSAARenderBuffer = null);
+ }, N.prototype._releaseTexture = function(M) {
+ this._releaseFramebufferObjects(M), this._deleteTexture(M._webGLTexture), this.unbindAllTextures();
+ var U = this._internalTexturesCache.indexOf(M);
+ U !== -1 && this._internalTexturesCache.splice(U, 1), M._lodTextureHigh && M._lodTextureHigh.dispose(), M._lodTextureMid && M._lodTextureMid.dispose(), M._lodTextureLow && M._lodTextureLow.dispose(), M._irradianceTexture && M._irradianceTexture.dispose();
+ }, N.prototype._deleteTexture = function(M) {
+ this._gl.deleteTexture(M);
+ }, N.prototype._setProgram = function(M) {
+ this._currentProgram !== M && (this._gl.useProgram(M), this._currentProgram = M);
+ }, N.prototype.bindSamplers = function(M) {
+ var U = M.getPipelineContext();
+ this._setProgram(U.program);
+ for (var X = M.getSamplers(), j = 0; j < X.length; j++) {
+ var ne = M.getUniform(X[j]);
+ ne && (this._boundUniforms[j] = ne);
+ }
+ this._currentEffect = null;
+ }, N.prototype._activateCurrentTexture = function() {
+ this._currentTextureChannel !== this._activeChannel && (this._gl.activeTexture(this._gl.TEXTURE0 + this._activeChannel), this._currentTextureChannel = this._activeChannel);
+ }, N.prototype._bindTextureDirectly = function(M, U, X, j) {
+ X === void 0 && (X = !1), j === void 0 && (j = !1);
+ var ne = !1, te = U && U._associatedChannel > -1;
+ return X && te && (this._activeChannel = U._associatedChannel), this._boundTexturesCache[this._activeChannel] !== U || j ? (this._activateCurrentTexture(), U && U.isMultiview ? this._gl.bindTexture(M, U ? U._colorTextureArray : null) : this._gl.bindTexture(M, U ? U._webGLTexture : null), this._boundTexturesCache[this._activeChannel] = U, U && (U._associatedChannel = this._activeChannel)) : X && (ne = !0, this._activateCurrentTexture()), te && !X && this._bindSamplerUniformToChannel(U._associatedChannel, this._activeChannel), ne;
+ }, N.prototype._bindTexture = function(M, U) {
+ if (M !== void 0) {
+ U && (U._associatedChannel = M), this._activeChannel = M;
+ var X = U ? this._getTextureTarget(U) : this._gl.TEXTURE_2D;
+ this._bindTextureDirectly(X, U);
+ }
+ }, N.prototype.unbindAllTextures = function() {
+ for (var M = 0; M < this._maxSimultaneousTextures; M++)
+ this._activeChannel = M, this._bindTextureDirectly(this._gl.TEXTURE_2D, null), this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null), this.webGLVersion > 1 && (this._bindTextureDirectly(this._gl.TEXTURE_3D, null), this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY, null));
+ }, N.prototype.setTexture = function(M, U, X) {
+ M !== void 0 && (U && (this._boundUniforms[M] = U), this._setTexture(M, X));
+ }, N.prototype._bindSamplerUniformToChannel = function(M, U) {
+ var X = this._boundUniforms[M];
+ X && X._currentState !== U && (this._gl.uniform1i(X, U), X._currentState = U);
+ }, N.prototype._getTextureWrapMode = function(M) {
+ switch (M) {
+ case m.a.TEXTURE_WRAP_ADDRESSMODE:
+ return this._gl.REPEAT;
+ case m.a.TEXTURE_CLAMP_ADDRESSMODE:
+ return this._gl.CLAMP_TO_EDGE;
+ case m.a.TEXTURE_MIRROR_ADDRESSMODE:
+ return this._gl.MIRRORED_REPEAT;
+ }
+ return this._gl.REPEAT;
+ }, N.prototype._setTexture = function(M, U, X, j) {
+ if (X === void 0 && (X = !1), j === void 0 && (j = !1), !U)
+ return this._boundTexturesCache[M] != null && (this._activeChannel = M, this._bindTextureDirectly(this._gl.TEXTURE_2D, null), this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null), this.webGLVersion > 1 && (this._bindTextureDirectly(this._gl.TEXTURE_3D, null), this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY, null))), !1;
+ if (U.video)
+ this._activeChannel = M, U.update();
+ else if (U.delayLoadState === m.a.DELAYLOADSTATE_NOTLOADED)
+ return U.delayLoad(), !1;
+ var ne;
+ ne = j ? U.depthStencilTexture : U.isReady() ? U.getInternalTexture() : U.isCube ? this.emptyCubeTexture : U.is3D ? this.emptyTexture3D : U.is2DArray ? this.emptyTexture2DArray : this.emptyTexture, !X && ne && (ne._associatedChannel = M);
+ var te = !0;
+ this._boundTexturesCache[M] === ne && (X || this._bindSamplerUniformToChannel(ne._associatedChannel, M), te = !1), this._activeChannel = M;
+ var de = this._getTextureTarget(ne);
+ if (te && this._bindTextureDirectly(de, ne, X), ne && !ne.isMultiview) {
+ if (ne.isCube && ne._cachedCoordinatesMode !== U.coordinatesMode) {
+ ne._cachedCoordinatesMode = U.coordinatesMode;
+ var pe = U.coordinatesMode !== m.a.TEXTURE_CUBIC_MODE && U.coordinatesMode !== m.a.TEXTURE_SKYBOX_MODE ? m.a.TEXTURE_WRAP_ADDRESSMODE : m.a.TEXTURE_CLAMP_ADDRESSMODE;
+ U.wrapU = pe, U.wrapV = pe;
+ }
+ ne._cachedWrapU !== U.wrapU && (ne._cachedWrapU = U.wrapU, this._setTextureParameterInteger(de, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(U.wrapU), ne)), ne._cachedWrapV !== U.wrapV && (ne._cachedWrapV = U.wrapV, this._setTextureParameterInteger(de, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(U.wrapV), ne)), ne.is3D && ne._cachedWrapR !== U.wrapR && (ne._cachedWrapR = U.wrapR, this._setTextureParameterInteger(de, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(U.wrapR), ne)), this._setAnisotropicLevel(de, ne, U.anisotropicFilteringLevel);
+ }
+ return !0;
+ }, N.prototype.setTextureArray = function(M, U, X) {
+ if (M !== void 0 && U) {
+ this._textureUnits && this._textureUnits.length === X.length || (this._textureUnits = new Int32Array(X.length));
+ for (var j = 0; j < X.length; j++) {
+ var ne = X[j].getInternalTexture();
+ ne ? (this._textureUnits[j] = M + j, ne._associatedChannel = M + j) : this._textureUnits[j] = -1;
+ }
+ this._gl.uniform1iv(U, this._textureUnits);
+ for (var te = 0; te < X.length; te++)
+ this._setTexture(this._textureUnits[te], X[te], !0);
+ }
+ }, N.prototype._setAnisotropicLevel = function(M, U, X) {
+ var j = this._caps.textureAnisotropicFilterExtension;
+ U.samplingMode !== m.a.TEXTURE_LINEAR_LINEAR_MIPNEAREST && U.samplingMode !== m.a.TEXTURE_LINEAR_LINEAR_MIPLINEAR && U.samplingMode !== m.a.TEXTURE_LINEAR_LINEAR && (X = 1), j && U._cachedAnisotropicFilteringLevel !== X && (this._setTextureParameterFloat(M, j.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(X, this._caps.maxAnisotropy), U), U._cachedAnisotropicFilteringLevel = X);
+ }, N.prototype._setTextureParameterFloat = function(M, U, X, j) {
+ this._bindTextureDirectly(M, j, !0, !0), this._gl.texParameterf(M, U, X);
+ }, N.prototype._setTextureParameterInteger = function(M, U, X, j) {
+ j && this._bindTextureDirectly(M, j, !0, !0), this._gl.texParameteri(M, U, X);
+ }, N.prototype.unbindAllAttributes = function() {
+ if (this._mustWipeVertexAttributes) {
+ this._mustWipeVertexAttributes = !1;
+ for (var M = 0; M < this._caps.maxVertexAttribs; M++)
+ this.disableAttributeByIndex(M);
+ } else {
+ M = 0;
+ for (var U = this._vertexAttribArraysEnabled.length; M < U; M++)
+ M >= this._caps.maxVertexAttribs || !this._vertexAttribArraysEnabled[M] || this.disableAttributeByIndex(M);
+ }
+ }, N.prototype.releaseEffects = function() {
+ for (var M in this._compiledEffects) {
+ var U = this._compiledEffects[M].getPipelineContext();
+ this._deletePipelineContext(U);
+ }
+ this._compiledEffects = {};
+ }, N.prototype.dispose = function() {
+ this.stopRenderLoop(), this.onBeforeTextureInitObservable && this.onBeforeTextureInitObservable.clear(), this._emptyTexture && (this._releaseTexture(this._emptyTexture), this._emptyTexture = null), this._emptyCubeTexture && (this._releaseTexture(this._emptyCubeTexture), this._emptyCubeTexture = null), this._dummyFramebuffer && this._gl.deleteFramebuffer(this._dummyFramebuffer), this.releaseEffects(), this.unbindAllAttributes(), this._boundUniforms = [], S.a.IsWindowObjectExist() && this._renderingCanvas && (this._doNotHandleContextLost || (this._renderingCanvas.removeEventListener("webglcontextlost", this._onContextLost), this._renderingCanvas.removeEventListener("webglcontextrestored", this._onContextRestored))), this._workingCanvas = null, this._workingContext = null, this._currentBufferPointers = [], this._renderingCanvas = null, this._currentProgram = null, this._boundRenderFunction = null, _.a.ResetCache();
+ for (var M = 0, U = this._activeRequests; M < U.length; M++)
+ U[M].abort();
+ }, N.prototype.attachContextLostEvent = function(M) {
+ this._renderingCanvas && this._renderingCanvas.addEventListener("webglcontextlost", M, !1);
+ }, N.prototype.attachContextRestoredEvent = function(M) {
+ this._renderingCanvas && this._renderingCanvas.addEventListener("webglcontextrestored", M, !1);
+ }, N.prototype.getError = function() {
+ return this._gl.getError();
+ }, N.prototype._canRenderToFloatFramebuffer = function() {
+ return this._webGLVersion > 1 ? this._caps.colorBufferFloat : this._canRenderToFramebuffer(m.a.TEXTURETYPE_FLOAT);
+ }, N.prototype._canRenderToHalfFloatFramebuffer = function() {
+ return this._webGLVersion > 1 ? this._caps.colorBufferFloat : this._canRenderToFramebuffer(m.a.TEXTURETYPE_HALF_FLOAT);
+ }, N.prototype._canRenderToFramebuffer = function(M) {
+ for (var U = this._gl; U.getError() !== U.NO_ERROR; )
+ ;
+ var X = !0, j = U.createTexture();
+ U.bindTexture(U.TEXTURE_2D, j), U.texImage2D(U.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(M), 1, 1, 0, U.RGBA, this._getWebGLTextureType(M), null), U.texParameteri(U.TEXTURE_2D, U.TEXTURE_MIN_FILTER, U.NEAREST), U.texParameteri(U.TEXTURE_2D, U.TEXTURE_MAG_FILTER, U.NEAREST);
+ var ne = U.createFramebuffer();
+ U.bindFramebuffer(U.FRAMEBUFFER, ne), U.framebufferTexture2D(U.FRAMEBUFFER, U.COLOR_ATTACHMENT0, U.TEXTURE_2D, j, 0);
+ var te = U.checkFramebufferStatus(U.FRAMEBUFFER);
+ if ((X = (X = X && te === U.FRAMEBUFFER_COMPLETE) && U.getError() === U.NO_ERROR) && (U.clear(U.COLOR_BUFFER_BIT), X = X && U.getError() === U.NO_ERROR), X) {
+ U.bindFramebuffer(U.FRAMEBUFFER, null);
+ var de = U.RGBA, pe = U.UNSIGNED_BYTE, ae = new Uint8Array(4);
+ U.readPixels(0, 0, 1, 1, de, pe, ae), X = X && U.getError() === U.NO_ERROR;
+ }
+ for (U.deleteTexture(j), U.deleteFramebuffer(ne), U.bindFramebuffer(U.FRAMEBUFFER, null); !X && U.getError() !== U.NO_ERROR; )
+ ;
+ return X;
+ }, N.prototype._getWebGLTextureType = function(M) {
+ if (this._webGLVersion === 1) {
+ switch (M) {
+ case m.a.TEXTURETYPE_FLOAT:
+ return this._gl.FLOAT;
+ case m.a.TEXTURETYPE_HALF_FLOAT:
+ return this._gl.HALF_FLOAT_OES;
+ case m.a.TEXTURETYPE_UNSIGNED_BYTE:
+ return this._gl.UNSIGNED_BYTE;
+ case m.a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
+ return this._gl.UNSIGNED_SHORT_4_4_4_4;
+ case m.a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
+ return this._gl.UNSIGNED_SHORT_5_5_5_1;
+ case m.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
+ return this._gl.UNSIGNED_SHORT_5_6_5;
+ }
+ return this._gl.UNSIGNED_BYTE;
+ }
+ switch (M) {
+ case m.a.TEXTURETYPE_BYTE:
+ return this._gl.BYTE;
+ case m.a.TEXTURETYPE_UNSIGNED_BYTE:
+ return this._gl.UNSIGNED_BYTE;
+ case m.a.TEXTURETYPE_SHORT:
+ return this._gl.SHORT;
+ case m.a.TEXTURETYPE_UNSIGNED_SHORT:
+ return this._gl.UNSIGNED_SHORT;
+ case m.a.TEXTURETYPE_INT:
+ return this._gl.INT;
+ case m.a.TEXTURETYPE_UNSIGNED_INTEGER:
+ return this._gl.UNSIGNED_INT;
+ case m.a.TEXTURETYPE_FLOAT:
+ return this._gl.FLOAT;
+ case m.a.TEXTURETYPE_HALF_FLOAT:
+ return this._gl.HALF_FLOAT;
+ case m.a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
+ return this._gl.UNSIGNED_SHORT_4_4_4_4;
+ case m.a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
+ return this._gl.UNSIGNED_SHORT_5_5_5_1;
+ case m.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
+ return this._gl.UNSIGNED_SHORT_5_6_5;
+ case m.a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
+ return this._gl.UNSIGNED_INT_2_10_10_10_REV;
+ case m.a.TEXTURETYPE_UNSIGNED_INT_24_8:
+ return this._gl.UNSIGNED_INT_24_8;
+ case m.a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
+ return this._gl.UNSIGNED_INT_10F_11F_11F_REV;
+ case m.a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
+ return this._gl.UNSIGNED_INT_5_9_9_9_REV;
+ case m.a.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:
+ return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV;
+ }
+ return this._gl.UNSIGNED_BYTE;
+ }, N.prototype._getInternalFormat = function(M) {
+ var U = this._gl.RGBA;
+ switch (M) {
+ case m.a.TEXTUREFORMAT_ALPHA:
+ U = this._gl.ALPHA;
+ break;
+ case m.a.TEXTUREFORMAT_LUMINANCE:
+ U = this._gl.LUMINANCE;
+ break;
+ case m.a.TEXTUREFORMAT_LUMINANCE_ALPHA:
+ U = this._gl.LUMINANCE_ALPHA;
+ break;
+ case m.a.TEXTUREFORMAT_RED:
+ U = this._gl.RED;
+ break;
+ case m.a.TEXTUREFORMAT_RG:
+ U = this._gl.RG;
+ break;
+ case m.a.TEXTUREFORMAT_RGB:
+ U = this._gl.RGB;
+ break;
+ case m.a.TEXTUREFORMAT_RGBA:
+ U = this._gl.RGBA;
+ }
+ if (this._webGLVersion > 1)
+ switch (M) {
+ case m.a.TEXTUREFORMAT_RED_INTEGER:
+ U = this._gl.RED_INTEGER;
+ break;
+ case m.a.TEXTUREFORMAT_RG_INTEGER:
+ U = this._gl.RG_INTEGER;
+ break;
+ case m.a.TEXTUREFORMAT_RGB_INTEGER:
+ U = this._gl.RGB_INTEGER;
+ break;
+ case m.a.TEXTUREFORMAT_RGBA_INTEGER:
+ U = this._gl.RGBA_INTEGER;
+ }
+ return U;
+ }, N.prototype._getRGBABufferInternalSizedFormat = function(M, U) {
+ if (this._webGLVersion === 1) {
+ if (U !== void 0)
+ switch (U) {
+ case m.a.TEXTUREFORMAT_ALPHA:
+ return this._gl.ALPHA;
+ case m.a.TEXTUREFORMAT_LUMINANCE:
+ return this._gl.LUMINANCE;
+ case m.a.TEXTUREFORMAT_LUMINANCE_ALPHA:
+ return this._gl.LUMINANCE_ALPHA;
+ case m.a.TEXTUREFORMAT_RGB:
+ return this._gl.RGB;
+ }
+ return this._gl.RGBA;
+ }
+ switch (M) {
+ case m.a.TEXTURETYPE_BYTE:
+ switch (U) {
+ case m.a.TEXTUREFORMAT_RED:
+ return this._gl.R8_SNORM;
+ case m.a.TEXTUREFORMAT_RG:
+ return this._gl.RG8_SNORM;
+ case m.a.TEXTUREFORMAT_RGB:
+ return this._gl.RGB8_SNORM;
+ case m.a.TEXTUREFORMAT_RED_INTEGER:
+ return this._gl.R8I;
+ case m.a.TEXTUREFORMAT_RG_INTEGER:
+ return this._gl.RG8I;
+ case m.a.TEXTUREFORMAT_RGB_INTEGER:
+ return this._gl.RGB8I;
+ case m.a.TEXTUREFORMAT_RGBA_INTEGER:
+ return this._gl.RGBA8I;
+ default:
+ return this._gl.RGBA8_SNORM;
+ }
+ case m.a.TEXTURETYPE_UNSIGNED_BYTE:
+ switch (U) {
+ case m.a.TEXTUREFORMAT_RED:
+ return this._gl.R8;
+ case m.a.TEXTUREFORMAT_RG:
+ return this._gl.RG8;
+ case m.a.TEXTUREFORMAT_RGB:
+ return this._gl.RGB8;
+ case m.a.TEXTUREFORMAT_RGBA:
+ return this._gl.RGBA8;
+ case m.a.TEXTUREFORMAT_RED_INTEGER:
+ return this._gl.R8UI;
+ case m.a.TEXTUREFORMAT_RG_INTEGER:
+ return this._gl.RG8UI;
+ case m.a.TEXTUREFORMAT_RGB_INTEGER:
+ return this._gl.RGB8UI;
+ case m.a.TEXTUREFORMAT_RGBA_INTEGER:
+ return this._gl.RGBA8UI;
+ case m.a.TEXTUREFORMAT_ALPHA:
+ return this._gl.ALPHA;
+ case m.a.TEXTUREFORMAT_LUMINANCE:
+ return this._gl.LUMINANCE;
+ case m.a.TEXTUREFORMAT_LUMINANCE_ALPHA:
+ return this._gl.LUMINANCE_ALPHA;
+ default:
+ return this._gl.RGBA8;
+ }
+ case m.a.TEXTURETYPE_SHORT:
+ switch (U) {
+ case m.a.TEXTUREFORMAT_RED_INTEGER:
+ return this._gl.R16I;
+ case m.a.TEXTUREFORMAT_RG_INTEGER:
+ return this._gl.RG16I;
+ case m.a.TEXTUREFORMAT_RGB_INTEGER:
+ return this._gl.RGB16I;
+ case m.a.TEXTUREFORMAT_RGBA_INTEGER:
+ default:
+ return this._gl.RGBA16I;
+ }
+ case m.a.TEXTURETYPE_UNSIGNED_SHORT:
+ switch (U) {
+ case m.a.TEXTUREFORMAT_RED_INTEGER:
+ return this._gl.R16UI;
+ case m.a.TEXTUREFORMAT_RG_INTEGER:
+ return this._gl.RG16UI;
+ case m.a.TEXTUREFORMAT_RGB_INTEGER:
+ return this._gl.RGB16UI;
+ case m.a.TEXTUREFORMAT_RGBA_INTEGER:
+ default:
+ return this._gl.RGBA16UI;
+ }
+ case m.a.TEXTURETYPE_INT:
+ switch (U) {
+ case m.a.TEXTUREFORMAT_RED_INTEGER:
+ return this._gl.R32I;
+ case m.a.TEXTUREFORMAT_RG_INTEGER:
+ return this._gl.RG32I;
+ case m.a.TEXTUREFORMAT_RGB_INTEGER:
+ return this._gl.RGB32I;
+ case m.a.TEXTUREFORMAT_RGBA_INTEGER:
+ default:
+ return this._gl.RGBA32I;
+ }
+ case m.a.TEXTURETYPE_UNSIGNED_INTEGER:
+ switch (U) {
+ case m.a.TEXTUREFORMAT_RED_INTEGER:
+ return this._gl.R32UI;
+ case m.a.TEXTUREFORMAT_RG_INTEGER:
+ return this._gl.RG32UI;
+ case m.a.TEXTUREFORMAT_RGB_INTEGER:
+ return this._gl.RGB32UI;
+ case m.a.TEXTUREFORMAT_RGBA_INTEGER:
+ default:
+ return this._gl.RGBA32UI;
+ }
+ case m.a.TEXTURETYPE_FLOAT:
+ switch (U) {
+ case m.a.TEXTUREFORMAT_RED:
+ return this._gl.R32F;
+ case m.a.TEXTUREFORMAT_RG:
+ return this._gl.RG32F;
+ case m.a.TEXTUREFORMAT_RGB:
+ return this._gl.RGB32F;
+ case m.a.TEXTUREFORMAT_RGBA:
+ default:
+ return this._gl.RGBA32F;
+ }
+ case m.a.TEXTURETYPE_HALF_FLOAT:
+ switch (U) {
+ case m.a.TEXTUREFORMAT_RED:
+ return this._gl.R16F;
+ case m.a.TEXTUREFORMAT_RG:
+ return this._gl.RG16F;
+ case m.a.TEXTUREFORMAT_RGB:
+ return this._gl.RGB16F;
+ case m.a.TEXTUREFORMAT_RGBA:
+ default:
+ return this._gl.RGBA16F;
+ }
+ case m.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
+ return this._gl.RGB565;
+ case m.a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
+ return this._gl.R11F_G11F_B10F;
+ case m.a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
+ return this._gl.RGB9_E5;
+ case m.a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
+ return this._gl.RGBA4;
+ case m.a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
+ return this._gl.RGB5_A1;
+ case m.a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
+ switch (U) {
+ case m.a.TEXTUREFORMAT_RGBA:
+ return this._gl.RGB10_A2;
+ case m.a.TEXTUREFORMAT_RGBA_INTEGER:
+ return this._gl.RGB10_A2UI;
+ default:
+ return this._gl.RGB10_A2;
+ }
+ }
+ return this._gl.RGBA8;
+ }, N.prototype._getRGBAMultiSampleBufferFormat = function(M) {
+ return M === m.a.TEXTURETYPE_FLOAT ? this._gl.RGBA32F : M === m.a.TEXTURETYPE_HALF_FLOAT ? this._gl.RGBA16F : this._gl.RGBA8;
+ }, N.prototype._loadFile = function(M, U, X, j, ne, te) {
+ var de = this, pe = N._FileToolsLoadFile(M, U, X, j, ne, te);
+ return this._activeRequests.push(pe), pe.onCompleteObservable.add(function(ae) {
+ de._activeRequests.splice(de._activeRequests.indexOf(ae), 1);
+ }), pe;
+ }, N._FileToolsLoadFile = function(M, U, X, j, ne, te) {
+ throw C.a.WarnImport("FileTools");
+ }, N.prototype.readPixels = function(M, U, X, j, ne) {
+ ne === void 0 && (ne = !0);
+ var te = ne ? 4 : 3, de = ne ? this._gl.RGBA : this._gl.RGB, pe = new Uint8Array(j * X * te);
+ return this._gl.readPixels(M, U, X, j, de, this._gl.UNSIGNED_BYTE, pe), pe;
+ }, Object.defineProperty(N, "IsSupported", { get: function() {
+ return this.isSupported();
+ }, enumerable: !1, configurable: !0 }), N.isSupported = function() {
+ if (this._HasMajorPerformanceCaveat !== null)
+ return !this._HasMajorPerformanceCaveat;
+ if (this._IsSupported === null)
+ try {
+ var M = v.a.CreateCanvas(1, 1), U = M.getContext("webgl") || M.getContext("experimental-webgl");
+ this._IsSupported = U != null && !!window.WebGLRenderingContext;
+ } catch {
+ this._IsSupported = !1;
+ }
+ return this._IsSupported;
+ }, Object.defineProperty(N, "HasMajorPerformanceCaveat", { get: function() {
+ if (this._HasMajorPerformanceCaveat === null)
+ try {
+ var M = v.a.CreateCanvas(1, 1), U = M.getContext("webgl", { failIfMajorPerformanceCaveat: !0 }) || M.getContext("experimental-webgl", { failIfMajorPerformanceCaveat: !0 });
+ this._HasMajorPerformanceCaveat = !U;
+ } catch {
+ this._HasMajorPerformanceCaveat = !1;
+ }
+ return this._HasMajorPerformanceCaveat;
+ }, enumerable: !1, configurable: !0 }), N.CeilingPOT = function(M) {
+ return M--, M |= M >> 1, M |= M >> 2, M |= M >> 4, M |= M >> 8, M |= M >> 16, ++M;
+ }, N.FloorPOT = function(M) {
+ return M |= M >> 1, M |= M >> 2, M |= M >> 4, M |= M >> 8, (M |= M >> 16) - (M >> 1);
+ }, N.NearestPOT = function(M) {
+ var U = N.CeilingPOT(M), X = N.FloorPOT(M);
+ return U - M > M - X ? X : U;
+ }, N.GetExponentOfTwo = function(M, U, X) {
+ var j;
+ switch (X === void 0 && (X = m.a.SCALEMODE_NEAREST), X) {
+ case m.a.SCALEMODE_FLOOR:
+ j = N.FloorPOT(M);
+ break;
+ case m.a.SCALEMODE_NEAREST:
+ j = N.NearestPOT(M);
+ break;
+ case m.a.SCALEMODE_CEILING:
+ default:
+ j = N.CeilingPOT(M);
+ }
+ return Math.min(j, U);
+ }, N.QueueNewFrame = function(M, U) {
+ return S.a.IsWindowObjectExist() ? (U || (U = window), U.requestPostAnimationFrame ? U.requestPostAnimationFrame(M) : U.requestAnimationFrame ? U.requestAnimationFrame(M) : U.msRequestAnimationFrame ? U.msRequestAnimationFrame(M) : U.webkitRequestAnimationFrame ? U.webkitRequestAnimationFrame(M) : U.mozRequestAnimationFrame ? U.mozRequestAnimationFrame(M) : U.oRequestAnimationFrame ? U.oRequestAnimationFrame(M) : window.setTimeout(M, 16)) : typeof requestAnimationFrame < "u" ? requestAnimationFrame(M) : setTimeout(M, 16);
+ }, N.prototype.getHostDocument = function() {
+ return this._renderingCanvas && this._renderingCanvas.ownerDocument ? this._renderingCanvas.ownerDocument : document;
+ }, N.ExceptionList = [{ key: "Chrome/63.0", capture: "63\\.0\\.3239\\.(\\d+)", captureConstraint: 108, targets: ["uniformBuffer"] }, { key: "Firefox/58", capture: null, captureConstraint: null, targets: ["uniformBuffer"] }, { key: "Firefox/59", capture: null, captureConstraint: null, targets: ["uniformBuffer"] }, { key: "Chrome/72.+?Mobile", capture: null, captureConstraint: null, targets: ["vao"] }, { key: "Chrome/73.+?Mobile", capture: null, captureConstraint: null, targets: ["vao"] }, { key: "Chrome/74.+?Mobile", capture: null, captureConstraint: null, targets: ["vao"] }, { key: "Mac OS.+Chrome/71", capture: null, captureConstraint: null, targets: ["vao"] }, { key: "Mac OS.+Chrome/72", capture: null, captureConstraint: null, targets: ["vao"] }], N._TextureLoaders = [], N.CollisionsEpsilon = 1e-3, N._IsSupported = null, N._HasMajorPerformanceCaveat = null, N;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "b", function() {
+ return V;
+ }), f.d(A, "a", function() {
+ return O;
+ });
+ var V, _ = f(6), C = f(102), u = f(2), I = f(21);
+ (function(x) {
+ x[x.Unknown = 0] = "Unknown", x[x.Url = 1] = "Url", x[x.Temp = 2] = "Temp", x[x.Raw = 3] = "Raw", x[x.Dynamic = 4] = "Dynamic", x[x.RenderTarget = 5] = "RenderTarget", x[x.MultiRenderTarget = 6] = "MultiRenderTarget", x[x.Cube = 7] = "Cube", x[x.CubeRaw = 8] = "CubeRaw", x[x.CubePrefiltered = 9] = "CubePrefiltered", x[x.Raw3D = 10] = "Raw3D", x[x.Raw2DArray = 11] = "Raw2DArray", x[x.Depth = 12] = "Depth", x[x.CubeRawRGBD = 13] = "CubeRawRGBD";
+ })(V || (V = {}));
+ var O = function() {
+ function x(m, c, T) {
+ T === void 0 && (T = !1), this.isReady = !1, this.isCube = !1, this.is3D = !1, this.is2DArray = !1, this.isMultiview = !1, this.url = "", this.samplingMode = -1, this.generateMipMaps = !1, this.samples = 0, this.type = -1, this.format = -1, this.onLoadedObservable = new _.c(), this.width = 0, this.height = 0, this.depth = 0, this.baseWidth = 0, this.baseHeight = 0, this.baseDepth = 0, this.invertY = !1, this._invertVScale = !1, this._associatedChannel = -1, this._source = V.Unknown, this._buffer = null, this._bufferView = null, this._bufferViewArray = null, this._bufferViewArrayArray = null, this._size = 0, this._extension = "", this._files = null, this._workingCanvas = null, this._workingContext = null, this._framebuffer = null, this._depthStencilBuffer = null, this._MSAAFramebuffer = null, this._MSAARenderBuffer = null, this._attachments = null, this._textureArray = null, this._cachedCoordinatesMode = null, this._cachedWrapU = null, this._cachedWrapV = null, this._cachedWrapR = null, this._cachedAnisotropicFilteringLevel = null, this._isDisabled = !1, this._compression = null, this._generateStencilBuffer = !1, this._generateDepthBuffer = !1, this._comparisonFunction = 0, this._sphericalPolynomial = null, this._lodGenerationScale = 0, this._lodGenerationOffset = 0, this._colorTextureArray = null, this._depthStencilTextureArray = null, this._lodTextureHigh = null, this._lodTextureMid = null, this._lodTextureLow = null, this._isRGBD = !1, this._linearSpecularLOD = !1, this._irradianceTexture = null, this._webGLTexture = null, this._references = 1, this._gammaSpace = null, this._engine = m, this._source = c, T || (this._webGLTexture = m._createTexture());
+ }
+ return x.prototype.getEngine = function() {
+ return this._engine;
+ }, Object.defineProperty(x.prototype, "source", { get: function() {
+ return this._source;
+ }, enumerable: !1, configurable: !0 }), x.prototype.incrementReferences = function() {
+ this._references++;
+ }, x.prototype.updateSize = function(m, c, T) {
+ T === void 0 && (T = 1), this.width = m, this.height = c, this.depth = T, this.baseWidth = m, this.baseHeight = c, this.baseDepth = T, this._size = m * c * T;
+ }, x.prototype._rebuild = function() {
+ var m, c, T = this;
+ switch (this.isReady = !1, this._cachedCoordinatesMode = null, this._cachedWrapU = null, this._cachedWrapV = null, this._cachedAnisotropicFilteringLevel = null, this.source) {
+ case V.Temp:
+ return;
+ case V.Url:
+ return void (c = this._engine.createTexture((m = this._originalUrl) !== null && m !== void 0 ? m : this.url, !this.generateMipMaps, this.invertY, null, this.samplingMode, function() {
+ c._swapAndDie(T), T.isReady = !0;
+ }, null, this._buffer, void 0, this.format));
+ case V.Raw:
+ return (c = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression))._swapAndDie(this), void (this.isReady = !0);
+ case V.Raw3D:
+ return (c = this._engine.createRawTexture3D(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression))._swapAndDie(this), void (this.isReady = !0);
+ case V.Raw2DArray:
+ return (c = this._engine.createRawTexture2DArray(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression))._swapAndDie(this), void (this.isReady = !0);
+ case V.Dynamic:
+ return (c = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode))._swapAndDie(this), void this._engine.updateDynamicTexture(this, this._engine.getRenderingCanvas(), this.invertY, void 0, void 0, !0);
+ case V.RenderTarget:
+ var S = new C.a();
+ if (S.generateDepthBuffer = this._generateDepthBuffer, S.generateMipMaps = this.generateMipMaps, S.generateStencilBuffer = this._generateStencilBuffer, S.samplingMode = this.samplingMode, S.type = this.type, this.isCube)
+ c = this._engine.createRenderTargetCubeTexture(this.width, S);
+ else {
+ var E = { width: this.width, height: this.height, layers: this.is2DArray ? this.depth : void 0 };
+ c = this._engine.createRenderTargetTexture(E, S);
+ }
+ return c._swapAndDie(this), void (this.isReady = !0);
+ case V.Depth:
+ var g = { bilinearFiltering: this.samplingMode !== u.a.TEXTURE_BILINEAR_SAMPLINGMODE, comparisonFunction: this._comparisonFunction, generateStencil: this._generateStencilBuffer, isCube: this.isCube }, l = { width: this.width, height: this.height, layers: this.is2DArray ? this.depth : void 0 };
+ return (c = this._engine.createDepthStencilTexture(l, g))._swapAndDie(this), void (this.isReady = !0);
+ case V.Cube:
+ return void (c = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, function() {
+ c._swapAndDie(T), T.isReady = !0;
+ }, null, this.format, this._extension));
+ case V.CubeRaw:
+ return (c = this._engine.createRawCubeTexture(this._bufferViewArray, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression))._swapAndDie(this), void (this.isReady = !0);
+ case V.CubeRawRGBD:
+ return c = this._engine.createRawCubeTexture(null, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression), void x._UpdateRGBDAsync(c, this._bufferViewArrayArray, this._sphericalPolynomial, this._lodGenerationScale, this._lodGenerationOffset).then(function() {
+ c._swapAndDie(T), T.isReady = !0;
+ });
+ case V.CubePrefiltered:
+ return void ((c = this._engine.createPrefilteredCubeTexture(this.url, null, this._lodGenerationScale, this._lodGenerationOffset, function(h) {
+ h && h._swapAndDie(T), T.isReady = !0;
+ }, null, this.format, this._extension))._sphericalPolynomial = this._sphericalPolynomial);
+ }
+ }, x.prototype._swapAndDie = function(m) {
+ m._webGLTexture = this._webGLTexture, m._isRGBD = this._isRGBD, this._framebuffer && (m._framebuffer = this._framebuffer), this._depthStencilBuffer && (m._depthStencilBuffer = this._depthStencilBuffer), m._depthStencilTexture = this._depthStencilTexture, this._lodTextureHigh && (m._lodTextureHigh && m._lodTextureHigh.dispose(), m._lodTextureHigh = this._lodTextureHigh), this._lodTextureMid && (m._lodTextureMid && m._lodTextureMid.dispose(), m._lodTextureMid = this._lodTextureMid), this._lodTextureLow && (m._lodTextureLow && m._lodTextureLow.dispose(), m._lodTextureLow = this._lodTextureLow), this._irradianceTexture && (m._irradianceTexture && m._irradianceTexture.dispose(), m._irradianceTexture = this._irradianceTexture);
+ var c, T = this._engine.getLoadedTexturesCache();
+ (c = T.indexOf(this)) !== -1 && T.splice(c, 1), (c = T.indexOf(m)) === -1 && T.push(m);
+ }, x.prototype.dispose = function() {
+ this._webGLTexture && (this._references--, this._references === 0 && (this._engine._releaseTexture(this), this._webGLTexture = null));
+ }, x._UpdateRGBDAsync = function(m, c, T, S, E) {
+ throw I.a.WarnImport("environmentTextureTools");
+ }, x;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "b", function() {
+ return V;
+ }), f.d(A, "c", function() {
+ return _;
+ }), f.d(A, "a", function() {
+ return C;
+ });
+ var V = 1 / 2.2, _ = 2.2, C = 1e-3;
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return x;
+ });
+ var V = f(1), _ = f(0), C = f(3), u = f(6), I = f(22), O = f(21), x = function() {
+ function m(c, T) {
+ T === void 0 && (T = null), this.state = "", this.metadata = null, this.reservedDataStore = null, this._doNotSerialize = !1, this._isDisposed = !1, this.animations = new Array(), this._ranges = {}, this.onReady = null, this._isEnabled = !0, this._isParentEnabled = !0, this._isReady = !0, this._currentRenderId = -1, this._parentUpdateId = -1, this._childUpdateId = -1, this._waitingParentId = null, this._cache = {}, this._parentNode = null, this._children = null, this._worldMatrix = _.a.Identity(), this._worldMatrixDeterminant = 0, this._worldMatrixDeterminantIsDirty = !0, this._sceneRootNodesIndex = -1, this._animationPropertiesOverride = null, this._isNode = !0, this.onDisposeObservable = new u.c(), this._onDisposeObserver = null, this._behaviors = new Array(), this.name = c, this.id = c, this._scene = T || I.a.LastCreatedScene, this.uniqueId = this._scene.getUniqueId(), this._initCache();
+ }
+ return m.AddNodeConstructor = function(c, T) {
+ this._NodeConstructors[c] = T;
+ }, m.Construct = function(c, T, S, E) {
+ var g = this._NodeConstructors[c];
+ return g ? g(T, S, E) : null;
+ }, Object.defineProperty(m.prototype, "doNotSerialize", { get: function() {
+ return !!this._doNotSerialize || !!this._parentNode && this._parentNode.doNotSerialize;
+ }, set: function(c) {
+ this._doNotSerialize = c;
+ }, enumerable: !1, configurable: !0 }), m.prototype.isDisposed = function() {
+ return this._isDisposed;
+ }, Object.defineProperty(m.prototype, "parent", { get: function() {
+ return this._parentNode;
+ }, set: function(c) {
+ if (this._parentNode !== c) {
+ var T = this._parentNode;
+ if (this._parentNode && this._parentNode._children !== void 0 && this._parentNode._children !== null) {
+ var S = this._parentNode._children.indexOf(this);
+ S !== -1 && this._parentNode._children.splice(S, 1), c || this._isDisposed || this._addToSceneRootNodes();
+ }
+ this._parentNode = c, this._parentNode && (this._parentNode._children !== void 0 && this._parentNode._children !== null || (this._parentNode._children = new Array()), this._parentNode._children.push(this), T || this._removeFromSceneRootNodes()), this._syncParentEnabledState();
+ }
+ }, enumerable: !1, configurable: !0 }), m.prototype._addToSceneRootNodes = function() {
+ this._sceneRootNodesIndex === -1 && (this._sceneRootNodesIndex = this._scene.rootNodes.length, this._scene.rootNodes.push(this));
+ }, m.prototype._removeFromSceneRootNodes = function() {
+ if (this._sceneRootNodesIndex !== -1) {
+ var c = this._scene.rootNodes, T = c.length - 1;
+ c[this._sceneRootNodesIndex] = c[T], c[this._sceneRootNodesIndex]._sceneRootNodesIndex = this._sceneRootNodesIndex, this._scene.rootNodes.pop(), this._sceneRootNodesIndex = -1;
+ }
+ }, Object.defineProperty(m.prototype, "animationPropertiesOverride", { get: function() {
+ return this._animationPropertiesOverride ? this._animationPropertiesOverride : this._scene.animationPropertiesOverride;
+ }, set: function(c) {
+ this._animationPropertiesOverride = c;
+ }, enumerable: !1, configurable: !0 }), m.prototype.getClassName = function() {
+ return "Node";
+ }, Object.defineProperty(m.prototype, "onDispose", { set: function(c) {
+ this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver), this._onDisposeObserver = this.onDisposeObservable.add(c);
+ }, enumerable: !1, configurable: !0 }), m.prototype.getScene = function() {
+ return this._scene;
+ }, m.prototype.getEngine = function() {
+ return this._scene.getEngine();
+ }, m.prototype.addBehavior = function(c, T) {
+ var S = this;
+ return T === void 0 && (T = !1), this._behaviors.indexOf(c) !== -1 || (c.init(), this._scene.isLoading && !T ? this._scene.onDataLoadedObservable.addOnce(function() {
+ c.attach(S);
+ }) : c.attach(this), this._behaviors.push(c)), this;
+ }, m.prototype.removeBehavior = function(c) {
+ var T = this._behaviors.indexOf(c);
+ return T === -1 || (this._behaviors[T].detach(), this._behaviors.splice(T, 1)), this;
+ }, Object.defineProperty(m.prototype, "behaviors", { get: function() {
+ return this._behaviors;
+ }, enumerable: !1, configurable: !0 }), m.prototype.getBehaviorByName = function(c) {
+ for (var T = 0, S = this._behaviors; T < S.length; T++) {
+ var E = S[T];
+ if (E.name === c)
+ return E;
+ }
+ return null;
+ }, m.prototype.getWorldMatrix = function() {
+ return this._currentRenderId !== this._scene.getRenderId() && this.computeWorldMatrix(), this._worldMatrix;
+ }, m.prototype._getWorldMatrixDeterminant = function() {
+ return this._worldMatrixDeterminantIsDirty && (this._worldMatrixDeterminantIsDirty = !1, this._worldMatrixDeterminant = this._worldMatrix.determinant()), this._worldMatrixDeterminant;
+ }, Object.defineProperty(m.prototype, "worldMatrixFromCache", { get: function() {
+ return this._worldMatrix;
+ }, enumerable: !1, configurable: !0 }), m.prototype._initCache = function() {
+ this._cache = {}, this._cache.parent = void 0;
+ }, m.prototype.updateCache = function(c) {
+ !c && this.isSynchronized() || (this._cache.parent = this.parent, this._updateCache());
+ }, m.prototype._getActionManagerForTrigger = function(c, T) {
+ return this.parent ? this.parent._getActionManagerForTrigger(c, !1) : null;
+ }, m.prototype._updateCache = function(c) {
+ }, m.prototype._isSynchronized = function() {
+ return !0;
+ }, m.prototype._markSyncedWithParent = function() {
+ this._parentNode && (this._parentUpdateId = this._parentNode._childUpdateId);
+ }, m.prototype.isSynchronizedWithParent = function() {
+ return !this._parentNode || this._parentUpdateId === this._parentNode._childUpdateId && this._parentNode.isSynchronized();
+ }, m.prototype.isSynchronized = function() {
+ return this._cache.parent != this._parentNode ? (this._cache.parent = this._parentNode, !1) : !(this._parentNode && !this.isSynchronizedWithParent()) && this._isSynchronized();
+ }, m.prototype.isReady = function(c) {
+ return this._isReady;
+ }, m.prototype.isEnabled = function(c) {
+ return c === void 0 && (c = !0), c === !1 ? this._isEnabled : !!this._isEnabled && this._isParentEnabled;
+ }, m.prototype._syncParentEnabledState = function() {
+ this._isParentEnabled = !this._parentNode || this._parentNode.isEnabled(), this._children && this._children.forEach(function(c) {
+ c._syncParentEnabledState();
+ });
+ }, m.prototype.setEnabled = function(c) {
+ this._isEnabled = c, this._syncParentEnabledState();
+ }, m.prototype.isDescendantOf = function(c) {
+ return !!this.parent && (this.parent === c || this.parent.isDescendantOf(c));
+ }, m.prototype._getDescendants = function(c, T, S) {
+ if (T === void 0 && (T = !1), this._children)
+ for (var E = 0; E < this._children.length; E++) {
+ var g = this._children[E];
+ S && !S(g) || c.push(g), T || g._getDescendants(c, !1, S);
+ }
+ }, m.prototype.getDescendants = function(c, T) {
+ var S = new Array();
+ return this._getDescendants(S, c, T), S;
+ }, m.prototype.getChildMeshes = function(c, T) {
+ var S = [];
+ return this._getDescendants(S, c, function(E) {
+ return (!T || T(E)) && E.cullingStrategy !== void 0;
+ }), S;
+ }, m.prototype.getChildren = function(c, T) {
+ return T === void 0 && (T = !0), this.getDescendants(T, c);
+ }, m.prototype._setReady = function(c) {
+ c !== this._isReady && (c ? (this.onReady && this.onReady(this), this._isReady = !0) : this._isReady = !1);
+ }, m.prototype.getAnimationByName = function(c) {
+ for (var T = 0; T < this.animations.length; T++) {
+ var S = this.animations[T];
+ if (S.name === c)
+ return S;
+ }
+ return null;
+ }, m.prototype.createAnimationRange = function(c, T, S) {
+ if (!this._ranges[c]) {
+ this._ranges[c] = m._AnimationRangeFactory(c, T, S);
+ for (var E = 0, g = this.animations.length; E < g; E++)
+ this.animations[E] && this.animations[E].createRange(c, T, S);
+ }
+ }, m.prototype.deleteAnimationRange = function(c, T) {
+ T === void 0 && (T = !0);
+ for (var S = 0, E = this.animations.length; S < E; S++)
+ this.animations[S] && this.animations[S].deleteRange(c, T);
+ this._ranges[c] = null;
+ }, m.prototype.getAnimationRange = function(c) {
+ return this._ranges[c] || null;
+ }, m.prototype.getAnimationRanges = function() {
+ var c, T = [];
+ for (c in this._ranges)
+ T.push(this._ranges[c]);
+ return T;
+ }, m.prototype.beginAnimation = function(c, T, S, E) {
+ var g = this.getAnimationRange(c);
+ return g ? this._scene.beginAnimation(this, g.from, g.to, T, S, E) : null;
+ }, m.prototype.serializeAnimationRanges = function() {
+ var c = [];
+ for (var T in this._ranges) {
+ var S = this._ranges[T];
+ if (S) {
+ var E = {};
+ E.name = T, E.from = S.from, E.to = S.to, c.push(E);
+ }
+ }
+ return c;
+ }, m.prototype.computeWorldMatrix = function(c) {
+ return this._worldMatrix || (this._worldMatrix = _.a.Identity()), this._worldMatrix;
+ }, m.prototype.dispose = function(c, T) {
+ if (T === void 0 && (T = !1), this._isDisposed = !0, !c)
+ for (var S = 0, E = this.getDescendants(!0); S < E.length; S++)
+ E[S].dispose(c, T);
+ this.parent ? this.parent = null : this._removeFromSceneRootNodes(), this.onDisposeObservable.notifyObservers(this), this.onDisposeObservable.clear();
+ for (var g = 0, l = this._behaviors; g < l.length; g++)
+ l[g].detach();
+ this._behaviors = [];
+ }, m.ParseAnimationRanges = function(c, T, S) {
+ if (T.ranges)
+ for (var E = 0; E < T.ranges.length; E++) {
+ var g = T.ranges[E];
+ c.createAnimationRange(g.name, g.from, g.to);
+ }
+ }, m.prototype.getHierarchyBoundingVectors = function(c, T) {
+ var S, E;
+ if (c === void 0 && (c = !0), T === void 0 && (T = null), this.getScene().incrementRenderId(), this.computeWorldMatrix(!0), this.getBoundingInfo && this.subMeshes) {
+ var g = this.getBoundingInfo();
+ S = g.boundingBox.minimumWorld.clone(), E = g.boundingBox.maximumWorld.clone();
+ } else
+ S = new _.e(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), E = new _.e(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
+ if (c)
+ for (var l = 0, h = this.getDescendants(!1); l < h.length; l++) {
+ var v = h[l];
+ if (v.computeWorldMatrix(!0), (!T || T(v)) && v.getBoundingInfo && v.getTotalVertices() !== 0) {
+ var b = v.getBoundingInfo().boundingBox, D = b.minimumWorld, w = b.maximumWorld;
+ _.e.CheckExtends(D, S, E), _.e.CheckExtends(w, S, E);
+ }
+ }
+ return { min: S, max: E };
+ }, m._AnimationRangeFactory = function(c, T, S) {
+ throw O.a.WarnImport("AnimationRange");
+ }, m._NodeConstructors = {}, Object(V.c)([Object(C.c)()], m.prototype, "name", void 0), Object(V.c)([Object(C.c)()], m.prototype, "id", void 0), Object(V.c)([Object(C.c)()], m.prototype, "uniqueId", void 0), Object(V.c)([Object(C.c)()], m.prototype, "state", void 0), Object(V.c)([Object(C.c)()], m.prototype, "metadata", void 0), m;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "b", function() {
+ return de;
+ }), f.d(A, "a", function() {
+ return pe;
+ });
+ var V = f(1), _ = f(3), C = f(33), u = f(20), I = f(0), O = f(9), x = f(4), m = f(105), c = f(42), T = f(25), S = f(76), E = f(87), g = f(15), l = f(10), h = f(11), v = f(19), b = f(5), D = `uniform vec4 vDiffuseColor;
+#ifdef SPECULARTERM
+uniform vec4 vSpecularColor;
+#endif
+uniform vec3 vEmissiveColor;
+uniform float visibility;
+
+#ifdef DIFFUSE
+uniform vec2 vDiffuseInfos;
+#endif
+#ifdef AMBIENT
+uniform vec2 vAmbientInfos;
+#endif
+#ifdef OPACITY
+uniform vec2 vOpacityInfos;
+#endif
+#ifdef EMISSIVE
+uniform vec2 vEmissiveInfos;
+#endif
+#ifdef LIGHTMAP
+uniform vec2 vLightmapInfos;
+#endif
+#ifdef BUMP
+uniform vec3 vBumpInfos;
+uniform vec2 vTangentSpaceParams;
+#endif
+#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)
+uniform mat4 view;
+#endif
+#ifdef REFRACTION
+uniform vec4 vRefractionInfos;
+#ifndef REFRACTIONMAP_3D
+uniform mat4 refractionMatrix;
+#endif
+#ifdef REFRACTIONFRESNEL
+uniform vec4 refractionLeftColor;
+uniform vec4 refractionRightColor;
+#endif
+#endif
+#if defined(SPECULAR) && defined(SPECULARTERM)
+uniform vec2 vSpecularInfos;
+#endif
+#ifdef DIFFUSEFRESNEL
+uniform vec4 diffuseLeftColor;
+uniform vec4 diffuseRightColor;
+#endif
+#ifdef OPACITYFRESNEL
+uniform vec4 opacityParts;
+#endif
+#ifdef EMISSIVEFRESNEL
+uniform vec4 emissiveLeftColor;
+uniform vec4 emissiveRightColor;
+#endif
+
+#ifdef REFLECTION
+uniform vec2 vReflectionInfos;
+#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION) || defined(REFLECTIONMAP_EQUIRECTANGULAR) || defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_SKYBOX)
+uniform mat4 reflectionMatrix;
+#endif
+#ifndef REFLECTIONMAP_SKYBOX
+#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)
+uniform vec3 vReflectionPosition;
+uniform vec3 vReflectionSize;
+#endif
+#endif
+#ifdef REFLECTIONFRESNEL
+uniform vec4 reflectionLeftColor;
+uniform vec4 reflectionRightColor;
+#endif
+#endif`;
+ b.a.IncludesShadersStore.defaultFragmentDeclaration = D;
+ var w = `layout(std140,column_major) uniform;
+uniform Material
+{
+vec4 diffuseLeftColor;
+vec4 diffuseRightColor;
+vec4 opacityParts;
+vec4 reflectionLeftColor;
+vec4 reflectionRightColor;
+vec4 refractionLeftColor;
+vec4 refractionRightColor;
+vec4 emissiveLeftColor;
+vec4 emissiveRightColor;
+vec2 vDiffuseInfos;
+vec2 vAmbientInfos;
+vec2 vOpacityInfos;
+vec2 vReflectionInfos;
+vec3 vReflectionPosition;
+vec3 vReflectionSize;
+vec2 vEmissiveInfos;
+vec2 vLightmapInfos;
+vec2 vSpecularInfos;
+vec3 vBumpInfos;
+mat4 diffuseMatrix;
+mat4 ambientMatrix;
+mat4 opacityMatrix;
+mat4 reflectionMatrix;
+mat4 emissiveMatrix;
+mat4 lightmapMatrix;
+mat4 specularMatrix;
+mat4 bumpMatrix;
+vec2 vTangentSpaceParams;
+float pointSize;
+mat4 refractionMatrix;
+vec4 vRefractionInfos;
+vec4 vSpecularColor;
+vec3 vEmissiveColor;
+float visibility;
+vec4 vDiffuseColor;
+vec4 vDetailInfos;
+mat4 detailMatrix;
+};
+uniform Scene {
+mat4 viewProjection;
+#ifdef MULTIVIEW
+mat4 viewProjectionR;
+#endif
+mat4 view;
+};
+`;
+ b.a.IncludesShadersStore.defaultUboDeclaration = w, f(160), f(59), f(106), f(107), f(154), f(130), f(161), f(131), f(108), f(109), f(132), f(133), f(115), f(116), f(125), f(110), f(134), f(162), f(135), f(155), f(136);
+ var N = `#include<__decl__defaultFragment>
+#if defined(BUMP) || !defined(NORMAL)
+#extension GL_OES_standard_derivatives : enable
+#endif
+#include[SCENE_MRT_COUNT]
+#define CUSTOM_FRAGMENT_BEGIN
+#ifdef LOGARITHMICDEPTH
+#extension GL_EXT_frag_depth : enable
+#endif
+
+#define RECIPROCAL_PI2 0.15915494
+uniform vec3 vEyePosition;
+uniform vec3 vAmbientColor;
+
+varying vec3 vPositionW;
+#ifdef NORMAL
+varying vec3 vNormalW;
+#endif
+#ifdef VERTEXCOLOR
+varying vec4 vColor;
+#endif
+#ifdef MAINUV1
+varying vec2 vMainUV1;
+#endif
+#ifdef MAINUV2
+varying vec2 vMainUV2;
+#endif
+
+#include
+
+#include<__decl__lightFragment>[0..maxSimultaneousLights]
+#include
+#include
+
+#ifdef DIFFUSE
+#if DIFFUSEDIRECTUV == 1
+#define vDiffuseUV vMainUV1
+#elif DIFFUSEDIRECTUV == 2
+#define vDiffuseUV vMainUV2
+#else
+varying vec2 vDiffuseUV;
+#endif
+uniform sampler2D diffuseSampler;
+#endif
+#ifdef AMBIENT
+#if AMBIENTDIRECTUV == 1
+#define vAmbientUV vMainUV1
+#elif AMBIENTDIRECTUV == 2
+#define vAmbientUV vMainUV2
+#else
+varying vec2 vAmbientUV;
+#endif
+uniform sampler2D ambientSampler;
+#endif
+#ifdef OPACITY
+#if OPACITYDIRECTUV == 1
+#define vOpacityUV vMainUV1
+#elif OPACITYDIRECTUV == 2
+#define vOpacityUV vMainUV2
+#else
+varying vec2 vOpacityUV;
+#endif
+uniform sampler2D opacitySampler;
+#endif
+#ifdef EMISSIVE
+#if EMISSIVEDIRECTUV == 1
+#define vEmissiveUV vMainUV1
+#elif EMISSIVEDIRECTUV == 2
+#define vEmissiveUV vMainUV2
+#else
+varying vec2 vEmissiveUV;
+#endif
+uniform sampler2D emissiveSampler;
+#endif
+#ifdef LIGHTMAP
+#if LIGHTMAPDIRECTUV == 1
+#define vLightmapUV vMainUV1
+#elif LIGHTMAPDIRECTUV == 2
+#define vLightmapUV vMainUV2
+#else
+varying vec2 vLightmapUV;
+#endif
+uniform sampler2D lightmapSampler;
+#endif
+#ifdef REFRACTION
+#ifdef REFRACTIONMAP_3D
+uniform samplerCube refractionCubeSampler;
+#else
+uniform sampler2D refraction2DSampler;
+#endif
+#endif
+#if defined(SPECULAR) && defined(SPECULARTERM)
+#if SPECULARDIRECTUV == 1
+#define vSpecularUV vMainUV1
+#elif SPECULARDIRECTUV == 2
+#define vSpecularUV vMainUV2
+#else
+varying vec2 vSpecularUV;
+#endif
+uniform sampler2D specularSampler;
+#endif
+#ifdef ALPHATEST
+uniform float alphaCutOff;
+#endif
+
+#include
+
+#ifdef REFLECTION
+#ifdef REFLECTIONMAP_3D
+uniform samplerCube reflectionCubeSampler;
+#else
+uniform sampler2D reflection2DSampler;
+#endif
+#ifdef REFLECTIONMAP_SKYBOX
+varying vec3 vPositionUVW;
+#else
+#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
+varying vec3 vDirectionW;
+#endif
+#endif
+#include
+#endif
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#define CUSTOM_FRAGMENT_DEFINITIONS
+void main(void) {
+#define CUSTOM_FRAGMENT_MAIN_BEGIN
+#include
+vec3 viewDirectionW=normalize(vEyePosition-vPositionW);
+
+vec4 baseColor=vec4(1.,1.,1.,1.);
+vec3 diffuseColor=vDiffuseColor.rgb;
+
+float alpha=vDiffuseColor.a;
+
+#ifdef NORMAL
+vec3 normalW=normalize(vNormalW);
+#else
+vec3 normalW=normalize(-cross(dFdx(vPositionW),dFdy(vPositionW)));
+#endif
+#include
+#ifdef TWOSIDEDLIGHTING
+normalW=gl_FrontFacing ? normalW : -normalW;
+#endif
+#ifdef DIFFUSE
+baseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);
+#if defined(ALPHATEST) && !defined(ALPHATEST_AFTERALLALPHACOMPUTATIONS)
+if (baseColor.a
+#ifdef VERTEXCOLOR
+baseColor.rgb*=vColor.rgb;
+#endif
+#ifdef DETAIL
+baseColor.rgb=baseColor.rgb*2.0*mix(0.5,detailColor.r,vDetailInfos.y);
+#endif
+#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE
+
+vec3 baseAmbientColor=vec3(1.,1.,1.);
+#ifdef AMBIENT
+baseAmbientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;
+#endif
+#define CUSTOM_FRAGMENT_BEFORE_LIGHTS
+
+#ifdef SPECULARTERM
+float glossiness=vSpecularColor.a;
+vec3 specularColor=vSpecularColor.rgb;
+#ifdef SPECULAR
+vec4 specularMapColor=texture2D(specularSampler,vSpecularUV+uvOffset);
+specularColor=specularMapColor.rgb;
+#ifdef GLOSSINESS
+glossiness=glossiness*specularMapColor.a;
+#endif
+#endif
+#else
+float glossiness=0.;
+#endif
+
+vec3 diffuseBase=vec3(0.,0.,0.);
+lightingInfo info;
+#ifdef SPECULARTERM
+vec3 specularBase=vec3(0.,0.,0.);
+#endif
+float shadow=1.;
+#ifdef LIGHTMAP
+vec4 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset);
+#ifdef RGBDLIGHTMAP
+lightmapColor.rgb=fromRGBD(lightmapColor);
+#endif
+lightmapColor.rgb*=vLightmapInfos.y;
+#endif
+#include[0..maxSimultaneousLights]
+
+vec4 refractionColor=vec4(0.,0.,0.,1.);
+#ifdef REFRACTION
+vec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y));
+#ifdef REFRACTIONMAP_3D
+refractionVector.y=refractionVector.y*vRefractionInfos.w;
+if (dot(refractionVector,viewDirectionW)<1.0) {
+refractionColor=textureCube(refractionCubeSampler,refractionVector);
+}
+#else
+vec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));
+vec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;
+refractionCoords.y=1.0-refractionCoords.y;
+refractionColor=texture2D(refraction2DSampler,refractionCoords);
+#endif
+#ifdef RGBDREFRACTION
+refractionColor.rgb=fromRGBD(refractionColor);
+#endif
+#ifdef IS_REFRACTION_LINEAR
+refractionColor.rgb=toGammaSpace(refractionColor.rgb);
+#endif
+refractionColor.rgb*=vRefractionInfos.x;
+#endif
+
+vec4 reflectionColor=vec4(0.,0.,0.,1.);
+#ifdef REFLECTION
+vec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);
+#ifdef REFLECTIONMAP_3D
+#ifdef ROUGHNESS
+float bias=vReflectionInfos.y;
+#ifdef SPECULARTERM
+#ifdef SPECULAR
+#ifdef GLOSSINESS
+bias*=(1.0-specularMapColor.a);
+#endif
+#endif
+#endif
+reflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias);
+#else
+reflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW);
+#endif
+#else
+vec2 coords=vReflectionUVW.xy;
+#ifdef REFLECTIONMAP_PROJECTION
+coords/=vReflectionUVW.z;
+#endif
+coords.y=1.0-coords.y;
+reflectionColor=texture2D(reflection2DSampler,coords);
+#endif
+#ifdef RGBDREFLECTION
+reflectionColor.rgb=fromRGBD(reflectionColor);
+#endif
+#ifdef IS_REFLECTION_LINEAR
+reflectionColor.rgb=toGammaSpace(reflectionColor.rgb);
+#endif
+reflectionColor.rgb*=vReflectionInfos.x;
+#ifdef REFLECTIONFRESNEL
+float reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);
+#ifdef REFLECTIONFRESNELFROMSPECULAR
+#ifdef SPECULARTERM
+reflectionColor.rgb*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;
+#else
+reflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;
+#endif
+#else
+reflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;
+#endif
+#endif
+#endif
+#ifdef REFRACTIONFRESNEL
+float refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a);
+refractionColor.rgb*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb;
+#endif
+#ifdef OPACITY
+vec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);
+#ifdef OPACITYRGB
+opacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);
+alpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;
+#else
+alpha*=opacityMap.a*vOpacityInfos.y;
+#endif
+#endif
+#ifdef VERTEXALPHA
+alpha*=vColor.a;
+#endif
+#ifdef OPACITYFRESNEL
+float opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);
+alpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;
+#endif
+#ifdef ALPHATEST
+#ifdef ALPHATEST_AFTERALLALPHACOMPUTATIONS
+if (alpha
+#include
+
+
+#ifdef IMAGEPROCESSINGPOSTPROCESS
+color.rgb=toLinearSpace(color.rgb);
+#else
+#ifdef IMAGEPROCESSING
+color.rgb=toLinearSpace(color.rgb);
+color=applyImageProcessing(color);
+#endif
+#endif
+color.a*=visibility;
+#ifdef PREMULTIPLYALPHA
+
+color.rgb*=color.a;
+#endif
+#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR
+#ifdef PREPASS
+gl_FragData[0]=color;
+#ifdef PREPASS_POSITION
+gl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,1.0);
+#endif
+#ifdef PREPASS_VELOCITY
+vec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;
+vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;
+vec2 velocity=abs(a-b);
+velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;
+gl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,1.0);
+#endif
+#ifdef PREPASS_IRRADIANCE
+gl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(0.0,0.0,0.0,1.0);
+#endif
+#ifdef PREPASS_DEPTHNORMAL
+gl_FragData[PREPASS_DEPTHNORMAL_INDEX]=vec4(vViewPos.z,(view*vec4(normalW,0.0)).rgb);
+#endif
+#ifdef PREPASS_ALBEDO
+gl_FragData[PREPASS_ALBEDO_INDEX]=vec4(0.0,0.0,0.0,1.0);
+#endif
+#ifdef PREPASS_REFLECTIVITY
+#if defined(SPECULAR)
+gl_FragData[PREPASS_REFLECTIVITY_INDEX]=specularMapColor;
+#else
+gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(0.0,0.0,0.0,1.0);
+#endif
+#endif
+#endif
+#if !defined(PREPASS) || defined(WEBGL2)
+gl_FragColor=color;
+#endif
+}
+`;
+ b.a.ShadersStore.defaultPixelShader = N;
+ var M = `
+uniform mat4 viewProjection;
+uniform mat4 view;
+#ifdef DIFFUSE
+uniform mat4 diffuseMatrix;
+uniform vec2 vDiffuseInfos;
+#endif
+#ifdef AMBIENT
+uniform mat4 ambientMatrix;
+uniform vec2 vAmbientInfos;
+#endif
+#ifdef OPACITY
+uniform mat4 opacityMatrix;
+uniform vec2 vOpacityInfos;
+#endif
+#ifdef EMISSIVE
+uniform vec2 vEmissiveInfos;
+uniform mat4 emissiveMatrix;
+#endif
+#ifdef LIGHTMAP
+uniform vec2 vLightmapInfos;
+uniform mat4 lightmapMatrix;
+#endif
+#if defined(SPECULAR) && defined(SPECULARTERM)
+uniform vec2 vSpecularInfos;
+uniform mat4 specularMatrix;
+#endif
+#ifdef BUMP
+uniform vec3 vBumpInfos;
+uniform mat4 bumpMatrix;
+#endif
+#ifdef REFLECTION
+uniform mat4 reflectionMatrix;
+#endif
+#ifdef POINTSIZE
+uniform float pointSize;
+#endif
+`;
+ b.a.IncludesShadersStore.defaultVertexDeclaration = M, f(78), f(79), f(163), f(164), f(117), f(137), f(93), f(94), f(100), f(80), f(81), f(165), f(156), f(111), f(157), f(138), b.a.IncludesShadersStore.pointCloudVertex = `#ifdef POINTSIZE
+gl_PointSize=pointSize;
+#endif`, f(158);
+ var U = `#include<__decl__defaultVertex>
+
+#define CUSTOM_VERTEX_BEGIN
+attribute vec3 position;
+#ifdef NORMAL
+attribute vec3 normal;
+#endif
+#ifdef TANGENT
+attribute vec4 tangent;
+#endif
+#ifdef UV1
+attribute vec2 uv;
+#endif
+#ifdef UV2
+attribute vec2 uv2;
+#endif
+#ifdef VERTEXCOLOR
+attribute vec4 color;
+#endif
+#include
+#include
+
+#include
+#include
+#ifdef MAINUV1
+varying vec2 vMainUV1;
+#endif
+#ifdef MAINUV2
+varying vec2 vMainUV2;
+#endif
+#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0
+varying vec2 vDiffuseUV;
+#endif
+#if defined(DETAIL) && DETAILDIRECTUV == 0
+varying vec2 vDetailUV;
+#endif
+#if defined(AMBIENT) && AMBIENTDIRECTUV == 0
+varying vec2 vAmbientUV;
+#endif
+#if defined(OPACITY) && OPACITYDIRECTUV == 0
+varying vec2 vOpacityUV;
+#endif
+#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0
+varying vec2 vEmissiveUV;
+#endif
+#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0
+varying vec2 vLightmapUV;
+#endif
+#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0
+varying vec2 vSpecularUV;
+#endif
+#if defined(BUMP) && BUMPDIRECTUV == 0
+varying vec2 vBumpUV;
+#endif
+
+varying vec3 vPositionW;
+#ifdef NORMAL
+varying vec3 vNormalW;
+#endif
+#ifdef VERTEXCOLOR
+varying vec4 vColor;
+#endif
+#include
+#include
+#include
+#include<__decl__lightFragment>[0..maxSimultaneousLights]
+#include
+#include[0..maxSimultaneousMorphTargets]
+#ifdef REFLECTIONMAP_SKYBOX
+varying vec3 vPositionUVW;
+#endif
+#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
+varying vec3 vDirectionW;
+#endif
+#include
+#define CUSTOM_VERTEX_DEFINITIONS
+void main(void) {
+#define CUSTOM_VERTEX_MAIN_BEGIN
+vec3 positionUpdated=position;
+#ifdef NORMAL
+vec3 normalUpdated=normal;
+#endif
+#ifdef TANGENT
+vec4 tangentUpdated=tangent;
+#endif
+#ifdef UV1
+vec2 uvUpdated=uv;
+#endif
+#include[0..maxSimultaneousMorphTargets]
+#ifdef REFLECTIONMAP_SKYBOX
+vPositionUVW=positionUpdated;
+#endif
+#define CUSTOM_VERTEX_UPDATE_POSITION
+#define CUSTOM_VERTEX_UPDATE_NORMAL
+#include
+#if defined(PREPASS) && defined(PREPASS_VELOCITY) && !defined(BONES_VELOCITY_ENABLED)
+
+vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);
+vPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0);
+#endif
+#include
+vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);
+#ifdef NORMAL
+mat3 normalWorld=mat3(finalWorld);
+#if defined(INSTANCES) && defined(THIN_INSTANCES)
+vNormalW=normalUpdated/vec3(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2]));
+vNormalW=normalize(normalWorld*vNormalW);
+#else
+#ifdef NONUNIFORMSCALING
+normalWorld=transposeMat3(inverseMat3(normalWorld));
+#endif
+vNormalW=normalize(normalWorld*normalUpdated);
+#endif
+#endif
+#define CUSTOM_VERTEX_UPDATE_WORLDPOS
+#ifdef MULTIVIEW
+if (gl_ViewID_OVR == 0u) {
+gl_Position=viewProjection*worldPos;
+} else {
+gl_Position=viewProjectionR*worldPos;
+}
+#else
+gl_Position=viewProjection*worldPos;
+#endif
+vPositionW=vec3(worldPos);
+#include
+#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
+vDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));
+#endif
+
+#ifndef UV1
+vec2 uvUpdated=vec2(0.,0.);
+#endif
+#ifndef UV2
+vec2 uv2=vec2(0.,0.);
+#endif
+#ifdef MAINUV1
+vMainUV1=uvUpdated;
+#endif
+#ifdef MAINUV2
+vMainUV2=uv2;
+#endif
+#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0
+if (vDiffuseInfos.x == 0.)
+{
+vDiffuseUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));
+}
+else
+{
+vDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
+}
+#endif
+#if defined(DETAIL) && DETAILDIRECTUV == 0
+if (vDetailInfos.x == 0.)
+{
+vDetailUV=vec2(detailMatrix*vec4(uvUpdated,1.0,0.0));
+}
+else
+{
+vDetailUV=vec2(detailMatrix*vec4(uv2,1.0,0.0));
+}
+#endif
+#if defined(AMBIENT) && AMBIENTDIRECTUV == 0
+if (vAmbientInfos.x == 0.)
+{
+vAmbientUV=vec2(ambientMatrix*vec4(uvUpdated,1.0,0.0));
+}
+else
+{
+vAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));
+}
+#endif
+#if defined(OPACITY) && OPACITYDIRECTUV == 0
+if (vOpacityInfos.x == 0.)
+{
+vOpacityUV=vec2(opacityMatrix*vec4(uvUpdated,1.0,0.0));
+}
+else
+{
+vOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));
+}
+#endif
+#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0
+if (vEmissiveInfos.x == 0.)
+{
+vEmissiveUV=vec2(emissiveMatrix*vec4(uvUpdated,1.0,0.0));
+}
+else
+{
+vEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));
+}
+#endif
+#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0
+if (vLightmapInfos.x == 0.)
+{
+vLightmapUV=vec2(lightmapMatrix*vec4(uvUpdated,1.0,0.0));
+}
+else
+{
+vLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));
+}
+#endif
+#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0
+if (vSpecularInfos.x == 0.)
+{
+vSpecularUV=vec2(specularMatrix*vec4(uvUpdated,1.0,0.0));
+}
+else
+{
+vSpecularUV=vec2(specularMatrix*vec4(uv2,1.0,0.0));
+}
+#endif
+#if defined(BUMP) && BUMPDIRECTUV == 0
+if (vBumpInfos.x == 0.)
+{
+vBumpUV=vec2(bumpMatrix*vec4(uvUpdated,1.0,0.0));
+}
+else
+{
+vBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));
+}
+#endif
+#include
+#include
+#include
+#include[0..maxSimultaneousLights]
+#ifdef VERTEXCOLOR
+
+vColor=color;
+#endif
+#include
+#include
+#define CUSTOM_VERTEX_MAIN_END
+}
+`;
+ b.a.ShadersStore.defaultVertexShader = U;
+ var X = f(2), j = f(67), ne = f(92), te = { effect: null, subMesh: null }, de = function(ae) {
+ function ee() {
+ var K = ae.call(this) || this;
+ return K.MAINUV1 = !1, K.MAINUV2 = !1, K.DIFFUSE = !1, K.DIFFUSEDIRECTUV = 0, K.DETAIL = !1, K.DETAILDIRECTUV = 0, K.DETAIL_NORMALBLENDMETHOD = 0, K.AMBIENT = !1, K.AMBIENTDIRECTUV = 0, K.OPACITY = !1, K.OPACITYDIRECTUV = 0, K.OPACITYRGB = !1, K.REFLECTION = !1, K.EMISSIVE = !1, K.EMISSIVEDIRECTUV = 0, K.SPECULAR = !1, K.SPECULARDIRECTUV = 0, K.BUMP = !1, K.BUMPDIRECTUV = 0, K.PARALLAX = !1, K.PARALLAXOCCLUSION = !1, K.SPECULAROVERALPHA = !1, K.CLIPPLANE = !1, K.CLIPPLANE2 = !1, K.CLIPPLANE3 = !1, K.CLIPPLANE4 = !1, K.CLIPPLANE5 = !1, K.CLIPPLANE6 = !1, K.ALPHATEST = !1, K.DEPTHPREPASS = !1, K.ALPHAFROMDIFFUSE = !1, K.POINTSIZE = !1, K.FOG = !1, K.SPECULARTERM = !1, K.DIFFUSEFRESNEL = !1, K.OPACITYFRESNEL = !1, K.REFLECTIONFRESNEL = !1, K.REFRACTIONFRESNEL = !1, K.EMISSIVEFRESNEL = !1, K.FRESNEL = !1, K.NORMAL = !1, K.UV1 = !1, K.UV2 = !1, K.VERTEXCOLOR = !1, K.VERTEXALPHA = !1, K.NUM_BONE_INFLUENCERS = 0, K.BonesPerMesh = 0, K.BONETEXTURE = !1, K.BONES_VELOCITY_ENABLED = !1, K.INSTANCES = !1, K.THIN_INSTANCES = !1, K.GLOSSINESS = !1, K.ROUGHNESS = !1, K.EMISSIVEASILLUMINATION = !1, K.LINKEMISSIVEWITHDIFFUSE = !1, K.REFLECTIONFRESNELFROMSPECULAR = !1, K.LIGHTMAP = !1, K.LIGHTMAPDIRECTUV = 0, K.OBJECTSPACE_NORMALMAP = !1, K.USELIGHTMAPASSHADOWMAP = !1, K.REFLECTIONMAP_3D = !1, K.REFLECTIONMAP_SPHERICAL = !1, K.REFLECTIONMAP_PLANAR = !1, K.REFLECTIONMAP_CUBIC = !1, K.USE_LOCAL_REFLECTIONMAP_CUBIC = !1, K.REFLECTIONMAP_PROJECTION = !1, K.REFLECTIONMAP_SKYBOX = !1, K.REFLECTIONMAP_EXPLICIT = !1, K.REFLECTIONMAP_EQUIRECTANGULAR = !1, K.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1, K.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1, K.INVERTCUBICMAP = !1, K.LOGARITHMICDEPTH = !1, K.REFRACTION = !1, K.REFRACTIONMAP_3D = !1, K.REFLECTIONOVERALPHA = !1, K.TWOSIDEDLIGHTING = !1, K.SHADOWFLOAT = !1, K.MORPHTARGETS = !1, K.MORPHTARGETS_NORMAL = !1, K.MORPHTARGETS_TANGENT = !1, K.MORPHTARGETS_UV = !1, K.NUM_MORPH_INFLUENCERS = 0, K.NONUNIFORMSCALING = !1, K.PREMULTIPLYALPHA = !1, K.ALPHATEST_AFTERALLALPHACOMPUTATIONS = !1, K.ALPHABLEND = !0, K.PREPASS = !1, K.PREPASS_IRRADIANCE = !1, K.PREPASS_IRRADIANCE_INDEX = -1, K.PREPASS_ALBEDO = !1, K.PREPASS_ALBEDO_INDEX = -1, K.PREPASS_DEPTHNORMAL = !1, K.PREPASS_DEPTHNORMAL_INDEX = -1, K.PREPASS_POSITION = !1, K.PREPASS_POSITION_INDEX = -1, K.PREPASS_VELOCITY = !1, K.PREPASS_VELOCITY_INDEX = -1, K.PREPASS_REFLECTIVITY = !1, K.PREPASS_REFLECTIVITY_INDEX = -1, K.SCENE_MRT_COUNT = 0, K.RGBDLIGHTMAP = !1, K.RGBDREFLECTION = !1, K.RGBDREFRACTION = !1, K.IMAGEPROCESSING = !1, K.VIGNETTE = !1, K.VIGNETTEBLENDMODEMULTIPLY = !1, K.VIGNETTEBLENDMODEOPAQUE = !1, K.TONEMAPPING = !1, K.TONEMAPPING_ACES = !1, K.CONTRAST = !1, K.COLORCURVES = !1, K.COLORGRADING = !1, K.COLORGRADING3D = !1, K.SAMPLER3DGREENDEPTH = !1, K.SAMPLER3DBGRMAP = !1, K.IMAGEPROCESSINGPOSTPROCESS = !1, K.MULTIVIEW = !1, K.IS_REFLECTION_LINEAR = !1, K.IS_REFRACTION_LINEAR = !1, K.EXPOSURE = !1, K.rebuild(), K;
+ }
+ return Object(V.d)(ee, ae), ee.prototype.setReflectionMode = function(K) {
+ for (var $ = 0, L = ["REFLECTIONMAP_CUBIC", "REFLECTIONMAP_EXPLICIT", "REFLECTIONMAP_PLANAR", "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_SKYBOX", "REFLECTIONMAP_SPHERICAL", "REFLECTIONMAP_EQUIRECTANGULAR", "REFLECTIONMAP_EQUIRECTANGULAR_FIXED", "REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"]; $ < L.length; $++) {
+ var G = L[$];
+ this[G] = G === K;
+ }
+ }, ee;
+ }(S.a), pe = function(ae) {
+ function ee(K, $) {
+ var L = ae.call(this, K, $) || this;
+ return L._diffuseTexture = null, L._ambientTexture = null, L._opacityTexture = null, L._reflectionTexture = null, L._emissiveTexture = null, L._specularTexture = null, L._bumpTexture = null, L._lightmapTexture = null, L._refractionTexture = null, L.ambientColor = new O.a(0, 0, 0), L.diffuseColor = new O.a(1, 1, 1), L.specularColor = new O.a(1, 1, 1), L.emissiveColor = new O.a(0, 0, 0), L.specularPower = 64, L._useAlphaFromDiffuseTexture = !1, L._useEmissiveAsIllumination = !1, L._linkEmissiveWithDiffuse = !1, L._useSpecularOverAlpha = !1, L._useReflectionOverAlpha = !1, L._disableLighting = !1, L._useObjectSpaceNormalMap = !1, L._useParallax = !1, L._useParallaxOcclusion = !1, L.parallaxScaleBias = 0.05, L._roughness = 0, L.indexOfRefraction = 0.98, L.invertRefractionY = !0, L.alphaCutOff = 0.4, L._useLightmapAsShadowmap = !1, L._useReflectionFresnelFromSpecular = !1, L._useGlossinessFromSpecularMapAlpha = !1, L._maxSimultaneousLights = 4, L._invertNormalMapX = !1, L._invertNormalMapY = !1, L._twoSidedLighting = !1, L.detailMap = new ne.a(L._markAllSubMeshesAsTexturesDirty.bind(L)), L._renderTargets = new C.a(16), L._worldViewProjectionMatrix = I.a.Zero(), L._globalAmbientColor = new O.a(0, 0, 0), L._rebuildInParallel = !1, L._attachImageProcessingConfiguration(null), L.prePassConfiguration = new m.a(), L.getRenderTargetTextures = function() {
+ return L._renderTargets.reset(), ee.ReflectionTextureEnabled && L._reflectionTexture && L._reflectionTexture.isRenderTarget && L._renderTargets.push(L._reflectionTexture), ee.RefractionTextureEnabled && L._refractionTexture && L._refractionTexture.isRenderTarget && L._renderTargets.push(L._refractionTexture), L._renderTargets;
+ }, L;
+ }
+ return Object(V.d)(ee, ae), Object.defineProperty(ee.prototype, "imageProcessingConfiguration", { get: function() {
+ return this._imageProcessingConfiguration;
+ }, set: function(K) {
+ this._attachImageProcessingConfiguration(K), this._markAllSubMeshesAsTexturesDirty();
+ }, enumerable: !1, configurable: !0 }), ee.prototype._attachImageProcessingConfiguration = function(K) {
+ var $ = this;
+ K !== this._imageProcessingConfiguration && (this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver), this._imageProcessingConfiguration = K || this.getScene().imageProcessingConfiguration, this._imageProcessingConfiguration && (this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function() {
+ $._markAllSubMeshesAsImageProcessingDirty();
+ })));
+ }, Object.defineProperty(ee.prototype, "cameraColorCurvesEnabled", { get: function() {
+ return this.imageProcessingConfiguration.colorCurvesEnabled;
+ }, set: function(K) {
+ this.imageProcessingConfiguration.colorCurvesEnabled = K;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(ee.prototype, "cameraColorGradingEnabled", { get: function() {
+ return this.imageProcessingConfiguration.colorGradingEnabled;
+ }, set: function(K) {
+ this.imageProcessingConfiguration.colorGradingEnabled = K;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(ee.prototype, "cameraToneMappingEnabled", { get: function() {
+ return this._imageProcessingConfiguration.toneMappingEnabled;
+ }, set: function(K) {
+ this._imageProcessingConfiguration.toneMappingEnabled = K;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(ee.prototype, "cameraExposure", { get: function() {
+ return this._imageProcessingConfiguration.exposure;
+ }, set: function(K) {
+ this._imageProcessingConfiguration.exposure = K;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(ee.prototype, "cameraContrast", { get: function() {
+ return this._imageProcessingConfiguration.contrast;
+ }, set: function(K) {
+ this._imageProcessingConfiguration.contrast = K;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(ee.prototype, "cameraColorGradingTexture", { get: function() {
+ return this._imageProcessingConfiguration.colorGradingTexture;
+ }, set: function(K) {
+ this._imageProcessingConfiguration.colorGradingTexture = K;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(ee.prototype, "cameraColorCurves", { get: function() {
+ return this._imageProcessingConfiguration.colorCurves;
+ }, set: function(K) {
+ this._imageProcessingConfiguration.colorCurves = K;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(ee.prototype, "canRenderToMRT", { get: function() {
+ return !0;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(ee.prototype, "hasRenderTargetTextures", { get: function() {
+ return !!(ee.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) || !!(ee.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget);
+ }, enumerable: !1, configurable: !0 }), ee.prototype.getClassName = function() {
+ return "StandardMaterial";
+ }, Object.defineProperty(ee.prototype, "useLogarithmicDepth", { get: function() {
+ return this._useLogarithmicDepth;
+ }, set: function(K) {
+ this._useLogarithmicDepth = K && this.getScene().getEngine().getCaps().fragmentDepthSupported, this._markAllSubMeshesAsMiscDirty();
+ }, enumerable: !1, configurable: !0 }), ee.prototype.needAlphaBlending = function() {
+ return !this._disableAlphaBlending && (this.alpha < 1 || this._opacityTexture != null || this._shouldUseAlphaFromDiffuseTexture() || this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled);
+ }, ee.prototype.needAlphaTesting = function() {
+ return !!this._forceAlphaTest || this._hasAlphaChannel() && (this._transparencyMode == null || this._transparencyMode === T.a.MATERIAL_ALPHATEST);
+ }, ee.prototype._shouldUseAlphaFromDiffuseTexture = function() {
+ return this._diffuseTexture != null && this._diffuseTexture.hasAlpha && this._useAlphaFromDiffuseTexture && this._transparencyMode !== T.a.MATERIAL_OPAQUE;
+ }, ee.prototype._hasAlphaChannel = function() {
+ return this._diffuseTexture != null && this._diffuseTexture.hasAlpha || this._opacityTexture != null;
+ }, ee.prototype.getAlphaTestTexture = function() {
+ return this._diffuseTexture;
+ }, ee.prototype.isReadyForSubMesh = function(K, $, L) {
+ if (L === void 0 && (L = !1), $.effect && this.isFrozen && $.effect._wasPreviouslyReady)
+ return !0;
+ $._materialDefines || ($._materialDefines = new de());
+ var G = this.getScene(), Q = $._materialDefines;
+ if (this._isReadyForSubMesh($))
+ return !0;
+ var oe = G.getEngine();
+ if (Q._needNormals = g.a.PrepareDefinesForLights(G, K, Q, !0, this._maxSimultaneousLights, this._disableLighting), g.a.PrepareDefinesForMultiview(G, Q), g.a.PrepareDefinesForPrePass(G, Q, this.canRenderToMRT), Q._areTexturesDirty) {
+ if (Q._needUVs = !1, Q.MAINUV1 = !1, Q.MAINUV2 = !1, G.texturesEnabled) {
+ if (this._diffuseTexture && ee.DiffuseTextureEnabled) {
+ if (!this._diffuseTexture.isReadyOrNotBlocking())
+ return !1;
+ g.a.PrepareDefinesForMergedUV(this._diffuseTexture, Q, "DIFFUSE");
+ } else
+ Q.DIFFUSE = !1;
+ if (this._ambientTexture && ee.AmbientTextureEnabled) {
+ if (!this._ambientTexture.isReadyOrNotBlocking())
+ return !1;
+ g.a.PrepareDefinesForMergedUV(this._ambientTexture, Q, "AMBIENT");
+ } else
+ Q.AMBIENT = !1;
+ if (this._opacityTexture && ee.OpacityTextureEnabled) {
+ if (!this._opacityTexture.isReadyOrNotBlocking())
+ return !1;
+ g.a.PrepareDefinesForMergedUV(this._opacityTexture, Q, "OPACITY"), Q.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
+ } else
+ Q.OPACITY = !1;
+ if (this._reflectionTexture && ee.ReflectionTextureEnabled) {
+ if (!this._reflectionTexture.isReadyOrNotBlocking())
+ return !1;
+ switch (Q._needNormals = !0, Q.REFLECTION = !0, Q.ROUGHNESS = this._roughness > 0, Q.REFLECTIONOVERALPHA = this._useReflectionOverAlpha, Q.INVERTCUBICMAP = this._reflectionTexture.coordinatesMode === l.a.INVCUBIC_MODE, Q.REFLECTIONMAP_3D = this._reflectionTexture.isCube, Q.RGBDREFLECTION = this._reflectionTexture.isRGBD, this._reflectionTexture.coordinatesMode) {
+ case l.a.EXPLICIT_MODE:
+ Q.setReflectionMode("REFLECTIONMAP_EXPLICIT");
+ break;
+ case l.a.PLANAR_MODE:
+ Q.setReflectionMode("REFLECTIONMAP_PLANAR");
+ break;
+ case l.a.PROJECTION_MODE:
+ Q.setReflectionMode("REFLECTIONMAP_PROJECTION");
+ break;
+ case l.a.SKYBOX_MODE:
+ Q.setReflectionMode("REFLECTIONMAP_SKYBOX");
+ break;
+ case l.a.SPHERICAL_MODE:
+ Q.setReflectionMode("REFLECTIONMAP_SPHERICAL");
+ break;
+ case l.a.EQUIRECTANGULAR_MODE:
+ Q.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");
+ break;
+ case l.a.FIXED_EQUIRECTANGULAR_MODE:
+ Q.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");
+ break;
+ case l.a.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
+ Q.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");
+ break;
+ case l.a.CUBIC_MODE:
+ case l.a.INVCUBIC_MODE:
+ default:
+ Q.setReflectionMode("REFLECTIONMAP_CUBIC");
+ }
+ Q.USE_LOCAL_REFLECTIONMAP_CUBIC = !!this._reflectionTexture.boundingBoxSize;
+ } else
+ Q.REFLECTION = !1;
+ if (this._emissiveTexture && ee.EmissiveTextureEnabled) {
+ if (!this._emissiveTexture.isReadyOrNotBlocking())
+ return !1;
+ g.a.PrepareDefinesForMergedUV(this._emissiveTexture, Q, "EMISSIVE");
+ } else
+ Q.EMISSIVE = !1;
+ if (this._lightmapTexture && ee.LightmapTextureEnabled) {
+ if (!this._lightmapTexture.isReadyOrNotBlocking())
+ return !1;
+ g.a.PrepareDefinesForMergedUV(this._lightmapTexture, Q, "LIGHTMAP"), Q.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap, Q.RGBDLIGHTMAP = this._lightmapTexture.isRGBD;
+ } else
+ Q.LIGHTMAP = !1;
+ if (this._specularTexture && ee.SpecularTextureEnabled) {
+ if (!this._specularTexture.isReadyOrNotBlocking())
+ return !1;
+ g.a.PrepareDefinesForMergedUV(this._specularTexture, Q, "SPECULAR"), Q.GLOSSINESS = this._useGlossinessFromSpecularMapAlpha;
+ } else
+ Q.SPECULAR = !1;
+ if (G.getEngine().getCaps().standardDerivatives && this._bumpTexture && ee.BumpTextureEnabled) {
+ if (!this._bumpTexture.isReady())
+ return !1;
+ g.a.PrepareDefinesForMergedUV(this._bumpTexture, Q, "BUMP"), Q.PARALLAX = this._useParallax, Q.PARALLAXOCCLUSION = this._useParallaxOcclusion, Q.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
+ } else
+ Q.BUMP = !1;
+ if (this._refractionTexture && ee.RefractionTextureEnabled) {
+ if (!this._refractionTexture.isReadyOrNotBlocking())
+ return !1;
+ Q._needUVs = !0, Q.REFRACTION = !0, Q.REFRACTIONMAP_3D = this._refractionTexture.isCube, Q.RGBDREFRACTION = this._refractionTexture.isRGBD;
+ } else
+ Q.REFRACTION = !1;
+ Q.TWOSIDEDLIGHTING = !this._backFaceCulling && this._twoSidedLighting;
+ } else
+ Q.DIFFUSE = !1, Q.AMBIENT = !1, Q.OPACITY = !1, Q.REFLECTION = !1, Q.EMISSIVE = !1, Q.LIGHTMAP = !1, Q.BUMP = !1, Q.REFRACTION = !1;
+ Q.ALPHAFROMDIFFUSE = this._shouldUseAlphaFromDiffuseTexture(), Q.EMISSIVEASILLUMINATION = this._useEmissiveAsIllumination, Q.LINKEMISSIVEWITHDIFFUSE = this._linkEmissiveWithDiffuse, Q.SPECULAROVERALPHA = this._useSpecularOverAlpha, Q.PREMULTIPLYALPHA = this.alphaMode === X.a.ALPHA_PREMULTIPLIED || this.alphaMode === X.a.ALPHA_PREMULTIPLIED_PORTERDUFF, Q.ALPHATEST_AFTERALLALPHACOMPUTATIONS = this.transparencyMode !== null, Q.ALPHABLEND = this.transparencyMode === null || this.needAlphaBlendingForMesh(K);
+ }
+ if (!this.detailMap.isReadyForSubMesh(Q, G))
+ return !1;
+ if (Q._areImageProcessingDirty && this._imageProcessingConfiguration) {
+ if (!this._imageProcessingConfiguration.isReady())
+ return !1;
+ this._imageProcessingConfiguration.prepareDefines(Q), Q.IS_REFLECTION_LINEAR = this.reflectionTexture != null && !this.reflectionTexture.gammaSpace, Q.IS_REFRACTION_LINEAR = this.refractionTexture != null && !this.refractionTexture.gammaSpace;
+ }
+ if (Q._areFresnelDirty && (ee.FresnelEnabled ? (this._diffuseFresnelParameters || this._opacityFresnelParameters || this._emissiveFresnelParameters || this._refractionFresnelParameters || this._reflectionFresnelParameters) && (Q.DIFFUSEFRESNEL = this._diffuseFresnelParameters && this._diffuseFresnelParameters.isEnabled, Q.OPACITYFRESNEL = this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled, Q.REFLECTIONFRESNEL = this._reflectionFresnelParameters && this._reflectionFresnelParameters.isEnabled, Q.REFLECTIONFRESNELFROMSPECULAR = this._useReflectionFresnelFromSpecular, Q.REFRACTIONFRESNEL = this._refractionFresnelParameters && this._refractionFresnelParameters.isEnabled, Q.EMISSIVEFRESNEL = this._emissiveFresnelParameters && this._emissiveFresnelParameters.isEnabled, Q._needNormals = !0, Q.FRESNEL = !0) : Q.FRESNEL = !1), g.a.PrepareDefinesForMisc(K, G, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(K) || this._forceAlphaTest, Q), g.a.PrepareDefinesForAttributes(K, Q, !0, !0, !0), g.a.PrepareDefinesForFrameBoundValues(G, oe, Q, L, null, $.getRenderingMesh().hasThinInstances), this.detailMap.prepareDefines(Q, G), Q.isDirty) {
+ var re = Q._areLightsDisposed;
+ Q.markAsProcessed();
+ var Y = new j.a();
+ Q.REFLECTION && Y.addFallback(0, "REFLECTION"), Q.SPECULAR && Y.addFallback(0, "SPECULAR"), Q.BUMP && Y.addFallback(0, "BUMP"), Q.PARALLAX && Y.addFallback(1, "PARALLAX"), Q.PARALLAXOCCLUSION && Y.addFallback(0, "PARALLAXOCCLUSION"), Q.SPECULAROVERALPHA && Y.addFallback(0, "SPECULAROVERALPHA"), Q.FOG && Y.addFallback(1, "FOG"), Q.POINTSIZE && Y.addFallback(0, "POINTSIZE"), Q.LOGARITHMICDEPTH && Y.addFallback(0, "LOGARITHMICDEPTH"), g.a.HandleFallbacksForShadows(Q, Y, this._maxSimultaneousLights), Q.SPECULARTERM && Y.addFallback(0, "SPECULARTERM"), Q.DIFFUSEFRESNEL && Y.addFallback(1, "DIFFUSEFRESNEL"), Q.OPACITYFRESNEL && Y.addFallback(2, "OPACITYFRESNEL"), Q.REFLECTIONFRESNEL && Y.addFallback(3, "REFLECTIONFRESNEL"), Q.EMISSIVEFRESNEL && Y.addFallback(4, "EMISSIVEFRESNEL"), Q.FRESNEL && Y.addFallback(4, "FRESNEL"), Q.MULTIVIEW && Y.addFallback(0, "MULTIVIEW");
+ var k = [x.b.PositionKind];
+ Q.NORMAL && k.push(x.b.NormalKind), Q.UV1 && k.push(x.b.UVKind), Q.UV2 && k.push(x.b.UV2Kind), Q.VERTEXCOLOR && k.push(x.b.ColorKind), g.a.PrepareAttributesForBones(k, K, Q, Y), g.a.PrepareAttributesForInstances(k, Q), g.a.PrepareAttributesForMorphTargets(k, K, Q);
+ var H = "default", Z = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vDiffuseColor", "vSpecularColor", "vEmissiveColor", "visibility", "vFogInfos", "vFogColor", "pointSize", "vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos", "mBones", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix", "normalMatrix", "lightmapMatrix", "refractionMatrix", "diffuseLeftColor", "diffuseRightColor", "opacityParts", "reflectionLeftColor", "reflectionRightColor", "emissiveLeftColor", "emissiveRightColor", "refractionLeftColor", "refractionRightColor", "vReflectionPosition", "vReflectionSize", "logarithmicDepthConstant", "vTangentSpaceParams", "alphaCutOff", "boneTextureWidth"], W = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler", "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler", "refractionCubeSampler", "refraction2DSampler", "boneSampler"], q = ["Material", "Scene"];
+ ne.a.AddUniforms(Z), ne.a.AddSamplers(W), m.a.AddUniforms(Z), m.a.AddSamplers(Z), c.a && (c.a.PrepareUniforms(Z, Q), c.a.PrepareSamplers(W, Q)), g.a.PrepareUniformsAndSamplersList({ uniformsNames: Z, uniformBuffersNames: q, samplers: W, defines: Q, maxSimultaneousLights: this._maxSimultaneousLights });
+ var he = {};
+ this.customShaderNameResolve && (H = this.customShaderNameResolve(H, Z, q, W, Q, k, he));
+ var ge = Q.toString(), me = $.effect, _e = G.getEngine().createEffect(H, { attributes: k, uniformsNames: Z, uniformBuffersNames: q, samplers: W, defines: ge, fallbacks: Y, onCompiled: this.onCompiled, onError: this.onError, indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: Q.NUM_MORPH_INFLUENCERS }, processFinalCode: he.processFinalCode, multiTarget: Q.PREPASS }, oe);
+ if (_e)
+ if (this._onEffectCreatedObservable && (te.effect = _e, te.subMesh = $, this._onEffectCreatedObservable.notifyObservers(te)), this.allowShaderHotSwapping && me && !_e.isReady()) {
+ if (_e = me, this._rebuildInParallel = !0, Q.markAsUnprocessed(), re)
+ return Q._areLightsDisposed = !0, !1;
+ } else
+ this._rebuildInParallel = !1, G.resetCachedMaterial(), $.setEffect(_e, Q), this.buildUniformLayout();
+ }
+ return !(!$.effect || !$.effect.isReady()) && (Q._renderId = G.getRenderId(), $.effect._wasPreviouslyReady = !0, !0);
+ }, ee.prototype.buildUniformLayout = function() {
+ var K = this._uniformBuffer;
+ K.addUniform("diffuseLeftColor", 4), K.addUniform("diffuseRightColor", 4), K.addUniform("opacityParts", 4), K.addUniform("reflectionLeftColor", 4), K.addUniform("reflectionRightColor", 4), K.addUniform("refractionLeftColor", 4), K.addUniform("refractionRightColor", 4), K.addUniform("emissiveLeftColor", 4), K.addUniform("emissiveRightColor", 4), K.addUniform("vDiffuseInfos", 2), K.addUniform("vAmbientInfos", 2), K.addUniform("vOpacityInfos", 2), K.addUniform("vReflectionInfos", 2), K.addUniform("vReflectionPosition", 3), K.addUniform("vReflectionSize", 3), K.addUniform("vEmissiveInfos", 2), K.addUniform("vLightmapInfos", 2), K.addUniform("vSpecularInfos", 2), K.addUniform("vBumpInfos", 3), K.addUniform("diffuseMatrix", 16), K.addUniform("ambientMatrix", 16), K.addUniform("opacityMatrix", 16), K.addUniform("reflectionMatrix", 16), K.addUniform("emissiveMatrix", 16), K.addUniform("lightmapMatrix", 16), K.addUniform("specularMatrix", 16), K.addUniform("bumpMatrix", 16), K.addUniform("vTangentSpaceParams", 2), K.addUniform("pointSize", 1), K.addUniform("refractionMatrix", 16), K.addUniform("vRefractionInfos", 4), K.addUniform("vSpecularColor", 4), K.addUniform("vEmissiveColor", 3), K.addUniform("visibility", 1), K.addUniform("vDiffuseColor", 4), ne.a.PrepareUniformBuffer(K), K.create();
+ }, ee.prototype.unbind = function() {
+ if (this._activeEffect) {
+ var K = !1;
+ this._reflectionTexture && this._reflectionTexture.isRenderTarget && (this._activeEffect.setTexture("reflection2DSampler", null), K = !0), this._refractionTexture && this._refractionTexture.isRenderTarget && (this._activeEffect.setTexture("refraction2DSampler", null), K = !0), K && this._markAllSubMeshesAsTexturesDirty();
+ }
+ ae.prototype.unbind.call(this);
+ }, ee.prototype.bindForSubMesh = function(K, $, L) {
+ var G = this.getScene(), Q = L._materialDefines;
+ if (Q) {
+ var oe = L.effect;
+ if (oe) {
+ this._activeEffect = oe, Q.INSTANCES && !Q.THIN_INSTANCES || this.bindOnlyWorldMatrix(K), this.prePassConfiguration.bindForSubMesh(this._activeEffect, G, $, K, this.isFrozen), Q.OBJECTSPACE_NORMALMAP && (K.toNormalMatrix(this._normalMatrix), this.bindOnlyNormalMatrix(this._normalMatrix));
+ var re = this._mustRebind(G, oe, $.visibility);
+ g.a.BindBonesParameters($, oe);
+ var Y = this._uniformBuffer;
+ if (re) {
+ if (Y.bindToEffect(oe, "Material"), this.bindViewProjection(oe), !Y.useUbo || !this.isFrozen || !Y.isSync) {
+ if (ee.FresnelEnabled && Q.FRESNEL && (this.diffuseFresnelParameters && this.diffuseFresnelParameters.isEnabled && (Y.updateColor4("diffuseLeftColor", this.diffuseFresnelParameters.leftColor, this.diffuseFresnelParameters.power), Y.updateColor4("diffuseRightColor", this.diffuseFresnelParameters.rightColor, this.diffuseFresnelParameters.bias)), this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled && Y.updateColor4("opacityParts", new O.a(this.opacityFresnelParameters.leftColor.toLuminance(), this.opacityFresnelParameters.rightColor.toLuminance(), this.opacityFresnelParameters.bias), this.opacityFresnelParameters.power), this.reflectionFresnelParameters && this.reflectionFresnelParameters.isEnabled && (Y.updateColor4("reflectionLeftColor", this.reflectionFresnelParameters.leftColor, this.reflectionFresnelParameters.power), Y.updateColor4("reflectionRightColor", this.reflectionFresnelParameters.rightColor, this.reflectionFresnelParameters.bias)), this.refractionFresnelParameters && this.refractionFresnelParameters.isEnabled && (Y.updateColor4("refractionLeftColor", this.refractionFresnelParameters.leftColor, this.refractionFresnelParameters.power), Y.updateColor4("refractionRightColor", this.refractionFresnelParameters.rightColor, this.refractionFresnelParameters.bias)), this.emissiveFresnelParameters && this.emissiveFresnelParameters.isEnabled && (Y.updateColor4("emissiveLeftColor", this.emissiveFresnelParameters.leftColor, this.emissiveFresnelParameters.power), Y.updateColor4("emissiveRightColor", this.emissiveFresnelParameters.rightColor, this.emissiveFresnelParameters.bias))), G.texturesEnabled) {
+ if (this._diffuseTexture && ee.DiffuseTextureEnabled && (Y.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level), g.a.BindTextureMatrix(this._diffuseTexture, Y, "diffuse")), this._ambientTexture && ee.AmbientTextureEnabled && (Y.updateFloat2("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level), g.a.BindTextureMatrix(this._ambientTexture, Y, "ambient")), this._opacityTexture && ee.OpacityTextureEnabled && (Y.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level), g.a.BindTextureMatrix(this._opacityTexture, Y, "opacity")), this._hasAlphaChannel() && oe.setFloat("alphaCutOff", this.alphaCutOff), this._reflectionTexture && ee.ReflectionTextureEnabled && (Y.updateFloat2("vReflectionInfos", this._reflectionTexture.level, this.roughness), Y.updateMatrix("reflectionMatrix", this._reflectionTexture.getReflectionTextureMatrix()), this._reflectionTexture.boundingBoxSize)) {
+ var k = this._reflectionTexture;
+ Y.updateVector3("vReflectionPosition", k.boundingBoxPosition), Y.updateVector3("vReflectionSize", k.boundingBoxSize);
+ }
+ if (this._emissiveTexture && ee.EmissiveTextureEnabled && (Y.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level), g.a.BindTextureMatrix(this._emissiveTexture, Y, "emissive")), this._lightmapTexture && ee.LightmapTextureEnabled && (Y.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level), g.a.BindTextureMatrix(this._lightmapTexture, Y, "lightmap")), this._specularTexture && ee.SpecularTextureEnabled && (Y.updateFloat2("vSpecularInfos", this._specularTexture.coordinatesIndex, this._specularTexture.level), g.a.BindTextureMatrix(this._specularTexture, Y, "specular")), this._bumpTexture && G.getEngine().getCaps().standardDerivatives && ee.BumpTextureEnabled && (Y.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, 1 / this._bumpTexture.level, this.parallaxScaleBias), g.a.BindTextureMatrix(this._bumpTexture, Y, "bump"), G._mirroredCameraPosition ? Y.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1 : -1, this._invertNormalMapY ? 1 : -1) : Y.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1 : 1, this._invertNormalMapY ? -1 : 1)), this._refractionTexture && ee.RefractionTextureEnabled) {
+ var H = 1;
+ this._refractionTexture.isCube || (Y.updateMatrix("refractionMatrix", this._refractionTexture.getReflectionTextureMatrix()), this._refractionTexture.depth && (H = this._refractionTexture.depth)), Y.updateFloat4("vRefractionInfos", this._refractionTexture.level, this.indexOfRefraction, H, this.invertRefractionY ? -1 : 1);
+ }
+ }
+ this.pointsCloud && Y.updateFloat("pointSize", this.pointSize), Q.SPECULARTERM && Y.updateColor4("vSpecularColor", this.specularColor, this.specularPower), Y.updateColor3("vEmissiveColor", ee.EmissiveTextureEnabled ? this.emissiveColor : O.a.BlackReadOnly), Y.updateColor4("vDiffuseColor", this.diffuseColor, this.alpha);
+ }
+ Y.updateFloat("visibility", $.visibility), G.texturesEnabled && (this._diffuseTexture && ee.DiffuseTextureEnabled && oe.setTexture("diffuseSampler", this._diffuseTexture), this._ambientTexture && ee.AmbientTextureEnabled && oe.setTexture("ambientSampler", this._ambientTexture), this._opacityTexture && ee.OpacityTextureEnabled && oe.setTexture("opacitySampler", this._opacityTexture), this._reflectionTexture && ee.ReflectionTextureEnabled && (this._reflectionTexture.isCube ? oe.setTexture("reflectionCubeSampler", this._reflectionTexture) : oe.setTexture("reflection2DSampler", this._reflectionTexture)), this._emissiveTexture && ee.EmissiveTextureEnabled && oe.setTexture("emissiveSampler", this._emissiveTexture), this._lightmapTexture && ee.LightmapTextureEnabled && oe.setTexture("lightmapSampler", this._lightmapTexture), this._specularTexture && ee.SpecularTextureEnabled && oe.setTexture("specularSampler", this._specularTexture), this._bumpTexture && G.getEngine().getCaps().standardDerivatives && ee.BumpTextureEnabled && oe.setTexture("bumpSampler", this._bumpTexture), this._refractionTexture && ee.RefractionTextureEnabled) && (H = 1, this._refractionTexture.isCube ? oe.setTexture("refractionCubeSampler", this._refractionTexture) : oe.setTexture("refraction2DSampler", this._refractionTexture)), this.detailMap.bindForSubMesh(Y, G, this.isFrozen), g.a.BindClipPlane(oe, G), G.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor), g.a.BindEyePosition(oe, G), oe.setColor3("vAmbientColor", this._globalAmbientColor);
+ }
+ !re && this.isFrozen || (G.lightsEnabled && !this._disableLighting && g.a.BindLights(G, $, oe, Q, this._maxSimultaneousLights, this._rebuildInParallel), (G.fogEnabled && $.applyFog && G.fogMode !== u.a.FOGMODE_NONE || this._reflectionTexture || this._refractionTexture) && this.bindView(oe), g.a.BindFogParameters(G, $, oe), Q.NUM_MORPH_INFLUENCERS && g.a.BindMorphTargetParameters($, oe), this.useLogarithmicDepth && g.a.BindLogDepth(Q, oe, G), this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess && this._imageProcessingConfiguration.bind(this._activeEffect)), Y.update(), this._afterBind($, this._activeEffect);
+ }
+ }
+ }, ee.prototype.getAnimatables = function() {
+ var K = [];
+ return this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0 && K.push(this._diffuseTexture), this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0 && K.push(this._ambientTexture), this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0 && K.push(this._opacityTexture), this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0 && K.push(this._reflectionTexture), this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0 && K.push(this._emissiveTexture), this._specularTexture && this._specularTexture.animations && this._specularTexture.animations.length > 0 && K.push(this._specularTexture), this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0 && K.push(this._bumpTexture), this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0 && K.push(this._lightmapTexture), this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0 && K.push(this._refractionTexture), this.detailMap.getAnimatables(K), K;
+ }, ee.prototype.getActiveTextures = function() {
+ var K = ae.prototype.getActiveTextures.call(this);
+ return this._diffuseTexture && K.push(this._diffuseTexture), this._ambientTexture && K.push(this._ambientTexture), this._opacityTexture && K.push(this._opacityTexture), this._reflectionTexture && K.push(this._reflectionTexture), this._emissiveTexture && K.push(this._emissiveTexture), this._specularTexture && K.push(this._specularTexture), this._bumpTexture && K.push(this._bumpTexture), this._lightmapTexture && K.push(this._lightmapTexture), this._refractionTexture && K.push(this._refractionTexture), this.detailMap.getActiveTextures(K), K;
+ }, ee.prototype.hasTexture = function(K) {
+ return !!ae.prototype.hasTexture.call(this, K) || this._diffuseTexture === K || this._ambientTexture === K || this._opacityTexture === K || this._reflectionTexture === K || this._emissiveTexture === K || this._specularTexture === K || this._bumpTexture === K || this._lightmapTexture === K || this._refractionTexture === K || this.detailMap.hasTexture(K);
+ }, ee.prototype.dispose = function(K, $) {
+ var L, G, Q, oe, re, Y, k, H, Z;
+ $ && ((L = this._diffuseTexture) === null || L === void 0 || L.dispose(), (G = this._ambientTexture) === null || G === void 0 || G.dispose(), (Q = this._opacityTexture) === null || Q === void 0 || Q.dispose(), (oe = this._reflectionTexture) === null || oe === void 0 || oe.dispose(), (re = this._emissiveTexture) === null || re === void 0 || re.dispose(), (Y = this._specularTexture) === null || Y === void 0 || Y.dispose(), (k = this._bumpTexture) === null || k === void 0 || k.dispose(), (H = this._lightmapTexture) === null || H === void 0 || H.dispose(), (Z = this._refractionTexture) === null || Z === void 0 || Z.dispose()), this.detailMap.dispose($), this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver), ae.prototype.dispose.call(this, K, $);
+ }, ee.prototype.clone = function(K) {
+ var $ = this, L = _.a.Clone(function() {
+ return new ee(K, $.getScene());
+ }, this);
+ return L.name = K, L.id = K, L;
+ }, ee.prototype.serialize = function() {
+ return _.a.Serialize(this);
+ }, ee.Parse = function(K, $, L) {
+ return _.a.Parse(function() {
+ return new ee(K.name, $);
+ }, K, $, L);
+ }, Object.defineProperty(ee, "DiffuseTextureEnabled", { get: function() {
+ return v.a.DiffuseTextureEnabled;
+ }, set: function(K) {
+ v.a.DiffuseTextureEnabled = K;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(ee, "DetailTextureEnabled", { get: function() {
+ return v.a.DetailTextureEnabled;
+ }, set: function(K) {
+ v.a.DetailTextureEnabled = K;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(ee, "AmbientTextureEnabled", { get: function() {
+ return v.a.AmbientTextureEnabled;
+ }, set: function(K) {
+ v.a.AmbientTextureEnabled = K;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(ee, "OpacityTextureEnabled", { get: function() {
+ return v.a.OpacityTextureEnabled;
+ }, set: function(K) {
+ v.a.OpacityTextureEnabled = K;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(ee, "ReflectionTextureEnabled", { get: function() {
+ return v.a.ReflectionTextureEnabled;
+ }, set: function(K) {
+ v.a.ReflectionTextureEnabled = K;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(ee, "EmissiveTextureEnabled", { get: function() {
+ return v.a.EmissiveTextureEnabled;
+ }, set: function(K) {
+ v.a.EmissiveTextureEnabled = K;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(ee, "SpecularTextureEnabled", { get: function() {
+ return v.a.SpecularTextureEnabled;
+ }, set: function(K) {
+ v.a.SpecularTextureEnabled = K;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(ee, "BumpTextureEnabled", { get: function() {
+ return v.a.BumpTextureEnabled;
+ }, set: function(K) {
+ v.a.BumpTextureEnabled = K;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(ee, "LightmapTextureEnabled", { get: function() {
+ return v.a.LightmapTextureEnabled;
+ }, set: function(K) {
+ v.a.LightmapTextureEnabled = K;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(ee, "RefractionTextureEnabled", { get: function() {
+ return v.a.RefractionTextureEnabled;
+ }, set: function(K) {
+ v.a.RefractionTextureEnabled = K;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(ee, "ColorGradingTextureEnabled", { get: function() {
+ return v.a.ColorGradingTextureEnabled;
+ }, set: function(K) {
+ v.a.ColorGradingTextureEnabled = K;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(ee, "FresnelEnabled", { get: function() {
+ return v.a.FresnelEnabled;
+ }, set: function(K) {
+ v.a.FresnelEnabled = K;
+ }, enumerable: !1, configurable: !0 }), Object(V.c)([Object(_.m)("diffuseTexture")], ee.prototype, "_diffuseTexture", void 0), Object(V.c)([Object(_.b)("_markAllSubMeshesAsTexturesAndMiscDirty")], ee.prototype, "diffuseTexture", void 0), Object(V.c)([Object(_.m)("ambientTexture")], ee.prototype, "_ambientTexture", void 0), Object(V.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")], ee.prototype, "ambientTexture", void 0), Object(V.c)([Object(_.m)("opacityTexture")], ee.prototype, "_opacityTexture", void 0), Object(V.c)([Object(_.b)("_markAllSubMeshesAsTexturesAndMiscDirty")], ee.prototype, "opacityTexture", void 0), Object(V.c)([Object(_.m)("reflectionTexture")], ee.prototype, "_reflectionTexture", void 0), Object(V.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")], ee.prototype, "reflectionTexture", void 0), Object(V.c)([Object(_.m)("emissiveTexture")], ee.prototype, "_emissiveTexture", void 0), Object(V.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")], ee.prototype, "emissiveTexture", void 0), Object(V.c)([Object(_.m)("specularTexture")], ee.prototype, "_specularTexture", void 0), Object(V.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")], ee.prototype, "specularTexture", void 0), Object(V.c)([Object(_.m)("bumpTexture")], ee.prototype, "_bumpTexture", void 0), Object(V.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")], ee.prototype, "bumpTexture", void 0), Object(V.c)([Object(_.m)("lightmapTexture")], ee.prototype, "_lightmapTexture", void 0), Object(V.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")], ee.prototype, "lightmapTexture", void 0), Object(V.c)([Object(_.m)("refractionTexture")], ee.prototype, "_refractionTexture", void 0), Object(V.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")], ee.prototype, "refractionTexture", void 0), Object(V.c)([Object(_.e)("ambient")], ee.prototype, "ambientColor", void 0), Object(V.c)([Object(_.e)("diffuse")], ee.prototype, "diffuseColor", void 0), Object(V.c)([Object(_.e)("specular")], ee.prototype, "specularColor", void 0), Object(V.c)([Object(_.e)("emissive")], ee.prototype, "emissiveColor", void 0), Object(V.c)([Object(_.c)()], ee.prototype, "specularPower", void 0), Object(V.c)([Object(_.c)("useAlphaFromDiffuseTexture")], ee.prototype, "_useAlphaFromDiffuseTexture", void 0), Object(V.c)([Object(_.b)("_markAllSubMeshesAsTexturesAndMiscDirty")], ee.prototype, "useAlphaFromDiffuseTexture", void 0), Object(V.c)([Object(_.c)("useEmissiveAsIllumination")], ee.prototype, "_useEmissiveAsIllumination", void 0), Object(V.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")], ee.prototype, "useEmissiveAsIllumination", void 0), Object(V.c)([Object(_.c)("linkEmissiveWithDiffuse")], ee.prototype, "_linkEmissiveWithDiffuse", void 0), Object(V.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")], ee.prototype, "linkEmissiveWithDiffuse", void 0), Object(V.c)([Object(_.c)("useSpecularOverAlpha")], ee.prototype, "_useSpecularOverAlpha", void 0), Object(V.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")], ee.prototype, "useSpecularOverAlpha", void 0), Object(V.c)([Object(_.c)("useReflectionOverAlpha")], ee.prototype, "_useReflectionOverAlpha", void 0), Object(V.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")], ee.prototype, "useReflectionOverAlpha", void 0), Object(V.c)([Object(_.c)("disableLighting")], ee.prototype, "_disableLighting", void 0), Object(V.c)([Object(_.b)("_markAllSubMeshesAsLightsDirty")], ee.prototype, "disableLighting", void 0), Object(V.c)([Object(_.c)("useObjectSpaceNormalMap")], ee.prototype, "_useObjectSpaceNormalMap", void 0), Object(V.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")], ee.prototype, "useObjectSpaceNormalMap", void 0), Object(V.c)([Object(_.c)("useParallax")], ee.prototype, "_useParallax", void 0), Object(V.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")], ee.prototype, "useParallax", void 0), Object(V.c)([Object(_.c)("useParallaxOcclusion")], ee.prototype, "_useParallaxOcclusion", void 0), Object(V.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")], ee.prototype, "useParallaxOcclusion", void 0), Object(V.c)([Object(_.c)()], ee.prototype, "parallaxScaleBias", void 0), Object(V.c)([Object(_.c)("roughness")], ee.prototype, "_roughness", void 0), Object(V.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")], ee.prototype, "roughness", void 0), Object(V.c)([Object(_.c)()], ee.prototype, "indexOfRefraction", void 0), Object(V.c)([Object(_.c)()], ee.prototype, "invertRefractionY", void 0), Object(V.c)([Object(_.c)()], ee.prototype, "alphaCutOff", void 0), Object(V.c)([Object(_.c)("useLightmapAsShadowmap")], ee.prototype, "_useLightmapAsShadowmap", void 0), Object(V.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")], ee.prototype, "useLightmapAsShadowmap", void 0), Object(V.c)([Object(_.h)("diffuseFresnelParameters")], ee.prototype, "_diffuseFresnelParameters", void 0), Object(V.c)([Object(_.b)("_markAllSubMeshesAsFresnelDirty")], ee.prototype, "diffuseFresnelParameters", void 0), Object(V.c)([Object(_.h)("opacityFresnelParameters")], ee.prototype, "_opacityFresnelParameters", void 0), Object(V.c)([Object(_.b)("_markAllSubMeshesAsFresnelAndMiscDirty")], ee.prototype, "opacityFresnelParameters", void 0), Object(V.c)([Object(_.h)("reflectionFresnelParameters")], ee.prototype, "_reflectionFresnelParameters", void 0), Object(V.c)([Object(_.b)("_markAllSubMeshesAsFresnelDirty")], ee.prototype, "reflectionFresnelParameters", void 0), Object(V.c)([Object(_.h)("refractionFresnelParameters")], ee.prototype, "_refractionFresnelParameters", void 0), Object(V.c)([Object(_.b)("_markAllSubMeshesAsFresnelDirty")], ee.prototype, "refractionFresnelParameters", void 0), Object(V.c)([Object(_.h)("emissiveFresnelParameters")], ee.prototype, "_emissiveFresnelParameters", void 0), Object(V.c)([Object(_.b)("_markAllSubMeshesAsFresnelDirty")], ee.prototype, "emissiveFresnelParameters", void 0), Object(V.c)([Object(_.c)("useReflectionFresnelFromSpecular")], ee.prototype, "_useReflectionFresnelFromSpecular", void 0), Object(V.c)([Object(_.b)("_markAllSubMeshesAsFresnelDirty")], ee.prototype, "useReflectionFresnelFromSpecular", void 0), Object(V.c)([Object(_.c)("useGlossinessFromSpecularMapAlpha")], ee.prototype, "_useGlossinessFromSpecularMapAlpha", void 0), Object(V.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")], ee.prototype, "useGlossinessFromSpecularMapAlpha", void 0), Object(V.c)([Object(_.c)("maxSimultaneousLights")], ee.prototype, "_maxSimultaneousLights", void 0), Object(V.c)([Object(_.b)("_markAllSubMeshesAsLightsDirty")], ee.prototype, "maxSimultaneousLights", void 0), Object(V.c)([Object(_.c)("invertNormalMapX")], ee.prototype, "_invertNormalMapX", void 0), Object(V.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")], ee.prototype, "invertNormalMapX", void 0), Object(V.c)([Object(_.c)("invertNormalMapY")], ee.prototype, "_invertNormalMapY", void 0), Object(V.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")], ee.prototype, "invertNormalMapY", void 0), Object(V.c)([Object(_.c)("twoSidedLighting")], ee.prototype, "_twoSidedLighting", void 0), Object(V.c)([Object(_.b)("_markAllSubMeshesAsTexturesDirty")], ee.prototype, "twoSidedLighting", void 0), Object(V.c)([Object(_.c)()], ee.prototype, "useLogarithmicDepth", null), ee;
+ }(E.a);
+ h.a.RegisteredTypes["BABYLON.StandardMaterial"] = pe, u.a.DefaultMaterialFactory = function(ae) {
+ return new pe("default material", ae);
+ };
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return M;
+ });
+ var V = f(1), _ = f(12), C = f(6), u = f(0), I = f(13), O = f(4), x = f(16), m = f(46), c = f(54), T = f(43), S = f(2), E = f(147), g = f(21), l = f(101), h = f(9), v = f(28), b = f(23), D = f(11), w = function() {
+ this.facetNb = 0, this.partitioningSubdivisions = 10, this.partitioningBBoxRatio = 1.01, this.facetDataEnabled = !1, this.facetParameters = {}, this.bbSize = u.e.Zero(), this.subDiv = { max: 1, X: 1, Y: 1, Z: 1 }, this.facetDepthSort = !1, this.facetDepthSortEnabled = !1;
+ }, N = function() {
+ this._hasVertexAlpha = !1, this._useVertexColors = !0, this._numBoneInfluencers = 4, this._applyFog = !0, this._receiveShadows = !1, this._facetData = new w(), this._visibility = 1, this._skeleton = null, this._layerMask = 268435455, this._computeBonesUsingShaders = !0, this._isActive = !1, this._onlyForInstances = !1, this._isActiveIntermediate = !1, this._onlyForInstancesIntermediate = !1, this._actAsRegularMesh = !1, this._currentLOD = null, this._currentLODIsUpToDate = !1;
+ }, M = function(U) {
+ function X(j, ne) {
+ ne === void 0 && (ne = null);
+ var te = U.call(this, j, ne, !1) || this;
+ return te._internalAbstractMeshDataInfo = new N(), te.cullingStrategy = X.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY, te.onCollideObservable = new C.c(), te.onCollisionPositionChangeObservable = new C.c(), te.onMaterialChangedObservable = new C.c(), te.definedFacingForward = !0, te._occlusionQuery = null, te._renderingGroup = null, te.alphaIndex = Number.MAX_VALUE, te.isVisible = !0, te.isPickable = !0, te.showSubMeshesBoundingBox = !1, te.isBlocker = !1, te.enablePointerMoveEvents = !1, te._renderingGroupId = 0, te._material = null, te.outlineColor = h.a.Red(), te.outlineWidth = 0.02, te.overlayColor = h.a.Red(), te.overlayAlpha = 0.5, te.useOctreeForRenderingSelection = !0, te.useOctreeForPicking = !0, te.useOctreeForCollisions = !0, te.alwaysSelectAsActiveMesh = !1, te.doNotSyncBoundingInfo = !1, te.actionManager = null, te._meshCollisionData = new E.a(), te.ellipsoid = new u.e(0.5, 1, 0.5), te.ellipsoidOffset = new u.e(0, 0, 0), te.edgesWidth = 1, te.edgesColor = new h.b(1, 0, 0, 1), te._edgesRenderer = null, te._masterMesh = null, te._boundingInfo = null, te._renderId = 0, te._intersectionsInProgress = new Array(), te._unIndexed = !1, te._lightSources = new Array(), te._waitingData = { lods: null, actions: null, freezeWorldMatrix: null }, te._bonesTransformMatrices = null, te._transformMatrixTexture = null, te.onRebuildObservable = new C.c(), te._onCollisionPositionChange = function(de, pe, ae) {
+ ae === void 0 && (ae = null), pe.subtractToRef(te._meshCollisionData._oldPositionForCollisions, te._meshCollisionData._diffPositionForCollisions), te._meshCollisionData._diffPositionForCollisions.length() > I.a.CollisionsEpsilon && te.position.addInPlace(te._meshCollisionData._diffPositionForCollisions), ae && te.onCollideObservable.notifyObservers(ae), te.onCollisionPositionChangeObservable.notifyObservers(te.position);
+ }, te.getScene().addMesh(te), te._resyncLightSources(), te;
+ }
+ return Object(V.d)(X, U), Object.defineProperty(X, "BILLBOARDMODE_NONE", { get: function() {
+ return m.a.BILLBOARDMODE_NONE;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(X, "BILLBOARDMODE_X", { get: function() {
+ return m.a.BILLBOARDMODE_X;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(X, "BILLBOARDMODE_Y", { get: function() {
+ return m.a.BILLBOARDMODE_Y;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(X, "BILLBOARDMODE_Z", { get: function() {
+ return m.a.BILLBOARDMODE_Z;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(X, "BILLBOARDMODE_ALL", { get: function() {
+ return m.a.BILLBOARDMODE_ALL;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(X, "BILLBOARDMODE_USE_POSITION", { get: function() {
+ return m.a.BILLBOARDMODE_USE_POSITION;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(X.prototype, "facetNb", { get: function() {
+ return this._internalAbstractMeshDataInfo._facetData.facetNb;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(X.prototype, "partitioningSubdivisions", { get: function() {
+ return this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions;
+ }, set: function(j) {
+ this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions = j;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(X.prototype, "partitioningBBoxRatio", { get: function() {
+ return this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio;
+ }, set: function(j) {
+ this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio = j;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(X.prototype, "mustDepthSortFacets", { get: function() {
+ return this._internalAbstractMeshDataInfo._facetData.facetDepthSort;
+ }, set: function(j) {
+ this._internalAbstractMeshDataInfo._facetData.facetDepthSort = j;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(X.prototype, "facetDepthSortFrom", { get: function() {
+ return this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom;
+ }, set: function(j) {
+ this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom = j;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(X.prototype, "isFacetDataEnabled", { get: function() {
+ return this._internalAbstractMeshDataInfo._facetData.facetDataEnabled;
+ }, enumerable: !1, configurable: !0 }), X.prototype._updateNonUniformScalingState = function(j) {
+ return !!U.prototype._updateNonUniformScalingState.call(this, j) && (this._markSubMeshesAsMiscDirty(), !0);
+ }, Object.defineProperty(X.prototype, "onCollide", { set: function(j) {
+ this._meshCollisionData._onCollideObserver && this.onCollideObservable.remove(this._meshCollisionData._onCollideObserver), this._meshCollisionData._onCollideObserver = this.onCollideObservable.add(j);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(X.prototype, "onCollisionPositionChange", { set: function(j) {
+ this._meshCollisionData._onCollisionPositionChangeObserver && this.onCollisionPositionChangeObservable.remove(this._meshCollisionData._onCollisionPositionChangeObserver), this._meshCollisionData._onCollisionPositionChangeObserver = this.onCollisionPositionChangeObservable.add(j);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(X.prototype, "visibility", { get: function() {
+ return this._internalAbstractMeshDataInfo._visibility;
+ }, set: function(j) {
+ this._internalAbstractMeshDataInfo._visibility !== j && (this._internalAbstractMeshDataInfo._visibility = j, this._markSubMeshesAsMiscDirty());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(X.prototype, "renderingGroupId", { get: function() {
+ return this._renderingGroupId;
+ }, set: function(j) {
+ this._renderingGroupId = j;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(X.prototype, "material", { get: function() {
+ return this._material;
+ }, set: function(j) {
+ this._material !== j && (this._material && this._material.meshMap && (this._material.meshMap[this.uniqueId] = void 0), this._material = j, j && j.meshMap && (j.meshMap[this.uniqueId] = this), this.onMaterialChangedObservable.hasObservers() && this.onMaterialChangedObservable.notifyObservers(this), this.subMeshes && this._unBindEffect());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(X.prototype, "receiveShadows", { get: function() {
+ return this._internalAbstractMeshDataInfo._receiveShadows;
+ }, set: function(j) {
+ this._internalAbstractMeshDataInfo._receiveShadows !== j && (this._internalAbstractMeshDataInfo._receiveShadows = j, this._markSubMeshesAsLightDirty());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(X.prototype, "hasVertexAlpha", { get: function() {
+ return this._internalAbstractMeshDataInfo._hasVertexAlpha;
+ }, set: function(j) {
+ this._internalAbstractMeshDataInfo._hasVertexAlpha !== j && (this._internalAbstractMeshDataInfo._hasVertexAlpha = j, this._markSubMeshesAsAttributesDirty(), this._markSubMeshesAsMiscDirty());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(X.prototype, "useVertexColors", { get: function() {
+ return this._internalAbstractMeshDataInfo._useVertexColors;
+ }, set: function(j) {
+ this._internalAbstractMeshDataInfo._useVertexColors !== j && (this._internalAbstractMeshDataInfo._useVertexColors = j, this._markSubMeshesAsAttributesDirty());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(X.prototype, "computeBonesUsingShaders", { get: function() {
+ return this._internalAbstractMeshDataInfo._computeBonesUsingShaders;
+ }, set: function(j) {
+ this._internalAbstractMeshDataInfo._computeBonesUsingShaders !== j && (this._internalAbstractMeshDataInfo._computeBonesUsingShaders = j, this._markSubMeshesAsAttributesDirty());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(X.prototype, "numBoneInfluencers", { get: function() {
+ return this._internalAbstractMeshDataInfo._numBoneInfluencers;
+ }, set: function(j) {
+ this._internalAbstractMeshDataInfo._numBoneInfluencers !== j && (this._internalAbstractMeshDataInfo._numBoneInfluencers = j, this._markSubMeshesAsAttributesDirty());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(X.prototype, "applyFog", { get: function() {
+ return this._internalAbstractMeshDataInfo._applyFog;
+ }, set: function(j) {
+ this._internalAbstractMeshDataInfo._applyFog !== j && (this._internalAbstractMeshDataInfo._applyFog = j, this._markSubMeshesAsMiscDirty());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(X.prototype, "layerMask", { get: function() {
+ return this._internalAbstractMeshDataInfo._layerMask;
+ }, set: function(j) {
+ j !== this._internalAbstractMeshDataInfo._layerMask && (this._internalAbstractMeshDataInfo._layerMask = j, this._resyncLightSources());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(X.prototype, "collisionMask", { get: function() {
+ return this._meshCollisionData._collisionMask;
+ }, set: function(j) {
+ this._meshCollisionData._collisionMask = isNaN(j) ? -1 : j;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(X.prototype, "collisionResponse", { get: function() {
+ return this._meshCollisionData._collisionResponse;
+ }, set: function(j) {
+ this._meshCollisionData._collisionResponse = j;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(X.prototype, "collisionGroup", { get: function() {
+ return this._meshCollisionData._collisionGroup;
+ }, set: function(j) {
+ this._meshCollisionData._collisionGroup = isNaN(j) ? -1 : j;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(X.prototype, "surroundingMeshes", { get: function() {
+ return this._meshCollisionData._surroundingMeshes;
+ }, set: function(j) {
+ this._meshCollisionData._surroundingMeshes = j;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(X.prototype, "lightSources", { get: function() {
+ return this._lightSources;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(X.prototype, "_positions", { get: function() {
+ return null;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(X.prototype, "skeleton", { get: function() {
+ return this._internalAbstractMeshDataInfo._skeleton;
+ }, set: function(j) {
+ var ne = this._internalAbstractMeshDataInfo._skeleton;
+ ne && ne.needInitialSkinMatrix && ne._unregisterMeshWithPoseMatrix(this), j && j.needInitialSkinMatrix && j._registerMeshWithPoseMatrix(this), this._internalAbstractMeshDataInfo._skeleton = j, this._internalAbstractMeshDataInfo._skeleton || (this._bonesTransformMatrices = null), this._markSubMeshesAsAttributesDirty();
+ }, enumerable: !1, configurable: !0 }), X.prototype.getClassName = function() {
+ return "AbstractMesh";
+ }, X.prototype.toString = function(j) {
+ var ne = "Name: " + this.name + ", isInstance: " + (this.getClassName() !== "InstancedMesh" ? "YES" : "NO");
+ ne += ", # of submeshes: " + (this.subMeshes ? this.subMeshes.length : 0);
+ var te = this._internalAbstractMeshDataInfo._skeleton;
+ return te && (ne += ", skeleton: " + te.name), j && (ne += ", billboard mode: " + ["NONE", "X", "Y", null, "Z", null, null, "ALL"][this.billboardMode], ne += ", freeze wrld mat: " + (this._isWorldMatrixFrozen || this._waitingData.freezeWorldMatrix ? "YES" : "NO")), ne;
+ }, X.prototype._getEffectiveParent = function() {
+ return this._masterMesh && this.billboardMode !== m.a.BILLBOARDMODE_NONE ? this._masterMesh : U.prototype._getEffectiveParent.call(this);
+ }, X.prototype._getActionManagerForTrigger = function(j, ne) {
+ if (ne === void 0 && (ne = !0), this.actionManager && (ne || this.actionManager.isRecursive)) {
+ if (!j)
+ return this.actionManager;
+ if (this.actionManager.hasSpecificTrigger(j))
+ return this.actionManager;
+ }
+ return this.parent ? this.parent._getActionManagerForTrigger(j, !1) : null;
+ }, X.prototype._rebuild = function() {
+ if (this.onRebuildObservable.notifyObservers(this), this._occlusionQuery && (this._occlusionQuery = null), this.subMeshes)
+ for (var j = 0, ne = this.subMeshes; j < ne.length; j++)
+ ne[j]._rebuild();
+ }, X.prototype._resyncLightSources = function() {
+ this._lightSources.length = 0;
+ for (var j = 0, ne = this.getScene().lights; j < ne.length; j++) {
+ var te = ne[j];
+ te.isEnabled() && te.canAffectMesh(this) && this._lightSources.push(te);
+ }
+ this._markSubMeshesAsLightDirty();
+ }, X.prototype._resyncLightSource = function(j) {
+ var ne = j.isEnabled() && j.canAffectMesh(this), te = this._lightSources.indexOf(j), de = !1;
+ if (te === -1) {
+ if (!ne)
+ return;
+ this._lightSources.push(j);
+ } else {
+ if (ne)
+ return;
+ de = !0, this._lightSources.splice(te, 1);
+ }
+ this._markSubMeshesAsLightDirty(de);
+ }, X.prototype._unBindEffect = function() {
+ for (var j = 0, ne = this.subMeshes; j < ne.length; j++)
+ ne[j].setEffect(null);
+ }, X.prototype._removeLightSource = function(j, ne) {
+ var te = this._lightSources.indexOf(j);
+ te !== -1 && (this._lightSources.splice(te, 1), this._markSubMeshesAsLightDirty(ne));
+ }, X.prototype._markSubMeshesAsDirty = function(j) {
+ if (this.subMeshes)
+ for (var ne = 0, te = this.subMeshes; ne < te.length; ne++) {
+ var de = te[ne];
+ de._materialDefines && j(de._materialDefines);
+ }
+ }, X.prototype._markSubMeshesAsLightDirty = function(j) {
+ j === void 0 && (j = !1), this._markSubMeshesAsDirty(function(ne) {
+ return ne.markAsLightDirty(j);
+ });
+ }, X.prototype._markSubMeshesAsAttributesDirty = function() {
+ this._markSubMeshesAsDirty(function(j) {
+ return j.markAsAttributesDirty();
+ });
+ }, X.prototype._markSubMeshesAsMiscDirty = function() {
+ this._markSubMeshesAsDirty(function(j) {
+ return j.markAsMiscDirty();
+ });
+ }, Object.defineProperty(X.prototype, "scaling", { get: function() {
+ return this._scaling;
+ }, set: function(j) {
+ this._scaling = j;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(X.prototype, "isBlocked", { get: function() {
+ return !1;
+ }, enumerable: !1, configurable: !0 }), X.prototype.getLOD = function(j) {
+ return this;
+ }, X.prototype.getTotalVertices = function() {
+ return 0;
+ }, X.prototype.getTotalIndices = function() {
+ return 0;
+ }, X.prototype.getIndices = function() {
+ return null;
+ }, X.prototype.getVerticesData = function(j) {
+ return null;
+ }, X.prototype.setVerticesData = function(j, ne, te, de) {
+ return this;
+ }, X.prototype.updateVerticesData = function(j, ne, te, de) {
+ return this;
+ }, X.prototype.setIndices = function(j, ne) {
+ return this;
+ }, X.prototype.isVerticesDataPresent = function(j) {
+ return !1;
+ }, X.prototype.getBoundingInfo = function() {
+ return this._masterMesh ? this._masterMesh.getBoundingInfo() : (this._boundingInfo || this._updateBoundingInfo(), this._boundingInfo);
+ }, X.prototype.normalizeToUnitCube = function(j, ne, te) {
+ return j === void 0 && (j = !0), ne === void 0 && (ne = !1), U.prototype.normalizeToUnitCube.call(this, j, ne, te);
+ }, X.prototype.setBoundingInfo = function(j) {
+ return this._boundingInfo = j, this;
+ }, Object.defineProperty(X.prototype, "useBones", { get: function() {
+ return this.skeleton && this.getScene().skeletonsEnabled && this.isVerticesDataPresent(O.b.MatricesIndicesKind) && this.isVerticesDataPresent(O.b.MatricesWeightsKind);
+ }, enumerable: !1, configurable: !0 }), X.prototype._preActivate = function() {
+ }, X.prototype._preActivateForIntermediateRendering = function(j) {
+ }, X.prototype._activate = function(j, ne) {
+ return this._renderId = j, !0;
+ }, X.prototype._postActivate = function() {
+ }, X.prototype._freeze = function() {
+ }, X.prototype._unFreeze = function() {
+ }, X.prototype.getWorldMatrix = function() {
+ return this._masterMesh && this.billboardMode === m.a.BILLBOARDMODE_NONE ? this._masterMesh.getWorldMatrix() : U.prototype.getWorldMatrix.call(this);
+ }, X.prototype._getWorldMatrixDeterminant = function() {
+ return this._masterMesh ? this._masterMesh._getWorldMatrixDeterminant() : U.prototype._getWorldMatrixDeterminant.call(this);
+ }, Object.defineProperty(X.prototype, "isAnInstance", { get: function() {
+ return !1;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(X.prototype, "hasInstances", { get: function() {
+ return !1;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(X.prototype, "hasThinInstances", { get: function() {
+ return !1;
+ }, enumerable: !1, configurable: !0 }), X.prototype.movePOV = function(j, ne, te) {
+ return this.position.addInPlace(this.calcMovePOV(j, ne, te)), this;
+ }, X.prototype.calcMovePOV = function(j, ne, te) {
+ var de = new u.a();
+ (this.rotationQuaternion ? this.rotationQuaternion : u.b.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z)).toRotationMatrix(de);
+ var pe = u.e.Zero(), ae = this.definedFacingForward ? -1 : 1;
+ return u.e.TransformCoordinatesFromFloatsToRef(j * ae, ne, te * ae, de, pe), pe;
+ }, X.prototype.rotatePOV = function(j, ne, te) {
+ return this.rotation.addInPlace(this.calcRotatePOV(j, ne, te)), this;
+ }, X.prototype.calcRotatePOV = function(j, ne, te) {
+ var de = this.definedFacingForward ? 1 : -1;
+ return new u.e(j * de, ne, te * de);
+ }, X.prototype.refreshBoundingInfo = function(j) {
+ return j === void 0 && (j = !1), this._boundingInfo && this._boundingInfo.isLocked || this._refreshBoundingInfo(this._getPositionData(j), null), this;
+ }, X.prototype._refreshBoundingInfo = function(j, ne) {
+ if (j) {
+ var te = Object(l.a)(j, 0, this.getTotalVertices(), ne);
+ this._boundingInfo ? this._boundingInfo.reConstruct(te.minimum, te.maximum) : this._boundingInfo = new T.a(te.minimum, te.maximum);
+ }
+ if (this.subMeshes)
+ for (var de = 0; de < this.subMeshes.length; de++)
+ this.subMeshes[de].refreshBoundingInfo(j);
+ this._updateBoundingInfo();
+ }, X.prototype._getPositionData = function(j) {
+ var ne = this.getVerticesData(O.b.PositionKind);
+ if (ne && j && this.skeleton) {
+ ne = _.b.Slice(ne), this._generatePointsArray();
+ var te = this.getVerticesData(O.b.MatricesIndicesKind), de = this.getVerticesData(O.b.MatricesWeightsKind);
+ if (de && te) {
+ var pe = this.numBoneInfluencers > 4, ae = pe ? this.getVerticesData(O.b.MatricesIndicesExtraKind) : null, ee = pe ? this.getVerticesData(O.b.MatricesWeightsExtraKind) : null;
+ this.skeleton.prepare();
+ for (var K = this.skeleton.getTransformMatrices(this), $ = u.c.Vector3[0], L = u.c.Matrix[0], G = u.c.Matrix[1], Q = 0, oe = 0; oe < ne.length; oe += 3, Q += 4) {
+ var re, Y;
+ for (L.reset(), re = 0; re < 4; re++)
+ (Y = de[Q + re]) > 0 && (u.a.FromFloat32ArrayToRefScaled(K, Math.floor(16 * te[Q + re]), Y, G), L.addToSelf(G));
+ if (pe)
+ for (re = 0; re < 4; re++)
+ (Y = ee[Q + re]) > 0 && (u.a.FromFloat32ArrayToRefScaled(K, Math.floor(16 * ae[Q + re]), Y, G), L.addToSelf(G));
+ u.e.TransformCoordinatesFromFloatsToRef(ne[oe], ne[oe + 1], ne[oe + 2], L, $), $.toArray(ne, oe), this._positions && this._positions[oe / 3].copyFrom($);
+ }
+ }
+ }
+ return ne;
+ }, X.prototype._updateBoundingInfo = function() {
+ var j = this._effectiveMesh;
+ return this._boundingInfo ? this._boundingInfo.update(j.worldMatrixFromCache) : this._boundingInfo = new T.a(this.absolutePosition, this.absolutePosition, j.worldMatrixFromCache), this._updateSubMeshesBoundingInfo(j.worldMatrixFromCache), this;
+ }, X.prototype._updateSubMeshesBoundingInfo = function(j) {
+ if (!this.subMeshes)
+ return this;
+ for (var ne = this.subMeshes.length, te = 0; te < ne; te++) {
+ var de = this.subMeshes[te];
+ (ne > 1 || !de.IsGlobal) && de.updateBoundingInfo(j);
+ }
+ return this;
+ }, X.prototype._afterComputeWorldMatrix = function() {
+ this.doNotSyncBoundingInfo || this._updateBoundingInfo();
+ }, Object.defineProperty(X.prototype, "_effectiveMesh", { get: function() {
+ return this.skeleton && this.skeleton.overrideMesh || this;
+ }, enumerable: !1, configurable: !0 }), X.prototype.isInFrustum = function(j) {
+ return this._boundingInfo !== null && this._boundingInfo.isInFrustum(j, this.cullingStrategy);
+ }, X.prototype.isCompletelyInFrustum = function(j) {
+ return this._boundingInfo !== null && this._boundingInfo.isCompletelyInFrustum(j);
+ }, X.prototype.intersectsMesh = function(j, ne, te) {
+ if (ne === void 0 && (ne = !1), !this._boundingInfo || !j._boundingInfo)
+ return !1;
+ if (this._boundingInfo.intersects(j._boundingInfo, ne))
+ return !0;
+ if (te) {
+ for (var de = 0, pe = this.getChildMeshes(); de < pe.length; de++)
+ if (pe[de].intersectsMesh(j, ne, !0))
+ return !0;
+ }
+ return !1;
+ }, X.prototype.intersectsPoint = function(j) {
+ return !!this._boundingInfo && this._boundingInfo.intersectsPoint(j);
+ }, Object.defineProperty(X.prototype, "checkCollisions", { get: function() {
+ return this._meshCollisionData._checkCollisions;
+ }, set: function(j) {
+ this._meshCollisionData._checkCollisions = j;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(X.prototype, "collider", { get: function() {
+ return this._meshCollisionData._collider;
+ }, enumerable: !1, configurable: !0 }), X.prototype.moveWithCollisions = function(j) {
+ this.getAbsolutePosition().addToRef(this.ellipsoidOffset, this._meshCollisionData._oldPositionForCollisions);
+ var ne = this.getScene().collisionCoordinator;
+ return this._meshCollisionData._collider || (this._meshCollisionData._collider = ne.createCollider()), this._meshCollisionData._collider._radius = this.ellipsoid, ne.getNewPosition(this._meshCollisionData._oldPositionForCollisions, j, this._meshCollisionData._collider, 3, this, this._onCollisionPositionChange, this.uniqueId), this;
+ }, X.prototype._collideForSubMesh = function(j, ne, te) {
+ if (this._generatePointsArray(), !this._positions)
+ return this;
+ if (!j._lastColliderWorldVertices || !j._lastColliderTransformMatrix.equals(ne)) {
+ j._lastColliderTransformMatrix = ne.clone(), j._lastColliderWorldVertices = [], j._trianglePlanes = [];
+ for (var de = j.verticesStart, pe = j.verticesStart + j.verticesCount, ae = de; ae < pe; ae++)
+ j._lastColliderWorldVertices.push(u.e.TransformCoordinates(this._positions[ae], ne));
+ }
+ return te._collide(j._trianglePlanes, j._lastColliderWorldVertices, this.getIndices(), j.indexStart, j.indexStart + j.indexCount, j.verticesStart, !!j.getMaterial(), this), this;
+ }, X.prototype._processCollisionsForSubMeshes = function(j, ne) {
+ for (var te = this._scene.getCollidingSubMeshCandidates(this, j), de = te.length, pe = 0; pe < de; pe++) {
+ var ae = te.data[pe];
+ de > 1 && !ae._checkCollision(j) || this._collideForSubMesh(ae, ne, j);
+ }
+ return this;
+ }, X.prototype._checkCollision = function(j) {
+ if (!this._boundingInfo || !this._boundingInfo._checkCollision(j))
+ return this;
+ var ne = u.c.Matrix[0], te = u.c.Matrix[1];
+ return u.a.ScalingToRef(1 / j._radius.x, 1 / j._radius.y, 1 / j._radius.z, ne), this.worldMatrixFromCache.multiplyToRef(ne, te), this._processCollisionsForSubMeshes(j, te), this;
+ }, X.prototype._generatePointsArray = function() {
+ return !1;
+ }, X.prototype.intersects = function(j, ne, te, de, pe, ae) {
+ var ee;
+ de === void 0 && (de = !1), ae === void 0 && (ae = !1);
+ var K = new c.a(), $ = this.getClassName() === "InstancedLinesMesh" || this.getClassName() === "LinesMesh" ? this.intersectionThreshold : 0, L = this._boundingInfo;
+ if (!this.subMeshes || !L || !(ae || j.intersectsSphere(L.boundingSphere, $) && j.intersectsBox(L.boundingBox, $)))
+ return K;
+ if (de)
+ return K.hit = !ae, K.pickedMesh = ae ? null : this, K.distance = ae ? 0 : u.e.Distance(j.origin, L.boundingSphere.center), K.subMeshId = 0, K;
+ if (!this._generatePointsArray())
+ return K;
+ for (var G = null, Q = this._scene.getIntersectingSubMeshCandidates(this, j), oe = Q.length, re = !1, Y = 0; Y < oe; Y++) {
+ var k = (H = Q.data[Y]).getMaterial();
+ if (k && (!((ee = this.getIndices()) === null || ee === void 0) && ee.length) && (k.fillMode == S.a.MATERIAL_TriangleStripDrawMode || k.fillMode == S.a.MATERIAL_TriangleFillMode || k.fillMode == S.a.MATERIAL_WireFrameFillMode || k.fillMode == S.a.MATERIAL_PointFillMode)) {
+ re = !0;
+ break;
+ }
+ }
+ if (!re)
+ return K.hit = !0, K.pickedMesh = this, K.distance = u.e.Distance(j.origin, L.boundingSphere.center), K.subMeshId = -1, K;
+ for (Y = 0; Y < oe; Y++) {
+ var H = Q.data[Y];
+ if (!(oe > 1) || H.canIntersects(j)) {
+ var Z = H.intersects(j, this._positions, this.getIndices(), ne, te);
+ if (Z && (ne || !G || Z.distance < G.distance) && ((G = Z).subMeshId = Y, ne))
+ break;
+ }
+ }
+ if (G) {
+ var W = pe ?? (this.skeleton && this.skeleton.overrideMesh ? this.skeleton.overrideMesh.getWorldMatrix() : this.getWorldMatrix()), q = u.c.Vector3[0], he = u.c.Vector3[1];
+ u.e.TransformCoordinatesToRef(j.origin, W, q), j.direction.scaleToRef(G.distance, he);
+ var ge = u.e.TransformNormal(he, W).addInPlace(q);
+ return K.hit = !0, K.distance = u.e.Distance(q, ge), K.pickedPoint = ge, K.pickedMesh = this, K.bu = G.bu || 0, K.bv = G.bv || 0, K.subMeshFaceId = G.faceId, K.faceId = G.faceId + Q.data[G.subMeshId].indexStart / (this.getClassName().indexOf("LinesMesh") !== -1 ? 2 : 3), K.subMeshId = G.subMeshId, K;
+ }
+ return K;
+ }, X.prototype.clone = function(j, ne, te) {
+ return null;
+ }, X.prototype.releaseSubMeshes = function() {
+ if (this.subMeshes)
+ for (; this.subMeshes.length; )
+ this.subMeshes[0].dispose();
+ else
+ this.subMeshes = new Array();
+ return this;
+ }, X.prototype.dispose = function(j, ne) {
+ var te, de = this;
+ for (ne === void 0 && (ne = !1), this._scene.useMaterialMeshMap && this._material && this._material.meshMap && (this._material.meshMap[this.uniqueId] = void 0), this.getScene().freeActiveMeshes(), this.getScene().freeRenderingGroups(), this.actionManager !== void 0 && this.actionManager !== null && (this.actionManager.dispose(), this.actionManager = null), this._internalAbstractMeshDataInfo._skeleton = null, this._transformMatrixTexture && (this._transformMatrixTexture.dispose(), this._transformMatrixTexture = null), te = 0; te < this._intersectionsInProgress.length; te++) {
+ var pe = this._intersectionsInProgress[te], ae = pe._intersectionsInProgress.indexOf(this);
+ pe._intersectionsInProgress.splice(ae, 1);
+ }
+ this._intersectionsInProgress = [], this.getScene().lights.forEach(function(K) {
+ var $ = K.includedOnlyMeshes.indexOf(de);
+ $ !== -1 && K.includedOnlyMeshes.splice($, 1), ($ = K.excludedMeshes.indexOf(de)) !== -1 && K.excludedMeshes.splice($, 1);
+ var L = K.getShadowGenerator();
+ if (L) {
+ var G = L.getShadowMap();
+ G && G.renderList && ($ = G.renderList.indexOf(de)) !== -1 && G.renderList.splice($, 1);
+ }
+ }), this.getClassName() === "InstancedMesh" && this.getClassName() === "InstancedLinesMesh" || this.releaseSubMeshes();
+ var ee = this.getScene().getEngine();
+ if (this._occlusionQuery && (this.isOcclusionQueryInProgress = !1, ee.deleteQuery(this._occlusionQuery), this._occlusionQuery = null), ee.wipeCaches(), this.getScene().removeMesh(this), ne && this.material && (this.material.getClassName() === "MultiMaterial" ? this.material.dispose(!1, !0, !0) : this.material.dispose(!1, !0)), !j)
+ for (te = 0; te < this.getScene().particleSystems.length; te++)
+ this.getScene().particleSystems[te].emitter === this && (this.getScene().particleSystems[te].dispose(), te--);
+ this._internalAbstractMeshDataInfo._facetData.facetDataEnabled && this.disableFacetData(), this.onAfterWorldMatrixUpdateObservable.clear(), this.onCollideObservable.clear(), this.onCollisionPositionChangeObservable.clear(), this.onRebuildObservable.clear(), U.prototype.dispose.call(this, j, ne);
+ }, X.prototype.addChild = function(j) {
+ return j.setParent(this), this;
+ }, X.prototype.removeChild = function(j) {
+ return j.setParent(null), this;
+ }, X.prototype._initFacetData = function() {
+ var j = this._internalAbstractMeshDataInfo._facetData;
+ j.facetNormals || (j.facetNormals = new Array()), j.facetPositions || (j.facetPositions = new Array()), j.facetPartitioning || (j.facetPartitioning = new Array()), j.facetNb = this.getIndices().length / 3 | 0, j.partitioningSubdivisions = j.partitioningSubdivisions ? j.partitioningSubdivisions : 10, j.partitioningBBoxRatio = j.partitioningBBoxRatio ? j.partitioningBBoxRatio : 1.01;
+ for (var ne = 0; ne < j.facetNb; ne++)
+ j.facetNormals[ne] = u.e.Zero(), j.facetPositions[ne] = u.e.Zero();
+ return j.facetDataEnabled = !0, this;
+ }, X.prototype.updateFacetData = function() {
+ var j = this._internalAbstractMeshDataInfo._facetData;
+ j.facetDataEnabled || this._initFacetData();
+ var ne = this.getVerticesData(O.b.PositionKind), te = this.getIndices(), de = this.getVerticesData(O.b.NormalKind), pe = this.getBoundingInfo();
+ if (j.facetDepthSort && !j.facetDepthSortEnabled) {
+ if (j.facetDepthSortEnabled = !0, te instanceof Uint16Array)
+ j.depthSortedIndices = new Uint16Array(te);
+ else if (te instanceof Uint32Array)
+ j.depthSortedIndices = new Uint32Array(te);
+ else {
+ for (var ae = !1, ee = 0; ee < te.length; ee++)
+ if (te[ee] > 65535) {
+ ae = !0;
+ break;
+ }
+ j.depthSortedIndices = ae ? new Uint32Array(te) : new Uint16Array(te);
+ }
+ if (j.facetDepthSortFunction = function(re, Y) {
+ return Y.sqDistance - re.sqDistance;
+ }, !j.facetDepthSortFrom) {
+ var K = this.getScene().activeCamera;
+ j.facetDepthSortFrom = K ? K.position : u.e.Zero();
+ }
+ j.depthSortedFacets = [];
+ for (var $ = 0; $ < j.facetNb; $++) {
+ var L = { ind: 3 * $, sqDistance: 0 };
+ j.depthSortedFacets.push(L);
+ }
+ j.invertedMatrix = u.a.Identity(), j.facetDepthSortOrigin = u.e.Zero();
+ }
+ j.bbSize.x = pe.maximum.x - pe.minimum.x > v.a ? pe.maximum.x - pe.minimum.x : v.a, j.bbSize.y = pe.maximum.y - pe.minimum.y > v.a ? pe.maximum.y - pe.minimum.y : v.a, j.bbSize.z = pe.maximum.z - pe.minimum.z > v.a ? pe.maximum.z - pe.minimum.z : v.a;
+ var G = j.bbSize.x > j.bbSize.y ? j.bbSize.x : j.bbSize.y;
+ if (G = G > j.bbSize.z ? G : j.bbSize.z, j.subDiv.max = j.partitioningSubdivisions, j.subDiv.X = Math.floor(j.subDiv.max * j.bbSize.x / G), j.subDiv.Y = Math.floor(j.subDiv.max * j.bbSize.y / G), j.subDiv.Z = Math.floor(j.subDiv.max * j.bbSize.z / G), j.subDiv.X = j.subDiv.X < 1 ? 1 : j.subDiv.X, j.subDiv.Y = j.subDiv.Y < 1 ? 1 : j.subDiv.Y, j.subDiv.Z = j.subDiv.Z < 1 ? 1 : j.subDiv.Z, j.facetParameters.facetNormals = this.getFacetLocalNormals(), j.facetParameters.facetPositions = this.getFacetLocalPositions(), j.facetParameters.facetPartitioning = this.getFacetLocalPartitioning(), j.facetParameters.bInfo = pe, j.facetParameters.bbSize = j.bbSize, j.facetParameters.subDiv = j.subDiv, j.facetParameters.ratio = this.partitioningBBoxRatio, j.facetParameters.depthSort = j.facetDepthSort, j.facetDepthSort && j.facetDepthSortEnabled && (this.computeWorldMatrix(!0), this._worldMatrix.invertToRef(j.invertedMatrix), u.e.TransformCoordinatesToRef(j.facetDepthSortFrom, j.invertedMatrix, j.facetDepthSortOrigin), j.facetParameters.distanceTo = j.facetDepthSortOrigin), j.facetParameters.depthSortedFacets = j.depthSortedFacets, x.a.ComputeNormals(ne, te, de, j.facetParameters), j.facetDepthSort && j.facetDepthSortEnabled) {
+ j.depthSortedFacets.sort(j.facetDepthSortFunction);
+ var Q = j.depthSortedIndices.length / 3 | 0;
+ for ($ = 0; $ < Q; $++) {
+ var oe = j.depthSortedFacets[$].ind;
+ j.depthSortedIndices[3 * $] = te[oe], j.depthSortedIndices[3 * $ + 1] = te[oe + 1], j.depthSortedIndices[3 * $ + 2] = te[oe + 2];
+ }
+ this.updateIndices(j.depthSortedIndices, void 0, !0);
+ }
+ return this;
+ }, X.prototype.getFacetLocalNormals = function() {
+ var j = this._internalAbstractMeshDataInfo._facetData;
+ return j.facetNormals || this.updateFacetData(), j.facetNormals;
+ }, X.prototype.getFacetLocalPositions = function() {
+ var j = this._internalAbstractMeshDataInfo._facetData;
+ return j.facetPositions || this.updateFacetData(), j.facetPositions;
+ }, X.prototype.getFacetLocalPartitioning = function() {
+ var j = this._internalAbstractMeshDataInfo._facetData;
+ return j.facetPartitioning || this.updateFacetData(), j.facetPartitioning;
+ }, X.prototype.getFacetPosition = function(j) {
+ var ne = u.e.Zero();
+ return this.getFacetPositionToRef(j, ne), ne;
+ }, X.prototype.getFacetPositionToRef = function(j, ne) {
+ var te = this.getFacetLocalPositions()[j], de = this.getWorldMatrix();
+ return u.e.TransformCoordinatesToRef(te, de, ne), this;
+ }, X.prototype.getFacetNormal = function(j) {
+ var ne = u.e.Zero();
+ return this.getFacetNormalToRef(j, ne), ne;
+ }, X.prototype.getFacetNormalToRef = function(j, ne) {
+ var te = this.getFacetLocalNormals()[j];
+ return u.e.TransformNormalToRef(te, this.getWorldMatrix(), ne), this;
+ }, X.prototype.getFacetsAtLocalCoordinates = function(j, ne, te) {
+ var de = this.getBoundingInfo(), pe = this._internalAbstractMeshDataInfo._facetData, ae = Math.floor((j - de.minimum.x * pe.partitioningBBoxRatio) * pe.subDiv.X * pe.partitioningBBoxRatio / pe.bbSize.x), ee = Math.floor((ne - de.minimum.y * pe.partitioningBBoxRatio) * pe.subDiv.Y * pe.partitioningBBoxRatio / pe.bbSize.y), K = Math.floor((te - de.minimum.z * pe.partitioningBBoxRatio) * pe.subDiv.Z * pe.partitioningBBoxRatio / pe.bbSize.z);
+ return ae < 0 || ae > pe.subDiv.max || ee < 0 || ee > pe.subDiv.max || K < 0 || K > pe.subDiv.max ? null : pe.facetPartitioning[ae + pe.subDiv.max * ee + pe.subDiv.max * pe.subDiv.max * K];
+ }, X.prototype.getClosestFacetAtCoordinates = function(j, ne, te, de, pe, ae) {
+ pe === void 0 && (pe = !1), ae === void 0 && (ae = !0);
+ var ee = this.getWorldMatrix(), K = u.c.Matrix[5];
+ ee.invertToRef(K);
+ var $ = u.c.Vector3[8];
+ u.e.TransformCoordinatesFromFloatsToRef(j, ne, te, K, $);
+ var L = this.getClosestFacetAtLocalCoordinates($.x, $.y, $.z, de, pe, ae);
+ return de && u.e.TransformCoordinatesFromFloatsToRef(de.x, de.y, de.z, ee, de), L;
+ }, X.prototype.getClosestFacetAtLocalCoordinates = function(j, ne, te, de, pe, ae) {
+ pe === void 0 && (pe = !1), ae === void 0 && (ae = !0);
+ var ee = null, K = 0, $ = 0, L = 0, G = 0, Q = 0, oe = 0, re = 0, Y = 0, k = this.getFacetLocalPositions(), H = this.getFacetLocalNormals(), Z = this.getFacetsAtLocalCoordinates(j, ne, te);
+ if (!Z)
+ return null;
+ for (var W, q, he, ge = Number.MAX_VALUE, me = ge, _e = 0; _e < Z.length; _e++)
+ q = H[W = Z[_e]], G = (j - (he = k[W]).x) * q.x + (ne - he.y) * q.y + (te - he.z) * q.z, (!pe || pe && ae && G >= 0 || pe && !ae && G <= 0) && (G = q.x * he.x + q.y * he.y + q.z * he.z, Q = -(q.x * j + q.y * ne + q.z * te - G) / (q.x * q.x + q.y * q.y + q.z * q.z), (me = (K = (oe = j + q.x * Q) - j) * K + ($ = (re = ne + q.y * Q) - ne) * $ + (L = (Y = te + q.z * Q) - te) * L) < ge && (ge = me, ee = W, de && (de.x = oe, de.y = re, de.z = Y)));
+ return ee;
+ }, X.prototype.getFacetDataParameters = function() {
+ return this._internalAbstractMeshDataInfo._facetData.facetParameters;
+ }, X.prototype.disableFacetData = function() {
+ var j = this._internalAbstractMeshDataInfo._facetData;
+ return j.facetDataEnabled && (j.facetDataEnabled = !1, j.facetPositions = new Array(), j.facetNormals = new Array(), j.facetPartitioning = new Array(), j.facetParameters = null, j.depthSortedIndices = new Uint32Array(0)), this;
+ }, X.prototype.updateIndices = function(j, ne, te) {
+ return this;
+ }, X.prototype.createNormals = function(j) {
+ var ne, te = this.getVerticesData(O.b.PositionKind), de = this.getIndices();
+ return ne = this.isVerticesDataPresent(O.b.NormalKind) ? this.getVerticesData(O.b.NormalKind) : [], x.a.ComputeNormals(te, de, ne, { useRightHandedSystem: this.getScene().useRightHandedSystem }), this.setVerticesData(O.b.NormalKind, ne, j), this;
+ }, X.prototype.alignWithNormal = function(j, ne) {
+ ne || (ne = b.a.Y);
+ var te = u.c.Vector3[0], de = u.c.Vector3[1];
+ return u.e.CrossToRef(ne, j, de), u.e.CrossToRef(j, de, te), this.rotationQuaternion ? u.b.RotationQuaternionFromAxisToRef(te, j, de, this.rotationQuaternion) : u.e.RotationFromAxisToRef(te, j, de, this.rotation), this;
+ }, X.prototype._checkOcclusionQuery = function() {
+ return !1;
+ }, X.prototype.disableEdgesRendering = function() {
+ throw g.a.WarnImport("EdgesRenderer");
+ }, X.prototype.enableEdgesRendering = function(j, ne, te) {
+ throw g.a.WarnImport("EdgesRenderer");
+ }, X.prototype.getConnectedParticleSystems = function() {
+ var j = this;
+ return this._scene.particleSystems.filter(function(ne) {
+ return ne.emitter === j;
+ });
+ }, X.OCCLUSION_TYPE_NONE = 0, X.OCCLUSION_TYPE_OPTIMISTIC = 1, X.OCCLUSION_TYPE_STRICT = 2, X.OCCLUSION_ALGORITHM_TYPE_ACCURATE = 0, X.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE = 1, X.CULLINGSTRATEGY_STANDARD = S.a.MESHES_CULLINGSTRATEGY_STANDARD, X.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = S.a.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY, X.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = S.a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION, X.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = S.a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY, X;
+ }(m.a);
+ D.a.RegisteredTypes["BABYLON.AbstractMesh"] = M;
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return m;
+ });
+ var V = f(8), _ = f(44), C = f(0), u = f(31), I = f(7), O = f(50), x = f(23);
+ I.a._PhysicsImpostorParser = function(c, T, S) {
+ return new m(T, S.physicsImpostor, { mass: S.physicsMass, friction: S.physicsFriction, restitution: S.physicsRestitution }, c);
+ };
+ var m = function() {
+ function c(T, S, E, g) {
+ var l = this;
+ E === void 0 && (E = { mass: 0 }), this.object = T, this.type = S, this._options = E, this._scene = g, this._pluginData = {}, this._bodyUpdateRequired = !1, this._onBeforePhysicsStepCallbacks = new Array(), this._onAfterPhysicsStepCallbacks = new Array(), this._onPhysicsCollideCallbacks = [], this._deltaPosition = C.e.Zero(), this._isDisposed = !1, this.soft = !1, this.segments = 0, this._tmpQuat = new C.b(), this._tmpQuat2 = new C.b(), this.beforeStep = function() {
+ l._physicsEngine && (l.object.translate(l._deltaPosition, -1), l._deltaRotationConjugated && l.object.rotationQuaternion && l.object.rotationQuaternion.multiplyToRef(l._deltaRotationConjugated, l.object.rotationQuaternion), l.object.computeWorldMatrix(!1), l.object.parent && l.object.rotationQuaternion ? (l.getParentsRotation(), l._tmpQuat.multiplyToRef(l.object.rotationQuaternion, l._tmpQuat)) : l._tmpQuat.copyFrom(l.object.rotationQuaternion || new C.b()), l._options.disableBidirectionalTransformation || l.object.rotationQuaternion && l._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(l, l.object.getAbsolutePosition(), l._tmpQuat), l._onBeforePhysicsStepCallbacks.forEach(function(h) {
+ h(l);
+ }));
+ }, this.afterStep = function() {
+ l._physicsEngine && (l._onAfterPhysicsStepCallbacks.forEach(function(h) {
+ h(l);
+ }), l._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(l), l.object.parent && l.object.rotationQuaternion && (l.getParentsRotation(), l._tmpQuat.conjugateInPlace(), l._tmpQuat.multiplyToRef(l.object.rotationQuaternion, l.object.rotationQuaternion)), l.object.setAbsolutePosition(l.object.position), l._deltaRotation && l.object.rotationQuaternion && l.object.rotationQuaternion.multiplyToRef(l._deltaRotation, l.object.rotationQuaternion), l.object.translate(l._deltaPosition, 1));
+ }, this.onCollideEvent = null, this.onCollide = function(h) {
+ if ((l._onPhysicsCollideCallbacks.length || l.onCollideEvent) && l._physicsEngine) {
+ var v = l._physicsEngine.getImpostorWithPhysicsBody(h.body);
+ v && (l.onCollideEvent && l.onCollideEvent(l, v), l._onPhysicsCollideCallbacks.filter(function(b) {
+ return b.otherImpostors.indexOf(v) !== -1;
+ }).forEach(function(b) {
+ b.callback(l, v, h.point);
+ }));
+ }
+ }, this.object ? (this.object.parent && E.mass !== 0 && V.a.Warn("A physics impostor has been created for an object which has a parent. Babylon physics currently works in local space so unexpected issues may occur."), !this._scene && T.getScene && (this._scene = T.getScene()), this._scene && (this.type > 100 && (this.soft = !0), this._physicsEngine = this._scene.getPhysicsEngine(), this._physicsEngine ? (this.object.rotationQuaternion || (this.object.rotation ? this.object.rotationQuaternion = C.b.RotationYawPitchRoll(this.object.rotation.y, this.object.rotation.x, this.object.rotation.z) : this.object.rotationQuaternion = new C.b()), this._options.mass = E.mass === void 0 ? 0 : E.mass, this._options.friction = E.friction === void 0 ? 0.2 : E.friction, this._options.restitution = E.restitution === void 0 ? 0.2 : E.restitution, this.soft && (this._options.mass = this._options.mass > 0 ? this._options.mass : 1, this._options.pressure = E.pressure === void 0 ? 200 : E.pressure, this._options.stiffness = E.stiffness === void 0 ? 1 : E.stiffness, this._options.velocityIterations = E.velocityIterations === void 0 ? 20 : E.velocityIterations, this._options.positionIterations = E.positionIterations === void 0 ? 20 : E.positionIterations, this._options.fixedPoints = E.fixedPoints === void 0 ? 0 : E.fixedPoints, this._options.margin = E.margin === void 0 ? 0 : E.margin, this._options.damping = E.damping === void 0 ? 0 : E.damping, this._options.path = E.path === void 0 ? null : E.path, this._options.shape = E.shape === void 0 ? null : E.shape), this._joints = [], !this.object.parent || this._options.ignoreParent ? this._init() : this.object.parent.physicsImpostor && V.a.Warn("You must affect impostors to children before affecting impostor to parent.")) : V.a.Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors."))) : V.a.Error("No object was provided. A physics object is obligatory");
+ }
+ return Object.defineProperty(c.prototype, "isDisposed", { get: function() {
+ return this._isDisposed;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(c.prototype, "mass", { get: function() {
+ return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyMass(this) : 0;
+ }, set: function(T) {
+ this.setMass(T);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(c.prototype, "friction", { get: function() {
+ return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyFriction(this) : 0;
+ }, set: function(T) {
+ this._physicsEngine && this._physicsEngine.getPhysicsPlugin().setBodyFriction(this, T);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(c.prototype, "restitution", { get: function() {
+ return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this) : 0;
+ }, set: function(T) {
+ this._physicsEngine && this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this, T);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(c.prototype, "pressure", { get: function() {
+ if (!this._physicsEngine)
+ return 0;
+ var T = this._physicsEngine.getPhysicsPlugin();
+ return T.setBodyPressure ? T.getBodyPressure(this) : 0;
+ }, set: function(T) {
+ if (this._physicsEngine) {
+ var S = this._physicsEngine.getPhysicsPlugin();
+ S.setBodyPressure && S.setBodyPressure(this, T);
+ }
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(c.prototype, "stiffness", { get: function() {
+ if (!this._physicsEngine)
+ return 0;
+ var T = this._physicsEngine.getPhysicsPlugin();
+ return T.getBodyStiffness ? T.getBodyStiffness(this) : 0;
+ }, set: function(T) {
+ if (this._physicsEngine) {
+ var S = this._physicsEngine.getPhysicsPlugin();
+ S.setBodyStiffness && S.setBodyStiffness(this, T);
+ }
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(c.prototype, "velocityIterations", { get: function() {
+ if (!this._physicsEngine)
+ return 0;
+ var T = this._physicsEngine.getPhysicsPlugin();
+ return T.getBodyVelocityIterations ? T.getBodyVelocityIterations(this) : 0;
+ }, set: function(T) {
+ if (this._physicsEngine) {
+ var S = this._physicsEngine.getPhysicsPlugin();
+ S.setBodyVelocityIterations && S.setBodyVelocityIterations(this, T);
+ }
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(c.prototype, "positionIterations", { get: function() {
+ if (!this._physicsEngine)
+ return 0;
+ var T = this._physicsEngine.getPhysicsPlugin();
+ return T.getBodyPositionIterations ? T.getBodyPositionIterations(this) : 0;
+ }, set: function(T) {
+ if (this._physicsEngine) {
+ var S = this._physicsEngine.getPhysicsPlugin();
+ S.setBodyPositionIterations && S.setBodyPositionIterations(this, T);
+ }
+ }, enumerable: !1, configurable: !0 }), c.prototype._init = function() {
+ this._physicsEngine && (this._physicsEngine.removeImpostor(this), this.physicsBody = null, this._parent = this._parent || this._getPhysicsParent(), this._isDisposed || this.parent && !this._options.ignoreParent || this._physicsEngine.addImpostor(this));
+ }, c.prototype._getPhysicsParent = function() {
+ return this.object.parent instanceof u.a ? this.object.parent.physicsImpostor : null;
+ }, c.prototype.isBodyInitRequired = function() {
+ return this._bodyUpdateRequired || !this._physicsBody && !this._parent;
+ }, c.prototype.setScalingUpdated = function() {
+ this.forceUpdate();
+ }, c.prototype.forceUpdate = function() {
+ this._init(), this.parent && !this._options.ignoreParent && this.parent.forceUpdate();
+ }, Object.defineProperty(c.prototype, "physicsBody", { get: function() {
+ return this._parent && !this._options.ignoreParent ? this._parent.physicsBody : this._physicsBody;
+ }, set: function(T) {
+ this._physicsBody && this._physicsEngine && this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this), this._physicsBody = T, this.resetUpdateFlags();
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(c.prototype, "parent", { get: function() {
+ return !this._options.ignoreParent && this._parent ? this._parent : null;
+ }, set: function(T) {
+ this._parent = T;
+ }, enumerable: !1, configurable: !0 }), c.prototype.resetUpdateFlags = function() {
+ this._bodyUpdateRequired = !1;
+ }, c.prototype.getObjectExtendSize = function() {
+ if (this.object.getBoundingInfo) {
+ var T = this.object.rotationQuaternion, S = this.object.scaling.clone();
+ this.object.rotationQuaternion = c.IDENTITY_QUATERNION;
+ var E = this.object.computeWorldMatrix && this.object.computeWorldMatrix(!0);
+ E && E.decompose(S, void 0, void 0);
+ var g = this.object.getBoundingInfo().boundingBox.extendSize.scale(2).multiplyInPlace(S);
+ return this.object.rotationQuaternion = T, this.object.computeWorldMatrix && this.object.computeWorldMatrix(!0), g;
+ }
+ return c.DEFAULT_OBJECT_SIZE;
+ }, c.prototype.getObjectCenter = function() {
+ return this.object.getBoundingInfo ? this.object.getBoundingInfo().boundingBox.centerWorld : this.object.position;
+ }, c.prototype.getParam = function(T) {
+ return this._options[T];
+ }, c.prototype.setParam = function(T, S) {
+ this._options[T] = S, this._bodyUpdateRequired = !0;
+ }, c.prototype.setMass = function(T) {
+ this.getParam("mass") !== T && this.setParam("mass", T), this._physicsEngine && this._physicsEngine.getPhysicsPlugin().setBodyMass(this, T);
+ }, c.prototype.getLinearVelocity = function() {
+ return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this) : C.e.Zero();
+ }, c.prototype.setLinearVelocity = function(T) {
+ this._physicsEngine && this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this, T);
+ }, c.prototype.getAngularVelocity = function() {
+ return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this) : C.e.Zero();
+ }, c.prototype.setAngularVelocity = function(T) {
+ this._physicsEngine && this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this, T);
+ }, c.prototype.executeNativeFunction = function(T) {
+ this._physicsEngine && T(this._physicsEngine.getPhysicsPlugin().world, this.physicsBody);
+ }, c.prototype.registerBeforePhysicsStep = function(T) {
+ this._onBeforePhysicsStepCallbacks.push(T);
+ }, c.prototype.unregisterBeforePhysicsStep = function(T) {
+ var S = this._onBeforePhysicsStepCallbacks.indexOf(T);
+ S > -1 ? this._onBeforePhysicsStepCallbacks.splice(S, 1) : V.a.Warn("Function to remove was not found");
+ }, c.prototype.registerAfterPhysicsStep = function(T) {
+ this._onAfterPhysicsStepCallbacks.push(T);
+ }, c.prototype.unregisterAfterPhysicsStep = function(T) {
+ var S = this._onAfterPhysicsStepCallbacks.indexOf(T);
+ S > -1 ? this._onAfterPhysicsStepCallbacks.splice(S, 1) : V.a.Warn("Function to remove was not found");
+ }, c.prototype.registerOnPhysicsCollide = function(T, S) {
+ var E = T instanceof Array ? T : [T];
+ this._onPhysicsCollideCallbacks.push({ callback: S, otherImpostors: E });
+ }, c.prototype.unregisterOnPhysicsCollide = function(T, S) {
+ var E = T instanceof Array ? T : [T], g = -1;
+ this._onPhysicsCollideCallbacks.some(function(l, h) {
+ if (l.callback === S && l.otherImpostors.length === E.length) {
+ var v = l.otherImpostors.every(function(b) {
+ return E.indexOf(b) > -1;
+ });
+ return v && (g = h), v;
+ }
+ return !1;
+ }) ? this._onPhysicsCollideCallbacks.splice(g, 1) : V.a.Warn("Function to remove was not found");
+ }, c.prototype.getParentsRotation = function() {
+ var T = this.object.parent;
+ for (this._tmpQuat.copyFromFloats(0, 0, 0, 1); T; )
+ T.rotationQuaternion ? this._tmpQuat2.copyFrom(T.rotationQuaternion) : C.b.RotationYawPitchRollToRef(T.rotation.y, T.rotation.x, T.rotation.z, this._tmpQuat2), this._tmpQuat.multiplyToRef(this._tmpQuat2, this._tmpQuat), T = T.parent;
+ return this._tmpQuat;
+ }, c.prototype.applyForce = function(T, S) {
+ return this._physicsEngine && this._physicsEngine.getPhysicsPlugin().applyForce(this, T, S), this;
+ }, c.prototype.applyImpulse = function(T, S) {
+ return this._physicsEngine && this._physicsEngine.getPhysicsPlugin().applyImpulse(this, T, S), this;
+ }, c.prototype.createJoint = function(T, S, E) {
+ var g = new O.e(S, E);
+ return this.addJoint(T, g), this;
+ }, c.prototype.addJoint = function(T, S) {
+ return this._joints.push({ otherImpostor: T, joint: S }), this._physicsEngine && this._physicsEngine.addJoint(this, T, S), this;
+ }, c.prototype.addAnchor = function(T, S, E, g, l) {
+ if (!this._physicsEngine)
+ return this;
+ var h = this._physicsEngine.getPhysicsPlugin();
+ return h.appendAnchor ? (this._physicsEngine && h.appendAnchor(this, T, S, E, g, l), this) : this;
+ }, c.prototype.addHook = function(T, S, E, g) {
+ if (!this._physicsEngine)
+ return this;
+ var l = this._physicsEngine.getPhysicsPlugin();
+ return l.appendAnchor ? (this._physicsEngine && l.appendHook(this, T, S, E, g), this) : this;
+ }, c.prototype.sleep = function() {
+ return this._physicsEngine && this._physicsEngine.getPhysicsPlugin().sleepBody(this), this;
+ }, c.prototype.wakeUp = function() {
+ return this._physicsEngine && this._physicsEngine.getPhysicsPlugin().wakeUpBody(this), this;
+ }, c.prototype.clone = function(T) {
+ return T ? new c(T, this.type, this._options, this._scene) : null;
+ }, c.prototype.dispose = function() {
+ var T = this;
+ this._physicsEngine && (this._joints.forEach(function(S) {
+ T._physicsEngine && T._physicsEngine.removeJoint(T, S.otherImpostor, S.joint);
+ }), this._physicsEngine.removeImpostor(this), this.parent && this.parent.forceUpdate(), this._isDisposed = !0);
+ }, c.prototype.setDeltaPosition = function(T) {
+ this._deltaPosition.copyFrom(T);
+ }, c.prototype.setDeltaRotation = function(T) {
+ this._deltaRotation || (this._deltaRotation = new C.b()), this._deltaRotation.copyFrom(T), this._deltaRotationConjugated = this._deltaRotation.conjugate();
+ }, c.prototype.getBoxSizeToRef = function(T) {
+ return this._physicsEngine && this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this, T), this;
+ }, c.prototype.getRadius = function() {
+ return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getRadius(this) : 0;
+ }, c.prototype.syncBoneWithImpostor = function(T, S, E, g, l) {
+ var h = c._tmpVecs[0], v = this.object;
+ if (v.rotationQuaternion)
+ if (l) {
+ var b = c._tmpQuat;
+ v.rotationQuaternion.multiplyToRef(l, b), T.setRotationQuaternion(b, x.c.WORLD, S);
+ } else
+ T.setRotationQuaternion(v.rotationQuaternion, x.c.WORLD, S);
+ h.x = 0, h.y = 0, h.z = 0, E && (h.x = E.x, h.y = E.y, h.z = E.z, T.getDirectionToRef(h, S, h), g == null && (g = E.length()), h.x *= g, h.y *= g, h.z *= g), T.getParent() ? (h.addInPlace(v.getAbsolutePosition()), T.setAbsolutePosition(h, S)) : (S.setAbsolutePosition(v.getAbsolutePosition()), S.position.x -= h.x, S.position.y -= h.y, S.position.z -= h.z);
+ }, c.prototype.syncImpostorWithBone = function(T, S, E, g, l, h) {
+ var v = this.object;
+ if (v.rotationQuaternion)
+ if (l) {
+ var b = c._tmpQuat;
+ T.getRotationQuaternionToRef(x.c.WORLD, S, b), b.multiplyToRef(l, v.rotationQuaternion);
+ } else
+ T.getRotationQuaternionToRef(x.c.WORLD, S, v.rotationQuaternion);
+ var D = c._tmpVecs[0], w = c._tmpVecs[1];
+ h || ((h = c._tmpVecs[2]).x = 0, h.y = 1, h.z = 0), T.getDirectionToRef(h, S, w), T.getAbsolutePositionToRef(S, D), g == null && E && (g = E.length()), g != null && (D.x += w.x * g, D.y += w.y * g, D.z += w.z * g), v.setAbsolutePosition(D);
+ }, c.DEFAULT_OBJECT_SIZE = new C.e(1, 1, 1), c.IDENTITY_QUATERNION = C.b.Identity(), c._tmpVecs = _.a.BuildArray(3, C.e.Zero), c._tmpQuat = C.b.Identity(), c.NoImpostor = 0, c.SphereImpostor = 1, c.BoxImpostor = 2, c.PlaneImpostor = 3, c.MeshImpostor = 4, c.CapsuleImpostor = 6, c.CylinderImpostor = 7, c.ParticleImpostor = 8, c.HeightmapImpostor = 9, c.ConvexHullImpostor = 10, c.CustomImpostor = 100, c.RopeImpostor = 101, c.ClothImpostor = 102, c.SoftbodyImpostor = 103, c;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return _;
+ }), f.d(A, "b", function() {
+ return C;
+ });
+ var V = f(1), _ = function() {
+ function u(I) {
+ this.length = 0, this.data = new Array(I), this._id = u._GlobalId++;
+ }
+ return u.prototype.push = function(I) {
+ this.data[this.length++] = I, this.length > this.data.length && (this.data.length *= 2);
+ }, u.prototype.forEach = function(I) {
+ for (var O = 0; O < this.length; O++)
+ I(this.data[O]);
+ }, u.prototype.sort = function(I) {
+ this.data.sort(I);
+ }, u.prototype.reset = function() {
+ this.length = 0;
+ }, u.prototype.dispose = function() {
+ this.reset(), this.data && (this.data.length = 0, this.data = []);
+ }, u.prototype.concat = function(I) {
+ if (I.length !== 0) {
+ this.length + I.length > this.data.length && (this.data.length = 2 * (this.length + I.length));
+ for (var O = 0; O < I.length; O++)
+ this.data[this.length++] = (I.data || I)[O];
+ }
+ }, u.prototype.indexOf = function(I) {
+ var O = this.data.indexOf(I);
+ return O >= this.length ? -1 : O;
+ }, u.prototype.contains = function(I) {
+ return this.indexOf(I) !== -1;
+ }, u._GlobalId = 0, u;
+ }(), C = function(u) {
+ function I() {
+ var O = u !== null && u.apply(this, arguments) || this;
+ return O._duplicateId = 0, O;
+ }
+ return Object(V.d)(I, u), I.prototype.push = function(O) {
+ u.prototype.push.call(this, O), O.__smartArrayFlags || (O.__smartArrayFlags = {}), O.__smartArrayFlags[this._id] = this._duplicateId;
+ }, I.prototype.pushNoDuplicate = function(O) {
+ return (!O.__smartArrayFlags || O.__smartArrayFlags[this._id] !== this._duplicateId) && (this.push(O), !0);
+ }, I.prototype.reset = function() {
+ u.prototype.reset.call(this), this._duplicateId++;
+ }, I.prototype.concatWithNoDuplicate = function(O) {
+ if (O.length !== 0) {
+ this.length + O.length > this.data.length && (this.data.length = 2 * (this.length + O.length));
+ for (var x = 0; x < O.length; x++) {
+ var m = (O.data || O)[x];
+ this.pushNoDuplicate(m);
+ }
+ }
+ }, I;
+ }(_);
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return V;
+ });
+ var V = function() {
+ function _() {
+ }
+ return _.EndsWith = function(C, u) {
+ return C.indexOf(u, C.length - u.length) !== -1;
+ }, _.StartsWith = function(C, u) {
+ return !!C && C.indexOf(u) === 0;
+ }, _.Decode = function(C) {
+ if (typeof TextDecoder < "u")
+ return new TextDecoder().decode(C);
+ for (var u = "", I = 0; I < C.byteLength; I++)
+ u += String.fromCharCode(C[I]);
+ return u;
+ }, _.EncodeArrayBufferToBase64 = function(C) {
+ for (var u, I, O, x, m, c, T, S = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", E = "", g = 0, l = ArrayBuffer.isView(C) ? new Uint8Array(C.buffer, C.byteOffset, C.byteLength) : new Uint8Array(C); g < l.length; )
+ x = (u = l[g++]) >> 2, m = (3 & u) << 4 | (I = g < l.length ? l[g++] : Number.NaN) >> 4, c = (15 & I) << 2 | (O = g < l.length ? l[g++] : Number.NaN) >> 6, T = 63 & O, isNaN(I) ? c = T = 64 : isNaN(O) && (T = 64), E += S.charAt(x) + S.charAt(m) + S.charAt(c) + S.charAt(T);
+ return E;
+ }, _.PadNumber = function(C, u) {
+ for (var I = String(C); I.length < u; )
+ I = "0" + I;
+ return I;
+ }, _;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return V;
+ });
+ var V = function() {
+ function _() {
+ this.rootNodes = new Array(), this.cameras = new Array(), this.lights = new Array(), this.meshes = new Array(), this.skeletons = new Array(), this.particleSystems = new Array(), this.animations = [], this.animationGroups = new Array(), this.multiMaterials = new Array(), this.materials = new Array(), this.morphTargetManagers = new Array(), this.geometries = new Array(), this.transformNodes = new Array(), this.actionManagers = new Array(), this.textures = new Array(), this._environmentTexture = null, this.postProcesses = new Array();
+ }
+ return _.AddParser = function(C, u) {
+ this._BabylonFileParsers[C] = u;
+ }, _.GetParser = function(C) {
+ return this._BabylonFileParsers[C] ? this._BabylonFileParsers[C] : null;
+ }, _.AddIndividualParser = function(C, u) {
+ this._IndividualBabylonFileParsers[C] = u;
+ }, _.GetIndividualParser = function(C) {
+ return this._IndividualBabylonFileParsers[C] ? this._IndividualBabylonFileParsers[C] : null;
+ }, _.Parse = function(C, u, I, O) {
+ for (var x in this._BabylonFileParsers)
+ this._BabylonFileParsers.hasOwnProperty(x) && this._BabylonFileParsers[x](C, u, I, O);
+ }, Object.defineProperty(_.prototype, "environmentTexture", { get: function() {
+ return this._environmentTexture;
+ }, set: function(C) {
+ this._environmentTexture = C;
+ }, enumerable: !1, configurable: !0 }), _.prototype.getNodes = function() {
+ var C = new Array();
+ return C = (C = (C = (C = C.concat(this.meshes)).concat(this.lights)).concat(this.cameras)).concat(this.transformNodes), this.skeletons.forEach(function(u) {
+ return C = C.concat(u.bones);
+ }), C;
+ }, _._BabylonFileParsers = {}, _._IndividualBabylonFileParsers = {}, _;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return m;
+ });
+ var V = f(20), _ = f(6), C = f(18), u = f(22), I = f(86), O = f(0), x = f(9), m = function() {
+ function c(T, S) {
+ var E = this;
+ S === void 0 && (S = !0), this.originalScene = T, this._pointerCaptures = {}, this._lastPointerEvents = {}, this._sharedGizmoLight = null, this._renderCamera = null, this.pickUtilitySceneFirst = !0, this.shouldRender = !0, this.onlyCheckPointerDownEvents = !0, this.processAllEvents = !1, this.onPointerOutObservable = new _.c(), this.utilityLayerScene = new V.a(T.getEngine(), { virtual: !0 }), this.utilityLayerScene.useRightHandedSystem = T.useRightHandedSystem, this.utilityLayerScene._allowPostProcessClearColor = !1, this.utilityLayerScene.detachControl(), S && (this._originalPointerObserver = T.onPrePointerObservable.add(function(g, l) {
+ if (E.utilityLayerScene.activeCamera && (E.processAllEvents || g.type === C.a.POINTERMOVE || g.type === C.a.POINTERUP || g.type === C.a.POINTERDOWN || g.type === C.a.POINTERDOUBLETAP)) {
+ E.utilityLayerScene.pointerX = T.pointerX, E.utilityLayerScene.pointerY = T.pointerY;
+ var h = g.event;
+ if (T.isPointerCaptured(h.pointerId))
+ E._pointerCaptures[h.pointerId] = !1;
+ else {
+ var v = g.ray ? E.utilityLayerScene.pickWithRay(g.ray) : E.utilityLayerScene.pick(T.pointerX, T.pointerY);
+ if (!g.ray && v && (g.ray = v.ray), E.utilityLayerScene.onPrePointerObservable.notifyObservers(g), E.onlyCheckPointerDownEvents && g.type != C.a.POINTERDOWN)
+ return g.skipOnPointerObservable || E.utilityLayerScene.onPointerObservable.notifyObservers(new C.b(g.type, g.event, v), g.type), void (g.type === C.a.POINTERUP && E._pointerCaptures[h.pointerId] && (E._pointerCaptures[h.pointerId] = !1));
+ if (E.utilityLayerScene.autoClearDepthAndStencil || E.pickUtilitySceneFirst)
+ v && v.hit && (g.skipOnPointerObservable || E.utilityLayerScene.onPointerObservable.notifyObservers(new C.b(g.type, g.event, v), g.type), g.skipOnPointerObservable = !0);
+ else {
+ var b = g.ray ? T.pickWithRay(g.ray) : T.pick(T.pointerX, T.pointerY), D = g.event;
+ b && v && (v.distance === 0 && b.pickedMesh ? E.mainSceneTrackerPredicate && E.mainSceneTrackerPredicate(b.pickedMesh) ? (E._notifyObservers(g, b, D), g.skipOnPointerObservable = !0) : g.type === C.a.POINTERDOWN ? E._pointerCaptures[D.pointerId] = !0 : E._lastPointerEvents[D.pointerId] && (E.onPointerOutObservable.notifyObservers(D.pointerId), delete E._lastPointerEvents[D.pointerId]) : !E._pointerCaptures[D.pointerId] && (v.distance < b.distance || b.distance === 0) ? (E._notifyObservers(g, v, D), g.skipOnPointerObservable || (g.skipOnPointerObservable = v.distance > 0)) : !E._pointerCaptures[D.pointerId] && v.distance > b.distance && (E.mainSceneTrackerPredicate && E.mainSceneTrackerPredicate(b.pickedMesh) ? (E._notifyObservers(g, b, D), g.skipOnPointerObservable = !0) : E._lastPointerEvents[D.pointerId] && (E.onPointerOutObservable.notifyObservers(D.pointerId), delete E._lastPointerEvents[D.pointerId])), g.type === C.a.POINTERUP && E._pointerCaptures[D.pointerId] && (E._pointerCaptures[D.pointerId] = !1));
+ }
+ }
+ }
+ }), this._originalPointerObserver && T.onPrePointerObservable.makeObserverTopPriority(this._originalPointerObserver)), this.utilityLayerScene.autoClear = !1, this._afterRenderObserver = this.originalScene.onAfterCameraRenderObservable.add(function(g) {
+ E.shouldRender && g == E.getRenderCamera() && E.render();
+ }), this._sceneDisposeObserver = this.originalScene.onDisposeObservable.add(function() {
+ E.dispose();
+ }), this._updateCamera();
+ }
+ return c.prototype.getRenderCamera = function(T) {
+ if (this._renderCamera)
+ return this._renderCamera;
+ var S = void 0;
+ return S = this.originalScene.activeCameras && this.originalScene.activeCameras.length > 1 ? this.originalScene.activeCameras[this.originalScene.activeCameras.length - 1] : this.originalScene.activeCamera, T && S && S.isRigCamera ? S.rigParent : S;
+ }, c.prototype.setRenderCamera = function(T) {
+ this._renderCamera = T;
+ }, c.prototype._getSharedGizmoLight = function() {
+ return this._sharedGizmoLight || (this._sharedGizmoLight = new I.a("shared gizmo light", new O.e(0, 1, 0), this.utilityLayerScene), this._sharedGizmoLight.intensity = 2, this._sharedGizmoLight.groundColor = x.a.Gray()), this._sharedGizmoLight;
+ }, Object.defineProperty(c, "DefaultUtilityLayer", { get: function() {
+ return c._DefaultUtilityLayer == null && (c._DefaultUtilityLayer = new c(u.a.LastCreatedScene), c._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce(function() {
+ c._DefaultUtilityLayer = null;
+ })), c._DefaultUtilityLayer;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(c, "DefaultKeepDepthUtilityLayer", { get: function() {
+ return c._DefaultKeepDepthUtilityLayer == null && (c._DefaultKeepDepthUtilityLayer = new c(u.a.LastCreatedScene), c._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = !1, c._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce(function() {
+ c._DefaultKeepDepthUtilityLayer = null;
+ })), c._DefaultKeepDepthUtilityLayer;
+ }, enumerable: !1, configurable: !0 }), c.prototype._notifyObservers = function(T, S, E) {
+ T.skipOnPointerObservable || (this.utilityLayerScene.onPointerObservable.notifyObservers(new C.b(T.type, T.event, S), T.type), this._lastPointerEvents[E.pointerId] = !0);
+ }, c.prototype.render = function() {
+ if (this._updateCamera(), this.utilityLayerScene.activeCamera) {
+ var T = this.utilityLayerScene.activeCamera.getScene(), S = this.utilityLayerScene.activeCamera;
+ S._scene = this.utilityLayerScene, S.leftCamera && (S.leftCamera._scene = this.utilityLayerScene), S.rightCamera && (S.rightCamera._scene = this.utilityLayerScene), this.utilityLayerScene.render(!1), S._scene = T, S.leftCamera && (S.leftCamera._scene = T), S.rightCamera && (S.rightCamera._scene = T);
+ }
+ }, c.prototype.dispose = function() {
+ this.onPointerOutObservable.clear(), this._afterRenderObserver && this.originalScene.onAfterCameraRenderObservable.remove(this._afterRenderObserver), this._sceneDisposeObserver && this.originalScene.onDisposeObservable.remove(this._sceneDisposeObserver), this._originalPointerObserver && this.originalScene.onPrePointerObservable.remove(this._originalPointerObserver), this.utilityLayerScene.dispose();
+ }, c.prototype._updateCamera = function() {
+ this.utilityLayerScene.cameraToUseForPointers = this.getRenderCamera(), this.utilityLayerScene.activeCamera = this.getRenderCamera();
+ }, c._DefaultUtilityLayer = null, c._DefaultKeepDepthUtilityLayer = null, c;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return _;
+ });
+ var V = f(139), _ = function() {
+ function C() {
+ }
+ return C.EnableFor = function(u) {
+ u._tags = u._tags || {}, u.hasTags = function() {
+ return C.HasTags(u);
+ }, u.addTags = function(I) {
+ return C.AddTagsTo(u, I);
+ }, u.removeTags = function(I) {
+ return C.RemoveTagsFrom(u, I);
+ }, u.matchesTagsQuery = function(I) {
+ return C.MatchesQuery(u, I);
+ };
+ }, C.DisableFor = function(u) {
+ delete u._tags, delete u.hasTags, delete u.addTags, delete u.removeTags, delete u.matchesTagsQuery;
+ }, C.HasTags = function(u) {
+ if (!u._tags)
+ return !1;
+ var I = u._tags;
+ for (var O in I)
+ if (I.hasOwnProperty(O))
+ return !0;
+ return !1;
+ }, C.GetTags = function(u, I) {
+ if (I === void 0 && (I = !0), !u._tags)
+ return null;
+ if (I) {
+ var O = [];
+ for (var x in u._tags)
+ u._tags.hasOwnProperty(x) && u._tags[x] === !0 && O.push(x);
+ return O.join(" ");
+ }
+ return u._tags;
+ }, C.AddTagsTo = function(u, I) {
+ I && typeof I == "string" && I.split(" ").forEach(function(O, x, m) {
+ C._AddTagTo(u, O);
+ });
+ }, C._AddTagTo = function(u, I) {
+ (I = I.trim()) !== "" && I !== "true" && I !== "false" && (I.match(/[\s]/) || I.match(/^([!]|([|]|[&]){2})/) || (C.EnableFor(u), u._tags[I] = !0));
+ }, C.RemoveTagsFrom = function(u, I) {
+ if (C.HasTags(u)) {
+ var O = I.split(" ");
+ for (var x in O)
+ C._RemoveTagFrom(u, O[x]);
+ }
+ }, C._RemoveTagFrom = function(u, I) {
+ delete u._tags[I];
+ }, C.MatchesQuery = function(u, I) {
+ return I === void 0 || (I === "" ? C.HasTags(u) : V.a.Eval(I, function(O) {
+ return C.HasTags(u) && u._tags[O];
+ }));
+ }, C;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return V;
+ });
+ var V = function() {
+ function _() {
+ }
+ return _.IsWindowObjectExist = function() {
+ return typeof window < "u";
+ }, _.IsNavigatorAvailable = function() {
+ return typeof navigator < "u";
+ }, _.IsDocumentAvailable = function() {
+ return typeof document < "u";
+ }, _.GetDOMTextContent = function(C) {
+ for (var u = "", I = C.firstChild; I; )
+ I.nodeType === 3 && (u += I.textContent), I = I.nextSibling;
+ return u;
+ }, _;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return x;
+ });
+ var V = f(44), _ = f(0), C = f(54), u = f(114), I = f(20), O = f(24), x = function() {
+ function m(c, T, S) {
+ S === void 0 && (S = Number.MAX_VALUE), this.origin = c, this.direction = T, this.length = S;
+ }
+ return m.prototype.intersectsBoxMinMax = function(c, T, S) {
+ S === void 0 && (S = 0);
+ var E, g, l, h, v = m._TmpVector3[0].copyFromFloats(c.x - S, c.y - S, c.z - S), b = m._TmpVector3[1].copyFromFloats(T.x + S, T.y + S, T.z + S), D = 0, w = Number.MAX_VALUE;
+ if (Math.abs(this.direction.x) < 1e-7) {
+ if (this.origin.x < v.x || this.origin.x > b.x)
+ return !1;
+ } else if (E = 1 / this.direction.x, g = (v.x - this.origin.x) * E, (l = (b.x - this.origin.x) * E) === -1 / 0 && (l = 1 / 0), g > l && (h = g, g = l, l = h), (D = Math.max(g, D)) > (w = Math.min(l, w)))
+ return !1;
+ if (Math.abs(this.direction.y) < 1e-7) {
+ if (this.origin.y < v.y || this.origin.y > b.y)
+ return !1;
+ } else if (E = 1 / this.direction.y, g = (v.y - this.origin.y) * E, (l = (b.y - this.origin.y) * E) === -1 / 0 && (l = 1 / 0), g > l && (h = g, g = l, l = h), (D = Math.max(g, D)) > (w = Math.min(l, w)))
+ return !1;
+ if (Math.abs(this.direction.z) < 1e-7) {
+ if (this.origin.z < v.z || this.origin.z > b.z)
+ return !1;
+ } else if (E = 1 / this.direction.z, g = (v.z - this.origin.z) * E, (l = (b.z - this.origin.z) * E) === -1 / 0 && (l = 1 / 0), g > l && (h = g, g = l, l = h), (D = Math.max(g, D)) > (w = Math.min(l, w)))
+ return !1;
+ return !0;
+ }, m.prototype.intersectsBox = function(c, T) {
+ return T === void 0 && (T = 0), this.intersectsBoxMinMax(c.minimum, c.maximum, T);
+ }, m.prototype.intersectsSphere = function(c, T) {
+ T === void 0 && (T = 0);
+ var S = c.center.x - this.origin.x, E = c.center.y - this.origin.y, g = c.center.z - this.origin.z, l = S * S + E * E + g * g, h = c.radius + T, v = h * h;
+ if (l <= v)
+ return !0;
+ var b = S * this.direction.x + E * this.direction.y + g * this.direction.z;
+ return !(b < 0) && l - b * b <= v;
+ }, m.prototype.intersectsTriangle = function(c, T, S) {
+ var E = m._TmpVector3[0], g = m._TmpVector3[1], l = m._TmpVector3[2], h = m._TmpVector3[3], v = m._TmpVector3[4];
+ T.subtractToRef(c, E), S.subtractToRef(c, g), _.e.CrossToRef(this.direction, g, l);
+ var b = _.e.Dot(E, l);
+ if (b === 0)
+ return null;
+ var D = 1 / b;
+ this.origin.subtractToRef(c, h);
+ var w = _.e.Dot(h, l) * D;
+ if (w < 0 || w > 1)
+ return null;
+ _.e.CrossToRef(h, E, v);
+ var N = _.e.Dot(this.direction, v) * D;
+ if (N < 0 || w + N > 1)
+ return null;
+ var M = _.e.Dot(g, v) * D;
+ return M > this.length ? null : new u.a(1 - w - N, w, M);
+ }, m.prototype.intersectsPlane = function(c) {
+ var T, S = _.e.Dot(c.normal, this.direction);
+ if (Math.abs(S) < 999999997475243e-21)
+ return null;
+ var E = _.e.Dot(c.normal, this.origin);
+ return (T = (-c.d - E) / S) < 0 ? T < -999999997475243e-21 ? null : 0 : T;
+ }, m.prototype.intersectsAxis = function(c, T) {
+ switch (T === void 0 && (T = 0), c) {
+ case "y":
+ return (S = (this.origin.y - T) / this.direction.y) > 0 ? null : new _.e(this.origin.x + this.direction.x * -S, T, this.origin.z + this.direction.z * -S);
+ case "x":
+ return (S = (this.origin.x - T) / this.direction.x) > 0 ? null : new _.e(T, this.origin.y + this.direction.y * -S, this.origin.z + this.direction.z * -S);
+ case "z":
+ var S;
+ return (S = (this.origin.z - T) / this.direction.z) > 0 ? null : new _.e(this.origin.x + this.direction.x * -S, this.origin.y + this.direction.y * -S, T);
+ default:
+ return null;
+ }
+ }, m.prototype.intersectsMesh = function(c, T) {
+ var S = _.c.Matrix[0];
+ return c.getWorldMatrix().invertToRef(S), this._tmpRay ? m.TransformToRef(this, S, this._tmpRay) : this._tmpRay = m.Transform(this, S), c.intersects(this._tmpRay, T);
+ }, m.prototype.intersectsMeshes = function(c, T, S) {
+ S ? S.length = 0 : S = [];
+ for (var E = 0; E < c.length; E++) {
+ var g = this.intersectsMesh(c[E], T);
+ g.hit && S.push(g);
+ }
+ return S.sort(this._comparePickingInfo), S;
+ }, m.prototype._comparePickingInfo = function(c, T) {
+ return c.distance < T.distance ? -1 : c.distance > T.distance ? 1 : 0;
+ }, m.prototype.intersectionSegment = function(c, T, S) {
+ var E = this.origin, g = _.c.Vector3[0], l = _.c.Vector3[1], h = _.c.Vector3[2], v = _.c.Vector3[3];
+ T.subtractToRef(c, g), this.direction.scaleToRef(m.rayl, h), E.addToRef(h, l), c.subtractToRef(E, v);
+ var b, D, w, N, M = _.e.Dot(g, g), U = _.e.Dot(g, h), X = _.e.Dot(h, h), j = _.e.Dot(g, v), ne = _.e.Dot(h, v), te = M * X - U * U, de = te, pe = te;
+ te < m.smallnum ? (D = 0, de = 1, N = ne, pe = X) : (N = M * ne - U * j, (D = U * ne - X * j) < 0 ? (D = 0, N = ne, pe = X) : D > de && (D = de, N = ne + U, pe = X)), N < 0 ? (N = 0, -j < 0 ? D = 0 : -j > M ? D = de : (D = -j, de = M)) : N > pe && (N = pe, -j + U < 0 ? D = 0 : -j + U > M ? D = de : (D = -j + U, de = M)), b = Math.abs(D) < m.smallnum ? 0 : D / de, w = Math.abs(N) < m.smallnum ? 0 : N / pe;
+ var ae = _.c.Vector3[4];
+ h.scaleToRef(w, ae);
+ var ee = _.c.Vector3[5];
+ g.scaleToRef(b, ee), ee.addInPlace(v);
+ var K = _.c.Vector3[6];
+ return ee.subtractToRef(ae, K), w > 0 && w <= this.length && K.lengthSquared() < S * S ? ee.length() : -1;
+ }, m.prototype.update = function(c, T, S, E, g, l, h) {
+ return this.unprojectRayToRef(c, T, S, E, g, l, h), this;
+ }, m.Zero = function() {
+ return new m(_.e.Zero(), _.e.Zero());
+ }, m.CreateNew = function(c, T, S, E, g, l, h) {
+ return m.Zero().update(c, T, S, E, g, l, h);
+ }, m.CreateNewFromTo = function(c, T, S) {
+ S === void 0 && (S = _.a.IdentityReadOnly);
+ var E = T.subtract(c), g = Math.sqrt(E.x * E.x + E.y * E.y + E.z * E.z);
+ return E.normalize(), m.Transform(new m(c, E, g), S);
+ }, m.Transform = function(c, T) {
+ var S = new m(new _.e(0, 0, 0), new _.e(0, 0, 0));
+ return m.TransformToRef(c, T, S), S;
+ }, m.TransformToRef = function(c, T, S) {
+ _.e.TransformCoordinatesToRef(c.origin, T, S.origin), _.e.TransformNormalToRef(c.direction, T, S.direction), S.length = c.length;
+ var E = S.direction, g = E.length();
+ if (g !== 0 && g !== 1) {
+ var l = 1 / g;
+ E.x *= l, E.y *= l, E.z *= l, S.length *= g;
+ }
+ }, m.prototype.unprojectRayToRef = function(c, T, S, E, g, l, h) {
+ var v = _.c.Matrix[0];
+ g.multiplyToRef(l, v), v.multiplyToRef(h, v), v.invert();
+ var b = _.c.Vector3[0];
+ b.x = c / S * 2 - 1, b.y = -(T / E * 2 - 1), b.z = -1;
+ var D = _.c.Vector3[1].copyFromFloats(b.x, b.y, 1), w = _.c.Vector3[2], N = _.c.Vector3[3];
+ _.e._UnprojectFromInvertedMatrixToRef(b, v, w), _.e._UnprojectFromInvertedMatrixToRef(D, v, N), this.origin.copyFrom(w), N.subtractToRef(w, this.direction), this.direction.normalize();
+ }, m._TmpVector3 = V.a.BuildArray(6, _.e.Zero), m.smallnum = 1e-8, m.rayl = 1e9, m;
+ }();
+ I.a.prototype.createPickingRay = function(m, c, T, S, E) {
+ E === void 0 && (E = !1);
+ var g = x.Zero();
+ return this.createPickingRayToRef(m, c, T, g, S, E), g;
+ }, I.a.prototype.createPickingRayToRef = function(m, c, T, S, E, g) {
+ g === void 0 && (g = !1);
+ var l = this.getEngine();
+ if (!E) {
+ if (!this.activeCamera)
+ return this;
+ E = this.activeCamera;
+ }
+ var h = E.viewport.toGlobal(l.getRenderWidth(), l.getRenderHeight());
+ return m = m / l.getHardwareScalingLevel() - h.x, c = c / l.getHardwareScalingLevel() - (l.getRenderHeight() - h.y - h.height), S.update(m, c, h.width, h.height, T || _.a.IdentityReadOnly, g ? _.a.IdentityReadOnly : E.getViewMatrix(), E.getProjectionMatrix()), this;
+ }, I.a.prototype.createPickingRayInCameraSpace = function(m, c, T) {
+ var S = x.Zero();
+ return this.createPickingRayInCameraSpaceToRef(m, c, S, T), S;
+ }, I.a.prototype.createPickingRayInCameraSpaceToRef = function(m, c, T, S) {
+ if (!C.a)
+ return this;
+ var E = this.getEngine();
+ if (!S) {
+ if (!this.activeCamera)
+ throw new Error("Active camera not set");
+ S = this.activeCamera;
+ }
+ var g = S.viewport.toGlobal(E.getRenderWidth(), E.getRenderHeight()), l = _.a.Identity();
+ return m = m / E.getHardwareScalingLevel() - g.x, c = c / E.getHardwareScalingLevel() - (E.getRenderHeight() - g.y - g.height), T.update(m, c, g.width, g.height, l, l, S.getProjectionMatrix()), this;
+ }, I.a.prototype._internalPickForMesh = function(m, c, T, S, E, g, l, h) {
+ var v = c(S), b = T.intersects(v, E, l, g, S, h);
+ return b && b.hit ? !E && m != null && b.distance >= m.distance ? null : b : null;
+ }, I.a.prototype._internalPick = function(m, c, T, S, E) {
+ if (!C.a)
+ return null;
+ for (var g = null, l = 0; l < this.meshes.length; l++) {
+ var h = this.meshes[l];
+ if (c) {
+ if (!c(h))
+ continue;
+ } else if (!h.isEnabled() || !h.isVisible || !h.isPickable)
+ continue;
+ var v, b = h.skeleton && h.skeleton.overrideMesh ? h.skeleton.overrideMesh.getWorldMatrix() : h.getWorldMatrix();
+ if (h.hasThinInstances && h.thinInstanceEnablePicking) {
+ if (v = this._internalPickForMesh(g, m, h, b, !0, !0, E)) {
+ if (S)
+ return g;
+ for (var D = _.c.Matrix[1], w = h.thinInstanceGetWorldMatrices(), N = 0; N < w.length; N++) {
+ w[N].multiplyToRef(b, D);
+ var M = this._internalPickForMesh(g, m, h, D, T, S, E, !0);
+ if (M && ((g = M).thinInstanceIndex = N, T))
+ return g;
+ }
+ }
+ } else if ((v = this._internalPickForMesh(g, m, h, b, T, S, E)) && (g = v, T))
+ return g;
+ }
+ return g || new C.a();
+ }, I.a.prototype._internalMultiPick = function(m, c, T) {
+ if (!C.a)
+ return null;
+ for (var S = new Array(), E = 0; E < this.meshes.length; E++) {
+ var g = this.meshes[E];
+ if (c) {
+ if (!c(g))
+ continue;
+ } else if (!g.isEnabled() || !g.isVisible || !g.isPickable)
+ continue;
+ var l, h = g.skeleton && g.skeleton.overrideMesh ? g.skeleton.overrideMesh.getWorldMatrix() : g.getWorldMatrix();
+ if (g.hasThinInstances && g.thinInstanceEnablePicking) {
+ if (l = this._internalPickForMesh(null, m, g, h, !0, !0, T))
+ for (var v = _.c.Matrix[1], b = g.thinInstanceGetWorldMatrices(), D = 0; D < b.length; D++) {
+ b[D].multiplyToRef(h, v);
+ var w = this._internalPickForMesh(null, m, g, v, !1, !1, T, !0);
+ w && (w.thinInstanceIndex = D, S.push(w));
+ }
+ } else
+ (l = this._internalPickForMesh(null, m, g, h, !1, !1, T)) && S.push(l);
+ }
+ return S;
+ }, I.a.prototype.pickWithBoundingInfo = function(m, c, T, S, E) {
+ var g = this;
+ if (!C.a)
+ return null;
+ var l = this._internalPick(function(h) {
+ return g._tempPickingRay || (g._tempPickingRay = x.Zero()), g.createPickingRayToRef(m, c, h, g._tempPickingRay, E || null), g._tempPickingRay;
+ }, T, S, !0);
+ return l && (l.ray = this.createPickingRay(m, c, _.a.Identity(), E || null)), l;
+ }, I.a.prototype.pick = function(m, c, T, S, E, g) {
+ var l = this;
+ if (!C.a)
+ return null;
+ var h = this._internalPick(function(v) {
+ return l._tempPickingRay || (l._tempPickingRay = x.Zero()), l.createPickingRayToRef(m, c, v, l._tempPickingRay, E || null), l._tempPickingRay;
+ }, T, S, !1, g);
+ return h && (h.ray = this.createPickingRay(m, c, _.a.Identity(), E || null)), h;
+ }, I.a.prototype.pickWithRay = function(m, c, T, S) {
+ var E = this, g = this._internalPick(function(l) {
+ return E._pickWithRayInverseMatrix || (E._pickWithRayInverseMatrix = _.a.Identity()), l.invertToRef(E._pickWithRayInverseMatrix), E._cachedRayForTransform || (E._cachedRayForTransform = x.Zero()), x.TransformToRef(m, E._pickWithRayInverseMatrix, E._cachedRayForTransform), E._cachedRayForTransform;
+ }, c, T, !1, S);
+ return g && (g.ray = m), g;
+ }, I.a.prototype.multiPick = function(m, c, T, S, E) {
+ var g = this;
+ return this._internalMultiPick(function(l) {
+ return g.createPickingRay(m, c, l, S || null);
+ }, T, E);
+ }, I.a.prototype.multiPickWithRay = function(m, c, T) {
+ var S = this;
+ return this._internalMultiPick(function(E) {
+ return S._pickWithRayInverseMatrix || (S._pickWithRayInverseMatrix = _.a.Identity()), E.invertToRef(S._pickWithRayInverseMatrix), S._cachedRayForTransform || (S._cachedRayForTransform = x.Zero()), x.TransformToRef(m, S._pickWithRayInverseMatrix, S._cachedRayForTransform), S._cachedRayForTransform;
+ }, c, T);
+ }, O.a.prototype.getForwardRay = function(m, c, T) {
+ return m === void 0 && (m = 100), this.getForwardRayToRef(new x(_.e.Zero(), _.e.Zero(), m), m, c, T);
+ }, O.a.prototype.getForwardRayToRef = function(m, c, T, S) {
+ return c === void 0 && (c = 100), T || (T = this.getWorldMatrix()), m.length = c, S ? m.origin.copyFrom(S) : m.origin.copyFrom(this.position), _.c.Vector3[2].set(0, 0, this._scene.useRightHandedSystem ? -1 : 1), _.e.TransformNormalToRef(_.c.Vector3[2], T, _.c.Vector3[3]), _.e.NormalizeToRef(_.c.Vector3[3], m.direction), m;
+ };
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return O;
+ });
+ var V = f(0), _ = f(7), C = f(16), u = f(98), I = f(4);
+ C.a.CreateLineSystem = function(x) {
+ for (var m = [], c = [], T = x.lines, S = x.colors, E = [], g = 0, l = 0; l < T.length; l++)
+ for (var h = T[l], v = 0; v < h.length; v++) {
+ if (c.push(h[v].x, h[v].y, h[v].z), S) {
+ var b = S[l];
+ E.push(b[v].r, b[v].g, b[v].b, b[v].a);
+ }
+ v > 0 && (m.push(g - 1), m.push(g)), g++;
+ }
+ var D = new C.a();
+ return D.indices = m, D.positions = c, S && (D.colors = E), D;
+ }, C.a.CreateDashedLines = function(x) {
+ var m, c, T = x.dashSize || 3, S = x.gapSize || 1, E = x.dashNb || 200, g = x.points, l = new Array(), h = new Array(), v = V.e.Zero(), b = 0, D = 0, w = 0, N = 0, M = 0;
+ for (M = 0; M < g.length - 1; M++)
+ g[M + 1].subtractToRef(g[M], v), b += v.length();
+ for (c = T * (m = b / E) / (T + S), M = 0; M < g.length - 1; M++) {
+ g[M + 1].subtractToRef(g[M], v), D = Math.floor(v.length() / m), v.normalize();
+ for (var U = 0; U < D; U++)
+ w = m * U, l.push(g[M].x + w * v.x, g[M].y + w * v.y, g[M].z + w * v.z), l.push(g[M].x + (w + c) * v.x, g[M].y + (w + c) * v.y, g[M].z + (w + c) * v.z), h.push(N, N + 1), N += 2;
+ }
+ var X = new C.a();
+ return X.positions = l, X.indices = h, X;
+ }, _.a.CreateLines = function(x, m, c, T, S) {
+ c === void 0 && (c = null), T === void 0 && (T = !1), S === void 0 && (S = null);
+ var E = { points: m, updatable: T, instance: S };
+ return O.CreateLines(x, E, c);
+ }, _.a.CreateDashedLines = function(x, m, c, T, S, E, g, l) {
+ E === void 0 && (E = null);
+ var h = { points: m, dashSize: c, gapSize: T, dashNb: S, updatable: g, instance: l };
+ return O.CreateDashedLines(x, h, E);
+ };
+ var O = function() {
+ function x() {
+ }
+ return x.CreateLineSystem = function(m, c, T) {
+ var S = c.instance, E = c.lines, g = c.colors;
+ if (S) {
+ var l, h, v = S.getVerticesData(I.b.PositionKind);
+ g && (l = S.getVerticesData(I.b.ColorKind));
+ for (var b = 0, D = 0, w = 0; w < E.length; w++)
+ for (var N = E[w], M = 0; M < N.length; M++)
+ v[b] = N[M].x, v[b + 1] = N[M].y, v[b + 2] = N[M].z, g && l && (h = g[w], l[D] = h[M].r, l[D + 1] = h[M].g, l[D + 2] = h[M].b, l[D + 3] = h[M].a, D += 4), b += 3;
+ return S.updateVerticesData(I.b.PositionKind, v, !1, !1), g && l && S.updateVerticesData(I.b.ColorKind, l, !1, !1), S;
+ }
+ var U = !!g, X = new u.b(m, T, null, void 0, void 0, U, c.useVertexAlpha);
+ return C.a.CreateLineSystem(c).applyToMesh(X, c.updatable), X;
+ }, x.CreateLines = function(m, c, T) {
+ T === void 0 && (T = null);
+ var S = c.colors ? [c.colors] : null;
+ return x.CreateLineSystem(m, { lines: [c.points], updatable: c.updatable, instance: c.instance, colors: S, useVertexAlpha: c.useVertexAlpha }, T);
+ }, x.CreateDashedLines = function(m, c, T) {
+ T === void 0 && (T = null);
+ var S = c.points, E = c.instance, g = c.gapSize || 1, l = c.dashSize || 3;
+ if (E)
+ return E.updateMeshPositions(function(v) {
+ var b, D, w = V.e.Zero(), N = v.length / 6, M = 0, U = 0, X = 0, j = 0, ne = 0, te = 0;
+ for (ne = 0; ne < S.length - 1; ne++)
+ S[ne + 1].subtractToRef(S[ne], w), M += w.length();
+ b = M / N;
+ var de = E._creationDataStorage.dashSize;
+ for (D = de * b / (de + E._creationDataStorage.gapSize), ne = 0; ne < S.length - 1; ne++)
+ for (S[ne + 1].subtractToRef(S[ne], w), U = Math.floor(w.length() / b), w.normalize(), te = 0; te < U && j < v.length; )
+ X = b * te, v[j] = S[ne].x + X * w.x, v[j + 1] = S[ne].y + X * w.y, v[j + 2] = S[ne].z + X * w.z, v[j + 3] = S[ne].x + (X + D) * w.x, v[j + 4] = S[ne].y + (X + D) * w.y, v[j + 5] = S[ne].z + (X + D) * w.z, j += 6, te++;
+ for (; j < v.length; )
+ v[j] = S[ne].x, v[j + 1] = S[ne].y, v[j + 2] = S[ne].z, j += 3;
+ }, !1), E;
+ var h = new u.b(m, T, null, void 0, void 0, void 0, c.useVertexAlpha);
+ return C.a.CreateDashedLines(c).applyToMesh(h, c.updatable), h._creationDataStorage = new _.b(), h._creationDataStorage.dashSize = l, h._creationDataStorage.gapSize = g, h;
+ }, x;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return u;
+ });
+ var V = f(34), _ = f(8), C = function(I, O) {
+ return I ? I.getClassName && I.getClassName() === "Mesh" ? null : I.getClassName && I.getClassName() === "SubMesh" ? I.clone(O) : I.clone ? I.clone() : null : null;
+ }, u = function() {
+ function I() {
+ }
+ return I.DeepCopy = function(O, x, m, c) {
+ for (var T = 0, S = function(b) {
+ var D = [];
+ do
+ Object.getOwnPropertyNames(b).forEach(function(w) {
+ D.indexOf(w) === -1 && D.push(w);
+ });
+ while (b = Object.getPrototypeOf(b));
+ return D;
+ }(O); T < S.length; T++) {
+ var E = S[T];
+ if ((E[0] !== "_" || c && c.indexOf(E) !== -1) && !(V.a.EndsWith(E, "Observable") || m && m.indexOf(E) !== -1)) {
+ var g = O[E], l = typeof g;
+ if (l !== "function")
+ try {
+ if (l === "object")
+ if (g instanceof Array) {
+ if (x[E] = [], g.length > 0)
+ if (typeof g[0] == "object")
+ for (var h = 0; h < g.length; h++) {
+ var v = C(g[h], x);
+ x[E].indexOf(v) === -1 && x[E].push(v);
+ }
+ else
+ x[E] = g.slice(0);
+ } else
+ x[E] = C(g, x);
+ else
+ x[E] = g;
+ } catch (b) {
+ _.a.Warn(b.message);
+ }
+ }
+ }
+ }, I;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "b", function() {
+ return m;
+ }), f.d(A, "a", function() {
+ return c;
+ });
+ var V = f(1), _ = f(3), C = f(6), u = f(12), I = f(9), O = f(76), x = f(121), m = function(T) {
+ function S() {
+ var E = T.call(this) || this;
+ return E.IMAGEPROCESSING = !1, E.VIGNETTE = !1, E.VIGNETTEBLENDMODEMULTIPLY = !1, E.VIGNETTEBLENDMODEOPAQUE = !1, E.TONEMAPPING = !1, E.TONEMAPPING_ACES = !1, E.CONTRAST = !1, E.COLORCURVES = !1, E.COLORGRADING = !1, E.COLORGRADING3D = !1, E.SAMPLER3DGREENDEPTH = !1, E.SAMPLER3DBGRMAP = !1, E.IMAGEPROCESSINGPOSTPROCESS = !1, E.EXPOSURE = !1, E.rebuild(), E;
+ }
+ return Object(V.d)(S, T), S;
+ }(O.a), c = function() {
+ function T() {
+ this.colorCurves = new x.a(), this._colorCurvesEnabled = !1, this._colorGradingEnabled = !1, this._colorGradingWithGreenDepth = !0, this._colorGradingBGR = !0, this._exposure = 1, this._toneMappingEnabled = !1, this._toneMappingType = T.TONEMAPPING_STANDARD, this._contrast = 1, this.vignetteStretch = 0, this.vignetteCentreX = 0, this.vignetteCentreY = 0, this.vignetteWeight = 1.5, this.vignetteColor = new I.b(0, 0, 0, 0), this.vignetteCameraFov = 0.5, this._vignetteBlendMode = T.VIGNETTEMODE_MULTIPLY, this._vignetteEnabled = !1, this._applyByPostProcess = !1, this._isEnabled = !0, this.onUpdateParameters = new C.c();
+ }
+ return Object.defineProperty(T.prototype, "colorCurvesEnabled", { get: function() {
+ return this._colorCurvesEnabled;
+ }, set: function(S) {
+ this._colorCurvesEnabled !== S && (this._colorCurvesEnabled = S, this._updateParameters());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(T.prototype, "colorGradingTexture", { get: function() {
+ return this._colorGradingTexture;
+ }, set: function(S) {
+ this._colorGradingTexture !== S && (this._colorGradingTexture = S, this._updateParameters());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(T.prototype, "colorGradingEnabled", { get: function() {
+ return this._colorGradingEnabled;
+ }, set: function(S) {
+ this._colorGradingEnabled !== S && (this._colorGradingEnabled = S, this._updateParameters());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(T.prototype, "colorGradingWithGreenDepth", { get: function() {
+ return this._colorGradingWithGreenDepth;
+ }, set: function(S) {
+ this._colorGradingWithGreenDepth !== S && (this._colorGradingWithGreenDepth = S, this._updateParameters());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(T.prototype, "colorGradingBGR", { get: function() {
+ return this._colorGradingBGR;
+ }, set: function(S) {
+ this._colorGradingBGR !== S && (this._colorGradingBGR = S, this._updateParameters());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(T.prototype, "exposure", { get: function() {
+ return this._exposure;
+ }, set: function(S) {
+ this._exposure !== S && (this._exposure = S, this._updateParameters());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(T.prototype, "toneMappingEnabled", { get: function() {
+ return this._toneMappingEnabled;
+ }, set: function(S) {
+ this._toneMappingEnabled !== S && (this._toneMappingEnabled = S, this._updateParameters());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(T.prototype, "toneMappingType", { get: function() {
+ return this._toneMappingType;
+ }, set: function(S) {
+ this._toneMappingType !== S && (this._toneMappingType = S, this._updateParameters());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(T.prototype, "contrast", { get: function() {
+ return this._contrast;
+ }, set: function(S) {
+ this._contrast !== S && (this._contrast = S, this._updateParameters());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(T.prototype, "vignetteBlendMode", { get: function() {
+ return this._vignetteBlendMode;
+ }, set: function(S) {
+ this._vignetteBlendMode !== S && (this._vignetteBlendMode = S, this._updateParameters());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(T.prototype, "vignetteEnabled", { get: function() {
+ return this._vignetteEnabled;
+ }, set: function(S) {
+ this._vignetteEnabled !== S && (this._vignetteEnabled = S, this._updateParameters());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(T.prototype, "applyByPostProcess", { get: function() {
+ return this._applyByPostProcess;
+ }, set: function(S) {
+ this._applyByPostProcess !== S && (this._applyByPostProcess = S, this._updateParameters());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(T.prototype, "isEnabled", { get: function() {
+ return this._isEnabled;
+ }, set: function(S) {
+ this._isEnabled !== S && (this._isEnabled = S, this._updateParameters());
+ }, enumerable: !1, configurable: !0 }), T.prototype._updateParameters = function() {
+ this.onUpdateParameters.notifyObservers(this);
+ }, T.prototype.getClassName = function() {
+ return "ImageProcessingConfiguration";
+ }, T.PrepareUniforms = function(S, E) {
+ E.EXPOSURE && S.push("exposureLinear"), E.CONTRAST && S.push("contrast"), E.COLORGRADING && S.push("colorTransformSettings"), E.VIGNETTE && (S.push("vInverseScreenSize"), S.push("vignetteSettings1"), S.push("vignetteSettings2")), E.COLORCURVES && x.a.PrepareUniforms(S);
+ }, T.PrepareSamplers = function(S, E) {
+ E.COLORGRADING && S.push("txColorTransform");
+ }, T.prototype.prepareDefines = function(S, E) {
+ if (E === void 0 && (E = !1), E !== this.applyByPostProcess || !this._isEnabled)
+ return S.VIGNETTE = !1, S.TONEMAPPING = !1, S.TONEMAPPING_ACES = !1, S.CONTRAST = !1, S.EXPOSURE = !1, S.COLORCURVES = !1, S.COLORGRADING = !1, S.COLORGRADING3D = !1, S.IMAGEPROCESSING = !1, void (S.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess && this._isEnabled);
+ switch (S.VIGNETTE = this.vignetteEnabled, S.VIGNETTEBLENDMODEMULTIPLY = this.vignetteBlendMode === T._VIGNETTEMODE_MULTIPLY, S.VIGNETTEBLENDMODEOPAQUE = !S.VIGNETTEBLENDMODEMULTIPLY, S.TONEMAPPING = this.toneMappingEnabled, this._toneMappingType) {
+ case T.TONEMAPPING_ACES:
+ S.TONEMAPPING_ACES = !0;
+ break;
+ default:
+ S.TONEMAPPING_ACES = !1;
+ }
+ S.CONTRAST = this.contrast !== 1, S.EXPOSURE = this.exposure !== 1, S.COLORCURVES = this.colorCurvesEnabled && !!this.colorCurves, S.COLORGRADING = this.colorGradingEnabled && !!this.colorGradingTexture, S.COLORGRADING ? S.COLORGRADING3D = this.colorGradingTexture.is3D : S.COLORGRADING3D = !1, S.SAMPLER3DGREENDEPTH = this.colorGradingWithGreenDepth, S.SAMPLER3DBGRMAP = this.colorGradingBGR, S.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess, S.IMAGEPROCESSING = S.VIGNETTE || S.TONEMAPPING || S.CONTRAST || S.EXPOSURE || S.COLORCURVES || S.COLORGRADING;
+ }, T.prototype.isReady = function() {
+ return !this.colorGradingEnabled || !this.colorGradingTexture || this.colorGradingTexture.isReady();
+ }, T.prototype.bind = function(S, E) {
+ if (this._colorCurvesEnabled && this.colorCurves && x.a.Bind(this.colorCurves, S), this._vignetteEnabled) {
+ var g = 1 / S.getEngine().getRenderWidth(), l = 1 / S.getEngine().getRenderHeight();
+ S.setFloat2("vInverseScreenSize", g, l);
+ var h = E ?? l / g, v = Math.tan(0.5 * this.vignetteCameraFov), b = v * h, D = Math.sqrt(b * v);
+ b = u.b.Mix(b, D, this.vignetteStretch), v = u.b.Mix(v, D, this.vignetteStretch), S.setFloat4("vignetteSettings1", b, v, -b * this.vignetteCentreX, -v * this.vignetteCentreY);
+ var w = -2 * this.vignetteWeight;
+ S.setFloat4("vignetteSettings2", this.vignetteColor.r, this.vignetteColor.g, this.vignetteColor.b, w);
+ }
+ if (S.setFloat("exposureLinear", this.exposure), S.setFloat("contrast", this.contrast), this.colorGradingTexture) {
+ S.setTexture("txColorTransform", this.colorGradingTexture);
+ var N = this.colorGradingTexture.getSize().height;
+ S.setFloat4("colorTransformSettings", (N - 1) / N, 0.5 / N, N, this.colorGradingTexture.level);
+ }
+ }, T.prototype.clone = function() {
+ return _.a.Clone(function() {
+ return new T();
+ }, this);
+ }, T.prototype.serialize = function() {
+ return _.a.Serialize(this);
+ }, T.Parse = function(S) {
+ return _.a.Parse(function() {
+ return new T();
+ }, S, null, null);
+ }, Object.defineProperty(T, "VIGNETTEMODE_MULTIPLY", { get: function() {
+ return this._VIGNETTEMODE_MULTIPLY;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(T, "VIGNETTEMODE_OPAQUE", { get: function() {
+ return this._VIGNETTEMODE_OPAQUE;
+ }, enumerable: !1, configurable: !0 }), T.TONEMAPPING_STANDARD = 0, T.TONEMAPPING_ACES = 1, T._VIGNETTEMODE_MULTIPLY = 0, T._VIGNETTEMODE_OPAQUE = 1, Object(V.c)([Object(_.g)()], T.prototype, "colorCurves", void 0), Object(V.c)([Object(_.c)()], T.prototype, "_colorCurvesEnabled", void 0), Object(V.c)([Object(_.m)("colorGradingTexture")], T.prototype, "_colorGradingTexture", void 0), Object(V.c)([Object(_.c)()], T.prototype, "_colorGradingEnabled", void 0), Object(V.c)([Object(_.c)()], T.prototype, "_colorGradingWithGreenDepth", void 0), Object(V.c)([Object(_.c)()], T.prototype, "_colorGradingBGR", void 0), Object(V.c)([Object(_.c)()], T.prototype, "_exposure", void 0), Object(V.c)([Object(_.c)()], T.prototype, "_toneMappingEnabled", void 0), Object(V.c)([Object(_.c)()], T.prototype, "_toneMappingType", void 0), Object(V.c)([Object(_.c)()], T.prototype, "_contrast", void 0), Object(V.c)([Object(_.c)()], T.prototype, "vignetteStretch", void 0), Object(V.c)([Object(_.c)()], T.prototype, "vignetteCentreX", void 0), Object(V.c)([Object(_.c)()], T.prototype, "vignetteCentreY", void 0), Object(V.c)([Object(_.c)()], T.prototype, "vignetteWeight", void 0), Object(V.c)([Object(_.f)()], T.prototype, "vignetteColor", void 0), Object(V.c)([Object(_.c)()], T.prototype, "vignetteCameraFov", void 0), Object(V.c)([Object(_.c)()], T.prototype, "_vignetteBlendMode", void 0), Object(V.c)([Object(_.c)()], T.prototype, "_vignetteEnabled", void 0), Object(V.c)([Object(_.c)()], T.prototype, "_applyByPostProcess", void 0), Object(V.c)([Object(_.c)()], T.prototype, "_isEnabled", void 0), T;
+ }();
+ _.a._ImageProcessingConfigurationParser = c.Parse;
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return T;
+ });
+ var V = f(44), _ = f(0), C = f(2), u = f(103), I = f(113), O = { min: 0, max: 0 }, x = { min: 0, max: 0 }, m = function(S, E, g) {
+ var l = _.e.Dot(E.centerWorld, S), h = Math.abs(_.e.Dot(E.directions[0], S)) * E.extendSize.x + Math.abs(_.e.Dot(E.directions[1], S)) * E.extendSize.y + Math.abs(_.e.Dot(E.directions[2], S)) * E.extendSize.z;
+ g.min = l - h, g.max = l + h;
+ }, c = function(S, E, g) {
+ return m(S, E, O), m(S, g, x), !(O.min > x.max || x.min > O.max);
+ }, T = function() {
+ function S(E, g, l) {
+ this._isLocked = !1, this.boundingBox = new u.a(E, g, l), this.boundingSphere = new I.a(E, g, l);
+ }
+ return S.prototype.reConstruct = function(E, g, l) {
+ this.boundingBox.reConstruct(E, g, l), this.boundingSphere.reConstruct(E, g, l);
+ }, Object.defineProperty(S.prototype, "minimum", { get: function() {
+ return this.boundingBox.minimum;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(S.prototype, "maximum", { get: function() {
+ return this.boundingBox.maximum;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(S.prototype, "isLocked", { get: function() {
+ return this._isLocked;
+ }, set: function(E) {
+ this._isLocked = E;
+ }, enumerable: !1, configurable: !0 }), S.prototype.update = function(E) {
+ this._isLocked || (this.boundingBox._update(E), this.boundingSphere._update(E));
+ }, S.prototype.centerOn = function(E, g) {
+ var l = S.TmpVector3[0].copyFrom(E).subtractInPlace(g), h = S.TmpVector3[1].copyFrom(E).addInPlace(g);
+ return this.boundingBox.reConstruct(l, h, this.boundingBox.getWorldMatrix()), this.boundingSphere.reConstruct(l, h, this.boundingBox.getWorldMatrix()), this;
+ }, S.prototype.scale = function(E) {
+ return this.boundingBox.scale(E), this.boundingSphere.scale(E), this;
+ }, S.prototype.isInFrustum = function(E, g) {
+ return g === void 0 && (g = C.a.MESHES_CULLINGSTRATEGY_STANDARD), !(g !== C.a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION && g !== C.a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY || !this.boundingSphere.isCenterInFrustum(E)) || !!this.boundingSphere.isInFrustum(E) && (!(g !== C.a.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY && g !== C.a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY) || this.boundingBox.isInFrustum(E));
+ }, Object.defineProperty(S.prototype, "diagonalLength", { get: function() {
+ var E = this.boundingBox;
+ return E.maximumWorld.subtractToRef(E.minimumWorld, S.TmpVector3[0]).length();
+ }, enumerable: !1, configurable: !0 }), S.prototype.isCompletelyInFrustum = function(E) {
+ return this.boundingBox.isCompletelyInFrustum(E);
+ }, S.prototype._checkCollision = function(E) {
+ return E._canDoCollision(this.boundingSphere.centerWorld, this.boundingSphere.radiusWorld, this.boundingBox.minimumWorld, this.boundingBox.maximumWorld);
+ }, S.prototype.intersectsPoint = function(E) {
+ return !!this.boundingSphere.centerWorld && !!this.boundingSphere.intersectsPoint(E) && !!this.boundingBox.intersectsPoint(E);
+ }, S.prototype.intersects = function(E, g) {
+ if (!I.a.Intersects(this.boundingSphere, E.boundingSphere) || !u.a.Intersects(this.boundingBox, E.boundingBox))
+ return !1;
+ if (!g)
+ return !0;
+ var l = this.boundingBox, h = E.boundingBox;
+ return !!c(l.directions[0], l, h) && !!c(l.directions[1], l, h) && !!c(l.directions[2], l, h) && !!c(h.directions[0], l, h) && !!c(h.directions[1], l, h) && !!c(h.directions[2], l, h) && !!c(_.e.Cross(l.directions[0], h.directions[0]), l, h) && !!c(_.e.Cross(l.directions[0], h.directions[1]), l, h) && !!c(_.e.Cross(l.directions[0], h.directions[2]), l, h) && !!c(_.e.Cross(l.directions[1], h.directions[0]), l, h) && !!c(_.e.Cross(l.directions[1], h.directions[1]), l, h) && !!c(_.e.Cross(l.directions[1], h.directions[2]), l, h) && !!c(_.e.Cross(l.directions[2], h.directions[0]), l, h) && !!c(_.e.Cross(l.directions[2], h.directions[1]), l, h) && !!c(_.e.Cross(l.directions[2], h.directions[2]), l, h);
+ }, S.TmpVector3 = V.a.BuildArray(2, _.e.Zero), S;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return V;
+ });
+ var V = function() {
+ function _() {
+ }
+ return _.BuildArray = function(C, u) {
+ for (var I = [], O = 0; O < C; ++O)
+ I.push(u());
+ return I;
+ }, _;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return u;
+ });
+ var V = f(0), _ = f(7), C = f(16);
+ C.a.CreateSphere = function(I) {
+ for (var O = I.segments || 32, x = I.diameterX || I.diameter || 1, m = I.diameterY || I.diameter || 1, c = I.diameterZ || I.diameter || 1, T = I.arc && (I.arc <= 0 || I.arc > 1) ? 1 : I.arc || 1, S = I.slice && I.slice <= 0 ? 1 : I.slice || 1, E = I.sideOrientation === 0 ? 0 : I.sideOrientation || C.a.DEFAULTSIDE, g = !!I.dedupTopBottomIndices, l = new V.e(x / 2, m / 2, c / 2), h = 2 + O, v = 2 * h, b = [], D = [], w = [], N = [], M = 0; M <= h; M++) {
+ for (var U = M / h, X = U * Math.PI * S, j = 0; j <= v; j++) {
+ var ne = j / v, te = ne * Math.PI * 2 * T, de = V.a.RotationZ(-X), pe = V.a.RotationY(te), ae = V.e.TransformCoordinates(V.e.Up(), de), ee = V.e.TransformCoordinates(ae, pe), K = ee.multiply(l), $ = ee.divide(l).normalize();
+ D.push(K.x, K.y, K.z), w.push($.x, $.y, $.z), N.push(ne, U);
+ }
+ if (M > 0)
+ for (var L = D.length / 3, G = L - 2 * (v + 1); G + v + 2 < L; G++)
+ g ? (M > 1 && (b.push(G), b.push(G + 1), b.push(G + v + 1)), (M < h || S < 1) && (b.push(G + v + 1), b.push(G + 1), b.push(G + v + 2))) : (b.push(G), b.push(G + 1), b.push(G + v + 1), b.push(G + v + 1), b.push(G + 1), b.push(G + v + 2));
+ }
+ C.a._ComputeSides(E, D, b, w, N, I.frontUVs, I.backUVs);
+ var Q = new C.a();
+ return Q.indices = b, Q.positions = D, Q.normals = w, Q.uvs = N, Q;
+ }, _.a.CreateSphere = function(I, O, x, m, c, T) {
+ var S = { segments: O, diameterX: x, diameterY: x, diameterZ: x, sideOrientation: T, updatable: c };
+ return u.CreateSphere(I, S, m);
+ };
+ var u = function() {
+ function I() {
+ }
+ return I.CreateSphere = function(O, x, m) {
+ m === void 0 && (m = null);
+ var c = new _.a(O, m);
+ return x.sideOrientation = _.a._GetDefaultSideOrientation(x.sideOrientation), c._originalBuilderSideOrientation = x.sideOrientation, C.a.CreateSphere(x).applyToMesh(c, x.updatable), c;
+ }, I;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return x;
+ });
+ var V = f(1), _ = f(3), C = f(6), u = f(0), I = f(29), O = f(23), x = function(m) {
+ function c(T, S, E) {
+ S === void 0 && (S = null), E === void 0 && (E = !0);
+ var g = m.call(this, T, S) || this;
+ return g._forward = new u.e(0, 0, 1), g._forwardInverted = new u.e(0, 0, -1), g._up = new u.e(0, 1, 0), g._right = new u.e(1, 0, 0), g._rightInverted = new u.e(-1, 0, 0), g._position = u.e.Zero(), g._rotation = u.e.Zero(), g._rotationQuaternion = null, g._scaling = u.e.One(), g._isDirty = !1, g._transformToBoneReferal = null, g._isAbsoluteSynced = !1, g._billboardMode = c.BILLBOARDMODE_NONE, g._preserveParentRotationForBillboard = !1, g.scalingDeterminant = 1, g._infiniteDistance = !1, g.ignoreNonUniformScaling = !1, g.reIntegrateRotationIntoRotationQuaternion = !1, g._poseMatrix = null, g._localMatrix = u.a.Zero(), g._usePivotMatrix = !1, g._absolutePosition = u.e.Zero(), g._absoluteScaling = u.e.Zero(), g._absoluteRotationQuaternion = u.b.Identity(), g._pivotMatrix = u.a.Identity(), g._postMultiplyPivotMatrix = !1, g._isWorldMatrixFrozen = !1, g._indexInSceneTransformNodesArray = -1, g.onAfterWorldMatrixUpdateObservable = new C.c(), g._nonUniformScaling = !1, E && g.getScene().addTransformNode(g), g;
+ }
+ return Object(V.d)(c, m), Object.defineProperty(c.prototype, "billboardMode", { get: function() {
+ return this._billboardMode;
+ }, set: function(T) {
+ this._billboardMode !== T && (this._billboardMode = T);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(c.prototype, "preserveParentRotationForBillboard", { get: function() {
+ return this._preserveParentRotationForBillboard;
+ }, set: function(T) {
+ T !== this._preserveParentRotationForBillboard && (this._preserveParentRotationForBillboard = T);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(c.prototype, "infiniteDistance", { get: function() {
+ return this._infiniteDistance;
+ }, set: function(T) {
+ this._infiniteDistance !== T && (this._infiniteDistance = T);
+ }, enumerable: !1, configurable: !0 }), c.prototype.getClassName = function() {
+ return "TransformNode";
+ }, Object.defineProperty(c.prototype, "position", { get: function() {
+ return this._position;
+ }, set: function(T) {
+ this._position = T, this._isDirty = !0;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(c.prototype, "rotation", { get: function() {
+ return this._rotation;
+ }, set: function(T) {
+ this._rotation = T, this._rotationQuaternion = null, this._isDirty = !0;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(c.prototype, "scaling", { get: function() {
+ return this._scaling;
+ }, set: function(T) {
+ this._scaling = T, this._isDirty = !0;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(c.prototype, "rotationQuaternion", { get: function() {
+ return this._rotationQuaternion;
+ }, set: function(T) {
+ this._rotationQuaternion = T, T && this._rotation.setAll(0), this._isDirty = !0;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(c.prototype, "forward", { get: function() {
+ return u.e.Normalize(u.e.TransformNormal(this.getScene().useRightHandedSystem ? this._forwardInverted : this._forward, this.getWorldMatrix()));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(c.prototype, "up", { get: function() {
+ return u.e.Normalize(u.e.TransformNormal(this._up, this.getWorldMatrix()));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(c.prototype, "right", { get: function() {
+ return u.e.Normalize(u.e.TransformNormal(this.getScene().useRightHandedSystem ? this._rightInverted : this._right, this.getWorldMatrix()));
+ }, enumerable: !1, configurable: !0 }), c.prototype.updatePoseMatrix = function(T) {
+ return this._poseMatrix ? (this._poseMatrix.copyFrom(T), this) : (this._poseMatrix = T.clone(), this);
+ }, c.prototype.getPoseMatrix = function() {
+ return this._poseMatrix || (this._poseMatrix = u.a.Identity()), this._poseMatrix;
+ }, c.prototype._isSynchronized = function() {
+ var T = this._cache;
+ return this.billboardMode === T.billboardMode && this.billboardMode === c.BILLBOARDMODE_NONE && !T.pivotMatrixUpdated && !this.infiniteDistance && !this.position._isDirty && !this.scaling._isDirty && !(this._rotationQuaternion && this._rotationQuaternion._isDirty || this.rotation._isDirty);
+ }, c.prototype._initCache = function() {
+ m.prototype._initCache.call(this);
+ var T = this._cache;
+ T.localMatrixUpdated = !1, T.billboardMode = -1, T.infiniteDistance = !1;
+ }, c.prototype.markAsDirty = function(T) {
+ return this._currentRenderId = Number.MAX_VALUE, this._isDirty = !0, this;
+ }, Object.defineProperty(c.prototype, "absolutePosition", { get: function() {
+ return this._absolutePosition;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(c.prototype, "absoluteScaling", { get: function() {
+ return this._syncAbsoluteScalingAndRotation(), this._absoluteScaling;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(c.prototype, "absoluteRotationQuaternion", { get: function() {
+ return this._syncAbsoluteScalingAndRotation(), this._absoluteRotationQuaternion;
+ }, enumerable: !1, configurable: !0 }), c.prototype.setPreTransformMatrix = function(T) {
+ return this.setPivotMatrix(T, !1);
+ }, c.prototype.setPivotMatrix = function(T, S) {
+ return S === void 0 && (S = !0), this._pivotMatrix.copyFrom(T), this._usePivotMatrix = !this._pivotMatrix.isIdentity(), this._cache.pivotMatrixUpdated = !0, this._postMultiplyPivotMatrix = S, this._postMultiplyPivotMatrix && (this._pivotMatrixInverse ? this._pivotMatrix.invertToRef(this._pivotMatrixInverse) : this._pivotMatrixInverse = u.a.Invert(this._pivotMatrix)), this;
+ }, c.prototype.getPivotMatrix = function() {
+ return this._pivotMatrix;
+ }, c.prototype.instantiateHierarchy = function(T, S, E) {
+ T === void 0 && (T = null);
+ var g = this.clone("Clone of " + (this.name || this.id), T || this.parent, !0);
+ g && E && E(this, g);
+ for (var l = 0, h = this.getChildTransformNodes(!0); l < h.length; l++)
+ h[l].instantiateHierarchy(g, S, E);
+ return g;
+ }, c.prototype.freezeWorldMatrix = function(T) {
+ return T === void 0 && (T = null), T ? this._worldMatrix = T : (this._isWorldMatrixFrozen = !1, this.computeWorldMatrix(!0)), this._isDirty = !1, this._isWorldMatrixFrozen = !0, this;
+ }, c.prototype.unfreezeWorldMatrix = function() {
+ return this._isWorldMatrixFrozen = !1, this.computeWorldMatrix(!0), this;
+ }, Object.defineProperty(c.prototype, "isWorldMatrixFrozen", { get: function() {
+ return this._isWorldMatrixFrozen;
+ }, enumerable: !1, configurable: !0 }), c.prototype.getAbsolutePosition = function() {
+ return this.computeWorldMatrix(), this._absolutePosition;
+ }, c.prototype.setAbsolutePosition = function(T) {
+ if (!T)
+ return this;
+ var S, E, g;
+ if (T.x === void 0) {
+ if (arguments.length < 3)
+ return this;
+ S = arguments[0], E = arguments[1], g = arguments[2];
+ } else
+ S = T.x, E = T.y, g = T.z;
+ if (this.parent) {
+ var l = u.c.Matrix[0];
+ this.parent.getWorldMatrix().invertToRef(l), u.e.TransformCoordinatesFromFloatsToRef(S, E, g, l, this.position);
+ } else
+ this.position.x = S, this.position.y = E, this.position.z = g;
+ return this._absolutePosition.copyFrom(T), this;
+ }, c.prototype.setPositionWithLocalVector = function(T) {
+ return this.computeWorldMatrix(), this.position = u.e.TransformNormal(T, this._localMatrix), this;
+ }, c.prototype.getPositionExpressedInLocalSpace = function() {
+ this.computeWorldMatrix();
+ var T = u.c.Matrix[0];
+ return this._localMatrix.invertToRef(T), u.e.TransformNormal(this.position, T);
+ }, c.prototype.locallyTranslate = function(T) {
+ return this.computeWorldMatrix(!0), this.position = u.e.TransformCoordinates(T, this._localMatrix), this;
+ }, c.prototype.lookAt = function(T, S, E, g, l) {
+ S === void 0 && (S = 0), E === void 0 && (E = 0), g === void 0 && (g = 0), l === void 0 && (l = O.c.LOCAL);
+ var h = c._lookAtVectorCache, v = l === O.c.LOCAL ? this.position : this.getAbsolutePosition();
+ if (T.subtractToRef(v, h), this.setDirection(h, S, E, g), l === O.c.WORLD && this.parent)
+ if (this.rotationQuaternion) {
+ var b = u.c.Matrix[0];
+ this.rotationQuaternion.toRotationMatrix(b);
+ var D = u.c.Matrix[1];
+ this.parent.getWorldMatrix().getRotationMatrixToRef(D), D.invert(), b.multiplyToRef(D, b), this.rotationQuaternion.fromRotationMatrix(b);
+ } else {
+ var w = u.c.Quaternion[0];
+ u.b.FromEulerVectorToRef(this.rotation, w), b = u.c.Matrix[0], w.toRotationMatrix(b), D = u.c.Matrix[1], this.parent.getWorldMatrix().getRotationMatrixToRef(D), D.invert(), b.multiplyToRef(D, b), w.fromRotationMatrix(b), w.toEulerAnglesToRef(this.rotation);
+ }
+ return this;
+ }, c.prototype.getDirection = function(T) {
+ var S = u.e.Zero();
+ return this.getDirectionToRef(T, S), S;
+ }, c.prototype.getDirectionToRef = function(T, S) {
+ return u.e.TransformNormalToRef(T, this.getWorldMatrix(), S), this;
+ }, c.prototype.setDirection = function(T, S, E, g) {
+ S === void 0 && (S = 0), E === void 0 && (E = 0), g === void 0 && (g = 0);
+ var l = -Math.atan2(T.z, T.x) + Math.PI / 2, h = Math.sqrt(T.x * T.x + T.z * T.z), v = -Math.atan2(T.y, h);
+ return this.rotationQuaternion ? u.b.RotationYawPitchRollToRef(l + S, v + E, g, this.rotationQuaternion) : (this.rotation.x = v + E, this.rotation.y = l + S, this.rotation.z = g), this;
+ }, c.prototype.setPivotPoint = function(T, S) {
+ S === void 0 && (S = O.c.LOCAL), this.getScene().getRenderId() == 0 && this.computeWorldMatrix(!0);
+ var E = this.getWorldMatrix();
+ if (S == O.c.WORLD) {
+ var g = u.c.Matrix[0];
+ E.invertToRef(g), T = u.e.TransformCoordinates(T, g);
+ }
+ return this.setPivotMatrix(u.a.Translation(-T.x, -T.y, -T.z), !0);
+ }, c.prototype.getPivotPoint = function() {
+ var T = u.e.Zero();
+ return this.getPivotPointToRef(T), T;
+ }, c.prototype.getPivotPointToRef = function(T) {
+ return T.x = -this._pivotMatrix.m[12], T.y = -this._pivotMatrix.m[13], T.z = -this._pivotMatrix.m[14], this;
+ }, c.prototype.getAbsolutePivotPoint = function() {
+ var T = u.e.Zero();
+ return this.getAbsolutePivotPointToRef(T), T;
+ }, c.prototype.getAbsolutePivotPointToRef = function(T) {
+ return this.getPivotPointToRef(T), u.e.TransformCoordinatesToRef(T, this.getWorldMatrix(), T), this;
+ }, c.prototype.setParent = function(T) {
+ if (!T && !this.parent)
+ return this;
+ var S = u.c.Quaternion[0], E = u.c.Vector3[0], g = u.c.Vector3[1];
+ if (T) {
+ var l = u.c.Matrix[0], h = u.c.Matrix[1];
+ this.computeWorldMatrix(!0), T.computeWorldMatrix(!0), T.getWorldMatrix().invertToRef(h), this.getWorldMatrix().multiplyToRef(h, l), l.decompose(g, S, E);
+ } else
+ this.computeWorldMatrix(!0), this.getWorldMatrix().decompose(g, S, E);
+ return this.rotationQuaternion ? this.rotationQuaternion.copyFrom(S) : S.toEulerAnglesToRef(this.rotation), this.scaling.copyFrom(g), this.position.copyFrom(E), this.parent = T, this;
+ }, Object.defineProperty(c.prototype, "nonUniformScaling", { get: function() {
+ return this._nonUniformScaling;
+ }, enumerable: !1, configurable: !0 }), c.prototype._updateNonUniformScalingState = function(T) {
+ return this._nonUniformScaling !== T && (this._nonUniformScaling = T, !0);
+ }, c.prototype.attachToBone = function(T, S) {
+ return this._transformToBoneReferal = S, this.parent = T, T.getSkeleton().prepare(), T.getWorldMatrix().determinant() < 0 && (this.scalingDeterminant *= -1), this;
+ }, c.prototype.detachFromBone = function() {
+ return this.parent ? (this.parent.getWorldMatrix().determinant() < 0 && (this.scalingDeterminant *= -1), this._transformToBoneReferal = null, this.parent = null, this) : this;
+ }, c.prototype.rotate = function(T, S, E) {
+ var g;
+ if (T.normalize(), this.rotationQuaternion || (this.rotationQuaternion = this.rotation.toQuaternion(), this.rotation.setAll(0)), E && E !== O.c.LOCAL) {
+ if (this.parent) {
+ var l = u.c.Matrix[0];
+ this.parent.getWorldMatrix().invertToRef(l), T = u.e.TransformNormal(T, l);
+ }
+ (g = u.b.RotationAxisToRef(T, S, c._rotationAxisCache)).multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
+ } else
+ g = u.b.RotationAxisToRef(T, S, c._rotationAxisCache), this.rotationQuaternion.multiplyToRef(g, this.rotationQuaternion);
+ return this;
+ }, c.prototype.rotateAround = function(T, S, E) {
+ S.normalize(), this.rotationQuaternion || (this.rotationQuaternion = u.b.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z), this.rotation.setAll(0));
+ var g = u.c.Vector3[0], l = u.c.Vector3[1], h = u.c.Vector3[2], v = u.c.Quaternion[0], b = u.c.Matrix[0], D = u.c.Matrix[1], w = u.c.Matrix[2], N = u.c.Matrix[3];
+ return T.subtractToRef(this.position, g), u.a.TranslationToRef(g.x, g.y, g.z, b), u.a.TranslationToRef(-g.x, -g.y, -g.z, D), u.a.RotationAxisToRef(S, E, w), D.multiplyToRef(w, N), N.multiplyToRef(b, N), N.decompose(l, v, h), this.position.addInPlace(h), v.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion), this;
+ }, c.prototype.translate = function(T, S, E) {
+ var g = T.scale(S);
+ if (E && E !== O.c.LOCAL)
+ this.setAbsolutePosition(this.getAbsolutePosition().add(g));
+ else {
+ var l = this.getPositionExpressedInLocalSpace().add(g);
+ this.setPositionWithLocalVector(l);
+ }
+ return this;
+ }, c.prototype.addRotation = function(T, S, E) {
+ var g;
+ this.rotationQuaternion ? g = this.rotationQuaternion : (g = u.c.Quaternion[1], u.b.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, g));
+ var l = u.c.Quaternion[0];
+ return u.b.RotationYawPitchRollToRef(S, T, E, l), g.multiplyInPlace(l), this.rotationQuaternion || g.toEulerAnglesToRef(this.rotation), this;
+ }, c.prototype._getEffectiveParent = function() {
+ return this.parent;
+ }, c.prototype.computeWorldMatrix = function(T) {
+ if (this._isWorldMatrixFrozen && !this._isDirty)
+ return this._worldMatrix;
+ var S = this.getScene().getRenderId();
+ if (!this._isDirty && !T && this.isSynchronized())
+ return this._currentRenderId = S, this._worldMatrix;
+ var E = this.getScene().activeCamera, g = (this._billboardMode & c.BILLBOARDMODE_USE_POSITION) != 0, l = this._billboardMode !== c.BILLBOARDMODE_NONE && !this.preserveParentRotationForBillboard;
+ l && E && g && (this.lookAt(E.position), (this.billboardMode & c.BILLBOARDMODE_X) !== c.BILLBOARDMODE_X && (this.rotation.x = 0), (this.billboardMode & c.BILLBOARDMODE_Y) !== c.BILLBOARDMODE_Y && (this.rotation.y = 0), (this.billboardMode & c.BILLBOARDMODE_Z) !== c.BILLBOARDMODE_Z && (this.rotation.z = 0)), this._updateCache();
+ var h = this._cache;
+ h.pivotMatrixUpdated = !1, h.billboardMode = this.billboardMode, h.infiniteDistance = this.infiniteDistance, this._currentRenderId = S, this._childUpdateId++, this._isDirty = !1, this._position._isDirty = !1, this._rotation._isDirty = !1, this._scaling._isDirty = !1;
+ var v, b = this._getEffectiveParent(), D = c._TmpScaling, w = this._position;
+ if (this._infiniteDistance && !this.parent && E) {
+ var N = E.getWorldMatrix(), M = new u.e(N.m[12], N.m[13], N.m[14]);
+ (w = c._TmpTranslation).copyFromFloats(this._position.x + M.x, this._position.y + M.y, this._position.z + M.z);
+ }
+ if (D.copyFromFloats(this._scaling.x * this.scalingDeterminant, this._scaling.y * this.scalingDeterminant, this._scaling.z * this.scalingDeterminant), this._rotationQuaternion ? (this._rotationQuaternion._isDirty = !1, v = this._rotationQuaternion, this.reIntegrateRotationIntoRotationQuaternion && this.rotation.lengthSquared() && (this._rotationQuaternion.multiplyInPlace(u.b.RotationYawPitchRoll(this._rotation.y, this._rotation.x, this._rotation.z)), this._rotation.copyFromFloats(0, 0, 0))) : (v = c._TmpRotation, u.b.RotationYawPitchRollToRef(this._rotation.y, this._rotation.x, this._rotation.z, v)), this._usePivotMatrix) {
+ var U = u.c.Matrix[1];
+ u.a.ScalingToRef(D.x, D.y, D.z, U);
+ var X = u.c.Matrix[0];
+ v.toRotationMatrix(X), this._pivotMatrix.multiplyToRef(U, u.c.Matrix[4]), u.c.Matrix[4].multiplyToRef(X, this._localMatrix), this._postMultiplyPivotMatrix && this._localMatrix.multiplyToRef(this._pivotMatrixInverse, this._localMatrix), this._localMatrix.addTranslationFromFloats(w.x, w.y, w.z);
+ } else
+ u.a.ComposeToRef(D, v, w, this._localMatrix);
+ if (b && b.getWorldMatrix) {
+ if (T && b.computeWorldMatrix(), l) {
+ this._transformToBoneReferal ? b.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), u.c.Matrix[7]) : u.c.Matrix[7].copyFrom(b.getWorldMatrix());
+ var j = u.c.Vector3[5], ne = u.c.Vector3[6];
+ u.c.Matrix[7].decompose(ne, void 0, j), u.a.ScalingToRef(ne.x, ne.y, ne.z, u.c.Matrix[7]), u.c.Matrix[7].setTranslation(j), this._localMatrix.multiplyToRef(u.c.Matrix[7], this._worldMatrix);
+ } else
+ this._transformToBoneReferal ? (this._localMatrix.multiplyToRef(b.getWorldMatrix(), u.c.Matrix[6]), u.c.Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), this._worldMatrix)) : this._localMatrix.multiplyToRef(b.getWorldMatrix(), this._worldMatrix);
+ this._markSyncedWithParent();
+ } else
+ this._worldMatrix.copyFrom(this._localMatrix);
+ if (l && E && this.billboardMode && !g) {
+ var te = u.c.Vector3[0];
+ if (this._worldMatrix.getTranslationToRef(te), u.c.Matrix[1].copyFrom(E.getViewMatrix()), u.c.Matrix[1].setTranslationFromFloats(0, 0, 0), u.c.Matrix[1].invertToRef(u.c.Matrix[0]), (this.billboardMode & c.BILLBOARDMODE_ALL) !== c.BILLBOARDMODE_ALL) {
+ u.c.Matrix[0].decompose(void 0, u.c.Quaternion[0], void 0);
+ var de = u.c.Vector3[1];
+ u.c.Quaternion[0].toEulerAnglesToRef(de), (this.billboardMode & c.BILLBOARDMODE_X) !== c.BILLBOARDMODE_X && (de.x = 0), (this.billboardMode & c.BILLBOARDMODE_Y) !== c.BILLBOARDMODE_Y && (de.y = 0), (this.billboardMode & c.BILLBOARDMODE_Z) !== c.BILLBOARDMODE_Z && (de.z = 0), u.a.RotationYawPitchRollToRef(de.y, de.x, de.z, u.c.Matrix[0]);
+ }
+ this._worldMatrix.setTranslationFromFloats(0, 0, 0), this._worldMatrix.multiplyToRef(u.c.Matrix[0], this._worldMatrix), this._worldMatrix.setTranslation(u.c.Vector3[0]);
+ }
+ return this.ignoreNonUniformScaling ? this._updateNonUniformScalingState(!1) : this._scaling.isNonUniformWithinEpsilon(1e-6) ? this._updateNonUniformScalingState(!0) : b && b._nonUniformScaling ? this._updateNonUniformScalingState(b._nonUniformScaling) : this._updateNonUniformScalingState(!1), this._afterComputeWorldMatrix(), this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]), this._isAbsoluteSynced = !1, this.onAfterWorldMatrixUpdateObservable.notifyObservers(this), this._poseMatrix || (this._poseMatrix = u.a.Invert(this._worldMatrix)), this._worldMatrixDeterminantIsDirty = !0, this._worldMatrix;
+ }, c.prototype.resetLocalMatrix = function(T) {
+ if (T === void 0 && (T = !0), this.computeWorldMatrix(), T)
+ for (var S = this.getChildren(), E = 0; E < S.length; ++E) {
+ var g = S[E];
+ if (g) {
+ g.computeWorldMatrix();
+ var l = u.c.Matrix[0];
+ g._localMatrix.multiplyToRef(this._localMatrix, l);
+ var h = u.c.Quaternion[0];
+ l.decompose(g.scaling, h, g.position), g.rotationQuaternion ? g.rotationQuaternion = h : h.toEulerAnglesToRef(g.rotation);
+ }
+ }
+ this.scaling.copyFromFloats(1, 1, 1), this.position.copyFromFloats(0, 0, 0), this.rotation.copyFromFloats(0, 0, 0), this.rotationQuaternion && (this.rotationQuaternion = u.b.Identity()), this._worldMatrix = u.a.Identity();
+ }, c.prototype._afterComputeWorldMatrix = function() {
+ }, c.prototype.registerAfterWorldMatrixUpdate = function(T) {
+ return this.onAfterWorldMatrixUpdateObservable.add(T), this;
+ }, c.prototype.unregisterAfterWorldMatrixUpdate = function(T) {
+ return this.onAfterWorldMatrixUpdateObservable.removeCallback(T), this;
+ }, c.prototype.getPositionInCameraSpace = function(T) {
+ return T === void 0 && (T = null), T || (T = this.getScene().activeCamera), u.e.TransformCoordinates(this.getAbsolutePosition(), T.getViewMatrix());
+ }, c.prototype.getDistanceToCamera = function(T) {
+ return T === void 0 && (T = null), T || (T = this.getScene().activeCamera), this.getAbsolutePosition().subtract(T.globalPosition).length();
+ }, c.prototype.clone = function(T, S, E) {
+ var g = this, l = _.a.Clone(function() {
+ return new c(T, g.getScene());
+ }, this);
+ if (l.name = T, l.id = T, S && (l.parent = S), !E)
+ for (var h = this.getDescendants(!0), v = 0; v < h.length; v++) {
+ var b = h[v];
+ b.clone && b.clone(T + "." + b.name, l);
+ }
+ return l;
+ }, c.prototype.serialize = function(T) {
+ var S = _.a.Serialize(this, T);
+ return S.type = this.getClassName(), this.parent && (S.parentId = this.parent.id), S.localMatrix = this.getPivotMatrix().asArray(), S.isEnabled = this.isEnabled(), this.parent && (S.parentId = this.parent.id), S;
+ }, c.Parse = function(T, S, E) {
+ var g = _.a.Parse(function() {
+ return new c(T.name, S);
+ }, T, S, E);
+ return T.localMatrix ? g.setPreTransformMatrix(u.a.FromArray(T.localMatrix)) : T.pivotMatrix && g.setPivotMatrix(u.a.FromArray(T.pivotMatrix)), g.setEnabled(T.isEnabled), T.parentId && (g._waitingParentId = T.parentId), g;
+ }, c.prototype.getChildTransformNodes = function(T, S) {
+ var E = [];
+ return this._getDescendants(E, T, function(g) {
+ return (!S || S(g)) && g instanceof c;
+ }), E;
+ }, c.prototype.dispose = function(T, S) {
+ if (S === void 0 && (S = !1), this.getScene().stopAnimation(this), this.getScene().removeTransformNode(this), this.onAfterWorldMatrixUpdateObservable.clear(), T)
+ for (var E = 0, g = this.getChildTransformNodes(!0); E < g.length; E++) {
+ var l = g[E];
+ l.parent = null, l.computeWorldMatrix(!0);
+ }
+ m.prototype.dispose.call(this, T, S);
+ }, c.prototype.normalizeToUnitCube = function(T, S, E) {
+ T === void 0 && (T = !0), S === void 0 && (S = !1);
+ var g = null, l = null;
+ S && (this.rotationQuaternion ? (l = this.rotationQuaternion.clone(), this.rotationQuaternion.copyFromFloats(0, 0, 0, 1)) : this.rotation && (g = this.rotation.clone(), this.rotation.copyFromFloats(0, 0, 0)));
+ var h = this.getHierarchyBoundingVectors(T, E), v = h.max.subtract(h.min), b = Math.max(v.x, v.y, v.z);
+ if (b === 0)
+ return this;
+ var D = 1 / b;
+ return this.scaling.scaleInPlace(D), S && (this.rotationQuaternion && l ? this.rotationQuaternion.copyFrom(l) : this.rotation && g && this.rotation.copyFrom(g)), this;
+ }, c.prototype._syncAbsoluteScalingAndRotation = function() {
+ this._isAbsoluteSynced || (this._worldMatrix.decompose(this._absoluteScaling, this._absoluteRotationQuaternion), this._isAbsoluteSynced = !0);
+ }, c.BILLBOARDMODE_NONE = 0, c.BILLBOARDMODE_X = 1, c.BILLBOARDMODE_Y = 2, c.BILLBOARDMODE_Z = 4, c.BILLBOARDMODE_ALL = 7, c.BILLBOARDMODE_USE_POSITION = 128, c._TmpRotation = u.b.Zero(), c._TmpScaling = u.e.Zero(), c._TmpTranslation = u.e.Zero(), c._lookAtVectorCache = new u.e(0, 0, 0), c._rotationAxisCache = new u.b(), Object(V.c)([Object(_.o)("position")], c.prototype, "_position", void 0), Object(V.c)([Object(_.o)("rotation")], c.prototype, "_rotation", void 0), Object(V.c)([Object(_.l)("rotationQuaternion")], c.prototype, "_rotationQuaternion", void 0), Object(V.c)([Object(_.o)("scaling")], c.prototype, "_scaling", void 0), Object(V.c)([Object(_.c)("billboardMode")], c.prototype, "_billboardMode", void 0), Object(V.c)([Object(_.c)()], c.prototype, "scalingDeterminant", void 0), Object(V.c)([Object(_.c)("infiniteDistance")], c.prototype, "_infiniteDistance", void 0), Object(V.c)([Object(_.c)()], c.prototype, "ignoreNonUniformScaling", void 0), Object(V.c)([Object(_.c)()], c.prototype, "reIntegrateRotationIntoRotationQuaternion", void 0), c;
+ }(I.a);
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return V;
+ });
+ var V = function() {
+ function _(C, u, I, O, x, m) {
+ this.source = C, this.pointerX = u, this.pointerY = I, this.meshUnderPointer = O, this.sourceEvent = x, this.additionalData = m;
+ }
+ return _.CreateNew = function(C, u, I) {
+ var O = C.getScene();
+ return new _(C, O.pointerX, O.pointerY, O.meshUnderPointer || C, u, I);
+ }, _.CreateNewFromSprite = function(C, u, I, O) {
+ return new _(C, u.pointerX, u.pointerY, u.meshUnderPointer, I, O);
+ }, _.CreateNewFromScene = function(C, u) {
+ return new _(null, C.pointerX, C.pointerY, C.meshUnderPointer, u);
+ }, _.CreateNewFromPrimitive = function(C, u, I, O) {
+ return new _(C, u.x, u.y, null, I, O);
+ }, _;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return m;
+ });
+ var V = f(1), _ = f(3), C = f(0), u = f(9), I = f(29), O = f(85), x = f(11), m = function(c) {
+ function T(S, E) {
+ var g = c.call(this, S, E) || this;
+ return g.diffuse = new u.a(1, 1, 1), g.specular = new u.a(1, 1, 1), g.falloffType = T.FALLOFF_DEFAULT, g.intensity = 1, g._range = Number.MAX_VALUE, g._inverseSquaredRange = 0, g._photometricScale = 1, g._intensityMode = T.INTENSITYMODE_AUTOMATIC, g._radius = 1e-5, g.renderPriority = 0, g._shadowEnabled = !0, g._excludeWithLayerMask = 0, g._includeOnlyWithLayerMask = 0, g._lightmapMode = 0, g._excludedMeshesIds = new Array(), g._includedOnlyMeshesIds = new Array(), g._isLight = !0, g.getScene().addLight(g), g._uniformBuffer = new O.a(g.getScene().getEngine()), g._buildUniformLayout(), g.includedOnlyMeshes = new Array(), g.excludedMeshes = new Array(), g._resyncMeshes(), g;
+ }
+ return Object(V.d)(T, c), Object.defineProperty(T.prototype, "range", { get: function() {
+ return this._range;
+ }, set: function(S) {
+ this._range = S, this._inverseSquaredRange = 1 / (this.range * this.range);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(T.prototype, "intensityMode", { get: function() {
+ return this._intensityMode;
+ }, set: function(S) {
+ this._intensityMode = S, this._computePhotometricScale();
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(T.prototype, "radius", { get: function() {
+ return this._radius;
+ }, set: function(S) {
+ this._radius = S, this._computePhotometricScale();
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(T.prototype, "shadowEnabled", { get: function() {
+ return this._shadowEnabled;
+ }, set: function(S) {
+ this._shadowEnabled !== S && (this._shadowEnabled = S, this._markMeshesAsLightDirty());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(T.prototype, "includedOnlyMeshes", { get: function() {
+ return this._includedOnlyMeshes;
+ }, set: function(S) {
+ this._includedOnlyMeshes = S, this._hookArrayForIncludedOnly(S);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(T.prototype, "excludedMeshes", { get: function() {
+ return this._excludedMeshes;
+ }, set: function(S) {
+ this._excludedMeshes = S, this._hookArrayForExcluded(S);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(T.prototype, "excludeWithLayerMask", { get: function() {
+ return this._excludeWithLayerMask;
+ }, set: function(S) {
+ this._excludeWithLayerMask = S, this._resyncMeshes();
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(T.prototype, "includeOnlyWithLayerMask", { get: function() {
+ return this._includeOnlyWithLayerMask;
+ }, set: function(S) {
+ this._includeOnlyWithLayerMask = S, this._resyncMeshes();
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(T.prototype, "lightmapMode", { get: function() {
+ return this._lightmapMode;
+ }, set: function(S) {
+ this._lightmapMode !== S && (this._lightmapMode = S, this._markMeshesAsLightDirty());
+ }, enumerable: !1, configurable: !0 }), T.prototype.transferTexturesToEffect = function(S, E) {
+ return this;
+ }, T.prototype._bindLight = function(S, E, g, l, h) {
+ h === void 0 && (h = !1);
+ var v = S.toString(), b = !1;
+ if (!h || !this._uniformBuffer._alreadyBound) {
+ if (this._uniformBuffer.bindToEffect(g, "Light" + v), this._renderId !== E.getRenderId() || !this._uniformBuffer.useUbo) {
+ this._renderId = E.getRenderId();
+ var D = this.getScaledIntensity();
+ this.transferToEffect(g, v), this.diffuse.scaleToRef(D, u.c.Color3[0]), this._uniformBuffer.updateColor4("vLightDiffuse", u.c.Color3[0], this.range, v), l && (this.specular.scaleToRef(D, u.c.Color3[1]), this._uniformBuffer.updateColor4("vLightSpecular", u.c.Color3[1], this.radius, v)), b = !0;
+ }
+ if (this.transferTexturesToEffect(g, v), E.shadowsEnabled && this.shadowEnabled) {
+ var w = this.getShadowGenerator();
+ w && (w.bindShadowLight(v, g), b = !0);
+ }
+ b && this._uniformBuffer.update();
+ }
+ }, T.prototype.getClassName = function() {
+ return "Light";
+ }, T.prototype.toString = function(S) {
+ var E = "Name: " + this.name;
+ if (E += ", type: " + ["Point", "Directional", "Spot", "Hemispheric"][this.getTypeID()], this.animations)
+ for (var g = 0; g < this.animations.length; g++)
+ E += ", animation[0]: " + this.animations[g].toString(S);
+ return E;
+ }, T.prototype._syncParentEnabledState = function() {
+ c.prototype._syncParentEnabledState.call(this), this.isDisposed() || this._resyncMeshes();
+ }, T.prototype.setEnabled = function(S) {
+ c.prototype.setEnabled.call(this, S), this._resyncMeshes();
+ }, T.prototype.getShadowGenerator = function() {
+ return this._shadowGenerator;
+ }, T.prototype.getAbsolutePosition = function() {
+ return C.e.Zero();
+ }, T.prototype.canAffectMesh = function(S) {
+ return !S || !(this.includedOnlyMeshes && this.includedOnlyMeshes.length > 0 && this.includedOnlyMeshes.indexOf(S) === -1) && !(this.excludedMeshes && this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(S) !== -1) && (this.includeOnlyWithLayerMask === 0 || (this.includeOnlyWithLayerMask & S.layerMask) != 0) && !(this.excludeWithLayerMask !== 0 && this.excludeWithLayerMask & S.layerMask);
+ }, T.CompareLightsPriority = function(S, E) {
+ return S.shadowEnabled !== E.shadowEnabled ? (E.shadowEnabled ? 1 : 0) - (S.shadowEnabled ? 1 : 0) : E.renderPriority - S.renderPriority;
+ }, T.prototype.dispose = function(S, E) {
+ E === void 0 && (E = !1), this._shadowGenerator && (this._shadowGenerator.dispose(), this._shadowGenerator = null), this.getScene().stopAnimation(this);
+ for (var g = 0, l = this.getScene().meshes; g < l.length; g++)
+ l[g]._removeLightSource(this, !0);
+ this._uniformBuffer.dispose(), this.getScene().removeLight(this), c.prototype.dispose.call(this, S, E);
+ }, T.prototype.getTypeID = function() {
+ return 0;
+ }, T.prototype.getScaledIntensity = function() {
+ return this._photometricScale * this.intensity;
+ }, T.prototype.clone = function(S, E) {
+ E === void 0 && (E = null);
+ var g = T.GetConstructorFromName(this.getTypeID(), S, this.getScene());
+ if (!g)
+ return null;
+ var l = _.a.Clone(g, this);
+ return E && (l.parent = E), l.setEnabled(this.isEnabled()), l;
+ }, T.prototype.serialize = function() {
+ var S = _.a.Serialize(this);
+ return S.type = this.getTypeID(), this.parent && (S.parentId = this.parent.id), this.excludedMeshes.length > 0 && (S.excludedMeshesIds = [], this.excludedMeshes.forEach(function(E) {
+ S.excludedMeshesIds.push(E.id);
+ })), this.includedOnlyMeshes.length > 0 && (S.includedOnlyMeshesIds = [], this.includedOnlyMeshes.forEach(function(E) {
+ S.includedOnlyMeshesIds.push(E.id);
+ })), _.a.AppendSerializedAnimations(this, S), S.ranges = this.serializeAnimationRanges(), S;
+ }, T.GetConstructorFromName = function(S, E, g) {
+ var l = I.a.Construct("Light_Type_" + S, E, g);
+ return l || null;
+ }, T.Parse = function(S, E) {
+ var g = T.GetConstructorFromName(S.type, S.name, E);
+ if (!g)
+ return null;
+ var l = _.a.Parse(g, S, E);
+ if (S.excludedMeshesIds && (l._excludedMeshesIds = S.excludedMeshesIds), S.includedOnlyMeshesIds && (l._includedOnlyMeshesIds = S.includedOnlyMeshesIds), S.parentId && (l._waitingParentId = S.parentId), S.falloffType !== void 0 && (l.falloffType = S.falloffType), S.lightmapMode !== void 0 && (l.lightmapMode = S.lightmapMode), S.animations) {
+ for (var h = 0; h < S.animations.length; h++) {
+ var v = S.animations[h], b = x.a.GetClass("BABYLON.Animation");
+ b && l.animations.push(b.Parse(v));
+ }
+ I.a.ParseAnimationRanges(l, S, E);
+ }
+ return S.autoAnimate && E.beginAnimation(l, S.autoAnimateFrom, S.autoAnimateTo, S.autoAnimateLoop, S.autoAnimateSpeed || 1), l;
+ }, T.prototype._hookArrayForExcluded = function(S) {
+ var E = this, g = S.push;
+ S.push = function() {
+ for (var b = [], D = 0; D < arguments.length; D++)
+ b[D] = arguments[D];
+ for (var w = g.apply(S, b), N = 0, M = b; N < M.length; N++) {
+ var U = M[N];
+ U._resyncLightSource(E);
+ }
+ return w;
+ };
+ var l = S.splice;
+ S.splice = function(b, D) {
+ for (var w = l.apply(S, [b, D]), N = 0, M = w; N < M.length; N++)
+ M[N]._resyncLightSource(E);
+ return w;
+ };
+ for (var h = 0, v = S; h < v.length; h++)
+ v[h]._resyncLightSource(this);
+ }, T.prototype._hookArrayForIncludedOnly = function(S) {
+ var E = this, g = S.push;
+ S.push = function() {
+ for (var h = [], v = 0; v < arguments.length; v++)
+ h[v] = arguments[v];
+ var b = g.apply(S, h);
+ return E._resyncMeshes(), b;
+ };
+ var l = S.splice;
+ S.splice = function(h, v) {
+ var b = l.apply(S, [h, v]);
+ return E._resyncMeshes(), b;
+ }, this._resyncMeshes();
+ }, T.prototype._resyncMeshes = function() {
+ for (var S = 0, E = this.getScene().meshes; S < E.length; S++)
+ E[S]._resyncLightSource(this);
+ }, T.prototype._markMeshesAsLightDirty = function() {
+ for (var S = 0, E = this.getScene().meshes; S < E.length; S++) {
+ var g = E[S];
+ g.lightSources.indexOf(this) !== -1 && g._markSubMeshesAsLightDirty();
+ }
+ }, T.prototype._computePhotometricScale = function() {
+ this._photometricScale = this._getPhotometricScale(), this.getScene().resetCachedMaterial();
+ }, T.prototype._getPhotometricScale = function() {
+ var S = 0, E = this.getTypeID(), g = this.intensityMode;
+ switch (g === T.INTENSITYMODE_AUTOMATIC && (g = E === T.LIGHTTYPEID_DIRECTIONALLIGHT ? T.INTENSITYMODE_ILLUMINANCE : T.INTENSITYMODE_LUMINOUSINTENSITY), E) {
+ case T.LIGHTTYPEID_POINTLIGHT:
+ case T.LIGHTTYPEID_SPOTLIGHT:
+ switch (g) {
+ case T.INTENSITYMODE_LUMINOUSPOWER:
+ S = 1 / (4 * Math.PI);
+ break;
+ case T.INTENSITYMODE_LUMINOUSINTENSITY:
+ S = 1;
+ break;
+ case T.INTENSITYMODE_LUMINANCE:
+ S = this.radius * this.radius;
+ }
+ break;
+ case T.LIGHTTYPEID_DIRECTIONALLIGHT:
+ switch (g) {
+ case T.INTENSITYMODE_ILLUMINANCE:
+ S = 1;
+ break;
+ case T.INTENSITYMODE_LUMINANCE:
+ var l = this.radius;
+ l = Math.max(l, 1e-3), S = 2 * Math.PI * (1 - Math.cos(l));
+ }
+ break;
+ case T.LIGHTTYPEID_HEMISPHERICLIGHT:
+ S = 1;
+ }
+ return S;
+ }, T.prototype._reorderLightsInScene = function() {
+ var S = this.getScene();
+ this._renderPriority != 0 && (S.requireLightSorting = !0), this.getScene().sortLightsByPriority();
+ }, T.FALLOFF_DEFAULT = 0, T.FALLOFF_PHYSICAL = 1, T.FALLOFF_GLTF = 2, T.FALLOFF_STANDARD = 3, T.LIGHTMAP_DEFAULT = 0, T.LIGHTMAP_SPECULAR = 1, T.LIGHTMAP_SHADOWSONLY = 2, T.INTENSITYMODE_AUTOMATIC = 0, T.INTENSITYMODE_LUMINOUSPOWER = 1, T.INTENSITYMODE_LUMINOUSINTENSITY = 2, T.INTENSITYMODE_ILLUMINANCE = 3, T.INTENSITYMODE_LUMINANCE = 4, T.LIGHTTYPEID_POINTLIGHT = 0, T.LIGHTTYPEID_DIRECTIONALLIGHT = 1, T.LIGHTTYPEID_SPOTLIGHT = 2, T.LIGHTTYPEID_HEMISPHERICLIGHT = 3, Object(V.c)([Object(_.e)()], T.prototype, "diffuse", void 0), Object(V.c)([Object(_.e)()], T.prototype, "specular", void 0), Object(V.c)([Object(_.c)()], T.prototype, "falloffType", void 0), Object(V.c)([Object(_.c)()], T.prototype, "intensity", void 0), Object(V.c)([Object(_.c)()], T.prototype, "range", null), Object(V.c)([Object(_.c)()], T.prototype, "intensityMode", null), Object(V.c)([Object(_.c)()], T.prototype, "radius", null), Object(V.c)([Object(_.c)()], T.prototype, "_renderPriority", void 0), Object(V.c)([Object(_.b)("_reorderLightsInScene")], T.prototype, "renderPriority", void 0), Object(V.c)([Object(_.c)("shadowEnabled")], T.prototype, "_shadowEnabled", void 0), Object(V.c)([Object(_.c)("excludeWithLayerMask")], T.prototype, "_excludeWithLayerMask", void 0), Object(V.c)([Object(_.c)("includeOnlyWithLayerMask")], T.prototype, "_includeOnlyWithLayerMask", void 0), Object(V.c)([Object(_.c)("lightmapMode")], T.prototype, "_lightmapMode", void 0), T;
+ }(I.a);
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return V;
+ });
+ var V = function() {
+ function _() {
+ this._xhr = typeof _native < "u" && _native.XMLHttpRequest ? new _native.XMLHttpRequest() : new XMLHttpRequest();
+ }
+ return _.prototype._injectCustomRequestHeaders = function() {
+ for (var C in _.CustomRequestHeaders) {
+ var u = _.CustomRequestHeaders[C];
+ u && this._xhr.setRequestHeader(C, u);
+ }
+ }, Object.defineProperty(_.prototype, "onprogress", { get: function() {
+ return this._xhr.onprogress;
+ }, set: function(C) {
+ this._xhr.onprogress = C;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(_.prototype, "readyState", { get: function() {
+ return this._xhr.readyState;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(_.prototype, "status", { get: function() {
+ return this._xhr.status;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(_.prototype, "statusText", { get: function() {
+ return this._xhr.statusText;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(_.prototype, "response", { get: function() {
+ return this._xhr.response;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(_.prototype, "responseURL", { get: function() {
+ return this._xhr.responseURL;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(_.prototype, "responseText", { get: function() {
+ return this._xhr.responseText;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(_.prototype, "responseType", { get: function() {
+ return this._xhr.responseType;
+ }, set: function(C) {
+ this._xhr.responseType = C;
+ }, enumerable: !1, configurable: !0 }), _.prototype.addEventListener = function(C, u, I) {
+ this._xhr.addEventListener(C, u, I);
+ }, _.prototype.removeEventListener = function(C, u, I) {
+ this._xhr.removeEventListener(C, u, I);
+ }, _.prototype.abort = function() {
+ this._xhr.abort();
+ }, _.prototype.send = function(C) {
+ _.CustomRequestHeaders && this._injectCustomRequestHeaders(), this._xhr.send(C);
+ }, _.prototype.open = function(C, u) {
+ for (var I = 0, O = _.CustomRequestModifiers; I < O.length; I++)
+ (0, O[I])(this._xhr, u);
+ return u = (u = u.replace("file:http:", "http:")).replace("file:https:", "https:"), this._xhr.open(C, u, !0);
+ }, _.prototype.setRequestHeader = function(C, u) {
+ this._xhr.setRequestHeader(C, u);
+ }, _.prototype.getResponseHeader = function(C) {
+ return this._xhr.getResponseHeader(C);
+ }, _.CustomRequestHeaders = {}, _.CustomRequestModifiers = new Array(), _;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "e", function() {
+ return _;
+ }), f.d(A, "a", function() {
+ return C;
+ }), f.d(A, "d", function() {
+ return u;
+ }), f.d(A, "c", function() {
+ return I;
+ }), f.d(A, "b", function() {
+ return O;
+ });
+ var V = f(1), _ = function() {
+ function x(m, c) {
+ this.type = m, this.jointData = c, c.nativeParams = c.nativeParams || {};
+ }
+ return Object.defineProperty(x.prototype, "physicsJoint", { get: function() {
+ return this._physicsJoint;
+ }, set: function(m) {
+ this._physicsJoint, this._physicsJoint = m;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(x.prototype, "physicsPlugin", { set: function(m) {
+ this._physicsPlugin = m;
+ }, enumerable: !1, configurable: !0 }), x.prototype.executeNativeFunction = function(m) {
+ m(this._physicsPlugin.world, this._physicsJoint);
+ }, x.DistanceJoint = 0, x.HingeJoint = 1, x.BallAndSocketJoint = 2, x.WheelJoint = 3, x.SliderJoint = 4, x.PrismaticJoint = 5, x.UniversalJoint = 6, x.Hinge2Joint = x.WheelJoint, x.PointToPointJoint = 8, x.SpringJoint = 9, x.LockJoint = 10, x;
+ }(), C = function(x) {
+ function m(c) {
+ return x.call(this, _.DistanceJoint, c) || this;
+ }
+ return Object(V.d)(m, x), m.prototype.updateDistance = function(c, T) {
+ this._physicsPlugin.updateDistanceJoint(this, c, T);
+ }, m;
+ }(_), u = function(x) {
+ function m(c, T) {
+ return x.call(this, c, T) || this;
+ }
+ return Object(V.d)(m, x), m.prototype.setMotor = function(c, T) {
+ this._physicsPlugin.setMotor(this, c || 0, T);
+ }, m.prototype.setLimit = function(c, T) {
+ this._physicsPlugin.setLimit(this, c, T);
+ }, m;
+ }(_), I = function(x) {
+ function m(c) {
+ return x.call(this, _.HingeJoint, c) || this;
+ }
+ return Object(V.d)(m, x), m.prototype.setMotor = function(c, T) {
+ this._physicsPlugin.setMotor(this, c || 0, T);
+ }, m.prototype.setLimit = function(c, T) {
+ this._physicsPlugin.setLimit(this, c, T);
+ }, m;
+ }(u), O = function(x) {
+ function m(c) {
+ return x.call(this, _.Hinge2Joint, c) || this;
+ }
+ return Object(V.d)(m, x), m.prototype.setMotor = function(c, T, S) {
+ S === void 0 && (S = 0), this._physicsPlugin.setMotor(this, c || 0, T, S);
+ }, m.prototype.setLimit = function(c, T, S) {
+ S === void 0 && (S = 0), this._physicsPlugin.setLimit(this, c, T, S);
+ }, m;
+ }(u);
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return I;
+ });
+ var V = f(0), _ = f(7), C = f(36), u = f(18), I = function() {
+ function O(x) {
+ var m = this;
+ x === void 0 && (x = C.a.DefaultUtilityLayer), this.gizmoLayer = x, this._attachedMesh = null, this._attachedNode = null, this._scaleRatio = 1, this._isHovered = !1, this._customMeshSet = !1, this._updateGizmoRotationToMatchAttachedMesh = !0, this.updateGizmoPositionToMatchAttachedMesh = !0, this.updateScale = !0, this._interactionsEnabled = !0, this._tempQuaternion = new V.b(0, 0, 0, 1), this._tempVector = new V.e(), this._tempVector2 = new V.e(), this._tempMatrix1 = new V.a(), this._tempMatrix2 = new V.a(), this._rightHandtoLeftHandMatrix = V.a.RotationY(Math.PI), this._rootMesh = new _.a("gizmoRootNode", x.utilityLayerScene), this._rootMesh.rotationQuaternion = V.b.Identity(), this._beforeRenderObserver = this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add(function() {
+ m._update();
+ });
+ }
+ return Object.defineProperty(O.prototype, "scaleRatio", { get: function() {
+ return this._scaleRatio;
+ }, set: function(x) {
+ this._scaleRatio = x;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(O.prototype, "isHovered", { get: function() {
+ return this._isHovered;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(O.prototype, "attachedMesh", { get: function() {
+ return this._attachedMesh;
+ }, set: function(x) {
+ this._attachedMesh = x, x && (this._attachedNode = x), this._rootMesh.setEnabled(!!x), this._attachedNodeChanged(x);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(O.prototype, "attachedNode", { get: function() {
+ return this._attachedNode;
+ }, set: function(x) {
+ this._attachedNode = x, this._attachedMesh = null, this._rootMesh.setEnabled(!!x), this._attachedNodeChanged(x);
+ }, enumerable: !1, configurable: !0 }), O.prototype.setCustomMesh = function(x) {
+ if (x.getScene() != this.gizmoLayer.utilityLayerScene)
+ throw "When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)";
+ this._rootMesh.getChildMeshes().forEach(function(m) {
+ m.dispose();
+ }), x.parent = this._rootMesh, this._customMeshSet = !0;
+ }, Object.defineProperty(O.prototype, "updateGizmoRotationToMatchAttachedMesh", { get: function() {
+ return this._updateGizmoRotationToMatchAttachedMesh;
+ }, set: function(x) {
+ this._updateGizmoRotationToMatchAttachedMesh = x;
+ }, enumerable: !1, configurable: !0 }), O.prototype._attachedNodeChanged = function(x) {
+ }, O.prototype._update = function() {
+ if (this.attachedNode) {
+ var x = this.attachedNode;
+ if (this.attachedMesh && (x = this.attachedMesh._effectiveMesh || this.attachedNode), this.updateGizmoPositionToMatchAttachedMesh) {
+ var m = x.getWorldMatrix().getRow(3), c = m ? m.toVector3() : new V.e(0, 0, 0);
+ this._rootMesh.position.copyFrom(c);
+ }
+ if (this.updateGizmoRotationToMatchAttachedMesh ? x.getWorldMatrix().decompose(void 0, this._rootMesh.rotationQuaternion) : this._rootMesh.rotationQuaternion.set(0, 0, 0, 1), this.updateScale) {
+ var T = this.gizmoLayer.utilityLayerScene.activeCamera, S = T.globalPosition;
+ T.devicePosition && (S = T.devicePosition), this._rootMesh.position.subtractToRef(S, this._tempVector);
+ var E = this._tempVector.length() * this.scaleRatio;
+ this._rootMesh.scaling.set(E, E, E), x._getWorldMatrixDeterminant() < 0 && (this._rootMesh.scaling.y *= -1);
+ } else
+ this._rootMesh.scaling.setAll(this.scaleRatio);
+ }
+ }, O.prototype._matrixChanged = function() {
+ if (this._attachedNode) {
+ if (this._attachedNode._isCamera) {
+ var x, m, c = this._attachedNode;
+ if (c.parent) {
+ var T = this._tempMatrix2;
+ c.parent._worldMatrix.invertToRef(T), this._attachedNode._worldMatrix.multiplyToRef(T, this._tempMatrix1), x = this._tempMatrix1;
+ } else
+ x = this._attachedNode._worldMatrix;
+ if (c.getScene().useRightHandedSystem ? (this._rightHandtoLeftHandMatrix.multiplyToRef(x, this._tempMatrix2), m = this._tempMatrix2) : m = x, m.decompose(this._tempVector2, this._tempQuaternion, this._tempVector), this._attachedNode.getClassName() === "FreeCamera" || this._attachedNode.getClassName() === "FlyCamera" || this._attachedNode.getClassName() === "ArcFollowCamera" || this._attachedNode.getClassName() === "TargetCamera" || this._attachedNode.getClassName() === "TouchCamera" || this._attachedNode.getClassName() === "UniversalCamera") {
+ var S = this._attachedNode;
+ S.rotation = this._tempQuaternion.toEulerAngles(), S.rotationQuaternion && S.rotationQuaternion.copyFrom(this._tempQuaternion);
+ }
+ c.position.copyFrom(this._tempVector);
+ } else if (this._attachedNode._isMesh || this._attachedNode.getClassName() === "AbstractMesh" || this._attachedNode.getClassName() === "TransformNode" || this._attachedNode.getClassName() === "InstancedMesh") {
+ var E = this._attachedNode;
+ if (E.parent) {
+ T = this._tempMatrix1;
+ var g = this._tempMatrix2;
+ E.parent.getWorldMatrix().invertToRef(T), this._attachedNode.getWorldMatrix().multiplyToRef(T, g), g.decompose(E.scaling, this._tempQuaternion, E.position);
+ } else
+ this._attachedNode._worldMatrix.decompose(E.scaling, this._tempQuaternion, E.position);
+ E.billboardMode || (E.rotationQuaternion ? E.rotationQuaternion.copyFrom(this._tempQuaternion) : E.rotation = this._tempQuaternion.toEulerAngles());
+ } else if (this._attachedNode.getClassName() === "Bone") {
+ var l = this._attachedNode, h = l.getParent();
+ if (h) {
+ var v = this._tempMatrix1, b = this._tempMatrix2;
+ h.getWorldMatrix().invertToRef(v), l.getWorldMatrix().multiplyToRef(v, b), l.getLocalMatrix().copyFrom(b);
+ } else
+ l.getLocalMatrix().copyFrom(l.getWorldMatrix());
+ l.markAsDirty();
+ }
+ }
+ }, O.GizmoAxisPointerObserver = function(x, m) {
+ var c = !1;
+ return x.utilityLayerScene.onPointerObservable.add(function(T) {
+ var S, E;
+ if (T.pickInfo) {
+ if (T.type === u.a.POINTERMOVE) {
+ if (c)
+ return;
+ m.forEach(function(g) {
+ var l, h;
+ if (g.colliderMeshes && g.gizmoMeshes) {
+ var v = ((l = g.colliderMeshes) === null || l === void 0 ? void 0 : l.indexOf((h = T == null ? void 0 : T.pickInfo) === null || h === void 0 ? void 0 : h.pickedMesh)) != -1 || g.active ? g.hoverMaterial : g.material;
+ g.gizmoMeshes.forEach(function(b) {
+ b.material = v, b.color && (b.color = v.diffuseColor);
+ });
+ }
+ });
+ }
+ T.type === u.a.POINTERDOWN && m.has((S = T.pickInfo.pickedMesh) === null || S === void 0 ? void 0 : S.parent) && (c = !0, m.get((E = T.pickInfo.pickedMesh) === null || E === void 0 ? void 0 : E.parent).active = !0, m.forEach(function(g) {
+ var l, h, v = ((l = g.colliderMeshes) === null || l === void 0 ? void 0 : l.indexOf((h = T == null ? void 0 : T.pickInfo) === null || h === void 0 ? void 0 : h.pickedMesh)) != -1 || g.active ? g.hoverMaterial : g.disableMaterial;
+ g.gizmoMeshes.forEach(function(b) {
+ b.material = v, b.color && (b.color = v.diffuseColor);
+ });
+ })), T.type === u.a.POINTERUP && m.forEach(function(g) {
+ g.active = !1, c = !1, g.gizmoMeshes.forEach(function(l) {
+ l.material = g.material, l.color && (l.color = g.material.diffuseColor);
+ });
+ });
+ }
+ });
+ }, O.prototype.dispose = function() {
+ this._rootMesh.dispose(), this._beforeRenderObserver && this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
+ }, O;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return c;
+ });
+ var V = f(1), _ = f(3), C = f(6), u = f(0), I = f(22), O = f(2), x = f(120), m = (f(56), f(77)), c = function(T) {
+ function S(E) {
+ var g = T.call(this, null) || this;
+ return g.metadata = null, g.reservedDataStore = null, g._hasAlpha = !1, g.getAlphaFromRGB = !1, g.level = 1, g.coordinatesIndex = 0, g._coordinatesMode = O.a.TEXTURE_EXPLICIT_MODE, g.wrapR = O.a.TEXTURE_WRAP_ADDRESSMODE, g.anisotropicFilteringLevel = S.DEFAULT_ANISOTROPIC_FILTERING_LEVEL, g._isCube = !1, g._gammaSpace = !0, g.invertZ = !1, g.lodLevelInAlpha = !1, g.isRenderTarget = !1, g._prefiltered = !1, g.animations = new Array(), g.onDisposeObservable = new C.c(), g._onDisposeObserver = null, g._scene = null, g._texture = null, g._uid = null, E ? S._isScene(E) ? g._scene = E : g._engine = E : g._scene = I.a.LastCreatedScene, g._scene && (g.uniqueId = g._scene.getUniqueId(), g._scene.addTexture(g), g._engine = g._scene.getEngine()), g._uid = null, g;
+ }
+ return Object(V.d)(S, T), Object.defineProperty(S.prototype, "hasAlpha", { get: function() {
+ return this._hasAlpha;
+ }, set: function(E) {
+ this._hasAlpha !== E && (this._hasAlpha = E, this._scene && this._scene.markAllMaterialsAsDirty(O.a.MATERIAL_TextureDirtyFlag | O.a.MATERIAL_MiscDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(S.prototype, "coordinatesMode", { get: function() {
+ return this._coordinatesMode;
+ }, set: function(E) {
+ this._coordinatesMode !== E && (this._coordinatesMode = E, this._scene && this._scene.markAllMaterialsAsDirty(O.a.MATERIAL_TextureDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(S.prototype, "wrapU", { get: function() {
+ return this._wrapU;
+ }, set: function(E) {
+ this._wrapU = E;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(S.prototype, "wrapV", { get: function() {
+ return this._wrapV;
+ }, set: function(E) {
+ this._wrapV = E;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(S.prototype, "isCube", { get: function() {
+ return this._texture ? this._texture.isCube : this._isCube;
+ }, set: function(E) {
+ this._texture ? this._texture.isCube = E : this._isCube = E;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(S.prototype, "is3D", { get: function() {
+ return !!this._texture && this._texture.is3D;
+ }, set: function(E) {
+ this._texture && (this._texture.is3D = E);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(S.prototype, "is2DArray", { get: function() {
+ return !!this._texture && this._texture.is2DArray;
+ }, set: function(E) {
+ this._texture && (this._texture.is2DArray = E);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(S.prototype, "gammaSpace", { get: function() {
+ return this._texture ? (this._texture._gammaSpace === null && (this._texture._gammaSpace = this._gammaSpace), this._texture._gammaSpace) : this._gammaSpace;
+ }, set: function(E) {
+ if (this._texture) {
+ if (this._texture._gammaSpace === E)
+ return;
+ this._texture._gammaSpace = E;
+ } else {
+ if (this._gammaSpace === E)
+ return;
+ this._gammaSpace = E;
+ }
+ this._markAllSubMeshesAsTexturesDirty();
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(S.prototype, "isRGBD", { get: function() {
+ return this._texture != null && this._texture._isRGBD;
+ }, set: function(E) {
+ this._texture && (this._texture._isRGBD = E);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(S.prototype, "noMipmap", { get: function() {
+ return !1;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(S.prototype, "lodGenerationOffset", { get: function() {
+ return this._texture ? this._texture._lodGenerationOffset : 0;
+ }, set: function(E) {
+ this._texture && (this._texture._lodGenerationOffset = E);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(S.prototype, "lodGenerationScale", { get: function() {
+ return this._texture ? this._texture._lodGenerationScale : 0;
+ }, set: function(E) {
+ this._texture && (this._texture._lodGenerationScale = E);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(S.prototype, "linearSpecularLOD", { get: function() {
+ return !!this._texture && this._texture._linearSpecularLOD;
+ }, set: function(E) {
+ this._texture && (this._texture._linearSpecularLOD = E);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(S.prototype, "irradianceTexture", { get: function() {
+ return this._texture ? this._texture._irradianceTexture : null;
+ }, set: function(E) {
+ this._texture && (this._texture._irradianceTexture = E);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(S.prototype, "uid", { get: function() {
+ return this._uid || (this._uid = x.a.RandomId()), this._uid;
+ }, enumerable: !1, configurable: !0 }), S.prototype.toString = function() {
+ return this.name;
+ }, S.prototype.getClassName = function() {
+ return "BaseTexture";
+ }, Object.defineProperty(S.prototype, "onDispose", { set: function(E) {
+ this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver), this._onDisposeObserver = this.onDisposeObservable.add(E);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(S.prototype, "isBlocking", { get: function() {
+ return !0;
+ }, enumerable: !1, configurable: !0 }), S.prototype.getScene = function() {
+ return this._scene;
+ }, S.prototype._getEngine = function() {
+ return this._engine;
+ }, S.prototype.checkTransformsAreIdentical = function(E) {
+ return E !== null;
+ }, S.prototype.getTextureMatrix = function() {
+ return u.a.IdentityReadOnly;
+ }, S.prototype.getReflectionTextureMatrix = function() {
+ return u.a.IdentityReadOnly;
+ }, S.prototype.isReadyOrNotBlocking = function() {
+ return !this.isBlocking || this.isReady();
+ }, S.prototype.scale = function(E) {
+ }, Object.defineProperty(S.prototype, "canRescale", { get: function() {
+ return !1;
+ }, enumerable: !1, configurable: !0 }), S.prototype._getFromCache = function(E, g, l, h) {
+ var v = this._getEngine();
+ if (!v)
+ return null;
+ for (var b = v.getLoadedTexturesCache(), D = 0; D < b.length; D++) {
+ var w = b[D];
+ if (!(h !== void 0 && h !== w.invertY || w.url !== E || w.generateMipMaps !== !g || l && l !== w.samplingMode))
+ return w.incrementReferences(), w;
+ }
+ return null;
+ }, S.prototype._rebuild = function() {
+ }, S.prototype.clone = function() {
+ return null;
+ }, Object.defineProperty(S.prototype, "textureType", { get: function() {
+ return this._texture && this._texture.type !== void 0 ? this._texture.type : O.a.TEXTURETYPE_UNSIGNED_INT;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(S.prototype, "textureFormat", { get: function() {
+ return this._texture && this._texture.format !== void 0 ? this._texture.format : O.a.TEXTUREFORMAT_RGBA;
+ }, enumerable: !1, configurable: !0 }), S.prototype._markAllSubMeshesAsTexturesDirty = function() {
+ var E = this.getScene();
+ E && E.markAllMaterialsAsDirty(O.a.MATERIAL_TextureDirtyFlag);
+ }, S.prototype.readPixels = function(E, g, l) {
+ if (E === void 0 && (E = 0), g === void 0 && (g = 0), l === void 0 && (l = null), !this._texture)
+ return null;
+ var h = this.getSize(), v = h.width, b = h.height, D = this._getEngine();
+ if (!D)
+ return null;
+ g != 0 && (v /= Math.pow(2, g), b /= Math.pow(2, g), v = Math.round(v), b = Math.round(b));
+ try {
+ return this._texture.isCube ? D._readTexturePixels(this._texture, v, b, E, g, l) : D._readTexturePixels(this._texture, v, b, -1, g, l);
+ } catch {
+ return null;
+ }
+ }, Object.defineProperty(S.prototype, "_lodTextureHigh", { get: function() {
+ return this._texture ? this._texture._lodTextureHigh : null;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(S.prototype, "_lodTextureMid", { get: function() {
+ return this._texture ? this._texture._lodTextureMid : null;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(S.prototype, "_lodTextureLow", { get: function() {
+ return this._texture ? this._texture._lodTextureLow : null;
+ }, enumerable: !1, configurable: !0 }), S.prototype.dispose = function() {
+ if (this._scene) {
+ this._scene.stopAnimation && this._scene.stopAnimation(this), this._scene._removePendingData(this);
+ var E = this._scene.textures.indexOf(this);
+ E >= 0 && this._scene.textures.splice(E, 1), this._scene.onTextureRemovedObservable.notifyObservers(this), this._scene = null;
+ }
+ this.onDisposeObservable.notifyObservers(this), this.onDisposeObservable.clear(), T.prototype.dispose.call(this);
+ }, S.prototype.serialize = function() {
+ if (!this.name)
+ return null;
+ var E = _.a.Serialize(this);
+ return _.a.AppendSerializedAnimations(this, E), E;
+ }, S.WhenAllReady = function(E, g) {
+ var l = E.length;
+ if (l !== 0)
+ for (var h = 0; h < E.length; h++) {
+ var v = E[h];
+ if (v.isReady())
+ --l == 0 && g();
+ else {
+ var b = v.onLoadObservable;
+ b && b.addOnce(function() {
+ --l == 0 && g();
+ });
+ }
+ }
+ else
+ g();
+ }, S._isScene = function(E) {
+ return E.getClassName() === "Scene";
+ }, S.DEFAULT_ANISOTROPIC_FILTERING_LEVEL = 4, Object(V.c)([Object(_.c)()], S.prototype, "uniqueId", void 0), Object(V.c)([Object(_.c)()], S.prototype, "name", void 0), Object(V.c)([Object(_.c)()], S.prototype, "metadata", void 0), Object(V.c)([Object(_.c)("hasAlpha")], S.prototype, "_hasAlpha", void 0), Object(V.c)([Object(_.c)()], S.prototype, "getAlphaFromRGB", void 0), Object(V.c)([Object(_.c)()], S.prototype, "level", void 0), Object(V.c)([Object(_.c)()], S.prototype, "coordinatesIndex", void 0), Object(V.c)([Object(_.c)("coordinatesMode")], S.prototype, "_coordinatesMode", void 0), Object(V.c)([Object(_.c)()], S.prototype, "wrapU", null), Object(V.c)([Object(_.c)()], S.prototype, "wrapV", null), Object(V.c)([Object(_.c)()], S.prototype, "wrapR", void 0), Object(V.c)([Object(_.c)()], S.prototype, "anisotropicFilteringLevel", void 0), Object(V.c)([Object(_.c)()], S.prototype, "isCube", null), Object(V.c)([Object(_.c)()], S.prototype, "is3D", null), Object(V.c)([Object(_.c)()], S.prototype, "is2DArray", null), Object(V.c)([Object(_.c)()], S.prototype, "gammaSpace", null), Object(V.c)([Object(_.c)()], S.prototype, "invertZ", void 0), Object(V.c)([Object(_.c)()], S.prototype, "lodLevelInAlpha", void 0), Object(V.c)([Object(_.c)()], S.prototype, "lodGenerationOffset", null), Object(V.c)([Object(_.c)()], S.prototype, "lodGenerationScale", null), Object(V.c)([Object(_.c)()], S.prototype, "linearSpecularLOD", null), Object(V.c)([Object(_.m)()], S.prototype, "irradianceTexture", null), Object(V.c)([Object(_.c)()], S.prototype, "isRenderTarget", void 0), S;
+ }(function() {
+ function T(S) {
+ this._wrapU = O.a.TEXTURE_WRAP_ADDRESSMODE, this._wrapV = O.a.TEXTURE_WRAP_ADDRESSMODE, this.wrapR = O.a.TEXTURE_WRAP_ADDRESSMODE, this.anisotropicFilteringLevel = 4, this.delayLoadState = O.a.DELAYLOADSTATE_NONE, this._texture = null, this._engine = null, this._cachedSize = m.a.Zero(), this._cachedBaseSize = m.a.Zero(), this._texture = S, this._texture && (this._engine = this._texture.getEngine());
+ }
+ return Object.defineProperty(T.prototype, "wrapU", { get: function() {
+ return this._wrapU;
+ }, set: function(S) {
+ this._wrapU = S;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(T.prototype, "wrapV", { get: function() {
+ return this._wrapV;
+ }, set: function(S) {
+ this._wrapV = S;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(T.prototype, "coordinatesMode", { get: function() {
+ return 0;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(T.prototype, "isCube", { get: function() {
+ return !!this._texture && this._texture.isCube;
+ }, set: function(S) {
+ this._texture && (this._texture.isCube = S);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(T.prototype, "is3D", { get: function() {
+ return !!this._texture && this._texture.is3D;
+ }, set: function(S) {
+ this._texture && (this._texture.is3D = S);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(T.prototype, "is2DArray", { get: function() {
+ return !!this._texture && this._texture.is2DArray;
+ }, set: function(S) {
+ this._texture && (this._texture.is2DArray = S);
+ }, enumerable: !1, configurable: !0 }), T.prototype.getClassName = function() {
+ return "ThinTexture";
+ }, T.prototype.isReady = function() {
+ return this.delayLoadState === O.a.DELAYLOADSTATE_NOTLOADED ? (this.delayLoad(), !1) : !!this._texture && this._texture.isReady;
+ }, T.prototype.delayLoad = function() {
+ }, T.prototype.getInternalTexture = function() {
+ return this._texture;
+ }, T.prototype.getSize = function() {
+ if (this._texture) {
+ if (this._texture.width)
+ return this._cachedSize.width = this._texture.width, this._cachedSize.height = this._texture.height, this._cachedSize;
+ if (this._texture._size)
+ return this._cachedSize.width = this._texture._size, this._cachedSize.height = this._texture._size, this._cachedSize;
+ }
+ return this._cachedSize;
+ }, T.prototype.getBaseSize = function() {
+ return this.isReady() && this._texture ? this._texture._size ? (this._cachedBaseSize.width = this._texture._size, this._cachedBaseSize.height = this._texture._size, this._cachedBaseSize) : (this._cachedBaseSize.width = this._texture.baseWidth, this._cachedBaseSize.height = this._texture.baseHeight, this._cachedBaseSize) : (this._cachedBaseSize.width = 0, this._cachedBaseSize.height = 0, this._cachedBaseSize);
+ }, T.prototype.updateSamplingMode = function(S) {
+ this._texture && this._engine && this._engine.updateTextureSamplingMode(S, this._texture);
+ }, T.prototype.releaseInternalTexture = function() {
+ this._texture && (this._texture.dispose(), this._texture = null);
+ }, T.prototype.dispose = function() {
+ this._texture && (this.releaseInternalTexture(), this._engine = null);
+ }, T;
+ }());
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return x;
+ });
+ var V = f(0), _ = f(9), C = f(7), u = f(16), I = f(20), O = f(23);
+ u.a.CreateCylinder = function(m) {
+ var c = m.height || 2, T = m.diameterTop === 0 ? 0 : m.diameterTop || m.diameter || 1, S = m.diameterBottom === 0 ? 0 : m.diameterBottom || m.diameter || 1;
+ T = T || 1e-5, S = S || 1e-5;
+ var E, g = m.tessellation || 24, l = m.subdivisions || 1, h = !!m.hasRings, v = !!m.enclose, b = m.cap === 0 ? 0 : m.cap || C.a.CAP_ALL, D = m.arc && (m.arc <= 0 || m.arc > 1) ? 1 : m.arc || 1, w = m.sideOrientation === 0 ? 0 : m.sideOrientation || u.a.DEFAULTSIDE, N = m.faceUV || new Array(3), M = m.faceColors, U = 2 + (1 + (D !== 1 && v ? 2 : 0)) * (h ? l : 1);
+ for (E = 0; E < U; E++)
+ M && M[E] === void 0 && (M[E] = new _.b(1, 1, 1, 1));
+ for (E = 0; E < U; E++)
+ N && N[E] === void 0 && (N[E] = new V.f(0, 0, 1, 1));
+ var X, j, ne, te, de, pe, ae = new Array(), ee = new Array(), K = new Array(), $ = new Array(), L = new Array(), G = 2 * Math.PI * D / g, Q = (S - T) / 2 / c, oe = V.e.Zero(), re = V.e.Zero(), Y = V.e.Zero(), k = V.e.Zero(), H = V.e.Zero(), Z = O.a.Y, W = 1, q = 1, he = 0, ge = 0;
+ for (te = 0; te <= l; te++)
+ for (ne = ((j = te / l) * (T - S) + S) / 2, W = h && te !== 0 && te !== l ? 2 : 1, pe = 0; pe < W; pe++) {
+ for (h && (q += pe), v && (q += 2 * pe), de = 0; de <= g; de++)
+ X = de * G, oe.x = Math.cos(-X) * ne, oe.y = -c / 2 + j * c, oe.z = Math.sin(-X) * ne, T === 0 && te === l ? (re.x = K[K.length - 3 * (g + 1)], re.y = K[K.length - 3 * (g + 1) + 1], re.z = K[K.length - 3 * (g + 1) + 2]) : (re.x = oe.x, re.z = oe.z, re.y = Math.sqrt(re.x * re.x + re.z * re.z) * Q, re.normalize()), de === 0 && (Y.copyFrom(oe), k.copyFrom(re)), ee.push(oe.x, oe.y, oe.z), K.push(re.x, re.y, re.z), ge = h ? he !== q ? N[q].y : N[q].w : N[q].y + (N[q].w - N[q].y) * j, $.push(N[q].x + (N[q].z - N[q].x) * de / g, ge), M && L.push(M[q].r, M[q].g, M[q].b, M[q].a);
+ D !== 1 && v && (ee.push(oe.x, oe.y, oe.z), ee.push(0, oe.y, 0), ee.push(0, oe.y, 0), ee.push(Y.x, Y.y, Y.z), V.e.CrossToRef(Z, re, H), H.normalize(), K.push(H.x, H.y, H.z, H.x, H.y, H.z), V.e.CrossToRef(k, Z, H), H.normalize(), K.push(H.x, H.y, H.z, H.x, H.y, H.z), ge = h ? he !== q ? N[q + 1].y : N[q + 1].w : N[q + 1].y + (N[q + 1].w - N[q + 1].y) * j, $.push(N[q + 1].x, ge), $.push(N[q + 1].z, ge), ge = h ? he !== q ? N[q + 2].y : N[q + 2].w : N[q + 2].y + (N[q + 2].w - N[q + 2].y) * j, $.push(N[q + 2].x, ge), $.push(N[q + 2].z, ge), M && (L.push(M[q + 1].r, M[q + 1].g, M[q + 1].b, M[q + 1].a), L.push(M[q + 1].r, M[q + 1].g, M[q + 1].b, M[q + 1].a), L.push(M[q + 2].r, M[q + 2].g, M[q + 2].b, M[q + 2].a), L.push(M[q + 2].r, M[q + 2].g, M[q + 2].b, M[q + 2].a))), he !== q && (he = q);
+ }
+ var me = D !== 1 && v ? g + 4 : g;
+ for (te = 0, q = 0; q < l; q++) {
+ var _e = 0, ye = 0, Pe = 0, be = 0;
+ for (de = 0; de < g; de++)
+ _e = te * (me + 1) + de, ye = (te + 1) * (me + 1) + de, Pe = te * (me + 1) + (de + 1), be = (te + 1) * (me + 1) + (de + 1), ae.push(_e, ye, Pe), ae.push(be, Pe, ye);
+ D !== 1 && v && (ae.push(_e + 2, ye + 2, Pe + 2), ae.push(be + 2, Pe + 2, ye + 2), ae.push(_e + 4, ye + 4, Pe + 4), ae.push(be + 4, Pe + 4, ye + 4)), te = h ? te + 2 : te + 1;
+ }
+ var Fe = function(We) {
+ var je = We ? T / 2 : S / 2;
+ if (je !== 0) {
+ var He, Qe, Ge, tt = We ? N[U - 1] : N[0], Je = null;
+ M && (Je = We ? M[U - 1] : M[0]);
+ var st = ee.length / 3, at = We ? c / 2 : -c / 2, pt = new V.e(0, at, 0);
+ ee.push(pt.x, pt.y, pt.z), K.push(0, We ? 1 : -1, 0), $.push(tt.x + 0.5 * (tt.z - tt.x), tt.y + 0.5 * (tt.w - tt.y)), Je && L.push(Je.r, Je.g, Je.b, Je.a);
+ var Tt = new V.d(0.5, 0.5);
+ for (Ge = 0; Ge <= g; Ge++) {
+ He = 2 * Math.PI * Ge * D / g;
+ var Lt = Math.cos(-He), Ot = Math.sin(-He);
+ Qe = new V.e(Lt * je, at, Ot * je);
+ var St = new V.d(Lt * Tt.x + 0.5, Ot * Tt.y + 0.5);
+ ee.push(Qe.x, Qe.y, Qe.z), K.push(0, We ? 1 : -1, 0), $.push(tt.x + (tt.z - tt.x) * St.x, tt.y + (tt.w - tt.y) * St.y), Je && L.push(Je.r, Je.g, Je.b, Je.a);
+ }
+ for (Ge = 0; Ge < g; Ge++)
+ We ? (ae.push(st), ae.push(st + (Ge + 2)), ae.push(st + (Ge + 1))) : (ae.push(st), ae.push(st + (Ge + 1)), ae.push(st + (Ge + 2)));
+ }
+ };
+ b !== C.a.CAP_START && b !== C.a.CAP_ALL || Fe(!1), b !== C.a.CAP_END && b !== C.a.CAP_ALL || Fe(!0), u.a._ComputeSides(w, ee, ae, K, $, m.frontUVs, m.backUVs);
+ var ke = new u.a();
+ return ke.indices = ae, ke.positions = ee, ke.normals = K, ke.uvs = $, M && (ke.colors = L), ke;
+ }, C.a.CreateCylinder = function(m, c, T, S, E, g, l, h, v) {
+ l !== void 0 && l instanceof I.a || (l !== void 0 && (v = h || C.a.DEFAULTSIDE, h = l), l = g, g = 1);
+ var b = { height: c, diameterTop: T, diameterBottom: S, tessellation: E, subdivisions: g, sideOrientation: v, updatable: h };
+ return x.CreateCylinder(m, b, l);
+ };
+ var x = function() {
+ function m() {
+ }
+ return m.CreateCylinder = function(c, T, S) {
+ var E = new C.a(c, S);
+ return T.sideOrientation = C.a._GetDefaultSideOrientation(T.sideOrientation), E._originalBuilderSideOrientation = T.sideOrientation, u.a.CreateCylinder(T).applyToMesh(E, T.updatable), E;
+ }, m;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return C;
+ });
+ var V = f(0), _ = f(4), C = function() {
+ function u() {
+ this._pickingUnavailable = !1, this.hit = !1, this.distance = 0, this.pickedPoint = null, this.pickedMesh = null, this.bu = 0, this.bv = 0, this.faceId = -1, this.subMeshFaceId = -1, this.subMeshId = 0, this.pickedSprite = null, this.thinInstanceIndex = -1, this.originMesh = null, this.ray = null;
+ }
+ return u.prototype.getNormal = function(I, O) {
+ if (I === void 0 && (I = !1), O === void 0 && (O = !0), !this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_.b.NormalKind))
+ return null;
+ var x, m = this.pickedMesh.getIndices();
+ if (!m)
+ return null;
+ if (O) {
+ var c = this.pickedMesh.getVerticesData(_.b.NormalKind), T = V.e.FromArray(c, 3 * m[3 * this.faceId]), S = V.e.FromArray(c, 3 * m[3 * this.faceId + 1]), E = V.e.FromArray(c, 3 * m[3 * this.faceId + 2]);
+ T = T.scale(this.bu), S = S.scale(this.bv), E = E.scale(1 - this.bu - this.bv), x = new V.e(T.x + S.x + E.x, T.y + S.y + E.y, T.z + S.z + E.z);
+ } else {
+ var g = this.pickedMesh.getVerticesData(_.b.PositionKind), l = V.e.FromArray(g, 3 * m[3 * this.faceId]), h = V.e.FromArray(g, 3 * m[3 * this.faceId + 1]), v = V.e.FromArray(g, 3 * m[3 * this.faceId + 2]), b = l.subtract(h), D = v.subtract(h);
+ x = V.e.Cross(b, D);
+ }
+ if (I) {
+ var w = this.pickedMesh.getWorldMatrix();
+ this.pickedMesh.nonUniformScaling && (V.c.Matrix[0].copyFrom(w), (w = V.c.Matrix[0]).setTranslationFromFloats(0, 0, 0), w.invert(), w.transposeToRef(V.c.Matrix[1]), w = V.c.Matrix[1]), x = V.e.TransformNormal(x, w);
+ }
+ return x.normalize(), x;
+ }, u.prototype.getTextureCoordinates = function() {
+ if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_.b.UVKind))
+ return null;
+ var I = this.pickedMesh.getIndices();
+ if (!I)
+ return null;
+ var O = this.pickedMesh.getVerticesData(_.b.UVKind);
+ if (!O)
+ return null;
+ var x = V.d.FromArray(O, 2 * I[3 * this.faceId]), m = V.d.FromArray(O, 2 * I[3 * this.faceId + 1]), c = V.d.FromArray(O, 2 * I[3 * this.faceId + 2]);
+ return x = x.scale(this.bu), m = m.scale(this.bv), c = c.scale(1 - this.bu - this.bv), new V.d(x.x + m.x + c.x, x.y + m.y + c.y);
+ }, u;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return _;
+ });
+ var V = f(57), _ = function() {
+ function C() {
+ this._startMonitoringTime = 0, this._min = 0, this._max = 0, this._average = 0, this._lastSecAverage = 0, this._current = 0, this._totalValueCount = 0, this._totalAccumulated = 0, this._lastSecAccumulated = 0, this._lastSecTime = 0, this._lastSecValueCount = 0;
+ }
+ return Object.defineProperty(C.prototype, "min", { get: function() {
+ return this._min;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(C.prototype, "max", { get: function() {
+ return this._max;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(C.prototype, "average", { get: function() {
+ return this._average;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(C.prototype, "lastSecAverage", { get: function() {
+ return this._lastSecAverage;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(C.prototype, "current", { get: function() {
+ return this._current;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(C.prototype, "total", { get: function() {
+ return this._totalAccumulated;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(C.prototype, "count", { get: function() {
+ return this._totalValueCount;
+ }, enumerable: !1, configurable: !0 }), C.prototype.fetchNewFrame = function() {
+ this._totalValueCount++, this._current = 0, this._lastSecValueCount++;
+ }, C.prototype.addCount = function(u, I) {
+ C.Enabled && (this._current += u, I && this._fetchResult());
+ }, C.prototype.beginMonitoring = function() {
+ C.Enabled && (this._startMonitoringTime = V.a.Now);
+ }, C.prototype.endMonitoring = function(u) {
+ if (u === void 0 && (u = !0), C.Enabled) {
+ u && this.fetchNewFrame();
+ var I = V.a.Now;
+ this._current = I - this._startMonitoringTime, u && this._fetchResult();
+ }
+ }, C.prototype._fetchResult = function() {
+ this._totalAccumulated += this._current, this._lastSecAccumulated += this._current, this._min = Math.min(this._min, this._current), this._max = Math.max(this._max, this._current), this._average = this._totalAccumulated / this._totalValueCount;
+ var u = V.a.Now;
+ u - this._lastSecTime > 1e3 && (this._lastSecAverage = this._lastSecAccumulated / this._lastSecValueCount, this._lastSecTime = u, this._lastSecAccumulated = 0, this._lastSecValueCount = 0);
+ }, C.Enabled = !0, C;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "b", function() {
+ return S;
+ }), f.d(A, "d", function() {
+ return E;
+ }), f.d(A, "c", function() {
+ return g;
+ }), f.d(A, "a", function() {
+ return l;
+ });
+ var V = f(1), _ = f(49), C = f(38), u = f(6), I = f(83), O = f(140), x = function(h) {
+ function v() {
+ return h !== null && h.apply(this, arguments) || this;
+ }
+ return Object(V.d)(v, h), v._setPrototypeOf = Object.setPrototypeOf || function(b, D) {
+ return b.__proto__ = D, b;
+ }, v;
+ }(Error), m = f(34), c = f(26), T = f(128), S = function(h) {
+ function v(b, D) {
+ var w = h.call(this, b) || this;
+ return w.name = "LoadFileError", x._setPrototypeOf(w, v.prototype), D instanceof _.a ? w.request = D : w.file = D, w;
+ }
+ return Object(V.d)(v, h), v;
+ }(x), E = function(h) {
+ function v(b, D) {
+ var w = h.call(this, b) || this;
+ return w.request = D, w.name = "RequestFileError", x._setPrototypeOf(w, v.prototype), w;
+ }
+ return Object(V.d)(v, h), v;
+ }(x), g = function(h) {
+ function v(b, D) {
+ var w = h.call(this, b) || this;
+ return w.file = D, w.name = "ReadFileError", x._setPrototypeOf(w, v.prototype), w;
+ }
+ return Object(V.d)(v, h), v;
+ }(x), l = function() {
+ function h() {
+ }
+ return h._CleanUrl = function(v) {
+ return v = v.replace(/#/gm, "%23");
+ }, h.SetCorsBehavior = function(v, b) {
+ if ((!v || v.indexOf("data:") !== 0) && h.CorsBehavior)
+ if (typeof h.CorsBehavior == "string" || this.CorsBehavior instanceof String)
+ b.crossOrigin = h.CorsBehavior;
+ else {
+ var D = h.CorsBehavior(v);
+ D && (b.crossOrigin = D);
+ }
+ }, h.LoadImage = function(v, b, D, w, N) {
+ var M;
+ N === void 0 && (N = "");
+ var U = !1;
+ if (v instanceof ArrayBuffer || ArrayBuffer.isView(v) ? typeof Blob < "u" ? (M = URL.createObjectURL(new Blob([v], { type: N })), U = !0) : M = "data:" + N + ";base64," + m.a.EncodeArrayBufferToBase64(v) : v instanceof Blob ? (M = URL.createObjectURL(v), U = !0) : (M = h._CleanUrl(v), M = h.PreprocessUrl(v)), typeof Image > "u")
+ return h.LoadFile(M, function(ae) {
+ createImageBitmap(new Blob([ae], { type: N })).then(function(ee) {
+ b(ee), U && URL.revokeObjectURL(M);
+ }).catch(function(ee) {
+ D && D("Error while trying to load image: " + v, ee);
+ });
+ }, void 0, w || void 0, !0, function(ae, ee) {
+ D && D("Error while trying to load image: " + v, ee);
+ }), null;
+ var X = new Image();
+ h.SetCorsBehavior(M, X);
+ var j = function() {
+ X.removeEventListener("load", j), X.removeEventListener("error", ne), b(X), U && X.src && URL.revokeObjectURL(X.src);
+ }, ne = function(ae) {
+ if (X.removeEventListener("load", j), X.removeEventListener("error", ne), D) {
+ var ee = v.toString();
+ D("Error while trying to load image: " + (ee.length < 32 ? ee : ee.slice(0, 32) + "..."), ae);
+ }
+ U && X.src && URL.revokeObjectURL(X.src);
+ };
+ X.addEventListener("load", j), X.addEventListener("error", ne);
+ var te = function() {
+ X.src = M;
+ };
+ if (M.substr(0, 5) !== "data:" && w && w.enableTexturesOffline)
+ w.open(function() {
+ w && w.loadImage(M, X);
+ }, te);
+ else {
+ if (M.indexOf("file:") !== -1) {
+ var de = decodeURIComponent(M.substring(5).toLowerCase());
+ if (I.a.FilesToLoad[de]) {
+ try {
+ var pe;
+ try {
+ pe = URL.createObjectURL(I.a.FilesToLoad[de]);
+ } catch {
+ pe = URL.createObjectURL(I.a.FilesToLoad[de]);
+ }
+ X.src = pe, U = !0;
+ } catch {
+ X.src = "";
+ }
+ return X;
+ }
+ }
+ te();
+ }
+ return X;
+ }, h.ReadFile = function(v, b, D, w, N) {
+ var M = new FileReader(), U = { onCompleteObservable: new u.c(), abort: function() {
+ return M.abort();
+ } };
+ return M.onloadend = function(X) {
+ return U.onCompleteObservable.notifyObservers(U);
+ }, N && (M.onerror = function(X) {
+ N(new g("Unable to read " + v.name, v));
+ }), M.onload = function(X) {
+ b(X.target.result);
+ }, D && (M.onprogress = D), w ? M.readAsArrayBuffer(v) : M.readAsText(v), U;
+ }, h.LoadFile = function(v, b, D, w, N, M) {
+ if (v.indexOf("file:") !== -1) {
+ var U = decodeURIComponent(v.substring(5).toLowerCase());
+ U.indexOf("./") === 0 && (U = U.substring(2));
+ var X = I.a.FilesToLoad[U];
+ if (X)
+ return h.ReadFile(X, b, D, N, M ? function(j) {
+ return M(void 0, new S(j.message, j.file));
+ } : void 0);
+ }
+ return h.RequestFile(v, function(j, ne) {
+ b(j, ne ? ne.responseURL : void 0);
+ }, D, w, N, M ? function(j) {
+ M(j.request, new S(j.message, j.request));
+ } : void 0);
+ }, h.RequestFile = function(v, b, D, w, N, M, U) {
+ v = h._CleanUrl(v), v = h.PreprocessUrl(v);
+ var X = h.BaseUrl + v, j = !1, ne = { onCompleteObservable: new u.c(), abort: function() {
+ return j = !0;
+ } }, te = function() {
+ var pe = new _.a(), ae = null;
+ ne.abort = function() {
+ j = !0, pe.readyState !== (XMLHttpRequest.DONE || 4) && pe.abort(), ae !== null && (clearTimeout(ae), ae = null);
+ };
+ var ee = function(K) {
+ pe.open("GET", X), U && U(pe), N && (pe.responseType = "arraybuffer"), D && pe.addEventListener("progress", D);
+ var $ = function() {
+ pe.removeEventListener("loadend", $), ne.onCompleteObservable.notifyObservers(ne), ne.onCompleteObservable.clear();
+ };
+ pe.addEventListener("loadend", $);
+ var L = function() {
+ if (!j && pe.readyState === (XMLHttpRequest.DONE || 4)) {
+ if (pe.removeEventListener("readystatechange", L), pe.status >= 200 && pe.status < 300 || pe.status === 0 && (!C.a.IsWindowObjectExist() || h.IsFileURL()))
+ return void b(N ? pe.response : pe.responseText, pe);
+ var G = h.DefaultRetryStrategy;
+ if (G) {
+ var Q = G(X, pe, K);
+ if (Q !== -1)
+ return pe.removeEventListener("loadend", $), pe = new _.a(), void (ae = setTimeout(function() {
+ return ee(K + 1);
+ }, Q));
+ }
+ var oe = new E("Error status: " + pe.status + " " + pe.statusText + " - Unable to load " + X, pe);
+ M && M(oe);
+ }
+ };
+ pe.addEventListener("readystatechange", L), pe.send();
+ };
+ ee(0);
+ };
+ if (w && w.enableSceneOffline) {
+ var de = function(pe) {
+ pe && pe.status > 400 ? M && M(pe) : te();
+ };
+ w.open(function() {
+ w && w.loadFile(h.BaseUrl + v, function(pe) {
+ j || b(pe), ne.onCompleteObservable.notifyObservers(ne);
+ }, D ? function(pe) {
+ j || D(pe);
+ } : void 0, de, N);
+ }, de);
+ } else
+ te();
+ return ne;
+ }, h.IsFileURL = function() {
+ return typeof location < "u" && location.protocol === "file:";
+ }, h.DefaultRetryStrategy = O.a.ExponentialBackoff(), h.BaseUrl = "", h.CorsBehavior = "anonymous", h.PreprocessUrl = function(v) {
+ return v;
+ }, h;
+ }();
+ c.a._FileToolsLoadImage = l.LoadImage.bind(l), c.a._FileToolsLoadFile = l.LoadFile.bind(l), T.a._FileToolsLoadFile = l.LoadFile.bind(l);
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return _;
+ });
+ var V = f(38), _ = function() {
+ function C() {
+ }
+ return Object.defineProperty(C, "Now", { get: function() {
+ return V.a.IsWindowObjectExist() && window.performance && window.performance.now ? window.performance.now() : Date.now();
+ }, enumerable: !1, configurable: !0 }), C;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return V;
+ });
+ var V = function() {
+ function _(C, u, I, O) {
+ this.x = C, this.y = u, this.width = I, this.height = O;
+ }
+ return _.prototype.toGlobal = function(C, u) {
+ return new _(this.x * C, this.y * u, this.width * C, this.height * u);
+ }, _.prototype.toGlobalToRef = function(C, u, I) {
+ return I.x = this.x * C, I.y = this.y * u, I.width = this.width * C, I.height = this.height * u, this;
+ }, _.prototype.clone = function() {
+ return new _(this.x, this.y, this.width, this.height);
+ }, _;
+ }();
+ }, function(Be, A, f) {
+ var V = "helperFunctions", _ = `const float PI=3.1415926535897932384626433832795;
+const float HALF_MIN=5.96046448e-08;
+const float LinearEncodePowerApprox=2.2;
+const float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;
+const vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);
+const float Epsilon=0.0000001;
+#define saturate(x) clamp(x,0.0,1.0)
+#define absEps(x) abs(x)+Epsilon
+#define maxEps(x) max(x,Epsilon)
+#define saturateEps(x) clamp(x,Epsilon,1.0)
+mat3 transposeMat3(mat3 inMatrix) {
+vec3 i0=inMatrix[0];
+vec3 i1=inMatrix[1];
+vec3 i2=inMatrix[2];
+mat3 outMatrix=mat3(
+vec3(i0.x,i1.x,i2.x),
+vec3(i0.y,i1.y,i2.y),
+vec3(i0.z,i1.z,i2.z)
+);
+return outMatrix;
+}
+
+mat3 inverseMat3(mat3 inMatrix) {
+float a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];
+float a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];
+float a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];
+float b01=a22*a11-a12*a21;
+float b11=-a22*a10+a12*a20;
+float b21=a21*a10-a11*a20;
+float det=a00*b01+a01*b11+a02*b21;
+return mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),
+b11,(a22*a00-a02*a20),(-a12*a00+a02*a10),
+b21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;
+}
+float toLinearSpace(float color)
+{
+return pow(color,LinearEncodePowerApprox);
+}
+vec3 toLinearSpace(vec3 color)
+{
+return pow(color,vec3(LinearEncodePowerApprox));
+}
+vec4 toLinearSpace(vec4 color)
+{
+return vec4(pow(color.rgb,vec3(LinearEncodePowerApprox)),color.a);
+}
+vec3 toGammaSpace(vec3 color)
+{
+return pow(color,vec3(GammaEncodePowerApprox));
+}
+vec4 toGammaSpace(vec4 color)
+{
+return vec4(pow(color.rgb,vec3(GammaEncodePowerApprox)),color.a);
+}
+float toGammaSpace(float color)
+{
+return pow(color,GammaEncodePowerApprox);
+}
+float square(float value)
+{
+return value*value;
+}
+float pow5(float value) {
+float sq=value*value;
+return sq*sq*value;
+}
+float getLuminance(vec3 color)
+{
+return clamp(dot(color,LuminanceEncodeApprox),0.,1.);
+}
+
+float getRand(vec2 seed) {
+return fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);
+}
+float dither(vec2 seed,float varianceAmount) {
+float rand=getRand(seed);
+float dither=mix(-varianceAmount/255.0,varianceAmount/255.0,rand);
+return dither;
+}
+
+const float rgbdMaxRange=255.0;
+vec4 toRGBD(vec3 color) {
+float maxRGB=maxEps(max(color.r,max(color.g,color.b)));
+float D=max(rgbdMaxRange/maxRGB,1.);
+D=clamp(floor(D)/255.0,0.,1.);
+
+vec3 rgb=color.rgb*D;
+
+rgb=toGammaSpace(rgb);
+return vec4(rgb,D);
+}
+vec3 fromRGBD(vec4 rgbd) {
+
+rgbd.rgb=toLinearSpace(rgbd.rgb);
+
+return rgbd.rgb/rgbd.a;
+}
+`;
+ f(5).a.IncludesShadersStore[V] = _;
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return _;
+ });
+ var V = f(0), _ = function() {
+ function C() {
+ }
+ return C._RemoveAndStorePivotPoint = function(u) {
+ u && C._PivotCached === 0 && (u.getPivotPointToRef(C._OldPivotPoint), C._PivotPostMultiplyPivotMatrix = u._postMultiplyPivotMatrix, C._OldPivotPoint.equalsToFloats(0, 0, 0) || (u.setPivotMatrix(V.a.IdentityReadOnly), C._OldPivotPoint.subtractToRef(u.getPivotPoint(), C._PivotTranslation), C._PivotTmpVector.copyFromFloats(1, 1, 1), C._PivotTmpVector.subtractInPlace(u.scaling), C._PivotTmpVector.multiplyInPlace(C._PivotTranslation), u.position.addInPlace(C._PivotTmpVector))), C._PivotCached++;
+ }, C._RestorePivotPoint = function(u) {
+ u && !C._OldPivotPoint.equalsToFloats(0, 0, 0) && C._PivotCached === 1 && (u.setPivotPoint(C._OldPivotPoint), u._postMultiplyPivotMatrix = C._PivotPostMultiplyPivotMatrix, C._PivotTmpVector.copyFromFloats(1, 1, 1), C._PivotTmpVector.subtractInPlace(u.scaling), C._PivotTmpVector.multiplyInPlace(C._PivotTranslation), u.position.subtractInPlace(C._PivotTmpVector)), this._PivotCached--;
+ }, C._PivotCached = 0, C._OldPivotPoint = new V.e(), C._PivotTranslation = new V.e(), C._PivotTmpVector = new V.e(), C._PivotPostMultiplyPivotMatrix = !1, C;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return O;
+ });
+ var V = f(4), _ = f(114), C = f(43), u = f(2), I = f(101), O = function() {
+ function x(m, c, T, S, E, g, l, h, v) {
+ h === void 0 && (h = !0), v === void 0 && (v = !0), this.materialIndex = m, this.verticesStart = c, this.verticesCount = T, this.indexStart = S, this.indexCount = E, this._materialDefines = null, this._materialEffect = null, this._effectOverride = null, this._linesIndexCount = 0, this._linesIndexBuffer = null, this._lastColliderWorldVertices = null, this._lastColliderTransformMatrix = null, this._renderId = 0, this._alphaIndex = 0, this._distanceToCamera = 0, this._currentMaterial = null, this._mesh = g, this._renderingMesh = l || g, v && g.subMeshes.push(this), this._trianglePlanes = [], this._id = g.subMeshes.length - 1, h && (this.refreshBoundingInfo(), g.computeWorldMatrix(!0));
+ }
+ return Object.defineProperty(x.prototype, "materialDefines", { get: function() {
+ return this._materialDefines;
+ }, set: function(m) {
+ this._materialDefines = m;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(x.prototype, "effect", { get: function() {
+ var m;
+ return (m = this._effectOverride) !== null && m !== void 0 ? m : this._materialEffect;
+ }, enumerable: !1, configurable: !0 }), x.prototype.setEffect = function(m, c) {
+ c === void 0 && (c = null), this._materialEffect !== m ? (this._materialDefines = c, this._materialEffect = m) : m || (this._materialDefines = null);
+ }, x.AddToMesh = function(m, c, T, S, E, g, l, h) {
+ return h === void 0 && (h = !0), new x(m, c, T, S, E, g, l, h);
+ }, Object.defineProperty(x.prototype, "IsGlobal", { get: function() {
+ return this.verticesStart === 0 && this.verticesCount === this._mesh.getTotalVertices();
+ }, enumerable: !1, configurable: !0 }), x.prototype.getBoundingInfo = function() {
+ return this.IsGlobal ? this._mesh.getBoundingInfo() : this._boundingInfo;
+ }, x.prototype.setBoundingInfo = function(m) {
+ return this._boundingInfo = m, this;
+ }, x.prototype.getMesh = function() {
+ return this._mesh;
+ }, x.prototype.getRenderingMesh = function() {
+ return this._renderingMesh;
+ }, x.prototype.getReplacementMesh = function() {
+ return this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : null;
+ }, x.prototype.getEffectiveMesh = function() {
+ var m = this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : null;
+ return m || this._renderingMesh;
+ }, x.prototype.getMaterial = function() {
+ var m = this._renderingMesh.material;
+ if (m == null)
+ return this._mesh.getScene().defaultMaterial;
+ if (this._IsMultiMaterial(m)) {
+ var c = m.getSubMaterial(this.materialIndex);
+ return this._currentMaterial !== c && (this._currentMaterial = c, this._materialDefines = null), c;
+ }
+ return m;
+ }, x.prototype._IsMultiMaterial = function(m) {
+ return m.getSubMaterial !== void 0;
+ }, x.prototype.refreshBoundingInfo = function(m) {
+ if (m === void 0 && (m = null), this._lastColliderWorldVertices = null, this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry)
+ return this;
+ if (m || (m = this._renderingMesh.getVerticesData(V.b.PositionKind)), !m)
+ return this._boundingInfo = this._mesh.getBoundingInfo(), this;
+ var c, T = this._renderingMesh.getIndices();
+ if (this.indexStart === 0 && this.indexCount === T.length) {
+ var S = this._renderingMesh.getBoundingInfo();
+ c = { minimum: S.minimum.clone(), maximum: S.maximum.clone() };
+ } else
+ c = Object(I.b)(m, T, this.indexStart, this.indexCount, this._renderingMesh.geometry.boundingBias);
+ return this._boundingInfo ? this._boundingInfo.reConstruct(c.minimum, c.maximum) : this._boundingInfo = new C.a(c.minimum, c.maximum), this;
+ }, x.prototype._checkCollision = function(m) {
+ return this.getBoundingInfo()._checkCollision(m);
+ }, x.prototype.updateBoundingInfo = function(m) {
+ var c = this.getBoundingInfo();
+ return c || (this.refreshBoundingInfo(), c = this.getBoundingInfo()), c && c.update(m), this;
+ }, x.prototype.isInFrustum = function(m) {
+ var c = this.getBoundingInfo();
+ return !!c && c.isInFrustum(m, this._mesh.cullingStrategy);
+ }, x.prototype.isCompletelyInFrustum = function(m) {
+ var c = this.getBoundingInfo();
+ return !!c && c.isCompletelyInFrustum(m);
+ }, x.prototype.render = function(m) {
+ return this._renderingMesh.render(this, m, this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : void 0), this;
+ }, x.prototype._getLinesIndexBuffer = function(m, c) {
+ if (!this._linesIndexBuffer) {
+ for (var T = [], S = this.indexStart; S < this.indexStart + this.indexCount; S += 3)
+ T.push(m[S], m[S + 1], m[S + 1], m[S + 2], m[S + 2], m[S]);
+ this._linesIndexBuffer = c.createIndexBuffer(T), this._linesIndexCount = T.length;
+ }
+ return this._linesIndexBuffer;
+ }, x.prototype.canIntersects = function(m) {
+ var c = this.getBoundingInfo();
+ return !!c && m.intersectsBox(c.boundingBox);
+ }, x.prototype.intersects = function(m, c, T, S, E) {
+ var g = this.getMaterial();
+ if (!g)
+ return null;
+ var l = 3, h = !1;
+ switch (g.fillMode) {
+ case u.a.MATERIAL_PointListDrawMode:
+ case u.a.MATERIAL_LineListDrawMode:
+ case u.a.MATERIAL_LineLoopDrawMode:
+ case u.a.MATERIAL_LineStripDrawMode:
+ case u.a.MATERIAL_TriangleFanDrawMode:
+ return null;
+ case u.a.MATERIAL_TriangleStripDrawMode:
+ l = 1, h = !0;
+ }
+ return this._mesh.getClassName() === "InstancedLinesMesh" || this._mesh.getClassName() === "LinesMesh" ? T.length ? this._intersectLines(m, c, T, this._mesh.intersectionThreshold, S) : this._intersectUnIndexedLines(m, c, T, this._mesh.intersectionThreshold, S) : !T.length && this._mesh._unIndexed ? this._intersectUnIndexedTriangles(m, c, T, S, E) : this._intersectTriangles(m, c, T, l, h, S, E);
+ }, x.prototype._intersectLines = function(m, c, T, S, E) {
+ for (var g = null, l = this.indexStart; l < this.indexStart + this.indexCount; l += 2) {
+ var h = c[T[l]], v = c[T[l + 1]], b = m.intersectionSegment(h, v, S);
+ if (!(b < 0) && (E || !g || b < g.distance) && ((g = new _.a(null, null, b)).faceId = l / 2, E))
+ break;
+ }
+ return g;
+ }, x.prototype._intersectUnIndexedLines = function(m, c, T, S, E) {
+ for (var g = null, l = this.verticesStart; l < this.verticesStart + this.verticesCount; l += 2) {
+ var h = c[l], v = c[l + 1], b = m.intersectionSegment(h, v, S);
+ if (!(b < 0) && (E || !g || b < g.distance) && ((g = new _.a(null, null, b)).faceId = l / 2, E))
+ break;
+ }
+ return g;
+ }, x.prototype._intersectTriangles = function(m, c, T, S, E, g, l) {
+ for (var h = null, v = -1, b = this.indexStart; b < this.indexStart + this.indexCount; b += S) {
+ v++;
+ var D = T[b], w = T[b + 1], N = T[b + 2];
+ if (E && N === 4294967295)
+ b += 2;
+ else {
+ var M = c[D], U = c[w], X = c[N];
+ if (!l || l(M, U, X, m)) {
+ var j = m.intersectsTriangle(M, U, X);
+ if (j) {
+ if (j.distance < 0)
+ continue;
+ if ((g || !h || j.distance < h.distance) && ((h = j).faceId = v, g))
+ break;
+ }
+ }
+ }
+ }
+ return h;
+ }, x.prototype._intersectUnIndexedTriangles = function(m, c, T, S, E) {
+ for (var g = null, l = this.verticesStart; l < this.verticesStart + this.verticesCount; l += 3) {
+ var h = c[l], v = c[l + 1], b = c[l + 2];
+ if (!E || E(h, v, b, m)) {
+ var D = m.intersectsTriangle(h, v, b);
+ if (D) {
+ if (D.distance < 0)
+ continue;
+ if ((S || !g || D.distance < g.distance) && ((g = D).faceId = l / 3, S))
+ break;
+ }
+ }
+ }
+ return g;
+ }, x.prototype._rebuild = function() {
+ this._linesIndexBuffer && (this._linesIndexBuffer = null);
+ }, x.prototype.clone = function(m, c) {
+ var T = new x(this.materialIndex, this.verticesStart, this.verticesCount, this.indexStart, this.indexCount, m, c, !1);
+ if (!this.IsGlobal) {
+ var S = this.getBoundingInfo();
+ if (!S)
+ return T;
+ T._boundingInfo = new C.a(S.minimum, S.maximum);
+ }
+ return T;
+ }, x.prototype.dispose = function() {
+ this._linesIndexBuffer && (this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer), this._linesIndexBuffer = null);
+ var m = this._mesh.subMeshes.indexOf(this);
+ this._mesh.subMeshes.splice(m, 1);
+ }, x.prototype.getClassName = function() {
+ return "SubMesh";
+ }, x.CreateFromIndices = function(m, c, T, S, E) {
+ for (var g = Number.MAX_VALUE, l = -Number.MAX_VALUE, h = (E || S).getIndices(), v = c; v < c + T; v++) {
+ var b = h[v];
+ b < g && (g = b), b > l && (l = b);
+ }
+ return new x(m, g, l - g + 1, c, T, S, E);
+ }, x;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return O;
+ });
+ var V = f(1), _ = f(8), C = f(10), u = f(2), I = (f(126), f(70)), O = function(x) {
+ function m(c, T, S, E, g, l, h) {
+ S === void 0 && (S = null), g === void 0 && (g = u.a.TEXTURE_TRILINEAR_SAMPLINGMODE), l === void 0 && (l = u.a.TEXTUREFORMAT_RGBA);
+ var v = x.call(this, null, S, !E, h, g, void 0, void 0, void 0, void 0, l) || this;
+ v.name = c, v.wrapU = C.a.CLAMP_ADDRESSMODE, v.wrapV = C.a.CLAMP_ADDRESSMODE, v._generateMipMaps = E;
+ var b = v._getEngine();
+ if (!b)
+ return v;
+ T.getContext ? (v._canvas = T, v._texture = b.createDynamicTexture(T.width, T.height, E, g)) : (v._canvas = I.a.CreateCanvas(1, 1), T.width || T.width === 0 ? v._texture = b.createDynamicTexture(T.width, T.height, E, g) : v._texture = b.createDynamicTexture(T, T, E, g));
+ var D = v.getSize();
+ return v._canvas.width = D.width, v._canvas.height = D.height, v._context = v._canvas.getContext("2d"), v;
+ }
+ return Object(V.d)(m, x), m.prototype.getClassName = function() {
+ return "DynamicTexture";
+ }, Object.defineProperty(m.prototype, "canRescale", { get: function() {
+ return !0;
+ }, enumerable: !1, configurable: !0 }), m.prototype._recreate = function(c) {
+ this._canvas.width = c.width, this._canvas.height = c.height, this.releaseInternalTexture(), this._texture = this._getEngine().createDynamicTexture(c.width, c.height, this._generateMipMaps, this.samplingMode);
+ }, m.prototype.scale = function(c) {
+ var T = this.getSize();
+ T.width *= c, T.height *= c, this._recreate(T);
+ }, m.prototype.scaleTo = function(c, T) {
+ var S = this.getSize();
+ S.width = c, S.height = T, this._recreate(S);
+ }, m.prototype.getContext = function() {
+ return this._context;
+ }, m.prototype.clear = function() {
+ var c = this.getSize();
+ this._context.fillRect(0, 0, c.width, c.height);
+ }, m.prototype.update = function(c, T) {
+ T === void 0 && (T = !1), this._getEngine().updateDynamicTexture(this._texture, this._canvas, c === void 0 || c, T, this._format || void 0);
+ }, m.prototype.drawText = function(c, T, S, E, g, l, h, v) {
+ v === void 0 && (v = !0);
+ var b = this.getSize();
+ if (l && (this._context.fillStyle = l, this._context.fillRect(0, 0, b.width, b.height)), this._context.font = E, T == null) {
+ var D = this._context.measureText(c);
+ T = (b.width - D.width) / 2;
+ }
+ if (S == null) {
+ var w = parseInt(E.replace(/\D/g, ""));
+ S = b.height / 2 + w / 3.65;
+ }
+ this._context.fillStyle = g || "", this._context.fillText(c, T, S), v && this.update(h);
+ }, m.prototype.clone = function() {
+ var c = this.getScene();
+ if (!c)
+ return this;
+ var T = this.getSize(), S = new m(this.name, T, c, this._generateMipMaps);
+ return S.hasAlpha = this.hasAlpha, S.level = this.level, S.wrapU = this.wrapU, S.wrapV = this.wrapV, S;
+ }, m.prototype.serialize = function() {
+ var c = this.getScene();
+ c && !c.isReady() && _.a.Warn("The scene must be ready before serializing the dynamic texture");
+ var T = x.prototype.serialize.call(this);
+ return this._IsCanvasElement(this._canvas) && (T.base64String = this._canvas.toDataURL()), T.invertY = this._invertY, T.samplingMode = this.samplingMode, T;
+ }, m.prototype._IsCanvasElement = function(c) {
+ return c.toDataURL !== void 0;
+ }, m.prototype._rebuild = function() {
+ this.update();
+ }, m;
+ }(C.a);
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return I;
+ });
+ var V = f(0), _ = f(9), C = f(7), u = f(16);
+ u.a.CreateBox = function(O) {
+ var x, m = [0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7, 8, 9, 10, 8, 10, 11, 12, 13, 14, 12, 14, 15, 16, 17, 18, 16, 18, 19, 20, 21, 22, 20, 22, 23], c = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0], T = [], S = O.width || O.size || 1, E = O.height || O.size || 1, g = O.depth || O.size || 1, l = O.wrap || !1, h = O.topBaseAt === void 0 ? 1 : O.topBaseAt, v = O.bottomBaseAt === void 0 ? 0 : O.bottomBaseAt, b = [2, 0, 3, 1][h = (h + 4) % 4], D = [2, 0, 1, 3][v = (v + 4) % 4], w = [1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1];
+ if (l) {
+ m = [2, 3, 0, 2, 0, 1, 4, 5, 6, 4, 6, 7, 9, 10, 11, 9, 11, 8, 12, 14, 15, 12, 13, 14], w = [-1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1];
+ for (var N = [[1, 1, 1], [-1, 1, 1], [-1, 1, -1], [1, 1, -1]], M = [[-1, -1, 1], [1, -1, 1], [1, -1, -1], [-1, -1, -1]], U = [17, 18, 19, 16], X = [22, 23, 20, 21]; b > 0; )
+ N.unshift(N.pop()), U.unshift(U.pop()), b--;
+ for (; D > 0; )
+ M.unshift(M.pop()), X.unshift(X.pop()), D--;
+ N = N.flat(), M = M.flat(), w = w.concat(N).concat(M), m.push(U[0], U[2], U[3], U[0], U[1], U[2]), m.push(X[0], X[2], X[3], X[0], X[1], X[2]);
+ }
+ var j = [S / 2, E / 2, g / 2];
+ x = w.reduce(function(G, Q, oe) {
+ return G.concat(Q * j[oe % 3]);
+ }, []);
+ for (var ne = O.sideOrientation === 0 ? 0 : O.sideOrientation || u.a.DEFAULTSIDE, te = O.faceUV || new Array(6), de = O.faceColors, pe = [], ae = 0; ae < 6; ae++)
+ te[ae] === void 0 && (te[ae] = new V.f(0, 0, 1, 1)), de && de[ae] === void 0 && (de[ae] = new _.b(1, 1, 1, 1));
+ for (var ee = 0; ee < 6; ee++)
+ if (T.push(te[ee].z, te[ee].w), T.push(te[ee].x, te[ee].w), T.push(te[ee].x, te[ee].y), T.push(te[ee].z, te[ee].y), de)
+ for (var K = 0; K < 4; K++)
+ pe.push(de[ee].r, de[ee].g, de[ee].b, de[ee].a);
+ u.a._ComputeSides(ne, x, m, c, T, O.frontUVs, O.backUVs);
+ var $ = new u.a();
+ if ($.indices = m, $.positions = x, $.normals = c, $.uvs = T, de) {
+ var L = ne === u.a.DOUBLESIDE ? pe.concat(pe) : pe;
+ $.colors = L;
+ }
+ return $;
+ }, C.a.CreateBox = function(O, x, m, c, T) {
+ m === void 0 && (m = null);
+ var S = { size: x, sideOrientation: T, updatable: c };
+ return I.CreateBox(O, S, m);
+ };
+ var I = function() {
+ function O() {
+ }
+ return O.CreateBox = function(x, m, c) {
+ c === void 0 && (c = null);
+ var T = new C.a(x, c);
+ return m.sideOrientation = C.a._GetDefaultSideOrientation(m.sideOrientation), T._originalBuilderSideOrientation = m.sideOrientation, u.a.CreateBox(m).applyToMesh(T, m.updatable), T;
+ }, O;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return _;
+ });
+ var V = f(0), _ = function() {
+ function C(u, I, O, x) {
+ this.normal = new V.e(u, I, O), this.d = x;
+ }
+ return C.prototype.asArray = function() {
+ return [this.normal.x, this.normal.y, this.normal.z, this.d];
+ }, C.prototype.clone = function() {
+ return new C(this.normal.x, this.normal.y, this.normal.z, this.d);
+ }, C.prototype.getClassName = function() {
+ return "Plane";
+ }, C.prototype.getHashCode = function() {
+ var u = this.normal.getHashCode();
+ return u = 397 * u ^ (0 | this.d);
+ }, C.prototype.normalize = function() {
+ var u = Math.sqrt(this.normal.x * this.normal.x + this.normal.y * this.normal.y + this.normal.z * this.normal.z), I = 0;
+ return u !== 0 && (I = 1 / u), this.normal.x *= I, this.normal.y *= I, this.normal.z *= I, this.d *= I, this;
+ }, C.prototype.transform = function(u) {
+ var I = C._TmpMatrix;
+ u.invertToRef(I);
+ var O = I.m, x = this.normal.x, m = this.normal.y, c = this.normal.z, T = this.d;
+ return new C(x * O[0] + m * O[1] + c * O[2] + T * O[3], x * O[4] + m * O[5] + c * O[6] + T * O[7], x * O[8] + m * O[9] + c * O[10] + T * O[11], x * O[12] + m * O[13] + c * O[14] + T * O[15]);
+ }, C.prototype.dotCoordinate = function(u) {
+ return this.normal.x * u.x + this.normal.y * u.y + this.normal.z * u.z + this.d;
+ }, C.prototype.copyFromPoints = function(u, I, O) {
+ var x, m = I.x - u.x, c = I.y - u.y, T = I.z - u.z, S = O.x - u.x, E = O.y - u.y, g = O.z - u.z, l = c * g - T * E, h = T * S - m * g, v = m * E - c * S, b = Math.sqrt(l * l + h * h + v * v);
+ return x = b !== 0 ? 1 / b : 0, this.normal.x = l * x, this.normal.y = h * x, this.normal.z = v * x, this.d = -(this.normal.x * u.x + this.normal.y * u.y + this.normal.z * u.z), this;
+ }, C.prototype.isFrontFacingTo = function(u, I) {
+ return V.e.Dot(this.normal, u) <= I;
+ }, C.prototype.signedDistanceTo = function(u) {
+ return V.e.Dot(u, this.normal) + this.d;
+ }, C.FromArray = function(u) {
+ return new C(u[0], u[1], u[2], u[3]);
+ }, C.FromPoints = function(u, I, O) {
+ var x = new C(0, 0, 0, 0);
+ return x.copyFromPoints(u, I, O), x;
+ }, C.FromPositionAndNormal = function(u, I) {
+ var O = new C(0, 0, 0, 0);
+ return I.normalize(), O.normal = I, O.d = -(I.x * u.x + I.y * u.y + I.z * u.z), O;
+ }, C.SignedDistanceToPlaneFromPositionAndNormal = function(u, I, O) {
+ var x = -(I.x * u.x + I.y * u.y + I.z * u.z);
+ return V.e.Dot(O, I) + x;
+ }, C._TmpMatrix = V.a.Identity(), C;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return m;
+ });
+ var V = f(7), _ = f(20), C = f(6), u = f(0), I = f(18), O = f(39), x = f(60), m = (f(84), function() {
+ function c(T) {
+ this._useAlternatePickedPointAboveMaxDragAngleDragSpeed = -1.1, this.maxDragAngle = 0, this._useAlternatePickedPointAboveMaxDragAngle = !1, this.currentDraggingPointerID = -1, this.dragging = !1, this.dragDeltaRatio = 0.2, this.updateDragPlane = !0, this._debugMode = !1, this._moving = !1, this.onDragObservable = new C.c(), this.onDragStartObservable = new C.c(), this.onDragEndObservable = new C.c(), this.moveAttached = !0, this.enabled = !0, this.startAndReleaseDragOnPointerEvents = !0, this.detachCameraControls = !0, this.useObjectOrientationForDragging = !0, this.validateDrag = function(E) {
+ return !0;
+ }, this._tmpVector = new u.e(0, 0, 0), this._alternatePickedPoint = new u.e(0, 0, 0), this._worldDragAxis = new u.e(0, 0, 0), this._targetPosition = new u.e(0, 0, 0), this._attachedToElement = !1, this._startDragRay = new O.a(new u.e(), new u.e()), this._lastPointerRay = {}, this._dragDelta = new u.e(), this._pointA = new u.e(0, 0, 0), this._pointC = new u.e(0, 0, 0), this._localAxis = new u.e(0, 0, 0), this._lookAt = new u.e(0, 0, 0), this._options = T || {};
+ var S = 0;
+ if (this._options.dragAxis && S++, this._options.dragPlaneNormal && S++, S > 1)
+ throw "Multiple drag modes specified in dragBehavior options. Only one expected";
+ }
+ return Object.defineProperty(c.prototype, "options", { get: function() {
+ return this._options;
+ }, set: function(T) {
+ this._options = T;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(c.prototype, "name", { get: function() {
+ return "PointerDrag";
+ }, enumerable: !1, configurable: !0 }), c.prototype.init = function() {
+ }, c.prototype.attach = function(T, S) {
+ var E = this;
+ this._scene = T.getScene(), this.attachedNode = T, c._planeScene || (this._debugMode ? c._planeScene = this._scene : (c._planeScene = new _.a(this._scene.getEngine(), { virtual: !0 }), c._planeScene.detachControl(), this._scene.onDisposeObservable.addOnce(function() {
+ c._planeScene.dispose(), c._planeScene = null;
+ }))), this._dragPlane = V.a.CreatePlane("pointerDragPlane", this._debugMode ? 1 : 1e4, c._planeScene, !1, V.a.DOUBLESIDE), this.lastDragPosition = new u.e(0, 0, 0);
+ var g = S || function(l) {
+ return E.attachedNode == l || l.isDescendantOf(E.attachedNode);
+ };
+ this._pointerObserver = this._scene.onPointerObservable.add(function(l, h) {
+ if (E.enabled) {
+ if (l.type == I.a.POINTERDOWN)
+ E.startAndReleaseDragOnPointerEvents && !E.dragging && l.pickInfo && l.pickInfo.hit && l.pickInfo.pickedMesh && l.pickInfo.pickedPoint && l.pickInfo.ray && g(l.pickInfo.pickedMesh) && E._startDrag(l.event.pointerId, l.pickInfo.ray, l.pickInfo.pickedPoint);
+ else if (l.type == I.a.POINTERUP)
+ E.startAndReleaseDragOnPointerEvents && E.currentDraggingPointerID == l.event.pointerId && E.releaseDrag();
+ else if (l.type == I.a.POINTERMOVE) {
+ var v = l.event.pointerId;
+ if (E.currentDraggingPointerID === c._AnyMouseID && v !== c._AnyMouseID) {
+ var b = l.event;
+ (b.pointerType === "mouse" || !E._scene.getEngine().hostInformation.isMobile && b instanceof MouseEvent) && (E._lastPointerRay[E.currentDraggingPointerID] && (E._lastPointerRay[v] = E._lastPointerRay[E.currentDraggingPointerID], delete E._lastPointerRay[E.currentDraggingPointerID]), E.currentDraggingPointerID = v);
+ }
+ E._lastPointerRay[v] || (E._lastPointerRay[v] = new O.a(new u.e(), new u.e())), l.pickInfo && l.pickInfo.ray && (E._lastPointerRay[v].origin.copyFrom(l.pickInfo.ray.origin), E._lastPointerRay[v].direction.copyFrom(l.pickInfo.ray.direction), E.currentDraggingPointerID == v && E.dragging && E._moveDrag(l.pickInfo.ray));
+ }
+ }
+ }), this._beforeRenderObserver = this._scene.onBeforeRenderObservable.add(function() {
+ E._moving && E.moveAttached && (x.a._RemoveAndStorePivotPoint(E.attachedNode), E._targetPosition.subtractToRef(E.attachedNode.absolutePosition, E._tmpVector), E._tmpVector.scaleInPlace(E.dragDeltaRatio), E.attachedNode.getAbsolutePosition().addToRef(E._tmpVector, E._tmpVector), E.validateDrag(E._tmpVector) && E.attachedNode.setAbsolutePosition(E._tmpVector), x.a._RestorePivotPoint(E.attachedNode));
+ });
+ }, c.prototype.releaseDrag = function() {
+ if (this.dragging && (this.dragging = !1, this.onDragEndObservable.notifyObservers({ dragPlanePoint: this.lastDragPosition, pointerId: this.currentDraggingPointerID })), this.currentDraggingPointerID = -1, this._moving = !1, this.detachCameraControls && this._attachedToElement && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
+ if (this._scene.activeCamera.getClassName() === "ArcRotateCamera") {
+ var T = this._scene.activeCamera;
+ T.attachControl(!T.inputs || T.inputs.noPreventDefault, T._useCtrlForPanning, T._panningMouseButton);
+ } else
+ this._scene.activeCamera.attachControl(!this._scene.activeCamera.inputs || this._scene.activeCamera.inputs.noPreventDefault);
+ this._attachedToElement = !1;
+ }
+ }, c.prototype.startDrag = function(T, S, E) {
+ T === void 0 && (T = c._AnyMouseID), this._startDrag(T, S, E);
+ var g = this._lastPointerRay[T];
+ T === c._AnyMouseID && (g = this._lastPointerRay[Object.keys(this._lastPointerRay)[0]]), g && this._moveDrag(g);
+ }, c.prototype._startDrag = function(T, S, E) {
+ if (this._scene.activeCamera && !this.dragging && this.attachedNode) {
+ x.a._RemoveAndStorePivotPoint(this.attachedNode), S ? (this._startDragRay.direction.copyFrom(S.direction), this._startDragRay.origin.copyFrom(S.origin)) : (this._startDragRay.origin.copyFrom(this._scene.activeCamera.position), this.attachedNode.getWorldMatrix().getTranslationToRef(this._tmpVector), this._tmpVector.subtractToRef(this._scene.activeCamera.position, this._startDragRay.direction)), this._updateDragPlanePosition(this._startDragRay, E || this._tmpVector);
+ var g = this._pickWithRayOnDragPlane(this._startDragRay);
+ g && (this.dragging = !0, this.currentDraggingPointerID = T, this.lastDragPosition.copyFrom(g), this.onDragStartObservable.notifyObservers({ dragPlanePoint: g, pointerId: this.currentDraggingPointerID }), this._targetPosition.copyFrom(this.attachedNode.absolutePosition), this.detachCameraControls && this._scene.activeCamera && this._scene.activeCamera.inputs && !this._scene.activeCamera.leftCamera && (this._scene.activeCamera.inputs.attachedToElement ? (this._scene.activeCamera.detachControl(), this._attachedToElement = !0) : this._attachedToElement = !1)), x.a._RestorePivotPoint(this.attachedNode);
+ }
+ }, c.prototype._moveDrag = function(T) {
+ this._moving = !0;
+ var S = this._pickWithRayOnDragPlane(T);
+ if (S) {
+ this.updateDragPlane && this._updateDragPlanePosition(T, S);
+ var E = 0;
+ this._options.dragAxis ? (this.useObjectOrientationForDragging ? u.e.TransformCoordinatesToRef(this._options.dragAxis, this.attachedNode.getWorldMatrix().getRotationMatrix(), this._worldDragAxis) : this._worldDragAxis.copyFrom(this._options.dragAxis), S.subtractToRef(this.lastDragPosition, this._tmpVector), E = u.e.Dot(this._tmpVector, this._worldDragAxis), this._worldDragAxis.scaleToRef(E, this._dragDelta)) : (E = this._dragDelta.length(), S.subtractToRef(this.lastDragPosition, this._dragDelta)), this._targetPosition.addInPlace(this._dragDelta), this.onDragObservable.notifyObservers({ dragDistance: E, delta: this._dragDelta, dragPlanePoint: S, dragPlaneNormal: this._dragPlane.forward, pointerId: this.currentDraggingPointerID }), this.lastDragPosition.copyFrom(S);
+ }
+ }, c.prototype._pickWithRayOnDragPlane = function(T) {
+ var S = this;
+ if (!T)
+ return null;
+ var E = Math.acos(u.e.Dot(this._dragPlane.forward, T.direction));
+ if (E > Math.PI / 2 && (E = Math.PI - E), this.maxDragAngle > 0 && E > this.maxDragAngle) {
+ if (this._useAlternatePickedPointAboveMaxDragAngle) {
+ this._tmpVector.copyFrom(T.direction), this.attachedNode.absolutePosition.subtractToRef(T.origin, this._alternatePickedPoint), this._alternatePickedPoint.normalize(), this._alternatePickedPoint.scaleInPlace(this._useAlternatePickedPointAboveMaxDragAngleDragSpeed * u.e.Dot(this._alternatePickedPoint, this._tmpVector)), this._tmpVector.addInPlace(this._alternatePickedPoint);
+ var g = u.e.Dot(this._dragPlane.forward, this._tmpVector);
+ return this._dragPlane.forward.scaleToRef(-g, this._alternatePickedPoint), this._alternatePickedPoint.addInPlace(this._tmpVector), this._alternatePickedPoint.addInPlace(this.attachedNode.absolutePosition), this._alternatePickedPoint;
+ }
+ return null;
+ }
+ var l = c._planeScene.pickWithRay(T, function(h) {
+ return h == S._dragPlane;
+ });
+ return l && l.hit && l.pickedMesh && l.pickedPoint ? l.pickedPoint : null;
+ }, c.prototype._updateDragPlanePosition = function(T, S) {
+ this._pointA.copyFrom(S), this._options.dragAxis ? (this.useObjectOrientationForDragging ? u.e.TransformCoordinatesToRef(this._options.dragAxis, this.attachedNode.getWorldMatrix().getRotationMatrix(), this._localAxis) : this._localAxis.copyFrom(this._options.dragAxis), T.origin.subtractToRef(this._pointA, this._pointC), this._pointC.normalize(), Math.abs(u.e.Dot(this._localAxis, this._pointC)) > 0.999 ? Math.abs(u.e.Dot(u.e.UpReadOnly, this._pointC)) > 0.999 ? this._lookAt.copyFrom(u.e.Right()) : this._lookAt.copyFrom(u.e.UpReadOnly) : (u.e.CrossToRef(this._localAxis, this._pointC, this._lookAt), u.e.CrossToRef(this._localAxis, this._lookAt, this._lookAt), this._lookAt.normalize()), this._dragPlane.position.copyFrom(this._pointA), this._pointA.addToRef(this._lookAt, this._lookAt), this._dragPlane.lookAt(this._lookAt)) : this._options.dragPlaneNormal ? (this.useObjectOrientationForDragging ? u.e.TransformCoordinatesToRef(this._options.dragPlaneNormal, this.attachedNode.getWorldMatrix().getRotationMatrix(), this._localAxis) : this._localAxis.copyFrom(this._options.dragPlaneNormal), this._dragPlane.position.copyFrom(this._pointA), this._pointA.addToRef(this._localAxis, this._lookAt), this._dragPlane.lookAt(this._lookAt)) : (this._dragPlane.position.copyFrom(this._pointA), this._dragPlane.lookAt(T.origin)), this._dragPlane.position.copyFrom(this.attachedNode.absolutePosition), this._dragPlane.computeWorldMatrix(!0);
+ }, c.prototype.detach = function() {
+ this._pointerObserver && this._scene.onPointerObservable.remove(this._pointerObserver), this._beforeRenderObserver && this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver), this.releaseDrag();
+ }, c._AnyMouseID = -2, c;
+ }());
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return _;
+ }), f.d(A, "b", function() {
+ return C;
+ }), f.d(A, "c", function() {
+ return u;
+ });
+ var V = f(1), _ = function() {
+ function I() {
+ }
+ return I.KEYDOWN = 1, I.KEYUP = 2, I;
+ }(), C = function(I, O) {
+ this.type = I, this.event = O;
+ }, u = function(I) {
+ function O(x, m) {
+ var c = I.call(this, x, m) || this;
+ return c.type = x, c.event = m, c.skipOnPointerObservable = !1, c;
+ }
+ return Object(V.d)(O, I), O;
+ }(C);
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return V;
+ });
+ var V = function() {
+ function _() {
+ this._defines = {}, this._currentRank = 32, this._maxRank = -1, this._mesh = null;
+ }
+ return _.prototype.unBindMesh = function() {
+ this._mesh = null;
+ }, _.prototype.addFallback = function(C, u) {
+ this._defines[C] || (C < this._currentRank && (this._currentRank = C), C > this._maxRank && (this._maxRank = C), this._defines[C] = new Array()), this._defines[C].push(u);
+ }, _.prototype.addCPUSkinningFallback = function(C, u) {
+ this._mesh = u, C < this._currentRank && (this._currentRank = C), C > this._maxRank && (this._maxRank = C);
+ }, Object.defineProperty(_.prototype, "hasMoreFallbacks", { get: function() {
+ return this._currentRank <= this._maxRank;
+ }, enumerable: !1, configurable: !0 }), _.prototype.reduce = function(C, u) {
+ if (this._mesh && this._mesh.computeBonesUsingShaders && this._mesh.numBoneInfluencers > 0) {
+ this._mesh.computeBonesUsingShaders = !1, C = C.replace("#define NUM_BONE_INFLUENCERS " + this._mesh.numBoneInfluencers, "#define NUM_BONE_INFLUENCERS 0"), u._bonesComputationForcedToCPU = !0;
+ for (var I = this._mesh.getScene(), O = 0; O < I.meshes.length; O++) {
+ var x = I.meshes[O];
+ if (x.material) {
+ if (x.computeBonesUsingShaders && x.numBoneInfluencers !== 0) {
+ if (x.material.getEffect() === u)
+ x.computeBonesUsingShaders = !1;
+ else if (x.subMeshes) {
+ for (var m = 0, c = x.subMeshes; m < c.length; m++)
+ if (c[m].effect === u) {
+ x.computeBonesUsingShaders = !1;
+ break;
+ }
+ }
+ }
+ } else
+ !this._mesh.material && x.computeBonesUsingShaders && x.numBoneInfluencers > 0 && (x.computeBonesUsingShaders = !1);
+ }
+ } else {
+ var T = this._defines[this._currentRank];
+ if (T)
+ for (O = 0; O < T.length; O++)
+ C = C.replace("#define " + T[O], "");
+ this._currentRank++;
+ }
+ return C;
+ }, _;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return I;
+ });
+ var V = f(1), _ = f(25), C = f(37), u = f(11), I = function(O) {
+ function x(m, c) {
+ var T = O.call(this, m, c, !0) || this;
+ return c.multiMaterials.push(T), T.subMaterials = new Array(), T._storeEffectOnSubMeshes = !0, T;
+ }
+ return Object(V.d)(x, O), Object.defineProperty(x.prototype, "subMaterials", { get: function() {
+ return this._subMaterials;
+ }, set: function(m) {
+ this._subMaterials = m, this._hookArray(m);
+ }, enumerable: !1, configurable: !0 }), x.prototype.getChildren = function() {
+ return this.subMaterials;
+ }, x.prototype._hookArray = function(m) {
+ var c = this, T = m.push;
+ m.push = function() {
+ for (var E = [], g = 0; g < arguments.length; g++)
+ E[g] = arguments[g];
+ var l = T.apply(m, E);
+ return c._markAllSubMeshesAsTexturesDirty(), l;
+ };
+ var S = m.splice;
+ m.splice = function(E, g) {
+ var l = S.apply(m, [E, g]);
+ return c._markAllSubMeshesAsTexturesDirty(), l;
+ };
+ }, x.prototype.getSubMaterial = function(m) {
+ return m < 0 || m >= this.subMaterials.length ? this.getScene().defaultMaterial : this.subMaterials[m];
+ }, x.prototype.getActiveTextures = function() {
+ var m;
+ return (m = O.prototype.getActiveTextures.call(this)).concat.apply(m, this.subMaterials.map(function(c) {
+ return c ? c.getActiveTextures() : [];
+ }));
+ }, x.prototype.hasTexture = function(m) {
+ var c;
+ if (O.prototype.hasTexture.call(this, m))
+ return !0;
+ for (var T = 0; T < this.subMaterials.length; T++)
+ if (!((c = this.subMaterials[T]) === null || c === void 0) && c.hasTexture(m))
+ return !0;
+ return !1;
+ }, x.prototype.getClassName = function() {
+ return "MultiMaterial";
+ }, x.prototype.isReadyForSubMesh = function(m, c, T) {
+ for (var S = 0; S < this.subMaterials.length; S++) {
+ var E = this.subMaterials[S];
+ if (E) {
+ if (E._storeEffectOnSubMeshes) {
+ if (!E.isReadyForSubMesh(m, c, T))
+ return !1;
+ continue;
+ }
+ if (!E.isReady(m))
+ return !1;
+ }
+ }
+ return !0;
+ }, x.prototype.clone = function(m, c) {
+ for (var T = new x(m, this.getScene()), S = 0; S < this.subMaterials.length; S++) {
+ var E = null, g = this.subMaterials[S];
+ E = c && g ? g.clone(m + "-" + g.name) : this.subMaterials[S], T.subMaterials.push(E);
+ }
+ return T;
+ }, x.prototype.serialize = function() {
+ var m = {};
+ m.name = this.name, m.id = this.id, C.a && (m.tags = C.a.GetTags(this)), m.materials = [];
+ for (var c = 0; c < this.subMaterials.length; c++) {
+ var T = this.subMaterials[c];
+ T ? m.materials.push(T.id) : m.materials.push(null);
+ }
+ return m;
+ }, x.prototype.dispose = function(m, c, T) {
+ var S = this.getScene();
+ if (S) {
+ if (T)
+ for (var E = 0; E < this.subMaterials.length; E++) {
+ var g = this.subMaterials[E];
+ g && g.dispose(m, c);
+ }
+ (E = S.multiMaterials.indexOf(this)) >= 0 && S.multiMaterials.splice(E, 1), O.prototype.dispose.call(this, m, c);
+ }
+ }, x.ParseMultiMaterial = function(m, c) {
+ var T = new x(m.name, c);
+ T.id = m.id, C.a && C.a.AddTagsTo(T, m.tags);
+ for (var S = 0; S < m.materials.length; S++) {
+ var E = m.materials[S];
+ E ? T.subMaterials.push(c.getLastMaterialByID(E)) : T.subMaterials.push(null);
+ }
+ return T;
+ }, x;
+ }(_.a);
+ u.a.RegisteredTypes["BABYLON.MultiMaterial"] = I;
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return _;
+ });
+ var V = f(2), _ = function() {
+ function C() {
+ }
+ return Object.defineProperty(C, "ForceFullSceneLoadingForIncremental", { get: function() {
+ return C._ForceFullSceneLoadingForIncremental;
+ }, set: function(u) {
+ C._ForceFullSceneLoadingForIncremental = u;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(C, "ShowLoadingScreen", { get: function() {
+ return C._ShowLoadingScreen;
+ }, set: function(u) {
+ C._ShowLoadingScreen = u;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(C, "loggingLevel", { get: function() {
+ return C._loggingLevel;
+ }, set: function(u) {
+ C._loggingLevel = u;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(C, "CleanBoneMatrixWeights", { get: function() {
+ return C._CleanBoneMatrixWeights;
+ }, set: function(u) {
+ C._CleanBoneMatrixWeights = u;
+ }, enumerable: !1, configurable: !0 }), C._ForceFullSceneLoadingForIncremental = !1, C._ShowLoadingScreen = !0, C._CleanBoneMatrixWeights = !1, C._loggingLevel = V.a.SCENELOADER_NO_LOGGING, C;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return V;
+ });
+ var V = function() {
+ function _() {
+ }
+ return _.CreateCanvas = function(C, u) {
+ if (typeof document > "u")
+ return new OffscreenCanvas(C, u);
+ var I = document.createElement("canvas");
+ return I.width = C, I.height = u, I;
+ }, _;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return E;
+ });
+ var V = f(0), _ = f(9), C = f(16), u = f(4), I = f(61), O = f(69), x = f(43), m = f(2), c = f(12), T = f(37), S = f(101), E = function() {
+ function g(l, h, v, b, D) {
+ b === void 0 && (b = !1), D === void 0 && (D = null), this.delayLoadState = m.a.DELAYLOADSTATE_NONE, this._totalVertices = 0, this._isDisposed = !1, this._indexBufferIsUpdatable = !1, this._positionsCache = [], this.useBoundingInfoFromGeometry = !1, this.id = l, this.uniqueId = h.getUniqueId(), this._engine = h.getEngine(), this._meshes = [], this._scene = h, this._vertexBuffers = {}, this._indices = [], this._updatable = b, v ? this.setAllVerticesData(v, b) : (this._totalVertices = 0, this._indices = []), this._engine.getCaps().vertexArrayObject && (this._vertexArrayObjects = {}), D && (this.applyToMesh(D), D.computeWorldMatrix(!0));
+ }
+ return Object.defineProperty(g.prototype, "boundingBias", { get: function() {
+ return this._boundingBias;
+ }, set: function(l) {
+ this._boundingBias ? this._boundingBias.copyFrom(l) : this._boundingBias = l.clone(), this._updateBoundingInfo(!0, null);
+ }, enumerable: !1, configurable: !0 }), g.CreateGeometryForMesh = function(l) {
+ var h = new g(g.RandomId(), l.getScene());
+ return h.applyToMesh(l), h;
+ }, Object.defineProperty(g.prototype, "meshes", { get: function() {
+ return this._meshes;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(g.prototype, "extend", { get: function() {
+ return this._extend;
+ }, enumerable: !1, configurable: !0 }), g.prototype.getScene = function() {
+ return this._scene;
+ }, g.prototype.getEngine = function() {
+ return this._engine;
+ }, g.prototype.isReady = function() {
+ return this.delayLoadState === m.a.DELAYLOADSTATE_LOADED || this.delayLoadState === m.a.DELAYLOADSTATE_NONE;
+ }, Object.defineProperty(g.prototype, "doNotSerialize", { get: function() {
+ for (var l = 0; l < this._meshes.length; l++)
+ if (!this._meshes[l].doNotSerialize)
+ return !1;
+ return !0;
+ }, enumerable: !1, configurable: !0 }), g.prototype._rebuild = function() {
+ for (var l in this._vertexArrayObjects && (this._vertexArrayObjects = {}), this._meshes.length !== 0 && this._indices && (this._indexBuffer = this._engine.createIndexBuffer(this._indices)), this._vertexBuffers)
+ this._vertexBuffers[l]._rebuild();
+ }, g.prototype.setAllVerticesData = function(l, h) {
+ l.applyToGeometry(this, h), this.notifyUpdate();
+ }, g.prototype.setVerticesData = function(l, h, v, b) {
+ v === void 0 && (v = !1), v && Array.isArray(h) && (h = new Float32Array(h));
+ var D = new u.b(this._engine, h, l, v, this._meshes.length === 0, b);
+ this.setVerticesBuffer(D);
+ }, g.prototype.removeVerticesData = function(l) {
+ this._vertexBuffers[l] && (this._vertexBuffers[l].dispose(), delete this._vertexBuffers[l]);
+ }, g.prototype.setVerticesBuffer = function(l, h) {
+ h === void 0 && (h = null);
+ var v = l.getKind();
+ if (this._vertexBuffers[v] && this._vertexBuffers[v].dispose(), this._vertexBuffers[v] = l, v === u.b.PositionKind) {
+ var b = l.getData();
+ h != null ? this._totalVertices = h : b != null && (this._totalVertices = b.length / (l.byteStride / 4)), this._updateExtend(b), this._resetPointsArrayCache();
+ for (var D = this._meshes, w = D.length, N = 0; N < w; N++) {
+ var M = D[N];
+ M._boundingInfo = new x.a(this._extend.minimum, this._extend.maximum), M._createGlobalSubMesh(!1), M.computeWorldMatrix(!0);
+ }
+ }
+ this.notifyUpdate(v), this._vertexArrayObjects && (this._disposeVertexArrayObjects(), this._vertexArrayObjects = {});
+ }, g.prototype.updateVerticesDataDirectly = function(l, h, v, b) {
+ b === void 0 && (b = !1);
+ var D = this.getVertexBuffer(l);
+ D && (D.updateDirectly(h, v, b), this.notifyUpdate(l));
+ }, g.prototype.updateVerticesData = function(l, h, v) {
+ v === void 0 && (v = !1);
+ var b = this.getVertexBuffer(l);
+ b && (b.update(h), l === u.b.PositionKind && this._updateBoundingInfo(v, h), this.notifyUpdate(l));
+ }, g.prototype._updateBoundingInfo = function(l, h) {
+ if (l && this._updateExtend(h), this._resetPointsArrayCache(), l)
+ for (var v = 0, b = this._meshes; v < b.length; v++) {
+ var D = b[v];
+ D._boundingInfo ? D._boundingInfo.reConstruct(this._extend.minimum, this._extend.maximum) : D._boundingInfo = new x.a(this._extend.minimum, this._extend.maximum);
+ for (var w = 0, N = D.subMeshes; w < N.length; w++)
+ N[w].refreshBoundingInfo();
+ }
+ }, g.prototype._bind = function(l, h) {
+ if (l) {
+ h === void 0 && (h = this._indexBuffer);
+ var v = this.getVertexBuffers();
+ v && (h == this._indexBuffer && this._vertexArrayObjects ? (this._vertexArrayObjects[l.key] || (this._vertexArrayObjects[l.key] = this._engine.recordVertexArrayObject(v, h, l)), this._engine.bindVertexArrayObject(this._vertexArrayObjects[l.key], h)) : this._engine.bindBuffers(v, h, l));
+ }
+ }, g.prototype.getTotalVertices = function() {
+ return this.isReady() ? this._totalVertices : 0;
+ }, g.prototype.getVerticesData = function(l, h, v) {
+ var b = this.getVertexBuffer(l);
+ if (!b)
+ return null;
+ var D = b.getData();
+ if (!D)
+ return null;
+ var w = b.getSize() * u.b.GetTypeByteLength(b.type), N = this._totalVertices * b.getSize();
+ if (b.type !== u.b.FLOAT || b.byteStride !== w) {
+ var M = [];
+ return b.forEach(N, function(te) {
+ return M.push(te);
+ }), M;
+ }
+ if (!(D instanceof Array || D instanceof Float32Array) || b.byteOffset !== 0 || D.length !== N) {
+ if (D instanceof Array) {
+ var U = b.byteOffset / 4;
+ return c.b.Slice(D, U, U + N);
+ }
+ if (D instanceof ArrayBuffer)
+ return new Float32Array(D, b.byteOffset, N);
+ if (U = D.byteOffset + b.byteOffset, v || h && this._meshes.length !== 1) {
+ var X = new Float32Array(N), j = new Float32Array(D.buffer, U, N);
+ return X.set(j), X;
+ }
+ var ne = U % 4;
+ return ne && (U = Math.max(0, U - ne)), new Float32Array(D.buffer, U, N);
+ }
+ return v || h && this._meshes.length !== 1 ? c.b.Slice(D) : D;
+ }, g.prototype.isVertexBufferUpdatable = function(l) {
+ var h = this._vertexBuffers[l];
+ return !!h && h.isUpdatable();
+ }, g.prototype.getVertexBuffer = function(l) {
+ return this.isReady() ? this._vertexBuffers[l] : null;
+ }, g.prototype.getVertexBuffers = function() {
+ return this.isReady() ? this._vertexBuffers : null;
+ }, g.prototype.isVerticesDataPresent = function(l) {
+ return this._vertexBuffers ? this._vertexBuffers[l] !== void 0 : !!this._delayInfo && this._delayInfo.indexOf(l) !== -1;
+ }, g.prototype.getVerticesDataKinds = function() {
+ var l, h = [];
+ if (!this._vertexBuffers && this._delayInfo)
+ for (l in this._delayInfo)
+ h.push(l);
+ else
+ for (l in this._vertexBuffers)
+ h.push(l);
+ return h;
+ }, g.prototype.updateIndices = function(l, h, v) {
+ if (v === void 0 && (v = !1), this._indexBuffer)
+ if (this._indexBufferIsUpdatable) {
+ var b = l.length !== this._indices.length;
+ if (v || (this._indices = l.slice()), this._engine.updateDynamicIndexBuffer(this._indexBuffer, l, h), b)
+ for (var D = 0, w = this._meshes; D < w.length; D++)
+ w[D]._createGlobalSubMesh(!0);
+ } else
+ this.setIndices(l, null, !0);
+ }, g.prototype.setIndices = function(l, h, v) {
+ h === void 0 && (h = null), v === void 0 && (v = !1), this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer), this._disposeVertexArrayObjects(), this._indices = l, this._indexBufferIsUpdatable = v, this._meshes.length !== 0 && this._indices && (this._indexBuffer = this._engine.createIndexBuffer(this._indices, v)), h != null && (this._totalVertices = h);
+ for (var b = 0, D = this._meshes; b < D.length; b++)
+ D[b]._createGlobalSubMesh(!0);
+ this.notifyUpdate();
+ }, g.prototype.getTotalIndices = function() {
+ return this.isReady() ? this._indices.length : 0;
+ }, g.prototype.getIndices = function(l, h) {
+ if (!this.isReady())
+ return null;
+ var v = this._indices;
+ if (h || l && this._meshes.length !== 1) {
+ for (var b = v.length, D = [], w = 0; w < b; w++)
+ D.push(v[w]);
+ return D;
+ }
+ return v;
+ }, g.prototype.getIndexBuffer = function() {
+ return this.isReady() ? this._indexBuffer : null;
+ }, g.prototype._releaseVertexArrayObject = function(l) {
+ l === void 0 && (l = null), l && this._vertexArrayObjects && this._vertexArrayObjects[l.key] && (this._engine.releaseVertexArrayObject(this._vertexArrayObjects[l.key]), delete this._vertexArrayObjects[l.key]);
+ }, g.prototype.releaseForMesh = function(l, h) {
+ var v = this._meshes, b = v.indexOf(l);
+ b !== -1 && (v.splice(b, 1), l._geometry = null, v.length === 0 && h && this.dispose());
+ }, g.prototype.applyToMesh = function(l) {
+ if (l._geometry !== this) {
+ var h = l._geometry;
+ h && h.releaseForMesh(l);
+ var v = this._meshes;
+ l._geometry = this, this._scene.pushGeometry(this), v.push(l), this.isReady() ? this._applyToMesh(l) : l._boundingInfo = this._boundingInfo;
+ }
+ }, g.prototype._updateExtend = function(l) {
+ l === void 0 && (l = null), this.useBoundingInfoFromGeometry && this._boundingInfo ? this._extend = { minimum: this._boundingInfo.minimum.clone(), maximum: this._boundingInfo.maximum.clone() } : (l || (l = this.getVerticesData(u.b.PositionKind)), this._extend = Object(S.a)(l, 0, this._totalVertices, this.boundingBias, 3));
+ }, g.prototype._applyToMesh = function(l) {
+ var h = this._meshes.length;
+ for (var v in this._vertexBuffers) {
+ h === 1 && this._vertexBuffers[v].create();
+ var b = this._vertexBuffers[v].getBuffer();
+ b && (b.references = h), v === u.b.PositionKind && (this._extend || this._updateExtend(), l._boundingInfo = new x.a(this._extend.minimum, this._extend.maximum), l._createGlobalSubMesh(!1), l._updateBoundingInfo());
+ }
+ h === 1 && this._indices && this._indices.length > 0 && (this._indexBuffer = this._engine.createIndexBuffer(this._indices)), this._indexBuffer && (this._indexBuffer.references = h), l._syncGeometryWithMorphTargetManager(), l.synchronizeInstances();
+ }, g.prototype.notifyUpdate = function(l) {
+ this.onGeometryUpdated && this.onGeometryUpdated(this, l);
+ for (var h = 0, v = this._meshes; h < v.length; h++)
+ v[h]._markSubMeshesAsAttributesDirty();
+ }, g.prototype.load = function(l, h) {
+ this.delayLoadState !== m.a.DELAYLOADSTATE_LOADING && (this.isReady() ? h && h() : (this.delayLoadState = m.a.DELAYLOADSTATE_LOADING, this._queueLoad(l, h)));
+ }, g.prototype._queueLoad = function(l, h) {
+ var v = this;
+ this.delayLoadingFile && (l._addPendingData(this), l._loadFile(this.delayLoadingFile, function(b) {
+ if (v._delayLoadingFunction) {
+ v._delayLoadingFunction(JSON.parse(b), v), v.delayLoadState = m.a.DELAYLOADSTATE_LOADED, v._delayInfo = [], l._removePendingData(v);
+ for (var D = v._meshes, w = D.length, N = 0; N < w; N++)
+ v._applyToMesh(D[N]);
+ h && h();
+ }
+ }, void 0, !0));
+ }, g.prototype.toLeftHanded = function() {
+ var l = this.getIndices(!1);
+ if (l != null && l.length > 0) {
+ for (var h = 0; h < l.length; h += 3) {
+ var v = l[h + 0];
+ l[h + 0] = l[h + 2], l[h + 2] = v;
+ }
+ this.setIndices(l);
+ }
+ var b = this.getVerticesData(u.b.PositionKind, !1);
+ if (b != null && b.length > 0) {
+ for (h = 0; h < b.length; h += 3)
+ b[h + 2] = -b[h + 2];
+ this.setVerticesData(u.b.PositionKind, b, !1);
+ }
+ var D = this.getVerticesData(u.b.NormalKind, !1);
+ if (D != null && D.length > 0) {
+ for (h = 0; h < D.length; h += 3)
+ D[h + 2] = -D[h + 2];
+ this.setVerticesData(u.b.NormalKind, D, !1);
+ }
+ }, g.prototype._resetPointsArrayCache = function() {
+ this._positions = null;
+ }, g.prototype._generatePointsArray = function() {
+ if (this._positions)
+ return !0;
+ var l = this.getVerticesData(u.b.PositionKind);
+ if (!l || l.length === 0)
+ return !1;
+ for (var h = 3 * this._positionsCache.length, v = this._positionsCache.length; h < l.length; h += 3, ++v)
+ this._positionsCache[v] = V.e.FromArray(l, h);
+ for (h = 0, v = 0; h < l.length; h += 3, ++v)
+ this._positionsCache[v].set(l[0 + h], l[1 + h], l[2 + h]);
+ return this._positionsCache.length = l.length / 3, this._positions = this._positionsCache, !0;
+ }, g.prototype.isDisposed = function() {
+ return this._isDisposed;
+ }, g.prototype._disposeVertexArrayObjects = function() {
+ if (this._vertexArrayObjects) {
+ for (var l in this._vertexArrayObjects)
+ this._engine.releaseVertexArrayObject(this._vertexArrayObjects[l]);
+ this._vertexArrayObjects = {};
+ }
+ }, g.prototype.dispose = function() {
+ var l, h = this._meshes, v = h.length;
+ for (l = 0; l < v; l++)
+ this.releaseForMesh(h[l]);
+ for (var b in this._meshes = [], this._disposeVertexArrayObjects(), this._vertexBuffers)
+ this._vertexBuffers[b].dispose();
+ this._vertexBuffers = {}, this._totalVertices = 0, this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer), this._indexBuffer = null, this._indices = [], this.delayLoadState = m.a.DELAYLOADSTATE_NONE, this.delayLoadingFile = null, this._delayLoadingFunction = null, this._delayInfo = [], this._boundingInfo = null, this._scene.removeGeometry(this), this._isDisposed = !0;
+ }, g.prototype.copy = function(l) {
+ var h = new C.a();
+ h.indices = [];
+ var v = this.getIndices();
+ if (v)
+ for (var b = 0; b < v.length; b++)
+ h.indices.push(v[b]);
+ var D, w = !1, N = !1;
+ for (D in this._vertexBuffers) {
+ var M = this.getVerticesData(D);
+ if (M && (M instanceof Float32Array ? h.set(new Float32Array(M), D) : h.set(M.slice(0), D), !N)) {
+ var U = this.getVertexBuffer(D);
+ U && (N = !(w = U.isUpdatable()));
+ }
+ }
+ var X = new g(l, this._scene, h, w);
+ for (D in X.delayLoadState = this.delayLoadState, X.delayLoadingFile = this.delayLoadingFile, X._delayLoadingFunction = this._delayLoadingFunction, this._delayInfo)
+ X._delayInfo = X._delayInfo || [], X._delayInfo.push(D);
+ return X._boundingInfo = new x.a(this._extend.minimum, this._extend.maximum), X;
+ }, g.prototype.serialize = function() {
+ var l = {};
+ return l.id = this.id, l.updatable = this._updatable, T.a && T.a.HasTags(this) && (l.tags = T.a.GetTags(this)), l;
+ }, g.prototype.toNumberArray = function(l) {
+ return Array.isArray(l) ? l : Array.prototype.slice.call(l);
+ }, g.prototype.serializeVerticeData = function() {
+ var l = this.serialize();
+ return this.isVerticesDataPresent(u.b.PositionKind) && (l.positions = this.toNumberArray(this.getVerticesData(u.b.PositionKind)), this.isVertexBufferUpdatable(u.b.PositionKind) && (l.positions._updatable = !0)), this.isVerticesDataPresent(u.b.NormalKind) && (l.normals = this.toNumberArray(this.getVerticesData(u.b.NormalKind)), this.isVertexBufferUpdatable(u.b.NormalKind) && (l.normals._updatable = !0)), this.isVerticesDataPresent(u.b.TangentKind) && (l.tangets = this.toNumberArray(this.getVerticesData(u.b.TangentKind)), this.isVertexBufferUpdatable(u.b.TangentKind) && (l.tangets._updatable = !0)), this.isVerticesDataPresent(u.b.UVKind) && (l.uvs = this.toNumberArray(this.getVerticesData(u.b.UVKind)), this.isVertexBufferUpdatable(u.b.UVKind) && (l.uvs._updatable = !0)), this.isVerticesDataPresent(u.b.UV2Kind) && (l.uv2s = this.toNumberArray(this.getVerticesData(u.b.UV2Kind)), this.isVertexBufferUpdatable(u.b.UV2Kind) && (l.uv2s._updatable = !0)), this.isVerticesDataPresent(u.b.UV3Kind) && (l.uv3s = this.toNumberArray(this.getVerticesData(u.b.UV3Kind)), this.isVertexBufferUpdatable(u.b.UV3Kind) && (l.uv3s._updatable = !0)), this.isVerticesDataPresent(u.b.UV4Kind) && (l.uv4s = this.toNumberArray(this.getVerticesData(u.b.UV4Kind)), this.isVertexBufferUpdatable(u.b.UV4Kind) && (l.uv4s._updatable = !0)), this.isVerticesDataPresent(u.b.UV5Kind) && (l.uv5s = this.toNumberArray(this.getVerticesData(u.b.UV5Kind)), this.isVertexBufferUpdatable(u.b.UV5Kind) && (l.uv5s._updatable = !0)), this.isVerticesDataPresent(u.b.UV6Kind) && (l.uv6s = this.toNumberArray(this.getVerticesData(u.b.UV6Kind)), this.isVertexBufferUpdatable(u.b.UV6Kind) && (l.uv6s._updatable = !0)), this.isVerticesDataPresent(u.b.ColorKind) && (l.colors = this.toNumberArray(this.getVerticesData(u.b.ColorKind)), this.isVertexBufferUpdatable(u.b.ColorKind) && (l.colors._updatable = !0)), this.isVerticesDataPresent(u.b.MatricesIndicesKind) && (l.matricesIndices = this.toNumberArray(this.getVerticesData(u.b.MatricesIndicesKind)), l.matricesIndices._isExpanded = !0, this.isVertexBufferUpdatable(u.b.MatricesIndicesKind) && (l.matricesIndices._updatable = !0)), this.isVerticesDataPresent(u.b.MatricesWeightsKind) && (l.matricesWeights = this.toNumberArray(this.getVerticesData(u.b.MatricesWeightsKind)), this.isVertexBufferUpdatable(u.b.MatricesWeightsKind) && (l.matricesWeights._updatable = !0)), l.indices = this.toNumberArray(this.getIndices()), l;
+ }, g.ExtractFromMesh = function(l, h) {
+ var v = l._geometry;
+ return v ? v.copy(h) : null;
+ }, g.RandomId = function() {
+ return c.b.RandomId();
+ }, g._ImportGeometry = function(l, h) {
+ var v = h.getScene(), b = l.geometryId;
+ if (b) {
+ var D = v.getGeometryByID(b);
+ D && D.applyToMesh(h);
+ } else if (l instanceof ArrayBuffer) {
+ var w = h._binaryInfo;
+ if (w.positionsAttrDesc && w.positionsAttrDesc.count > 0) {
+ var N = new Float32Array(l, w.positionsAttrDesc.offset, w.positionsAttrDesc.count);
+ h.setVerticesData(u.b.PositionKind, N, !1);
+ }
+ if (w.normalsAttrDesc && w.normalsAttrDesc.count > 0) {
+ var M = new Float32Array(l, w.normalsAttrDesc.offset, w.normalsAttrDesc.count);
+ h.setVerticesData(u.b.NormalKind, M, !1);
+ }
+ if (w.tangetsAttrDesc && w.tangetsAttrDesc.count > 0) {
+ var U = new Float32Array(l, w.tangetsAttrDesc.offset, w.tangetsAttrDesc.count);
+ h.setVerticesData(u.b.TangentKind, U, !1);
+ }
+ if (w.uvsAttrDesc && w.uvsAttrDesc.count > 0) {
+ var X = new Float32Array(l, w.uvsAttrDesc.offset, w.uvsAttrDesc.count);
+ h.setVerticesData(u.b.UVKind, X, !1);
+ }
+ if (w.uvs2AttrDesc && w.uvs2AttrDesc.count > 0) {
+ var j = new Float32Array(l, w.uvs2AttrDesc.offset, w.uvs2AttrDesc.count);
+ h.setVerticesData(u.b.UV2Kind, j, !1);
+ }
+ if (w.uvs3AttrDesc && w.uvs3AttrDesc.count > 0) {
+ var ne = new Float32Array(l, w.uvs3AttrDesc.offset, w.uvs3AttrDesc.count);
+ h.setVerticesData(u.b.UV3Kind, ne, !1);
+ }
+ if (w.uvs4AttrDesc && w.uvs4AttrDesc.count > 0) {
+ var te = new Float32Array(l, w.uvs4AttrDesc.offset, w.uvs4AttrDesc.count);
+ h.setVerticesData(u.b.UV4Kind, te, !1);
+ }
+ if (w.uvs5AttrDesc && w.uvs5AttrDesc.count > 0) {
+ var de = new Float32Array(l, w.uvs5AttrDesc.offset, w.uvs5AttrDesc.count);
+ h.setVerticesData(u.b.UV5Kind, de, !1);
+ }
+ if (w.uvs6AttrDesc && w.uvs6AttrDesc.count > 0) {
+ var pe = new Float32Array(l, w.uvs6AttrDesc.offset, w.uvs6AttrDesc.count);
+ h.setVerticesData(u.b.UV6Kind, pe, !1);
+ }
+ if (w.colorsAttrDesc && w.colorsAttrDesc.count > 0) {
+ var ae = new Float32Array(l, w.colorsAttrDesc.offset, w.colorsAttrDesc.count);
+ h.setVerticesData(u.b.ColorKind, ae, !1, w.colorsAttrDesc.stride);
+ }
+ if (w.matricesIndicesAttrDesc && w.matricesIndicesAttrDesc.count > 0) {
+ for (var ee = new Int32Array(l, w.matricesIndicesAttrDesc.offset, w.matricesIndicesAttrDesc.count), K = [], $ = 0; $ < ee.length; $++) {
+ var L = ee[$];
+ K.push(255 & L), K.push((65280 & L) >> 8), K.push((16711680 & L) >> 16), K.push(L >> 24 & 255);
+ }
+ h.setVerticesData(u.b.MatricesIndicesKind, K, !1);
+ }
+ if (w.matricesIndicesExtraAttrDesc && w.matricesIndicesExtraAttrDesc.count > 0) {
+ for (ee = new Int32Array(l, w.matricesIndicesExtraAttrDesc.offset, w.matricesIndicesExtraAttrDesc.count), K = [], $ = 0; $ < ee.length; $++)
+ L = ee[$], K.push(255 & L), K.push((65280 & L) >> 8), K.push((16711680 & L) >> 16), K.push(L >> 24 & 255);
+ h.setVerticesData(u.b.MatricesIndicesExtraKind, K, !1);
+ }
+ if (w.matricesWeightsAttrDesc && w.matricesWeightsAttrDesc.count > 0) {
+ var G = new Float32Array(l, w.matricesWeightsAttrDesc.offset, w.matricesWeightsAttrDesc.count);
+ h.setVerticesData(u.b.MatricesWeightsKind, G, !1);
+ }
+ if (w.indicesAttrDesc && w.indicesAttrDesc.count > 0) {
+ var Q = new Int32Array(l, w.indicesAttrDesc.offset, w.indicesAttrDesc.count);
+ h.setIndices(Q, null);
+ }
+ if (w.subMeshesAttrDesc && w.subMeshesAttrDesc.count > 0) {
+ var oe = new Int32Array(l, w.subMeshesAttrDesc.offset, 5 * w.subMeshesAttrDesc.count);
+ for (h.subMeshes = [], $ = 0; $ < w.subMeshesAttrDesc.count; $++) {
+ var re = oe[5 * $ + 0], Y = oe[5 * $ + 1], k = oe[5 * $ + 2], H = oe[5 * $ + 3], Z = oe[5 * $ + 4];
+ I.a.AddToMesh(re, Y, k, H, Z, h);
+ }
+ }
+ } else if (l.positions && l.normals && l.indices) {
+ if (h.setVerticesData(u.b.PositionKind, l.positions, l.positions._updatable), h.setVerticesData(u.b.NormalKind, l.normals, l.normals._updatable), l.tangents && h.setVerticesData(u.b.TangentKind, l.tangents, l.tangents._updatable), l.uvs && h.setVerticesData(u.b.UVKind, l.uvs, l.uvs._updatable), l.uvs2 && h.setVerticesData(u.b.UV2Kind, l.uvs2, l.uvs2._updatable), l.uvs3 && h.setVerticesData(u.b.UV3Kind, l.uvs3, l.uvs3._updatable), l.uvs4 && h.setVerticesData(u.b.UV4Kind, l.uvs4, l.uvs4._updatable), l.uvs5 && h.setVerticesData(u.b.UV5Kind, l.uvs5, l.uvs5._updatable), l.uvs6 && h.setVerticesData(u.b.UV6Kind, l.uvs6, l.uvs6._updatable), l.colors && h.setVerticesData(u.b.ColorKind, _.b.CheckColors4(l.colors, l.positions.length / 3), l.colors._updatable), l.matricesIndices)
+ if (l.matricesIndices._isExpanded)
+ delete l.matricesIndices._isExpanded, h.setVerticesData(u.b.MatricesIndicesKind, l.matricesIndices, l.matricesIndices._updatable);
+ else {
+ for (K = [], $ = 0; $ < l.matricesIndices.length; $++) {
+ var W = l.matricesIndices[$];
+ K.push(255 & W), K.push((65280 & W) >> 8), K.push((16711680 & W) >> 16), K.push(W >> 24 & 255);
+ }
+ h.setVerticesData(u.b.MatricesIndicesKind, K, l.matricesIndices._updatable);
+ }
+ if (l.matricesIndicesExtra)
+ if (l.matricesIndicesExtra._isExpanded)
+ delete l.matricesIndices._isExpanded, h.setVerticesData(u.b.MatricesIndicesExtraKind, l.matricesIndicesExtra, l.matricesIndicesExtra._updatable);
+ else {
+ for (K = [], $ = 0; $ < l.matricesIndicesExtra.length; $++)
+ W = l.matricesIndicesExtra[$], K.push(255 & W), K.push((65280 & W) >> 8), K.push((16711680 & W) >> 16), K.push(W >> 24 & 255);
+ h.setVerticesData(u.b.MatricesIndicesExtraKind, K, l.matricesIndicesExtra._updatable);
+ }
+ l.matricesWeights && (g._CleanMatricesWeights(l, h), h.setVerticesData(u.b.MatricesWeightsKind, l.matricesWeights, l.matricesWeights._updatable)), l.matricesWeightsExtra && h.setVerticesData(u.b.MatricesWeightsExtraKind, l.matricesWeightsExtra, l.matricesWeights._updatable), h.setIndices(l.indices, null);
+ }
+ if (l.subMeshes) {
+ h.subMeshes = [];
+ for (var q = 0; q < l.subMeshes.length; q++) {
+ var he = l.subMeshes[q];
+ I.a.AddToMesh(he.materialIndex, he.verticesStart, he.verticesCount, he.indexStart, he.indexCount, h);
+ }
+ }
+ h._shouldGenerateFlatShading && (h.convertToFlatShadedMesh(), h._shouldGenerateFlatShading = !1), h.computeWorldMatrix(!0), v.onMeshImportedObservable.notifyObservers(h);
+ }, g._CleanMatricesWeights = function(l, h) {
+ if (O.a.CleanBoneMatrixWeights) {
+ var v = 0;
+ if (l.skeletonId > -1) {
+ var b = h.getScene().getLastSkeletonByID(l.skeletonId);
+ if (b) {
+ v = b.bones.length;
+ for (var D = h.getVerticesData(u.b.MatricesIndicesKind), w = h.getVerticesData(u.b.MatricesIndicesExtraKind), N = l.matricesWeights, M = l.matricesWeightsExtra, U = l.numBoneInfluencer, X = N.length, j = 0; j < X; j += 4) {
+ for (var ne = 0, te = -1, de = 0; de < 4; de++)
+ ne += pe = N[j + de], pe < 1e-3 && te < 0 && (te = de);
+ if (M)
+ for (de = 0; de < 4; de++) {
+ var pe;
+ ne += pe = M[j + de], pe < 1e-3 && te < 0 && (te = de + 4);
+ }
+ if ((te < 0 || te > U - 1) && (te = U - 1), ne > 1e-3) {
+ var ae = 1 / ne;
+ for (de = 0; de < 4; de++)
+ N[j + de] *= ae;
+ if (M)
+ for (de = 0; de < 4; de++)
+ M[j + de] *= ae;
+ } else
+ te >= 4 ? (M[j + te - 4] = 1 - ne, w[j + te - 4] = v) : (N[j + te] = 1 - ne, D[j + te] = v);
+ }
+ h.setVerticesData(u.b.MatricesIndicesKind, D), l.matricesWeightsExtra && h.setVerticesData(u.b.MatricesIndicesExtraKind, w);
+ }
+ }
+ }
+ }, g.Parse = function(l, h, v) {
+ if (h.getGeometryByID(l.id))
+ return null;
+ var b = new g(l.id, h, void 0, l.updatable);
+ return T.a && T.a.AddTagsTo(b, l.tags), l.delayLoadingFile ? (b.delayLoadState = m.a.DELAYLOADSTATE_NOTLOADED, b.delayLoadingFile = v + l.delayLoadingFile, b._boundingInfo = new x.a(V.e.FromArray(l.boundingBoxMinimum), V.e.FromArray(l.boundingBoxMaximum)), b._delayInfo = [], l.hasUVs && b._delayInfo.push(u.b.UVKind), l.hasUVs2 && b._delayInfo.push(u.b.UV2Kind), l.hasUVs3 && b._delayInfo.push(u.b.UV3Kind), l.hasUVs4 && b._delayInfo.push(u.b.UV4Kind), l.hasUVs5 && b._delayInfo.push(u.b.UV5Kind), l.hasUVs6 && b._delayInfo.push(u.b.UV6Kind), l.hasColors && b._delayInfo.push(u.b.ColorKind), l.hasMatricesIndices && b._delayInfo.push(u.b.MatricesIndicesKind), l.hasMatricesWeights && b._delayInfo.push(u.b.MatricesWeightsKind), b._delayLoadingFunction = C.a.ImportVertexData) : C.a.ImportVertexData(l, b), h.pushGeometry(b, !0), b;
+ }, g;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "e", function() {
+ return V;
+ }), f.d(A, "c", function() {
+ return I;
+ }), f.d(A, "a", function() {
+ return O;
+ }), f.d(A, "b", function() {
+ return x;
+ }), f.d(A, "f", function() {
+ return m;
+ }), f.d(A, "g", function() {
+ return c;
+ }), f.d(A, "d", function() {
+ return T;
+ });
+ var V, _ = f(14), C = f(0), u = f(28);
+ (function(S) {
+ S[S.CW = 0] = "CW", S[S.CCW = 1] = "CCW";
+ })(V || (V = {}));
+ var I = function() {
+ function S() {
+ }
+ return S.Interpolate = function(E, g, l, h, v) {
+ for (var b = 1 - 3 * h + 3 * g, D = 3 * h - 6 * g, w = 3 * g, N = E, M = 0; M < 5; M++) {
+ var U = N * N;
+ N -= (b * (U * N) + D * U + w * N - E) * (1 / (3 * b * U + 2 * D * N + w)), N = Math.min(1, Math.max(0, N));
+ }
+ return 3 * Math.pow(1 - N, 2) * N * l + 3 * (1 - N) * Math.pow(N, 2) * v + Math.pow(N, 3);
+ }, S;
+ }(), O = function() {
+ function S(E) {
+ this._radians = E, this._radians < 0 && (this._radians += 2 * Math.PI);
+ }
+ return S.prototype.degrees = function() {
+ return 180 * this._radians / Math.PI;
+ }, S.prototype.radians = function() {
+ return this._radians;
+ }, S.BetweenTwoPoints = function(E, g) {
+ var l = g.subtract(E);
+ return new S(Math.atan2(l.y, l.x));
+ }, S.FromRadians = function(E) {
+ return new S(E);
+ }, S.FromDegrees = function(E) {
+ return new S(E * Math.PI / 180);
+ }, S;
+ }(), x = function(S, E, g) {
+ this.startPoint = S, this.midPoint = E, this.endPoint = g;
+ var l = Math.pow(E.x, 2) + Math.pow(E.y, 2), h = (Math.pow(S.x, 2) + Math.pow(S.y, 2) - l) / 2, v = (l - Math.pow(g.x, 2) - Math.pow(g.y, 2)) / 2, b = (S.x - E.x) * (E.y - g.y) - (E.x - g.x) * (S.y - E.y);
+ this.centerPoint = new C.d((h * (E.y - g.y) - v * (S.y - E.y)) / b, ((S.x - E.x) * v - (E.x - g.x) * h) / b), this.radius = this.centerPoint.subtract(this.startPoint).length(), this.startAngle = O.BetweenTwoPoints(this.centerPoint, this.startPoint);
+ var D = this.startAngle.degrees(), w = O.BetweenTwoPoints(this.centerPoint, this.midPoint).degrees(), N = O.BetweenTwoPoints(this.centerPoint, this.endPoint).degrees();
+ w - D > 180 && (w -= 360), w - D < -180 && (w += 360), N - w > 180 && (N -= 360), N - w < -180 && (N += 360), this.orientation = w - D < 0 ? V.CW : V.CCW, this.angle = O.FromDegrees(this.orientation === V.CW ? D - N : N - D);
+ }, m = function() {
+ function S(E, g) {
+ this._points = new Array(), this._length = 0, this.closed = !1, this._points.push(new C.d(E, g));
+ }
+ return S.prototype.addLineTo = function(E, g) {
+ if (this.closed)
+ return this;
+ var l = new C.d(E, g), h = this._points[this._points.length - 1];
+ return this._points.push(l), this._length += l.subtract(h).length(), this;
+ }, S.prototype.addArcTo = function(E, g, l, h, v) {
+ if (v === void 0 && (v = 36), this.closed)
+ return this;
+ var b = this._points[this._points.length - 1], D = new C.d(E, g), w = new C.d(l, h), N = new x(b, D, w), M = N.angle.radians() / v;
+ N.orientation === V.CW && (M *= -1);
+ for (var U = N.startAngle.radians() + M, X = 0; X < v; X++) {
+ var j = Math.cos(U) * N.radius + N.centerPoint.x, ne = Math.sin(U) * N.radius + N.centerPoint.y;
+ this.addLineTo(j, ne), U += M;
+ }
+ return this;
+ }, S.prototype.close = function() {
+ return this.closed = !0, this;
+ }, S.prototype.length = function() {
+ var E = this._length;
+ if (this.closed) {
+ var g = this._points[this._points.length - 1];
+ E += this._points[0].subtract(g).length();
+ }
+ return E;
+ }, S.prototype.getPoints = function() {
+ return this._points;
+ }, S.prototype.getPointAtLengthPosition = function(E) {
+ if (E < 0 || E > 1)
+ return C.d.Zero();
+ for (var g = E * this.length(), l = 0, h = 0; h < this._points.length; h++) {
+ var v = (h + 1) % this._points.length, b = this._points[h], D = this._points[v].subtract(b), w = D.length() + l;
+ if (g >= l && g <= w) {
+ var N = D.normalize(), M = g - l;
+ return new C.d(b.x + N.x * M, b.y + N.y * M);
+ }
+ l = w;
+ }
+ return C.d.Zero();
+ }, S.StartingAt = function(E, g) {
+ return new S(E, g);
+ }, S;
+ }(), c = function() {
+ function S(E, g, l, h) {
+ g === void 0 && (g = null), h === void 0 && (h = !1), this.path = E, this._curve = new Array(), this._distances = new Array(), this._tangents = new Array(), this._normals = new Array(), this._binormals = new Array(), this._pointAtData = { id: 0, point: C.e.Zero(), previousPointArrayIndex: 0, position: 0, subPosition: 0, interpolateReady: !1, interpolationMatrix: C.a.Identity() };
+ for (var v = 0; v < E.length; v++)
+ this._curve[v] = E[v].clone();
+ this._raw = l || !1, this._alignTangentsWithPath = h, this._compute(g, h);
+ }
+ return S.prototype.getCurve = function() {
+ return this._curve;
+ }, S.prototype.getPoints = function() {
+ return this._curve;
+ }, S.prototype.length = function() {
+ return this._distances[this._distances.length - 1];
+ }, S.prototype.getTangents = function() {
+ return this._tangents;
+ }, S.prototype.getNormals = function() {
+ return this._normals;
+ }, S.prototype.getBinormals = function() {
+ return this._binormals;
+ }, S.prototype.getDistances = function() {
+ return this._distances;
+ }, S.prototype.getPointAt = function(E) {
+ return this._updatePointAtData(E).point;
+ }, S.prototype.getTangentAt = function(E, g) {
+ return g === void 0 && (g = !1), this._updatePointAtData(E, g), g ? C.e.TransformCoordinates(C.e.Forward(), this._pointAtData.interpolationMatrix) : this._tangents[this._pointAtData.previousPointArrayIndex];
+ }, S.prototype.getNormalAt = function(E, g) {
+ return g === void 0 && (g = !1), this._updatePointAtData(E, g), g ? C.e.TransformCoordinates(C.e.Right(), this._pointAtData.interpolationMatrix) : this._normals[this._pointAtData.previousPointArrayIndex];
+ }, S.prototype.getBinormalAt = function(E, g) {
+ return g === void 0 && (g = !1), this._updatePointAtData(E, g), g ? C.e.TransformCoordinates(C.e.UpReadOnly, this._pointAtData.interpolationMatrix) : this._binormals[this._pointAtData.previousPointArrayIndex];
+ }, S.prototype.getDistanceAt = function(E) {
+ return this.length() * E;
+ }, S.prototype.getPreviousPointIndexAt = function(E) {
+ return this._updatePointAtData(E), this._pointAtData.previousPointArrayIndex;
+ }, S.prototype.getSubPositionAt = function(E) {
+ return this._updatePointAtData(E), this._pointAtData.subPosition;
+ }, S.prototype.getClosestPositionTo = function(E) {
+ for (var g = Number.MAX_VALUE, l = 0, h = 0; h < this._curve.length - 1; h++) {
+ var v = this._curve[h + 0], b = this._curve[h + 1].subtract(v).normalize(), D = this._distances[h + 1] - this._distances[h + 0], w = Math.min(Math.max(C.e.Dot(b, E.subtract(v).normalize()), 0) * C.e.Distance(v, E) / D, 1), N = C.e.Distance(v.add(b.scale(w * D)), E);
+ N < g && (g = N, l = (this._distances[h + 0] + D * w) / this.length());
+ }
+ return l;
+ }, S.prototype.slice = function(E, g) {
+ if (E === void 0 && (E = 0), g === void 0 && (g = 1), E < 0 && (E = 1 - -1 * E % 1), g < 0 && (g = 1 - -1 * g % 1), E > g) {
+ var l = E;
+ E = g, g = l;
+ }
+ var h = this.getCurve(), v = this.getPointAt(E), b = this.getPreviousPointIndexAt(E), D = this.getPointAt(g), w = this.getPreviousPointIndexAt(g) + 1, N = [];
+ return E !== 0 && (b++, N.push(v)), N.push.apply(N, h.slice(b, w)), g === 1 && E !== 1 || N.push(D), new S(N, this.getNormalAt(E), this._raw, this._alignTangentsWithPath);
+ }, S.prototype.update = function(E, g, l) {
+ g === void 0 && (g = null), l === void 0 && (l = !1);
+ for (var h = 0; h < E.length; h++)
+ this._curve[h].x = E[h].x, this._curve[h].y = E[h].y, this._curve[h].z = E[h].z;
+ return this._compute(g, l), this;
+ }, S.prototype._compute = function(E, g) {
+ g === void 0 && (g = !1);
+ var l = this._curve.length;
+ if (!(l < 2)) {
+ this._tangents[0] = this._getFirstNonNullVector(0), this._raw || this._tangents[0].normalize(), this._tangents[l - 1] = this._curve[l - 1].subtract(this._curve[l - 2]), this._raw || this._tangents[l - 1].normalize();
+ var h, v, b, D, w, N = this._tangents[0], M = this._normalVector(N, E);
+ this._normals[0] = M, this._raw || this._normals[0].normalize(), this._binormals[0] = C.e.Cross(N, this._normals[0]), this._raw || this._binormals[0].normalize(), this._distances[0] = 0;
+ for (var U = 1; U < l; U++)
+ h = this._getLastNonNullVector(U), U < l - 1 && (v = this._getFirstNonNullVector(U), this._tangents[U] = g ? v : h.add(v), this._tangents[U].normalize()), this._distances[U] = this._distances[U - 1] + this._curve[U].subtract(this._curve[U - 1]).length(), b = this._tangents[U], w = this._binormals[U - 1], this._normals[U] = C.e.Cross(w, b), this._raw || (this._normals[U].length() === 0 ? (D = this._normals[U - 1], this._normals[U] = D.clone()) : this._normals[U].normalize()), this._binormals[U] = C.e.Cross(b, this._normals[U]), this._raw || this._binormals[U].normalize();
+ this._pointAtData.id = NaN;
+ }
+ }, S.prototype._getFirstNonNullVector = function(E) {
+ for (var g = 1, l = this._curve[E + g].subtract(this._curve[E]); l.length() === 0 && E + g + 1 < this._curve.length; )
+ g++, l = this._curve[E + g].subtract(this._curve[E]);
+ return l;
+ }, S.prototype._getLastNonNullVector = function(E) {
+ for (var g = 1, l = this._curve[E].subtract(this._curve[E - g]); l.length() === 0 && E > g + 1; )
+ g++, l = this._curve[E].subtract(this._curve[E - g]);
+ return l;
+ }, S.prototype._normalVector = function(E, g) {
+ var l, h, v = E.length();
+ return v === 0 && (v = 1), g == null ? (h = _.a.WithinEpsilon(Math.abs(E.y) / v, 1, u.a) ? _.a.WithinEpsilon(Math.abs(E.x) / v, 1, u.a) ? _.a.WithinEpsilon(Math.abs(E.z) / v, 1, u.a) ? C.e.Zero() : new C.e(0, 0, 1) : new C.e(1, 0, 0) : new C.e(0, -1, 0), l = C.e.Cross(E, h)) : (l = C.e.Cross(E, g), C.e.CrossToRef(l, E, l)), l.normalize(), l;
+ }, S.prototype._updatePointAtData = function(E, g) {
+ if (g === void 0 && (g = !1), this._pointAtData.id === E)
+ return this._pointAtData.interpolateReady || this._updateInterpolationMatrix(), this._pointAtData;
+ this._pointAtData.id = E;
+ var l = this.getPoints();
+ if (E <= 0)
+ return this._setPointAtData(0, 0, l[0], 0, g);
+ if (E >= 1)
+ return this._setPointAtData(1, 1, l[l.length - 1], l.length - 1, g);
+ for (var h, v = l[0], b = 0, D = E * this.length(), w = 1; w < l.length; w++) {
+ h = l[w];
+ var N = C.e.Distance(v, h);
+ if ((b += N) === D)
+ return this._setPointAtData(E, 1, h, w, g);
+ if (b > D) {
+ var M = (b - D) / N, U = v.subtract(h), X = h.add(U.scaleInPlace(M));
+ return this._setPointAtData(E, 1 - M, X, w - 1, g);
+ }
+ v = h;
+ }
+ return this._pointAtData;
+ }, S.prototype._setPointAtData = function(E, g, l, h, v) {
+ return this._pointAtData.point = l, this._pointAtData.position = E, this._pointAtData.subPosition = g, this._pointAtData.previousPointArrayIndex = h, this._pointAtData.interpolateReady = v, v && this._updateInterpolationMatrix(), this._pointAtData;
+ }, S.prototype._updateInterpolationMatrix = function() {
+ this._pointAtData.interpolationMatrix = C.a.Identity();
+ var E = this._pointAtData.previousPointArrayIndex;
+ if (E !== this._tangents.length - 1) {
+ var g = E + 1, l = this._tangents[E].clone(), h = this._normals[E].clone(), v = this._binormals[E].clone(), b = this._tangents[g].clone(), D = this._normals[g].clone(), w = this._binormals[g].clone(), N = C.b.RotationQuaternionFromAxis(h, v, l), M = C.b.RotationQuaternionFromAxis(D, w, b);
+ C.b.Slerp(N, M, this._pointAtData.subPosition).toRotationMatrix(this._pointAtData.interpolationMatrix);
+ }
+ }, S;
+ }(), T = function() {
+ function S(E) {
+ this._length = 0, this._points = E, this._length = this._computeLength(E);
+ }
+ return S.CreateQuadraticBezier = function(E, g, l, h) {
+ h = h > 2 ? h : 3;
+ for (var v = new Array(), b = function(w, N, M, U) {
+ return (1 - w) * (1 - w) * N + 2 * w * (1 - w) * M + w * w * U;
+ }, D = 0; D <= h; D++)
+ v.push(new C.e(b(D / h, E.x, g.x, l.x), b(D / h, E.y, g.y, l.y), b(D / h, E.z, g.z, l.z)));
+ return new S(v);
+ }, S.CreateCubicBezier = function(E, g, l, h, v) {
+ v = v > 3 ? v : 4;
+ for (var b = new Array(), D = function(N, M, U, X, j) {
+ return (1 - N) * (1 - N) * (1 - N) * M + 3 * N * (1 - N) * (1 - N) * U + 3 * N * N * (1 - N) * X + N * N * N * j;
+ }, w = 0; w <= v; w++)
+ b.push(new C.e(D(w / v, E.x, g.x, l.x, h.x), D(w / v, E.y, g.y, l.y, h.y), D(w / v, E.z, g.z, l.z, h.z)));
+ return new S(b);
+ }, S.CreateHermiteSpline = function(E, g, l, h, v) {
+ for (var b = new Array(), D = 1 / v, w = 0; w <= v; w++)
+ b.push(C.e.Hermite(E, g, l, h, w * D));
+ return new S(b);
+ }, S.CreateCatmullRomSpline = function(E, g, l) {
+ var h = new Array(), v = 1 / g, b = 0;
+ if (l) {
+ for (var D = E.length, w = 0; w < D; w++) {
+ b = 0;
+ for (var N = 0; N < g; N++)
+ h.push(C.e.CatmullRom(E[w % D], E[(w + 1) % D], E[(w + 2) % D], E[(w + 3) % D], b)), b += v;
+ }
+ h.push(h[0]);
+ } else {
+ var M = new Array();
+ for (M.push(E[0].clone()), Array.prototype.push.apply(M, E), M.push(E[E.length - 1].clone()), w = 0; w < M.length - 3; w++)
+ for (b = 0, N = 0; N < g; N++)
+ h.push(C.e.CatmullRom(M[w], M[w + 1], M[w + 2], M[w + 3], b)), b += v;
+ w--, h.push(C.e.CatmullRom(M[w], M[w + 1], M[w + 2], M[w + 3], b));
+ }
+ return new S(h);
+ }, S.prototype.getPoints = function() {
+ return this._points;
+ }, S.prototype.length = function() {
+ return this._length;
+ }, S.prototype.continue = function(E) {
+ for (var g = this._points[this._points.length - 1], l = this._points.slice(), h = E.getPoints(), v = 1; v < h.length; v++)
+ l.push(h[v].subtract(h[0]).add(g));
+ return new S(l);
+ }, S.prototype._computeLength = function(E) {
+ for (var g = 0, l = 1; l < E.length; l++)
+ g += E[l].subtract(E[l - 1]).length();
+ return g;
+ }, S;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return l;
+ });
+ var V = f(1), _ = f(3), C = f(0), u = f(4), I = f(10), O = f(15), x = f(25), m = f(11), c = f(9), T = f(67), S = f(49), E = f(13), g = { effect: null, subMesh: null }, l = function(h) {
+ function v(b, D, w, N) {
+ N === void 0 && (N = {});
+ var M = h.call(this, b, D) || this;
+ return M._textures = {}, M._textureArrays = {}, M._floats = {}, M._ints = {}, M._floatsArrays = {}, M._colors3 = {}, M._colors3Arrays = {}, M._colors4 = {}, M._colors4Arrays = {}, M._vectors2 = {}, M._vectors3 = {}, M._vectors4 = {}, M._matrices = {}, M._matrixArrays = {}, M._matrices3x3 = {}, M._matrices2x2 = {}, M._vectors2Arrays = {}, M._vectors3Arrays = {}, M._vectors4Arrays = {}, M._cachedWorldViewMatrix = new C.a(), M._cachedWorldViewProjectionMatrix = new C.a(), M._multiview = !1, M._shaderPath = w, M._options = Object(V.a)({ needAlphaBlending: !1, needAlphaTesting: !1, attributes: ["position", "normal", "uv"], uniforms: ["worldViewProjection"], uniformBuffers: [], samplers: [], defines: [] }, N), M;
+ }
+ return Object(V.d)(v, h), Object.defineProperty(v.prototype, "shaderPath", { get: function() {
+ return this._shaderPath;
+ }, set: function(b) {
+ this._shaderPath = b;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(v.prototype, "options", { get: function() {
+ return this._options;
+ }, enumerable: !1, configurable: !0 }), v.prototype.getClassName = function() {
+ return "ShaderMaterial";
+ }, v.prototype.needAlphaBlending = function() {
+ return this.alpha < 1 || this._options.needAlphaBlending;
+ }, v.prototype.needAlphaTesting = function() {
+ return this._options.needAlphaTesting;
+ }, v.prototype._checkUniform = function(b) {
+ this._options.uniforms.indexOf(b) === -1 && this._options.uniforms.push(b);
+ }, v.prototype.setTexture = function(b, D) {
+ return this._options.samplers.indexOf(b) === -1 && this._options.samplers.push(b), this._textures[b] = D, this;
+ }, v.prototype.setTextureArray = function(b, D) {
+ return this._options.samplers.indexOf(b) === -1 && this._options.samplers.push(b), this._checkUniform(b), this._textureArrays[b] = D, this;
+ }, v.prototype.setFloat = function(b, D) {
+ return this._checkUniform(b), this._floats[b] = D, this;
+ }, v.prototype.setInt = function(b, D) {
+ return this._checkUniform(b), this._ints[b] = D, this;
+ }, v.prototype.setFloats = function(b, D) {
+ return this._checkUniform(b), this._floatsArrays[b] = D, this;
+ }, v.prototype.setColor3 = function(b, D) {
+ return this._checkUniform(b), this._colors3[b] = D, this;
+ }, v.prototype.setColor3Array = function(b, D) {
+ return this._checkUniform(b), this._colors3Arrays[b] = D.reduce(function(w, N) {
+ return N.toArray(w, w.length), w;
+ }, []), this;
+ }, v.prototype.setColor4 = function(b, D) {
+ return this._checkUniform(b), this._colors4[b] = D, this;
+ }, v.prototype.setColor4Array = function(b, D) {
+ return this._checkUniform(b), this._colors4Arrays[b] = D.reduce(function(w, N) {
+ return N.toArray(w, w.length), w;
+ }, []), this;
+ }, v.prototype.setVector2 = function(b, D) {
+ return this._checkUniform(b), this._vectors2[b] = D, this;
+ }, v.prototype.setVector3 = function(b, D) {
+ return this._checkUniform(b), this._vectors3[b] = D, this;
+ }, v.prototype.setVector4 = function(b, D) {
+ return this._checkUniform(b), this._vectors4[b] = D, this;
+ }, v.prototype.setMatrix = function(b, D) {
+ return this._checkUniform(b), this._matrices[b] = D, this;
+ }, v.prototype.setMatrices = function(b, D) {
+ this._checkUniform(b);
+ for (var w = new Float32Array(16 * D.length), N = 0; N < D.length; N++)
+ D[N].copyToArray(w, 16 * N);
+ return this._matrixArrays[b] = w, this;
+ }, v.prototype.setMatrix3x3 = function(b, D) {
+ return this._checkUniform(b), this._matrices3x3[b] = D, this;
+ }, v.prototype.setMatrix2x2 = function(b, D) {
+ return this._checkUniform(b), this._matrices2x2[b] = D, this;
+ }, v.prototype.setArray2 = function(b, D) {
+ return this._checkUniform(b), this._vectors2Arrays[b] = D, this;
+ }, v.prototype.setArray3 = function(b, D) {
+ return this._checkUniform(b), this._vectors3Arrays[b] = D, this;
+ }, v.prototype.setArray4 = function(b, D) {
+ return this._checkUniform(b), this._vectors4Arrays[b] = D, this;
+ }, v.prototype._checkCache = function(b, D) {
+ return !b || !this._effect || this._effect.defines.indexOf("#define INSTANCES") !== -1 === D;
+ }, v.prototype.isReadyForSubMesh = function(b, D, w) {
+ return this.isReady(b, w);
+ }, v.prototype.isReady = function(b, D) {
+ var w, N;
+ if (this._effect && this.isFrozen && this._effect._wasPreviouslyReady)
+ return !0;
+ var M = this.getScene(), U = M.getEngine();
+ if (!this.checkReadyOnEveryCall && this._renderId === M.getRenderId() && this._checkCache(b, D))
+ return !0;
+ var X = [], j = [], ne = new T.a();
+ U.getCaps().multiview && M.activeCamera && M.activeCamera.outputRenderTarget && M.activeCamera.outputRenderTarget.getViewCount() > 1 && (this._multiview = !0, X.push("#define MULTIVIEW"), this._options.uniforms.indexOf("viewProjection") !== -1 && this._options.uniforms.push("viewProjectionR") === -1 && this._options.uniforms.push("viewProjectionR"));
+ for (var te = 0; te < this._options.defines.length; te++)
+ X.push(this._options.defines[te]);
+ for (te = 0; te < this._options.attributes.length; te++)
+ j.push(this._options.attributes[te]);
+ b && b.isVerticesDataPresent(u.b.ColorKind) && (j.push(u.b.ColorKind), X.push("#define VERTEXCOLOR")), D && (X.push("#define INSTANCES"), O.a.PushAttributesForInstances(j), b != null && b.hasThinInstances && X.push("#define THIN_INSTANCES"));
+ var de = 0;
+ if (b && b.useBones && b.computeBonesUsingShaders && b.skeleton) {
+ j.push(u.b.MatricesIndicesKind), j.push(u.b.MatricesWeightsKind), b.numBoneInfluencers > 4 && (j.push(u.b.MatricesIndicesExtraKind), j.push(u.b.MatricesWeightsExtraKind));
+ var pe = b.skeleton;
+ de = b.numBoneInfluencers, X.push("#define NUM_BONE_INFLUENCERS " + de), ne.addCPUSkinningFallback(0, b), pe.isUsingTextureForMatrices ? (X.push("#define BONETEXTURE"), this._options.uniforms.indexOf("boneTextureWidth") === -1 && this._options.uniforms.push("boneTextureWidth"), this._options.samplers.indexOf("boneSampler") === -1 && this._options.samplers.push("boneSampler")) : (X.push("#define BonesPerMesh " + (pe.bones.length + 1)), this._options.uniforms.indexOf("mBones") === -1 && this._options.uniforms.push("mBones"));
+ } else
+ X.push("#define NUM_BONE_INFLUENCERS 0");
+ for (var ae in this._textures)
+ if (!this._textures[ae].isReady())
+ return !1;
+ b && this._shouldTurnAlphaTestOn(b) && X.push("#define ALPHATEST");
+ var ee = this._shaderPath, K = this._options.uniforms, $ = this._options.uniformBuffers, L = this._options.samplers;
+ this.customShaderNameResolve && (K = K.slice(), $ = $.slice(), L = L.slice(), ee = this.customShaderNameResolve(ee, K, $, L, X, j));
+ var G = this._effect, Q = X.join(`
+`);
+ return this._cachedDefines !== Q && (this._cachedDefines = Q, this._effect = U.createEffect(ee, { attributes: j, uniformsNames: K, uniformBuffersNames: $, samplers: L, defines: Q, fallbacks: ne, onCompiled: this.onCompiled, onError: this.onError, indexParameters: { maxSimultaneousMorphTargets: de } }, U), this._onEffectCreatedObservable && (g.effect = this._effect, this._onEffectCreatedObservable.notifyObservers(g))), (N = !(!((w = this._effect) === null || w === void 0) && w.isReady())) !== null && N !== void 0 && !N && (G !== this._effect && M.resetCachedMaterial(), this._renderId = M.getRenderId(), this._effect._wasPreviouslyReady = !0, !0);
+ }, v.prototype.bindOnlyWorldMatrix = function(b, D) {
+ var w = this.getScene(), N = D ?? this._effect;
+ N && (this._options.uniforms.indexOf("world") !== -1 && N.setMatrix("world", b), this._options.uniforms.indexOf("worldView") !== -1 && (b.multiplyToRef(w.getViewMatrix(), this._cachedWorldViewMatrix), N.setMatrix("worldView", this._cachedWorldViewMatrix)), this._options.uniforms.indexOf("worldViewProjection") !== -1 && (b.multiplyToRef(w.getTransformMatrix(), this._cachedWorldViewProjectionMatrix), N.setMatrix("worldViewProjection", this._cachedWorldViewProjectionMatrix)));
+ }, v.prototype.bindForSubMesh = function(b, D, w) {
+ this.bind(b, D, w._effectOverride);
+ }, v.prototype.bind = function(b, D, w) {
+ this.bindOnlyWorldMatrix(b, w);
+ var N = w ?? this._effect;
+ if (N && this.getScene().getCachedMaterial() !== this) {
+ var M;
+ for (M in this._options.uniforms.indexOf("view") !== -1 && N.setMatrix("view", this.getScene().getViewMatrix()), this._options.uniforms.indexOf("projection") !== -1 && N.setMatrix("projection", this.getScene().getProjectionMatrix()), this._options.uniforms.indexOf("viewProjection") !== -1 && (N.setMatrix("viewProjection", this.getScene().getTransformMatrix()), this._multiview && N.setMatrix("viewProjectionR", this.getScene()._transformMatrixR)), this.getScene().activeCamera && this._options.uniforms.indexOf("cameraPosition") !== -1 && N.setVector3("cameraPosition", this.getScene().activeCamera.globalPosition), O.a.BindBonesParameters(D, N), this._textures)
+ N.setTexture(M, this._textures[M]);
+ for (M in this._textureArrays)
+ N.setTextureArray(M, this._textureArrays[M]);
+ for (M in this._ints)
+ N.setInt(M, this._ints[M]);
+ for (M in this._floats)
+ N.setFloat(M, this._floats[M]);
+ for (M in this._floatsArrays)
+ N.setArray(M, this._floatsArrays[M]);
+ for (M in this._colors3)
+ N.setColor3(M, this._colors3[M]);
+ for (M in this._colors3Arrays)
+ N.setArray3(M, this._colors3Arrays[M]);
+ for (M in this._colors4) {
+ var U = this._colors4[M];
+ N.setFloat4(M, U.r, U.g, U.b, U.a);
+ }
+ for (M in this._colors4Arrays)
+ N.setArray4(M, this._colors4Arrays[M]);
+ for (M in this._vectors2)
+ N.setVector2(M, this._vectors2[M]);
+ for (M in this._vectors3)
+ N.setVector3(M, this._vectors3[M]);
+ for (M in this._vectors4)
+ N.setVector4(M, this._vectors4[M]);
+ for (M in this._matrices)
+ N.setMatrix(M, this._matrices[M]);
+ for (M in this._matrixArrays)
+ N.setMatrices(M, this._matrixArrays[M]);
+ for (M in this._matrices3x3)
+ N.setMatrix3x3(M, this._matrices3x3[M]);
+ for (M in this._matrices2x2)
+ N.setMatrix2x2(M, this._matrices2x2[M]);
+ for (M in this._vectors2Arrays)
+ N.setArray2(M, this._vectors2Arrays[M]);
+ for (M in this._vectors3Arrays)
+ N.setArray3(M, this._vectors3Arrays[M]);
+ for (M in this._vectors4Arrays)
+ N.setArray4(M, this._vectors4Arrays[M]);
+ }
+ var X = this._effect;
+ this._effect = N, this._afterBind(D), this._effect = X;
+ }, v.prototype._afterBind = function(b) {
+ h.prototype._afterBind.call(this, b), this.getScene()._cachedEffect = this._effect;
+ }, v.prototype.getActiveTextures = function() {
+ var b = h.prototype.getActiveTextures.call(this);
+ for (var D in this._textures)
+ b.push(this._textures[D]);
+ for (var D in this._textureArrays)
+ for (var w = this._textureArrays[D], N = 0; N < w.length; N++)
+ b.push(w[N]);
+ return b;
+ }, v.prototype.hasTexture = function(b) {
+ if (h.prototype.hasTexture.call(this, b))
+ return !0;
+ for (var D in this._textures)
+ if (this._textures[D] === b)
+ return !0;
+ for (var D in this._textureArrays)
+ for (var w = this._textureArrays[D], N = 0; N < w.length; N++)
+ if (w[N] === b)
+ return !0;
+ return !1;
+ }, v.prototype.clone = function(b) {
+ var D = this, w = _.a.Clone(function() {
+ return new v(b, D.getScene(), D._shaderPath, D._options);
+ }, this);
+ for (var N in w.name = b, w.id = b, typeof w._shaderPath == "object" && (w._shaderPath = Object(V.a)({}, w._shaderPath)), this._options = Object(V.a)({}, this._options), Object.keys(this._options).forEach(function(M) {
+ var U = D._options[M];
+ Array.isArray(U) && (D._options[M] = U.slice(0));
+ }), this._textures)
+ w.setTexture(N, this._textures[N]);
+ for (var N in this._floats)
+ w.setFloat(N, this._floats[N]);
+ for (var N in this._floatsArrays)
+ w.setFloats(N, this._floatsArrays[N]);
+ for (var N in this._colors3)
+ w.setColor3(N, this._colors3[N]);
+ for (var N in this._colors4)
+ w.setColor4(N, this._colors4[N]);
+ for (var N in this._vectors2)
+ w.setVector2(N, this._vectors2[N]);
+ for (var N in this._vectors3)
+ w.setVector3(N, this._vectors3[N]);
+ for (var N in this._vectors4)
+ w.setVector4(N, this._vectors4[N]);
+ for (var N in this._matrices)
+ w.setMatrix(N, this._matrices[N]);
+ for (var N in this._matrices3x3)
+ w.setMatrix3x3(N, this._matrices3x3[N]);
+ for (var N in this._matrices2x2)
+ w.setMatrix2x2(N, this._matrices2x2[N]);
+ return w;
+ }, v.prototype.dispose = function(b, D, w) {
+ if (D) {
+ var N;
+ for (N in this._textures)
+ this._textures[N].dispose();
+ for (N in this._textureArrays)
+ for (var M = this._textureArrays[N], U = 0; U < M.length; U++)
+ M[U].dispose();
+ }
+ this._textures = {}, h.prototype.dispose.call(this, b, D, w);
+ }, v.prototype.serialize = function() {
+ var b, D = _.a.Serialize(this);
+ for (b in D.customType = "BABYLON.ShaderMaterial", D.options = this._options, D.shaderPath = this._shaderPath, D.textures = {}, this._textures)
+ D.textures[b] = this._textures[b].serialize();
+ for (b in D.textureArrays = {}, this._textureArrays) {
+ D.textureArrays[b] = [];
+ for (var w = this._textureArrays[b], N = 0; N < w.length; N++)
+ D.textureArrays[b].push(w[N].serialize());
+ }
+ for (b in D.floats = {}, this._floats)
+ D.floats[b] = this._floats[b];
+ for (b in D.FloatArrays = {}, this._floatsArrays)
+ D.FloatArrays[b] = this._floatsArrays[b];
+ for (b in D.colors3 = {}, this._colors3)
+ D.colors3[b] = this._colors3[b].asArray();
+ for (b in D.colors3Arrays = {}, this._colors3Arrays)
+ D.colors3Arrays[b] = this._colors3Arrays[b];
+ for (b in D.colors4 = {}, this._colors4)
+ D.colors4[b] = this._colors4[b].asArray();
+ for (b in D.colors4Arrays = {}, this._colors4Arrays)
+ D.colors4Arrays[b] = this._colors4Arrays[b];
+ for (b in D.vectors2 = {}, this._vectors2)
+ D.vectors2[b] = this._vectors2[b].asArray();
+ for (b in D.vectors3 = {}, this._vectors3)
+ D.vectors3[b] = this._vectors3[b].asArray();
+ for (b in D.vectors4 = {}, this._vectors4)
+ D.vectors4[b] = this._vectors4[b].asArray();
+ for (b in D.matrices = {}, this._matrices)
+ D.matrices[b] = this._matrices[b].asArray();
+ for (b in D.matrixArray = {}, this._matrixArrays)
+ D.matrixArray[b] = this._matrixArrays[b];
+ for (b in D.matrices3x3 = {}, this._matrices3x3)
+ D.matrices3x3[b] = this._matrices3x3[b];
+ for (b in D.matrices2x2 = {}, this._matrices2x2)
+ D.matrices2x2[b] = this._matrices2x2[b];
+ for (b in D.vectors2Arrays = {}, this._vectors2Arrays)
+ D.vectors2Arrays[b] = this._vectors2Arrays[b];
+ for (b in D.vectors3Arrays = {}, this._vectors3Arrays)
+ D.vectors3Arrays[b] = this._vectors3Arrays[b];
+ for (b in D.vectors4Arrays = {}, this._vectors4Arrays)
+ D.vectors4Arrays[b] = this._vectors4Arrays[b];
+ return D;
+ }, v.Parse = function(b, D, w) {
+ var N, M = _.a.Parse(function() {
+ return new v(b.name, D, b.shaderPath, b.options);
+ }, b, D, w);
+ for (N in b.textures)
+ M.setTexture(N, I.a.Parse(b.textures[N], D, w));
+ for (N in b.textureArrays) {
+ for (var U = b.textureArrays[N], X = new Array(), j = 0; j < U.length; j++)
+ X.push(I.a.Parse(U[j], D, w));
+ M.setTextureArray(N, X);
+ }
+ for (N in b.floats)
+ M.setFloat(N, b.floats[N]);
+ for (N in b.floatsArrays)
+ M.setFloats(N, b.floatsArrays[N]);
+ for (N in b.colors3)
+ M.setColor3(N, c.a.FromArray(b.colors3[N]));
+ for (N in b.colors3Arrays) {
+ var ne = b.colors3Arrays[N].reduce(function(te, de, pe) {
+ return pe % 3 == 0 ? te.push([de]) : te[te.length - 1].push(de), te;
+ }, []).map(function(te) {
+ return c.a.FromArray(te);
+ });
+ M.setColor3Array(N, ne);
+ }
+ for (N in b.colors4)
+ M.setColor4(N, c.b.FromArray(b.colors4[N]));
+ for (N in b.colors4Arrays)
+ ne = b.colors4Arrays[N].reduce(function(te, de, pe) {
+ return pe % 4 == 0 ? te.push([de]) : te[te.length - 1].push(de), te;
+ }, []).map(function(te) {
+ return c.b.FromArray(te);
+ }), M.setColor4Array(N, ne);
+ for (N in b.vectors2)
+ M.setVector2(N, C.d.FromArray(b.vectors2[N]));
+ for (N in b.vectors3)
+ M.setVector3(N, C.e.FromArray(b.vectors3[N]));
+ for (N in b.vectors4)
+ M.setVector4(N, C.f.FromArray(b.vectors4[N]));
+ for (N in b.matrices)
+ M.setMatrix(N, C.a.FromArray(b.matrices[N]));
+ for (N in b.matrixArray)
+ M._matrixArrays[N] = new Float32Array(b.matrixArray[N]);
+ for (N in b.matrices3x3)
+ M.setMatrix3x3(N, b.matrices3x3[N]);
+ for (N in b.matrices2x2)
+ M.setMatrix2x2(N, b.matrices2x2[N]);
+ for (N in b.vectors2Arrays)
+ M.setArray2(N, b.vectors2Arrays[N]);
+ for (N in b.vectors3Arrays)
+ M.setArray3(N, b.vectors3Arrays[N]);
+ for (N in b.vectors4Arrays)
+ M.setArray4(N, b.vectors4Arrays[N]);
+ return M;
+ }, v.ParseFromFileAsync = function(b, D, w, N) {
+ var M = this;
+ return N === void 0 && (N = ""), new Promise(function(U, X) {
+ var j = new S.a();
+ j.addEventListener("readystatechange", function() {
+ if (j.readyState == 4)
+ if (j.status == 200) {
+ var ne = JSON.parse(j.responseText), te = M.Parse(ne, w || E.a.LastCreatedScene, N);
+ b && (te.name = b), U(te);
+ } else
+ X("Unable to load the ShaderMaterial");
+ }), j.open("GET", D), j.send();
+ });
+ }, v.CreateFromSnippetAsync = function(b, D, w) {
+ var N = this;
+ return w === void 0 && (w = ""), new Promise(function(M, U) {
+ var X = new S.a();
+ X.addEventListener("readystatechange", function() {
+ if (X.readyState == 4)
+ if (X.status == 200) {
+ var j = JSON.parse(JSON.parse(X.responseText).jsonPayload), ne = JSON.parse(j.shaderMaterial), te = N.Parse(ne, D || E.a.LastCreatedScene, w);
+ te.snippetId = b, M(te);
+ } else
+ U("Unable to load the snippet " + b);
+ }), X.open("GET", N.SnippetUrl + "/" + b.replace(/#/g, "/")), X.send();
+ });
+ }, v.SnippetUrl = "https://snippet.babylonjs.com", v;
+ }(x.a);
+ m.a.RegisteredTypes["BABYLON.ShaderMaterial"] = l;
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return V;
+ });
+ var V = function() {
+ function _() {
+ }
+ return _.SetMatrixPrecision = function(C) {
+ if (_.MatrixTrackPrecisionChange = !1, C && !_.MatrixUse64Bits && _.MatrixTrackedMatrices)
+ for (var u = 0; u < _.MatrixTrackedMatrices.length; ++u) {
+ var I = _.MatrixTrackedMatrices[u], O = I._m;
+ I._m = new Array(16);
+ for (var x = 0; x < 16; ++x)
+ I._m[x] = O[x];
+ }
+ _.MatrixUse64Bits = C, _.MatrixCurrentType = _.MatrixUse64Bits ? Array : Float32Array, _.MatrixTrackedMatrices = null;
+ }, _.MatrixUse64Bits = !1, _.MatrixTrackPrecisionChange = !0, _.MatrixCurrentType = Float32Array, _.MatrixTrackedMatrices = [], _;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return E;
+ });
+ var V = f(1), _ = f(6), C = f(0), u = f(46), I = f(7), O = f(53), x = f(65), m = f(51), c = f(36), T = f(30), S = f(9), E = function(g) {
+ function l(h, v, b, D, w) {
+ var N;
+ v === void 0 && (v = S.a.Gray()), b === void 0 && (b = c.a.DefaultUtilityLayer), D === void 0 && (D = null), w === void 0 && (w = 1);
+ var M = g.call(this, b) || this;
+ M._pointerObserver = null, M.snapDistance = 0, M.onSnapObservable = new _.c(), M._isEnabled = !0, M._parent = null, M._dragging = !1, M._parent = D, M._coloredMaterial = new T.a("", b.utilityLayerScene), M._coloredMaterial.diffuseColor = v, M._coloredMaterial.specularColor = v.subtract(new S.a(0.1, 0.1, 0.1)), M._hoverMaterial = new T.a("", b.utilityLayerScene), M._hoverMaterial.diffuseColor = S.a.Yellow(), M._disableMaterial = new T.a("", b.utilityLayerScene), M._disableMaterial.diffuseColor = S.a.Gray(), M._disableMaterial.alpha = 0.4;
+ var U = l._CreateArrow(b.utilityLayerScene, M._coloredMaterial, w), X = l._CreateArrow(b.utilityLayerScene, M._coloredMaterial, w + 4, !0);
+ M._gizmoMesh = new I.a("", b.utilityLayerScene), M._gizmoMesh.addChild(U), M._gizmoMesh.addChild(X), M._gizmoMesh.lookAt(M._rootMesh.position.add(h)), M._gizmoMesh.scaling.scaleInPlace(1 / 3), M._gizmoMesh.parent = M._rootMesh;
+ var j = 0, ne = new C.e(), te = { snapDistance: 0 };
+ M.dragBehavior = new x.a({ dragAxis: h }), M.dragBehavior.moveAttached = !1, M._rootMesh.addBehavior(M.dragBehavior), M.dragBehavior.onDragObservable.add(function(ae) {
+ if (M.attachedNode) {
+ if (M.snapDistance == 0)
+ M.attachedNode.position && M.attachedNode.position.addInPlaceFromFloats(ae.delta.x, ae.delta.y, ae.delta.z), M.attachedNode.getWorldMatrix().addTranslationFromFloats(ae.delta.x, ae.delta.y, ae.delta.z), M.attachedNode.updateCache();
+ else if (j += ae.dragDistance, Math.abs(j) > M.snapDistance) {
+ var ee = Math.floor(Math.abs(j) / M.snapDistance);
+ j %= M.snapDistance, ae.delta.normalizeToRef(ne), ne.scaleInPlace(M.snapDistance * ee), M.attachedNode.getWorldMatrix().addTranslationFromFloats(ne.x, ne.y, ne.z), M.attachedNode.updateCache(), te.snapDistance = M.snapDistance * ee, M.onSnapObservable.notifyObservers(te);
+ }
+ M._matrixChanged();
+ }
+ }), M.dragBehavior.onDragStartObservable.add(function() {
+ M._dragging = !0;
+ }), M.dragBehavior.onDragEndObservable.add(function() {
+ M._dragging = !1;
+ });
+ var de = b._getSharedGizmoLight();
+ de.includedOnlyMeshes = de.includedOnlyMeshes.concat(M._rootMesh.getChildMeshes(!1));
+ var pe = { gizmoMeshes: U.getChildMeshes(), colliderMeshes: X.getChildMeshes(), material: M._coloredMaterial, hoverMaterial: M._hoverMaterial, disableMaterial: M._disableMaterial, active: !1 };
+ return (N = M._parent) === null || N === void 0 || N.addToAxisCache(X, pe), M._pointerObserver = b.utilityLayerScene.onPointerObservable.add(function(ae) {
+ var ee;
+ if (!M._customMeshSet && (M._isHovered = pe.colliderMeshes.indexOf((ee = ae == null ? void 0 : ae.pickInfo) === null || ee === void 0 ? void 0 : ee.pickedMesh) != -1, !M._parent)) {
+ var K = M._isHovered || M._dragging ? M._hoverMaterial : M._coloredMaterial;
+ pe.gizmoMeshes.forEach(function($) {
+ $.material = K, $.color && ($.color = K.diffuseColor);
+ });
+ }
+ }), M;
+ }
+ return Object(V.d)(l, g), l._CreateArrow = function(h, v, b, D) {
+ b === void 0 && (b = 1), D === void 0 && (D = !1);
+ var w = new u.a("arrow", h), N = O.a.CreateCylinder("cylinder", { diameterTop: 0, height: 0.075, diameterBottom: 0.0375 * (1 + (b - 1) / 4), tessellation: 96 }, h), M = O.a.CreateCylinder("cylinder", { diameterTop: 5e-3 * b, height: 0.275, diameterBottom: 5e-3 * b, tessellation: 96 }, h);
+ return N.parent = w, N.material = v, N.rotation.x = Math.PI / 2, N.position.z += 0.3, M.parent = w, M.material = v, M.position.z += 0.1375, M.rotation.x = Math.PI / 2, D && (M.visibility = 0, N.visibility = 0), w;
+ }, l._CreateArrowInstance = function(h, v) {
+ for (var b = new u.a("arrow", h), D = 0, w = v.getChildMeshes(); D < w.length; D++) {
+ var N = w[D];
+ N.createInstance(N.name).parent = b;
+ }
+ return b;
+ }, l.prototype._attachedNodeChanged = function(h) {
+ this.dragBehavior && (this.dragBehavior.enabled = !!h);
+ }, Object.defineProperty(l.prototype, "isEnabled", { get: function() {
+ return this._isEnabled;
+ }, set: function(h) {
+ this._isEnabled = h, h ? this._parent && (this.attachedMesh = this._parent.attachedMesh, this.attachedNode = this._parent.attachedNode) : (this.attachedMesh = null, this.attachedNode = null);
+ }, enumerable: !1, configurable: !0 }), l.prototype.dispose = function() {
+ this.onSnapObservable.clear(), this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver), this.dragBehavior.detach(), this._gizmoMesh && this._gizmoMesh.dispose(), [this._coloredMaterial, this._hoverMaterial, this._disableMaterial].forEach(function(h) {
+ h && h.dispose();
+ }), g.prototype.dispose.call(this);
+ }, l;
+ }(m.a);
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return V;
+ });
+ var V = function() {
+ function _() {
+ this._isDirty = !0, this._areLightsDirty = !0, this._areLightsDisposed = !1, this._areAttributesDirty = !0, this._areTexturesDirty = !0, this._areFresnelDirty = !0, this._areMiscDirty = !0, this._arePrePassDirty = !0, this._areImageProcessingDirty = !0, this._normals = !1, this._uvs = !1, this._needNormals = !1, this._needUVs = !1;
+ }
+ return Object.defineProperty(_.prototype, "isDirty", { get: function() {
+ return this._isDirty;
+ }, enumerable: !1, configurable: !0 }), _.prototype.markAsProcessed = function() {
+ this._isDirty = !1, this._areAttributesDirty = !1, this._areTexturesDirty = !1, this._areFresnelDirty = !1, this._areLightsDirty = !1, this._areLightsDisposed = !1, this._areMiscDirty = !1, this._arePrePassDirty = !1, this._areImageProcessingDirty = !1;
+ }, _.prototype.markAsUnprocessed = function() {
+ this._isDirty = !0;
+ }, _.prototype.markAllAsDirty = function() {
+ this._areTexturesDirty = !0, this._areAttributesDirty = !0, this._areLightsDirty = !0, this._areFresnelDirty = !0, this._areMiscDirty = !0, this._areImageProcessingDirty = !0, this._isDirty = !0;
+ }, _.prototype.markAsImageProcessingDirty = function() {
+ this._areImageProcessingDirty = !0, this._isDirty = !0;
+ }, _.prototype.markAsLightDirty = function(C) {
+ C === void 0 && (C = !1), this._areLightsDirty = !0, this._areLightsDisposed = this._areLightsDisposed || C, this._isDirty = !0;
+ }, _.prototype.markAsAttributesDirty = function() {
+ this._areAttributesDirty = !0, this._isDirty = !0;
+ }, _.prototype.markAsTexturesDirty = function() {
+ this._areTexturesDirty = !0, this._isDirty = !0;
+ }, _.prototype.markAsFresnelDirty = function() {
+ this._areFresnelDirty = !0, this._isDirty = !0;
+ }, _.prototype.markAsMiscDirty = function() {
+ this._areMiscDirty = !0, this._isDirty = !0;
+ }, _.prototype.markAsPrePassDirty = function() {
+ this._arePrePassDirty = !0, this._isDirty = !0;
+ }, _.prototype.rebuild = function() {
+ this._keys = [];
+ for (var C = 0, u = Object.keys(this); C < u.length; C++) {
+ var I = u[C];
+ I[0] !== "_" && this._keys.push(I);
+ }
+ }, _.prototype.isEqual = function(C) {
+ if (this._keys.length !== C._keys.length)
+ return !1;
+ for (var u = 0; u < this._keys.length; u++) {
+ var I = this._keys[u];
+ if (this[I] !== C[I])
+ return !1;
+ }
+ return !0;
+ }, _.prototype.cloneTo = function(C) {
+ this._keys.length !== C._keys.length && (C._keys = this._keys.slice(0));
+ for (var u = 0; u < this._keys.length; u++) {
+ var I = this._keys[u];
+ C[I] = this[I];
+ }
+ }, _.prototype.reset = function() {
+ for (var C = 0; C < this._keys.length; C++) {
+ var u = this._keys[C];
+ switch (typeof this[u]) {
+ case "number":
+ this[u] = 0;
+ break;
+ case "string":
+ this[u] = "";
+ break;
+ default:
+ this[u] = !1;
+ }
+ }
+ }, _.prototype.toString = function() {
+ for (var C = "", u = 0; u < this._keys.length; u++) {
+ var I = this._keys[u], O = this[I];
+ switch (typeof O) {
+ case "number":
+ case "string":
+ C += "#define " + I + " " + O + `
+`;
+ break;
+ default:
+ O && (C += "#define " + I + `
+`);
+ }
+ }
+ return C;
+ }, _;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return V;
+ });
+ var V = function() {
+ function _(C, u) {
+ this.width = C, this.height = u;
+ }
+ return _.prototype.toString = function() {
+ return "{W: " + this.width + ", H: " + this.height + "}";
+ }, _.prototype.getClassName = function() {
+ return "Size";
+ }, _.prototype.getHashCode = function() {
+ var C = 0 | this.width;
+ return C = 397 * C ^ (0 | this.height);
+ }, _.prototype.copyFrom = function(C) {
+ this.width = C.width, this.height = C.height;
+ }, _.prototype.copyFromFloats = function(C, u) {
+ return this.width = C, this.height = u, this;
+ }, _.prototype.set = function(C, u) {
+ return this.copyFromFloats(C, u);
+ }, _.prototype.multiplyByFloats = function(C, u) {
+ return new _(this.width * C, this.height * u);
+ }, _.prototype.clone = function() {
+ return new _(this.width, this.height);
+ }, _.prototype.equals = function(C) {
+ return !!C && this.width === C.width && this.height === C.height;
+ }, Object.defineProperty(_.prototype, "surface", { get: function() {
+ return this.width * this.height;
+ }, enumerable: !1, configurable: !0 }), _.Zero = function() {
+ return new _(0, 0);
+ }, _.prototype.add = function(C) {
+ return new _(this.width + C.width, this.height + C.height);
+ }, _.prototype.subtract = function(C) {
+ return new _(this.width - C.width, this.height - C.height);
+ }, _.Lerp = function(C, u, I) {
+ return new _(C.width + (u.width - C.width) * I, C.height + (u.height - C.height) * I);
+ }, _;
+ }();
+ }, function(Be, A, f) {
+ var V = "bonesDeclaration", _ = `#if NUM_BONE_INFLUENCERS>0
+#ifdef BONETEXTURE
+uniform sampler2D boneSampler;
+uniform float boneTextureWidth;
+#else
+uniform mat4 mBones[BonesPerMesh];
+#ifdef BONES_VELOCITY_ENABLED
+uniform mat4 mPreviousBones[BonesPerMesh];
+#endif
+#endif
+attribute vec4 matricesIndices;
+attribute vec4 matricesWeights;
+#if NUM_BONE_INFLUENCERS>4
+attribute vec4 matricesIndicesExtra;
+attribute vec4 matricesWeightsExtra;
+#endif
+#ifdef BONETEXTURE
+#define inline
+mat4 readMatrixFromRawSampler(sampler2D smp,float index)
+{
+float offset=index*4.0;
+float dx=1.0/boneTextureWidth;
+vec4 m0=texture2D(smp,vec2(dx*(offset+0.5),0.));
+vec4 m1=texture2D(smp,vec2(dx*(offset+1.5),0.));
+vec4 m2=texture2D(smp,vec2(dx*(offset+2.5),0.));
+vec4 m3=texture2D(smp,vec2(dx*(offset+3.5),0.));
+return mat4(m0,m1,m2,m3);
+}
+#endif
+#endif`;
+ f(5).a.IncludesShadersStore[V] = _;
+ }, function(Be, A, f) {
+ var V = "instancesDeclaration", _ = `#ifdef INSTANCES
+attribute vec4 world0;
+attribute vec4 world1;
+attribute vec4 world2;
+attribute vec4 world3;
+#ifdef THIN_INSTANCES
+uniform mat4 world;
+#endif
+#else
+uniform mat4 world;
+#endif`;
+ f(5).a.IncludesShadersStore[V] = _;
+ }, function(Be, A, f) {
+ var V = "instancesVertex", _ = `#ifdef INSTANCES
+mat4 finalWorld=mat4(world0,world1,world2,world3);
+#ifdef THIN_INSTANCES
+finalWorld=world*finalWorld;
+#endif
+#else
+mat4 finalWorld=world;
+#endif`;
+ f(5).a.IncludesShadersStore[V] = _;
+ }, function(Be, A, f) {
+ var V = `#if NUM_BONE_INFLUENCERS>0
+mat4 influence;
+#ifdef BONETEXTURE
+influence=readMatrixFromRawSampler(boneSampler,matricesIndices[0])*matricesWeights[0];
+#if NUM_BONE_INFLUENCERS>1
+influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[1])*matricesWeights[1];
+#endif
+#if NUM_BONE_INFLUENCERS>2
+influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[2])*matricesWeights[2];
+#endif
+#if NUM_BONE_INFLUENCERS>3
+influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[3])*matricesWeights[3];
+#endif
+#if NUM_BONE_INFLUENCERS>4
+influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[0])*matricesWeightsExtra[0];
+#endif
+#if NUM_BONE_INFLUENCERS>5
+influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[1])*matricesWeightsExtra[1];
+#endif
+#if NUM_BONE_INFLUENCERS>6
+influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[2])*matricesWeightsExtra[2];
+#endif
+#if NUM_BONE_INFLUENCERS>7
+influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[3])*matricesWeightsExtra[3];
+#endif
+#else
+influence=mBones[int(matricesIndices[0])]*matricesWeights[0];
+#if NUM_BONE_INFLUENCERS>1
+influence+=mBones[int(matricesIndices[1])]*matricesWeights[1];
+#endif
+#if NUM_BONE_INFLUENCERS>2
+influence+=mBones[int(matricesIndices[2])]*matricesWeights[2];
+#endif
+#if NUM_BONE_INFLUENCERS>3
+influence+=mBones[int(matricesIndices[3])]*matricesWeights[3];
+#endif
+#if NUM_BONE_INFLUENCERS>4
+influence+=mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];
+#endif
+#if NUM_BONE_INFLUENCERS>5
+influence+=mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];
+#endif
+#if NUM_BONE_INFLUENCERS>6
+influence+=mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];
+#endif
+#if NUM_BONE_INFLUENCERS>7
+influence+=mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];
+#endif
+#endif
+finalWorld=finalWorld*influence;
+#endif`;
+ f(5).a.IncludesShadersStore.bonesVertex = V;
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return O;
+ });
+ var V = f(0), _ = f(7), C = f(4), u = f(16), I = f(43);
+ u.a.CreateRibbon = function(x) {
+ var m = x.pathArray, c = x.closeArray || !1, T = x.closePath || !1, S = x.invertUV || !1, E = Math.floor(m[0].length / 2), g = x.offset || E;
+ g = g > E ? E : Math.floor(g);
+ var l, h, v, b, D = x.sideOrientation === 0 ? 0 : x.sideOrientation || u.a.DEFAULTSIDE, w = x.uvs, N = x.colors, M = [], U = [], X = [], j = [], ne = [], te = [], de = [], pe = [], ae = [], ee = [];
+ if (m.length < 2) {
+ var K = [], $ = [];
+ for (v = 0; v < m[0].length - g; v++)
+ K.push(m[0][v]), $.push(m[0][v + g]);
+ m = [K, $];
+ }
+ var L, G, Q, oe, re, Y = 0, k = T ? 1 : 0;
+ for (l = m[0].length, h = 0; h < m.length; h++) {
+ for (de[h] = 0, ne[h] = [0], l = l < (G = (L = m[h]).length) ? l : G, b = 0; b < G; )
+ M.push(L[b].x, L[b].y, L[b].z), b > 0 && (Q = L[b].subtract(L[b - 1]).length() + de[h], ne[h].push(Q), de[h] = Q), b++;
+ T && (b--, M.push(L[0].x, L[0].y, L[0].z), Q = L[b].subtract(L[0]).length() + de[h], ne[h].push(Q), de[h] = Q), ae[h] = G + k, ee[h] = Y, Y += G + k;
+ }
+ var H, Z, W = null, q = null;
+ for (v = 0; v < l + k; v++) {
+ for (pe[v] = 0, te[v] = [0], h = 0; h < m.length - 1; h++)
+ oe = m[h], re = m[h + 1], v === l ? (W = oe[0], q = re[0]) : (W = oe[v], q = re[v]), Q = q.subtract(W).length() + pe[v], te[v].push(Q), pe[v] = Q;
+ c && q && W && (oe = m[h], re = m[0], v === l && (q = re[0]), Q = q.subtract(W).length() + pe[v], pe[v] = Q);
+ }
+ if (w)
+ for (h = 0; h < w.length; h++)
+ j.push(w[h].x, w[h].y);
+ else
+ for (h = 0; h < m.length; h++)
+ for (v = 0; v < l + k; v++)
+ H = de[h] != 0 ? ne[h][v] / de[h] : 0, Z = pe[v] != 0 ? te[v][h] / pe[v] : 0, S ? j.push(Z, H) : j.push(H, Z);
+ for (var he = 0, ge = ae[h = 0] - 1, me = ae[h + 1] - 1, _e = ge < me ? ge : me, ye = ee[1] - ee[0], Pe = c ? ae.length : ae.length - 1; he <= _e && h < Pe; )
+ U.push(he, he + ye, he + 1), U.push(he + ye + 1, he + 1, he + ye), (he += 1) === _e && (++h === ae.length - 1 ? (ye = ee[0] - ee[h], ge = ae[h] - 1, me = ae[0] - 1) : (ye = ee[h + 1] - ee[h], ge = ae[h] - 1, me = ae[h + 1] - 1), he = ee[h], _e = ge < me ? ge + he : me + he);
+ if (u.a.ComputeNormals(M, U, X), T) {
+ var be = 0, Fe = 0;
+ for (h = 0; h < m.length; h++)
+ be = 3 * ee[h], Fe = h + 1 < m.length ? 3 * (ee[h + 1] - 1) : X.length - 3, X[be] = 0.5 * (X[be] + X[Fe]), X[be + 1] = 0.5 * (X[be + 1] + X[Fe + 1]), X[be + 2] = 0.5 * (X[be + 2] + X[Fe + 2]), X[Fe] = X[be], X[Fe + 1] = X[be + 1], X[Fe + 2] = X[be + 2];
+ }
+ u.a._ComputeSides(D, M, U, X, j, x.frontUVs, x.backUVs);
+ var ke = null;
+ if (N) {
+ ke = new Float32Array(4 * N.length);
+ for (var We = 0; We < N.length; We++)
+ ke[4 * We] = N[We].r, ke[4 * We + 1] = N[We].g, ke[4 * We + 2] = N[We].b, ke[4 * We + 3] = N[We].a;
+ }
+ var je = new u.a(), He = new Float32Array(M), Qe = new Float32Array(X), Ge = new Float32Array(j);
+ return je.indices = U, je.positions = He, je.normals = Qe, je.uvs = Ge, ke && je.set(ke, C.b.ColorKind), T && (je._idx = ee), je;
+ }, _.a.CreateRibbon = function(x, m, c, T, S, E, g, l, h) {
+ return c === void 0 && (c = !1), g === void 0 && (g = !1), O.CreateRibbon(x, { pathArray: m, closeArray: c, closePath: T, offset: S, updatable: g, sideOrientation: l, instance: h }, E);
+ };
+ var O = function() {
+ function x() {
+ }
+ return x.CreateRibbon = function(m, c, T) {
+ T === void 0 && (T = null);
+ var S = c.pathArray, E = c.closeArray, g = c.closePath, l = _.a._GetDefaultSideOrientation(c.sideOrientation), h = c.instance, v = c.updatable;
+ if (h) {
+ var b = V.c.Vector3[0].setAll(Number.MAX_VALUE), D = V.c.Vector3[1].setAll(-Number.MAX_VALUE), w = h.getVerticesData(C.b.PositionKind);
+ if (function(G) {
+ for (var Q = S[0].length, oe = h, re = 0, Y = oe._originalBuilderSideOrientation === _.a.DOUBLESIDE ? 2 : 1, k = 1; k <= Y; ++k)
+ for (var H = 0; H < S.length; ++H) {
+ var Z = S[H], W = Z.length;
+ Q = Q < W ? Q : W;
+ for (var q = 0; q < Q; ++q) {
+ var he = Z[q];
+ G[re] = he.x, G[re + 1] = he.y, G[re + 2] = he.z, b.minimizeInPlaceFromFloats(he.x, he.y, he.z), D.maximizeInPlaceFromFloats(he.x, he.y, he.z), re += 3;
+ }
+ oe._creationDataStorage && oe._creationDataStorage.closePath && (he = Z[0], G[re] = he.x, G[re + 1] = he.y, G[re + 2] = he.z, re += 3);
+ }
+ }(w), h._boundingInfo ? h._boundingInfo.reConstruct(b, D, h._worldMatrix) : h._boundingInfo = new I.a(b, D, h._worldMatrix), h.updateVerticesData(C.b.PositionKind, w, !1, !1), c.colors) {
+ for (var N = h.getVerticesData(C.b.ColorKind), M = 0, U = 0; M < c.colors.length; M++, U += 4) {
+ var X = c.colors[M];
+ N[U] = X.r, N[U + 1] = X.g, N[U + 2] = X.b, N[U + 3] = X.a;
+ }
+ h.updateVerticesData(C.b.ColorKind, N, !1, !1);
+ }
+ if (c.uvs) {
+ for (var j = h.getVerticesData(C.b.UVKind), ne = 0; ne < c.uvs.length; ne++)
+ j[2 * ne] = c.uvs[ne].x, j[2 * ne + 1] = c.uvs[ne].y;
+ h.updateVerticesData(C.b.UVKind, j, !1, !1);
+ }
+ if (!h.areNormalsFrozen || h.isFacetDataEnabled) {
+ var te = h.getIndices(), de = h.getVerticesData(C.b.NormalKind), pe = h.isFacetDataEnabled ? h.getFacetDataParameters() : null;
+ if (u.a.ComputeNormals(w, te, de, pe), h._creationDataStorage && h._creationDataStorage.closePath)
+ for (var ae = 0, ee = 0, K = 0; K < S.length; K++)
+ ae = 3 * h._creationDataStorage.idx[K], ee = K + 1 < S.length ? 3 * (h._creationDataStorage.idx[K + 1] - 1) : de.length - 3, de[ae] = 0.5 * (de[ae] + de[ee]), de[ae + 1] = 0.5 * (de[ae + 1] + de[ee + 1]), de[ae + 2] = 0.5 * (de[ae + 2] + de[ee + 2]), de[ee] = de[ae], de[ee + 1] = de[ae + 1], de[ee + 2] = de[ae + 2];
+ h.areNormalsFrozen || h.updateVerticesData(C.b.NormalKind, de, !1, !1);
+ }
+ return h;
+ }
+ var $ = new _.a(m, T);
+ $._originalBuilderSideOrientation = l, $._creationDataStorage = new _.b();
+ var L = u.a.CreateRibbon(c);
+ return g && ($._creationDataStorage.idx = L._idx), $._creationDataStorage.closePath = g, $._creationDataStorage.closeArray = E, L.applyToMesh($, v), $;
+ }, x;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return V;
+ });
+ var V = function() {
+ function _() {
+ }
+ return _.FilesToLoad = {}, _;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return C;
+ });
+ var V = f(7), _ = f(16);
+ _.a.CreatePlane = function(u) {
+ var I = [], O = [], x = [], m = [], c = u.width || u.size || 1, T = u.height || u.size || 1, S = u.sideOrientation === 0 ? 0 : u.sideOrientation || _.a.DEFAULTSIDE, E = c / 2, g = T / 2;
+ O.push(-E, -g, 0), x.push(0, 0, -1), m.push(0, 0), O.push(E, -g, 0), x.push(0, 0, -1), m.push(1, 0), O.push(E, g, 0), x.push(0, 0, -1), m.push(1, 1), O.push(-E, g, 0), x.push(0, 0, -1), m.push(0, 1), I.push(0), I.push(1), I.push(2), I.push(0), I.push(2), I.push(3), _.a._ComputeSides(S, O, I, x, m, u.frontUVs, u.backUVs);
+ var l = new _.a();
+ return l.indices = I, l.positions = O, l.normals = x, l.uvs = m, l;
+ }, V.a.CreatePlane = function(u, I, O, x, m) {
+ var c = { size: I, width: I, height: I, sideOrientation: m, updatable: x };
+ return C.CreatePlane(u, c, O);
+ };
+ var C = function() {
+ function u() {
+ }
+ return u.CreatePlane = function(I, O, x) {
+ x === void 0 && (x = null);
+ var m = new V.a(I, x);
+ return O.sideOrientation = V.a._GetDefaultSideOrientation(O.sideOrientation), m._originalBuilderSideOrientation = O.sideOrientation, _.a.CreatePlane(O).applyToMesh(m, O.updatable), O.sourcePlane && (m.translate(O.sourcePlane.normal, -O.sourcePlane.d), m.setDirection(O.sourcePlane.normal.scale(-1))), m;
+ }, u;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return _;
+ });
+ var V = f(8), _ = (f(153), function() {
+ function C(u, I, O) {
+ this._alreadyBound = !1, this._valueCache = {}, this._engine = u, this._noUBO = !u.supportsUniformBuffers, this._dynamic = O, this._data = I || [], this._uniformLocations = {}, this._uniformSizes = {}, this._uniformLocationPointer = 0, this._needSync = !1, this._noUBO ? (this.updateMatrix3x3 = this._updateMatrix3x3ForEffect, this.updateMatrix2x2 = this._updateMatrix2x2ForEffect, this.updateFloat = this._updateFloatForEffect, this.updateFloat2 = this._updateFloat2ForEffect, this.updateFloat3 = this._updateFloat3ForEffect, this.updateFloat4 = this._updateFloat4ForEffect, this.updateMatrix = this._updateMatrixForEffect, this.updateVector3 = this._updateVector3ForEffect, this.updateVector4 = this._updateVector4ForEffect, this.updateColor3 = this._updateColor3ForEffect, this.updateColor4 = this._updateColor4ForEffect) : (this._engine._uniformBuffers.push(this), this.updateMatrix3x3 = this._updateMatrix3x3ForUniform, this.updateMatrix2x2 = this._updateMatrix2x2ForUniform, this.updateFloat = this._updateFloatForUniform, this.updateFloat2 = this._updateFloat2ForUniform, this.updateFloat3 = this._updateFloat3ForUniform, this.updateFloat4 = this._updateFloat4ForUniform, this.updateMatrix = this._updateMatrixForUniform, this.updateVector3 = this._updateVector3ForUniform, this.updateVector4 = this._updateVector4ForUniform, this.updateColor3 = this._updateColor3ForUniform, this.updateColor4 = this._updateColor4ForUniform);
+ }
+ return Object.defineProperty(C.prototype, "useUbo", { get: function() {
+ return !this._noUBO;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(C.prototype, "isSync", { get: function() {
+ return !this._needSync;
+ }, enumerable: !1, configurable: !0 }), C.prototype.isDynamic = function() {
+ return this._dynamic !== void 0;
+ }, C.prototype.getData = function() {
+ return this._bufferData;
+ }, C.prototype.getBuffer = function() {
+ return this._buffer;
+ }, C.prototype._fillAlignment = function(u) {
+ var I;
+ if (I = u <= 2 ? u : 4, this._uniformLocationPointer % I != 0) {
+ var O = this._uniformLocationPointer;
+ this._uniformLocationPointer += I - this._uniformLocationPointer % I;
+ for (var x = this._uniformLocationPointer - O, m = 0; m < x; m++)
+ this._data.push(0);
+ }
+ }, C.prototype.addUniform = function(u, I) {
+ if (!this._noUBO && this._uniformLocations[u] === void 0) {
+ var O;
+ if (I instanceof Array)
+ I = (O = I).length;
+ else {
+ I = I, O = [];
+ for (var x = 0; x < I; x++)
+ O.push(0);
+ }
+ for (this._fillAlignment(I), this._uniformSizes[u] = I, this._uniformLocations[u] = this._uniformLocationPointer, this._uniformLocationPointer += I, x = 0; x < I; x++)
+ this._data.push(O[x]);
+ this._needSync = !0;
+ }
+ }, C.prototype.addMatrix = function(u, I) {
+ this.addUniform(u, Array.prototype.slice.call(I.toArray()));
+ }, C.prototype.addFloat2 = function(u, I, O) {
+ var x = [I, O];
+ this.addUniform(u, x);
+ }, C.prototype.addFloat3 = function(u, I, O, x) {
+ var m = [I, O, x];
+ this.addUniform(u, m);
+ }, C.prototype.addColor3 = function(u, I) {
+ var O = new Array();
+ I.toArray(O), this.addUniform(u, O);
+ }, C.prototype.addColor4 = function(u, I, O) {
+ var x = new Array();
+ I.toArray(x), x.push(O), this.addUniform(u, x);
+ }, C.prototype.addVector3 = function(u, I) {
+ var O = new Array();
+ I.toArray(O), this.addUniform(u, O);
+ }, C.prototype.addMatrix3x3 = function(u) {
+ this.addUniform(u, 12);
+ }, C.prototype.addMatrix2x2 = function(u) {
+ this.addUniform(u, 8);
+ }, C.prototype.create = function() {
+ this._noUBO || this._buffer || (this._fillAlignment(4), this._bufferData = new Float32Array(this._data), this._rebuild(), this._needSync = !0);
+ }, C.prototype._rebuild = function() {
+ !this._noUBO && this._bufferData && (this._dynamic ? this._buffer = this._engine.createDynamicUniformBuffer(this._bufferData) : this._buffer = this._engine.createUniformBuffer(this._bufferData));
+ }, C.prototype.update = function() {
+ this._buffer ? (this._dynamic || this._needSync) && (this._engine.updateUniformBuffer(this._buffer, this._bufferData), this._needSync = !1) : this.create();
+ }, C.prototype.updateUniform = function(u, I, O) {
+ var x = this._uniformLocations[u];
+ if (x === void 0) {
+ if (this._buffer)
+ return void V.a.Error("Cannot add an uniform after UBO has been created.");
+ this.addUniform(u, O), x = this._uniformLocations[u];
+ }
+ if (this._buffer || this.create(), this._dynamic)
+ for (c = 0; c < O; c++)
+ this._bufferData[x + c] = I[c];
+ else {
+ for (var m = !1, c = 0; c < O; c++)
+ O !== 16 && this._bufferData[x + c] === I[c] || (m = !0, this._bufferData[x + c] = I[c]);
+ this._needSync = this._needSync || m;
+ }
+ }, C.prototype._cacheMatrix = function(u, I) {
+ var O = this._valueCache[u], x = I.updateFlag;
+ return (O === void 0 || O !== x) && (this._valueCache[u] = x, !0);
+ }, C.prototype._updateMatrix3x3ForUniform = function(u, I) {
+ for (var O = 0; O < 3; O++)
+ C._tempBuffer[4 * O] = I[3 * O], C._tempBuffer[4 * O + 1] = I[3 * O + 1], C._tempBuffer[4 * O + 2] = I[3 * O + 2], C._tempBuffer[4 * O + 3] = 0;
+ this.updateUniform(u, C._tempBuffer, 12);
+ }, C.prototype._updateMatrix3x3ForEffect = function(u, I) {
+ this._currentEffect.setMatrix3x3(u, I);
+ }, C.prototype._updateMatrix2x2ForEffect = function(u, I) {
+ this._currentEffect.setMatrix2x2(u, I);
+ }, C.prototype._updateMatrix2x2ForUniform = function(u, I) {
+ for (var O = 0; O < 2; O++)
+ C._tempBuffer[4 * O] = I[2 * O], C._tempBuffer[4 * O + 1] = I[2 * O + 1], C._tempBuffer[4 * O + 2] = 0, C._tempBuffer[4 * O + 3] = 0;
+ this.updateUniform(u, C._tempBuffer, 8);
+ }, C.prototype._updateFloatForEffect = function(u, I) {
+ this._currentEffect.setFloat(u, I);
+ }, C.prototype._updateFloatForUniform = function(u, I) {
+ C._tempBuffer[0] = I, this.updateUniform(u, C._tempBuffer, 1);
+ }, C.prototype._updateFloat2ForEffect = function(u, I, O, x) {
+ x === void 0 && (x = ""), this._currentEffect.setFloat2(u + x, I, O);
+ }, C.prototype._updateFloat2ForUniform = function(u, I, O) {
+ C._tempBuffer[0] = I, C._tempBuffer[1] = O, this.updateUniform(u, C._tempBuffer, 2);
+ }, C.prototype._updateFloat3ForEffect = function(u, I, O, x, m) {
+ m === void 0 && (m = ""), this._currentEffect.setFloat3(u + m, I, O, x);
+ }, C.prototype._updateFloat3ForUniform = function(u, I, O, x) {
+ C._tempBuffer[0] = I, C._tempBuffer[1] = O, C._tempBuffer[2] = x, this.updateUniform(u, C._tempBuffer, 3);
+ }, C.prototype._updateFloat4ForEffect = function(u, I, O, x, m, c) {
+ c === void 0 && (c = ""), this._currentEffect.setFloat4(u + c, I, O, x, m);
+ }, C.prototype._updateFloat4ForUniform = function(u, I, O, x, m) {
+ C._tempBuffer[0] = I, C._tempBuffer[1] = O, C._tempBuffer[2] = x, C._tempBuffer[3] = m, this.updateUniform(u, C._tempBuffer, 4);
+ }, C.prototype._updateMatrixForEffect = function(u, I) {
+ this._currentEffect.setMatrix(u, I);
+ }, C.prototype._updateMatrixForUniform = function(u, I) {
+ this._cacheMatrix(u, I) && this.updateUniform(u, I.toArray(), 16);
+ }, C.prototype._updateVector3ForEffect = function(u, I) {
+ this._currentEffect.setVector3(u, I);
+ }, C.prototype._updateVector3ForUniform = function(u, I) {
+ I.toArray(C._tempBuffer), this.updateUniform(u, C._tempBuffer, 3);
+ }, C.prototype._updateVector4ForEffect = function(u, I) {
+ this._currentEffect.setVector4(u, I);
+ }, C.prototype._updateVector4ForUniform = function(u, I) {
+ I.toArray(C._tempBuffer), this.updateUniform(u, C._tempBuffer, 4);
+ }, C.prototype._updateColor3ForEffect = function(u, I, O) {
+ O === void 0 && (O = ""), this._currentEffect.setColor3(u + O, I);
+ }, C.prototype._updateColor3ForUniform = function(u, I) {
+ I.toArray(C._tempBuffer), this.updateUniform(u, C._tempBuffer, 3);
+ }, C.prototype._updateColor4ForEffect = function(u, I, O, x) {
+ x === void 0 && (x = ""), this._currentEffect.setColor4(u + x, I, O);
+ }, C.prototype._updateColor4ForUniform = function(u, I, O) {
+ I.toArray(C._tempBuffer), C._tempBuffer[3] = O, this.updateUniform(u, C._tempBuffer, 4);
+ }, C.prototype.setTexture = function(u, I) {
+ this._currentEffect.setTexture(u, I);
+ }, C.prototype.updateUniformDirectly = function(u, I) {
+ this.updateUniform(u, I, I.length), this.update();
+ }, C.prototype.bindToEffect = function(u, I) {
+ this._currentEffect = u, !this._noUBO && this._buffer && (this._alreadyBound = !0, u.bindUniformBuffer(this._buffer, I));
+ }, C.prototype.dispose = function() {
+ if (!this._noUBO) {
+ var u = this._engine._uniformBuffers, I = u.indexOf(this);
+ I !== -1 && (u[I] = u[u.length - 1], u.pop()), this._buffer && this._engine._releaseBuffer(this._buffer) && (this._buffer = null);
+ }
+ }, C._MAX_UNIFORM_SIZE = 256, C._tempBuffer = new Float32Array(C._MAX_UNIFORM_SIZE), C;
+ }());
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return x;
+ });
+ var V = f(1), _ = f(3), C = f(0), u = f(9), I = f(29), O = f(48);
+ I.a.AddNodeConstructor("Light_Type_3", function(m, c) {
+ return function() {
+ return new x(m, C.e.Zero(), c);
+ };
+ });
+ var x = function(m) {
+ function c(T, S, E) {
+ var g = m.call(this, T, E) || this;
+ return g.groundColor = new u.a(0, 0, 0), g.direction = S || C.e.Up(), g;
+ }
+ return Object(V.d)(c, m), c.prototype._buildUniformLayout = function() {
+ this._uniformBuffer.addUniform("vLightData", 4), this._uniformBuffer.addUniform("vLightDiffuse", 4), this._uniformBuffer.addUniform("vLightSpecular", 4), this._uniformBuffer.addUniform("vLightGround", 3), this._uniformBuffer.addUniform("shadowsInfo", 3), this._uniformBuffer.addUniform("depthValues", 2), this._uniformBuffer.create();
+ }, c.prototype.getClassName = function() {
+ return "HemisphericLight";
+ }, c.prototype.setDirectionToTarget = function(T) {
+ return this.direction = C.e.Normalize(T.subtract(C.e.Zero())), this.direction;
+ }, c.prototype.getShadowGenerator = function() {
+ return null;
+ }, c.prototype.transferToEffect = function(T, S) {
+ var E = C.e.Normalize(this.direction);
+ return this._uniformBuffer.updateFloat4("vLightData", E.x, E.y, E.z, 0, S), this._uniformBuffer.updateColor3("vLightGround", this.groundColor.scale(this.intensity), S), this;
+ }, c.prototype.transferToNodeMaterialEffect = function(T, S) {
+ var E = C.e.Normalize(this.direction);
+ return T.setFloat3(S, E.x, E.y, E.z), this;
+ }, c.prototype.computeWorldMatrix = function() {
+ return this._worldMatrix || (this._worldMatrix = C.a.Identity()), this._worldMatrix;
+ }, c.prototype.getTypeID = function() {
+ return O.a.LIGHTTYPEID_HEMISPHERICLIGHT;
+ }, c.prototype.prepareLightSpecificDefines = function(T, S) {
+ T["HEMILIGHT" + S] = !0;
+ }, Object(V.c)([Object(_.e)()], c.prototype, "groundColor", void 0), Object(V.c)([Object(_.o)()], c.prototype, "direction", void 0), c;
+ }(O.a);
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return C;
+ });
+ var V = f(1), _ = f(0), C = function(u) {
+ function I(O, x) {
+ var m = u.call(this, O, x) || this;
+ return m._normalMatrix = new _.a(), m._storeEffectOnSubMeshes = !0, m;
+ }
+ return Object(V.d)(I, u), I.prototype.getEffect = function() {
+ return this._activeEffect;
+ }, I.prototype.isReady = function(O, x) {
+ return !!O && (!O.subMeshes || O.subMeshes.length === 0 || this.isReadyForSubMesh(O, O.subMeshes[0], x));
+ }, I.prototype._isReadyForSubMesh = function(O) {
+ var x = O._materialDefines;
+ return !(this.checkReadyOnEveryCall || !O.effect || !x || x._renderId !== this.getScene().getRenderId());
+ }, I.prototype.bindOnlyWorldMatrix = function(O) {
+ this._activeEffect.setMatrix("world", O);
+ }, I.prototype.bindOnlyNormalMatrix = function(O) {
+ this._activeEffect.setMatrix("normalMatrix", O);
+ }, I.prototype.bind = function(O, x) {
+ x && this.bindForSubMesh(O, x, x.subMeshes[0]);
+ }, I.prototype._afterBind = function(O, x) {
+ x === void 0 && (x = null), u.prototype._afterBind.call(this, O), this.getScene()._cachedEffect = x;
+ }, I.prototype._mustRebind = function(O, x, m) {
+ return m === void 0 && (m = 1), O.isCachedMaterialInvalid(this, x, m);
+ }, I;
+ }(f(25).a);
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return _;
+ });
+ var V = f(1), _ = function(C) {
+ function u(I) {
+ var O = C.call(this) || this;
+ return O._buffer = I, O;
+ }
+ return Object(V.d)(u, C), Object.defineProperty(u.prototype, "underlyingResource", { get: function() {
+ return this._buffer;
+ }, enumerable: !1, configurable: !0 }), u;
+ }(f(89).a);
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return V;
+ });
+ var V = function() {
+ function _() {
+ this.references = 0, this.capacity = 0, this.is32Bits = !1;
+ }
+ return Object.defineProperty(_.prototype, "underlyingResource", { get: function() {
+ return null;
+ }, enumerable: !1, configurable: !0 }), _;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return _;
+ });
+ var V = f(64), _ = function() {
+ function C() {
+ }
+ return C.GetPlanes = function(u) {
+ for (var I = [], O = 0; O < 6; O++)
+ I.push(new V.a(0, 0, 0, 0));
+ return C.GetPlanesToRef(u, I), I;
+ }, C.GetNearPlaneToRef = function(u, I) {
+ var O = u.m;
+ I.normal.x = O[3] + O[2], I.normal.y = O[7] + O[6], I.normal.z = O[11] + O[10], I.d = O[15] + O[14], I.normalize();
+ }, C.GetFarPlaneToRef = function(u, I) {
+ var O = u.m;
+ I.normal.x = O[3] - O[2], I.normal.y = O[7] - O[6], I.normal.z = O[11] - O[10], I.d = O[15] - O[14], I.normalize();
+ }, C.GetLeftPlaneToRef = function(u, I) {
+ var O = u.m;
+ I.normal.x = O[3] + O[0], I.normal.y = O[7] + O[4], I.normal.z = O[11] + O[8], I.d = O[15] + O[12], I.normalize();
+ }, C.GetRightPlaneToRef = function(u, I) {
+ var O = u.m;
+ I.normal.x = O[3] - O[0], I.normal.y = O[7] - O[4], I.normal.z = O[11] - O[8], I.d = O[15] - O[12], I.normalize();
+ }, C.GetTopPlaneToRef = function(u, I) {
+ var O = u.m;
+ I.normal.x = O[3] - O[1], I.normal.y = O[7] - O[5], I.normal.z = O[11] - O[9], I.d = O[15] - O[13], I.normalize();
+ }, C.GetBottomPlaneToRef = function(u, I) {
+ var O = u.m;
+ I.normal.x = O[3] + O[1], I.normal.y = O[7] + O[5], I.normal.z = O[11] + O[9], I.d = O[15] + O[13], I.normalize();
+ }, C.GetPlanesToRef = function(u, I) {
+ C.GetNearPlaneToRef(u, I[0]), C.GetFarPlaneToRef(u, I[1]), C.GetLeftPlaneToRef(u, I[2]), C.GetRightPlaneToRef(u, I[3]), C.GetTopPlaneToRef(u, I[4]), C.GetBottomPlaneToRef(u, I[5]);
+ }, C;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return _;
+ });
+ var V = f(2), _ = function() {
+ function C() {
+ this.hoverCursor = "", this.actions = new Array(), this.isRecursive = !1;
+ }
+ return Object.defineProperty(C, "HasTriggers", { get: function() {
+ for (var u in C.Triggers)
+ if (C.Triggers.hasOwnProperty(u))
+ return !0;
+ return !1;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(C, "HasPickTriggers", { get: function() {
+ for (var u in C.Triggers)
+ if (C.Triggers.hasOwnProperty(u)) {
+ var I = parseInt(u);
+ if (I >= V.a.ACTION_OnPickTrigger && I <= V.a.ACTION_OnPickUpTrigger)
+ return !0;
+ }
+ return !1;
+ }, enumerable: !1, configurable: !0 }), C.HasSpecificTrigger = function(u) {
+ for (var I in C.Triggers)
+ if (C.Triggers.hasOwnProperty(I) && parseInt(I) === u)
+ return !0;
+ return !1;
+ }, C.Triggers = {}, C;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return O;
+ });
+ var V = f(1), _ = f(25), C = f(3), u = f(19), I = f(15), O = function() {
+ function x(m) {
+ this._texture = null, this.diffuseBlendLevel = 1, this.roughnessBlendLevel = 1, this.bumpLevel = 1, this._normalBlendMethod = _.a.MATERIAL_NORMALBLENDMETHOD_WHITEOUT, this._isEnabled = !1, this.isEnabled = !1, this._internalMarkAllSubMeshesAsTexturesDirty = m;
+ }
+ return x.prototype._markAllSubMeshesAsTexturesDirty = function() {
+ this._internalMarkAllSubMeshesAsTexturesDirty();
+ }, x.prototype.isReadyForSubMesh = function(m, c) {
+ var T = c.getEngine();
+ return !(m._areTexturesDirty && c.texturesEnabled && T.getCaps().standardDerivatives && this._texture && u.a.DetailTextureEnabled && !this._texture.isReady());
+ }, x.prototype.prepareDefines = function(m, c) {
+ if (this._isEnabled) {
+ m.DETAIL_NORMALBLENDMETHOD = this._normalBlendMethod;
+ var T = c.getEngine();
+ m._areTexturesDirty && (T.getCaps().standardDerivatives && this._texture && u.a.DetailTextureEnabled && this._isEnabled ? (I.a.PrepareDefinesForMergedUV(this._texture, m, "DETAIL"), m.DETAIL_NORMALBLENDMETHOD = this._normalBlendMethod) : m.DETAIL = !1);
+ } else
+ m.DETAIL = !1;
+ }, x.prototype.bindForSubMesh = function(m, c, T) {
+ this._isEnabled && (m.useUbo && T && m.isSync || this._texture && u.a.DetailTextureEnabled && (m.updateFloat4("vDetailInfos", this._texture.coordinatesIndex, this.diffuseBlendLevel, this.bumpLevel, this.roughnessBlendLevel), I.a.BindTextureMatrix(this._texture, m, "detail")), c.texturesEnabled && this._texture && u.a.DetailTextureEnabled && m.setTexture("detailSampler", this._texture));
+ }, x.prototype.hasTexture = function(m) {
+ return this._texture === m;
+ }, x.prototype.getActiveTextures = function(m) {
+ this._texture && m.push(this._texture);
+ }, x.prototype.getAnimatables = function(m) {
+ this._texture && this._texture.animations && this._texture.animations.length > 0 && m.push(this._texture);
+ }, x.prototype.dispose = function(m) {
+ var c;
+ m && ((c = this._texture) === null || c === void 0 || c.dispose());
+ }, x.prototype.getClassName = function() {
+ return "DetailMap";
+ }, x.AddUniforms = function(m) {
+ m.push("vDetailInfos");
+ }, x.AddSamplers = function(m) {
+ m.push("detailSampler");
+ }, x.PrepareUniformBuffer = function(m) {
+ m.addUniform("vDetailInfos", 4), m.addUniform("detailMatrix", 16);
+ }, x.prototype.copyTo = function(m) {
+ C.a.Clone(function() {
+ return m;
+ }, this);
+ }, x.prototype.serialize = function() {
+ return C.a.Serialize(this);
+ }, x.prototype.parse = function(m, c, T) {
+ var S = this;
+ C.a.Parse(function() {
+ return S;
+ }, m, c, T);
+ }, Object(V.c)([Object(C.m)("detailTexture"), Object(C.b)("_markAllSubMeshesAsTexturesDirty")], x.prototype, "texture", void 0), Object(V.c)([Object(C.c)()], x.prototype, "diffuseBlendLevel", void 0), Object(V.c)([Object(C.c)()], x.prototype, "roughnessBlendLevel", void 0), Object(V.c)([Object(C.c)()], x.prototype, "bumpLevel", void 0), Object(V.c)([Object(C.c)(), Object(C.b)("_markAllSubMeshesAsTexturesDirty")], x.prototype, "normalBlendMethod", void 0), Object(V.c)([Object(C.c)(), Object(C.b)("_markAllSubMeshesAsTexturesDirty")], x.prototype, "isEnabled", void 0), x;
+ }();
+ }, function(Be, A, f) {
+ var V = "morphTargetsVertexGlobalDeclaration", _ = `#ifdef MORPHTARGETS
+uniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];
+#endif`;
+ f(5).a.IncludesShadersStore[V] = _;
+ }, function(Be, A, f) {
+ var V = "morphTargetsVertexDeclaration", _ = `#ifdef MORPHTARGETS
+attribute vec3 position{X};
+#ifdef MORPHTARGETS_NORMAL
+attribute vec3 normal{X};
+#endif
+#ifdef MORPHTARGETS_TANGENT
+attribute vec3 tangent{X};
+#endif
+#ifdef MORPHTARGETS_UV
+attribute vec2 uv_{X};
+#endif
+#endif`;
+ f(5).a.IncludesShadersStore[V] = _;
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return u;
+ });
+ var V = f(25), _ = f(4), C = f(2), u = function() {
+ function I(O) {
+ this._vertexBuffers = {}, this._scene = O;
+ }
+ return I.prototype._prepareBuffers = function() {
+ if (!this._vertexBuffers[_.b.PositionKind]) {
+ var O = [];
+ O.push(1, 1), O.push(-1, 1), O.push(-1, -1), O.push(1, -1), this._vertexBuffers[_.b.PositionKind] = new _.b(this._scene.getEngine(), O, _.b.PositionKind, !1, !1, 2), this._buildIndexBuffer();
+ }
+ }, I.prototype._buildIndexBuffer = function() {
+ var O = [];
+ O.push(0), O.push(1), O.push(2), O.push(0), O.push(2), O.push(3), this._indexBuffer = this._scene.getEngine().createIndexBuffer(O);
+ }, I.prototype._rebuild = function() {
+ var O = this._vertexBuffers[_.b.PositionKind];
+ O && (O._rebuild(), this._buildIndexBuffer());
+ }, I.prototype._prepareFrame = function(O, x) {
+ O === void 0 && (O = null), x === void 0 && (x = null);
+ var m = this._scene.activeCamera;
+ return !!m && !(!(x = x || m._postProcesses.filter(function(c) {
+ return c != null;
+ })) || x.length === 0 || !this._scene.postProcessesEnabled) && (x[0].activate(m, O, x != null), !0);
+ }, I.prototype.directRender = function(O, x, m, c, T, S) {
+ x === void 0 && (x = null), m === void 0 && (m = !1), c === void 0 && (c = 0), T === void 0 && (T = 0), S === void 0 && (S = !1);
+ for (var E = this._scene.getEngine(), g = 0; g < O.length; g++) {
+ g < O.length - 1 ? O[g + 1].activate(this._scene.activeCamera, x) : x ? E.bindFramebuffer(x, c, void 0, void 0, m, T) : S || E.restoreDefaultFramebuffer();
+ var l = O[g], h = l.apply();
+ h && (l.onBeforeRenderObservable.notifyObservers(h), this._prepareBuffers(), E.bindBuffers(this._vertexBuffers, this._indexBuffer, h), E.drawElementsType(V.a.TriangleFillMode, 0, 6), l.onAfterRenderObservable.notifyObservers(h));
+ }
+ E.setDepthBuffer(!0), E.setDepthWrite(!0);
+ }, I.prototype._finalizeFrame = function(O, x, m, c, T) {
+ T === void 0 && (T = !1);
+ var S = this._scene.activeCamera;
+ if (S && (c = c || S._postProcesses.filter(function(b) {
+ return b != null;
+ })).length !== 0 && this._scene.postProcessesEnabled) {
+ for (var E = this._scene.getEngine(), g = 0, l = c.length; g < l; g++) {
+ var h = c[g];
+ if (g < l - 1 ? h._outputTexture = c[g + 1].activate(S, x) : x ? (E.bindFramebuffer(x, m, void 0, void 0, T), h._outputTexture = x) : (E.restoreDefaultFramebuffer(), h._outputTexture = null), O)
+ break;
+ var v = h.apply();
+ v && (h.onBeforeRenderObservable.notifyObservers(v), this._prepareBuffers(), E.bindBuffers(this._vertexBuffers, this._indexBuffer, v), E.drawElementsType(V.a.TriangleFillMode, 0, 6), h.onAfterRenderObservable.notifyObservers(v));
+ }
+ E.setDepthBuffer(!0), E.setDepthWrite(!0), E.setAlphaMode(C.a.ALPHA_DISABLE);
+ }
+ }, I.prototype.dispose = function() {
+ var O = this._vertexBuffers[_.b.PositionKind];
+ O && (O.dispose(), this._vertexBuffers[_.b.PositionKind] = null), this._indexBuffer && (this._scene.getEngine()._releaseBuffer(this._indexBuffer), this._indexBuffer = null);
+ }, I;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return _;
+ }), f.d(A, "b", function() {
+ return C;
+ });
+ var V = f(148), _ = function() {
+ }, C = function() {
+ function u(I) {
+ this._useSceneAutoClearSetup = !1, this._renderingGroups = new Array(), this._autoClearDepthStencil = {}, this._customOpaqueSortCompareFn = {}, this._customAlphaTestSortCompareFn = {}, this._customTransparentSortCompareFn = {}, this._renderingGroupInfo = new _(), this._scene = I;
+ for (var O = u.MIN_RENDERINGGROUPS; O < u.MAX_RENDERINGGROUPS; O++)
+ this._autoClearDepthStencil[O] = { autoClear: !0, depth: !0, stencil: !0 };
+ }
+ return u.prototype._clearDepthStencilBuffer = function(I, O) {
+ I === void 0 && (I = !0), O === void 0 && (O = !0), this._depthStencilBufferAlreadyCleaned || (this._scene.getEngine().clear(null, !1, I, O), this._depthStencilBufferAlreadyCleaned = !0);
+ }, u.prototype.render = function(I, O, x, m) {
+ var c = this._renderingGroupInfo;
+ if (c.scene = this._scene, c.camera = this._scene.activeCamera, this._scene.spriteManagers && m)
+ for (var T = 0; T < this._scene.spriteManagers.length; T++) {
+ var S = this._scene.spriteManagers[T];
+ this.dispatchSprites(S);
+ }
+ for (T = u.MIN_RENDERINGGROUPS; T < u.MAX_RENDERINGGROUPS; T++) {
+ this._depthStencilBufferAlreadyCleaned = T === u.MIN_RENDERINGGROUPS;
+ var E = this._renderingGroups[T];
+ if (E) {
+ var g = Math.pow(2, T);
+ if (c.renderingGroupId = T, this._scene.onBeforeRenderingGroupObservable.notifyObservers(c, g), u.AUTOCLEAR) {
+ var l = this._useSceneAutoClearSetup ? this._scene.getAutoClearDepthStencilSetup(T) : this._autoClearDepthStencil[T];
+ l && l.autoClear && this._clearDepthStencilBuffer(l.depth, l.stencil);
+ }
+ for (var h = 0, v = this._scene._beforeRenderingGroupDrawStage; h < v.length; h++)
+ v[h].action(T);
+ E.render(I, m, x, O);
+ for (var b = 0, D = this._scene._afterRenderingGroupDrawStage; b < D.length; b++)
+ D[b].action(T);
+ this._scene.onAfterRenderingGroupObservable.notifyObservers(c, g);
+ }
+ }
+ }, u.prototype.reset = function() {
+ for (var I = u.MIN_RENDERINGGROUPS; I < u.MAX_RENDERINGGROUPS; I++) {
+ var O = this._renderingGroups[I];
+ O && O.prepare();
+ }
+ }, u.prototype.dispose = function() {
+ this.freeRenderingGroups(), this._renderingGroups.length = 0, this._renderingGroupInfo = null;
+ }, u.prototype.freeRenderingGroups = function() {
+ for (var I = u.MIN_RENDERINGGROUPS; I < u.MAX_RENDERINGGROUPS; I++) {
+ var O = this._renderingGroups[I];
+ O && O.dispose();
+ }
+ }, u.prototype._prepareRenderingGroup = function(I) {
+ this._renderingGroups[I] === void 0 && (this._renderingGroups[I] = new V.a(I, this._scene, this._customOpaqueSortCompareFn[I], this._customAlphaTestSortCompareFn[I], this._customTransparentSortCompareFn[I]));
+ }, u.prototype.dispatchSprites = function(I) {
+ var O = I.renderingGroupId || 0;
+ this._prepareRenderingGroup(O), this._renderingGroups[O].dispatchSprites(I);
+ }, u.prototype.dispatchParticles = function(I) {
+ var O = I.renderingGroupId || 0;
+ this._prepareRenderingGroup(O), this._renderingGroups[O].dispatchParticles(I);
+ }, u.prototype.dispatch = function(I, O, x) {
+ O === void 0 && (O = I.getMesh());
+ var m = O.renderingGroupId || 0;
+ this._prepareRenderingGroup(m), this._renderingGroups[m].dispatch(I, O, x);
+ }, u.prototype.setRenderingOrder = function(I, O, x, m) {
+ if (O === void 0 && (O = null), x === void 0 && (x = null), m === void 0 && (m = null), this._customOpaqueSortCompareFn[I] = O, this._customAlphaTestSortCompareFn[I] = x, this._customTransparentSortCompareFn[I] = m, this._renderingGroups[I]) {
+ var c = this._renderingGroups[I];
+ c.opaqueSortCompareFn = this._customOpaqueSortCompareFn[I], c.alphaTestSortCompareFn = this._customAlphaTestSortCompareFn[I], c.transparentSortCompareFn = this._customTransparentSortCompareFn[I];
+ }
+ }, u.prototype.setRenderingAutoClearDepthStencil = function(I, O, x, m) {
+ x === void 0 && (x = !0), m === void 0 && (m = !0), this._autoClearDepthStencil[I] = { autoClear: O, depth: x, stencil: m };
+ }, u.prototype.getAutoClearDepthStencilSetup = function(I) {
+ return this._autoClearDepthStencil[I];
+ }, u.MAX_RENDERINGGROUPS = 4, u.MIN_RENDERINGGROUPS = 0, u.AUTOCLEAR = !0, u;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return I;
+ });
+ var V = f(0), _ = f(7), C = f(82), u = f(72);
+ _.a.ExtrudeShape = function(O, x, m, c, T, S, E, g, l, h) {
+ E === void 0 && (E = null);
+ var v = { shape: x, path: m, scale: c, rotation: T, cap: S === 0 ? 0 : S || _.a.NO_CAP, sideOrientation: l, instance: h, updatable: g };
+ return I.ExtrudeShape(O, v, E);
+ }, _.a.ExtrudeShapeCustom = function(O, x, m, c, T, S, E, g, l, h, v, b) {
+ var D = { shape: x, path: m, scaleFunction: c, rotationFunction: T, ribbonCloseArray: S, ribbonClosePath: E, cap: g === 0 ? 0 : g || _.a.NO_CAP, sideOrientation: v, instance: b, updatable: h };
+ return I.ExtrudeShapeCustom(O, D, l);
+ };
+ var I = function() {
+ function O() {
+ }
+ return O.ExtrudeShape = function(x, m, c) {
+ c === void 0 && (c = null);
+ var T = m.path, S = m.shape, E = m.scale || 1, g = m.rotation || 0, l = m.cap === 0 ? 0 : m.cap || _.a.NO_CAP, h = m.updatable, v = _.a._GetDefaultSideOrientation(m.sideOrientation), b = m.instance || null, D = m.invertUV || !1;
+ return O._ExtrudeShapeGeneric(x, S, T, E, g, null, null, !1, !1, l, !1, c, !!h, v, b, D, m.frontUVs || null, m.backUVs || null);
+ }, O.ExtrudeShapeCustom = function(x, m, c) {
+ c === void 0 && (c = null);
+ var T = m.path, S = m.shape, E = m.scaleFunction || function() {
+ return 1;
+ }, g = m.rotationFunction || function() {
+ return 0;
+ }, l = m.ribbonCloseArray || !1, h = m.ribbonClosePath || !1, v = m.cap === 0 ? 0 : m.cap || _.a.NO_CAP, b = m.updatable, D = _.a._GetDefaultSideOrientation(m.sideOrientation), w = m.instance, N = m.invertUV || !1;
+ return O._ExtrudeShapeGeneric(x, S, T, null, null, E, g, l, h, v, !0, c, !!b, D, w || null, N, m.frontUVs || null, m.backUVs || null);
+ }, O._ExtrudeShapeGeneric = function(x, m, c, T, S, E, g, l, h, v, b, D, w, N, M, U, X, j) {
+ var ne, te, de = function(ee, K, $, L, G, Q, oe, re, Y, k) {
+ for (var H = $.getTangents(), Z = $.getNormals(), W = $.getBinormals(), q = $.getDistances(), he = 0, ge = k && re ? re : function() {
+ return Q !== null ? Q : 0;
+ }, me = k && oe ? oe : function() {
+ return G !== null ? G : 1;
+ }, _e = Y === _.a.NO_CAP || Y === _.a.CAP_END ? 0 : 2, ye = V.c.Matrix[0], Pe = 0; Pe < K.length; Pe++) {
+ for (var be = new Array(), Fe = ge(Pe, q[Pe]), ke = me(Pe, q[Pe]), We = 0; We < ee.length; We++) {
+ V.a.RotationAxisToRef(H[Pe], he, ye);
+ var je = H[Pe].scale(ee[We].z).add(Z[Pe].scale(ee[We].x)).add(W[Pe].scale(ee[We].y)), He = be[We] ? be[We] : V.e.Zero();
+ V.e.TransformCoordinatesToRef(je, ye, He), He.scaleInPlace(ke).addInPlace(K[Pe]), be[We] = He;
+ }
+ L[_e] = be, he += Fe, _e++;
+ }
+ var Qe = function(Ge) {
+ var tt, Je = Array(), st = V.e.Zero();
+ for (tt = 0; tt < Ge.length; tt++)
+ st.addInPlace(Ge[tt]);
+ for (st.scaleInPlace(1 / Ge.length), tt = 0; tt < Ge.length; tt++)
+ Je.push(st);
+ return Je;
+ };
+ switch (Y) {
+ case _.a.NO_CAP:
+ break;
+ case _.a.CAP_START:
+ L[0] = Qe(L[2]), L[1] = L[2];
+ break;
+ case _.a.CAP_END:
+ L[_e] = L[_e - 1], L[_e + 1] = Qe(L[_e - 1]);
+ break;
+ case _.a.CAP_ALL:
+ L[0] = Qe(L[2]), L[1] = L[2], L[_e] = L[_e - 1], L[_e + 1] = Qe(L[_e - 1]);
+ }
+ return L;
+ };
+ if (M) {
+ var pe = M._creationDataStorage;
+ return ne = pe.path3D.update(c), te = de(m, c, pe.path3D, pe.pathArray, T, S, E, g, pe.cap, b), M = _.a.CreateRibbon("", te, !1, !1, 0, D || void 0, !1, 0, M);
+ }
+ te = de(m, c, ne = new u.g(c), new Array(), T, S, E, g, v = v < 0 || v > 3 ? 0 : v, b);
+ var ae = C.a.CreateRibbon(x, { pathArray: te, closeArray: l, closePath: h, updatable: w, sideOrientation: N, invertUV: U, frontUVs: X || void 0, backUVs: j || void 0 }, D);
+ return ae._creationDataStorage.pathArray = te, ae._creationDataStorage.path3D = ne, ae._creationDataStorage.cap = v, ae;
+ }, O;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "b", function() {
+ return c;
+ }), f.d(A, "a", function() {
+ return T;
+ });
+ var V = f(1), _ = f(9), C = f(4), u = f(7), I = f(151), O = f(25), x = f(73), m = f(15), c = (f(166), f(167), function(S) {
+ function E(g, l, h, v, b, D, w) {
+ l === void 0 && (l = null), h === void 0 && (h = null), v === void 0 && (v = null);
+ var N = S.call(this, g, l, h, v, b) || this;
+ N.useVertexColor = D, N.useVertexAlpha = w, N.color = new _.a(1, 1, 1), N.alpha = 1, v && (N.color = v.color.clone(), N.alpha = v.alpha, N.useVertexColor = v.useVertexColor, N.useVertexAlpha = v.useVertexAlpha), N.intersectionThreshold = 0.1;
+ var M = { attributes: [C.b.PositionKind, "world0", "world1", "world2", "world3"], uniforms: ["vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "world", "viewProjection"], needAlphaBlending: !0, defines: [] };
+ return w === !1 && (M.needAlphaBlending = !1), D ? (M.defines.push("#define VERTEXCOLOR"), M.attributes.push(C.b.ColorKind)) : (M.uniforms.push("color"), N.color4 = new _.b()), N._colorShader = new x.a("colorShader", N.getScene(), "color", M), N;
+ }
+ return Object(V.d)(E, S), E.prototype._addClipPlaneDefine = function(g) {
+ var l = "#define " + g;
+ this._colorShader.options.defines.indexOf(l) === -1 && this._colorShader.options.defines.push(l);
+ }, E.prototype._removeClipPlaneDefine = function(g) {
+ var l = "#define " + g, h = this._colorShader.options.defines.indexOf(l);
+ h !== -1 && this._colorShader.options.defines.splice(h, 1);
+ }, E.prototype.isReady = function() {
+ var g = this.getScene();
+ return g.clipPlane ? this._addClipPlaneDefine("CLIPPLANE") : this._removeClipPlaneDefine("CLIPPLANE"), g.clipPlane2 ? this._addClipPlaneDefine("CLIPPLANE2") : this._removeClipPlaneDefine("CLIPPLANE2"), g.clipPlane3 ? this._addClipPlaneDefine("CLIPPLANE3") : this._removeClipPlaneDefine("CLIPPLANE3"), g.clipPlane4 ? this._addClipPlaneDefine("CLIPPLANE4") : this._removeClipPlaneDefine("CLIPPLANE4"), g.clipPlane5 ? this._addClipPlaneDefine("CLIPPLANE5") : this._removeClipPlaneDefine("CLIPPLANE5"), g.clipPlane6 ? this._addClipPlaneDefine("CLIPPLANE6") : this._removeClipPlaneDefine("CLIPPLANE6"), !!this._colorShader.isReady(this) && S.prototype.isReady.call(this);
+ }, E.prototype.getClassName = function() {
+ return "LinesMesh";
+ }, Object.defineProperty(E.prototype, "material", { get: function() {
+ return this._colorShader;
+ }, set: function(g) {
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(E.prototype, "checkCollisions", { get: function() {
+ return !1;
+ }, enumerable: !1, configurable: !0 }), E.prototype._bind = function(g, l, h) {
+ if (!this._geometry)
+ return this;
+ var v = this._colorShader.getEffect(), b = this.isUnIndexed ? null : this._geometry.getIndexBuffer();
+ if (this._geometry._bind(v, b), !this.useVertexColor) {
+ var D = this.color, w = D.r, N = D.g, M = D.b;
+ this.color4.set(w, N, M, this.alpha), this._colorShader.setColor4("color", this.color4);
+ }
+ return m.a.BindClipPlane(v, this.getScene()), this;
+ }, E.prototype._draw = function(g, l, h) {
+ if (!this._geometry || !this._geometry.getVertexBuffers() || !this._unIndexed && !this._geometry.getIndexBuffer())
+ return this;
+ var v = this.getScene().getEngine();
+ return this._unIndexed ? v.drawArraysType(O.a.LineListDrawMode, g.verticesStart, g.verticesCount, h) : v.drawElementsType(O.a.LineListDrawMode, g.indexStart, g.indexCount, h), this;
+ }, E.prototype.dispose = function(g) {
+ this._colorShader.dispose(!1, !1, !0), S.prototype.dispose.call(this, g);
+ }, E.prototype.clone = function(g, l, h) {
+ return l === void 0 && (l = null), new E(g, this.getScene(), l, this, h);
+ }, E.prototype.createInstance = function(g) {
+ return new T(g, this);
+ }, E;
+ }(u.a)), T = function(S) {
+ function E(g, l) {
+ var h = S.call(this, g, l) || this;
+ return h.intersectionThreshold = l.intersectionThreshold, h;
+ }
+ return Object(V.d)(E, S), E.prototype.getClassName = function() {
+ return "InstancedLinesMesh";
+ }, E;
+ }(I.a);
+ }, function(Be, A, f) {
+ f.r(A), f.d(A, "AxesViewer", function() {
+ return O;
+ }), f.d(A, "BoneAxesViewer", function() {
+ return c;
+ }), f.d(A, "DebugLayerTab", function() {
+ return V;
+ }), f.d(A, "DebugLayer", function() {
+ return l;
+ }), f.d(A, "PhysicsViewer", function() {
+ return U;
+ }), f.d(A, "RayHelper", function() {
+ return j;
+ }), f.d(A, "SkeletonViewer", function() {
+ return K;
+ });
+ var V, _ = f(0), C = f(30), u = f(75), I = f(9), O = function() {
+ function $(L, G, Q, oe, re, Y) {
+ if (G === void 0 && (G = 1), Q === void 0 && (Q = 2), this._scaleLinesFactor = 4, this._instanced = !1, this.scene = null, this.scaleLines = 1, this.scaleLines = G, !oe) {
+ var k = new C.a("", L);
+ k.disableLighting = !0, k.emissiveColor = I.a.Red().scale(0.5), oe = u.a._CreateArrow(L, k);
+ }
+ if (!re) {
+ var H = new C.a("", L);
+ H.disableLighting = !0, H.emissiveColor = I.a.Green().scale(0.5), re = u.a._CreateArrow(L, H);
+ }
+ if (!Y) {
+ var Z = new C.a("", L);
+ Z.disableLighting = !0, Z.emissiveColor = I.a.Blue().scale(0.5), Y = u.a._CreateArrow(L, Z);
+ }
+ this._xAxis = oe, this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor), this._yAxis = re, this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor), this._zAxis = Y, this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor), Q != null && ($._SetRenderingGroupId(this._xAxis, Q), $._SetRenderingGroupId(this._yAxis, Q), $._SetRenderingGroupId(this._zAxis, Q)), this.scene = L, this.update(new _.e(), _.e.Right(), _.e.Up(), _.e.Forward());
+ }
+ return Object.defineProperty($.prototype, "xAxis", { get: function() {
+ return this._xAxis;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty($.prototype, "yAxis", { get: function() {
+ return this._yAxis;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty($.prototype, "zAxis", { get: function() {
+ return this._zAxis;
+ }, enumerable: !1, configurable: !0 }), $.prototype.update = function(L, G, Q, oe) {
+ this._xAxis.position.copyFrom(L), this._xAxis.setDirection(G), this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor), this._yAxis.position.copyFrom(L), this._yAxis.setDirection(Q), this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor), this._zAxis.position.copyFrom(L), this._zAxis.setDirection(oe), this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
+ }, $.prototype.createInstance = function() {
+ var L = u.a._CreateArrowInstance(this.scene, this._xAxis), G = u.a._CreateArrowInstance(this.scene, this._yAxis), Q = u.a._CreateArrowInstance(this.scene, this._zAxis), oe = new $(this.scene, this.scaleLines, null, L, G, Q);
+ return oe._instanced = !0, oe;
+ }, $.prototype.dispose = function() {
+ this._xAxis && this._xAxis.dispose(!1, !this._instanced), this._yAxis && this._yAxis.dispose(!1, !this._instanced), this._zAxis && this._zAxis.dispose(!1, !this._instanced), this.scene = null;
+ }, $._SetRenderingGroupId = function(L, G) {
+ L.getChildMeshes().forEach(function(Q) {
+ Q.renderingGroupId = G;
+ });
+ }, $;
+ }(), x = f(1), m = f(23), c = function($) {
+ function L(G, Q, oe, re) {
+ re === void 0 && (re = 1);
+ var Y = $.call(this, G, re) || this;
+ return Y.pos = _.e.Zero(), Y.xaxis = _.e.Zero(), Y.yaxis = _.e.Zero(), Y.zaxis = _.e.Zero(), Y.mesh = oe, Y.bone = Q, Y;
+ }
+ return Object(x.d)(L, $), L.prototype.update = function() {
+ if (this.mesh && this.bone) {
+ var G = this.bone;
+ G._markAsDirtyAndCompose(), G.getAbsolutePositionToRef(this.mesh, this.pos), G.getDirectionToRef(m.a.X, this.mesh, this.xaxis), G.getDirectionToRef(m.a.Y, this.mesh, this.yaxis), G.getDirectionToRef(m.a.Z, this.mesh, this.zaxis), $.prototype.update.call(this, this.pos, this.xaxis, this.yaxis, this.zaxis);
+ }
+ }, L.prototype.dispose = function() {
+ this.mesh && (this.mesh = null, this.bone = null, $.prototype.dispose.call(this));
+ }, L;
+ }(O), T = f(12), S = f(6), E = f(20), g = f(13);
+ Object.defineProperty(E.a.prototype, "debugLayer", { get: function() {
+ return this._debugLayer || (this._debugLayer = new l(this)), this._debugLayer;
+ }, enumerable: !0, configurable: !0 }), function($) {
+ $[$.Properties = 0] = "Properties", $[$.Debug = 1] = "Debug", $[$.Statistics = 2] = "Statistics", $[$.Tools = 3] = "Tools", $[$.Settings = 4] = "Settings";
+ }(V || (V = {}));
+ var l = function() {
+ function $(L) {
+ var G = this;
+ this.BJSINSPECTOR = this._getGlobalInspector(), this._scene = L, this._scene.onDisposeObservable.add(function() {
+ G._scene._debugLayer && G._scene._debugLayer.hide();
+ });
+ }
+ return Object.defineProperty($.prototype, "onPropertyChangedObservable", { get: function() {
+ return this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector ? this.BJSINSPECTOR.Inspector.OnPropertyChangedObservable : (this._onPropertyChangedObservable || (this._onPropertyChangedObservable = new S.c()), this._onPropertyChangedObservable);
+ }, enumerable: !1, configurable: !0 }), $.prototype._createInspector = function(L) {
+ if (!this.isVisible()) {
+ if (this._onPropertyChangedObservable) {
+ for (var G = 0, Q = this._onPropertyChangedObservable.observers; G < Q.length; G++) {
+ var oe = Q[G];
+ this.BJSINSPECTOR.Inspector.OnPropertyChangedObservable.add(oe);
+ }
+ this._onPropertyChangedObservable.clear(), this._onPropertyChangedObservable = void 0;
+ }
+ var re = Object(x.a)({ overlay: !1, showExplorer: !0, showInspector: !0, embedMode: !1, handleResize: !0, enablePopup: !0 }, L);
+ this.BJSINSPECTOR = this.BJSINSPECTOR || this._getGlobalInspector(), this.BJSINSPECTOR.Inspector.Show(this._scene, re);
+ }
+ }, $.prototype.select = function(L, G) {
+ this.BJSINSPECTOR && (G && (Object.prototype.toString.call(G) == "[object String]" ? this.BJSINSPECTOR.Inspector.MarkLineContainerTitleForHighlighting(G) : this.BJSINSPECTOR.Inspector.MarkMultipleLineContainerTitlesForHighlighting(G)), this.BJSINSPECTOR.Inspector.OnSelectionChangeObservable.notifyObservers(L));
+ }, $.prototype._getGlobalInspector = function() {
+ return typeof INSPECTOR < "u" ? INSPECTOR : typeof BABYLON < "u" && BABYLON.Inspector !== void 0 ? BABYLON : void 0;
+ }, $.prototype.isVisible = function() {
+ return this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector.IsVisible;
+ }, $.prototype.hide = function() {
+ this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector.Hide();
+ }, $.prototype.setAsActiveScene = function() {
+ this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector._SetNewScene(this._scene);
+ }, $.prototype.show = function(L) {
+ var G = this;
+ return new Promise(function(Q, oe) {
+ if (G.BJSINSPECTOR === void 0) {
+ var re = L && L.inspectorURL ? L.inspectorURL : $.InspectorURL;
+ T.b.LoadScript(re, function() {
+ G._createInspector(L), Q(G);
+ });
+ } else
+ G._createInspector(L), Q(G);
+ });
+ }, $.InspectorURL = "https://unpkg.com/babylonjs-inspector@" + g.a.Version + "/babylon.inspector.bundle.js", $;
+ }(), h = f(7), v = f(63), b = f(45), D = f(22), w = f(32), N = f(36), M = f(53), U = function() {
+ function $(L) {
+ this._impostors = [], this._meshes = [], this._numMeshes = 0, this._debugMeshMeshes = new Array(), this._scene = L || D.a.LastCreatedScene;
+ var G = this._scene.getPhysicsEngine();
+ G && (this._physicsEnginePlugin = G.getPhysicsPlugin()), this._utilityLayer = new N.a(this._scene, !1), this._utilityLayer.pickUtilitySceneFirst = !1, this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = !0;
+ }
+ return $.prototype._updateDebugMeshes = function() {
+ for (var L = this._physicsEnginePlugin, G = 0; G < this._numMeshes; G++) {
+ var Q = this._impostors[G];
+ if (Q)
+ if (Q.isDisposed)
+ this.hideImpostor(this._impostors[G--]);
+ else {
+ if (Q.type === w.a.MeshImpostor)
+ continue;
+ var oe = this._meshes[G];
+ oe && L && L.syncMeshWithImpostor(oe, Q);
+ }
+ }
+ }, $.prototype.showImpostor = function(L, G) {
+ if (!this._scene)
+ return null;
+ for (var Q = 0; Q < this._numMeshes; Q++)
+ if (this._impostors[Q] == L)
+ return null;
+ var oe = this._getDebugMesh(L, G);
+ return oe && (this._impostors[this._numMeshes] = L, this._meshes[this._numMeshes] = oe, this._numMeshes === 0 && (this._renderFunction = this._updateDebugMeshes.bind(this), this._scene.registerBeforeRender(this._renderFunction)), this._numMeshes++), oe;
+ }, $.prototype.hideImpostor = function(L) {
+ if (L && this._scene && this._utilityLayer) {
+ for (var G = !1, Q = this._utilityLayer.utilityLayerScene, oe = 0; oe < this._numMeshes; oe++)
+ if (this._impostors[oe] == L) {
+ var re = this._meshes[oe];
+ if (!re)
+ continue;
+ Q.removeMesh(re), re.dispose();
+ var Y = this._debugMeshMeshes.indexOf(re);
+ Y > -1 && this._debugMeshMeshes.splice(Y, 1), this._numMeshes--, this._numMeshes > 0 ? (this._meshes[oe] = this._meshes[this._numMeshes], this._impostors[oe] = this._impostors[this._numMeshes], this._meshes[this._numMeshes] = null, this._impostors[this._numMeshes] = null) : (this._meshes[0] = null, this._impostors[0] = null), G = !0;
+ break;
+ }
+ G && this._numMeshes === 0 && this._scene.unregisterBeforeRender(this._renderFunction);
+ }
+ }, $.prototype._getDebugMaterial = function(L) {
+ return this._debugMaterial || (this._debugMaterial = new C.a("", L), this._debugMaterial.wireframe = !0, this._debugMaterial.emissiveColor = I.a.White(), this._debugMaterial.disableLighting = !0), this._debugMaterial;
+ }, $.prototype._getDebugBoxMesh = function(L) {
+ return this._debugBoxMesh || (this._debugBoxMesh = v.a.CreateBox("physicsBodyBoxViewMesh", { size: 1 }, L), this._debugBoxMesh.rotationQuaternion = _.b.Identity(), this._debugBoxMesh.material = this._getDebugMaterial(L), this._debugBoxMesh.setEnabled(!1)), this._debugBoxMesh.createInstance("physicsBodyBoxViewInstance");
+ }, $.prototype._getDebugSphereMesh = function(L) {
+ return this._debugSphereMesh || (this._debugSphereMesh = b.a.CreateSphere("physicsBodySphereViewMesh", { diameter: 1 }, L), this._debugSphereMesh.rotationQuaternion = _.b.Identity(), this._debugSphereMesh.material = this._getDebugMaterial(L), this._debugSphereMesh.setEnabled(!1)), this._debugSphereMesh.createInstance("physicsBodyBoxViewInstance");
+ }, $.prototype._getDebugCylinderMesh = function(L) {
+ return this._debugCylinderMesh || (this._debugCylinderMesh = M.a.CreateCylinder("physicsBodyCylinderViewMesh", { diameterTop: 1, diameterBottom: 1, height: 1 }, L), this._debugCylinderMesh.rotationQuaternion = _.b.Identity(), this._debugCylinderMesh.material = this._getDebugMaterial(L), this._debugCylinderMesh.setEnabled(!1)), this._debugCylinderMesh.createInstance("physicsBodyBoxViewInstance");
+ }, $.prototype._getDebugMeshMesh = function(L, G) {
+ var Q = new h.a(L.name, G, null, L);
+ return Q.position = _.e.Zero(), Q.setParent(L), Q.material = this._getDebugMaterial(G), this._debugMeshMeshes.push(Q), Q;
+ }, $.prototype._getDebugMesh = function(L, G) {
+ var Q = this;
+ if (!this._utilityLayer || G && G.parent && G.parent.physicsImpostor)
+ return null;
+ var oe = null, re = this._utilityLayer.utilityLayerScene;
+ switch (L.type) {
+ case w.a.BoxImpostor:
+ oe = this._getDebugBoxMesh(re), L.getBoxSizeToRef(oe.scaling);
+ break;
+ case w.a.SphereImpostor:
+ oe = this._getDebugSphereMesh(re);
+ var Y = L.getRadius();
+ oe.scaling.x = 2 * Y, oe.scaling.y = 2 * Y, oe.scaling.z = 2 * Y;
+ break;
+ case w.a.MeshImpostor:
+ G && (oe = this._getDebugMeshMesh(G, re));
+ break;
+ case w.a.NoImpostor:
+ G && G.getChildMeshes().filter(function(H) {
+ return H.physicsImpostor ? 1 : 0;
+ }).forEach(function(H) {
+ Q._getDebugBoxMesh(re).parent = H;
+ });
+ break;
+ case w.a.CylinderImpostor:
+ oe = this._getDebugCylinderMesh(re);
+ var k = L.object.getBoundingInfo();
+ oe.scaling.x = k.boundingBox.maximum.x - k.boundingBox.minimum.x, oe.scaling.y = k.boundingBox.maximum.y - k.boundingBox.minimum.y, oe.scaling.z = k.boundingBox.maximum.z - k.boundingBox.minimum.z;
+ }
+ return oe;
+ }, $.prototype.dispose = function() {
+ for (var L = this._numMeshes, G = 0; G < L; G++)
+ this.hideImpostor(this._impostors[0]);
+ this._debugBoxMesh && this._debugBoxMesh.dispose(), this._debugSphereMesh && this._debugSphereMesh.dispose(), this._debugCylinderMesh && this._debugCylinderMesh.dispose(), this._debugMaterial && this._debugMaterial.dispose(), this._impostors.length = 0, this._scene = null, this._physicsEnginePlugin = null, this._utilityLayer && (this._utilityLayer.dispose(), this._utilityLayer = null);
+ }, $;
+ }(), X = f(40), j = function() {
+ function $(L) {
+ this.ray = L;
+ }
+ return $.CreateAndShow = function(L, G, Q) {
+ var oe = new $(L);
+ return oe.show(G, Q), oe;
+ }, $.prototype.show = function(L, G) {
+ if (!this._renderFunction && this.ray) {
+ var Q = this.ray;
+ this._renderFunction = this._render.bind(this), this._scene = L, this._renderPoints = [Q.origin, Q.origin.add(Q.direction.scale(Q.length))], this._renderLine = h.a.CreateLines("ray", this._renderPoints, L, !0), this._renderLine.isPickable = !1, this._renderFunction && this._scene.registerBeforeRender(this._renderFunction);
+ }
+ G && this._renderLine && this._renderLine.color.copyFrom(G);
+ }, $.prototype.hide = function() {
+ this._renderFunction && this._scene && (this._scene.unregisterBeforeRender(this._renderFunction), this._scene = null, this._renderFunction = null, this._renderLine && (this._renderLine.dispose(), this._renderLine = null), this._renderPoints = []);
+ }, $.prototype._render = function() {
+ var L = this.ray;
+ if (L) {
+ var G = this._renderPoints[1], Q = Math.min(L.length, 1e6);
+ G.copyFrom(L.direction), G.scaleInPlace(Q), G.addInPlace(L.origin), this._renderPoints[0].copyFrom(L.origin), h.a.CreateLines("ray", this._renderPoints, this._scene, !0, this._renderLine);
+ }
+ }, $.prototype.attachToMesh = function(L, G, Q, oe) {
+ var re = this;
+ this._attachedToMesh = L;
+ var Y = this.ray;
+ Y && (Y.direction || (Y.direction = _.e.Zero()), Y.origin || (Y.origin = _.e.Zero()), oe && (Y.length = oe), Q || (Q = _.e.Zero()), G || (G = new _.e(0, 0, -1)), this._scene || (this._scene = L.getScene()), this._meshSpaceDirection ? (this._meshSpaceDirection.copyFrom(G), this._meshSpaceOrigin.copyFrom(Q)) : (this._meshSpaceDirection = G.clone(), this._meshSpaceOrigin = Q.clone()), this._onAfterRenderObserver || (this._onAfterRenderObserver = this._scene.onBeforeRenderObservable.add(function() {
+ return re._updateToMesh();
+ }), this._onAfterStepObserver = this._scene.onAfterStepObservable.add(function() {
+ return re._updateToMesh();
+ })), this._attachedToMesh.computeWorldMatrix(!0), this._updateToMesh());
+ }, $.prototype.detachFromMesh = function() {
+ this._attachedToMesh && this._scene && (this._onAfterRenderObserver && (this._scene.onBeforeRenderObservable.remove(this._onAfterRenderObserver), this._scene.onAfterStepObservable.remove(this._onAfterStepObserver)), this._attachedToMesh = null, this._onAfterRenderObserver = null, this._onAfterStepObserver = null, this._scene = null);
+ }, $.prototype._updateToMesh = function() {
+ var L = this.ray;
+ this._attachedToMesh && L && (this._attachedToMesh._isDisposed ? this.detachFromMesh() : (this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection, L.direction), _.e.TransformCoordinatesToRef(this._meshSpaceOrigin, this._attachedToMesh.getWorldMatrix(), L.origin)));
+ }, $.prototype.dispose = function() {
+ this.hide(), this.detachFromMesh(), this.ray = null;
+ }, $;
+ }(), ne = f(25), te = f(73), de = f(62), pe = f(4), ae = f(5), ee = f(97), K = function() {
+ function $(L, G, Q, oe, re, Y) {
+ var k, H, Z, W, q, he, ge, me, _e, ye, Pe, be, Fe, ke;
+ oe === void 0 && (oe = !0), re === void 0 && (re = 3), Y === void 0 && (Y = {}), this.skeleton = L, this.mesh = G, this.autoUpdateBonesMatrices = oe, this.renderingGroupId = re, this.options = Y, this.color = I.a.White(), this._debugLines = new Array(), this._localAxes = null, this._isEnabled = !1, this._obs = null, this._scene = Q, this._ready = !1, Y.pauseAnimations = (k = Y.pauseAnimations) === null || k === void 0 || k, Y.returnToRest = (H = Y.returnToRest) !== null && H !== void 0 && H, Y.displayMode = (Z = Y.displayMode) !== null && Z !== void 0 ? Z : $.DISPLAY_LINES, Y.displayOptions = (W = Y.displayOptions) !== null && W !== void 0 ? W : {}, Y.displayOptions.midStep = (q = Y.displayOptions.midStep) !== null && q !== void 0 ? q : 0.235, Y.displayOptions.midStepFactor = (he = Y.displayOptions.midStepFactor) !== null && he !== void 0 ? he : 0.155, Y.displayOptions.sphereBaseSize = (ge = Y.displayOptions.sphereBaseSize) !== null && ge !== void 0 ? ge : 0.15, Y.displayOptions.sphereScaleUnit = (me = Y.displayOptions.sphereScaleUnit) !== null && me !== void 0 ? me : 2, Y.displayOptions.sphereFactor = (_e = Y.displayOptions.sphereFactor) !== null && _e !== void 0 ? _e : 0.865, Y.displayOptions.spurFollowsChild = (ye = Y.displayOptions.spurFollowsChild) !== null && ye !== void 0 && ye, Y.displayOptions.showLocalAxes = (Pe = Y.displayOptions.showLocalAxes) !== null && Pe !== void 0 && Pe, Y.displayOptions.localAxesSize = (be = Y.displayOptions.localAxesSize) !== null && be !== void 0 ? be : 0.075, Y.computeBonesUsingShaders = (Fe = Y.computeBonesUsingShaders) === null || Fe === void 0 || Fe, Y.useAllBones = (ke = Y.useAllBones) === null || ke === void 0 || ke;
+ var We = G.getVerticesData(pe.b.MatricesIndicesKind), je = G.getVerticesData(pe.b.MatricesWeightsKind);
+ if (this._boneIndices = /* @__PURE__ */ new Set(), !Y.useAllBones && We && je)
+ for (var He = 0; He < We.length; ++He) {
+ var Qe = We[He];
+ je[He] !== 0 && this._boneIndices.add(Qe);
+ }
+ this._utilityLayer = new N.a(this._scene, !1), this._utilityLayer.pickUtilitySceneFirst = !1, this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = !0;
+ var Ge = this.options.displayMode || 0;
+ Ge > $.DISPLAY_SPHERE_AND_SPURS && (Ge = $.DISPLAY_LINES), this.displayMode = Ge, this.update(), this._bindObs();
+ }
+ return $.CreateBoneWeightShader = function(L, G) {
+ var Q, oe, re, Y, k, H, Z = L.skeleton, W = (Q = L.colorBase) !== null && Q !== void 0 ? Q : I.a.Black(), q = (oe = L.colorZero) !== null && oe !== void 0 ? oe : I.a.Blue(), he = (re = L.colorQuarter) !== null && re !== void 0 ? re : I.a.Green(), ge = (Y = L.colorHalf) !== null && Y !== void 0 ? Y : I.a.Yellow(), me = (k = L.colorFull) !== null && k !== void 0 ? k : I.a.Red(), _e = (H = L.targetBoneIndex) !== null && H !== void 0 ? H : 0;
+ ae.a.ShadersStore["boneWeights:" + Z.name + "VertexShader"] = `precision highp float;
+
+ attribute vec3 position;
+ attribute vec2 uv;
+
+ uniform mat4 view;
+ uniform mat4 projection;
+ uniform mat4 worldViewProjection;
+
+ #include
+ #if NUM_BONE_INFLUENCERS == 0
+ attribute vec4 matricesIndices;
+ attribute vec4 matricesWeights;
+ #endif
+
+ #include
+
+ varying vec3 vColor;
+
+ uniform vec3 colorBase;
+ uniform vec3 colorZero;
+ uniform vec3 colorQuarter;
+ uniform vec3 colorHalf;
+ uniform vec3 colorFull;
+
+ uniform float targetBoneIndex;
+
+ void main() {
+ vec3 positionUpdated = position;
+
+ #include
+ #include
+
+ vec4 worldPos = finalWorld * vec4(positionUpdated, 1.0);
+
+ vec3 color = colorBase;
+ float totalWeight = 0.;
+ if(matricesIndices[0] == targetBoneIndex && matricesWeights[0] > 0.){
+ totalWeight += matricesWeights[0];
+ }
+ if(matricesIndices[1] == targetBoneIndex && matricesWeights[1] > 0.){
+ totalWeight += matricesWeights[1];
+ }
+ if(matricesIndices[2] == targetBoneIndex && matricesWeights[2] > 0.){
+ totalWeight += matricesWeights[2];
+ }
+ if(matricesIndices[3] == targetBoneIndex && matricesWeights[3] > 0.){
+ totalWeight += matricesWeights[3];
+ }
+
+ color = mix(color, colorZero, smoothstep(0., 0.25, totalWeight));
+ color = mix(color, colorQuarter, smoothstep(0.25, 0.5, totalWeight));
+ color = mix(color, colorHalf, smoothstep(0.5, 0.75, totalWeight));
+ color = mix(color, colorFull, smoothstep(0.75, 1.0, totalWeight));
+ vColor = color;
+
+ gl_Position = projection * view * worldPos;
+ }`, ae.a.ShadersStore["boneWeights:" + Z.name + "FragmentShader"] = `
+ precision highp float;
+ varying vec3 vPosition;
+
+ varying vec3 vColor;
+
+ void main() {
+ vec4 color = vec4(vColor, 1.0);
+ gl_FragColor = color;
+ }
+ `;
+ var ye = new te.a("boneWeight:" + Z.name, G, { vertex: "boneWeights:" + Z.name, fragment: "boneWeights:" + Z.name }, { attributes: ["position", "normal", "matricesIndices", "matricesWeights"], uniforms: ["world", "worldView", "worldViewProjection", "view", "projection", "viewProjection", "colorBase", "colorZero", "colorQuarter", "colorHalf", "colorFull", "targetBoneIndex"] });
+ return ye.setColor3("colorBase", W), ye.setColor3("colorZero", q), ye.setColor3("colorQuarter", he), ye.setColor3("colorHalf", ge), ye.setColor3("colorFull", me), ye.setFloat("targetBoneIndex", _e), ye.getClassName = function() {
+ return "BoneWeightShader";
+ }, ye.transparencyMode = ne.a.MATERIAL_OPAQUE, ye;
+ }, $.CreateSkeletonMapShader = function(L, G) {
+ var Q, oe = L.skeleton, re = (Q = L.colorMap) !== null && Q !== void 0 ? Q : [{ color: new I.a(1, 0.38, 0.18), location: 0 }, { color: new I.a(0.59, 0.18, 1), location: 0.2 }, { color: new I.a(0.59, 1, 0.18), location: 0.4 }, { color: new I.a(1, 0.87, 0.17), location: 0.6 }, { color: new I.a(1, 0.17, 0.42), location: 0.8 }, { color: new I.a(0.17, 0.68, 1), location: 1 }], Y = oe.bones.length + 1, k = $._CreateBoneMapColorBuffer(Y, re, G), H = new te.a("boneWeights:" + oe.name, G, { vertexSource: `precision highp float;
+
+ attribute vec3 position;
+ attribute vec2 uv;
+
+ uniform mat4 view;
+ uniform mat4 projection;
+ uniform mat4 worldViewProjection;
+ uniform float colorMap[` + 4 * oe.bones.length + `];
+
+ #include
+ #if NUM_BONE_INFLUENCERS == 0
+ attribute vec4 matricesIndices;
+ attribute vec4 matricesWeights;
+ #endif
+ #include
+
+ varying vec3 vColor;
+
+ void main() {
+ vec3 positionUpdated = position;
+
+ #include
+ #include
+
+ vec3 color = vec3(0.);
+ bool first = true;
+
+ for (int i = 0; i < 4; i++) {
+ int boneIdx = int(matricesIndices[i]);
+ float boneWgt = matricesWeights[i];
+
+ vec3 c = vec3(colorMap[boneIdx * 4 + 0], colorMap[boneIdx * 4 + 1], colorMap[boneIdx * 4 + 2]);
+
+ if (boneWgt > 0.) {
+ if (first) {
+ first = false;
+ color = c;
+ } else {
+ color = mix(color, c, boneWgt);
+ }
+ }
+ }
+
+ vColor = color;
+
+ vec4 worldPos = finalWorld * vec4(positionUpdated, 1.0);
+
+ gl_Position = projection * view * worldPos;
+ }`, fragmentSource: `
+ precision highp float;
+ varying vec3 vColor;
+
+ void main() {
+ vec4 color = vec4( vColor, 1.0 );
+ gl_FragColor = color;
+ }
+ ` }, { attributes: ["position", "normal", "matricesIndices", "matricesWeights"], uniforms: ["world", "worldView", "worldViewProjection", "view", "projection", "viewProjection", "colorMap"] });
+ return H.setFloats("colorMap", k), H.getClassName = function() {
+ return "SkeletonMapShader";
+ }, H.transparencyMode = ne.a.MATERIAL_OPAQUE, H;
+ }, $._CreateBoneMapColorBuffer = function(L, G, Q) {
+ var oe = new de.a("temp", { width: L, height: 1 }, Q, !1), re = oe.getContext(), Y = re.createLinearGradient(0, 0, L, 0);
+ G.forEach(function(W) {
+ Y.addColorStop(W.location, W.color.toHexString());
+ }), re.fillStyle = Y, re.fillRect(0, 0, L, 1), oe.update();
+ for (var k = [], H = re.getImageData(0, 0, L, 1).data, Z = 0; Z < H.length; Z++)
+ k.push(H[Z] * (1 / 255));
+ return oe.dispose(), k;
+ }, Object.defineProperty($.prototype, "scene", { get: function() {
+ return this._scene;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty($.prototype, "utilityLayer", { get: function() {
+ return this._utilityLayer;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty($.prototype, "isReady", { get: function() {
+ return this._ready;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty($.prototype, "ready", { set: function(L) {
+ this._ready = L;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty($.prototype, "debugMesh", { get: function() {
+ return this._debugMesh;
+ }, set: function(L) {
+ this._debugMesh = L;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty($.prototype, "displayMode", { get: function() {
+ return this.options.displayMode || $.DISPLAY_LINES;
+ }, set: function(L) {
+ L > $.DISPLAY_SPHERE_AND_SPURS && (L = $.DISPLAY_LINES), this.options.displayMode = L;
+ }, enumerable: !1, configurable: !0 }), $.prototype._bindObs = function() {
+ var L = this;
+ switch (this.displayMode) {
+ case $.DISPLAY_LINES:
+ this._obs = this.scene.onBeforeRenderObservable.add(function() {
+ L._displayLinesUpdate();
+ });
+ }
+ }, $.prototype.update = function() {
+ switch (this.displayMode) {
+ case $.DISPLAY_LINES:
+ this._displayLinesUpdate();
+ break;
+ case $.DISPLAY_SPHERES:
+ this._buildSpheresAndSpurs(!0);
+ break;
+ case $.DISPLAY_SPHERE_AND_SPURS:
+ this._buildSpheresAndSpurs(!1);
+ }
+ this._buildLocalAxes();
+ }, Object.defineProperty($.prototype, "isEnabled", { get: function() {
+ return this._isEnabled;
+ }, set: function(L) {
+ this.isEnabled !== L && (this._isEnabled = L, this.debugMesh && this.debugMesh.setEnabled(L), L && !this._obs ? this._bindObs() : !L && this._obs && (this.scene.onBeforeRenderObservable.remove(this._obs), this._obs = null));
+ }, enumerable: !1, configurable: !0 }), $.prototype._getBonePosition = function(L, G, Q, oe, re, Y) {
+ oe === void 0 && (oe = 0), re === void 0 && (re = 0), Y === void 0 && (Y = 0);
+ var k = _.c.Matrix[0], H = G.getParent();
+ if (k.copyFrom(G.getLocalMatrix()), oe !== 0 || re !== 0 || Y !== 0) {
+ var Z = _.c.Matrix[1];
+ _.a.IdentityToRef(Z), Z.setTranslationFromFloats(oe, re, Y), Z.multiplyToRef(k, k);
+ }
+ H && k.multiplyToRef(H.getAbsoluteTransform(), k), k.multiplyToRef(Q, k), L.x = k.m[12], L.y = k.m[13], L.z = k.m[14];
+ }, $.prototype._getLinesForBonesWithLength = function(L, G) {
+ for (var Q = L.length, oe = this.mesh._effectiveMesh.position, re = 0, Y = 0; Y < Q; Y++) {
+ var k = L[Y], H = this._debugLines[re];
+ k._index !== -1 && (this._boneIndices.has(k.getIndex()) || this.options.useAllBones) && (H || (H = [_.e.Zero(), _.e.Zero()], this._debugLines[re] = H), this._getBonePosition(H[0], k, G), this._getBonePosition(H[1], k, G, 0, k.length, 0), H[0].subtractInPlace(oe), H[1].subtractInPlace(oe), re++);
+ }
+ }, $.prototype._getLinesForBonesNoLength = function(L) {
+ for (var G = L.length, Q = 0, oe = this.mesh._effectiveMesh, re = oe.position, Y = G - 1; Y >= 0; Y--) {
+ var k = L[Y], H = k.getParent();
+ if (H && (this._boneIndices.has(k.getIndex()) || this.options.useAllBones)) {
+ var Z = this._debugLines[Q];
+ Z || (Z = [_.e.Zero(), _.e.Zero()], this._debugLines[Q] = Z), k.getAbsolutePositionToRef(oe, Z[0]), H.getAbsolutePositionToRef(oe, Z[1]), Z[0].subtractInPlace(re), Z[1].subtractInPlace(re), Q++;
+ }
+ }
+ }, $.prototype._revert = function(L) {
+ this.options.pauseAnimations && (this.scene.animationsEnabled = L, this.utilityLayer.utilityLayerScene.animationsEnabled = L);
+ }, $.prototype._getAbsoluteBindPoseToRef = function(L, G) {
+ L !== null && L._index !== -1 ? (this._getAbsoluteBindPoseToRef(L.getParent(), G), L.getBindPose().multiplyToRef(G, G)) : G.copyFrom(_.a.Identity());
+ }, $.prototype._buildSpheresAndSpurs = function(L) {
+ var G, Q;
+ L === void 0 && (L = !0), this._debugMesh && (this._debugMesh.dispose(), this._debugMesh = null, this.ready = !1), this._ready = !1;
+ var oe = (G = this.utilityLayer) === null || G === void 0 ? void 0 : G.utilityLayerScene, re = this.skeleton.bones, Y = [], k = [], H = this.scene.animationsEnabled;
+ try {
+ this.options.pauseAnimations && (this.scene.animationsEnabled = !1, oe.animationsEnabled = !1), this.options.returnToRest && this.skeleton.returnToRest(), this.autoUpdateBonesMatrices && this.skeleton.computeAbsoluteTransforms();
+ for (var Z = Number.NEGATIVE_INFINITY, W = this.options.displayOptions || {}, q = function(He) {
+ var Qe = re[He];
+ if (Qe._index === -1 || !he._boneIndices.has(Qe.getIndex()) && !he.options.useAllBones)
+ return "continue";
+ var Ge = new _.a();
+ he._getAbsoluteBindPoseToRef(Qe, Ge);
+ var tt = new _.e();
+ Ge.decompose(void 0, void 0, tt), Qe.children.forEach(function(Ot, St) {
+ var Ct = new _.a();
+ Ot.getBindPose().multiplyToRef(Ge, Ct);
+ var nn = new _.e();
+ Ct.decompose(void 0, void 0, nn);
+ var Qt = _.e.Distance(tt, nn);
+ if (Qt > Z && (Z = Qt), !L) {
+ for (var $t = nn.clone().subtract(tt.clone()), Ie = $t.length(), Sn = $t.normalize().scale(Ie), en = W.midStep || 0.165, An = W.midStepFactor || 0.215, Ue = Sn.scale(en), Pn = ee.a.ExtrudeShapeCustom("skeletonViewer", { shape: [new _.e(1, -1, 0), new _.e(1, 1, 0), new _.e(-1, 1, 0), new _.e(-1, -1, 0), new _.e(1, -1, 0)], path: [_.e.Zero(), Ue, Sn], scaleFunction: function(So) {
+ switch (So) {
+ case 0:
+ case 2:
+ return 0;
+ case 1:
+ return Ie * An;
+ }
+ return 0;
+ }, sideOrientation: h.a.DEFAULTSIDE, updatable: !1 }, oe), rr = Pn.getTotalVertices(), Xe = [], En = [], Qn = 0; Qn < rr; Qn++)
+ Xe.push(1, 0, 0, 0), W.spurFollowsChild && Qn > 9 ? En.push(Ot.getIndex(), 0, 0, 0) : En.push(Qe.getIndex(), 0, 0, 0);
+ Pn.position = tt.clone(), Pn.setVerticesData(pe.b.MatricesWeightsKind, Xe, !1), Pn.setVerticesData(pe.b.MatricesIndicesKind, En, !1), Pn.convertToFlatShadedMesh(), k.push(Pn);
+ }
+ });
+ for (var Je = W.sphereBaseSize || 0.2, st = b.a.CreateSphere("skeletonViewer", { segments: 6, diameter: Je, updatable: !0 }, oe), at = st.getTotalVertices(), pt = [], Tt = [], Lt = 0; Lt < at; Lt++)
+ pt.push(1, 0, 0, 0), Tt.push(Qe.getIndex(), 0, 0, 0);
+ st.setVerticesData(pe.b.MatricesWeightsKind, pt, !1), st.setVerticesData(pe.b.MatricesIndicesKind, Tt, !1), st.position = tt.clone(), Y.push([st, Qe]);
+ }, he = this, ge = 0; ge < re.length; ge++)
+ q(ge);
+ var me = W.sphereScaleUnit || 2, _e = W.sphereFactor || 0.85, ye = [];
+ for (ge = 0; ge < Y.length; ge++) {
+ for (var Pe = Y[ge], be = Pe[0], Fe = Pe[1], ke = 1 / (me / Z), We = 0, je = Fe; je.getParent() && je.getParent().getIndex() !== -1; )
+ We++, je = je.getParent();
+ be.scaling.scaleInPlace(ke * Math.pow(_e, We)), ye.push(be);
+ }
+ this.debugMesh = h.a.MergeMeshes(ye.concat(k), !0, !0), this.debugMesh && (this.debugMesh.renderingGroupId = this.renderingGroupId, this.debugMesh.skeleton = this.skeleton, this.debugMesh.parent = this.mesh, this.debugMesh.computeBonesUsingShaders = (Q = this.options.computeBonesUsingShaders) === null || Q === void 0 || Q, this.debugMesh.alwaysSelectAsActiveMesh = !0), this.utilityLayer._getSharedGizmoLight().intensity = 0.7, this._revert(H), this.ready = !0;
+ } catch (He) {
+ console.error(He), this._revert(H), this.dispose();
+ }
+ }, $.prototype._buildLocalAxes = function() {
+ var L;
+ this._localAxes && this._localAxes.dispose(), this._localAxes = null;
+ var G = this.options.displayOptions || {};
+ if (G.showLocalAxes) {
+ var Q = this._utilityLayer.utilityLayerScene, oe = G.localAxesSize || 0.075, re = [], Y = [], k = new I.b(1, 0, 0, 1), H = new I.b(0, 1, 0, 1), Z = new I.b(0, 0, 1, 1), W = [], q = [];
+ for (var he in this.skeleton.bones) {
+ var ge = this.skeleton.bones[he];
+ if (ge._index !== -1 && (this._boneIndices.has(ge.getIndex()) || this.options.useAllBones)) {
+ var me = new _.a(), _e = new _.e();
+ this._getAbsoluteBindPoseToRef(ge, me), me.decompose(void 0, void 0, _e);
+ var ye = ge.getBindPose().getRotationMatrix(), Pe = _.e.TransformCoordinates(new _.e(0 + oe, 0, 0), ye), be = _.e.TransformCoordinates(new _.e(0, 0 + oe, 0), ye), Fe = _.e.TransformCoordinates(new _.e(0, 0, 0 + oe), ye), ke = [[_e, _e.add(Pe)], [_e, _e.add(be)], [_e, _e.add(Fe)]], We = [[k, k], [H, H], [Z, Z]];
+ re.push.apply(re, ke), Y.push.apply(Y, We);
+ for (var je = 0; je < 6; je++)
+ W.push(1, 0, 0, 0), q.push(ge.getIndex(), 0, 0, 0);
+ }
+ }
+ this._localAxes = X.a.CreateLineSystem("localAxes", { lines: re, colors: Y, updatable: !0 }, Q), this._localAxes.setVerticesData(pe.b.MatricesWeightsKind, W, !1), this._localAxes.setVerticesData(pe.b.MatricesIndicesKind, q, !1), this._localAxes.skeleton = this.skeleton, this._localAxes.renderingGroupId = this.renderingGroupId, this._localAxes.parent = this.mesh, this._localAxes.computeBonesUsingShaders = (L = this.options.computeBonesUsingShaders) === null || L === void 0 || L;
+ }
+ }, $.prototype._displayLinesUpdate = function() {
+ if (this._utilityLayer) {
+ this.autoUpdateBonesMatrices && this.skeleton.computeAbsoluteTransforms();
+ var L = this.mesh._effectiveMesh;
+ this.skeleton.bones[0].length === void 0 ? this._getLinesForBonesNoLength(this.skeleton.bones) : this._getLinesForBonesWithLength(this.skeleton.bones, L.getWorldMatrix());
+ var G = this._utilityLayer.utilityLayerScene;
+ G && (this._debugMesh ? X.a.CreateLineSystem("", { lines: this._debugLines, updatable: !0, instance: this._debugMesh }, G) : (this._debugMesh = X.a.CreateLineSystem("", { lines: this._debugLines, updatable: !0, instance: null }, G), this._debugMesh.renderingGroupId = this.renderingGroupId), this._debugMesh.position.copyFrom(this.mesh.position), this._debugMesh.color = this.color);
+ }
+ }, $.prototype.changeDisplayMode = function(L) {
+ var G = !!this.isEnabled;
+ this.displayMode !== L && (this.isEnabled = !1, this._debugMesh && (this._debugMesh.dispose(), this._debugMesh = null, this.ready = !1), this.displayMode = L, this.update(), this._bindObs(), this.isEnabled = G);
+ }, $.prototype.changeDisplayOptions = function(L, G) {
+ var Q = !!this.isEnabled;
+ this.options.displayOptions[L] = G, this.isEnabled = !1, this._debugMesh && (this._debugMesh.dispose(), this._debugMesh = null, this.ready = !1), this.update(), this._bindObs(), this.isEnabled = Q;
+ }, $.prototype.dispose = function() {
+ this.isEnabled = !1, this._debugMesh && (this._debugMesh.dispose(), this._debugMesh = null), this._utilityLayer && (this._utilityLayer.dispose(), this._utilityLayer = null), this.ready = !1;
+ }, $.DISPLAY_LINES = 0, $.DISPLAY_SPHERES = 1, $.DISPLAY_SPHERE_AND_SPURS = 2, $;
+ }();
+ }, function(Be, A, f) {
+ var V = "morphTargetsVertex", _ = `#ifdef MORPHTARGETS
+positionUpdated+=(position{X}-position)*morphTargetInfluences[{X}];
+#ifdef MORPHTARGETS_NORMAL
+normalUpdated+=(normal{X}-normal)*morphTargetInfluences[{X}];
+#endif
+#ifdef MORPHTARGETS_TANGENT
+tangentUpdated.xyz+=(tangent{X}-tangent.xyz)*morphTargetInfluences[{X}];
+#endif
+#ifdef MORPHTARGETS_UV
+uvUpdated+=(uv_{X}-uv)*morphTargetInfluences[{X}];
+#endif
+#endif`;
+ f(5).a.IncludesShadersStore[V] = _;
+ }, function(Be, A, f) {
+ f.d(A, "b", function() {
+ return _;
+ }), f.d(A, "a", function() {
+ return C;
+ });
+ var V = f(0);
+ function _(u, I, O, x, m) {
+ m === void 0 && (m = null);
+ for (var c = new V.e(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), T = new V.e(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE), S = O; S < O + x; S++) {
+ var E = 3 * I[S], g = u[E], l = u[E + 1], h = u[E + 2];
+ c.minimizeInPlaceFromFloats(g, l, h), T.maximizeInPlaceFromFloats(g, l, h);
+ }
+ return m && (c.x -= c.x * m.x + m.y, c.y -= c.y * m.x + m.y, c.z -= c.z * m.x + m.y, T.x += T.x * m.x + m.y, T.y += T.y * m.x + m.y, T.z += T.z * m.x + m.y), { minimum: c, maximum: T };
+ }
+ function C(u, I, O, x, m) {
+ x === void 0 && (x = null);
+ var c = new V.e(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), T = new V.e(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
+ m || (m = 3);
+ for (var S = I, E = I * m; S < I + O; S++, E += m) {
+ var g = u[E], l = u[E + 1], h = u[E + 2];
+ c.minimizeInPlaceFromFloats(g, l, h), T.maximizeInPlaceFromFloats(g, l, h);
+ }
+ return x && (c.x -= c.x * x.x + x.y, c.y -= c.y * x.x + x.y, c.z -= c.z * x.x + x.y, T.x += T.x * x.x + x.y, T.y += T.y * x.x + x.y, T.z += T.z * x.x + x.y), { minimum: c, maximum: T };
+ }
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return V;
+ });
+ var V = function() {
+ };
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return u;
+ });
+ var V = f(44), _ = f(0), C = f(28), u = function() {
+ function I(O, x, m) {
+ this.vectors = V.a.BuildArray(8, _.e.Zero), this.center = _.e.Zero(), this.centerWorld = _.e.Zero(), this.extendSize = _.e.Zero(), this.extendSizeWorld = _.e.Zero(), this.directions = V.a.BuildArray(3, _.e.Zero), this.vectorsWorld = V.a.BuildArray(8, _.e.Zero), this.minimumWorld = _.e.Zero(), this.maximumWorld = _.e.Zero(), this.minimum = _.e.Zero(), this.maximum = _.e.Zero(), this.reConstruct(O, x, m);
+ }
+ return I.prototype.reConstruct = function(O, x, m) {
+ var c = O.x, T = O.y, S = O.z, E = x.x, g = x.y, l = x.z, h = this.vectors;
+ this.minimum.copyFromFloats(c, T, S), this.maximum.copyFromFloats(E, g, l), h[0].copyFromFloats(c, T, S), h[1].copyFromFloats(E, g, l), h[2].copyFromFloats(E, T, S), h[3].copyFromFloats(c, g, S), h[4].copyFromFloats(c, T, l), h[5].copyFromFloats(E, g, S), h[6].copyFromFloats(c, g, l), h[7].copyFromFloats(E, T, l), x.addToRef(O, this.center).scaleInPlace(0.5), x.subtractToRef(O, this.extendSize).scaleInPlace(0.5), this._worldMatrix = m || _.a.IdentityReadOnly, this._update(this._worldMatrix);
+ }, I.prototype.scale = function(O) {
+ var x = I.TmpVector3, m = this.maximum.subtractToRef(this.minimum, x[0]), c = m.length();
+ m.normalizeFromLength(c);
+ var T = c * O, S = m.scaleInPlace(0.5 * T), E = this.center.subtractToRef(S, x[1]), g = this.center.addToRef(S, x[2]);
+ return this.reConstruct(E, g, this._worldMatrix), this;
+ }, I.prototype.getWorldMatrix = function() {
+ return this._worldMatrix;
+ }, I.prototype._update = function(O) {
+ var x = this.minimumWorld, m = this.maximumWorld, c = this.directions, T = this.vectorsWorld, S = this.vectors;
+ if (O.isIdentity()) {
+ for (x.copyFrom(this.minimum), m.copyFrom(this.maximum), E = 0; E < 8; ++E)
+ T[E].copyFrom(S[E]);
+ this.extendSizeWorld.copyFrom(this.extendSize), this.centerWorld.copyFrom(this.center);
+ } else {
+ x.setAll(Number.MAX_VALUE), m.setAll(-Number.MAX_VALUE);
+ for (var E = 0; E < 8; ++E) {
+ var g = T[E];
+ _.e.TransformCoordinatesToRef(S[E], O, g), x.minimizeInPlace(g), m.maximizeInPlace(g);
+ }
+ m.subtractToRef(x, this.extendSizeWorld).scaleInPlace(0.5), m.addToRef(x, this.centerWorld).scaleInPlace(0.5);
+ }
+ _.e.FromArrayToRef(O.m, 0, c[0]), _.e.FromArrayToRef(O.m, 4, c[1]), _.e.FromArrayToRef(O.m, 8, c[2]), this._worldMatrix = O;
+ }, I.prototype.isInFrustum = function(O) {
+ return I.IsInFrustum(this.vectorsWorld, O);
+ }, I.prototype.isCompletelyInFrustum = function(O) {
+ return I.IsCompletelyInFrustum(this.vectorsWorld, O);
+ }, I.prototype.intersectsPoint = function(O) {
+ var x = this.minimumWorld, m = this.maximumWorld, c = x.x, T = x.y, S = x.z, E = m.x, g = m.y, l = m.z, h = O.x, v = O.y, b = O.z, D = -C.a;
+ return !(E - h < D || D > h - c) && !(g - v < D || D > v - T) && !(l - b < D || D > b - S);
+ }, I.prototype.intersectsSphere = function(O) {
+ return I.IntersectsSphere(this.minimumWorld, this.maximumWorld, O.centerWorld, O.radiusWorld);
+ }, I.prototype.intersectsMinMax = function(O, x) {
+ var m = this.minimumWorld, c = this.maximumWorld, T = m.x, S = m.y, E = m.z, g = c.x, l = c.y, h = c.z, v = O.x, b = O.y, D = O.z, w = x.x, N = x.y, M = x.z;
+ return !(g < v || T > w) && !(l < b || S > N) && !(h < D || E > M);
+ }, I.Intersects = function(O, x) {
+ return O.intersectsMinMax(x.minimumWorld, x.maximumWorld);
+ }, I.IntersectsSphere = function(O, x, m, c) {
+ var T = I.TmpVector3[0];
+ return _.e.ClampToRef(m, O, x, T), _.e.DistanceSquared(m, T) <= c * c;
+ }, I.IsCompletelyInFrustum = function(O, x) {
+ for (var m = 0; m < 6; ++m)
+ for (var c = x[m], T = 0; T < 8; ++T)
+ if (c.dotCoordinate(O[T]) < 0)
+ return !1;
+ return !0;
+ }, I.IsInFrustum = function(O, x) {
+ for (var m = 0; m < 6; ++m) {
+ for (var c = !0, T = x[m], S = 0; S < 8; ++S)
+ if (T.dotCoordinate(O[S]) >= 0) {
+ c = !1;
+ break;
+ }
+ if (c)
+ return !1;
+ }
+ return !0;
+ }, I.TmpVector3 = V.a.BuildArray(3, _.e.Zero), I;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return _;
+ });
+ var V = f(38), _ = function() {
+ function C() {
+ }
+ return C.SetImmediate = function(u) {
+ V.a.IsWindowObjectExist() && window.setImmediate ? window.setImmediate(u) : setTimeout(u, 1);
+ }, C;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return C;
+ });
+ var V = f(0), _ = f(2), C = function() {
+ function u() {
+ this.previousWorldMatrices = {}, this.previousBones = {};
+ }
+ return u.AddUniforms = function(I) {
+ I.push("previousWorld", "previousViewProjection");
+ }, u.AddSamplers = function(I) {
+ }, u.prototype.bindForSubMesh = function(I, O, x, m, c) {
+ O.prePassRenderer && O.prePassRenderer.enabled && O.prePassRenderer.getIndex(_.a.PREPASS_VELOCITY_TEXTURE_TYPE) !== -1 && (this.previousWorldMatrices[x.uniqueId] || (this.previousWorldMatrices[x.uniqueId] = V.a.Identity()), this.previousViewProjection || (this.previousViewProjection = O.getTransformMatrix()), I.setMatrix("previousWorld", this.previousWorldMatrices[x.uniqueId]), I.setMatrix("previousViewProjection", this.previousViewProjection), this.previousWorldMatrices[x.uniqueId] = m.clone(), this.previousViewProjection = O.getTransformMatrix().clone());
+ }, u;
+ }();
+ }, function(Be, A, f) {
+ var V = "lightFragmentDeclaration", _ = `#ifdef LIGHT{X}
+uniform vec4 vLightData{X};
+uniform vec4 vLightDiffuse{X};
+#ifdef SPECULARTERM
+uniform vec4 vLightSpecular{X};
+#else
+vec4 vLightSpecular{X}=vec4(0.);
+#endif
+#ifdef SHADOW{X}
+#ifdef SHADOWCSM{X}
+uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];
+uniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];
+uniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];
+uniform float cascadeBlendFactor{X};
+varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];
+varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];
+varying vec4 vPositionFromCamera{X};
+#if defined(SHADOWPCSS{X})
+uniform highp sampler2DArrayShadow shadowSampler{X};
+uniform highp sampler2DArray depthSampler{X};
+uniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];
+uniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];
+uniform float penumbraDarkness{X};
+#elif defined(SHADOWPCF{X})
+uniform highp sampler2DArrayShadow shadowSampler{X};
+#else
+uniform highp sampler2DArray shadowSampler{X};
+#endif
+#ifdef SHADOWCSMDEBUG{X}
+const vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]
+(
+vec3 ( 1.5,0.0,0.0 ),
+vec3 ( 0.0,1.5,0.0 ),
+vec3 ( 0.0,0.0,5.5 ),
+vec3 ( 1.5,0.0,5.5 ),
+vec3 ( 1.5,1.5,0.0 ),
+vec3 ( 1.0,1.0,1.0 ),
+vec3 ( 0.0,1.0,5.5 ),
+vec3 ( 0.5,3.5,0.75 )
+);
+vec3 shadowDebug{X};
+#endif
+#ifdef SHADOWCSMUSESHADOWMAXZ{X}
+int index{X}=-1;
+#else
+int index{X}=SHADOWCSMNUM_CASCADES{X}-1;
+#endif
+float diff{X}=0.;
+#elif defined(SHADOWCUBE{X})
+uniform samplerCube shadowSampler{X};
+#else
+varying vec4 vPositionFromLight{X};
+varying float vDepthMetric{X};
+#if defined(SHADOWPCSS{X})
+uniform highp sampler2DShadow shadowSampler{X};
+uniform highp sampler2D depthSampler{X};
+#elif defined(SHADOWPCF{X})
+uniform highp sampler2DShadow shadowSampler{X};
+#else
+uniform sampler2D shadowSampler{X};
+#endif
+uniform mat4 lightMatrix{X};
+#endif
+uniform vec4 shadowsInfo{X};
+uniform vec2 depthValues{X};
+#endif
+#ifdef SPOTLIGHT{X}
+uniform vec4 vLightDirection{X};
+uniform vec4 vLightFalloff{X};
+#elif defined(POINTLIGHT{X})
+uniform vec4 vLightFalloff{X};
+#elif defined(HEMILIGHT{X})
+uniform vec3 vLightGround{X};
+#endif
+#ifdef PROJECTEDLIGHTTEXTURE{X}
+uniform mat4 textureProjectionMatrix{X};
+uniform sampler2D projectionLightSampler{X};
+#endif
+#endif`;
+ f(5).a.IncludesShadersStore[V] = _;
+ }, function(Be, A, f) {
+ var V = "lightUboDeclaration", _ = `#ifdef LIGHT{X}
+uniform Light{X}
+{
+vec4 vLightData;
+vec4 vLightDiffuse;
+vec4 vLightSpecular;
+#ifdef SPOTLIGHT{X}
+vec4 vLightDirection;
+vec4 vLightFalloff;
+#elif defined(POINTLIGHT{X})
+vec4 vLightFalloff;
+#elif defined(HEMILIGHT{X})
+vec3 vLightGround;
+#endif
+vec4 shadowsInfo;
+vec2 depthValues;
+} light{X};
+#ifdef PROJECTEDLIGHTTEXTURE{X}
+uniform mat4 textureProjectionMatrix{X};
+uniform sampler2D projectionLightSampler{X};
+#endif
+#ifdef SHADOW{X}
+#ifdef SHADOWCSM{X}
+uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];
+uniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];
+uniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];
+uniform float cascadeBlendFactor{X};
+varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];
+varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];
+varying vec4 vPositionFromCamera{X};
+#if defined(SHADOWPCSS{X})
+uniform highp sampler2DArrayShadow shadowSampler{X};
+uniform highp sampler2DArray depthSampler{X};
+uniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];
+uniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];
+uniform float penumbraDarkness{X};
+#elif defined(SHADOWPCF{X})
+uniform highp sampler2DArrayShadow shadowSampler{X};
+#else
+uniform highp sampler2DArray shadowSampler{X};
+#endif
+#ifdef SHADOWCSMDEBUG{X}
+const vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]
+(
+vec3 ( 1.5,0.0,0.0 ),
+vec3 ( 0.0,1.5,0.0 ),
+vec3 ( 0.0,0.0,5.5 ),
+vec3 ( 1.5,0.0,5.5 ),
+vec3 ( 1.5,1.5,0.0 ),
+vec3 ( 1.0,1.0,1.0 ),
+vec3 ( 0.0,1.0,5.5 ),
+vec3 ( 0.5,3.5,0.75 )
+);
+vec3 shadowDebug{X};
+#endif
+#ifdef SHADOWCSMUSESHADOWMAXZ{X}
+int index{X}=-1;
+#else
+int index{X}=SHADOWCSMNUM_CASCADES{X}-1;
+#endif
+float diff{X}=0.;
+#elif defined(SHADOWCUBE{X})
+uniform samplerCube shadowSampler{X};
+#else
+varying vec4 vPositionFromLight{X};
+varying float vDepthMetric{X};
+#if defined(SHADOWPCSS{X})
+uniform highp sampler2DShadow shadowSampler{X};
+uniform highp sampler2D depthSampler{X};
+#elif defined(SHADOWPCF{X})
+uniform highp sampler2DShadow shadowSampler{X};
+#else
+uniform sampler2D shadowSampler{X};
+#endif
+uniform mat4 lightMatrix{X};
+#endif
+#endif
+#endif`;
+ f(5).a.IncludesShadersStore[V] = _;
+ }, function(Be, A, f) {
+ var V = "imageProcessingDeclaration", _ = `#ifdef EXPOSURE
+uniform float exposureLinear;
+#endif
+#ifdef CONTRAST
+uniform float contrast;
+#endif
+#ifdef VIGNETTE
+uniform vec2 vInverseScreenSize;
+uniform vec4 vignetteSettings1;
+uniform vec4 vignetteSettings2;
+#endif
+#ifdef COLORCURVES
+uniform vec4 vCameraColorCurveNegative;
+uniform vec4 vCameraColorCurveNeutral;
+uniform vec4 vCameraColorCurvePositive;
+#endif
+#ifdef COLORGRADING
+#ifdef COLORGRADING3D
+uniform highp sampler3D txColorTransform;
+#else
+uniform sampler2D txColorTransform;
+#endif
+uniform vec4 colorTransformSettings;
+#endif`;
+ f(5).a.IncludesShadersStore[V] = _;
+ }, function(Be, A, f) {
+ var V = "imageProcessingFunctions", _ = `#if defined(COLORGRADING) && !defined(COLORGRADING3D)
+
+#define inline
+vec3 sampleTexture3D(sampler2D colorTransform,vec3 color,vec2 sampler3dSetting)
+{
+float sliceSize=2.0*sampler3dSetting.x;
+#ifdef SAMPLER3DGREENDEPTH
+float sliceContinuous=(color.g-sampler3dSetting.x)*sampler3dSetting.y;
+#else
+float sliceContinuous=(color.b-sampler3dSetting.x)*sampler3dSetting.y;
+#endif
+float sliceInteger=floor(sliceContinuous);
+
+
+float sliceFraction=sliceContinuous-sliceInteger;
+#ifdef SAMPLER3DGREENDEPTH
+vec2 sliceUV=color.rb;
+#else
+vec2 sliceUV=color.rg;
+#endif
+sliceUV.x*=sliceSize;
+sliceUV.x+=sliceInteger*sliceSize;
+sliceUV=saturate(sliceUV);
+vec4 slice0Color=texture2D(colorTransform,sliceUV);
+sliceUV.x+=sliceSize;
+sliceUV=saturate(sliceUV);
+vec4 slice1Color=texture2D(colorTransform,sliceUV);
+vec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction);
+#ifdef SAMPLER3DBGRMAP
+color.rgb=result.rgb;
+#else
+color.rgb=result.bgr;
+#endif
+return color;
+}
+#endif
+#ifdef TONEMAPPING_ACES
+
+
+
+
+
+const mat3 ACESInputMat=mat3(
+vec3(0.59719,0.07600,0.02840),
+vec3(0.35458,0.90834,0.13383),
+vec3(0.04823,0.01566,0.83777)
+);
+
+const mat3 ACESOutputMat=mat3(
+vec3( 1.60475,-0.10208,-0.00327),
+vec3(-0.53108,1.10813,-0.07276),
+vec3(-0.07367,-0.00605,1.07602)
+);
+vec3 RRTAndODTFit(vec3 v)
+{
+vec3 a=v*(v+0.0245786)-0.000090537;
+vec3 b=v*(0.983729*v+0.4329510)+0.238081;
+return a/b;
+}
+vec3 ACESFitted(vec3 color)
+{
+color=ACESInputMat*color;
+
+color=RRTAndODTFit(color);
+color=ACESOutputMat*color;
+
+color=saturate(color);
+return color;
+}
+#endif
+vec4 applyImageProcessing(vec4 result) {
+#ifdef EXPOSURE
+result.rgb*=exposureLinear;
+#endif
+#ifdef VIGNETTE
+
+vec2 viewportXY=gl_FragCoord.xy*vInverseScreenSize;
+viewportXY=viewportXY*2.0-1.0;
+vec3 vignetteXY1=vec3(viewportXY*vignetteSettings1.xy+vignetteSettings1.zw,1.0);
+float vignetteTerm=dot(vignetteXY1,vignetteXY1);
+float vignette=pow(vignetteTerm,vignetteSettings2.w);
+
+vec3 vignetteColor=vignetteSettings2.rgb;
+#ifdef VIGNETTEBLENDMODEMULTIPLY
+vec3 vignetteColorMultiplier=mix(vignetteColor,vec3(1,1,1),vignette);
+result.rgb*=vignetteColorMultiplier;
+#endif
+#ifdef VIGNETTEBLENDMODEOPAQUE
+result.rgb=mix(vignetteColor,result.rgb,vignette);
+#endif
+#endif
+#ifdef TONEMAPPING
+#ifdef TONEMAPPING_ACES
+result.rgb=ACESFitted(result.rgb);
+#else
+const float tonemappingCalibration=1.590579;
+result.rgb=1.0-exp2(-tonemappingCalibration*result.rgb);
+#endif
+#endif
+
+result.rgb=toGammaSpace(result.rgb);
+result.rgb=saturate(result.rgb);
+#ifdef CONTRAST
+
+vec3 resultHighContrast=result.rgb*result.rgb*(3.0-2.0*result.rgb);
+if (contrast<1.0) {
+
+result.rgb=mix(vec3(0.5,0.5,0.5),result.rgb,contrast);
+} else {
+
+result.rgb=mix(result.rgb,resultHighContrast,contrast-1.0);
+}
+#endif
+
+#ifdef COLORGRADING
+vec3 colorTransformInput=result.rgb*colorTransformSettings.xxx+colorTransformSettings.yyy;
+#ifdef COLORGRADING3D
+vec3 colorTransformOutput=texture(txColorTransform,colorTransformInput).rgb;
+#else
+vec3 colorTransformOutput=sampleTexture3D(txColorTransform,colorTransformInput,colorTransformSettings.yz).rgb;
+#endif
+result.rgb=mix(result.rgb,colorTransformOutput,colorTransformSettings.www);
+#endif
+#ifdef COLORCURVES
+
+float luma=getLuminance(result.rgb);
+vec2 curveMix=clamp(vec2(luma*3.0-1.5,luma*-3.0+1.5),vec2(0.0),vec2(1.0));
+vec4 colorCurve=vCameraColorCurveNeutral+curveMix.x*vCameraColorCurvePositive-curveMix.y*vCameraColorCurveNegative;
+result.rgb*=colorCurve.rgb;
+result.rgb=mix(vec3(luma),result.rgb,colorCurve.a);
+#endif
+return result;
+}`;
+ f(5).a.IncludesShadersStore[V] = _;
+ }, function(Be, A, f) {
+ var V = "clipPlaneFragment", _ = `#ifdef CLIPPLANE
+if (fClipDistance>0.0)
+{
+discard;
+}
+#endif
+#ifdef CLIPPLANE2
+if (fClipDistance2>0.0)
+{
+discard;
+}
+#endif
+#ifdef CLIPPLANE3
+if (fClipDistance3>0.0)
+{
+discard;
+}
+#endif
+#ifdef CLIPPLANE4
+if (fClipDistance4>0.0)
+{
+discard;
+}
+#endif
+#ifdef CLIPPLANE5
+if (fClipDistance5>0.0)
+{
+discard;
+}
+#endif
+#ifdef CLIPPLANE6
+if (fClipDistance6>0.0)
+{
+discard;
+}
+#endif`;
+ f(5).a.IncludesShadersStore[V] = _;
+ }, function(Be, A, f) {
+ var V = "clipPlaneVertex", _ = `#ifdef CLIPPLANE
+fClipDistance=dot(worldPos,vClipPlane);
+#endif
+#ifdef CLIPPLANE2
+fClipDistance2=dot(worldPos,vClipPlane2);
+#endif
+#ifdef CLIPPLANE3
+fClipDistance3=dot(worldPos,vClipPlane3);
+#endif
+#ifdef CLIPPLANE4
+fClipDistance4=dot(worldPos,vClipPlane4);
+#endif
+#ifdef CLIPPLANE5
+fClipDistance5=dot(worldPos,vClipPlane5);
+#endif
+#ifdef CLIPPLANE6
+fClipDistance6=dot(worldPos,vClipPlane6);
+#endif`;
+ f(5).a.IncludesShadersStore[V] = _;
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return V;
+ });
+ var V = function() {
+ function _() {
+ this._count = 0, this._data = {};
+ }
+ return _.prototype.copyFrom = function(C) {
+ var u = this;
+ this.clear(), C.forEach(function(I, O) {
+ return u.add(I, O);
+ });
+ }, _.prototype.get = function(C) {
+ var u = this._data[C];
+ if (u !== void 0)
+ return u;
+ }, _.prototype.getOrAddWithFactory = function(C, u) {
+ var I = this.get(C);
+ return I !== void 0 || (I = u(C)) && this.add(C, I), I;
+ }, _.prototype.getOrAdd = function(C, u) {
+ var I = this.get(C);
+ return I !== void 0 ? I : (this.add(C, u), u);
+ }, _.prototype.contains = function(C) {
+ return this._data[C] !== void 0;
+ }, _.prototype.add = function(C, u) {
+ return this._data[C] === void 0 && (this._data[C] = u, ++this._count, !0);
+ }, _.prototype.set = function(C, u) {
+ return this._data[C] !== void 0 && (this._data[C] = u, !0);
+ }, _.prototype.getAndRemove = function(C) {
+ var u = this.get(C);
+ return u !== void 0 ? (delete this._data[C], --this._count, u) : null;
+ }, _.prototype.remove = function(C) {
+ return !!this.contains(C) && (delete this._data[C], --this._count, !0);
+ }, _.prototype.clear = function() {
+ this._data = {}, this._count = 0;
+ }, Object.defineProperty(_.prototype, "count", { get: function() {
+ return this._count;
+ }, enumerable: !1, configurable: !0 }), _.prototype.forEach = function(C) {
+ for (var u in this._data)
+ C(u, this._data[u]);
+ }, _.prototype.first = function(C) {
+ for (var u in this._data) {
+ var I = C(u, this._data[u]);
+ if (I)
+ return I;
+ }
+ return null;
+ }, _;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return C;
+ });
+ var V = f(44), _ = f(0), C = function() {
+ function u(I, O, x) {
+ this.center = _.e.Zero(), this.centerWorld = _.e.Zero(), this.minimum = _.e.Zero(), this.maximum = _.e.Zero(), this.reConstruct(I, O, x);
+ }
+ return u.prototype.reConstruct = function(I, O, x) {
+ this.minimum.copyFrom(I), this.maximum.copyFrom(O);
+ var m = _.e.Distance(I, O);
+ O.addToRef(I, this.center).scaleInPlace(0.5), this.radius = 0.5 * m, this._update(x || _.a.IdentityReadOnly);
+ }, u.prototype.scale = function(I) {
+ var O = this.radius * I, x = u.TmpVector3, m = x[0].setAll(O), c = this.center.subtractToRef(m, x[1]), T = this.center.addToRef(m, x[2]);
+ return this.reConstruct(c, T, this._worldMatrix), this;
+ }, u.prototype.getWorldMatrix = function() {
+ return this._worldMatrix;
+ }, u.prototype._update = function(I) {
+ if (I.isIdentity())
+ this.centerWorld.copyFrom(this.center), this.radiusWorld = this.radius;
+ else {
+ _.e.TransformCoordinatesToRef(this.center, I, this.centerWorld);
+ var O = u.TmpVector3[0];
+ _.e.TransformNormalFromFloatsToRef(1, 1, 1, I, O), this.radiusWorld = Math.max(Math.abs(O.x), Math.abs(O.y), Math.abs(O.z)) * this.radius;
+ }
+ }, u.prototype.isInFrustum = function(I) {
+ for (var O = this.centerWorld, x = this.radiusWorld, m = 0; m < 6; m++)
+ if (I[m].dotCoordinate(O) <= -x)
+ return !1;
+ return !0;
+ }, u.prototype.isCenterInFrustum = function(I) {
+ for (var O = this.centerWorld, x = 0; x < 6; x++)
+ if (I[x].dotCoordinate(O) < 0)
+ return !1;
+ return !0;
+ }, u.prototype.intersectsPoint = function(I) {
+ var O = _.e.DistanceSquared(this.centerWorld, I);
+ return !(this.radiusWorld * this.radiusWorld < O);
+ }, u.Intersects = function(I, O) {
+ var x = _.e.DistanceSquared(I.centerWorld, O.centerWorld), m = I.radiusWorld + O.radiusWorld;
+ return !(m * m < x);
+ }, u.TmpVector3 = V.a.BuildArray(3, _.e.Zero), u;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return V;
+ });
+ var V = function(_, C, u) {
+ this.bu = _, this.bv = C, this.distance = u, this.faceId = 0, this.subMeshId = 0;
+ };
+ }, function(Be, A, f) {
+ var V = "clipPlaneFragmentDeclaration", _ = `#ifdef CLIPPLANE
+varying float fClipDistance;
+#endif
+#ifdef CLIPPLANE2
+varying float fClipDistance2;
+#endif
+#ifdef CLIPPLANE3
+varying float fClipDistance3;
+#endif
+#ifdef CLIPPLANE4
+varying float fClipDistance4;
+#endif
+#ifdef CLIPPLANE5
+varying float fClipDistance5;
+#endif
+#ifdef CLIPPLANE6
+varying float fClipDistance6;
+#endif`;
+ f(5).a.IncludesShadersStore[V] = _;
+ }, function(Be, A, f) {
+ var V = "logDepthDeclaration", _ = `#ifdef LOGARITHMICDEPTH
+uniform float logarithmicDepthConstant;
+varying float vFragmentDepth;
+#endif`;
+ f(5).a.IncludesShadersStore[V] = _;
+ }, function(Be, A, f) {
+ var V = "clipPlaneVertexDeclaration", _ = `#ifdef CLIPPLANE
+uniform vec4 vClipPlane;
+varying float fClipDistance;
+#endif
+#ifdef CLIPPLANE2
+uniform vec4 vClipPlane2;
+varying float fClipDistance2;
+#endif
+#ifdef CLIPPLANE3
+uniform vec4 vClipPlane3;
+varying float fClipDistance3;
+#endif
+#ifdef CLIPPLANE4
+uniform vec4 vClipPlane4;
+varying float fClipDistance4;
+#endif
+#ifdef CLIPPLANE5
+uniform vec4 vClipPlane5;
+varying float fClipDistance5;
+#endif
+#ifdef CLIPPLANE6
+uniform vec4 vClipPlane6;
+varying float fClipDistance6;
+#endif`;
+ f(5).a.IncludesShadersStore[V] = _;
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return V;
+ });
+ var V = function() {
+ function _() {
+ }
+ return _.prototype.attributeProcessor = function(C) {
+ return C.replace("attribute", "in");
+ }, _.prototype.varyingProcessor = function(C, u) {
+ return C.replace("varying", u ? "in" : "out");
+ }, _.prototype.postProcessor = function(C, u, I) {
+ var O = C.search(/#extension.+GL_EXT_draw_buffers.+require/) !== -1;
+ if (C = (C = C.replace(/#extension.+(GL_OVR_multiview2|GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g, "")).replace(/texture2D\s*\(/g, "texture("), I)
+ C = (C = (C = (C = (C = (C = (C = C.replace(/texture2DLodEXT\s*\(/g, "textureLod(")).replace(/textureCubeLodEXT\s*\(/g, "textureLod(")).replace(/textureCube\s*\(/g, "texture(")).replace(/gl_FragDepthEXT/g, "gl_FragDepth")).replace(/gl_FragColor/g, "glFragColor")).replace(/gl_FragData/g, "glFragData")).replace(/void\s+?main\s*\(/g, (O ? "" : `out vec4 glFragColor;
+`) + "void main(");
+ else if (u.indexOf("#define MULTIVIEW") !== -1)
+ return `#extension GL_OVR_multiview2 : require
+layout (num_views = 2) in;
+` + C;
+ return C;
+ }, _;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return V;
+ });
+ var V = function() {
+ function _() {
+ }
+ return _.BindClipPlane = function(C, u) {
+ if (u.clipPlane) {
+ var I = u.clipPlane;
+ C.setFloat4("vClipPlane", I.normal.x, I.normal.y, I.normal.z, I.d);
+ }
+ u.clipPlane2 && (I = u.clipPlane2, C.setFloat4("vClipPlane2", I.normal.x, I.normal.y, I.normal.z, I.d)), u.clipPlane3 && (I = u.clipPlane3, C.setFloat4("vClipPlane3", I.normal.x, I.normal.y, I.normal.z, I.d)), u.clipPlane4 && (I = u.clipPlane4, C.setFloat4("vClipPlane4", I.normal.x, I.normal.y, I.normal.z, I.d)), u.clipPlane5 && (I = u.clipPlane5, C.setFloat4("vClipPlane5", I.normal.x, I.normal.y, I.normal.z, I.d)), u.clipPlane6 && (I = u.clipPlane6, C.setFloat4("vClipPlane6", I.normal.x, I.normal.y, I.normal.z, I.d));
+ }, _;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return V;
+ });
+ var V = function() {
+ function _() {
+ }
+ return _.RandomId = function() {
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(C) {
+ var u = 16 * Math.random() | 0;
+ return (C === "x" ? u : 3 & u | 8).toString(16);
+ });
+ }, _;
+ }();
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return u;
+ });
+ var V = f(1), _ = f(3), C = f(9), u = function() {
+ function I() {
+ this._dirty = !0, this._tempColor = new C.b(0, 0, 0, 0), this._globalCurve = new C.b(0, 0, 0, 0), this._highlightsCurve = new C.b(0, 0, 0, 0), this._midtonesCurve = new C.b(0, 0, 0, 0), this._shadowsCurve = new C.b(0, 0, 0, 0), this._positiveCurve = new C.b(0, 0, 0, 0), this._negativeCurve = new C.b(0, 0, 0, 0), this._globalHue = 30, this._globalDensity = 0, this._globalSaturation = 0, this._globalExposure = 0, this._highlightsHue = 30, this._highlightsDensity = 0, this._highlightsSaturation = 0, this._highlightsExposure = 0, this._midtonesHue = 30, this._midtonesDensity = 0, this._midtonesSaturation = 0, this._midtonesExposure = 0, this._shadowsHue = 30, this._shadowsDensity = 0, this._shadowsSaturation = 0, this._shadowsExposure = 0;
+ }
+ return Object.defineProperty(I.prototype, "globalHue", { get: function() {
+ return this._globalHue;
+ }, set: function(O) {
+ this._globalHue = O, this._dirty = !0;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(I.prototype, "globalDensity", { get: function() {
+ return this._globalDensity;
+ }, set: function(O) {
+ this._globalDensity = O, this._dirty = !0;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(I.prototype, "globalSaturation", { get: function() {
+ return this._globalSaturation;
+ }, set: function(O) {
+ this._globalSaturation = O, this._dirty = !0;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(I.prototype, "globalExposure", { get: function() {
+ return this._globalExposure;
+ }, set: function(O) {
+ this._globalExposure = O, this._dirty = !0;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(I.prototype, "highlightsHue", { get: function() {
+ return this._highlightsHue;
+ }, set: function(O) {
+ this._highlightsHue = O, this._dirty = !0;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(I.prototype, "highlightsDensity", { get: function() {
+ return this._highlightsDensity;
+ }, set: function(O) {
+ this._highlightsDensity = O, this._dirty = !0;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(I.prototype, "highlightsSaturation", { get: function() {
+ return this._highlightsSaturation;
+ }, set: function(O) {
+ this._highlightsSaturation = O, this._dirty = !0;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(I.prototype, "highlightsExposure", { get: function() {
+ return this._highlightsExposure;
+ }, set: function(O) {
+ this._highlightsExposure = O, this._dirty = !0;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(I.prototype, "midtonesHue", { get: function() {
+ return this._midtonesHue;
+ }, set: function(O) {
+ this._midtonesHue = O, this._dirty = !0;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(I.prototype, "midtonesDensity", { get: function() {
+ return this._midtonesDensity;
+ }, set: function(O) {
+ this._midtonesDensity = O, this._dirty = !0;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(I.prototype, "midtonesSaturation", { get: function() {
+ return this._midtonesSaturation;
+ }, set: function(O) {
+ this._midtonesSaturation = O, this._dirty = !0;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(I.prototype, "midtonesExposure", { get: function() {
+ return this._midtonesExposure;
+ }, set: function(O) {
+ this._midtonesExposure = O, this._dirty = !0;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(I.prototype, "shadowsHue", { get: function() {
+ return this._shadowsHue;
+ }, set: function(O) {
+ this._shadowsHue = O, this._dirty = !0;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(I.prototype, "shadowsDensity", { get: function() {
+ return this._shadowsDensity;
+ }, set: function(O) {
+ this._shadowsDensity = O, this._dirty = !0;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(I.prototype, "shadowsSaturation", { get: function() {
+ return this._shadowsSaturation;
+ }, set: function(O) {
+ this._shadowsSaturation = O, this._dirty = !0;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(I.prototype, "shadowsExposure", { get: function() {
+ return this._shadowsExposure;
+ }, set: function(O) {
+ this._shadowsExposure = O, this._dirty = !0;
+ }, enumerable: !1, configurable: !0 }), I.prototype.getClassName = function() {
+ return "ColorCurves";
+ }, I.Bind = function(O, x, m, c, T) {
+ m === void 0 && (m = "vCameraColorCurvePositive"), c === void 0 && (c = "vCameraColorCurveNeutral"), T === void 0 && (T = "vCameraColorCurveNegative"), O._dirty && (O._dirty = !1, O.getColorGradingDataToRef(O._globalHue, O._globalDensity, O._globalSaturation, O._globalExposure, O._globalCurve), O.getColorGradingDataToRef(O._highlightsHue, O._highlightsDensity, O._highlightsSaturation, O._highlightsExposure, O._tempColor), O._tempColor.multiplyToRef(O._globalCurve, O._highlightsCurve), O.getColorGradingDataToRef(O._midtonesHue, O._midtonesDensity, O._midtonesSaturation, O._midtonesExposure, O._tempColor), O._tempColor.multiplyToRef(O._globalCurve, O._midtonesCurve), O.getColorGradingDataToRef(O._shadowsHue, O._shadowsDensity, O._shadowsSaturation, O._shadowsExposure, O._tempColor), O._tempColor.multiplyToRef(O._globalCurve, O._shadowsCurve), O._highlightsCurve.subtractToRef(O._midtonesCurve, O._positiveCurve), O._midtonesCurve.subtractToRef(O._shadowsCurve, O._negativeCurve)), x && (x.setFloat4(m, O._positiveCurve.r, O._positiveCurve.g, O._positiveCurve.b, O._positiveCurve.a), x.setFloat4(c, O._midtonesCurve.r, O._midtonesCurve.g, O._midtonesCurve.b, O._midtonesCurve.a), x.setFloat4(T, O._negativeCurve.r, O._negativeCurve.g, O._negativeCurve.b, O._negativeCurve.a));
+ }, I.PrepareUniforms = function(O) {
+ O.push("vCameraColorCurveNeutral", "vCameraColorCurvePositive", "vCameraColorCurveNegative");
+ }, I.prototype.getColorGradingDataToRef = function(O, x, m, c, T) {
+ O != null && (O = I.clamp(O, 0, 360), x = I.clamp(x, -100, 100), m = I.clamp(m, -100, 100), c = I.clamp(c, -100, 100), x = I.applyColorGradingSliderNonlinear(x), x *= 0.5, c = I.applyColorGradingSliderNonlinear(c), x < 0 && (x *= -1, O = (O + 180) % 360), I.fromHSBToRef(O, x, 50 + 0.25 * c, T), T.scaleToRef(2, T), T.a = 1 + 0.01 * m);
+ }, I.applyColorGradingSliderNonlinear = function(O) {
+ O /= 100;
+ var x = Math.abs(O);
+ return x = Math.pow(x, 2), O < 0 && (x *= -1), x *= 100;
+ }, I.fromHSBToRef = function(O, x, m, c) {
+ var T = I.clamp(O, 0, 360), S = I.clamp(x / 100, 0, 1), E = I.clamp(m / 100, 0, 1);
+ if (S === 0)
+ c.r = E, c.g = E, c.b = E;
+ else {
+ T /= 60;
+ var g = Math.floor(T), l = T - g, h = E * (1 - S), v = E * (1 - S * l), b = E * (1 - S * (1 - l));
+ switch (g) {
+ case 0:
+ c.r = E, c.g = b, c.b = h;
+ break;
+ case 1:
+ c.r = v, c.g = E, c.b = h;
+ break;
+ case 2:
+ c.r = h, c.g = E, c.b = b;
+ break;
+ case 3:
+ c.r = h, c.g = v, c.b = E;
+ break;
+ case 4:
+ c.r = b, c.g = h, c.b = E;
+ break;
+ default:
+ c.r = E, c.g = h, c.b = v;
+ }
+ }
+ c.a = 1;
+ }, I.clamp = function(O, x, m) {
+ return Math.min(Math.max(O, x), m);
+ }, I.prototype.clone = function() {
+ return _.a.Clone(function() {
+ return new I();
+ }, this);
+ }, I.prototype.serialize = function() {
+ return _.a.Serialize(this);
+ }, I.Parse = function(O) {
+ return _.a.Parse(function() {
+ return new I();
+ }, O, null, null);
+ }, Object(V.c)([Object(_.c)()], I.prototype, "_globalHue", void 0), Object(V.c)([Object(_.c)()], I.prototype, "_globalDensity", void 0), Object(V.c)([Object(_.c)()], I.prototype, "_globalSaturation", void 0), Object(V.c)([Object(_.c)()], I.prototype, "_globalExposure", void 0), Object(V.c)([Object(_.c)()], I.prototype, "_highlightsHue", void 0), Object(V.c)([Object(_.c)()], I.prototype, "_highlightsDensity", void 0), Object(V.c)([Object(_.c)()], I.prototype, "_highlightsSaturation", void 0), Object(V.c)([Object(_.c)()], I.prototype, "_highlightsExposure", void 0), Object(V.c)([Object(_.c)()], I.prototype, "_midtonesHue", void 0), Object(V.c)([Object(_.c)()], I.prototype, "_midtonesDensity", void 0), Object(V.c)([Object(_.c)()], I.prototype, "_midtonesSaturation", void 0), Object(V.c)([Object(_.c)()], I.prototype, "_midtonesExposure", void 0), I;
+ }();
+ _.a._ColorCurvesParser = u.Parse;
+ }, function(Be, A, f) {
+ f.d(A, "a", function() {
+ return C;
+ });
+ var V = f(8), _ = f(11), C = function() {
+ function u() {
+ }
+ return u.Instantiate = function(I) {
+ if (this.RegisteredExternalClasses && this.RegisteredExternalClasses[I])
+ return this.RegisteredExternalClasses[I];
+ var O = _.a.GetClass(I);
+ if (O)
+ return O;
+ V.a.Warn(I + " not found, you may have missed an import.");
+ for (var x = I.split("."), m = window || this, c = 0, T = x.length; c < T; c++)
+ m = m[x[c]];
+ return typeof m != "function" ? null : m;
+ }, u.RegisteredExternalClasses = {}, u;
+ }();
+ }, function(Be, A, f) {
+ var V = f(26), _ = f(2);
+ V.a.prototype.setAlphaConstants = function(C, u, I, O) {
+ this._alphaState.setAlphaBlendConstants(C, u, I, O);
+ }, V.a.prototype.setAlphaMode = function(C, u) {
+ if (u === void 0 && (u = !1), this._alphaMode !== C) {
+ switch (C) {
+ case _.a.ALPHA_DISABLE:
+ this._alphaState.alphaBlend = !1;
+ break;
+ case _.a.ALPHA_PREMULTIPLIED:
+ this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE), this._alphaState.alphaBlend = !0;
+ break;
+ case _.a.ALPHA_PREMULTIPLIED_PORTERDUFF:
+ this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA), this._alphaState.alphaBlend = !0;
+ break;
+ case _.a.ALPHA_COMBINE:
+ this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE), this._alphaState.alphaBlend = !0;
+ break;
+ case _.a.ALPHA_ONEONE:
+ this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ZERO, this._gl.ONE), this._alphaState.alphaBlend = !0;
+ break;
+ case _.a.ALPHA_ADD:
+ this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ONE), this._alphaState.alphaBlend = !0;
+ break;
+ case _.a.ALPHA_SUBTRACT:
+ this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE), this._alphaState.alphaBlend = !0;
+ break;
+ case _.a.ALPHA_MULTIPLY:
+ this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR, this._gl.ZERO, this._gl.ONE, this._gl.ONE), this._alphaState.alphaBlend = !0;
+ break;
+ case _.a.ALPHA_MAXIMIZED:
+ this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE), this._alphaState.alphaBlend = !0;
+ break;
+ case _.a.ALPHA_INTERPOLATE:
+ this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR, this._gl.ONE_MINUS_CONSTANT_COLOR, this._gl.CONSTANT_ALPHA, this._gl.ONE_MINUS_CONSTANT_ALPHA), this._alphaState.alphaBlend = !0;
+ break;
+ case _.a.ALPHA_SCREENMODE:
+ this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA), this._alphaState.alphaBlend = !0;
+ break;
+ case _.a.ALPHA_ONEONE_ONEONE:
+ this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ONE, this._gl.ONE), this._alphaState.alphaBlend = !0;
+ break;
+ case _.a.ALPHA_ALPHATOCOLOR:
+ this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ZERO), this._alphaState.alphaBlend = !0;
+ break;
+ case _.a.ALPHA_REVERSEONEMINUS:
+ this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE_MINUS_DST_COLOR, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE_MINUS_DST_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA), this._alphaState.alphaBlend = !0;
+ break;
+ case _.a.ALPHA_SRC_DSTONEMINUSSRCALPHA:
+ this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA), this._alphaState.alphaBlend = !0;
+ break;
+ case _.a.ALPHA_ONEONE_ONEZERO:
+ this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ONE, this._gl.ZERO), this._alphaState.alphaBlend = !0;
+ break;
+ case _.a.ALPHA_EXCLUSION:
+ this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE_MINUS_DST_COLOR, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ZERO, this._gl.ONE), this._alphaState.alphaBlend = !0;
+ }
+ u || (this.depthCullingState.depthMask = C === _.a.ALPHA_DISABLE), this._alphaMode = C;
+ }
+ }, V.a.prototype.getAlphaMode = function() {
+ return this._alphaMode;
+ }, V.a.prototype.setAlphaEquation = function(C) {
+ if (this._alphaEquation !== C) {
+ switch (C) {
+ case _.a.ALPHA_EQUATION_ADD:
+ this._alphaState.setAlphaEquationParameters(this._gl.FUNC_ADD, this._gl.FUNC_ADD);
+ break;
+ case _.a.ALPHA_EQUATION_SUBSTRACT:
+ this._alphaState.setAlphaEquationParameters(this._gl.FUNC_SUBTRACT, this._gl.FUNC_SUBTRACT);
+ break;
+ case _.a.ALPHA_EQUATION_REVERSE_SUBTRACT:
+ this._alphaState.setAlphaEquationParameters(this._gl.FUNC_REVERSE_SUBTRACT, this._gl.FUNC_REVERSE_SUBTRACT);
+ break;
+ case _.a.ALPHA_EQUATION_MAX:
+ this._alphaState.setAlphaEquationParameters(this._gl.MAX, this._gl.MAX);
+ break;
+ case _.a.ALPHA_EQUATION_MIN:
+ this._alphaState.setAlphaEquationParameters(this._gl.MIN, this._gl.MIN);
+ break;
+ case _.a.ALPHA_EQUATION_DARKEN:
+ this._alphaState.setAlphaEquationParameters(this._gl.MIN, this._gl.FUNC_ADD);
+ }
+ this._alphaEquation = C;
+ }
+ }, V.a.prototype.getAlphaEquation = function() {
+ return this._alphaEquation;
+ };
+ }, function(Be, A, f) {
+ var V = f(26);
+ V.a.prototype.updateDynamicIndexBuffer = function(_, C, u) {
+ var I;
+ this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null, this.bindIndexBuffer(_), I = C instanceof Uint16Array || C instanceof Uint32Array ? C : _.is32Bits ? new Uint32Array(C) : new Uint16Array(C), this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, I, this._gl.DYNAMIC_DRAW), this._resetIndexBufferBinding();
+ }, V.a.prototype.updateDynamicVertexBuffer = function(_, C, u, I) {
+ this.bindArrayBuffer(_), u === void 0 && (u = 0);
+ var O = C.length || C.byteLength;
+ I === void 0 || I >= O && u === 0 ? C instanceof Array ? this._gl.bufferSubData(this._gl.ARRAY_BUFFER, u, new Float32Array(C)) : this._gl.bufferSubData(this._gl.ARRAY_BUFFER, u, C) : C instanceof Array ? this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, new Float32Array(C).subarray(u, u + I)) : (C = C instanceof ArrayBuffer ? new Uint8Array(C, u, I) : new Uint8Array(C.buffer, C.byteOffset + u, I), this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, C)), this._resetVertexBufferBinding();
+ };
+ }, function(Be, A, f) {
+ var V = "fogFragmentDeclaration", _ = `#ifdef FOG
+#define FOGMODE_NONE 0.
+#define FOGMODE_EXP 1.
+#define FOGMODE_EXP2 2.
+#define FOGMODE_LINEAR 3.
+#define E 2.71828
+uniform vec4 vFogInfos;
+uniform vec3 vFogColor;
+varying vec3 vFogDistance;
+float CalcFogFactor()
+{
+float fogCoeff=1.0;
+float fogStart=vFogInfos.y;
+float fogEnd=vFogInfos.z;
+float fogDensity=vFogInfos.w;
+float fogDistance=length(vFogDistance);
+if (FOGMODE_LINEAR == vFogInfos.x)
+{
+fogCoeff=(fogEnd-fogDistance)/(fogEnd-fogStart);
+}
+else if (FOGMODE_EXP == vFogInfos.x)
+{
+fogCoeff=1.0/pow(E,fogDistance*fogDensity);
+}
+else if (FOGMODE_EXP2 == vFogInfos.x)
+{
+fogCoeff=1.0/pow(E,fogDistance*fogDistance*fogDensity*fogDensity);
+}
+return clamp(fogCoeff,0.0,1.0);
+}
+#endif`;
+ f(5).a.IncludesShadersStore[V] = _;
+ }, function(Be, A, f) {
+ var V = f(26), _ = f(27);
+ V.a.prototype.createDynamicTexture = function(C, u, I, O) {
+ var x = new _.a(this, _.b.Dynamic);
+ return x.baseWidth = C, x.baseHeight = u, I && (C = this.needPOTTextures ? V.a.GetExponentOfTwo(C, this._caps.maxTextureSize) : C, u = this.needPOTTextures ? V.a.GetExponentOfTwo(u, this._caps.maxTextureSize) : u), x.width = C, x.height = u, x.isReady = !1, x.generateMipMaps = I, x.samplingMode = O, this.updateTextureSamplingMode(O, x), this._internalTexturesCache.push(x), x;
+ }, V.a.prototype.updateDynamicTexture = function(C, u, I, O, x, m) {
+ if (O === void 0 && (O = !1), m === void 0 && (m = !1), C) {
+ var c = this._gl, T = c.TEXTURE_2D, S = this._bindTextureDirectly(T, C, !0, m);
+ this._unpackFlipY(I === void 0 ? C.invertY : I), O && c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1);
+ var E = this._getWebGLTextureType(C.type), g = this._getInternalFormat(x || C.format), l = this._getRGBABufferInternalSizedFormat(C.type, g);
+ c.texImage2D(T, 0, l, g, E, u), C.generateMipMaps && c.generateMipmap(T), S || this._bindTextureDirectly(T, null), O && c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0), C.isReady = !0;
+ }
+ };
+ }, function(Be, A, f) {
+ f.r(A), f.d(A, "AbstractScene", function() {
+ return V.a;
+ }), f.d(A, "AbstractActionManager", function() {
+ return _.a;
+ }), f.d(A, "Action", function() {
+ return x;
+ }), f.d(A, "ActionEvent", function() {
+ return m.a;
+ }), f.d(A, "ActionManager", function() {
+ return pe;
+ }), f.d(A, "Condition", function() {
+ return T;
+ }), f.d(A, "ValueCondition", function() {
+ return S;
+ }), f.d(A, "PredicateCondition", function() {
+ return E;
+ }), f.d(A, "StateCondition", function() {
+ return g;
+ }), f.d(A, "SwitchBooleanAction", function() {
+ return v;
+ }), f.d(A, "SetStateAction", function() {
+ return b;
+ }), f.d(A, "SetValueAction", function() {
+ return D;
+ }), f.d(A, "IncrementValueAction", function() {
+ return w;
+ }), f.d(A, "PlayAnimationAction", function() {
+ return N;
+ }), f.d(A, "StopAnimationAction", function() {
+ return M;
+ }), f.d(A, "DoNothingAction", function() {
+ return U;
+ }), f.d(A, "CombineAction", function() {
+ return X;
+ }), f.d(A, "ExecuteCodeAction", function() {
+ return j;
+ }), f.d(A, "SetParentAction", function() {
+ return ne;
+ }), f.d(A, "PlaySoundAction", function() {
+ return ae;
+ }), f.d(A, "StopSoundAction", function() {
+ return ee;
+ }), f.d(A, "InterpolateValueAction", function() {
+ return H;
+ }), f.d(A, "Animatable", function() {
+ return ke;
+ }), f.d(A, "_IAnimationState", function() {
+ return Y;
+ }), f.d(A, "Animation", function() {
+ return k;
+ }), f.d(A, "TargetedAnimation", function() {
+ return We;
+ }), f.d(A, "AnimationGroup", function() {
+ return je;
+ }), f.d(A, "AnimationPropertiesOverride", function() {
+ return He;
+ }), f.d(A, "EasingFunction", function() {
+ return Ge;
+ }), f.d(A, "CircleEase", function() {
+ return tt;
+ }), f.d(A, "BackEase", function() {
+ return Je;
+ }), f.d(A, "BounceEase", function() {
+ return st;
+ }), f.d(A, "CubicEase", function() {
+ return at;
+ }), f.d(A, "ElasticEase", function() {
+ return pt;
+ }), f.d(A, "ExponentialEase", function() {
+ return Tt;
+ }), f.d(A, "PowerEase", function() {
+ return Lt;
+ }), f.d(A, "QuadraticEase", function() {
+ return Ot;
+ }), f.d(A, "QuarticEase", function() {
+ return St;
+ }), f.d(A, "QuinticEase", function() {
+ return Ct;
+ }), f.d(A, "SineEase", function() {
+ return nn;
+ }), f.d(A, "BezierCurveEase", function() {
+ return Qt;
+ }), f.d(A, "RuntimeAnimation", function() {
+ return me;
+ }), f.d(A, "AnimationEvent", function() {
+ return $t;
+ }), f.d(A, "AnimationKeyInterpolation", function() {
+ return K;
+ }), f.d(A, "AnimationRange", function() {
+ return G;
+ }), f.d(A, "KeepAssets", function() {
+ return Sn;
+ }), f.d(A, "InstantiatedEntries", function() {
+ return en;
+ }), f.d(A, "AssetContainer", function() {
+ return An;
+ }), f.d(A, "Analyser", function() {
+ return Pn;
+ }), f.d(A, "AudioEngine", function() {
+ return rr;
+ }), f.d(A, "AudioSceneComponent", function() {
+ return qn;
+ }), f.d(A, "Sound", function() {
+ return Qn;
+ }), f.d(A, "SoundTrack", function() {
+ return So;
+ }), f.d(A, "WeightedSound", function() {
+ return lf;
+ }), f.d(A, "AutoRotationBehavior", function() {
+ return Qc;
+ }), f.d(A, "BouncingBehavior", function() {
+ return qc;
+ }), f.d(A, "FramingBehavior", function() {
+ return Zc;
+ }), f.d(A, "AttachToBoxBehavior", function() {
+ return uf;
+ }), f.d(A, "FadeInOutBehavior", function() {
+ return hf;
+ }), f.d(A, "MultiPointerScaleBehavior", function() {
+ return df;
+ }), f.d(A, "PointerDragBehavior", function() {
+ return fi.a;
+ }), f.d(A, "SixDofDragBehavior", function() {
+ return Jc;
+ }), f.d(A, "Bone", function() {
+ return Fe;
+ }), f.d(A, "BoneIKController", function() {
+ return ff;
+ }), f.d(A, "BoneLookController", function() {
+ return pf;
+ }), f.d(A, "Skeleton", function() {
+ return Ao;
+ }), f.d(A, "ArcRotateCameraGamepadInput", function() {
+ return Da;
+ }), f.d(A, "ArcRotateCameraKeyboardMoveInput", function() {
+ return La;
+ }), f.d(A, "ArcRotateCameraMouseWheelInput", function() {
+ return Na;
+ }), f.d(A, "ArcRotateCameraPointersInput", function() {
+ return wa;
+ }), f.d(A, "ArcRotateCameraVRDeviceOrientationInput", function() {
+ return Fa;
+ }), f.d(A, "FlyCameraKeyboardInput", function() {
+ return Ba;
+ }), f.d(A, "FlyCameraMouseInput", function() {
+ return Ua;
+ }), f.d(A, "FollowCameraKeyboardMoveInput", function() {
+ return Va;
+ }), f.d(A, "FollowCameraMouseWheelInput", function() {
+ return ka;
+ }), f.d(A, "FollowCameraPointersInput", function() {
+ return Ga;
+ }), f.d(A, "FreeCameraDeviceOrientationInput", function() {
+ return Xa;
+ }), f.d(A, "FreeCameraGamepadInput", function() {
+ return Ya;
+ }), f.d(A, "FreeCameraKeyboardMoveInput", function() {
+ return za;
+ }), f.d(A, "FreeCameraMouseInput", function() {
+ return ja;
+ }), f.d(A, "FreeCameraMouseWheelInput", function() {
+ return Ha;
+ }), f.d(A, "FreeCameraTouchInput", function() {
+ return Wa;
+ }), f.d(A, "FreeCameraVirtualJoystickInput", function() {
+ return Qa;
+ }), f.d(A, "CameraInputTypes", function() {
+ return un;
+ }), f.d(A, "CameraInputsManager", function() {
+ return zr;
+ }), f.d(A, "Camera", function() {
+ return _t.a;
+ }), f.d(A, "TargetCamera", function() {
+ return Pi;
+ }), f.d(A, "FreeCamera", function() {
+ return zn;
+ }), f.d(A, "FreeCameraInputsManager", function() {
+ return jr;
+ }), f.d(A, "TouchCamera", function() {
+ return qa;
+ }), f.d(A, "ArcRotateCamera", function() {
+ return ji;
+ }), f.d(A, "ArcRotateCameraInputsManager", function() {
+ return Po;
+ }), f.d(A, "DeviceOrientationCamera", function() {
+ return xo;
+ }), f.d(A, "FlyCamera", function() {
+ return gf;
+ }), f.d(A, "FlyCameraInputsManager", function() {
+ return ol;
+ }), f.d(A, "FollowCamera", function() {
+ return sl;
+ }), f.d(A, "ArcFollowCamera", function() {
+ return cl;
+ }), f.d(A, "FollowCameraInputsManager", function() {
+ return al;
+ }), f.d(A, "GamepadCamera", function() {
+ return Co;
+ }), f.d(A, "AnaglyphArcRotateCamera", function() {
+ return pl;
+ }), f.d(A, "AnaglyphFreeCamera", function() {
+ return _l;
+ }), f.d(A, "AnaglyphGamepadCamera", function() {
+ return ml;
+ }), f.d(A, "AnaglyphUniversalCamera", function() {
+ return gl;
+ }), f.d(A, "StereoscopicArcRotateCamera", function() {
+ return vl;
+ }), f.d(A, "StereoscopicFreeCamera", function() {
+ return yl;
+ }), f.d(A, "StereoscopicGamepadCamera", function() {
+ return bl;
+ }), f.d(A, "StereoscopicUniversalCamera", function() {
+ return Tl;
+ }), f.d(A, "UniversalCamera", function() {
+ return sr;
+ }), f.d(A, "VirtualJoysticksCamera", function() {
+ return El;
+ }), f.d(A, "VRCameraMetrics", function() {
+ return cr;
+ }), f.d(A, "VRDeviceOrientationArcRotateCamera", function() {
+ return xl;
+ }), f.d(A, "VRDeviceOrientationFreeCamera", function() {
+ return Ro;
+ }), f.d(A, "VRDeviceOrientationGamepadCamera", function() {
+ return Cl;
+ }), f.d(A, "OnAfterEnteringVRObservableEvent", function() {
+ return Cf;
+ }), f.d(A, "VRExperienceHelper", function() {
+ return Il;
+ }), f.d(A, "WebVRFreeCamera", function() {
+ return Mo;
+ }), f.d(A, "Collider", function() {
+ return Dl;
+ }), f.d(A, "DefaultCollisionCoordinator", function() {
+ return Ll;
+ }), f.d(A, "PickingInfo", function() {
+ return Yi.a;
+ }), f.d(A, "IntersectionInfo", function() {
+ return Rf.a;
+ }), f.d(A, "_MeshCollisionData", function() {
+ return Of.a;
+ }), f.d(A, "BoundingBox", function() {
+ return os.a;
+ }), f.d(A, "BoundingInfo", function() {
+ return Mi.a;
+ }), f.d(A, "BoundingSphere", function() {
+ return Nl.a;
+ }), f.d(A, "Octree", function() {
+ return Wr;
+ }), f.d(A, "OctreeBlock", function() {
+ return wl;
+ }), f.d(A, "OctreeSceneComponent", function() {
+ return us;
+ }), f.d(A, "Ray", function() {
+ return dn.a;
+ }), f.d(A, "AxesViewer", function() {
+ return Ki.AxesViewer;
+ }), f.d(A, "BoneAxesViewer", function() {
+ return Ki.BoneAxesViewer;
+ }), f.d(A, "DebugLayerTab", function() {
+ return Ki.DebugLayerTab;
+ }), f.d(A, "DebugLayer", function() {
+ return Ki.DebugLayer;
+ }), f.d(A, "PhysicsViewer", function() {
+ return Ki.PhysicsViewer;
+ }), f.d(A, "RayHelper", function() {
+ return Ki.RayHelper;
+ }), f.d(A, "SkeletonViewer", function() {
+ return Ki.SkeletonViewer;
+ }), f.d(A, "DeviceInputSystem", function() {
+ return Fl;
+ }), f.d(A, "DeviceType", function() {
+ return Xt;
+ }), f.d(A, "PointerInput", function() {
+ return as;
+ }), f.d(A, "DualShockInput", function() {
+ return ss;
+ }), f.d(A, "XboxInput", function() {
+ return cs;
+ }), f.d(A, "SwitchInput", function() {
+ return ls;
+ }), f.d(A, "DeviceSource", function() {
+ return Bl;
+ }), f.d(A, "DeviceSourceManager", function() {
+ return Mf;
+ }), f.d(A, "Constants", function() {
+ return h.a;
+ }), f.d(A, "ThinEngine", function() {
+ return wt.a;
+ }), f.d(A, "Engine", function() {
+ return Ue.a;
+ }), f.d(A, "EngineStore", function() {
+ return te.a;
+ }), f.d(A, "NullEngineOptions", function() {
+ return Ul.b;
+ }), f.d(A, "NullEngine", function() {
+ return Ul.a;
+ }), f.d(A, "_OcclusionDataStorage", function() {
+ return kl;
+ }), f.d(A, "_forceTransformFeedbackToBundle", function() {
+ return If;
+ }), f.d(A, "EngineView", function() {
+ return Df;
+ }), f.d(A, "WebGLPipelineContext", function() {
+ return Nf.a;
+ }), f.d(A, "WebGL2ShaderProcessor", function() {
+ return Gl.a;
+ }), f.d(A, "NativeEngine", function() {
+ return Vf;
+ }), f.d(A, "ShaderCodeInliner", function() {
+ return ds;
+ }), f.d(A, "PerformanceConfigurator", function() {
+ return kf.a;
+ }), f.d(A, "KeyboardEventTypes", function() {
+ return zi.a;
+ }), f.d(A, "KeyboardInfo", function() {
+ return zi.b;
+ }), f.d(A, "KeyboardInfoPre", function() {
+ return zi.c;
+ }), f.d(A, "PointerEventTypes", function() {
+ return yt.a;
+ }), f.d(A, "PointerInfoBase", function() {
+ return yt.c;
+ }), f.d(A, "PointerInfoPre", function() {
+ return yt.d;
+ }), f.d(A, "PointerInfo", function() {
+ return yt.b;
+ }), f.d(A, "ClipboardEventTypes", function() {
+ return No;
+ }), f.d(A, "ClipboardInfo", function() {
+ return Gf;
+ }), f.d(A, "DaydreamController", function() {
+ return ps;
+ }), f.d(A, "GearVRController", function() {
+ return _s;
+ }), f.d(A, "GenericController", function() {
+ return wo;
+ }), f.d(A, "OculusTouchController", function() {
+ return ms;
+ }), f.d(A, "PoseEnabledControllerType", function() {
+ return Jn;
+ }), f.d(A, "PoseEnabledControllerHelper", function() {
+ return xi;
+ }), f.d(A, "PoseEnabledController", function() {
+ return ar;
+ }), f.d(A, "ViveController", function() {
+ return Wl;
+ }), f.d(A, "WebVRController", function() {
+ return Ri;
+ }), f.d(A, "WindowsMotionController", function() {
+ return Fo;
+ }), f.d(A, "XRWindowsMotionController", function() {
+ return jf;
+ }), f.d(A, "StickValues", function() {
+ return _f;
+ }), f.d(A, "Gamepad", function() {
+ return hn;
+ }), f.d(A, "GenericPad", function() {
+ return nl;
+ }), f.d(A, "GamepadManager", function() {
+ return hl;
+ }), f.d(A, "GamepadSystemSceneComponent", function() {
+ return dl;
+ }), f.d(A, "Xbox360Button", function() {
+ return xn;
+ }), f.d(A, "Xbox360Dpad", function() {
+ return Hi;
+ }), f.d(A, "Xbox360Pad", function() {
+ return ll;
+ }), f.d(A, "DualShockButton", function() {
+ return Vn;
+ }), f.d(A, "DualShockDpad", function() {
+ return Wi;
+ }), f.d(A, "DualShockPad", function() {
+ return ul;
+ }), f.d(A, "AxisDragGizmo", function() {
+ return Bo.a;
+ }), f.d(A, "AxisScaleGizmo", function() {
+ return Kr;
+ }), f.d(A, "BoundingBoxGizmo", function() {
+ return Xl;
+ }), f.d(A, "Gizmo", function() {
+ return Ln.a;
+ }), f.d(A, "GizmoManager", function() {
+ return Hf;
+ }), f.d(A, "PlaneRotationGizmo", function() {
+ return Uo;
+ }), f.d(A, "PositionGizmo", function() {
+ return Kl;
+ }), f.d(A, "RotationGizmo", function() {
+ return Yl;
+ }), f.d(A, "ScaleGizmo", function() {
+ return Ql;
+ }), f.d(A, "LightGizmo", function() {
+ return Wf;
+ }), f.d(A, "CameraGizmo", function() {
+ return Yf;
+ }), f.d(A, "PlaneDragGizmo", function() {
+ return Vo;
+ }), f.d(A, "EnvironmentHelper", function() {
+ return Es;
+ }), f.d(A, "PhotoDome", function() {
+ return op;
+ }), f.d(A, "_forceSceneHelpersToBundle", function() {
+ return qp;
+ }), f.d(A, "VideoDome", function() {
+ return Zp;
+ }), f.d(A, "EngineInstrumentation", function() {
+ return Jp;
+ }), f.d(A, "SceneInstrumentation", function() {
+ return $p;
+ }), f.d(A, "_TimeToken", function() {
+ return Vl;
+ }), f.d(A, "EffectLayer", function() {
+ return no;
+ }), f.d(A, "EffectLayerSceneComponent", function() {
+ return du;
+ }), f.d(A, "GlowLayer", function() {
+ return Ko;
+ }), f.d(A, "HighlightLayer", function() {
+ return Ms;
+ }), f.d(A, "Layer", function() {
+ return s_;
+ }), f.d(A, "LayerSceneComponent", function() {
+ return pu;
+ }), f.d(A, "LensFlare", function() {
+ return _u;
+ }), f.d(A, "LensFlareSystem", function() {
+ return Is;
+ }), f.d(A, "LensFlareSystemSceneComponent", function() {
+ return mu;
+ }), f.d(A, "Light", function() {
+ return bi.a;
+ }), f.d(A, "ShadowLight", function() {
+ return ko;
+ }), f.d(A, "ShadowGenerator", function() {
+ return Fn;
+ }), f.d(A, "CascadedShadowGenerator", function() {
+ return Ds;
+ }), f.d(A, "ShadowGeneratorSceneComponent", function() {
+ return Su;
+ }), f.d(A, "DirectionalLight", function() {
+ return vs;
+ }), f.d(A, "HemisphericLight", function() {
+ return Oo.a;
+ }), f.d(A, "PointLight", function() {
+ return Ls;
+ }), f.d(A, "SpotLight", function() {
+ return ys;
+ }), f.d(A, "DefaultLoadingScreen", function() {
+ return Au;
+ }), f.d(A, "_BabylonLoaderRegistered", function() {
+ return x_;
+ }), f.d(A, "BabylonFileLoaderConfiguration", function() {
+ return $o;
+ }), f.d(A, "SceneLoaderAnimationGroupLoadingMode", function() {
+ return vi;
+ }), f.d(A, "SceneLoader", function() {
+ return Ft;
+ }), f.d(A, "SceneLoaderFlags", function() {
+ return yi.a;
+ }), f.d(A, "BackgroundMaterial", function() {
+ return qr;
+ }), f.d(A, "ColorCurves", function() {
+ return R_.a;
+ }), f.d(A, "EffectFallbacks", function() {
+ return _r.a;
+ }), f.d(A, "Effect", function() {
+ return ze.a;
+ }), f.d(A, "FresnelParameters", function() {
+ return Fu;
+ }), f.d(A, "ImageProcessingConfigurationDefines", function() {
+ return vn.b;
+ }), f.d(A, "ImageProcessingConfiguration", function() {
+ return vn.a;
+ }), f.d(A, "Material", function() {
+ return zt.a;
+ }), f.d(A, "MaterialDefines", function() {
+ return zo.a;
+ }), f.d(A, "ThinMaterialHelper", function() {
+ return Bu.a;
+ }), f.d(A, "MaterialHelper", function() {
+ return $e.a;
+ }), f.d(A, "MultiMaterial", function() {
+ return Qi.a;
+ }), f.d(A, "PBRMaterialDefines", function() {
+ return As;
+ }), f.d(A, "PBRBaseMaterial", function() {
+ return pn;
+ }), f.d(A, "PBRBaseSimpleMaterial", function() {
+ return Us;
+ }), f.d(A, "PBRMaterial", function() {
+ return $r;
+ }), f.d(A, "PBRMetallicRoughnessMaterial", function() {
+ return Uu;
+ }), f.d(A, "PBRSpecularGlossinessMaterial", function() {
+ return Vu;
+ }), f.d(A, "PushMaterial", function() {
+ return jo.a;
+ }), f.d(A, "ShaderMaterial", function() {
+ return ea.a;
+ }), f.d(A, "StandardMaterialDefines", function() {
+ return Nt.b;
+ }), f.d(A, "StandardMaterial", function() {
+ return Nt.a;
+ }), f.d(A, "BaseTexture", function() {
+ return kn.a;
+ }), f.d(A, "ColorGradingTexture", function() {
+ return ku;
+ }), f.d(A, "CubeTexture", function() {
+ return ei;
+ }), f.d(A, "DynamicTexture", function() {
+ return pi.a;
+ }), f.d(A, "EquiRectangularCubeTexture", function() {
+ return Gu;
+ }), f.d(A, "HDRFiltering", function() {
+ return Ru;
+ }), f.d(A, "HDRCubeTexture", function() {
+ return qo;
+ }), f.d(A, "HtmlElementTexture", function() {
+ return O_;
+ }), f.d(A, "InternalTextureSource", function() {
+ return Pt.b;
+ }), f.d(A, "InternalTexture", function() {
+ return Pt.a;
+ }), f.d(A, "_DDSTextureLoader", function() {
+ return eu;
+ }), f.d(A, "_ENVTextureLoader", function() {
+ return tu;
+ }), f.d(A, "_KTXTextureLoader", function() {
+ return nu;
+ }), f.d(A, "_TGATextureLoader", function() {
+ return zu;
+ }), f.d(A, "_BasisTextureLoader", function() {
+ return ju;
+ }), f.d(A, "MirrorTexture", function() {
+ return Ts;
+ }), f.d(A, "MultiRenderTarget", function() {
+ return Vs;
+ }), f.d(A, "TexturePacker", function() {
+ return D_;
+ }), f.d(A, "TexturePackerFrame", function() {
+ return ks;
+ }), f.d(A, "CustomProceduralTexture", function() {
+ return N_;
+ }), f.d(A, "NoiseProceduralTexture", function() {
+ return Wu;
+ }), f.d(A, "ProceduralTexture", function() {
+ return oo;
+ }), f.d(A, "ProceduralTextureSceneComponent", function() {
+ return Hu;
+ }), f.d(A, "RawCubeTexture", function() {
+ return F_;
+ }), f.d(A, "RawTexture", function() {
+ return Zn;
+ }), f.d(A, "RawTexture2DArray", function() {
+ return B_;
+ }), f.d(A, "RawTexture3D", function() {
+ return U_;
+ }), f.d(A, "RefractionTexture", function() {
+ return V_;
+ }), f.d(A, "RenderTargetTexture", function() {
+ return on;
+ }), f.d(A, "Texture", function() {
+ return Ne.a;
+ }), f.d(A, "VideoTexture", function() {
+ return hu;
+ }), f.d(A, "UniformBuffer", function() {
+ return Sl.a;
+ }), f.d(A, "MaterialFlags", function() {
+ return lt.a;
+ }), f.d(A, "NodeMaterialBlockTargets", function() {
+ return Ce;
+ }), f.d(A, "NodeMaterialBlockConnectionPointTypes", function() {
+ return le;
+ }), f.d(A, "NodeMaterialBlockConnectionPointMode", function() {
+ return gn;
+ }), f.d(A, "NodeMaterialSystemValues", function() {
+ return gt;
+ }), f.d(A, "NodeMaterialModes", function() {
+ return Rn;
+ }), f.d(A, "NodeMaterialConnectionPointCompatibilityStates", function() {
+ return ii;
+ }), f.d(A, "NodeMaterialConnectionPointDirection", function() {
+ return yn;
+ }), f.d(A, "NodeMaterialConnectionPoint", function() {
+ return na;
+ }), f.d(A, "NodeMaterialBlock", function() {
+ return dt;
+ }), f.d(A, "NodeMaterialDefines", function() {
+ return lo;
+ }), f.d(A, "NodeMaterial", function() {
+ return sa;
+ }), f.d(A, "VertexOutputBlock", function() {
+ return ao;
+ }), f.d(A, "BonesBlock", function() {
+ return qu;
+ }), f.d(A, "InstancesBlock", function() {
+ return Zu;
+ }), f.d(A, "MorphTargetsBlock", function() {
+ return Ju;
+ }), f.d(A, "LightInformationBlock", function() {
+ return $u;
+ }), f.d(A, "FragmentOutputBlock", function() {
+ return Pr;
+ }), f.d(A, "ImageProcessingBlock", function() {
+ return eh;
+ }), f.d(A, "PerturbNormalBlock", function() {
+ return th;
+ }), f.d(A, "DiscardBlock", function() {
+ return nh;
+ }), f.d(A, "FrontFacingBlock", function() {
+ return ih;
+ }), f.d(A, "DerivativeBlock", function() {
+ return rh;
+ }), f.d(A, "FragCoordBlock", function() {
+ return oh;
+ }), f.d(A, "ScreenSizeBlock", function() {
+ return ah;
+ }), f.d(A, "FogBlock", function() {
+ return sh;
+ }), f.d(A, "LightBlock", function() {
+ return ch;
+ }), f.d(A, "TextureBlock", function() {
+ return lh;
+ }), f.d(A, "ReflectionTextureBlock", function() {
+ return uh;
+ }), f.d(A, "CurrentScreenBlock", function() {
+ return zs;
+ }), f.d(A, "InputBlock", function() {
+ return Et;
+ }), f.d(A, "AnimatedInputBlockTypes", function() {
+ return Ni;
+ }), f.d(A, "MultiplyBlock", function() {
+ return ra;
+ }), f.d(A, "AddBlock", function() {
+ return hh;
+ }), f.d(A, "ScaleBlock", function() {
+ return dh;
+ }), f.d(A, "ClampBlock", function() {
+ return fh;
+ }), f.d(A, "CrossBlock", function() {
+ return ph;
+ }), f.d(A, "DotBlock", function() {
+ return _h;
+ }), f.d(A, "TransformBlock", function() {
+ return ia;
+ }), f.d(A, "RemapBlock", function() {
+ return Xs;
+ }), f.d(A, "NormalizeBlock", function() {
+ return mh;
+ }), f.d(A, "TrigonometryBlockOperations", function() {
+ return tn;
+ }), f.d(A, "TrigonometryBlock", function() {
+ return $s;
+ }), f.d(A, "ColorMergerBlock", function() {
+ return gh;
+ }), f.d(A, "VectorMergerBlock", function() {
+ return so;
+ }), f.d(A, "ColorSplitterBlock", function() {
+ return Js;
+ }), f.d(A, "VectorSplitterBlock", function() {
+ return vh;
+ }), f.d(A, "LerpBlock", function() {
+ return yh;
+ }), f.d(A, "DivideBlock", function() {
+ return bh;
+ }), f.d(A, "SubtractBlock", function() {
+ return Th;
+ }), f.d(A, "StepBlock", function() {
+ return Eh;
+ }), f.d(A, "OneMinusBlock", function() {
+ return nc;
+ }), f.d(A, "ViewDirectionBlock", function() {
+ return ic;
+ }), f.d(A, "FresnelBlock", function() {
+ return Sh;
+ }), f.d(A, "MaxBlock", function() {
+ return Ah;
+ }), f.d(A, "MinBlock", function() {
+ return Ph;
+ }), f.d(A, "DistanceBlock", function() {
+ return xh;
+ }), f.d(A, "LengthBlock", function() {
+ return Ch;
+ }), f.d(A, "NegateBlock", function() {
+ return Rh;
+ }), f.d(A, "PowBlock", function() {
+ return Oh;
+ }), f.d(A, "RandomNumberBlock", function() {
+ return Mh;
+ }), f.d(A, "ArcTan2Block", function() {
+ return Ih;
+ }), f.d(A, "SmoothStepBlock", function() {
+ return Dh;
+ }), f.d(A, "ReciprocalBlock", function() {
+ return Lh;
+ }), f.d(A, "ReplaceColorBlock", function() {
+ return Nh;
+ }), f.d(A, "PosterizeBlock", function() {
+ return wh;
+ }), f.d(A, "WaveBlockKind", function() {
+ return qi;
+ }), f.d(A, "WaveBlock", function() {
+ return Fh;
+ }), f.d(A, "GradientBlockColorStep", function() {
+ return ca;
+ }), f.d(A, "GradientBlock", function() {
+ return Bh;
+ }), f.d(A, "NLerpBlock", function() {
+ return Uh;
+ }), f.d(A, "WorleyNoise3DBlock", function() {
+ return Vh;
+ }), f.d(A, "SimplexPerlin3DBlock", function() {
+ return kh;
+ }), f.d(A, "NormalBlendBlock", function() {
+ return Gh;
+ }), f.d(A, "Rotate2dBlock", function() {
+ return zh;
+ }), f.d(A, "ReflectBlock", function() {
+ return jh;
+ }), f.d(A, "RefractBlock", function() {
+ return Hh;
+ }), f.d(A, "DesaturateBlock", function() {
+ return Wh;
+ }), f.d(A, "PBRMetallicRoughnessBlock", function() {
+ return Xh;
+ }), f.d(A, "SheenBlock", function() {
+ return rc;
+ }), f.d(A, "AnisotropyBlock", function() {
+ return oc;
+ }), f.d(A, "ReflectionBlock", function() {
+ return ac;
+ }), f.d(A, "ClearCoatBlock", function() {
+ return la;
+ }), f.d(A, "RefractionBlock", function() {
+ return sc;
+ }), f.d(A, "SubSurfaceBlock", function() {
+ return ua;
+ }), f.d(A, "ParticleTextureBlock", function() {
+ return js;
+ }), f.d(A, "ParticleRampGradientBlock", function() {
+ return Hs;
+ }), f.d(A, "ParticleBlendMultiplyBlock", function() {
+ return Ws;
+ }), f.d(A, "ModBlock", function() {
+ return Yh;
+ }), f.d(A, "NodeMaterialOptimizer", function() {
+ return H_;
+ }), f.d(A, "PropertyTypeForEdition", function() {
+ return It;
+ }), f.d(A, "editableInPropertyPage", function() {
+ return Bt;
+ }), f.d(A, "EffectRenderer", function() {
+ return xu;
+ }), f.d(A, "EffectWrapper", function() {
+ return Cu;
+ }), f.d(A, "ShadowDepthWrapper", function() {
+ return Y_;
+ }), f.d(A, "Scalar", function() {
+ return $.a;
+ }), f.d(A, "extractMinAndMaxIndexed", function() {
+ return Kh.b;
+ }), f.d(A, "extractMinAndMax", function() {
+ return Kh.a;
+ }), f.d(A, "Space", function() {
+ return be.c;
+ }), f.d(A, "Axis", function() {
+ return be.a;
+ }), f.d(A, "Coordinate", function() {
+ return be.b;
+ }), f.d(A, "Color3", function() {
+ return I.a;
+ }), f.d(A, "Color4", function() {
+ return I.b;
+ }), f.d(A, "TmpColors", function() {
+ return I.c;
+ }), f.d(A, "ToGammaSpace", function() {
+ return Vt.b;
+ }), f.d(A, "ToLinearSpace", function() {
+ return Vt.c;
+ }), f.d(A, "Epsilon", function() {
+ return Vt.a;
+ }), f.d(A, "Frustum", function() {
+ return Pl.a;
+ }), f.d(A, "Orientation", function() {
+ return Qe.e;
+ }), f.d(A, "BezierCurve", function() {
+ return Qe.c;
+ }), f.d(A, "Angle", function() {
+ return Qe.a;
+ }), f.d(A, "Arc2", function() {
+ return Qe.b;
+ }), f.d(A, "Path2", function() {
+ return Qe.f;
+ }), f.d(A, "Path3D", function() {
+ return Qe.g;
+ }), f.d(A, "Curve3", function() {
+ return Qe.d;
+ }), f.d(A, "Plane", function() {
+ return ur.a;
+ }), f.d(A, "Size", function() {
+ return oe.a;
+ }), f.d(A, "Vector2", function() {
+ return u.d;
+ }), f.d(A, "Vector3", function() {
+ return u.e;
+ }), f.d(A, "Vector4", function() {
+ return u.f;
+ }), f.d(A, "Quaternion", function() {
+ return u.b;
+ }), f.d(A, "Matrix", function() {
+ return u.a;
+ }), f.d(A, "TmpVectors", function() {
+ return u.c;
+ }), f.d(A, "PositionNormalVertex", function() {
+ return bs;
+ }), f.d(A, "PositionNormalTextureVertex", function() {
+ return Xf;
+ }), f.d(A, "Viewport", function() {
+ return jn.a;
+ }), f.d(A, "SphericalHarmonics", function() {
+ return hs;
+ }), f.d(A, "SphericalPolynomial", function() {
+ return Yr;
+ }), f.d(A, "AbstractMesh", function() {
+ return Mt.a;
+ }), f.d(A, "Buffer", function() {
+ return Oe.a;
+ }), f.d(A, "VertexBuffer", function() {
+ return Oe.b;
+ }), f.d(A, "DracoCompression", function() {
+ return Q_;
+ }), f.d(A, "CSG", function() {
+ return J_;
+ }), f.d(A, "Geometry", function() {
+ return Ns.a;
+ }), f.d(A, "GroundMesh", function() {
+ return Do;
+ }), f.d(A, "TrailMesh", function() {
+ return $_;
+ }), f.d(A, "InstancedMesh", function() {
+ return em.a;
+ }), f.d(A, "LinesMesh", function() {
+ return ho.b;
+ }), f.d(A, "InstancedLinesMesh", function() {
+ return ho.a;
+ }), f.d(A, "_CreationDataStorage", function() {
+ return Ie.b;
+ }), f.d(A, "_InstancesBatch", function() {
+ return Ie.c;
+ }), f.d(A, "Mesh", function() {
+ return Ie.a;
+ }), f.d(A, "VertexData", function() {
+ return ht.a;
+ }), f.d(A, "MeshBuilder", function() {
+ return im;
+ }), f.d(A, "SimplificationSettings", function() {
+ return rm;
+ }), f.d(A, "SimplificationQueue", function() {
+ return ed;
+ }), f.d(A, "SimplificationType", function() {
+ return _o;
+ }), f.d(A, "QuadraticErrorSimplification", function() {
+ return nd;
+ }), f.d(A, "SimplicationQueueSceneComponent", function() {
+ return id;
+ }), f.d(A, "Polygon", function() {
+ return nm;
+ }), f.d(A, "PolygonMeshBuilder", function() {
+ return Jh;
+ }), f.d(A, "SubMesh", function() {
+ return uo.a;
+ }), f.d(A, "MeshLODLevel", function() {
+ return cm.a;
+ }), f.d(A, "TransformNode", function() {
+ return pr.a;
+ }), f.d(A, "BoxBuilder", function() {
+ return fr.a;
+ }), f.d(A, "TiledBoxBuilder", function() {
+ return Zh;
+ }), f.d(A, "DiscBuilder", function() {
+ return ha;
+ }), f.d(A, "RibbonBuilder", function() {
+ return fo.a;
+ }), f.d(A, "SphereBuilder", function() {
+ return Nn.a;
+ }), f.d(A, "HemisphereBuilder", function() {
+ return Go;
+ }), f.d(A, "CylinderBuilder", function() {
+ return ci.a;
+ }), f.d(A, "TorusBuilder", function() {
+ return lr;
+ }), f.d(A, "TorusKnotBuilder", function() {
+ return uc;
+ }), f.d(A, "LinesBuilder", function() {
+ return sn.a;
+ }), f.d(A, "PolygonBuilder", function() {
+ return po;
+ }), f.d(A, "ShapeBuilder", function() {
+ return Jo.a;
+ }), f.d(A, "LatheBuilder", function() {
+ return dc;
+ }), f.d(A, "PlaneBuilder", function() {
+ return gs.a;
+ }), f.d(A, "TiledPlaneBuilder", function() {
+ return $h;
+ }), f.d(A, "GroundBuilder", function() {
+ return Oi;
+ }), f.d(A, "TubeBuilder", function() {
+ return fc;
+ }), f.d(A, "PolyhedronBuilder", function() {
+ return Qr;
+ }), f.d(A, "IcoSphereBuilder", function() {
+ return pc;
+ }), f.d(A, "DecalBuilder", function() {
+ return _c;
+ }), f.d(A, "CapsuleBuilder", function() {
+ return mc;
+ }), f.d(A, "DataBuffer", function() {
+ return zl.a;
+ }), f.d(A, "WebGLDataBuffer", function() {
+ return lm.a;
+ }), f.d(A, "MorphTarget", function() {
+ return Ou;
+ }), f.d(A, "MorphTargetManager", function() {
+ return Zo;
+ }), f.d(A, "RecastJSPlugin", function() {
+ return um;
+ }), f.d(A, "RecastJSCrowd", function() {
+ return rd;
+ }), f.d(A, "Node", function() {
+ return Q.a;
+ }), f.d(A, "Database", function() {
+ return od;
+ }), f.d(A, "BaseParticleSystem", function() {
+ return co;
+ }), f.d(A, "BoxParticleEmitter", function() {
+ return xr;
+ }), f.d(A, "ConeParticleEmitter", function() {
+ return Ys;
+ }), f.d(A, "CylinderParticleEmitter", function() {
+ return oa;
+ }), f.d(A, "CylinderDirectedParticleEmitter", function() {
+ return Ks;
+ }), f.d(A, "HemisphericParticleEmitter", function() {
+ return Qs;
+ }), f.d(A, "PointParticleEmitter", function() {
+ return qs;
+ }), f.d(A, "SphereParticleEmitter", function() {
+ return aa;
+ }), f.d(A, "SphereDirectedParticleEmitter", function() {
+ return Zs;
+ }), f.d(A, "CustomParticleEmitter", function() {
+ return Cr;
+ }), f.d(A, "MeshParticleEmitter", function() {
+ return Ku;
+ }), f.d(A, "GPUParticleSystem", function() {
+ return Zi;
+ }), f.d(A, "Particle", function() {
+ return sd;
+ }), f.d(A, "ParticleHelper", function() {
+ return vm;
+ }), f.d(A, "ParticleSystem", function() {
+ return cn;
+ }), f.d(A, "ParticleSystemSet", function() {
+ return da;
+ }), f.d(A, "SolidParticle", function() {
+ return yc;
+ }), f.d(A, "ModelShape", function() {
+ return bc;
+ }), f.d(A, "DepthSortedParticle", function() {
+ return cd;
+ }), f.d(A, "SolidParticleVertex", function() {
+ return ld;
+ }), f.d(A, "SolidParticleSystem", function() {
+ return ym;
+ }), f.d(A, "CloudPoint", function() {
+ return ud;
+ }), f.d(A, "PointsGroup", function() {
+ return fa;
+ }), f.d(A, "PointColor", function() {
+ return bn;
+ }), f.d(A, "PointsCloudSystem", function() {
+ return bm;
+ }), f.d(A, "SubEmitterType", function() {
+ return Rr;
+ }), f.d(A, "SubEmitter", function() {
+ return mo;
+ }), f.d(A, "PhysicsEngine", function() {
+ return Sr;
+ }), f.d(A, "PhysicsEngineSceneComponent", function() {
+ return hd;
+ }), f.d(A, "PhysicsHelper", function() {
+ return Tm;
+ }), f.d(A, "PhysicsRadialExplosionEventOptions", function() {
+ return Mr;
+ }), f.d(A, "PhysicsUpdraftEventOptions", function() {
+ return Tc;
+ }), f.d(A, "PhysicsVortexEventOptions", function() {
+ return Ec;
+ }), f.d(A, "PhysicsRadialImpulseFalloff", function() {
+ return go;
+ }), f.d(A, "PhysicsUpdraftMode", function() {
+ return Or;
+ }), f.d(A, "PhysicsImpostor", function() {
+ return At.a;
+ }), f.d(A, "PhysicsJoint", function() {
+ return Jt.e;
+ }), f.d(A, "DistanceJoint", function() {
+ return Jt.a;
+ }), f.d(A, "MotorEnabledJoint", function() {
+ return Jt.d;
+ }), f.d(A, "HingeJoint", function() {
+ return Jt.c;
+ }), f.d(A, "Hinge2Joint", function() {
+ return Jt.b;
+ }), f.d(A, "CannonJSPlugin", function() {
+ return Bs;
+ }), f.d(A, "AmmoJSPlugin", function() {
+ return Iu;
+ }), f.d(A, "OimoJSPlugin", function() {
+ return Mu;
+ }), f.d(A, "AnaglyphPostProcess", function() {
+ return Ja;
+ }), f.d(A, "BlackAndWhitePostProcess", function() {
+ return fd;
+ }), f.d(A, "BloomEffect", function() {
+ return Pc;
+ }), f.d(A, "BloomMergePostProcess", function() {
+ return Ac;
+ }), f.d(A, "BlurPostProcess", function() {
+ return _n;
+ }), f.d(A, "ChromaticAberrationPostProcess", function() {
+ return xc;
+ }), f.d(A, "CircleOfConfusionPostProcess", function() {
+ return Cc;
+ }), f.d(A, "ColorCorrectionPostProcess", function() {
+ return pd;
+ }), f.d(A, "ConvolutionPostProcess", function() {
+ return _d;
+ }), f.d(A, "DepthOfFieldBlurPostProcess", function() {
+ return pa;
+ }), f.d(A, "DepthOfFieldEffectBlurLevel", function() {
+ return Ji;
+ }), f.d(A, "DepthOfFieldEffect", function() {
+ return Rc;
+ }), f.d(A, "DepthOfFieldMergePostProcessOptions", function() {
+ return Lm;
+ }), f.d(A, "DepthOfFieldMergePostProcess", function() {
+ return md;
+ }), f.d(A, "DisplayPassPostProcess", function() {
+ return gd;
+ }), f.d(A, "ExtractHighlightsPostProcess", function() {
+ return Sc;
+ }), f.d(A, "FilterPostProcess", function() {
+ return vd;
+ }), f.d(A, "FxaaPostProcess", function() {
+ return vo;
+ }), f.d(A, "GrainPostProcess", function() {
+ return Oc;
+ }), f.d(A, "HighlightsPostProcess", function() {
+ return km;
+ }), f.d(A, "ImageProcessingPostProcess", function() {
+ return Io;
+ }), f.d(A, "MotionBlurPostProcess", function() {
+ return Mc;
+ }), f.d(A, "PassPostProcess", function() {
+ return Ci;
+ }), f.d(A, "PassCubePostProcess", function() {
+ return Tf;
+ }), f.d(A, "PostProcess", function() {
+ return ft;
+ }), f.d(A, "PostProcessManager", function() {
+ return es.a;
+ }), f.d(A, "RefractionPostProcess", function() {
+ return bd;
+ }), f.d(A, "DefaultRenderingPipeline", function() {
+ return Sd;
+ }), f.d(A, "LensRenderingPipeline", function() {
+ return Qm;
+ }), f.d(A, "SSAO2RenderingPipeline", function() {
+ return Ad;
+ }), f.d(A, "SSAORenderingPipeline", function() {
+ return eg;
+ }), f.d(A, "StandardRenderingPipeline", function() {
+ return Pd;
+ }), f.d(A, "PostProcessRenderEffect", function() {
+ return xt;
+ }), f.d(A, "PostProcessRenderPipeline", function() {
+ return Ir;
+ }), f.d(A, "PostProcessRenderPipelineManager", function() {
+ return Td;
+ }), f.d(A, "PostProcessRenderPipelineManagerSceneComponent", function() {
+ return Ed;
+ }), f.d(A, "SharpenPostProcess", function() {
+ return Ic;
+ }), f.d(A, "StereoscopicInterlacePostProcessI", function() {
+ return og;
+ }), f.d(A, "StereoscopicInterlacePostProcess", function() {
+ return ag;
+ }), f.d(A, "TonemappingOperator", function() {
+ return $i;
+ }), f.d(A, "TonemapPostProcess", function() {
+ return cg;
+ }), f.d(A, "VolumetricLightScatteringPostProcess", function() {
+ return xd;
+ }), f.d(A, "VRDistortionCorrectionPostProcess", function() {
+ return $a;
+ }), f.d(A, "VRMultiviewToSingleviewPostProcess", function() {
+ return ts;
+ }), f.d(A, "ScreenSpaceReflectionPostProcess", function() {
+ return Dc;
+ }), f.d(A, "ScreenSpaceCurvaturePostProcess", function() {
+ return Cd;
+ }), f.d(A, "ReflectionProbe", function() {
+ return Du;
+ }), f.d(A, "BoundingBoxRenderer", function() {
+ return Rd;
+ }), f.d(A, "DepthRenderer", function() {
+ return Qo;
+ }), f.d(A, "DepthRendererSceneComponent", function() {
+ return Od;
+ }), f.d(A, "EdgesRenderer", function() {
+ return Lc;
+ }), f.d(A, "LineEdgesRenderer", function() {
+ return Md;
+ }), f.d(A, "GeometryBufferRenderer", function() {
+ return ri;
+ }), f.d(A, "GeometryBufferRendererSceneComponent", function() {
+ return yd;
+ }), f.d(A, "PrePassRenderer", function() {
+ return Nc;
+ }), f.d(A, "PrePassRendererSceneComponent", function() {
+ return Id;
+ }), f.d(A, "SubSurfaceSceneComponent", function() {
+ return Ld;
+ }), f.d(A, "OutlineRenderer", function() {
+ return Nd;
+ }), f.d(A, "RenderingGroup", function() {
+ return Tg.a;
+ }), f.d(A, "RenderingGroupInfo", function() {
+ return Hr.a;
+ }), f.d(A, "RenderingManager", function() {
+ return Hr.b;
+ }), f.d(A, "UtilityLayerRenderer", function() {
+ return Cn.a;
+ }), f.d(A, "Scene", function() {
+ return _e.a;
+ }), f.d(A, "SceneComponentConstants", function() {
+ return ot.a;
+ }), f.d(A, "Stage", function() {
+ return ot.b;
+ }), f.d(A, "Sprite", function() {
+ return wd;
+ }), f.d(A, "SpriteManager", function() {
+ return Bd;
+ }), f.d(A, "SpriteMap", function() {
+ return Cg;
+ }), f.d(A, "SpritePackedManager", function() {
+ return Rg;
+ }), f.d(A, "SpriteSceneComponent", function() {
+ return Fd;
+ }), f.d(A, "AlphaState", function() {
+ return Og.a;
+ }), f.d(A, "DepthCullingState", function() {
+ return Mg.a;
+ }), f.d(A, "StencilState", function() {
+ return Ig.a;
+ }), f.d(A, "AndOrNotEvaluator", function() {
+ return Dg.a;
+ }), f.d(A, "AssetTaskState", function() {
+ return ui;
+ }), f.d(A, "AbstractAssetTask", function() {
+ return hi;
+ }), f.d(A, "AssetsProgressEvent", function() {
+ return Ud;
+ }), f.d(A, "ContainerAssetTask", function() {
+ return Vd;
+ }), f.d(A, "MeshAssetTask", function() {
+ return kd;
+ }), f.d(A, "TextFileAssetTask", function() {
+ return Gd;
+ }), f.d(A, "BinaryFileAssetTask", function() {
+ return zd;
+ }), f.d(A, "ImageAssetTask", function() {
+ return jd;
+ }), f.d(A, "TextureAssetTask", function() {
+ return Hd;
+ }), f.d(A, "CubeTextureAssetTask", function() {
+ return Wd;
+ }), f.d(A, "HDRCubeTextureAssetTask", function() {
+ return Xd;
+ }), f.d(A, "EquiRectangularCubeTextureAssetTask", function() {
+ return Yd;
+ }), f.d(A, "AssetsManager", function() {
+ return Lg;
+ }), f.d(A, "BasisTranscodeConfiguration", function() {
+ return M_;
+ }), f.d(A, "BasisTools", function() {
+ return ro;
+ }), f.d(A, "DDSTools", function() {
+ return Di;
+ }), f.d(A, "expandToProperty", function() {
+ return L.b;
+ }), f.d(A, "serialize", function() {
+ return L.c;
+ }), f.d(A, "serializeAsTexture", function() {
+ return L.m;
+ }), f.d(A, "serializeAsColor3", function() {
+ return L.e;
+ }), f.d(A, "serializeAsFresnelParameters", function() {
+ return L.h;
+ }), f.d(A, "serializeAsVector2", function() {
+ return L.n;
+ }), f.d(A, "serializeAsVector3", function() {
+ return L.o;
+ }), f.d(A, "serializeAsMeshReference", function() {
+ return L.k;
+ }), f.d(A, "serializeAsColorCurves", function() {
+ return L.g;
+ }), f.d(A, "serializeAsColor4", function() {
+ return L.f;
+ }), f.d(A, "serializeAsImageProcessingConfiguration", function() {
+ return L.i;
+ }), f.d(A, "serializeAsQuaternion", function() {
+ return L.l;
+ }), f.d(A, "serializeAsMatrix", function() {
+ return L.j;
+ }), f.d(A, "serializeAsCameraReference", function() {
+ return L.d;
+ }), f.d(A, "SerializationHelper", function() {
+ return L.a;
+ }), f.d(A, "Deferred", function() {
+ return Ng;
+ }), f.d(A, "EnvironmentTextureTools", function() {
+ return gi;
+ }), f.d(A, "MeshExploder", function() {
+ return wg;
+ }), f.d(A, "FilesInput", function() {
+ return Fg;
+ }), f.d(A, "CubeMapToSphericalPolynomialTools", function() {
+ return Lo;
+ }), f.d(A, "HDRTools", function() {
+ return Pu;
+ }), f.d(A, "PanoramaToCubeMapTools", function() {
+ return ws;
+ }), f.d(A, "KhronosTextureContainer", function() {
+ return Yo;
+ }), f.d(A, "EventState", function() {
+ return C.a;
+ }), f.d(A, "Observer", function() {
+ return C.d;
+ }), f.d(A, "MultiObserver", function() {
+ return C.b;
+ }), f.d(A, "Observable", function() {
+ return C.c;
+ }), f.d(A, "PerformanceMonitor", function() {
+ return Kd.a;
+ }), f.d(A, "RollingAverage", function() {
+ return Kd.b;
+ }), f.d(A, "PromisePolyfill", function() {
+ return Bg.a;
+ }), f.d(A, "SceneOptimization", function() {
+ return di;
+ }), f.d(A, "TextureOptimization", function() {
+ return _a;
+ }), f.d(A, "HardwareScalingOptimization", function() {
+ return Fc;
+ }), f.d(A, "ShadowsOptimization", function() {
+ return ma;
+ }), f.d(A, "PostProcessesOptimization", function() {
+ return ga;
+ }), f.d(A, "LensFlaresOptimization", function() {
+ return va;
+ }), f.d(A, "CustomOptimization", function() {
+ return Qd;
+ }), f.d(A, "ParticlesOptimization", function() {
+ return ya;
+ }), f.d(A, "RenderTargetsOptimization", function() {
+ return Bc;
+ }), f.d(A, "MergeMeshesOptimization", function() {
+ return ba;
+ }), f.d(A, "SceneOptimizerOptions", function() {
+ return Uc;
+ }), f.d(A, "SceneOptimizer", function() {
+ return Ug;
+ }), f.d(A, "SceneSerializer", function() {
+ return kc;
+ }), f.d(A, "SmartArray", function() {
+ return si.a;
+ }), f.d(A, "SmartArrayNoDuplicate", function() {
+ return si.b;
+ }), f.d(A, "StringDictionary", function() {
+ return rl.a;
+ }), f.d(A, "Tags", function() {
+ return Vg.a;
+ }), f.d(A, "TextureTools", function() {
+ return kg;
+ }), f.d(A, "TGATools", function() {
+ return ta;
+ }), f.d(A, "Tools", function() {
+ return Xe.b;
+ }), f.d(A, "className", function() {
+ return Xe.c;
+ }), f.d(A, "AsyncLoop", function() {
+ return Xe.a;
+ }), f.d(A, "VideoRecorder", function() {
+ return Gg;
+ }), f.d(A, "JoystickAxis", function() {
+ return rn;
+ }), f.d(A, "VirtualJoystick", function() {
+ return Ka;
+ }), f.d(A, "WorkerPool", function() {
+ return xs;
+ }), f.d(A, "Logger", function() {
+ return l.a;
+ }), f.d(A, "_TypeStore", function() {
+ return O.a;
+ }), f.d(A, "FilesInputStore", function() {
+ return fs.a;
+ }), f.d(A, "DeepCopier", function() {
+ return de.a;
+ }), f.d(A, "PivotTools", function() {
+ return Un.a;
+ }), f.d(A, "PrecisionDate", function() {
+ return ye.a;
+ }), f.d(A, "ScreenshotTools", function() {
+ return yo;
+ }), f.d(A, "WebRequest", function() {
+ return re.a;
+ }), f.d(A, "InspectableType", function() {
+ return wc;
+ }), f.d(A, "BRDFTextureTools", function() {
+ return Ho;
+ }), f.d(A, "RGBDTextureTools", function() {
+ return ql;
+ }), f.d(A, "ColorGradient", function() {
+ return gc;
+ }), f.d(A, "Color3Gradient", function() {
+ return ad;
+ }), f.d(A, "FactorGradient", function() {
+ return vc;
+ }), f.d(A, "GradientHelper", function() {
+ return On;
+ }), f.d(A, "PerfCounter", function() {
+ return Gn.a;
+ }), f.d(A, "RetryStrategy", function() {
+ return zg.a;
+ }), f.d(A, "CanvasGenerator", function() {
+ return ns.a;
+ }), f.d(A, "LoadFileError", function() {
+ return Xr.b;
+ }), f.d(A, "RequestFileError", function() {
+ return Xr.d;
+ }), f.d(A, "ReadFileError", function() {
+ return Xr.c;
+ }), f.d(A, "FileTools", function() {
+ return Xr.a;
+ }), f.d(A, "StringTools", function() {
+ return Hn.a;
+ }), f.d(A, "DataReader", function() {
+ return jg;
+ }), f.d(A, "MinMaxReducer", function() {
+ return yu;
+ }), f.d(A, "DepthReducer", function() {
+ return bu;
+ }), f.d(A, "DataStorage", function() {
+ return Hg;
+ }), f.d(A, "SceneRecorder", function() {
+ return Wg;
+ }), f.d(A, "KhronosTextureContainer2", function() {
+ return Cs;
+ }), f.d(A, "Trajectory", function() {
+ return Xg;
+ }), f.d(A, "TrajectoryClassifier", function() {
+ return Yg;
+ }), f.d(A, "TimerState", function() {
+ return Li;
+ }), f.d(A, "setAndStartTimer", function() {
+ return Os;
+ }), f.d(A, "AdvancedTimer", function() {
+ return Kp;
+ }), f.d(A, "CopyTools", function() {
+ return Kg.a;
+ }), f.d(A, "WebXRCamera", function() {
+ return iu;
+ }), f.d(A, "WebXREnterExitUIButton", function() {
+ return cu;
+ }), f.d(A, "WebXREnterExitUIOptions", function() {
+ return Yp;
+ }), f.d(A, "WebXREnterExitUI", function() {
+ return lu;
+ }), f.d(A, "WebXRExperienceHelper", function() {
+ return ru;
+ }), f.d(A, "WebXRInput", function() {
+ return su;
+ }), f.d(A, "WebXRInputSource", function() {
+ return au;
+ }), f.d(A, "WebXRManagedOutputCanvasOptions", function() {
+ return is;
+ }), f.d(A, "WebXRManagedOutputCanvas", function() {
+ return Rl;
+ }), f.d(A, "WebXRState", function() {
+ return fn;
+ }), f.d(A, "WebXRTrackingState", function() {
+ return Xi;
+ }), f.d(A, "WebXRSessionManager", function() {
+ return rs;
+ }), f.d(A, "WebXRDefaultExperienceOptions", function() {
+ return Qp;
+ }), f.d(A, "WebXRDefaultExperience", function() {
+ return uu;
+ }), f.d(A, "WebXRFeatureName", function() {
+ return ti;
+ }), f.d(A, "WebXRFeaturesManager", function() {
+ return Wn;
+ }), f.d(A, "WebXRAbstractFeature", function() {
+ return ni;
+ }), f.d(A, "WebXRHitTestLegacy", function() {
+ return Ea;
+ }), f.d(A, "WebXRAnchorSystem", function() {
+ return Sa;
+ }), f.d(A, "WebXRPlaneDetector", function() {
+ return Aa;
+ }), f.d(A, "WebXRBackgroundRemover", function() {
+ return Pa;
+ }), f.d(A, "WebXRMotionControllerTeleportation", function() {
+ return to;
+ }), f.d(A, "WebXRControllerPointerSelection", function() {
+ return eo;
+ }), f.d(A, "IWebXRControllerPhysicsOptions", function() {
+ return Zg;
+ }), f.d(A, "WebXRControllerPhysics", function() {
+ return xa;
+ }), f.d(A, "WebXRHitTest", function() {
+ return Ca;
+ }), f.d(A, "WebXRFeaturePointSystem", function() {
+ return Ra;
+ }), f.d(A, "WebXRHand", function() {
+ return $d;
+ }), f.d(A, "WebXRHandTracking", function() {
+ return Oa;
+ }), f.d(A, "WebXRAbstractMotionController", function() {
+ return br;
+ }), f.d(A, "WebXRControllerComponent", function() {
+ return yr;
+ }), f.d(A, "WebXRGenericTriggerMotionController", function() {
+ return Rs;
+ }), f.d(A, "WebXRMicrosoftMixedRealityController", function() {
+ return ef;
+ }), f.d(A, "WebXRMotionControllerManager", function() {
+ return wn;
+ }), f.d(A, "WebXROculusTouchMotionController", function() {
+ return zc;
+ }), f.d(A, "WebXRHTCViveMotionController", function() {
+ return tf;
+ }), f.d(A, "WebXRProfiledMotionController", function() {
+ return ou;
+ });
+ var V = f(35), _ = f(91), C = f(6), u = f(0), I = f(9), O = f(11), x = function() {
+ function r(t, e) {
+ this.triggerOptions = t, this.onBeforeExecuteObservable = new C.c(), t.parameter ? (this.trigger = t.trigger, this._triggerParameter = t.parameter) : t.trigger ? this.trigger = t.trigger : this.trigger = t, this._nextActiveAction = this, this._condition = e;
+ }
+ return r.prototype._prepare = function() {
+ }, r.prototype.getTriggerParameter = function() {
+ return this._triggerParameter;
+ }, r.prototype._executeCurrent = function(t) {
+ if (this._nextActiveAction._condition) {
+ var e = this._nextActiveAction._condition, n = this._actionManager.getScene().getRenderId();
+ if (e._evaluationId === n) {
+ if (!e._currentResult)
+ return;
+ } else {
+ if (e._evaluationId = n, !e.isValid())
+ return void (e._currentResult = !1);
+ e._currentResult = !0;
+ }
+ }
+ this.onBeforeExecuteObservable.notifyObservers(this), this._nextActiveAction.execute(t), this.skipToNextActiveAction();
+ }, r.prototype.execute = function(t) {
+ }, r.prototype.skipToNextActiveAction = function() {
+ this._nextActiveAction._child ? (this._nextActiveAction._child._actionManager || (this._nextActiveAction._child._actionManager = this._actionManager), this._nextActiveAction = this._nextActiveAction._child) : this._nextActiveAction = this;
+ }, r.prototype.then = function(t) {
+ return this._child = t, t._actionManager = this._actionManager, t._prepare(), t;
+ }, r.prototype._getProperty = function(t) {
+ return this._actionManager._getProperty(t);
+ }, r.prototype._getEffectiveTarget = function(t, e) {
+ return this._actionManager._getEffectiveTarget(t, e);
+ }, r.prototype.serialize = function(t) {
+ }, r.prototype._serialize = function(t, e) {
+ var n = { type: 1, children: [], name: t.name, properties: t.properties || [] };
+ if (this._child && this._child.serialize(n), this._condition) {
+ var i = this._condition.serialize();
+ return i.children.push(n), e && e.children.push(i), i;
+ }
+ return e && e.children.push(n), n;
+ }, r._SerializeValueAsString = function(t) {
+ return typeof t == "number" ? t.toString() : typeof t == "boolean" ? t ? "true" : "false" : t instanceof u.d ? t.x + ", " + t.y : t instanceof u.e ? t.x + ", " + t.y + ", " + t.z : t instanceof I.a ? t.r + ", " + t.g + ", " + t.b : t instanceof I.b ? t.r + ", " + t.g + ", " + t.b + ", " + t.a : t;
+ }, r._GetTargetProperty = function(t) {
+ return { name: "target", targetType: t._isMesh ? "MeshProperties" : t._isLight ? "LightProperties" : t._isCamera ? "CameraProperties" : "SceneProperties", value: t._isScene ? "Scene" : t.name };
+ }, r;
+ }();
+ O.a.RegisteredTypes["BABYLON.Action"] = x;
+ var m = f(47), c = f(1), T = function() {
+ function r(t) {
+ this._actionManager = t;
+ }
+ return r.prototype.isValid = function() {
+ return !0;
+ }, r.prototype._getProperty = function(t) {
+ return this._actionManager._getProperty(t);
+ }, r.prototype._getEffectiveTarget = function(t, e) {
+ return this._actionManager._getEffectiveTarget(t, e);
+ }, r.prototype.serialize = function() {
+ }, r.prototype._serialize = function(t) {
+ return { type: 2, children: [], name: t.name, properties: t.properties };
+ }, r;
+ }(), S = function(r) {
+ function t(e, n, i, o, a) {
+ a === void 0 && (a = t.IsEqual);
+ var s = r.call(this, e) || this;
+ return s.propertyPath = i, s.value = o, s.operator = a, s._target = n, s._effectiveTarget = s._getEffectiveTarget(n, s.propertyPath), s._property = s._getProperty(s.propertyPath), s;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t, "IsEqual", { get: function() {
+ return t._IsEqual;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "IsDifferent", { get: function() {
+ return t._IsDifferent;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "IsGreater", { get: function() {
+ return t._IsGreater;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t, "IsLesser", { get: function() {
+ return t._IsLesser;
+ }, enumerable: !1, configurable: !0 }), t.prototype.isValid = function() {
+ switch (this.operator) {
+ case t.IsGreater:
+ return this._effectiveTarget[this._property] > this.value;
+ case t.IsLesser:
+ return this._effectiveTarget[this._property] < this.value;
+ case t.IsEqual:
+ case t.IsDifferent:
+ var e;
+ return e = this.value.equals ? this.value.equals(this._effectiveTarget[this._property]) : this.value === this._effectiveTarget[this._property], this.operator === t.IsEqual ? e : !e;
+ }
+ return !1;
+ }, t.prototype.serialize = function() {
+ return this._serialize({ name: "ValueCondition", properties: [x._GetTargetProperty(this._target), { name: "propertyPath", value: this.propertyPath }, { name: "value", value: x._SerializeValueAsString(this.value) }, { name: "operator", value: t.GetOperatorName(this.operator) }] });
+ }, t.GetOperatorName = function(e) {
+ switch (e) {
+ case t._IsEqual:
+ return "IsEqual";
+ case t._IsDifferent:
+ return "IsDifferent";
+ case t._IsGreater:
+ return "IsGreater";
+ case t._IsLesser:
+ return "IsLesser";
+ default:
+ return "";
+ }
+ }, t._IsEqual = 0, t._IsDifferent = 1, t._IsGreater = 2, t._IsLesser = 3, t;
+ }(T), E = function(r) {
+ function t(e, n) {
+ var i = r.call(this, e) || this;
+ return i.predicate = n, i;
+ }
+ return Object(c.d)(t, r), t.prototype.isValid = function() {
+ return this.predicate();
+ }, t;
+ }(T), g = function(r) {
+ function t(e, n, i) {
+ var o = r.call(this, e) || this;
+ return o.value = i, o._target = n, o;
+ }
+ return Object(c.d)(t, r), t.prototype.isValid = function() {
+ return this._target.state === this.value;
+ }, t.prototype.serialize = function() {
+ return this._serialize({ name: "StateCondition", properties: [x._GetTargetProperty(this._target), { name: "value", value: this.value }] });
+ }, t;
+ }(T);
+ O.a.RegisteredTypes["BABYLON.ValueCondition"] = S, O.a.RegisteredTypes["BABYLON.PredicateCondition"] = E, O.a.RegisteredTypes["BABYLON.StateCondition"] = g;
+ var l = f(8), h = f(2), v = function(r) {
+ function t(e, n, i, o) {
+ var a = r.call(this, e, o) || this;
+ return a.propertyPath = i, a._target = a._effectiveTarget = n, a;
+ }
+ return Object(c.d)(t, r), t.prototype._prepare = function() {
+ this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath), this._property = this._getProperty(this.propertyPath);
+ }, t.prototype.execute = function() {
+ this._effectiveTarget[this._property] = !this._effectiveTarget[this._property];
+ }, t.prototype.serialize = function(e) {
+ return r.prototype._serialize.call(this, { name: "SwitchBooleanAction", properties: [x._GetTargetProperty(this._target), { name: "propertyPath", value: this.propertyPath }] }, e);
+ }, t;
+ }(x), b = function(r) {
+ function t(e, n, i, o) {
+ var a = r.call(this, e, o) || this;
+ return a.value = i, a._target = n, a;
+ }
+ return Object(c.d)(t, r), t.prototype.execute = function() {
+ this._target.state = this.value;
+ }, t.prototype.serialize = function(e) {
+ return r.prototype._serialize.call(this, { name: "SetStateAction", properties: [x._GetTargetProperty(this._target), { name: "value", value: this.value }] }, e);
+ }, t;
+ }(x), D = function(r) {
+ function t(e, n, i, o, a) {
+ var s = r.call(this, e, a) || this;
+ return s.propertyPath = i, s.value = o, s._target = s._effectiveTarget = n, s;
+ }
+ return Object(c.d)(t, r), t.prototype._prepare = function() {
+ this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath), this._property = this._getProperty(this.propertyPath);
+ }, t.prototype.execute = function() {
+ this._effectiveTarget[this._property] = this.value, this._target.markAsDirty && this._target.markAsDirty(this._property);
+ }, t.prototype.serialize = function(e) {
+ return r.prototype._serialize.call(this, { name: "SetValueAction", properties: [x._GetTargetProperty(this._target), { name: "propertyPath", value: this.propertyPath }, { name: "value", value: x._SerializeValueAsString(this.value) }] }, e);
+ }, t;
+ }(x), w = function(r) {
+ function t(e, n, i, o, a) {
+ var s = r.call(this, e, a) || this;
+ return s.propertyPath = i, s.value = o, s._target = s._effectiveTarget = n, s;
+ }
+ return Object(c.d)(t, r), t.prototype._prepare = function() {
+ this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath), this._property = this._getProperty(this.propertyPath), typeof this._effectiveTarget[this._property] != "number" && l.a.Warn("Warning: IncrementValueAction can only be used with number values");
+ }, t.prototype.execute = function() {
+ this._effectiveTarget[this._property] += this.value, this._target.markAsDirty && this._target.markAsDirty(this._property);
+ }, t.prototype.serialize = function(e) {
+ return r.prototype._serialize.call(this, { name: "IncrementValueAction", properties: [x._GetTargetProperty(this._target), { name: "propertyPath", value: this.propertyPath }, { name: "value", value: x._SerializeValueAsString(this.value) }] }, e);
+ }, t;
+ }(x), N = function(r) {
+ function t(e, n, i, o, a, s) {
+ var d = r.call(this, e, s) || this;
+ return d.from = i, d.to = o, d.loop = a, d._target = n, d;
+ }
+ return Object(c.d)(t, r), t.prototype._prepare = function() {
+ }, t.prototype.execute = function() {
+ this._actionManager.getScene().beginAnimation(this._target, this.from, this.to, this.loop);
+ }, t.prototype.serialize = function(e) {
+ return r.prototype._serialize.call(this, { name: "PlayAnimationAction", properties: [x._GetTargetProperty(this._target), { name: "from", value: String(this.from) }, { name: "to", value: String(this.to) }, { name: "loop", value: x._SerializeValueAsString(this.loop) || !1 }] }, e);
+ }, t;
+ }(x), M = function(r) {
+ function t(e, n, i) {
+ var o = r.call(this, e, i) || this;
+ return o._target = n, o;
+ }
+ return Object(c.d)(t, r), t.prototype._prepare = function() {
+ }, t.prototype.execute = function() {
+ this._actionManager.getScene().stopAnimation(this._target);
+ }, t.prototype.serialize = function(e) {
+ return r.prototype._serialize.call(this, { name: "StopAnimationAction", properties: [x._GetTargetProperty(this._target)] }, e);
+ }, t;
+ }(x), U = function(r) {
+ function t(e, n) {
+ return e === void 0 && (e = h.a.ACTION_NothingTrigger), r.call(this, e, n) || this;
+ }
+ return Object(c.d)(t, r), t.prototype.execute = function() {
+ }, t.prototype.serialize = function(e) {
+ return r.prototype._serialize.call(this, { name: "DoNothingAction", properties: [] }, e);
+ }, t;
+ }(x), X = function(r) {
+ function t(e, n, i) {
+ var o = r.call(this, e, i) || this;
+ return o.children = n, o;
+ }
+ return Object(c.d)(t, r), t.prototype._prepare = function() {
+ for (var e = 0; e < this.children.length; e++)
+ this.children[e]._actionManager = this._actionManager, this.children[e]._prepare();
+ }, t.prototype.execute = function(e) {
+ for (var n = 0; n < this.children.length; n++)
+ this.children[n].execute(e);
+ }, t.prototype.serialize = function(e) {
+ for (var n = r.prototype._serialize.call(this, { name: "CombineAction", properties: [], combine: [] }, e), i = 0; i < this.children.length; i++)
+ n.combine.push(this.children[i].serialize(null));
+ return n;
+ }, t;
+ }(x), j = function(r) {
+ function t(e, n, i) {
+ var o = r.call(this, e, i) || this;
+ return o.func = n, o;
+ }
+ return Object(c.d)(t, r), t.prototype.execute = function(e) {
+ this.func(e);
+ }, t;
+ }(x), ne = function(r) {
+ function t(e, n, i, o) {
+ var a = r.call(this, e, o) || this;
+ return a._target = n, a._parent = i, a;
+ }
+ return Object(c.d)(t, r), t.prototype._prepare = function() {
+ }, t.prototype.execute = function() {
+ if (this._target.parent !== this._parent) {
+ var e = this._parent.getWorldMatrix().clone();
+ e.invert(), this._target.position = u.e.TransformCoordinates(this._target.position, e), this._target.parent = this._parent;
+ }
+ }, t.prototype.serialize = function(e) {
+ return r.prototype._serialize.call(this, { name: "SetParentAction", properties: [x._GetTargetProperty(this._target), x._GetTargetProperty(this._parent)] }, e);
+ }, t;
+ }(x);
+ O.a.RegisteredTypes["BABYLON.SetParentAction"] = ne, O.a.RegisteredTypes["BABYLON.ExecuteCodeAction"] = j, O.a.RegisteredTypes["BABYLON.DoNothingAction"] = U, O.a.RegisteredTypes["BABYLON.StopAnimationAction"] = M, O.a.RegisteredTypes["BABYLON.PlayAnimationAction"] = N, O.a.RegisteredTypes["BABYLON.IncrementValueAction"] = w, O.a.RegisteredTypes["BABYLON.SetValueAction"] = D, O.a.RegisteredTypes["BABYLON.SetStateAction"] = b, O.a.RegisteredTypes["BABYLON.SetParentAction"] = ne;
+ var te = f(22), de = f(41), pe = function(r) {
+ function t(e) {
+ var n = r.call(this) || this;
+ return n._scene = e || te.a.LastCreatedScene, e.actionManagers.push(n), n;
+ }
+ return Object(c.d)(t, r), t.prototype.dispose = function() {
+ for (var e = this._scene.actionManagers.indexOf(this), n = 0; n < this.actions.length; n++) {
+ var i = this.actions[n];
+ t.Triggers[i.trigger]--, t.Triggers[i.trigger] === 0 && delete t.Triggers[i.trigger];
+ }
+ e > -1 && this._scene.actionManagers.splice(e, 1);
+ }, t.prototype.getScene = function() {
+ return this._scene;
+ }, t.prototype.hasSpecificTriggers = function(e) {
+ for (var n = 0; n < this.actions.length; n++) {
+ var i = this.actions[n];
+ if (e.indexOf(i.trigger) > -1)
+ return !0;
+ }
+ return !1;
+ }, t.prototype.hasSpecificTriggers2 = function(e, n) {
+ for (var i = 0; i < this.actions.length; i++) {
+ var o = this.actions[i];
+ if (e == o.trigger || n == o.trigger)
+ return !0;
+ }
+ return !1;
+ }, t.prototype.hasSpecificTrigger = function(e, n) {
+ for (var i = 0; i < this.actions.length; i++) {
+ var o = this.actions[i];
+ if (o.trigger === e && (!n || n(o.getTriggerParameter())))
+ return !0;
+ }
+ return !1;
+ }, Object.defineProperty(t.prototype, "hasPointerTriggers", { get: function() {
+ for (var e = 0; e < this.actions.length; e++) {
+ var n = this.actions[e];
+ if (n.trigger >= t.OnPickTrigger && n.trigger <= t.OnPointerOutTrigger)
+ return !0;
+ }
+ return !1;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hasPickTriggers", { get: function() {
+ for (var e = 0; e < this.actions.length; e++) {
+ var n = this.actions[e];
+ if (n.trigger >= t.OnPickTrigger && n.trigger <= t.OnPickUpTrigger)
+ return !0;
+ }
+ return !1;
+ }, enumerable: !1, configurable: !0 }), t.prototype.registerAction = function(e) {
+ return e.trigger === t.OnEveryFrameTrigger && this.getScene().actionManager !== this ? (l.a.Warn("OnEveryFrameTrigger can only be used with scene.actionManager"), null) : (this.actions.push(e), t.Triggers[e.trigger] ? t.Triggers[e.trigger]++ : t.Triggers[e.trigger] = 1, e._actionManager = this, e._prepare(), e);
+ }, t.prototype.unregisterAction = function(e) {
+ var n = this.actions.indexOf(e);
+ return n !== -1 && (this.actions.splice(n, 1), t.Triggers[e.trigger] -= 1, t.Triggers[e.trigger] === 0 && delete t.Triggers[e.trigger], e._actionManager = null, !0);
+ }, t.prototype.processTrigger = function(e, n) {
+ for (var i = 0; i < this.actions.length; i++) {
+ var o = this.actions[i];
+ if (o.trigger === e) {
+ if (n && (e === t.OnKeyUpTrigger || e === t.OnKeyDownTrigger)) {
+ var a = o.getTriggerParameter();
+ if (a && a !== n.sourceEvent.keyCode) {
+ if (!a.toLowerCase)
+ continue;
+ var s = a.toLowerCase();
+ if (s !== n.sourceEvent.key) {
+ var d = n.sourceEvent.charCode ? n.sourceEvent.charCode : n.sourceEvent.keyCode;
+ if (String.fromCharCode(d).toLowerCase() !== s)
+ continue;
+ }
+ }
+ }
+ o._executeCurrent(n);
+ }
+ }
+ }, t.prototype._getEffectiveTarget = function(e, n) {
+ for (var i = n.split("."), o = 0; o < i.length - 1; o++)
+ e = e[i[o]];
+ return e;
+ }, t.prototype._getProperty = function(e) {
+ var n = e.split(".");
+ return n[n.length - 1];
+ }, t.prototype.serialize = function(e) {
+ for (var n = { children: new Array(), name: e, type: 3, properties: new Array() }, i = 0; i < this.actions.length; i++) {
+ var o = { type: 0, children: new Array(), name: t.GetTriggerName(this.actions[i].trigger), properties: new Array() }, a = this.actions[i].triggerOptions;
+ if (a && typeof a != "number")
+ if (a.parameter instanceof Node)
+ o.properties.push(x._GetTargetProperty(a.parameter));
+ else {
+ var s = {};
+ de.a.DeepCopy(a.parameter, s, ["mesh"]), a.parameter && a.parameter.mesh && (s._meshId = a.parameter.mesh.id), o.properties.push({ name: "parameter", targetType: null, value: s });
+ }
+ this.actions[i].serialize(o), n.children.push(o);
+ }
+ return n;
+ }, t.Parse = function(e, n, i) {
+ var o = new t(i);
+ n === null ? i.actionManager = o : n.actionManager = o;
+ for (var a = function(F, z, J, ie) {
+ if (ie === null) {
+ var se = parseFloat(z);
+ return z === "true" || z === "false" ? z === "true" : isNaN(se) ? z : se;
+ }
+ for (var ce = ie.split("."), ue = z.split(","), fe = 0; fe < ce.length; fe++)
+ J = J[ce[fe]];
+ if (typeof J == "boolean")
+ return ue[0] === "true";
+ if (typeof J == "string")
+ return ue[0];
+ var ve = new Array();
+ for (fe = 0; fe < ue.length; fe++)
+ ve.push(parseFloat(ue[fe]));
+ return J instanceof u.e ? u.e.FromArray(ve) : J instanceof u.f ? u.f.FromArray(ve) : J instanceof I.a ? I.a.FromArray(ve) : J instanceof I.b ? I.b.FromArray(ve) : parseFloat(ue[0]);
+ }, s = function(F, z, J, ie, se) {
+ if (se === void 0 && (se = null), !F.detached) {
+ var ce = new Array(), ue = null, fe = null, ve = F.combine && F.combine.length > 0;
+ if (F.type === 2 ? ce.push(o) : ce.push(z), ve) {
+ for (var Te = new Array(), Re = 0; Re < F.combine.length; Re++)
+ s(F.combine[Re], t.NothingTrigger, J, ie, Te);
+ ce.push(Te);
+ } else
+ for (var Ae = 0; Ae < F.properties.length; Ae++) {
+ var Ee = F.properties[Ae].value, Se = F.properties[Ae].name, De = F.properties[Ae].targetType;
+ Se === "target" ? Ee = ue = De !== null && De === "SceneProperties" ? i : i.getNodeByName(Ee) : Se === "parent" ? Ee = i.getNodeByName(Ee) : Se === "sound" ? i.getSoundByName && (Ee = i.getSoundByName(Ee)) : Se !== "propertyPath" ? Ee = F.type === 2 && Se === "operator" ? S[Ee] : a(0, Ee, ue, Se === "value" ? fe : null) : fe = Ee, ce.push(Ee);
+ }
+ if (se === null ? ce.push(J) : ce.push(null), F.name === "InterpolateValueAction") {
+ var xe = ce[ce.length - 2];
+ ce[ce.length - 1] = xe, ce[ce.length - 2] = J;
+ }
+ var Le = function(we, Ye) {
+ var et = O.a.GetClass("BABYLON." + we);
+ if (et) {
+ var nt = Object.create(et.prototype);
+ return nt.constructor.apply(nt, Ye), nt;
+ }
+ }(F.name, ce);
+ if (Le instanceof T && J !== null) {
+ var Me = new U(z, J);
+ ie ? ie.then(Me) : o.registerAction(Me), ie = Me;
+ }
+ for (se === null ? Le instanceof T ? (J = Le, Le = ie) : (J = null, ie ? ie.then(Le) : o.registerAction(Le)) : se.push(Le), Ae = 0; Ae < F.children.length; Ae++)
+ s(F.children[Ae], z, J, Le, null);
+ }
+ }, d = 0; d < e.children.length; d++) {
+ var p, y = e.children[d];
+ if (y.properties.length > 0) {
+ var P = y.properties[0].value, R = y.properties[0].targetType === null ? P : i.getMeshByName(P);
+ R._meshId && (R.mesh = i.getMeshByID(R._meshId)), p = { trigger: t[y.name], parameter: R };
+ } else
+ p = t[y.name];
+ for (var B = 0; B < y.children.length; B++)
+ y.detached || s(y.children[B], p, null, null);
+ }
+ }, t.GetTriggerName = function(e) {
+ switch (e) {
+ case 0:
+ return "NothingTrigger";
+ case 1:
+ return "OnPickTrigger";
+ case 2:
+ return "OnLeftPickTrigger";
+ case 3:
+ return "OnRightPickTrigger";
+ case 4:
+ return "OnCenterPickTrigger";
+ case 5:
+ return "OnPickDownTrigger";
+ case 6:
+ return "OnPickUpTrigger";
+ case 7:
+ return "OnLongPressTrigger";
+ case 8:
+ return "OnPointerOverTrigger";
+ case 9:
+ return "OnPointerOutTrigger";
+ case 10:
+ return "OnEveryFrameTrigger";
+ case 11:
+ return "OnIntersectionEnterTrigger";
+ case 12:
+ return "OnIntersectionExitTrigger";
+ case 13:
+ return "OnKeyDownTrigger";
+ case 14:
+ return "OnKeyUpTrigger";
+ case 15:
+ return "OnPickOutTrigger";
+ default:
+ return "";
+ }
+ }, t.NothingTrigger = h.a.ACTION_NothingTrigger, t.OnPickTrigger = h.a.ACTION_OnPickTrigger, t.OnLeftPickTrigger = h.a.ACTION_OnLeftPickTrigger, t.OnRightPickTrigger = h.a.ACTION_OnRightPickTrigger, t.OnCenterPickTrigger = h.a.ACTION_OnCenterPickTrigger, t.OnPickDownTrigger = h.a.ACTION_OnPickDownTrigger, t.OnDoublePickTrigger = h.a.ACTION_OnDoublePickTrigger, t.OnPickUpTrigger = h.a.ACTION_OnPickUpTrigger, t.OnPickOutTrigger = h.a.ACTION_OnPickOutTrigger, t.OnLongPressTrigger = h.a.ACTION_OnLongPressTrigger, t.OnPointerOverTrigger = h.a.ACTION_OnPointerOverTrigger, t.OnPointerOutTrigger = h.a.ACTION_OnPointerOutTrigger, t.OnEveryFrameTrigger = h.a.ACTION_OnEveryFrameTrigger, t.OnIntersectionEnterTrigger = h.a.ACTION_OnIntersectionEnterTrigger, t.OnIntersectionExitTrigger = h.a.ACTION_OnIntersectionExitTrigger, t.OnKeyDownTrigger = h.a.ACTION_OnKeyDownTrigger, t.OnKeyUpTrigger = 15, t;
+ }(_.a), ae = function(r) {
+ function t(e, n, i) {
+ var o = r.call(this, e, i) || this;
+ return o._sound = n, o;
+ }
+ return Object(c.d)(t, r), t.prototype._prepare = function() {
+ }, t.prototype.execute = function() {
+ this._sound !== void 0 && this._sound.play();
+ }, t.prototype.serialize = function(e) {
+ return r.prototype._serialize.call(this, { name: "PlaySoundAction", properties: [{ name: "sound", value: this._sound.name }] }, e);
+ }, t;
+ }(x), ee = function(r) {
+ function t(e, n, i) {
+ var o = r.call(this, e, i) || this;
+ return o._sound = n, o;
+ }
+ return Object(c.d)(t, r), t.prototype._prepare = function() {
+ }, t.prototype.execute = function() {
+ this._sound !== void 0 && this._sound.stop();
+ }, t.prototype.serialize = function(e) {
+ return r.prototype._serialize.call(this, { name: "StopSoundAction", properties: [{ name: "sound", value: this._sound.name }] }, e);
+ }, t;
+ }(x);
+ O.a.RegisteredTypes["BABYLON.PlaySoundAction"] = ee, O.a.RegisteredTypes["BABYLON.StopSoundAction"] = ee;
+ var K, $ = f(14), L = f(3);
+ (function(r) {
+ r[r.STEP = 1] = "STEP";
+ })(K || (K = {}));
+ var G = function() {
+ function r(t, e, n) {
+ this.name = t, this.from = e, this.to = n;
+ }
+ return r.prototype.clone = function() {
+ return new r(this.name, this.from, this.to);
+ }, r;
+ }(), Q = f(29), oe = f(77), re = f(49), Y = function() {
+ }, k = function() {
+ function r(t, e, n, i, o, a) {
+ this.name = t, this.targetProperty = e, this.framePerSecond = n, this.dataType = i, this.loopMode = o, this.enableBlending = a, this._runtimeAnimations = new Array(), this._events = new Array(), this.blendingSpeed = 0.01, this._ranges = {}, this.targetPropertyPath = e.split("."), this.dataType = i, this.loopMode = o === void 0 ? r.ANIMATIONLOOPMODE_CYCLE : o;
+ }
+ return r._PrepareAnimation = function(t, e, n, i, o, a, s, d) {
+ var p = void 0;
+ if (!isNaN(parseFloat(o)) && isFinite(o) ? p = r.ANIMATIONTYPE_FLOAT : o instanceof u.b ? p = r.ANIMATIONTYPE_QUATERNION : o instanceof u.e ? p = r.ANIMATIONTYPE_VECTOR3 : o instanceof u.d ? p = r.ANIMATIONTYPE_VECTOR2 : o instanceof I.a ? p = r.ANIMATIONTYPE_COLOR3 : o instanceof I.b ? p = r.ANIMATIONTYPE_COLOR4 : o instanceof oe.a && (p = r.ANIMATIONTYPE_SIZE), p == null)
+ return null;
+ var y = new r(t, e, n, p, s), P = [{ frame: 0, value: o }, { frame: i, value: a }];
+ return y.setKeys(P), d !== void 0 && y.setEasingFunction(d), y;
+ }, r.CreateAnimation = function(t, e, n, i) {
+ var o = new r(t + "Animation", t, n, e, r.ANIMATIONLOOPMODE_CONSTANT);
+ return o.setEasingFunction(i), o;
+ }, r.CreateAndStartAnimation = function(t, e, n, i, o, a, s, d, p, y) {
+ var P = r._PrepareAnimation(t, n, i, o, a, s, d, p);
+ return P ? e.getScene().beginDirectAnimation(e, [P], 0, o, P.loopMode === 1, 1, y) : null;
+ }, r.CreateAndStartHierarchyAnimation = function(t, e, n, i, o, a, s, d, p, y, P) {
+ var R = r._PrepareAnimation(t, i, o, a, s, d, p, y);
+ return R ? e.getScene().beginDirectHierarchyAnimation(e, n, [R], 0, a, R.loopMode === 1, 1, P) : null;
+ }, r.CreateMergeAndStartAnimation = function(t, e, n, i, o, a, s, d, p, y) {
+ var P = r._PrepareAnimation(t, n, i, o, a, s, d, p);
+ return P ? (e.animations.push(P), e.getScene().beginAnimation(e, 0, o, P.loopMode === 1, 1, y)) : null;
+ }, r.MakeAnimationAdditive = function(t, e, n, i, o) {
+ e === void 0 && (e = 0), i === void 0 && (i = !1);
+ var a = t;
+ if (i && ((a = t.clone()).name = o || a.name), !a._keys.length)
+ return a;
+ e = e >= 0 ? e : 0;
+ var s = 0, d = a._keys[0], p = a._keys.length - 1, y = a._keys[p], P = { referenceValue: d.value, referencePosition: u.c.Vector3[0], referenceQuaternion: u.c.Quaternion[0], referenceScaling: u.c.Vector3[1], keyPosition: u.c.Vector3[2], keyQuaternion: u.c.Quaternion[1], keyScaling: u.c.Vector3[3] }, R = !1, B = d.frame, F = y.frame;
+ if (n) {
+ var z = a.getRange(n);
+ z && (B = z.from, F = z.to);
+ }
+ var J = d.frame === B, ie = y.frame === F;
+ if (a._keys.length === 1) {
+ var se = a._getKeyValue(a._keys[0]);
+ P.referenceValue = se.clone ? se.clone() : se, R = !0;
+ } else
+ e <= d.frame ? (se = a._getKeyValue(d.value), P.referenceValue = se.clone ? se.clone() : se, R = !0) : e >= y.frame && (se = a._getKeyValue(y.value), P.referenceValue = se.clone ? se.clone() : se, R = !0);
+ for (var ce = 0; !R || !J || !ie && ce < a._keys.length - 1; ) {
+ var ue = a._keys[ce], fe = a._keys[ce + 1];
+ if (!R && e >= ue.frame && e <= fe.frame) {
+ if (se = void 0, e === ue.frame)
+ se = a._getKeyValue(ue.value);
+ else if (e === fe.frame)
+ se = a._getKeyValue(fe.value);
+ else {
+ var ve = { key: ce, repeatCount: 0, loopMode: this.ANIMATIONLOOPMODE_CONSTANT };
+ se = a._interpolate(e, ve);
+ }
+ P.referenceValue = se.clone ? se.clone() : se, R = !0;
+ }
+ if (!J && B >= ue.frame && B <= fe.frame) {
+ if (B === ue.frame)
+ s = ce;
+ else if (B === fe.frame)
+ s = ce + 1;
+ else {
+ ve = { key: ce, repeatCount: 0, loopMode: this.ANIMATIONLOOPMODE_CONSTANT };
+ var Te = { frame: B, value: (se = a._interpolate(B, ve)).clone ? se.clone() : se };
+ a._keys.splice(ce + 1, 0, Te), s = ce + 1;
+ }
+ J = !0;
+ }
+ !ie && F >= ue.frame && F <= fe.frame && (F === ue.frame ? p = ce : F === fe.frame ? p = ce + 1 : (ve = { key: ce, repeatCount: 0, loopMode: this.ANIMATIONLOOPMODE_CONSTANT }, Te = { frame: F, value: (se = a._interpolate(F, ve)).clone ? se.clone() : se }, a._keys.splice(ce + 1, 0, Te), p = ce + 1), ie = !0), ce++;
+ }
+ for (a.dataType === r.ANIMATIONTYPE_QUATERNION ? P.referenceValue.normalize().conjugateInPlace() : a.dataType === r.ANIMATIONTYPE_MATRIX && (P.referenceValue.decompose(P.referenceScaling, P.referenceQuaternion, P.referencePosition), P.referenceQuaternion.normalize().conjugateInPlace()), ce = s; ce <= p; ce++)
+ if (Te = a._keys[ce], !ce || a.dataType === r.ANIMATIONTYPE_FLOAT || Te.value !== d.value)
+ switch (a.dataType) {
+ case r.ANIMATIONTYPE_MATRIX:
+ Te.value.decompose(P.keyScaling, P.keyQuaternion, P.keyPosition), P.keyPosition.subtractInPlace(P.referencePosition), P.keyScaling.divideInPlace(P.referenceScaling), P.referenceQuaternion.multiplyToRef(P.keyQuaternion, P.keyQuaternion), u.a.ComposeToRef(P.keyScaling, P.keyQuaternion, P.keyPosition, Te.value);
+ break;
+ case r.ANIMATIONTYPE_QUATERNION:
+ P.referenceValue.multiplyToRef(Te.value, Te.value);
+ break;
+ case r.ANIMATIONTYPE_VECTOR2:
+ case r.ANIMATIONTYPE_VECTOR3:
+ case r.ANIMATIONTYPE_COLOR3:
+ case r.ANIMATIONTYPE_COLOR4:
+ Te.value.subtractToRef(P.referenceValue, Te.value);
+ break;
+ case r.ANIMATIONTYPE_SIZE:
+ Te.value.width -= P.referenceValue.width, Te.value.height -= P.referenceValue.height;
+ break;
+ default:
+ Te.value -= P.referenceValue;
+ }
+ return a;
+ }, r.TransitionTo = function(t, e, n, i, o, a, s, d) {
+ if (d === void 0 && (d = null), s <= 0)
+ return n[t] = e, d && d(), null;
+ var p = o * (s / 1e3);
+ a.setKeys([{ frame: 0, value: n[t].clone ? n[t].clone() : n[t] }, { frame: p, value: e }]), n.animations || (n.animations = []), n.animations.push(a);
+ var y = i.beginAnimation(n, 0, p, !1);
+ return y.onAnimationEnd = d, y;
+ }, Object.defineProperty(r.prototype, "runtimeAnimations", { get: function() {
+ return this._runtimeAnimations;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "hasRunningRuntimeAnimations", { get: function() {
+ for (var t = 0, e = this._runtimeAnimations; t < e.length; t++)
+ if (!e[t].isStopped)
+ return !0;
+ return !1;
+ }, enumerable: !1, configurable: !0 }), r.prototype.toString = function(t) {
+ var e = "Name: " + this.name + ", property: " + this.targetProperty;
+ if (e += ", datatype: " + ["Float", "Vector3", "Quaternion", "Matrix", "Color3", "Vector2"][this.dataType], e += ", nKeys: " + (this._keys ? this._keys.length : "none"), e += ", nRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none"), t) {
+ e += ", Ranges: {";
+ var n = !0;
+ for (var i in this._ranges)
+ n && (e += ", ", n = !1), e += i;
+ e += "}";
+ }
+ return e;
+ }, r.prototype.addEvent = function(t) {
+ this._events.push(t), this._events.sort(function(e, n) {
+ return e.frame - n.frame;
+ });
+ }, r.prototype.removeEvents = function(t) {
+ for (var e = 0; e < this._events.length; e++)
+ this._events[e].frame === t && (this._events.splice(e, 1), e--);
+ }, r.prototype.getEvents = function() {
+ return this._events;
+ }, r.prototype.createRange = function(t, e, n) {
+ this._ranges[t] || (this._ranges[t] = new G(t, e, n));
+ }, r.prototype.deleteRange = function(t, e) {
+ e === void 0 && (e = !0);
+ var n = this._ranges[t];
+ if (n) {
+ if (e)
+ for (var i = n.from, o = n.to, a = this._keys.length - 1; a >= 0; a--)
+ this._keys[a].frame >= i && this._keys[a].frame <= o && this._keys.splice(a, 1);
+ this._ranges[t] = null;
+ }
+ }, r.prototype.getRange = function(t) {
+ return this._ranges[t];
+ }, r.prototype.getKeys = function() {
+ return this._keys;
+ }, r.prototype.getHighestFrame = function() {
+ for (var t = 0, e = 0, n = this._keys.length; e < n; e++)
+ t < this._keys[e].frame && (t = this._keys[e].frame);
+ return t;
+ }, r.prototype.getEasingFunction = function() {
+ return this._easingFunction;
+ }, r.prototype.setEasingFunction = function(t) {
+ this._easingFunction = t;
+ }, r.prototype.floatInterpolateFunction = function(t, e, n) {
+ return $.a.Lerp(t, e, n);
+ }, r.prototype.floatInterpolateFunctionWithTangents = function(t, e, n, i, o) {
+ return $.a.Hermite(t, e, n, i, o);
+ }, r.prototype.quaternionInterpolateFunction = function(t, e, n) {
+ return u.b.Slerp(t, e, n);
+ }, r.prototype.quaternionInterpolateFunctionWithTangents = function(t, e, n, i, o) {
+ return u.b.Hermite(t, e, n, i, o).normalize();
+ }, r.prototype.vector3InterpolateFunction = function(t, e, n) {
+ return u.e.Lerp(t, e, n);
+ }, r.prototype.vector3InterpolateFunctionWithTangents = function(t, e, n, i, o) {
+ return u.e.Hermite(t, e, n, i, o);
+ }, r.prototype.vector2InterpolateFunction = function(t, e, n) {
+ return u.d.Lerp(t, e, n);
+ }, r.prototype.vector2InterpolateFunctionWithTangents = function(t, e, n, i, o) {
+ return u.d.Hermite(t, e, n, i, o);
+ }, r.prototype.sizeInterpolateFunction = function(t, e, n) {
+ return oe.a.Lerp(t, e, n);
+ }, r.prototype.color3InterpolateFunction = function(t, e, n) {
+ return I.a.Lerp(t, e, n);
+ }, r.prototype.color4InterpolateFunction = function(t, e, n) {
+ return I.b.Lerp(t, e, n);
+ }, r.prototype._getKeyValue = function(t) {
+ return typeof t == "function" ? t() : t;
+ }, r.prototype._interpolate = function(t, e) {
+ if (e.loopMode === r.ANIMATIONLOOPMODE_CONSTANT && e.repeatCount > 0)
+ return e.highLimitValue.clone ? e.highLimitValue.clone() : e.highLimitValue;
+ var n = this._keys;
+ if (n.length === 1)
+ return this._getKeyValue(n[0].value);
+ var i = e.key;
+ if (n[i].frame >= t)
+ for (; i - 1 >= 0 && n[i].frame >= t; )
+ i--;
+ for (var o = i; o < n.length; o++) {
+ var a = n[o + 1];
+ if (a.frame >= t) {
+ e.key = o;
+ var s = n[o], d = this._getKeyValue(s.value);
+ if (s.interpolation === K.STEP)
+ return d;
+ var p = this._getKeyValue(a.value), y = s.outTangent !== void 0 && a.inTangent !== void 0, P = a.frame - s.frame, R = (t - s.frame) / P, B = this.getEasingFunction();
+ switch (B != null && (R = B.ease(R)), this.dataType) {
+ case r.ANIMATIONTYPE_FLOAT:
+ var F = y ? this.floatInterpolateFunctionWithTangents(d, s.outTangent * P, p, a.inTangent * P, R) : this.floatInterpolateFunction(d, p, R);
+ switch (e.loopMode) {
+ case r.ANIMATIONLOOPMODE_CYCLE:
+ case r.ANIMATIONLOOPMODE_CONSTANT:
+ return F;
+ case r.ANIMATIONLOOPMODE_RELATIVE:
+ return e.offsetValue * e.repeatCount + F;
+ }
+ break;
+ case r.ANIMATIONTYPE_QUATERNION:
+ var z = y ? this.quaternionInterpolateFunctionWithTangents(d, s.outTangent.scale(P), p, a.inTangent.scale(P), R) : this.quaternionInterpolateFunction(d, p, R);
+ switch (e.loopMode) {
+ case r.ANIMATIONLOOPMODE_CYCLE:
+ case r.ANIMATIONLOOPMODE_CONSTANT:
+ return z;
+ case r.ANIMATIONLOOPMODE_RELATIVE:
+ return z.addInPlace(e.offsetValue.scale(e.repeatCount));
+ }
+ return z;
+ case r.ANIMATIONTYPE_VECTOR3:
+ var J = y ? this.vector3InterpolateFunctionWithTangents(d, s.outTangent.scale(P), p, a.inTangent.scale(P), R) : this.vector3InterpolateFunction(d, p, R);
+ switch (e.loopMode) {
+ case r.ANIMATIONLOOPMODE_CYCLE:
+ case r.ANIMATIONLOOPMODE_CONSTANT:
+ return J;
+ case r.ANIMATIONLOOPMODE_RELATIVE:
+ return J.add(e.offsetValue.scale(e.repeatCount));
+ }
+ case r.ANIMATIONTYPE_VECTOR2:
+ var ie = y ? this.vector2InterpolateFunctionWithTangents(d, s.outTangent.scale(P), p, a.inTangent.scale(P), R) : this.vector2InterpolateFunction(d, p, R);
+ switch (e.loopMode) {
+ case r.ANIMATIONLOOPMODE_CYCLE:
+ case r.ANIMATIONLOOPMODE_CONSTANT:
+ return ie;
+ case r.ANIMATIONLOOPMODE_RELATIVE:
+ return ie.add(e.offsetValue.scale(e.repeatCount));
+ }
+ case r.ANIMATIONTYPE_SIZE:
+ switch (e.loopMode) {
+ case r.ANIMATIONLOOPMODE_CYCLE:
+ case r.ANIMATIONLOOPMODE_CONSTANT:
+ return this.sizeInterpolateFunction(d, p, R);
+ case r.ANIMATIONLOOPMODE_RELATIVE:
+ return this.sizeInterpolateFunction(d, p, R).add(e.offsetValue.scale(e.repeatCount));
+ }
+ case r.ANIMATIONTYPE_COLOR3:
+ switch (e.loopMode) {
+ case r.ANIMATIONLOOPMODE_CYCLE:
+ case r.ANIMATIONLOOPMODE_CONSTANT:
+ return this.color3InterpolateFunction(d, p, R);
+ case r.ANIMATIONLOOPMODE_RELATIVE:
+ return this.color3InterpolateFunction(d, p, R).add(e.offsetValue.scale(e.repeatCount));
+ }
+ case r.ANIMATIONTYPE_COLOR4:
+ switch (e.loopMode) {
+ case r.ANIMATIONLOOPMODE_CYCLE:
+ case r.ANIMATIONLOOPMODE_CONSTANT:
+ return this.color4InterpolateFunction(d, p, R);
+ case r.ANIMATIONLOOPMODE_RELATIVE:
+ return this.color4InterpolateFunction(d, p, R).add(e.offsetValue.scale(e.repeatCount));
+ }
+ case r.ANIMATIONTYPE_MATRIX:
+ switch (e.loopMode) {
+ case r.ANIMATIONLOOPMODE_CYCLE:
+ case r.ANIMATIONLOOPMODE_CONSTANT:
+ if (r.AllowMatricesInterpolation)
+ return this.matrixInterpolateFunction(d, p, R, e.workValue);
+ case r.ANIMATIONLOOPMODE_RELATIVE:
+ return d;
+ }
+ }
+ break;
+ }
+ }
+ return this._getKeyValue(n[n.length - 1].value);
+ }, r.prototype.matrixInterpolateFunction = function(t, e, n, i) {
+ return r.AllowMatrixDecomposeForInterpolation ? i ? (u.a.DecomposeLerpToRef(t, e, n, i), i) : u.a.DecomposeLerp(t, e, n) : i ? (u.a.LerpToRef(t, e, n, i), i) : u.a.Lerp(t, e, n);
+ }, r.prototype.clone = function() {
+ var t = new r(this.name, this.targetPropertyPath.join("."), this.framePerSecond, this.dataType, this.loopMode);
+ if (t.enableBlending = this.enableBlending, t.blendingSpeed = this.blendingSpeed, this._keys && t.setKeys(this._keys), this._ranges)
+ for (var e in t._ranges = {}, this._ranges) {
+ var n = this._ranges[e];
+ n && (t._ranges[e] = n.clone());
+ }
+ return t;
+ }, r.prototype.setKeys = function(t) {
+ this._keys = t.slice(0);
+ }, r.prototype.serialize = function() {
+ var t = {};
+ t.name = this.name, t.property = this.targetProperty, t.framePerSecond = this.framePerSecond, t.dataType = this.dataType, t.loopBehavior = this.loopMode, t.enableBlending = this.enableBlending, t.blendingSpeed = this.blendingSpeed;
+ var e = this.dataType;
+ t.keys = [];
+ for (var n = this.getKeys(), i = 0; i < n.length; i++) {
+ var o = n[i], a = {};
+ switch (a.frame = o.frame, e) {
+ case r.ANIMATIONTYPE_FLOAT:
+ a.values = [o.value], o.inTangent !== void 0 && a.values.push(o.inTangent), o.outTangent !== void 0 && (o.inTangent === void 0 && a.values.push(void 0), a.values.push(o.outTangent));
+ break;
+ case r.ANIMATIONTYPE_QUATERNION:
+ case r.ANIMATIONTYPE_MATRIX:
+ case r.ANIMATIONTYPE_VECTOR3:
+ case r.ANIMATIONTYPE_COLOR3:
+ case r.ANIMATIONTYPE_COLOR4:
+ a.values = o.value.asArray(), o.inTangent != null && a.values.push(o.inTangent.asArray()), o.outTangent != null && (o.inTangent === void 0 && a.values.push(void 0), a.values.push(o.outTangent.asArray()));
+ }
+ t.keys.push(a);
+ }
+ for (var s in t.ranges = [], this._ranges) {
+ var d = this._ranges[s];
+ if (d) {
+ var p = {};
+ p.name = s, p.from = d.from, p.to = d.to, t.ranges.push(p);
+ }
+ }
+ return t;
+ }, r._UniversalLerp = function(t, e, n) {
+ var i = t.constructor;
+ return i.Lerp ? i.Lerp(t, e, n) : i.Slerp ? i.Slerp(t, e, n) : t.toFixed ? t * (1 - n) + n * e : e;
+ }, r.Parse = function(t) {
+ var e, n, i = new r(t.name, t.property, t.framePerSecond, t.dataType, t.loopBehavior), o = t.dataType, a = [];
+ for (t.enableBlending && (i.enableBlending = t.enableBlending), t.blendingSpeed && (i.blendingSpeed = t.blendingSpeed), n = 0; n < t.keys.length; n++) {
+ var s, d, p = t.keys[n];
+ switch (o) {
+ case r.ANIMATIONTYPE_FLOAT:
+ e = p.values[0], p.values.length >= 1 && (s = p.values[1]), p.values.length >= 2 && (d = p.values[2]);
+ break;
+ case r.ANIMATIONTYPE_QUATERNION:
+ if (e = u.b.FromArray(p.values), p.values.length >= 8) {
+ var y = u.b.FromArray(p.values.slice(4, 8));
+ y.equals(u.b.Zero()) || (s = y);
+ }
+ if (p.values.length >= 12) {
+ var P = u.b.FromArray(p.values.slice(8, 12));
+ P.equals(u.b.Zero()) || (d = P);
+ }
+ break;
+ case r.ANIMATIONTYPE_MATRIX:
+ e = u.a.FromArray(p.values);
+ break;
+ case r.ANIMATIONTYPE_COLOR3:
+ e = I.a.FromArray(p.values);
+ break;
+ case r.ANIMATIONTYPE_COLOR4:
+ e = I.b.FromArray(p.values);
+ break;
+ case r.ANIMATIONTYPE_VECTOR3:
+ default:
+ e = u.e.FromArray(p.values);
+ }
+ var R = {};
+ R.frame = p.frame, R.value = e, s != null && (R.inTangent = s), d != null && (R.outTangent = d), a.push(R);
+ }
+ if (i.setKeys(a), t.ranges)
+ for (n = 0; n < t.ranges.length; n++)
+ e = t.ranges[n], i.createRange(e.name, e.from, e.to);
+ return i;
+ }, r.AppendSerializedAnimations = function(t, e) {
+ L.a.AppendSerializedAnimations(t, e);
+ }, r.ParseFromFileAsync = function(t, e) {
+ var n = this;
+ return new Promise(function(i, o) {
+ var a = new re.a();
+ a.addEventListener("readystatechange", function() {
+ if (a.readyState == 4)
+ if (a.status == 200) {
+ var s = JSON.parse(a.responseText);
+ if (s.length) {
+ for (var d = new Array(), p = 0, y = s; p < y.length; p++) {
+ var P = y[p];
+ d.push(n.Parse(P));
+ }
+ i(d);
+ } else
+ d = n.Parse(s), t && (d.name = t), i(d);
+ } else
+ o("Unable to load the animation");
+ }), a.open("GET", e), a.send();
+ });
+ }, r.CreateFromSnippetAsync = function(t) {
+ var e = this;
+ return new Promise(function(n, i) {
+ var o = new re.a();
+ o.addEventListener("readystatechange", function() {
+ if (o.readyState == 4)
+ if (o.status == 200) {
+ var a = JSON.parse(JSON.parse(o.responseText).jsonPayload);
+ if (a.animations) {
+ for (var s = JSON.parse(a.animations), d = new Array(), p = 0, y = s; p < y.length; p++) {
+ var P = y[p];
+ d.push(e.Parse(P));
+ }
+ n(d);
+ } else
+ s = JSON.parse(a.animation), (d = e.Parse(s)).snippetId = t, n(d);
+ } else
+ i("Unable to load the snippet " + t);
+ }), o.open("GET", e.SnippetUrl + "/" + t.replace(/#/g, "/")), o.send();
+ });
+ }, r.AllowMatricesInterpolation = !1, r.AllowMatrixDecomposeForInterpolation = !0, r.SnippetUrl = "https://snippet.babylonjs.com", r.ANIMATIONTYPE_FLOAT = 0, r.ANIMATIONTYPE_VECTOR3 = 1, r.ANIMATIONTYPE_QUATERNION = 2, r.ANIMATIONTYPE_MATRIX = 3, r.ANIMATIONTYPE_COLOR3 = 4, r.ANIMATIONTYPE_COLOR4 = 7, r.ANIMATIONTYPE_VECTOR2 = 5, r.ANIMATIONTYPE_SIZE = 6, r.ANIMATIONLOOPMODE_RELATIVE = 0, r.ANIMATIONLOOPMODE_CYCLE = 1, r.ANIMATIONLOOPMODE_CONSTANT = 2, r;
+ }();
+ O.a.RegisteredTypes["BABYLON.Animation"] = k, Q.a._AnimationRangeFactory = function(r, t, e) {
+ return new G(r, t, e);
+ };
+ var H = function(r) {
+ function t(e, n, i, o, a, s, d, p) {
+ a === void 0 && (a = 1e3);
+ var y = r.call(this, e, s) || this;
+ return y.duration = 1e3, y.onInterpolationDoneObservable = new C.c(), y.propertyPath = i, y.value = o, y.duration = a, y.stopOtherAnimations = d, y.onInterpolationDone = p, y._target = y._effectiveTarget = n, y;
+ }
+ return Object(c.d)(t, r), t.prototype._prepare = function() {
+ this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath), this._property = this._getProperty(this.propertyPath);
+ }, t.prototype.execute = function() {
+ var e, n = this, i = this._actionManager.getScene(), o = [{ frame: 0, value: this._effectiveTarget[this._property] }, { frame: 100, value: this.value }];
+ if (typeof this.value == "number")
+ e = k.ANIMATIONTYPE_FLOAT;
+ else if (this.value instanceof I.a)
+ e = k.ANIMATIONTYPE_COLOR3;
+ else if (this.value instanceof u.e)
+ e = k.ANIMATIONTYPE_VECTOR3;
+ else if (this.value instanceof u.a)
+ e = k.ANIMATIONTYPE_MATRIX;
+ else {
+ if (!(this.value instanceof u.b))
+ return void l.a.Warn("InterpolateValueAction: Unsupported type (" + typeof this.value + ")");
+ e = k.ANIMATIONTYPE_QUATERNION;
+ }
+ var a = new k("InterpolateValueAction", this._property, 1e3 / this.duration * 100, e, k.ANIMATIONLOOPMODE_CONSTANT);
+ a.setKeys(o), this.stopOtherAnimations && i.stopAnimation(this._effectiveTarget), i.beginDirectAnimation(this._effectiveTarget, [a], 0, 100, !1, 1, function() {
+ n.onInterpolationDoneObservable.notifyObservers(n), n.onInterpolationDone && n.onInterpolationDone();
+ });
+ }, t.prototype.serialize = function(e) {
+ return r.prototype._serialize.call(this, { name: "InterpolateValueAction", properties: [x._GetTargetProperty(this._target), { name: "propertyPath", value: this.propertyPath }, { name: "value", value: x._SerializeValueAsString(this.value) }, { name: "duration", value: x._SerializeValueAsString(this.duration) }, { name: "stopOtherAnimations", value: x._SerializeValueAsString(this.stopOtherAnimations) || !1 }] }, e);
+ }, t;
+ }(x);
+ O.a.RegisteredTypes["BABYLON.InterpolateValueAction"] = H;
+ var Z = Object.freeze(new u.b(0, 0, 0, 0)), W = Object.freeze(u.e.Zero()), q = Object.freeze(u.d.Zero()), he = Object.freeze(oe.a.Zero()), ge = Object.freeze(I.a.Black()), me = function() {
+ function r(t, e, n, i) {
+ var o = this;
+ if (this._events = new Array(), this._currentFrame = 0, this._originalValue = new Array(), this._originalBlendValue = null, this._offsetsCache = {}, this._highLimitsCache = {}, this._stopped = !1, this._blendingFactor = 0, this._currentValue = null, this._currentActiveTarget = null, this._directTarget = null, this._targetPath = "", this._weight = 1, this._ratioOffset = 0, this._previousDelay = 0, this._previousRatio = 0, this._targetIsArray = !1, this._animation = e, this._target = t, this._scene = n, this._host = i, this._activeTargets = [], e._runtimeAnimations.push(this), this._animationState = { key: 0, repeatCount: 0, loopMode: this._getCorrectLoopMode() }, this._animation.dataType === k.ANIMATIONTYPE_MATRIX && (this._animationState.workValue = u.a.Zero()), this._keys = this._animation.getKeys(), this._minFrame = this._keys[0].frame, this._maxFrame = this._keys[this._keys.length - 1].frame, this._minValue = this._keys[0].value, this._maxValue = this._keys[this._keys.length - 1].value, this._minFrame !== 0) {
+ var a = { frame: 0, value: this._minValue };
+ this._keys.splice(0, 0, a);
+ }
+ if (this._target instanceof Array) {
+ for (var s = 0, d = 0, p = this._target; d < p.length; d++) {
+ var y = p[d];
+ this._preparePath(y, s), this._getOriginalValues(s), s++;
+ }
+ this._targetIsArray = !0;
+ } else
+ this._preparePath(this._target), this._getOriginalValues(), this._targetIsArray = !1, this._directTarget = this._activeTargets[0];
+ var P = e.getEvents();
+ P && P.length > 0 && P.forEach(function(R) {
+ o._events.push(R._clone());
+ }), this._enableBlending = t && t.animationPropertiesOverride ? t.animationPropertiesOverride.enableBlending : this._animation.enableBlending;
+ }
+ return Object.defineProperty(r.prototype, "currentFrame", { get: function() {
+ return this._currentFrame;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "weight", { get: function() {
+ return this._weight;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "currentValue", { get: function() {
+ return this._currentValue;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "targetPath", { get: function() {
+ return this._targetPath;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "target", { get: function() {
+ return this._currentActiveTarget;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "isAdditive", { get: function() {
+ return this._host && this._host.isAdditive;
+ }, enumerable: !1, configurable: !0 }), r.prototype._preparePath = function(t, e) {
+ e === void 0 && (e = 0);
+ var n = this._animation.targetPropertyPath;
+ if (n.length > 1) {
+ for (var i = t[n[0]], o = 1; o < n.length - 1; o++)
+ i = i[n[o]];
+ this._targetPath = n[n.length - 1], this._activeTargets[e] = i;
+ } else
+ this._targetPath = n[0], this._activeTargets[e] = t;
+ }, Object.defineProperty(r.prototype, "animation", { get: function() {
+ return this._animation;
+ }, enumerable: !1, configurable: !0 }), r.prototype.reset = function(t) {
+ if (t === void 0 && (t = !1), t)
+ if (this._target instanceof Array)
+ for (var e = 0, n = 0, i = this._target; n < i.length; n++) {
+ var o = i[n];
+ this._originalValue[e] !== void 0 && this._setValue(o, this._activeTargets[e], this._originalValue[e], -1, e), e++;
+ }
+ else
+ this._originalValue[0] !== void 0 && this._setValue(this._target, this._directTarget, this._originalValue[0], -1, 0);
+ for (this._offsetsCache = {}, this._highLimitsCache = {}, this._currentFrame = 0, this._blendingFactor = 0, e = 0; e < this._events.length; e++)
+ this._events[e].isDone = !1;
+ }, r.prototype.isStopped = function() {
+ return this._stopped;
+ }, r.prototype.dispose = function() {
+ var t = this._animation.runtimeAnimations.indexOf(this);
+ t > -1 && this._animation.runtimeAnimations.splice(t, 1);
+ }, r.prototype.setValue = function(t, e) {
+ if (this._targetIsArray)
+ for (var n = 0; n < this._target.length; n++) {
+ var i = this._target[n];
+ this._setValue(i, this._activeTargets[n], t, e, n);
+ }
+ else
+ this._setValue(this._target, this._directTarget, t, e, 0);
+ }, r.prototype._getOriginalValues = function(t) {
+ var e;
+ t === void 0 && (t = 0);
+ var n = this._activeTargets[t];
+ (e = n.getRestPose && this._targetPath === "_matrix" ? n.getRestPose() : n[this._targetPath]) && e.clone ? this._originalValue[t] = e.clone() : this._originalValue[t] = e;
+ }, r.prototype._setValue = function(t, e, n, i, o) {
+ if (this._currentActiveTarget = e, this._weight = i, this._enableBlending && this._blendingFactor <= 1) {
+ if (!this._originalBlendValue) {
+ var a = e[this._targetPath];
+ a.clone ? this._originalBlendValue = a.clone() : this._originalBlendValue = a;
+ }
+ this._originalBlendValue.m ? k.AllowMatrixDecomposeForInterpolation ? this._currentValue ? u.a.DecomposeLerpToRef(this._originalBlendValue, n, this._blendingFactor, this._currentValue) : this._currentValue = u.a.DecomposeLerp(this._originalBlendValue, n, this._blendingFactor) : this._currentValue ? u.a.LerpToRef(this._originalBlendValue, n, this._blendingFactor, this._currentValue) : this._currentValue = u.a.Lerp(this._originalBlendValue, n, this._blendingFactor) : this._currentValue = k._UniversalLerp(this._originalBlendValue, n, this._blendingFactor);
+ var s = t && t.animationPropertiesOverride ? t.animationPropertiesOverride.blendingSpeed : this._animation.blendingSpeed;
+ this._blendingFactor += s;
+ } else
+ this._currentValue = n;
+ i !== -1 ? this._scene._registerTargetForLateAnimationBinding(this, this._originalValue[o]) : e[this._targetPath] = this._currentValue, t.markAsDirty && t.markAsDirty(this._animation.targetProperty);
+ }, r.prototype._getCorrectLoopMode = function() {
+ return this._target && this._target.animationPropertiesOverride ? this._target.animationPropertiesOverride.loopMode : this._animation.loopMode;
+ }, r.prototype.goToFrame = function(t) {
+ var e = this._animation.getKeys();
+ t < e[0].frame ? t = e[0].frame : t > e[e.length - 1].frame && (t = e[e.length - 1].frame);
+ var n = this._events;
+ if (n.length)
+ for (var i = 0; i < n.length; i++)
+ n[i].onlyOnce || (n[i].isDone = n[i].frame < t);
+ this._currentFrame = t;
+ var o = this._animation._interpolate(t, this._animationState);
+ this.setValue(o, -1);
+ }, r.prototype._prepareForSpeedRatioChange = function(t) {
+ var e = this._previousDelay * (this._animation.framePerSecond * t) / 1e3;
+ this._ratioOffset = this._previousRatio - e;
+ }, r.prototype.animate = function(t, e, n, i, o, a) {
+ a === void 0 && (a = -1);
+ var s = this._animation, d = s.targetPropertyPath;
+ if (!d || d.length < 1)
+ return this._stopped = !0, !1;
+ var p = !0;
+ (e < this._minFrame || e > this._maxFrame) && (e = this._minFrame), (n < this._minFrame || n > this._maxFrame) && (n = this._maxFrame);
+ var y, P, R = n - e, B = t * (s.framePerSecond * o) / 1e3 + this._ratioOffset, F = 0;
+ if (this._previousDelay = t, this._previousRatio = B, !i && n >= e && B >= R)
+ p = !1, F = s._getKeyValue(this._maxValue);
+ else if (!i && e >= n && B <= R)
+ p = !1, F = s._getKeyValue(this._minValue);
+ else if (this._animationState.loopMode !== k.ANIMATIONLOOPMODE_CYCLE) {
+ var z = n.toString() + e.toString();
+ if (!this._offsetsCache[z]) {
+ this._animationState.repeatCount = 0, this._animationState.loopMode = k.ANIMATIONLOOPMODE_CYCLE;
+ var J = s._interpolate(e, this._animationState), ie = s._interpolate(n, this._animationState);
+ switch (this._animationState.loopMode = this._getCorrectLoopMode(), s.dataType) {
+ case k.ANIMATIONTYPE_FLOAT:
+ this._offsetsCache[z] = ie - J;
+ break;
+ case k.ANIMATIONTYPE_QUATERNION:
+ this._offsetsCache[z] = ie.subtract(J);
+ break;
+ case k.ANIMATIONTYPE_VECTOR3:
+ this._offsetsCache[z] = ie.subtract(J);
+ case k.ANIMATIONTYPE_VECTOR2:
+ this._offsetsCache[z] = ie.subtract(J);
+ case k.ANIMATIONTYPE_SIZE:
+ this._offsetsCache[z] = ie.subtract(J);
+ case k.ANIMATIONTYPE_COLOR3:
+ this._offsetsCache[z] = ie.subtract(J);
+ }
+ this._highLimitsCache[z] = ie;
+ }
+ F = this._highLimitsCache[z], y = this._offsetsCache[z];
+ }
+ if (y === void 0)
+ switch (s.dataType) {
+ case k.ANIMATIONTYPE_FLOAT:
+ y = 0;
+ break;
+ case k.ANIMATIONTYPE_QUATERNION:
+ y = Z;
+ break;
+ case k.ANIMATIONTYPE_VECTOR3:
+ y = W;
+ break;
+ case k.ANIMATIONTYPE_VECTOR2:
+ y = q;
+ break;
+ case k.ANIMATIONTYPE_SIZE:
+ y = he;
+ break;
+ case k.ANIMATIONTYPE_COLOR3:
+ y = ge;
+ }
+ if (this._host && this._host.syncRoot) {
+ var se = this._host.syncRoot;
+ P = e + (n - e) * ((se.masterFrame - se.fromFrame) / (se.toFrame - se.fromFrame));
+ } else
+ P = p && R !== 0 ? e + B % R : n;
+ var ce = this._events;
+ if ((R > 0 && this.currentFrame > P || R < 0 && this.currentFrame < P) && (this._onLoop(), ce.length))
+ for (var ue = 0; ue < ce.length; ue++)
+ ce[ue].onlyOnce || (ce[ue].isDone = !1);
+ this._currentFrame = P, this._animationState.repeatCount = R === 0 ? 0 : B / R >> 0, this._animationState.highLimitValue = F, this._animationState.offsetValue = y;
+ var fe = s._interpolate(P, this._animationState);
+ if (this.setValue(fe, a), ce.length) {
+ for (ue = 0; ue < ce.length; ue++)
+ if (R > 0 && P >= ce[ue].frame && ce[ue].frame >= e || R < 0 && P <= ce[ue].frame && ce[ue].frame <= e) {
+ var ve = ce[ue];
+ ve.isDone || (ve.onlyOnce && (ce.splice(ue, 1), ue--), ve.isDone = !0, ve.action(P));
+ }
+ }
+ return p || (this._stopped = !0), p;
+ }, r;
+ }(), _e = f(20), ye = f(57), Pe = f(44), be = f(23), Fe = function(r) {
+ function t(e, n, i, o, a, s, d) {
+ i === void 0 && (i = null), o === void 0 && (o = null), a === void 0 && (a = null), s === void 0 && (s = null), d === void 0 && (d = null);
+ var p = r.call(this, e, n.getScene()) || this;
+ return p.name = e, p.children = new Array(), p.animations = new Array(), p._index = null, p._absoluteTransform = new u.a(), p._invertedAbsoluteTransform = new u.a(), p._scalingDeterminant = 1, p._worldTransform = new u.a(), p._needToDecompose = !0, p._needToCompose = !1, p._linkedTransformNode = null, p._waitingTransformNodeId = null, p._skeleton = n, p._localMatrix = o ? o.clone() : u.a.Identity(), p._restPose = a || p._localMatrix.clone(), p._bindPose = p._localMatrix.clone(), p._baseMatrix = s || p._localMatrix.clone(), p._index = d, n.bones.push(p), p.setParent(i, !1), (s || o) && p._updateDifferenceMatrix(), p;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "_matrix", { get: function() {
+ return this._compose(), this._localMatrix;
+ }, set: function(e) {
+ this._localMatrix.copyFrom(e), this._needToDecompose = !0;
+ }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
+ return "Bone";
+ }, t.prototype.getSkeleton = function() {
+ return this._skeleton;
+ }, t.prototype.getParent = function() {
+ return this._parent;
+ }, t.prototype.getChildren = function() {
+ return this.children;
+ }, t.prototype.getIndex = function() {
+ return this._index === null ? this.getSkeleton().bones.indexOf(this) : this._index;
+ }, t.prototype.setParent = function(e, n) {
+ if (n === void 0 && (n = !0), this._parent !== e) {
+ if (this._parent) {
+ var i = this._parent.children.indexOf(this);
+ i !== -1 && this._parent.children.splice(i, 1);
+ }
+ this._parent = e, this._parent && this._parent.children.push(this), n && this._updateDifferenceMatrix(), this.markAsDirty();
+ }
+ }, t.prototype.getLocalMatrix = function() {
+ return this._compose(), this._localMatrix;
+ }, t.prototype.getBaseMatrix = function() {
+ return this._baseMatrix;
+ }, t.prototype.getRestPose = function() {
+ return this._restPose;
+ }, t.prototype.setRestPose = function(e) {
+ this._restPose.copyFrom(e);
+ }, t.prototype.getBindPose = function() {
+ return this._bindPose;
+ }, t.prototype.setBindPose = function(e) {
+ this._bindPose.copyFrom(e);
+ }, t.prototype.getWorldMatrix = function() {
+ return this._worldTransform;
+ }, t.prototype.returnToRest = function() {
+ this._skeleton._numBonesWithLinkedTransformNode > 0 ? this.updateMatrix(this._restPose, !1, !1) : this.updateMatrix(this._restPose, !1, !0);
+ }, t.prototype.getInvertedAbsoluteTransform = function() {
+ return this._invertedAbsoluteTransform;
+ }, t.prototype.getAbsoluteTransform = function() {
+ return this._absoluteTransform;
+ }, t.prototype.linkTransformNode = function(e) {
+ this._linkedTransformNode && this._skeleton._numBonesWithLinkedTransformNode--, this._linkedTransformNode = e, this._linkedTransformNode && this._skeleton._numBonesWithLinkedTransformNode++;
+ }, t.prototype.getTransformNode = function() {
+ return this._linkedTransformNode;
+ }, Object.defineProperty(t.prototype, "position", { get: function() {
+ return this._decompose(), this._localPosition;
+ }, set: function(e) {
+ this._decompose(), this._localPosition.copyFrom(e), this._markAsDirtyAndCompose();
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rotation", { get: function() {
+ return this.getRotation();
+ }, set: function(e) {
+ this.setRotation(e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rotationQuaternion", { get: function() {
+ return this._decompose(), this._localRotation;
+ }, set: function(e) {
+ this.setRotationQuaternion(e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "scaling", { get: function() {
+ return this.getScale();
+ }, set: function(e) {
+ this.setScale(e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "animationPropertiesOverride", { get: function() {
+ return this._skeleton.animationPropertiesOverride;
+ }, enumerable: !1, configurable: !0 }), t.prototype._decompose = function() {
+ this._needToDecompose && (this._needToDecompose = !1, this._localScaling || (this._localScaling = u.e.Zero(), this._localRotation = u.b.Zero(), this._localPosition = u.e.Zero()), this._localMatrix.decompose(this._localScaling, this._localRotation, this._localPosition));
+ }, t.prototype._compose = function() {
+ this._needToCompose && (this._localScaling ? (this._needToCompose = !1, u.a.ComposeToRef(this._localScaling, this._localRotation, this._localPosition, this._localMatrix)) : this._needToCompose = !1);
+ }, t.prototype.updateMatrix = function(e, n, i) {
+ n === void 0 && (n = !0), i === void 0 && (i = !0), this._baseMatrix.copyFrom(e), n && this._updateDifferenceMatrix(), i ? (this._needToCompose = !1, this._localMatrix.copyFrom(e), this._markAsDirtyAndDecompose()) : this.markAsDirty();
+ }, t.prototype._updateDifferenceMatrix = function(e, n) {
+ if (n === void 0 && (n = !0), e || (e = this._baseMatrix), this._parent ? e.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform) : this._absoluteTransform.copyFrom(e), this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform), n)
+ for (var i = 0; i < this.children.length; i++)
+ this.children[i]._updateDifferenceMatrix();
+ this._scalingDeterminant = this._absoluteTransform.determinant() < 0 ? -1 : 1;
+ }, t.prototype.markAsDirty = function() {
+ this._currentRenderId++, this._childUpdateId++, this._skeleton._markAsDirty();
+ }, t.prototype._markAsDirtyAndCompose = function() {
+ this.markAsDirty(), this._needToCompose = !0;
+ }, t.prototype._markAsDirtyAndDecompose = function() {
+ this.markAsDirty(), this._needToDecompose = !0;
+ }, t.prototype.translate = function(e, n, i) {
+ n === void 0 && (n = be.c.LOCAL);
+ var o = this.getLocalMatrix();
+ if (n == be.c.LOCAL)
+ o.addAtIndex(12, e.x), o.addAtIndex(13, e.y), o.addAtIndex(14, e.z);
+ else {
+ var a = null;
+ i && (a = i.getWorldMatrix()), this._skeleton.computeAbsoluteTransforms();
+ var s = t._tmpMats[0], d = t._tmpVecs[0];
+ this._parent ? i && a ? (s.copyFrom(this._parent.getAbsoluteTransform()), s.multiplyToRef(a, s)) : s.copyFrom(this._parent.getAbsoluteTransform()) : u.a.IdentityToRef(s), s.setTranslationFromFloats(0, 0, 0), s.invert(), u.e.TransformCoordinatesToRef(e, s, d), o.addAtIndex(12, d.x), o.addAtIndex(13, d.y), o.addAtIndex(14, d.z);
+ }
+ this._markAsDirtyAndDecompose();
+ }, t.prototype.setPosition = function(e, n, i) {
+ n === void 0 && (n = be.c.LOCAL);
+ var o = this.getLocalMatrix();
+ if (n == be.c.LOCAL)
+ o.setTranslationFromFloats(e.x, e.y, e.z);
+ else {
+ var a = null;
+ i && (a = i.getWorldMatrix()), this._skeleton.computeAbsoluteTransforms();
+ var s = t._tmpMats[0], d = t._tmpVecs[0];
+ this._parent ? (i && a ? (s.copyFrom(this._parent.getAbsoluteTransform()), s.multiplyToRef(a, s)) : s.copyFrom(this._parent.getAbsoluteTransform()), s.invert()) : u.a.IdentityToRef(s), u.e.TransformCoordinatesToRef(e, s, d), o.setTranslationFromFloats(d.x, d.y, d.z);
+ }
+ this._markAsDirtyAndDecompose();
+ }, t.prototype.setAbsolutePosition = function(e, n) {
+ this.setPosition(e, be.c.WORLD, n);
+ }, t.prototype.scale = function(e, n, i, o) {
+ o === void 0 && (o = !1);
+ var a = this.getLocalMatrix(), s = t._tmpMats[0];
+ u.a.ScalingToRef(e, n, i, s), s.multiplyToRef(a, a), s.invert();
+ for (var d = 0, p = this.children; d < p.length; d++) {
+ var y = (B = p[d]).getLocalMatrix();
+ y.multiplyToRef(s, y), y.multiplyAtIndex(12, e), y.multiplyAtIndex(13, n), y.multiplyAtIndex(14, i), B._markAsDirtyAndDecompose();
+ }
+ if (this._markAsDirtyAndDecompose(), o)
+ for (var P = 0, R = this.children; P < R.length; P++) {
+ var B;
+ (B = R[P]).scale(e, n, i, o);
+ }
+ }, t.prototype.setScale = function(e) {
+ this._decompose(), this._localScaling.copyFrom(e), this._markAsDirtyAndCompose();
+ }, t.prototype.getScale = function() {
+ return this._decompose(), this._localScaling;
+ }, t.prototype.getScaleToRef = function(e) {
+ this._decompose(), e.copyFrom(this._localScaling);
+ }, t.prototype.setYawPitchRoll = function(e, n, i, o, a) {
+ if (o === void 0 && (o = be.c.LOCAL), o === be.c.LOCAL) {
+ var s = t._tmpQuat;
+ return u.b.RotationYawPitchRollToRef(e, n, i, s), void this.setRotationQuaternion(s, o, a);
+ }
+ var d = t._tmpMats[0];
+ if (this._getNegativeRotationToRef(d, a)) {
+ var p = t._tmpMats[1];
+ u.a.RotationYawPitchRollToRef(e, n, i, p), d.multiplyToRef(p, p), this._rotateWithMatrix(p, o, a);
+ }
+ }, t.prototype.rotate = function(e, n, i, o) {
+ i === void 0 && (i = be.c.LOCAL);
+ var a = t._tmpMats[0];
+ a.setTranslationFromFloats(0, 0, 0), u.a.RotationAxisToRef(e, n, a), this._rotateWithMatrix(a, i, o);
+ }, t.prototype.setAxisAngle = function(e, n, i, o) {
+ if (i === void 0 && (i = be.c.LOCAL), i === be.c.LOCAL) {
+ var a = t._tmpQuat;
+ return u.b.RotationAxisToRef(e, n, a), void this.setRotationQuaternion(a, i, o);
+ }
+ var s = t._tmpMats[0];
+ if (this._getNegativeRotationToRef(s, o)) {
+ var d = t._tmpMats[1];
+ u.a.RotationAxisToRef(e, n, d), s.multiplyToRef(d, d), this._rotateWithMatrix(d, i, o);
+ }
+ }, t.prototype.setRotation = function(e, n, i) {
+ n === void 0 && (n = be.c.LOCAL), this.setYawPitchRoll(e.y, e.x, e.z, n, i);
+ }, t.prototype.setRotationQuaternion = function(e, n, i) {
+ if (n === void 0 && (n = be.c.LOCAL), n === be.c.LOCAL)
+ return this._decompose(), this._localRotation.copyFrom(e), void this._markAsDirtyAndCompose();
+ var o = t._tmpMats[0];
+ if (this._getNegativeRotationToRef(o, i)) {
+ var a = t._tmpMats[1];
+ u.a.FromQuaternionToRef(e, a), o.multiplyToRef(a, a), this._rotateWithMatrix(a, n, i);
+ }
+ }, t.prototype.setRotationMatrix = function(e, n, i) {
+ if (n === void 0 && (n = be.c.LOCAL), n === be.c.LOCAL) {
+ var o = t._tmpQuat;
+ return u.b.FromRotationMatrixToRef(e, o), void this.setRotationQuaternion(o, n, i);
+ }
+ var a = t._tmpMats[0];
+ if (this._getNegativeRotationToRef(a, i)) {
+ var s = t._tmpMats[1];
+ s.copyFrom(e), a.multiplyToRef(e, s), this._rotateWithMatrix(s, n, i);
+ }
+ }, t.prototype._rotateWithMatrix = function(e, n, i) {
+ n === void 0 && (n = be.c.LOCAL);
+ var o = this.getLocalMatrix(), a = o.m[12], s = o.m[13], d = o.m[14], p = this.getParent(), y = t._tmpMats[3], P = t._tmpMats[4];
+ p && n == be.c.WORLD ? (i ? (y.copyFrom(i.getWorldMatrix()), p.getAbsoluteTransform().multiplyToRef(y, y)) : y.copyFrom(p.getAbsoluteTransform()), P.copyFrom(y), P.invert(), o.multiplyToRef(y, o), o.multiplyToRef(e, o), o.multiplyToRef(P, o)) : n == be.c.WORLD && i ? (y.copyFrom(i.getWorldMatrix()), P.copyFrom(y), P.invert(), o.multiplyToRef(y, o), o.multiplyToRef(e, o), o.multiplyToRef(P, o)) : o.multiplyToRef(e, o), o.setTranslationFromFloats(a, s, d), this.computeAbsoluteTransforms(), this._markAsDirtyAndDecompose();
+ }, t.prototype._getNegativeRotationToRef = function(e, n) {
+ var i = t._tmpMats[2];
+ return e.copyFrom(this.getAbsoluteTransform()), n && (e.multiplyToRef(n.getWorldMatrix(), e), u.a.ScalingToRef(n.scaling.x, n.scaling.y, n.scaling.z, i)), e.invert(), !isNaN(e.m[0]) && (i.multiplyAtIndex(0, this._scalingDeterminant), e.multiplyToRef(i, e), !0);
+ }, t.prototype.getPosition = function(e, n) {
+ e === void 0 && (e = be.c.LOCAL), n === void 0 && (n = null);
+ var i = u.e.Zero();
+ return this.getPositionToRef(e, n, i), i;
+ }, t.prototype.getPositionToRef = function(e, n, i) {
+ if (e === void 0 && (e = be.c.LOCAL), e == be.c.LOCAL) {
+ var o = this.getLocalMatrix();
+ i.x = o.m[12], i.y = o.m[13], i.z = o.m[14];
+ } else {
+ var a = null;
+ n && (a = n.getWorldMatrix()), this._skeleton.computeAbsoluteTransforms();
+ var s = t._tmpMats[0];
+ n && a ? (s.copyFrom(this.getAbsoluteTransform()), s.multiplyToRef(a, s)) : s = this.getAbsoluteTransform(), i.x = s.m[12], i.y = s.m[13], i.z = s.m[14];
+ }
+ }, t.prototype.getAbsolutePosition = function(e) {
+ e === void 0 && (e = null);
+ var n = u.e.Zero();
+ return this.getPositionToRef(be.c.WORLD, e, n), n;
+ }, t.prototype.getAbsolutePositionToRef = function(e, n) {
+ this.getPositionToRef(be.c.WORLD, e, n);
+ }, t.prototype.computeAbsoluteTransforms = function() {
+ if (this._compose(), this._parent)
+ this._localMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
+ else {
+ this._absoluteTransform.copyFrom(this._localMatrix);
+ var e = this._skeleton.getPoseMatrix();
+ e && this._absoluteTransform.multiplyToRef(e, this._absoluteTransform);
+ }
+ for (var n = this.children, i = n.length, o = 0; o < i; o++)
+ n[o].computeAbsoluteTransforms();
+ }, t.prototype.getDirection = function(e, n) {
+ n === void 0 && (n = null);
+ var i = u.e.Zero();
+ return this.getDirectionToRef(e, n, i), i;
+ }, t.prototype.getDirectionToRef = function(e, n, i) {
+ n === void 0 && (n = null);
+ var o = null;
+ n && (o = n.getWorldMatrix()), this._skeleton.computeAbsoluteTransforms();
+ var a = t._tmpMats[0];
+ a.copyFrom(this.getAbsoluteTransform()), n && o && a.multiplyToRef(o, a), u.e.TransformNormalToRef(e, a, i), i.normalize();
+ }, t.prototype.getRotation = function(e, n) {
+ e === void 0 && (e = be.c.LOCAL), n === void 0 && (n = null);
+ var i = u.e.Zero();
+ return this.getRotationToRef(e, n, i), i;
+ }, t.prototype.getRotationToRef = function(e, n, i) {
+ e === void 0 && (e = be.c.LOCAL), n === void 0 && (n = null);
+ var o = t._tmpQuat;
+ this.getRotationQuaternionToRef(e, n, o), o.toEulerAnglesToRef(i);
+ }, t.prototype.getRotationQuaternion = function(e, n) {
+ e === void 0 && (e = be.c.LOCAL), n === void 0 && (n = null);
+ var i = u.b.Identity();
+ return this.getRotationQuaternionToRef(e, n, i), i;
+ }, t.prototype.getRotationQuaternionToRef = function(e, n, i) {
+ if (e === void 0 && (e = be.c.LOCAL), n === void 0 && (n = null), e == be.c.LOCAL)
+ this._decompose(), i.copyFrom(this._localRotation);
+ else {
+ var o = t._tmpMats[0], a = this.getAbsoluteTransform();
+ n ? a.multiplyToRef(n.getWorldMatrix(), o) : o.copyFrom(a), o.multiplyAtIndex(0, this._scalingDeterminant), o.multiplyAtIndex(1, this._scalingDeterminant), o.multiplyAtIndex(2, this._scalingDeterminant), o.decompose(void 0, i, void 0);
+ }
+ }, t.prototype.getRotationMatrix = function(e, n) {
+ e === void 0 && (e = be.c.LOCAL);
+ var i = u.a.Identity();
+ return this.getRotationMatrixToRef(e, n, i), i;
+ }, t.prototype.getRotationMatrixToRef = function(e, n, i) {
+ if (e === void 0 && (e = be.c.LOCAL), e == be.c.LOCAL)
+ this.getLocalMatrix().getRotationMatrixToRef(i);
+ else {
+ var o = t._tmpMats[0], a = this.getAbsoluteTransform();
+ n ? a.multiplyToRef(n.getWorldMatrix(), o) : o.copyFrom(a), o.multiplyAtIndex(0, this._scalingDeterminant), o.multiplyAtIndex(1, this._scalingDeterminant), o.multiplyAtIndex(2, this._scalingDeterminant), o.getRotationMatrixToRef(i);
+ }
+ }, t.prototype.getAbsolutePositionFromLocal = function(e, n) {
+ n === void 0 && (n = null);
+ var i = u.e.Zero();
+ return this.getAbsolutePositionFromLocalToRef(e, n, i), i;
+ }, t.prototype.getAbsolutePositionFromLocalToRef = function(e, n, i) {
+ n === void 0 && (n = null);
+ var o = null;
+ n && (o = n.getWorldMatrix()), this._skeleton.computeAbsoluteTransforms();
+ var a = t._tmpMats[0];
+ n && o ? (a.copyFrom(this.getAbsoluteTransform()), a.multiplyToRef(o, a)) : a = this.getAbsoluteTransform(), u.e.TransformCoordinatesToRef(e, a, i);
+ }, t.prototype.getLocalPositionFromAbsolute = function(e, n) {
+ n === void 0 && (n = null);
+ var i = u.e.Zero();
+ return this.getLocalPositionFromAbsoluteToRef(e, n, i), i;
+ }, t.prototype.getLocalPositionFromAbsoluteToRef = function(e, n, i) {
+ n === void 0 && (n = null);
+ var o = null;
+ n && (o = n.getWorldMatrix()), this._skeleton.computeAbsoluteTransforms();
+ var a = t._tmpMats[0];
+ a.copyFrom(this.getAbsoluteTransform()), n && o && a.multiplyToRef(o, a), a.invert(), u.e.TransformCoordinatesToRef(e, a, i);
+ }, t.prototype.setCurrentPoseAsRest = function() {
+ this.setRestPose(this.getLocalMatrix());
+ }, t._tmpVecs = Pe.a.BuildArray(2, u.e.Zero), t._tmpQuat = u.b.Identity(), t._tmpMats = Pe.a.BuildArray(5, u.a.Identity), t;
+ }(Q.a), ke = function() {
+ function r(t, e, n, i, o, a, s, d, p, y) {
+ n === void 0 && (n = 0), i === void 0 && (i = 100), o === void 0 && (o = !1), a === void 0 && (a = 1), y === void 0 && (y = !1), this.target = e, this.fromFrame = n, this.toFrame = i, this.loopAnimation = o, this.onAnimationEnd = s, this.onAnimationLoop = p, this.isAdditive = y, this._localDelayOffset = null, this._pausedDelay = null, this._runtimeAnimations = new Array(), this._paused = !1, this._speedRatio = 1, this._weight = -1, this._syncRoot = null, this.disposeOnEnd = !0, this.animationStarted = !1, this.onAnimationEndObservable = new C.c(), this.onAnimationLoopObservable = new C.c(), this._scene = t, d && this.appendAnimations(e, d), this._speedRatio = a, t._activeAnimatables.push(this);
+ }
+ return Object.defineProperty(r.prototype, "syncRoot", { get: function() {
+ return this._syncRoot;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "masterFrame", { get: function() {
+ return this._runtimeAnimations.length === 0 ? 0 : this._runtimeAnimations[0].currentFrame;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "weight", { get: function() {
+ return this._weight;
+ }, set: function(t) {
+ this._weight = t !== -1 ? Math.min(Math.max(t, 0), 1) : -1;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "speedRatio", { get: function() {
+ return this._speedRatio;
+ }, set: function(t) {
+ for (var e = 0; e < this._runtimeAnimations.length; e++)
+ this._runtimeAnimations[e]._prepareForSpeedRatioChange(t);
+ this._speedRatio = t;
+ }, enumerable: !1, configurable: !0 }), r.prototype.syncWith = function(t) {
+ if (this._syncRoot = t, t) {
+ var e = this._scene._activeAnimatables.indexOf(this);
+ e > -1 && (this._scene._activeAnimatables.splice(e, 1), this._scene._activeAnimatables.push(this));
+ }
+ return this;
+ }, r.prototype.getAnimations = function() {
+ return this._runtimeAnimations;
+ }, r.prototype.appendAnimations = function(t, e) {
+ for (var n = this, i = 0; i < e.length; i++) {
+ var o = e[i], a = new me(t, o, this._scene, this);
+ a._onLoop = function() {
+ n.onAnimationLoopObservable.notifyObservers(n), n.onAnimationLoop && n.onAnimationLoop();
+ }, this._runtimeAnimations.push(a);
+ }
+ }, r.prototype.getAnimationByTargetProperty = function(t) {
+ for (var e = this._runtimeAnimations, n = 0; n < e.length; n++)
+ if (e[n].animation.targetProperty === t)
+ return e[n].animation;
+ return null;
+ }, r.prototype.getRuntimeAnimationByTargetProperty = function(t) {
+ for (var e = this._runtimeAnimations, n = 0; n < e.length; n++)
+ if (e[n].animation.targetProperty === t)
+ return e[n];
+ return null;
+ }, r.prototype.reset = function() {
+ for (var t = this._runtimeAnimations, e = 0; e < t.length; e++)
+ t[e].reset(!0);
+ this._localDelayOffset = null, this._pausedDelay = null;
+ }, r.prototype.enableBlending = function(t) {
+ for (var e = this._runtimeAnimations, n = 0; n < e.length; n++)
+ e[n].animation.enableBlending = !0, e[n].animation.blendingSpeed = t;
+ }, r.prototype.disableBlending = function() {
+ for (var t = this._runtimeAnimations, e = 0; e < t.length; e++)
+ t[e].animation.enableBlending = !1;
+ }, r.prototype.goToFrame = function(t) {
+ var e = this._runtimeAnimations;
+ if (e[0]) {
+ var n = e[0].animation.framePerSecond, i = e[0].currentFrame, o = this.speedRatio === 0 ? 0 : (t - i) / n * 1e3 / this.speedRatio;
+ this._localDelayOffset === null && (this._localDelayOffset = 0), this._localDelayOffset -= o;
+ }
+ for (var a = 0; a < e.length; a++)
+ e[a].goToFrame(t);
+ }, r.prototype.pause = function() {
+ this._paused || (this._paused = !0);
+ }, r.prototype.restart = function() {
+ this._paused = !1;
+ }, r.prototype._raiseOnAnimationEnd = function() {
+ this.onAnimationEnd && this.onAnimationEnd(), this.onAnimationEndObservable.notifyObservers(this);
+ }, r.prototype.stop = function(t, e) {
+ if (t || e) {
+ var n = this._scene._activeAnimatables.indexOf(this);
+ if (n > -1) {
+ for (var i = (a = this._runtimeAnimations).length - 1; i >= 0; i--) {
+ var o = a[i];
+ t && o.animation.name != t || e && !e(o.target) || (o.dispose(), a.splice(i, 1));
+ }
+ a.length == 0 && (this._scene._activeAnimatables.splice(n, 1), this._raiseOnAnimationEnd());
+ }
+ } else if ((i = this._scene._activeAnimatables.indexOf(this)) > -1) {
+ this._scene._activeAnimatables.splice(i, 1);
+ var a = this._runtimeAnimations;
+ for (i = 0; i < a.length; i++)
+ a[i].dispose();
+ this._raiseOnAnimationEnd();
+ }
+ }, r.prototype.waitAsync = function() {
+ var t = this;
+ return new Promise(function(e, n) {
+ t.onAnimationEndObservable.add(function() {
+ e(t);
+ }, void 0, void 0, t, !0);
+ });
+ }, r.prototype._animate = function(t) {
+ if (this._paused)
+ return this.animationStarted = !1, this._pausedDelay === null && (this._pausedDelay = t), !0;
+ if (this._localDelayOffset === null ? (this._localDelayOffset = t, this._pausedDelay = null) : this._pausedDelay !== null && (this._localDelayOffset += t - this._pausedDelay, this._pausedDelay = null), this._weight === 0)
+ return !0;
+ var e, n = !1, i = this._runtimeAnimations;
+ for (e = 0; e < i.length; e++) {
+ var o = i[e].animate(t - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this._speedRatio, this._weight);
+ n = n || o;
+ }
+ if (this.animationStarted = n, !n) {
+ if (this.disposeOnEnd)
+ for (e = this._scene._activeAnimatables.indexOf(this), this._scene._activeAnimatables.splice(e, 1), e = 0; e < i.length; e++)
+ i[e].dispose();
+ this._raiseOnAnimationEnd(), this.disposeOnEnd && (this.onAnimationEnd = null, this.onAnimationLoop = null, this.onAnimationLoopObservable.clear(), this.onAnimationEndObservable.clear());
+ }
+ return n;
+ }, r;
+ }();
+ _e.a.prototype._animate = function() {
+ if (this.animationsEnabled) {
+ var r = ye.a.Now;
+ if (!this._animationTimeLast) {
+ if (this._pendingData.length > 0)
+ return;
+ this._animationTimeLast = r;
+ }
+ this.deltaTime = this.useConstantAnimationDeltaTime ? 16 : (r - this._animationTimeLast) * this.animationTimeScale, this._animationTimeLast = r;
+ var t = this._activeAnimatables;
+ if (t.length !== 0) {
+ this._animationTime += this.deltaTime;
+ for (var e = this._animationTime, n = 0; n < t.length; n++) {
+ var i = t[n];
+ !i._animate(e) && i.disposeOnEnd && n--;
+ }
+ this._processLateAnimationBindings();
+ }
+ }
+ }, _e.a.prototype.beginWeightedAnimation = function(r, t, e, n, i, o, a, s, d, p, y) {
+ n === void 0 && (n = 1), o === void 0 && (o = 1), y === void 0 && (y = !1);
+ var P = this.beginAnimation(r, t, e, i, o, a, s, !1, d, p, y);
+ return P.weight = n, P;
+ }, _e.a.prototype.beginAnimation = function(r, t, e, n, i, o, a, s, d, p, y) {
+ i === void 0 && (i = 1), s === void 0 && (s = !0), y === void 0 && (y = !1), t > e && i > 0 && (i *= -1), s && this.stopAnimation(r, void 0, d), a || (a = new ke(this, r, t, e, n, i, o, void 0, p, y));
+ var P = !d || d(r);
+ if (r.animations && P && a.appendAnimations(r, r.animations), r.getAnimatables)
+ for (var R = r.getAnimatables(), B = 0; B < R.length; B++)
+ this.beginAnimation(R[B], t, e, n, i, o, a, s, d, p);
+ return a.reset(), a;
+ }, _e.a.prototype.beginHierarchyAnimation = function(r, t, e, n, i, o, a, s, d, p, y, P) {
+ o === void 0 && (o = 1), d === void 0 && (d = !0), P === void 0 && (P = !1);
+ var R = r.getDescendants(t), B = [];
+ B.push(this.beginAnimation(r, e, n, i, o, a, s, d, p, void 0, P));
+ for (var F = 0, z = R; F < z.length; F++) {
+ var J = z[F];
+ B.push(this.beginAnimation(J, e, n, i, o, a, s, d, p, void 0, P));
+ }
+ return B;
+ }, _e.a.prototype.beginDirectAnimation = function(r, t, e, n, i, o, a, s, d) {
+ return d === void 0 && (d = !1), o === void 0 && (o = 1), e > n && o > 0 && (o *= -1), new ke(this, r, e, n, i, o, a, t, s, d);
+ }, _e.a.prototype.beginDirectHierarchyAnimation = function(r, t, e, n, i, o, a, s, d, p) {
+ p === void 0 && (p = !1);
+ var y = r.getDescendants(t), P = [];
+ P.push(this.beginDirectAnimation(r, e, n, i, o, a, s, d, p));
+ for (var R = 0, B = y; R < B.length; R++) {
+ var F = B[R];
+ P.push(this.beginDirectAnimation(F, e, n, i, o, a, s, d, p));
+ }
+ return P;
+ }, _e.a.prototype.getAnimatableByTarget = function(r) {
+ for (var t = 0; t < this._activeAnimatables.length; t++)
+ if (this._activeAnimatables[t].target === r)
+ return this._activeAnimatables[t];
+ return null;
+ }, _e.a.prototype.getAllAnimatablesByTarget = function(r) {
+ for (var t = [], e = 0; e < this._activeAnimatables.length; e++)
+ this._activeAnimatables[e].target === r && t.push(this._activeAnimatables[e]);
+ return t;
+ }, _e.a.prototype.stopAnimation = function(r, t, e) {
+ for (var n = 0, i = this.getAllAnimatablesByTarget(r); n < i.length; n++)
+ i[n].stop(t, e);
+ }, _e.a.prototype.stopAllAnimations = function() {
+ if (this._activeAnimatables) {
+ for (var r = 0; r < this._activeAnimatables.length; r++)
+ this._activeAnimatables[r].stop();
+ this._activeAnimatables = [];
+ }
+ for (var t = 0, e = this.animationGroups; t < e.length; t++)
+ e[t].stop();
+ }, _e.a.prototype._registerTargetForLateAnimationBinding = function(r, t) {
+ var e = r.target;
+ this._registeredForLateAnimationBindings.pushNoDuplicate(e), e._lateAnimationHolders || (e._lateAnimationHolders = {}), e._lateAnimationHolders[r.targetPath] || (e._lateAnimationHolders[r.targetPath] = { totalWeight: 0, totalAdditiveWeight: 0, animations: [], additiveAnimations: [], originalValue: t }), r.isAdditive ? (e._lateAnimationHolders[r.targetPath].additiveAnimations.push(r), e._lateAnimationHolders[r.targetPath].totalAdditiveWeight += r.weight) : (e._lateAnimationHolders[r.targetPath].animations.push(r), e._lateAnimationHolders[r.targetPath].totalWeight += r.weight);
+ }, _e.a.prototype._processLateAnimationBindingsForMatrices = function(r) {
+ if (r.totalWeight === 0 && r.totalAdditiveWeight === 0)
+ return r.originalValue;
+ var t = 1, e = u.c.Vector3[0], n = u.c.Vector3[1], i = u.c.Quaternion[0], o = 0, a = r.animations[0], s = r.originalValue, d = 1, p = !1;
+ if (r.totalWeight < 1)
+ d = 1 - r.totalWeight, s.decompose(n, i, e);
+ else {
+ if (o = 1, t = r.totalWeight, (d = a.weight / t) == 1) {
+ if (!r.totalAdditiveWeight)
+ return a.currentValue;
+ p = !0;
+ }
+ a.currentValue.decompose(n, i, e);
+ }
+ if (!p) {
+ n.scaleInPlace(d), e.scaleInPlace(d), i.scaleInPlace(d);
+ for (var y = o; y < r.animations.length; y++)
+ if ((z = r.animations[y]).weight !== 0) {
+ d = z.weight / t;
+ var P = u.c.Vector3[2], R = u.c.Vector3[3], B = u.c.Quaternion[1];
+ z.currentValue.decompose(R, B, P), R.scaleAndAddToRef(d, n), B.scaleAndAddToRef(d, i), P.scaleAndAddToRef(d, e);
+ }
+ }
+ for (var F = 0; F < r.additiveAnimations.length; F++) {
+ var z;
+ (z = r.additiveAnimations[F]).weight !== 0 && (P = u.c.Vector3[2], R = u.c.Vector3[3], B = u.c.Quaternion[1], z.currentValue.decompose(R, B, P), R.multiplyToRef(n, R), u.e.LerpToRef(n, R, z.weight, n), i.multiplyToRef(B, B), u.b.SlerpToRef(i, B, z.weight, i), P.scaleAndAddToRef(z.weight, e));
+ }
+ var J = a ? a._animationState.workValue : u.c.Matrix[0].clone();
+ return u.a.ComposeToRef(n, i, e, J), J;
+ }, _e.a.prototype._processLateAnimationBindingsForQuaternions = function(r, t) {
+ if (r.totalWeight === 0 && r.totalAdditiveWeight === 0)
+ return t;
+ var e = r.animations[0], n = r.originalValue, i = t;
+ if (r.totalWeight === 0 && r.totalAdditiveWeight > 0)
+ i.copyFrom(n);
+ else if (r.animations.length === 1) {
+ if (u.b.SlerpToRef(n, e.currentValue, Math.min(1, r.totalWeight), i), r.totalAdditiveWeight === 0)
+ return i;
+ } else if (r.animations.length > 1) {
+ var o = 1, a = void 0, s = void 0;
+ if (r.totalWeight < 1) {
+ var d = 1 - r.totalWeight;
+ s = [], (a = []).push(n), s.push(d);
+ } else {
+ if (r.animations.length === 2 && (u.b.SlerpToRef(r.animations[0].currentValue, r.animations[1].currentValue, r.animations[1].weight / r.totalWeight, t), r.totalAdditiveWeight === 0))
+ return t;
+ a = [], s = [], o = r.totalWeight;
+ }
+ for (var p = 0; p < r.animations.length; p++) {
+ var y = r.animations[p];
+ a.push(y.currentValue), s.push(y.weight / o);
+ }
+ for (var P = 0, R = 0; R < a.length; )
+ R ? (P += s[R], u.b.SlerpToRef(i, a[R], s[R] / P, i), R++) : (u.b.SlerpToRef(a[R], a[R + 1], s[R + 1] / (s[R] + s[R + 1]), t), i = t, P = s[R] + s[R + 1], R += 2);
+ }
+ for (var B = 0; B < r.additiveAnimations.length; B++)
+ (y = r.additiveAnimations[B]).weight !== 0 && (i.multiplyToRef(y.currentValue, u.c.Quaternion[0]), u.b.SlerpToRef(i, u.c.Quaternion[0], y.weight, i));
+ return i;
+ }, _e.a.prototype._processLateAnimationBindings = function() {
+ if (this._registeredForLateAnimationBindings.length) {
+ for (var r = 0; r < this._registeredForLateAnimationBindings.length; r++) {
+ var t = this._registeredForLateAnimationBindings.data[r];
+ for (var e in t._lateAnimationHolders) {
+ var n = t._lateAnimationHolders[e], i = n.animations[0], o = n.originalValue, a = k.AllowMatrixDecomposeForInterpolation && o.m, s = t[e];
+ if (a)
+ s = this._processLateAnimationBindingsForMatrices(n);
+ else if (o.w !== void 0)
+ s = this._processLateAnimationBindingsForQuaternions(n, s || u.b.Identity());
+ else {
+ var d = 0, p = 1;
+ if (n.totalWeight < 1)
+ s = i && o.scale ? o.scale(1 - n.totalWeight) : i ? o * (1 - n.totalWeight) : o.clone ? o.clone() : o;
+ else if (i) {
+ p = n.totalWeight;
+ var y = i.weight / p;
+ s = y !== 1 ? i.currentValue.scale ? i.currentValue.scale(y) : i.currentValue * y : i.currentValue, d = 1;
+ }
+ for (var P = d; P < n.animations.length; P++)
+ (F = (B = n.animations[P]).weight / p) && (B.currentValue.scaleAndAddToRef ? B.currentValue.scaleAndAddToRef(F, s) : s += B.currentValue * F);
+ for (var R = 0; R < n.additiveAnimations.length; R++) {
+ var B, F;
+ (F = (B = n.additiveAnimations[R]).weight) && (B.currentValue.scaleAndAddToRef ? B.currentValue.scaleAndAddToRef(F, s) : s += B.currentValue * F);
+ }
+ }
+ t[e] = s;
+ }
+ t._lateAnimationHolders = {};
+ }
+ this._registeredForLateAnimationBindings.reset();
+ }
+ }, Fe.prototype.copyAnimationRange = function(r, t, e, n, i) {
+ n === void 0 && (n = !1), i === void 0 && (i = null), this.animations.length === 0 && (this.animations.push(new k(this.name, "_matrix", r.animations[0].framePerSecond, k.ANIMATIONTYPE_MATRIX, 0)), this.animations[0].setKeys([]));
+ var o = r.animations[0].getRange(t);
+ if (!o)
+ return !1;
+ for (var a, s, d, p = o.from, y = o.to, P = r.animations[0].getKeys(), R = r.length, B = r.getParent(), F = this.getParent(), z = n && B && R && this.length && R !== this.length, J = z && F && B ? F.length / B.length : 1, ie = n && !F && i && (i.x !== 1 || i.y !== 1 || i.z !== 1), se = this.animations[0].getKeys(), ce = 0, ue = P.length; ce < ue; ce++)
+ (a = P[ce]).frame >= p && a.frame <= y && (n ? (d = a.value.clone(), z ? (s = d.getTranslation(), d.setTranslation(s.scaleInPlace(J))) : ie && i ? (s = d.getTranslation(), d.setTranslation(s.multiplyInPlace(i))) : d = a.value) : d = a.value, se.push({ frame: a.frame + e, value: d }));
+ return this.animations[0].createRange(t, p + e, y + e), !0;
+ };
+ var We = function() {
+ function r() {
+ }
+ return r.prototype.getClassName = function() {
+ return "TargetedAnimation";
+ }, r.prototype.serialize = function() {
+ var t = {};
+ return t.animation = this.animation.serialize(), t.targetId = this.target.id, t;
+ }, r;
+ }(), je = function() {
+ function r(t, e) {
+ e === void 0 && (e = null), this.name = t, this._targetedAnimations = new Array(), this._animatables = new Array(), this._from = Number.MAX_VALUE, this._to = -Number.MAX_VALUE, this._speedRatio = 1, this._loopAnimation = !1, this._isAdditive = !1, this.onAnimationEndObservable = new C.c(), this.onAnimationLoopObservable = new C.c(), this.onAnimationGroupLoopObservable = new C.c(), this.onAnimationGroupEndObservable = new C.c(), this.onAnimationGroupPauseObservable = new C.c(), this.onAnimationGroupPlayObservable = new C.c(), this._scene = e || te.a.LastCreatedScene, this.uniqueId = this._scene.getUniqueId(), this._scene.addAnimationGroup(this);
+ }
+ return Object.defineProperty(r.prototype, "from", { get: function() {
+ return this._from;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "to", { get: function() {
+ return this._to;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "isStarted", { get: function() {
+ return this._isStarted;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "isPlaying", { get: function() {
+ return this._isStarted && !this._isPaused;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "speedRatio", { get: function() {
+ return this._speedRatio;
+ }, set: function(t) {
+ if (this._speedRatio !== t) {
+ this._speedRatio = t;
+ for (var e = 0; e < this._animatables.length; e++)
+ this._animatables[e].speedRatio = this._speedRatio;
+ }
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "loopAnimation", { get: function() {
+ return this._loopAnimation;
+ }, set: function(t) {
+ if (this._loopAnimation !== t) {
+ this._loopAnimation = t;
+ for (var e = 0; e < this._animatables.length; e++)
+ this._animatables[e].loopAnimation = this._loopAnimation;
+ }
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "isAdditive", { get: function() {
+ return this._isAdditive;
+ }, set: function(t) {
+ if (this._isAdditive !== t) {
+ this._isAdditive = t;
+ for (var e = 0; e < this._animatables.length; e++)
+ this._animatables[e].isAdditive = this._isAdditive;
+ }
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "targetedAnimations", { get: function() {
+ return this._targetedAnimations;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "animatables", { get: function() {
+ return this._animatables;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "children", { get: function() {
+ return this._targetedAnimations;
+ }, enumerable: !1, configurable: !0 }), r.prototype.addTargetedAnimation = function(t, e) {
+ var n = new We();
+ n.animation = t, n.target = e;
+ var i = t.getKeys();
+ return this._from > i[0].frame && (this._from = i[0].frame), this._to < i[i.length - 1].frame && (this._to = i[i.length - 1].frame), this._targetedAnimations.push(n), n;
+ }, r.prototype.normalize = function(t, e) {
+ t === void 0 && (t = null), e === void 0 && (e = null), t == null && (t = this._from), e == null && (e = this._to);
+ for (var n = 0; n < this._targetedAnimations.length; n++) {
+ var i = this._targetedAnimations[n].animation.getKeys(), o = i[0], a = i[i.length - 1];
+ if (o.frame > t) {
+ var s = { frame: t, value: o.value, inTangent: o.inTangent, outTangent: o.outTangent, interpolation: o.interpolation };
+ i.splice(0, 0, s);
+ }
+ a.frame < e && (s = { frame: e, value: a.value, inTangent: a.inTangent, outTangent: a.outTangent, interpolation: a.interpolation }, i.push(s));
+ }
+ return this._from = t, this._to = e, this;
+ }, r.prototype._processLoop = function(t, e, n) {
+ var i = this;
+ t.onAnimationLoop = function() {
+ i.onAnimationLoopObservable.notifyObservers(e), i._animationLoopFlags[n] || (i._animationLoopFlags[n] = !0, i._animationLoopCount++, i._animationLoopCount === i._targetedAnimations.length && (i.onAnimationGroupLoopObservable.notifyObservers(i), i._animationLoopCount = 0, i._animationLoopFlags = []));
+ };
+ }, r.prototype.start = function(t, e, n, i, o) {
+ var a = this;
+ if (t === void 0 && (t = !1), e === void 0 && (e = 1), this._isStarted || this._targetedAnimations.length === 0)
+ return this;
+ this._loopAnimation = t, this._animationLoopCount = 0, this._animationLoopFlags = [];
+ for (var s = function() {
+ var P = d._targetedAnimations[p], R = d._scene.beginDirectAnimation(P.target, [P.animation], n !== void 0 ? n : d._from, i !== void 0 ? i : d._to, t, e, void 0, void 0, o !== void 0 ? o : d._isAdditive);
+ R.onAnimationEnd = function() {
+ a.onAnimationEndObservable.notifyObservers(P), a._checkAnimationGroupEnded(R);
+ }, d._processLoop(R, P, p), d._animatables.push(R);
+ }, d = this, p = 0; p < this._targetedAnimations.length; p++)
+ s();
+ if (this._speedRatio = e, n !== void 0 && i !== void 0)
+ if (n < i && this._speedRatio < 0) {
+ var y = i;
+ i = n, n = y;
+ } else
+ n > i && this._speedRatio > 0 && (this._speedRatio = -e);
+ return this._isStarted = !0, this._isPaused = !1, this.onAnimationGroupPlayObservable.notifyObservers(this), this;
+ }, r.prototype.pause = function() {
+ if (!this._isStarted)
+ return this;
+ this._isPaused = !0;
+ for (var t = 0; t < this._animatables.length; t++)
+ this._animatables[t].pause();
+ return this.onAnimationGroupPauseObservable.notifyObservers(this), this;
+ }, r.prototype.play = function(t) {
+ return this.isStarted && this._animatables.length === this._targetedAnimations.length ? (t !== void 0 && (this.loopAnimation = t), this.restart()) : (this.stop(), this.start(t, this._speedRatio)), this._isPaused = !1, this;
+ }, r.prototype.reset = function() {
+ if (!this._isStarted)
+ return this.play(), this.goToFrame(0), this.stop(), this;
+ for (var t = 0; t < this._animatables.length; t++)
+ this._animatables[t].reset();
+ return this;
+ }, r.prototype.restart = function() {
+ if (!this._isStarted)
+ return this;
+ for (var t = 0; t < this._animatables.length; t++)
+ this._animatables[t].restart();
+ return this.onAnimationGroupPlayObservable.notifyObservers(this), this;
+ }, r.prototype.stop = function() {
+ if (!this._isStarted)
+ return this;
+ for (var t = this._animatables.slice(), e = 0; e < t.length; e++)
+ t[e].stop();
+ return this._isStarted = !1, this;
+ }, r.prototype.setWeightForAllAnimatables = function(t) {
+ for (var e = 0; e < this._animatables.length; e++)
+ this._animatables[e].weight = t;
+ return this;
+ }, r.prototype.syncAllAnimationsWith = function(t) {
+ for (var e = 0; e < this._animatables.length; e++)
+ this._animatables[e].syncWith(t);
+ return this;
+ }, r.prototype.goToFrame = function(t) {
+ if (!this._isStarted)
+ return this;
+ for (var e = 0; e < this._animatables.length; e++)
+ this._animatables[e].goToFrame(t);
+ return this;
+ }, r.prototype.dispose = function() {
+ this._targetedAnimations = [], this._animatables = [];
+ var t = this._scene.animationGroups.indexOf(this);
+ t > -1 && this._scene.animationGroups.splice(t, 1), this.onAnimationEndObservable.clear(), this.onAnimationGroupEndObservable.clear(), this.onAnimationGroupPauseObservable.clear(), this.onAnimationGroupPlayObservable.clear(), this.onAnimationLoopObservable.clear(), this.onAnimationGroupLoopObservable.clear();
+ }, r.prototype._checkAnimationGroupEnded = function(t) {
+ var e = this._animatables.indexOf(t);
+ e > -1 && this._animatables.splice(e, 1), this._animatables.length === 0 && (this._isStarted = !1, this.onAnimationGroupEndObservable.notifyObservers(this));
+ }, r.prototype.clone = function(t, e) {
+ for (var n = new r(t || this.name, this._scene), i = 0, o = this._targetedAnimations; i < o.length; i++) {
+ var a = o[i];
+ n.addTargetedAnimation(a.animation.clone(), e ? e(a.target) : a.target);
+ }
+ return n;
+ }, r.prototype.serialize = function() {
+ var t = {};
+ t.name = this.name, t.from = this.from, t.to = this.to, t.targetedAnimations = [];
+ for (var e = 0; e < this.targetedAnimations.length; e++) {
+ var n = this.targetedAnimations[e];
+ t.targetedAnimations[e] = n.serialize();
+ }
+ return t;
+ }, r.Parse = function(t, e) {
+ for (var n = new r(t.name, e), i = 0; i < t.targetedAnimations.length; i++) {
+ var o = t.targetedAnimations[i], a = k.Parse(o.animation), s = o.targetId;
+ if (o.animation.property === "influence") {
+ var d = e.getMorphTargetById(s);
+ d && n.addTargetedAnimation(a, d);
+ } else {
+ var p = e.getNodeByID(s);
+ p != null && n.addTargetedAnimation(a, p);
+ }
+ }
+ return t.from !== null && t.to !== null && n.normalize(t.from, t.to), n;
+ }, r.MakeAnimationAdditive = function(t, e, n, i, o) {
+ e === void 0 && (e = 0), i === void 0 && (i = !1);
+ var a = t;
+ i && (a = t.clone(o || a.name));
+ for (var s = a.targetedAnimations, d = 0; d < s.length; d++) {
+ var p = s[d];
+ k.MakeAnimationAdditive(p.animation, e, n);
+ }
+ return a.isAdditive = !0, a;
+ }, r.prototype.getClassName = function() {
+ return "AnimationGroup";
+ }, r.prototype.toString = function(t) {
+ var e = "Name: " + this.name;
+ return e += ", type: " + this.getClassName(), t && (e += ", from: " + this._from, e += ", to: " + this._to, e += ", isStarted: " + this._isStarted, e += ", speedRatio: " + this._speedRatio, e += ", targetedAnimations length: " + this._targetedAnimations.length, e += ", animatables length: " + this._animatables), e;
+ }, r;
+ }(), He = function() {
+ this.enableBlending = !1, this.blendingSpeed = 0.01, this.loopMode = k.ANIMATIONLOOPMODE_CYCLE;
+ }, Qe = f(72), Ge = function() {
+ function r() {
+ this._easingMode = r.EASINGMODE_EASEIN;
+ }
+ return r.prototype.setEasingMode = function(t) {
+ var e = Math.min(Math.max(t, 0), 2);
+ this._easingMode = e;
+ }, r.prototype.getEasingMode = function() {
+ return this._easingMode;
+ }, r.prototype.easeInCore = function(t) {
+ throw new Error("You must implement this method");
+ }, r.prototype.ease = function(t) {
+ switch (this._easingMode) {
+ case r.EASINGMODE_EASEIN:
+ return this.easeInCore(t);
+ case r.EASINGMODE_EASEOUT:
+ return 1 - this.easeInCore(1 - t);
+ }
+ return t >= 0.5 ? 0.5 * (1 - this.easeInCore(2 * (1 - t))) + 0.5 : 0.5 * this.easeInCore(2 * t);
+ }, r.EASINGMODE_EASEIN = 0, r.EASINGMODE_EASEOUT = 1, r.EASINGMODE_EASEINOUT = 2, r;
+ }(), tt = function(r) {
+ function t() {
+ return r !== null && r.apply(this, arguments) || this;
+ }
+ return Object(c.d)(t, r), t.prototype.easeInCore = function(e) {
+ return e = Math.max(0, Math.min(1, e)), 1 - Math.sqrt(1 - e * e);
+ }, t;
+ }(Ge), Je = function(r) {
+ function t(e) {
+ e === void 0 && (e = 1);
+ var n = r.call(this) || this;
+ return n.amplitude = e, n;
+ }
+ return Object(c.d)(t, r), t.prototype.easeInCore = function(e) {
+ var n = Math.max(0, this.amplitude);
+ return Math.pow(e, 3) - e * n * Math.sin(3.141592653589793 * e);
+ }, t;
+ }(Ge), st = function(r) {
+ function t(e, n) {
+ e === void 0 && (e = 3), n === void 0 && (n = 2);
+ var i = r.call(this) || this;
+ return i.bounces = e, i.bounciness = n, i;
+ }
+ return Object(c.d)(t, r), t.prototype.easeInCore = function(e) {
+ var n = Math.max(0, this.bounces), i = this.bounciness;
+ i <= 1 && (i = 1.001);
+ var o = Math.pow(i, n), a = 1 - i, s = (1 - o) / a + 0.5 * o, d = e * s, p = Math.log(-d * (1 - i) + 1) / Math.log(i), y = Math.floor(p), P = y + 1, R = (1 - Math.pow(i, y)) / (a * s), B = 0.5 * (R + (1 - Math.pow(i, P)) / (a * s)), F = e - B, z = B - R;
+ return -Math.pow(1 / i, n - y) / (z * z) * (F - z) * (F + z);
+ }, t;
+ }(Ge), at = function(r) {
+ function t() {
+ return r !== null && r.apply(this, arguments) || this;
+ }
+ return Object(c.d)(t, r), t.prototype.easeInCore = function(e) {
+ return e * e * e;
+ }, t;
+ }(Ge), pt = function(r) {
+ function t(e, n) {
+ e === void 0 && (e = 3), n === void 0 && (n = 3);
+ var i = r.call(this) || this;
+ return i.oscillations = e, i.springiness = n, i;
+ }
+ return Object(c.d)(t, r), t.prototype.easeInCore = function(e) {
+ var n = Math.max(0, this.oscillations), i = Math.max(0, this.springiness);
+ return (i == 0 ? e : (Math.exp(i * e) - 1) / (Math.exp(i) - 1)) * Math.sin((6.283185307179586 * n + 1.5707963267948966) * e);
+ }, t;
+ }(Ge), Tt = function(r) {
+ function t(e) {
+ e === void 0 && (e = 2);
+ var n = r.call(this) || this;
+ return n.exponent = e, n;
+ }
+ return Object(c.d)(t, r), t.prototype.easeInCore = function(e) {
+ return this.exponent <= 0 ? e : (Math.exp(this.exponent * e) - 1) / (Math.exp(this.exponent) - 1);
+ }, t;
+ }(Ge), Lt = function(r) {
+ function t(e) {
+ e === void 0 && (e = 2);
+ var n = r.call(this) || this;
+ return n.power = e, n;
+ }
+ return Object(c.d)(t, r), t.prototype.easeInCore = function(e) {
+ var n = Math.max(0, this.power);
+ return Math.pow(e, n);
+ }, t;
+ }(Ge), Ot = function(r) {
+ function t() {
+ return r !== null && r.apply(this, arguments) || this;
+ }
+ return Object(c.d)(t, r), t.prototype.easeInCore = function(e) {
+ return e * e;
+ }, t;
+ }(Ge), St = function(r) {
+ function t() {
+ return r !== null && r.apply(this, arguments) || this;
+ }
+ return Object(c.d)(t, r), t.prototype.easeInCore = function(e) {
+ return e * e * e * e;
+ }, t;
+ }(Ge), Ct = function(r) {
+ function t() {
+ return r !== null && r.apply(this, arguments) || this;
+ }
+ return Object(c.d)(t, r), t.prototype.easeInCore = function(e) {
+ return e * e * e * e * e;
+ }, t;
+ }(Ge), nn = function(r) {
+ function t() {
+ return r !== null && r.apply(this, arguments) || this;
+ }
+ return Object(c.d)(t, r), t.prototype.easeInCore = function(e) {
+ return 1 - Math.sin(1.5707963267948966 * (1 - e));
+ }, t;
+ }(Ge), Qt = function(r) {
+ function t(e, n, i, o) {
+ e === void 0 && (e = 0), n === void 0 && (n = 0), i === void 0 && (i = 1), o === void 0 && (o = 1);
+ var a = r.call(this) || this;
+ return a.x1 = e, a.y1 = n, a.x2 = i, a.y2 = o, a;
+ }
+ return Object(c.d)(t, r), t.prototype.easeInCore = function(e) {
+ return Qe.c.Interpolate(e, this.x1, this.y1, this.x2, this.y2);
+ }, t;
+ }(Ge), $t = function() {
+ function r(t, e, n) {
+ this.frame = t, this.action = e, this.onlyOnce = n, this.isDone = !1;
+ }
+ return r.prototype._clone = function() {
+ return new r(this.frame, this.action, this.onlyOnce);
+ }, r;
+ }(), Ie = f(7), Sn = function(r) {
+ function t() {
+ return r !== null && r.apply(this, arguments) || this;
+ }
+ return Object(c.d)(t, r), t;
+ }(V.a), en = function() {
+ this.rootNodes = [], this.skeletons = [], this.animationGroups = [];
+ }, An = function(r) {
+ function t(e) {
+ var n = r.call(this) || this;
+ return n._wasAddedToScene = !1, n.scene = e, n.sounds = [], n.effectLayers = [], n.layers = [], n.lensFlareSystems = [], n.proceduralTextures = [], n.reflectionProbes = [], e.onDisposeObservable.add(function() {
+ n._wasAddedToScene || n.dispose();
+ }), n;
+ }
+ return Object(c.d)(t, r), t.prototype.instantiateModelsToScene = function(e, n) {
+ var i = this;
+ n === void 0 && (n = !1);
+ var o = {}, a = {}, s = new en(), d = [], p = [], y = { doNotInstantiate: !0 }, P = function(R, B) {
+ if (o[R.uniqueId] = B.uniqueId, a[B.uniqueId] = B, e && (B.name = e(R.name)), B instanceof Ie.a) {
+ var F = B;
+ if (F.morphTargetManager) {
+ var z = R.morphTargetManager;
+ F.morphTargetManager = z.clone();
+ for (var J = 0; J < z.numTargets; J++) {
+ var ie = z.getTarget(J), se = F.morphTargetManager.getTarget(J);
+ o[ie.uniqueId] = se.uniqueId, a[se.uniqueId] = se;
+ }
+ }
+ }
+ };
+ return this.transformNodes.forEach(function(R) {
+ if (!R.parent) {
+ var B = R.instantiateHierarchy(null, y, function(F, z) {
+ P(F, z);
+ });
+ B && s.rootNodes.push(B);
+ }
+ }), this.meshes.forEach(function(R) {
+ if (!R.parent) {
+ var B = R.instantiateHierarchy(null, y, function(F, z) {
+ if (P(F, z), z.material) {
+ var J = z;
+ if (J.material)
+ if (n) {
+ var ie = F.material;
+ if (p.indexOf(ie) === -1) {
+ var se = ie.clone(e ? e(ie.name) : "Clone of " + ie.name);
+ if (p.push(ie), o[ie.uniqueId] = se.uniqueId, a[se.uniqueId] = se, ie.getClassName() === "MultiMaterial") {
+ for (var ce = ie, ue = 0, fe = ce.subMaterials; ue < fe.length; ue++) {
+ var ve = fe[ue];
+ ve && (se = ve.clone(e ? e(ve.name) : "Clone of " + ve.name), p.push(ve), o[ve.uniqueId] = se.uniqueId, a[se.uniqueId] = se);
+ }
+ ce.subMaterials = ce.subMaterials.map(function(Te) {
+ return Te && a[o[Te.uniqueId]];
+ });
+ }
+ }
+ J.material = a[o[ie.uniqueId]];
+ } else
+ J.material.getClassName() === "MultiMaterial" ? i.scene.multiMaterials.indexOf(J.material) === -1 && i.scene.addMultiMaterial(J.material) : i.scene.materials.indexOf(J.material) === -1 && i.scene.addMaterial(J.material);
+ }
+ });
+ B && s.rootNodes.push(B);
+ }
+ }), this.skeletons.forEach(function(R) {
+ var B = R.clone(e ? e(R.name) : "Clone of " + R.name);
+ R.overrideMesh && (B.overrideMesh = a[o[R.overrideMesh.uniqueId]]);
+ for (var F = 0, z = i.meshes; F < z.length; F++) {
+ var J = z[F];
+ if (J.skeleton === R && !J.isAnInstance) {
+ if (a[o[J.uniqueId]].skeleton = B, d.indexOf(B) !== -1)
+ continue;
+ d.push(B);
+ for (var ie = 0, se = B.bones; ie < se.length; ie++) {
+ var ce = se[ie];
+ ce._linkedTransformNode && (ce._linkedTransformNode = a[o[ce._linkedTransformNode.uniqueId]]);
+ }
+ }
+ }
+ s.skeletons.push(B);
+ }), this.animationGroups.forEach(function(R) {
+ var B = R.clone(R.name, function(F) {
+ return a[o[F.uniqueId]] || F;
+ });
+ s.animationGroups.push(B);
+ }), s;
+ }, t.prototype.addAllToScene = function() {
+ var e = this;
+ this._wasAddedToScene = !0, this.cameras.forEach(function(o) {
+ e.scene.addCamera(o);
+ }), this.lights.forEach(function(o) {
+ e.scene.addLight(o);
+ }), this.meshes.forEach(function(o) {
+ e.scene.addMesh(o);
+ }), this.skeletons.forEach(function(o) {
+ e.scene.addSkeleton(o);
+ }), this.animations.forEach(function(o) {
+ e.scene.addAnimation(o);
+ }), this.animationGroups.forEach(function(o) {
+ e.scene.addAnimationGroup(o);
+ }), this.multiMaterials.forEach(function(o) {
+ e.scene.addMultiMaterial(o);
+ }), this.materials.forEach(function(o) {
+ e.scene.addMaterial(o);
+ }), this.morphTargetManagers.forEach(function(o) {
+ e.scene.addMorphTargetManager(o);
+ }), this.geometries.forEach(function(o) {
+ e.scene.addGeometry(o);
+ }), this.transformNodes.forEach(function(o) {
+ e.scene.addTransformNode(o);
+ }), this.actionManagers.forEach(function(o) {
+ e.scene.addActionManager(o);
+ }), this.textures.forEach(function(o) {
+ e.scene.addTexture(o);
+ }), this.reflectionProbes.forEach(function(o) {
+ e.scene.addReflectionProbe(o);
+ }), this.environmentTexture && (this.scene.environmentTexture = this.environmentTexture);
+ for (var n = 0, i = this.scene._serializableComponents; n < i.length; n++)
+ i[n].addFromContainer(this);
+ }, t.prototype.removeAllFromScene = function() {
+ var e = this;
+ this._wasAddedToScene = !1, this.cameras.forEach(function(o) {
+ e.scene.removeCamera(o);
+ }), this.lights.forEach(function(o) {
+ e.scene.removeLight(o);
+ }), this.meshes.forEach(function(o) {
+ e.scene.removeMesh(o);
+ }), this.skeletons.forEach(function(o) {
+ e.scene.removeSkeleton(o);
+ }), this.animations.forEach(function(o) {
+ e.scene.removeAnimation(o);
+ }), this.animationGroups.forEach(function(o) {
+ e.scene.removeAnimationGroup(o);
+ }), this.multiMaterials.forEach(function(o) {
+ e.scene.removeMultiMaterial(o);
+ }), this.materials.forEach(function(o) {
+ e.scene.removeMaterial(o);
+ }), this.morphTargetManagers.forEach(function(o) {
+ e.scene.removeMorphTargetManager(o);
+ }), this.geometries.forEach(function(o) {
+ e.scene.removeGeometry(o);
+ }), this.transformNodes.forEach(function(o) {
+ e.scene.removeTransformNode(o);
+ }), this.actionManagers.forEach(function(o) {
+ e.scene.removeActionManager(o);
+ }), this.textures.forEach(function(o) {
+ e.scene.removeTexture(o);
+ }), this.reflectionProbes.forEach(function(o) {
+ e.scene.removeReflectionProbe(o);
+ }), this.environmentTexture === this.scene.environmentTexture && (this.scene.environmentTexture = null);
+ for (var n = 0, i = this.scene._serializableComponents; n < i.length; n++)
+ i[n].removeFromContainer(this);
+ }, t.prototype.dispose = function() {
+ this.cameras.forEach(function(i) {
+ i.dispose();
+ }), this.cameras = [], this.lights.forEach(function(i) {
+ i.dispose();
+ }), this.lights = [], this.meshes.forEach(function(i) {
+ i.dispose();
+ }), this.meshes = [], this.skeletons.forEach(function(i) {
+ i.dispose();
+ }), this.skeletons = [], this.animationGroups.forEach(function(i) {
+ i.dispose();
+ }), this.animationGroups = [], this.multiMaterials.forEach(function(i) {
+ i.dispose();
+ }), this.multiMaterials = [], this.materials.forEach(function(i) {
+ i.dispose();
+ }), this.materials = [], this.geometries.forEach(function(i) {
+ i.dispose();
+ }), this.geometries = [], this.transformNodes.forEach(function(i) {
+ i.dispose();
+ }), this.transformNodes = [], this.actionManagers.forEach(function(i) {
+ i.dispose();
+ }), this.actionManagers = [], this.textures.forEach(function(i) {
+ i.dispose();
+ }), this.textures = [], this.reflectionProbes.forEach(function(i) {
+ i.dispose();
+ }), this.reflectionProbes = [], this.environmentTexture && (this.environmentTexture.dispose(), this.environmentTexture = null);
+ for (var e = 0, n = this.scene._serializableComponents; e < n.length; e++)
+ n[e].removeFromContainer(this, !0);
+ }, t.prototype._moveAssets = function(e, n, i) {
+ if (e)
+ for (var o = 0, a = e; o < a.length; o++) {
+ var s = a[o], d = !0;
+ if (i) {
+ for (var p = 0, y = i; p < y.length; p++)
+ if (s === y[p]) {
+ d = !1;
+ break;
+ }
+ }
+ d && n.push(s);
+ }
+ }, t.prototype.moveAllFromScene = function(e) {
+ for (var n in this._wasAddedToScene = !1, e === void 0 && (e = new Sn()), this)
+ this.hasOwnProperty(n) && (this[n] = this[n] || (n === "environmentTexture" ? null : []), this._moveAssets(this.scene[n], this[n], e[n]));
+ this.environmentTexture = this.scene.environmentTexture, this.removeAllFromScene();
+ }, t.prototype.createRootMesh = function() {
+ var e = new Ie.a("assetContainerRootMesh", this.scene);
+ return this.meshes.forEach(function(n) {
+ n.parent || e.addChild(n);
+ }), this.meshes.unshift(e), e;
+ }, t.prototype.mergeAnimationsTo = function(e, n, i) {
+ if (e === void 0 && (e = te.a.LastCreatedScene), i === void 0 && (i = null), !e)
+ return l.a.Error("No scene available to merge animations to"), [];
+ var o = i || function(s) {
+ var d = null, p = s.animations.length ? s.animations[0].targetProperty : "", y = s.name.split(".").join("").split("_primitive")[0];
+ switch (p) {
+ case "position":
+ case "rotationQuaternion":
+ d = e.getTransformNodeByName(s.name) || e.getTransformNodeByName(y);
+ break;
+ case "influence":
+ d = e.getMorphTargetByName(s.name) || e.getMorphTargetByName(y);
+ break;
+ default:
+ d = e.getNodeByName(s.name) || e.getNodeByName(y);
+ }
+ return d;
+ };
+ this.getNodes().forEach(function(s) {
+ var d = o(s);
+ if (d !== null) {
+ for (var p = function(R) {
+ for (var B = 0, F = d.animations.filter(function(ie) {
+ return ie.targetProperty === R.targetProperty;
+ }); B < F.length; B++) {
+ var z = F[B], J = d.animations.indexOf(z, 0);
+ J > -1 && d.animations.splice(J, 1);
+ }
+ }, y = 0, P = s.animations; y < P.length; y++)
+ p(P[y]);
+ d.animations = d.animations.concat(s.animations);
+ }
+ });
+ var a = new Array();
+ return this.animationGroups.slice().forEach(function(s) {
+ a.push(s.clone(s.name, o)), s.animatables.forEach(function(d) {
+ d.stop();
+ });
+ }), n.forEach(function(s) {
+ var d = o(s.target);
+ d && (e.beginAnimation(d, s.fromFrame, s.toFrame, s.loopAnimation, s.speedRatio, s.onAnimationEnd ? s.onAnimationEnd : void 0, void 0, !0, void 0, s.onAnimationLoop ? s.onAnimationLoop : void 0), e.stopAnimation(s.target));
+ }), a;
+ }, t;
+ }(V.a), Ue = f(13), Pn = function() {
+ function r(t) {
+ this.SMOOTHING = 0.75, this.FFT_SIZE = 512, this.BARGRAPHAMPLITUDE = 256, this.DEBUGCANVASPOS = { x: 20, y: 20 }, this.DEBUGCANVASSIZE = { width: 320, height: 200 }, this._scene = t, this._audioEngine = Ue.a.audioEngine, this._audioEngine.canUseWebAudio && this._audioEngine.audioContext && (this._webAudioAnalyser = this._audioEngine.audioContext.createAnalyser(), this._webAudioAnalyser.minDecibels = -140, this._webAudioAnalyser.maxDecibels = 0, this._byteFreqs = new Uint8Array(this._webAudioAnalyser.frequencyBinCount), this._byteTime = new Uint8Array(this._webAudioAnalyser.frequencyBinCount), this._floatFreqs = new Float32Array(this._webAudioAnalyser.frequencyBinCount));
+ }
+ return r.prototype.getFrequencyBinCount = function() {
+ return this._audioEngine.canUseWebAudio ? this._webAudioAnalyser.frequencyBinCount : 0;
+ }, r.prototype.getByteFrequencyData = function() {
+ return this._audioEngine.canUseWebAudio && (this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING, this._webAudioAnalyser.fftSize = this.FFT_SIZE, this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs)), this._byteFreqs;
+ }, r.prototype.getByteTimeDomainData = function() {
+ return this._audioEngine.canUseWebAudio && (this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING, this._webAudioAnalyser.fftSize = this.FFT_SIZE, this._webAudioAnalyser.getByteTimeDomainData(this._byteTime)), this._byteTime;
+ }, r.prototype.getFloatFrequencyData = function() {
+ return this._audioEngine.canUseWebAudio && (this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING, this._webAudioAnalyser.fftSize = this.FFT_SIZE, this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs)), this._floatFreqs;
+ }, r.prototype.drawDebugCanvas = function() {
+ var t = this;
+ if (this._audioEngine.canUseWebAudio && (this._debugCanvas || (this._debugCanvas = document.createElement("canvas"), this._debugCanvas.width = this.DEBUGCANVASSIZE.width, this._debugCanvas.height = this.DEBUGCANVASSIZE.height, this._debugCanvas.style.position = "absolute", this._debugCanvas.style.top = this.DEBUGCANVASPOS.y + "px", this._debugCanvas.style.left = this.DEBUGCANVASPOS.x + "px", this._debugCanvasContext = this._debugCanvas.getContext("2d"), document.body.appendChild(this._debugCanvas), this._registerFunc = function() {
+ t.drawDebugCanvas();
+ }, this._scene.registerBeforeRender(this._registerFunc)), this._registerFunc && this._debugCanvasContext)) {
+ var e = this.getByteFrequencyData();
+ this._debugCanvasContext.fillStyle = "rgb(0, 0, 0)", this._debugCanvasContext.fillRect(0, 0, this.DEBUGCANVASSIZE.width, this.DEBUGCANVASSIZE.height);
+ for (var n = 0; n < this.getFrequencyBinCount(); n++) {
+ var i = e[n] / this.BARGRAPHAMPLITUDE, o = this.DEBUGCANVASSIZE.height * i, a = this.DEBUGCANVASSIZE.height - o - 1, s = this.DEBUGCANVASSIZE.width / this.getFrequencyBinCount(), d = n / this.getFrequencyBinCount() * 360;
+ this._debugCanvasContext.fillStyle = "hsl(" + d + ", 100%, 50%)", this._debugCanvasContext.fillRect(n * s, a, s, o);
+ }
+ }
+ }, r.prototype.stopDebugCanvas = function() {
+ this._debugCanvas && (this._registerFunc && (this._scene.unregisterBeforeRender(this._registerFunc), this._registerFunc = null), document.body.removeChild(this._debugCanvas), this._debugCanvas = null, this._debugCanvasContext = null);
+ }, r.prototype.connectAudioNodes = function(t, e) {
+ this._audioEngine.canUseWebAudio && (t.connect(this._webAudioAnalyser), this._webAudioAnalyser.connect(e));
+ }, r.prototype.dispose = function() {
+ this._audioEngine.canUseWebAudio && this._webAudioAnalyser.disconnect();
+ }, r;
+ }();
+ Ue.a.AudioEngineFactory = function(r) {
+ return new rr(r);
+ };
+ var rr = function() {
+ function r(t) {
+ var e = this;
+ t === void 0 && (t = null), this._audioContext = null, this._audioContextInitialized = !1, this._muteButton = null, this.canUseWebAudio = !1, this.WarnedWebAudioUnsupported = !1, this.isMP3supported = !1, this.isOGGsupported = !1, this.unlocked = !0, this.useCustomUnlockedButton = !1, this.onAudioUnlockedObservable = new C.c(), this.onAudioLockedObservable = new C.c(), this._tryToRun = !1, this._onResize = function() {
+ e._moveButtonToTopLeft();
+ }, window.AudioContext === void 0 && window.webkitAudioContext === void 0 || (window.AudioContext = window.AudioContext || window.webkitAudioContext, this.canUseWebAudio = !0);
+ var n = document.createElement("audio");
+ this._hostElement = t;
+ try {
+ n && n.canPlayType && (n.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/, "") || n.canPlayType("audio/mp3").replace(/^no$/, "")) && (this.isMP3supported = !0);
+ } catch {
+ }
+ try {
+ n && n.canPlayType && n.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, "") && (this.isOGGsupported = !0);
+ } catch {
+ }
+ }
+ return Object.defineProperty(r.prototype, "audioContext", { get: function() {
+ return this._audioContextInitialized ? this.unlocked || this._muteButton || this._displayMuteButton() : this._initializeAudioContext(), this._audioContext;
+ }, enumerable: !1, configurable: !0 }), r.prototype.lock = function() {
+ this._triggerSuspendedState();
+ }, r.prototype.unlock = function() {
+ this._triggerRunningState();
+ }, r.prototype._resumeAudioContext = function() {
+ var t;
+ return this._audioContext.resume !== void 0 && (t = this._audioContext.resume()), t || Promise.resolve();
+ }, r.prototype._initializeAudioContext = function() {
+ try {
+ this.canUseWebAudio && (this._audioContext = new AudioContext(), this.masterGain = this._audioContext.createGain(), this.masterGain.gain.value = 1, this.masterGain.connect(this._audioContext.destination), this._audioContextInitialized = !0, this._audioContext.state === "running" && this._triggerRunningState());
+ } catch (t) {
+ this.canUseWebAudio = !1, l.a.Error("Web Audio: " + t.message);
+ }
+ }, r.prototype._triggerRunningState = function() {
+ var t = this;
+ this._tryToRun || (this._tryToRun = !0, this._resumeAudioContext().then(function() {
+ t._tryToRun = !1, t._muteButton && t._hideMuteButton(), t.unlocked = !0, t.onAudioUnlockedObservable.notifyObservers(t);
+ }).catch(function() {
+ t._tryToRun = !1, t.unlocked = !1;
+ }));
+ }, r.prototype._triggerSuspendedState = function() {
+ this.unlocked = !1, this.onAudioLockedObservable.notifyObservers(this), this._displayMuteButton();
+ }, r.prototype._displayMuteButton = function() {
+ var t = this;
+ if (!this.useCustomUnlockedButton && !this._muteButton) {
+ this._muteButton = document.createElement("BUTTON"), this._muteButton.className = "babylonUnmuteIcon", this._muteButton.id = "babylonUnmuteIconBtn", this._muteButton.title = "Unmute";
+ var e = ".babylonUnmuteIcon { position: absolute; left: 20px; top: 20px; height: 40px; width: 60px; background-color: rgba(51,51,51,0.7); background-image: url(" + (window.SVGSVGElement ? "data:image/svg+xml;charset=UTF-8,%3Csvg%20version%3D%221.1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2239%22%20height%3D%2232%22%20viewBox%3D%220%200%2039%2032%22%3E%3Cpath%20fill%3D%22white%22%20d%3D%22M9.625%2018.938l-0.031%200.016h-4.953q-0.016%200-0.031-0.016v-12.453q0-0.016%200.031-0.016h4.953q0.031%200%200.031%200.016v12.453zM12.125%207.688l8.719-8.703v27.453l-8.719-8.719-0.016-0.047v-9.938zM23.359%207.875l1.406-1.406%204.219%204.203%204.203-4.203%201.422%201.406-4.219%204.219%204.219%204.203-1.484%201.359-4.141-4.156-4.219%204.219-1.406-1.422%204.219-4.203z%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E" : "https://cdn.babylonjs.com/Assets/audio.png") + "); background-size: 80%; background-repeat:no-repeat; background-position: center; background-position-y: 4px; border: none; outline: none; transition: transform 0.125s ease-out; cursor: pointer; z-index: 9999; } .babylonUnmuteIcon:hover { transform: scale(1.05) } .babylonUnmuteIcon:active { background-color: rgba(51,51,51,1) }", n = document.createElement("style");
+ n.appendChild(document.createTextNode(e)), document.getElementsByTagName("head")[0].appendChild(n), document.body.appendChild(this._muteButton), this._moveButtonToTopLeft(), this._muteButton.addEventListener("touchend", function() {
+ t._triggerRunningState();
+ }, !0), this._muteButton.addEventListener("click", function() {
+ t._triggerRunningState();
+ }, !0), window.addEventListener("resize", this._onResize);
+ }
+ }, r.prototype._moveButtonToTopLeft = function() {
+ this._hostElement && this._muteButton && (this._muteButton.style.top = this._hostElement.offsetTop + 20 + "px", this._muteButton.style.left = this._hostElement.offsetLeft + 20 + "px");
+ }, r.prototype._hideMuteButton = function() {
+ this._muteButton && (document.body.removeChild(this._muteButton), this._muteButton = null);
+ }, r.prototype.dispose = function() {
+ this.canUseWebAudio && this._audioContextInitialized && (this._connectedAnalyser && this._audioContext && (this._connectedAnalyser.stopDebugCanvas(), this._connectedAnalyser.dispose(), this.masterGain.disconnect(), this.masterGain.connect(this._audioContext.destination), this._connectedAnalyser = null), this.masterGain.gain.value = 1), this.WarnedWebAudioUnsupported = !1, this._hideMuteButton(), window.removeEventListener("resize", this._onResize), this.onAudioUnlockedObservable.clear(), this.onAudioLockedObservable.clear();
+ }, r.prototype.getGlobalVolume = function() {
+ return this.canUseWebAudio && this._audioContextInitialized ? this.masterGain.gain.value : -1;
+ }, r.prototype.setGlobalVolume = function(t) {
+ this.canUseWebAudio && this._audioContextInitialized && (this.masterGain.gain.value = t);
+ }, r.prototype.connectToAnalyser = function(t) {
+ this._connectedAnalyser && this._connectedAnalyser.stopDebugCanvas(), this.canUseWebAudio && this._audioContextInitialized && this._audioContext && (this._connectedAnalyser = t, this.masterGain.disconnect(), this._connectedAnalyser.connectAudioNodes(this.masterGain, this._audioContext.destination));
+ }, r;
+ }(), Xe = f(12), En = f(21), Qn = function() {
+ function r(t, e, n, i, o) {
+ var a, s, d, p, y = this;
+ if (i === void 0 && (i = null), this.autoplay = !1, this.loop = !1, this.useCustomAttenuation = !1, this.isPlaying = !1, this.isPaused = !1, this.spatialSound = !1, this.refDistance = 1, this.rolloffFactor = 1, this.maxDistance = 100, this.distanceModel = "linear", this.metadata = null, this.onEndedObservable = new C.c(), this._panningModel = "equalpower", this._playbackRate = 1, this._streaming = !1, this._startTime = 0, this._startOffset = 0, this._position = u.e.Zero(), this._positionInEmitterSpace = !1, this._localDirection = new u.e(1, 0, 0), this._volume = 1, this._isReadyToPlay = !1, this._isDirectional = !1, this._coneInnerAngle = 360, this._coneOuterAngle = 360, this._coneOuterGain = 0, this._isOutputConnected = !1, this._urlType = "Unknown", this.name = t, this._scene = n, r._SceneComponentInitialization(n), this._readyToPlayCallback = i, this._customAttenuationFunction = function(J, ie, se, ce, ue) {
+ return ie < se ? J * (1 - ie / se) : 0;
+ }, o && (this.autoplay = o.autoplay || !1, this.loop = o.loop || !1, o.volume !== void 0 && (this._volume = o.volume), this.spatialSound = (a = o.spatialSound) !== null && a !== void 0 && a, this.maxDistance = (s = o.maxDistance) !== null && s !== void 0 ? s : 100, this.useCustomAttenuation = (d = o.useCustomAttenuation) !== null && d !== void 0 && d, this.rolloffFactor = o.rolloffFactor || 1, this.refDistance = o.refDistance || 1, this.distanceModel = o.distanceModel || "linear", this._playbackRate = o.playbackRate || 1, this._streaming = (p = o.streaming) !== null && p !== void 0 && p, this._length = o.length, this._offset = o.offset), Ue.a.audioEngine.canUseWebAudio && Ue.a.audioEngine.audioContext) {
+ this._soundGain = Ue.a.audioEngine.audioContext.createGain(), this._soundGain.gain.value = this._volume, this._inputAudioNode = this._soundGain, this._outputAudioNode = this._soundGain, this.spatialSound && this._createSpatialParameters(), this._scene.mainSoundTrack.addSound(this);
+ var P = !0;
+ if (e)
+ try {
+ typeof e == "string" ? this._urlType = "String" : e instanceof ArrayBuffer ? this._urlType = "ArrayBuffer" : e instanceof MediaStream ? this._urlType = "MediaStream" : Array.isArray(e) && (this._urlType = "Array");
+ var R = [], B = !1;
+ switch (this._urlType) {
+ case "MediaStream":
+ this._streaming = !0, this._isReadyToPlay = !0, this._streamingSource = Ue.a.audioEngine.audioContext.createMediaStreamSource(e), this.autoplay && this.play(0, this._offset, this._length), this._readyToPlayCallback && this._readyToPlayCallback();
+ break;
+ case "ArrayBuffer":
+ e.byteLength > 0 && (B = !0, this._soundLoaded(e));
+ break;
+ case "String":
+ R.push(e);
+ case "Array":
+ R.length === 0 && (R = e);
+ for (var F = 0; F < R.length; F++) {
+ var z = R[F];
+ if (B = o && o.skipCodecCheck || z.indexOf(".mp3", z.length - 4) !== -1 && Ue.a.audioEngine.isMP3supported || z.indexOf(".ogg", z.length - 4) !== -1 && Ue.a.audioEngine.isOGGsupported || z.indexOf(".wav", z.length - 4) !== -1 || z.indexOf(".m4a", z.length - 4) !== -1 || z.indexOf("blob:") !== -1) {
+ this._streaming ? (this._htmlAudioElement = new Audio(z), this._htmlAudioElement.controls = !1, this._htmlAudioElement.loop = this.loop, Xe.b.SetCorsBehavior(z, this._htmlAudioElement), this._htmlAudioElement.preload = "auto", this._htmlAudioElement.addEventListener("canplaythrough", function() {
+ y._isReadyToPlay = !0, y.autoplay && y.play(0, y._offset, y._length), y._readyToPlayCallback && y._readyToPlayCallback();
+ }), document.body.appendChild(this._htmlAudioElement), this._htmlAudioElement.load()) : this._scene._loadFile(z, function(J) {
+ y._soundLoaded(J);
+ }, void 0, !0, !0, function(J) {
+ J && l.a.Error("XHR " + J.status + " error on: " + z + "."), l.a.Error("Sound creation aborted."), y._scene.mainSoundTrack.removeSound(y);
+ });
+ break;
+ }
+ }
+ break;
+ default:
+ P = !1;
+ }
+ P ? B || (this._isReadyToPlay = !0, this._readyToPlayCallback && window.setTimeout(function() {
+ y._readyToPlayCallback && y._readyToPlayCallback();
+ }, 1e3)) : l.a.Error("Parameter must be a URL to the sound, an Array of URLs (.mp3 & .ogg) or an ArrayBuffer of the sound.");
+ } catch {
+ l.a.Error("Unexpected error. Sound creation aborted."), this._scene.mainSoundTrack.removeSound(this);
+ }
+ } else
+ this._scene.mainSoundTrack.addSound(this), Ue.a.audioEngine.WarnedWebAudioUnsupported || (l.a.Error("Web Audio is not supported by your browser."), Ue.a.audioEngine.WarnedWebAudioUnsupported = !0), this._readyToPlayCallback && window.setTimeout(function() {
+ y._readyToPlayCallback && y._readyToPlayCallback();
+ }, 1e3);
+ }
+ return Object.defineProperty(r.prototype, "currentTime", { get: function() {
+ if (this._htmlAudioElement)
+ return this._htmlAudioElement.currentTime;
+ var t = this._startOffset;
+ return this.isPlaying && Ue.a.audioEngine.audioContext && (t += Ue.a.audioEngine.audioContext.currentTime - this._startTime), t;
+ }, enumerable: !1, configurable: !0 }), r.prototype.dispose = function() {
+ Ue.a.audioEngine.canUseWebAudio && (this.isPlaying && this.stop(), this._isReadyToPlay = !1, this.soundTrackId === -1 ? this._scene.mainSoundTrack.removeSound(this) : this._scene.soundTracks && this._scene.soundTracks[this.soundTrackId].removeSound(this), this._soundGain && (this._soundGain.disconnect(), this._soundGain = null), this._soundPanner && (this._soundPanner.disconnect(), this._soundPanner = null), this._soundSource && (this._soundSource.disconnect(), this._soundSource = null), this._audioBuffer = null, this._htmlAudioElement && (this._htmlAudioElement.pause(), this._htmlAudioElement.src = "", document.body.removeChild(this._htmlAudioElement)), this._streamingSource && this._streamingSource.disconnect(), this._connectedTransformNode && this._registerFunc && (this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc), this._connectedTransformNode = null));
+ }, r.prototype.isReady = function() {
+ return this._isReadyToPlay;
+ }, r.prototype._soundLoaded = function(t) {
+ var e = this;
+ Ue.a.audioEngine.audioContext && Ue.a.audioEngine.audioContext.decodeAudioData(t, function(n) {
+ e._audioBuffer = n, e._isReadyToPlay = !0, e.autoplay && e.play(0, e._offset, e._length), e._readyToPlayCallback && e._readyToPlayCallback();
+ }, function(n) {
+ l.a.Error("Error while decoding audio data for: " + e.name + " / Error: " + n);
+ });
+ }, r.prototype.setAudioBuffer = function(t) {
+ Ue.a.audioEngine.canUseWebAudio && (this._audioBuffer = t, this._isReadyToPlay = !0);
+ }, r.prototype.updateOptions = function(t) {
+ var e, n, i, o, a, s, d, p, y;
+ t && (this.loop = (e = t.loop) !== null && e !== void 0 ? e : this.loop, this.maxDistance = (n = t.maxDistance) !== null && n !== void 0 ? n : this.maxDistance, this.useCustomAttenuation = (i = t.useCustomAttenuation) !== null && i !== void 0 ? i : this.useCustomAttenuation, this.rolloffFactor = (o = t.rolloffFactor) !== null && o !== void 0 ? o : this.rolloffFactor, this.refDistance = (a = t.refDistance) !== null && a !== void 0 ? a : this.refDistance, this.distanceModel = (s = t.distanceModel) !== null && s !== void 0 ? s : this.distanceModel, this._playbackRate = (d = t.playbackRate) !== null && d !== void 0 ? d : this._playbackRate, this._length = (p = t.length) !== null && p !== void 0 ? p : void 0, this._offset = (y = t.offset) !== null && y !== void 0 ? y : void 0, this._updateSpatialParameters(), this.isPlaying && (this._streaming && this._htmlAudioElement ? (this._htmlAudioElement.playbackRate = this._playbackRate, this._htmlAudioElement.loop !== this.loop && (this._htmlAudioElement.loop = this.loop)) : this._soundSource && (this._soundSource.playbackRate.value = this._playbackRate, this._soundSource.loop !== this.loop && (this._soundSource.loop = this.loop), this._offset !== void 0 && this._soundSource.loopStart !== this._offset && (this._soundSource.loopStart = this._offset), this._length !== void 0 && this._length !== this._soundSource.loopEnd && (this._soundSource.loopEnd = (0 | this._offset) + this._length))));
+ }, r.prototype._createSpatialParameters = function() {
+ Ue.a.audioEngine.canUseWebAudio && Ue.a.audioEngine.audioContext && (this._scene.headphone && (this._panningModel = "HRTF"), this._soundPanner = Ue.a.audioEngine.audioContext.createPanner(), this._soundPanner && this._outputAudioNode && (this._updateSpatialParameters(), this._soundPanner.connect(this._outputAudioNode), this._inputAudioNode = this._soundPanner));
+ }, r.prototype._updateSpatialParameters = function() {
+ this.spatialSound && this._soundPanner && (this.useCustomAttenuation ? (this._soundPanner.distanceModel = "linear", this._soundPanner.maxDistance = Number.MAX_VALUE, this._soundPanner.refDistance = 1, this._soundPanner.rolloffFactor = 1, this._soundPanner.panningModel = this._panningModel) : (this._soundPanner.distanceModel = this.distanceModel, this._soundPanner.maxDistance = this.maxDistance, this._soundPanner.refDistance = this.refDistance, this._soundPanner.rolloffFactor = this.rolloffFactor, this._soundPanner.panningModel = this._panningModel));
+ }, r.prototype.switchPanningModelToHRTF = function() {
+ this._panningModel = "HRTF", this._switchPanningModel();
+ }, r.prototype.switchPanningModelToEqualPower = function() {
+ this._panningModel = "equalpower", this._switchPanningModel();
+ }, r.prototype._switchPanningModel = function() {
+ Ue.a.audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner && (this._soundPanner.panningModel = this._panningModel);
+ }, r.prototype.connectToSoundTrackAudioNode = function(t) {
+ Ue.a.audioEngine.canUseWebAudio && this._outputAudioNode && (this._isOutputConnected && this._outputAudioNode.disconnect(), this._outputAudioNode.connect(t), this._isOutputConnected = !0);
+ }, r.prototype.setDirectionalCone = function(t, e, n) {
+ e < t ? l.a.Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.") : (this._coneInnerAngle = t, this._coneOuterAngle = e, this._coneOuterGain = n, this._isDirectional = !0, this.isPlaying && this.loop && (this.stop(), this.play(0, this._offset, this._length)));
+ }, Object.defineProperty(r.prototype, "directionalConeInnerAngle", { get: function() {
+ return this._coneInnerAngle;
+ }, set: function(t) {
+ if (t != this._coneInnerAngle) {
+ if (this._coneOuterAngle < t)
+ return void l.a.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
+ this._coneInnerAngle = t, Ue.a.audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner && (this._soundPanner.coneInnerAngle = this._coneInnerAngle);
+ }
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "directionalConeOuterAngle", { get: function() {
+ return this._coneOuterAngle;
+ }, set: function(t) {
+ if (t != this._coneOuterAngle) {
+ if (t < this._coneInnerAngle)
+ return void l.a.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
+ this._coneOuterAngle = t, Ue.a.audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner && (this._soundPanner.coneOuterAngle = this._coneOuterAngle);
+ }
+ }, enumerable: !1, configurable: !0 }), r.prototype.setPosition = function(t) {
+ this._position = t, Ue.a.audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner && !isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z) && this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
+ }, r.prototype.setLocalDirectionToMesh = function(t) {
+ this._localDirection = t, Ue.a.audioEngine.canUseWebAudio && this._connectedTransformNode && this.isPlaying && this._updateDirection();
+ }, r.prototype._updateDirection = function() {
+ if (this._connectedTransformNode && this._soundPanner) {
+ var t = this._connectedTransformNode.getWorldMatrix(), e = u.e.TransformNormal(this._localDirection, t);
+ e.normalize(), this._soundPanner.setOrientation(e.x, e.y, e.z);
+ }
+ }, r.prototype.updateDistanceFromListener = function() {
+ if (Ue.a.audioEngine.canUseWebAudio && this._connectedTransformNode && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) {
+ var t = this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);
+ this._soundGain.gain.value = this._customAttenuationFunction(this._volume, t, this.maxDistance, this.refDistance, this.rolloffFactor);
+ }
+ }, r.prototype.setAttenuationFunction = function(t) {
+ this._customAttenuationFunction = t;
+ }, r.prototype.play = function(t, e, n) {
+ var i = this;
+ if (this._isReadyToPlay && this._scene.audioEnabled && Ue.a.audioEngine.audioContext)
+ try {
+ this._startOffset < 0 && (t = -this._startOffset, this._startOffset = 0);
+ var o = t ? Ue.a.audioEngine.audioContext.currentTime + t : Ue.a.audioEngine.audioContext.currentTime;
+ if (this._soundSource && this._streamingSource || this.spatialSound && this._soundPanner && (isNaN(this._position.x) || isNaN(this._position.y) || isNaN(this._position.z) || this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z), this._isDirectional && (this._soundPanner.coneInnerAngle = this._coneInnerAngle, this._soundPanner.coneOuterAngle = this._coneOuterAngle, this._soundPanner.coneOuterGain = this._coneOuterGain, this._connectedTransformNode ? this._updateDirection() : this._soundPanner.setOrientation(this._localDirection.x, this._localDirection.y, this._localDirection.z))), this._streaming)
+ this._streamingSource || (this._streamingSource = Ue.a.audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement), this._htmlAudioElement.onended = function() {
+ i._onended();
+ }, this._htmlAudioElement.playbackRate = this._playbackRate), this._streamingSource.disconnect(), this._inputAudioNode && this._streamingSource.connect(this._inputAudioNode), this._htmlAudioElement && (a = function() {
+ if (Ue.a.audioEngine.unlocked) {
+ var s = i._htmlAudioElement.play();
+ s !== void 0 && s.catch(function(d) {
+ Ue.a.audioEngine.lock(), (i.loop || i.autoplay) && Ue.a.audioEngine.onAudioUnlockedObservable.addOnce(function() {
+ a();
+ });
+ });
+ } else
+ (i.loop || i.autoplay) && Ue.a.audioEngine.onAudioUnlockedObservable.addOnce(function() {
+ a();
+ });
+ })();
+ else {
+ var a = function() {
+ if (Ue.a.audioEngine.audioContext) {
+ if (n = n || i._length, e = e || i._offset, i._soundSource) {
+ var s = i._soundSource;
+ s.onended = function() {
+ s.disconnect();
+ };
+ }
+ if (i._soundSource = Ue.a.audioEngine.audioContext.createBufferSource(), i._soundSource && i._inputAudioNode) {
+ i._soundSource.buffer = i._audioBuffer, i._soundSource.connect(i._inputAudioNode), i._soundSource.loop = i.loop, e !== void 0 && (i._soundSource.loopStart = e), n !== void 0 && (i._soundSource.loopEnd = (0 | e) + n), i._soundSource.playbackRate.value = i._playbackRate, i._soundSource.onended = function() {
+ i._onended();
+ }, o = t ? Ue.a.audioEngine.audioContext.currentTime + t : Ue.a.audioEngine.audioContext.currentTime;
+ var d = i.isPaused ? i._startOffset % i._soundSource.buffer.duration : e || 0;
+ i._soundSource.start(o, d, i.loop ? void 0 : n);
+ }
+ }
+ };
+ Ue.a.audioEngine.audioContext.state === "suspended" ? setTimeout(function() {
+ Ue.a.audioEngine.audioContext.state === "suspended" ? (Ue.a.audioEngine.lock(), (i.loop || i.autoplay) && Ue.a.audioEngine.onAudioUnlockedObservable.addOnce(function() {
+ a();
+ })) : a();
+ }, 500) : a();
+ }
+ this._startTime = o, this.isPlaying = !0, this.isPaused = !1;
+ } catch (s) {
+ l.a.Error("Error while trying to play audio: " + this.name + ", " + s.message);
+ }
+ }, r.prototype._onended = function() {
+ this.isPlaying = !1, this._startOffset = 0, this.onended && this.onended(), this.onEndedObservable.notifyObservers(this);
+ }, r.prototype.stop = function(t) {
+ var e = this;
+ if (this.isPlaying) {
+ if (this._streaming)
+ this._htmlAudioElement ? (this._htmlAudioElement.pause(), this._htmlAudioElement.currentTime > 0 && (this._htmlAudioElement.currentTime = 0)) : this._streamingSource.disconnect(), this.isPlaying = !1;
+ else if (Ue.a.audioEngine.audioContext && this._soundSource) {
+ var n = t ? Ue.a.audioEngine.audioContext.currentTime + t : Ue.a.audioEngine.audioContext.currentTime;
+ this._soundSource.stop(n), this._soundSource.onended = function() {
+ e.isPlaying = !1;
+ }, this.isPaused || (this._startOffset = 0);
+ }
+ }
+ }, r.prototype.pause = function() {
+ this.isPlaying && (this.isPaused = !0, this._streaming ? this._htmlAudioElement ? this._htmlAudioElement.pause() : this._streamingSource.disconnect() : Ue.a.audioEngine.audioContext && (this.stop(0), this._startOffset += Ue.a.audioEngine.audioContext.currentTime - this._startTime));
+ }, r.prototype.setVolume = function(t, e) {
+ Ue.a.audioEngine.canUseWebAudio && this._soundGain && (e && Ue.a.audioEngine.audioContext ? (this._soundGain.gain.cancelScheduledValues(Ue.a.audioEngine.audioContext.currentTime), this._soundGain.gain.setValueAtTime(this._soundGain.gain.value, Ue.a.audioEngine.audioContext.currentTime), this._soundGain.gain.linearRampToValueAtTime(t, Ue.a.audioEngine.audioContext.currentTime + e)) : this._soundGain.gain.value = t), this._volume = t;
+ }, r.prototype.setPlaybackRate = function(t) {
+ this._playbackRate = t, this.isPlaying && (this._streaming && this._htmlAudioElement ? this._htmlAudioElement.playbackRate = this._playbackRate : this._soundSource && (this._soundSource.playbackRate.value = this._playbackRate));
+ }, r.prototype.getVolume = function() {
+ return this._volume;
+ }, r.prototype.attachToMesh = function(t) {
+ var e = this;
+ this._connectedTransformNode && this._registerFunc && (this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc), this._registerFunc = null), this._connectedTransformNode = t, this.spatialSound || (this.spatialSound = !0, this._createSpatialParameters(), this.isPlaying && this.loop && (this.stop(), this.play(0, this._offset, this._length))), this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode), this._registerFunc = function(n) {
+ return e._onRegisterAfterWorldMatrixUpdate(n);
+ }, this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc);
+ }, r.prototype.detachFromMesh = function() {
+ this._connectedTransformNode && this._registerFunc && (this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc), this._registerFunc = null, this._connectedTransformNode = null);
+ }, r.prototype._onRegisterAfterWorldMatrixUpdate = function(t) {
+ if (this._positionInEmitterSpace)
+ t.worldMatrixFromCache.invertToRef(u.c.Matrix[0]), this.setPosition(u.c.Matrix[0].getTranslation());
+ else if (t.getBoundingInfo) {
+ var e = t.getBoundingInfo();
+ this.setPosition(e.boundingSphere.centerWorld);
+ } else
+ this.setPosition(t.absolutePosition);
+ Ue.a.audioEngine.canUseWebAudio && this._isDirectional && this.isPlaying && this._updateDirection();
+ }, r.prototype.clone = function() {
+ var t = this;
+ if (this._streaming)
+ return null;
+ var e = function() {
+ t._isReadyToPlay ? (i._audioBuffer = t.getAudioBuffer(), i._isReadyToPlay = !0, i.autoplay && i.play(0, t._offset, t._length)) : window.setTimeout(e, 300);
+ }, n = { autoplay: this.autoplay, loop: this.loop, volume: this._volume, spatialSound: this.spatialSound, maxDistance: this.maxDistance, useCustomAttenuation: this.useCustomAttenuation, rolloffFactor: this.rolloffFactor, refDistance: this.refDistance, distanceModel: this.distanceModel }, i = new r(this.name + "_cloned", new ArrayBuffer(0), this._scene, null, n);
+ return this.useCustomAttenuation && i.setAttenuationFunction(this._customAttenuationFunction), i.setPosition(this._position), i.setPlaybackRate(this._playbackRate), e(), i;
+ }, r.prototype.getAudioBuffer = function() {
+ return this._audioBuffer;
+ }, r.prototype.getSoundSource = function() {
+ return this._soundSource;
+ }, r.prototype.getSoundGain = function() {
+ return this._soundGain;
+ }, r.prototype.serialize = function() {
+ var t = { name: this.name, url: this.name, autoplay: this.autoplay, loop: this.loop, volume: this._volume, spatialSound: this.spatialSound, maxDistance: this.maxDistance, rolloffFactor: this.rolloffFactor, refDistance: this.refDistance, distanceModel: this.distanceModel, playbackRate: this._playbackRate, panningModel: this._panningModel, soundTrackId: this.soundTrackId, metadata: this.metadata };
+ return this.spatialSound && (this._connectedTransformNode && (t.connectedMeshId = this._connectedTransformNode.id), t.position = this._position.asArray(), t.refDistance = this.refDistance, t.distanceModel = this.distanceModel, t.isDirectional = this._isDirectional, t.localDirectionToMesh = this._localDirection.asArray(), t.coneInnerAngle = this._coneInnerAngle, t.coneOuterAngle = this._coneOuterAngle, t.coneOuterGain = this._coneOuterGain), t;
+ }, r.Parse = function(t, e, n, i) {
+ var o, a = t.name;
+ o = t.url ? n + t.url : n + a;
+ var s, d = { autoplay: t.autoplay, loop: t.loop, volume: t.volume, spatialSound: t.spatialSound, maxDistance: t.maxDistance, rolloffFactor: t.rolloffFactor, refDistance: t.refDistance, distanceModel: t.distanceModel, playbackRate: t.playbackRate };
+ if (i) {
+ var p = function() {
+ i._isReadyToPlay ? (s._audioBuffer = i.getAudioBuffer(), s._isReadyToPlay = !0, s.autoplay && s.play(0, s._offset, s._length)) : window.setTimeout(p, 300);
+ };
+ s = new r(a, new ArrayBuffer(0), e, null, d), p();
+ } else
+ s = new r(a, o, e, function() {
+ e._removePendingData(s);
+ }, d), e._addPendingData(s);
+ if (t.position) {
+ var y = u.e.FromArray(t.position);
+ s.setPosition(y);
+ }
+ if (t.isDirectional && (s.setDirectionalCone(t.coneInnerAngle || 360, t.coneOuterAngle || 360, t.coneOuterGain || 0), t.localDirectionToMesh)) {
+ var P = u.e.FromArray(t.localDirectionToMesh);
+ s.setLocalDirectionToMesh(P);
+ }
+ if (t.connectedMeshId) {
+ var R = e.getMeshByID(t.connectedMeshId);
+ R && s.attachToMesh(R);
+ }
+ return t.metadata && (s.metadata = t.metadata), s;
+ }, r._SceneComponentInitialization = function(t) {
+ throw En.a.WarnImport("AudioSceneComponent");
+ }, r;
+ }(), So = function() {
+ function r(t, e) {
+ e === void 0 && (e = {}), this.id = -1, this._isInitialized = !1, this._scene = t, this.soundCollection = new Array(), this._options = e, !this._options.mainTrack && this._scene.soundTracks && (this._scene.soundTracks.push(this), this.id = this._scene.soundTracks.length - 1);
+ }
+ return r.prototype._initializeSoundTrackAudioGraph = function() {
+ Ue.a.audioEngine.canUseWebAudio && Ue.a.audioEngine.audioContext && (this._outputAudioNode = Ue.a.audioEngine.audioContext.createGain(), this._outputAudioNode.connect(Ue.a.audioEngine.masterGain), this._options && this._options.volume && (this._outputAudioNode.gain.value = this._options.volume), this._isInitialized = !0);
+ }, r.prototype.dispose = function() {
+ if (Ue.a.audioEngine && Ue.a.audioEngine.canUseWebAudio) {
+ for (this._connectedAnalyser && this._connectedAnalyser.stopDebugCanvas(); this.soundCollection.length; )
+ this.soundCollection[0].dispose();
+ this._outputAudioNode && this._outputAudioNode.disconnect(), this._outputAudioNode = null;
+ }
+ }, r.prototype.addSound = function(t) {
+ this._isInitialized || this._initializeSoundTrackAudioGraph(), Ue.a.audioEngine.canUseWebAudio && this._outputAudioNode && t.connectToSoundTrackAudioNode(this._outputAudioNode), t.soundTrackId && (t.soundTrackId === -1 ? this._scene.mainSoundTrack.removeSound(t) : this._scene.soundTracks && this._scene.soundTracks[t.soundTrackId].removeSound(t)), this.soundCollection.push(t), t.soundTrackId = this.id;
+ }, r.prototype.removeSound = function(t) {
+ var e = this.soundCollection.indexOf(t);
+ e !== -1 && this.soundCollection.splice(e, 1);
+ }, r.prototype.setVolume = function(t) {
+ Ue.a.audioEngine.canUseWebAudio && this._outputAudioNode && (this._outputAudioNode.gain.value = t);
+ }, r.prototype.switchPanningModelToHRTF = function() {
+ if (Ue.a.audioEngine.canUseWebAudio)
+ for (var t = 0; t < this.soundCollection.length; t++)
+ this.soundCollection[t].switchPanningModelToHRTF();
+ }, r.prototype.switchPanningModelToEqualPower = function() {
+ if (Ue.a.audioEngine.canUseWebAudio)
+ for (var t = 0; t < this.soundCollection.length; t++)
+ this.soundCollection[t].switchPanningModelToEqualPower();
+ }, r.prototype.connectToAnalyser = function(t) {
+ this._connectedAnalyser && this._connectedAnalyser.stopDebugCanvas(), this._connectedAnalyser = t, Ue.a.audioEngine.canUseWebAudio && this._outputAudioNode && (this._outputAudioNode.disconnect(), this._connectedAnalyser.connectAudioNodes(this._outputAudioNode, Ue.a.audioEngine.masterGain));
+ }, r;
+ }(), ot = f(17);
+ V.a.AddParser(ot.a.NAME_AUDIO, function(r, t, e, n) {
+ var i, o = [];
+ if (e.sounds = e.sounds || [], r.sounds !== void 0 && r.sounds !== null)
+ for (var a = 0, s = r.sounds.length; a < s; a++) {
+ var d = r.sounds[a];
+ Ue.a.audioEngine.canUseWebAudio ? (d.url || (d.url = d.name), o[d.url] ? e.sounds.push(Qn.Parse(d, t, n, o[d.url])) : (i = Qn.Parse(d, t, n), o[d.url] = i, e.sounds.push(i))) : e.sounds.push(new Qn(d.name, null, t));
+ }
+ o = [];
+ }), Object.defineProperty(_e.a.prototype, "mainSoundTrack", { get: function() {
+ var r = this._getComponent(ot.a.NAME_AUDIO);
+ return r || (r = new qn(this), this._addComponent(r)), this._mainSoundTrack || (this._mainSoundTrack = new So(this, { mainTrack: !0 })), this._mainSoundTrack;
+ }, enumerable: !0, configurable: !0 }), _e.a.prototype.getSoundByName = function(r) {
+ var t;
+ for (t = 0; t < this.mainSoundTrack.soundCollection.length; t++)
+ if (this.mainSoundTrack.soundCollection[t].name === r)
+ return this.mainSoundTrack.soundCollection[t];
+ if (this.soundTracks) {
+ for (var e = 0; e < this.soundTracks.length; e++)
+ for (t = 0; t < this.soundTracks[e].soundCollection.length; t++)
+ if (this.soundTracks[e].soundCollection[t].name === r)
+ return this.soundTracks[e].soundCollection[t];
+ }
+ return null;
+ }, Object.defineProperty(_e.a.prototype, "audioEnabled", { get: function() {
+ var r = this._getComponent(ot.a.NAME_AUDIO);
+ return r || (r = new qn(this), this._addComponent(r)), r.audioEnabled;
+ }, set: function(r) {
+ var t = this._getComponent(ot.a.NAME_AUDIO);
+ t || (t = new qn(this), this._addComponent(t)), r ? t.enableAudio() : t.disableAudio();
+ }, enumerable: !0, configurable: !0 }), Object.defineProperty(_e.a.prototype, "headphone", { get: function() {
+ var r = this._getComponent(ot.a.NAME_AUDIO);
+ return r || (r = new qn(this), this._addComponent(r)), r.headphone;
+ }, set: function(r) {
+ var t = this._getComponent(ot.a.NAME_AUDIO);
+ t || (t = new qn(this), this._addComponent(t)), r ? t.switchAudioModeForHeadphones() : t.switchAudioModeForNormalSpeakers();
+ }, enumerable: !0, configurable: !0 }), Object.defineProperty(_e.a.prototype, "audioListenerPositionProvider", { get: function() {
+ var r = this._getComponent(ot.a.NAME_AUDIO);
+ return r || (r = new qn(this), this._addComponent(r)), r.audioListenerPositionProvider;
+ }, set: function(r) {
+ var t = this._getComponent(ot.a.NAME_AUDIO);
+ if (t || (t = new qn(this), this._addComponent(t)), typeof r != "function")
+ throw new Error("The value passed to [Scene.audioListenerPositionProvider] must be a function that returns a Vector3");
+ t.audioListenerPositionProvider = r;
+ }, enumerable: !0, configurable: !0 }), Object.defineProperty(_e.a.prototype, "audioPositioningRefreshRate", { get: function() {
+ var r = this._getComponent(ot.a.NAME_AUDIO);
+ return r || (r = new qn(this), this._addComponent(r)), r.audioPositioningRefreshRate;
+ }, set: function(r) {
+ var t = this._getComponent(ot.a.NAME_AUDIO);
+ t || (t = new qn(this), this._addComponent(t)), t.audioPositioningRefreshRate = r;
+ }, enumerable: !0, configurable: !0 });
+ var qn = function() {
+ function r(t) {
+ this.name = ot.a.NAME_AUDIO, this._audioEnabled = !0, this._headphone = !1, this.audioPositioningRefreshRate = 500, this._audioListenerPositionProvider = null, this._cachedCameraDirection = new u.e(), this._cachedCameraPosition = new u.e(), this._lastCheck = 0, this.scene = t, t.soundTracks = new Array(), t.sounds = new Array();
+ }
+ return Object.defineProperty(r.prototype, "audioEnabled", { get: function() {
+ return this._audioEnabled;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "headphone", { get: function() {
+ return this._headphone;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "audioListenerPositionProvider", { get: function() {
+ return this._audioListenerPositionProvider;
+ }, set: function(t) {
+ this._audioListenerPositionProvider = t;
+ }, enumerable: !1, configurable: !0 }), r.prototype.register = function() {
+ this.scene._afterRenderStage.registerStep(ot.a.STEP_AFTERRENDER_AUDIO, this, this._afterRender);
+ }, r.prototype.rebuild = function() {
+ }, r.prototype.serialize = function(t) {
+ if (t.sounds = [], this.scene.soundTracks)
+ for (var e = 0; e < this.scene.soundTracks.length; e++)
+ for (var n = this.scene.soundTracks[e], i = 0; i < n.soundCollection.length; i++)
+ t.sounds.push(n.soundCollection[i].serialize());
+ }, r.prototype.addFromContainer = function(t) {
+ var e = this;
+ t.sounds && t.sounds.forEach(function(n) {
+ n.play(), n.autoplay = !0, e.scene.mainSoundTrack.addSound(n);
+ });
+ }, r.prototype.removeFromContainer = function(t, e) {
+ var n = this;
+ e === void 0 && (e = !1), t.sounds && t.sounds.forEach(function(i) {
+ i.stop(), i.autoplay = !1, n.scene.mainSoundTrack.removeSound(i), e && i.dispose();
+ });
+ }, r.prototype.dispose = function() {
+ var t = this.scene;
+ if (t._mainSoundTrack && t.mainSoundTrack.dispose(), t.soundTracks)
+ for (var e = 0; e < t.soundTracks.length; e++)
+ t.soundTracks[e].dispose();
+ }, r.prototype.disableAudio = function() {
+ var t, e = this.scene;
+ for (this._audioEnabled = !1, Ue.a.audioEngine && Ue.a.audioEngine.audioContext && Ue.a.audioEngine.audioContext.suspend(), t = 0; t < e.mainSoundTrack.soundCollection.length; t++)
+ e.mainSoundTrack.soundCollection[t].pause();
+ if (e.soundTracks)
+ for (t = 0; t < e.soundTracks.length; t++)
+ for (var n = 0; n < e.soundTracks[t].soundCollection.length; n++)
+ e.soundTracks[t].soundCollection[n].pause();
+ }, r.prototype.enableAudio = function() {
+ var t, e = this.scene;
+ for (this._audioEnabled = !0, Ue.a.audioEngine && Ue.a.audioEngine.audioContext && Ue.a.audioEngine.audioContext.resume(), t = 0; t < e.mainSoundTrack.soundCollection.length; t++)
+ e.mainSoundTrack.soundCollection[t].isPaused && e.mainSoundTrack.soundCollection[t].play();
+ if (e.soundTracks)
+ for (t = 0; t < e.soundTracks.length; t++)
+ for (var n = 0; n < e.soundTracks[t].soundCollection.length; n++)
+ e.soundTracks[t].soundCollection[n].isPaused && e.soundTracks[t].soundCollection[n].play();
+ }, r.prototype.switchAudioModeForHeadphones = function() {
+ var t = this.scene;
+ if (this._headphone = !0, t.mainSoundTrack.switchPanningModelToHRTF(), t.soundTracks)
+ for (var e = 0; e < t.soundTracks.length; e++)
+ t.soundTracks[e].switchPanningModelToHRTF();
+ }, r.prototype.switchAudioModeForNormalSpeakers = function() {
+ var t = this.scene;
+ if (this._headphone = !1, t.mainSoundTrack.switchPanningModelToEqualPower(), t.soundTracks)
+ for (var e = 0; e < t.soundTracks.length; e++)
+ t.soundTracks[e].switchPanningModelToEqualPower();
+ }, r.prototype._afterRender = function() {
+ var t = ye.a.Now;
+ if (!(this._lastCheck && t - this._lastCheck < this.audioPositioningRefreshRate)) {
+ this._lastCheck = t;
+ var e = this.scene;
+ if (this._audioEnabled && e._mainSoundTrack && e.soundTracks && (e._mainSoundTrack.soundCollection.length !== 0 || e.soundTracks.length !== 1)) {
+ var n = Ue.a.audioEngine;
+ if (n && n.audioContext) {
+ if (this._audioListenerPositionProvider) {
+ var i = this._audioListenerPositionProvider();
+ i.x = i.x || 0, i.y = i.y || 0, i.z = i.z || 0, n.audioContext.listener.setPosition(i.x, i.y, i.z);
+ } else {
+ var o;
+ if (o = e.activeCameras && e.activeCameras.length > 0 ? e.activeCameras[0] : e.activeCamera) {
+ this._cachedCameraPosition.equals(o.globalPosition) || (this._cachedCameraPosition.copyFrom(o.globalPosition), n.audioContext.listener.setPosition(o.globalPosition.x, o.globalPosition.y, o.globalPosition.z)), o.rigCameras && o.rigCameras.length > 0 && (o = o.rigCameras[0]);
+ var a = u.a.Invert(o.getViewMatrix()), s = u.e.TransformNormal(e.useRightHandedSystem ? r._CameraDirectionRH : r._CameraDirectionLH, a);
+ s.normalize(), isNaN(s.x) || isNaN(s.y) || isNaN(s.z) || this._cachedCameraDirection.equals(s) || (this._cachedCameraDirection.copyFrom(s), n.audioContext.listener.setOrientation(s.x, s.y, s.z, 0, 1, 0));
+ } else
+ n.audioContext.listener.setPosition(0, 0, 0);
+ }
+ var d;
+ for (d = 0; d < e.mainSoundTrack.soundCollection.length; d++) {
+ var p = e.mainSoundTrack.soundCollection[d];
+ p.useCustomAttenuation && p.updateDistanceFromListener();
+ }
+ if (e.soundTracks)
+ for (d = 0; d < e.soundTracks.length; d++)
+ for (var y = 0; y < e.soundTracks[d].soundCollection.length; y++)
+ (p = e.soundTracks[d].soundCollection[y]).useCustomAttenuation && p.updateDistanceFromListener();
+ }
+ }
+ }
+ }, r._CameraDirectionLH = new u.e(0, 0, -1), r._CameraDirectionRH = new u.e(0, 0, 1), r;
+ }();
+ Qn._SceneComponentInitialization = function(r) {
+ var t = r._getComponent(ot.a.NAME_AUDIO);
+ t || (t = new qn(r), r._addComponent(t));
+ };
+ var lf = function() {
+ function r(t, e, n) {
+ var i = this;
+ if (this.loop = !1, this._coneInnerAngle = 360, this._coneOuterAngle = 360, this._volume = 1, this.isPlaying = !1, this.isPaused = !1, this._sounds = [], this._weights = [], e.length !== n.length)
+ throw new Error("Sounds length does not equal weights length");
+ this.loop = t, this._weights = n;
+ for (var o = 0, a = 0, s = n; a < s.length; a++)
+ o += s[a];
+ for (var d = o > 0 ? 1 / o : 0, p = 0; p < this._weights.length; p++)
+ this._weights[p] *= d;
+ this._sounds = e;
+ for (var y = 0, P = this._sounds; y < P.length; y++)
+ P[y].onEndedObservable.add(function() {
+ i._onended();
+ });
+ }
+ return Object.defineProperty(r.prototype, "directionalConeInnerAngle", { get: function() {
+ return this._coneInnerAngle;
+ }, set: function(t) {
+ if (t !== this._coneInnerAngle) {
+ if (this._coneOuterAngle < t)
+ return void l.a.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
+ this._coneInnerAngle = t;
+ for (var e = 0, n = this._sounds; e < n.length; e++)
+ n[e].directionalConeInnerAngle = t;
+ }
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "directionalConeOuterAngle", { get: function() {
+ return this._coneOuterAngle;
+ }, set: function(t) {
+ if (t !== this._coneOuterAngle) {
+ if (t < this._coneInnerAngle)
+ return void l.a.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
+ this._coneOuterAngle = t;
+ for (var e = 0, n = this._sounds; e < n.length; e++)
+ n[e].directionalConeOuterAngle = t;
+ }
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "volume", { get: function() {
+ return this._volume;
+ }, set: function(t) {
+ if (t !== this._volume)
+ for (var e = 0, n = this._sounds; e < n.length; e++)
+ n[e].setVolume(t);
+ }, enumerable: !1, configurable: !0 }), r.prototype._onended = function() {
+ this._currentIndex !== void 0 && (this._sounds[this._currentIndex].autoplay = !1), this.loop && this.isPlaying ? this.play() : this.isPlaying = !1;
+ }, r.prototype.pause = function() {
+ this.isPaused = !0, this._currentIndex !== void 0 && this._sounds[this._currentIndex].pause();
+ }, r.prototype.stop = function() {
+ this.isPlaying = !1, this._currentIndex !== void 0 && this._sounds[this._currentIndex].stop();
+ }, r.prototype.play = function(t) {
+ if (!this.isPaused) {
+ this.stop();
+ for (var e = Math.random(), n = 0, i = 0; i < this._weights.length; i++)
+ if (e <= (n += this._weights[i])) {
+ this._currentIndex = i;
+ break;
+ }
+ }
+ var o = this._sounds[this._currentIndex];
+ o.isReady() ? o.play(0, this.isPaused ? void 0 : t) : o.autoplay = !0, this.isPlaying = !0, this.isPaused = !1;
+ }, r;
+ }(), yt = f(18), Qc = function() {
+ function r() {
+ this._zoomStopsAnimation = !1, this._idleRotationSpeed = 0.05, this._idleRotationWaitTime = 2e3, this._idleRotationSpinupTime = 2e3, this._isPointerDown = !1, this._lastFrameTime = null, this._lastInteractionTime = -1 / 0, this._cameraRotationSpeed = 0, this._lastFrameRadius = 0;
+ }
+ return Object.defineProperty(r.prototype, "name", { get: function() {
+ return "AutoRotation";
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "zoomStopsAnimation", { get: function() {
+ return this._zoomStopsAnimation;
+ }, set: function(t) {
+ this._zoomStopsAnimation = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "idleRotationSpeed", { get: function() {
+ return this._idleRotationSpeed;
+ }, set: function(t) {
+ this._idleRotationSpeed = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "idleRotationWaitTime", { get: function() {
+ return this._idleRotationWaitTime;
+ }, set: function(t) {
+ this._idleRotationWaitTime = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "idleRotationSpinupTime", { get: function() {
+ return this._idleRotationSpinupTime;
+ }, set: function(t) {
+ this._idleRotationSpinupTime = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "rotationInProgress", { get: function() {
+ return Math.abs(this._cameraRotationSpeed) > 0;
+ }, enumerable: !1, configurable: !0 }), r.prototype.init = function() {
+ }, r.prototype.attach = function(t) {
+ var e = this;
+ this._attachedCamera = t;
+ var n = this._attachedCamera.getScene();
+ this._onPrePointerObservableObserver = n.onPrePointerObservable.add(function(i) {
+ i.type !== yt.a.POINTERDOWN ? i.type === yt.a.POINTERUP && (e._isPointerDown = !1) : e._isPointerDown = !0;
+ }), this._onAfterCheckInputsObserver = t.onAfterCheckInputsObservable.add(function() {
+ var i = ye.a.Now, o = 0;
+ e._lastFrameTime != null && (o = i - e._lastFrameTime), e._lastFrameTime = i, e._applyUserInteraction();
+ var a = i - e._lastInteractionTime - e._idleRotationWaitTime, s = Math.max(Math.min(a / e._idleRotationSpinupTime, 1), 0);
+ e._cameraRotationSpeed = e._idleRotationSpeed * s, e._attachedCamera && (e._attachedCamera.alpha -= e._cameraRotationSpeed * (o / 1e3));
+ });
+ }, r.prototype.detach = function() {
+ if (this._attachedCamera) {
+ var t = this._attachedCamera.getScene();
+ this._onPrePointerObservableObserver && t.onPrePointerObservable.remove(this._onPrePointerObservableObserver), this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver), this._attachedCamera = null;
+ }
+ }, r.prototype._userIsZooming = function() {
+ return !!this._attachedCamera && this._attachedCamera.inertialRadiusOffset !== 0;
+ }, r.prototype._shouldAnimationStopForInteraction = function() {
+ if (!this._attachedCamera)
+ return !1;
+ var t = !1;
+ return this._lastFrameRadius === this._attachedCamera.radius && this._attachedCamera.inertialRadiusOffset !== 0 && (t = !0), this._lastFrameRadius = this._attachedCamera.radius, this._zoomStopsAnimation ? t : this._userIsZooming();
+ }, r.prototype._applyUserInteraction = function() {
+ this._userIsMoving() && !this._shouldAnimationStopForInteraction() && (this._lastInteractionTime = ye.a.Now);
+ }, r.prototype._userIsMoving = function() {
+ return !!this._attachedCamera && (this._attachedCamera.inertialAlphaOffset !== 0 || this._attachedCamera.inertialBetaOffset !== 0 || this._attachedCamera.inertialRadiusOffset !== 0 || this._attachedCamera.inertialPanningX !== 0 || this._attachedCamera.inertialPanningY !== 0 || this._isPointerDown);
+ }, r;
+ }(), qc = function() {
+ function r() {
+ this.transitionDuration = 450, this.lowerRadiusTransitionRange = 2, this.upperRadiusTransitionRange = -2, this._autoTransitionRange = !1, this._radiusIsAnimating = !1, this._radiusBounceTransition = null, this._animatables = new Array();
+ }
+ return Object.defineProperty(r.prototype, "name", { get: function() {
+ return "Bouncing";
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "autoTransitionRange", { get: function() {
+ return this._autoTransitionRange;
+ }, set: function(t) {
+ var e = this;
+ if (this._autoTransitionRange !== t) {
+ this._autoTransitionRange = t;
+ var n = this._attachedCamera;
+ n && (t ? this._onMeshTargetChangedObserver = n.onMeshTargetChangedObservable.add(function(i) {
+ if (i) {
+ i.computeWorldMatrix(!0);
+ var o = i.getBoundingInfo().diagonalLength;
+ e.lowerRadiusTransitionRange = 0.05 * o, e.upperRadiusTransitionRange = 0.05 * o;
+ }
+ }) : this._onMeshTargetChangedObserver && n.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver));
+ }
+ }, enumerable: !1, configurable: !0 }), r.prototype.init = function() {
+ }, r.prototype.attach = function(t) {
+ var e = this;
+ this._attachedCamera = t, this._onAfterCheckInputsObserver = t.onAfterCheckInputsObservable.add(function() {
+ e._attachedCamera && (e._isRadiusAtLimit(e._attachedCamera.lowerRadiusLimit) && e._applyBoundRadiusAnimation(e.lowerRadiusTransitionRange), e._isRadiusAtLimit(e._attachedCamera.upperRadiusLimit) && e._applyBoundRadiusAnimation(e.upperRadiusTransitionRange));
+ });
+ }, r.prototype.detach = function() {
+ this._attachedCamera && (this._onAfterCheckInputsObserver && this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver), this._onMeshTargetChangedObserver && this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver), this._attachedCamera = null);
+ }, r.prototype._isRadiusAtLimit = function(t) {
+ return !!this._attachedCamera && this._attachedCamera.radius === t && !this._radiusIsAnimating;
+ }, r.prototype._applyBoundRadiusAnimation = function(t) {
+ var e = this;
+ if (this._attachedCamera) {
+ this._radiusBounceTransition || (r.EasingFunction.setEasingMode(r.EasingMode), this._radiusBounceTransition = k.CreateAnimation("radius", k.ANIMATIONTYPE_FLOAT, 60, r.EasingFunction)), this._cachedWheelPrecision = this._attachedCamera.wheelPrecision, this._attachedCamera.wheelPrecision = 1 / 0, this._attachedCamera.inertialRadiusOffset = 0, this.stopAllAnimations(), this._radiusIsAnimating = !0;
+ var n = k.TransitionTo("radius", this._attachedCamera.radius + t, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusBounceTransition, this.transitionDuration, function() {
+ return e._clearAnimationLocks();
+ });
+ n && this._animatables.push(n);
+ }
+ }, r.prototype._clearAnimationLocks = function() {
+ this._radiusIsAnimating = !1, this._attachedCamera && (this._attachedCamera.wheelPrecision = this._cachedWheelPrecision);
+ }, r.prototype.stopAllAnimations = function() {
+ for (this._attachedCamera && (this._attachedCamera.animations = []); this._animatables.length; )
+ this._animatables[0].onAnimationEnd = null, this._animatables[0].stop(), this._animatables.shift();
+ }, r.EasingFunction = new Je(0.3), r.EasingMode = Ge.EASINGMODE_EASEOUT, r;
+ }(), Zc = function() {
+ function r() {
+ this._mode = r.FitFrustumSidesMode, this._radiusScale = 1, this._positionScale = 0.5, this._defaultElevation = 0.3, this._elevationReturnTime = 1500, this._elevationReturnWaitTime = 1e3, this._zoomStopsAnimation = !1, this._framingTime = 1500, this.autoCorrectCameraLimitsAndSensibility = !0, this._isPointerDown = !1, this._lastInteractionTime = -1 / 0, this._animatables = new Array(), this._betaIsAnimating = !1;
+ }
+ return Object.defineProperty(r.prototype, "name", { get: function() {
+ return "Framing";
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "mode", { get: function() {
+ return this._mode;
+ }, set: function(t) {
+ this._mode = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "radiusScale", { get: function() {
+ return this._radiusScale;
+ }, set: function(t) {
+ this._radiusScale = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "positionScale", { get: function() {
+ return this._positionScale;
+ }, set: function(t) {
+ this._positionScale = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "defaultElevation", { get: function() {
+ return this._defaultElevation;
+ }, set: function(t) {
+ this._defaultElevation = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "elevationReturnTime", { get: function() {
+ return this._elevationReturnTime;
+ }, set: function(t) {
+ this._elevationReturnTime = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "elevationReturnWaitTime", { get: function() {
+ return this._elevationReturnWaitTime;
+ }, set: function(t) {
+ this._elevationReturnWaitTime = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "zoomStopsAnimation", { get: function() {
+ return this._zoomStopsAnimation;
+ }, set: function(t) {
+ this._zoomStopsAnimation = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "framingTime", { get: function() {
+ return this._framingTime;
+ }, set: function(t) {
+ this._framingTime = t;
+ }, enumerable: !1, configurable: !0 }), r.prototype.init = function() {
+ }, r.prototype.attach = function(t) {
+ var e = this;
+ this._attachedCamera = t;
+ var n = this._attachedCamera.getScene();
+ r.EasingFunction.setEasingMode(r.EasingMode), this._onPrePointerObservableObserver = n.onPrePointerObservable.add(function(i) {
+ i.type !== yt.a.POINTERDOWN ? i.type === yt.a.POINTERUP && (e._isPointerDown = !1) : e._isPointerDown = !0;
+ }), this._onMeshTargetChangedObserver = t.onMeshTargetChangedObservable.add(function(i) {
+ i && e.zoomOnMesh(i);
+ }), this._onAfterCheckInputsObserver = t.onAfterCheckInputsObservable.add(function() {
+ e._applyUserInteraction(), e._maintainCameraAboveGround();
+ });
+ }, r.prototype.detach = function() {
+ if (this._attachedCamera) {
+ var t = this._attachedCamera.getScene();
+ this._onPrePointerObservableObserver && t.onPrePointerObservable.remove(this._onPrePointerObservableObserver), this._onAfterCheckInputsObserver && this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver), this._onMeshTargetChangedObserver && this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver), this._attachedCamera = null;
+ }
+ }, r.prototype.zoomOnMesh = function(t, e, n) {
+ e === void 0 && (e = !1), n === void 0 && (n = null), t.computeWorldMatrix(!0);
+ var i = t.getBoundingInfo().boundingBox;
+ this.zoomOnBoundingInfo(i.minimumWorld, i.maximumWorld, e, n);
+ }, r.prototype.zoomOnMeshHierarchy = function(t, e, n) {
+ e === void 0 && (e = !1), n === void 0 && (n = null), t.computeWorldMatrix(!0);
+ var i = t.getHierarchyBoundingVectors(!0);
+ this.zoomOnBoundingInfo(i.min, i.max, e, n);
+ }, r.prototype.zoomOnMeshesHierarchy = function(t, e, n) {
+ e === void 0 && (e = !1), n === void 0 && (n = null);
+ for (var i = new u.e(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), o = new u.e(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE), a = 0; a < t.length; a++) {
+ var s = t[a].getHierarchyBoundingVectors(!0);
+ u.e.CheckExtends(s.min, i, o), u.e.CheckExtends(s.max, i, o);
+ }
+ this.zoomOnBoundingInfo(i, o, e, n);
+ }, r.prototype.zoomOnBoundingInfo = function(t, e, n, i) {
+ var o, a = this;
+ if (n === void 0 && (n = !1), i === void 0 && (i = null), this._attachedCamera) {
+ var s = t.y, d = s + (e.y - s) * this._positionScale, p = e.subtract(t).scale(0.5);
+ if (n)
+ o = new u.e(0, d, 0);
+ else {
+ var y = t.add(p);
+ o = new u.e(y.x, d, y.z);
+ }
+ this._vectorTransition || (this._vectorTransition = k.CreateAnimation("target", k.ANIMATIONTYPE_VECTOR3, 60, r.EasingFunction)), this._betaIsAnimating = !0;
+ var P = k.TransitionTo("target", o, this._attachedCamera, this._attachedCamera.getScene(), 60, this._vectorTransition, this._framingTime);
+ P && this._animatables.push(P);
+ var R = 0;
+ if (this._mode === r.FitFrustumSidesMode) {
+ var B = this._calculateLowerRadiusFromModelBoundingSphere(t, e);
+ this.autoCorrectCameraLimitsAndSensibility && (this._attachedCamera.lowerRadiusLimit = p.length() + this._attachedCamera.minZ), R = B;
+ } else
+ this._mode === r.IgnoreBoundsSizeMode && (R = this._calculateLowerRadiusFromModelBoundingSphere(t, e), this.autoCorrectCameraLimitsAndSensibility && this._attachedCamera.lowerRadiusLimit === null && (this._attachedCamera.lowerRadiusLimit = this._attachedCamera.minZ));
+ if (this.autoCorrectCameraLimitsAndSensibility) {
+ var F = e.subtract(t).length();
+ this._attachedCamera.panningSensibility = 5e3 / F, this._attachedCamera.wheelPrecision = 100 / R;
+ }
+ this._radiusTransition || (this._radiusTransition = k.CreateAnimation("radius", k.ANIMATIONTYPE_FLOAT, 60, r.EasingFunction)), (P = k.TransitionTo("radius", R, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime, function() {
+ a.stopAllAnimations(), i && i(), a._attachedCamera && a._attachedCamera.useInputToRestoreState && a._attachedCamera.storeState();
+ })) && this._animatables.push(P);
+ }
+ }, r.prototype._calculateLowerRadiusFromModelBoundingSphere = function(t, e) {
+ var n = e.subtract(t).length(), i = this._getFrustumSlope(), o = 0.5 * n * this._radiusScale, a = o * Math.sqrt(1 + 1 / (i.x * i.x)), s = o * Math.sqrt(1 + 1 / (i.y * i.y)), d = Math.max(a, s), p = this._attachedCamera;
+ return p ? (p.lowerRadiusLimit && this._mode === r.IgnoreBoundsSizeMode && (d = d < p.lowerRadiusLimit ? p.lowerRadiusLimit : d), p.upperRadiusLimit && (d = d > p.upperRadiusLimit ? p.upperRadiusLimit : d), d) : 0;
+ }, r.prototype._maintainCameraAboveGround = function() {
+ var t = this;
+ if (!(this._elevationReturnTime < 0)) {
+ var e = ye.a.Now - this._lastInteractionTime, n = 0.5 * Math.PI - this._defaultElevation, i = 0.5 * Math.PI;
+ if (this._attachedCamera && !this._betaIsAnimating && this._attachedCamera.beta > i && e >= this._elevationReturnWaitTime) {
+ this._betaIsAnimating = !0, this.stopAllAnimations(), this._betaTransition || (this._betaTransition = k.CreateAnimation("beta", k.ANIMATIONTYPE_FLOAT, 60, r.EasingFunction));
+ var o = k.TransitionTo("beta", n, this._attachedCamera, this._attachedCamera.getScene(), 60, this._betaTransition, this._elevationReturnTime, function() {
+ t._clearAnimationLocks(), t.stopAllAnimations();
+ });
+ o && this._animatables.push(o);
+ }
+ }
+ }, r.prototype._getFrustumSlope = function() {
+ var t = this._attachedCamera;
+ if (!t)
+ return u.d.Zero();
+ var e = t.getScene().getEngine().getAspectRatio(t), n = Math.tan(t.fov / 2), i = n * e;
+ return new u.d(i, n);
+ }, r.prototype._clearAnimationLocks = function() {
+ this._betaIsAnimating = !1;
+ }, r.prototype._applyUserInteraction = function() {
+ this.isUserIsMoving && (this._lastInteractionTime = ye.a.Now, this.stopAllAnimations(), this._clearAnimationLocks());
+ }, r.prototype.stopAllAnimations = function() {
+ for (this._attachedCamera && (this._attachedCamera.animations = []); this._animatables.length; )
+ this._animatables[0] && (this._animatables[0].onAnimationEnd = null, this._animatables[0].stop()), this._animatables.shift();
+ }, Object.defineProperty(r.prototype, "isUserIsMoving", { get: function() {
+ return !!this._attachedCamera && (this._attachedCamera.inertialAlphaOffset !== 0 || this._attachedCamera.inertialBetaOffset !== 0 || this._attachedCamera.inertialRadiusOffset !== 0 || this._attachedCamera.inertialPanningX !== 0 || this._attachedCamera.inertialPanningY !== 0 || this._isPointerDown);
+ }, enumerable: !1, configurable: !0 }), r.EasingFunction = new Tt(), r.EasingMode = Ge.EASINGMODE_EASEINOUT, r.IgnoreBoundsSizeMode = 0, r.FitFrustumSidesMode = 1, r;
+ }(), or = function(r, t, e, n) {
+ t === void 0 && (t = new u.e()), e === void 0 && (e = 0), n === void 0 && (n = !1), this.direction = r, this.rotatedDirection = t, this.diff = e, this.ignore = n;
+ }, uf = function() {
+ function r(t) {
+ this.ui = t, this.name = "AttachToBoxBehavior", this.distanceAwayFromFace = 0.15, this.distanceAwayFromBottomOfFace = 0.15, this._faceVectors = [new or(u.e.Up()), new or(u.e.Down()), new or(u.e.Left()), new or(u.e.Right()), new or(u.e.Forward()), new or(u.e.Forward().scaleInPlace(-1))], this._tmpMatrix = new u.a(), this._tmpVector = new u.e(), this._zeroVector = u.e.Zero(), this._lookAtTmpMatrix = new u.a();
+ }
+ return r.prototype.init = function() {
+ }, r.prototype._closestFace = function(t) {
+ var e = this;
+ return this._faceVectors.forEach(function(n) {
+ e._target.rotationQuaternion || (e._target.rotationQuaternion = u.b.RotationYawPitchRoll(e._target.rotation.y, e._target.rotation.x, e._target.rotation.z)), e._target.rotationQuaternion.toRotationMatrix(e._tmpMatrix), u.e.TransformCoordinatesToRef(n.direction, e._tmpMatrix, n.rotatedDirection), n.diff = u.e.GetAngleBetweenVectors(n.rotatedDirection, t, u.e.Cross(n.rotatedDirection, t));
+ }), this._faceVectors.reduce(function(n, i) {
+ return n.ignore ? i : i.ignore || n.diff < i.diff ? n : i;
+ }, this._faceVectors[0]);
+ }, r.prototype._lookAtToRef = function(t, e, n) {
+ e === void 0 && (e = new u.e(0, 1, 0)), u.a.LookAtLHToRef(this._zeroVector, t, e, this._lookAtTmpMatrix), this._lookAtTmpMatrix.invert(), u.b.FromRotationMatrixToRef(this._lookAtTmpMatrix, n);
+ }, r.prototype.attach = function(t) {
+ var e = this;
+ this._target = t, this._scene = this._target.getScene(), this._onRenderObserver = this._scene.onBeforeRenderObservable.add(function() {
+ if (e._scene.activeCamera) {
+ var n = e._scene.activeCamera.position;
+ e._scene.activeCamera.devicePosition && (n = e._scene.activeCamera.devicePosition);
+ var i = e._closestFace(n.subtract(t.position));
+ e._scene.activeCamera.leftCamera ? e._scene.activeCamera.leftCamera.computeWorldMatrix().getRotationMatrixToRef(e._tmpMatrix) : e._scene.activeCamera.computeWorldMatrix().getRotationMatrixToRef(e._tmpMatrix), u.e.TransformCoordinatesToRef(u.e.Up(), e._tmpMatrix, e._tmpVector), e._faceVectors.forEach(function(a) {
+ i.direction.x && a.direction.x && (a.ignore = !0), i.direction.y && a.direction.y && (a.ignore = !0), i.direction.z && a.direction.z && (a.ignore = !0);
+ });
+ var o = e._closestFace(e._tmpVector);
+ e._faceVectors.forEach(function(a) {
+ a.ignore = !1;
+ }), e.ui.position.copyFrom(t.position), i.direction.x && (i.rotatedDirection.scaleToRef(t.scaling.x / 2 + e.distanceAwayFromFace, e._tmpVector), e.ui.position.addInPlace(e._tmpVector)), i.direction.y && (i.rotatedDirection.scaleToRef(t.scaling.y / 2 + e.distanceAwayFromFace, e._tmpVector), e.ui.position.addInPlace(e._tmpVector)), i.direction.z && (i.rotatedDirection.scaleToRef(t.scaling.z / 2 + e.distanceAwayFromFace, e._tmpVector), e.ui.position.addInPlace(e._tmpVector)), e.ui.rotationQuaternion || (e.ui.rotationQuaternion = u.b.RotationYawPitchRoll(e.ui.rotation.y, e.ui.rotation.x, e.ui.rotation.z)), i.rotatedDirection.scaleToRef(-1, e._tmpVector), e._lookAtToRef(e._tmpVector, o.rotatedDirection, e.ui.rotationQuaternion), o.direction.x && e.ui.up.scaleToRef(e.distanceAwayFromBottomOfFace - t.scaling.x / 2, e._tmpVector), o.direction.y && e.ui.up.scaleToRef(e.distanceAwayFromBottomOfFace - t.scaling.y / 2, e._tmpVector), o.direction.z && e.ui.up.scaleToRef(e.distanceAwayFromBottomOfFace - t.scaling.z / 2, e._tmpVector), e.ui.position.addInPlace(e._tmpVector);
+ }
+ });
+ }, r.prototype.detach = function() {
+ this._scene.onBeforeRenderObservable.remove(this._onRenderObserver);
+ }, r;
+ }(), hf = function() {
+ function r() {
+ var t = this;
+ this.delay = 0, this.fadeInTime = 300, this._millisecondsPerFrame = 1e3 / 60, this._hovered = !1, this._hoverValue = 0, this._ownerNode = null, this._update = function() {
+ if (t._ownerNode) {
+ if (t._hoverValue += t._hovered ? t._millisecondsPerFrame : -t._millisecondsPerFrame, t._setAllVisibility(t._ownerNode, (t._hoverValue - t.delay) / t.fadeInTime), t._ownerNode.visibility > 1)
+ return t._setAllVisibility(t._ownerNode, 1), void (t._hoverValue = t.fadeInTime + t.delay);
+ if (t._ownerNode.visibility < 0 && (t._setAllVisibility(t._ownerNode, 0), t._hoverValue < 0))
+ return void (t._hoverValue = 0);
+ setTimeout(t._update, t._millisecondsPerFrame);
+ }
+ };
+ }
+ return Object.defineProperty(r.prototype, "name", { get: function() {
+ return "FadeInOut";
+ }, enumerable: !1, configurable: !0 }), r.prototype.init = function() {
+ }, r.prototype.attach = function(t) {
+ this._ownerNode = t, this._setAllVisibility(this._ownerNode, 0);
+ }, r.prototype.detach = function() {
+ this._ownerNode = null;
+ }, r.prototype.fadeIn = function(t) {
+ this._hovered = t, this._update();
+ }, r.prototype._setAllVisibility = function(t, e) {
+ var n = this;
+ t.visibility = e, t.getChildMeshes().forEach(function(i) {
+ n._setAllVisibility(i, e);
+ });
+ }, r;
+ }(), fi = f(65), df = function() {
+ function r() {
+ this._startDistance = 0, this._initialScale = new u.e(0, 0, 0), this._targetScale = new u.e(0, 0, 0), this._sceneRenderObserver = null, this._dragBehaviorA = new fi.a({}), this._dragBehaviorA.moveAttached = !1, this._dragBehaviorB = new fi.a({}), this._dragBehaviorB.moveAttached = !1;
+ }
+ return Object.defineProperty(r.prototype, "name", { get: function() {
+ return "MultiPointerScale";
+ }, enumerable: !1, configurable: !0 }), r.prototype.init = function() {
+ }, r.prototype._getCurrentDistance = function() {
+ return this._dragBehaviorA.lastDragPosition.subtract(this._dragBehaviorB.lastDragPosition).length();
+ }, r.prototype.attach = function(t) {
+ var e = this;
+ this._ownerNode = t, this._dragBehaviorA.onDragStartObservable.add(function(n) {
+ e._dragBehaviorA.dragging && e._dragBehaviorB.dragging && (e._dragBehaviorA.currentDraggingPointerID == e._dragBehaviorB.currentDraggingPointerID ? e._dragBehaviorA.releaseDrag() : (e._initialScale.copyFrom(t.scaling), e._startDistance = e._getCurrentDistance()));
+ }), this._dragBehaviorB.onDragStartObservable.add(function(n) {
+ e._dragBehaviorA.dragging && e._dragBehaviorB.dragging && (e._dragBehaviorA.currentDraggingPointerID == e._dragBehaviorB.currentDraggingPointerID ? e._dragBehaviorB.releaseDrag() : (e._initialScale.copyFrom(t.scaling), e._startDistance = e._getCurrentDistance()));
+ }), [this._dragBehaviorA, this._dragBehaviorB].forEach(function(n) {
+ n.onDragObservable.add(function() {
+ if (e._dragBehaviorA.dragging && e._dragBehaviorB.dragging) {
+ var i = e._getCurrentDistance() / e._startDistance;
+ e._initialScale.scaleToRef(i, e._targetScale);
+ }
+ });
+ }), t.addBehavior(this._dragBehaviorA), t.addBehavior(this._dragBehaviorB), this._sceneRenderObserver = t.getScene().onBeforeRenderObservable.add(function() {
+ if (e._dragBehaviorA.dragging && e._dragBehaviorB.dragging) {
+ var n = e._targetScale.subtract(t.scaling).scaleInPlace(0.1);
+ n.length() > 0.01 && t.scaling.addInPlace(n);
+ }
+ });
+ }, r.prototype.detach = function() {
+ var t = this;
+ this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver), [this._dragBehaviorA, this._dragBehaviorB].forEach(function(e) {
+ e.onDragStartObservable.clear(), e.onDragObservable.clear(), t._ownerNode.removeBehavior(e);
+ });
+ }, r;
+ }(), Mt = f(31), _t = f(24), Un = f(60), Jc = function() {
+ function r() {
+ this._sceneRenderObserver = null, this._targetPosition = new u.e(0, 0, 0), this._moving = !1, this._startingOrientation = new u.b(), this._attachedToElement = !1, this.zDragFactor = 3, this.rotateDraggedObject = !0, this.dragging = !1, this.dragDeltaRatio = 0.2, this.currentDraggingPointerID = -1, this.detachCameraControls = !0, this.onDragStartObservable = new C.c(), this.onDragObservable = new C.c(), this.onDragEndObservable = new C.c();
+ }
+ return Object.defineProperty(r.prototype, "name", { get: function() {
+ return "SixDofDrag";
+ }, enumerable: !1, configurable: !0 }), r.prototype.init = function() {
+ }, Object.defineProperty(r.prototype, "_pointerCamera", { get: function() {
+ return this._scene.cameraToUseForPointers ? this._scene.cameraToUseForPointers : this._scene.activeCamera;
+ }, enumerable: !1, configurable: !0 }), r.prototype.attach = function(t) {
+ var e = this;
+ this._ownerNode = t, this._scene = this._ownerNode.getScene(), r._virtualScene || (r._virtualScene = new _e.a(this._scene.getEngine(), { virtual: !0 }), r._virtualScene.detachControl(), this._scene.getEngine().scenes.pop());
+ var n = null, i = new u.e(0, 0, 0);
+ this._virtualOriginMesh = new Mt.a("", r._virtualScene), this._virtualOriginMesh.rotationQuaternion = new u.b(), this._virtualDragMesh = new Mt.a("", r._virtualScene), this._virtualDragMesh.rotationQuaternion = new u.b(), this._pointerObserver = this._scene.onPointerObservable.add(function(a, s) {
+ if (a.type == yt.a.POINTERDOWN) {
+ if (!e.dragging && a.pickInfo && a.pickInfo.hit && a.pickInfo.pickedMesh && a.pickInfo.ray && (R = a.pickInfo.pickedMesh, e._ownerNode == R || R.isDescendantOf(e._ownerNode))) {
+ e._pointerCamera && e._pointerCamera.cameraRigMode == _t.a.RIG_MODE_NONE && a.pickInfo.ray.origin.copyFrom(e._pointerCamera.globalPosition), n = e._ownerNode, Un.a._RemoveAndStorePivotPoint(n), i.copyFrom(a.pickInfo.ray.origin), e._virtualOriginMesh.position.copyFrom(a.pickInfo.ray.origin), e._virtualOriginMesh.lookAt(a.pickInfo.ray.origin.add(a.pickInfo.ray.direction)), e._virtualOriginMesh.removeChild(e._virtualDragMesh), n.computeWorldMatrix(), e._virtualDragMesh.position.copyFrom(n.absolutePosition), n.rotationQuaternion || (n.rotationQuaternion = u.b.RotationYawPitchRoll(n.rotation.y, n.rotation.x, n.rotation.z));
+ var d = n.parent;
+ n.setParent(null), e._virtualDragMesh.rotationQuaternion.copyFrom(n.rotationQuaternion), n.setParent(d), e._virtualOriginMesh.addChild(e._virtualDragMesh), e._targetPosition.copyFrom(e._virtualDragMesh.absolutePosition), e.dragging = !0, e.currentDraggingPointerID = a.event.pointerId, e.detachCameraControls && e._pointerCamera && !e._pointerCamera.leftCamera && (e._pointerCamera.inputs.attachedToElement ? (e._pointerCamera.detachControl(), e._attachedToElement = !0) : e._attachedToElement = !1), Un.a._RestorePivotPoint(n), e.onDragStartObservable.notifyObservers({});
+ }
+ } else if (a.type == yt.a.POINTERUP || a.type == yt.a.POINTERDOUBLETAP)
+ e.currentDraggingPointerID == a.event.pointerId && (e.dragging = !1, e._moving = !1, e.currentDraggingPointerID = -1, n = null, e._virtualOriginMesh.removeChild(e._virtualDragMesh), e.detachCameraControls && e._attachedToElement && e._pointerCamera && !e._pointerCamera.leftCamera && (e._pointerCamera.attachControl(!0), e._attachedToElement = !1), e.onDragEndObservable.notifyObservers({}));
+ else if (a.type == yt.a.POINTERMOVE && e.currentDraggingPointerID == a.event.pointerId && e.dragging && a.pickInfo && a.pickInfo.ray && n) {
+ var p = e.zDragFactor;
+ e._pointerCamera && e._pointerCamera.cameraRigMode == _t.a.RIG_MODE_NONE && (a.pickInfo.ray.origin.copyFrom(e._pointerCamera.globalPosition), p = 0);
+ var y = a.pickInfo.ray.origin.subtract(i);
+ i.copyFrom(a.pickInfo.ray.origin);
+ var P = -u.e.Dot(y, a.pickInfo.ray.direction);
+ e._virtualOriginMesh.addChild(e._virtualDragMesh), e._virtualDragMesh.position.z -= e._virtualDragMesh.position.z < 1 ? P * e.zDragFactor : P * p * e._virtualDragMesh.position.z, e._virtualDragMesh.position.z < 0 && (e._virtualDragMesh.position.z = 0), e._virtualOriginMesh.position.copyFrom(a.pickInfo.ray.origin), e._virtualOriginMesh.lookAt(a.pickInfo.ray.origin.add(a.pickInfo.ray.direction)), e._virtualOriginMesh.removeChild(e._virtualDragMesh), e._targetPosition.copyFrom(e._virtualDragMesh.absolutePosition), n.parent && u.e.TransformCoordinatesToRef(e._targetPosition, u.a.Invert(n.parent.getWorldMatrix()), e._targetPosition), e._moving || e._startingOrientation.copyFrom(e._virtualDragMesh.rotationQuaternion), e._moving = !0;
+ }
+ var R;
+ });
+ var o = new u.b();
+ this._sceneRenderObserver = t.getScene().onBeforeRenderObservable.add(function() {
+ if (e.dragging && e._moving && n) {
+ if (Un.a._RemoveAndStorePivotPoint(n), n.position.addInPlace(e._targetPosition.subtract(n.position).scale(e.dragDeltaRatio)), e.rotateDraggedObject) {
+ o.copyFrom(e._startingOrientation), o.x = -o.x, o.y = -o.y, o.z = -o.z, e._virtualDragMesh.rotationQuaternion.multiplyToRef(o, o), u.b.RotationYawPitchRollToRef(o.toEulerAngles("xyz").y, 0, 0, o), o.multiplyToRef(e._startingOrientation, o);
+ var a = n.parent;
+ (!a || a.scaling && !a.scaling.isNonUniformWithinEpsilon(1e-3)) && (n.setParent(null), u.b.SlerpToRef(n.rotationQuaternion, o, e.dragDeltaRatio, n.rotationQuaternion), n.setParent(a));
+ }
+ Un.a._RestorePivotPoint(n), e.onDragObservable.notifyObservers();
+ }
+ });
+ }, r.prototype.detach = function() {
+ this._scene && (this.detachCameraControls && this._attachedToElement && this._pointerCamera && !this._pointerCamera.leftCamera && (this._pointerCamera.attachControl(!0), this._attachedToElement = !1), this._scene.onPointerObservable.remove(this._pointerObserver)), this._ownerNode && this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver), this._virtualOriginMesh && this._virtualOriginMesh.dispose(), this._virtualDragMesh && this._virtualDragMesh.dispose(), this.onDragEndObservable.clear(), this.onDragObservable.clear(), this.onDragStartObservable.clear();
+ }, r;
+ }(), ff = function() {
+ function r(t, e, n) {
+ if (this.targetPosition = u.e.Zero(), this.poleTargetPosition = u.e.Zero(), this.poleTargetLocalOffset = u.e.Zero(), this.poleAngle = 0, this.slerpAmount = 1, this._bone1Quat = u.b.Identity(), this._bone1Mat = u.a.Identity(), this._bone2Ang = Math.PI, this._maxAngle = Math.PI, this._rightHandedSystem = !1, this._bendAxis = u.e.Right(), this._slerping = !1, this._adjustRoll = 0, this._bone2 = e, this._bone1 = e.getParent(), this._bone1) {
+ this.mesh = t;
+ var i = e.getPosition();
+ if (e.getAbsoluteTransform().determinant() > 0 && (this._rightHandedSystem = !0, this._bendAxis.x = 0, this._bendAxis.y = 0, this._bendAxis.z = -1, i.x > i.y && i.x > i.z && (this._adjustRoll = 0.5 * Math.PI, this._bendAxis.z = 1)), this._bone1.length) {
+ var o = this._bone1.getScale(), a = this._bone2.getScale();
+ this._bone1Length = this._bone1.length * o.y * this.mesh.scaling.y, this._bone2Length = this._bone2.length * a.y * this.mesh.scaling.y;
+ } else if (this._bone1.children[0]) {
+ t.computeWorldMatrix(!0);
+ var s = this._bone2.children[0].getAbsolutePosition(t), d = this._bone2.getAbsolutePosition(t), p = this._bone1.getAbsolutePosition(t);
+ this._bone1Length = u.e.Distance(s, d), this._bone2Length = u.e.Distance(d, p);
+ }
+ this._bone1.getRotationMatrixToRef(be.c.WORLD, t, this._bone1Mat), this.maxAngle = Math.PI, n && (n.targetMesh && (this.targetMesh = n.targetMesh, this.targetMesh.computeWorldMatrix(!0)), n.poleTargetMesh ? (this.poleTargetMesh = n.poleTargetMesh, this.poleTargetMesh.computeWorldMatrix(!0)) : n.poleTargetBone ? this.poleTargetBone = n.poleTargetBone : this._bone1.getParent() && (this.poleTargetBone = this._bone1.getParent()), n.poleTargetLocalOffset && this.poleTargetLocalOffset.copyFrom(n.poleTargetLocalOffset), n.poleAngle && (this.poleAngle = n.poleAngle), n.bendAxis && this._bendAxis.copyFrom(n.bendAxis), n.maxAngle && (this.maxAngle = n.maxAngle), n.slerpAmount && (this.slerpAmount = n.slerpAmount));
+ }
+ }
+ return Object.defineProperty(r.prototype, "maxAngle", { get: function() {
+ return this._maxAngle;
+ }, set: function(t) {
+ this._setMaxAngle(t);
+ }, enumerable: !1, configurable: !0 }), r.prototype._setMaxAngle = function(t) {
+ t < 0 && (t = 0), (t > Math.PI || t == null) && (t = Math.PI), this._maxAngle = t;
+ var e = this._bone1Length, n = this._bone2Length;
+ this._maxReach = Math.sqrt(e * e + n * n - 2 * e * n * Math.cos(t));
+ }, r.prototype.update = function() {
+ var t = this._bone1;
+ if (t) {
+ var e = this.targetPosition, n = this.poleTargetPosition, i = r._tmpMats[0], o = r._tmpMats[1];
+ this.targetMesh && e.copyFrom(this.targetMesh.getAbsolutePosition()), this.poleTargetBone ? this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset, this.mesh, n) : this.poleTargetMesh && u.e.TransformCoordinatesToRef(this.poleTargetLocalOffset, this.poleTargetMesh.getWorldMatrix(), n);
+ var a = r._tmpVecs[0], s = r._tmpVecs[1], d = r._tmpVecs[2], p = r._tmpVecs[3], y = r._tmpVecs[4], P = r._tmpQuat;
+ t.getAbsolutePositionToRef(this.mesh, a), n.subtractToRef(a, y), y.x == 0 && y.y == 0 && y.z == 0 ? y.y = 1 : y.normalize(), e.subtractToRef(a, p), p.normalize(), u.e.CrossToRef(p, y, s), s.normalize(), u.e.CrossToRef(p, s, d), d.normalize(), u.a.FromXYZAxesToRef(d, p, s, i);
+ var R = this._bone1Length, B = this._bone2Length, F = u.e.Distance(a, e);
+ this._maxReach > 0 && (F = Math.min(this._maxReach, F));
+ var z = (B * B + F * F - R * R) / (2 * B * F), J = (F * F + R * R - B * B) / (2 * F * R);
+ z > 1 && (z = 1), J > 1 && (J = 1), z < -1 && (z = -1), J < -1 && (J = -1);
+ var ie = Math.acos(z), se = Math.acos(J), ce = -ie - se;
+ if (this._rightHandedSystem)
+ u.a.RotationYawPitchRollToRef(0, 0, this._adjustRoll, o), o.multiplyToRef(i, i), u.a.RotationAxisToRef(this._bendAxis, se, o), o.multiplyToRef(i, i);
+ else {
+ var ue = r._tmpVecs[5];
+ ue.copyFrom(this._bendAxis), ue.x *= -1, u.a.RotationAxisToRef(ue, -se, o), o.multiplyToRef(i, i);
+ }
+ this.poleAngle && (u.a.RotationAxisToRef(p, this.poleAngle, o), i.multiplyToRef(o, i)), this._bone1 && (this.slerpAmount < 1 ? (this._slerping || u.b.FromRotationMatrixToRef(this._bone1Mat, this._bone1Quat), u.b.FromRotationMatrixToRef(i, P), u.b.SlerpToRef(this._bone1Quat, P, this.slerpAmount, this._bone1Quat), ce = this._bone2Ang * (1 - this.slerpAmount) + ce * this.slerpAmount, this._bone1.setRotationQuaternion(this._bone1Quat, be.c.WORLD, this.mesh), this._slerping = !0) : (this._bone1.setRotationMatrix(i, be.c.WORLD, this.mesh), this._bone1Mat.copyFrom(i), this._slerping = !1)), this._bone2.setAxisAngle(this._bendAxis, ce, be.c.LOCAL), this._bone2Ang = ce;
+ }
+ }, r._tmpVecs = [u.e.Zero(), u.e.Zero(), u.e.Zero(), u.e.Zero(), u.e.Zero(), u.e.Zero()], r._tmpQuat = u.b.Identity(), r._tmpMats = [u.a.Identity(), u.a.Identity()], r;
+ }(), pf = function() {
+ function r(t, e, n, i) {
+ if (this.upAxis = u.e.Up(), this.upAxisSpace = be.c.LOCAL, this.adjustYaw = 0, this.adjustPitch = 0, this.adjustRoll = 0, this.slerpAmount = 1, this._boneQuat = u.b.Identity(), this._slerping = !1, this._firstFrameSkipped = !1, this._fowardAxis = u.e.Forward(), this.mesh = t, this.bone = e, this.target = n, i && (i.adjustYaw && (this.adjustYaw = i.adjustYaw), i.adjustPitch && (this.adjustPitch = i.adjustPitch), i.adjustRoll && (this.adjustRoll = i.adjustRoll), i.maxYaw != null ? this.maxYaw = i.maxYaw : this.maxYaw = Math.PI, i.minYaw != null ? this.minYaw = i.minYaw : this.minYaw = -Math.PI, i.maxPitch != null ? this.maxPitch = i.maxPitch : this.maxPitch = Math.PI, i.minPitch != null ? this.minPitch = i.minPitch : this.minPitch = -Math.PI, i.slerpAmount != null && (this.slerpAmount = i.slerpAmount), i.upAxis != null && (this.upAxis = i.upAxis), i.upAxisSpace != null && (this.upAxisSpace = i.upAxisSpace), i.yawAxis != null || i.pitchAxis != null)) {
+ var o = be.a.Y, a = be.a.X;
+ i.yawAxis != null && (o = i.yawAxis.clone()).normalize(), i.pitchAxis != null && (a = i.pitchAxis.clone()).normalize();
+ var s = u.e.Cross(a, o);
+ this._transformYawPitch = u.a.Identity(), u.a.FromXYZAxesToRef(a, o, s, this._transformYawPitch), this._transformYawPitchInv = this._transformYawPitch.clone(), this._transformYawPitch.invert();
+ }
+ e.getParent() || this.upAxisSpace != be.c.BONE || (this.upAxisSpace = be.c.LOCAL);
+ }
+ return Object.defineProperty(r.prototype, "minYaw", { get: function() {
+ return this._minYaw;
+ }, set: function(t) {
+ this._minYaw = t, this._minYawSin = Math.sin(t), this._minYawCos = Math.cos(t), this._maxYaw != null && (this._midYawConstraint = 0.5 * this._getAngleDiff(this._minYaw, this._maxYaw) + this._minYaw, this._yawRange = this._maxYaw - this._minYaw);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "maxYaw", { get: function() {
+ return this._maxYaw;
+ }, set: function(t) {
+ this._maxYaw = t, this._maxYawSin = Math.sin(t), this._maxYawCos = Math.cos(t), this._minYaw != null && (this._midYawConstraint = 0.5 * this._getAngleDiff(this._minYaw, this._maxYaw) + this._minYaw, this._yawRange = this._maxYaw - this._minYaw);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "minPitch", { get: function() {
+ return this._minPitch;
+ }, set: function(t) {
+ this._minPitch = t, this._minPitchTan = Math.tan(t);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "maxPitch", { get: function() {
+ return this._maxPitch;
+ }, set: function(t) {
+ this._maxPitch = t, this._maxPitchTan = Math.tan(t);
+ }, enumerable: !1, configurable: !0 }), r.prototype.update = function() {
+ if (this.slerpAmount < 1 && !this._firstFrameSkipped)
+ this._firstFrameSkipped = !0;
+ else {
+ var t = this.bone, e = r._tmpVecs[0];
+ t.getAbsolutePositionToRef(this.mesh, e);
+ var n = this.target, i = r._tmpMats[0], o = r._tmpMats[1], a = this.mesh, s = t.getParent(), d = r._tmpVecs[1];
+ d.copyFrom(this.upAxis), this.upAxisSpace == be.c.BONE && s ? (this._transformYawPitch && u.e.TransformCoordinatesToRef(d, this._transformYawPitchInv, d), s.getDirectionToRef(d, this.mesh, d)) : this.upAxisSpace == be.c.LOCAL && (a.getDirectionToRef(d, d), a.scaling.x == 1 && a.scaling.y == 1 && a.scaling.z == 1 || d.normalize());
+ var p = !1, y = !1;
+ if (this._maxYaw == Math.PI && this._minYaw == -Math.PI || (p = !0), this._maxPitch == Math.PI && this._minPitch == -Math.PI || (y = !0), p || y) {
+ var P = r._tmpMats[2], R = r._tmpMats[3];
+ if (this.upAxisSpace == be.c.BONE && d.y == 1 && s)
+ s.getRotationMatrixToRef(be.c.WORLD, this.mesh, P);
+ else if (this.upAxisSpace != be.c.LOCAL || d.y != 1 || s) {
+ (F = r._tmpVecs[2]).copyFrom(this._fowardAxis), this._transformYawPitch && u.e.TransformCoordinatesToRef(F, this._transformYawPitchInv, F), s ? s.getDirectionToRef(F, this.mesh, F) : a.getDirectionToRef(F, F);
+ var B = u.e.Cross(d, F);
+ B.normalize();
+ var F = u.e.Cross(B, d);
+ u.a.FromXYZAxesToRef(B, d, F, P);
+ } else
+ P.copyFrom(a.getWorldMatrix());
+ P.invertToRef(R);
+ var z = null;
+ if (y) {
+ var J = r._tmpVecs[3];
+ n.subtractToRef(e, J), u.e.TransformCoordinatesToRef(J, R, J), z = Math.sqrt(J.x * J.x + J.z * J.z);
+ var ie = Math.atan2(J.y, z), se = ie;
+ ie > this._maxPitch ? (J.y = this._maxPitchTan * z, se = this._maxPitch) : ie < this._minPitch && (J.y = this._minPitchTan * z, se = this._minPitch), ie != se && (u.e.TransformCoordinatesToRef(J, P, J), J.addInPlace(e), n = J);
+ }
+ if (p) {
+ J = r._tmpVecs[4], n.subtractToRef(e, J), u.e.TransformCoordinatesToRef(J, R, J);
+ var ce = Math.atan2(J.x, J.z), ue = ce;
+ if ((ce > this._maxYaw || ce < this._minYaw) && (z == null && (z = Math.sqrt(J.x * J.x + J.z * J.z)), this._yawRange > Math.PI ? this._isAngleBetween(ce, this._maxYaw, this._midYawConstraint) ? (J.z = this._maxYawCos * z, J.x = this._maxYawSin * z, ue = this._maxYaw) : this._isAngleBetween(ce, this._midYawConstraint, this._minYaw) && (J.z = this._minYawCos * z, J.x = this._minYawSin * z, ue = this._minYaw) : ce > this._maxYaw ? (J.z = this._maxYawCos * z, J.x = this._maxYawSin * z, ue = this._maxYaw) : ce < this._minYaw && (J.z = this._minYawCos * z, J.x = this._minYawSin * z, ue = this._minYaw)), this._slerping && this._yawRange > Math.PI) {
+ var fe = r._tmpVecs[8];
+ fe.copyFrom(be.a.Z), this._transformYawPitch && u.e.TransformCoordinatesToRef(fe, this._transformYawPitchInv, fe);
+ var ve = r._tmpMats[4];
+ this._boneQuat.toRotationMatrix(ve), this.mesh.getWorldMatrix().multiplyToRef(ve, ve), u.e.TransformCoordinatesToRef(fe, ve, fe), u.e.TransformCoordinatesToRef(fe, R, fe);
+ var Te = Math.atan2(fe.x, fe.z);
+ if (this._getAngleBetween(Te, ce) > this._getAngleBetween(Te, this._midYawConstraint)) {
+ z == null && (z = Math.sqrt(J.x * J.x + J.z * J.z));
+ var Re = this._getAngleBetween(Te, this._maxYaw);
+ this._getAngleBetween(Te, this._minYaw) < Re ? (ue = Te + 0.75 * Math.PI, J.z = Math.cos(ue) * z, J.x = Math.sin(ue) * z) : (ue = Te - 0.75 * Math.PI, J.z = Math.cos(ue) * z, J.x = Math.sin(ue) * z);
+ }
+ }
+ ce != ue && (u.e.TransformCoordinatesToRef(J, P, J), J.addInPlace(e), n = J);
+ }
+ }
+ var Ae = r._tmpVecs[5], Ee = r._tmpVecs[6], Se = r._tmpVecs[7], De = r._tmpQuat;
+ n.subtractToRef(e, Ae), Ae.normalize(), u.e.CrossToRef(d, Ae, Ee), Ee.normalize(), u.e.CrossToRef(Ae, Ee, Se), Se.normalize(), u.a.FromXYZAxesToRef(Ee, Se, Ae, i), Ee.x === 0 && Ee.y === 0 && Ee.z === 0 || Se.x === 0 && Se.y === 0 && Se.z === 0 || Ae.x === 0 && Ae.y === 0 && Ae.z === 0 || ((this.adjustYaw || this.adjustPitch || this.adjustRoll) && (u.a.RotationYawPitchRollToRef(this.adjustYaw, this.adjustPitch, this.adjustRoll, o), o.multiplyToRef(i, i)), this.slerpAmount < 1 ? (this._slerping || this.bone.getRotationQuaternionToRef(be.c.WORLD, this.mesh, this._boneQuat), this._transformYawPitch && this._transformYawPitch.multiplyToRef(i, i), u.b.FromRotationMatrixToRef(i, De), u.b.SlerpToRef(this._boneQuat, De, this.slerpAmount, this._boneQuat), this.bone.setRotationQuaternion(this._boneQuat, be.c.WORLD, this.mesh), this._slerping = !0) : (this._transformYawPitch && this._transformYawPitch.multiplyToRef(i, i), this.bone.setRotationMatrix(i, be.c.WORLD, this.mesh), this._slerping = !1));
+ }
+ }, r.prototype._getAngleDiff = function(t, e) {
+ var n = e - t;
+ return (n %= 2 * Math.PI) > Math.PI ? n -= 2 * Math.PI : n < -Math.PI && (n += 2 * Math.PI), n;
+ }, r.prototype._getAngleBetween = function(t, e) {
+ var n = 0;
+ return (n = (t = (t %= 2 * Math.PI) < 0 ? t + 2 * Math.PI : t) < (e = (e %= 2 * Math.PI) < 0 ? e + 2 * Math.PI : e) ? e - t : t - e) > Math.PI && (n = 2 * Math.PI - n), n;
+ }, r.prototype._isAngleBetween = function(t, e, n) {
+ if (t = (t %= 2 * Math.PI) < 0 ? t + 2 * Math.PI : t, (e = (e %= 2 * Math.PI) < 0 ? e + 2 * Math.PI : e) < (n = (n %= 2 * Math.PI) < 0 ? n + 2 * Math.PI : n)) {
+ if (t > e && t < n)
+ return !0;
+ } else if (t > n && t < e)
+ return !0;
+ return !1;
+ }, r._tmpVecs = Pe.a.BuildArray(10, u.e.Zero), r._tmpQuat = u.b.Identity(), r._tmpMats = Pe.a.BuildArray(5, u.a.Identity), r;
+ }(), Ne = f(10), Pt = f(27), wt = f(26);
+ function $c(r, t, e, n) {
+ var i;
+ i = n === h.a.TEXTURETYPE_FLOAT ? new Float32Array(t * e * 4) : new Uint32Array(t * e * 4);
+ for (var o = 0; o < t; o++)
+ for (var a = 0; a < e; a++) {
+ var s = 3 * (a * t + o), d = 4 * (a * t + o);
+ i[d + 0] = r[s + 0], i[d + 1] = r[s + 1], i[d + 2] = r[s + 2], i[d + 3] = 1;
+ }
+ return i;
+ }
+ function el(r) {
+ return function(t, e, n, i, o, a, s, d, p, y) {
+ p === void 0 && (p = null), y === void 0 && (y = h.a.TEXTURETYPE_UNSIGNED_INT);
+ var P = r ? this._gl.TEXTURE_3D : this._gl.TEXTURE_2D_ARRAY, R = r ? Pt.b.Raw3D : Pt.b.Raw2DArray, B = new Pt.a(this, R);
+ B.baseWidth = e, B.baseHeight = n, B.baseDepth = i, B.width = e, B.height = n, B.depth = i, B.format = o, B.type = y, B.generateMipMaps = a, B.samplingMode = d, r ? B.is3D = !0 : B.is2DArray = !0, this._doNotHandleContextLost || (B._bufferView = t), r ? this.updateRawTexture3D(B, t, o, s, p, y) : this.updateRawTexture2DArray(B, t, o, s, p, y), this._bindTextureDirectly(P, B, !0);
+ var F = this._getSamplingParameters(d, a);
+ return this._gl.texParameteri(P, this._gl.TEXTURE_MAG_FILTER, F.mag), this._gl.texParameteri(P, this._gl.TEXTURE_MIN_FILTER, F.min), a && this._gl.generateMipmap(P), this._bindTextureDirectly(P, null), this._internalTexturesCache.push(B), B;
+ };
+ }
+ function tl(r) {
+ return function(t, e, n, i, o, a) {
+ o === void 0 && (o = null), a === void 0 && (a = h.a.TEXTURETYPE_UNSIGNED_INT);
+ var s = r ? this._gl.TEXTURE_3D : this._gl.TEXTURE_2D_ARRAY, d = this._getWebGLTextureType(a), p = this._getInternalFormat(n), y = this._getRGBABufferInternalSizedFormat(a, n);
+ this._bindTextureDirectly(s, t, !0), this._unpackFlipY(i === void 0 || !!i), this._doNotHandleContextLost || (t._bufferView = e, t.format = n, t.invertY = i, t._compression = o), t.width % 4 != 0 && this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1), o && e ? this._gl.compressedTexImage3D(s, 0, this.getCaps().s3tc[o], t.width, t.height, t.depth, 0, e) : this._gl.texImage3D(s, 0, y, t.width, t.height, t.depth, 0, p, d, e), t.generateMipMaps && this._gl.generateMipmap(s), this._bindTextureDirectly(s, null), t.isReady = !0;
+ };
+ }
+ wt.a.prototype.updateRawTexture = function(r, t, e, n, i, o) {
+ if (i === void 0 && (i = null), o === void 0 && (o = h.a.TEXTURETYPE_UNSIGNED_INT), r) {
+ var a = this._getRGBABufferInternalSizedFormat(o, e), s = this._getInternalFormat(e), d = this._getWebGLTextureType(o);
+ this._bindTextureDirectly(this._gl.TEXTURE_2D, r, !0), this._unpackFlipY(n === void 0 || !!n), this._doNotHandleContextLost || (r._bufferView = t, r.format = e, r.type = o, r.invertY = n, r._compression = i), r.width % 4 != 0 && this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1), i && t ? this._gl.compressedTexImage2D(this._gl.TEXTURE_2D, 0, this.getCaps().s3tc[i], r.width, r.height, 0, t) : this._gl.texImage2D(this._gl.TEXTURE_2D, 0, a, r.width, r.height, 0, s, d, t), r.generateMipMaps && this._gl.generateMipmap(this._gl.TEXTURE_2D), this._bindTextureDirectly(this._gl.TEXTURE_2D, null), r.isReady = !0;
+ }
+ }, wt.a.prototype.createRawTexture = function(r, t, e, n, i, o, a, s, d) {
+ s === void 0 && (s = null), d === void 0 && (d = h.a.TEXTURETYPE_UNSIGNED_INT);
+ var p = new Pt.a(this, Pt.b.Raw);
+ p.baseWidth = t, p.baseHeight = e, p.width = t, p.height = e, p.format = n, p.generateMipMaps = i, p.samplingMode = a, p.invertY = o, p._compression = s, p.type = d, this._doNotHandleContextLost || (p._bufferView = r), this.updateRawTexture(p, r, n, o, s, d), this._bindTextureDirectly(this._gl.TEXTURE_2D, p, !0);
+ var y = this._getSamplingParameters(a, i);
+ return this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, y.mag), this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, y.min), i && this._gl.generateMipmap(this._gl.TEXTURE_2D), this._bindTextureDirectly(this._gl.TEXTURE_2D, null), this._internalTexturesCache.push(p), p;
+ }, wt.a.prototype.createRawCubeTexture = function(r, t, e, n, i, o, a, s) {
+ s === void 0 && (s = null);
+ var d = this._gl, p = new Pt.a(this, Pt.b.CubeRaw);
+ p.isCube = !0, p.format = e, p.type = n, this._doNotHandleContextLost || (p._bufferViewArray = r);
+ var y = this._getWebGLTextureType(n), P = this._getInternalFormat(e);
+ P === d.RGB && (P = d.RGBA), y !== d.FLOAT || this._caps.textureFloatLinearFiltering ? y !== this._gl.HALF_FLOAT_OES || this._caps.textureHalfFloatLinearFiltering ? y !== d.FLOAT || this._caps.textureFloatRender ? y !== d.HALF_FLOAT || this._caps.colorBufferFloat || (i = !1, l.a.Warn("Render to half float textures is not supported. Mipmap generation forced to false.")) : (i = !1, l.a.Warn("Render to float textures is not supported. Mipmap generation forced to false.")) : (i = !1, a = h.a.TEXTURE_NEAREST_SAMPLINGMODE, l.a.Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")) : (i = !1, a = h.a.TEXTURE_NEAREST_SAMPLINGMODE, l.a.Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively."));
+ var R = t, B = R;
+ p.width = R, p.height = B, !this.needPOTTextures || Xe.b.IsExponentOfTwo(p.width) && Xe.b.IsExponentOfTwo(p.height) || (i = !1), r && this.updateRawCubeTexture(p, r, e, n, o, s), this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, p, !0), r && i && this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
+ var F = this._getSamplingParameters(a, i);
+ return d.texParameteri(d.TEXTURE_CUBE_MAP, d.TEXTURE_MAG_FILTER, F.mag), d.texParameteri(d.TEXTURE_CUBE_MAP, d.TEXTURE_MIN_FILTER, F.min), d.texParameteri(d.TEXTURE_CUBE_MAP, d.TEXTURE_WRAP_S, d.CLAMP_TO_EDGE), d.texParameteri(d.TEXTURE_CUBE_MAP, d.TEXTURE_WRAP_T, d.CLAMP_TO_EDGE), this._bindTextureDirectly(d.TEXTURE_CUBE_MAP, null), p.generateMipMaps = i, p;
+ }, wt.a.prototype.updateRawCubeTexture = function(r, t, e, n, i, o, a) {
+ o === void 0 && (o = null), a === void 0 && (a = 0), r._bufferViewArray = t, r.format = e, r.type = n, r.invertY = i, r._compression = o;
+ var s = this._gl, d = this._getWebGLTextureType(n), p = this._getInternalFormat(e), y = this._getRGBABufferInternalSizedFormat(n), P = !1;
+ p === s.RGB && (p = s.RGBA, P = !0), this._bindTextureDirectly(s.TEXTURE_CUBE_MAP, r, !0), this._unpackFlipY(i === void 0 || !!i), r.width % 4 != 0 && s.pixelStorei(s.UNPACK_ALIGNMENT, 1);
+ for (var R = 0; R < 6; R++) {
+ var B = t[R];
+ o ? s.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X + R, a, this.getCaps().s3tc[o], r.width, r.height, 0, B) : (P && (B = $c(B, r.width, r.height, n)), s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X + R, a, y, r.width, r.height, 0, p, d, B));
+ }
+ (!this.needPOTTextures || Xe.b.IsExponentOfTwo(r.width) && Xe.b.IsExponentOfTwo(r.height)) && r.generateMipMaps && a === 0 && this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP), this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null), r.isReady = !0;
+ }, wt.a.prototype.createRawCubeTextureFromUrl = function(r, t, e, n, i, o, a, s, d, p, y, P) {
+ var R = this;
+ d === void 0 && (d = null), p === void 0 && (p = null), y === void 0 && (y = h.a.TEXTURE_TRILINEAR_SAMPLINGMODE), P === void 0 && (P = !1);
+ var B = this._gl, F = this.createRawCubeTexture(null, e, n, i, !o, P, y, null);
+ return t == null || t._addPendingData(F), F.url = r, this._internalTexturesCache.push(F), this._loadFile(r, function(z) {
+ (function(J) {
+ var ie = F.width, se = a(J);
+ if (se) {
+ if (s) {
+ var ce = R._getWebGLTextureType(i), ue = R._getInternalFormat(n), fe = R._getRGBABufferInternalSizedFormat(i), ve = !1;
+ ue === B.RGB && (ue = B.RGBA, ve = !0), R._bindTextureDirectly(B.TEXTURE_CUBE_MAP, F, !0), R._unpackFlipY(!1);
+ for (var Te = s(se), Re = 0; Re < Te.length; Re++)
+ for (var Ae = ie >> Re, Ee = 0; Ee < 6; Ee++) {
+ var Se = Te[Re][Ee];
+ ve && (Se = $c(Se, Ae, Ae, i)), B.texImage2D(Ee, Re, fe, Ae, Ae, 0, ue, ce, Se);
+ }
+ R._bindTextureDirectly(B.TEXTURE_CUBE_MAP, null);
+ } else
+ R.updateRawCubeTexture(F, se, n, i, P);
+ F.isReady = !0, t == null || t._removePendingData(F), d && d();
+ }
+ })(z);
+ }, void 0, t == null ? void 0 : t.offlineProvider, !0, function(z, J) {
+ t == null || t._removePendingData(F), p && z && p(z.status + " " + z.statusText, J);
+ }), F;
+ }, wt.a.prototype.createRawTexture2DArray = el(!1), wt.a.prototype.createRawTexture3D = el(!0), wt.a.prototype.updateRawTexture2DArray = tl(!1), wt.a.prototype.updateRawTexture3D = tl(!0);
+ var Zn = function(r) {
+ function t(e, n, i, o, a, s, d, p, y) {
+ s === void 0 && (s = !0), d === void 0 && (d = !1), p === void 0 && (p = h.a.TEXTURE_TRILINEAR_SAMPLINGMODE), y === void 0 && (y = h.a.TEXTURETYPE_UNSIGNED_INT);
+ var P = r.call(this, null, a, !s, d) || this;
+ return P.format = o, P._engine && (P._texture = P._engine.createRawTexture(e, n, i, o, s, d, p, null, y), P.wrapU = Ne.a.CLAMP_ADDRESSMODE, P.wrapV = Ne.a.CLAMP_ADDRESSMODE), P;
+ }
+ return Object(c.d)(t, r), t.prototype.update = function(e) {
+ this._getEngine().updateRawTexture(this._texture, e, this._texture.format, this._texture.invertY, null, this._texture.type);
+ }, t.CreateLuminanceTexture = function(e, n, i, o, a, s, d) {
+ return a === void 0 && (a = !0), s === void 0 && (s = !1), d === void 0 && (d = h.a.TEXTURE_TRILINEAR_SAMPLINGMODE), new t(e, n, i, h.a.TEXTUREFORMAT_LUMINANCE, o, a, s, d);
+ }, t.CreateLuminanceAlphaTexture = function(e, n, i, o, a, s, d) {
+ return a === void 0 && (a = !0), s === void 0 && (s = !1), d === void 0 && (d = h.a.TEXTURE_TRILINEAR_SAMPLINGMODE), new t(e, n, i, h.a.TEXTUREFORMAT_LUMINANCE_ALPHA, o, a, s, d);
+ }, t.CreateAlphaTexture = function(e, n, i, o, a, s, d) {
+ return a === void 0 && (a = !0), s === void 0 && (s = !1), d === void 0 && (d = h.a.TEXTURE_TRILINEAR_SAMPLINGMODE), new t(e, n, i, h.a.TEXTUREFORMAT_ALPHA, o, a, s, d);
+ }, t.CreateRGBTexture = function(e, n, i, o, a, s, d, p) {
+ return a === void 0 && (a = !0), s === void 0 && (s = !1), d === void 0 && (d = h.a.TEXTURE_TRILINEAR_SAMPLINGMODE), p === void 0 && (p = h.a.TEXTURETYPE_UNSIGNED_INT), new t(e, n, i, h.a.TEXTUREFORMAT_RGB, o, a, s, d, p);
+ }, t.CreateRGBATexture = function(e, n, i, o, a, s, d, p) {
+ return a === void 0 && (a = !0), s === void 0 && (s = !1), d === void 0 && (d = h.a.TEXTURE_TRILINEAR_SAMPLINGMODE), p === void 0 && (p = h.a.TEXTURETYPE_UNSIGNED_INT), new t(e, n, i, h.a.TEXTUREFORMAT_RGBA, o, a, s, d, p);
+ }, t.CreateRTexture = function(e, n, i, o, a, s, d, p) {
+ return a === void 0 && (a = !0), s === void 0 && (s = !1), d === void 0 && (d = Ne.a.TRILINEAR_SAMPLINGMODE), p === void 0 && (p = h.a.TEXTURETYPE_FLOAT), new t(e, n, i, h.a.TEXTUREFORMAT_R, o, a, s, d, p);
+ }, t;
+ }(Ne.a), Ao = function() {
+ function r(t, e, n) {
+ this.name = t, this.id = e, this.bones = new Array(), this.needInitialSkinMatrix = !1, this.overrideMesh = null, this._isDirty = !0, this._meshesWithPoseMatrix = new Array(), this._identity = u.a.Identity(), this._ranges = {}, this._lastAbsoluteTransformsUpdateId = -1, this._canUseTextureForBones = !1, this._uniqueId = 0, this._numBonesWithLinkedTransformNode = 0, this._hasWaitingData = null, this._waitingOverrideMeshId = null, this.doNotSerialize = !1, this._useTextureToStoreBoneMatrices = !0, this._animationPropertiesOverride = null, this.onBeforeComputeObservable = new C.c(), this.bones = [], this._scene = n || te.a.LastCreatedScene, this._uniqueId = this._scene.getUniqueId(), this._scene.addSkeleton(this), this._isDirty = !0;
+ var i = this._scene.getEngine().getCaps();
+ this._canUseTextureForBones = i.textureFloat && i.maxVertexTextureImageUnits > 0;
+ }
+ return Object.defineProperty(r.prototype, "useTextureToStoreBoneMatrices", { get: function() {
+ return this._useTextureToStoreBoneMatrices;
+ }, set: function(t) {
+ this._useTextureToStoreBoneMatrices = t, this._markAsDirty();
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "animationPropertiesOverride", { get: function() {
+ return this._animationPropertiesOverride ? this._animationPropertiesOverride : this._scene.animationPropertiesOverride;
+ }, set: function(t) {
+ this._animationPropertiesOverride = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "isUsingTextureForMatrices", { get: function() {
+ return this.useTextureToStoreBoneMatrices && this._canUseTextureForBones;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "uniqueId", { get: function() {
+ return this._uniqueId;
+ }, enumerable: !1, configurable: !0 }), r.prototype.getClassName = function() {
+ return "Skeleton";
+ }, r.prototype.getChildren = function() {
+ return this.bones.filter(function(t) {
+ return !t.getParent();
+ });
+ }, r.prototype.getTransformMatrices = function(t) {
+ return this.needInitialSkinMatrix && t._bonesTransformMatrices ? t._bonesTransformMatrices : (this._transformMatrices || this.prepare(), this._transformMatrices);
+ }, r.prototype.getTransformMatrixTexture = function(t) {
+ return this.needInitialSkinMatrix && t._transformMatrixTexture ? t._transformMatrixTexture : this._transformMatrixTexture;
+ }, r.prototype.getScene = function() {
+ return this._scene;
+ }, r.prototype.toString = function(t) {
+ var e = "Name: " + this.name + ", nBones: " + this.bones.length;
+ if (e += ", nAnimationRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none"), t) {
+ e += ", Ranges: {";
+ var n = !0;
+ for (var i in this._ranges)
+ n && (e += ", ", n = !1), e += i;
+ e += "}";
+ }
+ return e;
+ }, r.prototype.getBoneIndexByName = function(t) {
+ for (var e = 0, n = this.bones.length; e < n; e++)
+ if (this.bones[e].name === t)
+ return e;
+ return -1;
+ }, r.prototype.createAnimationRange = function(t, e, n) {
+ if (!this._ranges[t]) {
+ this._ranges[t] = new G(t, e, n);
+ for (var i = 0, o = this.bones.length; i < o; i++)
+ this.bones[i].animations[0] && this.bones[i].animations[0].createRange(t, e, n);
+ }
+ }, r.prototype.deleteAnimationRange = function(t, e) {
+ e === void 0 && (e = !0);
+ for (var n = 0, i = this.bones.length; n < i; n++)
+ this.bones[n].animations[0] && this.bones[n].animations[0].deleteRange(t, e);
+ this._ranges[t] = null;
+ }, r.prototype.getAnimationRange = function(t) {
+ return this._ranges[t] || null;
+ }, r.prototype.getAnimationRanges = function() {
+ var t, e = [];
+ for (t in this._ranges)
+ e.push(this._ranges[t]);
+ return e;
+ }, r.prototype.copyAnimationRange = function(t, e, n) {
+ if (n === void 0 && (n = !1), this._ranges[e] || !t.getAnimationRange(e))
+ return !1;
+ var i, o, a = !0, s = this._getHighestAnimationFrame() + 1, d = {}, p = t.bones;
+ for (o = 0, i = p.length; o < i; o++)
+ d[p[o].name] = p[o];
+ this.bones.length !== p.length && (l.a.Warn("copyAnimationRange: this rig has " + this.bones.length + " bones, while source as " + p.length), a = !1);
+ var y = n && this.dimensionsAtRest && t.dimensionsAtRest ? this.dimensionsAtRest.divide(t.dimensionsAtRest) : null;
+ for (o = 0, i = this.bones.length; o < i; o++) {
+ var P = this.bones[o].name, R = d[P];
+ R ? a = a && this.bones[o].copyAnimationRange(R, e, s, n, y) : (l.a.Warn("copyAnimationRange: not same rig, missing source bone " + P), a = !1);
+ }
+ var B = t.getAnimationRange(e);
+ return B && (this._ranges[e] = new G(e, B.from + s, B.to + s)), a;
+ }, r.prototype.returnToRest = function() {
+ for (var t = u.c.Vector3[0], e = u.c.Quaternion[0], n = u.c.Vector3[1], i = 0; i < this.bones.length; i++) {
+ var o = this.bones[i];
+ o._index !== -1 && (o.returnToRest(), o._linkedTransformNode && (o.getRestPose().decompose(t, e, n), o._linkedTransformNode.position = n.clone(), o._linkedTransformNode.rotationQuaternion = e.clone(), o._linkedTransformNode.scaling = t.clone()));
+ }
+ }, r.prototype._getHighestAnimationFrame = function() {
+ for (var t = 0, e = 0, n = this.bones.length; e < n; e++)
+ if (this.bones[e].animations[0]) {
+ var i = this.bones[e].animations[0].getHighestFrame();
+ t < i && (t = i);
+ }
+ return t;
+ }, r.prototype.beginAnimation = function(t, e, n, i) {
+ var o = this.getAnimationRange(t);
+ return o ? this._scene.beginAnimation(this, o.from, o.to, e, n, i) : null;
+ }, r.MakeAnimationAdditive = function(t, e, n) {
+ e === void 0 && (e = 0);
+ var i = t.getAnimationRange(n);
+ if (!i)
+ return null;
+ for (var o = t._scene.getAllAnimatablesByTarget(t), a = null, s = 0; s < o.length; s++) {
+ var d = o[s];
+ if (d.fromFrame === (i == null ? void 0 : i.from) && d.toFrame === (i == null ? void 0 : i.to)) {
+ a = d;
+ break;
+ }
+ }
+ var p = t.getAnimatables();
+ for (s = 0; s < p.length; s++) {
+ var y = p[s].animations;
+ if (y)
+ for (var P = 0; P < y.length; P++)
+ k.MakeAnimationAdditive(y[P], e, n);
+ }
+ return a && (a.isAdditive = !0), t;
+ }, r.prototype._markAsDirty = function() {
+ this._isDirty = !0;
+ }, r.prototype._registerMeshWithPoseMatrix = function(t) {
+ this._meshesWithPoseMatrix.push(t);
+ }, r.prototype._unregisterMeshWithPoseMatrix = function(t) {
+ var e = this._meshesWithPoseMatrix.indexOf(t);
+ e > -1 && this._meshesWithPoseMatrix.splice(e, 1);
+ }, r.prototype._computeTransformMatrices = function(t, e) {
+ this.onBeforeComputeObservable.notifyObservers(this);
+ for (var n = 0; n < this.bones.length; n++) {
+ var i = this.bones[n];
+ i._childUpdateId++;
+ var o = i.getParent();
+ if (o ? i.getLocalMatrix().multiplyToRef(o.getWorldMatrix(), i.getWorldMatrix()) : e ? i.getLocalMatrix().multiplyToRef(e, i.getWorldMatrix()) : i.getWorldMatrix().copyFrom(i.getLocalMatrix()), i._index !== -1) {
+ var a = i._index === null ? n : i._index;
+ i.getInvertedAbsoluteTransform().multiplyToArray(i.getWorldMatrix(), t, 16 * a);
+ }
+ }
+ this._identity.copyToArray(t, 16 * this.bones.length);
+ }, r.prototype.prepare = function() {
+ if (this._numBonesWithLinkedTransformNode > 0)
+ for (var t = 0, e = this.bones; t < e.length; t++) {
+ var n = e[t];
+ n._linkedTransformNode && (n._linkedTransformNode.computeWorldMatrix(), n._matrix = n._linkedTransformNode._localMatrix, n.markAsDirty());
+ }
+ if (this._isDirty) {
+ if (this.needInitialSkinMatrix)
+ for (var i = 0; i < this._meshesWithPoseMatrix.length; i++) {
+ var o = this._meshesWithPoseMatrix[i], a = o.getPoseMatrix();
+ if (o._bonesTransformMatrices && o._bonesTransformMatrices.length === 16 * (this.bones.length + 1) || (o._bonesTransformMatrices = new Float32Array(16 * (this.bones.length + 1))), this._synchronizedWithMesh !== o) {
+ this._synchronizedWithMesh = o;
+ for (var s = 0; s < this.bones.length; s++) {
+ var d = this.bones[s];
+ d.getParent() || (d.getBaseMatrix().multiplyToRef(a, u.c.Matrix[1]), d._updateDifferenceMatrix(u.c.Matrix[1]));
+ }
+ if (this.isUsingTextureForMatrices) {
+ var p = 4 * (this.bones.length + 1);
+ o._transformMatrixTexture && o._transformMatrixTexture.getSize().width === p || (o._transformMatrixTexture && o._transformMatrixTexture.dispose(), o._transformMatrixTexture = Zn.CreateRGBATexture(o._bonesTransformMatrices, 4 * (this.bones.length + 1), 1, this._scene, !1, !1, h.a.TEXTURE_NEAREST_SAMPLINGMODE, h.a.TEXTURETYPE_FLOAT));
+ }
+ }
+ this._computeTransformMatrices(o._bonesTransformMatrices, a), this.isUsingTextureForMatrices && o._transformMatrixTexture && o._transformMatrixTexture.update(o._bonesTransformMatrices);
+ }
+ else
+ this._transformMatrices && this._transformMatrices.length === 16 * (this.bones.length + 1) || (this._transformMatrices = new Float32Array(16 * (this.bones.length + 1)), this.isUsingTextureForMatrices && (this._transformMatrixTexture && this._transformMatrixTexture.dispose(), this._transformMatrixTexture = Zn.CreateRGBATexture(this._transformMatrices, 4 * (this.bones.length + 1), 1, this._scene, !1, !1, h.a.TEXTURE_NEAREST_SAMPLINGMODE, h.a.TEXTURETYPE_FLOAT))), this._computeTransformMatrices(this._transformMatrices, null), this.isUsingTextureForMatrices && this._transformMatrixTexture && this._transformMatrixTexture.update(this._transformMatrices);
+ this._isDirty = !1, this._scene._activeBones.addCount(this.bones.length, !1);
+ }
+ }, r.prototype.getAnimatables = function() {
+ if (!this._animatables || this._animatables.length !== this.bones.length) {
+ this._animatables = [];
+ for (var t = 0; t < this.bones.length; t++)
+ this._animatables.push(this.bones[t]);
+ }
+ return this._animatables;
+ }, r.prototype.clone = function(t, e) {
+ var n = new r(t, e || t, this._scene);
+ n.needInitialSkinMatrix = this.needInitialSkinMatrix, n.overrideMesh = this.overrideMesh;
+ for (var i = 0; i < this.bones.length; i++) {
+ var o = this.bones[i], a = null, s = o.getParent();
+ if (s) {
+ var d = this.bones.indexOf(s);
+ a = n.bones[d];
+ }
+ var p = new Fe(o.name, n, a, o.getBaseMatrix().clone(), o.getRestPose().clone());
+ p._index = o._index, o._linkedTransformNode && p.linkTransformNode(o._linkedTransformNode), de.a.DeepCopy(o.animations, p.animations);
+ }
+ if (this._ranges)
+ for (var y in n._ranges = {}, this._ranges) {
+ var P = this._ranges[y];
+ P && (n._ranges[y] = P.clone());
+ }
+ return this._isDirty = !0, n;
+ }, r.prototype.enableBlending = function(t) {
+ t === void 0 && (t = 0.01), this.bones.forEach(function(e) {
+ e.animations.forEach(function(n) {
+ n.enableBlending = !0, n.blendingSpeed = t;
+ });
+ });
+ }, r.prototype.dispose = function() {
+ this._meshesWithPoseMatrix = [], this.getScene().stopAnimation(this), this.getScene().removeSkeleton(this), this._transformMatrixTexture && (this._transformMatrixTexture.dispose(), this._transformMatrixTexture = null);
+ }, r.prototype.serialize = function() {
+ var t, e, n = {};
+ n.name = this.name, n.id = this.id, this.dimensionsAtRest && (n.dimensionsAtRest = this.dimensionsAtRest.asArray()), n.bones = [], n.needInitialSkinMatrix = this.needInitialSkinMatrix, n.overrideMeshId = (t = this.overrideMesh) === null || t === void 0 ? void 0 : t.id;
+ for (var i = 0; i < this.bones.length; i++) {
+ var o = this.bones[i], a = o.getParent(), s = { parentBoneIndex: a ? this.bones.indexOf(a) : -1, index: o.getIndex(), name: o.name, matrix: o.getBaseMatrix().toArray(), rest: o.getRestPose().toArray(), linkedTransformNodeId: (e = o.getTransformNode()) === null || e === void 0 ? void 0 : e.id };
+ for (var d in n.bones.push(s), o.length && (s.length = o.length), o.metadata && (s.metadata = o.metadata), o.animations && o.animations.length > 0 && (s.animation = o.animations[0].serialize()), n.ranges = [], this._ranges) {
+ var p = this._ranges[d];
+ if (p) {
+ var y = {};
+ y.name = d, y.from = p.from, y.to = p.to, n.ranges.push(y);
+ }
+ }
+ }
+ return n;
+ }, r.Parse = function(t, e) {
+ var n, i = new r(t.name, t.id, e);
+ for (t.dimensionsAtRest && (i.dimensionsAtRest = u.e.FromArray(t.dimensionsAtRest)), i.needInitialSkinMatrix = t.needInitialSkinMatrix, t.overrideMeshId && (i._hasWaitingData = !0, i._waitingOverrideMeshId = t.overrideMeshId), n = 0; n < t.bones.length; n++) {
+ var o = t.bones[n], a = t.bones[n].index, s = null;
+ o.parentBoneIndex > -1 && (s = i.bones[o.parentBoneIndex]);
+ var d = o.rest ? u.a.FromArray(o.rest) : null, p = new Fe(o.name, i, s, u.a.FromArray(o.matrix), d, null, a);
+ o.id !== void 0 && o.id !== null && (p.id = o.id), o.length && (p.length = o.length), o.metadata && (p.metadata = o.metadata), o.animation && p.animations.push(k.Parse(o.animation)), o.linkedTransformNodeId !== void 0 && o.linkedTransformNodeId !== null && (i._hasWaitingData = !0, p._waitingTransformNodeId = o.linkedTransformNodeId);
+ }
+ if (t.ranges)
+ for (n = 0; n < t.ranges.length; n++) {
+ var y = t.ranges[n];
+ i.createAnimationRange(y.name, y.from, y.to);
+ }
+ return i;
+ }, r.prototype.computeAbsoluteTransforms = function(t) {
+ t === void 0 && (t = !1);
+ var e = this._scene.getRenderId();
+ (this._lastAbsoluteTransformsUpdateId != e || t) && (this.bones[0].computeAbsoluteTransforms(), this._lastAbsoluteTransformsUpdateId = e);
+ }, r.prototype.getPoseMatrix = function() {
+ var t = null;
+ return this._meshesWithPoseMatrix.length > 0 && (t = this._meshesWithPoseMatrix[0].getPoseMatrix()), t;
+ }, r.prototype.sortBones = function() {
+ for (var t = new Array(), e = new Array(this.bones.length), n = 0; n < this.bones.length; n++)
+ this._sortBones(n, t, e);
+ this.bones = t;
+ }, r.prototype._sortBones = function(t, e, n) {
+ if (!n[t]) {
+ n[t] = !0;
+ var i = this.bones[t];
+ i._index === void 0 && (i._index = t);
+ var o = i.getParent();
+ o && this._sortBones(this.bones.indexOf(o), e, n), e.push(i);
+ }
+ }, r.prototype.setCurrentPoseAsRest = function() {
+ this.bones.forEach(function(t) {
+ t.setCurrentPoseAsRest();
+ });
+ }, r;
+ }(), un = {}, zr = function() {
+ function r(t) {
+ this.attachedToElement = !1, this.attached = {}, this.camera = t, this.checkInputs = function() {
+ };
+ }
+ return r.prototype.add = function(t) {
+ var e = t.getSimpleName();
+ this.attached[e] ? l.a.Warn("camera input of type " + e + " already exists on camera") : (this.attached[e] = t, t.camera = this.camera, t.checkInputs && (this.checkInputs = this._addCheckInputs(t.checkInputs.bind(t))), this.attachedToElement && t.attachControl());
+ }, r.prototype.remove = function(t) {
+ for (var e in this.attached) {
+ var n = this.attached[e];
+ n === t && (n.detachControl(), n.camera = null, delete this.attached[e], this.rebuildInputCheck());
+ }
+ }, r.prototype.removeByType = function(t) {
+ for (var e in this.attached) {
+ var n = this.attached[e];
+ n.getClassName() === t && (n.detachControl(), n.camera = null, delete this.attached[e], this.rebuildInputCheck());
+ }
+ }, r.prototype._addCheckInputs = function(t) {
+ var e = this.checkInputs;
+ return function() {
+ e(), t();
+ };
+ }, r.prototype.attachInput = function(t) {
+ this.attachedToElement && t.attachControl(this.noPreventDefault);
+ }, r.prototype.attachElement = function(t) {
+ if (t === void 0 && (t = !1), !this.attachedToElement)
+ for (var e in t = !_t.a.ForceAttachControlToAlwaysPreventDefault && t, this.attachedToElement = !0, this.noPreventDefault = t, this.attached)
+ this.attached[e].attachControl(t);
+ }, r.prototype.detachElement = function(t) {
+ for (var e in t === void 0 && (t = !1), this.attached)
+ this.attached[e].detachControl(), t && (this.attached[e].camera = null);
+ this.attachedToElement = !1;
+ }, r.prototype.rebuildInputCheck = function() {
+ for (var t in this.checkInputs = function() {
+ }, this.attached) {
+ var e = this.attached[t];
+ e.checkInputs && (this.checkInputs = this._addCheckInputs(e.checkInputs.bind(e)));
+ }
+ }, r.prototype.clear = function() {
+ this.attachedToElement && this.detachElement(!0), this.attached = {}, this.attachedToElement = !1, this.checkInputs = function() {
+ };
+ }, r.prototype.serialize = function(t) {
+ var e = {};
+ for (var n in this.attached) {
+ var i = this.attached[n], o = L.a.Serialize(i);
+ e[i.getClassName()] = o;
+ }
+ t.inputsmgr = e;
+ }, r.prototype.parse = function(t) {
+ var e = t.inputsmgr;
+ if (e) {
+ for (var n in this.clear(), e)
+ if (a = un[n]) {
+ var i = e[n], o = L.a.Parse(function() {
+ return new a();
+ }, i, null);
+ this.add(o);
+ }
+ } else
+ for (var n in this.attached) {
+ var a;
+ (a = un[this.attached[n].getClassName()]) && (o = L.a.Parse(function() {
+ return new a();
+ }, t, null), this.remove(this.attached[n]), this.add(o));
+ }
+ }, r;
+ }(), _f = function(r, t) {
+ this.x = r, this.y = t;
+ }, hn = function() {
+ function r(t, e, n, i, o, a, s) {
+ i === void 0 && (i = 0), o === void 0 && (o = 1), a === void 0 && (a = 2), s === void 0 && (s = 3), this.id = t, this.index = e, this.browserGamepad = n, this._leftStick = { x: 0, y: 0 }, this._rightStick = { x: 0, y: 0 }, this._isConnected = !0, this._invertLeftStickY = !1, this.type = r.GAMEPAD, this._leftStickAxisX = i, this._leftStickAxisY = o, this._rightStickAxisX = a, this._rightStickAxisY = s, this.browserGamepad.axes.length >= 2 && (this._leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] }), this.browserGamepad.axes.length >= 4 && (this._rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] });
+ }
+ return Object.defineProperty(r.prototype, "isConnected", { get: function() {
+ return this._isConnected;
+ }, enumerable: !1, configurable: !0 }), r.prototype.onleftstickchanged = function(t) {
+ this._onleftstickchanged = t;
+ }, r.prototype.onrightstickchanged = function(t) {
+ this._onrightstickchanged = t;
+ }, Object.defineProperty(r.prototype, "leftStick", { get: function() {
+ return this._leftStick;
+ }, set: function(t) {
+ !this._onleftstickchanged || this._leftStick.x === t.x && this._leftStick.y === t.y || this._onleftstickchanged(t), this._leftStick = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "rightStick", { get: function() {
+ return this._rightStick;
+ }, set: function(t) {
+ !this._onrightstickchanged || this._rightStick.x === t.x && this._rightStick.y === t.y || this._onrightstickchanged(t), this._rightStick = t;
+ }, enumerable: !1, configurable: !0 }), r.prototype.update = function() {
+ this._leftStick && (this.leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] }, this._invertLeftStickY && (this.leftStick.y *= -1)), this._rightStick && (this.rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] });
+ }, r.prototype.dispose = function() {
+ }, r.GAMEPAD = 0, r.GENERIC = 1, r.XBOX = 2, r.POSE_ENABLED = 3, r.DUALSHOCK = 4, r;
+ }(), nl = function(r) {
+ function t(e, n, i) {
+ var o = r.call(this, e, n, i) || this;
+ return o.onButtonDownObservable = new C.c(), o.onButtonUpObservable = new C.c(), o.type = hn.GENERIC, o._buttons = new Array(i.buttons.length), o;
+ }
+ return Object(c.d)(t, r), t.prototype.onbuttondown = function(e) {
+ this._onbuttondown = e;
+ }, t.prototype.onbuttonup = function(e) {
+ this._onbuttonup = e;
+ }, t.prototype._setButtonValue = function(e, n, i) {
+ return e !== n && (e === 1 && (this._onbuttondown && this._onbuttondown(i), this.onButtonDownObservable.notifyObservers(i)), e === 0 && (this._onbuttonup && this._onbuttonup(i), this.onButtonUpObservable.notifyObservers(i))), e;
+ }, t.prototype.update = function() {
+ r.prototype.update.call(this);
+ for (var e = 0; e < this._buttons.length; e++)
+ this._buttons[e] = this._setButtonValue(this.browserGamepad.buttons[e].value, this._buttons[e], e);
+ }, t.prototype.dispose = function() {
+ r.prototype.dispose.call(this), this.onButtonDownObservable.clear(), this.onButtonUpObservable.clear();
+ }, t;
+ }(hn), Da = function() {
+ function r() {
+ this.gamepadRotationSensibility = 80, this.gamepadMoveSensibility = 40, this._yAxisScale = 1;
+ }
+ return Object.defineProperty(r.prototype, "invertYAxis", { get: function() {
+ return this._yAxisScale !== 1;
+ }, set: function(t) {
+ this._yAxisScale = t ? -1 : 1;
+ }, enumerable: !1, configurable: !0 }), r.prototype.attachControl = function() {
+ var t = this, e = this.camera.getScene().gamepadManager;
+ this._onGamepadConnectedObserver = e.onGamepadConnectedObservable.add(function(n) {
+ n.type !== hn.POSE_ENABLED && (t.gamepad && n.type !== hn.XBOX || (t.gamepad = n));
+ }), this._onGamepadDisconnectedObserver = e.onGamepadDisconnectedObservable.add(function(n) {
+ t.gamepad === n && (t.gamepad = null);
+ }), this.gamepad = e.getGamepadByType(hn.XBOX);
+ }, r.prototype.detachControl = function(t) {
+ this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver), this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver), this.gamepad = null;
+ }, r.prototype.checkInputs = function() {
+ if (this.gamepad) {
+ var t = this.camera, e = this.gamepad.rightStick;
+ if (e) {
+ if (e.x != 0) {
+ var n = e.x / this.gamepadRotationSensibility;
+ n != 0 && Math.abs(n) > 5e-3 && (t.inertialAlphaOffset += n);
+ }
+ if (e.y != 0) {
+ var i = e.y / this.gamepadRotationSensibility * this._yAxisScale;
+ i != 0 && Math.abs(i) > 5e-3 && (t.inertialBetaOffset += i);
+ }
+ }
+ var o = this.gamepad.leftStick;
+ if (o && o.y != 0) {
+ var a = o.y / this.gamepadMoveSensibility;
+ a != 0 && Math.abs(a) > 5e-3 && (this.camera.inertialRadiusOffset -= a);
+ }
+ }
+ }, r.prototype.getClassName = function() {
+ return "ArcRotateCameraGamepadInput";
+ }, r.prototype.getSimpleName = function() {
+ return "gamepad";
+ }, Object(c.c)([Object(L.c)()], r.prototype, "gamepadRotationSensibility", void 0), Object(c.c)([Object(L.c)()], r.prototype, "gamepadMoveSensibility", void 0), r;
+ }();
+ un.ArcRotateCameraGamepadInput = Da;
+ var zi = f(66), La = function() {
+ function r() {
+ this.keysUp = [38], this.keysDown = [40], this.keysLeft = [37], this.keysRight = [39], this.keysReset = [220], this.panningSensibility = 50, this.zoomingSensibility = 25, this.useAltToZoom = !0, this.angularSpeed = 0.01, this._keys = new Array();
+ }
+ return r.prototype.attachControl = function(t) {
+ var e = this;
+ t = Xe.b.BackCompatCameraNoPreventDefault(arguments), this._onCanvasBlurObserver || (this._scene = this.camera.getScene(), this._engine = this._scene.getEngine(), this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function() {
+ e._keys = [];
+ }), this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function(n) {
+ var i, o = n.event;
+ o.metaKey || (n.type === zi.a.KEYDOWN ? (e._ctrlPressed = o.ctrlKey, e._altPressed = o.altKey, (e.keysUp.indexOf(o.keyCode) !== -1 || e.keysDown.indexOf(o.keyCode) !== -1 || e.keysLeft.indexOf(o.keyCode) !== -1 || e.keysRight.indexOf(o.keyCode) !== -1 || e.keysReset.indexOf(o.keyCode) !== -1) && ((i = e._keys.indexOf(o.keyCode)) === -1 && e._keys.push(o.keyCode), o.preventDefault && (t || o.preventDefault()))) : e.keysUp.indexOf(o.keyCode) === -1 && e.keysDown.indexOf(o.keyCode) === -1 && e.keysLeft.indexOf(o.keyCode) === -1 && e.keysRight.indexOf(o.keyCode) === -1 && e.keysReset.indexOf(o.keyCode) === -1 || ((i = e._keys.indexOf(o.keyCode)) >= 0 && e._keys.splice(i, 1), o.preventDefault && (t || o.preventDefault())));
+ }));
+ }, r.prototype.detachControl = function(t) {
+ this._scene && (this._onKeyboardObserver && this._scene.onKeyboardObservable.remove(this._onKeyboardObserver), this._onCanvasBlurObserver && this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver), this._onKeyboardObserver = null, this._onCanvasBlurObserver = null), this._keys = [];
+ }, r.prototype.checkInputs = function() {
+ if (this._onKeyboardObserver)
+ for (var t = this.camera, e = 0; e < this._keys.length; e++) {
+ var n = this._keys[e];
+ this.keysLeft.indexOf(n) !== -1 ? this._ctrlPressed && this.camera._useCtrlForPanning ? t.inertialPanningX -= 1 / this.panningSensibility : t.inertialAlphaOffset -= this.angularSpeed : this.keysUp.indexOf(n) !== -1 ? this._ctrlPressed && this.camera._useCtrlForPanning ? t.inertialPanningY += 1 / this.panningSensibility : this._altPressed && this.useAltToZoom ? t.inertialRadiusOffset += 1 / this.zoomingSensibility : t.inertialBetaOffset -= this.angularSpeed : this.keysRight.indexOf(n) !== -1 ? this._ctrlPressed && this.camera._useCtrlForPanning ? t.inertialPanningX += 1 / this.panningSensibility : t.inertialAlphaOffset += this.angularSpeed : this.keysDown.indexOf(n) !== -1 ? this._ctrlPressed && this.camera._useCtrlForPanning ? t.inertialPanningY -= 1 / this.panningSensibility : this._altPressed && this.useAltToZoom ? t.inertialRadiusOffset -= 1 / this.zoomingSensibility : t.inertialBetaOffset += this.angularSpeed : this.keysReset.indexOf(n) !== -1 && t.useInputToRestoreState && t.restoreState();
+ }
+ }, r.prototype.getClassName = function() {
+ return "ArcRotateCameraKeyboardMoveInput";
+ }, r.prototype.getSimpleName = function() {
+ return "keyboard";
+ }, Object(c.c)([Object(L.c)()], r.prototype, "keysUp", void 0), Object(c.c)([Object(L.c)()], r.prototype, "keysDown", void 0), Object(c.c)([Object(L.c)()], r.prototype, "keysLeft", void 0), Object(c.c)([Object(L.c)()], r.prototype, "keysRight", void 0), Object(c.c)([Object(L.c)()], r.prototype, "keysReset", void 0), Object(c.c)([Object(L.c)()], r.prototype, "panningSensibility", void 0), Object(c.c)([Object(L.c)()], r.prototype, "zoomingSensibility", void 0), Object(c.c)([Object(L.c)()], r.prototype, "useAltToZoom", void 0), Object(c.c)([Object(L.c)()], r.prototype, "angularSpeed", void 0), r;
+ }();
+ un.ArcRotateCameraKeyboardMoveInput = La;
+ var Na = function() {
+ function r() {
+ this.wheelPrecision = 3, this.wheelDeltaPercentage = 0;
+ }
+ return r.prototype.computeDeltaFromMouseWheelLegacyEvent = function(t, e) {
+ var n = 0.01 * t * this.wheelDeltaPercentage * e;
+ return t > 0 ? n / (1 + this.wheelDeltaPercentage) : n * (1 + this.wheelDeltaPercentage);
+ }, r.prototype.attachControl = function(t) {
+ var e = this;
+ t = Xe.b.BackCompatCameraNoPreventDefault(arguments), this._wheel = function(n, i) {
+ if (n.type === yt.a.POINTERWHEEL) {
+ var o = n.event, a = 0, s = o, d = 0;
+ if (d = s.wheelDelta ? s.wheelDelta : 60 * -(o.deltaY || o.detail), e.wheelDeltaPercentage) {
+ if ((a = e.computeDeltaFromMouseWheelLegacyEvent(d, e.camera.radius)) > 0) {
+ for (var p = e.camera.radius, y = e.camera.inertialRadiusOffset + a, P = 0; P < 20 && Math.abs(y) > 1e-3; P++)
+ p -= y, y *= e.camera.inertia;
+ p = $.a.Clamp(p, 0, Number.MAX_VALUE), a = e.computeDeltaFromMouseWheelLegacyEvent(d, p);
+ }
+ } else
+ a = d / (40 * e.wheelPrecision);
+ a && (e.camera.inertialRadiusOffset += a), o.preventDefault && (t || o.preventDefault());
+ }
+ }, this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, yt.a.POINTERWHEEL);
+ }, r.prototype.detachControl = function(t) {
+ this._observer && (this.camera.getScene().onPointerObservable.remove(this._observer), this._observer = null, this._wheel = null);
+ }, r.prototype.getClassName = function() {
+ return "ArcRotateCameraMouseWheelInput";
+ }, r.prototype.getSimpleName = function() {
+ return "mousewheel";
+ }, Object(c.c)([Object(L.c)()], r.prototype, "wheelPrecision", void 0), Object(c.c)([Object(L.c)()], r.prototype, "wheelDeltaPercentage", void 0), r;
+ }();
+ un.ArcRotateCameraMouseWheelInput = Na;
+ var il = function() {
+ function r() {
+ this.buttons = [0, 1, 2];
+ }
+ return r.prototype.attachControl = function(t) {
+ var e = this;
+ t = Xe.b.BackCompatCameraNoPreventDefault(arguments);
+ var n = this.camera.getEngine(), i = n.getInputElement(), o = 0, a = null;
+ this.pointA = null, this.pointB = null, this._altKey = !1, this._ctrlKey = !1, this._metaKey = !1, this._shiftKey = !1, this._buttonsPressed = 0, this._pointerInput = function(d, p) {
+ var y = d.event, P = y.pointerType === "touch";
+ if (!n.isInVRExclusivePointerMode && (d.type === yt.a.POINTERMOVE || e.buttons.indexOf(y.button) !== -1)) {
+ var R = y.srcElement || y.target;
+ if (e._altKey = y.altKey, e._ctrlKey = y.ctrlKey, e._metaKey = y.metaKey, e._shiftKey = y.shiftKey, e._buttonsPressed = y.buttons, n.isPointerLock) {
+ var B = y.movementX || y.mozMovementX || y.webkitMovementX || y.msMovementX || 0, F = y.movementY || y.mozMovementY || y.webkitMovementY || y.msMovementY || 0;
+ e.onTouch(null, B, F), e.pointA = null, e.pointB = null;
+ } else if (d.type === yt.a.POINTERDOWN && R) {
+ try {
+ R.setPointerCapture(y.pointerId);
+ } catch {
+ }
+ e.pointA === null ? e.pointA = { x: y.clientX, y: y.clientY, pointerId: y.pointerId, type: y.pointerType } : e.pointB === null && (e.pointB = { x: y.clientX, y: y.clientY, pointerId: y.pointerId, type: y.pointerType }), e.onButtonDown(y), t || (y.preventDefault(), i && i.focus());
+ } else if (d.type === yt.a.POINTERDOUBLETAP)
+ e.onDoubleTap(y.pointerType);
+ else if (d.type === yt.a.POINTERUP && R) {
+ try {
+ R.releasePointerCapture(y.pointerId);
+ } catch {
+ }
+ P || (e.pointB = null), n._badOS ? e.pointA = e.pointB = null : e.pointB && e.pointA && e.pointA.pointerId == y.pointerId ? (e.pointA = e.pointB, e.pointB = null) : e.pointA && e.pointB && e.pointB.pointerId == y.pointerId ? e.pointB = null : e.pointA = e.pointB = null, (o !== 0 || a) && (e.onMultiTouch(e.pointA, e.pointB, o, 0, a, null), o = 0, a = null), e.onButtonUp(y), t || y.preventDefault();
+ } else if (d.type === yt.a.POINTERMOVE) {
+ if (t || y.preventDefault(), e.pointA && e.pointB === null)
+ B = y.clientX - e.pointA.x, F = y.clientY - e.pointA.y, e.onTouch(e.pointA, B, F), e.pointA.x = y.clientX, e.pointA.y = y.clientY;
+ else if (e.pointA && e.pointB) {
+ var z = e.pointA.pointerId === y.pointerId ? e.pointA : e.pointB;
+ z.x = y.clientX, z.y = y.clientY;
+ var J = e.pointA.x - e.pointB.x, ie = e.pointA.y - e.pointB.y, se = J * J + ie * ie, ce = { x: (e.pointA.x + e.pointB.x) / 2, y: (e.pointA.y + e.pointB.y) / 2, pointerId: y.pointerId, type: d.type };
+ e.onMultiTouch(e.pointA, e.pointB, o, se, a, ce), a = ce, o = se;
+ }
+ }
+ }
+ }, this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, yt.a.POINTERDOWN | yt.a.POINTERUP | yt.a.POINTERMOVE), this._onLostFocus = function() {
+ e.pointA = e.pointB = null, o = 0, a = null, e.onLostFocus();
+ }, i && i.addEventListener("contextmenu", this.onContextMenu.bind(this), !1);
+ var s = this.camera.getScene().getEngine().getHostWindow();
+ s && Xe.b.RegisterTopRootEvents(s, [{ name: "blur", handler: this._onLostFocus }]);
+ }, r.prototype.detachControl = function(t) {
+ if (this._onLostFocus) {
+ var e = this.camera.getScene().getEngine().getHostWindow();
+ e && Xe.b.UnregisterTopRootEvents(e, [{ name: "blur", handler: this._onLostFocus }]);
+ }
+ if (this._observer) {
+ if (this.camera.getScene().onPointerObservable.remove(this._observer), this._observer = null, this.onContextMenu) {
+ var n = this.camera.getScene().getEngine().getInputElement();
+ n && n.removeEventListener("contextmenu", this.onContextMenu);
+ }
+ this._onLostFocus = null;
+ }
+ this._altKey = !1, this._ctrlKey = !1, this._metaKey = !1, this._shiftKey = !1, this._buttonsPressed = 0;
+ }, r.prototype.getClassName = function() {
+ return "BaseCameraPointersInput";
+ }, r.prototype.getSimpleName = function() {
+ return "pointers";
+ }, r.prototype.onDoubleTap = function(t) {
+ }, r.prototype.onTouch = function(t, e, n) {
+ }, r.prototype.onMultiTouch = function(t, e, n, i, o, a) {
+ }, r.prototype.onContextMenu = function(t) {
+ t.preventDefault();
+ }, r.prototype.onButtonDown = function(t) {
+ }, r.prototype.onButtonUp = function(t) {
+ }, r.prototype.onLostFocus = function() {
+ }, Object(c.c)([Object(L.c)()], r.prototype, "buttons", void 0), r;
+ }(), wa = function(r) {
+ function t() {
+ var e = r !== null && r.apply(this, arguments) || this;
+ return e.buttons = [0, 1, 2], e.angularSensibilityX = 1e3, e.angularSensibilityY = 1e3, e.pinchPrecision = 12, e.pinchDeltaPercentage = 0, e.useNaturalPinchZoom = !1, e.panningSensibility = 1e3, e.multiTouchPanning = !0, e.multiTouchPanAndZoom = !0, e.pinchInwards = !0, e._isPanClick = !1, e._twoFingerActivityCount = 0, e._isPinching = !1, e;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "ArcRotateCameraPointersInput";
+ }, t.prototype.onTouch = function(e, n, i) {
+ this.panningSensibility !== 0 && (this._ctrlKey && this.camera._useCtrlForPanning || this._isPanClick) ? (this.camera.inertialPanningX += -n / this.panningSensibility, this.camera.inertialPanningY += i / this.panningSensibility) : (this.camera.inertialAlphaOffset -= n / this.angularSensibilityX, this.camera.inertialBetaOffset -= i / this.angularSensibilityY);
+ }, t.prototype.onDoubleTap = function(e) {
+ this.camera.useInputToRestoreState && this.camera.restoreState();
+ }, t.prototype.onMultiTouch = function(e, n, i, o, a, s) {
+ if (!(i === 0 && a === null || o === 0 && s === null)) {
+ var d = this.pinchInwards ? 1 : -1;
+ if (this.multiTouchPanAndZoom) {
+ if (this.useNaturalPinchZoom ? this.camera.radius = this.camera.radius * Math.sqrt(i) / Math.sqrt(o) : this.pinchDeltaPercentage ? this.camera.inertialRadiusOffset += 1e-3 * (o - i) * this.camera.radius * this.pinchDeltaPercentage : this.camera.inertialRadiusOffset += (o - i) / (this.pinchPrecision * d * (this.angularSensibilityX + this.angularSensibilityY) / 2), this.panningSensibility !== 0 && a && s) {
+ var p = s.x - a.x, y = s.y - a.y;
+ this.camera.inertialPanningX += -p / this.panningSensibility, this.camera.inertialPanningY += y / this.panningSensibility;
+ }
+ } else {
+ this._twoFingerActivityCount++;
+ var P = Math.sqrt(i), R = Math.sqrt(o);
+ this._isPinching || this._twoFingerActivityCount < 20 && Math.abs(R - P) > this.camera.pinchToPanMaxDistance ? (this.pinchDeltaPercentage ? this.camera.inertialRadiusOffset += 1e-3 * (o - i) * this.camera.radius * this.pinchDeltaPercentage : this.camera.inertialRadiusOffset += (o - i) / (this.pinchPrecision * d * (this.angularSensibilityX + this.angularSensibilityY) / 2), this._isPinching = !0) : this.panningSensibility !== 0 && this.multiTouchPanning && s && a && (p = s.x - a.x, y = s.y - a.y, this.camera.inertialPanningX += -p / this.panningSensibility, this.camera.inertialPanningY += y / this.panningSensibility);
+ }
+ }
+ }, t.prototype.onButtonDown = function(e) {
+ this._isPanClick = e.button === this.camera._panningMouseButton;
+ }, t.prototype.onButtonUp = function(e) {
+ this._twoFingerActivityCount = 0, this._isPinching = !1;
+ }, t.prototype.onLostFocus = function() {
+ this._isPanClick = !1, this._twoFingerActivityCount = 0, this._isPinching = !1;
+ }, Object(c.c)([Object(L.c)()], t.prototype, "buttons", void 0), Object(c.c)([Object(L.c)()], t.prototype, "angularSensibilityX", void 0), Object(c.c)([Object(L.c)()], t.prototype, "angularSensibilityY", void 0), Object(c.c)([Object(L.c)()], t.prototype, "pinchPrecision", void 0), Object(c.c)([Object(L.c)()], t.prototype, "pinchDeltaPercentage", void 0), Object(c.c)([Object(L.c)()], t.prototype, "useNaturalPinchZoom", void 0), Object(c.c)([Object(L.c)()], t.prototype, "panningSensibility", void 0), Object(c.c)([Object(L.c)()], t.prototype, "multiTouchPanning", void 0), Object(c.c)([Object(L.c)()], t.prototype, "multiTouchPanAndZoom", void 0), t;
+ }(il);
+ un.ArcRotateCameraPointersInput = wa;
+ var Po = function(r) {
+ function t(e) {
+ return r.call(this, e) || this;
+ }
+ return Object(c.d)(t, r), t.prototype.addMouseWheel = function() {
+ return this.add(new Na()), this;
+ }, t.prototype.addPointers = function() {
+ return this.add(new wa()), this;
+ }, t.prototype.addKeyboard = function() {
+ return this.add(new La()), this;
+ }, t;
+ }(zr);
+ Po.prototype.addVRDeviceOrientation = function() {
+ return this.add(new Fa()), this;
+ };
+ var Fa = function() {
+ function r() {
+ this.alphaCorrection = 1, this.gammaCorrection = 1, this._alpha = 0, this._gamma = 0, this._dirty = !1, this._deviceOrientationHandler = this._onOrientationEvent.bind(this);
+ }
+ return r.prototype.attachControl = function(t) {
+ var e = this;
+ t = Xe.b.BackCompatCameraNoPreventDefault(arguments), this.camera.attachControl(t);
+ var n = this.camera.getScene().getEngine().getHostWindow();
+ n && (typeof DeviceOrientationEvent < "u" && typeof DeviceOrientationEvent.requestPermission == "function" ? DeviceOrientationEvent.requestPermission().then(function(i) {
+ i === "granted" ? n.addEventListener("deviceorientation", e._deviceOrientationHandler) : Xe.b.Warn("Permission not granted.");
+ }).catch(function(i) {
+ Xe.b.Error(i);
+ }) : n.addEventListener("deviceorientation", this._deviceOrientationHandler));
+ }, r.prototype._onOrientationEvent = function(t) {
+ t.alpha !== null && (this._alpha = (0 | +t.alpha) * this.alphaCorrection), t.gamma !== null && (this._gamma = (0 | +t.gamma) * this.gammaCorrection), this._dirty = !0;
+ }, r.prototype.checkInputs = function() {
+ this._dirty && (this._dirty = !1, this._gamma < 0 && (this._gamma = 180 + this._gamma), this.camera.alpha = -this._alpha / 180 * Math.PI % Math.PI * 2, this.camera.beta = this._gamma / 180 * Math.PI);
+ }, r.prototype.detachControl = function(t) {
+ window.removeEventListener("deviceorientation", this._deviceOrientationHandler);
+ }, r.prototype.getClassName = function() {
+ return "ArcRotateCameraVRDeviceOrientationInput";
+ }, r.prototype.getSimpleName = function() {
+ return "VRDeviceOrientation";
+ }, r;
+ }();
+ un.ArcRotateCameraVRDeviceOrientationInput = Fa;
+ var Ba = function() {
+ function r() {
+ this.keysForward = [87], this.keysBackward = [83], this.keysUp = [69], this.keysDown = [81], this.keysRight = [68], this.keysLeft = [65], this._keys = new Array();
+ }
+ return r.prototype.attachControl = function(t) {
+ var e = this;
+ t = Xe.b.BackCompatCameraNoPreventDefault(arguments), this._onCanvasBlurObserver || (this._scene = this.camera.getScene(), this._engine = this._scene.getEngine(), this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function() {
+ e._keys = [];
+ }), this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function(n) {
+ var i, o = n.event;
+ n.type === zi.a.KEYDOWN ? e.keysForward.indexOf(o.keyCode) === -1 && e.keysBackward.indexOf(o.keyCode) === -1 && e.keysUp.indexOf(o.keyCode) === -1 && e.keysDown.indexOf(o.keyCode) === -1 && e.keysLeft.indexOf(o.keyCode) === -1 && e.keysRight.indexOf(o.keyCode) === -1 || ((i = e._keys.indexOf(o.keyCode)) === -1 && e._keys.push(o.keyCode), t || o.preventDefault()) : e.keysForward.indexOf(o.keyCode) === -1 && e.keysBackward.indexOf(o.keyCode) === -1 && e.keysUp.indexOf(o.keyCode) === -1 && e.keysDown.indexOf(o.keyCode) === -1 && e.keysLeft.indexOf(o.keyCode) === -1 && e.keysRight.indexOf(o.keyCode) === -1 || ((i = e._keys.indexOf(o.keyCode)) >= 0 && e._keys.splice(i, 1), t || o.preventDefault());
+ }));
+ }, r.prototype.detachControl = function(t) {
+ this._scene && (this._onKeyboardObserver && this._scene.onKeyboardObservable.remove(this._onKeyboardObserver), this._onCanvasBlurObserver && this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver), this._onKeyboardObserver = null, this._onCanvasBlurObserver = null), this._keys = [];
+ }, r.prototype.getClassName = function() {
+ return "FlyCameraKeyboardInput";
+ }, r.prototype._onLostFocus = function(t) {
+ this._keys = [];
+ }, r.prototype.getSimpleName = function() {
+ return "keyboard";
+ }, r.prototype.checkInputs = function() {
+ if (this._onKeyboardObserver)
+ for (var t = this.camera, e = 0; e < this._keys.length; e++) {
+ var n = this._keys[e], i = t._computeLocalCameraSpeed();
+ this.keysForward.indexOf(n) !== -1 ? t._localDirection.copyFromFloats(0, 0, i) : this.keysBackward.indexOf(n) !== -1 ? t._localDirection.copyFromFloats(0, 0, -i) : this.keysUp.indexOf(n) !== -1 ? t._localDirection.copyFromFloats(0, i, 0) : this.keysDown.indexOf(n) !== -1 ? t._localDirection.copyFromFloats(0, -i, 0) : this.keysRight.indexOf(n) !== -1 ? t._localDirection.copyFromFloats(i, 0, 0) : this.keysLeft.indexOf(n) !== -1 && t._localDirection.copyFromFloats(-i, 0, 0), t.getScene().useRightHandedSystem && (t._localDirection.z *= -1), t.getViewMatrix().invertToRef(t._cameraTransformMatrix), u.e.TransformNormalToRef(t._localDirection, t._cameraTransformMatrix, t._transformedDirection), t.cameraDirection.addInPlace(t._transformedDirection);
+ }
+ }, Object(c.c)([Object(L.c)()], r.prototype, "keysForward", void 0), Object(c.c)([Object(L.c)()], r.prototype, "keysBackward", void 0), Object(c.c)([Object(L.c)()], r.prototype, "keysUp", void 0), Object(c.c)([Object(L.c)()], r.prototype, "keysDown", void 0), Object(c.c)([Object(L.c)()], r.prototype, "keysRight", void 0), Object(c.c)([Object(L.c)()], r.prototype, "keysLeft", void 0), r;
+ }();
+ un.FlyCameraKeyboardInput = Ba;
+ var Ua = function() {
+ function r(t) {
+ this.buttons = [0, 1, 2], this.buttonsYaw = [-1, 0, 1], this.buttonsPitch = [-1, 0, 1], this.buttonsRoll = [2], this.activeButton = -1, this.angularSensibility = 1e3, this.previousPosition = null;
+ }
+ return r.prototype.attachControl = function(t) {
+ var e = this;
+ t = Xe.b.BackCompatCameraNoPreventDefault(arguments), this.noPreventDefault = t, this._observer = this.camera.getScene().onPointerObservable.add(function(n, i) {
+ e._pointerInput(n, i);
+ }, yt.a.POINTERDOWN | yt.a.POINTERUP | yt.a.POINTERMOVE), this._rollObserver = this.camera.getScene().onBeforeRenderObservable.add(function() {
+ e.camera.rollCorrect && e.camera.restoreRoll(e.camera.rollCorrect);
+ });
+ }, r.prototype.detachControl = function(t) {
+ this._observer && (this.camera.getScene().onPointerObservable.remove(this._observer), this.camera.getScene().onBeforeRenderObservable.remove(this._rollObserver), this._observer = null, this._rollObserver = null, this.previousPosition = null, this.noPreventDefault = void 0);
+ }, r.prototype.getClassName = function() {
+ return "FlyCameraMouseInput";
+ }, r.prototype.getSimpleName = function() {
+ return "mouse";
+ }, r.prototype._pointerInput = function(t, e) {
+ var n = t.event, i = this.camera.getEngine();
+ if (!i.isInVRExclusivePointerMode && (this.touchEnabled || n.pointerType !== "touch") && (t.type === yt.a.POINTERMOVE || this.buttons.indexOf(n.button) !== -1)) {
+ var o = n.srcElement || n.target;
+ if (t.type === yt.a.POINTERDOWN && o) {
+ try {
+ o.setPointerCapture(n.pointerId);
+ } catch {
+ }
+ this.previousPosition = { x: n.clientX, y: n.clientY }, this.activeButton = n.button, this.noPreventDefault || (n.preventDefault(), this.element.focus()), i.isPointerLock && this._onMouseMove(t.event);
+ } else if (t.type === yt.a.POINTERUP && o) {
+ try {
+ o.releasePointerCapture(n.pointerId);
+ } catch {
+ }
+ this.activeButton = -1, this.previousPosition = null, this.noPreventDefault || n.preventDefault();
+ } else if (t.type === yt.a.POINTERMOVE) {
+ if (!this.previousPosition)
+ return void (i.isPointerLock && this._onMouseMove(t.event));
+ var a = n.clientX - this.previousPosition.x, s = n.clientY - this.previousPosition.y;
+ this.rotateCamera(a, s), this.previousPosition = { x: n.clientX, y: n.clientY }, this.noPreventDefault || n.preventDefault();
+ }
+ }
+ }, r.prototype._onMouseMove = function(t) {
+ var e = this.camera.getEngine();
+ if (e.isPointerLock && !e.isInVRExclusivePointerMode) {
+ var n = t.movementX || t.mozMovementX || t.webkitMovementX || t.msMovementX || 0, i = t.movementY || t.mozMovementY || t.webkitMovementY || t.msMovementY || 0;
+ this.rotateCamera(n, i), this.previousPosition = null, this.noPreventDefault || t.preventDefault();
+ }
+ }, r.prototype.rotateCamera = function(t, e) {
+ var n = this, i = this.camera;
+ this.camera.getScene().useRightHandedSystem && (t *= -1), i.parent && i.parent._getWorldMatrixDeterminant() < 0 && (t *= -1);
+ var o, a = t / this.angularSensibility, s = e / this.angularSensibility, d = u.b.RotationYawPitchRoll(i.rotation.y, i.rotation.x, i.rotation.z);
+ if (this.buttonsPitch.some(function(P) {
+ return P === n.activeButton;
+ }) && (o = u.b.RotationAxis(be.a.X, s), d.multiplyInPlace(o)), this.buttonsYaw.some(function(P) {
+ return P === n.activeButton;
+ })) {
+ o = u.b.RotationAxis(be.a.Y, a), d.multiplyInPlace(o);
+ var p = i.bankedTurnLimit + i._trackRoll;
+ if (i.bankedTurn && -p < i.rotation.z && i.rotation.z < p) {
+ var y = i.bankedTurnMultiplier * -a;
+ o = u.b.RotationAxis(be.a.Z, y), d.multiplyInPlace(o);
+ }
+ }
+ this.buttonsRoll.some(function(P) {
+ return P === n.activeButton;
+ }) && (o = u.b.RotationAxis(be.a.Z, -a), i._trackRoll -= a, d.multiplyInPlace(o)), d.toEulerAnglesToRef(i.rotation);
+ }, Object(c.c)([Object(L.c)()], r.prototype, "buttons", void 0), Object(c.c)([Object(L.c)()], r.prototype, "angularSensibility", void 0), r;
+ }();
+ un.FlyCameraMouseInput = Ua;
+ var Va = function() {
+ function r() {
+ this.keysHeightOffsetIncr = [38], this.keysHeightOffsetDecr = [40], this.keysHeightOffsetModifierAlt = !1, this.keysHeightOffsetModifierCtrl = !1, this.keysHeightOffsetModifierShift = !1, this.keysRotationOffsetIncr = [37], this.keysRotationOffsetDecr = [39], this.keysRotationOffsetModifierAlt = !1, this.keysRotationOffsetModifierCtrl = !1, this.keysRotationOffsetModifierShift = !1, this.keysRadiusIncr = [40], this.keysRadiusDecr = [38], this.keysRadiusModifierAlt = !0, this.keysRadiusModifierCtrl = !1, this.keysRadiusModifierShift = !1, this.heightSensibility = 1, this.rotationSensibility = 1, this.radiusSensibility = 1, this._keys = new Array();
+ }
+ return r.prototype.attachControl = function(t) {
+ var e = this;
+ t = Xe.b.BackCompatCameraNoPreventDefault(arguments), this._onCanvasBlurObserver || (this._scene = this.camera.getScene(), this._engine = this._scene.getEngine(), this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function() {
+ e._keys = [];
+ }), this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function(n) {
+ var i, o = n.event;
+ o.metaKey || (n.type === zi.a.KEYDOWN ? (e._ctrlPressed = o.ctrlKey, e._altPressed = o.altKey, e._shiftPressed = o.shiftKey, (e.keysHeightOffsetIncr.indexOf(o.keyCode) !== -1 || e.keysHeightOffsetDecr.indexOf(o.keyCode) !== -1 || e.keysRotationOffsetIncr.indexOf(o.keyCode) !== -1 || e.keysRotationOffsetDecr.indexOf(o.keyCode) !== -1 || e.keysRadiusIncr.indexOf(o.keyCode) !== -1 || e.keysRadiusDecr.indexOf(o.keyCode) !== -1) && ((i = e._keys.indexOf(o.keyCode)) === -1 && e._keys.push(o.keyCode), o.preventDefault && (t || o.preventDefault()))) : e.keysHeightOffsetIncr.indexOf(o.keyCode) === -1 && e.keysHeightOffsetDecr.indexOf(o.keyCode) === -1 && e.keysRotationOffsetIncr.indexOf(o.keyCode) === -1 && e.keysRotationOffsetDecr.indexOf(o.keyCode) === -1 && e.keysRadiusIncr.indexOf(o.keyCode) === -1 && e.keysRadiusDecr.indexOf(o.keyCode) === -1 || ((i = e._keys.indexOf(o.keyCode)) >= 0 && e._keys.splice(i, 1), o.preventDefault && (t || o.preventDefault())));
+ }));
+ }, r.prototype.detachControl = function(t) {
+ this._scene && (this._onKeyboardObserver && this._scene.onKeyboardObservable.remove(this._onKeyboardObserver), this._onCanvasBlurObserver && this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver), this._onKeyboardObserver = null, this._onCanvasBlurObserver = null), this._keys = [];
+ }, r.prototype.checkInputs = function() {
+ var t = this;
+ this._onKeyboardObserver && this._keys.forEach(function(e) {
+ t.keysHeightOffsetIncr.indexOf(e) !== -1 && t._modifierHeightOffset() ? t.camera.heightOffset += t.heightSensibility : t.keysHeightOffsetDecr.indexOf(e) !== -1 && t._modifierHeightOffset() ? t.camera.heightOffset -= t.heightSensibility : t.keysRotationOffsetIncr.indexOf(e) !== -1 && t._modifierRotationOffset() ? (t.camera.rotationOffset += t.rotationSensibility, t.camera.rotationOffset %= 360) : t.keysRotationOffsetDecr.indexOf(e) !== -1 && t._modifierRotationOffset() ? (t.camera.rotationOffset -= t.rotationSensibility, t.camera.rotationOffset %= 360) : t.keysRadiusIncr.indexOf(e) !== -1 && t._modifierRadius() ? t.camera.radius += t.radiusSensibility : t.keysRadiusDecr.indexOf(e) !== -1 && t._modifierRadius() && (t.camera.radius -= t.radiusSensibility);
+ });
+ }, r.prototype.getClassName = function() {
+ return "FollowCameraKeyboardMoveInput";
+ }, r.prototype.getSimpleName = function() {
+ return "keyboard";
+ }, r.prototype._modifierHeightOffset = function() {
+ return this.keysHeightOffsetModifierAlt === this._altPressed && this.keysHeightOffsetModifierCtrl === this._ctrlPressed && this.keysHeightOffsetModifierShift === this._shiftPressed;
+ }, r.prototype._modifierRotationOffset = function() {
+ return this.keysRotationOffsetModifierAlt === this._altPressed && this.keysRotationOffsetModifierCtrl === this._ctrlPressed && this.keysRotationOffsetModifierShift === this._shiftPressed;
+ }, r.prototype._modifierRadius = function() {
+ return this.keysRadiusModifierAlt === this._altPressed && this.keysRadiusModifierCtrl === this._ctrlPressed && this.keysRadiusModifierShift === this._shiftPressed;
+ }, Object(c.c)([Object(L.c)()], r.prototype, "keysHeightOffsetIncr", void 0), Object(c.c)([Object(L.c)()], r.prototype, "keysHeightOffsetDecr", void 0), Object(c.c)([Object(L.c)()], r.prototype, "keysHeightOffsetModifierAlt", void 0), Object(c.c)([Object(L.c)()], r.prototype, "keysHeightOffsetModifierCtrl", void 0), Object(c.c)([Object(L.c)()], r.prototype, "keysHeightOffsetModifierShift", void 0), Object(c.c)([Object(L.c)()], r.prototype, "keysRotationOffsetIncr", void 0), Object(c.c)([Object(L.c)()], r.prototype, "keysRotationOffsetDecr", void 0), Object(c.c)([Object(L.c)()], r.prototype, "keysRotationOffsetModifierAlt", void 0), Object(c.c)([Object(L.c)()], r.prototype, "keysRotationOffsetModifierCtrl", void 0), Object(c.c)([Object(L.c)()], r.prototype, "keysRotationOffsetModifierShift", void 0), Object(c.c)([Object(L.c)()], r.prototype, "keysRadiusIncr", void 0), Object(c.c)([Object(L.c)()], r.prototype, "keysRadiusDecr", void 0), Object(c.c)([Object(L.c)()], r.prototype, "keysRadiusModifierAlt", void 0), Object(c.c)([Object(L.c)()], r.prototype, "keysRadiusModifierCtrl", void 0), Object(c.c)([Object(L.c)()], r.prototype, "keysRadiusModifierShift", void 0), Object(c.c)([Object(L.c)()], r.prototype, "heightSensibility", void 0), Object(c.c)([Object(L.c)()], r.prototype, "rotationSensibility", void 0), Object(c.c)([Object(L.c)()], r.prototype, "radiusSensibility", void 0), r;
+ }();
+ un.FollowCameraKeyboardMoveInput = Va;
+ var ka = function() {
+ function r() {
+ this.axisControlRadius = !0, this.axisControlHeight = !1, this.axisControlRotation = !1, this.wheelPrecision = 3, this.wheelDeltaPercentage = 0;
+ }
+ return r.prototype.attachControl = function(t) {
+ var e = this;
+ t = Xe.b.BackCompatCameraNoPreventDefault(arguments), this._wheel = function(n, i) {
+ if (n.type === yt.a.POINTERWHEEL) {
+ var o = n.event, a = 0, s = Math.max(-1, Math.min(1, o.deltaY || o.wheelDelta || -o.detail));
+ e.wheelDeltaPercentage ? (console.assert(e.axisControlRadius + e.axisControlHeight + e.axisControlRotation <= 1, "wheelDeltaPercentage only usable when mouse wheel controlls ONE axis. Currently enabled: axisControlRadius: " + e.axisControlRadius + ", axisControlHeightOffset: " + e.axisControlHeight + ", axisControlRotationOffset: " + e.axisControlRotation), e.axisControlRadius ? a = 0.01 * s * e.wheelDeltaPercentage * e.camera.radius : e.axisControlHeight ? a = 0.01 * s * e.wheelDeltaPercentage * e.camera.heightOffset : e.axisControlRotation && (a = 0.01 * s * e.wheelDeltaPercentage * e.camera.rotationOffset)) : a = s * e.wheelPrecision, a && (e.axisControlRadius ? e.camera.radius += a : e.axisControlHeight ? e.camera.heightOffset -= a : e.axisControlRotation && (e.camera.rotationOffset -= a)), o.preventDefault && (t || o.preventDefault());
+ }
+ }, this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, yt.a.POINTERWHEEL);
+ }, r.prototype.detachControl = function(t) {
+ this._observer && (this.camera.getScene().onPointerObservable.remove(this._observer), this._observer = null, this._wheel = null);
+ }, r.prototype.getClassName = function() {
+ return "ArcRotateCameraMouseWheelInput";
+ }, r.prototype.getSimpleName = function() {
+ return "mousewheel";
+ }, Object(c.c)([Object(L.c)()], r.prototype, "axisControlRadius", void 0), Object(c.c)([Object(L.c)()], r.prototype, "axisControlHeight", void 0), Object(c.c)([Object(L.c)()], r.prototype, "axisControlRotation", void 0), Object(c.c)([Object(L.c)()], r.prototype, "wheelPrecision", void 0), Object(c.c)([Object(L.c)()], r.prototype, "wheelDeltaPercentage", void 0), r;
+ }();
+ un.FollowCameraMouseWheelInput = ka;
+ var Ga = function(r) {
+ function t() {
+ var e = r !== null && r.apply(this, arguments) || this;
+ return e.angularSensibilityX = 1, e.angularSensibilityY = 1, e.pinchPrecision = 1e4, e.pinchDeltaPercentage = 0, e.axisXControlRadius = !1, e.axisXControlHeight = !1, e.axisXControlRotation = !0, e.axisYControlRadius = !1, e.axisYControlHeight = !0, e.axisYControlRotation = !1, e.axisPinchControlRadius = !0, e.axisPinchControlHeight = !1, e.axisPinchControlRotation = !1, e.warningEnable = !0, e._warningCounter = 0, e;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "FollowCameraPointersInput";
+ }, t.prototype.onTouch = function(e, n, i) {
+ this._warning(), this.axisXControlRotation ? this.camera.rotationOffset += n / this.angularSensibilityX : this.axisYControlRotation && (this.camera.rotationOffset += i / this.angularSensibilityX), this.axisXControlHeight ? this.camera.heightOffset += n / this.angularSensibilityY : this.axisYControlHeight && (this.camera.heightOffset += i / this.angularSensibilityY), this.axisXControlRadius ? this.camera.radius -= n / this.angularSensibilityY : this.axisYControlRadius && (this.camera.radius -= i / this.angularSensibilityY);
+ }, t.prototype.onMultiTouch = function(e, n, i, o, a, s) {
+ if (!(i === 0 && a === null || o === 0 && s === null)) {
+ var d = (o - i) / (this.pinchPrecision * (this.angularSensibilityX + this.angularSensibilityY) / 2);
+ this.pinchDeltaPercentage ? (d *= 0.01 * this.pinchDeltaPercentage, this.axisPinchControlRotation && (this.camera.rotationOffset += d * this.camera.rotationOffset), this.axisPinchControlHeight && (this.camera.heightOffset += d * this.camera.heightOffset), this.axisPinchControlRadius && (this.camera.radius -= d * this.camera.radius)) : (this.axisPinchControlRotation && (this.camera.rotationOffset += d), this.axisPinchControlHeight && (this.camera.heightOffset += d), this.axisPinchControlRadius && (this.camera.radius -= d));
+ }
+ }, t.prototype._warning = function() {
+ if (this.warningEnable && this._warningCounter++ % 100 == 0) {
+ var e = "It probably only makes sense to control ONE camera property with each pointer axis. Set 'warningEnable = false' if you are sure. Currently enabled: ";
+ console.assert(this.axisXControlRotation + this.axisXControlHeight + this.axisXControlRadius <= 1, e + "axisXControlRotation: " + this.axisXControlRotation + ", axisXControlHeight: " + this.axisXControlHeight + ", axisXControlRadius: " + this.axisXControlRadius), console.assert(this.axisYControlRotation + this.axisYControlHeight + this.axisYControlRadius <= 1, e + "axisYControlRotation: " + this.axisYControlRotation + ", axisYControlHeight: " + this.axisYControlHeight + ", axisYControlRadius: " + this.axisYControlRadius), console.assert(this.axisPinchControlRotation + this.axisPinchControlHeight + this.axisPinchControlRadius <= 1, e + "axisPinchControlRotation: " + this.axisPinchControlRotation + ", axisPinchControlHeight: " + this.axisPinchControlHeight + ", axisPinchControlRadius: " + this.axisPinchControlRadius);
+ }
+ }, Object(c.c)([Object(L.c)()], t.prototype, "angularSensibilityX", void 0), Object(c.c)([Object(L.c)()], t.prototype, "angularSensibilityY", void 0), Object(c.c)([Object(L.c)()], t.prototype, "pinchPrecision", void 0), Object(c.c)([Object(L.c)()], t.prototype, "pinchDeltaPercentage", void 0), Object(c.c)([Object(L.c)()], t.prototype, "axisXControlRadius", void 0), Object(c.c)([Object(L.c)()], t.prototype, "axisXControlHeight", void 0), Object(c.c)([Object(L.c)()], t.prototype, "axisXControlRotation", void 0), Object(c.c)([Object(L.c)()], t.prototype, "axisYControlRadius", void 0), Object(c.c)([Object(L.c)()], t.prototype, "axisYControlHeight", void 0), Object(c.c)([Object(L.c)()], t.prototype, "axisYControlRotation", void 0), Object(c.c)([Object(L.c)()], t.prototype, "axisPinchControlRadius", void 0), Object(c.c)([Object(L.c)()], t.prototype, "axisPinchControlHeight", void 0), Object(c.c)([Object(L.c)()], t.prototype, "axisPinchControlRotation", void 0), t;
+ }(il);
+ un.FollowCameraPointersInput = Ga;
+ var za = function() {
+ function r() {
+ this.keysUp = [38], this.keysUpward = [33], this.keysDown = [40], this.keysDownward = [34], this.keysLeft = [37], this.keysRight = [39], this._keys = new Array();
+ }
+ return r.prototype.attachControl = function(t) {
+ var e = this;
+ t = Xe.b.BackCompatCameraNoPreventDefault(arguments), this._onCanvasBlurObserver || (this._scene = this.camera.getScene(), this._engine = this._scene.getEngine(), this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function() {
+ e._keys = [];
+ }), this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function(n) {
+ var i, o = n.event;
+ o.metaKey || (n.type === zi.a.KEYDOWN ? e.keysUp.indexOf(o.keyCode) === -1 && e.keysDown.indexOf(o.keyCode) === -1 && e.keysLeft.indexOf(o.keyCode) === -1 && e.keysRight.indexOf(o.keyCode) === -1 && e.keysUpward.indexOf(o.keyCode) === -1 && e.keysDownward.indexOf(o.keyCode) === -1 || ((i = e._keys.indexOf(o.keyCode)) === -1 && e._keys.push(o.keyCode), t || o.preventDefault()) : e.keysUp.indexOf(o.keyCode) === -1 && e.keysDown.indexOf(o.keyCode) === -1 && e.keysLeft.indexOf(o.keyCode) === -1 && e.keysRight.indexOf(o.keyCode) === -1 && e.keysUpward.indexOf(o.keyCode) === -1 && e.keysDownward.indexOf(o.keyCode) === -1 || ((i = e._keys.indexOf(o.keyCode)) >= 0 && e._keys.splice(i, 1), t || o.preventDefault()));
+ }));
+ }, r.prototype.detachControl = function(t) {
+ this._scene && (this._onKeyboardObserver && this._scene.onKeyboardObservable.remove(this._onKeyboardObserver), this._onCanvasBlurObserver && this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver), this._onKeyboardObserver = null, this._onCanvasBlurObserver = null), this._keys = [];
+ }, r.prototype.checkInputs = function() {
+ if (this._onKeyboardObserver)
+ for (var t = this.camera, e = 0; e < this._keys.length; e++) {
+ var n = this._keys[e], i = t._computeLocalCameraSpeed();
+ this.keysLeft.indexOf(n) !== -1 ? t._localDirection.copyFromFloats(-i, 0, 0) : this.keysUp.indexOf(n) !== -1 ? t._localDirection.copyFromFloats(0, 0, i) : this.keysRight.indexOf(n) !== -1 ? t._localDirection.copyFromFloats(i, 0, 0) : this.keysDown.indexOf(n) !== -1 ? t._localDirection.copyFromFloats(0, 0, -i) : this.keysUpward.indexOf(n) !== -1 ? t._localDirection.copyFromFloats(0, i, 0) : this.keysDownward.indexOf(n) !== -1 && t._localDirection.copyFromFloats(0, -i, 0), t.getScene().useRightHandedSystem && (t._localDirection.z *= -1), t.getViewMatrix().invertToRef(t._cameraTransformMatrix), u.e.TransformNormalToRef(t._localDirection, t._cameraTransformMatrix, t._transformedDirection), t.cameraDirection.addInPlace(t._transformedDirection);
+ }
+ }, r.prototype.getClassName = function() {
+ return "FreeCameraKeyboardMoveInput";
+ }, r.prototype._onLostFocus = function() {
+ this._keys = [];
+ }, r.prototype.getSimpleName = function() {
+ return "keyboard";
+ }, Object(c.c)([Object(L.c)()], r.prototype, "keysUp", void 0), Object(c.c)([Object(L.c)()], r.prototype, "keysUpward", void 0), Object(c.c)([Object(L.c)()], r.prototype, "keysDown", void 0), Object(c.c)([Object(L.c)()], r.prototype, "keysDownward", void 0), Object(c.c)([Object(L.c)()], r.prototype, "keysLeft", void 0), Object(c.c)([Object(L.c)()], r.prototype, "keysRight", void 0), r;
+ }();
+ un.FreeCameraKeyboardMoveInput = za;
+ var ja = function() {
+ function r(t) {
+ t === void 0 && (t = !0), this.touchEnabled = t, this.buttons = [0, 1, 2], this.angularSensibility = 2e3, this.previousPosition = null, this.onPointerMovedObservable = new C.c(), this._allowCameraRotation = !0;
+ }
+ return r.prototype.attachControl = function(t) {
+ var e = this;
+ t = Xe.b.BackCompatCameraNoPreventDefault(arguments);
+ var n = this.camera.getEngine(), i = n.getInputElement();
+ this._pointerInput || (this._pointerInput = function(o) {
+ var a = o.event;
+ if (!n.isInVRExclusivePointerMode && (e.touchEnabled || a.pointerType !== "touch") && (o.type === yt.a.POINTERMOVE || e.buttons.indexOf(a.button) !== -1)) {
+ var s = a.srcElement || a.target;
+ if (o.type === yt.a.POINTERDOWN && s) {
+ try {
+ s.setPointerCapture(a.pointerId);
+ } catch {
+ }
+ e.previousPosition = { x: a.clientX, y: a.clientY }, t || (a.preventDefault(), i && i.focus()), n.isPointerLock && e._onMouseMove && e._onMouseMove(o.event);
+ } else if (o.type === yt.a.POINTERUP && s) {
+ try {
+ s.releasePointerCapture(a.pointerId);
+ } catch {
+ }
+ e.previousPosition = null, t || a.preventDefault();
+ } else if (o.type === yt.a.POINTERMOVE) {
+ if (!e.previousPosition)
+ return void (n.isPointerLock && e._onMouseMove && e._onMouseMove(o.event));
+ var d = a.clientX - e.previousPosition.x, p = a.clientY - e.previousPosition.y;
+ e.camera.getScene().useRightHandedSystem && (d *= -1), e.camera.parent && e.camera.parent._getWorldMatrixDeterminant() < 0 && (d *= -1), e._allowCameraRotation && (e.camera.cameraRotation.y += d / e.angularSensibility, e.camera.cameraRotation.x += p / e.angularSensibility), e.onPointerMovedObservable.notifyObservers({ offsetX: d, offsetY: p }), e.previousPosition = { x: a.clientX, y: a.clientY }, t || a.preventDefault();
+ }
+ }
+ }), this._onMouseMove = function(o) {
+ if (n.isPointerLock && !n.isInVRExclusivePointerMode) {
+ var a = o.movementX || o.mozMovementX || o.webkitMovementX || o.msMovementX || 0;
+ e.camera.getScene().useRightHandedSystem && (a *= -1), e.camera.parent && e.camera.parent._getWorldMatrixDeterminant() < 0 && (a *= -1), e.camera.cameraRotation.y += a / e.angularSensibility;
+ var s = o.movementY || o.mozMovementY || o.webkitMovementY || o.msMovementY || 0;
+ e.camera.cameraRotation.x += s / e.angularSensibility, e.previousPosition = null, t || o.preventDefault();
+ }
+ }, this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, yt.a.POINTERDOWN | yt.a.POINTERUP | yt.a.POINTERMOVE), i && i.addEventListener("contextmenu", this.onContextMenu.bind(this), !1);
+ }, r.prototype.onContextMenu = function(t) {
+ t.preventDefault();
+ }, r.prototype.detachControl = function(t) {
+ if (this._observer) {
+ if (this.camera.getScene().onPointerObservable.remove(this._observer), this.onContextMenu) {
+ var e = this.camera.getEngine().getInputElement();
+ e && e.removeEventListener("contextmenu", this.onContextMenu);
+ }
+ this.onPointerMovedObservable && this.onPointerMovedObservable.clear(), this._observer = null, this._onMouseMove = null, this.previousPosition = null;
+ }
+ }, r.prototype.getClassName = function() {
+ return "FreeCameraMouseInput";
+ }, r.prototype.getSimpleName = function() {
+ return "mouse";
+ }, Object(c.c)([Object(L.c)()], r.prototype, "buttons", void 0), Object(c.c)([Object(L.c)()], r.prototype, "angularSensibility", void 0), r;
+ }();
+ un.FreeCameraMouseInput = ja;
+ var Ut, mf = function() {
+ function r() {
+ this.wheelPrecisionX = 3, this.wheelPrecisionY = 3, this.wheelPrecisionZ = 3, this.onChangedObservable = new C.c(), this._wheelDeltaX = 0, this._wheelDeltaY = 0, this._wheelDeltaZ = 0, this._ffMultiplier = 12, this._normalize = 120;
+ }
+ return r.prototype.attachControl = function(t) {
+ var e = this;
+ t = Xe.b.BackCompatCameraNoPreventDefault(arguments), this._wheel = function(n) {
+ if (n.type === yt.a.POINTERWHEEL) {
+ var i = n.event, o = i.deltaMode === WheelEvent.DOM_DELTA_LINE ? e._ffMultiplier : 1;
+ i.deltaY !== void 0 ? (e._wheelDeltaX += e.wheelPrecisionX * o * i.deltaX / e._normalize, e._wheelDeltaY -= e.wheelPrecisionY * o * i.deltaY / e._normalize, e._wheelDeltaZ += e.wheelPrecisionZ * o * i.deltaZ / e._normalize) : i.wheelDeltaY !== void 0 ? (e._wheelDeltaX += e.wheelPrecisionX * o * i.wheelDeltaX / e._normalize, e._wheelDeltaY -= e.wheelPrecisionY * o * i.wheelDeltaY / e._normalize, e._wheelDeltaZ += e.wheelPrecisionZ * o * i.wheelDeltaZ / e._normalize) : i.wheelDelta && (e._wheelDeltaY -= e.wheelPrecisionY * i.wheelDelta / e._normalize), i.preventDefault && (t || i.preventDefault());
+ }
+ }, this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, yt.a.POINTERWHEEL);
+ }, r.prototype.detachControl = function(t) {
+ this._observer && (this.camera.getScene().onPointerObservable.remove(this._observer), this._observer = null, this._wheel = null), this.onChangedObservable && this.onChangedObservable.clear();
+ }, r.prototype.checkInputs = function() {
+ this.onChangedObservable.notifyObservers({ wheelDeltaX: this._wheelDeltaX, wheelDeltaY: this._wheelDeltaY, wheelDeltaZ: this._wheelDeltaZ }), this._wheelDeltaX = 0, this._wheelDeltaY = 0, this._wheelDeltaZ = 0;
+ }, r.prototype.getClassName = function() {
+ return "BaseCameraMouseWheelInput";
+ }, r.prototype.getSimpleName = function() {
+ return "mousewheel";
+ }, Object(c.c)([Object(L.c)()], r.prototype, "wheelPrecisionX", void 0), Object(c.c)([Object(L.c)()], r.prototype, "wheelPrecisionY", void 0), Object(c.c)([Object(L.c)()], r.prototype, "wheelPrecisionZ", void 0), r;
+ }();
+ (function(r) {
+ r[r.MoveRelative = 0] = "MoveRelative", r[r.RotateRelative = 1] = "RotateRelative", r[r.MoveScene = 2] = "MoveScene";
+ })(Ut || (Ut = {}));
+ var Ha = function(r) {
+ function t() {
+ var e = r !== null && r.apply(this, arguments) || this;
+ return e._moveRelative = u.e.Zero(), e._rotateRelative = u.e.Zero(), e._moveScene = u.e.Zero(), e._wheelXAction = Ut.MoveRelative, e._wheelXActionCoordinate = be.b.X, e._wheelYAction = Ut.MoveRelative, e._wheelYActionCoordinate = be.b.Z, e._wheelZAction = null, e._wheelZActionCoordinate = null, e;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "FreeCameraMouseWheelInput";
+ }, Object.defineProperty(t.prototype, "wheelXMoveRelative", { get: function() {
+ return this._wheelXAction !== Ut.MoveRelative ? null : this._wheelXActionCoordinate;
+ }, set: function(e) {
+ e === null && this._wheelXAction !== Ut.MoveRelative || (this._wheelXAction = Ut.MoveRelative, this._wheelXActionCoordinate = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wheelYMoveRelative", { get: function() {
+ return this._wheelYAction !== Ut.MoveRelative ? null : this._wheelYActionCoordinate;
+ }, set: function(e) {
+ e === null && this._wheelYAction !== Ut.MoveRelative || (this._wheelYAction = Ut.MoveRelative, this._wheelYActionCoordinate = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wheelZMoveRelative", { get: function() {
+ return this._wheelZAction !== Ut.MoveRelative ? null : this._wheelZActionCoordinate;
+ }, set: function(e) {
+ e === null && this._wheelZAction !== Ut.MoveRelative || (this._wheelZAction = Ut.MoveRelative, this._wheelZActionCoordinate = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wheelXRotateRelative", { get: function() {
+ return this._wheelXAction !== Ut.RotateRelative ? null : this._wheelXActionCoordinate;
+ }, set: function(e) {
+ e === null && this._wheelXAction !== Ut.RotateRelative || (this._wheelXAction = Ut.RotateRelative, this._wheelXActionCoordinate = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wheelYRotateRelative", { get: function() {
+ return this._wheelYAction !== Ut.RotateRelative ? null : this._wheelYActionCoordinate;
+ }, set: function(e) {
+ e === null && this._wheelYAction !== Ut.RotateRelative || (this._wheelYAction = Ut.RotateRelative, this._wheelYActionCoordinate = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wheelZRotateRelative", { get: function() {
+ return this._wheelZAction !== Ut.RotateRelative ? null : this._wheelZActionCoordinate;
+ }, set: function(e) {
+ e === null && this._wheelZAction !== Ut.RotateRelative || (this._wheelZAction = Ut.RotateRelative, this._wheelZActionCoordinate = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wheelXMoveScene", { get: function() {
+ return this._wheelXAction !== Ut.MoveScene ? null : this._wheelXActionCoordinate;
+ }, set: function(e) {
+ e === null && this._wheelXAction !== Ut.MoveScene || (this._wheelXAction = Ut.MoveScene, this._wheelXActionCoordinate = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wheelYMoveScene", { get: function() {
+ return this._wheelYAction !== Ut.MoveScene ? null : this._wheelYActionCoordinate;
+ }, set: function(e) {
+ e === null && this._wheelYAction !== Ut.MoveScene || (this._wheelYAction = Ut.MoveScene, this._wheelYActionCoordinate = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wheelZMoveScene", { get: function() {
+ return this._wheelZAction !== Ut.MoveScene ? null : this._wheelZActionCoordinate;
+ }, set: function(e) {
+ e === null && this._wheelZAction !== Ut.MoveScene || (this._wheelZAction = Ut.MoveScene, this._wheelZActionCoordinate = e);
+ }, enumerable: !1, configurable: !0 }), t.prototype.checkInputs = function() {
+ if (this._wheelDeltaX !== 0 || this._wheelDeltaY !== 0 || this._wheelDeltaZ != 0) {
+ this._moveRelative.setAll(0), this._rotateRelative.setAll(0), this._moveScene.setAll(0), this._updateCamera(), this.camera.getScene().useRightHandedSystem && (this._moveRelative.z *= -1);
+ var e = u.a.Zero();
+ this.camera.getViewMatrix().invertToRef(e);
+ var n = u.e.Zero();
+ u.e.TransformNormalToRef(this._moveRelative, e, n), this.camera.cameraRotation.x += this._rotateRelative.x / 200, this.camera.cameraRotation.y += this._rotateRelative.y / 200, this.camera.cameraDirection.addInPlace(n), this.camera.cameraDirection.addInPlace(this._moveScene), r.prototype.checkInputs.call(this);
+ }
+ }, t.prototype._updateCamera = function() {
+ var e = this._moveRelative, n = this._rotateRelative, i = this._moveScene, o = function(a, s, d) {
+ if (a !== 0 && s !== null && d !== null) {
+ var p = null;
+ switch (s) {
+ case Ut.MoveRelative:
+ p = e;
+ break;
+ case Ut.RotateRelative:
+ p = n;
+ break;
+ case Ut.MoveScene:
+ p = i;
+ }
+ switch (d) {
+ case be.b.X:
+ p.set(a, 0, 0);
+ break;
+ case be.b.Y:
+ p.set(0, a, 0);
+ break;
+ case be.b.Z:
+ p.set(0, 0, a);
+ }
+ }
+ };
+ o(this._wheelDeltaX, this._wheelXAction, this._wheelXActionCoordinate), o(this._wheelDeltaY, this._wheelYAction, this._wheelYActionCoordinate), o(this._wheelDeltaZ, this._wheelZAction, this._wheelZActionCoordinate);
+ }, Object(c.c)([Object(L.c)()], t.prototype, "wheelXMoveRelative", null), Object(c.c)([Object(L.c)()], t.prototype, "wheelYMoveRelative", null), Object(c.c)([Object(L.c)()], t.prototype, "wheelZMoveRelative", null), Object(c.c)([Object(L.c)()], t.prototype, "wheelXRotateRelative", null), Object(c.c)([Object(L.c)()], t.prototype, "wheelYRotateRelative", null), Object(c.c)([Object(L.c)()], t.prototype, "wheelZRotateRelative", null), Object(c.c)([Object(L.c)()], t.prototype, "wheelXMoveScene", null), Object(c.c)([Object(L.c)()], t.prototype, "wheelYMoveScene", null), Object(c.c)([Object(L.c)()], t.prototype, "wheelZMoveScene", null), t;
+ }(mf);
+ un.FreeCameraMouseWheelInput = Ha;
+ var Wa = function() {
+ function r(t) {
+ t === void 0 && (t = !1), this.allowMouse = t, this.touchAngularSensibility = 2e5, this.touchMoveSensibility = 250, this._offsetX = null, this._offsetY = null, this._pointerPressed = new Array();
+ }
+ return r.prototype.attachControl = function(t) {
+ var e = this;
+ t = Xe.b.BackCompatCameraNoPreventDefault(arguments);
+ var n = null;
+ if (this._pointerInput === void 0 && (this._onLostFocus = function() {
+ e._offsetX = null, e._offsetY = null;
+ }, this._pointerInput = function(a) {
+ var s = a.event, d = !e.camera.getEngine().hostInformation.isMobile && s instanceof MouseEvent;
+ if (e.allowMouse || s.pointerType !== "mouse" && !d) {
+ if (a.type === yt.a.POINTERDOWN) {
+ if (t || s.preventDefault(), e._pointerPressed.push(s.pointerId), e._pointerPressed.length !== 1)
+ return;
+ n = { x: s.clientX, y: s.clientY };
+ } else if (a.type === yt.a.POINTERUP) {
+ if (t || s.preventDefault(), (p = e._pointerPressed.indexOf(s.pointerId)) === -1 || (e._pointerPressed.splice(p, 1), p != 0))
+ return;
+ n = null, e._offsetX = null, e._offsetY = null;
+ } else if (a.type === yt.a.POINTERMOVE) {
+ if (t || s.preventDefault(), !n)
+ return;
+ var p;
+ if ((p = e._pointerPressed.indexOf(s.pointerId)) != 0)
+ return;
+ e._offsetX = s.clientX - n.x, e._offsetY = -(s.clientY - n.y);
+ }
+ }
+ }), this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, yt.a.POINTERDOWN | yt.a.POINTERUP | yt.a.POINTERMOVE), this._onLostFocus) {
+ var i = this.camera.getEngine(), o = i.getInputElement();
+ o && o.addEventListener("blur", this._onLostFocus);
+ }
+ }, r.prototype.detachControl = function(t) {
+ if (this._pointerInput) {
+ if (this._observer && (this.camera.getScene().onPointerObservable.remove(this._observer), this._observer = null), this._onLostFocus) {
+ var e = this.camera.getEngine().getInputElement();
+ e && e.removeEventListener("blur", this._onLostFocus), this._onLostFocus = null;
+ }
+ this._pointerPressed = [], this._offsetX = null, this._offsetY = null;
+ }
+ }, r.prototype.checkInputs = function() {
+ if (this._offsetX !== null && this._offsetY !== null && (this._offsetX !== 0 || this._offsetY !== 0)) {
+ var t = this.camera;
+ if (t.cameraRotation.y = this._offsetX / this.touchAngularSensibility, this._pointerPressed.length > 1)
+ t.cameraRotation.x = -this._offsetY / this.touchAngularSensibility;
+ else {
+ var e = t._computeLocalCameraSpeed(), n = new u.e(0, 0, e * this._offsetY / this.touchMoveSensibility);
+ u.a.RotationYawPitchRollToRef(t.rotation.y, t.rotation.x, 0, t._cameraRotationMatrix), t.cameraDirection.addInPlace(u.e.TransformCoordinates(n, t._cameraRotationMatrix));
+ }
+ }
+ }, r.prototype.getClassName = function() {
+ return "FreeCameraTouchInput";
+ }, r.prototype.getSimpleName = function() {
+ return "touch";
+ }, Object(c.c)([Object(L.c)()], r.prototype, "touchAngularSensibility", void 0), Object(c.c)([Object(L.c)()], r.prototype, "touchMoveSensibility", void 0), r;
+ }();
+ un.FreeCameraTouchInput = Wa;
+ var jr = function(r) {
+ function t(e) {
+ var n = r.call(this, e) || this;
+ return n._mouseInput = null, n._mouseWheelInput = null, n;
+ }
+ return Object(c.d)(t, r), t.prototype.addKeyboard = function() {
+ return this.add(new za()), this;
+ }, t.prototype.addMouse = function(e) {
+ return e === void 0 && (e = !0), this._mouseInput || (this._mouseInput = new ja(e), this.add(this._mouseInput)), this;
+ }, t.prototype.removeMouse = function() {
+ return this._mouseInput && this.remove(this._mouseInput), this;
+ }, t.prototype.addMouseWheel = function() {
+ return this._mouseWheelInput || (this._mouseWheelInput = new Ha(), this.add(this._mouseWheelInput)), this;
+ }, t.prototype.removeMouseWheel = function() {
+ return this._mouseWheelInput && this.remove(this._mouseWheelInput), this;
+ }, t.prototype.addTouch = function() {
+ return this.add(new Wa()), this;
+ }, t.prototype.clear = function() {
+ r.prototype.clear.call(this), this._mouseInput = null;
+ }, t;
+ }(zr);
+ jr.prototype.addDeviceOrientation = function() {
+ return this._deviceOrientationInput || (this._deviceOrientationInput = new Xa(), this.add(this._deviceOrientationInput)), this;
+ };
+ var Xa = function() {
+ function r() {
+ var t = this;
+ this._screenOrientationAngle = 0, this._screenQuaternion = new u.b(), this._alpha = 0, this._beta = 0, this._gamma = 0, this._onDeviceOrientationChangedObservable = new C.c(), this._orientationChanged = function() {
+ t._screenOrientationAngle = window.orientation !== void 0 ? +window.orientation : window.screen.orientation && window.screen.orientation.angle ? window.screen.orientation.angle : 0, t._screenOrientationAngle = -Xe.b.ToRadians(t._screenOrientationAngle / 2), t._screenQuaternion.copyFromFloats(0, Math.sin(t._screenOrientationAngle), 0, Math.cos(t._screenOrientationAngle));
+ }, this._deviceOrientation = function(e) {
+ t._alpha = e.alpha !== null ? e.alpha : 0, t._beta = e.beta !== null ? e.beta : 0, t._gamma = e.gamma !== null ? e.gamma : 0, e.alpha !== null && t._onDeviceOrientationChangedObservable.notifyObservers();
+ }, this._constantTranform = new u.b(-Math.sqrt(0.5), 0, 0, Math.sqrt(0.5)), this._orientationChanged();
+ }
+ return r.WaitForOrientationChangeAsync = function(t) {
+ return new Promise(function(e, n) {
+ var i = !1, o = function() {
+ window.removeEventListener("deviceorientation", o), i = !0, e();
+ };
+ t && setTimeout(function() {
+ i || (window.removeEventListener("deviceorientation", o), n("WaitForOrientationChangeAsync timed out"));
+ }, t), typeof DeviceOrientationEvent < "u" && typeof DeviceOrientationEvent.requestPermission == "function" ? DeviceOrientationEvent.requestPermission().then(function(a) {
+ a == "granted" ? window.addEventListener("deviceorientation", o) : Xe.b.Warn("Permission not granted.");
+ }).catch(function(a) {
+ Xe.b.Error(a);
+ }) : window.addEventListener("deviceorientation", o);
+ });
+ }, Object.defineProperty(r.prototype, "camera", { get: function() {
+ return this._camera;
+ }, set: function(t) {
+ var e = this;
+ this._camera = t, this._camera == null || this._camera.rotationQuaternion || (this._camera.rotationQuaternion = new u.b()), this._camera && this._camera.onDisposeObservable.add(function() {
+ e._onDeviceOrientationChangedObservable.clear();
+ });
+ }, enumerable: !1, configurable: !0 }), r.prototype.attachControl = function() {
+ var t = this, e = this.camera.getScene().getEngine().getHostWindow();
+ if (e) {
+ var n = function() {
+ e.addEventListener("orientationchange", t._orientationChanged), e.addEventListener("deviceorientation", t._deviceOrientation), t._orientationChanged();
+ };
+ typeof DeviceOrientationEvent < "u" && typeof DeviceOrientationEvent.requestPermission == "function" ? DeviceOrientationEvent.requestPermission().then(function(i) {
+ i === "granted" ? n() : Xe.b.Warn("Permission not granted.");
+ }).catch(function(i) {
+ Xe.b.Error(i);
+ }) : n();
+ }
+ }, r.prototype.detachControl = function(t) {
+ window.removeEventListener("orientationchange", this._orientationChanged), window.removeEventListener("deviceorientation", this._deviceOrientation), this._alpha = 0;
+ }, r.prototype.checkInputs = function() {
+ this._alpha && (u.b.RotationYawPitchRollToRef(Xe.b.ToRadians(this._alpha), Xe.b.ToRadians(this._beta), -Xe.b.ToRadians(this._gamma), this.camera.rotationQuaternion), this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion), this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform), this._camera.rotationQuaternion.z *= -1, this._camera.rotationQuaternion.w *= -1);
+ }, r.prototype.getClassName = function() {
+ return "FreeCameraDeviceOrientationInput";
+ }, r.prototype.getSimpleName = function() {
+ return "deviceOrientation";
+ }, r;
+ }();
+ un.FreeCameraDeviceOrientationInput = Xa;
+ var Ya = function() {
+ function r() {
+ this.gamepadAngularSensibility = 200, this.gamepadMoveSensibility = 40, this._yAxisScale = 1, this._cameraTransform = u.a.Identity(), this._deltaTransform = u.e.Zero(), this._vector3 = u.e.Zero(), this._vector2 = u.d.Zero();
+ }
+ return Object.defineProperty(r.prototype, "invertYAxis", { get: function() {
+ return this._yAxisScale !== 1;
+ }, set: function(t) {
+ this._yAxisScale = t ? -1 : 1;
+ }, enumerable: !1, configurable: !0 }), r.prototype.attachControl = function() {
+ var t = this, e = this.camera.getScene().gamepadManager;
+ this._onGamepadConnectedObserver = e.onGamepadConnectedObservable.add(function(n) {
+ n.type !== hn.POSE_ENABLED && (t.gamepad && n.type !== hn.XBOX || (t.gamepad = n));
+ }), this._onGamepadDisconnectedObserver = e.onGamepadDisconnectedObservable.add(function(n) {
+ t.gamepad === n && (t.gamepad = null);
+ }), this.gamepad = e.getGamepadByType(hn.XBOX), !this.gamepad && e.gamepads.length && (this.gamepad = e.gamepads[0]);
+ }, r.prototype.detachControl = function(t) {
+ this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver), this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver), this.gamepad = null;
+ }, r.prototype.checkInputs = function() {
+ if (this.gamepad && this.gamepad.leftStick) {
+ var t = this.camera, e = this.gamepad.leftStick, n = e.x / this.gamepadMoveSensibility, i = e.y / this.gamepadMoveSensibility;
+ e.x = Math.abs(n) > 5e-3 ? 0 + n : 0, e.y = Math.abs(i) > 5e-3 ? 0 + i : 0;
+ var o = this.gamepad.rightStick;
+ if (o) {
+ var a = o.x / this.gamepadAngularSensibility, s = o.y / this.gamepadAngularSensibility * this._yAxisScale;
+ o.x = Math.abs(a) > 1e-3 ? 0 + a : 0, o.y = Math.abs(s) > 1e-3 ? 0 + s : 0;
+ } else
+ o = { x: 0, y: 0 };
+ t.rotationQuaternion ? t.rotationQuaternion.toRotationMatrix(this._cameraTransform) : u.a.RotationYawPitchRollToRef(t.rotation.y, t.rotation.x, 0, this._cameraTransform);
+ var d = 50 * t._computeLocalCameraSpeed();
+ this._vector3.copyFromFloats(e.x * d, 0, -e.y * d), u.e.TransformCoordinatesToRef(this._vector3, this._cameraTransform, this._deltaTransform), t.cameraDirection.addInPlace(this._deltaTransform), this._vector2.copyFromFloats(o.y, o.x), t.cameraRotation.addInPlace(this._vector2);
+ }
+ }, r.prototype.getClassName = function() {
+ return "FreeCameraGamepadInput";
+ }, r.prototype.getSimpleName = function() {
+ return "gamepad";
+ }, Object(c.c)([Object(L.c)()], r.prototype, "gamepadAngularSensibility", void 0), Object(c.c)([Object(L.c)()], r.prototype, "gamepadMoveSensibility", void 0), r;
+ }();
+ un.FreeCameraGamepadInput = Ya;
+ var rn, rl = f(112);
+ (function(r) {
+ r[r.X = 0] = "X", r[r.Y = 1] = "Y", r[r.Z = 2] = "Z";
+ })(rn || (rn = {}));
+ var Ka = function() {
+ function r(t, e) {
+ var n = this, i = Object(c.a)(Object(c.a)({}, r._GetDefaultOptions()), e);
+ if (this._leftJoystick = !!t, r._globalJoystickIndex++, this._axisTargetedByLeftAndRight = rn.X, this._axisTargetedByUpAndDown = rn.Y, this.reverseLeftRight = !1, this.reverseUpDown = !1, this._touches = new rl.a(), this.deltaPosition = u.e.Zero(), this._joystickSensibility = 25, this._inversedSensibility = 1 / (this._joystickSensibility / 1e3), this._onResize = function(a) {
+ r.vjCanvasWidth = window.innerWidth, r.vjCanvasHeight = window.innerHeight, r.Canvas && (r.Canvas.width = r.vjCanvasWidth, r.Canvas.height = r.vjCanvasHeight), r.halfWidth = r.vjCanvasWidth / 2;
+ }, !r.Canvas) {
+ window.addEventListener("resize", this._onResize, !1), r.Canvas = document.createElement("canvas"), r.vjCanvasWidth = window.innerWidth, r.vjCanvasHeight = window.innerHeight, r.Canvas.width = window.innerWidth, r.Canvas.height = window.innerHeight, r.Canvas.style.width = "100%", r.Canvas.style.height = "100%", r.Canvas.style.position = "absolute", r.Canvas.style.backgroundColor = "transparent", r.Canvas.style.top = "0px", r.Canvas.style.left = "0px", r.Canvas.style.zIndex = "5", r.Canvas.style.msTouchAction = "none", r.Canvas.style.touchAction = "none", r.Canvas.setAttribute("touch-action", "none");
+ var o = r.Canvas.getContext("2d");
+ if (!o)
+ throw new Error("Unable to create canvas for virtual joystick");
+ r.vjCanvasContext = o, r.vjCanvasContext.strokeStyle = "#ffffff", r.vjCanvasContext.lineWidth = 2, document.body.appendChild(r.Canvas);
+ }
+ r.halfWidth = r.Canvas.width / 2, this.pressed = !1, this.limitToContainer = i.limitToContainer, this._joystickColor = i.color, this.containerSize = i.containerSize, this.puckSize = i.puckSize, i.position && this.setPosition(i.position.x, i.position.y), i.puckImage && this.setPuckImage(i.puckImage), i.containerImage && this.setContainerImage(i.containerImage), i.alwaysVisible && r._alwaysVisibleSticks++, this.alwaysVisible = i.alwaysVisible, this._joystickPointerID = -1, this._joystickPointerPos = new u.d(0, 0), this._joystickPreviousPointerPos = new u.d(0, 0), this._joystickPointerStartPos = new u.d(0, 0), this._deltaJoystickVector = new u.d(0, 0), this._onPointerDownHandlerRef = function(a) {
+ n._onPointerDown(a);
+ }, this._onPointerMoveHandlerRef = function(a) {
+ n._onPointerMove(a);
+ }, this._onPointerUpHandlerRef = function(a) {
+ n._onPointerUp(a);
+ }, r.Canvas.addEventListener("pointerdown", this._onPointerDownHandlerRef, !1), r.Canvas.addEventListener("pointermove", this._onPointerMoveHandlerRef, !1), r.Canvas.addEventListener("pointerup", this._onPointerUpHandlerRef, !1), r.Canvas.addEventListener("pointerout", this._onPointerUpHandlerRef, !1), r.Canvas.addEventListener("contextmenu", function(a) {
+ a.preventDefault();
+ }, !1), requestAnimationFrame(function() {
+ n._drawVirtualJoystick();
+ });
+ }
+ return r._GetDefaultOptions = function() {
+ return { puckSize: 40, containerSize: 60, color: "cyan", puckImage: void 0, containerImage: void 0, position: void 0, alwaysVisible: !1, limitToContainer: !1 };
+ }, r.prototype.setJoystickSensibility = function(t) {
+ this._joystickSensibility = t, this._inversedSensibility = 1 / (this._joystickSensibility / 1e3);
+ }, r.prototype._onPointerDown = function(t) {
+ t.preventDefault(), (this._leftJoystick === !0 ? t.clientX < r.halfWidth : t.clientX > r.halfWidth) && this._joystickPointerID < 0 ? (this._joystickPointerID = t.pointerId, this._joystickPosition ? (this._joystickPointerStartPos = this._joystickPosition.clone(), this._joystickPointerPos = this._joystickPosition.clone(), this._joystickPreviousPointerPos = this._joystickPosition.clone(), this._onPointerMove(t)) : (this._joystickPointerStartPos.x = t.clientX, this._joystickPointerStartPos.y = t.clientY, this._joystickPointerPos = this._joystickPointerStartPos.clone(), this._joystickPreviousPointerPos = this._joystickPointerStartPos.clone()), this._deltaJoystickVector.x = 0, this._deltaJoystickVector.y = 0, this.pressed = !0, this._touches.add(t.pointerId.toString(), t)) : r._globalJoystickIndex < 2 && this._action && (this._action(), this._touches.add(t.pointerId.toString(), { x: t.clientX, y: t.clientY, prevX: t.clientX, prevY: t.clientY }));
+ }, r.prototype._onPointerMove = function(t) {
+ if (this._joystickPointerID == t.pointerId) {
+ if (this.limitToContainer) {
+ var e = new u.d(t.clientX - this._joystickPointerStartPos.x, t.clientY - this._joystickPointerStartPos.y), n = e.length();
+ n > this.containerSize && e.scaleInPlace(this.containerSize / n), this._joystickPointerPos.x = this._joystickPointerStartPos.x + e.x, this._joystickPointerPos.y = this._joystickPointerStartPos.y + e.y;
+ } else
+ this._joystickPointerPos.x = t.clientX, this._joystickPointerPos.y = t.clientY;
+ this._deltaJoystickVector = this._joystickPointerPos.clone(), this._deltaJoystickVector = this._deltaJoystickVector.subtract(this._joystickPointerStartPos), 0 < r._alwaysVisibleSticks && (this._leftJoystick ? this._joystickPointerPos.x = Math.min(r.halfWidth, this._joystickPointerPos.x) : this._joystickPointerPos.x = Math.max(r.halfWidth, this._joystickPointerPos.x));
+ var i = (this.reverseLeftRight ? -1 : 1) * this._deltaJoystickVector.x / this._inversedSensibility;
+ switch (this._axisTargetedByLeftAndRight) {
+ case rn.X:
+ this.deltaPosition.x = Math.min(1, Math.max(-1, i));
+ break;
+ case rn.Y:
+ this.deltaPosition.y = Math.min(1, Math.max(-1, i));
+ break;
+ case rn.Z:
+ this.deltaPosition.z = Math.min(1, Math.max(-1, i));
+ }
+ var o = (this.reverseUpDown ? 1 : -1) * this._deltaJoystickVector.y / this._inversedSensibility;
+ switch (this._axisTargetedByUpAndDown) {
+ case rn.X:
+ this.deltaPosition.x = Math.min(1, Math.max(-1, o));
+ break;
+ case rn.Y:
+ this.deltaPosition.y = Math.min(1, Math.max(-1, o));
+ break;
+ case rn.Z:
+ this.deltaPosition.z = Math.min(1, Math.max(-1, o));
+ }
+ } else {
+ var a = this._touches.get(t.pointerId.toString());
+ a && (a.x = t.clientX, a.y = t.clientY);
+ }
+ }, r.prototype._onPointerUp = function(t) {
+ if (this._joystickPointerID == t.pointerId)
+ this._clearPreviousDraw(), this._joystickPointerID = -1, this.pressed = !1;
+ else {
+ var e = this._touches.get(t.pointerId.toString());
+ e && r.vjCanvasContext.clearRect(e.prevX - 44, e.prevY - 44, 88, 88);
+ }
+ this._deltaJoystickVector.x = 0, this._deltaJoystickVector.y = 0, this._touches.remove(t.pointerId.toString());
+ }, r.prototype.setJoystickColor = function(t) {
+ this._joystickColor = t;
+ }, Object.defineProperty(r.prototype, "containerSize", { get: function() {
+ return this._joystickContainerSize;
+ }, set: function(t) {
+ this._joystickContainerSize = t, this._clearContainerSize = ~~(2.1 * this._joystickContainerSize), this._clearContainerSizeOffset = ~~(this._clearContainerSize / 2);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "puckSize", { get: function() {
+ return this._joystickPuckSize;
+ }, set: function(t) {
+ this._joystickPuckSize = t, this._clearPuckSize = ~~(2.1 * this._joystickPuckSize), this._clearPuckSizeOffset = ~~(this._clearPuckSize / 2);
+ }, enumerable: !1, configurable: !0 }), r.prototype.clearPosition = function() {
+ this.alwaysVisible = !1, this._joystickPosition = null;
+ }, Object.defineProperty(r.prototype, "alwaysVisible", { get: function() {
+ return this._alwaysVisible;
+ }, set: function(t) {
+ this._alwaysVisible !== t && (t && this._joystickPosition ? (r._alwaysVisibleSticks++, this._alwaysVisible = !0) : (r._alwaysVisibleSticks--, this._alwaysVisible = !1));
+ }, enumerable: !1, configurable: !0 }), r.prototype.setPosition = function(t, e) {
+ this._joystickPointerStartPos && this._clearPreviousDraw(), this._joystickPosition = new u.d(t, e);
+ }, r.prototype.setActionOnTouch = function(t) {
+ this._action = t;
+ }, r.prototype.setAxisForLeftRight = function(t) {
+ switch (t) {
+ case rn.X:
+ case rn.Y:
+ case rn.Z:
+ this._axisTargetedByLeftAndRight = t;
+ break;
+ default:
+ this._axisTargetedByLeftAndRight = rn.X;
+ }
+ }, r.prototype.setAxisForUpDown = function(t) {
+ switch (t) {
+ case rn.X:
+ case rn.Y:
+ case rn.Z:
+ this._axisTargetedByUpAndDown = t;
+ break;
+ default:
+ this._axisTargetedByUpAndDown = rn.Y;
+ }
+ }, r.prototype._clearPreviousDraw = function() {
+ var t = this._joystickPosition || this._joystickPointerStartPos;
+ r.vjCanvasContext.clearRect(t.x - this._clearContainerSizeOffset, t.y - this._clearContainerSizeOffset, this._clearContainerSize, this._clearContainerSize), r.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x - this._clearPuckSizeOffset, this._joystickPreviousPointerPos.y - this._clearPuckSizeOffset, this._clearPuckSize, this._clearPuckSize);
+ }, r.prototype.setContainerImage = function(t) {
+ var e = this, n = new Image();
+ n.src = t, n.onload = function() {
+ return e._containerImage = n;
+ };
+ }, r.prototype.setPuckImage = function(t) {
+ var e = this, n = new Image();
+ n.src = t, n.onload = function() {
+ return e._puckImage = n;
+ };
+ }, r.prototype._drawContainer = function() {
+ var t = this._joystickPosition || this._joystickPointerStartPos;
+ this._clearPreviousDraw(), this._containerImage ? r.vjCanvasContext.drawImage(this._containerImage, t.x - this.containerSize, t.y - this.containerSize, 2 * this.containerSize, 2 * this.containerSize) : (r.vjCanvasContext.beginPath(), r.vjCanvasContext.strokeStyle = this._joystickColor, r.vjCanvasContext.lineWidth = 2, r.vjCanvasContext.arc(t.x, t.y, this.containerSize, 0, 2 * Math.PI, !0), r.vjCanvasContext.stroke(), r.vjCanvasContext.closePath(), r.vjCanvasContext.beginPath(), r.vjCanvasContext.lineWidth = 6, r.vjCanvasContext.strokeStyle = this._joystickColor, r.vjCanvasContext.arc(t.x, t.y, this.puckSize, 0, 2 * Math.PI, !0), r.vjCanvasContext.stroke(), r.vjCanvasContext.closePath());
+ }, r.prototype._drawPuck = function() {
+ this._puckImage ? r.vjCanvasContext.drawImage(this._puckImage, this._joystickPointerPos.x - this.puckSize, this._joystickPointerPos.y - this.puckSize, 2 * this.puckSize, 2 * this.puckSize) : (r.vjCanvasContext.beginPath(), r.vjCanvasContext.strokeStyle = this._joystickColor, r.vjCanvasContext.lineWidth = 2, r.vjCanvasContext.arc(this._joystickPointerPos.x, this._joystickPointerPos.y, this.puckSize, 0, 2 * Math.PI, !0), r.vjCanvasContext.stroke(), r.vjCanvasContext.closePath());
+ }, r.prototype._drawVirtualJoystick = function() {
+ var t = this;
+ this.alwaysVisible && this._drawContainer(), this.pressed && this._touches.forEach(function(e, n) {
+ n.pointerId === t._joystickPointerID ? (t.alwaysVisible || t._drawContainer(), t._drawPuck(), t._joystickPreviousPointerPos = t._joystickPointerPos.clone()) : (r.vjCanvasContext.clearRect(n.prevX - 44, n.prevY - 44, 88, 88), r.vjCanvasContext.beginPath(), r.vjCanvasContext.fillStyle = "white", r.vjCanvasContext.beginPath(), r.vjCanvasContext.strokeStyle = "red", r.vjCanvasContext.lineWidth = 6, r.vjCanvasContext.arc(n.x, n.y, 40, 0, 2 * Math.PI, !0), r.vjCanvasContext.stroke(), r.vjCanvasContext.closePath(), n.prevX = n.x, n.prevY = n.y);
+ }), requestAnimationFrame(function() {
+ t._drawVirtualJoystick();
+ });
+ }, r.prototype.releaseCanvas = function() {
+ r.Canvas && (r.Canvas.removeEventListener("pointerdown", this._onPointerDownHandlerRef), r.Canvas.removeEventListener("pointermove", this._onPointerMoveHandlerRef), r.Canvas.removeEventListener("pointerup", this._onPointerUpHandlerRef), r.Canvas.removeEventListener("pointerout", this._onPointerUpHandlerRef), window.removeEventListener("resize", this._onResize), document.body.removeChild(r.Canvas), r.Canvas = null);
+ }, r._globalJoystickIndex = 0, r._alwaysVisibleSticks = 0, r;
+ }();
+ jr.prototype.addVirtualJoystick = function() {
+ return this.add(new Qa()), this;
+ };
+ var Qa = function() {
+ function r() {
+ }
+ return r.prototype.getLeftJoystick = function() {
+ return this._leftjoystick;
+ }, r.prototype.getRightJoystick = function() {
+ return this._rightjoystick;
+ }, r.prototype.checkInputs = function() {
+ if (this._leftjoystick) {
+ var t = this.camera, e = 50 * t._computeLocalCameraSpeed(), n = u.a.RotationYawPitchRoll(t.rotation.y, t.rotation.x, 0), i = u.e.TransformCoordinates(new u.e(this._leftjoystick.deltaPosition.x * e, this._leftjoystick.deltaPosition.y * e, this._leftjoystick.deltaPosition.z * e), n);
+ t.cameraDirection = t.cameraDirection.add(i), t.cameraRotation = t.cameraRotation.addVector3(this._rightjoystick.deltaPosition), this._leftjoystick.pressed || (this._leftjoystick.deltaPosition = this._leftjoystick.deltaPosition.scale(0.9)), this._rightjoystick.pressed || (this._rightjoystick.deltaPosition = this._rightjoystick.deltaPosition.scale(0.9));
+ }
+ }, r.prototype.attachControl = function() {
+ this._leftjoystick = new Ka(!0), this._leftjoystick.setAxisForUpDown(rn.Z), this._leftjoystick.setAxisForLeftRight(rn.X), this._leftjoystick.setJoystickSensibility(0.15), this._rightjoystick = new Ka(!1), this._rightjoystick.setAxisForUpDown(rn.X), this._rightjoystick.setAxisForLeftRight(rn.Y), this._rightjoystick.reverseUpDown = !0, this._rightjoystick.setJoystickSensibility(0.05), this._rightjoystick.setJoystickColor("yellow");
+ }, r.prototype.detachControl = function(t) {
+ this._leftjoystick.releaseCanvas(), this._rightjoystick.releaseCanvas();
+ }, r.prototype.getClassName = function() {
+ return "FreeCameraVirtualJoystickInput";
+ }, r.prototype.getSimpleName = function() {
+ return "virtualJoystick";
+ }, r;
+ }();
+ un.FreeCameraVirtualJoystickInput = Qa;
+ var Vt = f(28), Pi = function(r) {
+ function t(e, n, i, o) {
+ o === void 0 && (o = !0);
+ var a = r.call(this, e, n, i, o) || this;
+ return a._tmpUpVector = u.e.Zero(), a._tmpTargetVector = u.e.Zero(), a.cameraDirection = new u.e(0, 0, 0), a.cameraRotation = new u.d(0, 0), a.ignoreParentScaling = !1, a.updateUpVectorFromRotation = !1, a._tmpQuaternion = new u.b(), a.rotation = new u.e(0, 0, 0), a.speed = 2, a.noRotationConstraint = !1, a.invertRotation = !1, a.inverseRotationSpeed = 0.2, a.lockedTarget = null, a._currentTarget = u.e.Zero(), a._initialFocalDistance = 1, a._viewMatrix = u.a.Zero(), a._camMatrix = u.a.Zero(), a._cameraTransformMatrix = u.a.Zero(), a._cameraRotationMatrix = u.a.Zero(), a._referencePoint = new u.e(0, 0, 1), a._transformedReferencePoint = u.e.Zero(), a._defaultUp = u.e.Up(), a._cachedRotationZ = 0, a._cachedQuaternionRotationZ = 0, a;
+ }
+ return Object(c.d)(t, r), t.prototype.getFrontPosition = function(e) {
+ this.getWorldMatrix();
+ var n = this.getTarget().subtract(this.position);
+ return n.normalize(), n.scaleInPlace(e), this.globalPosition.add(n);
+ }, t.prototype._getLockedTargetPosition = function() {
+ return this.lockedTarget ? (this.lockedTarget.absolutePosition && this.lockedTarget.computeWorldMatrix(), this.lockedTarget.absolutePosition || this.lockedTarget) : null;
+ }, t.prototype.storeState = function() {
+ return this._storedPosition = this.position.clone(), this._storedRotation = this.rotation.clone(), this.rotationQuaternion && (this._storedRotationQuaternion = this.rotationQuaternion.clone()), r.prototype.storeState.call(this);
+ }, t.prototype._restoreStateValues = function() {
+ return !!r.prototype._restoreStateValues.call(this) && (this.position = this._storedPosition.clone(), this.rotation = this._storedRotation.clone(), this.rotationQuaternion && (this.rotationQuaternion = this._storedRotationQuaternion.clone()), this.cameraDirection.copyFromFloats(0, 0, 0), this.cameraRotation.copyFromFloats(0, 0), !0);
+ }, t.prototype._initCache = function() {
+ r.prototype._initCache.call(this), this._cache.lockedTarget = new u.e(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), this._cache.rotation = new u.e(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), this._cache.rotationQuaternion = new u.b(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
+ }, t.prototype._updateCache = function(e) {
+ e || r.prototype._updateCache.call(this);
+ var n = this._getLockedTargetPosition();
+ n ? this._cache.lockedTarget ? this._cache.lockedTarget.copyFrom(n) : this._cache.lockedTarget = n.clone() : this._cache.lockedTarget = null, this._cache.rotation.copyFrom(this.rotation), this.rotationQuaternion && this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
+ }, t.prototype._isSynchronizedViewMatrix = function() {
+ if (!r.prototype._isSynchronizedViewMatrix.call(this))
+ return !1;
+ var e = this._getLockedTargetPosition();
+ return (this._cache.lockedTarget ? this._cache.lockedTarget.equals(e) : !e) && (this.rotationQuaternion ? this.rotationQuaternion.equals(this._cache.rotationQuaternion) : this._cache.rotation.equals(this.rotation));
+ }, t.prototype._computeLocalCameraSpeed = function() {
+ var e = this.getEngine();
+ return this.speed * Math.sqrt(e.getDeltaTime() / (100 * e.getFps()));
+ }, t.prototype.setTarget = function(e) {
+ this.upVector.normalize(), this._initialFocalDistance = e.subtract(this.position).length(), this.position.z === e.z && (this.position.z += Vt.a), this._referencePoint.normalize().scaleInPlace(this._initialFocalDistance), u.a.LookAtLHToRef(this.position, e, this._defaultUp, this._camMatrix), this._camMatrix.invert(), this.rotation.x = Math.atan(this._camMatrix.m[6] / this._camMatrix.m[10]);
+ var n = e.subtract(this.position);
+ n.x >= 0 ? this.rotation.y = -Math.atan(n.z / n.x) + Math.PI / 2 : this.rotation.y = -Math.atan(n.z / n.x) - Math.PI / 2, this.rotation.z = 0, isNaN(this.rotation.x) && (this.rotation.x = 0), isNaN(this.rotation.y) && (this.rotation.y = 0), isNaN(this.rotation.z) && (this.rotation.z = 0), this.rotationQuaternion && u.b.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
+ }, Object.defineProperty(t.prototype, "target", { get: function() {
+ return this.getTarget();
+ }, set: function(e) {
+ this.setTarget(e);
+ }, enumerable: !1, configurable: !0 }), t.prototype.getTarget = function() {
+ return this._currentTarget;
+ }, t.prototype._decideIfNeedsToMove = function() {
+ return Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
+ }, t.prototype._updatePosition = function() {
+ if (this.parent)
+ return this.parent.getWorldMatrix().invertToRef(u.c.Matrix[0]), u.e.TransformNormalToRef(this.cameraDirection, u.c.Matrix[0], u.c.Vector3[0]), void this.position.addInPlace(u.c.Vector3[0]);
+ this.position.addInPlace(this.cameraDirection);
+ }, t.prototype._checkInputs = function() {
+ var e = this.invertRotation ? -this.inverseRotationSpeed : 1, n = this._decideIfNeedsToMove(), i = Math.abs(this.cameraRotation.x) > 0 || Math.abs(this.cameraRotation.y) > 0;
+ n && this._updatePosition(), i && (this.rotationQuaternion && this.rotationQuaternion.toEulerAnglesToRef(this.rotation), this.rotation.x += this.cameraRotation.x * e, this.rotation.y += this.cameraRotation.y * e, !this.noRotationConstraint && (this.rotation.x > 1.570796 && (this.rotation.x = 1.570796), this.rotation.x < -1.570796 && (this.rotation.x = -1.570796)), this.rotationQuaternion && this.rotation.lengthSquared() && u.b.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion)), n && (Math.abs(this.cameraDirection.x) < this.speed * Vt.a && (this.cameraDirection.x = 0), Math.abs(this.cameraDirection.y) < this.speed * Vt.a && (this.cameraDirection.y = 0), Math.abs(this.cameraDirection.z) < this.speed * Vt.a && (this.cameraDirection.z = 0), this.cameraDirection.scaleInPlace(this.inertia)), i && (Math.abs(this.cameraRotation.x) < this.speed * Vt.a && (this.cameraRotation.x = 0), Math.abs(this.cameraRotation.y) < this.speed * Vt.a && (this.cameraRotation.y = 0), this.cameraRotation.scaleInPlace(this.inertia)), r.prototype._checkInputs.call(this);
+ }, t.prototype._updateCameraRotationMatrix = function() {
+ this.rotationQuaternion ? this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix) : u.a.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix);
+ }, t.prototype._rotateUpVectorWithCameraRotationMatrix = function() {
+ return u.e.TransformNormalToRef(this._defaultUp, this._cameraRotationMatrix, this.upVector), this;
+ }, t.prototype._getViewMatrix = function() {
+ return this.lockedTarget && this.setTarget(this._getLockedTargetPosition()), this._updateCameraRotationMatrix(), this.rotationQuaternion && this._cachedQuaternionRotationZ != this.rotationQuaternion.z ? (this._rotateUpVectorWithCameraRotationMatrix(), this._cachedQuaternionRotationZ = this.rotationQuaternion.z) : this._cachedRotationZ != this.rotation.z && (this._rotateUpVectorWithCameraRotationMatrix(), this._cachedRotationZ = this.rotation.z), u.e.TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint), this.position.addToRef(this._transformedReferencePoint, this._currentTarget), this.updateUpVectorFromRotation && (this.rotationQuaternion ? be.a.Y.rotateByQuaternionToRef(this.rotationQuaternion, this.upVector) : (u.b.FromEulerVectorToRef(this.rotation, this._tmpQuaternion), be.a.Y.rotateByQuaternionToRef(this._tmpQuaternion, this.upVector))), this._computeViewMatrix(this.position, this._currentTarget, this.upVector), this._viewMatrix;
+ }, t.prototype._computeViewMatrix = function(e, n, i) {
+ if (this.ignoreParentScaling) {
+ if (this.parent) {
+ var o = this.parent.getWorldMatrix();
+ u.e.TransformCoordinatesToRef(e, o, this._globalPosition), u.e.TransformCoordinatesToRef(n, o, this._tmpTargetVector), u.e.TransformNormalToRef(i, o, this._tmpUpVector), this._markSyncedWithParent();
+ } else
+ this._globalPosition.copyFrom(e), this._tmpTargetVector.copyFrom(n), this._tmpUpVector.copyFrom(i);
+ this.getScene().useRightHandedSystem ? u.a.LookAtRHToRef(this._globalPosition, this._tmpTargetVector, this._tmpUpVector, this._viewMatrix) : u.a.LookAtLHToRef(this._globalPosition, this._tmpTargetVector, this._tmpUpVector, this._viewMatrix);
+ } else
+ this.getScene().useRightHandedSystem ? u.a.LookAtRHToRef(e, n, i, this._viewMatrix) : u.a.LookAtLHToRef(e, n, i, this._viewMatrix), this.parent ? (o = this.parent.getWorldMatrix(), this._viewMatrix.invert(), this._viewMatrix.multiplyToRef(o, this._viewMatrix), this._viewMatrix.getTranslationToRef(this._globalPosition), this._viewMatrix.invert(), this._markSyncedWithParent()) : this._globalPosition.copyFrom(e);
+ }, t.prototype.createRigCamera = function(e, n) {
+ if (this.cameraRigMode !== _t.a.RIG_MODE_NONE) {
+ var i = new t(e, this.position.clone(), this.getScene());
+ return i.isRigCamera = !0, i.rigParent = this, this.cameraRigMode !== _t.a.RIG_MODE_VR && this.cameraRigMode !== _t.a.RIG_MODE_WEBVR || (this.rotationQuaternion || (this.rotationQuaternion = new u.b()), i._cameraRigParams = {}, i.rotationQuaternion = new u.b()), i;
+ }
+ return null;
+ }, t.prototype._updateRigCameras = function() {
+ var e = this._rigCameras[0], n = this._rigCameras[1];
+ switch (this.computeWorldMatrix(), this.cameraRigMode) {
+ case _t.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
+ case _t.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
+ case _t.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
+ case _t.a.RIG_MODE_STEREOSCOPIC_OVERUNDER:
+ case _t.a.RIG_MODE_STEREOSCOPIC_INTERLACED:
+ var i = this.cameraRigMode === _t.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED ? 1 : -1, o = this.cameraRigMode === _t.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED ? -1 : 1;
+ this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * i, e), this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * o, n);
+ break;
+ case _t.a.RIG_MODE_VR:
+ e.rotationQuaternion ? (e.rotationQuaternion.copyFrom(this.rotationQuaternion), n.rotationQuaternion.copyFrom(this.rotationQuaternion)) : (e.rotation.copyFrom(this.rotation), n.rotation.copyFrom(this.rotation)), e.position.copyFrom(this.position), n.position.copyFrom(this.position);
+ }
+ r.prototype._updateRigCameras.call(this);
+ }, t.prototype._getRigCamPositionAndTarget = function(e, n) {
+ this.getTarget().subtractToRef(this.position, t._TargetFocalPoint), t._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);
+ var i = t._TargetFocalPoint.addInPlace(this.position);
+ u.a.TranslationToRef(-i.x, -i.y, -i.z, t._TargetTransformMatrix), t._TargetTransformMatrix.multiplyToRef(u.a.RotationAxis(n.upVector, e), t._RigCamTransformMatrix), u.a.TranslationToRef(i.x, i.y, i.z, t._TargetTransformMatrix), t._RigCamTransformMatrix.multiplyToRef(t._TargetTransformMatrix, t._RigCamTransformMatrix), u.e.TransformCoordinatesToRef(this.position, t._RigCamTransformMatrix, n.position), n.setTarget(i);
+ }, t.prototype.getClassName = function() {
+ return "TargetCamera";
+ }, t._RigCamTransformMatrix = new u.a(), t._TargetTransformMatrix = new u.a(), t._TargetFocalPoint = new u.e(), Object(c.c)([Object(L.o)()], t.prototype, "rotation", void 0), Object(c.c)([Object(L.c)()], t.prototype, "speed", void 0), Object(c.c)([Object(L.k)("lockedTargetId")], t.prototype, "lockedTarget", void 0), t;
+ }(_t.a), zn = function(r) {
+ function t(e, n, i, o) {
+ o === void 0 && (o = !0);
+ var a = r.call(this, e, n, i, o) || this;
+ return a.ellipsoid = new u.e(0.5, 1, 0.5), a.ellipsoidOffset = new u.e(0, 0, 0), a.checkCollisions = !1, a.applyGravity = !1, a._needMoveForGravity = !1, a._oldPosition = u.e.Zero(), a._diffPosition = u.e.Zero(), a._newPosition = u.e.Zero(), a._collisionMask = -1, a._onCollisionPositionChange = function(s, d, p) {
+ p === void 0 && (p = null);
+ var y;
+ y = d, a._newPosition.copyFrom(y), a._newPosition.subtractToRef(a._oldPosition, a._diffPosition), a._diffPosition.length() > Ue.a.CollisionsEpsilon && (a.position.addInPlace(a._diffPosition), a.onCollide && p && a.onCollide(p));
+ }, a.inputs = new jr(a), a.inputs.addKeyboard().addMouse(), a;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "angularSensibility", { get: function() {
+ var e = this.inputs.attached.mouse;
+ return e ? e.angularSensibility : 0;
+ }, set: function(e) {
+ var n = this.inputs.attached.mouse;
+ n && (n.angularSensibility = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysUp", { get: function() {
+ var e = this.inputs.attached.keyboard;
+ return e ? e.keysUp : [];
+ }, set: function(e) {
+ var n = this.inputs.attached.keyboard;
+ n && (n.keysUp = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysUpward", { get: function() {
+ var e = this.inputs.attached.keyboard;
+ return e ? e.keysUpward : [];
+ }, set: function(e) {
+ var n = this.inputs.attached.keyboard;
+ n && (n.keysUpward = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysDown", { get: function() {
+ var e = this.inputs.attached.keyboard;
+ return e ? e.keysDown : [];
+ }, set: function(e) {
+ var n = this.inputs.attached.keyboard;
+ n && (n.keysDown = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysDownward", { get: function() {
+ var e = this.inputs.attached.keyboard;
+ return e ? e.keysDownward : [];
+ }, set: function(e) {
+ var n = this.inputs.attached.keyboard;
+ n && (n.keysDownward = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysLeft", { get: function() {
+ var e = this.inputs.attached.keyboard;
+ return e ? e.keysLeft : [];
+ }, set: function(e) {
+ var n = this.inputs.attached.keyboard;
+ n && (n.keysLeft = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysRight", { get: function() {
+ var e = this.inputs.attached.keyboard;
+ return e ? e.keysRight : [];
+ }, set: function(e) {
+ var n = this.inputs.attached.keyboard;
+ n && (n.keysRight = e);
+ }, enumerable: !1, configurable: !0 }), t.prototype.attachControl = function(e, n) {
+ n = Xe.b.BackCompatCameraNoPreventDefault(arguments), this.inputs.attachElement(n);
+ }, t.prototype.detachControl = function(e) {
+ this.inputs.detachElement(), this.cameraDirection = new u.e(0, 0, 0), this.cameraRotation = new u.d(0, 0);
+ }, Object.defineProperty(t.prototype, "collisionMask", { get: function() {
+ return this._collisionMask;
+ }, set: function(e) {
+ this._collisionMask = isNaN(e) ? -1 : e;
+ }, enumerable: !1, configurable: !0 }), t.prototype._collideWithWorld = function(e) {
+ (this.parent ? u.e.TransformCoordinates(this.position, this.parent.getWorldMatrix()) : this.position).subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition), this._oldPosition.addInPlace(this.ellipsoidOffset);
+ var n = this.getScene().collisionCoordinator;
+ this._collider || (this._collider = n.createCollider()), this._collider._radius = this.ellipsoid, this._collider.collisionMask = this._collisionMask;
+ var i = e;
+ this.applyGravity && (i = e.add(this.getScene().gravity)), n.getNewPosition(this._oldPosition, i, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
+ }, t.prototype._checkInputs = function() {
+ this._localDirection || (this._localDirection = u.e.Zero(), this._transformedDirection = u.e.Zero()), this.inputs.checkInputs(), r.prototype._checkInputs.call(this);
+ }, t.prototype._decideIfNeedsToMove = function() {
+ return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
+ }, t.prototype._updatePosition = function() {
+ this.checkCollisions && this.getScene().collisionsEnabled ? this._collideWithWorld(this.cameraDirection) : r.prototype._updatePosition.call(this);
+ }, t.prototype.dispose = function() {
+ this.inputs.clear(), r.prototype.dispose.call(this);
+ }, t.prototype.getClassName = function() {
+ return "FreeCamera";
+ }, Object(c.c)([Object(L.o)()], t.prototype, "ellipsoid", void 0), Object(c.c)([Object(L.o)()], t.prototype, "ellipsoidOffset", void 0), Object(c.c)([Object(L.c)()], t.prototype, "checkCollisions", void 0), Object(c.c)([Object(L.c)()], t.prototype, "applyGravity", void 0), t;
+ }(Pi);
+ Q.a.AddNodeConstructor("TouchCamera", function(r, t) {
+ return function() {
+ return new qa(r, u.e.Zero(), t);
+ };
+ });
+ var qa = function(r) {
+ function t(e, n, i) {
+ var o = r.call(this, e, n, i) || this;
+ return o.inputs.addTouch(), o._setupInputs(), o;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "touchAngularSensibility", { get: function() {
+ var e = this.inputs.attached.touch;
+ return e ? e.touchAngularSensibility : 0;
+ }, set: function(e) {
+ var n = this.inputs.attached.touch;
+ n && (n.touchAngularSensibility = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "touchMoveSensibility", { get: function() {
+ var e = this.inputs.attached.touch;
+ return e ? e.touchMoveSensibility : 0;
+ }, set: function(e) {
+ var n = this.inputs.attached.touch;
+ n && (n.touchMoveSensibility = e);
+ }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
+ return "TouchCamera";
+ }, t.prototype._setupInputs = function() {
+ var e = this.inputs.attached.touch, n = this.inputs.attached.mouse;
+ n ? n.touchEnabled = !1 : e.allowMouse = !0;
+ }, t;
+ }(zn);
+ Q.a.AddNodeConstructor("ArcRotateCamera", function(r, t) {
+ return function() {
+ return new ji(r, 0, 0, 1, u.e.Zero(), t);
+ };
+ });
+ var ji = function(r) {
+ function t(e, n, i, o, a, s, d) {
+ d === void 0 && (d = !0);
+ var p = r.call(this, e, u.e.Zero(), s, d) || this;
+ return p.inertialAlphaOffset = 0, p.inertialBetaOffset = 0, p.inertialRadiusOffset = 0, p.lowerAlphaLimit = null, p.upperAlphaLimit = null, p.lowerBetaLimit = 0.01, p.upperBetaLimit = Math.PI - 0.01, p.lowerRadiusLimit = null, p.upperRadiusLimit = null, p.inertialPanningX = 0, p.inertialPanningY = 0, p.pinchToPanMaxDistance = 20, p.panningDistanceLimit = null, p.panningOriginTarget = u.e.Zero(), p.panningInertia = 0.9, p.zoomOnFactor = 1, p.targetScreenOffset = u.d.Zero(), p.allowUpsideDown = !0, p.useInputToRestoreState = !0, p._viewMatrix = new u.a(), p.panningAxis = new u.e(1, 1, 0), p.onMeshTargetChangedObservable = new C.c(), p.checkCollisions = !1, p.collisionRadius = new u.e(0.5, 0.5, 0.5), p._previousPosition = u.e.Zero(), p._collisionVelocity = u.e.Zero(), p._newPosition = u.e.Zero(), p._computationVector = u.e.Zero(), p._onCollisionPositionChange = function(y, P, R) {
+ R === void 0 && (R = null), R ? (p.setPosition(P), p.onCollide && p.onCollide(R)) : p._previousPosition.copyFrom(p._position);
+ var B = Math.cos(p.alpha), F = Math.sin(p.alpha), z = Math.cos(p.beta), J = Math.sin(p.beta);
+ J === 0 && (J = 1e-4);
+ var ie = p._getTargetPosition();
+ p._computationVector.copyFromFloats(p.radius * B * J, p.radius * z, p.radius * F * J), ie.addToRef(p._computationVector, p._newPosition), p._position.copyFrom(p._newPosition);
+ var se = p.upVector;
+ p.allowUpsideDown && p.beta < 0 && (se = (se = se.clone()).negate()), p._computeViewMatrix(p._position, ie, se), p._viewMatrix.addAtIndex(12, p.targetScreenOffset.x), p._viewMatrix.addAtIndex(13, p.targetScreenOffset.y), p._collisionTriggered = !1;
+ }, p._target = u.e.Zero(), a && p.setTarget(a), p.alpha = n, p.beta = i, p.radius = o, p.getViewMatrix(), p.inputs = new Po(p), p.inputs.addKeyboard().addMouseWheel().addPointers(), p;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "target", { get: function() {
+ return this._target;
+ }, set: function(e) {
+ this.setTarget(e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "position", { get: function() {
+ return this._position;
+ }, set: function(e) {
+ this.setPosition(e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "upVector", { get: function() {
+ return this._upVector;
+ }, set: function(e) {
+ this._upToYMatrix || (this._YToUpMatrix = new u.a(), this._upToYMatrix = new u.a(), this._upVector = u.e.Zero()), e.normalize(), this._upVector.copyFrom(e), this.setMatUp();
+ }, enumerable: !1, configurable: !0 }), t.prototype.setMatUp = function() {
+ u.a.RotationAlignToRef(u.e.UpReadOnly, this._upVector, this._YToUpMatrix), u.a.RotationAlignToRef(this._upVector, u.e.UpReadOnly, this._upToYMatrix);
+ }, Object.defineProperty(t.prototype, "angularSensibilityX", { get: function() {
+ var e = this.inputs.attached.pointers;
+ return e ? e.angularSensibilityX : 0;
+ }, set: function(e) {
+ var n = this.inputs.attached.pointers;
+ n && (n.angularSensibilityX = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "angularSensibilityY", { get: function() {
+ var e = this.inputs.attached.pointers;
+ return e ? e.angularSensibilityY : 0;
+ }, set: function(e) {
+ var n = this.inputs.attached.pointers;
+ n && (n.angularSensibilityY = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "pinchPrecision", { get: function() {
+ var e = this.inputs.attached.pointers;
+ return e ? e.pinchPrecision : 0;
+ }, set: function(e) {
+ var n = this.inputs.attached.pointers;
+ n && (n.pinchPrecision = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "pinchDeltaPercentage", { get: function() {
+ var e = this.inputs.attached.pointers;
+ return e ? e.pinchDeltaPercentage : 0;
+ }, set: function(e) {
+ var n = this.inputs.attached.pointers;
+ n && (n.pinchDeltaPercentage = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "useNaturalPinchZoom", { get: function() {
+ var e = this.inputs.attached.pointers;
+ return !!e && e.useNaturalPinchZoom;
+ }, set: function(e) {
+ var n = this.inputs.attached.pointers;
+ n && (n.useNaturalPinchZoom = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "panningSensibility", { get: function() {
+ var e = this.inputs.attached.pointers;
+ return e ? e.panningSensibility : 0;
+ }, set: function(e) {
+ var n = this.inputs.attached.pointers;
+ n && (n.panningSensibility = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysUp", { get: function() {
+ var e = this.inputs.attached.keyboard;
+ return e ? e.keysUp : [];
+ }, set: function(e) {
+ var n = this.inputs.attached.keyboard;
+ n && (n.keysUp = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysDown", { get: function() {
+ var e = this.inputs.attached.keyboard;
+ return e ? e.keysDown : [];
+ }, set: function(e) {
+ var n = this.inputs.attached.keyboard;
+ n && (n.keysDown = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysLeft", { get: function() {
+ var e = this.inputs.attached.keyboard;
+ return e ? e.keysLeft : [];
+ }, set: function(e) {
+ var n = this.inputs.attached.keyboard;
+ n && (n.keysLeft = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysRight", { get: function() {
+ var e = this.inputs.attached.keyboard;
+ return e ? e.keysRight : [];
+ }, set: function(e) {
+ var n = this.inputs.attached.keyboard;
+ n && (n.keysRight = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wheelPrecision", { get: function() {
+ var e = this.inputs.attached.mousewheel;
+ return e ? e.wheelPrecision : 0;
+ }, set: function(e) {
+ var n = this.inputs.attached.mousewheel;
+ n && (n.wheelPrecision = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wheelDeltaPercentage", { get: function() {
+ var e = this.inputs.attached.mousewheel;
+ return e ? e.wheelDeltaPercentage : 0;
+ }, set: function(e) {
+ var n = this.inputs.attached.mousewheel;
+ n && (n.wheelDeltaPercentage = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "bouncingBehavior", { get: function() {
+ return this._bouncingBehavior;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "useBouncingBehavior", { get: function() {
+ return this._bouncingBehavior != null;
+ }, set: function(e) {
+ e !== this.useBouncingBehavior && (e ? (this._bouncingBehavior = new qc(), this.addBehavior(this._bouncingBehavior)) : this._bouncingBehavior && (this.removeBehavior(this._bouncingBehavior), this._bouncingBehavior = null));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "framingBehavior", { get: function() {
+ return this._framingBehavior;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "useFramingBehavior", { get: function() {
+ return this._framingBehavior != null;
+ }, set: function(e) {
+ e !== this.useFramingBehavior && (e ? (this._framingBehavior = new Zc(), this.addBehavior(this._framingBehavior)) : this._framingBehavior && (this.removeBehavior(this._framingBehavior), this._framingBehavior = null));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "autoRotationBehavior", { get: function() {
+ return this._autoRotationBehavior;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "useAutoRotationBehavior", { get: function() {
+ return this._autoRotationBehavior != null;
+ }, set: function(e) {
+ e !== this.useAutoRotationBehavior && (e ? (this._autoRotationBehavior = new Qc(), this.addBehavior(this._autoRotationBehavior)) : this._autoRotationBehavior && (this.removeBehavior(this._autoRotationBehavior), this._autoRotationBehavior = null));
+ }, enumerable: !1, configurable: !0 }), t.prototype._initCache = function() {
+ r.prototype._initCache.call(this), this._cache._target = new u.e(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), this._cache.alpha = void 0, this._cache.beta = void 0, this._cache.radius = void 0, this._cache.targetScreenOffset = u.d.Zero();
+ }, t.prototype._updateCache = function(e) {
+ e || r.prototype._updateCache.call(this), this._cache._target.copyFrom(this._getTargetPosition()), this._cache.alpha = this.alpha, this._cache.beta = this.beta, this._cache.radius = this.radius, this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset);
+ }, t.prototype._getTargetPosition = function() {
+ if (this._targetHost && this._targetHost.getAbsolutePosition) {
+ var e = this._targetHost.absolutePosition;
+ this._targetBoundingCenter ? e.addToRef(this._targetBoundingCenter, this._target) : this._target.copyFrom(e);
+ }
+ var n = this._getLockedTargetPosition();
+ return n || this._target;
+ }, t.prototype.storeState = function() {
+ return this._storedAlpha = this.alpha, this._storedBeta = this.beta, this._storedRadius = this.radius, this._storedTarget = this._getTargetPosition().clone(), this._storedTargetScreenOffset = this.targetScreenOffset.clone(), r.prototype.storeState.call(this);
+ }, t.prototype._restoreStateValues = function() {
+ return !!r.prototype._restoreStateValues.call(this) && (this.setTarget(this._storedTarget.clone()), this.alpha = this._storedAlpha, this.beta = this._storedBeta, this.radius = this._storedRadius, this.targetScreenOffset = this._storedTargetScreenOffset.clone(), this.inertialAlphaOffset = 0, this.inertialBetaOffset = 0, this.inertialRadiusOffset = 0, this.inertialPanningX = 0, this.inertialPanningY = 0, !0);
+ }, t.prototype._isSynchronizedViewMatrix = function() {
+ return !!r.prototype._isSynchronizedViewMatrix.call(this) && this._cache._target.equals(this._getTargetPosition()) && this._cache.alpha === this.alpha && this._cache.beta === this.beta && this._cache.radius === this.radius && this._cache.targetScreenOffset.equals(this.targetScreenOffset);
+ }, t.prototype.attachControl = function(e, n, i, o) {
+ var a = this;
+ i === void 0 && (i = !0), o === void 0 && (o = 2), n = Xe.b.BackCompatCameraNoPreventDefault(arguments), this._useCtrlForPanning = i, this._panningMouseButton = o, typeof arguments[0] == "boolean" && (arguments.length > 1 && (this._useCtrlForPanning = arguments[1]), arguments.length > 2 && (this._panningMouseButton = arguments[2])), this.inputs.attachElement(n), this._reset = function() {
+ a.inertialAlphaOffset = 0, a.inertialBetaOffset = 0, a.inertialRadiusOffset = 0, a.inertialPanningX = 0, a.inertialPanningY = 0;
+ };
+ }, t.prototype.detachControl = function(e) {
+ this.inputs.detachElement(), this._reset && this._reset();
+ }, t.prototype._checkInputs = function() {
+ if (!this._collisionTriggered) {
+ if (this.inputs.checkInputs(), this.inertialAlphaOffset !== 0 || this.inertialBetaOffset !== 0 || this.inertialRadiusOffset !== 0) {
+ var e = this.inertialAlphaOffset;
+ this.beta <= 0 && (e *= -1), this.getScene().useRightHandedSystem && (e *= -1), this.parent && this.parent._getWorldMatrixDeterminant() < 0 && (e *= -1), this.alpha += e, this.beta += this.inertialBetaOffset, this.radius -= this.inertialRadiusOffset, this.inertialAlphaOffset *= this.inertia, this.inertialBetaOffset *= this.inertia, this.inertialRadiusOffset *= this.inertia, Math.abs(this.inertialAlphaOffset) < Vt.a && (this.inertialAlphaOffset = 0), Math.abs(this.inertialBetaOffset) < Vt.a && (this.inertialBetaOffset = 0), Math.abs(this.inertialRadiusOffset) < this.speed * Vt.a && (this.inertialRadiusOffset = 0);
+ }
+ (this.inertialPanningX !== 0 || this.inertialPanningY !== 0) && (this._localDirection || (this._localDirection = u.e.Zero(), this._transformedDirection = u.e.Zero()), this._localDirection.copyFromFloats(this.inertialPanningX, this.inertialPanningY, this.inertialPanningY), this._localDirection.multiplyInPlace(this.panningAxis), this._viewMatrix.invertToRef(this._cameraTransformMatrix), u.e.TransformNormalToRef(this._localDirection, this._cameraTransformMatrix, this._transformedDirection), this.panningAxis.y || (this._transformedDirection.y = 0), !this._targetHost && (this.panningDistanceLimit ? (this._transformedDirection.addInPlace(this._target), u.e.DistanceSquared(this._transformedDirection, this.panningOriginTarget) <= this.panningDistanceLimit * this.panningDistanceLimit && this._target.copyFrom(this._transformedDirection)) : this._target.addInPlace(this._transformedDirection)), this.inertialPanningX *= this.panningInertia, this.inertialPanningY *= this.panningInertia, Math.abs(this.inertialPanningX) < this.speed * Vt.a && (this.inertialPanningX = 0), Math.abs(this.inertialPanningY) < this.speed * Vt.a && (this.inertialPanningY = 0)), this._checkLimits(), r.prototype._checkInputs.call(this);
+ }
+ }, t.prototype._checkLimits = function() {
+ this.lowerBetaLimit === null || this.lowerBetaLimit === void 0 ? this.allowUpsideDown && this.beta > Math.PI && (this.beta = this.beta - 2 * Math.PI) : this.beta < this.lowerBetaLimit && (this.beta = this.lowerBetaLimit), this.upperBetaLimit === null || this.upperBetaLimit === void 0 ? this.allowUpsideDown && this.beta < -Math.PI && (this.beta = this.beta + 2 * Math.PI) : this.beta > this.upperBetaLimit && (this.beta = this.upperBetaLimit), this.lowerAlphaLimit !== null && this.alpha < this.lowerAlphaLimit && (this.alpha = this.lowerAlphaLimit), this.upperAlphaLimit !== null && this.alpha > this.upperAlphaLimit && (this.alpha = this.upperAlphaLimit), this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit && (this.radius = this.lowerRadiusLimit, this.inertialRadiusOffset = 0), this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit && (this.radius = this.upperRadiusLimit, this.inertialRadiusOffset = 0);
+ }, t.prototype.rebuildAnglesAndRadius = function() {
+ this._position.subtractToRef(this._getTargetPosition(), this._computationVector), this._upVector.x === 0 && this._upVector.y === 1 && this._upVector.z === 0 || u.e.TransformCoordinatesToRef(this._computationVector, this._upToYMatrix, this._computationVector), this.radius = this._computationVector.length(), this.radius === 0 && (this.radius = 1e-4);
+ var e = this.alpha;
+ this._computationVector.x === 0 && this._computationVector.z === 0 ? this.alpha = Math.PI / 2 : this.alpha = Math.acos(this._computationVector.x / Math.sqrt(Math.pow(this._computationVector.x, 2) + Math.pow(this._computationVector.z, 2))), this._computationVector.z < 0 && (this.alpha = 2 * Math.PI - this.alpha);
+ var n = Math.round((e - this.alpha) / (2 * Math.PI));
+ this.alpha += 2 * n * Math.PI, this.beta = Math.acos(this._computationVector.y / this.radius), this._checkLimits();
+ }, t.prototype.setPosition = function(e) {
+ this._position.equals(e) || (this._position.copyFrom(e), this.rebuildAnglesAndRadius());
+ }, t.prototype.setTarget = function(e, n, i) {
+ if (n === void 0 && (n = !1), i === void 0 && (i = !1), e.getBoundingInfo)
+ this._targetBoundingCenter = n ? e.getBoundingInfo().boundingBox.centerWorld.clone() : null, e.computeWorldMatrix(), this._targetHost = e, this._target = this._getTargetPosition(), this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);
+ else {
+ var o = e, a = this._getTargetPosition();
+ if (a && !i && a.equals(o))
+ return;
+ this._targetHost = null, this._target = o, this._targetBoundingCenter = null, this.onMeshTargetChangedObservable.notifyObservers(null);
+ }
+ this.rebuildAnglesAndRadius();
+ }, t.prototype._getViewMatrix = function() {
+ var e = Math.cos(this.alpha), n = Math.sin(this.alpha), i = Math.cos(this.beta), o = Math.sin(this.beta);
+ o === 0 && (o = 1e-4), this.radius === 0 && (this.radius = 1e-4);
+ var a = this._getTargetPosition();
+ if (this._computationVector.copyFromFloats(this.radius * e * o, this.radius * i, this.radius * n * o), this._upVector.x === 0 && this._upVector.y === 1 && this._upVector.z === 0 || u.e.TransformCoordinatesToRef(this._computationVector, this._YToUpMatrix, this._computationVector), a.addToRef(this._computationVector, this._newPosition), this.getScene().collisionsEnabled && this.checkCollisions) {
+ var s = this.getScene().collisionCoordinator;
+ this._collider || (this._collider = s.createCollider()), this._collider._radius = this.collisionRadius, this._newPosition.subtractToRef(this._position, this._collisionVelocity), this._collisionTriggered = !0, s.getNewPosition(this._position, this._collisionVelocity, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
+ } else {
+ this._position.copyFrom(this._newPosition);
+ var d = this.upVector;
+ this.allowUpsideDown && o < 0 && (d = d.negate()), this._computeViewMatrix(this._position, a, d), this._viewMatrix.addAtIndex(12, this.targetScreenOffset.x), this._viewMatrix.addAtIndex(13, this.targetScreenOffset.y);
+ }
+ return this._currentTarget = a, this._viewMatrix;
+ }, t.prototype.zoomOn = function(e, n) {
+ n === void 0 && (n = !1), e = e || this.getScene().meshes;
+ var i = Ie.a.MinMax(e), o = u.e.Distance(i.min, i.max);
+ this.radius = o * this.zoomOnFactor, this.focusOn({ min: i.min, max: i.max, distance: o }, n);
+ }, t.prototype.focusOn = function(e, n) {
+ var i, o;
+ if (n === void 0 && (n = !1), e.min === void 0) {
+ var a = e || this.getScene().meshes;
+ i = Ie.a.MinMax(a), o = u.e.Distance(i.min, i.max);
+ } else
+ i = e, o = e.distance;
+ this._target = Ie.a.Center(i), n || (this.maxZ = 2 * o);
+ }, t.prototype.createRigCamera = function(e, n) {
+ var i = 0;
+ switch (this.cameraRigMode) {
+ case _t.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
+ case _t.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
+ case _t.a.RIG_MODE_STEREOSCOPIC_OVERUNDER:
+ case _t.a.RIG_MODE_STEREOSCOPIC_INTERLACED:
+ case _t.a.RIG_MODE_VR:
+ i = this._cameraRigParams.stereoHalfAngle * (n === 0 ? 1 : -1);
+ break;
+ case _t.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
+ i = this._cameraRigParams.stereoHalfAngle * (n === 0 ? -1 : 1);
+ }
+ var o = new t(e, this.alpha + i, this.beta, this.radius, this._target, this.getScene());
+ return o._cameraRigParams = {}, o.isRigCamera = !0, o.rigParent = this, o.upVector = this.upVector, o;
+ }, t.prototype._updateRigCameras = function() {
+ var e = this._rigCameras[0], n = this._rigCameras[1];
+ switch (e.beta = n.beta = this.beta, this.cameraRigMode) {
+ case _t.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
+ case _t.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
+ case _t.a.RIG_MODE_STEREOSCOPIC_OVERUNDER:
+ case _t.a.RIG_MODE_STEREOSCOPIC_INTERLACED:
+ case _t.a.RIG_MODE_VR:
+ e.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle, n.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
+ break;
+ case _t.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
+ e.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle, n.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
+ }
+ r.prototype._updateRigCameras.call(this);
+ }, t.prototype.dispose = function() {
+ this.inputs.clear(), r.prototype.dispose.call(this);
+ }, t.prototype.getClassName = function() {
+ return "ArcRotateCamera";
+ }, Object(c.c)([Object(L.c)()], t.prototype, "alpha", void 0), Object(c.c)([Object(L.c)()], t.prototype, "beta", void 0), Object(c.c)([Object(L.c)()], t.prototype, "radius", void 0), Object(c.c)([Object(L.o)("target")], t.prototype, "_target", void 0), Object(c.c)([Object(L.c)()], t.prototype, "inertialAlphaOffset", void 0), Object(c.c)([Object(L.c)()], t.prototype, "inertialBetaOffset", void 0), Object(c.c)([Object(L.c)()], t.prototype, "inertialRadiusOffset", void 0), Object(c.c)([Object(L.c)()], t.prototype, "lowerAlphaLimit", void 0), Object(c.c)([Object(L.c)()], t.prototype, "upperAlphaLimit", void 0), Object(c.c)([Object(L.c)()], t.prototype, "lowerBetaLimit", void 0), Object(c.c)([Object(L.c)()], t.prototype, "upperBetaLimit", void 0), Object(c.c)([Object(L.c)()], t.prototype, "lowerRadiusLimit", void 0), Object(c.c)([Object(L.c)()], t.prototype, "upperRadiusLimit", void 0), Object(c.c)([Object(L.c)()], t.prototype, "inertialPanningX", void 0), Object(c.c)([Object(L.c)()], t.prototype, "inertialPanningY", void 0), Object(c.c)([Object(L.c)()], t.prototype, "pinchToPanMaxDistance", void 0), Object(c.c)([Object(L.c)()], t.prototype, "panningDistanceLimit", void 0), Object(c.c)([Object(L.o)()], t.prototype, "panningOriginTarget", void 0), Object(c.c)([Object(L.c)()], t.prototype, "panningInertia", void 0), Object(c.c)([Object(L.c)()], t.prototype, "zoomOnFactor", void 0), Object(c.c)([Object(L.c)()], t.prototype, "targetScreenOffset", void 0), Object(c.c)([Object(L.c)()], t.prototype, "allowUpsideDown", void 0), Object(c.c)([Object(L.c)()], t.prototype, "useInputToRestoreState", void 0), t;
+ }(Pi);
+ Q.a.AddNodeConstructor("DeviceOrientationCamera", function(r, t) {
+ return function() {
+ return new xo(r, u.e.Zero(), t);
+ };
+ });
+ var xo = function(r) {
+ function t(e, n, i) {
+ var o = r.call(this, e, n, i) || this;
+ return o._tmpDragQuaternion = new u.b(), o._disablePointerInputWhenUsingDeviceOrientation = !0, o._dragFactor = 0, o._quaternionCache = new u.b(), o.inputs.addDeviceOrientation(), o.inputs._deviceOrientationInput && o.inputs._deviceOrientationInput._onDeviceOrientationChangedObservable.addOnce(function() {
+ o._disablePointerInputWhenUsingDeviceOrientation && o.inputs._mouseInput && (o.inputs._mouseInput._allowCameraRotation = !1, o.inputs._mouseInput.onPointerMovedObservable.add(function(a) {
+ o._dragFactor != 0 && (o._initialQuaternion || (o._initialQuaternion = new u.b()), u.b.FromEulerAnglesToRef(0, a.offsetX * o._dragFactor, 0, o._tmpDragQuaternion), o._initialQuaternion.multiplyToRef(o._tmpDragQuaternion, o._initialQuaternion));
+ }));
+ }), o;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "disablePointerInputWhenUsingDeviceOrientation", { get: function() {
+ return this._disablePointerInputWhenUsingDeviceOrientation;
+ }, set: function(e) {
+ this._disablePointerInputWhenUsingDeviceOrientation = e;
+ }, enumerable: !1, configurable: !0 }), t.prototype.enableHorizontalDragging = function(e) {
+ e === void 0 && (e = 1 / 300), this._dragFactor = e;
+ }, t.prototype.getClassName = function() {
+ return "DeviceOrientationCamera";
+ }, t.prototype._checkInputs = function() {
+ r.prototype._checkInputs.call(this), this._quaternionCache.copyFrom(this.rotationQuaternion), this._initialQuaternion && this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
+ }, t.prototype.resetToCurrentRotation = function(e) {
+ var n = this;
+ e === void 0 && (e = be.a.Y), this.rotationQuaternion && (this._initialQuaternion || (this._initialQuaternion = new u.b()), this._initialQuaternion.copyFrom(this._quaternionCache || this.rotationQuaternion), ["x", "y", "z"].forEach(function(i) {
+ e[i] ? n._initialQuaternion[i] *= -1 : n._initialQuaternion[i] = 0;
+ }), this._initialQuaternion.normalize(), this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion));
+ }, t;
+ }(zn), ol = function(r) {
+ function t(e) {
+ return r.call(this, e) || this;
+ }
+ return Object(c.d)(t, r), t.prototype.addKeyboard = function() {
+ return this.add(new Ba()), this;
+ }, t.prototype.addMouse = function(e) {
+ return e === void 0 && (e = !0), this.add(new Ua(e)), this;
+ }, t;
+ }(zr), gf = function(r) {
+ function t(e, n, i, o) {
+ o === void 0 && (o = !0);
+ var a = r.call(this, e, n, i, o) || this;
+ return a.ellipsoid = new u.e(1, 1, 1), a.ellipsoidOffset = new u.e(0, 0, 0), a.checkCollisions = !1, a.applyGravity = !1, a.cameraDirection = u.e.Zero(), a._trackRoll = 0, a.rollCorrect = 100, a.bankedTurn = !1, a.bankedTurnLimit = Math.PI / 2, a.bankedTurnMultiplier = 1, a._needMoveForGravity = !1, a._oldPosition = u.e.Zero(), a._diffPosition = u.e.Zero(), a._newPosition = u.e.Zero(), a._collisionMask = -1, a._onCollisionPositionChange = function(s, d, p) {
+ p === void 0 && (p = null);
+ var y;
+ y = d, a._newPosition.copyFrom(y), a._newPosition.subtractToRef(a._oldPosition, a._diffPosition), a._diffPosition.length() > Ue.a.CollisionsEpsilon && (a.position.addInPlace(a._diffPosition), a.onCollide && p && a.onCollide(p));
+ }, a.inputs = new ol(a), a.inputs.addKeyboard().addMouse(), a;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "angularSensibility", { get: function() {
+ var e = this.inputs.attached.mouse;
+ return e ? e.angularSensibility : 0;
+ }, set: function(e) {
+ var n = this.inputs.attached.mouse;
+ n && (n.angularSensibility = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysForward", { get: function() {
+ var e = this.inputs.attached.keyboard;
+ return e ? e.keysForward : [];
+ }, set: function(e) {
+ var n = this.inputs.attached.keyboard;
+ n && (n.keysForward = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysBackward", { get: function() {
+ var e = this.inputs.attached.keyboard;
+ return e ? e.keysBackward : [];
+ }, set: function(e) {
+ var n = this.inputs.attached.keyboard;
+ n && (n.keysBackward = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysUp", { get: function() {
+ var e = this.inputs.attached.keyboard;
+ return e ? e.keysUp : [];
+ }, set: function(e) {
+ var n = this.inputs.attached.keyboard;
+ n && (n.keysUp = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysDown", { get: function() {
+ var e = this.inputs.attached.keyboard;
+ return e ? e.keysDown : [];
+ }, set: function(e) {
+ var n = this.inputs.attached.keyboard;
+ n && (n.keysDown = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysLeft", { get: function() {
+ var e = this.inputs.attached.keyboard;
+ return e ? e.keysLeft : [];
+ }, set: function(e) {
+ var n = this.inputs.attached.keyboard;
+ n && (n.keysLeft = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "keysRight", { get: function() {
+ var e = this.inputs.attached.keyboard;
+ return e ? e.keysRight : [];
+ }, set: function(e) {
+ var n = this.inputs.attached.keyboard;
+ n && (n.keysRight = e);
+ }, enumerable: !1, configurable: !0 }), t.prototype.attachControl = function(e, n) {
+ n = Xe.b.BackCompatCameraNoPreventDefault(arguments), this.inputs.attachElement(n);
+ }, t.prototype.detachControl = function() {
+ this.inputs.detachElement(), this.cameraDirection = new u.e(0, 0, 0);
+ }, Object.defineProperty(t.prototype, "collisionMask", { get: function() {
+ return this._collisionMask;
+ }, set: function(e) {
+ this._collisionMask = isNaN(e) ? -1 : e;
+ }, enumerable: !1, configurable: !0 }), t.prototype._collideWithWorld = function(e) {
+ (this.parent ? u.e.TransformCoordinates(this.position, this.parent.getWorldMatrix()) : this.position).subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition), this._oldPosition.addInPlace(this.ellipsoidOffset);
+ var n = this.getScene().collisionCoordinator;
+ this._collider || (this._collider = n.createCollider()), this._collider._radius = this.ellipsoid, this._collider.collisionMask = this._collisionMask;
+ var i = e;
+ this.applyGravity && (i = e.add(this.getScene().gravity)), n.getNewPosition(this._oldPosition, i, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
+ }, t.prototype._checkInputs = function() {
+ this._localDirection || (this._localDirection = u.e.Zero(), this._transformedDirection = u.e.Zero()), this.inputs.checkInputs(), r.prototype._checkInputs.call(this);
+ }, t.prototype._decideIfNeedsToMove = function() {
+ return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
+ }, t.prototype._updatePosition = function() {
+ this.checkCollisions && this.getScene().collisionsEnabled ? this._collideWithWorld(this.cameraDirection) : r.prototype._updatePosition.call(this);
+ }, t.prototype.restoreRoll = function(e) {
+ var n = this._trackRoll, i = n - this.rotation.z;
+ Math.abs(i) >= 1e-3 && (this.rotation.z += i / e, Math.abs(n - this.rotation.z) <= 1e-3 && (this.rotation.z = n));
+ }, t.prototype.dispose = function() {
+ this.inputs.clear(), r.prototype.dispose.call(this);
+ }, t.prototype.getClassName = function() {
+ return "FlyCamera";
+ }, Object(c.c)([Object(L.o)()], t.prototype, "ellipsoid", void 0), Object(c.c)([Object(L.o)()], t.prototype, "ellipsoidOffset", void 0), Object(c.c)([Object(L.c)()], t.prototype, "checkCollisions", void 0), Object(c.c)([Object(L.c)()], t.prototype, "applyGravity", void 0), t;
+ }(Pi), al = function(r) {
+ function t(e) {
+ return r.call(this, e) || this;
+ }
+ return Object(c.d)(t, r), t.prototype.addKeyboard = function() {
+ return this.add(new Va()), this;
+ }, t.prototype.addMouseWheel = function() {
+ return this.add(new ka()), this;
+ }, t.prototype.addPointers = function() {
+ return this.add(new Ga()), this;
+ }, t.prototype.addVRDeviceOrientation = function() {
+ return console.warn("DeviceOrientation support not yet implemented for FollowCamera."), this;
+ }, t;
+ }(zr);
+ Q.a.AddNodeConstructor("FollowCamera", function(r, t) {
+ return function() {
+ return new sl(r, u.e.Zero(), t);
+ };
+ }), Q.a.AddNodeConstructor("ArcFollowCamera", function(r, t) {
+ return function() {
+ return new cl(r, 0, 0, 1, null, t);
+ };
+ });
+ var Jn, sl = function(r) {
+ function t(e, n, i, o) {
+ o === void 0 && (o = null);
+ var a = r.call(this, e, n, i) || this;
+ return a.radius = 12, a.lowerRadiusLimit = null, a.upperRadiusLimit = null, a.rotationOffset = 0, a.lowerRotationOffsetLimit = null, a.upperRotationOffsetLimit = null, a.heightOffset = 4, a.lowerHeightOffsetLimit = null, a.upperHeightOffsetLimit = null, a.cameraAcceleration = 0.05, a.maxCameraSpeed = 20, a.lockedTarget = o, a.inputs = new al(a), a.inputs.addKeyboard().addMouseWheel().addPointers(), a;
+ }
+ return Object(c.d)(t, r), t.prototype._follow = function(e) {
+ if (e) {
+ var n;
+ if (e.rotationQuaternion) {
+ var i = new u.a();
+ e.rotationQuaternion.toRotationMatrix(i), n = Math.atan2(i.m[8], i.m[10]);
+ } else
+ n = e.rotation.y;
+ var o = Xe.b.ToRadians(this.rotationOffset) + n, a = e.getAbsolutePosition(), s = a.x + Math.sin(o) * this.radius, d = a.z + Math.cos(o) * this.radius, p = s - this.position.x, y = a.y + this.heightOffset - this.position.y, P = d - this.position.z, R = p * this.cameraAcceleration * 2, B = y * this.cameraAcceleration, F = P * this.cameraAcceleration * 2;
+ (R > this.maxCameraSpeed || R < -this.maxCameraSpeed) && (R = R < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed), (B > this.maxCameraSpeed || B < -this.maxCameraSpeed) && (B = B < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed), (F > this.maxCameraSpeed || F < -this.maxCameraSpeed) && (F = F < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed), this.position = new u.e(this.position.x + R, this.position.y + B, this.position.z + F), this.setTarget(a);
+ }
+ }, t.prototype.attachControl = function(e, n) {
+ n = Xe.b.BackCompatCameraNoPreventDefault(arguments), this.inputs.attachElement(n), this._reset = function() {
+ };
+ }, t.prototype.detachControl = function(e) {
+ this.inputs.detachElement(), this._reset && this._reset();
+ }, t.prototype._checkInputs = function() {
+ this.inputs.checkInputs(), this._checkLimits(), r.prototype._checkInputs.call(this), this.lockedTarget && this._follow(this.lockedTarget);
+ }, t.prototype._checkLimits = function() {
+ this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit && (this.radius = this.lowerRadiusLimit), this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit && (this.radius = this.upperRadiusLimit), this.lowerHeightOffsetLimit !== null && this.heightOffset < this.lowerHeightOffsetLimit && (this.heightOffset = this.lowerHeightOffsetLimit), this.upperHeightOffsetLimit !== null && this.heightOffset > this.upperHeightOffsetLimit && (this.heightOffset = this.upperHeightOffsetLimit), this.lowerRotationOffsetLimit !== null && this.rotationOffset < this.lowerRotationOffsetLimit && (this.rotationOffset = this.lowerRotationOffsetLimit), this.upperRotationOffsetLimit !== null && this.rotationOffset > this.upperRotationOffsetLimit && (this.rotationOffset = this.upperRotationOffsetLimit);
+ }, t.prototype.getClassName = function() {
+ return "FollowCamera";
+ }, Object(c.c)([Object(L.c)()], t.prototype, "radius", void 0), Object(c.c)([Object(L.c)()], t.prototype, "lowerRadiusLimit", void 0), Object(c.c)([Object(L.c)()], t.prototype, "upperRadiusLimit", void 0), Object(c.c)([Object(L.c)()], t.prototype, "rotationOffset", void 0), Object(c.c)([Object(L.c)()], t.prototype, "lowerRotationOffsetLimit", void 0), Object(c.c)([Object(L.c)()], t.prototype, "upperRotationOffsetLimit", void 0), Object(c.c)([Object(L.c)()], t.prototype, "heightOffset", void 0), Object(c.c)([Object(L.c)()], t.prototype, "lowerHeightOffsetLimit", void 0), Object(c.c)([Object(L.c)()], t.prototype, "upperHeightOffsetLimit", void 0), Object(c.c)([Object(L.c)()], t.prototype, "cameraAcceleration", void 0), Object(c.c)([Object(L.c)()], t.prototype, "maxCameraSpeed", void 0), Object(c.c)([Object(L.k)("lockedTargetId")], t.prototype, "lockedTarget", void 0), t;
+ }(Pi), cl = function(r) {
+ function t(e, n, i, o, a, s) {
+ var d = r.call(this, e, u.e.Zero(), s) || this;
+ return d.alpha = n, d.beta = i, d.radius = o, d._cartesianCoordinates = u.e.Zero(), d._meshTarget = a, d._follow(), d;
+ }
+ return Object(c.d)(t, r), t.prototype._follow = function() {
+ if (this._meshTarget) {
+ this._cartesianCoordinates.x = this.radius * Math.cos(this.alpha) * Math.cos(this.beta), this._cartesianCoordinates.y = this.radius * Math.sin(this.beta), this._cartesianCoordinates.z = this.radius * Math.sin(this.alpha) * Math.cos(this.beta);
+ var e = this._meshTarget.getAbsolutePosition();
+ this.position = e.add(this._cartesianCoordinates), this.setTarget(e);
+ }
+ }, t.prototype._checkInputs = function() {
+ r.prototype._checkInputs.call(this), this._follow();
+ }, t.prototype.getClassName = function() {
+ return "ArcFollowCamera";
+ }, t;
+ }(Pi), Za = f(38), dn = f(39);
+ (function(r) {
+ r[r.VIVE = 0] = "VIVE", r[r.OCULUS = 1] = "OCULUS", r[r.WINDOWS = 2] = "WINDOWS", r[r.GEAR_VR = 3] = "GEAR_VR", r[r.DAYDREAM = 4] = "DAYDREAM", r[r.GENERIC = 5] = "GENERIC";
+ })(Jn || (Jn = {}));
+ var xn, Hi, xi = function() {
+ function r() {
+ }
+ return r.InitiateController = function(t) {
+ for (var e = 0, n = this._ControllerFactories; e < n.length; e++) {
+ var i = n[e];
+ if (i.canCreate(t))
+ return i.create(t);
+ }
+ if (this._DefaultControllerFactory)
+ return this._DefaultControllerFactory(t);
+ throw "The type of gamepad you are trying to load needs to be imported first or is not supported.";
+ }, r._ControllerFactories = [], r._DefaultControllerFactory = null, r;
+ }(), ar = function(r) {
+ function t(e) {
+ var n = r.call(this, e.id, e.index, e) || this;
+ return n.isXR = !1, n._deviceRoomPosition = u.e.Zero(), n._deviceRoomRotationQuaternion = new u.b(), n.devicePosition = u.e.Zero(), n.deviceRotationQuaternion = new u.b(), n.deviceScaleFactor = 1, n._trackPosition = !0, n._maxRotationDistFromHeadset = Math.PI / 5, n._draggedRoomRotation = 0, n._leftHandSystemQuaternion = new u.b(), n._deviceToWorld = u.a.Identity(), n._pointingPoseNode = null, n._workingMatrix = u.a.Identity(), n._meshAttachedObservable = new C.c(), n.type = hn.POSE_ENABLED, n.controllerType = Jn.GENERIC, n.position = u.e.Zero(), n.rotationQuaternion = new u.b(), n._calculatedPosition = u.e.Zero(), n._calculatedRotation = new u.b(), u.b.RotationYawPitchRollToRef(Math.PI, 0, 0, n._leftHandSystemQuaternion), n;
+ }
+ return Object(c.d)(t, r), t.prototype._disableTrackPosition = function(e) {
+ this._trackPosition && (this._calculatedPosition.copyFrom(e), this._trackPosition = !1);
+ }, t.prototype.update = function() {
+ r.prototype.update.call(this), this._updatePoseAndMesh();
+ }, t.prototype._updatePoseAndMesh = function() {
+ if (!this.isXR) {
+ var e = this.browserGamepad.pose;
+ if (this.updateFromDevice(e), !this._trackPosition && te.a.LastCreatedScene && te.a.LastCreatedScene.activeCamera && te.a.LastCreatedScene.activeCamera.devicePosition && ((n = te.a.LastCreatedScene.activeCamera)._computeDevicePosition(), this._deviceToWorld.setTranslation(n.devicePosition), n.deviceRotationQuaternion)) {
+ var n;
+ (n = n)._deviceRoomRotationQuaternion.toEulerAnglesToRef(u.c.Vector3[0]);
+ var i = Math.atan2(Math.sin(u.c.Vector3[0].y - this._draggedRoomRotation), Math.cos(u.c.Vector3[0].y - this._draggedRoomRotation));
+ if (Math.abs(i) > this._maxRotationDistFromHeadset) {
+ var o = i - (i < 0 ? -this._maxRotationDistFromHeadset : this._maxRotationDistFromHeadset);
+ this._draggedRoomRotation += o;
+ var a = Math.sin(-o), s = Math.cos(-o);
+ this._calculatedPosition.x = this._calculatedPosition.x * s - this._calculatedPosition.z * a, this._calculatedPosition.z = this._calculatedPosition.x * a + this._calculatedPosition.z * s;
+ }
+ }
+ u.e.TransformCoordinatesToRef(this._calculatedPosition, this._deviceToWorld, this.devicePosition), this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix), u.b.FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion), this.deviceRotationQuaternion.multiplyInPlace(this._calculatedRotation), this._mesh && (this._mesh.position.copyFrom(this.devicePosition), this._mesh.rotationQuaternion && this._mesh.rotationQuaternion.copyFrom(this.deviceRotationQuaternion));
+ }
+ }, t.prototype.updateFromDevice = function(e) {
+ if (!this.isXR && e) {
+ this.rawPose = e, e.position && (this._deviceRoomPosition.copyFromFloats(e.position[0], e.position[1], -e.position[2]), this._mesh && this._mesh.getScene().useRightHandedSystem && (this._deviceRoomPosition.z *= -1), this._trackPosition && this._deviceRoomPosition.scaleToRef(this.deviceScaleFactor, this._calculatedPosition), this._calculatedPosition.addInPlace(this.position));
+ var n = this.rawPose;
+ e.orientation && n.orientation && n.orientation.length === 4 && (this._deviceRoomRotationQuaternion.copyFromFloats(n.orientation[0], n.orientation[1], -n.orientation[2], -n.orientation[3]), this._mesh && (this._mesh.getScene().useRightHandedSystem ? (this._deviceRoomRotationQuaternion.z *= -1, this._deviceRoomRotationQuaternion.w *= -1) : this._deviceRoomRotationQuaternion.multiplyToRef(this._leftHandSystemQuaternion, this._deviceRoomRotationQuaternion)), this._deviceRoomRotationQuaternion.multiplyToRef(this.rotationQuaternion, this._calculatedRotation));
+ }
+ }, t.prototype.attachToMesh = function(e) {
+ if (this._mesh && (this._mesh.parent = null), this._mesh = e, this._poseControlledCamera && (this._mesh.parent = this._poseControlledCamera), this._mesh.rotationQuaternion || (this._mesh.rotationQuaternion = new u.b()), !this.isXR && (this._updatePoseAndMesh(), this._pointingPoseNode)) {
+ for (var n = [], i = this._pointingPoseNode; i.parent; )
+ n.push(i.parent), i = i.parent;
+ n.reverse().forEach(function(o) {
+ o.computeWorldMatrix(!0);
+ });
+ }
+ this._meshAttachedObservable.notifyObservers(e);
+ }, t.prototype.attachToPoseControlledCamera = function(e) {
+ this._poseControlledCamera = e, this._mesh && (this._mesh.parent = this._poseControlledCamera);
+ }, t.prototype.dispose = function() {
+ this._mesh && this._mesh.dispose(), this._mesh = null, r.prototype.dispose.call(this);
+ }, Object.defineProperty(t.prototype, "mesh", { get: function() {
+ return this._mesh;
+ }, enumerable: !1, configurable: !0 }), t.prototype.getForwardRay = function(e) {
+ if (e === void 0 && (e = 100), !this.mesh)
+ return new dn.a(u.e.Zero(), new u.e(0, 0, 1), e);
+ var n = this._pointingPoseNode ? this._pointingPoseNode.getWorldMatrix() : this.mesh.getWorldMatrix(), i = n.getTranslation(), o = new u.e(0, 0, -1), a = u.e.TransformNormal(o, n), s = u.e.Normalize(a);
+ return new dn.a(i, s, e);
+ }, t.POINTING_POSE = "POINTING_POSE", t;
+ }(hn);
+ (function(r) {
+ r[r.A = 0] = "A", r[r.B = 1] = "B", r[r.X = 2] = "X", r[r.Y = 3] = "Y", r[r.LB = 4] = "LB", r[r.RB = 5] = "RB", r[r.Back = 8] = "Back", r[r.Start = 9] = "Start", r[r.LeftStick = 10] = "LeftStick", r[r.RightStick = 11] = "RightStick";
+ })(xn || (xn = {})), function(r) {
+ r[r.Up = 12] = "Up", r[r.Down = 13] = "Down", r[r.Left = 14] = "Left", r[r.Right = 15] = "Right";
+ }(Hi || (Hi = {}));
+ var Vn, Wi, ll = function(r) {
+ function t(e, n, i, o) {
+ o === void 0 && (o = !1);
+ var a = r.call(this, e, n, i, 0, 1, 2, 3) || this;
+ return a._leftTrigger = 0, a._rightTrigger = 0, a.onButtonDownObservable = new C.c(), a.onButtonUpObservable = new C.c(), a.onPadDownObservable = new C.c(), a.onPadUpObservable = new C.c(), a._buttonA = 0, a._buttonB = 0, a._buttonX = 0, a._buttonY = 0, a._buttonBack = 0, a._buttonStart = 0, a._buttonLB = 0, a._buttonRB = 0, a._buttonLeftStick = 0, a._buttonRightStick = 0, a._dPadUp = 0, a._dPadDown = 0, a._dPadLeft = 0, a._dPadRight = 0, a._isXboxOnePad = !1, a.type = hn.XBOX, a._isXboxOnePad = o, a;
+ }
+ return Object(c.d)(t, r), t.prototype.onlefttriggerchanged = function(e) {
+ this._onlefttriggerchanged = e;
+ }, t.prototype.onrighttriggerchanged = function(e) {
+ this._onrighttriggerchanged = e;
+ }, Object.defineProperty(t.prototype, "leftTrigger", { get: function() {
+ return this._leftTrigger;
+ }, set: function(e) {
+ this._onlefttriggerchanged && this._leftTrigger !== e && this._onlefttriggerchanged(e), this._leftTrigger = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rightTrigger", { get: function() {
+ return this._rightTrigger;
+ }, set: function(e) {
+ this._onrighttriggerchanged && this._rightTrigger !== e && this._onrighttriggerchanged(e), this._rightTrigger = e;
+ }, enumerable: !1, configurable: !0 }), t.prototype.onbuttondown = function(e) {
+ this._onbuttondown = e;
+ }, t.prototype.onbuttonup = function(e) {
+ this._onbuttonup = e;
+ }, t.prototype.ondpaddown = function(e) {
+ this._ondpaddown = e;
+ }, t.prototype.ondpadup = function(e) {
+ this._ondpadup = e;
+ }, t.prototype._setButtonValue = function(e, n, i) {
+ return e !== n && (e === 1 && (this._onbuttondown && this._onbuttondown(i), this.onButtonDownObservable.notifyObservers(i)), e === 0 && (this._onbuttonup && this._onbuttonup(i), this.onButtonUpObservable.notifyObservers(i))), e;
+ }, t.prototype._setDPadValue = function(e, n, i) {
+ return e !== n && (e === 1 && (this._ondpaddown && this._ondpaddown(i), this.onPadDownObservable.notifyObservers(i)), e === 0 && (this._ondpadup && this._ondpadup(i), this.onPadUpObservable.notifyObservers(i))), e;
+ }, Object.defineProperty(t.prototype, "buttonA", { get: function() {
+ return this._buttonA;
+ }, set: function(e) {
+ this._buttonA = this._setButtonValue(e, this._buttonA, xn.A);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonB", { get: function() {
+ return this._buttonB;
+ }, set: function(e) {
+ this._buttonB = this._setButtonValue(e, this._buttonB, xn.B);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonX", { get: function() {
+ return this._buttonX;
+ }, set: function(e) {
+ this._buttonX = this._setButtonValue(e, this._buttonX, xn.X);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonY", { get: function() {
+ return this._buttonY;
+ }, set: function(e) {
+ this._buttonY = this._setButtonValue(e, this._buttonY, xn.Y);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonStart", { get: function() {
+ return this._buttonStart;
+ }, set: function(e) {
+ this._buttonStart = this._setButtonValue(e, this._buttonStart, xn.Start);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonBack", { get: function() {
+ return this._buttonBack;
+ }, set: function(e) {
+ this._buttonBack = this._setButtonValue(e, this._buttonBack, xn.Back);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonLB", { get: function() {
+ return this._buttonLB;
+ }, set: function(e) {
+ this._buttonLB = this._setButtonValue(e, this._buttonLB, xn.LB);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonRB", { get: function() {
+ return this._buttonRB;
+ }, set: function(e) {
+ this._buttonRB = this._setButtonValue(e, this._buttonRB, xn.RB);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonLeftStick", { get: function() {
+ return this._buttonLeftStick;
+ }, set: function(e) {
+ this._buttonLeftStick = this._setButtonValue(e, this._buttonLeftStick, xn.LeftStick);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonRightStick", { get: function() {
+ return this._buttonRightStick;
+ }, set: function(e) {
+ this._buttonRightStick = this._setButtonValue(e, this._buttonRightStick, xn.RightStick);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "dPadUp", { get: function() {
+ return this._dPadUp;
+ }, set: function(e) {
+ this._dPadUp = this._setDPadValue(e, this._dPadUp, Hi.Up);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "dPadDown", { get: function() {
+ return this._dPadDown;
+ }, set: function(e) {
+ this._dPadDown = this._setDPadValue(e, this._dPadDown, Hi.Down);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "dPadLeft", { get: function() {
+ return this._dPadLeft;
+ }, set: function(e) {
+ this._dPadLeft = this._setDPadValue(e, this._dPadLeft, Hi.Left);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "dPadRight", { get: function() {
+ return this._dPadRight;
+ }, set: function(e) {
+ this._dPadRight = this._setDPadValue(e, this._dPadRight, Hi.Right);
+ }, enumerable: !1, configurable: !0 }), t.prototype.update = function() {
+ r.prototype.update.call(this), this._isXboxOnePad, this.buttonA = this.browserGamepad.buttons[0].value, this.buttonB = this.browserGamepad.buttons[1].value, this.buttonX = this.browserGamepad.buttons[2].value, this.buttonY = this.browserGamepad.buttons[3].value, this.buttonLB = this.browserGamepad.buttons[4].value, this.buttonRB = this.browserGamepad.buttons[5].value, this.leftTrigger = this.browserGamepad.buttons[6].value, this.rightTrigger = this.browserGamepad.buttons[7].value, this.buttonBack = this.browserGamepad.buttons[8].value, this.buttonStart = this.browserGamepad.buttons[9].value, this.buttonLeftStick = this.browserGamepad.buttons[10].value, this.buttonRightStick = this.browserGamepad.buttons[11].value, this.dPadUp = this.browserGamepad.buttons[12].value, this.dPadDown = this.browserGamepad.buttons[13].value, this.dPadLeft = this.browserGamepad.buttons[14].value, this.dPadRight = this.browserGamepad.buttons[15].value;
+ }, t.prototype.dispose = function() {
+ r.prototype.dispose.call(this), this.onButtonDownObservable.clear(), this.onButtonUpObservable.clear(), this.onPadDownObservable.clear(), this.onPadUpObservable.clear();
+ }, t;
+ }(hn);
+ (function(r) {
+ r[r.Cross = 0] = "Cross", r[r.Circle = 1] = "Circle", r[r.Square = 2] = "Square", r[r.Triangle = 3] = "Triangle", r[r.L1 = 4] = "L1", r[r.R1 = 5] = "R1", r[r.Share = 8] = "Share", r[r.Options = 9] = "Options", r[r.LeftStick = 10] = "LeftStick", r[r.RightStick = 11] = "RightStick";
+ })(Vn || (Vn = {})), function(r) {
+ r[r.Up = 12] = "Up", r[r.Down = 13] = "Down", r[r.Left = 14] = "Left", r[r.Right = 15] = "Right";
+ }(Wi || (Wi = {}));
+ var ul = function(r) {
+ function t(e, n, i) {
+ var o = r.call(this, e.replace("STANDARD GAMEPAD", "SONY PLAYSTATION DUALSHOCK"), n, i, 0, 1, 2, 3) || this;
+ return o._leftTrigger = 0, o._rightTrigger = 0, o.onButtonDownObservable = new C.c(), o.onButtonUpObservable = new C.c(), o.onPadDownObservable = new C.c(), o.onPadUpObservable = new C.c(), o._buttonCross = 0, o._buttonCircle = 0, o._buttonSquare = 0, o._buttonTriangle = 0, o._buttonShare = 0, o._buttonOptions = 0, o._buttonL1 = 0, o._buttonR1 = 0, o._buttonLeftStick = 0, o._buttonRightStick = 0, o._dPadUp = 0, o._dPadDown = 0, o._dPadLeft = 0, o._dPadRight = 0, o.type = hn.DUALSHOCK, o;
+ }
+ return Object(c.d)(t, r), t.prototype.onlefttriggerchanged = function(e) {
+ this._onlefttriggerchanged = e;
+ }, t.prototype.onrighttriggerchanged = function(e) {
+ this._onrighttriggerchanged = e;
+ }, Object.defineProperty(t.prototype, "leftTrigger", { get: function() {
+ return this._leftTrigger;
+ }, set: function(e) {
+ this._onlefttriggerchanged && this._leftTrigger !== e && this._onlefttriggerchanged(e), this._leftTrigger = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rightTrigger", { get: function() {
+ return this._rightTrigger;
+ }, set: function(e) {
+ this._onrighttriggerchanged && this._rightTrigger !== e && this._onrighttriggerchanged(e), this._rightTrigger = e;
+ }, enumerable: !1, configurable: !0 }), t.prototype.onbuttondown = function(e) {
+ this._onbuttondown = e;
+ }, t.prototype.onbuttonup = function(e) {
+ this._onbuttonup = e;
+ }, t.prototype.ondpaddown = function(e) {
+ this._ondpaddown = e;
+ }, t.prototype.ondpadup = function(e) {
+ this._ondpadup = e;
+ }, t.prototype._setButtonValue = function(e, n, i) {
+ return e !== n && (e === 1 && (this._onbuttondown && this._onbuttondown(i), this.onButtonDownObservable.notifyObservers(i)), e === 0 && (this._onbuttonup && this._onbuttonup(i), this.onButtonUpObservable.notifyObservers(i))), e;
+ }, t.prototype._setDPadValue = function(e, n, i) {
+ return e !== n && (e === 1 && (this._ondpaddown && this._ondpaddown(i), this.onPadDownObservable.notifyObservers(i)), e === 0 && (this._ondpadup && this._ondpadup(i), this.onPadUpObservable.notifyObservers(i))), e;
+ }, Object.defineProperty(t.prototype, "buttonCross", { get: function() {
+ return this._buttonCross;
+ }, set: function(e) {
+ this._buttonCross = this._setButtonValue(e, this._buttonCross, Vn.Cross);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonCircle", { get: function() {
+ return this._buttonCircle;
+ }, set: function(e) {
+ this._buttonCircle = this._setButtonValue(e, this._buttonCircle, Vn.Circle);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonSquare", { get: function() {
+ return this._buttonSquare;
+ }, set: function(e) {
+ this._buttonSquare = this._setButtonValue(e, this._buttonSquare, Vn.Square);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonTriangle", { get: function() {
+ return this._buttonTriangle;
+ }, set: function(e) {
+ this._buttonTriangle = this._setButtonValue(e, this._buttonTriangle, Vn.Triangle);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonOptions", { get: function() {
+ return this._buttonOptions;
+ }, set: function(e) {
+ this._buttonOptions = this._setButtonValue(e, this._buttonOptions, Vn.Options);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonShare", { get: function() {
+ return this._buttonShare;
+ }, set: function(e) {
+ this._buttonShare = this._setButtonValue(e, this._buttonShare, Vn.Share);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonL1", { get: function() {
+ return this._buttonL1;
+ }, set: function(e) {
+ this._buttonL1 = this._setButtonValue(e, this._buttonL1, Vn.L1);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonR1", { get: function() {
+ return this._buttonR1;
+ }, set: function(e) {
+ this._buttonR1 = this._setButtonValue(e, this._buttonR1, Vn.R1);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonLeftStick", { get: function() {
+ return this._buttonLeftStick;
+ }, set: function(e) {
+ this._buttonLeftStick = this._setButtonValue(e, this._buttonLeftStick, Vn.LeftStick);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "buttonRightStick", { get: function() {
+ return this._buttonRightStick;
+ }, set: function(e) {
+ this._buttonRightStick = this._setButtonValue(e, this._buttonRightStick, Vn.RightStick);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "dPadUp", { get: function() {
+ return this._dPadUp;
+ }, set: function(e) {
+ this._dPadUp = this._setDPadValue(e, this._dPadUp, Wi.Up);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "dPadDown", { get: function() {
+ return this._dPadDown;
+ }, set: function(e) {
+ this._dPadDown = this._setDPadValue(e, this._dPadDown, Wi.Down);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "dPadLeft", { get: function() {
+ return this._dPadLeft;
+ }, set: function(e) {
+ this._dPadLeft = this._setDPadValue(e, this._dPadLeft, Wi.Left);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "dPadRight", { get: function() {
+ return this._dPadRight;
+ }, set: function(e) {
+ this._dPadRight = this._setDPadValue(e, this._dPadRight, Wi.Right);
+ }, enumerable: !1, configurable: !0 }), t.prototype.update = function() {
+ r.prototype.update.call(this), this.buttonCross = this.browserGamepad.buttons[0].value, this.buttonCircle = this.browserGamepad.buttons[1].value, this.buttonSquare = this.browserGamepad.buttons[2].value, this.buttonTriangle = this.browserGamepad.buttons[3].value, this.buttonL1 = this.browserGamepad.buttons[4].value, this.buttonR1 = this.browserGamepad.buttons[5].value, this.leftTrigger = this.browserGamepad.buttons[6].value, this.rightTrigger = this.browserGamepad.buttons[7].value, this.buttonShare = this.browserGamepad.buttons[8].value, this.buttonOptions = this.browserGamepad.buttons[9].value, this.buttonLeftStick = this.browserGamepad.buttons[10].value, this.buttonRightStick = this.browserGamepad.buttons[11].value, this.dPadUp = this.browserGamepad.buttons[12].value, this.dPadDown = this.browserGamepad.buttons[13].value, this.dPadLeft = this.browserGamepad.buttons[14].value, this.dPadRight = this.browserGamepad.buttons[15].value;
+ }, t.prototype.dispose = function() {
+ r.prototype.dispose.call(this), this.onButtonDownObservable.clear(), this.onButtonUpObservable.clear(), this.onPadDownObservable.clear(), this.onPadUpObservable.clear();
+ }, t;
+ }(hn), hl = function() {
+ function r(t) {
+ var e = this;
+ if (this._scene = t, this._babylonGamepads = [], this._oneGamepadConnected = !1, this._isMonitoring = !1, this.onGamepadDisconnectedObservable = new C.c(), Za.a.IsWindowObjectExist() ? (this._gamepadEventSupported = "GamepadEvent" in window, this._gamepadSupport = navigator.getGamepads || navigator.webkitGetGamepads || navigator.msGetGamepads || navigator.webkitGamepads) : this._gamepadEventSupported = !1, this.onGamepadConnectedObservable = new C.c(function(i) {
+ for (var o in e._babylonGamepads) {
+ var a = e._babylonGamepads[o];
+ a && a._isConnected && e.onGamepadConnectedObservable.notifyObserver(i, a);
+ }
+ }), this._onGamepadConnectedEvent = function(i) {
+ var o, a = i.gamepad;
+ a.index in e._babylonGamepads && e._babylonGamepads[a.index].isConnected || (e._babylonGamepads[a.index] ? ((o = e._babylonGamepads[a.index]).browserGamepad = a, o._isConnected = !0) : o = e._addNewGamepad(a), e.onGamepadConnectedObservable.notifyObservers(o), e._startMonitoringGamepads());
+ }, this._onGamepadDisconnectedEvent = function(i) {
+ var o = i.gamepad;
+ for (var a in e._babylonGamepads)
+ if (e._babylonGamepads[a].index === o.index) {
+ var s = e._babylonGamepads[a];
+ s._isConnected = !1, e.onGamepadDisconnectedObservable.notifyObservers(s), s.dispose && s.dispose();
+ break;
+ }
+ }, this._gamepadSupport)
+ if (this._updateGamepadObjects(), this._babylonGamepads.length && this._startMonitoringGamepads(), this._gamepadEventSupported) {
+ var n = this._scene ? this._scene.getEngine().getHostWindow() : window;
+ n && (n.addEventListener("gamepadconnected", this._onGamepadConnectedEvent, !1), n.addEventListener("gamepaddisconnected", this._onGamepadDisconnectedEvent, !1));
+ } else
+ this._startMonitoringGamepads();
+ }
+ return Object.defineProperty(r.prototype, "gamepads", { get: function() {
+ return this._babylonGamepads;
+ }, enumerable: !1, configurable: !0 }), r.prototype.getGamepadByType = function(t) {
+ t === void 0 && (t = hn.XBOX);
+ for (var e = 0, n = this._babylonGamepads; e < n.length; e++) {
+ var i = n[e];
+ if (i && i.type === t)
+ return i;
+ }
+ return null;
+ }, r.prototype.dispose = function() {
+ this._gamepadEventSupported && (this._onGamepadConnectedEvent && window.removeEventListener("gamepadconnected", this._onGamepadConnectedEvent), this._onGamepadDisconnectedEvent && window.removeEventListener("gamepaddisconnected", this._onGamepadDisconnectedEvent), this._onGamepadConnectedEvent = null, this._onGamepadDisconnectedEvent = null), this._babylonGamepads.forEach(function(t) {
+ t.dispose();
+ }), this.onGamepadConnectedObservable.clear(), this.onGamepadDisconnectedObservable.clear(), this._oneGamepadConnected = !1, this._stopMonitoringGamepads(), this._babylonGamepads = [];
+ }, r.prototype._addNewGamepad = function(t) {
+ var e;
+ this._oneGamepadConnected || (this._oneGamepadConnected = !0);
+ var n = t.id.search("054c") !== -1, i = t.id.search("Xbox One") !== -1;
+ return e = i || t.id.search("Xbox 360") !== -1 || t.id.search("xinput") !== -1 ? new ll(t.id, t.index, t, i) : n ? new ul(t.id, t.index, t) : t.pose ? xi.InitiateController(t) : new nl(t.id, t.index, t), this._babylonGamepads[e.index] = e, e;
+ }, r.prototype._startMonitoringGamepads = function() {
+ this._isMonitoring || (this._isMonitoring = !0, this._scene || this._checkGamepadsStatus());
+ }, r.prototype._stopMonitoringGamepads = function() {
+ this._isMonitoring = !1;
+ }, r.prototype._checkGamepadsStatus = function() {
+ var t = this;
+ for (var e in this._updateGamepadObjects(), this._babylonGamepads) {
+ var n = this._babylonGamepads[e];
+ n && n.isConnected && n.update();
+ }
+ this._isMonitoring && !this._scene && Ue.a.QueueNewFrame(function() {
+ t._checkGamepadsStatus();
+ });
+ }, r.prototype._updateGamepadObjects = function() {
+ for (var t = navigator.getGamepads ? navigator.getGamepads() : navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : [], e = 0; e < t.length; e++) {
+ var n = t[e];
+ if (n)
+ if (this._babylonGamepads[n.index])
+ this._babylonGamepads[e].browserGamepad = n, this._babylonGamepads[e].isConnected || (this._babylonGamepads[e]._isConnected = !0, this.onGamepadConnectedObservable.notifyObservers(this._babylonGamepads[e]));
+ else {
+ var i = this._addNewGamepad(n);
+ this.onGamepadConnectedObservable.notifyObservers(i);
+ }
+ }
+ }, r;
+ }();
+ Object.defineProperty(_e.a.prototype, "gamepadManager", { get: function() {
+ if (!this._gamepadManager) {
+ this._gamepadManager = new hl(this);
+ var r = this._getComponent(ot.a.NAME_GAMEPAD);
+ r || (r = new dl(this), this._addComponent(r));
+ }
+ return this._gamepadManager;
+ }, enumerable: !0, configurable: !0 }), jr.prototype.addGamepad = function() {
+ return this.add(new Ya()), this;
+ }, Po.prototype.addGamepad = function() {
+ return this.add(new Da()), this;
+ };
+ var dl = function() {
+ function r(t) {
+ this.name = ot.a.NAME_GAMEPAD, this.scene = t;
+ }
+ return r.prototype.register = function() {
+ this.scene._beforeCameraUpdateStage.registerStep(ot.a.STEP_BEFORECAMERAUPDATE_GAMEPAD, this, this._beforeCameraUpdate);
+ }, r.prototype.rebuild = function() {
+ }, r.prototype.dispose = function() {
+ var t = this.scene._gamepadManager;
+ t && (t.dispose(), this.scene._gamepadManager = null);
+ }, r.prototype._beforeCameraUpdate = function() {
+ var t = this.scene._gamepadManager;
+ t && t._isMonitoring && t._checkGamepadsStatus();
+ }, r;
+ }();
+ Q.a.AddNodeConstructor("FreeCamera", function(r, t) {
+ return function() {
+ return new sr(r, u.e.Zero(), t);
+ };
+ });
+ var sr = function(r) {
+ function t(e, n, i) {
+ var o = r.call(this, e, n, i) || this;
+ return o.inputs.addGamepad(), o;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "gamepadAngularSensibility", { get: function() {
+ var e = this.inputs.attached.gamepad;
+ return e ? e.gamepadAngularSensibility : 0;
+ }, set: function(e) {
+ var n = this.inputs.attached.gamepad;
+ n && (n.gamepadAngularSensibility = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "gamepadMoveSensibility", { get: function() {
+ var e = this.inputs.attached.gamepad;
+ return e ? e.gamepadMoveSensibility : 0;
+ }, set: function(e) {
+ var n = this.inputs.attached.gamepad;
+ n && (n.gamepadMoveSensibility = e);
+ }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
+ return "UniversalCamera";
+ }, t;
+ }(qa);
+ _t.a._createDefaultParsedCamera = function(r, t) {
+ return new sr(r, u.e.Zero(), t);
+ }, Q.a.AddNodeConstructor("GamepadCamera", function(r, t) {
+ return function() {
+ return new Co(r, u.e.Zero(), t);
+ };
+ });
+ var Co = function(r) {
+ function t(e, n, i) {
+ return r.call(this, e, n, i) || this;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "GamepadCamera";
+ }, t;
+ }(sr), si = f(33), ze = f(5), vf = `
+attribute vec2 position;
+uniform vec2 scale;
+
+varying vec2 vUV;
+const vec2 madd=vec2(0.5,0.5);
+void main(void) {
+vUV=(position*madd+madd)*scale;
+gl_Position=vec4(position,0.0,1.0);
+}`;
+ ze.a.ShadersStore.postprocessVertexShader = vf;
+ var fl = f(102);
+ wt.a.prototype.createRenderTargetTexture = function(r, t) {
+ var e = new fl.a();
+ t !== void 0 && typeof t == "object" ? (e.generateMipMaps = t.generateMipMaps, e.generateDepthBuffer = !!t.generateDepthBuffer, e.generateStencilBuffer = !!t.generateStencilBuffer, e.type = t.type === void 0 ? h.a.TEXTURETYPE_UNSIGNED_INT : t.type, e.samplingMode = t.samplingMode === void 0 ? h.a.TEXTURE_TRILINEAR_SAMPLINGMODE : t.samplingMode, e.format = t.format === void 0 ? h.a.TEXTUREFORMAT_RGBA : t.format) : (e.generateMipMaps = t, e.generateDepthBuffer = !0, e.generateStencilBuffer = !1, e.type = h.a.TEXTURETYPE_UNSIGNED_INT, e.samplingMode = h.a.TEXTURE_TRILINEAR_SAMPLINGMODE, e.format = h.a.TEXTUREFORMAT_RGBA), (e.type !== h.a.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering) && (e.type !== h.a.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering) || (e.samplingMode = h.a.TEXTURE_NEAREST_SAMPLINGMODE), e.type !== h.a.TEXTURETYPE_FLOAT || this._caps.textureFloat || (e.type = h.a.TEXTURETYPE_UNSIGNED_INT, l.a.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type"));
+ var n = this._gl, i = new Pt.a(this, Pt.b.RenderTarget), o = r.width || r, a = r.height || r, s = r.layers || 0, d = this._getSamplingParameters(e.samplingMode, !!e.generateMipMaps), p = s !== 0 ? n.TEXTURE_2D_ARRAY : n.TEXTURE_2D, y = this._getRGBABufferInternalSizedFormat(e.type, e.format), P = this._getInternalFormat(e.format), R = this._getWebGLTextureType(e.type);
+ this._bindTextureDirectly(p, i), s !== 0 ? (i.is2DArray = !0, n.texImage3D(p, 0, y, o, a, s, 0, P, R, null)) : n.texImage2D(p, 0, y, o, a, 0, P, R, null), n.texParameteri(p, n.TEXTURE_MAG_FILTER, d.mag), n.texParameteri(p, n.TEXTURE_MIN_FILTER, d.min), n.texParameteri(p, n.TEXTURE_WRAP_S, n.CLAMP_TO_EDGE), n.texParameteri(p, n.TEXTURE_WRAP_T, n.CLAMP_TO_EDGE), e.generateMipMaps && this._gl.generateMipmap(p), this._bindTextureDirectly(p, null);
+ var B = this._currentFramebuffer, F = n.createFramebuffer();
+ return this._bindUnboundFramebuffer(F), i._depthStencilBuffer = this._setupFramebufferDepthAttachments(!!e.generateStencilBuffer, e.generateDepthBuffer, o, a), i.is2DArray || n.framebufferTexture2D(n.FRAMEBUFFER, n.COLOR_ATTACHMENT0, n.TEXTURE_2D, i._webGLTexture, 0), this._bindUnboundFramebuffer(B), i._framebuffer = F, i.baseWidth = o, i.baseHeight = a, i.width = o, i.height = a, i.depth = s, i.isReady = !0, i.samples = 1, i.generateMipMaps = !!e.generateMipMaps, i.samplingMode = e.samplingMode, i.type = e.type, i.format = e.format, i._generateDepthBuffer = e.generateDepthBuffer, i._generateStencilBuffer = !!e.generateStencilBuffer, this._internalTexturesCache.push(i), i;
+ }, wt.a.prototype.createDepthStencilTexture = function(r, t) {
+ if (t.isCube) {
+ var e = r.width || r;
+ return this._createDepthStencilCubeTexture(e, t);
+ }
+ return this._createDepthStencilTexture(r, t);
+ }, wt.a.prototype._createDepthStencilTexture = function(r, t) {
+ var e = this._gl, n = r.layers || 0, i = n !== 0 ? e.TEXTURE_2D_ARRAY : e.TEXTURE_2D, o = new Pt.a(this, Pt.b.Depth);
+ if (!this._caps.depthTextureExtension)
+ return l.a.Error("Depth texture is not supported by your browser or hardware."), o;
+ var a = Object(c.a)({ bilinearFiltering: !1, comparisonFunction: 0, generateStencil: !1 }, t);
+ this._bindTextureDirectly(i, o, !0), this._setupDepthStencilTexture(o, r, a.generateStencil, a.bilinearFiltering, a.comparisonFunction);
+ var s = a.generateStencil ? e.UNSIGNED_INT_24_8 : e.UNSIGNED_INT, d = a.generateStencil ? e.DEPTH_STENCIL : e.DEPTH_COMPONENT, p = d;
+ return this.webGLVersion > 1 && (p = a.generateStencil ? e.DEPTH24_STENCIL8 : e.DEPTH_COMPONENT24), o.is2DArray ? e.texImage3D(i, 0, p, o.width, o.height, n, 0, d, s, null) : e.texImage2D(i, 0, p, o.width, o.height, 0, d, s, null), this._bindTextureDirectly(i, null), o;
+ };
+ var ft = function() {
+ function r(t, e, n, i, o, a, s, d, p, y, P, R, B, F, z) {
+ s === void 0 && (s = h.a.TEXTURE_NEAREST_SAMPLINGMODE), y === void 0 && (y = null), P === void 0 && (P = h.a.TEXTURETYPE_UNSIGNED_INT), R === void 0 && (R = "postprocess"), F === void 0 && (F = !1), z === void 0 && (z = h.a.TEXTUREFORMAT_RGBA), this.width = -1, this.height = -1, this.nodeMaterialSource = null, this._outputTexture = null, this.autoClear = !0, this.alphaMode = h.a.ALPHA_DISABLE, this.animations = new Array(), this.enablePixelPerfectMode = !1, this.forceFullscreenViewport = !0, this.scaleMode = h.a.SCALEMODE_FLOOR, this.alwaysForcePOT = !1, this._samples = 1, this.adaptScaleToCurrentViewport = !1, this._reusable = !1, this._textures = new si.a(2), this._currentRenderTextureInd = 0, this._scaleRatio = new u.d(1, 1), this._texelSize = u.d.Zero(), this.onActivateObservable = new C.c(), this.onSizeChangedObservable = new C.c(), this.onApplyObservable = new C.c(), this.onBeforeRenderObservable = new C.c(), this.onAfterRenderObservable = new C.c(), this.name = t, a != null ? (this._camera = a, this._scene = a.getScene(), a.attachPostProcess(this), this._engine = this._scene.getEngine(), this._scene.postProcesses.push(this), this.uniqueId = this._scene.getUniqueId()) : d && (this._engine = d, this._engine.postProcesses.push(this)), this._options = o, this.renderTargetSamplingMode = s || h.a.TEXTURE_NEAREST_SAMPLINGMODE, this._reusable = p || !1, this._textureType = P, this._textureFormat = z, this._samplers = i || [], this._samplers.push("textureSampler"), this._fragmentUrl = e, this._vertexUrl = R, this._parameters = n || [], this._parameters.push("scale"), this._indexParameters = B, F || this.updateEffect(y);
+ }
+ return Object.defineProperty(r.prototype, "samples", { get: function() {
+ return this._samples;
+ }, set: function(t) {
+ var e = this;
+ this._samples = Math.min(t, this._engine.getCaps().maxMSAASamples), this._textures.forEach(function(n) {
+ n.samples !== e._samples && e._engine.updateRenderTargetTextureSampleCount(n, e._samples);
+ });
+ }, enumerable: !1, configurable: !0 }), r.prototype.getEffectName = function() {
+ return this._fragmentUrl;
+ }, Object.defineProperty(r.prototype, "onActivate", { set: function(t) {
+ this._onActivateObserver && this.onActivateObservable.remove(this._onActivateObserver), t && (this._onActivateObserver = this.onActivateObservable.add(t));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "onSizeChanged", { set: function(t) {
+ this._onSizeChangedObserver && this.onSizeChangedObservable.remove(this._onSizeChangedObserver), this._onSizeChangedObserver = this.onSizeChangedObservable.add(t);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "onApply", { set: function(t) {
+ this._onApplyObserver && this.onApplyObservable.remove(this._onApplyObserver), this._onApplyObserver = this.onApplyObservable.add(t);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "onBeforeRender", { set: function(t) {
+ this._onBeforeRenderObserver && this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver), this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(t);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "onAfterRender", { set: function(t) {
+ this._onAfterRenderObserver && this.onAfterRenderObservable.remove(this._onAfterRenderObserver), this._onAfterRenderObserver = this.onAfterRenderObservable.add(t);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "inputTexture", { get: function() {
+ return this._textures.data[this._currentRenderTextureInd];
+ }, set: function(t) {
+ this._forcedOutputTexture = t;
+ }, enumerable: !1, configurable: !0 }), r.prototype.restoreDefaultInputTexture = function() {
+ this._forcedOutputTexture = null;
+ }, r.prototype.getCamera = function() {
+ return this._camera;
+ }, Object.defineProperty(r.prototype, "texelSize", { get: function() {
+ return this._shareOutputWithPostProcess ? this._shareOutputWithPostProcess.texelSize : (this._forcedOutputTexture && this._texelSize.copyFromFloats(1 / this._forcedOutputTexture.width, 1 / this._forcedOutputTexture.height), this._texelSize);
+ }, enumerable: !1, configurable: !0 }), r.prototype.getClassName = function() {
+ return "PostProcess";
+ }, r.prototype.getEngine = function() {
+ return this._engine;
+ }, r.prototype.getEffect = function() {
+ return this._effect;
+ }, r.prototype.shareOutputWith = function(t) {
+ return this._disposeTextures(), this._shareOutputWithPostProcess = t, this;
+ }, r.prototype.useOwnOutput = function() {
+ this._textures.length == 0 && (this._textures = new si.a(2)), this._shareOutputWithPostProcess = null;
+ }, r.prototype.updateEffect = function(t, e, n, i, o, a, s, d) {
+ t === void 0 && (t = null), e === void 0 && (e = null), n === void 0 && (n = null), this._effect = this._engine.createEffect({ vertex: s ?? this._vertexUrl, fragment: d ?? this._fragmentUrl }, ["position"], e || this._parameters, n || this._samplers, t !== null ? t : "", void 0, o, a, i || this._indexParameters);
+ }, r.prototype.isReusable = function() {
+ return this._reusable;
+ }, r.prototype.markTextureDirty = function() {
+ this.width = -1;
+ }, r.prototype.activate = function(t, e, n) {
+ var i = this;
+ e === void 0 && (e = null);
+ var o = (t = t || this._camera).getScene(), a = o.getEngine(), s = a.getCaps().maxTextureSize, d = (e ? e.width : this._engine.getRenderWidth(!0)) * this._options | 0, p = (e ? e.height : this._engine.getRenderHeight(!0)) * this._options | 0, y = t.parent;
+ !y || y.leftCamera != t && y.rightCamera != t || (d /= 2);
+ var P, R = this._options.width || d, B = this._options.height || p, F = this.renderTargetSamplingMode !== h.a.TEXTURE_NEAREST_LINEAR && this.renderTargetSamplingMode !== h.a.TEXTURE_NEAREST_NEAREST && this.renderTargetSamplingMode !== h.a.TEXTURE_LINEAR_LINEAR;
+ if (!this._shareOutputWithPostProcess && !this._forcedOutputTexture) {
+ if (this.adaptScaleToCurrentViewport) {
+ var z = a.currentViewport;
+ z && (R *= z.width, B *= z.height);
+ }
+ if ((F || this.alwaysForcePOT) && (this._options.width || (R = a.needPOTTextures ? Ue.a.GetExponentOfTwo(R, s, this.scaleMode) : R), this._options.height || (B = a.needPOTTextures ? Ue.a.GetExponentOfTwo(B, s, this.scaleMode) : B)), this.width !== R || this.height !== B) {
+ if (this._textures.length > 0) {
+ for (var J = 0; J < this._textures.length; J++)
+ this._engine._releaseTexture(this._textures.data[J]);
+ this._textures.reset();
+ }
+ this.width = R, this.height = B;
+ var ie = { width: this.width, height: this.height }, se = { generateMipMaps: F, generateDepthBuffer: n || t._postProcesses.indexOf(this) === 0, generateStencilBuffer: (n || t._postProcesses.indexOf(this) === 0) && this._engine.isStencilEnable, samplingMode: this.renderTargetSamplingMode, type: this._textureType, format: this._textureFormat };
+ this._textures.push(this._engine.createRenderTargetTexture(ie, se)), this._reusable && this._textures.push(this._engine.createRenderTargetTexture(ie, se)), this._texelSize.copyFromFloats(1 / this.width, 1 / this.height), this.onSizeChangedObservable.notifyObservers(this);
+ }
+ this._textures.forEach(function(ce) {
+ ce.samples !== i.samples && i._engine.updateRenderTargetTextureSampleCount(ce, i.samples);
+ });
+ }
+ return this._shareOutputWithPostProcess ? P = this._shareOutputWithPostProcess.inputTexture : this._forcedOutputTexture ? (P = this._forcedOutputTexture, this.width = this._forcedOutputTexture.width, this.height = this._forcedOutputTexture.height) : P = this.inputTexture, this.enablePixelPerfectMode ? (this._scaleRatio.copyFromFloats(d / R, p / B), this._engine.bindFramebuffer(P, 0, d, p, this.forceFullscreenViewport)) : (this._scaleRatio.copyFromFloats(1, 1), this._engine.bindFramebuffer(P, 0, void 0, void 0, this.forceFullscreenViewport)), this.onActivateObservable.notifyObservers(t), this.autoClear && this.alphaMode === h.a.ALPHA_DISABLE && this._engine.clear(this.clearColor ? this.clearColor : o.clearColor, o._allowPostProcessClearColor, !0, !0), this._reusable && (this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2), P;
+ }, Object.defineProperty(r.prototype, "isSupported", { get: function() {
+ return this._effect.isSupported;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "aspectRatio", { get: function() {
+ return this._shareOutputWithPostProcess ? this._shareOutputWithPostProcess.aspectRatio : this._forcedOutputTexture ? this._forcedOutputTexture.width / this._forcedOutputTexture.height : this.width / this.height;
+ }, enumerable: !1, configurable: !0 }), r.prototype.isReady = function() {
+ return this._effect && this._effect.isReady();
+ }, r.prototype.apply = function() {
+ return this._effect && this._effect.isReady() ? (this._engine.enableEffect(this._effect), this._engine.setState(!1), this._engine.setDepthBuffer(!1), this._engine.setDepthWrite(!1), this._engine.setAlphaMode(this.alphaMode), this.alphaConstants && this.getEngine().setAlphaConstants(this.alphaConstants.r, this.alphaConstants.g, this.alphaConstants.b, this.alphaConstants.a), t = this._shareOutputWithPostProcess ? this._shareOutputWithPostProcess.inputTexture : this._forcedOutputTexture ? this._forcedOutputTexture : this.inputTexture, this._effect._bindTexture("textureSampler", t), this._effect.setVector2("scale", this._scaleRatio), this.onApplyObservable.notifyObservers(this._effect), this._effect) : null;
+ var t;
+ }, r.prototype._disposeTextures = function() {
+ if (!this._shareOutputWithPostProcess && !this._forcedOutputTexture) {
+ if (this._textures.length > 0)
+ for (var t = 0; t < this._textures.length; t++)
+ this._engine._releaseTexture(this._textures.data[t]);
+ this._textures.dispose();
+ }
+ }, r.prototype.setPrePassRenderer = function(t) {
+ return !!this._prePassEffectConfiguration && (this._prePassEffectConfiguration = t.addEffectConfiguration(this._prePassEffectConfiguration), this._prePassEffectConfiguration.enabled = !0, !0);
+ }, r.prototype.dispose = function(t) {
+ var e;
+ if (t = t || this._camera, this._disposeTextures(), this._scene && (e = this._scene.postProcesses.indexOf(this)) !== -1 && this._scene.postProcesses.splice(e, 1), (e = this._engine.postProcesses.indexOf(this)) !== -1 && this._engine.postProcesses.splice(e, 1), t) {
+ if (t.detachPostProcess(this), (e = t._postProcesses.indexOf(this)) === 0 && t._postProcesses.length > 0) {
+ var n = this._camera._getFirstPostProcess();
+ n && n.markTextureDirty();
+ }
+ this.onActivateObservable.clear(), this.onAfterRenderObservable.clear(), this.onApplyObservable.clear(), this.onBeforeRenderObservable.clear(), this.onSizeChangedObservable.clear();
+ }
+ }, r.prototype.serialize = function() {
+ var t = L.a.Serialize(this);
+ return t.customType = "BABYLON." + this.getClassName(), t.cameraId = this.getCamera().id, t.reusable = this._reusable, t.options = this._options, t.textureType = this._textureType, t;
+ }, r.Parse = function(t, e, n) {
+ var i = O.a.GetClass(t.customType);
+ if (!i || !i._Parse)
+ return null;
+ var o = e.getCameraByID(t.cameraId);
+ return o ? i._Parse(t, o, e, n) : null;
+ }, Object(c.c)([Object(L.c)()], r.prototype, "uniqueId", void 0), Object(c.c)([Object(L.c)()], r.prototype, "name", void 0), Object(c.c)([Object(L.c)()], r.prototype, "width", void 0), Object(c.c)([Object(L.c)()], r.prototype, "height", void 0), Object(c.c)([Object(L.c)()], r.prototype, "renderTargetSamplingMode", void 0), Object(c.c)([Object(L.f)()], r.prototype, "clearColor", void 0), Object(c.c)([Object(L.c)()], r.prototype, "autoClear", void 0), Object(c.c)([Object(L.c)()], r.prototype, "alphaMode", void 0), Object(c.c)([Object(L.c)()], r.prototype, "alphaConstants", void 0), Object(c.c)([Object(L.c)()], r.prototype, "enablePixelPerfectMode", void 0), Object(c.c)([Object(L.c)()], r.prototype, "forceFullscreenViewport", void 0), Object(c.c)([Object(L.c)()], r.prototype, "scaleMode", void 0), Object(c.c)([Object(L.c)()], r.prototype, "alwaysForcePOT", void 0), Object(c.c)([Object(L.c)("samples")], r.prototype, "_samples", void 0), Object(c.c)([Object(L.c)()], r.prototype, "adaptScaleToCurrentViewport", void 0), r;
+ }();
+ O.a.RegisteredTypes["BABYLON.PostProcess"] = ft;
+ var yf = `
+varying vec2 vUV;
+uniform sampler2D textureSampler;
+void main(void)
+{
+gl_FragColor=texture2D(textureSampler,vUV);
+}`;
+ ze.a.ShadersStore.passPixelShader = yf;
+ var bf = `
+varying vec2 vUV;
+uniform samplerCube textureSampler;
+void main(void)
+{
+vec2 uv=vUV*2.0-1.0;
+#ifdef POSITIVEX
+gl_FragColor=textureCube(textureSampler,vec3(1.001,uv.y,uv.x));
+#endif
+#ifdef NEGATIVEX
+gl_FragColor=textureCube(textureSampler,vec3(-1.001,uv.y,uv.x));
+#endif
+#ifdef POSITIVEY
+gl_FragColor=textureCube(textureSampler,vec3(uv.y,1.001,uv.x));
+#endif
+#ifdef NEGATIVEY
+gl_FragColor=textureCube(textureSampler,vec3(uv.y,-1.001,uv.x));
+#endif
+#ifdef POSITIVEZ
+gl_FragColor=textureCube(textureSampler,vec3(uv,1.001));
+#endif
+#ifdef NEGATIVEZ
+gl_FragColor=textureCube(textureSampler,vec3(uv,-1.001));
+#endif
+}`;
+ ze.a.ShadersStore.passCubePixelShader = bf;
+ var Ci = function(r) {
+ function t(e, n, i, o, a, s, d, p) {
+ return i === void 0 && (i = null), d === void 0 && (d = h.a.TEXTURETYPE_UNSIGNED_INT), p === void 0 && (p = !1), r.call(this, e, "pass", null, null, n, i, o, a, s, void 0, d, void 0, null, p) || this;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "PassPostProcess";
+ }, t._Parse = function(e, n, i, o) {
+ return L.a.Parse(function() {
+ return new t(e.name, e.options, n, e.renderTargetSamplingMode, i.getEngine(), e.reusable);
+ }, e, i, o);
+ }, t;
+ }(ft);
+ O.a.RegisteredTypes["BABYLON.PassPostProcess"] = Ci;
+ var Tf = function(r) {
+ function t(e, n, i, o, a, s, d, p) {
+ i === void 0 && (i = null), d === void 0 && (d = h.a.TEXTURETYPE_UNSIGNED_INT), p === void 0 && (p = !1);
+ var y = r.call(this, e, "passCube", null, null, n, i, o, a, s, "#define POSITIVEX", d, void 0, null, p) || this;
+ return y._face = 0, y;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "face", { get: function() {
+ return this._face;
+ }, set: function(e) {
+ if (!(e < 0 || e > 5))
+ switch (this._face = e, this._face) {
+ case 0:
+ this.updateEffect("#define POSITIVEX");
+ break;
+ case 1:
+ this.updateEffect("#define NEGATIVEX");
+ break;
+ case 2:
+ this.updateEffect("#define POSITIVEY");
+ break;
+ case 3:
+ this.updateEffect("#define NEGATIVEY");
+ break;
+ case 4:
+ this.updateEffect("#define POSITIVEZ");
+ break;
+ case 5:
+ this.updateEffect("#define NEGATIVEZ");
+ }
+ }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
+ return "PassCubePostProcess";
+ }, t._Parse = function(e, n, i, o) {
+ return L.a.Parse(function() {
+ return new t(e.name, e.options, n, e.renderTargetSamplingMode, i.getEngine(), e.reusable);
+ }, e, i, o);
+ }, t;
+ }(ft);
+ Ue.a._RescalePostProcessFactory = function(r) {
+ return new Ci("rescale", 1, null, h.a.TEXTURE_BILINEAR_SAMPLINGMODE, r, !1, h.a.TEXTURETYPE_UNSIGNED_INT);
+ };
+ var Ef = `
+varying vec2 vUV;
+uniform sampler2D textureSampler;
+uniform sampler2D leftSampler;
+void main(void)
+{
+vec4 leftFrag=texture2D(leftSampler,vUV);
+leftFrag=vec4(1.0,leftFrag.g,leftFrag.b,1.0);
+vec4 rightFrag=texture2D(textureSampler,vUV);
+rightFrag=vec4(rightFrag.r,1.0,1.0,1.0);
+gl_FragColor=vec4(rightFrag.rgb*leftFrag.rgb,1.0);
+}`;
+ ze.a.ShadersStore.anaglyphPixelShader = Ef;
+ var Ja = function(r) {
+ function t(e, n, i, o, a, s) {
+ var d = r.call(this, e, "anaglyph", null, ["leftSampler"], n, i[1], o, a, s) || this;
+ return d._passedProcess = i[0]._rigPostProcess, d.onApplyObservable.add(function(p) {
+ p.setTextureFromPostProcess("leftSampler", d._passedProcess);
+ }), d;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "AnaglyphPostProcess";
+ }, t;
+ }(ft);
+ O.a.RegisteredTypes["BABYLON.AnaglyphPostProcess"] = Ja, _t.a._setStereoscopicAnaglyphRigMode = function(r) {
+ r._rigCameras[0]._rigPostProcess = new Ci(r.name + "_passthru", 1, r._rigCameras[0]), r._rigCameras[1]._rigPostProcess = new Ja(r.name + "_anaglyph", 1, r._rigCameras);
+ }, Q.a.AddNodeConstructor("AnaglyphArcRotateCamera", function(r, t, e) {
+ return function() {
+ return new pl(r, 0, 0, 1, u.e.Zero(), e.interaxial_distance, t);
+ };
+ });
+ var pl = function(r) {
+ function t(e, n, i, o, a, s, d) {
+ var p = r.call(this, e, n, i, o, a, d) || this;
+ return p.interaxialDistance = s, p.setCameraRigMode(_t.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: s }), p;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "AnaglyphArcRotateCamera";
+ }, t;
+ }(ji);
+ Q.a.AddNodeConstructor("AnaglyphFreeCamera", function(r, t, e) {
+ return function() {
+ return new _l(r, u.e.Zero(), e.interaxial_distance, t);
+ };
+ });
+ var _l = function(r) {
+ function t(e, n, i, o) {
+ var a = r.call(this, e, n, o) || this;
+ return a.interaxialDistance = i, a.setCameraRigMode(_t.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: i }), a;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "AnaglyphFreeCamera";
+ }, t;
+ }(zn);
+ Q.a.AddNodeConstructor("AnaglyphGamepadCamera", function(r, t, e) {
+ return function() {
+ return new ml(r, u.e.Zero(), e.interaxial_distance, t);
+ };
+ });
+ var ml = function(r) {
+ function t(e, n, i, o) {
+ var a = r.call(this, e, n, o) || this;
+ return a.interaxialDistance = i, a.setCameraRigMode(_t.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: i }), a;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "AnaglyphGamepadCamera";
+ }, t;
+ }(Co);
+ Q.a.AddNodeConstructor("AnaglyphUniversalCamera", function(r, t, e) {
+ return function() {
+ return new gl(r, u.e.Zero(), e.interaxial_distance, t);
+ };
+ });
+ var gl = function(r) {
+ function t(e, n, i, o) {
+ var a = r.call(this, e, n, o) || this;
+ return a.interaxialDistance = i, a.setCameraRigMode(_t.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: i }), a;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "AnaglyphUniversalCamera";
+ }, t;
+ }(sr), jn = f(58);
+ _t.a._setStereoscopicRigMode = function(r) {
+ var t = r.cameraRigMode === _t.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL || r.cameraRigMode === _t.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED, e = r.cameraRigMode === _t.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
+ r._rigCameras[e ? 1 : 0].viewport = new jn.a(0, 0, t ? 0.5 : 1, t ? 1 : 0.5), r._rigCameras[e ? 0 : 1].viewport = new jn.a(t ? 0.5 : 0, t ? 0 : 0.5, t ? 0.5 : 1, t ? 1 : 0.5);
+ }, Q.a.AddNodeConstructor("StereoscopicArcRotateCamera", function(r, t, e) {
+ return function() {
+ return new vl(r, 0, 0, 1, u.e.Zero(), e.interaxial_distance, e.isStereoscopicSideBySide, t);
+ };
+ });
+ var vl = function(r) {
+ function t(e, n, i, o, a, s, d, p) {
+ var y = r.call(this, e, n, i, o, a, p) || this;
+ return y.interaxialDistance = s, y.isStereoscopicSideBySide = d, y.setCameraRigMode(d ? _t.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL : _t.a.RIG_MODE_STEREOSCOPIC_OVERUNDER, { interaxialDistance: s }), y;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "StereoscopicArcRotateCamera";
+ }, t;
+ }(ji);
+ Q.a.AddNodeConstructor("StereoscopicFreeCamera", function(r, t, e) {
+ return function() {
+ return new yl(r, u.e.Zero(), e.interaxial_distance, e.isStereoscopicSideBySide, t);
+ };
+ });
+ var yl = function(r) {
+ function t(e, n, i, o, a) {
+ var s = r.call(this, e, n, a) || this;
+ return s.interaxialDistance = i, s.isStereoscopicSideBySide = o, s.setCameraRigMode(o ? _t.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL : _t.a.RIG_MODE_STEREOSCOPIC_OVERUNDER, { interaxialDistance: i }), s;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "StereoscopicFreeCamera";
+ }, t;
+ }(zn);
+ Q.a.AddNodeConstructor("StereoscopicGamepadCamera", function(r, t, e) {
+ return function() {
+ return new bl(r, u.e.Zero(), e.interaxial_distance, e.isStereoscopicSideBySide, t);
+ };
+ });
+ var bl = function(r) {
+ function t(e, n, i, o, a) {
+ var s = r.call(this, e, n, a) || this;
+ return s.interaxialDistance = i, s.isStereoscopicSideBySide = o, s.setCameraRigMode(o ? _t.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL : _t.a.RIG_MODE_STEREOSCOPIC_OVERUNDER, { interaxialDistance: i }), s;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "StereoscopicGamepadCamera";
+ }, t;
+ }(Co);
+ Q.a.AddNodeConstructor("StereoscopicFreeCamera", function(r, t, e) {
+ return function() {
+ return new Tl(r, u.e.Zero(), e.interaxial_distance, e.isStereoscopicSideBySide, t);
+ };
+ });
+ var Tl = function(r) {
+ function t(e, n, i, o, a) {
+ var s = r.call(this, e, n, a) || this;
+ return s.interaxialDistance = i, s.isStereoscopicSideBySide = o, s.setCameraRigMode(o ? _t.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL : _t.a.RIG_MODE_STEREOSCOPIC_OVERUNDER, { interaxialDistance: i }), s;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "StereoscopicUniversalCamera";
+ }, t;
+ }(sr);
+ Q.a.AddNodeConstructor("VirtualJoysticksCamera", function(r, t) {
+ return function() {
+ return new El(r, u.e.Zero(), t);
+ };
+ });
+ var El = function(r) {
+ function t(e, n, i) {
+ var o = r.call(this, e, n, i) || this;
+ return o.inputs.addVirtualJoystick(), o;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "VirtualJoysticksCamera";
+ }, t;
+ }(zn), cr = function() {
+ function r() {
+ this.compensateDistortion = !0, this.multiviewEnabled = !1;
+ }
+ return Object.defineProperty(r.prototype, "aspectRatio", { get: function() {
+ return this.hResolution / (2 * this.vResolution);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "aspectRatioFov", { get: function() {
+ return 2 * Math.atan(this.postProcessScaleFactor * this.vScreenSize / (2 * this.eyeToScreenDistance));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "leftHMatrix", { get: function() {
+ var t = 4 * (this.hScreenSize / 4 - this.lensSeparationDistance / 2) / this.hScreenSize;
+ return u.a.Translation(t, 0, 0);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "rightHMatrix", { get: function() {
+ var t = 4 * (this.hScreenSize / 4 - this.lensSeparationDistance / 2) / this.hScreenSize;
+ return u.a.Translation(-t, 0, 0);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "leftPreViewMatrix", { get: function() {
+ return u.a.Translation(0.5 * this.interpupillaryDistance, 0, 0);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "rightPreViewMatrix", { get: function() {
+ return u.a.Translation(-0.5 * this.interpupillaryDistance, 0, 0);
+ }, enumerable: !1, configurable: !0 }), r.GetDefault = function() {
+ var t = new r();
+ return t.hResolution = 1280, t.vResolution = 800, t.hScreenSize = 0.149759993, t.vScreenSize = 0.0935999975, t.vScreenCenter = 0.0467999987, t.eyeToScreenDistance = 0.0410000011, t.lensSeparationDistance = 0.063500002, t.interpupillaryDistance = 0.064000003, t.distortionK = [1, 0.219999999, 0.239999995, 0], t.chromaAbCorrection = [0.995999992, -0.00400000019, 1.01400006, 0], t.postProcessScaleFactor = 1.714605507808412, t.lensCenterOffset = 0.151976421, t;
+ }, r;
+ }(), Sf = `
+varying vec2 vUV;
+uniform sampler2D textureSampler;
+uniform vec2 LensCenter;
+uniform vec2 Scale;
+uniform vec2 ScaleIn;
+uniform vec4 HmdWarpParam;
+vec2 HmdWarp(vec2 in01) {
+vec2 theta=(in01-LensCenter)*ScaleIn;
+float rSq=theta.x*theta.x+theta.y*theta.y;
+vec2 rvector=theta*(HmdWarpParam.x+HmdWarpParam.y*rSq+HmdWarpParam.z*rSq*rSq+HmdWarpParam.w*rSq*rSq*rSq);
+return LensCenter+Scale*rvector;
+}
+void main(void)
+{
+vec2 tc=HmdWarp(vUV);
+if (tc.x <0.0 || tc.x>1.0 || tc.y<0.0 || tc.y>1.0)
+gl_FragColor=vec4(0.0,0.0,0.0,0.0);
+else{
+gl_FragColor=texture2D(textureSampler,tc);
+}
+}`;
+ ze.a.ShadersStore.vrDistortionCorrectionPixelShader = Sf;
+ var $a = function(r) {
+ function t(e, n, i, o) {
+ var a = r.call(this, e, "vrDistortionCorrection", ["LensCenter", "Scale", "ScaleIn", "HmdWarpParam"], null, o.postProcessScaleFactor, n, Ne.a.BILINEAR_SAMPLINGMODE) || this;
+ return a._isRightEye = i, a._distortionFactors = o.distortionK, a._postProcessScaleFactor = o.postProcessScaleFactor, a._lensCenterOffset = o.lensCenterOffset, a.adaptScaleToCurrentViewport = !0, a.onSizeChangedObservable.add(function() {
+ a._scaleIn = new u.d(2, 2 / a.aspectRatio), a._scaleFactor = new u.d(1 / a._postProcessScaleFactor * 0.5, 1 / a._postProcessScaleFactor * 0.5 * a.aspectRatio), a._lensCenter = new u.d(a._isRightEye ? 0.5 - 0.5 * a._lensCenterOffset : 0.5 + 0.5 * a._lensCenterOffset, 0.5);
+ }), a.onApplyObservable.add(function(s) {
+ s.setFloat2("LensCenter", a._lensCenter.x, a._lensCenter.y), s.setFloat2("Scale", a._scaleFactor.x, a._scaleFactor.y), s.setFloat2("ScaleIn", a._scaleIn.x, a._scaleIn.y), s.setFloat4("HmdWarpParam", a._distortionFactors[0], a._distortionFactors[1], a._distortionFactors[2], a._distortionFactors[3]);
+ }), a;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "VRDistortionCorrectionPostProcess";
+ }, t;
+ }(ft), Af = `precision mediump sampler2DArray;
+varying vec2 vUV;
+uniform sampler2DArray multiviewSampler;
+uniform int imageIndex;
+void main(void)
+{
+gl_FragColor=texture(multiviewSampler,vec3(vUV,imageIndex));
+}`;
+ ze.a.ShadersStore.vrMultiviewToSingleviewPixelShader = Af;
+ var Sl = f(85), es = f(95), Hr = f(96);
+ wt.a.prototype.createRenderTargetCubeTexture = function(r, t) {
+ var e = Object(c.a)({ generateMipMaps: !0, generateDepthBuffer: !0, generateStencilBuffer: !1, type: h.a.TEXTURETYPE_UNSIGNED_INT, samplingMode: h.a.TEXTURE_TRILINEAR_SAMPLINGMODE, format: h.a.TEXTUREFORMAT_RGBA }, t);
+ e.generateStencilBuffer = e.generateDepthBuffer && e.generateStencilBuffer, (e.type !== h.a.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering) && (e.type !== h.a.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering) || (e.samplingMode = h.a.TEXTURE_NEAREST_SAMPLINGMODE);
+ var n = this._gl, i = new Pt.a(this, Pt.b.RenderTarget);
+ this._bindTextureDirectly(n.TEXTURE_CUBE_MAP, i, !0);
+ var o = this._getSamplingParameters(e.samplingMode, e.generateMipMaps);
+ e.type !== h.a.TEXTURETYPE_FLOAT || this._caps.textureFloat || (e.type = h.a.TEXTURETYPE_UNSIGNED_INT, l.a.Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type")), n.texParameteri(n.TEXTURE_CUBE_MAP, n.TEXTURE_MAG_FILTER, o.mag), n.texParameteri(n.TEXTURE_CUBE_MAP, n.TEXTURE_MIN_FILTER, o.min), n.texParameteri(n.TEXTURE_CUBE_MAP, n.TEXTURE_WRAP_S, n.CLAMP_TO_EDGE), n.texParameteri(n.TEXTURE_CUBE_MAP, n.TEXTURE_WRAP_T, n.CLAMP_TO_EDGE);
+ for (var a = 0; a < 6; a++)
+ n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + a, 0, this._getRGBABufferInternalSizedFormat(e.type, e.format), r, r, 0, this._getInternalFormat(e.format), this._getWebGLTextureType(e.type), null);
+ var s = n.createFramebuffer();
+ return this._bindUnboundFramebuffer(s), i._depthStencilBuffer = this._setupFramebufferDepthAttachments(e.generateStencilBuffer, e.generateDepthBuffer, r, r), e.generateMipMaps && n.generateMipmap(n.TEXTURE_CUBE_MAP), this._bindTextureDirectly(n.TEXTURE_CUBE_MAP, null), this._bindUnboundFramebuffer(null), i._framebuffer = s, i.width = r, i.height = r, i.isReady = !0, i.isCube = !0, i.samples = 1, i.generateMipMaps = e.generateMipMaps, i.samplingMode = e.samplingMode, i.type = e.type, i.format = e.format, i._generateDepthBuffer = e.generateDepthBuffer, i._generateStencilBuffer = e.generateStencilBuffer, this._internalTexturesCache.push(i), i;
+ };
+ var on = function(r) {
+ function t(e, n, i, o, a, s, d, p, y, P, R, B, F) {
+ a === void 0 && (a = !0), s === void 0 && (s = h.a.TEXTURETYPE_UNSIGNED_INT), d === void 0 && (d = !1), p === void 0 && (p = Ne.a.TRILINEAR_SAMPLINGMODE), y === void 0 && (y = !0), P === void 0 && (P = !1), R === void 0 && (R = !1), B === void 0 && (B = h.a.TEXTUREFORMAT_RGBA), F === void 0 && (F = !1);
+ var z = r.call(this, null, i, !o) || this;
+ return z.renderParticles = !0, z.renderSprites = !1, z.ignoreCameraViewport = !1, z.onBeforeBindObservable = new C.c(), z.onAfterUnbindObservable = new C.c(), z.onBeforeRenderObservable = new C.c(), z.onAfterRenderObservable = new C.c(), z.onClearObservable = new C.c(), z.onResizeObservable = new C.c(), z._currentRefreshId = -1, z._refreshRate = 1, z._samples = 1, z.boundingBoxPosition = u.e.Zero(), (i = z.getScene()) && (z._coordinatesMode = Ne.a.PROJECTION_MODE, z.renderList = new Array(), z.name = e, z.isRenderTarget = !0, z._initialSizeParameter = n, z._processSizeParameter(n), z._resizeObserver = z.getScene().getEngine().onResizeObservable.add(function() {
+ }), z._generateMipMaps = !!o, z._doNotChangeAspectRatio = a, z._renderingManager = new Hr.b(i), z._renderingManager._useSceneAutoClearSetup = !0, R || (z._renderTargetOptions = { generateMipMaps: o, type: s, format: B, samplingMode: p, generateDepthBuffer: y, generateStencilBuffer: P }, p === Ne.a.NEAREST_SAMPLINGMODE && (z.wrapU = Ne.a.CLAMP_ADDRESSMODE, z.wrapV = Ne.a.CLAMP_ADDRESSMODE), F || (d ? (z._texture = i.getEngine().createRenderTargetCubeTexture(z.getRenderSize(), z._renderTargetOptions), z.coordinatesMode = Ne.a.INVCUBIC_MODE, z._textureMatrix = u.a.Identity()) : z._texture = i.getEngine().createRenderTargetTexture(z._size, z._renderTargetOptions)))), z;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "renderList", { get: function() {
+ return this._renderList;
+ }, set: function(e) {
+ this._renderList = e, this._renderList && this._hookArray(this._renderList);
+ }, enumerable: !1, configurable: !0 }), t.prototype._hookArray = function(e) {
+ var n = this, i = e.push;
+ e.push = function() {
+ for (var a = [], s = 0; s < arguments.length; s++)
+ a[s] = arguments[s];
+ var d = e.length === 0, p = i.apply(e, a);
+ return d && n.getScene() && n.getScene().meshes.forEach(function(y) {
+ y._markSubMeshesAsLightDirty();
+ }), p;
+ };
+ var o = e.splice;
+ e.splice = function(a, s) {
+ var d = o.apply(e, [a, s]);
+ return e.length === 0 && n.getScene().meshes.forEach(function(p) {
+ p._markSubMeshesAsLightDirty();
+ }), d;
+ };
+ }, Object.defineProperty(t.prototype, "onAfterUnbind", { set: function(e) {
+ this._onAfterUnbindObserver && this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver), this._onAfterUnbindObserver = this.onAfterUnbindObservable.add(e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onBeforeRender", { set: function(e) {
+ this._onBeforeRenderObserver && this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver), this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onAfterRender", { set: function(e) {
+ this._onAfterRenderObserver && this.onAfterRenderObservable.remove(this._onAfterRenderObserver), this._onAfterRenderObserver = this.onAfterRenderObservable.add(e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onClear", { set: function(e) {
+ this._onClearObserver && this.onClearObservable.remove(this._onClearObserver), this._onClearObserver = this.onClearObservable.add(e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "renderTargetOptions", { get: function() {
+ return this._renderTargetOptions;
+ }, enumerable: !1, configurable: !0 }), t.prototype._onRatioRescale = function() {
+ this._sizeRatio && this.resize(this._initialSizeParameter);
+ }, Object.defineProperty(t.prototype, "boundingBoxSize", { get: function() {
+ return this._boundingBoxSize;
+ }, set: function(e) {
+ if (!this._boundingBoxSize || !this._boundingBoxSize.equals(e)) {
+ this._boundingBoxSize = e;
+ var n = this.getScene();
+ n && n.markAllMaterialsAsDirty(h.a.MATERIAL_TextureDirtyFlag);
+ }
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "depthStencilTexture", { get: function() {
+ var e;
+ return ((e = this.getInternalTexture()) === null || e === void 0 ? void 0 : e._depthStencilTexture) || null;
+ }, enumerable: !1, configurable: !0 }), t.prototype.createDepthStencilTexture = function(e, n, i) {
+ e === void 0 && (e = 0), n === void 0 && (n = !0), i === void 0 && (i = !1);
+ var o = this.getInternalTexture();
+ if (this.getScene() && o) {
+ var a = this.getScene().getEngine();
+ o._depthStencilTexture = a.createDepthStencilTexture(this._size, { bilinearFiltering: n, comparisonFunction: e, generateStencil: i, isCube: this.isCube });
+ }
+ }, t.prototype._processSizeParameter = function(e) {
+ if (e.ratio) {
+ this._sizeRatio = e.ratio;
+ var n = this._getEngine();
+ this._size = { width: this._bestReflectionRenderTargetDimension(n.getRenderWidth(), this._sizeRatio), height: this._bestReflectionRenderTargetDimension(n.getRenderHeight(), this._sizeRatio) };
+ } else
+ this._size = e;
+ }, Object.defineProperty(t.prototype, "samples", { get: function() {
+ return this._samples;
+ }, set: function(e) {
+ if (this._samples !== e) {
+ var n = this.getScene();
+ n && (this._samples = n.getEngine().updateRenderTargetTextureSampleCount(this._texture, e));
+ }
+ }, enumerable: !1, configurable: !0 }), t.prototype.resetRefreshCounter = function() {
+ this._currentRefreshId = -1;
+ }, Object.defineProperty(t.prototype, "refreshRate", { get: function() {
+ return this._refreshRate;
+ }, set: function(e) {
+ this._refreshRate = e, this.resetRefreshCounter();
+ }, enumerable: !1, configurable: !0 }), t.prototype.addPostProcess = function(e) {
+ if (!this._postProcessManager) {
+ var n = this.getScene();
+ if (!n)
+ return;
+ this._postProcessManager = new es.a(n), this._postProcesses = new Array();
+ }
+ this._postProcesses.push(e), this._postProcesses[0].autoClear = !1;
+ }, t.prototype.clearPostProcesses = function(e) {
+ if (e === void 0 && (e = !1), this._postProcesses) {
+ if (e)
+ for (var n = 0, i = this._postProcesses; n < i.length; n++)
+ i[n].dispose();
+ this._postProcesses = [];
+ }
+ }, t.prototype.removePostProcess = function(e) {
+ if (this._postProcesses) {
+ var n = this._postProcesses.indexOf(e);
+ n !== -1 && (this._postProcesses.splice(n, 1), this._postProcesses.length > 0 && (this._postProcesses[0].autoClear = !1));
+ }
+ }, t.prototype._shouldRender = function() {
+ return this._currentRefreshId === -1 || this.refreshRate === this._currentRefreshId ? (this._currentRefreshId = 1, !0) : (this._currentRefreshId++, !1);
+ }, t.prototype.getRenderSize = function() {
+ return this.getRenderWidth();
+ }, t.prototype.getRenderWidth = function() {
+ return this._size.width ? this._size.width : this._size;
+ }, t.prototype.getRenderHeight = function() {
+ return this._size.width ? this._size.height : this._size;
+ }, t.prototype.getRenderLayers = function() {
+ var e = this._size.layers;
+ return e || 0;
+ }, Object.defineProperty(t.prototype, "canRescale", { get: function() {
+ return !0;
+ }, enumerable: !1, configurable: !0 }), t.prototype.scale = function(e) {
+ var n = Math.max(1, this.getRenderSize() * e);
+ this.resize(n);
+ }, t.prototype.getReflectionTextureMatrix = function() {
+ return this.isCube ? this._textureMatrix : r.prototype.getReflectionTextureMatrix.call(this);
+ }, t.prototype.resize = function(e) {
+ var n = this.isCube;
+ this.releaseInternalTexture();
+ var i = this.getScene();
+ i && (this._processSizeParameter(e), this._texture = n ? i.getEngine().createRenderTargetCubeTexture(this.getRenderSize(), this._renderTargetOptions) : i.getEngine().createRenderTargetTexture(this._size, this._renderTargetOptions), this.onResizeObservable.hasObservers() && this.onResizeObservable.notifyObservers(this));
+ }, t.prototype.render = function(e, n) {
+ if (e === void 0 && (e = !1), n === void 0 && (n = !1), p = this.getScene()) {
+ var i, o = p.getEngine();
+ if (this.useCameraPostProcesses !== void 0 && (e = this.useCameraPostProcesses), this._waitingRenderList) {
+ this.renderList = [];
+ for (var a = 0; a < this._waitingRenderList.length; a++) {
+ var s = this._waitingRenderList[a], d = p.getMeshByID(s);
+ d && this.renderList.push(d);
+ }
+ this._waitingRenderList = void 0;
+ }
+ if (this.renderListPredicate) {
+ var p;
+ if (this.renderList ? this.renderList.length = 0 : this.renderList = [], !(p = this.getScene()))
+ return;
+ var y = p.meshes;
+ for (a = 0; a < y.length; a++) {
+ var P = y[a];
+ this.renderListPredicate(P) && this.renderList.push(P);
+ }
+ }
+ if (this.onBeforeBindObservable.notifyObservers(this), this.activeCamera ? (i = this.activeCamera, o.setViewport(this.activeCamera.viewport, this.getRenderWidth(), this.getRenderHeight()), this.activeCamera !== p.activeCamera && p.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(!0))) : (i = p.activeCamera) && o.setViewport(i.viewport, this.getRenderWidth(), this.getRenderHeight()), this._defaultRenderListPrepared = !1, this.is2DArray)
+ for (var R = 0; R < this.getRenderLayers(); R++)
+ this.renderToTarget(0, e, n, R, i), p.incrementRenderId(), p.resetCachedMaterial();
+ else if (this.isCube)
+ for (var B = 0; B < 6; B++)
+ this.renderToTarget(B, e, n, void 0, i), p.incrementRenderId(), p.resetCachedMaterial();
+ else
+ this.renderToTarget(0, e, n, void 0, i);
+ this.onAfterUnbindObservable.notifyObservers(this), p.activeCamera && ((p.getEngine().scenes.length > 1 || this.activeCamera && this.activeCamera !== p.activeCamera) && p.setTransformMatrix(p.activeCamera.getViewMatrix(), p.activeCamera.getProjectionMatrix(!0)), o.setViewport(p.activeCamera.viewport)), p.resetCachedMaterial();
+ }
+ }, t.prototype._bestReflectionRenderTargetDimension = function(e, n) {
+ var i = e * n, o = Ue.a.NearestPOT(i + 16384 / (128 + i));
+ return Math.min(Ue.a.FloorPOT(e), o);
+ }, t.prototype._prepareRenderingManager = function(e, n, i, o) {
+ var a = this.getScene();
+ if (a) {
+ this._renderingManager.reset();
+ for (var s = a.getRenderId(), d = 0; d < n; d++) {
+ var p = e[d];
+ if (p && !p.isBlocked) {
+ if (this.customIsReadyFunction) {
+ if (!this.customIsReadyFunction(p, this.refreshRate)) {
+ this.resetRefreshCounter();
+ continue;
+ }
+ } else if (!p.isReady(this.refreshRate === 0)) {
+ this.resetRefreshCounter();
+ continue;
+ }
+ if (!p._internalAbstractMeshDataInfo._currentLODIsUpToDate && a.activeCamera && (p._internalAbstractMeshDataInfo._currentLOD = a.customLODSelector ? a.customLODSelector(p, a.activeCamera) : p.getLOD(a.activeCamera), p._internalAbstractMeshDataInfo._currentLODIsUpToDate = !0), !p._internalAbstractMeshDataInfo._currentLOD)
+ continue;
+ var y = p._internalAbstractMeshDataInfo._currentLOD;
+ y._preActivateForIntermediateRendering(s);
+ var P = void 0;
+ if (P = !(!o || !i) && (p.layerMask & i.layerMask) == 0, p.isEnabled() && p.isVisible && p.subMeshes && !P && (y !== p && y._activate(s, !0), p._activate(s, !0) && p.subMeshes.length)) {
+ p.isAnInstance ? p._internalAbstractMeshDataInfo._actAsRegularMesh && (y = p) : y._internalAbstractMeshDataInfo._onlyForInstancesIntermediate = !1, y._internalAbstractMeshDataInfo._isActiveIntermediate = !0;
+ for (var R = 0; R < y.subMeshes.length; R++) {
+ var B = y.subMeshes[R];
+ this._renderingManager.dispatch(B, y);
+ }
+ }
+ }
+ }
+ for (var F = 0; F < a.particleSystems.length; F++) {
+ var z = a.particleSystems[F], J = z.emitter;
+ z.isStarted() && J && J.position && J.isEnabled() && e.indexOf(J) >= 0 && this._renderingManager.dispatchParticles(z);
+ }
+ }
+ }, t.prototype._bindFrameBuffer = function(e, n) {
+ e === void 0 && (e = 0), n === void 0 && (n = 0);
+ var i = this.getScene();
+ if (i) {
+ var o = i.getEngine();
+ this._texture && o.bindFramebuffer(this._texture, this.isCube ? e : void 0, void 0, void 0, this.ignoreCameraViewport, 0, n);
+ }
+ }, t.prototype.unbindFrameBuffer = function(e, n) {
+ var i = this;
+ this._texture && e.unBindFramebuffer(this._texture, this.isCube, function() {
+ i.onAfterRenderObservable.notifyObservers(n);
+ });
+ }, t.prototype.renderToTarget = function(e, n, i, o, a) {
+ o === void 0 && (o = 0), a === void 0 && (a = null);
+ var s = this.getScene();
+ if (s) {
+ var d = s.getEngine();
+ if (this._texture) {
+ this._postProcessManager ? this._postProcessManager._prepareFrame(this._texture, this._postProcesses) : n && s.postProcessManager._prepareFrame(this._texture) || this._bindFrameBuffer(e, o), this.is2DArray ? this.onBeforeRenderObservable.notifyObservers(o) : this.onBeforeRenderObservable.notifyObservers(e);
+ var p = null, y = this.renderList ? this.renderList : s.getActiveMeshes().data, P = this.renderList ? this.renderList.length : s.getActiveMeshes().length;
+ this.getCustomRenderList && (p = this.getCustomRenderList(this.is2DArray ? o : e, y, P)), p ? this._prepareRenderingManager(p, p.length, a, !1) : (this._defaultRenderListPrepared || (this._prepareRenderingManager(y, P, a, !this.renderList), this._defaultRenderListPrepared = !0), p = y), this.onClearObservable.hasObservers() ? this.onClearObservable.notifyObservers(d) : d.clear(this.clearColor || s.clearColor, !0, !0, !0), this._doNotChangeAspectRatio || s.updateTransformMatrix(!0);
+ for (var R = 0, B = s._beforeRenderTargetDrawStage; R < B.length; R++)
+ B[R].action(this);
+ this._renderingManager.render(this.customRenderFunction, p, this.renderParticles, this.renderSprites);
+ for (var F = 0, z = s._afterRenderTargetDrawStage; F < z.length; F++)
+ z[F].action(this);
+ this._postProcessManager ? this._postProcessManager._finalizeFrame(!1, this._texture, e, this._postProcesses, this.ignoreCameraViewport) : n && s.postProcessManager._finalizeFrame(!1, this._texture, e), this._doNotChangeAspectRatio || s.updateTransformMatrix(!0), i && Xe.b.DumpFramebuffer(this.getRenderWidth(), this.getRenderHeight(), d), this.isCube && e !== 5 ? this.onAfterRenderObservable.notifyObservers(e) : (this.isCube && e === 5 && d.generateMipMapsForCubemap(this._texture), this.unbindFrameBuffer(d, e));
+ }
+ }
+ }, t.prototype.setRenderingOrder = function(e, n, i, o) {
+ n === void 0 && (n = null), i === void 0 && (i = null), o === void 0 && (o = null), this._renderingManager.setRenderingOrder(e, n, i, o);
+ }, t.prototype.setRenderingAutoClearDepthStencil = function(e, n) {
+ this._renderingManager.setRenderingAutoClearDepthStencil(e, n), this._renderingManager._useSceneAutoClearSetup = !1;
+ }, t.prototype.clone = function() {
+ var e = this.getSize(), n = new t(this.name, e, this.getScene(), this._renderTargetOptions.generateMipMaps, this._doNotChangeAspectRatio, this._renderTargetOptions.type, this.isCube, this._renderTargetOptions.samplingMode, this._renderTargetOptions.generateDepthBuffer, this._renderTargetOptions.generateStencilBuffer);
+ return n.hasAlpha = this.hasAlpha, n.level = this.level, n.coordinatesMode = this.coordinatesMode, this.renderList && (n.renderList = this.renderList.slice(0)), n;
+ }, t.prototype.serialize = function() {
+ if (!this.name)
+ return null;
+ var e = r.prototype.serialize.call(this);
+ if (e.renderTargetSize = this.getRenderSize(), e.renderList = [], this.renderList)
+ for (var n = 0; n < this.renderList.length; n++)
+ e.renderList.push(this.renderList[n].id);
+ return e;
+ }, t.prototype.disposeFramebufferObjects = function() {
+ var e = this.getInternalTexture(), n = this.getScene();
+ e && n && n.getEngine()._releaseFramebufferObjects(e);
+ }, t.prototype.dispose = function() {
+ this.onResizeObservable.clear(), this.onClearObservable.clear(), this.onAfterRenderObservable.clear(), this.onAfterUnbindObservable.clear(), this.onBeforeBindObservable.clear(), this.onBeforeRenderObservable.clear(), this._postProcessManager && (this._postProcessManager.dispose(), this._postProcessManager = null), this.clearPostProcesses(!0), this._resizeObserver && (this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver), this._resizeObserver = null), this.renderList = null;
+ var e = this.getScene();
+ if (e) {
+ var n = e.customRenderTargets.indexOf(this);
+ n >= 0 && e.customRenderTargets.splice(n, 1);
+ for (var i = 0, o = e.cameras; i < o.length; i++) {
+ var a = o[i];
+ (n = a.customRenderTargets.indexOf(this)) >= 0 && a.customRenderTargets.splice(n, 1);
+ }
+ this.depthStencilTexture && this.getScene().getEngine()._releaseTexture(this.depthStencilTexture), r.prototype.dispose.call(this);
+ }
+ }, t.prototype._rebuild = function() {
+ this.refreshRate === t.REFRESHRATE_RENDER_ONCE && (this.refreshRate = t.REFRESHRATE_RENDER_ONCE), this._postProcessManager && this._postProcessManager._rebuild();
+ }, t.prototype.freeRenderingGroups = function() {
+ this._renderingManager && this._renderingManager.freeRenderingGroups();
+ }, t.prototype.getViewCount = function() {
+ return 1;
+ }, t.REFRESHRATE_RENDER_ONCE = 0, t.REFRESHRATE_RENDER_ONEVERYFRAME = 1, t.REFRESHRATE_RENDER_ONEVERYTWOFRAMES = 2, t;
+ }(Ne.a);
+ Ne.a._CreateRenderTargetTexture = function(r, t, e, n) {
+ return new on(r, t, e, n);
+ };
+ var Al = function(r) {
+ function t(e, n) {
+ n === void 0 && (n = 512);
+ var i = r.call(this, "multiview rtt", n, e, !1, !0, Pt.b.Unknown, !1, void 0, !1, !1, !0, void 0, !0) || this, o = e.getEngine().createMultiviewRenderTargetTexture(i.getRenderWidth(), i.getRenderHeight());
+ return o.isMultiview = !0, o.format = h.a.TEXTUREFORMAT_RGBA, i._texture = o, i.samples = i._getEngine().getCaps().maxSamples || i.samples, i;
+ }
+ return Object(c.d)(t, r), t.prototype._bindFrameBuffer = function(e) {
+ this._texture && this.getScene().getEngine().bindMultiviewFramebuffer(this._texture);
+ }, t.prototype.getViewCount = function() {
+ return 2;
+ }, t;
+ }(on), Pl = f(90);
+ Ue.a.prototype.createMultiviewRenderTargetTexture = function(r, t) {
+ var e = this._gl;
+ if (!this.getCaps().multiview)
+ throw "Multiview is not supported";
+ var n = new Pt.a(this, Pt.b.Unknown, !0);
+ return n.width = r, n.height = t, n._framebuffer = e.createFramebuffer(), n._colorTextureArray = e.createTexture(), e.bindTexture(e.TEXTURE_2D_ARRAY, n._colorTextureArray), e.texStorage3D(e.TEXTURE_2D_ARRAY, 1, e.RGBA8, r, t, 2), n._depthStencilTextureArray = e.createTexture(), e.bindTexture(e.TEXTURE_2D_ARRAY, n._depthStencilTextureArray), e.texStorage3D(e.TEXTURE_2D_ARRAY, 1, e.DEPTH32F_STENCIL8, r, t, 2), n.isReady = !0, n;
+ }, Ue.a.prototype.bindMultiviewFramebuffer = function(r) {
+ var t = this._gl, e = this.getCaps().oculusMultiview || this.getCaps().multiview;
+ if (this.bindFramebuffer(r, void 0, void 0, void 0, !0), t.bindFramebuffer(t.DRAW_FRAMEBUFFER, r._framebuffer), !r._colorTextureArray || !r._depthStencilTextureArray)
+ throw "Invalid multiview frame buffer";
+ this.getCaps().oculusMultiview ? (e.framebufferTextureMultisampleMultiviewOVR(t.DRAW_FRAMEBUFFER, t.COLOR_ATTACHMENT0, r._colorTextureArray, 0, r.samples, 0, 2), e.framebufferTextureMultisampleMultiviewOVR(t.DRAW_FRAMEBUFFER, t.DEPTH_STENCIL_ATTACHMENT, r._depthStencilTextureArray, 0, r.samples, 0, 2)) : (e.framebufferTextureMultiviewOVR(t.DRAW_FRAMEBUFFER, t.COLOR_ATTACHMENT0, r._colorTextureArray, 0, 0, 2), e.framebufferTextureMultiviewOVR(t.DRAW_FRAMEBUFFER, t.DEPTH_STENCIL_ATTACHMENT, r._depthStencilTextureArray, 0, 0, 2));
+ }, _t.a.prototype._useMultiviewToSingleView = !1, _t.a.prototype._multiviewTexture = null, _t.a.prototype._resizeOrCreateMultiviewTexture = function(r, t) {
+ this._multiviewTexture ? this._multiviewTexture.getRenderWidth() == r && this._multiviewTexture.getRenderHeight() == t || (this._multiviewTexture.dispose(), this._multiviewTexture = new Al(this.getScene(), { width: r, height: t })) : this._multiviewTexture = new Al(this.getScene(), { width: r, height: t });
+ }, _e.a.prototype._transformMatrixR = u.a.Zero(), _e.a.prototype._multiviewSceneUbo = null, _e.a.prototype._createMultiviewUbo = function() {
+ this._multiviewSceneUbo = new Sl.a(this.getEngine(), void 0, !0), this._multiviewSceneUbo.addUniform("viewProjection", 16), this._multiviewSceneUbo.addUniform("viewProjectionR", 16), this._multiviewSceneUbo.addUniform("view", 16);
+ }, _e.a.prototype._updateMultiviewUbo = function(r, t) {
+ r && t && r.multiplyToRef(t, this._transformMatrixR), r && t && (r.multiplyToRef(t, u.c.Matrix[0]), Pl.a.GetRightPlaneToRef(u.c.Matrix[0], this._frustumPlanes[3])), this._multiviewSceneUbo && (this._multiviewSceneUbo.updateMatrix("viewProjection", this.getTransformMatrix()), this._multiviewSceneUbo.updateMatrix("viewProjectionR", this._transformMatrixR), this._multiviewSceneUbo.updateMatrix("view", this._viewMatrix), this._multiviewSceneUbo.update());
+ }, _e.a.prototype._renderMultiviewToSingleView = function(r) {
+ r._resizeOrCreateMultiviewTexture(r._rigPostProcess && r._rigPostProcess && r._rigPostProcess.width > 0 ? r._rigPostProcess.width : this.getEngine().getRenderWidth(!0), r._rigPostProcess && r._rigPostProcess && r._rigPostProcess.height > 0 ? r._rigPostProcess.height : this.getEngine().getRenderHeight(!0)), this._multiviewSceneUbo || this._createMultiviewUbo(), r.outputRenderTarget = r._multiviewTexture, this._renderForCamera(r), r.outputRenderTarget = null;
+ for (var t = 0; t < r._rigCameras.length; t++) {
+ var e = this.getEngine();
+ this._activeCamera = r._rigCameras[t], e.setViewport(this._activeCamera.viewport), this.postProcessManager && (this.postProcessManager._prepareFrame(), this.postProcessManager._finalizeFrame(this._activeCamera.isIntermediate));
+ }
+ };
+ var ts = function(r) {
+ function t(e, n, i) {
+ var o = r.call(this, e, "vrMultiviewToSingleview", ["imageIndex"], ["multiviewSampler"], i, n, Ne.a.BILINEAR_SAMPLINGMODE) || this;
+ return o.onSizeChangedObservable.add(function() {
+ }), o.onApplyObservable.add(function(a) {
+ n._scene.activeCamera && n._scene.activeCamera.isLeftCamera ? a.setInt("imageIndex", 0) : a.setInt("imageIndex", 1), a.setTexture("multiviewSampler", n._multiviewTexture);
+ }), o;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "VRMultiviewToSingleviewPostProcess";
+ }, t;
+ }(ft);
+ _t.a._setVRRigMode = function(r, t) {
+ var e = t.vrCameraMetrics || cr.GetDefault();
+ r._rigCameras[0]._cameraRigParams.vrMetrics = e, r._rigCameras[0].viewport = new jn.a(0, 0, 0.5, 1), r._rigCameras[0]._cameraRigParams.vrWorkMatrix = new u.a(), r._rigCameras[0]._cameraRigParams.vrHMatrix = e.leftHMatrix, r._rigCameras[0]._cameraRigParams.vrPreViewMatrix = e.leftPreViewMatrix, r._rigCameras[0].getProjectionMatrix = r._rigCameras[0]._getVRProjectionMatrix, r._rigCameras[1]._cameraRigParams.vrMetrics = e, r._rigCameras[1].viewport = new jn.a(0.5, 0, 0.5, 1), r._rigCameras[1]._cameraRigParams.vrWorkMatrix = new u.a(), r._rigCameras[1]._cameraRigParams.vrHMatrix = e.rightHMatrix, r._rigCameras[1]._cameraRigParams.vrPreViewMatrix = e.rightPreViewMatrix, r._rigCameras[1].getProjectionMatrix = r._rigCameras[1]._getVRProjectionMatrix, e.multiviewEnabled && (r.getScene().getEngine().getCaps().multiview ? (r._useMultiviewToSingleView = !0, r._rigPostProcess = new ts("VRMultiviewToSingleview", r, e.postProcessScaleFactor)) : (l.a.Warn("Multiview is not supported, falling back to standard rendering"), e.multiviewEnabled = !1)), e.compensateDistortion && (r._rigCameras[0]._rigPostProcess = new $a("VR_Distort_Compensation_Left", r._rigCameras[0], !1, e), r._rigCameras[1]._rigPostProcess = new $a("VR_Distort_Compensation_Right", r._rigCameras[1], !0, e));
+ }, Q.a.AddNodeConstructor("VRDeviceOrientationFreeCamera", function(r, t) {
+ return function() {
+ return new xl(r, 0, 0, 1, u.e.Zero(), t);
+ };
+ });
+ var xl = function(r) {
+ function t(e, n, i, o, a, s, d, p) {
+ d === void 0 && (d = !0), p === void 0 && (p = cr.GetDefault());
+ var y = r.call(this, e, n, i, o, a, s) || this;
+ return p.compensateDistortion = d, y.setCameraRigMode(_t.a.RIG_MODE_VR, { vrCameraMetrics: p }), y.inputs.addVRDeviceOrientation(), y;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "VRDeviceOrientationArcRotateCamera";
+ }, t;
+ }(ji);
+ Q.a.AddNodeConstructor("VRDeviceOrientationFreeCamera", function(r, t) {
+ return function() {
+ return new Ro(r, u.e.Zero(), t);
+ };
+ });
+ var Ro = function(r) {
+ function t(e, n, i, o, a) {
+ o === void 0 && (o = !0), a === void 0 && (a = cr.GetDefault());
+ var s = r.call(this, e, n, i) || this;
+ return a.compensateDistortion = o, s.setCameraRigMode(_t.a.RIG_MODE_VR, { vrCameraMetrics: a }), s;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "VRDeviceOrientationFreeCamera";
+ }, t;
+ }(xo);
+ Q.a.AddNodeConstructor("VRDeviceOrientationGamepadCamera", function(r, t) {
+ return function() {
+ return new Cl(r, u.e.Zero(), t);
+ };
+ });
+ var Cl = function(r) {
+ function t(e, n, i, o, a) {
+ o === void 0 && (o = !0), a === void 0 && (a = cr.GetDefault());
+ var s = r.call(this, e, n, i, o, a) || this;
+ return s.inputs.addGamepad(), s;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "VRDeviceOrientationGamepadCamera";
+ }, t;
+ }(Ro), Oo = f(86);
+ _t.a._setWebVRRigMode = function(r, t) {
+ if (t.vrDisplay) {
+ var e = t.vrDisplay.getEyeParameters("left"), n = t.vrDisplay.getEyeParameters("right");
+ r._rigCameras[0].viewport = new jn.a(0, 0, 0.5, 1), r._rigCameras[0].setCameraRigParameter("left", !0), r._rigCameras[0].setCameraRigParameter("specs", t.specs), r._rigCameras[0].setCameraRigParameter("eyeParameters", e), r._rigCameras[0].setCameraRigParameter("frameData", t.frameData), r._rigCameras[0].setCameraRigParameter("parentCamera", t.parentCamera), r._rigCameras[0]._cameraRigParams.vrWorkMatrix = new u.a(), r._rigCameras[0].getProjectionMatrix = r._getWebVRProjectionMatrix, r._rigCameras[0].parent = r, r._rigCameras[0]._getViewMatrix = r._getWebVRViewMatrix, r._rigCameras[1].viewport = new jn.a(0.5, 0, 0.5, 1), r._rigCameras[1].setCameraRigParameter("eyeParameters", n), r._rigCameras[1].setCameraRigParameter("specs", t.specs), r._rigCameras[1].setCameraRigParameter("frameData", t.frameData), r._rigCameras[1].setCameraRigParameter("parentCamera", t.parentCamera), r._rigCameras[1]._cameraRigParams.vrWorkMatrix = new u.a(), r._rigCameras[1].getProjectionMatrix = r._getWebVRProjectionMatrix, r._rigCameras[1].parent = r, r._rigCameras[1]._getViewMatrix = r._getWebVRViewMatrix;
+ }
+ }, Object.defineProperty(Ue.a.prototype, "isInVRExclusivePointerMode", { get: function() {
+ return this._vrExclusivePointerMode;
+ }, enumerable: !0, configurable: !0 }), Ue.a.prototype._prepareVRComponent = function() {
+ this._vrSupported = !1, this._vrExclusivePointerMode = !1, this.onVRDisplayChangedObservable = new C.c(), this.onVRRequestPresentComplete = new C.c(), this.onVRRequestPresentStart = new C.c();
+ }, Ue.a.prototype.isVRDevicePresent = function() {
+ return !!this._vrDisplay;
+ }, Ue.a.prototype.getVRDevice = function() {
+ return this._vrDisplay;
+ }, Ue.a.prototype.initWebVR = function() {
+ return this.initWebVRAsync(), this.onVRDisplayChangedObservable;
+ }, Ue.a.prototype.initWebVRAsync = function() {
+ var r = this, t = function() {
+ var n = { vrDisplay: r._vrDisplay, vrSupported: r._vrSupported };
+ r.onVRDisplayChangedObservable.notifyObservers(n), r._webVRInitPromise = new Promise(function(i) {
+ i(n);
+ });
+ };
+ if (!this._onVrDisplayConnect) {
+ this._onVrDisplayConnect = function(n) {
+ r._vrDisplay = n.display, t();
+ }, this._onVrDisplayDisconnect = function() {
+ r._vrDisplay.cancelAnimationFrame(r._frameHandler), r._vrDisplay = void 0, r._frameHandler = Ue.a.QueueNewFrame(r._boundRenderFunction), t();
+ }, this._onVrDisplayPresentChange = function() {
+ r._vrExclusivePointerMode = r._vrDisplay && r._vrDisplay.isPresenting;
+ };
+ var e = this.getHostWindow();
+ e && (e.addEventListener("vrdisplayconnect", this._onVrDisplayConnect), e.addEventListener("vrdisplaydisconnect", this._onVrDisplayDisconnect), e.addEventListener("vrdisplaypresentchange", this._onVrDisplayPresentChange));
+ }
+ return this._webVRInitPromise = this._webVRInitPromise || this._getVRDisplaysAsync(), this._webVRInitPromise.then(t), this._webVRInitPromise;
+ }, Ue.a.prototype._getVRDisplaysAsync = function() {
+ var r = this;
+ return new Promise(function(t) {
+ navigator.getVRDisplays ? navigator.getVRDisplays().then(function(e) {
+ r._vrSupported = !0, r._vrDisplay = e[0], t({ vrDisplay: r._vrDisplay, vrSupported: r._vrSupported });
+ }) : (r._vrDisplay = void 0, r._vrSupported = !1, t({ vrDisplay: r._vrDisplay, vrSupported: r._vrSupported }));
+ });
+ }, Ue.a.prototype.enableVR = function(r) {
+ var t = this;
+ if (this._vrDisplay && !this._vrDisplay.isPresenting) {
+ this.onVRRequestPresentStart.notifyObservers(this);
+ var e = { highRefreshRate: !!this.vrPresentationAttributes && this.vrPresentationAttributes.highRefreshRate, foveationLevel: this.vrPresentationAttributes ? this.vrPresentationAttributes.foveationLevel : 1, multiview: (this.getCaps().multiview || this.getCaps().oculusMultiview) && r.useMultiview };
+ this._vrDisplay.requestPresent([Object(c.a)({ source: this.getRenderingCanvas(), attributes: e }, e)]).then(function() {
+ t.onVRRequestPresentComplete.notifyObservers(!0), t._onVRFullScreenTriggered();
+ }).catch(function() {
+ t.onVRRequestPresentComplete.notifyObservers(!1);
+ });
+ }
+ }, Ue.a.prototype._onVRFullScreenTriggered = function() {
+ if (this._vrDisplay && this._vrDisplay.isPresenting) {
+ this._oldSize = new oe.a(this.getRenderWidth(), this.getRenderHeight()), this._oldHardwareScaleFactor = this.getHardwareScalingLevel();
+ var r = this._vrDisplay.getEyeParameters("left");
+ this.setHardwareScalingLevel(1), this.setSize(2 * r.renderWidth, r.renderHeight);
+ } else
+ this.setHardwareScalingLevel(this._oldHardwareScaleFactor), this.setSize(this._oldSize.width, this._oldSize.height);
+ }, Ue.a.prototype.disableVR = function() {
+ var r = this;
+ this._vrDisplay && this._vrDisplay.isPresenting && this._vrDisplay.exitPresent().then(function() {
+ return r._onVRFullScreenTriggered();
+ }).catch(function() {
+ return r._onVRFullScreenTriggered();
+ }), Za.a.IsWindowObjectExist() && (window.removeEventListener("vrdisplaypointerrestricted", this._onVRDisplayPointerRestricted), window.removeEventListener("vrdisplaypointerunrestricted", this._onVRDisplayPointerUnrestricted), this._onVrDisplayConnect && (window.removeEventListener("vrdisplayconnect", this._onVrDisplayConnect), this._onVrDisplayDisconnect && window.removeEventListener("vrdisplaydisconnect", this._onVrDisplayDisconnect), this._onVrDisplayPresentChange && window.removeEventListener("vrdisplaypresentchange", this._onVrDisplayPresentChange), this._onVrDisplayConnect = null, this._onVrDisplayDisconnect = null));
+ }, Ue.a.prototype._connectVREvents = function(r, t) {
+ var e = this;
+ if (this._onVRDisplayPointerRestricted = function() {
+ r && r.requestPointerLock();
+ }, this._onVRDisplayPointerUnrestricted = function() {
+ if (t)
+ t.exitPointerLock && t.exitPointerLock();
+ else {
+ var i = e.getHostWindow();
+ i.document && i.document.exitPointerLock && i.document.exitPointerLock();
+ }
+ }, Za.a.IsWindowObjectExist()) {
+ var n = this.getHostWindow();
+ n.addEventListener("vrdisplaypointerrestricted", this._onVRDisplayPointerRestricted, !1), n.addEventListener("vrdisplaypointerunrestricted", this._onVRDisplayPointerUnrestricted, !1);
+ }
+ }, Ue.a.prototype._submitVRFrame = function() {
+ if (this._vrDisplay && this._vrDisplay.isPresenting)
+ try {
+ this._vrDisplay.submitFrame();
+ } catch (r) {
+ Xe.b.Warn("webVR submitFrame has had an unexpected failure: " + r);
+ }
+ }, Ue.a.prototype.isVRPresenting = function() {
+ return this._vrDisplay && this._vrDisplay.isPresenting;
+ }, Ue.a.prototype._requestVRFrame = function() {
+ this._frameHandler = Ue.a.QueueNewFrame(this._boundRenderFunction, this._vrDisplay);
+ }, Q.a.AddNodeConstructor("WebVRFreeCamera", function(r, t) {
+ return function() {
+ return new Mo(r, u.e.Zero(), t);
+ };
+ }), Q.a.AddNodeConstructor("WebVRGamepadCamera", function(r, t) {
+ return function() {
+ return new Mo(r, u.e.Zero(), t);
+ };
+ });
+ var Mo = function(r) {
+ function t(e, n, i, o) {
+ o === void 0 && (o = {});
+ var a = r.call(this, e, n, i) || this;
+ a.webVROptions = o, a._vrDevice = null, a.rawPose = null, a._specsVersion = "1.1", a._attached = !1, a._descendants = [], a._deviceRoomPosition = u.e.Zero(), a._deviceRoomRotationQuaternion = u.b.Identity(), a._standingMatrix = null, a.devicePosition = u.e.Zero(), a.deviceRotationQuaternion = u.b.Identity(), a.deviceScaleFactor = 1, a._deviceToWorld = u.a.Identity(), a._worldToDevice = u.a.Identity(), a.controllers = [], a.onControllersAttachedObservable = new C.c(), a.onControllerMeshLoadedObservable = new C.c(), a.onPoseUpdatedFromDeviceObservable = new C.c(), a._poseSet = !1, a.rigParenting = !0, a._defaultHeight = void 0, a._detachIfAttached = function() {
+ var d = a.getEngine().getVRDevice();
+ d && !d.isPresenting && a.detachControl();
+ }, a._workingVector = u.e.Zero(), a._oneVector = u.e.One(), a._workingMatrix = u.a.Identity(), a._tmpMatrix = new u.a(), a._cache.position = u.e.Zero(), o.defaultHeight && (a._defaultHeight = o.defaultHeight, a.position.y = a._defaultHeight), a.minZ = 0.1, arguments.length === 5 && (a.webVROptions = arguments[4]), a.webVROptions.trackPosition == null && (a.webVROptions.trackPosition = !0), a.webVROptions.controllerMeshes == null && (a.webVROptions.controllerMeshes = !0), a.webVROptions.defaultLightingOnControllers == null && (a.webVROptions.defaultLightingOnControllers = !0), a.rotationQuaternion = new u.b(), a.webVROptions && a.webVROptions.positionScale && (a.deviceScaleFactor = a.webVROptions.positionScale);
+ var s = a.getEngine();
+ return a._onVREnabled = function(d) {
+ d && a.initControllers();
+ }, s.onVRRequestPresentComplete.add(a._onVREnabled), s.initWebVR().add(function(d) {
+ d.vrDisplay && a._vrDevice !== d.vrDisplay && (a._vrDevice = d.vrDisplay, a.setCameraRigMode(_t.a.RIG_MODE_WEBVR, { parentCamera: a, vrDisplay: a._vrDevice, frameData: a._frameData, specs: a._specsVersion }), a._attached && a.getEngine().enableVR(a.webVROptions));
+ }), typeof VRFrameData < "u" && (a._frameData = new VRFrameData()), o.useMultiview && (a.getScene().getEngine().getCaps().multiview ? (a._useMultiviewToSingleView = !0, a._rigPostProcess = new ts("VRMultiviewToSingleview", a, 1)) : (l.a.Warn("Multiview is not supported, falling back to standard rendering"), a._useMultiviewToSingleView = !1)), i.onBeforeCameraRenderObservable.add(function(d) {
+ d.parent === a && a.rigParenting && (a._descendants = a.getDescendants(!0, function(p) {
+ var y = a.controllers.some(function(R) {
+ return R._mesh === p;
+ }), P = a._rigCameras.indexOf(p) !== -1;
+ return !y && !P;
+ }), a._descendants.forEach(function(p) {
+ p.parent = d;
+ }));
+ }), i.onAfterCameraRenderObservable.add(function(d) {
+ d.parent === a && a.rigParenting && a._descendants.forEach(function(p) {
+ p.parent = a;
+ });
+ }), a;
+ }
+ return Object(c.d)(t, r), t.prototype.deviceDistanceToRoomGround = function() {
+ return this._standingMatrix ? (this._standingMatrix.getTranslationToRef(this._workingVector), this._deviceRoomPosition.y + this._workingVector.y) : this._defaultHeight || 0;
+ }, t.prototype.useStandingMatrix = function(e) {
+ var n = this;
+ e === void 0 && (e = function(i) {
+ }), this.getEngine().initWebVRAsync().then(function(i) {
+ i.vrDisplay && i.vrDisplay.stageParameters && i.vrDisplay.stageParameters.sittingToStandingTransform && n.webVROptions.trackPosition ? (n._standingMatrix = new u.a(), u.a.FromFloat32ArrayToRefScaled(i.vrDisplay.stageParameters.sittingToStandingTransform, 0, 1, n._standingMatrix), n.getScene().useRightHandedSystem || n._standingMatrix && n._standingMatrix.toggleModelMatrixHandInPlace(), e(!0)) : e(!1);
+ });
+ }, t.prototype.useStandingMatrixAsync = function() {
+ var e = this;
+ return new Promise(function(n) {
+ e.useStandingMatrix(function(i) {
+ n(i);
+ });
+ });
+ }, t.prototype.dispose = function() {
+ this._detachIfAttached(), this.getEngine().onVRRequestPresentComplete.removeCallback(this._onVREnabled), this._updateCacheWhenTrackingDisabledObserver && this._scene.onBeforeRenderObservable.remove(this._updateCacheWhenTrackingDisabledObserver), r.prototype.dispose.call(this);
+ }, t.prototype.getControllerByName = function(e) {
+ for (var n = 0, i = this.controllers; n < i.length; n++) {
+ var o = i[n];
+ if (o.hand === e)
+ return o;
+ }
+ return null;
+ }, Object.defineProperty(t.prototype, "leftController", { get: function() {
+ return this._leftController || (this._leftController = this.getControllerByName("left")), this._leftController;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rightController", { get: function() {
+ return this._rightController || (this._rightController = this.getControllerByName("right")), this._rightController;
+ }, enumerable: !1, configurable: !0 }), t.prototype.getForwardRay = function(e) {
+ return e === void 0 && (e = 100), this.leftCamera ? r.prototype.getForwardRay.call(this, e, this.leftCamera.getWorldMatrix(), this.leftCamera.globalPosition) : r.prototype.getForwardRay.call(this, e);
+ }, t.prototype._checkInputs = function() {
+ this._vrDevice && this._vrDevice.isPresenting && (this._vrDevice.getFrameData(this._frameData), this.updateFromDevice(this._frameData.pose)), r.prototype._checkInputs.call(this);
+ }, t.prototype.updateFromDevice = function(e) {
+ e && e.orientation && e.orientation.length === 4 && (this.rawPose = e, this._deviceRoomRotationQuaternion.copyFromFloats(e.orientation[0], e.orientation[1], -e.orientation[2], -e.orientation[3]), this.getScene().useRightHandedSystem && (this._deviceRoomRotationQuaternion.z *= -1, this._deviceRoomRotationQuaternion.w *= -1), this.webVROptions.trackPosition && this.rawPose.position && (this._deviceRoomPosition.copyFromFloats(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2]), this.getScene().useRightHandedSystem && (this._deviceRoomPosition.z *= -1)), this._poseSet = !0);
+ }, t.prototype.attachControl = function(e) {
+ e = Xe.b.BackCompatCameraNoPreventDefault(arguments), r.prototype.attachControl.call(this, e), this._attached = !0, e = !_t.a.ForceAttachControlToAlwaysPreventDefault && e, this._vrDevice && this.getEngine().enableVR(this.webVROptions);
+ var n = this._scene.getEngine().getHostWindow();
+ n && n.addEventListener("vrdisplaypresentchange", this._detachIfAttached);
+ }, t.prototype.detachControl = function(e) {
+ this.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver), this.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver), r.prototype.detachControl.call(this), this._attached = !1, this.getEngine().disableVR(), window.removeEventListener("vrdisplaypresentchange", this._detachIfAttached);
+ }, t.prototype.getClassName = function() {
+ return "WebVRFreeCamera";
+ }, t.prototype.resetToCurrentRotation = function() {
+ this._vrDevice.resetPose();
+ }, t.prototype._updateRigCameras = function() {
+ var e = this._rigCameras[0], n = this._rigCameras[1];
+ e.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion), n.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion), e.position.copyFrom(this._deviceRoomPosition), n.position.copyFrom(this._deviceRoomPosition);
+ }, t.prototype._correctPositionIfNotTrackPosition = function(e, n) {
+ n === void 0 && (n = !1), this.rawPose && this.rawPose.position && !this.webVROptions.trackPosition && (u.a.TranslationToRef(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2], this._tmpMatrix), n || this._tmpMatrix.invert(), this._tmpMatrix.multiplyToRef(e, e));
+ }, t.prototype._updateCache = function(e) {
+ var n = this;
+ this.rotationQuaternion.equals(this._cache.rotationQuaternion) && this.position.equals(this._cache.position) || (this.updateCacheCalled || (this.updateCacheCalled = !0, this.update()), this.rotationQuaternion.toRotationMatrix(this._workingMatrix), u.e.TransformCoordinatesToRef(this._deviceRoomPosition, this._workingMatrix, this._workingVector), this.devicePosition.subtractToRef(this._workingVector, this._workingVector), u.a.ComposeToRef(this._oneVector, this.rotationQuaternion, this._workingVector, this._deviceToWorld), this._deviceToWorld.getTranslationToRef(this._workingVector), this._workingVector.addInPlace(this.position), this._workingVector.subtractInPlace(this._cache.position), this._deviceToWorld.setTranslation(this._workingVector), this._deviceToWorld.invertToRef(this._worldToDevice), this.controllers.forEach(function(i) {
+ i._deviceToWorld.copyFrom(n._deviceToWorld), n._correctPositionIfNotTrackPosition(i._deviceToWorld), i.update();
+ })), e || r.prototype._updateCache.call(this), this.updateCacheCalled = !1;
+ }, t.prototype._computeDevicePosition = function() {
+ u.e.TransformCoordinatesToRef(this._deviceRoomPosition, this._deviceToWorld, this.devicePosition);
+ }, t.prototype.update = function() {
+ this._computeDevicePosition(), u.a.FromQuaternionToRef(this._deviceRoomRotationQuaternion, this._workingMatrix), this._workingMatrix.multiplyToRef(this._deviceToWorld, this._workingMatrix), u.b.FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion), this._poseSet && this.onPoseUpdatedFromDeviceObservable.notifyObservers(null), r.prototype.update.call(this);
+ }, t.prototype._getViewMatrix = function() {
+ return u.a.Identity();
+ }, t.prototype._getWebVRViewMatrix = function() {
+ var e = this._cameraRigParams.parentCamera;
+ e._updateCache();
+ var n = this._cameraRigParams.left ? this._cameraRigParams.frameData.leftViewMatrix : this._cameraRigParams.frameData.rightViewMatrix;
+ return u.a.FromArrayToRef(n, 0, this._webvrViewMatrix), this.getScene().useRightHandedSystem || this._webvrViewMatrix.toggleModelMatrixHandInPlace(), this._webvrViewMatrix.getRotationMatrixToRef(this._cameraRotationMatrix), u.e.TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint), this.position.addToRef(this._transformedReferencePoint, this._currentTarget), e.deviceScaleFactor !== 1 && (this._webvrViewMatrix.invert(), e.deviceScaleFactor && (this._webvrViewMatrix.multiplyAtIndex(12, e.deviceScaleFactor), this._webvrViewMatrix.multiplyAtIndex(13, e.deviceScaleFactor), this._webvrViewMatrix.multiplyAtIndex(14, e.deviceScaleFactor)), this._webvrViewMatrix.invert()), e._correctPositionIfNotTrackPosition(this._webvrViewMatrix, !0), e._worldToDevice.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix), this._workingMatrix = this._workingMatrix || u.a.Identity(), this._webvrViewMatrix.invertToRef(this._workingMatrix), this._workingMatrix.multiplyToRef(e.getWorldMatrix(), this._workingMatrix), this._workingMatrix.getTranslationToRef(this._globalPosition), this._markSyncedWithParent(), this._webvrViewMatrix;
+ }, t.prototype._getWebVRProjectionMatrix = function() {
+ var e = this.parent;
+ e._vrDevice.depthNear = e.minZ, e._vrDevice.depthFar = e.maxZ;
+ var n = this._cameraRigParams.left ? this._cameraRigParams.frameData.leftProjectionMatrix : this._cameraRigParams.frameData.rightProjectionMatrix;
+ return u.a.FromArrayToRef(n, 0, this._projectionMatrix), this.getScene().useRightHandedSystem || this._projectionMatrix.toggleProjectionMatrixHandInPlace(), this._projectionMatrix;
+ }, t.prototype.initControllers = function() {
+ var e = this;
+ this.controllers = [];
+ var n = this.getScene().gamepadManager;
+ this._onGamepadDisconnectedObserver = n.onGamepadDisconnectedObservable.add(function(i) {
+ if (i.type === hn.POSE_ENABLED) {
+ var o = i;
+ o.defaultModel && o.defaultModel.setEnabled(!1), o.hand === "right" && (e._rightController = null), o.hand === "left" && (e._leftController = null);
+ var a = e.controllers.indexOf(o);
+ a !== -1 && e.controllers.splice(a, 1);
+ }
+ }), this._onGamepadConnectedObserver = n.onGamepadConnectedObservable.add(function(i) {
+ if (i.type === hn.POSE_ENABLED) {
+ var o = i;
+ if (e.webVROptions.trackPosition || (o._disableTrackPosition(new u.e(o.hand == "left" ? -0.15 : 0.15, -0.5, 0.25)), e._updateCacheWhenTrackingDisabledObserver || (e._updateCacheWhenTrackingDisabledObserver = e._scene.onBeforeRenderObservable.add(function() {
+ e._updateCache();
+ }))), o.deviceScaleFactor = e.deviceScaleFactor, o._deviceToWorld.copyFrom(e._deviceToWorld), e._correctPositionIfNotTrackPosition(o._deviceToWorld), e.webVROptions.controllerMeshes && (o.defaultModel ? o.defaultModel.setEnabled(!0) : o.initControllerMesh(e.getScene(), function(d) {
+ if (d.scaling.scaleInPlace(e.deviceScaleFactor), e.onControllerMeshLoadedObservable.notifyObservers(o), e.webVROptions.defaultLightingOnControllers) {
+ e._lightOnControllers || (e._lightOnControllers = new Oo.a("vrControllersLight", new u.e(0, 1, 0), e.getScene()));
+ var p = function(y, P) {
+ var R = y.getChildren();
+ R && R.length !== 0 && R.forEach(function(B) {
+ P.includedOnlyMeshes.push(B), p(B, P);
+ });
+ };
+ e._lightOnControllers.includedOnlyMeshes.push(d), p(d, e._lightOnControllers);
+ }
+ })), o.attachToPoseControlledCamera(e), e.controllers.indexOf(o) === -1) {
+ e.controllers.push(o);
+ for (var a = !1, s = 0; s < e.controllers.length; s++)
+ e.controllers[s].controllerType === Jn.VIVE && (a ? e.controllers[s].hand = "right" : (a = !0, e.controllers[s].hand = "left"));
+ e.controllers.length >= 2 && e.onControllersAttachedObservable.notifyObservers(e.controllers);
+ }
+ }
+ });
+ }, t;
+ }(zn), Ri = function(r) {
+ function t(e) {
+ var n = r.call(this, e) || this;
+ return n.onTriggerStateChangedObservable = new C.c(), n.onMainButtonStateChangedObservable = new C.c(), n.onSecondaryButtonStateChangedObservable = new C.c(), n.onPadStateChangedObservable = new C.c(), n.onPadValuesChangedObservable = new C.c(), n.pad = { x: 0, y: 0 }, n._changes = { pressChanged: !1, touchChanged: !1, valueChanged: !1, changed: !1 }, n._buttons = new Array(e.buttons.length), n.hand = e.hand, n;
+ }
+ return Object(c.d)(t, r), t.prototype.onButtonStateChange = function(e) {
+ this._onButtonStateChange = e;
+ }, Object.defineProperty(t.prototype, "defaultModel", { get: function() {
+ return this._defaultModel;
+ }, enumerable: !1, configurable: !0 }), t.prototype.update = function() {
+ r.prototype.update.call(this);
+ for (var e = 0; e < this._buttons.length; e++)
+ this._setButtonValue(this.browserGamepad.buttons[e], this._buttons[e], e);
+ this.leftStick.x === this.pad.x && this.leftStick.y === this.pad.y || (this.pad.x = this.leftStick.x, this.pad.y = this.leftStick.y, this.onPadValuesChangedObservable.notifyObservers(this.pad));
+ }, t.prototype._setButtonValue = function(e, n, i) {
+ e || (e = { pressed: !1, touched: !1, value: 0 }), n ? (this._checkChanges(e, n), this._changes.changed && (this._onButtonStateChange && this._onButtonStateChange(this.index, i, e), this._handleButtonChange(i, e, this._changes)), this._buttons[i].pressed = e.pressed, this._buttons[i].touched = e.touched, this._buttons[i].value = e.value < 1e-8 ? 0 : e.value) : this._buttons[i] = { pressed: e.pressed, touched: e.touched, value: e.value };
+ }, t.prototype._checkChanges = function(e, n) {
+ return this._changes.pressChanged = e.pressed !== n.pressed, this._changes.touchChanged = e.touched !== n.touched, this._changes.valueChanged = e.value !== n.value, this._changes.changed = this._changes.pressChanged || this._changes.touchChanged || this._changes.valueChanged, this._changes;
+ }, t.prototype.dispose = function() {
+ r.prototype.dispose.call(this), this._defaultModel = null, this.onTriggerStateChangedObservable.clear(), this.onMainButtonStateChangedObservable.clear(), this.onSecondaryButtonStateChangedObservable.clear(), this.onPadStateChangedObservable.clear(), this.onPadValuesChangedObservable.clear();
+ }, t;
+ }(ar), vn = f(42), Nt = f(30), pi = f(62), Pf = (f(108), f(59), f(109), `
+varying vec2 vUV;
+uniform sampler2D textureSampler;
+#include
+#include
+#include
+void main(void)
+{
+vec4 result=texture2D(textureSampler,vUV);
+#ifdef IMAGEPROCESSING
+#ifndef FROMLINEARSPACE
+
+result.rgb=toLinearSpace(result.rgb);
+#endif
+result=applyImageProcessing(result);
+#else
+
+#ifdef FROMLINEARSPACE
+result=applyImageProcessing(result);
+#endif
+#endif
+gl_FragColor=result;
+}`);
+ ze.a.ShadersStore.imageProcessingPixelShader = Pf;
+ var Io = function(r) {
+ function t(e, n, i, o, a, s, d, p) {
+ i === void 0 && (i = null), d === void 0 && (d = h.a.TEXTURETYPE_UNSIGNED_INT);
+ var y = r.call(this, e, "imageProcessing", [], [], n, i, o, a, s, null, d, "postprocess", null, !0) || this;
+ return y._fromLinearSpace = !0, y._defines = { IMAGEPROCESSING: !1, VIGNETTE: !1, VIGNETTEBLENDMODEMULTIPLY: !1, VIGNETTEBLENDMODEOPAQUE: !1, TONEMAPPING: !1, TONEMAPPING_ACES: !1, CONTRAST: !1, COLORCURVES: !1, COLORGRADING: !1, COLORGRADING3D: !1, FROMLINEARSPACE: !1, SAMPLER3DGREENDEPTH: !1, SAMPLER3DBGRMAP: !1, IMAGEPROCESSINGPOSTPROCESS: !1, EXPOSURE: !1 }, p ? (p.applyByPostProcess = !0, y._attachImageProcessingConfiguration(p, !0), y.fromLinearSpace = !1) : (y._attachImageProcessingConfiguration(null, !0), y.imageProcessingConfiguration.applyByPostProcess = !0), y.onApply = function(P) {
+ y.imageProcessingConfiguration.bind(P, y.aspectRatio);
+ }, y;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "imageProcessingConfiguration", { get: function() {
+ return this._imageProcessingConfiguration;
+ }, set: function(e) {
+ e.applyByPostProcess = !0, this._attachImageProcessingConfiguration(e);
+ }, enumerable: !1, configurable: !0 }), t.prototype._attachImageProcessingConfiguration = function(e, n) {
+ var i = this;
+ if (n === void 0 && (n = !1), e !== this._imageProcessingConfiguration) {
+ if (this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver), e)
+ this._imageProcessingConfiguration = e;
+ else {
+ var o = null, a = this.getEngine(), s = this.getCamera();
+ if (s)
+ o = s.getScene();
+ else if (a && a.scenes) {
+ var d = a.scenes;
+ o = d[d.length - 1];
+ } else
+ o = te.a.LastCreatedScene;
+ this._imageProcessingConfiguration = o ? o.imageProcessingConfiguration : new vn.a();
+ }
+ this._imageProcessingConfiguration && (this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function() {
+ i._updateParameters();
+ })), n || this._updateParameters();
+ }
+ }, Object.defineProperty(t.prototype, "isSupported", { get: function() {
+ var e = this.getEffect();
+ return !e || e.isSupported;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "colorCurves", { get: function() {
+ return this.imageProcessingConfiguration.colorCurves;
+ }, set: function(e) {
+ this.imageProcessingConfiguration.colorCurves = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "colorCurvesEnabled", { get: function() {
+ return this.imageProcessingConfiguration.colorCurvesEnabled;
+ }, set: function(e) {
+ this.imageProcessingConfiguration.colorCurvesEnabled = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "colorGradingTexture", { get: function() {
+ return this.imageProcessingConfiguration.colorGradingTexture;
+ }, set: function(e) {
+ this.imageProcessingConfiguration.colorGradingTexture = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "colorGradingEnabled", { get: function() {
+ return this.imageProcessingConfiguration.colorGradingEnabled;
+ }, set: function(e) {
+ this.imageProcessingConfiguration.colorGradingEnabled = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "exposure", { get: function() {
+ return this.imageProcessingConfiguration.exposure;
+ }, set: function(e) {
+ this.imageProcessingConfiguration.exposure = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "toneMappingEnabled", { get: function() {
+ return this._imageProcessingConfiguration.toneMappingEnabled;
+ }, set: function(e) {
+ this._imageProcessingConfiguration.toneMappingEnabled = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "toneMappingType", { get: function() {
+ return this._imageProcessingConfiguration.toneMappingType;
+ }, set: function(e) {
+ this._imageProcessingConfiguration.toneMappingType = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "contrast", { get: function() {
+ return this.imageProcessingConfiguration.contrast;
+ }, set: function(e) {
+ this.imageProcessingConfiguration.contrast = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "vignetteStretch", { get: function() {
+ return this.imageProcessingConfiguration.vignetteStretch;
+ }, set: function(e) {
+ this.imageProcessingConfiguration.vignetteStretch = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "vignetteCentreX", { get: function() {
+ return this.imageProcessingConfiguration.vignetteCentreX;
+ }, set: function(e) {
+ this.imageProcessingConfiguration.vignetteCentreX = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "vignetteCentreY", { get: function() {
+ return this.imageProcessingConfiguration.vignetteCentreY;
+ }, set: function(e) {
+ this.imageProcessingConfiguration.vignetteCentreY = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "vignetteWeight", { get: function() {
+ return this.imageProcessingConfiguration.vignetteWeight;
+ }, set: function(e) {
+ this.imageProcessingConfiguration.vignetteWeight = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "vignetteColor", { get: function() {
+ return this.imageProcessingConfiguration.vignetteColor;
+ }, set: function(e) {
+ this.imageProcessingConfiguration.vignetteColor = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "vignetteCameraFov", { get: function() {
+ return this.imageProcessingConfiguration.vignetteCameraFov;
+ }, set: function(e) {
+ this.imageProcessingConfiguration.vignetteCameraFov = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "vignetteBlendMode", { get: function() {
+ return this.imageProcessingConfiguration.vignetteBlendMode;
+ }, set: function(e) {
+ this.imageProcessingConfiguration.vignetteBlendMode = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "vignetteEnabled", { get: function() {
+ return this.imageProcessingConfiguration.vignetteEnabled;
+ }, set: function(e) {
+ this.imageProcessingConfiguration.vignetteEnabled = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "fromLinearSpace", { get: function() {
+ return this._fromLinearSpace;
+ }, set: function(e) {
+ this._fromLinearSpace !== e && (this._fromLinearSpace = e, this._updateParameters());
+ }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
+ return "ImageProcessingPostProcess";
+ }, t.prototype._updateParameters = function() {
+ this._defines.FROMLINEARSPACE = this._fromLinearSpace, this.imageProcessingConfiguration.prepareDefines(this._defines, !0);
+ var e = "";
+ for (var n in this._defines)
+ this._defines[n] && (e += "#define " + n + `;\r
+`);
+ var i = ["textureSampler"], o = ["scale"];
+ vn.a && (vn.a.PrepareSamplers(i, this._defines), vn.a.PrepareUniforms(o, this._defines)), this.updateEffect(e, o, i);
+ }, t.prototype.dispose = function(e) {
+ r.prototype.dispose.call(this, e), this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver), this._imageProcessingConfiguration && (this.imageProcessingConfiguration.applyByPostProcess = !1);
+ }, Object(c.c)([Object(L.c)()], t.prototype, "_fromLinearSpace", void 0), t;
+ }(ft), ht = f(16), Oe = f(4);
+ Ie.a._GroundMeshParser = function(r, t) {
+ return Do.Parse(r, t);
+ };
+ var Do = function(r) {
+ function t(e, n) {
+ var i = r.call(this, e, n) || this;
+ return i.generateOctree = !1, i;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "GroundMesh";
+ }, Object.defineProperty(t.prototype, "subdivisions", { get: function() {
+ return Math.min(this._subdivisionsX, this._subdivisionsY);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "subdivisionsX", { get: function() {
+ return this._subdivisionsX;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "subdivisionsY", { get: function() {
+ return this._subdivisionsY;
+ }, enumerable: !1, configurable: !0 }), t.prototype.optimize = function(e, n) {
+ n === void 0 && (n = 32), this._subdivisionsX = e, this._subdivisionsY = e, this.subdivide(e), this.createOrUpdateSubmeshesOctree && this.createOrUpdateSubmeshesOctree(n);
+ }, t.prototype.getHeightAtCoordinates = function(e, n) {
+ var i = this.getWorldMatrix(), o = u.c.Matrix[5];
+ i.invertToRef(o);
+ var a = u.c.Vector3[8];
+ if (u.e.TransformCoordinatesFromFloatsToRef(e, 0, n, o, a), e = a.x, n = a.z, e < this._minX || e > this._maxX || n < this._minZ || n > this._maxZ)
+ return this.position.y;
+ this._heightQuads && this._heightQuads.length != 0 || (this._initHeightQuads(), this._computeHeightQuads());
+ var s = this._getFacetAt(e, n), d = -(s.x * e + s.z * n + s.w) / s.y;
+ return u.e.TransformCoordinatesFromFloatsToRef(0, d, 0, i, a), a.y;
+ }, t.prototype.getNormalAtCoordinates = function(e, n) {
+ var i = new u.e(0, 1, 0);
+ return this.getNormalAtCoordinatesToRef(e, n, i), i;
+ }, t.prototype.getNormalAtCoordinatesToRef = function(e, n, i) {
+ var o = this.getWorldMatrix(), a = u.c.Matrix[5];
+ o.invertToRef(a);
+ var s = u.c.Vector3[8];
+ if (u.e.TransformCoordinatesFromFloatsToRef(e, 0, n, a, s), e = s.x, n = s.z, e < this._minX || e > this._maxX || n < this._minZ || n > this._maxZ)
+ return this;
+ this._heightQuads && this._heightQuads.length != 0 || (this._initHeightQuads(), this._computeHeightQuads());
+ var d = this._getFacetAt(e, n);
+ return u.e.TransformNormalFromFloatsToRef(d.x, d.y, d.z, o, i), this;
+ }, t.prototype.updateCoordinateHeights = function() {
+ return this._heightQuads && this._heightQuads.length != 0 || this._initHeightQuads(), this._computeHeightQuads(), this;
+ }, t.prototype._getFacetAt = function(e, n) {
+ var i = Math.floor((e + this._maxX) * this._subdivisionsX / this._width), o = Math.floor(-(n + this._maxZ) * this._subdivisionsY / this._height + this._subdivisionsY), a = this._heightQuads[o * this._subdivisionsX + i];
+ return n < a.slope.x * e + a.slope.y ? a.facet1 : a.facet2;
+ }, t.prototype._initHeightQuads = function() {
+ var e = this._subdivisionsX, n = this._subdivisionsY;
+ this._heightQuads = new Array();
+ for (var i = 0; i < n; i++)
+ for (var o = 0; o < e; o++) {
+ var a = { slope: u.d.Zero(), facet1: new u.f(0, 0, 0, 0), facet2: new u.f(0, 0, 0, 0) };
+ this._heightQuads[i * e + o] = a;
+ }
+ return this;
+ }, t.prototype._computeHeightQuads = function() {
+ var e = this.getVerticesData(Oe.b.PositionKind);
+ if (!e)
+ return this;
+ for (var n = u.c.Vector3[3], i = u.c.Vector3[2], o = u.c.Vector3[1], a = u.c.Vector3[0], s = u.c.Vector3[4], d = u.c.Vector3[5], p = u.c.Vector3[6], y = u.c.Vector3[7], P = u.c.Vector3[8], R = 0, B = 0, F = 0, z = 0, J = 0, ie = 0, se = 0, ce = this._subdivisionsX, ue = this._subdivisionsY, fe = 0; fe < ue; fe++)
+ for (var ve = 0; ve < ce; ve++) {
+ R = 3 * ve, B = fe * (ce + 1) * 3, F = (fe + 1) * (ce + 1) * 3, n.x = e[B + R], n.y = e[B + R + 1], n.z = e[B + R + 2], i.x = e[B + R + 3], i.y = e[B + R + 4], i.z = e[B + R + 5], o.x = e[F + R], o.y = e[F + R + 1], o.z = e[F + R + 2], a.x = e[F + R + 3], a.y = e[F + R + 4], a.z = e[F + R + 5], z = (a.z - n.z) / (a.x - n.x), J = n.z - z * n.x, i.subtractToRef(n, s), o.subtractToRef(n, d), a.subtractToRef(n, p), u.e.CrossToRef(p, d, y), u.e.CrossToRef(s, p, P), y.normalize(), P.normalize(), ie = -(y.x * n.x + y.y * n.y + y.z * n.z), se = -(P.x * i.x + P.y * i.y + P.z * i.z);
+ var Te = this._heightQuads[fe * ce + ve];
+ Te.slope.copyFromFloats(z, J), Te.facet1.copyFromFloats(y.x, y.y, y.z, ie), Te.facet2.copyFromFloats(P.x, P.y, P.z, se);
+ }
+ return this;
+ }, t.prototype.serialize = function(e) {
+ r.prototype.serialize.call(this, e), e.subdivisionsX = this._subdivisionsX, e.subdivisionsY = this._subdivisionsY, e.minX = this._minX, e.maxX = this._maxX, e.minZ = this._minZ, e.maxZ = this._maxZ, e.width = this._width, e.height = this._height;
+ }, t.Parse = function(e, n) {
+ var i = new t(e.name, n);
+ return i._subdivisionsX = e.subdivisionsX || 1, i._subdivisionsY = e.subdivisionsY || 1, i._minX = e.minX, i._maxX = e.maxX, i._minZ = e.minZ, i._maxZ = e.maxZ, i._width = e.width, i._height = e.height, i;
+ }, t;
+ }(Ie.a), ns = f(70);
+ ht.a.CreateGround = function(r) {
+ var t, e, n = [], i = [], o = [], a = [], s = r.width || 1, d = r.height || 1, p = r.subdivisionsX || r.subdivisions || 1, y = r.subdivisionsY || r.subdivisions || 1;
+ for (t = 0; t <= y; t++)
+ for (e = 0; e <= p; e++) {
+ var P = new u.e(e * s / p - s / 2, 0, (y - t) * d / y - d / 2), R = new u.e(0, 1, 0);
+ i.push(P.x, P.y, P.z), o.push(R.x, R.y, R.z), a.push(e / p, 1 - t / y);
+ }
+ for (t = 0; t < y; t++)
+ for (e = 0; e < p; e++)
+ n.push(e + 1 + (t + 1) * (p + 1)), n.push(e + 1 + t * (p + 1)), n.push(e + t * (p + 1)), n.push(e + (t + 1) * (p + 1)), n.push(e + 1 + (t + 1) * (p + 1)), n.push(e + t * (p + 1));
+ var B = new ht.a();
+ return B.indices = n, B.positions = i, B.normals = o, B.uvs = a, B;
+ }, ht.a.CreateTiledGround = function(r) {
+ var t, e, n, i, o = r.xmin !== void 0 && r.xmin !== null ? r.xmin : -1, a = r.zmin !== void 0 && r.zmin !== null ? r.zmin : -1, s = r.xmax !== void 0 && r.xmax !== null ? r.xmax : 1, d = r.zmax !== void 0 && r.zmax !== null ? r.zmax : 1, p = r.subdivisions || { w: 1, h: 1 }, y = r.precision || { w: 1, h: 1 }, P = new Array(), R = new Array(), B = new Array(), F = new Array();
+ p.h = p.h < 1 ? 1 : p.h, p.w = p.w < 1 ? 1 : p.w, y.w = y.w < 1 ? 1 : y.w, y.h = y.h < 1 ? 1 : y.h;
+ var z = (s - o) / p.w, J = (d - a) / p.h;
+ function ie(ce, ue, fe, ve) {
+ var Te = R.length / 3, Re = y.w + 1;
+ for (t = 0; t < y.h; t++)
+ for (e = 0; e < y.w; e++) {
+ var Ae = [Te + e + t * Re, Te + (e + 1) + t * Re, Te + (e + 1) + (t + 1) * Re, Te + e + (t + 1) * Re];
+ P.push(Ae[1]), P.push(Ae[2]), P.push(Ae[3]), P.push(Ae[0]), P.push(Ae[1]), P.push(Ae[3]);
+ }
+ var Ee = u.e.Zero(), Se = new u.e(0, 1, 0);
+ for (t = 0; t <= y.h; t++)
+ for (Ee.z = t * (ve - ue) / y.h + ue, e = 0; e <= y.w; e++)
+ Ee.x = e * (fe - ce) / y.w + ce, Ee.y = 0, R.push(Ee.x, Ee.y, Ee.z), B.push(Se.x, Se.y, Se.z), F.push(e / y.w, t / y.h);
+ }
+ for (n = 0; n < p.h; n++)
+ for (i = 0; i < p.w; i++)
+ ie(o + i * z, a + n * J, o + (i + 1) * z, a + (n + 1) * J);
+ var se = new ht.a();
+ return se.indices = P, se.positions = R, se.normals = B, se.uvs = F, se;
+ }, ht.a.CreateGroundFromHeightMap = function(r) {
+ var t, e, n = [], i = [], o = [], a = [], s = r.colorFilter || new I.a(0.3, 0.59, 0.11), d = r.alphaFilter || 0, p = !1;
+ if (r.minHeight > r.maxHeight) {
+ p = !0;
+ var y = r.maxHeight;
+ r.maxHeight = r.minHeight, r.minHeight = y;
+ }
+ for (t = 0; t <= r.subdivisions; t++)
+ for (e = 0; e <= r.subdivisions; e++) {
+ var P = new u.e(e * r.width / r.subdivisions - r.width / 2, 0, (r.subdivisions - t) * r.height / r.subdivisions - r.height / 2), R = 4 * (((P.x + r.width / 2) / r.width * (r.bufferWidth - 1) | 0) + ((1 - (P.z + r.height / 2) / r.height) * (r.bufferHeight - 1) | 0) * r.bufferWidth), B = r.buffer[R] / 255, F = r.buffer[R + 1] / 255, z = r.buffer[R + 2] / 255, J = r.buffer[R + 3] / 255;
+ p && (B = 1 - B, F = 1 - F, z = 1 - z);
+ var ie = B * s.r + F * s.g + z * s.b;
+ P.y = J >= d ? r.minHeight + (r.maxHeight - r.minHeight) * ie : r.minHeight - Vt.a, i.push(P.x, P.y, P.z), o.push(0, 0, 0), a.push(e / r.subdivisions, 1 - t / r.subdivisions);
+ }
+ for (t = 0; t < r.subdivisions; t++)
+ for (e = 0; e < r.subdivisions; e++) {
+ var se = e + 1 + (t + 1) * (r.subdivisions + 1), ce = e + 1 + t * (r.subdivisions + 1), ue = e + t * (r.subdivisions + 1), fe = e + (t + 1) * (r.subdivisions + 1), ve = i[3 * se + 1] >= r.minHeight, Te = i[3 * ce + 1] >= r.minHeight, Re = i[3 * ue + 1] >= r.minHeight;
+ ve && Te && Re && (n.push(se), n.push(ce), n.push(ue)), i[3 * fe + 1] >= r.minHeight && ve && Re && (n.push(fe), n.push(se), n.push(ue));
+ }
+ ht.a.ComputeNormals(i, n, o);
+ var Ae = new ht.a();
+ return Ae.indices = n, Ae.positions = i, Ae.normals = o, Ae.uvs = a, Ae;
+ }, Ie.a.CreateGround = function(r, t, e, n, i, o) {
+ var a = { width: t, height: e, subdivisions: n, updatable: o };
+ return Oi.CreateGround(r, a, i);
+ }, Ie.a.CreateTiledGround = function(r, t, e, n, i, o, a, s, d) {
+ var p = { xmin: t, zmin: e, xmax: n, zmax: i, subdivisions: o, precision: a, updatable: d };
+ return Oi.CreateTiledGround(r, p, s);
+ }, Ie.a.CreateGroundFromHeightMap = function(r, t, e, n, i, o, a, s, d, p, y) {
+ var P = { width: e, height: n, subdivisions: i, minHeight: o, maxHeight: a, updatable: d, onReady: p, alphaFilter: y };
+ return Oi.CreateGroundFromHeightMap(r, t, P, s);
+ };
+ var Oi = function() {
+ function r() {
+ }
+ return r.CreateGround = function(t, e, n) {
+ var i = new Do(t, n);
+ return i._setReady(!1), i._subdivisionsX = e.subdivisionsX || e.subdivisions || 1, i._subdivisionsY = e.subdivisionsY || e.subdivisions || 1, i._width = e.width || 1, i._height = e.height || 1, i._maxX = i._width / 2, i._maxZ = i._height / 2, i._minX = -i._maxX, i._minZ = -i._maxZ, ht.a.CreateGround(e).applyToMesh(i, e.updatable), i._setReady(!0), i;
+ }, r.CreateTiledGround = function(t, e, n) {
+ n === void 0 && (n = null);
+ var i = new Ie.a(t, n);
+ return ht.a.CreateTiledGround(e).applyToMesh(i, e.updatable), i;
+ }, r.CreateGroundFromHeightMap = function(t, e, n, i) {
+ i === void 0 && (i = null);
+ var o = n.width || 10, a = n.height || 10, s = n.subdivisions || 1, d = n.minHeight || 0, p = n.maxHeight || 1, y = n.colorFilter || new I.a(0.3, 0.59, 0.11), P = n.alphaFilter || 0, R = n.updatable, B = n.onReady;
+ i = i || te.a.LastCreatedScene;
+ var F = new Do(t, i);
+ return F._subdivisionsX = s, F._subdivisionsY = s, F._width = o, F._height = a, F._maxX = F._width / 2, F._maxZ = F._height / 2, F._minX = -F._maxX, F._minZ = -F._maxZ, F._setReady(!1), Xe.b.LoadImage(e, function(z) {
+ var J = z.width, ie = z.height, se = ns.a.CreateCanvas(J, ie).getContext("2d");
+ if (!se)
+ throw new Error("Unable to get 2d context for CreateGroundFromHeightMap");
+ if (!i.isDisposed) {
+ se.drawImage(z, 0, 0);
+ var ce = se.getImageData(0, 0, J, ie).data;
+ ht.a.CreateGroundFromHeightMap({ width: o, height: a, subdivisions: s, minHeight: d, maxHeight: p, colorFilter: y, buffer: ce, bufferWidth: J, bufferHeight: ie, alphaFilter: P }).applyToMesh(F, R), B && B(F), F._setReady(!0);
+ }
+ }, function() {
+ }, i.offlineProvider), F;
+ }, r;
+ }();
+ ht.a.CreateTorus = function(r) {
+ for (var t = [], e = [], n = [], i = [], o = r.diameter || 1, a = r.thickness || 0.5, s = r.tessellation || 16, d = r.sideOrientation === 0 ? 0 : r.sideOrientation || ht.a.DEFAULTSIDE, p = s + 1, y = 0; y <= s; y++)
+ for (var P = y / s, R = y * Math.PI * 2 / s - Math.PI / 2, B = u.a.Translation(o / 2, 0, 0).multiply(u.a.RotationY(R)), F = 0; F <= s; F++) {
+ var z = 1 - F / s, J = F * Math.PI * 2 / s + Math.PI, ie = Math.cos(J), se = Math.sin(J), ce = new u.e(ie, se, 0), ue = ce.scale(a / 2), fe = new u.d(P, z);
+ ue = u.e.TransformCoordinates(ue, B), ce = u.e.TransformNormal(ce, B), e.push(ue.x, ue.y, ue.z), n.push(ce.x, ce.y, ce.z), i.push(fe.x, fe.y);
+ var ve = (y + 1) % p, Te = (F + 1) % p;
+ t.push(y * p + F), t.push(y * p + Te), t.push(ve * p + F), t.push(y * p + Te), t.push(ve * p + Te), t.push(ve * p + F);
+ }
+ ht.a._ComputeSides(d, e, t, n, i, r.frontUVs, r.backUVs);
+ var Re = new ht.a();
+ return Re.indices = t, Re.positions = e, Re.normals = n, Re.uvs = i, Re;
+ }, Ie.a.CreateTorus = function(r, t, e, n, i, o, a) {
+ var s = { diameter: t, thickness: e, tessellation: n, sideOrientation: a, updatable: o };
+ return lr.CreateTorus(r, s, i);
+ };
+ var fn, Xi, lr = function() {
+ function r() {
+ }
+ return r.CreateTorus = function(t, e, n) {
+ var i = new Ie.a(t, n);
+ return e.sideOrientation = Ie.a._GetDefaultSideOrientation(e.sideOrientation), i._originalBuilderSideOrientation = e.sideOrientation, ht.a.CreateTorus(e).applyToMesh(i, e.updatable), i;
+ }, r;
+ }(), ci = f(53), is = function() {
+ function r() {
+ }
+ return r.GetDefaults = function(t) {
+ var e = new r();
+ return e.canvasOptions = { antialias: !0, depth: !0, stencil: !t || t.isStencilEnable, alpha: !0, multiview: !1, framebufferScaleFactor: 1 }, e.newCanvasCssStyle = "position:absolute; bottom:0px;right:0px;z-index:10;width:90%;height:100%;background-color: #000000;", e;
+ }, r;
+ }(), Rl = function() {
+ function r(t, e) {
+ var n = this;
+ if (e === void 0 && (e = is.GetDefaults()), this._options = e, this._canvas = null, this.xrLayer = null, this.onXRLayerInitObservable = new C.c(), this._engine = t.scene.getEngine(), e.canvasElement)
+ this._setManagedOutputCanvas(e.canvasElement);
+ else {
+ var i = document.createElement("canvas");
+ i.style.cssText = this._options.newCanvasCssStyle || "position:absolute; bottom:0px;right:0px;", this._setManagedOutputCanvas(i);
+ }
+ t.onXRSessionInit.add(function() {
+ n._addCanvas();
+ }), t.onXRSessionEnded.add(function() {
+ n._removeCanvas();
+ });
+ }
+ return r.prototype.dispose = function() {
+ this._removeCanvas(), this._setManagedOutputCanvas(null);
+ }, r.prototype.initializeXRLayerAsync = function(t) {
+ var e = this, n = function() {
+ var i = new XRWebGLLayer(t, e.canvasContext, e._options.canvasOptions);
+ return e.onXRLayerInitObservable.notifyObservers(i), i;
+ };
+ return this.canvasContext.makeXRCompatible ? this.canvasContext.makeXRCompatible().then(function() {
+ return e.xrLayer = n(), e.xrLayer;
+ }) : (this.xrLayer = n(), Promise.resolve(this.xrLayer));
+ }, r.prototype._addCanvas = function() {
+ var t = this;
+ this._canvas && this._canvas !== this._engine.getRenderingCanvas() && document.body.appendChild(this._canvas), this.xrLayer ? this._setCanvasSize(!0) : this.onXRLayerInitObservable.addOnce(function(e) {
+ t._setCanvasSize(!0, e);
+ });
+ }, r.prototype._removeCanvas = function() {
+ this._canvas && document.body.contains(this._canvas) && this._canvas !== this._engine.getRenderingCanvas() && document.body.removeChild(this._canvas), this._setCanvasSize(!1);
+ }, r.prototype._setCanvasSize = function(t, e) {
+ t === void 0 && (t = !0), e === void 0 && (e = this.xrLayer), this._canvas && (t ? e && (this._canvas !== this._engine.getRenderingCanvas() ? (this._canvas.style.width = e.framebufferWidth + "px", this._canvas.style.height = e.framebufferHeight + "px") : this._engine.setSize(e.framebufferWidth, e.framebufferHeight)) : this._originalCanvasSize && (this._canvas !== this._engine.getRenderingCanvas() ? (this._canvas.style.width = this._originalCanvasSize.width + "px", this._canvas.style.height = this._originalCanvasSize.height + "px") : this._engine.setSize(this._originalCanvasSize.width, this._originalCanvasSize.height)));
+ }, r.prototype._setManagedOutputCanvas = function(t) {
+ this._removeCanvas(), t ? (this._originalCanvasSize = { width: t.offsetWidth, height: t.offsetHeight }, this._canvas = t, this.canvasContext = this._canvas.getContext("webgl2"), this.canvasContext || (this.canvasContext = this._canvas.getContext("webgl"))) : (this._canvas = null, this.canvasContext = null);
+ }, r;
+ }(), rs = function() {
+ function r(t) {
+ this.scene = t, this._sessionEnded = !1, this.baseLayer = null, this.currentTimestamp = -1, this.defaultHeightCompensation = 1.7, this.onXRFrameObservable = new C.c(), this.onXRReferenceSpaceChanged = new C.c(), this.onXRSessionEnded = new C.c(), this.onXRSessionInit = new C.c();
+ }
+ return Object.defineProperty(r.prototype, "referenceSpace", { get: function() {
+ return this._referenceSpace;
+ }, set: function(t) {
+ this._referenceSpace = t, this.onXRReferenceSpaceChanged.notifyObservers(this._referenceSpace);
+ }, enumerable: !1, configurable: !0 }), r.prototype.dispose = function() {
+ this._sessionEnded || this.exitXRAsync(), this.onXRFrameObservable.clear(), this.onXRSessionEnded.clear(), this.onXRReferenceSpaceChanged.clear(), this.onXRSessionInit.clear();
+ }, r.prototype.exitXRAsync = function() {
+ return this.session && !this._sessionEnded ? (this._sessionEnded = !0, this.session.end().catch(function(t) {
+ l.a.Warn("Could not end XR session.");
+ })) : Promise.resolve();
+ }, r.prototype.getRenderTargetTextureForEye = function(t) {
+ return this._rttProvider.getRenderTargetForEye(t);
+ }, r.prototype.getWebXRRenderTarget = function(t) {
+ var e = this.scene.getEngine();
+ return this._xrNavigator.xr.native ? this._xrNavigator.xr.getWebXRRenderTarget(e) : ((t = t || is.GetDefaults(e)).canvasElement = e.getRenderingCanvas() || void 0, new Rl(this, t));
+ }, r.prototype.initializeAsync = function() {
+ return this._xrNavigator = navigator, this._xrNavigator.xr ? Promise.resolve() : Promise.reject("WebXR not available");
+ }, r.prototype.initializeSessionAsync = function(t, e) {
+ var n = this;
+ return t === void 0 && (t = "immersive-vr"), e === void 0 && (e = {}), this._xrNavigator.xr.requestSession(t, e).then(function(i) {
+ return n.session = i, n.onXRSessionInit.notifyObservers(i), n._sessionEnded = !1, n.session.addEventListener("end", function() {
+ var o = n.scene.getEngine();
+ n._sessionEnded = !0, n._rttProvider = null, o.framebufferDimensionsObject = null, o.restoreDefaultFramebuffer(), o.customAnimationFrameRequester = null, n.onXRSessionEnded.notifyObservers(null), o._renderLoop();
+ }, { once: !0 }), n.session;
+ });
+ }, r.prototype.isSessionSupportedAsync = function(t) {
+ return r.IsSessionSupportedAsync(t);
+ }, r.prototype.resetReferenceSpace = function() {
+ this.referenceSpace = this.baseReferenceSpace;
+ }, r.prototype.runXRRenderLoop = function() {
+ var t = this, e = this.scene.getEngine();
+ if (e.customAnimationFrameRequester = { requestAnimationFrame: this.session.requestAnimationFrame.bind(this.session), renderFunction: function(i, o) {
+ t._sessionEnded || (t.currentFrame = o, t.currentTimestamp = i, o && (e.framebufferDimensionsObject = t.baseLayer, t.onXRFrameObservable.notifyObservers(o), e._renderLoop(), e.framebufferDimensionsObject = null));
+ } }, this._xrNavigator.xr.native)
+ this._rttProvider = this._xrNavigator.xr.getNativeRenderTargetProvider(this.session, this._createRenderTargetTexture.bind(this));
+ else {
+ var n = this._createRenderTargetTexture(this.baseLayer.framebufferWidth, this.baseLayer.framebufferHeight, this.baseLayer.framebuffer);
+ this._rttProvider = { getRenderTargetForEye: function() {
+ return n;
+ } }, e.framebufferDimensionsObject = this.baseLayer;
+ }
+ typeof window < "u" && window.cancelAnimationFrame && window.cancelAnimationFrame(e._frameHandler), e._renderLoop();
+ }, r.prototype.setReferenceSpaceTypeAsync = function(t) {
+ var e = this;
+ return t === void 0 && (t = "local-floor"), this.session.requestReferenceSpace(t).then(function(n) {
+ return n;
+ }, function(n) {
+ return l.a.Error("XR.requestReferenceSpace failed for the following reason: "), l.a.Error(n), l.a.Log('Defaulting to universally-supported "viewer" reference space type.'), e.session.requestReferenceSpace("viewer").then(function(i) {
+ var o = new XRRigidTransform({ x: 0, y: -e.defaultHeightCompensation, z: 0 });
+ return i.getOffsetReferenceSpace(o);
+ }, function(i) {
+ throw l.a.Error(i), 'XR initialization failed: required "viewer" reference space type not supported.';
+ });
+ }).then(function(n) {
+ return e.session.requestReferenceSpace("viewer").then(function(i) {
+ return e.viewerReferenceSpace = i, n;
+ });
+ }).then(function(n) {
+ return e.referenceSpace = e.baseReferenceSpace = n, e.referenceSpace;
+ });
+ }, r.prototype.updateRenderStateAsync = function(t) {
+ return t.baseLayer && (this.baseLayer = t.baseLayer), this.session.updateRenderState(t);
+ }, r.IsSessionSupportedAsync = function(t) {
+ if (!navigator.xr)
+ return Promise.resolve(!1);
+ var e = navigator.xr.isSessionSupported || navigator.xr.supportsSession;
+ return e ? e.call(navigator.xr, t).then(function(n) {
+ var i = n === void 0 || n;
+ return Promise.resolve(i);
+ }).catch(function(n) {
+ return l.a.Warn(n), Promise.resolve(!1);
+ }) : Promise.resolve(!1);
+ }, r.prototype._createRenderTargetTexture = function(t, e, n) {
+ n === void 0 && (n = null);
+ var i = new Pt.a(this.scene.getEngine(), Pt.b.Unknown, !0);
+ i.width = t, i.height = e, i._framebuffer = n;
+ var o = new on("XR renderTargetTexture", { width: t, height: e }, this.scene, void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0, !0);
+ return o._texture = i, o;
+ }, r;
+ }();
+ (function(r) {
+ r[r.ENTERING_XR = 0] = "ENTERING_XR", r[r.EXITING_XR = 1] = "EXITING_XR", r[r.IN_XR = 2] = "IN_XR", r[r.NOT_IN_XR = 3] = "NOT_IN_XR";
+ })(fn || (fn = {})), function(r) {
+ r[r.NOT_TRACKING = 0] = "NOT_TRACKING", r[r.TRACKING_LOST = 1] = "TRACKING_LOST", r[r.TRACKING = 2] = "TRACKING";
+ }(Xi || (Xi = {}));
+ var $n, Ol = function() {
+ function r(t, e) {
+ if (e === void 0 && (e = null), this.scene = t, this._pointerDownOnMeshAsked = !1, this._isActionableMesh = !1, this._teleportationRequestInitiated = !1, this._teleportationBackRequestInitiated = !1, this._rotationRightAsked = !1, this._rotationLeftAsked = !1, this._dpadPressed = !0, this._activePointer = !1, this._id = r._idCounter++, e)
+ this._gazeTracker = e.clone("gazeTracker");
+ else {
+ this._gazeTracker = Ie.a.CreateTorus("gazeTracker", 35e-4, 25e-4, 20, t, !1), this._gazeTracker.bakeCurrentTransformIntoVertices(), this._gazeTracker.isPickable = !1, this._gazeTracker.isVisible = !1;
+ var n = new Nt.a("targetMat", t);
+ n.specularColor = I.a.Black(), n.emissiveColor = new I.a(0.7, 0.7, 0.7), n.backFaceCulling = !1, this._gazeTracker.material = n;
+ }
+ }
+ return r.prototype._getForwardRay = function(t) {
+ return new dn.a(u.e.Zero(), new u.e(0, 0, t));
+ }, r.prototype._selectionPointerDown = function() {
+ this._pointerDownOnMeshAsked = !0, this._currentHit && this.scene.simulatePointerDown(this._currentHit, { pointerId: this._id });
+ }, r.prototype._selectionPointerUp = function() {
+ this._currentHit && this.scene.simulatePointerUp(this._currentHit, { pointerId: this._id }), this._pointerDownOnMeshAsked = !1;
+ }, r.prototype._activatePointer = function() {
+ this._activePointer = !0;
+ }, r.prototype._deactivatePointer = function() {
+ this._activePointer = !1;
+ }, r.prototype._updatePointerDistance = function(t) {
+ }, r.prototype.dispose = function() {
+ this._interactionsEnabled = !1, this._teleportationEnabled = !1, this._gazeTracker && this._gazeTracker.dispose();
+ }, r._idCounter = 0, r;
+ }(), xf = function(r) {
+ function t(e, n, i) {
+ var o = r.call(this, n, i) || this;
+ o.webVRController = e, o._laserPointer = Ie.a.CreateCylinder("laserPointer", 1, 4e-3, 2e-4, 20, 1, n, !1);
+ var a = new Nt.a("laserPointerMat", n);
+ if (a.emissiveColor = new I.a(0.7, 0.7, 0.7), a.alpha = 0.6, o._laserPointer.material = a, o._laserPointer.rotation.x = Math.PI / 2, o._laserPointer.position.z = -0.5, o._laserPointer.isVisible = !1, o._laserPointer.isPickable = !1, !e.mesh) {
+ var s = new Ie.a("preloadControllerMesh", n), d = new Ie.a(ar.POINTING_POSE, n);
+ d.rotation.x = -0.7, s.addChild(d), e.attachToMesh(s);
+ }
+ return o._setLaserPointerParent(e.mesh), o._meshAttachedObserver = e._meshAttachedObservable.add(function(p) {
+ o._setLaserPointerParent(p);
+ }), o;
+ }
+ return Object(c.d)(t, r), t.prototype._getForwardRay = function(e) {
+ return this.webVRController.getForwardRay(e);
+ }, t.prototype._activatePointer = function() {
+ r.prototype._activatePointer.call(this), this._laserPointer.isVisible = !0;
+ }, t.prototype._deactivatePointer = function() {
+ r.prototype._deactivatePointer.call(this), this._laserPointer.isVisible = !1;
+ }, t.prototype._setLaserPointerColor = function(e) {
+ this._laserPointer.material.emissiveColor = e;
+ }, t.prototype._setLaserPointerLightingDisabled = function(e) {
+ this._laserPointer.material.disableLighting = e;
+ }, t.prototype._setLaserPointerParent = function(e) {
+ var n = function(s) {
+ s.isPickable = !1, s.getChildMeshes().forEach(function(d) {
+ n(d);
+ });
+ };
+ n(e);
+ var i = e.getChildren(void 0, !1), o = e;
+ this.webVRController._pointingPoseNode = null;
+ for (var a = 0; a < i.length; a++)
+ if (i[a].name && i[a].name.indexOf(ar.POINTING_POSE) >= 0) {
+ o = i[a], this.webVRController._pointingPoseNode = o;
+ break;
+ }
+ this._laserPointer.parent = o;
+ }, t.prototype._updatePointerDistance = function(e) {
+ e === void 0 && (e = 100), this._laserPointer.scaling.y = e, this._laserPointer.position.z = -e / 2;
+ }, t.prototype.dispose = function() {
+ r.prototype.dispose.call(this), this._laserPointer.dispose(), this._meshAttachedObserver && this.webVRController._meshAttachedObservable.remove(this._meshAttachedObserver);
+ }, t;
+ }(Ol), Ml = function(r) {
+ function t(e, n) {
+ var i = r.call(this, n) || this;
+ return i.getCamera = e, i;
+ }
+ return Object(c.d)(t, r), t.prototype._getForwardRay = function(e) {
+ var n = this.getCamera();
+ return n ? n.getForwardRay(e) : new dn.a(u.e.Zero(), u.e.Forward());
+ }, t;
+ }(Ol), Cf = function() {
+ }, Il = function() {
+ function r(t, e) {
+ var n = this;
+ if (e === void 0 && (e = {}), this.webVROptions = e, this._webVRsupported = !1, this._webVRready = !1, this._webVRrequesting = !1, this._webVRpresenting = !1, this._fullscreenVRpresenting = !1, this.enableGazeEvenWhenNoPointerLock = !1, this.exitVROnDoubleTap = !0, this.onEnteringVRObservable = new C.c(), this.onAfterEnteringVRObservable = new C.c(), this.onExitingVRObservable = new C.c(), this.onControllerMeshLoadedObservable = new C.c(), this._useCustomVRButton = !1, this._teleportationRequested = !1, this._teleportActive = !1, this._floorMeshesCollection = [], this._teleportationMode = r.TELEPORTATIONMODE_CONSTANTTIME, this._teleportationTime = 122, this._teleportationSpeed = 20, this._rotationAllowed = !0, this._teleportBackwardsVector = new u.e(0, -1, -1), this._isDefaultTeleportationTarget = !0, this._teleportationFillColor = "#444444", this._teleportationBorderColor = "#FFFFFF", this._rotationAngle = 0, this._haloCenter = new u.e(0, 0, 0), this._padSensibilityUp = 0.65, this._padSensibilityDown = 0.35, this._leftController = null, this._rightController = null, this._gazeColor = new I.a(0.7, 0.7, 0.7), this._laserColor = new I.a(0.7, 0.7, 0.7), this._pickedLaserColor = new I.a(0.2, 0.2, 1), this._pickedGazeColor = new I.a(0, 0, 1), this.onNewMeshSelected = new C.c(), this.onMeshSelectedWithController = new C.c(), this.onNewMeshPicked = new C.c(), this.onBeforeCameraTeleport = new C.c(), this.onAfterCameraTeleport = new C.c(), this.onSelectedMeshUnselected = new C.c(), this.teleportationEnabled = !0, this._teleportationInitialized = !1, this._interactionsEnabled = !1, this._interactionsRequested = !1, this._displayGaze = !0, this._displayLaserPointer = !0, this.updateGazeTrackerScale = !0, this.updateGazeTrackerColor = !0, this.updateControllerLaserColor = !0, this.requestPointerLockOnFullScreen = !0, this.xrTestDone = !1, this._onResize = function() {
+ n.moveButtonToBottomRight(), n._fullscreenVRpresenting && n._webVRready && n.exitVR();
+ }, this._onFullscreenChange = function() {
+ var o = document;
+ o.fullscreen !== void 0 ? n._fullscreenVRpresenting = document.fullscreen : o.mozFullScreen !== void 0 ? n._fullscreenVRpresenting = o.mozFullScreen : o.webkitIsFullScreen !== void 0 ? n._fullscreenVRpresenting = o.webkitIsFullScreen : o.msIsFullScreen !== void 0 ? n._fullscreenVRpresenting = o.msIsFullScreen : document.msFullscreenElement !== void 0 && (n._fullscreenVRpresenting = document.msFullscreenElement), !n._fullscreenVRpresenting && n._inputElement && (n.exitVR(), !n._useCustomVRButton && n._btnVR && (n._btnVR.style.top = n._inputElement.offsetTop + n._inputElement.offsetHeight - 70 + "px", n._btnVR.style.left = n._inputElement.offsetLeft + n._inputElement.offsetWidth - 100 + "px", n.updateButtonVisibility()));
+ }, this._cachedAngularSensibility = { angularSensibilityX: null, angularSensibilityY: null, angularSensibility: null }, this.beforeRender = function() {
+ n._leftController && n._leftController._activePointer && n._castRayAndSelectObject(n._leftController), n._rightController && n._rightController._activePointer && n._castRayAndSelectObject(n._rightController), n._noControllerIsActive && (n._scene.getEngine().isPointerLock || n.enableGazeEvenWhenNoPointerLock) ? n._castRayAndSelectObject(n._cameraGazer) : n._cameraGazer._gazeTracker.isVisible = !1;
+ }, this._onNewGamepadConnected = function(o) {
+ if (o.type !== hn.POSE_ENABLED)
+ o.leftStick && o.onleftstickchanged(function(d) {
+ n._teleportationInitialized && n.teleportationEnabled && (!n._leftController && !n._rightController || n._leftController && !n._leftController._activePointer && n._rightController && !n._rightController._activePointer) && (n._checkTeleportWithRay(d, n._cameraGazer), n._checkTeleportBackwards(d, n._cameraGazer));
+ }), o.rightStick && o.onrightstickchanged(function(d) {
+ n._teleportationInitialized && n._checkRotate(d, n._cameraGazer);
+ }), o.type === hn.XBOX && (o.onbuttondown(function(d) {
+ n._interactionsEnabled && d === xn.A && n._cameraGazer._selectionPointerDown();
+ }), o.onbuttonup(function(d) {
+ n._interactionsEnabled && d === xn.A && n._cameraGazer._selectionPointerUp();
+ }));
+ else {
+ var a = o, s = new xf(a, n._scene, n._cameraGazer._gazeTracker);
+ a.hand === "right" || n._leftController && n._leftController.webVRController != a ? n._rightController = s : n._leftController = s, n._tryEnableInteractionOnController(s);
+ }
+ }, this._tryEnableInteractionOnController = function(o) {
+ n._interactionsRequested && !o._interactionsEnabled && n._enableInteractionOnController(o), n._teleportationRequested && !o._teleportationEnabled && n._enableTeleportationOnController(o);
+ }, this._onNewGamepadDisconnected = function(o) {
+ o instanceof Ri && (o.hand === "left" && n._leftController != null && (n._leftController.dispose(), n._leftController = null), o.hand === "right" && n._rightController != null && (n._rightController.dispose(), n._rightController = null));
+ }, this._workingVector = u.e.Zero(), this._workingQuaternion = u.b.Identity(), this._workingMatrix = u.a.Identity(), this._scene = t, this._inputElement = t.getEngine().getInputElement(), "getVRDisplays" in navigator || (e.useXR = !0), e.createFallbackVRDeviceOrientationFreeCamera === void 0 && (e.createFallbackVRDeviceOrientationFreeCamera = !0), e.createDeviceOrientationCamera === void 0 && (e.createDeviceOrientationCamera = !0), e.laserToggle === void 0 && (e.laserToggle = !0), e.defaultHeight === void 0 && (e.defaultHeight = 1.7), e.useCustomVRButton && (this._useCustomVRButton = !0, e.customVRButton && (this._btnVR = e.customVRButton)), e.rayLength && (this._rayLength = e.rayLength), this._defaultHeight = e.defaultHeight, e.positionScale && (this._rayLength *= e.positionScale, this._defaultHeight *= e.positionScale), this._hasEnteredVR = !1, this._scene.activeCamera ? this._position = this._scene.activeCamera.position.clone() : this._position = new u.e(0, this._defaultHeight, 0), e.createDeviceOrientationCamera || !this._scene.activeCamera) {
+ if (this._deviceOrientationCamera = new xo("deviceOrientationVRHelper", this._position.clone(), t), this._scene.activeCamera && (this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ, this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ, this._scene.activeCamera instanceof Pi && this._scene.activeCamera.rotation)) {
+ var i = this._scene.activeCamera;
+ i.rotationQuaternion ? this._deviceOrientationCamera.rotationQuaternion.copyFrom(i.rotationQuaternion) : this._deviceOrientationCamera.rotationQuaternion.copyFrom(u.b.RotationYawPitchRoll(i.rotation.y, i.rotation.x, i.rotation.z)), this._deviceOrientationCamera.rotation = i.rotation.clone();
+ }
+ this._scene.activeCamera = this._deviceOrientationCamera, this._inputElement && this._scene.activeCamera.attachControl();
+ } else
+ this._existingCamera = this._scene.activeCamera;
+ this.webVROptions.useXR && navigator.xr ? rs.IsSessionSupportedAsync("immersive-vr").then(function(o) {
+ o ? (l.a.Log("Using WebXR. It is recommended to use the WebXRDefaultExperience directly"), t.createDefaultXRExperienceAsync({ floorMeshes: e.floorMeshes || [] }).then(function(a) {
+ n.xr = a, n.xrTestDone = !0, n._cameraGazer = new Ml(function() {
+ return n.xr.baseExperience.camera;
+ }, t), n.xr.baseExperience.onStateChangedObservable.add(function(s) {
+ switch (s) {
+ case fn.ENTERING_XR:
+ n.onEnteringVRObservable.notifyObservers(n), n._interactionsEnabled || n.xr.pointerSelection.detach(), n.xr.pointerSelection.displayLaserPointer = n._displayLaserPointer;
+ break;
+ case fn.EXITING_XR:
+ n.onExitingVRObservable.notifyObservers(n), n._scene.getEngine().resize();
+ break;
+ case fn.IN_XR:
+ n._hasEnteredVR = !0;
+ break;
+ case fn.NOT_IN_XR:
+ n._hasEnteredVR = !1;
+ }
+ });
+ })) : n.completeVRInit(t, e);
+ }) : this.completeVRInit(t, e);
+ }
+ return Object.defineProperty(r.prototype, "onEnteringVR", { get: function() {
+ return this.onEnteringVRObservable;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "onExitingVR", { get: function() {
+ return this.onExitingVRObservable;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "onControllerMeshLoaded", { get: function() {
+ return this.onControllerMeshLoadedObservable;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "teleportationTarget", { get: function() {
+ return this._teleportationTarget;
+ }, set: function(t) {
+ t && (t.name = "teleportationTarget", this._isDefaultTeleportationTarget = !1, this._teleportationTarget = t);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "gazeTrackerMesh", { get: function() {
+ return this._cameraGazer._gazeTracker;
+ }, set: function(t) {
+ t && (this._cameraGazer._gazeTracker && this._cameraGazer._gazeTracker.dispose(), this._leftController && this._leftController._gazeTracker && this._leftController._gazeTracker.dispose(), this._rightController && this._rightController._gazeTracker && this._rightController._gazeTracker.dispose(), this._cameraGazer._gazeTracker = t, this._cameraGazer._gazeTracker.bakeCurrentTransformIntoVertices(), this._cameraGazer._gazeTracker.isPickable = !1, this._cameraGazer._gazeTracker.isVisible = !1, this._cameraGazer._gazeTracker.name = "gazeTracker", this._leftController && (this._leftController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker")), this._rightController && (this._rightController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker")));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "leftControllerGazeTrackerMesh", { get: function() {
+ return this._leftController ? this._leftController._gazeTracker : null;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "rightControllerGazeTrackerMesh", { get: function() {
+ return this._rightController ? this._rightController._gazeTracker : null;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "displayGaze", { get: function() {
+ return this._displayGaze;
+ }, set: function(t) {
+ this._displayGaze = t, t || (this._cameraGazer._gazeTracker.isVisible = !1, this._leftController && (this._leftController._gazeTracker.isVisible = !1), this._rightController && (this._rightController._gazeTracker.isVisible = !1));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "displayLaserPointer", { get: function() {
+ return this._displayLaserPointer;
+ }, set: function(t) {
+ this._displayLaserPointer = t, t ? (this._rightController && this._rightController._activatePointer(), this._leftController && this._leftController._activatePointer()) : (this._rightController && (this._rightController._deactivatePointer(), this._rightController._gazeTracker.isVisible = !1), this._leftController && (this._leftController._deactivatePointer(), this._leftController._gazeTracker.isVisible = !1));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "deviceOrientationCamera", { get: function() {
+ return this._deviceOrientationCamera;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "currentVRCamera", { get: function() {
+ return this._webVRready ? this._webVRCamera : this._scene.activeCamera;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "webVRCamera", { get: function() {
+ return this._webVRCamera;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "vrDeviceOrientationCamera", { get: function() {
+ return this._vrDeviceOrientationCamera;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "vrButton", { get: function() {
+ return this._btnVR;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "_teleportationRequestInitiated", { get: function() {
+ return this._cameraGazer._teleportationRequestInitiated || this._leftController !== null && this._leftController._teleportationRequestInitiated || this._rightController !== null && this._rightController._teleportationRequestInitiated;
+ }, enumerable: !1, configurable: !0 }), r.prototype.completeVRInit = function(t, e) {
+ var n = this;
+ if (this.xrTestDone = !0, e.createFallbackVRDeviceOrientationFreeCamera && (e.useMultiview && (e.vrDeviceOrientationCameraMetrics || (e.vrDeviceOrientationCameraMetrics = cr.GetDefault()), e.vrDeviceOrientationCameraMetrics.multiviewEnabled = !0), this._vrDeviceOrientationCamera = new Ro("VRDeviceOrientationVRHelper", this._position, this._scene, !0, e.vrDeviceOrientationCameraMetrics), this._vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE), this._webVRCamera = new Mo("WebVRHelper", this._position, this._scene, e), this._webVRCamera.useStandingMatrix(), this._cameraGazer = new Ml(function() {
+ return n.currentVRCamera;
+ }, t), !this._useCustomVRButton) {
+ this._btnVR = document.createElement("BUTTON"), this._btnVR.className = "babylonVRicon", this._btnVR.id = "babylonVRiconbtn", this._btnVR.title = "Click to switch to VR";
+ var i = ".babylonVRicon { position: absolute; right: 20px; height: 50px; width: 80px; background-color: rgba(51,51,51,0.7); background-image: url(" + (window.SVGSVGElement ? "data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%222048%22%20height%3D%221152%22%20viewBox%3D%220%200%202048%201152%22%20version%3D%221.1%22%3E%3Cpath%20transform%3D%22rotate%28180%201024%2C576.0000000000001%29%22%20d%3D%22m1109%2C896q17%2C0%2030%2C-12t13%2C-30t-12.5%2C-30.5t-30.5%2C-12.5l-170%2C0q-18%2C0%20-30.5%2C12.5t-12.5%2C30.5t13%2C30t30%2C12l170%2C0zm-85%2C256q59%2C0%20132.5%2C-1.5t154.5%2C-5.5t164.5%2C-11.5t163%2C-20t150%2C-30t124.5%2C-41.5q23%2C-11%2042%2C-24t38%2C-30q27%2C-25%2041%2C-61.5t14%2C-72.5l0%2C-257q0%2C-123%20-47%2C-232t-128%2C-190t-190%2C-128t-232%2C-47l-81%2C0q-37%2C0%20-68.5%2C14t-60.5%2C34.5t-55.5%2C45t-53%2C45t-53%2C34.5t-55.5%2C14t-55.5%2C-14t-53%2C-34.5t-53%2C-45t-55.5%2C-45t-60.5%2C-34.5t-68.5%2C-14l-81%2C0q-123%2C0%20-232%2C47t-190%2C128t-128%2C190t-47%2C232l0%2C257q0%2C68%2038%2C115t97%2C73q54%2C24%20124.5%2C41.5t150%2C30t163%2C20t164.5%2C11.5t154.5%2C5.5t132.5%2C1.5zm939%2C-298q0%2C39%20-24.5%2C67t-58.5%2C42q-54%2C23%20-122%2C39.5t-143.5%2C28t-155.5%2C19t-157%2C11t-148.5%2C5t-129.5%2C1.5q-59%2C0%20-130%2C-1.5t-148%2C-5t-157%2C-11t-155.5%2C-19t-143.5%2C-28t-122%2C-39.5q-34%2C-14%20-58.5%2C-42t-24.5%2C-67l0%2C-257q0%2C-106%2040.5%2C-199t110%2C-162.5t162.5%2C-109.5t199%2C-40l81%2C0q27%2C0%2052%2C14t50%2C34.5t51%2C44.5t55.5%2C44.5t63.5%2C34.5t74%2C14t74%2C-14t63.5%2C-34.5t55.5%2C-44.5t51%2C-44.5t50%2C-34.5t52%2C-14l14%2C0q37%2C0%2070%2C0.5t64.5%2C4.5t63.5%2C12t68%2C23q71%2C30%20128.5%2C78.5t98.5%2C110t63.5%2C133.5t22.5%2C149l0%2C257z%22%20fill%3D%22white%22%20/%3E%3C/svg%3E%0A" : "https://cdn.babylonjs.com/Assets/vrButton.png") + "); background-size: 80%; background-repeat:no-repeat; background-position: center; border: none; outline: none; transition: transform 0.125s ease-out } .babylonVRicon:hover { transform: scale(1.05) } .babylonVRicon:active {background-color: rgba(51,51,51,1) } .babylonVRicon:focus {background-color: rgba(51,51,51,1) }";
+ i += ".babylonVRicon.vrdisplaypresenting { display: none; }";
+ var o = document.createElement("style");
+ o.appendChild(document.createTextNode(i)), document.getElementsByTagName("head")[0].appendChild(o), this.moveButtonToBottomRight();
+ }
+ this._btnVR && this._btnVR.addEventListener("click", function() {
+ n.isInVRMode ? n._scene.getEngine().disableVR() : n.enterVR();
+ });
+ var a = this._scene.getEngine().getHostWindow();
+ a && (a.addEventListener("resize", this._onResize), document.addEventListener("fullscreenchange", this._onFullscreenChange, !1), document.addEventListener("mozfullscreenchange", this._onFullscreenChange, !1), document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, !1), document.addEventListener("msfullscreenchange", this._onFullscreenChange, !1), document.onmsfullscreenchange = this._onFullscreenChange, e.createFallbackVRDeviceOrientationFreeCamera ? this.displayVRButton() : this._scene.getEngine().onVRDisplayChangedObservable.add(function(s) {
+ s.vrDisplay && n.displayVRButton();
+ }), this._onKeyDown = function(s) {
+ s.keyCode === 27 && n.isInVRMode && n.exitVR();
+ }, document.addEventListener("keydown", this._onKeyDown), this._scene.onPrePointerObservable.add(function() {
+ n._hasEnteredVR && n.exitVROnDoubleTap && (n.exitVR(), n._fullscreenVRpresenting && n._scene.getEngine().exitFullscreen());
+ }, yt.a.POINTERDOUBLETAP, !1), this._onVRDisplayChanged = function(s) {
+ return n.onVRDisplayChanged(s);
+ }, this._onVrDisplayPresentChange = function() {
+ return n.onVrDisplayPresentChange();
+ }, this._onVRRequestPresentStart = function() {
+ n._webVRrequesting = !0, n.updateButtonVisibility();
+ }, this._onVRRequestPresentComplete = function() {
+ n._webVRrequesting = !1, n.updateButtonVisibility();
+ }, t.getEngine().onVRDisplayChangedObservable.add(this._onVRDisplayChanged), t.getEngine().onVRRequestPresentStart.add(this._onVRRequestPresentStart), t.getEngine().onVRRequestPresentComplete.add(this._onVRRequestPresentComplete), a.addEventListener("vrdisplaypresentchange", this._onVrDisplayPresentChange), t.onDisposeObservable.add(function() {
+ n.dispose();
+ }), this._webVRCamera.onControllerMeshLoadedObservable.add(function(s) {
+ return n._onDefaultMeshLoaded(s);
+ }), this._scene.gamepadManager.onGamepadConnectedObservable.add(this._onNewGamepadConnected), this._scene.gamepadManager.onGamepadDisconnectedObservable.add(this._onNewGamepadDisconnected), this.updateButtonVisibility(), this._circleEase = new tt(), this._circleEase.setEasingMode(Ge.EASINGMODE_EASEINOUT), this._teleportationEasing = this._circleEase, t.onPointerObservable.add(function(s) {
+ n._interactionsEnabled && t.activeCamera === n.vrDeviceOrientationCamera && s.event.pointerType === "mouse" && (s.type === yt.a.POINTERDOWN ? n._cameraGazer._selectionPointerDown() : s.type === yt.a.POINTERUP && n._cameraGazer._selectionPointerUp());
+ }), this.webVROptions.floorMeshes && this.enableTeleportation({ floorMeshes: this.webVROptions.floorMeshes }));
+ }, r.prototype._onDefaultMeshLoaded = function(t) {
+ this._leftController && this._leftController.webVRController == t && t.mesh && this._leftController._setLaserPointerParent(t.mesh), this._rightController && this._rightController.webVRController == t && t.mesh && this._rightController._setLaserPointerParent(t.mesh);
+ try {
+ this.onControllerMeshLoadedObservable.notifyObservers(t);
+ } catch (e) {
+ l.a.Warn("Error in your custom logic onControllerMeshLoaded: " + e);
+ }
+ }, Object.defineProperty(r.prototype, "isInVRMode", { get: function() {
+ return this.xr && this.webVROptions.useXR && this.xr.baseExperience.state === fn.IN_XR || this._webVRpresenting || this._fullscreenVRpresenting;
+ }, enumerable: !1, configurable: !0 }), r.prototype.onVrDisplayPresentChange = function() {
+ var t = this._scene.getEngine().getVRDevice();
+ if (t) {
+ var e = this._webVRpresenting;
+ this._webVRpresenting = t.isPresenting, e && !this._webVRpresenting && this.exitVR();
+ } else
+ l.a.Warn("Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?");
+ this.updateButtonVisibility();
+ }, r.prototype.onVRDisplayChanged = function(t) {
+ this._webVRsupported = t.vrSupported, this._webVRready = !!t.vrDisplay, this._webVRpresenting = t.vrDisplay && t.vrDisplay.isPresenting, this.updateButtonVisibility();
+ }, r.prototype.moveButtonToBottomRight = function() {
+ if (this._inputElement && !this._useCustomVRButton && this._btnVR) {
+ var t = this._inputElement.getBoundingClientRect();
+ this._btnVR.style.top = t.top + t.height - 70 + "px", this._btnVR.style.left = t.left + t.width - 100 + "px";
+ }
+ }, r.prototype.displayVRButton = function() {
+ this._useCustomVRButton || this._btnVRDisplayed || !this._btnVR || (document.body.appendChild(this._btnVR), this._btnVRDisplayed = !0);
+ }, r.prototype.updateButtonVisibility = function() {
+ this._btnVR && !this._useCustomVRButton && (this._btnVR.className = "babylonVRicon", this.isInVRMode ? this._btnVR.className += " vrdisplaypresenting" : (this._webVRready && (this._btnVR.className += " vrdisplayready"), this._webVRsupported && (this._btnVR.className += " vrdisplaysupported"), this._webVRrequesting && (this._btnVR.className += " vrdisplayrequesting")));
+ }, r.prototype.enterVR = function() {
+ var t = this;
+ if (this.xr)
+ this.xr.baseExperience.enterXRAsync("immersive-vr", "local-floor", this.xr.renderTarget);
+ else {
+ if (this.onEnteringVRObservable)
+ try {
+ this.onEnteringVRObservable.notifyObservers(this);
+ } catch (o) {
+ l.a.Warn("Error in your custom logic onEnteringVR: " + o);
+ }
+ if (this._scene.activeCamera) {
+ if (this._position = this._scene.activeCamera.position.clone(), this.vrDeviceOrientationCamera && (this.vrDeviceOrientationCamera.rotation = u.b.FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles(), this.vrDeviceOrientationCamera.angularSensibility = 2e3), this.webVRCamera) {
+ var e = this.webVRCamera.deviceRotationQuaternion.toEulerAngles().y, n = u.b.FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y - e, i = this.webVRCamera.rotationQuaternion.toEulerAngles().y;
+ this.webVRCamera.rotationQuaternion = u.b.FromEulerAngles(0, i + n, 0);
+ }
+ this._existingCamera = this._scene.activeCamera, this._existingCamera.angularSensibilityX && (this._cachedAngularSensibility.angularSensibilityX = this._existingCamera.angularSensibilityX, this._existingCamera.angularSensibilityX = Number.MAX_VALUE), this._existingCamera.angularSensibilityY && (this._cachedAngularSensibility.angularSensibilityY = this._existingCamera.angularSensibilityY, this._existingCamera.angularSensibilityY = Number.MAX_VALUE), this._existingCamera.angularSensibility && (this._cachedAngularSensibility.angularSensibility = this._existingCamera.angularSensibility, this._existingCamera.angularSensibility = Number.MAX_VALUE);
+ }
+ this._webVRrequesting || (this._webVRready ? this._webVRpresenting || (this._scene.getEngine().onVRRequestPresentComplete.addOnce(function(o) {
+ t.onAfterEnteringVRObservable.notifyObservers({ success: o });
+ }), this._webVRCamera.position = this._position, this._scene.activeCamera = this._webVRCamera) : this._vrDeviceOrientationCamera && (this._vrDeviceOrientationCamera.position = this._position, this._scene.activeCamera && (this._vrDeviceOrientationCamera.minZ = this._scene.activeCamera.minZ), this._scene.activeCamera = this._vrDeviceOrientationCamera, this._scene.getEngine().enterFullscreen(this.requestPointerLockOnFullScreen), this.updateButtonVisibility(), this._vrDeviceOrientationCamera.onViewMatrixChangedObservable.addOnce(function() {
+ t.onAfterEnteringVRObservable.notifyObservers({ success: !0 });
+ })), this._scene.activeCamera && this._inputElement && this._scene.activeCamera.attachControl(), this._interactionsEnabled && this._scene.registerBeforeRender(this.beforeRender), this._displayLaserPointer && [this._leftController, this._rightController].forEach(function(o) {
+ o && o._activatePointer();
+ }), this._hasEnteredVR = !0);
+ }
+ }, r.prototype.exitVR = function() {
+ if (this.xr)
+ this.xr.baseExperience.exitXRAsync();
+ else if (this._hasEnteredVR) {
+ if (this.onExitingVRObservable)
+ try {
+ this.onExitingVRObservable.notifyObservers(this);
+ } catch (e) {
+ l.a.Warn("Error in your custom logic onExitingVR: " + e);
+ }
+ this._webVRpresenting && this._scene.getEngine().disableVR(), this._scene.activeCamera && (this._position = this._scene.activeCamera.position.clone()), this.vrDeviceOrientationCamera && (this.vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE), this._deviceOrientationCamera ? (this._deviceOrientationCamera.position = this._position, this._scene.activeCamera = this._deviceOrientationCamera, this._cachedAngularSensibility.angularSensibilityX && (this._deviceOrientationCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX, this._cachedAngularSensibility.angularSensibilityX = null), this._cachedAngularSensibility.angularSensibilityY && (this._deviceOrientationCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY, this._cachedAngularSensibility.angularSensibilityY = null), this._cachedAngularSensibility.angularSensibility && (this._deviceOrientationCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility, this._cachedAngularSensibility.angularSensibility = null)) : this._existingCamera && (this._existingCamera.position = this._position, this._scene.activeCamera = this._existingCamera, this._inputElement && this._scene.activeCamera.attachControl(), this._cachedAngularSensibility.angularSensibilityX && (this._existingCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX, this._cachedAngularSensibility.angularSensibilityX = null), this._cachedAngularSensibility.angularSensibilityY && (this._existingCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY, this._cachedAngularSensibility.angularSensibilityY = null), this._cachedAngularSensibility.angularSensibility && (this._existingCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility, this._cachedAngularSensibility.angularSensibility = null)), this.updateButtonVisibility(), this._interactionsEnabled && (this._scene.unregisterBeforeRender(this.beforeRender), this._cameraGazer._gazeTracker.isVisible = !1, this._leftController && (this._leftController._gazeTracker.isVisible = !1), this._rightController && (this._rightController._gazeTracker.isVisible = !1)), this._scene.getEngine().resize(), [this._leftController, this._rightController].forEach(function(e) {
+ e && e._deactivatePointer();
+ }), this._hasEnteredVR = !1;
+ var t = this._scene.getEngine();
+ t._onVrDisplayPresentChange && t._onVrDisplayPresentChange();
+ }
+ }, Object.defineProperty(r.prototype, "position", { get: function() {
+ return this._position;
+ }, set: function(t) {
+ this._position = t, this._scene.activeCamera && (this._scene.activeCamera.position = t);
+ }, enumerable: !1, configurable: !0 }), r.prototype.enableInteractions = function() {
+ var t = this;
+ if (!this._interactionsEnabled) {
+ if (this._interactionsRequested = !0, this.xr)
+ return void (this.xr.baseExperience.state === fn.IN_XR && this.xr.pointerSelection.attach());
+ this._leftController && this._enableInteractionOnController(this._leftController), this._rightController && this._enableInteractionOnController(this._rightController), this.raySelectionPredicate = function(e) {
+ return e.isVisible && (e.isPickable || e.name === t._floorMeshName);
+ }, this.meshSelectionPredicate = function() {
+ return !0;
+ }, this._raySelectionPredicate = function(e) {
+ return !!(t._isTeleportationFloor(e) || e.name.indexOf("gazeTracker") === -1 && e.name.indexOf("teleportationTarget") === -1 && e.name.indexOf("torusTeleportation") === -1) && t.raySelectionPredicate(e);
+ }, this._interactionsEnabled = !0;
+ }
+ }, Object.defineProperty(r.prototype, "_noControllerIsActive", { get: function() {
+ return !(this._leftController && this._leftController._activePointer || this._rightController && this._rightController._activePointer);
+ }, enumerable: !1, configurable: !0 }), r.prototype._isTeleportationFloor = function(t) {
+ for (var e = 0; e < this._floorMeshesCollection.length; e++)
+ if (this._floorMeshesCollection[e].id === t.id)
+ return !0;
+ return !(!this._floorMeshName || t.name !== this._floorMeshName);
+ }, r.prototype.addFloorMesh = function(t) {
+ this._floorMeshesCollection && (this._floorMeshesCollection.indexOf(t) > -1 || this._floorMeshesCollection.push(t));
+ }, r.prototype.removeFloorMesh = function(t) {
+ if (this._floorMeshesCollection) {
+ var e = this._floorMeshesCollection.indexOf(t);
+ e !== -1 && this._floorMeshesCollection.splice(e, 1);
+ }
+ }, r.prototype.enableTeleportation = function(t) {
+ var e = this;
+ if (t === void 0 && (t = {}), !this._teleportationInitialized) {
+ if (this._teleportationRequested = !0, this.enableInteractions(), this.webVROptions.useXR && (t.floorMeshes || t.floorMeshName)) {
+ var n = t.floorMeshes || [];
+ if (!n.length) {
+ var i = this._scene.getMeshByName(t.floorMeshName);
+ i && n.push(i);
+ }
+ if (this.xr)
+ return n.forEach(function(s) {
+ e.xr.teleportation.addFloorMesh(s);
+ }), void (this.xr.teleportation.attached || this.xr.teleportation.attach());
+ if (!this.xrTestDone) {
+ var o = function() {
+ e.xrTestDone && (e._scene.unregisterBeforeRender(o), e.xr ? e.xr.teleportation.attached || e.xr.teleportation.attach() : e.enableTeleportation(t));
+ };
+ return void this._scene.registerBeforeRender(o);
+ }
+ }
+ t.floorMeshName && (this._floorMeshName = t.floorMeshName), t.floorMeshes && (this._floorMeshesCollection = t.floorMeshes), t.teleportationMode && (this._teleportationMode = t.teleportationMode), t.teleportationTime && t.teleportationTime > 0 && (this._teleportationTime = t.teleportationTime), t.teleportationSpeed && t.teleportationSpeed > 0 && (this._teleportationSpeed = t.teleportationSpeed), t.easingFunction !== void 0 && (this._teleportationEasing = t.easingFunction), this._leftController != null && this._enableTeleportationOnController(this._leftController), this._rightController != null && this._enableTeleportationOnController(this._rightController);
+ var a = new vn.a();
+ a.vignetteColor = new I.b(0, 0, 0, 0), a.vignetteEnabled = !0, this._postProcessMove = new Io("postProcessMove", 1, this._webVRCamera, void 0, void 0, void 0, void 0, a), this._webVRCamera.detachPostProcess(this._postProcessMove), this._teleportationInitialized = !0, this._isDefaultTeleportationTarget && (this._createTeleportationCircles(), this._teleportationTarget.scaling.scaleInPlace(this._webVRCamera.deviceScaleFactor));
+ }
+ }, r.prototype._enableInteractionOnController = function(t) {
+ var e = this;
+ t.webVRController.mesh && (t._interactionsEnabled = !0, this.isInVRMode && this._displayLaserPointer && t._activatePointer(), this.webVROptions.laserToggle && t.webVRController.onMainButtonStateChangedObservable.add(function(n) {
+ e._displayLaserPointer && n.value === 1 && (t._activePointer ? t._deactivatePointer() : t._activatePointer(), e.displayGaze && (t._gazeTracker.isVisible = t._activePointer));
+ }), t.webVRController.onTriggerStateChangedObservable.add(function(n) {
+ var i = t;
+ e._noControllerIsActive && (i = e._cameraGazer), i._pointerDownOnMeshAsked ? n.value < e._padSensibilityDown && i._selectionPointerUp() : n.value > e._padSensibilityUp && i._selectionPointerDown();
+ }));
+ }, r.prototype._checkTeleportWithRay = function(t, e) {
+ this._teleportationRequestInitiated && !e._teleportationRequestInitiated || (e._teleportationRequestInitiated ? Math.sqrt(t.y * t.y + t.x * t.x) < this._padSensibilityDown && (this._teleportActive && this.teleportCamera(this._haloCenter), e._teleportationRequestInitiated = !1) : t.y < -this._padSensibilityUp && e._dpadPressed && (e._activatePointer(), e._teleportationRequestInitiated = !0));
+ }, r.prototype._checkRotate = function(t, e) {
+ e._teleportationRequestInitiated || (e._rotationLeftAsked ? t.x > -this._padSensibilityDown && (e._rotationLeftAsked = !1) : t.x < -this._padSensibilityUp && e._dpadPressed && (e._rotationLeftAsked = !0, this._rotationAllowed && this._rotateCamera(!1)), e._rotationRightAsked ? t.x < this._padSensibilityDown && (e._rotationRightAsked = !1) : t.x > this._padSensibilityUp && e._dpadPressed && (e._rotationRightAsked = !0, this._rotationAllowed && this._rotateCamera(!0)));
+ }, r.prototype._checkTeleportBackwards = function(t, e) {
+ if (!e._teleportationRequestInitiated)
+ if (t.y > this._padSensibilityUp && e._dpadPressed) {
+ if (!e._teleportationBackRequestInitiated) {
+ if (!this.currentVRCamera)
+ return;
+ var n = u.b.FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix()), i = this.currentVRCamera.position;
+ this.currentVRCamera.devicePosition && this.currentVRCamera.deviceRotationQuaternion && (n = this.currentVRCamera.deviceRotationQuaternion, i = this.currentVRCamera.devicePosition), n.toEulerAnglesToRef(this._workingVector), this._workingVector.z = 0, this._workingVector.x = 0, u.b.RotationYawPitchRollToRef(this._workingVector.y, this._workingVector.x, this._workingVector.z, this._workingQuaternion), this._workingQuaternion.toRotationMatrix(this._workingMatrix), u.e.TransformCoordinatesToRef(this._teleportBackwardsVector, this._workingMatrix, this._workingVector);
+ var o = new dn.a(i, this._workingVector), a = this._scene.pickWithRay(o, this._raySelectionPredicate);
+ a && a.pickedPoint && a.pickedMesh && this._isTeleportationFloor(a.pickedMesh) && a.distance < 5 && this.teleportCamera(a.pickedPoint), e._teleportationBackRequestInitiated = !0;
+ }
+ } else
+ e._teleportationBackRequestInitiated = !1;
+ }, r.prototype._enableTeleportationOnController = function(t) {
+ var e = this;
+ t.webVRController.mesh && (t._interactionsEnabled || this._enableInteractionOnController(t), t._interactionsEnabled = !0, t._teleportationEnabled = !0, t.webVRController.controllerType === Jn.VIVE && (t._dpadPressed = !1, t.webVRController.onPadStateChangedObservable.add(function(n) {
+ t._dpadPressed = n.pressed, t._dpadPressed || (t._rotationLeftAsked = !1, t._rotationRightAsked = !1, t._teleportationBackRequestInitiated = !1);
+ })), t.webVRController.onPadValuesChangedObservable.add(function(n) {
+ e.teleportationEnabled && (e._checkTeleportBackwards(n, t), e._checkTeleportWithRay(n, t)), e._checkRotate(n, t);
+ }));
+ }, r.prototype._createTeleportationCircles = function() {
+ this._teleportationTarget = Ie.a.CreateGround("teleportationTarget", 2, 2, 2, this._scene), this._teleportationTarget.isPickable = !1;
+ var t = new pi.a("DynamicTexture", 512, this._scene, !0);
+ t.hasAlpha = !0;
+ var e = t.getContext();
+ e.beginPath(), e.arc(256, 256, 200, 0, 2 * Math.PI, !1), e.fillStyle = this._teleportationFillColor, e.fill(), e.lineWidth = 10, e.strokeStyle = this._teleportationBorderColor, e.stroke(), e.closePath(), t.update();
+ var n = new Nt.a("TextPlaneMaterial", this._scene);
+ n.diffuseTexture = t, this._teleportationTarget.material = n;
+ var i = Ie.a.CreateTorus("torusTeleportation", 0.75, 0.1, 25, this._scene, !1);
+ i.isPickable = !1, i.parent = this._teleportationTarget;
+ var o = new k("animationInnerCircle", "position.y", 30, k.ANIMATIONTYPE_FLOAT, k.ANIMATIONLOOPMODE_CYCLE), a = [];
+ a.push({ frame: 0, value: 0 }), a.push({ frame: 30, value: 0.4 }), a.push({ frame: 60, value: 0 }), o.setKeys(a);
+ var s = new nn();
+ s.setEasingMode(Ge.EASINGMODE_EASEINOUT), o.setEasingFunction(s), i.animations = [], i.animations.push(o), this._scene.beginAnimation(i, 0, 60, !0), this._hideTeleportationTarget();
+ }, r.prototype._displayTeleportationTarget = function() {
+ this._teleportActive = !0, this._teleportationInitialized && (this._teleportationTarget.isVisible = !0, this._isDefaultTeleportationTarget && (this._teleportationTarget.getChildren()[0].isVisible = !0));
+ }, r.prototype._hideTeleportationTarget = function() {
+ this._teleportActive = !1, this._teleportationInitialized && (this._teleportationTarget.isVisible = !1, this._isDefaultTeleportationTarget && (this._teleportationTarget.getChildren()[0].isVisible = !1));
+ }, r.prototype._rotateCamera = function(t) {
+ var e = this;
+ if (this.currentVRCamera instanceof zn) {
+ t ? this._rotationAngle++ : this._rotationAngle--, this.currentVRCamera.animations = [];
+ var n = u.b.FromRotationMatrix(u.a.RotationY(Math.PI / 4 * this._rotationAngle)), i = new k("animationRotation", "rotationQuaternion", 90, k.ANIMATIONTYPE_QUATERNION, k.ANIMATIONLOOPMODE_CONSTANT), o = [];
+ o.push({ frame: 0, value: this.currentVRCamera.rotationQuaternion }), o.push({ frame: 6, value: n }), i.setKeys(o), i.setEasingFunction(this._circleEase), this.currentVRCamera.animations.push(i), this._postProcessMove.animations = [];
+ var a = new k("animationPP", "vignetteWeight", 90, k.ANIMATIONTYPE_FLOAT, k.ANIMATIONLOOPMODE_CONSTANT), s = [];
+ s.push({ frame: 0, value: 0 }), s.push({ frame: 3, value: 4 }), s.push({ frame: 6, value: 0 }), a.setKeys(s), a.setEasingFunction(this._circleEase), this._postProcessMove.animations.push(a);
+ var d = new k("animationPP2", "vignetteStretch", 90, k.ANIMATIONTYPE_FLOAT, k.ANIMATIONLOOPMODE_CONSTANT), p = [];
+ p.push({ frame: 0, value: 0 }), p.push({ frame: 3, value: 10 }), p.push({ frame: 6, value: 0 }), d.setKeys(p), d.setEasingFunction(this._circleEase), this._postProcessMove.animations.push(d), this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0, this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0, this._postProcessMove.samples = 4, this._webVRCamera.attachPostProcess(this._postProcessMove), this._scene.beginAnimation(this._postProcessMove, 0, 6, !1, 1, function() {
+ e._webVRCamera.detachPostProcess(e._postProcessMove);
+ }), this._scene.beginAnimation(this.currentVRCamera, 0, 6, !1, 1);
+ }
+ }, r.prototype._moveTeleportationSelectorTo = function(t, e, n) {
+ if (t.pickedPoint) {
+ e._teleportationRequestInitiated && (this._displayTeleportationTarget(), this._haloCenter.copyFrom(t.pickedPoint), this._teleportationTarget.position.copyFrom(t.pickedPoint));
+ var i = this._convertNormalToDirectionOfRay(t.getNormal(!0, !1), n);
+ if (i) {
+ var o = u.e.Cross(be.a.Y, i), a = u.e.Cross(i, o);
+ u.e.RotationFromAxisToRef(a, i, o, this._teleportationTarget.rotation);
+ }
+ this._teleportationTarget.position.y += 0.1;
+ }
+ }, r.prototype.teleportCamera = function(t) {
+ var e = this;
+ if (this.currentVRCamera instanceof zn) {
+ this.webVRCamera.leftCamera ? (this._workingVector.copyFrom(this.webVRCamera.leftCamera.globalPosition), this._workingVector.subtractInPlace(this.webVRCamera.position), t.subtractToRef(this._workingVector, this._workingVector)) : this._workingVector.copyFrom(t), this.isInVRMode ? this._workingVector.y += this.webVRCamera.deviceDistanceToRoomGround() * this._webVRCamera.deviceScaleFactor : this._workingVector.y += this._defaultHeight, this.onBeforeCameraTeleport.notifyObservers(this._workingVector);
+ var n, i;
+ if (this._teleportationMode == r.TELEPORTATIONMODE_CONSTANTSPEED) {
+ i = 90;
+ var o = u.e.Distance(this.currentVRCamera.position, this._workingVector);
+ n = this._teleportationSpeed / o;
+ } else
+ i = Math.round(90 * this._teleportationTime / 1e3), n = 1;
+ this.currentVRCamera.animations = [];
+ var a = new k("animationCameraTeleportation", "position", 90, k.ANIMATIONTYPE_VECTOR3, k.ANIMATIONLOOPMODE_CONSTANT), s = [{ frame: 0, value: this.currentVRCamera.position }, { frame: i, value: this._workingVector }];
+ a.setKeys(s), a.setEasingFunction(this._teleportationEasing), this.currentVRCamera.animations.push(a), this._postProcessMove.animations = [];
+ var d = Math.round(i / 2), p = new k("animationPP", "vignetteWeight", 90, k.ANIMATIONTYPE_FLOAT, k.ANIMATIONLOOPMODE_CONSTANT), y = [];
+ y.push({ frame: 0, value: 0 }), y.push({ frame: d, value: 8 }), y.push({ frame: i, value: 0 }), p.setKeys(y), this._postProcessMove.animations.push(p);
+ var P = new k("animationPP2", "vignetteStretch", 90, k.ANIMATIONTYPE_FLOAT, k.ANIMATIONLOOPMODE_CONSTANT), R = [];
+ R.push({ frame: 0, value: 0 }), R.push({ frame: d, value: 10 }), R.push({ frame: i, value: 0 }), P.setKeys(R), this._postProcessMove.animations.push(P), this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0, this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0, this._webVRCamera.attachPostProcess(this._postProcessMove), this._scene.beginAnimation(this._postProcessMove, 0, i, !1, n, function() {
+ e._webVRCamera.detachPostProcess(e._postProcessMove);
+ }), this._scene.beginAnimation(this.currentVRCamera, 0, i, !1, n, function() {
+ e.onAfterCameraTeleport.notifyObservers(e._workingVector);
+ }), this._hideTeleportationTarget();
+ }
+ }, r.prototype._convertNormalToDirectionOfRay = function(t, e) {
+ return t && Math.acos(u.e.Dot(t, e.direction)) < Math.PI / 2 && t.scaleInPlace(-1), t;
+ }, r.prototype._castRayAndSelectObject = function(t) {
+ if (this.currentVRCamera instanceof zn) {
+ var e = t._getForwardRay(this._rayLength), n = this._scene.pickWithRay(e, this._raySelectionPredicate);
+ if (n && (t._laserPointer && (n.originMesh = t._laserPointer.parent), this._scene.simulatePointerMove(n, { pointerId: t._id })), t._currentHit = n, n && n.pickedPoint) {
+ if (this._displayGaze) {
+ var i = 1;
+ t._gazeTracker.isVisible = !0, t._isActionableMesh && (i = 3), this.updateGazeTrackerScale && (t._gazeTracker.scaling.x = n.distance * i, t._gazeTracker.scaling.y = n.distance * i, t._gazeTracker.scaling.z = n.distance * i);
+ var o = this._convertNormalToDirectionOfRay(n.getNormal(), e);
+ if (o) {
+ var a = u.e.Cross(be.a.Y, o), s = u.e.Cross(o, a);
+ u.e.RotationFromAxisToRef(s, o, a, t._gazeTracker.rotation);
+ }
+ t._gazeTracker.position.copyFrom(n.pickedPoint), t._gazeTracker.position.x < 0 ? t._gazeTracker.position.x += 2e-3 : t._gazeTracker.position.x -= 2e-3, t._gazeTracker.position.y < 0 ? t._gazeTracker.position.y += 2e-3 : t._gazeTracker.position.y -= 2e-3, t._gazeTracker.position.z < 0 ? t._gazeTracker.position.z += 2e-3 : t._gazeTracker.position.z -= 2e-3;
+ }
+ t._updatePointerDistance(n.distance);
+ } else
+ t._updatePointerDistance(), t._gazeTracker.isVisible = !1;
+ if (n && n.pickedMesh) {
+ if (this._teleportationInitialized && this._isTeleportationFloor(n.pickedMesh) && n.pickedPoint)
+ return t._currentMeshSelected && !this._isTeleportationFloor(t._currentMeshSelected) && this._notifySelectedMeshUnselected(t._currentMeshSelected), t._currentMeshSelected = null, void (t._teleportationRequestInitiated && this._moveTeleportationSelectorTo(n, t, e));
+ if (n.pickedMesh !== t._currentMeshSelected)
+ if (this.meshSelectionPredicate(n.pickedMesh)) {
+ this.onNewMeshPicked.notifyObservers(n), t._currentMeshSelected = n.pickedMesh, n.pickedMesh.isPickable && n.pickedMesh.actionManager ? (this.changeGazeColor(this._pickedGazeColor), this.changeLaserColor(this._pickedLaserColor), t._isActionableMesh = !0) : (this.changeGazeColor(this._gazeColor), this.changeLaserColor(this._laserColor), t._isActionableMesh = !1);
+ try {
+ this.onNewMeshSelected.notifyObservers(n.pickedMesh);
+ var d = t;
+ d.webVRController && this.onMeshSelectedWithController.notifyObservers({ mesh: n.pickedMesh, controller: d.webVRController });
+ } catch (p) {
+ l.a.Warn("Error while raising onNewMeshSelected or onMeshSelectedWithController: " + p);
+ }
+ } else
+ this._notifySelectedMeshUnselected(t._currentMeshSelected), t._currentMeshSelected = null, this.changeGazeColor(this._gazeColor), this.changeLaserColor(this._laserColor);
+ } else
+ this._notifySelectedMeshUnselected(t._currentMeshSelected), t._currentMeshSelected = null, this.changeGazeColor(this._gazeColor), this.changeLaserColor(this._laserColor);
+ }
+ }, r.prototype._notifySelectedMeshUnselected = function(t) {
+ t && this.onSelectedMeshUnselected.notifyObservers(t);
+ }, r.prototype.setLaserColor = function(t, e) {
+ e === void 0 && (e = this._pickedLaserColor), this._laserColor = t, this._pickedLaserColor = e;
+ }, r.prototype.setLaserLightingState = function(t) {
+ t === void 0 && (t = !0), this._leftController && this._leftController._setLaserPointerLightingDisabled(!t), this._rightController && this._rightController._setLaserPointerLightingDisabled(!t);
+ }, r.prototype.setGazeColor = function(t, e) {
+ e === void 0 && (e = this._pickedGazeColor), this._gazeColor = t, this._pickedGazeColor = e;
+ }, r.prototype.changeLaserColor = function(t) {
+ this.updateControllerLaserColor && (this._leftController && this._leftController._setLaserPointerColor(t), this._rightController && this._rightController._setLaserPointerColor(t));
+ }, r.prototype.changeGazeColor = function(t) {
+ this.updateGazeTrackerColor && this._cameraGazer._gazeTracker.material && (this._cameraGazer._gazeTracker.material.emissiveColor = t, this._leftController && (this._leftController._gazeTracker.material.emissiveColor = t), this._rightController && (this._rightController._gazeTracker.material.emissiveColor = t));
+ }, r.prototype.dispose = function() {
+ this.isInVRMode && this.exitVR(), this._postProcessMove && this._postProcessMove.dispose(), this._webVRCamera && this._webVRCamera.dispose(), this._vrDeviceOrientationCamera && this._vrDeviceOrientationCamera.dispose(), !this._useCustomVRButton && this._btnVR && this._btnVR.parentNode && document.body.removeChild(this._btnVR), this._deviceOrientationCamera && this._scene.activeCamera != this._deviceOrientationCamera && this._deviceOrientationCamera.dispose(), this._cameraGazer && this._cameraGazer.dispose(), this._leftController && this._leftController.dispose(), this._rightController && this._rightController.dispose(), this._teleportationTarget && this._teleportationTarget.dispose(), this.xr && this.xr.dispose(), this._floorMeshesCollection = [], document.removeEventListener("keydown", this._onKeyDown), window.removeEventListener("vrdisplaypresentchange", this._onVrDisplayPresentChange), window.removeEventListener("resize", this._onResize), document.removeEventListener("fullscreenchange", this._onFullscreenChange), document.removeEventListener("mozfullscreenchange", this._onFullscreenChange), document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange), document.removeEventListener("msfullscreenchange", this._onFullscreenChange), document.onmsfullscreenchange = null, this._scene.getEngine().onVRDisplayChangedObservable.removeCallback(this._onVRDisplayChanged), this._scene.getEngine().onVRRequestPresentStart.removeCallback(this._onVRRequestPresentStart), this._scene.getEngine().onVRRequestPresentComplete.removeCallback(this._onVRRequestPresentComplete), window.removeEventListener("vrdisplaypresentchange", this._onVrDisplayPresentChange), this._scene.gamepadManager.onGamepadConnectedObservable.removeCallback(this._onNewGamepadConnected), this._scene.gamepadManager.onGamepadDisconnectedObservable.removeCallback(this._onNewGamepadDisconnected), this._scene.unregisterBeforeRender(this.beforeRender);
+ }, r.prototype.getClassName = function() {
+ return "VRExperienceHelper";
+ }, r.TELEPORTATIONMODE_CONSTANTTIME = 0, r.TELEPORTATIONMODE_CONSTANTSPEED = 1, r;
+ }(), ur = f(64), hr = ($n = { root: 0, found: !1 }, function(r, t, e, n) {
+ $n.root = 0, $n.found = !1;
+ var i = t * t - 4 * r * e;
+ if (i < 0)
+ return $n;
+ var o = Math.sqrt(i), a = (-t - o) / (2 * r), s = (-t + o) / (2 * r);
+ if (a > s) {
+ var d = s;
+ s = a, a = d;
+ }
+ return a > 0 && a < n ? ($n.root = a, $n.found = !0, $n) : (s > 0 && s < n && ($n.root = s, $n.found = !0), $n);
+ }), Dl = function() {
+ function r() {
+ this._collisionPoint = u.e.Zero(), this._planeIntersectionPoint = u.e.Zero(), this._tempVector = u.e.Zero(), this._tempVector2 = u.e.Zero(), this._tempVector3 = u.e.Zero(), this._tempVector4 = u.e.Zero(), this._edge = u.e.Zero(), this._baseToVertex = u.e.Zero(), this._destinationPoint = u.e.Zero(), this._slidePlaneNormal = u.e.Zero(), this._displacementVector = u.e.Zero(), this._radius = u.e.One(), this._retry = 0, this._basePointWorld = u.e.Zero(), this._velocityWorld = u.e.Zero(), this._normalizedVelocity = u.e.Zero(), this._collisionMask = -1;
+ }
+ return Object.defineProperty(r.prototype, "collisionMask", { get: function() {
+ return this._collisionMask;
+ }, set: function(t) {
+ this._collisionMask = isNaN(t) ? -1 : t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "slidePlaneNormal", { get: function() {
+ return this._slidePlaneNormal;
+ }, enumerable: !1, configurable: !0 }), r.prototype._initialize = function(t, e, n) {
+ this._velocity = e, u.e.NormalizeToRef(e, this._normalizedVelocity), this._basePoint = t, t.multiplyToRef(this._radius, this._basePointWorld), e.multiplyToRef(this._radius, this._velocityWorld), this._velocityWorldLength = this._velocityWorld.length(), this._epsilon = n, this.collisionFound = !1;
+ }, r.prototype._checkPointInTriangle = function(t, e, n, i, o) {
+ e.subtractToRef(t, this._tempVector), n.subtractToRef(t, this._tempVector2), u.e.CrossToRef(this._tempVector, this._tempVector2, this._tempVector4);
+ var a = u.e.Dot(this._tempVector4, o);
+ return !(a < 0) && (i.subtractToRef(t, this._tempVector3), u.e.CrossToRef(this._tempVector2, this._tempVector3, this._tempVector4), !((a = u.e.Dot(this._tempVector4, o)) < 0) && (u.e.CrossToRef(this._tempVector3, this._tempVector, this._tempVector4), (a = u.e.Dot(this._tempVector4, o)) >= 0));
+ }, r.prototype._canDoCollision = function(t, e, n, i) {
+ var o = u.e.Distance(this._basePointWorld, t), a = Math.max(this._radius.x, this._radius.y, this._radius.z);
+ return !(o > this._velocityWorldLength + a + e) && !!function(s, d, p, y) {
+ return !(s.x > p.x + y) && !(p.x - y > d.x) && !(s.y > p.y + y) && !(p.y - y > d.y) && !(s.z > p.z + y) && !(p.z - y > d.z);
+ }(n, i, this._basePointWorld, this._velocityWorldLength + a);
+ }, r.prototype._testTriangle = function(t, e, n, i, o, a, s) {
+ var d, p = !1;
+ e || (e = []), e[t] || (e[t] = new ur.a(0, 0, 0, 0), e[t].copyFromPoints(n, i, o));
+ var y = e[t];
+ if (a || y.isFrontFacingTo(this._normalizedVelocity, 0)) {
+ var P = y.signedDistanceTo(this._basePoint), R = u.e.Dot(y.normal, this._velocity);
+ if (R == 0) {
+ if (Math.abs(P) >= 1)
+ return;
+ p = !0, d = 0;
+ } else {
+ var B = (1 - P) / R;
+ if ((d = (-1 - P) / R) > B) {
+ var F = B;
+ B = d, d = F;
+ }
+ if (d > 1 || B < 0)
+ return;
+ d < 0 && (d = 0), d > 1 && (d = 1);
+ }
+ this._collisionPoint.copyFromFloats(0, 0, 0);
+ var z = !1, J = 1;
+ if (p || (this._basePoint.subtractToRef(y.normal, this._planeIntersectionPoint), this._velocity.scaleToRef(d, this._tempVector), this._planeIntersectionPoint.addInPlace(this._tempVector), this._checkPointInTriangle(this._planeIntersectionPoint, n, i, o, y.normal) && (z = !0, J = d, this._collisionPoint.copyFrom(this._planeIntersectionPoint))), !z) {
+ var ie = this._velocity.lengthSquared(), se = ie;
+ this._basePoint.subtractToRef(n, this._tempVector);
+ var ce = 2 * u.e.Dot(this._velocity, this._tempVector), ue = this._tempVector.lengthSquared() - 1, fe = hr(se, ce, ue, J);
+ fe.found && (J = fe.root, z = !0, this._collisionPoint.copyFrom(n)), this._basePoint.subtractToRef(i, this._tempVector), ce = 2 * u.e.Dot(this._velocity, this._tempVector), ue = this._tempVector.lengthSquared() - 1, (fe = hr(se, ce, ue, J)).found && (J = fe.root, z = !0, this._collisionPoint.copyFrom(i)), this._basePoint.subtractToRef(o, this._tempVector), ce = 2 * u.e.Dot(this._velocity, this._tempVector), ue = this._tempVector.lengthSquared() - 1, (fe = hr(se, ce, ue, J)).found && (J = fe.root, z = !0, this._collisionPoint.copyFrom(o)), i.subtractToRef(n, this._edge), n.subtractToRef(this._basePoint, this._baseToVertex);
+ var ve = this._edge.lengthSquared(), Te = u.e.Dot(this._edge, this._velocity), Re = u.e.Dot(this._edge, this._baseToVertex);
+ if (se = ve * -ie + Te * Te, ce = ve * (2 * u.e.Dot(this._velocity, this._baseToVertex)) - 2 * Te * Re, ue = ve * (1 - this._baseToVertex.lengthSquared()) + Re * Re, (fe = hr(se, ce, ue, J)).found) {
+ var Ae = (Te * fe.root - Re) / ve;
+ Ae >= 0 && Ae <= 1 && (J = fe.root, z = !0, this._edge.scaleInPlace(Ae), n.addToRef(this._edge, this._collisionPoint));
+ }
+ o.subtractToRef(i, this._edge), i.subtractToRef(this._basePoint, this._baseToVertex), ve = this._edge.lengthSquared(), Te = u.e.Dot(this._edge, this._velocity), Re = u.e.Dot(this._edge, this._baseToVertex), se = ve * -ie + Te * Te, ce = ve * (2 * u.e.Dot(this._velocity, this._baseToVertex)) - 2 * Te * Re, ue = ve * (1 - this._baseToVertex.lengthSquared()) + Re * Re, (fe = hr(se, ce, ue, J)).found && (Ae = (Te * fe.root - Re) / ve) >= 0 && Ae <= 1 && (J = fe.root, z = !0, this._edge.scaleInPlace(Ae), i.addToRef(this._edge, this._collisionPoint)), n.subtractToRef(o, this._edge), o.subtractToRef(this._basePoint, this._baseToVertex), ve = this._edge.lengthSquared(), Te = u.e.Dot(this._edge, this._velocity), Re = u.e.Dot(this._edge, this._baseToVertex), se = ve * -ie + Te * Te, ce = ve * (2 * u.e.Dot(this._velocity, this._baseToVertex)) - 2 * Te * Re, ue = ve * (1 - this._baseToVertex.lengthSquared()) + Re * Re, (fe = hr(se, ce, ue, J)).found && (Ae = (Te * fe.root - Re) / ve) >= 0 && Ae <= 1 && (J = fe.root, z = !0, this._edge.scaleInPlace(Ae), o.addToRef(this._edge, this._collisionPoint));
+ }
+ if (z) {
+ var Ee = J * this._velocity.length();
+ (!this.collisionFound || Ee < this._nearestDistance) && (s.collisionResponse && (this.intersectionPoint ? this.intersectionPoint.copyFrom(this._collisionPoint) : this.intersectionPoint = this._collisionPoint.clone(), this._nearestDistance = Ee, this.collisionFound = !0), this.collidedMesh = s);
+ }
+ }
+ }, r.prototype._collide = function(t, e, n, i, o, a, s, d) {
+ if (n && n.length !== 0)
+ for (p = i; p < o; p += 3)
+ y = e[n[p] - a], P = e[n[p + 1] - a], R = e[n[p + 2] - a], this._testTriangle(p, t, R, P, y, s, d);
+ else
+ for (var p = 0; p < e.length; p += 3) {
+ var y = e[p], P = e[p + 1], R = e[p + 2];
+ this._testTriangle(p, t, R, P, y, s, d);
+ }
+ }, r.prototype._getResponse = function(t, e) {
+ t.addToRef(e, this._destinationPoint), e.scaleInPlace(this._nearestDistance / e.length()), this._basePoint.addToRef(e, t), t.subtractToRef(this.intersectionPoint, this._slidePlaneNormal), this._slidePlaneNormal.normalize(), this._slidePlaneNormal.scaleToRef(this._epsilon, this._displacementVector), t.addInPlace(this._displacementVector), this.intersectionPoint.addInPlace(this._displacementVector), this._slidePlaneNormal.scaleInPlace(ur.a.SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint, this._slidePlaneNormal, this._destinationPoint)), this._destinationPoint.subtractInPlace(this._slidePlaneNormal), this._destinationPoint.subtractToRef(this.intersectionPoint, e);
+ }, r;
+ }(), Ll = function() {
+ function r() {
+ this._scaledPosition = u.e.Zero(), this._scaledVelocity = u.e.Zero(), this._finalPosition = u.e.Zero();
+ }
+ return r.prototype.getNewPosition = function(t, e, n, i, o, a, s) {
+ t.divideToRef(n._radius, this._scaledPosition), e.divideToRef(n._radius, this._scaledVelocity), n.collidedMesh = null, n._retry = 0, n._initialVelocity = this._scaledVelocity, n._initialPosition = this._scaledPosition, this._collideWithWorld(this._scaledPosition, this._scaledVelocity, n, i, this._finalPosition, o), this._finalPosition.multiplyInPlace(n._radius), a(s, this._finalPosition, n.collidedMesh);
+ }, r.prototype.createCollider = function() {
+ return new Dl();
+ }, r.prototype.init = function(t) {
+ this._scene = t;
+ }, r.prototype._collideWithWorld = function(t, e, n, i, o, a) {
+ a === void 0 && (a = null);
+ var s = 10 * Ue.a.CollisionsEpsilon;
+ if (n._retry >= i)
+ o.copyFrom(t);
+ else {
+ var d = a ? a.collisionMask : n.collisionMask;
+ n._initialize(t, e, s);
+ for (var p = a && a.surroundingMeshes || this._scene.meshes, y = 0; y < p.length; y++) {
+ var P = p[y];
+ P.isEnabled() && P.checkCollisions && P.subMeshes && P !== a && d & P.collisionGroup && P._checkCollision(n);
+ }
+ n.collisionFound ? (e.x === 0 && e.y === 0 && e.z === 0 || n._getResponse(t, e), e.length() <= s ? o.copyFrom(t) : (n._retry++, this._collideWithWorld(t, e, n, i, o, a))) : t.addToRef(e, o);
+ }
+ }, r;
+ }();
+ _e.a.CollisionCoordinatorFactory = function() {
+ return new Ll();
+ };
+ var Yi = f(54), Rf = f(114), Of = f(147), os = f(103), Mi = f(43), Nl = f(113), wl = function() {
+ function r(t, e, n, i, o, a) {
+ this.entries = new Array(), this._boundingVectors = new Array(), this._capacity = n, this._depth = i, this._maxDepth = o, this._creationFunc = a, this._minPoint = t, this._maxPoint = e, this._boundingVectors.push(t.clone()), this._boundingVectors.push(e.clone()), this._boundingVectors.push(t.clone()), this._boundingVectors[2].x = e.x, this._boundingVectors.push(t.clone()), this._boundingVectors[3].y = e.y, this._boundingVectors.push(t.clone()), this._boundingVectors[4].z = e.z, this._boundingVectors.push(e.clone()), this._boundingVectors[5].z = t.z, this._boundingVectors.push(e.clone()), this._boundingVectors[6].x = t.x, this._boundingVectors.push(e.clone()), this._boundingVectors[7].y = t.y;
+ }
+ return Object.defineProperty(r.prototype, "capacity", { get: function() {
+ return this._capacity;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "minPoint", { get: function() {
+ return this._minPoint;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "maxPoint", { get: function() {
+ return this._maxPoint;
+ }, enumerable: !1, configurable: !0 }), r.prototype.addEntry = function(t) {
+ if (this.blocks)
+ for (var e = 0; e < this.blocks.length; e++)
+ this.blocks[e].addEntry(t);
+ else
+ this._creationFunc(t, this), this.entries.length > this.capacity && this._depth < this._maxDepth && this.createInnerBlocks();
+ }, r.prototype.removeEntry = function(t) {
+ if (this.blocks)
+ for (var e = 0; e < this.blocks.length; e++)
+ this.blocks[e].removeEntry(t);
+ else {
+ var n = this.entries.indexOf(t);
+ n > -1 && this.entries.splice(n, 1);
+ }
+ }, r.prototype.addEntries = function(t) {
+ for (var e = 0; e < t.length; e++) {
+ var n = t[e];
+ this.addEntry(n);
+ }
+ }, r.prototype.select = function(t, e, n) {
+ if (os.a.IsInFrustum(this._boundingVectors, t)) {
+ if (this.blocks) {
+ for (var i = 0; i < this.blocks.length; i++)
+ this.blocks[i].select(t, e, n);
+ return;
+ }
+ n ? e.concat(this.entries) : e.concatWithNoDuplicate(this.entries);
+ }
+ }, r.prototype.intersects = function(t, e, n, i) {
+ if (os.a.IntersectsSphere(this._minPoint, this._maxPoint, t, e)) {
+ if (this.blocks) {
+ for (var o = 0; o < this.blocks.length; o++)
+ this.blocks[o].intersects(t, e, n, i);
+ return;
+ }
+ i ? n.concat(this.entries) : n.concatWithNoDuplicate(this.entries);
+ }
+ }, r.prototype.intersectsRay = function(t, e) {
+ if (t.intersectsBoxMinMax(this._minPoint, this._maxPoint)) {
+ if (this.blocks) {
+ for (var n = 0; n < this.blocks.length; n++)
+ this.blocks[n].intersectsRay(t, e);
+ return;
+ }
+ e.concatWithNoDuplicate(this.entries);
+ }
+ }, r.prototype.createInnerBlocks = function() {
+ r._CreateBlocks(this._minPoint, this._maxPoint, this.entries, this._capacity, this._depth, this._maxDepth, this, this._creationFunc);
+ }, r._CreateBlocks = function(t, e, n, i, o, a, s, d) {
+ s.blocks = new Array();
+ for (var p = new u.e((e.x - t.x) / 2, (e.y - t.y) / 2, (e.z - t.z) / 2), y = 0; y < 2; y++)
+ for (var P = 0; P < 2; P++)
+ for (var R = 0; R < 2; R++) {
+ var B = new r(t.add(p.multiplyByFloats(y, P, R)), t.add(p.multiplyByFloats(y + 1, P + 1, R + 1)), i, o + 1, a, d);
+ B.addEntries(n), s.blocks.push(B);
+ }
+ }, r;
+ }(), Wr = function() {
+ function r(t, e, n) {
+ n === void 0 && (n = 2), this.maxDepth = n, this.dynamicContent = new Array(), this._maxBlockCapacity = e || 64, this._selectionContent = new si.b(1024), this._creationFunc = t;
+ }
+ return r.prototype.update = function(t, e, n) {
+ wl._CreateBlocks(t, e, n, this._maxBlockCapacity, 0, this.maxDepth, this, this._creationFunc);
+ }, r.prototype.addMesh = function(t) {
+ for (var e = 0; e < this.blocks.length; e++)
+ this.blocks[e].addEntry(t);
+ }, r.prototype.removeMesh = function(t) {
+ for (var e = 0; e < this.blocks.length; e++)
+ this.blocks[e].removeEntry(t);
+ }, r.prototype.select = function(t, e) {
+ this._selectionContent.reset();
+ for (var n = 0; n < this.blocks.length; n++)
+ this.blocks[n].select(t, this._selectionContent, e);
+ return e ? this._selectionContent.concat(this.dynamicContent) : this._selectionContent.concatWithNoDuplicate(this.dynamicContent), this._selectionContent;
+ }, r.prototype.intersects = function(t, e, n) {
+ this._selectionContent.reset();
+ for (var i = 0; i < this.blocks.length; i++)
+ this.blocks[i].intersects(t, e, this._selectionContent, n);
+ return n ? this._selectionContent.concat(this.dynamicContent) : this._selectionContent.concatWithNoDuplicate(this.dynamicContent), this._selectionContent;
+ }, r.prototype.intersectsRay = function(t) {
+ this._selectionContent.reset();
+ for (var e = 0; e < this.blocks.length; e++)
+ this.blocks[e].intersectsRay(t, this._selectionContent);
+ return this._selectionContent.concatWithNoDuplicate(this.dynamicContent), this._selectionContent;
+ }, r.CreationFuncForMeshes = function(t, e) {
+ var n = t.getBoundingInfo();
+ !t.isBlocked && n.boundingBox.intersectsMinMax(e.minPoint, e.maxPoint) && e.entries.push(t);
+ }, r.CreationFuncForSubMeshes = function(t, e) {
+ t.getBoundingInfo().boundingBox.intersectsMinMax(e.minPoint, e.maxPoint) && e.entries.push(t);
+ }, r;
+ }();
+ _e.a.prototype.createOrUpdateSelectionOctree = function(r, t) {
+ r === void 0 && (r = 64), t === void 0 && (t = 2);
+ var e = this._getComponent(ot.a.NAME_OCTREE);
+ e || (e = new us(this), this._addComponent(e)), this._selectionOctree || (this._selectionOctree = new Wr(Wr.CreationFuncForMeshes, r, t));
+ var n = this.getWorldExtends();
+ return this._selectionOctree.update(n.min, n.max, this.meshes), this._selectionOctree;
+ }, Object.defineProperty(_e.a.prototype, "selectionOctree", { get: function() {
+ return this._selectionOctree;
+ }, enumerable: !0, configurable: !0 }), Mt.a.prototype.createOrUpdateSubmeshesOctree = function(r, t) {
+ r === void 0 && (r = 64), t === void 0 && (t = 2);
+ var e = this.getScene(), n = e._getComponent(ot.a.NAME_OCTREE);
+ n || (n = new us(e), e._addComponent(n)), this._submeshesOctree || (this._submeshesOctree = new Wr(Wr.CreationFuncForSubMeshes, r, t)), this.computeWorldMatrix(!0);
+ var i = this.getBoundingInfo().boundingBox;
+ return this._submeshesOctree.update(i.minimumWorld, i.maximumWorld, this.subMeshes), this._submeshesOctree;
+ };
+ var Xt, as, ss, cs, ls, us = function() {
+ function r(t) {
+ this.name = ot.a.NAME_OCTREE, this.checksIsEnabled = !0, this._tempRay = new dn.a(u.e.Zero(), new u.e(1, 1, 1)), this.scene = t, this.scene.getActiveMeshCandidates = this.getActiveMeshCandidates.bind(this), this.scene.getActiveSubMeshCandidates = this.getActiveSubMeshCandidates.bind(this), this.scene.getCollidingSubMeshCandidates = this.getCollidingSubMeshCandidates.bind(this), this.scene.getIntersectingSubMeshCandidates = this.getIntersectingSubMeshCandidates.bind(this);
+ }
+ return r.prototype.register = function() {
+ var t = this;
+ this.scene.onMeshRemovedObservable.add(function(e) {
+ var n = t.scene.selectionOctree;
+ if (n != null) {
+ var i = n.dynamicContent.indexOf(e);
+ i !== -1 && n.dynamicContent.splice(i, 1);
+ }
+ }), this.scene.onMeshImportedObservable.add(function(e) {
+ var n = t.scene.selectionOctree;
+ n != null && n.addMesh(e);
+ });
+ }, r.prototype.getActiveMeshCandidates = function() {
+ return this.scene._selectionOctree ? this.scene._selectionOctree.select(this.scene.frustumPlanes) : this.scene._getDefaultMeshCandidates();
+ }, r.prototype.getActiveSubMeshCandidates = function(t) {
+ return t._submeshesOctree && t.useOctreeForRenderingSelection ? t._submeshesOctree.select(this.scene.frustumPlanes) : this.scene._getDefaultSubMeshCandidates(t);
+ }, r.prototype.getIntersectingSubMeshCandidates = function(t, e) {
+ return t._submeshesOctree && t.useOctreeForPicking ? (dn.a.TransformToRef(e, t.getWorldMatrix(), this._tempRay), t._submeshesOctree.intersectsRay(this._tempRay)) : this.scene._getDefaultSubMeshCandidates(t);
+ }, r.prototype.getCollidingSubMeshCandidates = function(t, e) {
+ if (t._submeshesOctree && t.useOctreeForCollisions) {
+ var n = e._velocityWorldLength + Math.max(e._radius.x, e._radius.y, e._radius.z);
+ return t._submeshesOctree.intersects(e._basePointWorld, n);
+ }
+ return this.scene._getDefaultSubMeshCandidates(t);
+ }, r.prototype.rebuild = function() {
+ }, r.prototype.dispose = function() {
+ }, r;
+ }(), Ki = f(99);
+ (function(r) {
+ r[r.Generic = 0] = "Generic", r[r.Keyboard = 1] = "Keyboard", r[r.Mouse = 2] = "Mouse", r[r.Touch = 3] = "Touch", r[r.DualShock = 4] = "DualShock", r[r.Xbox = 5] = "Xbox", r[r.Switch = 6] = "Switch";
+ })(Xt || (Xt = {})), function(r) {
+ r[r.Horizontal = 0] = "Horizontal", r[r.Vertical = 1] = "Vertical", r[r.LeftClick = 2] = "LeftClick", r[r.MiddleClick = 3] = "MiddleClick", r[r.RightClick = 4] = "RightClick", r[r.BrowserBack = 5] = "BrowserBack", r[r.BrowserForward = 6] = "BrowserForward";
+ }(as || (as = {})), function(r) {
+ r[r.Cross = 0] = "Cross", r[r.Circle = 1] = "Circle", r[r.Square = 2] = "Square", r[r.Triangle = 3] = "Triangle", r[r.L1 = 4] = "L1", r[r.R1 = 5] = "R1", r[r.L2 = 6] = "L2", r[r.R2 = 7] = "R2", r[r.Share = 8] = "Share", r[r.Options = 9] = "Options", r[r.L3 = 10] = "L3", r[r.R3 = 11] = "R3", r[r.DPadUp = 12] = "DPadUp", r[r.DPadDown = 13] = "DPadDown", r[r.DPadLeft = 14] = "DPadLeft", r[r.DPadRight = 15] = "DPadRight", r[r.Home = 16] = "Home", r[r.TouchPad = 17] = "TouchPad", r[r.LStickXAxis = 18] = "LStickXAxis", r[r.LStickYAxis = 19] = "LStickYAxis", r[r.RStickXAxis = 20] = "RStickXAxis", r[r.RStickYAxis = 21] = "RStickYAxis";
+ }(ss || (ss = {})), function(r) {
+ r[r.A = 0] = "A", r[r.B = 1] = "B", r[r.X = 2] = "X", r[r.Y = 3] = "Y", r[r.LB = 4] = "LB", r[r.RB = 5] = "RB", r[r.LT = 6] = "LT", r[r.RT = 7] = "RT", r[r.Back = 8] = "Back", r[r.Start = 9] = "Start", r[r.LS = 10] = "LS", r[r.RS = 11] = "RS", r[r.DPadUp = 12] = "DPadUp", r[r.DPadDown = 13] = "DPadDown", r[r.DPadLeft = 14] = "DPadLeft", r[r.DPadRight = 15] = "DPadRight", r[r.Home = 16] = "Home", r[r.LStickXAxis = 17] = "LStickXAxis", r[r.LStickYAxis = 18] = "LStickYAxis", r[r.RStickXAxis = 19] = "RStickXAxis", r[r.RStickYAxis = 20] = "RStickYAxis";
+ }(cs || (cs = {})), function(r) {
+ r[r.B = 0] = "B", r[r.A = 1] = "A", r[r.Y = 2] = "Y", r[r.X = 3] = "X", r[r.L = 4] = "L", r[r.R = 5] = "R", r[r.ZL = 6] = "ZL", r[r.ZR = 7] = "ZR", r[r.Minus = 8] = "Minus", r[r.Plus = 9] = "Plus", r[r.LS = 10] = "LS", r[r.RS = 11] = "RS", r[r.DPadUp = 12] = "DPadUp", r[r.DPadDown = 13] = "DPadDown", r[r.DPadLeft = 14] = "DPadLeft", r[r.DPadRight = 15] = "DPadRight", r[r.Home = 16] = "Home", r[r.Capture = 17] = "Capture", r[r.LStickXAxis = 18] = "LStickXAxis", r[r.LStickYAxis = 19] = "LStickYAxis", r[r.RStickXAxis = 20] = "RStickXAxis", r[r.RStickYAxis = 21] = "RStickYAxis";
+ }(ls || (ls = {}));
+ var Fl = function() {
+ function r(t) {
+ this.onDeviceDisconnected = function() {
+ }, this._inputs = [], this._keyboardActive = !1, this._pointerActive = !1, this._keyboardDownEvent = function(n) {
+ }, this._keyboardUpEvent = function(n) {
+ }, this._pointerMoveEvent = function(n) {
+ }, this._pointerDownEvent = function(n) {
+ }, this._pointerUpEvent = function(n) {
+ }, this._gamepadConnectedEvent = function(n) {
+ }, this._gamepadDisconnectedEvent = function(n) {
+ }, this._onDeviceConnected = function() {
+ };
+ var e = t.getInputElement();
+ e && (this._elementToAttachTo = e, this._handleKeyActions(), this._handlePointerActions(), this._handleGamepadActions(), this._checkForConnectedDevices());
+ }
+ return Object.defineProperty(r.prototype, "onDeviceConnected", { get: function() {
+ return this._onDeviceConnected;
+ }, set: function(t) {
+ this._onDeviceConnected = t;
+ for (var e = 0; e < this._inputs.length; e++)
+ if (this._inputs[e])
+ for (var n = 0; n < this._inputs[e].length; n++)
+ this._inputs[e][n] && this._onDeviceConnected(e, n);
+ }, enumerable: !1, configurable: !0 }), r.Create = function(t) {
+ return typeof _native < "u" && _native.DeviceInputSystem ? new _native.DeviceInputSystem(t) : new r(t);
+ }, r.prototype.pollInput = function(t, e, n) {
+ var i = this._inputs[t][e];
+ if (!i)
+ throw "Unable to find device " + Xt[t];
+ if (this._updateDevice(t, e, n), i[n] === void 0)
+ throw "Unable to find input " + n + " for device " + Xt[t] + " in slot " + e;
+ return i[n];
+ }, r.prototype.dispose = function() {
+ this._keyboardActive && (window.removeEventListener("keydown", this._keyboardDownEvent), window.removeEventListener("keyup", this._keyboardUpEvent)), this._pointerActive && (this._elementToAttachTo.removeEventListener("pointermove", this._pointerMoveEvent), this._elementToAttachTo.removeEventListener("pointerdown", this._pointerDownEvent), this._elementToAttachTo.removeEventListener("pointerup", this._pointerUpEvent)), window.removeEventListener("gamepadconnected", this._gamepadConnectedEvent), window.removeEventListener("gamepaddisconnected", this._gamepadDisconnectedEvent);
+ }, r.prototype._checkForConnectedDevices = function() {
+ for (var t = 0, e = navigator.getGamepads(); t < e.length; t++) {
+ var n = e[t];
+ n && this._addGamePad(n);
+ }
+ matchMedia("(pointer:fine)").matches && this._addPointerDevice(Xt.Mouse, 0, 0, 0);
+ }, r.prototype._addGamePad = function(t) {
+ var e = this._getGamepadDeviceType(t.id), n = t.index;
+ this._registerDevice(e, n, t.buttons.length + t.axes.length), this._gamepads = this._gamepads || new Array(t.index + 1), this._gamepads[n] = e;
+ }, r.prototype._addPointerDevice = function(t, e, n, i) {
+ this._pointerActive = !0, this._registerDevice(t, e, r._MAX_POINTER_INPUTS);
+ var o = this._inputs[t][e];
+ o[0] = n, o[1] = i;
+ }, r.prototype._registerDevice = function(t, e, n) {
+ if (this._inputs[t] || (this._inputs[t] = []), !this._inputs[t][e]) {
+ for (var i = new Array(n), o = 0; o < n; o++)
+ i[o] = 0;
+ this._inputs[t][e] = i, this.onDeviceConnected(t, e);
+ }
+ }, r.prototype._unregisterDevice = function(t, e) {
+ this._inputs[t][e] && (delete this._inputs[t][e], this.onDeviceDisconnected(t, e));
+ }, r.prototype._handleKeyActions = function() {
+ var t = this;
+ this._keyboardDownEvent = function(e) {
+ t._keyboardActive || (t._keyboardActive = !0, t._registerDevice(Xt.Keyboard, 0, r._MAX_KEYCODES));
+ var n = t._inputs[Xt.Keyboard][0];
+ n && (t.onInputChanged && t.onInputChanged(Xt.Keyboard, 0, e.keyCode, n[e.keyCode], 1), n[e.keyCode] = 1);
+ }, this._keyboardUpEvent = function(e) {
+ var n = t._inputs[Xt.Keyboard][0];
+ n && (t.onInputChanged && t.onInputChanged(Xt.Keyboard, 0, e.keyCode, n[e.keyCode], 0), n[e.keyCode] = 0);
+ }, window.addEventListener("keydown", this._keyboardDownEvent), window.addEventListener("keyup", this._keyboardUpEvent);
+ }, r.prototype._handlePointerActions = function() {
+ var t = this;
+ this._pointerMoveEvent = function(e) {
+ var n = e.pointerType == "mouse" ? Xt.Mouse : Xt.Touch, i = e.pointerType == "mouse" ? 0 : e.pointerId;
+ t._inputs[n] || (t._inputs[n] = []), t._inputs[n][i] || t._addPointerDevice(n, i, e.clientX, e.clientY);
+ var o = t._inputs[n][i];
+ o && (t.onInputChanged && (t.onInputChanged(n, i, 0, o[0], e.clientX), t.onInputChanged(n, i, 1, o[1], e.clientY)), o[0] = e.clientX, o[1] = e.clientY);
+ }, this._pointerDownEvent = function(e) {
+ var n = e.pointerType == "mouse" ? Xt.Mouse : Xt.Touch, i = e.pointerType == "mouse" ? 0 : e.pointerId;
+ t._inputs[n] || (t._inputs[n] = []), t._inputs[n][i] || t._addPointerDevice(n, i, e.clientX, e.clientY);
+ var o = t._inputs[n][i];
+ o && (t.onInputChanged && (t.onInputChanged(n, i, 0, o[0], e.clientX), t.onInputChanged(n, i, 1, o[1], e.clientY), t.onInputChanged(n, i, e.button + 2, o[e.button + 2], 1)), o[0] = e.clientX, o[1] = e.clientY, o[e.button + 2] = 1);
+ }, this._pointerUpEvent = function(e) {
+ var n = e.pointerType == "mouse" ? Xt.Mouse : Xt.Touch, i = e.pointerType == "mouse" ? 0 : e.pointerId, o = t._inputs[n][i];
+ o && (t.onInputChanged && t.onInputChanged(n, i, e.button + 2, o[e.button + 2], 0), o[0] = e.clientX, o[1] = e.clientY, o[e.button + 2] = 0), e.pointerType != "mouse" && t._unregisterDevice(n, i);
+ }, this._elementToAttachTo.addEventListener("pointermove", this._pointerMoveEvent), this._elementToAttachTo.addEventListener("pointerdown", this._pointerDownEvent), this._elementToAttachTo.addEventListener("pointerup", this._pointerUpEvent);
+ }, r.prototype._handleGamepadActions = function() {
+ var t = this;
+ this._gamepadConnectedEvent = function(e) {
+ t._addGamePad(e.gamepad);
+ }, this._gamepadDisconnectedEvent = function(e) {
+ if (t._gamepads) {
+ var n = t._getGamepadDeviceType(e.gamepad.id), i = e.gamepad.index;
+ t._unregisterDevice(n, i), delete t._gamepads[i];
+ }
+ }, window.addEventListener("gamepadconnected", this._gamepadConnectedEvent), window.addEventListener("gamepaddisconnected", this._gamepadDisconnectedEvent);
+ }, r.prototype._updateDevice = function(t, e, n) {
+ var i = navigator.getGamepads()[e];
+ if (i && t == this._gamepads[e]) {
+ var o = this._inputs[t][e];
+ n >= i.buttons.length ? o[n] = i.axes[n - i.buttons.length].valueOf() : o[n] = i.buttons[n].value;
+ }
+ }, r.prototype._getGamepadDeviceType = function(t) {
+ return t.indexOf("054c") !== -1 ? Xt.DualShock : t.indexOf("Xbox One") !== -1 || t.search("Xbox 360") !== -1 || t.search("xinput") !== -1 ? Xt.Xbox : t.indexOf("057e") !== -1 ? Xt.Switch : Xt.Generic;
+ }, r._MAX_KEYCODES = 255, r._MAX_POINTER_INPUTS = 7, r;
+ }(), Bl = function() {
+ function r(t, e, n) {
+ n === void 0 && (n = 0), this.deviceType = e, this.deviceSlot = n, this.onInputChangedObservable = new C.c(), this._deviceInputSystem = t;
+ }
+ return r.prototype.getInput = function(t) {
+ return this._deviceInputSystem.pollInput(this.deviceType, this.deviceSlot, t);
+ }, r;
+ }(), Mf = function() {
+ function r(t) {
+ var e = this;
+ this.onDeviceConnectedObservable = new C.c(function(i) {
+ e.getDevices().forEach(function(o) {
+ e.onDeviceConnectedObservable.notifyObserver(i, o);
+ });
+ }), this.onDeviceDisconnectedObservable = new C.c();
+ var n = Object.keys(Xt).length / 2;
+ this._devices = new Array(n), this._firstDevice = new Array(n), this._deviceInputSystem = Fl.Create(t), this._deviceInputSystem.onDeviceConnected = function(i, o) {
+ e._addDevice(i, o), e.onDeviceConnectedObservable.notifyObservers(e.getDeviceSource(i, o));
+ }, this._deviceInputSystem.onDeviceDisconnected = function(i, o) {
+ var a = e.getDeviceSource(i, o);
+ e._removeDevice(i, o), e.onDeviceDisconnectedObservable.notifyObservers(a);
+ }, this._deviceInputSystem.onInputChanged || (this._deviceInputSystem.onInputChanged = function(i, o, a, s, d) {
+ var p;
+ (p = e.getDeviceSource(i, o)) === null || p === void 0 || p.onInputChangedObservable.notifyObservers({ inputIndex: a, previousState: s, currentState: d });
+ });
+ }
+ return r.prototype.getDeviceSource = function(t, e) {
+ if (e === void 0) {
+ if (this._firstDevice[t] === void 0)
+ return null;
+ e = this._firstDevice[t];
+ }
+ return this._devices[t] && this._devices[t][e] !== void 0 ? this._devices[t][e] : null;
+ }, r.prototype.getDeviceSources = function(t) {
+ return this._devices[t].filter(function(e) {
+ return !!e;
+ });
+ }, r.prototype.getDevices = function() {
+ var t = new Array();
+ return this._devices.forEach(function(e) {
+ t.push.apply(t, e);
+ }), t;
+ }, r.prototype.dispose = function() {
+ this.onDeviceConnectedObservable.clear(), this.onDeviceDisconnectedObservable.clear(), this._deviceInputSystem.dispose();
+ }, r.prototype._addDevice = function(t, e) {
+ this._devices[t] || (this._devices[t] = new Array()), this._devices[t][e] || (this._devices[t][e] = new Bl(this._deviceInputSystem, t, e), this._updateFirstDevices(t));
+ }, r.prototype._removeDevice = function(t, e) {
+ delete this._devices[t][e], this._updateFirstDevices(t);
+ }, r.prototype._updateFirstDevices = function(t) {
+ switch (t) {
+ case Xt.Keyboard:
+ case Xt.Mouse:
+ this._firstDevice[t] = 0;
+ break;
+ case Xt.Touch:
+ case Xt.DualShock:
+ case Xt.Xbox:
+ case Xt.Switch:
+ case Xt.Generic:
+ var e = this._devices[t];
+ delete this._firstDevice[t];
+ for (var n = 0; n < e.length; n++)
+ if (e[n]) {
+ this._firstDevice[t] = n;
+ break;
+ }
+ }
+ }, r;
+ }(), Ul = f(168), Vl = (f(123), function() {
+ this._timeElapsedQueryEnded = !1;
+ }), kl = function() {
+ this.occlusionInternalRetryCounter = 0, this.isOcclusionQueryInProgress = !1, this.isOccluded = !1, this.occlusionRetryCount = -1, this.occlusionType = Mt.a.OCCLUSION_TYPE_NONE, this.occlusionQueryAlgorithmType = Mt.a.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE;
+ };
+ Ue.a.prototype.createQuery = function() {
+ return this._gl.createQuery();
+ }, Ue.a.prototype.deleteQuery = function(r) {
+ return this._gl.deleteQuery(r), this;
+ }, Ue.a.prototype.isQueryResultAvailable = function(r) {
+ return this._gl.getQueryParameter(r, this._gl.QUERY_RESULT_AVAILABLE);
+ }, Ue.a.prototype.getQueryResult = function(r) {
+ return this._gl.getQueryParameter(r, this._gl.QUERY_RESULT);
+ }, Ue.a.prototype.beginOcclusionQuery = function(r, t) {
+ var e = this._getGlAlgorithmType(r);
+ return this._gl.beginQuery(e, t), this;
+ }, Ue.a.prototype.endOcclusionQuery = function(r) {
+ var t = this._getGlAlgorithmType(r);
+ return this._gl.endQuery(t), this;
+ }, Ue.a.prototype._createTimeQuery = function() {
+ var r = this.getCaps().timerQuery;
+ return r.createQueryEXT ? r.createQueryEXT() : this.createQuery();
+ }, Ue.a.prototype._deleteTimeQuery = function(r) {
+ var t = this.getCaps().timerQuery;
+ t.deleteQueryEXT ? t.deleteQueryEXT(r) : this.deleteQuery(r);
+ }, Ue.a.prototype._getTimeQueryResult = function(r) {
+ var t = this.getCaps().timerQuery;
+ return t.getQueryObjectEXT ? t.getQueryObjectEXT(r, t.QUERY_RESULT_EXT) : this.getQueryResult(r);
+ }, Ue.a.prototype._getTimeQueryAvailability = function(r) {
+ var t = this.getCaps().timerQuery;
+ return t.getQueryObjectEXT ? t.getQueryObjectEXT(r, t.QUERY_RESULT_AVAILABLE_EXT) : this.isQueryResultAvailable(r);
+ }, Ue.a.prototype.startTimeQuery = function() {
+ var r = this.getCaps(), t = r.timerQuery;
+ if (!t)
+ return null;
+ var e = new Vl();
+ if (this._gl.getParameter(t.GPU_DISJOINT_EXT), r.canUseTimestampForTimerQuery)
+ e._startTimeQuery = this._createTimeQuery(), t.queryCounterEXT(e._startTimeQuery, t.TIMESTAMP_EXT);
+ else {
+ if (this._currentNonTimestampToken)
+ return this._currentNonTimestampToken;
+ e._timeElapsedQuery = this._createTimeQuery(), t.beginQueryEXT ? t.beginQueryEXT(t.TIME_ELAPSED_EXT, e._timeElapsedQuery) : this._gl.beginQuery(t.TIME_ELAPSED_EXT, e._timeElapsedQuery), this._currentNonTimestampToken = e;
+ }
+ return e;
+ }, Ue.a.prototype.endTimeQuery = function(r) {
+ var t = this.getCaps(), e = t.timerQuery;
+ if (!e || !r)
+ return -1;
+ if (t.canUseTimestampForTimerQuery) {
+ if (!r._startTimeQuery)
+ return -1;
+ r._endTimeQuery || (r._endTimeQuery = this._createTimeQuery(), e.queryCounterEXT(r._endTimeQuery, e.TIMESTAMP_EXT));
+ } else if (!r._timeElapsedQueryEnded) {
+ if (!r._timeElapsedQuery)
+ return -1;
+ e.endQueryEXT ? e.endQueryEXT(e.TIME_ELAPSED_EXT) : this._gl.endQuery(e.TIME_ELAPSED_EXT), r._timeElapsedQueryEnded = !0;
+ }
+ var n = this._gl.getParameter(e.GPU_DISJOINT_EXT), i = !1;
+ if (r._endTimeQuery ? i = this._getTimeQueryAvailability(r._endTimeQuery) : r._timeElapsedQuery && (i = this._getTimeQueryAvailability(r._timeElapsedQuery)), i && !n) {
+ var o = 0;
+ if (t.canUseTimestampForTimerQuery) {
+ if (!r._startTimeQuery || !r._endTimeQuery)
+ return -1;
+ var a = this._getTimeQueryResult(r._startTimeQuery);
+ o = this._getTimeQueryResult(r._endTimeQuery) - a, this._deleteTimeQuery(r._startTimeQuery), this._deleteTimeQuery(r._endTimeQuery), r._startTimeQuery = null, r._endTimeQuery = null;
+ } else {
+ if (!r._timeElapsedQuery)
+ return -1;
+ o = this._getTimeQueryResult(r._timeElapsedQuery), this._deleteTimeQuery(r._timeElapsedQuery), r._timeElapsedQuery = null, r._timeElapsedQueryEnded = !1, this._currentNonTimestampToken = null;
+ }
+ return o;
+ }
+ return -1;
+ }, Ue.a.prototype._getGlAlgorithmType = function(r) {
+ return r === Mt.a.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE ? this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE : this._gl.ANY_SAMPLES_PASSED;
+ }, Object.defineProperty(Mt.a.prototype, "isOcclusionQueryInProgress", { get: function() {
+ return this._occlusionDataStorage.isOcclusionQueryInProgress;
+ }, set: function(r) {
+ this._occlusionDataStorage.isOcclusionQueryInProgress = r;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(Mt.a.prototype, "_occlusionDataStorage", { get: function() {
+ return this.__occlusionDataStorage || (this.__occlusionDataStorage = new kl()), this.__occlusionDataStorage;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(Mt.a.prototype, "isOccluded", { get: function() {
+ return this._occlusionDataStorage.isOccluded;
+ }, set: function(r) {
+ this._occlusionDataStorage.isOccluded = r;
+ }, enumerable: !0, configurable: !0 }), Object.defineProperty(Mt.a.prototype, "occlusionQueryAlgorithmType", { get: function() {
+ return this._occlusionDataStorage.occlusionQueryAlgorithmType;
+ }, set: function(r) {
+ this._occlusionDataStorage.occlusionQueryAlgorithmType = r;
+ }, enumerable: !0, configurable: !0 }), Object.defineProperty(Mt.a.prototype, "occlusionType", { get: function() {
+ return this._occlusionDataStorage.occlusionType;
+ }, set: function(r) {
+ this._occlusionDataStorage.occlusionType = r;
+ }, enumerable: !0, configurable: !0 }), Object.defineProperty(Mt.a.prototype, "occlusionRetryCount", { get: function() {
+ return this._occlusionDataStorage.occlusionRetryCount;
+ }, set: function(r) {
+ this._occlusionDataStorage.occlusionRetryCount = r;
+ }, enumerable: !0, configurable: !0 }), Mt.a.prototype._checkOcclusionQuery = function() {
+ var r = this._occlusionDataStorage;
+ if (r.occlusionType === Mt.a.OCCLUSION_TYPE_NONE)
+ return r.isOccluded = !1, !1;
+ var t = this.getEngine();
+ if (t.webGLVersion < 2 || !t.isQueryResultAvailable)
+ return r.isOccluded = !1, !1;
+ if (this.isOcclusionQueryInProgress && this._occlusionQuery)
+ if (t.isQueryResultAvailable(this._occlusionQuery)) {
+ var e = t.getQueryResult(this._occlusionQuery);
+ r.isOcclusionQueryInProgress = !1, r.occlusionInternalRetryCounter = 0, r.isOccluded = e !== 1;
+ } else {
+ if (r.occlusionInternalRetryCounter++, !(r.occlusionRetryCount !== -1 && r.occlusionInternalRetryCounter > r.occlusionRetryCount))
+ return !1;
+ r.isOcclusionQueryInProgress = !1, r.occlusionInternalRetryCounter = 0, r.isOccluded = r.occlusionType !== Mt.a.OCCLUSION_TYPE_OPTIMISTIC && r.isOccluded;
+ }
+ var n = this.getScene();
+ if (n.getBoundingBoxRenderer) {
+ var i = n.getBoundingBoxRenderer();
+ this._occlusionQuery || (this._occlusionQuery = t.createQuery()), t.beginOcclusionQuery(r.occlusionQueryAlgorithmType, this._occlusionQuery), i.renderOcclusionBoundingBox(this), t.endOcclusionQuery(r.occlusionQueryAlgorithmType), this._occlusionDataStorage.isOcclusionQueryInProgress = !0;
+ }
+ return r.isOccluded;
+ };
+ var If = !0;
+ Ue.a.prototype.createTransformFeedback = function() {
+ return this._gl.createTransformFeedback();
+ }, Ue.a.prototype.deleteTransformFeedback = function(r) {
+ this._gl.deleteTransformFeedback(r);
+ }, Ue.a.prototype.bindTransformFeedback = function(r) {
+ this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK, r);
+ }, Ue.a.prototype.beginTransformFeedback = function(r) {
+ r === void 0 && (r = !0), this._gl.beginTransformFeedback(r ? this._gl.POINTS : this._gl.TRIANGLES);
+ }, Ue.a.prototype.endTransformFeedback = function() {
+ this._gl.endTransformFeedback();
+ }, Ue.a.prototype.setTranformFeedbackVaryings = function(r, t) {
+ this._gl.transformFeedbackVaryings(r, t, this._gl.INTERLEAVED_ATTRIBS);
+ }, Ue.a.prototype.bindTransformFeedbackBuffer = function(r) {
+ this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER, 0, r ? r.underlyingResource : null);
+ }, f(126), wt.a.prototype.updateVideoTexture = function(r, t, e) {
+ if (r && !r._isDisabled) {
+ var n = this._bindTextureDirectly(this._gl.TEXTURE_2D, r, !0);
+ this._unpackFlipY(!e);
+ try {
+ if (this._videoTextureSupported === void 0 && (this._gl.getError(), this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, t), this._gl.getError() !== 0 ? this._videoTextureSupported = !1 : this._videoTextureSupported = !0), this._videoTextureSupported)
+ this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, t);
+ else {
+ if (!r._workingCanvas) {
+ r._workingCanvas = ns.a.CreateCanvas(r.width, r.height);
+ var i = r._workingCanvas.getContext("2d");
+ if (!i)
+ throw new Error("Unable to get 2d context");
+ r._workingContext = i, r._workingCanvas.width = r.width, r._workingCanvas.height = r.height;
+ }
+ r._workingContext.clearRect(0, 0, r.width, r.height), r._workingContext.drawImage(t, 0, 0, t.videoWidth, t.videoHeight, 0, 0, r.width, r.height), this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, r._workingCanvas);
+ }
+ r.generateMipMaps && this._gl.generateMipmap(this._gl.TEXTURE_2D), n || this._bindTextureDirectly(this._gl.TEXTURE_2D, null), r.isReady = !0;
+ } catch {
+ r._isDisabled = !0;
+ }
+ }
+ }, wt.a.prototype.restoreSingleAttachment = function() {
+ var r = this._gl;
+ this.bindAttachments([r.BACK]);
+ }, wt.a.prototype.buildTextureLayout = function(r) {
+ for (var t = this._gl, e = [], n = 0; n < r.length; n++)
+ r[n] ? e.push(t["COLOR_ATTACHMENT" + n]) : e.push(t.NONE);
+ return e;
+ }, wt.a.prototype.bindAttachments = function(r) {
+ this._gl.drawBuffers(r);
+ }, wt.a.prototype.unBindMultiColorAttachmentFramebuffer = function(r, t, e) {
+ t === void 0 && (t = !1), this._currentRenderTarget = null;
+ var n = this._gl, i = r[0]._attachments, o = i.length;
+ if (r[0]._MSAAFramebuffer) {
+ n.bindFramebuffer(n.READ_FRAMEBUFFER, r[0]._MSAAFramebuffer), n.bindFramebuffer(n.DRAW_FRAMEBUFFER, r[0]._framebuffer);
+ for (var a = 0; a < o; a++) {
+ for (var s = r[a], d = 0; d < o; d++)
+ i[d] = n.NONE;
+ i[a] = n[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + a : "COLOR_ATTACHMENT" + a + "_WEBGL"], n.readBuffer(i[a]), n.drawBuffers(i), n.blitFramebuffer(0, 0, s.width, s.height, 0, 0, s.width, s.height, n.COLOR_BUFFER_BIT, n.NEAREST);
+ }
+ for (a = 0; a < o; a++)
+ i[a] = n[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + a : "COLOR_ATTACHMENT" + a + "_WEBGL"];
+ n.drawBuffers(i);
+ }
+ for (a = 0; a < o; a++)
+ !(s = r[a]).generateMipMaps || t || s.isCube || (this._bindTextureDirectly(n.TEXTURE_2D, s, !0), n.generateMipmap(n.TEXTURE_2D), this._bindTextureDirectly(n.TEXTURE_2D, null));
+ e && (r[0]._MSAAFramebuffer && this._bindUnboundFramebuffer(r[0]._framebuffer), e()), this._bindUnboundFramebuffer(null);
+ }, wt.a.prototype.createMultipleRenderTarget = function(r, t) {
+ var e = !1, n = !0, i = !1, o = !1, a = 1, s = h.a.TEXTURETYPE_UNSIGNED_INT, d = h.a.TEXTURE_TRILINEAR_SAMPLINGMODE, p = new Array(), y = new Array();
+ t !== void 0 && (e = t.generateMipMaps !== void 0 && t.generateMipMaps, n = t.generateDepthBuffer === void 0 || t.generateDepthBuffer, i = t.generateStencilBuffer !== void 0 && t.generateStencilBuffer, o = t.generateDepthTexture !== void 0 && t.generateDepthTexture, a = t.textureCount || 1, t.types && (p = t.types), t.samplingModes && (y = t.samplingModes));
+ var P = this._gl, R = P.createFramebuffer();
+ this._bindUnboundFramebuffer(R);
+ for (var B = r.width || r, F = r.height || r, z = [], J = [], ie = this._setupFramebufferDepthAttachments(i, n, B, F), se = 0; se < a; se++) {
+ var ce = y[se] || d, ue = p[se] || s;
+ (ue !== h.a.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering) && (ue !== h.a.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering) || (ce = h.a.TEXTURE_NEAREST_SAMPLINGMODE);
+ var fe = this._getSamplingParameters(ce, e);
+ ue !== h.a.TEXTURETYPE_FLOAT || this._caps.textureFloat || (ue = h.a.TEXTURETYPE_UNSIGNED_INT, l.a.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type"));
+ var ve = new Pt.a(this, Pt.b.MultiRenderTarget), Te = P[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + se : "COLOR_ATTACHMENT" + se + "_WEBGL"];
+ z.push(ve), J.push(Te), P.activeTexture(P["TEXTURE" + se]), P.bindTexture(P.TEXTURE_2D, ve._webGLTexture), P.texParameteri(P.TEXTURE_2D, P.TEXTURE_MAG_FILTER, fe.mag), P.texParameteri(P.TEXTURE_2D, P.TEXTURE_MIN_FILTER, fe.min), P.texParameteri(P.TEXTURE_2D, P.TEXTURE_WRAP_S, P.CLAMP_TO_EDGE), P.texParameteri(P.TEXTURE_2D, P.TEXTURE_WRAP_T, P.CLAMP_TO_EDGE), P.texImage2D(P.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(ue), B, F, 0, P.RGBA, this._getWebGLTextureType(ue), null), P.framebufferTexture2D(P.DRAW_FRAMEBUFFER, Te, P.TEXTURE_2D, ve._webGLTexture, 0), e && this._gl.generateMipmap(this._gl.TEXTURE_2D), this._bindTextureDirectly(P.TEXTURE_2D, null), ve._framebuffer = R, ve._depthStencilBuffer = ie, ve.baseWidth = B, ve.baseHeight = F, ve.width = B, ve.height = F, ve.isReady = !0, ve.samples = 1, ve.generateMipMaps = e, ve.samplingMode = ce, ve.type = ue, ve._generateDepthBuffer = n, ve._generateStencilBuffer = i, ve._attachments = J, ve._textureArray = z, this._internalTexturesCache.push(ve);
+ }
+ if (o && this._caps.depthTextureExtension) {
+ var Re = new Pt.a(this, Pt.b.MultiRenderTarget);
+ P.activeTexture(P.TEXTURE0), P.bindTexture(P.TEXTURE_2D, Re._webGLTexture), P.texParameteri(P.TEXTURE_2D, P.TEXTURE_MAG_FILTER, P.NEAREST), P.texParameteri(P.TEXTURE_2D, P.TEXTURE_MIN_FILTER, P.NEAREST), P.texParameteri(P.TEXTURE_2D, P.TEXTURE_WRAP_S, P.CLAMP_TO_EDGE), P.texParameteri(P.TEXTURE_2D, P.TEXTURE_WRAP_T, P.CLAMP_TO_EDGE), P.texImage2D(P.TEXTURE_2D, 0, this.webGLVersion < 2 ? P.DEPTH_COMPONENT : P.DEPTH_COMPONENT16, B, F, 0, P.DEPTH_COMPONENT, P.UNSIGNED_SHORT, null), P.framebufferTexture2D(P.FRAMEBUFFER, P.DEPTH_ATTACHMENT, P.TEXTURE_2D, Re._webGLTexture, 0), Re._framebuffer = R, Re.baseWidth = B, Re.baseHeight = F, Re.width = B, Re.height = F, Re.isReady = !0, Re.samples = 1, Re.generateMipMaps = e, Re.samplingMode = P.NEAREST, Re._generateDepthBuffer = n, Re._generateStencilBuffer = i, z.push(Re), this._internalTexturesCache.push(Re);
+ }
+ return P.drawBuffers(J), this._bindUnboundFramebuffer(null), this.resetTextureCache(), z;
+ }, wt.a.prototype.updateMultipleRenderTargetTextureSampleCount = function(r, t) {
+ if (this.webGLVersion < 2 || !r)
+ return 1;
+ if (r[0].samples === t)
+ return t;
+ var e = r[0]._attachments.length;
+ if (e === 0)
+ return 1;
+ var n = this._gl;
+ t = Math.min(t, this.getCaps().maxMSAASamples), r[0]._depthStencilBuffer && (n.deleteRenderbuffer(r[0]._depthStencilBuffer), r[0]._depthStencilBuffer = null), r[0]._MSAAFramebuffer && (n.deleteFramebuffer(r[0]._MSAAFramebuffer), r[0]._MSAAFramebuffer = null);
+ for (var i = 0; i < e; i++)
+ r[i]._MSAARenderBuffer && (n.deleteRenderbuffer(r[i]._MSAARenderBuffer), r[i]._MSAARenderBuffer = null);
+ if (t > 1 && n.renderbufferStorageMultisample) {
+ var o = n.createFramebuffer();
+ if (!o)
+ throw new Error("Unable to create multi sampled framebuffer");
+ this._bindUnboundFramebuffer(o);
+ var a = this._setupFramebufferDepthAttachments(r[0]._generateStencilBuffer, r[0]._generateDepthBuffer, r[0].width, r[0].height, t), s = [];
+ for (i = 0; i < e; i++) {
+ var d = r[i], p = n[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"], y = n.createRenderbuffer();
+ if (!y)
+ throw new Error("Unable to create multi sampled framebuffer");
+ n.bindRenderbuffer(n.RENDERBUFFER, y), n.renderbufferStorageMultisample(n.RENDERBUFFER, t, this._getRGBAMultiSampleBufferFormat(d.type), d.width, d.height), n.framebufferRenderbuffer(n.FRAMEBUFFER, p, n.RENDERBUFFER, y), d._MSAAFramebuffer = o, d._MSAARenderBuffer = y, d.samples = t, d._depthStencilBuffer = a, n.bindRenderbuffer(n.RENDERBUFFER, null), s.push(p);
+ }
+ n.drawBuffers(s);
+ } else
+ this._bindUnboundFramebuffer(r[0]._framebuffer);
+ return this._bindUnboundFramebuffer(null), t;
+ };
+ var Xr = f(56);
+ wt.a.prototype._createDepthStencilCubeTexture = function(r, t) {
+ var e = new Pt.a(this, Pt.b.Unknown);
+ if (e.isCube = !0, this.webGLVersion === 1)
+ return l.a.Error("Depth cube texture is not supported by WebGL 1."), e;
+ var n = Object(c.a)({ bilinearFiltering: !1, comparisonFunction: 0, generateStencil: !1 }, t), i = this._gl;
+ this._bindTextureDirectly(i.TEXTURE_CUBE_MAP, e, !0), this._setupDepthStencilTexture(e, r, n.generateStencil, n.bilinearFiltering, n.comparisonFunction);
+ for (var o = 0; o < 6; o++)
+ n.generateStencil ? i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + o, 0, i.DEPTH24_STENCIL8, r, r, 0, i.DEPTH_STENCIL, i.UNSIGNED_INT_24_8, null) : i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + o, 0, i.DEPTH_COMPONENT24, r, r, 0, i.DEPTH_COMPONENT, i.UNSIGNED_INT, null);
+ return this._bindTextureDirectly(i.TEXTURE_CUBE_MAP, null), e;
+ }, wt.a.prototype._partialLoadFile = function(r, t, e, n, i) {
+ i === void 0 && (i = null), this._loadFile(r, function(o) {
+ e[t] = o, e._internalCount++, e._internalCount === 6 && n(e);
+ }, void 0, void 0, !0, function(o, a) {
+ i && o && i(o.status + " " + o.statusText, a);
+ });
+ }, wt.a.prototype._cascadeLoadFiles = function(r, t, e, n) {
+ n === void 0 && (n = null);
+ var i = [];
+ i._internalCount = 0;
+ for (var o = 0; o < 6; o++)
+ this._partialLoadFile(e[o], o, i, t, n);
+ }, wt.a.prototype._cascadeLoadImgs = function(r, t, e, n, i) {
+ n === void 0 && (n = null);
+ var o = [];
+ o._internalCount = 0;
+ for (var a = 0; a < 6; a++)
+ this._partialLoadImg(e[a], a, o, r, t, n, i);
+ }, wt.a.prototype._partialLoadImg = function(r, t, e, n, i, o, a) {
+ var s;
+ o === void 0 && (o = null), s = Xr.a.LoadImage(r, function() {
+ s && (e[t] = s, e._internalCount++, n && n._removePendingData(s)), e._internalCount === 6 && i(e);
+ }, function(d, p) {
+ n && n._removePendingData(s), o && o(d, p);
+ }, n ? n.offlineProvider : null, a), n && s && n._addPendingData(s);
+ }, wt.a.prototype._setCubeMapTextureParams = function(r, t) {
+ var e = this._gl;
+ e.texParameteri(e.TEXTURE_CUBE_MAP, e.TEXTURE_MAG_FILTER, e.LINEAR), e.texParameteri(e.TEXTURE_CUBE_MAP, e.TEXTURE_MIN_FILTER, t ? e.LINEAR_MIPMAP_LINEAR : e.LINEAR), e.texParameteri(e.TEXTURE_CUBE_MAP, e.TEXTURE_WRAP_S, e.CLAMP_TO_EDGE), e.texParameteri(e.TEXTURE_CUBE_MAP, e.TEXTURE_WRAP_T, e.CLAMP_TO_EDGE), r.samplingMode = t ? h.a.TEXTURE_TRILINEAR_SAMPLINGMODE : h.a.TEXTURE_LINEAR_LINEAR, this._bindTextureDirectly(e.TEXTURE_CUBE_MAP, null);
+ }, wt.a.prototype.createCubeTexture = function(r, t, e, n, i, o, a, s, d, p, y, P, R) {
+ var B = this;
+ i === void 0 && (i = null), o === void 0 && (o = null), s === void 0 && (s = null), d === void 0 && (d = !1), p === void 0 && (p = 0), y === void 0 && (y = 0), P === void 0 && (P = null);
+ var F = this._gl, z = P || new Pt.a(this, Pt.b.Cube);
+ z.isCube = !0, z.url = r, z.generateMipMaps = !n, z._lodGenerationScale = p, z._lodGenerationOffset = y, this._doNotHandleContextLost || (z._extension = s, z._files = e);
+ var J = r;
+ this._transformTextureUrl && !P && (r = this._transformTextureUrl(r));
+ for (var ie = r.lastIndexOf("."), se = s || (ie > -1 ? r.substring(ie).toLowerCase() : ""), ce = null, ue = 0, fe = wt.a._TextureLoaders; ue < fe.length; ue++) {
+ var ve = fe[ue];
+ if (ve.canLoad(se)) {
+ ce = ve;
+ break;
+ }
+ }
+ if (ce) {
+ var Te = function(Re) {
+ B._bindTextureDirectly(F.TEXTURE_CUBE_MAP, z, !0), ce.loadCubeData(Re, z, d, i, o);
+ };
+ e && e.length === 6 ? ce.supportCascades ? this._cascadeLoadFiles(t, function(Re) {
+ return Te(Re.map(function(Ae) {
+ return new Uint8Array(Ae);
+ }));
+ }, e, o) : o ? o("Textures type does not support cascades.") : l.a.Warn("Texture loader does not support cascades.") : this._loadFile(r, function(Re) {
+ return Te(new Uint8Array(Re));
+ }, void 0, void 0, !0, function(Re, Ae) {
+ r === J ? o && Re && o(Re.status + " " + Re.statusText, Ae) : (l.a.Warn("Failed to load " + r + ", falling back to the " + J), B.createCubeTexture(J, t, e, n, i, o, a, s, d, p, y, z, R));
+ });
+ } else {
+ if (!e)
+ throw new Error("Cannot load cubemap because files were not defined");
+ this._cascadeLoadImgs(t, function(Re) {
+ var Ae = B.needPOTTextures ? wt.a.GetExponentOfTwo(Re[0].width, B._caps.maxCubemapTextureSize) : Re[0].width, Ee = Ae, Se = [F.TEXTURE_CUBE_MAP_POSITIVE_X, F.TEXTURE_CUBE_MAP_POSITIVE_Y, F.TEXTURE_CUBE_MAP_POSITIVE_Z, F.TEXTURE_CUBE_MAP_NEGATIVE_X, F.TEXTURE_CUBE_MAP_NEGATIVE_Y, F.TEXTURE_CUBE_MAP_NEGATIVE_Z];
+ B._bindTextureDirectly(F.TEXTURE_CUBE_MAP, z, !0), B._unpackFlipY(!1);
+ for (var De = a ? B._getInternalFormat(a) : B._gl.RGBA, xe = 0; xe < Se.length; xe++)
+ if (Re[xe].width !== Ae || Re[xe].height !== Ee) {
+ if (B._prepareWorkingCanvas(), !B._workingCanvas || !B._workingContext)
+ return void l.a.Warn("Cannot create canvas to resize texture.");
+ B._workingCanvas.width = Ae, B._workingCanvas.height = Ee, B._workingContext.drawImage(Re[xe], 0, 0, Re[xe].width, Re[xe].height, 0, 0, Ae, Ee), F.texImage2D(Se[xe], 0, De, De, F.UNSIGNED_BYTE, B._workingCanvas);
+ } else
+ F.texImage2D(Se[xe], 0, De, De, F.UNSIGNED_BYTE, Re[xe]);
+ n || F.generateMipmap(F.TEXTURE_CUBE_MAP), B._setCubeMapTextureParams(z, !n), z.width = Ae, z.height = Ee, z.isReady = !0, a && (z.format = a), z.onLoadedObservable.notifyObservers(z), z.onLoadedObservable.clear(), i && i();
+ }, e, o);
+ }
+ return this._internalTexturesCache.push(z), z;
+ }, f(153), f(124);
+ var Df = function() {
+ };
+ Ue.a.prototype.getInputElement = function() {
+ return this.inputElement || this.getRenderingCanvas();
+ }, Ue.a.prototype.registerView = function(r, t) {
+ var e = this;
+ this.views || (this.views = []);
+ for (var n = 0, i = this.views; n < i.length; n++) {
+ var o = i[n];
+ if (o.target === r)
+ return o;
+ }
+ var a = this.getRenderingCanvas();
+ a && (r.width = a.width, r.height = a.height);
+ var s = { target: r, camera: t };
+ return this.views.push(s), t && t.onDisposeObservable.add(function() {
+ e.unRegisterView(r);
+ }), s;
+ }, Ue.a.prototype.unRegisterView = function(r) {
+ if (!this.views)
+ return this;
+ for (var t = 0, e = this.views; t < e.length; t++) {
+ var n = e[t];
+ if (n.target === r) {
+ var i = this.views.indexOf(n);
+ i !== -1 && this.views.splice(i, 1);
+ break;
+ }
+ }
+ return this;
+ }, Ue.a.prototype._renderViews = function() {
+ if (!this.views)
+ return !1;
+ var r = this.getRenderingCanvas();
+ if (!r)
+ return !1;
+ for (var t = 0, e = this.views; t < e.length; t++) {
+ var n = e[t], i = n.target, o = i.getContext("2d");
+ if (o) {
+ var a = n.camera, s = null, d = null;
+ if (a) {
+ if ((d = a.getScene()).activeCameras && d.activeCameras.length)
+ continue;
+ this.activeView = n, s = d.activeCamera, d.activeCamera = a;
+ }
+ var p = i.width !== i.clientWidth || i.height !== i.clientHeight;
+ if (i.clientWidth && i.clientHeight && p && (i.width = i.clientWidth, i.height = i.clientHeight, r.width = i.clientWidth, r.height = i.clientHeight, this.resize()), !r.width || !r.height)
+ return !1;
+ this._renderFrame(), o.drawImage(r, 0, 0), s && d && (d.activeCamera = s);
+ }
+ }
+ return this.activeView = null, !0;
+ }, f(129);
+ function Lf(r) {
+ if (this._excludedCompressedTextures && this._excludedCompressedTextures.some(function(i) {
+ var o = "\\b" + i + "\\b";
+ return r && (r === i || r.match(new RegExp(o, "g")));
+ }))
+ return r;
+ var t = r.lastIndexOf("."), e = r.lastIndexOf("?"), n = e > -1 ? r.substring(e, r.length) : "";
+ return (t > -1 ? r.substring(0, t) : r) + this._textureFormatInUse + n;
+ }
+ Object.defineProperty(Ue.a.prototype, "texturesSupported", { get: function() {
+ var r = new Array();
+ return this._caps.astc && r.push("-astc.ktx"), this._caps.s3tc && r.push("-dxt.ktx"), this._caps.pvrtc && r.push("-pvrtc.ktx"), this._caps.etc2 && r.push("-etc2.ktx"), this._caps.etc1 && r.push("-etc1.ktx"), r;
+ }, enumerable: !0, configurable: !0 }), Object.defineProperty(Ue.a.prototype, "textureFormatInUse", { get: function() {
+ return this._textureFormatInUse || null;
+ }, enumerable: !0, configurable: !0 }), Ue.a.prototype.setCompressedTextureExclusions = function(r) {
+ this._excludedCompressedTextures = r;
+ }, Ue.a.prototype.setTextureFormatToUse = function(r) {
+ for (var t = this.texturesSupported, e = 0, n = t.length; e < n; e++)
+ for (var i = 0, o = r.length; i < o; i++)
+ if (t[e] === r[i].toLowerCase())
+ return this._transformTextureUrl = Lf.bind(this), this._textureFormatInUse = t[e];
+ return this._textureFormatInUse = "", this._transformTextureUrl = null, null;
+ };
+ var Nf = f(144), Gl = f(118), zl = f(89), li = [Math.sqrt(1 / (4 * Math.PI)), -Math.sqrt(3 / (4 * Math.PI)), Math.sqrt(3 / (4 * Math.PI)), -Math.sqrt(3 / (4 * Math.PI)), Math.sqrt(15 / (4 * Math.PI)), -Math.sqrt(15 / (4 * Math.PI)), Math.sqrt(5 / (16 * Math.PI)), -Math.sqrt(15 / (4 * Math.PI)), Math.sqrt(15 / (16 * Math.PI))], wf = [function(r) {
+ return 1;
+ }, function(r) {
+ return r.y;
+ }, function(r) {
+ return r.z;
+ }, function(r) {
+ return r.x;
+ }, function(r) {
+ return r.x * r.y;
+ }, function(r) {
+ return r.y * r.z;
+ }, function(r) {
+ return 3 * r.z * r.z - 1;
+ }, function(r) {
+ return r.x * r.z;
+ }, function(r) {
+ return r.x * r.x - r.y * r.y;
+ }], _i = function(r, t) {
+ return li[r] * wf[r](t);
+ }, mi = [Math.PI, 2 * Math.PI / 3, 2 * Math.PI / 3, 2 * Math.PI / 3, Math.PI / 4, Math.PI / 4, Math.PI / 4, Math.PI / 4, Math.PI / 4], hs = function() {
+ function r() {
+ this.preScaled = !1, this.l00 = u.e.Zero(), this.l1_1 = u.e.Zero(), this.l10 = u.e.Zero(), this.l11 = u.e.Zero(), this.l2_2 = u.e.Zero(), this.l2_1 = u.e.Zero(), this.l20 = u.e.Zero(), this.l21 = u.e.Zero(), this.l22 = u.e.Zero();
+ }
+ return r.prototype.addLight = function(t, e, n) {
+ var i = new u.e(e.r, e.g, e.b).scale(n);
+ this.l00 = this.l00.add(i.scale(_i(0, t))), this.l1_1 = this.l1_1.add(i.scale(_i(1, t))), this.l10 = this.l10.add(i.scale(_i(2, t))), this.l11 = this.l11.add(i.scale(_i(3, t))), this.l2_2 = this.l2_2.add(i.scale(_i(4, t))), this.l2_1 = this.l2_1.add(i.scale(_i(5, t))), this.l20 = this.l20.add(i.scale(_i(6, t))), this.l21 = this.l21.add(i.scale(_i(7, t))), this.l22 = this.l22.add(i.scale(_i(8, t)));
+ }, r.prototype.scaleInPlace = function(t) {
+ this.l00.scaleInPlace(t), this.l1_1.scaleInPlace(t), this.l10.scaleInPlace(t), this.l11.scaleInPlace(t), this.l2_2.scaleInPlace(t), this.l2_1.scaleInPlace(t), this.l20.scaleInPlace(t), this.l21.scaleInPlace(t), this.l22.scaleInPlace(t);
+ }, r.prototype.convertIncidentRadianceToIrradiance = function() {
+ this.l00.scaleInPlace(mi[0]), this.l1_1.scaleInPlace(mi[1]), this.l10.scaleInPlace(mi[2]), this.l11.scaleInPlace(mi[3]), this.l2_2.scaleInPlace(mi[4]), this.l2_1.scaleInPlace(mi[5]), this.l20.scaleInPlace(mi[6]), this.l21.scaleInPlace(mi[7]), this.l22.scaleInPlace(mi[8]);
+ }, r.prototype.convertIrradianceToLambertianRadiance = function() {
+ this.scaleInPlace(1 / Math.PI);
+ }, r.prototype.preScaleForRendering = function() {
+ this.preScaled = !0, this.l00.scaleInPlace(li[0]), this.l1_1.scaleInPlace(li[1]), this.l10.scaleInPlace(li[2]), this.l11.scaleInPlace(li[3]), this.l2_2.scaleInPlace(li[4]), this.l2_1.scaleInPlace(li[5]), this.l20.scaleInPlace(li[6]), this.l21.scaleInPlace(li[7]), this.l22.scaleInPlace(li[8]);
+ }, r.FromArray = function(t) {
+ var e = new r();
+ return u.e.FromArrayToRef(t[0], 0, e.l00), u.e.FromArrayToRef(t[1], 0, e.l1_1), u.e.FromArrayToRef(t[2], 0, e.l10), u.e.FromArrayToRef(t[3], 0, e.l11), u.e.FromArrayToRef(t[4], 0, e.l2_2), u.e.FromArrayToRef(t[5], 0, e.l2_1), u.e.FromArrayToRef(t[6], 0, e.l20), u.e.FromArrayToRef(t[7], 0, e.l21), u.e.FromArrayToRef(t[8], 0, e.l22), e;
+ }, r.FromPolynomial = function(t) {
+ var e = new r();
+ return e.l00 = t.xx.scale(0.376127).add(t.yy.scale(0.376127)).add(t.zz.scale(0.376126)), e.l1_1 = t.y.scale(0.977204), e.l10 = t.z.scale(0.977204), e.l11 = t.x.scale(0.977204), e.l2_2 = t.xy.scale(1.16538), e.l2_1 = t.yz.scale(1.16538), e.l20 = t.zz.scale(1.34567).subtract(t.xx.scale(0.672834)).subtract(t.yy.scale(0.672834)), e.l21 = t.zx.scale(1.16538), e.l22 = t.xx.scale(1.16538).subtract(t.yy.scale(1.16538)), e.l1_1.scaleInPlace(-1), e.l11.scaleInPlace(-1), e.l2_1.scaleInPlace(-1), e.l21.scaleInPlace(-1), e.scaleInPlace(Math.PI), e;
+ }, r;
+ }(), Yr = function() {
+ function r() {
+ this.x = u.e.Zero(), this.y = u.e.Zero(), this.z = u.e.Zero(), this.xx = u.e.Zero(), this.yy = u.e.Zero(), this.zz = u.e.Zero(), this.xy = u.e.Zero(), this.yz = u.e.Zero(), this.zx = u.e.Zero();
+ }
+ return Object.defineProperty(r.prototype, "preScaledHarmonics", { get: function() {
+ return this._harmonics || (this._harmonics = hs.FromPolynomial(this)), this._harmonics.preScaled || this._harmonics.preScaleForRendering(), this._harmonics;
+ }, enumerable: !1, configurable: !0 }), r.prototype.addAmbient = function(t) {
+ var e = new u.e(t.r, t.g, t.b);
+ this.xx = this.xx.add(e), this.yy = this.yy.add(e), this.zz = this.zz.add(e);
+ }, r.prototype.scaleInPlace = function(t) {
+ this.x.scaleInPlace(t), this.y.scaleInPlace(t), this.z.scaleInPlace(t), this.xx.scaleInPlace(t), this.yy.scaleInPlace(t), this.zz.scaleInPlace(t), this.yz.scaleInPlace(t), this.zx.scaleInPlace(t), this.xy.scaleInPlace(t);
+ }, r.FromHarmonics = function(t) {
+ var e = new r();
+ return e._harmonics = t, e.x = t.l11.scale(1.02333).scale(-1), e.y = t.l1_1.scale(1.02333).scale(-1), e.z = t.l10.scale(1.02333), e.xx = t.l00.scale(0.886277).subtract(t.l20.scale(0.247708)).add(t.l22.scale(0.429043)), e.yy = t.l00.scale(0.886277).subtract(t.l20.scale(0.247708)).subtract(t.l22.scale(0.429043)), e.zz = t.l00.scale(0.886277).add(t.l20.scale(0.495417)), e.yz = t.l2_1.scale(0.858086).scale(-1), e.zx = t.l21.scale(0.858086).scale(-1), e.xy = t.l2_2.scale(0.858086), e.scaleInPlace(1 / Math.PI), e;
+ }, r.FromArray = function(t) {
+ var e = new r();
+ return u.e.FromArrayToRef(t[0], 0, e.x), u.e.FromArrayToRef(t[1], 0, e.y), u.e.FromArrayToRef(t[2], 0, e.z), u.e.FromArrayToRef(t[3], 0, e.xx), u.e.FromArrayToRef(t[4], 0, e.yy), u.e.FromArrayToRef(t[5], 0, e.zz), u.e.FromArrayToRef(t[6], 0, e.yz), u.e.FromArrayToRef(t[7], 0, e.zx), u.e.FromArrayToRef(t[8], 0, e.xy), e;
+ }, r;
+ }(), kn = f(52), dr = function(r, t, e, n) {
+ this.name = r, this.worldAxisForNormal = t, this.worldAxisForFileX = e, this.worldAxisForFileY = n;
+ }, Lo = function() {
+ function r() {
+ }
+ return r.ConvertCubeMapTextureToSphericalPolynomial = function(t) {
+ if (!t.isCube)
+ return null;
+ var e, n, i = t.getSize().width, o = t.readPixels(0), a = t.readPixels(1);
+ t.isRenderTarget ? (e = t.readPixels(3), n = t.readPixels(2)) : (e = t.readPixels(2), n = t.readPixels(3));
+ var s = t.readPixels(4), d = t.readPixels(5), p = t.gammaSpace, y = h.a.TEXTUREFORMAT_RGBA, P = h.a.TEXTURETYPE_UNSIGNED_INT;
+ t.textureType != h.a.TEXTURETYPE_FLOAT && t.textureType != h.a.TEXTURETYPE_HALF_FLOAT || (P = h.a.TEXTURETYPE_FLOAT);
+ var R = { size: i, right: o, left: a, up: e, down: n, front: s, back: d, format: y, type: P, gammaSpace: p };
+ return this.ConvertCubeMapToSphericalPolynomial(R);
+ }, r.ConvertCubeMapToSphericalPolynomial = function(t) {
+ for (var e = new hs(), n = 0, i = 2 / t.size, o = i, a = 0.5 * i - 1, s = 0; s < 6; s++)
+ for (var d = this.FileFaces[s], p = t[d.name], y = a, P = t.format === h.a.TEXTUREFORMAT_RGBA ? 4 : 3, R = 0; R < t.size; R++) {
+ for (var B = a, F = 0; F < t.size; F++) {
+ var z = d.worldAxisForFileX.scale(B).add(d.worldAxisForFileY.scale(y)).add(d.worldAxisForNormal);
+ z.normalize();
+ var J = Math.pow(1 + B * B + y * y, -1.5), ie = p[R * t.size * P + F * P + 0], se = p[R * t.size * P + F * P + 1], ce = p[R * t.size * P + F * P + 2];
+ isNaN(ie) && (ie = 0), isNaN(se) && (se = 0), isNaN(ce) && (ce = 0), t.type === h.a.TEXTURETYPE_UNSIGNED_INT && (ie /= 255, se /= 255, ce /= 255), t.gammaSpace && (ie = Math.pow($.a.Clamp(ie), Vt.c), se = Math.pow($.a.Clamp(se), Vt.c), ce = Math.pow($.a.Clamp(ce), Vt.c)), ie = $.a.Clamp(ie, 0, 4096), se = $.a.Clamp(se, 0, 4096), ce = $.a.Clamp(ce, 0, 4096);
+ var ue = new I.a(ie, se, ce);
+ e.addLight(z, ue, J), n += J, B += i;
+ }
+ y += o;
+ }
+ var fe = 6 * (4 * Math.PI) / 6 / n;
+ return e.scaleInPlace(fe), e.convertIncidentRadianceToIrradiance(), e.convertIrradianceToLambertianRadiance(), Yr.FromHarmonics(e);
+ }, r.FileFaces = [new dr("right", new u.e(1, 0, 0), new u.e(0, 0, -1), new u.e(0, -1, 0)), new dr("left", new u.e(-1, 0, 0), new u.e(0, 0, 1), new u.e(0, -1, 0)), new dr("up", new u.e(0, 1, 0), new u.e(1, 0, 0), new u.e(0, 0, 1)), new dr("down", new u.e(0, -1, 0), new u.e(1, 0, 0), new u.e(0, 0, -1)), new dr("front", new u.e(0, 0, 1), new u.e(1, 0, 0), new u.e(0, -1, 0)), new dr("back", new u.e(0, 0, -1), new u.e(-1, 0, 0), new u.e(0, -1, 0))], r;
+ }();
+ Object.defineProperty(kn.a.prototype, "sphericalPolynomial", { get: function() {
+ if (this._texture) {
+ if (this._texture._sphericalPolynomial)
+ return this._texture._sphericalPolynomial;
+ if (this._texture.isReady)
+ return this._texture._sphericalPolynomial = Lo.ConvertCubeMapTextureToSphericalPolynomial(this), this._texture._sphericalPolynomial;
+ }
+ return null;
+ }, set: function(r) {
+ this._texture && (this._texture._sphericalPolynomial = r);
+ }, enumerable: !0, configurable: !0 });
+ var Ff = `
+varying vec2 vUV;
+uniform sampler2D textureSampler;
+#include
+void main(void)
+{
+gl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);
+}`;
+ ze.a.ShadersStore.rgbdEncodePixelShader = Ff;
+ var Bf = `
+varying vec2 vUV;
+uniform sampler2D textureSampler;
+#include
+void main(void)
+{
+gl_FragColor=vec4(fromRGBD(texture2D(textureSampler,vUV)),1.0);
+}`;
+ ze.a.ShadersStore.rgbdDecodePixelShader = Bf;
+ var gi = function() {
+ function r() {
+ }
+ return r.GetEnvInfo = function(t) {
+ for (var e = new DataView(t.buffer, t.byteOffset, t.byteLength), n = 0, i = 0; i < r._MagicBytes.length; i++)
+ if (e.getUint8(n++) !== r._MagicBytes[i])
+ return l.a.Error("Not a babylon environment map"), null;
+ for (var o = "", a = 0; a = e.getUint8(n++); )
+ o += String.fromCharCode(a);
+ var s = JSON.parse(o);
+ return s.specular && (s.specular.specularDataPosition = n, s.specular.lodGenerationScale = s.specular.lodGenerationScale || 0.8), s;
+ }, r.CreateEnvTextureAsync = function(t) {
+ var e = this, n = t.getInternalTexture();
+ if (!n)
+ return Promise.reject("The cube texture is invalid.");
+ var i = n.getEngine();
+ if (i && i.premultipliedAlpha)
+ return Promise.reject("Env texture can only be created when the engine is created with the premultipliedAlpha option set to false.");
+ if (t.textureType === h.a.TEXTURETYPE_UNSIGNED_INT)
+ return Promise.reject("The cube texture should allow HDR (Full Float or Half Float).");
+ var o = i.getRenderingCanvas();
+ if (!o)
+ return Promise.reject("Env texture can only be created when the engine is associated to a canvas.");
+ var a = h.a.TEXTURETYPE_FLOAT;
+ if (!i.getCaps().textureFloatRender && (a = h.a.TEXTURETYPE_HALF_FLOAT, !i.getCaps().textureHalfFloatRender))
+ return Promise.reject("Env texture can only be created when the browser supports half float or full float rendering.");
+ var s = n.width, d = new _e.a(i), p = {}, y = [], P = $.a.Log2(n.width);
+ P = Math.round(P);
+ for (var R = function(F) {
+ for (var z = Math.pow(2, P - F), J = function(se) {
+ var ce = t.readPixels(se, F), ue = i.createRawTexture(ce, z, z, h.a.TEXTUREFORMAT_RGBA, !1, !1, h.a.TEXTURE_NEAREST_SAMPLINGMODE, null, a), fe = new Promise(function(ve, Te) {
+ var Re = new ft("rgbdEncode", "rgbdEncode", null, null, 1, null, h.a.TEXTURE_NEAREST_SAMPLINGMODE, i, !1, void 0, h.a.TEXTURETYPE_UNSIGNED_INT, void 0, null, !1);
+ Re.getEffect().executeWhenCompiled(function() {
+ Re.onApply = function(Se) {
+ Se._bindTexture("textureSampler", ue);
+ };
+ var Ae = i.getRenderWidth(), Ee = i.getRenderHeight();
+ i.setSize(z, z), d.postProcessManager.directRender([Re], null), Xe.b.ToBlob(o, function(Se) {
+ var De = new FileReader();
+ De.onload = function(xe) {
+ var Le = xe.target.result;
+ p[6 * F + se] = Le, ve();
+ }, De.readAsArrayBuffer(Se);
+ }), i.setSize(Ae, Ee);
+ });
+ });
+ y.push(fe);
+ }, ie = 0; ie < 6; ie++)
+ J(ie);
+ }, B = 0; B <= P; B++)
+ R(B);
+ return Promise.all(y).then(function() {
+ d.dispose();
+ for (var F = { version: 1, width: s, irradiance: e._CreateEnvTextureIrradiance(t), specular: { mipmaps: [], lodGenerationScale: t.lodGenerationScale } }, z = 0, J = 0; J <= P; J++)
+ for (var ie = 0; ie < 6; ie++) {
+ var se = p[6 * J + ie].byteLength;
+ F.specular.mipmaps.push({ length: se, position: z }), z += se;
+ }
+ for (var ce = JSON.stringify(F), ue = new ArrayBuffer(ce.length + 1), fe = new Uint8Array(ue), ve = (J = 0, ce.length); J < ve; J++)
+ fe[J] = ce.charCodeAt(J);
+ fe[ce.length] = 0;
+ var Te = r._MagicBytes.length + z + ue.byteLength, Re = new ArrayBuffer(Te), Ae = new Uint8Array(Re), Ee = new DataView(Re), Se = 0;
+ for (J = 0; J < r._MagicBytes.length; J++)
+ Ee.setUint8(Se++, r._MagicBytes[J]);
+ for (Ae.set(new Uint8Array(ue), Se), Se += ue.byteLength, J = 0; J <= P; J++)
+ for (ie = 0; ie < 6; ie++) {
+ var De = p[6 * J + ie];
+ Ae.set(new Uint8Array(De), Se), Se += De.byteLength;
+ }
+ return Re;
+ });
+ }, r._CreateEnvTextureIrradiance = function(t) {
+ var e = t.sphericalPolynomial;
+ return e == null ? null : { x: [e.x.x, e.x.y, e.x.z], y: [e.y.x, e.y.y, e.y.z], z: [e.z.x, e.z.y, e.z.z], xx: [e.xx.x, e.xx.y, e.xx.z], yy: [e.yy.x, e.yy.y, e.yy.z], zz: [e.zz.x, e.zz.y, e.zz.z], yz: [e.yz.x, e.yz.y, e.yz.z], zx: [e.zx.x, e.zx.y, e.zx.z], xy: [e.xy.x, e.xy.y, e.xy.z] };
+ }, r.CreateImageDataArrayBufferViews = function(t, e) {
+ if (e.version !== 1)
+ throw new Error('Unsupported babylon environment map version "' + e.version + '"');
+ var n = e.specular, i = $.a.Log2(e.width);
+ if (i = Math.round(i) + 1, n.mipmaps.length !== 6 * i)
+ throw new Error('Unsupported specular mipmaps number "' + n.mipmaps.length + '"');
+ for (var o = new Array(i), a = 0; a < i; a++) {
+ o[a] = new Array(6);
+ for (var s = 0; s < 6; s++) {
+ var d = n.mipmaps[6 * a + s];
+ o[a][s] = new Uint8Array(t.buffer, t.byteOffset + n.specularDataPosition + d.position, d.length);
+ }
+ }
+ return o;
+ }, r.UploadEnvLevelsAsync = function(t, e, n) {
+ if (n.version !== 1)
+ throw new Error('Unsupported babylon environment map version "' + n.version + '"');
+ var i = n.specular;
+ if (!i)
+ return Promise.resolve();
+ t._lodGenerationScale = i.lodGenerationScale;
+ var o = r.CreateImageDataArrayBufferViews(e, n);
+ return r.UploadLevelsAsync(t, o);
+ }, r._OnImageReadyAsync = function(t, e, n, i, o, a, s, d, p, y, P) {
+ return new Promise(function(R, B) {
+ if (n) {
+ var F = e.createTexture(null, !0, !0, null, h.a.TEXTURE_NEAREST_SAMPLINGMODE, null, function(J) {
+ B(J);
+ }, t);
+ i.getEffect().executeWhenCompiled(function() {
+ i.onApply = function(J) {
+ J._bindTexture("textureSampler", F), J.setFloat2("scale", 1, 1);
+ }, e.scenes[0].postProcessManager.directRender([i], y, !0, a, s), e.restoreDefaultFramebuffer(), F.dispose(), URL.revokeObjectURL(o), R();
+ });
+ } else {
+ if (e._uploadImageToTexture(P, t, a, s), d) {
+ var z = p[s];
+ z && e._uploadImageToTexture(z._texture, t, a, 0);
+ }
+ R();
+ }
+ });
+ }, r.UploadLevelsAsync = function(t, e) {
+ var n = this;
+ if (!Xe.b.IsExponentOfTwo(t.width))
+ throw new Error("Texture size must be a power of two");
+ var i = Math.round($.a.Log2(t.width)) + 1, o = t.getEngine(), a = !1, s = !1, d = null, p = null, y = null, P = o.getCaps();
+ if (t.format = h.a.TEXTUREFORMAT_RGBA, t.type = h.a.TEXTURETYPE_UNSIGNED_INT, t.generateMipMaps = !0, t._cachedAnisotropicFilteringLevel = null, o.updateTextureSamplingMode(h.a.TEXTURE_TRILINEAR_SAMPLINGMODE, t), P.textureLOD ? o.webGLVersion < 2 ? a = !1 : P.textureHalfFloatRender && P.textureHalfFloatLinearFiltering ? (a = !0, t.type = h.a.TEXTURETYPE_HALF_FLOAT) : P.textureFloatRender && P.textureFloatLinearFiltering && (a = !0, t.type = h.a.TEXTURETYPE_FLOAT) : (a = !1, s = !0, y = {}), a)
+ d = new ft("rgbdDecode", "rgbdDecode", null, null, 1, null, h.a.TEXTURE_TRILINEAR_SAMPLINGMODE, o, !1, void 0, t.type, void 0, null, !1), t._isRGBD = !1, t.invertY = !1, p = o.createRenderTargetCubeTexture(t.width, { generateDepthBuffer: !1, generateMipMaps: !0, generateStencilBuffer: !1, samplingMode: h.a.TEXTURE_TRILINEAR_SAMPLINGMODE, type: t.type, format: h.a.TEXTUREFORMAT_RGBA });
+ else if (t._isRGBD = !0, t.invertY = !0, s)
+ for (var R = t._lodGenerationScale, B = t._lodGenerationOffset, F = 0; F < 3; F++) {
+ var z = (i - 1) * R + B, J = B + (z - B) * (1 - F / 2), ie = Math.round(Math.min(Math.max(J, 0), z)), se = new Pt.a(o, Pt.b.Temp);
+ se.isCube = !0, se.invertY = !0, se.generateMipMaps = !1, o.updateTextureSamplingMode(h.a.TEXTURE_LINEAR_LINEAR, se);
+ var ce = new kn.a(null);
+ switch (ce.isCube = !0, ce._texture = se, y[ie] = ce, F) {
+ case 0:
+ t._lodTextureLow = ce;
+ break;
+ case 1:
+ t._lodTextureMid = ce;
+ break;
+ case 2:
+ t._lodTextureHigh = ce;
+ }
+ }
+ var ue = [], fe = function(Ee) {
+ for (var Se = function(xe) {
+ var Le = e[Ee][xe], Me = new Blob([Le], { type: "image/png" }), we = URL.createObjectURL(Me), Ye = void 0;
+ if (typeof Image > "u")
+ Ye = createImageBitmap(Me).then(function(nt) {
+ return n._OnImageReadyAsync(nt, o, a, d, we, xe, Ee, s, y, p, t);
+ });
+ else {
+ var et = new Image();
+ et.src = we, Ye = new Promise(function(nt, ct) {
+ et.onload = function() {
+ n._OnImageReadyAsync(et, o, a, d, we, xe, Ee, s, y, p, t).then(function() {
+ return nt();
+ }).catch(function(Ke) {
+ ct(Ke);
+ });
+ }, et.onerror = function(Ke) {
+ ct(Ke);
+ };
+ });
+ }
+ ue.push(Ye);
+ }, De = 0; De < 6; De++)
+ Se(De);
+ };
+ for (F = 0; F < e.length; F++)
+ fe(F);
+ if (e.length < i) {
+ var ve = void 0, Te = Math.pow(2, i - 1 - e.length), Re = Te * Te * 4;
+ switch (t.type) {
+ case h.a.TEXTURETYPE_UNSIGNED_INT:
+ ve = new Uint8Array(Re);
+ break;
+ case h.a.TEXTURETYPE_HALF_FLOAT:
+ ve = new Uint16Array(Re);
+ break;
+ case h.a.TEXTURETYPE_FLOAT:
+ ve = new Float32Array(Re);
+ }
+ for (F = e.length; F < i; F++)
+ for (var Ae = 0; Ae < 6; Ae++)
+ o._uploadArrayBufferViewToTexture(t, ve, Ae, F);
+ }
+ return Promise.all(ue).then(function() {
+ p && (o._releaseFramebufferObjects(p), o._releaseTexture(t), p._swapAndDie(t)), d && d.dispose(), s && (t._lodTextureHigh && t._lodTextureHigh._texture && (t._lodTextureHigh._texture.isReady = !0), t._lodTextureMid && t._lodTextureMid._texture && (t._lodTextureMid._texture.isReady = !0), t._lodTextureLow && t._lodTextureLow._texture && (t._lodTextureLow._texture.isReady = !0));
+ });
+ }, r.UploadEnvSpherical = function(t, e) {
+ e.version !== 1 && l.a.Warn('Unsupported babylon environment map version "' + e.version + '"');
+ var n = e.irradiance;
+ if (n) {
+ var i = new Yr();
+ u.e.FromArrayToRef(n.x, 0, i.x), u.e.FromArrayToRef(n.y, 0, i.y), u.e.FromArrayToRef(n.z, 0, i.z), u.e.FromArrayToRef(n.xx, 0, i.xx), u.e.FromArrayToRef(n.yy, 0, i.yy), u.e.FromArrayToRef(n.zz, 0, i.zz), u.e.FromArrayToRef(n.yz, 0, i.yz), u.e.FromArrayToRef(n.zx, 0, i.zx), u.e.FromArrayToRef(n.xy, 0, i.xy), t._sphericalPolynomial = i;
+ }
+ }, r._UpdateRGBDAsync = function(t, e, n, i, o) {
+ return t._source = Pt.b.CubeRawRGBD, t._bufferViewArrayArray = e, t._lodGenerationScale = i, t._lodGenerationOffset = o, t._sphericalPolynomial = n, r.UploadLevelsAsync(t, e).then(function() {
+ t.isReady = !0;
+ });
+ }, r._MagicBytes = [134, 22, 135, 150, 246, 214, 150, 54], r;
+ }();
+ Pt.a._UpdateRGBDAsync = gi._UpdateRGBDAsync;
+ var vi, ds = function() {
+ function r(t, e) {
+ e === void 0 && (e = 20), this.debug = !1, this._sourceCode = t, this._numMaxIterations = e, this._functionDescr = [], this.inlineToken = "#define inline";
+ }
+ return Object.defineProperty(r.prototype, "code", { get: function() {
+ return this._sourceCode;
+ }, enumerable: !1, configurable: !0 }), r.prototype.processCode = function() {
+ this.debug && console.log("Start inlining process (code size=" + this._sourceCode.length + ")..."), this._collectFunctions(), this._processInlining(this._numMaxIterations), this.debug && console.log("End of inlining process.");
+ }, r.prototype._collectFunctions = function() {
+ for (var t = 0; t < this._sourceCode.length; ) {
+ var e = this._sourceCode.indexOf(this.inlineToken, t);
+ if (e < 0)
+ break;
+ var n = this._sourceCode.indexOf("(", e + this.inlineToken.length);
+ if (n < 0)
+ this.debug && console.warn("Could not find the opening parenthesis after the token. startIndex=" + t), t = e + this.inlineToken.length;
+ else {
+ var i = r._RegexpFindFunctionNameAndType.exec(this._sourceCode.substring(e + this.inlineToken.length, n));
+ if (i) {
+ var o = [i[3], i[4]], a = o[0], s = o[1], d = this._extractBetweenMarkers("(", ")", this._sourceCode, n);
+ if (d < 0)
+ this.debug && console.warn("Could not extract the parameters the function '" + s + "' (type=" + a + "). funcParamsStartIndex=" + n), t = e + this.inlineToken.length;
+ else {
+ var p = this._sourceCode.substring(n + 1, d), y = this._skipWhitespaces(this._sourceCode, d + 1);
+ if (y !== this._sourceCode.length) {
+ var P = this._extractBetweenMarkers("{", "}", this._sourceCode, y);
+ if (P < 0)
+ this.debug && console.warn("Could not extract the body of the function '" + s + "' (type=" + a + "). funcBodyStartIndex=" + y), t = e + this.inlineToken.length;
+ else {
+ for (var R = this._sourceCode.substring(y, P + 1), B = this._removeComments(p).split(","), F = [], z = 0; z < B.length; ++z) {
+ var J = B[z].trim(), ie = J.lastIndexOf(" ");
+ ie >= 0 && F.push(J.substring(ie + 1));
+ }
+ a !== "void" && F.push("return"), this._functionDescr.push({ name: s, type: a, parameters: F, body: R, callIndex: 0 }), t = P + 1;
+ var se = e > 0 ? this._sourceCode.substring(0, e) : "", ce = P + 1 < this._sourceCode.length - 1 ? this._sourceCode.substring(P + 1) : "";
+ this._sourceCode = se + ce, t -= P + 1 - e;
+ }
+ } else
+ this.debug && console.warn("Could not extract the body of the function '" + s + "' (type=" + a + "). funcParamsEndIndex=" + d), t = e + this.inlineToken.length;
+ }
+ } else
+ this.debug && console.warn("Could not extract the name/type of the function from: " + this._sourceCode.substring(e + this.inlineToken.length, n)), t = e + this.inlineToken.length;
+ }
+ }
+ this.debug && console.log("Collect functions: " + this._functionDescr.length + " functions found. functionDescr=", this._functionDescr);
+ }, r.prototype._processInlining = function(t) {
+ for (t === void 0 && (t = 20); t-- >= 0 && this._replaceFunctionCallsByCode(); )
+ ;
+ return this.debug && console.log("numMaxIterations is " + t + " after inlining process"), t >= 0;
+ }, r.prototype._extractBetweenMarkers = function(t, e, n, i) {
+ for (var o = i, a = 0, s = ""; o < n.length; ) {
+ var d = n.charAt(o);
+ if (s)
+ d === s ? s === '"' || s === "'" ? n.charAt(o - 1) !== "\\" && (s = "") : s = "" : s === "*/" && d === "*" && o + 1 < n.length && (n.charAt(o + 1) === "/" && (s = ""), s === "" && o++);
+ else
+ switch (d) {
+ case t:
+ a++;
+ break;
+ case e:
+ a--;
+ break;
+ case '"':
+ case "'":
+ case "`":
+ s = d;
+ break;
+ case "/":
+ if (o + 1 < n.length) {
+ var p = n.charAt(o + 1);
+ p === "/" ? s = `
+` : p === "*" && (s = "*/");
+ }
+ }
+ if (o++, a === 0)
+ break;
+ }
+ return a === 0 ? o - 1 : -1;
+ }, r.prototype._skipWhitespaces = function(t, e) {
+ for (; e < t.length; ) {
+ var n = t[e];
+ if (n !== " " && n !== `
+` && n !== "\r" && n !== " " && n !== `
+` && n !== " ")
+ break;
+ e++;
+ }
+ return e;
+ }, r.prototype._removeComments = function(t) {
+ for (var e = 0, n = "", i = !1, o = []; e < t.length; ) {
+ var a = t.charAt(e);
+ if (n)
+ a === n ? n === '"' || n === "'" ? (t.charAt(e - 1) !== "\\" && (n = ""), o.push(a)) : (n = "", i = !1) : n === "*/" && a === "*" && e + 1 < t.length ? (t.charAt(e + 1) === "/" && (n = ""), n === "" && (i = !1, e++)) : i || o.push(a);
+ else {
+ switch (a) {
+ case '"':
+ case "'":
+ case "`":
+ n = a;
+ break;
+ case "/":
+ if (e + 1 < t.length) {
+ var s = t.charAt(e + 1);
+ s === "/" ? (n = `
+`, i = !0) : s === "*" && (n = "*/", i = !0);
+ }
+ }
+ i || o.push(a);
+ }
+ e++;
+ }
+ return o.join("");
+ }, r.prototype._replaceFunctionCallsByCode = function() {
+ for (var t = !1, e = 0, n = this._functionDescr; e < n.length; e++)
+ for (var i = n[e], o = i.name, a = i.type, s = i.parameters, d = i.body, p = 0; p < this._sourceCode.length; ) {
+ var y = this._sourceCode.indexOf(o, p);
+ if (y < 0)
+ break;
+ var P = this._skipWhitespaces(this._sourceCode, y + o.length);
+ if (P !== this._sourceCode.length && this._sourceCode.charAt(P) === "(") {
+ var R = this._extractBetweenMarkers("(", ")", this._sourceCode, P);
+ if (R < 0)
+ this.debug && console.warn("Could not extract the parameters of the function call. Function '" + o + "' (type=" + a + "). callParamsStartIndex=" + P), p = y + o.length;
+ else {
+ for (var B = this._sourceCode.substring(P + 1, R), F = this._removeComments(B).split(","), z = [], J = 0; J < F.length; ++J) {
+ var ie = F[J].trim();
+ z.push(ie);
+ }
+ var se = a !== "void" ? o + "_" + i.callIndex++ : null;
+ if (se && z.push(se + " ="), z.length === s.length) {
+ p = R + 1;
+ var ce = this._replaceNames(d, s, z), ue = y > 0 ? this._sourceCode.substring(0, y) : "", fe = R + 1 < this._sourceCode.length - 1 ? this._sourceCode.substring(R + 1) : "";
+ if (se) {
+ var ve = this._findBackward(this._sourceCode, y - 1, `
+`);
+ ue = this._sourceCode.substring(0, ve + 1);
+ var Te = this._sourceCode.substring(ve + 1, y);
+ this._sourceCode = ue + a + " " + se + `;
+` + ce + `
+` + Te + se + fe, this.debug && console.log("Replace function call by code. Function '" + o + "' (type=" + a + "). injectDeclarationIndex=" + ve);
+ } else
+ this._sourceCode = ue + ce + fe, p += ce.length - (R + 1 - y), this.debug && console.log("Replace function call by code. Function '" + o + "' (type=" + a + "). functionCallIndex=" + y);
+ t = !0;
+ } else
+ this.debug && console.warn("Invalid function call: not the same number of parameters for the call than the number expected by the function. Function '" + o + "' (type=" + a + "). function parameters=" + s + ", call parameters=" + z), p = y + o.length;
+ }
+ } else
+ p = y + o.length;
+ }
+ return t;
+ }, r.prototype._findBackward = function(t, e, n) {
+ for (; e >= 0 && t.charAt(e) !== n; )
+ e--;
+ return e;
+ }, r.prototype._escapeRegExp = function(t) {
+ return t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
+ }, r.prototype._replaceNames = function(t, e, n) {
+ for (var i = 0; i < e.length; ++i) {
+ var o = new RegExp(this._escapeRegExp(e[i]), "g"), a = n[i];
+ t = t.replace(o, a);
+ }
+ return t;
+ }, r._RegexpFindFunctionNameAndType = /((\s+?)(\w+)\s+(\w+)\s*?)$/, r;
+ }(), Uf = function() {
+ function r() {
+ this.isAsync = !1, this.isReady = !1;
+ }
+ return r.prototype._getVertexShaderCode = function() {
+ return null;
+ }, r.prototype._getFragmentShaderCode = function() {
+ return null;
+ }, r.prototype._handlesSpectorRebuildCallback = function(t) {
+ throw new Error("Not implemented");
+ }, r;
+ }(), jl = function(r) {
+ function t() {
+ return r !== null && r.apply(this, arguments) || this;
+ }
+ return Object(c.d)(t, r), t;
+ }(zl.a), Hl = function(r) {
+ function t() {
+ return r !== null && r.apply(this, arguments) || this;
+ }
+ return Object(c.d)(t, r), t.prototype.getInternalTexture = function() {
+ return this;
+ }, t.prototype.getViewCount = function() {
+ return 1;
+ }, t;
+ }(Pt.a), Vf = function(r) {
+ function t() {
+ var e = r.call(this, null) || this;
+ return e._native = new _native.Engine(), e.INVALID_HANDLE = 65535, e._boundBuffersVertexArray = null, e._currentDepthTest = e._native.DEPTH_TEST_LEQUAL, e._webGLVersion = 2, e.disableUniformBuffers = !0, e._caps = { maxTexturesImageUnits: 16, maxVertexTextureImageUnits: 16, maxCombinedTexturesImageUnits: 32, maxTextureSize: 512, maxCubemapTextureSize: 512, maxRenderTextureSize: 512, maxVertexAttribs: 16, maxVaryingVectors: 16, maxFragmentUniformVectors: 16, maxVertexUniformVectors: 16, standardDerivatives: !0, astc: null, pvrtc: null, etc1: null, etc2: null, bptc: null, maxAnisotropy: 16, uintIndices: !0, fragmentDepthSupported: !1, highPrecisionShaderSupported: !0, colorBufferFloat: !1, textureFloat: !1, textureFloatLinearFiltering: !1, textureFloatRender: !1, textureHalfFloat: !1, textureHalfFloatLinearFiltering: !1, textureHalfFloatRender: !1, textureLOD: !0, drawBuffersExtension: !1, depthTextureExtension: !1, vertexArrayObject: !0, instancedArrays: !1, canUseTimestampForTimerQuery: !1, blendMinMax: !1, maxMSAASamples: 1 }, Xe.b.Log("Babylon Native (v" + Ue.a.Version + ") launched"), Xe.b.LoadScript = function(n, i, o, a) {
+ Xe.b.LoadFile(n, function(s) {
+ Function(s).apply(null), i && i();
+ }, void 0, void 0, !1, function(s, d) {
+ o && o("LoadScript Error", d);
+ });
+ }, typeof URL > "u" && (window.URL = { createObjectURL: function() {
+ }, revokeObjectURL: function() {
+ } }), typeof Blob > "u" && (window.Blob = function() {
+ }), e._shaderProcessor = new Gl.a(), e;
+ }
+ return Object(c.d)(t, r), t.prototype.getHardwareScalingLevel = function() {
+ return 1;
+ }, t.prototype.dispose = function() {
+ r.prototype.dispose.call(this), this._boundBuffersVertexArray && this._native.deleteVertexArray(this._boundBuffersVertexArray), this._native.dispose();
+ }, t.prototype._queueNewFrame = function(e, n) {
+ return n.requestAnimationFrame && n !== window ? n.requestAnimationFrame(e) : this._native.requestAnimationFrame(e), 0;
+ }, t.prototype._bindUnboundFramebuffer = function(e) {
+ this._currentFramebuffer !== e && (this._currentFramebuffer && this._native.unbindFramebuffer(this._currentFramebuffer), e && this._native.bindFramebuffer(e), this._currentFramebuffer = e);
+ }, t.prototype.getHostDocument = function() {
+ return null;
+ }, t.prototype.clear = function(e, n, i, o) {
+ o === void 0 && (o = !1);
+ var a = 0;
+ n && e && (this._native.clearColor(e.r, e.g, e.b, e.a !== void 0 ? e.a : 1), a |= this._native.CLEAR_FLAG_COLOR), i && (this._native.clearDepth(1), a |= this._native.CLEAR_FLAG_DEPTH), o && (this._native.clearStencil(0), a |= this._native.CLEAR_FLAG_STENCIL), this._native.clear(a);
+ }, t.prototype.createIndexBuffer = function(e, n) {
+ var i = this._normalizeIndexData(e), o = new jl();
+ if (o.references = 1, o.is32Bits = i.BYTES_PER_ELEMENT === 4, i.length) {
+ if (o.nativeIndexBuffer = this._native.createIndexBuffer(i, n != null && n), o.nativeVertexBuffer === this.INVALID_HANDLE)
+ throw new Error("Could not create a native index buffer.");
+ } else
+ o.nativeVertexBuffer = this.INVALID_HANDLE;
+ return o;
+ }, t.prototype.createVertexBuffer = function(e, n) {
+ var i = new jl();
+ if (i.references = 1, i.nativeVertexBuffer = this._native.createVertexBuffer(ArrayBuffer.isView(e) ? e : new Float32Array(e), n != null && n), i.nativeVertexBuffer === this.INVALID_HANDLE)
+ throw new Error("Could not create a native vertex buffer.");
+ return i;
+ }, t.prototype._recordVertexArrayObject = function(e, n, i, o) {
+ i && this._native.recordIndexBuffer(e, i.nativeIndexBuffer);
+ for (var a = o.getAttributesNames(), s = 0; s < a.length; s++) {
+ var d = o.getAttributeLocation(s);
+ if (d >= 0) {
+ var p = n[a[s]];
+ if (p) {
+ var y = p.getBuffer();
+ y && this._native.recordVertexBuffer(e, y.nativeVertexBuffer, d, p.byteOffset, p.byteStride, p.getSize(), this._getNativeAttribType(p.type), p.normalized);
+ }
+ }
+ }
+ }, t.prototype.bindBuffers = function(e, n, i) {
+ this._boundBuffersVertexArray && this._native.deleteVertexArray(this._boundBuffersVertexArray), this._boundBuffersVertexArray = this._native.createVertexArray(), this._recordVertexArrayObject(this._boundBuffersVertexArray, e, n, i), this._native.bindVertexArray(this._boundBuffersVertexArray);
+ }, t.prototype.recordVertexArrayObject = function(e, n, i) {
+ var o = this._native.createVertexArray();
+ return this._recordVertexArrayObject(o, e, n, i), o;
+ }, t.prototype.bindVertexArrayObject = function(e) {
+ this._native.bindVertexArray(e);
+ }, t.prototype.releaseVertexArrayObject = function(e) {
+ this._native.deleteVertexArray(e);
+ }, t.prototype.getAttributes = function(e, n) {
+ var i = e;
+ return this._native.getAttributes(i.nativeProgram, n);
+ }, t.prototype.drawElementsType = function(e, n, i, o) {
+ this._drawCalls.addCount(1, !1), this._native.drawIndexed(e, n, i);
+ }, t.prototype.drawArraysType = function(e, n, i, o) {
+ this._drawCalls.addCount(1, !1), this._native.draw(e, n, i);
+ }, t.prototype.createPipelineContext = function() {
+ return new Uf();
+ }, t.prototype._preparePipelineContext = function(e, n, i, o, a, s, d) {
+ var p = e;
+ p.nativeProgram = o ? this.createRawShaderProgram(e, n, i, void 0, d) : this.createShaderProgram(e, n, i, s, void 0, d);
+ }, t.prototype._isRenderingStateCompiled = function(e) {
+ return !0;
+ }, t.prototype._executeWhenRenderingStateIsCompiled = function(e, n) {
+ n();
+ }, t.prototype.createRawShaderProgram = function(e, n, i, o, a) {
+ throw new Error("Not Supported");
+ }, t.prototype.createShaderProgram = function(e, n, i, o, a, s) {
+ this.onBeforeShaderCompilationObservable.notifyObservers(this);
+ var d = new ds(n);
+ d.processCode(), n = d.code;
+ var p = new ds(i);
+ p.processCode(), i = p.code, n = wt.a._ConcatenateShader(n, o), i = wt.a._ConcatenateShader(i, o);
+ var y = this._native.createProgram(n, i);
+ return this.onAfterShaderCompilationObservable.notifyObservers(this), y;
+ }, t.prototype._setProgram = function(e) {
+ this._currentProgram !== e && (this._native.setProgram(e), this._currentProgram = e);
+ }, t.prototype._releaseEffect = function(e) {
+ }, t.prototype._deletePipelineContext = function(e) {
+ }, t.prototype.getUniforms = function(e, n) {
+ var i = e;
+ return this._native.getUniforms(i.nativeProgram, n);
+ }, t.prototype.bindUniformBlock = function(e, n, i) {
+ throw new Error("Not Implemented");
+ }, t.prototype.bindSamplers = function(e) {
+ var n = e.getPipelineContext();
+ this._setProgram(n.nativeProgram);
+ for (var i = e.getSamplers(), o = 0; o < i.length; o++) {
+ var a = e.getUniform(i[o]);
+ a && (this._boundUniforms[o] = a);
+ }
+ this._currentEffect = null;
+ }, t.prototype.setMatrix = function(e, n) {
+ e && this._native.setMatrix(e, n.toArray());
+ }, t.prototype.getRenderWidth = function(e) {
+ return e === void 0 && (e = !1), !e && this._currentRenderTarget ? this._currentRenderTarget.width : this._native.getRenderWidth();
+ }, t.prototype.getRenderHeight = function(e) {
+ return e === void 0 && (e = !1), !e && this._currentRenderTarget ? this._currentRenderTarget.height : this._native.getRenderHeight();
+ }, t.prototype.setViewport = function(e, n, i) {
+ this._cachedViewport = e, this._native.setViewPort(e.x, e.y, e.width, e.height);
+ }, t.prototype.setState = function(e, n, i, o) {
+ n === void 0 && (n = 0), o === void 0 && (o = !1), this._native.setState(e, n, o);
+ }, t.prototype.setZOffset = function(e) {
+ this._native.setZOffset(e);
+ }, t.prototype.getZOffset = function() {
+ return this._native.getZOffset();
+ }, t.prototype.setDepthBuffer = function(e) {
+ this._native.setDepthTest(e ? this._currentDepthTest : this._native.DEPTH_TEST_ALWAYS);
+ }, t.prototype.getDepthWrite = function() {
+ return this._native.getDepthWrite();
+ }, t.prototype.setDepthFunctionToGreater = function() {
+ this._currentDepthTest = this._native.DEPTH_TEST_GREATER, this._native.setDepthTest(this._currentDepthTest);
+ }, t.prototype.setDepthFunctionToGreaterOrEqual = function() {
+ this._currentDepthTest = this._native.DEPTH_TEST_GEQUAL, this._native.setDepthTest(this._currentDepthTest);
+ }, t.prototype.setDepthFunctionToLess = function() {
+ this._currentDepthTest = this._native.DEPTH_TEST_LESS, this._native.setDepthTest(this._currentDepthTest);
+ }, t.prototype.setDepthFunctionToLessOrEqual = function() {
+ this._currentDepthTest = this._native.DEPTH_TEST_LEQUAL, this._native.setDepthTest(this._currentDepthTest);
+ }, t.prototype.setDepthWrite = function(e) {
+ this._native.setDepthWrite(e);
+ }, t.prototype.setColorWrite = function(e) {
+ this._native.setColorWrite(e), this._colorWrite = e;
+ }, t.prototype.getColorWrite = function() {
+ return this._colorWrite;
+ }, t.prototype.setAlphaConstants = function(e, n, i, o) {
+ throw new Error("Setting alpha blend constant color not yet implemented.");
+ }, t.prototype.setAlphaMode = function(e, n) {
+ n === void 0 && (n = !1), this._alphaMode !== e && (e = this._getNativeAlphaMode(e), this._native.setBlendMode(e), n || this.setDepthWrite(e === h.a.ALPHA_DISABLE), this._alphaMode = e);
+ }, t.prototype.getAlphaMode = function() {
+ return this._alphaMode;
+ }, t.prototype.setInt = function(e, n) {
+ return !!e && (this._native.setInt(e, n), !0);
+ }, t.prototype.setIntArray = function(e, n) {
+ return !!e && (this._native.setIntArray(e, n), !0);
+ }, t.prototype.setIntArray2 = function(e, n) {
+ return !!e && (this._native.setIntArray2(e, n), !0);
+ }, t.prototype.setIntArray3 = function(e, n) {
+ return !!e && (this._native.setIntArray3(e, n), !0);
+ }, t.prototype.setIntArray4 = function(e, n) {
+ return !!e && (this._native.setIntArray4(e, n), !0);
+ }, t.prototype.setFloatArray = function(e, n) {
+ return !!e && (this._native.setFloatArray(e, n), !0);
+ }, t.prototype.setFloatArray2 = function(e, n) {
+ return !!e && (this._native.setFloatArray2(e, n), !0);
+ }, t.prototype.setFloatArray3 = function(e, n) {
+ return !!e && (this._native.setFloatArray3(e, n), !0);
+ }, t.prototype.setFloatArray4 = function(e, n) {
+ return !!e && (this._native.setFloatArray4(e, n), !0);
+ }, t.prototype.setArray = function(e, n) {
+ return !!e && (this._native.setFloatArray(e, n), !0);
+ }, t.prototype.setArray2 = function(e, n) {
+ return !!e && (this._native.setFloatArray2(e, n), !0);
+ }, t.prototype.setArray3 = function(e, n) {
+ return !!e && (this._native.setFloatArray3(e, n), !0);
+ }, t.prototype.setArray4 = function(e, n) {
+ return !!e && (this._native.setFloatArray4(e, n), !0);
+ }, t.prototype.setMatrices = function(e, n) {
+ return !!e && (this._native.setMatrices(e, n), !0);
+ }, t.prototype.setMatrix3x3 = function(e, n) {
+ return !!e && (this._native.setMatrix3x3(e, n), !0);
+ }, t.prototype.setMatrix2x2 = function(e, n) {
+ return !!e && (this._native.setMatrix2x2(e, n), !0);
+ }, t.prototype.setFloat = function(e, n) {
+ return !!e && (this._native.setFloat(e, n), !0);
+ }, t.prototype.setFloat2 = function(e, n, i) {
+ return !!e && (this._native.setFloat2(e, n, i), !0);
+ }, t.prototype.setFloat3 = function(e, n, i, o) {
+ return !!e && (this._native.setFloat3(e, n, i, o), !0);
+ }, t.prototype.setFloat4 = function(e, n, i, o, a) {
+ return !!e && (this._native.setFloat4(e, n, i, o, a), !0);
+ }, t.prototype.setColor3 = function(e, n) {
+ return !!e && (this._native.setFloat3(e, n.r, n.g, n.b), !0);
+ }, t.prototype.setColor4 = function(e, n, i) {
+ return !!e && (this._native.setFloat4(e, n.r, n.g, n.b, i), !0);
+ }, t.prototype.wipeCaches = function(e) {
+ this.preventCacheWipeBetweenFrames || (this.resetTextureCache(), this._currentEffect = null, e && (this._currentProgram = null, this._stencilState.reset(), this._depthCullingState.reset(), this._alphaState.reset()), this._cachedVertexBuffers = null, this._cachedIndexBuffer = null, this._cachedEffectForVertexBuffers = null);
+ }, t.prototype._createTexture = function() {
+ return this._native.createTexture();
+ }, t.prototype._deleteTexture = function(e) {
+ this._native.deleteTexture(e);
+ }, t.prototype.updateDynamicTexture = function(e, n, i, o, a) {
+ this.createTexture("data:my_image_name", !0, i, null, Ne.a.BILINEAR_SAMPLINGMODE, void 0, void 0, "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYSURBVChTY/z//z8DPsAEpXGC4aCAgQEAGGMDDWwwgqsAAAAASUVORK5CYII=", e, t.TEXTUREFORMAT_RGBA, null, void 0);
+ }, t.prototype.createTexture = function(e, n, i, o, a, s, d, p, y, P, R, B, F) {
+ var z = this;
+ a === void 0 && (a = h.a.TEXTURE_TRILINEAR_SAMPLINGMODE), s === void 0 && (s = null), d === void 0 && (d = null), p === void 0 && (p = null), y === void 0 && (y = null), P === void 0 && (P = null), R === void 0 && (R = null);
+ var J = (e = e || "").substr(0, 5) === "data:", ie = J && e.indexOf(";base64,") !== -1, se = y || new Pt.a(this, Pt.b.Url), ce = e;
+ !this._transformTextureUrl || ie || y || p || (e = this._transformTextureUrl(e));
+ for (var ue = e.lastIndexOf("."), fe = R || (ue > -1 ? e.substring(ue).toLowerCase() : ""), ve = null, Te = 0, Re = Ue.a._TextureLoaders; Te < Re.length; Te++) {
+ var Ae = Re[Te];
+ if (Ae.canLoad(fe)) {
+ ve = Ae;
+ break;
+ }
+ }
+ o && o._addPendingData(se), se.url = e, se.generateMipMaps = !n, se.samplingMode = a, se.invertY = i, this.doNotHandleContextLost || (se._buffer = p);
+ var Ee = null;
+ if (s && !y && (Ee = se.onLoadedObservable.add(s)), y || this._internalTexturesCache.push(se), ve)
+ throw new Error("Loading textures from IInternalTextureLoader not yet implemented.");
+ var Se = function(De) {
+ var xe = se._webGLTexture;
+ xe ? z._native.loadTexture(xe, De, !n, i, function() {
+ se.baseWidth = z._native.getTextureWidth(xe), se.baseHeight = z._native.getTextureHeight(xe), se.width = se.baseWidth, se.height = se.baseHeight, se.isReady = !0;
+ var Le = z._getNativeSamplingMode(a);
+ z._native.setTextureSampling(xe, Le), o && o._removePendingData(se), se.onLoadedObservable.notifyObservers(se), se.onLoadedObservable.clear();
+ }, function() {
+ throw new Error("Could not load a native texture.");
+ }) : o && o._removePendingData(se);
+ };
+ if (J)
+ if (p instanceof ArrayBuffer)
+ Se(new Uint8Array(p));
+ else if (ArrayBuffer.isView(p))
+ Se(p);
+ else {
+ if (typeof p != "string")
+ throw new Error("Unsupported buffer type");
+ Se(new Uint8Array(Xe.b.DecodeBase64(p)));
+ }
+ else
+ ie ? Se(new Uint8Array(Xe.b.DecodeBase64(e))) : this._loadFile(e, function(De) {
+ return Se(new Uint8Array(De));
+ }, void 0, void 0, !0, function(De, xe) {
+ (function(Le, Me) {
+ o && o._removePendingData(se), e === ce ? (Ee && se.onLoadedObservable.remove(Ee), te.a.UseFallbackTexture && z.createTexture(te.a.FallbackTexture, n, se.invertY, o, a, null, d, p, se), d && d((Le || "Unknown error") + (te.a.UseFallbackTexture ? " - Fallback texture was used" : ""), Me)) : (l.a.Warn("Failed to load " + e + ", falling back to " + ce), z.createTexture(ce, n, se.invertY, o, a, s, d, p, se, P, R, B, F));
+ })("Unable to load " + (De && De.responseURL, xe));
+ });
+ return se;
+ }, t.prototype._createDepthStencilTexture = function(e, n) {
+ var i = new Hl(this, Pt.b.Depth), o = e.width || e, a = e.height || e, s = this._native.createDepthTexture(i._webGLTexture, o, a);
+ return i._framebuffer = s, i;
+ }, t.prototype._releaseFramebufferObjects = function(e) {
+ }, t.prototype.createCubeTexture = function(e, n, i, o, a, s, d, p, y, P, R, B) {
+ var F = this;
+ a === void 0 && (a = null), s === void 0 && (s = null), p === void 0 && (p = null), P === void 0 && (P = 0), R === void 0 && (R = 0), B === void 0 && (B = null);
+ var z = B || new Pt.a(this, Pt.b.Cube);
+ z.isCube = !0, z.url = e, z.generateMipMaps = !o, z._lodGenerationScale = P, z._lodGenerationOffset = R, this._doNotHandleContextLost || (z._extension = p, z._files = i);
+ var J = e.lastIndexOf(".");
+ if ((p || (J > -1 ? e.substring(J).toLowerCase() : "")) === ".env") {
+ if (i && i.length === 6)
+ throw new Error("Multi-file loading not allowed on env files.");
+ this._loadFile(e, function(se) {
+ return function(ce) {
+ var ue = gi.GetEnvInfo(ce);
+ if (z.width = ue.width, z.height = ue.width, gi.UploadEnvSpherical(z, ue), ue.version !== 1)
+ throw new Error('Unsupported babylon environment map version "' + ue.version + '"');
+ var fe = ue.specular;
+ if (!fe)
+ throw new Error("Nothing else parsed so far");
+ z._lodGenerationScale = fe.lodGenerationScale;
+ var ve = gi.CreateImageDataArrayBufferViews(ce, ue);
+ z.format = h.a.TEXTUREFORMAT_RGBA, z.type = h.a.TEXTURETYPE_UNSIGNED_INT, z.generateMipMaps = !0, z.getEngine().updateTextureSamplingMode(Ne.a.TRILINEAR_SAMPLINGMODE, z), z._isRGBD = !0, z.invertY = !0, F._native.loadCubeTextureWithMips(z._webGLTexture, ve, function() {
+ z.isReady = !0, a && a();
+ }, function() {
+ throw new Error("Could not load a native cube texture.");
+ });
+ }(new Uint8Array(se));
+ }, void 0, void 0, !0, function(se, ce) {
+ s && se && s(se.status + " " + se.statusText, ce);
+ });
+ } else {
+ if (!i || i.length !== 6)
+ throw new Error("Cannot load cubemap because 6 files were not defined");
+ var ie = [i[0], i[3], i[1], i[4], i[2], i[5]];
+ Promise.all(ie.map(function(se) {
+ return Xe.b.LoadFileAsync(se).then(function(ce) {
+ return new Uint8Array(ce);
+ });
+ })).then(function(se) {
+ return new Promise(function(ce, ue) {
+ F._native.loadCubeTexture(z._webGLTexture, se, !o, ce, ue);
+ });
+ }).then(function() {
+ z.isReady = !0, a && a();
+ }, function(se) {
+ s && s("Failed to load cubemap: " + se.message, se);
+ });
+ }
+ return this._internalTexturesCache.push(z), z;
+ }, t.prototype.createRenderTargetTexture = function(e, n) {
+ var i = new fl.a();
+ n !== void 0 && typeof n == "object" ? (i.generateMipMaps = n.generateMipMaps, i.generateDepthBuffer = n.generateDepthBuffer === void 0 || n.generateDepthBuffer, i.generateStencilBuffer = i.generateDepthBuffer && n.generateStencilBuffer, i.type = n.type === void 0 ? h.a.TEXTURETYPE_UNSIGNED_INT : n.type, i.samplingMode = n.samplingMode === void 0 ? h.a.TEXTURE_TRILINEAR_SAMPLINGMODE : n.samplingMode, i.format = n.format === void 0 ? h.a.TEXTUREFORMAT_RGBA : n.format) : (i.generateMipMaps = n, i.generateDepthBuffer = !0, i.generateStencilBuffer = !1, i.type = h.a.TEXTURETYPE_UNSIGNED_INT, i.samplingMode = h.a.TEXTURE_TRILINEAR_SAMPLINGMODE, i.format = h.a.TEXTUREFORMAT_RGBA), (i.type !== h.a.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering) && (i.type !== h.a.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering) || (i.samplingMode = h.a.TEXTURE_NEAREST_SAMPLINGMODE);
+ var o = new Hl(this, Pt.b.RenderTarget), a = e.width || e, s = e.height || e;
+ i.type !== h.a.TEXTURETYPE_FLOAT || this._caps.textureFloat || (i.type = h.a.TEXTURETYPE_UNSIGNED_INT, l.a.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type"));
+ var d = this._native.createFramebuffer(o._webGLTexture, a, s, this._getNativeTextureFormat(i.format, i.type), i.samplingMode, !!i.generateStencilBuffer, i.generateDepthBuffer, !!i.generateMipMaps);
+ return o._framebuffer = d, o.baseWidth = a, o.baseHeight = s, o.width = a, o.height = s, o.isReady = !0, o.samples = 1, o.generateMipMaps = !!i.generateMipMaps, o.samplingMode = i.samplingMode, o.type = i.type, o.format = i.format, o._generateDepthBuffer = i.generateDepthBuffer, o._generateStencilBuffer = !!i.generateStencilBuffer, this._internalTexturesCache.push(o), o;
+ }, t.prototype.updateTextureSamplingMode = function(e, n) {
+ if (n._webGLTexture) {
+ var i = this._getNativeSamplingMode(e);
+ this._native.setTextureSampling(n._webGLTexture, i);
+ }
+ n.samplingMode = e;
+ }, t.prototype.bindFramebuffer = function(e, n, i, o, a) {
+ if (n)
+ throw new Error("Cuboid frame buffers are not yet supported in NativeEngine.");
+ if (i || o)
+ throw new Error("Required width/height for frame buffers not yet supported in NativeEngine.");
+ e._depthStencilTexture ? this._bindUnboundFramebuffer(e._depthStencilTexture._framebuffer) : this._bindUnboundFramebuffer(e._framebuffer);
+ }, t.prototype.unBindFramebuffer = function(e, n, i) {
+ n === void 0 && (n = !1), n && l.a.Warn("Disabling mipmap generation not yet supported in NativeEngine. Ignoring."), i && i(), this._bindUnboundFramebuffer(null);
+ }, t.prototype.createDynamicVertexBuffer = function(e) {
+ return this.createVertexBuffer(e, !0);
+ }, t.prototype.updateDynamicIndexBuffer = function(e, n, i) {
+ i === void 0 && (i = 0);
+ var o = e, a = this._normalizeIndexData(n);
+ o.is32Bits = a.BYTES_PER_ELEMENT === 4, this._native.updateDynamicIndexBuffer(o.nativeIndexBuffer, a, i);
+ }, t.prototype.updateDynamicVertexBuffer = function(e, n, i, o) {
+ var a = e, s = ArrayBuffer.isView(n) ? n : new Float32Array(n);
+ this._native.updateDynamicVertexBuffer(a.nativeVertexBuffer, s, i ?? 0, o ?? s.byteLength);
+ }, t.prototype._setTexture = function(e, n, i, o) {
+ o === void 0 && (o = !1);
+ var a, s = this._boundUniforms[e];
+ if (!s)
+ return !1;
+ if (!n)
+ return this._boundTexturesCache[e] != null && (this._activeChannel = e, this._native.setTexture(s, null)), !1;
+ if (n.video)
+ this._activeChannel = e, n.update();
+ else if (n.delayLoadState === h.a.DELAYLOADSTATE_NOTLOADED)
+ return n.delayLoad(), !1;
+ return a = o ? n.depthStencilTexture : n.isReady() ? n.getInternalTexture() : n.isCube ? this.emptyCubeTexture : n.is3D ? this.emptyTexture3D : n.is2DArray ? this.emptyTexture2DArray : this.emptyTexture, this._activeChannel = e, !(!a || !a._webGLTexture) && (this._native.setTextureWrapMode(a._webGLTexture, this._getAddressMode(n.wrapU), this._getAddressMode(n.wrapV), this._getAddressMode(n.wrapR)), this._updateAnisotropicLevel(n), this._native.setTexture(s, a._webGLTexture), !0);
+ }, t.prototype._updateAnisotropicLevel = function(e) {
+ var n = e.getInternalTexture(), i = e.anisotropicFilteringLevel;
+ n && n._webGLTexture && n._cachedAnisotropicFilteringLevel !== i && (this._native.setTextureAnisotropicLevel(n._webGLTexture, i), n._cachedAnisotropicFilteringLevel = i);
+ }, t.prototype._getAddressMode = function(e) {
+ switch (e) {
+ case h.a.TEXTURE_WRAP_ADDRESSMODE:
+ return this._native.ADDRESS_MODE_WRAP;
+ case h.a.TEXTURE_CLAMP_ADDRESSMODE:
+ return this._native.ADDRESS_MODE_CLAMP;
+ case h.a.TEXTURE_MIRROR_ADDRESSMODE:
+ return this._native.ADDRESS_MODE_MIRROR;
+ default:
+ throw new Error("Unexpected wrap mode: " + e + ".");
+ }
+ }, t.prototype._bindTexture = function(e, n) {
+ var i = this._boundUniforms[e];
+ i && this._native.setTexture(i, n._webGLTexture);
+ }, t.prototype._deleteBuffer = function(e) {
+ e.nativeIndexBuffer && (this._native.deleteIndexBuffer(e.nativeIndexBuffer), delete e.nativeIndexBuffer), e.nativeVertexBuffer && (this._native.deleteVertexBuffer(e.nativeVertexBuffer), delete e.nativeVertexBuffer);
+ }, t.prototype.releaseEffects = function() {
+ }, t.prototype._uploadCompressedDataToTextureDirectly = function(e, n, i, o, a, s, d) {
+ throw new Error("_uploadCompressedDataToTextureDirectly not implemented.");
+ }, t.prototype._uploadDataToTextureDirectly = function(e, n, i, o) {
+ throw new Error("_uploadDataToTextureDirectly not implemented.");
+ }, t.prototype._uploadArrayBufferViewToTexture = function(e, n, i, o) {
+ throw new Error("_uploadArrayBufferViewToTexture not implemented.");
+ }, t.prototype._uploadImageToTexture = function(e, n, i, o) {
+ throw new Error("_uploadArrayBufferViewToTexture not implemented.");
+ }, t.prototype._getNativeSamplingMode = function(e) {
+ switch (e) {
+ case h.a.TEXTURE_NEAREST_NEAREST:
+ return this._native.TEXTURE_NEAREST_NEAREST;
+ case h.a.TEXTURE_LINEAR_LINEAR:
+ return this._native.TEXTURE_LINEAR_LINEAR;
+ case h.a.TEXTURE_LINEAR_LINEAR_MIPLINEAR:
+ return this._native.TEXTURE_LINEAR_LINEAR_MIPLINEAR;
+ case h.a.TEXTURE_NEAREST_NEAREST_MIPNEAREST:
+ return this._native.TEXTURE_NEAREST_NEAREST_MIPNEAREST;
+ case h.a.TEXTURE_NEAREST_LINEAR_MIPNEAREST:
+ return this._native.TEXTURE_NEAREST_LINEAR_MIPNEAREST;
+ case h.a.TEXTURE_NEAREST_LINEAR_MIPLINEAR:
+ return this._native.TEXTURE_NEAREST_LINEAR_MIPLINEAR;
+ case h.a.TEXTURE_NEAREST_LINEAR:
+ return this._native.TEXTURE_NEAREST_LINEAR;
+ case h.a.TEXTURE_NEAREST_NEAREST_MIPLINEAR:
+ return this._native.TEXTURE_NEAREST_NEAREST_MIPLINEAR;
+ case h.a.TEXTURE_LINEAR_NEAREST_MIPNEAREST:
+ return this._native.TEXTURE_LINEAR_NEAREST_MIPNEAREST;
+ case h.a.TEXTURE_LINEAR_NEAREST_MIPLINEAR:
+ return this._native.TEXTURE_LINEAR_NEAREST_MIPLINEAR;
+ case h.a.TEXTURE_LINEAR_LINEAR_MIPNEAREST:
+ return this._native.TEXTURE_LINEAR_LINEAR_MIPNEAREST;
+ case h.a.TEXTURE_LINEAR_NEAREST:
+ return this._native.TEXTURE_LINEAR_NEAREST;
+ default:
+ throw new Error("Unsupported sampling mode: " + e + ".");
+ }
+ }, t.prototype._getNativeTextureFormat = function(e, n) {
+ if (e == h.a.TEXTUREFORMAT_RGBA && n == h.a.TEXTURETYPE_UNSIGNED_INT)
+ return this._native.TEXTURE_FORMAT_RGBA8;
+ if (e == h.a.TEXTUREFORMAT_RGBA && n == h.a.TEXTURETYPE_FLOAT)
+ return this._native.TEXTURE_FORMAT_RGBA32F;
+ throw new Error("Unsupported texture format or type: format " + e + ", type " + n + ".");
+ }, t.prototype._getNativeAlphaMode = function(e) {
+ switch (e) {
+ case h.a.ALPHA_DISABLE:
+ return this._native.ALPHA_DISABLE;
+ case h.a.ALPHA_ADD:
+ return this._native.ALPHA_ADD;
+ case h.a.ALPHA_COMBINE:
+ return this._native.ALPHA_COMBINE;
+ case h.a.ALPHA_SUBTRACT:
+ return this._native.ALPHA_SUBTRACT;
+ case h.a.ALPHA_MULTIPLY:
+ return this._native.ALPHA_MULTIPLY;
+ case h.a.ALPHA_MAXIMIZED:
+ return this._native.ALPHA_MAXIMIZED;
+ case h.a.ALPHA_ONEONE:
+ return this._native.ALPHA_ONEONE;
+ case h.a.ALPHA_PREMULTIPLIED:
+ return this._native.ALPHA_PREMULTIPLIED;
+ case h.a.ALPHA_PREMULTIPLIED_PORTERDUFF:
+ return this._native.ALPHA_PREMULTIPLIED_PORTERDUFF;
+ case h.a.ALPHA_INTERPOLATE:
+ return this._native.ALPHA_INTERPOLATE;
+ case h.a.ALPHA_SCREENMODE:
+ return this._native.ALPHA_SCREENMODE;
+ default:
+ throw new Error("Unsupported alpha mode: " + e + ".");
+ }
+ }, t.prototype._getNativeAttribType = function(e) {
+ switch (e) {
+ case Oe.b.UNSIGNED_BYTE:
+ return this._native.ATTRIB_TYPE_UINT8;
+ case Oe.b.SHORT:
+ return this._native.ATTRIB_TYPE_INT16;
+ case Oe.b.FLOAT:
+ return this._native.ATTRIB_TYPE_FLOAT;
+ default:
+ throw new Error("Unsupported attribute type: " + e + ".");
+ }
+ }, t;
+ }(Ue.a), kf = f(74), No = function() {
+ function r() {
+ }
+ return r.COPY = 1, r.CUT = 2, r.PASTE = 3, r;
+ }(), Gf = function() {
+ function r(t, e) {
+ this.type = t, this.event = e;
+ }
+ return r.GetTypeFromCharacter = function(t) {
+ switch (t) {
+ case 67:
+ return No.COPY;
+ case 86:
+ return No.PASTE;
+ case 88:
+ return No.CUT;
+ default:
+ return -1;
+ }
+ }, r;
+ }(), fs = f(83), yi = f(69);
+ (function(r) {
+ r[r.Clean = 0] = "Clean", r[r.Stop = 1] = "Stop", r[r.Sync = 2] = "Sync", r[r.NoSync = 3] = "NoSync";
+ })(vi || (vi = {}));
+ var Ft = function() {
+ function r() {
+ }
+ return Object.defineProperty(r, "ForceFullSceneLoadingForIncremental", { get: function() {
+ return yi.a.ForceFullSceneLoadingForIncremental;
+ }, set: function(t) {
+ yi.a.ForceFullSceneLoadingForIncremental = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r, "ShowLoadingScreen", { get: function() {
+ return yi.a.ShowLoadingScreen;
+ }, set: function(t) {
+ yi.a.ShowLoadingScreen = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r, "loggingLevel", { get: function() {
+ return yi.a.loggingLevel;
+ }, set: function(t) {
+ yi.a.loggingLevel = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r, "CleanBoneMatrixWeights", { get: function() {
+ return yi.a.CleanBoneMatrixWeights;
+ }, set: function(t) {
+ yi.a.CleanBoneMatrixWeights = t;
+ }, enumerable: !1, configurable: !0 }), r.GetDefaultPlugin = function() {
+ return r._registeredPlugins[".babylon"];
+ }, r._GetPluginForExtension = function(t) {
+ var e = r._registeredPlugins[t];
+ return e || (l.a.Warn("Unable to find a plugin to load " + t + " files. Trying to use .babylon default plugin. To load from a specific filetype (eg. gltf) see: https://doc.babylonjs.com/how_to/load_from_any_file_type"), r.GetDefaultPlugin());
+ }, r._GetPluginForDirectLoad = function(t) {
+ for (var e in r._registeredPlugins) {
+ var n = r._registeredPlugins[e].plugin;
+ if (n.canDirectLoad && n.canDirectLoad(t))
+ return r._registeredPlugins[e];
+ }
+ return r.GetDefaultPlugin();
+ }, r._GetPluginForFilename = function(t) {
+ var e = t.indexOf("?");
+ e !== -1 && (t = t.substring(0, e));
+ var n = t.lastIndexOf("."), i = t.substring(n, t.length).toLowerCase();
+ return r._GetPluginForExtension(i);
+ }, r._GetDirectLoad = function(t) {
+ return t.substr(0, 5) === "data:" ? t.substr(5) : null;
+ }, r._LoadData = function(t, e, n, i, o, a, s) {
+ var d, p = r._GetDirectLoad(t.name), y = s ? r._GetPluginForExtension(s) : p ? r._GetPluginForDirectLoad(t.name) : r._GetPluginForFilename(t.name);
+ if (!(d = y.plugin.createPlugin !== void 0 ? y.plugin.createPlugin() : y.plugin))
+ throw "The loader plugin corresponding to the file type you are trying to load has not been found. If using es6, please import the plugin you wish to use before.";
+ if (r.OnPluginActivatedObservable.notifyObservers(d), p) {
+ if (d.directLoad) {
+ var P = d.directLoad(e, p);
+ P.then ? P.then(function(Ae) {
+ n(d, Ae);
+ }).catch(function(Ae) {
+ o("Error in directLoad of _loadData: " + Ae, Ae);
+ }) : n(d, P);
+ } else
+ n(d, p);
+ return d;
+ }
+ var R = y.isBinary, B = function(Ae, Ee) {
+ e.isDisposed ? o("Scene has been disposed") : n(d, Ae, Ee);
+ }, F = null, z = !1, J = d.onDisposeObservable;
+ J && J.add(function() {
+ z = !0, F && (F.abort(), F = null), a();
+ });
+ var ie = function() {
+ if (!z) {
+ var Ae = function(Se, De) {
+ B(Se, De ? De.responseURL : void 0);
+ }, Ee = function(Se) {
+ o(Se.message, Se);
+ };
+ F = d.requestFile ? d.requestFile(e, t.url, Ae, i, R, Ee) : e._requestFile(t.url, Ae, i, !0, R, Ee);
+ }
+ }, se = t.file || fs.a.FilesToLoad[t.name.toLowerCase()];
+ if (t.rootUrl.indexOf("file:") === -1 || t.rootUrl.indexOf("file:") !== -1 && !se) {
+ var ce = e.getEngine(), ue = ce.enableOfflineSupport;
+ if (ue) {
+ for (var fe = !1, ve = 0, Te = e.disableOfflineSupportExceptionRules; ve < Te.length; ve++)
+ if (Te[ve].test(t.url)) {
+ fe = !0;
+ break;
+ }
+ ue = !fe;
+ }
+ ue && Ue.a.OfflineProviderFactory ? e.offlineProvider = Ue.a.OfflineProviderFactory(t.url, ie, ce.disableManifestCheck) : ie();
+ } else if (se) {
+ var Re = function(Ae) {
+ o(Ae.message, Ae);
+ };
+ F = d.readFile ? d.readFile(e, se, B, i, R, Re) : e._readFile(se, B, i, R, Re);
+ } else
+ o("Unable to find file named " + t.name);
+ return d;
+ }, r._GetFileInfo = function(t, e) {
+ var n, i, o = null;
+ if (e)
+ if (e.name) {
+ var a = e;
+ n = t + a.name, i = a.name, o = a;
+ } else {
+ var s = e;
+ if (s.substr(0, 1) === "/")
+ return Xe.b.Error("Wrong sceneFilename parameter"), null;
+ n = t + s, i = s;
+ }
+ else
+ n = t, i = Xe.b.GetFilename(t), t = Xe.b.GetFolderPath(t);
+ return { url: n, rootUrl: t, name: i, file: o };
+ }, r.GetPluginForExtension = function(t) {
+ return r._GetPluginForExtension(t).plugin;
+ }, r.IsPluginForExtensionAvailable = function(t) {
+ return !!r._registeredPlugins[t];
+ }, r.RegisterPlugin = function(t) {
+ if (typeof t.extensions == "string") {
+ var e = t.extensions;
+ r._registeredPlugins[e.toLowerCase()] = { plugin: t, isBinary: !1 };
+ } else {
+ var n = t.extensions;
+ Object.keys(n).forEach(function(i) {
+ r._registeredPlugins[i.toLowerCase()] = { plugin: t, isBinary: n[i].isBinary };
+ });
+ }
+ }, r.ImportMesh = function(t, e, n, i, o, a, s, d) {
+ if (n === void 0 && (n = ""), i === void 0 && (i = te.a.LastCreatedScene), o === void 0 && (o = null), a === void 0 && (a = null), s === void 0 && (s = null), d === void 0 && (d = null), !i)
+ return l.a.Error("No scene available to import mesh to"), null;
+ var p = r._GetFileInfo(e, n);
+ if (!p)
+ return null;
+ var y = {};
+ i._addPendingData(y);
+ var P = function() {
+ i._removePendingData(y);
+ }, R = function(z, J) {
+ var ie = "Unable to import meshes from " + p.url + ": " + z;
+ s ? s(i, ie, J) : l.a.Error(ie), P();
+ }, B = a ? function(z) {
+ try {
+ a(z);
+ } catch (J) {
+ R("Error in onProgress callback: " + J, J);
+ }
+ } : void 0, F = function(z, J, ie, se, ce, ue, fe) {
+ if (i.importedMeshesFiles.push(p.url), o)
+ try {
+ o(z, J, ie, se, ce, ue, fe);
+ } catch (ve) {
+ R("Error in onSuccess callback: " + ve, ve);
+ }
+ i._removePendingData(y);
+ };
+ return r._LoadData(p, i, function(z, J, ie) {
+ if (z.rewriteRootURL && (p.rootUrl = z.rewriteRootURL(p.rootUrl, ie)), z.importMesh) {
+ var se = z, ce = new Array(), ue = new Array(), fe = new Array();
+ if (!se.importMesh(t, i, J, p.rootUrl, ce, ue, fe, R))
+ return;
+ i.loadingPluginName = z.name, F(ce, ue, fe, [], [], [], []);
+ } else
+ z.importMeshAsync(t, i, J, p.rootUrl, B, p.name).then(function(ve) {
+ i.loadingPluginName = z.name, F(ve.meshes, ve.particleSystems, ve.skeletons, ve.animationGroups, ve.transformNodes, ve.geometries, ve.lights);
+ }).catch(function(ve) {
+ R(ve.message, ve);
+ });
+ }, B, R, P, d);
+ }, r.ImportMeshAsync = function(t, e, n, i, o, a) {
+ return n === void 0 && (n = ""), i === void 0 && (i = te.a.LastCreatedScene), o === void 0 && (o = null), a === void 0 && (a = null), new Promise(function(s, d) {
+ r.ImportMesh(t, e, n, i, function(p, y, P, R, B, F, z) {
+ s({ meshes: p, particleSystems: y, skeletons: P, animationGroups: R, transformNodes: B, geometries: F, lights: z });
+ }, o, function(p, y, P) {
+ d(P || new Error(y));
+ }, a);
+ });
+ }, r.Load = function(t, e, n, i, o, a, s) {
+ return e === void 0 && (e = ""), n === void 0 && (n = te.a.LastCreatedEngine), i === void 0 && (i = null), o === void 0 && (o = null), a === void 0 && (a = null), s === void 0 && (s = null), n ? r.Append(t, e, new _e.a(n), i, o, a, s) : (Xe.b.Error("No engine available"), null);
+ }, r.LoadAsync = function(t, e, n, i, o) {
+ return e === void 0 && (e = ""), n === void 0 && (n = te.a.LastCreatedEngine), i === void 0 && (i = null), o === void 0 && (o = null), new Promise(function(a, s) {
+ r.Load(t, e, n, function(d) {
+ a(d);
+ }, i, function(d, p, y) {
+ s(y || new Error(p));
+ }, o);
+ });
+ }, r.Append = function(t, e, n, i, o, a, s) {
+ var d = this;
+ if (e === void 0 && (e = ""), n === void 0 && (n = te.a.LastCreatedScene), i === void 0 && (i = null), o === void 0 && (o = null), a === void 0 && (a = null), s === void 0 && (s = null), !n)
+ return l.a.Error("No scene available to append to"), null;
+ var p = r._GetFileInfo(t, e);
+ if (!p)
+ return null;
+ r.ShowLoadingScreen && !this._showingLoadingScreen && (this._showingLoadingScreen = !0, n.getEngine().displayLoadingUI(), n.executeWhenReady(function() {
+ n.getEngine().hideLoadingUI(), d._showingLoadingScreen = !1;
+ }));
+ var y = {};
+ n._addPendingData(y);
+ var P = function() {
+ n._removePendingData(y);
+ }, R = function(z, J) {
+ var ie = "Unable to load from " + p.url + (z ? ": " + z : "");
+ a ? a(n, ie, J) : l.a.Error(ie), P();
+ }, B = o ? function(z) {
+ try {
+ o(z);
+ } catch (J) {
+ R("Error in onProgress callback", J);
+ }
+ } : void 0, F = function() {
+ if (i)
+ try {
+ i(n);
+ } catch (z) {
+ R("Error in onSuccess callback", z);
+ }
+ n._removePendingData(y);
+ };
+ return r._LoadData(p, n, function(z, J) {
+ if (z.load) {
+ if (!z.load(n, J, p.rootUrl, R))
+ return;
+ n.loadingPluginName = z.name, F();
+ } else
+ z.loadAsync(n, J, p.rootUrl, B, p.name).then(function() {
+ n.loadingPluginName = z.name, F();
+ }).catch(function(ie) {
+ R(ie.message, ie);
+ });
+ }, B, R, P, s);
+ }, r.AppendAsync = function(t, e, n, i, o) {
+ return e === void 0 && (e = ""), n === void 0 && (n = te.a.LastCreatedScene), i === void 0 && (i = null), o === void 0 && (o = null), new Promise(function(a, s) {
+ r.Append(t, e, n, function(d) {
+ a(d);
+ }, i, function(d, p, y) {
+ s(y || new Error(p));
+ }, o);
+ });
+ }, r.LoadAssetContainer = function(t, e, n, i, o, a, s) {
+ if (e === void 0 && (e = ""), n === void 0 && (n = te.a.LastCreatedScene), i === void 0 && (i = null), o === void 0 && (o = null), a === void 0 && (a = null), s === void 0 && (s = null), !n)
+ return l.a.Error("No scene available to load asset container to"), null;
+ var d = r._GetFileInfo(t, e);
+ if (!d)
+ return null;
+ var p = {};
+ n._addPendingData(p);
+ var y = function() {
+ n._removePendingData(p);
+ }, P = function(F, z) {
+ var J = "Unable to load assets from " + d.url + (F ? ": " + F : "");
+ z && z.message && (J += " (" + z.message + ")"), a ? a(n, J, z) : l.a.Error(J), y();
+ }, R = o ? function(F) {
+ try {
+ o(F);
+ } catch (z) {
+ P("Error in onProgress callback", z);
+ }
+ } : void 0, B = function(F) {
+ if (i)
+ try {
+ i(F);
+ } catch (z) {
+ P("Error in onSuccess callback", z);
+ }
+ n._removePendingData(p);
+ };
+ return r._LoadData(d, n, function(F, z) {
+ if (F.loadAssetContainer) {
+ var J = F.loadAssetContainer(n, z, d.rootUrl, P);
+ if (!J)
+ return;
+ n.loadingPluginName = F.name, B(J);
+ } else
+ F.loadAssetContainerAsync ? F.loadAssetContainerAsync(n, z, d.rootUrl, R, d.name).then(function(ie) {
+ n.loadingPluginName = F.name, B(ie);
+ }).catch(function(ie) {
+ P(ie.message, ie);
+ }) : P("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.");
+ }, R, P, y, s);
+ }, r.LoadAssetContainerAsync = function(t, e, n, i, o) {
+ return e === void 0 && (e = ""), n === void 0 && (n = te.a.LastCreatedScene), i === void 0 && (i = null), o === void 0 && (o = null), new Promise(function(a, s) {
+ r.LoadAssetContainer(t, e, n, function(d) {
+ a(d);
+ }, i, function(d, p, y) {
+ s(y || new Error(p));
+ }, o);
+ });
+ }, r.ImportAnimations = function(t, e, n, i, o, a, s, d, p, y) {
+ if (e === void 0 && (e = ""), n === void 0 && (n = te.a.LastCreatedScene), i === void 0 && (i = !0), o === void 0 && (o = vi.Clean), a === void 0 && (a = null), s === void 0 && (s = null), d === void 0 && (d = null), p === void 0 && (p = null), y === void 0 && (y = null), n) {
+ if (i) {
+ for (var P = 0, R = n.animatables; P < R.length; P++)
+ R[P].reset();
+ n.stopAllAnimations(), n.animationGroups.slice().forEach(function(F) {
+ F.dispose();
+ }), n.getNodes().forEach(function(F) {
+ F.animations && (F.animations = []);
+ });
+ } else
+ switch (o) {
+ case vi.Clean:
+ n.animationGroups.slice().forEach(function(F) {
+ F.dispose();
+ });
+ break;
+ case vi.Stop:
+ n.animationGroups.forEach(function(F) {
+ F.stop();
+ });
+ break;
+ case vi.Sync:
+ n.animationGroups.forEach(function(F) {
+ F.reset(), F.restart();
+ });
+ break;
+ case vi.NoSync:
+ break;
+ default:
+ return void l.a.Error("Unknown animation group loading mode value '" + o + "'");
+ }
+ var B = n.animatables.length;
+ this.LoadAssetContainer(t, e, n, function(F) {
+ F.mergeAnimationsTo(n, n.animatables.slice(B), a), F.dispose(), n.onAnimationFileImportedObservable.notifyObservers(n), s && s(n);
+ }, d, p, y);
+ } else
+ l.a.Error("No scene available to load animations to");
+ }, r.ImportAnimationsAsync = function(t, e, n, i, o, a, s, d, p, y) {
+ return e === void 0 && (e = ""), n === void 0 && (n = te.a.LastCreatedScene), i === void 0 && (i = !0), o === void 0 && (o = vi.Clean), a === void 0 && (a = null), d === void 0 && (d = null), y === void 0 && (y = null), new Promise(function(P, R) {
+ r.ImportAnimations(t, e, n, i, o, a, function(B) {
+ P(B);
+ }, d, function(B, F, z) {
+ R(z || new Error(F));
+ }, y);
+ });
+ }, r.NO_LOGGING = h.a.SCENELOADER_NO_LOGGING, r.MINIMAL_LOGGING = h.a.SCENELOADER_MINIMAL_LOGGING, r.SUMMARY_LOGGING = h.a.SCENELOADER_SUMMARY_LOGGING, r.DETAILED_LOGGING = h.a.SCENELOADER_DETAILED_LOGGING, r.OnPluginActivatedObservable = new C.c(), r._registeredPlugins = {}, r._showingLoadingScreen = !1, r;
+ }(), ps = function(r) {
+ function t(e) {
+ var n = r.call(this, e) || this;
+ return n.controllerType = Jn.DAYDREAM, n;
+ }
+ return Object(c.d)(t, r), t.prototype.initControllerMesh = function(e, n) {
+ var i = this;
+ Ft.ImportMesh("", t.MODEL_BASE_URL, t.MODEL_FILENAME, e, function(o) {
+ i._defaultModel = o[1], i.attachToMesh(i._defaultModel), n && n(i._defaultModel);
+ });
+ }, t.prototype._handleButtonChange = function(e, n, i) {
+ if (e === 0) {
+ var o = this.onTriggerStateChangedObservable;
+ o && o.notifyObservers(n);
+ } else
+ l.a.Warn("Unrecognized Daydream button index: " + e);
+ }, t.MODEL_BASE_URL = "https://controllers.babylonjs.com/generic/", t.MODEL_FILENAME = "generic.babylon", t.GAMEPAD_ID_PREFIX = "Daydream", t;
+ }(Ri);
+ xi._ControllerFactories.push({ canCreate: function(r) {
+ return r.id.indexOf(ps.GAMEPAD_ID_PREFIX) === 0;
+ }, create: function(r) {
+ return new ps(r);
+ } });
+ var _s = function(r) {
+ function t(e) {
+ var n = r.call(this, e) || this;
+ return n._buttonIndexToObservableNameMap = ["onPadStateChangedObservable", "onTriggerStateChangedObservable"], n.controllerType = Jn.GEAR_VR, n._calculatedPosition = new u.e(n.hand == "left" ? -0.15 : 0.15, -0.5, 0.25), n._disableTrackPosition(n._calculatedPosition), n;
+ }
+ return Object(c.d)(t, r), t.prototype.initControllerMesh = function(e, n) {
+ var i = this;
+ Ft.ImportMesh("", t.MODEL_BASE_URL, t.MODEL_FILENAME, e, function(o) {
+ var a = new Ie.a("", e);
+ o[1].parent = a, o[1].position.z = -0.15, i._defaultModel = a, i.attachToMesh(i._defaultModel), n && n(i._defaultModel);
+ });
+ }, t.prototype._handleButtonChange = function(e, n, i) {
+ if (e < this._buttonIndexToObservableNameMap.length) {
+ var o = this[this._buttonIndexToObservableNameMap[e]];
+ o && o.notifyObservers(n);
+ }
+ }, t.MODEL_BASE_URL = "https://controllers.babylonjs.com/generic/", t.MODEL_FILENAME = "generic.babylon", t.GAMEPAD_ID_PREFIX = "Gear VR", t;
+ }(Ri);
+ xi._ControllerFactories.push({ canCreate: function(r) {
+ return r.id.indexOf(_s.GAMEPAD_ID_PREFIX) === 0 || r.id.indexOf("Oculus Go") !== -1 || r.id.indexOf("Vive Focus") !== -1;
+ }, create: function(r) {
+ return new _s(r);
+ } });
+ var wo = function(r) {
+ function t(e) {
+ return r.call(this, e) || this;
+ }
+ return Object(c.d)(t, r), t.prototype.initControllerMesh = function(e, n) {
+ var i = this;
+ Ft.ImportMesh("", t.MODEL_BASE_URL, t.MODEL_FILENAME, e, function(o) {
+ i._defaultModel = o[1], i.attachToMesh(i._defaultModel), n && n(i._defaultModel);
+ });
+ }, t.prototype._handleButtonChange = function(e, n, i) {
+ console.log("Button id: " + e + "state: "), console.dir(n);
+ }, t.MODEL_BASE_URL = "https://controllers.babylonjs.com/generic/", t.MODEL_FILENAME = "generic.babylon", t;
+ }(Ri);
+ xi._DefaultControllerFactory = function(r) {
+ return new wo(r);
+ };
+ var ms = function(r) {
+ function t(e) {
+ var n = r.call(this, e) || this;
+ return n.onSecondaryTriggerStateChangedObservable = new C.c(), n.onThumbRestChangedObservable = new C.c(), n.controllerType = Jn.OCULUS, n;
+ }
+ return Object(c.d)(t, r), t.prototype.initControllerMesh = function(e, n) {
+ var i, o = this;
+ i = this.hand === "left" ? t.MODEL_LEFT_FILENAME : t.MODEL_RIGHT_FILENAME, Ft.ImportMesh("", t._IsQuest ? t.QUEST_MODEL_BASE_URL : t.MODEL_BASE_URL, i, e, function(a) {
+ o._defaultModel = t._IsQuest ? a[0] : a[1], o.attachToMesh(o._defaultModel), n && n(o._defaultModel);
+ });
+ }, Object.defineProperty(t.prototype, "onAButtonStateChangedObservable", { get: function() {
+ if (this.hand === "right")
+ return this.onMainButtonStateChangedObservable;
+ throw new Error("No A button on left hand");
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onBButtonStateChangedObservable", { get: function() {
+ if (this.hand === "right")
+ return this.onSecondaryButtonStateChangedObservable;
+ throw new Error("No B button on left hand");
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onXButtonStateChangedObservable", { get: function() {
+ if (this.hand === "left")
+ return this.onMainButtonStateChangedObservable;
+ throw new Error("No X button on right hand");
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onYButtonStateChangedObservable", { get: function() {
+ if (this.hand === "left")
+ return this.onSecondaryButtonStateChangedObservable;
+ throw new Error("No Y button on right hand");
+ }, enumerable: !1, configurable: !0 }), t.prototype._handleButtonChange = function(e, n, i) {
+ var o = n, a = this.hand === "right" ? -1 : 1;
+ switch (e) {
+ case 0:
+ return void this.onPadStateChangedObservable.notifyObservers(o);
+ case 1:
+ return !t._IsQuest && this._defaultModel && (this._defaultModel.getChildren()[3].rotation.x = 0.2 * -o.value, this._defaultModel.getChildren()[3].position.y = 5e-3 * -o.value, this._defaultModel.getChildren()[3].position.z = 5e-3 * -o.value), void this.onTriggerStateChangedObservable.notifyObservers(o);
+ case 2:
+ return !t._IsQuest && this._defaultModel && (this._defaultModel.getChildren()[4].position.x = a * o.value * 35e-4), void this.onSecondaryTriggerStateChangedObservable.notifyObservers(o);
+ case 3:
+ return !t._IsQuest && this._defaultModel && (o.pressed ? this._defaultModel.getChildren()[1].position.y = -1e-3 : this._defaultModel.getChildren()[1].position.y = 0), void this.onMainButtonStateChangedObservable.notifyObservers(o);
+ case 4:
+ return !t._IsQuest && this._defaultModel && (o.pressed ? this._defaultModel.getChildren()[2].position.y = -1e-3 : this._defaultModel.getChildren()[2].position.y = 0), void this.onSecondaryButtonStateChangedObservable.notifyObservers(o);
+ case 5:
+ return void this.onThumbRestChangedObservable.notifyObservers(o);
+ }
+ }, t.MODEL_BASE_URL = "https://controllers.babylonjs.com/oculus/", t.MODEL_LEFT_FILENAME = "left.babylon", t.MODEL_RIGHT_FILENAME = "right.babylon", t.QUEST_MODEL_BASE_URL = "https://controllers.babylonjs.com/oculusQuest/", t._IsQuest = !1, t;
+ }(Ri);
+ xi._ControllerFactories.push({ canCreate: function(r) {
+ return Ue.a.LastCreatedEngine && Ue.a.LastCreatedEngine._vrDisplay && Ue.a.LastCreatedEngine._vrDisplay.displayName === "Oculus Quest" && (ms._IsQuest = !0), r.id.indexOf("Oculus Touch") !== -1;
+ }, create: function(r) {
+ return new ms(r);
+ } });
+ var Wl = function(r) {
+ function t(e) {
+ var n = r.call(this, e) || this;
+ return n.controllerType = Jn.VIVE, n._invertLeftStickY = !0, n;
+ }
+ return Object(c.d)(t, r), t.prototype.initControllerMesh = function(e, n) {
+ var i = this;
+ Ft.ImportMesh("", t.MODEL_BASE_URL, t.MODEL_FILENAME, e, function(o) {
+ i._defaultModel = o[1], i.attachToMesh(i._defaultModel), n && n(i._defaultModel);
+ });
+ }, Object.defineProperty(t.prototype, "onLeftButtonStateChangedObservable", { get: function() {
+ return this.onMainButtonStateChangedObservable;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onRightButtonStateChangedObservable", { get: function() {
+ return this.onMainButtonStateChangedObservable;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onMenuButtonStateChangedObservable", { get: function() {
+ return this.onSecondaryButtonStateChangedObservable;
+ }, enumerable: !1, configurable: !0 }), t.prototype._handleButtonChange = function(e, n, i) {
+ var o = n;
+ switch (e) {
+ case 0:
+ return void this.onPadStateChangedObservable.notifyObservers(o);
+ case 1:
+ return this._defaultModel && (this._defaultModel.getChildren()[6].rotation.x = 0.15 * -o.value), void this.onTriggerStateChangedObservable.notifyObservers(o);
+ case 2:
+ return void this.onMainButtonStateChangedObservable.notifyObservers(o);
+ case 3:
+ return this._defaultModel && (o.pressed ? this._defaultModel.getChildren()[2].position.y = -1e-3 : this._defaultModel.getChildren()[2].position.y = 0), void this.onSecondaryButtonStateChangedObservable.notifyObservers(o);
+ }
+ }, t.MODEL_BASE_URL = "https://controllers.babylonjs.com/vive/", t.MODEL_FILENAME = "wand.babylon", t;
+ }(Ri);
+ xi._ControllerFactories.push({ canCreate: function(r) {
+ return r.id.toLowerCase().indexOf("openvr") !== -1;
+ }, create: function(r) {
+ return new Wl(r);
+ } });
+ var zf = function() {
+ this.buttonMeshes = {}, this.axisMeshes = {};
+ }, Fo = function(r) {
+ function t(e) {
+ var n = r.call(this, e) || this;
+ return n._mapping = { buttons: ["thumbstick", "trigger", "grip", "menu", "trackpad"], buttonMeshNames: { trigger: "SELECT", menu: "MENU", grip: "GRASP", thumbstick: "THUMBSTICK_PRESS", trackpad: "TOUCHPAD_PRESS" }, buttonObservableNames: { trigger: "onTriggerStateChangedObservable", menu: "onSecondaryButtonStateChangedObservable", grip: "onMainButtonStateChangedObservable", thumbstick: "onPadStateChangedObservable", trackpad: "onTrackpadChangedObservable" }, axisMeshNames: ["THUMBSTICK_X", "THUMBSTICK_Y", "TOUCHPAD_TOUCH_X", "TOUCHPAD_TOUCH_Y"], pointingPoseMeshName: ar.POINTING_POSE }, n.onTrackpadChangedObservable = new C.c(), n.onTrackpadValuesChangedObservable = new C.c(), n.trackpad = { x: 0, y: 0 }, n.controllerType = Jn.WINDOWS, n._loadedMeshInfo = null, n;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "onTriggerButtonStateChangedObservable", { get: function() {
+ return this.onTriggerStateChangedObservable;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onMenuButtonStateChangedObservable", { get: function() {
+ return this.onSecondaryButtonStateChangedObservable;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onGripButtonStateChangedObservable", { get: function() {
+ return this.onMainButtonStateChangedObservable;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onThumbstickButtonStateChangedObservable", { get: function() {
+ return this.onPadStateChangedObservable;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onTouchpadButtonStateChangedObservable", { get: function() {
+ return this.onTrackpadChangedObservable;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "onTouchpadValuesChangedObservable", { get: function() {
+ return this.onTrackpadValuesChangedObservable;
+ }, enumerable: !1, configurable: !0 }), t.prototype._updateTrackpad = function() {
+ !this.browserGamepad.axes || this.browserGamepad.axes[2] == this.trackpad.x && this.browserGamepad.axes[3] == this.trackpad.y || (this.trackpad.x = this.browserGamepad.axes[this._mapping.axisMeshNames.indexOf("TOUCHPAD_TOUCH_X")], this.trackpad.y = this.browserGamepad.axes[this._mapping.axisMeshNames.indexOf("TOUCHPAD_TOUCH_Y")], this.onTrackpadValuesChangedObservable.notifyObservers(this.trackpad));
+ }, t.prototype.update = function() {
+ if (r.prototype.update.call(this), this.browserGamepad.axes && (this._updateTrackpad(), this._loadedMeshInfo))
+ for (var e = 0; e < this._mapping.axisMeshNames.length; e++)
+ this._lerpAxisTransform(e, this.browserGamepad.axes[e]);
+ }, t.prototype._handleButtonChange = function(e, n, i) {
+ var o = this._mapping.buttons[e];
+ if (o) {
+ this._updateTrackpad();
+ var a = this[this._mapping.buttonObservableNames[o]];
+ a && a.notifyObservers(n), this._lerpButtonTransform(o, n.value);
+ }
+ }, t.prototype._lerpButtonTransform = function(e, n) {
+ if (this._loadedMeshInfo) {
+ var i = this._loadedMeshInfo.buttonMeshes[e];
+ i && i.unpressed.rotationQuaternion && i.pressed.rotationQuaternion && i.value.rotationQuaternion && (u.b.SlerpToRef(i.unpressed.rotationQuaternion, i.pressed.rotationQuaternion, n, i.value.rotationQuaternion), u.e.LerpToRef(i.unpressed.position, i.pressed.position, n, i.value.position));
+ }
+ }, t.prototype._lerpAxisTransform = function(e, n) {
+ if (this._loadedMeshInfo) {
+ var i = this._loadedMeshInfo.axisMeshes[e];
+ if (i && i.min.rotationQuaternion && i.max.rotationQuaternion && i.value.rotationQuaternion) {
+ var o = 0.5 * n + 0.5;
+ u.b.SlerpToRef(i.min.rotationQuaternion, i.max.rotationQuaternion, o, i.value.rotationQuaternion), u.e.LerpToRef(i.min.position, i.max.position, o, i.value.position);
+ }
+ }
+ }, t.prototype.initControllerMesh = function(e, n, i) {
+ var o, a, s = this;
+ if (i === void 0 && (i = !1), Ft.IsPluginForExtensionAvailable(".glb")) {
+ var d = "default";
+ if (this.id && !i) {
+ var p = this.id.match(t.GAMEPAD_ID_PATTERN);
+ d = p && p[0] || d;
+ }
+ a = this.hand === "left" ? t.MODEL_LEFT_FILENAME : t.MODEL_RIGHT_FILENAME, o = t.MODEL_BASE_URL + d + "/";
+ } else
+ l.a.Warn("You need to reference GLTF loader to load Windows Motion Controllers model. Falling back to generic models"), o = wo.MODEL_BASE_URL, a = wo.MODEL_FILENAME;
+ Ft.ImportMesh("", o, a, e, function(y) {
+ s._loadedMeshInfo = s.processModel(e, y), s._loadedMeshInfo && (s._defaultModel = s._loadedMeshInfo.rootNode, s.attachToMesh(s._defaultModel), n && n(s._defaultModel));
+ }, null, function(y, P) {
+ l.a.Log(P), l.a.Warn("Failed to retrieve controller model from the remote server: " + o + a), i || s.initControllerMesh(y, n, !0);
+ });
+ }, t.prototype.processModel = function(e, n) {
+ for (var i = null, o = new Ie.a(this.id + " " + this.hand, e), a = null, s = 0; s < n.length; s++) {
+ var d = n[s];
+ if (!d.parent) {
+ d.isPickable = !1, a = d;
+ break;
+ }
+ }
+ return a ? (a.setParent(o), i = this.createMeshInfo(o)) : l.a.Warn("Could not find root node in model file."), i;
+ }, t.prototype.createMeshInfo = function(e) {
+ var n, i = new zf();
+ for (i.rootNode = e, i.buttonMeshes = {}, i.axisMeshes = {}, n = 0; n < this._mapping.buttons.length; n++) {
+ var o = this._mapping.buttonMeshNames[this._mapping.buttons[n]];
+ if (o) {
+ var a = P(e, o);
+ if (a) {
+ var s = { index: n, value: R(a, "VALUE"), pressed: R(a, "PRESSED"), unpressed: R(a, "UNPRESSED") };
+ s.value && s.pressed && s.unpressed ? i.buttonMeshes[this._mapping.buttons[n]] = s : l.a.Warn("Missing button submesh under mesh with name: " + o + "(VALUE: " + !!s.value + ", PRESSED: " + !!s.pressed + ", UNPRESSED:" + !!s.unpressed + ")");
+ } else
+ l.a.Warn("Missing button mesh with name: " + o);
+ } else
+ l.a.Log("Skipping unknown button at index: " + n + " with mapped name: " + this._mapping.buttons[n]);
+ }
+ for (n = 0; n < this._mapping.axisMeshNames.length; n++) {
+ var d = this._mapping.axisMeshNames[n];
+ if (d) {
+ var p = P(e, d);
+ if (p) {
+ var y = { index: n, value: R(p, "VALUE"), min: R(p, "MIN"), max: R(p, "MAX") };
+ y.value && y.min && y.max ? i.axisMeshes[n] = y : l.a.Warn("Missing axis submesh under mesh with name: " + d + "(VALUE: " + !!y.value + ", MIN: " + !!y.min + ", MAX:" + !!y.max + ")");
+ } else
+ l.a.Warn("Missing axis mesh with name: " + d);
+ } else
+ l.a.Log("Skipping unknown axis at index: " + n);
+ }
+ return i.pointingPoseNode = P(e, this._mapping.pointingPoseMeshName), i.pointingPoseNode ? this._pointingPoseNode = i.pointingPoseNode : l.a.Warn("Missing pointing pose mesh with name: " + this._mapping.pointingPoseMeshName), i;
+ function P(B, F) {
+ return B.getChildren(function(z) {
+ return z.name === F;
+ }, !1)[0];
+ }
+ function R(B, F) {
+ return B.getChildren(function(z) {
+ return z.name == F;
+ }, !0)[0];
+ }
+ }, t.prototype.getForwardRay = function(e) {
+ if (e === void 0 && (e = 100), !this._loadedMeshInfo || !this._loadedMeshInfo.pointingPoseNode)
+ return r.prototype.getForwardRay.call(this, e);
+ var n = this._loadedMeshInfo.pointingPoseNode.getWorldMatrix(), i = n.getTranslation(), o = new u.e(0, 0, -1), a = u.e.TransformNormal(o, n), s = u.e.Normalize(a);
+ return new dn.a(i, s, e);
+ }, t.prototype.dispose = function() {
+ r.prototype.dispose.call(this), this.onTrackpadChangedObservable.clear(), this.onTrackpadValuesChangedObservable.clear();
+ }, t.MODEL_BASE_URL = "https://controllers.babylonjs.com/microsoft/", t.MODEL_LEFT_FILENAME = "left.glb", t.MODEL_RIGHT_FILENAME = "right.glb", t.GAMEPAD_ID_PREFIX = "Spatial Controller (Spatial Interaction Source) ", t.GAMEPAD_ID_PATTERN = /([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/, t;
+ }(Ri), jf = function(r) {
+ function t(e) {
+ var n = r.call(this, e) || this;
+ return n._mapping = { buttons: ["trigger", "grip", "trackpad", "thumbstick", "menu"], buttonMeshNames: { trigger: "SELECT", menu: "MENU", grip: "GRASP", thumbstick: "THUMBSTICK_PRESS", trackpad: "TOUCHPAD_PRESS" }, buttonObservableNames: { trigger: "onTriggerStateChangedObservable", menu: "onSecondaryButtonStateChangedObservable", grip: "onMainButtonStateChangedObservable", thumbstick: "onThumbstickStateChangedObservable", trackpad: "onTrackpadChangedObservable" }, axisMeshNames: ["TOUCHPAD_TOUCH_X", "TOUCHPAD_TOUCH_Y", "THUMBSTICK_X", "THUMBSTICK_Y"], pointingPoseMeshName: ar.POINTING_POSE }, n.thumbstickValues = { x: 0, y: 0 }, n.onThumbstickStateChangedObservable = new C.c(), n.onThumbstickValuesChangedObservable = new C.c(), n.onTrackpadChangedObservable = n.onPadStateChangedObservable, n.onTrackpadValuesChangedObservable = n.onPadValuesChangedObservable, n;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "onThumbstickButtonStateChangedObservable", { get: function() {
+ return this.onThumbstickStateChangedObservable;
+ }, enumerable: !1, configurable: !0 }), t.prototype._updateTrackpad = function() {
+ !this.browserGamepad.axes || this.browserGamepad.axes[2] == this.thumbstickValues.x && this.browserGamepad.axes[3] == this.thumbstickValues.y || (this.trackpad.x = this.browserGamepad.axes[2], this.trackpad.y = this.browserGamepad.axes[3], this.onThumbstickValuesChangedObservable.notifyObservers(this.trackpad));
+ }, t.prototype.dispose = function() {
+ r.prototype.dispose.call(this), this.onThumbstickStateChangedObservable.clear(), this.onThumbstickValuesChangedObservable.clear();
+ }, t;
+ }(Fo);
+ xi._ControllerFactories.push({ canCreate: function(r) {
+ return r.id.indexOf(Fo.GAMEPAD_ID_PREFIX) === 0;
+ }, create: function(r) {
+ return new Fo(r);
+ } });
+ var Bo = f(75), fr = f(63), Ln = f(51), Cn = f(36), Kr = function(r) {
+ function t(e, n, i, o, a) {
+ var s, d, p, y, P, R, B;
+ n === void 0 && (n = I.a.Gray()), i === void 0 && (i = Cn.a.DefaultUtilityLayer), o === void 0 && (o = null), a === void 0 && (a = 1);
+ var F = r.call(this, i) || this;
+ F._pointerObserver = null, F.snapDistance = 0, F.onSnapObservable = new C.c(), F.uniformScaling = !1, F.sensitivity = 1, F._isEnabled = !0, F._parent = null, F._dragging = !1, F._tmpVector = new u.e(), F._tmpMatrix = new u.a(), F._tmpMatrix2 = new u.a(), F._parent = o, F._coloredMaterial = new Nt.a("", i.utilityLayerScene), F._coloredMaterial.diffuseColor = n, F._coloredMaterial.specularColor = n.subtract(new I.a(0.1, 0.1, 0.1)), F._hoverMaterial = new Nt.a("", i.utilityLayerScene), F._hoverMaterial.diffuseColor = I.a.Yellow(), F._disableMaterial = new Nt.a("", i.utilityLayerScene), F._disableMaterial.diffuseColor = I.a.Gray(), F._disableMaterial.alpha = 0.4, F._gizmoMesh = new Ie.a("axis", i.utilityLayerScene);
+ var z = F._createGizmoMesh(F._gizmoMesh, a), J = z.arrowMesh, ie = z.arrowTail, se = F._createGizmoMesh(F._gizmoMesh, a + 4, !0);
+ F._gizmoMesh.lookAt(F._rootMesh.position.add(e)), F._rootMesh.addChild(F._gizmoMesh), F._gizmoMesh.scaling.scaleInPlace(1 / 3);
+ var ce = J.position.clone(), ue = ie.position.clone(), fe = ie.scaling.clone(), ve = function(xe) {
+ var Le = xe * (3 / F._rootMesh.scaling.length()) * 6;
+ J.position.z += Le / 3.5, ie.scaling.y += Le, ie.position.z = J.position.z / 2;
+ }, Te = function() {
+ J.position.set(ce.x, ce.y, ce.z), ie.position.set(ue.x, ue.y, ue.z), ie.scaling.set(fe.x, fe.y, fe.z), F._dragging = !1;
+ };
+ F.dragBehavior = new fi.a({ dragAxis: e }), F.dragBehavior.moveAttached = !1, F._rootMesh.addBehavior(F.dragBehavior);
+ var Re = 0, Ae = new u.e(), Ee = { snapDistance: 0 };
+ F.dragBehavior.onDragObservable.add(function(xe) {
+ if (F.attachedNode) {
+ var Le = F.sensitivity * xe.dragDistance * (3 * F.scaleRatio / F._rootMesh.scaling.length()), Me = !1, we = 0;
+ F.uniformScaling ? (F.attachedNode.getWorldMatrix().decompose(Ae), Ae.normalize(), Ae.y < 0 && Ae.scaleInPlace(-1)) : Ae.copyFrom(e), F.snapDistance == 0 ? Ae.scaleToRef(Le, Ae) : (Re += Le, Math.abs(Re) > F.snapDistance ? (we = Math.floor(Math.abs(Re) / F.snapDistance), Re < 0 && (we *= -1), Re %= F.snapDistance, Ae.scaleToRef(F.snapDistance * we, Ae), Me = !0) : Ae.scaleInPlace(0)), u.a.ScalingToRef(1 + Ae.x, 1 + Ae.y, 1 + Ae.z, F._tmpMatrix2), F._tmpMatrix2.multiplyToRef(F.attachedNode.getWorldMatrix(), F._tmpMatrix), F._tmpMatrix.decompose(F._tmpVector), Math.abs(F._tmpVector.x) < 1e5 && Math.abs(F._tmpVector.y) < 1e5 && Math.abs(F._tmpVector.z) < 1e5 && F.attachedNode.getWorldMatrix().copyFrom(F._tmpMatrix), Me && (Ee.snapDistance = F.snapDistance * we, F.onSnapObservable.notifyObservers(Ee)), F._matrixChanged();
+ }
+ }), F.dragBehavior.onDragStartObservable.add(function() {
+ F._dragging = !0;
+ }), F.dragBehavior.onDragObservable.add(function(xe) {
+ return ve(xe.dragDistance);
+ }), F.dragBehavior.onDragEndObservable.add(Te), (p = (d = (s = o == null ? void 0 : o.uniformScaleGizmo) === null || s === void 0 ? void 0 : s.dragBehavior) === null || d === void 0 ? void 0 : d.onDragObservable) === null || p === void 0 || p.add(function(xe) {
+ return ve(xe.delta.y);
+ }), (R = (P = (y = o == null ? void 0 : o.uniformScaleGizmo) === null || y === void 0 ? void 0 : y.dragBehavior) === null || P === void 0 ? void 0 : P.onDragEndObservable) === null || R === void 0 || R.add(Te);
+ var Se = { gizmoMeshes: [J, ie], colliderMeshes: [se.arrowMesh, se.arrowTail], material: F._coloredMaterial, hoverMaterial: F._hoverMaterial, disableMaterial: F._disableMaterial, active: !1 };
+ (B = F._parent) === null || B === void 0 || B.addToAxisCache(F._gizmoMesh, Se), F._pointerObserver = i.utilityLayerScene.onPointerObservable.add(function(xe) {
+ var Le;
+ if (!F._customMeshSet && (F._isHovered = Se.colliderMeshes.indexOf((Le = xe == null ? void 0 : xe.pickInfo) === null || Le === void 0 ? void 0 : Le.pickedMesh) != -1, !F._parent)) {
+ var Me = F._isHovered || F._dragging ? F._hoverMaterial : F._coloredMaterial;
+ Se.gizmoMeshes.forEach(function(we) {
+ we.material = Me, we.color && (we.color = Me.diffuseColor);
+ });
+ }
+ });
+ var De = i._getSharedGizmoLight();
+ return De.includedOnlyMeshes = De.includedOnlyMeshes.concat(F._rootMesh.getChildMeshes()), F;
+ }
+ return Object(c.d)(t, r), t.prototype._createGizmoMesh = function(e, n, i) {
+ i === void 0 && (i = !1);
+ var o = fr.a.CreateBox("yPosMesh", { size: 0.4 * (1 + (n - 1) / 4) }, this.gizmoLayer.utilityLayerScene), a = ci.a.CreateCylinder("cylinder", { diameterTop: 5e-3 * n, height: 0.275, diameterBottom: 5e-3 * n, tessellation: 96 }, this.gizmoLayer.utilityLayerScene);
+ return o.scaling.scaleInPlace(0.1), o.material = this._coloredMaterial, o.rotation.x = Math.PI / 2, o.position.z += 0.3, a.material = this._coloredMaterial, a.position.z += 0.1375, a.rotation.x = Math.PI / 2, i && (o.visibility = 0, a.visibility = 0), e.addChild(o), e.addChild(a), { arrowMesh: o, arrowTail: a };
+ }, t.prototype._attachedNodeChanged = function(e) {
+ this.dragBehavior && (this.dragBehavior.enabled = !!e);
+ }, Object.defineProperty(t.prototype, "isEnabled", { get: function() {
+ return this._isEnabled;
+ }, set: function(e) {
+ this._isEnabled = e, e ? this._parent && (this.attachedMesh = this._parent.attachedMesh, this.attachedNode = this._parent.attachedNode) : (this.attachedMesh = null, this.attachedNode = null);
+ }, enumerable: !1, configurable: !0 }), t.prototype.dispose = function() {
+ this.onSnapObservable.clear(), this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver), this.dragBehavior.detach(), this._gizmoMesh && this._gizmoMesh.dispose(), [this._coloredMaterial, this._hoverMaterial, this._disableMaterial].forEach(function(e) {
+ e && e.dispose();
+ }), r.prototype.dispose.call(this);
+ }, t.prototype.setCustomMesh = function(e, n) {
+ var i = this;
+ n === void 0 && (n = !1), r.prototype.setCustomMesh.call(this, e), n && (this._rootMesh.getChildMeshes().forEach(function(o) {
+ o.material = i._coloredMaterial, o.color && (o.color = i._coloredMaterial.diffuseColor);
+ }), this._customMeshSet = !1);
+ }, t;
+ }(Ln.a), Nn = f(45), sn = f(40), Xl = function(r) {
+ function t(e, n) {
+ e === void 0 && (e = I.a.Gray()), n === void 0 && (n = Cn.a.DefaultKeepDepthUtilityLayer);
+ var i = r.call(this, n) || this;
+ i._boundingDimensions = new u.e(1, 1, 1), i._renderObserver = null, i._pointerObserver = null, i._scaleDragSpeed = 0.2, i._tmpQuaternion = new u.b(), i._tmpVector = new u.e(0, 0, 0), i._tmpRotationMatrix = new u.a(), i.ignoreChildren = !1, i.includeChildPredicate = null, i.rotationSphereSize = 0.1, i.scaleBoxSize = 0.1, i.fixedDragMeshScreenSize = !1, i.fixedDragMeshBoundsSize = !1, i.fixedDragMeshScreenSizeDistanceFactor = 10, i.onDragStartObservable = new C.c(), i.onScaleBoxDragObservable = new C.c(), i.onScaleBoxDragEndObservable = new C.c(), i.onRotationSphereDragObservable = new C.c(), i.onRotationSphereDragEndObservable = new C.c(), i.scalePivot = null, i._existingMeshScale = new u.e(), i._dragMesh = null, i.pointerDragBehavior = new fi.a(), i.updateScale = !1, i._anchorMesh = new Mt.a("anchor", n.utilityLayerScene), i.coloredMaterial = new Nt.a("", n.utilityLayerScene), i.coloredMaterial.disableLighting = !0, i.hoverColoredMaterial = new Nt.a("", n.utilityLayerScene), i.hoverColoredMaterial.disableLighting = !0, i._lineBoundingBox = new Mt.a("", n.utilityLayerScene), i._lineBoundingBox.rotationQuaternion = new u.b();
+ var o = [];
+ o.push(sn.a.CreateLines("lines", { points: [new u.e(0, 0, 0), new u.e(i._boundingDimensions.x, 0, 0)] }, n.utilityLayerScene)), o.push(sn.a.CreateLines("lines", { points: [new u.e(0, 0, 0), new u.e(0, i._boundingDimensions.y, 0)] }, n.utilityLayerScene)), o.push(sn.a.CreateLines("lines", { points: [new u.e(0, 0, 0), new u.e(0, 0, i._boundingDimensions.z)] }, n.utilityLayerScene)), o.push(sn.a.CreateLines("lines", { points: [new u.e(i._boundingDimensions.x, 0, 0), new u.e(i._boundingDimensions.x, i._boundingDimensions.y, 0)] }, n.utilityLayerScene)), o.push(sn.a.CreateLines("lines", { points: [new u.e(i._boundingDimensions.x, 0, 0), new u.e(i._boundingDimensions.x, 0, i._boundingDimensions.z)] }, n.utilityLayerScene)), o.push(sn.a.CreateLines("lines", { points: [new u.e(0, i._boundingDimensions.y, 0), new u.e(i._boundingDimensions.x, i._boundingDimensions.y, 0)] }, n.utilityLayerScene)), o.push(sn.a.CreateLines("lines", { points: [new u.e(0, i._boundingDimensions.y, 0), new u.e(0, i._boundingDimensions.y, i._boundingDimensions.z)] }, n.utilityLayerScene)), o.push(sn.a.CreateLines("lines", { points: [new u.e(0, 0, i._boundingDimensions.z), new u.e(i._boundingDimensions.x, 0, i._boundingDimensions.z)] }, n.utilityLayerScene)), o.push(sn.a.CreateLines("lines", { points: [new u.e(0, 0, i._boundingDimensions.z), new u.e(0, i._boundingDimensions.y, i._boundingDimensions.z)] }, n.utilityLayerScene)), o.push(sn.a.CreateLines("lines", { points: [new u.e(i._boundingDimensions.x, i._boundingDimensions.y, i._boundingDimensions.z), new u.e(0, i._boundingDimensions.y, i._boundingDimensions.z)] }, n.utilityLayerScene)), o.push(sn.a.CreateLines("lines", { points: [new u.e(i._boundingDimensions.x, i._boundingDimensions.y, i._boundingDimensions.z), new u.e(i._boundingDimensions.x, 0, i._boundingDimensions.z)] }, n.utilityLayerScene)), o.push(sn.a.CreateLines("lines", { points: [new u.e(i._boundingDimensions.x, i._boundingDimensions.y, i._boundingDimensions.z), new u.e(i._boundingDimensions.x, i._boundingDimensions.y, 0)] }, n.utilityLayerScene)), o.forEach(function(J) {
+ J.color = e, J.position.addInPlace(new u.e(-i._boundingDimensions.x / 2, -i._boundingDimensions.y / 2, -i._boundingDimensions.z / 2)), J.isPickable = !1, i._lineBoundingBox.addChild(J);
+ }), i._rootMesh.addChild(i._lineBoundingBox), i.setColor(e), i._rotateSpheresParent = new Mt.a("", n.utilityLayerScene), i._rotateSpheresParent.rotationQuaternion = new u.b();
+ for (var a = function(J) {
+ var ie = Nn.a.CreateSphere("", { diameter: 1 }, n.utilityLayerScene);
+ ie.rotationQuaternion = new u.b(), ie.material = s.coloredMaterial, (P = new fi.a({})).moveAttached = !1, P.updateDragPlane = !1, ie.addBehavior(P);
+ var se = new u.e(1, 0, 0), ce = 0;
+ P.onDragStartObservable.add(function() {
+ se.copyFrom(ie.forward), ce = 0;
+ }), P.onDragObservable.add(function(ue) {
+ if (i.onRotationSphereDragObservable.notifyObservers({}), i.attachedMesh) {
+ var fe = i.attachedMesh.parent;
+ if (fe && fe.scaling && fe.scaling.isNonUniformWithinEpsilon(1e-3))
+ return void l.a.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
+ Un.a._RemoveAndStorePivotPoint(i.attachedMesh);
+ var ve = se, Te = ue.dragPlaneNormal.scale(u.e.Dot(ue.dragPlaneNormal, ve)), Re = ve.subtract(Te).normalizeToNew(), Ae = u.e.Dot(Re, ue.delta) < 0 ? Math.abs(ue.delta.length()) : -Math.abs(ue.delta.length());
+ Ae = Ae / i._boundingDimensions.length() * i._anchorMesh.scaling.length(), i.attachedMesh.rotationQuaternion || (i.attachedMesh.rotationQuaternion = u.b.RotationYawPitchRoll(i.attachedMesh.rotation.y, i.attachedMesh.rotation.x, i.attachedMesh.rotation.z)), i._anchorMesh.rotationQuaternion || (i._anchorMesh.rotationQuaternion = u.b.RotationYawPitchRoll(i._anchorMesh.rotation.y, i._anchorMesh.rotation.x, i._anchorMesh.rotation.z)), ce += Ae, Math.abs(ce) <= 2 * Math.PI && (J >= 8 ? u.b.RotationYawPitchRollToRef(0, 0, Ae, i._tmpQuaternion) : J >= 4 ? u.b.RotationYawPitchRollToRef(Ae, 0, 0, i._tmpQuaternion) : u.b.RotationYawPitchRollToRef(0, Ae, 0, i._tmpQuaternion), i._anchorMesh.addChild(i.attachedMesh), i._anchorMesh.rotationQuaternion.multiplyToRef(i._tmpQuaternion, i._anchorMesh.rotationQuaternion), i._anchorMesh.removeChild(i.attachedMesh), i.attachedMesh.setParent(fe)), i.updateBoundingBox(), Un.a._RestorePivotPoint(i.attachedMesh);
+ }
+ i._updateDummy();
+ }), P.onDragStartObservable.add(function() {
+ i.onDragStartObservable.notifyObservers({}), i._selectNode(ie);
+ }), P.onDragEndObservable.add(function() {
+ i.onRotationSphereDragEndObservable.notifyObservers({}), i._selectNode(null), i._updateDummy();
+ }), s._rotateSpheresParent.addChild(ie);
+ }, s = this, d = 0; d < 12; d++)
+ a(d);
+ i._rootMesh.addChild(i._rotateSpheresParent), i._scaleBoxesParent = new Mt.a("", n.utilityLayerScene), i._scaleBoxesParent.rotationQuaternion = new u.b();
+ for (var p = 0; p < 3; p++)
+ for (var y = 0; y < 3; y++)
+ for (var P, R = function() {
+ var J = (p === 1 ? 1 : 0) + (y === 1 ? 1 : 0) + (F === 1 ? 1 : 0);
+ if (J === 1 || J === 3)
+ return "continue";
+ var ie = fr.a.CreateBox("", { size: 1 }, n.utilityLayerScene);
+ ie.material = B.coloredMaterial, ie.metadata = J === 2;
+ var se = new u.e(p - 1, y - 1, F - 1).normalize();
+ (P = new fi.a({ dragAxis: se })).updateDragPlane = !1, P.moveAttached = !1, ie.addBehavior(P), P.onDragObservable.add(function(ce) {
+ if (i.onScaleBoxDragObservable.notifyObservers({}), i.attachedMesh) {
+ var ue = i.attachedMesh.parent;
+ if (ue && ue.scaling && ue.scaling.isNonUniformWithinEpsilon(1e-3))
+ return void l.a.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
+ Un.a._RemoveAndStorePivotPoint(i.attachedMesh);
+ var fe = ce.dragDistance / i._boundingDimensions.length() * i._anchorMesh.scaling.length(), ve = new u.e(fe, fe, fe);
+ J === 2 && (ve.x *= Math.abs(se.x), ve.y *= Math.abs(se.y), ve.z *= Math.abs(se.z)), ve.scaleInPlace(i._scaleDragSpeed), i.updateBoundingBox(), i.scalePivot ? (i.attachedMesh.getWorldMatrix().getRotationMatrixToRef(i._tmpRotationMatrix), i._boundingDimensions.scaleToRef(0.5, i._tmpVector), u.e.TransformCoordinatesToRef(i._tmpVector, i._tmpRotationMatrix, i._tmpVector), i._anchorMesh.position.subtractInPlace(i._tmpVector), i._boundingDimensions.multiplyToRef(i.scalePivot, i._tmpVector), u.e.TransformCoordinatesToRef(i._tmpVector, i._tmpRotationMatrix, i._tmpVector), i._anchorMesh.position.addInPlace(i._tmpVector)) : (ie.absolutePosition.subtractToRef(i._anchorMesh.position, i._tmpVector), i._anchorMesh.position.subtractInPlace(i._tmpVector)), i._anchorMesh.addChild(i.attachedMesh), i._anchorMesh.scaling.addInPlace(ve), (i._anchorMesh.scaling.x < 0 || i._anchorMesh.scaling.y < 0 || i._anchorMesh.scaling.z < 0) && i._anchorMesh.scaling.subtractInPlace(ve), i._anchorMesh.removeChild(i.attachedMesh), i.attachedMesh.setParent(ue), Un.a._RestorePivotPoint(i.attachedMesh);
+ }
+ i._updateDummy();
+ }), P.onDragStartObservable.add(function() {
+ i.onDragStartObservable.notifyObservers({}), i._selectNode(ie);
+ }), P.onDragEndObservable.add(function() {
+ i.onScaleBoxDragEndObservable.notifyObservers({}), i._selectNode(null), i._updateDummy();
+ }), B._scaleBoxesParent.addChild(ie);
+ }, B = this, F = 0; F < 3; F++)
+ R();
+ i._rootMesh.addChild(i._scaleBoxesParent);
+ var z = new Array();
+ return i._pointerObserver = n.utilityLayerScene.onPointerObservable.add(function(J) {
+ z[J.event.pointerId] ? J.pickInfo && J.pickInfo.pickedMesh != z[J.event.pointerId] && (z[J.event.pointerId].material = i.coloredMaterial, delete z[J.event.pointerId]) : i._rotateSpheresParent.getChildMeshes().concat(i._scaleBoxesParent.getChildMeshes()).forEach(function(ie) {
+ J.pickInfo && J.pickInfo.pickedMesh == ie && (z[J.event.pointerId] = ie, ie.material = i.hoverColoredMaterial);
+ });
+ }), i._renderObserver = i.gizmoLayer.originalScene.onBeforeRenderObservable.add(function() {
+ i.attachedMesh && !i._existingMeshScale.equals(i.attachedMesh.scaling) ? i.updateBoundingBox() : (i.fixedDragMeshScreenSize || i.fixedDragMeshBoundsSize) && (i._updateRotationSpheres(), i._updateScaleBoxes()), i._dragMesh && i.attachedMesh && i.pointerDragBehavior.dragging && (i._lineBoundingBox.position.rotateByQuaternionToRef(i._rootMesh.rotationQuaternion, i._tmpVector), i.attachedMesh.setAbsolutePosition(i._dragMesh.position.add(i._tmpVector.scale(-1))));
+ }), i.updateBoundingBox(), i;
+ }
+ return Object(c.d)(t, r), t.prototype.setColor = function(e) {
+ this.coloredMaterial.emissiveColor = e, this.hoverColoredMaterial.emissiveColor = e.clone().add(new I.a(0.3, 0.3, 0.3)), this._lineBoundingBox.getChildren().forEach(function(n) {
+ n.color && (n.color = e);
+ });
+ }, t.prototype._attachedNodeChanged = function(e) {
+ var n = this;
+ if (e) {
+ Un.a._RemoveAndStorePivotPoint(e);
+ var i = e.parent;
+ this._anchorMesh.addChild(e), this._anchorMesh.removeChild(e), e.setParent(i), Un.a._RestorePivotPoint(e), this.updateBoundingBox(), e.getChildMeshes(!1).forEach(function(o) {
+ o.markAsDirty("scaling");
+ }), this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce(function() {
+ n._updateDummy();
+ });
+ }
+ }, t.prototype._selectNode = function(e) {
+ this._rotateSpheresParent.getChildMeshes().concat(this._scaleBoxesParent.getChildMeshes()).forEach(function(n) {
+ n.isVisible = !e || n == e;
+ });
+ }, t.prototype.updateBoundingBox = function() {
+ if (this.attachedMesh) {
+ Un.a._RemoveAndStorePivotPoint(this.attachedMesh);
+ var e = this.attachedMesh.parent;
+ this.attachedMesh.setParent(null);
+ var n = null;
+ this.attachedMesh.skeleton && (n = this.attachedMesh.skeleton.overrideMesh, this.attachedMesh.skeleton.overrideMesh = null), this._update(), this.attachedMesh.rotationQuaternion || (this.attachedMesh.rotationQuaternion = u.b.RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z)), this._anchorMesh.rotationQuaternion || (this._anchorMesh.rotationQuaternion = u.b.RotationYawPitchRoll(this._anchorMesh.rotation.y, this._anchorMesh.rotation.x, this._anchorMesh.rotation.z)), this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion), this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion), this._tmpVector.copyFrom(this.attachedMesh.position), this.attachedMesh.rotationQuaternion.set(0, 0, 0, 1), this.attachedMesh.position.set(0, 0, 0);
+ var i = this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren, this.includeChildPredicate);
+ i.max.subtractToRef(i.min, this._boundingDimensions), this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions), this._lineBoundingBox.position.set((i.max.x + i.min.x) / 2, (i.max.y + i.min.y) / 2, (i.max.z + i.min.z) / 2), this._rotateSpheresParent.position.copyFrom(this._lineBoundingBox.position), this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position), this._lineBoundingBox.computeWorldMatrix(), this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition), this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion), this.attachedMesh.position.copyFrom(this._tmpVector), this.attachedMesh.setParent(e), this.attachedMesh.skeleton && (this.attachedMesh.skeleton.overrideMesh = n);
+ }
+ this._updateRotationSpheres(), this._updateScaleBoxes(), this.attachedMesh && (this._existingMeshScale.copyFrom(this.attachedMesh.scaling), Un.a._RestorePivotPoint(this.attachedMesh));
+ }, t.prototype._updateRotationSpheres = function() {
+ for (var e = this._rotateSpheresParent.getChildMeshes(), n = 0; n < 3; n++)
+ for (var i = 0; i < 2; i++)
+ for (var o = 0; o < 2; o++) {
+ var a = 4 * n + 2 * i + o;
+ if (n == 0 && (e[a].position.set(this._boundingDimensions.x / 2, this._boundingDimensions.y * i, this._boundingDimensions.z * o), e[a].position.addInPlace(new u.e(-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2)), e[a].lookAt(u.e.Cross(e[a].position.normalizeToNew(), u.e.Right()).normalizeToNew().add(e[a].position))), n == 1 && (e[a].position.set(this._boundingDimensions.x * i, this._boundingDimensions.y / 2, this._boundingDimensions.z * o), e[a].position.addInPlace(new u.e(-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2)), e[a].lookAt(u.e.Cross(e[a].position.normalizeToNew(), u.e.Up()).normalizeToNew().add(e[a].position))), n == 2 && (e[a].position.set(this._boundingDimensions.x * i, this._boundingDimensions.y * o, this._boundingDimensions.z / 2), e[a].position.addInPlace(new u.e(-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2)), e[a].lookAt(u.e.Cross(e[a].position.normalizeToNew(), u.e.Forward()).normalizeToNew().add(e[a].position))), this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
+ e[a].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
+ var s = this.rotationSphereSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
+ e[a].scaling.set(s, s, s);
+ } else
+ this.fixedDragMeshBoundsSize ? e[a].scaling.set(this.rotationSphereSize * this._boundingDimensions.x, this.rotationSphereSize * this._boundingDimensions.y, this.rotationSphereSize * this._boundingDimensions.z) : e[a].scaling.set(this.rotationSphereSize, this.rotationSphereSize, this.rotationSphereSize);
+ }
+ }, t.prototype._updateScaleBoxes = function() {
+ for (var e = this._scaleBoxesParent.getChildMeshes(), n = 0, i = 0; i < 3; i++)
+ for (var o = 0; o < 3; o++)
+ for (var a = 0; a < 3; a++) {
+ var s = (i === 1 ? 1 : 0) + (o === 1 ? 1 : 0) + (a === 1 ? 1 : 0);
+ if (s !== 1 && s !== 3) {
+ if (e[n])
+ if (e[n].position.set(this._boundingDimensions.x * (i / 2), this._boundingDimensions.y * (o / 2), this._boundingDimensions.z * (a / 2)), e[n].position.addInPlace(new u.e(-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2)), this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
+ e[n].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
+ var d = this.scaleBoxSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
+ e[n].scaling.set(d, d, d);
+ } else
+ this.fixedDragMeshBoundsSize ? e[n].scaling.set(this.scaleBoxSize * this._boundingDimensions.x, this.scaleBoxSize * this._boundingDimensions.y, this.scaleBoxSize * this._boundingDimensions.z) : e[n].scaling.set(this.scaleBoxSize, this.scaleBoxSize, this.scaleBoxSize);
+ n++;
+ }
+ }
+ }, t.prototype.setEnabledRotationAxis = function(e) {
+ this._rotateSpheresParent.getChildMeshes().forEach(function(n, i) {
+ i < 4 ? n.setEnabled(e.indexOf("x") != -1) : i < 8 ? n.setEnabled(e.indexOf("y") != -1) : n.setEnabled(e.indexOf("z") != -1);
+ });
+ }, t.prototype.setEnabledScaling = function(e, n) {
+ n === void 0 && (n = !1), this._scaleBoxesParent.getChildMeshes().forEach(function(i, o) {
+ var a = e;
+ n && i.metadata === !0 && (a = !1), i.setEnabled(a);
+ });
+ }, t.prototype._updateDummy = function() {
+ this._dragMesh && (this._dragMesh.position.copyFrom(this._lineBoundingBox.getAbsolutePosition()), this._dragMesh.scaling.copyFrom(this._lineBoundingBox.scaling), this._dragMesh.rotationQuaternion.copyFrom(this._rootMesh.rotationQuaternion));
+ }, t.prototype.enableDragBehavior = function() {
+ this._dragMesh = Ie.a.CreateBox("dummy", 1, this.gizmoLayer.utilityLayerScene), this._dragMesh.visibility = 0, this._dragMesh.rotationQuaternion = new u.b(), this.pointerDragBehavior.useObjectOrientationForDragging = !1, this._dragMesh.addBehavior(this.pointerDragBehavior);
+ }, t.prototype.dispose = function() {
+ this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver), this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver), this._lineBoundingBox.dispose(), this._rotateSpheresParent.dispose(), this._scaleBoxesParent.dispose(), this._dragMesh && this._dragMesh.dispose(), r.prototype.dispose.call(this);
+ }, t.MakeNotPickableAndWrapInBoundingBox = function(e) {
+ var n = function(d) {
+ d.isPickable = !1, d.getChildMeshes().forEach(function(p) {
+ n(p);
+ });
+ };
+ n(e), e.rotationQuaternion || (e.rotationQuaternion = u.b.RotationYawPitchRoll(e.rotation.y, e.rotation.x, e.rotation.z));
+ var i = e.position.clone(), o = e.rotationQuaternion.clone();
+ e.rotationQuaternion.set(0, 0, 0, 1), e.position.set(0, 0, 0);
+ var a = fr.a.CreateBox("box", { size: 1 }, e.getScene()), s = e.getHierarchyBoundingVectors();
+ return s.max.subtractToRef(s.min, a.scaling), a.scaling.y === 0 && (a.scaling.y = Vt.a), a.scaling.x === 0 && (a.scaling.x = Vt.a), a.scaling.z === 0 && (a.scaling.z = Vt.a), a.position.set((s.max.x + s.min.x) / 2, (s.max.y + s.min.y) / 2, (s.max.z + s.min.z) / 2), e.addChild(a), e.rotationQuaternion.copyFrom(o), e.position.copyFrom(i), e.removeChild(a), a.addChild(e), a.visibility = 0, a;
+ }, t.prototype.setCustomMesh = function(e) {
+ l.a.Error("Custom meshes are not supported on this gizmo");
+ }, t;
+ }(Ln.a), Uo = function(r) {
+ function t(e, n, i, o, a, s, d) {
+ var p;
+ n === void 0 && (n = I.a.Gray()), i === void 0 && (i = Cn.a.DefaultUtilityLayer), o === void 0 && (o = 32), a === void 0 && (a = null), d === void 0 && (d = 1);
+ var y = r.call(this, i) || this;
+ y._pointerObserver = null, y.snapDistance = 0, y.onSnapObservable = new C.c(), y._isEnabled = !0, y._parent = null, y._dragging = !1, y._parent = a, y._coloredMaterial = new Nt.a("", i.utilityLayerScene), y._coloredMaterial.diffuseColor = n, y._coloredMaterial.specularColor = n.subtract(new I.a(0.1, 0.1, 0.1)), y._hoverMaterial = new Nt.a("", i.utilityLayerScene), y._hoverMaterial.diffuseColor = I.a.Yellow(), y._disableMaterial = new Nt.a("", i.utilityLayerScene), y._disableMaterial.diffuseColor = I.a.Gray(), y._disableMaterial.alpha = 0.4, y._gizmoMesh = new Ie.a("", i.utilityLayerScene);
+ var P = y._createGizmoMesh(y._gizmoMesh, d, o), R = P.rotationMesh, B = P.collider, F = [];
+ y._rotationCircle = y.setupRotationCircle(F, y._gizmoMesh), y._gizmoMesh.lookAt(y._rootMesh.position.add(e)), y._rootMesh.addChild(y._gizmoMesh), y._gizmoMesh.scaling.scaleInPlace(1 / 3), y.dragBehavior = new fi.a({ dragPlaneNormal: e }), y.dragBehavior.moveAttached = !1, y.dragBehavior.maxDragAngle = 9 * Math.PI / 20, y.dragBehavior._useAlternatePickedPointAboveMaxDragAngle = !0, y._rootMesh.addBehavior(y.dragBehavior);
+ var z = 0, J = new u.e(), ie = new u.e(), se = new u.a(), ce = new u.e(), ue = new u.e();
+ y.dragBehavior.onDragStartObservable.add(function(Se) {
+ if (y.attachedNode) {
+ J.copyFrom(Se.dragPlanePoint);
+ var De = new u.e(0, 0, 1), xe = y._rotationCircle.getDirection(De);
+ xe.normalize(), y._gizmoMesh.removeChild(y._rotationCircle), J.copyFrom(Se.dragPlanePoint), ie = Se.dragPlanePoint;
+ var Le = y._rotationCircle.getAbsolutePosition().clone(), Me = y._rotationCircle.getAbsolutePosition().clone().addInPlace(xe), we = Se.dragPlanePoint, Ye = u.e.GetAngleBetweenVectors(Me.subtract(Le), we.subtract(Le), y._rotationCircle.up);
+ y._rotationCircle.addRotation(0, Ye, 0), y._dragging = !0;
+ }
+ }), y.dragBehavior.onDragEndObservable.add(function() {
+ z = 0, y.updateRotationCircle(y._rotationCircle, F, z, ie), y._gizmoMesh.addChild(y._rotationCircle), y._dragging = !1;
+ });
+ var fe = { snapDistance: 0 }, ve = 0, Te = new u.a(), Re = new u.b();
+ y.dragBehavior.onDragObservable.add(function(Se) {
+ if (y.attachedNode) {
+ var De = new u.e(1, 1, 1), xe = new u.b(0, 0, 0, 1), Le = new u.e(0, 0, 0);
+ y.attachedNode.getWorldMatrix().decompose(De, xe, Le);
+ var Me = Se.dragPlanePoint.subtract(Le).normalize(), we = J.subtract(Le).normalize(), Ye = u.e.Cross(Me, we), et = u.e.Dot(Me, we), nt = Math.atan2(Ye.length(), et);
+ ce.copyFrom(e), ue.copyFrom(e), y.updateGizmoRotationToMatchAttachedMesh && (xe.toRotationMatrix(se), ue = u.e.TransformCoordinates(ce, se));
+ var ct = !1;
+ if (i.utilityLayerScene.activeCamera) {
+ var Ke = i.utilityLayerScene.activeCamera.position.subtract(Le);
+ u.e.Dot(Ke, ue) > 0 && (ce.scaleInPlace(-1), ue.scaleInPlace(-1), ct = !0);
+ }
+ u.e.Dot(ue, Ye) > 0 && (nt = -nt);
+ var rt = !1;
+ if (y.snapDistance != 0)
+ if (ve += nt, Math.abs(ve) > y.snapDistance) {
+ var it = Math.floor(Math.abs(ve) / y.snapDistance);
+ ve < 0 && (it *= -1), ve %= y.snapDistance, nt = y.snapDistance * it, rt = !0;
+ } else
+ nt = 0;
+ z += ct ? -nt : nt, y.updateRotationCircle(y._rotationCircle, F, z, ie);
+ var qe = Math.sin(nt / 2);
+ if (Re.set(ce.x * qe, ce.y * qe, ce.z * qe, Math.cos(nt / 2)), Te.determinant() > 0) {
+ var ut = new u.e();
+ Re.toEulerAnglesToRef(ut), u.b.RotationYawPitchRollToRef(ut.y, -ut.x, -ut.z, Re);
+ }
+ y.updateGizmoRotationToMatchAttachedMesh ? xe.multiplyToRef(Re, xe) : Re.multiplyToRef(xe, xe), y.attachedNode.getWorldMatrix().copyFrom(u.a.Compose(De, xe, Le)), J.copyFrom(Se.dragPlanePoint), rt && (fe.snapDistance = nt, y.onSnapObservable.notifyObservers(fe)), y._matrixChanged();
+ }
+ });
+ var Ae = i._getSharedGizmoLight();
+ Ae.includedOnlyMeshes = Ae.includedOnlyMeshes.concat(y._rootMesh.getChildMeshes(!1));
+ var Ee = { colliderMeshes: [B], gizmoMeshes: [R], material: y._coloredMaterial, hoverMaterial: y._hoverMaterial, disableMaterial: y._disableMaterial, active: !1 };
+ return (p = y._parent) === null || p === void 0 || p.addToAxisCache(y._gizmoMesh, Ee), y._pointerObserver = i.utilityLayerScene.onPointerObservable.add(function(Se) {
+ var De;
+ if (!y._customMeshSet && (y._isHovered = Ee.colliderMeshes.indexOf((De = Se == null ? void 0 : Se.pickInfo) === null || De === void 0 ? void 0 : De.pickedMesh) != -1, !y._parent)) {
+ var xe = y._isHovered || y._dragging ? y._hoverMaterial : y._coloredMaterial;
+ Ee.gizmoMeshes.forEach(function(Le) {
+ Le.material = xe, Le.color && (Le.color = xe.diffuseColor);
+ });
+ }
+ }), y;
+ }
+ return Object(c.d)(t, r), t.prototype._createGizmoMesh = function(e, n, i) {
+ var o = Ie.a.CreateTorus("ignore", 0.6, 0.03 * n, i, this.gizmoLayer.utilityLayerScene);
+ o.visibility = 0;
+ var a = Ie.a.CreateTorus("", 0.6, 5e-3 * n, i, this.gizmoLayer.utilityLayerScene);
+ return a.material = this._coloredMaterial, a.rotation.x = Math.PI / 2, o.rotation.x = Math.PI / 2, e.addChild(a), e.addChild(o), { rotationMesh: a, collider: o };
+ }, t.prototype._attachedNodeChanged = function(e) {
+ this.dragBehavior && (this.dragBehavior.enabled = !!e);
+ }, t.prototype.setupRotationCircle = function(e, n) {
+ for (var i = t._CircleConstants.pi2 / t._CircleConstants.tessellation, o = -Math.PI / 2; o < Math.PI / 2 - 1.5; o += i / 2) {
+ for (var a = [], s = 0; s < t._CircleConstants.pi2 * t._CircleConstants.rotationCircleRange + 0.01; s += i)
+ if (s < 0) {
+ var d = t._CircleConstants.radius * Math.sin(s) * Math.cos(o), p = t._CircleConstants.radius * Math.cos(s) * Math.cos(o);
+ a.push(new u.e(d, 0, p));
+ } else
+ a.push(new u.e(0, 0, 0));
+ e.push(a);
+ }
+ var y = new Nt.a("", this.gizmoLayer.utilityLayerScene);
+ y.diffuseColor = I.a.Yellow(), y.backFaceCulling = !1;
+ var P = Ie.a.CreateRibbon("rotationCircle", e, !1, !1, 0, this.gizmoLayer.utilityLayerScene, !0);
+ return P.material = y, P.material.alpha = 0.25, P.rotation.x = Math.PI / 2, n.addChild(P), P;
+ }, t.prototype.updateRotationPath = function(e, n) {
+ for (var i = t._CircleConstants.pi2 / t._CircleConstants.tessellation, o = 0, a = -Math.PI / 2; a < Math.PI / 2 - 1.5; a += i / 2) {
+ var s = e[o];
+ if (s)
+ for (var d = 0, p = 0; p < t._CircleConstants.pi2 * t._CircleConstants.rotationCircleRange + 0.01; p += i) {
+ if (s[d])
+ if (p < Math.abs(n)) {
+ var y = n > 0 ? p : -1 * p, P = n > 0 ? a : -1 * a;
+ s[d].set(t._CircleConstants.radius * Math.sin(y) * Math.cos(P), 0, t._CircleConstants.radius * Math.cos(y) * Math.cos(P));
+ } else
+ s[d].set(0, 0, 0);
+ d++;
+ }
+ o++;
+ }
+ }, t.prototype.updateRotationCircle = function(e, n, i, o) {
+ this.updateRotationPath(n, i), Ie.a.CreateRibbon("rotationCircle", n, !1, !1, 0, this.gizmoLayer.utilityLayerScene, void 0, void 0, e.geometry ? e : void 0);
+ }, Object.defineProperty(t.prototype, "isEnabled", { get: function() {
+ return this._isEnabled;
+ }, set: function(e) {
+ this._isEnabled = e, e ? this._parent && (this.attachedMesh = this._parent.attachedMesh) : this.attachedMesh = null;
+ }, enumerable: !1, configurable: !0 }), t.prototype.dispose = function() {
+ this.onSnapObservable.clear(), this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver), this.dragBehavior.detach(), this._gizmoMesh && this._gizmoMesh.dispose(), this._rotationCircle && this._rotationCircle.dispose(), [this._coloredMaterial, this._hoverMaterial, this._disableMaterial].forEach(function(e) {
+ e && e.dispose();
+ }), r.prototype.dispose.call(this);
+ }, t._CircleConstants = { radius: 0.3, pi2: 2 * Math.PI, tessellation: 70, rotationCircleRange: 4 }, t;
+ }(Ln.a), Yl = function(r) {
+ function t(e, n, i, o, a) {
+ e === void 0 && (e = Cn.a.DefaultUtilityLayer), n === void 0 && (n = 32), i === void 0 && (i = !1), o === void 0 && (o = 1);
+ var s = r.call(this, e) || this;
+ return s.onDragStartObservable = new C.c(), s.onDragEndObservable = new C.c(), s._observables = [], s._gizmoAxisCache = /* @__PURE__ */ new Map(), s.xGizmo = new Uo(new u.e(1, 0, 0), I.a.Red().scale(0.5), e, n, s, i, o), s.yGizmo = new Uo(new u.e(0, 1, 0), I.a.Green().scale(0.5), e, n, s, i, o), s.zGizmo = new Uo(new u.e(0, 0, 1), I.a.Blue().scale(0.5), e, n, s, i, o), [s.xGizmo, s.yGizmo, s.zGizmo].forEach(function(d) {
+ d.dragBehavior.onDragStartObservable.add(function() {
+ s.onDragStartObservable.notifyObservers({});
+ }), d.dragBehavior.onDragEndObservable.add(function() {
+ s.onDragEndObservable.notifyObservers({});
+ });
+ }), s.attachedMesh = null, s.attachedNode = null, a ? a.addToAxisCache(s._gizmoAxisCache) : Ln.a.GizmoAxisPointerObserver(e, s._gizmoAxisCache), s;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "attachedMesh", { get: function() {
+ return this._meshAttached;
+ }, set: function(e) {
+ this._meshAttached = e, this._nodeAttached = e, this._checkBillboardTransform(), [this.xGizmo, this.yGizmo, this.zGizmo].forEach(function(n) {
+ n.isEnabled ? n.attachedMesh = e : n.attachedMesh = null;
+ });
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "attachedNode", { get: function() {
+ return this._nodeAttached;
+ }, set: function(e) {
+ this._meshAttached = null, this._nodeAttached = e, this._checkBillboardTransform(), [this.xGizmo, this.yGizmo, this.zGizmo].forEach(function(n) {
+ n.isEnabled ? n.attachedNode = e : n.attachedNode = null;
+ });
+ }, enumerable: !1, configurable: !0 }), t.prototype._checkBillboardTransform = function() {
+ this._nodeAttached && this._nodeAttached.billboardMode && console.log("Rotation Gizmo will not work with transforms in billboard mode.");
+ }, Object.defineProperty(t.prototype, "isHovered", { get: function() {
+ var e = !1;
+ return [this.xGizmo, this.yGizmo, this.zGizmo].forEach(function(n) {
+ e = e || n.isHovered;
+ }), e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "updateGizmoRotationToMatchAttachedMesh", { get: function() {
+ return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
+ }, set: function(e) {
+ this.xGizmo && (this.xGizmo.updateGizmoRotationToMatchAttachedMesh = e, this.yGizmo.updateGizmoRotationToMatchAttachedMesh = e, this.zGizmo.updateGizmoRotationToMatchAttachedMesh = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "snapDistance", { get: function() {
+ return this.xGizmo.snapDistance;
+ }, set: function(e) {
+ this.xGizmo && (this.xGizmo.snapDistance = e, this.yGizmo.snapDistance = e, this.zGizmo.snapDistance = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "scaleRatio", { get: function() {
+ return this.xGizmo.scaleRatio;
+ }, set: function(e) {
+ this.xGizmo && (this.xGizmo.scaleRatio = e, this.yGizmo.scaleRatio = e, this.zGizmo.scaleRatio = e);
+ }, enumerable: !1, configurable: !0 }), t.prototype.addToAxisCache = function(e, n) {
+ this._gizmoAxisCache.set(e, n);
+ }, t.prototype.dispose = function() {
+ var e = this;
+ this.xGizmo.dispose(), this.yGizmo.dispose(), this.zGizmo.dispose(), this.onDragStartObservable.clear(), this.onDragEndObservable.clear(), this._observables.forEach(function(n) {
+ e.gizmoLayer.utilityLayerScene.onPointerObservable.remove(n);
+ });
+ }, t.prototype.setCustomMesh = function(e) {
+ l.a.Error("Custom meshes are not supported on this gizmo, please set the custom meshes on the gizmos contained within this one (gizmo.xGizmo, gizmo.yGizmo, gizmo.zGizmo)");
+ }, t;
+ }(Ln.a), pr = f(46), gs = f(84), Vo = function(r) {
+ function t(e, n, i, o) {
+ var a;
+ n === void 0 && (n = I.a.Gray()), i === void 0 && (i = Cn.a.DefaultUtilityLayer), o === void 0 && (o = null);
+ var s = r.call(this, i) || this;
+ s._pointerObserver = null, s.snapDistance = 0, s.onSnapObservable = new C.c(), s._isEnabled = !1, s._parent = null, s._dragging = !1, s._parent = o, s._coloredMaterial = new Nt.a("", i.utilityLayerScene), s._coloredMaterial.diffuseColor = n, s._coloredMaterial.specularColor = n.subtract(new I.a(0.1, 0.1, 0.1)), s._hoverMaterial = new Nt.a("", i.utilityLayerScene), s._hoverMaterial.diffuseColor = I.a.Yellow(), s._disableMaterial = new Nt.a("", i.utilityLayerScene), s._disableMaterial.diffuseColor = I.a.Gray(), s._disableMaterial.alpha = 0.4, s._gizmoMesh = t._CreatePlane(i.utilityLayerScene, s._coloredMaterial), s._gizmoMesh.lookAt(s._rootMesh.position.add(e)), s._gizmoMesh.scaling.scaleInPlace(1 / 3), s._gizmoMesh.parent = s._rootMesh;
+ var d = 0, p = new u.e(), y = { snapDistance: 0 };
+ s.dragBehavior = new fi.a({ dragPlaneNormal: e }), s.dragBehavior.moveAttached = !1, s._rootMesh.addBehavior(s.dragBehavior), s.dragBehavior.onDragObservable.add(function(B) {
+ if (s.attachedNode) {
+ if (s.snapDistance == 0)
+ s.attachedNode.getWorldMatrix().addTranslationFromFloats(B.delta.x, B.delta.y, B.delta.z);
+ else if (d += B.dragDistance, Math.abs(d) > s.snapDistance) {
+ var F = Math.floor(Math.abs(d) / s.snapDistance);
+ d %= s.snapDistance, B.delta.normalizeToRef(p), p.scaleInPlace(s.snapDistance * F), s.attachedNode.getWorldMatrix().addTranslationFromFloats(p.x, p.y, p.z), y.snapDistance = s.snapDistance * F, s.onSnapObservable.notifyObservers(y);
+ }
+ s._matrixChanged();
+ }
+ }), s.dragBehavior.onDragStartObservable.add(function() {
+ s._dragging = !0;
+ }), s.dragBehavior.onDragEndObservable.add(function() {
+ s._dragging = !1;
+ });
+ var P = i._getSharedGizmoLight();
+ P.includedOnlyMeshes = P.includedOnlyMeshes.concat(s._rootMesh.getChildMeshes(!1));
+ var R = { gizmoMeshes: s._gizmoMesh.getChildMeshes(), colliderMeshes: s._gizmoMesh.getChildMeshes(), material: s._coloredMaterial, hoverMaterial: s._hoverMaterial, disableMaterial: s._disableMaterial, active: !1 };
+ return (a = s._parent) === null || a === void 0 || a.addToAxisCache(s._gizmoMesh, R), s._pointerObserver = i.utilityLayerScene.onPointerObservable.add(function(B) {
+ var F;
+ if (!s._customMeshSet && (s._isHovered = R.colliderMeshes.indexOf((F = B == null ? void 0 : B.pickInfo) === null || F === void 0 ? void 0 : F.pickedMesh) != -1, !s._parent)) {
+ var z = s._isHovered || s._dragging ? s._hoverMaterial : s._coloredMaterial;
+ R.gizmoMeshes.forEach(function(J) {
+ J.material = z;
+ });
+ }
+ }), s;
+ }
+ return Object(c.d)(t, r), t._CreatePlane = function(e, n) {
+ var i = new pr.a("plane", e), o = gs.a.CreatePlane("dragPlane", { width: 0.1375, height: 0.1375, sideOrientation: 2 }, e);
+ return o.material = n, o.parent = i, i;
+ }, t.prototype._attachedNodeChanged = function(e) {
+ this.dragBehavior && (this.dragBehavior.enabled = !!e);
+ }, Object.defineProperty(t.prototype, "isEnabled", { get: function() {
+ return this._isEnabled;
+ }, set: function(e) {
+ this._isEnabled = e, e ? this._parent && (this.attachedNode = this._parent.attachedNode) : this.attachedNode = null;
+ }, enumerable: !1, configurable: !0 }), t.prototype.dispose = function() {
+ this.onSnapObservable.clear(), this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver), this.dragBehavior.detach(), r.prototype.dispose.call(this), this._gizmoMesh && this._gizmoMesh.dispose(), [this._coloredMaterial, this._hoverMaterial, this._disableMaterial].forEach(function(e) {
+ e && e.dispose();
+ });
+ }, t;
+ }(Ln.a), Kl = function(r) {
+ function t(e, n, i) {
+ e === void 0 && (e = Cn.a.DefaultUtilityLayer), n === void 0 && (n = 1);
+ var o = r.call(this, e) || this;
+ return o._meshAttached = null, o._nodeAttached = null, o._observables = [], o._gizmoAxisCache = /* @__PURE__ */ new Map(), o.onDragStartObservable = new C.c(), o.onDragEndObservable = new C.c(), o._planarGizmoEnabled = !1, o.xGizmo = new Bo.a(new u.e(1, 0, 0), I.a.Red().scale(0.5), e, o, n), o.yGizmo = new Bo.a(new u.e(0, 1, 0), I.a.Green().scale(0.5), e, o, n), o.zGizmo = new Bo.a(new u.e(0, 0, 1), I.a.Blue().scale(0.5), e, o, n), o.xPlaneGizmo = new Vo(new u.e(1, 0, 0), I.a.Red().scale(0.5), o.gizmoLayer, o), o.yPlaneGizmo = new Vo(new u.e(0, 1, 0), I.a.Green().scale(0.5), o.gizmoLayer, o), o.zPlaneGizmo = new Vo(new u.e(0, 0, 1), I.a.Blue().scale(0.5), o.gizmoLayer, o), [o.xGizmo, o.yGizmo, o.zGizmo, o.xPlaneGizmo, o.yPlaneGizmo, o.zPlaneGizmo].forEach(function(a) {
+ a.dragBehavior.onDragStartObservable.add(function() {
+ o.onDragStartObservable.notifyObservers({});
+ }), a.dragBehavior.onDragEndObservable.add(function() {
+ o.onDragEndObservable.notifyObservers({});
+ });
+ }), o.attachedMesh = null, i ? i.addToAxisCache(o._gizmoAxisCache) : Ln.a.GizmoAxisPointerObserver(e, o._gizmoAxisCache), o;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "attachedMesh", { get: function() {
+ return this._meshAttached;
+ }, set: function(e) {
+ this._meshAttached = e, this._nodeAttached = e, [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(n) {
+ n.isEnabled ? n.attachedMesh = e : n.attachedMesh = null;
+ });
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "attachedNode", { get: function() {
+ return this._nodeAttached;
+ }, set: function(e) {
+ this._meshAttached = null, this._nodeAttached = null, [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(n) {
+ n.isEnabled ? n.attachedNode = e : n.attachedNode = null;
+ });
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isHovered", { get: function() {
+ var e = !1;
+ return [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(n) {
+ e = e || n.isHovered;
+ }), e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "planarGizmoEnabled", { get: function() {
+ return this._planarGizmoEnabled;
+ }, set: function(e) {
+ var n = this;
+ this._planarGizmoEnabled = e, [this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(i) {
+ i && (i.isEnabled = e, e && (i.attachedMesh ? i.attachedMesh = n.attachedMesh : i.attachedNode = n.attachedNode));
+ }, this);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "updateGizmoRotationToMatchAttachedMesh", { get: function() {
+ return this._updateGizmoRotationToMatchAttachedMesh;
+ }, set: function(e) {
+ this._updateGizmoRotationToMatchAttachedMesh = e, [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(n) {
+ n && (n.updateGizmoRotationToMatchAttachedMesh = e);
+ });
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "snapDistance", { get: function() {
+ return this._snapDistance;
+ }, set: function(e) {
+ this._snapDistance = e, [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(n) {
+ n && (n.snapDistance = e);
+ });
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "scaleRatio", { get: function() {
+ return this._scaleRatio;
+ }, set: function(e) {
+ this._scaleRatio = e, [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(n) {
+ n && (n.scaleRatio = e);
+ });
+ }, enumerable: !1, configurable: !0 }), t.prototype.addToAxisCache = function(e, n) {
+ this._gizmoAxisCache.set(e, n);
+ }, t.prototype.dispose = function() {
+ var e = this;
+ [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(n) {
+ n && n.dispose();
+ }), this._observables.forEach(function(n) {
+ e.gizmoLayer.utilityLayerScene.onPointerObservable.remove(n);
+ }), this.onDragStartObservable.clear(), this.onDragEndObservable.clear();
+ }, t.prototype.setCustomMesh = function(e) {
+ l.a.Error("Custom meshes are not supported on this gizmo, please set the custom meshes on the gizmos contained within this one (gizmo.xGizmo, gizmo.yGizmo, gizmo.zGizmo,gizmo.xPlaneGizmo, gizmo.yPlaneGizmo, gizmo.zPlaneGizmo)");
+ }, t;
+ }(Ln.a);
+ ht.a.CreatePolyhedron = function(r) {
+ var t = [];
+ t[0] = { vertex: [[0, 0, 1.732051], [1.632993, 0, -0.5773503], [-0.8164966, 1.414214, -0.5773503], [-0.8164966, -1.414214, -0.5773503]], face: [[0, 1, 2], [0, 2, 3], [0, 3, 1], [1, 3, 2]] }, t[1] = { vertex: [[0, 0, 1.414214], [1.414214, 0, 0], [0, 1.414214, 0], [-1.414214, 0, 0], [0, -1.414214, 0], [0, 0, -1.414214]], face: [[0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 1], [1, 4, 5], [1, 5, 2], [2, 5, 3], [3, 5, 4]] }, t[2] = { vertex: [[0, 0, 1.070466], [0.7136442, 0, 0.7978784], [-0.3568221, 0.618034, 0.7978784], [-0.3568221, -0.618034, 0.7978784], [0.7978784, 0.618034, 0.3568221], [0.7978784, -0.618034, 0.3568221], [-0.9341724, 0.381966, 0.3568221], [0.1362939, 1, 0.3568221], [0.1362939, -1, 0.3568221], [-0.9341724, -0.381966, 0.3568221], [0.9341724, 0.381966, -0.3568221], [0.9341724, -0.381966, -0.3568221], [-0.7978784, 0.618034, -0.3568221], [-0.1362939, 1, -0.3568221], [-0.1362939, -1, -0.3568221], [-0.7978784, -0.618034, -0.3568221], [0.3568221, 0.618034, -0.7978784], [0.3568221, -0.618034, -0.7978784], [-0.7136442, 0, -0.7978784], [0, 0, -1.070466]], face: [[0, 1, 4, 7, 2], [0, 2, 6, 9, 3], [0, 3, 8, 5, 1], [1, 5, 11, 10, 4], [2, 7, 13, 12, 6], [3, 9, 15, 14, 8], [4, 10, 16, 13, 7], [5, 8, 14, 17, 11], [6, 12, 18, 15, 9], [10, 11, 17, 19, 16], [12, 13, 16, 19, 18], [14, 15, 18, 19, 17]] }, t[3] = { vertex: [[0, 0, 1.175571], [1.051462, 0, 0.5257311], [0.3249197, 1, 0.5257311], [-0.8506508, 0.618034, 0.5257311], [-0.8506508, -0.618034, 0.5257311], [0.3249197, -1, 0.5257311], [0.8506508, 0.618034, -0.5257311], [0.8506508, -0.618034, -0.5257311], [-0.3249197, 1, -0.5257311], [-1.051462, 0, -0.5257311], [-0.3249197, -1, -0.5257311], [0, 0, -1.175571]], face: [[0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 5], [0, 5, 1], [1, 5, 7], [1, 7, 6], [1, 6, 2], [2, 6, 8], [2, 8, 3], [3, 8, 9], [3, 9, 4], [4, 9, 10], [4, 10, 5], [5, 10, 7], [6, 7, 11], [6, 11, 8], [7, 10, 11], [8, 11, 9], [9, 11, 10]] }, t[4] = { vertex: [[0, 0, 1.070722], [0.7148135, 0, 0.7971752], [-0.104682, 0.7071068, 0.7971752], [-0.6841528, 0.2071068, 0.7971752], [-0.104682, -0.7071068, 0.7971752], [0.6101315, 0.7071068, 0.5236279], [1.04156, 0.2071068, 0.1367736], [0.6101315, -0.7071068, 0.5236279], [-0.3574067, 1, 0.1367736], [-0.7888348, -0.5, 0.5236279], [-0.9368776, 0.5, 0.1367736], [-0.3574067, -1, 0.1367736], [0.3574067, 1, -0.1367736], [0.9368776, -0.5, -0.1367736], [0.7888348, 0.5, -0.5236279], [0.3574067, -1, -0.1367736], [-0.6101315, 0.7071068, -0.5236279], [-1.04156, -0.2071068, -0.1367736], [-0.6101315, -0.7071068, -0.5236279], [0.104682, 0.7071068, -0.7971752], [0.6841528, -0.2071068, -0.7971752], [0.104682, -0.7071068, -0.7971752], [-0.7148135, 0, -0.7971752], [0, 0, -1.070722]], face: [[0, 2, 3], [1, 6, 5], [4, 9, 11], [7, 15, 13], [8, 16, 10], [12, 14, 19], [17, 22, 18], [20, 21, 23], [0, 1, 5, 2], [0, 3, 9, 4], [0, 4, 7, 1], [1, 7, 13, 6], [2, 5, 12, 8], [2, 8, 10, 3], [3, 10, 17, 9], [4, 11, 15, 7], [5, 6, 14, 12], [6, 13, 20, 14], [8, 12, 19, 16], [9, 17, 18, 11], [10, 16, 22, 17], [11, 18, 21, 15], [13, 15, 21, 20], [14, 20, 23, 19], [16, 19, 23, 22], [18, 22, 23, 21]] }, t[5] = { vertex: [[0, 0, 1.322876], [1.309307, 0, 0.1889822], [-0.9819805, 0.8660254, 0.1889822], [0.1636634, -1.299038, 0.1889822], [0.3273268, 0.8660254, -0.9449112], [-0.8183171, -0.4330127, -0.9449112]], face: [[0, 3, 1], [2, 4, 5], [0, 1, 4, 2], [0, 2, 5, 3], [1, 3, 5, 4]] }, t[6] = { vertex: [[0, 0, 1.159953], [1.013464, 0, 0.5642542], [-0.3501431, 0.9510565, 0.5642542], [-0.7715208, -0.6571639, 0.5642542], [0.6633206, 0.9510565, -0.03144481], [0.8682979, -0.6571639, -0.3996071], [-1.121664, 0.2938926, -0.03144481], [-0.2348831, -1.063314, -0.3996071], [0.5181548, 0.2938926, -0.9953061], [-0.5850262, -0.112257, -0.9953061]], face: [[0, 1, 4, 2], [0, 2, 6, 3], [1, 5, 8, 4], [3, 6, 9, 7], [5, 7, 9, 8], [0, 3, 7, 5, 1], [2, 4, 8, 9, 6]] }, t[7] = { vertex: [[0, 0, 1.118034], [0.8944272, 0, 0.6708204], [-0.2236068, 0.8660254, 0.6708204], [-0.7826238, -0.4330127, 0.6708204], [0.6708204, 0.8660254, 0.2236068], [1.006231, -0.4330127, -0.2236068], [-1.006231, 0.4330127, 0.2236068], [-0.6708204, -0.8660254, -0.2236068], [0.7826238, 0.4330127, -0.6708204], [0.2236068, -0.8660254, -0.6708204], [-0.8944272, 0, -0.6708204], [0, 0, -1.118034]], face: [[0, 1, 4, 2], [0, 2, 6, 3], [1, 5, 8, 4], [3, 6, 10, 7], [5, 9, 11, 8], [7, 10, 11, 9], [0, 3, 7, 9, 5, 1], [2, 4, 8, 11, 10, 6]] }, t[8] = { vertex: [[-0.729665, 0.670121, 0.319155], [-0.655235, -0.29213, -0.754096], [-0.093922, -0.607123, 0.537818], [0.702196, 0.595691, 0.485187], [0.776626, -0.36656, -0.588064]], face: [[1, 4, 2], [0, 1, 2], [3, 0, 2], [4, 3, 2], [4, 1, 0, 3]] }, t[9] = { vertex: [[-0.868849, -0.100041, 0.61257], [-0.329458, 0.976099, 0.28078], [-0.26629, -0.013796, -0.477654], [-0.13392, -1.034115, 0.229829], [0.738834, 0.707117, -0.307018], [0.859683, -0.535264, -0.338508]], face: [[3, 0, 2], [5, 3, 2], [4, 5, 2], [1, 4, 2], [0, 1, 2], [0, 3, 5, 4, 1]] }, t[10] = { vertex: [[-0.610389, 0.243975, 0.531213], [-0.187812, -0.48795, -0.664016], [-0.187812, 0.9759, -0.664016], [0.187812, -0.9759, 0.664016], [0.798201, 0.243975, 0.132803]], face: [[1, 3, 0], [3, 4, 0], [3, 1, 4], [0, 2, 1], [0, 4, 2], [2, 4, 1]] }, t[11] = { vertex: [[-1.028778, 0.392027, -0.048786], [-0.640503, -0.646161, 0.621837], [-0.125162, -0.395663, -0.540059], [4683e-6, 0.888447, -0.651988], [0.125161, 0.395663, 0.540059], [0.632925, -0.791376, 0.433102], [1.031672, 0.157063, -0.354165]], face: [[3, 2, 0], [2, 1, 0], [2, 5, 1], [0, 4, 3], [0, 1, 4], [4, 1, 5], [2, 3, 6], [3, 4, 6], [5, 2, 6], [4, 5, 6]] }, t[12] = { vertex: [[-0.669867, 0.334933, -0.529576], [-0.669867, 0.334933, 0.529577], [-0.4043, 1.212901, 0], [-0.334933, -0.669867, -0.529576], [-0.334933, -0.669867, 0.529577], [0.334933, 0.669867, -0.529576], [0.334933, 0.669867, 0.529577], [0.4043, -1.212901, 0], [0.669867, -0.334933, -0.529576], [0.669867, -0.334933, 0.529577]], face: [[8, 9, 7], [6, 5, 2], [3, 8, 7], [5, 0, 2], [4, 3, 7], [0, 1, 2], [9, 4, 7], [1, 6, 2], [9, 8, 5, 6], [8, 3, 0, 5], [3, 4, 1, 0], [4, 9, 6, 1]] }, t[13] = { vertex: [[-0.931836, 0.219976, -0.264632], [-0.636706, 0.318353, 0.692816], [-0.613483, -0.735083, -0.264632], [-0.326545, 0.979634, 0], [-0.318353, -0.636706, 0.692816], [-0.159176, 0.477529, -0.856368], [0.159176, -0.477529, -0.856368], [0.318353, 0.636706, 0.692816], [0.326545, -0.979634, 0], [0.613482, 0.735082, -0.264632], [0.636706, -0.318353, 0.692816], [0.931835, -0.219977, -0.264632]], face: [[11, 10, 8], [7, 9, 3], [6, 11, 8], [9, 5, 3], [2, 6, 8], [5, 0, 3], [4, 2, 8], [0, 1, 3], [10, 4, 8], [1, 7, 3], [10, 11, 9, 7], [11, 6, 5, 9], [6, 2, 0, 5], [2, 4, 1, 0], [4, 10, 7, 1]] }, t[14] = { vertex: [[-0.93465, 0.300459, -0.271185], [-0.838689, -0.260219, -0.516017], [-0.711319, 0.717591, 0.128359], [-0.710334, -0.156922, 0.080946], [-0.599799, 0.556003, -0.725148], [-0.503838, -4675e-6, -0.969981], [-0.487004, 0.26021, 0.48049], [-0.460089, -0.750282, -0.512622], [-0.376468, 0.973135, -0.325605], [-0.331735, -0.646985, 0.084342], [-0.254001, 0.831847, 0.530001], [-0.125239, -0.494738, -0.966586], [0.029622, 0.027949, 0.730817], [0.056536, -0.982543, -0.262295], [0.08085, 1.087391, 0.076037], [0.125583, -0.532729, 0.485984], [0.262625, 0.599586, 0.780328], [0.391387, -0.726999, -0.716259], [0.513854, -0.868287, 0.139347], [0.597475, 0.85513, 0.326364], [0.641224, 0.109523, 0.783723], [0.737185, -0.451155, 0.538891], [0.848705, -0.612742, -0.314616], [0.976075, 0.365067, 0.32976], [1.072036, -0.19561, 0.084927]], face: [[15, 18, 21], [12, 20, 16], [6, 10, 2], [3, 0, 1], [9, 7, 13], [2, 8, 4, 0], [0, 4, 5, 1], [1, 5, 11, 7], [7, 11, 17, 13], [13, 17, 22, 18], [18, 22, 24, 21], [21, 24, 23, 20], [20, 23, 19, 16], [16, 19, 14, 10], [10, 14, 8, 2], [15, 9, 13, 18], [12, 15, 21, 20], [6, 12, 16, 10], [3, 6, 2, 0], [9, 3, 1, 7], [9, 15, 12, 6, 3], [22, 17, 11, 5, 4, 8, 14, 19, 23, 24]] };
+ var e, n, i, o, a, s, d = r.type && (r.type < 0 || r.type >= t.length) ? 0 : r.type || 0, p = r.size, y = r.sizeX || p || 1, P = r.sizeY || p || 1, R = r.sizeZ || p || 1, B = r.custom || t[d], F = B.face.length, z = r.faceUV || new Array(F), J = r.faceColors, ie = r.flat === void 0 || r.flat, se = r.sideOrientation === 0 ? 0 : r.sideOrientation || ht.a.DEFAULTSIDE, ce = new Array(), ue = new Array(), fe = new Array(), ve = new Array(), Te = new Array(), Re = 0, Ae = 0, Ee = new Array(), Se = 0, De = 0;
+ if (ie)
+ for (De = 0; De < F; De++)
+ J && J[De] === void 0 && (J[De] = new I.b(1, 1, 1, 1)), z && z[De] === void 0 && (z[De] = new u.f(0, 0, 1, 1));
+ if (ie)
+ for (De = 0; De < F; De++) {
+ var xe = B.face[De].length;
+ for (i = 2 * Math.PI / xe, o = 0.5 * Math.tan(i / 2), a = 0.5, Se = 0; Se < xe; Se++)
+ ce.push(B.vertex[B.face[De][Se]][0] * y, B.vertex[B.face[De][Se]][1] * P, B.vertex[B.face[De][Se]][2] * R), Ee.push(Re), Re++, e = z[De].x + (z[De].z - z[De].x) * (0.5 + o), n = z[De].y + (z[De].w - z[De].y) * (a - 0.5), ve.push(e, n), s = o * Math.cos(i) - a * Math.sin(i), a = o * Math.sin(i) + a * Math.cos(i), o = s, J && Te.push(J[De].r, J[De].g, J[De].b, J[De].a);
+ for (Se = 0; Se < xe - 2; Se++)
+ ue.push(Ee[0 + Ae], Ee[Se + 2 + Ae], Ee[Se + 1 + Ae]);
+ Ae += xe;
+ }
+ else {
+ for (Se = 0; Se < B.vertex.length; Se++)
+ ce.push(B.vertex[Se][0] * y, B.vertex[Se][1] * P, B.vertex[Se][2] * R), ve.push(0, 0);
+ for (De = 0; De < F; De++)
+ for (Se = 0; Se < B.face[De].length - 2; Se++)
+ ue.push(B.face[De][0], B.face[De][Se + 2], B.face[De][Se + 1]);
+ }
+ ht.a.ComputeNormals(ce, ue, fe), ht.a._ComputeSides(se, ce, ue, fe, ve, r.frontUVs, r.backUVs);
+ var Le = new ht.a();
+ return Le.positions = ce, Le.indices = ue, Le.normals = fe, Le.uvs = ve, J && ie && (Le.colors = Te), Le;
+ }, Ie.a.CreatePolyhedron = function(r, t, e) {
+ return Qr.CreatePolyhedron(r, t, e);
+ };
+ var Qr = function() {
+ function r() {
+ }
+ return r.CreatePolyhedron = function(t, e, n) {
+ n === void 0 && (n = null);
+ var i = new Ie.a(t, n);
+ return e.sideOrientation = Ie.a._GetDefaultSideOrientation(e.sideOrientation), i._originalBuilderSideOrientation = e.sideOrientation, ht.a.CreatePolyhedron(e).applyToMesh(i, e.updatable), i;
+ }, r;
+ }(), Ql = function(r) {
+ function t(e, n, i) {
+ e === void 0 && (e = Cn.a.DefaultUtilityLayer), n === void 0 && (n = 1);
+ var o = r.call(this, e) || this;
+ return o._meshAttached = null, o._nodeAttached = null, o._sensitivity = 1, o._observables = [], o._gizmoAxisCache = /* @__PURE__ */ new Map(), o.onDragStartObservable = new C.c(), o.onDragEndObservable = new C.c(), o.uniformScaleGizmo = o._createUniformScaleMesh(), o.xGizmo = new Kr(new u.e(1, 0, 0), I.a.Red().scale(0.5), e, o, n), o.yGizmo = new Kr(new u.e(0, 1, 0), I.a.Green().scale(0.5), e, o, n), o.zGizmo = new Kr(new u.e(0, 0, 1), I.a.Blue().scale(0.5), e, o, n), [o.xGizmo, o.yGizmo, o.zGizmo, o.uniformScaleGizmo].forEach(function(a) {
+ a.dragBehavior.onDragStartObservable.add(function() {
+ o.onDragStartObservable.notifyObservers({});
+ }), a.dragBehavior.onDragEndObservable.add(function() {
+ o.onDragEndObservable.notifyObservers({});
+ });
+ }), o.attachedMesh = null, o.attachedNode = null, i ? i.addToAxisCache(o._gizmoAxisCache) : Ln.a.GizmoAxisPointerObserver(e, o._gizmoAxisCache), o;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "attachedMesh", { get: function() {
+ return this._meshAttached;
+ }, set: function(e) {
+ this._meshAttached = e, this._nodeAttached = e, [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function(n) {
+ n.isEnabled ? n.attachedMesh = e : n.attachedMesh = null;
+ });
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "attachedNode", { get: function() {
+ return this._nodeAttached;
+ }, set: function(e) {
+ this._meshAttached = null, this._nodeAttached = e, [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function(n) {
+ n.isEnabled ? n.attachedNode = e : n.attachedNode = null;
+ });
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isHovered", { get: function() {
+ var e = !1;
+ return [this.xGizmo, this.yGizmo, this.zGizmo].forEach(function(n) {
+ e = e || n.isHovered;
+ }), e;
+ }, enumerable: !1, configurable: !0 }), t.prototype._createUniformScaleMesh = function() {
+ this._coloredMaterial = new Nt.a("", this.gizmoLayer.utilityLayerScene), this._coloredMaterial.diffuseColor = I.a.Gray(), this._hoverMaterial = new Nt.a("", this.gizmoLayer.utilityLayerScene), this._hoverMaterial.diffuseColor = I.a.Yellow(), this._disableMaterial = new Nt.a("", this.gizmoLayer.utilityLayerScene), this._disableMaterial.diffuseColor = I.a.Gray(), this._disableMaterial.alpha = 0.4;
+ var e = new Kr(new u.e(0, 1, 0), I.a.Gray().scale(0.5), this.gizmoLayer, this);
+ e.updateGizmoRotationToMatchAttachedMesh = !1, e.uniformScaling = !0, this._uniformScalingMesh = Qr.CreatePolyhedron("uniform", { type: 1 }, e.gizmoLayer.utilityLayerScene), this._uniformScalingMesh.scaling.scaleInPlace(0.01), this._uniformScalingMesh.visibility = 0, this._octahedron = Qr.CreatePolyhedron("", { type: 1 }, e.gizmoLayer.utilityLayerScene), this._octahedron.scaling.scaleInPlace(7e-3), this._uniformScalingMesh.addChild(this._octahedron), e.setCustomMesh(this._uniformScalingMesh, !0);
+ var n = this.gizmoLayer._getSharedGizmoLight();
+ n.includedOnlyMeshes = n.includedOnlyMeshes.concat(this._octahedron);
+ var i = { gizmoMeshes: [this._octahedron, this._uniformScalingMesh], colliderMeshes: [this._uniformScalingMesh], material: this._coloredMaterial, hoverMaterial: this._hoverMaterial, disableMaterial: this._disableMaterial, active: !1 };
+ return this.addToAxisCache(e._rootMesh, i), e;
+ }, Object.defineProperty(t.prototype, "updateGizmoRotationToMatchAttachedMesh", { get: function() {
+ return this._updateGizmoRotationToMatchAttachedMesh;
+ }, set: function(e) {
+ e ? (this._updateGizmoRotationToMatchAttachedMesh = e, [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function(n) {
+ n && (n.updateGizmoRotationToMatchAttachedMesh = e);
+ })) : l.a.Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported.");
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "snapDistance", { get: function() {
+ return this._snapDistance;
+ }, set: function(e) {
+ this._snapDistance = e, [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function(n) {
+ n && (n.snapDistance = e);
+ });
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "scaleRatio", { get: function() {
+ return this._scaleRatio;
+ }, set: function(e) {
+ this._scaleRatio = e, [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function(n) {
+ n && (n.scaleRatio = e);
+ });
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "sensitivity", { get: function() {
+ return this._sensitivity;
+ }, set: function(e) {
+ this._sensitivity = e, [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function(n) {
+ n && (n.sensitivity = e);
+ });
+ }, enumerable: !1, configurable: !0 }), t.prototype.addToAxisCache = function(e, n) {
+ this._gizmoAxisCache.set(e, n);
+ }, t.prototype.dispose = function() {
+ var e = this;
+ [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function(n) {
+ n && n.dispose();
+ }), this._observables.forEach(function(n) {
+ e.gizmoLayer.utilityLayerScene.onPointerObservable.remove(n);
+ }), this.onDragStartObservable.clear(), this.onDragEndObservable.clear(), [this._uniformScalingMesh, this._octahedron].forEach(function(n) {
+ n && n.dispose();
+ }), [this._coloredMaterial, this._hoverMaterial, this._disableMaterial].forEach(function(n) {
+ n && n.dispose();
+ });
+ }, t;
+ }(Ln.a), Hf = function() {
+ function r(t, e, n, i) {
+ e === void 0 && (e = 1), n === void 0 && (n = Cn.a.DefaultUtilityLayer), i === void 0 && (i = Cn.a.DefaultKeepDepthUtilityLayer), this.scene = t, this.clearGizmoOnEmptyPointerEvent = !1, this.onAttachedToMeshObservable = new C.c(), this.onAttachedToNodeObservable = new C.c(), this._gizmosEnabled = { positionGizmo: !1, rotationGizmo: !1, scaleGizmo: !1, boundingBoxGizmo: !1 }, this._pointerObservers = [], this._attachedMesh = null, this._attachedNode = null, this._boundingBoxColor = I.a.FromHexString("#0984e3"), this._thickness = 1, this._gizmoAxisCache = /* @__PURE__ */ new Map(), this.boundingBoxDragBehavior = new Jc(), this.attachableMeshes = null, this.attachableNodes = null, this.usePointerToAttachGizmos = !0, this._defaultUtilityLayer = n, this._defaultKeepDepthUtilityLayer = i, this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = !1, this._thickness = e, this.gizmos = { positionGizmo: null, rotationGizmo: null, scaleGizmo: null, boundingBoxGizmo: null };
+ var o = this._attachToMeshPointerObserver(t), a = Ln.a.GizmoAxisPointerObserver(this._defaultUtilityLayer, this._gizmoAxisCache);
+ this._pointerObservers = [o, a];
+ }
+ return Object.defineProperty(r.prototype, "keepDepthUtilityLayer", { get: function() {
+ return this._defaultKeepDepthUtilityLayer;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "utilityLayer", { get: function() {
+ return this._defaultUtilityLayer;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "isHovered", { get: function() {
+ var t = !1;
+ for (var e in this.gizmos) {
+ var n = this.gizmos[e];
+ if (n && n.isHovered) {
+ t = !0;
+ break;
+ }
+ }
+ return t;
+ }, enumerable: !1, configurable: !0 }), r.prototype._attachToMeshPointerObserver = function(t) {
+ var e = this;
+ return t.onPointerObservable.add(function(n) {
+ if (e.usePointerToAttachGizmos && n.type == yt.a.POINTERDOWN)
+ if (n.pickInfo && n.pickInfo.pickedMesh) {
+ var i = n.pickInfo.pickedMesh;
+ if (e.attachableMeshes == null)
+ for (; i && i.parent != null; )
+ i = i.parent;
+ else {
+ var o = !1;
+ e.attachableMeshes.forEach(function(a) {
+ i && (i == a || i.isDescendantOf(a)) && (i = a, o = !0);
+ }), o || (i = null);
+ }
+ i instanceof Mt.a ? e._attachedMesh != i && e.attachToMesh(i) : e.clearGizmoOnEmptyPointerEvent && e.attachToMesh(null);
+ } else
+ e.clearGizmoOnEmptyPointerEvent && e.attachToMesh(null);
+ });
+ }, r.prototype.attachToMesh = function(t) {
+ for (var e in this._attachedMesh && this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior), this._attachedNode && this._attachedNode.removeBehavior(this.boundingBoxDragBehavior), this._attachedMesh = t, this._attachedNode = null, this.gizmos) {
+ var n = this.gizmos[e];
+ n && this._gizmosEnabled[e] && (n.attachedMesh = t);
+ }
+ this.boundingBoxGizmoEnabled && this._attachedMesh && this._attachedMesh.addBehavior(this.boundingBoxDragBehavior), this.onAttachedToMeshObservable.notifyObservers(t);
+ }, r.prototype.attachToNode = function(t) {
+ for (var e in this._attachedMesh && this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior), this._attachedNode && this._attachedNode.removeBehavior(this.boundingBoxDragBehavior), this._attachedMesh = null, this._attachedNode = t, this.gizmos) {
+ var n = this.gizmos[e];
+ n && this._gizmosEnabled[e] && (n.attachedNode = t);
+ }
+ this.boundingBoxGizmoEnabled && this._attachedNode && this._attachedNode.addBehavior(this.boundingBoxDragBehavior), this.onAttachedToNodeObservable.notifyObservers(t);
+ }, Object.defineProperty(r.prototype, "positionGizmoEnabled", { get: function() {
+ return this._gizmosEnabled.positionGizmo;
+ }, set: function(t) {
+ t ? (this.gizmos.positionGizmo || (this.gizmos.positionGizmo = new Kl(this._defaultUtilityLayer, this._thickness, this)), this._attachedNode ? this.gizmos.positionGizmo.attachedNode = this._attachedNode : this.gizmos.positionGizmo.attachedMesh = this._attachedMesh) : this.gizmos.positionGizmo && (this.gizmos.positionGizmo.attachedNode = null), this._gizmosEnabled.positionGizmo = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "rotationGizmoEnabled", { get: function() {
+ return this._gizmosEnabled.rotationGizmo;
+ }, set: function(t) {
+ t ? (this.gizmos.rotationGizmo || (this.gizmos.rotationGizmo = new Yl(this._defaultUtilityLayer, 32, !1, this._thickness, this)), this._attachedNode ? this.gizmos.rotationGizmo.attachedNode = this._attachedNode : this.gizmos.rotationGizmo.attachedMesh = this._attachedMesh) : this.gizmos.rotationGizmo && (this.gizmos.rotationGizmo.attachedNode = null), this._gizmosEnabled.rotationGizmo = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "scaleGizmoEnabled", { get: function() {
+ return this._gizmosEnabled.scaleGizmo;
+ }, set: function(t) {
+ t ? (this.gizmos.scaleGizmo = this.gizmos.scaleGizmo || new Ql(this._defaultUtilityLayer, this._thickness, this), this._attachedNode ? this.gizmos.scaleGizmo.attachedNode = this._attachedNode : this.gizmos.scaleGizmo.attachedMesh = this._attachedMesh) : this.gizmos.scaleGizmo && (this.gizmos.scaleGizmo.attachedNode = null), this._gizmosEnabled.scaleGizmo = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "boundingBoxGizmoEnabled", { get: function() {
+ return this._gizmosEnabled.boundingBoxGizmo;
+ }, set: function(t) {
+ t ? (this.gizmos.boundingBoxGizmo = this.gizmos.boundingBoxGizmo || new Xl(this._boundingBoxColor, this._defaultKeepDepthUtilityLayer), this._attachedMesh ? this.gizmos.boundingBoxGizmo.attachedMesh = this._attachedMesh : this.gizmos.boundingBoxGizmo.attachedNode = this._attachedNode, this._attachedMesh ? (this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior), this._attachedMesh.addBehavior(this.boundingBoxDragBehavior)) : this._attachedNode && (this._attachedNode.removeBehavior(this.boundingBoxDragBehavior), this._attachedNode.addBehavior(this.boundingBoxDragBehavior))) : this.gizmos.boundingBoxGizmo && (this._attachedMesh ? this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior) : this._attachedNode && this._attachedNode.removeBehavior(this.boundingBoxDragBehavior), this.gizmos.boundingBoxGizmo.attachedNode = null), this._gizmosEnabled.boundingBoxGizmo = t;
+ }, enumerable: !1, configurable: !0 }), r.prototype.addToAxisCache = function(t) {
+ var e = this;
+ t.size > 0 && t.forEach(function(n, i) {
+ e._gizmoAxisCache.set(i, n);
+ });
+ }, r.prototype.dispose = function() {
+ var t = this;
+ for (var e in this._pointerObservers.forEach(function(i) {
+ t.scene.onPointerObservable.remove(i);
+ }), this.gizmos) {
+ var n = this.gizmos[e];
+ n && n.dispose();
+ }
+ this._defaultKeepDepthUtilityLayer.dispose(), this._defaultUtilityLayer.dispose(), this.boundingBoxDragBehavior.detach(), this.onAttachedToMeshObservable.clear();
+ }, r;
+ }(), bi = f(48), ko = function(r) {
+ function t() {
+ var e = r !== null && r.apply(this, arguments) || this;
+ return e._needProjectionMatrixCompute = !0, e;
+ }
+ return Object(c.d)(t, r), t.prototype._setPosition = function(e) {
+ this._position = e;
+ }, Object.defineProperty(t.prototype, "position", { get: function() {
+ return this._position;
+ }, set: function(e) {
+ this._setPosition(e);
+ }, enumerable: !1, configurable: !0 }), t.prototype._setDirection = function(e) {
+ this._direction = e;
+ }, Object.defineProperty(t.prototype, "direction", { get: function() {
+ return this._direction;
+ }, set: function(e) {
+ this._setDirection(e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "shadowMinZ", { get: function() {
+ return this._shadowMinZ;
+ }, set: function(e) {
+ this._shadowMinZ = e, this.forceProjectionMatrixCompute();
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "shadowMaxZ", { get: function() {
+ return this._shadowMaxZ;
+ }, set: function(e) {
+ this._shadowMaxZ = e, this.forceProjectionMatrixCompute();
+ }, enumerable: !1, configurable: !0 }), t.prototype.computeTransformedInformation = function() {
+ return !(!this.parent || !this.parent.getWorldMatrix) && (this.transformedPosition || (this.transformedPosition = u.e.Zero()), u.e.TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition), this.direction && (this.transformedDirection || (this.transformedDirection = u.e.Zero()), u.e.TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this.transformedDirection)), !0);
+ }, t.prototype.getDepthScale = function() {
+ return 50;
+ }, t.prototype.getShadowDirection = function(e) {
+ return this.transformedDirection ? this.transformedDirection : this.direction;
+ }, t.prototype.getAbsolutePosition = function() {
+ return this.transformedPosition ? this.transformedPosition : this.position;
+ }, t.prototype.setDirectionToTarget = function(e) {
+ return this.direction = u.e.Normalize(e.subtract(this.position)), this.direction;
+ }, t.prototype.getRotation = function() {
+ this.direction.normalize();
+ var e = u.e.Cross(this.direction, be.a.Y), n = u.e.Cross(e, this.direction);
+ return u.e.RotationFromAxis(e, n, this.direction);
+ }, t.prototype.needCube = function() {
+ return !1;
+ }, t.prototype.needProjectionMatrixCompute = function() {
+ return this._needProjectionMatrixCompute;
+ }, t.prototype.forceProjectionMatrixCompute = function() {
+ this._needProjectionMatrixCompute = !0;
+ }, t.prototype._initCache = function() {
+ r.prototype._initCache.call(this), this._cache.position = u.e.Zero();
+ }, t.prototype._isSynchronized = function() {
+ return !!this._cache.position.equals(this.position);
+ }, t.prototype.computeWorldMatrix = function(e) {
+ return !e && this.isSynchronized() ? (this._currentRenderId = this.getScene().getRenderId(), this._worldMatrix) : (this._updateCache(), this._cache.position.copyFrom(this.position), this._worldMatrix || (this._worldMatrix = u.a.Identity()), u.a.TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix), this.parent && this.parent.getWorldMatrix && (this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix), this._markSyncedWithParent()), this._worldMatrixDeterminantIsDirty = !0, this._worldMatrix);
+ }, t.prototype.getDepthMinZ = function(e) {
+ return this.shadowMinZ !== void 0 ? this.shadowMinZ : e.minZ;
+ }, t.prototype.getDepthMaxZ = function(e) {
+ return this.shadowMaxZ !== void 0 ? this.shadowMaxZ : e.maxZ;
+ }, t.prototype.setShadowProjectionMatrix = function(e, n, i) {
+ return this.customProjectionMatrixBuilder ? this.customProjectionMatrixBuilder(n, i, e) : this._setDefaultShadowProjectionMatrix(e, n, i), this;
+ }, Object(c.c)([Object(L.o)()], t.prototype, "position", null), Object(c.c)([Object(L.o)()], t.prototype, "direction", null), Object(c.c)([Object(L.c)()], t.prototype, "shadowMinZ", null), Object(c.c)([Object(L.c)()], t.prototype, "shadowMaxZ", null), t;
+ }(bi.a);
+ Q.a.AddNodeConstructor("Light_Type_1", function(r, t) {
+ return function() {
+ return new vs(r, u.e.Zero(), t);
+ };
+ });
+ var vs = function(r) {
+ function t(e, n, i) {
+ var o = r.call(this, e, i) || this;
+ return o._shadowFrustumSize = 0, o._shadowOrthoScale = 0.1, o.autoUpdateExtends = !0, o.autoCalcShadowZBounds = !1, o._orthoLeft = Number.MAX_VALUE, o._orthoRight = Number.MIN_VALUE, o._orthoTop = Number.MIN_VALUE, o._orthoBottom = Number.MAX_VALUE, o.position = n.scale(-1), o.direction = n, o;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "shadowFrustumSize", { get: function() {
+ return this._shadowFrustumSize;
+ }, set: function(e) {
+ this._shadowFrustumSize = e, this.forceProjectionMatrixCompute();
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "shadowOrthoScale", { get: function() {
+ return this._shadowOrthoScale;
+ }, set: function(e) {
+ this._shadowOrthoScale = e, this.forceProjectionMatrixCompute();
+ }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
+ return "DirectionalLight";
+ }, t.prototype.getTypeID = function() {
+ return bi.a.LIGHTTYPEID_DIRECTIONALLIGHT;
+ }, t.prototype._setDefaultShadowProjectionMatrix = function(e, n, i) {
+ this.shadowFrustumSize > 0 ? this._setDefaultFixedFrustumShadowProjectionMatrix(e) : this._setDefaultAutoExtendShadowProjectionMatrix(e, n, i);
+ }, t.prototype._setDefaultFixedFrustumShadowProjectionMatrix = function(e) {
+ var n = this.getScene().activeCamera;
+ n && u.a.OrthoLHToRef(this.shadowFrustumSize, this.shadowFrustumSize, this.shadowMinZ !== void 0 ? this.shadowMinZ : n.minZ, this.shadowMaxZ !== void 0 ? this.shadowMaxZ : n.maxZ, e);
+ }, t.prototype._setDefaultAutoExtendShadowProjectionMatrix = function(e, n, i) {
+ var o = this.getScene().activeCamera;
+ if (o) {
+ if (this.autoUpdateExtends || this._orthoLeft === Number.MAX_VALUE) {
+ var a = u.e.Zero();
+ this._orthoLeft = Number.MAX_VALUE, this._orthoRight = Number.MIN_VALUE, this._orthoTop = Number.MIN_VALUE, this._orthoBottom = Number.MAX_VALUE;
+ for (var s = Number.MAX_VALUE, d = Number.MIN_VALUE, p = 0; p < i.length; p++) {
+ var y = i[p];
+ if (y)
+ for (var P = y.getBoundingInfo().boundingBox, R = 0; R < P.vectorsWorld.length; R++)
+ u.e.TransformCoordinatesToRef(P.vectorsWorld[R], n, a), a.x < this._orthoLeft && (this._orthoLeft = a.x), a.y < this._orthoBottom && (this._orthoBottom = a.y), a.x > this._orthoRight && (this._orthoRight = a.x), a.y > this._orthoTop && (this._orthoTop = a.y), this.autoCalcShadowZBounds && (a.z < s && (s = a.z), a.z > d && (d = a.z));
+ }
+ this.autoCalcShadowZBounds && (this._shadowMinZ = s, this._shadowMaxZ = d);
+ }
+ var B = this._orthoRight - this._orthoLeft, F = this._orthoTop - this._orthoBottom;
+ u.a.OrthoOffCenterLHToRef(this._orthoLeft - B * this.shadowOrthoScale, this._orthoRight + B * this.shadowOrthoScale, this._orthoBottom - F * this.shadowOrthoScale, this._orthoTop + F * this.shadowOrthoScale, this.shadowMinZ !== void 0 ? this.shadowMinZ : o.minZ, this.shadowMaxZ !== void 0 ? this.shadowMaxZ : o.maxZ, e);
+ }
+ }, t.prototype._buildUniformLayout = function() {
+ this._uniformBuffer.addUniform("vLightData", 4), this._uniformBuffer.addUniform("vLightDiffuse", 4), this._uniformBuffer.addUniform("vLightSpecular", 4), this._uniformBuffer.addUniform("shadowsInfo", 3), this._uniformBuffer.addUniform("depthValues", 2), this._uniformBuffer.create();
+ }, t.prototype.transferToEffect = function(e, n) {
+ return this.computeTransformedInformation() ? (this._uniformBuffer.updateFloat4("vLightData", this.transformedDirection.x, this.transformedDirection.y, this.transformedDirection.z, 1, n), this) : (this._uniformBuffer.updateFloat4("vLightData", this.direction.x, this.direction.y, this.direction.z, 1, n), this);
+ }, t.prototype.transferToNodeMaterialEffect = function(e, n) {
+ return this.computeTransformedInformation() ? (e.setFloat3(n, this.transformedDirection.x, this.transformedDirection.y, this.transformedDirection.z), this) : (e.setFloat3(n, this.direction.x, this.direction.y, this.direction.z), this);
+ }, t.prototype.getDepthMinZ = function(e) {
+ return 1;
+ }, t.prototype.getDepthMaxZ = function(e) {
+ return 1;
+ }, t.prototype.prepareLightSpecificDefines = function(e, n) {
+ e["DIRLIGHT" + n] = !0;
+ }, Object(c.c)([Object(L.c)()], t.prototype, "shadowFrustumSize", null), Object(c.c)([Object(L.c)()], t.prototype, "shadowOrthoScale", null), Object(c.c)([Object(L.c)()], t.prototype, "autoUpdateExtends", void 0), Object(c.c)([Object(L.c)()], t.prototype, "autoCalcShadowZBounds", void 0), t;
+ }(ko);
+ Ie.a.CreateHemisphere = function(r, t, e, n) {
+ var i = { segments: t, diameter: e };
+ return Go.CreateHemisphere(r, i, n);
+ };
+ var Go = function() {
+ function r() {
+ }
+ return r.CreateHemisphere = function(t, e, n) {
+ e.diameter || (e.diameter = 1), e.segments || (e.segments = 16);
+ var i = Nn.a.CreateSphere("", { slice: 0.5, diameter: e.diameter, segments: e.segments }, n), o = Ie.a.CreateDisc("", e.diameter / 2, 3 * e.segments + (4 - e.segments), n);
+ o.rotation.x = -Math.PI / 2, o.parent = i;
+ var a = Ie.a.MergeMeshes([o, i], !0);
+ return a.name = t, a;
+ }, r;
+ }();
+ Q.a.AddNodeConstructor("Light_Type_2", function(r, t) {
+ return function() {
+ return new ys(r, u.e.Zero(), u.e.Zero(), 0, 0, t);
+ };
+ });
+ var ys = function(r) {
+ function t(e, n, i, o, a, s) {
+ var d = r.call(this, e, s) || this;
+ return d._innerAngle = 0, d._projectionTextureMatrix = u.a.Zero(), d._projectionTextureLightNear = 1e-6, d._projectionTextureLightFar = 1e3, d._projectionTextureUpDirection = u.e.Up(), d._projectionTextureViewLightDirty = !0, d._projectionTextureProjectionLightDirty = !0, d._projectionTextureDirty = !0, d._projectionTextureViewTargetVector = u.e.Zero(), d._projectionTextureViewLightMatrix = u.a.Zero(), d._projectionTextureProjectionLightMatrix = u.a.Zero(), d._projectionTextureScalingMatrix = u.a.FromValues(0.5, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 0.5, 0, 0.5, 0.5, 0.5, 1), d.position = n, d.direction = i, d.angle = o, d.exponent = a, d;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "angle", { get: function() {
+ return this._angle;
+ }, set: function(e) {
+ this._angle = e, this._cosHalfAngle = Math.cos(0.5 * e), this._projectionTextureProjectionLightDirty = !0, this.forceProjectionMatrixCompute(), this._computeAngleValues();
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "innerAngle", { get: function() {
+ return this._innerAngle;
+ }, set: function(e) {
+ this._innerAngle = e, this._computeAngleValues();
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "shadowAngleScale", { get: function() {
+ return this._shadowAngleScale;
+ }, set: function(e) {
+ this._shadowAngleScale = e, this.forceProjectionMatrixCompute();
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "projectionTextureMatrix", { get: function() {
+ return this._projectionTextureMatrix;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "projectionTextureLightNear", { get: function() {
+ return this._projectionTextureLightNear;
+ }, set: function(e) {
+ this._projectionTextureLightNear = e, this._projectionTextureProjectionLightDirty = !0;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "projectionTextureLightFar", { get: function() {
+ return this._projectionTextureLightFar;
+ }, set: function(e) {
+ this._projectionTextureLightFar = e, this._projectionTextureProjectionLightDirty = !0;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "projectionTextureUpDirection", { get: function() {
+ return this._projectionTextureUpDirection;
+ }, set: function(e) {
+ this._projectionTextureUpDirection = e, this._projectionTextureProjectionLightDirty = !0;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "projectionTexture", { get: function() {
+ return this._projectionTexture;
+ }, set: function(e) {
+ var n = this;
+ this._projectionTexture !== e && (this._projectionTexture = e, this._projectionTextureDirty = !0, this._projectionTexture && !this._projectionTexture.isReady() && (t._IsProceduralTexture(this._projectionTexture) ? this._projectionTexture.getEffect().executeWhenCompiled(function() {
+ n._markMeshesAsLightDirty();
+ }) : t._IsTexture(this._projectionTexture) && this._projectionTexture.onLoadObservable.addOnce(function() {
+ n._markMeshesAsLightDirty();
+ })));
+ }, enumerable: !1, configurable: !0 }), t._IsProceduralTexture = function(e) {
+ return e.onGeneratedObservable !== void 0;
+ }, t._IsTexture = function(e) {
+ return e.onLoadObservable !== void 0;
+ }, t.prototype.getClassName = function() {
+ return "SpotLight";
+ }, t.prototype.getTypeID = function() {
+ return bi.a.LIGHTTYPEID_SPOTLIGHT;
+ }, t.prototype._setDirection = function(e) {
+ r.prototype._setDirection.call(this, e), this._projectionTextureViewLightDirty = !0;
+ }, t.prototype._setPosition = function(e) {
+ r.prototype._setPosition.call(this, e), this._projectionTextureViewLightDirty = !0;
+ }, t.prototype._setDefaultShadowProjectionMatrix = function(e, n, i) {
+ var o = this.getScene().activeCamera;
+ if (o) {
+ this._shadowAngleScale = this._shadowAngleScale || 1;
+ var a = this._shadowAngleScale * this._angle;
+ u.a.PerspectiveFovLHToRef(a, 1, this.getDepthMinZ(o), this.getDepthMaxZ(o), e);
+ }
+ }, t.prototype._computeProjectionTextureViewLightMatrix = function() {
+ this._projectionTextureViewLightDirty = !1, this._projectionTextureDirty = !0, this.position.addToRef(this.direction, this._projectionTextureViewTargetVector), u.a.LookAtLHToRef(this.position, this._projectionTextureViewTargetVector, this._projectionTextureUpDirection, this._projectionTextureViewLightMatrix);
+ }, t.prototype._computeProjectionTextureProjectionLightMatrix = function() {
+ this._projectionTextureProjectionLightDirty = !1, this._projectionTextureDirty = !0;
+ var e = this.projectionTextureLightFar, n = this.projectionTextureLightNear, i = e / (e - n), o = -i * n, a = 1 / Math.tan(this._angle / 2);
+ u.a.FromValuesToRef(a / 1, 0, 0, 0, 0, a, 0, 0, 0, 0, i, 1, 0, 0, o, 0, this._projectionTextureProjectionLightMatrix);
+ }, t.prototype._computeProjectionTextureMatrix = function() {
+ if (this._projectionTextureDirty = !1, this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix, this._projectionTextureMatrix), this._projectionTexture instanceof Ne.a) {
+ var e = this._projectionTexture.uScale / 2, n = this._projectionTexture.vScale / 2;
+ u.a.FromValuesToRef(e, 0, 0, 0, 0, n, 0, 0, 0, 0, 0.5, 0, 0.5, 0.5, 0.5, 1, this._projectionTextureScalingMatrix);
+ }
+ this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix, this._projectionTextureMatrix);
+ }, t.prototype._buildUniformLayout = function() {
+ this._uniformBuffer.addUniform("vLightData", 4), this._uniformBuffer.addUniform("vLightDiffuse", 4), this._uniformBuffer.addUniform("vLightSpecular", 4), this._uniformBuffer.addUniform("vLightDirection", 3), this._uniformBuffer.addUniform("vLightFalloff", 4), this._uniformBuffer.addUniform("shadowsInfo", 3), this._uniformBuffer.addUniform("depthValues", 2), this._uniformBuffer.create();
+ }, t.prototype._computeAngleValues = function() {
+ this._lightAngleScale = 1 / Math.max(1e-3, Math.cos(0.5 * this._innerAngle) - this._cosHalfAngle), this._lightAngleOffset = -this._cosHalfAngle * this._lightAngleScale;
+ }, t.prototype.transferTexturesToEffect = function(e, n) {
+ return this.projectionTexture && this.projectionTexture.isReady() && (this._projectionTextureViewLightDirty && this._computeProjectionTextureViewLightMatrix(), this._projectionTextureProjectionLightDirty && this._computeProjectionTextureProjectionLightMatrix(), this._projectionTextureDirty && this._computeProjectionTextureMatrix(), e.setMatrix("textureProjectionMatrix" + n, this._projectionTextureMatrix), e.setTexture("projectionLightSampler" + n, this.projectionTexture)), this;
+ }, t.prototype.transferToEffect = function(e, n) {
+ var i;
+ return this.computeTransformedInformation() ? (this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, this.exponent, n), i = u.e.Normalize(this.transformedDirection)) : (this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, this.exponent, n), i = u.e.Normalize(this.direction)), this._uniformBuffer.updateFloat4("vLightDirection", i.x, i.y, i.z, this._cosHalfAngle, n), this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, this._lightAngleScale, this._lightAngleOffset, n), this;
+ }, t.prototype.transferToNodeMaterialEffect = function(e, n) {
+ var i;
+ return i = this.computeTransformedInformation() ? u.e.Normalize(this.transformedDirection) : u.e.Normalize(this.direction), this.getScene().useRightHandedSystem ? e.setFloat3(n, -i.x, -i.y, -i.z) : e.setFloat3(n, i.x, i.y, i.z), this;
+ }, t.prototype.dispose = function() {
+ r.prototype.dispose.call(this), this._projectionTexture && this._projectionTexture.dispose();
+ }, t.prototype.prepareLightSpecificDefines = function(e, n) {
+ e["SPOTLIGHT" + n] = !0, e["PROJECTEDLIGHTTEXTURE" + n] = !(!this.projectionTexture || !this.projectionTexture.isReady());
+ }, Object(c.c)([Object(L.c)()], t.prototype, "angle", null), Object(c.c)([Object(L.c)()], t.prototype, "innerAngle", null), Object(c.c)([Object(L.c)()], t.prototype, "shadowAngleScale", null), Object(c.c)([Object(L.c)()], t.prototype, "exponent", void 0), Object(c.c)([Object(L.c)()], t.prototype, "projectionTextureLightNear", null), Object(c.c)([Object(L.c)()], t.prototype, "projectionTextureLightFar", null), Object(c.c)([Object(L.c)()], t.prototype, "projectionTextureUpDirection", null), Object(c.c)([Object(L.m)("projectedLightTexture")], t.prototype, "_projectionTexture", void 0), t;
+ }(ko), Wf = function(r) {
+ function t(e) {
+ e === void 0 && (e = Cn.a.DefaultUtilityLayer);
+ var n = r.call(this, e) || this;
+ return n._cachedPosition = new u.e(), n._cachedForward = new u.e(0, 0, 1), n._pointerObserver = null, n.onClickedObservable = new C.c(), n._light = null, n.attachedMesh = new Mt.a("", n.gizmoLayer.utilityLayerScene), n._attachedMeshParent = new pr.a("parent", n.gizmoLayer.utilityLayerScene), n.attachedMesh.parent = n._attachedMeshParent, n._material = new Nt.a("light", n.gizmoLayer.utilityLayerScene), n._material.diffuseColor = new I.a(0.5, 0.5, 0.5), n._material.specularColor = new I.a(0.1, 0.1, 0.1), n._pointerObserver = e.utilityLayerScene.onPointerObservable.add(function(i) {
+ n._light && (n._isHovered = !(!i.pickInfo || n._rootMesh.getChildMeshes().indexOf(i.pickInfo.pickedMesh) == -1), n._isHovered && i.event.button === 0 && n.onClickedObservable.notifyObservers(n._light));
+ }, yt.a.POINTERDOWN), n;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "light", { get: function() {
+ return this._light;
+ }, set: function(e) {
+ var n = this;
+ if (this._light = e, e) {
+ this._lightMesh && this._lightMesh.dispose(), e instanceof Oo.a ? this._lightMesh = t._CreateHemisphericLightMesh(this.gizmoLayer.utilityLayerScene) : this._lightMesh = e instanceof vs ? t._CreateDirectionalLightMesh(this.gizmoLayer.utilityLayerScene) : e instanceof ys ? t._CreateSpotLightMesh(this.gizmoLayer.utilityLayerScene) : t._CreatePointLightMesh(this.gizmoLayer.utilityLayerScene), this._lightMesh.getChildMeshes(!1).forEach(function(o) {
+ o.material = n._material;
+ }), this._lightMesh.parent = this._rootMesh;
+ var i = this.gizmoLayer._getSharedGizmoLight();
+ i.includedOnlyMeshes = i.includedOnlyMeshes.concat(this._lightMesh.getChildMeshes(!1)), this._lightMesh.rotationQuaternion = new u.b(), this.attachedMesh.reservedDataStore || (this.attachedMesh.reservedDataStore = {}), this.attachedMesh.reservedDataStore.lightGizmo = this, e.parent && this._attachedMeshParent.freezeWorldMatrix(e.parent.getWorldMatrix()), e.position && (this.attachedMesh.position.copyFrom(e.position), this.attachedMesh.computeWorldMatrix(!0), this._cachedPosition.copyFrom(this.attachedMesh.position)), e.direction && (this.attachedMesh.setDirection(e.direction), this.attachedMesh.computeWorldMatrix(!0), this._cachedForward.copyFrom(this.attachedMesh.forward)), this._update();
+ }
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "material", { get: function() {
+ return this._material;
+ }, enumerable: !1, configurable: !0 }), t.prototype._update = function() {
+ r.prototype._update.call(this), this._light && (this._light.parent && this._attachedMeshParent.freezeWorldMatrix(this._light.parent.getWorldMatrix()), this._light.position && (this.attachedMesh.position.equals(this._cachedPosition) ? (this.attachedMesh.position.copyFrom(this._light.position), this.attachedMesh.computeWorldMatrix(!0), this._cachedPosition.copyFrom(this.attachedMesh.position)) : (this._light.position.copyFrom(this.attachedMesh.position), this._cachedPosition.copyFrom(this.attachedMesh.position))), this._light.direction && (u.e.DistanceSquared(this.attachedMesh.forward, this._cachedForward) > 1e-4 ? (this._light.direction.copyFrom(this.attachedMesh.forward), this._cachedForward.copyFrom(this.attachedMesh.forward)) : u.e.DistanceSquared(this.attachedMesh.forward, this._light.direction) > 1e-4 && (this.attachedMesh.setDirection(this._light.direction), this.attachedMesh.computeWorldMatrix(!0), this._cachedForward.copyFrom(this.attachedMesh.forward))));
+ }, t.prototype.dispose = function() {
+ this.onClickedObservable.clear(), this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver), this._material.dispose(), r.prototype.dispose.call(this), this._attachedMeshParent.dispose();
+ }, t._CreateHemisphericLightMesh = function(e) {
+ var n = new Ie.a("hemisphereLight", e), i = Go.CreateHemisphere(n.name, { segments: 10, diameter: 1 }, e);
+ i.position.z = -0.15, i.rotation.x = Math.PI / 2, i.parent = n;
+ var o = this._CreateLightLines(3, e);
+ return o.parent = n, o.position.z, n.scaling.scaleInPlace(t._Scale), n.rotation.x = Math.PI / 2, n;
+ }, t._CreatePointLightMesh = function(e) {
+ var n = new Ie.a("pointLight", e), i = Nn.a.CreateSphere(n.name, { segments: 10, diameter: 1 }, e);
+ return i.rotation.x = Math.PI / 2, i.parent = n, this._CreateLightLines(5, e).parent = n, n.scaling.scaleInPlace(t._Scale), n.rotation.x = Math.PI / 2, n;
+ }, t._CreateSpotLightMesh = function(e) {
+ var n = new Ie.a("spotLight", e);
+ Nn.a.CreateSphere(n.name, { segments: 10, diameter: 1 }, e).parent = n;
+ var i = Go.CreateHemisphere(n.name, { segments: 10, diameter: 2 }, e);
+ return i.parent = n, i.rotation.x = -Math.PI / 2, this._CreateLightLines(2, e).parent = n, n.scaling.scaleInPlace(t._Scale), n.rotation.x = Math.PI / 2, n;
+ }, t._CreateDirectionalLightMesh = function(e) {
+ var n = new Ie.a("directionalLight", e), i = new Ie.a(n.name, e);
+ i.parent = n, Nn.a.CreateSphere(n.name, { diameter: 1.2, segments: 10 }, e).parent = i;
+ var o = Ie.a.CreateCylinder(n.name, 6, 0.3, 0.3, 6, 1, e);
+ o.parent = i, (a = o.clone(n.name)).scaling.y = 0.5, a.position.x += 1.25, (s = o.clone(n.name)).scaling.y = 0.5, s.position.x += -1.25;
+ var a, s, d = Ie.a.CreateCylinder(n.name, 1, 0, 0.6, 6, 1, e);
+ return d.position.y += 3, d.parent = i, (a = d.clone(n.name)).position.y = 1.5, a.position.x += 1.25, (s = d.clone(n.name)).position.y = 1.5, s.position.x += -1.25, i.scaling.scaleInPlace(t._Scale), i.rotation.z = Math.PI / 2, i.rotation.y = Math.PI / 2, n;
+ }, t._Scale = 7e-3, t._CreateLightLines = function(e, n) {
+ var i = new Ie.a("root", n);
+ i.rotation.x = Math.PI / 2;
+ var o = new Ie.a("linePivot", n);
+ o.parent = i;
+ var a = Ie.a.CreateCylinder("line", 2, 0.2, 0.3, 6, 1, n);
+ if (a.position.y = a.scaling.y / 2 + 1.2, a.parent = o, e < 2)
+ return o;
+ for (var s = 0; s < 4; s++)
+ (d = o.clone("lineParentClone")).rotation.z = Math.PI / 4, d.rotation.y = Math.PI / 2 + Math.PI / 2 * s, d.getChildMeshes()[0].scaling.y = 0.5, d.getChildMeshes()[0].scaling.x = d.getChildMeshes()[0].scaling.z = 0.8, d.getChildMeshes()[0].position.y = d.getChildMeshes()[0].scaling.y / 2 + 1.2;
+ if (e < 3)
+ return i;
+ for (s = 0; s < 4; s++)
+ (d = o.clone("linePivotClone")).rotation.z = Math.PI / 2, d.rotation.y = Math.PI / 2 * s;
+ if (e < 4)
+ return i;
+ for (s = 0; s < 4; s++) {
+ var d;
+ (d = o.clone("linePivotClone")).rotation.z = Math.PI + Math.PI / 4, d.rotation.y = Math.PI / 2 + Math.PI / 2 * s, d.getChildMeshes()[0].scaling.y = 0.5, d.getChildMeshes()[0].scaling.x = d.getChildMeshes()[0].scaling.z = 0.8, d.getChildMeshes()[0].position.y = d.getChildMeshes()[0].scaling.y / 2 + 1.2;
+ }
+ return e < 5 || ((d = o.clone("linePivotClone")).rotation.z = Math.PI), i;
+ }, t;
+ }(Ln.a), bs = function() {
+ function r(t, e) {
+ t === void 0 && (t = u.e.Zero()), e === void 0 && (e = u.e.Up()), this.position = t, this.normal = e;
+ }
+ return r.prototype.clone = function() {
+ return new r(this.position.clone(), this.normal.clone());
+ }, r;
+ }(), Xf = function() {
+ function r(t, e, n) {
+ t === void 0 && (t = u.e.Zero()), e === void 0 && (e = u.e.Up()), n === void 0 && (n = u.d.Zero()), this.position = t, this.normal = e, this.uv = n;
+ }
+ return r.prototype.clone = function() {
+ return new r(this.position.clone(), this.normal.clone(), this.uv.clone());
+ }, r;
+ }(), Yf = function(r) {
+ function t(e) {
+ e === void 0 && (e = Cn.a.DefaultUtilityLayer);
+ var n = r.call(this, e) || this;
+ return n._pointerObserver = null, n.onClickedObservable = new C.c(), n._camera = null, n._invProjection = new u.a(), n._material = new Nt.a("cameraGizmoMaterial", n.gizmoLayer.utilityLayerScene), n._material.diffuseColor = new I.a(0.5, 0.5, 0.5), n._material.specularColor = new I.a(0.1, 0.1, 0.1), n._pointerObserver = e.utilityLayerScene.onPointerObservable.add(function(i) {
+ n._camera && (n._isHovered = !(!i.pickInfo || n._rootMesh.getChildMeshes().indexOf(i.pickInfo.pickedMesh) == -1), n._isHovered && i.event.button === 0 && n.onClickedObservable.notifyObservers(n._camera));
+ }, yt.a.POINTERDOWN), n;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "displayFrustum", { get: function() {
+ return this._cameraLinesMesh.isEnabled();
+ }, set: function(e) {
+ this._cameraLinesMesh.setEnabled(e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "camera", { get: function() {
+ return this._camera;
+ }, set: function(e) {
+ var n = this;
+ if (this._camera = e, this.attachedNode = e, e) {
+ this._cameraMesh && this._cameraMesh.dispose(), this._cameraLinesMesh && this._cameraLinesMesh.dispose(), this._cameraMesh = t._CreateCameraMesh(this.gizmoLayer.utilityLayerScene), this._cameraLinesMesh = t._CreateCameraFrustum(this.gizmoLayer.utilityLayerScene), this._cameraMesh.getChildMeshes(!1).forEach(function(o) {
+ o.material = n._material;
+ }), this._cameraMesh.parent = this._rootMesh, this._cameraLinesMesh.parent = this._rootMesh, this.gizmoLayer.utilityLayerScene.activeCamera && this.gizmoLayer.utilityLayerScene.activeCamera.maxZ < 1.5 * e.maxZ && (this.gizmoLayer.utilityLayerScene.activeCamera.maxZ = 1.5 * e.maxZ), this.attachedNode.reservedDataStore || (this.attachedNode.reservedDataStore = {}), this.attachedNode.reservedDataStore.cameraGizmo = this;
+ var i = this.gizmoLayer._getSharedGizmoLight();
+ i.includedOnlyMeshes = i.includedOnlyMeshes.concat(this._cameraMesh.getChildMeshes(!1)), this._update();
+ }
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "material", { get: function() {
+ return this._material;
+ }, enumerable: !1, configurable: !0 }), t.prototype._update = function() {
+ r.prototype._update.call(this), this._camera && (this._camera.getProjectionMatrix().invertToRef(this._invProjection), this._cameraLinesMesh.setPivotMatrix(this._invProjection, !1), this._cameraLinesMesh.scaling.x = 1 / this._rootMesh.scaling.x, this._cameraLinesMesh.scaling.y = 1 / this._rootMesh.scaling.y, this._cameraLinesMesh.scaling.z = 1 / this._rootMesh.scaling.z, this._cameraMesh.parent = null, this._cameraMesh.rotation.y = 0.5 * Math.PI * (this._camera.getScene().useRightHandedSystem ? 1 : -1), this._cameraMesh.parent = this._rootMesh);
+ }, t.prototype.dispose = function() {
+ this.onClickedObservable.clear(), this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver), this._cameraMesh && this._cameraMesh.dispose(), this._cameraLinesMesh && this._cameraLinesMesh.dispose(), this._material.dispose(), r.prototype.dispose.call(this);
+ }, t._CreateCameraMesh = function(e) {
+ var n = new Ie.a("rootCameraGizmo", e), i = new Ie.a(n.name, e);
+ i.parent = n, fr.a.CreateBox(n.name, { width: 1, height: 0.8, depth: 0.5 }, e).parent = i;
+ var o = ci.a.CreateCylinder(n.name, { height: 0.5, diameterTop: 0.8, diameterBottom: 0.8 }, e);
+ o.parent = i, o.position.y = 0.3, o.position.x = -0.6, o.rotation.x = 0.5 * Math.PI;
+ var a = ci.a.CreateCylinder(n.name, { height: 0.5, diameterTop: 0.6, diameterBottom: 0.6 }, e);
+ a.parent = i, a.position.y = 0.5, a.position.x = 0.4, a.rotation.x = 0.5 * Math.PI;
+ var s = ci.a.CreateCylinder(n.name, { height: 0.5, diameterTop: 0.5, diameterBottom: 0.5 }, e);
+ return s.parent = i, s.position.y = 0, s.position.x = 0.6, s.rotation.z = 0.5 * Math.PI, n.scaling.scaleInPlace(t._Scale), i.position.x = -0.9, n;
+ }, t._CreateCameraFrustum = function(e) {
+ var n = new Ie.a("rootCameraGizmo", e), i = new Ie.a(n.name, e);
+ i.parent = n;
+ for (var o = 0; o < 4; o += 2)
+ for (var a = 0; a < 4; a += 2) {
+ var s;
+ (s = sn.a.CreateLines("lines", { points: [new u.e(-1 + a, -1 + o, -1), new u.e(-1 + a, -1 + o, 1)] }, e)).parent = i, s.alwaysSelectAsActiveMesh = !0, s.isPickable = !1, (s = sn.a.CreateLines("lines", { points: [new u.e(-1, -1 + a, -1 + o), new u.e(1, -1 + a, -1 + o)] }, e)).parent = i, s.alwaysSelectAsActiveMesh = !0, s.isPickable = !1, (s = sn.a.CreateLines("lines", { points: [new u.e(-1 + a, -1, -1 + o), new u.e(-1 + a, 1, -1 + o)] }, e)).parent = i, s.alwaysSelectAsActiveMesh = !0, s.isPickable = !1;
+ }
+ return n;
+ }, t._Scale = 0.05, t;
+ }(Ln.a);
+ ze.a.IncludesShadersStore.kernelBlurVaryingDeclaration = "varying vec2 sampleCoord{X};";
+ var Kf = `vec4 pack(float depth)
+{
+const vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);
+const vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);
+vec4 res=fract(depth*bit_shift);
+res-=res.xxyz*bit_mask;
+return res;
+}
+float unpack(vec4 color)
+{
+const vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);
+return dot(color,bit_shift);
+}`;
+ ze.a.IncludesShadersStore.packingFunctions = Kf;
+ var Qf = `#ifdef DOF
+factor=sampleCoC(sampleCoord{X});
+computedWeight=KERNEL_WEIGHT{X}*factor;
+sumOfWeights+=computedWeight;
+#else
+computedWeight=KERNEL_WEIGHT{X};
+#endif
+#ifdef PACKEDFLOAT
+blend+=unpack(texture2D(textureSampler,sampleCoord{X}))*computedWeight;
+#else
+blend+=texture2D(textureSampler,sampleCoord{X})*computedWeight;
+#endif`;
+ ze.a.IncludesShadersStore.kernelBlurFragment = Qf;
+ var qf = `#ifdef DOF
+factor=sampleCoC(sampleCenter+delta*KERNEL_DEP_OFFSET{X});
+computedWeight=KERNEL_DEP_WEIGHT{X}*factor;
+sumOfWeights+=computedWeight;
+#else
+computedWeight=KERNEL_DEP_WEIGHT{X};
+#endif
+#ifdef PACKEDFLOAT
+blend+=unpack(texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X}))*computedWeight;
+#else
+blend+=texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X})*computedWeight;
+#endif`;
+ ze.a.IncludesShadersStore.kernelBlurFragment2 = qf;
+ var Zf = `
+uniform sampler2D textureSampler;
+uniform vec2 delta;
+
+varying vec2 sampleCenter;
+#ifdef DOF
+uniform sampler2D circleOfConfusionSampler;
+uniform vec2 cameraMinMaxZ;
+float sampleDistance(const in vec2 offset) {
+float depth=texture2D(circleOfConfusionSampler,offset).g;
+return cameraMinMaxZ.x+(cameraMinMaxZ.y-cameraMinMaxZ.x)*depth;
+}
+float sampleCoC(const in vec2 offset) {
+float coc=texture2D(circleOfConfusionSampler,offset).r;
+return coc;
+}
+#endif
+#include[0..varyingCount]
+#ifdef PACKEDFLOAT
+#include
+#endif
+void main(void)
+{
+float computedWeight=0.0;
+#ifdef PACKEDFLOAT
+float blend=0.;
+#else
+vec4 blend=vec4(0.);
+#endif
+#ifdef DOF
+float sumOfWeights=CENTER_WEIGHT;
+float factor=0.0;
+
+#ifdef PACKEDFLOAT
+blend+=unpack(texture2D(textureSampler,sampleCenter))*CENTER_WEIGHT;
+#else
+blend+=texture2D(textureSampler,sampleCenter)*CENTER_WEIGHT;
+#endif
+#endif
+#include[0..varyingCount]
+#include[0..depCount]
+#ifdef PACKEDFLOAT
+gl_FragColor=pack(blend);
+#else
+gl_FragColor=blend;
+#endif
+#ifdef DOF
+gl_FragColor/=sumOfWeights;
+#endif
+}`;
+ ze.a.ShadersStore.kernelBlurPixelShader = Zf, ze.a.IncludesShadersStore.kernelBlurVertex = "sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";
+ var Jf = `
+attribute vec2 position;
+
+uniform vec2 delta;
+
+varying vec2 sampleCenter;
+#include[0..varyingCount]
+const vec2 madd=vec2(0.5,0.5);
+void main(void) {
+sampleCenter=(position*madd+madd);
+#include[0..varyingCount]
+gl_Position=vec4(position,0.0,1.0);
+}`;
+ ze.a.ShadersStore.kernelBlurVertexShader = Jf;
+ var _n = function(r) {
+ function t(e, n, i, o, a, s, d, p, y, P, R) {
+ s === void 0 && (s = Ne.a.BILINEAR_SAMPLINGMODE), y === void 0 && (y = h.a.TEXTURETYPE_UNSIGNED_INT), P === void 0 && (P = ""), R === void 0 && (R = !1);
+ var B = r.call(this, e, "kernelBlur", ["delta", "direction", "cameraMinMaxZ"], ["circleOfConfusionSampler"], o, a, s, d, p, null, y, "kernelBlur", { varyingCount: 0, depCount: 0 }, !0) || this;
+ return B.blockCompilation = R, B._packedFloat = !1, B._staticDefines = "", B._staticDefines = P, B.direction = n, B.onApplyObservable.add(function(F) {
+ B._outputTexture ? F.setFloat2("delta", 1 / B._outputTexture.width * B.direction.x, 1 / B._outputTexture.height * B.direction.y) : F.setFloat2("delta", 1 / B.width * B.direction.x, 1 / B.height * B.direction.y);
+ }), B.kernel = i, B;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "kernel", { get: function() {
+ return this._idealKernel;
+ }, set: function(e) {
+ this._idealKernel !== e && (e = Math.max(e, 1), this._idealKernel = e, this._kernel = this._nearestBestKernel(e), this.blockCompilation || this._updateParameters());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "packedFloat", { get: function() {
+ return this._packedFloat;
+ }, set: function(e) {
+ this._packedFloat !== e && (this._packedFloat = e, this.blockCompilation || this._updateParameters());
+ }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
+ return "BlurPostProcess";
+ }, t.prototype.updateEffect = function(e, n, i, o, a, s) {
+ this._updateParameters(a, s);
+ }, t.prototype._updateParameters = function(e, n) {
+ for (var i = this._kernel, o = (i - 1) / 2, a = [], s = [], d = 0, p = 0; p < i; p++) {
+ var y = p / (i - 1), P = this._gaussianWeight(2 * y - 1);
+ a[p] = p - o, s[p] = P, d += P;
+ }
+ for (p = 0; p < s.length; p++)
+ s[p] /= d;
+ var R = [], B = [], F = [];
+ for (p = 0; p <= o; p += 2) {
+ var z = Math.min(p + 1, Math.floor(o));
+ if (p === z)
+ F.push({ o: a[p], w: s[p] });
+ else {
+ var J = z === o, ie = s[p] + s[z] * (J ? 0.5 : 1), se = a[p] + 1 / (1 + s[p] / s[z]);
+ se === 0 ? (F.push({ o: a[p], w: s[p] }), F.push({ o: a[p + 1], w: s[p + 1] })) : (F.push({ o: se, w: ie }), F.push({ o: -se, w: ie }));
+ }
+ }
+ for (p = 0; p < F.length; p++)
+ B[p] = F[p].o, R[p] = F[p].w;
+ a = B, s = R;
+ var ce = this.getEngine().getCaps().maxVaryingVectors, ue = Math.max(ce, 0) - 1, fe = Math.min(a.length, ue), ve = "";
+ for (ve += this._staticDefines, this._staticDefines.indexOf("DOF") != -1 && (ve += "#define CENTER_WEIGHT " + this._glslFloat(s[fe - 1]) + `\r
+`, fe--), p = 0; p < fe; p++)
+ ve += "#define KERNEL_OFFSET" + p + " " + this._glslFloat(a[p]) + `\r
+`, ve += "#define KERNEL_WEIGHT" + p + " " + this._glslFloat(s[p]) + `\r
+`;
+ var Te = 0;
+ for (p = ue; p < a.length; p++)
+ ve += "#define KERNEL_DEP_OFFSET" + Te + " " + this._glslFloat(a[p]) + `\r
+`, ve += "#define KERNEL_DEP_WEIGHT" + Te + " " + this._glslFloat(s[p]) + `\r
+`, Te++;
+ this.packedFloat && (ve += "#define PACKEDFLOAT 1"), this.blockCompilation = !1, r.prototype.updateEffect.call(this, ve, null, null, { varyingCount: fe, depCount: Te }, e, n);
+ }, t.prototype._nearestBestKernel = function(e) {
+ for (var n = Math.round(e), i = 0, o = [n, n - 1, n + 1, n - 2, n + 2]; i < o.length; i++) {
+ var a = o[i];
+ if (a % 2 != 0 && Math.floor(a / 2) % 2 == 0 && a > 0)
+ return Math.max(a, 3);
+ }
+ return Math.max(n, 3);
+ }, t.prototype._gaussianWeight = function(e) {
+ var n = -e * e / 0.2222222222222222;
+ return 1 / (Math.sqrt(2 * Math.PI) * (1 / 3)) * Math.exp(n);
+ }, t.prototype._glslFloat = function(e, n) {
+ return n === void 0 && (n = 8), e.toFixed(n).replace(/0+$/, "");
+ }, t._Parse = function(e, n, i, o) {
+ return L.a.Parse(function() {
+ return new t(e.name, e.direction, e.kernel, e.options, n, e.renderTargetSamplingMode, i.getEngine(), e.reusable, e.textureType, void 0, !1);
+ }, e, i, o);
+ }, Object(c.c)([Object(L.c)("kernel")], t.prototype, "_kernel", void 0), Object(c.c)([Object(L.c)("packedFloat")], t.prototype, "_packedFloat", void 0), Object(c.c)([Object(L.n)()], t.prototype, "direction", void 0), t;
+ }(ft);
+ O.a.RegisteredTypes["BABYLON.BlurPostProcess"] = _n;
+ var Ts = function(r) {
+ function t(e, n, i, o, a, s, d) {
+ a === void 0 && (a = h.a.TEXTURETYPE_UNSIGNED_INT), s === void 0 && (s = Ne.a.BILINEAR_SAMPLINGMODE), d === void 0 && (d = !0);
+ var p = r.call(this, e, n, i, o, !0, a, !1, s, d) || this;
+ return p.scene = i, p.mirrorPlane = new ur.a(0, 1, 0, 1), p._transformMatrix = u.a.Zero(), p._mirrorMatrix = u.a.Zero(), p._adaptiveBlurKernel = 0, p._blurKernelX = 0, p._blurKernelY = 0, p._blurRatio = 1, p.ignoreCameraViewport = !0, p._updateGammaSpace(), p._imageProcessingConfigChangeObserver = i.imageProcessingConfiguration.onUpdateParameters.add(function() {
+ p._updateGammaSpace;
+ }), p.onBeforeRenderObservable.add(function() {
+ u.a.ReflectionToRef(p.mirrorPlane, p._mirrorMatrix), p._savedViewMatrix = i.getViewMatrix(), p._mirrorMatrix.multiplyToRef(p._savedViewMatrix, p._transformMatrix), i.setTransformMatrix(p._transformMatrix, i.getProjectionMatrix()), i.clipPlane = p.mirrorPlane, i.getEngine().cullBackFaces = !1, i._mirroredCameraPosition = u.e.TransformCoordinates(i.activeCamera.globalPosition, p._mirrorMatrix);
+ }), p.onAfterRenderObservable.add(function() {
+ i.setTransformMatrix(p._savedViewMatrix, i.getProjectionMatrix()), i.getEngine().cullBackFaces = !0, i._mirroredCameraPosition = null, i.clipPlane = null;
+ }), p;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "blurRatio", { get: function() {
+ return this._blurRatio;
+ }, set: function(e) {
+ this._blurRatio !== e && (this._blurRatio = e, this._preparePostProcesses());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "adaptiveBlurKernel", { set: function(e) {
+ this._adaptiveBlurKernel = e, this._autoComputeBlurKernel();
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "blurKernel", { set: function(e) {
+ this.blurKernelX = e, this.blurKernelY = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "blurKernelX", { get: function() {
+ return this._blurKernelX;
+ }, set: function(e) {
+ this._blurKernelX !== e && (this._blurKernelX = e, this._preparePostProcesses());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "blurKernelY", { get: function() {
+ return this._blurKernelY;
+ }, set: function(e) {
+ this._blurKernelY !== e && (this._blurKernelY = e, this._preparePostProcesses());
+ }, enumerable: !1, configurable: !0 }), t.prototype._autoComputeBlurKernel = function() {
+ var e = this.getScene().getEngine(), n = this.getRenderWidth() / e.getRenderWidth(), i = this.getRenderHeight() / e.getRenderHeight();
+ this.blurKernelX = this._adaptiveBlurKernel * n, this.blurKernelY = this._adaptiveBlurKernel * i;
+ }, t.prototype._onRatioRescale = function() {
+ this._sizeRatio && (this.resize(this._initialSizeParameter), this._adaptiveBlurKernel || this._preparePostProcesses()), this._adaptiveBlurKernel && this._autoComputeBlurKernel();
+ }, t.prototype._updateGammaSpace = function() {
+ this.gammaSpace = !this.scene.imageProcessingConfiguration.isEnabled || !this.scene.imageProcessingConfiguration.applyByPostProcess;
+ }, t.prototype._preparePostProcesses = function() {
+ if (this.clearPostProcesses(!0), this._blurKernelX && this._blurKernelY) {
+ var e = this.getScene().getEngine(), n = e.getCaps().textureFloatRender ? h.a.TEXTURETYPE_FLOAT : h.a.TEXTURETYPE_HALF_FLOAT;
+ this._blurX = new _n("horizontal blur", new u.d(1, 0), this._blurKernelX, this._blurRatio, null, Ne.a.BILINEAR_SAMPLINGMODE, e, !1, n), this._blurX.autoClear = !1, this._blurRatio === 1 && this.samples < 2 && this._texture ? this._blurX.inputTexture = this._texture : this._blurX.alwaysForcePOT = !0, this._blurY = new _n("vertical blur", new u.d(0, 1), this._blurKernelY, this._blurRatio, null, Ne.a.BILINEAR_SAMPLINGMODE, e, !1, n), this._blurY.autoClear = !1, this._blurY.alwaysForcePOT = this._blurRatio !== 1, this.addPostProcess(this._blurX), this.addPostProcess(this._blurY);
+ } else
+ this._blurY && (this.removePostProcess(this._blurY), this._blurY.dispose(), this._blurY = null), this._blurX && (this.removePostProcess(this._blurX), this._blurX.dispose(), this._blurX = null);
+ }, t.prototype.clone = function() {
+ var e = this.getScene();
+ if (!e)
+ return this;
+ var n = this.getSize(), i = new t(this.name, n.width, e, this._renderTargetOptions.generateMipMaps, this._renderTargetOptions.type, this._renderTargetOptions.samplingMode, this._renderTargetOptions.generateDepthBuffer);
+ return i.hasAlpha = this.hasAlpha, i.level = this.level, i.mirrorPlane = this.mirrorPlane.clone(), this.renderList && (i.renderList = this.renderList.slice(0)), i;
+ }, t.prototype.serialize = function() {
+ if (!this.name)
+ return null;
+ var e = r.prototype.serialize.call(this);
+ return e.mirrorPlane = this.mirrorPlane.asArray(), e;
+ }, t.prototype.dispose = function() {
+ r.prototype.dispose.call(this), this.scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver);
+ }, t;
+ }(on);
+ Ne.a._CreateMirror = function(r, t, e, n) {
+ return new Ts(r, t, e, n);
+ };
+ var Hn = f(34), ei = function(r) {
+ function t(e, n, i, o, a, s, d, p, y, P, R, B, F, z) {
+ var J;
+ i === void 0 && (i = null), o === void 0 && (o = !1), a === void 0 && (a = null), s === void 0 && (s = null), d === void 0 && (d = null), p === void 0 && (p = h.a.TEXTUREFORMAT_RGBA), y === void 0 && (y = !1), P === void 0 && (P = null), R === void 0 && (R = !1), B === void 0 && (B = 0.8), F === void 0 && (F = 0);
+ var ie = r.call(this, n) || this;
+ if (ie.onLoadObservable = new C.c(), ie.boundingBoxPosition = u.e.Zero(), ie._rotationY = 0, ie._files = null, ie._forcedExtension = null, ie._extensions = null, ie.name = e, ie.url = e, ie._noMipmap = o, ie.hasAlpha = !1, ie._format = p, ie.isCube = !0, ie._textureMatrix = u.a.Identity(), ie._createPolynomials = R, ie.coordinatesMode = Ne.a.CUBIC_MODE, ie._extensions = i, ie._files = a, ie._forcedExtension = P, ie._loaderOptions = z, !e && !a)
+ return ie;
+ var se = e.lastIndexOf("."), ce = P || (se > -1 ? e.substring(se).toLowerCase() : ""), ue = ce === ".dds", fe = ce === ".env";
+ if (fe ? (ie.gammaSpace = !1, ie._prefiltered = !1, ie.anisotropicFilteringLevel = 1) : (ie._prefiltered = y, y && (ie.gammaSpace = !1, ie.anisotropicFilteringLevel = 1)), ie._texture = ie._getFromCache(e, o), !a && (fe || ue || i || (i = ["_px.jpg", "_py.jpg", "_pz.jpg", "_nx.jpg", "_ny.jpg", "_nz.jpg"]), a = [], i))
+ for (var ve = 0; ve < i.length; ve++)
+ a.push(e + i[ve]);
+ ie._files = a;
+ var Te = function() {
+ ie.onLoadObservable.notifyObservers(ie), s && s();
+ };
+ if (ie._texture)
+ ie._texture.isReady ? Xe.b.SetImmediate(function() {
+ return Te();
+ }) : ie._texture.onLoadedObservable.add(function() {
+ return Te();
+ });
+ else {
+ var Re = ie.getScene();
+ Re != null && Re.useDelayedTextureLoading ? ie.delayLoadState = h.a.DELAYLOADSTATE_NOTLOADED : (ie._texture = y ? ie._getEngine().createPrefilteredCubeTexture(e, Re, B, F, s, d, p, P, ie._createPolynomials) : ie._getEngine().createCubeTexture(e, Re, a, o, s, d, ie._format, P, !1, B, F, null, z), (J = ie._texture) === null || J === void 0 || J.onLoadedObservable.add(function() {
+ return ie.onLoadObservable.notifyObservers(ie);
+ }));
+ }
+ return ie;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "boundingBoxSize", { get: function() {
+ return this._boundingBoxSize;
+ }, set: function(e) {
+ if (!this._boundingBoxSize || !this._boundingBoxSize.equals(e)) {
+ this._boundingBoxSize = e;
+ var n = this.getScene();
+ n && n.markAllMaterialsAsDirty(h.a.MATERIAL_TextureDirtyFlag);
+ }
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rotationY", { get: function() {
+ return this._rotationY;
+ }, set: function(e) {
+ this._rotationY = e, this.setReflectionTextureMatrix(u.a.RotationY(this._rotationY));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "noMipmap", { get: function() {
+ return this._noMipmap;
+ }, enumerable: !1, configurable: !0 }), t.CreateFromImages = function(e, n, i) {
+ var o = "";
+ return e.forEach(function(a) {
+ return o += a;
+ }), new t(o, n, null, i, e);
+ }, t.CreateFromPrefilteredData = function(e, n, i, o) {
+ i === void 0 && (i = null), o === void 0 && (o = !0);
+ var a = n.useDelayedTextureLoading;
+ n.useDelayedTextureLoading = !1;
+ var s = new t(e, n, null, !1, null, null, null, void 0, !0, i, o);
+ return n.useDelayedTextureLoading = a, s;
+ }, t.prototype.getClassName = function() {
+ return "CubeTexture";
+ }, t.prototype.updateURL = function(e, n, i, o) {
+ var a;
+ o === void 0 && (o = !1), this.url && (this.releaseInternalTexture(), (a = this.getScene()) === null || a === void 0 || a.markAllMaterialsAsDirty(h.a.MATERIAL_TextureDirtyFlag)), this.name && !Hn.a.StartsWith(this.name, "data:") || (this.name = e), this.url = e, this.delayLoadState = h.a.DELAYLOADSTATE_NOTLOADED, this._prefiltered = o, this._prefiltered && (this.gammaSpace = !1, this.anisotropicFilteringLevel = 1), this._forcedExtension = n || null, i && (this._delayedOnLoad = i), this.delayLoad(n);
+ }, t.prototype.delayLoad = function(e) {
+ var n, i = this;
+ if (this.delayLoadState === h.a.DELAYLOADSTATE_NOTLOADED && (this.delayLoadState = h.a.DELAYLOADSTATE_LOADED, this._texture = this._getFromCache(this.url, this._noMipmap), !this._texture)) {
+ var o = this.getScene();
+ this._prefiltered ? this._texture = this._getEngine().createPrefilteredCubeTexture(this.url, o, 0.8, 0, this._delayedOnLoad, void 0, this._format, e, this._createPolynomials) : this._texture = this._getEngine().createCubeTexture(this.url, o, this._files, this._noMipmap, this._delayedOnLoad, null, this._format, e, !1, 0, 0, null, this._loaderOptions), (n = this._texture) === null || n === void 0 || n.onLoadedObservable.add(function() {
+ return i.onLoadObservable.notifyObservers(i);
+ });
+ }
+ }, t.prototype.getReflectionTextureMatrix = function() {
+ return this._textureMatrix;
+ }, t.prototype.setReflectionTextureMatrix = function(e) {
+ var n, i = this;
+ e.updateFlag !== this._textureMatrix.updateFlag && (e.isIdentity() !== this._textureMatrix.isIdentity() && ((n = this.getScene()) === null || n === void 0 || n.markAllMaterialsAsDirty(h.a.MATERIAL_TextureDirtyFlag, function(o) {
+ return o.getActiveTextures().indexOf(i) !== -1;
+ })), this._textureMatrix = e);
+ }, t.Parse = function(e, n, i) {
+ var o = L.a.Parse(function() {
+ var p = !1;
+ return e.prefiltered && (p = e.prefiltered), new t(i + e.name, n, e.extensions, !1, e.files || null, null, null, void 0, p, e.forcedExtension);
+ }, e, n);
+ if (e.boundingBoxPosition && (o.boundingBoxPosition = u.e.FromArray(e.boundingBoxPosition)), e.boundingBoxSize && (o.boundingBoxSize = u.e.FromArray(e.boundingBoxSize)), e.animations)
+ for (var a = 0; a < e.animations.length; a++) {
+ var s = e.animations[a], d = O.a.GetClass("BABYLON.Animation");
+ d && o.animations.push(d.Parse(s));
+ }
+ return o;
+ }, t.prototype.clone = function() {
+ var e = this, n = 0, i = L.a.Clone(function() {
+ var o = new t(e.url, e.getScene() || e._getEngine(), e._extensions, e._noMipmap, e._files);
+ return n = o.uniqueId, o;
+ }, this);
+ return i.uniqueId = n, i;
+ }, Object(c.c)([Object(L.c)()], t.prototype, "url", void 0), Object(c.c)([Object(L.c)("rotationY")], t.prototype, "rotationY", null), Object(c.c)([Object(L.c)("files")], t.prototype, "_files", void 0), Object(c.c)([Object(L.c)("forcedExtension")], t.prototype, "_forcedExtension", void 0), Object(c.c)([Object(L.c)("extensions")], t.prototype, "_extensions", void 0), Object(c.c)([Object(L.j)("textureMatrix")], t.prototype, "_textureMatrix", void 0), t;
+ }(kn.a);
+ Ne.a._CubeTextureParser = ei.Parse, O.a.RegisteredTypes["BABYLON.CubeTexture"] = ei;
+ var $e = f(15), zo = f(76), jo = f(87), lt = f(19), $f = ` uniform vec4 vPrimaryColor;
+#ifdef USEHIGHLIGHTANDSHADOWCOLORS
+uniform vec4 vPrimaryColorShadow;
+#endif
+uniform float shadowLevel;
+uniform float alpha;
+#ifdef DIFFUSE
+uniform vec2 vDiffuseInfos;
+#endif
+#ifdef REFLECTION
+uniform vec2 vReflectionInfos;
+uniform mat4 reflectionMatrix;
+uniform vec3 vReflectionMicrosurfaceInfos;
+#endif
+#if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)
+uniform vec3 vBackgroundCenter;
+#endif
+#ifdef REFLECTIONFRESNEL
+uniform vec4 vReflectionControl;
+#endif
+#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)
+uniform mat4 view;
+#endif`;
+ ze.a.IncludesShadersStore.backgroundFragmentDeclaration = $f;
+ var ep = `layout(std140,column_major) uniform;
+uniform Material
+{
+uniform vec4 vPrimaryColor;
+uniform vec4 vPrimaryColorShadow;
+uniform vec2 vDiffuseInfos;
+uniform vec2 vReflectionInfos;
+uniform mat4 diffuseMatrix;
+uniform mat4 reflectionMatrix;
+uniform vec3 vReflectionMicrosurfaceInfos;
+uniform float fFovMultiplier;
+uniform float pointSize;
+uniform float shadowLevel;
+uniform float alpha;
+#if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)
+uniform vec3 vBackgroundCenter;
+#endif
+#ifdef REFLECTIONFRESNEL
+uniform vec4 vReflectionControl;
+#endif
+};
+uniform Scene {
+mat4 viewProjection;
+#ifdef MULTIVIEW
+mat4 viewProjectionR;
+#endif
+mat4 view;
+};`;
+ ze.a.IncludesShadersStore.backgroundUboDeclaration = ep, f(131), f(106), f(107), f(154), f(130), f(115), f(125), f(110), f(135), f(136);
+ var tp = `#ifdef TEXTURELODSUPPORT
+#extension GL_EXT_shader_texture_lod : enable
+#endif
+precision highp float;
+#include<__decl__backgroundFragment>
+#define RECIPROCAL_PI2 0.15915494
+
+uniform vec3 vEyePosition;
+
+varying vec3 vPositionW;
+#ifdef MAINUV1
+varying vec2 vMainUV1;
+#endif
+#ifdef MAINUV2
+varying vec2 vMainUV2;
+#endif
+#ifdef NORMAL
+varying vec3 vNormalW;
+#endif
+#ifdef DIFFUSE
+#if DIFFUSEDIRECTUV == 1
+#define vDiffuseUV vMainUV1
+#elif DIFFUSEDIRECTUV == 2
+#define vDiffuseUV vMainUV2
+#else
+varying vec2 vDiffuseUV;
+#endif
+uniform sampler2D diffuseSampler;
+#endif
+
+#ifdef REFLECTION
+#ifdef REFLECTIONMAP_3D
+#define sampleReflection(s,c) textureCube(s,c)
+uniform samplerCube reflectionSampler;
+#ifdef TEXTURELODSUPPORT
+#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)
+#else
+uniform samplerCube reflectionSamplerLow;
+uniform samplerCube reflectionSamplerHigh;
+#endif
+#else
+#define sampleReflection(s,c) texture2D(s,c)
+uniform sampler2D reflectionSampler;
+#ifdef TEXTURELODSUPPORT
+#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)
+#else
+uniform samplerCube reflectionSamplerLow;
+uniform samplerCube reflectionSamplerHigh;
+#endif
+#endif
+#ifdef REFLECTIONMAP_SKYBOX
+varying vec3 vPositionUVW;
+#else
+#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
+varying vec3 vDirectionW;
+#endif
+#endif
+#include
+#endif
+
+#ifndef FROMLINEARSPACE
+#define FROMLINEARSPACE;
+#endif
+
+#ifndef SHADOWONLY
+#define SHADOWONLY;
+#endif
+#include
+
+#include<__decl__lightFragment>[0..maxSimultaneousLights]
+#include
+#include
+#include
+#include
+#include
+
+#include
+#ifdef REFLECTIONFRESNEL
+#define FRESNEL_MAXIMUM_ON_ROUGH 0.25
+vec3 fresnelSchlickEnvironmentGGX(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)
+{
+
+float weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);
+return reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));
+}
+#endif
+void main(void) {
+#include
+vec3 viewDirectionW=normalize(vEyePosition-vPositionW);
+
+#ifdef NORMAL
+vec3 normalW=normalize(vNormalW);
+#else
+vec3 normalW=vec3(0.0,1.0,0.0);
+#endif
+
+float shadow=1.;
+float globalShadow=0.;
+float shadowLightCount=0.;
+#include[0..maxSimultaneousLights]
+#ifdef SHADOWINUSE
+globalShadow/=shadowLightCount;
+#else
+globalShadow=1.0;
+#endif
+#ifndef BACKMAT_SHADOWONLY
+
+vec4 reflectionColor=vec4(1.,1.,1.,1.);
+#ifdef REFLECTION
+vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);
+#ifdef REFLECTIONMAP_OPPOSITEZ
+reflectionVector.z*=-1.0;
+#endif
+
+#ifdef REFLECTIONMAP_3D
+vec3 reflectionCoords=reflectionVector;
+#else
+vec2 reflectionCoords=reflectionVector.xy;
+#ifdef REFLECTIONMAP_PROJECTION
+reflectionCoords/=reflectionVector.z;
+#endif
+reflectionCoords.y=1.0-reflectionCoords.y;
+#endif
+#ifdef REFLECTIONBLUR
+float reflectionLOD=vReflectionInfos.y;
+#ifdef TEXTURELODSUPPORT
+
+reflectionLOD=reflectionLOD*log2(vReflectionMicrosurfaceInfos.x)*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;
+reflectionColor=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);
+#else
+float lodReflectionNormalized=saturate(reflectionLOD);
+float lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;
+vec4 reflectionSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);
+if(lodReflectionNormalizedDoubled<1.0){
+reflectionColor=mix(
+sampleReflection(reflectionSamplerHigh,reflectionCoords),
+reflectionSpecularMid,
+lodReflectionNormalizedDoubled
+);
+} else {
+reflectionColor=mix(
+reflectionSpecularMid,
+sampleReflection(reflectionSamplerLow,reflectionCoords),
+lodReflectionNormalizedDoubled-1.0
+);
+}
+#endif
+#else
+vec4 reflectionSample=sampleReflection(reflectionSampler,reflectionCoords);
+reflectionColor=reflectionSample;
+#endif
+#ifdef RGBDREFLECTION
+reflectionColor.rgb=fromRGBD(reflectionColor);
+#endif
+#ifdef GAMMAREFLECTION
+reflectionColor.rgb=toLinearSpace(reflectionColor.rgb);
+#endif
+#ifdef REFLECTIONBGR
+reflectionColor.rgb=reflectionColor.bgr;
+#endif
+
+reflectionColor.rgb*=vReflectionInfos.x;
+#endif
+
+vec3 diffuseColor=vec3(1.,1.,1.);
+float finalAlpha=alpha;
+#ifdef DIFFUSE
+vec4 diffuseMap=texture2D(diffuseSampler,vDiffuseUV);
+#ifdef GAMMADIFFUSE
+diffuseMap.rgb=toLinearSpace(diffuseMap.rgb);
+#endif
+
+diffuseMap.rgb*=vDiffuseInfos.y;
+#ifdef DIFFUSEHASALPHA
+finalAlpha*=diffuseMap.a;
+#endif
+diffuseColor=diffuseMap.rgb;
+#endif
+
+#ifdef REFLECTIONFRESNEL
+vec3 colorBase=diffuseColor;
+#else
+vec3 colorBase=reflectionColor.rgb*diffuseColor;
+#endif
+colorBase=max(colorBase,0.0);
+
+#ifdef USERGBCOLOR
+vec3 finalColor=colorBase;
+#else
+#ifdef USEHIGHLIGHTANDSHADOWCOLORS
+vec3 mainColor=mix(vPrimaryColorShadow.rgb,vPrimaryColor.rgb,colorBase);
+#else
+vec3 mainColor=vPrimaryColor.rgb;
+#endif
+vec3 finalColor=colorBase*mainColor;
+#endif
+
+#ifdef REFLECTIONFRESNEL
+vec3 reflectionAmount=vReflectionControl.xxx;
+vec3 reflectionReflectance0=vReflectionControl.yyy;
+vec3 reflectionReflectance90=vReflectionControl.zzz;
+float VdotN=dot(normalize(vEyePosition),normalW);
+vec3 planarReflectionFresnel=fresnelSchlickEnvironmentGGX(saturate(VdotN),reflectionReflectance0,reflectionReflectance90,1.0);
+reflectionAmount*=planarReflectionFresnel;
+#ifdef REFLECTIONFALLOFF
+float reflectionDistanceFalloff=1.0-saturate(length(vPositionW.xyz-vBackgroundCenter)*vReflectionControl.w);
+reflectionDistanceFalloff*=reflectionDistanceFalloff;
+reflectionAmount*=reflectionDistanceFalloff;
+#endif
+finalColor=mix(finalColor,reflectionColor.rgb,saturate(reflectionAmount));
+#endif
+#ifdef OPACITYFRESNEL
+float viewAngleToFloor=dot(normalW,normalize(vEyePosition-vBackgroundCenter));
+
+const float startAngle=0.1;
+float fadeFactor=saturate(viewAngleToFloor/startAngle);
+finalAlpha*=fadeFactor*fadeFactor;
+#endif
+
+#ifdef SHADOWINUSE
+finalColor=mix(finalColor*shadowLevel,finalColor,globalShadow);
+#endif
+
+vec4 color=vec4(finalColor,finalAlpha);
+#else
+vec4 color=vec4(vPrimaryColor.rgb,(1.0-clamp(globalShadow,0.,1.))*alpha);
+#endif
+#include
+#ifdef IMAGEPROCESSINGPOSTPROCESS
+
+
+color.rgb=clamp(color.rgb,0.,30.0);
+#else
+
+color=applyImageProcessing(color);
+#endif
+#ifdef PREMULTIPLYALPHA
+
+color.rgb*=color.a;
+#endif
+#ifdef NOISE
+color.rgb+=dither(vPositionW.xy,0.5);
+color=max(color,0.0);
+#endif
+gl_FragColor=color;
+}
+`;
+ ze.a.ShadersStore.backgroundPixelShader = tp;
+ var np = `uniform mat4 view;
+uniform mat4 viewProjection;
+uniform float shadowLevel;
+#ifdef DIFFUSE
+uniform mat4 diffuseMatrix;
+uniform vec2 vDiffuseInfos;
+#endif
+#ifdef REFLECTION
+uniform vec2 vReflectionInfos;
+uniform mat4 reflectionMatrix;
+uniform vec3 vReflectionMicrosurfaceInfos;
+uniform float fFovMultiplier;
+#endif
+#ifdef POINTSIZE
+uniform float pointSize;
+#endif`;
+ ze.a.IncludesShadersStore.backgroundVertexDeclaration = np, f(78), f(79), f(117), f(137), f(80), f(81), f(111), f(157), f(138);
+ var ip = `precision highp float;
+#include<__decl__backgroundVertex>
+#include
+
+attribute vec3 position;
+#ifdef NORMAL
+attribute vec3 normal;
+#endif
+#include
+
+#include
+
+varying vec3 vPositionW;
+#ifdef NORMAL
+varying vec3 vNormalW;
+#endif
+#ifdef UV1
+attribute vec2 uv;
+#endif
+#ifdef UV2
+attribute vec2 uv2;
+#endif
+#ifdef MAINUV1
+varying vec2 vMainUV1;
+#endif
+#ifdef MAINUV2
+varying vec2 vMainUV2;
+#endif
+#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0
+varying vec2 vDiffuseUV;
+#endif
+#include
+#include
+#include<__decl__lightFragment>[0..maxSimultaneousLights]
+#ifdef REFLECTIONMAP_SKYBOX
+varying vec3 vPositionUVW;
+#endif
+#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
+varying vec3 vDirectionW;
+#endif
+void main(void) {
+#ifdef REFLECTIONMAP_SKYBOX
+vPositionUVW=position;
+#endif
+#include
+#include
+#ifdef MULTIVIEW
+if (gl_ViewID_OVR == 0u) {
+gl_Position=viewProjection*finalWorld*vec4(position,1.0);
+} else {
+gl_Position=viewProjectionR*finalWorld*vec4(position,1.0);
+}
+#else
+gl_Position=viewProjection*finalWorld*vec4(position,1.0);
+#endif
+vec4 worldPos=finalWorld*vec4(position,1.0);
+vPositionW=vec3(worldPos);
+#ifdef NORMAL
+mat3 normalWorld=mat3(finalWorld);
+#ifdef NONUNIFORMSCALING
+normalWorld=transposeMat3(inverseMat3(normalWorld));
+#endif
+vNormalW=normalize(normalWorld*normal);
+#endif
+#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
+vDirectionW=normalize(vec3(finalWorld*vec4(position,0.0)));
+#ifdef EQUIRECTANGULAR_RELFECTION_FOV
+mat3 screenToWorld=inverseMat3(mat3(finalWorld*viewProjection));
+vec3 segment=mix(vDirectionW,screenToWorld*vec3(0.0,0.0,1.0),abs(fFovMultiplier-1.0));
+if (fFovMultiplier<=1.0) {
+vDirectionW=normalize(segment);
+} else {
+vDirectionW=normalize(vDirectionW+(vDirectionW-segment));
+}
+#endif
+#endif
+#ifndef UV1
+vec2 uv=vec2(0.,0.);
+#endif
+#ifndef UV2
+vec2 uv2=vec2(0.,0.);
+#endif
+#ifdef MAINUV1
+vMainUV1=uv;
+#endif
+#ifdef MAINUV2
+vMainUV2=uv2;
+#endif
+#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0
+if (vDiffuseInfos.x == 0.)
+{
+vDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));
+}
+else
+{
+vDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
+}
+#endif
+
+#include
+
+#include
+
+#include[0..maxSimultaneousLights]
+
+#ifdef VERTEXCOLOR
+vColor=color;
+#endif
+
+#ifdef POINTSIZE
+gl_PointSize=pointSize;
+#endif
+}
+`;
+ ze.a.ShadersStore.backgroundVertexShader = ip;
+ var _r = f(67), rp = function(r) {
+ function t() {
+ var e = r.call(this) || this;
+ return e.DIFFUSE = !1, e.DIFFUSEDIRECTUV = 0, e.GAMMADIFFUSE = !1, e.DIFFUSEHASALPHA = !1, e.OPACITYFRESNEL = !1, e.REFLECTIONBLUR = !1, e.REFLECTIONFRESNEL = !1, e.REFLECTIONFALLOFF = !1, e.TEXTURELODSUPPORT = !1, e.PREMULTIPLYALPHA = !1, e.USERGBCOLOR = !1, e.USEHIGHLIGHTANDSHADOWCOLORS = !1, e.BACKMAT_SHADOWONLY = !1, e.NOISE = !1, e.REFLECTIONBGR = !1, e.IMAGEPROCESSING = !1, e.VIGNETTE = !1, e.VIGNETTEBLENDMODEMULTIPLY = !1, e.VIGNETTEBLENDMODEOPAQUE = !1, e.TONEMAPPING = !1, e.TONEMAPPING_ACES = !1, e.CONTRAST = !1, e.COLORCURVES = !1, e.COLORGRADING = !1, e.COLORGRADING3D = !1, e.SAMPLER3DGREENDEPTH = !1, e.SAMPLER3DBGRMAP = !1, e.IMAGEPROCESSINGPOSTPROCESS = !1, e.EXPOSURE = !1, e.MULTIVIEW = !1, e.REFLECTION = !1, e.REFLECTIONMAP_3D = !1, e.REFLECTIONMAP_SPHERICAL = !1, e.REFLECTIONMAP_PLANAR = !1, e.REFLECTIONMAP_CUBIC = !1, e.REFLECTIONMAP_PROJECTION = !1, e.REFLECTIONMAP_SKYBOX = !1, e.REFLECTIONMAP_EXPLICIT = !1, e.REFLECTIONMAP_EQUIRECTANGULAR = !1, e.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1, e.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1, e.INVERTCUBICMAP = !1, e.REFLECTIONMAP_OPPOSITEZ = !1, e.LODINREFLECTIONALPHA = !1, e.GAMMAREFLECTION = !1, e.RGBDREFLECTION = !1, e.EQUIRECTANGULAR_RELFECTION_FOV = !1, e.MAINUV1 = !1, e.MAINUV2 = !1, e.UV1 = !1, e.UV2 = !1, e.CLIPPLANE = !1, e.CLIPPLANE2 = !1, e.CLIPPLANE3 = !1, e.CLIPPLANE4 = !1, e.CLIPPLANE5 = !1, e.CLIPPLANE6 = !1, e.POINTSIZE = !1, e.FOG = !1, e.NORMAL = !1, e.NUM_BONE_INFLUENCERS = 0, e.BonesPerMesh = 0, e.INSTANCES = !1, e.SHADOWFLOAT = !1, e.rebuild(), e;
+ }
+ return Object(c.d)(t, r), t;
+ }(zo.a), qr = function(r) {
+ function t(e, n) {
+ var i = r.call(this, e, n) || this;
+ return i.primaryColor = I.a.White(), i._primaryColorShadowLevel = 0, i._primaryColorHighlightLevel = 0, i.reflectionTexture = null, i.reflectionBlur = 0, i.diffuseTexture = null, i._shadowLights = null, i.shadowLights = null, i.shadowLevel = 0, i.sceneCenter = u.e.Zero(), i.opacityFresnel = !0, i.reflectionFresnel = !1, i.reflectionFalloffDistance = 0, i.reflectionAmount = 1, i.reflectionReflectance0 = 0.05, i.reflectionReflectance90 = 0.5, i.useRGBColor = !0, i.enableNoise = !1, i._fovMultiplier = 1, i.useEquirectangularFOV = !1, i._maxSimultaneousLights = 4, i.maxSimultaneousLights = 4, i._shadowOnly = !1, i.shadowOnly = !1, i._imageProcessingObserver = null, i.switchToBGR = !1, i._renderTargets = new si.a(16), i._reflectionControls = u.f.Zero(), i._white = I.a.White(), i._primaryShadowColor = I.a.Black(), i._primaryHighlightColor = I.a.Black(), i._attachImageProcessingConfiguration(null), i.getRenderTargetTextures = function() {
+ return i._renderTargets.reset(), i._diffuseTexture && i._diffuseTexture.isRenderTarget && i._renderTargets.push(i._diffuseTexture), i._reflectionTexture && i._reflectionTexture.isRenderTarget && i._renderTargets.push(i._reflectionTexture), i._renderTargets;
+ }, i;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "_perceptualColor", { get: function() {
+ return this.__perceptualColor;
+ }, set: function(e) {
+ this.__perceptualColor = e, this._computePrimaryColorFromPerceptualColor(), this._markAllSubMeshesAsLightsDirty();
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "primaryColorShadowLevel", { get: function() {
+ return this._primaryColorShadowLevel;
+ }, set: function(e) {
+ this._primaryColorShadowLevel = e, this._computePrimaryColors(), this._markAllSubMeshesAsLightsDirty();
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "primaryColorHighlightLevel", { get: function() {
+ return this._primaryColorHighlightLevel;
+ }, set: function(e) {
+ this._primaryColorHighlightLevel = e, this._computePrimaryColors(), this._markAllSubMeshesAsLightsDirty();
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "reflectionStandardFresnelWeight", { set: function(e) {
+ var n = e;
+ n < 0.5 ? (n *= 2, this.reflectionReflectance0 = t.StandardReflectance0 * n, this.reflectionReflectance90 = t.StandardReflectance90 * n) : (n = 2 * n - 1, this.reflectionReflectance0 = t.StandardReflectance0 + (1 - t.StandardReflectance0) * n, this.reflectionReflectance90 = t.StandardReflectance90 + (1 - t.StandardReflectance90) * n);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "fovMultiplier", { get: function() {
+ return this._fovMultiplier;
+ }, set: function(e) {
+ isNaN(e) && (e = 1), this._fovMultiplier = Math.max(0, Math.min(2, e));
+ }, enumerable: !1, configurable: !0 }), t.prototype._attachImageProcessingConfiguration = function(e) {
+ var n = this;
+ e !== this._imageProcessingConfiguration && (this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver), this._imageProcessingConfiguration = e || this.getScene().imageProcessingConfiguration, this._imageProcessingConfiguration && (this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function() {
+ n._computePrimaryColorFromPerceptualColor(), n._markAllSubMeshesAsImageProcessingDirty();
+ })));
+ }, Object.defineProperty(t.prototype, "imageProcessingConfiguration", { get: function() {
+ return this._imageProcessingConfiguration;
+ }, set: function(e) {
+ this._attachImageProcessingConfiguration(e), this._markAllSubMeshesAsTexturesDirty();
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraColorCurvesEnabled", { get: function() {
+ return this.imageProcessingConfiguration.colorCurvesEnabled;
+ }, set: function(e) {
+ this.imageProcessingConfiguration.colorCurvesEnabled = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraColorGradingEnabled", { get: function() {
+ return this.imageProcessingConfiguration.colorGradingEnabled;
+ }, set: function(e) {
+ this.imageProcessingConfiguration.colorGradingEnabled = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraToneMappingEnabled", { get: function() {
+ return this._imageProcessingConfiguration.toneMappingEnabled;
+ }, set: function(e) {
+ this._imageProcessingConfiguration.toneMappingEnabled = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraExposure", { get: function() {
+ return this._imageProcessingConfiguration.exposure;
+ }, set: function(e) {
+ this._imageProcessingConfiguration.exposure = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraContrast", { get: function() {
+ return this._imageProcessingConfiguration.contrast;
+ }, set: function(e) {
+ this._imageProcessingConfiguration.contrast = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraColorGradingTexture", { get: function() {
+ return this._imageProcessingConfiguration.colorGradingTexture;
+ }, set: function(e) {
+ this.imageProcessingConfiguration.colorGradingTexture = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraColorCurves", { get: function() {
+ return this.imageProcessingConfiguration.colorCurves;
+ }, set: function(e) {
+ this.imageProcessingConfiguration.colorCurves = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hasRenderTargetTextures", { get: function() {
+ return !(!this._diffuseTexture || !this._diffuseTexture.isRenderTarget) || !(!this._reflectionTexture || !this._reflectionTexture.isRenderTarget);
+ }, enumerable: !1, configurable: !0 }), t.prototype.needAlphaTesting = function() {
+ return !0;
+ }, t.prototype.needAlphaBlending = function() {
+ return this.alpha < 1 || this._diffuseTexture != null && this._diffuseTexture.hasAlpha || this._shadowOnly;
+ }, t.prototype.isReadyForSubMesh = function(e, n, i) {
+ var o = this;
+ if (i === void 0 && (i = !1), n.effect && this.isFrozen && n.effect._wasPreviouslyReady)
+ return !0;
+ n._materialDefines || (n._materialDefines = new rp());
+ var a = this.getScene(), s = n._materialDefines;
+ if (this._isReadyForSubMesh(n))
+ return !0;
+ var d = a.getEngine();
+ if ($e.a.PrepareDefinesForLights(a, e, s, !1, this._maxSimultaneousLights), s._needNormals = !0, $e.a.PrepareDefinesForMultiview(a, s), s._areTexturesDirty) {
+ if (s._needUVs = !1, a.texturesEnabled) {
+ if (a.getEngine().getCaps().textureLOD && (s.TEXTURELODSUPPORT = !0), this._diffuseTexture && lt.a.DiffuseTextureEnabled) {
+ if (!this._diffuseTexture.isReadyOrNotBlocking())
+ return !1;
+ $e.a.PrepareDefinesForMergedUV(this._diffuseTexture, s, "DIFFUSE"), s.DIFFUSEHASALPHA = this._diffuseTexture.hasAlpha, s.GAMMADIFFUSE = this._diffuseTexture.gammaSpace, s.OPACITYFRESNEL = this._opacityFresnel;
+ } else
+ s.DIFFUSE = !1, s.DIFFUSEHASALPHA = !1, s.GAMMADIFFUSE = !1, s.OPACITYFRESNEL = !1;
+ var p = this._reflectionTexture;
+ if (p && lt.a.ReflectionTextureEnabled) {
+ if (!p.isReadyOrNotBlocking())
+ return !1;
+ switch (s.REFLECTION = !0, s.GAMMAREFLECTION = p.gammaSpace, s.RGBDREFLECTION = p.isRGBD, s.REFLECTIONBLUR = this._reflectionBlur > 0, s.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !p.invertZ : p.invertZ, s.LODINREFLECTIONALPHA = p.lodLevelInAlpha, s.EQUIRECTANGULAR_RELFECTION_FOV = this.useEquirectangularFOV, s.REFLECTIONBGR = this.switchToBGR, p.coordinatesMode === Ne.a.INVCUBIC_MODE && (s.INVERTCUBICMAP = !0), s.REFLECTIONMAP_3D = p.isCube, p.coordinatesMode) {
+ case Ne.a.EXPLICIT_MODE:
+ s.REFLECTIONMAP_EXPLICIT = !0;
+ break;
+ case Ne.a.PLANAR_MODE:
+ s.REFLECTIONMAP_PLANAR = !0;
+ break;
+ case Ne.a.PROJECTION_MODE:
+ s.REFLECTIONMAP_PROJECTION = !0;
+ break;
+ case Ne.a.SKYBOX_MODE:
+ s.REFLECTIONMAP_SKYBOX = !0;
+ break;
+ case Ne.a.SPHERICAL_MODE:
+ s.REFLECTIONMAP_SPHERICAL = !0;
+ break;
+ case Ne.a.EQUIRECTANGULAR_MODE:
+ s.REFLECTIONMAP_EQUIRECTANGULAR = !0;
+ break;
+ case Ne.a.FIXED_EQUIRECTANGULAR_MODE:
+ s.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !0;
+ break;
+ case Ne.a.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
+ s.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !0;
+ break;
+ case Ne.a.CUBIC_MODE:
+ case Ne.a.INVCUBIC_MODE:
+ default:
+ s.REFLECTIONMAP_CUBIC = !0;
+ }
+ this.reflectionFresnel ? (s.REFLECTIONFRESNEL = !0, s.REFLECTIONFALLOFF = this.reflectionFalloffDistance > 0, this._reflectionControls.x = this.reflectionAmount, this._reflectionControls.y = this.reflectionReflectance0, this._reflectionControls.z = this.reflectionReflectance90, this._reflectionControls.w = 1 / this.reflectionFalloffDistance) : (s.REFLECTIONFRESNEL = !1, s.REFLECTIONFALLOFF = !1);
+ } else
+ s.REFLECTION = !1, s.REFLECTIONFRESNEL = !1, s.REFLECTIONFALLOFF = !1, s.REFLECTIONBLUR = !1, s.REFLECTIONMAP_3D = !1, s.REFLECTIONMAP_SPHERICAL = !1, s.REFLECTIONMAP_PLANAR = !1, s.REFLECTIONMAP_CUBIC = !1, s.REFLECTIONMAP_PROJECTION = !1, s.REFLECTIONMAP_SKYBOX = !1, s.REFLECTIONMAP_EXPLICIT = !1, s.REFLECTIONMAP_EQUIRECTANGULAR = !1, s.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1, s.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1, s.INVERTCUBICMAP = !1, s.REFLECTIONMAP_OPPOSITEZ = !1, s.LODINREFLECTIONALPHA = !1, s.GAMMAREFLECTION = !1, s.RGBDREFLECTION = !1;
+ }
+ s.PREMULTIPLYALPHA = this.alphaMode === h.a.ALPHA_PREMULTIPLIED || this.alphaMode === h.a.ALPHA_PREMULTIPLIED_PORTERDUFF, s.USERGBCOLOR = this._useRGBColor, s.NOISE = this._enableNoise;
+ }
+ if (s._areLightsDirty && (s.USEHIGHLIGHTANDSHADOWCOLORS = !this._useRGBColor && (this._primaryColorShadowLevel !== 0 || this._primaryColorHighlightLevel !== 0), s.BACKMAT_SHADOWONLY = this._shadowOnly), s._areImageProcessingDirty && this._imageProcessingConfiguration) {
+ if (!this._imageProcessingConfiguration.isReady())
+ return !1;
+ this._imageProcessingConfiguration.prepareDefines(s);
+ }
+ if ($e.a.PrepareDefinesForMisc(e, a, !1, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(e), s), $e.a.PrepareDefinesForFrameBoundValues(a, d, s, i, null, n.getRenderingMesh().hasThinInstances), $e.a.PrepareDefinesForAttributes(e, s, !1, !0, !1) && e && (a.getEngine().getCaps().standardDerivatives || e.isVerticesDataPresent(Oe.b.NormalKind) || (e.createNormals(!0), l.a.Warn("BackgroundMaterial: Normals have been created for the mesh: " + e.name))), s.isDirty) {
+ s.markAsProcessed(), a.resetCachedMaterial();
+ var y = new _r.a();
+ s.FOG && y.addFallback(0, "FOG"), s.POINTSIZE && y.addFallback(1, "POINTSIZE"), s.MULTIVIEW && y.addFallback(0, "MULTIVIEW"), $e.a.HandleFallbacksForShadows(s, y, this._maxSimultaneousLights);
+ var P = [Oe.b.PositionKind];
+ s.NORMAL && P.push(Oe.b.NormalKind), s.UV1 && P.push(Oe.b.UVKind), s.UV2 && P.push(Oe.b.UV2Kind), $e.a.PrepareAttributesForBones(P, e, s, y), $e.a.PrepareAttributesForInstances(P, s);
+ var R = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vFogInfos", "vFogColor", "pointSize", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "mBones", "vPrimaryColor", "vPrimaryColorShadow", "vReflectionInfos", "reflectionMatrix", "vReflectionMicrosurfaceInfos", "fFovMultiplier", "shadowLevel", "alpha", "vBackgroundCenter", "vReflectionControl", "vDiffuseInfos", "diffuseMatrix"], B = ["diffuseSampler", "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh"], F = ["Material", "Scene"];
+ vn.a && (vn.a.PrepareUniforms(R, s), vn.a.PrepareSamplers(B, s)), $e.a.PrepareUniformsAndSamplersList({ uniformsNames: R, uniformBuffersNames: F, samplers: B, defines: s, maxSimultaneousLights: this._maxSimultaneousLights });
+ var z = s.toString();
+ n.setEffect(a.getEngine().createEffect("background", { attributes: P, uniformsNames: R, uniformBuffersNames: F, samplers: B, defines: z, fallbacks: y, onCompiled: function(J) {
+ o.onCompiled && o.onCompiled(J), o.bindSceneUniformBuffer(J, a.getSceneUniformBuffer());
+ }, onError: this.onError, indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights } }, d), s), this.buildUniformLayout();
+ }
+ return !(!n.effect || !n.effect.isReady()) && (s._renderId = a.getRenderId(), n.effect._wasPreviouslyReady = !0, !0);
+ }, t.prototype._computePrimaryColorFromPerceptualColor = function() {
+ this.__perceptualColor && (this._primaryColor.copyFrom(this.__perceptualColor), this._primaryColor.toLinearSpaceToRef(this._primaryColor), this._imageProcessingConfiguration && this._primaryColor.scaleToRef(1 / this._imageProcessingConfiguration.exposure, this._primaryColor), this._computePrimaryColors());
+ }, t.prototype._computePrimaryColors = function() {
+ this._primaryColorShadowLevel === 0 && this._primaryColorHighlightLevel === 0 || (this._primaryColor.scaleToRef(this._primaryColorShadowLevel, this._primaryShadowColor), this._primaryColor.subtractToRef(this._primaryShadowColor, this._primaryShadowColor), this._white.subtractToRef(this._primaryColor, this._primaryHighlightColor), this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel, this._primaryHighlightColor), this._primaryColor.addToRef(this._primaryHighlightColor, this._primaryHighlightColor));
+ }, t.prototype.buildUniformLayout = function() {
+ this._uniformBuffer.addUniform("vPrimaryColor", 4), this._uniformBuffer.addUniform("vPrimaryColorShadow", 4), this._uniformBuffer.addUniform("vDiffuseInfos", 2), this._uniformBuffer.addUniform("vReflectionInfos", 2), this._uniformBuffer.addUniform("diffuseMatrix", 16), this._uniformBuffer.addUniform("reflectionMatrix", 16), this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3), this._uniformBuffer.addUniform("fFovMultiplier", 1), this._uniformBuffer.addUniform("pointSize", 1), this._uniformBuffer.addUniform("shadowLevel", 1), this._uniformBuffer.addUniform("alpha", 1), this._uniformBuffer.addUniform("vBackgroundCenter", 3), this._uniformBuffer.addUniform("vReflectionControl", 4), this._uniformBuffer.create();
+ }, t.prototype.unbind = function() {
+ this._diffuseTexture && this._diffuseTexture.isRenderTarget && this._uniformBuffer.setTexture("diffuseSampler", null), this._reflectionTexture && this._reflectionTexture.isRenderTarget && this._uniformBuffer.setTexture("reflectionSampler", null), r.prototype.unbind.call(this);
+ }, t.prototype.bindOnlyWorldMatrix = function(e) {
+ this._activeEffect.setMatrix("world", e);
+ }, t.prototype.bindForSubMesh = function(e, n, i) {
+ var o = this.getScene(), a = i._materialDefines;
+ if (a) {
+ var s = i.effect;
+ if (s) {
+ this._activeEffect = s, this.bindOnlyWorldMatrix(e), $e.a.BindBonesParameters(n, this._activeEffect);
+ var d = this._mustRebind(o, s, n.visibility);
+ if (d) {
+ this._uniformBuffer.bindToEffect(s, "Material"), this.bindViewProjection(s);
+ var p = this._reflectionTexture;
+ this._uniformBuffer.useUbo && this.isFrozen && this._uniformBuffer.isSync || (o.texturesEnabled && (this._diffuseTexture && lt.a.DiffuseTextureEnabled && (this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level), $e.a.BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse")), p && lt.a.ReflectionTextureEnabled && (this._uniformBuffer.updateMatrix("reflectionMatrix", p.getReflectionTextureMatrix()), this._uniformBuffer.updateFloat2("vReflectionInfos", p.level, this._reflectionBlur), this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", p.getSize().width, p.lodGenerationScale, p.lodGenerationOffset))), this.shadowLevel > 0 && this._uniformBuffer.updateFloat("shadowLevel", this.shadowLevel), this._uniformBuffer.updateFloat("alpha", this.alpha), this.pointsCloud && this._uniformBuffer.updateFloat("pointSize", this.pointSize), a.USEHIGHLIGHTANDSHADOWCOLORS ? (this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryHighlightColor, 1), this._uniformBuffer.updateColor4("vPrimaryColorShadow", this._primaryShadowColor, 1)) : this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryColor, 1)), this._uniformBuffer.updateFloat("fFovMultiplier", this._fovMultiplier), o.texturesEnabled && (this._diffuseTexture && lt.a.DiffuseTextureEnabled && this._uniformBuffer.setTexture("diffuseSampler", this._diffuseTexture), p && lt.a.ReflectionTextureEnabled && (a.REFLECTIONBLUR && a.TEXTURELODSUPPORT ? this._uniformBuffer.setTexture("reflectionSampler", p) : a.REFLECTIONBLUR ? (this._uniformBuffer.setTexture("reflectionSampler", p._lodTextureMid || p), this._uniformBuffer.setTexture("reflectionSamplerLow", p._lodTextureLow || p), this._uniformBuffer.setTexture("reflectionSamplerHigh", p._lodTextureHigh || p)) : this._uniformBuffer.setTexture("reflectionSampler", p), a.REFLECTIONFRESNEL && (this._uniformBuffer.updateFloat3("vBackgroundCenter", this.sceneCenter.x, this.sceneCenter.y, this.sceneCenter.z), this._uniformBuffer.updateFloat4("vReflectionControl", this._reflectionControls.x, this._reflectionControls.y, this._reflectionControls.z, this._reflectionControls.w)))), $e.a.BindClipPlane(this._activeEffect, o), $e.a.BindEyePosition(s, o);
+ }
+ !d && this.isFrozen || (o.lightsEnabled && $e.a.BindLights(o, n, this._activeEffect, a, this._maxSimultaneousLights, !1), this.bindView(s), $e.a.BindFogParameters(o, n, this._activeEffect, !0), this._imageProcessingConfiguration && this._imageProcessingConfiguration.bind(this._activeEffect)), this._uniformBuffer.update(), this._afterBind(n, this._activeEffect);
+ }
+ }
+ }, t.prototype.hasTexture = function(e) {
+ return !!r.prototype.hasTexture.call(this, e) || this._reflectionTexture === e || this._diffuseTexture === e;
+ }, t.prototype.dispose = function(e, n) {
+ e === void 0 && (e = !1), n === void 0 && (n = !1), n && (this.diffuseTexture && this.diffuseTexture.dispose(), this.reflectionTexture && this.reflectionTexture.dispose()), this._renderTargets.dispose(), this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver), r.prototype.dispose.call(this, e);
+ }, t.prototype.clone = function(e) {
+ var n = this;
+ return L.a.Clone(function() {
+ return new t(e, n.getScene());
+ }, this);
+ }, t.prototype.serialize = function() {
+ var e = L.a.Serialize(this);
+ return e.customType = "BABYLON.BackgroundMaterial", e;
+ }, t.prototype.getClassName = function() {
+ return "BackgroundMaterial";
+ }, t.Parse = function(e, n, i) {
+ return L.a.Parse(function() {
+ return new t(e.name, n);
+ }, e, n, i);
+ }, t.StandardReflectance0 = 0.05, t.StandardReflectance90 = 0.5, Object(c.c)([Object(L.e)()], t.prototype, "_primaryColor", void 0), Object(c.c)([Object(L.b)("_markAllSubMeshesAsLightsDirty")], t.prototype, "primaryColor", void 0), Object(c.c)([Object(L.e)()], t.prototype, "__perceptualColor", void 0), Object(c.c)([Object(L.c)()], t.prototype, "_primaryColorShadowLevel", void 0), Object(c.c)([Object(L.c)()], t.prototype, "_primaryColorHighlightLevel", void 0), Object(c.c)([Object(L.b)("_markAllSubMeshesAsLightsDirty")], t.prototype, "primaryColorHighlightLevel", null), Object(c.c)([Object(L.m)()], t.prototype, "_reflectionTexture", void 0), Object(c.c)([Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionTexture", void 0), Object(c.c)([Object(L.c)()], t.prototype, "_reflectionBlur", void 0), Object(c.c)([Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionBlur", void 0), Object(c.c)([Object(L.m)()], t.prototype, "_diffuseTexture", void 0), Object(c.c)([Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "diffuseTexture", void 0), Object(c.c)([Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "shadowLights", void 0), Object(c.c)([Object(L.c)()], t.prototype, "_shadowLevel", void 0), Object(c.c)([Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "shadowLevel", void 0), Object(c.c)([Object(L.o)()], t.prototype, "_sceneCenter", void 0), Object(c.c)([Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "sceneCenter", void 0), Object(c.c)([Object(L.c)()], t.prototype, "_opacityFresnel", void 0), Object(c.c)([Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "opacityFresnel", void 0), Object(c.c)([Object(L.c)()], t.prototype, "_reflectionFresnel", void 0), Object(c.c)([Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionFresnel", void 0), Object(c.c)([Object(L.c)()], t.prototype, "_reflectionFalloffDistance", void 0), Object(c.c)([Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionFalloffDistance", void 0), Object(c.c)([Object(L.c)()], t.prototype, "_reflectionAmount", void 0), Object(c.c)([Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionAmount", void 0), Object(c.c)([Object(L.c)()], t.prototype, "_reflectionReflectance0", void 0), Object(c.c)([Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionReflectance0", void 0), Object(c.c)([Object(L.c)()], t.prototype, "_reflectionReflectance90", void 0), Object(c.c)([Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionReflectance90", void 0), Object(c.c)([Object(L.c)()], t.prototype, "_useRGBColor", void 0), Object(c.c)([Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRGBColor", void 0), Object(c.c)([Object(L.c)()], t.prototype, "_enableNoise", void 0), Object(c.c)([Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "enableNoise", void 0), Object(c.c)([Object(L.c)()], t.prototype, "_maxSimultaneousLights", void 0), Object(c.c)([Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "maxSimultaneousLights", void 0), Object(c.c)([Object(L.c)()], t.prototype, "_shadowOnly", void 0), Object(c.c)([Object(L.b)("_markAllSubMeshesAsLightsDirty")], t.prototype, "shadowOnly", void 0), Object(c.c)([Object(L.i)()], t.prototype, "_imageProcessingConfiguration", void 0), t;
+ }(jo.a);
+ O.a.RegisteredTypes["BABYLON.BackgroundMaterial"] = qr;
+ var Es = function() {
+ function r(t, e) {
+ var n = this;
+ this._errorHandler = function(i, o) {
+ n.onErrorObservable.notifyObservers({ message: i, exception: o });
+ }, this._options = Object(c.a)(Object(c.a)({}, r._getDefaultOptions()), t), this._scene = e, this.onErrorObservable = new C.c(), this._setupBackground(), this._setupImageProcessing();
+ }
+ return r._getDefaultOptions = function() {
+ return { createGround: !0, groundSize: 15, groundTexture: this._groundTextureCDNUrl, groundColor: new I.a(0.2, 0.2, 0.3).toLinearSpace().scale(3), groundOpacity: 0.9, enableGroundShadow: !0, groundShadowLevel: 0.5, enableGroundMirror: !1, groundMirrorSizeRatio: 0.3, groundMirrorBlurKernel: 64, groundMirrorAmount: 1, groundMirrorFresnelWeight: 1, groundMirrorFallOffDistance: 0, groundMirrorTextureType: h.a.TEXTURETYPE_UNSIGNED_INT, groundYBias: 1e-5, createSkybox: !0, skyboxSize: 20, skyboxTexture: this._skyboxTextureCDNUrl, skyboxColor: new I.a(0.2, 0.2, 0.3).toLinearSpace().scale(3), backgroundYRotation: 0, sizeAuto: !0, rootPosition: u.e.Zero(), setupImageProcessing: !0, environmentTexture: this._environmentTextureCDNUrl, cameraExposure: 0.8, cameraContrast: 1.2, toneMappingEnabled: !0 };
+ }, Object.defineProperty(r.prototype, "rootMesh", { get: function() {
+ return this._rootMesh;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "skybox", { get: function() {
+ return this._skybox;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "skyboxTexture", { get: function() {
+ return this._skyboxTexture;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "skyboxMaterial", { get: function() {
+ return this._skyboxMaterial;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "ground", { get: function() {
+ return this._ground;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "groundTexture", { get: function() {
+ return this._groundTexture;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "groundMirror", { get: function() {
+ return this._groundMirror;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "groundMirrorRenderList", { get: function() {
+ return this._groundMirror ? this._groundMirror.renderList : null;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "groundMaterial", { get: function() {
+ return this._groundMaterial;
+ }, enumerable: !1, configurable: !0 }), r.prototype.updateOptions = function(t) {
+ var e = Object(c.a)(Object(c.a)({}, this._options), t);
+ this._ground && !e.createGround && (this._ground.dispose(), this._ground = null), this._groundMaterial && !e.createGround && (this._groundMaterial.dispose(), this._groundMaterial = null), this._groundTexture && this._options.groundTexture != e.groundTexture && (this._groundTexture.dispose(), this._groundTexture = null), this._skybox && !e.createSkybox && (this._skybox.dispose(), this._skybox = null), this._skyboxMaterial && !e.createSkybox && (this._skyboxMaterial.dispose(), this._skyboxMaterial = null), this._skyboxTexture && this._options.skyboxTexture != e.skyboxTexture && (this._skyboxTexture.dispose(), this._skyboxTexture = null), this._groundMirror && !e.enableGroundMirror && (this._groundMirror.dispose(), this._groundMirror = null), this._scene.environmentTexture && this._options.environmentTexture != e.environmentTexture && this._scene.environmentTexture.dispose(), this._options = e, this._setupBackground(), this._setupImageProcessing();
+ }, r.prototype.setMainColor = function(t) {
+ this.groundMaterial && (this.groundMaterial.primaryColor = t), this.skyboxMaterial && (this.skyboxMaterial.primaryColor = t), this.groundMirror && (this.groundMirror.clearColor = new I.b(t.r, t.g, t.b, 1));
+ }, r.prototype._setupImageProcessing = function() {
+ this._options.setupImageProcessing && (this._scene.imageProcessingConfiguration.contrast = this._options.cameraContrast, this._scene.imageProcessingConfiguration.exposure = this._options.cameraExposure, this._scene.imageProcessingConfiguration.toneMappingEnabled = this._options.toneMappingEnabled, this._setupEnvironmentTexture());
+ }, r.prototype._setupEnvironmentTexture = function() {
+ if (!this._scene.environmentTexture)
+ if (this._options.environmentTexture instanceof kn.a)
+ this._scene.environmentTexture = this._options.environmentTexture;
+ else {
+ var t = ei.CreateFromPrefilteredData(this._options.environmentTexture, this._scene);
+ this._scene.environmentTexture = t;
+ }
+ }, r.prototype._setupBackground = function() {
+ this._rootMesh || (this._rootMesh = new Ie.a("BackgroundHelper", this._scene)), this._rootMesh.rotation.y = this._options.backgroundYRotation;
+ var t = this._getSceneSize();
+ this._options.createGround && (this._setupGround(t), this._setupGroundMaterial(), this._setupGroundDiffuseTexture(), this._options.enableGroundMirror && this._setupGroundMirrorTexture(t), this._setupMirrorInGroundMaterial()), this._options.createSkybox && (this._setupSkybox(t), this._setupSkyboxMaterial(), this._setupSkyboxReflectionTexture()), this._rootMesh.position.x = t.rootPosition.x, this._rootMesh.position.z = t.rootPosition.z, this._rootMesh.position.y = t.rootPosition.y;
+ }, r.prototype._getSceneSize = function() {
+ var t = this, e = this._options.groundSize, n = this._options.skyboxSize, i = this._options.rootPosition;
+ if (!this._scene.meshes || this._scene.meshes.length === 1)
+ return { groundSize: e, skyboxSize: n, rootPosition: i };
+ var o = this._scene.getWorldExtends(function(d) {
+ return d !== t._ground && d !== t._rootMesh && d !== t._skybox;
+ }), a = o.max.subtract(o.min);
+ if (this._options.sizeAuto) {
+ this._scene.activeCamera instanceof ji && this._scene.activeCamera.upperRadiusLimit && (n = e = 2 * this._scene.activeCamera.upperRadiusLimit);
+ var s = a.length();
+ s > e && (n = e = 2 * s), e *= 1.1, n *= 1.5, (i = o.min.add(a.scale(0.5))).y = o.min.y - this._options.groundYBias;
+ }
+ return { groundSize: e, skyboxSize: n, rootPosition: i };
+ }, r.prototype._setupGround = function(t) {
+ var e = this;
+ this._ground && !this._ground.isDisposed() || (this._ground = Ie.a.CreatePlane("BackgroundPlane", t.groundSize, this._scene), this._ground.rotation.x = Math.PI / 2, this._ground.parent = this._rootMesh, this._ground.onDisposeObservable.add(function() {
+ e._ground = null;
+ })), this._ground.receiveShadows = this._options.enableGroundShadow;
+ }, r.prototype._setupGroundMaterial = function() {
+ this._groundMaterial || (this._groundMaterial = new qr("BackgroundPlaneMaterial", this._scene)), this._groundMaterial.alpha = this._options.groundOpacity, this._groundMaterial.alphaMode = h.a.ALPHA_PREMULTIPLIED_PORTERDUFF, this._groundMaterial.shadowLevel = this._options.groundShadowLevel, this._groundMaterial.primaryColor = this._options.groundColor, this._groundMaterial.useRGBColor = !1, this._groundMaterial.enableNoise = !0, this._ground && (this._ground.material = this._groundMaterial);
+ }, r.prototype._setupGroundDiffuseTexture = function() {
+ this._groundMaterial && (this._groundTexture || (this._options.groundTexture instanceof kn.a ? this._groundMaterial.diffuseTexture = this._options.groundTexture : (this._groundTexture = new Ne.a(this._options.groundTexture, this._scene, void 0, void 0, void 0, void 0, this._errorHandler), this._groundTexture.gammaSpace = !1, this._groundTexture.hasAlpha = !0, this._groundMaterial.diffuseTexture = this._groundTexture)));
+ }, r.prototype._setupGroundMirrorTexture = function(t) {
+ var e = Ne.a.CLAMP_ADDRESSMODE;
+ if (!this._groundMirror && (this._groundMirror = new Ts("BackgroundPlaneMirrorTexture", { ratio: this._options.groundMirrorSizeRatio }, this._scene, !1, this._options.groundMirrorTextureType, Ne.a.BILINEAR_SAMPLINGMODE, !0), this._groundMirror.mirrorPlane = new ur.a(0, -1, 0, t.rootPosition.y), this._groundMirror.anisotropicFilteringLevel = 1, this._groundMirror.wrapU = e, this._groundMirror.wrapV = e, this._groundMirror.gammaSpace = !1, this._groundMirror.renderList))
+ for (var n = 0; n < this._scene.meshes.length; n++) {
+ var i = this._scene.meshes[n];
+ i !== this._ground && i !== this._skybox && i !== this._rootMesh && this._groundMirror.renderList.push(i);
+ }
+ this._groundMirror.clearColor = new I.b(this._options.groundColor.r, this._options.groundColor.g, this._options.groundColor.b, 1), this._groundMirror.adaptiveBlurKernel = this._options.groundMirrorBlurKernel;
+ }, r.prototype._setupMirrorInGroundMaterial = function() {
+ this._groundMaterial && (this._groundMaterial.reflectionTexture = this._groundMirror, this._groundMaterial.reflectionFresnel = !0, this._groundMaterial.reflectionAmount = this._options.groundMirrorAmount, this._groundMaterial.reflectionStandardFresnelWeight = this._options.groundMirrorFresnelWeight, this._groundMaterial.reflectionFalloffDistance = this._options.groundMirrorFallOffDistance);
+ }, r.prototype._setupSkybox = function(t) {
+ var e = this;
+ this._skybox && !this._skybox.isDisposed() || (this._skybox = Ie.a.CreateBox("BackgroundSkybox", t.skyboxSize, this._scene, void 0, Ie.a.BACKSIDE), this._skybox.onDisposeObservable.add(function() {
+ e._skybox = null;
+ })), this._skybox.parent = this._rootMesh;
+ }, r.prototype._setupSkyboxMaterial = function() {
+ this._skybox && (this._skyboxMaterial || (this._skyboxMaterial = new qr("BackgroundSkyboxMaterial", this._scene)), this._skyboxMaterial.useRGBColor = !1, this._skyboxMaterial.primaryColor = this._options.skyboxColor, this._skyboxMaterial.enableNoise = !0, this._skybox.material = this._skyboxMaterial);
+ }, r.prototype._setupSkyboxReflectionTexture = function() {
+ this._skyboxMaterial && (this._skyboxTexture || (this._options.skyboxTexture instanceof kn.a ? this._skyboxMaterial.reflectionTexture = this._options.skyboxTexture : (this._skyboxTexture = new ei(this._options.skyboxTexture, this._scene, void 0, void 0, void 0, void 0, this._errorHandler), this._skyboxTexture.coordinatesMode = Ne.a.SKYBOX_MODE, this._skyboxTexture.gammaSpace = !1, this._skyboxMaterial.reflectionTexture = this._skyboxTexture)));
+ }, r.prototype.dispose = function() {
+ this._groundMaterial && this._groundMaterial.dispose(!0, !0), this._skyboxMaterial && this._skyboxMaterial.dispose(!0, !0), this._rootMesh.dispose(!1);
+ }, r._groundTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundGround.png", r._skyboxTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundSkybox.dds", r._environmentTextureCDNUrl = "https://assets.babylonjs.com/environments/environmentSpecular.env", r;
+ }(), Ii = function(r) {
+ function t(e, n, i, o, a) {
+ a === void 0 && (a = null);
+ var s = r.call(this, e, o) || this;
+ s.onError = a, s._halfDome = !1, s._crossEye = !1, s._useDirectMapping = !1, s._textureMode = t.MODE_MONOSCOPIC, s._onBeforeCameraRenderObserver = null, s.onLoadErrorObservable = new C.c(), o = s.getScene(), e = e || "textureDome", i.resolution = 0 | Math.abs(i.resolution) || 32, i.clickToPlay = !!i.clickToPlay, i.autoPlay = i.autoPlay === void 0 || !!i.autoPlay, i.loop = i.loop === void 0 || !!i.loop, i.size = Math.abs(i.size) || (o.activeCamera ? 0.48 * o.activeCamera.maxZ : 1e3), i.useDirectMapping === void 0 ? s._useDirectMapping = !0 : s._useDirectMapping = i.useDirectMapping, i.faceForward === void 0 && (i.faceForward = !0), s._setReady(!1), s._mesh = Ie.a.CreateSphere(e + "_mesh", i.resolution, i.size, o, !1, Ie.a.BACKSIDE);
+ var d = s._material = new qr(e + "_material", o);
+ d.useEquirectangularFOV = !0, d.fovMultiplier = 1, d.opacityFresnel = !1;
+ var p = s._initTexture(n, o, i);
+ if (s.texture = p, s._mesh.material = d, s._mesh.parent = s, s._halfDomeMask = Nn.a.CreateSphere("", { slice: 0.5, diameter: 0.98 * i.size, segments: 2 * i.resolution, sideOrientation: Ie.a.BACKSIDE }, o), s._halfDomeMask.rotate(be.a.X, -Math.PI / 2), s._halfDomeMask.parent = s._mesh, s._halfDome = !!i.halfDomeMode, s._halfDomeMask.setEnabled(s._halfDome), s._crossEye = !!i.crossEyeMode, s._texture.anisotropicFilteringLevel = 1, s._texture.onLoadObservable.addOnce(function() {
+ s._setReady(!0);
+ }), i.faceForward && o.activeCamera) {
+ var y = o.activeCamera, P = u.e.Forward(), R = u.e.TransformNormal(P, y.getViewMatrix());
+ R.normalize(), s.rotation.y = Math.acos(u.e.Dot(P, R));
+ }
+ return s._changeTextureMode(s._textureMode), s;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "texture", { get: function() {
+ return this._texture;
+ }, set: function(e) {
+ this._texture !== e && (this._texture = e, this._useDirectMapping ? (this._texture.wrapU = Ne.a.CLAMP_ADDRESSMODE, this._texture.wrapV = Ne.a.CLAMP_ADDRESSMODE, this._material.diffuseTexture = this._texture) : (this._texture.coordinatesMode = Ne.a.FIXED_EQUIRECTANGULAR_MIRRORED_MODE, this._texture.wrapV = Ne.a.CLAMP_ADDRESSMODE, this._material.reflectionTexture = this._texture), this._changeTextureMode(this._textureMode));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "mesh", { get: function() {
+ return this._mesh;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "fovMultiplier", { get: function() {
+ return this._material.fovMultiplier;
+ }, set: function(e) {
+ this._material.fovMultiplier = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "textureMode", { get: function() {
+ return this._textureMode;
+ }, set: function(e) {
+ this._textureMode !== e && this._changeTextureMode(e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "halfDome", { get: function() {
+ return this._halfDome;
+ }, set: function(e) {
+ this._halfDome = e, this._halfDomeMask.setEnabled(e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "crossEye", { get: function() {
+ return this._crossEye;
+ }, set: function(e) {
+ this._crossEye = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "material", { get: function() {
+ return this._material;
+ }, enumerable: !1, configurable: !0 }), t.prototype._changeTextureMode = function(e) {
+ var n = this;
+ switch (this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver), this._textureMode = e, this._texture.uScale = 1, this._texture.vScale = 1, this._texture.uOffset = 0, this._texture.vOffset = 0, this._texture.vAng = 0, e) {
+ case t.MODE_MONOSCOPIC:
+ this._halfDome && (this._texture.uScale = 2, this._texture.uOffset = -1);
+ break;
+ case t.MODE_SIDEBYSIDE:
+ this._texture.uScale = this._halfDome ? 0.99999 : 0.5;
+ var i = this._halfDome ? 0 : 0.5, o = this._halfDome ? -0.5 : 0;
+ this._onBeforeCameraRenderObserver = this._scene.onBeforeCameraRenderObservable.add(function(a) {
+ var s = a.isRightCamera;
+ n._crossEye && (s = !s), n._texture.uOffset = s ? i : o;
+ });
+ break;
+ case t.MODE_TOPBOTTOM:
+ this._texture.vScale = this._halfDome ? 0.99999 : 0.5, this._onBeforeCameraRenderObserver = this._scene.onBeforeCameraRenderObservable.add(function(a) {
+ var s = a.isRightCamera;
+ n._crossEye && (s = !s), n._texture.vOffset = s ? 0.5 : 0;
+ });
+ }
+ }, t.prototype.dispose = function(e, n) {
+ n === void 0 && (n = !1), this._texture.dispose(), this._mesh.dispose(), this._material.dispose(), this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver), this.onLoadErrorObservable.clear(), r.prototype.dispose.call(this, e, n);
+ }, t.MODE_MONOSCOPIC = 0, t.MODE_TOPBOTTOM = 1, t.MODE_SIDEBYSIDE = 2, t;
+ }(pr.a), op = function(r) {
+ function t() {
+ return r !== null && r.apply(this, arguments) || this;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "photoTexture", { get: function() {
+ return this.texture;
+ }, set: function(e) {
+ this.texture = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "imageMode", { get: function() {
+ return this.textureMode;
+ }, set: function(e) {
+ this.textureMode = e;
+ }, enumerable: !1, configurable: !0 }), t.prototype._initTexture = function(e, n, i) {
+ var o = this;
+ return new Ne.a(e, n, !i.generateMipMaps, !this._useDirectMapping, void 0, void 0, function(a, s) {
+ o.onLoadErrorObservable.notifyObservers(a || "Unknown error occured"), o.onError && o.onError(a, s);
+ });
+ }, t.MODE_MONOSCOPIC = Ii.MODE_MONOSCOPIC, t.MODE_TOPBOTTOM = Ii.MODE_TOPBOTTOM, t.MODE_SIDEBYSIDE = Ii.MODE_SIDEBYSIDE, t;
+ }(Ii), ql = function() {
+ function r() {
+ }
+ return r.ExpandRGBDTexture = function(t) {
+ var e = t._texture;
+ if (e && t.isRGBD) {
+ var n = e.getEngine(), i = n.getCaps(), o = !1;
+ i.textureHalfFloatRender && i.textureHalfFloatLinearFiltering ? (o = !0, e.type = h.a.TEXTURETYPE_HALF_FLOAT) : i.textureFloatRender && i.textureFloatLinearFiltering && (o = !0, e.type = h.a.TEXTURETYPE_FLOAT), o && (e.isReady = !1, e._isRGBD = !1, e.invertY = !1), t.onLoadObservable.addOnce(function() {
+ if (o) {
+ var a = new ft("rgbdDecode", "rgbdDecode", null, null, 1, null, h.a.TEXTURE_TRILINEAR_SAMPLINGMODE, n, !1, void 0, e.type, void 0, null, !1), s = n.createRenderTargetTexture(e.width, { generateDepthBuffer: !1, generateMipMaps: !1, generateStencilBuffer: !1, samplingMode: e.samplingMode, type: e.type, format: h.a.TEXTUREFORMAT_RGBA });
+ a.getEffect().executeWhenCompiled(function() {
+ a.onApply = function(d) {
+ d._bindTexture("textureSampler", e), d.setFloat2("scale", 1, 1);
+ }, t.getScene().postProcessManager.directRender([a], s, !0), n.restoreDefaultFramebuffer(), n._releaseTexture(e), n._releaseFramebufferObjects(s), a && a.dispose(), s._swapAndDie(e), e.isReady = !0;
+ });
+ }
+ });
+ }
+ }, r;
+ }(), Ho = function() {
+ function r() {
+ }
+ return r.GetEnvironmentBRDFTexture = function(t) {
+ if (!t.environmentBRDFTexture) {
+ var e = t.useDelayedTextureLoading;
+ t.useDelayedTextureLoading = !1;
+ var n = t._blockEntityCollection;
+ t._blockEntityCollection = !1;
+ var i = Ne.a.CreateFromBase64String(this._environmentBRDFBase64Texture, "EnvironmentBRDFTexture" + this._instanceNumber++, t, !0, !1, Ne.a.BILINEAR_SAMPLINGMODE);
+ t._blockEntityCollection = n;
+ var o = t.getEngine().getLoadedTexturesCache(), a = o.indexOf(i.getInternalTexture());
+ a !== -1 && o.splice(a, 1), i.isRGBD = !0, i.wrapU = Ne.a.CLAMP_ADDRESSMODE, i.wrapV = Ne.a.CLAMP_ADDRESSMODE, t.environmentBRDFTexture = i, t.useDelayedTextureLoading = e, ql.ExpandRGBDTexture(i);
+ }
+ return t.environmentBRDFTexture;
+ }, r._instanceNumber = 0, r._environmentBRDFBase64Texture = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAgAElEQVR42u29yY5tWXIlZnbuiSaTbZFUkZRKrCKhElASQA0EoQABgn6hJvoXzfUP+gP9hWb6Bg00IgRoQJaKqUxmZmTEe8/v0uB2u7Fm2T7HIyIrnz88uPvt3f2a2WrMbOvf/u3PvvzP/sUf/N6//i8vf/lv/3v5H//d//Sb//Uq/5u8yf8hV/m/5Cp/L1f5hVzlG7nKJ7mKyJuIXN/hPwqXI/g++zq6rPI5u8z+WqfLre+zy7PrVv9L8brsMiGvk8XLmM/sdfHXal4e3ad6GXPdyu2ij8u/+uv/5cuf/OSLfdtEfvUr+dnf/d0X//t3H/7bf/hP//N/928h/0Yg/4VA/kogfyGQP5Wr/IFAvhbIlwK5CGQTPP+9z5uPeePJSW+yo2+s/GtN30Rnv1E+f5zxof9R/lSXv/nr//mrr3+i+5dfyX7ZZQP07Tffys//8R/l/9TtX7790T/7r/8G8pdy+/8XAvnnAvkzgfwzgfyxQP5AIL8vkJ8K5KsmMVzu1U7p5PA5AXxOAJ8TwPf7sX/51ZeXfcemqnp9w/W77/S7X/6T/vzf/7383RWCX3/z05/9i3/13/0PX//eX/2FyP8tIv+PiPy9iPy/IvIzEfm5iPxCRH4lIt/c/393//9BRD6KyKf7f488fP74/PH544dJAF9cLl98IZfLBZtuqterXr/7Dt9982v95S9+Lv+gF/3i7Spv/8lf/vnf/vGf/dF/JfKnIvLnIvLvReQ/NEngn0TklyLy6/v/34jIt00iGJOBlxAsdvv54/PH5493SQCXy9t2ueh2ueimKorrFbjq9eNH+fDtb+TXv/ol/vHyhX4Fxfbx7euPf/Lnf/PfiPyeiPyhiPxxkwB+fk8AvxzQgJcIrGTwFsiAEXH4/PH54/PHUgLY7whgu2C7bLqpQgHB2xvePn6SDx8+6G9+84384vKF/IPu8iVU9Y/+7C/+jWxffiHytYj8VER+X0T+oEEBvxqQwCMJeIngo5EI3goIwVMIPn98/vj8ESaAbbtu2ybbvl8u2ybbdtluSECA65u8ffqIDx8+6G++/VZ/efkV/sO261dQXP7wT/7kX8vl8qXIFyLylbySwe/dE0CLAr65B/9vGn0gQwRMMqgmhM/J4fPH548eAezbZd/lsm3YtssNAYiqiogAAkCvb5/k46cP8u2HD/rrb7+R/2/b9Wu9yJe//8d/9Ney6S5yEZFdRL68/38khG/uKOCnAwoYkcCoEXwkEgGDDq7CeQfyOTl8/vhd1QCum26ybZtu2yabbrKpQvXue1yvuF6v+vbpTT5+/CDffviAX1++1V9sO77WXb/66R/+4V/dgkbllQi+aBLBV/dE8LWRALwkYCWCNyMZXElkwLTMeMkga/P4/PH547ccAVwuctkvdxSw6bbdtYDbTfSZBN7e8PHTR/3u4wf55vKd/nL7DX6mu3791U9//5+/gkNFZGuSgZUQvnKowKgLWLTAQgRtEniTuEfwaELw0MJvf3LQzynud+53uG+X6y3gN9kul+2y6XVT1U27JCDAFVc8ksAn/e7jR/nN5YP+avtWfq6Xy9f7Vz/9w1dgRYngiyYhfNkkgzYBWHTg44AEMmqQUYQKOmDaiCIa8TmsfmzB+DnZDQjgcpGLbti2y3bZHjRAdRMVvb/dcYU8kcDbPQlsH/CrbddfbF98+RPZfvLFnAQeieCRDC5DMvju/vmD4JkEvjRQgKULeGggowdHkAHTYxihg89vu88I5UeGAPSOAFTlrgPopiqbKPSmCKreUoAAkCcSePukHz590m8vH+WbD9/JP335k6/+tA86KxFchv8jMvhiogE4JQm8XhfKqOAqx5qRPyeGzx8/cgSwbXcUoLJtim27C4Oi93+4v6VxQwKAvl2v+Hj9pB8+fZJvt4/yzfbF9lPdv/wJnsE2BogmyeCRED40tGFvksIXiSbgiYSRRpDNDZ6BDI6ghM+J4fPHeyKAO+zX7cb9t4tedMMNAQju5V+f1uAtBSiu1zsduMrHy5t8ePsk3376KN98sX/xE5FPAnm7/782o0DiUINXMkCXCB7/P94/e87AWUmARQWVvgMuKej9t1RLBp+Tw+ePgwngsutFFdu26WXbbl+rSvdfbnqAiuA23QcBgCugV1zl7e1NPm5v+LC96XfbJ/1W9y++fgXjA3bDYXV+MuhRwSPwL3JLMFYC+HS/LU8HYrGwIhwyNOF12SvgM4SgztdifP85MXz+KGsA2C6X7aJ6bXSAOwrY5OYIqGy3d5uq4P5GhABXuV6veLvRAf10fZMPb2/y3b7vX7+g+9v98/WOBq7GG7RNAlYy+Dgkhhb+Xxp0sE8IAC4SGAP/TbgVJK/PoJPBnAiwPKxsXfbbnRg+i3s/JAK4Q/4b9NfLtomBAqCickMBjy7BuywAUVyv8na94tMjCVzf9KNcLl/0SeA6oAEYb1i9g+FtSALb/bKL8/+t+wxXFMyswqiHoK4ToIgKqslgpg1qUC0QoYbvJZg/B/q5v4szHmPX7YEAsD0CX25OwEUVm9xag1+agKg+nxQArnKjAtDr9U0+Xd/k4/UqH7bL5YsewrcBBiMJZPRAp6TwQgWfjM9vgRbgUYGL8AvLWH2gqhesCokeUmCSwPsnhs8fP2YNYMO2XeSmAWxy2VQaXeDmDIhApf33rD4PTUCuV+DtCn27XuXT5ir8VmCJ2G5BpBM8/r/dEcJb8/0lEQMtJHA5TAlqNuLRhJChhEpSqFabH3di+G1AGj+W1/dyAR4IYJNNnuLf6+tWC9CHHiAtFhAIFLjK2/Uqn65X+SS67aK+3QeTDoy/IG2ogQ7fb/dAtz5vBgrYGqrwNtCHsVfgIvwK07OTQBURVNCBFpKCOjqCHn5L/67TgTN+fpySAC56nwSUi256kXsSuFGAVyLoUIDo8/Pz7fdoErr/v17lk162HbgHvFpIYDfoAJJfW4sGPjkU4VNAF8ZEcLmLhdc7kljdY1y1Dq9yLiI4IiRqcLujb138KIPn80ejATwRwIbtBvn1cqv+2J78/5EI5N4cJA8qIPcmwRsKAHDF9WYP6mV7VmrgLuTpxYTcMEW0LAmoQxFsuvAI8tv/a/C5fV2ZMMiKg++FCM7RDPRu8ebWY7VG6VJi+Bzk35MI2LsAckMAgwvQ0gC5DQjd3ABg2HQLAPpEAlZ1Bu7VV7MGHDFRAbo3VKsTbAY9sPWC/uvx86gBbDK3D1eEQS8pbAeSgSwmhepnJb6uBv/o/PzHLzxWA/X7TH77De5j6AGQi6o0CUGfCOD2X7cXAlCFQABtEsGLDtxuOyQB2UTQBKZe5GUPXgkUYCUAbZJRhBDeuq8xBf+bgwbehDm+BFQi2IJksOocvA8ysIMfxluVcRsY/eB3JzH8GFDAXQO48X/dcIf9jyDHptIigDsFkEe066tBSETQUYF7ElDdYEBytN4+rk9UcBPfrKaZqFHWcw3i4J8/X4ev2//bSXqAhwTay6OEIPLD2Ipt8OtAGzxkwLw9WVFRjTc/qC6H3+YK/b1oAA0KuOizHfieCLaHHiAb5NYTIC9EMEbZrVEQt1xwhVy1UfBh8PUOquMizwaap3tQXfY5B//tea/NZdfhsvbz+PURQTDSGWB87VX/7WSd4KxjUqrIgE0IUkoKGnhIvwvawpGf6eECXJ7tv4qbA7DJgwpsKthEmmYgfaAAffYF3HLxo0vwNjJ0SwRWMG4db4eh1gPNm18vQ+us/0eGmxDemu/fnM/X4evq/8342ksGHgLY5LyT/zg0wM8lcMjgGFXwqIOVFJBQw99eCvF9oZL9Mfl3QwAvIXDsBRC9R+fz8x0FPBLB0xJEpwUobrfAkARgIAF41h3wQgP6QAmX5E/7eI43IxGwwf/moIkRyWRJQIPgt9CA9b39nzt4bYUWjAlCjWDPgv8IEjgLJfzuaAsrv9VdVG4OwOXW/fdoA35qAdL0BDwvf6AAUVHd8LIEu94A3K+Q+2YxaB84MOH62P//qoo38fCRDERE2zf0JfmDa+MieElAjcDPKz+mRKCOtdgGtXaBjgNJ4H2owSpNeAW/rRH4CaHSpMwnBYYycjgSJwfie9CR6mPu20Uv8kABF206AvXlBMiIBPSlB9wjBW1fwEuSb94296VCqgMaGCt/G1BbExi3IG+r3a3J6P48Gv/J0YmEYoiGY7V/SxwFCwGoE/xa0AJ0CEiV9QPCJb1OJ5F1VTjEY2/MO9AEJvj1BJTQpqLfTlGwjABuzT962e4IoKnyrdh3+/6mzDVJ4PHOxj0JqGKoy20+wBMN6D1gLWi9NQHfVP5MEEPzjGYy8BMAOnTAJgEr8HUIejRo5xrA5xkR5AngmiSHs+zDDAmMgWzTg55GSJEmHE8IvWPAoYTfhWak/Wn/bQ0CGLSAjv83SUEfKp5q24LXuQICpzrjrgWoza8xVE00CQCORdhMJuTUT/rjuls0gO4Iby8BIEgK6gS7BsGuTtDrScH/fR68biUHNVGBnxjeNyHEvQe/ve3LZQqgG3rof6cEclsNflG9J4KtaQ8WHcVBHS1BtHE4QP9OBMS98mpbKTeDW7dJwRsnHpMBTFJpV4I+b0kY/NqInVFSyBLANbnMSgBM8F+Fqfxq/h657/Up+GaBnwV9hRqc9bZ/vA6vu+T9E8KPJWns94UfTeCj2QXwCHS9dNL8Xf3Ho/rfewSeFODGDV69AU0y6NFAE1DP3qK++rdB7/1HRxf86gT376zOr99T/h/ioBiXWQkgQgVeIrCC/WomhDmQK+hASI2ARQZKooHMLdCJwGEBBXC3+uERwg+VOHZ9ioAt9H80AI06wGgJ3nQA3BoCut6AhxYwgcPOFnxuFnrphk+NIKIGrWPQtgz3b0i7Y6D5rs1GKqTop0nQX52vmQC4BkjA+r4a7Kx9WLENGeegkhSETBCrNXIMdi/444Rw1n6E96ry7OPuj8UfLxtQ78NA2iSBbg7gIiIbdDLsb5agPhLC3RkYKv8NDbS2YGsatNRAG2oQwf9ZIOydgy1MAzBkAw8UwEEIDzSAqdPQ6za0PkeJAMH3Z0wXniUSZoHvBXU2mcjQgv56TedIKglCpIoQfgwCIjOytd8WgN0bfxoR8Fn9Gx0Aj5Zgq0lIZbsH/ibSJoFnS+C98g9ooHEELI3gliy25yONIiE6pb0NfBlyNEYyENoodkKwgl6I6s8kARgJ4ZoEfuYWHLEJa0LhSBXm7kImGeSfVdoJ1DO2G7WXsehAptupSOoyrCSF904k+6vt98X/ZcM98Hsd4JYIXhQAIg3/f9AAUYhsLQKAtkHVBnzjCKhOoYl2ym+iBtvzDzQ2DLXJ4PUmbJHAVnBQX4jkxfvHhNDqAdHXGQJgv0aSDGItgOseHIU+K9hXnIJzkoGlEKzNHagTdJ6VWEUH4iCKH4fd2AwDPaYBm4Wgng4gQ9V/CoGiuNmD04AQtNGMGzSAAQ2I2pzfogY9LRh7BrbOh4+D30sAencljFu2CUFrwY8UAWRfWwGvVOVfbx2uIILM0pwDv082dUTw8hYs8L+uIWiHGpWgClnAa1lMPJogovvvbePPs/q3Xr++kgCsfgB5oQF9WYKPJqEn6G+OE3i5AqouF59FQOmahQC8rlPLj38kg1c2f30vw+XaoIX24/pMGIgSBoZqoH3wo0sIIGlA9PWcCPrAtpPB8eBf6x1o6cHra+2+tpIFP4PgBfxZtZUJfo4qxELT948D9ucK8Mt9+ccjIQw6QJcEbrD/1g340ATuDgDkFfx6twSf1f9xvuBECYxq/7ythQQGm+5JDx6Brw4CkMGT3wgscCUoQ4sU2t6DR2ciBjTgtcpenQoZVX9NuL4Owc+dVaDursYVkVALX+shjSBKBuvCYDUZjE5BdNkxdHAUBexyHwB6NP7Iyw7sxUDViwge1t+mz8B/LAvVx/c3PeBBCToB8IUGOgqA3iV4yUg6UAOxaUFHDx6CYS8SorMOue0CCJGAf5YfRhoAI+A1CvwxqNkAY5yAIx2EQmkFfeWOXi+nEdSQQA0ZHMEItiagJArQxDXIrj8nCfQi4HZPAttrIahso9oPQ/2/JwV5JQU8zw+7I4D7/sBn4EO6rjw0FR+i3Z9fHtahzsFvJgM0X+tmVH5vaYiNDGAigewAz+gyNLThnjCURQFR1b9d3lZvnVqmj9mEPDKIUIC4KCCjBXywS4N+otp/Hk3QVthOkwEKlV9PQwXjT7s/zwF4Qf9toAAzFdjuaEB6S7D1//U5FIQu2MevO0rQQH8ZmoXE6B/IkgE60XCjVoq8gt2iCG0S8L5GdxkM1cGsfsCMArSCAnrr7dzAZxCEEpepvB8tqHJ/q+bmJGGts/AcAXFOMMeTwC7Pw0B6CtCtA2vWgonqBQJFSwH0JQK29OB2kvgj2HHXAoyeAIsCQO0kMNECAhFMqCBf8mElAkyBbX1tJQP2RJ/ha0gpAfS9l+/5n00CkrQpq0MZbOdAuxmMvHswog62jZj7BnYQe19b14kxNq2D/ehX/p68HEcF+x3yP7z/V/A/q/5DA3i5A/dzA5pdgbKp3v3/wQF4Bb70WkCTHGRAA6+KL0bFl6FJaFw0ImZwm6igSwbbwPn9RMBWf3sN2JgA/BVh/Rg0kQBgePf6HglAHLFQwqQQOwDjbdVxNZjR4iM6Qa3WxwvNxh0JFb3g/WzFQQS8b/ttKcDWoABtUMAd8j9hf0MB2uDXhzX4CHj03L9DBU3Qjz0C0l4mLSLQPicOOwZoVCB6P6dA7nDbGkVuxcNr8PU2JQO4wX5trEqmccZaHU4q8oCDFOpzAnOwqyMIMktNNNAHouDGxO37DgArQZzlmp/14W1QlqHTMaIIx7SCx0+5yza7AKJ3IXBrNAHVDcMZAU/BT/vgv/ULPOA+XiLggAREDF2g0ci6xNDRglegd7P7TWWH5oJfayliEg7bScQRBVgI4Ookg/F6rvpLWP29swREqA3CaG8/FpKqS8DTAV4TiBqIqtxfzaQRLys5I0XEFIFrPbZRQb+16Fgi2LvJv8EFUPW1gGfQv1T/F/d/HBnccP7rAwnIIyHI4ArgWeGbU4eHy6Tx/EeTZIb5bo/BsMBjmjBE08f/RB0PHYBd9eVRAGY7cHRwiBf8WeCPHY1bgBTa9xKTELzEkQX9CPtl0gJiqsAmCT7I8xbjivh3JGFI+D2nBcSJQJ8agDX+O9iBL7UfG4bzAkcaICrbtYHz1ycSmGmAjJfL3CMgT3tQpmrfB7gxSzC1DnvdhQMieG47u75+kTouKNkM8c/+vq/Q7ZYjO/hhVvRq8F/9gGfhP8aqE9EIdR6LTwJ1h0BItyDqB8iFwuNqASscRnYioxOg9ApvnYA35f8e9Ohbfe8J4rknoFkO0lmA2gmAG0YK0DkB4ieEjiLoMD8wBzom27ANZkzIoU8EMHk/uo1mzeVoEoRWKn8L/62EYAX/lsB7D/LXg74uAMr9oGivJ0CNJCGD6i9DhZdQF+gtOp4S+NODRzsDVbhdgv4BqTMNyIL9SCKwL9/FGPp5oQKxIf8A/UX6r231H7YIqLML0Ae2GtrADOvRQH5b/MPE9dt9BGLNG8jVTAQvIaK5TtvvvWQgDvyXIClUA78S9Nfg7VtIBlO7cbsEYkQDMot+ygQ7QwmOawTHnAM2XUSnJvPIYRYMmYPS+sv3J+cfP3d04JYIXsF/EwMbBKB9Q9AY+BiSwFj9mzrSXmcJhFPVHySTbgHJCPvRQ/z7G/SVUETsg0ZF+i3CRoCjhf7y1A9mOiDD7TwdwEoEXjLwAv+avLE2B7Jnb+OqDpBoAchoQJskxKnss0vu7Q2YhcDv4ySeLOg9GsCKiUIihP7yfW7zbTsBh0TQfN0iAWn9f72Z56/Ax9P7j5OAH/Qvv3/QxKfk0DgDuP+R3USg3bzBC7bO/QT9Eeh9QvDPG7glBQzJwK740lAFFgFk8P88CqDGAa223YckWYhr+c0BPdwetl2ocnsfzePAWcVnnAIp6gDVhDLyfV4nqFEDPxHsbWD3k4BDkN+pARqKMLYBPzYEvxp9xmCHQQdgWH/9EtH2TIFpu3AH/cdGydv1j0TQbRrq+D/mLcX3ZACZ15bF378CG0My6Kq/zoGOQwhASDFwFbxyNGBuSxbCEhQ/uEPe/6gAERWQObCVVfjPpQX+rexxYhYFxIkgpgX7Y/vPs+Pvxf9vwt8kAs7i32t3QCP+3SPaTwIytQXP38u0PESm+YER+o9B3vr8mETAUfDrEkPI80ck0FZ0dXh9U+HRbhey0cAc2H7A4y4egoD6y8JfkBiigLdFP8v2W00E8deT2IeAKujZ/QAVKpAtKI20gLWksHedfgPcb+0+NEHefd9vB9rayi8h7J91gBbaw20MsnWAF5xHkyDUCOoXp+yrOwwxcKj0aL6fFppaaKDv6OpHR5sgx5BAlK/+fYhuP1D196o8e7lFBaKqv5YIMnFQpd0FGVR35RJCnCDaABaXBtgbiSwtICMtalKC+1JQ6bx/PLcDPQL91QFodQNKpwOgF/9eqcBxBBqRcKAAVk+ArQOMx1RYGgB6naDhlK+uQQwJYx4meQbxtNnYQwMjt/d4f3M9ZE4UOld1LAh99fbfzOxiEkKFCkTJIUIMUeVnJ/9sDt8/e1NEJOi9oVHDGYhgnSLss9DX2IAqw1zALUncKcDr0FB5NP+0cBQNrEezDiyiADPkt9qGpwoPdL0AGPx/NOKeyf3b9WJNdfcFv6bKd2cLMJVfJ6Y3B6wB9WFUfWWEwKMfGiQL+3bz9XGQz2EHKhF41GCtZyDi/gUCsNhYoAr3UNJ58YidHKqnMb/6AB5J4N73/4L+t7mAkeeP3P+1LNSB/l0SkMEd8DcEuUlguEw6t2AU/PCE/q++Akw6QFf1u6SBrj1ZnnhG50AfkoGIdf7gJv1KcSfgzWWkQ9U33Z3tHXYASKJ9e/YhU90rvD+q9Ej69/wxYJVs506Eg/r3DkMDzEdDBRGgcZay49XihLA30P+l8N+hf1f57/0AoxbQbwYaan/rBMirE9Dk+sBzTkC8JNDEUlv5McB8PP19Y01Gayep+hC/2zvQ/2HGLAurowsNGlA1cnqGGzeH5weiYLZm7h3QQC4O2tXdhvMMk1ZS5ebpgI8eMrPvPGkwaxayk8Yc6PMOBPEdC1XZ+2UfbfOPtxLMQQAG9BcZFoF0gp/RKjxe7+oAw9T7ZPWhgedodgz0gf5KBtrtIZhQAZpAV1Bi36w6t98qVfH7hqGI318lLCjLCUFlxRHwqYEH9a2qb4XjWvDT7kBwfbZA5P0+PNuRuW1yf4yNQH3zzwv6b70QOJ0G9OT/dhoYRUGT15uQH/71MjQLtQlxfDuiCXrtM+SkA+icQdH6sU/xz7Ze7FlubV4TpoTQ2osdpaEjtqADmEU7OkBEFoLeC3IWFFeswJXKXzkboNL+wzcFHU8hTGKIboO7CLi1/P+5F+gydQhuvRbwEgxvtACmANikhLTbj0gCYk8KdlYgmj+4Ymaod7TwahwadICuX0Cm2fE5iNHPK0x/CDV66Kyg1MnqjNFBnhBoLQCgUULfaVe5nq/6EQWY67bXCszUb+7232fVPz51iGB12owK9peyP1T4raMFF/OEYJP792mgXYfZ04GHMAhBkCSmSj+dKqRPgVFGHbpLEGMiGFeQWfSgrY52VxaeDUPSNJI0P7NoisG729HHl78z6hxfs9rV3m4JjgM/lsui2qmThjCfDFSb+I9vwUqG5wwL55U7C+6ot8B+7N2o6r3q37T9trfpjgmTvv7PSQATLLeRAOZhIJHBQfDQQJPBdUwEbVW3+L08EcEE/9G4ANrCeWcnPKRHDupbNynMx5AA9IRYLmrc/YLSiD5EaEBS/s/TgnU9ILcH19n+CpHwegLejx7Mn/d25fdN+e9U/1vgb7bqf08MOtf8EXxaoh+GY8L6gDfhvs4i6HQ7seYI2sv1GchdMsBIG3xlvxcCRzdgCPTn+6q/TW00VE8Q9FaFv+R2VlOM1vm/hhjhDCdgNflVKME5B47I9xT8z0YgPAJ8myb/LqHy36j/Mwqw9AALxuO1JVjiuQAYLcFzIhiEPe05fk8tRjGw7yWQbsfuLAT2VqOId1osnr0F49VM8INACPHDoBz4B5mqqSnUgyh3ArjXxfQH5BbgUS8gP7aU+w0zHD9GGD0CGHf+P1p/DeivlhU4BbxR9a2kYFR58YaDZCUR2P0DMmgED2eg77puegy6PgDphEB0CwlG/i9d+/Hs34pBEQrBn0W51mqGnJAk3ACCHeiqkQ1XFQA5AlKH7Lk8yJKWY3/nym14h2C3JvxeMwD9ZVMz0BPMi1n1RbKl1cYhIVblF3G0ATsRiCMUvoK9//OgcwYMoe+ZKOLlC6/Xk50br9NFz9fanqA8UIYSpCwlBO4kHc4WLLBfBHVaKwKgLQjmP4Un61Vq+3s7Bsyi0WztmLjJwJwFeE0I2vD/1Q6MVwefxfUf32skCPbCnxQqf+QMPEUDHZ7vGeyj020JgkPXXwsldA7SYR1RE3h94NvNtugswcgxXEkIcBPCGZ1rmrgDC0A4K88nm2fn/eTnpQtWyZfybRoK8Dro4zYDIMGsf7saTBzvX0SMbkAD6o9CYbsfMK38cJKD9l2FJt9/VGs0h5Gib33pxMKWNsigFUh3G2un+/N1WUglI/EEx8fq27vUNnwsiOoKecL7kQS8VnWAGCFUgn6dBtQhv40CmIYggwK0uwDHRGAuBXVdfwzHUjZzATLMAoyJ4FmBhzaWBlrHld9CCWpPHRqofBqMReMGTJ78q9rDes1Tv7/0m0v0AFHXNR6P6g30SHivin7V1BOhh3iWPwvps/yE836L2XiwnUT8x2iHgfqhnwn667QHEE8oLQjEvtEW7GYBZDrDVkwNIO4G5GiBDf9fGoFM6n+vbEtzXwP6u9AduaWnGYSLAlVdl/AU+ikrSeEIKgwdaZ4AACAASURBVKj4/wtgHcHtdO2nWKcBkPfxcvnNQvsj2Me9f02r76T8q0IBn9OLKfz1HX8yVXQYGoAB/2UeBQ5/5kCL6+H/OGGoRnLSwdd3oH8r7KkGTbgIxEwVWvnF8KOpHnyzfF9Jod5Px+IF1h8owyitDw/XEgRb5bPqbt1uvn7qBIQ16vtS/u+DP3cR7CH0WWJgd5mTJKYgNzoGjQrfvu99NDBC+bnyW1x/qhTatv2OaMKgJWPvv5kwnMgxHYGFRtJW8VMl3uP+MgoqSZyWFKr7+KIDw1d6+IiOgZI4+d5iYL3imzbgyO+tph9t2oSBxOM3ugHtPoFZ1LM0hF4kXNEBssvVgPdjdXZWK7uKvyS3q1Xb1WQwtVDqSUggq+Vw3t56JA2cz7PXOwGNW1ecwxPhfe3QEUsDsFaAz8jg0nf+iZMAHNg/XSazDuC18Iq1HBRrOsAQ8NLB+16g614jmuSgs3bROxE55D+WDDQNA4ivdMJ9M1b309UqknaDU8ObV9/PwmMPATvTMAxpABLBzugUtV9bLdhNDQA+7B9tQJ06/7QNDHGSwtgZOCIA47InIoDdROQGtt0U1HI3GaoUnCnC/rzBMQJteN17+VaAzYNA7e+PFqHQUyXPUYB7iQYa5ZFjq1Zqpx8Uqu/XT7+6BWC1Xaj0GlBIwMoHu7UzcI/6/Acb8KIq+hzmGWmAYnADrIpvKP7TZeLaf0LAeQkGgebbq9FToI44p654F47tekKkI0L5PQNZPsDwPBpy/ni+wKMN76Vav4+2cFZFf8+JwAraMt0DFB7beA/u4Zz/a+RXx0M/ct4/jwaNAS8G17eSwmta0Fhx0VRxJkHMivso+onMXr+YwdWKbgioy1jp4x4AzIKg5lEA7wvHEYCRmdx11TAuT6lDLVl4KvXkAET9P4RT8H2u+lg9EPQIpw+/NpJ7RwE8HaDv/Mu4f3OdNkq/EfAiEiOANjEALvcWL9gfFV4NZbgbQc6qPky4Pm35QZxtH1f4j+P/jXuaYPcWwIEH/fmEPBoAO4m4LGxV3txOQqDU+dXgey+UwSzuqP++uImO/u/6ogCb7wTc1n61sL+vZi87rxnrNas+giTg6QLzaUCjIp6JfhwtGI7AjBBB9JjDY4ePYVR6ZPgN4owVv6Q2N5hhVHwNeYrM+w6dN6K1sMHZm/Ce7bHe3dzKr1xw1w4JrSQMZtgnoQHlr18fzunAszD4qurNUg/TDqzx/lfCaO6t4tACMUQ6P6htWjDPC1hCoZ8kpODzJ70MUR9AODcgwyqyPhmE+wfHYB/hvSqt6qeXUShhXH+d9SR8DzrDaZZdpSp/HxqLMQuATgDU/qDPRgOIeT8cvz/h/XC6BtE7ACLOWPE0KIS4UUjmZaJ2grBphiWgT41BUVWZfP3AnEIT6OrfoF122l2rMycBoU5i/OXoUZ4/aglsXwLzHNU++FVF3qikOj5HXm2PBitT1WuvJRAB+6O//W0/PY8vQH5IrAsMs/WuVmAdHBrQgrbOxJShXwRSsu08h8JMBpo0+aDTALwV4tbswgzHrftG/dJKIAQb5h9KCssWIMeto+GYqG12/HWGjx8kzqNJaa0noMWOr2KwW01AMwJoNvhMQda2/RKQP/3ecABM3g9uD6BY68Ntz9+nDOMb5iV+hIE+dP/Zs/wwJhJ9mgBnohBuStABUXjugF3hkXF9ZZJAjefKdHZCc389LoStKvIl7QIEb1d9RyciQgFDI9Cjyccc/23Aam7/PZJBhgDgin5CtQvbCzX8ip9YgIFtOAt+w0owp/hOiCWgEGbVHuYjRigPGR/YOnEoqPDoV5z5YqB3mRq2ox5ICmSSgAP1Ne+XV2NE+/vuFbCTRADxtS70VRBCjgBk2OyDUQiUgfl77b7DwaHm2rAZ7osRSOOUoHgKfNBSLI767+oDYrfwZvqChSpGfj3pFwZFsCJg2jeIQQBUiyI4WgD68ww4qO8khuWkkIuDrxWv2nv+UTBpJYiPd0KemTA8qqFiuUF1jWS3BoG6pADJq751JqBI0wvAVPyMQvjcX1zbELltKK+zBiXRFiRxG+b7q3M9xuLdzR8g0gCGNzSM5gNYfqGO9CBT8OHct6oB3KsSDBisUnwsFuISQaRHxDSv0vptt2oeLHMERfRn/FG/Cx01EpgIQG8LP+/i37PKw53xn6sYCM4/JwSRrCnIeB1ZkLsawDhaPKv/njU3wnZ/dBdGE8+YTHSG8+ofGgIjsC19YnwdM/KAnTSsqj6ig7uGgIPw3nYFzhhIIvriAxFP9CQd4HSlnzgxONIdrE7A8ZDPx9fjib8ifgegNIliRgdx95+E1T7+3nQVNNhEzDgGA3T2rEDLduwtPpuuouPcs8swwXFjdTaMKt+jA5gUAQPcf95KJQxYU0cYxEDvsBSmYuukp7AwnqniC9Afa5z8vboI68ImT0t26CvwBzSggkj447r9IojvCn7U92J/Hw0QSdwZKNNjxPCfSxRqnATkdwpOwh88oc4J8KTSm/wdbZjrc+4iFP8YO0/5JJDCfaijK5xVXevqfg6zGRrQf83chvX4aRfAE//6vv5+6490U4ADdO7QgM/5bcHP/n4OtCQhBEFeDWSvos8DPq8/IwzLzjpa8/U6MMSkBklDm8e0mn3QIY7XG1Om8wzN48y7HwhOK3P0/ZwUQHHv4psbdoVeb9VlAjChBCdtDDpOKTh9ZfcagOYq31RFjN4/gwBYzp8lAwYNwBELhZoxECeZxMlAzWGdCRV0fQWGHo8+8Kx+AAxnCIzowAxy9KvNepWfsfp4RR9kUrD88CPVTuXRybhqqTHcnxEGndsgub1Gdug8yz9fHt3Hpl57x/mfCOC29FOSQ7/noAZR5W3Ob24UMpuPYAYiQrQgk1gnFoUIKr4vKFpV15pHUJO3Y5rfH3UFHU4bGkU+NKJ9f2hJyOMxDBDpjAgwiYqvk5TqNl9EH2Arb6fA3yaA4cBtPWewhkEcIQJBlGzYp6zRmr1v+e3Fv27xpzvyI44NGDkCIi7CGNV9Dw0M8NtHC2vUwHINumCGNG8erxOwtQINsW88Tlwdoc+F85nI559ngEDpt2F/Uu3hiXYrkN/pBFS26hYDAkFgErMK67y9mGBA3L5ore5izf8b3n805MOq/t7XU4WHv1DUF/5gugCSOAIW/59uMwl6CHWAib8bvfxWl9/rBGEMTTwDfG+ezEYG4yk6FvRPuPwE+wvc39IRjENWM+/cm5b0W4Pf4WuKUnw/vD6eDbB1ETs5vl77Dhnm/51g6wPWwQAqxnivgQaeS3gy/u/1H4hpTPrIgHAN0mSgXUX13YP5PMIuQAfBr/f70cdeE+QoCX3i8nFMLcAjInBoAIYqt1LhC1WdtvmSab28AYffaeivCB+ohdYQgfUa/WS4ToMsNLHLc9nnvPZLwn1/EefPVf+U/xvnCVSEQEkEQEnEQJO7S7RvYDxNeNYKrG7DKMhtsQ8cMmhgPKKKj+F7CiHYFR5KIIPxOmg5IVAtu3ACQSPh7CzUQOgAej5CWEkIe3vgxz0ROGO//qYfz/dnLT+ZxDr4QW0eNCJBorCFOVC312Ec2TiY5Bk0cAaQmiA1VH1MOwDHQ0kHdEDDf+2UTWhS4Z8diQMicLx8MLBfverLcP/jQzF0P8EJj5+NGK9RCz755S6F/f1+X/gxeP+Wsedv+vF8/54aSPJYFjIQd624MDz/UDLQnr8HU3ztKHRf8Qeno1vyAQJBaLcMtTV3cvgP56COCqd/QP9xLgBkH4BxO13n4hNUDtACC6G1S3zqooZ6Ba4lp/zcAFb7iERKQwQcF39IFJjdXECGADw0IE4gg674pYAnk4HoHPx54tD5daO5vxrugSkMjgiiqc7TVKAT6AT8R4ckbHEQCYR/IZBxJgA+XZjsR7vaoRpIxWqeqfXuGC2CxwudicwePEB1kNkaZCuwyF0DuKv/4sz9mzP/Qxdg3BDkBTMC8Q+loD6UGBzx0Kz6eAX/KArOQTlPHFoI4vVtf4rNuLrca9edRn4xBP7k8w+9AgZCgBfEUZWfEs8iFNZ3UO7TqmkjCO/rWdgco/yIqHcQWaC2EGTzgz5y/iXQAvyx3riyxxV/JeBriaGB9OrTA5g9/eokM+37GszqfA/UZk9iW5UnCtBqBl3XoNN6Ag/+zy6A5evPAp+TIFDn15gQw9rjrOzFX0s2JBVAxa/nP1a6AsNWYGjPNGPLTQgBsNUFvOA3Ht9o/rGDN0tWOCcxJGp+f7++kkP7PxcGv1+GjkaLt/fawpwwerQxBJNW4b+PJsYEgiAYYdEAGIlDNaAbRkIgK3ut0jKByp+8yz23X6GttmBmjwDvChgiYLP5V/zhH6/110sGcKo5CkggCngxnIPoPja0j2B+1BRkiYJiviaLJqghDI63G2nAgAxMCuDdnoD0wIQm+urMB3VuAwbBrFGgGgnhAFqg9+ujKsLxB3qGCQNEEtPinIQlAj4WgIw7/iXc9V/x/yUWFs2KH504bAh4aYWf4TrTLGTy9YbftyLeVOWNfYNyt/ji29mQnqMAltU3ioTtbX343yv/1u0YPUBz6zB702tQucnX0gWaFh6DgPdmhXaapGotw0SFz1qDiTMdd8h45HfcqCPRUhA3+NmKz1l9teCPaMd4urGaewRitNBDdahR5c3AfQmDCFT9vmtQEwqAYXX4XI2n23Z9B/Yb1FL+LWox6wHGbZSo6FR1LzyG+3hriSZvWT6jfXhl2cmQZJDrAbuYAqAHo1GA/EOgD8eGcU7A8eDvH4fQBuAhBL/Zp/vamPTrRENDGLTV/7E1WEPLDlP/PwzU4YhusIMUgfIPAr6Dhv5R4y2r8ldFwiFoYHnmr8TAHbhRQSZOctH598ZYhqt6wP7q/ouqe77RJxvzFYaji/z4vna4v5cUMDXqDAJ5ytktqtBDckyjvJg04hl16LB0xFfyMfD77PZjErGQRRjYIfSvoAXntks0ok8MsUC4KARWnYPlJBeIgLeFrUgDOHYCag0/XNAbWgRwQuLAsaQwIhC1g7+jCNKuT38JfnYSyTi+QQEwwHeT4/dWHYxJPxfOj5oAnRQqgU3YgGZSOaDyK3n/qkDYBKptzR3oD6B4fyRKjp2AzSl80YR/3P+/1vBjX18Jbu+YsrMRgbqPP8zrDLTAaupphfeZtyPs9BPztpLSBZjowF3woYRwBwOWaqbev15b7X4RWsiqYiY6ZkFEIoUwUA2OrkeEQE8HYNyD/rl3m88jCGgO/nPW3xy8x4Q/HBcM1dYg5q8N+B/SBSYhtD0EY1PRGLDoKIBHF3yLz4H/gSYQJRETgqeB2d4vC8L2NVnQn4PoVJJAcP0inahAfdXVI8CFszjRagCTtRdV7Sr895NBpRKXIT64RMFw/iw5eChhEvmmyUIH+k+Qu3cLzOAN6ILlFvgWnx3YWFDz0f38ze9GlfP6UQ3ojEY0gtqRIEbA5/WgQFhsEuIeL75uTzvqHktAWfj/OD6sQXssROcGiRgFn0QVkld7OznMDT7CJKzhMIqxW9B+LCOQdH4uyxIcE49VTSeLj0wKjzcp2oDXQA8YoDEGBLMW0BJw+eAxXejPV/IXd59/tp5rVyYXDw5BlRetSpQAcvgfOwVM8ObzBq/AQ2wX4lwkQV3vNhYFfn2LFgaoDU1ogqsfqGkJYmrj9Tr22KQwBLzbLuzDeA9yzyJjVRfwegWq0H+FThDPA6ZhZwX2M2Kh4waovCzAWJTzD/qY00c+6PM8coz08VNqglzx54LfHuTJK7z2rwX35ABLg1DzsZ7Qv7l/f2yXDlbf4C/irg0MJ0aCuD0wP74MrxfdFlX7tq+vtRdCpvt599EG9Yz3V+P+Oj/n4zLruZHcJ7oMt/MNp9eD6HEeFb6/TMfbWo85Pb79HJo8t3371/PuIAZqMvjPC34nVV6ZB4hEuA7AzA5cfU0y2n6ux89D/35/n2/vWY5Bf0qwf3tPLISO1Tap9qzFB6eap/beqI94NCCbGwgqOItY3CGl446CaQ8i2Q9g0AvmgJOnBoAA0gu17tsKtKS7D4udgCYERy2QIceCX/P7mBW+g/7D9S6Mn50CS0eAoQPDcBjopIA5+EcxEjLweRjXq0UbLIjcBxsGx2IZvlf0ATjz/6qypAmY7bhrk4ahsIis6ccXKHdueAfUgk+RWPCLh42c6zEeKyJpRTdRAOqBbl/Wq/uT+q+Fx3FoTIuCzc6+hN8j4veGjuAnhSE5gKnco3A3XwYlq2sq+lmP4yEOpqEoG0M+mGDYuYT0pKCFHgLHKt3T7T9p8GcWH+n1UwGa8X6kQt2x4CeqPexegT6o/Z4Cr313PHdgrsS2ZReLfpKIf+IMFnmVmwxQ9AhithYT73+p2s+JIVfrjwiHnpAZrSsr9CMstQXP1+1+510N/q8E/YoekMN9OMFvi5LvkRDsy9rgFCOoPdpgaQIWBZjf5KCSQszZJ1ivTvLokpen6tsJAVND0NFqb6GUGg2Im4Dyx9Pn7/0dm4pADAslJzTv+dKNrAPQ0wyySm7bj1RQgbAXsRa4R+mBJzpaQmHLmy0BLoL+Nh2ZRca8uUc6P37k97n451fvTieAE8BdZ2ItqFEK6oOJIYPsiU4woo140Oh+H/UC++gatHYcOFT+2y3AYvD1rM/fpxdUcsAi70c0OxAEP45X/hymE9XeoC0zfYhbcqfbhs09HpwnKMDR6g0mmYyKth/UcLl9ITGQ8N1S6s+gA1HvQCc2pluPvN2Br8SyZyfyxPP/VhCi1L1HWX2CQCuAE8TIq/sBYdANZmTIwqq0sb0HIzhhugBeUpBZLFyA8y+EErsBUYDZHYN9QAAooQwOws+uQlhdESSSqk5Qsh8LSYI6LDS1AbmOvLlRBqQIeITvM36+TP63VfE5hFClCTr9zEyVFwS3STQBy66DMHB+PJWIrfgGnYBx2dTboPa2X49GaBVlePA7CFx4iaGi4ns0aLVjMGvtPTDtmO4XEE8E5Kb/8qYai+NHl60LgAICcUCoJPVeiYG6Pxw/X9VFNVbFn9FNPzXoIRDTyzcpREYB5Fm1EQQn3KRi9wKApR8Tz48SwxnV3qM0q7ZhpdKvr0zfY+gO4oQf+EGPFYW/Xf5hwWsUgxiBbShGoGIx+D2eH1h2EeR3UQMH4zMaUKr4033nzkSkfQADelFbLOQCalxdxvN8mInhPas9bxtGJw29Fx3Y8429MAS0fL33Oeo7qFZeiToCC3B/VSNYuU0fgDnkhxGgMFdxiYEY7MYel+OHPH30IMeVFK1C79l+QdXVpFqHlMAXEf3EYDyfkkGdNvJ8f3RAXU0jpgM7jMNA5yCrtfzOicKG/M9bgEkEjqqPPDEcDfqVwGZv6zcO9avDfOhf4OmLFd9OLBHHdxp51HvOBlnAoQksYjASA1xnIhPsapTCPjbsGB2YevpPpgM73EYeSYIftgPgte6CWesVBB9QEgfnWYMgoeC8ql69bWoRIqYHvSIv/u26bj/jdqZ9KSGk74JRo6QS9PuTiSHm6Z62kLUGH0UO4rwWrhtRETkR4iKRdI8giJ2D2nUCMjsA0TXiVDb98NAf/rCMlajA9wesWHZrAe1dlwRyVI2jx4KkyUHSx7YDe6YD4tOC6XW01puEdAJwaEJzf1uATHi6ZlSCpBQscsh6C1xRcWEG4bCFeKcAVhVlDu54JQIkTT21hptIT/Afk0kMcS9BKfjBJozcDXCrtgbWXxbMAw3INQIxtQJPAGwXmYaBbYh4SCsuKwLOAQ5awKskCMmRg8P3xwlBfbosQaDqyZqBkyQe1CLQACoTgN4qbyHsPwkTiF2pYaj6MAXBmUosQHnUEYCsBL3MW39SNKMJ5PfoBsT33DVJCEbFnBCMOkHfvj6Xq8uw+dgRIhGgAiUqf5QgKDFyhe8nnYrlqn9sG1GoAfirubygX4H+8IM1CmQrMFAJ5ExzKIp54nPoVU2Auh6eBShDlTV4u5c4HE/fVvjFrsII0Ik6QX+Iq68jB19ziLoKC27FYe0gC+j1RSS+BgB7AvAM3m8HLdy5fV60C8RMVuhD1ieQB32MCCq0QPJuvuw5IHF/geMKwOPdpmsxBwVEfGEOgeincJqNmuSFIPhPq/xM81CWIIi+gCFBqDX3QPYd2OcCRo6GZBoA3AM+00aesAOQ7/2Pe/vBCXoguD4OBD1WfPwClzcui12AuH+gC0gEwW72KfjBCQRBr05D0IQc7N8PzOCMehPWK384MPVDJQim7yDdoiRTItzzFV/ZOX9sYFetP0fsQzb6O7wOoFjxk89YoQXv+BmSN+yYHYO+BsDRAXHhuJXsEFbdIEGZQWUkNVNzGA9NZUVBIQL7jASR0AclE4Pb7JN3BO72mG92+o8UG3nybj+mASh0FsLKn9GPxDrEcS2Au35BzHO1BksriIJdpqWjKR1wlpR4fN977rZqI+XbYjYDgVDpcYQalOYKMiuQbB3G6Pu/HlMbi9a0EMkksXtjvvXTfgMKAEZRN/i/O7yD8Da2S2Bdh3ICWfp8yuMkYl5a4df4vVWt4UF0yyqEnaT6swYyWB8/j111Y1ERS9oB0SLMtBGDEBD1PEHwtdjUEAHnqmoHU4wCDAoAS+lHwtu9eQLUAgmxVvAuMB9cELMV3m8EUtcBYYI9nkNIEEJYrQeUHfnzzRyC39j8CgSkir/E0P2odnAmAqDnDIhqrtV9BDNS2POjv/0pwKr6z1h/PMz3uf9ykFYq9TtoAXSwpz0HljdvBCVAPY6t7osv6gFhMpkX13rcfXQMIpuTsfTibkfOPRAC2meLRipI4mDPwMD5x+v3+Ey+qEfACwoUEkKQSMZxYJDz9R68PyP43yvo2aYf881rNQbZgRU/jp80QnW/hdXqJxMvCFxXQSNHpE8QiF4XI+wFfQcw7VL2Md7RRajsKgh2D+6SLAKPF356+/7yXYBTUgFy/38StUjFHweD+iiHh8/LV/i/TSvGk4L5x7F6AsIKbgb4C0YjgdGRIToGUx7cgS3JKP8pRcgak95BJGQbjaJdBYQ1qHYnYHL8F45QgHx2gLMQ2cDxBD/4SeR0LSDi5XzPQNjM4ySE/HGG6g+ugltLNSARn281BPtNO72eJLjdX4ITSEgpQvJYFEUg24f1qAYQNQdxx6Q/RcB85j9f+03zf2QV33IDPHegNgPABTfqFR8cZK9TA7/ll0EQbUUHW8Gr1d+MSadia+LRHwhunv87yWoJ3h/pRDwJAbDNQQFd2P2mH4kP/wDT/ZeN3CK3+ZjvgVpw4r20AMafb58j4N1UMknuj6iCx883PU9g2VHVH5JX2eEcPghSgRBCKPzK0Q3fknwPN0Hk0CyC0zBkz//7duEetgFjVtypASDI4CsknYJgYDhqsBxxy29+eyxrAZX75EEf8f+CkOcijMDDHx4ASYGGu8WHgPwpHJc0qOG8FgFTuVk0cRZVePFwHEIUEu8xSHoL5qWg4I7/HgOKXe2dcnu2SSdCGIDTA+AcxY1zYL6Q6AAFu+/1GvjKPSeEoJV3NiM4Dz9C6oWkEav+NWjPWXNOIkKgNTi2I8LeBgaZHJxqrC4oNXoB9pzzMws/OW3ghSyQJgjbygOVEDhoj4nHLld8HPD6UUMFVLIgKrTL7cFoBRLQgEdXIseZ2/HhFPKbk4d5tYWwwR0nIFQSD2P5gQhs6meVfB+Bkyz2fOIvX/zxqsSODuAGIOLtPNnmIPCrv6Kqvgz3q4tCwNl9lWYfnsdHj2HTgQw5IBHwULmfSu1jEV3gDFSxTBmqSEVqiYK2IkWcRiAkwV/cyW9YhqHXDw9dkNQAcO6HFNJT7oChfrPUYc3KY17zAd+evAwF2w5SCKLV4EuCEKsKfjBVWHu9Q9Arh4CoBqEMWYBsNX7YgKP/69uC3M7/mOOz232QT+ox4iCyJGEFP4oBHd+GVvXBwX35nqp7qeIbV6L6tdZub3ueJ+gBIKgC6S5gOQFxDoGr+Bv2nzqbknd7ph/EmXzO0o+kZdc/wqvQkAOUffVMzKtYgx5Vob1/+HAfCdzHSiXHenX35/2JTr3KZ9Ruj2lYiMhLIFoNyMq9hFroeYMTE0bSLbhb4l3YlFPa6hMd2jk8dmrDgdQCnC4/+ANFlYTB6ATlx2GDGXP1rvL+SnWHw+cJes5/rRWt4H2pw9GklD4uSMpwasIQiaYR92gIyFX5S8dtRZt/nCAH48VXW3hRE/HKOsGquj8EM85Q9cfeAV4XwNGAlmIFIwPYrfLKuxV476RRetzcdeAsRSZhiHizCKEIOHn3EMOWy5X4uIJnXX6sFiBFLaBm/THOQAkVJK9j6TKwiSDTBWpwHkSPQJX7U959uAkoaTUuug6oQCBz1Zlxm0OJSIoIw04M+7zCGuYiznCfHww9AN6Ir+HXA7lfn2oBSJ2FOOh8SzINfmcAyITq8JX/sOMPx6A9LeYtVfwgCBZhdu25OB9/XmWWNPUEPD5dUuJ68wd1AqD2+w1PI9KxE9BW5t3z/igdYGWiL7L+wPv9jgVY8f0ZcbCKCuLAHN+c5wa69Zpr0J9t2KnpAGzyiAIPiFalJ8/xXrrA6Y+/8NoDnWCPNwFJzf5DpVkHte8hx76P+HU1+HEytEeSEIzAsu5r6wPJGu6oLz8VrKofXLce+ywIHhNa/Dmw8LrptWXZ4NKZm4pr/QQ7Qk8ehMrPtAF7PQCD309QgRgRZMKgAbFREAfBBXNalbHA9cEHMo4IgIUuPjjBWEUFEQpYTkhVO43eRiynJw9Jjj8TOUIlJExK+0wA4gWgQvcFBHAc7P4/u78/Ff4CC5ATB3P3oUwFClYgcALcxzp/B9Ez4DUV8RjBbsCBrMH4dLNwIDaCGhA6o3pXksdBvYBsktrXDgNJKAFy1Z+ZGIy5NXgXoBT8a3ZgVSPIUAMV6DjLxhsV8wX4n4ibbONObHNyCr8Z4FinNFjg8ziiF5zSV8A99u7Zdf5OisvVaAAAG3VJREFU/kIPAJLWX3hUIFD6o7MD4WkHIMXBk4IftSrPNBJVk0OoC7ice8HGS8XBKDoz/YFBLaQi392lGpCMJfhD9xVkx5Xbj73P9V4m1j0v73x9FjDDPlYvATkgFAVWcdNvJBamliOjAwRV0EpeRymAe717kMYRyy/j5FwFBX0fP7Dyx8gq8wn2ZXi8GfGYR+lFcGJSxa3Y84WgzBHetlU4cvKY44Ps4iP9fsgsPGEhQTAcHqwwGCj61SoPexKwasXFqtxq8qhD9SixoBBYcJEDNzmIoi3J7QkoJActVHocTVpPBCDhElAvMDK1PT/Sq3DwB/ygmyB9GNhYDH4so4Foy48kkPtZfZEv1PQTxYpyX0EI3Bu+/5krcN8fgwVdwWu2JNVNWAk+PcOOPMNdGFyAZ5Aj6gicgzNfwuHZg0HrLxBWfjSRl88fVCo/apX/IBrIvf65ZxtEoK9Bec4KZIPLe76osQns46NwW0pUPCPAyMc4A/KXOwZzFLGbAqD5xhhbgBcWfoJBAlarcCSQgdQJ+Movnih4gjZQTw51rz588y/ZgxVUEAQ8soCfX8OR26JwujCLGFAMsOjnwGrlPuQw9D/PPv8BYVR7pG/eeFtQpsLzR2KFI8SwKj9KlX++HeLOPuSBKrKeHBi7L4b+Kx184+ptAp4Trcscv69oARVYzWgaK01H1X0K3zNSmARKtxXYHvwJuT+8gLGGWgpHcWOmBeljFB2Ckg6wiAYOqfxEK3GMCAj6kIiTWdCBCXhkjUKMgJcLk271N9uLSbtvvK0S69OXAvoA5z94VsFubbmZvx4QAnXgBnJxENyQjy38wef81uPhxMpPJIQzr5ckuUTKe0wZyN57iFTWga8GvCwlh5UqvYgmaNV9XSxEVWs40kkosFwA70RgNOu8mLZfR6wDiwRa35y7j08NksqPQhcfkRBK/J8R75Iz+9C8gJpqzwiIeZII3QnYOkJWbVEI5jNuA+o2BwK82ifwnpSgHwaC+GNAdmW2VXfC+vPu6wR6lBj84C9WfvivZyUhZMJlJhjSukDlFJ3g4AvGJfC1iEpQJ/CaEd7G9wds7p71+odruKrHip/C7RdsxeVjzIxhoNkFGOW/+sk/YVAGtltfzZAIfzix8gcHhZCXpcGN2u69qWqD9OlRFAy7x2fQBhHUiETB+DocqvArYt98f+AEAXApsEmEcNLC0t2uPHCqPQIXwHYDfI4/9+8LMpchqr5HK39MJSrBXwnutNqjovjHFdq+fcHLp7YLR4mGgduW5hFpAXUoL4cTTuW5HJSkB5PC0S7A+8c+837DyoM1J9iv/po/o3BunlDqPjOSO/YbLFd+FGy9sxKFeT8b+nLNPrkAyD53FtT27yUS32yqUaEGTMBiASGcZ0FmK8nWxbvjC1q6WQC4VdWdAcBY8eFoAzIrC0b7Wt8wlPcIdE1FhUWeKU1Igv8Q/0dl4k/NnYSxdlDon8diUDeuQB4c8XVzcahRgyyZmNC+LAgeCfSVALde8/t1DCYawNoePGT83wlOpFUdOZKwxn89OsMEf0X8CxJCBN/dwKbFwkSMgx0ACJJDJD4iC1JEYh6XcEqVHpx4+J4I4UiAl26r5x64sttvSlAn3LBuQCz6edU8C+J5epBrC4YP52EFDgHrCw1B0eU9bOaTgh3wmYvQV3Oqqcf53XnVNXUBELX1xtSgFrirlII5d3HFulxBCNEfZx0h7K2f34XwdHpuYQcguN189Ow/nPXclaUcqMH5leCXjKOjbv3F0a7i2ZaRHmBe5zwnhA9S736ZC8AH8LHkg/T5znYgmES1dtuzGo92qwHIquiWX+4KgVLd8utv9Ml1BQNhEJW/FOgweiTguCUoQHkEwYhjfQIgm8eAzPKzHqAG5xGiiPyxeGRRaYetUpDVpHVC1T9bHGyaknb/TQTnuG7rDYwYCUT7/cMjtILzA+Go/FPw581F/mWeTkDuBsBCAK8ki+A29nMzPn4Rzjv6QV7xWW4fzQFUxb9jQQ1qc28kMi4mDl1NBr4usIsz5ltZqNm7AeJXfuTHd7nioLEyPBISU+8/tP1AC4Il/n+YGmjg2NiBRdl6yCw//zG5ph7bqaBuz8B4VMU/TqSsNPbwCeZA1cdxyG9SgKzRZPL+GXFOiH1/SFZ9wX8M3zUgvH8a4rMBjZj/h1W9MrwTiN6MlsCKiI4gycBzgV/xUaQGjGDHwHiYi0VIzeEAasCpNuL76AC7BIEl7i4AIxnAfoMxk35eJbZ68wWEUChs8IPz/EEE9BkUoNA4RCWSLJkY1h0Y/dG9bVCtUVPe7QRhtStXG4nOECDfUxc4Uw/Ik8JkA9o9+a83IrfHH11EdFUWc4phNgVFWkPsIHBnCvCCYBSgqEN9qtoXuwHhByYoJJA7BxIkkRwpDGgAHo+vQ3ZGOwCFJCJKUAx4MBpFZWvReeLgtBBkDDQu2OJxXa7SE/P4ZiUPHABjY1DsFIhPAaygWewiXK72hHjow/k8gCL6gKES8qcDZ7A+EhYlWCPGCX1wXIwzkQEKt8cP6iqkC0FEhFj/ZYtvXCtwuBLcDT5wXN+9H6ZEIkTwV/x/s78fXFX3siWHEKrC3tw7EFZ31Ll7ttknQyEMGgAqCaVe1bGk8r8nFWCQQR0h7CY0dsU/mIeIuA1AGCo02Q0YVXxub36sG1Qgfo0CBBUXxap+ECFEycQVyViBEBFPt14TK9rZHB9EwMG7DPXOv0OVHkdtx7OSCXfb3av4CFZGTwQBwT7/hKPHE4PzpJ4L4+FM9r1n8B+B+9R9I4Fu9brYUZgCunZWNxdQgIs8mASBQ4F8hJpEiaf4GPihk8FdAxin/kybjZjTj+mAQy6ihZ9whDvHAWB6BKrBXQr+5SBfqPaINwiz12UIwoTmbPACZY/fshBBBKNlW8ZCHwH/cVKSOZMm4Mxk4OwE9JeB+EFkn1IzcPQoiSB4vGgNeJSoik1A7m0TCmE/HrggB+/1M12C1Z18ACGoIeH1pH2IhAqFWgBq+kDFEWAvA3X8tpW0cnSD5WAOriOHhnYraF1eLTkS8P/QsHUBdtMPnOrMaANJE9AZiaKWII5Ue/8PTHn/UcCSTgIF2xN4zdmAQYIAKeBFl6FiO0aKfq5jcImHfPwTxcEdRmD3LcFoAva1Hdjm9UgGggI9YOoPkOBYLsT8HlG3nucMDGkOOJ8CkNOELdSO7D5qqAeJYBb2GpABgRi2gxLITgrOQ9C937HgB+0i7MeRx3gfPWCXLtgbLJAu/gCFBPzRX8eADJqCvA3FViC/BlOQC4LZyrBq8BdQAOUKoKjqR7v7EFfVFMojPgEoSlJesNIePyLHwW9NRgq7E6HvUN8A0yj0wyWDHRZ3J2A1jHdMyu3hCGwSDwdRir7h9VP7AKLgPoMCgKziOFLtrUm8aIFHlgxYfz8WBYUU55iAXauo+evJaIK/NTgRJM9sUcZRzcCnMdNKMJc7usnAyrpxHYkTRHK+n1HxS01LheAHqRWwKIDqLvQC0+PupHZgBawfVGsiniTVHwZHRqbUI/D4Cd+ftgyLAR1ehkIiqaKFw7MJEwUIuK5zsu4svoFYCFKgBJZACBuppOId2RDkPZas8H9kULcA9a0KTCQDGtpnzT+RMJiOGseHl4BQ1C29AWUXIIf/OIwwqoNEK3SCuA7FRiBrE9B4/PcrGJ1OQNj83F4Xbol/TgVHfMiIZLAdcaVkgh8sLrd+liNQH/FqsNTfj15m1J0X+ffZuq/gTY7QnvIfJz6UzBJLs83ItQpt3RfZz5iuGfNPajpngUm0R8DoA5jDlzsOTAwZjzsC3Jjxg7H914PjlcskGdghgx9HG4OOQH34uwQyzz61/0qiYNQjXxECuWYbGM/DrjtPH/Mw/K+gBLLSA+cEfPr4MroArzcDuybbr8Zc72i2UnzeHnTgzD4Ug78SzIvCoARVOQxaFFR3TzWnkkHUVFShEuqKxZnKz4p4YYcf8ZhYhuu8wFgSHcuuwCJagI4bgchJQK/qe9c/RT6nGcg6KGREJpb+MI0EY/b0jcsni3AJBeCQNsBOFVYoApcM2Aom4VFgIRdHpeIG8D3YaxBD+qCiQ+rBOSVnci8hzkAG1t/pgHA4uwDzmu8xFKkkkIqCfkIRs204r/hiDgutoAAcowBMZ9+KS0CcXVBOHCvJw2jMQSJyeoeExF2DuTuRcuWAo9sefyUQ6/oBaIjPtiRH1KvQKvygAHb171d+vc4GRMDPoxN/kL5pwlVh1mBQ1quQJAJ5j0TgOAis+h8d3mnC8xTKE34+8sDNjyVXE6nFMN+H39TQDmocHScENvN74LoGScGU4f7g6IG3n3C3qnG6JBS+Z5tHOOzRYQx+u7MZmAl0OSsRLAS/VIKfRAWU92+12aaVPksGDBWQuCMvgNy2M2Mt8EwqbjosZAec5xLEAmXmcFTHiOWARWglpNpjdEtBQRxJJU5VL5/7F1X86XntXgUK4q+KggsUoIIK8oA+kgy4+zLaACqQGTVOX6MBWdehL6BxHn+tlyBMDGAqufd7WOX5WTJwKYDfXJJP2GXDPk7Tj5Ed7BOG7DMFaBRAJgI/+H2Ngeb2SKb0zkoGlQBHkefDr7xMA5HZeJPtKIzyApI9gmnPgf1c3mulfhe0gFekDCdNFnrOwi4Gs6eTACNjB+Uegcgojog4V25P8bctRYY6RL8AJklE9ACFAGZdBEahd4d4CmghFhbzcwaXYH5qTlS6DY+KfNH5Avzjo2JJ0poDkSCMxLn73H/eB+ifvgvyIFCWAji7BWC8hd0qj0FziMdrS70BlVbgamIgcmotGZDNPwm0L9l5iHv7WRoAFx57ScFS2r2iwot8oKu8l+TOCOg2mZ2nFdjTgOFQENzKkJ8OjEnsE8f6AzyXwT6MNF3RDRnuj0Lwo6wTlBMDIyqaz6G+RiLJMg/KUrQV/rh9uH0tWduwoxmky0kSMQ+rnXxZsGadgnxfgk1pCnsIsGYltvfdzTOBIclIsN8MLAGcz5gBwj94AE8DuC9Molip/JGwB57nRyJiyD3pyk6q5ij+3TzRLohcqyqCEQBTepF15+WVmW8SEr5jMUUkx3oMIsrH3ndwAQganKzyMpOJNxMQooGBYwcByw7axIhgPRGEr6GSGJhkAELoQ1YRg+dPeD5IIRDIqq5PA2Jh0Rq0YcS8XBi0ghGRFpCtWTdum5+yLOsQf2EuYY8AfnbQZDgCjHxBSKwTGpt8QCIDVH3/4H5OwEvldhliINwAFLsEyyIfGKV+vm3eEehVqKTdNxtDiPoLHCRiuwTJxCECxMDqDjTvZ63KaPKvRgV2i/F3ohm88V8LN8hgJcXD5pVGIPPNn9EBqSQC0I4AMxBUcQNCkarkFgSn/oCs9GCVep4eUG5BRAOcQOCWlGSc3If0IFqRfURQGRrKewPKEJ9sLnIowKCcw+f48N6UHjqYtgInaCCkBbPSj8VEkCr2g8U43wY1xX/BNkwreQrzg+oaJghOCGTU8RBxuIp6VFOGoEXgEsBLIgV6gBgxoLSI5CgiYNT+GBHsU01GthrceiMUtv9KgAYktgVNeGrBbtiOQVi9x8WjiAW7UNUnm4Vet7WtsFgDCDYEwQ/EVL1PnQf/xCDLTowTh4c4HPRDoQaiwhKIAae4B7xgCBydI/CDPOrevK0FR4p6w3VfoXgQiB3T1N8Y1PCD0X19JqcHGfzB5WkQE4p/kdeXBcEVUXEIFqSij82lMyrWq/7c+LFHA7z5/dwOHHg8s/Y8C2CmhbmALtare+4UWLfb25BmXABKABTniC8gRAP2yvDAiUAsElnrxFzITQa/sAFecAOY7zPV/8jMQHSbWAiUPGkQNABhw85xrSCv+mMSzFR8+7mjw01A8f4F8S/td4jnDHYxpT8/OEyV3gz2+GTfdAeAszswfJNGlQhEIjB0Bls0BKn4Iw7WKu9f1gmSagmvqleEwJwnZwjO7npz1HdCJ1hS/mlBcRXyF3i/M7NxqJFoeH27z7nnJaBmpUZKHsTbGUc1ALEoIGsGYl9ixS50gjAT/VhB8IzvGTrBVfWEz1MzAkRFTtecW731VdjNQPukVdhdn0Y8d/a7WYH6i/TBPBzUFwAlHwtGHOQISrgb1AMUgDETTA3+THAdeRJhg59V/Ektofa9I8wxVICkC7QQSAd2O3cftzPzdMK6aA4iZI4ILfYRbb9RgqICt2AxVnYZ4kkBvHOBxT/zN9ybHx/f5Ql2fkGCX6ANm6F8WCfqAS+Eq5AGcHJd2IFHagTMHAAj+mWBnDXuc81CjhsAi5dL2K8QCYI1aJ/PJtSSxEFXASv7C2I3ZB9/a0j/7nDn/j1pHsz9Jr8fNpxPBUAUUYD4wz5GBlmyAiORjtAIGDFwzSUwqiNZ1d1tPiB7/Q9VeI9KeJU16/knkEeQJEALjY4rkp74fCZiMDSA/PgvT/aT2gYgp5E/P29AKBQAo6TRth5T4VesQFb0i4K7RA2MZpgyFXCEQHCOixuYMPgy2L7+45ezSSKt2oUkURlpXkEMOLSiXPuDQZjk63N5bmzOSxQdLHX7AhwUEA0BAeQPJIQzkAuFlOK/GtyLdiGDKEBdllQ7YouxV2Xdwza9So4Kp5Z0yAgUhTlJgFzSFrznIHYIwKcCu2/L3LsCg6UI1b1/CA+ApIV5/32HqOIjdQusE4azip5Wc1b0q/QGIAlaWEJbXP3r/L+AEipw/+BtkQVY9fIM2i/ZhgVEgJO6DZ1ksVtlYdoQAPhVO0oKmYBmnAYco4DRCRB3TwCziptaE0auER9/VzRqKNOEYINOQg2m1l9GpGNQAhh1v6UmxNQh2M4+LmlUzll0OTjYQOaGlZAEMCrdhmBphaMBwBADrSQQc3//He8KgFETT7p6BHnjj2X9EXsDjrgBS6ihoAmcSQVYmE4JgYWFpp1waAQRoqDzxDhU+HxSnZHz/9JEY6Y5MJA+cwoWrt99+U3Mc/9g/NQTFaigAEtwB1yBzwzucZSX7RZEILhR1d5GDCsBLVUdIQvsldZfEJt5i/MHx2hGJZFkVVyK242iFeh58oBUFqIQbkfp2DV2X0CkAYgv1sU+P+I/HmBu8nErugdRnUWhfp+A/ddlbEH3uQlBsNobUEMHasK1HOYn8BEEvCUaiuigXRIKj+sGOPA4KAWz9/s7WxcgB4+a6/fI2osEwv4yOENAiPf+wQhbc/5f0gGisWuQaRFmGoIqguARWsBQgTTocDLMT5OJUQnhqdCEig+/EShKSEgTVV0MBMnz04BcshPnLk/+OaV0/dwKzB4QUt1NB6uTDfGOP+cNm9mEsBAFiM7AQh9AKVEU75vy68jeOxrUC4mDEuYO0oLqoSdHaEF2eXYYSm0V+oEOwpLmYFOF3Z4CmAeBTIGueiIw2xoKPzDBJVBXQ5g5O8/twwA+QguIjJt3+g0NQEcDfUXgO5gsqlTBLkQLdl86K3CWneitQ8sg/5oWAUJP2C3V3RoEyji5n4b9lB4t9pz2CA+cAFn1Z9I/uzYsU/ELtEBOCHYQQqGcFejV+yeuRJX31zsKV5IGjway9z6PLDxKwNEPsBuOEiqw57jGgOtZ1Y++T50AuMFl7hPIbhskiOwsATtRoc7rS7dXrpcgrMCGJca6ELJo+Y0be0BW5ZKGcFz4y8W9BduwcDnK9iO5fagsKpp9ANnvDPxeP8THNyIVFo1AMas8Qk5v2Ytm0LCCYAXqn+wQsPTBh/5Bcnne14Os3uCQt28vsK1WUESJFviBgAW//3u9PLxusXchcCR2WsNzv/ImvgZzzkUByDUAIrjTvmSHAowpJBQE4SUlxMxnARlQbIqkArVAJ6pBBvELCCKlkyCDAP45BYfEPfcUpfMch3Vn4bheYK4E66BxAxHSVd5INgEPgU/NBCDfNQ8Ho1CoINAPQAW/QT8OCIZlNFCB84XhoDChFByHGjx35v9BLgyhmojqHYb5QYXnuAecvua0hZe6BV9f7v4ibvgvamrmAc1TmaEir0LQ9h97eYAYVoM/nWA60i8Q3Ifezha9BqaaL3zvqd6IAuwwLSCCuCLuJWch4h30giPtyiAphKEBcCu9BV5wwzkMxID8rhMwdwMhcSFgrBT3RUTQboAUg3+p+Qe1IGarOioVnazmefV3lHpwA0AcLWCahUiXwePHWJsP+GH1gnp/we5KfOhJAbsj0H/BIEb04TbrTPsAyb2LLu93KwfCvn5PLAwrOXAa72eEQRo1CNdw5IprsAZ3hApy9zlcITG2vpCihsRSYxNS+J4vdBZ6B52eqRcQ/QXmSjAWSfa/5GA5qEg4iJFtm624AqXLrSA2gx8p1Mdqcghv41S0lSp/xAYs9gakQc4Ie2RTUYwYgt748mV+FU1Xgp14eW3XYZ6cdqGTNHwHICTwEeTPl0jEZwIgP9gDEaogeg5IHWCF+1eoAhvEKPB/EAeTRsM/pSAP5wjWEUMM1/NJRhwJbpJSgK7S7zF3EOsI5jBQBK9DV80Z8Y0COzvmWzJXgDl40KEC6cqvqgi4OB5cpgLFYK/1CvDiItXqC6/S87wfAUfPtxqfGNzlYaOjlf1IsHPPvffHgDAoEeEST4ZLZUd/RSo91/BjXY5ggWgQ4In3fyj4mUqPrInHOCLKO3wUwRsfyXpt1nEIRLrqcWeTuk7bigsbid1zD4iDRQtnIdQsyIXnFCn1I9D7ADgxEhOvR5AJosoUbu1FkJyYCi9OhQERoIx+4AX/YqUXQhtYEwKN4Cy1HntLMmtaAQpqfrT/UCoLSxeswjA5UWPPi0mjajUWxMTdVusNvt/ChMdmILK5IRMFu90BMEzFYHdg2GAgeYVHMMJIBTA7EFTx/5fpgTFXz9w/en0ZjD8kCDoKPNGwlB01BmoWQbh+AxR689mBponGJOr9OwmMu3dtJ/ylW1Tik4ElUPmR9RqII+pVhD9ychABMQ51gOIZg+/G+5mGIzLB1JJC5WhzYjhJ7IWmLDpA8jzsAafUPkB2WnFBF4iSxkq1ty7f25rv/+EQLOxs2oUdTSA9HIR9swdBlCcFe9owPC3XWDDC0ISVzsEVbSCF/sWdA5Fu4HJqankp2SeQCYYrImNalfmhpVxYrGkUS4LeSUjg8dD7+D7w/ybIfy7vlB9/HJ978zr7/45Qgajzj+4EjIK/ULHPRAOlKr/aG0AFcqCyu0GcW45Igh6JMJmhA49/U+cEssHNJhtXDC1MOya3j/sAiAGcrEtqtgjBD6wEzSDc7D8o6C8rIqAZyPk+NQoNLAZ1hR64Yl1FBY648smUYKnSg1Xwk/0DyRyArByMUobyByhCcPnOaPyoegREFS4jNfYAw+IHCjdC1J2WDZBke/OyN85J24WiXwDYPoJyYuCD238ulvuzwt6KgHf0shWKsqCFFGjB/w8HU8eeTED9wAAAAABJRU5ErkJggg==", r;
+ }(), mr = function() {
+ function r(t) {
+ this._isEnabled = !1, this.isEnabled = !1, this.intensity = 1, this.roughness = 0, this._indexOfRefraction = r._DefaultIndexOfRefraction, this.indexOfRefraction = r._DefaultIndexOfRefraction, this._texture = null, this.texture = null, this._useRoughnessFromMainTexture = !0, this.useRoughnessFromMainTexture = !0, this._textureRoughness = null, this.textureRoughness = null, this._remapF0OnInterfaceChange = !0, this.remapF0OnInterfaceChange = !0, this._bumpTexture = null, this.bumpTexture = null, this._isTintEnabled = !1, this.isTintEnabled = !1, this.tintColor = I.a.White(), this.tintColorAtDistance = 1, this.tintThickness = 1, this._tintTexture = null, this.tintTexture = null, this._internalMarkAllSubMeshesAsTexturesDirty = t;
+ }
+ return r.prototype._markAllSubMeshesAsTexturesDirty = function() {
+ this._internalMarkAllSubMeshesAsTexturesDirty();
+ }, r.prototype.isReadyForSubMesh = function(t, e, n, i) {
+ return !(t._areTexturesDirty && e.texturesEnabled && (this._texture && lt.a.ClearCoatTextureEnabled && !this._texture.isReadyOrNotBlocking() || this._textureRoughness && lt.a.ClearCoatTextureEnabled && !this._textureRoughness.isReadyOrNotBlocking() || n.getCaps().standardDerivatives && this._bumpTexture && lt.a.ClearCoatBumpTextureEnabled && !i && !this._bumpTexture.isReady() || this._isTintEnabled && this._tintTexture && lt.a.ClearCoatTintTextureEnabled && !this._tintTexture.isReadyOrNotBlocking()));
+ }, r.prototype.prepareDefines = function(t, e) {
+ var n;
+ this._isEnabled ? (t.CLEARCOAT = !0, t.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE = this._useRoughnessFromMainTexture, t.CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL = this._texture !== null && this._texture._texture === ((n = this._textureRoughness) === null || n === void 0 ? void 0 : n._texture) && this._texture.checkTransformsAreIdentical(this._textureRoughness), t.CLEARCOAT_REMAP_F0 = this._remapF0OnInterfaceChange, t._areTexturesDirty && e.texturesEnabled && (this._texture && lt.a.ClearCoatTextureEnabled ? $e.a.PrepareDefinesForMergedUV(this._texture, t, "CLEARCOAT_TEXTURE") : t.CLEARCOAT_TEXTURE = !1, this._textureRoughness && lt.a.ClearCoatTextureEnabled ? $e.a.PrepareDefinesForMergedUV(this._textureRoughness, t, "CLEARCOAT_TEXTURE_ROUGHNESS") : t.CLEARCOAT_TEXTURE_ROUGHNESS = !1, this._bumpTexture && lt.a.ClearCoatBumpTextureEnabled ? $e.a.PrepareDefinesForMergedUV(this._bumpTexture, t, "CLEARCOAT_BUMP") : t.CLEARCOAT_BUMP = !1, t.CLEARCOAT_DEFAULTIOR = this._indexOfRefraction === r._DefaultIndexOfRefraction, this._isTintEnabled ? (t.CLEARCOAT_TINT = !0, this._tintTexture && lt.a.ClearCoatTintTextureEnabled ? $e.a.PrepareDefinesForMergedUV(this._tintTexture, t, "CLEARCOAT_TINT_TEXTURE") : t.CLEARCOAT_TINT_TEXTURE = !1) : (t.CLEARCOAT_TINT = !1, t.CLEARCOAT_TINT_TEXTURE = !1))) : (t.CLEARCOAT = !1, t.CLEARCOAT_TEXTURE = !1, t.CLEARCOAT_TEXTURE_ROUGHNESS = !1, t.CLEARCOAT_BUMP = !1, t.CLEARCOAT_TINT = !1, t.CLEARCOAT_TINT_TEXTURE = !1, t.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE = !1, t.CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL = !1);
+ }, r.prototype.bindForSubMesh = function(t, e, n, i, o, a, s, d) {
+ var p, y, P, R, B, F, z, J, ie = d._materialDefines, se = ie.CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL;
+ if (!t.useUbo || !o || !t.isSync) {
+ se && lt.a.ClearCoatTextureEnabled ? (t.updateFloat4("vClearCoatInfos", this._texture.coordinatesIndex, this._texture.level, -1, -1), $e.a.BindTextureMatrix(this._texture, t, "clearCoat")) : (this._texture || this._textureRoughness) && lt.a.ClearCoatTextureEnabled && (t.updateFloat4("vClearCoatInfos", (y = (p = this._texture) === null || p === void 0 ? void 0 : p.coordinatesIndex) !== null && y !== void 0 ? y : 0, (R = (P = this._texture) === null || P === void 0 ? void 0 : P.level) !== null && R !== void 0 ? R : 0, (F = (B = this._textureRoughness) === null || B === void 0 ? void 0 : B.coordinatesIndex) !== null && F !== void 0 ? F : 0, (J = (z = this._textureRoughness) === null || z === void 0 ? void 0 : z.level) !== null && J !== void 0 ? J : 0), this._texture && $e.a.BindTextureMatrix(this._texture, t, "clearCoat"), !this._textureRoughness || se || ie.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE || $e.a.BindTextureMatrix(this._textureRoughness, t, "clearCoatRoughness")), this._bumpTexture && n.getCaps().standardDerivatives && lt.a.ClearCoatTextureEnabled && !i && (t.updateFloat2("vClearCoatBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level), $e.a.BindTextureMatrix(this._bumpTexture, t, "clearCoatBump"), e._mirroredCameraPosition ? t.updateFloat2("vClearCoatTangentSpaceParams", a ? 1 : -1, s ? 1 : -1) : t.updateFloat2("vClearCoatTangentSpaceParams", a ? -1 : 1, s ? -1 : 1)), this._tintTexture && lt.a.ClearCoatTintTextureEnabled && (t.updateFloat2("vClearCoatTintInfos", this._tintTexture.coordinatesIndex, this._tintTexture.level), $e.a.BindTextureMatrix(this._tintTexture, t, "clearCoatTint")), t.updateFloat2("vClearCoatParams", this.intensity, this.roughness);
+ var ce = 1 - this._indexOfRefraction, ue = 1 + this._indexOfRefraction, fe = Math.pow(-ce / ue, 2), ve = 1 / this._indexOfRefraction;
+ t.updateFloat4("vClearCoatRefractionParams", fe, ve, ce, ue), this._isTintEnabled && (t.updateFloat4("vClearCoatTintParams", this.tintColor.r, this.tintColor.g, this.tintColor.b, Math.max(1e-5, this.tintThickness)), t.updateFloat("clearCoatColorAtDistance", Math.max(1e-5, this.tintColorAtDistance)));
+ }
+ e.texturesEnabled && (this._texture && lt.a.ClearCoatTextureEnabled && t.setTexture("clearCoatSampler", this._texture), this._textureRoughness && !se && !ie.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE && lt.a.ClearCoatTextureEnabled && t.setTexture("clearCoatRoughnessSampler", this._textureRoughness), this._bumpTexture && n.getCaps().standardDerivatives && lt.a.ClearCoatBumpTextureEnabled && !i && t.setTexture("clearCoatBumpSampler", this._bumpTexture), this._isTintEnabled && this._tintTexture && lt.a.ClearCoatTintTextureEnabled && t.setTexture("clearCoatTintSampler", this._tintTexture));
+ }, r.prototype.hasTexture = function(t) {
+ return this._texture === t || this._textureRoughness === t || this._bumpTexture === t || this._tintTexture === t;
+ }, r.prototype.getActiveTextures = function(t) {
+ this._texture && t.push(this._texture), this._textureRoughness && t.push(this._textureRoughness), this._bumpTexture && t.push(this._bumpTexture), this._tintTexture && t.push(this._tintTexture);
+ }, r.prototype.getAnimatables = function(t) {
+ this._texture && this._texture.animations && this._texture.animations.length > 0 && t.push(this._texture), this._textureRoughness && this._textureRoughness.animations && this._textureRoughness.animations.length > 0 && t.push(this._textureRoughness), this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0 && t.push(this._bumpTexture), this._tintTexture && this._tintTexture.animations && this._tintTexture.animations.length > 0 && t.push(this._tintTexture);
+ }, r.prototype.dispose = function(t) {
+ var e, n, i, o;
+ t && ((e = this._texture) === null || e === void 0 || e.dispose(), (n = this._textureRoughness) === null || n === void 0 || n.dispose(), (i = this._bumpTexture) === null || i === void 0 || i.dispose(), (o = this._tintTexture) === null || o === void 0 || o.dispose());
+ }, r.prototype.getClassName = function() {
+ return "PBRClearCoatConfiguration";
+ }, r.AddFallbacks = function(t, e, n) {
+ return t.CLEARCOAT_BUMP && e.addFallback(n++, "CLEARCOAT_BUMP"), t.CLEARCOAT_TINT && e.addFallback(n++, "CLEARCOAT_TINT"), t.CLEARCOAT && e.addFallback(n++, "CLEARCOAT"), n;
+ }, r.AddUniforms = function(t) {
+ t.push("vClearCoatTangentSpaceParams", "vClearCoatParams", "vClearCoatRefractionParams", "vClearCoatTintParams", "clearCoatColorAtDistance", "clearCoatMatrix", "clearCoatRoughnessMatrix", "clearCoatBumpMatrix", "clearCoatTintMatrix", "vClearCoatInfos", "vClearCoatBumpInfos", "vClearCoatTintInfos");
+ }, r.AddSamplers = function(t) {
+ t.push("clearCoatSampler", "clearCoatRoughnessSampler", "clearCoatBumpSampler", "clearCoatTintSampler");
+ }, r.PrepareUniformBuffer = function(t) {
+ t.addUniform("vClearCoatParams", 2), t.addUniform("vClearCoatRefractionParams", 4), t.addUniform("vClearCoatInfos", 4), t.addUniform("clearCoatMatrix", 16), t.addUniform("clearCoatRoughnessMatrix", 16), t.addUniform("vClearCoatBumpInfos", 2), t.addUniform("vClearCoatTangentSpaceParams", 2), t.addUniform("clearCoatBumpMatrix", 16), t.addUniform("vClearCoatTintParams", 4), t.addUniform("clearCoatColorAtDistance", 1), t.addUniform("vClearCoatTintInfos", 2), t.addUniform("clearCoatTintMatrix", 16);
+ }, r.prototype.copyTo = function(t) {
+ L.a.Clone(function() {
+ return t;
+ }, this);
+ }, r.prototype.serialize = function() {
+ return L.a.Serialize(this);
+ }, r.prototype.parse = function(t, e, n) {
+ var i = this;
+ L.a.Parse(function() {
+ return i;
+ }, t, e, n);
+ }, r._DefaultIndexOfRefraction = 1.5, Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], r.prototype, "isEnabled", void 0), Object(c.c)([Object(L.c)()], r.prototype, "intensity", void 0), Object(c.c)([Object(L.c)()], r.prototype, "roughness", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], r.prototype, "indexOfRefraction", void 0), Object(c.c)([Object(L.m)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], r.prototype, "texture", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], r.prototype, "useRoughnessFromMainTexture", void 0), Object(c.c)([Object(L.m)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], r.prototype, "textureRoughness", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], r.prototype, "remapF0OnInterfaceChange", void 0), Object(c.c)([Object(L.m)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], r.prototype, "bumpTexture", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], r.prototype, "isTintEnabled", void 0), Object(c.c)([Object(L.e)()], r.prototype, "tintColor", void 0), Object(c.c)([Object(L.c)()], r.prototype, "tintColorAtDistance", void 0), Object(c.c)([Object(L.c)()], r.prototype, "tintThickness", void 0), Object(c.c)([Object(L.m)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], r.prototype, "tintTexture", void 0), r;
+ }(), gr = function() {
+ function r(t) {
+ this._isEnabled = !1, this.isEnabled = !1, this.intensity = 1, this.direction = new u.d(1, 0), this._texture = null, this.texture = null, this._internalMarkAllSubMeshesAsTexturesDirty = t;
+ }
+ return r.prototype._markAllSubMeshesAsTexturesDirty = function() {
+ this._internalMarkAllSubMeshesAsTexturesDirty();
+ }, r.prototype.isReadyForSubMesh = function(t, e) {
+ return !(t._areTexturesDirty && e.texturesEnabled && this._texture && lt.a.AnisotropicTextureEnabled && !this._texture.isReadyOrNotBlocking());
+ }, r.prototype.prepareDefines = function(t, e, n) {
+ this._isEnabled ? (t.ANISOTROPIC = this._isEnabled, this._isEnabled && !e.isVerticesDataPresent(Oe.b.TangentKind) && (t._needUVs = !0, t.MAINUV1 = !0), t._areTexturesDirty && n.texturesEnabled && (this._texture && lt.a.AnisotropicTextureEnabled ? $e.a.PrepareDefinesForMergedUV(this._texture, t, "ANISOTROPIC_TEXTURE") : t.ANISOTROPIC_TEXTURE = !1)) : (t.ANISOTROPIC = !1, t.ANISOTROPIC_TEXTURE = !1);
+ }, r.prototype.bindForSubMesh = function(t, e, n) {
+ t.useUbo && n && t.isSync || (this._texture && lt.a.AnisotropicTextureEnabled && (t.updateFloat2("vAnisotropyInfos", this._texture.coordinatesIndex, this._texture.level), $e.a.BindTextureMatrix(this._texture, t, "anisotropy")), t.updateFloat3("vAnisotropy", this.direction.x, this.direction.y, this.intensity)), e.texturesEnabled && this._texture && lt.a.AnisotropicTextureEnabled && t.setTexture("anisotropySampler", this._texture);
+ }, r.prototype.hasTexture = function(t) {
+ return this._texture === t;
+ }, r.prototype.getActiveTextures = function(t) {
+ this._texture && t.push(this._texture);
+ }, r.prototype.getAnimatables = function(t) {
+ this._texture && this._texture.animations && this._texture.animations.length > 0 && t.push(this._texture);
+ }, r.prototype.dispose = function(t) {
+ t && this._texture && this._texture.dispose();
+ }, r.prototype.getClassName = function() {
+ return "PBRAnisotropicConfiguration";
+ }, r.AddFallbacks = function(t, e, n) {
+ return t.ANISOTROPIC && e.addFallback(n++, "ANISOTROPIC"), n;
+ }, r.AddUniforms = function(t) {
+ t.push("vAnisotropy", "vAnisotropyInfos", "anisotropyMatrix");
+ }, r.PrepareUniformBuffer = function(t) {
+ t.addUniform("vAnisotropy", 3), t.addUniform("vAnisotropyInfos", 2), t.addUniform("anisotropyMatrix", 16);
+ }, r.AddSamplers = function(t) {
+ t.push("anisotropySampler");
+ }, r.prototype.copyTo = function(t) {
+ L.a.Clone(function() {
+ return t;
+ }, this);
+ }, r.prototype.serialize = function() {
+ return L.a.Serialize(this);
+ }, r.prototype.parse = function(t, e, n) {
+ var i = this;
+ L.a.Parse(function() {
+ return i;
+ }, t, e, n);
+ }, Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], r.prototype, "isEnabled", void 0), Object(c.c)([Object(L.c)()], r.prototype, "intensity", void 0), Object(c.c)([Object(L.n)()], r.prototype, "direction", void 0), Object(c.c)([Object(L.m)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], r.prototype, "texture", void 0), r;
+ }(), ap = function() {
+ function r(t) {
+ this._useEnergyConservation = r.DEFAULT_USE_ENERGY_CONSERVATION, this.useEnergyConservation = r.DEFAULT_USE_ENERGY_CONSERVATION, this._useSmithVisibilityHeightCorrelated = r.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED, this.useSmithVisibilityHeightCorrelated = r.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED, this._useSphericalHarmonics = r.DEFAULT_USE_SPHERICAL_HARMONICS, this.useSphericalHarmonics = r.DEFAULT_USE_SPHERICAL_HARMONICS, this._useSpecularGlossinessInputEnergyConservation = r.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION, this.useSpecularGlossinessInputEnergyConservation = r.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION, this._internalMarkAllSubMeshesAsMiscDirty = t;
+ }
+ return r.prototype._markAllSubMeshesAsMiscDirty = function() {
+ this._internalMarkAllSubMeshesAsMiscDirty();
+ }, r.prototype.prepareDefines = function(t) {
+ t.BRDF_V_HEIGHT_CORRELATED = this._useSmithVisibilityHeightCorrelated, t.MS_BRDF_ENERGY_CONSERVATION = this._useEnergyConservation && this._useSmithVisibilityHeightCorrelated, t.SPHERICAL_HARMONICS = this._useSphericalHarmonics, t.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION = this._useSpecularGlossinessInputEnergyConservation;
+ }, r.prototype.getClassName = function() {
+ return "PBRBRDFConfiguration";
+ }, r.prototype.copyTo = function(t) {
+ L.a.Clone(function() {
+ return t;
+ }, this);
+ }, r.prototype.serialize = function() {
+ return L.a.Serialize(this);
+ }, r.prototype.parse = function(t, e, n) {
+ var i = this;
+ L.a.Parse(function() {
+ return i;
+ }, t, e, n);
+ }, r.DEFAULT_USE_ENERGY_CONSERVATION = !0, r.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED = !0, r.DEFAULT_USE_SPHERICAL_HARMONICS = !0, r.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION = !0, Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsMiscDirty")], r.prototype, "useEnergyConservation", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsMiscDirty")], r.prototype, "useSmithVisibilityHeightCorrelated", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsMiscDirty")], r.prototype, "useSphericalHarmonics", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsMiscDirty")], r.prototype, "useSpecularGlossinessInputEnergyConservation", void 0), r;
+ }(), Zr = function() {
+ function r(t) {
+ this._isEnabled = !1, this.isEnabled = !1, this._linkSheenWithAlbedo = !1, this.linkSheenWithAlbedo = !1, this.intensity = 1, this.color = I.a.White(), this._texture = null, this.texture = null, this._useRoughnessFromMainTexture = !0, this.useRoughnessFromMainTexture = !0, this._roughness = null, this.roughness = null, this._textureRoughness = null, this.textureRoughness = null, this._albedoScaling = !1, this.albedoScaling = !1, this._internalMarkAllSubMeshesAsTexturesDirty = t;
+ }
+ return r.prototype._markAllSubMeshesAsTexturesDirty = function() {
+ this._internalMarkAllSubMeshesAsTexturesDirty();
+ }, r.prototype.isReadyForSubMesh = function(t, e) {
+ return !(t._areTexturesDirty && e.texturesEnabled && (this._texture && lt.a.SheenTextureEnabled && !this._texture.isReadyOrNotBlocking() || this._textureRoughness && lt.a.SheenTextureEnabled && !this._textureRoughness.isReadyOrNotBlocking()));
+ }, r.prototype.prepareDefines = function(t, e) {
+ var n;
+ this._isEnabled ? (t.SHEEN = this._isEnabled, t.SHEEN_LINKWITHALBEDO = this._linkSheenWithAlbedo, t.SHEEN_ROUGHNESS = this._roughness !== null, t.SHEEN_ALBEDOSCALING = this._albedoScaling, t.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE = this._useRoughnessFromMainTexture, t.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL = this._texture !== null && this._texture._texture === ((n = this._textureRoughness) === null || n === void 0 ? void 0 : n._texture) && this._texture.checkTransformsAreIdentical(this._textureRoughness), t._areTexturesDirty && e.texturesEnabled && (this._texture && lt.a.SheenTextureEnabled ? $e.a.PrepareDefinesForMergedUV(this._texture, t, "SHEEN_TEXTURE") : t.SHEEN_TEXTURE = !1, this._textureRoughness && lt.a.SheenTextureEnabled ? $e.a.PrepareDefinesForMergedUV(this._textureRoughness, t, "SHEEN_TEXTURE_ROUGHNESS") : t.SHEEN_TEXTURE_ROUGHNESS = !1)) : (t.SHEEN = !1, t.SHEEN_TEXTURE = !1, t.SHEEN_TEXTURE_ROUGHNESS = !1, t.SHEEN_LINKWITHALBEDO = !1, t.SHEEN_ROUGHNESS = !1, t.SHEEN_ALBEDOSCALING = !1, t.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE = !1, t.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL = !1);
+ }, r.prototype.bindForSubMesh = function(t, e, n, i) {
+ var o, a, s, d, p, y, P, R, B = i._materialDefines, F = B.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL;
+ t.useUbo && n && t.isSync || (F && lt.a.SheenTextureEnabled ? (t.updateFloat4("vSheenInfos", this._texture.coordinatesIndex, this._texture.level, -1, -1), $e.a.BindTextureMatrix(this._texture, t, "sheen")) : (this._texture || this._textureRoughness) && lt.a.SheenTextureEnabled && (t.updateFloat4("vSheenInfos", (a = (o = this._texture) === null || o === void 0 ? void 0 : o.coordinatesIndex) !== null && a !== void 0 ? a : 0, (d = (s = this._texture) === null || s === void 0 ? void 0 : s.level) !== null && d !== void 0 ? d : 0, (y = (p = this._textureRoughness) === null || p === void 0 ? void 0 : p.coordinatesIndex) !== null && y !== void 0 ? y : 0, (R = (P = this._textureRoughness) === null || P === void 0 ? void 0 : P.level) !== null && R !== void 0 ? R : 0), this._texture && $e.a.BindTextureMatrix(this._texture, t, "sheen"), !this._textureRoughness || F || B.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE || $e.a.BindTextureMatrix(this._textureRoughness, t, "sheenRoughness")), t.updateFloat4("vSheenColor", this.color.r, this.color.g, this.color.b, this.intensity), this._roughness !== null && t.updateFloat("vSheenRoughness", this._roughness)), e.texturesEnabled && (this._texture && lt.a.SheenTextureEnabled && t.setTexture("sheenSampler", this._texture), this._textureRoughness && !F && !B.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE && lt.a.SheenTextureEnabled && t.setTexture("sheenRoughnessSampler", this._textureRoughness));
+ }, r.prototype.hasTexture = function(t) {
+ return this._texture === t || this._textureRoughness === t;
+ }, r.prototype.getActiveTextures = function(t) {
+ this._texture && t.push(this._texture), this._textureRoughness && t.push(this._textureRoughness);
+ }, r.prototype.getAnimatables = function(t) {
+ this._texture && this._texture.animations && this._texture.animations.length > 0 && t.push(this._texture), this._textureRoughness && this._textureRoughness.animations && this._textureRoughness.animations.length > 0 && t.push(this._textureRoughness);
+ }, r.prototype.dispose = function(t) {
+ var e, n;
+ t && ((e = this._texture) === null || e === void 0 || e.dispose(), (n = this._textureRoughness) === null || n === void 0 || n.dispose());
+ }, r.prototype.getClassName = function() {
+ return "PBRSheenConfiguration";
+ }, r.AddFallbacks = function(t, e, n) {
+ return t.SHEEN && e.addFallback(n++, "SHEEN"), n;
+ }, r.AddUniforms = function(t) {
+ t.push("vSheenColor", "vSheenRoughness", "vSheenInfos", "sheenMatrix", "sheenRoughnessMatrix");
+ }, r.PrepareUniformBuffer = function(t) {
+ t.addUniform("vSheenColor", 4), t.addUniform("vSheenRoughness", 1), t.addUniform("vSheenInfos", 4), t.addUniform("sheenMatrix", 16), t.addUniform("sheenRoughnessMatrix", 16);
+ }, r.AddSamplers = function(t) {
+ t.push("sheenSampler"), t.push("sheenRoughnessSampler");
+ }, r.prototype.copyTo = function(t) {
+ L.a.Clone(function() {
+ return t;
+ }, this);
+ }, r.prototype.serialize = function() {
+ return L.a.Serialize(this);
+ }, r.prototype.parse = function(t, e, n) {
+ var i = this;
+ L.a.Parse(function() {
+ return i;
+ }, t, e, n);
+ }, Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], r.prototype, "isEnabled", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], r.prototype, "linkSheenWithAlbedo", void 0), Object(c.c)([Object(L.c)()], r.prototype, "intensity", void 0), Object(c.c)([Object(L.e)()], r.prototype, "color", void 0), Object(c.c)([Object(L.m)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], r.prototype, "texture", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], r.prototype, "useRoughnessFromMainTexture", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], r.prototype, "roughness", void 0), Object(c.c)([Object(L.m)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], r.prototype, "textureRoughness", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], r.prototype, "albedoScaling", void 0), r;
+ }(), Jr = function() {
+ function r(t, e, n) {
+ this._isRefractionEnabled = !1, this.isRefractionEnabled = !1, this._isTranslucencyEnabled = !1, this.isTranslucencyEnabled = !1, this._isScatteringEnabled = !1, this.isScatteringEnabled = !1, this._scatteringDiffusionProfileIndex = 0, this.refractionIntensity = 1, this.translucencyIntensity = 1, this.useAlbedoToTintRefraction = !1, this._thicknessTexture = null, this.thicknessTexture = null, this._refractionTexture = null, this.refractionTexture = null, this._indexOfRefraction = 1.5, this.indexOfRefraction = 1.5, this._volumeIndexOfRefraction = -1, this._invertRefractionY = !1, this.invertRefractionY = !1, this._linkRefractionWithTransparency = !1, this.linkRefractionWithTransparency = !1, this.minimumThickness = 0, this.maximumThickness = 1, this.tintColor = I.a.White(), this.tintColorAtDistance = 1, this.diffusionDistance = I.a.White(), this._useMaskFromThicknessTexture = !1, this.useMaskFromThicknessTexture = !1, this._useMaskFromThicknessTextureGltf = !1, this.useMaskFromThicknessTextureGltf = !1, this._internalMarkAllSubMeshesAsTexturesDirty = t, this._internalMarkScenePrePassDirty = e, this._scene = n;
+ }
+ return Object.defineProperty(r.prototype, "scatteringDiffusionProfile", { get: function() {
+ return this._scene.subSurfaceConfiguration ? this._scene.subSurfaceConfiguration.ssDiffusionProfileColors[this._scatteringDiffusionProfileIndex] : null;
+ }, set: function(t) {
+ this._scene.enableSubSurfaceForPrePass() && t && (this._scatteringDiffusionProfileIndex = this._scene.subSurfaceConfiguration.addDiffusionProfile(t));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "volumeIndexOfRefraction", { get: function() {
+ return this._volumeIndexOfRefraction >= 1 ? this._volumeIndexOfRefraction : this._indexOfRefraction;
+ }, set: function(t) {
+ this._volumeIndexOfRefraction = t >= 1 ? t : -1;
+ }, enumerable: !1, configurable: !0 }), r.prototype._markAllSubMeshesAsTexturesDirty = function() {
+ this._internalMarkAllSubMeshesAsTexturesDirty();
+ }, r.prototype._markScenePrePassDirty = function() {
+ this._internalMarkAllSubMeshesAsTexturesDirty(), this._internalMarkScenePrePassDirty();
+ }, r.prototype.isReadyForSubMesh = function(t, e) {
+ if (t._areTexturesDirty && e.texturesEnabled) {
+ if (this._thicknessTexture && lt.a.ThicknessTextureEnabled && !this._thicknessTexture.isReadyOrNotBlocking())
+ return !1;
+ var n = this._getRefractionTexture(e);
+ if (n && lt.a.RefractionTextureEnabled && !n.isReadyOrNotBlocking())
+ return !1;
+ }
+ return !0;
+ }, r.prototype.prepareDefines = function(t, e) {
+ if (t._areTexturesDirty && (t.SUBSURFACE = !1, t.SS_TRANSLUCENCY = this._isTranslucencyEnabled, t.SS_SCATTERING = this._isScatteringEnabled, t.SS_THICKNESSANDMASK_TEXTURE = !1, t.SS_MASK_FROM_THICKNESS_TEXTURE = !1, t.SS_MASK_FROM_THICKNESS_TEXTURE_GLTF = !1, t.SS_REFRACTION = !1, t.SS_REFRACTIONMAP_3D = !1, t.SS_GAMMAREFRACTION = !1, t.SS_RGBDREFRACTION = !1, t.SS_LINEARSPECULARREFRACTION = !1, t.SS_REFRACTIONMAP_OPPOSITEZ = !1, t.SS_LODINREFRACTIONALPHA = !1, t.SS_LINKREFRACTIONTOTRANSPARENCY = !1, t.SS_ALBEDOFORREFRACTIONTINT = !1, (this._isRefractionEnabled || this._isTranslucencyEnabled || this._isScatteringEnabled) && (t.SUBSURFACE = !0, t._areTexturesDirty && e.texturesEnabled && this._thicknessTexture && lt.a.ThicknessTextureEnabled && $e.a.PrepareDefinesForMergedUV(this._thicknessTexture, t, "SS_THICKNESSANDMASK_TEXTURE"), t.SS_MASK_FROM_THICKNESS_TEXTURE = this._useMaskFromThicknessTexture, t.SS_MASK_FROM_THICKNESS_TEXTURE_GLTF = this._useMaskFromThicknessTextureGltf), this._isRefractionEnabled && e.texturesEnabled)) {
+ var n = this._getRefractionTexture(e);
+ n && lt.a.RefractionTextureEnabled && (t.SS_REFRACTION = !0, t.SS_REFRACTIONMAP_3D = n.isCube, t.SS_GAMMAREFRACTION = n.gammaSpace, t.SS_RGBDREFRACTION = n.isRGBD, t.SS_LINEARSPECULARREFRACTION = n.linearSpecularLOD, t.SS_REFRACTIONMAP_OPPOSITEZ = n.invertZ, t.SS_LODINREFRACTIONALPHA = n.lodLevelInAlpha, t.SS_LINKREFRACTIONTOTRANSPARENCY = this._linkRefractionWithTransparency, t.SS_ALBEDOFORREFRACTIONTINT = this.useAlbedoToTintRefraction);
+ }
+ }, r.prototype.bindForSubMesh = function(t, e, n, i, o, a) {
+ var s = this._getRefractionTexture(e);
+ if (!t.useUbo || !i || !t.isSync) {
+ if (this._thicknessTexture && lt.a.ThicknessTextureEnabled && (t.updateFloat2("vThicknessInfos", this._thicknessTexture.coordinatesIndex, this._thicknessTexture.level), $e.a.BindTextureMatrix(this._thicknessTexture, t, "thickness")), t.updateFloat2("vThicknessParam", this.minimumThickness, this.maximumThickness - this.minimumThickness), s && lt.a.RefractionTextureEnabled) {
+ t.updateMatrix("refractionMatrix", s.getReflectionTextureMatrix());
+ var d = 1;
+ s.isCube || s.depth && (d = s.depth);
+ var p = s.getSize().width, y = this.volumeIndexOfRefraction;
+ t.updateFloat4("vRefractionInfos", s.level, 1 / y, d, this._invertRefractionY ? -1 : 1), t.updateFloat3("vRefractionMicrosurfaceInfos", p, s.lodGenerationScale, s.lodGenerationOffset), a && t.updateFloat2("vRefractionFilteringInfo", p, $.a.Log2(p));
+ }
+ this.isScatteringEnabled && t.updateFloat("scatteringDiffusionProfile", this._scatteringDiffusionProfileIndex), t.updateColor3("vDiffusionDistance", this.diffusionDistance), t.updateFloat4("vTintColor", this.tintColor.r, this.tintColor.g, this.tintColor.b, this.tintColorAtDistance), t.updateFloat3("vSubSurfaceIntensity", this.refractionIntensity, this.translucencyIntensity, 0);
+ }
+ e.texturesEnabled && (this._thicknessTexture && lt.a.ThicknessTextureEnabled && t.setTexture("thicknessSampler", this._thicknessTexture), s && lt.a.RefractionTextureEnabled && (o ? t.setTexture("refractionSampler", s) : (t.setTexture("refractionSampler", s._lodTextureMid || s), t.setTexture("refractionSamplerLow", s._lodTextureLow || s), t.setTexture("refractionSamplerHigh", s._lodTextureHigh || s))));
+ }, r.prototype.unbind = function(t) {
+ return !(!this._refractionTexture || !this._refractionTexture.isRenderTarget) && (t.setTexture("refractionSampler", null), !0);
+ }, r.prototype._getRefractionTexture = function(t) {
+ return this._refractionTexture ? this._refractionTexture : this._isRefractionEnabled ? t.environmentTexture : null;
+ }, Object.defineProperty(r.prototype, "disableAlphaBlending", { get: function() {
+ return this.isRefractionEnabled && this._linkRefractionWithTransparency;
+ }, enumerable: !1, configurable: !0 }), r.prototype.fillRenderTargetTextures = function(t) {
+ lt.a.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget && t.push(this._refractionTexture);
+ }, r.prototype.hasTexture = function(t) {
+ return this._thicknessTexture === t || this._refractionTexture === t;
+ }, r.prototype.hasRenderTargetTextures = function() {
+ return !!(lt.a.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget);
+ }, r.prototype.getActiveTextures = function(t) {
+ this._thicknessTexture && t.push(this._thicknessTexture), this._refractionTexture && t.push(this._refractionTexture);
+ }, r.prototype.getAnimatables = function(t) {
+ this._thicknessTexture && this._thicknessTexture.animations && this._thicknessTexture.animations.length > 0 && t.push(this._thicknessTexture), this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0 && t.push(this._refractionTexture);
+ }, r.prototype.dispose = function(t) {
+ t && (this._thicknessTexture && this._thicknessTexture.dispose(), this._refractionTexture && this._refractionTexture.dispose());
+ }, r.prototype.getClassName = function() {
+ return "PBRSubSurfaceConfiguration";
+ }, r.AddFallbacks = function(t, e, n) {
+ return t.SS_SCATTERING && e.addFallback(n++, "SS_SCATTERING"), t.SS_TRANSLUCENCY && e.addFallback(n++, "SS_TRANSLUCENCY"), n;
+ }, r.AddUniforms = function(t) {
+ t.push("vDiffusionDistance", "vTintColor", "vSubSurfaceIntensity", "vRefractionMicrosurfaceInfos", "vRefractionFilteringInfo", "vRefractionInfos", "vThicknessInfos", "vThicknessParam", "refractionMatrix", "thicknessMatrix", "scatteringDiffusionProfile");
+ }, r.AddSamplers = function(t) {
+ t.push("thicknessSampler", "refractionSampler", "refractionSamplerLow", "refractionSamplerHigh");
+ }, r.PrepareUniformBuffer = function(t) {
+ t.addUniform("vRefractionMicrosurfaceInfos", 3), t.addUniform("vRefractionFilteringInfo", 2), t.addUniform("vRefractionInfos", 4), t.addUniform("refractionMatrix", 16), t.addUniform("vThicknessInfos", 2), t.addUniform("thicknessMatrix", 16), t.addUniform("vThicknessParam", 2), t.addUniform("vDiffusionDistance", 3), t.addUniform("vTintColor", 4), t.addUniform("vSubSurfaceIntensity", 3), t.addUniform("scatteringDiffusionProfile", 1);
+ }, r.prototype.copyTo = function(t) {
+ L.a.Clone(function() {
+ return t;
+ }, this);
+ }, r.prototype.serialize = function() {
+ return L.a.Serialize(this);
+ }, r.prototype.parse = function(t, e, n) {
+ var i = this;
+ L.a.Parse(function() {
+ return i;
+ }, t, e, n);
+ }, Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], r.prototype, "isRefractionEnabled", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], r.prototype, "isTranslucencyEnabled", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markScenePrePassDirty")], r.prototype, "isScatteringEnabled", void 0), Object(c.c)([Object(L.c)()], r.prototype, "_scatteringDiffusionProfileIndex", void 0), Object(c.c)([Object(L.c)()], r.prototype, "refractionIntensity", void 0), Object(c.c)([Object(L.c)()], r.prototype, "translucencyIntensity", void 0), Object(c.c)([Object(L.c)()], r.prototype, "useAlbedoToTintRefraction", void 0), Object(c.c)([Object(L.m)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], r.prototype, "thicknessTexture", void 0), Object(c.c)([Object(L.m)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], r.prototype, "refractionTexture", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], r.prototype, "indexOfRefraction", void 0), Object(c.c)([Object(L.c)()], r.prototype, "_volumeIndexOfRefraction", void 0), Object(c.c)([Object(L.b)("_markAllSubMeshesAsTexturesDirty")], r.prototype, "volumeIndexOfRefraction", null), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], r.prototype, "invertRefractionY", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], r.prototype, "linkRefractionWithTransparency", void 0), Object(c.c)([Object(L.c)()], r.prototype, "minimumThickness", void 0), Object(c.c)([Object(L.c)()], r.prototype, "maximumThickness", void 0), Object(c.c)([Object(L.e)()], r.prototype, "tintColor", void 0), Object(c.c)([Object(L.c)()], r.prototype, "tintColorAtDistance", void 0), Object(c.c)([Object(L.e)()], r.prototype, "diffusionDistance", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], r.prototype, "useMaskFromThicknessTexture", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], r.prototype, "useMaskFromThicknessTextureGltf", void 0), r;
+ }(), Ss = f(105), zt = f(25), sp = (f(160), `uniform vec3 vReflectionColor;
+uniform vec4 vAlbedoColor;
+
+uniform vec4 vLightingIntensity;
+uniform vec4 vReflectivityColor;
+uniform vec4 vMetallicReflectanceFactors;
+uniform vec3 vEmissiveColor;
+uniform float visibility;
+
+#ifdef ALBEDO
+uniform vec2 vAlbedoInfos;
+#endif
+#ifdef AMBIENT
+uniform vec4 vAmbientInfos;
+#endif
+#ifdef BUMP
+uniform vec3 vBumpInfos;
+uniform vec2 vTangentSpaceParams;
+#endif
+#ifdef OPACITY
+uniform vec2 vOpacityInfos;
+#endif
+#ifdef EMISSIVE
+uniform vec2 vEmissiveInfos;
+#endif
+#ifdef LIGHTMAP
+uniform vec2 vLightmapInfos;
+#endif
+#ifdef REFLECTIVITY
+uniform vec3 vReflectivityInfos;
+#endif
+#ifdef MICROSURFACEMAP
+uniform vec2 vMicroSurfaceSamplerInfos;
+#endif
+
+#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(SS_REFRACTION)
+uniform mat4 view;
+#endif
+
+#ifdef REFLECTION
+uniform vec2 vReflectionInfos;
+#ifdef REALTIME_FILTERING
+uniform vec2 vReflectionFilteringInfo;
+#endif
+uniform mat4 reflectionMatrix;
+uniform vec3 vReflectionMicrosurfaceInfos;
+#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)
+uniform vec3 vReflectionPosition;
+uniform vec3 vReflectionSize;
+#endif
+#endif
+
+#ifdef CLEARCOAT
+uniform vec2 vClearCoatParams;
+uniform vec4 vClearCoatRefractionParams;
+#if defined(CLEARCOAT_TEXTURE) || defined(CLEARCOAT_TEXTURE_ROUGHNESS)
+uniform vec4 vClearCoatInfos;
+#endif
+#ifdef CLEARCOAT_TEXTURE
+uniform mat4 clearCoatMatrix;
+#endif
+#ifdef CLEARCOAT_TEXTURE_ROUGHNESS
+uniform mat4 clearCoatRoughnessMatrix;
+#endif
+#ifdef CLEARCOAT_BUMP
+uniform vec2 vClearCoatBumpInfos;
+uniform vec2 vClearCoatTangentSpaceParams;
+uniform mat4 clearCoatBumpMatrix;
+#endif
+#ifdef CLEARCOAT_TINT
+uniform vec4 vClearCoatTintParams;
+uniform float clearCoatColorAtDistance;
+#ifdef CLEARCOAT_TINT_TEXTURE
+uniform vec2 vClearCoatTintInfos;
+uniform mat4 clearCoatTintMatrix;
+#endif
+#endif
+#endif
+
+#ifdef ANISOTROPIC
+uniform vec3 vAnisotropy;
+#ifdef ANISOTROPIC_TEXTURE
+uniform vec2 vAnisotropyInfos;
+uniform mat4 anisotropyMatrix;
+#endif
+#endif
+
+#ifdef SHEEN
+uniform vec4 vSheenColor;
+#ifdef SHEEN_ROUGHNESS
+uniform float vSheenRoughness;
+#endif
+#if defined(SHEEN_TEXTURE) || defined(SHEEN_TEXTURE_ROUGHNESS)
+uniform vec4 vSheenInfos;
+#endif
+#ifdef SHEEN_TEXTURE
+uniform mat4 sheenMatrix;
+#endif
+#ifdef SHEEN_TEXTURE_ROUGHNESS
+uniform mat4 sheenRoughnessMatrix;
+#endif
+#endif
+
+#ifdef SUBSURFACE
+#ifdef SS_REFRACTION
+uniform vec3 vRefractionMicrosurfaceInfos;
+uniform vec4 vRefractionInfos;
+uniform mat4 refractionMatrix;
+#ifdef REALTIME_FILTERING
+uniform vec2 vRefractionFilteringInfo;
+#endif
+#endif
+#ifdef SS_THICKNESSANDMASK_TEXTURE
+uniform vec2 vThicknessInfos;
+uniform mat4 thicknessMatrix;
+#endif
+uniform vec2 vThicknessParam;
+uniform vec3 vDiffusionDistance;
+uniform vec4 vTintColor;
+uniform vec3 vSubSurfaceIntensity;
+#endif
+#ifdef PREPASS
+#ifdef PREPASS_IRRADIANCE
+uniform float scatteringDiffusionProfile;
+#endif
+#endif`);
+ ze.a.IncludesShadersStore.pbrFragmentDeclaration = sp;
+ var cp = `layout(std140,column_major) uniform;
+uniform Material
+{
+uniform vec2 vAlbedoInfos;
+uniform vec4 vAmbientInfos;
+uniform vec2 vOpacityInfos;
+uniform vec2 vEmissiveInfos;
+uniform vec2 vLightmapInfos;
+uniform vec3 vReflectivityInfos;
+uniform vec2 vMicroSurfaceSamplerInfos;
+uniform vec2 vReflectionInfos;
+uniform vec2 vReflectionFilteringInfo;
+uniform vec3 vReflectionPosition;
+uniform vec3 vReflectionSize;
+uniform vec3 vBumpInfos;
+uniform mat4 albedoMatrix;
+uniform mat4 ambientMatrix;
+uniform mat4 opacityMatrix;
+uniform mat4 emissiveMatrix;
+uniform mat4 lightmapMatrix;
+uniform mat4 reflectivityMatrix;
+uniform mat4 microSurfaceSamplerMatrix;
+uniform mat4 bumpMatrix;
+uniform vec2 vTangentSpaceParams;
+uniform mat4 reflectionMatrix;
+uniform vec3 vReflectionColor;
+uniform vec4 vAlbedoColor;
+uniform vec4 vLightingIntensity;
+uniform vec3 vReflectionMicrosurfaceInfos;
+uniform float pointSize;
+uniform vec4 vReflectivityColor;
+uniform vec3 vEmissiveColor;
+uniform float visibility;
+uniform vec4 vMetallicReflectanceFactors;
+uniform vec2 vMetallicReflectanceInfos;
+uniform mat4 metallicReflectanceMatrix;
+uniform vec2 vClearCoatParams;
+uniform vec4 vClearCoatRefractionParams;
+uniform vec4 vClearCoatInfos;
+uniform mat4 clearCoatMatrix;
+uniform mat4 clearCoatRoughnessMatrix;
+uniform vec2 vClearCoatBumpInfos;
+uniform vec2 vClearCoatTangentSpaceParams;
+uniform mat4 clearCoatBumpMatrix;
+uniform vec4 vClearCoatTintParams;
+uniform float clearCoatColorAtDistance;
+uniform vec2 vClearCoatTintInfos;
+uniform mat4 clearCoatTintMatrix;
+uniform vec3 vAnisotropy;
+uniform vec2 vAnisotropyInfos;
+uniform mat4 anisotropyMatrix;
+uniform vec4 vSheenColor;
+uniform float vSheenRoughness;
+uniform vec4 vSheenInfos;
+uniform mat4 sheenMatrix;
+uniform mat4 sheenRoughnessMatrix;
+uniform vec3 vRefractionMicrosurfaceInfos;
+uniform vec2 vRefractionFilteringInfo;
+uniform vec4 vRefractionInfos;
+uniform mat4 refractionMatrix;
+uniform vec2 vThicknessInfos;
+uniform mat4 thicknessMatrix;
+uniform vec2 vThicknessParam;
+uniform vec3 vDiffusionDistance;
+uniform vec4 vTintColor;
+uniform vec3 vSubSurfaceIntensity;
+uniform float scatteringDiffusionProfile;
+uniform vec4 vDetailInfos;
+uniform mat4 detailMatrix;
+};
+uniform Scene {
+mat4 viewProjection;
+#ifdef MULTIVIEW
+mat4 viewProjectionR;
+#endif
+mat4 view;
+};`;
+ ze.a.IncludesShadersStore.pbrUboDeclaration = cp;
+ var lp = `uniform vec4 vEyePosition;
+uniform vec3 vAmbientColor;
+uniform vec4 vCameraInfos;
+
+varying vec3 vPositionW;
+#if DEBUGMODE>0
+uniform vec2 vDebugMode;
+varying vec4 vClipSpacePosition;
+#endif
+#ifdef MAINUV1
+varying vec2 vMainUV1;
+#endif
+#ifdef MAINUV2
+varying vec2 vMainUV2;
+#endif
+#ifdef NORMAL
+varying vec3 vNormalW;
+#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
+varying vec3 vEnvironmentIrradiance;
+#endif
+#endif
+#ifdef VERTEXCOLOR
+varying vec4 vColor;
+#endif`;
+ ze.a.IncludesShadersStore.pbrFragmentExtraDeclaration = lp;
+ var up = `#ifdef ALBEDO
+#if ALBEDODIRECTUV == 1
+#define vAlbedoUV vMainUV1
+#elif ALBEDODIRECTUV == 2
+#define vAlbedoUV vMainUV2
+#else
+varying vec2 vAlbedoUV;
+#endif
+uniform sampler2D albedoSampler;
+#endif
+#ifdef AMBIENT
+#if AMBIENTDIRECTUV == 1
+#define vAmbientUV vMainUV1
+#elif AMBIENTDIRECTUV == 2
+#define vAmbientUV vMainUV2
+#else
+varying vec2 vAmbientUV;
+#endif
+uniform sampler2D ambientSampler;
+#endif
+#ifdef OPACITY
+#if OPACITYDIRECTUV == 1
+#define vOpacityUV vMainUV1
+#elif OPACITYDIRECTUV == 2
+#define vOpacityUV vMainUV2
+#else
+varying vec2 vOpacityUV;
+#endif
+uniform sampler2D opacitySampler;
+#endif
+#ifdef EMISSIVE
+#if EMISSIVEDIRECTUV == 1
+#define vEmissiveUV vMainUV1
+#elif EMISSIVEDIRECTUV == 2
+#define vEmissiveUV vMainUV2
+#else
+varying vec2 vEmissiveUV;
+#endif
+uniform sampler2D emissiveSampler;
+#endif
+#ifdef LIGHTMAP
+#if LIGHTMAPDIRECTUV == 1
+#define vLightmapUV vMainUV1
+#elif LIGHTMAPDIRECTUV == 2
+#define vLightmapUV vMainUV2
+#else
+varying vec2 vLightmapUV;
+#endif
+uniform sampler2D lightmapSampler;
+#endif
+#ifdef REFLECTIVITY
+#if REFLECTIVITYDIRECTUV == 1
+#define vReflectivityUV vMainUV1
+#elif REFLECTIVITYDIRECTUV == 2
+#define vReflectivityUV vMainUV2
+#else
+varying vec2 vReflectivityUV;
+#endif
+uniform sampler2D reflectivitySampler;
+#endif
+#ifdef MICROSURFACEMAP
+#if MICROSURFACEMAPDIRECTUV == 1
+#define vMicroSurfaceSamplerUV vMainUV1
+#elif MICROSURFACEMAPDIRECTUV == 2
+#define vMicroSurfaceSamplerUV vMainUV2
+#else
+varying vec2 vMicroSurfaceSamplerUV;
+#endif
+uniform sampler2D microSurfaceSampler;
+#endif
+#ifdef METALLIC_REFLECTANCE
+#if METALLIC_REFLECTANCEDIRECTUV == 1
+#define vMetallicReflectanceUV vMainUV1
+#elif METALLIC_REFLECTANCEDIRECTUV == 2
+#define vMetallicReflectanceUV vMainUV2
+#else
+varying vec2 vMetallicReflectanceUV;
+#endif
+uniform sampler2D metallicReflectanceSampler;
+#endif
+#ifdef CLEARCOAT
+#if defined(CLEARCOAT_TEXTURE)
+#if CLEARCOAT_TEXTUREDIRECTUV == 1
+#define vClearCoatUV vMainUV1
+#elif CLEARCOAT_TEXTUREDIRECTUV == 2
+#define vClearCoatUV vMainUV2
+#else
+varying vec2 vClearCoatUV;
+#endif
+#endif
+#if defined(CLEARCOAT_TEXTURE_ROUGHNESS)
+#if CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV == 1
+#define vClearCoatRoughnessUV vMainUV1
+#elif CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV == 2
+#define vClearCoatRoughnessUV vMainUV2
+#else
+varying vec2 vClearCoatRoughnessUV;
+#endif
+#endif
+#ifdef CLEARCOAT_TEXTURE
+uniform sampler2D clearCoatSampler;
+#endif
+#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL)
+uniform sampler2D clearCoatRoughnessSampler;
+#endif
+#ifdef CLEARCOAT_BUMP
+#if CLEARCOAT_BUMPDIRECTUV == 1
+#define vClearCoatBumpUV vMainUV1
+#elif CLEARCOAT_BUMPDIRECTUV == 2
+#define vClearCoatBumpUV vMainUV2
+#else
+varying vec2 vClearCoatBumpUV;
+#endif
+uniform sampler2D clearCoatBumpSampler;
+#endif
+#ifdef CLEARCOAT_TINT_TEXTURE
+#if CLEARCOAT_TINT_TEXTUREDIRECTUV == 1
+#define vClearCoatTintUV vMainUV1
+#elif CLEARCOAT_TINT_TEXTUREDIRECTUV == 2
+#define vClearCoatTintUV vMainUV2
+#else
+varying vec2 vClearCoatTintUV;
+#endif
+uniform sampler2D clearCoatTintSampler;
+#endif
+#endif
+#ifdef SHEEN
+#ifdef SHEEN_TEXTURE
+#if SHEEN_TEXTUREDIRECTUV == 1
+#define vSheenUV vMainUV1
+#elif SHEEN_TEXTUREDIRECTUV == 2
+#define vSheenUV vMainUV2
+#else
+varying vec2 vSheenUV;
+#endif
+#endif
+#ifdef SHEEN_TEXTURE_ROUGHNESS
+#if SHEEN_TEXTURE_ROUGHNESSDIRECTUV == 1
+#define vSheenRoughnessUV vMainUV1
+#elif SHEEN_TEXTURE_ROUGHNESSDIRECTUV == 2
+#define vSheenRoughnessUV vMainUV2
+#else
+varying vec2 vSheenRoughnessUV;
+#endif
+#endif
+#ifdef SHEEN_TEXTURE
+uniform sampler2D sheenSampler;
+#endif
+#if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL)
+uniform sampler2D sheenRoughnessSampler;
+#endif
+#endif
+#ifdef ANISOTROPIC
+#ifdef ANISOTROPIC_TEXTURE
+#if ANISOTROPIC_TEXTUREDIRECTUV == 1
+#define vAnisotropyUV vMainUV1
+#elif ANISOTROPIC_TEXTUREDIRECTUV == 2
+#define vAnisotropyUV vMainUV2
+#else
+varying vec2 vAnisotropyUV;
+#endif
+uniform sampler2D anisotropySampler;
+#endif
+#endif
+
+#ifdef REFLECTION
+#ifdef REFLECTIONMAP_3D
+#define sampleReflection(s,c) textureCube(s,c)
+uniform samplerCube reflectionSampler;
+#ifdef LODBASEDMICROSFURACE
+#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)
+#else
+uniform samplerCube reflectionSamplerLow;
+uniform samplerCube reflectionSamplerHigh;
+#endif
+#ifdef USEIRRADIANCEMAP
+uniform samplerCube irradianceSampler;
+#endif
+#else
+#define sampleReflection(s,c) texture2D(s,c)
+uniform sampler2D reflectionSampler;
+#ifdef LODBASEDMICROSFURACE
+#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)
+#else
+uniform sampler2D reflectionSamplerLow;
+uniform sampler2D reflectionSamplerHigh;
+#endif
+#ifdef USEIRRADIANCEMAP
+uniform sampler2D irradianceSampler;
+#endif
+#endif
+#ifdef REFLECTIONMAP_SKYBOX
+varying vec3 vPositionUVW;
+#else
+#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
+varying vec3 vDirectionW;
+#endif
+#endif
+#endif
+#ifdef ENVIRONMENTBRDF
+uniform sampler2D environmentBrdfSampler;
+#endif
+
+#ifdef SUBSURFACE
+#ifdef SS_REFRACTION
+#ifdef SS_REFRACTIONMAP_3D
+#define sampleRefraction(s,c) textureCube(s,c)
+uniform samplerCube refractionSampler;
+#ifdef LODBASEDMICROSFURACE
+#define sampleRefractionLod(s,c,l) textureCubeLodEXT(s,c,l)
+#else
+uniform samplerCube refractionSamplerLow;
+uniform samplerCube refractionSamplerHigh;
+#endif
+#else
+#define sampleRefraction(s,c) texture2D(s,c)
+uniform sampler2D refractionSampler;
+#ifdef LODBASEDMICROSFURACE
+#define sampleRefractionLod(s,c,l) texture2DLodEXT(s,c,l)
+#else
+uniform sampler2D refractionSamplerLow;
+uniform sampler2D refractionSamplerHigh;
+#endif
+#endif
+#endif
+#ifdef SS_THICKNESSANDMASK_TEXTURE
+#if SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 1
+#define vThicknessUV vMainUV1
+#elif SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 2
+#define vThicknessUV vMainUV2
+#else
+varying vec2 vThicknessUV;
+#endif
+uniform sampler2D thicknessSampler;
+#endif
+#endif`;
+ ze.a.IncludesShadersStore.pbrFragmentSamplersDeclaration = up, f(116), ze.a.IncludesShadersStore.subSurfaceScatteringFunctions = `bool testLightingForSSS(float diffusionProfile)
+{
+return diffusionProfile<1.;
+}`;
+ var hp = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+vec3 hemisphereCosSample(vec2 u) {
+
+float phi=2.*PI*u.x;
+float cosTheta2=1.-u.y;
+float cosTheta=sqrt(cosTheta2);
+float sinTheta=sqrt(1.-cosTheta2);
+return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+vec3 hemisphereImportanceSampleDggx(vec2 u,float a) {
+
+float phi=2.*PI*u.x;
+
+float cosTheta2=(1.-u.y)/(1.+(a+1.)*((a-1.)*u.y));
+float cosTheta=sqrt(cosTheta2);
+float sinTheta=sqrt(1.-cosTheta2);
+return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+vec3 hemisphereImportanceSampleDCharlie(vec2 u,float a) {
+
+float phi=2.*PI*u.x;
+float sinTheta=pow(u.y,a/(2.*a+1.));
+float cosTheta=sqrt(1.-sinTheta*sinTheta);
+return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);
+}`;
+ ze.a.IncludesShadersStore.importanceSampling = hp;
+ var dp = `
+#define RECIPROCAL_PI2 0.15915494
+#define RECIPROCAL_PI 0.31830988618
+
+#define MINIMUMVARIANCE 0.0005
+float convertRoughnessToAverageSlope(float roughness)
+{
+
+return square(roughness)+MINIMUMVARIANCE;
+}
+float fresnelGrazingReflectance(float reflectance0) {
+
+
+float reflectance90=saturate(reflectance0*25.0);
+return reflectance90;
+}
+vec2 getAARoughnessFactors(vec3 normalVector) {
+#ifdef SPECULARAA
+vec3 nDfdx=dFdx(normalVector.xyz);
+vec3 nDfdy=dFdy(normalVector.xyz);
+float slopeSquare=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));
+
+float geometricRoughnessFactor=pow(saturate(slopeSquare),0.333);
+
+float geometricAlphaGFactor=sqrt(slopeSquare);
+
+geometricAlphaGFactor*=0.75;
+return vec2(geometricRoughnessFactor,geometricAlphaGFactor);
+#else
+return vec2(0.);
+#endif
+}
+#ifdef ANISOTROPIC
+
+
+vec2 getAnisotropicRoughness(float alphaG,float anisotropy) {
+float alphaT=max(alphaG*(1.0+anisotropy),MINIMUMVARIANCE);
+float alphaB=max(alphaG*(1.0-anisotropy),MINIMUMVARIANCE);
+return vec2(alphaT,alphaB);
+}
+
+
+vec3 getAnisotropicBentNormals(const vec3 T,const vec3 B,const vec3 N,const vec3 V,float anisotropy) {
+vec3 anisotropicFrameDirection=anisotropy>=0.0 ? B : T;
+vec3 anisotropicFrameTangent=cross(normalize(anisotropicFrameDirection),V);
+vec3 anisotropicFrameNormal=cross(anisotropicFrameTangent,anisotropicFrameDirection);
+vec3 anisotropicNormal=normalize(mix(N,anisotropicFrameNormal,abs(anisotropy)));
+return anisotropicNormal;
+
+}
+#endif
+#if defined(CLEARCOAT) || defined(SS_REFRACTION)
+
+
+
+vec3 cocaLambert(vec3 alpha,float distance) {
+return exp(-alpha*distance);
+}
+
+vec3 cocaLambert(float NdotVRefract,float NdotLRefract,vec3 alpha,float thickness) {
+return cocaLambert(alpha,(thickness*((NdotLRefract+NdotVRefract)/(NdotLRefract*NdotVRefract))));
+}
+
+vec3 computeColorAtDistanceInMedia(vec3 color,float distance) {
+return -log(color)/distance;
+}
+vec3 computeClearCoatAbsorption(float NdotVRefract,float NdotLRefract,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {
+vec3 clearCoatAbsorption=mix(vec3(1.0),
+cocaLambert(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness),
+clearCoatIntensity);
+return clearCoatAbsorption;
+}
+#endif
+
+
+
+
+#ifdef MICROSURFACEAUTOMATIC
+float computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor)
+{
+const float kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;
+float reflectivityLuminance=getLuminance(reflectivityColor);
+float reflectivityLuma=sqrt(reflectivityLuminance);
+microSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;
+return microSurface;
+}
+#endif`;
+ ze.a.IncludesShadersStore.pbrHelperFunctions = dp;
+ var fp = `#ifdef USESPHERICALFROMREFLECTIONMAP
+#ifdef SPHERICAL_HARMONICS
+uniform vec3 vSphericalL00;
+uniform vec3 vSphericalL1_1;
+uniform vec3 vSphericalL10;
+uniform vec3 vSphericalL11;
+uniform vec3 vSphericalL2_2;
+uniform vec3 vSphericalL2_1;
+uniform vec3 vSphericalL20;
+uniform vec3 vSphericalL21;
+uniform vec3 vSphericalL22;
+
+
+
+
+
+
+
+vec3 computeEnvironmentIrradiance(vec3 normal) {
+return vSphericalL00
++vSphericalL1_1*(normal.y)
++vSphericalL10*(normal.z)
++vSphericalL11*(normal.x)
++vSphericalL2_2*(normal.y*normal.x)
++vSphericalL2_1*(normal.y*normal.z)
++vSphericalL20*((3.0*normal.z*normal.z)-1.0)
++vSphericalL21*(normal.z*normal.x)
++vSphericalL22*(normal.x*normal.x-(normal.y*normal.y));
+}
+#else
+uniform vec3 vSphericalX;
+uniform vec3 vSphericalY;
+uniform vec3 vSphericalZ;
+uniform vec3 vSphericalXX_ZZ;
+uniform vec3 vSphericalYY_ZZ;
+uniform vec3 vSphericalZZ;
+uniform vec3 vSphericalXY;
+uniform vec3 vSphericalYZ;
+uniform vec3 vSphericalZX;
+
+vec3 computeEnvironmentIrradiance(vec3 normal) {
+
+
+
+
+
+
+
+
+
+float Nx=normal.x;
+float Ny=normal.y;
+float Nz=normal.z;
+vec3 C1=vSphericalZZ.rgb;
+vec3 Cx=vSphericalX.rgb;
+vec3 Cy=vSphericalY.rgb;
+vec3 Cz=vSphericalZ.rgb;
+vec3 Cxx_zz=vSphericalXX_ZZ.rgb;
+vec3 Cyy_zz=vSphericalYY_ZZ.rgb;
+vec3 Cxy=vSphericalXY.rgb;
+vec3 Cyz=vSphericalYZ.rgb;
+vec3 Czx=vSphericalZX.rgb;
+vec3 a1=Cyy_zz*Ny+Cy;
+vec3 a2=Cyz*Nz+a1;
+vec3 b1=Czx*Nz+Cx;
+vec3 b2=Cxy*Ny+b1;
+vec3 b3=Cxx_zz*Nx+b2;
+vec3 t1=Cz*Nz+C1;
+vec3 t2=a2*Ny+t1;
+vec3 t3=b3*Nx+t2;
+return t3;
+}
+#endif
+#endif`;
+ ze.a.IncludesShadersStore.harmonicsFunctions = fp;
+ var pp = `
+struct preLightingInfo
+{
+
+vec3 lightOffset;
+float lightDistanceSquared;
+float lightDistance;
+
+float attenuation;
+
+vec3 L;
+vec3 H;
+float NdotV;
+float NdotLUnclamped;
+float NdotL;
+float VdotH;
+float roughness;
+};
+preLightingInfo computePointAndSpotPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {
+preLightingInfo result;
+
+result.lightOffset=lightData.xyz-vPositionW;
+result.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);
+
+result.lightDistance=sqrt(result.lightDistanceSquared);
+
+result.L=normalize(result.lightOffset);
+result.H=normalize(V+result.L);
+result.VdotH=saturate(dot(V,result.H));
+result.NdotLUnclamped=dot(N,result.L);
+result.NdotL=saturateEps(result.NdotLUnclamped);
+return result;
+}
+preLightingInfo computeDirectionalPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {
+preLightingInfo result;
+
+result.lightDistance=length(-lightData.xyz);
+
+result.L=normalize(-lightData.xyz);
+result.H=normalize(V+result.L);
+result.VdotH=saturate(dot(V,result.H));
+result.NdotLUnclamped=dot(N,result.L);
+result.NdotL=saturateEps(result.NdotLUnclamped);
+return result;
+}
+preLightingInfo computeHemisphericPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {
+preLightingInfo result;
+
+
+result.NdotL=dot(N,lightData.xyz)*0.5+0.5;
+result.NdotL=saturateEps(result.NdotL);
+result.NdotLUnclamped=result.NdotL;
+#ifdef SPECULARTERM
+result.L=normalize(lightData.xyz);
+result.H=normalize(V+result.L);
+result.VdotH=saturate(dot(V,result.H));
+#endif
+return result;
+}`;
+ ze.a.IncludesShadersStore.pbrDirectLightingSetupFunctions = pp;
+ var _p = `float computeDistanceLightFalloff_Standard(vec3 lightOffset,float range)
+{
+return max(0.,1.0-length(lightOffset)/range);
+}
+float computeDistanceLightFalloff_Physical(float lightDistanceSquared)
+{
+return 1.0/maxEps(lightDistanceSquared);
+}
+float computeDistanceLightFalloff_GLTF(float lightDistanceSquared,float inverseSquaredRange)
+{
+float lightDistanceFalloff=1.0/maxEps(lightDistanceSquared);
+float factor=lightDistanceSquared*inverseSquaredRange;
+float attenuation=saturate(1.0-factor*factor);
+attenuation*=attenuation;
+
+lightDistanceFalloff*=attenuation;
+return lightDistanceFalloff;
+}
+float computeDistanceLightFalloff(vec3 lightOffset,float lightDistanceSquared,float range,float inverseSquaredRange)
+{
+#ifdef USEPHYSICALLIGHTFALLOFF
+return computeDistanceLightFalloff_Physical(lightDistanceSquared);
+#elif defined(USEGLTFLIGHTFALLOFF)
+return computeDistanceLightFalloff_GLTF(lightDistanceSquared,inverseSquaredRange);
+#else
+return computeDistanceLightFalloff_Standard(lightOffset,range);
+#endif
+}
+float computeDirectionalLightFalloff_Standard(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent)
+{
+float falloff=0.0;
+float cosAngle=maxEps(dot(-lightDirection,directionToLightCenterW));
+if (cosAngle>=cosHalfAngle)
+{
+falloff=max(0.,pow(cosAngle,exponent));
+}
+return falloff;
+}
+float computeDirectionalLightFalloff_Physical(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle)
+{
+const float kMinusLog2ConeAngleIntensityRatio=6.64385618977;
+
+
+
+
+
+float concentrationKappa=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);
+
+
+vec4 lightDirectionSpreadSG=vec4(-lightDirection*concentrationKappa,-concentrationKappa);
+float falloff=exp2(dot(vec4(directionToLightCenterW,1.0),lightDirectionSpreadSG));
+return falloff;
+}
+float computeDirectionalLightFalloff_GLTF(vec3 lightDirection,vec3 directionToLightCenterW,float lightAngleScale,float lightAngleOffset)
+{
+
+
+
+float cd=dot(-lightDirection,directionToLightCenterW);
+float falloff=saturate(cd*lightAngleScale+lightAngleOffset);
+
+falloff*=falloff;
+return falloff;
+}
+float computeDirectionalLightFalloff(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent,float lightAngleScale,float lightAngleOffset)
+{
+#ifdef USEPHYSICALLIGHTFALLOFF
+return computeDirectionalLightFalloff_Physical(lightDirection,directionToLightCenterW,cosHalfAngle);
+#elif defined(USEGLTFLIGHTFALLOFF)
+return computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenterW,lightAngleScale,lightAngleOffset);
+#else
+return computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent);
+#endif
+}`;
+ ze.a.IncludesShadersStore.pbrDirectLightingFalloffFunctions = _p;
+ var mp = `
+#define FRESNEL_MAXIMUM_ON_ROUGH 0.25
+
+
+
+
+#ifdef MS_BRDF_ENERGY_CONSERVATION
+
+
+vec3 getEnergyConservationFactor(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {
+return 1.0+specularEnvironmentR0*(1.0/environmentBrdf.y-1.0);
+}
+#endif
+#ifdef ENVIRONMENTBRDF
+vec3 getBRDFLookup(float NdotV,float perceptualRoughness) {
+
+vec2 UV=vec2(NdotV,perceptualRoughness);
+
+vec4 brdfLookup=texture2D(environmentBrdfSampler,UV);
+#ifdef ENVIRONMENTBRDF_RGBD
+brdfLookup.rgb=fromRGBD(brdfLookup.rgba);
+#endif
+return brdfLookup.rgb;
+}
+vec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,const vec3 specularEnvironmentR90,const vec3 environmentBrdf) {
+#ifdef BRDF_V_HEIGHT_CORRELATED
+vec3 reflectance=(specularEnvironmentR90-specularEnvironmentR0)*environmentBrdf.x+specularEnvironmentR0*environmentBrdf.y;
+
+#else
+vec3 reflectance=specularEnvironmentR0*environmentBrdf.x+specularEnvironmentR90*environmentBrdf.y;
+#endif
+return reflectance;
+}
+vec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {
+#ifdef BRDF_V_HEIGHT_CORRELATED
+vec3 reflectance=mix(environmentBrdf.xxx,environmentBrdf.yyy,specularEnvironmentR0);
+#else
+vec3 reflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;
+#endif
+return reflectance;
+}
+#endif
+
+#if !defined(ENVIRONMENTBRDF) || defined(REFLECTIONMAP_SKYBOX) || defined(ALPHAFRESNEL)
+vec3 getReflectanceFromAnalyticalBRDFLookup_Jones(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)
+{
+
+float weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);
+return reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));
+}
+#endif
+#if defined(SHEEN) && defined(ENVIRONMENTBRDF)
+
+vec3 getSheenReflectanceFromBRDFLookup(const vec3 reflectance0,const vec3 environmentBrdf) {
+vec3 sheenEnvironmentReflectance=reflectance0*environmentBrdf.b;
+return sheenEnvironmentReflectance;
+}
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+vec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90)
+{
+return reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);
+}
+float fresnelSchlickGGX(float VdotH,float reflectance0,float reflectance90)
+{
+return reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);
+}
+#ifdef CLEARCOAT
+
+
+
+
+
+vec3 getR0RemappedForClearCoat(vec3 f0) {
+#ifdef CLEARCOAT_DEFAULTIOR
+#ifdef MOBILE
+return saturate(f0*(f0*0.526868+0.529324)-0.0482256);
+#else
+return saturate(f0*(f0*(0.941892-0.263008*f0)+0.346479)-0.0285998);
+#endif
+#else
+vec3 s=sqrt(f0);
+vec3 t=(vClearCoatRefractionParams.z+vClearCoatRefractionParams.w*s)/(vClearCoatRefractionParams.w+vClearCoatRefractionParams.z*s);
+return t*t;
+#endif
+}
+#endif
+
+
+
+
+
+
+float normalDistributionFunction_TrowbridgeReitzGGX(float NdotH,float alphaG)
+{
+
+
+
+float a2=square(alphaG);
+float d=NdotH*NdotH*(a2-1.0)+1.0;
+return a2/(PI*d*d);
+}
+#ifdef SHEEN
+
+
+float normalDistributionFunction_CharlieSheen(float NdotH,float alphaG)
+{
+float invR=1./alphaG;
+float cos2h=NdotH*NdotH;
+float sin2h=1.-cos2h;
+return (2.+invR)*pow(sin2h,invR*.5)/(2.*PI);
+}
+#endif
+#ifdef ANISOTROPIC
+
+
+float normalDistributionFunction_BurleyGGX_Anisotropic(float NdotH,float TdotH,float BdotH,const vec2 alphaTB) {
+float a2=alphaTB.x*alphaTB.y;
+vec3 v=vec3(alphaTB.y*TdotH,alphaTB.x*BdotH,a2*NdotH);
+float v2=dot(v,v);
+float w2=a2/v2;
+return a2*w2*w2*RECIPROCAL_PI;
+}
+#endif
+
+
+
+
+#ifdef BRDF_V_HEIGHT_CORRELATED
+
+
+
+float smithVisibility_GGXCorrelated(float NdotL,float NdotV,float alphaG) {
+#ifdef MOBILE
+
+float GGXV=NdotL*(NdotV*(1.0-alphaG)+alphaG);
+float GGXL=NdotV*(NdotL*(1.0-alphaG)+alphaG);
+return 0.5/(GGXV+GGXL);
+#else
+float a2=alphaG*alphaG;
+float GGXV=NdotL*sqrt(NdotV*(NdotV-a2*NdotV)+a2);
+float GGXL=NdotV*sqrt(NdotL*(NdotL-a2*NdotL)+a2);
+return 0.5/(GGXV+GGXL);
+#endif
+}
+#else
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+float smithVisibilityG1_TrowbridgeReitzGGXFast(float dot,float alphaG)
+{
+#ifdef MOBILE
+
+return 1.0/(dot+alphaG+(1.0-alphaG)*dot ));
+#else
+float alphaSquared=alphaG*alphaG;
+return 1.0/(dot+sqrt(alphaSquared+(1.0-alphaSquared)*dot*dot));
+#endif
+}
+float smithVisibility_TrowbridgeReitzGGXFast(float NdotL,float NdotV,float alphaG)
+{
+float visibility=smithVisibilityG1_TrowbridgeReitzGGXFast(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGXFast(NdotV,alphaG);
+
+return visibility;
+}
+#endif
+#ifdef ANISOTROPIC
+
+
+float smithVisibility_GGXCorrelated_Anisotropic(float NdotL,float NdotV,float TdotV,float BdotV,float TdotL,float BdotL,const vec2 alphaTB) {
+float lambdaV=NdotL*length(vec3(alphaTB.x*TdotV,alphaTB.y*BdotV,NdotV));
+float lambdaL=NdotV*length(vec3(alphaTB.x*TdotL,alphaTB.y*BdotL,NdotL));
+float v=0.5/(lambdaV+lambdaL);
+return v;
+}
+#endif
+#ifdef CLEARCOAT
+float visibility_Kelemen(float VdotH) {
+
+
+
+return 0.25/(VdotH*VdotH);
+}
+#endif
+#ifdef SHEEN
+
+
+
+float visibility_Ashikhmin(float NdotL,float NdotV)
+{
+return 1./(4.*(NdotL+NdotV-NdotL*NdotV));
+}
+
+#endif
+
+
+
+
+
+
+
+float diffuseBRDF_Burley(float NdotL,float NdotV,float VdotH,float roughness) {
+
+
+float diffuseFresnelNV=pow5(saturateEps(1.0-NdotL));
+float diffuseFresnelNL=pow5(saturateEps(1.0-NdotV));
+float diffuseFresnel90=0.5+2.0*VdotH*VdotH*roughness;
+float fresnel =
+(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *
+(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);
+return fresnel/PI;
+}
+#ifdef SS_TRANSLUCENCY
+
+
+vec3 transmittanceBRDF_Burley(const vec3 tintColor,const vec3 diffusionDistance,float thickness) {
+vec3 S=1./maxEps(diffusionDistance);
+vec3 temp=exp((-0.333333333*thickness)*S);
+return tintColor.rgb*0.25*(temp*temp*temp+3.0*temp);
+}
+
+
+float computeWrappedDiffuseNdotL(float NdotL,float w) {
+float t=1.0+w;
+float invt2=1.0/square(t);
+return saturate((NdotL+w)*invt2);
+}
+#endif
+`;
+ ze.a.IncludesShadersStore.pbrBRDFFunctions = mp;
+ var gp = `#ifdef NUM_SAMPLES
+#if NUM_SAMPLES>0
+#ifdef WEBGL2
+
+
+float radicalInverse_VdC(uint bits)
+{
+bits=(bits << 16u) | (bits >> 16u);
+bits=((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
+bits=((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
+bits=((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
+bits=((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
+return float(bits)*2.3283064365386963e-10;
+}
+vec2 hammersley(uint i,uint N)
+{
+return vec2(float(i)/float(N),radicalInverse_VdC(i));
+}
+#else
+float vanDerCorpus(int n,int base)
+{
+float invBase=1.0/float(base);
+float denom=1.0;
+float result=0.0;
+for(int i=0; i<32; ++i)
+{
+if(n>0)
+{
+denom=mod(float(n),2.0);
+result+=denom*invBase;
+invBase=invBase/2.0;
+n=int(float(n)/2.0);
+}
+}
+return result;
+}
+vec2 hammersley(int i,int N)
+{
+return vec2(float(i)/float(N),vanDerCorpus(i,2));
+}
+#endif
+float log4(float x) {
+return log2(x)/2.;
+}
+const float NUM_SAMPLES_FLOAT=float(NUM_SAMPLES);
+const float NUM_SAMPLES_FLOAT_INVERSED=1./NUM_SAMPLES_FLOAT;
+const float K=4.;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#define inline
+vec3 irradiance(samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)
+{
+vec3 n=normalize(inputN);
+vec3 result=vec3(0.0);
+vec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);
+tangent=normalize(cross(tangent,n));
+vec3 bitangent=cross(n,tangent);
+mat3 tbn=mat3(tangent,bitangent,n);
+float maxLevel=filteringInfo.y;
+float dim0=filteringInfo.x;
+float omegaP=(4.*PI)/(6.*dim0*dim0);
+#ifdef WEBGL2
+for(uint i=0u; i0.) {
+float pdf_inversed=PI/NoL;
+float omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;
+float l=log4(omegaS)-log4(omegaP)+log4(K);
+float mipLevel=clamp(l,0.0,maxLevel);
+vec3 c=textureCubeLodEXT(inputTexture,tbn*Ls,mipLevel).rgb;
+#ifdef GAMMA_INPUT
+c=toLinearSpace(c);
+#endif
+result+=c;
+}
+}
+result=result*NUM_SAMPLES_FLOAT_INVERSED;
+return result;
+}
+#define inline
+vec3 radiance(float alphaG,samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)
+{
+vec3 n=normalize(inputN);
+if (alphaG == 0.) {
+vec3 c=textureCube(inputTexture,n).rgb;
+#ifdef GAMMA_INPUT
+c=toLinearSpace(c);
+#endif
+return c;
+}
+vec3 result=vec3(0.);
+vec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);
+tangent=normalize(cross(tangent,n));
+vec3 bitangent=cross(n,tangent);
+mat3 tbn=mat3(tangent,bitangent,n);
+float maxLevel=filteringInfo.y;
+float dim0=filteringInfo.x;
+float omegaP=(4.*PI)/(6.*dim0*dim0);
+float weight=0.;
+#ifdef WEBGL2
+for(uint i=0u; i0.) {
+float pdf_inversed=4./normalDistributionFunction_TrowbridgeReitzGGX(NoH,alphaG);
+float omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;
+float l=log4(omegaS)-log4(omegaP)+log4(K);
+float mipLevel=clamp(float(l),0.0,maxLevel);
+weight+=NoL;
+vec3 c=textureCubeLodEXT(inputTexture,tbn*L,mipLevel).rgb;
+#ifdef GAMMA_INPUT
+c=toLinearSpace(c);
+#endif
+result+=c*NoL;
+}
+}
+result=result/weight;
+return result;
+}
+#endif
+#endif`;
+ ze.a.IncludesShadersStore.hdrFilteringFunctions = gp;
+ var vp = `#define CLEARCOATREFLECTANCE90 1.0
+
+struct lightingInfo
+{
+vec3 diffuse;
+#ifdef SPECULARTERM
+vec3 specular;
+#endif
+#ifdef CLEARCOAT
+
+
+vec4 clearCoat;
+#endif
+#ifdef SHEEN
+vec3 sheen;
+#endif
+};
+
+float adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance) {
+#if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF)
+
+float lightRoughness=lightRadius/lightDistance;
+
+float totalRoughness=saturate(lightRoughness+roughness);
+return totalRoughness;
+#else
+return roughness;
+#endif
+}
+vec3 computeHemisphericDiffuseLighting(preLightingInfo info,vec3 lightColor,vec3 groundColor) {
+return mix(groundColor,lightColor,info.NdotL);
+}
+vec3 computeDiffuseLighting(preLightingInfo info,vec3 lightColor) {
+float diffuseTerm=diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.roughness);
+return diffuseTerm*info.attenuation*info.NdotL*lightColor;
+}
+#define inline
+vec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){
+vec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);
+strq/=strq.w;
+vec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;
+return toLinearSpace(textureColor);
+}
+#ifdef SS_TRANSLUCENCY
+vec3 computeDiffuseAndTransmittedLighting(preLightingInfo info,vec3 lightColor,vec3 transmittance) {
+float NdotL=absEps(info.NdotLUnclamped);
+
+float wrapNdotL=computeWrappedDiffuseNdotL(NdotL,0.02);
+
+float trAdapt=step(0.,info.NdotLUnclamped);
+vec3 transmittanceNdotL=mix(transmittance*wrapNdotL,vec3(wrapNdotL),trAdapt);
+float diffuseTerm=diffuseBRDF_Burley(NdotL,info.NdotV,info.VdotH,info.roughness);
+return diffuseTerm*transmittanceNdotL*info.attenuation*lightColor;
+}
+#endif
+#ifdef SPECULARTERM
+vec3 computeSpecularLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {
+float NdotH=saturateEps(dot(N,info.H));
+float roughness=max(info.roughness,geometricRoughnessFactor);
+float alphaG=convertRoughnessToAverageSlope(roughness);
+vec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);
+float distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);
+#ifdef BRDF_V_HEIGHT_CORRELATED
+float smithVisibility=smithVisibility_GGXCorrelated(info.NdotL,info.NdotV,alphaG);
+#else
+float smithVisibility=smithVisibility_TrowbridgeReitzGGXFast(info.NdotL,info.NdotV,alphaG);
+#endif
+vec3 specTerm=fresnel*distribution*smithVisibility;
+return specTerm*info.attenuation*info.NdotL*lightColor;
+}
+#endif
+#ifdef ANISOTROPIC
+vec3 computeAnisotropicSpecularLighting(preLightingInfo info,vec3 V,vec3 N,vec3 T,vec3 B,float anisotropy,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {
+float NdotH=saturateEps(dot(N,info.H));
+float TdotH=dot(T,info.H);
+float BdotH=dot(B,info.H);
+float TdotV=dot(T,V);
+float BdotV=dot(B,V);
+float TdotL=dot(T,info.L);
+float BdotL=dot(B,info.L);
+float alphaG=convertRoughnessToAverageSlope(info.roughness);
+vec2 alphaTB=getAnisotropicRoughness(alphaG,anisotropy);
+alphaTB=max(alphaTB,square(geometricRoughnessFactor));
+vec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);
+float distribution=normalDistributionFunction_BurleyGGX_Anisotropic(NdotH,TdotH,BdotH,alphaTB);
+float smithVisibility=smithVisibility_GGXCorrelated_Anisotropic(info.NdotL,info.NdotV,TdotV,BdotV,TdotL,BdotL,alphaTB);
+vec3 specTerm=fresnel*distribution*smithVisibility;
+return specTerm*info.attenuation*info.NdotL*lightColor;
+}
+#endif
+#ifdef CLEARCOAT
+vec4 computeClearCoatLighting(preLightingInfo info,vec3 Ncc,float geometricRoughnessFactor,float clearCoatIntensity,vec3 lightColor) {
+float NccdotL=saturateEps(dot(Ncc,info.L));
+float NccdotH=saturateEps(dot(Ncc,info.H));
+float clearCoatRoughness=max(info.roughness,geometricRoughnessFactor);
+float alphaG=convertRoughnessToAverageSlope(clearCoatRoughness);
+float fresnel=fresnelSchlickGGX(info.VdotH,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);
+fresnel*=clearCoatIntensity;
+float distribution=normalDistributionFunction_TrowbridgeReitzGGX(NccdotH,alphaG);
+float kelemenVisibility=visibility_Kelemen(info.VdotH);
+float clearCoatTerm=fresnel*distribution*kelemenVisibility;
+return vec4(
+clearCoatTerm*info.attenuation*NccdotL*lightColor,
+1.0-fresnel
+);
+}
+vec3 computeClearCoatLightingAbsorption(float NdotVRefract,vec3 L,vec3 Ncc,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {
+vec3 LRefract=-refract(L,Ncc,vClearCoatRefractionParams.y);
+float NdotLRefract=saturateEps(dot(Ncc,LRefract));
+vec3 absorption=computeClearCoatAbsorption(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);
+return absorption;
+}
+#endif
+#ifdef SHEEN
+vec3 computeSheenLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {
+float NdotH=saturateEps(dot(N,info.H));
+float roughness=max(info.roughness,geometricRoughnessFactor);
+float alphaG=convertRoughnessToAverageSlope(roughness);
+
+
+float fresnel=1.;
+float distribution=normalDistributionFunction_CharlieSheen(NdotH,alphaG);
+
+float visibility=visibility_Ashikhmin(info.NdotL,info.NdotV);
+
+float sheenTerm=fresnel*distribution*visibility;
+return sheenTerm*info.attenuation*info.NdotL*lightColor;
+}
+#endif
+`;
+ ze.a.IncludesShadersStore.pbrDirectLightingFunctions = vp;
+ var yp = `#if defined(REFLECTION) || defined(SS_REFRACTION)
+float getLodFromAlphaG(float cubeMapDimensionPixels,float microsurfaceAverageSlope) {
+float microsurfaceAverageSlopeTexels=cubeMapDimensionPixels*microsurfaceAverageSlope;
+float lod=log2(microsurfaceAverageSlopeTexels);
+return lod;
+}
+float getLinearLodFromRoughness(float cubeMapDimensionPixels,float roughness) {
+float lod=log2(cubeMapDimensionPixels)*roughness;
+return lod;
+}
+#endif
+#if defined(ENVIRONMENTBRDF) && defined(RADIANCEOCCLUSION)
+float environmentRadianceOcclusion(float ambientOcclusion,float NdotVUnclamped) {
+
+
+float temp=NdotVUnclamped+ambientOcclusion;
+return saturate(square(temp)-1.0+ambientOcclusion);
+}
+#endif
+#if defined(ENVIRONMENTBRDF) && defined(HORIZONOCCLUSION)
+float environmentHorizonOcclusion(vec3 view,vec3 normal,vec3 geometricNormal) {
+
+vec3 reflection=reflect(view,normal);
+float temp=saturate(1.0+1.1*dot(reflection,geometricNormal));
+return square(temp);
+}
+#endif
+
+
+
+
+#if defined(LODINREFLECTIONALPHA) || defined(SS_LODINREFRACTIONALPHA)
+
+
+#define UNPACK_LOD(x) (1.0-x)*255.0
+float getLodFromAlphaG(float cubeMapDimensionPixels,float alphaG,float NdotV) {
+float microsurfaceAverageSlope=alphaG;
+
+
+
+
+
+
+microsurfaceAverageSlope*=sqrt(abs(NdotV));
+return getLodFromAlphaG(cubeMapDimensionPixels,microsurfaceAverageSlope);
+}
+#endif`;
+ ze.a.IncludesShadersStore.pbrIBLFunctions = yp, f(132), f(133);
+ var bp = `struct albedoOpacityOutParams
+{
+vec3 surfaceAlbedo;
+float alpha;
+};
+#define pbr_inline
+void albedoOpacityBlock(
+const in vec4 vAlbedoColor,
+#ifdef ALBEDO
+const in vec4 albedoTexture,
+const in vec2 albedoInfos,
+#endif
+#ifdef OPACITY
+const in vec4 opacityMap,
+const in vec2 vOpacityInfos,
+#endif
+#ifdef DETAIL
+const in vec4 detailColor,
+const in vec4 vDetailInfos,
+#endif
+out albedoOpacityOutParams outParams
+)
+{
+
+vec3 surfaceAlbedo=vAlbedoColor.rgb;
+float alpha=vAlbedoColor.a;
+#ifdef ALBEDO
+#if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)
+alpha*=albedoTexture.a;
+#endif
+#ifdef GAMMAALBEDO
+surfaceAlbedo*=toLinearSpace(albedoTexture.rgb);
+#else
+surfaceAlbedo*=albedoTexture.rgb;
+#endif
+surfaceAlbedo*=albedoInfos.y;
+#endif
+#ifdef VERTEXCOLOR
+surfaceAlbedo*=vColor.rgb;
+#endif
+#ifdef DETAIL
+float detailAlbedo=2.0*mix(0.5,detailColor.r,vDetailInfos.y);
+surfaceAlbedo.rgb=surfaceAlbedo.rgb*detailAlbedo*detailAlbedo;
+#endif
+#define CUSTOM_FRAGMENT_UPDATE_ALBEDO
+
+#ifdef OPACITY
+#ifdef OPACITYRGB
+alpha=getLuminance(opacityMap.rgb);
+#else
+alpha*=opacityMap.a;
+#endif
+alpha*=vOpacityInfos.y;
+#endif
+#ifdef VERTEXALPHA
+alpha*=vColor.a;
+#endif
+#if !defined(SS_LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)
+#ifdef ALPHATEST
+if (alpha0
+vec4 surfaceMetallicColorMap;
+vec4 surfaceReflectivityColorMap;
+vec2 metallicRoughness;
+vec3 metallicF0;
+#endif
+};
+#define pbr_inline
+void reflectivityBlock(
+const in vec4 vReflectivityColor,
+#ifdef METALLICWORKFLOW
+const in vec3 surfaceAlbedo,
+const in vec4 metallicReflectanceFactors,
+#endif
+#ifdef REFLECTIVITY
+const in vec3 reflectivityInfos,
+const in vec4 surfaceMetallicOrReflectivityColorMap,
+#endif
+#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
+const in vec3 ambientOcclusionColorIn,
+#endif
+#ifdef MICROSURFACEMAP
+const in vec4 microSurfaceTexel,
+#endif
+#ifdef DETAIL
+const in vec4 detailColor,
+const in vec4 vDetailInfos,
+#endif
+out reflectivityOutParams outParams
+)
+{
+float microSurface=vReflectivityColor.a;
+vec3 surfaceReflectivityColor=vReflectivityColor.rgb;
+#ifdef METALLICWORKFLOW
+vec2 metallicRoughness=surfaceReflectivityColor.rg;
+#ifdef REFLECTIVITY
+#if DEBUGMODE>0
+outParams.surfaceMetallicColorMap=surfaceMetallicOrReflectivityColorMap;
+#endif
+#ifdef AOSTOREINMETALMAPRED
+vec3 aoStoreInMetalMap=vec3(surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r);
+outParams.ambientOcclusionColor=mix(ambientOcclusionColorIn,aoStoreInMetalMap,reflectivityInfos.z);
+#endif
+#ifdef METALLNESSSTOREINMETALMAPBLUE
+metallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.b;
+#else
+metallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.r;
+#endif
+#ifdef ROUGHNESSSTOREINMETALMAPALPHA
+metallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.a;
+#else
+#ifdef ROUGHNESSSTOREINMETALMAPGREEN
+metallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.g;
+#endif
+#endif
+#endif
+#ifdef DETAIL
+float detailRoughness=mix(0.5,detailColor.b,vDetailInfos.w);
+float loLerp=mix(0.,metallicRoughness.g,detailRoughness*2.);
+float hiLerp=mix(metallicRoughness.g,1.,(detailRoughness-0.5)*2.);
+metallicRoughness.g=mix(loLerp,hiLerp,step(detailRoughness,0.5));
+#endif
+#ifdef MICROSURFACEMAP
+metallicRoughness.g*=microSurfaceTexel.r;
+#endif
+#if DEBUGMODE>0
+outParams.metallicRoughness=metallicRoughness;
+#endif
+#define CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS
+
+microSurface=1.0-metallicRoughness.g;
+
+vec3 baseColor=surfaceAlbedo;
+#ifdef FROSTBITE_REFLECTANCE
+
+
+
+
+
+
+outParams.surfaceAlbedo=baseColor.rgb*(1.0-metallicRoughness.r);
+
+surfaceReflectivityColor=mix(0.16*reflectance*reflectance,baseColor,metallicRoughness.r);
+#else
+vec3 metallicF0=metallicReflectanceFactors.rgb;
+#if DEBUGMODE>0
+outParams.metallicF0=metallicF0;
+#endif
+
+outParams.surfaceAlbedo=mix(baseColor.rgb*(1.0-metallicF0),vec3(0.,0.,0.),metallicRoughness.r);
+
+surfaceReflectivityColor=mix(metallicF0,baseColor,metallicRoughness.r);
+#endif
+#else
+#ifdef REFLECTIVITY
+surfaceReflectivityColor*=surfaceMetallicOrReflectivityColorMap.rgb;
+#if DEBUGMODE>0
+outParams.surfaceReflectivityColorMap=surfaceMetallicOrReflectivityColorMap;
+#endif
+#ifdef MICROSURFACEFROMREFLECTIVITYMAP
+microSurface*=surfaceMetallicOrReflectivityColorMap.a;
+microSurface*=reflectivityInfos.z;
+#else
+#ifdef MICROSURFACEAUTOMATIC
+microSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);
+#endif
+#ifdef MICROSURFACEMAP
+microSurface*=microSurfaceTexel.r;
+#endif
+#define CUSTOM_FRAGMENT_UPDATE_MICROSURFACE
+#endif
+#endif
+#endif
+
+microSurface=saturate(microSurface);
+
+float roughness=1.-microSurface;
+outParams.microSurface=microSurface;
+outParams.roughness=roughness;
+outParams.surfaceReflectivityColor=surfaceReflectivityColor;
+}
+`;
+ ze.a.IncludesShadersStore.pbrBlockReflectivity = Tp;
+ var Ep = `struct ambientOcclusionOutParams
+{
+vec3 ambientOcclusionColor;
+#if DEBUGMODE>0
+vec3 ambientOcclusionColorMap;
+#endif
+};
+#define pbr_inline
+void ambientOcclusionBlock(
+#ifdef AMBIENT
+const in vec3 ambientOcclusionColorMap_,
+const in vec4 vAmbientInfos,
+#endif
+out ambientOcclusionOutParams outParams
+)
+{
+vec3 ambientOcclusionColor=vec3(1.,1.,1.);
+#ifdef AMBIENT
+vec3 ambientOcclusionColorMap=ambientOcclusionColorMap_*vAmbientInfos.y;
+#ifdef AMBIENTINGRAYSCALE
+ambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);
+#endif
+ambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);
+#if DEBUGMODE>0
+outParams.ambientOcclusionColorMap=ambientOcclusionColorMap;
+#endif
+#endif
+outParams.ambientOcclusionColor=ambientOcclusionColor;
+}
+`;
+ ze.a.IncludesShadersStore.pbrBlockAmbientOcclusion = Ep;
+ var Sp = `#ifdef ALPHAFRESNEL
+#if defined(ALPHATEST) || defined(ALPHABLEND)
+struct alphaFresnelOutParams
+{
+float alpha;
+};
+#define pbr_inline
+void alphaFresnelBlock(
+const in vec3 normalW,
+const in vec3 viewDirectionW,
+const in float alpha,
+const in float microSurface,
+out alphaFresnelOutParams outParams
+)
+{
+
+
+
+float opacityPerceptual=alpha;
+#ifdef LINEARALPHAFRESNEL
+float opacity0=opacityPerceptual;
+#else
+float opacity0=opacityPerceptual*opacityPerceptual;
+#endif
+float opacity90=fresnelGrazingReflectance(opacity0);
+vec3 normalForward=faceforward(normalW,-viewDirectionW,normalW);
+
+outParams.alpha=getReflectanceFromAnalyticalBRDFLookup_Jones(saturate(dot(viewDirectionW,normalForward)),vec3(opacity0),vec3(opacity90),sqrt(microSurface)).x;
+#ifdef ALPHATEST
+if (outParams.alpha0
+vec3 anisotropyMapData;
+#endif
+};
+#define pbr_inline
+void anisotropicBlock(
+const in vec3 vAnisotropy,
+#ifdef ANISOTROPIC_TEXTURE
+const in vec3 anisotropyMapData,
+#endif
+const in mat3 TBN,
+const in vec3 normalW,
+const in vec3 viewDirectionW,
+out anisotropicOutParams outParams
+)
+{
+float anisotropy=vAnisotropy.b;
+vec3 anisotropyDirection=vec3(vAnisotropy.xy,0.);
+#ifdef ANISOTROPIC_TEXTURE
+anisotropy*=anisotropyMapData.b;
+anisotropyDirection.rg*=anisotropyMapData.rg*2.0-1.0;
+#if DEBUGMODE>0
+outParams.anisotropyMapData=anisotropyMapData;
+#endif
+#endif
+mat3 anisoTBN=mat3(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));
+vec3 anisotropicTangent=normalize(anisoTBN*anisotropyDirection);
+vec3 anisotropicBitangent=normalize(cross(anisoTBN[2],anisotropicTangent));
+outParams.anisotropy=anisotropy;
+outParams.anisotropicTangent=anisotropicTangent;
+outParams.anisotropicBitangent=anisotropicBitangent;
+outParams.anisotropicNormal=getAnisotropicBentNormals(anisotropicTangent,anisotropicBitangent,normalW,viewDirectionW,anisotropy);
+}
+#endif
+`;
+ ze.a.IncludesShadersStore.pbrBlockAnisotropic = Ap;
+ var Pp = `#ifdef REFLECTION
+struct reflectionOutParams
+{
+vec4 environmentRadiance;
+vec3 environmentIrradiance;
+#ifdef REFLECTIONMAP_3D
+vec3 reflectionCoords;
+#else
+vec2 reflectionCoords;
+#endif
+#ifdef SS_TRANSLUCENCY
+#ifdef USESPHERICALFROMREFLECTIONMAP
+#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
+vec3 irradianceVector;
+#endif
+#endif
+#endif
+};
+#define pbr_inline
+void createReflectionCoords(
+const in vec3 vPositionW,
+const in vec3 normalW,
+#ifdef ANISOTROPIC
+const in anisotropicOutParams anisotropicOut,
+#endif
+#ifdef REFLECTIONMAP_3D
+out vec3 reflectionCoords
+#else
+out vec2 reflectionCoords
+#endif
+)
+{
+#ifdef ANISOTROPIC
+vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),anisotropicOut.anisotropicNormal);
+#else
+vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);
+#endif
+#ifdef REFLECTIONMAP_OPPOSITEZ
+reflectionVector.z*=-1.0;
+#endif
+
+#ifdef REFLECTIONMAP_3D
+reflectionCoords=reflectionVector;
+#else
+reflectionCoords=reflectionVector.xy;
+#ifdef REFLECTIONMAP_PROJECTION
+reflectionCoords/=reflectionVector.z;
+#endif
+reflectionCoords.y=1.0-reflectionCoords.y;
+#endif
+}
+#define pbr_inline
+#define inline
+void sampleReflectionTexture(
+const in float alphaG,
+const in vec3 vReflectionMicrosurfaceInfos,
+const in vec2 vReflectionInfos,
+const in vec3 vReflectionColor,
+#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
+const in float NdotVUnclamped,
+#endif
+#ifdef LINEARSPECULARREFLECTION
+const in float roughness,
+#endif
+#ifdef REFLECTIONMAP_3D
+const in samplerCube reflectionSampler,
+const vec3 reflectionCoords,
+#else
+const in sampler2D reflectionSampler,
+const vec2 reflectionCoords,
+#endif
+#ifndef LODBASEDMICROSFURACE
+#ifdef REFLECTIONMAP_3D
+const in samplerCube reflectionSamplerLow,
+const in samplerCube reflectionSamplerHigh,
+#else
+const in sampler2D reflectionSamplerLow,
+const in sampler2D reflectionSamplerHigh,
+#endif
+#endif
+#ifdef REALTIME_FILTERING
+const in vec2 vReflectionFilteringInfo,
+#endif
+out vec4 environmentRadiance
+)
+{
+
+#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
+float reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);
+#elif defined(LINEARSPECULARREFLECTION)
+float reflectionLOD=getLinearLodFromRoughness(vReflectionMicrosurfaceInfos.x,roughness);
+#else
+float reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG);
+#endif
+#ifdef LODBASEDMICROSFURACE
+
+reflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;
+#ifdef LODINREFLECTIONALPHA
+
+
+
+
+
+
+
+
+
+float automaticReflectionLOD=UNPACK_LOD(sampleReflection(reflectionSampler,reflectionCoords).a);
+float requestedReflectionLOD=max(automaticReflectionLOD,reflectionLOD);
+#else
+float requestedReflectionLOD=reflectionLOD;
+#endif
+#ifdef REALTIME_FILTERING
+environmentRadiance=vec4(radiance(alphaG,reflectionSampler,reflectionCoords,vReflectionFilteringInfo),1.0);
+#else
+environmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);
+#endif
+#else
+float lodReflectionNormalized=saturate(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x));
+float lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;
+vec4 environmentMid=sampleReflection(reflectionSampler,reflectionCoords);
+if (lodReflectionNormalizedDoubled<1.0){
+environmentRadiance=mix(
+sampleReflection(reflectionSamplerHigh,reflectionCoords),
+environmentMid,
+lodReflectionNormalizedDoubled
+);
+} else {
+environmentRadiance=mix(
+environmentMid,
+sampleReflection(reflectionSamplerLow,reflectionCoords),
+lodReflectionNormalizedDoubled-1.0
+);
+}
+#endif
+#ifdef RGBDREFLECTION
+environmentRadiance.rgb=fromRGBD(environmentRadiance);
+#endif
+#ifdef GAMMAREFLECTION
+environmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb);
+#endif
+
+environmentRadiance.rgb*=vReflectionInfos.x;
+environmentRadiance.rgb*=vReflectionColor.rgb;
+}
+#define pbr_inline
+#define inline
+void reflectionBlock(
+const in vec3 vPositionW,
+const in vec3 normalW,
+const in float alphaG,
+const in vec3 vReflectionMicrosurfaceInfos,
+const in vec2 vReflectionInfos,
+const in vec3 vReflectionColor,
+#ifdef ANISOTROPIC
+const in anisotropicOutParams anisotropicOut,
+#endif
+#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
+const in float NdotVUnclamped,
+#endif
+#ifdef LINEARSPECULARREFLECTION
+const in float roughness,
+#endif
+#ifdef REFLECTIONMAP_3D
+const in samplerCube reflectionSampler,
+#else
+const in sampler2D reflectionSampler,
+#endif
+#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
+const in vec3 vEnvironmentIrradiance,
+#endif
+#ifdef USESPHERICALFROMREFLECTIONMAP
+#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
+const in mat4 reflectionMatrix,
+#endif
+#endif
+#ifdef USEIRRADIANCEMAP
+#ifdef REFLECTIONMAP_3D
+const in samplerCube irradianceSampler,
+#else
+const in sampler2D irradianceSampler,
+#endif
+#endif
+#ifndef LODBASEDMICROSFURACE
+#ifdef REFLECTIONMAP_3D
+const in samplerCube reflectionSamplerLow,
+const in samplerCube reflectionSamplerHigh,
+#else
+const in sampler2D reflectionSamplerLow,
+const in sampler2D reflectionSamplerHigh,
+#endif
+#endif
+#ifdef REALTIME_FILTERING
+const in vec2 vReflectionFilteringInfo,
+#endif
+out reflectionOutParams outParams
+)
+{
+
+vec4 environmentRadiance=vec4(0.,0.,0.,0.);
+#ifdef REFLECTIONMAP_3D
+vec3 reflectionCoords=vec3(0.);
+#else
+vec2 reflectionCoords=vec2(0.);
+#endif
+createReflectionCoords(
+vPositionW,
+normalW,
+#ifdef ANISOTROPIC
+anisotropicOut,
+#endif
+reflectionCoords
+);
+sampleReflectionTexture(
+alphaG,
+vReflectionMicrosurfaceInfos,
+vReflectionInfos,
+vReflectionColor,
+#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
+NdotVUnclamped,
+#endif
+#ifdef LINEARSPECULARREFLECTION
+roughness,
+#endif
+#ifdef REFLECTIONMAP_3D
+reflectionSampler,
+reflectionCoords,
+#else
+reflectionSampler,
+reflectionCoords,
+#endif
+#ifndef LODBASEDMICROSFURACE
+reflectionSamplerLow,
+reflectionSamplerHigh,
+#endif
+#ifdef REALTIME_FILTERING
+vReflectionFilteringInfo,
+#endif
+environmentRadiance
+);
+
+vec3 environmentIrradiance=vec3(0.,0.,0.);
+#ifdef USESPHERICALFROMREFLECTIONMAP
+#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
+environmentIrradiance=vEnvironmentIrradiance;
+#else
+#ifdef ANISOTROPIC
+vec3 irradianceVector=vec3(reflectionMatrix*vec4(anisotropicOut.anisotropicNormal,0)).xyz;
+#else
+vec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;
+#endif
+#ifdef REFLECTIONMAP_OPPOSITEZ
+irradianceVector.z*=-1.0;
+#endif
+#ifdef INVERTCUBICMAP
+irradianceVector.y*=-1.0;
+#endif
+#if defined(REALTIME_FILTERING)
+environmentIrradiance=irradiance(reflectionSampler,irradianceVector,vReflectionFilteringInfo);
+#else
+environmentIrradiance=computeEnvironmentIrradiance(irradianceVector);
+#endif
+#ifdef SS_TRANSLUCENCY
+outParams.irradianceVector=irradianceVector;
+#endif
+#endif
+#elif defined(USEIRRADIANCEMAP)
+vec4 environmentIrradiance4=sampleReflection(irradianceSampler,reflectionCoords);
+environmentIrradiance=environmentIrradiance4.rgb;
+#ifdef RGBDREFLECTION
+environmentIrradiance.rgb=fromRGBD(environmentIrradiance4);
+#endif
+#ifdef GAMMAREFLECTION
+environmentIrradiance.rgb=toLinearSpace(environmentIrradiance.rgb);
+#endif
+#endif
+environmentIrradiance*=vReflectionColor.rgb;
+outParams.environmentRadiance=environmentRadiance;
+outParams.environmentIrradiance=environmentIrradiance;
+outParams.reflectionCoords=reflectionCoords;
+}
+#endif
+`;
+ ze.a.IncludesShadersStore.pbrBlockReflection = Pp;
+ var xp = `#ifdef SHEEN
+struct sheenOutParams
+{
+float sheenIntensity;
+vec3 sheenColor;
+float sheenRoughness;
+#ifdef SHEEN_LINKWITHALBEDO
+vec3 surfaceAlbedo;
+#endif
+#if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
+float sheenAlbedoScaling;
+#endif
+#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
+vec3 finalSheenRadianceScaled;
+#endif
+#if DEBUGMODE>0
+vec4 sheenMapData;
+vec3 sheenEnvironmentReflectance;
+#endif
+};
+#define pbr_inline
+#define inline
+void sheenBlock(
+const in vec4 vSheenColor,
+#ifdef SHEEN_ROUGHNESS
+const in float vSheenRoughness,
+#if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
+const in vec4 sheenMapRoughnessData,
+#endif
+#endif
+const in float roughness,
+#ifdef SHEEN_TEXTURE
+const in vec4 sheenMapData,
+#endif
+const in float reflectance,
+#ifdef SHEEN_LINKWITHALBEDO
+const in vec3 baseColor,
+const in vec3 surfaceAlbedo,
+#endif
+#ifdef ENVIRONMENTBRDF
+const in float NdotV,
+const in vec3 environmentBrdf,
+#endif
+#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
+const in vec2 AARoughnessFactors,
+const in vec3 vReflectionMicrosurfaceInfos,
+const in vec2 vReflectionInfos,
+const in vec3 vReflectionColor,
+const in vec4 vLightingIntensity,
+#ifdef REFLECTIONMAP_3D
+const in samplerCube reflectionSampler,
+const in vec3 reflectionCoords,
+#else
+const in sampler2D reflectionSampler,
+const in vec2 reflectionCoords,
+#endif
+const in float NdotVUnclamped,
+#ifndef LODBASEDMICROSFURACE
+#ifdef REFLECTIONMAP_3D
+const in samplerCube reflectionSamplerLow,
+const in samplerCube reflectionSamplerHigh,
+#else
+const in sampler2D reflectionSamplerLow,
+const in sampler2D reflectionSamplerHigh,
+#endif
+#endif
+#ifdef REALTIME_FILTERING
+const in vec2 vReflectionFilteringInfo,
+#endif
+#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
+const in float seo,
+#endif
+#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
+const in float eho,
+#endif
+#endif
+out sheenOutParams outParams
+)
+{
+float sheenIntensity=vSheenColor.a;
+#ifdef SHEEN_TEXTURE
+#if DEBUGMODE>0
+outParams.sheenMapData=sheenMapData;
+#endif
+#endif
+#ifdef SHEEN_LINKWITHALBEDO
+float sheenFactor=pow5(1.0-sheenIntensity);
+vec3 sheenColor=baseColor.rgb*(1.0-sheenFactor);
+float sheenRoughness=sheenIntensity;
+outParams.surfaceAlbedo=surfaceAlbedo*sheenFactor;
+#ifdef SHEEN_TEXTURE
+sheenIntensity*=sheenMapData.a;
+#endif
+#else
+vec3 sheenColor=vSheenColor.rgb;
+#ifdef SHEEN_TEXTURE
+sheenColor.rgb*=sheenMapData.rgb;
+#endif
+#ifdef SHEEN_ROUGHNESS
+float sheenRoughness=vSheenRoughness;
+#ifdef SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE
+#if defined(SHEEN_TEXTURE)
+sheenRoughness*=sheenMapData.a;
+#endif
+#elif defined(SHEEN_TEXTURE_ROUGHNESS)
+#ifdef SHEEN_TEXTURE_ROUGHNESS_IDENTICAL
+sheenRoughness*=sheenMapData.a;
+#else
+sheenRoughness*=sheenMapRoughnessData.a;
+#endif
+#endif
+#else
+float sheenRoughness=roughness;
+#ifdef SHEEN_TEXTURE
+sheenIntensity*=sheenMapData.a;
+#endif
+#endif
+
+#if !defined(SHEEN_ALBEDOSCALING)
+sheenIntensity*=(1.-reflectance);
+#endif
+
+sheenColor*=sheenIntensity;
+#endif
+
+#ifdef ENVIRONMENTBRDF
+
+#ifdef SHEEN_ROUGHNESS
+vec3 environmentSheenBrdf=getBRDFLookup(NdotV,sheenRoughness);
+#else
+vec3 environmentSheenBrdf=environmentBrdf;
+#endif
+
+#endif
+#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
+float sheenAlphaG=convertRoughnessToAverageSlope(sheenRoughness);
+#ifdef SPECULARAA
+
+sheenAlphaG+=AARoughnessFactors.y;
+#endif
+vec4 environmentSheenRadiance=vec4(0.,0.,0.,0.);
+sampleReflectionTexture(
+sheenAlphaG,
+vReflectionMicrosurfaceInfos,
+vReflectionInfos,
+vReflectionColor,
+#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
+NdotVUnclamped,
+#endif
+#ifdef LINEARSPECULARREFLECTION
+sheenRoughness,
+#endif
+reflectionSampler,
+reflectionCoords,
+#ifndef LODBASEDMICROSFURACE
+reflectionSamplerLow,
+reflectionSamplerHigh,
+#endif
+#ifdef REALTIME_FILTERING
+vReflectionFilteringInfo,
+#endif
+environmentSheenRadiance
+);
+vec3 sheenEnvironmentReflectance=getSheenReflectanceFromBRDFLookup(sheenColor,environmentSheenBrdf);
+#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
+sheenEnvironmentReflectance*=seo;
+#endif
+#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
+sheenEnvironmentReflectance*=eho;
+#endif
+#if DEBUGMODE>0
+outParams.sheenEnvironmentReflectance=sheenEnvironmentReflectance;
+#endif
+outParams.finalSheenRadianceScaled=
+environmentSheenRadiance.rgb *
+sheenEnvironmentReflectance *
+vLightingIntensity.z;
+
+
+
+
+
+#endif
+#if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
+
+
+
+outParams.sheenAlbedoScaling=1.0-sheenIntensity*max(max(sheenColor.r,sheenColor.g),sheenColor.b)*environmentSheenBrdf.b;
+#endif
+
+outParams.sheenIntensity=sheenIntensity;
+outParams.sheenColor=sheenColor;
+outParams.sheenRoughness=sheenRoughness;
+}
+#endif
+`;
+ ze.a.IncludesShadersStore.pbrBlockSheen = xp;
+ var Cp = `struct clearcoatOutParams
+{
+vec3 specularEnvironmentR0;
+float conservationFactor;
+vec3 clearCoatNormalW;
+vec2 clearCoatAARoughnessFactors;
+float clearCoatIntensity;
+float clearCoatRoughness;
+#ifdef REFLECTION
+vec3 finalClearCoatRadianceScaled;
+#endif
+#ifdef CLEARCOAT_TINT
+vec3 absorption;
+float clearCoatNdotVRefract;
+vec3 clearCoatColor;
+float clearCoatThickness;
+#endif
+#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
+vec3 energyConservationFactorClearCoat;
+#endif
+#if DEBUGMODE>0
+mat3 TBNClearCoat;
+vec2 clearCoatMapData;
+vec4 clearCoatTintMapData;
+vec4 environmentClearCoatRadiance;
+float clearCoatNdotV;
+vec3 clearCoatEnvironmentReflectance;
+#endif
+};
+#ifdef CLEARCOAT
+#define pbr_inline
+#define inline
+void clearcoatBlock(
+const in vec3 vPositionW,
+const in vec3 geometricNormalW,
+const in vec3 viewDirectionW,
+const in vec2 vClearCoatParams,
+#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
+const in vec4 clearCoatMapRoughnessData,
+#endif
+const in vec3 specularEnvironmentR0,
+#ifdef CLEARCOAT_TEXTURE
+const in vec2 clearCoatMapData,
+#endif
+#ifdef CLEARCOAT_TINT
+const in vec4 vClearCoatTintParams,
+const in float clearCoatColorAtDistance,
+const in vec4 vClearCoatRefractionParams,
+#ifdef CLEARCOAT_TINT_TEXTURE
+const in vec4 clearCoatTintMapData,
+#endif
+#endif
+#ifdef CLEARCOAT_BUMP
+const in vec2 vClearCoatBumpInfos,
+const in vec4 clearCoatBumpMapData,
+const in vec2 vClearCoatBumpUV,
+#if defined(TANGENT) && defined(NORMAL)
+const in mat3 vTBN,
+#else
+const in vec2 vClearCoatTangentSpaceParams,
+#endif
+#ifdef OBJECTSPACE_NORMALMAP
+const in mat4 normalMatrix,
+#endif
+#endif
+#if defined(FORCENORMALFORWARD) && defined(NORMAL)
+const in vec3 faceNormal,
+#endif
+#ifdef REFLECTION
+const in vec3 vReflectionMicrosurfaceInfos,
+const in vec2 vReflectionInfos,
+const in vec3 vReflectionColor,
+const in vec4 vLightingIntensity,
+#ifdef REFLECTIONMAP_3D
+const in samplerCube reflectionSampler,
+#else
+const in sampler2D reflectionSampler,
+#endif
+#ifndef LODBASEDMICROSFURACE
+#ifdef REFLECTIONMAP_3D
+const in samplerCube reflectionSamplerLow,
+const in samplerCube reflectionSamplerHigh,
+#else
+const in sampler2D reflectionSamplerLow,
+const in sampler2D reflectionSamplerHigh,
+#endif
+#endif
+#ifdef REALTIME_FILTERING
+const in vec2 vReflectionFilteringInfo,
+#endif
+#endif
+#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
+#ifdef RADIANCEOCCLUSION
+const in float ambientMonochrome,
+#endif
+#endif
+out clearcoatOutParams outParams
+)
+{
+
+float clearCoatIntensity=vClearCoatParams.x;
+float clearCoatRoughness=vClearCoatParams.y;
+#ifdef CLEARCOAT_TEXTURE
+clearCoatIntensity*=clearCoatMapData.x;
+#ifdef CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE
+clearCoatRoughness*=clearCoatMapData.y;
+#endif
+#if DEBUGMODE>0
+outParams.clearCoatMapData=clearCoatMapData;
+#endif
+#endif
+#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
+#ifdef CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL
+clearCoatRoughness*=clearCoatMapData.y;
+#else
+clearCoatRoughness*=clearCoatMapRoughnessData.y;
+#endif
+#endif
+outParams.clearCoatIntensity=clearCoatIntensity;
+outParams.clearCoatRoughness=clearCoatRoughness;
+#ifdef CLEARCOAT_TINT
+vec3 clearCoatColor=vClearCoatTintParams.rgb;
+float clearCoatThickness=vClearCoatTintParams.a;
+#ifdef CLEARCOAT_TINT_TEXTURE
+clearCoatColor*=clearCoatTintMapData.rgb;
+clearCoatThickness*=clearCoatTintMapData.a;
+#if DEBUGMODE>0
+outParams.clearCoatTintMapData=clearCoatTintMapData;
+#endif
+#endif
+outParams.clearCoatColor=computeColorAtDistanceInMedia(clearCoatColor,clearCoatColorAtDistance);
+outParams.clearCoatThickness=clearCoatThickness;
+#endif
+
+
+
+
+#ifdef CLEARCOAT_REMAP_F0
+vec3 specularEnvironmentR0Updated=getR0RemappedForClearCoat(specularEnvironmentR0);
+#else
+vec3 specularEnvironmentR0Updated=specularEnvironmentR0;
+#endif
+outParams.specularEnvironmentR0=mix(specularEnvironmentR0,specularEnvironmentR0Updated,clearCoatIntensity);
+
+vec3 clearCoatNormalW=geometricNormalW;
+#ifdef CLEARCOAT_BUMP
+#ifdef NORMALXYSCALE
+float clearCoatNormalScale=1.0;
+#else
+float clearCoatNormalScale=vClearCoatBumpInfos.y;
+#endif
+#if defined(TANGENT) && defined(NORMAL)
+mat3 TBNClearCoat=vTBN;
+#else
+mat3 TBNClearCoat=cotangent_frame(clearCoatNormalW*clearCoatNormalScale,vPositionW,vClearCoatBumpUV,vClearCoatTangentSpaceParams);
+#endif
+#if DEBUGMODE>0
+outParams.TBNClearCoat=TBNClearCoat;
+#endif
+#ifdef OBJECTSPACE_NORMALMAP
+clearCoatNormalW=normalize(clearCoatBumpMapData.xyz*2.0-1.0);
+clearCoatNormalW=normalize(mat3(normalMatrix)*clearCoatNormalW);
+#else
+clearCoatNormalW=perturbNormal(TBNClearCoat,clearCoatBumpMapData.xyz,vClearCoatBumpInfos.y);
+#endif
+#endif
+#if defined(FORCENORMALFORWARD) && defined(NORMAL)
+clearCoatNormalW*=sign(dot(clearCoatNormalW,faceNormal));
+#endif
+#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
+clearCoatNormalW=gl_FrontFacing ? clearCoatNormalW : -clearCoatNormalW;
+#endif
+outParams.clearCoatNormalW=clearCoatNormalW;
+
+outParams.clearCoatAARoughnessFactors=getAARoughnessFactors(clearCoatNormalW.xyz);
+
+float clearCoatNdotVUnclamped=dot(clearCoatNormalW,viewDirectionW);
+
+float clearCoatNdotV=absEps(clearCoatNdotVUnclamped);
+#if DEBUGMODE>0
+outParams.clearCoatNdotV=clearCoatNdotV;
+#endif
+#ifdef CLEARCOAT_TINT
+
+vec3 clearCoatVRefract=-refract(vPositionW,clearCoatNormalW,vClearCoatRefractionParams.y);
+
+outParams.clearCoatNdotVRefract=absEps(dot(clearCoatNormalW,clearCoatVRefract));
+#endif
+#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
+
+vec3 environmentClearCoatBrdf=getBRDFLookup(clearCoatNdotV,clearCoatRoughness);
+#endif
+
+#if defined(REFLECTION)
+float clearCoatAlphaG=convertRoughnessToAverageSlope(clearCoatRoughness);
+#ifdef SPECULARAA
+
+clearCoatAlphaG+=outParams.clearCoatAARoughnessFactors.y;
+#endif
+vec4 environmentClearCoatRadiance=vec4(0.,0.,0.,0.);
+vec3 clearCoatReflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),clearCoatNormalW);
+#ifdef REFLECTIONMAP_OPPOSITEZ
+clearCoatReflectionVector.z*=-1.0;
+#endif
+
+#ifdef REFLECTIONMAP_3D
+vec3 clearCoatReflectionCoords=clearCoatReflectionVector;
+#else
+vec2 clearCoatReflectionCoords=clearCoatReflectionVector.xy;
+#ifdef REFLECTIONMAP_PROJECTION
+clearCoatReflectionCoords/=clearCoatReflectionVector.z;
+#endif
+clearCoatReflectionCoords.y=1.0-clearCoatReflectionCoords.y;
+#endif
+sampleReflectionTexture(
+clearCoatAlphaG,
+vReflectionMicrosurfaceInfos,
+vReflectionInfos,
+vReflectionColor,
+#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
+clearCoatNdotVUnclamped,
+#endif
+#ifdef LINEARSPECULARREFLECTION
+clearCoatRoughness,
+#endif
+reflectionSampler,
+clearCoatReflectionCoords,
+#ifndef LODBASEDMICROSFURACE
+reflectionSamplerLow,
+reflectionSamplerHigh,
+#endif
+#ifdef REALTIME_FILTERING
+vReflectionFilteringInfo,
+#endif
+environmentClearCoatRadiance
+);
+#if DEBUGMODE>0
+outParams.environmentClearCoatRadiance=environmentClearCoatRadiance;
+#endif
+
+#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
+vec3 clearCoatEnvironmentReflectance=getReflectanceFromBRDFLookup(vec3(vClearCoatRefractionParams.x),environmentClearCoatBrdf);
+#ifdef RADIANCEOCCLUSION
+float clearCoatSeo=environmentRadianceOcclusion(ambientMonochrome,clearCoatNdotVUnclamped);
+clearCoatEnvironmentReflectance*=clearCoatSeo;
+#endif
+#ifdef HORIZONOCCLUSION
+#ifdef BUMP
+#ifdef REFLECTIONMAP_3D
+float clearCoatEho=environmentHorizonOcclusion(-viewDirectionW,clearCoatNormalW,geometricNormalW);
+clearCoatEnvironmentReflectance*=clearCoatEho;
+#endif
+#endif
+#endif
+#else
+
+vec3 clearCoatEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(clearCoatNdotV,vec3(1.),vec3(1.),sqrt(1.-clearCoatRoughness));
+#endif
+clearCoatEnvironmentReflectance*=clearCoatIntensity;
+#if DEBUGMODE>0
+outParams.clearCoatEnvironmentReflectance=clearCoatEnvironmentReflectance;
+#endif
+outParams.finalClearCoatRadianceScaled=
+environmentClearCoatRadiance.rgb *
+clearCoatEnvironmentReflectance *
+vLightingIntensity.z;
+#endif
+#if defined(CLEARCOAT_TINT)
+
+outParams.absorption=computeClearCoatAbsorption(outParams.clearCoatNdotVRefract,outParams.clearCoatNdotVRefract,outParams.clearCoatColor,clearCoatThickness,clearCoatIntensity);
+#endif
+
+float fresnelIBLClearCoat=fresnelSchlickGGX(clearCoatNdotV,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);
+fresnelIBLClearCoat*=clearCoatIntensity;
+outParams.conservationFactor=(1.-fresnelIBLClearCoat);
+#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
+outParams.energyConservationFactorClearCoat=getEnergyConservationFactor(outParams.specularEnvironmentR0,environmentClearCoatBrdf);
+#endif
+}
+#endif
+`;
+ ze.a.IncludesShadersStore.pbrBlockClearcoat = Cp;
+ var Rp = `struct subSurfaceOutParams
+{
+vec3 specularEnvironmentReflectance;
+#ifdef SS_REFRACTION
+vec3 finalRefraction;
+vec3 surfaceAlbedo;
+#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
+float alpha;
+#endif
+#ifdef REFLECTION
+float refractionFactorForIrradiance;
+#endif
+#endif
+#ifdef SS_TRANSLUCENCY
+vec3 transmittance;
+float translucencyIntensity;
+#ifdef REFLECTION
+vec3 refractionIrradiance;
+#endif
+#endif
+#if DEBUGMODE>0
+vec4 thicknessMap;
+vec4 environmentRefraction;
+vec3 refractionTransmittance;
+#endif
+};
+#ifdef SUBSURFACE
+#define pbr_inline
+#define inline
+void subSurfaceBlock(
+const in vec3 vSubSurfaceIntensity,
+const in vec2 vThicknessParam,
+const in vec4 vTintColor,
+const in vec3 normalW,
+const in vec3 specularEnvironmentReflectance,
+#ifdef SS_THICKNESSANDMASK_TEXTURE
+const in vec4 thicknessMap,
+#endif
+#ifdef REFLECTION
+#ifdef SS_TRANSLUCENCY
+const in mat4 reflectionMatrix,
+#ifdef USESPHERICALFROMREFLECTIONMAP
+#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
+const in vec3 irradianceVector_,
+#endif
+#if defined(REALTIME_FILTERING)
+const in samplerCube reflectionSampler,
+const in vec2 vReflectionFilteringInfo,
+#endif
+#endif
+#ifdef USEIRRADIANCEMAP
+#ifdef REFLECTIONMAP_3D
+const in samplerCube irradianceSampler,
+#else
+const in sampler2D irradianceSampler,
+#endif
+#endif
+#endif
+#endif
+#ifdef SS_REFRACTION
+const in vec3 vPositionW,
+const in vec3 viewDirectionW,
+const in mat4 view,
+const in vec3 surfaceAlbedo,
+const in vec4 vRefractionInfos,
+const in mat4 refractionMatrix,
+const in vec3 vRefractionMicrosurfaceInfos,
+const in vec4 vLightingIntensity,
+#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
+const in float alpha,
+#endif
+#ifdef SS_LODINREFRACTIONALPHA
+const in float NdotVUnclamped,
+#endif
+#ifdef SS_LINEARSPECULARREFRACTION
+const in float roughness,
+#else
+const in float alphaG,
+#endif
+#ifdef SS_REFRACTIONMAP_3D
+const in samplerCube refractionSampler,
+#ifndef LODBASEDMICROSFURACE
+const in samplerCube refractionSamplerLow,
+const in samplerCube refractionSamplerHigh,
+#endif
+#else
+const in sampler2D refractionSampler,
+#ifndef LODBASEDMICROSFURACE
+const in sampler2D refractionSamplerLow,
+const in sampler2D refractionSamplerHigh,
+#endif
+#endif
+#ifdef ANISOTROPIC
+const in anisotropicOutParams anisotropicOut,
+#endif
+#ifdef REALTIME_FILTERING
+const in vec2 vRefractionFilteringInfo,
+#endif
+#endif
+#ifdef SS_TRANSLUCENCY
+const in vec3 vDiffusionDistance,
+#endif
+out subSurfaceOutParams outParams
+)
+{
+outParams.specularEnvironmentReflectance=specularEnvironmentReflectance;
+
+
+
+#ifdef SS_REFRACTION
+float refractionIntensity=vSubSurfaceIntensity.x;
+#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
+refractionIntensity*=(1.0-alpha);
+
+outParams.alpha=1.0;
+#endif
+#endif
+#ifdef SS_TRANSLUCENCY
+float translucencyIntensity=vSubSurfaceIntensity.y;
+#endif
+#ifdef SS_THICKNESSANDMASK_TEXTURE
+float thickness=thicknessMap.r*vThicknessParam.y+vThicknessParam.x;
+#if DEBUGMODE>0
+outParams.thicknessMap=thicknessMap;
+#endif
+#ifdef SS_MASK_FROM_THICKNESS_TEXTURE
+#ifdef SS_REFRACTION
+refractionIntensity*=thicknessMap.g;
+#endif
+#ifdef SS_TRANSLUCENCY
+translucencyIntensity*=thicknessMap.b;
+#endif
+#elif defined(SS_MASK_FROM_THICKNESS_TEXTURE_GLTF)
+#ifdef SS_REFRACTION
+refractionIntensity*=thicknessMap.r;
+#elif defined(SS_TRANSLUCENCY)
+translucencyIntensity*=thicknessMap.r;
+#endif
+thickness=thicknessMap.g*vThicknessParam.y+vThicknessParam.x;
+#endif
+#else
+float thickness=vThicknessParam.y;
+#endif
+
+
+
+#ifdef SS_TRANSLUCENCY
+thickness=maxEps(thickness);
+vec3 transmittance=transmittanceBRDF_Burley(vTintColor.rgb,vDiffusionDistance,thickness);
+transmittance*=translucencyIntensity;
+outParams.transmittance=transmittance;
+outParams.translucencyIntensity=translucencyIntensity;
+#endif
+
+
+
+#ifdef SS_REFRACTION
+vec4 environmentRefraction=vec4(0.,0.,0.,0.);
+#ifdef ANISOTROPIC
+vec3 refractionVector=refract(-viewDirectionW,anisotropicOut.anisotropicNormal,vRefractionInfos.y);
+#else
+vec3 refractionVector=refract(-viewDirectionW,normalW,vRefractionInfos.y);
+#endif
+#ifdef SS_REFRACTIONMAP_OPPOSITEZ
+refractionVector.z*=-1.0;
+#endif
+
+#ifdef SS_REFRACTIONMAP_3D
+refractionVector.y=refractionVector.y*vRefractionInfos.w;
+vec3 refractionCoords=refractionVector;
+refractionCoords=vec3(refractionMatrix*vec4(refractionCoords,0));
+#else
+vec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));
+vec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;
+refractionCoords.y=1.0-refractionCoords.y;
+#endif
+#ifdef SS_LODINREFRACTIONALPHA
+float refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);
+#elif defined(SS_LINEARSPECULARREFRACTION)
+float refractionLOD=getLinearLodFromRoughness(vRefractionMicrosurfaceInfos.x,roughness);
+#else
+float refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG);
+#endif
+#ifdef LODBASEDMICROSFURACE
+
+refractionLOD=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z;
+#ifdef SS_LODINREFRACTIONALPHA
+
+
+
+
+
+
+
+
+
+float automaticRefractionLOD=UNPACK_LOD(sampleRefraction(refractionSampler,refractionCoords).a);
+float requestedRefractionLOD=max(automaticRefractionLOD,refractionLOD);
+#else
+float requestedRefractionLOD=refractionLOD;
+#endif
+#ifdef REALTIME_FILTERING
+environmentRefraction=vec4(radiance(alphaG,refractionSampler,refractionCoords,vRefractionFilteringInfo),1.0);
+#else
+environmentRefraction=sampleRefractionLod(refractionSampler,refractionCoords,requestedRefractionLOD);
+#endif
+#else
+float lodRefractionNormalized=saturate(refractionLOD/log2(vRefractionMicrosurfaceInfos.x));
+float lodRefractionNormalizedDoubled=lodRefractionNormalized*2.0;
+vec4 environmentRefractionMid=sampleRefraction(refractionSampler,refractionCoords);
+if (lodRefractionNormalizedDoubled<1.0){
+environmentRefraction=mix(
+sampleRefraction(refractionSamplerHigh,refractionCoords),
+environmentRefractionMid,
+lodRefractionNormalizedDoubled
+);
+} else {
+environmentRefraction=mix(
+environmentRefractionMid,
+sampleRefraction(refractionSamplerLow,refractionCoords),
+lodRefractionNormalizedDoubled-1.0
+);
+}
+#endif
+#ifdef SS_RGBDREFRACTION
+environmentRefraction.rgb=fromRGBD(environmentRefraction);
+#endif
+#ifdef SS_GAMMAREFRACTION
+environmentRefraction.rgb=toLinearSpace(environmentRefraction.rgb);
+#endif
+
+environmentRefraction.rgb*=vRefractionInfos.x;
+#endif
+
+
+
+#ifdef SS_REFRACTION
+vec3 refractionTransmittance=vec3(refractionIntensity);
+#ifdef SS_THICKNESSANDMASK_TEXTURE
+vec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);
+
+
+
+
+
+refractionTransmittance*=cocaLambert(volumeAlbedo,thickness);
+#elif defined(SS_LINKREFRACTIONTOTRANSPARENCY)
+
+float maxChannel=max(max(surfaceAlbedo.r,surfaceAlbedo.g),surfaceAlbedo.b);
+vec3 volumeAlbedo=saturate(maxChannel*surfaceAlbedo);
+
+environmentRefraction.rgb*=volumeAlbedo;
+#else
+
+vec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);
+refractionTransmittance*=cocaLambert(volumeAlbedo,vThicknessParam.y);
+#endif
+#ifdef SS_ALBEDOFORREFRACTIONTINT
+
+environmentRefraction.rgb*=surfaceAlbedo.rgb;
+#endif
+
+outParams.surfaceAlbedo=surfaceAlbedo*(1.-refractionIntensity);
+#ifdef REFLECTION
+
+outParams.refractionFactorForIrradiance=(1.-refractionIntensity);
+
+#endif
+
+vec3 bounceSpecularEnvironmentReflectance=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance);
+outParams.specularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,refractionIntensity);
+
+refractionTransmittance*=1.0-outParams.specularEnvironmentReflectance;
+#if DEBUGMODE>0
+outParams.refractionTransmittance=refractionTransmittance;
+#endif
+outParams.finalRefraction=environmentRefraction.rgb*refractionTransmittance*vLightingIntensity.z;
+#if DEBUGMODE>0
+outParams.environmentRefraction=environmentRefraction;
+#endif
+#endif
+
+
+
+#if defined(REFLECTION) && defined(SS_TRANSLUCENCY)
+#if defined(NORMAL) && defined(USESPHERICALINVERTEX) || !defined(USESPHERICALFROMREFLECTIONMAP)
+vec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;
+#ifdef REFLECTIONMAP_OPPOSITEZ
+irradianceVector.z*=-1.0;
+#endif
+#ifdef INVERTCUBICMAP
+irradianceVector.y*=-1.0;
+#endif
+#else
+vec3 irradianceVector=irradianceVector_;
+#endif
+#if defined(USESPHERICALFROMREFLECTIONMAP)
+#if defined(REALTIME_FILTERING)
+vec3 refractionIrradiance=irradiance(reflectionSampler,-irradianceVector,vReflectionFilteringInfo);
+#else
+vec3 refractionIrradiance=computeEnvironmentIrradiance(-irradianceVector);
+#endif
+#elif defined(USEIRRADIANCEMAP)
+#ifdef REFLECTIONMAP_3D
+vec3 irradianceCoords=irradianceVector;
+#else
+vec2 irradianceCoords=irradianceVector.xy;
+#ifdef REFLECTIONMAP_PROJECTION
+irradianceCoords/=irradianceVector.z;
+#endif
+irradianceCoords.y=1.0-irradianceCoords.y;
+#endif
+vec4 refractionIrradiance=sampleReflection(irradianceSampler,-irradianceCoords);
+#ifdef RGBDREFLECTION
+refractionIrradiance.rgb=fromRGBD(refractionIrradiance);
+#endif
+#ifdef GAMMAREFLECTION
+refractionIrradiance.rgb=toLinearSpace(refractionIrradiance.rgb);
+#endif
+#else
+vec4 refractionIrradiance=vec4(0.);
+#endif
+refractionIrradiance.rgb*=transmittance;
+outParams.refractionIrradiance=refractionIrradiance.rgb;
+#endif
+}
+#endif
+`;
+ ze.a.IncludesShadersStore.pbrBlockSubSurface = Rp;
+ var Op = `vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);
+#ifdef NORMAL
+vec3 normalW=normalize(vNormalW);
+#else
+vec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;
+#endif
+vec3 geometricNormalW=normalW;
+#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
+geometricNormalW=gl_FrontFacing ? geometricNormalW : -geometricNormalW;
+#endif
+`;
+ ze.a.IncludesShadersStore.pbrBlockNormalGeometric = Op, f(134);
+ var Mp = `#if defined(FORCENORMALFORWARD) && defined(NORMAL)
+vec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;
+#if defined(TWOSIDEDLIGHTING)
+faceNormal=gl_FrontFacing ? faceNormal : -faceNormal;
+#endif
+normalW*=sign(dot(normalW,faceNormal));
+#endif
+#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
+normalW=gl_FrontFacing ? normalW : -normalW;
+#endif
+`;
+ ze.a.IncludesShadersStore.pbrBlockNormalFinal = Mp, f(162);
+ var Ip = `#ifdef LIGHTMAP
+vec4 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset);
+#ifdef RGBDLIGHTMAP
+lightmapColor.rgb=fromRGBD(lightmapColor);
+#endif
+#ifdef GAMMALIGHTMAP
+lightmapColor.rgb=toLinearSpace(lightmapColor.rgb);
+#endif
+lightmapColor.rgb*=vLightmapInfos.y;
+#endif
+`;
+ ze.a.IncludesShadersStore.pbrBlockLightmapInit = Ip;
+ var Dp = `float NdotVUnclamped=dot(normalW,viewDirectionW);
+
+float NdotV=absEps(NdotVUnclamped);
+float alphaG=convertRoughnessToAverageSlope(roughness);
+vec2 AARoughnessFactors=getAARoughnessFactors(normalW.xyz);
+#ifdef SPECULARAA
+
+alphaG+=AARoughnessFactors.y;
+#endif
+#if defined(ENVIRONMENTBRDF)
+
+vec3 environmentBrdf=getBRDFLookup(NdotV,roughness);
+#endif
+#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
+#ifdef RADIANCEOCCLUSION
+#ifdef AMBIENTINGRAYSCALE
+float ambientMonochrome=aoOut.ambientOcclusionColor.r;
+#else
+float ambientMonochrome=getLuminance(aoOut.ambientOcclusionColor);
+#endif
+float seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);
+#endif
+#ifdef HORIZONOCCLUSION
+#ifdef BUMP
+#ifdef REFLECTIONMAP_3D
+float eho=environmentHorizonOcclusion(-viewDirectionW,normalW,geometricNormalW);
+#endif
+#endif
+#endif
+#endif
+`;
+ ze.a.IncludesShadersStore.pbrBlockGeometryInfo = Dp;
+ var Lp = `float reflectance=max(max(reflectivityOut.surfaceReflectivityColor.r,reflectivityOut.surfaceReflectivityColor.g),reflectivityOut.surfaceReflectivityColor.b);
+vec3 specularEnvironmentR0=reflectivityOut.surfaceReflectivityColor.rgb;
+#ifdef METALLICWORKFLOW
+vec3 specularEnvironmentR90=vec3(metallicReflectanceFactors.a);
+#else
+vec3 specularEnvironmentR90=vec3(1.0,1.0,1.0);
+#endif
+
+#ifdef ALPHAFRESNEL
+float reflectance90=fresnelGrazingReflectance(reflectance);
+specularEnvironmentR90=specularEnvironmentR90*reflectance90;
+#endif
+`;
+ ze.a.IncludesShadersStore.pbrBlockReflectance0 = Lp;
+ var Np = `#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
+vec3 specularEnvironmentReflectance=getReflectanceFromBRDFLookup(clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,environmentBrdf);
+#ifdef RADIANCEOCCLUSION
+specularEnvironmentReflectance*=seo;
+#endif
+#ifdef HORIZONOCCLUSION
+#ifdef BUMP
+#ifdef REFLECTIONMAP_3D
+specularEnvironmentReflectance*=eho;
+#endif
+#endif
+#endif
+#else
+
+vec3 specularEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(NdotV,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));
+#endif
+#ifdef CLEARCOAT
+specularEnvironmentReflectance*=clearcoatOut.conservationFactor;
+#if defined(CLEARCOAT_TINT)
+specularEnvironmentReflectance*=clearcoatOut.absorption;
+#endif
+#endif
+`;
+ ze.a.IncludesShadersStore.pbrBlockReflectance = Np;
+ var wp = `vec3 diffuseBase=vec3(0.,0.,0.);
+#ifdef SPECULARTERM
+vec3 specularBase=vec3(0.,0.,0.);
+#endif
+#ifdef CLEARCOAT
+vec3 clearCoatBase=vec3(0.,0.,0.);
+#endif
+#ifdef SHEEN
+vec3 sheenBase=vec3(0.,0.,0.);
+#endif
+
+preLightingInfo preInfo;
+lightingInfo info;
+float shadow=1.;
+#if defined(CLEARCOAT) && defined(CLEARCOAT_TINT)
+vec3 absorption=vec3(0.);
+#endif
+`;
+ ze.a.IncludesShadersStore.pbrBlockDirectLighting = wp;
+ var Fp = `
+
+
+
+#if defined(ENVIRONMENTBRDF)
+#ifdef MS_BRDF_ENERGY_CONSERVATION
+vec3 energyConservationFactor=getEnergyConservationFactor(clearcoatOut.specularEnvironmentR0,environmentBrdf);
+#endif
+#endif
+#ifndef METALLICWORKFLOW
+#ifdef SPECULAR_GLOSSINESS_ENERGY_CONSERVATION
+surfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb;
+#endif
+#endif
+#if defined(SHEEN) && defined(SHEEN_ALBEDOSCALING) && defined(ENVIRONMENTBRDF)
+surfaceAlbedo.rgb=sheenOut.sheenAlbedoScaling*surfaceAlbedo.rgb;
+#endif
+
+#ifdef REFLECTION
+vec3 finalIrradiance=reflectionOut.environmentIrradiance;
+#if defined(CLEARCOAT)
+finalIrradiance*=clearcoatOut.conservationFactor;
+#if defined(CLEARCOAT_TINT)
+finalIrradiance*=clearcoatOut.absorption;
+#endif
+#endif
+#if defined(SS_REFRACTION)
+finalIrradiance*=subSurfaceOut.refractionFactorForIrradiance;
+#endif
+#if defined(SS_TRANSLUCENCY)
+finalIrradiance*=(1.0-subSurfaceOut.translucencyIntensity);
+finalIrradiance+=subSurfaceOut.refractionIrradiance;
+#endif
+finalIrradiance*=surfaceAlbedo.rgb;
+finalIrradiance*=vLightingIntensity.z;
+finalIrradiance*=aoOut.ambientOcclusionColor;
+#endif
+
+#ifdef SPECULARTERM
+vec3 finalSpecular=specularBase;
+finalSpecular=max(finalSpecular,0.0);
+vec3 finalSpecularScaled=finalSpecular*vLightingIntensity.x*vLightingIntensity.w;
+#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
+finalSpecularScaled*=energyConservationFactor;
+#endif
+#if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
+finalSpecularScaled*=sheenOut.sheenAlbedoScaling;
+#endif
+#endif
+
+#ifdef REFLECTION
+vec3 finalRadiance=reflectionOut.environmentRadiance.rgb;
+finalRadiance*=subSurfaceOut.specularEnvironmentReflectance;
+vec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z;
+#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
+finalRadianceScaled*=energyConservationFactor;
+#endif
+#if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
+finalRadianceScaled*=sheenOut.sheenAlbedoScaling;
+#endif
+#endif
+
+#ifdef SHEEN
+vec3 finalSheen=sheenBase*sheenOut.sheenColor;
+finalSheen=max(finalSheen,0.0);
+vec3 finalSheenScaled=finalSheen*vLightingIntensity.x*vLightingIntensity.w;
+#if defined(CLEARCOAT) && defined(REFLECTION) && defined(ENVIRONMENTBRDF)
+sheenOut.finalSheenRadianceScaled*=clearcoatOut.conservationFactor;
+#if defined(CLEARCOAT_TINT)
+sheenOut.finalSheenRadianceScaled*=clearcoatOut.absorption;
+#endif
+#endif
+#endif
+
+#ifdef CLEARCOAT
+vec3 finalClearCoat=clearCoatBase;
+finalClearCoat=max(finalClearCoat,0.0);
+vec3 finalClearCoatScaled=finalClearCoat*vLightingIntensity.x*vLightingIntensity.w;
+#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
+finalClearCoatScaled*=clearcoatOut.energyConservationFactorClearCoat;
+#endif
+#ifdef SS_REFRACTION
+subSurfaceOut.finalRefraction*=clearcoatOut.conservationFactor;
+#ifdef CLEARCOAT_TINT
+subSurfaceOut.finalRefraction*=clearcoatOut.absorption;
+#endif
+#endif
+#endif
+
+#ifdef ALPHABLEND
+float luminanceOverAlpha=0.0;
+#if defined(REFLECTION) && defined(RADIANCEOVERALPHA)
+luminanceOverAlpha+=getLuminance(finalRadianceScaled);
+#if defined(CLEARCOAT)
+luminanceOverAlpha+=getLuminance(clearcoatOut.finalClearCoatRadianceScaled);
+#endif
+#endif
+#if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)
+luminanceOverAlpha+=getLuminance(finalSpecularScaled);
+#endif
+#if defined(CLEARCOAT) && defined(CLEARCOATOVERALPHA)
+luminanceOverAlpha+=getLuminance(finalClearCoatScaled);
+#endif
+#if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA) || defined(CLEARCOATOVERALPHA)
+alpha=saturate(alpha+luminanceOverAlpha*luminanceOverAlpha);
+#endif
+#endif
+`;
+ ze.a.IncludesShadersStore.pbrBlockFinalLitComponents = Fp;
+ var Bp = `
+vec3 finalDiffuse=diffuseBase;
+finalDiffuse*=surfaceAlbedo.rgb;
+finalDiffuse=max(finalDiffuse,0.0);
+finalDiffuse*=vLightingIntensity.x;
+
+vec3 finalAmbient=vAmbientColor;
+finalAmbient*=surfaceAlbedo.rgb;
+
+vec3 finalEmissive=vEmissiveColor;
+#ifdef EMISSIVE
+vec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb;
+finalEmissive*=toLinearSpace(emissiveColorTex.rgb);
+finalEmissive*=vEmissiveInfos.y;
+#endif
+finalEmissive*=vLightingIntensity.y;
+
+#ifdef AMBIENT
+vec3 ambientOcclusionForDirectDiffuse=mix(vec3(1.),aoOut.ambientOcclusionColor,vAmbientInfos.w);
+#else
+vec3 ambientOcclusionForDirectDiffuse=aoOut.ambientOcclusionColor;
+#endif
+finalAmbient*=aoOut.ambientOcclusionColor;
+finalDiffuse*=ambientOcclusionForDirectDiffuse;
+`;
+ ze.a.IncludesShadersStore.pbrBlockFinalUnlitComponents = Bp;
+ var Up = `vec4 finalColor=vec4(
+finalAmbient +
+finalDiffuse +
+#ifndef UNLIT
+#ifdef REFLECTION
+finalIrradiance +
+#endif
+#ifdef SPECULARTERM
+finalSpecularScaled +
+#endif
+#ifdef SHEEN
+finalSheenScaled +
+#endif
+#ifdef CLEARCOAT
+finalClearCoatScaled +
+#endif
+#ifdef REFLECTION
+finalRadianceScaled +
+#if defined(SHEEN) && defined(ENVIRONMENTBRDF)
+sheenOut.finalSheenRadianceScaled +
+#endif
+#ifdef CLEARCOAT
+clearcoatOut.finalClearCoatRadianceScaled +
+#endif
+#endif
+#ifdef SS_REFRACTION
+subSurfaceOut.finalRefraction +
+#endif
+#endif
+finalEmissive,
+alpha);
+
+#ifdef LIGHTMAP
+#ifndef LIGHTMAPEXCLUDED
+#ifdef USELIGHTMAPASSHADOWMAP
+finalColor.rgb*=lightmapColor.rgb;
+#else
+finalColor.rgb+=lightmapColor.rgb;
+#endif
+#endif
+#endif
+#define CUSTOM_FRAGMENT_BEFORE_FOG
+
+finalColor=max(finalColor,0.0);
+`;
+ ze.a.IncludesShadersStore.pbrBlockFinalColorComposition = Up, f(155);
+ var Vp = `#ifdef IMAGEPROCESSINGPOSTPROCESS
+
+
+finalColor.rgb=clamp(finalColor.rgb,0.,30.0);
+#else
+
+finalColor=applyImageProcessing(finalColor);
+#endif
+finalColor.a*=visibility;
+#ifdef PREMULTIPLYALPHA
+
+finalColor.rgb*=finalColor.a;
+#endif
+`;
+ ze.a.IncludesShadersStore.pbrBlockImageProcessing = Vp;
+ var kp = `#if DEBUGMODE>0
+if (vClipSpacePosition.x/vClipSpacePosition.w>=vDebugMode.x) {
+
+#if DEBUGMODE == 1
+gl_FragColor.rgb=vPositionW.rgb;
+#define DEBUGMODE_NORMALIZE
+#elif DEBUGMODE == 2 && defined(NORMAL)
+gl_FragColor.rgb=vNormalW.rgb;
+#define DEBUGMODE_NORMALIZE
+#elif DEBUGMODE == 3 && defined(BUMP) || DEBUGMODE == 3 && defined(PARALLAX) || DEBUGMODE == 3 && defined(ANISOTROPIC)
+
+gl_FragColor.rgb=TBN[0];
+#define DEBUGMODE_NORMALIZE
+#elif DEBUGMODE == 4 && defined(BUMP) || DEBUGMODE == 4 && defined(PARALLAX) || DEBUGMODE == 4 && defined(ANISOTROPIC)
+
+gl_FragColor.rgb=TBN[1];
+#define DEBUGMODE_NORMALIZE
+#elif DEBUGMODE == 5
+
+gl_FragColor.rgb=normalW;
+#define DEBUGMODE_NORMALIZE
+#elif DEBUGMODE == 6 && defined(MAINUV1)
+gl_FragColor.rgb=vec3(vMainUV1,0.0);
+#elif DEBUGMODE == 7 && defined(MAINUV2)
+gl_FragColor.rgb=vec3(vMainUV2,0.0);
+#elif DEBUGMODE == 8 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)
+
+gl_FragColor.rgb=clearcoatOut.TBNClearCoat[0];
+#define DEBUGMODE_NORMALIZE
+#elif DEBUGMODE == 9 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)
+
+gl_FragColor.rgb=clearcoatOut.TBNClearCoat[1];
+#define DEBUGMODE_NORMALIZE
+#elif DEBUGMODE == 10 && defined(CLEARCOAT)
+
+gl_FragColor.rgb=clearcoatOut.clearCoatNormalW;
+#define DEBUGMODE_NORMALIZE
+#elif DEBUGMODE == 11 && defined(ANISOTROPIC)
+gl_FragColor.rgb=anisotropicOut.anisotropicNormal;
+#define DEBUGMODE_NORMALIZE
+#elif DEBUGMODE == 12 && defined(ANISOTROPIC)
+gl_FragColor.rgb=anisotropicOut.anisotropicTangent;
+#define DEBUGMODE_NORMALIZE
+#elif DEBUGMODE == 13 && defined(ANISOTROPIC)
+gl_FragColor.rgb=anisotropicOut.anisotropicBitangent;
+#define DEBUGMODE_NORMALIZE
+
+#elif DEBUGMODE == 20 && defined(ALBEDO)
+gl_FragColor.rgb=albedoTexture.rgb;
+#elif DEBUGMODE == 21 && defined(AMBIENT)
+gl_FragColor.rgb=aoOut.ambientOcclusionColorMap.rgb;
+#elif DEBUGMODE == 22 && defined(OPACITY)
+gl_FragColor.rgb=opacityMap.rgb;
+#elif DEBUGMODE == 23 && defined(EMISSIVE)
+gl_FragColor.rgb=emissiveColorTex.rgb;
+#define DEBUGMODE_GAMMA
+#elif DEBUGMODE == 24 && defined(LIGHTMAP)
+gl_FragColor.rgb=lightmapColor.rgb;
+#define DEBUGMODE_GAMMA
+#elif DEBUGMODE == 25 && defined(REFLECTIVITY) && defined(METALLICWORKFLOW)
+gl_FragColor.rgb=reflectivityOut.surfaceMetallicColorMap.rgb;
+#elif DEBUGMODE == 26 && defined(REFLECTIVITY) && !defined(METALLICWORKFLOW)
+gl_FragColor.rgb=reflectivityOut.surfaceReflectivityColorMap.rgb;
+#define DEBUGMODE_GAMMA
+#elif DEBUGMODE == 27 && defined(CLEARCOAT) && defined(CLEARCOAT_TEXTURE)
+gl_FragColor.rgb=vec3(clearcoatOut.clearCoatMapData.rg,0.0);
+#elif DEBUGMODE == 28 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
+gl_FragColor.rgb=clearcoatOut.clearCoatTintMapData.rgb;
+#elif DEBUGMODE == 29 && defined(SHEEN) && defined(SHEEN_TEXTURE)
+gl_FragColor.rgb=sheenOut.sheenMapData.rgb;
+#elif DEBUGMODE == 30 && defined(ANISOTROPIC) && defined(ANISOTROPIC_TEXTURE)
+gl_FragColor.rgb=anisotropicOut.anisotropyMapData.rgb;
+#elif DEBUGMODE == 31 && defined(SUBSURFACE) && defined(SS_THICKNESSANDMASK_TEXTURE)
+gl_FragColor.rgb=subSurfaceOut.thicknessMap.rgb;
+
+#elif DEBUGMODE == 40 && defined(SS_REFRACTION)
+
+gl_FragColor.rgb=subSurfaceOut.environmentRefraction.rgb;
+#define DEBUGMODE_GAMMA
+#elif DEBUGMODE == 41 && defined(REFLECTION)
+gl_FragColor.rgb=reflectionOut.environmentRadiance.rgb;
+#define DEBUGMODE_GAMMA
+#elif DEBUGMODE == 42 && defined(CLEARCOAT) && defined(REFLECTION)
+gl_FragColor.rgb=clearcoatOut.environmentClearCoatRadiance.rgb;
+#define DEBUGMODE_GAMMA
+
+#elif DEBUGMODE == 50
+gl_FragColor.rgb=diffuseBase.rgb;
+#define DEBUGMODE_GAMMA
+#elif DEBUGMODE == 51 && defined(SPECULARTERM)
+gl_FragColor.rgb=specularBase.rgb;
+#define DEBUGMODE_GAMMA
+#elif DEBUGMODE == 52 && defined(CLEARCOAT)
+gl_FragColor.rgb=clearCoatBase.rgb;
+#define DEBUGMODE_GAMMA
+#elif DEBUGMODE == 53 && defined(SHEEN)
+gl_FragColor.rgb=sheenBase.rgb;
+#define DEBUGMODE_GAMMA
+#elif DEBUGMODE == 54 && defined(REFLECTION)
+gl_FragColor.rgb=reflectionOut.environmentIrradiance.rgb;
+#define DEBUGMODE_GAMMA
+
+#elif DEBUGMODE == 60
+gl_FragColor.rgb=surfaceAlbedo.rgb;
+#define DEBUGMODE_GAMMA
+#elif DEBUGMODE == 61
+gl_FragColor.rgb=clearcoatOut.specularEnvironmentR0;
+#define DEBUGMODE_GAMMA
+#elif DEBUGMODE == 62 && defined(METALLICWORKFLOW)
+gl_FragColor.rgb=vec3(reflectivityOut.metallicRoughness.r);
+#elif DEBUGMODE == 71 && defined(METALLICWORKFLOW)
+gl_FragColor.rgb=reflectivityOut.metallicF0;
+#elif DEBUGMODE == 63
+gl_FragColor.rgb=vec3(roughness);
+#elif DEBUGMODE == 64
+gl_FragColor.rgb=vec3(alphaG);
+#elif DEBUGMODE == 65
+gl_FragColor.rgb=vec3(NdotV);
+#elif DEBUGMODE == 66 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT)
+gl_FragColor.rgb=clearcoatOut.clearCoatColor.rgb;
+#define DEBUGMODE_GAMMA
+#elif DEBUGMODE == 67 && defined(CLEARCOAT)
+gl_FragColor.rgb=vec3(clearcoatOut.clearCoatRoughness);
+#elif DEBUGMODE == 68 && defined(CLEARCOAT)
+gl_FragColor.rgb=vec3(clearcoatOut.clearCoatNdotV);
+#elif DEBUGMODE == 69 && defined(SUBSURFACE) && defined(SS_TRANSLUCENCY)
+gl_FragColor.rgb=subSurfaceOut.transmittance;
+#elif DEBUGMODE == 70 && defined(SUBSURFACE) && defined(SS_REFRACTION)
+gl_FragColor.rgb=subSurfaceOut.refractionTransmittance;
+
+#elif DEBUGMODE == 80 && defined(RADIANCEOCCLUSION)
+gl_FragColor.rgb=vec3(seo);
+#elif DEBUGMODE == 81 && defined(HORIZONOCCLUSION)
+gl_FragColor.rgb=vec3(eho);
+#elif DEBUGMODE == 82 && defined(MS_BRDF_ENERGY_CONSERVATION)
+gl_FragColor.rgb=vec3(energyConservationFactor);
+#elif DEBUGMODE == 83 && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
+gl_FragColor.rgb=specularEnvironmentReflectance;
+#define DEBUGMODE_GAMMA
+#elif DEBUGMODE == 84 && defined(CLEARCOAT) && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
+gl_FragColor.rgb=clearcoatOut.clearCoatEnvironmentReflectance;
+#define DEBUGMODE_GAMMA
+#elif DEBUGMODE == 85 && defined(SHEEN) && defined(REFLECTION)
+gl_FragColor.rgb=sheenOut.sheenEnvironmentReflectance;
+#define DEBUGMODE_GAMMA
+#elif DEBUGMODE == 86 && defined(ALPHABLEND)
+gl_FragColor.rgb=vec3(luminanceOverAlpha);
+#elif DEBUGMODE == 87
+gl_FragColor.rgb=vec3(alpha);
+#endif
+gl_FragColor.rgb*=vDebugMode.y;
+#ifdef DEBUGMODE_NORMALIZE
+gl_FragColor.rgb=normalize(gl_FragColor.rgb)*0.5+0.5;
+#endif
+#ifdef DEBUGMODE_GAMMA
+gl_FragColor.rgb=toGammaSpace(gl_FragColor.rgb);
+#endif
+gl_FragColor.a=1.0;
+#ifdef PREPASS
+gl_FragData[0]=toLinearSpace(gl_FragColor);
+gl_FragData[1]=vec4(0.,0.,0.,0.);
+#endif
+return;
+}
+#endif`;
+ ze.a.IncludesShadersStore.pbrDebug = kp;
+ var Gp = `#if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)
+#extension GL_OES_standard_derivatives : enable
+#endif
+#ifdef LODBASEDMICROSFURACE
+#extension GL_EXT_shader_texture_lod : enable
+#endif
+#define CUSTOM_FRAGMENT_BEGIN
+#ifdef LOGARITHMICDEPTH
+#extension GL_EXT_frag_depth : enable
+#endif
+#include[SCENE_MRT_COUNT]
+precision highp float;
+
+#ifndef FROMLINEARSPACE
+#define FROMLINEARSPACE
+#endif
+
+#include<__decl__pbrFragment>
+#include
+#include<__decl__lightFragment>[0..maxSimultaneousLights]
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#ifdef REFLECTION
+#include
+#endif
+#define CUSTOM_FRAGMENT_DEFINITIONS
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+void main(void) {
+#define CUSTOM_FRAGMENT_MAIN_BEGIN
+#include
+
+#include
+#include
+#include
+
+albedoOpacityOutParams albedoOpacityOut;
+#ifdef ALBEDO
+vec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset);
+#endif
+#ifdef OPACITY
+vec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);
+#endif
+albedoOpacityBlock(
+vAlbedoColor,
+#ifdef ALBEDO
+albedoTexture,
+vAlbedoInfos,
+#endif
+#ifdef OPACITY
+opacityMap,
+vOpacityInfos,
+#endif
+#ifdef DETAIL
+detailColor,
+vDetailInfos,
+#endif
+albedoOpacityOut
+);
+vec3 surfaceAlbedo=albedoOpacityOut.surfaceAlbedo;
+float alpha=albedoOpacityOut.alpha;
+#define CUSTOM_FRAGMENT_UPDATE_ALPHA
+#include
+#define CUSTOM_FRAGMENT_BEFORE_LIGHTS
+
+ambientOcclusionOutParams aoOut;
+#ifdef AMBIENT
+vec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb;
+#endif
+ambientOcclusionBlock(
+#ifdef AMBIENT
+ambientOcclusionColorMap,
+vAmbientInfos,
+#endif
+aoOut
+);
+#include
+#ifdef UNLIT
+vec3 diffuseBase=vec3(1.,1.,1.);
+#else
+
+vec3 baseColor=surfaceAlbedo;
+reflectivityOutParams reflectivityOut;
+#if defined(REFLECTIVITY)
+vec4 surfaceMetallicOrReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);
+vec4 baseReflectivity=surfaceMetallicOrReflectivityColorMap;
+#ifndef METALLICWORKFLOW
+surfaceMetallicOrReflectivityColorMap=toLinearSpace(surfaceMetallicOrReflectivityColorMap);
+surfaceMetallicOrReflectivityColorMap.rgb*=vReflectivityInfos.y;
+#endif
+#endif
+#if defined(MICROSURFACEMAP)
+vec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;
+#endif
+#ifdef METALLICWORKFLOW
+vec4 metallicReflectanceFactors=vMetallicReflectanceFactors;
+#ifdef METALLIC_REFLECTANCE
+vec4 metallicReflectanceFactorsMap=texture2D(metallicReflectanceSampler,vMetallicReflectanceUV+uvOffset);
+metallicReflectanceFactorsMap=toLinearSpace(metallicReflectanceFactorsMap);
+metallicReflectanceFactors*=metallicReflectanceFactorsMap;
+#endif
+#endif
+reflectivityBlock(
+vReflectivityColor,
+#ifdef METALLICWORKFLOW
+surfaceAlbedo,
+metallicReflectanceFactors,
+#endif
+#ifdef REFLECTIVITY
+vReflectivityInfos,
+surfaceMetallicOrReflectivityColorMap,
+#endif
+#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
+aoOut.ambientOcclusionColor,
+#endif
+#ifdef MICROSURFACEMAP
+microSurfaceTexel,
+#endif
+#ifdef DETAIL
+detailColor,
+vDetailInfos,
+#endif
+reflectivityOut
+);
+float microSurface=reflectivityOut.microSurface;
+float roughness=reflectivityOut.roughness;
+#ifdef METALLICWORKFLOW
+surfaceAlbedo=reflectivityOut.surfaceAlbedo;
+#endif
+#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
+aoOut.ambientOcclusionColor=reflectivityOut.ambientOcclusionColor;
+#endif
+
+#ifdef ALPHAFRESNEL
+#if defined(ALPHATEST) || defined(ALPHABLEND)
+alphaFresnelOutParams alphaFresnelOut;
+alphaFresnelBlock(
+normalW,
+viewDirectionW,
+alpha,
+microSurface,
+alphaFresnelOut
+);
+alpha=alphaFresnelOut.alpha;
+#endif
+#endif
+
+#include
+
+#ifdef ANISOTROPIC
+anisotropicOutParams anisotropicOut;
+#ifdef ANISOTROPIC_TEXTURE
+vec3 anisotropyMapData=texture2D(anisotropySampler,vAnisotropyUV+uvOffset).rgb*vAnisotropyInfos.y;
+#endif
+anisotropicBlock(
+vAnisotropy,
+#ifdef ANISOTROPIC_TEXTURE
+anisotropyMapData,
+#endif
+TBN,
+normalW,
+viewDirectionW,
+anisotropicOut
+);
+#endif
+
+#ifdef REFLECTION
+reflectionOutParams reflectionOut;
+reflectionBlock(
+vPositionW,
+normalW,
+alphaG,
+vReflectionMicrosurfaceInfos,
+vReflectionInfos,
+vReflectionColor,
+#ifdef ANISOTROPIC
+anisotropicOut,
+#endif
+#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
+NdotVUnclamped,
+#endif
+#ifdef LINEARSPECULARREFLECTION
+roughness,
+#endif
+reflectionSampler,
+#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
+vEnvironmentIrradiance,
+#endif
+#ifdef USESPHERICALFROMREFLECTIONMAP
+#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
+reflectionMatrix,
+#endif
+#endif
+#ifdef USEIRRADIANCEMAP
+irradianceSampler,
+#endif
+#ifndef LODBASEDMICROSFURACE
+reflectionSamplerLow,
+reflectionSamplerHigh,
+#endif
+#ifdef REALTIME_FILTERING
+vReflectionFilteringInfo,
+#endif
+reflectionOut
+);
+#endif
+
+#include
+
+#ifdef SHEEN
+sheenOutParams sheenOut;
+#ifdef SHEEN_TEXTURE
+vec4 sheenMapData=toLinearSpace(texture2D(sheenSampler,vSheenUV+uvOffset))*vSheenInfos.y;
+#endif
+#if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
+vec4 sheenMapRoughnessData=texture2D(sheenRoughnessSampler,vSheenRoughnessUV+uvOffset)*vSheenInfos.w;
+#endif
+sheenBlock(
+vSheenColor,
+#ifdef SHEEN_ROUGHNESS
+vSheenRoughness,
+#if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
+sheenMapRoughnessData,
+#endif
+#endif
+roughness,
+#ifdef SHEEN_TEXTURE
+sheenMapData,
+#endif
+reflectance,
+#ifdef SHEEN_LINKWITHALBEDO
+baseColor,
+surfaceAlbedo,
+#endif
+#ifdef ENVIRONMENTBRDF
+NdotV,
+environmentBrdf,
+#endif
+#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
+AARoughnessFactors,
+vReflectionMicrosurfaceInfos,
+vReflectionInfos,
+vReflectionColor,
+vLightingIntensity,
+reflectionSampler,
+reflectionOut.reflectionCoords,
+NdotVUnclamped,
+#ifndef LODBASEDMICROSFURACE
+reflectionSamplerLow,
+reflectionSamplerHigh,
+#endif
+#ifdef REALTIME_FILTERING
+vReflectionFilteringInfo,
+#endif
+#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
+seo,
+#endif
+#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
+eho,
+#endif
+#endif
+sheenOut
+);
+#ifdef SHEEN_LINKWITHALBEDO
+surfaceAlbedo=sheenOut.surfaceAlbedo;
+#endif
+#endif
+
+clearcoatOutParams clearcoatOut;
+#ifdef CLEARCOAT
+#ifdef CLEARCOAT_TEXTURE
+vec2 clearCoatMapData=texture2D(clearCoatSampler,vClearCoatUV+uvOffset).rg*vClearCoatInfos.y;
+#endif
+#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
+vec4 clearCoatMapRoughnessData=texture2D(clearCoatRoughnessSampler,vClearCoatRoughnessUV+uvOffset)*vClearCoatInfos.w;
+#endif
+#if defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
+vec4 clearCoatTintMapData=toLinearSpace(texture2D(clearCoatTintSampler,vClearCoatTintUV+uvOffset));
+#endif
+#ifdef CLEARCOAT_BUMP
+vec4 clearCoatBumpMapData=texture2D(clearCoatBumpSampler,vClearCoatBumpUV+uvOffset);
+#endif
+clearcoatBlock(
+vPositionW,
+geometricNormalW,
+viewDirectionW,
+vClearCoatParams,
+#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
+clearCoatMapRoughnessData,
+#endif
+specularEnvironmentR0,
+#ifdef CLEARCOAT_TEXTURE
+clearCoatMapData,
+#endif
+#ifdef CLEARCOAT_TINT
+vClearCoatTintParams,
+clearCoatColorAtDistance,
+vClearCoatRefractionParams,
+#ifdef CLEARCOAT_TINT_TEXTURE
+clearCoatTintMapData,
+#endif
+#endif
+#ifdef CLEARCOAT_BUMP
+vClearCoatBumpInfos,
+clearCoatBumpMapData,
+vClearCoatBumpUV,
+#if defined(TANGENT) && defined(NORMAL)
+vTBN,
+#else
+vClearCoatTangentSpaceParams,
+#endif
+#ifdef OBJECTSPACE_NORMALMAP
+normalMatrix,
+#endif
+#endif
+#if defined(FORCENORMALFORWARD) && defined(NORMAL)
+faceNormal,
+#endif
+#ifdef REFLECTION
+vReflectionMicrosurfaceInfos,
+vReflectionInfos,
+vReflectionColor,
+vLightingIntensity,
+reflectionSampler,
+#ifndef LODBASEDMICROSFURACE
+reflectionSamplerLow,
+reflectionSamplerHigh,
+#endif
+#ifdef REALTIME_FILTERING
+vReflectionFilteringInfo,
+#endif
+#endif
+#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
+#ifdef RADIANCEOCCLUSION
+ambientMonochrome,
+#endif
+#endif
+clearcoatOut
+);
+#else
+clearcoatOut.specularEnvironmentR0=specularEnvironmentR0;
+#endif
+
+#include
+
+subSurfaceOutParams subSurfaceOut;
+#ifdef SUBSURFACE
+#ifdef SS_THICKNESSANDMASK_TEXTURE
+vec4 thicknessMap=texture2D(thicknessSampler,vThicknessUV+uvOffset);
+#endif
+subSurfaceBlock(
+vSubSurfaceIntensity,
+vThicknessParam,
+vTintColor,
+normalW,
+specularEnvironmentReflectance,
+#ifdef SS_THICKNESSANDMASK_TEXTURE
+thicknessMap,
+#endif
+#ifdef REFLECTION
+#ifdef SS_TRANSLUCENCY
+reflectionMatrix,
+#ifdef USESPHERICALFROMREFLECTIONMAP
+#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
+reflectionOut.irradianceVector,
+#endif
+#if defined(REALTIME_FILTERING)
+reflectionSampler,
+vReflectionFilteringInfo,
+#endif
+#endif
+#ifdef USEIRRADIANCEMAP
+irradianceSampler,
+#endif
+#endif
+#endif
+#ifdef SS_REFRACTION
+vPositionW,
+viewDirectionW,
+view,
+surfaceAlbedo,
+vRefractionInfos,
+refractionMatrix,
+vRefractionMicrosurfaceInfos,
+vLightingIntensity,
+#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
+alpha,
+#endif
+#ifdef SS_LODINREFRACTIONALPHA
+NdotVUnclamped,
+#endif
+#ifdef SS_LINEARSPECULARREFRACTION
+roughness,
+#else
+alphaG,
+#endif
+refractionSampler,
+#ifndef LODBASEDMICROSFURACE
+refractionSamplerLow,
+refractionSamplerHigh,
+#endif
+#ifdef ANISOTROPIC
+anisotropicOut,
+#endif
+#ifdef REALTIME_FILTERING
+vRefractionFilteringInfo,
+#endif
+#endif
+#ifdef SS_TRANSLUCENCY
+vDiffusionDistance,
+#endif
+subSurfaceOut
+);
+#ifdef SS_REFRACTION
+surfaceAlbedo=subSurfaceOut.surfaceAlbedo;
+#ifdef SS_LINKREFRACTIONTOTRANSPARENCY
+alpha=subSurfaceOut.alpha;
+#endif
+#endif
+#else
+subSurfaceOut.specularEnvironmentReflectance=specularEnvironmentReflectance;
+#endif
+
+#include
+#include[0..maxSimultaneousLights]
+
+#include
+#endif
+#include
+#include
+#include
+#include(color,finalColor)
+#include
+#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR
+#ifdef PREPASS
+#ifdef PREPASS_POSITION
+gl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,1.0);
+#endif
+#ifdef PREPASS_VELOCITY
+vec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;
+vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;
+vec2 velocity=abs(a-b);
+velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;
+gl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,1.0);
+#endif
+#ifdef PREPASS_IRRADIANCE
+vec3 irradiance=finalDiffuse;
+#ifndef UNLIT
+#ifdef REFLECTION
+irradiance+=finalIrradiance;
+#endif
+#endif
+vec3 sqAlbedo=sqrt(surfaceAlbedo);
+#ifdef SS_SCATTERING
+gl_FragData[0]=vec4(finalColor.rgb-irradiance,finalColor.a);
+irradiance/=sqAlbedo;
+#else
+gl_FragData[0]=finalColor;
+float scatteringDiffusionProfile=255.;
+#endif
+gl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(irradiance,scatteringDiffusionProfile/255.);
+#else
+gl_FragData[0]=vec4(finalColor.rgb,finalColor.a);
+#endif
+#ifdef PREPASS_DEPTHNORMAL
+gl_FragData[PREPASS_DEPTHNORMAL_INDEX]=vec4(vViewPos.z,(view*vec4(normalW,0.0)).rgb);
+#endif
+#ifdef PREPASS_ALBEDO
+gl_FragData[PREPASS_ALBEDO_INDEX]=vec4(sqAlbedo,1.0);
+#endif
+#ifdef PREPASS_REFLECTIVITY
+#if defined(REFLECTIVITY)
+gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(baseReflectivity.rgb,1.0);
+#else
+gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(0.0,0.0,0.0,1.0);
+#endif
+#endif
+#endif
+#if !defined(PREPASS) || defined(WEBGL2)
+gl_FragColor=finalColor;
+#endif
+#include
+}
+`;
+ ze.a.ShadersStore.pbrPixelShader = Gp;
+ var zp = `uniform mat4 view;
+uniform mat4 viewProjection;
+#ifdef ALBEDO
+uniform mat4 albedoMatrix;
+uniform vec2 vAlbedoInfos;
+#endif
+#ifdef AMBIENT
+uniform mat4 ambientMatrix;
+uniform vec4 vAmbientInfos;
+#endif
+#ifdef OPACITY
+uniform mat4 opacityMatrix;
+uniform vec2 vOpacityInfos;
+#endif
+#ifdef EMISSIVE
+uniform vec2 vEmissiveInfos;
+uniform mat4 emissiveMatrix;
+#endif
+#ifdef LIGHTMAP
+uniform vec2 vLightmapInfos;
+uniform mat4 lightmapMatrix;
+#endif
+#ifdef REFLECTIVITY
+uniform vec3 vReflectivityInfos;
+uniform mat4 reflectivityMatrix;
+#endif
+#ifdef METALLIC_REFLECTANCE
+uniform vec2 vMetallicReflectanceInfos;
+uniform mat4 metallicReflectanceMatrix;
+#endif
+#ifdef MICROSURFACEMAP
+uniform vec2 vMicroSurfaceSamplerInfos;
+uniform mat4 microSurfaceSamplerMatrix;
+#endif
+#ifdef BUMP
+uniform vec3 vBumpInfos;
+uniform mat4 bumpMatrix;
+#endif
+#ifdef POINTSIZE
+uniform float pointSize;
+#endif
+
+#ifdef REFLECTION
+uniform vec2 vReflectionInfos;
+uniform mat4 reflectionMatrix;
+#endif
+
+#ifdef CLEARCOAT
+#if defined(CLEARCOAT_TEXTURE) || defined(CLEARCOAT_TEXTURE_ROUGHNESS)
+uniform vec4 vClearCoatInfos;
+#endif
+#ifdef CLEARCOAT_TEXTURE
+uniform mat4 clearCoatMatrix;
+#endif
+#ifdef CLEARCOAT_TEXTURE_ROUGHNESS
+uniform mat4 clearCoatRoughnessMatrix;
+#endif
+#ifdef CLEARCOAT_BUMP
+uniform vec2 vClearCoatBumpInfos;
+uniform mat4 clearCoatBumpMatrix;
+#endif
+#ifdef CLEARCOAT_TINT_TEXTURE
+uniform vec2 vClearCoatTintInfos;
+uniform mat4 clearCoatTintMatrix;
+#endif
+#endif
+
+#ifdef ANISOTROPIC
+#ifdef ANISOTROPIC_TEXTURE
+uniform vec2 vAnisotropyInfos;
+uniform mat4 anisotropyMatrix;
+#endif
+#endif
+
+#ifdef SHEEN
+#if defined(SHEEN_TEXTURE) || defined(SHEEN_TEXTURE_ROUGHNESS)
+uniform vec4 vSheenInfos;
+#endif
+#ifdef SHEEN_TEXTURE
+uniform mat4 sheenMatrix;
+#endif
+#ifdef SHEEN_TEXTURE_ROUGHNESS
+uniform mat4 sheenRoughnessMatrix;
+#endif
+#endif
+
+#ifdef SUBSURFACE
+#ifdef SS_REFRACTION
+uniform vec4 vRefractionInfos;
+uniform mat4 refractionMatrix;
+#endif
+#ifdef SS_THICKNESSANDMASK_TEXTURE
+uniform vec2 vThicknessInfos;
+uniform mat4 thicknessMatrix;
+#endif
+#endif
+`;
+ ze.a.IncludesShadersStore.pbrVertexDeclaration = zp, f(163), f(164), f(93), f(94), f(100), f(165), f(156), f(158);
+ var jp = `precision highp float;
+#include<__decl__pbrVertex>
+#define CUSTOM_VERTEX_BEGIN
+
+attribute vec3 position;
+#ifdef NORMAL
+attribute vec3 normal;
+#endif
+#ifdef TANGENT
+attribute vec4 tangent;
+#endif
+#ifdef UV1
+attribute vec2 uv;
+#endif
+#ifdef UV2
+attribute vec2 uv2;
+#endif
+#ifdef MAINUV1
+varying vec2 vMainUV1;
+#endif
+#ifdef MAINUV2
+varying vec2 vMainUV2;
+#endif
+#ifdef VERTEXCOLOR
+attribute vec4 color;
+#endif
+#include
+#include
+
+#include
+#include
+#if defined(ALBEDO) && ALBEDODIRECTUV == 0
+varying vec2 vAlbedoUV;
+#endif
+#if defined(DETAIL) && DETAILDIRECTUV == 0
+varying vec2 vDetailUV;
+#endif
+#if defined(AMBIENT) && AMBIENTDIRECTUV == 0
+varying vec2 vAmbientUV;
+#endif
+#if defined(OPACITY) && OPACITYDIRECTUV == 0
+varying vec2 vOpacityUV;
+#endif
+#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0
+varying vec2 vEmissiveUV;
+#endif
+#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0
+varying vec2 vLightmapUV;
+#endif
+#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0
+varying vec2 vReflectivityUV;
+#endif
+#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0
+varying vec2 vMicroSurfaceSamplerUV;
+#endif
+#if defined(METALLIC_REFLECTANCE) && METALLIC_REFLECTANCEDIRECTUV == 0
+varying vec2 vMetallicReflectanceUV;
+#endif
+#if defined(BUMP) && BUMPDIRECTUV == 0
+varying vec2 vBumpUV;
+#endif
+#ifdef CLEARCOAT
+#if defined(CLEARCOAT_TEXTURE) && CLEARCOAT_TEXTUREDIRECTUV == 0
+varying vec2 vClearCoatUV;
+#endif
+#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV == 0
+varying vec2 vClearCoatRoughnessUV;
+#endif
+#if defined(CLEARCOAT_BUMP) && CLEARCOAT_BUMPDIRECTUV == 0
+varying vec2 vClearCoatBumpUV;
+#endif
+#if defined(CLEARCOAT_TINT_TEXTURE) && CLEARCOAT_TINT_TEXTUREDIRECTUV == 0
+varying vec2 vClearCoatTintUV;
+#endif
+#endif
+#ifdef SHEEN
+#if defined(SHEEN_TEXTURE) && SHEEN_TEXTUREDIRECTUV == 0
+varying vec2 vSheenUV;
+#endif
+#if defined(SHEEN_TEXTURE_ROUGHNESS) && SHEEN_TEXTURE_ROUGHNESSDIRECTUV == 0
+varying vec2 vSheenRoughnessUV;
+#endif
+#endif
+#ifdef ANISOTROPIC
+#if defined(ANISOTROPIC_TEXTURE) && ANISOTROPIC_TEXTUREDIRECTUV == 0
+varying vec2 vAnisotropyUV;
+#endif
+#endif
+#ifdef SUBSURFACE
+#if defined(SS_THICKNESSANDMASK_TEXTURE) && SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 0
+varying vec2 vThicknessUV;
+#endif
+#endif
+
+varying vec3 vPositionW;
+#if DEBUGMODE>0
+varying vec4 vClipSpacePosition;
+#endif
+#ifdef NORMAL
+varying vec3 vNormalW;
+#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
+varying vec3 vEnvironmentIrradiance;
+#include
+#endif
+#endif
+#ifdef VERTEXCOLOR
+varying vec4 vColor;
+#endif
+#include
+#include
+#include
+#include<__decl__lightFragment>[0..maxSimultaneousLights]
+#include
+#include[0..maxSimultaneousMorphTargets]
+#ifdef REFLECTIONMAP_SKYBOX
+varying vec3 vPositionUVW;
+#endif
+#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
+varying vec3 vDirectionW;
+#endif
+#include
+#define CUSTOM_VERTEX_DEFINITIONS
+void main(void) {
+#define CUSTOM_VERTEX_MAIN_BEGIN
+vec3 positionUpdated=position;
+#ifdef NORMAL
+vec3 normalUpdated=normal;
+#endif
+#ifdef TANGENT
+vec4 tangentUpdated=tangent;
+#endif
+#ifdef UV1
+vec2 uvUpdated=uv;
+#endif
+#include[0..maxSimultaneousMorphTargets]
+#ifdef REFLECTIONMAP_SKYBOX
+vPositionUVW=positionUpdated;
+#endif
+#define CUSTOM_VERTEX_UPDATE_POSITION
+#define CUSTOM_VERTEX_UPDATE_NORMAL
+#include
+#if defined(PREPASS) && defined(PREPASS_VELOCITY) && !defined(BONES_VELOCITY_ENABLED)
+
+vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);
+vPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0);
+#endif
+#include
+vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);
+vPositionW=vec3(worldPos);
+#include
+#ifdef NORMAL
+mat3 normalWorld=mat3(finalWorld);
+#if defined(INSTANCES) && defined(THIN_INSTANCES)
+vNormalW=normalUpdated/vec3(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2]));
+vNormalW=normalize(normalWorld*vNormalW);
+#else
+#ifdef NONUNIFORMSCALING
+normalWorld=transposeMat3(inverseMat3(normalWorld));
+#endif
+vNormalW=normalize(normalWorld*normalUpdated);
+#endif
+#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
+vec3 reflectionVector=vec3(reflectionMatrix*vec4(vNormalW,0)).xyz;
+#ifdef REFLECTIONMAP_OPPOSITEZ
+reflectionVector.z*=-1.0;
+#endif
+vEnvironmentIrradiance=computeEnvironmentIrradiance(reflectionVector);
+#endif
+#endif
+#define CUSTOM_VERTEX_UPDATE_WORLDPOS
+#ifdef MULTIVIEW
+if (gl_ViewID_OVR == 0u) {
+gl_Position=viewProjection*worldPos;
+} else {
+gl_Position=viewProjectionR*worldPos;
+}
+#else
+gl_Position=viewProjection*worldPos;
+#endif
+#if DEBUGMODE>0
+vClipSpacePosition=gl_Position;
+#endif
+#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
+vDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));
+#endif
+
+#ifndef UV1
+vec2 uvUpdated=vec2(0.,0.);
+#endif
+#ifndef UV2
+vec2 uv2=vec2(0.,0.);
+#endif
+#ifdef MAINUV1
+vMainUV1=uvUpdated;
+#endif
+#ifdef MAINUV2
+vMainUV2=uv2;
+#endif
+#if defined(ALBEDO) && ALBEDODIRECTUV == 0
+if (vAlbedoInfos.x == 0.)
+{
+vAlbedoUV=vec2(albedoMatrix*vec4(uvUpdated,1.0,0.0));
+}
+else
+{
+vAlbedoUV=vec2(albedoMatrix*vec4(uv2,1.0,0.0));
+}
+#endif
+#if defined(DETAIL) && DETAILDIRECTUV == 0
+if (vDetailInfos.x == 0.)
+{
+vDetailUV=vec2(detailMatrix*vec4(uvUpdated,1.0,0.0));
+}
+else
+{
+vDetailUV=vec2(detailMatrix*vec4(uv2,1.0,0.0));
+}
+#endif
+#if defined(AMBIENT) && AMBIENTDIRECTUV == 0
+if (vAmbientInfos.x == 0.)
+{
+vAmbientUV=vec2(ambientMatrix*vec4(uvUpdated,1.0,0.0));
+}
+else
+{
+vAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));
+}
+#endif
+#if defined(OPACITY) && OPACITYDIRECTUV == 0
+if (vOpacityInfos.x == 0.)
+{
+vOpacityUV=vec2(opacityMatrix*vec4(uvUpdated,1.0,0.0));
+}
+else
+{
+vOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));
+}
+#endif
+#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0
+if (vEmissiveInfos.x == 0.)
+{
+vEmissiveUV=vec2(emissiveMatrix*vec4(uvUpdated,1.0,0.0));
+}
+else
+{
+vEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));
+}
+#endif
+#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0
+if (vLightmapInfos.x == 0.)
+{
+vLightmapUV=vec2(lightmapMatrix*vec4(uvUpdated,1.0,0.0));
+}
+else
+{
+vLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));
+}
+#endif
+#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0
+if (vReflectivityInfos.x == 0.)
+{
+vReflectivityUV=vec2(reflectivityMatrix*vec4(uvUpdated,1.0,0.0));
+}
+else
+{
+vReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));
+}
+#endif
+#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0
+if (vMicroSurfaceSamplerInfos.x == 0.)
+{
+vMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uvUpdated,1.0,0.0));
+}
+else
+{
+vMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv2,1.0,0.0));
+}
+#endif
+#if defined(METALLIC_REFLECTANCE) && METALLIC_REFLECTANCEDIRECTUV == 0
+if (vMetallicReflectanceInfos.x == 0.)
+{
+vMetallicReflectanceUV=vec2(metallicReflectanceMatrix*vec4(uvUpdated,1.0,0.0));
+}
+else
+{
+vMetallicReflectanceUV=vec2(metallicReflectanceMatrix*vec4(uv2,1.0,0.0));
+}
+#endif
+#if defined(BUMP) && BUMPDIRECTUV == 0
+if (vBumpInfos.x == 0.)
+{
+vBumpUV=vec2(bumpMatrix*vec4(uvUpdated,1.0,0.0));
+}
+else
+{
+vBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));
+}
+#endif
+#ifdef CLEARCOAT
+#if defined(CLEARCOAT_TEXTURE) && CLEARCOAT_TEXTUREDIRECTUV == 0
+if (vClearCoatInfos.x == 0.)
+{
+vClearCoatUV=vec2(clearCoatMatrix*vec4(uvUpdated,1.0,0.0));
+}
+else
+{
+vClearCoatUV=vec2(clearCoatMatrix*vec4(uv2,1.0,0.0));
+}
+#endif
+#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV == 0
+if (vClearCoatInfos.z == 0.)
+{
+vClearCoatRoughnessUV=vec2(clearCoatRoughnessMatrix*vec4(uvUpdated,1.0,0.0));
+}
+else
+{
+vClearCoatRoughnessUV=vec2(clearCoatRoughnessMatrix*vec4(uv2,1.0,0.0));
+}
+#endif
+#if defined(CLEARCOAT_BUMP) && CLEARCOAT_BUMPDIRECTUV == 0
+if (vClearCoatBumpInfos.x == 0.)
+{
+vClearCoatBumpUV=vec2(clearCoatBumpMatrix*vec4(uvUpdated,1.0,0.0));
+}
+else
+{
+vClearCoatBumpUV=vec2(clearCoatBumpMatrix*vec4(uv2,1.0,0.0));
+}
+#endif
+#if defined(CLEARCOAT_TINT_TEXTURE) && CLEARCOAT_TINT_TEXTUREDIRECTUV == 0
+if (vClearCoatTintInfos.x == 0.)
+{
+vClearCoatTintUV=vec2(clearCoatTintMatrix*vec4(uvUpdated,1.0,0.0));
+}
+else
+{
+vClearCoatTintUV=vec2(clearCoatTintMatrix*vec4(uv2,1.0,0.0));
+}
+#endif
+#endif
+#ifdef SHEEN
+#if defined(SHEEN_TEXTURE) && SHEEN_TEXTUREDIRECTUV == 0
+if (vSheenInfos.x == 0.)
+{
+vSheenUV=vec2(sheenMatrix*vec4(uvUpdated,1.0,0.0));
+}
+else
+{
+vSheenUV=vec2(sheenMatrix*vec4(uv2,1.0,0.0));
+}
+#endif
+#if defined(SHEEN_TEXTURE_ROUGHNESS) && SHEEN_TEXTURE_ROUGHNESSDIRECTUV == 0
+if (vSheenInfos.z == 0.)
+{
+vSheenRoughnessUV=vec2(sheenRoughnessMatrix*vec4(uvUpdated,1.0,0.0));
+}
+else
+{
+vSheenRoughnessUV=vec2(sheenRoughnessMatrix*vec4(uv2,1.0,0.0));
+}
+#endif
+#endif
+#ifdef ANISOTROPIC
+#if defined(ANISOTROPIC_TEXTURE) && ANISOTROPIC_TEXTUREDIRECTUV == 0
+if (vAnisotropyInfos.x == 0.)
+{
+vAnisotropyUV=vec2(anisotropyMatrix*vec4(uvUpdated,1.0,0.0));
+}
+else
+{
+vAnisotropyUV=vec2(anisotropyMatrix*vec4(uv2,1.0,0.0));
+}
+#endif
+#endif
+#ifdef SUBSURFACE
+#if defined(SS_THICKNESSANDMASK_TEXTURE) && SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 0
+if (vThicknessInfos.x == 0.)
+{
+vThicknessUV=vec2(thicknessMatrix*vec4(uvUpdated,1.0,0.0));
+}
+else
+{
+vThicknessUV=vec2(thicknessMatrix*vec4(uv2,1.0,0.0));
+}
+#endif
+#endif
+
+#include
+
+#include
+
+#include
+
+#include[0..maxSimultaneousLights]
+
+#ifdef VERTEXCOLOR
+vColor=color;
+#endif
+
+#ifdef POINTSIZE
+gl_PointSize=pointSize;
+#endif
+
+#include
+#define CUSTOM_VERTEX_MAIN_END
+}`;
+ ze.a.ShadersStore.pbrVertexShader = jp;
+ var Wo = f(92), vr = { effect: null, subMesh: null }, As = function(r) {
+ function t() {
+ var e = r.call(this) || this;
+ return e.PBR = !0, e.NUM_SAMPLES = "0", e.REALTIME_FILTERING = !1, e.MAINUV1 = !1, e.MAINUV2 = !1, e.UV1 = !1, e.UV2 = !1, e.ALBEDO = !1, e.GAMMAALBEDO = !1, e.ALBEDODIRECTUV = 0, e.VERTEXCOLOR = !1, e.DETAIL = !1, e.DETAILDIRECTUV = 0, e.DETAIL_NORMALBLENDMETHOD = 0, e.AMBIENT = !1, e.AMBIENTDIRECTUV = 0, e.AMBIENTINGRAYSCALE = !1, e.OPACITY = !1, e.VERTEXALPHA = !1, e.OPACITYDIRECTUV = 0, e.OPACITYRGB = !1, e.ALPHATEST = !1, e.DEPTHPREPASS = !1, e.ALPHABLEND = !1, e.ALPHAFROMALBEDO = !1, e.ALPHATESTVALUE = "0.5", e.SPECULAROVERALPHA = !1, e.RADIANCEOVERALPHA = !1, e.ALPHAFRESNEL = !1, e.LINEARALPHAFRESNEL = !1, e.PREMULTIPLYALPHA = !1, e.EMISSIVE = !1, e.EMISSIVEDIRECTUV = 0, e.REFLECTIVITY = !1, e.REFLECTIVITYDIRECTUV = 0, e.SPECULARTERM = !1, e.MICROSURFACEFROMREFLECTIVITYMAP = !1, e.MICROSURFACEAUTOMATIC = !1, e.LODBASEDMICROSFURACE = !1, e.MICROSURFACEMAP = !1, e.MICROSURFACEMAPDIRECTUV = 0, e.METALLICWORKFLOW = !1, e.ROUGHNESSSTOREINMETALMAPALPHA = !1, e.ROUGHNESSSTOREINMETALMAPGREEN = !1, e.METALLNESSSTOREINMETALMAPBLUE = !1, e.AOSTOREINMETALMAPRED = !1, e.METALLIC_REFLECTANCE = !1, e.METALLIC_REFLECTANCEDIRECTUV = 0, e.ENVIRONMENTBRDF = !1, e.ENVIRONMENTBRDF_RGBD = !1, e.NORMAL = !1, e.TANGENT = !1, e.BUMP = !1, e.BUMPDIRECTUV = 0, e.OBJECTSPACE_NORMALMAP = !1, e.PARALLAX = !1, e.PARALLAXOCCLUSION = !1, e.NORMALXYSCALE = !0, e.LIGHTMAP = !1, e.LIGHTMAPDIRECTUV = 0, e.USELIGHTMAPASSHADOWMAP = !1, e.GAMMALIGHTMAP = !1, e.RGBDLIGHTMAP = !1, e.REFLECTION = !1, e.REFLECTIONMAP_3D = !1, e.REFLECTIONMAP_SPHERICAL = !1, e.REFLECTIONMAP_PLANAR = !1, e.REFLECTIONMAP_CUBIC = !1, e.USE_LOCAL_REFLECTIONMAP_CUBIC = !1, e.REFLECTIONMAP_PROJECTION = !1, e.REFLECTIONMAP_SKYBOX = !1, e.REFLECTIONMAP_EXPLICIT = !1, e.REFLECTIONMAP_EQUIRECTANGULAR = !1, e.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1, e.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1, e.INVERTCUBICMAP = !1, e.USESPHERICALFROMREFLECTIONMAP = !1, e.USEIRRADIANCEMAP = !1, e.SPHERICAL_HARMONICS = !1, e.USESPHERICALINVERTEX = !1, e.REFLECTIONMAP_OPPOSITEZ = !1, e.LODINREFLECTIONALPHA = !1, e.GAMMAREFLECTION = !1, e.RGBDREFLECTION = !1, e.LINEARSPECULARREFLECTION = !1, e.RADIANCEOCCLUSION = !1, e.HORIZONOCCLUSION = !1, e.INSTANCES = !1, e.THIN_INSTANCES = !1, e.PREPASS = !1, e.PREPASS_IRRADIANCE = !1, e.PREPASS_IRRADIANCE_INDEX = -1, e.PREPASS_ALBEDO = !1, e.PREPASS_ALBEDO_INDEX = -1, e.PREPASS_DEPTHNORMAL = !1, e.PREPASS_DEPTHNORMAL_INDEX = -1, e.PREPASS_POSITION = !1, e.PREPASS_POSITION_INDEX = -1, e.PREPASS_VELOCITY = !1, e.PREPASS_VELOCITY_INDEX = -1, e.PREPASS_REFLECTIVITY = !1, e.PREPASS_REFLECTIVITY_INDEX = -1, e.SCENE_MRT_COUNT = 0, e.NUM_BONE_INFLUENCERS = 0, e.BonesPerMesh = 0, e.BONETEXTURE = !1, e.BONES_VELOCITY_ENABLED = !1, e.NONUNIFORMSCALING = !1, e.MORPHTARGETS = !1, e.MORPHTARGETS_NORMAL = !1, e.MORPHTARGETS_TANGENT = !1, e.MORPHTARGETS_UV = !1, e.NUM_MORPH_INFLUENCERS = 0, e.IMAGEPROCESSING = !1, e.VIGNETTE = !1, e.VIGNETTEBLENDMODEMULTIPLY = !1, e.VIGNETTEBLENDMODEOPAQUE = !1, e.TONEMAPPING = !1, e.TONEMAPPING_ACES = !1, e.CONTRAST = !1, e.COLORCURVES = !1, e.COLORGRADING = !1, e.COLORGRADING3D = !1, e.SAMPLER3DGREENDEPTH = !1, e.SAMPLER3DBGRMAP = !1, e.IMAGEPROCESSINGPOSTPROCESS = !1, e.EXPOSURE = !1, e.MULTIVIEW = !1, e.USEPHYSICALLIGHTFALLOFF = !1, e.USEGLTFLIGHTFALLOFF = !1, e.TWOSIDEDLIGHTING = !1, e.SHADOWFLOAT = !1, e.CLIPPLANE = !1, e.CLIPPLANE2 = !1, e.CLIPPLANE3 = !1, e.CLIPPLANE4 = !1, e.CLIPPLANE5 = !1, e.CLIPPLANE6 = !1, e.POINTSIZE = !1, e.FOG = !1, e.LOGARITHMICDEPTH = !1, e.FORCENORMALFORWARD = !1, e.SPECULARAA = !1, e.CLEARCOAT = !1, e.CLEARCOAT_DEFAULTIOR = !1, e.CLEARCOAT_TEXTURE = !1, e.CLEARCOAT_TEXTURE_ROUGHNESS = !1, e.CLEARCOAT_TEXTUREDIRECTUV = 0, e.CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV = 0, e.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE = !1, e.CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL = !1, e.CLEARCOAT_BUMP = !1, e.CLEARCOAT_BUMPDIRECTUV = 0, e.CLEARCOAT_REMAP_F0 = !0, e.CLEARCOAT_TINT = !1, e.CLEARCOAT_TINT_TEXTURE = !1, e.CLEARCOAT_TINT_TEXTUREDIRECTUV = 0, e.ANISOTROPIC = !1, e.ANISOTROPIC_TEXTURE = !1, e.ANISOTROPIC_TEXTUREDIRECTUV = 0, e.BRDF_V_HEIGHT_CORRELATED = !1, e.MS_BRDF_ENERGY_CONSERVATION = !1, e.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION = !1, e.SHEEN = !1, e.SHEEN_TEXTURE = !1, e.SHEEN_TEXTURE_ROUGHNESS = !1, e.SHEEN_TEXTUREDIRECTUV = 0, e.SHEEN_TEXTURE_ROUGHNESSDIRECTUV = 0, e.SHEEN_LINKWITHALBEDO = !1, e.SHEEN_ROUGHNESS = !1, e.SHEEN_ALBEDOSCALING = !1, e.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE = !1, e.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL = !1, e.SUBSURFACE = !1, e.SS_REFRACTION = !1, e.SS_TRANSLUCENCY = !1, e.SS_SCATTERING = !1, e.SS_THICKNESSANDMASK_TEXTURE = !1, e.SS_THICKNESSANDMASK_TEXTUREDIRECTUV = 0, e.SS_REFRACTIONMAP_3D = !1, e.SS_REFRACTIONMAP_OPPOSITEZ = !1, e.SS_LODINREFRACTIONALPHA = !1, e.SS_GAMMAREFRACTION = !1, e.SS_RGBDREFRACTION = !1, e.SS_LINEARSPECULARREFRACTION = !1, e.SS_LINKREFRACTIONTOTRANSPARENCY = !1, e.SS_ALBEDOFORREFRACTIONTINT = !1, e.SS_MASK_FROM_THICKNESS_TEXTURE = !1, e.SS_MASK_FROM_THICKNESS_TEXTURE_GLTF = !1, e.UNLIT = !1, e.DEBUGMODE = 0, e.rebuild(), e;
+ }
+ return Object(c.d)(t, r), t.prototype.reset = function() {
+ r.prototype.reset.call(this), this.ALPHATESTVALUE = "0.5", this.PBR = !0;
+ }, t;
+ }(zo.a), pn = function(r) {
+ function t(e, n) {
+ var i = r.call(this, e, n) || this;
+ return i._directIntensity = 1, i._emissiveIntensity = 1, i._environmentIntensity = 1, i._specularIntensity = 1, i._lightingInfos = new u.f(i._directIntensity, i._emissiveIntensity, i._environmentIntensity, i._specularIntensity), i._disableBumpMap = !1, i._albedoTexture = null, i._ambientTexture = null, i._ambientTextureStrength = 1, i._ambientTextureImpactOnAnalyticalLights = t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS, i._opacityTexture = null, i._reflectionTexture = null, i._emissiveTexture = null, i._reflectivityTexture = null, i._metallicTexture = null, i._metallic = null, i._roughness = null, i._metallicF0Factor = 1, i._metallicReflectanceColor = I.a.White(), i._metallicReflectanceTexture = null, i._microSurfaceTexture = null, i._bumpTexture = null, i._lightmapTexture = null, i._ambientColor = new I.a(0, 0, 0), i._albedoColor = new I.a(1, 1, 1), i._reflectivityColor = new I.a(1, 1, 1), i._reflectionColor = new I.a(1, 1, 1), i._emissiveColor = new I.a(0, 0, 0), i._microSurface = 0.9, i._useLightmapAsShadowmap = !1, i._useHorizonOcclusion = !0, i._useRadianceOcclusion = !0, i._useAlphaFromAlbedoTexture = !1, i._useSpecularOverAlpha = !0, i._useMicroSurfaceFromReflectivityMapAlpha = !1, i._useRoughnessFromMetallicTextureAlpha = !0, i._useRoughnessFromMetallicTextureGreen = !1, i._useMetallnessFromMetallicTextureBlue = !1, i._useAmbientOcclusionFromMetallicTextureRed = !1, i._useAmbientInGrayScale = !1, i._useAutoMicroSurfaceFromReflectivityMap = !1, i._lightFalloff = t.LIGHTFALLOFF_PHYSICAL, i._useRadianceOverAlpha = !0, i._useObjectSpaceNormalMap = !1, i._useParallax = !1, i._useParallaxOcclusion = !1, i._parallaxScaleBias = 0.05, i._disableLighting = !1, i._maxSimultaneousLights = 4, i._invertNormalMapX = !1, i._invertNormalMapY = !1, i._twoSidedLighting = !1, i._alphaCutOff = 0.4, i._forceAlphaTest = !1, i._useAlphaFresnel = !1, i._useLinearAlphaFresnel = !1, i._environmentBRDFTexture = null, i._forceIrradianceInFragment = !1, i._realTimeFiltering = !1, i._realTimeFilteringQuality = h.a.TEXTURE_FILTERING_QUALITY_LOW, i._forceNormalForward = !1, i._enableSpecularAntiAliasing = !1, i._imageProcessingObserver = null, i._renderTargets = new si.a(16), i._globalAmbientColor = new I.a(0, 0, 0), i._useLogarithmicDepth = !1, i._unlit = !1, i._debugMode = 0, i.debugMode = 0, i.debugLimit = -1, i.debugFactor = 1, i.clearCoat = new mr(i._markAllSubMeshesAsTexturesDirty.bind(i)), i.anisotropy = new gr(i._markAllSubMeshesAsTexturesDirty.bind(i)), i.brdf = new ap(i._markAllSubMeshesAsMiscDirty.bind(i)), i.sheen = new Zr(i._markAllSubMeshesAsTexturesDirty.bind(i)), i.detailMap = new Wo.a(i._markAllSubMeshesAsTexturesDirty.bind(i)), i._rebuildInParallel = !1, i._attachImageProcessingConfiguration(null), i.getRenderTargetTextures = function() {
+ return i._renderTargets.reset(), lt.a.ReflectionTextureEnabled && i._reflectionTexture && i._reflectionTexture.isRenderTarget && i._renderTargets.push(i._reflectionTexture), i.subSurface.fillRenderTargetTextures(i._renderTargets), i._renderTargets;
+ }, i._environmentBRDFTexture = Ho.GetEnvironmentBRDFTexture(n), i.subSurface = new Jr(i._markAllSubMeshesAsTexturesDirty.bind(i), i._markScenePrePassDirty.bind(i), n), i.prePassConfiguration = new Ss.a(), i;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "realTimeFiltering", { get: function() {
+ return this._realTimeFiltering;
+ }, set: function(e) {
+ this._realTimeFiltering = e, this.markAsDirty(h.a.MATERIAL_TextureDirtyFlag);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "realTimeFilteringQuality", { get: function() {
+ return this._realTimeFilteringQuality;
+ }, set: function(e) {
+ this._realTimeFilteringQuality = e, this.markAsDirty(h.a.MATERIAL_TextureDirtyFlag);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "canRenderToMRT", { get: function() {
+ return !0;
+ }, enumerable: !1, configurable: !0 }), t.prototype._attachImageProcessingConfiguration = function(e) {
+ var n = this;
+ e !== this._imageProcessingConfiguration && (this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver), this._imageProcessingConfiguration = e || this.getScene().imageProcessingConfiguration, this._imageProcessingConfiguration && (this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function() {
+ n._markAllSubMeshesAsImageProcessingDirty();
+ })));
+ }, Object.defineProperty(t.prototype, "hasRenderTargetTextures", { get: function() {
+ return !!(lt.a.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) || this.subSurface.hasRenderTargetTextures();
+ }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
+ return "PBRBaseMaterial";
+ }, Object.defineProperty(t.prototype, "useLogarithmicDepth", { get: function() {
+ return this._useLogarithmicDepth;
+ }, set: function(e) {
+ this._useLogarithmicDepth = e && this.getScene().getEngine().getCaps().fragmentDepthSupported;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "_disableAlphaBlending", { get: function() {
+ return this.subSurface.disableAlphaBlending || this._transparencyMode === t.PBRMATERIAL_OPAQUE || this._transparencyMode === t.PBRMATERIAL_ALPHATEST;
+ }, enumerable: !1, configurable: !0 }), t.prototype.needAlphaBlending = function() {
+ return !this._disableAlphaBlending && (this.alpha < 1 || this._opacityTexture != null || this._shouldUseAlphaFromAlbedoTexture());
+ }, t.prototype.needAlphaTesting = function() {
+ return !!this._forceAlphaTest || !this.subSurface.disableAlphaBlending && this._hasAlphaChannel() && (this._transparencyMode == null || this._transparencyMode === t.PBRMATERIAL_ALPHATEST);
+ }, t.prototype._shouldUseAlphaFromAlbedoTexture = function() {
+ return this._albedoTexture != null && this._albedoTexture.hasAlpha && this._useAlphaFromAlbedoTexture && this._transparencyMode !== t.PBRMATERIAL_OPAQUE;
+ }, t.prototype._hasAlphaChannel = function() {
+ return this._albedoTexture != null && this._albedoTexture.hasAlpha || this._opacityTexture != null;
+ }, t.prototype.getAlphaTestTexture = function() {
+ return this._albedoTexture;
+ }, t.prototype.isReadyForSubMesh = function(e, n, i) {
+ if (n.effect && this.isFrozen && n.effect._wasPreviouslyReady)
+ return !0;
+ n._materialDefines || (n._materialDefines = new As());
+ var o = n._materialDefines;
+ if (this._isReadyForSubMesh(n))
+ return !0;
+ var a = this.getScene(), s = a.getEngine();
+ if (o._areTexturesDirty && a.texturesEnabled) {
+ if (this._albedoTexture && lt.a.DiffuseTextureEnabled && !this._albedoTexture.isReadyOrNotBlocking() || this._ambientTexture && lt.a.AmbientTextureEnabled && !this._ambientTexture.isReadyOrNotBlocking() || this._opacityTexture && lt.a.OpacityTextureEnabled && !this._opacityTexture.isReadyOrNotBlocking())
+ return !1;
+ var d = this._getReflectionTexture();
+ if (d && lt.a.ReflectionTextureEnabled && (!d.isReadyOrNotBlocking() || d.irradianceTexture && !d.irradianceTexture.isReadyOrNotBlocking()) || this._lightmapTexture && lt.a.LightmapTextureEnabled && !this._lightmapTexture.isReadyOrNotBlocking() || this._emissiveTexture && lt.a.EmissiveTextureEnabled && !this._emissiveTexture.isReadyOrNotBlocking())
+ return !1;
+ if (lt.a.SpecularTextureEnabled) {
+ if (this._metallicTexture) {
+ if (!this._metallicTexture.isReadyOrNotBlocking())
+ return !1;
+ } else if (this._reflectivityTexture && !this._reflectivityTexture.isReadyOrNotBlocking())
+ return !1;
+ if (this._metallicReflectanceTexture && !this._metallicReflectanceTexture.isReadyOrNotBlocking() || this._microSurfaceTexture && !this._microSurfaceTexture.isReadyOrNotBlocking())
+ return !1;
+ }
+ if (s.getCaps().standardDerivatives && this._bumpTexture && lt.a.BumpTextureEnabled && !this._disableBumpMap && !this._bumpTexture.isReady() || this._environmentBRDFTexture && lt.a.ReflectionTextureEnabled && !this._environmentBRDFTexture.isReady())
+ return !1;
+ }
+ if (!(this.subSurface.isReadyForSubMesh(o, a) && this.clearCoat.isReadyForSubMesh(o, a, s, this._disableBumpMap) && this.sheen.isReadyForSubMesh(o, a) && this.anisotropy.isReadyForSubMesh(o, a) && this.detailMap.isReadyForSubMesh(o, a)) || o._areImageProcessingDirty && this._imageProcessingConfiguration && !this._imageProcessingConfiguration.isReady())
+ return !1;
+ s.getCaps().standardDerivatives || e.isVerticesDataPresent(Oe.b.NormalKind) || (e.createNormals(!0), l.a.Warn("PBRMaterial: Normals have been created for the mesh: " + e.name));
+ var p = n.effect, y = o._areLightsDisposed, P = this._prepareEffect(e, o, this.onCompiled, this.onError, i, null, n.getRenderingMesh().hasThinInstances);
+ if (P)
+ if (this._onEffectCreatedObservable && (vr.effect = P, vr.subMesh = n, this._onEffectCreatedObservable.notifyObservers(vr)), this.allowShaderHotSwapping && p && !P.isReady()) {
+ if (P = p, this._rebuildInParallel = !0, o.markAsUnprocessed(), y)
+ return o._areLightsDisposed = !0, !1;
+ } else
+ this._rebuildInParallel = !1, a.resetCachedMaterial(), n.setEffect(P, o), this.buildUniformLayout();
+ return !(!n.effect || !n.effect.isReady()) && (o._renderId = a.getRenderId(), n.effect._wasPreviouslyReady = !0, !0);
+ }, t.prototype.isMetallicWorkflow = function() {
+ return !(this._metallic == null && this._roughness == null && !this._metallicTexture);
+ }, t.prototype._prepareEffect = function(e, n, i, o, a, s, d) {
+ if (i === void 0 && (i = null), o === void 0 && (o = null), a === void 0 && (a = null), s === void 0 && (s = null), this._prepareDefines(e, n, a, s, d), !n.isDirty)
+ return null;
+ n.markAsProcessed();
+ var p = this.getScene().getEngine(), y = new _r.a(), P = 0;
+ n.USESPHERICALINVERTEX && y.addFallback(P++, "USESPHERICALINVERTEX"), n.FOG && y.addFallback(P, "FOG"), n.SPECULARAA && y.addFallback(P, "SPECULARAA"), n.POINTSIZE && y.addFallback(P, "POINTSIZE"), n.LOGARITHMICDEPTH && y.addFallback(P, "LOGARITHMICDEPTH"), n.PARALLAX && y.addFallback(P, "PARALLAX"), n.PARALLAXOCCLUSION && y.addFallback(P++, "PARALLAXOCCLUSION"), P = gr.AddFallbacks(n, y, P), P = gr.AddFallbacks(n, y, P), P = Jr.AddFallbacks(n, y, P), P = Zr.AddFallbacks(n, y, P), n.ENVIRONMENTBRDF && y.addFallback(P++, "ENVIRONMENTBRDF"), n.TANGENT && y.addFallback(P++, "TANGENT"), n.BUMP && y.addFallback(P++, "BUMP"), P = $e.a.HandleFallbacksForShadows(n, y, this._maxSimultaneousLights, P++), n.SPECULARTERM && y.addFallback(P++, "SPECULARTERM"), n.USESPHERICALFROMREFLECTIONMAP && y.addFallback(P++, "USESPHERICALFROMREFLECTIONMAP"), n.USEIRRADIANCEMAP && y.addFallback(P++, "USEIRRADIANCEMAP"), n.LIGHTMAP && y.addFallback(P++, "LIGHTMAP"), n.NORMAL && y.addFallback(P++, "NORMAL"), n.AMBIENT && y.addFallback(P++, "AMBIENT"), n.EMISSIVE && y.addFallback(P++, "EMISSIVE"), n.VERTEXCOLOR && y.addFallback(P++, "VERTEXCOLOR"), n.MORPHTARGETS && y.addFallback(P++, "MORPHTARGETS"), n.MULTIVIEW && y.addFallback(0, "MULTIVIEW");
+ var R = [Oe.b.PositionKind];
+ n.NORMAL && R.push(Oe.b.NormalKind), n.TANGENT && R.push(Oe.b.TangentKind), n.UV1 && R.push(Oe.b.UVKind), n.UV2 && R.push(Oe.b.UV2Kind), n.VERTEXCOLOR && R.push(Oe.b.ColorKind), $e.a.PrepareAttributesForBones(R, e, n, y), $e.a.PrepareAttributesForInstances(R, n), $e.a.PrepareAttributesForMorphTargets(R, e, n);
+ var B = "pbr", F = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vAlbedoColor", "vReflectivityColor", "vMetallicReflectanceFactors", "vEmissiveColor", "visibility", "vReflectionColor", "vFogInfos", "vFogColor", "pointSize", "vAlbedoInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vReflectionPosition", "vReflectionSize", "vEmissiveInfos", "vReflectivityInfos", "vReflectionFilteringInfo", "vMetallicReflectanceInfos", "vMicroSurfaceSamplerInfos", "vBumpInfos", "vLightmapInfos", "mBones", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "albedoMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "reflectivityMatrix", "normalMatrix", "microSurfaceSamplerMatrix", "bumpMatrix", "lightmapMatrix", "metallicReflectanceMatrix", "vLightingIntensity", "logarithmicDepthConstant", "vSphericalX", "vSphericalY", "vSphericalZ", "vSphericalXX_ZZ", "vSphericalYY_ZZ", "vSphericalZZ", "vSphericalXY", "vSphericalYZ", "vSphericalZX", "vSphericalL00", "vSphericalL1_1", "vSphericalL10", "vSphericalL11", "vSphericalL2_2", "vSphericalL2_1", "vSphericalL20", "vSphericalL21", "vSphericalL22", "vReflectionMicrosurfaceInfos", "vTangentSpaceParams", "boneTextureWidth", "vDebugMode"], z = ["albedoSampler", "reflectivitySampler", "ambientSampler", "emissiveSampler", "bumpSampler", "lightmapSampler", "opacitySampler", "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh", "irradianceSampler", "microSurfaceSampler", "environmentBrdfSampler", "boneSampler", "metallicReflectanceSampler"], J = ["Material", "Scene"];
+ Wo.a.AddUniforms(F), Wo.a.AddSamplers(z), Jr.AddUniforms(F), Jr.AddSamplers(z), mr.AddUniforms(F), mr.AddSamplers(z), gr.AddUniforms(F), gr.AddSamplers(z), Zr.AddUniforms(F), Zr.AddSamplers(z), Ss.a.AddUniforms(F), Ss.a.AddSamplers(F), vn.a && (vn.a.PrepareUniforms(F, n), vn.a.PrepareSamplers(z, n)), $e.a.PrepareUniformsAndSamplersList({ uniformsNames: F, uniformBuffersNames: J, samplers: z, defines: n, maxSimultaneousLights: this._maxSimultaneousLights });
+ var ie = {};
+ this.customShaderNameResolve && (B = this.customShaderNameResolve(B, F, J, z, n, R, ie));
+ var se = n.toString();
+ return p.createEffect(B, { attributes: R, uniformsNames: F, uniformBuffersNames: J, samplers: z, defines: se, fallbacks: y, onCompiled: i, onError: o, indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: n.NUM_MORPH_INFLUENCERS }, processFinalCode: ie.processFinalCode, multiTarget: n.PREPASS }, p);
+ }, t.prototype._prepareDefines = function(e, n, i, o, a) {
+ i === void 0 && (i = null), o === void 0 && (o = null), a === void 0 && (a = !1);
+ var s = this.getScene(), d = s.getEngine();
+ if ($e.a.PrepareDefinesForLights(s, e, n, !0, this._maxSimultaneousLights, this._disableLighting), n._needNormals = !0, $e.a.PrepareDefinesForMultiview(s, n), $e.a.PrepareDefinesForPrePass(s, n, this.canRenderToMRT), n.METALLICWORKFLOW = this.isMetallicWorkflow(), n._areTexturesDirty) {
+ if (n._needUVs = !1, s.texturesEnabled) {
+ s.getEngine().getCaps().textureLOD && (n.LODBASEDMICROSFURACE = !0), this._albedoTexture && lt.a.DiffuseTextureEnabled ? ($e.a.PrepareDefinesForMergedUV(this._albedoTexture, n, "ALBEDO"), n.GAMMAALBEDO = this._albedoTexture.gammaSpace) : n.ALBEDO = !1, this._ambientTexture && lt.a.AmbientTextureEnabled ? ($e.a.PrepareDefinesForMergedUV(this._ambientTexture, n, "AMBIENT"), n.AMBIENTINGRAYSCALE = this._useAmbientInGrayScale) : n.AMBIENT = !1, this._opacityTexture && lt.a.OpacityTextureEnabled ? ($e.a.PrepareDefinesForMergedUV(this._opacityTexture, n, "OPACITY"), n.OPACITYRGB = this._opacityTexture.getAlphaFromRGB) : n.OPACITY = !1;
+ var p = this._getReflectionTexture();
+ if (p && lt.a.ReflectionTextureEnabled) {
+ switch (n.REFLECTION = !0, n.GAMMAREFLECTION = p.gammaSpace, n.RGBDREFLECTION = p.isRGBD, n.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !p.invertZ : p.invertZ, n.LODINREFLECTIONALPHA = p.lodLevelInAlpha, n.LINEARSPECULARREFLECTION = p.linearSpecularLOD, this.realTimeFiltering && this.realTimeFilteringQuality > 0 ? (n.NUM_SAMPLES = "" + this.realTimeFilteringQuality, d.webGLVersion > 1 && (n.NUM_SAMPLES = n.NUM_SAMPLES + "u"), n.REALTIME_FILTERING = !0) : n.REALTIME_FILTERING = !1, p.coordinatesMode === Ne.a.INVCUBIC_MODE && (n.INVERTCUBICMAP = !0), n.REFLECTIONMAP_3D = p.isCube, n.REFLECTIONMAP_CUBIC = !1, n.REFLECTIONMAP_EXPLICIT = !1, n.REFLECTIONMAP_PLANAR = !1, n.REFLECTIONMAP_PROJECTION = !1, n.REFLECTIONMAP_SKYBOX = !1, n.REFLECTIONMAP_SPHERICAL = !1, n.REFLECTIONMAP_EQUIRECTANGULAR = !1, n.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1, n.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1, p.coordinatesMode) {
+ case Ne.a.EXPLICIT_MODE:
+ n.REFLECTIONMAP_EXPLICIT = !0;
+ break;
+ case Ne.a.PLANAR_MODE:
+ n.REFLECTIONMAP_PLANAR = !0;
+ break;
+ case Ne.a.PROJECTION_MODE:
+ n.REFLECTIONMAP_PROJECTION = !0;
+ break;
+ case Ne.a.SKYBOX_MODE:
+ n.REFLECTIONMAP_SKYBOX = !0;
+ break;
+ case Ne.a.SPHERICAL_MODE:
+ n.REFLECTIONMAP_SPHERICAL = !0;
+ break;
+ case Ne.a.EQUIRECTANGULAR_MODE:
+ n.REFLECTIONMAP_EQUIRECTANGULAR = !0;
+ break;
+ case Ne.a.FIXED_EQUIRECTANGULAR_MODE:
+ n.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !0;
+ break;
+ case Ne.a.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
+ n.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !0;
+ break;
+ case Ne.a.CUBIC_MODE:
+ case Ne.a.INVCUBIC_MODE:
+ default:
+ n.REFLECTIONMAP_CUBIC = !0, n.USE_LOCAL_REFLECTIONMAP_CUBIC = !!p.boundingBoxSize;
+ }
+ p.coordinatesMode !== Ne.a.SKYBOX_MODE && (p.irradianceTexture ? (n.USEIRRADIANCEMAP = !0, n.USESPHERICALFROMREFLECTIONMAP = !1) : p.isCube && (n.USESPHERICALFROMREFLECTIONMAP = !0, n.USEIRRADIANCEMAP = !1, this._forceIrradianceInFragment || this.realTimeFiltering || s.getEngine().getCaps().maxVaryingVectors <= 8 ? n.USESPHERICALINVERTEX = !1 : n.USESPHERICALINVERTEX = !0));
+ } else
+ n.REFLECTION = !1, n.REFLECTIONMAP_3D = !1, n.REFLECTIONMAP_SPHERICAL = !1, n.REFLECTIONMAP_PLANAR = !1, n.REFLECTIONMAP_CUBIC = !1, n.USE_LOCAL_REFLECTIONMAP_CUBIC = !1, n.REFLECTIONMAP_PROJECTION = !1, n.REFLECTIONMAP_SKYBOX = !1, n.REFLECTIONMAP_EXPLICIT = !1, n.REFLECTIONMAP_EQUIRECTANGULAR = !1, n.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1, n.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1, n.INVERTCUBICMAP = !1, n.USESPHERICALFROMREFLECTIONMAP = !1, n.USEIRRADIANCEMAP = !1, n.USESPHERICALINVERTEX = !1, n.REFLECTIONMAP_OPPOSITEZ = !1, n.LODINREFLECTIONALPHA = !1, n.GAMMAREFLECTION = !1, n.RGBDREFLECTION = !1, n.LINEARSPECULARREFLECTION = !1;
+ this._lightmapTexture && lt.a.LightmapTextureEnabled ? ($e.a.PrepareDefinesForMergedUV(this._lightmapTexture, n, "LIGHTMAP"), n.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap, n.GAMMALIGHTMAP = this._lightmapTexture.gammaSpace, n.RGBDLIGHTMAP = this._lightmapTexture.isRGBD) : n.LIGHTMAP = !1, this._emissiveTexture && lt.a.EmissiveTextureEnabled ? $e.a.PrepareDefinesForMergedUV(this._emissiveTexture, n, "EMISSIVE") : n.EMISSIVE = !1, lt.a.SpecularTextureEnabled ? (this._metallicTexture ? ($e.a.PrepareDefinesForMergedUV(this._metallicTexture, n, "REFLECTIVITY"), n.ROUGHNESSSTOREINMETALMAPALPHA = this._useRoughnessFromMetallicTextureAlpha, n.ROUGHNESSSTOREINMETALMAPGREEN = !this._useRoughnessFromMetallicTextureAlpha && this._useRoughnessFromMetallicTextureGreen, n.METALLNESSSTOREINMETALMAPBLUE = this._useMetallnessFromMetallicTextureBlue, n.AOSTOREINMETALMAPRED = this._useAmbientOcclusionFromMetallicTextureRed) : this._reflectivityTexture ? ($e.a.PrepareDefinesForMergedUV(this._reflectivityTexture, n, "REFLECTIVITY"), n.MICROSURFACEFROMREFLECTIVITYMAP = this._useMicroSurfaceFromReflectivityMapAlpha, n.MICROSURFACEAUTOMATIC = this._useAutoMicroSurfaceFromReflectivityMap) : n.REFLECTIVITY = !1, this._metallicReflectanceTexture ? $e.a.PrepareDefinesForMergedUV(this._metallicReflectanceTexture, n, "METALLIC_REFLECTANCE") : n.METALLIC_REFLECTANCE = !1, this._microSurfaceTexture ? $e.a.PrepareDefinesForMergedUV(this._microSurfaceTexture, n, "MICROSURFACEMAP") : n.MICROSURFACEMAP = !1) : (n.REFLECTIVITY = !1, n.MICROSURFACEMAP = !1), s.getEngine().getCaps().standardDerivatives && this._bumpTexture && lt.a.BumpTextureEnabled && !this._disableBumpMap ? ($e.a.PrepareDefinesForMergedUV(this._bumpTexture, n, "BUMP"), this._useParallax && this._albedoTexture && lt.a.DiffuseTextureEnabled ? (n.PARALLAX = !0, n.PARALLAXOCCLUSION = !!this._useParallaxOcclusion) : n.PARALLAX = !1, n.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap) : n.BUMP = !1, this._environmentBRDFTexture && lt.a.ReflectionTextureEnabled ? (n.ENVIRONMENTBRDF = !0, n.ENVIRONMENTBRDF_RGBD = this._environmentBRDFTexture.isRGBD) : (n.ENVIRONMENTBRDF = !1, n.ENVIRONMENTBRDF_RGBD = !1), this._shouldUseAlphaFromAlbedoTexture() ? n.ALPHAFROMALBEDO = !0 : n.ALPHAFROMALBEDO = !1;
+ }
+ n.SPECULAROVERALPHA = this._useSpecularOverAlpha, this._lightFalloff === t.LIGHTFALLOFF_STANDARD ? (n.USEPHYSICALLIGHTFALLOFF = !1, n.USEGLTFLIGHTFALLOFF = !1) : this._lightFalloff === t.LIGHTFALLOFF_GLTF ? (n.USEPHYSICALLIGHTFALLOFF = !1, n.USEGLTFLIGHTFALLOFF = !0) : (n.USEPHYSICALLIGHTFALLOFF = !0, n.USEGLTFLIGHTFALLOFF = !1), n.RADIANCEOVERALPHA = this._useRadianceOverAlpha, !this.backFaceCulling && this._twoSidedLighting ? n.TWOSIDEDLIGHTING = !0 : n.TWOSIDEDLIGHTING = !1, n.SPECULARAA = s.getEngine().getCaps().standardDerivatives && this._enableSpecularAntiAliasing;
+ }
+ (n._areTexturesDirty || n._areMiscDirty) && (n.ALPHATESTVALUE = this._alphaCutOff + (this._alphaCutOff % 1 == 0 ? "." : ""), n.PREMULTIPLYALPHA = this.alphaMode === h.a.ALPHA_PREMULTIPLIED || this.alphaMode === h.a.ALPHA_PREMULTIPLIED_PORTERDUFF, n.ALPHABLEND = this.needAlphaBlendingForMesh(e), n.ALPHAFRESNEL = this._useAlphaFresnel || this._useLinearAlphaFresnel, n.LINEARALPHAFRESNEL = this._useLinearAlphaFresnel), n._areImageProcessingDirty && this._imageProcessingConfiguration && this._imageProcessingConfiguration.prepareDefines(n), n.FORCENORMALFORWARD = this._forceNormalForward, n.RADIANCEOCCLUSION = this._useRadianceOcclusion, n.HORIZONOCCLUSION = this._useHorizonOcclusion, n._areMiscDirty && ($e.a.PrepareDefinesForMisc(e, s, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(e) || this._forceAlphaTest, n), n.UNLIT = this._unlit || (this.pointsCloud || this.wireframe) && !e.isVerticesDataPresent(Oe.b.NormalKind), n.DEBUGMODE = this._debugMode), this.detailMap.prepareDefines(n, s), this.subSurface.prepareDefines(n, s), this.clearCoat.prepareDefines(n, s), this.anisotropy.prepareDefines(n, e, s), this.brdf.prepareDefines(n), this.sheen.prepareDefines(n, s), $e.a.PrepareDefinesForFrameBoundValues(s, d, n, !!i, o, a), $e.a.PrepareDefinesForAttributes(e, n, !0, !0, !0, this._transparencyMode !== t.PBRMATERIAL_OPAQUE);
+ }, t.prototype.forceCompilation = function(e, n, i) {
+ var o = this, a = Object(c.a)({ clipPlane: !1, useInstances: !1 }, i), s = new As(), d = this._prepareEffect(e, s, void 0, void 0, a.useInstances, a.clipPlane, e.hasThinInstances);
+ this._onEffectCreatedObservable && (vr.effect = d, vr.subMesh = null, this._onEffectCreatedObservable.notifyObservers(vr)), d.isReady() ? n && n(this) : d.onCompileObservable.add(function() {
+ n && n(o);
+ });
+ }, t.prototype.buildUniformLayout = function() {
+ var e = this._uniformBuffer;
+ e.addUniform("vAlbedoInfos", 2), e.addUniform("vAmbientInfos", 4), e.addUniform("vOpacityInfos", 2), e.addUniform("vEmissiveInfos", 2), e.addUniform("vLightmapInfos", 2), e.addUniform("vReflectivityInfos", 3), e.addUniform("vMicroSurfaceSamplerInfos", 2), e.addUniform("vReflectionInfos", 2), e.addUniform("vReflectionFilteringInfo", 2), e.addUniform("vReflectionPosition", 3), e.addUniform("vReflectionSize", 3), e.addUniform("vBumpInfos", 3), e.addUniform("albedoMatrix", 16), e.addUniform("ambientMatrix", 16), e.addUniform("opacityMatrix", 16), e.addUniform("emissiveMatrix", 16), e.addUniform("lightmapMatrix", 16), e.addUniform("reflectivityMatrix", 16), e.addUniform("microSurfaceSamplerMatrix", 16), e.addUniform("bumpMatrix", 16), e.addUniform("vTangentSpaceParams", 2), e.addUniform("reflectionMatrix", 16), e.addUniform("vReflectionColor", 3), e.addUniform("vAlbedoColor", 4), e.addUniform("vLightingIntensity", 4), e.addUniform("vReflectionMicrosurfaceInfos", 3), e.addUniform("pointSize", 1), e.addUniform("vReflectivityColor", 4), e.addUniform("vEmissiveColor", 3), e.addUniform("visibility", 1), e.addUniform("vMetallicReflectanceFactors", 4), e.addUniform("vMetallicReflectanceInfos", 2), e.addUniform("metallicReflectanceMatrix", 16), mr.PrepareUniformBuffer(e), gr.PrepareUniformBuffer(e), Zr.PrepareUniformBuffer(e), Jr.PrepareUniformBuffer(e), Wo.a.PrepareUniformBuffer(e), e.create();
+ }, t.prototype.unbind = function() {
+ if (this._activeEffect) {
+ var e = !1;
+ this._reflectionTexture && this._reflectionTexture.isRenderTarget && (this._activeEffect.setTexture("reflection2DSampler", null), e = !0), this.subSurface.unbind(this._activeEffect) && (e = !0), e && this._markAllSubMeshesAsTexturesDirty();
+ }
+ r.prototype.unbind.call(this);
+ }, t.prototype.bindForSubMesh = function(e, n, i) {
+ var o = this.getScene(), a = i._materialDefines;
+ if (a) {
+ var s = i.effect;
+ if (s) {
+ this._activeEffect = s, a.INSTANCES && !a.THIN_INSTANCES || this.bindOnlyWorldMatrix(e), this.prePassConfiguration.bindForSubMesh(this._activeEffect, o, n, e, this.isFrozen), a.OBJECTSPACE_NORMALMAP && (e.toNormalMatrix(this._normalMatrix), this.bindOnlyNormalMatrix(this._normalMatrix));
+ var d = this._mustRebind(o, s, n.visibility);
+ $e.a.BindBonesParameters(n, this._activeEffect, this.prePassConfiguration);
+ var p = null, y = this._uniformBuffer;
+ if (d) {
+ var P = o.getEngine();
+ if (y.bindToEffect(s, "Material"), this.bindViewProjection(s), p = this._getReflectionTexture(), !y.useUbo || !this.isFrozen || !y.isSync) {
+ if (o.texturesEnabled) {
+ if (this._albedoTexture && lt.a.DiffuseTextureEnabled && (y.updateFloat2("vAlbedoInfos", this._albedoTexture.coordinatesIndex, this._albedoTexture.level), $e.a.BindTextureMatrix(this._albedoTexture, y, "albedo")), this._ambientTexture && lt.a.AmbientTextureEnabled && (y.updateFloat4("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level, this._ambientTextureStrength, this._ambientTextureImpactOnAnalyticalLights), $e.a.BindTextureMatrix(this._ambientTexture, y, "ambient")), this._opacityTexture && lt.a.OpacityTextureEnabled && (y.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level), $e.a.BindTextureMatrix(this._opacityTexture, y, "opacity")), p && lt.a.ReflectionTextureEnabled) {
+ if (y.updateMatrix("reflectionMatrix", p.getReflectionTextureMatrix()), y.updateFloat2("vReflectionInfos", p.level, 0), p.boundingBoxSize) {
+ var R = p;
+ y.updateVector3("vReflectionPosition", R.boundingBoxPosition), y.updateVector3("vReflectionSize", R.boundingBoxSize);
+ }
+ if (this.realTimeFiltering) {
+ var B = p.getSize().width;
+ y.updateFloat2("vReflectionFilteringInfo", B, $.a.Log2(B));
+ }
+ if (!a.USEIRRADIANCEMAP) {
+ var F = p.sphericalPolynomial;
+ if (a.USESPHERICALFROMREFLECTIONMAP && F)
+ if (a.SPHERICAL_HARMONICS) {
+ var z = F.preScaledHarmonics;
+ this._activeEffect.setVector3("vSphericalL00", z.l00), this._activeEffect.setVector3("vSphericalL1_1", z.l1_1), this._activeEffect.setVector3("vSphericalL10", z.l10), this._activeEffect.setVector3("vSphericalL11", z.l11), this._activeEffect.setVector3("vSphericalL2_2", z.l2_2), this._activeEffect.setVector3("vSphericalL2_1", z.l2_1), this._activeEffect.setVector3("vSphericalL20", z.l20), this._activeEffect.setVector3("vSphericalL21", z.l21), this._activeEffect.setVector3("vSphericalL22", z.l22);
+ } else
+ this._activeEffect.setFloat3("vSphericalX", F.x.x, F.x.y, F.x.z), this._activeEffect.setFloat3("vSphericalY", F.y.x, F.y.y, F.y.z), this._activeEffect.setFloat3("vSphericalZ", F.z.x, F.z.y, F.z.z), this._activeEffect.setFloat3("vSphericalXX_ZZ", F.xx.x - F.zz.x, F.xx.y - F.zz.y, F.xx.z - F.zz.z), this._activeEffect.setFloat3("vSphericalYY_ZZ", F.yy.x - F.zz.x, F.yy.y - F.zz.y, F.yy.z - F.zz.z), this._activeEffect.setFloat3("vSphericalZZ", F.zz.x, F.zz.y, F.zz.z), this._activeEffect.setFloat3("vSphericalXY", F.xy.x, F.xy.y, F.xy.z), this._activeEffect.setFloat3("vSphericalYZ", F.yz.x, F.yz.y, F.yz.z), this._activeEffect.setFloat3("vSphericalZX", F.zx.x, F.zx.y, F.zx.z);
+ }
+ y.updateFloat3("vReflectionMicrosurfaceInfos", p.getSize().width, p.lodGenerationScale, p.lodGenerationOffset);
+ }
+ this._emissiveTexture && lt.a.EmissiveTextureEnabled && (y.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level), $e.a.BindTextureMatrix(this._emissiveTexture, y, "emissive")), this._lightmapTexture && lt.a.LightmapTextureEnabled && (y.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level), $e.a.BindTextureMatrix(this._lightmapTexture, y, "lightmap")), lt.a.SpecularTextureEnabled && (this._metallicTexture ? (y.updateFloat3("vReflectivityInfos", this._metallicTexture.coordinatesIndex, this._metallicTexture.level, this._ambientTextureStrength), $e.a.BindTextureMatrix(this._metallicTexture, y, "reflectivity")) : this._reflectivityTexture && (y.updateFloat3("vReflectivityInfos", this._reflectivityTexture.coordinatesIndex, this._reflectivityTexture.level, 1), $e.a.BindTextureMatrix(this._reflectivityTexture, y, "reflectivity")), this._metallicReflectanceTexture && (y.updateFloat2("vMetallicReflectanceInfos", this._metallicReflectanceTexture.coordinatesIndex, this._metallicReflectanceTexture.level), $e.a.BindTextureMatrix(this._metallicReflectanceTexture, y, "metallicReflectance")), this._microSurfaceTexture && (y.updateFloat2("vMicroSurfaceSamplerInfos", this._microSurfaceTexture.coordinatesIndex, this._microSurfaceTexture.level), $e.a.BindTextureMatrix(this._microSurfaceTexture, y, "microSurfaceSampler"))), this._bumpTexture && P.getCaps().standardDerivatives && lt.a.BumpTextureEnabled && !this._disableBumpMap && (y.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level, this._parallaxScaleBias), $e.a.BindTextureMatrix(this._bumpTexture, y, "bump"), o._mirroredCameraPosition ? y.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1 : -1, this._invertNormalMapY ? 1 : -1) : y.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1 : 1, this._invertNormalMapY ? -1 : 1));
+ }
+ if (this.pointsCloud && y.updateFloat("pointSize", this.pointSize), a.METALLICWORKFLOW) {
+ I.c.Color3[0].r = this._metallic === void 0 || this._metallic === null ? 1 : this._metallic, I.c.Color3[0].g = this._roughness === void 0 || this._roughness === null ? 1 : this._roughness, y.updateColor4("vReflectivityColor", I.c.Color3[0], 1);
+ var J = this.subSurface.indexOfRefraction, ie = Math.pow((J - 1) / (J + 1), 2);
+ this._metallicReflectanceColor.scaleToRef(ie * this._metallicF0Factor, I.c.Color3[0]);
+ var se = this._metallicF0Factor;
+ y.updateColor4("vMetallicReflectanceFactors", I.c.Color3[0], se);
+ } else
+ y.updateColor4("vReflectivityColor", this._reflectivityColor, this._microSurface);
+ y.updateColor3("vEmissiveColor", lt.a.EmissiveTextureEnabled ? this._emissiveColor : I.a.BlackReadOnly), y.updateColor3("vReflectionColor", this._reflectionColor), !a.SS_REFRACTION && this.subSurface.linkRefractionWithTransparency ? y.updateColor4("vAlbedoColor", this._albedoColor, 1) : y.updateColor4("vAlbedoColor", this._albedoColor, this.alpha), this._lightingInfos.x = this._directIntensity, this._lightingInfos.y = this._emissiveIntensity, this._lightingInfos.z = this._environmentIntensity * o.environmentIntensity, this._lightingInfos.w = this._specularIntensity, y.updateVector4("vLightingIntensity", this._lightingInfos);
+ }
+ y.updateFloat("visibility", n.visibility), o.texturesEnabled && (this._albedoTexture && lt.a.DiffuseTextureEnabled && y.setTexture("albedoSampler", this._albedoTexture), this._ambientTexture && lt.a.AmbientTextureEnabled && y.setTexture("ambientSampler", this._ambientTexture), this._opacityTexture && lt.a.OpacityTextureEnabled && y.setTexture("opacitySampler", this._opacityTexture), p && lt.a.ReflectionTextureEnabled && (a.LODBASEDMICROSFURACE ? y.setTexture("reflectionSampler", p) : (y.setTexture("reflectionSampler", p._lodTextureMid || p), y.setTexture("reflectionSamplerLow", p._lodTextureLow || p), y.setTexture("reflectionSamplerHigh", p._lodTextureHigh || p)), a.USEIRRADIANCEMAP && y.setTexture("irradianceSampler", p.irradianceTexture)), a.ENVIRONMENTBRDF && y.setTexture("environmentBrdfSampler", this._environmentBRDFTexture), this._emissiveTexture && lt.a.EmissiveTextureEnabled && y.setTexture("emissiveSampler", this._emissiveTexture), this._lightmapTexture && lt.a.LightmapTextureEnabled && y.setTexture("lightmapSampler", this._lightmapTexture), lt.a.SpecularTextureEnabled && (this._metallicTexture ? y.setTexture("reflectivitySampler", this._metallicTexture) : this._reflectivityTexture && y.setTexture("reflectivitySampler", this._reflectivityTexture), this._metallicReflectanceTexture && y.setTexture("metallicReflectanceSampler", this._metallicReflectanceTexture), this._microSurfaceTexture && y.setTexture("microSurfaceSampler", this._microSurfaceTexture)), this._bumpTexture && P.getCaps().standardDerivatives && lt.a.BumpTextureEnabled && !this._disableBumpMap && y.setTexture("bumpSampler", this._bumpTexture)), this.detailMap.bindForSubMesh(y, o, this.isFrozen), this.subSurface.bindForSubMesh(y, o, P, this.isFrozen, a.LODBASEDMICROSFURACE, this.realTimeFiltering), this.clearCoat.bindForSubMesh(y, o, P, this._disableBumpMap, this.isFrozen, this._invertNormalMapX, this._invertNormalMapY, i), this.anisotropy.bindForSubMesh(y, o, this.isFrozen), this.sheen.bindForSubMesh(y, o, this.isFrozen, i), $e.a.BindClipPlane(this._activeEffect, o), o.ambientColor.multiplyToRef(this._ambientColor, this._globalAmbientColor);
+ var ce = o._forcedViewPosition ? o._forcedViewPosition : o._mirroredCameraPosition ? o._mirroredCameraPosition : o.activeCamera.globalPosition, ue = o.useRightHandedSystem === (o._mirroredCameraPosition != null);
+ s.setFloat4("vEyePosition", ce.x, ce.y, ce.z, ue ? -1 : 1), s.setColor3("vAmbientColor", this._globalAmbientColor), s.setFloat2("vDebugMode", this.debugLimit, this.debugFactor);
+ }
+ !d && this.isFrozen || (o.lightsEnabled && !this._disableLighting && $e.a.BindLights(o, n, this._activeEffect, a, this._maxSimultaneousLights, this._rebuildInParallel), (o.fogEnabled && n.applyFog && o.fogMode !== _e.a.FOGMODE_NONE || p) && this.bindView(s), $e.a.BindFogParameters(o, n, this._activeEffect, !0), a.NUM_MORPH_INFLUENCERS && $e.a.BindMorphTargetParameters(n, this._activeEffect), this._imageProcessingConfiguration.bind(this._activeEffect), $e.a.BindLogDepth(a, this._activeEffect, o)), y.update(), this._afterBind(n, this._activeEffect);
+ }
+ }
+ }, t.prototype.getAnimatables = function() {
+ var e = [];
+ return this._albedoTexture && this._albedoTexture.animations && this._albedoTexture.animations.length > 0 && e.push(this._albedoTexture), this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0 && e.push(this._ambientTexture), this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0 && e.push(this._opacityTexture), this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0 && e.push(this._reflectionTexture), this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0 && e.push(this._emissiveTexture), this._metallicTexture && this._metallicTexture.animations && this._metallicTexture.animations.length > 0 ? e.push(this._metallicTexture) : this._reflectivityTexture && this._reflectivityTexture.animations && this._reflectivityTexture.animations.length > 0 && e.push(this._reflectivityTexture), this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0 && e.push(this._bumpTexture), this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0 && e.push(this._lightmapTexture), this.detailMap.getAnimatables(e), this.subSurface.getAnimatables(e), this.clearCoat.getAnimatables(e), this.sheen.getAnimatables(e), this.anisotropy.getAnimatables(e), e;
+ }, t.prototype._getReflectionTexture = function() {
+ return this._reflectionTexture ? this._reflectionTexture : this.getScene().environmentTexture;
+ }, t.prototype.getActiveTextures = function() {
+ var e = r.prototype.getActiveTextures.call(this);
+ return this._albedoTexture && e.push(this._albedoTexture), this._ambientTexture && e.push(this._ambientTexture), this._opacityTexture && e.push(this._opacityTexture), this._reflectionTexture && e.push(this._reflectionTexture), this._emissiveTexture && e.push(this._emissiveTexture), this._reflectivityTexture && e.push(this._reflectivityTexture), this._metallicTexture && e.push(this._metallicTexture), this._metallicReflectanceTexture && e.push(this._metallicReflectanceTexture), this._microSurfaceTexture && e.push(this._microSurfaceTexture), this._bumpTexture && e.push(this._bumpTexture), this._lightmapTexture && e.push(this._lightmapTexture), this.detailMap.getActiveTextures(e), this.subSurface.getActiveTextures(e), this.clearCoat.getActiveTextures(e), this.sheen.getActiveTextures(e), this.anisotropy.getActiveTextures(e), e;
+ }, t.prototype.hasTexture = function(e) {
+ return !!r.prototype.hasTexture.call(this, e) || this._albedoTexture === e || this._ambientTexture === e || this._opacityTexture === e || this._reflectionTexture === e || this._reflectivityTexture === e || this._metallicTexture === e || this._metallicReflectanceTexture === e || this._microSurfaceTexture === e || this._bumpTexture === e || this._lightmapTexture === e || this.detailMap.hasTexture(e) || this.subSurface.hasTexture(e) || this.clearCoat.hasTexture(e) || this.sheen.hasTexture(e) || this.anisotropy.hasTexture(e);
+ }, t.prototype.setPrePassRenderer = function(e) {
+ if (this.subSurface.isScatteringEnabled) {
+ var n = this.getScene().enableSubSurfaceForPrePass();
+ return n && (n.enabled = !0), !0;
+ }
+ return !1;
+ }, t.prototype.dispose = function(e, n) {
+ var i, o, a, s, d, p, y, P, R, B, F;
+ n && (this._environmentBRDFTexture && this.getScene().environmentBRDFTexture !== this._environmentBRDFTexture && this._environmentBRDFTexture.dispose(), (i = this._albedoTexture) === null || i === void 0 || i.dispose(), (o = this._ambientTexture) === null || o === void 0 || o.dispose(), (a = this._opacityTexture) === null || a === void 0 || a.dispose(), (s = this._reflectionTexture) === null || s === void 0 || s.dispose(), (d = this._emissiveTexture) === null || d === void 0 || d.dispose(), (p = this._metallicTexture) === null || p === void 0 || p.dispose(), (y = this._reflectivityTexture) === null || y === void 0 || y.dispose(), (P = this._bumpTexture) === null || P === void 0 || P.dispose(), (R = this._lightmapTexture) === null || R === void 0 || R.dispose(), (B = this._metallicReflectanceTexture) === null || B === void 0 || B.dispose(), (F = this._microSurfaceTexture) === null || F === void 0 || F.dispose()), this.detailMap.dispose(n), this.subSurface.dispose(n), this.clearCoat.dispose(n), this.sheen.dispose(n), this.anisotropy.dispose(n), this._renderTargets.dispose(), this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver), r.prototype.dispose.call(this, e, n);
+ }, t.PBRMATERIAL_OPAQUE = zt.a.MATERIAL_OPAQUE, t.PBRMATERIAL_ALPHATEST = zt.a.MATERIAL_ALPHATEST, t.PBRMATERIAL_ALPHABLEND = zt.a.MATERIAL_ALPHABLEND, t.PBRMATERIAL_ALPHATESTANDBLEND = zt.a.MATERIAL_ALPHATESTANDBLEND, t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = 0, t.LIGHTFALLOFF_PHYSICAL = 0, t.LIGHTFALLOFF_GLTF = 1, t.LIGHTFALLOFF_STANDARD = 2, Object(c.c)([Object(L.i)()], t.prototype, "_imageProcessingConfiguration", void 0), Object(c.c)([Object(L.b)("_markAllSubMeshesAsMiscDirty")], t.prototype, "debugMode", void 0), Object(c.c)([Object(L.c)()], t.prototype, "useLogarithmicDepth", null), t;
+ }(jo.a), $r = function(r) {
+ function t(e, n) {
+ var i = r.call(this, e, n) || this;
+ return i.directIntensity = 1, i.emissiveIntensity = 1, i.environmentIntensity = 1, i.specularIntensity = 1, i.disableBumpMap = !1, i.ambientTextureStrength = 1, i.ambientTextureImpactOnAnalyticalLights = t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS, i.metallicF0Factor = 1, i.metallicReflectanceColor = I.a.White(), i.ambientColor = new I.a(0, 0, 0), i.albedoColor = new I.a(1, 1, 1), i.reflectivityColor = new I.a(1, 1, 1), i.reflectionColor = new I.a(1, 1, 1), i.emissiveColor = new I.a(0, 0, 0), i.microSurface = 1, i.useLightmapAsShadowmap = !1, i.useAlphaFromAlbedoTexture = !1, i.forceAlphaTest = !1, i.alphaCutOff = 0.4, i.useSpecularOverAlpha = !0, i.useMicroSurfaceFromReflectivityMapAlpha = !1, i.useRoughnessFromMetallicTextureAlpha = !0, i.useRoughnessFromMetallicTextureGreen = !1, i.useMetallnessFromMetallicTextureBlue = !1, i.useAmbientOcclusionFromMetallicTextureRed = !1, i.useAmbientInGrayScale = !1, i.useAutoMicroSurfaceFromReflectivityMap = !1, i.useRadianceOverAlpha = !0, i.useObjectSpaceNormalMap = !1, i.useParallax = !1, i.useParallaxOcclusion = !1, i.parallaxScaleBias = 0.05, i.disableLighting = !1, i.forceIrradianceInFragment = !1, i.maxSimultaneousLights = 4, i.invertNormalMapX = !1, i.invertNormalMapY = !1, i.twoSidedLighting = !1, i.useAlphaFresnel = !1, i.useLinearAlphaFresnel = !1, i.environmentBRDFTexture = null, i.forceNormalForward = !1, i.enableSpecularAntiAliasing = !1, i.useHorizonOcclusion = !0, i.useRadianceOcclusion = !0, i.unlit = !1, i._environmentBRDFTexture = Ho.GetEnvironmentBRDFTexture(n), i;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "refractionTexture", { get: function() {
+ return this.subSurface.refractionTexture;
+ }, set: function(e) {
+ this.subSurface.refractionTexture = e, e ? this.subSurface.isRefractionEnabled = !0 : this.subSurface.linkRefractionWithTransparency || (this.subSurface.isRefractionEnabled = !1);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "indexOfRefraction", { get: function() {
+ return this.subSurface.indexOfRefraction;
+ }, set: function(e) {
+ this.subSurface.indexOfRefraction = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "invertRefractionY", { get: function() {
+ return this.subSurface.invertRefractionY;
+ }, set: function(e) {
+ this.subSurface.invertRefractionY = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "linkRefractionWithTransparency", { get: function() {
+ return this.subSurface.linkRefractionWithTransparency;
+ }, set: function(e) {
+ this.subSurface.linkRefractionWithTransparency = e, e && (this.subSurface.isRefractionEnabled = !0);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "usePhysicalLightFalloff", { get: function() {
+ return this._lightFalloff === pn.LIGHTFALLOFF_PHYSICAL;
+ }, set: function(e) {
+ e !== this.usePhysicalLightFalloff && (this._markAllSubMeshesAsTexturesDirty(), this._lightFalloff = e ? pn.LIGHTFALLOFF_PHYSICAL : pn.LIGHTFALLOFF_STANDARD);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "useGLTFLightFalloff", { get: function() {
+ return this._lightFalloff === pn.LIGHTFALLOFF_GLTF;
+ }, set: function(e) {
+ e !== this.useGLTFLightFalloff && (this._markAllSubMeshesAsTexturesDirty(), this._lightFalloff = e ? pn.LIGHTFALLOFF_GLTF : pn.LIGHTFALLOFF_STANDARD);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "imageProcessingConfiguration", { get: function() {
+ return this._imageProcessingConfiguration;
+ }, set: function(e) {
+ this._attachImageProcessingConfiguration(e), this._markAllSubMeshesAsTexturesDirty();
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraColorCurvesEnabled", { get: function() {
+ return this.imageProcessingConfiguration.colorCurvesEnabled;
+ }, set: function(e) {
+ this.imageProcessingConfiguration.colorCurvesEnabled = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraColorGradingEnabled", { get: function() {
+ return this.imageProcessingConfiguration.colorGradingEnabled;
+ }, set: function(e) {
+ this.imageProcessingConfiguration.colorGradingEnabled = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraToneMappingEnabled", { get: function() {
+ return this._imageProcessingConfiguration.toneMappingEnabled;
+ }, set: function(e) {
+ this._imageProcessingConfiguration.toneMappingEnabled = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraExposure", { get: function() {
+ return this._imageProcessingConfiguration.exposure;
+ }, set: function(e) {
+ this._imageProcessingConfiguration.exposure = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraContrast", { get: function() {
+ return this._imageProcessingConfiguration.contrast;
+ }, set: function(e) {
+ this._imageProcessingConfiguration.contrast = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraColorGradingTexture", { get: function() {
+ return this._imageProcessingConfiguration.colorGradingTexture;
+ }, set: function(e) {
+ this._imageProcessingConfiguration.colorGradingTexture = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraColorCurves", { get: function() {
+ return this._imageProcessingConfiguration.colorCurves;
+ }, set: function(e) {
+ this._imageProcessingConfiguration.colorCurves = e;
+ }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
+ return "PBRMaterial";
+ }, t.prototype.clone = function(e) {
+ var n = this, i = L.a.Clone(function() {
+ return new t(e, n.getScene());
+ }, this);
+ return i.id = e, i.name = e, this.clearCoat.copyTo(i.clearCoat), this.anisotropy.copyTo(i.anisotropy), this.brdf.copyTo(i.brdf), this.sheen.copyTo(i.sheen), this.subSurface.copyTo(i.subSurface), i;
+ }, t.prototype.serialize = function() {
+ var e = L.a.Serialize(this);
+ return e.customType = "BABYLON.PBRMaterial", e.clearCoat = this.clearCoat.serialize(), e.anisotropy = this.anisotropy.serialize(), e.brdf = this.brdf.serialize(), e.sheen = this.sheen.serialize(), e.subSurface = this.subSurface.serialize(), e;
+ }, t.Parse = function(e, n, i) {
+ var o = L.a.Parse(function() {
+ return new t(e.name, n);
+ }, e, n, i);
+ return e.clearCoat && o.clearCoat.parse(e.clearCoat, n, i), e.anisotropy && o.anisotropy.parse(e.anisotropy, n, i), e.brdf && o.brdf.parse(e.brdf, n, i), e.sheen && o.sheen.parse(e.sheen, n, i), e.subSurface && o.subSurface.parse(e.subSurface, n, i), o;
+ }, t.PBRMATERIAL_OPAQUE = pn.PBRMATERIAL_OPAQUE, t.PBRMATERIAL_ALPHATEST = pn.PBRMATERIAL_ALPHATEST, t.PBRMATERIAL_ALPHABLEND = pn.PBRMATERIAL_ALPHABLEND, t.PBRMATERIAL_ALPHATESTANDBLEND = pn.PBRMATERIAL_ALPHATESTANDBLEND, t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = pn.DEFAULT_AO_ON_ANALYTICAL_LIGHTS, Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "directIntensity", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveIntensity", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "environmentIntensity", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "specularIntensity", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "disableBumpMap", void 0), Object(c.c)([Object(L.m)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "albedoTexture", void 0), Object(c.c)([Object(L.m)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "ambientTexture", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "ambientTextureStrength", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "ambientTextureImpactOnAnalyticalLights", void 0), Object(c.c)([Object(L.m)(), Object(L.b)("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "opacityTexture", void 0), Object(c.c)([Object(L.m)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionTexture", void 0), Object(c.c)([Object(L.m)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveTexture", void 0), Object(c.c)([Object(L.m)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectivityTexture", void 0), Object(c.c)([Object(L.m)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallicTexture", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallic", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "roughness", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallicF0Factor", void 0), Object(c.c)([Object(L.e)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallicReflectanceColor", void 0), Object(c.c)([Object(L.m)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallicReflectanceTexture", void 0), Object(c.c)([Object(L.m)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "microSurfaceTexture", void 0), Object(c.c)([Object(L.m)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "bumpTexture", void 0), Object(c.c)([Object(L.m)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty", null)], t.prototype, "lightmapTexture", void 0), Object(c.c)([Object(L.e)("ambient"), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "ambientColor", void 0), Object(c.c)([Object(L.e)("albedo"), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "albedoColor", void 0), Object(c.c)([Object(L.e)("reflectivity"), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectivityColor", void 0), Object(c.c)([Object(L.e)("reflection"), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionColor", void 0), Object(c.c)([Object(L.e)("emissive"), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveColor", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "microSurface", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useLightmapAsShadowmap", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "useAlphaFromAlbedoTexture", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "forceAlphaTest", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "alphaCutOff", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useSpecularOverAlpha", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useMicroSurfaceFromReflectivityMapAlpha", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRoughnessFromMetallicTextureAlpha", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRoughnessFromMetallicTextureGreen", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useMetallnessFromMetallicTextureBlue", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useAmbientOcclusionFromMetallicTextureRed", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useAmbientInGrayScale", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useAutoMicroSurfaceFromReflectivityMap", void 0), Object(c.c)([Object(L.c)()], t.prototype, "usePhysicalLightFalloff", null), Object(c.c)([Object(L.c)()], t.prototype, "useGLTFLightFalloff", null), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRadianceOverAlpha", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useObjectSpaceNormalMap", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useParallax", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useParallaxOcclusion", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "parallaxScaleBias", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsLightsDirty")], t.prototype, "disableLighting", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "forceIrradianceInFragment", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsLightsDirty")], t.prototype, "maxSimultaneousLights", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertNormalMapX", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertNormalMapY", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "twoSidedLighting", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useAlphaFresnel", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useLinearAlphaFresnel", void 0), Object(c.c)([Object(L.m)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "environmentBRDFTexture", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "forceNormalForward", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "enableSpecularAntiAliasing", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useHorizonOcclusion", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRadianceOcclusion", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsMiscDirty")], t.prototype, "unlit", void 0), t;
+ }(pn);
+ O.a.RegisteredTypes["BABYLON.PBRMaterial"] = $r;
+ function Xo(r) {
+ return r.charCodeAt(0) + (r.charCodeAt(1) << 8) + (r.charCodeAt(2) << 16) + (r.charCodeAt(3) << 24);
+ }
+ var Zl = Xo("DXT1"), Jl = Xo("DXT3"), $l = Xo("DXT5"), Ps = Xo("DX10"), Di = function() {
+ function r() {
+ }
+ return r.GetDDSInfo = function(t) {
+ var e = new Int32Array(t.buffer, t.byteOffset, 31), n = new Int32Array(t.buffer, t.byteOffset, 35), i = 1;
+ 131072 & e[2] && (i = Math.max(1, e[7]));
+ var o = e[21], a = o === Ps ? n[32] : 0, s = h.a.TEXTURETYPE_UNSIGNED_INT;
+ switch (o) {
+ case 113:
+ s = h.a.TEXTURETYPE_HALF_FLOAT;
+ break;
+ case 116:
+ s = h.a.TEXTURETYPE_FLOAT;
+ break;
+ case Ps:
+ if (a === 10) {
+ s = h.a.TEXTURETYPE_HALF_FLOAT;
+ break;
+ }
+ if (a === 2) {
+ s = h.a.TEXTURETYPE_FLOAT;
+ break;
+ }
+ }
+ return { width: e[4], height: e[3], mipmapCount: i, isFourCC: (4 & e[20]) == 4, isRGB: (64 & e[20]) == 64, isLuminance: (131072 & e[20]) == 131072, isCube: (512 & e[28]) == 512, isCompressed: o === Zl || o === Jl || o === $l, dxgiFormat: a, textureType: s };
+ }, r._ToHalfFloat = function(t) {
+ r._FloatView || (r._FloatView = new Float32Array(1), r._Int32View = new Int32Array(r._FloatView.buffer)), r._FloatView[0] = t;
+ var e = r._Int32View[0], n = e >> 16 & 32768, i = e >> 12 & 2047, o = e >> 23 & 255;
+ return o < 103 ? n : o > 142 ? (n |= 31744, n |= (o == 255 ? 0 : 1) && 8388607 & e) : o < 113 ? n |= ((i |= 2048) >> 114 - o) + (i >> 113 - o & 1) : (n |= o - 112 << 10 | i >> 1, n += 1 & i);
+ }, r._FromHalfFloat = function(t) {
+ var e = (32768 & t) >> 15, n = (31744 & t) >> 10, i = 1023 & t;
+ return n === 0 ? (e ? -1 : 1) * Math.pow(2, -14) * (i / Math.pow(2, 10)) : n == 31 ? i ? NaN : 1 / 0 * (e ? -1 : 1) : (e ? -1 : 1) * Math.pow(2, n - 15) * (1 + i / Math.pow(2, 10));
+ }, r._GetHalfFloatAsFloatRGBAArrayBuffer = function(t, e, n, i, o, a) {
+ for (var s = new Float32Array(i), d = new Uint16Array(o, n), p = 0, y = 0; y < e; y++)
+ for (var P = 0; P < t; P++) {
+ var R = 4 * (P + y * t);
+ s[p] = r._FromHalfFloat(d[R]), s[p + 1] = r._FromHalfFloat(d[R + 1]), s[p + 2] = r._FromHalfFloat(d[R + 2]), r.StoreLODInAlphaChannel ? s[p + 3] = a : s[p + 3] = r._FromHalfFloat(d[R + 3]), p += 4;
+ }
+ return s;
+ }, r._GetHalfFloatRGBAArrayBuffer = function(t, e, n, i, o, a) {
+ if (r.StoreLODInAlphaChannel) {
+ for (var s = new Uint16Array(i), d = new Uint16Array(o, n), p = 0, y = 0; y < e; y++)
+ for (var P = 0; P < t; P++) {
+ var R = 4 * (P + y * t);
+ s[p] = d[R], s[p + 1] = d[R + 1], s[p + 2] = d[R + 2], s[p + 3] = r._ToHalfFloat(a), p += 4;
+ }
+ return s;
+ }
+ return new Uint16Array(o, n, i);
+ }, r._GetFloatRGBAArrayBuffer = function(t, e, n, i, o, a) {
+ if (r.StoreLODInAlphaChannel) {
+ for (var s = new Float32Array(i), d = new Float32Array(o, n), p = 0, y = 0; y < e; y++)
+ for (var P = 0; P < t; P++) {
+ var R = 4 * (P + y * t);
+ s[p] = d[R], s[p + 1] = d[R + 1], s[p + 2] = d[R + 2], s[p + 3] = a, p += 4;
+ }
+ return s;
+ }
+ return new Float32Array(o, n, i);
+ }, r._GetFloatAsUIntRGBAArrayBuffer = function(t, e, n, i, o, a) {
+ for (var s = new Uint8Array(i), d = new Float32Array(o, n), p = 0, y = 0; y < e; y++)
+ for (var P = 0; P < t; P++) {
+ var R = 4 * (P + y * t);
+ s[p] = 255 * $.a.Clamp(d[R]), s[p + 1] = 255 * $.a.Clamp(d[R + 1]), s[p + 2] = 255 * $.a.Clamp(d[R + 2]), r.StoreLODInAlphaChannel ? s[p + 3] = a : s[p + 3] = 255 * $.a.Clamp(d[R + 3]), p += 4;
+ }
+ return s;
+ }, r._GetHalfFloatAsUIntRGBAArrayBuffer = function(t, e, n, i, o, a) {
+ for (var s = new Uint8Array(i), d = new Uint16Array(o, n), p = 0, y = 0; y < e; y++)
+ for (var P = 0; P < t; P++) {
+ var R = 4 * (P + y * t);
+ s[p] = 255 * $.a.Clamp(r._FromHalfFloat(d[R])), s[p + 1] = 255 * $.a.Clamp(r._FromHalfFloat(d[R + 1])), s[p + 2] = 255 * $.a.Clamp(r._FromHalfFloat(d[R + 2])), r.StoreLODInAlphaChannel ? s[p + 3] = a : s[p + 3] = 255 * $.a.Clamp(r._FromHalfFloat(d[R + 3])), p += 4;
+ }
+ return s;
+ }, r._GetRGBAArrayBuffer = function(t, e, n, i, o, a, s, d, p) {
+ for (var y = new Uint8Array(i), P = new Uint8Array(o, n), R = 0, B = 0; B < e; B++)
+ for (var F = 0; F < t; F++) {
+ var z = 4 * (F + B * t);
+ y[R] = P[z + a], y[R + 1] = P[z + s], y[R + 2] = P[z + d], y[R + 3] = P[z + p], R += 4;
+ }
+ return y;
+ }, r._ExtractLongWordOrder = function(t) {
+ return t === 0 || t === 255 || t === -16777216 ? 0 : 1 + r._ExtractLongWordOrder(t >> 8);
+ }, r._GetRGBArrayBuffer = function(t, e, n, i, o, a, s, d) {
+ for (var p = new Uint8Array(i), y = new Uint8Array(o, n), P = 0, R = 0; R < e; R++)
+ for (var B = 0; B < t; B++) {
+ var F = 3 * (B + R * t);
+ p[P] = y[F + a], p[P + 1] = y[F + s], p[P + 2] = y[F + d], P += 3;
+ }
+ return p;
+ }, r._GetLuminanceArrayBuffer = function(t, e, n, i, o) {
+ for (var a = new Uint8Array(i), s = new Uint8Array(o, n), d = 0, p = 0; p < e; p++)
+ for (var y = 0; y < t; y++) {
+ var P = y + p * t;
+ a[d] = s[P], d++;
+ }
+ return a;
+ }, r.UploadDDSLevels = function(t, e, n, i, o, a, s, d) {
+ s === void 0 && (s = -1);
+ var p = null;
+ i.sphericalPolynomial && (p = new Array());
+ var y, P, R, B, F, z, J, ie = t.getCaps().s3tc, se = new Int32Array(n.buffer, n.byteOffset, 31), ce = 0, ue = 0, fe = 1;
+ if (se[0] === 542327876)
+ if (i.isFourCC || i.isRGB || i.isLuminance)
+ if (!i.isCompressed || ie) {
+ var ve = se[22];
+ B = se[1] + 4;
+ var Te, Re = !1;
+ if (i.isFourCC)
+ switch (y = se[21]) {
+ case Zl:
+ fe = 8, ue = ie.COMPRESSED_RGBA_S3TC_DXT1_EXT;
+ break;
+ case Jl:
+ fe = 16, ue = ie.COMPRESSED_RGBA_S3TC_DXT3_EXT;
+ break;
+ case $l:
+ fe = 16, ue = ie.COMPRESSED_RGBA_S3TC_DXT5_EXT;
+ break;
+ case 113:
+ case 116:
+ Re = !0;
+ break;
+ case Ps:
+ B += 20;
+ var Ae = !1;
+ switch (i.dxgiFormat) {
+ case 10:
+ case 2:
+ Re = !0, Ae = !0;
+ break;
+ case 88:
+ i.isRGB = !0, i.isFourCC = !1, ve = 32, Ae = !0;
+ }
+ if (Ae)
+ break;
+ default:
+ return void console.error("Unsupported FourCC code:", (Te = y, String.fromCharCode(255 & Te, Te >> 8 & 255, Te >> 16 & 255, Te >> 24 & 255)));
+ }
+ var Ee = r._ExtractLongWordOrder(se[23]), Se = r._ExtractLongWordOrder(se[24]), De = r._ExtractLongWordOrder(se[25]), xe = r._ExtractLongWordOrder(se[26]);
+ Re && (ue = t._getRGBABufferInternalSizedFormat(i.textureType)), z = 1, 131072 & se[2] && o !== !1 && (z = Math.max(1, se[7]));
+ for (var Le = d || 0; Le < a; Le++) {
+ for (P = se[4], R = se[3], J = 0; J < z; ++J) {
+ if (s === -1 || s === J) {
+ var Me = s === -1 ? J : 0;
+ if (!i.isCompressed && i.isFourCC) {
+ e.format = h.a.TEXTUREFORMAT_RGBA, ce = P * R * 4;
+ var we = null;
+ t._badOS || t._badDesktopOS || !t.getCaps().textureHalfFloat && !t.getCaps().textureFloat ? (ve === 128 ? (we = r._GetFloatAsUIntRGBAArrayBuffer(P, R, n.byteOffset + B, ce, n.buffer, Me), p && Me == 0 && p.push(r._GetFloatRGBAArrayBuffer(P, R, n.byteOffset + B, ce, n.buffer, Me))) : ve === 64 && (we = r._GetHalfFloatAsUIntRGBAArrayBuffer(P, R, n.byteOffset + B, ce, n.buffer, Me), p && Me == 0 && p.push(r._GetHalfFloatAsFloatRGBAArrayBuffer(P, R, n.byteOffset + B, ce, n.buffer, Me))), e.type = h.a.TEXTURETYPE_UNSIGNED_INT) : ve === 128 ? (e.type = h.a.TEXTURETYPE_FLOAT, we = r._GetFloatRGBAArrayBuffer(P, R, n.byteOffset + B, ce, n.buffer, Me), p && Me == 0 && p.push(we)) : ve !== 64 || t.getCaps().textureHalfFloat ? (e.type = h.a.TEXTURETYPE_HALF_FLOAT, we = r._GetHalfFloatRGBAArrayBuffer(P, R, n.byteOffset + B, ce, n.buffer, Me), p && Me == 0 && p.push(r._GetHalfFloatAsFloatRGBAArrayBuffer(P, R, B, ce, n.buffer, Me))) : (e.type = h.a.TEXTURETYPE_FLOAT, we = r._GetHalfFloatAsFloatRGBAArrayBuffer(P, R, n.byteOffset + B, ce, n.buffer, Me), p && Me == 0 && p.push(we)), we && t._uploadDataToTextureDirectly(e, we, Le, Me);
+ } else if (i.isRGB)
+ e.type = h.a.TEXTURETYPE_UNSIGNED_INT, ve === 24 ? (e.format = h.a.TEXTUREFORMAT_RGB, ce = P * R * 3, F = r._GetRGBArrayBuffer(P, R, n.byteOffset + B, ce, n.buffer, Ee, Se, De), t._uploadDataToTextureDirectly(e, F, Le, Me)) : (e.format = h.a.TEXTUREFORMAT_RGBA, ce = P * R * 4, F = r._GetRGBAArrayBuffer(P, R, n.byteOffset + B, ce, n.buffer, Ee, Se, De, xe), t._uploadDataToTextureDirectly(e, F, Le, Me));
+ else if (i.isLuminance) {
+ var Ye = t._getUnpackAlignement(), et = P;
+ ce = Math.floor((P + Ye - 1) / Ye) * Ye * (R - 1) + et, F = r._GetLuminanceArrayBuffer(P, R, n.byteOffset + B, ce, n.buffer), e.format = h.a.TEXTUREFORMAT_LUMINANCE, e.type = h.a.TEXTURETYPE_UNSIGNED_INT, t._uploadDataToTextureDirectly(e, F, Le, Me);
+ } else
+ ce = Math.max(4, P) / 4 * Math.max(4, R) / 4 * fe, F = new Uint8Array(n.buffer, n.byteOffset + B, ce), e.type = h.a.TEXTURETYPE_UNSIGNED_INT, t._uploadCompressedDataToTextureDirectly(e, ue, P, R, F, Le, Me);
+ }
+ B += ve ? P * R * (ve / 8) : ce, P *= 0.5, R *= 0.5, P = Math.max(1, P), R = Math.max(1, R);
+ }
+ if (d !== void 0)
+ break;
+ }
+ p && p.length > 0 ? i.sphericalPolynomial = Lo.ConvertCubeMapToSphericalPolynomial({ size: se[4], right: p[0], left: p[1], up: p[2], down: p[3], front: p[4], back: p[5], format: h.a.TEXTUREFORMAT_RGBA, type: h.a.TEXTURETYPE_FLOAT, gammaSpace: !1 }) : i.sphericalPolynomial = void 0;
+ } else
+ l.a.Error("Compressed textures are not supported on this platform.");
+ else
+ l.a.Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");
+ else
+ l.a.Error("Invalid magic number in DDS header");
+ }, r.StoreLODInAlphaChannel = !1, r;
+ }();
+ wt.a.prototype.createPrefilteredCubeTexture = function(r, t, e, n, i, o, a, s, d) {
+ var p = this;
+ return i === void 0 && (i = null), o === void 0 && (o = null), s === void 0 && (s = null), d === void 0 && (d = !0), this.createCubeTexture(r, t, null, !1, function(y) {
+ if (y) {
+ var P = y.texture;
+ if (d ? y.info.sphericalPolynomial && (P._sphericalPolynomial = y.info.sphericalPolynomial) : P._sphericalPolynomial = new Yr(), P._source = Pt.b.CubePrefiltered, p.getCaps().textureLOD)
+ i && i(P);
+ else {
+ var R = p._gl, B = y.width;
+ if (B) {
+ for (var F = [], z = 0; z < 3; z++) {
+ var J = 1 - z / 2, ie = n, se = $.a.Log2(B) * e + n, ce = ie + (se - ie) * J, ue = Math.round(Math.min(Math.max(ce, 0), se)), fe = new Pt.a(p, Pt.b.Temp);
+ if (fe.type = P.type, fe.format = P.format, fe.width = Math.pow(2, Math.max($.a.Log2(B) - ue, 0)), fe.height = fe.width, fe.isCube = !0, p._bindTextureDirectly(R.TEXTURE_CUBE_MAP, fe, !0), fe.samplingMode = h.a.TEXTURE_LINEAR_LINEAR, R.texParameteri(R.TEXTURE_CUBE_MAP, R.TEXTURE_MAG_FILTER, R.LINEAR), R.texParameteri(R.TEXTURE_CUBE_MAP, R.TEXTURE_MIN_FILTER, R.LINEAR), R.texParameteri(R.TEXTURE_CUBE_MAP, R.TEXTURE_WRAP_S, R.CLAMP_TO_EDGE), R.texParameteri(R.TEXTURE_CUBE_MAP, R.TEXTURE_WRAP_T, R.CLAMP_TO_EDGE), y.isDDS) {
+ var ve = y.info, Te = y.data;
+ p._unpackFlipY(ve.isCompressed), Di.UploadDDSLevels(p, fe, Te, ve, !0, 6, ue);
+ } else
+ l.a.Warn("DDS is the only prefiltered cube map supported so far.");
+ p._bindTextureDirectly(R.TEXTURE_CUBE_MAP, null);
+ var Re = new kn.a(t);
+ Re.isCube = !0, Re._texture = fe, fe.isReady = !0, F.push(Re);
+ }
+ P._lodTextureHigh = F[2], P._lodTextureMid = F[1], P._lodTextureLow = F[0], i && i(P);
+ }
+ }
+ } else
+ i && i(null);
+ }, o, a, s, d, e, n);
+ };
+ var eu = function() {
+ function r() {
+ this.supportCascades = !0;
+ }
+ return r.prototype.canLoad = function(t) {
+ return Hn.a.EndsWith(t, ".dds");
+ }, r.prototype.loadCubeData = function(t, e, n, i, o) {
+ var a, s = e.getEngine(), d = !1;
+ if (Array.isArray(t))
+ for (var p = 0; p < t.length; p++) {
+ var y = t[p];
+ a = Di.GetDDSInfo(y), e.width = a.width, e.height = a.height, d = (a.isRGB || a.isLuminance || a.mipmapCount > 1) && e.generateMipMaps, s._unpackFlipY(a.isCompressed), Di.UploadDDSLevels(s, e, y, a, d, 6, -1, p), a.isFourCC || a.mipmapCount !== 1 || s.generateMipMapsForCubemap(e);
+ }
+ else {
+ var P = t;
+ a = Di.GetDDSInfo(P), e.width = a.width, e.height = a.height, n && (a.sphericalPolynomial = new Yr()), d = (a.isRGB || a.isLuminance || a.mipmapCount > 1) && e.generateMipMaps, s._unpackFlipY(a.isCompressed), Di.UploadDDSLevels(s, e, P, a, d, 6), a.isFourCC || a.mipmapCount !== 1 || s.generateMipMapsForCubemap(e, !1);
+ }
+ s._setCubeMapTextureParams(e, d), e.isReady = !0, e.onLoadedObservable.notifyObservers(e), e.onLoadedObservable.clear(), i && i({ isDDS: !0, width: e.width, info: a, data: t, texture: e });
+ }, r.prototype.loadData = function(t, e, n) {
+ var i = Di.GetDDSInfo(t), o = (i.isRGB || i.isLuminance || i.mipmapCount > 1) && e.generateMipMaps && i.width >> i.mipmapCount - 1 == 1;
+ n(i.width, i.height, o, i.isFourCC, function() {
+ Di.UploadDDSLevels(e.getEngine(), e, t, i, o, 1);
+ });
+ }, r;
+ }();
+ Ue.a._TextureLoaders.push(new eu());
+ var tu = function() {
+ function r() {
+ this.supportCascades = !1;
+ }
+ return r.prototype.canLoad = function(t) {
+ return Hn.a.EndsWith(t, ".env");
+ }, r.prototype.loadCubeData = function(t, e, n, i, o) {
+ if (!Array.isArray(t)) {
+ var a = gi.GetEnvInfo(t);
+ a ? (e.width = a.width, e.height = a.width, gi.UploadEnvSpherical(e, a), gi.UploadEnvLevelsAsync(e, t, a).then(function() {
+ e.isReady = !0, e.onLoadedObservable.notifyObservers(e), e.onLoadedObservable.clear(), i && i();
+ })) : o && o("Can not parse the environment file", null);
+ }
+ }, r.prototype.loadData = function(t, e, n) {
+ throw ".env not supported in 2d.";
+ }, r;
+ }();
+ Ue.a._TextureLoaders.push(new tu());
+ var Yo = function() {
+ function r(t, e, n, i) {
+ if (this.data = t, this.isInvalid = !1, !r.IsValid(t))
+ return this.isInvalid = !0, void l.a.Error("texture missing KTX identifier");
+ var o = Uint32Array.BYTES_PER_ELEMENT, a = new DataView(this.data.buffer, this.data.byteOffset + 12, 13 * o), s = a.getUint32(0, !0) === 67305985;
+ this.glType = a.getUint32(1 * o, s), this.glTypeSize = a.getUint32(2 * o, s), this.glFormat = a.getUint32(3 * o, s), this.glInternalFormat = a.getUint32(4 * o, s), this.glBaseInternalFormat = a.getUint32(5 * o, s), this.pixelWidth = a.getUint32(6 * o, s), this.pixelHeight = a.getUint32(7 * o, s), this.pixelDepth = a.getUint32(8 * o, s), this.numberOfArrayElements = a.getUint32(9 * o, s), this.numberOfFaces = a.getUint32(10 * o, s), this.numberOfMipmapLevels = a.getUint32(11 * o, s), this.bytesOfKeyValueData = a.getUint32(12 * o, s), this.glType === 0 ? (this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels), this.pixelHeight !== 0 && this.pixelDepth === 0 ? this.numberOfArrayElements === 0 ? this.numberOfFaces === e ? this.loadType = r.COMPRESSED_2D : l.a.Error("number of faces expected" + e + ", but found " + this.numberOfFaces) : l.a.Error("texture arrays not currently supported") : l.a.Error("only 2D textures currently supported")) : l.a.Error("only compressed formats currently supported");
+ }
+ return r.prototype.uploadLevels = function(t, e) {
+ switch (this.loadType) {
+ case r.COMPRESSED_2D:
+ this._upload2DCompressedLevels(t, e);
+ break;
+ case r.TEX_2D:
+ case r.COMPRESSED_3D:
+ case r.TEX_3D:
+ }
+ }, r.prototype._upload2DCompressedLevels = function(t, e) {
+ for (var n = r.HEADER_LEN + this.bytesOfKeyValueData, i = this.pixelWidth, o = this.pixelHeight, a = e ? this.numberOfMipmapLevels : 1, s = 0; s < a; s++) {
+ var d = new Int32Array(this.data.buffer, this.data.byteOffset + n, 1)[0];
+ n += 4;
+ for (var p = 0; p < this.numberOfFaces; p++) {
+ var y = new Uint8Array(this.data.buffer, this.data.byteOffset + n, d);
+ t.getEngine()._uploadCompressedDataToTextureDirectly(t, this.glInternalFormat, i, o, y, p, s), n += d, n += 3 - (d + 3) % 4;
+ }
+ i = Math.max(1, 0.5 * i), o = Math.max(1, 0.5 * o);
+ }
+ }, r.IsValid = function(t) {
+ if (t.byteLength >= 12) {
+ var e = new Uint8Array(t.buffer, t.byteOffset, 12);
+ if (e[0] === 171 && e[1] === 75 && e[2] === 84 && e[3] === 88 && e[4] === 32 && e[5] === 49 && e[6] === 49 && e[7] === 187 && e[8] === 13 && e[9] === 10 && e[10] === 26 && e[11] === 10)
+ return !0;
+ }
+ return !1;
+ }, r.HEADER_LEN = 64, r.COMPRESSED_2D = 0, r.COMPRESSED_3D = 1, r.TEX_2D = 2, r.TEX_3D = 3, r;
+ }(), xs = function() {
+ function r(t) {
+ this._pendingActions = new Array(), this._workerInfos = t.map(function(e) {
+ return { worker: e, active: !1 };
+ });
+ }
+ return r.prototype.dispose = function() {
+ for (var t = 0, e = this._workerInfos; t < e.length; t++)
+ e[t].worker.terminate();
+ this._workerInfos = [], this._pendingActions = [];
+ }, r.prototype.push = function(t) {
+ for (var e = 0, n = this._workerInfos; e < n.length; e++) {
+ var i = n[e];
+ if (!i.active)
+ return void this._execute(i, t);
+ }
+ this._pendingActions.push(t);
+ }, r.prototype._execute = function(t, e) {
+ var n = this;
+ t.active = !0, e(t.worker, function() {
+ t.active = !1;
+ var i = n._pendingActions.shift();
+ i && n._execute(t, i);
+ });
+ }, r;
+ }(), Cs = function() {
+ function r(t, e) {
+ e === void 0 && (e = r.DefaultNumWorkers), this._engine = t, r._Initialized || r._CreateWorkerPool(e);
+ }
+ return r.GetDefaultNumWorkers = function() {
+ return typeof navigator == "object" && navigator.hardwareConcurrency ? Math.min(Math.floor(0.5 * navigator.hardwareConcurrency), 4) : 1;
+ }, r._CreateWorkerPool = function(t) {
+ this._Initialized = !0, t && typeof Worker == "function" ? r._WorkerPoolPromise = new Promise(function(e) {
+ for (var n = "(" + Hp + ")()", i = URL.createObjectURL(new Blob([n], { type: "application/javascript" })), o = new Array(t), a = 0; a < o.length; a++)
+ o[a] = new Promise(function(s, d) {
+ var p = new Worker(i), y = function(R) {
+ p.removeEventListener("error", y), p.removeEventListener("message", P), d(R);
+ }, P = function(R) {
+ R.data.action === "init" && (p.removeEventListener("error", y), p.removeEventListener("message", P), s(p));
+ };
+ p.addEventListener("error", y), p.addEventListener("message", P), p.postMessage({ action: "init", urls: r.URLConfig });
+ });
+ Promise.all(o).then(function(s) {
+ e(new xs(s));
+ });
+ }) : (KTX2DECODER.MSCTranscoder.UseFromWorkerThread = !1, KTX2DECODER.WASMMemoryManager.LoadBinariesFromCurrentThread = !0);
+ }, r.prototype.uploadAsync = function(t, e, n) {
+ var i = this, o = this._engine.getCaps(), a = { astc: !!o.astc, bptc: !!o.bptc, s3tc: !!o.s3tc, pvrtc: !!o.pvrtc, etc2: !!o.etc2, etc1: !!o.etc1 };
+ return r._WorkerPoolPromise ? r._WorkerPoolPromise.then(function(s) {
+ return new Promise(function(d, p) {
+ s.push(function(y, P) {
+ var R = function(F) {
+ y.removeEventListener("error", R), y.removeEventListener("message", B), p(F), P();
+ }, B = function(F) {
+ if (F.data.action === "decoded") {
+ if (y.removeEventListener("error", R), y.removeEventListener("message", B), F.data.success)
+ try {
+ i._createTexture(F.data.decodedData, e, n), d();
+ } catch (z) {
+ p({ message: z });
+ }
+ else
+ p({ message: F.data.msg });
+ P();
+ }
+ };
+ y.addEventListener("error", R), y.addEventListener("message", B), y.postMessage({ action: "decode", data: t, caps: a, options: n });
+ });
+ });
+ }) : new Promise(function(s, d) {
+ r._Ktx2Decoder || (r._Ktx2Decoder = new KTX2DECODER.KTX2Decoder()), r._Ktx2Decoder.decode(t, o).then(function(p) {
+ i._createTexture(p, e), s();
+ }).catch(function(p) {
+ d({ message: p });
+ });
+ });
+ }, r.prototype.dispose = function() {
+ r._WorkerPoolPromise && r._WorkerPoolPromise.then(function(t) {
+ t.dispose();
+ }), delete r._WorkerPoolPromise;
+ }, r.prototype._createTexture = function(t, e, n) {
+ if (this._engine._bindTextureDirectly(this._engine._gl.TEXTURE_2D, e), n && (n.transcodedFormat = t.transcodedFormat, n.isInGammaSpace = t.isInGammaSpace, n.transcoderName = t.transcoderName), t.transcodedFormat === 32856 ? (e.type = h.a.TEXTURETYPE_UNSIGNED_BYTE, e.format = h.a.TEXTUREFORMAT_RGBA) : e.format = t.transcodedFormat, e._gammaSpace = t.isInGammaSpace, t.errors)
+ throw new Error("KTX2 container - could not transcode the data. " + t.errors);
+ for (var i = 0; i < t.mipmaps.length; ++i) {
+ var o = t.mipmaps[i];
+ if (!o || !o.data)
+ throw new Error("KTX2 container - could not transcode one of the image");
+ t.transcodedFormat === 32856 ? (e.width = o.width, e.height = o.height, this._engine._uploadDataToTextureDirectly(e, o.data, 0, i, void 0, !0)) : this._engine._uploadCompressedDataToTextureDirectly(e, t.transcodedFormat, o.width, o.height, o.data, 0, i);
+ }
+ e.width = t.mipmaps[0].width, e.height = t.mipmaps[0].height, e.generateMipMaps = t.mipmaps.length > 1, e.isReady = !0, this._engine._bindTextureDirectly(this._engine._gl.TEXTURE_2D, null);
+ }, r.IsValid = function(t) {
+ if (t.byteLength >= 12) {
+ var e = new Uint8Array(t.buffer, t.byteOffset, 12);
+ if (e[0] === 171 && e[1] === 75 && e[2] === 84 && e[3] === 88 && e[4] === 32 && e[5] === 50 && e[6] === 48 && e[7] === 187 && e[8] === 13 && e[9] === 10 && e[10] === 26 && e[11] === 10)
+ return !0;
+ }
+ return !1;
+ }, r.URLConfig = { jsDecoderModule: "https://preview.babylonjs.com/babylon.ktx2Decoder.js", wasmUASTCToASTC: null, wasmUASTCToBC7: null, wasmUASTCToRGBA_UNORM: null, wasmUASTCToRGBA_SRGB: null, jsMSCTranscoder: null, wasmMSCTranscoder: null }, r.DefaultNumWorkers = r.GetDefaultNumWorkers(), r;
+ }();
+ function Hp() {
+ var r;
+ onmessage = function(t) {
+ switch (t.data.action) {
+ case "init":
+ var e = t.data.urls;
+ importScripts(e.jsDecoderModule), e.wasmUASTCToASTC !== null && (KTX2DECODER.LiteTranscoder_UASTC_ASTC.WasmModuleURL = e.wasmUASTCToASTC), e.wasmUASTCToBC7 !== null && (KTX2DECODER.LiteTranscoder_UASTC_BC7.WasmModuleURL = e.wasmUASTCToBC7), e.wasmUASTCToRGBA_UNORM !== null && (KTX2DECODER.LiteTranscoder_UASTC_RGBA_UNORM.WasmModuleURL = e.wasmUASTCToRGBA_UNORM), e.wasmUASTCToRGBA_SRGB !== null && (KTX2DECODER.LiteTranscoder_UASTC_RGBA_SRGB.WasmModuleURL = e.wasmUASTCToRGBA_SRGB), e.jsMSCTranscoder !== null && (KTX2DECODER.MSCTranscoder.JSModuleURL = e.jsMSCTranscoder), e.wasmMSCTranscoder !== null && (KTX2DECODER.MSCTranscoder.WasmModuleURL = e.wasmMSCTranscoder), r = new KTX2DECODER.KTX2Decoder(), postMessage({ action: "init" });
+ break;
+ case "decode":
+ r.decode(t.data.data, t.data.caps, t.data.options).then(function(n) {
+ for (var i = [], o = 0; o < n.mipmaps.length; ++o) {
+ var a = n.mipmaps[o];
+ a && a.data && i.push(a.data.buffer);
+ }
+ postMessage({ action: "decoded", success: !0, decodedData: n }, i);
+ }).catch(function(n) {
+ postMessage({ action: "decoded", success: !1, msg: n });
+ });
+ }
+ };
+ }
+ var nu = function() {
+ function r() {
+ this.supportCascades = !1;
+ }
+ return r.prototype.canLoad = function(t, e) {
+ return Hn.a.EndsWith(t, ".ktx") || Hn.a.EndsWith(t, ".ktx2") || e === "image/ktx" || e === "image/ktx2";
+ }, r.prototype.loadCubeData = function(t, e, n, i, o) {
+ if (!Array.isArray(t)) {
+ e._invertVScale = !e.invertY;
+ var a = e.getEngine(), s = new Yo(t, 6), d = s.numberOfMipmapLevels > 1 && e.generateMipMaps;
+ a._unpackFlipY(!0), s.uploadLevels(e, e.generateMipMaps), e.width = s.pixelWidth, e.height = s.pixelHeight, a._setCubeMapTextureParams(e, d), e.isReady = !0, e.onLoadedObservable.notifyObservers(e), e.onLoadedObservable.clear(), i && i();
+ }
+ }, r.prototype.loadData = function(t, e, n, i) {
+ if (Yo.IsValid(t)) {
+ e._invertVScale = !e.invertY;
+ var o = new Yo(t, 1);
+ n(o.pixelWidth, o.pixelHeight, e.generateMipMaps, !0, function() {
+ o.uploadLevels(e, e.generateMipMaps);
+ }, o.isInvalid);
+ } else
+ Cs.IsValid(t) ? new Cs(e.getEngine()).uploadAsync(t, e, i).then(function() {
+ n(e.width, e.height, e.generateMipMaps, !0, function() {
+ }, !1);
+ }, function(a) {
+ l.a.Warn("Failed to load KTX2 texture data: " + a.message), n(0, 0, !1, !1, function() {
+ }, !0);
+ }) : (l.a.Error("texture missing KTX identifier"), n(0, 0, !1, !1, function() {
+ }, !0));
+ }, r;
+ }();
+ Ue.a._TextureLoaders.unshift(new nu());
+ var iu = function(r) {
+ function t(e, n, i) {
+ var o = r.call(this, e, u.e.Zero(), n) || this;
+ return o._xrSessionManager = i, o._firstFrame = !1, o._referenceQuaternion = u.b.Identity(), o._referencedPosition = new u.e(), o._xrInvPositionCache = new u.e(), o._xrInvQuaternionCache = u.b.Identity(), o._trackingState = Xi.NOT_TRACKING, o.onBeforeCameraTeleport = new C.c(), o.onAfterCameraTeleport = new C.c(), o.onTrackingStateChanged = new C.c(), o.compensateOnFirstFrame = !0, o._rotate180 = new u.b(0, 1, 0, 0), o.minZ = 0.1, o.rotationQuaternion = new u.b(), o.cameraRigMode = _t.a.RIG_MODE_CUSTOM, o.updateUpVectorFromRotation = !0, o._updateNumberOfRigCameras(1), o.freezeProjectionMatrix(), o._xrSessionManager.onXRSessionInit.add(function() {
+ o._referencedPosition.copyFromFloats(0, 0, 0), o._referenceQuaternion.copyFromFloats(0, 0, 0, 1), o._firstFrame = o.compensateOnFirstFrame;
+ }), o._xrSessionManager.onXRFrameObservable.add(function(a) {
+ o._firstFrame && o._updateFromXRSession(), o._updateReferenceSpace(), o._updateFromXRSession();
+ }, void 0, !0), o;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "trackingState", { get: function() {
+ return this._trackingState;
+ }, enumerable: !1, configurable: !0 }), t.prototype._setTrackingState = function(e) {
+ this._trackingState !== e && (this._trackingState = e, this.onTrackingStateChanged.notifyObservers(e));
+ }, Object.defineProperty(t.prototype, "realWorldHeight", { get: function() {
+ var e = this._xrSessionManager.currentFrame && this._xrSessionManager.currentFrame.getViewerPose(this._xrSessionManager.baseReferenceSpace);
+ return e && e.transform ? e.transform.position.y : 0;
+ }, enumerable: !1, configurable: !0 }), t.prototype._updateForDualEyeDebugging = function() {
+ this._updateNumberOfRigCameras(2), this.rigCameras[0].viewport = new jn.a(0, 0, 0.5, 1), this.rigCameras[0].outputRenderTarget = null, this.rigCameras[1].viewport = new jn.a(0.5, 0, 0.5, 1), this.rigCameras[1].outputRenderTarget = null;
+ }, t.prototype.setTransformationFromNonVRCamera = function(e, n) {
+ e === void 0 && (e = this.getScene().activeCamera), n === void 0 && (n = !0), e && e !== this && (e.computeWorldMatrix().decompose(void 0, this.rotationQuaternion, this.position), this.position.y = 0, u.b.FromEulerAnglesToRef(0, this.rotationQuaternion.toEulerAngles().y, 0, this.rotationQuaternion), this._firstFrame = !0, n && this._xrSessionManager.resetReferenceSpace());
+ }, t.prototype.getClassName = function() {
+ return "WebXRCamera";
+ }, t.prototype._updateFromXRSession = function() {
+ var e = this, n = this._xrSessionManager.currentFrame && this._xrSessionManager.currentFrame.getViewerPose(this._xrSessionManager.referenceSpace);
+ if (n) {
+ var i = n.emulatedPosition ? Xi.TRACKING_LOST : Xi.TRACKING;
+ if (this._setTrackingState(i), n.transform) {
+ var o = n.transform.position;
+ this._referencedPosition.set(o.x, o.y, o.z);
+ var a = n.transform.orientation;
+ this._referenceQuaternion.set(a.x, a.y, a.z, a.w), this._scene.useRightHandedSystem || (this._referencedPosition.z *= -1, this._referenceQuaternion.z *= -1, this._referenceQuaternion.w *= -1), this._firstFrame ? (this._firstFrame = !1, this.position.y += this._referencedPosition.y, this._referenceQuaternion.copyFromFloats(0, 0, 0, 1)) : (this.rotationQuaternion.copyFrom(this._referenceQuaternion), this.position.copyFrom(this._referencedPosition));
+ }
+ this.rigCameras.length !== n.views.length && this._updateNumberOfRigCameras(n.views.length), n.views.forEach(function(s, d) {
+ var p = e.rigCameras[d];
+ p.isLeftCamera || p.isRightCamera || (s.eye === "right" ? p._isRightCamera = !0 : s.eye === "left" && (p._isLeftCamera = !0));
+ var y = s.transform.position, P = s.transform.orientation;
+ if (p.position.set(y.x, y.y, y.z), p.rotationQuaternion.set(P.x, P.y, P.z, P.w), e._scene.useRightHandedSystem ? p.rotationQuaternion.multiplyInPlace(e._rotate180) : (p.position.z *= -1, p.rotationQuaternion.z *= -1, p.rotationQuaternion.w *= -1), u.a.FromFloat32ArrayToRefScaled(s.projectionMatrix, 0, 1, p._projectionMatrix), e._scene.useRightHandedSystem || p._projectionMatrix.toggleProjectionMatrixHandInPlace(), d === 0 && e._projectionMatrix.copyFrom(p._projectionMatrix), e._xrSessionManager.session.renderState.baseLayer) {
+ var R = e._xrSessionManager.session.renderState.baseLayer.getViewport(s), B = e._xrSessionManager.session.renderState.baseLayer.framebufferWidth, F = e._xrSessionManager.session.renderState.baseLayer.framebufferHeight;
+ p.viewport.width = R.width / B, p.viewport.height = R.height / F, p.viewport.x = R.x / B, p.viewport.y = R.y / F;
+ }
+ p.outputRenderTarget = e._xrSessionManager.getRenderTargetTextureForEye(s.eye);
+ });
+ } else
+ this._setTrackingState(Xi.NOT_TRACKING);
+ }, t.prototype._updateNumberOfRigCameras = function(e) {
+ for (e === void 0 && (e = 1); this.rigCameras.length < e; ) {
+ var n = new Pi("XR-RigCamera: " + this.rigCameras.length, u.e.Zero(), this.getScene());
+ n.minZ = 0.1, n.rotationQuaternion = new u.b(), n.updateUpVectorFromRotation = !0, n.isRigCamera = !0, n.rigParent = this, n.freezeProjectionMatrix(), this.rigCameras.push(n);
+ }
+ for (; this.rigCameras.length > e; ) {
+ var i = this.rigCameras.pop();
+ i && i.dispose();
+ }
+ }, t.prototype._updateReferenceSpace = function() {
+ this.position.equals(this._referencedPosition) && this.rotationQuaternion.equals(this._referenceQuaternion) || (this.position.subtractToRef(this._referencedPosition, this._referencedPosition), this._referenceQuaternion.conjugateInPlace(), this._referenceQuaternion.multiplyToRef(this.rotationQuaternion, this._referenceQuaternion), this._updateReferenceSpaceOffset(this._referencedPosition, this._referenceQuaternion.normalize()));
+ }, t.prototype._updateReferenceSpaceOffset = function(e, n, i) {
+ if (i === void 0 && (i = !1), this._xrSessionManager.referenceSpace && this._xrSessionManager.currentFrame) {
+ this._xrInvPositionCache.copyFrom(e), n ? this._xrInvQuaternionCache.copyFrom(n) : this._xrInvQuaternionCache.copyFromFloats(0, 0, 0, 1), this._scene.useRightHandedSystem || (this._xrInvPositionCache.z *= -1, this._xrInvQuaternionCache.z *= -1, this._xrInvQuaternionCache.w *= -1), this._xrInvPositionCache.negateInPlace(), this._xrInvQuaternionCache.conjugateInPlace(), this._xrInvPositionCache.rotateByQuaternionToRef(this._xrInvQuaternionCache, this._xrInvPositionCache), i && (this._xrInvPositionCache.y = 0);
+ var o = new XRRigidTransform({ x: this._xrInvPositionCache.x, y: this._xrInvPositionCache.y, z: this._xrInvPositionCache.z }, { x: this._xrInvQuaternionCache.x, y: this._xrInvQuaternionCache.y, z: this._xrInvQuaternionCache.z, w: this._xrInvQuaternionCache.w }), a = this._xrSessionManager.referenceSpace.getOffsetReferenceSpace(o), s = this._xrSessionManager.currentFrame && this._xrSessionManager.currentFrame.getViewerPose(a);
+ if (s) {
+ var d = new u.e(s.transform.position.x, s.transform.position.y, s.transform.position.z);
+ this._scene.useRightHandedSystem || (d.z *= -1), this.position.subtractToRef(d, d), this._scene.useRightHandedSystem || (d.z *= -1), d.negateInPlace();
+ var p = new XRRigidTransform({ x: d.x, y: d.y, z: d.z });
+ this._xrSessionManager.referenceSpace = a.getOffsetReferenceSpace(p);
+ }
+ }
+ }, t;
+ }(zn), ti = function() {
+ function r() {
+ }
+ return r.ANCHOR_SYSTEM = "xr-anchor-system", r.BACKGROUND_REMOVER = "xr-background-remover", r.HIT_TEST = "xr-hit-test", r.PHYSICS_CONTROLLERS = "xr-physics-controller", r.PLANE_DETECTION = "xr-plane-detection", r.POINTER_SELECTION = "xr-controller-pointer-selection", r.TELEPORTATION = "xr-controller-teleportation", r.FEATURE_POINTS = "xr-feature-points", r.HAND_TRACKING = "xr-hand-tracking", r;
+ }(), Wn = function() {
+ function r(t) {
+ var e = this;
+ this._xrSessionManager = t, this._features = {}, this._xrSessionManager.onXRSessionInit.add(function() {
+ e.getEnabledFeatures().forEach(function(n) {
+ var i = e._features[n];
+ !i.enabled || i.featureImplementation.attached || i.featureImplementation.disableAutoAttach || e.attachFeature(n);
+ });
+ }), this._xrSessionManager.onXRSessionEnded.add(function() {
+ e.getEnabledFeatures().forEach(function(n) {
+ var i = e._features[n];
+ i.enabled && i.featureImplementation.attached && e.detachFeature(n);
+ });
+ });
+ }
+ return r.AddWebXRFeature = function(t, e, n, i) {
+ n === void 0 && (n = 1), i === void 0 && (i = !1), this._AvailableFeatures[t] = this._AvailableFeatures[t] || { latest: n }, n > this._AvailableFeatures[t].latest && (this._AvailableFeatures[t].latest = n), i && (this._AvailableFeatures[t].stable = n), this._AvailableFeatures[t][n] = e;
+ }, r.ConstructFeature = function(t, e, n, i) {
+ e === void 0 && (e = 1);
+ var o = this._AvailableFeatures[t][e];
+ if (!o)
+ throw new Error("feature not found");
+ return o(n, i);
+ }, r.GetAvailableFeatures = function() {
+ return Object.keys(this._AvailableFeatures);
+ }, r.GetAvailableVersions = function(t) {
+ return Object.keys(this._AvailableFeatures[t]);
+ }, r.GetLatestVersionOfFeature = function(t) {
+ return this._AvailableFeatures[t] && this._AvailableFeatures[t].latest || -1;
+ }, r.GetStableVersionOfFeature = function(t) {
+ return this._AvailableFeatures[t] && this._AvailableFeatures[t].stable || -1;
+ }, r.prototype.attachFeature = function(t) {
+ var e = this._features[t];
+ e && e.enabled && !e.featureImplementation.attached && e.featureImplementation.attach();
+ }, r.prototype.detachFeature = function(t) {
+ var e = this._features[t];
+ e && e.featureImplementation.attached && e.featureImplementation.detach();
+ }, r.prototype.disableFeature = function(t) {
+ var e = typeof t == "string" ? t : t.Name, n = this._features[e];
+ return !(!n || !n.enabled) && (n.enabled = !1, this.detachFeature(e), n.featureImplementation.dispose(), !0);
+ }, r.prototype.dispose = function() {
+ var t = this;
+ this.getEnabledFeatures().forEach(function(e) {
+ t.disableFeature(e), t._features[e].featureImplementation.dispose();
+ });
+ }, r.prototype.enableFeature = function(t, e, n, i, o) {
+ var a = this;
+ e === void 0 && (e = "latest"), n === void 0 && (n = {}), i === void 0 && (i = !0), o === void 0 && (o = !0);
+ var s = typeof t == "string" ? t : t.Name, d = 0;
+ if (typeof e == "string") {
+ if (!e)
+ throw new Error("Error in provided version - " + s + " (" + e + ")");
+ if ((d = e === "stable" ? r.GetStableVersionOfFeature(s) : e === "latest" ? r.GetLatestVersionOfFeature(s) : +e) === -1 || isNaN(d))
+ throw new Error("feature not found - " + s + " (" + e + ")");
+ } else
+ d = e;
+ var p = this._features[s], y = r.ConstructFeature(s, d, this._xrSessionManager, n);
+ if (!y)
+ throw new Error("feature not found - " + s);
+ p && this.disableFeature(s);
+ var P = y();
+ if (P.dependsOn && !P.dependsOn.every(function(R) {
+ return !!a._features[R];
+ }))
+ throw new Error("Dependant features missing. Make sure the following features are enabled - " + P.dependsOn.join(", "));
+ if (P.isCompatible())
+ return this._features[s] = { featureImplementation: P, enabled: !0, version: d, required: o }, i ? this._xrSessionManager.session && !this._features[s].featureImplementation.attached && this.attachFeature(s) : this._features[s].featureImplementation.disableAutoAttach = !0, this._features[s].featureImplementation;
+ if (o)
+ throw new Error("required feature not compatible");
+ return Xe.b.Warn("Feature " + s + " not compatible with the current environment/browser and was not enabled."), P;
+ }, r.prototype.getEnabledFeature = function(t) {
+ return this._features[t] && this._features[t].featureImplementation;
+ }, r.prototype.getEnabledFeatures = function() {
+ return Object.keys(this._features);
+ }, r.prototype.extendXRSessionInitObject = function(t) {
+ var e = this;
+ return this.getEnabledFeatures().forEach(function(n) {
+ var i = e._features[n], o = i.featureImplementation.xrNativeFeatureName;
+ o && (i.required ? (t.requiredFeatures = t.requiredFeatures || [], t.requiredFeatures.indexOf(o) === -1 && t.requiredFeatures.push(o)) : (t.optionalFeatures = t.optionalFeatures || [], t.optionalFeatures.indexOf(o) === -1 && t.optionalFeatures.push(o)));
+ }), t;
+ }, r._AvailableFeatures = {}, r;
+ }(), ru = function() {
+ function r(t) {
+ var e = this;
+ this.scene = t, this._nonVRCamera = null, this._originalSceneAutoClear = !0, this._supported = !1, this.onInitialXRPoseSetObservable = new C.c(), this.onStateChangedObservable = new C.c(), this.state = fn.NOT_IN_XR, this.sessionManager = new rs(t), this.camera = new iu("", t, this.sessionManager), this.featuresManager = new Wn(this.sessionManager), t.onDisposeObservable.add(function() {
+ e.exitXRAsync();
+ });
+ }
+ return r.CreateAsync = function(t) {
+ var e = new r(t);
+ return e.sessionManager.initializeAsync().then(function() {
+ return e._supported = !0, e;
+ }).catch(function(n) {
+ throw e._setState(fn.NOT_IN_XR), e.dispose(), n;
+ });
+ }, r.prototype.dispose = function() {
+ this.camera.dispose(), this.onStateChangedObservable.clear(), this.onInitialXRPoseSetObservable.clear(), this.sessionManager.dispose(), this._nonVRCamera && (this.scene.activeCamera = this._nonVRCamera);
+ }, r.prototype.enterXRAsync = function(t, e, n, i) {
+ var o = this;
+ if (n === void 0 && (n = this.sessionManager.getWebXRRenderTarget()), i === void 0 && (i = {}), !this._supported)
+ throw "WebXR not supported in this browser or environment";
+ return this._setState(fn.ENTERING_XR), e !== "viewer" && e !== "local" && (i.optionalFeatures = i.optionalFeatures || [], i.optionalFeatures.push(e)), this.featuresManager.extendXRSessionInitObject(i), t === "immersive-ar" && e !== "unbounded" && l.a.Warn("We recommend using 'unbounded' reference space type when using 'immersive-ar' session mode"), this.sessionManager.initializeSessionAsync(t, i).then(function() {
+ return o.sessionManager.setReferenceSpaceTypeAsync(e);
+ }).then(function() {
+ return n.initializeXRLayerAsync(o.sessionManager.session);
+ }).then(function() {
+ return o.sessionManager.updateRenderStateAsync({ depthFar: o.camera.maxZ, depthNear: o.camera.minZ, baseLayer: n.xrLayer });
+ }).then(function() {
+ return o.sessionManager.runXRRenderLoop(), o._originalSceneAutoClear = o.scene.autoClear, o._nonVRCamera = o.scene.activeCamera, o.scene.activeCamera = o.camera, t !== "immersive-ar" ? o._nonXRToXRCamera() : (o.scene.autoClear = !1, o.camera.compensateOnFirstFrame = !1), o.sessionManager.onXRSessionEnded.addOnce(function() {
+ o.camera.rigCameras.forEach(function(a) {
+ a.outputRenderTarget = null;
+ }), o.scene.autoClear = o._originalSceneAutoClear, o.scene.activeCamera = o._nonVRCamera, t !== "immersive-ar" && o.camera.compensateOnFirstFrame && (o._nonVRCamera.setPosition ? o._nonVRCamera.setPosition(o.camera.position) : o._nonVRCamera.position.copyFrom(o.camera.position)), o._setState(fn.NOT_IN_XR);
+ }), o.sessionManager.onXRFrameObservable.addOnce(function() {
+ o._setState(fn.IN_XR);
+ }), o.sessionManager;
+ }).catch(function(a) {
+ throw console.log(a), console.log(a.message), o._setState(fn.NOT_IN_XR), a;
+ });
+ }, r.prototype.exitXRAsync = function() {
+ return this.state !== fn.IN_XR ? Promise.resolve() : (this._setState(fn.EXITING_XR), this.sessionManager.exitXRAsync());
+ }, r.prototype._nonXRToXRCamera = function() {
+ this.camera.setTransformationFromNonVRCamera(this._nonVRCamera), this.onInitialXRPoseSetObservable.notifyObservers(this.camera);
+ }, r.prototype._setState = function(t) {
+ this.state !== t && (this.state = t, this.onStateChangedObservable.notifyObservers(this.state));
+ }, r;
+ }(), yr = function() {
+ function r(t, e, n, i) {
+ n === void 0 && (n = -1), i === void 0 && (i = []), this.id = t, this.type = e, this._buttonIndex = n, this._axesIndices = i, this._axes = { x: 0, y: 0 }, this._changes = {}, this._currentValue = 0, this._hasChanges = !1, this._pressed = !1, this._touched = !1, this.onAxisValueChangedObservable = new C.c(), this.onButtonStateChangedObservable = new C.c();
+ }
+ return Object.defineProperty(r.prototype, "axes", { get: function() {
+ return this._axes;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "changes", { get: function() {
+ return this._changes;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "hasChanges", { get: function() {
+ return this._hasChanges;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "pressed", { get: function() {
+ return this._pressed;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "touched", { get: function() {
+ return this._touched;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "value", { get: function() {
+ return this._currentValue;
+ }, enumerable: !1, configurable: !0 }), r.prototype.dispose = function() {
+ this.onAxisValueChangedObservable.clear(), this.onButtonStateChangedObservable.clear();
+ }, r.prototype.isAxes = function() {
+ return this._axesIndices.length !== 0;
+ }, r.prototype.isButton = function() {
+ return this._buttonIndex !== -1;
+ }, r.prototype.update = function(t) {
+ var e = !1, n = !1;
+ if (this._hasChanges = !1, this._changes = {}, this.isButton()) {
+ var i = t.buttons[this._buttonIndex];
+ if (!i)
+ return;
+ this._currentValue !== i.value && (this.changes.value = { current: i.value, previous: this._currentValue }, e = !0, this._currentValue = i.value), this._touched !== i.touched && (this.changes.touched = { current: i.touched, previous: this._touched }, e = !0, this._touched = i.touched), this._pressed !== i.pressed && (this.changes.pressed = { current: i.pressed, previous: this._pressed }, e = !0, this._pressed = i.pressed);
+ }
+ this.isAxes() && (this._axes.x !== t.axes[this._axesIndices[0]] && (this.changes.axes = { current: { x: t.axes[this._axesIndices[0]], y: this._axes.y }, previous: { x: this._axes.x, y: this._axes.y } }, this._axes.x = t.axes[this._axesIndices[0]], n = !0), this._axes.y !== t.axes[this._axesIndices[1]] && (this.changes.axes ? this.changes.axes.current.y = t.axes[this._axesIndices[1]] : this.changes.axes = { current: { x: this._axes.x, y: t.axes[this._axesIndices[1]] }, previous: { x: this._axes.x, y: this._axes.y } }, this._axes.y = t.axes[this._axesIndices[1]], n = !0)), e && (this._hasChanges = !0, this.onButtonStateChangedObservable.notifyObservers(this)), n && (this._hasChanges = !0, this.onAxisValueChangedObservable.notifyObservers(this._axes));
+ }, r.BUTTON_TYPE = "button", r.SQUEEZE_TYPE = "squeeze", r.THUMBSTICK_TYPE = "thumbstick", r.TOUCHPAD_TYPE = "touchpad", r.TRIGGER_TYPE = "trigger", r;
+ }(), br = function() {
+ function r(t, e, n, i, o) {
+ var a = this;
+ this.scene = t, this.layout = e, this.gamepadObject = n, this.handedness = i, this._initComponent = function(s) {
+ if (s) {
+ var d = a.layout.components[s], p = d.type, y = d.gamepadIndices.button, P = [];
+ d.gamepadIndices.xAxis !== void 0 && d.gamepadIndices.yAxis !== void 0 && P.push(d.gamepadIndices.xAxis, d.gamepadIndices.yAxis), a.components[s] = new yr(s, p, y, P);
+ }
+ }, this._modelReady = !1, this.components = {}, this.disableAnimation = !1, this.onModelLoadedObservable = new C.c(), e.components && Object.keys(e.components).forEach(this._initComponent);
+ }
+ return r.prototype.dispose = function() {
+ var t = this;
+ this.getComponentIds().forEach(function(e) {
+ return t.getComponent(e).dispose();
+ }), this.rootMesh && this.rootMesh.dispose();
+ }, r.prototype.getAllComponentsOfType = function(t) {
+ var e = this;
+ return this.getComponentIds().map(function(n) {
+ return e.components[n];
+ }).filter(function(n) {
+ return n.type === t;
+ });
+ }, r.prototype.getComponent = function(t) {
+ return this.components[t];
+ }, r.prototype.getComponentIds = function() {
+ return Object.keys(this.components);
+ }, r.prototype.getComponentOfType = function(t) {
+ return this.getAllComponentsOfType(t)[0] || null;
+ }, r.prototype.getMainComponent = function() {
+ return this.getComponent(this.layout.selectComponentId);
+ }, r.prototype.loadModel = function() {
+ return Object(c.b)(this, void 0, void 0, function() {
+ var t, e, n = this;
+ return Object(c.e)(this, function(i) {
+ return t = !this._getModelLoadingConstraints(), e = this._getGenericFilenameAndPath(), t ? l.a.Warn("Falling back to generic models") : e = this._getFilenameAndPath(), [2, new Promise(function(o, a) {
+ Ft.ImportMesh("", e.path, e.filename, n.scene, function(s) {
+ t ? n._getGenericParentMesh(s) : n._setRootMesh(s), n._processLoadedModel(s), n._modelReady = !0, n.onModelLoadedObservable.notifyObservers(n), o(!0);
+ }, null, function(s, d) {
+ l.a.Log(d), l.a.Warn("Failed to retrieve controller model of type " + n.profileId + " from the remote server: " + e.path + e.filename), a(d);
+ });
+ })];
+ });
+ });
+ }, r.prototype.updateFromXRFrame = function(t) {
+ var e = this;
+ this.getComponentIds().forEach(function(n) {
+ return e.getComponent(n).update(e.gamepadObject);
+ }), this.updateModel(t);
+ }, Object.defineProperty(r.prototype, "handness", { get: function() {
+ return this.handedness;
+ }, enumerable: !1, configurable: !0 }), r.prototype.pulse = function(t, e, n) {
+ return n === void 0 && (n = 0), this.gamepadObject.hapticActuators && this.gamepadObject.hapticActuators[n] ? this.gamepadObject.hapticActuators[n].pulse(t, e) : Promise.resolve(!1);
+ }, r.prototype._getChildByName = function(t, e) {
+ return t.getChildren(function(n) {
+ return n.name === e;
+ }, !1)[0];
+ }, r.prototype._getImmediateChildByName = function(t, e) {
+ return t.getChildren(function(n) {
+ return n.name == e;
+ }, !0)[0];
+ }, r.prototype._lerpTransform = function(t, e, n) {
+ if (t.minMesh && t.maxMesh && t.valueMesh && t.minMesh.rotationQuaternion && t.maxMesh.rotationQuaternion && t.valueMesh.rotationQuaternion) {
+ var i = n ? 0.5 * e + 0.5 : e;
+ u.b.SlerpToRef(t.minMesh.rotationQuaternion, t.maxMesh.rotationQuaternion, i, t.valueMesh.rotationQuaternion), u.e.LerpToRef(t.minMesh.position, t.maxMesh.position, i, t.valueMesh.position);
+ }
+ }, r.prototype.updateModel = function(t) {
+ this._modelReady && this._updateModel(t);
+ }, r.prototype._getGenericFilenameAndPath = function() {
+ return { filename: "generic.babylon", path: "https://controllers.babylonjs.com/generic/" };
+ }, r.prototype._getGenericParentMesh = function(t) {
+ var e = this;
+ this.rootMesh = new Ie.a(this.profileId + " " + this.handedness, this.scene), t.forEach(function(n) {
+ n.parent || (n.isPickable = !1, n.setParent(e.rootMesh));
+ }), this.rootMesh.rotationQuaternion = u.b.FromEulerAngles(0, Math.PI, 0);
+ }, r;
+ }(), Rs = function(r) {
+ function t(e, n, i) {
+ var o = r.call(this, e, Wp[i], n, i) || this;
+ return o.profileId = t.ProfileId, o;
+ }
+ return Object(c.d)(t, r), t.prototype._getFilenameAndPath = function() {
+ return { filename: "generic.babylon", path: "https://controllers.babylonjs.com/generic/" };
+ }, t.prototype._getModelLoadingConstraints = function() {
+ return !0;
+ }, t.prototype._processLoadedModel = function(e) {
+ }, t.prototype._setRootMesh = function(e) {
+ var n = this;
+ this.rootMesh = new Ie.a(this.profileId + " " + this.handedness, this.scene), e.forEach(function(i) {
+ i.isPickable = !1, i.parent || i.setParent(n.rootMesh);
+ }), this.rootMesh.rotationQuaternion = u.b.FromEulerAngles(0, Math.PI, 0);
+ }, t.prototype._updateModel = function() {
+ }, t.ProfileId = "generic-trigger", t;
+ }(br), Wp = { left: { selectComponentId: "xr-standard-trigger", components: { "xr-standard-trigger": { type: "trigger", gamepadIndices: { button: 0 }, rootNodeName: "xr_standard_trigger", visualResponses: {} } }, gamepadMapping: "xr-standard", rootNodeName: "generic-trigger-left", assetPath: "left.glb" }, right: { selectComponentId: "xr-standard-trigger", components: { "xr-standard-trigger": { type: "trigger", gamepadIndices: { button: 0 }, rootNodeName: "xr_standard_trigger", visualResponses: {} } }, gamepadMapping: "xr-standard", rootNodeName: "generic-trigger-right", assetPath: "right.glb" }, none: { selectComponentId: "xr-standard-trigger", components: { "xr-standard-trigger": { type: "trigger", gamepadIndices: { button: 0 }, rootNodeName: "xr_standard_trigger", visualResponses: {} } }, gamepadMapping: "xr-standard", rootNodeName: "generic-trigger-none", assetPath: "none.glb" } }, ou = function(r) {
+ function t(e, n, i, o) {
+ var a = r.call(this, e, i.layouts[n.handedness || "none"], n.gamepad, n.handedness) || this;
+ return a._repositoryUrl = o, a._buttonMeshMapping = {}, a._touchDots = {}, a.profileId = i.profileId, a;
+ }
+ return Object(c.d)(t, r), t.prototype.dispose = function() {
+ var e = this;
+ r.prototype.dispose.call(this), Object.keys(this._touchDots).forEach(function(n) {
+ e._touchDots[n].dispose();
+ });
+ }, t.prototype._getFilenameAndPath = function() {
+ return { filename: this.layout.assetPath, path: this._repositoryUrl + "/profiles/" + this.profileId + "/" };
+ }, t.prototype._getModelLoadingConstraints = function() {
+ var e = Ft.IsPluginForExtensionAvailable(".glb");
+ return e || l.a.Warn("glTF / glb loaded was not registered, using generic controller instead"), e;
+ }, t.prototype._processLoadedModel = function(e) {
+ var n = this;
+ this.getComponentIds().forEach(function(i) {
+ var o = n.layout.components[i];
+ n._buttonMeshMapping[i] = { mainMesh: n._getChildByName(n.rootMesh, o.rootNodeName), states: {} }, Object.keys(o.visualResponses).forEach(function(a) {
+ var s = o.visualResponses[a];
+ if (s.valueNodeProperty === "transform")
+ n._buttonMeshMapping[i].states[a] = { valueMesh: n._getChildByName(n.rootMesh, s.valueNodeName), minMesh: n._getChildByName(n.rootMesh, s.minNodeName), maxMesh: n._getChildByName(n.rootMesh, s.maxNodeName) };
+ else {
+ var d = o.type === yr.TOUCHPAD_TYPE && o.touchPointNodeName ? o.touchPointNodeName : s.valueNodeName;
+ if (n._buttonMeshMapping[i].states[a] = { valueMesh: n._getChildByName(n.rootMesh, d) }, o.type === yr.TOUCHPAD_TYPE && !n._touchDots[a]) {
+ var p = Nn.a.CreateSphere(a + "dot", { diameter: 15e-4, segments: 8 }, n.scene);
+ p.material = new Nt.a(a + "mat", n.scene), p.material.diffuseColor = I.a.Red(), p.parent = n._buttonMeshMapping[i].states[a].valueMesh || null, p.isVisible = !1, n._touchDots[a] = p;
+ }
+ }
+ });
+ });
+ }, t.prototype._setRootMesh = function(e) {
+ var n;
+ this.rootMesh = new Ie.a(this.profileId + "-" + this.handedness, this.scene), this.rootMesh.isPickable = !1;
+ for (var i = 0; i < e.length; i++) {
+ var o = e[i];
+ o.isPickable = !1, o.parent || (n = o);
+ }
+ n && n.setParent(this.rootMesh), this.scene.useRightHandedSystem || this.rootMesh.rotate(be.a.Y, Math.PI, be.c.WORLD);
+ }, t.prototype._updateModel = function(e) {
+ var n = this;
+ this.disableAnimation || this.getComponentIds().forEach(function(i) {
+ var o = n.getComponent(i);
+ if (o.hasChanges) {
+ var a = n._buttonMeshMapping[i], s = n.layout.components[i];
+ Object.keys(s.visualResponses).forEach(function(d) {
+ var p = s.visualResponses[d], y = o.value;
+ if (p.componentProperty === "xAxis" ? y = o.axes.x : p.componentProperty === "yAxis" && (y = o.axes.y), p.valueNodeProperty === "transform")
+ n._lerpTransform(a.states[d], y, p.componentProperty !== "button");
+ else {
+ var P = a.states[d].valueMesh;
+ P && (P.isVisible = o.touched || o.pressed), n._touchDots[d] && (n._touchDots[d].isVisible = o.touched || o.pressed);
+ }
+ });
+ }
+ });
+ }, t;
+ }(br), wn = function() {
+ function r() {
+ }
+ return r.ClearProfilesCache = function() {
+ this._ProfilesList = null, this._ProfileLoadingPromises = {};
+ }, r.DefaultFallbacks = function() {
+ this.RegisterFallbacksForProfileId("google-daydream", ["generic-touchpad"]), this.RegisterFallbacksForProfileId("htc-vive-focus", ["generic-trigger-touchpad"]), this.RegisterFallbacksForProfileId("htc-vive", ["generic-trigger-squeeze-touchpad"]), this.RegisterFallbacksForProfileId("magicleap-one", ["generic-trigger-squeeze-touchpad"]), this.RegisterFallbacksForProfileId("windows-mixed-reality", ["generic-trigger-squeeze-touchpad-thumbstick"]), this.RegisterFallbacksForProfileId("microsoft-mixed-reality", ["windows-mixed-reality", "generic-trigger-squeeze-touchpad-thumbstick"]), this.RegisterFallbacksForProfileId("oculus-go", ["generic-trigger-touchpad"]), this.RegisterFallbacksForProfileId("oculus-touch-v2", ["oculus-touch", "generic-trigger-squeeze-thumbstick"]), this.RegisterFallbacksForProfileId("oculus-touch", ["generic-trigger-squeeze-thumbstick"]), this.RegisterFallbacksForProfileId("samsung-gearvr", ["windows-mixed-reality", "generic-trigger-squeeze-touchpad-thumbstick"]), this.RegisterFallbacksForProfileId("samsung-odyssey", ["generic-touchpad"]), this.RegisterFallbacksForProfileId("valve-index", ["generic-trigger-squeeze-touchpad-thumbstick"]);
+ }, r.FindFallbackWithProfileId = function(t) {
+ var e = this._Fallbacks[t] || [];
+ return e.unshift(t), e;
+ }, r.GetMotionControllerWithXRInput = function(t, e, n) {
+ var i = this, o = [];
+ if (n && o.push(n), o.push.apply(o, t.profiles || []), o.length && !o[0] && o.pop(), t.gamepad && t.gamepad.id)
+ switch (t.gamepad.id) {
+ case (t.gamepad.id.match(/oculus touch/gi) ? t.gamepad.id : void 0):
+ o.push("oculus-touch-v2");
+ }
+ var a = o.indexOf("windows-mixed-reality");
+ if (a !== -1 && o.splice(a, 0, "microsoft-mixed-reality"), o.length || o.push("generic-trigger"), this.UseOnlineRepository) {
+ var s = this.PrioritizeOnlineRepository ? this._LoadProfileFromRepository : this._LoadProfilesFromAvailableControllers, d = this.PrioritizeOnlineRepository ? this._LoadProfilesFromAvailableControllers : this._LoadProfileFromRepository;
+ return s.call(this, o, t, e).catch(function() {
+ return d.call(i, o, t, e);
+ });
+ }
+ return this._LoadProfilesFromAvailableControllers(o, t, e);
+ }, r.RegisterController = function(t, e) {
+ this._AvailableControllers[t] = e;
+ }, r.RegisterFallbacksForProfileId = function(t, e) {
+ var n;
+ this._Fallbacks[t] ? (n = this._Fallbacks[t]).push.apply(n, e) : this._Fallbacks[t] = e;
+ }, r.UpdateProfilesList = function() {
+ return this._ProfilesList = Xe.b.LoadFileAsync(this.BaseRepositoryUrl + "/profiles/profilesList.json", !1).then(function(t) {
+ return JSON.parse(t.toString());
+ }), this._ProfilesList;
+ }, r._LoadProfileFromRepository = function(t, e, n) {
+ var i = this;
+ return Promise.resolve().then(function() {
+ return i._ProfilesList ? i._ProfilesList : i.UpdateProfilesList();
+ }).then(function(o) {
+ for (var a = 0; a < t.length; ++a)
+ if (t[a] && o[t[a]])
+ return t[a];
+ throw new Error("neither controller " + t[0] + " nor all fallbacks were found in the repository,");
+ }).then(function(o) {
+ return i._ProfileLoadingPromises[o] || (i._ProfileLoadingPromises[o] = Xe.b.LoadFileAsync(i.BaseRepositoryUrl + "/profiles/" + o + "/profile.json", !1).then(function(a) {
+ return JSON.parse(a);
+ })), i._ProfileLoadingPromises[o];
+ }).then(function(o) {
+ return new ou(n, e, o, i.BaseRepositoryUrl);
+ });
+ }, r._LoadProfilesFromAvailableControllers = function(t, e, n) {
+ for (var i = 0; i < t.length; ++i)
+ if (t[i])
+ for (var o = this.FindFallbackWithProfileId(t[i]), a = 0; a < o.length; ++a) {
+ var s = this._AvailableControllers[o[a]];
+ if (s)
+ return Promise.resolve(s(e, n));
+ }
+ throw new Error("no controller requested was found in the available controllers list");
+ }, r._AvailableControllers = {}, r._Fallbacks = {}, r._ProfileLoadingPromises = {}, r.BaseRepositoryUrl = "https://immersive-web.github.io/webxr-input-profiles/packages/viewer/dist", r.PrioritizeOnlineRepository = !0, r.UseOnlineRepository = !0, r;
+ }();
+ wn.RegisterController(Rs.ProfileId, function(r, t) {
+ return new Rs(t, r.gamepad, r.handedness);
+ }), wn.DefaultFallbacks();
+ var Xp = 0, au = function() {
+ function r(t, e, n) {
+ var i = this;
+ n === void 0 && (n = {}), this._scene = t, this.inputSource = e, this._options = n, this._tmpVector = new u.e(), this._disposed = !1, this.onDisposeObservable = new C.c(), this.onMeshLoadedObservable = new C.c(), this.onMotionControllerInitObservable = new C.c(), this._uniqueId = "controller-" + Xp++ + "-" + e.targetRayMode + "-" + e.handedness, this.pointer = new Mt.a(this._uniqueId + "-pointer", t), this.pointer.rotationQuaternion = new u.b(), this.inputSource.gripSpace && (this.grip = new Mt.a(this._uniqueId + "-grip", this._scene), this.grip.rotationQuaternion = new u.b()), this._tmpVector.set(0, 0, this._scene.useRightHandedSystem ? -1 : 1), this.inputSource.gamepad && wn.GetMotionControllerWithXRInput(e, t, this._options.forceControllerProfile).then(function(o) {
+ i.motionController = o, i.onMotionControllerInitObservable.notifyObservers(o), i._options.doNotLoadControllerMesh || i.motionController.loadModel().then(function(a) {
+ var s;
+ a && i.motionController && i.motionController.rootMesh && (i._options.renderingGroupId && (i.motionController.rootMesh.renderingGroupId = i._options.renderingGroupId, i.motionController.rootMesh.getChildMeshes(!1).forEach(function(d) {
+ return d.renderingGroupId = i._options.renderingGroupId;
+ })), i.onMeshLoadedObservable.notifyObservers(i.motionController.rootMesh), i.motionController.rootMesh.parent = i.grip || i.pointer, i.motionController.disableAnimation = !!i._options.disableMotionControllerAnimation), i._disposed && ((s = i.motionController) === null || s === void 0 || s.dispose());
+ });
+ }, function() {
+ Xe.b.Warn("Could not find a matching motion controller for the registered input source");
+ });
+ }
+ return Object.defineProperty(r.prototype, "uniqueId", { get: function() {
+ return this._uniqueId;
+ }, enumerable: !1, configurable: !0 }), r.prototype.dispose = function() {
+ this.grip && this.grip.dispose(), this.motionController && this.motionController.dispose(), this.pointer.dispose(), this.onMotionControllerInitObservable.clear(), this.onMeshLoadedObservable.clear(), this.onDisposeObservable.notifyObservers(this), this.onDisposeObservable.clear(), this._disposed = !0;
+ }, r.prototype.getWorldPointerRayToRef = function(t, e) {
+ e === void 0 && (e = !1);
+ var n = e && this.grip ? this.grip : this.pointer;
+ u.e.TransformNormalToRef(this._tmpVector, n.getWorldMatrix(), t.direction), t.direction.normalize(), t.origin.copyFrom(n.absolutePosition), t.length = 1e3;
+ }, r.prototype.updateFromXRFrame = function(t, e) {
+ var n = t.getPose(this.inputSource.targetRaySpace, e);
+ if (n) {
+ var i = n.transform.position;
+ this.pointer.position.set(i.x, i.y, i.z);
+ var o = n.transform.orientation;
+ this.pointer.rotationQuaternion.set(o.x, o.y, o.z, o.w), this._scene.useRightHandedSystem || (this.pointer.position.z *= -1, this.pointer.rotationQuaternion.z *= -1, this.pointer.rotationQuaternion.w *= -1);
+ }
+ if (this.inputSource.gripSpace && this.grip) {
+ var a = t.getPose(this.inputSource.gripSpace, e);
+ if (a) {
+ i = a.transform.position;
+ var s = a.transform.orientation;
+ this.grip.position.set(i.x, i.y, i.z), this.grip.rotationQuaternion.set(s.x, s.y, s.z, s.w), this._scene.useRightHandedSystem || (this.grip.position.z *= -1, this.grip.rotationQuaternion.z *= -1, this.grip.rotationQuaternion.w *= -1);
+ }
+ }
+ this.motionController && this.motionController.updateFromXRFrame(t);
+ }, r;
+ }(), su = function() {
+ function r(t, e, n) {
+ var i = this;
+ if (n === void 0 && (n = {}), this.xrSessionManager = t, this.xrCamera = e, this.options = n, this.controllers = [], this.onControllerAddedObservable = new C.c(), this.onControllerRemovedObservable = new C.c(), this._onInputSourcesChange = function(o) {
+ i._addAndRemoveControllers(o.added, o.removed);
+ }, this._sessionEndedObserver = this.xrSessionManager.onXRSessionEnded.add(function() {
+ i._addAndRemoveControllers([], i.controllers.map(function(o) {
+ return o.inputSource;
+ }));
+ }), this._sessionInitObserver = this.xrSessionManager.onXRSessionInit.add(function(o) {
+ o.addEventListener("inputsourceschange", i._onInputSourcesChange);
+ }), this._frameObserver = this.xrSessionManager.onXRFrameObservable.add(function(o) {
+ i.controllers.forEach(function(a) {
+ a.updateFromXRFrame(o, i.xrSessionManager.referenceSpace);
+ });
+ }), this.options.customControllersRepositoryURL && (wn.BaseRepositoryUrl = this.options.customControllersRepositoryURL), wn.UseOnlineRepository = !this.options.disableOnlineControllerRepository, wn.UseOnlineRepository)
+ try {
+ wn.UpdateProfilesList().catch(function() {
+ wn.UseOnlineRepository = !1;
+ });
+ } catch {
+ wn.UseOnlineRepository = !1;
+ }
+ }
+ return r.prototype._addAndRemoveControllers = function(t, e) {
+ for (var n = this, i = this.controllers.map(function(P) {
+ return P.inputSource;
+ }), o = 0, a = t; o < a.length; o++) {
+ var s = a[o];
+ if (i.indexOf(s) === -1) {
+ var d = new au(this.xrSessionManager.scene, s, Object(c.a)(Object(c.a)({}, this.options.controllerOptions || {}), { forceControllerProfile: this.options.forceInputProfile, doNotLoadControllerMesh: this.options.doNotLoadControllerMeshes, disableMotionControllerAnimation: this.options.disableControllerAnimation }));
+ this.controllers.push(d), this.onControllerAddedObservable.notifyObservers(d);
+ }
+ }
+ var p = [], y = [];
+ this.controllers.forEach(function(P) {
+ e.indexOf(P.inputSource) === -1 ? p.push(P) : y.push(P);
+ }), this.controllers = p, y.forEach(function(P) {
+ n.onControllerRemovedObservable.notifyObservers(P), P.dispose();
+ });
+ }, r.prototype.dispose = function() {
+ this.controllers.forEach(function(t) {
+ t.dispose();
+ }), this.xrSessionManager.onXRFrameObservable.remove(this._frameObserver), this.xrSessionManager.onXRSessionInit.remove(this._sessionInitObserver), this.xrSessionManager.onXRSessionEnded.remove(this._sessionEndedObserver), this.onControllerAddedObservable.clear(), this.onControllerRemovedObservable.clear();
+ }, r;
+ }(), ni = function() {
+ function r(t) {
+ this._xrSessionManager = t, this._attached = !1, this._removeOnDetach = [], this.isDisposed = !1, this.disableAutoAttach = !1, this.xrNativeFeatureName = "";
+ }
+ return Object.defineProperty(r.prototype, "attached", { get: function() {
+ return this._attached;
+ }, enumerable: !1, configurable: !0 }), r.prototype.attach = function(t) {
+ var e = this;
+ if (this.isDisposed)
+ return !1;
+ if (t)
+ this.attached && this.detach();
+ else if (this.attached)
+ return !1;
+ return this._attached = !0, this._addNewAttachObserver(this._xrSessionManager.onXRFrameObservable, function(n) {
+ return e._onXRFrame(n);
+ }), !0;
+ }, r.prototype.detach = function() {
+ return this._attached ? (this._attached = !1, this._removeOnDetach.forEach(function(t) {
+ t.observable.remove(t.observer);
+ }), !0) : (this.disableAutoAttach = !0, !1);
+ }, r.prototype.dispose = function() {
+ this.detach(), this.isDisposed = !0;
+ }, r.prototype.isCompatible = function() {
+ return !0;
+ }, r.prototype._addNewAttachObserver = function(t, e) {
+ this._removeOnDetach.push({ observable: t, observer: t.add(e) });
+ }, r;
+ }(), eo = function(r) {
+ function t(e, n) {
+ var i = r.call(this, e) || this;
+ return i._options = n, i._attachController = function(o) {
+ if (!i._controllers[o.uniqueId]) {
+ var a = i._generateNewMeshPair(o.pointer), s = a.laserPointer, d = a.selectionMesh;
+ switch (i._controllers[o.uniqueId] = { xrController: o, laserPointer: s, selectionMesh: d, meshUnderPointer: null, pick: null, tmpRay: new dn.a(new u.e(), new u.e()), id: t._idCounter++ }, i._attachedController ? !i._options.enablePointerSelectionOnAllControllers && i._options.preferredHandedness && o.inputSource.handedness === i._options.preferredHandedness && (i._attachedController = o.uniqueId) : i._options.enablePointerSelectionOnAllControllers || (i._attachedController = o.uniqueId), o.inputSource.targetRayMode) {
+ case "tracked-pointer":
+ return i._attachTrackedPointerRayMode(o);
+ case "gaze":
+ return i._attachGazeMode(o);
+ case "screen":
+ return i._attachScreenRayMode(o);
+ }
+ }
+ }, i._controllers = {}, i._tmpVectorForPickCompare = new u.e(), i.disablePointerLighting = !0, i.disableSelectionMeshLighting = !0, i.displayLaserPointer = !0, i.displaySelectionMesh = !0, i.laserPointerPickedColor = new I.a(0.9, 0.9, 0.9), i.laserPointerDefaultColor = new I.a(0.7, 0.7, 0.7), i.selectionMeshDefaultColor = new I.a(0.8, 0.8, 0.8), i.selectionMeshPickedColor = new I.a(0.3, 0.3, 1), i._identityMatrix = u.a.Identity(), i._screenCoordinatesRef = u.e.Zero(), i._viewportRef = new jn.a(0, 0, 0, 0), i._scene = i._xrSessionManager.scene, i;
+ }
+ return Object(c.d)(t, r), t.prototype.attach = function() {
+ var e = this;
+ if (!r.prototype.attach.call(this))
+ return !1;
+ if (this._options.xrInput.controllers.forEach(this._attachController), this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable, this._attachController), this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable, function(s) {
+ e._detachController(s.uniqueId);
+ }), this._scene.constantlyUpdateMeshUnderPointer = !0, this._options.gazeCamera) {
+ var n = this._options.gazeCamera, i = this._generateNewMeshPair(n), o = i.laserPointer, a = i.selectionMesh;
+ this._controllers.camera = { webXRCamera: n, laserPointer: o, selectionMesh: a, meshUnderPointer: null, pick: null, tmpRay: new dn.a(new u.e(), new u.e()), id: t._idCounter++ }, this._attachGazeMode();
+ }
+ return !0;
+ }, t.prototype.detach = function() {
+ var e = this;
+ return !!r.prototype.detach.call(this) && (Object.keys(this._controllers).forEach(function(n) {
+ e._detachController(n);
+ }), !0);
+ }, t.prototype.getMeshUnderPointer = function(e) {
+ return this._controllers[e] ? this._controllers[e].meshUnderPointer : null;
+ }, t.prototype.getXRControllerByPointerId = function(e) {
+ for (var n = Object.keys(this._controllers), i = 0; i < n.length; ++i)
+ if (this._controllers[n[i]].id === e)
+ return this._controllers[n[i]].xrController || null;
+ return null;
+ }, t.prototype._onXRFrame = function(e) {
+ var n = this;
+ Object.keys(this._controllers).forEach(function(i) {
+ var o, a = n._controllers[i];
+ if (!n._options.enablePointerSelectionOnAllControllers && i !== n._attachedController)
+ return a.selectionMesh.isVisible = !1, a.laserPointer.isVisible = !1, void (a.pick = null);
+ if (a.laserPointer.isVisible = n.displayLaserPointer, a.xrController)
+ o = a.xrController.pointer.position, a.xrController.getWorldPointerRayToRef(a.tmpRay);
+ else {
+ if (!a.webXRCamera)
+ return;
+ o = a.webXRCamera.position, a.webXRCamera.getForwardRayToRef(a.tmpRay);
+ }
+ if (n._options.maxPointerDistance && (a.tmpRay.length = n._options.maxPointerDistance), !n._options.disableScenePointerVectorUpdate && o) {
+ var s = n._xrSessionManager.scene, d = n._options.xrInput.xrCamera;
+ d && (d.viewport.toGlobalToRef(s.getEngine().getRenderWidth(), s.getEngine().getRenderHeight(), n._viewportRef), u.e.ProjectToRef(o, n._identityMatrix, s.getTransformMatrix(), n._viewportRef, n._screenCoordinatesRef), s.pointerX = n._screenCoordinatesRef.x, s.pointerY = n._screenCoordinatesRef.y);
+ }
+ a.pick = n._scene.pickWithRay(a.tmpRay, n._scene.pointerMovePredicate || n.raySelectionPredicate);
+ var p = a.pick;
+ if (p && p.pickedPoint && p.hit) {
+ n._updatePointerDistance(a.laserPointer, p.distance), a.selectionMesh.position.copyFrom(p.pickedPoint), a.selectionMesh.scaling.x = Math.sqrt(p.distance), a.selectionMesh.scaling.y = Math.sqrt(p.distance), a.selectionMesh.scaling.z = Math.sqrt(p.distance);
+ var y = n._convertNormalToDirectionOfRay(p.getNormal(!0), a.tmpRay);
+ if (a.selectionMesh.position.copyFrom(p.pickedPoint), y) {
+ var P = u.e.Cross(be.a.Y, y), R = u.e.Cross(y, P);
+ u.e.RotationFromAxisToRef(R, y, P, a.selectionMesh.rotation), a.selectionMesh.position.addInPlace(y.scale(1e-3));
+ }
+ a.selectionMesh.isVisible = n.displaySelectionMesh, a.meshUnderPointer = p.pickedMesh;
+ } else
+ a.selectionMesh.isVisible = !1, n._updatePointerDistance(a.laserPointer, 1), a.meshUnderPointer = null;
+ });
+ }, t.prototype._attachGazeMode = function(e) {
+ var n = this, i = this._controllers[e && e.uniqueId || "camera"], o = this._options.timeToSelect || 3e3, a = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || Cn.a.DefaultUtilityLayer.utilityLayerScene : this._scene, s = new Yi.a(), d = lr.CreateTorus("selection", { diameter: 0.0525, thickness: 0.015, tessellation: 20 }, a);
+ d.isVisible = !1, d.isPickable = !1, d.parent = i.selectionMesh;
+ var p = 0, y = !1;
+ i.onFrameObserver = this._xrSessionManager.onXRFrameObservable.add(function() {
+ if (i.pick) {
+ if (i.laserPointer.material.alpha = 0, d.isVisible = !1, i.pick.hit)
+ if (n._pickingMoved(s, i.pick))
+ y && (n._options.disablePointerUpOnTouchOut || n._scene.simulatePointerUp(i.pick, { pointerId: i.id })), y = !1, p = 0;
+ else if (p > o / 10 && (d.isVisible = !0), (p += n._scene.getEngine().getDeltaTime()) >= o)
+ n._scene.simulatePointerDown(i.pick, { pointerId: i.id }), y = !0, n._options.disablePointerUpOnTouchOut && n._scene.simulatePointerUp(i.pick, { pointerId: i.id }), d.isVisible = !1;
+ else {
+ var P = 1 - p / o;
+ d.scaling.set(P, P, P);
+ }
+ else
+ y = !1, p = 0;
+ n._scene.simulatePointerMove(i.pick, { pointerId: i.id }), s = i.pick;
+ }
+ }), this._options.renderingGroupId !== void 0 && (d.renderingGroupId = this._options.renderingGroupId), e && e.onDisposeObservable.addOnce(function() {
+ i.pick && !n._options.disablePointerUpOnTouchOut && y && n._scene.simulatePointerUp(i.pick, { pointerId: i.id }), d.dispose();
+ });
+ }, t.prototype._attachScreenRayMode = function(e) {
+ var n = this, i = this._controllers[e.uniqueId], o = !1;
+ i.onFrameObserver = this._xrSessionManager.onXRFrameObservable.add(function() {
+ !i.pick || n._options.disablePointerUpOnTouchOut && o || (o ? n._scene.simulatePointerMove(i.pick, { pointerId: i.id }) : (n._scene.simulatePointerDown(i.pick, { pointerId: i.id }), o = !0, n._options.disablePointerUpOnTouchOut && n._scene.simulatePointerUp(i.pick, { pointerId: i.id })));
+ }), e.onDisposeObservable.addOnce(function() {
+ i.pick && o && !n._options.disablePointerUpOnTouchOut && n._scene.simulatePointerUp(i.pick, { pointerId: i.id });
+ });
+ }, t.prototype._attachTrackedPointerRayMode = function(e) {
+ var n = this, i = this._controllers[e.uniqueId];
+ if (this._options.forceGazeMode)
+ return this._attachGazeMode(e);
+ if (i.onFrameObserver = this._xrSessionManager.onXRFrameObservable.add(function() {
+ i.laserPointer.material.disableLighting = n.disablePointerLighting, i.selectionMesh.material.disableLighting = n.disableSelectionMeshLighting, i.pick && n._scene.simulatePointerMove(i.pick, { pointerId: i.id });
+ }), e.inputSource.gamepad) {
+ var o = function(d) {
+ n._options.overrideButtonId && (i.selectionComponent = d.getComponent(n._options.overrideButtonId)), i.selectionComponent || (i.selectionComponent = d.getMainComponent()), i.onButtonChangedObserver = i.selectionComponent.onButtonStateChangedObservable.add(function(p) {
+ if (p.changes.pressed) {
+ var y = p.changes.pressed.current;
+ i.pick ? (n._options.enablePointerSelectionOnAllControllers || e.uniqueId === n._attachedController) && (y ? (n._scene.simulatePointerDown(i.pick, { pointerId: i.id }), i.selectionMesh.material.emissiveColor = n.selectionMeshPickedColor, i.laserPointer.material.emissiveColor = n.laserPointerPickedColor) : (n._scene.simulatePointerUp(i.pick, { pointerId: i.id }), i.selectionMesh.material.emissiveColor = n.selectionMeshDefaultColor, i.laserPointer.material.emissiveColor = n.laserPointerDefaultColor)) : !y || n._options.enablePointerSelectionOnAllControllers || n._options.disableSwitchOnClick || (n._attachedController = e.uniqueId);
+ }
+ });
+ };
+ e.motionController ? o(e.motionController) : e.onMotionControllerInitObservable.add(o);
+ } else {
+ var a = function(d) {
+ i.xrController && d.inputSource === i.xrController.inputSource && i.pick && (n._scene.simulatePointerDown(i.pick, { pointerId: i.id }), i.selectionMesh.material.emissiveColor = n.selectionMeshPickedColor, i.laserPointer.material.emissiveColor = n.laserPointerPickedColor);
+ }, s = function(d) {
+ i.xrController && d.inputSource === i.xrController.inputSource && i.pick && (n._scene.simulatePointerUp(i.pick, { pointerId: i.id }), i.selectionMesh.material.emissiveColor = n.selectionMeshDefaultColor, i.laserPointer.material.emissiveColor = n.laserPointerDefaultColor);
+ };
+ i.eventListeners = { selectend: s, selectstart: a }, this._xrSessionManager.session.addEventListener("selectstart", a), this._xrSessionManager.session.addEventListener("selectend", s);
+ }
+ }, t.prototype._convertNormalToDirectionOfRay = function(e, n) {
+ return e && Math.acos(u.e.Dot(e, n.direction)) < Math.PI / 2 && e.scaleInPlace(-1), e;
+ }, t.prototype._detachController = function(e) {
+ var n = this, i = this._controllers[e];
+ if (i && (i.selectionComponent && i.onButtonChangedObserver && i.selectionComponent.onButtonStateChangedObservable.remove(i.onButtonChangedObserver), i.onFrameObserver && this._xrSessionManager.onXRFrameObservable.remove(i.onFrameObserver), i.eventListeners && Object.keys(i.eventListeners).forEach(function(a) {
+ var s = i.eventListeners && i.eventListeners[a];
+ s && n._xrSessionManager.session.removeEventListener(a, s);
+ }), i.selectionMesh.dispose(), i.laserPointer.dispose(), delete this._controllers[e], this._attachedController === e)) {
+ var o = Object.keys(this._controllers);
+ o.length ? this._attachedController = o[0] : this._attachedController = "";
+ }
+ }, t.prototype._generateNewMeshPair = function(e) {
+ var n = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || Cn.a.DefaultUtilityLayer.utilityLayerScene : this._scene, i = ci.a.CreateCylinder("laserPointer", { height: 1, diameterTop: 2e-4, diameterBottom: 4e-3, tessellation: 20, subdivisions: 1 }, n);
+ i.parent = e;
+ var o = new Nt.a("laserPointerMat", n);
+ o.emissiveColor = this.laserPointerDefaultColor, o.alpha = 0.7, i.material = o, i.rotation.x = Math.PI / 2, this._updatePointerDistance(i, 1), i.isPickable = !1;
+ var a = lr.CreateTorus("gazeTracker", { diameter: 0.0105, thickness: 75e-4, tessellation: 20 }, n);
+ a.bakeCurrentTransformIntoVertices(), a.isPickable = !1, a.isVisible = !1;
+ var s = new Nt.a("targetMat", n);
+ return s.specularColor = I.a.Black(), s.emissiveColor = this.selectionMeshDefaultColor, s.backFaceCulling = !1, a.material = s, this._options.renderingGroupId !== void 0 && (i.renderingGroupId = this._options.renderingGroupId, a.renderingGroupId = this._options.renderingGroupId), { laserPointer: i, selectionMesh: a };
+ }, t.prototype._pickingMoved = function(e, n) {
+ var i;
+ if (!e.hit || !n.hit || !(e.pickedMesh && e.pickedPoint && n.pickedMesh && n.pickedPoint) || e.pickedMesh !== n.pickedMesh)
+ return !0;
+ (i = e.pickedPoint) === null || i === void 0 || i.subtractToRef(n.pickedPoint, this._tmpVectorForPickCompare), this._tmpVectorForPickCompare.set(Math.abs(this._tmpVectorForPickCompare.x), Math.abs(this._tmpVectorForPickCompare.y), Math.abs(this._tmpVectorForPickCompare.z));
+ var o = 0.01 * (this._options.gazeModePointerMovedFactor || 1) * n.distance;
+ return this._tmpVectorForPickCompare.length() > o;
+ }, t.prototype._updatePointerDistance = function(e, n) {
+ n === void 0 && (n = 100), e.scaling.y = n, this._scene.useRightHandedSystem && (n *= -1), e.position.z = n / 2 + 0.05;
+ }, Object.defineProperty(t.prototype, "lasterPointerDefaultColor", { get: function() {
+ return this.laserPointerDefaultColor;
+ }, enumerable: !1, configurable: !0 }), t._idCounter = 200, t.Name = ti.POINTER_SELECTION, t.Version = 1, t;
+ }(ni);
+ Wn.AddWebXRFeature(eo.Name, function(r, t) {
+ return function() {
+ return new eo(r, t);
+ };
+ }, eo.Version, !0);
+ var Li, cu = function() {
+ function r(t, e, n) {
+ this.element = t, this.sessionMode = e, this.referenceSpaceType = n;
+ }
+ return r.prototype.update = function(t) {
+ }, r;
+ }(), Yp = function() {
+ }, lu = function() {
+ function r(t, e) {
+ var n = this;
+ if (this.scene = t, this.options = e, this._activeButton = null, this._buttons = [], this.activeButtonChangedObservable = new C.c(), this.overlay = document.createElement("div"), this.overlay.classList.add("xr-button-overlay"), this.overlay.style.cssText = "z-index:11;position: absolute; right: 20px;bottom: 50px;", typeof window < "u" && window.location && window.location.protocol === "http:" && Xe.b.Warn("WebXR can only be served over HTTPS"), e.customButtons)
+ this._buttons = e.customButtons;
+ else {
+ var i = e.sessionMode || "immersive-vr", o = e.referenceSpaceType || "local-floor", a = ".babylonVRicon { color: #868686; border-color: #868686; border-style: solid; margin-left: 10px; height: 50px; width: 80px; background-color: rgba(51,51,51,0.7); background-image: url(" + (typeof SVGSVGElement > "u" ? "https://cdn.babylonjs.com/Assets/vrButton.png" : "data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%222048%22%20height%3D%221152%22%20viewBox%3D%220%200%202048%201152%22%20version%3D%221.1%22%3E%3Cpath%20transform%3D%22rotate%28180%201024%2C576.0000000000001%29%22%20d%3D%22m1109%2C896q17%2C0%2030%2C-12t13%2C-30t-12.5%2C-30.5t-30.5%2C-12.5l-170%2C0q-18%2C0%20-30.5%2C12.5t-12.5%2C30.5t13%2C30t30%2C12l170%2C0zm-85%2C256q59%2C0%20132.5%2C-1.5t154.5%2C-5.5t164.5%2C-11.5t163%2C-20t150%2C-30t124.5%2C-41.5q23%2C-11%2042%2C-24t38%2C-30q27%2C-25%2041%2C-61.5t14%2C-72.5l0%2C-257q0%2C-123%20-47%2C-232t-128%2C-190t-190%2C-128t-232%2C-47l-81%2C0q-37%2C0%20-68.5%2C14t-60.5%2C34.5t-55.5%2C45t-53%2C45t-53%2C34.5t-55.5%2C14t-55.5%2C-14t-53%2C-34.5t-53%2C-45t-55.5%2C-45t-60.5%2C-34.5t-68.5%2C-14l-81%2C0q-123%2C0%20-232%2C47t-190%2C128t-128%2C190t-47%2C232l0%2C257q0%2C68%2038%2C115t97%2C73q54%2C24%20124.5%2C41.5t150%2C30t163%2C20t164.5%2C11.5t154.5%2C5.5t132.5%2C1.5zm939%2C-298q0%2C39%20-24.5%2C67t-58.5%2C42q-54%2C23%20-122%2C39.5t-143.5%2C28t-155.5%2C19t-157%2C11t-148.5%2C5t-129.5%2C1.5q-59%2C0%20-130%2C-1.5t-148%2C-5t-157%2C-11t-155.5%2C-19t-143.5%2C-28t-122%2C-39.5q-34%2C-14%20-58.5%2C-42t-24.5%2C-67l0%2C-257q0%2C-106%2040.5%2C-199t110%2C-162.5t162.5%2C-109.5t199%2C-40l81%2C0q27%2C0%2052%2C14t50%2C34.5t51%2C44.5t55.5%2C44.5t63.5%2C34.5t74%2C14t74%2C-14t63.5%2C-34.5t55.5%2C-44.5t51%2C-44.5t50%2C-34.5t52%2C-14l14%2C0q37%2C0%2070%2C0.5t64.5%2C4.5t63.5%2C12t68%2C23q71%2C30%20128.5%2C78.5t98.5%2C110t63.5%2C133.5t22.5%2C149l0%2C257z%22%20fill%3D%22white%22%20/%3E%3C/svg%3E%0A") + "); background-size: 80%; background-repeat:no-repeat; background-position: center; border: none; outline: none; transition: transform 0.125s ease-out } .babylonVRicon:hover { transform: scale(1.05) } .babylonVRicon:active {background-color: rgba(51,51,51,1) } .babylonVRicon:focus {background-color: rgba(51,51,51,1) }";
+ a += '.babylonVRicon.vrdisplaypresenting { background-image: none;} .vrdisplaypresenting::after { content: "EXIT"} .xr-error::after { content: "ERROR"}';
+ var s = document.createElement("style");
+ s.appendChild(document.createTextNode(a)), document.getElementsByTagName("head")[0].appendChild(s);
+ var d = document.createElement("button");
+ d.className = "babylonVRicon", d.title = i + " - " + o, this._buttons.push(new cu(d, i, o)), this._buttons[this._buttons.length - 1].update = function(y) {
+ this.element.style.display = y === null || y === this ? "" : "none", d.className = "babylonVRicon" + (y === this ? " vrdisplaypresenting" : "");
+ }, this._updateButtons(null);
+ }
+ var p = t.getEngine().getInputElement();
+ p && p.parentNode && (p.parentNode.appendChild(this.overlay), t.onDisposeObservable.addOnce(function() {
+ n.dispose();
+ }));
+ }
+ return r.CreateAsync = function(t, e, n) {
+ var i = this, o = new r(t, n), a = o._buttons.map(function(s) {
+ return e.sessionManager.isSessionSupportedAsync(s.sessionMode);
+ });
+ return e.onStateChangedObservable.add(function(s) {
+ s == fn.NOT_IN_XR && o._updateButtons(null);
+ }), Promise.all(a).then(function(s) {
+ return s.forEach(function(d, p) {
+ d ? (o.overlay.appendChild(o._buttons[p].element), o._buttons[p].element.onclick = function() {
+ return Object(c.b)(i, void 0, void 0, function() {
+ var y, P, R;
+ return Object(c.e)(this, function(B) {
+ switch (B.label) {
+ case 0:
+ return e.state != fn.IN_XR ? [3, 2] : [4, e.exitXRAsync()];
+ case 1:
+ return B.sent(), o._updateButtons(null), [3, 6];
+ case 2:
+ if (e.state != fn.NOT_IN_XR)
+ return [3, 6];
+ if (!n.renderTarget)
+ return [3, 6];
+ B.label = 3;
+ case 3:
+ return B.trys.push([3, 5, , 6]), [4, e.enterXRAsync(o._buttons[p].sessionMode, o._buttons[p].referenceSpaceType, n.renderTarget, { optionalFeatures: n.optionalFeatures, requiredFeatures: n.requiredFeatures })];
+ case 4:
+ return B.sent(), o._updateButtons(o._buttons[p]), [3, 6];
+ case 5:
+ return y = B.sent(), o._updateButtons(null), P = o._buttons[p].element, R = P.title, P.title = "Error entering XR session : " + R, P.classList.add("xr-error"), n.onError && n.onError(y), [3, 6];
+ case 6:
+ return [2];
+ }
+ });
+ });
+ }) : Xe.b.Warn('Session mode "' + o._buttons[p].sessionMode + '" not supported in browser');
+ }), o;
+ });
+ }, r.prototype.dispose = function() {
+ var t = this.scene.getEngine().getInputElement();
+ t && t.parentNode && t.parentNode.contains(this.overlay) && t.parentNode.removeChild(this.overlay), this.activeButtonChangedObservable.clear();
+ }, r.prototype._updateButtons = function(t) {
+ var e = this;
+ this._activeButton = t, this._buttons.forEach(function(n) {
+ n.update(e._activeButton);
+ }), this.activeButtonChangedObservable.notifyObservers(this._activeButton);
+ }, r;
+ }();
+ function Os(r) {
+ var t, e = 0, n = Date.now();
+ r.observableParameters = (t = r.observableParameters) !== null && t !== void 0 ? t : {};
+ var i = r.contextObservable.add(function(o) {
+ var a = Date.now(), s = { startTime: n, currentTime: a, deltaTime: e = a - n, completeRate: e / r.timeout, payload: o };
+ r.onTick && r.onTick(s), r.breakCondition && r.breakCondition() && (r.contextObservable.remove(i), r.onAborted && r.onAborted(s)), e >= r.timeout && (r.contextObservable.remove(i), r.onEnded && r.onEnded(s));
+ }, r.observableParameters.mask, r.observableParameters.insertFirst, r.observableParameters.scope);
+ return i;
+ }
+ (function(r) {
+ r[r.INIT = 0] = "INIT", r[r.STARTED = 1] = "STARTED", r[r.ENDED = 2] = "ENDED";
+ })(Li || (Li = {}));
+ var Kp = function() {
+ function r(t) {
+ var e, n, i = this;
+ this.onEachCountObservable = new C.c(), this.onTimerAbortedObservable = new C.c(), this.onTimerEndedObservable = new C.c(), this.onStateChangedObservable = new C.c(), this._observer = null, this._breakOnNextTick = !1, this._tick = function(o) {
+ var a = Date.now();
+ i._timer = a - i._startTime;
+ var s = { startTime: i._startTime, currentTime: a, deltaTime: i._timer, completeRate: i._timer / i._timeToEnd, payload: o }, d = i._breakOnNextTick || i._breakCondition(s);
+ d || i._timer >= i._timeToEnd ? i._stop(s, d) : i.onEachCountObservable.notifyObservers(s);
+ }, this._setState(Li.INIT), this._contextObservable = t.contextObservable, this._observableParameters = (e = t.observableParameters) !== null && e !== void 0 ? e : {}, this._breakCondition = (n = t.breakCondition) !== null && n !== void 0 ? n : function() {
+ return !1;
+ }, t.onEnded && this.onTimerEndedObservable.add(t.onEnded), t.onTick && this.onEachCountObservable.add(t.onTick), t.onAborted && this.onTimerAbortedObservable.add(t.onAborted);
+ }
+ return Object.defineProperty(r.prototype, "breakCondition", { set: function(t) {
+ this._breakCondition = t;
+ }, enumerable: !1, configurable: !0 }), r.prototype.clearObservables = function() {
+ this.onEachCountObservable.clear(), this.onTimerAbortedObservable.clear(), this.onTimerEndedObservable.clear(), this.onStateChangedObservable.clear();
+ }, r.prototype.start = function(t) {
+ if (t === void 0 && (t = this._timeToEnd), this._state === Li.STARTED)
+ throw new Error("Timer already started. Please stop it before starting again");
+ this._timeToEnd = t, this._startTime = Date.now(), this._timer = 0, this._observer = this._contextObservable.add(this._tick, this._observableParameters.mask, this._observableParameters.insertFirst, this._observableParameters.scope), this._setState(Li.STARTED);
+ }, r.prototype.stop = function() {
+ this._state === Li.STARTED && (this._breakOnNextTick = !0);
+ }, r.prototype.dispose = function() {
+ this._observer && this._contextObservable.remove(this._observer), this.clearObservables();
+ }, r.prototype._setState = function(t) {
+ this._state = t, this.onStateChangedObservable.notifyObservers(this._state);
+ }, r.prototype._stop = function(t, e) {
+ e === void 0 && (e = !1), this._contextObservable.remove(this._observer), this._setState(Li.ENDED), e ? this.onTimerAbortedObservable.notifyObservers(t) : this.onTimerEndedObservable.notifyObservers(t);
+ }, r;
+ }(), to = function(r) {
+ function t(e, n) {
+ var i = r.call(this, e) || this;
+ return i._options = n, i._controllers = {}, i._snappedToPoint = !1, i._tmpRay = new dn.a(new u.e(), new u.e()), i._tmpVector = new u.e(), i._tmpQuaternion = new u.b(), i.backwardsMovementEnabled = !0, i.backwardsTeleportationDistance = 0.7, i.parabolicCheckRadius = 5, i.parabolicRayEnabled = !0, i.straightRayEnabled = !0, i.rotationAngle = Math.PI / 8, i._rotationEnabled = !0, i._attachController = function(o) {
+ if (!(i._controllers[o.uniqueId] || i._options.forceHandedness && o.inputSource.handedness !== i._options.forceHandedness)) {
+ i._controllers[o.uniqueId] = { xrController: o, teleportationState: { forward: !1, backwards: !1, rotating: !1, currentRotation: 0, baseRotation: 0 } };
+ var a = i._controllers[o.uniqueId];
+ if (a.xrController.inputSource.targetRayMode === "tracked-pointer" && a.xrController.inputSource.gamepad) {
+ var s = function() {
+ if (o.motionController) {
+ var d = o.motionController.getComponentOfType(yr.THUMBSTICK_TYPE) || o.motionController.getComponentOfType(yr.TOUCHPAD_TYPE);
+ if (!d || i._options.useMainComponentOnly) {
+ var p = o.motionController.getMainComponent();
+ if (!p)
+ return;
+ a.teleportationComponent = p, a.onButtonChangedObserver = p.onButtonStateChangedObservable.add(function() {
+ p.changes.pressed && (p.changes.pressed.current ? (a.teleportationState.forward = !0, i._currentTeleportationControllerId = a.xrController.uniqueId, a.teleportationState.baseRotation = i._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y, a.teleportationState.currentRotation = 0, Os({ timeout: i._options.timeToTeleport || 3e3, contextObservable: i._xrSessionManager.onXRFrameObservable, breakCondition: function() {
+ return !p.pressed;
+ }, onEnded: function() {
+ i._currentTeleportationControllerId === a.xrController.uniqueId && a.teleportationState.forward && i._teleportForward(o.uniqueId);
+ } })) : (a.teleportationState.forward = !1, i._currentTeleportationControllerId = ""));
+ });
+ } else
+ a.teleportationComponent = d, a.onAxisChangedObserver = d.onAxisValueChangedObservable.add(function(y) {
+ if (y.y <= 0.7 && a.teleportationState.backwards && (a.teleportationState.backwards = !1), y.y > 0.7 && !a.teleportationState.forward && i.backwardsMovementEnabled && !i.snapPointsOnly && !a.teleportationState.backwards) {
+ a.teleportationState.backwards = !0, i._tmpQuaternion.copyFrom(i._options.xrInput.xrCamera.rotationQuaternion), i._tmpQuaternion.toEulerAnglesToRef(i._tmpVector), i._tmpVector.x = 0, i._tmpVector.z = 0, u.b.FromEulerVectorToRef(i._tmpVector, i._tmpQuaternion), i._tmpVector.set(0, 0, i.backwardsTeleportationDistance * (i._xrSessionManager.scene.useRightHandedSystem ? 1 : -1)), i._tmpVector.rotateByQuaternionToRef(i._tmpQuaternion, i._tmpVector), i._tmpVector.addInPlace(i._options.xrInput.xrCamera.position), i._tmpRay.origin.copyFrom(i._tmpVector), i._tmpRay.length = i._options.xrInput.xrCamera.realWorldHeight + 0.1, i._tmpRay.direction.set(0, -1, 0);
+ var P = i._xrSessionManager.scene.pickWithRay(i._tmpRay, function(B) {
+ return i._floorMeshes.indexOf(B) !== -1;
+ });
+ P && P.pickedPoint && (i._options.xrInput.xrCamera.position.x = P.pickedPoint.x, i._options.xrInput.xrCamera.position.z = P.pickedPoint.z);
+ }
+ if (y.y < -0.7 && !i._currentTeleportationControllerId && !a.teleportationState.rotating && (a.teleportationState.forward = !0, i._currentTeleportationControllerId = a.xrController.uniqueId, a.teleportationState.baseRotation = i._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y), y.x) {
+ if (a.teleportationState.forward)
+ i._currentTeleportationControllerId === a.xrController.uniqueId && (i.rotationEnabled ? setTimeout(function() {
+ a.teleportationState.currentRotation = Math.atan2(y.x, y.y * (i._xrSessionManager.scene.useRightHandedSystem ? 1 : -1));
+ }) : a.teleportationState.currentRotation = 0);
+ else if (!a.teleportationState.rotating && Math.abs(y.x) > 0.7) {
+ a.teleportationState.rotating = !0;
+ var R = i.rotationAngle * (y.x > 0 ? 1 : -1) * (i._xrSessionManager.scene.useRightHandedSystem ? -1 : 1);
+ i._options.xrInput.xrCamera.rotationQuaternion.multiplyInPlace(u.b.FromEulerAngles(0, R, 0));
+ }
+ } else
+ a.teleportationState.rotating = !1;
+ y.x === 0 && y.y === 0 && a.teleportationState.forward && i._teleportForward(o.uniqueId);
+ });
+ }
+ };
+ o.motionController ? s() : o.onMotionControllerInitObservable.addOnce(function() {
+ s();
+ });
+ } else
+ i._xrSessionManager.scene.onPointerObservable.add(function(d) {
+ d.type === yt.a.POINTERDOWN ? (a.teleportationState.forward = !0, i._currentTeleportationControllerId = a.xrController.uniqueId, a.teleportationState.baseRotation = i._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y, a.teleportationState.currentRotation = 0, Os({ timeout: i._options.timeToTeleport || 3e3, contextObservable: i._xrSessionManager.onXRFrameObservable, onEnded: function() {
+ i._currentTeleportationControllerId === a.xrController.uniqueId && a.teleportationState.forward && i._teleportForward(o.uniqueId);
+ } })) : d.type === yt.a.POINTERUP && (a.teleportationState.forward = !1, i._currentTeleportationControllerId = "");
+ });
+ }
+ }, i._options.teleportationTargetMesh || i._createDefaultTargetMesh(), i._floorMeshes = i._options.floorMeshes || [], i._snapToPositions = i._options.snapPositions || [], i._setTargetMeshVisibility(!1), i;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "rotationEnabled", { get: function() {
+ return this._rotationEnabled;
+ }, set: function(e) {
+ if (this._rotationEnabled = e, this._options.teleportationTargetMesh) {
+ var n = this._options.teleportationTargetMesh.getChildMeshes(!1, function(i) {
+ return i.name === "rotationCone";
+ });
+ n[0] && n[0].setEnabled(e);
+ }
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "teleportationTargetMesh", { get: function() {
+ return this._options.teleportationTargetMesh || null;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "snapPointsOnly", { get: function() {
+ return !!this._options.snapPointsOnly;
+ }, set: function(e) {
+ this._options.snapPointsOnly = e;
+ }, enumerable: !1, configurable: !0 }), t.prototype.addFloorMesh = function(e) {
+ this._floorMeshes.push(e);
+ }, t.prototype.addSnapPoint = function(e) {
+ this._snapToPositions.push(e);
+ }, t.prototype.attach = function() {
+ var e = this;
+ return !!r.prototype.attach.call(this) && (this._currentTeleportationControllerId = "", this._options.xrInput.controllers.forEach(this._attachController), this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable, this._attachController), this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable, function(n) {
+ e._detachController(n.uniqueId);
+ }), !0);
+ }, t.prototype.detach = function() {
+ var e = this;
+ return !!r.prototype.detach.call(this) && (Object.keys(this._controllers).forEach(function(n) {
+ e._detachController(n);
+ }), this._setTargetMeshVisibility(!1), this._currentTeleportationControllerId = "", this._controllers = {}, !0);
+ }, t.prototype.dispose = function() {
+ r.prototype.dispose.call(this), this._options.teleportationTargetMesh && this._options.teleportationTargetMesh.dispose(!1, !0);
+ }, t.prototype.removeFloorMesh = function(e) {
+ var n = this._floorMeshes.indexOf(e);
+ n !== -1 && this._floorMeshes.splice(n, 1);
+ }, t.prototype.removeFloorMeshByName = function(e) {
+ var n = this._xrSessionManager.scene.getMeshByName(e);
+ n && this.removeFloorMesh(n);
+ }, t.prototype.removeSnapPoint = function(e) {
+ var n = this._snapToPositions.indexOf(e);
+ if (n === -1) {
+ for (var i = 0; i < this._snapToPositions.length; ++i)
+ if (this._snapToPositions[i].equals(e)) {
+ n = i;
+ break;
+ }
+ }
+ return n !== -1 && (this._snapToPositions.splice(n, 1), !0);
+ }, t.prototype.setSelectionFeature = function(e) {
+ this._selectionFeature = e;
+ }, t.prototype._onXRFrame = function(e) {
+ var n = this, i = this._xrSessionManager.currentFrame, o = this._xrSessionManager.scene;
+ if (this.attach && i) {
+ var a = this._options.teleportationTargetMesh;
+ if (this._currentTeleportationControllerId) {
+ if (!a)
+ return;
+ a.rotationQuaternion = a.rotationQuaternion || new u.b();
+ var s = this._controllers[this._currentTeleportationControllerId];
+ if (s && s.teleportationState.forward) {
+ u.b.RotationYawPitchRollToRef(s.teleportationState.currentRotation + s.teleportationState.baseRotation, 0, 0, a.rotationQuaternion);
+ var d = !1;
+ if (s.xrController.getWorldPointerRayToRef(this._tmpRay), this.straightRayEnabled) {
+ if ((p = o.pickWithRay(this._tmpRay, function(B) {
+ if (n._options.pickBlockerMeshes && n._options.pickBlockerMeshes.indexOf(B) !== -1)
+ return !0;
+ var F = n._floorMeshes.indexOf(B);
+ return F !== -1 && n._floorMeshes[F].absolutePosition.y < n._options.xrInput.xrCamera.position.y;
+ })) && p.pickedMesh && this._options.pickBlockerMeshes && this._options.pickBlockerMeshes.indexOf(p.pickedMesh) !== -1)
+ return;
+ p && p.pickedPoint && (d = !0, this._setTargetMeshPosition(p.pickedPoint), this._setTargetMeshVisibility(!0), this._showParabolicPath(p));
+ }
+ if (this.parabolicRayEnabled && !d) {
+ var p, y = s.xrController.pointer.rotationQuaternion.toEulerAngles().x, P = Math.PI / 2 - Math.abs(y) + 1, R = this.parabolicCheckRadius * P;
+ if (this._tmpRay.origin.addToRef(this._tmpRay.direction.scale(2 * R), this._tmpVector), this._tmpVector.y = this._tmpRay.origin.y, this._tmpRay.origin.addInPlace(this._tmpRay.direction.scale(R)), this._tmpVector.subtractToRef(this._tmpRay.origin, this._tmpRay.direction), this._tmpRay.direction.normalize(), (p = o.pickWithRay(this._tmpRay, function(B) {
+ return !(!n._options.pickBlockerMeshes || n._options.pickBlockerMeshes.indexOf(B) === -1) || n._floorMeshes.indexOf(B) !== -1;
+ })) && p.pickedMesh && this._options.pickBlockerMeshes && this._options.pickBlockerMeshes.indexOf(p.pickedMesh) !== -1)
+ return;
+ p && p.pickedPoint && (d = !0, this._setTargetMeshPosition(p.pickedPoint), this._setTargetMeshVisibility(!0), this._showParabolicPath(p));
+ }
+ this._setTargetMeshVisibility(d);
+ } else
+ this._setTargetMeshVisibility(!1);
+ } else
+ this._setTargetMeshVisibility(!1);
+ }
+ }, t.prototype._createDefaultTargetMesh = function() {
+ this._options.defaultTargetMeshOptions = this._options.defaultTargetMeshOptions || {};
+ var e = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || Cn.a.DefaultUtilityLayer.utilityLayerScene : this._xrSessionManager.scene, n = Oi.CreateGround("teleportationTarget", { width: 2, height: 2, subdivisions: 2 }, e);
+ n.isPickable = !1;
+ var i = new pi.a("teleportationPlaneDynamicTexture", 512, e, !0);
+ i.hasAlpha = !0;
+ var o = i.getContext();
+ o.beginPath(), o.arc(256, 256, 200, 0, 2 * Math.PI, !1), o.fillStyle = this._options.defaultTargetMeshOptions.teleportationFillColor || "#444444", o.fill(), o.lineWidth = 10, o.strokeStyle = this._options.defaultTargetMeshOptions.teleportationBorderColor || "#FFFFFF", o.stroke(), o.closePath(), i.update();
+ var a = new Nt.a("teleportationPlaneMaterial", e);
+ a.diffuseTexture = i, n.material = a;
+ var s = lr.CreateTorus("torusTeleportation", { diameter: 0.75, thickness: 0.1, tessellation: 20 }, e);
+ if (s.isPickable = !1, s.parent = n, !this._options.defaultTargetMeshOptions.disableAnimation) {
+ var d = new k("animationInnerCircle", "position.y", 30, k.ANIMATIONTYPE_FLOAT, k.ANIMATIONLOOPMODE_CYCLE), p = [];
+ p.push({ frame: 0, value: 0 }), p.push({ frame: 30, value: 0.4 }), p.push({ frame: 60, value: 0 }), d.setKeys(p);
+ var y = new nn();
+ y.setEasingMode(Ge.EASINGMODE_EASEINOUT), d.setEasingFunction(y), s.animations = [], s.animations.push(d), e.beginAnimation(s, 0, 60, !0);
+ }
+ var P = ci.a.CreateCylinder("rotationCone", { diameterTop: 0, tessellation: 4 }, e);
+ if (P.isPickable = !1, P.scaling.set(0.5, 0.12, 0.2), P.rotate(be.a.X, Math.PI / 2), P.position.z = 0.6, P.parent = s, this._options.defaultTargetMeshOptions.torusArrowMaterial)
+ s.material = this._options.defaultTargetMeshOptions.torusArrowMaterial, P.material = this._options.defaultTargetMeshOptions.torusArrowMaterial;
+ else {
+ var R = new Nt.a("torusConsMat", e);
+ R.disableLighting = !!this._options.defaultTargetMeshOptions.disableLighting, R.disableLighting ? R.emissiveColor = new I.a(0.3, 0.3, 1) : R.diffuseColor = new I.a(0.3, 0.3, 1), R.alpha = 0.9, s.material = R, P.material = R, this._teleportationRingMaterial = R;
+ }
+ this._options.renderingGroupId !== void 0 && (n.renderingGroupId = this._options.renderingGroupId, s.renderingGroupId = this._options.renderingGroupId, P.renderingGroupId = this._options.renderingGroupId), this._options.teleportationTargetMesh = n;
+ }, t.prototype._detachController = function(e) {
+ var n = this._controllers[e];
+ n && (n.teleportationComponent && (n.onAxisChangedObserver && n.teleportationComponent.onAxisValueChangedObservable.remove(n.onAxisChangedObserver), n.onButtonChangedObserver && n.teleportationComponent.onButtonStateChangedObservable.remove(n.onButtonChangedObserver)), delete this._controllers[e]);
+ }, t.prototype._findClosestSnapPointWithRadius = function(e, n) {
+ n === void 0 && (n = this._options.snapToPositionRadius || 0.8);
+ var i = null, o = Number.MAX_VALUE;
+ if (this._snapToPositions.length) {
+ var a = n * n;
+ this._snapToPositions.forEach(function(s) {
+ var d = u.e.DistanceSquared(s, e);
+ d <= a && d < o && (o = d, i = s);
+ });
+ }
+ return i;
+ }, t.prototype._setTargetMeshPosition = function(e) {
+ if (this._options.teleportationTargetMesh) {
+ var n = this._findClosestSnapPointWithRadius(e);
+ this._snappedToPoint = !!n, this.snapPointsOnly && !this._snappedToPoint && this._teleportationRingMaterial ? this._teleportationRingMaterial.diffuseColor.set(1, 0.3, 0.3) : this.snapPointsOnly && this._snappedToPoint && this._teleportationRingMaterial && this._teleportationRingMaterial.diffuseColor.set(0.3, 0.3, 1), this._options.teleportationTargetMesh.position.copyFrom(n || e), this._options.teleportationTargetMesh.position.y += 0.01;
+ }
+ }, t.prototype._setTargetMeshVisibility = function(e) {
+ this._options.teleportationTargetMesh && this._options.teleportationTargetMesh.isVisible !== e && (this._options.teleportationTargetMesh.isVisible = e, this._options.teleportationTargetMesh.getChildren(void 0, !1).forEach(function(n) {
+ n.isVisible = e;
+ }), e ? this._selectionFeature && this._selectionFeature.detach() : (this._quadraticBezierCurve && (this._quadraticBezierCurve.dispose(), this._quadraticBezierCurve = null), this._selectionFeature && this._selectionFeature.attach()));
+ }, t.prototype._showParabolicPath = function(e) {
+ if (e.pickedPoint) {
+ var n = this._controllers[this._currentTeleportationControllerId], i = Qe.d.CreateQuadraticBezier(n.xrController.pointer.absolutePosition, e.ray.origin, e.pickedPoint, 25);
+ this._options.generateRayPathMesh ? this._quadraticBezierCurve = this._options.generateRayPathMesh(i.getPoints()) : this._quadraticBezierCurve = sn.a.CreateLines("teleportation path line", { points: i.getPoints(), instance: this._quadraticBezierCurve, updatable: !0 }), this._quadraticBezierCurve.isPickable = !1;
+ }
+ }, t.prototype._teleportForward = function(e) {
+ var n = this._controllers[e];
+ if (n && n.teleportationState.forward && (n.teleportationState.forward = !1, this._currentTeleportationControllerId = "", (!this.snapPointsOnly || this._snappedToPoint) && this._options.teleportationTargetMesh && this._options.teleportationTargetMesh.isVisible)) {
+ var i = this._options.xrInput.xrCamera.realWorldHeight;
+ this._options.xrInput.xrCamera.onBeforeCameraTeleport.notifyObservers(this._options.xrInput.xrCamera.position), this._options.xrInput.xrCamera.position.copyFrom(this._options.teleportationTargetMesh.position), this._options.xrInput.xrCamera.position.y += i, this._options.xrInput.xrCamera.rotationQuaternion.multiplyInPlace(u.b.FromEulerAngles(0, n.teleportationState.currentRotation - (this._xrSessionManager.scene.useRightHandedSystem ? Math.PI : 0), 0)), this._options.xrInput.xrCamera.onAfterCameraTeleport.notifyObservers(this._options.xrInput.xrCamera.position);
+ }
+ }, t.Name = ti.TELEPORTATION, t.Version = 1, t;
+ }(ni);
+ Wn.AddWebXRFeature(to.Name, function(r, t) {
+ return function() {
+ return new to(r, t);
+ };
+ }, to.Version, !0);
+ var Qp = function() {
+ }, uu = function() {
+ function r() {
+ }
+ return r.CreateAsync = function(t, e) {
+ e === void 0 && (e = {});
+ var n = new r();
+ return ru.CreateAsync(t).then(function(i) {
+ if (n.baseExperience = i, e.ignoreNativeCameraTransformation && (n.baseExperience.camera.compensateOnFirstFrame = !1), n.input = new su(i.sessionManager, i.camera, Object(c.a)({ controllerOptions: { renderingGroupId: e.renderingGroupId } }, e.inputOptions || {})), n.pointerSelection = n.baseExperience.featuresManager.enableFeature(eo.Name, e.useStablePlugins ? "stable" : "latest", { xrInput: n.input, renderingGroupId: e.renderingGroupId }), e.disableTeleportation || (n.teleportation = n.baseExperience.featuresManager.enableFeature(to.Name, e.useStablePlugins ? "stable" : "latest", { floorMeshes: e.floorMeshes, xrInput: n.input, renderingGroupId: e.renderingGroupId }), n.teleportation.setSelectionFeature(n.pointerSelection)), n.renderTarget = n.baseExperience.sessionManager.getWebXRRenderTarget(e.outputCanvasOptions), !e.disableDefaultUI) {
+ var o = Object(c.a)({ renderTarget: n.renderTarget }, e.uiOptions || {});
+ return e.optionalFeatures && (typeof e.optionalFeatures == "boolean" ? o.optionalFeatures = ["hit-test", "anchors", "plane-detection", "hand-tracking"] : o.optionalFeatures = e.optionalFeatures), lu.CreateAsync(t, n.baseExperience, o).then(function(a) {
+ n.enterExitUI = a;
+ });
+ }
+ }).then(function() {
+ return n;
+ }).catch(function(i) {
+ return l.a.Error("Error initializing XR"), l.a.Error(i), n;
+ });
+ }, r.prototype.dispose = function() {
+ this.baseExperience && this.baseExperience.dispose(), this.input && this.input.dispose(), this.enterExitUI && this.enterExitUI.dispose(), this.renderTarget && this.renderTarget.dispose();
+ }, r;
+ }(), qp = !0;
+ _e.a.prototype.createDefaultLight = function(r) {
+ if (r === void 0 && (r = !1), r && this.lights)
+ for (var t = 0; t < this.lights.length; t++)
+ this.lights[t].dispose();
+ this.lights.length === 0 && new Oo.a("default light", u.e.Up(), this);
+ }, _e.a.prototype.createDefaultCamera = function(r, t, e) {
+ if (r === void 0 && (r = !1), t === void 0 && (t = !1), e === void 0 && (e = !1), t && this.activeCamera && (this.activeCamera.dispose(), this.activeCamera = null), !this.activeCamera) {
+ var n, i = this.getWorldExtends(function(P) {
+ return P.isVisible && P.isEnabled();
+ }), o = i.max.subtract(i.min), a = i.min.add(o.scale(0.5)), s = 1.5 * o.length();
+ if (isFinite(s) || (s = 1, a.copyFromFloats(0, 0, 0)), r) {
+ var d = new ji("default camera", -Math.PI / 2, Math.PI / 2, s, a, this);
+ d.lowerRadiusLimit = 0.01 * s, d.wheelPrecision = 100 / s, n = d;
+ } else {
+ var p = new zn("default camera", new u.e(a.x, a.y, -s), this);
+ p.setTarget(a), n = p;
+ }
+ n.minZ = 0.01 * s, n.maxZ = 1e3 * s, n.speed = 0.2 * s, this.activeCamera = n;
+ var y = this.getEngine().getInputElement();
+ e && y && n.attachControl();
+ }
+ }, _e.a.prototype.createDefaultCameraOrLight = function(r, t, e) {
+ r === void 0 && (r = !1), t === void 0 && (t = !1), e === void 0 && (e = !1), this.createDefaultLight(t), this.createDefaultCamera(r, t, e);
+ }, _e.a.prototype.createDefaultSkybox = function(r, t, e, n, i) {
+ if (t === void 0 && (t = !1), e === void 0 && (e = 1e3), n === void 0 && (n = 0), i === void 0 && (i = !0), !r)
+ return l.a.Warn("Can not create default skybox without environment texture."), null;
+ i && r && (this.environmentTexture = r);
+ var o = Ie.a.CreateBox("hdrSkyBox", e, this);
+ if (t) {
+ var a = new $r("skyBox", this);
+ a.backFaceCulling = !1, a.reflectionTexture = r.clone(), a.reflectionTexture && (a.reflectionTexture.coordinatesMode = Ne.a.SKYBOX_MODE), a.microSurface = 1 - n, a.disableLighting = !0, a.twoSidedLighting = !0, o.infiniteDistance = !0, o.material = a;
+ } else {
+ var s = new Nt.a("skyBox", this);
+ s.backFaceCulling = !1, s.reflectionTexture = r.clone(), s.reflectionTexture && (s.reflectionTexture.coordinatesMode = Ne.a.SKYBOX_MODE), s.disableLighting = !0, o.infiniteDistance = !0, o.material = s;
+ }
+ return o.isPickable = !1, o;
+ }, _e.a.prototype.createDefaultEnvironment = function(r) {
+ return Es ? new Es(r, this) : null;
+ }, _e.a.prototype.createDefaultVRExperience = function(r) {
+ return r === void 0 && (r = {}), new Il(this, r);
+ }, _e.a.prototype.createDefaultXRExperienceAsync = function(r) {
+ return r === void 0 && (r = {}), uu.CreateAsync(this, r).then(function(t) {
+ return t;
+ });
+ };
+ var hu = function(r) {
+ function t(e, n, i, o, a, s, d) {
+ o === void 0 && (o = !1), a === void 0 && (a = !1), s === void 0 && (s = Ne.a.TRILINEAR_SAMPLINGMODE), d === void 0 && (d = { autoPlay: !0, loop: !0, autoUpdateTexture: !0 });
+ var p = r.call(this, null, i, !o, a) || this;
+ p._onUserActionRequestedObservable = null, p._stillImageCaptured = !1, p._displayingPosterTexture = !1, p._frameId = -1, p._currentSrc = null, p._createInternalTexture = function() {
+ if (p._texture != null) {
+ if (!p._displayingPosterTexture)
+ return;
+ p._texture.dispose(), p._displayingPosterTexture = !1;
+ }
+ if (!p._getEngine().needPOTTextures || Xe.b.IsExponentOfTwo(p.video.videoWidth) && Xe.b.IsExponentOfTwo(p.video.videoHeight) ? (p.wrapU = Ne.a.WRAP_ADDRESSMODE, p.wrapV = Ne.a.WRAP_ADDRESSMODE) : (p.wrapU = Ne.a.CLAMP_ADDRESSMODE, p.wrapV = Ne.a.CLAMP_ADDRESSMODE, p._generateMipMaps = !1), p._texture = p._getEngine().createDynamicTexture(p.video.videoWidth, p.video.videoHeight, p._generateMipMaps, p.samplingMode), p.video.autoplay || p._settings.poster)
+ p._texture.isReady = !0, p._updateInternalTexture(), p.onLoadObservable.hasObservers() && p.onLoadObservable.notifyObservers(p);
+ else {
+ var P = p.video.onplaying, R = !1, B = p.video.muted;
+ p.video.muted = !0, p.video.onplaying = function() {
+ p.video.muted = B, p.video.onplaying = P, p._texture.isReady = !0, p._updateInternalTexture(), R || p.video.pause(), p.onLoadObservable.hasObservers() && p.onLoadObservable.notifyObservers(p);
+ };
+ var F = p.video.play();
+ F ? F.then(function() {
+ }).catch(function() {
+ R = !0, p._onUserActionRequestedObservable && p._onUserActionRequestedObservable.hasObservers() && p._onUserActionRequestedObservable.notifyObservers(p);
+ }) : (p.video.onplaying = P, p._texture.isReady = !0, p._updateInternalTexture(), p.onLoadObservable.hasObservers() && p.onLoadObservable.notifyObservers(p));
+ }
+ }, p.reset = function() {
+ p._texture != null && (p._displayingPosterTexture || (p._texture.dispose(), p._texture = null));
+ }, p._updateInternalTexture = function() {
+ if (p._texture != null && p._texture.isReady && !(p.video.readyState < p.video.HAVE_CURRENT_DATA || p._displayingPosterTexture)) {
+ var P = p.getScene().getFrameId();
+ p._frameId !== P && (p._frameId = P, p._getEngine().updateVideoTexture(p._texture, p.video, p._invertY));
+ }
+ }, p._generateMipMaps = o, p._initialSamplingMode = s, p.autoUpdateTexture = d.autoUpdateTexture, p._currentSrc = n, p.name = e || p._getName(n), p.video = p._getVideo(n), p._settings = d, d.poster && (p.video.poster = d.poster), d.autoPlay !== void 0 && (p.video.autoplay = d.autoPlay), d.loop !== void 0 && (p.video.loop = d.loop), d.muted !== void 0 && (p.video.muted = d.muted), p.video.setAttribute("playsinline", ""), p.video.addEventListener("paused", p._updateInternalTexture), p.video.addEventListener("seeked", p._updateInternalTexture), p.video.addEventListener("emptied", p.reset), p._createInternalTextureOnEvent = d.poster && !d.autoPlay ? "play" : "canplay", p.video.addEventListener(p._createInternalTextureOnEvent, p._createInternalTexture), d.autoPlay && p.video.play();
+ var y = p.video.readyState >= p.video.HAVE_CURRENT_DATA;
+ return !d.poster || d.autoPlay && y ? y && p._createInternalTexture() : (p._texture = p._getEngine().createTexture(d.poster, !1, !p.invertY, i), p._displayingPosterTexture = !0), p;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "onUserActionRequestedObservable", { get: function() {
+ return this._onUserActionRequestedObservable || (this._onUserActionRequestedObservable = new C.c()), this._onUserActionRequestedObservable;
+ }, enumerable: !1, configurable: !0 }), t.prototype._getName = function(e) {
+ return e instanceof HTMLVideoElement ? e.currentSrc : typeof e == "object" ? e.toString() : e;
+ }, t.prototype._getVideo = function(e) {
+ if (e instanceof HTMLVideoElement)
+ return Xe.b.SetCorsBehavior(e.currentSrc, e), e;
+ var n = document.createElement("video");
+ return typeof e == "string" ? (Xe.b.SetCorsBehavior(e, n), n.src = e) : (Xe.b.SetCorsBehavior(e[0], n), e.forEach(function(i) {
+ var o = document.createElement("source");
+ o.src = i, n.appendChild(o);
+ })), n;
+ }, t.prototype._rebuild = function() {
+ this.update();
+ }, t.prototype.update = function() {
+ this.autoUpdateTexture && this.updateTexture(!0);
+ }, t.prototype.updateTexture = function(e) {
+ e && (this.video.paused && this._stillImageCaptured || (this._stillImageCaptured = !0, this._updateInternalTexture()));
+ }, t.prototype.updateURL = function(e) {
+ this.video.src = e, this._currentSrc = e;
+ }, t.prototype.clone = function() {
+ return new t(this.name, this._currentSrc, this.getScene(), this._generateMipMaps, this.invertY, this.samplingMode, this._settings);
+ }, t.prototype.dispose = function() {
+ r.prototype.dispose.call(this), this._currentSrc = null, this._onUserActionRequestedObservable && (this._onUserActionRequestedObservable.clear(), this._onUserActionRequestedObservable = null), this.video.removeEventListener(this._createInternalTextureOnEvent, this._createInternalTexture), this.video.removeEventListener("paused", this._updateInternalTexture), this.video.removeEventListener("seeked", this._updateInternalTexture), this.video.removeEventListener("emptied", this.reset), this.video.pause();
+ }, t.CreateFromStreamAsync = function(e, n) {
+ var i = document.createElement("video");
+ return e.getEngine()._badOS && (document.body.appendChild(i), i.style.transform = "scale(0.0001, 0.0001)", i.style.opacity = "0", i.style.position = "fixed", i.style.bottom = "0px", i.style.right = "0px"), i.setAttribute("autoplay", ""), i.setAttribute("muted", "true"), i.setAttribute("playsinline", ""), i.muted = !0, i.mozSrcObject !== void 0 ? i.mozSrcObject = n : typeof i.srcObject == "object" ? i.srcObject = n : (window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL, i.src = window.URL && window.URL.createObjectURL(n)), new Promise(function(o) {
+ var a = function() {
+ o(new t("video", i, e, !0, !0)), i.removeEventListener("playing", a);
+ };
+ i.addEventListener("playing", a), i.play();
+ });
+ }, t.CreateFromWebCamAsync = function(e, n, i) {
+ var o, a = this;
+ return i === void 0 && (i = !1), n && n.deviceId && (o = { exact: n.deviceId }), navigator.mediaDevices ? navigator.mediaDevices.getUserMedia({ video: n, audio: i }).then(function(s) {
+ return a.CreateFromStreamAsync(e, s);
+ }) : (navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia, navigator.getUserMedia && navigator.getUserMedia({ video: { deviceId: o, width: { min: n && n.minWidth || 256, max: n && n.maxWidth || 640 }, height: { min: n && n.minHeight || 256, max: n && n.maxHeight || 480 } }, audio: i }, function(s) {
+ return a.CreateFromStreamAsync(e, s);
+ }, function(s) {
+ l.a.Error(s.name);
+ }), Promise.reject("No support for userMedia on this device"));
+ }, t.CreateFromWebCam = function(e, n, i, o) {
+ o === void 0 && (o = !1), this.CreateFromWebCamAsync(e, i, o).then(function(a) {
+ n && n(a);
+ }).catch(function(a) {
+ l.a.Error(a.name);
+ });
+ }, t;
+ }(Ne.a), Zp = function(r) {
+ function t() {
+ return r !== null && r.apply(this, arguments) || this;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "videoTexture", { get: function() {
+ return this._texture;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "videoMode", { get: function() {
+ return this.textureMode;
+ }, set: function(e) {
+ this.textureMode = e;
+ }, enumerable: !1, configurable: !0 }), t.prototype._initTexture = function(e, n, i) {
+ var o = this, a = { loop: i.loop, autoPlay: i.autoPlay, autoUpdateTexture: !0, poster: i.poster }, s = new hu((this.name || "videoDome") + "_texture", e, n, i.generateMipMaps, this._useDirectMapping, Ne.a.TRILINEAR_SAMPLINGMODE, a);
+ return i.clickToPlay && (n.onPointerUp = function() {
+ o._texture.video.play();
+ }), s;
+ }, t.MODE_MONOSCOPIC = Ii.MODE_MONOSCOPIC, t.MODE_TOPBOTTOM = Ii.MODE_TOPBOTTOM, t.MODE_SIDEBYSIDE = Ii.MODE_SIDEBYSIDE, t;
+ }(Ii), Gn = f(55), Jp = function() {
+ function r(t) {
+ this.engine = t, this._captureGPUFrameTime = !1, this._gpuFrameTime = new Gn.a(), this._captureShaderCompilationTime = !1, this._shaderCompilationTime = new Gn.a(), this._onBeginFrameObserver = null, this._onEndFrameObserver = null, this._onBeforeShaderCompilationObserver = null, this._onAfterShaderCompilationObserver = null;
+ }
+ return Object.defineProperty(r.prototype, "gpuFrameTimeCounter", { get: function() {
+ return this._gpuFrameTime;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "captureGPUFrameTime", { get: function() {
+ return this._captureGPUFrameTime;
+ }, set: function(t) {
+ var e = this;
+ t !== this._captureGPUFrameTime && (this._captureGPUFrameTime = t, t ? (this._onBeginFrameObserver = this.engine.onBeginFrameObservable.add(function() {
+ e._gpuFrameTimeToken || (e._gpuFrameTimeToken = e.engine.startTimeQuery());
+ }), this._onEndFrameObserver = this.engine.onEndFrameObservable.add(function() {
+ if (e._gpuFrameTimeToken) {
+ var n = e.engine.endTimeQuery(e._gpuFrameTimeToken);
+ n > -1 && (e._gpuFrameTimeToken = null, e._gpuFrameTime.fetchNewFrame(), e._gpuFrameTime.addCount(n, !0));
+ }
+ })) : (this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver), this._onBeginFrameObserver = null, this.engine.onEndFrameObservable.remove(this._onEndFrameObserver), this._onEndFrameObserver = null));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "shaderCompilationTimeCounter", { get: function() {
+ return this._shaderCompilationTime;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "captureShaderCompilationTime", { get: function() {
+ return this._captureShaderCompilationTime;
+ }, set: function(t) {
+ var e = this;
+ t !== this._captureShaderCompilationTime && (this._captureShaderCompilationTime = t, t ? (this._onBeforeShaderCompilationObserver = this.engine.onBeforeShaderCompilationObservable.add(function() {
+ e._shaderCompilationTime.fetchNewFrame(), e._shaderCompilationTime.beginMonitoring();
+ }), this._onAfterShaderCompilationObserver = this.engine.onAfterShaderCompilationObservable.add(function() {
+ e._shaderCompilationTime.endMonitoring();
+ })) : (this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver), this._onBeforeShaderCompilationObserver = null, this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver), this._onAfterShaderCompilationObserver = null));
+ }, enumerable: !1, configurable: !0 }), r.prototype.dispose = function() {
+ this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver), this._onBeginFrameObserver = null, this.engine.onEndFrameObservable.remove(this._onEndFrameObserver), this._onEndFrameObserver = null, this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver), this._onBeforeShaderCompilationObserver = null, this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver), this._onAfterShaderCompilationObserver = null, this.engine = null;
+ }, r;
+ }(), $p = function() {
+ function r(t) {
+ var e = this;
+ this.scene = t, this._captureActiveMeshesEvaluationTime = !1, this._activeMeshesEvaluationTime = new Gn.a(), this._captureRenderTargetsRenderTime = !1, this._renderTargetsRenderTime = new Gn.a(), this._captureFrameTime = !1, this._frameTime = new Gn.a(), this._captureRenderTime = !1, this._renderTime = new Gn.a(), this._captureInterFrameTime = !1, this._interFrameTime = new Gn.a(), this._captureParticlesRenderTime = !1, this._particlesRenderTime = new Gn.a(), this._captureSpritesRenderTime = !1, this._spritesRenderTime = new Gn.a(), this._capturePhysicsTime = !1, this._physicsTime = new Gn.a(), this._captureAnimationsTime = !1, this._animationsTime = new Gn.a(), this._captureCameraRenderTime = !1, this._cameraRenderTime = new Gn.a(), this._onBeforeActiveMeshesEvaluationObserver = null, this._onAfterActiveMeshesEvaluationObserver = null, this._onBeforeRenderTargetsRenderObserver = null, this._onAfterRenderTargetsRenderObserver = null, this._onAfterRenderObserver = null, this._onBeforeDrawPhaseObserver = null, this._onAfterDrawPhaseObserver = null, this._onBeforeAnimationsObserver = null, this._onBeforeParticlesRenderingObserver = null, this._onAfterParticlesRenderingObserver = null, this._onBeforeSpritesRenderingObserver = null, this._onAfterSpritesRenderingObserver = null, this._onBeforePhysicsObserver = null, this._onAfterPhysicsObserver = null, this._onAfterAnimationsObserver = null, this._onBeforeCameraRenderObserver = null, this._onAfterCameraRenderObserver = null, this._onBeforeAnimationsObserver = t.onBeforeAnimationsObservable.add(function() {
+ e._captureActiveMeshesEvaluationTime && e._activeMeshesEvaluationTime.fetchNewFrame(), e._captureRenderTargetsRenderTime && e._renderTargetsRenderTime.fetchNewFrame(), e._captureFrameTime && (Xe.b.StartPerformanceCounter("Scene rendering"), e._frameTime.beginMonitoring()), e._captureInterFrameTime && e._interFrameTime.endMonitoring(), e._captureParticlesRenderTime && e._particlesRenderTime.fetchNewFrame(), e._captureSpritesRenderTime && e._spritesRenderTime.fetchNewFrame(), e._captureAnimationsTime && e._animationsTime.beginMonitoring(), e.scene.getEngine()._drawCalls.fetchNewFrame();
+ }), this._onAfterRenderObserver = t.onAfterRenderObservable.add(function() {
+ e._captureFrameTime && (Xe.b.EndPerformanceCounter("Scene rendering"), e._frameTime.endMonitoring()), e._captureRenderTime && e._renderTime.endMonitoring(!1), e._captureInterFrameTime && e._interFrameTime.beginMonitoring();
+ });
+ }
+ return Object.defineProperty(r.prototype, "activeMeshesEvaluationTimeCounter", { get: function() {
+ return this._activeMeshesEvaluationTime;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "captureActiveMeshesEvaluationTime", { get: function() {
+ return this._captureActiveMeshesEvaluationTime;
+ }, set: function(t) {
+ var e = this;
+ t !== this._captureActiveMeshesEvaluationTime && (this._captureActiveMeshesEvaluationTime = t, t ? (this._onBeforeActiveMeshesEvaluationObserver = this.scene.onBeforeActiveMeshesEvaluationObservable.add(function() {
+ Xe.b.StartPerformanceCounter("Active meshes evaluation"), e._activeMeshesEvaluationTime.beginMonitoring();
+ }), this._onAfterActiveMeshesEvaluationObserver = this.scene.onAfterActiveMeshesEvaluationObservable.add(function() {
+ Xe.b.EndPerformanceCounter("Active meshes evaluation"), e._activeMeshesEvaluationTime.endMonitoring();
+ })) : (this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver), this._onBeforeActiveMeshesEvaluationObserver = null, this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver), this._onAfterActiveMeshesEvaluationObserver = null));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "renderTargetsRenderTimeCounter", { get: function() {
+ return this._renderTargetsRenderTime;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "captureRenderTargetsRenderTime", { get: function() {
+ return this._captureRenderTargetsRenderTime;
+ }, set: function(t) {
+ var e = this;
+ t !== this._captureRenderTargetsRenderTime && (this._captureRenderTargetsRenderTime = t, t ? (this._onBeforeRenderTargetsRenderObserver = this.scene.onBeforeRenderTargetsRenderObservable.add(function() {
+ Xe.b.StartPerformanceCounter("Render targets rendering"), e._renderTargetsRenderTime.beginMonitoring();
+ }), this._onAfterRenderTargetsRenderObserver = this.scene.onAfterRenderTargetsRenderObservable.add(function() {
+ Xe.b.EndPerformanceCounter("Render targets rendering"), e._renderTargetsRenderTime.endMonitoring(!1);
+ })) : (this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver), this._onBeforeRenderTargetsRenderObserver = null, this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver), this._onAfterRenderTargetsRenderObserver = null));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "particlesRenderTimeCounter", { get: function() {
+ return this._particlesRenderTime;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "captureParticlesRenderTime", { get: function() {
+ return this._captureParticlesRenderTime;
+ }, set: function(t) {
+ var e = this;
+ t !== this._captureParticlesRenderTime && (this._captureParticlesRenderTime = t, t ? (this._onBeforeParticlesRenderingObserver = this.scene.onBeforeParticlesRenderingObservable.add(function() {
+ Xe.b.StartPerformanceCounter("Particles"), e._particlesRenderTime.beginMonitoring();
+ }), this._onAfterParticlesRenderingObserver = this.scene.onAfterParticlesRenderingObservable.add(function() {
+ Xe.b.EndPerformanceCounter("Particles"), e._particlesRenderTime.endMonitoring(!1);
+ })) : (this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver), this._onBeforeParticlesRenderingObserver = null, this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver), this._onAfterParticlesRenderingObserver = null));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "spritesRenderTimeCounter", { get: function() {
+ return this._spritesRenderTime;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "captureSpritesRenderTime", { get: function() {
+ return this._captureSpritesRenderTime;
+ }, set: function(t) {
+ var e = this;
+ t !== this._captureSpritesRenderTime && (this._captureSpritesRenderTime = t, this.scene.spriteManagers && (t ? (this._onBeforeSpritesRenderingObserver = this.scene.onBeforeSpritesRenderingObservable.add(function() {
+ Xe.b.StartPerformanceCounter("Sprites"), e._spritesRenderTime.beginMonitoring();
+ }), this._onAfterSpritesRenderingObserver = this.scene.onAfterSpritesRenderingObservable.add(function() {
+ Xe.b.EndPerformanceCounter("Sprites"), e._spritesRenderTime.endMonitoring(!1);
+ })) : (this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver), this._onBeforeSpritesRenderingObserver = null, this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver), this._onAfterSpritesRenderingObserver = null)));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "physicsTimeCounter", { get: function() {
+ return this._physicsTime;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "capturePhysicsTime", { get: function() {
+ return this._capturePhysicsTime;
+ }, set: function(t) {
+ var e = this;
+ t !== this._capturePhysicsTime && this.scene.onBeforePhysicsObservable && (this._capturePhysicsTime = t, t ? (this._onBeforePhysicsObserver = this.scene.onBeforePhysicsObservable.add(function() {
+ Xe.b.StartPerformanceCounter("Physics"), e._physicsTime.beginMonitoring();
+ }), this._onAfterPhysicsObserver = this.scene.onAfterPhysicsObservable.add(function() {
+ Xe.b.EndPerformanceCounter("Physics"), e._physicsTime.endMonitoring();
+ })) : (this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver), this._onBeforePhysicsObserver = null, this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver), this._onAfterPhysicsObserver = null));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "animationsTimeCounter", { get: function() {
+ return this._animationsTime;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "captureAnimationsTime", { get: function() {
+ return this._captureAnimationsTime;
+ }, set: function(t) {
+ var e = this;
+ t !== this._captureAnimationsTime && (this._captureAnimationsTime = t, t ? this._onAfterAnimationsObserver = this.scene.onAfterAnimationsObservable.add(function() {
+ e._animationsTime.endMonitoring();
+ }) : (this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver), this._onAfterAnimationsObserver = null));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "frameTimeCounter", { get: function() {
+ return this._frameTime;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "captureFrameTime", { get: function() {
+ return this._captureFrameTime;
+ }, set: function(t) {
+ this._captureFrameTime = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "interFrameTimeCounter", { get: function() {
+ return this._interFrameTime;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "captureInterFrameTime", { get: function() {
+ return this._captureInterFrameTime;
+ }, set: function(t) {
+ this._captureInterFrameTime = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "renderTimeCounter", { get: function() {
+ return this._renderTime;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "captureRenderTime", { get: function() {
+ return this._captureRenderTime;
+ }, set: function(t) {
+ var e = this;
+ t !== this._captureRenderTime && (this._captureRenderTime = t, t ? (this._onBeforeDrawPhaseObserver = this.scene.onBeforeDrawPhaseObservable.add(function() {
+ e._renderTime.beginMonitoring(), Xe.b.StartPerformanceCounter("Main render");
+ }), this._onAfterDrawPhaseObserver = this.scene.onAfterDrawPhaseObservable.add(function() {
+ e._renderTime.endMonitoring(!1), Xe.b.EndPerformanceCounter("Main render");
+ })) : (this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver), this._onBeforeDrawPhaseObserver = null, this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver), this._onAfterDrawPhaseObserver = null));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "cameraRenderTimeCounter", { get: function() {
+ return this._cameraRenderTime;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "captureCameraRenderTime", { get: function() {
+ return this._captureCameraRenderTime;
+ }, set: function(t) {
+ var e = this;
+ t !== this._captureCameraRenderTime && (this._captureCameraRenderTime = t, t ? (this._onBeforeCameraRenderObserver = this.scene.onBeforeCameraRenderObservable.add(function(n) {
+ e._cameraRenderTime.beginMonitoring(), Xe.b.StartPerformanceCounter("Rendering camera " + n.name);
+ }), this._onAfterCameraRenderObserver = this.scene.onAfterCameraRenderObservable.add(function(n) {
+ e._cameraRenderTime.endMonitoring(!1), Xe.b.EndPerformanceCounter("Rendering camera " + n.name);
+ })) : (this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver), this._onBeforeCameraRenderObserver = null, this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver), this._onAfterCameraRenderObserver = null));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "drawCallsCounter", { get: function() {
+ return this.scene.getEngine()._drawCalls;
+ }, enumerable: !1, configurable: !0 }), r.prototype.dispose = function() {
+ this.scene.onAfterRenderObservable.remove(this._onAfterRenderObserver), this._onAfterRenderObserver = null, this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver), this._onBeforeActiveMeshesEvaluationObserver = null, this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver), this._onAfterActiveMeshesEvaluationObserver = null, this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver), this._onBeforeRenderTargetsRenderObserver = null, this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver), this._onAfterRenderTargetsRenderObserver = null, this.scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver), this._onBeforeAnimationsObserver = null, this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver), this._onBeforeParticlesRenderingObserver = null, this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver), this._onAfterParticlesRenderingObserver = null, this._onBeforeSpritesRenderingObserver && (this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver), this._onBeforeSpritesRenderingObserver = null), this._onAfterSpritesRenderingObserver && (this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver), this._onAfterSpritesRenderingObserver = null), this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver), this._onBeforeDrawPhaseObserver = null, this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver), this._onAfterDrawPhaseObserver = null, this._onBeforePhysicsObserver && (this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver), this._onBeforePhysicsObserver = null), this._onAfterPhysicsObserver && (this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver), this._onAfterPhysicsObserver = null), this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver), this._onAfterAnimationsObserver = null, this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver), this._onBeforeCameraRenderObserver = null, this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver), this._onAfterCameraRenderObserver = null, this.scene = null;
+ }, r;
+ }(), e_ = `#ifdef DIFFUSE
+varying vec2 vUVDiffuse;
+uniform sampler2D diffuseSampler;
+#endif
+#ifdef OPACITY
+varying vec2 vUVOpacity;
+uniform sampler2D opacitySampler;
+uniform float opacityIntensity;
+#endif
+#ifdef EMISSIVE
+varying vec2 vUVEmissive;
+uniform sampler2D emissiveSampler;
+#endif
+#ifdef VERTEXALPHA
+varying vec4 vColor;
+#endif
+uniform vec4 glowColor;
+void main(void)
+{
+vec4 finalColor=glowColor;
+
+#ifdef DIFFUSE
+vec4 albedoTexture=texture2D(diffuseSampler,vUVDiffuse);
+#ifdef GLOW
+
+finalColor.a*=albedoTexture.a;
+#endif
+#ifdef HIGHLIGHT
+
+finalColor.a=albedoTexture.a;
+#endif
+#endif
+#ifdef OPACITY
+vec4 opacityMap=texture2D(opacitySampler,vUVOpacity);
+#ifdef OPACITYRGB
+finalColor.a*=getLuminance(opacityMap.rgb);
+#else
+finalColor.a*=opacityMap.a;
+#endif
+finalColor.a*=opacityIntensity;
+#endif
+#ifdef VERTEXALPHA
+finalColor.a*=vColor.a;
+#endif
+#ifdef ALPHATEST
+if (finalColor.a
+#include
+#include[0..maxSimultaneousMorphTargets]
+
+#include
+uniform mat4 viewProjection;
+varying vec4 vPosition;
+#ifdef UV1
+attribute vec2 uv;
+#endif
+#ifdef UV2
+attribute vec2 uv2;
+#endif
+#ifdef DIFFUSE
+varying vec2 vUVDiffuse;
+uniform mat4 diffuseMatrix;
+#endif
+#ifdef OPACITY
+varying vec2 vUVOpacity;
+uniform mat4 opacityMatrix;
+#endif
+#ifdef EMISSIVE
+varying vec2 vUVEmissive;
+uniform mat4 emissiveMatrix;
+#endif
+#ifdef VERTEXALPHA
+attribute vec4 color;
+varying vec4 vColor;
+#endif
+void main(void)
+{
+vec3 positionUpdated=position;
+#ifdef UV1
+vec2 uvUpdated=uv;
+#endif
+#include[0..maxSimultaneousMorphTargets]
+#include
+#include
+#ifdef CUBEMAP
+vPosition=finalWorld*vec4(positionUpdated,1.0);
+gl_Position=viewProjection*finalWorld*vec4(position,1.0);
+#else
+vPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);
+gl_Position=vPosition;
+#endif
+#ifdef DIFFUSE
+#ifdef DIFFUSEUV1
+vUVDiffuse=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));
+#endif
+#ifdef DIFFUSEUV2
+vUVDiffuse=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
+#endif
+#endif
+#ifdef OPACITY
+#ifdef OPACITYUV1
+vUVOpacity=vec2(opacityMatrix*vec4(uvUpdated,1.0,0.0));
+#endif
+#ifdef OPACITYUV2
+vUVOpacity=vec2(opacityMatrix*vec4(uv2,1.0,0.0));
+#endif
+#endif
+#ifdef EMISSIVE
+#ifdef EMISSIVEUV1
+vUVEmissive=vec2(emissiveMatrix*vec4(uvUpdated,1.0,0.0));
+#endif
+#ifdef EMISSIVEUV2
+vUVEmissive=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));
+#endif
+#endif
+#ifdef VERTEXALPHA
+vColor=color;
+#endif
+}`;
+ ze.a.ShadersStore.glowMapGenerationVertexShader = t_;
+ var no = function() {
+ function r(t, e) {
+ this._vertexBuffers = {}, this._maxSize = 0, this._mainTextureDesiredSize = { width: 0, height: 0 }, this._shouldRender = !0, this._postProcesses = [], this._textures = [], this._emissiveTextureAndColor = { texture: null, color: new I.b() }, this.neutralColor = new I.b(), this.isEnabled = !0, this.disableBoundingBoxesFromEffectLayer = !1, this.onDisposeObservable = new C.c(), this.onBeforeRenderMainTextureObservable = new C.c(), this.onBeforeComposeObservable = new C.c(), this.onBeforeRenderMeshToEffect = new C.c(), this.onAfterRenderMeshToEffect = new C.c(), this.onAfterComposeObservable = new C.c(), this.onSizeChangedObservable = new C.c(), this.name = t, this._scene = e || te.a.LastCreatedScene, r._SceneComponentInitialization(this._scene), this._engine = this._scene.getEngine(), this._maxSize = this._engine.getCaps().maxTextureSize, this._scene.effectLayers.push(this), this._generateIndexBuffer(), this._generateVertexBuffer();
+ }
+ return Object.defineProperty(r.prototype, "camera", { get: function() {
+ return this._effectLayerOptions.camera;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "renderingGroupId", { get: function() {
+ return this._effectLayerOptions.renderingGroupId;
+ }, set: function(t) {
+ this._effectLayerOptions.renderingGroupId = t;
+ }, enumerable: !1, configurable: !0 }), r.prototype._init = function(t) {
+ this._effectLayerOptions = Object(c.a)({ mainTextureRatio: 0.5, alphaBlendingMode: h.a.ALPHA_COMBINE, camera: null, renderingGroupId: -1 }, t), this._setMainTextureSize(), this._createMainTexture(), this._createTextureAndPostProcesses(), this._mergeEffect = this._createMergeEffect();
+ }, r.prototype._generateIndexBuffer = function() {
+ var t = [];
+ t.push(0), t.push(1), t.push(2), t.push(0), t.push(2), t.push(3), this._indexBuffer = this._engine.createIndexBuffer(t);
+ }, r.prototype._generateVertexBuffer = function() {
+ var t = [];
+ t.push(1, 1), t.push(-1, 1), t.push(-1, -1), t.push(1, -1);
+ var e = new Oe.b(this._engine, t, Oe.b.PositionKind, !1, !1, 2);
+ this._vertexBuffers[Oe.b.PositionKind] = e;
+ }, r.prototype._setMainTextureSize = function() {
+ this._effectLayerOptions.mainTextureFixedSize ? (this._mainTextureDesiredSize.width = this._effectLayerOptions.mainTextureFixedSize, this._mainTextureDesiredSize.height = this._effectLayerOptions.mainTextureFixedSize) : (this._mainTextureDesiredSize.width = this._engine.getRenderWidth() * this._effectLayerOptions.mainTextureRatio, this._mainTextureDesiredSize.height = this._engine.getRenderHeight() * this._effectLayerOptions.mainTextureRatio, this._mainTextureDesiredSize.width = this._engine.needPOTTextures ? Ue.a.GetExponentOfTwo(this._mainTextureDesiredSize.width, this._maxSize) : this._mainTextureDesiredSize.width, this._mainTextureDesiredSize.height = this._engine.needPOTTextures ? Ue.a.GetExponentOfTwo(this._mainTextureDesiredSize.height, this._maxSize) : this._mainTextureDesiredSize.height), this._mainTextureDesiredSize.width = Math.floor(this._mainTextureDesiredSize.width), this._mainTextureDesiredSize.height = Math.floor(this._mainTextureDesiredSize.height);
+ }, r.prototype._createMainTexture = function() {
+ var t = this;
+ this._mainTexture = new on("HighlightLayerMainRTT", { width: this._mainTextureDesiredSize.width, height: this._mainTextureDesiredSize.height }, this._scene, !1, !0, h.a.TEXTURETYPE_UNSIGNED_INT), this._mainTexture.activeCamera = this._effectLayerOptions.camera, this._mainTexture.wrapU = Ne.a.CLAMP_ADDRESSMODE, this._mainTexture.wrapV = Ne.a.CLAMP_ADDRESSMODE, this._mainTexture.anisotropicFilteringLevel = 1, this._mainTexture.updateSamplingMode(Ne.a.BILINEAR_SAMPLINGMODE), this._mainTexture.renderParticles = !1, this._mainTexture.renderList = null, this._mainTexture.ignoreCameraViewport = !0, this._mainTexture.customRenderFunction = function(n, i, o, a) {
+ var s;
+ t.onBeforeRenderMainTextureObservable.notifyObservers(t);
+ var d = t._scene.getEngine();
+ if (a.length) {
+ for (d.setColorWrite(!1), s = 0; s < a.length; s++)
+ t._renderSubMesh(a.data[s]);
+ d.setColorWrite(!0);
+ }
+ for (s = 0; s < n.length; s++)
+ t._renderSubMesh(n.data[s]);
+ for (s = 0; s < i.length; s++)
+ t._renderSubMesh(i.data[s]);
+ var p = d.getAlphaMode();
+ for (s = 0; s < o.length; s++)
+ t._renderSubMesh(o.data[s], !0);
+ d.setAlphaMode(p);
+ }, this._mainTexture.onClearObservable.add(function(n) {
+ n.clear(t.neutralColor, !0, !0, !0);
+ });
+ var e = this._scene.getBoundingBoxRenderer().enabled;
+ this._mainTexture.onBeforeBindObservable.add(function() {
+ t._scene.getBoundingBoxRenderer().enabled = !t.disableBoundingBoxesFromEffectLayer && e;
+ }), this._mainTexture.onAfterUnbindObservable.add(function() {
+ t._scene.getBoundingBoxRenderer().enabled = e;
+ });
+ }, r.prototype._addCustomEffectDefines = function(t) {
+ }, r.prototype._isReady = function(t, e, n) {
+ var i = t.getMaterial();
+ if (!i || !i.isReadyForSubMesh(t.getMesh(), t, e))
+ return !1;
+ var o = [], a = [Oe.b.PositionKind], s = t.getMesh(), d = !1, p = !1;
+ if (i) {
+ var y = i.needAlphaTesting(), P = i.getAlphaTestTexture(), R = P && P.hasAlpha && (i.useAlphaFromDiffuseTexture || i._useAlphaFromAlbedoTexture);
+ P && (y || R) && (o.push("#define DIFFUSE"), s.isVerticesDataPresent(Oe.b.UV2Kind) && P.coordinatesIndex === 1 ? (o.push("#define DIFFUSEUV2"), p = !0) : s.isVerticesDataPresent(Oe.b.UVKind) && (o.push("#define DIFFUSEUV1"), d = !0), y && (o.push("#define ALPHATEST"), o.push("#define ALPHATESTVALUE 0.4")));
+ var B = i.opacityTexture;
+ B && (o.push("#define OPACITY"), s.isVerticesDataPresent(Oe.b.UV2Kind) && B.coordinatesIndex === 1 ? (o.push("#define OPACITYUV2"), p = !0) : s.isVerticesDataPresent(Oe.b.UVKind) && (o.push("#define OPACITYUV1"), d = !0));
+ }
+ n && (o.push("#define EMISSIVE"), s.isVerticesDataPresent(Oe.b.UV2Kind) && n.coordinatesIndex === 1 ? (o.push("#define EMISSIVEUV2"), p = !0) : s.isVerticesDataPresent(Oe.b.UVKind) && (o.push("#define EMISSIVEUV1"), d = !0)), s.isVerticesDataPresent(Oe.b.ColorKind) && s.hasVertexAlpha && (a.push(Oe.b.ColorKind), o.push("#define VERTEXALPHA")), d && (a.push(Oe.b.UVKind), o.push("#define UV1")), p && (a.push(Oe.b.UV2Kind), o.push("#define UV2"));
+ var F = new _r.a();
+ if (s.useBones && s.computeBonesUsingShaders) {
+ a.push(Oe.b.MatricesIndicesKind), a.push(Oe.b.MatricesWeightsKind), s.numBoneInfluencers > 4 && (a.push(Oe.b.MatricesIndicesExtraKind), a.push(Oe.b.MatricesWeightsExtraKind)), o.push("#define NUM_BONE_INFLUENCERS " + s.numBoneInfluencers);
+ var z = s.skeleton;
+ z && z.isUsingTextureForMatrices ? o.push("#define BONETEXTURE") : o.push("#define BonesPerMesh " + (z ? z.bones.length + 1 : 0)), s.numBoneInfluencers > 0 && F.addCPUSkinningFallback(0, s);
+ } else
+ o.push("#define NUM_BONE_INFLUENCERS 0");
+ var J = s.morphTargetManager, ie = 0;
+ J && J.numInfluencers > 0 && (o.push("#define MORPHTARGETS"), ie = J.numInfluencers, o.push("#define NUM_MORPH_INFLUENCERS " + ie), $e.a.PrepareAttributesForMorphTargetsInfluencers(a, s, ie)), e && (o.push("#define INSTANCES"), $e.a.PushAttributesForInstances(a), t.getRenderingMesh().hasThinInstances && o.push("#define THIN_INSTANCES")), this._addCustomEffectDefines(o);
+ var se = o.join(`
+`);
+ return this._cachedDefines !== se && (this._cachedDefines = se, this._effectLayerMapGenerationEffect = this._scene.getEngine().createEffect("glowMapGeneration", a, ["world", "mBones", "viewProjection", "glowColor", "morphTargetInfluences", "boneTextureWidth", "diffuseMatrix", "emissiveMatrix", "opacityMatrix", "opacityIntensity"], ["diffuseSampler", "emissiveSampler", "opacitySampler", "boneSampler"], se, F, void 0, void 0, { maxSimultaneousMorphTargets: ie })), this._effectLayerMapGenerationEffect.isReady();
+ }, r.prototype.render = function() {
+ var t = this._mergeEffect;
+ if (t.isReady()) {
+ for (var e = 0; e < this._postProcesses.length; e++)
+ if (!this._postProcesses[e].isReady())
+ return;
+ var n = this._scene.getEngine();
+ this.onBeforeComposeObservable.notifyObservers(this), n.enableEffect(t), n.setState(!1), n.bindBuffers(this._vertexBuffers, this._indexBuffer, t);
+ var i = n.getAlphaMode();
+ n.setAlphaMode(this._effectLayerOptions.alphaBlendingMode), this._internalRender(t), n.setAlphaMode(i), this.onAfterComposeObservable.notifyObservers(this);
+ var o = this._mainTexture.getSize();
+ this._setMainTextureSize(), o.width === this._mainTextureDesiredSize.width && o.height === this._mainTextureDesiredSize.height || (this.onSizeChangedObservable.notifyObservers(this), this._disposeTextureAndPostProcesses(), this._createMainTexture(), this._createTextureAndPostProcesses());
+ }
+ }, r.prototype.hasMesh = function(t) {
+ return this.renderingGroupId === -1 || t.renderingGroupId === this.renderingGroupId;
+ }, r.prototype.shouldRender = function() {
+ return this.isEnabled && this._shouldRender;
+ }, r.prototype._shouldRenderMesh = function(t) {
+ return !0;
+ }, r.prototype._canRenderMesh = function(t, e) {
+ return !e.needAlphaBlendingForMesh(t);
+ }, r.prototype._shouldRenderEmissiveTextureForMesh = function() {
+ return !0;
+ }, r.prototype._renderSubMesh = function(t, e) {
+ var n, i = this;
+ if (e === void 0 && (e = !1), this.shouldRender()) {
+ var o = t.getMaterial(), a = t.getMesh(), s = t.getReplacementMesh(), d = t.getRenderingMesh(), p = t.getEffectiveMesh(), y = this._scene, P = y.getEngine();
+ if (p._internalAbstractMeshDataInfo._isActiveIntermediate = !1, o && this._canRenderMesh(d, o)) {
+ var R = (n = d.overrideMaterialSideOrientation) !== null && n !== void 0 ? n : o.sideOrientation;
+ d._getWorldMatrixDeterminant() < 0 && (R = R === zt.a.ClockWiseSideOrientation ? zt.a.CounterClockWiseSideOrientation : zt.a.ClockWiseSideOrientation);
+ var B = R === zt.a.ClockWiseSideOrientation;
+ P.setState(o.backFaceCulling, o.zOffset, void 0, B);
+ var F = d._getInstancesRenderList(t._id, !!s);
+ if (!F.mustReturn && this._shouldRenderMesh(d)) {
+ var z = F.hardwareInstancedRendering[t._id] || d.hasThinInstances;
+ if (this._setEmissiveTextureAndColor(d, t, o), this.onBeforeRenderMeshToEffect.notifyObservers(a), this._useMeshMaterial(d))
+ d.render(t, z, s || void 0);
+ else if (this._isReady(t, z, this._emissiveTextureAndColor.texture)) {
+ P.enableEffect(this._effectLayerMapGenerationEffect), d._bind(t, this._effectLayerMapGenerationEffect, zt.a.TriangleFillMode), this._effectLayerMapGenerationEffect.setMatrix("viewProjection", y.getTransformMatrix()), this._effectLayerMapGenerationEffect.setMatrix("world", p.getWorldMatrix()), this._effectLayerMapGenerationEffect.setFloat4("glowColor", this._emissiveTextureAndColor.color.r, this._emissiveTextureAndColor.color.g, this._emissiveTextureAndColor.color.b, this._emissiveTextureAndColor.color.a);
+ var J = o.needAlphaTesting(), ie = o.getAlphaTestTexture(), se = ie && ie.hasAlpha && (o.useAlphaFromDiffuseTexture || o._useAlphaFromAlbedoTexture);
+ ie && (J || se) && (this._effectLayerMapGenerationEffect.setTexture("diffuseSampler", ie), (ce = ie.getTextureMatrix()) && this._effectLayerMapGenerationEffect.setMatrix("diffuseMatrix", ce));
+ var ce, ue = o.opacityTexture;
+ if (ue && (this._effectLayerMapGenerationEffect.setTexture("opacitySampler", ue), this._effectLayerMapGenerationEffect.setFloat("opacityIntensity", ue.level), (ce = ue.getTextureMatrix()) && this._effectLayerMapGenerationEffect.setMatrix("opacityMatrix", ce)), this._emissiveTextureAndColor.texture && (this._effectLayerMapGenerationEffect.setTexture("emissiveSampler", this._emissiveTextureAndColor.texture), this._effectLayerMapGenerationEffect.setMatrix("emissiveMatrix", this._emissiveTextureAndColor.texture.getTextureMatrix())), d.useBones && d.computeBonesUsingShaders && d.skeleton) {
+ var fe = d.skeleton;
+ if (fe.isUsingTextureForMatrices) {
+ var ve = fe.getTransformMatrixTexture(d);
+ if (!ve)
+ return;
+ this._effectLayerMapGenerationEffect.setTexture("boneSampler", ve), this._effectLayerMapGenerationEffect.setFloat("boneTextureWidth", 4 * (fe.bones.length + 1));
+ } else
+ this._effectLayerMapGenerationEffect.setMatrices("mBones", fe.getTransformMatrices(d));
+ }
+ $e.a.BindMorphTargetParameters(d, this._effectLayerMapGenerationEffect), e && P.setAlphaMode(o.alphaMode), d._processRendering(p, t, this._effectLayerMapGenerationEffect, o.fillMode, F, z, function(Te, Re) {
+ return i._effectLayerMapGenerationEffect.setMatrix("world", Re);
+ });
+ } else
+ this._mainTexture.resetRefreshCounter();
+ this.onAfterRenderMeshToEffect.notifyObservers(a);
+ }
+ }
+ }
+ }, r.prototype._useMeshMaterial = function(t) {
+ return !1;
+ }, r.prototype._rebuild = function() {
+ var t = this._vertexBuffers[Oe.b.PositionKind];
+ t && t._rebuild(), this._generateIndexBuffer();
+ }, r.prototype._disposeTextureAndPostProcesses = function() {
+ this._mainTexture.dispose();
+ for (var t = 0; t < this._postProcesses.length; t++)
+ this._postProcesses[t] && this._postProcesses[t].dispose();
+ for (this._postProcesses = [], t = 0; t < this._textures.length; t++)
+ this._textures[t] && this._textures[t].dispose();
+ this._textures = [];
+ }, r.prototype.dispose = function() {
+ var t = this._vertexBuffers[Oe.b.PositionKind];
+ t && (t.dispose(), this._vertexBuffers[Oe.b.PositionKind] = null), this._indexBuffer && (this._scene.getEngine()._releaseBuffer(this._indexBuffer), this._indexBuffer = null), this._disposeTextureAndPostProcesses();
+ var e = this._scene.effectLayers.indexOf(this, 0);
+ e > -1 && this._scene.effectLayers.splice(e, 1), this.onDisposeObservable.notifyObservers(this), this.onDisposeObservable.clear(), this.onBeforeRenderMainTextureObservable.clear(), this.onBeforeComposeObservable.clear(), this.onBeforeRenderMeshToEffect.clear(), this.onAfterRenderMeshToEffect.clear(), this.onAfterComposeObservable.clear(), this.onSizeChangedObservable.clear();
+ }, r.prototype.getClassName = function() {
+ return "EffectLayer";
+ }, r.Parse = function(t, e, n) {
+ return Xe.b.Instantiate(t.customType).Parse(t, e, n);
+ }, r._SceneComponentInitialization = function(t) {
+ throw En.a.WarnImport("EffectLayerSceneComponent");
+ }, Object(c.c)([Object(L.c)()], r.prototype, "name", void 0), Object(c.c)([Object(L.f)()], r.prototype, "neutralColor", void 0), Object(c.c)([Object(L.c)()], r.prototype, "isEnabled", void 0), Object(c.c)([Object(L.d)()], r.prototype, "camera", null), Object(c.c)([Object(L.c)()], r.prototype, "renderingGroupId", null), Object(c.c)([Object(L.c)()], r.prototype, "disableBoundingBoxesFromEffectLayer", void 0), r;
+ }();
+ V.a.AddParser(ot.a.NAME_EFFECTLAYER, function(r, t, e, n) {
+ if (r.effectLayers) {
+ e.effectLayers || (e.effectLayers = new Array());
+ for (var i = 0; i < r.effectLayers.length; i++) {
+ var o = no.Parse(r.effectLayers[i], t, n);
+ e.effectLayers.push(o);
+ }
+ }
+ }), V.a.prototype.removeEffectLayer = function(r) {
+ var t = this.effectLayers.indexOf(r);
+ return t !== -1 && this.effectLayers.splice(t, 1), t;
+ }, V.a.prototype.addEffectLayer = function(r) {
+ this.effectLayers.push(r);
+ };
+ var du = function() {
+ function r(t) {
+ this.name = ot.a.NAME_EFFECTLAYER, this._renderEffects = !1, this._needStencil = !1, this._previousStencilState = !1, this.scene = t, this._engine = t.getEngine(), t.effectLayers = new Array();
+ }
+ return r.prototype.register = function() {
+ this.scene._isReadyForMeshStage.registerStep(ot.a.STEP_ISREADYFORMESH_EFFECTLAYER, this, this._isReadyForMesh), this.scene._cameraDrawRenderTargetStage.registerStep(ot.a.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER, this, this._renderMainTexture), this.scene._beforeCameraDrawStage.registerStep(ot.a.STEP_BEFORECAMERADRAW_EFFECTLAYER, this, this._setStencil), this.scene._afterRenderingGroupDrawStage.registerStep(ot.a.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW, this, this._drawRenderingGroup), this.scene._afterCameraDrawStage.registerStep(ot.a.STEP_AFTERCAMERADRAW_EFFECTLAYER, this, this._setStencilBack), this.scene._afterCameraDrawStage.registerStep(ot.a.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW, this, this._drawCamera);
+ }, r.prototype.rebuild = function() {
+ for (var t = 0, e = this.scene.effectLayers; t < e.length; t++)
+ e[t]._rebuild();
+ }, r.prototype.serialize = function(t) {
+ t.effectLayers = [];
+ for (var e = 0, n = this.scene.effectLayers; e < n.length; e++) {
+ var i = n[e];
+ i.serialize && t.effectLayers.push(i.serialize());
+ }
+ }, r.prototype.addFromContainer = function(t) {
+ var e = this;
+ t.effectLayers && t.effectLayers.forEach(function(n) {
+ e.scene.addEffectLayer(n);
+ });
+ }, r.prototype.removeFromContainer = function(t, e) {
+ var n = this;
+ t.effectLayers && t.effectLayers.forEach(function(i) {
+ n.scene.removeEffectLayer(i), e && i.dispose();
+ });
+ }, r.prototype.dispose = function() {
+ for (var t = this.scene.effectLayers; t.length; )
+ t[0].dispose();
+ }, r.prototype._isReadyForMesh = function(t, e) {
+ for (var n = 0, i = this.scene.effectLayers; n < i.length; n++) {
+ var o = i[n];
+ if (o.hasMesh(t))
+ for (var a = 0, s = t.subMeshes; a < s.length; a++) {
+ var d = s[a];
+ if (!o.isReady(d, e))
+ return !1;
+ }
+ }
+ return !0;
+ }, r.prototype._renderMainTexture = function(t) {
+ this._renderEffects = !1, this._needStencil = !1;
+ var e = !1, n = this.scene.effectLayers;
+ if (n && n.length > 0) {
+ this._previousStencilState = this._engine.getStencilBuffer();
+ for (var i = 0, o = n; i < o.length; i++) {
+ var a = o[i];
+ if (a.shouldRender() && (!a.camera || a.camera.cameraRigMode === _t.a.RIG_MODE_NONE && t === a.camera || a.camera.cameraRigMode !== _t.a.RIG_MODE_NONE && a.camera._rigCameras.indexOf(t) > -1)) {
+ this._renderEffects = !0, this._needStencil = this._needStencil || a.needStencil();
+ var s = a._mainTexture;
+ s._shouldRender() && (this.scene.incrementRenderId(), s.render(!1, !1), e = !0);
+ }
+ }
+ this.scene.incrementRenderId();
+ }
+ return e;
+ }, r.prototype._setStencil = function() {
+ this._needStencil && this._engine.setStencilBuffer(!0);
+ }, r.prototype._setStencilBack = function() {
+ this._needStencil && this._engine.setStencilBuffer(this._previousStencilState);
+ }, r.prototype._draw = function(t) {
+ if (this._renderEffects) {
+ this._engine.setDepthBuffer(!1);
+ for (var e = this.scene.effectLayers, n = 0; n < e.length; n++) {
+ var i = e[n];
+ i.renderingGroupId === t && i.shouldRender() && i.render();
+ }
+ this._engine.setDepthBuffer(!0);
+ }
+ }, r.prototype._drawCamera = function() {
+ this._renderEffects && this._draw(-1);
+ }, r.prototype._drawRenderingGroup = function(t) {
+ !this.scene._isInIntermediateRendering() && this._renderEffects && this._draw(t);
+ }, r;
+ }();
+ no._SceneComponentInitialization = function(r) {
+ var t = r._getComponent(ot.a.NAME_EFFECTLAYER);
+ t || (t = new du(r), r._addComponent(t));
+ };
+ var n_ = `
+varying vec2 vUV;
+uniform sampler2D textureSampler;
+#ifdef EMISSIVE
+uniform sampler2D textureSampler2;
+#endif
+
+uniform float offset;
+void main(void) {
+vec4 baseColor=texture2D(textureSampler,vUV);
+#ifdef EMISSIVE
+baseColor+=texture2D(textureSampler2,vUV);
+baseColor*=offset;
+#else
+baseColor.a=abs(offset-baseColor.a);
+#ifdef STROKE
+float alpha=smoothstep(.0,.1,baseColor.a);
+baseColor.a=alpha;
+baseColor.rgb=baseColor.rgb*alpha;
+#endif
+#endif
+gl_FragColor=baseColor;
+}`;
+ ze.a.ShadersStore.glowMapMergePixelShader = n_;
+ var i_ = `
+attribute vec2 position;
+
+varying vec2 vUV;
+const vec2 madd=vec2(0.5,0.5);
+void main(void) {
+vUV=position*madd+madd;
+gl_Position=vec4(position,0.0,1.0);
+}`;
+ ze.a.ShadersStore.glowMapMergeVertexShader = i_, V.a.prototype.getGlowLayerByName = function(r) {
+ for (var t = 0; t < this.effectLayers.length; t++)
+ if (this.effectLayers[t].name === r && this.effectLayers[t].getEffectName() === Ko.EffectName)
+ return this.effectLayers[t];
+ return null;
+ };
+ var Ko = function(r) {
+ function t(e, n, i) {
+ var o = r.call(this, e, n) || this;
+ return o._intensity = 1, o._includedOnlyMeshes = [], o._excludedMeshes = [], o._meshesUsingTheirOwnMaterials = [], o.neutralColor = new I.b(0, 0, 0, 1), o._options = Object(c.a)({ mainTextureRatio: t.DefaultTextureRatio, blurKernelSize: 32, mainTextureFixedSize: void 0, camera: null, mainTextureSamples: 1, renderingGroupId: -1 }, i), o._init({ alphaBlendingMode: h.a.ALPHA_ADD, camera: o._options.camera, mainTextureFixedSize: o._options.mainTextureFixedSize, mainTextureRatio: o._options.mainTextureRatio, renderingGroupId: o._options.renderingGroupId }), o;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "blurKernelSize", { get: function() {
+ return this._horizontalBlurPostprocess1.kernel;
+ }, set: function(e) {
+ this._horizontalBlurPostprocess1.kernel = e, this._verticalBlurPostprocess1.kernel = e, this._horizontalBlurPostprocess2.kernel = e, this._verticalBlurPostprocess2.kernel = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "intensity", { get: function() {
+ return this._intensity;
+ }, set: function(e) {
+ this._intensity = e;
+ }, enumerable: !1, configurable: !0 }), t.prototype.getEffectName = function() {
+ return t.EffectName;
+ }, t.prototype._createMergeEffect = function() {
+ return this._engine.createEffect("glowMapMerge", [Oe.b.PositionKind], ["offset"], ["textureSampler", "textureSampler2"], `#define EMISSIVE
+`);
+ }, t.prototype._createTextureAndPostProcesses = function() {
+ var e = this, n = this._mainTextureDesiredSize.width, i = this._mainTextureDesiredSize.height;
+ n = this._engine.needPOTTextures ? Ue.a.GetExponentOfTwo(n, this._maxSize) : n, i = this._engine.needPOTTextures ? Ue.a.GetExponentOfTwo(i, this._maxSize) : i;
+ var o = 0;
+ o = this._engine.getCaps().textureHalfFloatRender ? h.a.TEXTURETYPE_HALF_FLOAT : h.a.TEXTURETYPE_UNSIGNED_INT, this._blurTexture1 = new on("GlowLayerBlurRTT", { width: n, height: i }, this._scene, !1, !0, o), this._blurTexture1.wrapU = Ne.a.CLAMP_ADDRESSMODE, this._blurTexture1.wrapV = Ne.a.CLAMP_ADDRESSMODE, this._blurTexture1.updateSamplingMode(Ne.a.BILINEAR_SAMPLINGMODE), this._blurTexture1.renderParticles = !1, this._blurTexture1.ignoreCameraViewport = !0;
+ var a = Math.floor(n / 2), s = Math.floor(i / 2);
+ this._blurTexture2 = new on("GlowLayerBlurRTT2", { width: a, height: s }, this._scene, !1, !0, o), this._blurTexture2.wrapU = Ne.a.CLAMP_ADDRESSMODE, this._blurTexture2.wrapV = Ne.a.CLAMP_ADDRESSMODE, this._blurTexture2.updateSamplingMode(Ne.a.BILINEAR_SAMPLINGMODE), this._blurTexture2.renderParticles = !1, this._blurTexture2.ignoreCameraViewport = !0, this._textures = [this._blurTexture1, this._blurTexture2], this._horizontalBlurPostprocess1 = new _n("GlowLayerHBP1", new u.d(1, 0), this._options.blurKernelSize / 2, { width: n, height: i }, null, Ne.a.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1, o), this._horizontalBlurPostprocess1.width = n, this._horizontalBlurPostprocess1.height = i, this._horizontalBlurPostprocess1.onApplyObservable.add(function(d) {
+ d.setTexture("textureSampler", e._mainTexture);
+ }), this._verticalBlurPostprocess1 = new _n("GlowLayerVBP1", new u.d(0, 1), this._options.blurKernelSize / 2, { width: n, height: i }, null, Ne.a.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1, o), this._horizontalBlurPostprocess2 = new _n("GlowLayerHBP2", new u.d(1, 0), this._options.blurKernelSize / 2, { width: a, height: s }, null, Ne.a.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1, o), this._horizontalBlurPostprocess2.width = a, this._horizontalBlurPostprocess2.height = s, this._horizontalBlurPostprocess2.onApplyObservable.add(function(d) {
+ d.setTexture("textureSampler", e._blurTexture1);
+ }), this._verticalBlurPostprocess2 = new _n("GlowLayerVBP2", new u.d(0, 1), this._options.blurKernelSize / 2, { width: a, height: s }, null, Ne.a.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1, o), this._postProcesses = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1, this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2], this._postProcesses1 = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1], this._postProcesses2 = [this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2], this._mainTexture.samples = this._options.mainTextureSamples, this._mainTexture.onAfterUnbindObservable.add(function() {
+ var d = e._blurTexture1.getInternalTexture();
+ if (d) {
+ e._scene.postProcessManager.directRender(e._postProcesses1, d, !0);
+ var p = e._blurTexture2.getInternalTexture();
+ p && e._scene.postProcessManager.directRender(e._postProcesses2, p, !0), e._engine.unBindFramebuffer(p ?? d, !0);
+ }
+ }), this._postProcesses.map(function(d) {
+ d.autoClear = !1;
+ });
+ }, t.prototype.isReady = function(e, n) {
+ var i = e.getMaterial(), o = e.getRenderingMesh();
+ if (!i || !o)
+ return !1;
+ var a = i.emissiveTexture;
+ return r.prototype._isReady.call(this, e, n, a);
+ }, t.prototype.needStencil = function() {
+ return !1;
+ }, t.prototype._canRenderMesh = function(e, n) {
+ return !0;
+ }, t.prototype._internalRender = function(e) {
+ e.setTexture("textureSampler", this._blurTexture1), e.setTexture("textureSampler2", this._blurTexture2), e.setFloat("offset", this._intensity);
+ var n = this._engine, i = n.getStencilBuffer();
+ n.setStencilBuffer(!1), n.drawElementsType(zt.a.TriangleFillMode, 0, 6), n.setStencilBuffer(i);
+ }, t.prototype._setEmissiveTextureAndColor = function(e, n, i) {
+ var o = 1;
+ this.customEmissiveTextureSelector ? this._emissiveTextureAndColor.texture = this.customEmissiveTextureSelector(e, n, i) : i ? (this._emissiveTextureAndColor.texture = i.emissiveTexture, this._emissiveTextureAndColor.texture && (o = this._emissiveTextureAndColor.texture.level)) : this._emissiveTextureAndColor.texture = null, this.customEmissiveColorSelector ? this.customEmissiveColorSelector(e, n, i, this._emissiveTextureAndColor.color) : i.emissiveColor ? this._emissiveTextureAndColor.color.set(i.emissiveColor.r * o, i.emissiveColor.g * o, i.emissiveColor.b * o, i.alpha) : this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
+ }, t.prototype._shouldRenderMesh = function(e) {
+ return this.hasMesh(e);
+ }, t.prototype._addCustomEffectDefines = function(e) {
+ e.push("#define GLOW");
+ }, t.prototype.addExcludedMesh = function(e) {
+ this._excludedMeshes.indexOf(e.uniqueId) === -1 && this._excludedMeshes.push(e.uniqueId);
+ }, t.prototype.removeExcludedMesh = function(e) {
+ var n = this._excludedMeshes.indexOf(e.uniqueId);
+ n !== -1 && this._excludedMeshes.splice(n, 1);
+ }, t.prototype.addIncludedOnlyMesh = function(e) {
+ this._includedOnlyMeshes.indexOf(e.uniqueId) === -1 && this._includedOnlyMeshes.push(e.uniqueId);
+ }, t.prototype.removeIncludedOnlyMesh = function(e) {
+ var n = this._includedOnlyMeshes.indexOf(e.uniqueId);
+ n !== -1 && this._includedOnlyMeshes.splice(n, 1);
+ }, t.prototype.hasMesh = function(e) {
+ return !!r.prototype.hasMesh.call(this, e) && (this._includedOnlyMeshes.length ? this._includedOnlyMeshes.indexOf(e.uniqueId) !== -1 : !this._excludedMeshes.length || this._excludedMeshes.indexOf(e.uniqueId) === -1);
+ }, t.prototype._useMeshMaterial = function(e) {
+ return this._meshesUsingTheirOwnMaterials.length != 0 && this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId) > -1;
+ }, t.prototype.referenceMeshToUseItsOwnMaterial = function(e) {
+ this._meshesUsingTheirOwnMaterials.push(e.uniqueId);
+ }, t.prototype.unReferenceMeshFromUsingItsOwnMaterial = function(e) {
+ for (var n = this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId); n >= 0; )
+ this._meshesUsingTheirOwnMaterials.splice(n, 1), n = this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId);
+ }, t.prototype._disposeMesh = function(e) {
+ this.removeIncludedOnlyMesh(e), this.removeExcludedMesh(e);
+ }, t.prototype.getClassName = function() {
+ return "GlowLayer";
+ }, t.prototype.serialize = function() {
+ var e, n = L.a.Serialize(this);
+ if (n.customType = "BABYLON.GlowLayer", n.includedMeshes = [], this._includedOnlyMeshes.length)
+ for (e = 0; e < this._includedOnlyMeshes.length; e++)
+ (i = this._scene.getMeshByUniqueID(this._includedOnlyMeshes[e])) && n.includedMeshes.push(i.id);
+ if (n.excludedMeshes = [], this._excludedMeshes.length)
+ for (e = 0; e < this._excludedMeshes.length; e++) {
+ var i;
+ (i = this._scene.getMeshByUniqueID(this._excludedMeshes[e])) && n.excludedMeshes.push(i.id);
+ }
+ return n;
+ }, t.Parse = function(e, n, i) {
+ var o, a = L.a.Parse(function() {
+ return new t(e.name, n, e.options);
+ }, e, n, i);
+ for (o = 0; o < e.excludedMeshes.length; o++)
+ (s = n.getMeshByID(e.excludedMeshes[o])) && a.addExcludedMesh(s);
+ for (o = 0; o < e.includedMeshes.length; o++) {
+ var s;
+ (s = n.getMeshByID(e.includedMeshes[o])) && a.addIncludedOnlyMesh(s);
+ }
+ return a;
+ }, t.EffectName = "GlowLayer", t.DefaultBlurKernelSize = 32, t.DefaultTextureRatio = 0.5, Object(c.c)([Object(L.c)()], t.prototype, "blurKernelSize", null), Object(c.c)([Object(L.c)()], t.prototype, "intensity", null), Object(c.c)([Object(L.c)("options")], t.prototype, "_options", void 0), t;
+ }(no);
+ O.a.RegisteredTypes["BABYLON.GlowLayer"] = Ko;
+ var r_ = `
+varying vec2 vUV;
+uniform sampler2D textureSampler;
+
+uniform vec2 screenSize;
+uniform vec2 direction;
+uniform float blurWidth;
+
+float getLuminance(vec3 color)
+{
+return dot(color,vec3(0.2126,0.7152,0.0722));
+}
+void main(void)
+{
+float weights[7];
+weights[0]=0.05;
+weights[1]=0.1;
+weights[2]=0.2;
+weights[3]=0.3;
+weights[4]=0.2;
+weights[5]=0.1;
+weights[6]=0.05;
+vec2 texelSize=vec2(1.0/screenSize.x,1.0/screenSize.y);
+vec2 texelStep=texelSize*direction*blurWidth;
+vec2 start=vUV-3.0*texelStep;
+vec4 baseColor=vec4(0.,0.,0.,0.);
+vec2 texelOffset=vec2(0.,0.);
+for (int i=0; i<7; i++)
+{
+
+vec4 texel=texture2D(textureSampler,start+texelOffset);
+baseColor.a+=texel.a*weights[i];
+
+float luminance=getLuminance(baseColor.rgb);
+float luminanceTexel=getLuminance(texel.rgb);
+float choice=step(luminanceTexel,luminance);
+baseColor.rgb=choice*baseColor.rgb+(1.0-choice)*texel.rgb;
+texelOffset+=texelStep;
+}
+gl_FragColor=baseColor;
+}`;
+ ze.a.ShadersStore.glowBlurPostProcessPixelShader = r_, V.a.prototype.getHighlightLayerByName = function(r) {
+ for (var t = 0; t < this.effectLayers.length; t++)
+ if (this.effectLayers[t].name === r && this.effectLayers[t].getEffectName() === Ms.EffectName)
+ return this.effectLayers[t];
+ return null;
+ };
+ var fu = function(r) {
+ function t(e, n, i, o, a, s, d, p) {
+ s === void 0 && (s = Ne.a.BILINEAR_SAMPLINGMODE);
+ var y = r.call(this, e, "glowBlurPostProcess", ["screenSize", "direction", "blurWidth"], null, o, a, s, d, p) || this;
+ return y.direction = n, y.kernel = i, y.onApplyObservable.add(function(P) {
+ P.setFloat2("screenSize", y.width, y.height), P.setVector2("direction", y.direction), P.setFloat("blurWidth", y.kernel);
+ }), y;
+ }
+ return Object(c.d)(t, r), t;
+ }(ft), Ms = function(r) {
+ function t(e, n, i) {
+ var o = r.call(this, e, n) || this;
+ return o.name = e, o.innerGlow = !0, o.outerGlow = !0, o.onBeforeBlurObservable = new C.c(), o.onAfterBlurObservable = new C.c(), o._instanceGlowingMeshStencilReference = t.GlowingMeshStencilReference++, o._meshes = {}, o._excludedMeshes = {}, o.neutralColor = t.NeutralColor, o._engine.isStencilEnable || l.a.Warn("Rendering the Highlight Layer requires the stencil to be active on the canvas. var engine = new Engine(canvas, antialias, { stencil: true }"), o._options = Object(c.a)({ mainTextureRatio: 0.5, blurTextureSizeRatio: 0.5, blurHorizontalSize: 1, blurVerticalSize: 1, alphaBlendingMode: h.a.ALPHA_COMBINE, camera: null, renderingGroupId: -1 }, i), o._init({ alphaBlendingMode: o._options.alphaBlendingMode, camera: o._options.camera, mainTextureFixedSize: o._options.mainTextureFixedSize, mainTextureRatio: o._options.mainTextureRatio, renderingGroupId: o._options.renderingGroupId }), o._shouldRender = !1, o;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "blurHorizontalSize", { get: function() {
+ return this._horizontalBlurPostprocess.kernel;
+ }, set: function(e) {
+ this._horizontalBlurPostprocess.kernel = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "blurVerticalSize", { get: function() {
+ return this._verticalBlurPostprocess.kernel;
+ }, set: function(e) {
+ this._verticalBlurPostprocess.kernel = e;
+ }, enumerable: !1, configurable: !0 }), t.prototype.getEffectName = function() {
+ return t.EffectName;
+ }, t.prototype._createMergeEffect = function() {
+ return this._engine.createEffect("glowMapMerge", [Oe.b.PositionKind], ["offset"], ["textureSampler"], this._options.isStroke ? `#define STROKE
+` : void 0);
+ }, t.prototype._createTextureAndPostProcesses = function() {
+ var e = this, n = this._mainTextureDesiredSize.width * this._options.blurTextureSizeRatio, i = this._mainTextureDesiredSize.height * this._options.blurTextureSizeRatio;
+ n = this._engine.needPOTTextures ? Ue.a.GetExponentOfTwo(n, this._maxSize) : n, i = this._engine.needPOTTextures ? Ue.a.GetExponentOfTwo(i, this._maxSize) : i;
+ var o = 0;
+ o = this._engine.getCaps().textureHalfFloatRender ? h.a.TEXTURETYPE_HALF_FLOAT : h.a.TEXTURETYPE_UNSIGNED_INT, this._blurTexture = new on("HighlightLayerBlurRTT", { width: n, height: i }, this._scene, !1, !0, o), this._blurTexture.wrapU = Ne.a.CLAMP_ADDRESSMODE, this._blurTexture.wrapV = Ne.a.CLAMP_ADDRESSMODE, this._blurTexture.anisotropicFilteringLevel = 16, this._blurTexture.updateSamplingMode(Ne.a.TRILINEAR_SAMPLINGMODE), this._blurTexture.renderParticles = !1, this._blurTexture.ignoreCameraViewport = !0, this._textures = [this._blurTexture], this._options.alphaBlendingMode === h.a.ALPHA_COMBINE ? (this._downSamplePostprocess = new Ci("HighlightLayerPPP", this._options.blurTextureSizeRatio, null, Ne.a.BILINEAR_SAMPLINGMODE, this._scene.getEngine()), this._downSamplePostprocess.onApplyObservable.add(function(a) {
+ a.setTexture("textureSampler", e._mainTexture);
+ }), this._horizontalBlurPostprocess = new fu("HighlightLayerHBP", new u.d(1, 0), this._options.blurHorizontalSize, 1, null, Ne.a.BILINEAR_SAMPLINGMODE, this._scene.getEngine()), this._horizontalBlurPostprocess.onApplyObservable.add(function(a) {
+ a.setFloat2("screenSize", n, i);
+ }), this._verticalBlurPostprocess = new fu("HighlightLayerVBP", new u.d(0, 1), this._options.blurVerticalSize, 1, null, Ne.a.BILINEAR_SAMPLINGMODE, this._scene.getEngine()), this._verticalBlurPostprocess.onApplyObservable.add(function(a) {
+ a.setFloat2("screenSize", n, i);
+ }), this._postProcesses = [this._downSamplePostprocess, this._horizontalBlurPostprocess, this._verticalBlurPostprocess]) : (this._horizontalBlurPostprocess = new _n("HighlightLayerHBP", new u.d(1, 0), this._options.blurHorizontalSize / 2, { width: n, height: i }, null, Ne.a.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1, o), this._horizontalBlurPostprocess.width = n, this._horizontalBlurPostprocess.height = i, this._horizontalBlurPostprocess.onApplyObservable.add(function(a) {
+ a.setTexture("textureSampler", e._mainTexture);
+ }), this._verticalBlurPostprocess = new _n("HighlightLayerVBP", new u.d(0, 1), this._options.blurVerticalSize / 2, { width: n, height: i }, null, Ne.a.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1, o), this._postProcesses = [this._horizontalBlurPostprocess, this._verticalBlurPostprocess]), this._mainTexture.onAfterUnbindObservable.add(function() {
+ e.onBeforeBlurObservable.notifyObservers(e);
+ var a = e._blurTexture.getInternalTexture();
+ a && (e._scene.postProcessManager.directRender(e._postProcesses, a, !0), e._engine.unBindFramebuffer(a, !0)), e.onAfterBlurObservable.notifyObservers(e);
+ }), this._postProcesses.map(function(a) {
+ a.autoClear = !1;
+ });
+ }, t.prototype.needStencil = function() {
+ return !0;
+ }, t.prototype.isReady = function(e, n) {
+ var i = e.getMaterial(), o = e.getRenderingMesh();
+ if (!i || !o || !this._meshes)
+ return !1;
+ var a = null, s = this._meshes[o.uniqueId];
+ return s && s.glowEmissiveOnly && i && (a = i.emissiveTexture), r.prototype._isReady.call(this, e, n, a);
+ }, t.prototype._internalRender = function(e) {
+ e.setTexture("textureSampler", this._blurTexture);
+ var n = this._engine;
+ n.cacheStencilState(), n.setStencilOperationPass(h.a.REPLACE), n.setStencilOperationFail(h.a.KEEP), n.setStencilOperationDepthFail(h.a.KEEP), n.setStencilMask(0), n.setStencilBuffer(!0), n.setStencilFunctionReference(this._instanceGlowingMeshStencilReference), this.outerGlow && (e.setFloat("offset", 0), n.setStencilFunction(h.a.NOTEQUAL), n.drawElementsType(zt.a.TriangleFillMode, 0, 6)), this.innerGlow && (e.setFloat("offset", 1), n.setStencilFunction(h.a.EQUAL), n.drawElementsType(zt.a.TriangleFillMode, 0, 6)), n.restoreStencilState();
+ }, t.prototype.shouldRender = function() {
+ return !!r.prototype.shouldRender.call(this) && !!this._meshes;
+ }, t.prototype._shouldRenderMesh = function(e) {
+ return (!this._excludedMeshes || !this._excludedMeshes[e.uniqueId]) && !!r.prototype.hasMesh.call(this, e);
+ }, t.prototype._canRenderMesh = function(e, n) {
+ return !0;
+ }, t.prototype._addCustomEffectDefines = function(e) {
+ e.push("#define HIGHLIGHT");
+ }, t.prototype._setEmissiveTextureAndColor = function(e, n, i) {
+ var o = this._meshes[e.uniqueId];
+ o ? this._emissiveTextureAndColor.color.set(o.color.r, o.color.g, o.color.b, 1) : this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a), o && o.glowEmissiveOnly && i ? (this._emissiveTextureAndColor.texture = i.emissiveTexture, this._emissiveTextureAndColor.color.set(1, 1, 1, 1)) : this._emissiveTextureAndColor.texture = null;
+ }, t.prototype.addExcludedMesh = function(e) {
+ this._excludedMeshes && (this._excludedMeshes[e.uniqueId] || (this._excludedMeshes[e.uniqueId] = { mesh: e, beforeBind: e.onBeforeBindObservable.add(function(n) {
+ n.getEngine().setStencilBuffer(!1);
+ }), afterRender: e.onAfterRenderObservable.add(function(n) {
+ n.getEngine().setStencilBuffer(!0);
+ }) }));
+ }, t.prototype.removeExcludedMesh = function(e) {
+ if (this._excludedMeshes) {
+ var n = this._excludedMeshes[e.uniqueId];
+ n && (n.beforeBind && e.onBeforeBindObservable.remove(n.beforeBind), n.afterRender && e.onAfterRenderObservable.remove(n.afterRender)), this._excludedMeshes[e.uniqueId] = null;
+ }
+ }, t.prototype.hasMesh = function(e) {
+ return !!this._meshes && !!r.prototype.hasMesh.call(this, e) && this._meshes[e.uniqueId] !== void 0 && this._meshes[e.uniqueId] !== null;
+ }, t.prototype.addMesh = function(e, n, i) {
+ var o = this;
+ if (i === void 0 && (i = !1), this._meshes) {
+ var a = this._meshes[e.uniqueId];
+ a ? a.color = n : (this._meshes[e.uniqueId] = { mesh: e, color: n, observerHighlight: e.onBeforeBindObservable.add(function(s) {
+ o.isEnabled && (o._excludedMeshes && o._excludedMeshes[s.uniqueId] ? o._defaultStencilReference(s) : s.getScene().getEngine().setStencilFunctionReference(o._instanceGlowingMeshStencilReference));
+ }), observerDefault: e.onAfterRenderObservable.add(function(s) {
+ o.isEnabled && o._defaultStencilReference(s);
+ }), glowEmissiveOnly: i }, e.onDisposeObservable.add(function() {
+ o._disposeMesh(e);
+ })), this._shouldRender = !0;
+ }
+ }, t.prototype.removeMesh = function(e) {
+ if (this._meshes) {
+ var n = this._meshes[e.uniqueId];
+ for (var i in n && (n.observerHighlight && e.onBeforeBindObservable.remove(n.observerHighlight), n.observerDefault && e.onAfterRenderObservable.remove(n.observerDefault), delete this._meshes[e.uniqueId]), this._shouldRender = !1, this._meshes)
+ if (this._meshes[i]) {
+ this._shouldRender = !0;
+ break;
+ }
+ }
+ }, t.prototype.removeAllMeshes = function() {
+ if (this._meshes) {
+ for (var e in this._meshes)
+ if (this._meshes.hasOwnProperty(e)) {
+ var n = this._meshes[e];
+ n && this.removeMesh(n.mesh);
+ }
+ }
+ }, t.prototype._defaultStencilReference = function(e) {
+ e.getScene().getEngine().setStencilFunctionReference(t.NormalMeshStencilReference);
+ }, t.prototype._disposeMesh = function(e) {
+ this.removeMesh(e), this.removeExcludedMesh(e);
+ }, t.prototype.dispose = function() {
+ if (this._meshes) {
+ for (var e in this._meshes)
+ (n = this._meshes[e]) && n.mesh && (n.observerHighlight && n.mesh.onBeforeBindObservable.remove(n.observerHighlight), n.observerDefault && n.mesh.onAfterRenderObservable.remove(n.observerDefault));
+ this._meshes = null;
+ }
+ if (this._excludedMeshes) {
+ for (var e in this._excludedMeshes) {
+ var n;
+ (n = this._excludedMeshes[e]) && (n.beforeBind && n.mesh.onBeforeBindObservable.remove(n.beforeBind), n.afterRender && n.mesh.onAfterRenderObservable.remove(n.afterRender));
+ }
+ this._excludedMeshes = null;
+ }
+ r.prototype.dispose.call(this);
+ }, t.prototype.getClassName = function() {
+ return "HighlightLayer";
+ }, t.prototype.serialize = function() {
+ var e = L.a.Serialize(this);
+ if (e.customType = "BABYLON.HighlightLayer", e.meshes = [], this._meshes)
+ for (var n in this._meshes) {
+ var i = this._meshes[n];
+ i && e.meshes.push({ glowEmissiveOnly: i.glowEmissiveOnly, color: i.color.asArray(), meshId: i.mesh.id });
+ }
+ if (e.excludedMeshes = [], this._excludedMeshes)
+ for (var o in this._excludedMeshes) {
+ var a = this._excludedMeshes[o];
+ a && e.excludedMeshes.push(a.mesh.id);
+ }
+ return e;
+ }, t.Parse = function(e, n, i) {
+ var o, a = L.a.Parse(function() {
+ return new t(e.name, n, e.options);
+ }, e, n, i);
+ for (o = 0; o < e.excludedMeshes.length; o++)
+ (s = n.getMeshByID(e.excludedMeshes[o])) && a.addExcludedMesh(s);
+ for (o = 0; o < e.meshes.length; o++) {
+ var s, d = e.meshes[o];
+ (s = n.getMeshByID(d.meshId)) && a.addMesh(s, I.a.FromArray(d.color), d.glowEmissiveOnly);
+ }
+ return a;
+ }, t.EffectName = "HighlightLayer", t.NeutralColor = new I.b(0, 0, 0, 0), t.GlowingMeshStencilReference = 2, t.NormalMeshStencilReference = 1, Object(c.c)([Object(L.c)()], t.prototype, "innerGlow", void 0), Object(c.c)([Object(L.c)()], t.prototype, "outerGlow", void 0), Object(c.c)([Object(L.c)()], t.prototype, "blurHorizontalSize", null), Object(c.c)([Object(L.c)()], t.prototype, "blurVerticalSize", null), Object(c.c)([Object(L.c)("options")], t.prototype, "_options", void 0), t;
+ }(no);
+ O.a.RegisteredTypes["BABYLON.HighlightLayer"] = Ms;
+ var pu = function() {
+ function r(t) {
+ this.name = ot.a.NAME_LAYER, this.scene = t, this._engine = t.getEngine(), t.layers = new Array();
+ }
+ return r.prototype.register = function() {
+ this.scene._beforeCameraDrawStage.registerStep(ot.a.STEP_BEFORECAMERADRAW_LAYER, this, this._drawCameraBackground), this.scene._afterCameraDrawStage.registerStep(ot.a.STEP_AFTERCAMERADRAW_LAYER, this, this._drawCameraForeground), this.scene._beforeRenderTargetDrawStage.registerStep(ot.a.STEP_BEFORERENDERTARGETDRAW_LAYER, this, this._drawRenderTargetBackground), this.scene._afterRenderTargetDrawStage.registerStep(ot.a.STEP_AFTERRENDERTARGETDRAW_LAYER, this, this._drawRenderTargetForeground);
+ }, r.prototype.rebuild = function() {
+ for (var t = 0, e = this.scene.layers; t < e.length; t++)
+ e[t]._rebuild();
+ }, r.prototype.dispose = function() {
+ for (var t = this.scene.layers; t.length; )
+ t[0].dispose();
+ }, r.prototype._draw = function(t) {
+ var e = this.scene.layers;
+ if (e.length) {
+ this._engine.setDepthBuffer(!1);
+ for (var n = 0, i = e; n < i.length; n++) {
+ var o = i[n];
+ t(o) && o.render();
+ }
+ this._engine.setDepthBuffer(!0);
+ }
+ }, r.prototype._drawCameraPredicate = function(t, e, n) {
+ return !t.renderOnlyInRenderTargetTextures && t.isBackground === e && (t.layerMask & n) != 0;
+ }, r.prototype._drawCameraBackground = function(t) {
+ var e = this;
+ this._draw(function(n) {
+ return e._drawCameraPredicate(n, !0, t.layerMask);
+ });
+ }, r.prototype._drawCameraForeground = function(t) {
+ var e = this;
+ this._draw(function(n) {
+ return e._drawCameraPredicate(n, !1, t.layerMask);
+ });
+ }, r.prototype._drawRenderTargetPredicate = function(t, e, n, i) {
+ return t.renderTargetTextures.length > 0 && t.isBackground === e && t.renderTargetTextures.indexOf(i) > -1 && (t.layerMask & n) != 0;
+ }, r.prototype._drawRenderTargetBackground = function(t) {
+ var e = this;
+ this._draw(function(n) {
+ return e._drawRenderTargetPredicate(n, !0, e.scene.activeCamera.layerMask, t);
+ });
+ }, r.prototype._drawRenderTargetForeground = function(t) {
+ var e = this;
+ this._draw(function(n) {
+ return e._drawRenderTargetPredicate(n, !1, e.scene.activeCamera.layerMask, t);
+ });
+ }, r.prototype.addFromContainer = function(t) {
+ var e = this;
+ t.layers && t.layers.forEach(function(n) {
+ e.scene.layers.push(n);
+ });
+ }, r.prototype.removeFromContainer = function(t, e) {
+ var n = this;
+ e === void 0 && (e = !1), t.layers && t.layers.forEach(function(i) {
+ var o = n.scene.layers.indexOf(i);
+ o !== -1 && n.scene.layers.splice(o, 1), e && i.dispose();
+ });
+ }, r;
+ }(), o_ = `
+varying vec2 vUV;
+uniform sampler2D textureSampler;
+
+uniform vec4 color;
+
+#include
+void main(void) {
+vec4 baseColor=texture2D(textureSampler,vUV);
+#ifdef LINEAR
+baseColor.rgb=toGammaSpace(baseColor.rgb);
+#endif
+#ifdef ALPHATEST
+if (baseColor.a<0.4)
+discard;
+#endif
+gl_FragColor=baseColor*color;
+}`;
+ ze.a.ShadersStore.layerPixelShader = o_;
+ var a_ = `
+attribute vec2 position;
+
+uniform vec2 scale;
+uniform vec2 offset;
+uniform mat4 textureMatrix;
+
+varying vec2 vUV;
+const vec2 madd=vec2(0.5,0.5);
+void main(void) {
+vec2 shiftedPosition=position*scale+offset;
+vUV=vec2(textureMatrix*vec4(shiftedPosition*madd+madd,1.0,0.0));
+gl_Position=vec4(shiftedPosition,0.0,1.0);
+}`;
+ ze.a.ShadersStore.layerVertexShader = a_;
+ var s_ = function() {
+ function r(t, e, n, i, o) {
+ this.name = t, this.scale = new u.d(1, 1), this.offset = new u.d(0, 0), this.alphaBlendingMode = h.a.ALPHA_COMBINE, this.layerMask = 268435455, this.renderTargetTextures = [], this.renderOnlyInRenderTargetTextures = !1, this._vertexBuffers = {}, this.onDisposeObservable = new C.c(), this.onBeforeRenderObservable = new C.c(), this.onAfterRenderObservable = new C.c(), this.texture = e ? new Ne.a(e, n, !0) : null, this.isBackground = i === void 0 || i, this.color = o === void 0 ? new I.b(1, 1, 1, 1) : o, this._scene = n || te.a.LastCreatedScene;
+ var a = this._scene._getComponent(ot.a.NAME_LAYER);
+ a || (a = new pu(this._scene), this._scene._addComponent(a)), this._scene.layers.push(this);
+ var s = this._scene.getEngine(), d = [];
+ d.push(1, 1), d.push(-1, 1), d.push(-1, -1), d.push(1, -1);
+ var p = new Oe.b(s, d, Oe.b.PositionKind, !1, !1, 2);
+ this._vertexBuffers[Oe.b.PositionKind] = p, this._createIndexBuffer();
+ }
+ return Object.defineProperty(r.prototype, "onDispose", { set: function(t) {
+ this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver), this._onDisposeObserver = this.onDisposeObservable.add(t);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "onBeforeRender", { set: function(t) {
+ this._onBeforeRenderObserver && this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver), this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(t);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "onAfterRender", { set: function(t) {
+ this._onAfterRenderObserver && this.onAfterRenderObservable.remove(this._onAfterRenderObserver), this._onAfterRenderObserver = this.onAfterRenderObservable.add(t);
+ }, enumerable: !1, configurable: !0 }), r.prototype._createIndexBuffer = function() {
+ var t = this._scene.getEngine(), e = [];
+ e.push(0), e.push(1), e.push(2), e.push(0), e.push(2), e.push(3), this._indexBuffer = t.createIndexBuffer(e);
+ }, r.prototype._rebuild = function() {
+ var t = this._vertexBuffers[Oe.b.PositionKind];
+ t && t._rebuild(), this._createIndexBuffer();
+ }, r.prototype.render = function() {
+ var t = this._scene.getEngine(), e = "";
+ this.alphaTest && (e = "#define ALPHATEST"), this.texture && !this.texture.gammaSpace && (e += `\r
+#define LINEAR`), this._previousDefines !== e && (this._previousDefines = e, this._effect = t.createEffect("layer", [Oe.b.PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], e));
+ var n = this._effect;
+ n && n.isReady() && this.texture && this.texture.isReady() && (t = this._scene.getEngine(), this.onBeforeRenderObservable.notifyObservers(this), t.enableEffect(n), t.setState(!1), n.setTexture("textureSampler", this.texture), n.setMatrix("textureMatrix", this.texture.getTextureMatrix()), n.setFloat4("color", this.color.r, this.color.g, this.color.b, this.color.a), n.setVector2("offset", this.offset), n.setVector2("scale", this.scale), t.bindBuffers(this._vertexBuffers, this._indexBuffer, n), this.alphaTest ? t.drawElementsType(zt.a.TriangleFillMode, 0, 6) : (t.setAlphaMode(this.alphaBlendingMode), t.drawElementsType(zt.a.TriangleFillMode, 0, 6), t.setAlphaMode(h.a.ALPHA_DISABLE)), this.onAfterRenderObservable.notifyObservers(this));
+ }, r.prototype.dispose = function() {
+ var t = this._vertexBuffers[Oe.b.PositionKind];
+ t && (t.dispose(), this._vertexBuffers[Oe.b.PositionKind] = null), this._indexBuffer && (this._scene.getEngine()._releaseBuffer(this._indexBuffer), this._indexBuffer = null), this.texture && (this.texture.dispose(), this.texture = null), this.renderTargetTextures = [];
+ var e = this._scene.layers.indexOf(this);
+ this._scene.layers.splice(e, 1), this.onDisposeObservable.notifyObservers(this), this.onDisposeObservable.clear(), this.onAfterRenderObservable.clear(), this.onBeforeRenderObservable.clear();
+ }, r;
+ }(), _u = function() {
+ function r(t, e, n, i, o) {
+ this.size = t, this.position = e, this.alphaMode = h.a.ALPHA_ONEONE, this.color = n || new I.a(1, 1, 1), this.texture = i ? new Ne.a(i, o.getScene(), !0) : null, this._system = o, o.lensFlares.push(this);
+ }
+ return r.AddFlare = function(t, e, n, i, o) {
+ return new r(t, e, n, i, o);
+ }, r.prototype.dispose = function() {
+ this.texture && this.texture.dispose();
+ var t = this._system.lensFlares.indexOf(this);
+ this._system.lensFlares.splice(t, 1);
+ }, r;
+ }(), c_ = `
+varying vec2 vUV;
+uniform sampler2D textureSampler;
+
+uniform vec4 color;
+void main(void) {
+vec4 baseColor=texture2D(textureSampler,vUV);
+gl_FragColor=baseColor*color;
+}`;
+ ze.a.ShadersStore.lensFlarePixelShader = c_;
+ var l_ = `
+attribute vec2 position;
+
+uniform mat4 viewportMatrix;
+
+varying vec2 vUV;
+const vec2 madd=vec2(0.5,0.5);
+void main(void) {
+vUV=position*madd+madd;
+gl_Position=viewportMatrix*vec4(position,0.0,1.0);
+}`;
+ ze.a.ShadersStore.lensFlareVertexShader = l_;
+ var Is = function() {
+ function r(t, e, n) {
+ this.name = t, this.lensFlares = new Array(), this.borderLimit = 300, this.viewportBorder = 0, this.layerMask = 268435455, this._vertexBuffers = {}, this._isEnabled = !0, this._scene = n || te.a.LastCreatedScene, r._SceneComponentInitialization(this._scene), this._emitter = e, this.id = t, n.lensFlareSystems.push(this), this.meshesSelectionPredicate = function(s) {
+ return n.activeCamera && s.material && s.isVisible && s.isEnabled() && s.isBlocker && (s.layerMask & n.activeCamera.layerMask) != 0;
+ };
+ var i = n.getEngine(), o = [];
+ o.push(1, 1), o.push(-1, 1), o.push(-1, -1), o.push(1, -1), this._vertexBuffers[Oe.b.PositionKind] = new Oe.b(i, o, Oe.b.PositionKind, !1, !1, 2);
+ var a = [];
+ a.push(0), a.push(1), a.push(2), a.push(0), a.push(2), a.push(3), this._indexBuffer = i.createIndexBuffer(a), this._effect = i.createEffect("lensFlare", [Oe.b.PositionKind], ["color", "viewportMatrix"], ["textureSampler"], "");
+ }
+ return Object.defineProperty(r.prototype, "isEnabled", { get: function() {
+ return this._isEnabled;
+ }, set: function(t) {
+ this._isEnabled = t;
+ }, enumerable: !1, configurable: !0 }), r.prototype.getScene = function() {
+ return this._scene;
+ }, r.prototype.getEmitter = function() {
+ return this._emitter;
+ }, r.prototype.setEmitter = function(t) {
+ this._emitter = t;
+ }, r.prototype.getEmitterPosition = function() {
+ return this._emitter.getAbsolutePosition ? this._emitter.getAbsolutePosition() : this._emitter.position;
+ }, r.prototype.computeEffectivePosition = function(t) {
+ var e = this.getEmitterPosition();
+ return e = u.e.Project(e, u.a.Identity(), this._scene.getTransformMatrix(), t), this._positionX = e.x, this._positionY = e.y, e = u.e.TransformCoordinates(this.getEmitterPosition(), this._scene.getViewMatrix()), this.viewportBorder > 0 && (t.x -= this.viewportBorder, t.y -= this.viewportBorder, t.width += 2 * this.viewportBorder, t.height += 2 * this.viewportBorder, e.x += this.viewportBorder, e.y += this.viewportBorder, this._positionX += this.viewportBorder, this._positionY += this.viewportBorder), e.z > 0 && (this._positionX > t.x && this._positionX < t.x + t.width && this._positionY > t.y && (this._positionY, t.y, t.height), !0);
+ }, r.prototype._isVisible = function() {
+ if (!this._isEnabled || !this._scene.activeCamera)
+ return !1;
+ var t = this.getEmitterPosition().subtract(this._scene.activeCamera.globalPosition), e = t.length();
+ t.normalize();
+ var n = new dn.a(this._scene.activeCamera.globalPosition, t), i = this._scene.pickWithRay(n, this.meshesSelectionPredicate, !0);
+ return !i || !i.hit || i.distance > e;
+ }, r.prototype.render = function() {
+ if (!this._effect.isReady() || !this._scene.activeCamera)
+ return !1;
+ var t, e, n = this._scene.getEngine(), i = this._scene.activeCamera.viewport.toGlobal(n.getRenderWidth(!0), n.getRenderHeight(!0));
+ if (!this.computeEffectivePosition(i) || !this._isVisible())
+ return !1;
+ var o = (t = this._positionX < this.borderLimit + i.x ? this.borderLimit + i.x - this._positionX : this._positionX > i.x + i.width - this.borderLimit ? this._positionX - i.x - i.width + this.borderLimit : 0) > (e = this._positionY < this.borderLimit + i.y ? this.borderLimit + i.y - this._positionY : this._positionY > i.y + i.height - this.borderLimit ? this._positionY - i.y - i.height + this.borderLimit : 0) ? t : e;
+ (o -= this.viewportBorder) > this.borderLimit && (o = this.borderLimit);
+ var a = 1 - $.a.Clamp(o / this.borderLimit, 0, 1);
+ if (a < 0)
+ return !1;
+ a > 1 && (a = 1), this.viewportBorder > 0 && (i.x += this.viewportBorder, i.y += this.viewportBorder, i.width -= 2 * this.viewportBorder, i.height -= 2 * this.viewportBorder, this._positionX -= this.viewportBorder, this._positionY -= this.viewportBorder);
+ var s = i.x + i.width / 2, d = i.y + i.height / 2, p = s - this._positionX, y = d - this._positionY;
+ n.enableEffect(this._effect), n.setState(!1), n.setDepthBuffer(!1), n.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
+ for (var P = 0; P < this.lensFlares.length; P++) {
+ var R = this.lensFlares[P];
+ if (!R.texture || R.texture.isReady()) {
+ n.setAlphaMode(R.alphaMode);
+ var B = s - p * R.position, F = d - y * R.position, z = R.size, J = R.size * n.getAspectRatio(this._scene.activeCamera, !0), ie = B / (i.width + 2 * i.x) * 2 - 1, se = 1 - F / (i.height + 2 * i.y) * 2, ce = u.a.FromValues(z / 2, 0, 0, 0, 0, J / 2, 0, 0, 0, 0, 1, 0, ie, se, 0, 1);
+ this._effect.setMatrix("viewportMatrix", ce), this._effect.setTexture("textureSampler", R.texture), this._effect.setFloat4("color", R.color.r * a, R.color.g * a, R.color.b * a, 1), n.drawElementsType(zt.a.TriangleFillMode, 0, 6);
+ }
+ }
+ return n.setDepthBuffer(!0), n.setAlphaMode(h.a.ALPHA_DISABLE), !0;
+ }, r.prototype.dispose = function() {
+ var t = this._vertexBuffers[Oe.b.PositionKind];
+ for (t && (t.dispose(), this._vertexBuffers[Oe.b.PositionKind] = null), this._indexBuffer && (this._scene.getEngine()._releaseBuffer(this._indexBuffer), this._indexBuffer = null); this.lensFlares.length; )
+ this.lensFlares[0].dispose();
+ var e = this._scene.lensFlareSystems.indexOf(this);
+ this._scene.lensFlareSystems.splice(e, 1);
+ }, r.Parse = function(t, e, n) {
+ var i = e.getLastEntryByID(t.emitterId), o = t.name || "lensFlareSystem#" + t.emitterId, a = new r(o, i, e);
+ a.id = t.id || o, a.borderLimit = t.borderLimit;
+ for (var s = 0; s < t.flares.length; s++) {
+ var d = t.flares[s];
+ _u.AddFlare(d.size, d.position, I.a.FromArray(d.color), d.textureName ? n + d.textureName : "", a);
+ }
+ return a;
+ }, r.prototype.serialize = function() {
+ var t = {};
+ t.id = this.id, t.name = this.name, t.emitterId = this.getEmitter().id, t.borderLimit = this.borderLimit, t.flares = [];
+ for (var e = 0; e < this.lensFlares.length; e++) {
+ var n = this.lensFlares[e];
+ t.flares.push({ size: n.size, position: n.position, color: n.color.asArray(), textureName: Xe.b.GetFilename(n.texture ? n.texture.name : "") });
+ }
+ return t;
+ }, r._SceneComponentInitialization = function(t) {
+ throw En.a.WarnImport("LensFlareSystemSceneComponent");
+ }, r;
+ }();
+ V.a.AddParser(ot.a.NAME_LENSFLARESYSTEM, function(r, t, e, n) {
+ if (r.lensFlareSystems !== void 0 && r.lensFlareSystems !== null) {
+ e.lensFlareSystems || (e.lensFlareSystems = new Array());
+ for (var i = 0, o = r.lensFlareSystems.length; i < o; i++) {
+ var a = r.lensFlareSystems[i], s = Is.Parse(a, t, n);
+ e.lensFlareSystems.push(s);
+ }
+ }
+ }), V.a.prototype.getLensFlareSystemByName = function(r) {
+ for (var t = 0; t < this.lensFlareSystems.length; t++)
+ if (this.lensFlareSystems[t].name === r)
+ return this.lensFlareSystems[t];
+ return null;
+ }, V.a.prototype.getLensFlareSystemByID = function(r) {
+ for (var t = 0; t < this.lensFlareSystems.length; t++)
+ if (this.lensFlareSystems[t].id === r)
+ return this.lensFlareSystems[t];
+ return null;
+ }, V.a.prototype.removeLensFlareSystem = function(r) {
+ var t = this.lensFlareSystems.indexOf(r);
+ return t !== -1 && this.lensFlareSystems.splice(t, 1), t;
+ }, V.a.prototype.addLensFlareSystem = function(r) {
+ this.lensFlareSystems.push(r);
+ };
+ var mu = function() {
+ function r(t) {
+ this.name = ot.a.NAME_LENSFLARESYSTEM, this.scene = t, t.lensFlareSystems = new Array();
+ }
+ return r.prototype.register = function() {
+ this.scene._afterCameraDrawStage.registerStep(ot.a.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM, this, this._draw);
+ }, r.prototype.rebuild = function() {
+ }, r.prototype.addFromContainer = function(t) {
+ var e = this;
+ t.lensFlareSystems && t.lensFlareSystems.forEach(function(n) {
+ e.scene.addLensFlareSystem(n);
+ });
+ }, r.prototype.removeFromContainer = function(t, e) {
+ var n = this;
+ t.lensFlareSystems && t.lensFlareSystems.forEach(function(i) {
+ n.scene.removeLensFlareSystem(i), e && i.dispose();
+ });
+ }, r.prototype.serialize = function(t) {
+ t.lensFlareSystems = [];
+ for (var e = 0, n = this.scene.lensFlareSystems; e < n.length; e++) {
+ var i = n[e];
+ t.lensFlareSystems.push(i.serialize());
+ }
+ }, r.prototype.dispose = function() {
+ for (var t = this.scene.lensFlareSystems; t.length; )
+ t[0].dispose();
+ }, r.prototype._draw = function(t) {
+ if (this.scene.lensFlaresEnabled) {
+ var e = this.scene.lensFlareSystems;
+ Xe.b.StartPerformanceCounter("Lens flares", e.length > 0);
+ for (var n = 0, i = e; n < i.length; n++) {
+ var o = i[n];
+ t.layerMask & o.layerMask && o.render();
+ }
+ Xe.b.EndPerformanceCounter("Lens flares", e.length > 0);
+ }
+ }, r;
+ }();
+ Is._SceneComponentInitialization = function(r) {
+ var t = r._getComponent(ot.a.NAME_LENSFLARESYSTEM);
+ t || (t = new mu(r), r._addComponent(t));
+ };
+ var u_ = `
+
+
+
+
+float bayerDither2(vec2 _P) {
+return mod(2.0*_P.y+_P.x+1.0,4.0);
+}
+
+
+float bayerDither4(vec2 _P) {
+vec2 P1=mod(_P,2.0);
+vec2 P2=floor(0.5*mod(_P,4.0));
+return 4.0*bayerDither2(P1)+bayerDither2(P2);
+}
+
+float bayerDither8(vec2 _P) {
+vec2 P1=mod(_P,2.0);
+vec2 P2=floor(0.5*mod(_P,4.0));
+vec2 P4=floor(0.25*mod(_P,8.0));
+return 4.0*(4.0*bayerDither2(P1)+bayerDither2(P2))+bayerDither2(P4);
+}
+`;
+ ze.a.IncludesShadersStore.bayerDitherFunctions = u_;
+ var h_ = `#if SM_FLOAT == 0
+#include
+#endif
+#if SM_SOFTTRANSPARENTSHADOW == 1
+#include
+uniform float softTransparentShadowSM;
+#endif
+varying float vDepthMetricSM;
+#if SM_USEDISTANCE == 1
+uniform vec3 lightDataSM;
+varying vec3 vPositionWSM;
+#endif
+uniform vec3 biasAndScaleSM;
+uniform vec2 depthValuesSM;
+#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1
+varying float zSM;
+#endif
+`;
+ ze.a.IncludesShadersStore.shadowMapFragmentDeclaration = h_;
+ var d_ = ` float depthSM=vDepthMetricSM;
+#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1
+#if SM_USEDISTANCE == 1
+depthSM=clamp(((length(vPositionWSM-lightDataSM)+depthValuesSM.x)/(depthValuesSM.y))+biasAndScaleSM.x,0.0,1.0);
+#else
+depthSM=clamp(((zSM+depthValuesSM.x)/(depthValuesSM.y))+biasAndScaleSM.x,0.0,1.0);
+#endif
+gl_FragDepth=depthSM;
+#elif SM_USEDISTANCE == 1
+depthSM=(length(vPositionWSM-lightDataSM)+depthValuesSM.x)/(depthValuesSM.y)+biasAndScaleSM.x;
+#endif
+#if SM_ESM == 1
+depthSM=clamp(exp(-min(87.,biasAndScaleSM.z*depthSM)),0.,1.);
+#endif
+#if SM_FLOAT == 1
+gl_FragColor=vec4(depthSM,1.0,1.0,1.0);
+#else
+gl_FragColor=pack(depthSM);
+#endif
+return;`;
+ ze.a.IncludesShadersStore.shadowMapFragment = d_;
+ var f_ = `#include
+#ifdef ALPHATEST
+varying vec2 vUV;
+uniform sampler2D diffuseSampler;
+#endif
+#include
+void main(void)
+{
+#include
+#ifdef ALPHATEST
+float alphaFromAlphaTexture=texture2D(diffuseSampler,vUV).a;
+if (alphaFromAlphaTexture<0.4)
+discard;
+#endif
+#if SM_SOFTTRANSPARENTSHADOW == 1
+#ifdef ALPHATEST
+if ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM*alphaFromAlphaTexture) discard;
+#else
+if ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM) discard;
+#endif
+#endif
+#include
+}`;
+ ze.a.ShadersStore.shadowMapPixelShader = f_;
+ var p_ = `#if SM_NORMALBIAS == 1
+uniform vec3 lightDataSM;
+#endif
+uniform vec3 biasAndScaleSM;
+uniform vec2 depthValuesSM;
+varying float vDepthMetricSM;
+#if SM_USEDISTANCE == 1
+varying vec3 vPositionWSM;
+#endif
+#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1
+varying float zSM;
+#endif
+`;
+ ze.a.IncludesShadersStore.shadowMapVertexDeclaration = p_;
+ var __ = `
+#if SM_NORMALBIAS == 1
+#if SM_DIRECTIONINLIGHTDATA == 1
+vec3 worldLightDirSM=normalize(-lightDataSM.xyz);
+#else
+vec3 directionToLightSM=lightDataSM.xyz-worldPos.xyz;
+vec3 worldLightDirSM=normalize(directionToLightSM);
+#endif
+float ndlSM=dot(vNormalW,worldLightDirSM);
+float sinNLSM=sqrt(1.0-ndlSM*ndlSM);
+float normalBiasSM=biasAndScaleSM.y*sinNLSM;
+worldPos.xyz-=vNormalW*normalBiasSM;
+#endif
+`;
+ ze.a.IncludesShadersStore.shadowMapVertexNormalBias = __;
+ var m_ = `#if SM_USEDISTANCE == 1
+vPositionWSM=worldPos.xyz;
+#endif
+#if SM_DEPTHTEXTURE == 1
+
+gl_Position.z+=biasAndScaleSM.x*gl_Position.w;
+#endif
+#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1
+zSM=gl_Position.z;
+gl_Position.z=0.0;
+#elif SM_USEDISTANCE == 0
+
+vDepthMetricSM=((gl_Position.z+depthValuesSM.x)/(depthValuesSM.y))+biasAndScaleSM.x;
+#endif
+`;
+ ze.a.IncludesShadersStore.shadowMapVertexMetric = m_;
+ var g_ = `
+attribute vec3 position;
+#ifdef NORMAL
+attribute vec3 normal;
+#endif
+#include
+#include
+#include[0..maxSimultaneousMorphTargets]
+
+#include
+#include
+uniform mat4 viewProjection;
+#ifdef ALPHATEST
+varying vec2 vUV;
+uniform mat4 diffuseMatrix;
+#ifdef UV1
+attribute vec2 uv;
+#endif
+#ifdef UV2
+attribute vec2 uv2;
+#endif
+#endif
+#include
+#include
+void main(void)
+{
+vec3 positionUpdated=position;
+#ifdef UV1
+vec2 uvUpdated=uv;
+#endif
+#ifdef NORMAL
+vec3 normalUpdated=normal;
+#endif
+#include[0..maxSimultaneousMorphTargets]
+#include
+#include
+vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);
+#ifdef NORMAL
+mat3 normWorldSM=mat3(finalWorld);
+#if defined(INSTANCES) && defined(THIN_INSTANCES)
+vec3 vNormalW=normalUpdated/vec3(dot(normWorldSM[0],normWorldSM[0]),dot(normWorldSM[1],normWorldSM[1]),dot(normWorldSM[2],normWorldSM[2]));
+vNormalW=normalize(normWorldSM*vNormalW);
+#else
+#ifdef NONUNIFORMSCALING
+normWorldSM=transposeMat3(inverseMat3(normWorldSM));
+#endif
+vec3 vNormalW=normalize(normWorldSM*normalUpdated);
+#endif
+#endif
+#include
+
+gl_Position=viewProjection*worldPos;
+#include
+#ifdef ALPHATEST
+#ifdef UV1
+vUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));
+#endif
+#ifdef UV2
+vUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
+#endif
+#endif
+#include
+}`;
+ ze.a.ShadersStore.shadowMapVertexShader = g_;
+ var v_ = `
+varying vec2 vUV;
+uniform sampler2D textureSampler;
+
+uniform vec2 screenSize;
+void main(void)
+{
+vec4 colorDepth=vec4(0.0);
+for (int x=-OFFSET; x<=OFFSET; x++)
+for (int y=-OFFSET; y<=OFFSET; y++)
+colorDepth+=texture2D(textureSampler,vUV+vec2(x,y)/screenSize);
+gl_FragColor=(colorDepth/float((OFFSET*2+1)*(OFFSET*2+1)));
+}`;
+ ze.a.ShadersStore.depthBoxBlurPixelShader = v_;
+ var y_ = `#if SM_SOFTTRANSPARENTSHADOW == 1
+if ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM*alpha) discard;
+#endif
+`;
+ ze.a.IncludesShadersStore.shadowMapFragmentSoftTransparentShadow = y_;
+ var gu = new u.a(), vu = new u.a(), Fn = function() {
+ function r(t, e, n) {
+ this.onBeforeShadowMapRenderObservable = new C.c(), this.onAfterShadowMapRenderObservable = new C.c(), this.onBeforeShadowMapRenderMeshObservable = new C.c(), this.onAfterShadowMapRenderMeshObservable = new C.c(), this._bias = 5e-5, this._normalBias = 0, this._blurBoxOffset = 1, this._blurScale = 2, this._blurKernel = 1, this._useKernelBlur = !1, this._filter = r.FILTER_NONE, this._filteringQuality = r.QUALITY_HIGH, this._contactHardeningLightSizeUVRatio = 0.1, this._darkness = 0, this._transparencyShadow = !1, this.enableSoftTransparentShadow = !1, this.frustumEdgeFalloff = 0, this.forceBackFacesOnly = !1, this._lightDirection = u.e.Zero(), this._viewMatrix = u.a.Zero(), this._projectionMatrix = u.a.Zero(), this._transformMatrix = u.a.Zero(), this._cachedPosition = new u.e(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), this._cachedDirection = new u.e(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), this._currentFaceIndex = 0, this._currentFaceIndexCache = 0, this._defaultTextureMatrix = u.a.Identity(), this._mapSize = t, this._light = e, this._scene = e.getScene(), e._shadowGenerator = this, this.id = e.id, r._SceneComponentInitialization(this._scene);
+ var i = this._scene.getEngine().getCaps();
+ n ? i.textureFloatRender && i.textureFloatLinearFiltering ? this._textureType = h.a.TEXTURETYPE_FLOAT : i.textureHalfFloatRender && i.textureHalfFloatLinearFiltering ? this._textureType = h.a.TEXTURETYPE_HALF_FLOAT : this._textureType = h.a.TEXTURETYPE_UNSIGNED_INT : i.textureHalfFloatRender && i.textureHalfFloatLinearFiltering ? this._textureType = h.a.TEXTURETYPE_HALF_FLOAT : i.textureFloatRender && i.textureFloatLinearFiltering ? this._textureType = h.a.TEXTURETYPE_FLOAT : this._textureType = h.a.TEXTURETYPE_UNSIGNED_INT, this._initializeGenerator(), this._applyFilterValues();
+ }
+ return Object.defineProperty(r.prototype, "bias", { get: function() {
+ return this._bias;
+ }, set: function(t) {
+ this._bias = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "normalBias", { get: function() {
+ return this._normalBias;
+ }, set: function(t) {
+ this._normalBias = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "blurBoxOffset", { get: function() {
+ return this._blurBoxOffset;
+ }, set: function(t) {
+ this._blurBoxOffset !== t && (this._blurBoxOffset = t, this._disposeBlurPostProcesses());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "blurScale", { get: function() {
+ return this._blurScale;
+ }, set: function(t) {
+ this._blurScale !== t && (this._blurScale = t, this._disposeBlurPostProcesses());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "blurKernel", { get: function() {
+ return this._blurKernel;
+ }, set: function(t) {
+ this._blurKernel !== t && (this._blurKernel = t, this._disposeBlurPostProcesses());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "useKernelBlur", { get: function() {
+ return this._useKernelBlur;
+ }, set: function(t) {
+ this._useKernelBlur !== t && (this._useKernelBlur = t, this._disposeBlurPostProcesses());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "depthScale", { get: function() {
+ return this._depthScale !== void 0 ? this._depthScale : this._light.getDepthScale();
+ }, set: function(t) {
+ this._depthScale = t;
+ }, enumerable: !1, configurable: !0 }), r.prototype._validateFilter = function(t) {
+ return t;
+ }, Object.defineProperty(r.prototype, "filter", { get: function() {
+ return this._filter;
+ }, set: function(t) {
+ if (t = this._validateFilter(t), this._light.needCube()) {
+ if (t === r.FILTER_BLUREXPONENTIALSHADOWMAP)
+ return void (this.useExponentialShadowMap = !0);
+ if (t === r.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)
+ return void (this.useCloseExponentialShadowMap = !0);
+ if (t === r.FILTER_PCF || t === r.FILTER_PCSS)
+ return void (this.usePoissonSampling = !0);
+ }
+ t !== r.FILTER_PCF && t !== r.FILTER_PCSS || this._scene.getEngine().webGLVersion !== 1 ? this._filter !== t && (this._filter = t, this._disposeBlurPostProcesses(), this._applyFilterValues(), this._light._markMeshesAsLightDirty()) : this.usePoissonSampling = !0;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "usePoissonSampling", { get: function() {
+ return this.filter === r.FILTER_POISSONSAMPLING;
+ }, set: function(t) {
+ var e = this._validateFilter(r.FILTER_POISSONSAMPLING);
+ (t || this.filter === r.FILTER_POISSONSAMPLING) && (this.filter = t ? e : r.FILTER_NONE);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "useExponentialShadowMap", { get: function() {
+ return this.filter === r.FILTER_EXPONENTIALSHADOWMAP;
+ }, set: function(t) {
+ var e = this._validateFilter(r.FILTER_EXPONENTIALSHADOWMAP);
+ (t || this.filter === r.FILTER_EXPONENTIALSHADOWMAP) && (this.filter = t ? e : r.FILTER_NONE);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "useBlurExponentialShadowMap", { get: function() {
+ return this.filter === r.FILTER_BLUREXPONENTIALSHADOWMAP;
+ }, set: function(t) {
+ var e = this._validateFilter(r.FILTER_BLUREXPONENTIALSHADOWMAP);
+ (t || this.filter === r.FILTER_BLUREXPONENTIALSHADOWMAP) && (this.filter = t ? e : r.FILTER_NONE);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "useCloseExponentialShadowMap", { get: function() {
+ return this.filter === r.FILTER_CLOSEEXPONENTIALSHADOWMAP;
+ }, set: function(t) {
+ var e = this._validateFilter(r.FILTER_CLOSEEXPONENTIALSHADOWMAP);
+ (t || this.filter === r.FILTER_CLOSEEXPONENTIALSHADOWMAP) && (this.filter = t ? e : r.FILTER_NONE);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "useBlurCloseExponentialShadowMap", { get: function() {
+ return this.filter === r.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP;
+ }, set: function(t) {
+ var e = this._validateFilter(r.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP);
+ (t || this.filter === r.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) && (this.filter = t ? e : r.FILTER_NONE);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "usePercentageCloserFiltering", { get: function() {
+ return this.filter === r.FILTER_PCF;
+ }, set: function(t) {
+ var e = this._validateFilter(r.FILTER_PCF);
+ (t || this.filter === r.FILTER_PCF) && (this.filter = t ? e : r.FILTER_NONE);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "filteringQuality", { get: function() {
+ return this._filteringQuality;
+ }, set: function(t) {
+ this._filteringQuality !== t && (this._filteringQuality = t, this._disposeBlurPostProcesses(), this._applyFilterValues(), this._light._markMeshesAsLightDirty());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "useContactHardeningShadow", { get: function() {
+ return this.filter === r.FILTER_PCSS;
+ }, set: function(t) {
+ var e = this._validateFilter(r.FILTER_PCSS);
+ (t || this.filter === r.FILTER_PCSS) && (this.filter = t ? e : r.FILTER_NONE);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "contactHardeningLightSizeUVRatio", { get: function() {
+ return this._contactHardeningLightSizeUVRatio;
+ }, set: function(t) {
+ this._contactHardeningLightSizeUVRatio = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "darkness", { get: function() {
+ return this._darkness;
+ }, set: function(t) {
+ this.setDarkness(t);
+ }, enumerable: !1, configurable: !0 }), r.prototype.getDarkness = function() {
+ return this._darkness;
+ }, r.prototype.setDarkness = function(t) {
+ return this._darkness = t >= 1 ? 1 : t <= 0 ? 0 : t, this;
+ }, Object.defineProperty(r.prototype, "transparencyShadow", { get: function() {
+ return this._transparencyShadow;
+ }, set: function(t) {
+ this.setTransparencyShadow(t);
+ }, enumerable: !1, configurable: !0 }), r.prototype.setTransparencyShadow = function(t) {
+ return this._transparencyShadow = t, this;
+ }, r.prototype.getShadowMap = function() {
+ return this._shadowMap;
+ }, r.prototype.getShadowMapForRendering = function() {
+ return this._shadowMap2 ? this._shadowMap2 : this._shadowMap;
+ }, r.prototype.getClassName = function() {
+ return r.CLASSNAME;
+ }, r.prototype.addShadowCaster = function(t, e) {
+ var n;
+ return e === void 0 && (e = !0), this._shadowMap ? (this._shadowMap.renderList || (this._shadowMap.renderList = []), this._shadowMap.renderList.push(t), e && (n = this._shadowMap.renderList).push.apply(n, t.getChildMeshes()), this) : this;
+ }, r.prototype.removeShadowCaster = function(t, e) {
+ if (e === void 0 && (e = !0), !this._shadowMap || !this._shadowMap.renderList)
+ return this;
+ var n = this._shadowMap.renderList.indexOf(t);
+ if (n !== -1 && this._shadowMap.renderList.splice(n, 1), e)
+ for (var i = 0, o = t.getChildren(); i < o.length; i++) {
+ var a = o[i];
+ this.removeShadowCaster(a);
+ }
+ return this;
+ }, r.prototype.getLight = function() {
+ return this._light;
+ }, Object.defineProperty(r.prototype, "mapSize", { get: function() {
+ return this._mapSize;
+ }, set: function(t) {
+ this._mapSize = t, this._light._markMeshesAsLightDirty(), this.recreateShadowMap();
+ }, enumerable: !1, configurable: !0 }), r.prototype._initializeGenerator = function() {
+ this._light._markMeshesAsLightDirty(), this._initializeShadowMap();
+ }, r.prototype._createTargetRenderTexture = function() {
+ this._scene.getEngine().webGLVersion > 1 ? (this._shadowMap = new on(this._light.name + "_shadowMap", this._mapSize, this._scene, !1, !0, this._textureType, this._light.needCube(), void 0, !1, !1), this._shadowMap.createDepthStencilTexture(h.a.LESS, !0)) : this._shadowMap = new on(this._light.name + "_shadowMap", this._mapSize, this._scene, !1, !0, this._textureType, this._light.needCube());
+ }, r.prototype._initializeShadowMap = function() {
+ var t = this;
+ if (this._createTargetRenderTexture(), this._shadowMap !== null) {
+ this._shadowMap.wrapU = Ne.a.CLAMP_ADDRESSMODE, this._shadowMap.wrapV = Ne.a.CLAMP_ADDRESSMODE, this._shadowMap.anisotropicFilteringLevel = 1, this._shadowMap.updateSamplingMode(Ne.a.BILINEAR_SAMPLINGMODE), this._shadowMap.renderParticles = !1, this._shadowMap.ignoreCameraViewport = !0, this._storedUniqueId && (this._shadowMap.uniqueId = this._storedUniqueId), this._shadowMap.customRenderFunction = this._renderForShadowMap.bind(this), this._shadowMap.customIsReadyFunction = function(a, s) {
+ return !0;
+ };
+ var e = this._scene.getEngine();
+ this._shadowMap.onBeforeRenderObservable.add(function(a) {
+ if (t._currentFaceIndex = a, t._filter === r.FILTER_PCF && e.setColorWrite(!1), t._scene.getSceneUniformBuffer().useUbo) {
+ var s = t._scene.getSceneUniformBuffer();
+ s.updateMatrix("viewProjection", t.getTransformMatrix()), s.updateMatrix("view", t._viewMatrix), s.update();
+ }
+ }), this._shadowMap.onAfterUnbindObservable.add(function() {
+ if (t._scene.getSceneUniformBuffer().useUbo) {
+ var a = t._scene.getSceneUniformBuffer();
+ a.updateMatrix("viewProjection", t._scene.getTransformMatrix()), a.updateMatrix("view", t._scene.getViewMatrix()), a.update();
+ }
+ if (t._filter === r.FILTER_PCF && e.setColorWrite(!0), t.useBlurExponentialShadowMap || t.useBlurCloseExponentialShadowMap) {
+ var s = t.getShadowMapForRendering();
+ if (s) {
+ var d = s.getInternalTexture();
+ t._scene.postProcessManager.directRender(t._blurPostProcesses, d, !0), e.unBindFramebuffer(d, !0);
+ }
+ }
+ });
+ var n = new I.b(0, 0, 0, 0), i = new I.b(1, 1, 1, 1);
+ this._shadowMap.onClearObservable.add(function(a) {
+ t._filter === r.FILTER_PCF ? a.clear(i, !1, !0, !1) : t.useExponentialShadowMap || t.useBlurExponentialShadowMap ? a.clear(n, !0, !0, !1) : a.clear(i, !0, !0, !1);
+ }), this._shadowMap.onResizeObservable.add(function(a) {
+ t._storedUniqueId = t._shadowMap.uniqueId, t._mapSize = a.getRenderSize(), t._light._markMeshesAsLightDirty(), t.recreateShadowMap();
+ });
+ for (var o = Hr.b.MIN_RENDERINGGROUPS; o < Hr.b.MAX_RENDERINGGROUPS; o++)
+ this._shadowMap.setRenderingAutoClearDepthStencil(o, !1);
+ }
+ }, r.prototype._initializeBlurRTTAndPostProcesses = function() {
+ var t = this, e = this._scene.getEngine(), n = this._mapSize / this.blurScale;
+ this.useKernelBlur && this.blurScale === 1 || (this._shadowMap2 = new on(this._light.name + "_shadowMap2", n, this._scene, !1, !0, this._textureType), this._shadowMap2.wrapU = Ne.a.CLAMP_ADDRESSMODE, this._shadowMap2.wrapV = Ne.a.CLAMP_ADDRESSMODE, this._shadowMap2.updateSamplingMode(Ne.a.BILINEAR_SAMPLINGMODE)), this.useKernelBlur ? (this._kernelBlurXPostprocess = new _n(this._light.name + "KernelBlurX", new u.d(1, 0), this.blurKernel, 1, null, Ne.a.BILINEAR_SAMPLINGMODE, e, !1, this._textureType), this._kernelBlurXPostprocess.width = n, this._kernelBlurXPostprocess.height = n, this._kernelBlurXPostprocess.onApplyObservable.add(function(i) {
+ i.setTexture("textureSampler", t._shadowMap);
+ }), this._kernelBlurYPostprocess = new _n(this._light.name + "KernelBlurY", new u.d(0, 1), this.blurKernel, 1, null, Ne.a.BILINEAR_SAMPLINGMODE, e, !1, this._textureType), this._kernelBlurXPostprocess.autoClear = !1, this._kernelBlurYPostprocess.autoClear = !1, this._textureType === h.a.TEXTURETYPE_UNSIGNED_INT && (this._kernelBlurXPostprocess.packedFloat = !0, this._kernelBlurYPostprocess.packedFloat = !0), this._blurPostProcesses = [this._kernelBlurXPostprocess, this._kernelBlurYPostprocess]) : (this._boxBlurPostprocess = new ft(this._light.name + "DepthBoxBlur", "depthBoxBlur", ["screenSize", "boxOffset"], [], 1, null, Ne.a.BILINEAR_SAMPLINGMODE, e, !1, "#define OFFSET " + this._blurBoxOffset, this._textureType), this._boxBlurPostprocess.onApplyObservable.add(function(i) {
+ i.setFloat2("screenSize", n, n), i.setTexture("textureSampler", t._shadowMap);
+ }), this._boxBlurPostprocess.autoClear = !1, this._blurPostProcesses = [this._boxBlurPostprocess]);
+ }, r.prototype._renderForShadowMap = function(t, e, n, i) {
+ var o, a = this._scene.getEngine(), s = a.getColorWrite();
+ if (i.length) {
+ for (a.setColorWrite(!1), o = 0; o < i.length; o++)
+ this._renderSubMeshForShadowMap(i.data[o]);
+ a.setColorWrite(s);
+ }
+ for (o = 0; o < t.length; o++)
+ this._renderSubMeshForShadowMap(t.data[o]);
+ for (o = 0; o < e.length; o++)
+ this._renderSubMeshForShadowMap(e.data[o]);
+ if (this._transparencyShadow)
+ for (o = 0; o < n.length; o++)
+ this._renderSubMeshForShadowMap(n.data[o], !0);
+ else
+ for (o = 0; o < n.length; o++)
+ n.data[o].getEffectiveMesh()._internalAbstractMeshDataInfo._isActiveIntermediate = !1;
+ }, r.prototype._bindCustomEffectForRenderSubMeshForShadowMap = function(t, e, n, i) {
+ var o, a, s, d, p, y;
+ e.setMatrix((o = n == null ? void 0 : n.viewProjection) !== null && o !== void 0 ? o : "viewProjection", this.getTransformMatrix()), e.setMatrix((a = n == null ? void 0 : n.view) !== null && a !== void 0 ? a : "view", this._viewMatrix), e.setMatrix((s = n == null ? void 0 : n.projection) !== null && s !== void 0 ? s : "projection", this._projectionMatrix);
+ var P = i.getWorldMatrix();
+ e.setMatrix((d = n == null ? void 0 : n.world) !== null && d !== void 0 ? d : "world", P), P.multiplyToRef(this.getTransformMatrix(), gu), e.setMatrix((p = n == null ? void 0 : n.worldViewProjection) !== null && p !== void 0 ? p : "worldViewProjection", gu), P.multiplyToRef(this._viewMatrix, vu), e.setMatrix((y = n == null ? void 0 : n.worldView) !== null && y !== void 0 ? y : "worldView", vu);
+ }, r.prototype._renderSubMeshForShadowMap = function(t, e) {
+ var n, i;
+ e === void 0 && (e = !1);
+ var o = t.getRenderingMesh(), a = t.getEffectiveMesh(), s = this._scene, d = s.getEngine(), p = t.getMaterial();
+ if (a._internalAbstractMeshDataInfo._isActiveIntermediate = !1, p && t.verticesCount !== 0 && t._renderId !== s.getRenderId()) {
+ d.setState(p.backFaceCulling);
+ var y = o._getInstancesRenderList(t._id, !!t.getReplacementMesh());
+ if (!y.mustReturn) {
+ var P = d.getCaps().instancedArrays && (y.visibleInstances[t._id] !== null && y.visibleInstances[t._id] !== void 0 || o.hasThinInstances);
+ if (!this.customAllowRendering || this.customAllowRendering(t))
+ if (this.isReady(t, P, e)) {
+ t._renderId = s.getRenderId();
+ var R = (n = o.material) === null || n === void 0 ? void 0 : n.shadowDepthWrapper, B = (i = R == null ? void 0 : R.getEffect(t, this)) !== null && i !== void 0 ? i : this._effect;
+ if (d.enableEffect(B), o._bind(t, B, p.fillMode), this.getTransformMatrix(), B.setFloat3("biasAndScaleSM", this.bias, this.normalBias, this.depthScale), this.getLight().getTypeID() === bi.a.LIGHTTYPEID_DIRECTIONALLIGHT ? B.setVector3("lightDataSM", this._cachedDirection) : B.setVector3("lightDataSM", this._cachedPosition), s.activeCamera && B.setFloat2("depthValuesSM", this.getLight().getDepthMinZ(s.activeCamera), this.getLight().getDepthMinZ(s.activeCamera) + this.getLight().getDepthMaxZ(s.activeCamera)), e && this.enableSoftTransparentShadow && B.setFloat("softTransparentShadowSM", a.visibility), R)
+ t._effectOverride = B, R.standalone ? R.baseMaterial.bindForSubMesh(a.getWorldMatrix(), o, t) : p.bindForSubMesh(a.getWorldMatrix(), o, t), t._effectOverride = null;
+ else {
+ if (B.setMatrix("viewProjection", this.getTransformMatrix()), p && p.needAlphaTesting()) {
+ var F = p.getAlphaTestTexture();
+ F && (B.setTexture("diffuseSampler", F), B.setMatrix("diffuseMatrix", F.getTextureMatrix() || this._defaultTextureMatrix));
+ }
+ if (o.useBones && o.computeBonesUsingShaders && o.skeleton) {
+ var z = o.skeleton;
+ if (z.isUsingTextureForMatrices) {
+ var J = z.getTransformMatrixTexture(o);
+ if (!J)
+ return;
+ B.setTexture("boneSampler", J), B.setFloat("boneTextureWidth", 4 * (z.bones.length + 1));
+ } else
+ B.setMatrices("mBones", z.getTransformMatrices(o));
+ }
+ $e.a.BindMorphTargetParameters(o, B), $e.a.BindClipPlane(B, s);
+ }
+ this._bindCustomEffectForRenderSubMeshForShadowMap(t, B, R == null ? void 0 : R._matriceNames, a), this.forceBackFacesOnly && d.setState(!0, 0, !1, !0), this.onBeforeShadowMapRenderMeshObservable.notifyObservers(o), this.onBeforeShadowMapRenderObservable.notifyObservers(B), o._processRendering(a, t, B, p.fillMode, y, P, function(ie, se) {
+ return B.setMatrix("world", se);
+ }), this.forceBackFacesOnly && d.setState(!0, 0, !1, !1), this.onAfterShadowMapRenderObservable.notifyObservers(B), this.onAfterShadowMapRenderMeshObservable.notifyObservers(o);
+ } else
+ this._shadowMap && this._shadowMap.resetRefreshCounter();
+ }
+ }
+ }, r.prototype._applyFilterValues = function() {
+ this._shadowMap && (this.filter === r.FILTER_NONE || this.filter === r.FILTER_PCSS ? this._shadowMap.updateSamplingMode(Ne.a.NEAREST_SAMPLINGMODE) : this._shadowMap.updateSamplingMode(Ne.a.BILINEAR_SAMPLINGMODE));
+ }, r.prototype.forceCompilation = function(t, e) {
+ var n = this, i = Object(c.a)({ useInstances: !1 }, e), o = this.getShadowMap();
+ if (o) {
+ var a = o.renderList;
+ if (a) {
+ for (var s = new Array(), d = 0, p = a; d < p.length; d++) {
+ var y = p[d];
+ s.push.apply(s, y.subMeshes);
+ }
+ if (s.length !== 0) {
+ var P = 0, R = function() {
+ var B, F;
+ if (n._scene && n._scene.getEngine()) {
+ for (; n.isReady(s[P], i.useInstances, (F = (B = s[P].getMaterial()) === null || B === void 0 ? void 0 : B.needAlphaBlendingForMesh(s[P].getMesh())) !== null && F !== void 0 && F); )
+ if (++P >= s.length)
+ return void (t && t(n));
+ setTimeout(R, 16);
+ }
+ };
+ R();
+ } else
+ t && t(this);
+ } else
+ t && t(this);
+ } else
+ t && t(this);
+ }, r.prototype.forceCompilationAsync = function(t) {
+ var e = this;
+ return new Promise(function(n) {
+ e.forceCompilation(function() {
+ n();
+ }, t);
+ });
+ }, r.prototype._isReadyCustomDefines = function(t, e, n) {
+ }, r.prototype._prepareShadowDefines = function(t, e, n, i) {
+ n.push("#define SM_FLOAT " + (this._textureType !== h.a.TEXTURETYPE_UNSIGNED_INT ? "1" : "0")), n.push("#define SM_ESM " + (this.useExponentialShadowMap || this.useBlurExponentialShadowMap ? "1" : "0")), n.push("#define SM_DEPTHTEXTURE " + (this.usePercentageCloserFiltering || this.useContactHardeningShadow ? "1" : "0"));
+ var o = t.getMesh();
+ return n.push("#define SM_NORMALBIAS " + (this.normalBias && o.isVerticesDataPresent(Oe.b.NormalKind) ? "1" : "0")), n.push("#define SM_DIRECTIONINLIGHTDATA " + (this.getLight().getTypeID() === bi.a.LIGHTTYPEID_DIRECTIONALLIGHT ? "1" : "0")), n.push("#define SM_USEDISTANCE " + (this._light.needCube() ? "1" : "0")), n.push("#define SM_SOFTTRANSPARENTSHADOW " + (this.enableSoftTransparentShadow && i ? "1" : "0")), this._isReadyCustomDefines(n, t, e), n;
+ }, r.prototype.isReady = function(t, e, n) {
+ var i = t.getMaterial(), o = i == null ? void 0 : i.shadowDepthWrapper, a = [];
+ if (this._prepareShadowDefines(t, e, a, n), o) {
+ if (!o.isReadyForSubMesh(t, a, this, e))
+ return !1;
+ } else {
+ var s = [Oe.b.PositionKind], d = t.getMesh();
+ if (this.normalBias && d.isVerticesDataPresent(Oe.b.NormalKind) && (s.push(Oe.b.NormalKind), a.push("#define NORMAL"), d.nonUniformScaling && a.push("#define NONUNIFORMSCALING")), i && i.needAlphaTesting()) {
+ var p = i.getAlphaTestTexture();
+ if (p) {
+ if (!p.isReady())
+ return !1;
+ a.push("#define ALPHATEST"), d.isVerticesDataPresent(Oe.b.UVKind) && (s.push(Oe.b.UVKind), a.push("#define UV1")), d.isVerticesDataPresent(Oe.b.UV2Kind) && p.coordinatesIndex === 1 && (s.push(Oe.b.UV2Kind), a.push("#define UV2"));
+ }
+ }
+ var y = new _r.a();
+ if (d.useBones && d.computeBonesUsingShaders && d.skeleton) {
+ s.push(Oe.b.MatricesIndicesKind), s.push(Oe.b.MatricesWeightsKind), d.numBoneInfluencers > 4 && (s.push(Oe.b.MatricesIndicesExtraKind), s.push(Oe.b.MatricesWeightsExtraKind));
+ var P = d.skeleton;
+ a.push("#define NUM_BONE_INFLUENCERS " + d.numBoneInfluencers), d.numBoneInfluencers > 0 && y.addCPUSkinningFallback(0, d), P.isUsingTextureForMatrices ? a.push("#define BONETEXTURE") : a.push("#define BonesPerMesh " + (P.bones.length + 1));
+ } else
+ a.push("#define NUM_BONE_INFLUENCERS 0");
+ var R = d.morphTargetManager, B = 0;
+ R && R.numInfluencers > 0 && (a.push("#define MORPHTARGETS"), B = R.numInfluencers, a.push("#define NUM_MORPH_INFLUENCERS " + B), $e.a.PrepareAttributesForMorphTargetsInfluencers(s, d, B));
+ var F = this._scene;
+ if (F.clipPlane && a.push("#define CLIPPLANE"), F.clipPlane2 && a.push("#define CLIPPLANE2"), F.clipPlane3 && a.push("#define CLIPPLANE3"), F.clipPlane4 && a.push("#define CLIPPLANE4"), F.clipPlane5 && a.push("#define CLIPPLANE5"), F.clipPlane6 && a.push("#define CLIPPLANE6"), e && (a.push("#define INSTANCES"), $e.a.PushAttributesForInstances(s), t.getRenderingMesh().hasThinInstances && a.push("#define THIN_INSTANCES")), this.customShaderOptions && this.customShaderOptions.defines)
+ for (var z = 0, J = this.customShaderOptions.defines; z < J.length; z++) {
+ var ie = J[z];
+ a.indexOf(ie) === -1 && a.push(ie);
+ }
+ var se = a.join(`
+`);
+ if (this._cachedDefines !== se) {
+ this._cachedDefines = se;
+ var ce = "shadowMap", ue = ["world", "mBones", "viewProjection", "diffuseMatrix", "lightDataSM", "depthValuesSM", "biasAndScaleSM", "morphTargetInfluences", "boneTextureWidth", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "softTransparentShadowSM"], fe = ["diffuseSampler", "boneSampler"];
+ if (this.customShaderOptions) {
+ if (ce = this.customShaderOptions.shaderName, this.customShaderOptions.attributes)
+ for (var ve = 0, Te = this.customShaderOptions.attributes; ve < Te.length; ve++) {
+ var Re = Te[ve];
+ s.indexOf(Re) === -1 && s.push(Re);
+ }
+ if (this.customShaderOptions.uniforms)
+ for (var Ae = 0, Ee = this.customShaderOptions.uniforms; Ae < Ee.length; Ae++) {
+ var Se = Ee[Ae];
+ ue.indexOf(Se) === -1 && ue.push(Se);
+ }
+ if (this.customShaderOptions.samplers)
+ for (var De = 0, xe = this.customShaderOptions.samplers; De < xe.length; De++) {
+ var Le = xe[De];
+ fe.indexOf(Le) === -1 && fe.push(Le);
+ }
+ }
+ this._effect = this._scene.getEngine().createEffect(ce, s, ue, fe, se, y, void 0, void 0, { maxSimultaneousMorphTargets: B });
+ }
+ if (!this._effect.isReady())
+ return !1;
+ }
+ return (this.useBlurExponentialShadowMap || this.useBlurCloseExponentialShadowMap) && (this._blurPostProcesses && this._blurPostProcesses.length || this._initializeBlurRTTAndPostProcesses()), !(this._kernelBlurXPostprocess && !this._kernelBlurXPostprocess.isReady()) && !(this._kernelBlurYPostprocess && !this._kernelBlurYPostprocess.isReady()) && !(this._boxBlurPostprocess && !this._boxBlurPostprocess.isReady());
+ }, r.prototype.prepareDefines = function(t, e) {
+ var n = this._scene, i = this._light;
+ n.shadowsEnabled && i.shadowEnabled && (t["SHADOW" + e] = !0, this.useContactHardeningShadow ? (t["SHADOWPCSS" + e] = !0, this._filteringQuality === r.QUALITY_LOW ? t["SHADOWLOWQUALITY" + e] = !0 : this._filteringQuality === r.QUALITY_MEDIUM && (t["SHADOWMEDIUMQUALITY" + e] = !0)) : this.usePercentageCloserFiltering ? (t["SHADOWPCF" + e] = !0, this._filteringQuality === r.QUALITY_LOW ? t["SHADOWLOWQUALITY" + e] = !0 : this._filteringQuality === r.QUALITY_MEDIUM && (t["SHADOWMEDIUMQUALITY" + e] = !0)) : this.usePoissonSampling ? t["SHADOWPOISSON" + e] = !0 : this.useExponentialShadowMap || this.useBlurExponentialShadowMap ? t["SHADOWESM" + e] = !0 : (this.useCloseExponentialShadowMap || this.useBlurCloseExponentialShadowMap) && (t["SHADOWCLOSEESM" + e] = !0), i.needCube() && (t["SHADOWCUBE" + e] = !0));
+ }, r.prototype.bindShadowLight = function(t, e) {
+ var n = this._light, i = this._scene;
+ if (i.shadowsEnabled && n.shadowEnabled) {
+ var o = i.activeCamera;
+ if (o) {
+ var a = this.getShadowMap();
+ a && (n.needCube() || e.setMatrix("lightMatrix" + t, this.getTransformMatrix()), this._filter === r.FILTER_PCF ? (e.setDepthStencilTexture("shadowSampler" + t, this.getShadowMapForRendering()), n._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), a.getSize().width, 1 / a.getSize().width, this.frustumEdgeFalloff, t)) : this._filter === r.FILTER_PCSS ? (e.setDepthStencilTexture("shadowSampler" + t, this.getShadowMapForRendering()), e.setTexture("depthSampler" + t, this.getShadowMapForRendering()), n._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / a.getSize().width, this._contactHardeningLightSizeUVRatio * a.getSize().width, this.frustumEdgeFalloff, t)) : (e.setTexture("shadowSampler" + t, this.getShadowMapForRendering()), n._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), this.blurScale / a.getSize().width, this.depthScale, this.frustumEdgeFalloff, t)), n._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(o), this.getLight().getDepthMinZ(o) + this.getLight().getDepthMaxZ(o), t));
+ }
+ }
+ }, r.prototype.getTransformMatrix = function() {
+ var t = this._scene;
+ if (this._currentRenderID === t.getRenderId() && this._currentFaceIndexCache === this._currentFaceIndex)
+ return this._transformMatrix;
+ this._currentRenderID = t.getRenderId(), this._currentFaceIndexCache = this._currentFaceIndex;
+ var e = this._light.position;
+ if (this._light.computeTransformedInformation() && (e = this._light.transformedPosition), u.e.NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex), this._lightDirection), Math.abs(u.e.Dot(this._lightDirection, u.e.Up())) === 1 && (this._lightDirection.z = 1e-13), this._light.needProjectionMatrixCompute() || !this._cachedPosition || !this._cachedDirection || !e.equals(this._cachedPosition) || !this._lightDirection.equals(this._cachedDirection)) {
+ this._cachedPosition.copyFrom(e), this._cachedDirection.copyFrom(this._lightDirection), u.a.LookAtLHToRef(e, e.add(this._lightDirection), u.e.Up(), this._viewMatrix);
+ var n = this.getShadowMap();
+ if (n) {
+ var i = n.renderList;
+ i && this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, i);
+ }
+ this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
+ }
+ return this._transformMatrix;
+ }, r.prototype.recreateShadowMap = function() {
+ var t = this._shadowMap;
+ if (t) {
+ var e = t.renderList;
+ this._disposeRTTandPostProcesses(), this._initializeGenerator(), this.filter = this.filter, this._applyFilterValues(), this._shadowMap.renderList = e;
+ }
+ }, r.prototype._disposeBlurPostProcesses = function() {
+ this._shadowMap2 && (this._shadowMap2.dispose(), this._shadowMap2 = null), this._boxBlurPostprocess && (this._boxBlurPostprocess.dispose(), this._boxBlurPostprocess = null), this._kernelBlurXPostprocess && (this._kernelBlurXPostprocess.dispose(), this._kernelBlurXPostprocess = null), this._kernelBlurYPostprocess && (this._kernelBlurYPostprocess.dispose(), this._kernelBlurYPostprocess = null), this._blurPostProcesses = [];
+ }, r.prototype._disposeRTTandPostProcesses = function() {
+ this._shadowMap && (this._shadowMap.dispose(), this._shadowMap = null), this._disposeBlurPostProcesses();
+ }, r.prototype.dispose = function() {
+ this._disposeRTTandPostProcesses(), this._light && (this._light._shadowGenerator = null, this._light._markMeshesAsLightDirty()), this.onBeforeShadowMapRenderMeshObservable.clear(), this.onBeforeShadowMapRenderObservable.clear(), this.onAfterShadowMapRenderMeshObservable.clear(), this.onAfterShadowMapRenderObservable.clear();
+ }, r.prototype.serialize = function() {
+ var t = {}, e = this.getShadowMap();
+ if (!e)
+ return t;
+ if (t.className = this.getClassName(), t.lightId = this._light.id, t.id = this._light.id, t.mapSize = e.getRenderSize(), t.forceBackFacesOnly = this.forceBackFacesOnly, t.darkness = this.getDarkness(), t.transparencyShadow = this._transparencyShadow, t.frustumEdgeFalloff = this.frustumEdgeFalloff, t.bias = this.bias, t.normalBias = this.normalBias, t.usePercentageCloserFiltering = this.usePercentageCloserFiltering, t.useContactHardeningShadow = this.useContactHardeningShadow, t.contactHardeningLightSizeUVRatio = this.contactHardeningLightSizeUVRatio, t.filteringQuality = this.filteringQuality, t.useExponentialShadowMap = this.useExponentialShadowMap, t.useBlurExponentialShadowMap = this.useBlurExponentialShadowMap, t.useCloseExponentialShadowMap = this.useBlurExponentialShadowMap, t.useBlurCloseExponentialShadowMap = this.useBlurExponentialShadowMap, t.usePoissonSampling = this.usePoissonSampling, t.depthScale = this.depthScale, t.blurBoxOffset = this.blurBoxOffset, t.blurKernel = this.blurKernel, t.blurScale = this.blurScale, t.useKernelBlur = this.useKernelBlur, t.renderList = [], e.renderList)
+ for (var n = 0; n < e.renderList.length; n++) {
+ var i = e.renderList[n];
+ t.renderList.push(i.id);
+ }
+ return t;
+ }, r.Parse = function(t, e, n) {
+ for (var i = e.getLightByID(t.lightId), o = n ? n(t.mapSize, i) : new r(t.mapSize, i), a = o.getShadowMap(), s = 0; s < t.renderList.length; s++)
+ e.getMeshesByID(t.renderList[s]).forEach(function(d) {
+ a && (a.renderList || (a.renderList = []), a.renderList.push(d));
+ });
+ return t.id !== void 0 && (o.id = t.id), o.forceBackFacesOnly = !!t.forceBackFacesOnly, t.darkness !== void 0 && o.setDarkness(t.darkness), t.transparencyShadow && o.setTransparencyShadow(!0), t.frustumEdgeFalloff !== void 0 && (o.frustumEdgeFalloff = t.frustumEdgeFalloff), t.bias !== void 0 && (o.bias = t.bias), t.normalBias !== void 0 && (o.normalBias = t.normalBias), t.usePercentageCloserFiltering ? o.usePercentageCloserFiltering = !0 : t.useContactHardeningShadow ? o.useContactHardeningShadow = !0 : t.usePoissonSampling ? o.usePoissonSampling = !0 : t.useExponentialShadowMap ? o.useExponentialShadowMap = !0 : t.useBlurExponentialShadowMap ? o.useBlurExponentialShadowMap = !0 : t.useCloseExponentialShadowMap ? o.useCloseExponentialShadowMap = !0 : t.useBlurCloseExponentialShadowMap ? o.useBlurCloseExponentialShadowMap = !0 : t.useVarianceShadowMap ? o.useExponentialShadowMap = !0 : t.useBlurVarianceShadowMap && (o.useBlurExponentialShadowMap = !0), t.contactHardeningLightSizeUVRatio !== void 0 && (o.contactHardeningLightSizeUVRatio = t.contactHardeningLightSizeUVRatio), t.filteringQuality !== void 0 && (o.filteringQuality = t.filteringQuality), t.depthScale && (o.depthScale = t.depthScale), t.blurScale && (o.blurScale = t.blurScale), t.blurBoxOffset && (o.blurBoxOffset = t.blurBoxOffset), t.useKernelBlur && (o.useKernelBlur = t.useKernelBlur), t.blurKernel && (o.blurKernel = t.blurKernel), o;
+ }, r.CLASSNAME = "ShadowGenerator", r.FILTER_NONE = 0, r.FILTER_EXPONENTIALSHADOWMAP = 1, r.FILTER_POISSONSAMPLING = 2, r.FILTER_BLUREXPONENTIALSHADOWMAP = 3, r.FILTER_CLOSEEXPONENTIALSHADOWMAP = 4, r.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP = 5, r.FILTER_PCF = 6, r.FILTER_PCSS = 7, r.QUALITY_HIGH = 0, r.QUALITY_MEDIUM = 1, r.QUALITY_LOW = 2, r._SceneComponentInitialization = function(t) {
+ throw En.a.WarnImport("ShadowGeneratorSceneComponent");
+ }, r;
+ }(), b_ = `#ifdef ALPHATEST
+varying vec2 vUV;
+uniform sampler2D diffuseSampler;
+#endif
+varying float vDepthMetric;
+#ifdef PACKED
+#include
+#endif
+void main(void)
+{
+#ifdef ALPHATEST
+if (texture2D(diffuseSampler,vUV).a<0.4)
+discard;
+#endif
+#ifdef NONLINEARDEPTH
+#ifdef PACKED
+gl_FragColor=pack(gl_FragCoord.z);
+#else
+gl_FragColor=vec4(gl_FragCoord.z,0.0,0.0,0.0);
+#endif
+#else
+#ifdef PACKED
+gl_FragColor=pack(vDepthMetric);
+#else
+gl_FragColor=vec4(vDepthMetric,0.0,0.0,1.0);
+#endif
+#endif
+}`;
+ ze.a.ShadersStore.depthPixelShader = b_;
+ var T_ = `
+attribute vec3 position;
+#include
+#include
+#include[0..maxSimultaneousMorphTargets]
+
+#include
+uniform mat4 viewProjection;
+uniform vec2 depthValues;
+#if defined(ALPHATEST) || defined(NEED_UV)
+varying vec2 vUV;
+uniform mat4 diffuseMatrix;
+#ifdef UV1
+attribute vec2 uv;
+#endif
+#ifdef UV2
+attribute vec2 uv2;
+#endif
+#endif
+varying float vDepthMetric;
+void main(void)
+{
+vec3 positionUpdated=position;
+#ifdef UV1
+vec2 uvUpdated=uv;
+#endif
+#include[0..maxSimultaneousMorphTargets]
+#include
+#include
+gl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);
+vDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y));
+#if defined(ALPHATEST) || defined(BASIC_RENDER)
+#ifdef UV1
+vUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));
+#endif
+#ifdef UV2
+vUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
+#endif
+#endif
+}
+`;
+ ze.a.ShadersStore.depthVertexShader = T_;
+ var Qo = function() {
+ function r(t, e, n, i) {
+ var o = this;
+ e === void 0 && (e = h.a.TEXTURETYPE_FLOAT), n === void 0 && (n = null), i === void 0 && (i = !1), this.enabled = !0, this.useOnlyInActiveCamera = !1, this._scene = t, this._storeNonLinearDepth = i, this.isPacked = e === h.a.TEXTURETYPE_UNSIGNED_BYTE, this.isPacked ? this._clearColor = new I.b(1, 1, 1, 1) : this._clearColor = new I.b(1, 0, 0, 1), r._SceneComponentInitialization(this._scene), this._camera = n;
+ var a = t.getEngine(), s = this.isPacked || a.webGLVersion === 1 ? h.a.TEXTUREFORMAT_RGBA : h.a.TEXTUREFORMAT_R;
+ this._depthMap = new on("depthMap", { width: a.getRenderWidth(), height: a.getRenderHeight() }, this._scene, !1, !0, e, !1, void 0, void 0, void 0, void 0, s), this._depthMap.wrapU = Ne.a.CLAMP_ADDRESSMODE, this._depthMap.wrapV = Ne.a.CLAMP_ADDRESSMODE, this._depthMap.refreshRate = 1, this._depthMap.renderParticles = !1, this._depthMap.renderList = null, this._depthMap.activeCamera = this._camera, this._depthMap.ignoreCameraViewport = !0, this._depthMap.useCameraPostProcesses = !1, this._depthMap.onClearObservable.add(function(p) {
+ p.clear(o._clearColor, !0, !0, !0);
+ });
+ var d = function(p) {
+ var y = p.getRenderingMesh(), P = p.getEffectiveMesh(), R = o._scene, B = R.getEngine(), F = p.getMaterial();
+ if (P._internalAbstractMeshDataInfo._isActiveIntermediate = !1, F && p.verticesCount !== 0 && p._renderId !== R.getRenderId()) {
+ B.setState(F.backFaceCulling, 0, !1, R.useRightHandedSystem);
+ var z = y._getInstancesRenderList(p._id, !!p.getReplacementMesh());
+ if (!z.mustReturn) {
+ var J = B.getCaps().instancedArrays && (z.visibleInstances[p._id] !== null && z.visibleInstances[p._id] !== void 0 || y.hasThinInstances), ie = o._camera || R.activeCamera;
+ if (o.isReady(p, J) && ie) {
+ if (p._renderId = R.getRenderId(), B.enableEffect(o._effect), y._bind(p, o._effect, F.fillMode), o._effect.setMatrix("viewProjection", R.getTransformMatrix()), o._effect.setFloat2("depthValues", ie.minZ, ie.minZ + ie.maxZ), F && F.needAlphaTesting()) {
+ var se = F.getAlphaTestTexture();
+ se && (o._effect.setTexture("diffuseSampler", se), o._effect.setMatrix("diffuseMatrix", se.getTextureMatrix()));
+ }
+ y.useBones && y.computeBonesUsingShaders && y.skeleton && o._effect.setMatrices("mBones", y.skeleton.getTransformMatrices(y)), $e.a.BindMorphTargetParameters(y, o._effect), y._processRendering(P, p, o._effect, F.fillMode, z, J, function(ce, ue) {
+ return o._effect.setMatrix("world", ue);
+ });
+ }
+ }
+ }
+ };
+ this._depthMap.customRenderFunction = function(p, y, P, R) {
+ var B;
+ if (R.length) {
+ for (a.setColorWrite(!1), B = 0; B < R.length; B++)
+ d(R.data[B]);
+ a.setColorWrite(!0);
+ }
+ for (B = 0; B < p.length; B++)
+ d(p.data[B]);
+ for (B = 0; B < y.length; B++)
+ d(y.data[B]);
+ };
+ }
+ return r.prototype.isReady = function(t, e) {
+ var n = t.getMaterial();
+ if (n.disableDepthWrite)
+ return !1;
+ var i = [], o = [Oe.b.PositionKind], a = t.getMesh();
+ n && n.needAlphaTesting() && n.getAlphaTestTexture() && (i.push("#define ALPHATEST"), a.isVerticesDataPresent(Oe.b.UVKind) && (o.push(Oe.b.UVKind), i.push("#define UV1")), a.isVerticesDataPresent(Oe.b.UV2Kind) && (o.push(Oe.b.UV2Kind), i.push("#define UV2"))), a.useBones && a.computeBonesUsingShaders ? (o.push(Oe.b.MatricesIndicesKind), o.push(Oe.b.MatricesWeightsKind), a.numBoneInfluencers > 4 && (o.push(Oe.b.MatricesIndicesExtraKind), o.push(Oe.b.MatricesWeightsExtraKind)), i.push("#define NUM_BONE_INFLUENCERS " + a.numBoneInfluencers), i.push("#define BonesPerMesh " + (a.skeleton ? a.skeleton.bones.length + 1 : 0))) : i.push("#define NUM_BONE_INFLUENCERS 0");
+ var s = a.morphTargetManager, d = 0;
+ s && s.numInfluencers > 0 && (d = s.numInfluencers, i.push("#define MORPHTARGETS"), i.push("#define NUM_MORPH_INFLUENCERS " + d), $e.a.PrepareAttributesForMorphTargetsInfluencers(o, a, d)), e && (i.push("#define INSTANCES"), $e.a.PushAttributesForInstances(o), t.getRenderingMesh().hasThinInstances && i.push("#define THIN_INSTANCES")), this._storeNonLinearDepth && i.push("#define NONLINEARDEPTH"), this.isPacked && i.push("#define PACKED");
+ var p = i.join(`
+`);
+ return this._cachedDefines !== p && (this._cachedDefines = p, this._effect = this._scene.getEngine().createEffect("depth", o, ["world", "mBones", "viewProjection", "diffuseMatrix", "depthValues", "morphTargetInfluences"], ["diffuseSampler"], p, void 0, void 0, void 0, { maxSimultaneousMorphTargets: d })), this._effect.isReady();
+ }, r.prototype.getDepthMap = function() {
+ return this._depthMap;
+ }, r.prototype.dispose = function() {
+ this._depthMap.dispose();
+ }, r._SceneComponentInitialization = function(t) {
+ throw En.a.WarnImport("DepthRendererSceneComponent");
+ }, r;
+ }(), E_ = `attribute vec2 vUV;
+uniform sampler2D textureSampler;
+#if defined(INITIAL)
+uniform sampler2D sourceTexture;
+uniform vec2 texSize;
+void main(void)
+{
+ivec2 coord=ivec2(vUV*(texSize-1.0));
+float f1=texelFetch(sourceTexture,coord,0).r;
+float f2=texelFetch(sourceTexture,coord+ivec2(1,0),0).r;
+float f3=texelFetch(sourceTexture,coord+ivec2(1,1),0).r;
+float f4=texelFetch(sourceTexture,coord+ivec2(0,1),0).r;
+float minz=min(min(min(f1,f2),f3),f4);
+#ifdef DEPTH_REDUX
+float maxz=max(max(max(sign(1.0-f1)*f1,sign(1.0-f2)*f2),sign(1.0-f3)*f3),sign(1.0-f4)*f4);
+#else
+float maxz=max(max(max(f1,f2),f3),f4);
+#endif
+glFragColor=vec4(minz,maxz,0.,0.);
+}
+#elif defined(MAIN)
+uniform vec2 texSize;
+void main(void)
+{
+ivec2 coord=ivec2(vUV*(texSize-1.0));
+vec2 f1=texelFetch(textureSampler,coord,0).rg;
+vec2 f2=texelFetch(textureSampler,coord+ivec2(1,0),0).rg;
+vec2 f3=texelFetch(textureSampler,coord+ivec2(1,1),0).rg;
+vec2 f4=texelFetch(textureSampler,coord+ivec2(0,1),0).rg;
+float minz=min(min(min(f1.x,f2.x),f3.x),f4.x);
+float maxz=max(max(max(f1.y,f2.y),f3.y),f4.y);
+glFragColor=vec4(minz,maxz,0.,0.);
+}
+#elif defined(ONEBEFORELAST)
+uniform ivec2 texSize;
+void main(void)
+{
+ivec2 coord=ivec2(vUV*vec2(texSize-1));
+vec2 f1=texelFetch(textureSampler,coord % texSize,0).rg;
+vec2 f2=texelFetch(textureSampler,(coord+ivec2(1,0)) % texSize,0).rg;
+vec2 f3=texelFetch(textureSampler,(coord+ivec2(1,1)) % texSize,0).rg;
+vec2 f4=texelFetch(textureSampler,(coord+ivec2(0,1)) % texSize,0).rg;
+float minz=min(f1.x,f2.x);
+float maxz=max(f1.y,f2.y);
+glFragColor=vec4(minz,maxz,0.,0.);
+}
+#elif defined(LAST)
+void main(void)
+{
+discard;
+glFragColor=vec4(0.);
+}
+#endif
+`;
+ ze.a.ShadersStore.minmaxReduxPixelShader = E_;
+ var yu = function() {
+ function r(t) {
+ this.onAfterReductionPerformed = new C.c(), this._forceFullscreenViewport = !0, this._activated = !1, this._camera = t, this._postProcessManager = new es.a(t.getScene());
+ }
+ return Object.defineProperty(r.prototype, "sourceTexture", { get: function() {
+ return this._sourceTexture;
+ }, enumerable: !1, configurable: !0 }), r.prototype.setSourceTexture = function(t, e, n, i) {
+ var o = this;
+ if (n === void 0 && (n = h.a.TEXTURETYPE_HALF_FLOAT), i === void 0 && (i = !0), t !== this._sourceTexture) {
+ this.dispose(!1), this._sourceTexture = t, this._reductionSteps = [], this._forceFullscreenViewport = i;
+ var a = this._camera.getScene(), s = new ft("Initial reduction phase", "minmaxRedux", ["texSize"], ["sourceTexture"], 1, null, h.a.TEXTURE_NEAREST_NEAREST, a.getEngine(), !1, "#define INITIAL" + (e ? `
+#define DEPTH_REDUX` : ""), n, void 0, void 0, void 0, h.a.TEXTUREFORMAT_RG);
+ s.autoClear = !1, s.forceFullscreenViewport = i;
+ var d = this._sourceTexture.getRenderWidth(), p = this._sourceTexture.getRenderHeight();
+ s.onApply = /* @__PURE__ */ function(R, B) {
+ return function(F) {
+ F.setTexture("sourceTexture", o._sourceTexture), F.setFloatArray2("texSize", new Float32Array([R, B]));
+ };
+ }(d, p), this._reductionSteps.push(s);
+ for (var y = 1; d > 1 || p > 1; ) {
+ d = Math.max(Math.round(d / 2), 1), p = Math.max(Math.round(p / 2), 1);
+ var P = new ft("Reduction phase " + y, "minmaxRedux", ["texSize"], null, { width: d, height: p }, null, h.a.TEXTURE_NEAREST_NEAREST, a.getEngine(), !1, "#define " + (d == 1 && p == 1 ? "LAST" : d == 1 || p == 1 ? "ONEBEFORELAST" : "MAIN"), n, void 0, void 0, void 0, h.a.TEXTUREFORMAT_RG);
+ P.autoClear = !1, P.forceFullscreenViewport = i, P.onApply = /* @__PURE__ */ function(R, B) {
+ return function(F) {
+ R == 1 || B == 1 ? F.setIntArray2("texSize", new Int32Array([R, B])) : F.setFloatArray2("texSize", new Float32Array([R, B]));
+ };
+ }(d, p), this._reductionSteps.push(P), y++, d == 1 && p == 1 && P.onAfterRenderObservable.add(function(R, B, F) {
+ var z = new Float32Array(4 * R * B), J = { min: 0, max: 0 };
+ return function() {
+ a.getEngine()._readTexturePixels(F.inputTexture, R, B, -1, 0, z), J.min = z[0], J.max = z[1], o.onAfterReductionPerformed.notifyObservers(J);
+ };
+ }(d, p, P));
+ }
+ }
+ }, Object.defineProperty(r.prototype, "refreshRate", { get: function() {
+ return this._sourceTexture ? this._sourceTexture.refreshRate : -1;
+ }, set: function(t) {
+ this._sourceTexture && (this._sourceTexture.refreshRate = t);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "activated", { get: function() {
+ return this._activated;
+ }, enumerable: !1, configurable: !0 }), r.prototype.activate = function() {
+ var t = this;
+ !this._onAfterUnbindObserver && this._sourceTexture && (this._onAfterUnbindObserver = this._sourceTexture.onAfterUnbindObservable.add(function() {
+ t._reductionSteps[0].activate(t._camera), t._postProcessManager.directRender(t._reductionSteps, t._reductionSteps[0].inputTexture, t._forceFullscreenViewport), t._camera.getScene().getEngine().unBindFramebuffer(t._reductionSteps[0].inputTexture, !1);
+ }), this._activated = !0);
+ }, r.prototype.deactivate = function() {
+ this._onAfterUnbindObserver && this._sourceTexture && (this._sourceTexture.onAfterUnbindObservable.remove(this._onAfterUnbindObserver), this._onAfterUnbindObserver = null, this._activated = !1);
+ }, r.prototype.dispose = function(t) {
+ if (t === void 0 && (t = !0), t && this.onAfterReductionPerformed.clear(), this.deactivate(), this._reductionSteps) {
+ for (var e = 0; e < this._reductionSteps.length; ++e)
+ this._reductionSteps[e].dispose();
+ this._reductionSteps = null;
+ }
+ this._postProcessManager && t && this._postProcessManager.dispose(), this._sourceTexture = null;
+ }, r;
+ }(), bu = function(r) {
+ function t(e) {
+ return r.call(this, e) || this;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "depthRenderer", { get: function() {
+ return this._depthRenderer;
+ }, enumerable: !1, configurable: !0 }), t.prototype.setDepthRenderer = function(e, n, i) {
+ e === void 0 && (e = null), n === void 0 && (n = h.a.TEXTURETYPE_HALF_FLOAT), i === void 0 && (i = !0);
+ var o = this._camera.getScene();
+ this._depthRenderer && (delete o._depthRenderer[this._depthRendererId], this._depthRenderer.dispose(), this._depthRenderer = null), e === null && (o._depthRenderer || (o._depthRenderer = {}), (e = this._depthRenderer = new Qo(o, n, this._camera, !1)).enabled = !1, this._depthRendererId = "minmax" + this._camera.id, o._depthRenderer[this._depthRendererId] = e), r.prototype.setSourceTexture.call(this, e.getDepthMap(), !0, n, i);
+ }, t.prototype.setSourceTexture = function(e, n, i, o) {
+ i === void 0 && (i = h.a.TEXTURETYPE_HALF_FLOAT), o === void 0 && (o = !0), r.prototype.setSourceTexture.call(this, e, n, i, o);
+ }, t.prototype.activate = function() {
+ this._depthRenderer && (this._depthRenderer.enabled = !0), r.prototype.activate.call(this);
+ }, t.prototype.deactivate = function() {
+ r.prototype.deactivate.call(this), this._depthRenderer && (this._depthRenderer.enabled = !1);
+ }, t.prototype.dispose = function(e) {
+ if (e === void 0 && (e = !0), r.prototype.dispose.call(this, e), this._depthRenderer && e) {
+ var n = this._depthRenderer.getDepthMap().getScene();
+ n && delete n._depthRenderer[this._depthRendererId], this._depthRenderer.dispose(), this._depthRenderer = null;
+ }
+ }, t;
+ }(yu), Tu = u.e.Up(), S_ = u.e.Zero(), mn = new u.e(), Tr = new u.e(), Er = new u.a(), Eu = new u.a(), Ds = function(r) {
+ function t(e, n, i) {
+ var o = this;
+ if (t.IsSupported)
+ return (o = r.call(this, e, n, i) || this).usePercentageCloserFiltering = !0, o;
+ l.a.Error("CascadedShadowMap needs WebGL 2 support.");
+ }
+ return Object(c.d)(t, r), t.prototype._validateFilter = function(e) {
+ return e === Fn.FILTER_NONE || e === Fn.FILTER_PCF || e === Fn.FILTER_PCSS ? e : (console.error('Unsupported filter "' + e + '"!'), Fn.FILTER_NONE);
+ }, Object.defineProperty(t.prototype, "numCascades", { get: function() {
+ return this._numCascades;
+ }, set: function(e) {
+ (e = Math.min(Math.max(e, t.MIN_CASCADES_COUNT), t.MAX_CASCADES_COUNT)) !== this._numCascades && (this._numCascades = e, this.recreateShadowMap());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "freezeShadowCastersBoundingInfo", { get: function() {
+ return this._freezeShadowCastersBoundingInfo;
+ }, set: function(e) {
+ this._freezeShadowCastersBoundingInfoObservable && e && (this._scene.onBeforeRenderObservable.remove(this._freezeShadowCastersBoundingInfoObservable), this._freezeShadowCastersBoundingInfoObservable = null), this._freezeShadowCastersBoundingInfoObservable || e || (this._freezeShadowCastersBoundingInfoObservable = this._scene.onBeforeRenderObservable.add(this._computeShadowCastersBoundingInfo.bind(this))), this._freezeShadowCastersBoundingInfo = e, e && this._computeShadowCastersBoundingInfo();
+ }, enumerable: !1, configurable: !0 }), t.prototype._computeShadowCastersBoundingInfo = function() {
+ if (this._scbiMin.copyFromFloats(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), this._scbiMax.copyFromFloats(Number.MIN_VALUE, Number.MIN_VALUE, Number.MIN_VALUE), this._shadowMap && this._shadowMap.renderList) {
+ for (var e = this._shadowMap.renderList, n = 0; n < e.length; n++)
+ if (a = e[n]) {
+ var i = a.getBoundingInfo().boundingBox;
+ this._scbiMin.minimizeInPlace(i.minimumWorld), this._scbiMax.maximizeInPlace(i.maximumWorld);
+ }
+ var o = this._scene.meshes;
+ for (n = 0; n < o.length; n++) {
+ var a;
+ (a = o[n]) && a.isVisible && a.isEnabled && a.receiveShadows && (i = a.getBoundingInfo().boundingBox, this._scbiMin.minimizeInPlace(i.minimumWorld), this._scbiMax.maximizeInPlace(i.maximumWorld));
+ }
+ }
+ this._shadowCastersBoundingInfo.reConstruct(this._scbiMin, this._scbiMax);
+ }, Object.defineProperty(t.prototype, "shadowCastersBoundingInfo", { get: function() {
+ return this._shadowCastersBoundingInfo;
+ }, set: function(e) {
+ this._shadowCastersBoundingInfo = e;
+ }, enumerable: !1, configurable: !0 }), t.prototype.setMinMaxDistance = function(e, n) {
+ this._minDistance === e && this._maxDistance === n || (e > n && (e = 0, n = 1), e < 0 && (e = 0), n > 1 && (n = 1), this._minDistance = e, this._maxDistance = n, this._breaksAreDirty = !0);
+ }, Object.defineProperty(t.prototype, "minDistance", { get: function() {
+ return this._minDistance;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "maxDistance", { get: function() {
+ return this._maxDistance;
+ }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
+ return t.CLASSNAME;
+ }, t.prototype.getCascadeMinExtents = function(e) {
+ return e >= 0 && e < this._numCascades ? this._cascadeMinExtents[e] : null;
+ }, t.prototype.getCascadeMaxExtents = function(e) {
+ return e >= 0 && e < this._numCascades ? this._cascadeMaxExtents[e] : null;
+ }, Object.defineProperty(t.prototype, "shadowMaxZ", { get: function() {
+ return this._scene && this._scene.activeCamera ? this._shadowMaxZ : 0;
+ }, set: function(e) {
+ this._scene && this._scene.activeCamera ? this._shadowMaxZ === e || e < this._scene.activeCamera.minZ || e > this._scene.activeCamera.maxZ || (this._shadowMaxZ = e, this._light._markMeshesAsLightDirty(), this._breaksAreDirty = !0) : this._shadowMaxZ = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "debug", { get: function() {
+ return this._debug;
+ }, set: function(e) {
+ this._debug = e, this._light._markMeshesAsLightDirty();
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "depthClamp", { get: function() {
+ return this._depthClamp;
+ }, set: function(e) {
+ this._depthClamp = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cascadeBlendPercentage", { get: function() {
+ return this._cascadeBlendPercentage;
+ }, set: function(e) {
+ this._cascadeBlendPercentage = e, this._light._markMeshesAsLightDirty();
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "lambda", { get: function() {
+ return this._lambda;
+ }, set: function(e) {
+ var n = Math.min(Math.max(e, 0), 1);
+ this._lambda != n && (this._lambda = n, this._breaksAreDirty = !0);
+ }, enumerable: !1, configurable: !0 }), t.prototype.getCascadeViewMatrix = function(e) {
+ return e >= 0 && e < this._numCascades ? this._viewMatrices[e] : null;
+ }, t.prototype.getCascadeProjectionMatrix = function(e) {
+ return e >= 0 && e < this._numCascades ? this._projectionMatrices[e] : null;
+ }, t.prototype.getCascadeTransformMatrix = function(e) {
+ return e >= 0 && e < this._numCascades ? this._transformMatrices[e] : null;
+ }, t.prototype.setDepthRenderer = function(e) {
+ this._depthRenderer = e, this._depthReducer && this._depthReducer.setDepthRenderer(this._depthRenderer);
+ }, Object.defineProperty(t.prototype, "autoCalcDepthBounds", { get: function() {
+ return this._autoCalcDepthBounds;
+ }, set: function(e) {
+ var n = this, i = this._scene.activeCamera;
+ if (i) {
+ if (this._autoCalcDepthBounds = e, !e)
+ return this._depthReducer && this._depthReducer.deactivate(), void this.setMinMaxDistance(0, 1);
+ this._depthReducer || (this._depthReducer = new bu(i), this._depthReducer.onAfterReductionPerformed.add(function(o) {
+ var a = o.min, s = o.max;
+ a >= s && (a = 0, s = 1), a == n._minDistance && s == n._maxDistance || n.setMinMaxDistance(a, s);
+ }), this._depthReducer.setDepthRenderer(this._depthRenderer)), this._depthReducer.activate();
+ }
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "autoCalcDepthBoundsRefreshRate", { get: function() {
+ var e, n, i;
+ return (i = (n = (e = this._depthReducer) === null || e === void 0 ? void 0 : e.depthRenderer) === null || n === void 0 ? void 0 : n.getDepthMap().refreshRate) !== null && i !== void 0 ? i : -1;
+ }, set: function(e) {
+ var n;
+ !((n = this._depthReducer) === null || n === void 0) && n.depthRenderer && (this._depthReducer.depthRenderer.getDepthMap().refreshRate = e);
+ }, enumerable: !1, configurable: !0 }), t.prototype.splitFrustum = function() {
+ this._breaksAreDirty = !0;
+ }, t.prototype._splitFrustum = function() {
+ var e = this._scene.activeCamera;
+ if (e) {
+ for (var n = e.minZ, i = e.maxZ, o = i - n, a = this._minDistance, s = n + a * o, d = n + (this._shadowMaxZ < i && this._shadowMaxZ >= n ? Math.min((this._shadowMaxZ - n) / (i - n), this._maxDistance) : this._maxDistance) * o, p = d - s, y = d / s, P = 0; P < this._cascades.length; ++P) {
+ var R = (P + 1) / this._numCascades, B = s * Math.pow(y, R), F = s + p * R, z = this._lambda * (B - F) + F;
+ this._cascades[P].prevBreakDistance = P === 0 ? a : this._cascades[P - 1].breakDistance, this._cascades[P].breakDistance = (z - n) / o, this._viewSpaceFrustumsZ[P] = n + this._cascades[P].breakDistance * o, this._frustumLengths[P] = (this._cascades[P].breakDistance - this._cascades[P].prevBreakDistance) * o;
+ }
+ this._breaksAreDirty = !1;
+ }
+ }, t.prototype._computeMatrices = function() {
+ if (this._scene.activeCamera) {
+ u.e.NormalizeToRef(this._light.getShadowDirection(0), this._lightDirection), Math.abs(u.e.Dot(this._lightDirection, u.e.Up())) === 1 && (this._lightDirection.z = 1e-13), this._cachedDirection.copyFrom(this._lightDirection);
+ for (var e = 0; e < this._numCascades; ++e) {
+ this._computeFrustumInWorldSpace(e), this._computeCascadeFrustum(e), this._cascadeMaxExtents[e].subtractToRef(this._cascadeMinExtents[e], mn), this._frustumCenter[e].addToRef(this._lightDirection.scale(this._cascadeMinExtents[e].z), this._shadowCameraPos[e]), u.a.LookAtLHToRef(this._shadowCameraPos[e], this._frustumCenter[e], Tu, this._viewMatrices[e]);
+ var n = 0, i = mn.z, o = this._shadowCastersBoundingInfo;
+ o.update(this._viewMatrices[e]), i = Math.min(i, o.boundingBox.maximumWorld.z), n = this._depthClamp && this.filter !== Fn.FILTER_PCSS ? Math.max(n, o.boundingBox.minimumWorld.z) : Math.min(n, o.boundingBox.minimumWorld.z), u.a.OrthoOffCenterLHToRef(this._cascadeMinExtents[e].x, this._cascadeMaxExtents[e].x, this._cascadeMinExtents[e].y, this._cascadeMaxExtents[e].y, n, i, this._projectionMatrices[e]), this._cascadeMinExtents[e].z = n, this._cascadeMaxExtents[e].z = i, this._viewMatrices[e].multiplyToRef(this._projectionMatrices[e], this._transformMatrices[e]), u.e.TransformCoordinatesToRef(S_, this._transformMatrices[e], mn), mn.scaleInPlace(this._mapSize / 2), Tr.copyFromFloats(Math.round(mn.x), Math.round(mn.y), Math.round(mn.z)), Tr.subtractInPlace(mn).scaleInPlace(2 / this._mapSize), u.a.TranslationToRef(Tr.x, Tr.y, 0, Er), this._projectionMatrices[e].multiplyToRef(Er, this._projectionMatrices[e]), this._viewMatrices[e].multiplyToRef(this._projectionMatrices[e], this._transformMatrices[e]), this._transformMatrices[e].copyToArray(this._transformMatricesAsArray, 16 * e);
+ }
+ }
+ }, t.prototype._computeFrustumInWorldSpace = function(e) {
+ if (this._scene.activeCamera) {
+ var n = this._cascades[e].prevBreakDistance, i = this._cascades[e].breakDistance;
+ this._scene.activeCamera.getViewMatrix();
+ for (var o = u.a.Invert(this._scene.activeCamera.getTransformationMatrix()), a = 0; a < t.frustumCornersNDCSpace.length; ++a)
+ u.e.TransformCoordinatesToRef(t.frustumCornersNDCSpace[a], o, this._frustumCornersWorldSpace[e][a]);
+ for (a = 0; a < t.frustumCornersNDCSpace.length / 2; ++a)
+ mn.copyFrom(this._frustumCornersWorldSpace[e][a + 4]).subtractInPlace(this._frustumCornersWorldSpace[e][a]), Tr.copyFrom(mn).scaleInPlace(n), mn.scaleInPlace(i), mn.addInPlace(this._frustumCornersWorldSpace[e][a]), this._frustumCornersWorldSpace[e][a + 4].copyFrom(mn), this._frustumCornersWorldSpace[e][a].addInPlace(Tr);
+ }
+ }, t.prototype._computeCascadeFrustum = function(e) {
+ if (this._cascadeMinExtents[e].copyFromFloats(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), this._cascadeMaxExtents[e].copyFromFloats(Number.MIN_VALUE, Number.MIN_VALUE, Number.MIN_VALUE), this._frustumCenter[e].copyFromFloats(0, 0, 0), this._scene.activeCamera) {
+ for (var n = 0; n < this._frustumCornersWorldSpace[e].length; ++n)
+ this._frustumCenter[e].addInPlace(this._frustumCornersWorldSpace[e][n]);
+ if (this._frustumCenter[e].scaleInPlace(1 / this._frustumCornersWorldSpace[e].length), this.stabilizeCascades) {
+ var i = 0;
+ for (n = 0; n < this._frustumCornersWorldSpace[e].length; ++n) {
+ var o = this._frustumCornersWorldSpace[e][n].subtractToRef(this._frustumCenter[e], mn).length();
+ i = Math.max(i, o);
+ }
+ i = Math.ceil(16 * i) / 16, this._cascadeMaxExtents[e].copyFromFloats(i, i, i), this._cascadeMinExtents[e].copyFromFloats(-i, -i, -i);
+ } else {
+ var a = this._frustumCenter[e];
+ for (this._frustumCenter[e].addToRef(this._lightDirection, mn), u.a.LookAtLHToRef(a, mn, Tu, Er), n = 0; n < this._frustumCornersWorldSpace[e].length; ++n)
+ u.e.TransformCoordinatesToRef(this._frustumCornersWorldSpace[e][n], Er, mn), this._cascadeMinExtents[e].minimizeInPlace(mn), this._cascadeMaxExtents[e].maximizeInPlace(mn);
+ }
+ }
+ }, Object.defineProperty(t, "IsSupported", { get: function() {
+ var e = te.a.LastCreatedEngine;
+ return !!e && e.webGLVersion != 1;
+ }, enumerable: !1, configurable: !0 }), t.prototype._initializeGenerator = function() {
+ var e, n, i, o, a, s, d, p, y, P, R, B, F, z, J, ie, se, ce, ue, fe;
+ this.penumbraDarkness = (e = this.penumbraDarkness) !== null && e !== void 0 ? e : 1, this._numCascades = (n = this._numCascades) !== null && n !== void 0 ? n : t.DEFAULT_CASCADES_COUNT, this.stabilizeCascades = (i = this.stabilizeCascades) !== null && i !== void 0 && i, this._freezeShadowCastersBoundingInfoObservable = (o = this._freezeShadowCastersBoundingInfoObservable) !== null && o !== void 0 ? o : null, this.freezeShadowCastersBoundingInfo = (a = this.freezeShadowCastersBoundingInfo) !== null && a !== void 0 && a, this._scbiMin = (s = this._scbiMin) !== null && s !== void 0 ? s : new u.e(0, 0, 0), this._scbiMax = (d = this._scbiMax) !== null && d !== void 0 ? d : new u.e(0, 0, 0), this._shadowCastersBoundingInfo = (p = this._shadowCastersBoundingInfo) !== null && p !== void 0 ? p : new Mi.a(new u.e(0, 0, 0), new u.e(0, 0, 0)), this._breaksAreDirty = (y = this._breaksAreDirty) === null || y === void 0 || y, this._minDistance = (P = this._minDistance) !== null && P !== void 0 ? P : 0, this._maxDistance = (R = this._maxDistance) !== null && R !== void 0 ? R : 1, this._currentLayer = (B = this._currentLayer) !== null && B !== void 0 ? B : 0, this._shadowMaxZ = (J = (F = this._shadowMaxZ) !== null && F !== void 0 ? F : (z = this._scene.activeCamera) === null || z === void 0 ? void 0 : z.maxZ) !== null && J !== void 0 ? J : 1e4, this._debug = (ie = this._debug) !== null && ie !== void 0 && ie, this._depthClamp = (se = this._depthClamp) === null || se === void 0 || se, this._cascadeBlendPercentage = (ce = this._cascadeBlendPercentage) !== null && ce !== void 0 ? ce : 0.1, this._lambda = (ue = this._lambda) !== null && ue !== void 0 ? ue : 0.5, this._autoCalcDepthBounds = (fe = this._autoCalcDepthBounds) !== null && fe !== void 0 && fe, r.prototype._initializeGenerator.call(this);
+ }, t.prototype._createTargetRenderTexture = function() {
+ var e = { width: this._mapSize, height: this._mapSize, layers: this.numCascades };
+ this._shadowMap = new on(this._light.name + "_shadowMap", e, this._scene, !1, !0, this._textureType, !1, void 0, !1, !1, void 0), this._shadowMap.createDepthStencilTexture(h.a.LESS, !0);
+ }, t.prototype._initializeShadowMap = function() {
+ var e = this;
+ if (r.prototype._initializeShadowMap.call(this), this._shadowMap !== null) {
+ this._transformMatricesAsArray = new Float32Array(16 * this._numCascades), this._viewSpaceFrustumsZ = new Array(this._numCascades), this._frustumLengths = new Array(this._numCascades), this._lightSizeUVCorrection = new Array(2 * this._numCascades), this._depthCorrection = new Array(this._numCascades), this._cascades = [], this._viewMatrices = [], this._projectionMatrices = [], this._transformMatrices = [], this._cascadeMinExtents = [], this._cascadeMaxExtents = [], this._frustumCenter = [], this._shadowCameraPos = [], this._frustumCornersWorldSpace = [];
+ for (var n = 0; n < this._numCascades; ++n) {
+ this._cascades[n] = { prevBreakDistance: 0, breakDistance: 0 }, this._viewMatrices[n] = u.a.Zero(), this._projectionMatrices[n] = u.a.Zero(), this._transformMatrices[n] = u.a.Zero(), this._cascadeMinExtents[n] = new u.e(), this._cascadeMaxExtents[n] = new u.e(), this._frustumCenter[n] = new u.e(), this._shadowCameraPos[n] = new u.e(), this._frustumCornersWorldSpace[n] = new Array(t.frustumCornersNDCSpace.length);
+ for (var i = 0; i < t.frustumCornersNDCSpace.length; ++i)
+ this._frustumCornersWorldSpace[n][i] = new u.e();
+ }
+ this._shadowMap.onBeforeRenderObservable.add(function(o) {
+ if (e._currentLayer = o, e._scene.getSceneUniformBuffer().useUbo) {
+ var a = e._scene.getSceneUniformBuffer();
+ a.updateMatrix("viewProjection", e.getCascadeTransformMatrix(o)), a.updateMatrix("view", e.getCascadeViewMatrix(o)), a.update();
+ }
+ }), this._shadowMap.onBeforeBindObservable.add(function() {
+ e._breaksAreDirty && e._splitFrustum(), e._computeMatrices();
+ }), this._splitFrustum();
+ }
+ }, t.prototype._bindCustomEffectForRenderSubMeshForShadowMap = function(e, n, i, o) {
+ var a, s, d, p, y, P;
+ n.setMatrix((a = i == null ? void 0 : i.viewProjection) !== null && a !== void 0 ? a : "viewProjection", this.getCascadeTransformMatrix(this._currentLayer)), n.setMatrix((s = i == null ? void 0 : i.view) !== null && s !== void 0 ? s : "view", this.getCascadeViewMatrix(this._currentLayer)), n.setMatrix((d = i == null ? void 0 : i.projection) !== null && d !== void 0 ? d : "projection", this.getCascadeProjectionMatrix(this._currentLayer));
+ var R = o.getWorldMatrix();
+ n.setMatrix((p = i == null ? void 0 : i.world) !== null && p !== void 0 ? p : "world", R), R.multiplyToRef(this.getCascadeTransformMatrix(this._currentLayer), Er), n.setMatrix((y = i == null ? void 0 : i.worldViewProjection) !== null && y !== void 0 ? y : "worldViewProjection", Er), R.multiplyToRef(this.getCascadeViewMatrix(this._currentLayer), Eu), n.setMatrix((P = i == null ? void 0 : i.worldView) !== null && P !== void 0 ? P : "worldView", Eu);
+ }, t.prototype._isReadyCustomDefines = function(e, n, i) {
+ e.push("#define SM_DEPTHCLAMP " + (this._depthClamp && this._filter !== Fn.FILTER_PCSS ? "1" : "0"));
+ }, t.prototype.prepareDefines = function(e, n) {
+ r.prototype.prepareDefines.call(this, e, n);
+ var i = this._scene, o = this._light;
+ if (i.shadowsEnabled && o.shadowEnabled) {
+ e["SHADOWCSM" + n] = !0, e["SHADOWCSMDEBUG" + n] = this.debug, e["SHADOWCSMNUM_CASCADES" + n] = this.numCascades, e["SHADOWCSM_RIGHTHANDED" + n] = i.useRightHandedSystem;
+ var a = i.activeCamera;
+ a && this._shadowMaxZ < a.maxZ && (e["SHADOWCSMUSESHADOWMAXZ" + n] = !0), this.cascadeBlendPercentage === 0 && (e["SHADOWCSMNOBLEND" + n] = !0);
+ }
+ }, t.prototype.bindShadowLight = function(e, n) {
+ var i = this._light, o = this._scene;
+ if (o.shadowsEnabled && i.shadowEnabled) {
+ var a = o.activeCamera;
+ if (a) {
+ var s = this.getShadowMap();
+ if (s) {
+ var d = s.getSize().width;
+ if (n.setMatrices("lightMatrix" + e, this._transformMatricesAsArray), n.setArray("viewFrustumZ" + e, this._viewSpaceFrustumsZ), n.setFloat("cascadeBlendFactor" + e, this.cascadeBlendPercentage === 0 ? 1e4 : 1 / this.cascadeBlendPercentage), n.setArray("frustumLengths" + e, this._frustumLengths), this._filter === Fn.FILTER_PCF)
+ n.setDepthStencilTexture("shadowSampler" + e, s), i._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), d, 1 / d, this.frustumEdgeFalloff, e);
+ else if (this._filter === Fn.FILTER_PCSS) {
+ for (var p = 0; p < this._numCascades; ++p)
+ this._lightSizeUVCorrection[2 * p + 0] = p === 0 ? 1 : (this._cascadeMaxExtents[0].x - this._cascadeMinExtents[0].x) / (this._cascadeMaxExtents[p].x - this._cascadeMinExtents[p].x), this._lightSizeUVCorrection[2 * p + 1] = p === 0 ? 1 : (this._cascadeMaxExtents[0].y - this._cascadeMinExtents[0].y) / (this._cascadeMaxExtents[p].y - this._cascadeMinExtents[p].y), this._depthCorrection[p] = p === 0 ? 1 : (this._cascadeMaxExtents[p].z - this._cascadeMinExtents[p].z) / (this._cascadeMaxExtents[0].z - this._cascadeMinExtents[0].z);
+ n.setDepthStencilTexture("shadowSampler" + e, s), n.setTexture("depthSampler" + e, s), n.setArray2("lightSizeUVCorrection" + e, this._lightSizeUVCorrection), n.setArray("depthCorrection" + e, this._depthCorrection), n.setFloat("penumbraDarkness" + e, this.penumbraDarkness), i._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / d, this._contactHardeningLightSizeUVRatio * d, this.frustumEdgeFalloff, e);
+ } else
+ n.setTexture("shadowSampler" + e, s), i._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), d, 1 / d, this.frustumEdgeFalloff, e);
+ i._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(a), this.getLight().getDepthMinZ(a) + this.getLight().getDepthMaxZ(a), e);
+ }
+ }
+ }
+ }, t.prototype.getTransformMatrix = function() {
+ return this.getCascadeTransformMatrix(0);
+ }, t.prototype.dispose = function() {
+ r.prototype.dispose.call(this), this._freezeShadowCastersBoundingInfoObservable && (this._scene.onBeforeRenderObservable.remove(this._freezeShadowCastersBoundingInfoObservable), this._freezeShadowCastersBoundingInfoObservable = null), this._depthReducer && (this._depthReducer.dispose(), this._depthReducer = null);
+ }, t.prototype.serialize = function() {
+ var e = r.prototype.serialize.call(this), n = this.getShadowMap();
+ if (!n)
+ return e;
+ if (e.numCascades = this._numCascades, e.debug = this._debug, e.stabilizeCascades = this.stabilizeCascades, e.lambda = this._lambda, e.cascadeBlendPercentage = this.cascadeBlendPercentage, e.depthClamp = this._depthClamp, e.autoCalcDepthBounds = this.autoCalcDepthBounds, e.shadowMaxZ = this._shadowMaxZ, e.penumbraDarkness = this.penumbraDarkness, e.freezeShadowCastersBoundingInfo = this._freezeShadowCastersBoundingInfo, e.minDistance = this.minDistance, e.maxDistance = this.maxDistance, e.renderList = [], n.renderList)
+ for (var i = 0; i < n.renderList.length; i++) {
+ var o = n.renderList[i];
+ e.renderList.push(o.id);
+ }
+ return e;
+ }, t.Parse = function(e, n) {
+ var i = Fn.Parse(e, n, function(o, a) {
+ return new t(o, a);
+ });
+ return e.numCascades !== void 0 && (i.numCascades = e.numCascades), e.debug !== void 0 && (i.debug = e.debug), e.stabilizeCascades !== void 0 && (i.stabilizeCascades = e.stabilizeCascades), e.lambda !== void 0 && (i.lambda = e.lambda), e.cascadeBlendPercentage !== void 0 && (i.cascadeBlendPercentage = e.cascadeBlendPercentage), e.depthClamp !== void 0 && (i.depthClamp = e.depthClamp), e.autoCalcDepthBounds !== void 0 && (i.autoCalcDepthBounds = e.autoCalcDepthBounds), e.shadowMaxZ !== void 0 && (i.shadowMaxZ = e.shadowMaxZ), e.penumbraDarkness !== void 0 && (i.penumbraDarkness = e.penumbraDarkness), e.freezeShadowCastersBoundingInfo !== void 0 && (i.freezeShadowCastersBoundingInfo = e.freezeShadowCastersBoundingInfo), e.minDistance !== void 0 && e.maxDistance !== void 0 && i.setMinMaxDistance(e.minDistance, e.maxDistance), i;
+ }, t.frustumCornersNDCSpace = [new u.e(-1, 1, -1), new u.e(1, 1, -1), new u.e(1, -1, -1), new u.e(-1, -1, -1), new u.e(-1, 1, 1), new u.e(1, 1, 1), new u.e(1, -1, 1), new u.e(-1, -1, 1)], t.CLASSNAME = "CascadedShadowGenerator", t.DEFAULT_CASCADES_COUNT = 4, t.MIN_CASCADES_COUNT = 2, t.MAX_CASCADES_COUNT = 4, t._SceneComponentInitialization = function(e) {
+ throw En.a.WarnImport("ShadowGeneratorSceneComponent");
+ }, t;
+ }(Fn);
+ V.a.AddParser(ot.a.NAME_SHADOWGENERATOR, function(r, t) {
+ if (r.shadowGenerators !== void 0 && r.shadowGenerators !== null)
+ for (var e = 0, n = r.shadowGenerators.length; e < n; e++) {
+ var i = r.shadowGenerators[e];
+ i.className === Ds.CLASSNAME ? Ds.Parse(i, t) : Fn.Parse(i, t);
+ }
+ });
+ var Su = function() {
+ function r(t) {
+ this.name = ot.a.NAME_SHADOWGENERATOR, this.scene = t;
+ }
+ return r.prototype.register = function() {
+ this.scene._gatherRenderTargetsStage.registerStep(ot.a.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR, this, this._gatherRenderTargets);
+ }, r.prototype.rebuild = function() {
+ }, r.prototype.serialize = function(t) {
+ t.shadowGenerators = [];
+ for (var e = 0, n = this.scene.lights; e < n.length; e++) {
+ var i = n[e].getShadowGenerator();
+ i && t.shadowGenerators.push(i.serialize());
+ }
+ }, r.prototype.addFromContainer = function(t) {
+ }, r.prototype.removeFromContainer = function(t, e) {
+ }, r.prototype.dispose = function() {
+ }, r.prototype._gatherRenderTargets = function(t) {
+ var e = this.scene;
+ if (this.scene.shadowsEnabled)
+ for (var n = 0; n < e.lights.length; n++) {
+ var i = e.lights[n], o = i.getShadowGenerator();
+ if (i.isEnabled() && i.shadowEnabled && o) {
+ var a = o.getShadowMap();
+ e.textures.indexOf(a) !== -1 && t.push(a);
+ }
+ }
+ }, r;
+ }();
+ Fn._SceneComponentInitialization = function(r) {
+ var t = r._getComponent(ot.a.NAME_SHADOWGENERATOR);
+ t || (t = new Su(r), r._addComponent(t));
+ }, Q.a.AddNodeConstructor("Light_Type_0", function(r, t) {
+ return function() {
+ return new Ls(r, u.e.Zero(), t);
+ };
+ });
+ var Ls = function(r) {
+ function t(e, n, i) {
+ var o = r.call(this, e, i) || this;
+ return o._shadowAngle = Math.PI / 2, o.position = n, o;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "shadowAngle", { get: function() {
+ return this._shadowAngle;
+ }, set: function(e) {
+ this._shadowAngle = e, this.forceProjectionMatrixCompute();
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "direction", { get: function() {
+ return this._direction;
+ }, set: function(e) {
+ var n = this.needCube();
+ this._direction = e, this.needCube() !== n && this._shadowGenerator && this._shadowGenerator.recreateShadowMap();
+ }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
+ return "PointLight";
+ }, t.prototype.getTypeID = function() {
+ return bi.a.LIGHTTYPEID_POINTLIGHT;
+ }, t.prototype.needCube = function() {
+ return !this.direction;
+ }, t.prototype.getShadowDirection = function(e) {
+ if (this.direction)
+ return r.prototype.getShadowDirection.call(this, e);
+ switch (e) {
+ case 0:
+ return new u.e(1, 0, 0);
+ case 1:
+ return new u.e(-1, 0, 0);
+ case 2:
+ return new u.e(0, -1, 0);
+ case 3:
+ return new u.e(0, 1, 0);
+ case 4:
+ return new u.e(0, 0, 1);
+ case 5:
+ return new u.e(0, 0, -1);
+ }
+ return u.e.Zero();
+ }, t.prototype._setDefaultShadowProjectionMatrix = function(e, n, i) {
+ var o = this.getScene().activeCamera;
+ o && u.a.PerspectiveFovLHToRef(this.shadowAngle, 1, this.getDepthMinZ(o), this.getDepthMaxZ(o), e);
+ }, t.prototype._buildUniformLayout = function() {
+ this._uniformBuffer.addUniform("vLightData", 4), this._uniformBuffer.addUniform("vLightDiffuse", 4), this._uniformBuffer.addUniform("vLightSpecular", 4), this._uniformBuffer.addUniform("vLightFalloff", 4), this._uniformBuffer.addUniform("shadowsInfo", 3), this._uniformBuffer.addUniform("depthValues", 2), this._uniformBuffer.create();
+ }, t.prototype.transferToEffect = function(e, n) {
+ return this.computeTransformedInformation() ? this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, 0, n) : this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, 0, n), this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, 0, 0, n), this;
+ }, t.prototype.transferToNodeMaterialEffect = function(e, n) {
+ return this.computeTransformedInformation() ? e.setFloat3(n, this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z) : e.setFloat3(n, this.position.x, this.position.y, this.position.z), this;
+ }, t.prototype.prepareLightSpecificDefines = function(e, n) {
+ e["POINTLIGHT" + n] = !0;
+ }, Object(c.c)([Object(L.c)()], t.prototype, "shadowAngle", null), t;
+ }(ko), Au = function() {
+ function r(t, e, n) {
+ var i = this;
+ e === void 0 && (e = ""), n === void 0 && (n = "black"), this._renderingCanvas = t, this._loadingText = e, this._loadingDivBackgroundColor = n, this._resizeLoadingUI = function() {
+ var o = i._renderingCanvas.getBoundingClientRect(), a = window.getComputedStyle(i._renderingCanvas).position;
+ i._loadingDiv && (i._loadingDiv.style.position = a === "fixed" ? "fixed" : "absolute", i._loadingDiv.style.left = o.left + "px", i._loadingDiv.style.top = o.top + "px", i._loadingDiv.style.width = o.width + "px", i._loadingDiv.style.height = o.height + "px");
+ };
+ }
+ return r.prototype.displayLoadingUI = function() {
+ if (!this._loadingDiv) {
+ this._loadingDiv = document.createElement("div"), this._loadingDiv.id = "babylonjsLoadingDiv", this._loadingDiv.style.opacity = "0", this._loadingDiv.style.transition = "opacity 1.5s ease", this._loadingDiv.style.pointerEvents = "none", this._loadingDiv.style.display = "grid", this._loadingDiv.style.gridTemplateRows = "100%", this._loadingDiv.style.gridTemplateColumns = "100%", this._loadingDiv.style.justifyItems = "center", this._loadingDiv.style.alignItems = "center", this._loadingTextDiv = document.createElement("div"), this._loadingTextDiv.style.position = "absolute", this._loadingTextDiv.style.left = "0", this._loadingTextDiv.style.top = "50%", this._loadingTextDiv.style.marginTop = "80px", this._loadingTextDiv.style.width = "100%", this._loadingTextDiv.style.height = "20px", this._loadingTextDiv.style.fontFamily = "Arial", this._loadingTextDiv.style.fontSize = "14px", this._loadingTextDiv.style.color = "white", this._loadingTextDiv.style.textAlign = "center", this._loadingTextDiv.style.zIndex = "1", this._loadingTextDiv.innerHTML = "Loading", this._loadingDiv.appendChild(this._loadingTextDiv), this._loadingTextDiv.innerHTML = this._loadingText;
+ var t = document.createElement("style");
+ t.type = "text/css", t.innerHTML = `@-webkit-keyframes spin1 { 0% { -webkit-transform: rotate(0deg);}
+ 100% { -webkit-transform: rotate(360deg);}
+ } @keyframes spin1 { 0% { transform: rotate(0deg);}
+ 100% { transform: rotate(360deg);}
+ }`, document.getElementsByTagName("head")[0].appendChild(t);
+ var e = !!window.SVGSVGElement, n = new Image();
+ r.DefaultLogoUrl ? n.src = r.DefaultLogoUrl : n.src = e ? "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxODAuMTcgMjA4LjA0Ij48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2ZmZjt9LmNscy0ye2ZpbGw6I2UwNjg0Yjt9LmNscy0ze2ZpbGw6I2JiNDY0Yjt9LmNscy00e2ZpbGw6I2UwZGVkODt9LmNscy01e2ZpbGw6I2Q1ZDJjYTt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPkJhYnlsb25Mb2dvPC90aXRsZT48ZyBpZD0iTGF5ZXJfMiIgZGF0YS1uYW1lPSJMYXllciAyIj48ZyBpZD0iUGFnZV9FbGVtZW50cyIgZGF0YS1uYW1lPSJQYWdlIEVsZW1lbnRzIj48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik05MC4wOSwwLDAsNTJWMTU2bDkwLjA5LDUyLDkwLjA4LTUyVjUyWiIvPjxwb2x5Z29uIGNsYXNzPSJjbHMtMiIgcG9pbnRzPSIxODAuMTcgNTIuMDEgMTUxLjk3IDM1LjczIDEyNC44NSA1MS4zOSAxNTMuMDUgNjcuNjcgMTgwLjE3IDUyLjAxIi8+PHBvbHlnb24gY2xhc3M9ImNscy0yIiBwb2ludHM9IjI3LjEyIDY3LjY3IDExNy4yMSAxNS42NiA5MC4wOCAwIDAgNTIuMDEgMjcuMTIgNjcuNjciLz48cG9seWdvbiBjbGFzcz0iY2xzLTIiIHBvaW50cz0iNjEuODkgMTIwLjMgOTAuMDggMTM2LjU4IDExOC4yOCAxMjAuMyA5MC4wOCAxMDQuMDIgNjEuODkgMTIwLjMiLz48cG9seWdvbiBjbGFzcz0iY2xzLTMiIHBvaW50cz0iMTUzLjA1IDY3LjY3IDE1My4wNSAxNDAuMzcgOTAuMDggMTc2LjcyIDI3LjEyIDE0MC4zNyAyNy4xMiA2Ny42NyAwIDUyLjAxIDAgMTU2LjAzIDkwLjA4IDIwOC4wNCAxODAuMTcgMTU2LjAzIDE4MC4xNyA1Mi4wMSAxNTMuMDUgNjcuNjciLz48cG9seWdvbiBjbGFzcz0iY2xzLTMiIHBvaW50cz0iOTAuMDggNzEuNDYgNjEuODkgODcuNzQgNjEuODkgMTIwLjMgOTAuMDggMTA0LjAyIDExOC4yOCAxMjAuMyAxMTguMjggODcuNzQgOTAuMDggNzEuNDYiLz48cG9seWdvbiBjbGFzcz0iY2xzLTQiIHBvaW50cz0iMTUzLjA1IDY3LjY3IDExOC4yOCA4Ny43NCAxMTguMjggMTIwLjMgOTAuMDggMTM2LjU4IDkwLjA4IDE3Ni43MiAxNTMuMDUgMTQwLjM3IDE1My4wNSA2Ny42NyIvPjxwb2x5Z29uIGNsYXNzPSJjbHMtNSIgcG9pbnRzPSIyNy4xMiA2Ny42NyA2MS44OSA4Ny43NCA2MS44OSAxMjAuMyA5MC4wOCAxMzYuNTggOTAuMDggMTc2LjcyIDI3LjEyIDE0MC4zNyAyNy4xMiA2Ny42NyIvPjwvZz48L2c+PC9zdmc+" : "https://cdn.babylonjs.com/Assets/babylonLogo.png", n.style.width = "150px", n.style.gridColumn = "1", n.style.gridRow = "1", n.style.top = "50%", n.style.left = "50%", n.style.transform = "translate(-50%, -50%)", n.style.position = "absolute";
+ var i = document.createElement("div");
+ i.style.width = "300px", i.style.gridColumn = "1", i.style.gridRow = "1", i.style.top = "50%", i.style.left = "50%", i.style.transform = "translate(-50%, -50%)", i.style.position = "absolute";
+ var o = new Image();
+ if (r.DefaultSpinnerUrl ? o.src = r.DefaultSpinnerUrl : o.src = e ? "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzOTIgMzkyIj48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2UwNjg0Yjt9LmNscy0ye2ZpbGw6bm9uZTt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPlNwaW5uZXJJY29uPC90aXRsZT48ZyBpZD0iTGF5ZXJfMiIgZGF0YS1uYW1lPSJMYXllciAyIj48ZyBpZD0iU3Bpbm5lciI+PHBhdGggY2xhc3M9ImNscy0xIiBkPSJNNDAuMjEsMTI2LjQzYzMuNy03LjMxLDcuNjctMTQuNDQsMTItMjEuMzJsMy4zNi01LjEsMy41Mi01YzEuMjMtMS42MywyLjQxLTMuMjksMy42NS00LjkxczIuNTMtMy4yMSwzLjgyLTQuNzlBMTg1LjIsMTg1LjIsMCwwLDEsODMuNCw2Ny40M2EyMDgsMjA4LDAsMCwxLDE5LTE1LjY2YzMuMzUtMi40MSw2Ljc0LTQuNzgsMTAuMjUtN3M3LjExLTQuMjgsMTAuNzUtNi4zMmM3LjI5LTQsMTQuNzMtOCwyMi41My0xMS40OSwzLjktMS43Miw3Ljg4LTMuMywxMi00LjY0YTEwNC4yMiwxMDQuMjIsMCwwLDEsMTIuNDQtMy4yMyw2Mi40NCw2Mi40NCwwLDAsMSwxMi43OC0xLjM5QTI1LjkyLDI1LjkyLDAsMCwxLDE5NiwyMS40NGE2LjU1LDYuNTUsMCwwLDEsMi4wNSw5LDYuNjYsNi42NiwwLDAsMS0xLjY0LDEuNzhsLS40MS4yOWEyMi4wNywyMi4wNywwLDAsMS01Ljc4LDMsMzAuNDIsMzAuNDIsMCwwLDEtNS42NywxLjYyLDM3LjgyLDM3LjgyLDAsMCwxLTUuNjkuNzFjLTEsMC0xLjkuMTgtMi44NS4yNmwtMi44NS4yNHEtNS43Mi41MS0xMS40OCwxLjFjLTMuODQuNC03LjcxLjgyLTExLjU4LDEuNGExMTIuMzQsMTEyLjM0LDAsMCwwLTIyLjk0LDUuNjFjLTMuNzIsMS4zNS03LjM0LDMtMTAuOTQsNC42NHMtNy4xNCwzLjUxLTEwLjYsNS41MUExNTEuNiwxNTEuNiwwLDAsMCw2OC41Niw4N0M2Ny4yMyw4OC40OCw2Niw5MCw2NC42NCw5MS41NnMtMi41MSwzLjE1LTMuNzUsNC43M2wtMy41NCw0LjljLTEuMTMsMS42Ni0yLjIzLDMuMzUtMy4zMyw1YTEyNywxMjcsMCwwLDAtMTAuOTMsMjEuNDksMS41OCwxLjU4LDAsMSwxLTMtMS4xNVM0MC4xOSwxMjYuNDcsNDAuMjEsMTI2LjQzWiIvPjxyZWN0IGNsYXNzPSJjbHMtMiIgd2lkdGg9IjM5MiIgaGVpZ2h0PSIzOTIiLz48L2c+PC9nPjwvc3ZnPg==" : "https://cdn.babylonjs.com/Assets/loadingIcon.png", o.style.animation = "spin1 0.75s infinite linear", o.style.webkitAnimation = "spin1 0.75s infinite linear", o.style.transformOrigin = "50% 50%", o.style.webkitTransformOrigin = "50% 50%", !e) {
+ var a = { w: 16, h: 18.5 }, s = { w: 30, h: 30 };
+ n.style.width = a.w + "vh", n.style.height = a.h + "vh", n.style.left = "calc(50% - " + a.w / 2 + "vh)", n.style.top = "calc(50% - " + a.h / 2 + "vh)", o.style.width = s.w + "vh", o.style.height = s.h + "vh", o.style.left = "calc(50% - " + s.w / 2 + "vh)", o.style.top = "calc(50% - " + s.h / 2 + "vh)";
+ }
+ i.appendChild(o), this._loadingDiv.appendChild(n), this._loadingDiv.appendChild(i), this._resizeLoadingUI(), window.addEventListener("resize", this._resizeLoadingUI), this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor, document.body.appendChild(this._loadingDiv), this._loadingDiv.style.opacity = "1";
+ }
+ }, r.prototype.hideLoadingUI = function() {
+ var t = this;
+ this._loadingDiv && (this._loadingDiv.style.opacity = "0", this._loadingDiv.addEventListener("transitionend", function() {
+ t._loadingDiv && (t._loadingDiv.parentElement && t._loadingDiv.parentElement.removeChild(t._loadingDiv), window.removeEventListener("resize", t._resizeLoadingUI), t._loadingDiv = null);
+ }));
+ }, Object.defineProperty(r.prototype, "loadingUIText", { get: function() {
+ return this._loadingText;
+ }, set: function(t) {
+ this._loadingText = t, this._loadingTextDiv && (this._loadingTextDiv.innerHTML = this._loadingText);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "loadingUIBackgroundColor", { get: function() {
+ return this._loadingDivBackgroundColor;
+ }, set: function(t) {
+ this._loadingDivBackgroundColor = t, this._loadingDiv && (this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor);
+ }, enumerable: !1, configurable: !0 }), r.DefaultLogoUrl = "", r.DefaultSpinnerUrl = "", r;
+ }();
+ Ue.a.DefaultLoadingScreenFactory = function(r) {
+ return new Au(r);
+ };
+ var Ns = f(71), Qi = f(68), ws = function() {
+ function r() {
+ }
+ return r.ConvertPanoramaToCubemap = function(t, e, n, i) {
+ if (!t)
+ throw "ConvertPanoramaToCubemap: input cannot be null";
+ if (t.length != e * n * 3)
+ throw "ConvertPanoramaToCubemap: input size is wrong";
+ return { front: this.CreateCubemapTexture(i, this.FACE_FRONT, t, e, n), back: this.CreateCubemapTexture(i, this.FACE_BACK, t, e, n), left: this.CreateCubemapTexture(i, this.FACE_LEFT, t, e, n), right: this.CreateCubemapTexture(i, this.FACE_RIGHT, t, e, n), up: this.CreateCubemapTexture(i, this.FACE_UP, t, e, n), down: this.CreateCubemapTexture(i, this.FACE_DOWN, t, e, n), size: i, type: h.a.TEXTURETYPE_FLOAT, format: h.a.TEXTUREFORMAT_RGB, gammaSpace: !1 };
+ }, r.CreateCubemapTexture = function(t, e, n, i, o) {
+ for (var a = new ArrayBuffer(t * t * 4 * 3), s = new Float32Array(a), d = e[1].subtract(e[0]).scale(1 / t), p = e[3].subtract(e[2]).scale(1 / t), y = 1 / t, P = 0, R = 0; R < t; R++) {
+ for (var B = e[0], F = e[2], z = 0; z < t; z++) {
+ var J = F.subtract(B).scale(P).add(B);
+ J.normalize();
+ var ie = this.CalcProjectionSpherical(J, n, i, o);
+ s[R * t * 3 + 3 * z + 0] = ie.r, s[R * t * 3 + 3 * z + 1] = ie.g, s[R * t * 3 + 3 * z + 2] = ie.b, B = B.add(d), F = F.add(p);
+ }
+ P += y;
+ }
+ return s;
+ }, r.CalcProjectionSpherical = function(t, e, n, i) {
+ for (var o = Math.atan2(t.z, t.x), a = Math.acos(t.y); o < -Math.PI; )
+ o += 2 * Math.PI;
+ for (; o > Math.PI; )
+ o -= 2 * Math.PI;
+ var s = o / Math.PI, d = a / Math.PI;
+ s = 0.5 * s + 0.5;
+ var p = Math.round(s * n);
+ p < 0 ? p = 0 : p >= n && (p = n - 1);
+ var y = Math.round(d * i);
+ y < 0 ? y = 0 : y >= i && (y = i - 1);
+ var P = i - y - 1;
+ return { r: e[P * n * 3 + 3 * p + 0], g: e[P * n * 3 + 3 * p + 1], b: e[P * n * 3 + 3 * p + 2] };
+ }, r.FACE_LEFT = [new u.e(-1, -1, -1), new u.e(1, -1, -1), new u.e(-1, 1, -1), new u.e(1, 1, -1)], r.FACE_RIGHT = [new u.e(1, -1, 1), new u.e(-1, -1, 1), new u.e(1, 1, 1), new u.e(-1, 1, 1)], r.FACE_FRONT = [new u.e(1, -1, -1), new u.e(1, -1, 1), new u.e(1, 1, -1), new u.e(1, 1, 1)], r.FACE_BACK = [new u.e(-1, -1, 1), new u.e(-1, -1, -1), new u.e(-1, 1, 1), new u.e(-1, 1, -1)], r.FACE_DOWN = [new u.e(1, 1, -1), new u.e(1, 1, 1), new u.e(-1, 1, -1), new u.e(-1, 1, 1)], r.FACE_UP = [new u.e(-1, -1, -1), new u.e(-1, -1, 1), new u.e(1, -1, -1), new u.e(1, -1, 1)], r;
+ }(), Pu = function() {
+ function r() {
+ }
+ return r.Ldexp = function(t, e) {
+ return e > 1023 ? t * Math.pow(2, 1023) * Math.pow(2, e - 1023) : e < -1074 ? t * Math.pow(2, -1074) * Math.pow(2, e + 1074) : t * Math.pow(2, e);
+ }, r.Rgbe2float = function(t, e, n, i, o, a) {
+ o > 0 ? (o = this.Ldexp(1, o - 136), t[a + 0] = e * o, t[a + 1] = n * o, t[a + 2] = i * o) : (t[a + 0] = 0, t[a + 1] = 0, t[a + 2] = 0);
+ }, r.readStringLine = function(t, e) {
+ for (var n = "", i = "", o = e; o < t.length - e && (i = String.fromCharCode(t[o])) != `
+`; o++)
+ n += i;
+ return n;
+ }, r.RGBE_ReadHeader = function(t) {
+ var e, n, i = this.readStringLine(t, 0);
+ if (i[0] != "#" || i[1] != "?")
+ throw "Bad HDR Format.";
+ var o = !1, a = !1, s = 0;
+ do
+ s += i.length + 1, (i = this.readStringLine(t, s)) == "FORMAT=32-bit_rle_rgbe" ? a = !0 : i.length == 0 && (o = !0);
+ while (!o);
+ if (!a)
+ throw "HDR Bad header format, unsupported FORMAT";
+ s += i.length + 1, i = this.readStringLine(t, s);
+ var d = /^\-Y (.*) \+X (.*)$/g.exec(i);
+ if (!d || d.length < 3)
+ throw "HDR Bad header format, no size";
+ if (n = parseInt(d[2]), e = parseInt(d[1]), n < 8 || n > 32767)
+ throw "HDR Bad header format, unsupported size";
+ return { height: e, width: n, dataPosition: s += i.length + 1 };
+ }, r.GetCubeMapTextureData = function(t, e) {
+ var n = new Uint8Array(t), i = this.RGBE_ReadHeader(n), o = this.RGBE_ReadPixels(n, i);
+ return ws.ConvertPanoramaToCubemap(o, i.width, i.height, e);
+ }, r.RGBE_ReadPixels = function(t, e) {
+ return this.RGBE_ReadPixels_RLE(t, e);
+ }, r.RGBE_ReadPixels_RLE = function(t, e) {
+ for (var n, i, o, a, s, d = e.height, p = e.width, y = e.dataPosition, P = 0, R = 0, B = 0, F = new ArrayBuffer(4 * p), z = new Uint8Array(F), J = new ArrayBuffer(e.width * e.height * 4 * 3), ie = new Float32Array(J); d > 0; ) {
+ if (n = t[y++], i = t[y++], o = t[y++], a = t[y++], n != 2 || i != 2 || 128 & o || e.width < 8 || e.width > 32767)
+ return this.RGBE_ReadPixels_NOT_RLE(t, e);
+ if ((o << 8 | a) != p)
+ throw "HDR Bad header format, wrong scan line width";
+ for (P = 0, B = 0; B < 4; B++)
+ for (R = (B + 1) * p; P < R; )
+ if (n = t[y++], i = t[y++], n > 128) {
+ if ((s = n - 128) == 0 || s > R - P)
+ throw "HDR Bad Format, bad scanline data (run)";
+ for (; s-- > 0; )
+ z[P++] = i;
+ } else {
+ if ((s = n) == 0 || s > R - P)
+ throw "HDR Bad Format, bad scanline data (non-run)";
+ if (z[P++] = i, --s > 0)
+ for (var se = 0; se < s; se++)
+ z[P++] = t[y++];
+ }
+ for (B = 0; B < p; B++)
+ n = z[B], i = z[B + p], o = z[B + 2 * p], a = z[B + 3 * p], this.Rgbe2float(ie, n, i, o, a, (e.height - d) * p * 3 + 3 * B);
+ d--;
+ }
+ return ie;
+ }, r.RGBE_ReadPixels_NOT_RLE = function(t, e) {
+ for (var n, i, o, a, s, d = e.height, p = e.width, y = e.dataPosition, P = new ArrayBuffer(e.width * e.height * 4 * 3), R = new Float32Array(P); d > 0; ) {
+ for (s = 0; s < e.width; s++)
+ n = t[y++], i = t[y++], o = t[y++], a = t[y++], this.Rgbe2float(R, n, i, o, a, (e.height - d) * p * 3 + 3 * s);
+ d--;
+ }
+ return R;
+ }, r;
+ }(), xu = function() {
+ function r(t, e) {
+ var n;
+ e === void 0 && (e = r._DefaultOptions), this.engine = t, this._fullscreenViewport = new jn.a(0, 0, 1, 1), e = Object(c.a)(Object(c.a)({}, r._DefaultOptions), e), this._vertexBuffers = ((n = {})[Oe.b.PositionKind] = new Oe.b(t, e.positions, Oe.b.PositionKind, !1, !1, 2), n), this._indexBuffer = t.createIndexBuffer(e.indices);
+ }
+ return r.prototype.setViewport = function(t) {
+ t === void 0 && (t = this._fullscreenViewport), this.engine.setViewport(t);
+ }, r.prototype.bindBuffers = function(t) {
+ this.engine.bindBuffers(this._vertexBuffers, this._indexBuffer, t);
+ }, r.prototype.applyEffectWrapper = function(t) {
+ this.engine.depthCullingState.depthTest = !1, this.engine.stencilState.stencilTest = !1, this.engine.enableEffect(t.effect), this.bindBuffers(t.effect), t.onApplyObservable.notifyObservers({});
+ }, r.prototype.restoreStates = function() {
+ this.engine.depthCullingState.depthTest = !0, this.engine.stencilState.stencilTest = !0;
+ }, r.prototype.draw = function() {
+ this.engine.drawElementsType(h.a.MATERIAL_TriangleFillMode, 0, 6);
+ }, r.prototype.isRenderTargetTexture = function(t) {
+ return t.renderList !== void 0;
+ }, r.prototype.render = function(t, e) {
+ if (e === void 0 && (e = null), t.effect.isReady()) {
+ this.setViewport();
+ var n = e === null ? null : this.isRenderTargetTexture(e) ? e.getInternalTexture() : e;
+ n && this.engine.bindFramebuffer(n), this.applyEffectWrapper(t), this.draw(), n && this.engine.unBindFramebuffer(n), this.restoreStates();
+ }
+ }, r.prototype.dispose = function() {
+ var t = this._vertexBuffers[Oe.b.PositionKind];
+ t && (t.dispose(), delete this._vertexBuffers[Oe.b.PositionKind]), this._indexBuffer && this.engine._releaseBuffer(this._indexBuffer);
+ }, r._DefaultOptions = { positions: [1, 1, -1, 1, -1, -1, 1, -1], indices: [0, 1, 2, 0, 2, 3] }, r;
+ }(), Cu = function() {
+ function r(t) {
+ var e, n = this;
+ this.onApplyObservable = new C.c();
+ var i = t.uniformNames || [];
+ t.vertexShader ? e = { fragmentSource: t.fragmentShader, vertexSource: t.vertexShader, spectorName: t.name || "effectWrapper" } : (i.push("scale"), e = { fragmentSource: t.fragmentShader, vertex: "postprocess", spectorName: t.name || "effectWrapper" }, this.onApplyObservable.add(function() {
+ n.effect.setFloat2("scale", 1, 1);
+ }));
+ var o = t.defines ? t.defines.join(`
+`) : "";
+ t.useShaderStore ? (e.fragment = e.fragmentSource, e.vertex || (e.vertex = e.vertexSource), delete e.fragmentSource, delete e.vertexSource, this.effect = t.engine.createEffect(e.spectorName, t.attributeNames || ["position"], i, t.samplerNames, o, void 0, t.onCompiled)) : this.effect = new ze.a(e, t.attributeNames || ["position"], i, t.samplerNames, t.engine, o, void 0, t.onCompiled);
+ }
+ return r.prototype.dispose = function() {
+ this.effect.dispose();
+ }, r;
+ }(), A_ = `
+attribute vec2 position;
+
+varying vec3 direction;
+
+uniform vec3 up;
+uniform vec3 right;
+uniform vec3 front;
+void main(void) {
+mat3 view=mat3(up,right,front);
+direction=view*vec3(position,1.0);
+gl_Position=vec4(position,0.0,1.0);
+}`;
+ ze.a.ShadersStore.hdrFilteringVertexShader = A_;
+ var P_ = `#include
+#include
+#include
+#include
+uniform float alphaG;
+uniform samplerCube inputTexture;
+uniform vec2 vFilteringInfo;
+uniform float hdrScale;
+varying vec3 direction;
+void main() {
+vec3 color=radiance(alphaG,inputTexture,direction,vFilteringInfo);
+gl_FragColor=vec4(color*hdrScale,1.0);
+}`;
+ ze.a.ShadersStore.hdrFilteringPixelShader = P_;
+ var Ru = function() {
+ function r(t, e) {
+ e === void 0 && (e = {}), this._lodGenerationOffset = 0, this._lodGenerationScale = 0.8, this.quality = h.a.TEXTURE_FILTERING_QUALITY_OFFLINE, this.hdrScale = 1, this._engine = t, this.hdrScale = e.hdrScale || this.hdrScale, this.quality = e.hdrScale || this.quality;
+ }
+ return r.prototype._createRenderTarget = function(t) {
+ var e = h.a.TEXTURETYPE_UNSIGNED_BYTE;
+ this._engine.getCaps().textureHalfFloatRender ? e = h.a.TEXTURETYPE_HALF_FLOAT : this._engine.getCaps().textureFloatRender && (e = h.a.TEXTURETYPE_FLOAT);
+ var n = this._engine.createRenderTargetCubeTexture(t, { format: h.a.TEXTUREFORMAT_RGBA, type: e, generateMipMaps: !1, generateDepthBuffer: !1, generateStencilBuffer: !1, samplingMode: h.a.TEXTURE_NEAREST_SAMPLINGMODE });
+ return this._engine.updateTextureWrappingMode(n, h.a.TEXTURE_CLAMP_ADDRESSMODE, h.a.TEXTURE_CLAMP_ADDRESSMODE, h.a.TEXTURE_CLAMP_ADDRESSMODE), this._engine.updateTextureSamplingMode(h.a.TEXTURE_TRILINEAR_SAMPLINGMODE, n, !0), n;
+ }, r.prototype._prefilterInternal = function(t) {
+ var e = t.getSize().width, n = Math.round($.a.Log2(e)) + 1, i = this._effectWrapper.effect, o = this._createRenderTarget(e);
+ this._effectRenderer.setViewport();
+ var a = t.getInternalTexture();
+ a && this._engine.updateTextureSamplingMode(h.a.TEXTURE_TRILINEAR_SAMPLINGMODE, a, !0), this._effectRenderer.applyEffectWrapper(this._effectWrapper);
+ var s = [[new u.e(0, 0, -1), new u.e(0, -1, 0), new u.e(1, 0, 0)], [new u.e(0, 0, 1), new u.e(0, -1, 0), new u.e(-1, 0, 0)], [new u.e(1, 0, 0), new u.e(0, 0, 1), new u.e(0, 1, 0)], [new u.e(1, 0, 0), new u.e(0, 0, -1), new u.e(0, -1, 0)], [new u.e(1, 0, 0), new u.e(0, -1, 0), new u.e(0, 0, 1)], [new u.e(-1, 0, 0), new u.e(0, -1, 0), new u.e(0, 0, -1)]];
+ i.setFloat("hdrScale", this.hdrScale), i.setFloat2("vFilteringInfo", t.getSize().width, n), i.setTexture("inputTexture", t);
+ for (var d = 0; d < 6; d++) {
+ i.setVector3("up", s[d][0]), i.setVector3("right", s[d][1]), i.setVector3("front", s[d][2]);
+ for (var p = 0; p < n; p++) {
+ this._engine.bindFramebuffer(o, d, void 0, void 0, !0, p), this._effectRenderer.applyEffectWrapper(this._effectWrapper);
+ var y = Math.pow(2, (p - this._lodGenerationOffset) / this._lodGenerationScale) / e;
+ p === 0 && (y = 0), i.setFloat("alphaG", y), this._effectRenderer.draw();
+ }
+ }
+ return this._effectRenderer.restoreStates(), this._engine.restoreDefaultFramebuffer(), this._engine._releaseFramebufferObjects(o), this._engine._releaseTexture(t._texture), o._swapAndDie(t._texture), t._prefiltered = !0, t;
+ }, r.prototype._createEffect = function(t, e) {
+ var n = [];
+ return t.gammaSpace && n.push("#define GAMMA_INPUT"), n.push("#define NUM_SAMPLES " + this.quality + "u"), new Cu({ engine: this._engine, name: "hdrFiltering", vertexShader: "hdrFiltering", fragmentShader: "hdrFiltering", samplerNames: ["inputTexture"], uniformNames: ["vSampleDirections", "vWeights", "up", "right", "front", "vFilteringInfo", "hdrScale", "alphaG"], useShaderStore: !0, defines: n, onCompiled: e });
+ }, r.prototype.isReady = function(t) {
+ return t.isReady() && this._effectWrapper.effect.isReady();
+ }, r.prototype.prefilter = function(t, e) {
+ var n = this;
+ if (e === void 0 && (e = null), this._engine.webGLVersion !== 1)
+ return new Promise(function(i) {
+ n._effectRenderer = new xu(n._engine), n._effectWrapper = n._createEffect(t), n._effectWrapper.effect.executeWhenCompiled(function() {
+ n._prefilterInternal(t), n._effectRenderer.dispose(), n._effectWrapper.dispose(), i(), e && e();
+ });
+ });
+ l.a.Warn("HDR prefiltering is not available in WebGL 1., you can use real time filtering instead.");
+ }, r;
+ }(), qo = function(r) {
+ function t(e, n, i, o, a, s, d, p, y) {
+ var P;
+ o === void 0 && (o = !1), a === void 0 && (a = !0), s === void 0 && (s = !1), d === void 0 && (d = !1), p === void 0 && (p = null), y === void 0 && (y = null);
+ var R = r.call(this, n) || this;
+ return R._generateHarmonics = !0, R._onLoad = null, R._onError = null, R._isBlocking = !0, R._rotationY = 0, R.boundingBoxPosition = u.e.Zero(), e && (R._coordinatesMode = Ne.a.CUBIC_MODE, R.name = e, R.url = e, R.hasAlpha = !1, R.isCube = !0, R._textureMatrix = u.a.Identity(), R._prefilterOnLoad = d, R._onLoad = p, R._onError = y, R.gammaSpace = s, R._noMipmap = o, R._size = i, R._generateHarmonics = a, R._texture = R._getFromCache(e, R._noMipmap), R._texture ? p && (R._texture.isReady ? Xe.b.SetImmediate(function() {
+ return p();
+ }) : R._texture.onLoadedObservable.add(p)) : !((P = R.getScene()) === null || P === void 0) && P.useDelayedTextureLoading ? R.delayLoadState = h.a.DELAYLOADSTATE_NOTLOADED : R.loadTexture()), R;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "isBlocking", { get: function() {
+ return this._isBlocking;
+ }, set: function(e) {
+ this._isBlocking = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rotationY", { get: function() {
+ return this._rotationY;
+ }, set: function(e) {
+ this._rotationY = e, this.setReflectionTextureMatrix(u.a.RotationY(this._rotationY));
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "boundingBoxSize", { get: function() {
+ return this._boundingBoxSize;
+ }, set: function(e) {
+ if (!this._boundingBoxSize || !this._boundingBoxSize.equals(e)) {
+ this._boundingBoxSize = e;
+ var n = this.getScene();
+ n && n.markAllMaterialsAsDirty(h.a.MATERIAL_TextureDirtyFlag);
+ }
+ }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
+ return "HDRCubeTexture";
+ }, t.prototype.loadTexture = function() {
+ var e = this, n = this._getEngine();
+ if (this._getEngine().webGLVersion >= 2 && this._prefilterOnLoad) {
+ var i = this._onLoad, o = new Ru(n);
+ this._onLoad = function() {
+ o.prefilter(e, i);
+ };
+ }
+ this._texture = n.createRawCubeTextureFromUrl(this.url, this.getScene(), this._size, h.a.TEXTUREFORMAT_RGB, n.getCaps().textureFloat ? h.a.TEXTURETYPE_FLOAT : h.a.TEXTURETYPE_UNSIGNED_INT, this._noMipmap, function(a) {
+ e.lodGenerationOffset = 0, e.lodGenerationScale = 0.8;
+ var s = Pu.GetCubeMapTextureData(a, e._size);
+ if (e._generateHarmonics) {
+ var d = Lo.ConvertCubeMapToSphericalPolynomial(s);
+ e.sphericalPolynomial = d;
+ }
+ for (var p = [], y = null, P = 0; P < 6; P++) {
+ if (!n.getCaps().textureFloat) {
+ var R = new ArrayBuffer(e._size * e._size * 3);
+ y = new Uint8Array(R);
+ }
+ var B = s[t._facesMapping[P]];
+ if (e.gammaSpace || y) {
+ for (var F = 0; F < e._size * e._size; F++)
+ if (e.gammaSpace && (B[3 * F + 0] = Math.pow(B[3 * F + 0], Vt.b), B[3 * F + 1] = Math.pow(B[3 * F + 1], Vt.b), B[3 * F + 2] = Math.pow(B[3 * F + 2], Vt.b)), y) {
+ var z = Math.max(255 * B[3 * F + 0], 0), J = Math.max(255 * B[3 * F + 1], 0), ie = Math.max(255 * B[3 * F + 2], 0), se = Math.max(Math.max(z, J), ie);
+ if (se > 255) {
+ var ce = 255 / se;
+ z *= ce, J *= ce, ie *= ce;
+ }
+ y[3 * F + 0] = z, y[3 * F + 1] = J, y[3 * F + 2] = ie;
+ }
+ }
+ y ? p.push(y) : p.push(B);
+ }
+ return p;
+ }, null, this._onLoad, this._onError);
+ }, t.prototype.clone = function() {
+ var e = new t(this.url, this.getScene() || this._getEngine(), this._size, this._noMipmap, this._generateHarmonics, this.gammaSpace);
+ return e.level = this.level, e.wrapU = this.wrapU, e.wrapV = this.wrapV, e.coordinatesIndex = this.coordinatesIndex, e.coordinatesMode = this.coordinatesMode, e;
+ }, t.prototype.delayLoad = function() {
+ this.delayLoadState === h.a.DELAYLOADSTATE_NOTLOADED && (this.delayLoadState = h.a.DELAYLOADSTATE_LOADED, this._texture = this._getFromCache(this.url, this._noMipmap), this._texture || this.loadTexture());
+ }, t.prototype.getReflectionTextureMatrix = function() {
+ return this._textureMatrix;
+ }, t.prototype.setReflectionTextureMatrix = function(e) {
+ var n, i = this;
+ this._textureMatrix = e, e.updateFlag !== this._textureMatrix.updateFlag && e.isIdentity() !== this._textureMatrix.isIdentity() && ((n = this.getScene()) === null || n === void 0 || n.markAllMaterialsAsDirty(h.a.MATERIAL_TextureDirtyFlag, function(o) {
+ return o.getActiveTextures().indexOf(i) !== -1;
+ }));
+ }, t.Parse = function(e, n, i) {
+ var o = null;
+ return e.name && !e.isRenderTarget && ((o = new t(i + e.name, n, e.size, e.noMipmap, e.generateHarmonics, e.useInGammaSpace)).name = e.name, o.hasAlpha = e.hasAlpha, o.level = e.level, o.coordinatesMode = e.coordinatesMode, o.isBlocking = e.isBlocking), o && (e.boundingBoxPosition && (o.boundingBoxPosition = u.e.FromArray(e.boundingBoxPosition)), e.boundingBoxSize && (o.boundingBoxSize = u.e.FromArray(e.boundingBoxSize)), e.rotationY && (o.rotationY = e.rotationY)), o;
+ }, t.prototype.serialize = function() {
+ if (!this.name)
+ return null;
+ var e = {};
+ return e.name = this.name, e.hasAlpha = this.hasAlpha, e.isCube = !0, e.level = this.level, e.size = this._size, e.coordinatesMode = this.coordinatesMode, e.useInGammaSpace = this.gammaSpace, e.generateHarmonics = this._generateHarmonics, e.customType = "BABYLON.HDRCubeTexture", e.noMipmap = this._noMipmap, e.isBlocking = this._isBlocking, e.rotationY = this._rotationY, e;
+ }, t._facesMapping = ["right", "left", "up", "down", "front", "back"], t;
+ }(kn.a);
+ O.a.RegisteredTypes["BABYLON.HDRCubeTexture"] = qo;
+ var Ou = function() {
+ function r(t, e, n) {
+ e === void 0 && (e = 0), n === void 0 && (n = null), this.name = t, this.animations = new Array(), this._positions = null, this._normals = null, this._tangents = null, this._uvs = null, this._uniqueId = 0, this.onInfluenceChanged = new C.c(), this._onDataLayoutChanged = new C.c(), this._animationPropertiesOverride = null, this._scene = n || te.a.LastCreatedScene, this.influence = e, this._scene && (this._uniqueId = this._scene.getUniqueId());
+ }
+ return Object.defineProperty(r.prototype, "influence", { get: function() {
+ return this._influence;
+ }, set: function(t) {
+ if (this._influence !== t) {
+ var e = this._influence;
+ this._influence = t, this.onInfluenceChanged.hasObservers() && this.onInfluenceChanged.notifyObservers(e === 0 || t === 0);
+ }
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "animationPropertiesOverride", { get: function() {
+ return !this._animationPropertiesOverride && this._scene ? this._scene.animationPropertiesOverride : this._animationPropertiesOverride;
+ }, set: function(t) {
+ this._animationPropertiesOverride = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "uniqueId", { get: function() {
+ return this._uniqueId;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "hasPositions", { get: function() {
+ return !!this._positions;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "hasNormals", { get: function() {
+ return !!this._normals;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "hasTangents", { get: function() {
+ return !!this._tangents;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "hasUVs", { get: function() {
+ return !!this._uvs;
+ }, enumerable: !1, configurable: !0 }), r.prototype.setPositions = function(t) {
+ var e = this.hasPositions;
+ this._positions = t, e !== this.hasPositions && this._onDataLayoutChanged.notifyObservers(void 0);
+ }, r.prototype.getPositions = function() {
+ return this._positions;
+ }, r.prototype.setNormals = function(t) {
+ var e = this.hasNormals;
+ this._normals = t, e !== this.hasNormals && this._onDataLayoutChanged.notifyObservers(void 0);
+ }, r.prototype.getNormals = function() {
+ return this._normals;
+ }, r.prototype.setTangents = function(t) {
+ var e = this.hasTangents;
+ this._tangents = t, e !== this.hasTangents && this._onDataLayoutChanged.notifyObservers(void 0);
+ }, r.prototype.getTangents = function() {
+ return this._tangents;
+ }, r.prototype.setUVs = function(t) {
+ var e = this.hasUVs;
+ this._uvs = t, e !== this.hasUVs && this._onDataLayoutChanged.notifyObservers(void 0);
+ }, r.prototype.getUVs = function() {
+ return this._uvs;
+ }, r.prototype.clone = function() {
+ var t = this, e = L.a.Clone(function() {
+ return new r(t.name, t.influence, t._scene);
+ }, this);
+ return e._positions = this._positions, e._normals = this._normals, e._tangents = this._tangents, e._uvs = this._uvs, e;
+ }, r.prototype.serialize = function() {
+ var t = {};
+ return t.name = this.name, t.influence = this.influence, t.positions = Array.prototype.slice.call(this.getPositions()), this.id != null && (t.id = this.id), this.hasNormals && (t.normals = Array.prototype.slice.call(this.getNormals())), this.hasTangents && (t.tangents = Array.prototype.slice.call(this.getTangents())), this.hasUVs && (t.uvs = Array.prototype.slice.call(this.getUVs())), L.a.AppendSerializedAnimations(this, t), t;
+ }, r.prototype.getClassName = function() {
+ return "MorphTarget";
+ }, r.Parse = function(t) {
+ var e = new r(t.name, t.influence);
+ if (e.setPositions(t.positions), t.id != null && (e.id = t.id), t.normals && e.setNormals(t.normals), t.tangents && e.setTangents(t.tangents), t.uvs && e.setUVs(t.uvs), t.animations)
+ for (var n = 0; n < t.animations.length; n++) {
+ var i = t.animations[n], o = O.a.GetClass("BABYLON.Animation");
+ o && e.animations.push(o.Parse(i));
+ }
+ return e;
+ }, r.FromMesh = function(t, e, n) {
+ e || (e = t.name);
+ var i = new r(e, n, t.getScene());
+ return i.setPositions(t.getVerticesData(Oe.b.PositionKind)), t.isVerticesDataPresent(Oe.b.NormalKind) && i.setNormals(t.getVerticesData(Oe.b.NormalKind)), t.isVerticesDataPresent(Oe.b.TangentKind) && i.setTangents(t.getVerticesData(Oe.b.TangentKind)), t.isVerticesDataPresent(Oe.b.UVKind) && i.setUVs(t.getVerticesData(Oe.b.UVKind)), i;
+ }, Object(c.c)([Object(L.c)()], r.prototype, "id", void 0), r;
+ }(), Zo = function() {
+ function r(t) {
+ t === void 0 && (t = null), this._targets = new Array(), this._targetInfluenceChangedObservers = new Array(), this._targetDataLayoutChangedObservers = new Array(), this._activeTargets = new si.a(16), this._supportsNormals = !1, this._supportsTangents = !1, this._supportsUVs = !1, this._vertexCount = 0, this._uniqueId = 0, this._tempInfluences = new Array(), this.enableNormalMorphing = !0, this.enableTangentMorphing = !0, this.enableUVMorphing = !0, t || (t = te.a.LastCreatedScene), this._scene = t, this._scene && (this._scene.morphTargetManagers.push(this), this._uniqueId = this._scene.getUniqueId());
+ }
+ return Object.defineProperty(r.prototype, "uniqueId", { get: function() {
+ return this._uniqueId;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "vertexCount", { get: function() {
+ return this._vertexCount;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "supportsNormals", { get: function() {
+ return this._supportsNormals && this.enableNormalMorphing;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "supportsTangents", { get: function() {
+ return this._supportsTangents && this.enableTangentMorphing;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "supportsUVs", { get: function() {
+ return this._supportsUVs && this.enableUVMorphing;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "numTargets", { get: function() {
+ return this._targets.length;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "numInfluencers", { get: function() {
+ return this._activeTargets.length;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "influences", { get: function() {
+ return this._influences;
+ }, enumerable: !1, configurable: !0 }), r.prototype.getActiveTarget = function(t) {
+ return this._activeTargets.data[t];
+ }, r.prototype.getTarget = function(t) {
+ return this._targets[t];
+ }, r.prototype.addTarget = function(t) {
+ var e = this;
+ this._targets.push(t), this._targetInfluenceChangedObservers.push(t.onInfluenceChanged.add(function(n) {
+ e._syncActiveTargets(n);
+ })), this._targetDataLayoutChangedObservers.push(t._onDataLayoutChanged.add(function() {
+ e._syncActiveTargets(!0);
+ })), this._syncActiveTargets(!0);
+ }, r.prototype.removeTarget = function(t) {
+ var e = this._targets.indexOf(t);
+ e >= 0 && (this._targets.splice(e, 1), t.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(e, 1)[0]), t._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(e, 1)[0]), this._syncActiveTargets(!0));
+ }, r.prototype.clone = function() {
+ for (var t = new r(this._scene), e = 0, n = this._targets; e < n.length; e++) {
+ var i = n[e];
+ t.addTarget(i.clone());
+ }
+ return t.enableNormalMorphing = this.enableNormalMorphing, t.enableTangentMorphing = this.enableTangentMorphing, t.enableUVMorphing = this.enableUVMorphing, t;
+ }, r.prototype.serialize = function() {
+ var t = {};
+ t.id = this.uniqueId, t.targets = [];
+ for (var e = 0, n = this._targets; e < n.length; e++) {
+ var i = n[e];
+ t.targets.push(i.serialize());
+ }
+ return t;
+ }, r.prototype._syncActiveTargets = function(t) {
+ var e = 0;
+ this._activeTargets.reset(), this._supportsNormals = !0, this._supportsTangents = !0, this._supportsUVs = !0, this._vertexCount = 0;
+ for (var n = 0, i = this._targets; n < i.length; n++) {
+ var o = i[n];
+ if (o.influence !== 0) {
+ this._activeTargets.push(o), this._tempInfluences[e++] = o.influence, this._supportsNormals = this._supportsNormals && o.hasNormals, this._supportsTangents = this._supportsTangents && o.hasTangents, this._supportsUVs = this._supportsUVs && o.hasUVs;
+ var a = o.getPositions();
+ if (a) {
+ var s = a.length / 3;
+ if (this._vertexCount === 0)
+ this._vertexCount = s;
+ else if (this._vertexCount !== s)
+ return void l.a.Error("Incompatible target. Targets must all have the same vertices count.");
+ }
+ }
+ }
+ this._influences && this._influences.length === e || (this._influences = new Float32Array(e));
+ for (var d = 0; d < e; d++)
+ this._influences[d] = this._tempInfluences[d];
+ t && this.synchronize();
+ }, r.prototype.synchronize = function() {
+ if (this._scene)
+ for (var t = 0, e = this._scene.meshes; t < e.length; t++) {
+ var n = e[t];
+ n.morphTargetManager === this && n._syncGeometryWithMorphTargetManager();
+ }
+ }, r.Parse = function(t, e) {
+ var n = new r(e);
+ n._uniqueId = t.id;
+ for (var i = 0, o = t.targets; i < o.length; i++) {
+ var a = o[i];
+ n.addTarget(Ou.Parse(a));
+ }
+ return n;
+ }, r;
+ }(), At = f(32), Jt = f(50), Sr = function() {
+ function r(t, e) {
+ if (e === void 0 && (e = r.DefaultPluginFactory()), this._physicsPlugin = e, this._impostors = [], this._joints = [], this._subTimeStep = 0, !this._physicsPlugin.isSupported())
+ throw new Error("Physics Engine " + this._physicsPlugin.name + " cannot be found. Please make sure it is included.");
+ t = t || new u.e(0, -9.807, 0), this.setGravity(t), this.setTimeStep();
+ }
+ return r.DefaultPluginFactory = function() {
+ throw En.a.WarnImport("CannonJSPlugin");
+ }, r.prototype.setGravity = function(t) {
+ this.gravity = t, this._physicsPlugin.setGravity(this.gravity);
+ }, r.prototype.setTimeStep = function(t) {
+ t === void 0 && (t = 1 / 60), this._physicsPlugin.setTimeStep(t);
+ }, r.prototype.getTimeStep = function() {
+ return this._physicsPlugin.getTimeStep();
+ }, r.prototype.setSubTimeStep = function(t) {
+ t === void 0 && (t = 0), this._subTimeStep = t;
+ }, r.prototype.getSubTimeStep = function() {
+ return this._subTimeStep;
+ }, r.prototype.dispose = function() {
+ this._impostors.forEach(function(t) {
+ t.dispose();
+ }), this._physicsPlugin.dispose();
+ }, r.prototype.getPhysicsPluginName = function() {
+ return this._physicsPlugin.name;
+ }, r.prototype.addImpostor = function(t) {
+ t.uniqueId = this._impostors.push(t), t.parent || this._physicsPlugin.generatePhysicsBody(t);
+ }, r.prototype.removeImpostor = function(t) {
+ var e = this._impostors.indexOf(t);
+ e > -1 && this._impostors.splice(e, 1).length && this.getPhysicsPlugin().removePhysicsBody(t);
+ }, r.prototype.addJoint = function(t, e, n) {
+ var i = { mainImpostor: t, connectedImpostor: e, joint: n };
+ n.physicsPlugin = this._physicsPlugin, this._joints.push(i), this._physicsPlugin.generateJoint(i);
+ }, r.prototype.removeJoint = function(t, e, n) {
+ var i = this._joints.filter(function(o) {
+ return o.connectedImpostor === e && o.joint === n && o.mainImpostor === t;
+ });
+ i.length && this._physicsPlugin.removeJoint(i[0]);
+ }, r.prototype._step = function(t) {
+ var e = this;
+ this._impostors.forEach(function(n) {
+ n.isBodyInitRequired() && e._physicsPlugin.generatePhysicsBody(n);
+ }), t > 0.1 ? t = 0.1 : t <= 0 && (t = 1 / 60), this._physicsPlugin.executeStep(t, this._impostors);
+ }, r.prototype.getPhysicsPlugin = function() {
+ return this._physicsPlugin;
+ }, r.prototype.getImpostors = function() {
+ return this._impostors;
+ }, r.prototype.getImpostorForPhysicsObject = function(t) {
+ for (var e = 0; e < this._impostors.length; ++e)
+ if (this._impostors[e].object === t)
+ return this._impostors[e];
+ return null;
+ }, r.prototype.getImpostorWithPhysicsBody = function(t) {
+ for (var e = 0; e < this._impostors.length; ++e)
+ if (this._impostors[e].physicsBody === t)
+ return this._impostors[e];
+ return null;
+ }, r.prototype.raycast = function(t, e) {
+ return this._physicsPlugin.raycast(t, e);
+ }, r.Epsilon = 1e-3, r;
+ }(), Fs = function() {
+ function r() {
+ this._hasHit = !1, this._hitDistance = 0, this._hitNormalWorld = u.e.Zero(), this._hitPointWorld = u.e.Zero(), this._rayFromWorld = u.e.Zero(), this._rayToWorld = u.e.Zero();
+ }
+ return Object.defineProperty(r.prototype, "hasHit", { get: function() {
+ return this._hasHit;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "hitDistance", { get: function() {
+ return this._hitDistance;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "hitNormalWorld", { get: function() {
+ return this._hitNormalWorld;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "hitPointWorld", { get: function() {
+ return this._hitPointWorld;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "rayFromWorld", { get: function() {
+ return this._rayFromWorld;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "rayToWorld", { get: function() {
+ return this._rayToWorld;
+ }, enumerable: !1, configurable: !0 }), r.prototype.setHitData = function(t, e) {
+ this._hasHit = !0, this._hitNormalWorld = new u.e(t.x, t.y, t.z), this._hitPointWorld = new u.e(e.x, e.y, e.z);
+ }, r.prototype.setHitDistance = function(t) {
+ this._hitDistance = t;
+ }, r.prototype.calculateHitDistance = function() {
+ this._hitDistance = u.e.Distance(this._rayFromWorld, this._hitPointWorld);
+ }, r.prototype.reset = function(t, e) {
+ t === void 0 && (t = u.e.Zero()), e === void 0 && (e = u.e.Zero()), this._rayFromWorld = t, this._rayToWorld = e, this._hasHit = !1, this._hitDistance = 0, this._hitNormalWorld = u.e.Zero(), this._hitPointWorld = u.e.Zero();
+ }, r;
+ }(), Bs = function() {
+ function r(t, e, n) {
+ t === void 0 && (t = !0), e === void 0 && (e = 10), n === void 0 && (n = CANNON), this._useDeltaForWorldStep = t, this.name = "CannonJSPlugin", this._physicsMaterials = new Array(), this._fixedTimeStep = 1 / 60, this._physicsBodysToRemoveAfterStep = new Array(), this._firstFrame = !0, this._minus90X = new u.b(-0.7071067811865475, 0, 0, 0.7071067811865475), this._plus90X = new u.b(0.7071067811865475, 0, 0, 0.7071067811865475), this._tmpPosition = u.e.Zero(), this._tmpDeltaPosition = u.e.Zero(), this._tmpUnityRotation = new u.b(), this.BJSCANNON = n, this.isSupported() ? (this._extendNamespace(), this.world = new this.BJSCANNON.World(), this.world.broadphase = new this.BJSCANNON.NaiveBroadphase(), this.world.solver.iterations = e, this._cannonRaycastResult = new this.BJSCANNON.RaycastResult(), this._raycastResult = new Fs()) : l.a.Error("CannonJS is not available. Please make sure you included the js file.");
+ }
+ return r.prototype.setGravity = function(t) {
+ var e = t;
+ this.world.gravity.set(e.x, e.y, e.z);
+ }, r.prototype.setTimeStep = function(t) {
+ this._fixedTimeStep = t;
+ }, r.prototype.getTimeStep = function() {
+ return this._fixedTimeStep;
+ }, r.prototype.executeStep = function(t, e) {
+ if (this._firstFrame) {
+ this._firstFrame = !1;
+ for (var n = 0, i = e; n < i.length; n++) {
+ var o = i[n];
+ o.type != At.a.HeightmapImpostor && o.type !== At.a.PlaneImpostor && o.beforeStep();
+ }
+ }
+ this.world.step(this._useDeltaForWorldStep ? t : this._fixedTimeStep), this._removeMarkedPhysicsBodiesFromWorld();
+ }, r.prototype._removeMarkedPhysicsBodiesFromWorld = function() {
+ var t = this;
+ this._physicsBodysToRemoveAfterStep.length > 0 && (this._physicsBodysToRemoveAfterStep.forEach(function(e) {
+ t.world.remove(e);
+ }), this._physicsBodysToRemoveAfterStep = []);
+ }, r.prototype.applyImpulse = function(t, e, n) {
+ var i = new this.BJSCANNON.Vec3(n.x, n.y, n.z), o = new this.BJSCANNON.Vec3(e.x, e.y, e.z);
+ t.physicsBody.applyImpulse(o, i);
+ }, r.prototype.applyForce = function(t, e, n) {
+ var i = new this.BJSCANNON.Vec3(n.x, n.y, n.z), o = new this.BJSCANNON.Vec3(e.x, e.y, e.z);
+ t.physicsBody.applyForce(o, i);
+ }, r.prototype.generatePhysicsBody = function(t) {
+ if (this._removeMarkedPhysicsBodiesFromWorld(), t.parent)
+ t.physicsBody && (this.removePhysicsBody(t), t.forceUpdate());
+ else {
+ if (t.isBodyInitRequired()) {
+ var e = this._createShape(t), n = t.physicsBody;
+ n && this.removePhysicsBody(t);
+ var i = this._addMaterial("mat-" + t.uniqueId, t.getParam("friction"), t.getParam("restitution")), o = { mass: t.getParam("mass"), material: i }, a = t.getParam("nativeOptions");
+ for (var s in a)
+ a.hasOwnProperty(s) && (o[s] = a[s]);
+ t.physicsBody = new this.BJSCANNON.Body(o), t.physicsBody.addEventListener("collide", t.onCollide), this.world.addEventListener("preStep", t.beforeStep), this.world.addEventListener("postStep", t.afterStep), t.physicsBody.addShape(e), this.world.add(t.physicsBody), n && ["force", "torque", "velocity", "angularVelocity"].forEach(function(d) {
+ var p = n[d];
+ t.physicsBody[d].set(p.x, p.y, p.z);
+ }), this._processChildMeshes(t);
+ }
+ this._updatePhysicsBodyTransformation(t);
+ }
+ }, r.prototype._processChildMeshes = function(t) {
+ var e = this, n = t.object.getChildMeshes ? t.object.getChildMeshes(!0) : [], i = t.object.rotationQuaternion;
+ if (n.length) {
+ var o = function(a) {
+ if (i && a.rotationQuaternion) {
+ var s = a.getPhysicsImpostor();
+ if (s && s.parent !== t) {
+ var d = a.getAbsolutePosition().subtract(a.parent.getAbsolutePosition()), p = a.rotationQuaternion;
+ s.physicsBody && (e.removePhysicsBody(s), s.physicsBody = null), s.parent = t, s.resetUpdateFlags(), t.physicsBody.addShape(e._createShape(s), new e.BJSCANNON.Vec3(d.x, d.y, d.z), new e.BJSCANNON.Quaternion(p.x, p.y, p.z, p.w)), t.physicsBody.mass += s.getParam("mass");
+ }
+ i.multiplyInPlace(a.rotationQuaternion), a.getChildMeshes(!0).filter(function(y) {
+ return !!y.physicsImpostor;
+ }).forEach(o);
+ }
+ };
+ n.filter(function(a) {
+ return !!a.physicsImpostor;
+ }).forEach(o);
+ }
+ }, r.prototype.removePhysicsBody = function(t) {
+ t.physicsBody.removeEventListener("collide", t.onCollide), this.world.removeEventListener("preStep", t.beforeStep), this.world.removeEventListener("postStep", t.afterStep), this._physicsBodysToRemoveAfterStep.indexOf(t.physicsBody) === -1 && this._physicsBodysToRemoveAfterStep.push(t.physicsBody);
+ }, r.prototype.generateJoint = function(t) {
+ var e = t.mainImpostor.physicsBody, n = t.connectedImpostor.physicsBody;
+ if (e && n) {
+ var i, o = t.joint.jointData, a = { pivotA: o.mainPivot ? new this.BJSCANNON.Vec3().set(o.mainPivot.x, o.mainPivot.y, o.mainPivot.z) : null, pivotB: o.connectedPivot ? new this.BJSCANNON.Vec3().set(o.connectedPivot.x, o.connectedPivot.y, o.connectedPivot.z) : null, axisA: o.mainAxis ? new this.BJSCANNON.Vec3().set(o.mainAxis.x, o.mainAxis.y, o.mainAxis.z) : null, axisB: o.connectedAxis ? new this.BJSCANNON.Vec3().set(o.connectedAxis.x, o.connectedAxis.y, o.connectedAxis.z) : null, maxForce: o.nativeParams.maxForce, collideConnected: !!o.collision };
+ switch (t.joint.type) {
+ case Jt.e.HingeJoint:
+ case Jt.e.Hinge2Joint:
+ i = new this.BJSCANNON.HingeConstraint(e, n, a);
+ break;
+ case Jt.e.DistanceJoint:
+ i = new this.BJSCANNON.DistanceConstraint(e, n, o.maxDistance || 2);
+ break;
+ case Jt.e.SpringJoint:
+ var s = o;
+ i = new this.BJSCANNON.Spring(e, n, { restLength: s.length, stiffness: s.stiffness, damping: s.damping, localAnchorA: a.pivotA, localAnchorB: a.pivotB });
+ break;
+ case Jt.e.LockJoint:
+ i = new this.BJSCANNON.LockConstraint(e, n, a);
+ break;
+ case Jt.e.PointToPointJoint:
+ case Jt.e.BallAndSocketJoint:
+ default:
+ i = new this.BJSCANNON.PointToPointConstraint(e, a.pivotA, n, a.pivotB, a.maxForce);
+ }
+ i.collideConnected = !!o.collision, t.joint.physicsJoint = i, t.joint.type !== Jt.e.SpringJoint ? this.world.addConstraint(i) : (t.joint.jointData.forceApplicationCallback = t.joint.jointData.forceApplicationCallback || function() {
+ i.applyForce();
+ }, t.mainImpostor.registerAfterPhysicsStep(t.joint.jointData.forceApplicationCallback));
+ }
+ }, r.prototype.removeJoint = function(t) {
+ t.joint.type !== Jt.e.SpringJoint ? this.world.removeConstraint(t.joint.physicsJoint) : t.mainImpostor.unregisterAfterPhysicsStep(t.joint.jointData.forceApplicationCallback);
+ }, r.prototype._addMaterial = function(t, e, n) {
+ var i, o;
+ for (i = 0; i < this._physicsMaterials.length; i++)
+ if ((o = this._physicsMaterials[i]).friction === e && o.restitution === n)
+ return o;
+ var a = new this.BJSCANNON.Material(t);
+ return a.friction = e, a.restitution = n, this._physicsMaterials.push(a), a;
+ }, r.prototype._checkWithEpsilon = function(t) {
+ return t < Sr.Epsilon ? Sr.Epsilon : t;
+ }, r.prototype._createShape = function(t) {
+ var e, n = t.object, i = t.getObjectExtendSize();
+ switch (t.type) {
+ case At.a.SphereImpostor:
+ var o = i.x, a = i.y, s = i.z;
+ e = new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(o), this._checkWithEpsilon(a), this._checkWithEpsilon(s)) / 2);
+ break;
+ case At.a.CylinderImpostor:
+ var d = t.getParam("nativeOptions");
+ d || (d = {});
+ var p = d.radiusTop !== void 0 ? d.radiusTop : this._checkWithEpsilon(i.x) / 2, y = d.radiusBottom !== void 0 ? d.radiusBottom : this._checkWithEpsilon(i.x) / 2, P = d.height !== void 0 ? d.height : this._checkWithEpsilon(i.y), R = d.numSegments !== void 0 ? d.numSegments : 16;
+ e = new this.BJSCANNON.Cylinder(p, y, P, R);
+ var B = new this.BJSCANNON.Quaternion();
+ B.setFromAxisAngle(new this.BJSCANNON.Vec3(1, 0, 0), -Math.PI / 2);
+ var F = new this.BJSCANNON.Vec3(0, 0, 0);
+ e.transformAllPoints(F, B);
+ break;
+ case At.a.BoxImpostor:
+ var z = i.scale(0.5);
+ e = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(z.x), this._checkWithEpsilon(z.y), this._checkWithEpsilon(z.z)));
+ break;
+ case At.a.PlaneImpostor:
+ l.a.Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead"), e = new this.BJSCANNON.Plane();
+ break;
+ case At.a.MeshImpostor:
+ var J = n.getVerticesData ? n.getVerticesData(Oe.b.PositionKind) : [], ie = n.getIndices ? n.getIndices() : [];
+ if (!J)
+ return;
+ var se = n.position.clone(), ce = n.rotation && n.rotation.clone(), ue = n.rotationQuaternion && n.rotationQuaternion.clone();
+ n.position.copyFromFloats(0, 0, 0), n.rotation && n.rotation.copyFromFloats(0, 0, 0), n.rotationQuaternion && n.rotationQuaternion.copyFrom(t.getParentsRotation()), n.rotationQuaternion && n.parent && n.rotationQuaternion.conjugateInPlace();
+ var fe, ve = n.computeWorldMatrix(!0), Te = new Array();
+ for (fe = 0; fe < J.length; fe += 3)
+ u.e.TransformCoordinates(u.e.FromArray(J, fe), ve).toArray(Te, fe);
+ l.a.Warn("MeshImpostor only collides against spheres."), e = new this.BJSCANNON.Trimesh(Te, ie), n.position.copyFrom(se), ce && n.rotation && n.rotation.copyFrom(ce), ue && n.rotationQuaternion && n.rotationQuaternion.copyFrom(ue);
+ break;
+ case At.a.HeightmapImpostor:
+ var Re = n.position.clone(), Ae = n.rotation && n.rotation.clone(), Ee = n.rotationQuaternion && n.rotationQuaternion.clone();
+ n.position.copyFromFloats(0, 0, 0), n.rotation && n.rotation.copyFromFloats(0, 0, 0), n.rotationQuaternion && n.rotationQuaternion.copyFrom(t.getParentsRotation()), n.rotationQuaternion && n.parent && n.rotationQuaternion.conjugateInPlace(), n.rotationQuaternion && n.rotationQuaternion.multiplyInPlace(this._minus90X), e = this._createHeightmap(n), n.position.copyFrom(Re), Ae && n.rotation && n.rotation.copyFrom(Ae), Ee && n.rotationQuaternion && n.rotationQuaternion.copyFrom(Ee), n.computeWorldMatrix(!0);
+ break;
+ case At.a.ParticleImpostor:
+ e = new this.BJSCANNON.Particle();
+ break;
+ case At.a.NoImpostor:
+ e = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(0, 0, 0));
+ }
+ return e;
+ }, r.prototype._createHeightmap = function(t, e) {
+ var n, i = t.getVerticesData(Oe.b.PositionKind), o = t.computeWorldMatrix(!0), a = new Array();
+ for (n = 0; n < i.length; n += 3)
+ u.e.TransformCoordinates(u.e.FromArray(i, n), o).toArray(a, n);
+ i = a;
+ for (var s = new Array(), d = e || ~~(Math.sqrt(i.length / 3) - 1), p = t.getBoundingInfo(), y = Math.min(p.boundingBox.extendSizeWorld.x, p.boundingBox.extendSizeWorld.y), P = p.boundingBox.extendSizeWorld.z, R = 2 * y / d, B = 0; B < i.length; B += 3) {
+ var F = Math.round(i[B + 0] / R + d / 2), z = Math.round(-1 * (i[B + 1] / R - d / 2)), J = -i[B + 2] + P;
+ s[F] || (s[F] = []), s[F][z] || (s[F][z] = J), s[F][z] = Math.max(J, s[F][z]);
+ }
+ for (F = 0; F <= d; ++F) {
+ if (!s[F]) {
+ for (var ie = 1; !s[(F + ie) % d]; )
+ ie++;
+ s[F] = s[(F + ie) % d].slice();
+ }
+ for (z = 0; z <= d; ++z)
+ if (!s[F][z]) {
+ var se;
+ for (ie = 1; se === void 0; )
+ se = s[F][(z + ie++) % d];
+ s[F][z] = se;
+ }
+ }
+ var ce = new this.BJSCANNON.Heightfield(s, { elementSize: R });
+ return ce.minY = P, ce;
+ }, r.prototype._updatePhysicsBodyTransformation = function(t) {
+ var e = t.object;
+ if (e.computeWorldMatrix && e.computeWorldMatrix(!0), e.getBoundingInfo()) {
+ var n = t.getObjectCenter();
+ this._tmpDeltaPosition.copyFrom(e.getAbsolutePivotPoint().subtract(n)), this._tmpDeltaPosition.divideInPlace(t.object.scaling), this._tmpPosition.copyFrom(n);
+ var i = e.rotationQuaternion;
+ if (i) {
+ if (t.type !== At.a.PlaneImpostor && t.type !== At.a.HeightmapImpostor || (i = i.multiply(this._minus90X), t.setDeltaRotation(this._plus90X)), t.type === At.a.HeightmapImpostor) {
+ var o = e, a = o.getBoundingInfo(), s = o.rotationQuaternion;
+ o.rotationQuaternion = this._tmpUnityRotation, o.computeWorldMatrix(!0);
+ var d = n.clone(), p = o.getPivotMatrix();
+ p = p ? p.clone() : u.a.Identity();
+ var y = u.a.Translation(a.boundingBox.extendSizeWorld.x, 0, -a.boundingBox.extendSizeWorld.z);
+ o.setPreTransformMatrix(y), o.computeWorldMatrix(!0);
+ var P = a.boundingBox.centerWorld.subtract(n).subtract(o.position).negate();
+ this._tmpPosition.copyFromFloats(P.x, P.y - a.boundingBox.extendSizeWorld.y, P.z), this._tmpDeltaPosition.copyFrom(a.boundingBox.centerWorld.subtract(d)), this._tmpDeltaPosition.y += a.boundingBox.extendSizeWorld.y, o.rotationQuaternion = s, o.setPreTransformMatrix(p), o.computeWorldMatrix(!0);
+ } else
+ t.type === At.a.MeshImpostor && this._tmpDeltaPosition.copyFromFloats(0, 0, 0);
+ t.setDeltaPosition(this._tmpDeltaPosition), t.physicsBody.position.set(this._tmpPosition.x, this._tmpPosition.y, this._tmpPosition.z), t.physicsBody.quaternion.set(i.x, i.y, i.z, i.w);
+ }
+ }
+ }, r.prototype.setTransformationFromPhysicsBody = function(t) {
+ if (t.object.position.set(t.physicsBody.position.x, t.physicsBody.position.y, t.physicsBody.position.z), t.object.rotationQuaternion) {
+ var e = t.physicsBody.quaternion;
+ t.object.rotationQuaternion.set(e.x, e.y, e.z, e.w);
+ }
+ }, r.prototype.setPhysicsBodyTransformation = function(t, e, n) {
+ t.physicsBody.position.set(e.x, e.y, e.z), t.physicsBody.quaternion.set(n.x, n.y, n.z, n.w);
+ }, r.prototype.isSupported = function() {
+ return this.BJSCANNON !== void 0;
+ }, r.prototype.setLinearVelocity = function(t, e) {
+ t.physicsBody.velocity.set(e.x, e.y, e.z);
+ }, r.prototype.setAngularVelocity = function(t, e) {
+ t.physicsBody.angularVelocity.set(e.x, e.y, e.z);
+ }, r.prototype.getLinearVelocity = function(t) {
+ var e = t.physicsBody.velocity;
+ return e ? new u.e(e.x, e.y, e.z) : null;
+ }, r.prototype.getAngularVelocity = function(t) {
+ var e = t.physicsBody.angularVelocity;
+ return e ? new u.e(e.x, e.y, e.z) : null;
+ }, r.prototype.setBodyMass = function(t, e) {
+ t.physicsBody.mass = e, t.physicsBody.updateMassProperties();
+ }, r.prototype.getBodyMass = function(t) {
+ return t.physicsBody.mass;
+ }, r.prototype.getBodyFriction = function(t) {
+ return t.physicsBody.material.friction;
+ }, r.prototype.setBodyFriction = function(t, e) {
+ t.physicsBody.material.friction = e;
+ }, r.prototype.getBodyRestitution = function(t) {
+ return t.physicsBody.material.restitution;
+ }, r.prototype.setBodyRestitution = function(t, e) {
+ t.physicsBody.material.restitution = e;
+ }, r.prototype.sleepBody = function(t) {
+ t.physicsBody.sleep();
+ }, r.prototype.wakeUpBody = function(t) {
+ t.physicsBody.wakeUp();
+ }, r.prototype.updateDistanceJoint = function(t, e) {
+ t.physicsJoint.distance = e;
+ }, r.prototype.setMotor = function(t, e, n, i) {
+ i || (t.physicsJoint.enableMotor(), t.physicsJoint.setMotorSpeed(e), n && this.setLimit(t, n));
+ }, r.prototype.setLimit = function(t, e, n) {
+ t.physicsJoint.motorEquation.maxForce = e, t.physicsJoint.motorEquation.minForce = n === void 0 ? -e : n;
+ }, r.prototype.syncMeshWithImpostor = function(t, e) {
+ var n = e.physicsBody;
+ t.position.x = n.position.x, t.position.y = n.position.y, t.position.z = n.position.z, t.rotationQuaternion && (t.rotationQuaternion.x = n.quaternion.x, t.rotationQuaternion.y = n.quaternion.y, t.rotationQuaternion.z = n.quaternion.z, t.rotationQuaternion.w = n.quaternion.w);
+ }, r.prototype.getRadius = function(t) {
+ return t.physicsBody.shapes[0].boundingSphereRadius;
+ }, r.prototype.getBoxSizeToRef = function(t, e) {
+ var n = t.physicsBody.shapes[0];
+ e.x = 2 * n.halfExtents.x, e.y = 2 * n.halfExtents.y, e.z = 2 * n.halfExtents.z;
+ }, r.prototype.dispose = function() {
+ }, r.prototype._extendNamespace = function() {
+ var t = new this.BJSCANNON.Vec3(), e = this.BJSCANNON;
+ this.BJSCANNON.World.prototype.step = function(n, i, o) {
+ if (o = o || 10, (i = i || 0) === 0)
+ this.internalStep(n), this.time += n;
+ else {
+ var a = Math.floor((this.time + i) / n) - Math.floor(this.time / n);
+ a = Math.min(a, o) || 1;
+ for (var s = performance.now(), d = 0; d !== a && (this.internalStep(n), !(performance.now() - s > 1e3 * n)); d++)
+ ;
+ this.time += i;
+ for (var p = this.time % n / n, y = t, P = this.bodies, R = 0; R !== P.length; R++) {
+ var B = P[R];
+ B.type !== e.Body.STATIC && B.sleepState !== e.Body.SLEEPING ? (B.position.vsub(B.previousPosition, y), y.scale(p, y), B.position.vadd(y, B.interpolatedPosition)) : (B.interpolatedPosition.set(B.position.x, B.position.y, B.position.z), B.interpolatedQuaternion.set(B.quaternion.x, B.quaternion.y, B.quaternion.z, B.quaternion.w));
+ }
+ }
+ };
+ }, r.prototype.raycast = function(t, e) {
+ return this._cannonRaycastResult.reset(), this.world.raycastClosest(t, e, {}, this._cannonRaycastResult), this._raycastResult.reset(t, e), this._cannonRaycastResult.hasHit && (this._raycastResult.setHitData({ x: this._cannonRaycastResult.hitNormalWorld.x, y: this._cannonRaycastResult.hitNormalWorld.y, z: this._cannonRaycastResult.hitNormalWorld.z }, { x: this._cannonRaycastResult.hitPointWorld.x, y: this._cannonRaycastResult.hitPointWorld.y, z: this._cannonRaycastResult.hitPointWorld.z }), this._raycastResult.setHitDistance(this._cannonRaycastResult.distance)), this._raycastResult;
+ }, r;
+ }();
+ Sr.DefaultPluginFactory = function() {
+ return new Bs();
+ };
+ var Mu = function() {
+ function r(t, e, n) {
+ t === void 0 && (t = !0), n === void 0 && (n = OIMO), this._useDeltaForWorldStep = t, this.name = "OimoJSPlugin", this._fixedTimeStep = 1 / 60, this._tmpImpostorsArray = [], this._tmpPositionVector = u.e.Zero(), this.BJSOIMO = n, this.world = new this.BJSOIMO.World({ iterations: e }), this.world.clear(), this._raycastResult = new Fs();
+ }
+ return r.prototype.setGravity = function(t) {
+ this.world.gravity.set(t.x, t.y, t.z);
+ }, r.prototype.setTimeStep = function(t) {
+ this.world.timeStep = t;
+ }, r.prototype.getTimeStep = function() {
+ return this.world.timeStep;
+ }, r.prototype.executeStep = function(t, e) {
+ var n = this;
+ e.forEach(function(s) {
+ s.beforeStep();
+ }), this.world.timeStep = this._useDeltaForWorldStep ? t : this._fixedTimeStep, this.world.step(), e.forEach(function(s) {
+ s.afterStep(), n._tmpImpostorsArray[s.uniqueId] = s;
+ });
+ for (var i = this.world.contacts; i !== null; )
+ if (!i.touching || i.body1.sleeping || i.body2.sleeping) {
+ var o = this._tmpImpostorsArray[+i.body1.name], a = this._tmpImpostorsArray[+i.body2.name];
+ o && a && (o.onCollide({ body: a.physicsBody, point: null }), a.onCollide({ body: o.physicsBody, point: null })), i = i.next;
+ } else
+ i = i.next;
+ }, r.prototype.applyImpulse = function(t, e, n) {
+ var i = t.physicsBody.mass;
+ t.physicsBody.applyImpulse(n.scale(this.world.invScale), e.scale(this.world.invScale * i));
+ }, r.prototype.applyForce = function(t, e, n) {
+ l.a.Warn("Oimo doesn't support applying force. Using impule instead."), this.applyImpulse(t, e, n);
+ }, r.prototype.generatePhysicsBody = function(t) {
+ var e = this;
+ if (t.parent)
+ t.physicsBody && (this.removePhysicsBody(t), t.forceUpdate());
+ else {
+ if (t.isBodyInitRequired()) {
+ var n = { name: t.uniqueId, config: [t.getParam("mass") || 1e-3, t.getParam("friction"), t.getParam("restitution")], size: [], type: [], pos: [], posShape: [], rot: [], rotShape: [], move: t.getParam("mass") !== 0, density: t.getParam("mass"), friction: t.getParam("friction"), restitution: t.getParam("restitution"), world: this.world }, i = [t];
+ (s = t.object).getChildMeshes && s.getChildMeshes().forEach(function(d) {
+ d.physicsImpostor && i.push(d.physicsImpostor);
+ });
+ var o = function(d) {
+ return Math.max(d, Sr.Epsilon);
+ }, a = new u.b();
+ i.forEach(function(d) {
+ if (d.object.rotationQuaternion) {
+ var p = d.object.rotationQuaternion;
+ a.copyFrom(p), d.object.rotationQuaternion.set(0, 0, 0, 1), d.object.computeWorldMatrix(!0);
+ var y = a.toEulerAngles(), P = d.getObjectExtendSize();
+ if (d === t) {
+ var R = t.getObjectCenter();
+ t.object.getAbsolutePivotPoint().subtractToRef(R, e._tmpPositionVector), e._tmpPositionVector.divideInPlace(t.object.scaling), n.pos.push(R.x), n.pos.push(R.y), n.pos.push(R.z), n.posShape.push(0, 0, 0), n.rotShape.push(0, 0, 0);
+ } else {
+ var B = d.object.position.clone();
+ n.posShape.push(B.x), n.posShape.push(B.y), n.posShape.push(B.z), n.rotShape.push(57.29577951308232 * y.x, 57.29577951308232 * y.y, 57.29577951308232 * y.z);
+ }
+ switch (d.object.rotationQuaternion.copyFrom(a), d.type) {
+ case At.a.ParticleImpostor:
+ l.a.Warn("No Particle support in OIMO.js. using SphereImpostor instead");
+ case At.a.SphereImpostor:
+ var F = P.x, z = P.y, J = P.z, ie = Math.max(o(F), o(z), o(J)) / 2;
+ n.type.push("sphere"), n.size.push(ie), n.size.push(ie), n.size.push(ie);
+ break;
+ case At.a.CylinderImpostor:
+ var se = o(P.x) / 2, ce = o(P.y);
+ n.type.push("cylinder"), n.size.push(se), n.size.push(ce), n.size.push(ce);
+ break;
+ case At.a.PlaneImpostor:
+ case At.a.BoxImpostor:
+ default:
+ se = o(P.x), ce = o(P.y);
+ var ue = o(P.z);
+ n.type.push("box"), n.size.push(se), n.size.push(ce), n.size.push(ue);
+ }
+ d.object.rotationQuaternion = p;
+ }
+ }), t.physicsBody = this.world.add(n), t.physicsBody.resetQuaternion(a), t.physicsBody.updatePosition(0);
+ } else
+ this._tmpPositionVector.copyFromFloats(0, 0, 0);
+ var s;
+ t.setDeltaPosition(this._tmpPositionVector);
+ }
+ }, r.prototype.removePhysicsBody = function(t) {
+ this.world.removeRigidBody(t.physicsBody);
+ }, r.prototype.generateJoint = function(t) {
+ var e = t.mainImpostor.physicsBody, n = t.connectedImpostor.physicsBody;
+ if (e && n) {
+ var i, o = t.joint.jointData, a = o.nativeParams || {}, s = { body1: e, body2: n, axe1: a.axe1 || (o.mainAxis ? o.mainAxis.asArray() : null), axe2: a.axe2 || (o.connectedAxis ? o.connectedAxis.asArray() : null), pos1: a.pos1 || (o.mainPivot ? o.mainPivot.asArray() : null), pos2: a.pos2 || (o.connectedPivot ? o.connectedPivot.asArray() : null), min: a.min, max: a.max, collision: a.collision || o.collision, spring: a.spring, world: this.world };
+ switch (t.joint.type) {
+ case Jt.e.BallAndSocketJoint:
+ i = "jointBall";
+ break;
+ case Jt.e.SpringJoint:
+ l.a.Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");
+ var d = o;
+ s.min = d.length || s.min, s.max = Math.max(s.min, s.max);
+ case Jt.e.DistanceJoint:
+ i = "jointDistance", s.max = o.maxDistance;
+ break;
+ case Jt.e.PrismaticJoint:
+ i = "jointPrisme";
+ break;
+ case Jt.e.SliderJoint:
+ i = "jointSlide";
+ break;
+ case Jt.e.WheelJoint:
+ i = "jointWheel";
+ break;
+ case Jt.e.HingeJoint:
+ default:
+ i = "jointHinge";
+ }
+ s.type = i, t.joint.physicsJoint = this.world.add(s);
+ }
+ }, r.prototype.removeJoint = function(t) {
+ try {
+ this.world.removeJoint(t.joint.physicsJoint);
+ } catch (e) {
+ l.a.Warn(e);
+ }
+ }, r.prototype.isSupported = function() {
+ return this.BJSOIMO !== void 0;
+ }, r.prototype.setTransformationFromPhysicsBody = function(t) {
+ if (!t.physicsBody.sleeping) {
+ if (t.physicsBody.shapes.next) {
+ for (var e = t.physicsBody.shapes; e.next; )
+ e = e.next;
+ t.object.position.set(e.position.x, e.position.y, e.position.z);
+ } else {
+ var n = t.physicsBody.getPosition();
+ t.object.position.set(n.x, n.y, n.z);
+ }
+ if (t.object.rotationQuaternion) {
+ var i = t.physicsBody.getQuaternion();
+ t.object.rotationQuaternion.set(i.x, i.y, i.z, i.w);
+ }
+ }
+ }, r.prototype.setPhysicsBodyTransformation = function(t, e, n) {
+ var i = t.physicsBody;
+ t.physicsBody.shapes.next || (i.position.set(e.x, e.y, e.z), i.orientation.set(n.x, n.y, n.z, n.w), i.syncShapes(), i.awake());
+ }, r.prototype.setLinearVelocity = function(t, e) {
+ t.physicsBody.linearVelocity.set(e.x, e.y, e.z);
+ }, r.prototype.setAngularVelocity = function(t, e) {
+ t.physicsBody.angularVelocity.set(e.x, e.y, e.z);
+ }, r.prototype.getLinearVelocity = function(t) {
+ var e = t.physicsBody.linearVelocity;
+ return e ? new u.e(e.x, e.y, e.z) : null;
+ }, r.prototype.getAngularVelocity = function(t) {
+ var e = t.physicsBody.angularVelocity;
+ return e ? new u.e(e.x, e.y, e.z) : null;
+ }, r.prototype.setBodyMass = function(t, e) {
+ var n = e === 0;
+ t.physicsBody.shapes.density = n ? 1 : e, t.physicsBody.setupMass(n ? 2 : 1);
+ }, r.prototype.getBodyMass = function(t) {
+ return t.physicsBody.shapes.density;
+ }, r.prototype.getBodyFriction = function(t) {
+ return t.physicsBody.shapes.friction;
+ }, r.prototype.setBodyFriction = function(t, e) {
+ t.physicsBody.shapes.friction = e;
+ }, r.prototype.getBodyRestitution = function(t) {
+ return t.physicsBody.shapes.restitution;
+ }, r.prototype.setBodyRestitution = function(t, e) {
+ t.physicsBody.shapes.restitution = e;
+ }, r.prototype.sleepBody = function(t) {
+ t.physicsBody.sleep();
+ }, r.prototype.wakeUpBody = function(t) {
+ t.physicsBody.awake();
+ }, r.prototype.updateDistanceJoint = function(t, e, n) {
+ t.physicsJoint.limitMotor.upperLimit = e, n !== void 0 && (t.physicsJoint.limitMotor.lowerLimit = n);
+ }, r.prototype.setMotor = function(t, e, n, i) {
+ n !== void 0 ? l.a.Warn("OimoJS plugin currently has unexpected behavior when using setMotor with force parameter") : n = 1e6, e *= -1;
+ var o = i ? t.physicsJoint.rotationalLimitMotor2 : t.physicsJoint.rotationalLimitMotor1 || t.physicsJoint.rotationalLimitMotor || t.physicsJoint.limitMotor;
+ o && o.setMotor(e, n);
+ }, r.prototype.setLimit = function(t, e, n, i) {
+ var o = i ? t.physicsJoint.rotationalLimitMotor2 : t.physicsJoint.rotationalLimitMotor1 || t.physicsJoint.rotationalLimitMotor || t.physicsJoint.limitMotor;
+ o && o.setLimit(e, n === void 0 ? -e : n);
+ }, r.prototype.syncMeshWithImpostor = function(t, e) {
+ var n = e.physicsBody;
+ t.position.x = n.position.x, t.position.y = n.position.y, t.position.z = n.position.z, t.rotationQuaternion && (t.rotationQuaternion.x = n.orientation.x, t.rotationQuaternion.y = n.orientation.y, t.rotationQuaternion.z = n.orientation.z, t.rotationQuaternion.w = n.orientation.s);
+ }, r.prototype.getRadius = function(t) {
+ return t.physicsBody.shapes.radius;
+ }, r.prototype.getBoxSizeToRef = function(t, e) {
+ var n = t.physicsBody.shapes;
+ e.x = 2 * n.halfWidth, e.y = 2 * n.halfHeight, e.z = 2 * n.halfDepth;
+ }, r.prototype.dispose = function() {
+ this.world.clear();
+ }, r.prototype.raycast = function(t, e) {
+ return l.a.Warn("raycast is not currently supported by the Oimo physics plugin"), this._raycastResult.reset(t, e), this._raycastResult;
+ }, r;
+ }(), Jo = f(97), Iu = function() {
+ function r(t, e, n) {
+ var i = this;
+ t === void 0 && (t = !0), e === void 0 && (e = Ammo), n === void 0 && (n = null), this._useDeltaForWorldStep = t, this.bjsAMMO = {}, this.name = "AmmoJSPlugin", this._timeStep = 1 / 60, this._fixedTimeStep = 1 / 60, this._maxSteps = 5, this._tmpQuaternion = new u.b(), this._tmpContactCallbackResult = !1, this._tmpContactPoint = new u.e(), this._tmpMatrix = new u.a(), typeof e == "function" ? e(this.bjsAMMO) : this.bjsAMMO = e, this.isSupported() ? (this._collisionConfiguration = new this.bjsAMMO.btSoftBodyRigidBodyCollisionConfiguration(), this._dispatcher = new this.bjsAMMO.btCollisionDispatcher(this._collisionConfiguration), this._overlappingPairCache = n || new this.bjsAMMO.btDbvtBroadphase(), this._solver = new this.bjsAMMO.btSequentialImpulseConstraintSolver(), this._softBodySolver = new this.bjsAMMO.btDefaultSoftBodySolver(), this.world = new this.bjsAMMO.btSoftRigidDynamicsWorld(this._dispatcher, this._overlappingPairCache, this._solver, this._collisionConfiguration, this._softBodySolver), this._tmpAmmoConcreteContactResultCallback = new this.bjsAMMO.ConcreteContactResultCallback(), this._tmpAmmoConcreteContactResultCallback.addSingleResult = function(o, a, s, d) {
+ var p = (o = i.bjsAMMO.wrapPointer(o, Ammo.btManifoldPoint)).getPositionWorldOnA();
+ i._tmpContactPoint.x = p.x(), i._tmpContactPoint.y = p.y(), i._tmpContactPoint.z = p.z(), i._tmpContactCallbackResult = !0;
+ }, this._raycastResult = new Fs(), this._tmpAmmoTransform = new this.bjsAMMO.btTransform(), this._tmpAmmoTransform.setIdentity(), this._tmpAmmoQuaternion = new this.bjsAMMO.btQuaternion(0, 0, 0, 1), this._tmpAmmoVectorA = new this.bjsAMMO.btVector3(0, 0, 0), this._tmpAmmoVectorB = new this.bjsAMMO.btVector3(0, 0, 0), this._tmpAmmoVectorC = new this.bjsAMMO.btVector3(0, 0, 0), this._tmpAmmoVectorD = new this.bjsAMMO.btVector3(0, 0, 0)) : l.a.Error("AmmoJS is not available. Please make sure you included the js file.");
+ }
+ return r.prototype.setGravity = function(t) {
+ this._tmpAmmoVectorA.setValue(t.x, t.y, t.z), this.world.setGravity(this._tmpAmmoVectorA), this.world.getWorldInfo().set_m_gravity(this._tmpAmmoVectorA);
+ }, r.prototype.setTimeStep = function(t) {
+ this._timeStep = t;
+ }, r.prototype.setFixedTimeStep = function(t) {
+ this._fixedTimeStep = t;
+ }, r.prototype.setMaxSteps = function(t) {
+ this._maxSteps = t;
+ }, r.prototype.getTimeStep = function() {
+ return this._timeStep;
+ }, r.prototype._isImpostorInContact = function(t) {
+ return this._tmpContactCallbackResult = !1, this.world.contactTest(t.physicsBody, this._tmpAmmoConcreteContactResultCallback), this._tmpContactCallbackResult;
+ }, r.prototype._isImpostorPairInContact = function(t, e) {
+ return this._tmpContactCallbackResult = !1, this.world.contactPairTest(t.physicsBody, e.physicsBody, this._tmpAmmoConcreteContactResultCallback), this._tmpContactCallbackResult;
+ }, r.prototype._stepSimulation = function(t, e, n) {
+ if (t === void 0 && (t = 1 / 60), e === void 0 && (e = 10), n === void 0 && (n = 1 / 60), e == 0)
+ this.world.stepSimulation(t, 0);
+ else
+ for (; e > 0 && t > 0; )
+ t - n < n ? (this.world.stepSimulation(t, 0), t = 0) : (t -= n, this.world.stepSimulation(n, 0)), e--;
+ }, r.prototype.executeStep = function(t, e) {
+ for (var n = 0, i = e; n < i.length; n++) {
+ var o = i[n];
+ o.soft || o.beforeStep();
+ }
+ this._stepSimulation(this._useDeltaForWorldStep ? t : this._timeStep, this._maxSteps, this._fixedTimeStep);
+ for (var a = 0, s = e; a < s.length; a++) {
+ var d = s[a];
+ if (d.soft ? this._afterSoftStep(d) : d.afterStep(), d._onPhysicsCollideCallbacks.length > 0 && this._isImpostorInContact(d))
+ for (var p = 0, y = d._onPhysicsCollideCallbacks; p < y.length; p++)
+ for (var P = 0, R = y[p].otherImpostors; P < R.length; P++) {
+ var B = R[P];
+ (d.physicsBody.isActive() || B.physicsBody.isActive()) && this._isImpostorPairInContact(d, B) && (d.onCollide({ body: B.physicsBody, point: this._tmpContactPoint }), B.onCollide({ body: d.physicsBody, point: this._tmpContactPoint }));
+ }
+ }
+ }, r.prototype._afterSoftStep = function(t) {
+ t.type === At.a.RopeImpostor ? this._ropeStep(t) : this._softbodyOrClothStep(t);
+ }, r.prototype._ropeStep = function(t) {
+ for (var e, n, i, o, a = t.physicsBody.get_m_nodes(), s = a.size(), d = new Array(), p = 0; p < s; p++)
+ n = (e = a.at(p).get_m_x()).x(), i = e.y(), o = e.z(), d.push(new u.e(n, i, o));
+ var y = t.object, P = t.getParam("shape");
+ t._isFromLine ? t.object = sn.a.CreateLines("lines", { points: d, instance: y }) : t.object = Jo.a.ExtrudeShape("ext", { shape: P, path: d, instance: y });
+ }, r.prototype._softbodyOrClothStep = function(t) {
+ var e = t.type === At.a.ClothImpostor ? 1 : -1, n = t.object, i = n.getVerticesData(Oe.b.PositionKind);
+ i || (i = []);
+ var o = n.getVerticesData(Oe.b.NormalKind);
+ o || (o = []);
+ for (var a, s, d, p, y, P, R, B, F = i.length / 3, z = t.physicsBody.get_m_nodes(), J = 0; J < F; J++) {
+ var ie;
+ d = (s = (a = z.at(J)).get_m_x()).x(), p = s.y(), y = s.z() * e, P = (ie = a.get_m_n()).x(), R = ie.y(), B = ie.z() * e, i[3 * J] = d, i[3 * J + 1] = p, i[3 * J + 2] = y, o[3 * J] = P, o[3 * J + 1] = R, o[3 * J + 2] = B;
+ }
+ var se = new ht.a();
+ se.positions = i, se.normals = o, se.uvs = n.getVerticesData(Oe.b.UVKind), se.colors = n.getVerticesData(Oe.b.ColorKind), n && n.getIndices && (se.indices = n.getIndices()), se.applyToMesh(n);
+ }, r.prototype.applyImpulse = function(t, e, n) {
+ if (t.soft)
+ l.a.Warn("Cannot be applied to a soft body");
+ else {
+ t.physicsBody.activate();
+ var i = this._tmpAmmoVectorA, o = this._tmpAmmoVectorB;
+ t.object && t.object.getWorldMatrix && n.subtractInPlace(t.object.getWorldMatrix().getTranslation()), i.setValue(n.x, n.y, n.z), o.setValue(e.x, e.y, e.z), t.physicsBody.applyImpulse(o, i);
+ }
+ }, r.prototype.applyForce = function(t, e, n) {
+ if (t.soft)
+ l.a.Warn("Cannot be applied to a soft body");
+ else {
+ t.physicsBody.activate();
+ var i = this._tmpAmmoVectorA, o = this._tmpAmmoVectorB;
+ t.object && t.object.getWorldMatrix && n.subtractInPlace(t.object.getWorldMatrix().getTranslation()), i.setValue(n.x, n.y, n.z), o.setValue(e.x, e.y, e.z), t.physicsBody.applyForce(o, i);
+ }
+ }, r.prototype.generatePhysicsBody = function(t) {
+ if (t._pluginData.toDispose = [], t.parent)
+ t.physicsBody && (this.removePhysicsBody(t), t.forceUpdate());
+ else if (t.isBodyInitRequired()) {
+ var e = this._createShape(t), n = t.getParam("mass");
+ if (t._pluginData.mass = n, t.soft)
+ e.get_m_cfg().set_collisions(17), e.get_m_cfg().set_kDP(t.getParam("damping")), this.bjsAMMO.castObject(e, this.bjsAMMO.btCollisionObject).getCollisionShape().setMargin(t.getParam("margin")), e.setActivationState(r.DISABLE_DEACTIVATION_FLAG), this.world.addSoftBody(e, 1, -1), t.physicsBody = e, t._pluginData.toDispose.push(e), this.setBodyPressure(t, 0), t.type === At.a.SoftbodyImpostor && this.setBodyPressure(t, t.getParam("pressure")), this.setBodyStiffness(t, t.getParam("stiffness")), this.setBodyVelocityIterations(t, t.getParam("velocityIterations")), this.setBodyPositionIterations(t, t.getParam("positionIterations"));
+ else {
+ var i = new this.bjsAMMO.btVector3(0, 0, 0), o = new this.bjsAMMO.btTransform();
+ o.setIdentity(), n !== 0 && e.calculateLocalInertia(n, i), this._tmpAmmoVectorA.setValue(t.object.position.x, t.object.position.y, t.object.position.z), this._tmpAmmoQuaternion.setValue(t.object.rotationQuaternion.x, t.object.rotationQuaternion.y, t.object.rotationQuaternion.z, t.object.rotationQuaternion.w), o.setOrigin(this._tmpAmmoVectorA), o.setRotation(this._tmpAmmoQuaternion);
+ var a = new this.bjsAMMO.btDefaultMotionState(o), s = new this.bjsAMMO.btRigidBodyConstructionInfo(n, a, e, i), d = new this.bjsAMMO.btRigidBody(s);
+ n === 0 && (d.setCollisionFlags(d.getCollisionFlags() | r.KINEMATIC_FLAG), d.setActivationState(r.DISABLE_DEACTIVATION_FLAG)), t.type != At.a.NoImpostor || e.getChildShape || d.setCollisionFlags(d.getCollisionFlags() | r.DISABLE_COLLISION_FLAG);
+ var p = t.getParam("group"), y = t.getParam("mask");
+ p && y ? this.world.addRigidBody(d, p, y) : this.world.addRigidBody(d), t.physicsBody = d, t._pluginData.toDispose = t._pluginData.toDispose.concat([d, s, a, o, i, e]);
+ }
+ this.setBodyRestitution(t, t.getParam("restitution")), this.setBodyFriction(t, t.getParam("friction"));
+ }
+ }, r.prototype.removePhysicsBody = function(t) {
+ var e = this;
+ this.world && (t.soft ? this.world.removeSoftBody(t.physicsBody) : this.world.removeRigidBody(t.physicsBody), t._pluginData && (t._pluginData.toDispose.forEach(function(n) {
+ e.bjsAMMO.destroy(n);
+ }), t._pluginData.toDispose = []));
+ }, r.prototype.generateJoint = function(t) {
+ var e = t.mainImpostor.physicsBody, n = t.connectedImpostor.physicsBody;
+ if (e && n) {
+ var i, o = t.joint.jointData;
+ switch (o.mainPivot || (o.mainPivot = new u.e(0, 0, 0)), o.connectedPivot || (o.connectedPivot = new u.e(0, 0, 0)), t.joint.type) {
+ case Jt.e.DistanceJoint:
+ var a = o.maxDistance;
+ a && (o.mainPivot = new u.e(0, -a / 2, 0), o.connectedPivot = new u.e(0, a / 2, 0)), i = new this.bjsAMMO.btPoint2PointConstraint(e, n, new this.bjsAMMO.btVector3(o.mainPivot.x, o.mainPivot.y, o.mainPivot.z), new this.bjsAMMO.btVector3(o.connectedPivot.x, o.connectedPivot.y, o.connectedPivot.z));
+ break;
+ case Jt.e.HingeJoint:
+ o.mainAxis || (o.mainAxis = new u.e(0, 0, 0)), o.connectedAxis || (o.connectedAxis = new u.e(0, 0, 0));
+ var s = new this.bjsAMMO.btVector3(o.mainAxis.x, o.mainAxis.y, o.mainAxis.z), d = new this.bjsAMMO.btVector3(o.connectedAxis.x, o.connectedAxis.y, o.connectedAxis.z);
+ i = new this.bjsAMMO.btHingeConstraint(e, n, new this.bjsAMMO.btVector3(o.mainPivot.x, o.mainPivot.y, o.mainPivot.z), new this.bjsAMMO.btVector3(o.connectedPivot.x, o.connectedPivot.y, o.connectedPivot.z), s, d);
+ break;
+ case Jt.e.BallAndSocketJoint:
+ i = new this.bjsAMMO.btPoint2PointConstraint(e, n, new this.bjsAMMO.btVector3(o.mainPivot.x, o.mainPivot.y, o.mainPivot.z), new this.bjsAMMO.btVector3(o.connectedPivot.x, o.connectedPivot.y, o.connectedPivot.z));
+ break;
+ default:
+ l.a.Warn("JointType not currently supported by the Ammo plugin, falling back to PhysicsJoint.BallAndSocketJoint"), i = new this.bjsAMMO.btPoint2PointConstraint(e, n, new this.bjsAMMO.btVector3(o.mainPivot.x, o.mainPivot.y, o.mainPivot.z), new this.bjsAMMO.btVector3(o.connectedPivot.x, o.connectedPivot.y, o.connectedPivot.z));
+ }
+ this.world.addConstraint(i, !t.joint.jointData.collision), t.joint.physicsJoint = i;
+ }
+ }, r.prototype.removeJoint = function(t) {
+ this.world && this.world.removeConstraint(t.joint.physicsJoint);
+ }, r.prototype._addMeshVerts = function(t, e, n) {
+ var i = this, o = 0;
+ if (n && n.getIndices && n.getWorldMatrix && n.getChildMeshes) {
+ var a = n.getIndices();
+ a || (a = []);
+ var s = n.getVerticesData(Oe.b.PositionKind);
+ s || (s = []), n.computeWorldMatrix(!1);
+ for (var d = a.length / 3, p = 0; p < d; p++) {
+ for (var y = [], P = 0; P < 3; P++) {
+ var R, B = new u.e(s[3 * a[3 * p + P] + 0], s[3 * a[3 * p + P] + 1], s[3 * a[3 * p + P] + 2]);
+ u.a.ScalingToRef(n.scaling.x, n.scaling.y, n.scaling.z, this._tmpMatrix), B = u.e.TransformCoordinates(B, this._tmpMatrix), (R = P == 0 ? this._tmpAmmoVectorA : P == 1 ? this._tmpAmmoVectorB : this._tmpAmmoVectorC).setValue(B.x, B.y, B.z), y.push(R);
+ }
+ t.addTriangle(y[0], y[1], y[2]), o++;
+ }
+ n.getChildMeshes().forEach(function(F) {
+ o += i._addMeshVerts(t, e, F);
+ });
+ }
+ return o;
+ }, r.prototype._softVertexData = function(t) {
+ var e = t.object;
+ if (e && e.getIndices && e.getWorldMatrix && e.getChildMeshes) {
+ e.getIndices();
+ var n = e.getVerticesData(Oe.b.PositionKind);
+ n || (n = []);
+ var i = e.getVerticesData(Oe.b.NormalKind);
+ i || (i = []), e.computeWorldMatrix(!1);
+ for (var o = [], a = [], s = 0; s < n.length; s += 3) {
+ var d = new u.e(n[s], n[s + 1], n[s + 2]), p = new u.e(i[s], i[s + 1], i[s + 2]);
+ d = u.e.TransformCoordinates(d, e.getWorldMatrix()), p = u.e.TransformNormal(p, e.getWorldMatrix()), o.push(d.x, d.y, d.z), a.push(p.x, p.y, p.z);
+ }
+ var y = new ht.a();
+ return y.positions = o, y.normals = a, y.uvs = e.getVerticesData(Oe.b.UVKind), y.colors = e.getVerticesData(Oe.b.ColorKind), e && e.getIndices && (y.indices = e.getIndices()), y.applyToMesh(e), e.position = u.e.Zero(), e.rotationQuaternion = null, e.rotation = u.e.Zero(), e.computeWorldMatrix(!0), y;
+ }
+ return ht.a.ExtractFromMesh(e);
+ }, r.prototype._createSoftbody = function(t) {
+ var e = t.object;
+ if (e && e.getIndices) {
+ var n = e.getIndices();
+ n || (n = []);
+ var i = this._softVertexData(t), o = i.positions, a = i.normals;
+ if (o === null || a === null)
+ return new this.bjsAMMO.btCompoundShape();
+ for (var s = [], d = [], p = 0; p < o.length; p += 3) {
+ var y = new u.e(o[p], o[p + 1], o[p + 2]), P = new u.e(a[p], a[p + 1], a[p + 2]);
+ s.push(y.x, y.y, -y.z), d.push(P.x, P.y, -P.z);
+ }
+ var R = new this.bjsAMMO.btSoftBodyHelpers().CreateFromTriMesh(this.world.getWorldInfo(), s, e.getIndices(), n.length / 3, !0), B = o.length / 3, F = R.get_m_nodes();
+ for (p = 0; p < B; p++) {
+ var z;
+ (z = F.at(p).get_m_n()).setX(d[3 * p]), z.setY(d[3 * p + 1]), z.setZ(d[3 * p + 2]);
+ }
+ return R;
+ }
+ }, r.prototype._createCloth = function(t) {
+ var e = t.object;
+ if (e && e.getIndices) {
+ e.getIndices();
+ var n = this._softVertexData(t), i = n.positions, o = n.normals;
+ if (i === null || o === null)
+ return new this.bjsAMMO.btCompoundShape();
+ var a = i.length, s = Math.sqrt(a / 3);
+ t.segments = s;
+ var d = s - 1;
+ return this._tmpAmmoVectorA.setValue(i[0], i[1], i[2]), this._tmpAmmoVectorB.setValue(i[3 * d], i[3 * d + 1], i[3 * d + 2]), this._tmpAmmoVectorD.setValue(i[a - 3], i[a - 2], i[a - 1]), this._tmpAmmoVectorC.setValue(i[a - 3 - 3 * d], i[a - 2 - 3 * d], i[a - 1 - 3 * d]), new this.bjsAMMO.btSoftBodyHelpers().CreatePatch(this.world.getWorldInfo(), this._tmpAmmoVectorA, this._tmpAmmoVectorB, this._tmpAmmoVectorC, this._tmpAmmoVectorD, s, s, t.getParam("fixedPoints"), !0);
+ }
+ }, r.prototype._createRope = function(t) {
+ var e, n, i = this._softVertexData(t), o = i.positions, a = i.normals;
+ if (o === null || a === null)
+ return new this.bjsAMMO.btCompoundShape();
+ if (i.applyToMesh(t.object, !0), t._isFromLine = !0, a.map(function(y) {
+ return y * y;
+ }).reduce(function(y, P) {
+ return y + P;
+ }) === 0)
+ n = (e = o.length) / 3 - 1, this._tmpAmmoVectorA.setValue(o[0], o[1], o[2]), this._tmpAmmoVectorB.setValue(o[e - 3], o[e - 2], o[e - 1]);
+ else {
+ t._isFromLine = !1;
+ var s = t.getParam("path");
+ if (t.getParam("shape") === null)
+ return l.a.Warn("No shape available for extruded mesh"), new this.bjsAMMO.btCompoundShape();
+ if (o.length % (3 * s.length) != 0)
+ return l.a.Warn("Path does not match extrusion"), new this.bjsAMMO.btCompoundShape();
+ n = (e = s.length) - 1, this._tmpAmmoVectorA.setValue(s[0].x, s[0].y, s[0].z), this._tmpAmmoVectorB.setValue(s[e - 1].x, s[e - 1].y, s[e - 1].z);
+ }
+ t.segments = n;
+ var d = t.getParam("fixedPoints");
+ d = d > 3 ? 3 : d;
+ var p = new this.bjsAMMO.btSoftBodyHelpers().CreateRope(this.world.getWorldInfo(), this._tmpAmmoVectorA, this._tmpAmmoVectorB, n - 1, d);
+ return p.get_m_cfg().set_collisions(17), p;
+ }, r.prototype._createCustom = function(t) {
+ var e = null;
+ return this.onCreateCustomShape && (e = this.onCreateCustomShape(t)), e == null && (e = new this.bjsAMMO.btCompoundShape()), e;
+ }, r.prototype._addHullVerts = function(t, e, n) {
+ var i = this, o = 0;
+ if (n && n.getIndices && n.getWorldMatrix && n.getChildMeshes) {
+ var a = n.getIndices();
+ a || (a = []);
+ var s = n.getVerticesData(Oe.b.PositionKind);
+ s || (s = []), n.computeWorldMatrix(!1);
+ for (var d = a.length / 3, p = 0; p < d; p++) {
+ for (var y = [], P = 0; P < 3; P++) {
+ var R, B = new u.e(s[3 * a[3 * p + P] + 0], s[3 * a[3 * p + P] + 1], s[3 * a[3 * p + P] + 2]);
+ u.a.ScalingToRef(n.scaling.x, n.scaling.y, n.scaling.z, this._tmpMatrix), B = u.e.TransformCoordinates(B, this._tmpMatrix), (R = P == 0 ? this._tmpAmmoVectorA : P == 1 ? this._tmpAmmoVectorB : this._tmpAmmoVectorC).setValue(B.x, B.y, B.z), y.push(R);
+ }
+ t.addPoint(y[0], !0), t.addPoint(y[1], !0), t.addPoint(y[2], !0), o++;
+ }
+ n.getChildMeshes().forEach(function(F) {
+ o += i._addHullVerts(t, e, F);
+ });
+ }
+ return o;
+ }, r.prototype._createShape = function(t, e) {
+ var n = this;
+ e === void 0 && (e = !1);
+ var i, o = t.object, a = t.getObjectExtendSize();
+ if (!e) {
+ var s = t.object.getChildMeshes ? t.object.getChildMeshes(!0) : [];
+ i = new this.bjsAMMO.btCompoundShape();
+ var d = 0;
+ if (s.forEach(function(F) {
+ var z = F.getPhysicsImpostor();
+ if (z) {
+ if (z.type == At.a.MeshImpostor)
+ throw "A child MeshImpostor is not supported. Only primitive impostors are supported as children (eg. box or sphere)";
+ var J = n._createShape(z), ie = F.parent.getWorldMatrix().clone(), se = new u.e();
+ ie.decompose(se), n._tmpAmmoTransform.getOrigin().setValue(F.position.x * se.x, F.position.y * se.y, F.position.z * se.z), n._tmpAmmoQuaternion.setValue(F.rotationQuaternion.x, F.rotationQuaternion.y, F.rotationQuaternion.z, F.rotationQuaternion.w), n._tmpAmmoTransform.setRotation(n._tmpAmmoQuaternion), i.addChildShape(n._tmpAmmoTransform, J), z.dispose(), d++;
+ }
+ }), d > 0) {
+ if (t.type != At.a.NoImpostor) {
+ var p = this._createShape(t, !0);
+ p && (this._tmpAmmoTransform.getOrigin().setValue(0, 0, 0), this._tmpAmmoQuaternion.setValue(0, 0, 0, 1), this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion), i.addChildShape(this._tmpAmmoTransform, p));
+ }
+ return i;
+ }
+ this.bjsAMMO.destroy(i), i = null;
+ }
+ switch (t.type) {
+ case At.a.SphereImpostor:
+ if ($.a.WithinEpsilon(a.x, a.y, 1e-4) && $.a.WithinEpsilon(a.x, a.z, 1e-4))
+ i = new this.bjsAMMO.btSphereShape(a.x / 2);
+ else {
+ var y = [new this.bjsAMMO.btVector3(0, 0, 0)];
+ (i = new this.bjsAMMO.btMultiSphereShape(y, [1], 1)).setLocalScaling(new this.bjsAMMO.btVector3(a.x / 2, a.y / 2, a.z / 2));
+ }
+ break;
+ case At.a.CapsuleImpostor:
+ i = new this.bjsAMMO.btCapsuleShape(a.x / 2, a.y / 2);
+ break;
+ case At.a.CylinderImpostor:
+ this._tmpAmmoVectorA.setValue(a.x / 2, a.y / 2, a.z / 2), i = new this.bjsAMMO.btCylinderShape(this._tmpAmmoVectorA);
+ break;
+ case At.a.PlaneImpostor:
+ case At.a.BoxImpostor:
+ this._tmpAmmoVectorA.setValue(a.x / 2, a.y / 2, a.z / 2), i = new this.bjsAMMO.btBoxShape(this._tmpAmmoVectorA);
+ break;
+ case At.a.MeshImpostor:
+ if (t.getParam("mass") == 0) {
+ var P = new this.bjsAMMO.btTriangleMesh();
+ t._pluginData.toDispose.push(P);
+ var R = this._addMeshVerts(P, o, o);
+ i = R == 0 ? new this.bjsAMMO.btCompoundShape() : new this.bjsAMMO.btBvhTriangleMeshShape(P);
+ break;
+ }
+ case At.a.ConvexHullImpostor:
+ var B = new this.bjsAMMO.btConvexHullShape();
+ (R = this._addHullVerts(B, o, o)) == 0 ? (t._pluginData.toDispose.push(B), i = new this.bjsAMMO.btCompoundShape()) : i = B;
+ break;
+ case At.a.NoImpostor:
+ i = new this.bjsAMMO.btSphereShape(a.x / 2);
+ break;
+ case At.a.CustomImpostor:
+ i = this._createCustom(t);
+ break;
+ case At.a.SoftbodyImpostor:
+ i = this._createSoftbody(t);
+ break;
+ case At.a.ClothImpostor:
+ i = this._createCloth(t);
+ break;
+ case At.a.RopeImpostor:
+ i = this._createRope(t);
+ break;
+ default:
+ l.a.Warn("The impostor type is not currently supported by the ammo plugin.");
+ }
+ return i;
+ }, r.prototype.setTransformationFromPhysicsBody = function(t) {
+ t.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform), t.object.position.set(this._tmpAmmoTransform.getOrigin().x(), this._tmpAmmoTransform.getOrigin().y(), this._tmpAmmoTransform.getOrigin().z()), t.object.rotationQuaternion ? t.object.rotationQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w()) : t.object.rotation && (this._tmpQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w()), this._tmpQuaternion.toEulerAnglesToRef(t.object.rotation));
+ }, r.prototype.setPhysicsBodyTransformation = function(t, e, n) {
+ var i = t.physicsBody.getWorldTransform();
+ if (Math.abs(i.getOrigin().x() - e.x) > Vt.a || Math.abs(i.getOrigin().y() - e.y) > Vt.a || Math.abs(i.getOrigin().z() - e.z) > Vt.a || Math.abs(i.getRotation().x() - n.x) > Vt.a || Math.abs(i.getRotation().y() - n.y) > Vt.a || Math.abs(i.getRotation().z() - n.z) > Vt.a || Math.abs(i.getRotation().w() - n.w) > Vt.a)
+ if (this._tmpAmmoVectorA.setValue(e.x, e.y, e.z), i.setOrigin(this._tmpAmmoVectorA), this._tmpAmmoQuaternion.setValue(n.x, n.y, n.z, n.w), i.setRotation(this._tmpAmmoQuaternion), t.physicsBody.setWorldTransform(i), t.mass == 0) {
+ var o = t.physicsBody.getMotionState();
+ o && o.setWorldTransform(i);
+ } else
+ t.physicsBody.activate();
+ }, r.prototype.isSupported = function() {
+ return this.bjsAMMO !== void 0;
+ }, r.prototype.setLinearVelocity = function(t, e) {
+ this._tmpAmmoVectorA.setValue(e.x, e.y, e.z), t.soft ? t.physicsBody.linearVelocity(this._tmpAmmoVectorA) : t.physicsBody.setLinearVelocity(this._tmpAmmoVectorA);
+ }, r.prototype.setAngularVelocity = function(t, e) {
+ this._tmpAmmoVectorA.setValue(e.x, e.y, e.z), t.soft ? t.physicsBody.angularVelocity(this._tmpAmmoVectorA) : t.physicsBody.setAngularVelocity(this._tmpAmmoVectorA);
+ }, r.prototype.getLinearVelocity = function(t) {
+ if (t.soft)
+ var e = t.physicsBody.linearVelocity();
+ else
+ e = t.physicsBody.getLinearVelocity();
+ if (!e)
+ return null;
+ var n = new u.e(e.x(), e.y(), e.z());
+ return this.bjsAMMO.destroy(e), n;
+ }, r.prototype.getAngularVelocity = function(t) {
+ if (t.soft)
+ var e = t.physicsBody.angularVelocity();
+ else
+ e = t.physicsBody.getAngularVelocity();
+ if (!e)
+ return null;
+ var n = new u.e(e.x(), e.y(), e.z());
+ return this.bjsAMMO.destroy(e), n;
+ }, r.prototype.setBodyMass = function(t, e) {
+ t.soft ? t.physicsBody.setTotalMass(e, !1) : t.physicsBody.setMassProps(e), t._pluginData.mass = e;
+ }, r.prototype.getBodyMass = function(t) {
+ return t._pluginData.mass || 0;
+ }, r.prototype.getBodyFriction = function(t) {
+ return t._pluginData.friction || 0;
+ }, r.prototype.setBodyFriction = function(t, e) {
+ t.soft ? t.physicsBody.get_m_cfg().set_kDF(e) : t.physicsBody.setFriction(e), t._pluginData.friction = e;
+ }, r.prototype.getBodyRestitution = function(t) {
+ return t._pluginData.restitution || 0;
+ }, r.prototype.setBodyRestitution = function(t, e) {
+ t.physicsBody.setRestitution(e), t._pluginData.restitution = e;
+ }, r.prototype.getBodyPressure = function(t) {
+ return t.soft ? t._pluginData.pressure || 0 : (l.a.Warn("Pressure is not a property of a rigid body"), 0);
+ }, r.prototype.setBodyPressure = function(t, e) {
+ t.soft ? t.type === At.a.SoftbodyImpostor ? (t.physicsBody.get_m_cfg().set_kPR(e), t._pluginData.pressure = e) : (t.physicsBody.get_m_cfg().set_kPR(0), t._pluginData.pressure = 0) : l.a.Warn("Pressure can only be applied to a softbody");
+ }, r.prototype.getBodyStiffness = function(t) {
+ return t.soft ? t._pluginData.stiffness || 0 : (l.a.Warn("Stiffness is not a property of a rigid body"), 0);
+ }, r.prototype.setBodyStiffness = function(t, e) {
+ t.soft ? (e = (e = e < 0 ? 0 : e) > 1 ? 1 : e, t.physicsBody.get_m_materials().at(0).set_m_kLST(e), t._pluginData.stiffness = e) : l.a.Warn("Stiffness cannot be applied to a rigid body");
+ }, r.prototype.getBodyVelocityIterations = function(t) {
+ return t.soft ? t._pluginData.velocityIterations || 0 : (l.a.Warn("Velocity iterations is not a property of a rigid body"), 0);
+ }, r.prototype.setBodyVelocityIterations = function(t, e) {
+ t.soft ? (e = e < 0 ? 0 : e, t.physicsBody.get_m_cfg().set_viterations(e), t._pluginData.velocityIterations = e) : l.a.Warn("Velocity iterations cannot be applied to a rigid body");
+ }, r.prototype.getBodyPositionIterations = function(t) {
+ return t.soft ? t._pluginData.positionIterations || 0 : (l.a.Warn("Position iterations is not a property of a rigid body"), 0);
+ }, r.prototype.setBodyPositionIterations = function(t, e) {
+ t.soft ? (e = e < 0 ? 0 : e, t.physicsBody.get_m_cfg().set_piterations(e), t._pluginData.positionIterations = e) : l.a.Warn("Position iterations cannot be applied to a rigid body");
+ }, r.prototype.appendAnchor = function(t, e, n, i, o, a) {
+ o === void 0 && (o = 1), a === void 0 && (a = !1);
+ var s = t.segments, d = Math.round((s - 1) * n) + s * (s - 1 - Math.round((s - 1) * i));
+ t.physicsBody.appendAnchor(d, e.physicsBody, a, o);
+ }, r.prototype.appendHook = function(t, e, n, i, o) {
+ i === void 0 && (i = 1), o === void 0 && (o = !1);
+ var a = Math.round(t.segments * n);
+ t.physicsBody.appendAnchor(a, e.physicsBody, o, i);
+ }, r.prototype.sleepBody = function(t) {
+ l.a.Warn("sleepBody is not currently supported by the Ammo physics plugin");
+ }, r.prototype.wakeUpBody = function(t) {
+ t.physicsBody.activate();
+ }, r.prototype.updateDistanceJoint = function(t, e, n) {
+ l.a.Warn("updateDistanceJoint is not currently supported by the Ammo physics plugin");
+ }, r.prototype.setMotor = function(t, e, n, i) {
+ t.physicsJoint.enableAngularMotor(!0, e, n);
+ }, r.prototype.setLimit = function(t, e, n) {
+ l.a.Warn("setLimit is not currently supported by the Ammo physics plugin");
+ }, r.prototype.syncMeshWithImpostor = function(t, e) {
+ e.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform), t.position.x = this._tmpAmmoTransform.getOrigin().x(), t.position.y = this._tmpAmmoTransform.getOrigin().y(), t.position.z = this._tmpAmmoTransform.getOrigin().z(), t.rotationQuaternion && (t.rotationQuaternion.x = this._tmpAmmoTransform.getRotation().x(), t.rotationQuaternion.y = this._tmpAmmoTransform.getRotation().y(), t.rotationQuaternion.z = this._tmpAmmoTransform.getRotation().z(), t.rotationQuaternion.w = this._tmpAmmoTransform.getRotation().w());
+ }, r.prototype.getRadius = function(t) {
+ return t.getObjectExtendSize().x / 2;
+ }, r.prototype.getBoxSizeToRef = function(t, e) {
+ var n = t.getObjectExtendSize();
+ e.x = n.x, e.y = n.y, e.z = n.z;
+ }, r.prototype.dispose = function() {
+ this.bjsAMMO.destroy(this.world), this.bjsAMMO.destroy(this._solver), this.bjsAMMO.destroy(this._overlappingPairCache), this.bjsAMMO.destroy(this._dispatcher), this.bjsAMMO.destroy(this._collisionConfiguration), this.bjsAMMO.destroy(this._tmpAmmoVectorA), this.bjsAMMO.destroy(this._tmpAmmoVectorB), this.bjsAMMO.destroy(this._tmpAmmoVectorC), this.bjsAMMO.destroy(this._tmpAmmoTransform), this.bjsAMMO.destroy(this._tmpAmmoQuaternion), this.bjsAMMO.destroy(this._tmpAmmoConcreteContactResultCallback), this.world = null;
+ }, r.prototype.raycast = function(t, e) {
+ this._tmpAmmoVectorRCA = new this.bjsAMMO.btVector3(t.x, t.y, t.z), this._tmpAmmoVectorRCB = new this.bjsAMMO.btVector3(e.x, e.y, e.z);
+ var n = new this.bjsAMMO.ClosestRayResultCallback(this._tmpAmmoVectorRCA, this._tmpAmmoVectorRCB);
+ return this.world.rayTest(this._tmpAmmoVectorRCA, this._tmpAmmoVectorRCB, n), this._raycastResult.reset(t, e), n.hasHit() && (this._raycastResult.setHitData({ x: n.get_m_hitNormalWorld().x(), y: n.get_m_hitNormalWorld().y(), z: n.get_m_hitNormalWorld().z() }, { x: n.get_m_hitPointWorld().x(), y: n.get_m_hitPointWorld().y(), z: n.get_m_hitPointWorld().z() }), this._raycastResult.calculateHitDistance()), this.bjsAMMO.destroy(n), this.bjsAMMO.destroy(this._tmpAmmoVectorRCA), this.bjsAMMO.destroy(this._tmpAmmoVectorRCB), this._raycastResult;
+ }, r.DISABLE_COLLISION_FLAG = 4, r.KINEMATIC_FLAG = 2, r.DISABLE_DEACTIVATION_FLAG = 4, r;
+ }();
+ V.a.prototype.removeReflectionProbe = function(r) {
+ if (!this.reflectionProbes)
+ return -1;
+ var t = this.reflectionProbes.indexOf(r);
+ return t !== -1 && this.reflectionProbes.splice(t, 1), t;
+ }, V.a.prototype.addReflectionProbe = function(r) {
+ this.reflectionProbes || (this.reflectionProbes = []), this.reflectionProbes.push(r);
+ };
+ var Du = function() {
+ function r(t, e, n, i, o) {
+ var a = this;
+ i === void 0 && (i = !0), o === void 0 && (o = !1), this.name = t, this._viewMatrix = u.a.Identity(), this._target = u.e.Zero(), this._add = u.e.Zero(), this._invertYAxis = !1, this.position = u.e.Zero(), this._scene = n, this._scene.reflectionProbes || (this._scene.reflectionProbes = new Array()), this._scene.reflectionProbes.push(this);
+ var s = h.a.TEXTURETYPE_UNSIGNED_BYTE;
+ if (o) {
+ var d = this._scene.getEngine().getCaps();
+ d.textureHalfFloatRender ? s = h.a.TEXTURETYPE_HALF_FLOAT : d.textureFloatRender && (s = h.a.TEXTURETYPE_FLOAT);
+ }
+ this._renderTargetTexture = new on(t, e, n, i, !0, s, !0), this._renderTargetTexture.onBeforeRenderObservable.add(function(p) {
+ switch (p) {
+ case 0:
+ a._add.copyFromFloats(1, 0, 0);
+ break;
+ case 1:
+ a._add.copyFromFloats(-1, 0, 0);
+ break;
+ case 2:
+ a._add.copyFromFloats(0, a._invertYAxis ? 1 : -1, 0);
+ break;
+ case 3:
+ a._add.copyFromFloats(0, a._invertYAxis ? -1 : 1, 0);
+ break;
+ case 4:
+ a._add.copyFromFloats(0, 0, 1);
+ break;
+ case 5:
+ a._add.copyFromFloats(0, 0, -1);
+ }
+ a._attachedMesh && a.position.copyFrom(a._attachedMesh.getAbsolutePosition()), a.position.addToRef(a._add, a._target), u.a.LookAtLHToRef(a.position, a._target, u.e.Up(), a._viewMatrix), n.activeCamera && (a._projectionMatrix = u.a.PerspectiveFovLH(Math.PI / 2, 1, n.activeCamera.minZ, n.activeCamera.maxZ), n.setTransformMatrix(a._viewMatrix, a._projectionMatrix)), n._forcedViewPosition = a.position;
+ }), this._renderTargetTexture.onAfterUnbindObservable.add(function() {
+ n._forcedViewPosition = null, n.updateTransformMatrix(!0);
+ });
+ }
+ return Object.defineProperty(r.prototype, "samples", { get: function() {
+ return this._renderTargetTexture.samples;
+ }, set: function(t) {
+ this._renderTargetTexture.samples = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "refreshRate", { get: function() {
+ return this._renderTargetTexture.refreshRate;
+ }, set: function(t) {
+ this._renderTargetTexture.refreshRate = t;
+ }, enumerable: !1, configurable: !0 }), r.prototype.getScene = function() {
+ return this._scene;
+ }, Object.defineProperty(r.prototype, "cubeTexture", { get: function() {
+ return this._renderTargetTexture;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "renderList", { get: function() {
+ return this._renderTargetTexture.renderList;
+ }, enumerable: !1, configurable: !0 }), r.prototype.attachToMesh = function(t) {
+ this._attachedMesh = t;
+ }, r.prototype.setRenderingAutoClearDepthStencil = function(t, e) {
+ this._renderTargetTexture.setRenderingAutoClearDepthStencil(t, e);
+ }, r.prototype.dispose = function() {
+ var t = this._scene.reflectionProbes.indexOf(this);
+ t !== -1 && this._scene.reflectionProbes.splice(t, 1), this._renderTargetTexture && (this._renderTargetTexture.dispose(), this._renderTargetTexture = null);
+ }, r.prototype.toString = function(t) {
+ var e = "Name: " + this.name;
+ return t && (e += ", position: " + this.position.toString(), this._attachedMesh && (e += ", attached mesh: " + this._attachedMesh.name)), e;
+ }, r.prototype.getClassName = function() {
+ return "ReflectionProbe";
+ }, r.prototype.serialize = function() {
+ var t = L.a.Serialize(this, this._renderTargetTexture.serialize());
+ return t.isReflectionProbe = !0, t;
+ }, r.Parse = function(t, e, n) {
+ var i = null;
+ if (e.reflectionProbes)
+ for (var o = 0; o < e.reflectionProbes.length; o++) {
+ var a = e.reflectionProbes[o];
+ if (a.name === t.name) {
+ i = a;
+ break;
+ }
+ }
+ return (i = L.a.Parse(function() {
+ return i || new r(t.name, t.renderTargetSize, e, t._generateMipMaps);
+ }, t, e, n)).cubeTexture._waitingRenderList = t.renderList, t._attachedMesh && i.attachToMesh(e.getMeshByID(t._attachedMesh)), i;
+ }, Object(c.c)([Object(L.k)()], r.prototype, "_attachedMesh", void 0), Object(c.c)([Object(L.o)()], r.prototype, "position", void 0), r;
+ }(), x_ = !0, $o = function() {
+ function r() {
+ }
+ return r.LoaderInjectedPhysicsEngine = void 0, r;
+ }(), Lu = function(r, t, e, n) {
+ for (var i = 0, o = t.materials.length; i < o; i++) {
+ var a = t.materials[i];
+ if (a.id === r)
+ return zt.a.Parse(a, e, n);
+ }
+ return null;
+ }, C_ = function(r, t, e) {
+ for (var n in t)
+ if (r.name === t[n])
+ return e.push(r.id), !0;
+ return !(!r.parentId || e.indexOf(r.parentId) === -1) && (e.push(r.id), !0);
+ }, Ar = function(r, t) {
+ return r + " of " + (t ? t.file + " from " + t.name + " version: " + t.version + ", exporter version: " + t.exporter_version : "unknown");
+ }, Nu = function(r, t) {
+ var e = t;
+ if (t._waitingData.lods) {
+ if (t._waitingData.lods.ids && t._waitingData.lods.ids.length > 0) {
+ var n = t._waitingData.lods.ids, i = e.isEnabled(!1);
+ if (t._waitingData.lods.distances) {
+ var o = t._waitingData.lods.distances;
+ if (o.length >= n.length) {
+ var a = o.length > n.length ? o[o.length - 1] : 0;
+ e.setEnabled(!1);
+ for (var s = 0; s < n.length; s++) {
+ var d = n[s], p = r.getMeshByID(d);
+ p != null && e.addLODLevel(o[s], p);
+ }
+ a > 0 && e.addLODLevel(a, null), i === !0 && e.setEnabled(!0);
+ } else
+ Xe.b.Warn("Invalid level of detail distances for " + t.name);
+ }
+ }
+ t._waitingData.lods = null;
+ }
+ }, wu = function(r, t, e, n, i) {
+ i === void 0 && (i = !1);
+ var o = new An(r), a = "importScene has failed JSON parse";
+ try {
+ var s = JSON.parse(t);
+ a = "";
+ var d, p, y = Ft.loggingLevel === Ft.DETAILED_LOGGING;
+ if (s.environmentTexture !== void 0 && s.environmentTexture !== null) {
+ var P = s.isPBR === void 0 || s.isPBR;
+ if (s.environmentTextureType && s.environmentTextureType === "BABYLON.HDRCubeTexture") {
+ var R = s.environmentTextureSize ? s.environmentTextureSize : 128, B = new qo((s.environmentTexture.match(/https?:\/\//g) ? "" : e) + s.environmentTexture, r, R, !0, !P);
+ s.environmentTextureRotationY && (B.rotationY = s.environmentTextureRotationY), r.environmentTexture = B;
+ } else if (Hn.a.EndsWith(s.environmentTexture, ".env")) {
+ var F = new ei((s.environmentTexture.match(/https?:\/\//g) ? "" : e) + s.environmentTexture, r);
+ s.environmentTextureRotationY && (F.rotationY = s.environmentTextureRotationY), r.environmentTexture = F;
+ } else {
+ var z = ei.CreateFromPrefilteredData((s.environmentTexture.match(/https?:\/\//g) ? "" : e) + s.environmentTexture, r);
+ s.environmentTextureRotationY && (z.rotationY = s.environmentTextureRotationY), r.environmentTexture = z;
+ }
+ if (s.createDefaultSkybox === !0) {
+ var J = r.activeCamera !== void 0 && r.activeCamera !== null ? (r.activeCamera.maxZ - r.activeCamera.minZ) / 2 : 1e3, ie = s.skyboxBlurLevel || 0;
+ r.createDefaultSkybox(r.environmentTexture, P, J, ie);
+ }
+ o.environmentTexture = r.environmentTexture;
+ }
+ if (s.environmentIntensity !== void 0 && s.environmentIntensity !== null && (r.environmentIntensity = s.environmentIntensity), s.lights !== void 0 && s.lights !== null)
+ for (d = 0, p = s.lights.length; d < p; d++) {
+ var se = s.lights[d], ce = bi.a.Parse(se, r);
+ ce && (o.lights.push(ce), a += d === 0 ? `
+ Lights:` : "", a += `
+ ` + ce.toString(y));
+ }
+ if (s.reflectionProbes !== void 0 && s.reflectionProbes !== null)
+ for (d = 0, p = s.reflectionProbes.length; d < p; d++) {
+ var ue = s.reflectionProbes[d], fe = Du.Parse(ue, r, e);
+ fe && (o.reflectionProbes.push(fe), a += d === 0 ? `
+ Reflection Probes:` : "", a += `
+ ` + fe.toString(y));
+ }
+ if (s.animations !== void 0 && s.animations !== null)
+ for (d = 0, p = s.animations.length; d < p; d++) {
+ var ve = s.animations[d], Te = O.a.GetClass("BABYLON.Animation");
+ if (Te) {
+ var Re = Te.Parse(ve);
+ r.animations.push(Re), o.animations.push(Re), a += d === 0 ? `
+ Animations:` : "", a += `
+ ` + Re.toString(y);
+ }
+ }
+ if (s.materials !== void 0 && s.materials !== null)
+ for (d = 0, p = s.materials.length; d < p; d++) {
+ var Ae = s.materials[d], Ee = zt.a.Parse(Ae, r, e);
+ Ee && (o.materials.push(Ee), a += d === 0 ? `
+ Materials:` : "", a += `
+ ` + Ee.toString(y), Ee.getActiveTextures().forEach(function(Kt) {
+ o.textures.indexOf(Kt) == -1 && o.textures.push(Kt);
+ }));
+ }
+ if (s.multiMaterials !== void 0 && s.multiMaterials !== null)
+ for (d = 0, p = s.multiMaterials.length; d < p; d++) {
+ var Se = s.multiMaterials[d], De = Qi.a.ParseMultiMaterial(Se, r);
+ o.multiMaterials.push(De), a += d === 0 ? `
+ MultiMaterials:` : "", a += `
+ ` + De.toString(y), De.getActiveTextures().forEach(function(Kt) {
+ o.textures.indexOf(Kt) == -1 && o.textures.push(Kt);
+ });
+ }
+ if (s.morphTargetManagers !== void 0 && s.morphTargetManagers !== null)
+ for (var xe = 0, Le = s.morphTargetManagers; xe < Le.length; xe++) {
+ var Me = Le[xe];
+ o.morphTargetManagers.push(Zo.Parse(Me, r));
+ }
+ if (s.skeletons !== void 0 && s.skeletons !== null)
+ for (d = 0, p = s.skeletons.length; d < p; d++) {
+ var we = s.skeletons[d], Ye = Ao.Parse(we, r);
+ o.skeletons.push(Ye), a += d === 0 ? `
+ Skeletons:` : "", a += `
+ ` + Ye.toString(y);
+ }
+ var et = s.geometries;
+ if (et != null) {
+ var nt = new Array(), ct = et.vertexData;
+ if (ct != null)
+ for (d = 0, p = ct.length; d < p; d++) {
+ var Ke = ct[d];
+ nt.push(Ns.a.Parse(Ke, r, e));
+ }
+ nt.forEach(function(Kt) {
+ Kt && o.geometries.push(Kt);
+ });
+ }
+ if (s.transformNodes !== void 0 && s.transformNodes !== null)
+ for (d = 0, p = s.transformNodes.length; d < p; d++) {
+ var rt = s.transformNodes[d], it = pr.a.Parse(rt, r, e);
+ o.transformNodes.push(it);
+ }
+ if (s.meshes !== void 0 && s.meshes !== null)
+ for (d = 0, p = s.meshes.length; d < p; d++) {
+ var qe = s.meshes[d], ut = Ie.a.Parse(qe, r, e);
+ if (o.meshes.push(ut), ut.hasInstances)
+ for (var Ve = 0, Ze = ut.instances; Ve < Ze.length; Ve++) {
+ var vt = Ze[Ve];
+ o.meshes.push(vt);
+ }
+ a += d === 0 ? `
+ Meshes:` : "", a += `
+ ` + ut.toString(y);
+ }
+ if (s.cameras !== void 0 && s.cameras !== null)
+ for (d = 0, p = s.cameras.length; d < p; d++) {
+ var jt = s.cameras[d], Dt = _t.a.Parse(jt, r);
+ o.cameras.push(Dt), a += d === 0 ? `
+ Cameras:` : "", a += `
+ ` + Dt.toString(y);
+ }
+ if (s.postProcesses !== void 0 && s.postProcesses !== null)
+ for (d = 0, p = s.postProcesses.length; d < p; d++) {
+ var Yt = s.postProcesses[d], mt = ft.Parse(Yt, r, e);
+ mt && (o.postProcesses.push(mt), a += d === 0 ? `
+Postprocesses:` : "", a += `
+ ` + mt.toString());
+ }
+ if (s.animationGroups !== void 0 && s.animationGroups !== null)
+ for (d = 0, p = s.animationGroups.length; d < p; d++) {
+ var qt = s.animationGroups[d], Ht = je.Parse(qt, r);
+ o.animationGroups.push(Ht), a += d === 0 ? `
+ AnimationGroups:` : "", a += `
+ ` + Ht.toString(y);
+ }
+ for (d = 0, p = r.cameras.length; d < p; d++)
+ (Dt = r.cameras[d])._waitingParentId && (Dt.parent = r.getLastEntryByID(Dt._waitingParentId), Dt._waitingParentId = null);
+ for (d = 0, p = r.lights.length; d < p; d++) {
+ var kt = r.lights[d];
+ kt && kt._waitingParentId && (kt.parent = r.getLastEntryByID(kt._waitingParentId), kt._waitingParentId = null);
+ }
+ for (d = 0, p = r.transformNodes.length; d < p; d++) {
+ var Wt = r.transformNodes[d];
+ Wt._waitingParentId && (Wt.parent = r.getLastEntryByID(Wt._waitingParentId), Wt._waitingParentId = null);
+ }
+ for (d = 0, p = r.meshes.length; d < p; d++)
+ (ut = r.meshes[d])._waitingParentId && (ut.parent = r.getLastEntryByID(ut._waitingParentId), ut._waitingParentId = null), ut._waitingData.lods && Nu(r, ut);
+ for (d = 0, p = r.skeletons.length; d < p; d++)
+ (Ye = r.skeletons[d])._hasWaitingData && (Ye.bones != null && Ye.bones.forEach(function(Kt) {
+ if (Kt._waitingTransformNodeId) {
+ var oi = r.getLastEntryByID(Kt._waitingTransformNodeId);
+ oi && Kt.linkTransformNode(oi), Kt._waitingTransformNodeId = null;
+ }
+ }), Ye._waitingOverrideMeshId && (Ye.overrideMesh = r.getMeshByID(Ye._waitingOverrideMeshId), Ye._waitingOverrideMeshId = null), Ye._hasWaitingData = null);
+ for (d = 0, p = r.meshes.length; d < p; d++) {
+ var bt = r.meshes[d];
+ bt._waitingData.freezeWorldMatrix ? (bt.freezeWorldMatrix(), bt._waitingData.freezeWorldMatrix = null) : bt.computeWorldMatrix(!0);
+ }
+ for (d = 0, p = r.lights.length; d < p; d++) {
+ var Rt = r.lights[d];
+ if (Rt._excludedMeshesIds.length > 0) {
+ for (var Zt = 0; Zt < Rt._excludedMeshesIds.length; Zt++) {
+ var Mn = r.getMeshByID(Rt._excludedMeshesIds[Zt]);
+ Mn && Rt.excludedMeshes.push(Mn);
+ }
+ Rt._excludedMeshesIds = [];
+ }
+ if (Rt._includedOnlyMeshesIds.length > 0) {
+ for (var Bn = 0; Bn < Rt._includedOnlyMeshesIds.length; Bn++) {
+ var Kn = r.getMeshByID(Rt._includedOnlyMeshesIds[Bn]);
+ Kn && Rt.includedOnlyMeshes.push(Kn);
+ }
+ Rt._includedOnlyMeshesIds = [];
+ }
+ }
+ for (V.a.Parse(s, r, o, e), d = 0, p = r.meshes.length; d < p; d++)
+ (ut = r.meshes[d])._waitingData.actions && (pe.Parse(ut._waitingData.actions, ut, r), ut._waitingData.actions = null);
+ s.actions !== void 0 && s.actions !== null && pe.Parse(s.actions, null, r);
+ } catch (Kt) {
+ var In = Ar("loadAssets", s ? s.producer : "Unknown") + a;
+ if (!n)
+ throw l.a.Log(In), Kt;
+ n(In, Kt);
+ } finally {
+ i || o.removeAllFromScene(), a !== null && Ft.loggingLevel !== Ft.NO_LOGGING && l.a.Log(Ar("loadAssets", s ? s.producer : "Unknown") + (Ft.loggingLevel !== Ft.MINIMAL_LOGGING ? a : ""));
+ }
+ return o;
+ };
+ Ft.RegisterPlugin({ name: "babylon.js", extensions: ".babylon", canDirectLoad: function(r) {
+ return r.indexOf("babylon") !== -1;
+ }, importMesh: function(r, t, e, n, i, o, a, s) {
+ var d = "importMesh has failed JSON parse";
+ try {
+ var p = JSON.parse(e);
+ d = "";
+ var y = Ft.loggingLevel === Ft.DETAILED_LOGGING;
+ r ? Array.isArray(r) || (r = [r]) : r = null;
+ var P = new Array();
+ if (p.meshes !== void 0 && p.meshes !== null) {
+ var R, B, F, z = [], J = [];
+ for (R = 0, B = p.meshes.length; R < B; R++) {
+ var ie = p.meshes[R];
+ if (r === null || C_(ie, r, P)) {
+ if (r !== null && delete r[r.indexOf(ie.name)], ie.geometryId !== void 0 && ie.geometryId !== null && p.geometries !== void 0 && p.geometries !== null) {
+ var se = !1;
+ ["boxes", "spheres", "cylinders", "toruses", "grounds", "planes", "torusKnots", "vertexData"].forEach(function(it) {
+ se !== !0 && p.geometries[it] && Array.isArray(p.geometries[it]) && p.geometries[it].forEach(function(qe) {
+ if (qe.id === ie.geometryId) {
+ switch (it) {
+ case "vertexData":
+ Ns.a.Parse(qe, t, n);
+ }
+ se = !0;
+ }
+ });
+ }), se === !1 && l.a.Warn("Geometry not found for mesh " + ie.id);
+ }
+ if (ie.materialId) {
+ var ce = J.indexOf(ie.materialId) !== -1;
+ if (ce === !1 && p.multiMaterials !== void 0 && p.multiMaterials !== null)
+ for (var ue = 0, fe = p.multiMaterials.length; ue < fe; ue++) {
+ var ve = p.multiMaterials[ue];
+ if (ve.id === ie.materialId) {
+ for (var Te = 0, Re = ve.materials.length; Te < Re; Te++) {
+ var Ae, Ee = ve.materials[Te];
+ J.push(Ee), (Ae = Lu(Ee, p, t, n)) && (d += `
+ Material ` + Ae.toString(y));
+ }
+ J.push(ve.id);
+ var Se = Qi.a.ParseMultiMaterial(ve, t);
+ Se && (ce = !0, d += `
+ Multi-Material ` + Se.toString(y));
+ break;
+ }
+ }
+ ce === !1 && (J.push(ie.materialId), (Ae = Lu(ie.materialId, p, t, n)) ? d += `
+ Material ` + Ae.toString(y) : l.a.Warn("Material not found for mesh " + ie.id));
+ }
+ if (ie.skeletonId > -1 && p.skeletons !== void 0 && p.skeletons !== null && !(z.indexOf(ie.skeletonId) > -1))
+ for (var De = 0, xe = p.skeletons.length; De < xe; De++) {
+ var Le = p.skeletons[De];
+ if (Le.id === ie.skeletonId) {
+ var Me = Ao.Parse(Le, t);
+ a.push(Me), z.push(Le.id), d += `
+ Skeleton ` + Me.toString(y);
+ }
+ }
+ if (p.morphTargetManagers !== void 0 && p.morphTargetManagers !== null)
+ for (var we = 0, Ye = p.morphTargetManagers; we < Ye.length; we++) {
+ var et = Ye[we];
+ Zo.Parse(et, t);
+ }
+ var nt = Ie.a.Parse(ie, t, n);
+ i.push(nt), d += `
+ Mesh ` + nt.toString(y);
+ }
+ }
+ for (R = 0, B = t.meshes.length; R < B; R++)
+ (F = t.meshes[R])._waitingParentId && (F.parent = t.getLastEntryByID(F._waitingParentId), F._waitingParentId = null), F._waitingData.lods && Nu(t, F);
+ for (R = 0, B = t.skeletons.length; R < B; R++)
+ (Me = t.skeletons[R])._hasWaitingData && (Me.bones != null && Me.bones.forEach(function(it) {
+ if (it._waitingTransformNodeId) {
+ var qe = t.getLastEntryByID(it._waitingTransformNodeId);
+ qe && it.linkTransformNode(qe), it._waitingTransformNodeId = null;
+ }
+ }), Me._waitingOverrideMeshId && (Me.overrideMesh = t.getMeshByID(Me._waitingOverrideMeshId), Me._waitingOverrideMeshId = null), Me._hasWaitingData = null);
+ for (R = 0, B = t.meshes.length; R < B; R++)
+ (F = t.meshes[R])._waitingData.freezeWorldMatrix ? (F.freezeWorldMatrix(), F._waitingData.freezeWorldMatrix = null) : F.computeWorldMatrix(!0);
+ }
+ if (p.particleSystems !== void 0 && p.particleSystems !== null) {
+ var ct = V.a.GetIndividualParser(ot.a.NAME_PARTICLESYSTEM);
+ if (ct)
+ for (R = 0, B = p.particleSystems.length; R < B; R++) {
+ var Ke = p.particleSystems[R];
+ P.indexOf(Ke.emitterId) !== -1 && o.push(ct(Ke, t, n));
+ }
+ }
+ return !0;
+ } catch (it) {
+ var rt = Ar("importMesh", p ? p.producer : "Unknown") + d;
+ if (!s)
+ throw l.a.Log(rt), it;
+ s(rt, it);
+ } finally {
+ d !== null && Ft.loggingLevel !== Ft.NO_LOGGING && l.a.Log(Ar("importMesh", p ? p.producer : "Unknown") + (Ft.loggingLevel !== Ft.MINIMAL_LOGGING ? d : ""));
+ }
+ return !1;
+ }, load: function(r, t, e, n) {
+ var i = "importScene has failed JSON parse";
+ try {
+ var o = JSON.parse(t);
+ if (i = "", o.useDelayedTextureLoading !== void 0 && o.useDelayedTextureLoading !== null && (r.useDelayedTextureLoading = o.useDelayedTextureLoading && !Ft.ForceFullSceneLoadingForIncremental), o.autoClear !== void 0 && o.autoClear !== null && (r.autoClear = o.autoClear), o.clearColor !== void 0 && o.clearColor !== null && (r.clearColor = I.b.FromArray(o.clearColor)), o.ambientColor !== void 0 && o.ambientColor !== null && (r.ambientColor = I.a.FromArray(o.ambientColor)), o.gravity !== void 0 && o.gravity !== null && (r.gravity = u.e.FromArray(o.gravity)), o.fogMode && o.fogMode !== 0)
+ switch (r.fogMode = o.fogMode, r.fogColor = I.a.FromArray(o.fogColor), r.fogStart = o.fogStart, r.fogEnd = o.fogEnd, r.fogDensity = o.fogDensity, i += " Fog mode for scene: ", r.fogMode) {
+ case 1:
+ i += `exp
+`;
+ break;
+ case 2:
+ i += `exp2
+`;
+ break;
+ case 3:
+ i += `linear
+`;
+ }
+ if (o.physicsEnabled) {
+ var a;
+ o.physicsEngine === "cannon" ? a = new Bs(void 0, void 0, $o.LoaderInjectedPhysicsEngine) : o.physicsEngine === "oimo" ? a = new Mu(void 0, $o.LoaderInjectedPhysicsEngine) : o.physicsEngine === "ammo" && (a = new Iu(void 0, $o.LoaderInjectedPhysicsEngine, void 0)), i = " Physics engine " + (o.physicsEngine ? o.physicsEngine : "oimo") + ` enabled
+`;
+ var s = o.physicsGravity ? u.e.FromArray(o.physicsGravity) : null;
+ r.enablePhysics(s, a);
+ }
+ return o.metadata !== void 0 && o.metadata !== null && (r.metadata = o.metadata), o.collisionsEnabled !== void 0 && o.collisionsEnabled !== null && (r.collisionsEnabled = o.collisionsEnabled), !!wu(r, t, e, n, !0) && (o.autoAnimate && r.beginAnimation(r, o.autoAnimateFrom, o.autoAnimateTo, o.autoAnimateLoop, o.autoAnimateSpeed || 1), o.activeCameraID !== void 0 && o.activeCameraID !== null && r.setActiveCameraByID(o.activeCameraID), !0);
+ } catch (p) {
+ var d = Ar("importScene", o ? o.producer : "Unknown") + i;
+ if (!n)
+ throw l.a.Log(d), p;
+ n(d, p);
+ } finally {
+ i !== null && Ft.loggingLevel !== Ft.NO_LOGGING && l.a.Log(Ar("importScene", o ? o.producer : "Unknown") + (Ft.loggingLevel !== Ft.MINIMAL_LOGGING ? i : ""));
+ }
+ return !1;
+ }, loadAssetContainer: function(r, t, e, n) {
+ return wu(r, t, e, n);
+ } });
+ var R_ = f(121), Fu = function() {
+ function r(t) {
+ t === void 0 && (t = {}), this._isEnabled = !0, this.bias = t.bias === void 0 ? 0 : t.bias, this.power = t.power === void 0 ? 1 : t.power, this.leftColor = t.leftColor || I.a.White(), this.rightColor = t.rightColor || I.a.Black(), t.isEnabled === !1 && (this.isEnabled = !1);
+ }
+ return Object.defineProperty(r.prototype, "isEnabled", { get: function() {
+ return this._isEnabled;
+ }, set: function(t) {
+ this._isEnabled !== t && (this._isEnabled = t, Ue.a.MarkAllMaterialsAsDirty(h.a.MATERIAL_FresnelDirtyFlag | h.a.MATERIAL_MiscDirtyFlag));
+ }, enumerable: !1, configurable: !0 }), r.prototype.clone = function() {
+ var t = new r();
+ return de.a.DeepCopy(this, t), t;
+ }, r.prototype.equals = function(t) {
+ return t && this.bias === t.bias && this.power === t.power && this.leftColor.equals(t.leftColor) && this.rightColor.equals(t.rightColor) && this.isEnabled === t.isEnabled;
+ }, r.prototype.serialize = function() {
+ return { isEnabled: this.isEnabled, leftColor: this.leftColor.asArray(), rightColor: this.rightColor.asArray(), bias: this.bias, power: this.power };
+ }, r.Parse = function(t) {
+ return new r({ isEnabled: t.isEnabled, leftColor: I.a.FromArray(t.leftColor), rightColor: I.a.FromArray(t.rightColor), bias: t.bias, power: t.power || 1 });
+ }, r;
+ }();
+ L.a._FresnelParametersParser = Fu.Parse;
+ var Bu = f(119), Us = function(r) {
+ function t(e, n) {
+ var i = r.call(this, e, n) || this;
+ return i.maxSimultaneousLights = 4, i.disableLighting = !1, i.invertNormalMapX = !1, i.invertNormalMapY = !1, i.emissiveColor = new I.a(0, 0, 0), i.occlusionStrength = 1, i.useLightmapAsShadowmap = !1, i._useAlphaFromAlbedoTexture = !0, i._useAmbientInGrayScale = !0, i;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "doubleSided", { get: function() {
+ return this._twoSidedLighting;
+ }, set: function(e) {
+ this._twoSidedLighting !== e && (this._twoSidedLighting = e, this.backFaceCulling = !e, this._markAllSubMeshesAsTexturesDirty());
+ }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
+ return "PBRBaseSimpleMaterial";
+ }, Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsLightsDirty")], t.prototype, "maxSimultaneousLights", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsLightsDirty")], t.prototype, "disableLighting", void 0), Object(c.c)([Object(L.m)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty", "_reflectionTexture")], t.prototype, "environmentTexture", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertNormalMapX", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertNormalMapY", void 0), Object(c.c)([Object(L.m)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty", "_bumpTexture")], t.prototype, "normalTexture", void 0), Object(c.c)([Object(L.e)("emissive"), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveColor", void 0), Object(c.c)([Object(L.m)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveTexture", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty", "_ambientTextureStrength")], t.prototype, "occlusionStrength", void 0), Object(c.c)([Object(L.m)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty", "_ambientTexture")], t.prototype, "occlusionTexture", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty", "_alphaCutOff")], t.prototype, "alphaCutOff", void 0), Object(c.c)([Object(L.c)()], t.prototype, "doubleSided", null), Object(c.c)([Object(L.m)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty", null)], t.prototype, "lightmapTexture", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useLightmapAsShadowmap", void 0), t;
+ }(pn), Uu = function(r) {
+ function t(e, n) {
+ var i = r.call(this, e, n) || this;
+ return i._useRoughnessFromMetallicTextureAlpha = !1, i._useRoughnessFromMetallicTextureGreen = !0, i._useMetallnessFromMetallicTextureBlue = !0, i.metallic = 1, i.roughness = 1, i;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "PBRMetallicRoughnessMaterial";
+ }, t.prototype.clone = function(e) {
+ var n = this, i = L.a.Clone(function() {
+ return new t(e, n.getScene());
+ }, this);
+ return i.id = e, i.name = e, this.clearCoat.copyTo(i.clearCoat), this.anisotropy.copyTo(i.anisotropy), this.brdf.copyTo(i.brdf), this.sheen.copyTo(i.sheen), this.subSurface.copyTo(i.subSurface), i;
+ }, t.prototype.serialize = function() {
+ var e = L.a.Serialize(this);
+ return e.customType = "BABYLON.PBRMetallicRoughnessMaterial", e.clearCoat = this.clearCoat.serialize(), e.anisotropy = this.anisotropy.serialize(), e.brdf = this.brdf.serialize(), e.sheen = this.sheen.serialize(), e.subSurface = this.subSurface.serialize(), e;
+ }, t.Parse = function(e, n, i) {
+ var o = L.a.Parse(function() {
+ return new t(e.name, n);
+ }, e, n, i);
+ return e.clearCoat && o.clearCoat.parse(e.clearCoat, n, i), e.anisotropy && o.anisotropy.parse(e.anisotropy, n, i), e.brdf && o.brdf.parse(e.brdf, n, i), e.sheen && o.sheen.parse(e.sheen, n, i), e.subSurface && o.subSurface.parse(e.subSurface, n, i), o;
+ }, Object(c.c)([Object(L.e)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty", "_albedoColor")], t.prototype, "baseColor", void 0), Object(c.c)([Object(L.m)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")], t.prototype, "baseTexture", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallic", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty")], t.prototype, "roughness", void 0), Object(c.c)([Object(L.m)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty", "_metallicTexture")], t.prototype, "metallicRoughnessTexture", void 0), t;
+ }(Us);
+ O.a.RegisteredTypes["BABYLON.PBRMetallicRoughnessMaterial"] = Uu;
+ var Vu = function(r) {
+ function t(e, n) {
+ var i = r.call(this, e, n) || this;
+ return i._useMicroSurfaceFromReflectivityMapAlpha = !0, i;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "PBRSpecularGlossinessMaterial";
+ }, t.prototype.clone = function(e) {
+ var n = this, i = L.a.Clone(function() {
+ return new t(e, n.getScene());
+ }, this);
+ return i.id = e, i.name = e, this.clearCoat.copyTo(i.clearCoat), this.anisotropy.copyTo(i.anisotropy), this.brdf.copyTo(i.brdf), this.sheen.copyTo(i.sheen), this.subSurface.copyTo(i.subSurface), i;
+ }, t.prototype.serialize = function() {
+ var e = L.a.Serialize(this);
+ return e.customType = "BABYLON.PBRSpecularGlossinessMaterial", e.clearCoat = this.clearCoat.serialize(), e.anisotropy = this.anisotropy.serialize(), e.brdf = this.brdf.serialize(), e.sheen = this.sheen.serialize(), e.subSurface = this.subSurface.serialize(), e;
+ }, t.Parse = function(e, n, i) {
+ var o = L.a.Parse(function() {
+ return new t(e.name, n);
+ }, e, n, i);
+ return e.clearCoat && o.clearCoat.parse(e.clearCoat, n, i), e.anisotropy && o.anisotropy.parse(e.anisotropy, n, i), e.brdf && o.brdf.parse(e.brdf, n, i), e.sheen && o.sheen.parse(e.sheen, n, i), e.subSurface && o.subSurface.parse(e.subSurface, n, i), o;
+ }, Object(c.c)([Object(L.e)("diffuse"), Object(L.b)("_markAllSubMeshesAsTexturesDirty", "_albedoColor")], t.prototype, "diffuseColor", void 0), Object(c.c)([Object(L.m)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")], t.prototype, "diffuseTexture", void 0), Object(c.c)([Object(L.e)("specular"), Object(L.b)("_markAllSubMeshesAsTexturesDirty", "_reflectivityColor")], t.prototype, "specularColor", void 0), Object(c.c)([Object(L.c)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty", "_microSurface")], t.prototype, "glossiness", void 0), Object(c.c)([Object(L.m)(), Object(L.b)("_markAllSubMeshesAsTexturesDirty", "_reflectivityTexture")], t.prototype, "specularGlossinessTexture", void 0), t;
+ }(Us);
+ O.a.RegisteredTypes["BABYLON.PBRSpecularGlossinessMaterial"] = Vu;
+ var ea = f(73), ku = function(r) {
+ function t(e, n, i) {
+ i === void 0 && (i = null);
+ var o = r.call(this, n) || this;
+ if (!e)
+ return o;
+ if (o._textureMatrix = u.a.Identity(), o.name = e, o.url = e, o._onLoad = i, o._texture = o._getFromCache(e, !0), o._texture)
+ o._triggerOnLoad();
+ else {
+ var a = o.getScene();
+ a && a.useDelayedTextureLoading ? o.delayLoadState = h.a.DELAYLOADSTATE_NOTLOADED : o.loadTexture();
+ }
+ return o;
+ }
+ return Object(c.d)(t, r), t.prototype._triggerOnLoad = function() {
+ this._onLoad && this._onLoad();
+ }, t.prototype.getTextureMatrix = function() {
+ return this._textureMatrix;
+ }, t.prototype.load3dlTexture = function() {
+ var e, n = this, i = this._getEngine();
+ e = i.webGLVersion === 1 ? i.createRawTexture(null, 1, 1, h.a.TEXTUREFORMAT_RGBA, !1, !1, h.a.TEXTURE_BILINEAR_SAMPLINGMODE, null, h.a.TEXTURETYPE_UNSIGNED_INT) : i.createRawTexture3D(null, 1, 1, 1, h.a.TEXTUREFORMAT_RGBA, !1, !1, h.a.TEXTURE_BILINEAR_SAMPLINGMODE, null, h.a.TEXTURETYPE_UNSIGNED_INT), this._texture = e, this._texture.isReady = !1, this.isCube = !1, this.is3D = i.webGLVersion > 1, this.wrapU = h.a.TEXTURE_CLAMP_ADDRESSMODE, this.wrapV = h.a.TEXTURE_CLAMP_ADDRESSMODE, this.wrapR = h.a.TEXTURE_CLAMP_ADDRESSMODE, this.anisotropicFilteringLevel = 1;
+ var o = function(s) {
+ if (typeof s == "string") {
+ for (var d, p = null, y = null, P = s.split(`
+`), R = 0, B = 0, F = 0, z = 0, J = 0, ie = 0; ie < P.length; ie++)
+ if (d = P[ie], t._noneEmptyLineRegex.test(d) && d.indexOf("#") !== 0) {
+ var se = d.split(" ");
+ if (R !== 0) {
+ if (R != 0) {
+ var ce = Math.max(parseInt(se[0]), 0), ue = Math.max(parseInt(se[1]), 0), fe = Math.max(parseInt(se[2]), 0);
+ J = Math.max(ce, J), J = Math.max(ue, J), J = Math.max(fe, J);
+ var ve = 4 * (B + z * R + F * R * R);
+ y && (y[ve + 0] = ce, y[ve + 1] = ue, y[ve + 2] = fe), ++F % R == 0 && (F = 0, ++z % R == 0 && (B++, z = 0));
+ }
+ } else
+ R = se.length, p = new Uint8Array(R * R * R * 4), y = new Float32Array(R * R * R * 4);
+ }
+ if (y && p)
+ for (ie = 0; ie < y.length; ie++)
+ if (ie > 0 && (ie + 1) % 4 == 0)
+ p[ie] = 255;
+ else {
+ var Te = y[ie];
+ p[ie] = Te / J * 255;
+ }
+ e.is3D ? (e.updateSize(R, R, R), i.updateRawTexture3D(e, p, h.a.TEXTUREFORMAT_RGBA, !1)) : (e.updateSize(R * R, R), i.updateRawTexture(e, p, h.a.TEXTUREFORMAT_RGBA, !1)), e.isReady = !0, n._triggerOnLoad();
+ }
+ }, a = this.getScene();
+ return a ? a._loadFile(this.url, o) : i._loadFile(this.url, o), this._texture;
+ }, t.prototype.loadTexture = function() {
+ this.url && this.url.toLocaleLowerCase().indexOf(".3dl") == this.url.length - 4 && this.load3dlTexture();
+ }, t.prototype.clone = function() {
+ var e = new t(this.url, this.getScene() || this._getEngine());
+ return e.level = this.level, e;
+ }, t.prototype.delayLoad = function() {
+ this.delayLoadState === h.a.DELAYLOADSTATE_NOTLOADED && (this.delayLoadState = h.a.DELAYLOADSTATE_LOADED, this._texture = this._getFromCache(this.url, !0), this._texture || this.loadTexture());
+ }, t.Parse = function(e, n) {
+ var i = null;
+ return e.name && !e.isRenderTarget && ((i = new t(e.name, n)).name = e.name, i.level = e.level), i;
+ }, t.prototype.serialize = function() {
+ if (!this.name)
+ return null;
+ var e = {};
+ return e.name = this.name, e.level = this.level, e.customType = "BABYLON.ColorGradingTexture", e;
+ }, t._noneEmptyLineRegex = /\S+/, t;
+ }(kn.a);
+ O.a.RegisteredTypes["BABYLON.ColorGradingTexture"] = ku;
+ var Gu = function(r) {
+ function t(e, n, i, o, a, s, d) {
+ o === void 0 && (o = !1), a === void 0 && (a = !0), s === void 0 && (s = null), d === void 0 && (d = null);
+ var p = r.call(this, n) || this;
+ if (p._onLoad = null, p._onError = null, !e)
+ throw new Error("Image url is not set");
+ return p._coordinatesMode = Ne.a.CUBIC_MODE, p.name = e, p.url = e, p._size = i, p._noMipmap = o, p.gammaSpace = a, p._onLoad = s, p._onError = d, p.hasAlpha = !1, p.isCube = !0, p._texture = p._getFromCache(e, p._noMipmap), p._texture ? s && (p._texture.isReady ? Xe.b.SetImmediate(function() {
+ return s();
+ }) : p._texture.onLoadedObservable.add(s)) : n.useDelayedTextureLoading ? p.delayLoadState = h.a.DELAYLOADSTATE_NOTLOADED : p.loadImage(p.loadTexture.bind(p), p._onError), p;
+ }
+ return Object(c.d)(t, r), t.prototype.loadImage = function(e, n) {
+ var i = this, o = document.createElement("canvas"), a = new Image();
+ a.addEventListener("load", function() {
+ i._width = a.width, i._height = a.height, o.width = i._width, o.height = i._height;
+ var s = o.getContext("2d");
+ s.drawImage(a, 0, 0);
+ var d = s.getImageData(0, 0, a.width, a.height);
+ i._buffer = d.data.buffer, o.remove(), e();
+ }), a.addEventListener("error", function(s) {
+ n && n(i.getClassName() + " could not be loaded", s);
+ }), a.src = this.url;
+ }, t.prototype.loadTexture = function() {
+ var e = this, n = this.getScene();
+ n && (this._texture = n.getEngine().createRawCubeTextureFromUrl(this.url, n, this._size, h.a.TEXTUREFORMAT_RGB, n.getEngine().getCaps().textureFloat ? h.a.TEXTURETYPE_FLOAT : h.a.TEXTURETYPE_UNSIGNED_INTEGER, this._noMipmap, function() {
+ for (var i = e.getFloat32ArrayFromArrayBuffer(e._buffer), o = ws.ConvertPanoramaToCubemap(i, e._width, e._height, e._size), a = [], s = 0; s < 6; s++) {
+ var d = o[t._FacesMapping[s]];
+ a.push(d);
+ }
+ return a;
+ }, null, this._onLoad, this._onError));
+ }, t.prototype.getFloat32ArrayFromArrayBuffer = function(e) {
+ for (var n = new DataView(e), i = new Float32Array(3 * e.byteLength / 4), o = 0, a = 0; a < e.byteLength; a++)
+ (a + 1) % 4 != 0 && (i[o++] = n.getUint8(a) / 255);
+ return i;
+ }, t.prototype.getClassName = function() {
+ return "EquiRectangularCubeTexture";
+ }, t.prototype.clone = function() {
+ var e = this.getScene();
+ if (!e)
+ return this;
+ var n = new t(this.url, e, this._size, this._noMipmap, this.gammaSpace);
+ return n.level = this.level, n.wrapU = this.wrapU, n.wrapV = this.wrapV, n.coordinatesIndex = this.coordinatesIndex, n.coordinatesMode = this.coordinatesMode, n;
+ }, t._FacesMapping = ["right", "left", "up", "down", "front", "back"], t;
+ }(kn.a), O_ = function(r) {
+ function t(e, n, i) {
+ var o = r.call(this, i.scene || i.engine) || this;
+ return n && (i.engine || i.scene) && (i = Object(c.a)(Object(c.a)({}, t.DefaultOptions), i), o._generateMipMaps = i.generateMipMaps, o._samplingMode = i.samplingMode, o._textureMatrix = u.a.Identity(), o.name = e, o.element = n, o._isVideo = n instanceof HTMLVideoElement, o.anisotropicFilteringLevel = 1, o._createInternalTexture()), o;
+ }
+ return Object(c.d)(t, r), t.prototype._createInternalTexture = function() {
+ var e = 0, n = 0;
+ this._isVideo ? (e = this.element.videoWidth, n = this.element.videoHeight) : (e = this.element.width, n = this.element.height);
+ var i = this._getEngine();
+ i && (this._texture = i.createDynamicTexture(e, n, this._generateMipMaps, this._samplingMode)), this.update();
+ }, t.prototype.getTextureMatrix = function() {
+ return this._textureMatrix;
+ }, t.prototype.update = function(e) {
+ e === void 0 && (e = null);
+ var n = this._getEngine();
+ if (this._texture != null && n != null)
+ if (this._isVideo) {
+ var i = this.element;
+ if (i.readyState < i.HAVE_CURRENT_DATA)
+ return;
+ n.updateVideoTexture(this._texture, i, e === null || e);
+ } else {
+ var o = this.element;
+ n.updateDynamicTexture(this._texture, o, e === null || e, !1);
+ }
+ }, t.DefaultOptions = { generateMipMaps: !1, samplingMode: h.a.TEXTURE_BILINEAR_SAMPLINGMODE, engine: null, scene: null }, t;
+ }(kn.a), ta = function() {
+ function r() {
+ }
+ return r.GetTGAHeader = function(t) {
+ var e = 0;
+ return { id_length: t[e++], colormap_type: t[e++], image_type: t[e++], colormap_index: t[e++] | t[e++] << 8, colormap_length: t[e++] | t[e++] << 8, colormap_size: t[e++], origin: [t[e++] | t[e++] << 8, t[e++] | t[e++] << 8], width: t[e++] | t[e++] << 8, height: t[e++] | t[e++] << 8, pixel_size: t[e++], flags: t[e++] };
+ }, r.UploadContent = function(t, e) {
+ if (e.length < 19)
+ l.a.Error("Unable to load TGA file - Not enough data to contain header");
+ else {
+ var n = 18, i = r.GetTGAHeader(e);
+ if (i.id_length + n > e.length)
+ l.a.Error("Unable to load TGA file - Not enough data");
+ else {
+ n += i.id_length;
+ var o, a = !1, s = !1, d = !1;
+ switch (i.image_type) {
+ case r._TYPE_RLE_INDEXED:
+ a = !0;
+ case r._TYPE_INDEXED:
+ s = !0;
+ break;
+ case r._TYPE_RLE_RGB:
+ a = !0;
+ case r._TYPE_RGB:
+ break;
+ case r._TYPE_RLE_GREY:
+ a = !0;
+ case r._TYPE_GREY:
+ d = !0;
+ }
+ var p, y, P, R, B, F, z, J = i.pixel_size >> 3, ie = i.width * i.height * J;
+ if (s && (p = e.subarray(n, n += i.colormap_length * (i.colormap_size >> 3))), a) {
+ var se, ce, ue;
+ o = new Uint8Array(ie);
+ for (var fe = 0, ve = new Uint8Array(J); n < ie && fe < ie; )
+ if (ce = 1 + (127 & (se = e[n++])), 128 & se) {
+ for (ue = 0; ue < J; ++ue)
+ ve[ue] = e[n++];
+ for (ue = 0; ue < ce; ++ue)
+ o.set(ve, fe + ue * J);
+ fe += J * ce;
+ } else {
+ for (ce *= J, ue = 0; ue < ce; ++ue)
+ o[fe + ue] = e[n++];
+ fe += ce;
+ }
+ } else
+ o = e.subarray(n, n += s ? i.width * i.height : ie);
+ switch ((i.flags & r._ORIGIN_MASK) >> r._ORIGIN_SHIFT) {
+ default:
+ case r._ORIGIN_UL:
+ y = 0, R = 1, z = i.width, P = 0, B = 1, F = i.height;
+ break;
+ case r._ORIGIN_BL:
+ y = 0, R = 1, z = i.width, P = i.height - 1, B = -1, F = -1;
+ break;
+ case r._ORIGIN_UR:
+ y = i.width - 1, R = -1, z = -1, P = 0, B = 1, F = i.height;
+ break;
+ case r._ORIGIN_BR:
+ y = i.width - 1, R = -1, z = -1, P = i.height - 1, B = -1, F = -1;
+ }
+ var Te = r["_getImageData" + (d ? "Grey" : "") + i.pixel_size + "bits"](i, p, o, P, B, F, y, R, z);
+ t.getEngine()._uploadDataToTextureDirectly(t, Te);
+ }
+ }
+ }, r._getImageData8bits = function(t, e, n, i, o, a, s, d, p) {
+ var y, P, R, B = n, F = e, z = t.width, J = t.height, ie = 0, se = new Uint8Array(z * J * 4);
+ for (R = i; R !== a; R += o)
+ for (P = s; P !== p; P += d, ie++)
+ y = B[ie], se[4 * (P + z * R) + 3] = 255, se[4 * (P + z * R) + 2] = F[3 * y + 0], se[4 * (P + z * R) + 1] = F[3 * y + 1], se[4 * (P + z * R) + 0] = F[3 * y + 2];
+ return se;
+ }, r._getImageData16bits = function(t, e, n, i, o, a, s, d, p) {
+ var y, P, R, B = n, F = t.width, z = t.height, J = 0, ie = new Uint8Array(F * z * 4);
+ for (R = i; R !== a; R += o)
+ for (P = s; P !== p; P += d, J += 2) {
+ var se = 255 * ((31744 & (y = B[J + 0] + (B[J + 1] << 8))) >> 10) / 31 | 0, ce = 255 * ((992 & y) >> 5) / 31 | 0, ue = 255 * (31 & y) / 31 | 0;
+ ie[4 * (P + F * R) + 0] = se, ie[4 * (P + F * R) + 1] = ce, ie[4 * (P + F * R) + 2] = ue, ie[4 * (P + F * R) + 3] = 32768 & y ? 0 : 255;
+ }
+ return ie;
+ }, r._getImageData24bits = function(t, e, n, i, o, a, s, d, p) {
+ var y, P, R = n, B = t.width, F = t.height, z = 0, J = new Uint8Array(B * F * 4);
+ for (P = i; P !== a; P += o)
+ for (y = s; y !== p; y += d, z += 3)
+ J[4 * (y + B * P) + 3] = 255, J[4 * (y + B * P) + 2] = R[z + 0], J[4 * (y + B * P) + 1] = R[z + 1], J[4 * (y + B * P) + 0] = R[z + 2];
+ return J;
+ }, r._getImageData32bits = function(t, e, n, i, o, a, s, d, p) {
+ var y, P, R = n, B = t.width, F = t.height, z = 0, J = new Uint8Array(B * F * 4);
+ for (P = i; P !== a; P += o)
+ for (y = s; y !== p; y += d, z += 4)
+ J[4 * (y + B * P) + 2] = R[z + 0], J[4 * (y + B * P) + 1] = R[z + 1], J[4 * (y + B * P) + 0] = R[z + 2], J[4 * (y + B * P) + 3] = R[z + 3];
+ return J;
+ }, r._getImageDataGrey8bits = function(t, e, n, i, o, a, s, d, p) {
+ var y, P, R, B = n, F = t.width, z = t.height, J = 0, ie = new Uint8Array(F * z * 4);
+ for (R = i; R !== a; R += o)
+ for (P = s; P !== p; P += d, J++)
+ y = B[J], ie[4 * (P + F * R) + 0] = y, ie[4 * (P + F * R) + 1] = y, ie[4 * (P + F * R) + 2] = y, ie[4 * (P + F * R) + 3] = 255;
+ return ie;
+ }, r._getImageDataGrey16bits = function(t, e, n, i, o, a, s, d, p) {
+ var y, P, R = n, B = t.width, F = t.height, z = 0, J = new Uint8Array(B * F * 4);
+ for (P = i; P !== a; P += o)
+ for (y = s; y !== p; y += d, z += 2)
+ J[4 * (y + B * P) + 0] = R[z + 0], J[4 * (y + B * P) + 1] = R[z + 0], J[4 * (y + B * P) + 2] = R[z + 0], J[4 * (y + B * P) + 3] = R[z + 1];
+ return J;
+ }, r._TYPE_INDEXED = 1, r._TYPE_RGB = 2, r._TYPE_GREY = 3, r._TYPE_RLE_INDEXED = 9, r._TYPE_RLE_RGB = 10, r._TYPE_RLE_GREY = 11, r._ORIGIN_MASK = 48, r._ORIGIN_SHIFT = 4, r._ORIGIN_BL = 0, r._ORIGIN_BR = 1, r._ORIGIN_UL = 2, r._ORIGIN_UR = 3, r;
+ }(), zu = function() {
+ function r() {
+ this.supportCascades = !1;
+ }
+ return r.prototype.canLoad = function(t) {
+ return Hn.a.EndsWith(t, ".tga");
+ }, r.prototype.loadCubeData = function(t, e, n, i, o) {
+ throw ".env not supported in Cube.";
+ }, r.prototype.loadData = function(t, e, n) {
+ var i = new Uint8Array(t.buffer, t.byteOffset, t.byteLength), o = ta.GetTGAHeader(i);
+ n(o.width, o.height, e.generateMipMaps, !1, function() {
+ ta.UploadContent(e, i);
+ });
+ }, r;
+ }();
+ Ue.a._TextureLoaders.push(new zu());
+ var io, M_ = function() {
+ };
+ (function(r) {
+ r[r.cTFETC1 = 0] = "cTFETC1", r[r.cTFBC1 = 1] = "cTFBC1", r[r.cTFBC4 = 2] = "cTFBC4", r[r.cTFPVRTC1_4_OPAQUE_ONLY = 3] = "cTFPVRTC1_4_OPAQUE_ONLY", r[r.cTFBC7_M6_OPAQUE_ONLY = 4] = "cTFBC7_M6_OPAQUE_ONLY", r[r.cTFETC2 = 5] = "cTFETC2", r[r.cTFBC3 = 6] = "cTFBC3", r[r.cTFBC5 = 7] = "cTFBC5";
+ })(io || (io = {}));
+ var ro = function() {
+ function r() {
+ }
+ return r.GetInternalFormatFromBasisFormat = function(t) {
+ if (t === io.cTFETC1)
+ return 36196;
+ if (t === io.cTFBC1)
+ return 33776;
+ if (t === io.cTFBC3)
+ return 33779;
+ throw "The chosen Basis transcoder format is not currently supported";
+ }, r._CreateWorkerAsync = function() {
+ var t = this;
+ return this._WorkerPromise || (this._WorkerPromise = new Promise(function(e) {
+ t._Worker ? e(t._Worker) : Xe.b.LoadFileAsync(r.WasmModuleURL).then(function(n) {
+ var i = URL.createObjectURL(new Blob(["(" + I_ + ")()"], { type: "application/javascript" }));
+ t._Worker = new Worker(i);
+ var o = function(a) {
+ a.data.action === "init" && (t._Worker.removeEventListener("message", o), e(t._Worker));
+ };
+ t._Worker.addEventListener("message", o), t._Worker.postMessage({ action: "init", url: r.JSModuleURL, wasmBinary: n });
+ });
+ })), this._WorkerPromise;
+ }, r.TranscodeAsync = function(t, e) {
+ var n = this, i = t instanceof ArrayBuffer ? new Uint8Array(t) : t;
+ return new Promise(function(o, a) {
+ n._CreateWorkerAsync().then(function() {
+ var s = n._actionId++, d = function(y) {
+ y.data.action === "transcode" && y.data.id === s && (n._Worker.removeEventListener("message", d), y.data.success ? o(y.data) : a("Transcode is not supported on this device"));
+ };
+ n._Worker.addEventListener("message", d);
+ var p = new Uint8Array(i.byteLength);
+ p.set(new Uint8Array(i.buffer, i.byteOffset, i.byteLength)), n._Worker.postMessage({ action: "transcode", id: s, imageData: p, config: e, ignoreSupportedFormats: n._IgnoreSupportedFormats }, [p.buffer]);
+ });
+ });
+ }, r.LoadTextureFromTranscodeResult = function(t, e) {
+ for (var n, i = t.getEngine(), o = function() {
+ if (n = e.fileInfo.images[a].levels[0], t._invertVScale = t.invertY, e.format === -1)
+ if (t.type = h.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5, t.format = h.a.TEXTUREFORMAT_RGB, i.webGLVersion < 2 && ($.a.Log2(n.width) % 1 != 0 || $.a.Log2(n.height) % 1 != 0)) {
+ var s = new Pt.a(i, Pt.b.Temp);
+ t._invertVScale = t.invertY, s.type = h.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5, s.format = h.a.TEXTUREFORMAT_RGB, s.width = n.width + 3 & -4, s.height = n.height + 3 & -4, i._bindTextureDirectly(i._gl.TEXTURE_2D, s, !0), i._uploadDataToTextureDirectly(s, n.transcodedPixels, a, 0, h.a.TEXTUREFORMAT_RGB, !0), i._rescaleTexture(s, t, i.scenes[0], i._getInternalFormat(h.a.TEXTUREFORMAT_RGB), function() {
+ i._releaseTexture(s), i._bindTextureDirectly(i._gl.TEXTURE_2D, t, !0);
+ });
+ } else
+ t._invertVScale = !t.invertY, t.width = n.width + 3 & -4, t.height = n.height + 3 & -4, i._uploadDataToTextureDirectly(t, n.transcodedPixels, a, 0, h.a.TEXTUREFORMAT_RGB, !0);
+ else
+ t.width = n.width, t.height = n.height, e.fileInfo.images[a].levels.forEach(function(d, p) {
+ i._uploadCompressedDataToTextureDirectly(t, r.GetInternalFormatFromBasisFormat(e.format), d.width, d.height, d.transcodedPixels, a, p);
+ }), i.webGLVersion < 2 && ($.a.Log2(t.width) % 1 != 0 || $.a.Log2(t.height) % 1 != 0) && (Xe.b.Warn("Loaded .basis texture width and height are not a power of two. Texture wrapping will be set to Texture.CLAMP_ADDRESSMODE as other modes are not supported with non power of two dimensions in webGL 1."), t._cachedWrapU = Ne.a.CLAMP_ADDRESSMODE, t._cachedWrapV = Ne.a.CLAMP_ADDRESSMODE);
+ }, a = 0; a < e.fileInfo.images.length; a++)
+ o();
+ }, r._IgnoreSupportedFormats = !1, r.JSModuleURL = "https://preview.babylonjs.com/basisTranscoder/basis_transcoder.js", r.WasmModuleURL = "https://preview.babylonjs.com/basisTranscoder/basis_transcoder.wasm", r._WorkerPromise = null, r._Worker = null, r._actionId = 0, r;
+ }();
+ function I_() {
+ var r = 0, t = 1, e = 5, n = 6, i = null;
+ function o(a, s, d, p, y) {
+ var P = a.getImageTranscodedSizeInBytes(s, d, p), R = new Uint8Array(P);
+ return a.transcodeImage(R, s, d, p, 1, 0) ? (y && (R = function(B, F, z, J) {
+ for (var ie = new Uint16Array(4), se = new Uint16Array(z * J), ce = z / 4, ue = J / 4, fe = 0; fe < ue; fe++)
+ for (var ve = 0; ve < ce; ve++) {
+ var Te = F + 8 * (fe * ce + ve);
+ ie[0] = B[Te] | B[Te + 1] << 8, ie[1] = B[Te + 2] | B[Te + 3] << 8, ie[2] = (2 * (31 & ie[0]) + 1 * (31 & ie[1])) / 3 | (2 * (2016 & ie[0]) + 1 * (2016 & ie[1])) / 3 & 2016 | (2 * (63488 & ie[0]) + 1 * (63488 & ie[1])) / 3 & 63488, ie[3] = (2 * (31 & ie[1]) + 1 * (31 & ie[0])) / 3 | (2 * (2016 & ie[1]) + 1 * (2016 & ie[0])) / 3 & 2016 | (2 * (63488 & ie[1]) + 1 * (63488 & ie[0])) / 3 & 63488;
+ for (var Re = 0; Re < 4; Re++) {
+ var Ae = B[Te + 4 + Re], Ee = (4 * fe + Re) * z + 4 * ve;
+ se[Ee++] = ie[3 & Ae], se[Ee++] = ie[Ae >> 2 & 3], se[Ee++] = ie[Ae >> 4 & 3], se[Ee++] = ie[Ae >> 6 & 3];
+ }
+ }
+ return se;
+ }(R, 0, a.getImageWidth(s, d) + 3 & -4, a.getImageHeight(s, d) + 3 & -4)), R) : null;
+ }
+ onmessage = function(a) {
+ if (a.data.action === "init")
+ i || (Module = { wasmBinary: a.data.wasmBinary }, importScripts(a.data.url), i = new Promise(function(fe) {
+ Module.onRuntimeInitialized = function() {
+ Module.initializeBasis(), fe();
+ };
+ })), i.then(function() {
+ postMessage({ action: "init" });
+ });
+ else if (a.data.action === "transcode") {
+ var s = a.data.config, d = a.data.imageData, p = new Module.BasisFile(d), y = function(fe) {
+ for (var ve = fe.getHasAlpha(), Te = fe.getNumImages(), Re = [], Ae = 0; Ae < Te; Ae++) {
+ for (var Ee = { levels: [] }, Se = fe.getNumLevels(Ae), De = 0; De < Se; De++) {
+ var xe = { width: fe.getImageWidth(Ae, De), height: fe.getImageHeight(Ae, De) };
+ Ee.levels.push(xe);
+ }
+ Re.push(Ee);
+ }
+ return { hasAlpha: ve, images: Re };
+ }(p), P = a.data.ignoreSupportedFormats ? null : function(fe, ve) {
+ var Te = null;
+ return fe.supportedCompressionFormats && (fe.supportedCompressionFormats.etc1 ? Te = r : fe.supportedCompressionFormats.s3tc ? Te = ve.hasAlpha ? n : t : fe.supportedCompressionFormats.pvrtc || fe.supportedCompressionFormats.etc2 && (Te = e)), Te;
+ }(a.data.config, y), R = !1;
+ P === null && (R = !0, P = y.hasAlpha ? n : t);
+ var B = !0;
+ p.startTranscoding() || (B = !1);
+ for (var F = [], z = 0; z < y.images.length && B; z++) {
+ var J = y.images[z];
+ if (s.loadSingleImage === void 0 || s.loadSingleImage === z) {
+ var ie = J.levels.length;
+ s.loadMipmapLevels === !1 && (ie = 1);
+ for (var se = 0; se < ie; se++) {
+ var ce = J.levels[se], ue = o(p, z, se, P, R);
+ if (!ue) {
+ B = !1;
+ break;
+ }
+ ce.transcodedPixels = ue, F.push(ce.transcodedPixels.buffer);
+ }
+ }
+ }
+ p.close(), p.delete(), R && (P = -1), B ? postMessage({ action: "transcode", success: B, id: a.data.id, fileInfo: y, format: P }, F) : postMessage({ action: "transcode", success: B, id: a.data.id });
+ }
+ };
+ }
+ var ju = function() {
+ function r() {
+ this.supportCascades = !1;
+ }
+ return r.prototype.canLoad = function(t) {
+ return Hn.a.EndsWith(t, ".basis");
+ }, r.prototype.loadCubeData = function(t, e, n, i, o) {
+ if (!Array.isArray(t)) {
+ var a = e.getEngine().getCaps(), s = { supportedCompressionFormats: { etc1: !!a.etc1, s3tc: !!a.s3tc, pvrtc: !!a.pvrtc, etc2: !!a.etc2 } };
+ ro.TranscodeAsync(t, s).then(function(d) {
+ var p = d.fileInfo.images[0].levels.length > 1 && e.generateMipMaps;
+ ro.LoadTextureFromTranscodeResult(e, d), e.getEngine()._setCubeMapTextureParams(e, p), e.isReady = !0, e.onLoadedObservable.notifyObservers(e), e.onLoadedObservable.clear(), i && i();
+ }).catch(function(d) {
+ Xe.b.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"), e.isReady = !0;
+ });
+ }
+ }, r.prototype.loadData = function(t, e, n) {
+ var i = e.getEngine().getCaps(), o = { supportedCompressionFormats: { etc1: !!i.etc1, s3tc: !!i.s3tc, pvrtc: !!i.pvrtc, etc2: !!i.etc2 } };
+ ro.TranscodeAsync(t, o).then(function(a) {
+ var s = a.fileInfo.images[0].levels[0], d = a.fileInfo.images[0].levels.length > 1 && e.generateMipMaps;
+ n(s.width, s.height, d, a.format !== -1, function() {
+ ro.LoadTextureFromTranscodeResult(e, a);
+ });
+ }).catch(function(a) {
+ Xe.b.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"), n(0, 0, !1, !1, function() {
+ });
+ });
+ }, r;
+ }();
+ Ue.a._TextureLoaders.push(new ju());
+ var Vs = function(r) {
+ function t(e, n, i, o, a) {
+ var s = this, d = !(!a || !a.generateMipMaps) && a.generateMipMaps, p = !(!a || !a.generateDepthTexture) && a.generateDepthTexture, y = !a || a.doNotChangeAspectRatio === void 0 || a.doNotChangeAspectRatio;
+ if ((s = r.call(this, e, n, o, d, y) || this).isSupported) {
+ var P = [], R = [];
+ s._initTypes(i, P, R, a);
+ var B = !a || a.generateDepthBuffer === void 0 || a.generateDepthBuffer, F = !(!a || a.generateStencilBuffer === void 0) && a.generateStencilBuffer;
+ return s._size = n, s._multiRenderTargetOptions = { samplingModes: R, generateMipMaps: d, generateDepthBuffer: B, generateStencilBuffer: F, generateDepthTexture: p, types: P, textureCount: i }, s._count = i, s._createInternalTextures(), s._createTextures(), s;
+ }
+ s.dispose();
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "isSupported", { get: function() {
+ return this._getEngine().webGLVersion > 1 || this._getEngine().getCaps().drawBuffersExtension;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "textures", { get: function() {
+ return this._textures;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "count", { get: function() {
+ return this._count;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "depthTexture", { get: function() {
+ return this._textures[this._textures.length - 1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wrapU", { set: function(e) {
+ if (this._textures)
+ for (var n = 0; n < this._textures.length; n++)
+ this._textures[n].wrapU = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "wrapV", { set: function(e) {
+ if (this._textures)
+ for (var n = 0; n < this._textures.length; n++)
+ this._textures[n].wrapV = e;
+ }, enumerable: !1, configurable: !0 }), t.prototype._initTypes = function(e, n, i, o) {
+ for (var a = 0; a < e; a++)
+ o && o.types && o.types[a] !== void 0 ? n.push(o.types[a]) : n.push(o && o.defaultType ? o.defaultType : h.a.TEXTURETYPE_UNSIGNED_INT), o && o.samplingModes && o.samplingModes[a] !== void 0 ? i.push(o.samplingModes[a]) : i.push(Ne.a.BILINEAR_SAMPLINGMODE);
+ }, t.prototype._rebuild = function(e) {
+ e === void 0 && (e = !1), this.releaseInternalTextures(), this._createInternalTextures(), e && this._createTextures();
+ for (var n = 0; n < this._internalTextures.length; n++)
+ this._textures[n]._texture = this._internalTextures[n];
+ this._texture = this._internalTextures[0], this.samples !== 1 && this._getEngine().updateMultipleRenderTargetTextureSampleCount(this._internalTextures, this.samples);
+ }, t.prototype._createInternalTextures = function() {
+ this._internalTextures = this._getEngine().createMultipleRenderTarget(this._size, this._multiRenderTargetOptions);
+ }, t.prototype._createTextures = function() {
+ this._textures = [];
+ for (var e = 0; e < this._internalTextures.length; e++) {
+ var n = new Ne.a(null, this.getScene());
+ n._texture = this._internalTextures[e], this._textures.push(n);
+ }
+ this._texture = this._internalTextures[0];
+ }, t.prototype.replaceTexture = function(e, n) {
+ e._texture && (this._textures[n] = e, this._internalTextures[n] = e._texture);
+ }, Object.defineProperty(t.prototype, "samples", { get: function() {
+ return this._samples;
+ }, set: function(e) {
+ this._samples !== e && (this._samples = this._getEngine().updateMultipleRenderTargetTextureSampleCount(this._internalTextures, e));
+ }, enumerable: !1, configurable: !0 }), t.prototype.resize = function(e) {
+ this._size = e, this._rebuild();
+ }, t.prototype.updateCount = function(e, n) {
+ this._multiRenderTargetOptions.textureCount = e, this._count = e;
+ var i = [], o = [];
+ this._initTypes(e, i, o, n), this._multiRenderTargetOptions.types = i, this._multiRenderTargetOptions.samplingModes = o, this._rebuild(!0);
+ }, t.prototype.unbindFrameBuffer = function(e, n) {
+ var i = this;
+ e.unBindMultiColorAttachmentFramebuffer(this._internalTextures, this.isCube, function() {
+ i.onAfterRenderObservable.notifyObservers(n);
+ });
+ }, t.prototype.dispose = function() {
+ this.releaseInternalTextures(), r.prototype.dispose.call(this);
+ }, t.prototype.releaseInternalTextures = function() {
+ if (this._internalTextures)
+ for (var e = this._internalTextures.length - 1; e >= 0; e--)
+ this._internalTextures[e] !== void 0 && (this._internalTextures[e].dispose(), this._internalTextures.splice(e, 1));
+ }, t;
+ }(on), ks = function(r, t, e) {
+ this.id = r, this.scale = t, this.offset = e;
+ }, D_ = function() {
+ function r(t, e, n, i) {
+ var o, a, s, d, p, y, P, R, B, F, z, J, ie;
+ return this.name = t, this.meshes = e, this.scene = i, this.options = n, this.options.map = (o = this.options.map) !== null && o !== void 0 ? o : ["ambientTexture", "bumpTexture", "diffuseTexture", "emissiveTexture", "lightmapTexture", "opacityTexture", "reflectionTexture", "refractionTexture", "specularTexture"], this.options.uvsIn = (a = this.options.uvsIn) !== null && a !== void 0 ? a : Oe.b.UVKind, this.options.uvsOut = (s = this.options.uvsOut) !== null && s !== void 0 ? s : Oe.b.UVKind, this.options.layout = (d = this.options.layout) !== null && d !== void 0 ? d : r.LAYOUT_STRIP, this.options.layout === r.LAYOUT_COLNUM && (this.options.colnum = (p = this.options.colnum) !== null && p !== void 0 ? p : 8), this.options.updateInputMeshes = (y = this.options.updateInputMeshes) === null || y === void 0 || y, this.options.disposeSources = (P = this.options.disposeSources) === null || P === void 0 || P, this._expecting = 0, this.options.fillBlanks = (R = this.options.fillBlanks) === null || R === void 0 || R, this.options.fillBlanks === !0 && (this.options.customFillColor = (B = this.options.customFillColor) !== null && B !== void 0 ? B : "black"), this.options.frameSize = (F = this.options.frameSize) !== null && F !== void 0 ? F : 256, this.options.paddingRatio = (z = this.options.paddingRatio) !== null && z !== void 0 ? z : 0.0115, this._paddingValue = Math.ceil(this.options.frameSize * this.options.paddingRatio), this._paddingValue % 2 != 0 && this._paddingValue++, this.options.paddingMode = (J = this.options.paddingMode) !== null && J !== void 0 ? J : r.SUBUV_WRAP, this.options.paddingMode === r.SUBUV_COLOR && (this.options.paddingColor = (ie = this.options.paddingColor) !== null && ie !== void 0 ? ie : new I.b(0, 0, 0, 1)), this.sets = {}, this.frames = [], this;
+ }
+ return r.prototype._createFrames = function(t) {
+ for (var e = this, n = this._calculateSize(), i = new u.d(1, 1).divide(n), o = 0, a = this._expecting, s = this.meshes.length, d = Object.keys(this.sets), p = 0; p < d.length; p++) {
+ var y = d[p], P = new pi.a(this.name + ".TexturePack." + y + "Set", { width: n.x, height: n.y }, this.scene, !0, Ne.a.TRILINEAR_SAMPLINGMODE, Ue.a.TEXTUREFORMAT_RGBA), R = P.getContext();
+ R.fillStyle = "rgba(0,0,0,0)", R.fillRect(0, 0, n.x, n.y), P.update(!1), this.sets[y] = P;
+ }
+ var B = this.options.frameSize || 256, F = this._paddingValue, z = B + 2 * F;
+ for (p = 0; p < s; p++)
+ for (var J = this.meshes[p].material, ie = function(ue) {
+ var fe = new pi.a("temp", z, se.scene, !0), ve = fe.getContext(), Te = se._getFrameOffset(p), Re = function() {
+ o++, fe.update(!1);
+ var De = ve.getImageData(0, 0, z, z), xe = e.sets[Ae];
+ if (xe.getContext().putImageData(De, n.x * Te.x, n.y * Te.y), fe.dispose(), xe.update(!1), o == a)
+ return e._calculateMeshUVFrames(B, F, n, i, e.options.updateInputMeshes || !1), void t();
+ }, Ae = d[ue] || "_blank";
+ if (J && J[Ae] !== null) {
+ var Ee = J[Ae], Se = new Image();
+ Ee instanceof pi.a ? Se.src = Ee.getContext().canvas.toDataURL("image/png") : Se.src = Ee.url, Xe.b.SetCorsBehavior(Se.src, Se), Se.onload = function() {
+ ve.fillStyle = "rgba(0,0,0,0)", ve.fillRect(0, 0, z, z), fe.update(!1), ve.setTransform(1, 0, 0, -1, 0, 0);
+ var De = [0, 0, 1, 0, 1, 1, 0, 1, -1, 1, -1, 0, -2, 0, -1, 1, -1];
+ switch (e.options.paddingMode) {
+ case 0:
+ for (var xe = 0; xe < 9; xe++)
+ ve.drawImage(Se, 0, 0, Se.width, Se.height, F + B * De[xe], F + B * De[xe + 1] - z, B, B);
+ break;
+ case 1:
+ for (var Le = 0; Le < F; Le++)
+ ve.drawImage(Se, 0, 0, Se.width, Se.height, Le + B * De[0], F - z, B, B), ve.drawImage(Se, 0, 0, Se.width, Se.height, 2 * F - Le, F - z, B, B), ve.drawImage(Se, 0, 0, Se.width, Se.height, F, Le - z, B, B), ve.drawImage(Se, 0, 0, Se.width, Se.height, F, 2 * F - Le - z, B, B);
+ ve.drawImage(Se, 0, 0, Se.width, Se.height, F + B * De[0], F + B * De[1] - z, B, B);
+ break;
+ case 2:
+ ve.fillStyle = (e.options.paddingColor || I.a.Black()).toHexString(), ve.fillRect(0, 0, z, -z), ve.clearRect(F, F, B, B), ve.drawImage(Se, 0, 0, Se.width, Se.height, F + B * De[0], F + B * De[1] - z, B, B);
+ }
+ ve.setTransform(1, 0, 0, 1, 0, 0), Re();
+ };
+ } else
+ ve.fillStyle = "rgba(0,0,0,0)", se.options.fillBlanks && (ve.fillStyle = se.options.customFillColor), ve.fillRect(0, 0, z, z), Re();
+ }, se = this, ce = 0; ce < d.length; ce++)
+ ie(ce);
+ }, r.prototype._calculateSize = function() {
+ var t = this.meshes.length || 0, e = this.options.frameSize || 0, n = this._paddingValue || 0;
+ switch (this.options.layout) {
+ case 0:
+ return new u.d(e * t + 2 * n * t, e + 2 * n);
+ case 1:
+ var i = Math.max(2, Math.ceil(Math.sqrt(t))), o = e * i + 2 * n * i;
+ return new u.d(o, o);
+ case 2:
+ var a = this.options.colnum || 1, s = Math.max(1, Math.ceil(t / a));
+ return new u.d(e * a + 2 * n * a, e * s + 2 * n * s);
+ }
+ return u.d.Zero();
+ }, r.prototype._calculateMeshUVFrames = function(t, e, n, i, o) {
+ for (var a = this.meshes.length, s = 0; s < a; s++) {
+ var d = this.meshes[s], p = new u.d(t / n.x, t / n.y), y = i.clone().scale(e), P = this._getFrameOffset(s).add(y), R = new ks(s, p, P);
+ this.frames.push(R), o && (this._updateMeshUV(d, s), this._updateTextureReferences(d));
+ }
+ }, r.prototype._getFrameOffset = function(t) {
+ var e, n, i, o = this.meshes.length;
+ switch (this.options.layout) {
+ case 0:
+ return e = 1 / o, new u.d(t * e, 0);
+ case 1:
+ var a = Math.max(2, Math.ceil(Math.sqrt(o)));
+ return i = t - (n = Math.floor(t / a)) * a, e = 1 / a, new u.d(i * e, n * e);
+ case 2:
+ var s = this.options.colnum || 1, d = Math.max(1, Math.ceil(o / s));
+ return n = t - (i = Math.floor(t / d)) * d, e = new u.d(1 / s, 1 / d), new u.d(i * e.x, n * e.y);
+ }
+ return u.d.Zero();
+ }, r.prototype._updateMeshUV = function(t, e) {
+ var n = this.frames[e], i = t.getVerticesData(this.options.uvsIn || Oe.b.UVKind), o = [], a = 0;
+ i.length && (a = i.length || 0);
+ for (var s = 0; s < a; s += 2)
+ o.push(i[s] * n.scale.x + n.offset.x, i[s + 1] * n.scale.y + n.offset.y);
+ t.setVerticesData(this.options.uvsOut || Oe.b.UVKind, o);
+ }, r.prototype._updateTextureReferences = function(t, e) {
+ e === void 0 && (e = !1);
+ for (var n = t.material, i = Object.keys(this.sets), o = function(d) {
+ d.dispose && d.dispose();
+ }, a = 0; a < i.length; a++) {
+ var s = i[a];
+ if (e)
+ n[s] !== null && o(n[s]), n[s] = this.sets[s];
+ else {
+ if (!n)
+ return;
+ n[s] !== null && (o(n[s]), n[s] = this.sets[s]);
+ }
+ }
+ }, r.prototype.setMeshToFrame = function(t, e, n) {
+ n === void 0 && (n = !1), this._updateMeshUV(t, e), n && this._updateTextureReferences(t, !0);
+ }, r.prototype.processAsync = function() {
+ var t = this;
+ return new Promise(function(e, n) {
+ try {
+ if (t.meshes.length === 0)
+ return void e();
+ for (var i = 0, o = function(d) {
+ var p = t.meshes[d], y = p.material;
+ if (!y)
+ return ++i === t.meshes.length ? { value: t._createFrames(e) } : "continue";
+ y.forceCompilationAsync(p).then(function() {
+ (function(P) {
+ if (i++, t.options.map) {
+ for (var R = 0; R < t.options.map.length; R++)
+ P[t.options.map[R]] !== null && (t.sets[t.options.map[R]] || (t.sets[t.options.map[R]] = !0), t._expecting++);
+ i === t.meshes.length && t._createFrames(e);
+ }
+ })(y);
+ });
+ }, a = 0; a < t.meshes.length; a++) {
+ var s = o(a);
+ if (typeof s == "object")
+ return s.value;
+ }
+ } catch (d) {
+ return n(d);
+ }
+ });
+ }, r.prototype.dispose = function() {
+ for (var t = Object.keys(this.sets), e = 0; e < t.length; e++) {
+ var n = t[e];
+ this.sets[n].dispose();
+ }
+ }, r.prototype.download = function(t, e) {
+ var n = this;
+ t === void 0 && (t = "png"), e === void 0 && (e = 1), setTimeout(function() {
+ var i = { name: n.name, sets: {}, options: {}, frames: [] }, o = Object.keys(n.sets), a = Object.keys(n.options);
+ try {
+ for (var s = 0; s < o.length; s++) {
+ var d = o[s], p = n.sets[d];
+ i.sets[d] = p.getContext().canvas.toDataURL("image/" + t, e);
+ }
+ for (s = 0; s < a.length; s++) {
+ var y = a[s];
+ i.options[y] = n.options[y];
+ }
+ for (s = 0; s < n.frames.length; s++) {
+ var P = n.frames[s];
+ i.frames.push(P.scale.x, P.scale.y, P.offset.x, P.offset.y);
+ }
+ } catch (F) {
+ return void l.a.Warn("Unable to download: " + F);
+ }
+ var R = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(i, null, 4)), B = document.createElement("a");
+ B.setAttribute("href", R), B.setAttribute("download", n.name + "_texurePackage.json"), document.body.appendChild(B), B.click(), B.remove();
+ }, 0);
+ }, r.prototype.updateFromJSON = function(t) {
+ try {
+ var e = JSON.parse(t);
+ this.name = e.name;
+ for (var n = Object.keys(e.options), i = 0; i < n.length; i++)
+ this.options[n[i]] = e.options[n[i]];
+ for (i = 0; i < e.frames.length; i += 4) {
+ var o = new ks(i / 4, new u.d(e.frames[i], e.frames[i + 1]), new u.d(e.frames[i + 2], e.frames[i + 3]));
+ this.frames.push(o);
+ }
+ var a = Object.keys(e.sets);
+ for (i = 0; i < a.length; i++) {
+ var s = new Ne.a(e.sets[a[i]], this.scene, !1, !1);
+ this.sets[a[i]] = s;
+ }
+ } catch (d) {
+ l.a.Warn("Unable to update from JSON: " + d);
+ }
+ }, r.LAYOUT_STRIP = 0, r.LAYOUT_POWER2 = 1, r.LAYOUT_COLNUM = 2, r.SUBUV_WRAP = 0, r.SUBUV_EXTEND = 1, r.SUBUV_COLOR = 2, r;
+ }(), Hu = function() {
+ function r(t) {
+ this.name = ot.a.NAME_PROCEDURALTEXTURE, this.scene = t, this.scene.proceduralTextures = new Array();
+ }
+ return r.prototype.register = function() {
+ this.scene._beforeClearStage.registerStep(ot.a.STEP_BEFORECLEAR_PROCEDURALTEXTURE, this, this._beforeClear);
+ }, r.prototype.rebuild = function() {
+ }, r.prototype.dispose = function() {
+ }, r.prototype._beforeClear = function() {
+ if (this.scene.proceduralTexturesEnabled) {
+ Xe.b.StartPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
+ for (var t = 0; t < this.scene.proceduralTextures.length; t++) {
+ var e = this.scene.proceduralTextures[t];
+ e._shouldRender() && e.render();
+ }
+ Xe.b.EndPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
+ }
+ }, r;
+ }(), L_ = `
+attribute vec2 position;
+
+varying vec2 vPosition;
+varying vec2 vUV;
+const vec2 madd=vec2(0.5,0.5);
+void main(void) {
+vPosition=position;
+vUV=position*madd+madd;
+gl_Position=vec4(position,0.0,1.0);
+}`;
+ ze.a.ShadersStore.proceduralVertexShader = L_;
+ var oo = function(r) {
+ function t(e, n, i, o, a, s, d, p) {
+ a === void 0 && (a = null), s === void 0 && (s = !0), d === void 0 && (d = !1), p === void 0 && (p = h.a.TEXTURETYPE_UNSIGNED_INT);
+ var y = r.call(this, null, o, !s) || this;
+ y.isEnabled = !0, y.autoClear = !0, y.onGeneratedObservable = new C.c(), y.onBeforeGenerationObservable = new C.c(), y.nodeMaterialSource = null, y._textures = {}, y._currentRefreshId = -1, y._frameId = -1, y._refreshRate = 1, y._vertexBuffers = {}, y._uniforms = new Array(), y._samplers = new Array(), y._floats = {}, y._ints = {}, y._floatsArrays = {}, y._colors3 = {}, y._colors4 = {}, y._vectors2 = {}, y._vectors3 = {}, y._matrices = {}, y._fallbackTextureUsed = !1, y._cachedDefines = "", y._contentUpdateId = -1;
+ var P = (o = y.getScene() || te.a.LastCreatedScene)._getComponent(ot.a.NAME_PROCEDURALTEXTURE);
+ P || (P = new Hu(o), o._addComponent(P)), o.proceduralTextures.push(y), y._fullEngine = o.getEngine(), y.name = e, y.isRenderTarget = !0, y._size = n, y._generateMipMaps = s, y.setFragment(i), y._fallbackTexture = a, d ? (y._texture = y._fullEngine.createRenderTargetCubeTexture(n, { generateMipMaps: s, generateDepthBuffer: !1, generateStencilBuffer: !1, type: p }), y.setFloat("face", 0)) : y._texture = y._fullEngine.createRenderTargetTexture(n, { generateMipMaps: s, generateDepthBuffer: !1, generateStencilBuffer: !1, type: p });
+ var R = [];
+ return R.push(1, 1), R.push(-1, 1), R.push(-1, -1), R.push(1, -1), y._vertexBuffers[Oe.b.PositionKind] = new Oe.b(y._fullEngine, R, Oe.b.PositionKind, !1, !1, 2), y._createIndexBuffer(), y;
+ }
+ return Object(c.d)(t, r), t.prototype.getEffect = function() {
+ return this._effect;
+ }, t.prototype.getContent = function() {
+ return this._contentData && this._frameId === this._contentUpdateId || (this._contentData = this.readPixels(0, 0, this._contentData), this._contentUpdateId = this._frameId), this._contentData;
+ }, t.prototype._createIndexBuffer = function() {
+ var e = this._fullEngine, n = [];
+ n.push(0), n.push(1), n.push(2), n.push(0), n.push(2), n.push(3), this._indexBuffer = e.createIndexBuffer(n);
+ }, t.prototype._rebuild = function() {
+ var e = this._vertexBuffers[Oe.b.PositionKind];
+ e && e._rebuild(), this._createIndexBuffer(), this.refreshRate === on.REFRESHRATE_RENDER_ONCE && (this.refreshRate = on.REFRESHRATE_RENDER_ONCE);
+ }, t.prototype.reset = function() {
+ this._effect !== void 0 && this._effect.dispose();
+ }, t.prototype._getDefines = function() {
+ return "";
+ }, t.prototype.isReady = function() {
+ var e, n = this, i = this._fullEngine;
+ if (this.nodeMaterialSource)
+ return this._effect.isReady();
+ if (!this._fragment)
+ return !1;
+ if (this._fallbackTextureUsed)
+ return !0;
+ var o = this._getDefines();
+ return !(!this._effect || o !== this._cachedDefines || !this._effect.isReady()) || (e = this._fragment.fragmentElement !== void 0 ? { vertex: "procedural", fragmentElement: this._fragment.fragmentElement } : { vertex: "procedural", fragment: this._fragment }, this._cachedDefines = o, this._effect = i.createEffect(e, [Oe.b.PositionKind], this._uniforms, this._samplers, o, void 0, void 0, function() {
+ n.releaseInternalTexture(), n._fallbackTexture && (n._texture = n._fallbackTexture._texture, n._texture && n._texture.incrementReferences()), n._fallbackTextureUsed = !0;
+ }), this._effect.isReady());
+ }, t.prototype.resetRefreshCounter = function() {
+ this._currentRefreshId = -1;
+ }, t.prototype.setFragment = function(e) {
+ this._fragment = e;
+ }, Object.defineProperty(t.prototype, "refreshRate", { get: function() {
+ return this._refreshRate;
+ }, set: function(e) {
+ this._refreshRate = e, this.resetRefreshCounter();
+ }, enumerable: !1, configurable: !0 }), t.prototype._shouldRender = function() {
+ return this.isEnabled && this.isReady() && this._texture ? !this._fallbackTextureUsed && (this._currentRefreshId === -1 || this.refreshRate === this._currentRefreshId ? (this._currentRefreshId = 1, this._frameId++, !0) : (this._currentRefreshId++, !1)) : (this._texture && (this._texture.isReady = !1), !1);
+ }, t.prototype.getRenderSize = function() {
+ return this._size;
+ }, t.prototype.resize = function(e, n) {
+ this._fallbackTextureUsed || (this.releaseInternalTexture(), this._texture = this._fullEngine.createRenderTargetTexture(e, n), this._size = e, this._generateMipMaps = n);
+ }, t.prototype._checkUniform = function(e) {
+ this._uniforms.indexOf(e) === -1 && this._uniforms.push(e);
+ }, t.prototype.setTexture = function(e, n) {
+ return this._samplers.indexOf(e) === -1 && this._samplers.push(e), this._textures[e] = n, this;
+ }, t.prototype.setFloat = function(e, n) {
+ return this._checkUniform(e), this._floats[e] = n, this;
+ }, t.prototype.setInt = function(e, n) {
+ return this._checkUniform(e), this._ints[e] = n, this;
+ }, t.prototype.setFloats = function(e, n) {
+ return this._checkUniform(e), this._floatsArrays[e] = n, this;
+ }, t.prototype.setColor3 = function(e, n) {
+ return this._checkUniform(e), this._colors3[e] = n, this;
+ }, t.prototype.setColor4 = function(e, n) {
+ return this._checkUniform(e), this._colors4[e] = n, this;
+ }, t.prototype.setVector2 = function(e, n) {
+ return this._checkUniform(e), this._vectors2[e] = n, this;
+ }, t.prototype.setVector3 = function(e, n) {
+ return this._checkUniform(e), this._vectors3[e] = n, this;
+ }, t.prototype.setMatrix = function(e, n) {
+ return this._checkUniform(e), this._matrices[e] = n, this;
+ }, t.prototype.render = function(e) {
+ var n = this.getScene();
+ if (n) {
+ var i = this._fullEngine;
+ if (i.enableEffect(this._effect), this.onBeforeGenerationObservable.notifyObservers(this), i.setState(!1), !this.nodeMaterialSource) {
+ for (var o in this._textures)
+ this._effect.setTexture(o, this._textures[o]);
+ for (o in this._ints)
+ this._effect.setInt(o, this._ints[o]);
+ for (o in this._floats)
+ this._effect.setFloat(o, this._floats[o]);
+ for (o in this._floatsArrays)
+ this._effect.setArray(o, this._floatsArrays[o]);
+ for (o in this._colors3)
+ this._effect.setColor3(o, this._colors3[o]);
+ for (o in this._colors4) {
+ var a = this._colors4[o];
+ this._effect.setFloat4(o, a.r, a.g, a.b, a.a);
+ }
+ for (o in this._vectors2)
+ this._effect.setVector2(o, this._vectors2[o]);
+ for (o in this._vectors3)
+ this._effect.setVector3(o, this._vectors3[o]);
+ for (o in this._matrices)
+ this._effect.setMatrix(o, this._matrices[o]);
+ }
+ if (this._texture) {
+ if (this.isCube)
+ for (var s = 0; s < 6; s++)
+ i.bindFramebuffer(this._texture, s, void 0, void 0, !0), i.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect), this._effect.setFloat("face", s), this.autoClear && i.clear(n.clearColor, !0, !1, !1), i.drawElementsType(zt.a.TriangleFillMode, 0, 6), s === 5 && i.generateMipMapsForCubemap(this._texture);
+ else
+ i.bindFramebuffer(this._texture, 0, void 0, void 0, !0), i.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect), this.autoClear && i.clear(n.clearColor, !0, !1, !1), i.drawElementsType(zt.a.TriangleFillMode, 0, 6);
+ i.unBindFramebuffer(this._texture, this.isCube), this.onGenerated && this.onGenerated(), this.onGeneratedObservable.notifyObservers(this);
+ }
+ }
+ }, t.prototype.clone = function() {
+ var e = this.getSize(), n = new t(this.name, e.width, this._fragment, this.getScene(), this._fallbackTexture, this._generateMipMaps);
+ return n.hasAlpha = this.hasAlpha, n.level = this.level, n.coordinatesMode = this.coordinatesMode, n;
+ }, t.prototype.dispose = function() {
+ var e = this.getScene();
+ if (e) {
+ var n = e.proceduralTextures.indexOf(this);
+ n >= 0 && e.proceduralTextures.splice(n, 1);
+ var i = this._vertexBuffers[Oe.b.PositionKind];
+ i && (i.dispose(), this._vertexBuffers[Oe.b.PositionKind] = null), this._indexBuffer && this._fullEngine._releaseBuffer(this._indexBuffer) && (this._indexBuffer = null), this.onGeneratedObservable.clear(), this.onBeforeGenerationObservable.clear(), r.prototype.dispose.call(this);
+ }
+ }, Object(c.c)([Object(L.c)()], t.prototype, "isEnabled", void 0), Object(c.c)([Object(L.c)()], t.prototype, "autoClear", void 0), Object(c.c)([Object(L.c)()], t.prototype, "_generateMipMaps", void 0), Object(c.c)([Object(L.c)()], t.prototype, "_size", void 0), Object(c.c)([Object(L.c)()], t.prototype, "refreshRate", null), t;
+ }(Ne.a);
+ O.a.RegisteredTypes["BABYLON.ProceduralTexture"] = oo;
+ var N_ = function(r) {
+ function t(e, n, i, o, a, s) {
+ var d = r.call(this, e, i, null, o, a, s) || this;
+ return d._animate = !0, d._time = 0, d._texturePath = n, d._loadJson(n), d.refreshRate = 1, d;
+ }
+ return Object(c.d)(t, r), t.prototype._loadJson = function(e) {
+ var n = this, i = function() {
+ try {
+ n.setFragment(n._texturePath);
+ } catch {
+ l.a.Error("No json or ShaderStore or DOM element found for CustomProceduralTexture");
+ }
+ }, o = e + "/config.json", a = new re.a();
+ a.open("GET", o), a.addEventListener("load", function() {
+ if (a.status === 200 || a.responseText && a.responseText.length > 0)
+ try {
+ n._config = JSON.parse(a.response), n.updateShaderUniforms(), n.updateTextures(), n.setFragment(n._texturePath + "/custom"), n._animate = n._config.animate, n.refreshRate = n._config.refreshrate;
+ } catch {
+ i();
+ }
+ else
+ i();
+ }, !1), a.addEventListener("error", function() {
+ i();
+ }, !1);
+ try {
+ a.send();
+ } catch {
+ l.a.Error("CustomProceduralTexture: Error on XHR send request.");
+ }
+ }, t.prototype.isReady = function() {
+ if (!r.prototype.isReady.call(this))
+ return !1;
+ for (var e in this._textures)
+ if (!this._textures[e].isReady())
+ return !1;
+ return !0;
+ }, t.prototype.render = function(e) {
+ var n = this.getScene();
+ this._animate && n && (this._time += 0.03 * n.getAnimationRatio(), this.updateShaderUniforms()), r.prototype.render.call(this, e);
+ }, t.prototype.updateTextures = function() {
+ for (var e = 0; e < this._config.sampler2Ds.length; e++)
+ this.setTexture(this._config.sampler2Ds[e].sample2Dname, new Ne.a(this._texturePath + "/" + this._config.sampler2Ds[e].textureRelativeUrl, this.getScene()));
+ }, t.prototype.updateShaderUniforms = function() {
+ if (this._config)
+ for (var e = 0; e < this._config.uniforms.length; e++) {
+ var n = this._config.uniforms[e];
+ switch (n.type) {
+ case "float":
+ this.setFloat(n.name, n.value);
+ break;
+ case "color3":
+ this.setColor3(n.name, new I.a(n.r, n.g, n.b));
+ break;
+ case "color4":
+ this.setColor4(n.name, new I.b(n.r, n.g, n.b, n.a));
+ break;
+ case "vector2":
+ this.setVector2(n.name, new u.d(n.x, n.y));
+ break;
+ case "vector3":
+ this.setVector3(n.name, new u.e(n.x, n.y, n.z));
+ }
+ }
+ this.setFloat("time", this._time);
+ }, Object.defineProperty(t.prototype, "animate", { get: function() {
+ return this._animate;
+ }, set: function(e) {
+ this._animate = e;
+ }, enumerable: !1, configurable: !0 }), t;
+ }(oo), w_ = `
+
+uniform float brightness;
+uniform float persistence;
+uniform float timeScale;
+
+varying vec2 vUV;
+
+vec2 hash22(vec2 p)
+{
+p=p*mat2(127.1,311.7,269.5,183.3);
+p=-1.0+2.0*fract(sin(p)*43758.5453123);
+return sin(p*6.283+timeScale);
+}
+float interpolationNoise(vec2 p)
+{
+vec2 pi=floor(p);
+vec2 pf=p-pi;
+vec2 w=pf*pf*(3.-2.*pf);
+float f00=dot(hash22(pi+vec2(.0,.0)),pf-vec2(.0,.0));
+float f01=dot(hash22(pi+vec2(.0,1.)),pf-vec2(.0,1.));
+float f10=dot(hash22(pi+vec2(1.0,0.)),pf-vec2(1.0,0.));
+float f11=dot(hash22(pi+vec2(1.0,1.)),pf-vec2(1.0,1.));
+float xm1=mix(f00,f10,w.x);
+float xm2=mix(f01,f11,w.x);
+float ym=mix(xm1,xm2,w.y);
+return ym;
+}
+float perlinNoise2D(float x,float y)
+{
+float sum=0.0;
+float frequency=0.0;
+float amplitude=0.0;
+for(int i=0; i 0;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "isConnectedInVertexShader", { get: function() {
+ if (this.target === Ce.Vertex)
+ return !0;
+ if (!this.hasEndpoints)
+ return !1;
+ for (var t = 0, e = this._endpoints; t < e.length; t++) {
+ var n = e[t];
+ if (n.ownerBlock.target === Ce.Vertex || n.target === Ce.Vertex || (n.ownerBlock.target === Ce.Neutral || n.ownerBlock.target === Ce.VertexAndFragment) && n.ownerBlock.outputs.some(function(i) {
+ return i.isConnectedInVertexShader;
+ }))
+ return !0;
+ }
+ return !1;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "isConnectedInFragmentShader", { get: function() {
+ if (this.target === Ce.Fragment)
+ return !0;
+ if (!this.hasEndpoints)
+ return !1;
+ for (var t = 0, e = this._endpoints; t < e.length; t++) {
+ var n = e[t];
+ if (n.ownerBlock.target === Ce.Fragment || (n.ownerBlock.target === Ce.Neutral || n.ownerBlock.target === Ce.VertexAndFragment) && n.ownerBlock.outputs.some(function(i) {
+ return i.isConnectedInFragmentShader;
+ }))
+ return !0;
+ }
+ return !1;
+ }, enumerable: !1, configurable: !0 }), r.prototype.createCustomInputBlock = function() {
+ return null;
+ }, r.prototype.getClassName = function() {
+ return "NodeMaterialConnectionPoint";
+ }, r.prototype.canConnectTo = function(t) {
+ return this.checkCompatibilityState(t) === ii.Compatible;
+ }, r.prototype.checkCompatibilityState = function(t) {
+ if (this._ownerBlock.target === Ce.Fragment) {
+ var e = t.ownerBlock;
+ if (e.target === Ce.Vertex)
+ return ii.TargetIncompatible;
+ for (var n = 0, i = e.outputs; n < i.length; n++)
+ if (i[n].isConnectedInVertexShader)
+ return ii.TargetIncompatible;
+ }
+ return this.type !== t.type && t.innerType !== le.AutoDetect ? r.AreEquivalentTypes(this.type, t.type) || t.acceptedConnectionPointTypes && t.acceptedConnectionPointTypes.indexOf(this.type) !== -1 || t._acceptedConnectionPointType && r.AreEquivalentTypes(t._acceptedConnectionPointType.type, this.type) ? ii.Compatible : ii.TypeIncompatible : t.excludedConnectionPointTypes && t.excludedConnectionPointTypes.indexOf(this.type) !== -1 ? 1 : ii.Compatible;
+ }, r.prototype.connectTo = function(t, e) {
+ if (e === void 0 && (e = !1), !e && !this.canConnectTo(t))
+ throw "Cannot connect these two connectors.";
+ return this._endpoints.push(t), t._connectedPoint = this, this._enforceAssociatedVariableName = !1, this.onConnectionObservable.notifyObservers(t), t.onConnectionObservable.notifyObservers(this), this;
+ }, r.prototype.disconnectFrom = function(t) {
+ var e = this._endpoints.indexOf(t);
+ return e === -1 || (this._endpoints.splice(e, 1), t._connectedPoint = null, this._enforceAssociatedVariableName = !1, t._enforceAssociatedVariableName = !1), this;
+ }, r.prototype.serialize = function(t) {
+ t === void 0 && (t = !0);
+ var e = {};
+ return e.name = this.name, e.displayName = this.displayName, t && this.connectedPoint && (e.inputName = this.name, e.targetBlockId = this.connectedPoint.ownerBlock.uniqueId, e.targetConnectionName = this.connectedPoint.name, e.isExposedOnFrame = !0, e.exposedPortPosition = this.exposedPortPosition), (this.isExposedOnFrame || this.exposedPortPosition >= 0) && (e.isExposedOnFrame = !0, e.exposedPortPosition = this.exposedPortPosition), e;
+ }, r.prototype.dispose = function() {
+ this.onConnectionObservable.clear();
+ }, r;
+ }(), k_ = f(152), dt = function() {
+ function r(t, e, n, i) {
+ e === void 0 && (e = Ce.Vertex), n === void 0 && (n = !1), i === void 0 && (i = !1), this._isFinalMerger = !1, this._isInput = !1, this._name = "", this._isUnique = !1, this.inputsAreExclusive = !1, this._codeVariableName = "", this._inputs = new Array(), this._outputs = new Array(), this.comments = "", this.visibleInInspector = !1, this._target = e, this._isFinalMerger = n, this._isInput = i, this._name = t, this.uniqueId = k_.a.UniqueId;
+ }
+ return Object.defineProperty(r.prototype, "name", { get: function() {
+ return this._name;
+ }, set: function(t) {
+ this.validateBlockName(t) && (this._name = t);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "isUnique", { get: function() {
+ return this._isUnique;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "isFinalMerger", { get: function() {
+ return this._isFinalMerger;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "isInput", { get: function() {
+ return this._isInput;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "buildId", { get: function() {
+ return this._buildId;
+ }, set: function(t) {
+ this._buildId = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "target", { get: function() {
+ return this._target;
+ }, set: function(t) {
+ !(this._target & t) && (this._target = t);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "inputs", { get: function() {
+ return this._inputs;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "outputs", { get: function() {
+ return this._outputs;
+ }, enumerable: !1, configurable: !0 }), r.prototype.getInputByName = function(t) {
+ var e = this._inputs.filter(function(n) {
+ return n.name === t;
+ });
+ return e.length ? e[0] : null;
+ }, r.prototype.getOutputByName = function(t) {
+ var e = this._outputs.filter(function(n) {
+ return n.name === t;
+ });
+ return e.length ? e[0] : null;
+ }, r.prototype.initialize = function(t) {
+ }, r.prototype.bind = function(t, e, n, i) {
+ }, r.prototype._declareOutput = function(t, e) {
+ return e._getGLType(t.type) + " " + t.associatedVariableName;
+ }, r.prototype._writeVariable = function(t) {
+ return t.connectedPoint ? "" + t.associatedVariableName : "0.";
+ }, r.prototype._writeFloat = function(t) {
+ var e = t.toString();
+ return e.indexOf(".") === -1 && (e += ".0"), "" + e;
+ }, r.prototype.getClassName = function() {
+ return "NodeMaterialBlock";
+ }, r.prototype.registerInput = function(t, e, n, i, o) {
+ return n === void 0 && (n = !1), (o = o ?? new na(t, this, yn.Input)).type = e, o.isOptional = n, i && (o.target = i), this._inputs.push(o), this;
+ }, r.prototype.registerOutput = function(t, e, n, i) {
+ return (i = i ?? new na(t, this, yn.Output)).type = e, n && (i.target = n), this._outputs.push(i), this;
+ }, r.prototype.getFirstAvailableInput = function(t) {
+ t === void 0 && (t = null);
+ for (var e = 0, n = this._inputs; e < n.length; e++) {
+ var i = n[e];
+ if (!(i.connectedPoint || t && t.type !== i.type && i.type !== le.AutoDetect))
+ return i;
+ }
+ return null;
+ }, r.prototype.getFirstAvailableOutput = function(t) {
+ t === void 0 && (t = null);
+ for (var e = 0, n = this._outputs; e < n.length; e++) {
+ var i = n[e];
+ if (!t || !t.target || t.target === Ce.Neutral || t.target & i.target)
+ return i;
+ }
+ return null;
+ }, r.prototype.getSiblingOutput = function(t) {
+ var e = this._outputs.indexOf(t);
+ return e === -1 || e >= this._outputs.length ? null : this._outputs[e + 1];
+ }, r.prototype.connectTo = function(t, e) {
+ if (this._outputs.length !== 0) {
+ for (var n = e && e.output ? this.getOutputByName(e.output) : this.getFirstAvailableOutput(t), i = !0; i; ) {
+ var o = e && e.input ? t.getInputByName(e.input) : t.getFirstAvailableInput(n);
+ if (n && o && n.canConnectTo(o))
+ n.connectTo(o), i = !1;
+ else {
+ if (!n)
+ throw "Unable to find a compatible match";
+ n = this.getSiblingOutput(n);
+ }
+ }
+ return this;
+ }
+ }, r.prototype._buildBlock = function(t) {
+ }, r.prototype.updateUniformsAndSamples = function(t, e, n, i) {
+ }, r.prototype.provideFallbacks = function(t, e) {
+ }, r.prototype.initializeDefines = function(t, e, n, i) {
+ }, r.prototype.prepareDefines = function(t, e, n, i, o) {
+ }, r.prototype.autoConfigure = function(t) {
+ }, r.prototype.replaceRepeatableContent = function(t, e, n, i) {
+ }, r.prototype.isReady = function(t, e, n, i) {
+ return !0;
+ }, r.prototype._linkConnectionTypes = function(t, e, n) {
+ n === void 0 && (n = !1), n ? this._inputs[e]._acceptedConnectionPointType = this._inputs[t] : this._inputs[t]._linkedConnectionSource = this._inputs[e], this._inputs[e]._linkedConnectionSource = this._inputs[t];
+ }, r.prototype._processBuild = function(t, e, n, i) {
+ t.build(e, i);
+ var o = e._vertexState != null, a = t._buildTarget === Ce.Vertex && t.target !== Ce.VertexAndFragment;
+ if (o && (!(t.target & t._buildTarget) || !(t.target & n.target) || this.target !== Ce.VertexAndFragment && a) && (!t.isInput && e.target !== t._buildTarget || t.isInput && t.isAttribute && !t._noContextSwitch)) {
+ var s = n.connectedPoint;
+ e._vertexState._emitVaryingFromString("v_" + s.associatedVariableName, e._getGLType(s.type)) && (e._vertexState.compilationString += "v_" + s.associatedVariableName + " = " + s.associatedVariableName + `;\r
+`), n.associatedVariableName = "v_" + s.associatedVariableName, n._enforceAssociatedVariableName = !0;
+ }
+ }, r.prototype.validateBlockName = function(t) {
+ for (var e = 0, n = ["position", "normal", "tangent", "particle_positionw", "uv", "uv2", "position2d", "particle_uv", "matricesIndices", "matricesWeights", "world0", "world1", "world2", "world3", "particle_color", "particle_texturemask"]; e < n.length; e++)
+ if (t === n[e])
+ return !1;
+ return !0;
+ }, r.prototype.build = function(t, e) {
+ if (this._buildId === t.sharedData.buildId)
+ return !0;
+ if (!this.isInput)
+ for (var n = 0, i = this._outputs; n < i.length; n++)
+ (y = i[n]).associatedVariableName || (y.associatedVariableName = t._getFreeVariableName(y.name));
+ for (var o = 0, a = this._inputs; o < a.length; o++) {
+ var s = a[o];
+ if (s.connectedPoint) {
+ if (this.target !== Ce.Neutral && (!(s.target & this.target) || !(s.target & t.target)))
+ continue;
+ (B = s.connectedPoint.ownerBlock) && B !== this && this._processBuild(B, t, s, e);
+ } else
+ s.isOptional || t.sharedData.checks.notConnectedNonOptionalInputs.push(s);
+ }
+ if (this._buildId === t.sharedData.buildId)
+ return !0;
+ if (t.sharedData.verbose && console.log((t.target === Ce.Vertex ? "Vertex shader" : "Fragment shader") + ": Building " + this.name + " [" + this.getClassName() + "]"), this.isFinalMerger)
+ switch (t.target) {
+ case Ce.Vertex:
+ t.sharedData.checks.emitVertex = !0;
+ break;
+ case Ce.Fragment:
+ t.sharedData.checks.emitFragment = !0;
+ }
+ !this.isInput && t.sharedData.emitComments && (t.compilationString += `\r
+//` + this.name + `\r
+`), this._buildBlock(t), this._buildId = t.sharedData.buildId, this._buildTarget = t.target;
+ for (var d = 0, p = this._outputs; d < p.length; d++) {
+ var y;
+ if ((y = p[d]).target & t.target)
+ for (var P = 0, R = y.endpoints; P < R.length; P++) {
+ var B, F = R[P];
+ (B = F.ownerBlock) && B.target & t.target && e.indexOf(B) !== -1 && this._processBuild(B, t, F, e);
+ }
+ }
+ return !1;
+ }, r.prototype._inputRename = function(t) {
+ return t;
+ }, r.prototype._outputRename = function(t) {
+ return t;
+ }, r.prototype._dumpPropertiesCode = function() {
+ return this._codeVariableName + ".visibleInInspector = " + this.visibleInInspector + `;\r
+`;
+ }, r.prototype._dumpCode = function(t, e) {
+ var n;
+ e.push(this);
+ var i = this.name.replace(/[^A-Za-z_]+/g, "");
+ if (this._codeVariableName = i || this.getClassName() + "_" + this.uniqueId, t.indexOf(this._codeVariableName) !== -1) {
+ var o = 0;
+ do
+ o++, this._codeVariableName = i + o;
+ while (t.indexOf(this._codeVariableName) !== -1);
+ }
+ t.push(this._codeVariableName), n = `\r
+// ` + this.getClassName() + `\r
+`, this.comments && (n += "// " + this.comments + `\r
+`), n += "var " + this._codeVariableName + " = new BABYLON." + this.getClassName() + '("' + this.name + `");\r
+`, n += this._dumpPropertiesCode();
+ for (var a = 0, s = this.inputs; a < s.length; a++) {
+ var d = s[a];
+ if (d.isConnected) {
+ var p = d.connectedPoint.ownerBlock;
+ e.indexOf(p) === -1 && (n += p._dumpCode(t, e));
+ }
+ }
+ for (var y = 0, P = this.outputs; y < P.length; y++) {
+ var R = P[y];
+ if (R.hasEndpoints)
+ for (var B = 0, F = R.endpoints; B < F.length; B++)
+ (p = F[B].ownerBlock) && e.indexOf(p) === -1 && (n += p._dumpCode(t, e));
+ }
+ return n;
+ }, r.prototype._dumpCodeForOutputConnections = function(t) {
+ var e = "";
+ if (t.indexOf(this) !== -1)
+ return e;
+ t.push(this);
+ for (var n = 0, i = this.inputs; n < i.length; n++) {
+ var o = i[n];
+ if (o.isConnected) {
+ var a = o.connectedPoint, s = a.ownerBlock;
+ e += s._dumpCodeForOutputConnections(t), e += s._codeVariableName + "." + s._outputRename(a.name) + ".connectTo(" + this._codeVariableName + "." + this._inputRename(o.name) + `);\r
+`;
+ }
+ }
+ return e;
+ }, r.prototype.clone = function(t, e) {
+ e === void 0 && (e = "");
+ var n = this.serialize(), i = O.a.GetClass(n.customType);
+ if (i) {
+ var o = new i();
+ return o._deserialize(n, t, e), o;
+ }
+ return null;
+ }, r.prototype.serialize = function() {
+ var t = {};
+ t.customType = "BABYLON." + this.getClassName(), t.id = this.uniqueId, t.name = this.name, t.comments = this.comments, t.visibleInInspector = this.visibleInInspector, t.inputs = [], t.outputs = [];
+ for (var e = 0, n = this.inputs; e < n.length; e++) {
+ var i = n[e];
+ t.inputs.push(i.serialize());
+ }
+ for (var o = 0, a = this.outputs; o < a.length; o++) {
+ var s = a[o];
+ t.outputs.push(s.serialize(!1));
+ }
+ return t;
+ }, r.prototype._deserialize = function(t, e, n) {
+ this.name = t.name, this.comments = t.comments, this.visibleInInspector = !!t.visibleInInspector, this._deserializePortDisplayNamesAndExposedOnFrame(t);
+ }, r.prototype._deserializePortDisplayNamesAndExposedOnFrame = function(t) {
+ var e = this, n = t.inputs, i = t.outputs;
+ n && n.forEach(function(o, a) {
+ o.displayName && (e.inputs[a].displayName = o.displayName), o.isExposedOnFrame && (e.inputs[a].isExposedOnFrame = o.isExposedOnFrame, e.inputs[a].exposedPortPosition = o.exposedPortPosition);
+ }), i && i.forEach(function(o, a) {
+ o.displayName && (e.outputs[a].displayName = o.displayName), o.isExposedOnFrame && (e.outputs[a].isExposedOnFrame = o.isExposedOnFrame, e.outputs[a].exposedPortPosition = o.exposedPortPosition);
+ });
+ }, r.prototype.dispose = function() {
+ for (var t = 0, e = this.inputs; t < e.length; t++)
+ e[t].dispose();
+ for (var n = 0, i = this.outputs; n < i.length; n++)
+ i[n].dispose();
+ }, r;
+ }(), Xu = function() {
+ function r() {
+ this.supportUniformBuffers = !1, this.attributes = new Array(), this.uniforms = new Array(), this.constants = new Array(), this.samplers = new Array(), this.functions = {}, this.extensions = {}, this.counters = {}, this._attributeDeclaration = "", this._uniformDeclaration = "", this._constantDeclaration = "", this._samplerDeclaration = "", this._varyingTransfer = "", this._injectAtEnd = "", this._repeatableContentAnchorIndex = 0, this._builtCompilationString = "", this.compilationString = "";
+ }
+ return r.prototype.finalize = function(t) {
+ var e = t.sharedData.emitComments, n = this.target === Ce.Fragment;
+ this.compilationString = `\r
+` + (e ? `//Entry point\r
+` : "") + `void main(void) {\r
+` + this.compilationString, this._constantDeclaration && (this.compilationString = `\r
+` + (e ? `//Constants\r
+` : "") + this._constantDeclaration + `\r
+` + this.compilationString);
+ var i = "";
+ for (var o in this.functions)
+ i += this.functions[o] + `\r
+`;
+ for (var a in this.compilationString = `\r
+` + i + `\r
+` + this.compilationString, !n && this._varyingTransfer && (this.compilationString = this.compilationString + `\r
+` + this._varyingTransfer), this._injectAtEnd && (this.compilationString = this.compilationString + `\r
+` + this._injectAtEnd), this.compilationString = this.compilationString + `\r
+}`, this.sharedData.varyingDeclaration && (this.compilationString = `\r
+` + (e ? `//Varyings\r
+` : "") + this.sharedData.varyingDeclaration + `\r
+` + this.compilationString), this._samplerDeclaration && (this.compilationString = `\r
+` + (e ? `//Samplers\r
+` : "") + this._samplerDeclaration + `\r
+` + this.compilationString), this._uniformDeclaration && (this.compilationString = `\r
+` + (e ? `//Uniforms\r
+` : "") + this._uniformDeclaration + `\r
+` + this.compilationString), this._attributeDeclaration && !n && (this.compilationString = `\r
+` + (e ? `//Attributes\r
+` : "") + this._attributeDeclaration + `\r
+` + this.compilationString), this.compilationString = `precision highp float;\r
+` + this.compilationString, this.extensions) {
+ var s = this.extensions[a];
+ this.compilationString = `\r
+` + s + `\r
+` + this.compilationString;
+ }
+ this._builtCompilationString = this.compilationString;
+ }, Object.defineProperty(r.prototype, "_repeatableContentAnchor", { get: function() {
+ return "###___ANCHOR" + this._repeatableContentAnchorIndex++ + "___###";
+ }, enumerable: !1, configurable: !0 }), r.prototype._getFreeVariableName = function(t) {
+ return t = t.replace(/[^a-zA-Z_]+/g, ""), this.sharedData.variableNames[t] === void 0 ? (this.sharedData.variableNames[t] = 0, t === "output" || t === "texture" ? t + this.sharedData.variableNames[t] : t) : (this.sharedData.variableNames[t]++, t + this.sharedData.variableNames[t]);
+ }, r.prototype._getFreeDefineName = function(t) {
+ return this.sharedData.defineNames[t] === void 0 ? this.sharedData.defineNames[t] = 0 : this.sharedData.defineNames[t]++, t + this.sharedData.defineNames[t];
+ }, r.prototype._excludeVariableName = function(t) {
+ this.sharedData.variableNames[t] = 0;
+ }, r.prototype._emit2DSampler = function(t) {
+ this.samplers.indexOf(t) < 0 && (this._samplerDeclaration += "uniform sampler2D " + t + `;\r
+`, this.samplers.push(t));
+ }, r.prototype._getGLType = function(t) {
+ switch (t) {
+ case le.Float:
+ return "float";
+ case le.Int:
+ return "int";
+ case le.Vector2:
+ return "vec2";
+ case le.Color3:
+ case le.Vector3:
+ return "vec3";
+ case le.Color4:
+ case le.Vector4:
+ return "vec4";
+ case le.Matrix:
+ return "mat4";
+ }
+ return "";
+ }, r.prototype._emitExtension = function(t, e, n) {
+ n === void 0 && (n = ""), this.extensions[t] || (n && (e = "#if " + n + `\r
+` + e + `\r
+#endif`), this.extensions[t] = e);
+ }, r.prototype._emitFunction = function(t, e, n) {
+ this.functions[t] || (this.sharedData.emitComments && (e = n + `\r
+` + e), this.functions[t] = e);
+ }, r.prototype._emitCodeFromInclude = function(t, e, n) {
+ if (n && n.repeatKey)
+ return "#include<" + t + ">[0.." + n.repeatKey + `]\r
+`;
+ var i = ze.a.IncludesShadersStore[t] + `\r
+`;
+ if (this.sharedData.emitComments && (i = e + `\r
+` + i), !n)
+ return i;
+ if (n.replaceStrings)
+ for (var o = 0; o < n.replaceStrings.length; o++) {
+ var a = n.replaceStrings[o];
+ i = i.replace(a.search, a.replace);
+ }
+ return i;
+ }, r.prototype._emitFunctionFromInclude = function(t, e, n, i) {
+ i === void 0 && (i = "");
+ var o = t + i;
+ if (!this.functions[o]) {
+ if (!(n && (n.removeAttributes || n.removeUniforms || n.removeVaryings || n.removeIfDef || n.replaceStrings)))
+ return n && n.repeatKey ? this.functions[o] = "#include<" + t + ">[0.." + n.repeatKey + `]\r
+` : this.functions[o] = "#include<" + t + `>\r
+`, void (this.sharedData.emitComments && (this.functions[o] = e + `\r
+` + this.functions[o]));
+ if (this.functions[o] = ze.a.IncludesShadersStore[t], this.sharedData.emitComments && (this.functions[o] = e + `\r
+` + this.functions[o]), n.removeIfDef && (this.functions[o] = this.functions[o].replace(/^\s*?#ifdef.+$/gm, ""), this.functions[o] = this.functions[o].replace(/^\s*?#endif.*$/gm, ""), this.functions[o] = this.functions[o].replace(/^\s*?#else.*$/gm, ""), this.functions[o] = this.functions[o].replace(/^\s*?#elif.*$/gm, "")), n.removeAttributes && (this.functions[o] = this.functions[o].replace(/^\s*?attribute.+$/gm, "")), n.removeUniforms && (this.functions[o] = this.functions[o].replace(/^\s*?uniform.+$/gm, "")), n.removeVaryings && (this.functions[o] = this.functions[o].replace(/^\s*?varying.+$/gm, "")), n.replaceStrings)
+ for (var a = 0; a < n.replaceStrings.length; a++) {
+ var s = n.replaceStrings[a];
+ this.functions[o] = this.functions[o].replace(s.search, s.replace);
+ }
+ }
+ }, r.prototype._registerTempVariable = function(t) {
+ return this.sharedData.temps.indexOf(t) === -1 && (this.sharedData.temps.push(t), !0);
+ }, r.prototype._emitVaryingFromString = function(t, e, n, i) {
+ return n === void 0 && (n = ""), i === void 0 && (i = !1), this.sharedData.varyings.indexOf(t) === -1 && (this.sharedData.varyings.push(t), n && (Hn.a.StartsWith(n, "defined(") ? this.sharedData.varyingDeclaration += "#if " + n + `\r
+` : this.sharedData.varyingDeclaration += (i ? "#ifndef" : "#ifdef") + " " + n + `\r
+`), this.sharedData.varyingDeclaration += "varying " + e + " " + t + `;\r
+`, n && (this.sharedData.varyingDeclaration += `#endif\r
+`), !0);
+ }, r.prototype._emitUniformFromString = function(t, e, n, i) {
+ n === void 0 && (n = ""), i === void 0 && (i = !1), this.uniforms.indexOf(t) === -1 && (this.uniforms.push(t), n && (Hn.a.StartsWith(n, "defined(") ? this._uniformDeclaration += "#if " + n + `\r
+` : this._uniformDeclaration += (i ? "#ifndef" : "#ifdef") + " " + n + `\r
+`), this._uniformDeclaration += "uniform " + e + " " + t + `;\r
+`, n && (this._uniformDeclaration += `#endif\r
+`));
+ }, r.prototype._emitFloat = function(t) {
+ return t.toString() === t.toFixed(0) ? t + ".0" : t.toString();
+ }, r;
+ }(), G_ = function() {
+ function r() {
+ this.temps = new Array(), this.varyings = new Array(), this.varyingDeclaration = "", this.inputBlocks = new Array(), this.textureBlocks = new Array(), this.bindableBlocks = new Array(), this.blocksWithFallbacks = new Array(), this.blocksWithDefines = new Array(), this.repeatableContentBlocks = new Array(), this.dynamicUniformBlocks = new Array(), this.blockingBlocks = new Array(), this.animatedInputs = new Array(), this.variableNames = {}, this.defineNames = {}, this.hints = { needWorldViewMatrix: !1, needWorldViewProjectionMatrix: !1, needAlphaBlending: !1, needAlphaTesting: !1 }, this.checks = { emitVertex: !1, emitFragment: !1, notConnectedNonOptionalInputs: new Array() }, this.allowEmptyVertexProgram = !1, this.variableNames.position = 0, this.variableNames.normal = 0, this.variableNames.tangent = 0, this.variableNames.uv = 0, this.variableNames.uv2 = 0, this.variableNames.uv3 = 0, this.variableNames.uv4 = 0, this.variableNames.uv4 = 0, this.variableNames.uv5 = 0, this.variableNames.uv6 = 0, this.variableNames.color = 0, this.variableNames.matricesIndices = 0, this.variableNames.matricesWeights = 0, this.variableNames.matricesIndicesExtra = 0, this.variableNames.matricesWeightsExtra = 0, this.variableNames.diffuseBase = 0, this.variableNames.specularBase = 0, this.variableNames.worldPos = 0, this.variableNames.shadow = 0, this.variableNames.view = 0, this.variableNames.vTBN = 0, this.defineNames.MAINUV0 = 0, this.defineNames.MAINUV1 = 0, this.defineNames.MAINUV2 = 0, this.defineNames.MAINUV3 = 0, this.defineNames.MAINUV4 = 0, this.defineNames.MAINUV5 = 0, this.defineNames.MAINUV6 = 0, this.defineNames.MAINUV7 = 0;
+ }
+ return r.prototype.emitErrors = function() {
+ var t = "";
+ this.checks.emitVertex || this.allowEmptyVertexProgram || (t += `NodeMaterial does not have a vertex output. You need to at least add a block that generates a glPosition value.\r
+`), this.checks.emitFragment || (t += `NodeMaterial does not have a fragment output. You need to at least add a block that generates a glFragColor value.\r
+`);
+ for (var e = 0, n = this.checks.notConnectedNonOptionalInputs; e < n.length; e++) {
+ var i = n[e];
+ t += "input " + i.name + " from block " + i.ownerBlock.name + "[" + i.ownerBlock.getClassName() + `] is not connected and is not optional.\r
+`;
+ }
+ if (t)
+ throw `Build of NodeMaterial failed:\r
+` + t;
+ }, r;
+ }(), ia = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Vertex) || this;
+ return n.complementW = 1, n.complementZ = 0, n.registerInput("vector", le.AutoDetect), n.registerInput("transform", le.Matrix), n.registerOutput("output", le.Vector4), n.registerOutput("xyz", le.Vector3), n._inputs[0].onConnectionObservable.add(function(i) {
+ if (i.ownerBlock.isInput) {
+ var o = i.ownerBlock;
+ o.name !== "normal" && o.name !== "tangent" || (n.complementW = 0);
+ }
+ }), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "TransformBlock";
+ }, Object.defineProperty(t.prototype, "vector", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xyz", { get: function() {
+ return this._outputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "transform", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this.vector, i = this.transform;
+ if (n.connectedPoint) {
+ if (this.complementW === 0) {
+ var o = "//" + this.name;
+ e._emitFunctionFromInclude("helperFunctions", o), e.sharedData.blocksWithDefines.push(this);
+ var a = e._getFreeVariableName(i.associatedVariableName + "_NUS");
+ switch (e.compilationString += "mat3 " + a + " = mat3(" + i.associatedVariableName + `);\r
+`, e.compilationString += `#ifdef NONUNIFORMSCALING\r
+`, e.compilationString += a + " = transposeMat3(inverseMat3(" + a + `));\r
+`, e.compilationString += `#endif\r
+`, n.connectedPoint.type) {
+ case le.Vector2:
+ e.compilationString += this._declareOutput(this.output, e) + " = vec4(" + a + " * vec3(" + n.associatedVariableName + ", " + this._writeFloat(this.complementZ) + "), " + this._writeFloat(this.complementW) + `);\r
+`;
+ break;
+ case le.Vector3:
+ case le.Color3:
+ e.compilationString += this._declareOutput(this.output, e) + " = vec4(" + a + " * " + n.associatedVariableName + ", " + this._writeFloat(this.complementW) + `);\r
+`;
+ break;
+ default:
+ e.compilationString += this._declareOutput(this.output, e) + " = vec4(" + a + " * " + n.associatedVariableName + ".xyz, " + this._writeFloat(this.complementW) + `);\r
+`;
+ }
+ } else
+ switch (a = i.associatedVariableName, n.connectedPoint.type) {
+ case le.Vector2:
+ e.compilationString += this._declareOutput(this.output, e) + " = " + a + " * vec4(" + n.associatedVariableName + ", " + this._writeFloat(this.complementZ) + ", " + this._writeFloat(this.complementW) + `);\r
+`;
+ break;
+ case le.Vector3:
+ case le.Color3:
+ e.compilationString += this._declareOutput(this.output, e) + " = " + a + " * vec4(" + n.associatedVariableName + ", " + this._writeFloat(this.complementW) + `);\r
+`;
+ break;
+ default:
+ e.compilationString += this._declareOutput(this.output, e) + " = " + a + " * " + n.associatedVariableName + `;\r
+`;
+ }
+ this.xyz.hasEndpoints && (e.compilationString += this._declareOutput(this.xyz, e) + " = " + this.output.associatedVariableName + `.xyz;\r
+`);
+ }
+ return this;
+ }, t.prototype.prepareDefines = function(e, n, i, o, a) {
+ e.nonUniformScaling && i.setValue("NONUNIFORMSCALING", !0);
+ }, t.prototype.serialize = function() {
+ var e = r.prototype.serialize.call(this);
+ return e.complementZ = this.complementZ, e.complementW = this.complementW, e;
+ }, t.prototype._deserialize = function(e, n, i) {
+ r.prototype._deserialize.call(this, e, n, i), this.complementZ = e.complementZ !== void 0 ? e.complementZ : 0, this.complementW = e.complementW !== void 0 ? e.complementW : 1;
+ }, t.prototype._dumpPropertiesCode = function() {
+ var e = this._codeVariableName + ".complementZ = " + this.complementZ + `;\r
+`;
+ return e += this._codeVariableName + ".complementW = " + this.complementW + `;\r
+`;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.TransformBlock"] = ia;
+ var ao = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Vertex, !0) || this;
+ return n.registerInput("vector", le.Vector4), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "VertexOutputBlock";
+ }, Object.defineProperty(t.prototype, "vector", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this.vector;
+ return e.compilationString += "gl_Position = " + n.associatedVariableName + `;\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.VertexOutputBlock"] = ao;
+ var Ni, Pr = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Fragment, !0) || this;
+ return n.registerInput("rgba", le.Color4, !0), n.registerInput("rgb", le.Color3, !0), n.registerInput("a", le.Float, !0), n.rgb.acceptedConnectionPointTypes.push(le.Float), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "FragmentOutputBlock";
+ }, Object.defineProperty(t.prototype, "rgba", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgb", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "a", { get: function() {
+ return this._inputs[2];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this.rgba, i = this.rgb, o = this.a;
+ if (e.sharedData.hints.needAlphaBlending = n.isConnected || o.isConnected, n.connectedPoint)
+ o.isConnected ? e.compilationString += "gl_FragColor = vec4(" + n.associatedVariableName + ".rgb, " + o.associatedVariableName + `);\r
+` : e.compilationString += "gl_FragColor = " + n.associatedVariableName + `;\r
+`;
+ else if (i.connectedPoint) {
+ var a = "1.0";
+ o.connectedPoint && (a = o.associatedVariableName), i.connectedPoint.type === le.Float ? e.compilationString += "gl_FragColor = vec4(" + i.associatedVariableName + ", " + i.associatedVariableName + ", " + i.associatedVariableName + ", " + a + `);\r
+` : e.compilationString += "gl_FragColor = vec4(" + i.associatedVariableName + ", " + a + `);\r
+`;
+ } else
+ e.sharedData.checks.notConnectedNonOptionalInputs.push(n);
+ return this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.FragmentOutputBlock"] = Pr, function(r) {
+ r[r.None = 0] = "None", r[r.Time = 1] = "Time";
+ }(Ni || (Ni = {}));
+ var z_ = { position2d: "position", particle_uv: "vUV", particle_color: "vColor", particle_texturemask: "textureMask", particle_positionw: "vPositionW" }, Gs = { particle_uv: !0, particle_color: !0, particle_texturemask: !0, particle_positionw: !0 }, Yu = { particle_texturemask: !0 }, Et = function(r) {
+ function t(e, n, i) {
+ n === void 0 && (n = Ce.Vertex), i === void 0 && (i = le.AutoDetect);
+ var o = r.call(this, e, n, !1, !0) || this;
+ return o._mode = gn.Undefined, o._animationType = Ni.None, o.min = 0, o.max = 0, o.isBoolean = !1, o.matrixMode = 0, o._systemValue = null, o.isConstant = !1, o.groupInInspector = "", o.onValueChangedObservable = new C.c(), o.convertToGammaSpace = !1, o.convertToLinearSpace = !1, o._type = i, o.setDefaultValue(), o.registerOutput("output", i), o;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "type", { get: function() {
+ if (this._type === le.AutoDetect) {
+ if (this.isUniform && this.value != null) {
+ if (!isNaN(this.value))
+ return this._type = le.Float, this._type;
+ switch (this.value.getClassName()) {
+ case "Vector2":
+ return this._type = le.Vector2, this._type;
+ case "Vector3":
+ return this._type = le.Vector3, this._type;
+ case "Vector4":
+ return this._type = le.Vector4, this._type;
+ case "Color3":
+ return this._type = le.Color3, this._type;
+ case "Color4":
+ return this._type = le.Color4, this._type;
+ case "Matrix":
+ return this._type = le.Matrix, this._type;
+ }
+ }
+ if (this.isAttribute)
+ switch (this.name) {
+ case "position":
+ case "normal":
+ case "tangent":
+ case "particle_positionw":
+ return this._type = le.Vector3, this._type;
+ case "uv":
+ case "uv2":
+ case "position2d":
+ case "particle_uv":
+ return this._type = le.Vector2, this._type;
+ case "matricesIndices":
+ case "matricesWeights":
+ case "world0":
+ case "world1":
+ case "world2":
+ case "world3":
+ return this._type = le.Vector4, this._type;
+ case "color":
+ case "particle_color":
+ case "particle_texturemask":
+ return this._type = le.Color4, this._type;
+ }
+ if (this.isSystemValue)
+ switch (this._systemValue) {
+ case gt.World:
+ case gt.WorldView:
+ case gt.WorldViewProjection:
+ case gt.View:
+ case gt.ViewProjection:
+ case gt.Projection:
+ return this._type = le.Matrix, this._type;
+ case gt.CameraPosition:
+ return this._type = le.Vector3, this._type;
+ case gt.FogColor:
+ return this._type = le.Color3, this._type;
+ case gt.DeltaTime:
+ return this._type = le.Float, this._type;
+ }
+ }
+ return this._type;
+ }, enumerable: !1, configurable: !0 }), t.prototype.validateBlockName = function(e) {
+ return !!this.isAttribute || r.prototype.validateBlockName.call(this, e);
+ }, Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype.setAsAttribute = function(e) {
+ return this._mode = gn.Attribute, e && (this.name = e), this;
+ }, t.prototype.setAsSystemValue = function(e) {
+ return this.systemValue = e, this;
+ }, Object.defineProperty(t.prototype, "value", { get: function() {
+ return this._storedValue;
+ }, set: function(e) {
+ this.type === le.Float && (this.isBoolean ? e = e ? 1 : 0 : this.min !== this.max && (e = Math.max(this.min, e), e = Math.min(this.max, e))), this._storedValue = e, this._mode = gn.Uniform, this.onValueChangedObservable.notifyObservers(this);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "valueCallback", { get: function() {
+ return this._valueCallback;
+ }, set: function(e) {
+ this._valueCallback = e, this._mode = gn.Uniform;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "associatedVariableName", { get: function() {
+ return this._associatedVariableName;
+ }, set: function(e) {
+ this._associatedVariableName = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "animationType", { get: function() {
+ return this._animationType;
+ }, set: function(e) {
+ this._animationType = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isUndefined", { get: function() {
+ return this._mode === gn.Undefined;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isUniform", { get: function() {
+ return this._mode === gn.Uniform;
+ }, set: function(e) {
+ this._mode = e ? gn.Uniform : gn.Undefined, this.associatedVariableName = "";
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isAttribute", { get: function() {
+ return this._mode === gn.Attribute;
+ }, set: function(e) {
+ this._mode = e ? gn.Attribute : gn.Undefined, this.associatedVariableName = "";
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isVarying", { get: function() {
+ return this._mode === gn.Varying;
+ }, set: function(e) {
+ this._mode = e ? gn.Varying : gn.Undefined, this.associatedVariableName = "";
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isSystemValue", { get: function() {
+ return this._systemValue != null;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "systemValue", { get: function() {
+ return this._systemValue;
+ }, set: function(e) {
+ this._mode = gn.Uniform, this.associatedVariableName = "", this._systemValue = e;
+ }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
+ return "InputBlock";
+ }, t.prototype.animate = function(e) {
+ switch (this._animationType) {
+ case Ni.Time:
+ this.type === le.Float && (this.value += 0.01 * e.getAnimationRatio());
+ }
+ }, t.prototype._emitDefine = function(e) {
+ return e[0] === "!" ? "#ifndef " + e.substring(1) + `\r
+` : "#ifdef " + e + `\r
+`;
+ }, t.prototype.initialize = function(e) {
+ this.associatedVariableName = "";
+ }, t.prototype.setDefaultValue = function() {
+ switch (this.type) {
+ case le.Float:
+ this.value = 0;
+ break;
+ case le.Vector2:
+ this.value = u.d.Zero();
+ break;
+ case le.Vector3:
+ this.value = u.e.Zero();
+ break;
+ case le.Vector4:
+ this.value = u.f.Zero();
+ break;
+ case le.Color3:
+ this.value = I.a.White();
+ break;
+ case le.Color4:
+ this.value = new I.b(1, 1, 1, 1);
+ break;
+ case le.Matrix:
+ this.value = u.a.Identity();
+ }
+ }, t.prototype._emitConstant = function(e) {
+ switch (this.type) {
+ case le.Float:
+ return "" + e._emitFloat(this.value);
+ case le.Vector2:
+ return "vec2(" + this.value.x + ", " + this.value.y + ")";
+ case le.Vector3:
+ return "vec3(" + this.value.x + ", " + this.value.y + ", " + this.value.z + ")";
+ case le.Vector4:
+ return "vec4(" + this.value.x + ", " + this.value.y + ", " + this.value.z + ", " + this.value.w + ")";
+ case le.Color3:
+ return I.c.Color3[0].set(this.value.r, this.value.g, this.value.b), this.convertToGammaSpace && I.c.Color3[0].toGammaSpaceToRef(I.c.Color3[0]), this.convertToLinearSpace && I.c.Color3[0].toLinearSpaceToRef(I.c.Color3[0]), "vec3(" + I.c.Color3[0].r + ", " + I.c.Color3[0].g + ", " + I.c.Color3[0].b + ")";
+ case le.Color4:
+ return I.c.Color4[0].set(this.value.r, this.value.g, this.value.b, this.value.a), this.convertToGammaSpace && I.c.Color4[0].toGammaSpaceToRef(I.c.Color4[0]), this.convertToLinearSpace && I.c.Color4[0].toLinearSpaceToRef(I.c.Color4[0]), "vec4(" + I.c.Color4[0].r + ", " + I.c.Color4[0].g + ", " + I.c.Color4[0].b + ", " + I.c.Color4[0].a + ")";
+ }
+ return "";
+ }, Object.defineProperty(t.prototype, "_noContextSwitch", { get: function() {
+ return Gs[this.name];
+ }, enumerable: !1, configurable: !0 }), t.prototype._emit = function(e, n) {
+ var i;
+ if (this.isUniform) {
+ if (this.associatedVariableName || (this.associatedVariableName = e._getFreeVariableName("u_" + this.name)), this.isConstant)
+ return e.constants.indexOf(this.associatedVariableName) !== -1 ? void 0 : (e.constants.push(this.associatedVariableName), void (e._constantDeclaration += this._declareOutput(this.output, e) + " = " + this._emitConstant(e) + `;\r
+`));
+ if (e.uniforms.indexOf(this.associatedVariableName) !== -1)
+ return;
+ e.uniforms.push(this.associatedVariableName), n && (e._uniformDeclaration += this._emitDefine(n)), e._uniformDeclaration += "uniform " + e._getGLType(this.type) + " " + this.associatedVariableName + `;\r
+`, n && (e._uniformDeclaration += `#endif\r
+`);
+ var o = e.sharedData.hints;
+ if (this._systemValue !== null && this._systemValue !== void 0)
+ switch (this._systemValue) {
+ case gt.WorldView:
+ o.needWorldViewMatrix = !0;
+ break;
+ case gt.WorldViewProjection:
+ o.needWorldViewProjectionMatrix = !0;
+ }
+ else
+ this._animationType !== Ni.None && e.sharedData.animatedInputs.push(this);
+ } else if (this.isAttribute) {
+ if (this.associatedVariableName = (i = z_[this.name]) !== null && i !== void 0 ? i : this.name, this.target === Ce.Vertex && e._vertexState)
+ return void (Gs[this.name] ? Yu[this.name] ? e._emitUniformFromString(this.associatedVariableName, e._getGLType(this.type), n) : e._emitVaryingFromString(this.associatedVariableName, e._getGLType(this.type), n) : this._emit(e._vertexState, n));
+ if (e.attributes.indexOf(this.associatedVariableName) !== -1)
+ return;
+ e.attributes.push(this.associatedVariableName), Gs[this.name] ? Yu[this.name] ? e._emitUniformFromString(this.associatedVariableName, e._getGLType(this.type), n) : e._emitVaryingFromString(this.associatedVariableName, e._getGLType(this.type), n) : (n && (e._attributeDeclaration += this._emitDefine(n)), e._attributeDeclaration += "attribute " + e._getGLType(this.type) + " " + this.associatedVariableName + `;\r
+`, n && (e._attributeDeclaration += `#endif\r
+`));
+ }
+ }, t.prototype._transmitWorld = function(e, n, i, o) {
+ if (this._systemValue) {
+ var a = this.associatedVariableName;
+ switch (this._systemValue) {
+ case gt.World:
+ e.setMatrix(a, n);
+ break;
+ case gt.WorldView:
+ e.setMatrix(a, i);
+ break;
+ case gt.WorldViewProjection:
+ e.setMatrix(a, o);
+ }
+ }
+ }, t.prototype._transmit = function(e, n) {
+ if (!this.isAttribute) {
+ var i = this.associatedVariableName;
+ if (this._systemValue)
+ switch (this._systemValue) {
+ case gt.World:
+ case gt.WorldView:
+ case gt.WorldViewProjection:
+ return;
+ case gt.View:
+ e.setMatrix(i, n.getViewMatrix());
+ break;
+ case gt.Projection:
+ e.setMatrix(i, n.getProjectionMatrix());
+ break;
+ case gt.ViewProjection:
+ e.setMatrix(i, n.getTransformMatrix());
+ break;
+ case gt.CameraPosition:
+ $e.a.BindEyePosition(e, n, i);
+ break;
+ case gt.FogColor:
+ e.setColor3(i, n.fogColor);
+ break;
+ case gt.DeltaTime:
+ e.setFloat(i, n.deltaTime / 1e3);
+ }
+ else {
+ var o = this._valueCallback ? this._valueCallback() : this._storedValue;
+ if (o !== null)
+ switch (this.type) {
+ case le.Float:
+ e.setFloat(i, o);
+ break;
+ case le.Int:
+ e.setInt(i, o);
+ break;
+ case le.Color3:
+ I.c.Color3[0].set(this.value.r, this.value.g, this.value.b), this.convertToGammaSpace && I.c.Color3[0].toGammaSpaceToRef(I.c.Color3[0]), this.convertToLinearSpace && I.c.Color3[0].toLinearSpaceToRef(I.c.Color3[0]), e.setColor3(i, I.c.Color3[0]);
+ break;
+ case le.Color4:
+ I.c.Color4[0].set(this.value.r, this.value.g, this.value.b, this.value.a), this.convertToGammaSpace && I.c.Color4[0].toGammaSpaceToRef(I.c.Color4[0]), this.convertToLinearSpace && I.c.Color4[0].toLinearSpaceToRef(I.c.Color4[0]), e.setDirectColor4(i, I.c.Color4[0]);
+ break;
+ case le.Vector2:
+ e.setVector2(i, o);
+ break;
+ case le.Vector3:
+ e.setVector3(i, o);
+ break;
+ case le.Vector4:
+ e.setVector4(i, o);
+ break;
+ case le.Matrix:
+ e.setMatrix(i, o);
+ }
+ }
+ }
+ }, t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e), (this.isUniform || this.isSystemValue) && e.sharedData.inputBlocks.push(this), this._emit(e);
+ }, t.prototype._dumpPropertiesCode = function() {
+ var e = this._codeVariableName;
+ if (this.isAttribute)
+ return e + '.setAsAttribute("' + this.name + `");\r
+`;
+ if (this.isSystemValue)
+ return e + ".setAsSystemValue(BABYLON.NodeMaterialSystemValues." + gt[this._systemValue] + `);\r
+`;
+ if (this.isUniform) {
+ var n = [], i = "";
+ switch (this.type) {
+ case le.Float:
+ i = "" + this.value;
+ break;
+ case le.Vector2:
+ i = "new BABYLON.Vector2(" + this.value.x + ", " + this.value.y + ")";
+ break;
+ case le.Vector3:
+ i = "new BABYLON.Vector3(" + this.value.x + ", " + this.value.y + ", " + this.value.z + ")";
+ break;
+ case le.Vector4:
+ i = "new BABYLON.Vector4(" + this.value.x + ", " + this.value.y + ", " + this.value.z + ", " + this.value.w + ")";
+ break;
+ case le.Color3:
+ i = "new BABYLON.Color3(" + this.value.r + ", " + this.value.g + ", " + this.value.b + ")", this.convertToGammaSpace && (i += ".toGammaSpace()"), this.convertToLinearSpace && (i += ".toLinearSpace()");
+ break;
+ case le.Color4:
+ i = "new BABYLON.Color4(" + this.value.r + ", " + this.value.g + ", " + this.value.b + ", " + this.value.a + ")", this.convertToGammaSpace && (i += ".toGammaSpace()"), this.convertToLinearSpace && (i += ".toLinearSpace()");
+ break;
+ case le.Matrix:
+ i = "BABYLON.Matrix.FromArray([" + this.value.m + "])";
+ }
+ return n.push(e + ".value = " + i), this.type === le.Float && n.push(e + ".min = " + this.min, e + ".max = " + this.max, e + ".isBoolean = " + this.isBoolean, e + ".matrixMode = " + this.matrixMode, e + ".animationType = BABYLON.AnimatedInputBlockTypes." + Ni[this.animationType]), n.push(e + ".isConstant = " + this.isConstant), n.push(""), n.join(`;\r
+`);
+ }
+ return "";
+ }, t.prototype.dispose = function() {
+ this.onValueChangedObservable.clear(), r.prototype.dispose.call(this);
+ }, t.prototype.serialize = function() {
+ var e = r.prototype.serialize.call(this);
+ return e.type = this.type, e.mode = this._mode, e.systemValue = this._systemValue, e.animationType = this._animationType, e.min = this.min, e.max = this.max, e.isBoolean = this.isBoolean, e.matrixMode = this.matrixMode, e.isConstant = this.isConstant, e.groupInInspector = this.groupInInspector, e.convertToGammaSpace = this.convertToGammaSpace, e.convertToLinearSpace = this.convertToLinearSpace, this._storedValue != null && this._mode === gn.Uniform && (this._storedValue.asArray ? (e.valueType = "BABYLON." + this._storedValue.getClassName(), e.value = this._storedValue.asArray()) : (e.valueType = "number", e.value = this._storedValue)), e;
+ }, t.prototype._deserialize = function(e, n, i) {
+ if (this._mode = e.mode, r.prototype._deserialize.call(this, e, n, i), this._type = e.type, this._systemValue = e.systemValue || e.wellKnownValue, this._animationType = e.animationType, this.min = e.min || 0, this.max = e.max || 0, this.isBoolean = !!e.isBoolean, this.matrixMode = e.matrixMode || 0, this.isConstant = !!e.isConstant, this.groupInInspector = e.groupInInspector || "", this.convertToGammaSpace = !!e.convertToGammaSpace, this.convertToLinearSpace = !!e.convertToLinearSpace, e.valueType)
+ if (e.valueType === "number")
+ this._storedValue = e.value;
+ else {
+ var o = O.a.GetClass(e.valueType);
+ o && (this._storedValue = o.FromArray(e.value));
+ }
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.InputBlock"] = Et;
+ var zs = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.VertexAndFragment) || this;
+ return n._samplerName = "textureSampler", n.convertToGammaSpace = !1, n.convertToLinearSpace = !1, n._isUnique = !1, n.registerInput("uv", le.Vector2, !1, Ce.VertexAndFragment), n.registerOutput("rgba", le.Color4, Ce.Neutral), n.registerOutput("rgb", le.Color3, Ce.Neutral), n.registerOutput("r", le.Float, Ce.Neutral), n.registerOutput("g", le.Float, Ce.Neutral), n.registerOutput("b", le.Float, Ce.Neutral), n.registerOutput("a", le.Float, Ce.Neutral), n._inputs[0].acceptedConnectionPointTypes.push(le.Vector3), n._inputs[0].acceptedConnectionPointTypes.push(le.Vector4), n._inputs[0]._prioritizeVertex = !1, n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "CurrentScreenBlock";
+ }, Object.defineProperty(t.prototype, "uv", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgba", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgb", { get: function() {
+ return this._outputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "r", { get: function() {
+ return this._outputs[2];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "g", { get: function() {
+ return this._outputs[3];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "b", { get: function() {
+ return this._outputs[4];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "a", { get: function() {
+ return this._outputs[5];
+ }, enumerable: !1, configurable: !0 }), t.prototype.initialize = function(e) {
+ e._excludeVariableName("textureSampler");
+ }, Object.defineProperty(t.prototype, "target", { get: function() {
+ return this.uv.isConnected ? this.uv.sourceBlock.isInput ? Ce.VertexAndFragment : Ce.Fragment : Ce.VertexAndFragment;
+ }, enumerable: !1, configurable: !0 }), t.prototype.prepareDefines = function(e, n, i) {
+ i.setValue(this._linearDefineName, this.convertToGammaSpace, !0), i.setValue(this._gammaDefineName, this.convertToLinearSpace, !0);
+ }, t.prototype.isReady = function() {
+ return !(this.texture && !this.texture.isReadyOrNotBlocking());
+ }, t.prototype._injectVertexCode = function(e) {
+ var n = this.uv;
+ if (n.connectedPoint.ownerBlock.isInput && (n.connectedPoint.ownerBlock.isAttribute || e._emitUniformFromString(n.associatedVariableName, "vec2")), this._mainUVName = "vMain" + n.associatedVariableName, e._emitVaryingFromString(this._mainUVName, "vec2"), e.compilationString += this._mainUVName + " = " + n.associatedVariableName + `.xy;\r
+`, this._outputs.some(function(s) {
+ return s.isConnectedInVertexShader;
+ })) {
+ this._writeTextureRead(e, !0);
+ for (var i = 0, o = this._outputs; i < o.length; i++) {
+ var a = o[i];
+ a.hasEndpoints && this._writeOutput(e, a, a.name, !0);
+ }
+ }
+ }, t.prototype._writeTextureRead = function(e, n) {
+ n === void 0 && (n = !1);
+ var i = this.uv;
+ if (n) {
+ if (e.target === Ce.Fragment)
+ return;
+ e.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + this._samplerName + ", " + i.associatedVariableName + `);\r
+`;
+ } else
+ this.uv.ownerBlock.target !== Ce.Fragment ? e.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + this._samplerName + ", " + this._mainUVName + `);\r
+` : e.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + this._samplerName + ", " + i.associatedVariableName + `);\r
+`;
+ }, t.prototype._writeOutput = function(e, n, i, o) {
+ if (o === void 0 && (o = !1), o) {
+ if (e.target === Ce.Fragment)
+ return;
+ e.compilationString += this._declareOutput(n, e) + " = " + this._tempTextureRead + "." + i + `;\r
+`;
+ } else
+ this.uv.ownerBlock.target !== Ce.Fragment ? (e.compilationString += this._declareOutput(n, e) + " = " + this._tempTextureRead + "." + i + `;\r
+`, e.compilationString += "#ifdef " + this._linearDefineName + `\r
+`, e.compilationString += n.associatedVariableName + " = toGammaSpace(" + n.associatedVariableName + `);\r
+`, e.compilationString += `#endif\r
+`, e.compilationString += "#ifdef " + this._gammaDefineName + `\r
+`, e.compilationString += n.associatedVariableName + " = toLinearSpace(" + n.associatedVariableName + `);\r
+`, e.compilationString += `#endif\r
+`) : e.compilationString += this._declareOutput(n, e) + " = " + this._tempTextureRead + "." + i + `;\r
+`;
+ }, t.prototype._buildBlock = function(e) {
+ if (r.prototype._buildBlock.call(this, e), this._tempTextureRead = e._getFreeVariableName("tempTextureRead"), e.sharedData.blockingBlocks.indexOf(this) < 0 && e.sharedData.blockingBlocks.push(this), e.sharedData.textureBlocks.indexOf(this) < 0 && e.sharedData.textureBlocks.push(this), e.sharedData.blocksWithDefines.indexOf(this) < 0 && e.sharedData.blocksWithDefines.push(this), e.target !== Ce.Fragment)
+ return e._emit2DSampler(this._samplerName), void this._injectVertexCode(e);
+ if (this._outputs.some(function(s) {
+ return s.isConnectedInFragmentShader;
+ })) {
+ e._emit2DSampler(this._samplerName), this._linearDefineName = e._getFreeDefineName("ISLINEAR"), this._gammaDefineName = e._getFreeDefineName("ISGAMMA");
+ var n = "//" + this.name;
+ e._emitFunctionFromInclude("helperFunctions", n), this._writeTextureRead(e);
+ for (var i = 0, o = this._outputs; i < o.length; i++) {
+ var a = o[i];
+ a.hasEndpoints && this._writeOutput(e, a, a.name);
+ }
+ return this;
+ }
+ }, t.prototype.serialize = function() {
+ var e = r.prototype.serialize.call(this);
+ return e.convertToGammaSpace = this.convertToGammaSpace, e.convertToLinearSpace = this.convertToLinearSpace, this.texture && (e.texture = this.texture.serialize()), e;
+ }, t.prototype._deserialize = function(e, n, i) {
+ r.prototype._deserialize.call(this, e, n, i), this.convertToGammaSpace = e.convertToGammaSpace, this.convertToLinearSpace = !!e.convertToLinearSpace, e.texture && (i = e.texture.url.indexOf("data:") === 0 ? "" : i, this.texture = Ne.a.Parse(e.texture, n, i));
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.CurrentScreenBlock"] = zs;
+ var js = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Fragment) || this;
+ return n._samplerName = "diffuseSampler", n.convertToGammaSpace = !1, n.convertToLinearSpace = !1, n._isUnique = !1, n.registerInput("uv", le.Vector2, !1, Ce.VertexAndFragment), n.registerOutput("rgba", le.Color4, Ce.Neutral), n.registerOutput("rgb", le.Color3, Ce.Neutral), n.registerOutput("r", le.Float, Ce.Neutral), n.registerOutput("g", le.Float, Ce.Neutral), n.registerOutput("b", le.Float, Ce.Neutral), n.registerOutput("a", le.Float, Ce.Neutral), n._inputs[0].acceptedConnectionPointTypes.push(le.Vector3), n._inputs[0].acceptedConnectionPointTypes.push(le.Vector4), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "ParticleTextureBlock";
+ }, Object.defineProperty(t.prototype, "uv", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgba", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgb", { get: function() {
+ return this._outputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "r", { get: function() {
+ return this._outputs[2];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "g", { get: function() {
+ return this._outputs[3];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "b", { get: function() {
+ return this._outputs[4];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "a", { get: function() {
+ return this._outputs[5];
+ }, enumerable: !1, configurable: !0 }), t.prototype.initialize = function(e) {
+ e._excludeVariableName("diffuseSampler");
+ }, t.prototype.autoConfigure = function(e) {
+ if (!this.uv.isConnected) {
+ var n = e.getInputBlockByPredicate(function(i) {
+ return i.isAttribute && i.name === "particle_uv";
+ });
+ n || (n = new Et("uv")).setAsAttribute("particle_uv"), n.output.connectTo(this.uv);
+ }
+ }, t.prototype.prepareDefines = function(e, n, i) {
+ i.setValue(this._linearDefineName, this.convertToGammaSpace, !0), i.setValue(this._gammaDefineName, this.convertToLinearSpace, !0);
+ }, t.prototype.isReady = function() {
+ return !(this.texture && !this.texture.isReadyOrNotBlocking());
+ }, t.prototype._writeOutput = function(e, n, i) {
+ e.compilationString += this._declareOutput(n, e) + " = " + this._tempTextureRead + "." + i + `;\r
+`, e.compilationString += "#ifdef " + this._linearDefineName + `\r
+`, e.compilationString += n.associatedVariableName + " = toGammaSpace(" + n.associatedVariableName + `);\r
+`, e.compilationString += `#endif\r
+`, e.compilationString += "#ifdef " + this._gammaDefineName + `\r
+`, e.compilationString += n.associatedVariableName + " = toLinearSpace(" + n.associatedVariableName + `);\r
+`, e.compilationString += `#endif\r
+`;
+ }, t.prototype._buildBlock = function(e) {
+ if (r.prototype._buildBlock.call(this, e), e.target !== Ce.Vertex) {
+ this._tempTextureRead = e._getFreeVariableName("tempTextureRead"), e._emit2DSampler(this._samplerName), e.sharedData.blockingBlocks.push(this), e.sharedData.textureBlocks.push(this), e.sharedData.blocksWithDefines.push(this), this._linearDefineName = e._getFreeDefineName("ISLINEAR"), this._gammaDefineName = e._getFreeDefineName("ISGAMMA");
+ var n = "//" + this.name;
+ e._emitFunctionFromInclude("helperFunctions", n), e.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + this._samplerName + ", " + this.uv.associatedVariableName + `);\r
+`;
+ for (var i = 0, o = this._outputs; i < o.length; i++) {
+ var a = o[i];
+ a.hasEndpoints && this._writeOutput(e, a, a.name);
+ }
+ return this;
+ }
+ }, t.prototype.serialize = function() {
+ var e = r.prototype.serialize.call(this);
+ return e.convertToGammaSpace = this.convertToGammaSpace, e.convertToLinearSpace = this.convertToLinearSpace, this.texture && (e.texture = this.texture.serialize()), e;
+ }, t.prototype._deserialize = function(e, n, i) {
+ r.prototype._deserialize.call(this, e, n, i), this.convertToGammaSpace = e.convertToGammaSpace, this.convertToLinearSpace = !!e.convertToLinearSpace, e.texture && (i = e.texture.url.indexOf("data:") === 0 ? "" : i, this.texture = Ne.a.Parse(e.texture, n, i));
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.ParticleTextureBlock"] = js;
+ var Hs = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Fragment) || this;
+ return n._isUnique = !0, n.registerInput("color", le.Color4, !1, Ce.Fragment), n.registerOutput("rampColor", le.Color4, Ce.Fragment), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "ParticleRampGradientBlock";
+ }, Object.defineProperty(t.prototype, "color", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rampColor", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype.initialize = function(e) {
+ e._excludeVariableName("remapRanges"), e._excludeVariableName("rampSampler"), e._excludeVariableName("baseColor"), e._excludeVariableName("alpha"), e._excludeVariableName("remappedColorIndex"), e._excludeVariableName("rampColor"), e._excludeVariableName("finalAlpha");
+ }, t.prototype._buildBlock = function(e) {
+ if (r.prototype._buildBlock.call(this, e), e.target !== Ce.Vertex)
+ return e._emit2DSampler("rampSampler"), e._emitVaryingFromString("remapRanges", "vec4", "RAMPGRADIENT"), e.compilationString += `
+ #ifdef RAMPGRADIENT
+ vec4 baseColor = ` + this.color.associatedVariableName + `;
+ float alpha = ` + this.color.associatedVariableName + `.a;
+
+ float remappedColorIndex = clamp((alpha - remapRanges.x) / remapRanges.y, 0.0, 1.0);
+
+ vec4 rampColor = texture2D(rampSampler, vec2(1.0 - remappedColorIndex, 0.));
+ baseColor.rgb *= rampColor.rgb;
+
+ // Remapped alpha
+ float finalAlpha = baseColor.a;
+ baseColor.a = clamp((alpha * rampColor.a - remapRanges.z) / remapRanges.w, 0.0, 1.0);
+
+ ` + this._declareOutput(this.rampColor, e) + ` = baseColor;
+ #else
+ ` + this._declareOutput(this.rampColor, e) + " = " + this.color.associatedVariableName + `;
+ #endif
+ `, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.ParticleRampGradientBlock"] = Hs;
+ var Ws = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Fragment) || this;
+ return n._isUnique = !0, n.registerInput("color", le.Color4, !1, Ce.Fragment), n.registerInput("alphaTexture", le.Float, !1, Ce.Fragment), n.registerInput("alphaColor", le.Float, !1, Ce.Fragment), n.registerOutput("blendColor", le.Color4, Ce.Fragment), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "ParticleBlendMultiplyBlock";
+ }, Object.defineProperty(t.prototype, "color", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "alphaTexture", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "alphaColor", { get: function() {
+ return this._inputs[2];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "blendColor", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype.initialize = function(e) {
+ e._excludeVariableName("sourceAlpha");
+ }, t.prototype._buildBlock = function(e) {
+ if (r.prototype._buildBlock.call(this, e), e.target !== Ce.Vertex)
+ return e.compilationString += `
+ #ifdef BLENDMULTIPLYMODE
+ ` + this._declareOutput(this.blendColor, e) + `;
+ float sourceAlpha = ` + this.alphaColor.associatedVariableName + " * " + this.alphaTexture.associatedVariableName + `;
+ ` + this.blendColor.associatedVariableName + ".rgb = " + this.color.associatedVariableName + `.rgb * sourceAlpha + vec3(1.0) * (1.0 - sourceAlpha);
+ ` + this.blendColor.associatedVariableName + ".a = " + this.color.associatedVariableName + `.a;
+ #else
+ ` + this._declareOutput(this.blendColor, e) + " = " + this.color.associatedVariableName + `;
+ #endif
+ `, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.ParticleBlendMultiplyBlock"] = Ws;
+ var It, so = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("xyz ", le.Vector3, !0), n.registerInput("xy ", le.Vector2, !0), n.registerInput("x", le.Float, !0), n.registerInput("y", le.Float, !0), n.registerInput("z", le.Float, !0), n.registerInput("w", le.Float, !0), n.registerOutput("xyzw", le.Vector4), n.registerOutput("xyz", le.Vector3), n.registerOutput("xy", le.Vector2), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "VectorMergerBlock";
+ }, Object.defineProperty(t.prototype, "xyzIn", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xyIn", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "x", { get: function() {
+ return this._inputs[2];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "y", { get: function() {
+ return this._inputs[3];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "z", { get: function() {
+ return this._inputs[4];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "w", { get: function() {
+ return this._inputs[5];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xyzw", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xyzOut", { get: function() {
+ return this._outputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xyOut", { get: function() {
+ return this._outputs[2];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xy", { get: function() {
+ return this.xyOut;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xyz", { get: function() {
+ return this.xyzOut;
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this.x, i = this.y, o = this.z, a = this.w, s = this.xyIn, d = this.xyzIn, p = this._outputs[0], y = this._outputs[1], P = this._outputs[2];
+ return d.isConnected ? p.hasEndpoints ? e.compilationString += this._declareOutput(p, e) + " = vec4(" + d.associatedVariableName + ", " + (a.isConnected ? this._writeVariable(a) : "0.0") + `);\r
+` : y.hasEndpoints ? e.compilationString += this._declareOutput(y, e) + " = " + d.associatedVariableName + `;\r
+` : P.hasEndpoints && (e.compilationString += this._declareOutput(P, e) + " = " + d.associatedVariableName + `.xy;\r
+`) : s.isConnected ? p.hasEndpoints ? e.compilationString += this._declareOutput(p, e) + " = vec4(" + s.associatedVariableName + ", " + (o.isConnected ? this._writeVariable(o) : "0.0") + ", " + (a.isConnected ? this._writeVariable(a) : "0.0") + `);\r
+` : y.hasEndpoints ? e.compilationString += this._declareOutput(y, e) + " = vec3(" + s.associatedVariableName + ", " + (o.isConnected ? this._writeVariable(o) : "0.0") + `);\r
+` : P.hasEndpoints && (e.compilationString += this._declareOutput(P, e) + " = " + s.associatedVariableName + `;\r
+`) : p.hasEndpoints ? e.compilationString += this._declareOutput(p, e) + " = vec4(" + (n.isConnected ? this._writeVariable(n) : "0.0") + ", " + (i.isConnected ? this._writeVariable(i) : "0.0") + ", " + (o.isConnected ? this._writeVariable(o) : "0.0") + ", " + (a.isConnected ? this._writeVariable(a) : "0.0") + `);\r
+` : y.hasEndpoints ? e.compilationString += this._declareOutput(y, e) + " = vec3(" + (n.isConnected ? this._writeVariable(n) : "0.0") + ", " + (i.isConnected ? this._writeVariable(i) : "0.0") + ", " + (o.isConnected ? this._writeVariable(o) : "0.0") + `);\r
+` : P.hasEndpoints && (e.compilationString += this._declareOutput(P, e) + " = vec2(" + (n.isConnected ? this._writeVariable(n) : "0.0") + ", " + (i.isConnected ? this._writeVariable(i) : "0.0") + `);\r
+`), this;
+ }, t;
+ }(dt);
+ function Bt(r, t, e, n) {
+ return t === void 0 && (t = It.Boolean), e === void 0 && (e = "PROPERTIES"), function(i, o) {
+ var a = i._propStore;
+ a || (a = [], i._propStore = a), a.push({ propertyName: o, displayName: r, type: t, groupName: e, options: n ?? {} });
+ };
+ }
+ O.a.RegisteredTypes["BABYLON.VectorMergerBlock"] = so, function(r) {
+ r[r.Boolean = 0] = "Boolean", r[r.Float = 1] = "Float", r[r.Vector2 = 2] = "Vector2", r[r.List = 3] = "List";
+ }(It || (It = {}));
+ var Xs = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.sourceRange = new u.d(-1, 1), n.targetRange = new u.d(0, 1), n.registerInput("input", le.AutoDetect), n.registerInput("sourceMin", le.Float, !0), n.registerInput("sourceMax", le.Float, !0), n.registerInput("targetMin", le.Float, !0), n.registerInput("targetMax", le.Float, !0), n.registerOutput("output", le.BasedOnInput), n._outputs[0]._typeConnectionSource = n._inputs[0], n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "RemapBlock";
+ }, Object.defineProperty(t.prototype, "input", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "sourceMin", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "sourceMax", { get: function() {
+ return this._inputs[2];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "targetMin", { get: function() {
+ return this._inputs[3];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "targetMax", { get: function() {
+ return this._inputs[4];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0], i = this.sourceMin.isConnected ? this.sourceMin.associatedVariableName : this._writeFloat(this.sourceRange.x), o = this.sourceMax.isConnected ? this.sourceMax.associatedVariableName : this._writeFloat(this.sourceRange.y), a = this.targetMin.isConnected ? this.targetMin.associatedVariableName : this._writeFloat(this.targetRange.x), s = this.targetMax.isConnected ? this.targetMax.associatedVariableName : this._writeFloat(this.targetRange.y);
+ return e.compilationString += this._declareOutput(n, e) + " = " + a + " + (" + this._inputs[0].associatedVariableName + " - " + i + ") * (" + s + " - " + a + ") / (" + o + " - " + i + `);\r
+`, this;
+ }, t.prototype._dumpPropertiesCode = function() {
+ var e = this._codeVariableName + ".sourceRange = new BABYLON.Vector2(" + this.sourceRange.x + ", " + this.sourceRange.y + `);\r
+`;
+ return e += this._codeVariableName + ".targetRange = new BABYLON.Vector2(" + this.targetRange.x + ", " + this.targetRange.y + `);\r
+`;
+ }, t.prototype.serialize = function() {
+ var e = r.prototype.serialize.call(this);
+ return e.sourceRange = this.sourceRange.asArray(), e.targetRange = this.targetRange.asArray(), e;
+ }, t.prototype._deserialize = function(e, n, i) {
+ r.prototype._deserialize.call(this, e, n, i), this.sourceRange = u.d.FromArray(e.sourceRange), this.targetRange = u.d.FromArray(e.targetRange);
+ }, Object(c.c)([Bt("From", It.Vector2)], t.prototype, "sourceRange", void 0), Object(c.c)([Bt("To", It.Vector2)], t.prototype, "targetRange", void 0), t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.RemapBlock"] = Xs;
+ var ra = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("left", le.AutoDetect), n.registerInput("right", le.AutoDetect), n.registerOutput("output", le.BasedOnInput), n._outputs[0]._typeConnectionSource = n._inputs[0], n._linkConnectionTypes(0, 1), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "MultiplyBlock";
+ }, Object.defineProperty(t.prototype, "left", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "right", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0];
+ return e.compilationString += this._declareOutput(n, e) + " = " + this.left.associatedVariableName + " * " + this.right.associatedVariableName + `;\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.MultiplyBlock"] = ra;
+ var xr = function() {
+ function r() {
+ this.direction1 = new u.e(0, 1, 0), this.direction2 = new u.e(0, 1, 0), this.minEmitBox = new u.e(-0.5, -0.5, -0.5), this.maxEmitBox = new u.e(0.5, 0.5, 0.5);
+ }
+ return r.prototype.startDirectionFunction = function(t, e, n, i) {
+ var o = $.a.RandomRange(this.direction1.x, this.direction2.x), a = $.a.RandomRange(this.direction1.y, this.direction2.y), s = $.a.RandomRange(this.direction1.z, this.direction2.z);
+ if (i)
+ return e.x = o, e.y = a, void (e.z = s);
+ u.e.TransformNormalFromFloatsToRef(o, a, s, t, e);
+ }, r.prototype.startPositionFunction = function(t, e, n, i) {
+ var o = $.a.RandomRange(this.minEmitBox.x, this.maxEmitBox.x), a = $.a.RandomRange(this.minEmitBox.y, this.maxEmitBox.y), s = $.a.RandomRange(this.minEmitBox.z, this.maxEmitBox.z);
+ if (i)
+ return e.x = o, e.y = a, void (e.z = s);
+ u.e.TransformCoordinatesFromFloatsToRef(o, a, s, t, e);
+ }, r.prototype.clone = function() {
+ var t = new r();
+ return de.a.DeepCopy(this, t), t;
+ }, r.prototype.applyToShader = function(t) {
+ t.setVector3("direction1", this.direction1), t.setVector3("direction2", this.direction2), t.setVector3("minEmitBox", this.minEmitBox), t.setVector3("maxEmitBox", this.maxEmitBox);
+ }, r.prototype.getEffectDefines = function() {
+ return "#define BOXEMITTER";
+ }, r.prototype.getClassName = function() {
+ return "BoxParticleEmitter";
+ }, r.prototype.serialize = function() {
+ var t = {};
+ return t.type = this.getClassName(), t.direction1 = this.direction1.asArray(), t.direction2 = this.direction2.asArray(), t.minEmitBox = this.minEmitBox.asArray(), t.maxEmitBox = this.maxEmitBox.asArray(), t;
+ }, r.prototype.parse = function(t) {
+ u.e.FromArrayToRef(t.direction1, 0, this.direction1), u.e.FromArrayToRef(t.direction2, 0, this.direction2), u.e.FromArrayToRef(t.minEmitBox, 0, this.minEmitBox), u.e.FromArrayToRef(t.maxEmitBox, 0, this.maxEmitBox);
+ }, r;
+ }(), Ys = function() {
+ function r(t, e, n) {
+ t === void 0 && (t = 1), e === void 0 && (e = Math.PI), n === void 0 && (n = 0), this.directionRandomizer = n, this.radiusRange = 1, this.heightRange = 1, this.emitFromSpawnPointOnly = !1, this.angle = e, this.radius = t;
+ }
+ return Object.defineProperty(r.prototype, "radius", { get: function() {
+ return this._radius;
+ }, set: function(t) {
+ this._radius = t, this._buildHeight();
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "angle", { get: function() {
+ return this._angle;
+ }, set: function(t) {
+ this._angle = t, this._buildHeight();
+ }, enumerable: !1, configurable: !0 }), r.prototype._buildHeight = function() {
+ this._angle !== 0 ? this._height = this._radius / Math.tan(this._angle / 2) : this._height = 1;
+ }, r.prototype.startDirectionFunction = function(t, e, n, i) {
+ i ? u.c.Vector3[0].copyFrom(n._localPosition).normalize() : n.position.subtractToRef(t.getTranslation(), u.c.Vector3[0]).normalize();
+ var o = $.a.RandomRange(0, this.directionRandomizer), a = $.a.RandomRange(0, this.directionRandomizer), s = $.a.RandomRange(0, this.directionRandomizer);
+ e.x = u.c.Vector3[0].x + o, e.y = u.c.Vector3[0].y + a, e.z = u.c.Vector3[0].z + s, e.normalize();
+ }, r.prototype.startPositionFunction = function(t, e, n, i) {
+ var o, a = $.a.RandomRange(0, 2 * Math.PI);
+ o = this.emitFromSpawnPointOnly ? 1e-4 : 1 - (o = $.a.RandomRange(0, this.heightRange)) * o;
+ var s = this._radius - $.a.RandomRange(0, this._radius * this.radiusRange), d = (s *= o) * Math.sin(a), p = s * Math.cos(a), y = o * this._height;
+ if (i)
+ return e.x = d, e.y = y, void (e.z = p);
+ u.e.TransformCoordinatesFromFloatsToRef(d, y, p, t, e);
+ }, r.prototype.clone = function() {
+ var t = new r(this._radius, this._angle, this.directionRandomizer);
+ return de.a.DeepCopy(this, t), t;
+ }, r.prototype.applyToShader = function(t) {
+ t.setFloat2("radius", this._radius, this.radiusRange), t.setFloat("coneAngle", this._angle), t.setFloat2("height", this._height, this.heightRange), t.setFloat("directionRandomizer", this.directionRandomizer);
+ }, r.prototype.getEffectDefines = function() {
+ var t = "#define CONEEMITTER";
+ return this.emitFromSpawnPointOnly && (t += `
+#define CONEEMITTERSPAWNPOINT`), t;
+ }, r.prototype.getClassName = function() {
+ return "ConeParticleEmitter";
+ }, r.prototype.serialize = function() {
+ var t = {};
+ return t.type = this.getClassName(), t.radius = this._radius, t.angle = this._angle, t.directionRandomizer = this.directionRandomizer, t.radiusRange = this.radiusRange, t.heightRange = this.heightRange, t.emitFromSpawnPointOnly = this.emitFromSpawnPointOnly, t;
+ }, r.prototype.parse = function(t) {
+ this.radius = t.radius, this.angle = t.angle, this.directionRandomizer = t.directionRandomizer, this.radiusRange = t.radiusRange !== void 0 ? t.radiusRange : 1, this.heightRange = t.radiusRange !== void 0 ? t.heightRange : 1, this.emitFromSpawnPointOnly = t.emitFromSpawnPointOnly !== void 0 && t.emitFromSpawnPointOnly;
+ }, r;
+ }(), oa = function() {
+ function r(t, e, n, i) {
+ t === void 0 && (t = 1), e === void 0 && (e = 1), n === void 0 && (n = 1), i === void 0 && (i = 0), this.radius = t, this.height = e, this.radiusRange = n, this.directionRandomizer = i;
+ }
+ return r.prototype.startDirectionFunction = function(t, e, n, i) {
+ var o = n.position.subtract(t.getTranslation()).normalize(), a = $.a.RandomRange(-this.directionRandomizer / 2, this.directionRandomizer / 2), s = Math.atan2(o.x, o.z);
+ s += $.a.RandomRange(-Math.PI / 2, Math.PI / 2) * this.directionRandomizer, o.y = a, o.x = Math.sin(s), o.z = Math.cos(s), o.normalize(), i ? e.copyFrom(o) : u.e.TransformNormalFromFloatsToRef(o.x, o.y, o.z, t, e);
+ }, r.prototype.startPositionFunction = function(t, e, n, i) {
+ var o = $.a.RandomRange(-this.height / 2, this.height / 2), a = $.a.RandomRange(0, 2 * Math.PI), s = $.a.RandomRange((1 - this.radiusRange) * (1 - this.radiusRange), 1), d = Math.sqrt(s) * this.radius, p = d * Math.cos(a), y = d * Math.sin(a);
+ i ? e.copyFromFloats(p, o, y) : u.e.TransformCoordinatesFromFloatsToRef(p, o, y, t, e);
+ }, r.prototype.clone = function() {
+ var t = new r(this.radius, this.directionRandomizer);
+ return de.a.DeepCopy(this, t), t;
+ }, r.prototype.applyToShader = function(t) {
+ t.setFloat("radius", this.radius), t.setFloat("height", this.height), t.setFloat("radiusRange", this.radiusRange), t.setFloat("directionRandomizer", this.directionRandomizer);
+ }, r.prototype.getEffectDefines = function() {
+ return "#define CYLINDEREMITTER";
+ }, r.prototype.getClassName = function() {
+ return "CylinderParticleEmitter";
+ }, r.prototype.serialize = function() {
+ var t = {};
+ return t.type = this.getClassName(), t.radius = this.radius, t.height = this.height, t.radiusRange = this.radiusRange, t.directionRandomizer = this.directionRandomizer, t;
+ }, r.prototype.parse = function(t) {
+ this.radius = t.radius, this.height = t.height, this.radiusRange = t.radiusRange, this.directionRandomizer = t.directionRandomizer;
+ }, r;
+ }(), Ks = function(r) {
+ function t(e, n, i, o, a) {
+ e === void 0 && (e = 1), n === void 0 && (n = 1), i === void 0 && (i = 1), o === void 0 && (o = new u.e(0, 1, 0)), a === void 0 && (a = new u.e(0, 1, 0));
+ var s = r.call(this, e, n, i) || this;
+ return s.direction1 = o, s.direction2 = a, s;
+ }
+ return Object(c.d)(t, r), t.prototype.startDirectionFunction = function(e, n, i) {
+ var o = $.a.RandomRange(this.direction1.x, this.direction2.x), a = $.a.RandomRange(this.direction1.y, this.direction2.y), s = $.a.RandomRange(this.direction1.z, this.direction2.z);
+ u.e.TransformNormalFromFloatsToRef(o, a, s, e, n);
+ }, t.prototype.clone = function() {
+ var e = new t(this.radius, this.height, this.radiusRange, this.direction1, this.direction2);
+ return de.a.DeepCopy(this, e), e;
+ }, t.prototype.applyToShader = function(e) {
+ e.setFloat("radius", this.radius), e.setFloat("height", this.height), e.setFloat("radiusRange", this.radiusRange), e.setVector3("direction1", this.direction1), e.setVector3("direction2", this.direction2);
+ }, t.prototype.getEffectDefines = function() {
+ return `#define CYLINDEREMITTER
+#define DIRECTEDCYLINDEREMITTER`;
+ }, t.prototype.getClassName = function() {
+ return "CylinderDirectedParticleEmitter";
+ }, t.prototype.serialize = function() {
+ var e = r.prototype.serialize.call(this);
+ return e.direction1 = this.direction1.asArray(), e.direction2 = this.direction2.asArray(), e;
+ }, t.prototype.parse = function(e) {
+ r.prototype.parse.call(this, e), this.direction1.copyFrom(e.direction1), this.direction2.copyFrom(e.direction2);
+ }, t;
+ }(oa), Qs = function() {
+ function r(t, e, n) {
+ t === void 0 && (t = 1), e === void 0 && (e = 1), n === void 0 && (n = 0), this.radius = t, this.radiusRange = e, this.directionRandomizer = n;
+ }
+ return r.prototype.startDirectionFunction = function(t, e, n, i) {
+ var o = n.position.subtract(t.getTranslation()).normalize(), a = $.a.RandomRange(0, this.directionRandomizer), s = $.a.RandomRange(0, this.directionRandomizer), d = $.a.RandomRange(0, this.directionRandomizer);
+ o.x += a, o.y += s, o.z += d, o.normalize(), i ? e.copyFrom(o) : u.e.TransformNormalFromFloatsToRef(o.x, o.y, o.z, t, e);
+ }, r.prototype.startPositionFunction = function(t, e, n, i) {
+ var o = this.radius - $.a.RandomRange(0, this.radius * this.radiusRange), a = $.a.RandomRange(0, 1), s = $.a.RandomRange(0, 2 * Math.PI), d = Math.acos(2 * a - 1), p = o * Math.cos(s) * Math.sin(d), y = o * Math.cos(d), P = o * Math.sin(s) * Math.sin(d);
+ i ? e.copyFromFloats(p, Math.abs(y), P) : u.e.TransformCoordinatesFromFloatsToRef(p, Math.abs(y), P, t, e);
+ }, r.prototype.clone = function() {
+ var t = new r(this.radius, this.directionRandomizer);
+ return de.a.DeepCopy(this, t), t;
+ }, r.prototype.applyToShader = function(t) {
+ t.setFloat("radius", this.radius), t.setFloat("radiusRange", this.radiusRange), t.setFloat("directionRandomizer", this.directionRandomizer);
+ }, r.prototype.getEffectDefines = function() {
+ return "#define HEMISPHERICEMITTER";
+ }, r.prototype.getClassName = function() {
+ return "HemisphericParticleEmitter";
+ }, r.prototype.serialize = function() {
+ var t = {};
+ return t.type = this.getClassName(), t.radius = this.radius, t.radiusRange = this.radiusRange, t.directionRandomizer = this.directionRandomizer, t;
+ }, r.prototype.parse = function(t) {
+ this.radius = t.radius, this.radiusRange = t.radiusRange, this.directionRandomizer = t.directionRandomizer;
+ }, r;
+ }(), qs = function() {
+ function r() {
+ this.direction1 = new u.e(0, 1, 0), this.direction2 = new u.e(0, 1, 0);
+ }
+ return r.prototype.startDirectionFunction = function(t, e, n, i) {
+ var o = $.a.RandomRange(this.direction1.x, this.direction2.x), a = $.a.RandomRange(this.direction1.y, this.direction2.y), s = $.a.RandomRange(this.direction1.z, this.direction2.z);
+ i ? e.copyFromFloats(o, a, s) : u.e.TransformNormalFromFloatsToRef(o, a, s, t, e);
+ }, r.prototype.startPositionFunction = function(t, e, n, i) {
+ i ? e.copyFromFloats(0, 0, 0) : u.e.TransformCoordinatesFromFloatsToRef(0, 0, 0, t, e);
+ }, r.prototype.clone = function() {
+ var t = new r();
+ return de.a.DeepCopy(this, t), t;
+ }, r.prototype.applyToShader = function(t) {
+ t.setVector3("direction1", this.direction1), t.setVector3("direction2", this.direction2);
+ }, r.prototype.getEffectDefines = function() {
+ return "#define POINTEMITTER";
+ }, r.prototype.getClassName = function() {
+ return "PointParticleEmitter";
+ }, r.prototype.serialize = function() {
+ var t = {};
+ return t.type = this.getClassName(), t.direction1 = this.direction1.asArray(), t.direction2 = this.direction2.asArray(), t;
+ }, r.prototype.parse = function(t) {
+ u.e.FromArrayToRef(t.direction1, 0, this.direction1), u.e.FromArrayToRef(t.direction2, 0, this.direction2);
+ }, r;
+ }(), aa = function() {
+ function r(t, e, n) {
+ t === void 0 && (t = 1), e === void 0 && (e = 1), n === void 0 && (n = 0), this.radius = t, this.radiusRange = e, this.directionRandomizer = n;
+ }
+ return r.prototype.startDirectionFunction = function(t, e, n, i) {
+ var o = n.position.subtract(t.getTranslation()).normalize(), a = $.a.RandomRange(0, this.directionRandomizer), s = $.a.RandomRange(0, this.directionRandomizer), d = $.a.RandomRange(0, this.directionRandomizer);
+ o.x += a, o.y += s, o.z += d, o.normalize(), i ? e.copyFrom(o) : u.e.TransformNormalFromFloatsToRef(o.x, o.y, o.z, t, e);
+ }, r.prototype.startPositionFunction = function(t, e, n, i) {
+ var o = this.radius - $.a.RandomRange(0, this.radius * this.radiusRange), a = $.a.RandomRange(0, 1), s = $.a.RandomRange(0, 2 * Math.PI), d = Math.acos(2 * a - 1), p = o * Math.cos(s) * Math.sin(d), y = o * Math.cos(d), P = o * Math.sin(s) * Math.sin(d);
+ i ? e.copyFromFloats(p, y, P) : u.e.TransformCoordinatesFromFloatsToRef(p, y, P, t, e);
+ }, r.prototype.clone = function() {
+ var t = new r(this.radius, this.directionRandomizer);
+ return de.a.DeepCopy(this, t), t;
+ }, r.prototype.applyToShader = function(t) {
+ t.setFloat("radius", this.radius), t.setFloat("radiusRange", this.radiusRange), t.setFloat("directionRandomizer", this.directionRandomizer);
+ }, r.prototype.getEffectDefines = function() {
+ return "#define SPHEREEMITTER";
+ }, r.prototype.getClassName = function() {
+ return "SphereParticleEmitter";
+ }, r.prototype.serialize = function() {
+ var t = {};
+ return t.type = this.getClassName(), t.radius = this.radius, t.radiusRange = this.radiusRange, t.directionRandomizer = this.directionRandomizer, t;
+ }, r.prototype.parse = function(t) {
+ this.radius = t.radius, this.radiusRange = t.radiusRange, this.directionRandomizer = t.directionRandomizer;
+ }, r;
+ }(), Zs = function(r) {
+ function t(e, n, i) {
+ e === void 0 && (e = 1), n === void 0 && (n = new u.e(0, 1, 0)), i === void 0 && (i = new u.e(0, 1, 0));
+ var o = r.call(this, e) || this;
+ return o.direction1 = n, o.direction2 = i, o;
+ }
+ return Object(c.d)(t, r), t.prototype.startDirectionFunction = function(e, n, i) {
+ var o = $.a.RandomRange(this.direction1.x, this.direction2.x), a = $.a.RandomRange(this.direction1.y, this.direction2.y), s = $.a.RandomRange(this.direction1.z, this.direction2.z);
+ u.e.TransformNormalFromFloatsToRef(o, a, s, e, n);
+ }, t.prototype.clone = function() {
+ var e = new t(this.radius, this.direction1, this.direction2);
+ return de.a.DeepCopy(this, e), e;
+ }, t.prototype.applyToShader = function(e) {
+ e.setFloat("radius", this.radius), e.setFloat("radiusRange", this.radiusRange), e.setVector3("direction1", this.direction1), e.setVector3("direction2", this.direction2);
+ }, t.prototype.getEffectDefines = function() {
+ return `#define SPHEREEMITTER
+#define DIRECTEDSPHEREEMITTER`;
+ }, t.prototype.getClassName = function() {
+ return "SphereDirectedParticleEmitter";
+ }, t.prototype.serialize = function() {
+ var e = r.prototype.serialize.call(this);
+ return e.direction1 = this.direction1.asArray(), e.direction2 = this.direction2.asArray(), e;
+ }, t.prototype.parse = function(e) {
+ r.prototype.parse.call(this, e), this.direction1.copyFrom(e.direction1), this.direction2.copyFrom(e.direction2);
+ }, t;
+ }(aa), Cr = function() {
+ function r() {
+ this.particlePositionGenerator = function() {
+ }, this.particleDestinationGenerator = function() {
+ };
+ }
+ return r.prototype.startDirectionFunction = function(t, e, n, i) {
+ var o = u.c.Vector3[0];
+ if (this.particleDestinationGenerator) {
+ this.particleDestinationGenerator(-1, n, o);
+ var a = u.c.Vector3[1];
+ o.subtractToRef(n.position, a), a.scaleToRef(1 / n.lifeTime, o);
+ } else
+ o.set(0, 0, 0);
+ i ? e.copyFrom(o) : u.e.TransformNormalToRef(o, t, e);
+ }, r.prototype.startPositionFunction = function(t, e, n, i) {
+ var o = u.c.Vector3[0];
+ this.particlePositionGenerator ? this.particlePositionGenerator(-1, n, o) : o.set(0, 0, 0), i ? e.copyFrom(o) : u.e.TransformCoordinatesToRef(o, t, e);
+ }, r.prototype.clone = function() {
+ var t = new r();
+ return de.a.DeepCopy(this, t), t;
+ }, r.prototype.applyToShader = function(t) {
+ }, r.prototype.getEffectDefines = function() {
+ return "#define CUSTOMEMITTER";
+ }, r.prototype.getClassName = function() {
+ return "CustomParticleEmitter";
+ }, r.prototype.serialize = function() {
+ var t = {};
+ return t.type = this.getClassName(), t;
+ }, r.prototype.parse = function(t) {
+ }, r;
+ }(), Ku = function() {
+ function r(t) {
+ t === void 0 && (t = null), this._indices = null, this._positions = null, this._normals = null, this._storedNormal = u.e.Zero(), this._mesh = null, this.direction1 = new u.e(0, 1, 0), this.direction2 = new u.e(0, 1, 0), this.useMeshNormalsForDirection = !0, this.mesh = t;
+ }
+ return Object.defineProperty(r.prototype, "mesh", { get: function() {
+ return this._mesh;
+ }, set: function(t) {
+ this._mesh !== t && (this._mesh = t, t ? (this._indices = t.getIndices(), this._positions = t.getVerticesData(Oe.b.PositionKind), this._normals = t.getVerticesData(Oe.b.NormalKind)) : (this._indices = null, this._positions = null, this._normals = null));
+ }, enumerable: !1, configurable: !0 }), r.prototype.startDirectionFunction = function(t, e, n, i) {
+ if (this.useMeshNormalsForDirection && this._normals)
+ u.e.TransformNormalToRef(this._storedNormal, t, e);
+ else {
+ var o = $.a.RandomRange(this.direction1.x, this.direction2.x), a = $.a.RandomRange(this.direction1.y, this.direction2.y), s = $.a.RandomRange(this.direction1.z, this.direction2.z);
+ i ? e.copyFromFloats(o, a, s) : u.e.TransformNormalFromFloatsToRef(o, a, s, t, e);
+ }
+ }, r.prototype.startPositionFunction = function(t, e, n, i) {
+ if (this._indices && this._positions) {
+ var o = 3 * Math.random() * (this._indices.length / 3) | 0, a = Math.random(), s = Math.random() * (1 - a), d = 1 - a - s, p = this._indices[o], y = this._indices[o + 1], P = this._indices[o + 2], R = u.c.Vector3[0], B = u.c.Vector3[1], F = u.c.Vector3[2], z = u.c.Vector3[3];
+ u.e.FromArrayToRef(this._positions, 3 * p, R), u.e.FromArrayToRef(this._positions, 3 * y, B), u.e.FromArrayToRef(this._positions, 3 * P, F), z.x = a * R.x + s * B.x + d * F.x, z.y = a * R.y + s * B.y + d * F.y, z.z = a * R.z + s * B.z + d * F.z, i ? e.copyFromFloats(z.x, z.y, z.z) : u.e.TransformCoordinatesFromFloatsToRef(z.x, z.y, z.z, t, e), this.useMeshNormalsForDirection && this._normals && (u.e.FromArrayToRef(this._normals, 3 * p, R), u.e.FromArrayToRef(this._normals, 3 * y, B), u.e.FromArrayToRef(this._normals, 3 * P, F), this._storedNormal.x = a * R.x + s * B.x + d * F.x, this._storedNormal.y = a * R.y + s * B.y + d * F.y, this._storedNormal.z = a * R.z + s * B.z + d * F.z);
+ }
+ }, r.prototype.clone = function() {
+ var t = new r(this.mesh);
+ return de.a.DeepCopy(this, t), t;
+ }, r.prototype.applyToShader = function(t) {
+ t.setVector3("direction1", this.direction1), t.setVector3("direction2", this.direction2);
+ }, r.prototype.getEffectDefines = function() {
+ return "";
+ }, r.prototype.getClassName = function() {
+ return "MeshParticleEmitter";
+ }, r.prototype.serialize = function() {
+ var t, e = {};
+ return e.type = this.getClassName(), e.direction1 = this.direction1.asArray(), e.direction2 = this.direction2.asArray(), e.meshId = (t = this.mesh) === null || t === void 0 ? void 0 : t.id, e.useMeshNormalsForDirection = this.useMeshNormalsForDirection, e;
+ }, r.prototype.parse = function(t, e) {
+ u.e.FromArrayToRef(t.direction1, 0, this.direction1), u.e.FromArrayToRef(t.direction2, 0, this.direction2), t.meshId && e && (this.mesh = e.getLastMeshByID(t.meshId)), this.useMeshNormalsForDirection = t.useMeshNormalsForDirection;
+ }, r;
+ }(), co = function() {
+ function r(t) {
+ this.animations = [], this.renderingGroupId = 0, this.emitter = u.e.Zero(), this.emitRate = 10, this.manualEmitCount = -1, this.updateSpeed = 0.01, this.targetStopDuration = 0, this.disposeOnStop = !1, this.minEmitPower = 1, this.maxEmitPower = 1, this.minLifeTime = 1, this.maxLifeTime = 1, this.minSize = 1, this.maxSize = 1, this.minScaleX = 1, this.maxScaleX = 1, this.minScaleY = 1, this.maxScaleY = 1, this.minInitialRotation = 0, this.maxInitialRotation = 0, this.minAngularSpeed = 0, this.maxAngularSpeed = 0, this.layerMask = 268435455, this.customShader = null, this.preventAutoStart = !1, this.noiseStrength = new u.e(10, 10, 10), this.onAnimationEnd = null, this.blendMode = r.BLENDMODE_ONEONE, this.forceDepthWrite = !1, this.preWarmCycles = 0, this.preWarmStepOffset = 1, this.spriteCellChangeSpeed = 1, this.startSpriteCellID = 0, this.endSpriteCellID = 0, this.spriteCellWidth = 0, this.spriteCellHeight = 0, this.spriteRandomStartCell = !1, this.translationPivot = new u.d(0, 0), this.beginAnimationOnStart = !1, this.beginAnimationFrom = 0, this.beginAnimationTo = 60, this.beginAnimationLoop = !1, this.worldOffset = new u.e(0, 0, 0), this.gravity = u.e.Zero(), this._colorGradients = null, this._sizeGradients = null, this._lifeTimeGradients = null, this._angularSpeedGradients = null, this._velocityGradients = null, this._limitVelocityGradients = null, this._dragGradients = null, this._emitRateGradients = null, this._startSizeGradients = null, this._rampGradients = null, this._colorRemapGradients = null, this._alphaRemapGradients = null, this.startDelay = 0, this.limitVelocityDamping = 0.4, this.color1 = new I.b(1, 1, 1, 1), this.color2 = new I.b(1, 1, 1, 1), this.colorDead = new I.b(0, 0, 0, 1), this.textureMask = new I.b(1, 1, 1, 1), this._isSubEmitter = !1, this.billboardMode = h.a.PARTICLES_BILLBOARDMODE_ALL, this._isBillboardBased = !0, this._imageProcessingConfigurationDefines = new vn.b(), this.id = t, this.name = t;
+ }
+ return Object.defineProperty(r.prototype, "noiseTexture", { get: function() {
+ return this._noiseTexture;
+ }, set: function(t) {
+ this._noiseTexture !== t && (this._noiseTexture = t, this._reset());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "isAnimationSheetEnabled", { get: function() {
+ return this._isAnimationSheetEnabled;
+ }, set: function(t) {
+ this._isAnimationSheetEnabled != t && (this._isAnimationSheetEnabled = t, this._reset());
+ }, enumerable: !1, configurable: !0 }), r.prototype.getScene = function() {
+ return this._scene;
+ }, r.prototype._hasTargetStopDurationDependantGradient = function() {
+ return this._startSizeGradients && this._startSizeGradients.length > 0 || this._emitRateGradients && this._emitRateGradients.length > 0 || this._lifeTimeGradients && this._lifeTimeGradients.length > 0;
+ }, r.prototype.getDragGradients = function() {
+ return this._dragGradients;
+ }, r.prototype.getLimitVelocityGradients = function() {
+ return this._limitVelocityGradients;
+ }, r.prototype.getColorGradients = function() {
+ return this._colorGradients;
+ }, r.prototype.getSizeGradients = function() {
+ return this._sizeGradients;
+ }, r.prototype.getColorRemapGradients = function() {
+ return this._colorRemapGradients;
+ }, r.prototype.getAlphaRemapGradients = function() {
+ return this._alphaRemapGradients;
+ }, r.prototype.getLifeTimeGradients = function() {
+ return this._lifeTimeGradients;
+ }, r.prototype.getAngularSpeedGradients = function() {
+ return this._angularSpeedGradients;
+ }, r.prototype.getVelocityGradients = function() {
+ return this._velocityGradients;
+ }, r.prototype.getStartSizeGradients = function() {
+ return this._startSizeGradients;
+ }, r.prototype.getEmitRateGradients = function() {
+ return this._emitRateGradients;
+ }, Object.defineProperty(r.prototype, "direction1", { get: function() {
+ return this.particleEmitterType.direction1 ? this.particleEmitterType.direction1 : u.e.Zero();
+ }, set: function(t) {
+ this.particleEmitterType.direction1 && (this.particleEmitterType.direction1 = t);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "direction2", { get: function() {
+ return this.particleEmitterType.direction2 ? this.particleEmitterType.direction2 : u.e.Zero();
+ }, set: function(t) {
+ this.particleEmitterType.direction2 && (this.particleEmitterType.direction2 = t);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "minEmitBox", { get: function() {
+ return this.particleEmitterType.minEmitBox ? this.particleEmitterType.minEmitBox : u.e.Zero();
+ }, set: function(t) {
+ this.particleEmitterType.minEmitBox && (this.particleEmitterType.minEmitBox = t);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "maxEmitBox", { get: function() {
+ return this.particleEmitterType.maxEmitBox ? this.particleEmitterType.maxEmitBox : u.e.Zero();
+ }, set: function(t) {
+ this.particleEmitterType.maxEmitBox && (this.particleEmitterType.maxEmitBox = t);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "isBillboardBased", { get: function() {
+ return this._isBillboardBased;
+ }, set: function(t) {
+ this._isBillboardBased !== t && (this._isBillboardBased = t, this._reset());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "imageProcessingConfiguration", { get: function() {
+ return this._imageProcessingConfiguration;
+ }, set: function(t) {
+ this._attachImageProcessingConfiguration(t);
+ }, enumerable: !1, configurable: !0 }), r.prototype._attachImageProcessingConfiguration = function(t) {
+ t !== this._imageProcessingConfiguration && (!t && this._scene ? this._imageProcessingConfiguration = this._scene.imageProcessingConfiguration : this._imageProcessingConfiguration = t);
+ }, r.prototype._reset = function() {
+ }, r.prototype._removeGradientAndTexture = function(t, e, n) {
+ if (!e)
+ return this;
+ for (var i = 0, o = 0, a = e; o < a.length; o++) {
+ if (a[o].gradient === t) {
+ e.splice(i, 1);
+ break;
+ }
+ i++;
+ }
+ return n && n.dispose(), this;
+ }, r.prototype.createPointEmitter = function(t, e) {
+ var n = new qs();
+ return n.direction1 = t, n.direction2 = e, this.particleEmitterType = n, n;
+ }, r.prototype.createHemisphericEmitter = function(t, e) {
+ t === void 0 && (t = 1), e === void 0 && (e = 1);
+ var n = new Qs(t, e);
+ return this.particleEmitterType = n, n;
+ }, r.prototype.createSphereEmitter = function(t, e) {
+ t === void 0 && (t = 1), e === void 0 && (e = 1);
+ var n = new aa(t, e);
+ return this.particleEmitterType = n, n;
+ }, r.prototype.createDirectedSphereEmitter = function(t, e, n) {
+ t === void 0 && (t = 1), e === void 0 && (e = new u.e(0, 1, 0)), n === void 0 && (n = new u.e(0, 1, 0));
+ var i = new Zs(t, e, n);
+ return this.particleEmitterType = i, i;
+ }, r.prototype.createCylinderEmitter = function(t, e, n, i) {
+ t === void 0 && (t = 1), e === void 0 && (e = 1), n === void 0 && (n = 1), i === void 0 && (i = 0);
+ var o = new oa(t, e, n, i);
+ return this.particleEmitterType = o, o;
+ }, r.prototype.createDirectedCylinderEmitter = function(t, e, n, i, o) {
+ t === void 0 && (t = 1), e === void 0 && (e = 1), n === void 0 && (n = 1), i === void 0 && (i = new u.e(0, 1, 0)), o === void 0 && (o = new u.e(0, 1, 0));
+ var a = new Ks(t, e, n, i, o);
+ return this.particleEmitterType = a, a;
+ }, r.prototype.createConeEmitter = function(t, e) {
+ t === void 0 && (t = 1), e === void 0 && (e = Math.PI / 4);
+ var n = new Ys(t, e);
+ return this.particleEmitterType = n, n;
+ }, r.prototype.createBoxEmitter = function(t, e, n, i) {
+ var o = new xr();
+ return this.particleEmitterType = o, this.direction1 = t, this.direction2 = e, this.minEmitBox = n, this.maxEmitBox = i, o;
+ }, r.BLENDMODE_ONEONE = 0, r.BLENDMODE_STANDARD = 1, r.BLENDMODE_ADD = 2, r.BLENDMODE_MULTIPLY = 3, r.BLENDMODE_MULTIPLYADD = 4, r;
+ }(), Js = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("rgba", le.Color4, !0), n.registerInput("rgb ", le.Color3, !0), n.registerOutput("rgb", le.Color3), n.registerOutput("r", le.Float), n.registerOutput("g", le.Float), n.registerOutput("b", le.Float), n.registerOutput("a", le.Float), n.inputsAreExclusive = !0, n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "ColorSplitterBlock";
+ }, Object.defineProperty(t.prototype, "rgba", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgbIn", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgbOut", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "r", { get: function() {
+ return this._outputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "g", { get: function() {
+ return this._outputs[2];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "b", { get: function() {
+ return this._outputs[3];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "a", { get: function() {
+ return this._outputs[4];
+ }, enumerable: !1, configurable: !0 }), t.prototype._inputRename = function(e) {
+ return e === "rgb " ? "rgbIn" : e;
+ }, t.prototype._outputRename = function(e) {
+ return e === "rgb" ? "rgbOut" : e;
+ }, t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this.rgba.isConnected ? this.rgba : this.rgbIn;
+ if (n.isConnected) {
+ var i = this._outputs[0], o = this._outputs[1], a = this._outputs[2], s = this._outputs[3], d = this._outputs[4];
+ return i.hasEndpoints && (e.compilationString += this._declareOutput(i, e) + " = " + n.associatedVariableName + `.rgb;\r
+`), o.hasEndpoints && (e.compilationString += this._declareOutput(o, e) + " = " + n.associatedVariableName + `.r;\r
+`), a.hasEndpoints && (e.compilationString += this._declareOutput(a, e) + " = " + n.associatedVariableName + `.g;\r
+`), s.hasEndpoints && (e.compilationString += this._declareOutput(s, e) + " = " + n.associatedVariableName + `.b;\r
+`), d.hasEndpoints && (e.compilationString += this._declareOutput(d, e) + " = " + n.associatedVariableName + `.a;\r
+`), this;
+ }
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.ColorSplitterBlock"] = Js;
+ var tn, Qu = f(104);
+ (function(r) {
+ r[r.Cos = 0] = "Cos", r[r.Sin = 1] = "Sin", r[r.Abs = 2] = "Abs", r[r.Exp = 3] = "Exp", r[r.Exp2 = 4] = "Exp2", r[r.Round = 5] = "Round", r[r.Floor = 6] = "Floor", r[r.Ceiling = 7] = "Ceiling", r[r.Sqrt = 8] = "Sqrt", r[r.Log = 9] = "Log", r[r.Tan = 10] = "Tan", r[r.ArcTan = 11] = "ArcTan", r[r.ArcCos = 12] = "ArcCos", r[r.ArcSin = 13] = "ArcSin", r[r.Fract = 14] = "Fract", r[r.Sign = 15] = "Sign", r[r.Radians = 16] = "Radians", r[r.Degrees = 17] = "Degrees";
+ })(tn || (tn = {}));
+ var $s = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.operation = tn.Cos, n.registerInput("input", le.AutoDetect), n.registerOutput("output", le.BasedOnInput), n._outputs[0]._typeConnectionSource = n._inputs[0], n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "TrigonometryBlock";
+ }, Object.defineProperty(t.prototype, "input", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0], i = "";
+ switch (this.operation) {
+ case tn.Cos:
+ i = "cos";
+ break;
+ case tn.Sin:
+ i = "sin";
+ break;
+ case tn.Abs:
+ i = "abs";
+ break;
+ case tn.Exp:
+ i = "exp";
+ break;
+ case tn.Exp2:
+ i = "exp2";
+ break;
+ case tn.Round:
+ i = "round";
+ break;
+ case tn.Floor:
+ i = "floor";
+ break;
+ case tn.Ceiling:
+ i = "ceil";
+ break;
+ case tn.Sqrt:
+ i = "sqrt";
+ break;
+ case tn.Log:
+ i = "log";
+ break;
+ case tn.Tan:
+ i = "tan";
+ break;
+ case tn.ArcTan:
+ i = "atan";
+ break;
+ case tn.ArcCos:
+ i = "acos";
+ break;
+ case tn.ArcSin:
+ i = "asin";
+ break;
+ case tn.Fract:
+ i = "fract";
+ break;
+ case tn.Sign:
+ i = "sign";
+ break;
+ case tn.Radians:
+ i = "radians";
+ break;
+ case tn.Degrees:
+ i = "degrees";
+ }
+ return e.compilationString += this._declareOutput(n, e) + " = " + i + "(" + this.input.associatedVariableName + `);\r
+`, this;
+ }, t.prototype.serialize = function() {
+ var e = r.prototype.serialize.call(this);
+ return e.operation = this.operation, e;
+ }, t.prototype._deserialize = function(e, n, i) {
+ r.prototype._deserialize.call(this, e, n, i), this.operation = e.operation;
+ }, t.prototype._dumpPropertiesCode = function() {
+ return this._codeVariableName + ".operation = BABYLON.TrigonometryBlockOperations." + tn[this.operation] + `;\r
+`;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.TrigonometryBlock"] = $s;
+ var ec = { effect: null, subMesh: null }, lo = function(r) {
+ function t() {
+ var e = r.call(this) || this;
+ return e.NORMAL = !1, e.TANGENT = !1, e.UV1 = !1, e.NUM_BONE_INFLUENCERS = 0, e.BonesPerMesh = 0, e.BONETEXTURE = !1, e.MORPHTARGETS = !1, e.MORPHTARGETS_NORMAL = !1, e.MORPHTARGETS_TANGENT = !1, e.MORPHTARGETS_UV = !1, e.NUM_MORPH_INFLUENCERS = 0, e.IMAGEPROCESSING = !1, e.VIGNETTE = !1, e.VIGNETTEBLENDMODEMULTIPLY = !1, e.VIGNETTEBLENDMODEOPAQUE = !1, e.TONEMAPPING = !1, e.TONEMAPPING_ACES = !1, e.CONTRAST = !1, e.EXPOSURE = !1, e.COLORCURVES = !1, e.COLORGRADING = !1, e.COLORGRADING3D = !1, e.SAMPLER3DGREENDEPTH = !1, e.SAMPLER3DBGRMAP = !1, e.IMAGEPROCESSINGPOSTPROCESS = !1, e.BUMPDIRECTUV = 0, e.rebuild(), e;
+ }
+ return Object(c.d)(t, r), t.prototype.setValue = function(e, n, i) {
+ i === void 0 && (i = !1), this[e] === void 0 && this._keys.push(e), i && this[e] !== n && this.markAsUnprocessed(), this[e] = n;
+ }, t;
+ }(zo.a), sa = function(r) {
+ function t(e, n, i) {
+ i === void 0 && (i = {});
+ var o = r.call(this, e, n || Ue.a.LastCreatedScene) || this;
+ return o._buildId = t._BuildIdGenerator++, o._buildWasSuccessful = !1, o._cachedWorldViewMatrix = new u.a(), o._cachedWorldViewProjectionMatrix = new u.a(), o._optimizers = new Array(), o._animationFrame = -1, o.BJSNODEMATERIALEDITOR = o._getGlobalNodeMaterialEditor(), o.editorData = null, o.ignoreAlpha = !1, o.maxSimultaneousLights = 4, o.onBuildObservable = new C.c(), o._vertexOutputNodes = new Array(), o._fragmentOutputNodes = new Array(), o.attachedBlocks = new Array(), o._mode = Rn.Material, o._options = Object(c.a)({ emitComments: !1 }, i), o._attachImageProcessingConfiguration(null), o;
+ }
+ return Object(c.d)(t, r), t.prototype._getGlobalNodeMaterialEditor = function() {
+ return typeof NODEEDITOR < "u" ? NODEEDITOR : typeof BABYLON < "u" && BABYLON.NodeEditor !== void 0 ? BABYLON : void 0;
+ }, Object.defineProperty(t.prototype, "options", { get: function() {
+ return this._options;
+ }, set: function(e) {
+ this._options = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "imageProcessingConfiguration", { get: function() {
+ return this._imageProcessingConfiguration;
+ }, set: function(e) {
+ this._attachImageProcessingConfiguration(e), this._markAllSubMeshesAsTexturesDirty();
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "mode", { get: function() {
+ return this._mode;
+ }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
+ return "NodeMaterial";
+ }, t.prototype._attachImageProcessingConfiguration = function(e) {
+ var n = this;
+ e !== this._imageProcessingConfiguration && (this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver), this._imageProcessingConfiguration = e || this.getScene().imageProcessingConfiguration, this._imageProcessingConfiguration && (this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function() {
+ n._markAllSubMeshesAsImageProcessingDirty();
+ })));
+ }, t.prototype.getBlockByName = function(e) {
+ for (var n = null, i = 0, o = this.attachedBlocks; i < o.length; i++) {
+ var a = o[i];
+ if (a.name === e) {
+ if (n)
+ return Xe.b.Warn("More than one block was found with the name `" + e + "`"), n;
+ n = a;
+ }
+ }
+ return n;
+ }, t.prototype.getBlockByPredicate = function(e) {
+ for (var n = 0, i = this.attachedBlocks; n < i.length; n++) {
+ var o = i[n];
+ if (e(o))
+ return o;
+ }
+ return null;
+ }, t.prototype.getInputBlockByPredicate = function(e) {
+ for (var n = 0, i = this.attachedBlocks; n < i.length; n++) {
+ var o = i[n];
+ if (o.isInput && e(o))
+ return o;
+ }
+ return null;
+ }, t.prototype.getInputBlocks = function() {
+ for (var e = [], n = 0, i = this.attachedBlocks; n < i.length; n++) {
+ var o = i[n];
+ o.isInput && e.push(o);
+ }
+ return e;
+ }, t.prototype.registerOptimizer = function(e) {
+ if (!(this._optimizers.indexOf(e) > -1))
+ return this._optimizers.push(e), this;
+ }, t.prototype.unregisterOptimizer = function(e) {
+ var n = this._optimizers.indexOf(e);
+ if (n !== -1)
+ return this._optimizers.splice(n, 1), this;
+ }, t.prototype.addOutputNode = function(e) {
+ if (e.target === null)
+ throw "This node is not meant to be an output node. You may want to explicitly set its target value.";
+ return e.target & Ce.Vertex && this._addVertexOutputNode(e), e.target & Ce.Fragment && this._addFragmentOutputNode(e), this;
+ }, t.prototype.removeOutputNode = function(e) {
+ return e.target === null || (e.target & Ce.Vertex && this._removeVertexOutputNode(e), e.target & Ce.Fragment && this._removeFragmentOutputNode(e)), this;
+ }, t.prototype._addVertexOutputNode = function(e) {
+ if (this._vertexOutputNodes.indexOf(e) === -1)
+ return e.target = Ce.Vertex, this._vertexOutputNodes.push(e), this;
+ }, t.prototype._removeVertexOutputNode = function(e) {
+ var n = this._vertexOutputNodes.indexOf(e);
+ if (n !== -1)
+ return this._vertexOutputNodes.splice(n, 1), this;
+ }, t.prototype._addFragmentOutputNode = function(e) {
+ if (this._fragmentOutputNodes.indexOf(e) === -1)
+ return e.target = Ce.Fragment, this._fragmentOutputNodes.push(e), this;
+ }, t.prototype._removeFragmentOutputNode = function(e) {
+ var n = this._fragmentOutputNodes.indexOf(e);
+ if (n !== -1)
+ return this._fragmentOutputNodes.splice(n, 1), this;
+ }, t.prototype.needAlphaBlending = function() {
+ return !this.ignoreAlpha && (this.alpha < 1 || this._sharedData && this._sharedData.hints.needAlphaBlending);
+ }, t.prototype.needAlphaTesting = function() {
+ return this._sharedData && this._sharedData.hints.needAlphaTesting;
+ }, t.prototype._initializeBlock = function(e, n, i) {
+ if (e.initialize(n), e.autoConfigure(this), e._preparationId = this._buildId, this.attachedBlocks.indexOf(e) === -1) {
+ if (e.isUnique) {
+ for (var o = e.getClassName(), a = 0, s = this.attachedBlocks; a < s.length; a++)
+ if (s[a].getClassName() === o)
+ throw "Cannot have multiple blocks of type " + o + " in the same NodeMaterial";
+ }
+ this.attachedBlocks.push(e);
+ }
+ for (var d = 0, p = e.inputs; d < p.length; d++) {
+ var y = p[d];
+ y.associatedVariableName = "";
+ var P = y.connectedPoint;
+ if (P) {
+ var R = P.ownerBlock;
+ R !== e && ((R.target === Ce.VertexAndFragment || n.target === Ce.Fragment && R.target === Ce.Vertex && R._preparationId !== this._buildId) && i.push(R), this._initializeBlock(R, n, i));
+ }
+ }
+ for (var B = 0, F = e.outputs; B < F.length; B++)
+ F[B].associatedVariableName = "";
+ }, t.prototype._resetDualBlocks = function(e, n) {
+ e.target === Ce.VertexAndFragment && (e.buildId = n);
+ for (var i = 0, o = e.inputs; i < o.length; i++) {
+ var a = o[i].connectedPoint;
+ if (a) {
+ var s = a.ownerBlock;
+ s !== e && this._resetDualBlocks(s, n);
+ }
+ }
+ }, t.prototype.removeBlock = function(e) {
+ var n = this.attachedBlocks.indexOf(e);
+ n > -1 && this.attachedBlocks.splice(n, 1), e.isFinalMerger && this.removeOutputNode(e);
+ }, t.prototype.build = function(e) {
+ e === void 0 && (e = !1), this._buildWasSuccessful = !1;
+ var n = this.getScene().getEngine(), i = this._mode === Rn.Particle;
+ if (this._vertexOutputNodes.length === 0 && !i)
+ throw "You must define at least one vertexOutputNode";
+ if (this._fragmentOutputNodes.length === 0)
+ throw "You must define at least one fragmentOutputNode";
+ this._vertexCompilationState = new Xu(), this._vertexCompilationState.supportUniformBuffers = n.supportsUniformBuffers, this._vertexCompilationState.target = Ce.Vertex, this._fragmentCompilationState = new Xu(), this._fragmentCompilationState.supportUniformBuffers = n.supportsUniformBuffers, this._fragmentCompilationState.target = Ce.Fragment, this._sharedData = new G_(), this._vertexCompilationState.sharedData = this._sharedData, this._fragmentCompilationState.sharedData = this._sharedData, this._sharedData.buildId = this._buildId, this._sharedData.emitComments = this._options.emitComments, this._sharedData.verbose = e, this._sharedData.scene = this.getScene(), this._sharedData.allowEmptyVertexProgram = i;
+ for (var o = [], a = [], s = 0, d = this._vertexOutputNodes; s < d.length; s++) {
+ var p = d[s];
+ o.push(p), this._initializeBlock(p, this._vertexCompilationState, a);
+ }
+ for (var y = 0, P = this._fragmentOutputNodes; y < P.length; y++) {
+ var R = P[y];
+ a.push(R), this._initializeBlock(R, this._fragmentCompilationState, o);
+ }
+ this.optimize();
+ for (var B = 0, F = o; B < F.length; B++)
+ (p = F[B]).build(this._vertexCompilationState, o);
+ this._fragmentCompilationState.uniforms = this._vertexCompilationState.uniforms.slice(0), this._fragmentCompilationState._uniformDeclaration = this._vertexCompilationState._uniformDeclaration, this._fragmentCompilationState._constantDeclaration = this._vertexCompilationState._constantDeclaration, this._fragmentCompilationState._vertexState = this._vertexCompilationState;
+ for (var z = 0, J = a; z < J.length; z++)
+ R = J[z], this._resetDualBlocks(R, this._buildId - 1);
+ for (var ie = 0, se = a; ie < se.length; ie++)
+ (R = se[ie]).build(this._fragmentCompilationState, a);
+ this._vertexCompilationState.finalize(this._vertexCompilationState), this._fragmentCompilationState.finalize(this._fragmentCompilationState), this._buildId = t._BuildIdGenerator++, this._sharedData.emitErrors(), e && (console.log("Vertex shader:"), console.log(this._vertexCompilationState.compilationString), console.log("Fragment shader:"), console.log(this._fragmentCompilationState.compilationString)), this._buildWasSuccessful = !0, this.onBuildObservable.notifyObservers(this);
+ for (var ce = 0, ue = this.getScene().meshes; ce < ue.length; ce++) {
+ var fe = ue[ce];
+ if (fe.subMeshes)
+ for (var ve = 0, Te = fe.subMeshes; ve < Te.length; ve++) {
+ var Re = Te[ve];
+ if (Re.getMaterial() === this && Re._materialDefines) {
+ var Ae = Re._materialDefines;
+ Ae.markAllAsDirty(), Ae.reset();
+ }
+ }
+ }
+ }, t.prototype.optimize = function() {
+ for (var e = 0, n = this._optimizers; e < n.length; e++)
+ n[e].optimize(this._vertexOutputNodes, this._fragmentOutputNodes);
+ }, t.prototype._prepareDefinesForAttributes = function(e, n) {
+ var i = n.NORMAL, o = n.TANGENT, a = n.UV1;
+ n.NORMAL = e.isVerticesDataPresent(Oe.b.NormalKind), n.TANGENT = e.isVerticesDataPresent(Oe.b.TangentKind), n.UV1 = e.isVerticesDataPresent(Oe.b.UVKind), i === n.NORMAL && o === n.TANGENT && a === n.UV1 || n.markAsAttributesDirty();
+ }, t.prototype.createPostProcess = function(e, n, i, o, a, s, d) {
+ return n === void 0 && (n = 1), i === void 0 && (i = h.a.TEXTURE_NEAREST_SAMPLINGMODE), s === void 0 && (s = h.a.TEXTURETYPE_UNSIGNED_INT), d === void 0 && (d = h.a.TEXTUREFORMAT_RGBA), this.mode !== Rn.PostProcess ? (console.log("Incompatible material mode"), null) : this._createEffectForPostProcess(null, e, n, i, o, a, s, d);
+ }, t.prototype.createEffectForPostProcess = function(e) {
+ this._createEffectForPostProcess(e);
+ }, t.prototype._createEffectForPostProcess = function(e, n, i, o, a, s, d, p) {
+ var y = this;
+ i === void 0 && (i = 1), o === void 0 && (o = h.a.TEXTURE_NEAREST_SAMPLINGMODE), d === void 0 && (d = h.a.TEXTURETYPE_UNSIGNED_INT), p === void 0 && (p = h.a.TEXTUREFORMAT_RGBA);
+ var P = this.name + this._buildId, R = new lo(), B = new Mt.a(P + "PostProcess", this.getScene()), F = this._buildId;
+ return this._processDefines(B, R), ze.a.RegisterShader(P, this._fragmentCompilationState._builtCompilationString, this._vertexCompilationState._builtCompilationString), e ? e.updateEffect(R.toString(), this._fragmentCompilationState.uniforms, this._fragmentCompilationState.samplers, { maxSimultaneousLights: this.maxSimultaneousLights }, void 0, void 0, P, P) : e = new ft(this.name + "PostProcess", P, this._fragmentCompilationState.uniforms, this._fragmentCompilationState.samplers, i, n, o, a, s, R.toString(), d, P, { maxSimultaneousLights: this.maxSimultaneousLights }, !1, p), e.nodeMaterialSource = this, e.onApplyObservable.add(function(z) {
+ F !== y._buildId && (delete ze.a.ShadersStore[P + "VertexShader"], delete ze.a.ShadersStore[P + "PixelShader"], P = y.name + y._buildId, R.markAsUnprocessed(), F = y._buildId), y._processDefines(B, R) && (ze.a.RegisterShader(P, y._fragmentCompilationState._builtCompilationString, y._vertexCompilationState._builtCompilationString), Qu.a.SetImmediate(function() {
+ return e.updateEffect(R.toString(), y._fragmentCompilationState.uniforms, y._fragmentCompilationState.samplers, { maxSimultaneousLights: y.maxSimultaneousLights }, void 0, void 0, P, P);
+ })), y._checkInternals(z);
+ }), e;
+ }, t.prototype.createProceduralTexture = function(e, n) {
+ var i = this;
+ if (this.mode !== Rn.ProceduralTexture)
+ return console.log("Incompatible material mode"), null;
+ var o = this.name + this._buildId, a = new oo(o, e, null, n), s = new Mt.a(o + "Procedural", this.getScene());
+ s.reservedDataStore = { hidden: !0 };
+ var d = new lo(), p = this._processDefines(s, d);
+ ze.a.RegisterShader(o, this._fragmentCompilationState._builtCompilationString, this._vertexCompilationState._builtCompilationString);
+ var y = this.getScene().getEngine().createEffect({ vertexElement: o, fragmentElement: o }, [Oe.b.PositionKind], this._fragmentCompilationState.uniforms, this._fragmentCompilationState.samplers, d.toString(), p == null ? void 0 : p.fallbacks, void 0);
+ a.nodeMaterialSource = this, a._effect = y;
+ var P = this._buildId;
+ return a.onBeforeGenerationObservable.add(function() {
+ P !== i._buildId && (delete ze.a.ShadersStore[o + "VertexShader"], delete ze.a.ShadersStore[o + "PixelShader"], o = i.name + i._buildId, d.markAsUnprocessed(), P = i._buildId);
+ var R = i._processDefines(s, d);
+ R && (ze.a.RegisterShader(o, i._fragmentCompilationState._builtCompilationString, i._vertexCompilationState._builtCompilationString), Qu.a.SetImmediate(function() {
+ y = i.getScene().getEngine().createEffect({ vertexElement: o, fragmentElement: o }, [Oe.b.PositionKind], i._fragmentCompilationState.uniforms, i._fragmentCompilationState.samplers, d.toString(), R == null ? void 0 : R.fallbacks, void 0), a._effect = y;
+ })), i._checkInternals(y);
+ }), a;
+ }, t.prototype._createEffectForParticles = function(e, n, i, o, a, s, d, p) {
+ var y = this;
+ p === void 0 && (p = "");
+ var P = this.name + this._buildId + "_" + n;
+ s || (s = new lo()), d || (d = this.getScene().getMeshByName(this.name + "Particle")) || ((d = new Mt.a(this.name + "Particle", this.getScene())).reservedDataStore = { hidden: !0 });
+ var R = this._buildId, B = [], F = p;
+ if (!a) {
+ var z = this._processDefines(d, s);
+ ze.a.RegisterShader(P, this._fragmentCompilationState._builtCompilationString), e.fillDefines(B, n), F = B.join(`
+`), a = this.getScene().getEngine().createEffectForParticles(P, this._fragmentCompilationState.uniforms, this._fragmentCompilationState.samplers, s.toString() + `
+` + F, z == null ? void 0 : z.fallbacks, i, o, e), e.setCustomEffect(a, n);
+ }
+ a.onBindObservable.add(function(J) {
+ R !== y._buildId && (delete ze.a.ShadersStore[P + "PixelShader"], P = y.name + y._buildId + "_" + n, s.markAsUnprocessed(), R = y._buildId), B.length = 0, e.fillDefines(B, n);
+ var ie = B.join(`
+`);
+ ie !== F && (s.markAsUnprocessed(), F = ie);
+ var se = y._processDefines(d, s);
+ if (se)
+ return ze.a.RegisterShader(P, y._fragmentCompilationState._builtCompilationString), J = y.getScene().getEngine().createEffectForParticles(P, y._fragmentCompilationState.uniforms, y._fragmentCompilationState.samplers, s.toString() + `
+` + F, se == null ? void 0 : se.fallbacks, i, o, e), e.setCustomEffect(J, n), void y._createEffectForParticles(e, n, i, o, J, s, d, F);
+ y._checkInternals(J);
+ });
+ }, t.prototype._checkInternals = function(e) {
+ if (this._sharedData.animatedInputs) {
+ var n = this.getScene(), i = n.getFrameId();
+ if (this._animationFrame !== i) {
+ for (var o = 0, a = this._sharedData.animatedInputs; o < a.length; o++)
+ a[o].animate(n);
+ this._animationFrame = i;
+ }
+ }
+ for (var s = 0, d = this._sharedData.bindableBlocks; s < d.length; s++)
+ d[s].bind(e, this);
+ for (var p = 0, y = this._sharedData.inputBlocks; p < y.length; p++)
+ y[p]._transmit(e, this.getScene());
+ }, t.prototype.createEffectForParticles = function(e, n, i) {
+ this.mode === Rn.Particle ? (this._createEffectForParticles(e, co.BLENDMODE_ONEONE, n, i), this._createEffectForParticles(e, co.BLENDMODE_MULTIPLY, n, i)) : console.log("Incompatible material mode");
+ }, t.prototype._processDefines = function(e, n, i, o) {
+ var a = this;
+ i === void 0 && (i = !1);
+ var s = null;
+ if (this._sharedData.blocksWithDefines.forEach(function(B) {
+ B.initializeDefines(e, a, n, i);
+ }), this._sharedData.blocksWithDefines.forEach(function(B) {
+ B.prepareDefines(e, a, n, i, o);
+ }), n.isDirty) {
+ var d = n._areLightsDisposed;
+ n.markAsProcessed(), this._vertexCompilationState.compilationString = this._vertexCompilationState._builtCompilationString, this._fragmentCompilationState.compilationString = this._fragmentCompilationState._builtCompilationString, this._sharedData.repeatableContentBlocks.forEach(function(B) {
+ B.replaceRepeatableContent(a._vertexCompilationState, a._fragmentCompilationState, e, n);
+ });
+ var p = [];
+ this._sharedData.dynamicUniformBlocks.forEach(function(B) {
+ B.updateUniformsAndSamples(a._vertexCompilationState, a, n, p);
+ });
+ var y = this._vertexCompilationState.uniforms;
+ this._fragmentCompilationState.uniforms.forEach(function(B) {
+ y.indexOf(B) === -1 && y.push(B);
+ });
+ var P = this._vertexCompilationState.samplers;
+ this._fragmentCompilationState.samplers.forEach(function(B) {
+ P.indexOf(B) === -1 && P.push(B);
+ });
+ var R = new _r.a();
+ this._sharedData.blocksWithFallbacks.forEach(function(B) {
+ B.provideFallbacks(e, R);
+ }), s = { lightDisposed: d, uniformBuffers: p, mergedUniforms: y, mergedSamplers: P, fallbacks: R };
+ }
+ return s;
+ }, t.prototype.isReadyForSubMesh = function(e, n, i) {
+ var o = this;
+ if (i === void 0 && (i = !1), !this._buildWasSuccessful)
+ return !1;
+ var a = this.getScene();
+ if (this._sharedData.animatedInputs) {
+ var s = a.getFrameId();
+ if (this._animationFrame !== s) {
+ for (var d = 0, p = this._sharedData.animatedInputs; d < p.length; d++)
+ p[d].animate(a);
+ this._animationFrame = s;
+ }
+ }
+ if (n.effect && this.isFrozen && n.effect._wasPreviouslyReady)
+ return !0;
+ n._materialDefines || (n._materialDefines = new lo());
+ var y = n._materialDefines;
+ if (this._isReadyForSubMesh(n))
+ return !0;
+ var P = a.getEngine();
+ if (this._prepareDefinesForAttributes(e, y), this._sharedData.blockingBlocks.some(function(J) {
+ return !J.isReady(e, o, y, i);
+ }))
+ return !1;
+ var R = this._processDefines(e, y, i, n);
+ if (R) {
+ var B = n.effect, F = y.toString(), z = P.createEffect({ vertex: "nodeMaterial" + this._buildId, fragment: "nodeMaterial" + this._buildId, vertexSource: this._vertexCompilationState.compilationString, fragmentSource: this._fragmentCompilationState.compilationString }, { attributes: this._vertexCompilationState.attributes, uniformsNames: R.mergedUniforms, uniformBuffersNames: R.uniformBuffers, samplers: R.mergedSamplers, defines: F, fallbacks: R.fallbacks, onCompiled: this.onCompiled, onError: this.onError, indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights, maxSimultaneousMorphTargets: y.NUM_MORPH_INFLUENCERS } }, P);
+ if (z)
+ if (this._onEffectCreatedObservable && (ec.effect = z, ec.subMesh = n, this._onEffectCreatedObservable.notifyObservers(ec)), this.allowShaderHotSwapping && B && !z.isReady()) {
+ if (z = B, y.markAsUnprocessed(), R.lightDisposed)
+ return y._areLightsDisposed = !0, !1;
+ } else
+ a.resetCachedMaterial(), n.setEffect(z, y);
+ }
+ return !(!n.effect || !n.effect.isReady()) && (y._renderId = a.getRenderId(), n.effect._wasPreviouslyReady = !0, !0);
+ }, Object.defineProperty(t.prototype, "compiledShaders", { get: function() {
+ return `// Vertex shader\r
+` + this._vertexCompilationState.compilationString + `\r
+\r
+// Fragment shader\r
+` + this._fragmentCompilationState.compilationString;
+ }, enumerable: !1, configurable: !0 }), t.prototype.bindOnlyWorldMatrix = function(e) {
+ var n = this.getScene();
+ if (this._activeEffect) {
+ var i = this._sharedData.hints;
+ i.needWorldViewMatrix && e.multiplyToRef(n.getViewMatrix(), this._cachedWorldViewMatrix), i.needWorldViewProjectionMatrix && e.multiplyToRef(n.getTransformMatrix(), this._cachedWorldViewProjectionMatrix);
+ for (var o = 0, a = this._sharedData.inputBlocks; o < a.length; o++)
+ a[o]._transmitWorld(this._activeEffect, e, this._cachedWorldViewMatrix, this._cachedWorldViewProjectionMatrix);
+ }
+ }, t.prototype.bindForSubMesh = function(e, n, i) {
+ var o = this.getScene(), a = i.effect;
+ if (a) {
+ if (this._activeEffect = a, this.bindOnlyWorldMatrix(e), this._mustRebind(o, a, n.visibility)) {
+ var s = this._sharedData;
+ if (a && o.getCachedEffect() !== a) {
+ for (var d = 0, p = s.bindableBlocks; d < p.length; d++)
+ p[d].bind(a, this, n, i);
+ for (var y = 0, P = s.inputBlocks; y < P.length; y++)
+ P[y]._transmit(a, o);
+ }
+ }
+ this._afterBind(n, this._activeEffect);
+ }
+ }, t.prototype.getActiveTextures = function() {
+ var e = r.prototype.getActiveTextures.call(this);
+ return this._sharedData && e.push.apply(e, this._sharedData.textureBlocks.filter(function(n) {
+ return n.texture;
+ }).map(function(n) {
+ return n.texture;
+ })), e;
+ }, t.prototype.getTextureBlocks = function() {
+ return this._sharedData ? this._sharedData.textureBlocks : [];
+ }, t.prototype.hasTexture = function(e) {
+ if (r.prototype.hasTexture.call(this, e))
+ return !0;
+ if (!this._sharedData)
+ return !1;
+ for (var n = 0, i = this._sharedData.textureBlocks; n < i.length; n++)
+ if (i[n].texture === e)
+ return !0;
+ return !1;
+ }, t.prototype.dispose = function(e, n, i) {
+ if (n)
+ for (var o = 0, a = this._sharedData.textureBlocks.filter(function(p) {
+ return p.texture;
+ }).map(function(p) {
+ return p.texture;
+ }); o < a.length; o++)
+ a[o].dispose();
+ for (var s = 0, d = this.attachedBlocks; s < d.length; s++)
+ d[s].dispose();
+ this.onBuildObservable.clear(), r.prototype.dispose.call(this, e, n, i);
+ }, t.prototype._createNodeEditor = function() {
+ this.BJSNODEMATERIALEDITOR = this.BJSNODEMATERIALEDITOR || this._getGlobalNodeMaterialEditor(), this.BJSNODEMATERIALEDITOR.NodeEditor.Show({ nodeMaterial: this });
+ }, t.prototype.edit = function(e) {
+ var n = this;
+ return new Promise(function(i, o) {
+ if (n.BJSNODEMATERIALEDITOR === void 0) {
+ var a = e && e.editorURL ? e.editorURL : t.EditorURL;
+ Xe.b.LoadScript(a, function() {
+ n._createNodeEditor(), i();
+ });
+ } else
+ n._createNodeEditor(), i();
+ });
+ }, t.prototype.clear = function() {
+ this._vertexOutputNodes = [], this._fragmentOutputNodes = [], this.attachedBlocks = [];
+ }, t.prototype.setToDefault = function() {
+ this.clear(), this.editorData = null;
+ var e = new Et("Position");
+ e.setAsAttribute("position");
+ var n = new Et("World");
+ n.setAsSystemValue(BABYLON.NodeMaterialSystemValues.World);
+ var i = new ia("WorldPos");
+ e.connectTo(i), n.connectTo(i);
+ var o = new Et("ViewProjection");
+ o.setAsSystemValue(BABYLON.NodeMaterialSystemValues.ViewProjection);
+ var a = new ia("WorldPos * ViewProjectionTransform");
+ i.connectTo(a), o.connectTo(a);
+ var s = new ao("VertexOutput");
+ a.connectTo(s);
+ var d = new Et("color");
+ d.value = new I.b(0.8, 0.8, 0.8, 1);
+ var p = new Pr("FragmentOutput");
+ d.connectTo(p), this.addOutputNode(s), this.addOutputNode(p), this._mode = Rn.Material;
+ }, t.prototype.setToDefaultPostProcess = function() {
+ this.clear(), this.editorData = null;
+ var e = new Et("Position");
+ e.setAsAttribute("position2d");
+ var n = new Et("Constant1");
+ n.isConstant = !0, n.value = 1;
+ var i = new so("Position3D");
+ e.connectTo(i), n.connectTo(i, { input: "w" });
+ var o = new ao("VertexOutput");
+ i.connectTo(o);
+ var a = new Et("Scale");
+ a.visibleInInspector = !0, a.value = new u.d(1, 1);
+ var s = new Xs("uv0");
+ e.connectTo(s);
+ var d = new ra("UV scale");
+ s.connectTo(d), a.connectTo(d);
+ var p = new zs("CurrentScreen");
+ d.connectTo(p), p.texture = new Ne.a("https://assets.babylonjs.com/nme/currentScreenPostProcess.png", this.getScene());
+ var y = new Pr("FragmentOutput");
+ p.connectTo(y, { output: "rgba" }), this.addOutputNode(o), this.addOutputNode(y), this._mode = Rn.PostProcess;
+ }, t.prototype.setToDefaultProceduralTexture = function() {
+ this.clear(), this.editorData = null;
+ var e = new Et("Position");
+ e.setAsAttribute("position2d");
+ var n = new Et("Constant1");
+ n.isConstant = !0, n.value = 1;
+ var i = new so("Position3D");
+ e.connectTo(i), n.connectTo(i, { input: "w" });
+ var o = new ao("VertexOutput");
+ i.connectTo(o);
+ var a = new Et("Time");
+ a.value = 0, a.min = 0, a.max = 0, a.isBoolean = !1, a.matrixMode = 0, a.animationType = Ni.Time, a.isConstant = !1;
+ var s = new Et("Color3");
+ s.value = new I.a(1, 1, 1), s.isConstant = !1;
+ var d = new Pr("FragmentOutput"), p = new so("VectorMerger");
+ p.visibleInInspector = !1;
+ var y = new $s("Cos");
+ y.operation = tn.Cos, e.connectTo(p), a.output.connectTo(y.input), y.output.connectTo(p.z), p.xyzOut.connectTo(d.rgb), this.addOutputNode(o), this.addOutputNode(d), this._mode = Rn.ProceduralTexture;
+ }, t.prototype.setToDefaultParticle = function() {
+ this.clear(), this.editorData = null;
+ var e = new Et("uv");
+ e.setAsAttribute("particle_uv");
+ var n = new js("ParticleTexture");
+ e.connectTo(n);
+ var i = new Et("Color");
+ i.setAsAttribute("particle_color");
+ var o = new ra("Texture * Color");
+ n.connectTo(o), i.connectTo(o);
+ var a = new Hs("ParticleRampGradient");
+ o.connectTo(a);
+ var s = new Js("ColorSplitter");
+ i.connectTo(s);
+ var d = new Ws("ParticleBlendMultiply");
+ a.connectTo(d), n.connectTo(d, { output: "a" }), s.connectTo(d, { output: "a" });
+ var p = new Pr("FragmentOutput");
+ d.connectTo(p), this.addOutputNode(p), this._mode = Rn.Particle;
+ }, t.prototype.loadAsync = function(e) {
+ var n = this;
+ return this.getScene()._loadFileAsync(e).then(function(i) {
+ var o = JSON.parse(i);
+ n.loadFromSerialization(o, "");
+ });
+ }, t.prototype._gatherBlocks = function(e, n) {
+ if (n.indexOf(e) === -1) {
+ n.push(e);
+ for (var i = 0, o = e.inputs; i < o.length; i++) {
+ var a = o[i].connectedPoint;
+ if (a) {
+ var s = a.ownerBlock;
+ s !== e && this._gatherBlocks(s, n);
+ }
+ }
+ }
+ }, t.prototype.generateCode = function() {
+ for (var e = [], n = [], i = [], o = 0, a = this._vertexOutputNodes; o < a.length; o++) {
+ var s = a[o];
+ this._gatherBlocks(s, n);
+ }
+ for (var d = [], p = 0, y = this._fragmentOutputNodes; p < y.length; p++)
+ s = y[p], this._gatherBlocks(s, d);
+ for (var P = 'var nodeMaterial = new BABYLON.NodeMaterial("' + (this.name || "node material") + `");\r
+`, R = 0, B = n; R < B.length; R++)
+ (Re = B[R]).isInput && e.indexOf(Re) === -1 && (P += Re._dumpCode(i, e));
+ for (var F = 0, z = d; F < z.length; F++)
+ (Re = z[F]).isInput && e.indexOf(Re) === -1 && (P += Re._dumpCode(i, e));
+ e = [], P += `\r
+// Connections\r
+`;
+ for (var J = 0, ie = this._vertexOutputNodes; J < ie.length; J++)
+ P += (Re = ie[J])._dumpCodeForOutputConnections(e);
+ for (var se = 0, ce = this._fragmentOutputNodes; se < ce.length; se++)
+ P += (Re = ce[se])._dumpCodeForOutputConnections(e);
+ P += `\r
+// Output nodes\r
+`;
+ for (var ue = 0, fe = this._vertexOutputNodes; ue < fe.length; ue++)
+ P += "nodeMaterial.addOutputNode(" + (Re = fe[ue])._codeVariableName + `);\r
+`;
+ for (var ve = 0, Te = this._fragmentOutputNodes; ve < Te.length; ve++) {
+ var Re;
+ P += "nodeMaterial.addOutputNode(" + (Re = Te[ve])._codeVariableName + `);\r
+`;
+ }
+ return P += `nodeMaterial.build();\r
+`;
+ }, t.prototype.serialize = function(e) {
+ var n = e ? {} : L.a.Serialize(this);
+ n.editorData = JSON.parse(JSON.stringify(this.editorData));
+ var i = [];
+ if (e)
+ i = e;
+ else {
+ n.customType = "BABYLON.NodeMaterial", n.outputNodes = [];
+ for (var o = 0, a = this._vertexOutputNodes; o < a.length; o++) {
+ var s = a[o];
+ this._gatherBlocks(s, i), n.outputNodes.push(s.uniqueId);
+ }
+ for (var d = 0, p = this._fragmentOutputNodes; d < p.length; d++)
+ s = p[d], this._gatherBlocks(s, i), n.outputNodes.indexOf(s.uniqueId) === -1 && n.outputNodes.push(s.uniqueId);
+ }
+ n.blocks = [];
+ for (var y = 0, P = i; y < P.length; y++) {
+ var R = P[y];
+ n.blocks.push(R.serialize());
+ }
+ if (!e)
+ for (var B = 0, F = this.attachedBlocks; B < F.length; B++)
+ R = F[B], i.indexOf(R) === -1 && n.blocks.push(R.serialize());
+ return n;
+ }, t.prototype._restoreConnections = function(e, n, i) {
+ for (var o = 0, a = e.outputs; o < a.length; o++)
+ for (var s = a[o], d = 0, p = n.blocks; d < p.length; d++) {
+ var y = p[d], P = i[y.id];
+ if (P)
+ for (var R = 0, B = y.inputs; R < B.length; R++) {
+ var F = B[R];
+ if (!(i[F.targetBlockId] !== e || F.targetConnectionName !== s.name)) {
+ var z = P.getInputByName(F.inputName);
+ if (!z || z.isConnected)
+ continue;
+ s.connectTo(z, !0), this._restoreConnections(P, n, i);
+ }
+ }
+ }
+ }, t.prototype.loadFromSerialization = function(e, n, i) {
+ var o;
+ n === void 0 && (n = ""), i === void 0 && (i = !1), i || this.clear();
+ for (var a = {}, s = 0, d = e.blocks; s < d.length; s++) {
+ var p = d[s], y = O.a.GetClass(p.customType);
+ y && ((R = new y())._deserialize(p, this.getScene(), n), a[p.id] = R, this.attachedBlocks.push(R));
+ }
+ for (var P = 0; P < e.blocks.length; P++) {
+ var R;
+ (R = a[e.blocks[P].id]) && (R.inputs.length && !i || this._restoreConnections(R, e, a));
+ }
+ if (e.outputNodes)
+ for (var B = 0, F = e.outputNodes; B < F.length; B++) {
+ var z = F[B];
+ this.addOutputNode(a[z]);
+ }
+ if (e.locations || e.editorData && e.editorData.locations) {
+ for (var J = e.locations || e.editorData.locations, ie = 0, se = J; ie < se.length; ie++) {
+ var ce = se[ie];
+ a[ce.blockId] && (ce.blockId = a[ce.blockId].uniqueId);
+ }
+ i && this.editorData && this.editorData.locations && J.concat(this.editorData.locations), e.locations ? this.editorData = { locations: J } : (this.editorData = e.editorData, this.editorData.locations = J);
+ var ue = [];
+ for (var fe in a)
+ ue[fe] = a[fe].uniqueId;
+ this.editorData.map = ue;
+ }
+ this.comment = e.comment, i || (this._mode = (o = e.mode) !== null && o !== void 0 ? o : Rn.Material);
+ }, t.prototype.clone = function(e) {
+ var n = this, i = this.serialize(), o = L.a.Clone(function() {
+ return new t(e, n.getScene(), n.options);
+ }, this);
+ return o.id = e, o.name = e, o.loadFromSerialization(i), o.build(), o;
+ }, t.Parse = function(e, n, i) {
+ i === void 0 && (i = "");
+ var o = L.a.Parse(function() {
+ return new t(e.name, n);
+ }, e, n, i);
+ return o.loadFromSerialization(e, i), o.build(), o;
+ }, t.ParseFromFileAsync = function(e, n, i) {
+ var o = new t(e, i);
+ return new Promise(function(a, s) {
+ return o.loadAsync(n).then(function() {
+ o.build(), a(o);
+ }).catch(s);
+ });
+ }, t.ParseFromSnippetAsync = function(e, n, i, o) {
+ var a = this;
+ return i === void 0 && (i = ""), e === "_BLANK" ? Promise.resolve(this.CreateDefault("blank", n)) : new Promise(function(s, d) {
+ var p = new re.a();
+ p.addEventListener("readystatechange", function() {
+ if (p.readyState == 4)
+ if (p.status == 200) {
+ var y = JSON.parse(JSON.parse(p.responseText).jsonPayload), P = JSON.parse(y.nodeMaterial);
+ o || ((o = L.a.Parse(function() {
+ return new t(e, n);
+ }, P, n, i)).uniqueId = n.getUniqueId()), o.loadFromSerialization(P), o.snippetId = e;
+ try {
+ o.build(), s(o);
+ } catch (R) {
+ d(R);
+ }
+ } else
+ d("Unable to load the snippet " + e);
+ }), p.open("GET", a.SnippetUrl + "/" + e.replace(/#/g, "/")), p.send();
+ });
+ }, t.CreateDefault = function(e, n) {
+ var i = new t(e, n);
+ return i.setToDefault(), i.build(), i;
+ }, t._BuildIdGenerator = 0, t.EditorURL = "https://unpkg.com/babylonjs-node-editor@" + Ue.a.Version + "/babylon.nodeEditor.js", t.SnippetUrl = "https://snippet.babylonjs.com", t.IgnoreTexturesAtLoadTime = !1, Object(c.c)([Object(L.c)("mode")], t.prototype, "_mode", void 0), Object(c.c)([Object(L.c)("comment")], t.prototype, "comment", void 0), t;
+ }(jo.a);
+ O.a.RegisteredTypes["BABYLON.NodeMaterial"] = sa;
+ var qu = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Vertex) || this;
+ return n.registerInput("matricesIndices", le.Vector4), n.registerInput("matricesWeights", le.Vector4), n.registerInput("matricesIndicesExtra", le.Vector4, !0), n.registerInput("matricesWeightsExtra", le.Vector4, !0), n.registerInput("world", le.Matrix), n.registerOutput("output", le.Matrix), n;
+ }
+ return Object(c.d)(t, r), t.prototype.initialize = function(e) {
+ e._excludeVariableName("boneSampler"), e._excludeVariableName("boneTextureWidth"), e._excludeVariableName("mBones"), e._excludeVariableName("BonesPerMesh");
+ }, t.prototype.getClassName = function() {
+ return "BonesBlock";
+ }, Object.defineProperty(t.prototype, "matricesIndices", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "matricesWeights", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "matricesIndicesExtra", { get: function() {
+ return this._inputs[2];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "matricesWeightsExtra", { get: function() {
+ return this._inputs[3];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "world", { get: function() {
+ return this._inputs[4];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function(e) {
+ if (!this.matricesIndices.isConnected) {
+ var n = e.getInputBlockByPredicate(function(a) {
+ return a.isAttribute && a.name === "matricesIndices";
+ });
+ n || (n = new Et("matricesIndices")).setAsAttribute("matricesIndices"), n.output.connectTo(this.matricesIndices);
+ }
+ if (!this.matricesWeights.isConnected) {
+ var i = e.getInputBlockByPredicate(function(a) {
+ return a.isAttribute && a.name === "matricesWeights";
+ });
+ i || (i = new Et("matricesWeights")).setAsAttribute("matricesWeights"), i.output.connectTo(this.matricesWeights);
+ }
+ if (!this.world.isConnected) {
+ var o = e.getInputBlockByPredicate(function(a) {
+ return a.systemValue === gt.World;
+ });
+ o || (o = new Et("world")).setAsSystemValue(gt.World), o.output.connectTo(this.world);
+ }
+ }, t.prototype.provideFallbacks = function(e, n) {
+ e && e.useBones && e.computeBonesUsingShaders && e.skeleton && n.addCPUSkinningFallback(0, e);
+ }, t.prototype.bind = function(e, n, i) {
+ $e.a.BindBonesParameters(i, e);
+ }, t.prototype.prepareDefines = function(e, n, i) {
+ i._areAttributesDirty && $e.a.PrepareDefinesForBones(e, i);
+ }, t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e), e.sharedData.blocksWithFallbacks.push(this), e.sharedData.bindableBlocks.push(this), e.sharedData.blocksWithDefines.push(this), e.uniforms.push("boneTextureWidth"), e.uniforms.push("mBones"), e.samplers.push("boneSampler");
+ var n = "//" + this.name;
+ e._emitFunctionFromInclude("bonesDeclaration", n, { removeAttributes: !0, removeUniforms: !1, removeVaryings: !0, removeIfDef: !1 });
+ var i = e._getFreeVariableName("influence");
+ e.compilationString += e._emitCodeFromInclude("bonesVertex", n, { replaceStrings: [{ search: /finalWorld=finalWorld\*influence;/, replace: "" }, { search: /influence/gm, replace: i }] });
+ var o = this._outputs[0], a = this.world;
+ return e.compilationString += `#if NUM_BONE_INFLUENCERS>0\r
+`, e.compilationString += this._declareOutput(o, e) + " = " + a.associatedVariableName + " * " + i + `;\r
+`, e.compilationString += `#else\r
+`, e.compilationString += this._declareOutput(o, e) + " = " + a.associatedVariableName + `;\r
+`, e.compilationString += `#endif\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.BonesBlock"] = qu;
+ var Zu = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Vertex) || this;
+ return n.registerInput("world0", le.Vector4), n.registerInput("world1", le.Vector4), n.registerInput("world2", le.Vector4), n.registerInput("world3", le.Vector4), n.registerInput("world", le.Matrix, !0), n.registerOutput("output", le.Matrix), n.registerOutput("instanceID", le.Float), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "InstancesBlock";
+ }, Object.defineProperty(t.prototype, "world0", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "world1", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "world2", { get: function() {
+ return this._inputs[2];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "world3", { get: function() {
+ return this._inputs[3];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "world", { get: function() {
+ return this._inputs[4];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "instanceID", { get: function() {
+ return this._outputs[1];
+ }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function(e) {
+ if (!this.world0.connectedPoint) {
+ var n = e.getInputBlockByPredicate(function(d) {
+ return d.isAttribute && d.name === "world0";
+ });
+ n || (n = new Et("world0")).setAsAttribute("world0"), n.output.connectTo(this.world0);
+ }
+ if (!this.world1.connectedPoint) {
+ var i = e.getInputBlockByPredicate(function(d) {
+ return d.isAttribute && d.name === "world1";
+ });
+ i || (i = new Et("world1")).setAsAttribute("world1"), i.output.connectTo(this.world1);
+ }
+ if (!this.world2.connectedPoint) {
+ var o = e.getInputBlockByPredicate(function(d) {
+ return d.isAttribute && d.name === "world2";
+ });
+ o || (o = new Et("world2")).setAsAttribute("world2"), o.output.connectTo(this.world2);
+ }
+ if (!this.world3.connectedPoint) {
+ var a = e.getInputBlockByPredicate(function(d) {
+ return d.isAttribute && d.name === "world3";
+ });
+ a || (a = new Et("world3")).setAsAttribute("world3"), a.output.connectTo(this.world3);
+ }
+ if (!this.world.connectedPoint) {
+ var s = e.getInputBlockByPredicate(function(d) {
+ return d.isAttribute && d.name === "world";
+ });
+ s || (s = new Et("world")).setAsSystemValue(gt.World), s.output.connectTo(this.world);
+ }
+ this.world.define = "!INSTANCES || THIN_INSTANCES";
+ }, t.prototype.prepareDefines = function(e, n, i, o, a) {
+ o === void 0 && (o = !1);
+ var s = !1;
+ i.INSTANCES !== o && (i.setValue("INSTANCES", o), s = !0), a && i.THIN_INSTANCES !== !!(a != null && a.getRenderingMesh().hasThinInstances) && (i.setValue("THIN_INSTANCES", !!(a != null && a.getRenderingMesh().hasThinInstances)), s = !0), s && i.markAsUnprocessed();
+ }, t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e), e.sharedData.blocksWithDefines.push(this);
+ var n = this._outputs[0], i = this._outputs[1], o = this.world0, a = this.world1, s = this.world2, d = this.world3;
+ return e.compilationString += `#ifdef INSTANCES\r
+`, e.compilationString += this._declareOutput(n, e) + " = mat4(" + o.associatedVariableName + ", " + a.associatedVariableName + ", " + s.associatedVariableName + ", " + d.associatedVariableName + `);\r
+`, e.compilationString += `#ifdef THIN_INSTANCES\r
+`, e.compilationString += n.associatedVariableName + " = " + this.world.associatedVariableName + " * " + n.associatedVariableName + `;\r
+`, e.compilationString += `#endif\r
+`, e.compilationString += this._declareOutput(i, e) + ` = float(gl_InstanceID);\r
+`, e.compilationString += `#else\r
+`, e.compilationString += this._declareOutput(n, e) + " = " + this.world.associatedVariableName + `;\r
+`, e.compilationString += this._declareOutput(i, e) + ` = 0.0;\r
+`, e.compilationString += `#endif\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.InstancesBlock"] = Zu;
+ var Ju = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Vertex) || this;
+ return n.registerInput("position", le.Vector3), n.registerInput("normal", le.Vector3), n.registerInput("tangent", le.Vector3), n.registerInput("uv", le.Vector2), n.registerOutput("positionOutput", le.Vector3), n.registerOutput("normalOutput", le.Vector3), n.registerOutput("tangentOutput", le.Vector3), n.registerOutput("uvOutput", le.Vector2), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "MorphTargetsBlock";
+ }, Object.defineProperty(t.prototype, "position", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "normal", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "tangent", { get: function() {
+ return this._inputs[2];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "uv", { get: function() {
+ return this._inputs[3];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "positionOutput", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "normalOutput", { get: function() {
+ return this._outputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "tangentOutput", { get: function() {
+ return this._outputs[2];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "uvOutput", { get: function() {
+ return this._outputs[3];
+ }, enumerable: !1, configurable: !0 }), t.prototype.initialize = function(e) {
+ e._excludeVariableName("morphTargetInfluences");
+ }, t.prototype.autoConfigure = function(e) {
+ if (!this.position.isConnected) {
+ var n = e.getInputBlockByPredicate(function(s) {
+ return s.isAttribute && s.name === "position";
+ });
+ n || (n = new Et("position")).setAsAttribute(), n.output.connectTo(this.position);
+ }
+ if (!this.normal.isConnected) {
+ var i = e.getInputBlockByPredicate(function(s) {
+ return s.isAttribute && s.name === "normal";
+ });
+ i || (i = new Et("normal")).setAsAttribute("normal"), i.output.connectTo(this.normal);
+ }
+ if (!this.tangent.isConnected) {
+ var o = e.getInputBlockByPredicate(function(s) {
+ return s.isAttribute && s.name === "tangent";
+ });
+ o || (o = new Et("tangent")).setAsAttribute("tangent"), o.output.connectTo(this.tangent);
+ }
+ if (!this.uv.isConnected) {
+ var a = e.getInputBlockByPredicate(function(s) {
+ return s.isAttribute && s.name === "uv";
+ });
+ a || (a = new Et("uv")).setAsAttribute("uv"), a.output.connectTo(this.uv);
+ }
+ }, t.prototype.prepareDefines = function(e, n, i) {
+ i._areAttributesDirty && $e.a.PrepareDefinesForMorphTargets(e, i);
+ }, t.prototype.bind = function(e, n, i) {
+ i && i.morphTargetManager && i.morphTargetManager.numInfluencers > 0 && $e.a.BindMorphTargetParameters(i, e);
+ }, t.prototype.replaceRepeatableContent = function(e, n, i, o) {
+ for (var a = this.position, s = this.normal, d = this.tangent, p = this.uv, y = this.positionOutput, P = this.normalOutput, R = this.tangentOutput, B = this.uvOutput, F = e, z = o.NUM_MORPH_INFLUENCERS, J = i.morphTargetManager, ie = J && J.supportsNormals && o.NORMAL, se = J && J.supportsTangents && o.TANGENT, ce = J && J.supportsUVs && o.UV1, ue = "", fe = 0; fe < z; fe++)
+ ue += `#ifdef MORPHTARGETS\r
+`, ue += y.associatedVariableName + " += (position" + fe + " - " + a.associatedVariableName + ") * morphTargetInfluences[" + fe + `];\r
+`, ie && (ue += `#ifdef MORPHTARGETS_NORMAL\r
+`, ue += P.associatedVariableName + " += (normal" + fe + " - " + s.associatedVariableName + ") * morphTargetInfluences[" + fe + `];\r
+`, ue += `#endif\r
+`), se && (ue += `#ifdef MORPHTARGETS_TANGENT\r
+`, ue += R.associatedVariableName + ".xyz += (tangent" + fe + " - " + d.associatedVariableName + ".xyz) * morphTargetInfluences[" + fe + `];\r
+`, ue += `#endif\r
+`), ce && (ue += `#ifdef MORPHTARGETS_UV\r
+`, ue += B.associatedVariableName + ".xy += (uv_" + fe + " - " + p.associatedVariableName + ".xy) * morphTargetInfluences[" + fe + `];\r
+`, ue += `#endif\r
+`), ue += `#endif\r
+`;
+ if (F.compilationString = F.compilationString.replace(this._repeatableContentAnchor, ue), z > 0)
+ for (fe = 0; fe < z; fe++)
+ F.attributes.push(Oe.b.PositionKind + fe), ie && F.attributes.push(Oe.b.NormalKind + fe), se && F.attributes.push(Oe.b.TangentKind + fe), ce && F.attributes.push(Oe.b.UVKind + "_" + fe);
+ }, t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e), e.sharedData.blocksWithDefines.push(this), e.sharedData.bindableBlocks.push(this), e.sharedData.repeatableContentBlocks.push(this);
+ var n = this.position, i = this.normal, o = this.tangent, a = this.uv, s = this.positionOutput, d = this.normalOutput, p = this.tangentOutput, y = this.uvOutput, P = "//" + this.name;
+ return e.uniforms.push("morphTargetInfluences"), e._emitFunctionFromInclude("morphTargetsVertexGlobalDeclaration", P), e._emitFunctionFromInclude("morphTargetsVertexDeclaration", P, { repeatKey: "maxSimultaneousMorphTargets" }), e.compilationString += this._declareOutput(s, e) + " = " + n.associatedVariableName + `;\r
+`, e.compilationString += `#ifdef NORMAL\r
+`, e.compilationString += this._declareOutput(d, e) + " = " + i.associatedVariableName + `;\r
+`, e.compilationString += `#else\r
+`, e.compilationString += this._declareOutput(d, e) + ` = vec3(0., 0., 0.);\r
+`, e.compilationString += `#endif\r
+`, e.compilationString += `#ifdef TANGENT\r
+`, e.compilationString += this._declareOutput(p, e) + " = " + o.associatedVariableName + `;\r
+`, e.compilationString += `#else\r
+`, e.compilationString += this._declareOutput(p, e) + ` = vec3(0., 0., 0.);\r
+`, e.compilationString += `#endif\r
+`, e.compilationString += `#ifdef UV1\r
+`, e.compilationString += this._declareOutput(y, e) + " = " + a.associatedVariableName + `;\r
+`, e.compilationString += `#else\r
+`, e.compilationString += this._declareOutput(y, e) + ` = vec2(0., 0.);\r
+`, e.compilationString += `#endif\r
+`, this._repeatableContentAnchor = e._repeatableContentAnchor, e.compilationString += this._repeatableContentAnchor, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.MorphTargetsBlock"] = Ju;
+ var $u = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Vertex) || this;
+ return n.registerInput("worldPosition", le.Vector4, !1, Ce.Vertex), n.registerOutput("direction", le.Vector3), n.registerOutput("color", le.Color3), n.registerOutput("intensity", le.Float), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "LightInformationBlock";
+ }, Object.defineProperty(t.prototype, "worldPosition", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "direction", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "color", { get: function() {
+ return this._outputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "intensity", { get: function() {
+ return this._outputs[2];
+ }, enumerable: !1, configurable: !0 }), t.prototype.bind = function(e, n, i) {
+ if (i) {
+ this.light && this.light.isDisposed && (this.light = null);
+ var o = this.light, a = n.getScene();
+ if (!o && a.lights.length && (o = a.lights[0]), !o || !o.isEnabled)
+ return e.setFloat3(this._lightDataUniformName, 0, 0, 0), void e.setFloat4(this._lightColorUniformName, 0, 0, 0, 0);
+ o.transferToNodeMaterialEffect(e, this._lightDataUniformName), e.setColor4(this._lightColorUniformName, o.diffuse, o.intensity);
+ }
+ }, t.prototype.prepareDefines = function(e, n, i) {
+ if (i._areLightsDirty) {
+ var o = this.light;
+ i.setValue(this._lightTypeDefineName, !!(o && o instanceof Ls));
+ }
+ }, t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e), e.sharedData.bindableBlocks.push(this), e.sharedData.blocksWithDefines.push(this);
+ var n = this.direction, i = this.color, o = this.intensity;
+ return this._lightDataUniformName = e._getFreeVariableName("lightData"), this._lightColorUniformName = e._getFreeVariableName("lightColor"), this._lightTypeDefineName = e._getFreeDefineName("LIGHTPOINTTYPE"), e._emitUniformFromString(this._lightDataUniformName, "vec3"), e._emitUniformFromString(this._lightColorUniformName, "vec4"), e.compilationString += "#ifdef " + this._lightTypeDefineName + `\r
+`, e.compilationString += this._declareOutput(n, e) + " = normalize(" + this.worldPosition.associatedVariableName + ".xyz - " + this._lightDataUniformName + `);\r
+`, e.compilationString += `#else\r
+`, e.compilationString += this._declareOutput(n, e) + " = " + this._lightDataUniformName + `;\r
+`, e.compilationString += `#endif\r
+`, e.compilationString += this._declareOutput(i, e) + " = " + this._lightColorUniformName + `.rgb;\r
+`, e.compilationString += this._declareOutput(o, e) + " = " + this._lightColorUniformName + `.a;\r
+`, this;
+ }, t.prototype.serialize = function() {
+ var e = r.prototype.serialize.call(this);
+ return this.light && (e.lightId = this.light.id), e;
+ }, t.prototype._deserialize = function(e, n, i) {
+ r.prototype._deserialize.call(this, e, n, i), e.lightId && (this.light = n.getLightByID(e.lightId));
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.LightInformationBlock"] = $u;
+ var eh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Fragment) || this;
+ return n.registerInput("color", le.Color4), n.registerOutput("output", le.Color4), n._inputs[0].acceptedConnectionPointTypes.push(le.Color3), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "ImageProcessingBlock";
+ }, Object.defineProperty(t.prototype, "color", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype.initialize = function(e) {
+ e._excludeVariableName("exposureLinear"), e._excludeVariableName("contrast"), e._excludeVariableName("vInverseScreenSize"), e._excludeVariableName("vignetteSettings1"), e._excludeVariableName("vignetteSettings2"), e._excludeVariableName("vCameraColorCurveNegative"), e._excludeVariableName("vCameraColorCurveNeutral"), e._excludeVariableName("vCameraColorCurvePositive"), e._excludeVariableName("txColorTransform"), e._excludeVariableName("colorTransformSettings");
+ }, t.prototype.isReady = function(e, n, i) {
+ return !(i._areImageProcessingDirty && n.imageProcessingConfiguration && !n.imageProcessingConfiguration.isReady());
+ }, t.prototype.prepareDefines = function(e, n, i) {
+ i._areImageProcessingDirty && n.imageProcessingConfiguration && n.imageProcessingConfiguration.prepareDefines(i);
+ }, t.prototype.bind = function(e, n, i) {
+ i && n.imageProcessingConfiguration && n.imageProcessingConfiguration.bind(e);
+ }, t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e), e.sharedData.blocksWithDefines.push(this), e.sharedData.blockingBlocks.push(this), e.sharedData.bindableBlocks.push(this), e.uniforms.push("exposureLinear"), e.uniforms.push("contrast"), e.uniforms.push("vInverseScreenSize"), e.uniforms.push("vignetteSettings1"), e.uniforms.push("vignetteSettings2"), e.uniforms.push("vCameraColorCurveNegative"), e.uniforms.push("vCameraColorCurveNeutral"), e.uniforms.push("vCameraColorCurvePositive"), e.uniforms.push("txColorTransform"), e.uniforms.push("colorTransformSettings");
+ var n = this.color, i = this._outputs[0], o = "//" + this.name;
+ return e._emitFunctionFromInclude("helperFunctions", o), e._emitFunctionFromInclude("imageProcessingDeclaration", o), e._emitFunctionFromInclude("imageProcessingFunctions", o), n.connectedPoint.type === le.Color4 || n.connectedPoint.type === le.Vector4 ? e.compilationString += this._declareOutput(i, e) + " = " + n.associatedVariableName + `;\r
+` : e.compilationString += this._declareOutput(i, e) + " = vec4(" + n.associatedVariableName + `, 1.0);\r
+`, e.compilationString += `#ifdef IMAGEPROCESSINGPOSTPROCESS\r
+`, e.compilationString += i.associatedVariableName + ".rgb = toLinearSpace(" + n.associatedVariableName + `.rgb);\r
+`, e.compilationString += `#else\r
+`, e.compilationString += `#ifdef IMAGEPROCESSING\r
+`, e.compilationString += i.associatedVariableName + ".rgb = toLinearSpace(" + n.associatedVariableName + `.rgb);\r
+`, e.compilationString += i.associatedVariableName + " = applyImageProcessing(" + i.associatedVariableName + `);\r
+`, e.compilationString += `#endif\r
+`, e.compilationString += `#endif\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.ImageProcessingBlock"] = eh;
+ var th = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Fragment) || this;
+ return n._tangentSpaceParameterName = "", n.invertX = !1, n.invertY = !1, n.registerInput("worldPosition", le.Vector4, !1), n.registerInput("worldNormal", le.Vector4, !1), n.registerInput("worldTangent", le.Vector4, !0), n.registerInput("uv", le.Vector2, !1), n.registerInput("normalMapColor", le.Color3, !1), n.registerInput("strength", le.Float, !1), n.registerOutput("output", le.Vector4), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "PerturbNormalBlock";
+ }, Object.defineProperty(t.prototype, "worldPosition", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldNormal", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldTangent", { get: function() {
+ return this._inputs[2];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "uv", { get: function() {
+ return this._inputs[3];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "normalMapColor", { get: function() {
+ return this._inputs[4];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "strength", { get: function() {
+ return this._inputs[5];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype.prepareDefines = function(e, n, i) {
+ i.setValue("BUMP", !0);
+ }, t.prototype.bind = function(e, n, i) {
+ n.getScene()._mirroredCameraPosition ? e.setFloat2(this._tangentSpaceParameterName, this.invertX ? 1 : -1, this.invertY ? 1 : -1) : e.setFloat2(this._tangentSpaceParameterName, this.invertX ? -1 : 1, this.invertY ? -1 : 1);
+ }, t.prototype.autoConfigure = function(e) {
+ if (!this.uv.isConnected) {
+ var n = e.getInputBlockByPredicate(function(o) {
+ return o.isAttribute && o.name === "uv";
+ });
+ n || (n = new Et("uv")).setAsAttribute(), n.output.connectTo(this.uv);
+ }
+ if (!this.strength.isConnected) {
+ var i = new Et("strength");
+ i.value = 1, i.output.connectTo(this.strength);
+ }
+ }, t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = "//" + this.name, i = this.uv, o = this.worldPosition, a = this.worldNormal, s = this.worldTangent;
+ e.sharedData.blocksWithDefines.push(this), e.sharedData.bindableBlocks.push(this), this._tangentSpaceParameterName = e._getFreeDefineName("tangentSpaceParameter"), e._emitUniformFromString(this._tangentSpaceParameterName, "vec2");
+ var d = this.strength.isConnectedToInputBlock && this.strength.connectInputBlock.isConstant ? "" + e._emitFloat(1 / this.strength.connectInputBlock.value) : "1.0 / " + this.strength.associatedVariableName;
+ e._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable");
+ var p = { search: /defined\(TANGENT\)/g, replace: s.isConnected ? "defined(TANGENT)" : "defined(IGNORE)" };
+ return s.isConnected && (e.compilationString += "vec3 tbnNormal = normalize(" + a.associatedVariableName + `.xyz);\r
+`, e.compilationString += "vec3 tbnTangent = normalize(" + s.associatedVariableName + `.xyz);\r
+`, e.compilationString += `vec3 tbnBitangent = cross(tbnNormal, tbnTangent);\r
+`, e.compilationString += `mat3 vTBN = mat3(tbnTangent, tbnBitangent, tbnNormal);\r
+`), e._emitFunctionFromInclude("bumpFragmentMainFunctions", n, { replaceStrings: [p] }), e._emitFunctionFromInclude("bumpFragmentFunctions", n, { replaceStrings: [{ search: /vBumpInfos.y/g, replace: d }, { search: /vTangentSpaceParams/g, replace: this._tangentSpaceParameterName }, { search: /vPositionW/g, replace: o.associatedVariableName + ".xyz" }] }), e.compilationString += this._declareOutput(this.output, e) + ` = vec4(0.);\r
+`, e.compilationString += e._emitCodeFromInclude("bumpFragment", n, { replaceStrings: [{ search: /perturbNormal\(TBN,vBumpUV\+uvOffset\)/g, replace: "perturbNormal(TBN, " + this.normalMapColor.associatedVariableName + ")" }, { search: /vBumpInfos.y/g, replace: d }, { search: /vBumpUV/g, replace: i.associatedVariableName }, { search: /vPositionW/g, replace: o.associatedVariableName + ".xyz" }, { search: /normalW=/g, replace: this.output.associatedVariableName + ".xyz = " }, { search: /mat3\(normalMatrix\)\*normalW/g, replace: "mat3(normalMatrix) * " + this.output.associatedVariableName + ".xyz" }, { search: /normalW/g, replace: a.associatedVariableName + ".xyz" }, p] }), this;
+ }, t.prototype._dumpPropertiesCode = function() {
+ var e = this._codeVariableName + ".invertX = " + this.invertX + `;\r
+`;
+ return e += this._codeVariableName + ".invertY = " + this.invertY + `;\r
+`;
+ }, t.prototype.serialize = function() {
+ var e = r.prototype.serialize.call(this);
+ return e.invertX = this.invertX, e.invertY = this.invertY, e;
+ }, t.prototype._deserialize = function(e, n, i) {
+ r.prototype._deserialize.call(this, e, n, i), this.invertX = e.invertX, this.invertY = e.invertY;
+ }, Object(c.c)([Bt("Invert X axis", It.Boolean, "PROPERTIES", { notifiers: { update: !1 } })], t.prototype, "invertX", void 0), Object(c.c)([Bt("Invert Y axis", It.Boolean, "PROPERTIES", { notifiers: { update: !1 } })], t.prototype, "invertY", void 0), t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.PerturbNormalBlock"] = th;
+ var nh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Fragment, !0) || this;
+ return n.registerInput("value", le.Float, !0), n.registerInput("cutoff", le.Float, !0), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "DiscardBlock";
+ }, Object.defineProperty(t.prototype, "value", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cutoff", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ if (r.prototype._buildBlock.call(this, e), e.sharedData.hints.needAlphaTesting = !0, this.cutoff.isConnected && this.value.isConnected)
+ return e.compilationString += "if (" + this.value.associatedVariableName + " < " + this.cutoff.associatedVariableName + `) discard;\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.DiscardBlock"] = nh;
+ var ih = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Fragment) || this;
+ return n.registerOutput("output", le.Float, Ce.Fragment), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "FrontFacingBlock";
+ }, Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ if (r.prototype._buildBlock.call(this, e), e.target === Ce.Vertex)
+ throw "FrontFacingBlock must only be used in a fragment shader";
+ var n = this._outputs[0];
+ return e.compilationString += this._declareOutput(n, e) + ` = gl_FrontFacing ? 1.0 : 0.0;\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.FrontFacingBlock"] = ih;
+ var rh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Fragment) || this;
+ return n.registerInput("input", le.AutoDetect, !1), n.registerOutput("dx", le.BasedOnInput), n.registerOutput("dy", le.BasedOnInput), n._outputs[0]._typeConnectionSource = n._inputs[0], n._outputs[1]._typeConnectionSource = n._inputs[0], n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "DerivativeBlock";
+ }, Object.defineProperty(t.prototype, "input", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "dx", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "dy", { get: function() {
+ return this._outputs[1];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0], i = this._outputs[1];
+ return e._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable"), n.hasEndpoints && (e.compilationString += this._declareOutput(n, e) + " = dFdx(" + this.input.associatedVariableName + `);\r
+`), i.hasEndpoints && (e.compilationString += this._declareOutput(i, e) + " = dFdy(" + this.input.associatedVariableName + `);\r
+`), this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.DerivativeBlock"] = rh;
+ var oh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Fragment) || this;
+ return n.registerOutput("xy", le.Vector2, Ce.Fragment), n.registerOutput("xyz", le.Vector3, Ce.Fragment), n.registerOutput("xyzw", le.Vector4, Ce.Fragment), n.registerOutput("x", le.Float, Ce.Fragment), n.registerOutput("y", le.Float, Ce.Fragment), n.registerOutput("z", le.Float, Ce.Fragment), n.registerOutput("w", le.Float, Ce.Fragment), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "FragCoordBlock";
+ }, Object.defineProperty(t.prototype, "xy", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xyz", { get: function() {
+ return this._outputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xyzw", { get: function() {
+ return this._outputs[2];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "x", { get: function() {
+ return this._outputs[3];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "y", { get: function() {
+ return this._outputs[4];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "z", { get: function() {
+ return this._outputs[5];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[6];
+ }, enumerable: !1, configurable: !0 }), t.prototype.writeOutputs = function(e) {
+ for (var n = "", i = 0, o = this._outputs; i < o.length; i++) {
+ var a = o[i];
+ a.hasEndpoints && (n += this._declareOutput(a, e) + " = gl_FragCoord." + a.name + `;\r
+`);
+ }
+ return n;
+ }, t.prototype._buildBlock = function(e) {
+ if (r.prototype._buildBlock.call(this, e), e.target === Ce.Vertex)
+ throw "FragCoordBlock must only be used in a fragment shader";
+ return e.compilationString += this.writeOutputs(e), this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.FragCoordBlock"] = oh;
+ var ah = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Fragment) || this;
+ return n.registerOutput("xy", le.Vector2, Ce.Fragment), n.registerOutput("x", le.Float, Ce.Fragment), n.registerOutput("y", le.Float, Ce.Fragment), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "ScreenSizeBlock";
+ }, Object.defineProperty(t.prototype, "xy", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "x", { get: function() {
+ return this._outputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "y", { get: function() {
+ return this._outputs[2];
+ }, enumerable: !1, configurable: !0 }), t.prototype.bind = function(e, n, i) {
+ var o = this._scene.getEngine();
+ e.setFloat2(this._varName, o.getRenderWidth(), o.getRenderWidth());
+ }, t.prototype.writeOutputs = function(e, n) {
+ for (var i = "", o = 0, a = this._outputs; o < a.length; o++) {
+ var s = a[o];
+ s.hasEndpoints && (i += this._declareOutput(s, e) + " = " + n + "." + s.name + `;\r
+`);
+ }
+ return i;
+ }, t.prototype._buildBlock = function(e) {
+ if (r.prototype._buildBlock.call(this, e), this._scene = e.sharedData.scene, e.target === Ce.Vertex)
+ throw "ScreenSizeBlock must only be used in a fragment shader";
+ return e.sharedData.bindableBlocks.push(this), this._varName = e._getFreeVariableName("screenSize"), e._emitUniformFromString(this._varName, "vec2"), e.compilationString += this.writeOutputs(e, this._varName), this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.ScreenSizeBlock"] = ah;
+ var sh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.VertexAndFragment, !0) || this;
+ return n.registerInput("worldPosition", le.Vector4, !1, Ce.Vertex), n.registerInput("view", le.Matrix, !1, Ce.Vertex), n.registerInput("input", le.Color3, !1, Ce.Fragment), n.registerInput("fogColor", le.Color3, !1, Ce.Fragment), n.registerOutput("output", le.Color3, Ce.Fragment), n.input.acceptedConnectionPointTypes.push(le.Color4), n.fogColor.acceptedConnectionPointTypes.push(le.Color4), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "FogBlock";
+ }, Object.defineProperty(t.prototype, "worldPosition", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "view", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "input", { get: function() {
+ return this._inputs[2];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "fogColor", { get: function() {
+ return this._inputs[3];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function(e) {
+ if (!this.view.isConnected) {
+ var n = e.getInputBlockByPredicate(function(o) {
+ return o.systemValue === gt.View;
+ });
+ n || (n = new Et("view")).setAsSystemValue(gt.View), n.output.connectTo(this.view);
+ }
+ if (!this.fogColor.isConnected) {
+ var i = e.getInputBlockByPredicate(function(o) {
+ return o.systemValue === gt.FogColor;
+ });
+ i || (i = new Et("fogColor", void 0, le.Color3)).setAsSystemValue(gt.FogColor), i.output.connectTo(this.fogColor);
+ }
+ }, t.prototype.prepareDefines = function(e, n, i) {
+ var o = e.getScene();
+ i.setValue("FOG", n.fogEnabled && $e.a.GetFogState(e, o));
+ }, t.prototype.bind = function(e, n, i) {
+ if (i) {
+ var o = i.getScene();
+ e.setFloat4(this._fogParameters, o.fogMode, o.fogStart, o.fogEnd, o.fogDensity);
+ }
+ }, t.prototype._buildBlock = function(e) {
+ if (r.prototype._buildBlock.call(this, e), e.target === Ce.Fragment) {
+ e.sharedData.blocksWithDefines.push(this), e.sharedData.bindableBlocks.push(this), e._emitFunctionFromInclude("fogFragmentDeclaration", "//" + this.name, { removeUniforms: !0, removeVaryings: !0, removeIfDef: !1, replaceStrings: [{ search: /float CalcFogFactor\(\)/, replace: "float CalcFogFactor(vec3 vFogDistance, vec4 vFogInfos)" }] });
+ var n = e._getFreeVariableName("fog"), i = this.input, o = this.fogColor;
+ this._fogParameters = e._getFreeVariableName("fogParameters");
+ var a = this._outputs[0];
+ e._emitUniformFromString(this._fogParameters, "vec4"), e.compilationString += `#ifdef FOG\r
+`, e.compilationString += "float " + n + " = CalcFogFactor(" + this._fogDistanceName + ", " + this._fogParameters + `);\r
+`, e.compilationString += this._declareOutput(a, e) + " = " + n + " * " + i.associatedVariableName + ".rgb + (1.0 - " + n + ") * " + o.associatedVariableName + `.rgb;\r
+`, e.compilationString += `#else\r
+` + this._declareOutput(a, e) + " = " + i.associatedVariableName + `.rgb;\r
+`, e.compilationString += `#endif\r
+`;
+ } else {
+ var s = this.worldPosition, d = this.view;
+ this._fogDistanceName = e._getFreeVariableName("vFogDistance"), e._emitVaryingFromString(this._fogDistanceName, "vec3"), e.compilationString += this._fogDistanceName + " = (" + d.associatedVariableName + " * " + s.associatedVariableName + `).xyz;\r
+`;
+ }
+ return this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.FogBlock"] = sh;
+ var ch = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.VertexAndFragment) || this;
+ return n._isUnique = !0, n.registerInput("worldPosition", le.Vector4, !1, Ce.Vertex), n.registerInput("worldNormal", le.Vector4, !1, Ce.Fragment), n.registerInput("cameraPosition", le.Vector3, !1, Ce.Fragment), n.registerInput("glossiness", le.Float, !0, Ce.Fragment), n.registerInput("glossPower", le.Float, !0, Ce.Fragment), n.registerInput("diffuseColor", le.Color3, !0, Ce.Fragment), n.registerInput("specularColor", le.Color3, !0, Ce.Fragment), n.registerInput("view", le.Matrix, !0), n.registerOutput("diffuseOutput", le.Color3, Ce.Fragment), n.registerOutput("specularOutput", le.Color3, Ce.Fragment), n.registerOutput("shadow", le.Float, Ce.Fragment), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "LightBlock";
+ }, Object.defineProperty(t.prototype, "worldPosition", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldNormal", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraPosition", { get: function() {
+ return this._inputs[2];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "glossiness", { get: function() {
+ return this._inputs[3];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "glossPower", { get: function() {
+ return this._inputs[4];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "diffuseColor", { get: function() {
+ return this._inputs[5];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "specularColor", { get: function() {
+ return this._inputs[6];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "view", { get: function() {
+ return this._inputs[7];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "diffuseOutput", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "specularOutput", { get: function() {
+ return this._outputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "shadow", { get: function() {
+ return this._outputs[2];
+ }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function(e) {
+ if (!this.cameraPosition.isConnected) {
+ var n = e.getInputBlockByPredicate(function(i) {
+ return i.systemValue === gt.CameraPosition;
+ });
+ n || (n = new Et("cameraPosition")).setAsSystemValue(gt.CameraPosition), n.output.connectTo(this.cameraPosition);
+ }
+ }, t.prototype.prepareDefines = function(e, n, i) {
+ if (i._areLightsDirty) {
+ var o = e.getScene();
+ if (this.light) {
+ var a = { needNormals: !1, needRebuild: !1, lightmapMode: !1, shadowEnabled: !1, specularEnabled: !1 };
+ $e.a.PrepareDefinesForLight(o, e, this.light, this._lightId, i, !0, a), a.needRebuild && i.rebuild();
+ } else
+ $e.a.PrepareDefinesForLights(o, e, i, !0, n.maxSimultaneousLights);
+ }
+ }, t.prototype.updateUniformsAndSamples = function(e, n, i, o) {
+ for (var a = 0; a < n.maxSimultaneousLights && i["LIGHT" + a]; a++) {
+ var s = e.uniforms.indexOf("vLightData" + a) >= 0;
+ $e.a.PrepareUniformsAndSamplersForLight(a, e.uniforms, e.samplers, i["PROJECTEDLIGHTTEXTURE" + a], o, s);
+ }
+ }, t.prototype.bind = function(e, n, i) {
+ if (i) {
+ var o = i.getScene();
+ this.light ? $e.a.BindLight(this.light, this._lightId, o, e, !0) : $e.a.BindLights(o, i, e, !0, n.maxSimultaneousLights);
+ }
+ }, t.prototype._injectVertexCode = function(e) {
+ var n = this.worldPosition, i = "//" + this.name;
+ this.light ? (this._lightId = (e.counters.lightCounter !== void 0 ? e.counters.lightCounter : -1) + 1, e.counters.lightCounter = this._lightId, e._emitFunctionFromInclude(e.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", i, { replaceStrings: [{ search: /{X}/g, replace: this._lightId.toString() }] }, this._lightId.toString())) : (e._emitFunctionFromInclude(e.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", i, { repeatKey: "maxSimultaneousLights" }), this._lightId = 0, e.sharedData.dynamicUniformBlocks.push(this));
+ var o = "v_" + n.associatedVariableName;
+ e._emitVaryingFromString(o, "vec4") && (e.compilationString += o + " = " + n.associatedVariableName + `;\r
+`), this.light ? e.compilationString += e._emitCodeFromInclude("shadowsVertex", i, { replaceStrings: [{ search: /{X}/g, replace: this._lightId.toString() }, { search: /worldPos/g, replace: n.associatedVariableName }] }) : (e.compilationString += "vec4 worldPos = " + n.associatedVariableName + `;\r
+`, this.view.isConnected && (e.compilationString += "mat4 view = " + this.view.associatedVariableName + `;\r
+`), e.compilationString += e._emitCodeFromInclude("shadowsVertex", i, { repeatKey: "maxSimultaneousLights" }));
+ }, t.prototype._buildBlock = function(e) {
+ if (r.prototype._buildBlock.call(this, e), e.target === Ce.Fragment) {
+ e.sharedData.bindableBlocks.push(this), e.sharedData.blocksWithDefines.push(this);
+ var n = "//" + this.name, i = this.worldPosition;
+ e._emitFunctionFromInclude("helperFunctions", n), e._emitFunctionFromInclude("lightsFragmentFunctions", n, { replaceStrings: [{ search: /vPositionW/g, replace: "v_" + i.associatedVariableName + ".xyz" }] }), e._emitFunctionFromInclude("shadowsFragmentFunctions", n, { replaceStrings: [{ search: /vPositionW/g, replace: "v_" + i.associatedVariableName + ".xyz" }] }), this.light ? e._emitFunctionFromInclude(e.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", n, { replaceStrings: [{ search: /{X}/g, replace: this._lightId.toString() }] }, this._lightId.toString()) : e._emitFunctionFromInclude(e.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", n, { repeatKey: "maxSimultaneousLights" }), this._lightId === 0 && (e._registerTempVariable("viewDirectionW") && (e.compilationString += "vec3 viewDirectionW = normalize(" + this.cameraPosition.associatedVariableName + " - v_" + i.associatedVariableName + `.xyz);\r
+`), e.compilationString += `lightingInfo info;\r
+`, e.compilationString += `float shadow = 1.;\r
+`, e.compilationString += "float glossiness = " + (this.glossiness.isConnected ? this.glossiness.associatedVariableName : "1.0") + " * " + (this.glossPower.isConnected ? this.glossPower.associatedVariableName : "1024.0") + `;\r
+`, e.compilationString += `vec3 diffuseBase = vec3(0., 0., 0.);\r
+`, e.compilationString += `vec3 specularBase = vec3(0., 0., 0.);\r
+`, e.compilationString += "vec3 normalW = " + this.worldNormal.associatedVariableName + `.xyz;\r
+`), this.light ? e.compilationString += e._emitCodeFromInclude("lightFragment", n, { replaceStrings: [{ search: /{X}/g, replace: this._lightId.toString() }] }) : e.compilationString += e._emitCodeFromInclude("lightFragment", n, { repeatKey: "maxSimultaneousLights" });
+ var o = this.diffuseOutput, a = this.specularOutput;
+ return e.compilationString += this._declareOutput(o, e) + " = diffuseBase" + (this.diffuseColor.isConnected ? " * " + this.diffuseColor.associatedVariableName : "") + `;\r
+`, a.hasEndpoints && (e.compilationString += this._declareOutput(a, e) + " = specularBase" + (this.specularColor.isConnected ? " * " + this.specularColor.associatedVariableName : "") + `;\r
+`), this.shadow.hasEndpoints && (e.compilationString += this._declareOutput(this.shadow, e) + ` = shadow;\r
+`), this;
+ }
+ this._injectVertexCode(e);
+ }, t.prototype.serialize = function() {
+ var e = r.prototype.serialize.call(this);
+ return this.light && (e.lightId = this.light.id), e;
+ }, t.prototype._deserialize = function(e, n, i) {
+ r.prototype._deserialize.call(this, e, n, i), e.lightId && (this.light = n.getLightByID(e.lightId));
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.LightBlock"] = ch;
+ var lh = function(r) {
+ function t(e, n) {
+ n === void 0 && (n = !1);
+ var i = r.call(this, e, n ? Ce.Fragment : Ce.VertexAndFragment) || this;
+ return i.convertToGammaSpace = !1, i.convertToLinearSpace = !1, i._fragmentOnly = n, i.registerInput("uv", le.Vector2, !1, Ce.VertexAndFragment), i.registerOutput("rgba", le.Color4, Ce.Neutral), i.registerOutput("rgb", le.Color3, Ce.Neutral), i.registerOutput("r", le.Float, Ce.Neutral), i.registerOutput("g", le.Float, Ce.Neutral), i.registerOutput("b", le.Float, Ce.Neutral), i.registerOutput("a", le.Float, Ce.Neutral), i._inputs[0].acceptedConnectionPointTypes.push(le.Vector3), i._inputs[0].acceptedConnectionPointTypes.push(le.Vector4), i._inputs[0]._prioritizeVertex = !n, i;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "TextureBlock";
+ }, Object.defineProperty(t.prototype, "uv", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgba", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgb", { get: function() {
+ return this._outputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "r", { get: function() {
+ return this._outputs[2];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "g", { get: function() {
+ return this._outputs[3];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "b", { get: function() {
+ return this._outputs[4];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "a", { get: function() {
+ return this._outputs[5];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "target", { get: function() {
+ if (this._fragmentOnly)
+ return Ce.Fragment;
+ if (!this.uv.isConnected || this.uv.sourceBlock.isInput)
+ return Ce.VertexAndFragment;
+ for (var e = this.uv.connectedPoint; e; ) {
+ if (e.target === Ce.Fragment)
+ return Ce.Fragment;
+ if (e.target === Ce.Vertex)
+ return Ce.VertexAndFragment;
+ if (e.target === Ce.Neutral || e.target === Ce.VertexAndFragment) {
+ var n = e.ownerBlock;
+ e = null;
+ for (var i = 0, o = n.inputs; i < o.length; i++) {
+ var a = o[i];
+ if (a.connectedPoint) {
+ e = a.connectedPoint;
+ break;
+ }
+ }
+ }
+ }
+ return Ce.VertexAndFragment;
+ }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function(e) {
+ if (!this.uv.isConnected)
+ if (e.mode === Rn.PostProcess)
+ (n = e.getBlockByPredicate(function(o) {
+ return o.name === "uv";
+ })) && n.connectTo(this);
+ else {
+ var n, i = e.mode === Rn.Particle ? "particle_uv" : "uv";
+ (n = e.getInputBlockByPredicate(function(o) {
+ return o.isAttribute && o.name === i;
+ })) || (n = new Et("uv")).setAsAttribute(i), n.output.connectTo(this.uv);
+ }
+ }, t.prototype.initializeDefines = function(e, n, i, o) {
+ i._areTexturesDirty && i.setValue(this._mainUVDefineName, !1);
+ }, t.prototype.prepareDefines = function(e, n, i) {
+ if (i._areTexturesDirty) {
+ if (!this.texture || !this.texture.getTextureMatrix)
+ return i.setValue(this._defineName, !1), void i.setValue(this._mainUVDefineName, !0);
+ i.setValue(this._linearDefineName, this.convertToGammaSpace), i.setValue(this._gammaDefineName, this.convertToLinearSpace), this._isMixed && (this.texture.getTextureMatrix().isIdentityAs3x2() ? (i.setValue(this._defineName, !1), i.setValue(this._mainUVDefineName, !0)) : i.setValue(this._defineName, !0));
+ }
+ }, t.prototype.isReady = function() {
+ return !(this.texture && !this.texture.isReadyOrNotBlocking());
+ }, t.prototype.bind = function(e, n, i) {
+ this.texture && (this._isMixed && (e.setFloat(this._textureInfoName, this.texture.level), e.setMatrix(this._textureTransformName, this.texture.getTextureMatrix())), e.setTexture(this._samplerName, this.texture));
+ }, Object.defineProperty(t.prototype, "_isMixed", { get: function() {
+ return this.target !== Ce.Fragment;
+ }, enumerable: !1, configurable: !0 }), t.prototype._injectVertexCode = function(e) {
+ var n = this.uv;
+ if (this._defineName = e._getFreeDefineName("UVTRANSFORM"), this._mainUVDefineName = "VMAIN" + n.associatedVariableName.toUpperCase(), n.connectedPoint.ownerBlock.isInput && (n.connectedPoint.ownerBlock.isAttribute || e._emitUniformFromString(n.associatedVariableName, "vec2")), this._mainUVName = "vMain" + n.associatedVariableName, this._transformedUVName = e._getFreeVariableName("transformedUV"), this._textureTransformName = e._getFreeVariableName("textureTransform"), this._textureInfoName = e._getFreeVariableName("textureInfoName"), e._emitVaryingFromString(this._transformedUVName, "vec2", this._defineName), e._emitVaryingFromString(this._mainUVName, "vec2", this._mainUVDefineName), e._emitUniformFromString(this._textureTransformName, "mat4", this._defineName), e.compilationString += "#ifdef " + this._defineName + `\r
+`, e.compilationString += this._transformedUVName + " = vec2(" + this._textureTransformName + " * vec4(" + n.associatedVariableName + `.xy, 1.0, 0.0));\r
+`, e.compilationString += "#elif defined(" + this._mainUVDefineName + `)\r
+`, e.compilationString += this._mainUVName + " = " + n.associatedVariableName + `.xy;\r
+`, e.compilationString += `#endif\r
+`, this._outputs.some(function(s) {
+ return s.isConnectedInVertexShader;
+ })) {
+ this._writeTextureRead(e, !0);
+ for (var i = 0, o = this._outputs; i < o.length; i++) {
+ var a = o[i];
+ a.hasEndpoints && this._writeOutput(e, a, a.name, !0);
+ }
+ }
+ }, t.prototype._writeTextureRead = function(e, n) {
+ n === void 0 && (n = !1);
+ var i = this.uv;
+ if (n) {
+ if (e.target === Ce.Fragment)
+ return;
+ e.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + this._samplerName + ", " + i.associatedVariableName + `);\r
+`;
+ } else
+ this.uv.ownerBlock.target !== Ce.Fragment ? (e.compilationString += "#ifdef " + this._defineName + `\r
+`, e.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + this._samplerName + ", " + this._transformedUVName + `);\r
+`, e.compilationString += "#elif defined(" + this._mainUVDefineName + `)\r
+`, e.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + this._samplerName + ", " + this._mainUVName + `);\r
+`, e.compilationString += `#endif\r
+`) : e.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + this._samplerName + ", " + i.associatedVariableName + `);\r
+`;
+ }, t.prototype._writeOutput = function(e, n, i, o) {
+ if (o === void 0 && (o = !1), o) {
+ if (e.target === Ce.Fragment)
+ return;
+ e.compilationString += this._declareOutput(n, e) + " = " + this._tempTextureRead + "." + i + `;\r
+`;
+ } else if (this.uv.ownerBlock.target !== Ce.Fragment) {
+ var a = " * " + this._textureInfoName;
+ e.compilationString += this._declareOutput(n, e) + " = " + this._tempTextureRead + "." + i + a + `;\r
+`, i !== "a" && (e.compilationString += "#ifdef " + this._linearDefineName + `\r
+`, e.compilationString += n.associatedVariableName + " = toGammaSpace(" + n.associatedVariableName + `);\r
+`, e.compilationString += `#endif\r
+`, e.compilationString += "#ifdef " + this._gammaDefineName + `\r
+`, e.compilationString += n.associatedVariableName + " = toLinearSpace(" + n.associatedVariableName + `);\r
+`, e.compilationString += `#endif\r
+`);
+ } else
+ e.compilationString += this._declareOutput(n, e) + " = " + this._tempTextureRead + "." + i + `;\r
+`;
+ }, t.prototype._buildBlock = function(e) {
+ if (r.prototype._buildBlock.call(this, e), (e.target === Ce.Vertex || this._fragmentOnly) && (this._tempTextureRead = e._getFreeVariableName("tempTextureRead")), (!this._isMixed && e.target === Ce.Fragment || this._isMixed && e.target === Ce.Vertex) && (this._samplerName = e._getFreeVariableName(this.name + "Sampler"), e._emit2DSampler(this._samplerName), e.sharedData.blockingBlocks.push(this), e.sharedData.textureBlocks.push(this), e.sharedData.blocksWithDefines.push(this), e.sharedData.bindableBlocks.push(this)), e.target === Ce.Fragment) {
+ if (this._outputs.some(function(s) {
+ return s.isConnectedInFragmentShader;
+ })) {
+ this._isMixed && e._emit2DSampler(this._samplerName), this._linearDefineName = e._getFreeDefineName("ISLINEAR"), this._gammaDefineName = e._getFreeDefineName("ISGAMMA");
+ var n = "//" + this.name;
+ e._emitFunctionFromInclude("helperFunctions", n), this._isMixed && e._emitUniformFromString(this._textureInfoName, "float"), this._writeTextureRead(e);
+ for (var i = 0, o = this._outputs; i < o.length; i++) {
+ var a = o[i];
+ a.hasEndpoints && this._writeOutput(e, a, a.name);
+ }
+ return this;
+ }
+ } else
+ this._injectVertexCode(e);
+ }, t.prototype._dumpPropertiesCode = function() {
+ if (!this.texture)
+ return "";
+ var e = this._codeVariableName + '.texture = new BABYLON.Texture("' + this.texture.name + `", null);\r
+`;
+ return e += this._codeVariableName + ".texture.wrapU = " + this.texture.wrapU + `;\r
+`, e += this._codeVariableName + ".texture.wrapV = " + this.texture.wrapV + `;\r
+`, e += this._codeVariableName + ".texture.uAng = " + this.texture.uAng + `;\r
+`, e += this._codeVariableName + ".texture.vAng = " + this.texture.vAng + `;\r
+`, e += this._codeVariableName + ".texture.wAng = " + this.texture.wAng + `;\r
+`, e += this._codeVariableName + ".texture.uOffset = " + this.texture.uOffset + `;\r
+`, e += this._codeVariableName + ".texture.vOffset = " + this.texture.vOffset + `;\r
+`, e += this._codeVariableName + ".texture.uScale = " + this.texture.uScale + `;\r
+`, e += this._codeVariableName + ".texture.vScale = " + this.texture.vScale + `;\r
+`, e += this._codeVariableName + ".convertToGammaSpace = " + this.convertToGammaSpace + `;\r
+`, e += this._codeVariableName + ".convertToLinearSpace = " + this.convertToLinearSpace + `;\r
+`;
+ }, t.prototype.serialize = function() {
+ var e = r.prototype.serialize.call(this);
+ return e.convertToGammaSpace = this.convertToGammaSpace, e.convertToLinearSpace = this.convertToLinearSpace, e.fragmentOnly = this._fragmentOnly, this.texture && !this.texture.isRenderTarget && (e.texture = this.texture.serialize()), e;
+ }, t.prototype._deserialize = function(e, n, i) {
+ r.prototype._deserialize.call(this, e, n, i), this.convertToGammaSpace = e.convertToGammaSpace, this.convertToLinearSpace = !!e.convertToLinearSpace, this._fragmentOnly = !!e.fragmentOnly, e.texture && !sa.IgnoreTexturesAtLoadTime && (i = e.texture.url.indexOf("data:") === 0 ? "" : i, this.texture = Ne.a.Parse(e.texture, n, i));
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.TextureBlock"] = lh;
+ var tc = function(r) {
+ function t(e) {
+ return r.call(this, e, Ce.VertexAndFragment) || this;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "ReflectionTextureBaseBlock";
+ }, t.prototype._getTexture = function() {
+ return this.texture;
+ }, t.prototype.autoConfigure = function(e) {
+ if (!this.position.isConnected) {
+ var n = e.getInputBlockByPredicate(function(a) {
+ return a.isAttribute && a.name === "position";
+ });
+ n || (n = new Et("position")).setAsAttribute(), n.output.connectTo(this.position);
+ }
+ if (!this.world.isConnected) {
+ var i = e.getInputBlockByPredicate(function(a) {
+ return a.systemValue === gt.World;
+ });
+ i || (i = new Et("world")).setAsSystemValue(gt.World), i.output.connectTo(this.world);
+ }
+ if (this.view && !this.view.isConnected) {
+ var o = e.getInputBlockByPredicate(function(a) {
+ return a.systemValue === gt.View;
+ });
+ o || (o = new Et("view")).setAsSystemValue(gt.View), o.output.connectTo(this.view);
+ }
+ }, t.prototype.prepareDefines = function(e, n, i) {
+ if (i._areTexturesDirty) {
+ var o = this._getTexture();
+ o && o.getTextureMatrix && (i.setValue(this._define3DName, o.isCube, !0), i.setValue(this._defineLocalCubicName, !!o.boundingBoxSize, !0), i.setValue(this._defineExplicitName, o.coordinatesMode === h.a.TEXTURE_EXPLICIT_MODE, !0), i.setValue(this._defineSkyboxName, o.coordinatesMode === h.a.TEXTURE_SKYBOX_MODE, !0), i.setValue(this._defineCubicName, o.coordinatesMode === h.a.TEXTURE_CUBIC_MODE || o.coordinatesMode === h.a.TEXTURE_INVCUBIC_MODE, !0), i.setValue("INVERTCUBICMAP", o.coordinatesMode === h.a.TEXTURE_INVCUBIC_MODE, !0), i.setValue(this._defineSphericalName, o.coordinatesMode === h.a.TEXTURE_SPHERICAL_MODE, !0), i.setValue(this._definePlanarName, o.coordinatesMode === h.a.TEXTURE_PLANAR_MODE, !0), i.setValue(this._defineProjectionName, o.coordinatesMode === h.a.TEXTURE_PROJECTION_MODE, !0), i.setValue(this._defineEquirectangularName, o.coordinatesMode === h.a.TEXTURE_EQUIRECTANGULAR_MODE, !0), i.setValue(this._defineEquirectangularFixedName, o.coordinatesMode === h.a.TEXTURE_FIXED_EQUIRECTANGULAR_MODE, !0), i.setValue(this._defineMirroredEquirectangularFixedName, o.coordinatesMode === h.a.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE, !0));
+ }
+ }, t.prototype.isReady = function() {
+ var e = this._getTexture();
+ return !(e && !e.isReadyOrNotBlocking());
+ }, t.prototype.bind = function(e, n, i) {
+ var o = this._getTexture();
+ i && o && (e.setMatrix(this._reflectionMatrixName, o.getReflectionTextureMatrix()), o.isCube ? e.setTexture(this._cubeSamplerName, o) : e.setTexture(this._2DSamplerName, o));
+ }, t.prototype.handleVertexSide = function(e) {
+ this._define3DName = e._getFreeDefineName("REFLECTIONMAP_3D"), this._defineCubicName = e._getFreeDefineName("REFLECTIONMAP_CUBIC"), this._defineSphericalName = e._getFreeDefineName("REFLECTIONMAP_SPHERICAL"), this._definePlanarName = e._getFreeDefineName("REFLECTIONMAP_PLANAR"), this._defineProjectionName = e._getFreeDefineName("REFLECTIONMAP_PROJECTION"), this._defineExplicitName = e._getFreeDefineName("REFLECTIONMAP_EXPLICIT"), this._defineEquirectangularName = e._getFreeDefineName("REFLECTIONMAP_EQUIRECTANGULAR"), this._defineLocalCubicName = e._getFreeDefineName("USE_LOCAL_REFLECTIONMAP_CUBIC"), this._defineMirroredEquirectangularFixedName = e._getFreeDefineName("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"), this._defineEquirectangularFixedName = e._getFreeDefineName("REFLECTIONMAP_EQUIRECTANGULAR_FIXED"), this._defineSkyboxName = e._getFreeDefineName("REFLECTIONMAP_SKYBOX"), this._defineOppositeZ = e._getFreeDefineName("REFLECTIONMAP_OPPOSITEZ"), this._reflectionMatrixName = e._getFreeVariableName("reflectionMatrix"), e._emitUniformFromString(this._reflectionMatrixName, "mat4");
+ var n = "", i = "v_" + this.worldPosition.associatedVariableName;
+ return e._emitVaryingFromString(i, "vec4") && (n += i + " = " + this.worldPosition.associatedVariableName + `;\r
+`), this._positionUVWName = e._getFreeVariableName("positionUVW"), this._directionWName = e._getFreeVariableName("directionW"), e._emitVaryingFromString(this._positionUVWName, "vec3", this._defineSkyboxName) && (n += "#ifdef " + this._defineSkyboxName + `\r
+`, n += this._positionUVWName + " = " + this.position.associatedVariableName + `.xyz;\r
+`, n += `#endif\r
+`), e._emitVaryingFromString(this._directionWName, "vec3", "defined(" + this._defineEquirectangularFixedName + ") || defined(" + this._defineMirroredEquirectangularFixedName + ")") && (n += "#if defined(" + this._defineEquirectangularFixedName + ") || defined(" + this._defineMirroredEquirectangularFixedName + `)\r
+`, n += this._directionWName + " = normalize(vec3(" + this.world.associatedVariableName + " * vec4(" + this.position.associatedVariableName + `.xyz, 0.0)));\r
+`, n += `#endif\r
+`), n;
+ }, t.prototype.handleFragmentSideInits = function(e) {
+ e.sharedData.blockingBlocks.push(this), e.sharedData.textureBlocks.push(this), this._cubeSamplerName = e._getFreeVariableName(this.name + "CubeSampler"), e.samplers.push(this._cubeSamplerName), this._2DSamplerName = e._getFreeVariableName(this.name + "2DSampler"), e.samplers.push(this._2DSamplerName), e._samplerDeclaration += "#ifdef " + this._define3DName + `\r
+`, e._samplerDeclaration += "uniform samplerCube " + this._cubeSamplerName + `;\r
+`, e._samplerDeclaration += `#else\r
+`, e._samplerDeclaration += "uniform sampler2D " + this._2DSamplerName + `;\r
+`, e._samplerDeclaration += `#endif\r
+`, e.sharedData.blocksWithDefines.push(this), e.sharedData.bindableBlocks.push(this);
+ var n = "//" + this.name;
+ e._emitFunction("ReciprocalPI", "#define RECIPROCAL_PI2 0.15915494", ""), e._emitFunctionFromInclude("reflectionFunction", n, { replaceStrings: [{ search: /vec3 computeReflectionCoords/g, replace: "void DUMMYFUNC" }] }), this._reflectionColorName = e._getFreeVariableName("reflectionColor"), this._reflectionVectorName = e._getFreeVariableName("reflectionUVW"), this._reflectionCoordsName = e._getFreeVariableName("reflectionCoords");
+ }, t.prototype.handleFragmentSideCodeReflectionCoords = function(e, n, i) {
+ i === void 0 && (i = !1), n || (n = "v_" + this.worldPosition.associatedVariableName);
+ var o = this._reflectionMatrixName, a = "normalize(" + this._directionWName + ")", s = "" + this._positionUVWName, d = "" + this.cameraPosition.associatedVariableName, p = "" + this.view.associatedVariableName;
+ e += ".xyz";
+ var y = `
+ #ifdef ` + this._defineMirroredEquirectangularFixedName + `
+ vec3 ` + this._reflectionVectorName + " = computeMirroredFixedEquirectangularCoords(" + n + ", " + e + ", " + a + `);
+ #endif
+
+ #ifdef ` + this._defineEquirectangularFixedName + `
+ vec3 ` + this._reflectionVectorName + " = computeFixedEquirectangularCoords(" + n + ", " + e + ", " + a + `);
+ #endif
+
+ #ifdef ` + this._defineEquirectangularName + `
+ vec3 ` + this._reflectionVectorName + " = computeEquirectangularCoords(" + n + ", " + e + ", " + d + ".xyz, " + o + `);
+ #endif
+
+ #ifdef ` + this._defineSphericalName + `
+ vec3 ` + this._reflectionVectorName + " = computeSphericalCoords(" + n + ", " + e + ", " + p + ", " + o + `);
+ #endif
+
+ #ifdef ` + this._definePlanarName + `
+ vec3 ` + this._reflectionVectorName + " = computePlanarCoords(" + n + ", " + e + ", " + d + ".xyz, " + o + `);
+ #endif
+
+ #ifdef ` + this._defineCubicName + `
+ #ifdef ` + this._defineLocalCubicName + `
+ vec3 ` + this._reflectionVectorName + " = computeCubicLocalCoords(" + n + ", " + e + ", " + d + ".xyz, " + o + `, vReflectionSize, vReflectionPosition);
+ #else
+ vec3 ` + this._reflectionVectorName + " = computeCubicCoords(" + n + ", " + e + ", " + d + ".xyz, " + o + `);
+ #endif
+ #endif
+
+ #ifdef ` + this._defineProjectionName + `
+ vec3 ` + this._reflectionVectorName + " = computeProjectionCoords(" + n + ", " + p + ", " + o + `);
+ #endif
+
+ #ifdef ` + this._defineSkyboxName + `
+ vec3 ` + this._reflectionVectorName + " = computeSkyBoxCoords(" + s + ", " + o + `);
+ #endif
+
+ #ifdef ` + this._defineExplicitName + `
+ vec3 ` + this._reflectionVectorName + ` = vec3(0, 0, 0);
+ #endif
+
+ #ifdef ` + this._defineOppositeZ + `
+ ` + this._reflectionVectorName + `.z *= -1.0;
+ #endif\r
+`;
+ return i || (y += `
+ #ifdef ` + this._define3DName + `
+ vec3 ` + this._reflectionCoordsName + " = " + this._reflectionVectorName + `;
+ #else
+ vec2 ` + this._reflectionCoordsName + " = " + this._reflectionVectorName + `.xy;
+ #ifdef ` + this._defineProjectionName + `
+ ` + this._reflectionCoordsName + " /= " + this._reflectionVectorName + `.z;
+ #endif
+ ` + this._reflectionCoordsName + ".y = 1.0 - " + this._reflectionCoordsName + `.y;
+ #endif\r
+`), y;
+ }, t.prototype.handleFragmentSideCodeReflectionColor = function(e, n) {
+ n === void 0 && (n = ".rgb");
+ var i = "vec" + (n.length === 0 ? "4" : n.length - 1) + " " + this._reflectionColorName + `;
+ #ifdef ` + this._define3DName + `\r
+`;
+ return i += e ? this._reflectionColorName + " = textureCubeLodEXT(" + this._cubeSamplerName + ", " + this._reflectionVectorName + ", " + e + ")" + n + `;\r
+` : this._reflectionColorName + " = textureCube(" + this._cubeSamplerName + ", " + this._reflectionVectorName + ")" + n + `;\r
+`, i += `
+ #else\r
+`, i += e ? this._reflectionColorName + " = texture2DLodEXT(" + this._2DSamplerName + ", " + this._reflectionCoordsName + ", " + e + ")" + n + `;\r
+` : this._reflectionColorName + " = texture2D(" + this._2DSamplerName + ", " + this._reflectionCoordsName + ")" + n + `;\r
+`, i += `#endif\r
+`;
+ }, t.prototype.writeOutputs = function(e, n) {
+ var i = "";
+ if (e.target === Ce.Fragment)
+ for (var o = 0, a = this._outputs; o < a.length; o++) {
+ var s = a[o];
+ s.hasEndpoints && (i += this._declareOutput(s, e) + " = " + n + "." + s.name + `;\r
+`);
+ }
+ return i;
+ }, t.prototype._buildBlock = function(e) {
+ return r.prototype._buildBlock.call(this, e), this;
+ }, t.prototype._dumpPropertiesCode = function() {
+ return this.texture ? (e = this.texture.isCube ? this._codeVariableName + '.texture = new BABYLON.CubeTexture("' + this.texture.name + `");\r
+` : this._codeVariableName + '.texture = new BABYLON.Texture("' + this.texture.name + `");\r
+`, e += this._codeVariableName + ".texture.coordinatesMode = " + this.texture.coordinatesMode + `;\r
+`) : "";
+ var e;
+ }, t.prototype.serialize = function() {
+ var e = r.prototype.serialize.call(this);
+ return this.texture && (e.texture = this.texture.serialize()), e;
+ }, t.prototype._deserialize = function(e, n, i) {
+ r.prototype._deserialize.call(this, e, n, i), e.texture && (i = e.texture.url.indexOf("data:") === 0 ? "" : i, e.texture.isCube ? this.texture = ei.Parse(e.texture, n, i) : this.texture = Ne.a.Parse(e.texture, n, i));
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.ReflectionTextureBaseBlock"] = tc;
+ var uh = function(r) {
+ function t(e) {
+ var n = r.call(this, e) || this;
+ return n.registerInput("position", le.Vector3, !1, Ce.Vertex), n.registerInput("worldPosition", le.Vector4, !1, Ce.Vertex), n.registerInput("worldNormal", le.Vector4, !1, Ce.Fragment), n.registerInput("world", le.Matrix, !1, Ce.Vertex), n.registerInput("cameraPosition", le.Vector3, !1, Ce.Fragment), n.registerInput("view", le.Matrix, !1, Ce.Fragment), n.registerOutput("rgb", le.Color3, Ce.Fragment), n.registerOutput("rgba", le.Color4, Ce.Fragment), n.registerOutput("r", le.Float, Ce.Fragment), n.registerOutput("g", le.Float, Ce.Fragment), n.registerOutput("b", le.Float, Ce.Fragment), n.registerOutput("a", le.Float, Ce.Fragment), n._inputs[0].acceptedConnectionPointTypes.push(le.Vector4), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "ReflectionTextureBlock";
+ }, Object.defineProperty(t.prototype, "position", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldPosition", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldNormal", { get: function() {
+ return this._inputs[2];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "world", { get: function() {
+ return this._inputs[3];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraPosition", { get: function() {
+ return this._inputs[4];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "view", { get: function() {
+ return this._inputs[5];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgb", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgba", { get: function() {
+ return this._outputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "r", { get: function() {
+ return this._outputs[2];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "g", { get: function() {
+ return this._outputs[3];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "b", { get: function() {
+ return this._outputs[4];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "a", { get: function() {
+ return this._outputs[5];
+ }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function(e) {
+ if (r.prototype.autoConfigure.call(this, e), !this.cameraPosition.isConnected) {
+ var n = e.getInputBlockByPredicate(function(i) {
+ return i.systemValue === gt.CameraPosition;
+ });
+ n || (n = new Et("cameraPosition")).setAsSystemValue(gt.CameraPosition), n.output.connectTo(this.cameraPosition);
+ }
+ }, t.prototype._buildBlock = function(e) {
+ if (r.prototype._buildBlock.call(this, e), !this.texture)
+ return e.compilationString += this.writeOutputs(e, "vec3(0.)"), this;
+ if (e.target !== Ce.Fragment)
+ return e.compilationString += this.handleVertexSide(e), this;
+ this.handleFragmentSideInits(e);
+ var n = e._getFreeVariableName("normalWUnit");
+ return e.compilationString += "vec4 " + n + " = normalize(" + this.worldNormal.associatedVariableName + `);\r
+`, e.compilationString += this.handleFragmentSideCodeReflectionCoords(n), e.compilationString += this.handleFragmentSideCodeReflectionColor(void 0, ""), e.compilationString += this.writeOutputs(e, this._reflectionColorName), this;
+ }, t;
+ }(tc);
+ O.a.RegisteredTypes["BABYLON.ReflectionTextureBlock"] = uh;
+ var hh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("left", le.AutoDetect), n.registerInput("right", le.AutoDetect), n.registerOutput("output", le.BasedOnInput), n._outputs[0]._typeConnectionSource = n._inputs[0], n._linkConnectionTypes(0, 1), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "AddBlock";
+ }, Object.defineProperty(t.prototype, "left", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "right", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0];
+ return e.compilationString += this._declareOutput(n, e) + " = " + this.left.associatedVariableName + " + " + this.right.associatedVariableName + `;\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.AddBlock"] = hh;
+ var dh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("input", le.AutoDetect), n.registerInput("factor", le.Float), n.registerOutput("output", le.BasedOnInput), n._outputs[0]._typeConnectionSource = n._inputs[0], n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "ScaleBlock";
+ }, Object.defineProperty(t.prototype, "input", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "factor", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0];
+ return e.compilationString += this._declareOutput(n, e) + " = " + this.input.associatedVariableName + " * " + this.factor.associatedVariableName + `;\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.ScaleBlock"] = dh;
+ var fh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.minimum = 0, n.maximum = 1, n.registerInput("value", le.AutoDetect), n.registerOutput("output", le.BasedOnInput), n._outputs[0]._typeConnectionSource = n._inputs[0], n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "ClampBlock";
+ }, Object.defineProperty(t.prototype, "value", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0];
+ return e.compilationString += this._declareOutput(n, e) + " = clamp(" + this.value.associatedVariableName + ", " + this._writeFloat(this.minimum) + ", " + this._writeFloat(this.maximum) + `);\r
+`, this;
+ }, t.prototype._dumpPropertiesCode = function() {
+ var e = this._codeVariableName + ".minimum = " + this.minimum + `;\r
+`;
+ return e += this._codeVariableName + ".maximum = " + this.maximum + `;\r
+`;
+ }, t.prototype.serialize = function() {
+ var e = r.prototype.serialize.call(this);
+ return e.minimum = this.minimum, e.maximum = this.maximum, e;
+ }, t.prototype._deserialize = function(e, n, i) {
+ r.prototype._deserialize.call(this, e, n, i), this.minimum = e.minimum, this.maximum = e.maximum;
+ }, Object(c.c)([Bt("Minimum", It.Float)], t.prototype, "minimum", void 0), Object(c.c)([Bt("Maximum", It.Float)], t.prototype, "maximum", void 0), t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.ClampBlock"] = fh;
+ var ph = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("left", le.AutoDetect), n.registerInput("right", le.AutoDetect), n.registerOutput("output", le.Vector3), n._linkConnectionTypes(0, 1), n._inputs[0].excludedConnectionPointTypes.push(le.Float), n._inputs[0].excludedConnectionPointTypes.push(le.Matrix), n._inputs[0].excludedConnectionPointTypes.push(le.Vector2), n._inputs[1].excludedConnectionPointTypes.push(le.Float), n._inputs[1].excludedConnectionPointTypes.push(le.Matrix), n._inputs[1].excludedConnectionPointTypes.push(le.Vector2), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "CrossBlock";
+ }, Object.defineProperty(t.prototype, "left", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "right", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0];
+ return e.compilationString += this._declareOutput(n, e) + " = cross(" + this.left.associatedVariableName + ".xyz, " + this.right.associatedVariableName + `.xyz);\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.CrossBlock"] = ph;
+ var _h = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("left", le.AutoDetect), n.registerInput("right", le.AutoDetect), n.registerOutput("output", le.Float), n._linkConnectionTypes(0, 1), n._inputs[0].excludedConnectionPointTypes.push(le.Float), n._inputs[0].excludedConnectionPointTypes.push(le.Matrix), n._inputs[1].excludedConnectionPointTypes.push(le.Float), n._inputs[1].excludedConnectionPointTypes.push(le.Matrix), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "DotBlock";
+ }, Object.defineProperty(t.prototype, "left", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "right", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0];
+ return e.compilationString += this._declareOutput(n, e) + " = dot(" + this.left.associatedVariableName + ", " + this.right.associatedVariableName + `);\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.DotBlock"] = _h;
+ var mh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("input", le.AutoDetect), n.registerOutput("output", le.BasedOnInput), n._outputs[0]._typeConnectionSource = n._inputs[0], n._inputs[0].excludedConnectionPointTypes.push(le.Float), n._inputs[0].excludedConnectionPointTypes.push(le.Matrix), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "NormalizeBlock";
+ }, Object.defineProperty(t.prototype, "input", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0], i = this._inputs[0];
+ return e.compilationString += this._declareOutput(n, e) + " = normalize(" + i.associatedVariableName + `);\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.NormalizeBlock"] = mh;
+ var gh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("rgb ", le.Color3, !0), n.registerInput("r", le.Float, !0), n.registerInput("g", le.Float, !0), n.registerInput("b", le.Float, !0), n.registerInput("a", le.Float, !0), n.registerOutput("rgba", le.Color4), n.registerOutput("rgb", le.Color3), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "ColorMergerBlock";
+ }, Object.defineProperty(t.prototype, "rgbIn", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "r", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "g", { get: function() {
+ return this._inputs[2];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "b", { get: function() {
+ return this._inputs[3];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "a", { get: function() {
+ return this._inputs[4];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgba", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgbOut", { get: function() {
+ return this._outputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "rgb", { get: function() {
+ return this.rgbOut;
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this.r, i = this.g, o = this.b, a = this.a, s = this.rgbIn, d = this._outputs[0], p = this._outputs[1];
+ return s.isConnected ? d.hasEndpoints ? e.compilationString += this._declareOutput(d, e) + " = vec4(" + s.associatedVariableName + ", " + (a.isConnected ? this._writeVariable(a) : "0.0") + `);\r
+` : p.hasEndpoints && (e.compilationString += this._declareOutput(p, e) + " = " + s.associatedVariableName + `;\r
+`) : d.hasEndpoints ? e.compilationString += this._declareOutput(d, e) + " = vec4(" + (n.isConnected ? this._writeVariable(n) : "0.0") + ", " + (i.isConnected ? this._writeVariable(i) : "0.0") + ", " + (o.isConnected ? this._writeVariable(o) : "0.0") + ", " + (a.isConnected ? this._writeVariable(a) : "0.0") + `);\r
+` : p.hasEndpoints && (e.compilationString += this._declareOutput(p, e) + " = vec3(" + (n.isConnected ? this._writeVariable(n) : "0.0") + ", " + (i.isConnected ? this._writeVariable(i) : "0.0") + ", " + (o.isConnected ? this._writeVariable(o) : "0.0") + `);\r
+`), this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.ColorMergerBlock"] = gh;
+ var vh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("xyzw", le.Vector4, !0), n.registerInput("xyz ", le.Vector3, !0), n.registerInput("xy ", le.Vector2, !0), n.registerOutput("xyz", le.Vector3), n.registerOutput("xy", le.Vector2), n.registerOutput("x", le.Float), n.registerOutput("y", le.Float), n.registerOutput("z", le.Float), n.registerOutput("w", le.Float), n.inputsAreExclusive = !0, n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "VectorSplitterBlock";
+ }, Object.defineProperty(t.prototype, "xyzw", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xyzIn", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xyIn", { get: function() {
+ return this._inputs[2];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xyzOut", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "xyOut", { get: function() {
+ return this._outputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "x", { get: function() {
+ return this._outputs[2];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "y", { get: function() {
+ return this._outputs[3];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "z", { get: function() {
+ return this._outputs[4];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "w", { get: function() {
+ return this._outputs[5];
+ }, enumerable: !1, configurable: !0 }), t.prototype._inputRename = function(e) {
+ switch (e) {
+ case "xy ":
+ return "xyIn";
+ case "xyz ":
+ return "xyzIn";
+ default:
+ return e;
+ }
+ }, t.prototype._outputRename = function(e) {
+ switch (e) {
+ case "xy":
+ return "xyOut";
+ case "xyz":
+ return "xyzOut";
+ default:
+ return e;
+ }
+ }, t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this.xyzw.isConnected ? this.xyzw : this.xyzIn.isConnected ? this.xyzIn : this.xyIn, i = this._outputs[0], o = this._outputs[1], a = this._outputs[2], s = this._outputs[3], d = this._outputs[4], p = this._outputs[5];
+ return i.hasEndpoints && (n === this.xyIn ? e.compilationString += this._declareOutput(i, e) + " = vec3(" + n.associatedVariableName + `, 0.0);\r
+` : e.compilationString += this._declareOutput(i, e) + " = " + n.associatedVariableName + `.xyz;\r
+`), o.hasEndpoints && (e.compilationString += this._declareOutput(o, e) + " = " + n.associatedVariableName + `.xy;\r
+`), a.hasEndpoints && (e.compilationString += this._declareOutput(a, e) + " = " + n.associatedVariableName + `.x;\r
+`), s.hasEndpoints && (e.compilationString += this._declareOutput(s, e) + " = " + n.associatedVariableName + `.y;\r
+`), d.hasEndpoints && (e.compilationString += this._declareOutput(d, e) + " = " + n.associatedVariableName + `.z;\r
+`), p.hasEndpoints && (e.compilationString += this._declareOutput(p, e) + " = " + n.associatedVariableName + `.w;\r
+`), this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.VectorSplitterBlock"] = vh;
+ var yh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("left", le.AutoDetect), n.registerInput("right", le.AutoDetect), n.registerInput("gradient", le.AutoDetect), n.registerOutput("output", le.BasedOnInput), n._outputs[0]._typeConnectionSource = n._inputs[0], n._linkConnectionTypes(0, 1), n._linkConnectionTypes(1, 2, !0), n._inputs[2].acceptedConnectionPointTypes.push(le.Float), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "LerpBlock";
+ }, Object.defineProperty(t.prototype, "left", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "right", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "gradient", { get: function() {
+ return this._inputs[2];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0];
+ return e.compilationString += this._declareOutput(n, e) + " = mix(" + this.left.associatedVariableName + " , " + this.right.associatedVariableName + ", " + this.gradient.associatedVariableName + `);\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.LerpBlock"] = yh;
+ var bh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("left", le.AutoDetect), n.registerInput("right", le.AutoDetect), n.registerOutput("output", le.BasedOnInput), n._outputs[0]._typeConnectionSource = n._inputs[0], n._linkConnectionTypes(0, 1), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "DivideBlock";
+ }, Object.defineProperty(t.prototype, "left", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "right", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0];
+ return e.compilationString += this._declareOutput(n, e) + " = " + this.left.associatedVariableName + " / " + this.right.associatedVariableName + `;\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.DivideBlock"] = bh;
+ var Th = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("left", le.AutoDetect), n.registerInput("right", le.AutoDetect), n.registerOutput("output", le.BasedOnInput), n._outputs[0]._typeConnectionSource = n._inputs[0], n._linkConnectionTypes(0, 1), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "SubtractBlock";
+ }, Object.defineProperty(t.prototype, "left", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "right", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0];
+ return e.compilationString += this._declareOutput(n, e) + " = " + this.left.associatedVariableName + " - " + this.right.associatedVariableName + `;\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.SubtractBlock"] = Th;
+ var Eh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("value", le.Float), n.registerInput("edge", le.Float), n.registerOutput("output", le.Float), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "StepBlock";
+ }, Object.defineProperty(t.prototype, "value", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "edge", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0];
+ return e.compilationString += this._declareOutput(n, e) + " = step(" + this.edge.associatedVariableName + ", " + this.value.associatedVariableName + `);\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.StepBlock"] = Eh;
+ var nc = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("input", le.AutoDetect), n.registerOutput("output", le.BasedOnInput), n._outputs[0]._typeConnectionSource = n._inputs[0], n._outputs[0].excludedConnectionPointTypes.push(le.Matrix), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "OneMinusBlock";
+ }, Object.defineProperty(t.prototype, "input", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0];
+ return e.compilationString += this._declareOutput(n, e) + " = 1. - " + this.input.associatedVariableName + `;\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.OneMinusBlock"] = nc, O.a.RegisteredTypes["BABYLON.OppositeBlock"] = nc;
+ var ic = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("worldPosition", le.Vector4), n.registerInput("cameraPosition", le.Vector3), n.registerOutput("output", le.Vector3), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "ViewDirectionBlock";
+ }, Object.defineProperty(t.prototype, "worldPosition", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraPosition", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function(e) {
+ if (!this.cameraPosition.isConnected) {
+ var n = e.getInputBlockByPredicate(function(i) {
+ return i.systemValue === gt.CameraPosition;
+ });
+ n || (n = new Et("cameraPosition")).setAsSystemValue(gt.CameraPosition), n.output.connectTo(this.cameraPosition);
+ }
+ }, t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0];
+ return e.compilationString += this._declareOutput(n, e) + " = normalize(" + this.cameraPosition.associatedVariableName + " - " + this.worldPosition.associatedVariableName + `.xyz);\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.ViewDirectionBlock"] = ic, f(161);
+ var Sh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("worldNormal", le.Vector4), n.registerInput("viewDirection", le.Vector3), n.registerInput("bias", le.Float), n.registerInput("power", le.Float), n.registerOutput("fresnel", le.Float), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "FresnelBlock";
+ }, Object.defineProperty(t.prototype, "worldNormal", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "viewDirection", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "bias", { get: function() {
+ return this._inputs[2];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "power", { get: function() {
+ return this._inputs[3];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "fresnel", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function(e) {
+ if (!this.viewDirection.isConnected) {
+ var n = new ic("View direction");
+ n.output.connectTo(this.viewDirection), n.autoConfigure(e);
+ }
+ if (!this.bias.isConnected) {
+ var i = new Et("bias");
+ i.value = 0, i.output.connectTo(this.bias);
+ }
+ if (!this.power.isConnected) {
+ var o = new Et("power");
+ o.value = 1, o.output.connectTo(this.power);
+ }
+ }, t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = "//" + this.name;
+ return e._emitFunctionFromInclude("fresnelFunction", n, { removeIfDef: !0 }), e.compilationString += this._declareOutput(this.fresnel, e) + " = computeFresnelTerm(" + this.viewDirection.associatedVariableName + ".xyz, " + this.worldNormal.associatedVariableName + ".xyz, " + this.bias.associatedVariableName + ", " + this.power.associatedVariableName + `);\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.FresnelBlock"] = Sh;
+ var Ah = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("left", le.AutoDetect), n.registerInput("right", le.AutoDetect), n.registerOutput("output", le.BasedOnInput), n._outputs[0]._typeConnectionSource = n._inputs[0], n._linkConnectionTypes(0, 1), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "MaxBlock";
+ }, Object.defineProperty(t.prototype, "left", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "right", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0];
+ return e.compilationString += this._declareOutput(n, e) + " = max(" + this.left.associatedVariableName + ", " + this.right.associatedVariableName + `);\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.MaxBlock"] = Ah;
+ var Ph = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("left", le.AutoDetect), n.registerInput("right", le.AutoDetect), n.registerOutput("output", le.BasedOnInput), n._outputs[0]._typeConnectionSource = n._inputs[0], n._linkConnectionTypes(0, 1), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "MinBlock";
+ }, Object.defineProperty(t.prototype, "left", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "right", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0];
+ return e.compilationString += this._declareOutput(n, e) + " = min(" + this.left.associatedVariableName + ", " + this.right.associatedVariableName + `);\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.MinBlock"] = Ph;
+ var xh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("left", le.AutoDetect), n.registerInput("right", le.AutoDetect), n.registerOutput("output", le.Float), n._linkConnectionTypes(0, 1), n._inputs[0].excludedConnectionPointTypes.push(le.Float), n._inputs[0].excludedConnectionPointTypes.push(le.Matrix), n._inputs[1].excludedConnectionPointTypes.push(le.Float), n._inputs[1].excludedConnectionPointTypes.push(le.Matrix), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "DistanceBlock";
+ }, Object.defineProperty(t.prototype, "left", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "right", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0];
+ return e.compilationString += this._declareOutput(n, e) + " = length(" + this.left.associatedVariableName + " - " + this.right.associatedVariableName + `);\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.DistanceBlock"] = xh;
+ var Ch = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("value", le.AutoDetect), n.registerOutput("output", le.Float), n._inputs[0].excludedConnectionPointTypes.push(le.Float), n._inputs[0].excludedConnectionPointTypes.push(le.Matrix), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "LengthBlock";
+ }, Object.defineProperty(t.prototype, "value", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0];
+ return e.compilationString += this._declareOutput(n, e) + " = length(" + this.value.associatedVariableName + `);\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.LengthBlock"] = Ch;
+ var Rh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("value", le.AutoDetect), n.registerOutput("output", le.BasedOnInput), n._outputs[0]._typeConnectionSource = n._inputs[0], n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "NegateBlock";
+ }, Object.defineProperty(t.prototype, "value", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0];
+ return e.compilationString += this._declareOutput(n, e) + " = -1.0 * " + this.value.associatedVariableName + `;\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.NegateBlock"] = Rh;
+ var Oh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("value", le.AutoDetect), n.registerInput("power", le.AutoDetect), n.registerOutput("output", le.BasedOnInput), n._outputs[0]._typeConnectionSource = n._inputs[0], n._linkConnectionTypes(0, 1), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "PowBlock";
+ }, Object.defineProperty(t.prototype, "value", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "power", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0];
+ return e.compilationString += this._declareOutput(n, e) + " = pow(" + this.value.associatedVariableName + ", " + this.power.associatedVariableName + `);\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.PowBlock"] = Oh;
+ var Mh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("seed", le.Vector2), n.registerOutput("output", le.Float), n._inputs[0].acceptedConnectionPointTypes.push(le.Vector3), n._inputs[0].acceptedConnectionPointTypes.push(le.Vector4), n._inputs[0].acceptedConnectionPointTypes.push(le.Color3), n._inputs[0].acceptedConnectionPointTypes.push(le.Color4), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "RandomNumberBlock";
+ }, Object.defineProperty(t.prototype, "seed", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0], i = "//" + this.name;
+ return e._emitFunctionFromInclude("helperFunctions", i), e.compilationString += this._declareOutput(n, e) + " = getRand(" + this.seed.associatedVariableName + `.xy);\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.RandomNumberBlock"] = Mh;
+ var Ih = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("x", le.Float), n.registerInput("y", le.Float), n.registerOutput("output", le.Float), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "ArcTan2Block";
+ }, Object.defineProperty(t.prototype, "x", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "y", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0];
+ return e.compilationString += this._declareOutput(n, e) + " = atan(" + this.x.associatedVariableName + ", " + this.y.associatedVariableName + `);\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.ArcTan2Block"] = Ih;
+ var Dh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("value", le.AutoDetect), n.registerInput("edge0", le.Float), n.registerInput("edge1", le.Float), n.registerOutput("output", le.BasedOnInput), n._outputs[0]._typeConnectionSource = n._inputs[0], n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "SmoothStepBlock";
+ }, Object.defineProperty(t.prototype, "value", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "edge0", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "edge1", { get: function() {
+ return this._inputs[2];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0];
+ return e.compilationString += this._declareOutput(n, e) + " = smoothstep(" + this.edge0.associatedVariableName + ", " + this.edge1.associatedVariableName + ", " + this.value.associatedVariableName + `);\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.SmoothStepBlock"] = Dh;
+ var Lh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("input", le.AutoDetect), n.registerOutput("output", le.BasedOnInput), n._outputs[0]._typeConnectionSource = n._inputs[0], n._outputs[0].excludedConnectionPointTypes.push(le.Matrix), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "ReciprocalBlock";
+ }, Object.defineProperty(t.prototype, "input", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0];
+ return e.compilationString += this._declareOutput(n, e) + " = 1. / " + this.input.associatedVariableName + `;\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.ReciprocalBlock"] = Lh;
+ var Nh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("value", le.AutoDetect), n.registerInput("reference", le.AutoDetect), n.registerInput("distance", le.Float), n.registerInput("replacement", le.AutoDetect), n.registerOutput("output", le.BasedOnInput), n._outputs[0]._typeConnectionSource = n._inputs[0], n._linkConnectionTypes(0, 1), n._linkConnectionTypes(0, 3), n._inputs[0].excludedConnectionPointTypes.push(le.Float), n._inputs[0].excludedConnectionPointTypes.push(le.Matrix), n._inputs[1].excludedConnectionPointTypes.push(le.Float), n._inputs[1].excludedConnectionPointTypes.push(le.Matrix), n._inputs[3].excludedConnectionPointTypes.push(le.Float), n._inputs[3].excludedConnectionPointTypes.push(le.Matrix), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "ReplaceColorBlock";
+ }, Object.defineProperty(t.prototype, "value", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "reference", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "distance", { get: function() {
+ return this._inputs[2];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "replacement", { get: function() {
+ return this._inputs[3];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0];
+ return e.compilationString += this._declareOutput(n, e) + `;\r
+`, e.compilationString += "if (length(" + this.value.associatedVariableName + " - " + this.reference.associatedVariableName + ") < " + this.distance.associatedVariableName + `) {\r
+`, e.compilationString += n.associatedVariableName + " = " + this.replacement.associatedVariableName + `;\r
+`, e.compilationString += `} else {\r
+`, e.compilationString += n.associatedVariableName + " = " + this.value.associatedVariableName + `;\r
+`, e.compilationString += `}\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.ReplaceColorBlock"] = Nh;
+ var qi, wh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("value", le.AutoDetect), n.registerInput("steps", le.AutoDetect), n.registerOutput("output", le.BasedOnInput), n._outputs[0]._typeConnectionSource = n._inputs[0], n._linkConnectionTypes(0, 1), n._inputs[0].excludedConnectionPointTypes.push(le.Matrix), n._inputs[1].excludedConnectionPointTypes.push(le.Matrix), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "PosterizeBlock";
+ }, Object.defineProperty(t.prototype, "value", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "steps", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0];
+ return e.compilationString += this._declareOutput(n, e) + " = floor(" + this.value.associatedVariableName + " / (1.0 / " + this.steps.associatedVariableName + ")) * (1.0 / " + this.steps.associatedVariableName + `);\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.PosterizeBlock"] = wh, function(r) {
+ r[r.SawTooth = 0] = "SawTooth", r[r.Square = 1] = "Square", r[r.Triangle = 2] = "Triangle";
+ }(qi || (qi = {}));
+ var Fh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.kind = qi.SawTooth, n.registerInput("input", le.AutoDetect), n.registerOutput("output", le.BasedOnInput), n._outputs[0]._typeConnectionSource = n._inputs[0], n._inputs[0].excludedConnectionPointTypes.push(le.Matrix), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "WaveBlock";
+ }, Object.defineProperty(t.prototype, "input", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0];
+ switch (this.kind) {
+ case qi.SawTooth:
+ e.compilationString += this._declareOutput(n, e) + " = " + this.input.associatedVariableName + " - floor(0.5 + " + this.input.associatedVariableName + `);\r
+`;
+ break;
+ case qi.Square:
+ e.compilationString += this._declareOutput(n, e) + " = 1.0 - 2.0 * round(fract(" + this.input.associatedVariableName + `));\r
+`;
+ break;
+ case qi.Triangle:
+ e.compilationString += this._declareOutput(n, e) + " = 2.0 * abs(2.0 * (" + this.input.associatedVariableName + " - floor(0.5 + " + this.input.associatedVariableName + `))) - 1.0;\r
+`;
+ }
+ return this;
+ }, t.prototype.serialize = function() {
+ var e = r.prototype.serialize.call(this);
+ return e.kind = this.kind, e;
+ }, t.prototype._deserialize = function(e, n, i) {
+ r.prototype._deserialize.call(this, e, n, i), this.kind = e.kind;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.WaveBlock"] = Fh;
+ var ca = function() {
+ function r(t, e) {
+ this.step = t, this.color = e;
+ }
+ return Object.defineProperty(r.prototype, "step", { get: function() {
+ return this._step;
+ }, set: function(t) {
+ this._step = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "color", { get: function() {
+ return this._color;
+ }, set: function(t) {
+ this._color = t;
+ }, enumerable: !1, configurable: !0 }), r;
+ }(), Bh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.colorSteps = [new ca(0, I.a.Black()), new ca(1, I.a.White())], n.onValueChangedObservable = new C.c(), n.registerInput("gradient", le.Float), n.registerOutput("output", le.Color3), n._inputs[0].acceptedConnectionPointTypes.push(le.Vector2), n._inputs[0].acceptedConnectionPointTypes.push(le.Vector3), n._inputs[0].acceptedConnectionPointTypes.push(le.Vector4), n._inputs[0].acceptedConnectionPointTypes.push(le.Color3), n._inputs[0].acceptedConnectionPointTypes.push(le.Color4), n;
+ }
+ return Object(c.d)(t, r), t.prototype.colorStepsUpdated = function() {
+ this.onValueChangedObservable.notifyObservers(this);
+ }, t.prototype.getClassName = function() {
+ return "GradientBlock";
+ }, Object.defineProperty(t.prototype, "gradient", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._writeColorConstant = function(e) {
+ var n = this.colorSteps[e];
+ return "vec3(" + n.color.r + ", " + n.color.g + ", " + n.color.b + ")";
+ }, t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0];
+ if (this.colorSteps.length && this.gradient.connectedPoint) {
+ var i = e._getFreeVariableName("gradientTempColor"), o = e._getFreeVariableName("gradientTempPosition");
+ e.compilationString += "vec3 " + i + " = " + this._writeColorConstant(0) + `;\r
+`, e.compilationString += "float " + o + `;\r
+`;
+ var a = this.gradient.associatedVariableName;
+ this.gradient.connectedPoint.type !== le.Float && (a += ".x");
+ for (var s = 1; s < this.colorSteps.length; s++) {
+ var d = this.colorSteps[s], p = this.colorSteps[s - 1];
+ e.compilationString += o + " = clamp((" + a + " - " + e._emitFloat(p.step) + ") / (" + e._emitFloat(d.step) + " - " + e._emitFloat(p.step) + "), 0.0, 1.0) * step(" + e._emitFloat(s) + ", " + e._emitFloat(this.colorSteps.length - 1) + `);\r
+`, e.compilationString += i + " = mix(" + i + ", " + this._writeColorConstant(s) + ", " + o + `);\r
+`;
+ }
+ return e.compilationString += this._declareOutput(n, e) + " = " + i + `;\r
+`, this;
+ }
+ e.compilationString += this._declareOutput(n, e) + ` = vec3(0., 0., 0.);\r
+`;
+ }, t.prototype.serialize = function() {
+ var e = r.prototype.serialize.call(this);
+ e.colorSteps = [];
+ for (var n = 0, i = this.colorSteps; n < i.length; n++) {
+ var o = i[n];
+ e.colorSteps.push({ step: o.step, color: { r: o.color.r, g: o.color.g, b: o.color.b } });
+ }
+ return e;
+ }, t.prototype._deserialize = function(e, n, i) {
+ r.prototype._deserialize.call(this, e, n, i), this.colorSteps = [];
+ for (var o = 0, a = e.colorSteps; o < a.length; o++) {
+ var s = a[o];
+ this.colorSteps.push(new ca(s.step, new I.a(s.color.r, s.color.g, s.color.b)));
+ }
+ }, t.prototype._dumpPropertiesCode = function() {
+ for (var e = "", n = 0, i = this.colorSteps; n < i.length; n++) {
+ var o = i[n];
+ e += this._codeVariableName + ".colorSteps.push(new BABYLON.GradientBlockColorStep(" + o.step + ", new BABYLON.Color3(" + o.color.r + ", " + o.color.g + ", " + o.color.b + `)));\r
+`;
+ }
+ return e;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.GradientBlock"] = Bh;
+ var Uh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("left", le.AutoDetect), n.registerInput("right", le.AutoDetect), n.registerInput("gradient", le.AutoDetect), n.registerOutput("output", le.BasedOnInput), n._outputs[0]._typeConnectionSource = n._inputs[0], n._linkConnectionTypes(0, 1), n._linkConnectionTypes(1, 2, !0), n._inputs[2].acceptedConnectionPointTypes.push(le.Float), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "NLerpBlock";
+ }, Object.defineProperty(t.prototype, "left", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "right", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "gradient", { get: function() {
+ return this._inputs[2];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0];
+ return e.compilationString += this._declareOutput(n, e) + " = normalize(mix(" + this.left.associatedVariableName + " , " + this.right.associatedVariableName + ", " + this.gradient.associatedVariableName + `));\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.NLerpBlock"] = Uh;
+ var Vh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.manhattanDistance = !1, n.registerInput("seed", le.Vector3), n.registerInput("jitter", le.Float), n.registerOutput("output", le.Vector2), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "WorleyNoise3DBlock";
+ }, Object.defineProperty(t.prototype, "seed", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "jitter", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ if (r.prototype._buildBlock.call(this, e), this.seed.isConnected && this._outputs[0].hasEndpoints)
+ return e._emitFunction("worley3D", `vec3 permute(vec3 x){\r
+ return mod((34.0 * x + 1.0) * x, 289.0);\r
+}\r
+\r
+vec3 dist(vec3 x, vec3 y, vec3 z, bool manhattanDistance){\r
+ return manhattanDistance ? abs(x) + abs(y) + abs(z) : (x * x + y * y + z * z);\r
+}\r
+\r
+vec2 worley(vec3 P, float jitter, bool manhattanDistance){\r
+ float K = 0.142857142857; // 1/7\r
+ float Ko = 0.428571428571; // 1/2-K/2\r
+ float K2 = 0.020408163265306; // 1/(7*7)\r
+ float Kz = 0.166666666667; // 1/6\r
+ float Kzo = 0.416666666667; // 1/2-1/6*2\r
+\r
+ vec3 Pi = mod(floor(P), 289.0);\r
+ vec3 Pf = fract(P) - 0.5;\r
+\r
+ vec3 Pfx = Pf.x + vec3(1.0, 0.0, -1.0);\r
+ vec3 Pfy = Pf.y + vec3(1.0, 0.0, -1.0);\r
+ vec3 Pfz = Pf.z + vec3(1.0, 0.0, -1.0);\r
+\r
+ vec3 p = permute(Pi.x + vec3(-1.0, 0.0, 1.0));\r
+ vec3 p1 = permute(p + Pi.y - 1.0);\r
+ vec3 p2 = permute(p + Pi.y);\r
+ vec3 p3 = permute(p + Pi.y + 1.0);\r
+\r
+ vec3 p11 = permute(p1 + Pi.z - 1.0);\r
+ vec3 p12 = permute(p1 + Pi.z);\r
+ vec3 p13 = permute(p1 + Pi.z + 1.0);\r
+\r
+ vec3 p21 = permute(p2 + Pi.z - 1.0);\r
+ vec3 p22 = permute(p2 + Pi.z);\r
+ vec3 p23 = permute(p2 + Pi.z + 1.0);\r
+\r
+ vec3 p31 = permute(p3 + Pi.z - 1.0);\r
+ vec3 p32 = permute(p3 + Pi.z);\r
+ vec3 p33 = permute(p3 + Pi.z + 1.0);\r
+\r
+ vec3 ox11 = fract(p11*K) - Ko;\r
+ vec3 oy11 = mod(floor(p11*K), 7.0)*K - Ko;\r
+ vec3 oz11 = floor(p11*K2)*Kz - Kzo; // p11 < 289 guaranteed\r
+\r
+ vec3 ox12 = fract(p12*K) - Ko;\r
+ vec3 oy12 = mod(floor(p12*K), 7.0)*K - Ko;\r
+ vec3 oz12 = floor(p12*K2)*Kz - Kzo;\r
+\r
+ vec3 ox13 = fract(p13*K) - Ko;\r
+ vec3 oy13 = mod(floor(p13*K), 7.0)*K - Ko;\r
+ vec3 oz13 = floor(p13*K2)*Kz - Kzo;\r
+\r
+ vec3 ox21 = fract(p21*K) - Ko;\r
+ vec3 oy21 = mod(floor(p21*K), 7.0)*K - Ko;\r
+ vec3 oz21 = floor(p21*K2)*Kz - Kzo;\r
+\r
+ vec3 ox22 = fract(p22*K) - Ko;\r
+ vec3 oy22 = mod(floor(p22*K), 7.0)*K - Ko;\r
+ vec3 oz22 = floor(p22*K2)*Kz - Kzo;\r
+\r
+ vec3 ox23 = fract(p23*K) - Ko;\r
+ vec3 oy23 = mod(floor(p23*K), 7.0)*K - Ko;\r
+ vec3 oz23 = floor(p23*K2)*Kz - Kzo;\r
+\r
+ vec3 ox31 = fract(p31*K) - Ko;\r
+ vec3 oy31 = mod(floor(p31*K), 7.0)*K - Ko;\r
+ vec3 oz31 = floor(p31*K2)*Kz - Kzo;\r
+\r
+ vec3 ox32 = fract(p32*K) - Ko;\r
+ vec3 oy32 = mod(floor(p32*K), 7.0)*K - Ko;\r
+ vec3 oz32 = floor(p32*K2)*Kz - Kzo;\r
+\r
+ vec3 ox33 = fract(p33*K) - Ko;\r
+ vec3 oy33 = mod(floor(p33*K), 7.0)*K - Ko;\r
+ vec3 oz33 = floor(p33*K2)*Kz - Kzo;\r
+\r
+ vec3 dx11 = Pfx + jitter*ox11;\r
+ vec3 dy11 = Pfy.x + jitter*oy11;\r
+ vec3 dz11 = Pfz.x + jitter*oz11;\r
+\r
+ vec3 dx12 = Pfx + jitter*ox12;\r
+ vec3 dy12 = Pfy.x + jitter*oy12;\r
+ vec3 dz12 = Pfz.y + jitter*oz12;\r
+\r
+ vec3 dx13 = Pfx + jitter*ox13;\r
+ vec3 dy13 = Pfy.x + jitter*oy13;\r
+ vec3 dz13 = Pfz.z + jitter*oz13;\r
+\r
+ vec3 dx21 = Pfx + jitter*ox21;\r
+ vec3 dy21 = Pfy.y + jitter*oy21;\r
+ vec3 dz21 = Pfz.x + jitter*oz21;\r
+\r
+ vec3 dx22 = Pfx + jitter*ox22;\r
+ vec3 dy22 = Pfy.y + jitter*oy22;\r
+ vec3 dz22 = Pfz.y + jitter*oz22;\r
+\r
+ vec3 dx23 = Pfx + jitter*ox23;\r
+ vec3 dy23 = Pfy.y + jitter*oy23;\r
+ vec3 dz23 = Pfz.z + jitter*oz23;\r
+\r
+ vec3 dx31 = Pfx + jitter*ox31;\r
+ vec3 dy31 = Pfy.z + jitter*oy31;\r
+ vec3 dz31 = Pfz.x + jitter*oz31;\r
+\r
+ vec3 dx32 = Pfx + jitter*ox32;\r
+ vec3 dy32 = Pfy.z + jitter*oy32;\r
+ vec3 dz32 = Pfz.y + jitter*oz32;\r
+\r
+ vec3 dx33 = Pfx + jitter*ox33;\r
+ vec3 dy33 = Pfy.z + jitter*oy33;\r
+ vec3 dz33 = Pfz.z + jitter*oz33;\r
+\r
+ vec3 d11 = dist(dx11, dy11, dz11, manhattanDistance);\r
+ vec3 d12 =dist(dx12, dy12, dz12, manhattanDistance);\r
+ vec3 d13 = dist(dx13, dy13, dz13, manhattanDistance);\r
+ vec3 d21 = dist(dx21, dy21, dz21, manhattanDistance);\r
+ vec3 d22 = dist(dx22, dy22, dz22, manhattanDistance);\r
+ vec3 d23 = dist(dx23, dy23, dz23, manhattanDistance);\r
+ vec3 d31 = dist(dx31, dy31, dz31, manhattanDistance);\r
+ vec3 d32 = dist(dx32, dy32, dz32, manhattanDistance);\r
+ vec3 d33 = dist(dx33, dy33, dz33, manhattanDistance);\r
+\r
+ vec3 d1a = min(d11, d12);\r
+ d12 = max(d11, d12);\r
+ d11 = min(d1a, d13); // Smallest now not in d12 or d13\r
+ d13 = max(d1a, d13);\r
+ d12 = min(d12, d13); // 2nd smallest now not in d13\r
+ vec3 d2a = min(d21, d22);\r
+ d22 = max(d21, d22);\r
+ d21 = min(d2a, d23); // Smallest now not in d22 or d23\r
+ d23 = max(d2a, d23);\r
+ d22 = min(d22, d23); // 2nd smallest now not in d23\r
+ vec3 d3a = min(d31, d32);\r
+ d32 = max(d31, d32);\r
+ d31 = min(d3a, d33); // Smallest now not in d32 or d33\r
+ d33 = max(d3a, d33);\r
+ d32 = min(d32, d33); // 2nd smallest now not in d33\r
+ vec3 da = min(d11, d21);\r
+ d21 = max(d11, d21);\r
+ d11 = min(da, d31); // Smallest now in d11\r
+ d31 = max(da, d31); // 2nd smallest now not in d31\r
+ d11.xy = (d11.x < d11.y) ? d11.xy : d11.yx;\r
+ d11.xz = (d11.x < d11.z) ? d11.xz : d11.zx; // d11.x now smallest\r
+ d12 = min(d12, d21); // 2nd smallest now not in d21\r
+ d12 = min(d12, d22); // nor in d22\r
+ d12 = min(d12, d31); // nor in d31\r
+ d12 = min(d12, d32); // nor in d32\r
+ d11.yz = min(d11.yz,d12.xy); // nor in d12.yz\r
+ d11.y = min(d11.y,d12.z); // Only two more to go\r
+ d11.y = min(d11.y,d11.z); // Done! (Phew!)\r
+ return sqrt(d11.xy); // F1, F2\r
+}\r
+\r
+`, "// Worley3D"), e.compilationString += this._declareOutput(this._outputs[0], e) + " = worley(" + this.seed.associatedVariableName + ", " + this.jitter.associatedVariableName + ", " + this.manhattanDistance + `);\r
+`, this;
+ }, t.prototype._dumpPropertiesCode = function() {
+ return this._codeVariableName + ".manhattanDistance = " + this.manhattanDistance + `;\r
+`;
+ }, t.prototype.serialize = function() {
+ var e = r.prototype.serialize.call(this);
+ return e.manhattanDistance = this.manhattanDistance, e;
+ }, t.prototype._deserialize = function(e, n, i) {
+ r.prototype._deserialize.call(this, e, n, i), this.manhattanDistance = e.manhattanDistance;
+ }, Object(c.c)([Bt("Use Manhattan Distance", It.Boolean, "PROPERTIES", { notifiers: { update: !1 } })], t.prototype, "manhattanDistance", void 0), t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.WorleyNoise3DBlock"] = Vh;
+ var kh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("seed", le.Vector3), n.registerOutput("output", le.Float), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "SimplexPerlin3DBlock";
+ }, Object.defineProperty(t.prototype, "seed", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ if (r.prototype._buildBlock.call(this, e), this.seed.isConnected && this._outputs[0].hasEndpoints)
+ return e._emitFunction("SimplexPerlin3D", `const float SKEWFACTOR = 1.0/3.0;\r
+const float UNSKEWFACTOR = 1.0/6.0;\r
+const float SIMPLEX_CORNER_POS = 0.5;\r
+const float SIMPLEX_TETRAHADRON_HEIGHT = 0.70710678118654752440084436210485;\r
+float SimplexPerlin3D( vec3 P ){\r
+ P *= SIMPLEX_TETRAHADRON_HEIGHT;\r
+ vec3 Pi = floor( P + dot( P, vec3( SKEWFACTOR) ) ); vec3 x0 = P - Pi + dot(Pi, vec3( UNSKEWFACTOR ) );\r
+ vec3 g = step(x0.yzx, x0.xyz);\r
+ vec3 l = 1.0 - g;\r
+ vec3 Pi_1 = min( g.xyz, l.zxy );\r
+ vec3 Pi_2 = max( g.xyz, l.zxy );\r
+ vec3 x1 = x0 - Pi_1 + UNSKEWFACTOR;\r
+ vec3 x2 = x0 - Pi_2 + SKEWFACTOR;\r
+ vec3 x3 = x0 - SIMPLEX_CORNER_POS;\r
+ vec4 v1234_x = vec4( x0.x, x1.x, x2.x, x3.x );\r
+ vec4 v1234_y = vec4( x0.y, x1.y, x2.y, x3.y );\r
+ vec4 v1234_z = vec4( x0.z, x1.z, x2.z, x3.z );\r
+ Pi.xyz = Pi.xyz - floor(Pi.xyz * ( 1.0 / 69.0 )) * 69.0;\r
+ vec3 Pi_inc1 = step( Pi, vec3( 69.0 - 1.5 ) ) * ( Pi + 1.0 );\r
+ vec4 Pt = vec4( Pi.xy, Pi_inc1.xy ) + vec2( 50.0, 161.0 ).xyxy;\r
+ Pt *= Pt;\r
+ vec4 V1xy_V2xy = mix( Pt.xyxy, Pt.zwzw, vec4( Pi_1.xy, Pi_2.xy ) );\r
+ Pt = vec4( Pt.x, V1xy_V2xy.xz, Pt.z ) * vec4( Pt.y, V1xy_V2xy.yw, Pt.w );\r
+ const vec3 SOMELARGEFLOATS = vec3( 635.298681, 682.357502, 668.926525 );\r
+ const vec3 ZINC = vec3( 48.500388, 65.294118, 63.934599 );\r
+ vec3 lowz_mods = vec3( 1.0 / ( SOMELARGEFLOATS.xyz + Pi.zzz * ZINC.xyz ) );\r
+ vec3 highz_mods = vec3( 1.0 / ( SOMELARGEFLOATS.xyz + Pi_inc1.zzz * ZINC.xyz ) );\r
+ Pi_1 = ( Pi_1.z < 0.5 ) ? lowz_mods : highz_mods;\r
+ Pi_2 = ( Pi_2.z < 0.5 ) ? lowz_mods : highz_mods;\r
+ vec4 hash_0 = fract( Pt * vec4( lowz_mods.x, Pi_1.x, Pi_2.x, highz_mods.x ) ) - 0.49999;\r
+ vec4 hash_1 = fract( Pt * vec4( lowz_mods.y, Pi_1.y, Pi_2.y, highz_mods.y ) ) - 0.49999;\r
+ vec4 hash_2 = fract( Pt * vec4( lowz_mods.z, Pi_1.z, Pi_2.z, highz_mods.z ) ) - 0.49999;\r
+ vec4 grad_results = inversesqrt( hash_0 * hash_0 + hash_1 * hash_1 + hash_2 * hash_2 ) * ( hash_0 * v1234_x + hash_1 * v1234_y + hash_2 * v1234_z );\r
+ const float FINAL_NORMALIZATION = 37.837227241611314102871574478976;\r
+ vec4 kernel_weights = v1234_x * v1234_x + v1234_y * v1234_y + v1234_z * v1234_z;\r
+ kernel_weights = max(0.5 - kernel_weights, 0.0);\r
+ kernel_weights = kernel_weights*kernel_weights*kernel_weights;\r
+ return dot( kernel_weights, grad_results ) * FINAL_NORMALIZATION;\r
+}\r
+`, "// SimplexPerlin3D"), e.compilationString += this._declareOutput(this._outputs[0], e) + " = SimplexPerlin3D(" + this.seed.associatedVariableName + `);\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.SimplexPerlin3DBlock"] = kh;
+ var Gh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("normalMap0", le.Vector3), n.registerInput("normalMap1", le.Vector3), n.registerOutput("output", le.Vector3), n._inputs[0].acceptedConnectionPointTypes.push(le.Color3), n._inputs[0].acceptedConnectionPointTypes.push(le.Color4), n._inputs[0].acceptedConnectionPointTypes.push(le.Vector4), n._inputs[1].acceptedConnectionPointTypes.push(le.Color3), n._inputs[1].acceptedConnectionPointTypes.push(le.Color4), n._inputs[1].acceptedConnectionPointTypes.push(le.Vector4), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "NormalBlendBlock";
+ }, Object.defineProperty(t.prototype, "normalMap0", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "normalMap1", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0], i = this._inputs[0], o = this._inputs[1], a = e._getFreeVariableName("stepR"), s = e._getFreeVariableName("stepG");
+ return e.compilationString += "float " + a + " = step(0.5, " + i.associatedVariableName + `.r);\r
+`, e.compilationString += "float " + s + " = step(0.5, " + i.associatedVariableName + `.g);\r
+`, e.compilationString += this._declareOutput(n, e) + `;\r
+`, e.compilationString += n.associatedVariableName + ".r = (1.0 - " + a + ") * " + i.associatedVariableName + ".r * " + o.associatedVariableName + ".r * 2.0 + " + a + " * (1.0 - " + i.associatedVariableName + ".r) * (1.0 - " + o.associatedVariableName + `.r) * 2.0;\r
+`, e.compilationString += n.associatedVariableName + ".g = (1.0 - " + s + ") * " + i.associatedVariableName + ".g * " + o.associatedVariableName + ".g * 2.0 + " + s + " * (1.0 - " + i.associatedVariableName + ".g) * (1.0 - " + o.associatedVariableName + `.g) * 2.0;\r
+`, e.compilationString += n.associatedVariableName + ".b = " + i.associatedVariableName + ".b * " + o.associatedVariableName + `.b;\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.NormalBlendBlock"] = Gh;
+ var zh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("input", le.Vector2), n.registerInput("angle", le.Float), n.registerOutput("output", le.Vector2), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "Rotate2dBlock";
+ }, Object.defineProperty(t.prototype, "input", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "angle", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function(e) {
+ if (!this.angle.isConnected) {
+ var n = new Et("angle");
+ n.value = 0, n.output.connectTo(this.angle);
+ }
+ }, t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0], i = this.angle, o = this.input;
+ return e.compilationString += this._declareOutput(n, e) + " = vec2(cos(" + i.associatedVariableName + ") * " + o.associatedVariableName + ".x - sin(" + i.associatedVariableName + ") * " + o.associatedVariableName + ".y, sin(" + i.associatedVariableName + ") * " + o.associatedVariableName + ".x + cos(" + i.associatedVariableName + ") * " + o.associatedVariableName + `.y);\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.Rotate2dBlock"] = zh;
+ var jh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("incident", le.Vector3), n.registerInput("normal", le.Vector3), n.registerOutput("output", le.Vector3), n._inputs[0].acceptedConnectionPointTypes.push(le.Vector4), n._inputs[0].acceptedConnectionPointTypes.push(le.Color3), n._inputs[0].acceptedConnectionPointTypes.push(le.Color4), n._inputs[1].acceptedConnectionPointTypes.push(le.Vector4), n._inputs[1].acceptedConnectionPointTypes.push(le.Color3), n._inputs[1].acceptedConnectionPointTypes.push(le.Color4), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "ReflectBlock";
+ }, Object.defineProperty(t.prototype, "incident", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "normal", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0];
+ return e.compilationString += this._declareOutput(n, e) + " = reflect(" + this.incident.associatedVariableName + ".xyz, " + this.normal.associatedVariableName + `.xyz);\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.ReflectBlock"] = jh;
+ var Hh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("incident", le.Vector3), n.registerInput("normal", le.Vector3), n.registerInput("ior", le.Float), n.registerOutput("output", le.Vector3), n._inputs[0].acceptedConnectionPointTypes.push(le.Vector4), n._inputs[0].acceptedConnectionPointTypes.push(le.Color3), n._inputs[0].acceptedConnectionPointTypes.push(le.Color4), n._inputs[1].acceptedConnectionPointTypes.push(le.Vector4), n._inputs[1].acceptedConnectionPointTypes.push(le.Color3), n._inputs[1].acceptedConnectionPointTypes.push(le.Color4), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "RefractBlock";
+ }, Object.defineProperty(t.prototype, "incident", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "normal", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "ior", { get: function() {
+ return this._inputs[2];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0];
+ return e.compilationString += this._declareOutput(n, e) + " = refract(" + this.incident.associatedVariableName + ".xyz, " + this.normal.associatedVariableName + ".xyz, " + this.ior.associatedVariableName + `);\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.RefractBlock"] = Hh;
+ var Wh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("color", le.Color3), n.registerInput("level", le.Float), n.registerOutput("output", le.Color3), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "DesaturateBlock";
+ }, Object.defineProperty(t.prototype, "color", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "level", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0], i = this.color.associatedVariableName, o = e._getFreeVariableName("colorMin"), a = e._getFreeVariableName("colorMax"), s = e._getFreeVariableName("colorMerge");
+ return e.compilationString += "float " + o + " = min(min(" + i + ".x, " + i + ".y), " + i + `.z);\r
+`, e.compilationString += "float " + a + " = max(max(" + i + ".x, " + i + ".y), " + i + `.z);\r
+`, e.compilationString += "float " + s + " = 0.5 * (" + o + " + " + a + `);\r
+`, e.compilationString += this._declareOutput(n, e) + " = mix(" + i + ", vec3(" + s + ", " + s + ", " + s + "), " + this.level.associatedVariableName + `);\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.DesaturateBlock"] = Wh;
+ var Xn = function(r) {
+ function t(e, n, i, o, a, s) {
+ var d = r.call(this, e, n, i) || this;
+ return d._blockType = o, d._blockName = a, d._nameForCheking = s, d._nameForCheking || (d._nameForCheking = e), d.needDualDirectionValidation = !0, d;
+ }
+ return Object(c.d)(t, r), t.prototype.checkCompatibilityState = function(e) {
+ return e instanceof t && e.name === this._nameForCheking ? ii.Compatible : ii.TypeIncompatible;
+ }, t.prototype.createCustomInputBlock = function() {
+ return [new this._blockType(this._blockName), this.name];
+ }, t;
+ }(na), rc = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Fragment) || this;
+ return n.albedoScaling = !1, n.linkSheenWithAlbedo = !1, n._isUnique = !0, n.registerInput("intensity", le.Float, !0, Ce.Fragment), n.registerInput("color", le.Color3, !0, Ce.Fragment), n.registerInput("roughness", le.Float, !0, Ce.Fragment), n.registerOutput("sheen", le.Object, Ce.Fragment, new Xn("sheen", n, yn.Output, t, "SheenBlock")), n;
+ }
+ return Object(c.d)(t, r), t.prototype.initialize = function(e) {
+ e._excludeVariableName("sheenOut"), e._excludeVariableName("sheenMapData"), e._excludeVariableName("vSheenColor"), e._excludeVariableName("vSheenRoughness");
+ }, t.prototype.getClassName = function() {
+ return "SheenBlock";
+ }, Object.defineProperty(t.prototype, "intensity", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "color", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "roughness", { get: function() {
+ return this._inputs[2];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "sheen", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype.prepareDefines = function(e, n, i) {
+ r.prototype.prepareDefines.call(this, e, n, i), i.setValue("SHEEN", !0), i.setValue("SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE", !0, !0), i.setValue("SHEEN_LINKWITHALBEDO", this.linkSheenWithAlbedo, !0), i.setValue("SHEEN_ROUGHNESS", this.roughness.isConnected, !0), i.setValue("SHEEN_ALBEDOSCALING", this.albedoScaling, !0);
+ }, t.prototype.getCode = function(e) {
+ return `#ifdef SHEEN
+ sheenOutParams sheenOut;
+
+ vec4 vSheenColor = vec4(` + (this.color.isConnected ? this.color.associatedVariableName : "vec3(1.)") + ", " + (this.intensity.isConnected ? this.intensity.associatedVariableName : "1.") + `);
+
+ sheenBlock(
+ vSheenColor,
+ #ifdef SHEEN_ROUGHNESS
+ ` + (this.roughness.isConnected ? this.roughness.associatedVariableName : "0.") + `,
+ #endif
+ roughness,
+ #ifdef SHEEN_TEXTURE
+ vec4(0.),
+ #endif
+ reflectance,
+ #ifdef SHEEN_LINKWITHALBEDO
+ baseColor,
+ surfaceAlbedo,
+ #endif
+ #ifdef ENVIRONMENTBRDF
+ NdotV,
+ environmentBrdf,
+ #endif
+ #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
+ AARoughnessFactors,
+ ` + (e == null ? void 0 : e._vReflectionMicrosurfaceInfosName) + `,
+ ` + (e == null ? void 0 : e._vReflectionInfosName) + `,
+ ` + (e == null ? void 0 : e.reflectionColor) + `,
+ vLightingIntensity,
+ #ifdef ` + (e == null ? void 0 : e._define3DName) + `
+ ` + (e == null ? void 0 : e._cubeSamplerName) + `,
+ #else
+ ` + (e == null ? void 0 : e._2DSamplerName) + `,
+ #endif
+ reflectionOut.reflectionCoords,
+ NdotVUnclamped,
+ #ifndef LODBASEDMICROSFURACE
+ #ifdef ` + (e == null ? void 0 : e._define3DName) + `
+ ` + (e == null ? void 0 : e._cubeSamplerName) + `,
+ ` + (e == null ? void 0 : e._cubeSamplerName) + `,
+ #else
+ ` + (e == null ? void 0 : e._2DSamplerName) + `,
+ ` + (e == null ? void 0 : e._2DSamplerName) + `,
+ #endif
+ #endif
+ #if !defined(` + (e == null ? void 0 : e._defineSkyboxName) + `) && defined(RADIANCEOCCLUSION)
+ seo,
+ #endif
+ #if !defined(` + (e == null ? void 0 : e._defineSkyboxName) + ") && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(" + (e == null ? void 0 : e._define3DName) + `)
+ eho,
+ #endif
+ #endif
+ sheenOut
+ );
+
+ #ifdef SHEEN_LINKWITHALBEDO
+ surfaceAlbedo = sheenOut.surfaceAlbedo;
+ #endif
+ #endif\r
+`;
+ }, t.prototype._buildBlock = function(e) {
+ return e.target === Ce.Fragment && e.sharedData.blocksWithDefines.push(this), this;
+ }, t.prototype._dumpPropertiesCode = function() {
+ var e = r.prototype._dumpPropertiesCode.call(this);
+ return e += this._codeVariableName + ".albedoScaling = " + this.albedoScaling + `;\r
+`, e += this._codeVariableName + ".linkSheenWithAlbedo = " + this.linkSheenWithAlbedo + `;\r
+`;
+ }, t.prototype.serialize = function() {
+ var e = r.prototype.serialize.call(this);
+ return e.albedoScaling = this.albedoScaling, e.linkSheenWithAlbedo = this.linkSheenWithAlbedo, e;
+ }, t.prototype._deserialize = function(e, n, i) {
+ r.prototype._deserialize.call(this, e, n, i), this.albedoScaling = e.albedoScaling, this.linkSheenWithAlbedo = e.linkSheenWithAlbedo;
+ }, Object(c.c)([Bt("Albedo scaling", It.Boolean, "PROPERTIES", { notifiers: { update: !0 } })], t.prototype, "albedoScaling", void 0), Object(c.c)([Bt("Link sheen with albedo", It.Boolean, "PROPERTIES", { notifiers: { update: !0 } })], t.prototype, "linkSheenWithAlbedo", void 0), t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.SheenBlock"] = rc;
+ var oc = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Fragment) || this;
+ return n._isUnique = !0, n.registerInput("intensity", le.Float, !0, Ce.Fragment), n.registerInput("direction", le.Vector2, !0, Ce.Fragment), n.registerInput("uv", le.Vector2, !0), n.registerInput("worldTangent", le.Vector4, !0), n.registerOutput("anisotropy", le.Object, Ce.Fragment, new Xn("anisotropy", n, yn.Output, t, "AnisotropyBlock")), n;
+ }
+ return Object(c.d)(t, r), t.prototype.initialize = function(e) {
+ e._excludeVariableName("anisotropicOut"), e._excludeVariableName("TBN");
+ }, t.prototype.getClassName = function() {
+ return "AnisotropyBlock";
+ }, Object.defineProperty(t.prototype, "intensity", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "direction", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "uv", { get: function() {
+ return this._inputs[2];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldTangent", { get: function() {
+ return this._inputs[3];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "anisotropy", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._generateTBNSpace = function(e) {
+ var n = "", i = "//" + this.name, o = this.uv, a = this.worldPositionConnectionPoint, s = this.worldNormalConnectionPoint, d = this.worldTangent;
+ o.isConnected || console.error("You must connect the 'uv' input of the Anisotropy block!"), e._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable");
+ var p = { search: /defined\(TANGENT\)/g, replace: d.isConnected ? "defined(TANGENT)" : "defined(IGNORE)" };
+ return d.isConnected && (n += "vec3 tbnNormal = normalize(" + s.associatedVariableName + `.xyz);\r
+`, n += "vec3 tbnTangent = normalize(" + d.associatedVariableName + `.xyz);\r
+`, n += `vec3 tbnBitangent = cross(tbnNormal, tbnTangent);\r
+`, n += `mat3 vTBN = mat3(tbnTangent, tbnBitangent, tbnNormal);\r
+`), n += `
+ #if defined(` + (d.isConnected ? "TANGENT" : "IGNORE") + `) && defined(NORMAL)
+ mat3 TBN = vTBN;
+ #else
+ mat3 TBN = cotangent_frame(` + s.associatedVariableName + ".xyz, v_" + a.associatedVariableName + ".xyz, " + (o.isConnected ? o.associatedVariableName : "vec2(0.)") + `, vec2(1., 1.));
+ #endif\r
+`, e._emitFunctionFromInclude("bumpFragmentMainFunctions", i, { replaceStrings: [p] }), n;
+ }, t.prototype.getCode = function(e, n) {
+ n === void 0 && (n = !1);
+ var i = "";
+ n && (i += this._generateTBNSpace(e));
+ var o = this.intensity.isConnected ? this.intensity.associatedVariableName : "1.0";
+ return i += `anisotropicOutParams anisotropicOut;
+ anisotropicBlock(
+ vec3(` + (this.direction.isConnected ? this.direction.associatedVariableName : "vec2(1., 0.)") + ", " + o + `),
+ #ifdef ANISOTROPIC_TEXTURE
+ vec3(0.),
+ #endif
+ TBN,
+ normalW,
+ viewDirectionW,
+ anisotropicOut
+ );\r
+`;
+ }, t.prototype.prepareDefines = function(e, n, i) {
+ r.prototype.prepareDefines.call(this, e, n, i), i.setValue("ANISOTROPIC", !0), i.setValue("ANISOTROPIC_TEXTURE", !1, !0);
+ }, t.prototype._buildBlock = function(e) {
+ return e.target === Ce.Fragment && e.sharedData.blocksWithDefines.push(this), this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.AnisotropyBlock"] = oc;
+ var ac = function(r) {
+ function t(e) {
+ var n = r.call(this, e) || this;
+ return n.useSphericalHarmonics = !0, n.forceIrradianceInFragment = !1, n._isUnique = !0, n.registerInput("position", le.Vector3, !1, Ce.Vertex), n.registerInput("world", le.Matrix, !1, Ce.Vertex), n.registerInput("color", le.Color3, !0, Ce.Fragment), n.registerOutput("reflection", le.Object, Ce.Fragment, new Xn("reflection", n, yn.Output, t, "ReflectionBlock")), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "ReflectionBlock";
+ }, Object.defineProperty(t.prototype, "position", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldPosition", { get: function() {
+ return this.worldPositionConnectionPoint;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldNormal", { get: function() {
+ return this.worldNormalConnectionPoint;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "world", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraPosition", { get: function() {
+ return this.cameraPositionConnectionPoint;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "view", { get: function() {
+ return this.viewConnectionPoint;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "color", { get: function() {
+ return this._inputs[2];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "reflection", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hasTexture", { get: function() {
+ return !!this._getTexture();
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "reflectionColor", { get: function() {
+ return this.color.isConnected ? this.color.associatedVariableName : "vec3(1., 1., 1.)";
+ }, enumerable: !1, configurable: !0 }), t.prototype._getTexture = function() {
+ return this.texture ? this.texture : this._scene.environmentTexture;
+ }, t.prototype.prepareDefines = function(e, n, i) {
+ r.prototype.prepareDefines.call(this, e, n, i);
+ var o = this._getTexture(), a = o && o.getTextureMatrix;
+ i.setValue("REFLECTION", a, !0), a && (i.setValue(this._defineLODReflectionAlpha, o.lodLevelInAlpha, !0), i.setValue(this._defineLinearSpecularReflection, o.linearSpecularLOD, !0), i.setValue(this._defineOppositeZ, this._scene.useRightHandedSystem ? !o.invertZ : o.invertZ, !0), i.setValue("SPHERICAL_HARMONICS", this.useSphericalHarmonics, !0), i.setValue("GAMMAREFLECTION", o.gammaSpace, !0), i.setValue("RGBDREFLECTION", o.isRGBD, !0), o && o.coordinatesMode !== Ne.a.SKYBOX_MODE && o.isCube && (i.setValue("USESPHERICALFROMREFLECTIONMAP", !0), i.setValue("USEIRRADIANCEMAP", !1), this.forceIrradianceInFragment || this._scene.getEngine().getCaps().maxVaryingVectors <= 8 ? i.setValue("USESPHERICALINVERTEX", !1) : i.setValue("USESPHERICALINVERTEX", !0)));
+ }, t.prototype.bind = function(e, n, i, o) {
+ r.prototype.bind.call(this, e, n, i);
+ var a = this._getTexture();
+ if (a && o) {
+ a.isCube ? e.setTexture(this._cubeSamplerName, a) : e.setTexture(this._2DSamplerName, a);
+ var s = a.getSize().width;
+ e.setFloat3(this._vReflectionMicrosurfaceInfosName, s, a.lodGenerationScale, a.lodGenerationOffset), e.setFloat2(this._vReflectionFilteringInfoName, s, $.a.Log2(s));
+ var d = o._materialDefines, p = a.sphericalPolynomial;
+ if (d.USESPHERICALFROMREFLECTIONMAP && p)
+ if (d.SPHERICAL_HARMONICS) {
+ var y = p.preScaledHarmonics;
+ e.setVector3("vSphericalL00", y.l00), e.setVector3("vSphericalL1_1", y.l1_1), e.setVector3("vSphericalL10", y.l10), e.setVector3("vSphericalL11", y.l11), e.setVector3("vSphericalL2_2", y.l2_2), e.setVector3("vSphericalL2_1", y.l2_1), e.setVector3("vSphericalL20", y.l20), e.setVector3("vSphericalL21", y.l21), e.setVector3("vSphericalL22", y.l22);
+ } else
+ e.setFloat3("vSphericalX", p.x.x, p.x.y, p.x.z), e.setFloat3("vSphericalY", p.y.x, p.y.y, p.y.z), e.setFloat3("vSphericalZ", p.z.x, p.z.y, p.z.z), e.setFloat3("vSphericalXX_ZZ", p.xx.x - p.zz.x, p.xx.y - p.zz.y, p.xx.z - p.zz.z), e.setFloat3("vSphericalYY_ZZ", p.yy.x - p.zz.x, p.yy.y - p.zz.y, p.yy.z - p.zz.z), e.setFloat3("vSphericalZZ", p.zz.x, p.zz.y, p.zz.z), e.setFloat3("vSphericalXY", p.xy.x, p.xy.y, p.xy.z), e.setFloat3("vSphericalYZ", p.yz.x, p.yz.y, p.yz.z), e.setFloat3("vSphericalZX", p.zx.x, p.zx.y, p.zx.z);
+ }
+ }, t.prototype.handleVertexSide = function(e) {
+ var n = r.prototype.handleVertexSide.call(this, e);
+ e._emitFunctionFromInclude("harmonicsFunctions", "//" + this.name, { replaceStrings: [{ search: /uniform vec3 vSphericalL00;[\s\S]*?uniform vec3 vSphericalL22;/g, replace: "" }, { search: /uniform vec3 vSphericalX;[\s\S]*?uniform vec3 vSphericalZX;/g, replace: "" }] });
+ var i = e._getFreeVariableName("reflectionVector");
+ return this._vEnvironmentIrradianceName = e._getFreeVariableName("vEnvironmentIrradiance"), e._emitVaryingFromString(this._vEnvironmentIrradianceName, "vec3", "defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)"), e._emitUniformFromString("vSphericalL00", "vec3", "SPHERICAL_HARMONICS"), e._emitUniformFromString("vSphericalL1_1", "vec3", "SPHERICAL_HARMONICS"), e._emitUniformFromString("vSphericalL10", "vec3", "SPHERICAL_HARMONICS"), e._emitUniformFromString("vSphericalL11", "vec3", "SPHERICAL_HARMONICS"), e._emitUniformFromString("vSphericalL2_2", "vec3", "SPHERICAL_HARMONICS"), e._emitUniformFromString("vSphericalL2_1", "vec3", "SPHERICAL_HARMONICS"), e._emitUniformFromString("vSphericalL20", "vec3", "SPHERICAL_HARMONICS"), e._emitUniformFromString("vSphericalL21", "vec3", "SPHERICAL_HARMONICS"), e._emitUniformFromString("vSphericalL22", "vec3", "SPHERICAL_HARMONICS"), e._emitUniformFromString("vSphericalX", "vec3", "SPHERICAL_HARMONICS", !0), e._emitUniformFromString("vSphericalY", "vec3", "SPHERICAL_HARMONICS", !0), e._emitUniformFromString("vSphericalZ", "vec3", "SPHERICAL_HARMONICS", !0), e._emitUniformFromString("vSphericalXX_ZZ", "vec3", "SPHERICAL_HARMONICS", !0), e._emitUniformFromString("vSphericalYY_ZZ", "vec3", "SPHERICAL_HARMONICS", !0), e._emitUniformFromString("vSphericalZZ", "vec3", "SPHERICAL_HARMONICS", !0), e._emitUniformFromString("vSphericalXY", "vec3", "SPHERICAL_HARMONICS", !0), e._emitUniformFromString("vSphericalYZ", "vec3", "SPHERICAL_HARMONICS", !0), e._emitUniformFromString("vSphericalZX", "vec3", "SPHERICAL_HARMONICS", !0), n += `#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
+ vec3 ` + i + " = vec3(" + this._reflectionMatrixName + " * vec4(normalize(" + this.worldNormal.associatedVariableName + `).xyz, 0)).xyz;
+ #ifdef ` + this._defineOppositeZ + `
+ ` + i + `.z *= -1.0;
+ #endif
+ ` + this._vEnvironmentIrradianceName + " = computeEnvironmentIrradiance(" + i + `);
+ #endif\r
+`;
+ }, t.prototype.getCode = function(e, n) {
+ var i = "";
+ this.handleFragmentSideInits(e), e._emitFunctionFromInclude("harmonicsFunctions", "//" + this.name, { replaceStrings: [{ search: /uniform vec3 vSphericalL00;[\s\S]*?uniform vec3 vSphericalL22;/g, replace: "" }, { search: /uniform vec3 vSphericalX;[\s\S]*?uniform vec3 vSphericalZX;/g, replace: "" }] }), e._emitFunction("sampleReflection", `
+ #ifdef ` + this._define3DName + `
+ #define sampleReflection(s, c) textureCube(s, c)
+ #else
+ #define sampleReflection(s, c) texture2D(s, c)
+ #endif\r
+`, "//" + this.name), e._emitFunction("sampleReflectionLod", `
+ #ifdef ` + this._define3DName + `
+ #define sampleReflectionLod(s, c, l) textureCubeLodEXT(s, c, l)
+ #else
+ #define sampleReflectionLod(s, c, l) texture2DLodEXT(s, c, l)
+ #endif\r
+`, "//" + this.name);
+ var o = `
+ vec3 computeReflectionCoordsPBR(vec4 worldPos, vec3 worldNormal) {
+ ` + this.handleFragmentSideCodeReflectionCoords("worldNormal", "worldPos", !0) + `
+ return ` + this._reflectionVectorName + `;
+ }\r
+`;
+ return e._emitFunction("computeReflectionCoordsPBR", o, "//" + this.name), this._vReflectionMicrosurfaceInfosName = e._getFreeVariableName("vReflectionMicrosurfaceInfos"), e._emitUniformFromString(this._vReflectionMicrosurfaceInfosName, "vec3"), this._vReflectionInfosName = e._getFreeVariableName("vReflectionInfos"), this._vReflectionFilteringInfoName = e._getFreeVariableName("vReflectionFilteringInfo"), e._emitUniformFromString(this._vReflectionFilteringInfoName, "vec2"), i += `#ifdef REFLECTION
+ vec2 ` + this._vReflectionInfosName + ` = vec2(1., 0.);
+
+ reflectionOutParams reflectionOut;
+
+ reflectionBlock(
+ v_` + this.worldPosition.associatedVariableName + `.xyz,
+ ` + n + `,
+ alphaG,
+ ` + this._vReflectionMicrosurfaceInfosName + `,
+ ` + this._vReflectionInfosName + `,
+ ` + this.reflectionColor + `,
+ #ifdef ANISOTROPIC
+ anisotropicOut,
+ #endif
+ #if defined(` + this._defineLODReflectionAlpha + ") && !defined(" + this._defineSkyboxName + `)
+ NdotVUnclamped,
+ #endif
+ #ifdef ` + this._defineLinearSpecularReflection + `
+ roughness,
+ #endif
+ #ifdef ` + this._define3DName + `
+ ` + this._cubeSamplerName + `,
+ #else
+ ` + this._2DSamplerName + `,
+ #endif
+ #if defined(NORMAL) && defined(USESPHERICALINVERTEX)
+ ` + this._vEnvironmentIrradianceName + `,
+ #endif
+ #ifdef USESPHERICALFROMREFLECTIONMAP
+ #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
+ ` + this._reflectionMatrixName + `,
+ #endif
+ #endif
+ #ifdef USEIRRADIANCEMAP
+ irradianceSampler, // ** not handled **
+ #endif
+ #ifndef LODBASEDMICROSFURACE
+ #ifdef ` + this._define3DName + `
+ ` + this._cubeSamplerName + `,
+ ` + this._cubeSamplerName + `,
+ #else
+ ` + this._2DSamplerName + `,
+ ` + this._2DSamplerName + `,
+ #endif
+ #endif
+ #ifdef REALTIME_FILTERING
+ ` + this._vReflectionFilteringInfoName + `,
+ #endif
+ reflectionOut
+ );
+ #endif\r
+`;
+ }, t.prototype._buildBlock = function(e) {
+ return this._scene = e.sharedData.scene, e.target !== Ce.Fragment && (this._defineLODReflectionAlpha = e._getFreeDefineName("LODINREFLECTIONALPHA"), this._defineLinearSpecularReflection = e._getFreeDefineName("LINEARSPECULARREFLECTION")), this;
+ }, t.prototype._dumpPropertiesCode = function() {
+ var e = r.prototype._dumpPropertiesCode.call(this);
+ return this.texture && (e += this._codeVariableName + ".texture.gammaSpace = " + this.texture.gammaSpace + `);\r
+`), e += this._codeVariableName + ".useSphericalHarmonics = " + this.useSphericalHarmonics + `;\r
+`, e += this._codeVariableName + ".forceIrradianceInFragment = " + this.forceIrradianceInFragment + `;\r
+`;
+ }, t.prototype.serialize = function() {
+ var e, n, i = r.prototype.serialize.call(this);
+ return i.useSphericalHarmonics = this.useSphericalHarmonics, i.forceIrradianceInFragment = this.forceIrradianceInFragment, i.gammaSpace = (n = (e = this.texture) === null || e === void 0 ? void 0 : e.gammaSpace) === null || n === void 0 || n, i;
+ }, t.prototype._deserialize = function(e, n, i) {
+ r.prototype._deserialize.call(this, e, n, i), this.useSphericalHarmonics = e.useSphericalHarmonics, this.forceIrradianceInFragment = e.forceIrradianceInFragment, this.texture && (this.texture.gammaSpace = e.gammaSpace);
+ }, Object(c.c)([Bt("Spherical Harmonics", It.Boolean, "ADVANCED", { notifiers: { update: !0 } })], t.prototype, "useSphericalHarmonics", void 0), Object(c.c)([Bt("Force irradiance in fragment", It.Boolean, "ADVANCED", { notifiers: { update: !0 } })], t.prototype, "forceIrradianceInFragment", void 0), t;
+ }(tc);
+ O.a.RegisteredTypes["BABYLON.ReflectionBlock"] = ac;
+ var la = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Fragment) || this;
+ return n.remapF0OnInterfaceChange = !0, n._isUnique = !0, n.registerInput("intensity", le.Float, !1, Ce.Fragment), n.registerInput("roughness", le.Float, !0, Ce.Fragment), n.registerInput("indexOfRefraction", le.Float, !0, Ce.Fragment), n.registerInput("normalMapColor", le.Color3, !0, Ce.Fragment), n.registerInput("uv", le.Vector2, !0, Ce.Fragment), n.registerInput("tintColor", le.Color3, !0, Ce.Fragment), n.registerInput("tintAtDistance", le.Float, !0, Ce.Fragment), n.registerInput("tintThickness", le.Float, !0, Ce.Fragment), n.registerInput("worldTangent", le.Vector4, !0), n.registerOutput("clearcoat", le.Object, Ce.Fragment, new Xn("clearcoat", n, yn.Output, t, "ClearCoatBlock")), n;
+ }
+ return Object(c.d)(t, r), t.prototype.initialize = function(e) {
+ e._excludeVariableName("clearcoatOut"), e._excludeVariableName("vClearCoatParams"), e._excludeVariableName("vClearCoatTintParams"), e._excludeVariableName("vClearCoatRefractionParams"), e._excludeVariableName("vClearCoatTangentSpaceParams");
+ }, t.prototype.getClassName = function() {
+ return "ClearCoatBlock";
+ }, Object.defineProperty(t.prototype, "intensity", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "roughness", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "indexOfRefraction", { get: function() {
+ return this._inputs[2];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "normalMapColor", { get: function() {
+ return this._inputs[3];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "uv", { get: function() {
+ return this._inputs[4];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "tintColor", { get: function() {
+ return this._inputs[5];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "tintAtDistance", { get: function() {
+ return this._inputs[6];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "tintThickness", { get: function() {
+ return this._inputs[7];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldTangent", { get: function() {
+ return this._inputs[8];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "clearcoat", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function(e) {
+ if (!this.intensity.isConnected) {
+ var n = new Et("ClearCoat intensity", Ce.Fragment, le.Float);
+ n.value = 1, n.output.connectTo(this.intensity);
+ }
+ }, t.prototype.prepareDefines = function(e, n, i) {
+ r.prototype.prepareDefines.call(this, e, n, i), i.setValue("CLEARCOAT", !0), i.setValue("CLEARCOAT_TEXTURE", !1, !0), i.setValue("CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE", !0, !0), i.setValue("CLEARCOAT_TINT", this.tintColor.isConnected || this.tintThickness.isConnected || this.tintAtDistance.isConnected, !0), i.setValue("CLEARCOAT_BUMP", this.normalMapColor.isConnected, !0), i.setValue("CLEARCOAT_DEFAULTIOR", !this.indexOfRefraction.isConnected || this.indexOfRefraction.connectInputBlock.value === mr._DefaultIndexOfRefraction, !0), i.setValue("CLEARCOAT_REMAP_F0", this.remapF0OnInterfaceChange, !0);
+ }, t.prototype.bind = function(e, n, i, o) {
+ var a, s;
+ r.prototype.bind.call(this, e, n, i);
+ var d = (s = (a = this.indexOfRefraction.connectInputBlock) === null || a === void 0 ? void 0 : a.value) !== null && s !== void 0 ? s : mr._DefaultIndexOfRefraction, p = 1 - d, y = 1 + d, P = Math.pow(-p / y, 2), R = 1 / d;
+ e.setFloat4("vClearCoatRefractionParams", P, R, p, y);
+ var B = this.clearcoat.hasEndpoints ? this.clearcoat.endpoints[0].ownerBlock : null, F = B != null && B.perturbedNormal.isConnected ? B.perturbedNormal.connectedPoint.ownerBlock : null;
+ this._scene._mirroredCameraPosition ? e.setFloat2("vClearCoatTangentSpaceParams", F != null && F.invertX ? 1 : -1, F != null && F.invertY ? 1 : -1) : e.setFloat2("vClearCoatTangentSpaceParams", F != null && F.invertX ? -1 : 1, F != null && F.invertY ? -1 : 1);
+ }, t.prototype._generateTBNSpace = function(e, n, i) {
+ var o = "", a = "//" + this.name, s = this.worldTangent;
+ e._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable");
+ var d = { search: /defined\(TANGENT\)/g, replace: s.isConnected ? "defined(TANGENT)" : "defined(IGNORE)" };
+ return s.isConnected && (o += "vec3 tbnNormal = normalize(" + i + `.xyz);\r
+`, o += "vec3 tbnTangent = normalize(" + s.associatedVariableName + `.xyz);\r
+`, o += `vec3 tbnBitangent = cross(tbnNormal, tbnTangent);\r
+`, o += `mat3 vTBN = mat3(tbnTangent, tbnBitangent, tbnNormal);\r
+`), e._emitFunctionFromInclude("bumpFragmentMainFunctions", a, { replaceStrings: [d] }), o;
+ }, t.GetCode = function(e, n, i, o, a, s, d) {
+ var p = "", y = n != null && n.intensity.isConnected ? n.intensity.associatedVariableName : "1.", P = n != null && n.roughness.isConnected ? n.roughness.associatedVariableName : "0.", R = n != null && n.normalMapColor.isConnected ? n.normalMapColor.associatedVariableName : "vec3(0.)", B = n != null && n.uv.isConnected ? n.uv.associatedVariableName : "vec2(0.)", F = n != null && n.tintColor.isConnected ? n.tintColor.associatedVariableName : "vec3(1.)", z = n != null && n.tintThickness.isConnected ? n.tintThickness.associatedVariableName : "1.", J = n != null && n.tintAtDistance.isConnected ? n.tintAtDistance.associatedVariableName : "1.";
+ return n && (e._emitUniformFromString("vClearCoatRefractionParams", "vec4"), e._emitUniformFromString("vClearCoatTangentSpaceParams", "vec2")), a && n && (p += n._generateTBNSpace(e, o, d), s = n.worldTangent.isConnected), p += `clearcoatOutParams clearcoatOut;
+
+ #ifdef CLEARCOAT
+ vec2 vClearCoatParams = vec2(` + y + ", " + P + `);
+ vec4 vClearCoatTintParams = vec4(` + F + ", " + z + `);
+
+ clearcoatBlock(
+ ` + o + `.xyz,
+ geometricNormalW,
+ viewDirectionW,
+ vClearCoatParams,
+ specularEnvironmentR0,
+ #ifdef CLEARCOAT_TEXTURE
+ vec2(0.),
+ #endif
+ #ifdef CLEARCOAT_TINT
+ vClearCoatTintParams,
+ ` + J + `,
+ vClearCoatRefractionParams,
+ #ifdef CLEARCOAT_TINT_TEXTURE
+ vec4(0.),
+ #endif
+ #endif
+ #ifdef CLEARCOAT_BUMP
+ vec2(0., 1.),
+ vec4(` + R + `, 0.),
+ ` + B + `,
+ #if defined(` + (s ? "TANGENT" : "IGNORE") + `) && defined(NORMAL)
+ vTBN,
+ #else
+ vClearCoatTangentSpaceParams,
+ #endif
+ #ifdef OBJECTSPACE_NORMALMAP
+ normalMatrix,
+ #endif
+ #endif
+ #if defined(FORCENORMALFORWARD) && defined(NORMAL)
+ faceNormal,
+ #endif
+ #ifdef REFLECTION
+ ` + (i == null ? void 0 : i._vReflectionMicrosurfaceInfosName) + `,
+ ` + (i == null ? void 0 : i._vReflectionInfosName) + `,
+ ` + (i == null ? void 0 : i.reflectionColor) + `,
+ vLightingIntensity,
+ #ifdef ` + (i == null ? void 0 : i._define3DName) + `
+ ` + (i == null ? void 0 : i._cubeSamplerName) + `,
+ #else
+ ` + (i == null ? void 0 : i._2DSamplerName) + `,
+ #endif
+ #ifndef LODBASEDMICROSFURACE
+ #ifdef ` + (i == null ? void 0 : i._define3DName) + `
+ ` + (i == null ? void 0 : i._cubeSamplerName) + `,
+ ` + (i == null ? void 0 : i._cubeSamplerName) + `,
+ #else
+ ` + (i == null ? void 0 : i._2DSamplerName) + `,
+ ` + (i == null ? void 0 : i._2DSamplerName) + `,
+ #endif
+ #endif
+ #endif
+ #if defined(ENVIRONMENTBRDF) && !defined(` + (i == null ? void 0 : i._defineSkyboxName) + `)
+ #ifdef RADIANCEOCCLUSION
+ ambientMonochrome,
+ #endif
+ #endif
+ clearcoatOut
+ );
+ #else
+ clearcoatOut.specularEnvironmentR0 = specularEnvironmentR0;
+ #endif\r
+`;
+ }, t.prototype._buildBlock = function(e) {
+ return this._scene = e.sharedData.scene, e.target === Ce.Fragment && (e.sharedData.bindableBlocks.push(this), e.sharedData.blocksWithDefines.push(this)), this;
+ }, t.prototype._dumpPropertiesCode = function() {
+ var e = "";
+ return e += this._codeVariableName + ".remapF0OnInterfaceChange = " + this.remapF0OnInterfaceChange + `;\r
+`;
+ }, t.prototype.serialize = function() {
+ var e = r.prototype.serialize.call(this);
+ return e.remapF0OnInterfaceChange = this.remapF0OnInterfaceChange, e;
+ }, t.prototype._deserialize = function(e, n, i) {
+ var o;
+ r.prototype._deserialize.call(this, e, n, i), this.remapF0OnInterfaceChange = (o = e.remapF0OnInterfaceChange) === null || o === void 0 || o;
+ }, Object(c.c)([Bt("Remap F0 on interface change", It.Boolean, "ADVANCED")], t.prototype, "remapF0OnInterfaceChange", void 0), t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.ClearCoatBlock"] = la;
+ var sc = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Fragment) || this;
+ return n.linkRefractionWithTransparency = !1, n.invertRefractionY = !1, n._isUnique = !0, n.registerInput("intensity", le.Float, !1, Ce.Fragment), n.registerInput("tintAtDistance", le.Float, !0, Ce.Fragment), n.registerOutput("refraction", le.Object, Ce.Fragment, new Xn("refraction", n, yn.Output, t, "RefractionBlock")), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "RefractionBlock";
+ }, Object.defineProperty(t.prototype, "intensity", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "tintAtDistance", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "view", { get: function() {
+ return this.viewConnectionPoint;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "refraction", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hasTexture", { get: function() {
+ return !!this._getTexture();
+ }, enumerable: !1, configurable: !0 }), t.prototype._getTexture = function() {
+ return this.texture ? this.texture : this._scene.environmentTexture;
+ }, t.prototype.autoConfigure = function(e) {
+ if (!this.intensity.isConnected) {
+ var n = new Et("Refraction intensity", Ce.Fragment, le.Float);
+ n.value = 1, n.output.connectTo(this.intensity);
+ }
+ if (this.view && !this.view.isConnected) {
+ var i = e.getInputBlockByPredicate(function(o) {
+ return o.systemValue === gt.View;
+ });
+ i || (i = new Et("view")).setAsSystemValue(gt.View), i.output.connectTo(this.view);
+ }
+ }, t.prototype.prepareDefines = function(e, n, i) {
+ r.prototype.prepareDefines.call(this, e, n, i);
+ var o = this._getTexture(), a = o && o.getTextureMatrix;
+ i.setValue("SS_REFRACTION", a, !0), a && (i.setValue(this._define3DName, o.isCube, !0), i.setValue(this._defineLODRefractionAlpha, o.lodLevelInAlpha, !0), i.setValue(this._defineLinearSpecularRefraction, o.linearSpecularLOD, !0), i.setValue(this._defineOppositeZ, this._scene.useRightHandedSystem ? !o.invertZ : o.invertZ, !0), i.setValue("SS_LINKREFRACTIONTOTRANSPARENCY", this.linkRefractionWithTransparency, !0), i.setValue("SS_GAMMAREFRACTION", o.gammaSpace, !0), i.setValue("SS_RGBDREFRACTION", o.isRGBD, !0));
+ }, t.prototype.isReady = function() {
+ var e = this._getTexture();
+ return !(e && !e.isReadyOrNotBlocking());
+ }, t.prototype.bind = function(e, n, i, o) {
+ var a, s;
+ r.prototype.bind.call(this, e, n, i);
+ var d = this._getTexture();
+ if (d) {
+ d.isCube ? e.setTexture(this._cubeSamplerName, d) : e.setTexture(this._2DSamplerName, d), e.setMatrix(this._refractionMatrixName, d.getReflectionTextureMatrix());
+ var p = 1;
+ d.isCube || d.depth && (p = d.depth);
+ var y = (s = (a = this.indexOfRefractionConnectionPoint.connectInputBlock) === null || a === void 0 ? void 0 : a.value) !== null && s !== void 0 ? s : 1.5;
+ e.setFloat4(this._vRefractionInfosName, d.level, 1 / y, p, this.invertRefractionY ? -1 : 1), e.setFloat3(this._vRefractionMicrosurfaceInfosName, d.getSize().width, d.lodGenerationScale, d.lodGenerationOffset);
+ var P = d.getSize().width;
+ e.setFloat2(this._vRefractionFilteringInfoName, P, $.a.Log2(P));
+ }
+ }, t.prototype.getCode = function(e) {
+ return e.sharedData.blockingBlocks.push(this), e.sharedData.textureBlocks.push(this), this._cubeSamplerName = e._getFreeVariableName(this.name + "CubeSampler"), e.samplers.push(this._cubeSamplerName), this._2DSamplerName = e._getFreeVariableName(this.name + "2DSampler"), e.samplers.push(this._2DSamplerName), this._define3DName = e._getFreeDefineName("SS_REFRACTIONMAP_3D"), e._samplerDeclaration += "#ifdef " + this._define3DName + `\r
+`, e._samplerDeclaration += "uniform samplerCube " + this._cubeSamplerName + `;\r
+`, e._samplerDeclaration += `#else\r
+`, e._samplerDeclaration += "uniform sampler2D " + this._2DSamplerName + `;\r
+`, e._samplerDeclaration += `#endif\r
+`, e.sharedData.blocksWithDefines.push(this), e.sharedData.bindableBlocks.push(this), this._defineLODRefractionAlpha = e._getFreeDefineName("SS_LODINREFRACTIONALPHA"), this._defineLinearSpecularRefraction = e._getFreeDefineName("SS_LINEARSPECULARREFRACTION"), this._defineOppositeZ = e._getFreeDefineName("SS_REFRACTIONMAP_OPPOSITEZ"), this._refractionMatrixName = e._getFreeVariableName("refractionMatrix"), e._emitUniformFromString(this._refractionMatrixName, "mat4"), e._emitFunction("sampleRefraction", `
+ #ifdef ` + this._define3DName + `
+ #define sampleRefraction(s, c) textureCube(s, c)
+ #else
+ #define sampleRefraction(s, c) texture2D(s, c)
+ #endif\r
+`, "//" + this.name), e._emitFunction("sampleRefractionLod", `
+ #ifdef ` + this._define3DName + `
+ #define sampleRefractionLod(s, c, l) textureCubeLodEXT(s, c, l)
+ #else
+ #define sampleRefractionLod(s, c, l) texture2DLodEXT(s, c, l)
+ #endif\r
+`, "//" + this.name), this._vRefractionMicrosurfaceInfosName = e._getFreeVariableName("vRefractionMicrosurfaceInfos"), e._emitUniformFromString(this._vRefractionMicrosurfaceInfosName, "vec3"), this._vRefractionInfosName = e._getFreeVariableName("vRefractionInfos"), e._emitUniformFromString(this._vRefractionInfosName, "vec4"), this._vRefractionFilteringInfoName = e._getFreeVariableName("vRefractionFilteringInfo"), e._emitUniformFromString(this._vRefractionFilteringInfoName, "vec2"), "";
+ }, t.prototype._buildBlock = function(e) {
+ return this._scene = e.sharedData.scene, this;
+ }, t.prototype._dumpPropertiesCode = function() {
+ var e = r.prototype._dumpPropertiesCode.call(this);
+ return this.texture && (e = this.texture.isCube ? this._codeVariableName + '.texture = new BABYLON.CubeTexture("' + this.texture.name + `");\r
+` : this._codeVariableName + '.texture = new BABYLON.Texture("' + this.texture.name + `");\r
+`, e += this._codeVariableName + ".texture.coordinatesMode = " + this.texture.coordinatesMode + `;\r
+`), e += this._codeVariableName + ".linkRefractionWithTransparency = " + this.linkRefractionWithTransparency + `;\r
+`, e += this._codeVariableName + ".invertRefractionY = " + this.invertRefractionY + `;\r
+`;
+ }, t.prototype.serialize = function() {
+ var e = r.prototype.serialize.call(this);
+ return this.texture && (e.texture = this.texture.serialize()), e.linkRefractionWithTransparency = this.linkRefractionWithTransparency, e.invertRefractionY = this.invertRefractionY, e;
+ }, t.prototype._deserialize = function(e, n, i) {
+ r.prototype._deserialize.call(this, e, n, i), e.texture && (i = e.texture.url.indexOf("data:") === 0 ? "" : i, e.texture.isCube ? this.texture = ei.Parse(e.texture, n, i) : this.texture = Ne.a.Parse(e.texture, n, i)), this.linkRefractionWithTransparency = e.linkRefractionWithTransparency, this.invertRefractionY = e.invertRefractionY;
+ }, Object(c.c)([Bt("Link refraction to transparency", It.Boolean, "ADVANCED", { notifiers: { update: !0 } })], t.prototype, "linkRefractionWithTransparency", void 0), Object(c.c)([Bt("Invert refraction Y", It.Boolean, "ADVANCED", { notifiers: { update: !0 } })], t.prototype, "invertRefractionY", void 0), t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.RefractionBlock"] = sc;
+ var ua = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Fragment) || this;
+ return n._isUnique = !0, n.registerInput("thickness", le.Float, !1, Ce.Fragment), n.registerInput("tintColor", le.Color3, !0, Ce.Fragment), n.registerInput("translucencyIntensity", le.Float, !0, Ce.Fragment), n.registerInput("translucencyDiffusionDist", le.Color3, !0, Ce.Fragment), n.registerInput("refraction", le.Object, !0, Ce.Fragment, new Xn("refraction", n, yn.Input, sc, "RefractionBlock")), n.registerOutput("subsurface", le.Object, Ce.Fragment, new Xn("subsurface", n, yn.Output, t, "SubSurfaceBlock")), n;
+ }
+ return Object(c.d)(t, r), t.prototype.initialize = function(e) {
+ e._excludeVariableName("subSurfaceOut"), e._excludeVariableName("vThicknessParam"), e._excludeVariableName("vTintColor"), e._excludeVariableName("vSubSurfaceIntensity");
+ }, t.prototype.getClassName = function() {
+ return "SubSurfaceBlock";
+ }, Object.defineProperty(t.prototype, "thickness", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "tintColor", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "translucencyIntensity", { get: function() {
+ return this._inputs[2];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "translucencyDiffusionDist", { get: function() {
+ return this._inputs[3];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "refraction", { get: function() {
+ return this._inputs[4];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "subsurface", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function(e) {
+ if (!this.thickness.isConnected) {
+ var n = new Et("SubSurface thickness", Ce.Fragment, le.Float);
+ n.value = 0, n.output.connectTo(this.thickness);
+ }
+ }, t.prototype.prepareDefines = function(e, n, i) {
+ r.prototype.prepareDefines.call(this, e, n, i);
+ var o = this.translucencyDiffusionDist.isConnected || this.translucencyIntensity.isConnected;
+ i.setValue("SUBSURFACE", o || this.refraction.isConnected, !0), i.setValue("SS_TRANSLUCENCY", o, !0), i.setValue("SS_THICKNESSANDMASK_TEXTURE", !1, !0), i.setValue("SS_MASK_FROM_THICKNESS_TEXTURE", !1, !0), i.setValue("SS_MASK_FROM_THICKNESS_TEXTURE_GLTF", !1, !0);
+ }, t.GetCode = function(e, n, i, o) {
+ var a, s, d, p, y, P, R, B, F, z, J, ie, se, ce, ue, fe, ve = "", Te = n != null && n.thickness.isConnected ? n.thickness.associatedVariableName : "0.", Re = n != null && n.tintColor.isConnected ? n.tintColor.associatedVariableName : "vec3(1.)", Ae = n != null && n.translucencyIntensity.isConnected ? n == null ? void 0 : n.translucencyIntensity.associatedVariableName : "1.", Ee = n != null && n.translucencyDiffusionDist.isConnected ? n == null ? void 0 : n.translucencyDiffusionDist.associatedVariableName : "vec3(1.)", Se = n != null && n.refraction.isConnected ? (a = n == null ? void 0 : n.refraction.connectedPoint) === null || a === void 0 ? void 0 : a.ownerBlock : null, De = Se != null && Se.tintAtDistance.isConnected ? Se.tintAtDistance.associatedVariableName : "1.", xe = Se != null && Se.intensity.isConnected ? Se.intensity.associatedVariableName : "1.", Le = Se != null && Se.view.isConnected ? Se.view.associatedVariableName : "";
+ return ve += (s = Se == null ? void 0 : Se.getCode(e)) !== null && s !== void 0 ? s : "", ve += `subSurfaceOutParams subSurfaceOut;
+
+ #ifdef SUBSURFACE
+ vec2 vThicknessParam = vec2(0., ` + Te + `);
+ vec4 vTintColor = vec4(` + Re + ", " + De + `);
+ vec3 vSubSurfaceIntensity = vec3(` + xe + ", " + Ae + `, 0.);
+
+ subSurfaceBlock(
+ vSubSurfaceIntensity,
+ vThicknessParam,
+ vTintColor,
+ normalW,
+ specularEnvironmentReflectance,
+ #ifdef SS_THICKNESSANDMASK_TEXTURE
+ vec4(0.),
+ #endif
+ #ifdef REFLECTION
+ #ifdef SS_TRANSLUCENCY
+ ` + (i == null ? void 0 : i._reflectionMatrixName) + `,
+ #ifdef USESPHERICALFROMREFLECTIONMAP
+ #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
+ reflectionOut.irradianceVector,
+ #endif
+ #if defined(REALTIME_FILTERING)
+ ` + (i == null ? void 0 : i._cubeSamplerName) + `,
+ ` + (i == null ? void 0 : i._vReflectionFilteringInfoName) + `,
+ #endif
+ #endif
+ #ifdef USEIRRADIANCEMAP
+ irradianceSampler,
+ #endif
+ #endif
+ #endif
+ #ifdef SS_REFRACTION
+ ` + o + `.xyz,
+ viewDirectionW,
+ ` + Le + `,
+ surfaceAlbedo,
+ ` + ((d = Se == null ? void 0 : Se._vRefractionInfosName) !== null && d !== void 0 ? d : "") + `,
+ ` + ((p = Se == null ? void 0 : Se._refractionMatrixName) !== null && p !== void 0 ? p : "") + `,
+ ` + ((y = Se == null ? void 0 : Se._vRefractionMicrosurfaceInfosName) !== null && y !== void 0 ? y : "") + `,
+ vLightingIntensity,
+ #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
+ alpha,
+ #endif
+ #ifdef ` + ((P = Se == null ? void 0 : Se._defineLODRefractionAlpha) !== null && P !== void 0 ? P : "IGNORE") + `
+ NdotVUnclamped,
+ #endif
+ #ifdef ` + ((R = Se == null ? void 0 : Se._defineLinearSpecularRefraction) !== null && R !== void 0 ? R : "IGNORE") + `
+ roughness,
+ #else
+ alphaG,
+ #endif
+ #ifdef ` + ((B = Se == null ? void 0 : Se._define3DName) !== null && B !== void 0 ? B : "IGNORE") + `
+ ` + ((F = Se == null ? void 0 : Se._cubeSamplerName) !== null && F !== void 0 ? F : "") + `,
+ #else
+ ` + ((z = Se == null ? void 0 : Se._2DSamplerName) !== null && z !== void 0 ? z : "") + `,
+ #endif
+ #ifndef LODBASEDMICROSFURACE
+ #ifdef ` + ((J = Se == null ? void 0 : Se._define3DName) !== null && J !== void 0 ? J : "IGNORE") + `
+ ` + ((ie = Se == null ? void 0 : Se._cubeSamplerName) !== null && ie !== void 0 ? ie : "") + `,
+ ` + ((se = Se == null ? void 0 : Se._cubeSamplerName) !== null && se !== void 0 ? se : "") + `,
+ #else
+ ` + ((ce = Se == null ? void 0 : Se._2DSamplerName) !== null && ce !== void 0 ? ce : "") + `,
+ ` + ((ue = Se == null ? void 0 : Se._2DSamplerName) !== null && ue !== void 0 ? ue : "") + `,
+ #endif
+ #endif
+ #ifdef ANISOTROPIC
+ anisotropicOut,
+ #endif
+ #ifdef REALTIME_FILTERING
+ ` + ((fe = Se == null ? void 0 : Se._vRefractionFilteringInfoName) !== null && fe !== void 0 ? fe : "") + `,
+ #endif
+ #endif
+ #ifdef SS_TRANSLUCENCY
+ ` + Ee + `,
+ #endif
+ subSurfaceOut
+ );
+
+ #ifdef SS_REFRACTION
+ surfaceAlbedo = subSurfaceOut.surfaceAlbedo;
+ #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
+ alpha = subSurfaceOut.alpha;
+ #endif
+ #endif
+ #else
+ subSurfaceOut.specularEnvironmentReflectance = specularEnvironmentReflectance;
+ #endif\r
+`;
+ }, t.prototype._buildBlock = function(e) {
+ return e.target === Ce.Fragment && e.sharedData.blocksWithDefines.push(this), this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.SubSurfaceBlock"] = ua;
+ var j_ = { ambientClr: ["finalAmbient", ""], diffuseDir: ["finalDiffuse", ""], specularDir: ["finalSpecularScaled", "!defined(UNLIT) && defined(SPECULARTERM)"], clearcoatDir: ["finalClearCoatScaled", "!defined(UNLIT) && defined(CLEARCOAT)"], sheenDir: ["finalSheenScaled", "!defined(UNLIT) && defined(SHEEN)"], diffuseInd: ["finalIrradiance", "!defined(UNLIT) && defined(REFLECTION)"], specularInd: ["finalRadianceScaled", "!defined(UNLIT) && defined(REFLECTION)"], clearcoatInd: ["clearcoatOut.finalClearCoatRadianceScaled", "!defined(UNLIT) && defined(REFLECTION) && defined(CLEARCOAT)"], sheenInd: ["sheenOut.finalSheenRadianceScaled", "!defined(UNLIT) && defined(REFLECTION) && defined(SHEEN) && defined(ENVIRONMENTBRDF)"], refraction: ["subSurfaceOut.finalRefraction", "!defined(UNLIT) && defined(SS_REFRACTION)"], lighting: ["finalColor.rgb", ""], shadow: ["shadow", ""], alpha: ["alpha", ""] }, Xh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.VertexAndFragment) || this;
+ return n._environmentBRDFTexture = null, n._metallicReflectanceColor = I.a.White(), n._metallicF0Factor = 1, n.directIntensity = 1, n.environmentIntensity = 1, n.specularIntensity = 1, n.lightFalloff = 0, n.useAlphaTest = !1, n.alphaTestCutoff = 0.5, n.useAlphaBlending = !1, n.useRadianceOverAlpha = !0, n.useSpecularOverAlpha = !0, n.enableSpecularAntiAliasing = !1, n.realTimeFiltering = !1, n.realTimeFilteringQuality = h.a.TEXTURE_FILTERING_QUALITY_LOW, n.useEnergyConservation = !0, n.useRadianceOcclusion = !0, n.useHorizonOcclusion = !0, n.unlit = !1, n.forceNormalForward = !1, n.debugMode = 0, n.debugLimit = 0, n.debugFactor = 1, n._isUnique = !0, n.registerInput("worldPosition", le.Vector4, !1, Ce.Vertex), n.registerInput("worldNormal", le.Vector4, !1, Ce.Fragment), n.registerInput("view", le.Matrix, !1), n.registerInput("cameraPosition", le.Vector3, !1, Ce.Fragment), n.registerInput("perturbedNormal", le.Vector4, !0, Ce.Fragment), n.registerInput("baseColor", le.Color3, !0, Ce.Fragment), n.registerInput("metallic", le.Float, !1, Ce.Fragment), n.registerInput("roughness", le.Float, !1, Ce.Fragment), n.registerInput("ambientOcc", le.Float, !0, Ce.Fragment), n.registerInput("opacity", le.Float, !0, Ce.Fragment), n.registerInput("indexOfRefraction", le.Float, !0, Ce.Fragment), n.registerInput("ambientColor", le.Color3, !0, Ce.Fragment), n.registerInput("reflection", le.Object, !0, Ce.Fragment, new Xn("reflection", n, yn.Input, ac, "ReflectionBlock")), n.registerInput("clearcoat", le.Object, !0, Ce.Fragment, new Xn("clearcoat", n, yn.Input, la, "ClearCoatBlock")), n.registerInput("sheen", le.Object, !0, Ce.Fragment, new Xn("sheen", n, yn.Input, rc, "SheenBlock")), n.registerInput("subsurface", le.Object, !0, Ce.Fragment, new Xn("subsurface", n, yn.Input, ua, "SubSurfaceBlock")), n.registerInput("anisotropy", le.Object, !0, Ce.Fragment, new Xn("anisotropy", n, yn.Input, oc, "AnisotropyBlock")), n.registerOutput("ambientClr", le.Color3, Ce.Fragment), n.registerOutput("diffuseDir", le.Color3, Ce.Fragment), n.registerOutput("specularDir", le.Color3, Ce.Fragment), n.registerOutput("clearcoatDir", le.Color3, Ce.Fragment), n.registerOutput("sheenDir", le.Color3, Ce.Fragment), n.registerOutput("diffuseInd", le.Color3, Ce.Fragment), n.registerOutput("specularInd", le.Color3, Ce.Fragment), n.registerOutput("clearcoatInd", le.Color3, Ce.Fragment), n.registerOutput("sheenInd", le.Color3, Ce.Fragment), n.registerOutput("refraction", le.Color3, Ce.Fragment), n.registerOutput("lighting", le.Color3, Ce.Fragment), n.registerOutput("shadow", le.Float, Ce.Fragment), n.registerOutput("alpha", le.Float, Ce.Fragment), n;
+ }
+ return Object(c.d)(t, r), t.prototype.initialize = function(e) {
+ e._excludeVariableName("vLightingIntensity"), e._excludeVariableName("geometricNormalW"), e._excludeVariableName("normalW"), e._excludeVariableName("faceNormal"), e._excludeVariableName("albedoOpacityOut"), e._excludeVariableName("surfaceAlbedo"), e._excludeVariableName("alpha"), e._excludeVariableName("aoOut"), e._excludeVariableName("baseColor"), e._excludeVariableName("reflectivityOut"), e._excludeVariableName("microSurface"), e._excludeVariableName("roughness"), e._excludeVariableName("NdotVUnclamped"), e._excludeVariableName("NdotV"), e._excludeVariableName("alphaG"), e._excludeVariableName("AARoughnessFactors"), e._excludeVariableName("environmentBrdf"), e._excludeVariableName("ambientMonochrome"), e._excludeVariableName("seo"), e._excludeVariableName("eho"), e._excludeVariableName("environmentRadiance"), e._excludeVariableName("irradianceVector"), e._excludeVariableName("environmentIrradiance"), e._excludeVariableName("diffuseBase"), e._excludeVariableName("specularBase"), e._excludeVariableName("preInfo"), e._excludeVariableName("info"), e._excludeVariableName("shadow"), e._excludeVariableName("finalDiffuse"), e._excludeVariableName("finalAmbient"), e._excludeVariableName("ambientOcclusionForDirectDiffuse"), e._excludeVariableName("finalColor"), e._excludeVariableName("vClipSpacePosition"), e._excludeVariableName("vDebugMode");
+ }, t.prototype.getClassName = function() {
+ return "PBRMetallicRoughnessBlock";
+ }, Object.defineProperty(t.prototype, "worldPosition", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "worldNormal", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "view", { get: function() {
+ return this._inputs[2];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "cameraPosition", { get: function() {
+ return this._inputs[3];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "perturbedNormal", { get: function() {
+ return this._inputs[4];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "baseColor", { get: function() {
+ return this._inputs[5];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "metallic", { get: function() {
+ return this._inputs[6];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "roughness", { get: function() {
+ return this._inputs[7];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "ambientOcc", { get: function() {
+ return this._inputs[8];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "opacity", { get: function() {
+ return this._inputs[9];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "indexOfRefraction", { get: function() {
+ return this._inputs[10];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "ambientColor", { get: function() {
+ return this._inputs[11];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "reflection", { get: function() {
+ return this._inputs[12];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "clearcoat", { get: function() {
+ return this._inputs[13];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "sheen", { get: function() {
+ return this._inputs[14];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "subsurface", { get: function() {
+ return this._inputs[15];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "anisotropy", { get: function() {
+ return this._inputs[16];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "ambientClr", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "diffuseDir", { get: function() {
+ return this._outputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "specularDir", { get: function() {
+ return this._outputs[2];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "clearcoatDir", { get: function() {
+ return this._outputs[3];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "sheenDir", { get: function() {
+ return this._outputs[4];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "diffuseIndirect", { get: function() {
+ return this._outputs[5];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "specularIndirect", { get: function() {
+ return this._outputs[6];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "clearcoatIndirect", { get: function() {
+ return this._outputs[7];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "sheenIndirect", { get: function() {
+ return this._outputs[8];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "refraction", { get: function() {
+ return this._outputs[9];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "lighting", { get: function() {
+ return this._outputs[10];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "shadow", { get: function() {
+ return this._outputs[11];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "alpha", { get: function() {
+ return this._outputs[12];
+ }, enumerable: !1, configurable: !0 }), t.prototype.autoConfigure = function(e) {
+ if (!this.cameraPosition.isConnected) {
+ var n = e.getInputBlockByPredicate(function(o) {
+ return o.systemValue === gt.CameraPosition;
+ });
+ n || (n = new Et("cameraPosition")).setAsSystemValue(gt.CameraPosition), n.output.connectTo(this.cameraPosition);
+ }
+ if (!this.view.isConnected) {
+ var i = e.getInputBlockByPredicate(function(o) {
+ return o.systemValue === gt.View;
+ });
+ i || (i = new Et("view")).setAsSystemValue(gt.View), i.output.connectTo(this.view);
+ }
+ }, t.prototype.prepareDefines = function(e, n, i) {
+ i.setValue("PBR", !0), i.setValue("METALLICWORKFLOW", !0), i.setValue("DEBUGMODE", this.debugMode, !0), i.setValue("NORMALXYSCALE", !0), i.setValue("BUMP", this.perturbedNormal.isConnected, !0), i.setValue("LODBASEDMICROSFURACE", this._scene.getEngine().getCaps().textureLOD), i.setValue("ALBEDO", !1, !0), i.setValue("OPACITY", this.opacity.isConnected, !0), i.setValue("AMBIENT", !0, !0), i.setValue("AMBIENTINGRAYSCALE", !1, !0), i.setValue("REFLECTIVITY", !1, !0), i.setValue("AOSTOREINMETALMAPRED", !1, !0), i.setValue("METALLNESSSTOREINMETALMAPBLUE", !1, !0), i.setValue("ROUGHNESSSTOREINMETALMAPALPHA", !1, !0), i.setValue("ROUGHNESSSTOREINMETALMAPGREEN", !1, !0), this.lightFalloff === pn.LIGHTFALLOFF_STANDARD ? (i.setValue("USEPHYSICALLIGHTFALLOFF", !1), i.setValue("USEGLTFLIGHTFALLOFF", !1)) : this.lightFalloff === pn.LIGHTFALLOFF_GLTF ? (i.setValue("USEPHYSICALLIGHTFALLOFF", !1), i.setValue("USEGLTFLIGHTFALLOFF", !0)) : (i.setValue("USEPHYSICALLIGHTFALLOFF", !0), i.setValue("USEGLTFLIGHTFALLOFF", !1));
+ var o = this.alphaTestCutoff.toString();
+ if (i.setValue("ALPHABLEND", this.useAlphaBlending, !0), i.setValue("ALPHAFROMALBEDO", !1, !0), i.setValue("ALPHATEST", this.useAlphaTest, !0), i.setValue("ALPHATESTVALUE", o.indexOf(".") < 0 ? o + "." : o, !0), i.setValue("OPACITYRGB", !1, !0), i.setValue("RADIANCEOVERALPHA", this.useRadianceOverAlpha, !0), i.setValue("SPECULAROVERALPHA", this.useSpecularOverAlpha, !0), i.setValue("SPECULARAA", this._scene.getEngine().getCaps().standardDerivatives && this.enableSpecularAntiAliasing, !0), i.setValue("REALTIME_FILTERING", this.realTimeFiltering, !0), this._scene.getEngine().webGLVersion > 1 ? i.setValue("NUM_SAMPLES", this.realTimeFilteringQuality + "u", !0) : i.setValue("NUM_SAMPLES", "" + this.realTimeFilteringQuality, !0), i.setValue("BRDF_V_HEIGHT_CORRELATED", !0), i.setValue("MS_BRDF_ENERGY_CONSERVATION", this.useEnergyConservation, !0), i.setValue("RADIANCEOCCLUSION", this.useRadianceOcclusion, !0), i.setValue("HORIZONOCCLUSION", this.useHorizonOcclusion, !0), i.setValue("UNLIT", this.unlit, !0), i.setValue("FORCENORMALFORWARD", this.forceNormalForward, !0), this._environmentBRDFTexture && lt.a.ReflectionTextureEnabled ? (i.setValue("ENVIRONMENTBRDF", !0), i.setValue("ENVIRONMENTBRDF_RGBD", this._environmentBRDFTexture.isRGBD, !0)) : (i.setValue("ENVIRONMENTBRDF", !1), i.setValue("ENVIRONMENTBRDF_RGBD", !1)), i._areLightsDirty) {
+ var a = e.getScene();
+ if (this.light) {
+ var s = { needNormals: !1, needRebuild: !1, lightmapMode: !1, shadowEnabled: !1, specularEnabled: !1 };
+ $e.a.PrepareDefinesForLight(a, e, this.light, this._lightId, i, !0, s), s.needRebuild && i.rebuild();
+ } else
+ $e.a.PrepareDefinesForLights(a, e, i, !0, n.maxSimultaneousLights), i._needNormals = !0, $e.a.PrepareDefinesForMultiview(a, i);
+ }
+ }, t.prototype.updateUniformsAndSamples = function(e, n, i, o) {
+ for (var a = 0; a < n.maxSimultaneousLights && i["LIGHT" + a]; a++) {
+ var s = e.uniforms.indexOf("vLightData" + a) >= 0;
+ $e.a.PrepareUniformsAndSamplersForLight(a, e.uniforms, e.samplers, i["PROJECTEDLIGHTTEXTURE" + a], o, s);
+ }
+ }, t.prototype.bind = function(e, n, i) {
+ var o, a;
+ if (i) {
+ var s = i.getScene();
+ this.light ? $e.a.BindLight(this.light, this._lightId, s, e, !0) : $e.a.BindLights(s, i, e, !0, n.maxSimultaneousLights), e.setTexture(this._environmentBrdfSamplerName, this._environmentBRDFTexture), e.setFloat2("vDebugMode", this.debugLimit, this.debugFactor);
+ var d = this._scene.ambientColor;
+ d && e.setColor3("ambientFromScene", d);
+ var p = s.useRightHandedSystem === (s._mirroredCameraPosition != null);
+ e.setFloat(this._invertNormalName, p ? -1 : 1), e.setFloat4("vLightingIntensity", this.directIntensity, 1, this.environmentIntensity * this._scene.environmentIntensity, this.specularIntensity);
+ var y = (a = (o = this.indexOfRefraction.connectInputBlock) === null || o === void 0 ? void 0 : o.value) !== null && a !== void 0 ? a : 1.5, P = Math.pow((y - 1) / (y + 1), 2);
+ this._metallicReflectanceColor.scaleToRef(P * this._metallicF0Factor, I.c.Color3[0]);
+ var R = this._metallicF0Factor;
+ e.setColor4(this._vMetallicReflectanceFactorsName, I.c.Color3[0], R);
+ }
+ }, t.prototype._injectVertexCode = function(e) {
+ var n, i, o = this.worldPosition, a = "//" + this.name;
+ this.light ? (this._lightId = (e.counters.lightCounter !== void 0 ? e.counters.lightCounter : -1) + 1, e.counters.lightCounter = this._lightId, e._emitFunctionFromInclude(e.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", a, { replaceStrings: [{ search: /{X}/g, replace: this._lightId.toString() }] }, this._lightId.toString())) : (e._emitFunctionFromInclude(e.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", a, { repeatKey: "maxSimultaneousLights" }), this._lightId = 0, e.sharedData.dynamicUniformBlocks.push(this));
+ var s = "v_" + o.associatedVariableName;
+ e._emitVaryingFromString(s, "vec4") && (e.compilationString += s + " = " + o.associatedVariableName + `;\r
+`);
+ var d = this.reflection.isConnected ? (n = this.reflection.connectedPoint) === null || n === void 0 ? void 0 : n.ownerBlock : null;
+ d && (d.viewConnectionPoint = this.view), e.compilationString += (i = d == null ? void 0 : d.handleVertexSide(e)) !== null && i !== void 0 ? i : "", e._emitUniformFromString("vDebugMode", "vec2", "defined(IGNORE) || DEBUGMODE > 0"), e._emitUniformFromString("ambientFromScene", "vec3"), e._emitVaryingFromString("vClipSpacePosition", "vec4", "defined(IGNORE) || DEBUGMODE > 0") && (e._injectAtEnd += `#if DEBUGMODE > 0\r
+`, e._injectAtEnd += `vClipSpacePosition = gl_Position;\r
+`, e._injectAtEnd += `#endif\r
+`), this.light ? e.compilationString += e._emitCodeFromInclude("shadowsVertex", a, { replaceStrings: [{ search: /{X}/g, replace: this._lightId.toString() }, { search: /worldPos/g, replace: o.associatedVariableName }] }) : (e.compilationString += "vec4 worldPos = " + o.associatedVariableName + `;\r
+`, this.view.isConnected && (e.compilationString += "mat4 view = " + this.view.associatedVariableName + `;\r
+`), e.compilationString += e._emitCodeFromInclude("shadowsVertex", a, { repeatKey: "maxSimultaneousLights" }));
+ }, t.prototype._getAlbedoOpacityCode = function() {
+ var e = `albedoOpacityOutParams albedoOpacityOut;\r
+`;
+ return e += `albedoOpacityBlock(
+ vec4(` + (this.baseColor.isConnected ? this.baseColor.associatedVariableName : "vec3(1.)") + `, 1.),
+ #ifdef ALBEDO
+ vec4(1.),
+ vec2(1., 1.),
+ #endif
+ #ifdef OPACITY
+ vec4(` + (this.opacity.isConnected ? this.opacity.associatedVariableName : "1.") + `),
+ vec2(1., 1.),
+ #endif
+ albedoOpacityOut
+ );
+
+ vec3 surfaceAlbedo = albedoOpacityOut.surfaceAlbedo;
+ float alpha = albedoOpacityOut.alpha;\r
+`;
+ }, t.prototype._getAmbientOcclusionCode = function() {
+ var e = `ambientOcclusionOutParams aoOut;\r
+`;
+ return e += `ambientOcclusionBlock(
+ #ifdef AMBIENT
+ vec3(` + (this.ambientOcc.isConnected ? this.ambientOcc.associatedVariableName : "1.") + `),
+ vec4(0., 1.0, 1.0, 0.),
+ #endif
+ aoOut
+ );\r
+`;
+ }, t.prototype._getReflectivityCode = function(e) {
+ var n = `reflectivityOutParams reflectivityOut;\r
+`;
+ return this._vMetallicReflectanceFactorsName = e._getFreeVariableName("vMetallicReflectanceFactors"), e._emitUniformFromString(this._vMetallicReflectanceFactorsName, "vec4"), n += `vec3 baseColor = surfaceAlbedo;
+
+ reflectivityBlock(
+ vec4(` + this.metallic.associatedVariableName + ", " + this.roughness.associatedVariableName + `, 0., 0.),
+ #ifdef METALLICWORKFLOW
+ surfaceAlbedo,
+ ` + this._vMetallicReflectanceFactorsName + `,
+ #endif
+ #ifdef REFLECTIVITY
+ vec3(0., 0., 1.),
+ vec4(1.),
+ #endif
+ #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
+ aoOut.ambientOcclusionColor,
+ #endif
+ #ifdef MICROSURFACEMAP
+ microSurfaceTexel, <== not handled!
+ #endif
+ reflectivityOut
+ );
+
+ float microSurface = reflectivityOut.microSurface;
+ float roughness = reflectivityOut.roughness;
+
+ #ifdef METALLICWORKFLOW
+ surfaceAlbedo = reflectivityOut.surfaceAlbedo;
+ #endif
+ #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
+ aoOut.ambientOcclusionColor = reflectivityOut.ambientOcclusionColor;
+ #endif\r
+`;
+ }, t.prototype._buildBlock = function(e) {
+ var n, i, o, a, s, d, p, y, P, R, B, F, z, J, ie, se, ce, ue, fe, ve, Te, Re, Ae, Ee, Se, De, xe, Le, Me, we, Ye, et, nt, ct, Ke, rt, it, qe, ut;
+ r.prototype._buildBlock.call(this, e), this._scene = e.sharedData.scene, this._environmentBRDFTexture || (this._environmentBRDFTexture = Ho.GetEnvironmentBRDFTexture(this._scene));
+ var Ve = this.reflection.isConnected ? (n = this.reflection.connectedPoint) === null || n === void 0 ? void 0 : n.ownerBlock : null;
+ if (Ve && (Ve.worldPositionConnectionPoint = this.worldPosition, Ve.cameraPositionConnectionPoint = this.cameraPosition, Ve.worldNormalConnectionPoint = this.worldNormal), e.target !== Ce.Fragment)
+ return this._injectVertexCode(e), this;
+ e.sharedData.bindableBlocks.push(this), e.sharedData.blocksWithDefines.push(this);
+ var Ze = "//" + this.name, vt = "v_" + this.worldPosition.associatedVariableName, jt = this.perturbedNormal;
+ this._environmentBrdfSamplerName = e._getFreeVariableName("environmentBrdfSampler"), e._emit2DSampler(this._environmentBrdfSamplerName), e.sharedData.hints.needAlphaBlending = e.sharedData.hints.needAlphaBlending || this.useAlphaBlending, e.sharedData.hints.needAlphaTesting = e.sharedData.hints.needAlphaTesting || this.useAlphaTest, e._emitExtension("lod", "#extension GL_EXT_shader_texture_lod : enable", "defined(LODBASEDMICROSFURACE)"), e._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable"), this.light ? e._emitFunctionFromInclude(e.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", Ze, { replaceStrings: [{ search: /{X}/g, replace: this._lightId.toString() }] }, this._lightId.toString()) : e._emitFunctionFromInclude(e.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", Ze, { repeatKey: "maxSimultaneousLights" }), e._emitFunctionFromInclude("helperFunctions", Ze), e._emitFunctionFromInclude("importanceSampling", Ze), e._emitFunctionFromInclude("pbrHelperFunctions", Ze), e._emitFunctionFromInclude("imageProcessingFunctions", Ze), e._emitFunctionFromInclude("shadowsFragmentFunctions", Ze, { replaceStrings: [{ search: /vPositionW/g, replace: vt + ".xyz" }] }), e._emitFunctionFromInclude("pbrDirectLightingSetupFunctions", Ze, { replaceStrings: [{ search: /vPositionW/g, replace: vt + ".xyz" }] }), e._emitFunctionFromInclude("pbrDirectLightingFalloffFunctions", Ze), e._emitFunctionFromInclude("pbrBRDFFunctions", Ze, { replaceStrings: [{ search: /REFLECTIONMAP_SKYBOX/g, replace: (i = Ve == null ? void 0 : Ve._defineSkyboxName) !== null && i !== void 0 ? i : "REFLECTIONMAP_SKYBOX" }] }), e._emitFunctionFromInclude("hdrFilteringFunctions", Ze), e._emitFunctionFromInclude("pbrDirectLightingFunctions", Ze, { replaceStrings: [{ search: /vPositionW/g, replace: vt + ".xyz" }] }), e._emitFunctionFromInclude("pbrIBLFunctions", Ze), e._emitFunctionFromInclude("pbrBlockAlbedoOpacity", Ze), e._emitFunctionFromInclude("pbrBlockReflectivity", Ze), e._emitFunctionFromInclude("pbrBlockAmbientOcclusion", Ze), e._emitFunctionFromInclude("pbrBlockAlphaFresnel", Ze), e._emitFunctionFromInclude("pbrBlockAnisotropic", Ze), e._emitUniformFromString("vLightingIntensity", "vec4"), this._vNormalWName = e._getFreeVariableName("vNormalW"), e.compilationString += "vec4 " + this._vNormalWName + " = normalize(" + this.worldNormal.associatedVariableName + `);\r
+`, e._registerTempVariable("viewDirectionW") && (e.compilationString += "vec3 viewDirectionW = normalize(" + this.cameraPosition.associatedVariableName + " - " + vt + `.xyz);\r
+`), e.compilationString += "vec3 geometricNormalW = " + this._vNormalWName + `.xyz;\r
+`, e.compilationString += "vec3 normalW = " + (jt.isConnected ? "normalize(" + jt.associatedVariableName + ".xyz)" : "geometricNormalW") + `;\r
+`, this._invertNormalName = e._getFreeVariableName("invertNormal"), e._emitUniformFromString(this._invertNormalName, "float"), e.compilationString += e._emitCodeFromInclude("pbrBlockNormalFinal", Ze, { replaceStrings: [{ search: /vPositionW/g, replace: vt + ".xyz" }, { search: /vEyePosition.w/g, replace: this._invertNormalName }] }), e.compilationString += this._getAlbedoOpacityCode(), e.compilationString += e._emitCodeFromInclude("depthPrePass", Ze), e.compilationString += this._getAmbientOcclusionCode(), e.compilationString += e._emitCodeFromInclude("pbrBlockLightmapInit", Ze), e.compilationString += `#ifdef UNLIT
+ vec3 diffuseBase = vec3(1., 1., 1.);
+ #else\r
+`, e.compilationString += this._getReflectivityCode(e), e.compilationString += e._emitCodeFromInclude("pbrBlockGeometryInfo", Ze, { replaceStrings: [{ search: /REFLECTIONMAP_SKYBOX/g, replace: (o = Ve == null ? void 0 : Ve._defineSkyboxName) !== null && o !== void 0 ? o : "REFLECTIONMAP_SKYBOX" }, { search: /REFLECTIONMAP_3D/g, replace: (a = Ve == null ? void 0 : Ve._define3DName) !== null && a !== void 0 ? a : "REFLECTIONMAP_3D" }] });
+ var Dt = this.anisotropy.isConnected ? (s = this.anisotropy.connectedPoint) === null || s === void 0 ? void 0 : s.ownerBlock : null;
+ Dt && (Dt.worldPositionConnectionPoint = this.worldPosition, Dt.worldNormalConnectionPoint = this.worldNormal, e.compilationString += Dt.getCode(e, !this.perturbedNormal.isConnected)), Ve && Ve.hasTexture && (e.compilationString += Ve.getCode(e, Dt ? "anisotropicOut.anisotropicNormal" : "normalW")), e._emitFunctionFromInclude("pbrBlockReflection", Ze, { replaceStrings: [{ search: /computeReflectionCoords/g, replace: "computeReflectionCoordsPBR" }, { search: /REFLECTIONMAP_3D/g, replace: (d = Ve == null ? void 0 : Ve._define3DName) !== null && d !== void 0 ? d : "REFLECTIONMAP_3D" }, { search: /REFLECTIONMAP_OPPOSITEZ/g, replace: (p = Ve == null ? void 0 : Ve._defineOppositeZ) !== null && p !== void 0 ? p : "REFLECTIONMAP_OPPOSITEZ" }, { search: /REFLECTIONMAP_PROJECTION/g, replace: (y = Ve == null ? void 0 : Ve._defineProjectionName) !== null && y !== void 0 ? y : "REFLECTIONMAP_PROJECTION" }, { search: /REFLECTIONMAP_SKYBOX/g, replace: (P = Ve == null ? void 0 : Ve._defineSkyboxName) !== null && P !== void 0 ? P : "REFLECTIONMAP_SKYBOX" }, { search: /LODINREFLECTIONALPHA/g, replace: (R = Ve == null ? void 0 : Ve._defineLODReflectionAlpha) !== null && R !== void 0 ? R : "LODINREFLECTIONALPHA" }, { search: /LINEARSPECULARREFLECTION/g, replace: (B = Ve == null ? void 0 : Ve._defineLinearSpecularReflection) !== null && B !== void 0 ? B : "LINEARSPECULARREFLECTION" }, { search: /vReflectionFilteringInfo/g, replace: (F = Ve == null ? void 0 : Ve._vReflectionFilteringInfoName) !== null && F !== void 0 ? F : "vReflectionFilteringInfo" }] }), e.compilationString += e._emitCodeFromInclude("pbrBlockReflectance0", Ze, { replaceStrings: [{ search: /metallicReflectanceFactors/g, replace: this._vMetallicReflectanceFactorsName }] });
+ var Yt = this.sheen.isConnected ? (z = this.sheen.connectedPoint) === null || z === void 0 ? void 0 : z.ownerBlock : null;
+ Yt && (e.compilationString += Yt.getCode(Ve)), e._emitFunctionFromInclude("pbrBlockSheen", Ze, { replaceStrings: [{ search: /REFLECTIONMAP_3D/g, replace: (J = Ve == null ? void 0 : Ve._define3DName) !== null && J !== void 0 ? J : "REFLECTIONMAP_3D" }, { search: /REFLECTIONMAP_SKYBOX/g, replace: (ie = Ve == null ? void 0 : Ve._defineSkyboxName) !== null && ie !== void 0 ? ie : "REFLECTIONMAP_SKYBOX" }, { search: /LODINREFLECTIONALPHA/g, replace: (se = Ve == null ? void 0 : Ve._defineLODReflectionAlpha) !== null && se !== void 0 ? se : "LODINREFLECTIONALPHA" }, { search: /LINEARSPECULARREFLECTION/g, replace: (ce = Ve == null ? void 0 : Ve._defineLinearSpecularReflection) !== null && ce !== void 0 ? ce : "LINEARSPECULARREFLECTION" }] });
+ var mt = this.clearcoat.isConnected ? (ue = this.clearcoat.connectedPoint) === null || ue === void 0 ? void 0 : ue.ownerBlock : null, qt = !this.perturbedNormal.isConnected && !this.anisotropy.isConnected, Ht = this.perturbedNormal.isConnected && ((fe = this.perturbedNormal.connectedPoint) === null || fe === void 0 ? void 0 : fe.ownerBlock).worldTangent.isConnected, kt = this.anisotropy.isConnected && ((ve = this.anisotropy.connectedPoint) === null || ve === void 0 ? void 0 : ve.ownerBlock).worldTangent.isConnected, Wt = Ht || !this.perturbedNormal.isConnected && kt;
+ e.compilationString += la.GetCode(e, mt, Ve, vt, qt, Wt, this.worldNormal.associatedVariableName), qt && (Wt = (Te = mt == null ? void 0 : mt.worldTangent.isConnected) !== null && Te !== void 0 && Te), e._emitFunctionFromInclude("pbrBlockClearcoat", Ze, { replaceStrings: [{ search: /computeReflectionCoords/g, replace: "computeReflectionCoordsPBR" }, { search: /REFLECTIONMAP_3D/g, replace: (Re = Ve == null ? void 0 : Ve._define3DName) !== null && Re !== void 0 ? Re : "REFLECTIONMAP_3D" }, { search: /REFLECTIONMAP_OPPOSITEZ/g, replace: (Ae = Ve == null ? void 0 : Ve._defineOppositeZ) !== null && Ae !== void 0 ? Ae : "REFLECTIONMAP_OPPOSITEZ" }, { search: /REFLECTIONMAP_PROJECTION/g, replace: (Ee = Ve == null ? void 0 : Ve._defineProjectionName) !== null && Ee !== void 0 ? Ee : "REFLECTIONMAP_PROJECTION" }, { search: /REFLECTIONMAP_SKYBOX/g, replace: (Se = Ve == null ? void 0 : Ve._defineSkyboxName) !== null && Se !== void 0 ? Se : "REFLECTIONMAP_SKYBOX" }, { search: /LODINREFLECTIONALPHA/g, replace: (De = Ve == null ? void 0 : Ve._defineLODReflectionAlpha) !== null && De !== void 0 ? De : "LODINREFLECTIONALPHA" }, { search: /LINEARSPECULARREFLECTION/g, replace: (xe = Ve == null ? void 0 : Ve._defineLinearSpecularReflection) !== null && xe !== void 0 ? xe : "LINEARSPECULARREFLECTION" }, { search: /defined\(TANGENT\)/g, replace: Wt ? "defined(TANGENT)" : "defined(IGNORE)" }] }), e.compilationString += e._emitCodeFromInclude("pbrBlockReflectance", Ze, { replaceStrings: [{ search: /REFLECTIONMAP_SKYBOX/g, replace: (Le = Ve == null ? void 0 : Ve._defineSkyboxName) !== null && Le !== void 0 ? Le : "REFLECTIONMAP_SKYBOX" }, { search: /REFLECTIONMAP_3D/g, replace: (Me = Ve == null ? void 0 : Ve._define3DName) !== null && Me !== void 0 ? Me : "REFLECTIONMAP_3D" }] });
+ var bt = this.subsurface.isConnected ? (we = this.subsurface.connectedPoint) === null || we === void 0 ? void 0 : we.ownerBlock : null, Rt = this.subsurface.isConnected ? (et = ((Ye = this.subsurface.connectedPoint) === null || Ye === void 0 ? void 0 : Ye.ownerBlock).refraction.connectedPoint) === null || et === void 0 ? void 0 : et.ownerBlock : null;
+ Rt && (Rt.viewConnectionPoint = this.view, Rt.indexOfRefractionConnectionPoint = this.indexOfRefraction), e.compilationString += ua.GetCode(e, bt, Ve, vt), e._emitFunctionFromInclude("pbrBlockSubSurface", Ze, { replaceStrings: [{ search: /REFLECTIONMAP_3D/g, replace: (nt = Ve == null ? void 0 : Ve._define3DName) !== null && nt !== void 0 ? nt : "REFLECTIONMAP_3D" }, { search: /REFLECTIONMAP_OPPOSITEZ/g, replace: (ct = Ve == null ? void 0 : Ve._defineOppositeZ) !== null && ct !== void 0 ? ct : "REFLECTIONMAP_OPPOSITEZ" }, { search: /REFLECTIONMAP_PROJECTION/g, replace: (Ke = Ve == null ? void 0 : Ve._defineProjectionName) !== null && Ke !== void 0 ? Ke : "REFLECTIONMAP_PROJECTION" }, { search: /SS_REFRACTIONMAP_3D/g, replace: (rt = Rt == null ? void 0 : Rt._define3DName) !== null && rt !== void 0 ? rt : "SS_REFRACTIONMAP_3D" }, { search: /SS_LODINREFRACTIONALPHA/g, replace: (it = Rt == null ? void 0 : Rt._defineLODRefractionAlpha) !== null && it !== void 0 ? it : "SS_LODINREFRACTIONALPHA" }, { search: /SS_LINEARSPECULARREFRACTION/g, replace: (qe = Rt == null ? void 0 : Rt._defineLinearSpecularRefraction) !== null && qe !== void 0 ? qe : "SS_LINEARSPECULARREFRACTION" }, { search: /SS_REFRACTIONMAP_OPPOSITEZ/g, replace: (ut = Rt == null ? void 0 : Rt._defineOppositeZ) !== null && ut !== void 0 ? ut : "SS_REFRACTIONMAP_OPPOSITEZ" }] }), e.compilationString += e._emitCodeFromInclude("pbrBlockDirectLighting", Ze), this.light ? e.compilationString += e._emitCodeFromInclude("lightFragment", Ze, { replaceStrings: [{ search: /{X}/g, replace: this._lightId.toString() }] }) : e.compilationString += e._emitCodeFromInclude("lightFragment", Ze, { repeatKey: "maxSimultaneousLights" }), e.compilationString += e._emitCodeFromInclude("pbrBlockFinalLitComponents", Ze), e.compilationString += `#endif\r
+`;
+ var Zt = this.ambientColor.isConnected ? this.ambientColor.associatedVariableName : "vec3(0., 0., 0.)", Mn = pn.DEFAULT_AO_ON_ANALYTICAL_LIGHTS.toString();
+ Mn.indexOf(".") === -1 && (Mn += "."), e.compilationString += e._emitCodeFromInclude("pbrBlockFinalUnlitComponents", Ze, { replaceStrings: [{ search: /vec3 finalEmissive[\s\S]*?finalEmissive\*=vLightingIntensity\.y;/g, replace: "" }, { search: /vAmbientColor/g, replace: Zt + " * ambientFromScene" }, { search: /vAmbientInfos\.w/g, replace: Mn }] }), e.compilationString += e._emitCodeFromInclude("pbrBlockFinalColorComposition", Ze, { replaceStrings: [{ search: /finalEmissive/g, replace: "vec3(0.)" }] }), e.compilationString += e._emitCodeFromInclude("pbrBlockImageProcessing", Ze, { replaceStrings: [{ search: /visibility/g, replace: "1." }] }), e.compilationString += e._emitCodeFromInclude("pbrDebug", Ze, { replaceStrings: [{ search: /vNormalW/g, replace: this._vNormalWName }, { search: /vPositionW/g, replace: vt }, { search: /albedoTexture\.rgb;/g, replace: `vec3(1.);\r
+gl_FragColor.rgb = toGammaSpace(gl_FragColor.rgb);\r
+` }] });
+ for (var Bn = 0, Kn = this._outputs; Bn < Kn.length; Bn++) {
+ var In = Kn[Bn];
+ if (In.hasEndpoints) {
+ var Kt = j_[In.name];
+ if (Kt) {
+ var oi = Kt[0], Ti = Kt[1];
+ Ti && (e.compilationString += "#if " + Ti + `\r
+`), e.compilationString += this._declareOutput(In, e) + " = " + oi + `;\r
+`, Ti && (e.compilationString += `#else\r
+`, e.compilationString += this._declareOutput(In, e) + ` = vec3(0.);\r
+`, e.compilationString += `#endif\r
+`);
+ } else
+ console.error("There's no remapping for the " + In.name + " end point! No code generated");
+ }
+ }
+ return this;
+ }, t.prototype._dumpPropertiesCode = function() {
+ var e = "";
+ return e += this._codeVariableName + ".lightFalloff = " + this.lightFalloff + `;\r
+`, e += this._codeVariableName + ".useAlphaTest = " + this.useAlphaTest + `;\r
+`, e += this._codeVariableName + ".alphaTestCutoff = " + this.alphaTestCutoff + `;\r
+`, e += this._codeVariableName + ".useAlphaBlending = " + this.useAlphaBlending + `;\r
+`, e += this._codeVariableName + ".useRadianceOverAlpha = " + this.useRadianceOverAlpha + `;\r
+`, e += this._codeVariableName + ".useSpecularOverAlpha = " + this.useSpecularOverAlpha + `;\r
+`, e += this._codeVariableName + ".enableSpecularAntiAliasing = " + this.enableSpecularAntiAliasing + `;\r
+`, e += this._codeVariableName + ".realTimeFiltering = " + this.realTimeFiltering + `;\r
+`, e += this._codeVariableName + ".realTimeFilteringQuality = " + this.realTimeFilteringQuality + `;\r
+`, e += this._codeVariableName + ".useEnergyConservation = " + this.useEnergyConservation + `;\r
+`, e += this._codeVariableName + ".useRadianceOcclusion = " + this.useRadianceOcclusion + `;\r
+`, e += this._codeVariableName + ".useHorizonOcclusion = " + this.useHorizonOcclusion + `;\r
+`, e += this._codeVariableName + ".unlit = " + this.unlit + `;\r
+`, e += this._codeVariableName + ".forceNormalForward = " + this.forceNormalForward + `;\r
+`, e += this._codeVariableName + ".debugMode = " + this.debugMode + `;\r
+`, e += this._codeVariableName + ".debugLimit = " + this.debugLimit + `;\r
+`, e += this._codeVariableName + ".debugFactor = " + this.debugFactor + `;\r
+`;
+ }, t.prototype.serialize = function() {
+ var e = r.prototype.serialize.call(this);
+ return this.light && (e.lightId = this.light.id), e.lightFalloff = this.lightFalloff, e.useAlphaTest = this.useAlphaTest, e.alphaTestCutoff = this.alphaTestCutoff, e.useAlphaBlending = this.useAlphaBlending, e.useRadianceOverAlpha = this.useRadianceOverAlpha, e.useSpecularOverAlpha = this.useSpecularOverAlpha, e.enableSpecularAntiAliasing = this.enableSpecularAntiAliasing, e.realTimeFiltering = this.realTimeFiltering, e.realTimeFilteringQuality = this.realTimeFilteringQuality, e.useEnergyConservation = this.useEnergyConservation, e.useRadianceOcclusion = this.useRadianceOcclusion, e.useHorizonOcclusion = this.useHorizonOcclusion, e.unlit = this.unlit, e.forceNormalForward = this.forceNormalForward, e.debugMode = this.debugMode, e.debugLimit = this.debugLimit, e.debugFactor = this.debugFactor, e;
+ }, t.prototype._deserialize = function(e, n, i) {
+ var o, a;
+ r.prototype._deserialize.call(this, e, n, i), e.lightId && (this.light = n.getLightByID(e.lightId)), this.lightFalloff = (o = e.lightFalloff) !== null && o !== void 0 ? o : 0, this.useAlphaTest = e.useAlphaTest, this.alphaTestCutoff = e.alphaTestCutoff, this.useAlphaBlending = e.useAlphaBlending, this.useRadianceOverAlpha = e.useRadianceOverAlpha, this.useSpecularOverAlpha = e.useSpecularOverAlpha, this.enableSpecularAntiAliasing = e.enableSpecularAntiAliasing, this.realTimeFiltering = !!e.realTimeFiltering, this.realTimeFilteringQuality = (a = e.realTimeFilteringQuality) !== null && a !== void 0 ? a : h.a.TEXTURE_FILTERING_QUALITY_LOW, this.useEnergyConservation = e.useEnergyConservation, this.useRadianceOcclusion = e.useRadianceOcclusion, this.useHorizonOcclusion = e.useHorizonOcclusion, this.unlit = e.unlit, this.forceNormalForward = !!e.forceNormalForward, this.debugMode = e.debugMode, this.debugLimit = e.debugLimit, this.debugFactor = e.debugFactor;
+ }, Object(c.c)([Bt("Direct lights", It.Float, "INTENSITY", { min: 0, max: 1, notifiers: { update: !0 } })], t.prototype, "directIntensity", void 0), Object(c.c)([Bt("Environment lights", It.Float, "INTENSITY", { min: 0, max: 1, notifiers: { update: !0 } })], t.prototype, "environmentIntensity", void 0), Object(c.c)([Bt("Specular highlights", It.Float, "INTENSITY", { min: 0, max: 1, notifiers: { update: !0 } })], t.prototype, "specularIntensity", void 0), Object(c.c)([Bt("Light falloff", It.List, "LIGHTING & COLORS", { notifiers: { update: !0 }, options: [{ label: "Physical", value: pn.LIGHTFALLOFF_PHYSICAL }, { label: "GLTF", value: pn.LIGHTFALLOFF_GLTF }, { label: "Standard", value: pn.LIGHTFALLOFF_STANDARD }] })], t.prototype, "lightFalloff", void 0), Object(c.c)([Bt("Alpha Testing", It.Boolean, "OPACITY")], t.prototype, "useAlphaTest", void 0), Object(c.c)([Bt("Alpha CutOff", It.Float, "OPACITY", { min: 0, max: 1, notifiers: { update: !0 } })], t.prototype, "alphaTestCutoff", void 0), Object(c.c)([Bt("Alpha blending", It.Boolean, "OPACITY")], t.prototype, "useAlphaBlending", void 0), Object(c.c)([Bt("Radiance over alpha", It.Boolean, "RENDERING", { notifiers: { update: !0 } })], t.prototype, "useRadianceOverAlpha", void 0), Object(c.c)([Bt("Specular over alpha", It.Boolean, "RENDERING", { notifiers: { update: !0 } })], t.prototype, "useSpecularOverAlpha", void 0), Object(c.c)([Bt("Specular anti-aliasing", It.Boolean, "RENDERING", { notifiers: { update: !0 } })], t.prototype, "enableSpecularAntiAliasing", void 0), Object(c.c)([Bt("Realtime filtering", It.Boolean, "RENDERING", { notifiers: { update: !0 } })], t.prototype, "realTimeFiltering", void 0), Object(c.c)([Bt("Realtime filtering quality", It.List, "RENDERING", { notifiers: { update: !0 }, options: [{ label: "Low", value: h.a.TEXTURE_FILTERING_QUALITY_LOW }, { label: "Medium", value: h.a.TEXTURE_FILTERING_QUALITY_MEDIUM }, { label: "High", value: h.a.TEXTURE_FILTERING_QUALITY_HIGH }] })], t.prototype, "realTimeFilteringQuality", void 0), Object(c.c)([Bt("Energy Conservation", It.Boolean, "ADVANCED", { notifiers: { update: !0 } })], t.prototype, "useEnergyConservation", void 0), Object(c.c)([Bt("Radiance occlusion", It.Boolean, "ADVANCED", { notifiers: { update: !0 } })], t.prototype, "useRadianceOcclusion", void 0), Object(c.c)([Bt("Horizon occlusion", It.Boolean, "ADVANCED", { notifiers: { update: !0 } })], t.prototype, "useHorizonOcclusion", void 0), Object(c.c)([Bt("Unlit", It.Boolean, "ADVANCED", { notifiers: { update: !0 } })], t.prototype, "unlit", void 0), Object(c.c)([Bt("Force normal forward", It.Boolean, "ADVANCED", { notifiers: { update: !0 } })], t.prototype, "forceNormalForward", void 0), Object(c.c)([Bt("Debug mode", It.List, "DEBUG", { notifiers: { update: !0 }, options: [{ label: "None", value: 0 }, { label: "Normalized position", value: 1 }, { label: "Normals", value: 2 }, { label: "Tangents", value: 3 }, { label: "Bitangents", value: 4 }, { label: "Bump Normals", value: 5 }, { label: "ClearCoat Normals", value: 8 }, { label: "ClearCoat Tangents", value: 9 }, { label: "ClearCoat Bitangents", value: 10 }, { label: "Anisotropic Normals", value: 11 }, { label: "Anisotropic Tangents", value: 12 }, { label: "Anisotropic Bitangents", value: 13 }, { label: "Env Refraction", value: 40 }, { label: "Env Reflection", value: 41 }, { label: "Env Clear Coat", value: 42 }, { label: "Direct Diffuse", value: 50 }, { label: "Direct Specular", value: 51 }, { label: "Direct Clear Coat", value: 52 }, { label: "Direct Sheen", value: 53 }, { label: "Env Irradiance", value: 54 }, { label: "Surface Albedo", value: 60 }, { label: "Reflectance 0", value: 61 }, { label: "Metallic", value: 62 }, { label: "Metallic F0", value: 71 }, { label: "Roughness", value: 63 }, { label: "AlphaG", value: 64 }, { label: "NdotV", value: 65 }, { label: "ClearCoat Color", value: 66 }, { label: "ClearCoat Roughness", value: 67 }, { label: "ClearCoat NdotV", value: 68 }, { label: "Transmittance", value: 69 }, { label: "Refraction Transmittance", value: 70 }, { label: "SEO", value: 80 }, { label: "EHO", value: 81 }, { label: "Energy Factor", value: 82 }, { label: "Specular Reflectance", value: 83 }, { label: "Clear Coat Reflectance", value: 84 }, { label: "Sheen Reflectance", value: 85 }, { label: "Luminance Over Alpha", value: 86 }, { label: "Alpha", value: 87 }] })], t.prototype, "debugMode", void 0), Object(c.c)([Bt("Split position", It.Float, "DEBUG", { min: -1, max: 1, notifiers: { update: !0 } })], t.prototype, "debugLimit", void 0), Object(c.c)([Bt("Output factor", It.Float, "DEBUG", { min: 0, max: 5, notifiers: { update: !0 } })], t.prototype, "debugFactor", void 0), t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.PBRMetallicRoughnessBlock"] = Xh;
+ var Yh = function(r) {
+ function t(e) {
+ var n = r.call(this, e, Ce.Neutral) || this;
+ return n.registerInput("left", le.AutoDetect), n.registerInput("right", le.AutoDetect), n.registerOutput("output", le.BasedOnInput), n._outputs[0]._typeConnectionSource = n._inputs[0], n._linkConnectionTypes(0, 1), n;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "ModBlock";
+ }, Object.defineProperty(t.prototype, "left", { get: function() {
+ return this._inputs[0];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "right", { get: function() {
+ return this._inputs[1];
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "output", { get: function() {
+ return this._outputs[0];
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildBlock = function(e) {
+ r.prototype._buildBlock.call(this, e);
+ var n = this._outputs[0];
+ return e.compilationString += this._declareOutput(n, e) + " = mod(" + this.left.associatedVariableName + ", " + this.right.associatedVariableName + `);\r
+`, this;
+ }, t;
+ }(dt);
+ O.a.RegisteredTypes["BABYLON.ModBlock"] = Yh;
+ var H_ = function() {
+ function r() {
+ }
+ return r.prototype.optimize = function(t, e) {
+ }, r;
+ }(), W_ = f(120), X_ = function() {
+ function r() {
+ this.mm = /* @__PURE__ */ new Map();
+ }
+ return r.prototype.get = function(t, e) {
+ var n = this.mm.get(t);
+ if (n !== void 0)
+ return n.get(e);
+ }, r.prototype.set = function(t, e, n) {
+ var i = this.mm.get(t);
+ i === void 0 && this.mm.set(t, i = /* @__PURE__ */ new Map()), i.set(e, n);
+ }, r;
+ }(), Y_ = function() {
+ function r(t, e, n) {
+ var i = this;
+ this._baseMaterial = t, this._scene = e, this._options = n, this._subMeshToEffect = /* @__PURE__ */ new Map(), this._subMeshToDepthEffect = new X_(), this._meshes = /* @__PURE__ */ new Map();
+ var o = t.getClassName() === "NodeMaterial" ? "u_" : "";
+ if (o) {
+ this._matriceNames = { world: o + "World", view: o + "View", projection: o + "Projection", viewProjection: o + "ViewProjection", worldView: o + "WorldxView", worldViewProjection: o + "WorldxViewxProjection" };
+ for (var a = t.getInputBlocks(), s = 0; s < a.length; ++s)
+ switch (a[s]._systemValue) {
+ case gt.World:
+ this._matriceNames.world = a[s].associatedVariableName;
+ break;
+ case gt.View:
+ this._matriceNames.view = a[s].associatedVariableName;
+ break;
+ case gt.Projection:
+ this._matriceNames.projection = a[s].associatedVariableName;
+ break;
+ case gt.ViewProjection:
+ this._matriceNames.viewProjection = a[s].associatedVariableName;
+ break;
+ case gt.WorldView:
+ this._matriceNames.worldView = a[s].associatedVariableName;
+ break;
+ case gt.WorldViewProjection:
+ this._matriceNames.worldViewProjection = a[s].associatedVariableName;
+ }
+ } else
+ this._matriceNames = { world: o + "world", view: o + "view", projection: o + "projection", viewProjection: o + "viewProjection", worldView: o + "worldView", worldViewProjection: o + "worldViewProjection" };
+ this._onEffectCreatedObserver = this._baseMaterial.onEffectCreatedObservable.add(function(d) {
+ var p, y = (p = d.subMesh) === null || p === void 0 ? void 0 : p.getMesh();
+ y && !i._meshes.has(y) && i._meshes.set(y, y.onDisposeObservable.add(function(P) {
+ for (var R = i._subMeshToEffect.keys(), B = R.next(); B.done !== !0; B = R.next()) {
+ var F = B.value;
+ (F == null ? void 0 : F.getMesh()) === P && (i._subMeshToEffect.delete(F), i._subMeshToDepthEffect.mm.delete(F));
+ }
+ })), i._subMeshToEffect.set(d.subMesh, d.effect), i._subMeshToDepthEffect.mm.delete(d.subMesh);
+ });
+ }
+ return Object.defineProperty(r.prototype, "standalone", { get: function() {
+ var t, e;
+ return (e = (t = this._options) === null || t === void 0 ? void 0 : t.standalone) !== null && e !== void 0 && e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "baseMaterial", { get: function() {
+ return this._baseMaterial;
+ }, enumerable: !1, configurable: !0 }), r.prototype.getEffect = function(t, e) {
+ var n, i, o, a, s, d;
+ return (d = (o = (i = (n = this._subMeshToDepthEffect.mm.get(t)) === null || n === void 0 ? void 0 : n.get(e)) === null || i === void 0 ? void 0 : i.depthEffect) !== null && o !== void 0 ? o : (s = (a = this._subMeshToDepthEffect.mm.get(null)) === null || a === void 0 ? void 0 : a.get(e)) === null || s === void 0 ? void 0 : s.depthEffect) !== null && d !== void 0 ? d : null;
+ }, r.prototype.isReadyForSubMesh = function(t, e, n, i) {
+ var o, a;
+ return this.standalone && this._baseMaterial.isReadyForSubMesh(t.getMesh(), t, i), (a = (o = this._makeEffect(t, e, n)) === null || o === void 0 ? void 0 : o.isReady()) !== null && a !== void 0 && a;
+ }, r.prototype.dispose = function() {
+ this._baseMaterial.onEffectCreatedObservable.remove(this._onEffectCreatedObserver), this._onEffectCreatedObserver = null;
+ for (var t = this._meshes.entries(), e = t.next(); e.done !== !0; e = t.next()) {
+ var n = e.value, i = n[0], o = n[1];
+ i.onDisposeObservable.remove(o);
+ }
+ }, r.prototype._makeEffect = function(t, e, n) {
+ var i, o = (i = this._subMeshToEffect.get(t)) !== null && i !== void 0 ? i : this._subMeshToEffect.get(null);
+ if (!o)
+ return null;
+ var a = this._subMeshToDepthEffect.get(t, n);
+ a || (a = { depthEffect: null, depthDefines: "", token: W_.a.RandomId() }, this._subMeshToDepthEffect.set(t, n, a));
+ var s = e.join(`
+`);
+ if (a.depthEffect && s === a.depthDefines)
+ return a.depthEffect;
+ a.depthDefines = s;
+ var d = o.rawVertexSourceCode, p = o.rawFragmentSourceCode, y = this._options && this._options.remappedVariables ? "#include(" + this._options.remappedVariables.join(",") + ")" : ze.a.IncludesShadersStore.shadowMapVertexNormalBias, P = this._options && this._options.remappedVariables ? "#include(" + this._options.remappedVariables.join(",") + ")" : ze.a.IncludesShadersStore.shadowMapVertexMetric, R = this._options && this._options.remappedVariables ? "#include(" + this._options.remappedVariables.join(",") + ")" : ze.a.IncludesShadersStore.shadowMapFragmentSoftTransparentShadow, B = ze.a.IncludesShadersStore.shadowMapFragment;
+ d = (d = (d = (d = d.replace(/void\s+?main/g, ze.a.IncludesShadersStore.shadowMapVertexDeclaration + `\r
+void main`)).replace(/#define SHADOWDEPTH_NORMALBIAS|#define CUSTOM_VERTEX_UPDATE_WORLDPOS/g, y)).indexOf("#define SHADOWDEPTH_METRIC") !== -1 ? d.replace(/#define SHADOWDEPTH_METRIC/g, P) : d.replace(/}\s*$/g, P + `\r
+}`)).replace(/#define SHADER_NAME.*?\n|out vec4 glFragColor;\n/g, "");
+ var F = p.indexOf("#define SHADOWDEPTH_SOFTTRANSPARENTSHADOW") >= 0 || p.indexOf("#define CUSTOM_FRAGMENT_BEFORE_FOG") >= 0, z = p.indexOf("#define SHADOWDEPTH_FRAGMENT") !== -1, J = "";
+ F ? p = p.replace(/#define SHADOWDEPTH_SOFTTRANSPARENTSHADOW|#define CUSTOM_FRAGMENT_BEFORE_FOG/g, R) : J = R + `\r
+`, p = p.replace(/void\s+?main/g, ze.a.IncludesShadersStore.shadowMapFragmentDeclaration + `\r
+void main`), z ? p = p.replace(/#define SHADOWDEPTH_FRAGMENT/g, B) : J += B + `\r
+`, J && (p = p.replace(/}\s*$/g, J + "}")), p = p.replace(/#define SHADER_NAME.*?\n|out vec4 glFragColor;\n/g, "");
+ var ie = o.getUniformNames().slice();
+ return ie.push("biasAndScaleSM", "depthValuesSM", "lightDataSM", "softTransparentShadowSM"), a.depthEffect = this._scene.getEngine().createEffect({ vertexSource: d, fragmentSource: p, vertexToken: a.token, fragmentToken: a.token }, { attributes: o.getAttributesNames(), uniformsNames: ie, uniformBuffersNames: o.getUniformBuffersNames(), samplers: o.getSamplers(), defines: s + `
+` + o.defines.replace("#define SHADOWS", "").replace(/#define SHADOW\d/g, ""), indexParameters: o.getIndexParameters() }, this._scene.getEngine()), a.depthEffect;
+ }, r;
+ }(), Kh = f(101);
+ function cc(r, t, e, n, i) {
+ var o = new r.DecoderBuffer();
+ o.Init(t, t.byteLength);
+ var a, s, d = new r.Decoder();
+ try {
+ var p = d.GetEncodedGeometryType(o);
+ switch (p) {
+ case r.TRIANGULAR_MESH:
+ a = new r.Mesh(), s = d.DecodeBufferToMesh(o, a);
+ break;
+ case r.POINT_CLOUD:
+ a = new r.PointCloud(), s = d.DecodeBufferToPointCloud(o, a);
+ break;
+ default:
+ throw new Error("Invalid geometry type " + p);
+ }
+ if (!s.ok() || !a.ptr)
+ throw new Error(s.error_msg());
+ if (p === r.TRIANGULAR_MESH) {
+ var y = 3 * a.num_faces(), P = 4 * y, R = r._malloc(P);
+ try {
+ d.GetTrianglesUInt32Array(a, P, R);
+ var B = new Uint32Array(y);
+ B.set(new Uint32Array(r.HEAPF32.buffer, R, y)), n(B);
+ } finally {
+ r._free(R);
+ }
+ }
+ var F = function(se, ce) {
+ var ue = ce.num_components(), fe = a.num_points(), ve = fe * ue, Te = ve * Float32Array.BYTES_PER_ELEMENT, Re = r._malloc(Te);
+ try {
+ d.GetAttributeDataArrayForAllPoints(a, ce, r.DT_FLOAT32, Te, Re);
+ var Ae = new Float32Array(r.HEAPF32.buffer, Re, ve);
+ if (se === "color" && ue === 3) {
+ for (var Ee = new Float32Array(4 * fe), Se = 0, De = 0; Se < Ee.length; Se += 4, De += ue)
+ Ee[Se + 0] = Ae[De + 0], Ee[Se + 1] = Ae[De + 1], Ee[Se + 2] = Ae[De + 2], Ee[Se + 3] = 1;
+ i(se, Ee);
+ } else
+ (Ee = new Float32Array(ve)).set(new Float32Array(r.HEAPF32.buffer, Re, ve)), i(se, Ee);
+ } finally {
+ r._free(Re);
+ }
+ };
+ if (e)
+ for (var z in e) {
+ var J = e[z];
+ F(z, d.GetAttributeByUniqueId(a, J));
+ }
+ else {
+ var ie = { position: "POSITION", normal: "NORMAL", color: "COLOR", uv: "TEX_COORD" };
+ for (var z in ie)
+ (J = d.GetAttributeId(a, r[ie[z]])) !== -1 && F(z, d.GetAttribute(a, J));
+ }
+ } finally {
+ a && r.destroy(a), r.destroy(d), r.destroy(o);
+ }
+ }
+ function K_() {
+ var r;
+ onmessage = function(t) {
+ var e = t.data;
+ switch (e.id) {
+ case "init":
+ var n = e.decoder;
+ n.url && (importScripts(n.url), r = DracoDecoderModule({ wasmBinary: n.wasmBinary })), postMessage("done");
+ break;
+ case "decodeMesh":
+ if (!r)
+ throw new Error("Draco decoder module is not available");
+ r.then(function(i) {
+ cc(i, e.dataView, e.attributes, function(o) {
+ postMessage({ id: "indices", value: o }, [o.buffer]);
+ }, function(o, a) {
+ postMessage({ id: o, value: a }, [a.buffer]);
+ }), postMessage("done");
+ });
+ }
+ };
+ }
+ function Qh(r) {
+ return typeof document != "object" || typeof r != "string" ? r : Xe.b.GetAbsoluteUrl(r);
+ }
+ var Q_ = function() {
+ function r(t) {
+ t === void 0 && (t = r.DefaultNumWorkers);
+ var e = r.Configuration.decoder, n = e.wasmUrl && e.wasmBinaryUrl && typeof WebAssembly == "object" ? { url: e.wasmUrl, wasmBinaryPromise: Xe.b.LoadFileAsync(Qh(e.wasmBinaryUrl)) } : { url: e.fallbackUrl, wasmBinaryPromise: Promise.resolve(void 0) };
+ t && typeof Worker == "function" ? this._workerPoolPromise = n.wasmBinaryPromise.then(function(i) {
+ for (var o = cc + "(" + K_ + ")()", a = URL.createObjectURL(new Blob([o], { type: "application/javascript" })), s = new Array(t), d = 0; d < s.length; d++)
+ s[d] = new Promise(function(p, y) {
+ var P = new Worker(a), R = function(F) {
+ P.removeEventListener("error", R), P.removeEventListener("message", B), y(F);
+ }, B = function(F) {
+ F.data === "done" && (P.removeEventListener("error", R), P.removeEventListener("message", B), p(P));
+ };
+ P.addEventListener("error", R), P.addEventListener("message", B), P.postMessage({ id: "init", decoder: { url: Qh(n.url), wasmBinary: i } });
+ });
+ return Promise.all(s).then(function(p) {
+ return new xs(p);
+ });
+ }) : this._decoderModulePromise = n.wasmBinaryPromise.then(function(i) {
+ if (!n.url)
+ throw new Error("Draco decoder module is not available");
+ return Xe.b.LoadScriptAsync(n.url).then(function() {
+ return o = i, new Promise(function(a) {
+ DracoDecoderModule({ wasmBinary: o }).then(function(s) {
+ a({ module: s });
+ });
+ });
+ var o;
+ });
+ });
+ }
+ return Object.defineProperty(r, "DecoderAvailable", { get: function() {
+ var t = r.Configuration.decoder;
+ return !!(t.wasmUrl && t.wasmBinaryUrl && typeof WebAssembly == "object" || t.fallbackUrl);
+ }, enumerable: !1, configurable: !0 }), r.GetDefaultNumWorkers = function() {
+ return typeof navigator == "object" && navigator.hardwareConcurrency ? Math.min(Math.floor(0.5 * navigator.hardwareConcurrency), 4) : 1;
+ }, Object.defineProperty(r, "Default", { get: function() {
+ return r._Default || (r._Default = new r()), r._Default;
+ }, enumerable: !1, configurable: !0 }), r.prototype.dispose = function() {
+ this._workerPoolPromise && this._workerPoolPromise.then(function(t) {
+ t.dispose();
+ }), delete this._workerPoolPromise, delete this._decoderModulePromise;
+ }, r.prototype.whenReadyAsync = function() {
+ return this._workerPoolPromise ? this._workerPoolPromise.then(function() {
+ }) : this._decoderModulePromise ? this._decoderModulePromise.then(function() {
+ }) : Promise.resolve();
+ }, r.prototype.decodeMeshAsync = function(t, e) {
+ var n = t instanceof ArrayBuffer ? new Uint8Array(t) : t;
+ if (this._workerPoolPromise)
+ return this._workerPoolPromise.then(function(i) {
+ return new Promise(function(o, a) {
+ i.push(function(s, d) {
+ var p = new ht.a(), y = function(B) {
+ s.removeEventListener("error", y), s.removeEventListener("message", P), a(B), d();
+ }, P = function(B) {
+ B.data === "done" ? (s.removeEventListener("error", y), s.removeEventListener("message", P), o(p), d()) : B.data.id === "indices" ? p.indices = B.data.value : p.set(B.data.value, B.data.id);
+ };
+ s.addEventListener("error", y), s.addEventListener("message", P);
+ var R = new Uint8Array(n.byteLength);
+ R.set(new Uint8Array(n.buffer, n.byteOffset, n.byteLength)), s.postMessage({ id: "decodeMesh", dataView: R, attributes: e }, [R.buffer]);
+ });
+ });
+ });
+ if (this._decoderModulePromise)
+ return this._decoderModulePromise.then(function(i) {
+ var o = new ht.a();
+ return cc(i.module, n, e, function(a) {
+ o.indices = a;
+ }, function(a, s) {
+ o.set(s, a);
+ }), o;
+ });
+ throw new Error("Draco decoder module is not available");
+ }, r.Configuration = { decoder: { wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js", wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm", fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js" } }, r.DefaultNumWorkers = r.GetDefaultNumWorkers(), r._Default = null, r;
+ }(), uo = f(61), qh = 0, q_ = function() {
+ function r(t, e, n, i) {
+ this.pos = t, this.normal = e, this.uv = n, this.vertColor = i;
+ }
+ return r.prototype.clone = function() {
+ var t, e;
+ return new r(this.pos.clone(), this.normal.clone(), (t = this.uv) === null || t === void 0 ? void 0 : t.clone(), (e = this.vertColor) === null || e === void 0 ? void 0 : e.clone());
+ }, r.prototype.flip = function() {
+ this.normal = this.normal.scale(-1);
+ }, r.prototype.interpolate = function(t, e) {
+ return new r(u.e.Lerp(this.pos, t.pos, e), u.e.Lerp(this.normal, t.normal, e), this.uv && t.uv ? u.d.Lerp(this.uv, t.uv, e) : void 0, this.vertColor && t.vertColor ? I.b.Lerp(this.vertColor, t.vertColor, e) : void 0);
+ }, r;
+ }(), Z_ = function() {
+ function r(t, e) {
+ this.normal = t, this.w = e;
+ }
+ return r.FromPoints = function(t, e, n) {
+ var i = n.subtract(t), o = e.subtract(t);
+ if (i.lengthSquared() === 0 || o.lengthSquared() === 0)
+ return null;
+ var a = u.e.Normalize(u.e.Cross(i, o));
+ return new r(a, u.e.Dot(a, t));
+ }, r.prototype.clone = function() {
+ return new r(this.normal.clone(), this.w);
+ }, r.prototype.flip = function() {
+ this.normal.scaleInPlace(-1), this.w = -this.w;
+ }, r.prototype.splitPolygon = function(t, e, n, i, o) {
+ var a, s, d = 0, p = [];
+ for (a = 0; a < t.vertices.length; a++) {
+ var y = (s = u.e.Dot(this.normal, t.vertices[a].pos) - this.w) < -r.EPSILON ? 2 : s > r.EPSILON ? 1 : 0;
+ d |= y, p.push(y);
+ }
+ switch (d) {
+ case 0:
+ (u.e.Dot(this.normal, t.plane.normal) > 0 ? e : n).push(t);
+ break;
+ case 1:
+ i.push(t);
+ break;
+ case 2:
+ o.push(t);
+ break;
+ case 3:
+ var P, R = [], B = [];
+ for (a = 0; a < t.vertices.length; a++) {
+ var F = (a + 1) % t.vertices.length, z = p[a], J = p[F], ie = t.vertices[a], se = t.vertices[F];
+ if (z !== 2 && R.push(ie), z !== 1 && B.push(z !== 2 ? ie.clone() : ie), (z | J) == 3) {
+ s = (this.w - u.e.Dot(this.normal, ie.pos)) / u.e.Dot(this.normal, se.pos.subtract(ie.pos));
+ var ce = ie.interpolate(se, s);
+ R.push(ce), B.push(ce.clone());
+ }
+ }
+ R.length >= 3 && (P = new lc(R, t.shared)).plane && i.push(P), B.length >= 3 && (P = new lc(B, t.shared)).plane && o.push(P);
+ }
+ }, r.EPSILON = 1e-5, r;
+ }(), lc = function() {
+ function r(t, e) {
+ this.vertices = t, this.shared = e, this.plane = Z_.FromPoints(t[0].pos, t[1].pos, t[2].pos);
+ }
+ return r.prototype.clone = function() {
+ return new r(this.vertices.map(function(t) {
+ return t.clone();
+ }), this.shared);
+ }, r.prototype.flip = function() {
+ this.vertices.reverse().map(function(t) {
+ t.flip();
+ }), this.plane.flip();
+ }, r;
+ }(), Yn = function() {
+ function r(t) {
+ this.plane = null, this.front = null, this.back = null, this.polygons = new Array(), t && this.build(t);
+ }
+ return r.prototype.clone = function() {
+ var t = new r();
+ return t.plane = this.plane && this.plane.clone(), t.front = this.front && this.front.clone(), t.back = this.back && this.back.clone(), t.polygons = this.polygons.map(function(e) {
+ return e.clone();
+ }), t;
+ }, r.prototype.invert = function() {
+ for (var t = 0; t < this.polygons.length; t++)
+ this.polygons[t].flip();
+ this.plane && this.plane.flip(), this.front && this.front.invert(), this.back && this.back.invert();
+ var e = this.front;
+ this.front = this.back, this.back = e;
+ }, r.prototype.clipPolygons = function(t) {
+ if (!this.plane)
+ return t.slice();
+ for (var e = new Array(), n = new Array(), i = 0; i < t.length; i++)
+ this.plane.splitPolygon(t[i], e, n, e, n);
+ return this.front && (e = this.front.clipPolygons(e)), n = this.back ? this.back.clipPolygons(n) : [], e.concat(n);
+ }, r.prototype.clipTo = function(t) {
+ this.polygons = t.clipPolygons(this.polygons), this.front && this.front.clipTo(t), this.back && this.back.clipTo(t);
+ }, r.prototype.allPolygons = function() {
+ var t = this.polygons.slice();
+ return this.front && (t = t.concat(this.front.allPolygons())), this.back && (t = t.concat(this.back.allPolygons())), t;
+ }, r.prototype.build = function(t) {
+ if (t.length) {
+ this.plane || (this.plane = t[0].plane.clone());
+ for (var e = new Array(), n = new Array(), i = 0; i < t.length; i++)
+ this.plane.splitPolygon(t[i], this.polygons, this.polygons, e, n);
+ e.length && (this.front || (this.front = new r()), this.front.build(e)), n.length && (this.back || (this.back = new r()), this.back.build(n));
+ }
+ }, r;
+ }(), J_ = function() {
+ function r() {
+ this.polygons = new Array();
+ }
+ return r.FromMesh = function(t) {
+ var e, n, i, o, a, s, d, p, y, P = void 0, R = void 0, B = new Array(), F = null;
+ if (!(t instanceof Ie.a))
+ throw "BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh";
+ t.computeWorldMatrix(!0), s = t.getWorldMatrix(), d = t.position.clone(), p = t.rotation.clone(), t.rotationQuaternion && (F = t.rotationQuaternion.clone()), y = t.scaling.clone();
+ for (var z = t.getIndices(), J = t.getVerticesData(Oe.b.PositionKind), ie = t.getVerticesData(Oe.b.NormalKind), se = t.getVerticesData(Oe.b.UVKind), ce = t.getVerticesData(Oe.b.ColorKind), ue = t.subMeshes, fe = 0, ve = ue.length; fe < ve; fe++)
+ for (var Te = ue[fe].indexStart, Re = ue[fe].indexCount + ue[fe].indexStart; Te < Re; Te += 3) {
+ a = [];
+ for (var Ae = 0; Ae < 3; Ae++) {
+ var Ee = new u.e(ie[3 * z[Te + Ae]], ie[3 * z[Te + Ae] + 1], ie[3 * z[Te + Ae] + 2]);
+ se && (P = new u.d(se[2 * z[Te + Ae]], se[2 * z[Te + Ae] + 1])), ce && (R = new I.b(ce[4 * z[Te + Ae]], ce[4 * z[Te + Ae] + 1], ce[4 * z[Te + Ae] + 2], ce[4 * z[Te + Ae] + 3]));
+ var Se = new u.e(J[3 * z[Te + Ae]], J[3 * z[Te + Ae] + 1], J[3 * z[Te + Ae] + 2]);
+ i = u.e.TransformCoordinates(Se, s), n = u.e.TransformNormal(Ee, s), e = new q_(i, n, P, R), a.push(e);
+ }
+ (o = new lc(a, { subMeshId: fe, meshId: qh, materialIndex: ue[fe].materialIndex })).plane && B.push(o);
+ }
+ var De = r.FromPolygons(B);
+ return De.matrix = s, De.position = d, De.rotation = p, De.scaling = y, De.rotationQuaternion = F, qh++, De;
+ }, r.FromPolygons = function(t) {
+ var e = new r();
+ return e.polygons = t, e;
+ }, r.prototype.clone = function() {
+ var t = new r();
+ return t.polygons = this.polygons.map(function(e) {
+ return e.clone();
+ }), t.copyTransformAttributes(this), t;
+ }, r.prototype.union = function(t) {
+ var e = new Yn(this.clone().polygons), n = new Yn(t.clone().polygons);
+ return e.clipTo(n), n.clipTo(e), n.invert(), n.clipTo(e), n.invert(), e.build(n.allPolygons()), r.FromPolygons(e.allPolygons()).copyTransformAttributes(this);
+ }, r.prototype.unionInPlace = function(t) {
+ var e = new Yn(this.polygons), n = new Yn(t.polygons);
+ e.clipTo(n), n.clipTo(e), n.invert(), n.clipTo(e), n.invert(), e.build(n.allPolygons()), this.polygons = e.allPolygons();
+ }, r.prototype.subtract = function(t) {
+ var e = new Yn(this.clone().polygons), n = new Yn(t.clone().polygons);
+ return e.invert(), e.clipTo(n), n.clipTo(e), n.invert(), n.clipTo(e), n.invert(), e.build(n.allPolygons()), e.invert(), r.FromPolygons(e.allPolygons()).copyTransformAttributes(this);
+ }, r.prototype.subtractInPlace = function(t) {
+ var e = new Yn(this.polygons), n = new Yn(t.polygons);
+ e.invert(), e.clipTo(n), n.clipTo(e), n.invert(), n.clipTo(e), n.invert(), e.build(n.allPolygons()), e.invert(), this.polygons = e.allPolygons();
+ }, r.prototype.intersect = function(t) {
+ var e = new Yn(this.clone().polygons), n = new Yn(t.clone().polygons);
+ return e.invert(), n.clipTo(e), n.invert(), e.clipTo(n), n.clipTo(e), e.build(n.allPolygons()), e.invert(), r.FromPolygons(e.allPolygons()).copyTransformAttributes(this);
+ }, r.prototype.intersectInPlace = function(t) {
+ var e = new Yn(this.polygons), n = new Yn(t.polygons);
+ e.invert(), n.clipTo(e), n.invert(), e.clipTo(n), n.clipTo(e), e.build(n.allPolygons()), e.invert(), this.polygons = e.allPolygons();
+ }, r.prototype.inverse = function() {
+ var t = this.clone();
+ return t.inverseInPlace(), t;
+ }, r.prototype.inverseInPlace = function() {
+ this.polygons.map(function(t) {
+ t.flip();
+ });
+ }, r.prototype.copyTransformAttributes = function(t) {
+ return this.matrix = t.matrix, this.position = t.position, this.rotation = t.rotation, this.scaling = t.scaling, this.rotationQuaternion = t.rotationQuaternion, this;
+ }, r.prototype.buildMeshGeometry = function(t, e, n) {
+ var i = this.matrix.clone();
+ i.invert();
+ var o, a, s, d = new Ie.a(t, e), p = [], y = [], P = [], R = null, B = null, F = u.e.Zero(), z = u.e.Zero(), J = u.d.Zero(), ie = new I.b(0, 0, 0, 0), se = this.polygons, ce = [0, 0, 0], ue = {}, fe = 0, ve = {};
+ n && se.sort(function(ct, Ke) {
+ return ct.shared.meshId === Ke.shared.meshId ? ct.shared.subMeshId - Ke.shared.subMeshId : ct.shared.meshId - Ke.shared.meshId;
+ });
+ for (var Te = 0, Re = se.length; Te < Re; Te++) {
+ ve[(o = se[Te]).shared.meshId] || (ve[o.shared.meshId] = {}), ve[o.shared.meshId][o.shared.subMeshId] || (ve[o.shared.meshId][o.shared.subMeshId] = { indexStart: 1 / 0, indexEnd: -1 / 0, materialIndex: o.shared.materialIndex }), s = ve[o.shared.meshId][o.shared.subMeshId];
+ for (var Ae = 2, Ee = o.vertices.length; Ae < Ee; Ae++) {
+ ce[0] = 0, ce[1] = Ae - 1, ce[2] = Ae;
+ for (var Se = 0; Se < 3; Se++) {
+ F.copyFrom(o.vertices[ce[Se]].pos), z.copyFrom(o.vertices[ce[Se]].normal), o.vertices[ce[Se]].uv && (R || (R = []), J.copyFrom(o.vertices[ce[Se]].uv)), o.vertices[ce[Se]].vertColor && (B || (B = []), ie.copyFrom(o.vertices[ce[Se]].vertColor));
+ var De = u.e.TransformCoordinates(F, i), xe = u.e.TransformNormal(z, i);
+ a = ue[De.x + "," + De.y + "," + De.z];
+ var Le = !1;
+ R && R[2 * a] !== J.x && R[2 * a + 1] !== J.y && (Le = !0);
+ var Me = !1;
+ B && B[4 * a] !== ie.r && B[4 * a + 1] !== ie.g && B[4 * a + 2] !== ie.b && B[4 * a + 3] !== ie.a && (Me = !0), (a === void 0 || P[3 * a] !== xe.x || P[3 * a + 1] !== xe.y || P[3 * a + 2] !== xe.z || Le || Me) && (p.push(De.x, De.y, De.z), R && R.push(J.x, J.y), P.push(z.x, z.y, z.z), B && B.push(ie.r, ie.g, ie.b, ie.a), a = ue[De.x + "," + De.y + "," + De.z] = p.length / 3 - 1), y.push(a), s.indexStart = Math.min(fe, s.indexStart), s.indexEnd = Math.max(fe, s.indexEnd), fe++;
+ }
+ }
+ }
+ if (d.setVerticesData(Oe.b.PositionKind, p), d.setVerticesData(Oe.b.NormalKind, P), R && d.setVerticesData(Oe.b.UVKind, R), B && d.setVerticesData(Oe.b.ColorKind, B), d.setIndices(y, null), n) {
+ var we, Ye = 0;
+ for (var et in d.subMeshes = new Array(), ve) {
+ for (var nt in we = -1, ve[et])
+ s = ve[et][nt], uo.a.CreateFromIndices(s.materialIndex + Ye, s.indexStart, s.indexEnd - s.indexStart + 1, d), we = Math.max(s.materialIndex, we);
+ Ye += ++we;
+ }
+ }
+ return d;
+ }, r.prototype.toMesh = function(t, e, n, i) {
+ e === void 0 && (e = null);
+ var o = this.buildMeshGeometry(t, n, i);
+ return o.material = e, o.position.copyFrom(this.position), o.rotation.copyFrom(this.rotation), this.rotationQuaternion && (o.rotationQuaternion = this.rotationQuaternion.clone()), o.scaling.copyFrom(this.scaling), o.computeWorldMatrix(!0), o;
+ }, r;
+ }(), $_ = function(r) {
+ function t(e, n, i, o, a, s) {
+ o === void 0 && (o = 1), a === void 0 && (a = 60), s === void 0 && (s = !0);
+ var d = r.call(this, e, i) || this;
+ d._sectionPolygonPointsCount = 4, d._running = !1, d._autoStart = s, d._generator = n, d._diameter = o, d._length = a, d._sectionVectors = [], d._sectionNormalVectors = [];
+ for (var p = 0; p < d._sectionPolygonPointsCount; p++)
+ d._sectionVectors[p] = u.e.Zero(), d._sectionNormalVectors[p] = u.e.Zero();
+ return d._createMesh(), d;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "TrailMesh";
+ }, t.prototype._createMesh = function() {
+ var e = new ht.a(), n = [], i = [], o = [], a = u.e.Zero();
+ a = this._generator instanceof Mt.a && this._generator._boundingInfo ? this._generator._boundingInfo.boundingBox.centerWorld : this._generator.position;
+ for (var s = 2 * Math.PI / this._sectionPolygonPointsCount, d = 0; d < this._sectionPolygonPointsCount; d++)
+ n.push(a.x + Math.cos(d * s) * this._diameter, a.y + Math.sin(d * s) * this._diameter, a.z);
+ for (d = 1; d <= this._length; d++) {
+ for (var p = 0; p < this._sectionPolygonPointsCount; p++)
+ n.push(a.x + Math.cos(p * s) * this._diameter, a.y + Math.sin(p * s) * this._diameter, a.z);
+ var y = n.length / 3 - 2 * this._sectionPolygonPointsCount;
+ for (p = 0; p < this._sectionPolygonPointsCount - 1; p++)
+ o.push(y + p, y + p + this._sectionPolygonPointsCount, y + p + this._sectionPolygonPointsCount + 1), o.push(y + p, y + p + this._sectionPolygonPointsCount + 1, y + p + 1);
+ o.push(y + this._sectionPolygonPointsCount - 1, y + this._sectionPolygonPointsCount - 1 + this._sectionPolygonPointsCount, y + this._sectionPolygonPointsCount), o.push(y + this._sectionPolygonPointsCount - 1, y + this._sectionPolygonPointsCount, y);
+ }
+ ht.a.ComputeNormals(n, o, i), e.positions = n, e.normals = i, e.indices = o, e.applyToMesh(this, !0), this._autoStart && this.start();
+ }, t.prototype.start = function() {
+ var e = this;
+ this._running || (this._running = !0, this._beforeRenderObserver = this.getScene().onBeforeRenderObservable.add(function() {
+ e.update();
+ }));
+ }, t.prototype.stop = function() {
+ this._beforeRenderObserver && this._running && (this._running = !1, this.getScene().onBeforeRenderObservable.remove(this._beforeRenderObserver));
+ }, t.prototype.update = function() {
+ var e = this.getVerticesData(Oe.b.PositionKind), n = this.getVerticesData(Oe.b.NormalKind), i = this._generator.getWorldMatrix();
+ if (e && n) {
+ for (var o = 3 * this._sectionPolygonPointsCount; o < e.length; o++)
+ e[o - 3 * this._sectionPolygonPointsCount] = e[o] - n[o] / this._length * this._diameter;
+ for (o = 3 * this._sectionPolygonPointsCount; o < n.length; o++)
+ n[o - 3 * this._sectionPolygonPointsCount] = n[o];
+ var a = e.length - 3 * this._sectionPolygonPointsCount, s = 2 * Math.PI / this._sectionPolygonPointsCount;
+ for (o = 0; o < this._sectionPolygonPointsCount; o++)
+ this._sectionVectors[o].copyFromFloats(Math.cos(o * s) * this._diameter, Math.sin(o * s) * this._diameter, 0), this._sectionNormalVectors[o].copyFromFloats(Math.cos(o * s), Math.sin(o * s), 0), u.e.TransformCoordinatesToRef(this._sectionVectors[o], i, this._sectionVectors[o]), u.e.TransformNormalToRef(this._sectionNormalVectors[o], i, this._sectionNormalVectors[o]);
+ for (o = 0; o < this._sectionPolygonPointsCount; o++)
+ e[a + 3 * o] = this._sectionVectors[o].x, e[a + 3 * o + 1] = this._sectionVectors[o].y, e[a + 3 * o + 2] = this._sectionVectors[o].z, n[a + 3 * o] = this._sectionNormalVectors[o].x, n[a + 3 * o + 1] = this._sectionNormalVectors[o].y, n[a + 3 * o + 2] = this._sectionNormalVectors[o].z;
+ this.updateVerticesData(Oe.b.PositionKind, e, !0, !1), this.updateVerticesData(Oe.b.NormalKind, n, !0, !1);
+ }
+ }, t.prototype.clone = function(e, n) {
+ return e === void 0 && (e = ""), new t(e, n === void 0 ? this._generator : n, this.getScene(), this._diameter, this._length, this._autoStart);
+ }, t.prototype.serialize = function(e) {
+ r.prototype.serialize.call(this, e);
+ }, t.Parse = function(e, n) {
+ return new t(e.name, e._generator, n, e._diameter, e._length, e._autoStart);
+ }, t;
+ }(Ie.a), em = f(151), ho = f(98), fo = f(82);
+ ht.a.CreateDisc = function(r) {
+ var t = new Array(), e = new Array(), n = new Array(), i = new Array(), o = r.radius || 0.5, a = r.tessellation || 64, s = r.arc && (r.arc <= 0 || r.arc > 1) ? 1 : r.arc || 1, d = r.sideOrientation === 0 ? 0 : r.sideOrientation || ht.a.DEFAULTSIDE;
+ t.push(0, 0, 0), i.push(0.5, 0.5);
+ for (var p = 2 * Math.PI * s, y = s === 1 ? p / a : p / (a - 1), P = 0, R = 0; R < a; R++) {
+ var B = Math.cos(P), F = Math.sin(P), z = (B + 1) / 2, J = (1 - F) / 2;
+ t.push(o * B, o * F, 0), i.push(z, J), P += y;
+ }
+ s === 1 && (t.push(t[3], t[4], t[5]), i.push(i[2], i[3]));
+ for (var ie = t.length / 3, se = 1; se < ie - 1; se++)
+ e.push(se + 1, 0, se);
+ ht.a.ComputeNormals(t, e, n), ht.a._ComputeSides(d, t, e, n, i, r.frontUVs, r.backUVs);
+ var ce = new ht.a();
+ return ce.indices = e, ce.positions = t, ce.normals = n, ce.uvs = i, ce;
+ }, Ie.a.CreateDisc = function(r, t, e, n, i, o) {
+ n === void 0 && (n = null);
+ var a = { radius: t, tessellation: e, sideOrientation: o, updatable: i };
+ return ha.CreateDisc(r, a, n);
+ };
+ var ha = function() {
+ function r() {
+ }
+ return r.CreateDisc = function(t, e, n) {
+ n === void 0 && (n = null);
+ var i = new Ie.a(t, n);
+ return e.sideOrientation = Ie.a._GetDefaultSideOrientation(e.sideOrientation), i._originalBuilderSideOrientation = e.sideOrientation, ht.a.CreateDisc(e).applyToMesh(i, e.updatable), i;
+ }, r;
+ }();
+ ht.a.CreateTiledBox = function(r) {
+ for (var t = r.faceUV || new Array(6), e = r.faceColors, n = r.pattern || Ie.a.NO_FLIP, i = r.width || r.size || 1, o = r.height || r.size || 1, a = r.depth || r.size || 1, s = r.tileWidth || r.tileSize || 1, d = r.tileHeight || r.tileSize || 1, p = r.alignHorizontal || 0, y = r.alignVertical || 0, P = r.sideOrientation === 0 ? 0 : r.sideOrientation || ht.a.DEFAULTSIDE, R = 0; R < 6; R++)
+ t[R] === void 0 && (t[R] = new u.f(0, 0, 1, 1)), e && e[R] === void 0 && (e[R] = new I.b(1, 1, 1, 1));
+ var B = i / 2, F = o / 2, z = a / 2, J = [];
+ for (R = 0; R < 2; R++)
+ J[R] = ht.a.CreateTiledPlane({ pattern: n, tileWidth: s, tileHeight: d, width: i, height: o, alignVertical: y, alignHorizontal: p, sideOrientation: P });
+ for (R = 2; R < 4; R++)
+ J[R] = ht.a.CreateTiledPlane({ pattern: n, tileWidth: s, tileHeight: d, width: a, height: o, alignVertical: y, alignHorizontal: p, sideOrientation: P });
+ var ie = y;
+ for (y === Ie.a.BOTTOM ? ie = Ie.a.TOP : y === Ie.a.TOP && (ie = Ie.a.BOTTOM), R = 4; R < 6; R++)
+ J[R] = ht.a.CreateTiledPlane({ pattern: n, tileWidth: s, tileHeight: d, width: i, height: a, alignVertical: ie, alignHorizontal: p, sideOrientation: P });
+ var se = [], ce = [], ue = [], fe = [], ve = [], Te = [], Re = [], Ae = [], Ee = 0, Se = 0, De = 0;
+ for (R = 0; R < 6; R++) {
+ Ee = J[R].positions.length, Te[R] = [], Re[R] = [];
+ for (var xe = 0; xe < Ee / 3; xe++)
+ Te[R].push(new u.e(J[R].positions[3 * xe], J[R].positions[3 * xe + 1], J[R].positions[3 * xe + 2])), Re[R].push(new u.e(J[R].normals[3 * xe], J[R].normals[3 * xe + 1], J[R].normals[3 * xe + 2]));
+ Se = J[R].uvs.length, Ae[R] = [];
+ for (var Le = 0; Le < Se; Le += 2)
+ Ae[R][Le] = t[R].x + (t[R].z - t[R].x) * J[R].uvs[Le], Ae[R][Le + 1] = t[R].y + (t[R].w - t[R].y) * J[R].uvs[Le + 1];
+ if (ue = ue.concat(Ae[R]), fe = fe.concat(J[R].indices.map(function(Ve) {
+ return Ve + De;
+ })), De += Te[R].length, e)
+ for (var Me = 0; Me < 4; Me++)
+ ve.push(e[R].r, e[R].g, e[R].b, e[R].a);
+ }
+ var we = new u.e(0, 0, z), Ye = u.a.RotationY(Math.PI);
+ se = Te[0].map(function(Ve) {
+ return u.e.TransformNormal(Ve, Ye).add(we);
+ }).map(function(Ve) {
+ return [Ve.x, Ve.y, Ve.z];
+ }).reduce(function(Ve, Ze) {
+ return Ve.concat(Ze);
+ }, []), ce = Re[0].map(function(Ve) {
+ return u.e.TransformNormal(Ve, Ye);
+ }).map(function(Ve) {
+ return [Ve.x, Ve.y, Ve.z];
+ }).reduce(function(Ve, Ze) {
+ return Ve.concat(Ze);
+ }, []), se = se.concat(Te[1].map(function(Ve) {
+ return Ve.subtract(we);
+ }).map(function(Ve) {
+ return [Ve.x, Ve.y, Ve.z];
+ }).reduce(function(Ve, Ze) {
+ return Ve.concat(Ze);
+ }, [])), ce = ce.concat(Re[1].map(function(Ve) {
+ return [Ve.x, Ve.y, Ve.z];
+ }).reduce(function(Ve, Ze) {
+ return Ve.concat(Ze);
+ }, []));
+ var et = new u.e(B, 0, 0), nt = u.a.RotationY(-Math.PI / 2);
+ se = se.concat(Te[2].map(function(Ve) {
+ return u.e.TransformNormal(Ve, nt).add(et);
+ }).map(function(Ve) {
+ return [Ve.x, Ve.y, Ve.z];
+ }).reduce(function(Ve, Ze) {
+ return Ve.concat(Ze);
+ }, [])), ce = ce.concat(Re[2].map(function(Ve) {
+ return u.e.TransformNormal(Ve, nt);
+ }).map(function(Ve) {
+ return [Ve.x, Ve.y, Ve.z];
+ }).reduce(function(Ve, Ze) {
+ return Ve.concat(Ze);
+ }, []));
+ var ct = u.a.RotationY(Math.PI / 2);
+ se = se.concat(Te[3].map(function(Ve) {
+ return u.e.TransformNormal(Ve, ct).subtract(et);
+ }).map(function(Ve) {
+ return [Ve.x, Ve.y, Ve.z];
+ }).reduce(function(Ve, Ze) {
+ return Ve.concat(Ze);
+ }, [])), ce = ce.concat(Re[3].map(function(Ve) {
+ return u.e.TransformNormal(Ve, ct);
+ }).map(function(Ve) {
+ return [Ve.x, Ve.y, Ve.z];
+ }).reduce(function(Ve, Ze) {
+ return Ve.concat(Ze);
+ }, []));
+ var Ke = new u.e(0, F, 0), rt = u.a.RotationX(Math.PI / 2);
+ se = se.concat(Te[4].map(function(Ve) {
+ return u.e.TransformNormal(Ve, rt).add(Ke);
+ }).map(function(Ve) {
+ return [Ve.x, Ve.y, Ve.z];
+ }).reduce(function(Ve, Ze) {
+ return Ve.concat(Ze);
+ }, [])), ce = ce.concat(Re[4].map(function(Ve) {
+ return u.e.TransformNormal(Ve, rt);
+ }).map(function(Ve) {
+ return [Ve.x, Ve.y, Ve.z];
+ }).reduce(function(Ve, Ze) {
+ return Ve.concat(Ze);
+ }, []));
+ var it = u.a.RotationX(-Math.PI / 2);
+ se = se.concat(Te[5].map(function(Ve) {
+ return u.e.TransformNormal(Ve, it).subtract(Ke);
+ }).map(function(Ve) {
+ return [Ve.x, Ve.y, Ve.z];
+ }).reduce(function(Ve, Ze) {
+ return Ve.concat(Ze);
+ }, [])), ce = ce.concat(Re[5].map(function(Ve) {
+ return u.e.TransformNormal(Ve, it);
+ }).map(function(Ve) {
+ return [Ve.x, Ve.y, Ve.z];
+ }).reduce(function(Ve, Ze) {
+ return Ve.concat(Ze);
+ }, [])), ht.a._ComputeSides(P, se, fe, ce, ue);
+ var qe = new ht.a();
+ if (qe.indices = fe, qe.positions = se, qe.normals = ce, qe.uvs = ue, e) {
+ var ut = P === ht.a.DOUBLESIDE ? ve.concat(ve) : ve;
+ qe.colors = ut;
+ }
+ return qe;
+ };
+ var Zh = function() {
+ function r() {
+ }
+ return r.CreateTiledBox = function(t, e, n) {
+ n === void 0 && (n = null);
+ var i = new Ie.a(t, n);
+ return e.sideOrientation = Ie.a._GetDefaultSideOrientation(e.sideOrientation), i._originalBuilderSideOrientation = e.sideOrientation, ht.a.CreateTiledBox(e).applyToMesh(i, e.updatable), i;
+ }, r;
+ }();
+ ht.a.CreateTorusKnot = function(r) {
+ var t, e, n = new Array(), i = new Array(), o = new Array(), a = new Array(), s = r.radius || 2, d = r.tube || 0.5, p = r.radialSegments || 32, y = r.tubularSegments || 32, P = r.p || 2, R = r.q || 3, B = r.sideOrientation === 0 ? 0 : r.sideOrientation || ht.a.DEFAULTSIDE, F = function(Le) {
+ var Me = Math.cos(Le), we = Math.sin(Le), Ye = R / P * Le, et = Math.cos(Ye), nt = s * (2 + et) * 0.5 * Me, ct = s * (2 + et) * we * 0.5, Ke = s * Math.sin(Ye) * 0.5;
+ return new u.e(nt, ct, Ke);
+ };
+ for (t = 0; t <= p; t++) {
+ var z = t % p / p * 2 * P * Math.PI, J = F(z), ie = F(z + 0.01), se = ie.subtract(J), ce = ie.add(J), ue = u.e.Cross(se, ce);
+ for (ce = u.e.Cross(ue, se), ue.normalize(), ce.normalize(), e = 0; e < y; e++) {
+ var fe = e % y / y * 2 * Math.PI, ve = -d * Math.cos(fe), Te = d * Math.sin(fe);
+ i.push(J.x + ve * ce.x + Te * ue.x), i.push(J.y + ve * ce.y + Te * ue.y), i.push(J.z + ve * ce.z + Te * ue.z), a.push(t / p), a.push(e / y);
+ }
+ }
+ for (t = 0; t < p; t++)
+ for (e = 0; e < y; e++) {
+ var Re = (e + 1) % y, Ae = t * y + e, Ee = (t + 1) * y + e, Se = (t + 1) * y + Re, De = t * y + Re;
+ n.push(De), n.push(Ee), n.push(Ae), n.push(De), n.push(Se), n.push(Ee);
+ }
+ ht.a.ComputeNormals(i, n, o), ht.a._ComputeSides(B, i, n, o, a, r.frontUVs, r.backUVs);
+ var xe = new ht.a();
+ return xe.indices = n, xe.positions = i, xe.normals = o, xe.uvs = a, xe;
+ }, Ie.a.CreateTorusKnot = function(r, t, e, n, i, o, a, s, d, p) {
+ var y = { radius: t, tube: e, radialSegments: n, tubularSegments: i, p: o, q: a, sideOrientation: p, updatable: d };
+ return uc.CreateTorusKnot(r, y, s);
+ };
+ var uc = function() {
+ function r() {
+ }
+ return r.CreateTorusKnot = function(t, e, n) {
+ var i = new Ie.a(t, n);
+ return e.sideOrientation = Ie.a._GetDefaultSideOrientation(e.sideOrientation), i._originalBuilderSideOrientation = e.sideOrientation, ht.a.CreateTorusKnot(e).applyToMesh(i, e.updatable), i;
+ }, r;
+ }(), tm = function(r) {
+ function t(e, n) {
+ var i = r.call(this, e.x, e.y) || this;
+ return i.index = n, i;
+ }
+ return Object(c.d)(t, r), t;
+ }(u.d), hc = function() {
+ function r() {
+ this.elements = new Array();
+ }
+ return r.prototype.add = function(t) {
+ var e = this, n = new Array();
+ return t.forEach(function(i) {
+ var o = new tm(i, e.elements.length);
+ n.push(o), e.elements.push(o);
+ }), n;
+ }, r.prototype.computeBounds = function() {
+ var t = new u.d(this.elements[0].x, this.elements[0].y), e = new u.d(this.elements[0].x, this.elements[0].y);
+ return this.elements.forEach(function(n) {
+ n.x < t.x ? t.x = n.x : n.x > e.x && (e.x = n.x), n.y < t.y ? t.y = n.y : n.y > e.y && (e.y = n.y);
+ }), { min: t, max: e, width: e.x - t.x, height: e.y - t.y };
+ }, r;
+ }(), nm = function() {
+ function r() {
+ }
+ return r.Rectangle = function(t, e, n, i) {
+ return [new u.d(t, e), new u.d(n, e), new u.d(n, i), new u.d(t, i)];
+ }, r.Circle = function(t, e, n, i) {
+ e === void 0 && (e = 0), n === void 0 && (n = 0), i === void 0 && (i = 32);
+ for (var o = new Array(), a = 0, s = 2 * Math.PI / i, d = 0; d < i; d++)
+ o.push(new u.d(e + Math.cos(a) * t, n + Math.sin(a) * t)), a -= s;
+ return o;
+ }, r.Parse = function(t) {
+ var e, n = t.split(/[^-+eE\.\d]+/).map(parseFloat).filter(function(o) {
+ return !isNaN(o);
+ }), i = [];
+ for (e = 0; e < (2147483646 & n.length); e += 2)
+ i.push(new u.d(n[e], n[e + 1]));
+ return i;
+ }, r.StartingAt = function(t, e) {
+ return Qe.f.StartingAt(t, e);
+ }, r;
+ }(), Jh = function() {
+ function r(t, e, n, i) {
+ var o;
+ i === void 0 && (i = earcut), this._points = new hc(), this._outlinepoints = new hc(), this._holes = new Array(), this._epoints = new Array(), this._eholes = new Array(), this.bjsEarcut = i, this._name = t, this._scene = n || Ue.a.LastCreatedScene, o = e instanceof Qe.f ? e.getPoints() : e, this._addToepoint(o), this._points.add(o), this._outlinepoints.add(o), this.bjsEarcut === void 0 && l.a.Warn("Earcut was not found, the polygon will not be built.");
+ }
+ return r.prototype._addToepoint = function(t) {
+ for (var e = 0, n = t; e < n.length; e++) {
+ var i = n[e];
+ this._epoints.push(i.x, i.y);
+ }
+ }, r.prototype.addHole = function(t) {
+ this._points.add(t);
+ var e = new hc();
+ return e.add(t), this._holes.push(e), this._eholes.push(this._epoints.length / 2), this._addToepoint(t), this;
+ }, r.prototype.build = function(t, e) {
+ t === void 0 && (t = !1), e === void 0 && (e = 0);
+ var n = new Ie.a(this._name, this._scene), i = this.buildVertexData(e);
+ return n.setVerticesData(Oe.b.PositionKind, i.positions, t), n.setVerticesData(Oe.b.NormalKind, i.normals, t), n.setVerticesData(Oe.b.UVKind, i.uvs, t), n.setIndices(i.indices), n;
+ }, r.prototype.buildVertexData = function(t) {
+ var e = this;
+ t === void 0 && (t = 0);
+ var n = new ht.a(), i = new Array(), o = new Array(), a = new Array(), s = this._points.computeBounds();
+ this._points.elements.forEach(function(J) {
+ i.push(0, 1, 0), o.push(J.x, 0, J.y), a.push((J.x - s.min.x) / s.width, (J.y - s.min.y) / s.height);
+ });
+ for (var d = new Array(), p = this.bjsEarcut(this._epoints, this._eholes, 2), y = 0; y < p.length; y++)
+ d.push(p[y]);
+ if (t > 0) {
+ var P = o.length / 3;
+ this._points.elements.forEach(function(J) {
+ i.push(0, -1, 0), o.push(J.x, -t, J.y), a.push(1 - (J.x - s.min.x) / s.width, 1 - (J.y - s.min.y) / s.height);
+ });
+ var R = d.length;
+ for (y = 0; y < R; y += 3) {
+ var B = d[y + 0], F = d[y + 1], z = d[y + 2];
+ d.push(z + P), d.push(F + P), d.push(B + P);
+ }
+ this.addSide(o, i, a, d, s, this._outlinepoints, t, !1), this._holes.forEach(function(J) {
+ e.addSide(o, i, a, d, s, J, t, !0);
+ });
+ }
+ return n.indices = d, n.positions = o, n.normals = i, n.uvs = a, n;
+ }, r.prototype.addSide = function(t, e, n, i, o, a, s, d) {
+ for (var p = t.length / 3, y = 0, P = 0; P < a.elements.length; P++) {
+ var R, B = a.elements[P];
+ R = P + 1 > a.elements.length - 1 ? a.elements[0] : a.elements[P + 1], t.push(B.x, 0, B.y), t.push(B.x, -s, B.y), t.push(R.x, 0, R.y), t.push(R.x, -s, R.y);
+ var F = new u.e(B.x, 0, B.y), z = new u.e(R.x, 0, R.y).subtract(F), J = new u.e(0, 1, 0), ie = u.e.Cross(z, J);
+ ie = ie.normalize(), n.push(y / o.width, 0), n.push(y / o.width, 1), y += z.length(), n.push(y / o.width, 0), n.push(y / o.width, 1), d ? (e.push(ie.x, ie.y, ie.z), e.push(ie.x, ie.y, ie.z), e.push(ie.x, ie.y, ie.z), e.push(ie.x, ie.y, ie.z), i.push(p), i.push(p + 2), i.push(p + 1), i.push(p + 1), i.push(p + 2), i.push(p + 3)) : (e.push(-ie.x, -ie.y, -ie.z), e.push(-ie.x, -ie.y, -ie.z), e.push(-ie.x, -ie.y, -ie.z), e.push(-ie.x, -ie.y, -ie.z), i.push(p), i.push(p + 1), i.push(p + 2), i.push(p + 1), i.push(p + 3), i.push(p + 2)), p += 4;
+ }
+ }, r;
+ }();
+ ht.a.CreatePolygon = function(r, t, e, n, i, o, a) {
+ for (var s = e || new Array(3), d = n, p = [], y = a || !1, P = 0; P < 3; P++)
+ s[P] === void 0 && (s[P] = new u.f(0, 0, 1, 1)), d && d[P] === void 0 && (d[P] = new I.b(1, 1, 1, 1));
+ var R = r.getVerticesData(Oe.b.PositionKind), B = r.getVerticesData(Oe.b.NormalKind), F = r.getVerticesData(Oe.b.UVKind), z = r.getIndices(), J = R.length / 9, ie = 0, se = 0, ce = 0, ue = 0, fe = [0];
+ if (y)
+ for (var ve = J; ve < R.length / 3; ve += 4)
+ se = R[3 * (ve + 2)] - R[3 * ve], ce = R[3 * (ve + 2) + 2] - R[3 * ve + 2], ue += Math.sqrt(se * se + ce * ce), fe.push(ue);
+ ve = 0;
+ for (var Te = 0, Re = 0; Re < B.length; Re += 3)
+ Math.abs(B[Re + 1]) < 1e-3 && (Te = 1), Math.abs(B[Re + 1] - 1) < 1e-3 && (Te = 0), Math.abs(B[Re + 1] + 1) < 1e-3 && (Te = 2), ve = Re / 3, Te === 1 ? (ie = ve - J, F[2 * ve] = ie % 4 < 1.5 ? y ? s[Te].x + (s[Te].z - s[Te].x) * fe[Math.floor(ie / 4)] / ue : s[Te].x : y ? s[Te].x + (s[Te].z - s[Te].x) * fe[Math.floor(ie / 4) + 1] / ue : s[Te].z, F[2 * ve + 1] = ie % 2 == 0 ? s[Te].w : s[Te].y) : (F[2 * ve] = (1 - F[2 * ve]) * s[Te].x + F[2 * ve] * s[Te].z, F[2 * ve + 1] = (1 - F[2 * ve + 1]) * s[Te].y + F[2 * ve + 1] * s[Te].w), d && p.push(d[Te].r, d[Te].g, d[Te].b, d[Te].a);
+ ht.a._ComputeSides(t, R, z, B, F, i, o);
+ var Ae = new ht.a();
+ if (Ae.indices = z, Ae.positions = R, Ae.normals = B, Ae.uvs = F, d) {
+ var Ee = t === ht.a.DOUBLESIDE ? p.concat(p) : p;
+ Ae.colors = Ee;
+ }
+ return Ae;
+ }, Ie.a.CreatePolygon = function(r, t, e, n, i, o, a) {
+ a === void 0 && (a = earcut);
+ var s = { shape: t, holes: n, updatable: i, sideOrientation: o };
+ return po.CreatePolygon(r, s, e, a);
+ }, Ie.a.ExtrudePolygon = function(r, t, e, n, i, o, a, s) {
+ s === void 0 && (s = earcut);
+ var d = { shape: t, holes: i, depth: e, updatable: o, sideOrientation: a };
+ return po.ExtrudePolygon(r, d, n, s);
+ };
+ var po = function() {
+ function r() {
+ }
+ return r.CreatePolygon = function(t, e, n, i) {
+ n === void 0 && (n = null), i === void 0 && (i = earcut), e.sideOrientation = Ie.a._GetDefaultSideOrientation(e.sideOrientation);
+ for (var o = e.shape, a = e.holes || [], s = e.depth || 0, d = [], p = [], y = 0; y < o.length; y++)
+ d[y] = new u.d(o[y].x, o[y].z);
+ d[0].equalsWithEpsilon(d[d.length - 1], 1e-8) && d.pop();
+ for (var P = new Jh(t, d, n || te.a.LastCreatedScene, i), R = 0; R < a.length; R++) {
+ p = [];
+ for (var B = 0; B < a[R].length; B++)
+ p.push(new u.d(a[R][B].x, a[R][B].z));
+ P.addHole(p);
+ }
+ var F = P.build(e.updatable, s);
+ return F._originalBuilderSideOrientation = e.sideOrientation, ht.a.CreatePolygon(F, e.sideOrientation, e.faceUV, e.faceColors, e.frontUVs, e.backUVs, e.wrap).applyToMesh(F, e.updatable), F;
+ }, r.ExtrudePolygon = function(t, e, n, i) {
+ return n === void 0 && (n = null), i === void 0 && (i = earcut), r.CreatePolygon(t, e, n, i);
+ }, r;
+ }();
+ Ie.a.CreateLathe = function(r, t, e, n, i, o, a) {
+ var s = { shape: t, radius: e, tessellation: n, sideOrientation: a, updatable: o };
+ return dc.CreateLathe(r, s, i);
+ };
+ var dc = function() {
+ function r() {
+ }
+ return r.CreateLathe = function(t, e, n) {
+ n === void 0 && (n = null);
+ var i, o = e.arc ? e.arc <= 0 || e.arc > 1 ? 1 : e.arc : 1, a = e.closed === void 0 || e.closed, s = e.shape, d = e.radius || 1, p = e.tessellation || 64, y = e.clip || 0, P = e.updatable, R = Ie.a._GetDefaultSideOrientation(e.sideOrientation), B = e.cap || Ie.a.NO_CAP, F = 2 * Math.PI, z = new Array(), J = e.invertUV || !1, ie = 0, se = 0, ce = F / p * o, ue = new Array();
+ for (ie = 0; ie <= p - y; ie++) {
+ for (ue = [], B != Ie.a.CAP_START && B != Ie.a.CAP_ALL || (ue.push(new u.e(0, s[0].y, 0)), ue.push(new u.e(Math.cos(ie * ce) * s[0].x * d, s[0].y, Math.sin(ie * ce) * s[0].x * d))), se = 0; se < s.length; se++)
+ i = new u.e(Math.cos(ie * ce) * s[se].x * d, s[se].y, Math.sin(ie * ce) * s[se].x * d), ue.push(i);
+ B != Ie.a.CAP_END && B != Ie.a.CAP_ALL || (ue.push(new u.e(Math.cos(ie * ce) * s[s.length - 1].x * d, s[s.length - 1].y, Math.sin(ie * ce) * s[s.length - 1].x * d)), ue.push(new u.e(0, s[s.length - 1].y, 0))), z.push(ue);
+ }
+ return fo.a.CreateRibbon(t, { pathArray: z, closeArray: a, sideOrientation: R, updatable: P, invertUV: J, frontUVs: e.frontUVs, backUVs: e.backUVs }, n);
+ }, r;
+ }();
+ ht.a.CreateTiledPlane = function(r) {
+ var t = r.pattern || Ie.a.NO_FLIP, e = r.tileWidth || r.tileSize || 1, n = r.tileHeight || r.tileSize || 1, i = r.alignHorizontal || 0, o = r.alignVertical || 0, a = r.width || r.size || 1, s = Math.floor(a / e), d = a - s * e, p = r.height || r.size || 1, y = Math.floor(p / n), P = p - y * n, R = e * s / 2, B = n * y / 2, F = 0, z = 0, J = 0, ie = 0, se = 0, ce = 0;
+ if (d > 0 || P > 0) {
+ switch (J = -R, ie = -B, se = R, ce = B, i) {
+ case Ie.a.CENTER:
+ J -= d /= 2, se += d;
+ break;
+ case Ie.a.LEFT:
+ se += d, F = -d / 2;
+ break;
+ case Ie.a.RIGHT:
+ J -= d, F = d / 2;
+ }
+ switch (o) {
+ case Ie.a.CENTER:
+ ie -= P /= 2, ce += P;
+ break;
+ case Ie.a.BOTTOM:
+ ce += P, z = -P / 2;
+ break;
+ case Ie.a.TOP:
+ ie -= P, z = P / 2;
+ }
+ }
+ var ue = [], fe = [], ve = [];
+ ve[0] = [0, 0, 1, 0, 1, 1, 0, 1], ve[1] = [0, 0, 1, 0, 1, 1, 0, 1], t !== Ie.a.ROTATE_TILE && t !== Ie.a.ROTATE_ROW || (ve[1] = [1, 1, 0, 1, 0, 0, 1, 0]), t !== Ie.a.FLIP_TILE && t !== Ie.a.FLIP_ROW || (ve[1] = [1, 0, 0, 0, 0, 1, 1, 1]), t !== Ie.a.FLIP_N_ROTATE_TILE && t !== Ie.a.FLIP_N_ROTATE_ROW || (ve[1] = [0, 1, 1, 1, 1, 0, 0, 0]);
+ for (var Te = [], Re = [], Ae = [], Ee = 0, Se = 0; Se < y; Se++)
+ for (var De = 0; De < s; De++)
+ ue.push(De * e - R + F, Se * n - B + z, 0), ue.push((De + 1) * e - R + F, Se * n - B + z, 0), ue.push((De + 1) * e - R + F, (Se + 1) * n - B + z, 0), ue.push(De * e - R + F, (Se + 1) * n - B + z, 0), Ae.push(Ee, Ee + 1, Ee + 3, Ee + 1, Ee + 2, Ee + 3), Te = t === Ie.a.FLIP_TILE || t === Ie.a.ROTATE_TILE || t === Ie.a.FLIP_N_ROTATE_TILE ? Te.concat(ve[(De % 2 + Se % 2) % 2]) : t === Ie.a.FLIP_ROW || t === Ie.a.ROTATE_ROW || t === Ie.a.FLIP_N_ROTATE_ROW ? Te.concat(ve[Se % 2]) : Te.concat(ve[0]), Re.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), fe.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1), Ee += 4;
+ if (d > 0 || P > 0) {
+ var xe, Le, Me, we, Ye = P > 0 && (o === Ie.a.CENTER || o === Ie.a.TOP), et = P > 0 && (o === Ie.a.CENTER || o === Ie.a.BOTTOM), nt = d > 0 && (i === Ie.a.CENTER || i === Ie.a.RIGHT), ct = d > 0 && (i === Ie.a.CENTER || i === Ie.a.LEFT), Ke = [];
+ if (Ye && nt && (ue.push(J + F, ie + z, 0), ue.push(-R + F, ie + z, 0), ue.push(-R + F, ie + P + z, 0), ue.push(J + F, ie + P + z, 0), Ae.push(Ee, Ee + 1, Ee + 3, Ee + 1, Ee + 2, Ee + 3), Ee += 4, Ke = [xe = 1 - d / e, Le = 1 - P / n, Me = 1, Le, Me, we = 1, xe, we], t === Ie.a.ROTATE_ROW && (Ke = [1 - xe, 1 - Le, 1 - Me, 1 - Le, 1 - Me, 1 - we, 1 - xe, 1 - we]), t === Ie.a.FLIP_ROW && (Ke = [1 - xe, Le, 1 - Me, Le, 1 - Me, we, 1 - xe, we]), t === Ie.a.FLIP_N_ROTATE_ROW && (Ke = [xe, 1 - Le, Me, 1 - Le, Me, 1 - we, xe, 1 - we]), Te = Te.concat(Ke), Re.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), fe.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)), Ye && ct && (ue.push(R + F, ie + z, 0), ue.push(se + F, ie + z, 0), ue.push(se + F, ie + P + z, 0), ue.push(R + F, ie + P + z, 0), Ae.push(Ee, Ee + 1, Ee + 3, Ee + 1, Ee + 2, Ee + 3), Ee += 4, Ke = [xe = 0, Le = 1 - P / n, Me = d / e, Le, Me, we = 1, xe, we], (t === Ie.a.ROTATE_ROW || t === Ie.a.ROTATE_TILE && s % 2 == 0) && (Ke = [1 - xe, 1 - Le, 1 - Me, 1 - Le, 1 - Me, 1 - we, 1 - xe, 1 - we]), (t === Ie.a.FLIP_ROW || t === Ie.a.FLIP_TILE && s % 2 == 0) && (Ke = [1 - xe, Le, 1 - Me, Le, 1 - Me, we, 1 - xe, we]), (t === Ie.a.FLIP_N_ROTATE_ROW || t === Ie.a.FLIP_N_ROTATE_TILE && s % 2 == 0) && (Ke = [xe, 1 - Le, Me, 1 - Le, Me, 1 - we, xe, 1 - we]), Te = Te.concat(Ke), Re.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), fe.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)), et && nt && (ue.push(J + F, B + z, 0), ue.push(-R + F, B + z, 0), ue.push(-R + F, ce + z, 0), ue.push(J + F, ce + z, 0), Ae.push(Ee, Ee + 1, Ee + 3, Ee + 1, Ee + 2, Ee + 3), Ee += 4, Ke = [xe = 1 - d / e, Le = 0, Me = 1, Le, Me, we = P / n, xe, we], (t === Ie.a.ROTATE_ROW && y % 2 == 1 || t === Ie.a.ROTATE_TILE && y % 1 == 0) && (Ke = [1 - xe, 1 - Le, 1 - Me, 1 - Le, 1 - Me, 1 - we, 1 - xe, 1 - we]), (t === Ie.a.FLIP_ROW && y % 2 == 1 || t === Ie.a.FLIP_TILE && y % 2 == 0) && (Ke = [1 - xe, Le, 1 - Me, Le, 1 - Me, we, 1 - xe, we]), (t === Ie.a.FLIP_N_ROTATE_ROW && y % 2 == 1 || t === Ie.a.FLIP_N_ROTATE_TILE && y % 2 == 0) && (Ke = [xe, 1 - Le, Me, 1 - Le, Me, 1 - we, xe, 1 - we]), Te = Te.concat(Ke), Re.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), fe.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)), et && ct && (ue.push(R + F, B + z, 0), ue.push(se + F, B + z, 0), ue.push(se + F, ce + z, 0), ue.push(R + F, ce + z, 0), Ae.push(Ee, Ee + 1, Ee + 3, Ee + 1, Ee + 2, Ee + 3), Ee += 4, Ke = [xe = 0, Le = 0, Me = d / e, Le, Me, we = P / n, xe, we], (t === Ie.a.ROTATE_ROW && y % 2 == 1 || t === Ie.a.ROTATE_TILE && (y + s) % 2 == 1) && (Ke = [1 - xe, 1 - Le, 1 - Me, 1 - Le, 1 - Me, 1 - we, 1 - xe, 1 - we]), (t === Ie.a.FLIP_ROW && y % 2 == 1 || t === Ie.a.FLIP_TILE && (y + s) % 2 == 1) && (Ke = [1 - xe, Le, 1 - Me, Le, 1 - Me, we, 1 - xe, we]), (t === Ie.a.FLIP_N_ROTATE_ROW && y % 2 == 1 || t === Ie.a.FLIP_N_ROTATE_TILE && (y + s) % 2 == 1) && (Ke = [xe, 1 - Le, Me, 1 - Le, Me, 1 - we, xe, 1 - we]), Te = Te.concat(Ke), Re.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), fe.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)), Ye) {
+ var rt = [];
+ for (xe = 0, Le = 1 - P / n, Me = 1, we = 1, rt[0] = [xe, Le, Me, Le, Me, we, xe, we], rt[1] = [xe, Le, Me, Le, Me, we, xe, we], t !== Ie.a.ROTATE_TILE && t !== Ie.a.ROTATE_ROW || (rt[1] = [1 - xe, 1 - Le, 1 - Me, 1 - Le, 1 - Me, 1 - we, 1 - xe, 1 - we]), t !== Ie.a.FLIP_TILE && t !== Ie.a.FLIP_ROW || (rt[1] = [1 - xe, Le, 1 - Me, Le, 1 - Me, we, 1 - xe, we]), t !== Ie.a.FLIP_N_ROTATE_TILE && t !== Ie.a.FLIP_N_ROTATE_ROW || (rt[1] = [xe, 1 - Le, Me, 1 - Le, Me, 1 - we, xe, 1 - we]), De = 0; De < s; De++)
+ ue.push(De * e - R + F, ie + z, 0), ue.push((De + 1) * e - R + F, ie + z, 0), ue.push((De + 1) * e - R + F, ie + P + z, 0), ue.push(De * e - R + F, ie + P + z, 0), Ae.push(Ee, Ee + 1, Ee + 3, Ee + 1, Ee + 2, Ee + 3), Ee += 4, Te = t === Ie.a.FLIP_TILE || t === Ie.a.ROTATE_TILE || t === Ie.a.FLIP_N_ROTATE_TILE ? Te.concat(rt[(De + 1) % 2]) : t === Ie.a.FLIP_ROW || t === Ie.a.ROTATE_ROW || t === Ie.a.FLIP_N_ROTATE_ROW ? Te.concat(rt[1]) : Te.concat(rt[0]), Re.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), fe.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1);
+ }
+ if (et) {
+ var it = [];
+ for (xe = 0, Le = 0, Me = 1, we = P / n, it[0] = [xe, Le, Me, Le, Me, we, xe, we], it[1] = [xe, Le, Me, Le, Me, we, xe, we], t !== Ie.a.ROTATE_TILE && t !== Ie.a.ROTATE_ROW || (it[1] = [1 - xe, 1 - Le, 1 - Me, 1 - Le, 1 - Me, 1 - we, 1 - xe, 1 - we]), t !== Ie.a.FLIP_TILE && t !== Ie.a.FLIP_ROW || (it[1] = [1 - xe, Le, 1 - Me, Le, 1 - Me, we, 1 - xe, we]), t !== Ie.a.FLIP_N_ROTATE_TILE && t !== Ie.a.FLIP_N_ROTATE_ROW || (it[1] = [xe, 1 - Le, Me, 1 - Le, Me, 1 - we, xe, 1 - we]), De = 0; De < s; De++)
+ ue.push(De * e - R + F, ce - P + z, 0), ue.push((De + 1) * e - R + F, ce - P + z, 0), ue.push((De + 1) * e - R + F, ce + z, 0), ue.push(De * e - R + F, ce + z, 0), Ae.push(Ee, Ee + 1, Ee + 3, Ee + 1, Ee + 2, Ee + 3), Ee += 4, Te = t === Ie.a.FLIP_TILE || t === Ie.a.ROTATE_TILE || t === Ie.a.FLIP_N_ROTATE_TILE ? Te.concat(it[(De + y) % 2]) : t === Ie.a.FLIP_ROW || t === Ie.a.ROTATE_ROW || t === Ie.a.FLIP_N_ROTATE_ROW ? Te.concat(it[y % 2]) : Te.concat(it[0]), Re.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), fe.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1);
+ }
+ if (nt) {
+ var qe = [];
+ for (xe = 1 - d / e, Le = 0, Me = 1, we = 1, qe[0] = [xe, Le, Me, Le, Me, we, xe, we], qe[1] = [xe, Le, Me, Le, Me, we, xe, we], t !== Ie.a.ROTATE_TILE && t !== Ie.a.ROTATE_ROW || (qe[1] = [1 - xe, 1 - Le, 1 - Me, 1 - Le, 1 - Me, 1 - we, 1 - xe, 1 - we]), t !== Ie.a.FLIP_TILE && t !== Ie.a.FLIP_ROW || (qe[1] = [1 - xe, Le, 1 - Me, Le, 1 - Me, we, 1 - xe, we]), t !== Ie.a.FLIP_N_ROTATE_TILE && t !== Ie.a.FLIP_N_ROTATE_ROW || (qe[1] = [xe, 1 - Le, Me, 1 - Le, Me, 1 - we, xe, 1 - we]), Se = 0; Se < y; Se++)
+ ue.push(J + F, Se * n - B + z, 0), ue.push(J + d + F, Se * n - B + z, 0), ue.push(J + d + F, (Se + 1) * n - B + z, 0), ue.push(J + F, (Se + 1) * n - B + z, 0), Ae.push(Ee, Ee + 1, Ee + 3, Ee + 1, Ee + 2, Ee + 3), Ee += 4, Te = t === Ie.a.FLIP_TILE || t === Ie.a.ROTATE_TILE || t === Ie.a.FLIP_N_ROTATE_TILE ? Te.concat(qe[(Se + 1) % 2]) : t === Ie.a.FLIP_ROW || t === Ie.a.ROTATE_ROW || t === Ie.a.FLIP_N_ROTATE_ROW ? Te.concat(qe[Se % 2]) : Te.concat(qe[0]), Re.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), fe.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1);
+ }
+ if (ct) {
+ var ut = [];
+ for (xe = 0, Le = 0, Me = d / n, we = 1, ut[0] = [xe, Le, Me, Le, Me, we, xe, we], ut[1] = [xe, Le, Me, Le, Me, we, xe, we], t !== Ie.a.ROTATE_TILE && t !== Ie.a.ROTATE_ROW || (ut[1] = [1 - xe, 1 - Le, 1 - Me, 1 - Le, 1 - Me, 1 - we, 1 - xe, 1 - we]), t !== Ie.a.FLIP_TILE && t !== Ie.a.FLIP_ROW || (ut[1] = [1 - xe, Le, 1 - Me, Le, 1 - Me, we, 1 - xe, we]), t !== Ie.a.FLIP_N_ROTATE_TILE && t !== Ie.a.FLIP_N_ROTATE_ROW || (ut[1] = [xe, 1 - Le, Me, 1 - Le, Me, 1 - we, xe, 1 - we]), Se = 0; Se < y; Se++)
+ ue.push(se - d + F, Se * n - B + z, 0), ue.push(se + F, Se * n - B + z, 0), ue.push(se + F, (Se + 1) * n - B + z, 0), ue.push(se - d + F, (Se + 1) * n - B + z, 0), Ae.push(Ee, Ee + 1, Ee + 3, Ee + 1, Ee + 2, Ee + 3), Ee += 4, Te = t === Ie.a.FLIP_TILE || t === Ie.a.ROTATE_TILE || t === Ie.a.FLIP_N_ROTATE_TILE ? Te.concat(ut[(Se + s) % 2]) : t === Ie.a.FLIP_ROW || t === Ie.a.ROTATE_ROW || t === Ie.a.FLIP_N_ROTATE_ROW ? Te.concat(ut[Se % 2]) : Te.concat(ut[0]), Re.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), fe.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1);
+ }
+ }
+ var Ve = r.sideOrientation === 0 ? 0 : r.sideOrientation || ht.a.DEFAULTSIDE;
+ ht.a._ComputeSides(Ve, ue, Ae, fe, Te, r.frontUVs, r.backUVs);
+ var Ze = new ht.a();
+ Ze.indices = Ae, Ze.positions = ue, Ze.normals = fe, Ze.uvs = Te;
+ var vt = Ve === ht.a.DOUBLESIDE ? Re.concat(Re) : Re;
+ return Ze.colors = vt, Ze;
+ };
+ var $h = function() {
+ function r() {
+ }
+ return r.CreateTiledPlane = function(t, e, n) {
+ n === void 0 && (n = null);
+ var i = new Ie.a(t, n);
+ return e.sideOrientation = Ie.a._GetDefaultSideOrientation(e.sideOrientation), i._originalBuilderSideOrientation = e.sideOrientation, ht.a.CreateTiledPlane(e).applyToMesh(i, e.updatable), i;
+ }, r;
+ }();
+ Ie.a.CreateTube = function(r, t, e, n, i, o, a, s, d, p) {
+ var y = { path: t, radius: e, tessellation: n, radiusFunction: i, arc: 1, cap: o, updatable: s, sideOrientation: d, instance: p };
+ return fc.CreateTube(r, y, a);
+ };
+ var fc = function() {
+ function r() {
+ }
+ return r.CreateTube = function(t, e, n) {
+ n === void 0 && (n = null);
+ var i = e.path, o = e.instance, a = 1;
+ e.radius !== void 0 ? a = e.radius : o && (a = o._creationDataStorage.radius);
+ var s = e.tessellation || 64, d = e.radiusFunction || null, p = e.cap || Ie.a.NO_CAP, y = e.invertUV || !1, P = e.updatable, R = Ie.a._GetDefaultSideOrientation(e.sideOrientation);
+ e.arc = e.arc && (e.arc <= 0 || e.arc > 1) ? 1 : e.arc || 1;
+ var B, F, z = function(ce, ue, fe, ve, Te, Re, Ae, Ee) {
+ for (var Se, De, xe, Le, Me = ue.getTangents(), we = ue.getNormals(), Ye = ue.getDistances(), et = 2 * Math.PI / Te * Ee, nt = Re || function() {
+ return ve;
+ }, ct = u.c.Matrix[0], Ke = Ae === Ie.a.NO_CAP || Ae === Ie.a.CAP_END ? 0 : 2, rt = 0; rt < ce.length; rt++) {
+ De = nt(rt, Ye[rt]), Se = Array(), xe = we[rt];
+ for (var it = 0; it < Te; it++)
+ u.a.RotationAxisToRef(Me[rt], et * it, ct), Le = Se[it] ? Se[it] : u.e.Zero(), u.e.TransformCoordinatesToRef(xe, ct, Le), Le.scaleInPlace(De).addInPlace(ce[rt]), Se[it] = Le;
+ fe[Ke] = Se, Ke++;
+ }
+ var qe = function(ut, Ve) {
+ for (var Ze = Array(), vt = 0; vt < ut; vt++)
+ Ze.push(ce[Ve]);
+ return Ze;
+ };
+ switch (Ae) {
+ case Ie.a.NO_CAP:
+ break;
+ case Ie.a.CAP_START:
+ fe[0] = qe(Te, 0), fe[1] = fe[2].slice(0);
+ break;
+ case Ie.a.CAP_END:
+ fe[Ke] = fe[Ke - 1].slice(0), fe[Ke + 1] = qe(Te, ce.length - 1);
+ break;
+ case Ie.a.CAP_ALL:
+ fe[0] = qe(Te, 0), fe[1] = fe[2].slice(0), fe[Ke] = fe[Ke - 1].slice(0), fe[Ke + 1] = qe(Te, ce.length - 1);
+ }
+ return fe;
+ };
+ if (o) {
+ var J = o._creationDataStorage, ie = e.arc || J.arc;
+ return F = z(i, B = J.path3D.update(i), J.pathArray, a, J.tessellation, d, J.cap, ie), o = fo.a.CreateRibbon("", { pathArray: F, instance: o }), J.path3D = B, J.pathArray = F, J.arc = ie, J.radius = a, o;
+ }
+ F = z(i, B = new Qe.g(i), new Array(), a, s, d, p = p < 0 || p > 3 ? 0 : p, e.arc);
+ var se = fo.a.CreateRibbon(t, { pathArray: F, closePath: !0, closeArray: !1, updatable: P, sideOrientation: R, invertUV: y, frontUVs: e.frontUVs, backUVs: e.backUVs }, n);
+ return se._creationDataStorage.pathArray = F, se._creationDataStorage.path3D = B, se._creationDataStorage.tessellation = s, se._creationDataStorage.cap = p, se._creationDataStorage.arc = e.arc, se._creationDataStorage.radius = a, se;
+ }, r;
+ }();
+ ht.a.CreateIcoSphere = function(r) {
+ var t, e = r.sideOrientation || ht.a.DEFAULTSIDE, n = r.radius || 1, i = r.flat === void 0 || r.flat, o = r.subdivisions || 4, a = r.radiusX || n, s = r.radiusY || n, d = r.radiusZ || n, p = (1 + Math.sqrt(5)) / 2, y = [-1, p, -0, 1, p, 0, -1, -p, 0, 1, -p, 0, 0, -1, -p, 0, 1, -p, 0, -1, p, 0, 1, p, p, 0, 1, p, 0, -1, -p, 0, 1, -p, 0, -1], P = [0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 12, 22, 23, 1, 5, 20, 5, 11, 4, 23, 22, 13, 22, 18, 6, 7, 1, 8, 14, 21, 4, 14, 4, 2, 16, 13, 6, 15, 6, 19, 3, 8, 9, 4, 21, 5, 13, 17, 23, 6, 13, 22, 19, 6, 18, 9, 8, 1], R = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 2, 3, 3, 3, 4, 7, 8, 9, 9, 10, 11], B = [5, 1, 3, 1, 6, 4, 0, 0, 5, 3, 4, 2, 2, 2, 4, 0, 2, 0, 1, 1, 6, 0, 6, 2, 0, 4, 3, 3, 4, 4, 3, 1, 4, 2, 4, 4, 0, 2, 1, 1, 2, 2, 3, 3, 1, 3, 2, 4], F = [0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0], z = new Array(), J = new Array(), ie = new Array(), se = new Array(), ce = 0, ue = new Array(3), fe = new Array(3);
+ for (t = 0; t < 3; t++)
+ ue[t] = u.e.Zero(), fe[t] = u.d.Zero();
+ for (var ve = 0; ve < 20; ve++) {
+ for (t = 0; t < 3; t++) {
+ var Te = P[3 * ve + t];
+ ue[t].copyFromFloats(y[3 * R[Te]], y[3 * R[Te] + 1], y[3 * R[Te] + 2]), ue[t].normalize().scaleInPlace(n), fe[t].copyFromFloats(B[2 * Te] * (138 / 1024) + 60 / 1024 + F[ve] * (-40 / 1024), B[2 * Te + 1] * (239 / 1024) + 26 / 1024 + F[ve] * (20 / 1024));
+ }
+ for (var Re = function(De, xe, Le, Me) {
+ var we, Ye = u.e.Lerp(ue[0], ue[2], xe / o), et = u.e.Lerp(ue[1], ue[2], xe / o), nt = o === xe ? ue[2] : u.e.Lerp(Ye, et, De / (o - xe));
+ if (nt.normalize(), i) {
+ var ct = u.e.Lerp(ue[0], ue[2], Me / o), Ke = u.e.Lerp(ue[1], ue[2], Me / o);
+ we = u.e.Lerp(ct, Ke, Le / (o - Me));
+ } else
+ we = new u.e(nt.x, nt.y, nt.z);
+ we.x /= a, we.y /= s, we.z /= d, we.normalize();
+ var rt = u.d.Lerp(fe[0], fe[2], xe / o), it = u.d.Lerp(fe[1], fe[2], xe / o), qe = o === xe ? fe[2] : u.d.Lerp(rt, it, De / (o - xe));
+ J.push(nt.x * a, nt.y * s, nt.z * d), ie.push(we.x, we.y, we.z), se.push(qe.x, qe.y), z.push(ce), ce++;
+ }, Ae = 0; Ae < o; Ae++)
+ for (var Ee = 0; Ee + Ae < o; Ee++)
+ Re(Ee, Ae, Ee + 1 / 3, Ae + 1 / 3), Re(Ee + 1, Ae, Ee + 1 / 3, Ae + 1 / 3), Re(Ee, Ae + 1, Ee + 1 / 3, Ae + 1 / 3), Ee + Ae + 1 < o && (Re(Ee + 1, Ae, Ee + 2 / 3, Ae + 2 / 3), Re(Ee + 1, Ae + 1, Ee + 2 / 3, Ae + 2 / 3), Re(Ee, Ae + 1, Ee + 2 / 3, Ae + 2 / 3));
+ }
+ ht.a._ComputeSides(e, J, z, ie, se, r.frontUVs, r.backUVs);
+ var Se = new ht.a();
+ return Se.indices = z, Se.positions = J, Se.normals = ie, Se.uvs = se, Se;
+ }, Ie.a.CreateIcoSphere = function(r, t, e) {
+ return pc.CreateIcoSphere(r, t, e);
+ };
+ var pc = function() {
+ function r() {
+ }
+ return r.CreateIcoSphere = function(t, e, n) {
+ n === void 0 && (n = null);
+ var i = new Ie.a(t, n);
+ return e.sideOrientation = Ie.a._GetDefaultSideOrientation(e.sideOrientation), i._originalBuilderSideOrientation = e.sideOrientation, ht.a.CreateIcoSphere(e).applyToMesh(i, e.updatable), i;
+ }, r;
+ }();
+ Ie.a.CreateDecal = function(r, t, e, n, i, o) {
+ var a = { position: e, normal: n, size: i, angle: o };
+ return _c.CreateDecal(r, t, a);
+ };
+ var _c = function() {
+ function r() {
+ }
+ return r.CreateDecal = function(t, e, n) {
+ var i = e.getIndices(), o = e.getVerticesData(Oe.b.PositionKind), a = e.getVerticesData(Oe.b.NormalKind), s = n.position || u.e.Zero(), d = n.normal || u.e.Up(), p = n.size || u.e.One(), y = n.angle || 0;
+ if (!d) {
+ var P = new u.e(0, 0, 1), R = e.getScene().activeCamera, B = u.e.TransformCoordinates(P, R.getWorldMatrix());
+ d = R.globalPosition.subtract(B);
+ }
+ var F = -Math.atan2(d.z, d.x) - Math.PI / 2, z = Math.sqrt(d.x * d.x + d.z * d.z), J = Math.atan2(d.y, z), ie = u.a.RotationYawPitchRoll(F, J, y).multiply(u.a.Translation(s.x, s.y, s.z)), se = u.a.Invert(ie), ce = e.getWorldMatrix().multiply(se), ue = new ht.a();
+ ue.indices = [], ue.positions = [], ue.normals = [], ue.uvs = [];
+ for (var fe = 0, ve = function(xe) {
+ var Le = new bs();
+ if (!i || !o || !a)
+ return Le;
+ var Me = i[xe];
+ return Le.position = new u.e(o[3 * Me], o[3 * Me + 1], o[3 * Me + 2]), Le.position = u.e.TransformCoordinates(Le.position, ce), Le.normal = new u.e(a[3 * Me], a[3 * Me + 1], a[3 * Me + 2]), Le.normal = u.e.TransformNormal(Le.normal, ce), Le;
+ }, Te = function(xe, Le) {
+ if (xe.length === 0)
+ return xe;
+ for (var Me = 0.5 * Math.abs(u.e.Dot(p, Le)), we = function(Ve, Ze) {
+ var vt = u.e.GetClipFactor(Ve.position, Ze.position, Le, Me);
+ return new bs(u.e.Lerp(Ve.position, Ze.position, vt), u.e.Lerp(Ve.normal, Ze.normal, vt));
+ }, Ye = new Array(), et = 0; et < xe.length; et += 3) {
+ var nt, ct, Ke, rt = null, it = null, qe = null, ut = null;
+ switch (((nt = u.e.Dot(xe[et].position, Le) - Me > 0) ? 1 : 0) + ((ct = u.e.Dot(xe[et + 1].position, Le) - Me > 0) ? 1 : 0) + ((Ke = u.e.Dot(xe[et + 2].position, Le) - Me > 0) ? 1 : 0)) {
+ case 0:
+ Ye.push(xe[et]), Ye.push(xe[et + 1]), Ye.push(xe[et + 2]);
+ break;
+ case 1:
+ if (nt && (rt = xe[et + 1], it = xe[et + 2], qe = we(xe[et], rt), ut = we(xe[et], it)), ct) {
+ rt = xe[et], it = xe[et + 2], qe = we(xe[et + 1], rt), ut = we(xe[et + 1], it), Ye.push(qe), Ye.push(it.clone()), Ye.push(rt.clone()), Ye.push(it.clone()), Ye.push(qe.clone()), Ye.push(ut);
+ break;
+ }
+ Ke && (rt = xe[et], it = xe[et + 1], qe = we(xe[et + 2], rt), ut = we(xe[et + 2], it)), rt && it && qe && ut && (Ye.push(rt.clone()), Ye.push(it.clone()), Ye.push(qe), Ye.push(ut), Ye.push(qe.clone()), Ye.push(it.clone()));
+ break;
+ case 2:
+ nt || (it = we(rt = xe[et].clone(), xe[et + 1]), qe = we(rt, xe[et + 2]), Ye.push(rt), Ye.push(it), Ye.push(qe)), ct || (it = we(rt = xe[et + 1].clone(), xe[et + 2]), qe = we(rt, xe[et]), Ye.push(rt), Ye.push(it), Ye.push(qe)), Ke || (it = we(rt = xe[et + 2].clone(), xe[et]), qe = we(rt, xe[et + 1]), Ye.push(rt), Ye.push(it), Ye.push(qe));
+ }
+ }
+ return Ye;
+ }, Re = 0; Re < i.length; Re += 3) {
+ var Ae = new Array();
+ if (Ae.push(ve(Re)), Ae.push(ve(Re + 1)), Ae.push(ve(Re + 2)), Ae = Te(Ae, new u.e(1, 0, 0)), Ae = Te(Ae, new u.e(-1, 0, 0)), Ae = Te(Ae, new u.e(0, 1, 0)), Ae = Te(Ae, new u.e(0, -1, 0)), Ae = Te(Ae, new u.e(0, 0, 1)), (Ae = Te(Ae, new u.e(0, 0, -1))).length !== 0)
+ for (var Ee = 0; Ee < Ae.length; Ee++) {
+ var Se = Ae[Ee];
+ ue.indices.push(fe), Se.position.toArray(ue.positions, 3 * fe), Se.normal.toArray(ue.normals, 3 * fe), ue.uvs.push(0.5 + Se.position.x / p.x), ue.uvs.push(0.5 + Se.position.y / p.y), fe++;
+ }
+ }
+ var De = new Ie.a(t, e.getScene());
+ return ue.applyToMesh(De), De.position = s.clone(), De.rotation = new u.e(J, F, y), De;
+ }, r;
+ }();
+ ht.a.CreateCapsule = function(r) {
+ r === void 0 && (r = { subdivisions: 2, tessellation: 16, height: 1, radius: 0.25, capSubdivisions: 6 });
+ var t, e, n = Math.max(r.subdivisions ? r.subdivisions : 2, 1), i = Math.max(r.tessellation ? r.tessellation : 16, 3), o = Math.max(r.height ? r.height : 1, 0), a = Math.max(r.radius ? r.radius : 0.25, 0), s = Math.max(r.capSubdivisions ? r.capSubdivisions : 6, 1), d = i, p = n, y = Math.max(r.radiusTop ? r.radiusTop : a, 0), P = Math.max(r.radiusBottom ? r.radiusBottom : a, 0), R = o - (y + P), B = 2 * Math.PI, F = Math.max(r.topCapSubdivisions ? r.topCapSubdivisions : s, 1), z = Math.max(r.bottomCapSubdivisions ? r.bottomCapSubdivisions : s, 1), J = Math.acos((P - y) / o), ie = [], se = [], ce = [], ue = [], fe = 0, ve = [], Te = 0.5 * R, Re = 0.5 * Math.PI, Ae = u.e.Zero(), Ee = u.e.Zero(), Se = Math.cos(J), De = Math.sin(J), xe = new u.d(y * De, Te + y * Se).subtract(new u.d(P * De, P * Se - Te)).length(), Le = y * J + xe + P * (Re - J), Me = 0;
+ for (e = 0; e <= F; e++) {
+ var we = [], Ye = Re - J * (e / F);
+ Me += y * J / F;
+ var et = Math.cos(Ye), nt = Math.sin(Ye), ct = et * y;
+ for (t = 0; t <= d; t++) {
+ var Ke = (Ve = t / d) * B + 0, rt = Math.sin(Ke), it = Math.cos(Ke);
+ Ee.x = ct * rt, Ee.y = Te + nt * y, Ee.z = ct * it, se.push(Ee.x, Ee.y, Ee.z), Ae.set(et * rt, nt, et * it), ce.push(Ae.x, Ae.y, Ae.z), ue.push(Ve, 1 - Me / Le), we.push(fe), fe++;
+ }
+ ve.push(we);
+ }
+ var qe = o - y - P + Se * y - Se * P, ut = De * (P - y) / qe;
+ for (e = 1; e <= p; e++) {
+ for (we = [], Me += xe / p, ct = De * (e * (P - y) / p + y), t = 0; t <= d; t++)
+ Ke = (Ve = t / d) * B + 0, rt = Math.sin(Ke), it = Math.cos(Ke), Ee.x = ct * rt, Ee.y = Te + Se * y - e * qe / p, Ee.z = ct * it, se.push(Ee.x, Ee.y, Ee.z), Ae.set(rt, ut, it).normalize(), ce.push(Ae.x, Ae.y, Ae.z), ue.push(Ve, 1 - Me / Le), we.push(fe), fe++;
+ ve.push(we);
+ }
+ for (e = 1; e <= z; e++) {
+ for (we = [], Ye = Re - J - (Math.PI - J) * (e / z), Me += P * J / z, et = Math.cos(Ye), nt = Math.sin(Ye), ct = et * P, t = 0; t <= d; t++) {
+ var Ve;
+ Ke = (Ve = t / d) * B + 0, rt = Math.sin(Ke), it = Math.cos(Ke), Ee.x = ct * rt, Ee.y = nt * P - Te, Ee.z = ct * it, se.push(Ee.x, Ee.y, Ee.z), Ae.set(et * rt, nt, et * it), ce.push(Ae.x, Ae.y, Ae.z), ue.push(Ve, 1 - Me / Le), we.push(fe), fe++;
+ }
+ ve.push(we);
+ }
+ for (t = 0; t < d; t++)
+ for (e = 0; e < F + p + z; e++) {
+ var Ze = ve[e][t], vt = ve[e + 1][t], jt = ve[e + 1][t + 1], Dt = ve[e][t + 1];
+ ie.push(Ze), ie.push(vt), ie.push(Dt), ie.push(vt), ie.push(jt), ie.push(Dt);
+ }
+ if (ie = ie.reverse(), r.orientation && !r.orientation.equals(u.e.Up())) {
+ var Yt = new u.a();
+ r.orientation.clone().scale(0.5 * Math.PI).cross(u.e.Up()).toQuaternion().toRotationMatrix(Yt);
+ for (var mt = u.e.Zero(), qt = 0; qt < se.length; qt += 3)
+ mt.set(se[qt], se[qt + 1], se[qt + 2]), u.e.TransformCoordinatesToRef(mt.clone(), Yt, mt), se[qt] = mt.x, se[qt + 1] = mt.y, se[qt + 2] = mt.z;
+ }
+ var Ht = new ht.a();
+ return Ht.positions = se, Ht.normals = ce, Ht.uvs = ue, Ht.indices = ie, Ht;
+ }, Ie.a.CreateCapsule = function(r, t, e) {
+ return mc.CreateCapsule(r, t, e);
+ };
+ var _o, mc = function() {
+ function r() {
+ }
+ return r.CreateCapsule = function(t, e, n) {
+ e === void 0 && (e = { orientation: u.e.Up(), subdivisions: 2, tessellation: 16, height: 1, radius: 0.25, capSubdivisions: 6 });
+ var i = new Ie.a(t, n);
+ return ht.a.CreateCapsule(e).applyToMesh(i), i;
+ }, r;
+ }(), im = function() {
+ function r() {
+ }
+ return r.CreateBox = function(t, e, n) {
+ return n === void 0 && (n = null), fr.a.CreateBox(t, e, n);
+ }, r.CreateTiledBox = function(t, e, n) {
+ return n === void 0 && (n = null), Zh.CreateTiledBox(t, e, n);
+ }, r.CreateSphere = function(t, e, n) {
+ return n === void 0 && (n = null), Nn.a.CreateSphere(t, e, n);
+ }, r.CreateDisc = function(t, e, n) {
+ return n === void 0 && (n = null), ha.CreateDisc(t, e, n);
+ }, r.CreateIcoSphere = function(t, e, n) {
+ return n === void 0 && (n = null), pc.CreateIcoSphere(t, e, n);
+ }, r.CreateRibbon = function(t, e, n) {
+ return n === void 0 && (n = null), fo.a.CreateRibbon(t, e, n);
+ }, r.CreateCylinder = function(t, e, n) {
+ return n === void 0 && (n = null), ci.a.CreateCylinder(t, e, n);
+ }, r.CreateTorus = function(t, e, n) {
+ return n === void 0 && (n = null), lr.CreateTorus(t, e, n);
+ }, r.CreateTorusKnot = function(t, e, n) {
+ return n === void 0 && (n = null), uc.CreateTorusKnot(t, e, n);
+ }, r.CreateLineSystem = function(t, e, n) {
+ return sn.a.CreateLineSystem(t, e, n);
+ }, r.CreateLines = function(t, e, n) {
+ return n === void 0 && (n = null), sn.a.CreateLines(t, e, n);
+ }, r.CreateDashedLines = function(t, e, n) {
+ return n === void 0 && (n = null), sn.a.CreateDashedLines(t, e, n);
+ }, r.ExtrudeShape = function(t, e, n) {
+ return n === void 0 && (n = null), Jo.a.ExtrudeShape(t, e, n);
+ }, r.ExtrudeShapeCustom = function(t, e, n) {
+ return n === void 0 && (n = null), Jo.a.ExtrudeShapeCustom(t, e, n);
+ }, r.CreateLathe = function(t, e, n) {
+ return n === void 0 && (n = null), dc.CreateLathe(t, e, n);
+ }, r.CreateTiledPlane = function(t, e, n) {
+ return n === void 0 && (n = null), $h.CreateTiledPlane(t, e, n);
+ }, r.CreatePlane = function(t, e, n) {
+ return n === void 0 && (n = null), gs.a.CreatePlane(t, e, n);
+ }, r.CreateGround = function(t, e, n) {
+ return n === void 0 && (n = null), Oi.CreateGround(t, e, n);
+ }, r.CreateTiledGround = function(t, e, n) {
+ return n === void 0 && (n = null), Oi.CreateTiledGround(t, e, n);
+ }, r.CreateGroundFromHeightMap = function(t, e, n, i) {
+ return i === void 0 && (i = null), Oi.CreateGroundFromHeightMap(t, e, n, i);
+ }, r.CreatePolygon = function(t, e, n, i) {
+ return n === void 0 && (n = null), i === void 0 && (i = earcut), po.CreatePolygon(t, e, n, i);
+ }, r.ExtrudePolygon = function(t, e, n, i) {
+ return n === void 0 && (n = null), i === void 0 && (i = earcut), po.ExtrudePolygon(t, e, n, i);
+ }, r.CreateTube = function(t, e, n) {
+ return n === void 0 && (n = null), fc.CreateTube(t, e, n);
+ }, r.CreatePolyhedron = function(t, e, n) {
+ return n === void 0 && (n = null), Qr.CreatePolyhedron(t, e, n);
+ }, r.CreateDecal = function(t, e, n) {
+ return _c.CreateDecal(t, e, n);
+ }, r.CreateCapsule = function(t, e, n) {
+ return e === void 0 && (e = { orientation: u.e.Up(), subdivisions: 2, tessellation: 16, height: 1, radius: 0.25, capSubdivisions: 6 }), n === void 0 && (n = null), mc.CreateCapsule(t, e, n);
+ }, r;
+ }(), rm = function(r, t, e) {
+ this.quality = r, this.distance = t, this.optimizeMesh = e;
+ }, ed = function() {
+ function r() {
+ this.running = !1, this._simplificationArray = [];
+ }
+ return r.prototype.addTask = function(t) {
+ this._simplificationArray.push(t);
+ }, r.prototype.executeNext = function() {
+ var t = this._simplificationArray.pop();
+ t ? (this.running = !0, this.runSimplification(t)) : this.running = !1;
+ }, r.prototype.runSimplification = function(t) {
+ var e = this;
+ if (t.parallelProcessing)
+ t.settings.forEach(function(i) {
+ e.getSimplifier(t).simplify(i, function(o) {
+ i.distance !== void 0 && t.mesh.addLODLevel(i.distance, o), o.isVisible = !0, i.quality === t.settings[t.settings.length - 1].quality && t.successCallback && t.successCallback(), e.executeNext();
+ });
+ });
+ else {
+ var n = this.getSimplifier(t);
+ Xe.a.Run(t.settings.length, function(i) {
+ var o, a;
+ o = t.settings[i.index], a = function() {
+ i.executeNext();
+ }, n.simplify(o, function(s) {
+ o.distance !== void 0 && t.mesh.addLODLevel(o.distance, s), s.isVisible = !0, a();
+ });
+ }, function() {
+ t.successCallback && t.successCallback(), e.executeNext();
+ });
+ }
+ }, r.prototype.getSimplifier = function(t) {
+ switch (t.simplificationType) {
+ case _o.QUADRATIC:
+ default:
+ return new nd(t.mesh);
+ }
+ }, r;
+ }();
+ (function(r) {
+ r[r.QUADRATIC = 0] = "QUADRATIC";
+ })(_o || (_o = {}));
+ var om = function(r) {
+ this.vertices = r, this.error = new Array(4), this.deleted = !1, this.isDirty = !1, this.deletePending = !1, this.borderFactor = 0;
+ }, am = function() {
+ function r(t, e) {
+ this.position = t, this.id = e, this.isBorder = !0, this.q = new td(), this.triangleCount = 0, this.triangleStart = 0, this.originalOffsets = [];
+ }
+ return r.prototype.updatePosition = function(t) {
+ this.position.copyFrom(t);
+ }, r;
+ }(), td = function() {
+ function r(t) {
+ this.data = new Array(10);
+ for (var e = 0; e < 10; ++e)
+ t && t[e] ? this.data[e] = t[e] : this.data[e] = 0;
+ }
+ return r.prototype.det = function(t, e, n, i, o, a, s, d, p) {
+ return this.data[t] * this.data[o] * this.data[p] + this.data[n] * this.data[i] * this.data[d] + this.data[e] * this.data[a] * this.data[s] - this.data[n] * this.data[o] * this.data[s] - this.data[t] * this.data[a] * this.data[d] - this.data[e] * this.data[i] * this.data[p];
+ }, r.prototype.addInPlace = function(t) {
+ for (var e = 0; e < 10; ++e)
+ this.data[e] += t.data[e];
+ }, r.prototype.addArrayInPlace = function(t) {
+ for (var e = 0; e < 10; ++e)
+ this.data[e] += t[e];
+ }, r.prototype.add = function(t) {
+ for (var e = new r(), n = 0; n < 10; ++n)
+ e.data[n] = this.data[n] + t.data[n];
+ return e;
+ }, r.FromData = function(t, e, n, i) {
+ return new r(r.DataFromNumbers(t, e, n, i));
+ }, r.DataFromNumbers = function(t, e, n, i) {
+ return [t * t, t * e, t * n, t * i, e * e, e * n, e * i, n * n, n * i, i * i];
+ }, r;
+ }(), sm = function(r, t) {
+ this.vertexId = r, this.triangleId = t;
+ }, nd = function() {
+ function r(t) {
+ this._mesh = t, this.syncIterations = 5e3, this.aggressiveness = 7, this.decimationIterations = 100, this.boundingBoxEpsilon = Vt.a;
+ }
+ return r.prototype.simplify = function(t, e) {
+ var n = this;
+ this.initDecimatedMesh(), Xe.a.Run(this._mesh.subMeshes.length, function(i) {
+ n.initWithMesh(i.index, function() {
+ n.runDecimation(t, i.index, function() {
+ i.executeNext();
+ });
+ }, t.optimizeMesh);
+ }, function() {
+ setTimeout(function() {
+ e(n._reconstructedMesh);
+ }, 0);
+ });
+ }, r.prototype.runDecimation = function(t, e, n) {
+ var i = this, o = ~~(this.triangles.length * t.quality), a = 0, s = this.triangles.length;
+ Xe.a.Run(this.decimationIterations, function(d) {
+ var p, y;
+ s - a <= o ? d.breakLoop() : (p = d.index, y = function() {
+ d.executeNext();
+ }, setTimeout(function() {
+ p % 5 == 0 && i.updateMesh(p === 0);
+ for (var P = 0; P < i.triangles.length; ++P)
+ i.triangles[P].isDirty = !1;
+ var R = 1e-9 * Math.pow(p + 3, i.aggressiveness);
+ Xe.a.SyncAsyncForLoop(i.triangles.length, i.syncIterations, function(B) {
+ var F = ~~((i.triangles.length / 2 + B) % i.triangles.length), z = i.triangles[F];
+ if (z && !(z.error[3] > R || z.deleted || z.isDirty)) {
+ for (var J = 0; J < 3; ++J)
+ if (z.error[J] < R) {
+ var ie = [], se = [], ce = z.vertices[J], ue = z.vertices[(J + 1) % 3];
+ if (ce.isBorder || ue.isBorder)
+ continue;
+ var fe = u.e.Zero();
+ i.calculateError(ce, ue, fe);
+ var ve = new Array();
+ if (i.isFlipped(ce, ue, fe, ie, ve) || i.isFlipped(ue, ce, fe, se, ve) || ie.indexOf(!0) < 0 || se.indexOf(!0) < 0)
+ continue;
+ var Te = new Array();
+ if (ve.forEach(function(Se) {
+ Te.indexOf(Se) === -1 && (Se.deletePending = !0, Te.push(Se));
+ }), Te.length % 2 != 0)
+ continue;
+ ce.q = ue.q.add(ce.q), ce.updatePosition(fe);
+ var Re = i.references.length;
+ a = i.updateTriangles(ce, ce, ie, a), a = i.updateTriangles(ce, ue, se, a);
+ var Ae = i.references.length - Re;
+ if (Ae <= ce.triangleCount) {
+ if (Ae)
+ for (var Ee = 0; Ee < Ae; Ee++)
+ i.references[ce.triangleStart + Ee] = i.references[Re + Ee];
+ } else
+ ce.triangleStart = Re;
+ ce.triangleCount = Ae;
+ break;
+ }
+ }
+ }, y, function() {
+ return s - a <= o;
+ });
+ }, 0));
+ }, function() {
+ setTimeout(function() {
+ i.reconstructMesh(e), n();
+ }, 0);
+ });
+ }, r.prototype.initWithMesh = function(t, e, n) {
+ var i = this;
+ this.vertices = [], this.triangles = [];
+ var o = this._mesh.getVerticesData(Oe.b.PositionKind), a = this._mesh.getIndices(), s = this._mesh.subMeshes[t], d = [], p = s.verticesCount;
+ Xe.a.SyncAsyncForLoop(p, this.syncIterations / 4 >> 0, function(y) {
+ if (o) {
+ var P = y + s.verticesStart, R = u.e.FromArray(o, 3 * P), B = function(F) {
+ if (n) {
+ for (var z = 0; z < i.vertices.length; ++z)
+ if (i.vertices[z].position.equalsWithEpsilon(F, 1e-4))
+ return i.vertices[z];
+ }
+ return null;
+ }(R) || new am(R, i.vertices.length);
+ B.originalOffsets.push(P), B.id === i.vertices.length && i.vertices.push(B), d.push(B.id);
+ }
+ }, function() {
+ Xe.a.SyncAsyncForLoop(s.indexCount / 3, i.syncIterations, function(y) {
+ if (a) {
+ var P = 3 * (s.indexStart / 3 + y), R = a[P + 0], B = a[P + 1], F = a[P + 2], z = i.vertices[d[R - s.verticesStart]], J = i.vertices[d[B - s.verticesStart]], ie = i.vertices[d[F - s.verticesStart]], se = new om([z, J, ie]);
+ se.originalOffset = P, i.triangles.push(se);
+ }
+ }, function() {
+ i.init(e);
+ });
+ });
+ }, r.prototype.init = function(t) {
+ var e = this;
+ Xe.a.SyncAsyncForLoop(this.triangles.length, this.syncIterations, function(n) {
+ var i = e.triangles[n];
+ i.normal = u.e.Cross(i.vertices[1].position.subtract(i.vertices[0].position), i.vertices[2].position.subtract(i.vertices[0].position)).normalize();
+ for (var o = 0; o < 3; o++)
+ i.vertices[o].q.addArrayInPlace(td.DataFromNumbers(i.normal.x, i.normal.y, i.normal.z, -u.e.Dot(i.normal, i.vertices[0].position)));
+ }, function() {
+ Xe.a.SyncAsyncForLoop(e.triangles.length, e.syncIterations, function(n) {
+ for (var i = e.triangles[n], o = 0; o < 3; ++o)
+ i.error[o] = e.calculateError(i.vertices[o], i.vertices[(o + 1) % 3]);
+ i.error[3] = Math.min(i.error[0], i.error[1], i.error[2]);
+ }, function() {
+ t();
+ });
+ });
+ }, r.prototype.reconstructMesh = function(t) {
+ var e, n, i, o = [];
+ for (e = 0; e < this.vertices.length; ++e)
+ this.vertices[e].triangleCount = 0;
+ for (e = 0; e < this.triangles.length; ++e)
+ if (!this.triangles[e].deleted) {
+ for (n = this.triangles[e], i = 0; i < 3; ++i)
+ n.vertices[i].triangleCount = 1;
+ o.push(n);
+ }
+ var a = this._reconstructedMesh.getVerticesData(Oe.b.PositionKind) || [], s = this._reconstructedMesh.getVerticesData(Oe.b.NormalKind) || [], d = this._reconstructedMesh.getVerticesData(Oe.b.UVKind) || [], p = this._reconstructedMesh.getVerticesData(Oe.b.ColorKind) || [], y = this._mesh.getVerticesData(Oe.b.NormalKind), P = this._mesh.getVerticesData(Oe.b.UVKind), R = this._mesh.getVerticesData(Oe.b.ColorKind), B = 0;
+ for (e = 0; e < this.vertices.length; ++e) {
+ var F = this.vertices[e];
+ F.id = B, F.triangleCount && F.originalOffsets.forEach(function(fe) {
+ a.push(F.position.x), a.push(F.position.y), a.push(F.position.z), y && y.length && (s.push(y[3 * fe]), s.push(y[3 * fe + 1]), s.push(y[3 * fe + 2])), P && P.length && (d.push(P[2 * fe]), d.push(P[2 * fe + 1])), R && R.length && (p.push(R[4 * fe]), p.push(R[4 * fe + 1]), p.push(R[4 * fe + 2]), p.push(R[4 * fe + 3])), ++B;
+ });
+ }
+ var z = this._reconstructedMesh.getTotalIndices(), J = this._reconstructedMesh.getTotalVertices(), ie = this._reconstructedMesh.subMeshes;
+ this._reconstructedMesh.subMeshes = [];
+ var se = this._reconstructedMesh.getIndices(), ce = this._mesh.getIndices();
+ for (e = 0; e < o.length; ++e)
+ n = o[e], [0, 1, 2].forEach(function(fe) {
+ var ve = ce[n.originalOffset + fe], Te = n.vertices[fe].originalOffsets.indexOf(ve);
+ Te < 0 && (Te = 0), se.push(n.vertices[fe].id + Te + J);
+ });
+ this._reconstructedMesh.setIndices(se), this._reconstructedMesh.setVerticesData(Oe.b.PositionKind, a), s.length > 0 && this._reconstructedMesh.setVerticesData(Oe.b.NormalKind, s), d.length > 0 && this._reconstructedMesh.setVerticesData(Oe.b.UVKind, d), p.length > 0 && this._reconstructedMesh.setVerticesData(Oe.b.ColorKind, p);
+ var ue = this._mesh.subMeshes[t];
+ t > 0 && (this._reconstructedMesh.subMeshes = [], ie.forEach(function(fe) {
+ uo.a.AddToMesh(fe.materialIndex, fe.verticesStart, fe.verticesCount, fe.indexStart, fe.indexCount, fe.getMesh());
+ }), uo.a.AddToMesh(ue.materialIndex, J, B, z, 3 * o.length, this._reconstructedMesh));
+ }, r.prototype.initDecimatedMesh = function() {
+ this._reconstructedMesh = new Ie.a(this._mesh.name + "Decimated", this._mesh.getScene()), this._reconstructedMesh.material = this._mesh.material, this._reconstructedMesh.parent = this._mesh.parent, this._reconstructedMesh.isVisible = !1, this._reconstructedMesh.renderingGroupId = this._mesh.renderingGroupId;
+ }, r.prototype.isFlipped = function(t, e, n, i, o) {
+ for (var a = 0; a < t.triangleCount; ++a) {
+ var s = this.triangles[this.references[t.triangleStart + a].triangleId];
+ if (!s.deleted) {
+ var d = this.references[t.triangleStart + a].vertexId, p = s.vertices[(d + 1) % 3], y = s.vertices[(d + 2) % 3];
+ if (p !== e && y !== e) {
+ var P = p.position.subtract(n);
+ P = P.normalize();
+ var R = y.position.subtract(n);
+ if (R = R.normalize(), Math.abs(u.e.Dot(P, R)) > 0.999)
+ return !0;
+ var B = u.e.Cross(P, R).normalize();
+ if (i[a] = !1, u.e.Dot(B, s.normal) < 0.2)
+ return !0;
+ } else
+ i[a] = !0, o.push(s);
+ }
+ }
+ return !1;
+ }, r.prototype.updateTriangles = function(t, e, n, i) {
+ for (var o = i, a = 0; a < e.triangleCount; ++a) {
+ var s = this.references[e.triangleStart + a], d = this.triangles[s.triangleId];
+ d.deleted || (n[a] && d.deletePending ? (d.deleted = !0, o++) : (d.vertices[s.vertexId] = t, d.isDirty = !0, d.error[0] = this.calculateError(d.vertices[0], d.vertices[1]) + d.borderFactor / 2, d.error[1] = this.calculateError(d.vertices[1], d.vertices[2]) + d.borderFactor / 2, d.error[2] = this.calculateError(d.vertices[2], d.vertices[0]) + d.borderFactor / 2, d.error[3] = Math.min(d.error[0], d.error[1], d.error[2]), this.references.push(s)));
+ }
+ return o;
+ }, r.prototype.identifyBorder = function() {
+ for (var t = 0; t < this.vertices.length; ++t) {
+ var e, n = [], i = [], o = this.vertices[t];
+ for (e = 0; e < o.triangleCount; ++e)
+ for (var a = this.triangles[this.references[o.triangleStart + e].triangleId], s = 0; s < 3; s++) {
+ for (var d = 0, p = a.vertices[s]; d < n.length && i[d] !== p.id; )
+ ++d;
+ d === n.length ? (n.push(1), i.push(p.id)) : n[d]++;
+ }
+ for (e = 0; e < n.length; ++e)
+ n[e] === 1 ? this.vertices[i[e]].isBorder = !0 : this.vertices[i[e]].isBorder = !1;
+ }
+ }, r.prototype.updateMesh = function(t) {
+ var e, n, i, o;
+ if (t === void 0 && (t = !1), !t) {
+ var a = [];
+ for (e = 0; e < this.triangles.length; ++e)
+ this.triangles[e].deleted || a.push(this.triangles[e]);
+ this.triangles = a;
+ }
+ for (e = 0; e < this.vertices.length; ++e)
+ this.vertices[e].triangleCount = 0, this.vertices[e].triangleStart = 0;
+ for (e = 0; e < this.triangles.length; ++e)
+ for (n = this.triangles[e], i = 0; i < 3; ++i)
+ (o = n.vertices[i]).triangleCount++;
+ var s = 0;
+ for (e = 0; e < this.vertices.length; ++e)
+ this.vertices[e].triangleStart = s, s += this.vertices[e].triangleCount, this.vertices[e].triangleCount = 0;
+ var d = new Array(3 * this.triangles.length);
+ for (e = 0; e < this.triangles.length; ++e)
+ for (n = this.triangles[e], i = 0; i < 3; ++i)
+ d[(o = n.vertices[i]).triangleStart + o.triangleCount] = new sm(i, e), o.triangleCount++;
+ this.references = d, t && this.identifyBorder();
+ }, r.prototype.vertexError = function(t, e) {
+ var n = e.x, i = e.y, o = e.z;
+ return t.data[0] * n * n + 2 * t.data[1] * n * i + 2 * t.data[2] * n * o + 2 * t.data[3] * n + t.data[4] * i * i + 2 * t.data[5] * i * o + 2 * t.data[6] * i + t.data[7] * o * o + 2 * t.data[8] * o + t.data[9];
+ }, r.prototype.calculateError = function(t, e, n) {
+ var i = t.q.add(e.q), o = t.isBorder && e.isBorder, a = 0, s = i.det(0, 1, 2, 1, 4, 5, 2, 5, 7);
+ if (s === 0 || o) {
+ var d = t.position.add(e.position).divide(new u.e(2, 2, 2)), p = this.vertexError(i, t.position), y = this.vertexError(i, e.position), P = this.vertexError(i, d);
+ (a = Math.min(p, y, P)) === p ? n && n.copyFrom(t.position) : a === y ? n && n.copyFrom(e.position) : n && n.copyFrom(d);
+ } else
+ n || (n = u.e.Zero()), n.x = -1 / s * i.det(1, 2, 3, 4, 5, 6, 5, 7, 8), n.y = 1 / s * i.det(0, 2, 3, 1, 5, 6, 2, 7, 8), n.z = -1 / s * i.det(0, 1, 3, 1, 4, 6, 2, 5, 8), a = this.vertexError(i, n);
+ return a;
+ }, r;
+ }();
+ Object.defineProperty(_e.a.prototype, "simplificationQueue", { get: function() {
+ if (!this._simplificationQueue) {
+ this._simplificationQueue = new ed();
+ var r = this._getComponent(ot.a.NAME_SIMPLIFICATIONQUEUE);
+ r || (r = new id(this), this._addComponent(r));
+ }
+ return this._simplificationQueue;
+ }, set: function(r) {
+ this._simplificationQueue = r;
+ }, enumerable: !0, configurable: !0 }), Ie.a.prototype.simplify = function(r, t, e, n) {
+ return t === void 0 && (t = !0), e === void 0 && (e = _o.QUADRATIC), this.getScene().simplificationQueue.addTask({ settings: r, parallelProcessing: t, mesh: this, simplificationType: e, successCallback: n }), this;
+ };
+ var id = function() {
+ function r(t) {
+ this.name = ot.a.NAME_SIMPLIFICATIONQUEUE, this.scene = t;
+ }
+ return r.prototype.register = function() {
+ this.scene._beforeCameraUpdateStage.registerStep(ot.a.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE, this, this._beforeCameraUpdate);
+ }, r.prototype.rebuild = function() {
+ }, r.prototype.dispose = function() {
+ }, r.prototype._beforeCameraUpdate = function() {
+ this.scene._simplificationQueue && !this.scene._simplificationQueue.running && this.scene._simplificationQueue.executeNext();
+ }, r;
+ }(), cm = f(149), lm = f(88);
+ Ie.a.prototype.thinInstanceAdd = function(r, t) {
+ t === void 0 && (t = !0), this._thinInstanceUpdateBufferSize("matrix", Array.isArray(r) ? r.length : 1);
+ var e = this._thinInstanceDataStorage.instancesCount;
+ if (Array.isArray(r))
+ for (var n = 0; n < r.length; ++n)
+ this.thinInstanceSetMatrixAt(this._thinInstanceDataStorage.instancesCount++, r[n], n === r.length - 1 && t);
+ else
+ this.thinInstanceSetMatrixAt(this._thinInstanceDataStorage.instancesCount++, r, t);
+ return e;
+ }, Ie.a.prototype.thinInstanceAddSelf = function(r) {
+ return r === void 0 && (r = !0), this.thinInstanceAdd(u.a.IdentityReadOnly, r);
+ }, Ie.a.prototype.thinInstanceRegisterAttribute = function(r, t) {
+ this.removeVerticesData(r), this._thinInstanceInitializeUserStorage(), this._userThinInstanceBuffersStorage.strides[r] = t, this._userThinInstanceBuffersStorage.sizes[r] = t * Math.max(32, this._thinInstanceDataStorage.instancesCount), this._userThinInstanceBuffersStorage.data[r] = new Float32Array(this._userThinInstanceBuffersStorage.sizes[r]), this._userThinInstanceBuffersStorage.vertexBuffers[r] = new Oe.b(this.getEngine(), this._userThinInstanceBuffersStorage.data[r], r, !0, !1, t, !0), this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[r]);
+ }, Ie.a.prototype.thinInstanceSetMatrixAt = function(r, t, e) {
+ if (e === void 0 && (e = !0), !this._thinInstanceDataStorage.matrixData || r >= this._thinInstanceDataStorage.instancesCount)
+ return !1;
+ var n = this._thinInstanceDataStorage.matrixData;
+ return t.copyToArray(n, 16 * r), this._thinInstanceDataStorage.worldMatrices && (this._thinInstanceDataStorage.worldMatrices[r] = t), e && (this.thinInstanceBufferUpdated("matrix"), this.doNotSyncBoundingInfo || this.thinInstanceRefreshBoundingInfo(!1)), !0;
+ }, Ie.a.prototype.thinInstanceSetAttributeAt = function(r, t, e, n) {
+ return n === void 0 && (n = !0), !(!this._userThinInstanceBuffersStorage || !this._userThinInstanceBuffersStorage.data[r] || t >= this._thinInstanceDataStorage.instancesCount) && (this._thinInstanceUpdateBufferSize(r, 0), this._userThinInstanceBuffersStorage.data[r].set(e, t * this._userThinInstanceBuffersStorage.strides[r]), n && this.thinInstanceBufferUpdated(r), !0);
+ }, Object.defineProperty(Ie.a.prototype, "thinInstanceCount", { get: function() {
+ return this._thinInstanceDataStorage.instancesCount;
+ }, set: function(r) {
+ var t, e;
+ r <= ((e = (t = this._thinInstanceDataStorage.matrixData) === null || t === void 0 ? void 0 : t.length) !== null && e !== void 0 ? e : 0) / 16 && (this._thinInstanceDataStorage.instancesCount = r);
+ }, enumerable: !0, configurable: !0 }), Ie.a.prototype.thinInstanceSetBuffer = function(r, t, e, n) {
+ var i, o;
+ if (e === void 0 && (e = 0), n === void 0 && (n = !1), e = e || 16, r === "matrix")
+ if ((i = this._thinInstanceDataStorage.matrixBuffer) === null || i === void 0 || i.dispose(), this._thinInstanceDataStorage.matrixBuffer = null, this._thinInstanceDataStorage.matrixBufferSize = t ? t.length : 32 * e, this._thinInstanceDataStorage.matrixData = t, this._thinInstanceDataStorage.worldMatrices = null, t !== null) {
+ this._thinInstanceDataStorage.instancesCount = t.length / e;
+ var a = new Oe.a(this.getEngine(), t, !n, e, !1, !0);
+ this._thinInstanceDataStorage.matrixBuffer = a, this.setVerticesBuffer(a.createVertexBuffer("world0", 0, 4)), this.setVerticesBuffer(a.createVertexBuffer("world1", 4, 4)), this.setVerticesBuffer(a.createVertexBuffer("world2", 8, 4)), this.setVerticesBuffer(a.createVertexBuffer("world3", 12, 4)), this.doNotSyncBoundingInfo || this.thinInstanceRefreshBoundingInfo(!1);
+ } else
+ this._thinInstanceDataStorage.instancesCount = 0, this.doNotSyncBoundingInfo || this.refreshBoundingInfo(!0);
+ else
+ t === null ? !((o = this._userThinInstanceBuffersStorage) === null || o === void 0) && o.data[r] && (this.removeVerticesData(r), delete this._userThinInstanceBuffersStorage.data[r], delete this._userThinInstanceBuffersStorage.strides[r], delete this._userThinInstanceBuffersStorage.sizes[r], delete this._userThinInstanceBuffersStorage.vertexBuffers[r]) : (this._thinInstanceInitializeUserStorage(), this._userThinInstanceBuffersStorage.data[r] = t, this._userThinInstanceBuffersStorage.strides[r] = e, this._userThinInstanceBuffersStorage.sizes[r] = t.length, this._userThinInstanceBuffersStorage.vertexBuffers[r] = new Oe.b(this.getEngine(), t, r, !n, !1, e, !0), this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[r]));
+ }, Ie.a.prototype.thinInstanceBufferUpdated = function(r) {
+ var t;
+ r === "matrix" ? this._thinInstanceDataStorage.matrixBuffer && this._thinInstanceDataStorage.matrixBuffer.updateDirectly(this._thinInstanceDataStorage.matrixData, 0, this._thinInstanceDataStorage.instancesCount) : !((t = this._userThinInstanceBuffersStorage) === null || t === void 0) && t.vertexBuffers[r] && this._userThinInstanceBuffersStorage.vertexBuffers[r].updateDirectly(this._userThinInstanceBuffersStorage.data[r], 0);
+ }, Ie.a.prototype.thinInstancePartialBufferUpdate = function(r, t, e) {
+ var n;
+ r === "matrix" ? this._thinInstanceDataStorage.matrixBuffer && this._thinInstanceDataStorage.matrixBuffer.updateDirectly(t, e) : !((n = this._userThinInstanceBuffersStorage) === null || n === void 0) && n.vertexBuffers[r] && this._userThinInstanceBuffersStorage.vertexBuffers[r].updateDirectly(t, e);
+ }, Ie.a.prototype.thinInstanceGetWorldMatrices = function() {
+ if (!this._thinInstanceDataStorage.matrixData || !this._thinInstanceDataStorage.matrixBuffer)
+ return [];
+ var r = this._thinInstanceDataStorage.matrixData;
+ if (!this._thinInstanceDataStorage.worldMatrices) {
+ this._thinInstanceDataStorage.worldMatrices = new Array();
+ for (var t = 0; t < this._thinInstanceDataStorage.instancesCount; ++t)
+ this._thinInstanceDataStorage.worldMatrices[t] = u.a.FromArray(r, 16 * t);
+ }
+ return this._thinInstanceDataStorage.worldMatrices;
+ }, Ie.a.prototype.thinInstanceRefreshBoundingInfo = function(r) {
+ if (r === void 0 && (r = !1), this._thinInstanceDataStorage.matrixData && this._thinInstanceDataStorage.matrixBuffer) {
+ var t = this._thinInstanceDataStorage.boundingVectors;
+ r && (t.length = 0, this.refreshBoundingInfo(!0));
+ var e = this.getBoundingInfo(), n = this._thinInstanceDataStorage.matrixData;
+ if (t.length === 0)
+ for (var i = 0; i < e.boundingBox.vectors.length; ++i)
+ t.push(e.boundingBox.vectors[i].clone());
+ u.c.Vector3[0].setAll(Number.POSITIVE_INFINITY), u.c.Vector3[1].setAll(Number.NEGATIVE_INFINITY);
+ for (var o = 0; o < this._thinInstanceDataStorage.instancesCount; ++o)
+ for (u.a.FromArrayToRef(n, 16 * o, u.c.Matrix[0]), i = 0; i < t.length; ++i)
+ u.e.TransformCoordinatesToRef(t[i], u.c.Matrix[0], u.c.Vector3[2]), u.c.Vector3[0].minimizeInPlace(u.c.Vector3[2]), u.c.Vector3[1].maximizeInPlace(u.c.Vector3[2]);
+ e.reConstruct(u.c.Vector3[0], u.c.Vector3[1]), this._updateBoundingInfo();
+ }
+ }, Ie.a.prototype._thinInstanceUpdateBufferSize = function(r, t) {
+ var e, n;
+ t === void 0 && (t = 1);
+ var i = r === "matrix";
+ if (i || this._userThinInstanceBuffersStorage && this._userThinInstanceBuffersStorage.strides[r]) {
+ for (var o = i ? 16 : this._userThinInstanceBuffersStorage.strides[r], a = i ? this._thinInstanceDataStorage.matrixBufferSize : this._userThinInstanceBuffersStorage.sizes[r], s = i ? this._thinInstanceDataStorage.matrixData : this._userThinInstanceBuffersStorage.data[r], d = (this._thinInstanceDataStorage.instancesCount + t) * o, p = a; p < d; )
+ p *= 2;
+ if (!s || a != p) {
+ if (s) {
+ var y = new Float32Array(p);
+ y.set(s, 0), s = y;
+ } else
+ s = new Float32Array(p);
+ if (i) {
+ (e = this._thinInstanceDataStorage.matrixBuffer) === null || e === void 0 || e.dispose();
+ var P = new Oe.a(this.getEngine(), s, !0, o, !1, !0);
+ this._thinInstanceDataStorage.matrixBuffer = P, this._thinInstanceDataStorage.matrixData = s, this._thinInstanceDataStorage.matrixBufferSize = p, this.setVerticesBuffer(P.createVertexBuffer("world0", 0, 4)), this.setVerticesBuffer(P.createVertexBuffer("world1", 4, 4)), this.setVerticesBuffer(P.createVertexBuffer("world2", 8, 4)), this.setVerticesBuffer(P.createVertexBuffer("world3", 12, 4));
+ } else
+ (n = this._userThinInstanceBuffersStorage.vertexBuffers[r]) === null || n === void 0 || n.dispose(), this._userThinInstanceBuffersStorage.data[r] = s, this._userThinInstanceBuffersStorage.sizes[r] = p, this._userThinInstanceBuffersStorage.vertexBuffers[r] = new Oe.b(this.getEngine(), s, r, !0, !1, o, !0), this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[r]);
+ }
+ }
+ }, Ie.a.prototype._thinInstanceInitializeUserStorage = function() {
+ this._userThinInstanceBuffersStorage || (this._userThinInstanceBuffersStorage = { data: {}, sizes: {}, vertexBuffers: {}, strides: {} });
+ }, Ie.a.prototype._disposeThinInstanceSpecificData = function() {
+ var r;
+ !((r = this._thinInstanceDataStorage) === null || r === void 0) && r.matrixBuffer && (this._thinInstanceDataStorage.matrixBuffer.dispose(), this._thinInstanceDataStorage.matrixBuffer = null);
+ };
+ var um = function() {
+ function r(t) {
+ t === void 0 && (t = Recast), this.bjsRECAST = {}, this.name = "RecastJSPlugin", this._maximumSubStepCount = 10, this._timeStep = 1 / 60, typeof t == "function" ? t(this.bjsRECAST) : this.bjsRECAST = t, this.isSupported() ? this.setTimeStep() : l.a.Error("RecastJS is not available. Please make sure you included the js file.");
+ }
+ return r.prototype.setTimeStep = function(t) {
+ t === void 0 && (t = 1 / 60), this._timeStep = t;
+ }, r.prototype.getTimeStep = function() {
+ return this._timeStep;
+ }, r.prototype.setMaximumSubStepCount = function(t) {
+ t === void 0 && (t = 10), this._maximumSubStepCount = t;
+ }, r.prototype.getMaximumSubStepCount = function() {
+ return this._maximumSubStepCount;
+ }, r.prototype.createNavMesh = function(t, e) {
+ var n, i, o, a = new this.bjsRECAST.rcConfig();
+ a.cs = e.cs, a.ch = e.ch, a.borderSize = 0, a.tileSize = 0, a.walkableSlopeAngle = e.walkableSlopeAngle, a.walkableHeight = e.walkableHeight, a.walkableClimb = e.walkableClimb, a.walkableRadius = e.walkableRadius, a.maxEdgeLen = e.maxEdgeLen, a.maxSimplificationError = e.maxSimplificationError, a.minRegionArea = e.minRegionArea, a.mergeRegionArea = e.mergeRegionArea, a.maxVertsPerPoly = e.maxVertsPerPoly, a.detailSampleDist = e.detailSampleDist, a.detailSampleMaxError = e.detailSampleMaxError, this.navMesh = new this.bjsRECAST.NavMesh();
+ var s = [], d = [], p = 0;
+ for (n = 0; n < t.length; n++)
+ if (t[n]) {
+ var y = t[n], P = y.getIndices();
+ if (!P)
+ continue;
+ var R = y.getVerticesData(Oe.b.PositionKind, !1, !1);
+ if (!R)
+ continue;
+ var B = y.computeWorldMatrix(!0);
+ for (i = 0; i < P.length; i++)
+ s.push(P[i] + p);
+ var F = u.e.Zero(), z = u.e.Zero();
+ for (o = 0; o < R.length; o += 3)
+ u.e.FromArrayToRef(R, o, z), u.e.TransformCoordinatesToRef(z, B, F), d.push(F.x, F.y, F.z);
+ p += R.length / 3;
+ }
+ this.navMesh.build(d, p, s, s.length, a);
+ }, r.prototype.createDebugNavMesh = function(t) {
+ var e, n, i = this.navMesh.getDebugNavMesh(), o = i.getTriangleCount(), a = [], s = [];
+ for (e = 0; e < 3 * o; e++)
+ a.push(e);
+ for (e = 0; e < o; e++)
+ for (n = 0; n < 3; n++) {
+ var d = i.getTriangle(e).getPoint(n);
+ s.push(d.x, d.y, d.z);
+ }
+ var p = new Ie.a("NavMeshDebug", t), y = new ht.a();
+ return y.indices = a, y.positions = s, y.applyToMesh(p, !1), p;
+ }, r.prototype.getClosestPoint = function(t) {
+ var e = new this.bjsRECAST.Vec3(t.x, t.y, t.z), n = this.navMesh.getClosestPoint(e);
+ return new u.e(n.x, n.y, n.z);
+ }, r.prototype.getClosestPointToRef = function(t, e) {
+ var n = new this.bjsRECAST.Vec3(t.x, t.y, t.z), i = this.navMesh.getClosestPoint(n);
+ e.set(i.x, i.y, i.z);
+ }, r.prototype.getRandomPointAround = function(t, e) {
+ var n = new this.bjsRECAST.Vec3(t.x, t.y, t.z), i = this.navMesh.getRandomPointAround(n, e);
+ return new u.e(i.x, i.y, i.z);
+ }, r.prototype.getRandomPointAroundToRef = function(t, e, n) {
+ var i = new this.bjsRECAST.Vec3(t.x, t.y, t.z), o = this.navMesh.getRandomPointAround(i, e);
+ n.set(o.x, o.y, o.z);
+ }, r.prototype.moveAlong = function(t, e) {
+ var n = new this.bjsRECAST.Vec3(t.x, t.y, t.z), i = new this.bjsRECAST.Vec3(e.x, e.y, e.z), o = this.navMesh.moveAlong(n, i);
+ return new u.e(o.x, o.y, o.z);
+ }, r.prototype.moveAlongToRef = function(t, e, n) {
+ var i = new this.bjsRECAST.Vec3(t.x, t.y, t.z), o = new this.bjsRECAST.Vec3(e.x, e.y, e.z), a = this.navMesh.moveAlong(i, o);
+ n.set(a.x, a.y, a.z);
+ }, r.prototype.computePath = function(t, e) {
+ var n, i = new this.bjsRECAST.Vec3(t.x, t.y, t.z), o = new this.bjsRECAST.Vec3(e.x, e.y, e.z), a = this.navMesh.computePath(i, o), s = a.getPointCount(), d = [];
+ for (n = 0; n < s; n++) {
+ var p = a.getPoint(n);
+ d.push(new u.e(p.x, p.y, p.z));
+ }
+ return d;
+ }, r.prototype.createCrowd = function(t, e, n) {
+ return new rd(this, t, e, n);
+ }, r.prototype.setDefaultQueryExtent = function(t) {
+ var e = new this.bjsRECAST.Vec3(t.x, t.y, t.z);
+ this.navMesh.setDefaultQueryExtent(e);
+ }, r.prototype.getDefaultQueryExtent = function() {
+ var t = this.navMesh.getDefaultQueryExtent();
+ return new u.e(t.x, t.y, t.z);
+ }, r.prototype.buildFromNavmeshData = function(t) {
+ var e = t.length * t.BYTES_PER_ELEMENT, n = this.bjsRECAST._malloc(e), i = new Uint8Array(this.bjsRECAST.HEAPU8.buffer, n, e);
+ i.set(t);
+ var o = new this.bjsRECAST.NavmeshData();
+ o.dataPointer = i.byteOffset, o.size = t.length, this.navMesh = new this.bjsRECAST.NavMesh(), this.navMesh.buildFromNavmeshData(o), this.bjsRECAST._free(i.byteOffset);
+ }, r.prototype.getNavmeshData = function() {
+ var t = this.navMesh.getNavmeshData(), e = new Uint8Array(this.bjsRECAST.HEAPU8.buffer, t.dataPointer, t.size), n = new Uint8Array(t.size);
+ return n.set(e), this.navMesh.freeNavmeshData(t), n;
+ }, r.prototype.getDefaultQueryExtentToRef = function(t) {
+ var e = this.navMesh.getDefaultQueryExtent();
+ t.set(e.x, e.y, e.z);
+ }, r.prototype.dispose = function() {
+ }, r.prototype.isSupported = function() {
+ return this.bjsRECAST !== void 0;
+ }, r;
+ }(), rd = function() {
+ function r(t, e, n, i) {
+ var o = this;
+ this.recastCrowd = {}, this.transforms = new Array(), this.agents = new Array(), this._onBeforeAnimationsObserver = null, this.bjsRECASTPlugin = t, this.recastCrowd = new this.bjsRECASTPlugin.bjsRECAST.Crowd(e, n, this.bjsRECASTPlugin.navMesh.getNavMesh()), this._scene = i, this._onBeforeAnimationsObserver = i.onBeforeAnimationsObservable.add(function() {
+ o.update(1e-3 * i.getEngine().getDeltaTime());
+ });
+ }
+ return r.prototype.addAgent = function(t, e, n) {
+ var i = new this.bjsRECASTPlugin.bjsRECAST.dtCrowdAgentParams();
+ i.radius = e.radius, i.height = e.height, i.maxAcceleration = e.maxAcceleration, i.maxSpeed = e.maxSpeed, i.collisionQueryRange = e.collisionQueryRange, i.pathOptimizationRange = e.pathOptimizationRange, i.separationWeight = e.separationWeight, i.updateFlags = 7, i.obstacleAvoidanceType = 0, i.queryFilterType = 0, i.userData = 0;
+ var o = this.recastCrowd.addAgent(new this.bjsRECASTPlugin.bjsRECAST.Vec3(t.x, t.y, t.z), i);
+ return this.transforms.push(n), this.agents.push(o), o;
+ }, r.prototype.getAgentPosition = function(t) {
+ var e = this.recastCrowd.getAgentPosition(t);
+ return new u.e(e.x, e.y, e.z);
+ }, r.prototype.getAgentPositionToRef = function(t, e) {
+ var n = this.recastCrowd.getAgentPosition(t);
+ e.set(n.x, n.y, n.z);
+ }, r.prototype.getAgentVelocity = function(t) {
+ var e = this.recastCrowd.getAgentVelocity(t);
+ return new u.e(e.x, e.y, e.z);
+ }, r.prototype.getAgentVelocityToRef = function(t, e) {
+ var n = this.recastCrowd.getAgentVelocity(t);
+ e.set(n.x, n.y, n.z);
+ }, r.prototype.getAgentNextTargetPath = function(t) {
+ var e = this.recastCrowd.getAgentNextTargetPath(t);
+ return new u.e(e.x, e.y, e.z);
+ }, r.prototype.getAgentNextTargetPathToRef = function(t, e) {
+ var n = this.recastCrowd.getAgentNextTargetPath(t);
+ e.set(n.x, n.y, n.z);
+ }, r.prototype.getAgentState = function(t) {
+ return this.recastCrowd.getAgentState(t);
+ }, r.prototype.overOffmeshConnection = function(t) {
+ return this.recastCrowd.overOffmeshConnection(t);
+ }, r.prototype.agentGoto = function(t, e) {
+ this.recastCrowd.agentGoto(t, new this.bjsRECASTPlugin.bjsRECAST.Vec3(e.x, e.y, e.z));
+ }, r.prototype.agentTeleport = function(t, e) {
+ this.recastCrowd.agentTeleport(t, new this.bjsRECASTPlugin.bjsRECAST.Vec3(e.x, e.y, e.z));
+ }, r.prototype.updateAgentParameters = function(t, e) {
+ var n = this.recastCrowd.getAgentParameters(t);
+ e.radius !== void 0 && (n.radius = e.radius), e.height !== void 0 && (n.height = e.height), e.maxAcceleration !== void 0 && (n.maxAcceleration = e.maxAcceleration), e.maxSpeed !== void 0 && (n.maxSpeed = e.maxSpeed), e.collisionQueryRange !== void 0 && (n.collisionQueryRange = e.collisionQueryRange), e.pathOptimizationRange !== void 0 && (n.pathOptimizationRange = e.pathOptimizationRange), e.separationWeight !== void 0 && (n.separationWeight = e.separationWeight), this.recastCrowd.setAgentParameters(t, n);
+ }, r.prototype.removeAgent = function(t) {
+ this.recastCrowd.removeAgent(t);
+ var e = this.agents.indexOf(t);
+ e > -1 && (this.agents.splice(e, 1), this.transforms.splice(e, 1));
+ }, r.prototype.getAgents = function() {
+ return this.agents;
+ }, r.prototype.update = function(t) {
+ var e = this.bjsRECASTPlugin.getTimeStep(), n = this.bjsRECASTPlugin.getMaximumSubStepCount();
+ if (e <= Vt.a)
+ this.recastCrowd.update(t);
+ else {
+ var i = t / e;
+ n && i > n && (i = n), i < 1 && (i = 1);
+ for (var o = 0; o < i; o++)
+ this.recastCrowd.update(e);
+ }
+ for (var a = 0; a < this.agents.length; a++)
+ this.transforms[a].position = this.getAgentPosition(this.agents[a]);
+ }, r.prototype.setDefaultQueryExtent = function(t) {
+ var e = new this.bjsRECASTPlugin.bjsRECAST.Vec3(t.x, t.y, t.z);
+ this.recastCrowd.setDefaultQueryExtent(e);
+ }, r.prototype.getDefaultQueryExtent = function() {
+ var t = this.recastCrowd.getDefaultQueryExtent();
+ return new u.e(t.x, t.y, t.z);
+ }, r.prototype.getDefaultQueryExtentToRef = function(t) {
+ var e = this.recastCrowd.getDefaultQueryExtent();
+ t.set(e.x, e.y, e.z);
+ }, r.prototype.dispose = function() {
+ this.recastCrowd.destroy(), this._scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver), this._onBeforeAnimationsObserver = null;
+ }, r;
+ }();
+ Ue.a.OfflineProviderFactory = function(r, t, e) {
+ return e === void 0 && (e = !1), new od(r, t, e);
+ };
+ var Rr, od = function() {
+ function r(t, e, n) {
+ var i = this;
+ n === void 0 && (n = !1), this._idbFactory = typeof window < "u" ? window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB : indexedDB, this._callbackManifestChecked = e, this._currentSceneUrl = r._ReturnFullUrlLocation(t), this._db = null, this._enableSceneOffline = !1, this._enableTexturesOffline = !1, this._manifestVersionFound = 0, this._mustUpdateRessources = !1, this._hasReachedQuota = !1, r.IDBStorageEnabled ? n ? (this._enableSceneOffline = !0, this._enableTexturesOffline = !0, this._manifestVersionFound = 1, Xe.b.SetImmediate(function() {
+ i._callbackManifestChecked(!0);
+ })) : this._checkManifestFile() : this._callbackManifestChecked(!0);
+ }
+ return Object.defineProperty(r.prototype, "enableSceneOffline", { get: function() {
+ return this._enableSceneOffline;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "enableTexturesOffline", { get: function() {
+ return this._enableTexturesOffline;
+ }, enumerable: !1, configurable: !0 }), r.prototype._checkManifestFile = function() {
+ var t = this, e = function() {
+ t._enableSceneOffline = !1, t._enableTexturesOffline = !1, t._callbackManifestChecked(!1);
+ }, n = !1, i = this._currentSceneUrl + ".manifest", o = new re.a();
+ navigator.onLine && (n = !0, i = i + (i.match(/\?/) == null ? "?" : "&") + Date.now()), o.open("GET", i), o.addEventListener("load", function() {
+ if (o.status === 200 || r._ValidateXHRData(o, 1))
+ try {
+ var a = JSON.parse(o.response);
+ t._enableSceneOffline = a.enableSceneOffline, t._enableTexturesOffline = a.enableTexturesOffline && r.IsUASupportingBlobStorage, a.version && !isNaN(parseInt(a.version)) && (t._manifestVersionFound = a.version), t._callbackManifestChecked && t._callbackManifestChecked(!0);
+ } catch {
+ e();
+ }
+ else
+ e();
+ }, !1), o.addEventListener("error", function() {
+ if (n) {
+ n = !1;
+ var a = t._currentSceneUrl + ".manifest";
+ o.open("GET", a), o.send();
+ } else
+ e();
+ }, !1);
+ try {
+ o.send();
+ } catch {
+ l.a.Error("Error on XHR send request."), this._callbackManifestChecked(!1);
+ }
+ }, r.prototype.open = function(t, e) {
+ var n = this, i = function() {
+ n._isSupported = !1, e && e();
+ };
+ if (this._idbFactory && (this._enableSceneOffline || this._enableTexturesOffline))
+ if (this._db)
+ t && t();
+ else {
+ this._hasReachedQuota = !1, this._isSupported = !0;
+ var o = this._idbFactory.open("babylonjs", 1);
+ o.onerror = function() {
+ i();
+ }, o.onblocked = function() {
+ l.a.Error("IDB request blocked. Please reload the page."), i();
+ }, o.onsuccess = function() {
+ n._db = o.result, t();
+ }, o.onupgradeneeded = function(a) {
+ if (n._db = a.target.result, n._db)
+ try {
+ n._db.createObjectStore("scenes", { keyPath: "sceneUrl" }), n._db.createObjectStore("versions", { keyPath: "sceneUrl" }), n._db.createObjectStore("textures", { keyPath: "textureUrl" });
+ } catch (s) {
+ l.a.Error("Error while creating object stores. Exception: " + s.message), i();
+ }
+ };
+ }
+ else
+ this._isSupported = !1, e && e();
+ }, r.prototype.loadImage = function(t, e) {
+ var n = this, i = r._ReturnFullUrlLocation(t), o = function() {
+ n._hasReachedQuota || n._db === null ? e.src = t : n._saveImageIntoDBAsync(i, e);
+ };
+ this._mustUpdateRessources ? o() : this._loadImageFromDBAsync(i, e, o);
+ }, r.prototype._loadImageFromDBAsync = function(t, e, n) {
+ if (this._isSupported && this._db !== null) {
+ var i, o = this._db.transaction(["textures"]);
+ o.onabort = function() {
+ e.src = t;
+ }, o.oncomplete = function() {
+ var s;
+ if (i) {
+ var d = window.URL || window.webkitURL;
+ s = d.createObjectURL(i.data), e.onerror = function() {
+ l.a.Error("Error loading image from blob URL: " + s + " switching back to web url: " + t), e.src = t;
+ }, e.src = s;
+ } else
+ n();
+ };
+ var a = o.objectStore("textures").get(t);
+ a.onsuccess = function(s) {
+ i = s.target.result;
+ }, a.onerror = function() {
+ l.a.Error("Error loading texture " + t + " from DB."), e.src = t;
+ };
+ } else
+ l.a.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."), e.src = t;
+ }, r.prototype._saveImageIntoDBAsync = function(t, e) {
+ var n = this;
+ if (this._isSupported) {
+ var i = function() {
+ var s;
+ if (o) {
+ var d = window.URL || window.webkitURL;
+ try {
+ s = d.createObjectURL(o);
+ } catch {
+ s = d.createObjectURL(o);
+ }
+ }
+ s && (e.src = s);
+ };
+ if (r.IsUASupportingBlobStorage) {
+ var o, a = new re.a();
+ a.open("GET", t), a.responseType = "blob", a.addEventListener("load", function() {
+ if (a.status === 200 && n._db) {
+ o = a.response;
+ var s = n._db.transaction(["textures"], "readwrite");
+ s.onabort = function(y) {
+ try {
+ var P = (y.srcElement || y.target).error;
+ P && P.name === "QuotaExceededError" && (n._hasReachedQuota = !0);
+ } catch {
+ }
+ i();
+ }, s.oncomplete = function() {
+ i();
+ };
+ var d = { textureUrl: t, data: o };
+ try {
+ var p = s.objectStore("textures").put(d);
+ p.onsuccess = function() {
+ }, p.onerror = function() {
+ i();
+ };
+ } catch (y) {
+ y.code === 25 && (r.IsUASupportingBlobStorage = !1, n._enableTexturesOffline = !1), e.src = t;
+ }
+ } else
+ e.src = t;
+ }, !1), a.addEventListener("error", function() {
+ l.a.Error("Error in XHR request in BABYLON.Database."), e.src = t;
+ }, !1), a.send();
+ } else
+ e.src = t;
+ } else
+ l.a.Error("Error: IndexedDB not supported by your browser or Babylon.js database is not open."), e.src = t;
+ }, r.prototype._checkVersionFromDB = function(t, e) {
+ var n = this;
+ this._loadVersionFromDBAsync(t, e, function() {
+ n._saveVersionIntoDBAsync(t, e);
+ });
+ }, r.prototype._loadVersionFromDBAsync = function(t, e, n) {
+ var i, o = this;
+ if (this._isSupported && this._db)
+ try {
+ var a = this._db.transaction(["versions"]);
+ a.oncomplete = function() {
+ i ? o._manifestVersionFound !== i.data ? (o._mustUpdateRessources = !0, n()) : e(i.data) : (o._mustUpdateRessources = !0, n());
+ }, a.onabort = function() {
+ e(-1);
+ };
+ var s = a.objectStore("versions").get(t);
+ s.onsuccess = function(d) {
+ i = d.target.result;
+ }, s.onerror = function() {
+ l.a.Error("Error loading version for scene " + t + " from DB."), e(-1);
+ };
+ } catch (d) {
+ l.a.Error("Error while accessing 'versions' object store (READ OP). Exception: " + d.message), e(-1);
+ }
+ else
+ l.a.Error("Error: IndexedDB not supported by your browser or Babylon.js database is not open."), e(-1);
+ }, r.prototype._saveVersionIntoDBAsync = function(t, e) {
+ var n = this;
+ if (this._isSupported && !this._hasReachedQuota && this._db)
+ try {
+ var i = this._db.transaction(["versions"], "readwrite");
+ i.onabort = function(s) {
+ try {
+ var d = s.srcElement.error;
+ d && d.name === "QuotaExceededError" && (n._hasReachedQuota = !0);
+ } catch {
+ }
+ e(-1);
+ }, i.oncomplete = function() {
+ e(n._manifestVersionFound);
+ };
+ var o = { sceneUrl: t, data: this._manifestVersionFound }, a = i.objectStore("versions").put(o);
+ a.onsuccess = function() {
+ }, a.onerror = function() {
+ l.a.Error("Error in DB add version request in BABYLON.Database.");
+ };
+ } catch (s) {
+ l.a.Error("Error while accessing 'versions' object store (WRITE OP). Exception: " + s.message), e(-1);
+ }
+ else
+ e(-1);
+ }, r.prototype.loadFile = function(t, e, n, i, o) {
+ var a = this, s = r._ReturnFullUrlLocation(t), d = function() {
+ a._saveFileAsync(s, e, n, o, i);
+ };
+ this._checkVersionFromDB(s, function(p) {
+ p !== -1 ? a._mustUpdateRessources ? a._saveFileAsync(s, e, n, o, i) : a._loadFileAsync(s, e, d) : i && i();
+ });
+ }, r.prototype._loadFileAsync = function(t, e, n) {
+ if (this._isSupported && this._db) {
+ var i, o;
+ i = t.indexOf(".babylon") !== -1 ? "scenes" : "textures";
+ var a = this._db.transaction([i]);
+ a.oncomplete = function() {
+ o ? e(o.data) : n();
+ }, a.onabort = function() {
+ n();
+ };
+ var s = a.objectStore(i).get(t);
+ s.onsuccess = function(d) {
+ o = d.target.result;
+ }, s.onerror = function() {
+ l.a.Error("Error loading file " + t + " from DB."), n();
+ };
+ } else
+ l.a.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."), e();
+ }, r.prototype._saveFileAsync = function(t, e, n, i, o) {
+ var a = this;
+ if (this._isSupported) {
+ var s;
+ s = t.indexOf(".babylon") !== -1 ? "scenes" : "textures";
+ var d, p = new re.a();
+ p.open("GET", t + "?" + Date.now()), i && (p.responseType = "arraybuffer"), n && (p.onprogress = n), p.addEventListener("load", function() {
+ if (p.status === 200 || p.status < 400 && r._ValidateXHRData(p, i ? 6 : 1))
+ if (d = i ? p.response : p.responseText, !a._hasReachedQuota && a._db) {
+ var y, P = a._db.transaction([s], "readwrite");
+ P.onabort = function(B) {
+ try {
+ var F = B.srcElement.error;
+ F && F.name === "QuotaExceededError" && (a._hasReachedQuota = !0);
+ } catch {
+ }
+ e(d);
+ }, P.oncomplete = function() {
+ e(d);
+ }, y = s === "scenes" ? { sceneUrl: t, data: d, version: a._manifestVersionFound } : { textureUrl: t, data: d };
+ try {
+ var R = P.objectStore(s).put(y);
+ R.onsuccess = function() {
+ }, R.onerror = function() {
+ l.a.Error("Error in DB add file request in BABYLON.Database.");
+ };
+ } catch {
+ e(d);
+ }
+ } else
+ e(d);
+ else
+ p.status >= 400 && o ? o(p) : e();
+ }, !1), p.addEventListener("error", function() {
+ l.a.Error("error on XHR request."), e();
+ }, !1), p.send();
+ } else
+ l.a.Error("Error: IndexedDB not supported by your browser or Babylon.js database is not open."), e();
+ }, r._ValidateXHRData = function(t, e) {
+ e === void 0 && (e = 7);
+ try {
+ if (1 & e) {
+ if (t.responseText && t.responseText.length > 0)
+ return !0;
+ if (e === 1)
+ return !1;
+ }
+ if (2 & e) {
+ var n = ta.GetTGAHeader(t.response);
+ if (n.width && n.height && n.width > 0 && n.height > 0)
+ return !0;
+ if (e === 2)
+ return !1;
+ }
+ if (4 & e) {
+ var i = new Uint8Array(t.response, 0, 3);
+ return i[0] === 68 && i[1] === 68 && i[2] === 83;
+ }
+ } catch {
+ }
+ return !1;
+ }, r.IsUASupportingBlobStorage = !0, r.IDBStorageEnabled = !1, r._ParseURL = function(t) {
+ document.createElement("a").href = t;
+ var e = t.substring(0, t.lastIndexOf("#")), n = t.substring(e.lastIndexOf("/") + 1, t.length);
+ return t.substring(0, t.indexOf(n, 0));
+ }, r._ReturnFullUrlLocation = function(t) {
+ return t.indexOf("http:/") === -1 && t.indexOf("https:/") === -1 && typeof window < "u" ? r._ParseURL(window.location.href) + t : t;
+ }, r;
+ }(), gc = function() {
+ function r(t, e, n) {
+ this.gradient = t, this.color1 = e, this.color2 = n;
+ }
+ return r.prototype.getColorToRef = function(t) {
+ this.color2 ? I.b.LerpToRef(this.color1, this.color2, Math.random(), t) : t.copyFrom(this.color1);
+ }, r;
+ }(), ad = function(r, t) {
+ this.gradient = r, this.color = t;
+ }, vc = function() {
+ function r(t, e, n) {
+ this.gradient = t, this.factor1 = e, this.factor2 = n;
+ }
+ return r.prototype.getFactor = function() {
+ return this.factor2 === void 0 || this.factor2 === this.factor1 ? this.factor1 : this.factor1 + (this.factor2 - this.factor1) * Math.random();
+ }, r;
+ }(), On = function() {
+ function r() {
+ }
+ return r.GetCurrentGradient = function(t, e, n) {
+ if (e[0].gradient > t)
+ n(e[0], e[0], 1);
+ else {
+ for (var i = 0; i < e.length - 1; i++) {
+ var o = e[i], a = e[i + 1];
+ if (t >= o.gradient && t <= a.gradient)
+ return void n(o, a, (t - o.gradient) / (a.gradient - o.gradient));
+ }
+ var s = e.length - 1;
+ n(e[s], e[s], 1);
+ }
+ }, r;
+ }(), sd = function() {
+ function r(t) {
+ this.particleSystem = t, this.position = u.e.Zero(), this.direction = u.e.Zero(), this.color = new I.b(0, 0, 0, 0), this.colorStep = new I.b(0, 0, 0, 0), this.lifeTime = 1, this.age = 0, this.size = 0, this.scale = new u.d(1, 1), this.angle = 0, this.angularSpeed = 0, this.cellIndex = 0, this._attachedSubEmitters = null, this._currentColor1 = new I.b(0, 0, 0, 0), this._currentColor2 = new I.b(0, 0, 0, 0), this._currentSize1 = 0, this._currentSize2 = 0, this._currentAngularSpeed1 = 0, this._currentAngularSpeed2 = 0, this._currentVelocity1 = 0, this._currentVelocity2 = 0, this._currentLimitVelocity1 = 0, this._currentLimitVelocity2 = 0, this._currentDrag1 = 0, this._currentDrag2 = 0, this.id = r._Count++, this.particleSystem.isAnimationSheetEnabled && this.updateCellInfoFromSystem();
+ }
+ return r.prototype.updateCellInfoFromSystem = function() {
+ this.cellIndex = this.particleSystem.startSpriteCellID;
+ }, r.prototype.updateCellIndex = function() {
+ var t = this.age, e = this.particleSystem.spriteCellChangeSpeed;
+ this.particleSystem.spriteRandomStartCell && (this._randomCellOffset === void 0 && (this._randomCellOffset = Math.random() * this.lifeTime), e === 0 ? (e = 1, t = this._randomCellOffset) : t += this._randomCellOffset);
+ var n = this._initialEndSpriteCellID - this._initialStartSpriteCellID, i = $.a.Clamp(t * e % this.lifeTime / this.lifeTime);
+ this.cellIndex = this._initialStartSpriteCellID + i * n | 0;
+ }, r.prototype._inheritParticleInfoToSubEmitter = function(t) {
+ if (t.particleSystem.emitter.position) {
+ var e = t.particleSystem.emitter;
+ if (e.position.copyFrom(this.position), t.inheritDirection) {
+ var n = u.c.Vector3[0];
+ this.direction.normalizeToRef(n), e.setDirection(n, 0, Math.PI / 2);
+ }
+ } else
+ t.particleSystem.emitter.copyFrom(this.position);
+ this.direction.scaleToRef(t.inheritedVelocityAmount / 2, u.c.Vector3[0]), t.particleSystem._inheritedVelocityOffset.copyFrom(u.c.Vector3[0]);
+ }, r.prototype._inheritParticleInfoToSubEmitters = function() {
+ var t = this;
+ this._attachedSubEmitters && this._attachedSubEmitters.length > 0 && this._attachedSubEmitters.forEach(function(e) {
+ t._inheritParticleInfoToSubEmitter(e);
+ });
+ }, r.prototype._reset = function() {
+ this.age = 0, this.id = r._Count++, this._currentColorGradient = null, this._currentSizeGradient = null, this._currentAngularSpeedGradient = null, this._currentVelocityGradient = null, this._currentLimitVelocityGradient = null, this._currentDragGradient = null, this.cellIndex = this.particleSystem.startSpriteCellID, this._randomCellOffset = void 0;
+ }, r.prototype.copyTo = function(t) {
+ t.position.copyFrom(this.position), this._initialDirection ? t._initialDirection ? t._initialDirection.copyFrom(this._initialDirection) : t._initialDirection = this._initialDirection.clone() : t._initialDirection = null, t.direction.copyFrom(this.direction), this._localPosition && (t._localPosition ? t._localPosition.copyFrom(this._localPosition) : t._localPosition = this._localPosition.clone()), t.color.copyFrom(this.color), t.colorStep.copyFrom(this.colorStep), t.lifeTime = this.lifeTime, t.age = this.age, t._randomCellOffset = this._randomCellOffset, t.size = this.size, t.scale.copyFrom(this.scale), t.angle = this.angle, t.angularSpeed = this.angularSpeed, t.particleSystem = this.particleSystem, t.cellIndex = this.cellIndex, t.id = this.id, t._attachedSubEmitters = this._attachedSubEmitters, this._currentColorGradient && (t._currentColorGradient = this._currentColorGradient, t._currentColor1.copyFrom(this._currentColor1), t._currentColor2.copyFrom(this._currentColor2)), this._currentSizeGradient && (t._currentSizeGradient = this._currentSizeGradient, t._currentSize1 = this._currentSize1, t._currentSize2 = this._currentSize2), this._currentAngularSpeedGradient && (t._currentAngularSpeedGradient = this._currentAngularSpeedGradient, t._currentAngularSpeed1 = this._currentAngularSpeed1, t._currentAngularSpeed2 = this._currentAngularSpeed2), this._currentVelocityGradient && (t._currentVelocityGradient = this._currentVelocityGradient, t._currentVelocity1 = this._currentVelocity1, t._currentVelocity2 = this._currentVelocity2), this._currentLimitVelocityGradient && (t._currentLimitVelocityGradient = this._currentLimitVelocityGradient, t._currentLimitVelocity1 = this._currentLimitVelocity1, t._currentLimitVelocity2 = this._currentLimitVelocity2), this._currentDragGradient && (t._currentDragGradient = this._currentDragGradient, t._currentDrag1 = this._currentDrag1, t._currentDrag2 = this._currentDrag2), this.particleSystem.isAnimationSheetEnabled && (t._initialStartSpriteCellID = this._initialStartSpriteCellID, t._initialEndSpriteCellID = this._initialEndSpriteCellID), this.particleSystem.useRampGradients && (t.remapData && this.remapData ? t.remapData.copyFrom(this.remapData) : t.remapData = new u.f(0, 0, 0, 0)), this._randomNoiseCoordinates1 && (t._randomNoiseCoordinates1 ? (t._randomNoiseCoordinates1.copyFrom(this._randomNoiseCoordinates1), t._randomNoiseCoordinates2.copyFrom(this._randomNoiseCoordinates2)) : (t._randomNoiseCoordinates1 = this._randomNoiseCoordinates1.clone(), t._randomNoiseCoordinates2 = this._randomNoiseCoordinates2.clone()));
+ }, r._Count = 0, r;
+ }();
+ (function(r) {
+ r[r.ATTACHED = 0] = "ATTACHED", r[r.END = 1] = "END";
+ })(Rr || (Rr = {}));
+ var mo = function() {
+ function r(t) {
+ if (this.particleSystem = t, this.type = Rr.END, this.inheritDirection = !1, this.inheritedVelocityAmount = 0, !t.emitter || !t.emitter.dispose) {
+ var e = O.a.GetClass("BABYLON.AbstractMesh");
+ t.emitter = new e("SubemitterSystemEmitter", t.getScene());
+ }
+ t.onDisposeObservable.add(function() {
+ t.emitter && t.emitter.dispose && t.emitter.dispose();
+ });
+ }
+ return r.prototype.clone = function() {
+ var t = this.particleSystem.emitter;
+ t ? t instanceof u.e ? t = t.clone() : t.getClassName().indexOf("Mesh") !== -1 && ((t = new (O.a.GetClass("BABYLON.Mesh"))("", t.getScene())).isVisible = !1) : t = new u.e();
+ var e = new r(this.particleSystem.clone("", t));
+ return e.particleSystem.name += "Clone", e.type = this.type, e.inheritDirection = this.inheritDirection, e.inheritedVelocityAmount = this.inheritedVelocityAmount, e.particleSystem._disposeEmitterOnDispose = !0, e.particleSystem.disposeOnStop = !0, e;
+ }, r.prototype.serialize = function() {
+ var t = {};
+ return t.type = this.type, t.inheritDirection = this.inheritDirection, t.inheritedVelocityAmount = this.inheritedVelocityAmount, t.particleSystem = this.particleSystem.serialize(), t;
+ }, r._ParseParticleSystem = function(t, e, n) {
+ throw En.a.WarnImport("ParseParticle");
+ }, r.Parse = function(t, e, n) {
+ var i = t.particleSystem, o = new r(r._ParseParticleSystem(i, e, n));
+ return o.type = t.type, o.inheritDirection = t.inheritDirection, o.inheritedVelocityAmount = t.inheritedVelocityAmount, o.particleSystem._isSubEmitter = !0, o;
+ }, r.prototype.dispose = function() {
+ this.particleSystem.dispose();
+ }, r;
+ }(), hm = `
+varying vec2 vUV;
+varying vec4 vColor;
+uniform vec4 textureMask;
+uniform sampler2D diffuseSampler;
+#include
+#include
+#include
+#include
+#ifdef RAMPGRADIENT
+varying vec4 remapRanges;
+uniform sampler2D rampSampler;
+#endif
+void main(void) {
+#include
+vec4 textureColor=texture2D(diffuseSampler,vUV);
+vec4 baseColor=(textureColor*textureMask+(vec4(1.,1.,1.,1.)-textureMask))*vColor;
+#ifdef RAMPGRADIENT
+float alpha=baseColor.a;
+float remappedColorIndex=clamp((alpha-remapRanges.x)/remapRanges.y,0.0,1.0);
+vec4 rampColor=texture2D(rampSampler,vec2(1.0-remappedColorIndex,0.));
+baseColor.rgb*=rampColor.rgb;
+
+float finalAlpha=baseColor.a;
+baseColor.a=clamp((alpha*rampColor.a-remapRanges.z)/remapRanges.w,0.0,1.0);
+#endif
+#ifdef BLENDMULTIPLYMODE
+float sourceAlpha=vColor.a*textureColor.a;
+baseColor.rgb=baseColor.rgb*sourceAlpha+vec3(1.0)*(1.0-sourceAlpha);
+#endif
+
+
+#ifdef IMAGEPROCESSINGPOSTPROCESS
+baseColor.rgb=toLinearSpace(baseColor.rgb);
+#else
+#ifdef IMAGEPROCESSING
+baseColor.rgb=toLinearSpace(baseColor.rgb);
+baseColor=applyImageProcessing(baseColor);
+#endif
+#endif
+gl_FragColor=baseColor;
+}`;
+ ze.a.ShadersStore.particlesPixelShader = hm;
+ var dm = `
+attribute vec3 position;
+attribute vec4 color;
+attribute float angle;
+attribute vec2 size;
+#ifdef ANIMATESHEET
+attribute float cellIndex;
+#endif
+#ifndef BILLBOARD
+attribute vec3 direction;
+#endif
+#ifdef BILLBOARDSTRETCHED
+attribute vec3 direction;
+#endif
+#ifdef RAMPGRADIENT
+attribute vec4 remapData;
+#endif
+attribute vec2 offset;
+
+uniform mat4 view;
+uniform mat4 projection;
+uniform vec2 translationPivot;
+#ifdef ANIMATESHEET
+uniform vec3 particlesInfos;
+#endif
+
+varying vec2 vUV;
+varying vec4 vColor;
+varying vec3 vPositionW;
+#ifdef RAMPGRADIENT
+varying vec4 remapRanges;
+#endif
+#if defined(BILLBOARD) && !defined(BILLBOARDY) && !defined(BILLBOARDSTRETCHED)
+uniform mat4 invView;
+#endif
+#include
+#ifdef BILLBOARD
+uniform vec3 eyePosition;
+#endif
+vec3 rotate(vec3 yaxis,vec3 rotatedCorner) {
+vec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));
+vec3 zaxis=normalize(cross(yaxis,xaxis));
+vec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);
+vec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);
+vec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);
+mat3 rotMatrix=mat3(row0,row1,row2);
+vec3 alignedCorner=rotMatrix*rotatedCorner;
+return position+alignedCorner;
+}
+#ifdef BILLBOARDSTRETCHED
+vec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {
+vec3 normalizedToCamera=normalize(toCamera);
+vec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));
+vec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));
+vec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);
+vec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);
+vec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);
+mat3 rotMatrix=mat3(row0,row1,row2);
+vec3 alignedCorner=rotMatrix*rotatedCorner;
+return position+alignedCorner;
+}
+#endif
+void main(void) {
+vec2 cornerPos;
+cornerPos=(vec2(offset.x-0.5,offset.y-0.5)-translationPivot)*size+translationPivot;
+#ifdef BILLBOARD
+
+vec3 rotatedCorner;
+#ifdef BILLBOARDY
+rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
+rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
+rotatedCorner.y=0.;
+vec3 yaxis=position-eyePosition;
+yaxis.y=0.;
+vPositionW=rotate(normalize(yaxis),rotatedCorner);
+vec3 viewPos=(view*vec4(vPositionW,1.0)).xyz;
+#elif defined(BILLBOARDSTRETCHED)
+rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
+rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
+rotatedCorner.z=0.;
+vec3 toCamera=position-eyePosition;
+vPositionW=rotateAlign(toCamera,rotatedCorner);
+vec3 viewPos=(view*vec4(vPositionW,1.0)).xyz;
+#else
+rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
+rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
+rotatedCorner.z=0.;
+vec3 viewPos=(view*vec4(position,1.0)).xyz+rotatedCorner;
+vPositionW=(invView*vec4(viewPos,1)).xyz;
+#endif
+#ifdef RAMPGRADIENT
+remapRanges=remapData;
+#endif
+
+gl_Position=projection*vec4(viewPos,1.0);
+#else
+
+vec3 rotatedCorner;
+rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
+rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
+rotatedCorner.y=0.;
+vec3 yaxis=normalize(direction);
+vPositionW=rotate(yaxis,rotatedCorner);
+gl_Position=projection*view*vec4(vPositionW,1.0);
+#endif
+vColor=color;
+#ifdef ANIMATESHEET
+float rowOffset=floor(cellIndex*particlesInfos.z);
+float columnOffset=cellIndex-rowOffset/particlesInfos.z;
+vec2 uvScale=particlesInfos.xy;
+vec2 uvOffset=vec2(offset.x ,1.0-offset.y);
+vUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;
+#else
+vUV=offset;
+#endif
+
+#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)
+vec4 worldPos=vec4(vPositionW,1.0);
+#endif
+#include
+}`;
+ ze.a.ShadersStore.particlesVertexShader = dm;
+ var cn = function(r) {
+ function t(e, n, i, o, a, s) {
+ o === void 0 && (o = null), a === void 0 && (a = !1), s === void 0 && (s = 0.01);
+ var d = r.call(this, e) || this;
+ return d._inheritedVelocityOffset = new u.e(), d.onDisposeObservable = new C.c(), d.onStoppedObservable = new C.c(), d._particles = new Array(), d._stockParticles = new Array(), d._newPartsExcess = 0, d._vertexBuffers = {}, d._scaledColorStep = new I.b(0, 0, 0, 0), d._colorDiff = new I.b(0, 0, 0, 0), d._scaledDirection = u.e.Zero(), d._scaledGravity = u.e.Zero(), d._currentRenderId = -1, d._useInstancing = !1, d._started = !1, d._stopped = !1, d._actualFrame = 0, d._currentEmitRate1 = 0, d._currentEmitRate2 = 0, d._currentStartSize1 = 0, d._currentStartSize2 = 0, d._rawTextureWidth = 256, d._useRampGradients = !1, d._disposeEmitterOnDispose = !1, d.isLocal = !1, d._onBeforeDrawParticlesObservable = null, d.recycleParticle = function(p) {
+ var y = d._particles.pop();
+ y !== p && y.copyTo(p), d._stockParticles.push(y);
+ }, d._createParticle = function() {
+ var p;
+ if (d._stockParticles.length !== 0 ? (p = d._stockParticles.pop())._reset() : p = new sd(d), d._subEmitters && d._subEmitters.length > 0) {
+ var y = d._subEmitters[Math.floor(Math.random() * d._subEmitters.length)];
+ p._attachedSubEmitters = [], y.forEach(function(P) {
+ if (P.type === Rr.ATTACHED) {
+ var R = P.clone();
+ p._attachedSubEmitters.push(R), R.particleSystem.start();
+ }
+ });
+ }
+ return p;
+ }, d._emitFromParticle = function(p) {
+ if (d._subEmitters && d._subEmitters.length !== 0) {
+ var y = Math.floor(Math.random() * d._subEmitters.length);
+ d._subEmitters[y].forEach(function(P) {
+ if (P.type === Rr.END) {
+ var R = P.clone();
+ p._inheritParticleInfoToSubEmitter(R), R.particleSystem._rootParticleSystem = d, d.activeSubSystems.push(R.particleSystem), R.particleSystem.start();
+ }
+ });
+ }
+ }, d._capacity = n, d._epsilon = s, d._isAnimationSheetEnabled = a, i && i.getClassName() !== "Scene" ? (d._engine = i, d.defaultProjectionMatrix = u.a.PerspectiveFovLH(0.8, 1, 0.1, 100)) : (d._scene = i || te.a.LastCreatedScene, d._engine = d._scene.getEngine(), d.uniqueId = d._scene.getUniqueId(), d._scene.particleSystems.push(d)), d._engine.getCaps().vertexArrayObject && (d._vertexArrayObject = null), d._attachImageProcessingConfiguration(null), d._customEffect = { 0: o }, d._useInstancing = d._engine.getCaps().instancedArrays, d._createIndexBuffer(), d._createVertexBuffers(), d.particleEmitterType = new xr(), d.updateFunction = function(p) {
+ var y = null, P = null;
+ d.noiseTexture && (y = d.noiseTexture.getSize(), P = d.noiseTexture.getContent());
+ for (var R, B = function() {
+ R = p[F];
+ var z = d._scaledUpdateSpeed, J = R.age;
+ if (R.age += z, R.age > R.lifeTime) {
+ var ie = R.age - J;
+ z = (R.lifeTime - J) * z / ie, R.age = R.lifeTime;
+ }
+ var se = R.age / R.lifeTime;
+ d._colorGradients && d._colorGradients.length > 0 ? On.GetCurrentGradient(se, d._colorGradients, function(Ae, Ee, Se) {
+ Ae !== R._currentColorGradient && (R._currentColor1.copyFrom(R._currentColor2), Ee.getColorToRef(R._currentColor2), R._currentColorGradient = Ae), I.b.LerpToRef(R._currentColor1, R._currentColor2, Se, R.color);
+ }) : (R.colorStep.scaleToRef(z, d._scaledColorStep), R.color.addInPlace(d._scaledColorStep), R.color.a < 0 && (R.color.a = 0)), d._angularSpeedGradients && d._angularSpeedGradients.length > 0 && On.GetCurrentGradient(se, d._angularSpeedGradients, function(Ae, Ee, Se) {
+ Ae !== R._currentAngularSpeedGradient && (R._currentAngularSpeed1 = R._currentAngularSpeed2, R._currentAngularSpeed2 = Ee.getFactor(), R._currentAngularSpeedGradient = Ae), R.angularSpeed = $.a.Lerp(R._currentAngularSpeed1, R._currentAngularSpeed2, Se);
+ }), R.angle += R.angularSpeed * z;
+ var ce = z;
+ if (d._velocityGradients && d._velocityGradients.length > 0 && On.GetCurrentGradient(se, d._velocityGradients, function(Ae, Ee, Se) {
+ Ae !== R._currentVelocityGradient && (R._currentVelocity1 = R._currentVelocity2, R._currentVelocity2 = Ee.getFactor(), R._currentVelocityGradient = Ae), ce *= $.a.Lerp(R._currentVelocity1, R._currentVelocity2, Se);
+ }), R.direction.scaleToRef(ce, d._scaledDirection), d._limitVelocityGradients && d._limitVelocityGradients.length > 0 && On.GetCurrentGradient(se, d._limitVelocityGradients, function(Ae, Ee, Se) {
+ Ae !== R._currentLimitVelocityGradient && (R._currentLimitVelocity1 = R._currentLimitVelocity2, R._currentLimitVelocity2 = Ee.getFactor(), R._currentLimitVelocityGradient = Ae);
+ var De = $.a.Lerp(R._currentLimitVelocity1, R._currentLimitVelocity2, Se);
+ R.direction.length() > De && R.direction.scaleInPlace(d.limitVelocityDamping);
+ }), d._dragGradients && d._dragGradients.length > 0 && On.GetCurrentGradient(se, d._dragGradients, function(Ae, Ee, Se) {
+ Ae !== R._currentDragGradient && (R._currentDrag1 = R._currentDrag2, R._currentDrag2 = Ee.getFactor(), R._currentDragGradient = Ae);
+ var De = $.a.Lerp(R._currentDrag1, R._currentDrag2, Se);
+ d._scaledDirection.scaleInPlace(1 - De);
+ }), d.isLocal && R._localPosition ? (R._localPosition.addInPlace(d._scaledDirection), u.e.TransformCoordinatesToRef(R._localPosition, d._emitterWorldMatrix, R.position)) : R.position.addInPlace(d._scaledDirection), P && y && R._randomNoiseCoordinates1) {
+ var ue = d._fetchR(R._randomNoiseCoordinates1.x, R._randomNoiseCoordinates1.y, y.width, y.height, P), fe = d._fetchR(R._randomNoiseCoordinates1.z, R._randomNoiseCoordinates2.x, y.width, y.height, P), ve = d._fetchR(R._randomNoiseCoordinates2.y, R._randomNoiseCoordinates2.z, y.width, y.height, P), Te = u.c.Vector3[0], Re = u.c.Vector3[1];
+ Te.copyFromFloats((2 * ue - 1) * d.noiseStrength.x, (2 * fe - 1) * d.noiseStrength.y, (2 * ve - 1) * d.noiseStrength.z), Te.scaleToRef(z, Re), R.direction.addInPlace(Re);
+ }
+ if (d.gravity.scaleToRef(z, d._scaledGravity), R.direction.addInPlace(d._scaledGravity), d._sizeGradients && d._sizeGradients.length > 0 && On.GetCurrentGradient(se, d._sizeGradients, function(Ae, Ee, Se) {
+ Ae !== R._currentSizeGradient && (R._currentSize1 = R._currentSize2, R._currentSize2 = Ee.getFactor(), R._currentSizeGradient = Ae), R.size = $.a.Lerp(R._currentSize1, R._currentSize2, Se);
+ }), d._useRampGradients && (d._colorRemapGradients && d._colorRemapGradients.length > 0 && On.GetCurrentGradient(se, d._colorRemapGradients, function(Ae, Ee, Se) {
+ var De = $.a.Lerp(Ae.factor1, Ee.factor1, Se), xe = $.a.Lerp(Ae.factor2, Ee.factor2, Se);
+ R.remapData.x = De, R.remapData.y = xe - De;
+ }), d._alphaRemapGradients && d._alphaRemapGradients.length > 0 && On.GetCurrentGradient(se, d._alphaRemapGradients, function(Ae, Ee, Se) {
+ var De = $.a.Lerp(Ae.factor1, Ee.factor1, Se), xe = $.a.Lerp(Ae.factor2, Ee.factor2, Se);
+ R.remapData.z = De, R.remapData.w = xe - De;
+ })), d._isAnimationSheetEnabled && R.updateCellIndex(), R._inheritParticleInfoToSubEmitters(), R.age >= R.lifeTime)
+ return d._emitFromParticle(R), R._attachedSubEmitters && (R._attachedSubEmitters.forEach(function(Ae) {
+ Ae.particleSystem.disposeOnStop = !0, Ae.particleSystem.stop();
+ }), R._attachedSubEmitters = null), d.recycleParticle(R), F--, "continue";
+ }, F = 0; F < p.length; F++)
+ B();
+ }, d;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "onDispose", { set: function(e) {
+ this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver), this._onDisposeObserver = this.onDisposeObservable.add(e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "useRampGradients", { get: function() {
+ return this._useRampGradients;
+ }, set: function(e) {
+ this._useRampGradients !== e && (this._useRampGradients = e, this._resetEffect());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "particles", { get: function() {
+ return this._particles;
+ }, enumerable: !1, configurable: !0 }), t.prototype.getActiveCount = function() {
+ return this._particles.length;
+ }, t.prototype.getClassName = function() {
+ return "ParticleSystem";
+ }, t.prototype.isStopping = function() {
+ return this._stopped && this.isAlive();
+ }, t.prototype.getCustomEffect = function(e) {
+ var n;
+ return e === void 0 && (e = 0), (n = this._customEffect[e]) !== null && n !== void 0 ? n : this._customEffect[0];
+ }, t.prototype.setCustomEffect = function(e, n) {
+ n === void 0 && (n = 0), this._customEffect[n] = e;
+ }, Object.defineProperty(t.prototype, "onBeforeDrawParticlesObservable", { get: function() {
+ return this._onBeforeDrawParticlesObservable || (this._onBeforeDrawParticlesObservable = new C.c()), this._onBeforeDrawParticlesObservable;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "vertexShaderName", { get: function() {
+ return "particles";
+ }, enumerable: !1, configurable: !0 }), t.prototype._addFactorGradient = function(e, n, i, o) {
+ var a = new vc(n, i, o);
+ e.push(a), e.sort(function(s, d) {
+ return s.gradient < d.gradient ? -1 : s.gradient > d.gradient ? 1 : 0;
+ });
+ }, t.prototype._removeFactorGradient = function(e, n) {
+ if (e)
+ for (var i = 0, o = 0, a = e; o < a.length; o++) {
+ if (a[o].gradient === n) {
+ e.splice(i, 1);
+ break;
+ }
+ i++;
+ }
+ }, t.prototype.addLifeTimeGradient = function(e, n, i) {
+ return this._lifeTimeGradients || (this._lifeTimeGradients = []), this._addFactorGradient(this._lifeTimeGradients, e, n, i), this;
+ }, t.prototype.removeLifeTimeGradient = function(e) {
+ return this._removeFactorGradient(this._lifeTimeGradients, e), this;
+ }, t.prototype.addSizeGradient = function(e, n, i) {
+ return this._sizeGradients || (this._sizeGradients = []), this._addFactorGradient(this._sizeGradients, e, n, i), this;
+ }, t.prototype.removeSizeGradient = function(e) {
+ return this._removeFactorGradient(this._sizeGradients, e), this;
+ }, t.prototype.addColorRemapGradient = function(e, n, i) {
+ return this._colorRemapGradients || (this._colorRemapGradients = []), this._addFactorGradient(this._colorRemapGradients, e, n, i), this;
+ }, t.prototype.removeColorRemapGradient = function(e) {
+ return this._removeFactorGradient(this._colorRemapGradients, e), this;
+ }, t.prototype.addAlphaRemapGradient = function(e, n, i) {
+ return this._alphaRemapGradients || (this._alphaRemapGradients = []), this._addFactorGradient(this._alphaRemapGradients, e, n, i), this;
+ }, t.prototype.removeAlphaRemapGradient = function(e) {
+ return this._removeFactorGradient(this._alphaRemapGradients, e), this;
+ }, t.prototype.addAngularSpeedGradient = function(e, n, i) {
+ return this._angularSpeedGradients || (this._angularSpeedGradients = []), this._addFactorGradient(this._angularSpeedGradients, e, n, i), this;
+ }, t.prototype.removeAngularSpeedGradient = function(e) {
+ return this._removeFactorGradient(this._angularSpeedGradients, e), this;
+ }, t.prototype.addVelocityGradient = function(e, n, i) {
+ return this._velocityGradients || (this._velocityGradients = []), this._addFactorGradient(this._velocityGradients, e, n, i), this;
+ }, t.prototype.removeVelocityGradient = function(e) {
+ return this._removeFactorGradient(this._velocityGradients, e), this;
+ }, t.prototype.addLimitVelocityGradient = function(e, n, i) {
+ return this._limitVelocityGradients || (this._limitVelocityGradients = []), this._addFactorGradient(this._limitVelocityGradients, e, n, i), this;
+ }, t.prototype.removeLimitVelocityGradient = function(e) {
+ return this._removeFactorGradient(this._limitVelocityGradients, e), this;
+ }, t.prototype.addDragGradient = function(e, n, i) {
+ return this._dragGradients || (this._dragGradients = []), this._addFactorGradient(this._dragGradients, e, n, i), this;
+ }, t.prototype.removeDragGradient = function(e) {
+ return this._removeFactorGradient(this._dragGradients, e), this;
+ }, t.prototype.addEmitRateGradient = function(e, n, i) {
+ return this._emitRateGradients || (this._emitRateGradients = []), this._addFactorGradient(this._emitRateGradients, e, n, i), this;
+ }, t.prototype.removeEmitRateGradient = function(e) {
+ return this._removeFactorGradient(this._emitRateGradients, e), this;
+ }, t.prototype.addStartSizeGradient = function(e, n, i) {
+ return this._startSizeGradients || (this._startSizeGradients = []), this._addFactorGradient(this._startSizeGradients, e, n, i), this;
+ }, t.prototype.removeStartSizeGradient = function(e) {
+ return this._removeFactorGradient(this._startSizeGradients, e), this;
+ }, t.prototype._createRampGradientTexture = function() {
+ if (this._rampGradients && this._rampGradients.length && !this._rampGradientsTexture && this._scene) {
+ for (var e = new Uint8Array(4 * this._rawTextureWidth), n = I.c.Color3[0], i = 0; i < this._rawTextureWidth; i++) {
+ var o = i / this._rawTextureWidth;
+ On.GetCurrentGradient(o, this._rampGradients, function(a, s, d) {
+ I.a.LerpToRef(a.color, s.color, d, n), e[4 * i] = 255 * n.r, e[4 * i + 1] = 255 * n.g, e[4 * i + 2] = 255 * n.b, e[4 * i + 3] = 255;
+ });
+ }
+ this._rampGradientsTexture = Zn.CreateRGBATexture(e, this._rawTextureWidth, 1, this._scene, !1, !1, h.a.TEXTURE_NEAREST_SAMPLINGMODE);
+ }
+ }, t.prototype.getRampGradients = function() {
+ return this._rampGradients;
+ }, t.prototype.forceRefreshGradients = function() {
+ this._syncRampGradientTexture();
+ }, t.prototype._syncRampGradientTexture = function() {
+ this._rampGradients && (this._rampGradients.sort(function(e, n) {
+ return e.gradient < n.gradient ? -1 : e.gradient > n.gradient ? 1 : 0;
+ }), this._rampGradientsTexture && (this._rampGradientsTexture.dispose(), this._rampGradientsTexture = null), this._createRampGradientTexture());
+ }, t.prototype.addRampGradient = function(e, n) {
+ this._rampGradients || (this._rampGradients = []);
+ var i = new ad(e, n);
+ return this._rampGradients.push(i), this._syncRampGradientTexture(), this;
+ }, t.prototype.removeRampGradient = function(e) {
+ return this._removeGradientAndTexture(e, this._rampGradients, this._rampGradientsTexture), this._rampGradientsTexture = null, this._rampGradients && this._rampGradients.length > 0 && this._createRampGradientTexture(), this;
+ }, t.prototype.addColorGradient = function(e, n, i) {
+ this._colorGradients || (this._colorGradients = []);
+ var o = new gc(e, n, i);
+ return this._colorGradients.push(o), this._colorGradients.sort(function(a, s) {
+ return a.gradient < s.gradient ? -1 : a.gradient > s.gradient ? 1 : 0;
+ }), this;
+ }, t.prototype.removeColorGradient = function(e) {
+ if (!this._colorGradients)
+ return this;
+ for (var n = 0, i = 0, o = this._colorGradients; i < o.length; i++) {
+ if (o[i].gradient === e) {
+ this._colorGradients.splice(n, 1);
+ break;
+ }
+ n++;
+ }
+ return this;
+ }, t.prototype._fetchR = function(e, n, i, o, a) {
+ return a[4 * (((e = 0.5 * Math.abs(e) + 0.5) * i % i | 0) + ((n = 0.5 * Math.abs(n) + 0.5) * o % o | 0) * i)] / 255;
+ }, t.prototype._reset = function() {
+ this._resetEffect();
+ }, t.prototype._resetEffect = function() {
+ this._vertexBuffer && (this._vertexBuffer.dispose(), this._vertexBuffer = null), this._spriteBuffer && (this._spriteBuffer.dispose(), this._spriteBuffer = null), this._vertexArrayObject && (this._engine.releaseVertexArrayObject(this._vertexArrayObject), this._vertexArrayObject = null), this._createVertexBuffers();
+ }, t.prototype._createVertexBuffers = function() {
+ this._vertexBufferSize = this._useInstancing ? 10 : 12, this._isAnimationSheetEnabled && (this._vertexBufferSize += 1), this._isBillboardBased && this.billboardMode !== t.BILLBOARDMODE_STRETCHED || (this._vertexBufferSize += 3), this._useRampGradients && (this._vertexBufferSize += 4);
+ var e = this._engine;
+ this._vertexData = new Float32Array(this._capacity * this._vertexBufferSize * (this._useInstancing ? 1 : 4)), this._vertexBuffer = new Oe.a(e, this._vertexData, !0, this._vertexBufferSize);
+ var n = 0, i = this._vertexBuffer.createVertexBuffer(Oe.b.PositionKind, n, 3, this._vertexBufferSize, this._useInstancing);
+ this._vertexBuffers[Oe.b.PositionKind] = i, n += 3;
+ var o = this._vertexBuffer.createVertexBuffer(Oe.b.ColorKind, n, 4, this._vertexBufferSize, this._useInstancing);
+ this._vertexBuffers[Oe.b.ColorKind] = o, n += 4;
+ var a = this._vertexBuffer.createVertexBuffer("angle", n, 1, this._vertexBufferSize, this._useInstancing);
+ this._vertexBuffers.angle = a, n += 1;
+ var s, d = this._vertexBuffer.createVertexBuffer("size", n, 2, this._vertexBufferSize, this._useInstancing);
+ if (this._vertexBuffers.size = d, n += 2, this._isAnimationSheetEnabled) {
+ var p = this._vertexBuffer.createVertexBuffer("cellIndex", n, 1, this._vertexBufferSize, this._useInstancing);
+ this._vertexBuffers.cellIndex = p, n += 1;
+ }
+ if (!this._isBillboardBased || this.billboardMode === t.BILLBOARDMODE_STRETCHED) {
+ var y = this._vertexBuffer.createVertexBuffer("direction", n, 3, this._vertexBufferSize, this._useInstancing);
+ this._vertexBuffers.direction = y, n += 3;
+ }
+ if (this._useRampGradients) {
+ var P = this._vertexBuffer.createVertexBuffer("remapData", n, 4, this._vertexBufferSize, this._useInstancing);
+ this._vertexBuffers.remapData = P, n += 4;
+ }
+ if (this._useInstancing) {
+ var R = new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]);
+ this._spriteBuffer = new Oe.a(e, R, !1, 2), s = this._spriteBuffer.createVertexBuffer("offset", 0, 2);
+ } else
+ s = this._vertexBuffer.createVertexBuffer("offset", n, 2, this._vertexBufferSize, this._useInstancing), n += 2;
+ this._vertexBuffers.offset = s;
+ }, t.prototype._createIndexBuffer = function() {
+ if (!this._useInstancing) {
+ for (var e = [], n = 0, i = 0; i < this._capacity; i++)
+ e.push(n), e.push(n + 1), e.push(n + 2), e.push(n), e.push(n + 2), e.push(n + 3), n += 4;
+ this._indexBuffer = this._engine.createIndexBuffer(e);
+ }
+ }, t.prototype.getCapacity = function() {
+ return this._capacity;
+ }, t.prototype.isAlive = function() {
+ return this._alive;
+ }, t.prototype.isStarted = function() {
+ return this._started;
+ }, t.prototype._prepareSubEmitterInternalArray = function() {
+ var e = this;
+ this._subEmitters = new Array(), this.subEmitters && this.subEmitters.forEach(function(n) {
+ n instanceof t ? e._subEmitters.push([new mo(n)]) : n instanceof mo ? e._subEmitters.push([n]) : n instanceof Array && e._subEmitters.push(n);
+ });
+ }, t.prototype.start = function(e) {
+ var n, i = this;
+ if (e === void 0 && (e = this.startDelay), !this.targetStopDuration && this._hasTargetStopDurationDependantGradient())
+ throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
+ if (e)
+ setTimeout(function() {
+ i.start(0);
+ }, e);
+ else {
+ if (this._prepareSubEmitterInternalArray(), this._started = !0, this._stopped = !1, this._actualFrame = 0, this._subEmitters && this._subEmitters.length != 0 && (this.activeSubSystems = new Array()), this._emitRateGradients && (this._emitRateGradients.length > 0 && (this._currentEmitRateGradient = this._emitRateGradients[0], this._currentEmitRate1 = this._currentEmitRateGradient.getFactor(), this._currentEmitRate2 = this._currentEmitRate1), this._emitRateGradients.length > 1 && (this._currentEmitRate2 = this._emitRateGradients[1].getFactor())), this._startSizeGradients && (this._startSizeGradients.length > 0 && (this._currentStartSizeGradient = this._startSizeGradients[0], this._currentStartSize1 = this._currentStartSizeGradient.getFactor(), this._currentStartSize2 = this._currentStartSize1), this._startSizeGradients.length > 1 && (this._currentStartSize2 = this._startSizeGradients[1].getFactor())), this.preWarmCycles) {
+ ((n = this.emitter) === null || n === void 0 ? void 0 : n.getClassName().indexOf("Mesh")) !== -1 && this.emitter.computeWorldMatrix(!0);
+ var o = this.noiseTexture;
+ if (o && o.onGeneratedObservable)
+ o.onGeneratedObservable.addOnce(function() {
+ setTimeout(function() {
+ for (var s = 0; s < i.preWarmCycles; s++)
+ i.animate(!0), o.render();
+ });
+ });
+ else
+ for (var a = 0; a < this.preWarmCycles; a++)
+ this.animate(!0);
+ }
+ this.beginAnimationOnStart && this.animations && this.animations.length > 0 && this._scene && this._scene.beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
+ }
+ }, t.prototype.stop = function(e) {
+ e === void 0 && (e = !0), this._stopped || (this.onStoppedObservable.notifyObservers(this), this._stopped = !0, e && this._stopSubEmitters());
+ }, t.prototype.reset = function() {
+ this._stockParticles = [], this._particles = [];
+ }, t.prototype._appendParticleVertex = function(e, n, i, o) {
+ var a = e * this._vertexBufferSize;
+ if (this._vertexData[a++] = n.position.x + this.worldOffset.x, this._vertexData[a++] = n.position.y + this.worldOffset.y, this._vertexData[a++] = n.position.z + this.worldOffset.z, this._vertexData[a++] = n.color.r, this._vertexData[a++] = n.color.g, this._vertexData[a++] = n.color.b, this._vertexData[a++] = n.color.a, this._vertexData[a++] = n.angle, this._vertexData[a++] = n.scale.x * n.size, this._vertexData[a++] = n.scale.y * n.size, this._isAnimationSheetEnabled && (this._vertexData[a++] = n.cellIndex), this._isBillboardBased)
+ this.billboardMode === t.BILLBOARDMODE_STRETCHED && (this._vertexData[a++] = n.direction.x, this._vertexData[a++] = n.direction.y, this._vertexData[a++] = n.direction.z);
+ else if (n._initialDirection) {
+ var s = n._initialDirection;
+ this.isLocal && (u.e.TransformNormalToRef(s, this._emitterWorldMatrix, u.c.Vector3[0]), s = u.c.Vector3[0]), s.x === 0 && s.z === 0 && (s.x = 1e-3), this._vertexData[a++] = s.x, this._vertexData[a++] = s.y, this._vertexData[a++] = s.z;
+ } else {
+ var d = n.direction;
+ this.isLocal && (u.e.TransformNormalToRef(d, this._emitterWorldMatrix, u.c.Vector3[0]), d = u.c.Vector3[0]), d.x === 0 && d.z === 0 && (d.x = 1e-3), this._vertexData[a++] = d.x, this._vertexData[a++] = d.y, this._vertexData[a++] = d.z;
+ }
+ this._useRampGradients && n.remapData && (this._vertexData[a++] = n.remapData.x, this._vertexData[a++] = n.remapData.y, this._vertexData[a++] = n.remapData.z, this._vertexData[a++] = n.remapData.w), this._useInstancing || (this._isAnimationSheetEnabled && (i === 0 ? i = this._epsilon : i === 1 && (i = 1 - this._epsilon), o === 0 ? o = this._epsilon : o === 1 && (o = 1 - this._epsilon)), this._vertexData[a++] = i, this._vertexData[a++] = o);
+ }, t.prototype._stopSubEmitters = function() {
+ this.activeSubSystems && (this.activeSubSystems.forEach(function(e) {
+ e.stop(!0);
+ }), this.activeSubSystems = new Array());
+ }, t.prototype._removeFromRoot = function() {
+ if (this._rootParticleSystem) {
+ var e = this._rootParticleSystem.activeSubSystems.indexOf(this);
+ e !== -1 && this._rootParticleSystem.activeSubSystems.splice(e, 1), this._rootParticleSystem = null;
+ }
+ }, t.prototype._update = function(e) {
+ var n, i = this;
+ if (this._alive = this._particles.length > 0, this.emitter.position) {
+ var o = this.emitter;
+ this._emitterWorldMatrix = o.getWorldMatrix();
+ } else {
+ var a = this.emitter;
+ this._emitterWorldMatrix = u.a.Translation(a.x, a.y, a.z);
+ }
+ this.updateFunction(this._particles);
+ for (var s, d = function() {
+ if (p._particles.length === p._capacity)
+ return "break";
+ if (n = p._createParticle(), p._particles.push(n), p.targetStopDuration && p._lifeTimeGradients && p._lifeTimeGradients.length > 0) {
+ var P = $.a.Clamp(p._actualFrame / p.targetStopDuration);
+ On.GetCurrentGradient(P, p._lifeTimeGradients, function(F, z) {
+ var J = F, ie = z, se = J.getFactor(), ce = ie.getFactor(), ue = (P - J.gradient) / (ie.gradient - J.gradient);
+ n.lifeTime = $.a.Lerp(se, ce, ue);
+ });
+ } else
+ n.lifeTime = $.a.RandomRange(p.minLifeTime, p.maxLifeTime);
+ var R = $.a.RandomRange(p.minEmitPower, p.maxEmitPower);
+ if (p.startPositionFunction ? p.startPositionFunction(p._emitterWorldMatrix, n.position, n, p.isLocal) : p.particleEmitterType.startPositionFunction(p._emitterWorldMatrix, n.position, n, p.isLocal), p.isLocal && (n._localPosition ? n._localPosition.copyFrom(n.position) : n._localPosition = n.position.clone(), u.e.TransformCoordinatesToRef(n._localPosition, p._emitterWorldMatrix, n.position)), p.startDirectionFunction ? p.startDirectionFunction(p._emitterWorldMatrix, n.direction, n, p.isLocal) : p.particleEmitterType.startDirectionFunction(p._emitterWorldMatrix, n.direction, n, p.isLocal), R === 0 ? n._initialDirection ? n._initialDirection.copyFrom(n.direction) : n._initialDirection = n.direction.clone() : n._initialDirection = null, n.direction.scaleInPlace(R), p._sizeGradients && p._sizeGradients.length !== 0 ? (n._currentSizeGradient = p._sizeGradients[0], n._currentSize1 = n._currentSizeGradient.getFactor(), n.size = n._currentSize1, p._sizeGradients.length > 1 ? n._currentSize2 = p._sizeGradients[1].getFactor() : n._currentSize2 = n._currentSize1) : n.size = $.a.RandomRange(p.minSize, p.maxSize), n.scale.copyFromFloats($.a.RandomRange(p.minScaleX, p.maxScaleX), $.a.RandomRange(p.minScaleY, p.maxScaleY)), p._startSizeGradients && p._startSizeGradients[0] && p.targetStopDuration) {
+ var B = p._actualFrame / p.targetStopDuration;
+ On.GetCurrentGradient(B, p._startSizeGradients, function(F, z, J) {
+ F !== i._currentStartSizeGradient && (i._currentStartSize1 = i._currentStartSize2, i._currentStartSize2 = z.getFactor(), i._currentStartSizeGradient = F);
+ var ie = $.a.Lerp(i._currentStartSize1, i._currentStartSize2, J);
+ n.scale.scaleInPlace(ie);
+ });
+ }
+ p._angularSpeedGradients && p._angularSpeedGradients.length !== 0 ? (n._currentAngularSpeedGradient = p._angularSpeedGradients[0], n.angularSpeed = n._currentAngularSpeedGradient.getFactor(), n._currentAngularSpeed1 = n.angularSpeed, p._angularSpeedGradients.length > 1 ? n._currentAngularSpeed2 = p._angularSpeedGradients[1].getFactor() : n._currentAngularSpeed2 = n._currentAngularSpeed1) : n.angularSpeed = $.a.RandomRange(p.minAngularSpeed, p.maxAngularSpeed), n.angle = $.a.RandomRange(p.minInitialRotation, p.maxInitialRotation), p._velocityGradients && p._velocityGradients.length > 0 && (n._currentVelocityGradient = p._velocityGradients[0], n._currentVelocity1 = n._currentVelocityGradient.getFactor(), p._velocityGradients.length > 1 ? n._currentVelocity2 = p._velocityGradients[1].getFactor() : n._currentVelocity2 = n._currentVelocity1), p._limitVelocityGradients && p._limitVelocityGradients.length > 0 && (n._currentLimitVelocityGradient = p._limitVelocityGradients[0], n._currentLimitVelocity1 = n._currentLimitVelocityGradient.getFactor(), p._limitVelocityGradients.length > 1 ? n._currentLimitVelocity2 = p._limitVelocityGradients[1].getFactor() : n._currentLimitVelocity2 = n._currentLimitVelocity1), p._dragGradients && p._dragGradients.length > 0 && (n._currentDragGradient = p._dragGradients[0], n._currentDrag1 = n._currentDragGradient.getFactor(), p._dragGradients.length > 1 ? n._currentDrag2 = p._dragGradients[1].getFactor() : n._currentDrag2 = n._currentDrag1), p._colorGradients && p._colorGradients.length !== 0 ? (n._currentColorGradient = p._colorGradients[0], n._currentColorGradient.getColorToRef(n.color), n._currentColor1.copyFrom(n.color), p._colorGradients.length > 1 ? p._colorGradients[1].getColorToRef(n._currentColor2) : n._currentColor2.copyFrom(n.color)) : (s = $.a.RandomRange(0, 1), I.b.LerpToRef(p.color1, p.color2, s, n.color), p.colorDead.subtractToRef(n.color, p._colorDiff), p._colorDiff.scaleToRef(1 / n.lifeTime, n.colorStep)), p._isAnimationSheetEnabled && (n._initialStartSpriteCellID = p.startSpriteCellID, n._initialEndSpriteCellID = p.endSpriteCellID), n.direction.addInPlace(p._inheritedVelocityOffset), p._useRampGradients && (n.remapData = new u.f(0, 1, 0, 1)), p.noiseTexture && (n._randomNoiseCoordinates1 ? (n._randomNoiseCoordinates1.copyFromFloats(Math.random(), Math.random(), Math.random()), n._randomNoiseCoordinates2.copyFromFloats(Math.random(), Math.random(), Math.random())) : (n._randomNoiseCoordinates1 = new u.e(Math.random(), Math.random(), Math.random()), n._randomNoiseCoordinates2 = new u.e(Math.random(), Math.random(), Math.random()))), n._inheritParticleInfoToSubEmitters();
+ }, p = this, y = 0; y < e && d() !== "break"; y++)
+ ;
+ }, t._GetAttributeNamesOrOptions = function(e, n, i) {
+ e === void 0 && (e = !1), n === void 0 && (n = !1), i === void 0 && (i = !1);
+ var o = [Oe.b.PositionKind, Oe.b.ColorKind, "angle", "offset", "size"];
+ return e && o.push("cellIndex"), n || o.push("direction"), i && o.push("remapData"), o;
+ }, t._GetEffectCreationOptions = function(e) {
+ e === void 0 && (e = !1);
+ var n = ["invView", "view", "projection", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "textureMask", "translationPivot", "eyePosition"];
+ return e && n.push("particlesInfos"), n;
+ }, t.prototype.fillDefines = function(e, n) {
+ if (this._scene && (this._scene.clipPlane && e.push("#define CLIPPLANE"), this._scene.clipPlane2 && e.push("#define CLIPPLANE2"), this._scene.clipPlane3 && e.push("#define CLIPPLANE3"), this._scene.clipPlane4 && e.push("#define CLIPPLANE4"), this._scene.clipPlane5 && e.push("#define CLIPPLANE5"), this._scene.clipPlane6 && e.push("#define CLIPPLANE6")), this._isAnimationSheetEnabled && e.push("#define ANIMATESHEET"), n === t.BLENDMODE_MULTIPLY && e.push("#define BLENDMULTIPLYMODE"), this._useRampGradients && e.push("#define RAMPGRADIENT"), this._isBillboardBased)
+ switch (e.push("#define BILLBOARD"), this.billboardMode) {
+ case t.BILLBOARDMODE_Y:
+ e.push("#define BILLBOARDY");
+ break;
+ case t.BILLBOARDMODE_STRETCHED:
+ e.push("#define BILLBOARDSTRETCHED");
+ break;
+ case t.BILLBOARDMODE_ALL:
+ e.push("#define BILLBOARDMODE_ALL");
+ }
+ this._imageProcessingConfiguration && (this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines), e.push(this._imageProcessingConfigurationDefines.toString()));
+ }, t.prototype.fillUniformsAttributesAndSamplerNames = function(e, n, i) {
+ n.push.apply(n, t._GetAttributeNamesOrOptions(this._isAnimationSheetEnabled, this._isBillboardBased && this.billboardMode !== t.BILLBOARDMODE_STRETCHED, this._useRampGradients)), e.push.apply(e, t._GetEffectCreationOptions(this._isAnimationSheetEnabled)), i.push("diffuseSampler", "rampSampler"), this._imageProcessingConfiguration && (vn.a.PrepareUniforms(e, this._imageProcessingConfigurationDefines), vn.a.PrepareSamplers(i, this._imageProcessingConfigurationDefines));
+ }, t.prototype._getEffect = function(e) {
+ var n = this.getCustomEffect(e);
+ if (n)
+ return n;
+ var i = [];
+ this.fillDefines(i, e);
+ var o = i.join(`
+`);
+ if (this._cachedDefines !== o) {
+ this._cachedDefines = o;
+ var a = [], s = [], d = [];
+ this.fillUniformsAttributesAndSamplerNames(s, a, d), this._effect = this._engine.createEffect("particles", a, s, d, o);
+ }
+ return this._effect;
+ }, t.prototype.animate = function(e) {
+ var n, i = this;
+ if (e === void 0 && (e = !1), this._started) {
+ if (!e && this._scene) {
+ if (!this.isReady() || this._currentRenderId === this._scene.getFrameId())
+ return;
+ this._currentRenderId = this._scene.getFrameId();
+ }
+ var o;
+ if (this._scaledUpdateSpeed = this.updateSpeed * (e ? this.preWarmStepOffset : ((n = this._scene) === null || n === void 0 ? void 0 : n.getAnimationRatio()) || 1), this.manualEmitCount > -1)
+ o = this.manualEmitCount, this._newPartsExcess = 0, this.manualEmitCount = 0;
+ else {
+ var a = this.emitRate;
+ if (this._emitRateGradients && this._emitRateGradients.length > 0 && this.targetStopDuration) {
+ var s = this._actualFrame / this.targetStopDuration;
+ On.GetCurrentGradient(s, this._emitRateGradients, function(P, R, B) {
+ P !== i._currentEmitRateGradient && (i._currentEmitRate1 = i._currentEmitRate2, i._currentEmitRate2 = R.getFactor(), i._currentEmitRateGradient = P), a = $.a.Lerp(i._currentEmitRate1, i._currentEmitRate2, B);
+ });
+ }
+ o = a * this._scaledUpdateSpeed >> 0, this._newPartsExcess += a * this._scaledUpdateSpeed - o;
+ }
+ if (this._newPartsExcess > 1 && (o += this._newPartsExcess >> 0, this._newPartsExcess -= this._newPartsExcess >> 0), this._alive = !1, this._stopped ? o = 0 : (this._actualFrame += this._scaledUpdateSpeed, this.targetStopDuration && this._actualFrame >= this.targetStopDuration && this.stop()), this._update(o), this._stopped && (this._alive || (this._started = !1, this.onAnimationEnd && this.onAnimationEnd(), this.disposeOnStop && this._scene && this._scene._toBeDisposed.push(this))), !e) {
+ for (var d = 0, p = 0; p < this._particles.length; p++) {
+ var y = this._particles[p];
+ this._appendParticleVertices(d, y), d += this._useInstancing ? 1 : 4;
+ }
+ this._vertexBuffer && this._vertexBuffer.update(this._vertexData);
+ }
+ this.manualEmitCount === 0 && this.disposeOnStop && this.stop();
+ }
+ }, t.prototype._appendParticleVertices = function(e, n) {
+ this._appendParticleVertex(e++, n, 0, 0), this._useInstancing || (this._appendParticleVertex(e++, n, 1, 0), this._appendParticleVertex(e++, n, 1, 1), this._appendParticleVertex(e++, n, 0, 1));
+ }, t.prototype.rebuild = function() {
+ for (var e in this._createIndexBuffer(), this._vertexBuffer && this._vertexBuffer._rebuild(), this._vertexBuffers)
+ this._vertexBuffers[e]._rebuild();
+ }, t.prototype.isReady = function() {
+ if (!this.emitter || this._imageProcessingConfiguration && !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady())
+ return !1;
+ if (this.blendMode !== t.BLENDMODE_MULTIPLYADD) {
+ if (!this._getEffect(this.blendMode).isReady())
+ return !1;
+ } else if (!this._getEffect(t.BLENDMODE_MULTIPLY).isReady() || !this._getEffect(t.BLENDMODE_ADD).isReady())
+ return !1;
+ return !0;
+ }, t.prototype._render = function(e) {
+ var n, i, o = this._getEffect(e), a = this._engine;
+ a.enableEffect(o);
+ var s = (n = this.defaultViewMatrix) !== null && n !== void 0 ? n : this._scene.getViewMatrix();
+ if (o.setTexture("diffuseSampler", this.particleTexture), o.setMatrix("view", s), o.setMatrix("projection", (i = this.defaultProjectionMatrix) !== null && i !== void 0 ? i : this._scene.getProjectionMatrix()), this._isAnimationSheetEnabled && this.particleTexture) {
+ var d = this.particleTexture.getBaseSize();
+ o.setFloat3("particlesInfos", this.spriteCellWidth / d.width, this.spriteCellHeight / d.height, this.spriteCellWidth / d.width);
+ }
+ if (o.setVector2("translationPivot", this.translationPivot), o.setFloat4("textureMask", this.textureMask.r, this.textureMask.g, this.textureMask.b, this.textureMask.a), this._isBillboardBased && this._scene) {
+ var p = this._scene.activeCamera;
+ o.setVector3("eyePosition", p.globalPosition);
+ }
+ this._rampGradientsTexture && (this._rampGradients && this._rampGradients.length || (this._rampGradientsTexture.dispose(), this._rampGradientsTexture = null), o.setTexture("rampSampler", this._rampGradientsTexture));
+ var y = o.defines;
+ switch (this._scene && (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4 || this._scene.clipPlane5 || this._scene.clipPlane6) && Bu.a.BindClipPlane(o, this._scene), y.indexOf("#define BILLBOARDMODE_ALL") >= 0 && (s.invertToRef(u.c.Matrix[0]), o.setMatrix("invView", u.c.Matrix[0])), this._vertexArrayObject !== void 0 ? (this._vertexArrayObject || (this._vertexArrayObject = this._engine.recordVertexArrayObject(this._vertexBuffers, this._indexBuffer, o)), this._engine.bindVertexArrayObject(this._vertexArrayObject, this._indexBuffer)) : a.bindBuffers(this._vertexBuffers, this._indexBuffer, o), this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess && this._imageProcessingConfiguration.bind(o), e) {
+ case t.BLENDMODE_ADD:
+ a.setAlphaMode(h.a.ALPHA_ADD);
+ break;
+ case t.BLENDMODE_ONEONE:
+ a.setAlphaMode(h.a.ALPHA_ONEONE);
+ break;
+ case t.BLENDMODE_STANDARD:
+ a.setAlphaMode(h.a.ALPHA_COMBINE);
+ break;
+ case t.BLENDMODE_MULTIPLY:
+ a.setAlphaMode(h.a.ALPHA_MULTIPLY);
+ }
+ return this._onBeforeDrawParticlesObservable && this._onBeforeDrawParticlesObservable.notifyObservers(o), this._useInstancing ? a.drawArraysType(h.a.MATERIAL_TriangleFanDrawMode, 0, 4, this._particles.length) : a.drawElementsType(h.a.MATERIAL_TriangleFillMode, 0, 6 * this._particles.length), this._particles.length;
+ }, t.prototype.render = function() {
+ if (!this.isReady() || !this._particles.length)
+ return 0;
+ var e = this._engine;
+ e.setState && (e.setState(!1), this.forceDepthWrite && e.setDepthWrite(!0));
+ var n = 0;
+ return n = this.blendMode === t.BLENDMODE_MULTIPLYADD ? this._render(t.BLENDMODE_MULTIPLY) + this._render(t.BLENDMODE_ADD) : this._render(this.blendMode), this._engine.unbindInstanceAttributes(), this._engine.setAlphaMode(h.a.ALPHA_DISABLE), n;
+ }, t.prototype.dispose = function(e) {
+ if (e === void 0 && (e = !0), this._vertexBuffer && (this._vertexBuffer.dispose(), this._vertexBuffer = null), this._spriteBuffer && (this._spriteBuffer.dispose(), this._spriteBuffer = null), this._indexBuffer && (this._engine._releaseBuffer(this._indexBuffer), this._indexBuffer = null), this._vertexArrayObject && (this._engine.releaseVertexArrayObject(this._vertexArrayObject), this._vertexArrayObject = null), e && this.particleTexture && (this.particleTexture.dispose(), this.particleTexture = null), e && this.noiseTexture && (this.noiseTexture.dispose(), this.noiseTexture = null), this._rampGradientsTexture && (this._rampGradientsTexture.dispose(), this._rampGradientsTexture = null), this._removeFromRoot(), this._subEmitters && this._subEmitters.length) {
+ for (var n = 0; n < this._subEmitters.length; n++)
+ for (var i = 0, o = this._subEmitters[n]; i < o.length; i++)
+ o[i].dispose();
+ this._subEmitters = [], this.subEmitters = [];
+ }
+ this._disposeEmitterOnDispose && this.emitter && this.emitter.dispose && this.emitter.dispose(!0), this._onBeforeDrawParticlesObservable && this._onBeforeDrawParticlesObservable.clear(), this._scene && ((n = this._scene.particleSystems.indexOf(this)) > -1 && this._scene.particleSystems.splice(n, 1), this._scene._activeParticleSystems.dispose()), this.onDisposeObservable.notifyObservers(this), this.onDisposeObservable.clear(), this.onStoppedObservable.clear(), this.reset();
+ }, t.prototype.clone = function(e, n) {
+ var i = Object(c.a)({}, this._customEffect), o = null, a = this._engine;
+ if (a.createEffectForParticles && this.customShader != null) {
+ var s = (o = this.customShader).shaderOptions.defines.length > 0 ? o.shaderOptions.defines.join(`
+`) : "";
+ i[0] = a.createEffectForParticles(o.shaderPath.fragmentElement, o.shaderOptions.uniforms, o.shaderOptions.samplers, s);
+ }
+ var d = this.serialize(), p = t.Parse(d, this._scene || this._engine, "");
+ return p.name = e, p.customShader = o, p._customEffect = i, n === void 0 && (n = this.emitter), this.noiseTexture && (p.noiseTexture = this.noiseTexture.clone()), p.emitter = n, this.preventAutoStart || p.start(), p;
+ }, t.prototype.serialize = function(e) {
+ e === void 0 && (e = !1);
+ var n = {};
+ if (t._Serialize(n, this, e), n.textureMask = this.textureMask.asArray(), n.customShader = this.customShader, n.preventAutoStart = this.preventAutoStart, this.subEmitters) {
+ n.subEmitters = [], this._subEmitters || this._prepareSubEmitterInternalArray();
+ for (var i = 0, o = this._subEmitters; i < o.length; i++) {
+ for (var a = [], s = 0, d = o[i]; s < d.length; s++) {
+ var p = d[s];
+ a.push(p.serialize());
+ }
+ n.subEmitters.push(a);
+ }
+ }
+ return n;
+ }, t._Serialize = function(e, n, i) {
+ if (e.name = n.name, e.id = n.id, e.capacity = n.getCapacity(), n.emitter.position) {
+ var o = n.emitter;
+ e.emitterId = o.id;
+ } else {
+ var a = n.emitter;
+ e.emitter = a.asArray();
+ }
+ n.particleEmitterType && (e.particleEmitterType = n.particleEmitterType.serialize()), n.particleTexture && (i ? e.texture = n.particleTexture.serialize() : (e.textureName = n.particleTexture.name, e.invertY = !!n.particleTexture._invertY)), e.isLocal = n.isLocal, L.a.AppendSerializedAnimations(n, e), e.beginAnimationOnStart = n.beginAnimationOnStart, e.beginAnimationFrom = n.beginAnimationFrom, e.beginAnimationTo = n.beginAnimationTo, e.beginAnimationLoop = n.beginAnimationLoop, e.startDelay = n.startDelay, e.renderingGroupId = n.renderingGroupId, e.isBillboardBased = n.isBillboardBased, e.billboardMode = n.billboardMode, e.minAngularSpeed = n.minAngularSpeed, e.maxAngularSpeed = n.maxAngularSpeed, e.minSize = n.minSize, e.maxSize = n.maxSize, e.minScaleX = n.minScaleX, e.maxScaleX = n.maxScaleX, e.minScaleY = n.minScaleY, e.maxScaleY = n.maxScaleY, e.minEmitPower = n.minEmitPower, e.maxEmitPower = n.maxEmitPower, e.minLifeTime = n.minLifeTime, e.maxLifeTime = n.maxLifeTime, e.emitRate = n.emitRate, e.gravity = n.gravity.asArray(), e.noiseStrength = n.noiseStrength.asArray(), e.color1 = n.color1.asArray(), e.color2 = n.color2.asArray(), e.colorDead = n.colorDead.asArray(), e.updateSpeed = n.updateSpeed, e.targetStopDuration = n.targetStopDuration, e.blendMode = n.blendMode, e.preWarmCycles = n.preWarmCycles, e.preWarmStepOffset = n.preWarmStepOffset, e.minInitialRotation = n.minInitialRotation, e.maxInitialRotation = n.maxInitialRotation, e.startSpriteCellID = n.startSpriteCellID, e.endSpriteCellID = n.endSpriteCellID, e.spriteCellChangeSpeed = n.spriteCellChangeSpeed, e.spriteCellWidth = n.spriteCellWidth, e.spriteCellHeight = n.spriteCellHeight, e.spriteRandomStartCell = n.spriteRandomStartCell, e.isAnimationSheetEnabled = n.isAnimationSheetEnabled;
+ var s = n.getColorGradients();
+ if (s) {
+ e.colorGradients = [];
+ for (var d = 0, p = s; d < p.length; d++) {
+ var y = p[d], P = { gradient: y.gradient, color1: y.color1.asArray() };
+ y.color2 ? P.color2 = y.color2.asArray() : P.color2 = y.color1.asArray(), e.colorGradients.push(P);
+ }
+ }
+ var R = n.getRampGradients();
+ if (R) {
+ e.rampGradients = [];
+ for (var B = 0, F = R; B < F.length; B++) {
+ var z = F[B];
+ P = { gradient: z.gradient, color: z.color.asArray() }, e.rampGradients.push(P);
+ }
+ e.useRampGradients = n.useRampGradients;
+ }
+ var J = n.getColorRemapGradients();
+ if (J) {
+ e.colorRemapGradients = [];
+ for (var ie = 0, se = J; ie < se.length; ie++) {
+ var ce = se[ie];
+ P = { gradient: ce.gradient, factor1: ce.factor1 }, ce.factor2 !== void 0 ? P.factor2 = ce.factor2 : P.factor2 = ce.factor1, e.colorRemapGradients.push(P);
+ }
+ }
+ var ue = n.getAlphaRemapGradients();
+ if (ue) {
+ e.alphaRemapGradients = [];
+ for (var fe = 0, ve = ue; fe < ve.length; fe++) {
+ var Te = ve[fe];
+ P = { gradient: Te.gradient, factor1: Te.factor1 }, Te.factor2 !== void 0 ? P.factor2 = Te.factor2 : P.factor2 = Te.factor1, e.alphaRemapGradients.push(P);
+ }
+ }
+ var Re = n.getSizeGradients();
+ if (Re) {
+ e.sizeGradients = [];
+ for (var Ae = 0, Ee = Re; Ae < Ee.length; Ae++) {
+ var Se = Ee[Ae];
+ P = { gradient: Se.gradient, factor1: Se.factor1 }, Se.factor2 !== void 0 ? P.factor2 = Se.factor2 : P.factor2 = Se.factor1, e.sizeGradients.push(P);
+ }
+ }
+ var De = n.getAngularSpeedGradients();
+ if (De) {
+ e.angularSpeedGradients = [];
+ for (var xe = 0, Le = De; xe < Le.length; xe++) {
+ var Me = Le[xe];
+ P = { gradient: Me.gradient, factor1: Me.factor1 }, Me.factor2 !== void 0 ? P.factor2 = Me.factor2 : P.factor2 = Me.factor1, e.angularSpeedGradients.push(P);
+ }
+ }
+ var we = n.getVelocityGradients();
+ if (we) {
+ e.velocityGradients = [];
+ for (var Ye = 0, et = we; Ye < et.length; Ye++) {
+ var nt = et[Ye];
+ P = { gradient: nt.gradient, factor1: nt.factor1 }, nt.factor2 !== void 0 ? P.factor2 = nt.factor2 : P.factor2 = nt.factor1, e.velocityGradients.push(P);
+ }
+ }
+ var ct = n.getDragGradients();
+ if (ct) {
+ e.dragGradients = [];
+ for (var Ke = 0, rt = ct; Ke < rt.length; Ke++) {
+ var it = rt[Ke];
+ P = { gradient: it.gradient, factor1: it.factor1 }, it.factor2 !== void 0 ? P.factor2 = it.factor2 : P.factor2 = it.factor1, e.dragGradients.push(P);
+ }
+ }
+ var qe = n.getEmitRateGradients();
+ if (qe) {
+ e.emitRateGradients = [];
+ for (var ut = 0, Ve = qe; ut < Ve.length; ut++) {
+ var Ze = Ve[ut];
+ P = { gradient: Ze.gradient, factor1: Ze.factor1 }, Ze.factor2 !== void 0 ? P.factor2 = Ze.factor2 : P.factor2 = Ze.factor1, e.emitRateGradients.push(P);
+ }
+ }
+ var vt = n.getStartSizeGradients();
+ if (vt) {
+ e.startSizeGradients = [];
+ for (var jt = 0, Dt = vt; jt < Dt.length; jt++) {
+ var Yt = Dt[jt];
+ P = { gradient: Yt.gradient, factor1: Yt.factor1 }, Yt.factor2 !== void 0 ? P.factor2 = Yt.factor2 : P.factor2 = Yt.factor1, e.startSizeGradients.push(P);
+ }
+ }
+ var mt = n.getLifeTimeGradients();
+ if (mt) {
+ e.lifeTimeGradients = [];
+ for (var qt = 0, Ht = mt; qt < Ht.length; qt++) {
+ var kt = Ht[qt];
+ P = { gradient: kt.gradient, factor1: kt.factor1 }, kt.factor2 !== void 0 ? P.factor2 = kt.factor2 : P.factor2 = kt.factor1, e.lifeTimeGradients.push(P);
+ }
+ }
+ var Wt = n.getLimitVelocityGradients();
+ if (Wt) {
+ e.limitVelocityGradients = [];
+ for (var bt = 0, Rt = Wt; bt < Rt.length; bt++) {
+ var Zt = Rt[bt];
+ P = { gradient: Zt.gradient, factor1: Zt.factor1 }, Zt.factor2 !== void 0 ? P.factor2 = Zt.factor2 : P.factor2 = Zt.factor1, e.limitVelocityGradients.push(P);
+ }
+ e.limitVelocityDamping = n.limitVelocityDamping;
+ }
+ n.noiseTexture && (e.noiseTexture = n.noiseTexture.serialize());
+ }, t._Parse = function(e, n, i, o) {
+ var a;
+ a = i instanceof wt.a ? null : i;
+ var s, d = O.a.GetClass("BABYLON.Texture");
+ if (d && a && (e.texture ? n.particleTexture = d.Parse(e.texture, a, o) : e.textureName && (n.particleTexture = new d(o + e.textureName, a, !1, e.invertY === void 0 || e.invertY), n.particleTexture.name = e.textureName)), e.emitterId || e.emitterId === 0 || e.emitter !== void 0 ? e.emitterId && a ? n.emitter = a.getLastMeshByID(e.emitterId) : n.emitter = u.e.FromArray(e.emitter) : n.emitter = u.e.Zero(), n.isLocal = !!e.isLocal, e.renderingGroupId !== void 0 && (n.renderingGroupId = e.renderingGroupId), e.isBillboardBased !== void 0 && (n.isBillboardBased = e.isBillboardBased), e.billboardMode !== void 0 && (n.billboardMode = e.billboardMode), e.animations) {
+ for (var p = 0; p < e.animations.length; p++) {
+ var y = e.animations[p], P = O.a.GetClass("BABYLON.Animation");
+ P && n.animations.push(P.Parse(y));
+ }
+ n.beginAnimationOnStart = e.beginAnimationOnStart, n.beginAnimationFrom = e.beginAnimationFrom, n.beginAnimationTo = e.beginAnimationTo, n.beginAnimationLoop = e.beginAnimationLoop;
+ }
+ if (e.autoAnimate && a && a.beginAnimation(n, e.autoAnimateFrom, e.autoAnimateTo, e.autoAnimateLoop, e.autoAnimateSpeed || 1), n.startDelay = 0 | e.startDelay, n.minAngularSpeed = e.minAngularSpeed, n.maxAngularSpeed = e.maxAngularSpeed, n.minSize = e.minSize, n.maxSize = e.maxSize, e.minScaleX && (n.minScaleX = e.minScaleX, n.maxScaleX = e.maxScaleX, n.minScaleY = e.minScaleY, n.maxScaleY = e.maxScaleY), e.preWarmCycles !== void 0 && (n.preWarmCycles = e.preWarmCycles, n.preWarmStepOffset = e.preWarmStepOffset), e.minInitialRotation !== void 0 && (n.minInitialRotation = e.minInitialRotation, n.maxInitialRotation = e.maxInitialRotation), n.minLifeTime = e.minLifeTime, n.maxLifeTime = e.maxLifeTime, n.minEmitPower = e.minEmitPower, n.maxEmitPower = e.maxEmitPower, n.emitRate = e.emitRate, n.gravity = u.e.FromArray(e.gravity), e.noiseStrength && (n.noiseStrength = u.e.FromArray(e.noiseStrength)), n.color1 = I.b.FromArray(e.color1), n.color2 = I.b.FromArray(e.color2), n.colorDead = I.b.FromArray(e.colorDead), n.updateSpeed = e.updateSpeed, n.targetStopDuration = e.targetStopDuration, n.blendMode = e.blendMode, e.colorGradients)
+ for (var R = 0, B = e.colorGradients; R < B.length; R++) {
+ var F = B[R];
+ n.addColorGradient(F.gradient, I.b.FromArray(F.color1), F.color2 ? I.b.FromArray(F.color2) : void 0);
+ }
+ if (e.rampGradients) {
+ for (var z = 0, J = e.rampGradients; z < J.length; z++) {
+ var ie = J[z];
+ n.addRampGradient(ie.gradient, I.a.FromArray(ie.color));
+ }
+ n.useRampGradients = e.useRampGradients;
+ }
+ if (e.colorRemapGradients)
+ for (var se = 0, ce = e.colorRemapGradients; se < ce.length; se++) {
+ var ue = ce[se];
+ n.addColorRemapGradient(ue.gradient, ue.factor1 !== void 0 ? ue.factor1 : ue.factor, ue.factor2);
+ }
+ if (e.alphaRemapGradients)
+ for (var fe = 0, ve = e.alphaRemapGradients; fe < ve.length; fe++) {
+ var Te = ve[fe];
+ n.addAlphaRemapGradient(Te.gradient, Te.factor1 !== void 0 ? Te.factor1 : Te.factor, Te.factor2);
+ }
+ if (e.sizeGradients)
+ for (var Re = 0, Ae = e.sizeGradients; Re < Ae.length; Re++) {
+ var Ee = Ae[Re];
+ n.addSizeGradient(Ee.gradient, Ee.factor1 !== void 0 ? Ee.factor1 : Ee.factor, Ee.factor2);
+ }
+ if (e.angularSpeedGradients)
+ for (var Se = 0, De = e.angularSpeedGradients; Se < De.length; Se++) {
+ var xe = De[Se];
+ n.addAngularSpeedGradient(xe.gradient, xe.factor1 !== void 0 ? xe.factor1 : xe.factor, xe.factor2);
+ }
+ if (e.velocityGradients)
+ for (var Le = 0, Me = e.velocityGradients; Le < Me.length; Le++) {
+ var we = Me[Le];
+ n.addVelocityGradient(we.gradient, we.factor1 !== void 0 ? we.factor1 : we.factor, we.factor2);
+ }
+ if (e.dragGradients)
+ for (var Ye = 0, et = e.dragGradients; Ye < et.length; Ye++) {
+ var nt = et[Ye];
+ n.addDragGradient(nt.gradient, nt.factor1 !== void 0 ? nt.factor1 : nt.factor, nt.factor2);
+ }
+ if (e.emitRateGradients)
+ for (var ct = 0, Ke = e.emitRateGradients; ct < Ke.length; ct++) {
+ var rt = Ke[ct];
+ n.addEmitRateGradient(rt.gradient, rt.factor1 !== void 0 ? rt.factor1 : rt.factor, rt.factor2);
+ }
+ if (e.startSizeGradients)
+ for (var it = 0, qe = e.startSizeGradients; it < qe.length; it++) {
+ var ut = qe[it];
+ n.addStartSizeGradient(ut.gradient, ut.factor1 !== void 0 ? ut.factor1 : ut.factor, ut.factor2);
+ }
+ if (e.lifeTimeGradients)
+ for (var Ve = 0, Ze = e.lifeTimeGradients; Ve < Ze.length; Ve++) {
+ var vt = Ze[Ve];
+ n.addLifeTimeGradient(vt.gradient, vt.factor1 !== void 0 ? vt.factor1 : vt.factor, vt.factor2);
+ }
+ if (e.limitVelocityGradients) {
+ for (var jt = 0, Dt = e.limitVelocityGradients; jt < Dt.length; jt++) {
+ var Yt = Dt[jt];
+ n.addLimitVelocityGradient(Yt.gradient, Yt.factor1 !== void 0 ? Yt.factor1 : Yt.factor, Yt.factor2);
+ }
+ n.limitVelocityDamping = e.limitVelocityDamping;
+ }
+ if (e.noiseTexture && a) {
+ var mt = O.a.GetClass("BABYLON.ProceduralTexture");
+ n.noiseTexture = mt.Parse(e.noiseTexture, a, o);
+ }
+ if (e.particleEmitterType) {
+ switch (e.particleEmitterType.type) {
+ case "SphereParticleEmitter":
+ s = new aa();
+ break;
+ case "SphereDirectedParticleEmitter":
+ s = new Zs();
+ break;
+ case "ConeEmitter":
+ case "ConeParticleEmitter":
+ s = new Ys();
+ break;
+ case "CylinderParticleEmitter":
+ s = new oa();
+ break;
+ case "CylinderDirectedParticleEmitter":
+ s = new Ks();
+ break;
+ case "HemisphericParticleEmitter":
+ s = new Qs();
+ break;
+ case "PointParticleEmitter":
+ s = new qs();
+ break;
+ case "MeshParticleEmitter":
+ s = new Ku();
+ break;
+ case "BoxEmitter":
+ case "BoxParticleEmitter":
+ default:
+ s = new xr();
+ }
+ s.parse(e.particleEmitterType, a);
+ } else
+ (s = new xr()).parse(e, a);
+ n.particleEmitterType = s, n.startSpriteCellID = e.startSpriteCellID, n.endSpriteCellID = e.endSpriteCellID, n.spriteCellWidth = e.spriteCellWidth, n.spriteCellHeight = e.spriteCellHeight, n.spriteCellChangeSpeed = e.spriteCellChangeSpeed, n.spriteRandomStartCell = e.spriteRandomStartCell;
+ }, t.Parse = function(e, n, i, o) {
+ o === void 0 && (o = !1);
+ var a, s = e.name, d = null, p = null;
+ if (a = n instanceof wt.a ? n : n.getEngine(), e.customShader && a.createEffectForParticles) {
+ var y = (p = e.customShader).shaderOptions.defines.length > 0 ? p.shaderOptions.defines.join(`
+`) : "";
+ d = a.createEffectForParticles(p.shaderPath.fragmentElement, p.shaderOptions.uniforms, p.shaderOptions.samplers, y);
+ }
+ var P = new t(s, e.capacity, n, d, e.isAnimationSheetEnabled);
+ if (P.customShader = p, e.id && (P.id = e.id), e.subEmitters) {
+ P.subEmitters = [];
+ for (var R = 0, B = e.subEmitters; R < B.length; R++) {
+ for (var F = [], z = 0, J = B[R]; z < J.length; z++) {
+ var ie = J[z];
+ F.push(mo.Parse(ie, n, i));
+ }
+ P.subEmitters.push(F);
+ }
+ }
+ return t._Parse(e, P, n, i), e.textureMask && (P.textureMask = I.b.FromArray(e.textureMask)), e.preventAutoStart && (P.preventAutoStart = e.preventAutoStart), o || P.preventAutoStart || P.start(), P;
+ }, t.BILLBOARDMODE_Y = h.a.PARTICLES_BILLBOARDMODE_Y, t.BILLBOARDMODE_ALL = h.a.PARTICLES_BILLBOARDMODE_ALL, t.BILLBOARDMODE_STRETCHED = h.a.PARTICLES_BILLBOARDMODE_STRETCHED, t;
+ }(co);
+ mo._ParseParticleSystem = cn.Parse, ze.a.ShadersStore.gpuUpdateParticlesPixelShader = `#version 300 es
+void main() {
+discard;
+}
+`;
+ var fm = `#version 300 es
+#define PI 3.14159
+uniform float currentCount;
+uniform float timeDelta;
+uniform float stopFactor;
+#ifndef LOCAL
+uniform mat4 emitterWM;
+#endif
+uniform vec2 lifeTime;
+uniform vec2 emitPower;
+uniform vec2 sizeRange;
+uniform vec4 scaleRange;
+#ifndef COLORGRADIENTS
+uniform vec4 color1;
+uniform vec4 color2;
+#endif
+uniform vec3 gravity;
+uniform sampler2D randomSampler;
+uniform sampler2D randomSampler2;
+uniform vec4 angleRange;
+#ifdef BOXEMITTER
+uniform vec3 direction1;
+uniform vec3 direction2;
+uniform vec3 minEmitBox;
+uniform vec3 maxEmitBox;
+#endif
+#ifdef POINTEMITTER
+uniform vec3 direction1;
+uniform vec3 direction2;
+#endif
+#ifdef HEMISPHERICEMITTER
+uniform float radius;
+uniform float radiusRange;
+uniform float directionRandomizer;
+#endif
+#ifdef SPHEREEMITTER
+uniform float radius;
+uniform float radiusRange;
+#ifdef DIRECTEDSPHEREEMITTER
+uniform vec3 direction1;
+uniform vec3 direction2;
+#else
+uniform float directionRandomizer;
+#endif
+#endif
+#ifdef CYLINDEREMITTER
+uniform float radius;
+uniform float height;
+uniform float radiusRange;
+#ifdef DIRECTEDCYLINDEREMITTER
+uniform vec3 direction1;
+uniform vec3 direction2;
+#else
+uniform float directionRandomizer;
+#endif
+#endif
+#ifdef CONEEMITTER
+uniform vec2 radius;
+uniform float coneAngle;
+uniform vec2 height;
+uniform float directionRandomizer;
+#endif
+
+in vec3 position;
+#ifdef CUSTOMEMITTER
+in vec3 initialPosition;
+#endif
+in float age;
+in float life;
+in vec4 seed;
+in vec3 size;
+#ifndef COLORGRADIENTS
+in vec4 color;
+#endif
+in vec3 direction;
+#ifndef BILLBOARD
+in vec3 initialDirection;
+#endif
+#ifdef ANGULARSPEEDGRADIENTS
+in float angle;
+#else
+in vec2 angle;
+#endif
+#ifdef ANIMATESHEET
+in float cellIndex;
+#ifdef ANIMATESHEETRANDOMSTART
+in float cellStartOffset;
+#endif
+#endif
+#ifdef NOISE
+in vec3 noiseCoordinates1;
+in vec3 noiseCoordinates2;
+#endif
+
+out vec3 outPosition;
+#ifdef CUSTOMEMITTER
+out vec3 outInitialPosition;
+#endif
+out float outAge;
+out float outLife;
+out vec4 outSeed;
+out vec3 outSize;
+#ifndef COLORGRADIENTS
+out vec4 outColor;
+#endif
+out vec3 outDirection;
+#ifndef BILLBOARD
+out vec3 outInitialDirection;
+#endif
+#ifdef ANGULARSPEEDGRADIENTS
+out float outAngle;
+#else
+out vec2 outAngle;
+#endif
+#ifdef ANIMATESHEET
+out float outCellIndex;
+#ifdef ANIMATESHEETRANDOMSTART
+out float outCellStartOffset;
+#endif
+#endif
+#ifdef NOISE
+out vec3 outNoiseCoordinates1;
+out vec3 outNoiseCoordinates2;
+#endif
+#ifdef SIZEGRADIENTS
+uniform sampler2D sizeGradientSampler;
+#endif
+#ifdef ANGULARSPEEDGRADIENTS
+uniform sampler2D angularSpeedGradientSampler;
+#endif
+#ifdef VELOCITYGRADIENTS
+uniform sampler2D velocityGradientSampler;
+#endif
+#ifdef LIMITVELOCITYGRADIENTS
+uniform sampler2D limitVelocityGradientSampler;
+uniform float limitVelocityDamping;
+#endif
+#ifdef DRAGGRADIENTS
+uniform sampler2D dragGradientSampler;
+#endif
+#ifdef NOISE
+uniform vec3 noiseStrength;
+uniform sampler2D noiseSampler;
+#endif
+#ifdef ANIMATESHEET
+uniform vec3 cellInfos;
+#endif
+vec3 getRandomVec3(float offset) {
+return texture(randomSampler2,vec2(float(gl_VertexID)*offset/currentCount,0)).rgb;
+}
+vec4 getRandomVec4(float offset) {
+return texture(randomSampler,vec2(float(gl_VertexID)*offset/currentCount,0));
+}
+void main() {
+float newAge=age+timeDelta;
+
+if (newAge>=life && stopFactor != 0.) {
+vec3 newPosition;
+vec3 newDirection;
+
+vec4 randoms=getRandomVec4(seed.x);
+
+outLife=lifeTime.x+(lifeTime.y-lifeTime.x)*randoms.r;
+outAge=newAge-life;
+
+outSeed=seed;
+
+#ifdef SIZEGRADIENTS
+outSize.x=texture(sizeGradientSampler,vec2(0,0)).r;
+#else
+outSize.x=sizeRange.x+(sizeRange.y-sizeRange.x)*randoms.g;
+#endif
+outSize.y=scaleRange.x+(scaleRange.y-scaleRange.x)*randoms.b;
+outSize.z=scaleRange.z+(scaleRange.w-scaleRange.z)*randoms.a;
+#ifndef COLORGRADIENTS
+
+outColor=color1+(color2-color1)*randoms.b;
+#endif
+
+#ifndef ANGULARSPEEDGRADIENTS
+outAngle.y=angleRange.x+(angleRange.y-angleRange.x)*randoms.a;
+outAngle.x=angleRange.z+(angleRange.w-angleRange.z)*randoms.r;
+#else
+outAngle=angleRange.z+(angleRange.w-angleRange.z)*randoms.r;
+#endif
+
+#ifdef POINTEMITTER
+vec3 randoms2=getRandomVec3(seed.y);
+vec3 randoms3=getRandomVec3(seed.z);
+newPosition=vec3(0,0,0);
+newDirection=direction1+(direction2-direction1)*randoms3;
+#elif defined(BOXEMITTER)
+vec3 randoms2=getRandomVec3(seed.y);
+vec3 randoms3=getRandomVec3(seed.z);
+newPosition=minEmitBox+(maxEmitBox-minEmitBox)*randoms2;
+newDirection=direction1+(direction2-direction1)*randoms3;
+#elif defined(HEMISPHERICEMITTER)
+vec3 randoms2=getRandomVec3(seed.y);
+vec3 randoms3=getRandomVec3(seed.z);
+
+float phi=2.0*PI*randoms2.x;
+float theta=acos(2.0*randoms2.y-1.0);
+float randX=cos(phi)*sin(theta);
+float randY=cos(theta);
+float randZ=sin(phi)*sin(theta);
+newPosition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,abs(randY),randZ);
+newDirection=newPosition+directionRandomizer*randoms3;
+#elif defined(SPHEREEMITTER)
+vec3 randoms2=getRandomVec3(seed.y);
+vec3 randoms3=getRandomVec3(seed.z);
+
+float phi=2.0*PI*randoms2.x;
+float theta=acos(2.0*randoms2.y-1.0);
+float randX=cos(phi)*sin(theta);
+float randY=cos(theta);
+float randZ=sin(phi)*sin(theta);
+newPosition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,randY,randZ);
+#ifdef DIRECTEDSPHEREEMITTER
+newDirection=direction1+(direction2-direction1)*randoms3;
+#else
+
+newDirection=newPosition+directionRandomizer*randoms3;
+#endif
+#elif defined(CYLINDEREMITTER)
+vec3 randoms2=getRandomVec3(seed.y);
+vec3 randoms3=getRandomVec3(seed.z);
+
+float yPos=(randoms2.x-0.5)*height;
+float angle=randoms2.y*PI*2.;
+float inverseRadiusRangeSquared=((1.-radiusRange)*(1.-radiusRange));
+float positionRadius=radius*sqrt(inverseRadiusRangeSquared+(randoms2.z*(1.-inverseRadiusRangeSquared)));
+float xPos=positionRadius*cos(angle);
+float zPos=positionRadius*sin(angle);
+newPosition=vec3(xPos,yPos,zPos);
+#ifdef DIRECTEDCYLINDEREMITTER
+newDirection=direction1+(direction2-direction1)*randoms3;
+#else
+
+angle=angle+((randoms3.x-0.5)*PI);
+newDirection=vec3(cos(angle),randoms3.y-0.5,sin(angle));
+newDirection=normalize(newDirection);
+#endif
+#elif defined(CONEEMITTER)
+vec3 randoms2=getRandomVec3(seed.y);
+float s=2.0*PI*randoms2.x;
+#ifdef CONEEMITTERSPAWNPOINT
+float h=0.0001;
+#else
+float h=randoms2.y*height.y;
+
+h=1.-h*h;
+#endif
+float lRadius=radius.x-radius.x*randoms2.z*radius.y;
+lRadius=lRadius*h;
+float randX=lRadius*sin(s);
+float randZ=lRadius*cos(s);
+float randY=h*height.x;
+newPosition=vec3(randX,randY,randZ);
+
+if (abs(cos(coneAngle)) == 1.0) {
+newDirection=vec3(0.,1.0,0.);
+} else {
+vec3 randoms3=getRandomVec3(seed.z);
+newDirection=normalize(newPosition+directionRandomizer*randoms3);
+}
+#elif defined(CUSTOMEMITTER)
+newPosition=initialPosition;
+outInitialPosition=initialPosition;
+#else
+
+newPosition=vec3(0.,0.,0.);
+
+newDirection=2.0*(getRandomVec3(seed.w)-vec3(0.5,0.5,0.5));
+#endif
+float power=emitPower.x+(emitPower.y-emitPower.x)*randoms.a;
+#ifdef LOCAL
+outPosition=newPosition;
+#else
+outPosition=(emitterWM*vec4(newPosition,1.)).xyz;
+#endif
+#ifdef CUSTOMEMITTER
+outDirection=direction;
+#ifndef BILLBOARD
+outInitialDirection=direction;
+#endif
+#else
+#ifdef LOCAL
+vec3 initial=newDirection;
+#else
+vec3 initial=(emitterWM*vec4(newDirection,0.)).xyz;
+#endif
+outDirection=initial*power;
+#ifndef BILLBOARD
+outInitialDirection=initial;
+#endif
+#endif
+#ifdef ANIMATESHEET
+outCellIndex=cellInfos.x;
+#ifdef ANIMATESHEETRANDOMSTART
+outCellStartOffset=randoms.a*outLife;
+#endif
+#endif
+#ifdef NOISE
+outNoiseCoordinates1=noiseCoordinates1;
+outNoiseCoordinates2=noiseCoordinates2;
+#endif
+} else {
+float directionScale=timeDelta;
+outAge=newAge;
+float ageGradient=newAge/life;
+#ifdef VELOCITYGRADIENTS
+directionScale*=texture(velocityGradientSampler,vec2(ageGradient,0)).r;
+#endif
+#ifdef DRAGGRADIENTS
+directionScale*=1.0-texture(dragGradientSampler,vec2(ageGradient,0)).r;
+#endif
+#if defined(CUSTOMEMITTER)
+outPosition=position+(direction-position)*ageGradient;
+outInitialPosition=initialPosition;
+#else
+outPosition=position+direction*directionScale;
+#endif
+outLife=life;
+outSeed=seed;
+#ifndef COLORGRADIENTS
+outColor=color;
+#endif
+#ifdef SIZEGRADIENTS
+outSize.x=texture(sizeGradientSampler,vec2(ageGradient,0)).r;
+outSize.yz=size.yz;
+#else
+outSize=size;
+#endif
+#ifndef BILLBOARD
+outInitialDirection=initialDirection;
+#endif
+#ifdef CUSTOMEMITTER
+outDirection=direction;
+#else
+vec3 updatedDirection=direction+gravity*timeDelta;
+#ifdef LIMITVELOCITYGRADIENTS
+float limitVelocity=texture(limitVelocityGradientSampler,vec2(ageGradient,0)).r;
+float currentVelocity=length(updatedDirection);
+if (currentVelocity>limitVelocity) {
+updatedDirection=updatedDirection*limitVelocityDamping;
+}
+#endif
+outDirection=updatedDirection;
+#ifdef NOISE
+float fetchedR=texture(noiseSampler,vec2(noiseCoordinates1.x,noiseCoordinates1.y)*vec2(0.5)+vec2(0.5)).r;
+float fetchedG=texture(noiseSampler,vec2(noiseCoordinates1.z,noiseCoordinates2.x)*vec2(0.5)+vec2(0.5)).r;
+float fetchedB=texture(noiseSampler,vec2(noiseCoordinates2.y,noiseCoordinates2.z)*vec2(0.5)+vec2(0.5)).r;
+vec3 force=vec3(2.*fetchedR-1.,2.*fetchedG-1.,2.*fetchedB-1.)*noiseStrength;
+outDirection=outDirection+force*timeDelta;
+outNoiseCoordinates1=noiseCoordinates1;
+outNoiseCoordinates2=noiseCoordinates2;
+#endif
+#endif
+#ifdef ANGULARSPEEDGRADIENTS
+float angularSpeed=texture(angularSpeedGradientSampler,vec2(ageGradient,0)).r;
+outAngle=angle+angularSpeed*timeDelta;
+#else
+outAngle=vec2(angle.x+angle.y*timeDelta,angle.y);
+#endif
+#ifdef ANIMATESHEET
+float offsetAge=outAge;
+float dist=cellInfos.y-cellInfos.x;
+#ifdef ANIMATESHEETRANDOMSTART
+outCellStartOffset=cellStartOffset;
+offsetAge+=cellStartOffset;
+#else
+float cellStartOffset=0.;
+#endif
+float ratio=clamp(mod(cellStartOffset+cellInfos.z*offsetAge,life)/life,0.,1.0);
+outCellIndex=float(int(cellInfos.x+ratio*dist));
+#endif
+}
+}`;
+ ze.a.ShadersStore.gpuUpdateParticlesVertexShader = fm;
+ var pm = `#ifdef CLIPPLANE
+in float fClipDistance;
+#endif
+#ifdef CLIPPLANE2
+in float fClipDistance2;
+#endif
+#ifdef CLIPPLANE3
+in float fClipDistance3;
+#endif
+#ifdef CLIPPLANE4
+in float fClipDistance4;
+#endif
+#ifdef CLIPPLANE5
+in float fClipDistance5;
+#endif
+#ifdef CLIPPLANE6
+in float fClipDistance6;
+#endif`;
+ ze.a.IncludesShadersStore.clipPlaneFragmentDeclaration2 = pm;
+ var _m = `#version 300 es
+uniform sampler2D diffuseSampler;
+in vec2 vUV;
+in vec4 vColor;
+out vec4 outFragColor;
+#include
+#include
+#include
+#include
+void main() {
+#include
+vec4 textureColor=texture(diffuseSampler,vUV);
+outFragColor=textureColor*vColor;
+#ifdef BLENDMULTIPLYMODE
+float alpha=vColor.a*textureColor.a;
+outFragColor.rgb=outFragColor.rgb*alpha+vec3(1.0)*(1.0-alpha);
+#endif
+
+
+#ifdef IMAGEPROCESSINGPOSTPROCESS
+outFragColor.rgb=toLinearSpace(outFragColor.rgb);
+#else
+#ifdef IMAGEPROCESSING
+outFragColor.rgb=toLinearSpace(outFragColor.rgb);
+outFragColor=applyImageProcessing(outFragColor);
+#endif
+#endif
+}
+`;
+ ze.a.ShadersStore.gpuRenderParticlesPixelShader = _m;
+ var mm = `#ifdef CLIPPLANE
+uniform vec4 vClipPlane;
+out float fClipDistance;
+#endif
+#ifdef CLIPPLANE2
+uniform vec4 vClipPlane2;
+out float fClipDistance2;
+#endif
+#ifdef CLIPPLANE3
+uniform vec4 vClipPlane3;
+out float fClipDistance3;
+#endif
+#ifdef CLIPPLANE4
+uniform vec4 vClipPlane4;
+out float fClipDistance4;
+#endif
+#ifdef CLIPPLANE5
+uniform vec4 vClipPlane5;
+out float fClipDistance5;
+#endif
+#ifdef CLIPPLANE6
+uniform vec4 vClipPlane6;
+out float fClipDistance6;
+#endif`;
+ ze.a.IncludesShadersStore.clipPlaneVertexDeclaration2 = mm;
+ var gm = `#version 300 es
+uniform mat4 view;
+uniform mat4 projection;
+uniform vec2 translationPivot;
+uniform vec3 worldOffset;
+#ifdef LOCAL
+uniform mat4 emitterWM;
+#endif
+
+in vec3 position;
+in float age;
+in float life;
+in vec3 size;
+#ifndef BILLBOARD
+in vec3 initialDirection;
+#endif
+#ifdef BILLBOARDSTRETCHED
+in vec3 direction;
+#endif
+in float angle;
+#ifdef ANIMATESHEET
+in float cellIndex;
+#endif
+in vec2 offset;
+in vec2 uv;
+out vec2 vUV;
+out vec4 vColor;
+out vec3 vPositionW;
+#if defined(BILLBOARD) && !defined(BILLBOARDY) && !defined(BILLBOARDSTRETCHED)
+uniform mat4 invView;
+#endif
+#include
+#ifdef COLORGRADIENTS
+uniform sampler2D colorGradientSampler;
+#else
+uniform vec4 colorDead;
+in vec4 color;
+#endif
+#ifdef ANIMATESHEET
+uniform vec3 sheetInfos;
+#endif
+#ifdef BILLBOARD
+uniform vec3 eyePosition;
+#endif
+vec3 rotate(vec3 yaxis,vec3 rotatedCorner) {
+vec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));
+vec3 zaxis=normalize(cross(yaxis,xaxis));
+vec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);
+vec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);
+vec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);
+mat3 rotMatrix=mat3(row0,row1,row2);
+vec3 alignedCorner=rotMatrix*rotatedCorner;
+#ifdef LOCAL
+return ((emitterWM*vec4(position,1.0)).xyz+worldOffset)+alignedCorner;
+#else
+return (position+worldOffset)+alignedCorner;
+#endif
+}
+#ifdef BILLBOARDSTRETCHED
+vec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {
+vec3 normalizedToCamera=normalize(toCamera);
+vec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));
+vec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));
+vec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);
+vec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);
+vec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);
+mat3 rotMatrix=mat3(row0,row1,row2);
+vec3 alignedCorner=rotMatrix*rotatedCorner;
+#ifdef LOCAL
+return ((emitterWM*vec4(position,1.0)).xyz+worldOffset)+alignedCorner;
+#else
+return (position+worldOffset)+alignedCorner;
+#endif
+}
+#endif
+void main() {
+#ifdef ANIMATESHEET
+float rowOffset=floor(cellIndex/sheetInfos.z);
+float columnOffset=cellIndex-rowOffset*sheetInfos.z;
+vec2 uvScale=sheetInfos.xy;
+vec2 uvOffset=vec2(uv.x ,1.0-uv.y);
+vUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;
+#else
+vUV=uv;
+#endif
+float ratio=age/life;
+#ifdef COLORGRADIENTS
+vColor=texture(colorGradientSampler,vec2(ratio,0));
+#else
+vColor=color*vec4(1.0-ratio)+colorDead*vec4(ratio);
+#endif
+vec2 cornerPos=(offset-translationPivot)*size.yz*size.x+translationPivot;
+#ifdef BILLBOARD
+vec4 rotatedCorner;
+rotatedCorner.w=0.;
+#ifdef BILLBOARDY
+rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
+rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
+rotatedCorner.y=0.;
+vec3 yaxis=(position+worldOffset)-eyePosition;
+yaxis.y=0.;
+vPositionW=rotate(normalize(yaxis),rotatedCorner.xyz);
+vec4 viewPosition=(view*vec4(vPositionW,1.0));
+#elif defined(BILLBOARDSTRETCHED)
+rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
+rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
+rotatedCorner.z=0.;
+vec3 toCamera=(position+worldOffset)-eyePosition;
+vPositionW=rotateAlign(toCamera,rotatedCorner.xyz);
+vec4 viewPosition=(view*vec4(vPositionW,1.0));
+#else
+
+rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
+rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
+rotatedCorner.z=0.;
+
+#ifdef LOCAL
+vec4 viewPosition=view*vec4(((emitterWM*vec4(position,1.0)).xyz+worldOffset),1.0)+rotatedCorner;
+#else
+vec4 viewPosition=view*vec4((position+worldOffset),1.0)+rotatedCorner;
+#endif
+vPositionW=(invView*viewPosition).xyz;
+#endif
+#else
+
+vec3 rotatedCorner;
+rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
+rotatedCorner.y=0.;
+rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
+vec3 yaxis=normalize(initialDirection);
+vPositionW=rotate(yaxis,rotatedCorner);
+
+vec4 viewPosition=view*vec4(vPositionW,1.0);
+#endif
+gl_Position=projection*viewPosition;
+
+#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)
+vec4 worldPos=vec4(vPositionW,1.0);
+#endif
+#include
+}`;
+ ze.a.ShadersStore.gpuRenderParticlesVertexShader = gm;
+ var Zi = function(r) {
+ function t(e, n, i, o, a) {
+ o === void 0 && (o = !1), a === void 0 && (a = null);
+ var s = r.call(this, e) || this;
+ s.layerMask = 268435455, s._accumulatedCount = 0, s._targetIndex = 0, s._currentRenderId = -1, s._started = !1, s._stopped = !1, s._timeDelta = 0, s._actualFrame = 0, s._rawTextureWidth = 256, s.onDisposeObservable = new C.c(), s.onStoppedObservable = new C.c(), s.forceDepthWrite = !1, s._preWarmDone = !1, s.isLocal = !1, s._onBeforeDrawParticlesObservable = null, i && i.getClassName() !== "Scene" ? (s._engine = i, s.defaultProjectionMatrix = u.a.PerspectiveFovLH(0.8, 1, 0.1, 100)) : (s._scene = i || te.a.LastCreatedScene, s._engine = s._scene.getEngine(), s.uniqueId = s._scene.getUniqueId(), s._scene.particleSystems.push(s)), s._customEffect = { 0: a }, s._attachImageProcessingConfiguration(null), n.randomTextureSize || delete n.randomTextureSize;
+ var d = Object(c.a)({ capacity: 5e4, randomTextureSize: s._engine.getCaps().maxTextureSize }, n), p = n;
+ isFinite(p) && (d.capacity = p), s._capacity = d.capacity, s._activeCount = d.capacity, s._currentActiveCount = 0, s._isAnimationSheetEnabled = o, s._updateEffectOptions = { attributes: ["position", "initialPosition", "age", "life", "seed", "size", "color", "direction", "initialDirection", "angle", "cellIndex", "cellStartOffset", "noiseCoordinates1", "noiseCoordinates2"], uniformsNames: ["currentCount", "timeDelta", "emitterWM", "lifeTime", "color1", "color2", "sizeRange", "scaleRange", "gravity", "emitPower", "direction1", "direction2", "minEmitBox", "maxEmitBox", "radius", "directionRandomizer", "height", "coneAngle", "stopFactor", "angleRange", "radiusRange", "cellInfos", "noiseStrength", "limitVelocityDamping"], uniformBuffersNames: [], samplers: ["randomSampler", "randomSampler2", "sizeGradientSampler", "angularSpeedGradientSampler", "velocityGradientSampler", "limitVelocityGradientSampler", "noiseSampler", "dragGradientSampler"], defines: "", fallbacks: null, onCompiled: null, onError: null, indexParameters: null, maxSimultaneousLights: 0, transformFeedbackVaryings: [] }, s.particleEmitterType = new xr();
+ for (var y = Math.min(s._engine.getCaps().maxTextureSize, d.randomTextureSize), P = [], R = 0; R < y; ++R)
+ P.push(Math.random()), P.push(Math.random()), P.push(Math.random()), P.push(Math.random());
+ for (s._randomTexture = new Zn(new Float32Array(P), y, 1, h.a.TEXTUREFORMAT_RGBA, i, !1, !1, h.a.TEXTURE_NEAREST_SAMPLINGMODE, h.a.TEXTURETYPE_FLOAT), s._randomTexture.wrapU = h.a.TEXTURE_WRAP_ADDRESSMODE, s._randomTexture.wrapV = h.a.TEXTURE_WRAP_ADDRESSMODE, P = [], R = 0; R < y; ++R)
+ P.push(Math.random()), P.push(Math.random()), P.push(Math.random()), P.push(Math.random());
+ return s._randomTexture2 = new Zn(new Float32Array(P), y, 1, h.a.TEXTUREFORMAT_RGBA, i, !1, !1, h.a.TEXTURE_NEAREST_SAMPLINGMODE, h.a.TEXTURETYPE_FLOAT), s._randomTexture2.wrapU = h.a.TEXTURE_WRAP_ADDRESSMODE, s._randomTexture2.wrapV = h.a.TEXTURE_WRAP_ADDRESSMODE, s._randomTextureSize = y, s;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t, "IsSupported", { get: function() {
+ return !!te.a.LastCreatedEngine && te.a.LastCreatedEngine.webGLVersion > 1;
+ }, enumerable: !1, configurable: !0 }), t.prototype.getCapacity = function() {
+ return this._capacity;
+ }, Object.defineProperty(t.prototype, "activeParticleCount", { get: function() {
+ return this._activeCount;
+ }, set: function(e) {
+ this._activeCount = Math.min(e, this._capacity);
+ }, enumerable: !1, configurable: !0 }), t.prototype.isReady = function() {
+ return this._updateEffect ? !!(this.emitter && this._updateEffect.isReady() && (!this._imageProcessingConfiguration || this._imageProcessingConfiguration.isReady()) && this._getEffect().isReady() && this.particleTexture && this.particleTexture.isReady()) : (this._recreateUpdateEffect(), this._recreateRenderEffect(), !1);
+ }, t.prototype.isStarted = function() {
+ return this._started;
+ }, t.prototype.isStopped = function() {
+ return this._stopped;
+ }, t.prototype.isStopping = function() {
+ return !1;
+ }, t.prototype.getActiveCount = function() {
+ return this._currentActiveCount;
+ }, t.prototype.start = function(e) {
+ var n = this;
+ if (e === void 0 && (e = this.startDelay), !this.targetStopDuration && this._hasTargetStopDurationDependantGradient())
+ throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
+ e ? setTimeout(function() {
+ n.start(0);
+ }, e) : (this._started = !0, this._stopped = !1, this._preWarmDone = !1, this.beginAnimationOnStart && this.animations && this.animations.length > 0 && this._scene && this._scene.beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop));
+ }, t.prototype.stop = function() {
+ this._stopped || (this._stopped = !0);
+ }, t.prototype.reset = function() {
+ this._releaseBuffers(), this._releaseVAOs(), this._currentActiveCount = 0, this._targetIndex = 0;
+ }, t.prototype.getClassName = function() {
+ return "GPUParticleSystem";
+ }, t.prototype.getCustomEffect = function(e) {
+ var n;
+ return e === void 0 && (e = 0), (n = this._customEffect[e]) !== null && n !== void 0 ? n : this._customEffect[0];
+ }, t.prototype.setCustomEffect = function(e, n) {
+ n === void 0 && (n = 0), this._customEffect[n] = e;
+ }, Object.defineProperty(t.prototype, "onBeforeDrawParticlesObservable", { get: function() {
+ return this._onBeforeDrawParticlesObservable || (this._onBeforeDrawParticlesObservable = new C.c()), this._onBeforeDrawParticlesObservable;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "vertexShaderName", { get: function() {
+ return "gpuRenderParticles";
+ }, enumerable: !1, configurable: !0 }), t.prototype._removeGradientAndTexture = function(e, n, i) {
+ return r.prototype._removeGradientAndTexture.call(this, e, n, i), this._releaseBuffers(), this;
+ }, t.prototype.addColorGradient = function(e, n, i) {
+ this._colorGradients || (this._colorGradients = []);
+ var o = new gc(e, n);
+ return this._colorGradients.push(o), this._refreshColorGradient(!0), this._releaseBuffers(), this;
+ }, t.prototype._refreshColorGradient = function(e) {
+ e === void 0 && (e = !1), this._colorGradients && (e && this._colorGradients.sort(function(n, i) {
+ return n.gradient < i.gradient ? -1 : n.gradient > i.gradient ? 1 : 0;
+ }), this._colorGradientsTexture && (this._colorGradientsTexture.dispose(), this._colorGradientsTexture = null));
+ }, t.prototype.forceRefreshGradients = function() {
+ this._refreshColorGradient(), this._refreshFactorGradient(this._sizeGradients, "_sizeGradientsTexture"), this._refreshFactorGradient(this._angularSpeedGradients, "_angularSpeedGradientsTexture"), this._refreshFactorGradient(this._velocityGradients, "_velocityGradientsTexture"), this._refreshFactorGradient(this._limitVelocityGradients, "_limitVelocityGradientsTexture"), this._refreshFactorGradient(this._dragGradients, "_dragGradientsTexture"), this.reset();
+ }, t.prototype.removeColorGradient = function(e) {
+ return this._removeGradientAndTexture(e, this._colorGradients, this._colorGradientsTexture), this._colorGradientsTexture = null, this;
+ }, t.prototype._addFactorGradient = function(e, n, i) {
+ var o = new vc(n, i);
+ e.push(o), this._releaseBuffers();
+ }, t.prototype.addSizeGradient = function(e, n) {
+ return this._sizeGradients || (this._sizeGradients = []), this._addFactorGradient(this._sizeGradients, e, n), this._refreshFactorGradient(this._sizeGradients, "_sizeGradientsTexture", !0), this._releaseBuffers(), this;
+ }, t.prototype.removeSizeGradient = function(e) {
+ return this._removeGradientAndTexture(e, this._sizeGradients, this._sizeGradientsTexture), this._sizeGradientsTexture = null, this;
+ }, t.prototype._refreshFactorGradient = function(e, n, i) {
+ i === void 0 && (i = !1), e && (i && e.sort(function(o, a) {
+ return o.gradient < a.gradient ? -1 : o.gradient > a.gradient ? 1 : 0;
+ }), this[n] && (this[n].dispose(), this[n] = null));
+ }, t.prototype.addAngularSpeedGradient = function(e, n) {
+ return this._angularSpeedGradients || (this._angularSpeedGradients = []), this._addFactorGradient(this._angularSpeedGradients, e, n), this._refreshFactorGradient(this._angularSpeedGradients, "_angularSpeedGradientsTexture", !0), this._releaseBuffers(), this;
+ }, t.prototype.removeAngularSpeedGradient = function(e) {
+ return this._removeGradientAndTexture(e, this._angularSpeedGradients, this._angularSpeedGradientsTexture), this._angularSpeedGradientsTexture = null, this;
+ }, t.prototype.addVelocityGradient = function(e, n) {
+ return this._velocityGradients || (this._velocityGradients = []), this._addFactorGradient(this._velocityGradients, e, n), this._refreshFactorGradient(this._velocityGradients, "_velocityGradientsTexture", !0), this._releaseBuffers(), this;
+ }, t.prototype.removeVelocityGradient = function(e) {
+ return this._removeGradientAndTexture(e, this._velocityGradients, this._velocityGradientsTexture), this._velocityGradientsTexture = null, this;
+ }, t.prototype.addLimitVelocityGradient = function(e, n) {
+ return this._limitVelocityGradients || (this._limitVelocityGradients = []), this._addFactorGradient(this._limitVelocityGradients, e, n), this._refreshFactorGradient(this._limitVelocityGradients, "_limitVelocityGradientsTexture", !0), this._releaseBuffers(), this;
+ }, t.prototype.removeLimitVelocityGradient = function(e) {
+ return this._removeGradientAndTexture(e, this._limitVelocityGradients, this._limitVelocityGradientsTexture), this._limitVelocityGradientsTexture = null, this;
+ }, t.prototype.addDragGradient = function(e, n) {
+ return this._dragGradients || (this._dragGradients = []), this._addFactorGradient(this._dragGradients, e, n), this._refreshFactorGradient(this._dragGradients, "_dragGradientsTexture", !0), this._releaseBuffers(), this;
+ }, t.prototype.removeDragGradient = function(e) {
+ return this._removeGradientAndTexture(e, this._dragGradients, this._dragGradientsTexture), this._dragGradientsTexture = null, this;
+ }, t.prototype.addEmitRateGradient = function(e, n, i) {
+ return this;
+ }, t.prototype.removeEmitRateGradient = function(e) {
+ return this;
+ }, t.prototype.addStartSizeGradient = function(e, n, i) {
+ return this;
+ }, t.prototype.removeStartSizeGradient = function(e) {
+ return this;
+ }, t.prototype.addColorRemapGradient = function(e, n, i) {
+ return this;
+ }, t.prototype.removeColorRemapGradient = function() {
+ return this;
+ }, t.prototype.addAlphaRemapGradient = function(e, n, i) {
+ return this;
+ }, t.prototype.removeAlphaRemapGradient = function() {
+ return this;
+ }, t.prototype.addRampGradient = function(e, n) {
+ return this;
+ }, t.prototype.removeRampGradient = function() {
+ return this;
+ }, t.prototype.getRampGradients = function() {
+ return null;
+ }, Object.defineProperty(t.prototype, "useRampGradients", { get: function() {
+ return !1;
+ }, set: function(e) {
+ }, enumerable: !1, configurable: !0 }), t.prototype.addLifeTimeGradient = function(e, n, i) {
+ return this;
+ }, t.prototype.removeLifeTimeGradient = function(e) {
+ return this;
+ }, t.prototype._reset = function() {
+ this._releaseBuffers();
+ }, t.prototype._createUpdateVAO = function(e) {
+ var n = {};
+ n.position = e.createVertexBuffer("position", 0, 3);
+ var i = 3;
+ this.particleEmitterType instanceof Cr && (n.initialPosition = e.createVertexBuffer("initialPosition", i, 3), i += 3), n.age = e.createVertexBuffer("age", i, 1), i += 1, n.life = e.createVertexBuffer("life", i, 1), i += 1, n.seed = e.createVertexBuffer("seed", i, 4), i += 4, n.size = e.createVertexBuffer("size", i, 3), i += 3, this._colorGradientsTexture || (n.color = e.createVertexBuffer("color", i, 4), i += 4), n.direction = e.createVertexBuffer("direction", i, 3), i += 3, this._isBillboardBased || (n.initialDirection = e.createVertexBuffer("initialDirection", i, 3), i += 3), this._angularSpeedGradientsTexture ? (n.angle = e.createVertexBuffer("angle", i, 1), i += 1) : (n.angle = e.createVertexBuffer("angle", i, 2), i += 2), this._isAnimationSheetEnabled && (n.cellIndex = e.createVertexBuffer("cellIndex", i, 1), i += 1, this.spriteRandomStartCell && (n.cellStartOffset = e.createVertexBuffer("cellStartOffset", i, 1), i += 1)), this.noiseTexture && (n.noiseCoordinates1 = e.createVertexBuffer("noiseCoordinates1", i, 3), i += 3, n.noiseCoordinates2 = e.createVertexBuffer("noiseCoordinates2", i, 3), i += 3);
+ var o = this._engine.recordVertexArrayObject(n, null, this._updateEffect);
+ return this._engine.bindArrayBuffer(null), o;
+ }, t.prototype._createRenderVAO = function(e, n) {
+ var i = {};
+ i.position = e.createVertexBuffer("position", 0, 3, this._attributesStrideSize, !0);
+ var o = 3;
+ this.particleEmitterType instanceof Cr && (o += 3), i.age = e.createVertexBuffer("age", o, 1, this._attributesStrideSize, !0), o += 1, i.life = e.createVertexBuffer("life", o, 1, this._attributesStrideSize, !0), o += 5, i.size = e.createVertexBuffer("size", o, 3, this._attributesStrideSize, !0), o += 3, this._colorGradientsTexture || (i.color = e.createVertexBuffer("color", o, 4, this._attributesStrideSize, !0), o += 4), this.billboardMode === cn.BILLBOARDMODE_STRETCHED && (i.direction = e.createVertexBuffer("direction", o, 3, this._attributesStrideSize, !0)), o += 3, this._isBillboardBased || (i.initialDirection = e.createVertexBuffer("initialDirection", o, 3, this._attributesStrideSize, !0), o += 3), i.angle = e.createVertexBuffer("angle", o, 1, this._attributesStrideSize, !0), this._angularSpeedGradientsTexture ? o++ : o += 2, this._isAnimationSheetEnabled && (i.cellIndex = e.createVertexBuffer("cellIndex", o, 1, this._attributesStrideSize, !0), o += 1, this.spriteRandomStartCell && (i.cellStartOffset = e.createVertexBuffer("cellStartOffset", o, 1, this._attributesStrideSize, !0), o += 1)), this.noiseTexture && (i.noiseCoordinates1 = e.createVertexBuffer("noiseCoordinates1", o, 3, this._attributesStrideSize, !0), o += 3, i.noiseCoordinates2 = e.createVertexBuffer("noiseCoordinates2", o, 3, this._attributesStrideSize, !0), o += 3), i.offset = n.createVertexBuffer("offset", 0, 2), i.uv = n.createVertexBuffer("uv", 2, 2);
+ var a = this._engine.recordVertexArrayObject(i, null, this._getEffect());
+ return this._engine.bindArrayBuffer(null), a;
+ }, t.prototype._initialize = function(e) {
+ if (e === void 0 && (e = !1), !this._buffer0 || e) {
+ var n = this._engine, i = new Array();
+ this._attributesStrideSize = 21, this._targetIndex = 0, this.particleEmitterType instanceof Cr && (this._attributesStrideSize += 3), this.isBillboardBased || (this._attributesStrideSize += 3), this._colorGradientsTexture && (this._attributesStrideSize -= 4), this._angularSpeedGradientsTexture && (this._attributesStrideSize -= 1), this._isAnimationSheetEnabled && (this._attributesStrideSize += 1, this.spriteRandomStartCell && (this._attributesStrideSize += 1)), this.noiseTexture && (this._attributesStrideSize += 6);
+ for (var o = this.particleEmitterType instanceof Cr, a = u.c.Vector3[0], s = 0; s < this._capacity; s++)
+ i.push(0), i.push(0), i.push(0), o && (this.particleEmitterType.particlePositionGenerator(s, null, a), i.push(a.x), i.push(a.y), i.push(a.z)), i.push(0), i.push(0), i.push(Math.random()), i.push(Math.random()), i.push(Math.random()), i.push(Math.random()), i.push(0), i.push(0), i.push(0), this._colorGradientsTexture || (i.push(0), i.push(0), i.push(0), i.push(0)), o ? (this.particleEmitterType.particleDestinationGenerator(s, null, a), i.push(a.x), i.push(a.y), i.push(a.z)) : (i.push(0), i.push(0), i.push(0)), this.isBillboardBased || (i.push(0), i.push(0), i.push(0)), i.push(0), this._angularSpeedGradientsTexture || i.push(0), this._isAnimationSheetEnabled && (i.push(0), this.spriteRandomStartCell && i.push(0)), this.noiseTexture && (i.push(Math.random()), i.push(Math.random()), i.push(Math.random()), i.push(Math.random()), i.push(Math.random()), i.push(Math.random()));
+ var d = new Float32Array([0.5, 0.5, 1, 1, -0.5, 0.5, 0, 1, -0.5, -0.5, 0, 0, 0.5, -0.5, 1, 0]);
+ this._buffer0 = new Oe.a(n, i, !1, this._attributesStrideSize), this._buffer1 = new Oe.a(n, i, !1, this._attributesStrideSize), this._spriteBuffer = new Oe.a(n, d, !1, 4), this._updateVAO = [], this._updateVAO.push(this._createUpdateVAO(this._buffer0)), this._updateVAO.push(this._createUpdateVAO(this._buffer1)), this._renderVAO = [], this._renderVAO.push(this._createRenderVAO(this._buffer1, this._spriteBuffer)), this._renderVAO.push(this._createRenderVAO(this._buffer0, this._spriteBuffer)), this._sourceBuffer = this._buffer0, this._targetBuffer = this._buffer1;
+ }
+ }, t.prototype._recreateUpdateEffect = function() {
+ var e = this.particleEmitterType ? this.particleEmitterType.getEffectDefines() : "";
+ this._isBillboardBased && (e += `
+#define BILLBOARD`), this._colorGradientsTexture && (e += `
+#define COLORGRADIENTS`), this._sizeGradientsTexture && (e += `
+#define SIZEGRADIENTS`), this._angularSpeedGradientsTexture && (e += `
+#define ANGULARSPEEDGRADIENTS`), this._velocityGradientsTexture && (e += `
+#define VELOCITYGRADIENTS`), this._limitVelocityGradientsTexture && (e += `
+#define LIMITVELOCITYGRADIENTS`), this._dragGradientsTexture && (e += `
+#define DRAGGRADIENTS`), this.isAnimationSheetEnabled && (e += `
+#define ANIMATESHEET`, this.spriteRandomStartCell && (e += `
+#define ANIMATESHEETRANDOMSTART`)), this.noiseTexture && (e += `
+#define NOISE`), this.isLocal && (e += `
+#define LOCAL`), this._updateEffect && this._updateEffectOptions.defines === e || (this._updateEffectOptions.transformFeedbackVaryings = ["outPosition"], this.particleEmitterType instanceof Cr && this._updateEffectOptions.transformFeedbackVaryings.push("outInitialPosition"), this._updateEffectOptions.transformFeedbackVaryings.push("outAge"), this._updateEffectOptions.transformFeedbackVaryings.push("outLife"), this._updateEffectOptions.transformFeedbackVaryings.push("outSeed"), this._updateEffectOptions.transformFeedbackVaryings.push("outSize"), this._colorGradientsTexture || this._updateEffectOptions.transformFeedbackVaryings.push("outColor"), this._updateEffectOptions.transformFeedbackVaryings.push("outDirection"), this._isBillboardBased || this._updateEffectOptions.transformFeedbackVaryings.push("outInitialDirection"), this._updateEffectOptions.transformFeedbackVaryings.push("outAngle"), this.isAnimationSheetEnabled && (this._updateEffectOptions.transformFeedbackVaryings.push("outCellIndex"), this.spriteRandomStartCell && this._updateEffectOptions.transformFeedbackVaryings.push("outCellStartOffset")), this.noiseTexture && (this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates1"), this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates2")), this._updateEffectOptions.defines = e, this._updateEffect = new ze.a("gpuUpdateParticles", this._updateEffectOptions, this._engine));
+ }, t.prototype._getEffect = function() {
+ var e;
+ return (e = this.getCustomEffect()) !== null && e !== void 0 ? e : this._renderEffect;
+ }, t.prototype.fillDefines = function(e, n) {
+ if (this._scene && (this._scene.clipPlane && e.push("#define CLIPPLANE"), this._scene.clipPlane2 && e.push("#define CLIPPLANE2"), this._scene.clipPlane3 && e.push("#define CLIPPLANE3"), this._scene.clipPlane4 && e.push("#define CLIPPLANE4"), this._scene.clipPlane5 && e.push("#define CLIPPLANE5"), this._scene.clipPlane6 && e.push("#define CLIPPLANE6")), this.blendMode === cn.BLENDMODE_MULTIPLY && e.push("#define BLENDMULTIPLYMODE"), this.isLocal && e.push("#define LOCAL"), this._isBillboardBased)
+ switch (e.push("#define BILLBOARD"), this.billboardMode) {
+ case cn.BILLBOARDMODE_Y:
+ e.push("#define BILLBOARDY");
+ break;
+ case cn.BILLBOARDMODE_STRETCHED:
+ e.push("#define BILLBOARDSTRETCHED");
+ break;
+ case cn.BILLBOARDMODE_ALL:
+ e.push("#define BILLBOARDMODE_ALL");
+ }
+ this._colorGradientsTexture && e.push("#define COLORGRADIENTS"), this.isAnimationSheetEnabled && e.push("#define ANIMATESHEET"), this._imageProcessingConfiguration && (this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines), e.push("" + this._imageProcessingConfigurationDefines.toString()));
+ }, t.prototype.fillUniformsAttributesAndSamplerNames = function(e, n, i) {
+ n.push("position", "age", "life", "size", "color", "offset", "uv", "direction", "initialDirection", "angle", "cellIndex"), e.push("emitterWM", "worldOffset", "view", "projection", "colorDead", "invView", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "sheetInfos", "translationPivot", "eyePosition"), i.push("diffuseSampler", "colorGradientSampler"), this._imageProcessingConfiguration && (vn.a.PrepareUniforms(e, this._imageProcessingConfigurationDefines), vn.a.PrepareSamplers(i, this._imageProcessingConfigurationDefines));
+ }, t.prototype._recreateRenderEffect = function() {
+ var e = this.getCustomEffect();
+ if (e)
+ return e;
+ var n = [];
+ this.fillDefines(n);
+ var i = n.join(`
+`);
+ if (this._renderEffect && this._renderEffect.defines === i)
+ return this._renderEffect;
+ var o = [], a = [], s = [];
+ return this.fillUniformsAttributesAndSamplerNames(a, o, s), this._renderEffect = new ze.a("gpuRenderParticles", o, a, s, this._engine, i), this._renderEffect;
+ }, t.prototype.animate = function(e) {
+ var n;
+ e === void 0 && (e = !1), this._timeDelta = this.updateSpeed * (e ? this.preWarmStepOffset : ((n = this._scene) === null || n === void 0 ? void 0 : n.getAnimationRatio()) || 1), this._actualFrame += this._timeDelta, this._stopped || this.targetStopDuration && this._actualFrame >= this.targetStopDuration && this.stop();
+ }, t.prototype._createFactorGradientTexture = function(e, n) {
+ var i = this[n];
+ if (e && e.length && !i) {
+ for (var o = new Float32Array(this._rawTextureWidth), a = 0; a < this._rawTextureWidth; a++) {
+ var s = a / this._rawTextureWidth;
+ On.GetCurrentGradient(s, e, function(d, p, y) {
+ o[a] = $.a.Lerp(d.factor1, p.factor1, y);
+ });
+ }
+ this[n] = Zn.CreateRTexture(o, this._rawTextureWidth, 1, this._scene || this._engine, !1, !1, h.a.TEXTURE_NEAREST_SAMPLINGMODE);
+ }
+ }, t.prototype._createSizeGradientTexture = function() {
+ this._createFactorGradientTexture(this._sizeGradients, "_sizeGradientsTexture");
+ }, t.prototype._createAngularSpeedGradientTexture = function() {
+ this._createFactorGradientTexture(this._angularSpeedGradients, "_angularSpeedGradientsTexture");
+ }, t.prototype._createVelocityGradientTexture = function() {
+ this._createFactorGradientTexture(this._velocityGradients, "_velocityGradientsTexture");
+ }, t.prototype._createLimitVelocityGradientTexture = function() {
+ this._createFactorGradientTexture(this._limitVelocityGradients, "_limitVelocityGradientsTexture");
+ }, t.prototype._createDragGradientTexture = function() {
+ this._createFactorGradientTexture(this._dragGradients, "_dragGradientsTexture");
+ }, t.prototype._createColorGradientTexture = function() {
+ if (this._colorGradients && this._colorGradients.length && !this._colorGradientsTexture) {
+ for (var e = new Uint8Array(4 * this._rawTextureWidth), n = I.c.Color4[0], i = 0; i < this._rawTextureWidth; i++) {
+ var o = i / this._rawTextureWidth;
+ On.GetCurrentGradient(o, this._colorGradients, function(a, s, d) {
+ I.b.LerpToRef(a.color1, s.color1, d, n), e[4 * i] = 255 * n.r, e[4 * i + 1] = 255 * n.g, e[4 * i + 2] = 255 * n.b, e[4 * i + 3] = 255 * n.a;
+ });
+ }
+ this._colorGradientsTexture = Zn.CreateRGBATexture(e, this._rawTextureWidth, 1, this._scene, !1, !1, h.a.TEXTURE_NEAREST_SAMPLINGMODE);
+ }
+ }, t.prototype.render = function(e) {
+ var n, i;
+ if (e === void 0 && (e = !1), !this._started || (this._createColorGradientTexture(), this._createSizeGradientTexture(), this._createAngularSpeedGradientTexture(), this._createVelocityGradientTexture(), this._createLimitVelocityGradientTexture(), this._createDragGradientTexture(), this._recreateUpdateEffect(), this._recreateRenderEffect(), !this.isReady()))
+ return 0;
+ if (!e && this._scene) {
+ if (!this._preWarmDone && this.preWarmCycles) {
+ for (var o = 0; o < this.preWarmCycles; o++)
+ this.animate(!0), this.render(!0);
+ this._preWarmDone = !0;
+ }
+ if (this._currentRenderId === this._scene.getFrameId())
+ return 0;
+ this._currentRenderId = this._scene.getFrameId();
+ }
+ if (this._initialize(), this._accumulatedCount += this.emitRate * this._timeDelta, this._accumulatedCount > 1) {
+ var a = 0 | this._accumulatedCount;
+ this._accumulatedCount -= a, this._currentActiveCount = Math.min(this._activeCount, this._currentActiveCount + a);
+ }
+ if (!this._currentActiveCount)
+ return 0;
+ this._engine.enableEffect(this._updateEffect);
+ var s, d = this._engine;
+ if (!d.setState)
+ throw new Error("GPU particles cannot work with a full Engine. ThinEngine is not supported");
+ if (this._updateEffect.setFloat("currentCount", this._currentActiveCount), this._updateEffect.setFloat("timeDelta", this._timeDelta), this._updateEffect.setFloat("stopFactor", this._stopped ? 0 : 1), this._updateEffect.setTexture("randomSampler", this._randomTexture), this._updateEffect.setTexture("randomSampler2", this._randomTexture2), this._updateEffect.setFloat2("lifeTime", this.minLifeTime, this.maxLifeTime), this._updateEffect.setFloat2("emitPower", this.minEmitPower, this.maxEmitPower), this._colorGradientsTexture || (this._updateEffect.setDirectColor4("color1", this.color1), this._updateEffect.setDirectColor4("color2", this.color2)), this._updateEffect.setFloat2("sizeRange", this.minSize, this.maxSize), this._updateEffect.setFloat4("scaleRange", this.minScaleX, this.maxScaleX, this.minScaleY, this.maxScaleY), this._updateEffect.setFloat4("angleRange", this.minAngularSpeed, this.maxAngularSpeed, this.minInitialRotation, this.maxInitialRotation), this._updateEffect.setVector3("gravity", this.gravity), this._sizeGradientsTexture && this._updateEffect.setTexture("sizeGradientSampler", this._sizeGradientsTexture), this._angularSpeedGradientsTexture && this._updateEffect.setTexture("angularSpeedGradientSampler", this._angularSpeedGradientsTexture), this._velocityGradientsTexture && this._updateEffect.setTexture("velocityGradientSampler", this._velocityGradientsTexture), this._limitVelocityGradientsTexture && (this._updateEffect.setTexture("limitVelocityGradientSampler", this._limitVelocityGradientsTexture), this._updateEffect.setFloat("limitVelocityDamping", this.limitVelocityDamping)), this._dragGradientsTexture && this._updateEffect.setTexture("dragGradientSampler", this._dragGradientsTexture), this.particleEmitterType && this.particleEmitterType.applyToShader(this._updateEffect), this._isAnimationSheetEnabled && this._updateEffect.setFloat3("cellInfos", this.startSpriteCellID, this.endSpriteCellID, this.spriteCellChangeSpeed), this.noiseTexture && (this._updateEffect.setTexture("noiseSampler", this.noiseTexture), this._updateEffect.setVector3("noiseStrength", this.noiseStrength)), this.emitter.position)
+ s = this.emitter.getWorldMatrix();
+ else {
+ var p = this.emitter;
+ s = u.a.Translation(p.x, p.y, p.z);
+ }
+ if (this.isLocal || this._updateEffect.setMatrix("emitterWM", s), this._engine.bindVertexArrayObject(this._updateVAO[this._targetIndex], null), d.bindTransformFeedbackBuffer(this._targetBuffer.getBuffer()), d.setRasterizerState(!1), d.beginTransformFeedback(!0), d.drawArraysType(h.a.MATERIAL_PointListDrawMode, 0, this._currentActiveCount), d.endTransformFeedback(), d.setRasterizerState(!0), d.bindTransformFeedbackBuffer(null), !e) {
+ var y = this._getEffect();
+ this._engine.enableEffect(y);
+ var P = ((n = this._scene) === null || n === void 0 ? void 0 : n.getViewMatrix()) || u.a.IdentityReadOnly;
+ if (y.setMatrix("view", P), y.setMatrix("projection", (i = this.defaultProjectionMatrix) !== null && i !== void 0 ? i : this._scene.getProjectionMatrix()), y.setTexture("diffuseSampler", this.particleTexture), y.setVector2("translationPivot", this.translationPivot), y.setVector3("worldOffset", this.worldOffset), this.isLocal && y.setMatrix("emitterWM", s), this._colorGradientsTexture ? y.setTexture("colorGradientSampler", this._colorGradientsTexture) : y.setDirectColor4("colorDead", this.colorDead), this._isAnimationSheetEnabled && this.particleTexture) {
+ var R = this.particleTexture.getBaseSize();
+ y.setFloat3("sheetInfos", this.spriteCellWidth / R.width, this.spriteCellHeight / R.height, R.width / this.spriteCellWidth);
+ }
+ if (this._isBillboardBased && this._scene) {
+ var B = this._scene.activeCamera;
+ y.setVector3("eyePosition", B.globalPosition);
+ }
+ var F = y.defines;
+ if (this._scene && (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4 || this._scene.clipPlane5 || this._scene.clipPlane6) && $e.a.BindClipPlane(y, this._scene), F.indexOf("#define BILLBOARDMODE_ALL") >= 0) {
+ var z = P.clone();
+ z.invert(), y.setMatrix("invView", z);
+ }
+ switch (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess && this._imageProcessingConfiguration.bind(y), this.blendMode) {
+ case cn.BLENDMODE_ADD:
+ this._engine.setAlphaMode(h.a.ALPHA_ADD);
+ break;
+ case cn.BLENDMODE_ONEONE:
+ this._engine.setAlphaMode(h.a.ALPHA_ONEONE);
+ break;
+ case cn.BLENDMODE_STANDARD:
+ this._engine.setAlphaMode(h.a.ALPHA_COMBINE);
+ break;
+ case cn.BLENDMODE_MULTIPLY:
+ this._engine.setAlphaMode(h.a.ALPHA_MULTIPLY);
+ }
+ this.forceDepthWrite && d.setDepthWrite(!0), this._engine.bindVertexArrayObject(this._renderVAO[this._targetIndex], null), this._onBeforeDrawParticlesObservable && this._onBeforeDrawParticlesObservable.notifyObservers(y), this._engine.drawArraysType(h.a.MATERIAL_TriangleFanDrawMode, 0, 4, this._currentActiveCount), this._engine.setAlphaMode(h.a.ALPHA_DISABLE);
+ }
+ this._targetIndex++, this._targetIndex === 2 && (this._targetIndex = 0);
+ var J = this._sourceBuffer;
+ return this._sourceBuffer = this._targetBuffer, this._targetBuffer = J, this._currentActiveCount;
+ }, t.prototype.rebuild = function() {
+ this._initialize(!0);
+ }, t.prototype._releaseBuffers = function() {
+ this._buffer0 && (this._buffer0.dispose(), this._buffer0 = null), this._buffer1 && (this._buffer1.dispose(), this._buffer1 = null), this._spriteBuffer && (this._spriteBuffer.dispose(), this._spriteBuffer = null);
+ }, t.prototype._releaseVAOs = function() {
+ if (this._updateVAO) {
+ for (var e = 0; e < this._updateVAO.length; e++)
+ this._engine.releaseVertexArrayObject(this._updateVAO[e]);
+ for (this._updateVAO = [], e = 0; e < this._renderVAO.length; e++)
+ this._engine.releaseVertexArrayObject(this._renderVAO[e]);
+ this._renderVAO = [];
+ }
+ }, t.prototype.dispose = function(e) {
+ if (e === void 0 && (e = !0), this._scene) {
+ var n = this._scene.particleSystems.indexOf(this);
+ n > -1 && this._scene.particleSystems.splice(n, 1);
+ }
+ this._releaseBuffers(), this._releaseVAOs(), this._colorGradientsTexture && (this._colorGradientsTexture.dispose(), this._colorGradientsTexture = null), this._sizeGradientsTexture && (this._sizeGradientsTexture.dispose(), this._sizeGradientsTexture = null), this._angularSpeedGradientsTexture && (this._angularSpeedGradientsTexture.dispose(), this._angularSpeedGradientsTexture = null), this._velocityGradientsTexture && (this._velocityGradientsTexture.dispose(), this._velocityGradientsTexture = null), this._limitVelocityGradientsTexture && (this._limitVelocityGradientsTexture.dispose(), this._limitVelocityGradientsTexture = null), this._dragGradientsTexture && (this._dragGradientsTexture.dispose(), this._dragGradientsTexture = null), this._randomTexture && (this._randomTexture.dispose(), this._randomTexture = null), this._randomTexture2 && (this._randomTexture2.dispose(), this._randomTexture2 = null), e && this.particleTexture && (this.particleTexture.dispose(), this.particleTexture = null), e && this.noiseTexture && (this.noiseTexture.dispose(), this.noiseTexture = null), this.onStoppedObservable.clear(), this.onDisposeObservable.notifyObservers(this), this.onDisposeObservable.clear();
+ }, t.prototype.clone = function(e, n) {
+ var i = this.serialize(), o = t.Parse(i, this._scene || this._engine, ""), a = Object(c.a)({}, this._customEffect);
+ return o.name = e, o._customEffect = a, n === void 0 && (n = this.emitter), o.emitter = n, o.noiseTexture = this.noiseTexture, o;
+ }, t.prototype.serialize = function(e) {
+ e === void 0 && (e = !1);
+ var n = {};
+ return cn._Serialize(n, this, e), n.activeParticleCount = this.activeParticleCount, n.randomTextureSize = this._randomTextureSize, n;
+ }, t.Parse = function(e, n, i, o) {
+ o === void 0 && (o = !1);
+ var a = new t(e.name, { capacity: e.capacity, randomTextureSize: e.randomTextureSize }, n);
+ return e.activeParticleCount && (a.activeParticleCount = e.activeParticleCount), cn._Parse(e, a, n, i), e.preventAutoStart && (a.preventAutoStart = e.preventAutoStart), o || a.preventAutoStart || a.start(), a;
+ }, t;
+ }(co), da = function() {
+ function r() {
+ this.systems = new Array();
+ }
+ return Object.defineProperty(r.prototype, "emitterNode", { get: function() {
+ return this._emitterNode;
+ }, enumerable: !1, configurable: !0 }), r.prototype.setEmitterAsSphere = function(t, e, n) {
+ this._emitterNode && this._emitterNode.dispose(), this._emitterCreationOptions = { kind: "Sphere", options: t, renderingGroupId: e };
+ var i = Nn.a.CreateSphere("emitterSphere", { diameter: t.diameter, segments: t.segments }, n);
+ i.renderingGroupId = e;
+ var o = new Nt.a("emitterSphereMaterial", n);
+ o.emissiveColor = t.color, i.material = o;
+ for (var a = 0, s = this.systems; a < s.length; a++)
+ s[a].emitter = i;
+ this._emitterNode = i;
+ }, r.prototype.start = function(t) {
+ for (var e = 0, n = this.systems; e < n.length; e++) {
+ var i = n[e];
+ t && (i.emitter = t), i.start();
+ }
+ }, r.prototype.dispose = function() {
+ for (var t = 0, e = this.systems; t < e.length; t++)
+ e[t].dispose();
+ this.systems = [], this._emitterNode && (this._emitterNode.dispose(), this._emitterNode = null);
+ }, r.prototype.serialize = function(t) {
+ t === void 0 && (t = !1);
+ for (var e = { systems: [] }, n = 0, i = this.systems; n < i.length; n++) {
+ var o = i[n];
+ e.systems.push(o.serialize(t));
+ }
+ return this._emitterNode && (e.emitter = this._emitterCreationOptions), e;
+ }, r.Parse = function(t, e, n) {
+ n === void 0 && (n = !1);
+ var i = new r(), o = this.BaseAssetsUrl + "/textures/";
+ e = e || te.a.LastCreatedScene;
+ for (var a = 0, s = t.systems; a < s.length; a++) {
+ var d = s[a];
+ i.systems.push(n ? Zi.Parse(d, e, o, !0) : cn.Parse(d, e, o, !0));
+ }
+ if (t.emitter) {
+ var p = t.emitter.options;
+ switch (t.emitter.kind) {
+ case "Sphere":
+ i.setEmitterAsSphere({ diameter: p.diameter, segments: p.segments, color: I.a.FromArray(p.color) }, t.emitter.renderingGroupId, e);
+ }
+ }
+ return i;
+ }, r.BaseAssetsUrl = "https://assets.babylonjs.com/particles", r;
+ }(), vm = function() {
+ function r() {
+ }
+ return r.CreateDefault = function(t, e, n, i) {
+ var o;
+ return e === void 0 && (e = 500), i === void 0 && (i = !1), (o = i ? new Zi("default system", { capacity: e }, n) : new cn("default system", e, n)).emitter = t, o.particleTexture = new Ne.a("https://www.babylonjs.com/assets/Flare.png", o.getScene()), o.createConeEmitter(0.1, Math.PI / 4), o.color1 = new I.b(1, 1, 1, 1), o.color2 = new I.b(1, 1, 1, 1), o.colorDead = new I.b(1, 1, 1, 0), o.minSize = 0.1, o.maxSize = 0.1, o.minEmitPower = 2, o.maxEmitPower = 2, o.updateSpeed = 1 / 60, o.emitRate = 30, o;
+ }, r.CreateAsync = function(t, e, n) {
+ n === void 0 && (n = !1), e || (e = te.a.LastCreatedScene);
+ var i = {};
+ return e._addPendingData(i), new Promise(function(o, a) {
+ if (n && !Zi.IsSupported)
+ return e._removePendingData(i), a("Particle system with GPU is not supported.");
+ Xe.b.LoadFile(r.BaseAssetsUrl + "/systems/" + t + ".json", function(s) {
+ e._removePendingData(i);
+ var d = JSON.parse(s.toString());
+ return o(da.Parse(d, e, n));
+ }, void 0, void 0, void 0, function() {
+ return e._removePendingData(i), a("An error occured while the creation of your particle system. Check if your type '" + t + "' exists.");
+ });
+ });
+ }, r.ExportSet = function(t) {
+ for (var e = new da(), n = 0, i = t; n < i.length; n++) {
+ var o = i[n];
+ e.systems.push(o);
+ }
+ return e;
+ }, r.ParseFromFileAsync = function(t, e, n, i, o) {
+ return i === void 0 && (i = !1), o === void 0 && (o = ""), new Promise(function(a, s) {
+ var d = new re.a();
+ d.addEventListener("readystatechange", function() {
+ if (d.readyState == 4)
+ if (d.status == 200) {
+ var p = JSON.parse(d.responseText), y = void 0;
+ y = i ? Zi.Parse(p, n, o) : cn.Parse(p, n, o), t && (y.name = t), a(y);
+ } else
+ s("Unable to load the particle system");
+ }), d.open("GET", e), d.send();
+ });
+ }, r.CreateFromSnippetAsync = function(t, e, n, i) {
+ var o = this;
+ if (n === void 0 && (n = !1), i === void 0 && (i = ""), t === "_BLANK") {
+ var a = this.CreateDefault(null);
+ return a.start(), Promise.resolve(a);
+ }
+ return new Promise(function(s, d) {
+ var p = new re.a();
+ p.addEventListener("readystatechange", function() {
+ if (p.readyState == 4)
+ if (p.status == 200) {
+ var y = JSON.parse(JSON.parse(p.responseText).jsonPayload), P = JSON.parse(y.particleSystem), R = void 0;
+ (R = n ? Zi.Parse(P, e, i) : cn.Parse(P, e, i)).snippetId = t, s(R);
+ } else
+ d("Unable to load the snippet " + t);
+ }), p.open("GET", o.SnippetUrl + "/" + t.replace(/#/g, "/")), p.send();
+ });
+ }, r.BaseAssetsUrl = da.BaseAssetsUrl, r.SnippetUrl = "https://snippet.babylonjs.com", r;
+ }();
+ V.a.AddParser(ot.a.NAME_PARTICLESYSTEM, function(r, t, e, n) {
+ var i = V.a.GetIndividualParser(ot.a.NAME_PARTICLESYSTEM);
+ if (i && r.particleSystems !== void 0 && r.particleSystems !== null)
+ for (var o = 0, a = r.particleSystems.length; o < a; o++) {
+ var s = r.particleSystems[o];
+ e.particleSystems.push(i(s, t, n));
+ }
+ }), V.a.AddIndividualParser(ot.a.NAME_PARTICLESYSTEM, function(r, t, e) {
+ return r.activeParticleCount ? Zi.Parse(r, t, e) : cn.Parse(r, t, e);
+ }), Ue.a.prototype.createEffectForParticles = function(r, t, e, n, i, o, a, s) {
+ var d;
+ t === void 0 && (t = []), e === void 0 && (e = []), n === void 0 && (n = "");
+ var p = [], y = [], P = [];
+ return s ? s.fillUniformsAttributesAndSamplerNames(y, p, P) : (p = cn._GetAttributeNamesOrOptions(), y = cn._GetEffectCreationOptions()), n.indexOf(" BILLBOARD") === -1 && (n += `
+#define BILLBOARD
+`), e.indexOf("diffuseSampler") === -1 && e.push("diffuseSampler"), this.createEffect({ vertex: (d = s == null ? void 0 : s.vertexShaderName) !== null && d !== void 0 ? d : "particles", fragmentElement: r }, p, y.concat(t), P.concat(e), n, i, o, a);
+ }, Ie.a.prototype.getEmittedParticleSystems = function() {
+ for (var r = new Array(), t = 0; t < this.getScene().particleSystems.length; t++) {
+ var e = this.getScene().particleSystems[t];
+ e.emitter === this && r.push(e);
+ }
+ return r;
+ }, Ie.a.prototype.getHierarchyEmittedParticleSystems = function() {
+ var r = new Array(), t = this.getDescendants();
+ t.push(this);
+ for (var e = 0; e < this.getScene().particleSystems.length; e++) {
+ var n = this.getScene().particleSystems[e], i = n.emitter;
+ i.position && t.indexOf(i) !== -1 && r.push(n);
+ }
+ return r;
+ };
+ var bn, yc = function() {
+ function r(t, e, n, i, o, a, s, d, p, y) {
+ p === void 0 && (p = null), y === void 0 && (y = null), this.idx = 0, this.id = 0, this.color = new I.b(1, 1, 1, 1), this.position = u.e.Zero(), this.rotation = u.e.Zero(), this.scaling = u.e.One(), this.uvs = new u.f(0, 0, 1, 1), this.velocity = u.e.Zero(), this.pivot = u.e.Zero(), this.translateFromPivot = !1, this.alive = !0, this.isVisible = !0, this._pos = 0, this._ind = 0, this.shapeId = 0, this.idxInShape = 0, this._stillInvisible = !1, this._rotationMatrix = [1, 0, 0, 0, 1, 0, 0, 0, 1], this.parentId = null, this.materialIndex = null, this.props = null, this.cullingStrategy = Mt.a.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY, this._globalPosition = u.e.Zero(), this.idx = t, this.id = e, this._pos = n, this._ind = i, this._model = o, this.shapeId = a, this.idxInShape = s, this._sps = d, p && (this._modelBoundingInfo = p, this._boundingInfo = new Mi.a(p.minimum, p.maximum)), y !== null && (this.materialIndex = y);
+ }
+ return r.prototype.copyToRef = function(t) {
+ return t.position.copyFrom(this.position), t.rotation.copyFrom(this.rotation), this.rotationQuaternion && (t.rotationQuaternion ? t.rotationQuaternion.copyFrom(this.rotationQuaternion) : t.rotationQuaternion = this.rotationQuaternion.clone()), t.scaling.copyFrom(this.scaling), this.color && (t.color ? t.color.copyFrom(this.color) : t.color = this.color.clone()), t.uvs.copyFrom(this.uvs), t.velocity.copyFrom(this.velocity), t.pivot.copyFrom(this.pivot), t.translateFromPivot = this.translateFromPivot, t.alive = this.alive, t.isVisible = this.isVisible, t.parentId = this.parentId, t.cullingStrategy = this.cullingStrategy, this.materialIndex !== null && (t.materialIndex = this.materialIndex), this;
+ }, Object.defineProperty(r.prototype, "scale", { get: function() {
+ return this.scaling;
+ }, set: function(t) {
+ this.scaling = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "quaternion", { get: function() {
+ return this.rotationQuaternion;
+ }, set: function(t) {
+ this.rotationQuaternion = t;
+ }, enumerable: !1, configurable: !0 }), r.prototype.intersectsMesh = function(t) {
+ return !(!this._boundingInfo || !t._boundingInfo) && (this._sps._bSphereOnly ? Nl.a.Intersects(this._boundingInfo.boundingSphere, t._boundingInfo.boundingSphere) : this._boundingInfo.intersects(t._boundingInfo, !1));
+ }, r.prototype.isInFrustum = function(t) {
+ return this._boundingInfo !== null && this._boundingInfo.isInFrustum(t, this.cullingStrategy);
+ }, r.prototype.getRotationMatrix = function(t) {
+ var e;
+ if (this.rotationQuaternion)
+ e = this.rotationQuaternion;
+ else {
+ e = u.c.Quaternion[0];
+ var n = this.rotation;
+ u.b.RotationYawPitchRollToRef(n.y, n.x, n.z, e);
+ }
+ e.toRotationMatrix(t);
+ }, r;
+ }(), bc = function(r, t, e, n, i, o, a, s, d) {
+ this._indicesLength = 0, this.shapeID = r, this._shape = t, this._indices = e, this._indicesLength = e.length, this._shapeUV = o, this._shapeColors = i, this._normals = n, this._positionFunction = a, this._vertexFunction = s, this._material = d;
+ }, cd = function(r, t, e, n) {
+ this.idx = 0, this.ind = 0, this.indicesLength = 0, this.sqDistance = 0, this.materialIndex = 0, this.idx = r, this.ind = t, this.indicesLength = e, this.materialIndex = n;
+ }, ld = function() {
+ function r() {
+ this.position = u.e.Zero(), this.color = new I.b(1, 1, 1, 1), this.uv = u.d.Zero();
+ }
+ return Object.defineProperty(r.prototype, "x", { get: function() {
+ return this.position.x;
+ }, set: function(t) {
+ this.position.x = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "y", { get: function() {
+ return this.position.y;
+ }, set: function(t) {
+ this.position.y = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "z", { get: function() {
+ return this.position.z;
+ }, set: function(t) {
+ this.position.z = t;
+ }, enumerable: !1, configurable: !0 }), r;
+ }(), ym = function() {
+ function r(t, e, n) {
+ this.particles = new Array(), this.nbParticles = 0, this.billboard = !1, this.recomputeNormals = !1, this.counter = 0, this.vars = {}, this._bSphereOnly = !1, this._bSphereRadiusFactor = 1, this._positions = new Array(), this._indices = new Array(), this._normals = new Array(), this._colors = new Array(), this._uvs = new Array(), this._index = 0, this._updatable = !0, this._pickable = !1, this._isVisibilityBoxLocked = !1, this._alwaysVisible = !1, this._depthSort = !1, this._expandable = !1, this._shapeCounter = 0, this._copy = new yc(0, 0, 0, 0, null, 0, 0, this), this._color = new I.b(0, 0, 0, 0), this._computeParticleColor = !0, this._computeParticleTexture = !0, this._computeParticleRotation = !0, this._computeParticleVertex = !1, this._computeBoundingBox = !1, this._depthSortParticles = !0, this._mustUnrotateFixedNormals = !1, this._particlesIntersect = !1, this._needs32Bits = !1, this._isNotBuilt = !0, this._lastParticleId = 0, this._idxOfId = [], this._multimaterialEnabled = !1, this._useModelMaterial = !1, this._depthSortFunction = function(i, o) {
+ return o.sqDistance - i.sqDistance;
+ }, this._materialSortFunction = function(i, o) {
+ return i.materialIndex - o.materialIndex;
+ }, this._autoUpdateSubMeshes = !1, this.name = t, this._scene = e || te.a.LastCreatedScene, this._camera = e.activeCamera, this._pickable = !!n && n.isPickable, this._depthSort = !!n && n.enableDepthSort, this._multimaterialEnabled = !!n && n.enableMultiMaterial, this._useModelMaterial = !!n && n.useModelMaterial, this._multimaterialEnabled = !!this._useModelMaterial || this._multimaterialEnabled, this._expandable = !!n && n.expandable, this._particlesIntersect = !!n && n.particleIntersection, this._bSphereOnly = !!n && n.boundingSphereOnly, this._bSphereRadiusFactor = n && n.bSphereRadiusFactor ? n.bSphereRadiusFactor : 1, n && n.updatable !== void 0 ? this._updatable = n.updatable : this._updatable = !0, this._pickable && (this.pickedBySubMesh = [[]], this.pickedParticles = this.pickedBySubMesh[0]), (this._depthSort || this._multimaterialEnabled) && (this.depthSortedParticles = []), this._multimaterialEnabled && (this._multimaterial = new Qi.a(this.name + "MultiMaterial", this._scene), this._materials = [], this._materialIndexesById = {}), this._tmpVertex = new ld();
+ }
+ return r.prototype.buildMesh = function() {
+ if (!this._isNotBuilt && this.mesh)
+ return this.mesh;
+ if (this.nbParticles === 0 && !this.mesh) {
+ var t = ha.CreateDisc("", { radius: 1, tessellation: 3 }, this._scene);
+ this.addShape(t, 1), t.dispose();
+ }
+ if (this._indices32 = this._needs32Bits ? new Uint32Array(this._indices) : new Uint16Array(this._indices), this._positions32 = new Float32Array(this._positions), this._uvs32 = new Float32Array(this._uvs), this._colors32 = new Float32Array(this._colors), !this.mesh) {
+ var e = new Ie.a(this.name, this._scene);
+ this.mesh = e;
+ }
+ !this._updatable && this._multimaterialEnabled && this._sortParticlesByMaterial(), this.recomputeNormals && ht.a.ComputeNormals(this._positions32, this._indices32, this._normals), this._normals32 = new Float32Array(this._normals), this._fixedNormal32 = new Float32Array(this._normals), this._mustUnrotateFixedNormals && this._unrotateFixedNormals();
+ var n = new ht.a();
+ if (n.indices = this._depthSort ? this._indices : this._indices32, n.set(this._positions32, Oe.b.PositionKind), n.set(this._normals32, Oe.b.NormalKind), this._uvs32.length > 0 && n.set(this._uvs32, Oe.b.UVKind), this._colors32.length > 0 && n.set(this._colors32, Oe.b.ColorKind), n.applyToMesh(this.mesh, this._updatable), this.mesh.isPickable = this._pickable, this._pickable) {
+ for (var i = 0, o = 0; o < this.nbParticles; o++)
+ for (var a = this.particles[o], s = a._model._indicesLength, d = 0; d < s; d++)
+ if (d % 3 == 0) {
+ var p = { idx: a.idx, faceId: i };
+ this.pickedParticles[i] = p, i++;
+ }
+ }
+ return this._multimaterialEnabled && this.setMultiMaterial(this._materials), this._expandable || (this._depthSort || this._multimaterialEnabled || (this._indices = null), this._positions = null, this._normals = null, this._uvs = null, this._colors = null, this._updatable || (this.particles.length = 0)), this._isNotBuilt = !1, this.recomputeNormals = !1, this.mesh;
+ }, r.prototype.digest = function(t, e) {
+ var n = e && e.facetNb || 1, i = e && e.number || 0, o = e && e.delta || 0, a = t.getVerticesData(Oe.b.PositionKind), s = t.getIndices(), d = t.getVerticesData(Oe.b.UVKind), p = t.getVerticesData(Oe.b.ColorKind), y = t.getVerticesData(Oe.b.NormalKind), P = e && e.storage ? e.storage : null, R = 0, B = s.length / 3;
+ i ? (i = i > B ? B : i, n = Math.round(B / i), o = 0) : n = n > B ? B : n;
+ for (var F = [], z = [], J = [], ie = [], se = [], ce = u.e.Zero(), ue = n; R < B; ) {
+ R > B - (n = ue + Math.floor((1 + o) * Math.random())) && (n = B - R), F.length = 0, z.length = 0, J.length = 0, ie.length = 0, se.length = 0;
+ for (var fe = 0, ve = 3 * R; ve < 3 * (R + n); ve++) {
+ J.push(fe);
+ var Te = s[ve], Re = 3 * Te;
+ if (F.push(a[Re], a[Re + 1], a[Re + 2]), z.push(y[Re], y[Re + 1], y[Re + 2]), d) {
+ var Ae = 2 * Te;
+ ie.push(d[Ae], d[Ae + 1]);
+ }
+ if (p) {
+ var Ee = 4 * Te;
+ se.push(p[Ee], p[Ee + 1], p[Ee + 2], p[Ee + 3]);
+ }
+ fe++;
+ }
+ var Se, De = this.nbParticles, xe = this._posToShape(F), Le = this._uvsToShapeUV(ie), Me = Xe.b.Slice(J), we = Xe.b.Slice(se), Ye = Xe.b.Slice(z);
+ for (ce.copyFromFloats(0, 0, 0), Se = 0; Se < xe.length; Se++)
+ ce.addInPlace(xe[Se]);
+ ce.scaleInPlace(1 / xe.length);
+ var et, nt = new u.e(1 / 0, 1 / 0, 1 / 0), ct = new u.e(-1 / 0, -1 / 0, -1 / 0);
+ for (Se = 0; Se < xe.length; Se++)
+ xe[Se].subtractInPlace(ce), nt.minimizeInPlaceFromFloats(xe[Se].x, xe[Se].y, xe[Se].z), ct.maximizeInPlaceFromFloats(xe[Se].x, xe[Se].y, xe[Se].z);
+ this._particlesIntersect && (et = new Mi.a(nt, ct));
+ var Ke = null;
+ this._useModelMaterial && (Ke = t.material ? t.material : this._setDefaultMaterial());
+ var rt = new bc(this._shapeCounter, xe, Me, Ye, we, Le, null, null, Ke), it = this._positions.length, qe = this._indices.length;
+ this._meshBuilder(this._index, qe, xe, this._positions, Me, this._indices, ie, this._uvs, we, this._colors, Ye, this._normals, De, 0, null, rt), this._addParticle(De, this._lastParticleId, it, qe, rt, this._shapeCounter, 0, et, P), this.particles[this.nbParticles].position.addInPlace(ce), P || (this._index += xe.length, De++, this.nbParticles++, this._lastParticleId++), this._shapeCounter++, R += n;
+ }
+ return this._isNotBuilt = !0, this;
+ }, r.prototype._unrotateFixedNormals = function() {
+ for (var t = 0, e = 0, n = u.c.Vector3[0], i = u.c.Quaternion[0], o = u.c.Matrix[0], a = 0; a < this.particles.length; a++) {
+ var s = this.particles[a], d = s._model._shape;
+ if (s.rotationQuaternion)
+ s.rotationQuaternion.conjugateToRef(i);
+ else {
+ var p = s.rotation;
+ u.b.RotationYawPitchRollToRef(p.y, p.x, p.z, i), i.conjugateInPlace();
+ }
+ i.toRotationMatrix(o);
+ for (var y = 0; y < d.length; y++)
+ e = t + 3 * y, u.e.TransformNormalFromFloatsToRef(this._normals32[e], this._normals32[e + 1], this._normals32[e + 2], o, n), n.toArray(this._fixedNormal32, e);
+ t = e + 3;
+ }
+ }, r.prototype._resetCopy = function() {
+ var t = this._copy;
+ t.position.setAll(0), t.rotation.setAll(0), t.rotationQuaternion = null, t.scaling.setAll(1), t.uvs.copyFromFloats(0, 0, 1, 1), t.color = null, t.translateFromPivot = !1, t.shapeId = 0, t.materialIndex = null;
+ }, r.prototype._meshBuilder = function(t, e, n, i, o, a, s, d, p, y, P, R, B, F, z, J) {
+ var ie, se = 0, ce = 0, ue = 0;
+ this._resetCopy();
+ var fe = this._copy, ve = !(!z || !z.storage);
+ if (fe.idx = B, fe.idxInShape = F, fe.shapeId = J.shapeID, this._useModelMaterial) {
+ var Te = J._material.uniqueId, Re = this._materialIndexesById;
+ Re.hasOwnProperty(Te) || (Re[Te] = this._materials.length, this._materials.push(J._material));
+ var Ae = Re[Te];
+ fe.materialIndex = Ae;
+ }
+ if (z && z.positionFunction && (z.positionFunction(fe, B, F), this._mustUnrotateFixedNormals = !0), ve)
+ return fe;
+ var Ee = u.c.Matrix[0], Se = this._tmpVertex, De = Se.position, xe = Se.color, Le = Se.uv, Me = u.c.Vector3[1], we = u.c.Vector3[2], Ye = u.c.Vector3[3];
+ u.a.IdentityToRef(Ee), fe.getRotationMatrix(Ee), fe.pivot.multiplyToRef(fe.scaling, Ye), fe.translateFromPivot ? we.setAll(0) : we.copyFrom(Ye);
+ var et = z && z.vertexFunction;
+ for (ie = 0; ie < n.length; ie++) {
+ if (De.copyFrom(n[ie]), fe.color && xe.copyFrom(fe.color), s && Le.copyFromFloats(s[se], s[se + 1]), et && z.vertexFunction(fe, Se, ie), De.multiplyInPlace(fe.scaling).subtractInPlace(Ye), u.e.TransformCoordinatesToRef(De, Ee, Me), Me.addInPlace(we).addInPlace(fe.position), i.push(Me.x, Me.y, Me.z), s) {
+ var nt = fe.uvs;
+ d.push((nt.z - nt.x) * Le.x + nt.x, (nt.w - nt.y) * Le.y + nt.y), se += 2;
+ }
+ if (fe.color)
+ this._color.copyFrom(xe);
+ else {
+ var ct = this._color;
+ p && p[ce] !== void 0 ? (ct.r = p[ce], ct.g = p[ce + 1], ct.b = p[ce + 2], ct.a = p[ce + 3]) : (ct.r = 1, ct.g = 1, ct.b = 1, ct.a = 1);
+ }
+ y.push(this._color.r, this._color.g, this._color.b, this._color.a), ce += 4, !this.recomputeNormals && P && (u.e.TransformNormalFromFloatsToRef(P[ue], P[ue + 1], P[ue + 2], Ee, De), R.push(De.x, De.y, De.z), ue += 3);
+ }
+ for (ie = 0; ie < o.length; ie++) {
+ var Ke = t + o[ie];
+ a.push(Ke), Ke > 65535 && (this._needs32Bits = !0);
+ }
+ if (this._depthSort || this._multimaterialEnabled) {
+ var rt = fe.materialIndex !== null ? fe.materialIndex : 0;
+ this.depthSortedParticles.push(new cd(B, e, o.length, rt));
+ }
+ return fe;
+ }, r.prototype._posToShape = function(t) {
+ for (var e = [], n = 0; n < t.length; n += 3)
+ e.push(u.e.FromArray(t, n));
+ return e;
+ }, r.prototype._uvsToShapeUV = function(t) {
+ var e = [];
+ if (t)
+ for (var n = 0; n < t.length; n++)
+ e.push(t[n]);
+ return e;
+ }, r.prototype._addParticle = function(t, e, n, i, o, a, s, d, p) {
+ d === void 0 && (d = null), p === void 0 && (p = null);
+ var y = new yc(t, e, n, i, o, a, s, this, d);
+ return (p || this.particles).push(y), y;
+ }, r.prototype.addShape = function(t, e, n) {
+ var i = t.getVerticesData(Oe.b.PositionKind), o = t.getIndices(), a = t.getVerticesData(Oe.b.UVKind), s = t.getVerticesData(Oe.b.ColorKind), d = t.getVerticesData(Oe.b.NormalKind);
+ this.recomputeNormals = !d;
+ var p = Xe.b.SliceToArray(o), y = Xe.b.SliceToArray(d), P = s ? Xe.b.SliceToArray(s) : [], R = n && n.storage ? n.storage : null, B = null;
+ this._particlesIntersect && (B = t.getBoundingInfo());
+ var F = this._posToShape(i), z = this._uvsToShapeUV(a), J = n ? n.positionFunction : null, ie = n ? n.vertexFunction : null, se = null;
+ this._useModelMaterial && (se = t.material ? t.material : this._setDefaultMaterial());
+ for (var ce = new bc(this._shapeCounter, F, p, y, P, z, J, ie, se), ue = 0; ue < e; ue++)
+ this._insertNewParticle(this.nbParticles, ue, ce, F, o, a, s, d, B, R, n);
+ return this._shapeCounter++, this._isNotBuilt = !0, this._shapeCounter - 1;
+ }, r.prototype._rebuildParticle = function(t, e) {
+ e === void 0 && (e = !1), this._resetCopy();
+ var n = this._copy;
+ t._model._positionFunction && t._model._positionFunction(n, t.idx, t.idxInShape);
+ var i = u.c.Matrix[0], o = u.c.Vector3[0], a = u.c.Vector3[1], s = u.c.Vector3[2], d = u.c.Vector3[3];
+ n.getRotationMatrix(i), t.pivot.multiplyToRef(t.scaling, d), n.translateFromPivot ? s.copyFromFloats(0, 0, 0) : s.copyFrom(d);
+ for (var p = t._model._shape, y = 0; y < p.length; y++)
+ o.copyFrom(p[y]), t._model._vertexFunction && t._model._vertexFunction(n, o, y), o.multiplyInPlace(n.scaling).subtractInPlace(d), u.e.TransformCoordinatesToRef(o, i, a), a.addInPlace(s).addInPlace(n.position).toArray(this._positions32, t._pos + 3 * y);
+ e && (t.position.setAll(0), t.rotation.setAll(0), t.rotationQuaternion = null, t.scaling.setAll(1), t.uvs.setAll(0), t.pivot.setAll(0), t.translateFromPivot = !1, t.parentId = null);
+ }, r.prototype.rebuildMesh = function(t) {
+ t === void 0 && (t = !1);
+ for (var e = 0; e < this.particles.length; e++)
+ this._rebuildParticle(this.particles[e], t);
+ return this.mesh.updateVerticesData(Oe.b.PositionKind, this._positions32, !1, !1), this;
+ }, r.prototype.removeParticles = function(t, e) {
+ var n = e - t + 1;
+ if (!this._expandable || n <= 0 || n >= this.nbParticles || !this._updatable)
+ return [];
+ var i = this.particles, o = this.nbParticles;
+ if (e < o - 1)
+ for (var a = e + 1, s = i[a]._pos - i[t]._pos, d = i[a]._ind - i[t]._ind, p = a; p < o; p++) {
+ var y = i[p];
+ y._pos -= s, y._ind -= d;
+ }
+ var P = i.splice(t, n);
+ this._positions.length = 0, this._indices.length = 0, this._colors.length = 0, this._uvs.length = 0, this._normals.length = 0, this._index = 0, this._idxOfId.length = 0, (this._depthSort || this._multimaterialEnabled) && (this.depthSortedParticles = []);
+ for (var R = 0, B = i.length, F = 0; F < B; F++) {
+ var z = i[F], J = z._model, ie = J._shape, se = J._indices, ce = J._normals, ue = J._shapeColors, fe = J._shapeUV;
+ z.idx = F, this._idxOfId[z.id] = F, this._meshBuilder(this._index, R, ie, this._positions, se, this._indices, fe, this._uvs, ue, this._colors, ce, this._normals, z.idx, z.idxInShape, null, J), this._index += ie.length, R += se.length;
+ }
+ return this.nbParticles -= n, this._isNotBuilt = !0, P;
+ }, r.prototype.insertParticlesFromArray = function(t) {
+ if (!this._expandable)
+ return this;
+ for (var e = 0, n = t[0].shapeId, i = t.length, o = 0; o < i; o++) {
+ var a = t[o], s = a._model, d = s._shape, p = s._indices, y = s._shapeUV, P = s._shapeColors, R = s._normals, B = !R;
+ this.recomputeNormals = B || this.recomputeNormals;
+ var F = a._boundingInfo, z = this._insertNewParticle(this.nbParticles, e, s, d, p, y, P, R, F, null, null);
+ a.copyToRef(z), e++, n != a.shapeId && (n = a.shapeId, e = 0);
+ }
+ return this._isNotBuilt = !0, this;
+ }, r.prototype._insertNewParticle = function(t, e, n, i, o, a, s, d, p, y, P) {
+ var R = this._positions.length, B = this._indices.length, F = this._meshBuilder(this._index, B, i, this._positions, o, this._indices, a, this._uvs, s, this._colors, d, this._normals, t, e, P, n), z = null;
+ return this._updatable && ((z = this._addParticle(this.nbParticles, this._lastParticleId, R, B, n, this._shapeCounter, e, p, y)).position.copyFrom(F.position), z.rotation.copyFrom(F.rotation), F.rotationQuaternion && (z.rotationQuaternion ? z.rotationQuaternion.copyFrom(F.rotationQuaternion) : z.rotationQuaternion = F.rotationQuaternion.clone()), F.color && (z.color ? z.color.copyFrom(F.color) : z.color = F.color.clone()), z.scaling.copyFrom(F.scaling), z.uvs.copyFrom(F.uvs), F.materialIndex !== null && (z.materialIndex = F.materialIndex), this.expandable && (this._idxOfId[z.id] = z.idx)), y || (this._index += i.length, this.nbParticles++, this._lastParticleId++), z;
+ }, r.prototype.setParticles = function(t, e, n) {
+ if (t === void 0 && (t = 0), e === void 0 && (e = this.nbParticles - 1), n === void 0 && (n = !0), !this._updatable || this._isNotBuilt)
+ return this;
+ this.beforeUpdateParticles(t, e, n);
+ var i = u.c.Matrix[0], o = u.c.Matrix[1], a = this.mesh, s = this._colors32, d = this._positions32, p = this._normals32, y = this._uvs32, P = this._indices32, R = this._indices, B = this._fixedNormal32, F = u.c.Vector3, z = F[5].copyFromFloats(1, 0, 0), J = F[6].copyFromFloats(0, 1, 0), ie = F[7].copyFromFloats(0, 0, 1), se = F[8].setAll(Number.MAX_VALUE), ce = F[9].setAll(-Number.MAX_VALUE), ue = F[10].setAll(0), fe = this._tmpVertex, ve = fe.position, Te = fe.color, Re = fe.uv;
+ if ((this.billboard || this._depthSort) && (this.mesh.computeWorldMatrix(!0), this.mesh._worldMatrix.invertToRef(o)), this.billboard) {
+ var Ae = F[0];
+ this._camera.getDirectionToRef(be.a.Z, Ae), u.e.TransformNormalToRef(Ae, o, ie), ie.normalize();
+ var Ee = this._camera.getViewMatrix(!0);
+ u.e.TransformNormalFromFloatsToRef(Ee.m[1], Ee.m[5], Ee.m[9], o, J), u.e.CrossToRef(J, ie, z), J.normalize(), z.normalize();
+ }
+ this._depthSort && u.e.TransformCoordinatesToRef(this._camera.globalPosition, o, ue), u.a.IdentityToRef(i);
+ var Se = 0, De = 0, xe = 0, Le = 0, Me = 0, we = 0, Ye = 0;
+ if (this.mesh.isFacetDataEnabled && (this._computeBoundingBox = !0), e = e >= this.nbParticles ? this.nbParticles - 1 : e, this._computeBoundingBox && (t != 0 || e != this.nbParticles - 1)) {
+ var et = this.mesh._boundingInfo;
+ et && (se.copyFrom(et.minimum), ce.copyFrom(et.maximum));
+ }
+ var nt = (De = this.particles[t]._pos) / 3 | 0;
+ Le = 4 * nt, we = 2 * nt;
+ for (var ct = t; ct <= e; ct++) {
+ var Ke = this.particles[ct];
+ this.updateParticle(Ke);
+ var rt = Ke._model._shape, it = Ke._model._shapeUV, qe = Ke._rotationMatrix, ut = Ke.position, Ve = Ke.rotation, Ze = Ke.scaling, vt = Ke._globalPosition;
+ if (this._depthSort && this._depthSortParticles) {
+ var jt = this.depthSortedParticles[ct];
+ jt.idx = Ke.idx, jt.ind = Ke._ind, jt.indicesLength = Ke._model._indicesLength, jt.sqDistance = u.e.DistanceSquared(Ke.position, ue);
+ }
+ if (!Ke.alive || Ke._stillInvisible && !Ke.isVisible)
+ De += 3 * (Ye = rt.length), Le += 4 * Ye, we += 2 * Ye;
+ else {
+ if (Ke.isVisible) {
+ Ke._stillInvisible = !1;
+ var Dt = F[12];
+ if (Ke.pivot.multiplyToRef(Ze, Dt), this.billboard && (Ve.x = 0, Ve.y = 0), (this._computeParticleRotation || this.billboard) && Ke.getRotationMatrix(i), Ke.parentId !== null) {
+ var Yt = this.getParticleById(Ke.parentId);
+ if (Yt) {
+ var mt = Yt._rotationMatrix, qt = Yt._globalPosition, Ht = ut.x * mt[1] + ut.y * mt[4] + ut.z * mt[7], kt = ut.x * mt[0] + ut.y * mt[3] + ut.z * mt[6], Wt = ut.x * mt[2] + ut.y * mt[5] + ut.z * mt[8];
+ if (vt.x = qt.x + kt, vt.y = qt.y + Ht, vt.z = qt.z + Wt, this._computeParticleRotation || this.billboard) {
+ var bt = i.m;
+ qe[0] = bt[0] * mt[0] + bt[1] * mt[3] + bt[2] * mt[6], qe[1] = bt[0] * mt[1] + bt[1] * mt[4] + bt[2] * mt[7], qe[2] = bt[0] * mt[2] + bt[1] * mt[5] + bt[2] * mt[8], qe[3] = bt[4] * mt[0] + bt[5] * mt[3] + bt[6] * mt[6], qe[4] = bt[4] * mt[1] + bt[5] * mt[4] + bt[6] * mt[7], qe[5] = bt[4] * mt[2] + bt[5] * mt[5] + bt[6] * mt[8], qe[6] = bt[8] * mt[0] + bt[9] * mt[3] + bt[10] * mt[6], qe[7] = bt[8] * mt[1] + bt[9] * mt[4] + bt[10] * mt[7], qe[8] = bt[8] * mt[2] + bt[9] * mt[5] + bt[10] * mt[8];
+ }
+ } else
+ Ke.parentId = null;
+ } else
+ vt.x = ut.x, vt.y = ut.y, vt.z = ut.z, (this._computeParticleRotation || this.billboard) && (bt = i.m, qe[0] = bt[0], qe[1] = bt[1], qe[2] = bt[2], qe[3] = bt[4], qe[4] = bt[5], qe[5] = bt[6], qe[6] = bt[8], qe[7] = bt[9], qe[8] = bt[10]);
+ var Rt = F[11];
+ for (Ke.translateFromPivot ? Rt.setAll(0) : Rt.copyFrom(Dt), Ye = 0; Ye < rt.length; Ye++) {
+ Se = De + 3 * Ye, xe = Le + 4 * Ye, Me = we + 2 * Ye;
+ var Zt = 2 * Ye, Mn = Zt + 1;
+ ve.copyFrom(rt[Ye]), this._computeParticleColor && Ke.color && Te.copyFrom(Ke.color), this._computeParticleTexture && Re.copyFromFloats(it[Zt], it[Mn]), this._computeParticleVertex && this.updateParticleVertex(Ke, fe, Ye);
+ var Bn = ve.x * Ze.x - Dt.x, Kn = ve.y * Ze.y - Dt.y, In = ve.z * Ze.z - Dt.z;
+ kt = Bn * qe[0] + Kn * qe[3] + In * qe[6], Ht = Bn * qe[1] + Kn * qe[4] + In * qe[7], Wt = Bn * qe[2] + Kn * qe[5] + In * qe[8], kt += Rt.x, Ht += Rt.y, Wt += Rt.z;
+ var Kt = d[Se] = vt.x + z.x * kt + J.x * Ht + ie.x * Wt, oi = d[Se + 1] = vt.y + z.y * kt + J.y * Ht + ie.y * Wt, Ti = d[Se + 2] = vt.z + z.z * kt + J.z * Ht + ie.z * Wt;
+ if (this._computeBoundingBox && (se.minimizeInPlaceFromFloats(Kt, oi, Ti), ce.maximizeInPlaceFromFloats(Kt, oi, Ti)), !this._computeParticleVertex) {
+ var Lr = B[Se], Nr = B[Se + 1], ai = B[Se + 2], wi = Lr * qe[0] + Nr * qe[3] + ai * qe[6], wr = Lr * qe[1] + Nr * qe[4] + ai * qe[7], Gt = Lr * qe[2] + Nr * qe[5] + ai * qe[8];
+ p[Se] = z.x * wi + J.x * wr + ie.x * Gt, p[Se + 1] = z.y * wi + J.y * wr + ie.y * Gt, p[Se + 2] = z.z * wi + J.z * wr + ie.z * Gt;
+ }
+ if (this._computeParticleColor && Ke.color) {
+ var Fi = this._colors32;
+ Fi[xe] = Te.r, Fi[xe + 1] = Te.g, Fi[xe + 2] = Te.b, Fi[xe + 3] = Te.a;
+ }
+ if (this._computeParticleTexture) {
+ var Tn = Ke.uvs;
+ y[Me] = Re.x * (Tn.z - Tn.x) + Tn.x, y[Me + 1] = Re.y * (Tn.w - Tn.y) + Tn.y;
+ }
+ }
+ } else
+ for (Ke._stillInvisible = !0, Ye = 0; Ye < rt.length; Ye++) {
+ if (xe = Le + 4 * Ye, Me = we + 2 * Ye, d[Se = De + 3 * Ye] = d[Se + 1] = d[Se + 2] = 0, p[Se] = p[Se + 1] = p[Se + 2] = 0, this._computeParticleColor && Ke.color) {
+ var er = Ke.color;
+ s[xe] = er.r, s[xe + 1] = er.g, s[xe + 2] = er.b, s[xe + 3] = er.a;
+ }
+ this._computeParticleTexture && (Tn = Ke.uvs, y[Me] = it[2 * Ye] * (Tn.z - Tn.x) + Tn.x, y[Me + 1] = it[2 * Ye + 1] * (Tn.w - Tn.y) + Tn.y);
+ }
+ if (this._particlesIntersect) {
+ var Ei = Ke._boundingInfo, Ma = Ei.boundingBox, Ia = Ei.boundingSphere, Fr = Ke._modelBoundingInfo;
+ if (!this._bSphereOnly) {
+ var Bi = Fr.boundingBox.vectors, Ui = F[1], tr = F[2];
+ Ui.setAll(Number.MAX_VALUE), tr.setAll(-Number.MAX_VALUE);
+ for (var Vi = 0; Vi < 8; Vi++) {
+ var Br = Bi[Vi].x * Ze.x, Ur = Bi[Vi].y * Ze.y, Vr = Bi[Vi].z * Ze.z, ki = (kt = Br * qe[0] + Ur * qe[3] + Vr * qe[6], Ht = Br * qe[1] + Ur * qe[4] + Vr * qe[7], Wt = Br * qe[2] + Ur * qe[5] + Vr * qe[8], ut.x + z.x * kt + J.x * Ht + ie.x * Wt), Gi = ut.y + z.y * kt + J.y * Ht + ie.y * Wt, kr = ut.z + z.z * kt + J.z * Ht + ie.z * Wt;
+ Ui.minimizeInPlaceFromFloats(ki, Gi, kr), tr.maximizeInPlaceFromFloats(ki, Gi, kr);
+ }
+ Ma.reConstruct(Ui, tr, a._worldMatrix);
+ }
+ var Si = Fr.minimum.multiplyToRef(Ze, F[1]), Dn = Fr.maximum.multiplyToRef(Ze, F[2]), bo = Dn.addToRef(Si, F[3]).scaleInPlace(0.5).addInPlace(vt), nr = Dn.subtractToRef(Si, F[4]).scaleInPlace(0.5 * this._bSphereRadiusFactor), To = bo.subtractToRef(nr, F[1]), tv = bo.addToRef(nr, F[2]);
+ Ia.reConstruct(To, tv, a._worldMatrix);
+ }
+ De = Se + 3, Le = xe + 4, we = Me + 2;
+ }
+ }
+ if (n) {
+ if (this._computeParticleColor && a.updateVerticesData(Oe.b.ColorKind, s, !1, !1), this._computeParticleTexture && a.updateVerticesData(Oe.b.UVKind, y, !1, !1), a.updateVerticesData(Oe.b.PositionKind, d, !1, !1), !a.areNormalsFrozen || a.isFacetDataEnabled) {
+ if (this._computeParticleVertex || a.isFacetDataEnabled) {
+ var nv = a.isFacetDataEnabled ? a.getFacetDataParameters() : null;
+ ht.a.ComputeNormals(d, P, p, nv);
+ for (var Ai = 0; Ai < p.length; Ai++)
+ B[Ai] = p[Ai];
+ }
+ a.areNormalsFrozen || a.updateVerticesData(Oe.b.NormalKind, p, !1, !1);
+ }
+ if (this._depthSort && this._depthSortParticles) {
+ var jc = this.depthSortedParticles;
+ jc.sort(this._depthSortFunction);
+ for (var iv = jc.length, nf = 0, Hc = 0, Wc = 0; Wc < iv; Wc++) {
+ var Xc = jc[Wc], rv = Xc.indicesLength, ov = Xc.ind;
+ for (Ai = 0; Ai < rv; Ai++)
+ if (P[nf] = R[ov + Ai], nf++, this._pickable && Ai % 3 == 0) {
+ var rf = this.pickedParticles[Hc];
+ rf.idx = Xc.idx, rf.faceId = Hc, Hc++;
+ }
+ }
+ a.updateIndices(P);
+ }
+ }
+ return this._computeBoundingBox && (a._boundingInfo ? a._boundingInfo.reConstruct(se, ce, a._worldMatrix) : a._boundingInfo = new Mi.a(se, ce, a._worldMatrix)), this._autoUpdateSubMeshes && this.computeSubMeshes(), this.afterUpdateParticles(t, e, n), this;
+ }, r.prototype.dispose = function() {
+ this.mesh.dispose(), this.vars = null, this._positions = null, this._indices = null, this._normals = null, this._uvs = null, this._colors = null, this._indices32 = null, this._positions32 = null, this._normals32 = null, this._fixedNormal32 = null, this._uvs32 = null, this._colors32 = null, this.pickedParticles = null, this.pickedBySubMesh = null, this._materials = null, this._materialIndexes = null, this._indicesByMaterial = null, this._idxOfId = null;
+ }, r.prototype.pickedParticle = function(t) {
+ if (t.hit) {
+ var e = t.subMeshId, n = t.faceId, i = this.pickedBySubMesh;
+ if (i[e] && i[e][n])
+ return i[e][n];
+ }
+ return null;
+ }, r.prototype.getParticleById = function(t) {
+ var e = this.particles[t];
+ if (e && e.id == t)
+ return e;
+ var n = this.particles, i = this._idxOfId[t];
+ if (i !== void 0)
+ return n[i];
+ for (var o = 0, a = this.nbParticles; o < a; ) {
+ var s = n[o];
+ if (s.id == t)
+ return s;
+ o++;
+ }
+ return null;
+ }, r.prototype.getParticlesByShapeId = function(t) {
+ var e = [];
+ return this.getParticlesByShapeIdToRef(t, e), e;
+ }, r.prototype.getParticlesByShapeIdToRef = function(t, e) {
+ e.length = 0;
+ for (var n = 0; n < this.nbParticles; n++) {
+ var i = this.particles[n];
+ i.shapeId == t && e.push(i);
+ }
+ return this;
+ }, r.prototype.computeSubMeshes = function() {
+ if (!this.mesh || !this._multimaterialEnabled)
+ return this;
+ var t = this.depthSortedParticles;
+ if (this.particles.length > 0)
+ for (var e = 0; e < this.particles.length; e++) {
+ var n = this.particles[e];
+ n.materialIndex || (n.materialIndex = 0);
+ var i = t[e];
+ i.materialIndex = n.materialIndex, i.ind = n._ind, i.indicesLength = n._model._indicesLength, i.idx = n.idx;
+ }
+ this._sortParticlesByMaterial();
+ var o = this._indicesByMaterial, a = this._materialIndexes, s = this.mesh;
+ s.subMeshes = [];
+ for (var d = s.getTotalVertices(), p = 0; p < a.length; p++) {
+ var y = o[p], P = o[p + 1] - y, R = a[p];
+ new uo.a(R, 0, d, y, P, s);
+ }
+ return this;
+ }, r.prototype._sortParticlesByMaterial = function() {
+ var t = [0];
+ this._indicesByMaterial = t;
+ var e = [];
+ this._materialIndexes = e;
+ var n = this.depthSortedParticles;
+ n.sort(this._materialSortFunction);
+ var i = n.length, o = this._indices32, a = this._indices, s = 0, d = 0, p = 0, y = n[0].materialIndex;
+ e.push(y), this._pickable && (this.pickedBySubMesh = [[]], this.pickedParticles = this.pickedBySubMesh[0]);
+ for (var P = 0; P < i; P++) {
+ var R = n[P], B = R.indicesLength, F = R.ind;
+ R.materialIndex !== y && (y = R.materialIndex, t.push(p), e.push(y), this._pickable && (s++, this.pickedBySubMesh[s] = [], d = 0));
+ for (var z = 0, J = 0; J < B; J++) {
+ if (o[p] = a[F + J], this._pickable && J % 3 == 0) {
+ var ie = this.pickedBySubMesh[s][d];
+ ie ? (ie.idx = R.idx, ie.faceId = z) : this.pickedBySubMesh[s][d] = { idx: R.idx, faceId: z }, d++, z++;
+ }
+ p++;
+ }
+ }
+ return t.push(o.length), this._updatable && this.mesh.updateIndices(o), this;
+ }, r.prototype._setMaterialIndexesById = function() {
+ this._materialIndexesById = {};
+ for (var t = 0; t < this._materials.length; t++) {
+ var e = this._materials[t].uniqueId;
+ this._materialIndexesById[e] = t;
+ }
+ }, r.prototype._filterUniqueMaterialId = function(t) {
+ return t.filter(function(e, n, i) {
+ return i.indexOf(e) === n;
+ });
+ }, r.prototype._setDefaultMaterial = function() {
+ return this._defaultMaterial || (this._defaultMaterial = new Nt.a(this.name + "DefaultMaterial", this._scene)), this._defaultMaterial;
+ }, r.prototype.refreshVisibleSize = function() {
+ return this._isVisibilityBoxLocked || this.mesh.refreshBoundingInfo(), this;
+ }, r.prototype.setVisibilityBox = function(t) {
+ var e = t / 2;
+ this.mesh._boundingInfo = new Mi.a(new u.e(-e, -e, -e), new u.e(e, e, e));
+ }, Object.defineProperty(r.prototype, "isAlwaysVisible", { get: function() {
+ return this._alwaysVisible;
+ }, set: function(t) {
+ this._alwaysVisible = t, this.mesh.alwaysSelectAsActiveMesh = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "isVisibilityBoxLocked", { get: function() {
+ return this._isVisibilityBoxLocked;
+ }, set: function(t) {
+ this._isVisibilityBoxLocked = t, this.mesh.getBoundingInfo().isLocked = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "computeParticleRotation", { get: function() {
+ return this._computeParticleRotation;
+ }, set: function(t) {
+ this._computeParticleRotation = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "computeParticleColor", { get: function() {
+ return this._computeParticleColor;
+ }, set: function(t) {
+ this._computeParticleColor = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "computeParticleTexture", { get: function() {
+ return this._computeParticleTexture;
+ }, set: function(t) {
+ this._computeParticleTexture = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "computeParticleVertex", { get: function() {
+ return this._computeParticleVertex;
+ }, set: function(t) {
+ this._computeParticleVertex = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "computeBoundingBox", { get: function() {
+ return this._computeBoundingBox;
+ }, set: function(t) {
+ this._computeBoundingBox = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "depthSortParticles", { get: function() {
+ return this._depthSortParticles;
+ }, set: function(t) {
+ this._depthSortParticles = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "expandable", { get: function() {
+ return this._expandable;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "multimaterialEnabled", { get: function() {
+ return this._multimaterialEnabled;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "useModelMaterial", { get: function() {
+ return this._useModelMaterial;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "materials", { get: function() {
+ return this._materials;
+ }, enumerable: !1, configurable: !0 }), r.prototype.setMultiMaterial = function(t) {
+ this._materials = this._filterUniqueMaterialId(t), this._setMaterialIndexesById(), this._multimaterial && this._multimaterial.dispose(), this._multimaterial = new Qi.a(this.name + "MultiMaterial", this._scene);
+ for (var e = 0; e < this._materials.length; e++)
+ this._multimaterial.subMaterials.push(this._materials[e]);
+ this.computeSubMeshes(), this.mesh.material = this._multimaterial;
+ }, Object.defineProperty(r.prototype, "multimaterial", { get: function() {
+ return this._multimaterial;
+ }, set: function(t) {
+ this._multimaterial = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "autoUpdateSubMeshes", { get: function() {
+ return this._autoUpdateSubMeshes;
+ }, set: function(t) {
+ this._autoUpdateSubMeshes = t;
+ }, enumerable: !1, configurable: !0 }), r.prototype.initParticles = function() {
+ }, r.prototype.recycleParticle = function(t) {
+ return t;
+ }, r.prototype.updateParticle = function(t) {
+ return t;
+ }, r.prototype.updateParticleVertex = function(t, e, n) {
+ return this;
+ }, r.prototype.beforeUpdateParticles = function(t, e, n) {
+ }, r.prototype.afterUpdateParticles = function(t, e, n) {
+ }, r;
+ }(), ud = function() {
+ function r(t, e, n, i, o) {
+ this.idx = 0, this.color = new I.b(1, 1, 1, 1), this.position = u.e.Zero(), this.rotation = u.e.Zero(), this.uv = new u.d(0, 0), this.velocity = u.e.Zero(), this.pivot = u.e.Zero(), this.translateFromPivot = !1, this._pos = 0, this._ind = 0, this.groupId = 0, this.idxInGroup = 0, this._stillInvisible = !1, this._rotationMatrix = [1, 0, 0, 0, 1, 0, 0, 0, 1], this.parentId = null, this._globalPosition = u.e.Zero(), this.idx = t, this._group = e, this.groupId = n, this.idxInGroup = i, this._pcs = o;
+ }
+ return Object.defineProperty(r.prototype, "size", { get: function() {
+ return this.size;
+ }, set: function(t) {
+ this.size = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "quaternion", { get: function() {
+ return this.rotationQuaternion;
+ }, set: function(t) {
+ this.rotationQuaternion = t;
+ }, enumerable: !1, configurable: !0 }), r.prototype.intersectsMesh = function(t, e) {
+ if (!t._boundingInfo)
+ return !1;
+ if (e = e || !1)
+ return t.getBoundingInfo().boundingSphere.intersectsPoint(this.position.add(this._pcs.mesh.position));
+ var n, i, o, a, s, d;
+ n = t.getBoundingInfo().boundingBox.maximumWorld.x, i = t.getBoundingInfo().boundingBox.minimumWorld.x, o = t.getBoundingInfo().boundingBox.maximumWorld.y, a = t.getBoundingInfo().boundingBox.minimumWorld.y, s = t.getBoundingInfo().boundingBox.maximumWorld.z, d = t.getBoundingInfo().boundingBox.minimumWorld.z;
+ var p = this.position.x + this._pcs.mesh.position.x, y = this.position.y + this._pcs.mesh.position.y, P = this.position.z + this._pcs.mesh.position.z;
+ return i <= p && p <= n && a <= y && y <= o && d <= P && P <= s;
+ }, r.prototype.getRotationMatrix = function(t) {
+ var e;
+ if (this.rotationQuaternion)
+ e = this.rotationQuaternion;
+ else {
+ e = u.c.Quaternion[0];
+ var n = this.rotation;
+ u.b.RotationYawPitchRollToRef(n.y, n.x, n.z, e);
+ }
+ e.toRotationMatrix(t);
+ }, r;
+ }(), fa = function(r, t) {
+ this.groupID = r, this._positionFunction = t;
+ };
+ (function(r) {
+ r[r.Color = 2] = "Color", r[r.UV = 1] = "UV", r[r.Random = 0] = "Random", r[r.Stated = 3] = "Stated";
+ })(bn || (bn = {}));
+ var bm = function() {
+ function r(t, e, n, i) {
+ this.particles = new Array(), this.nbParticles = 0, this.counter = 0, this.vars = {}, this._promises = [], this._positions = new Array(), this._indices = new Array(), this._normals = new Array(), this._colors = new Array(), this._uvs = new Array(), this._updatable = !0, this._isVisibilityBoxLocked = !1, this._alwaysVisible = !1, this._groups = new Array(), this._groupCounter = 0, this._computeParticleColor = !0, this._computeParticleTexture = !0, this._computeParticleRotation = !0, this._computeBoundingBox = !1, this._isReady = !1, this.name = t, this._size = e, this._scene = n || te.a.LastCreatedScene, i && i.updatable !== void 0 ? this._updatable = i.updatable : this._updatable = !0;
+ }
+ return r.prototype.buildMeshAsync = function() {
+ var t = this;
+ return Promise.all(this._promises).then(function() {
+ return t._isReady = !0, t._buildMesh();
+ });
+ }, r.prototype._buildMesh = function() {
+ this.nbParticles === 0 && this.addPoints(1), this._positions32 = new Float32Array(this._positions), this._uvs32 = new Float32Array(this._uvs), this._colors32 = new Float32Array(this._colors);
+ var t = new ht.a();
+ t.set(this._positions32, Oe.b.PositionKind), this._uvs32.length > 0 && t.set(this._uvs32, Oe.b.UVKind);
+ var e = 0;
+ this._colors32.length > 0 && (e = 1, t.set(this._colors32, Oe.b.ColorKind));
+ var n = new Ie.a(this.name, this._scene);
+ t.applyToMesh(n, this._updatable), this.mesh = n, this._positions = null, this._uvs = null, this._colors = null, this._updatable || (this.particles.length = 0);
+ var i = new Nt.a("point cloud material", this._scene);
+ return i.emissiveColor = new I.a(e, e, e), i.disableLighting = !0, i.pointsCloud = !0, i.pointSize = this._size, n.material = i, new Promise(function(o) {
+ return o(n);
+ });
+ }, r.prototype._addParticle = function(t, e, n, i) {
+ var o = new ud(t, e, n, i, this);
+ return this.particles.push(o), o;
+ }, r.prototype._randomUnitVector = function(t) {
+ t.position = new u.e(Math.random(), Math.random(), Math.random()), t.color = new I.b(1, 1, 1, 1);
+ }, r.prototype._getColorIndicesForCoord = function(t, e, n, i) {
+ var o = t._groupImageData, a = n * (4 * i) + 4 * e, s = [a, a + 1, a + 2, a + 3], d = s[1], p = s[2], y = s[3], P = o[s[0]], R = o[d], B = o[p], F = o[y];
+ return new I.b(P / 255, R / 255, B / 255, F);
+ }, r.prototype._setPointsColorOrUV = function(t, e, n, i, o, a, s) {
+ n && t.updateFacetData();
+ var d = 2 * t.getBoundingInfo().boundingSphere.radius, p = t.getVerticesData(Oe.b.PositionKind), y = t.getIndices(), P = t.getVerticesData(Oe.b.UVKind), R = t.getVerticesData(Oe.b.ColorKind), B = u.e.Zero();
+ t.computeWorldMatrix();
+ var F = t.getWorldMatrix();
+ if (!F.isIdentity())
+ for (var z = 0; z < p.length / 3; z++)
+ u.e.TransformCoordinatesFromFloatsToRef(p[3 * z], p[3 * z + 1], p[3 * z + 2], F, B), p[3 * z] = B.x, p[3 * z + 1] = B.y, p[3 * z + 2] = B.z;
+ var J, ie, se = 0, ce = 0, ue = 0, fe = 0, ve = 0, Te = 0, Re = 0, Ae = 0, Ee = 0, Se = 0, De = 0, xe = 0, Le = 0, Me = 0, we = u.e.Zero(), Ye = u.e.Zero(), et = u.e.Zero(), nt = u.e.Zero(), ct = u.e.Zero(), Ke = 0, rt = 0, it = 0, qe = 0, ut = 0, Ve = 0, Ze = u.d.Zero(), vt = u.d.Zero(), jt = u.d.Zero(), Dt = u.d.Zero(), Yt = u.d.Zero(), mt = 0, qt = 0, Ht = 0, kt = 0, Wt = 0, bt = 0, Rt = 0, Zt = 0, Mn = 0, Bn = 0, Kn = 0, In = 0, Kt = u.f.Zero(), oi = u.f.Zero(), Ti = u.f.Zero(), Lr = u.f.Zero(), Nr = u.f.Zero(), ai = 0, wi = 0;
+ s = s || 0;
+ var wr, Gt = new u.f(0, 0, 0, 0), Fi = u.e.Zero(), Tn = u.e.Zero(), er = u.e.Zero(), Ei = 0, Ma = u.e.Zero(), Ia = 0, Fr = 0, Bi = new dn.a(u.e.Zero(), new u.e(1, 0, 0)), Ui = u.e.Zero();
+ for (ce = 0; ce < y.length / 3; ce++) {
+ var tr, Vi, Br, Ur, Vr, ki, Gi, kr;
+ ue = y[3 * ce], fe = y[3 * ce + 1], ve = y[3 * ce + 2], Te = p[3 * ue], Re = p[3 * ue + 1], Ae = p[3 * ue + 2], Ee = p[3 * fe], Se = p[3 * fe + 1], De = p[3 * fe + 2], xe = p[3 * ve], Le = p[3 * ve + 1], Me = p[3 * ve + 2], we.set(Te, Re, Ae), Ye.set(Ee, Se, De), et.set(xe, Le, Me), Ye.subtractToRef(we, nt), et.subtractToRef(Ye, ct), P && (Ke = P[2 * ue], rt = P[2 * ue + 1], it = P[2 * fe], qe = P[2 * fe + 1], ut = P[2 * ve], Ve = P[2 * ve + 1], Ze.set(Ke, rt), vt.set(it, qe), jt.set(ut, Ve), vt.subtractToRef(Ze, Dt), jt.subtractToRef(vt, Yt)), R && i && (mt = R[4 * ue], qt = R[4 * ue + 1], Ht = R[4 * ue + 2], kt = R[4 * ue + 3], Wt = R[4 * fe], bt = R[4 * fe + 1], Rt = R[4 * fe + 2], Zt = R[4 * fe + 3], Mn = R[4 * ve], Bn = R[4 * ve + 1], Kn = R[4 * ve + 2], In = R[4 * ve + 3], Kt.set(mt, qt, Ht, kt), oi.set(Wt, bt, Rt, Zt), Ti.set(Mn, Bn, Kn, In), oi.subtractToRef(Kt, Lr), Ti.subtractToRef(oi, Nr));
+ for (var Si, Dn, bo = new I.a(0, 0, 0), nr = new I.a(0, 0, 0), To = 0; To < e._groupDensity[ce]; To++)
+ se = this.particles.length, this._addParticle(se, e, this._groupCounter, ce + To), Dn = this.particles[se], ai = $.a.RandomRange(0, 1), wi = $.a.RandomRange(0, 1), J = we.add(nt.scale(ai)).add(ct.scale(ai * wi)), n && (Fi = t.getFacetNormal(ce).normalize().scale(-1), Tn = nt.clone().normalize(), er = u.e.Cross(Fi, Tn), Ei = $.a.RandomRange(0, 2 * Math.PI), Ma = Tn.scale(Math.cos(Ei)).add(er.scale(Math.sin(Ei))), Ei = $.a.RandomRange(0.1, Math.PI / 2), Ui = Ma.scale(Math.cos(Ei)).add(Fi.scale(Math.sin(Ei))), Bi.origin = J.add(Ui.scale(1e-5)), Bi.direction = Ui, Bi.length = d, (wr = Bi.intersectsMesh(t)).hit && (Fr = wr.pickedPoint.subtract(J).length(), Ia = $.a.RandomRange(0, 1) * Fr, J.addInPlace(Ui.scale(Ia)))), Dn.position = J.clone(), this._positions.push(Dn.position.x, Dn.position.y, Dn.position.z), i !== void 0 ? P && (ie = Ze.add(Dt.scale(ai)).add(Yt.scale(ai * wi)), i ? o && e._groupImageData !== null ? (tr = e._groupImgWidth, Vi = e._groupImgHeight, Si = this._getColorIndicesForCoord(e, Math.round(ie.x * tr), Math.round(ie.y * Vi), tr), Dn.color = Si, this._colors.push(Si.r, Si.g, Si.b, Si.a)) : R ? (Gt = Kt.add(Lr.scale(ai)).add(Nr.scale(ai * wi)), Dn.color = new I.b(Gt.x, Gt.y, Gt.z, Gt.w), this._colors.push(Gt.x, Gt.y, Gt.z, Gt.w)) : (Gt = Kt.set(Math.random(), Math.random(), Math.random(), 1), Dn.color = new I.b(Gt.x, Gt.y, Gt.z, Gt.w), this._colors.push(Gt.x, Gt.y, Gt.z, Gt.w)) : (Dn.uv = ie.clone(), this._uvs.push(Dn.uv.x, Dn.uv.y))) : (a ? (bo.set(a.r, a.g, a.b), Br = $.a.RandomRange(-s, s), Ur = $.a.RandomRange(-s, s), Vr = (kr = bo.toHSV()).r, (ki = kr.g + Br) < 0 && (ki = 0), ki > 1 && (ki = 1), (Gi = kr.b + Ur) < 0 && (Gi = 0), Gi > 1 && (Gi = 1), I.a.HSVtoRGBToRef(Vr, ki, Gi, nr), Gt.set(nr.r, nr.g, nr.b, 1)) : Gt = Kt.set(Math.random(), Math.random(), Math.random(), 1), Dn.color = new I.b(Gt.x, Gt.y, Gt.z, Gt.w), this._colors.push(Gt.x, Gt.y, Gt.z, Gt.w));
+ }
+ }, r.prototype._colorFromTexture = function(t, e, n) {
+ var i = this;
+ if (t.material === null)
+ return l.a.Warn(t.name + "has no material."), e._groupImageData = null, void this._setPointsColorOrUV(t, e, n, !0, !1);
+ var o = t.material.getActiveTextures();
+ if (o.length === 0)
+ return l.a.Warn(t.name + "has no useable texture."), e._groupImageData = null, void this._setPointsColorOrUV(t, e, n, !0, !1);
+ var a = t.clone();
+ a.setEnabled(!1), this._promises.push(new Promise(function(s) {
+ kn.a.WhenAllReady(o, function() {
+ var d = e._textureNb;
+ return d < 0 && (d = 0), d > o.length - 1 && (d = o.length - 1), e._groupImageData = o[d].readPixels(), e._groupImgWidth = o[d].getSize().width, e._groupImgHeight = o[d].getSize().height, i._setPointsColorOrUV(a, e, n, !0, !0), a.dispose(), s();
+ });
+ }));
+ }, r.prototype._calculateDensity = function(t, e, n) {
+ for (var i, o, a, s, d, p, y, P, R, B, F, z, J, ie, se, ce, ue, fe = new Array(), ve = u.e.Zero(), Te = u.e.Zero(), Re = u.e.Zero(), Ae = u.e.Zero(), Ee = u.e.Zero(), Se = u.e.Zero(), De = new Array(), xe = 0, Le = n.length / 3, Me = 0; Me < Le; Me++)
+ i = n[3 * Me], o = n[3 * Me + 1], a = n[3 * Me + 2], s = e[3 * i], d = e[3 * i + 1], p = e[3 * i + 2], y = e[3 * o], P = e[3 * o + 1], R = e[3 * o + 2], B = e[3 * a], F = e[3 * a + 1], z = e[3 * a + 2], ve.set(s, d, p), Te.set(y, P, R), Re.set(B, F, z), Te.subtractToRef(ve, Ae), Re.subtractToRef(Te, Ee), Re.subtractToRef(ve, Se), ce = ((J = Ae.length()) + (ie = Ee.length()) + (se = Se.length())) / 2, xe += ue = Math.sqrt(ce * (ce - J) * (ce - ie) * (ce - se)), De[Me] = ue;
+ var we = 0;
+ for (Me = 0; Me < Le; Me++)
+ fe[Me] = Math.floor(t * De[Me] / xe), we += fe[Me];
+ var Ye = t - we, et = Math.floor(Ye / Le), nt = Ye % Le;
+ for (et > 0 && (fe = fe.map(function(ct) {
+ return ct + et;
+ })), Me = 0; Me < nt; Me++)
+ fe[Me] += 1;
+ return fe;
+ }, r.prototype.addPoints = function(t, e) {
+ e === void 0 && (e = this._randomUnitVector);
+ for (var n, i = new fa(this._groupCounter, e), o = this.nbParticles, a = 0; a < t; a++)
+ n = this._addParticle(o, i, this._groupCounter, a), i && i._positionFunction && i._positionFunction(n, o, a), this._positions.push(n.position.x, n.position.y, n.position.z), n.color && this._colors.push(n.color.r, n.color.g, n.color.b, n.color.a), n.uv && this._uvs.push(n.uv.x, n.uv.y), o++;
+ return this.nbParticles += t, this._groupCounter++, this._groupCounter;
+ }, r.prototype.addSurfacePoints = function(t, e, n, i, o) {
+ var a = n || bn.Random;
+ (isNaN(a) || a < 0 || a > 3) && (a = bn.Random);
+ var s = t.getVerticesData(Oe.b.PositionKind), d = t.getIndices();
+ this._groups.push(this._groupCounter);
+ var p = new fa(this._groupCounter, null);
+ switch (p._groupDensity = this._calculateDensity(e, s, d), a === bn.Color ? p._textureNb = i || 0 : i = i || new I.b(1, 1, 1, 1), a) {
+ case bn.Color:
+ this._colorFromTexture(t, p, !1);
+ break;
+ case bn.UV:
+ this._setPointsColorOrUV(t, p, !1, !1, !1);
+ break;
+ case bn.Random:
+ this._setPointsColorOrUV(t, p, !1);
+ break;
+ case bn.Stated:
+ this._setPointsColorOrUV(t, p, !1, void 0, void 0, i, o);
+ }
+ return this.nbParticles += e, this._groupCounter++, this._groupCounter - 1;
+ }, r.prototype.addVolumePoints = function(t, e, n, i, o) {
+ var a = n || bn.Random;
+ (isNaN(a) || a < 0 || a > 3) && (a = bn.Random);
+ var s = t.getVerticesData(Oe.b.PositionKind), d = t.getIndices();
+ this._groups.push(this._groupCounter);
+ var p = new fa(this._groupCounter, null);
+ switch (p._groupDensity = this._calculateDensity(e, s, d), a === bn.Color ? p._textureNb = i || 0 : i = i || new I.b(1, 1, 1, 1), a) {
+ case bn.Color:
+ this._colorFromTexture(t, p, !0);
+ break;
+ case bn.UV:
+ this._setPointsColorOrUV(t, p, !0, !1, !1);
+ break;
+ case bn.Random:
+ this._setPointsColorOrUV(t, p, !0);
+ break;
+ case bn.Stated:
+ this._setPointsColorOrUV(t, p, !0, void 0, void 0, i, o);
+ }
+ return this.nbParticles += e, this._groupCounter++, this._groupCounter - 1;
+ }, r.prototype.setParticles = function(t, e, n) {
+ if (t === void 0 && (t = 0), e === void 0 && (e = this.nbParticles - 1), n === void 0 && (n = !0), !this._updatable || !this._isReady)
+ return this;
+ this.beforeUpdateParticles(t, e, n);
+ var i = u.c.Matrix[0], o = this.mesh, a = this._colors32, s = this._positions32, d = this._uvs32, p = u.c.Vector3, y = p[5].copyFromFloats(1, 0, 0), P = p[6].copyFromFloats(0, 1, 0), R = p[7].copyFromFloats(0, 0, 1), B = p[8].setAll(Number.MAX_VALUE), F = p[9].setAll(-Number.MAX_VALUE);
+ u.a.IdentityToRef(i);
+ var z = 0;
+ if (this.mesh.isFacetDataEnabled && (this._computeBoundingBox = !0), e = e >= this.nbParticles ? this.nbParticles - 1 : e, this._computeBoundingBox && (t != 0 || e != this.nbParticles - 1)) {
+ var J = this.mesh._boundingInfo;
+ J && (B.copyFrom(J.minimum), F.copyFrom(J.maximum));
+ }
+ z = 0;
+ for (var ie = 0, se = 0, ce = 0, ue = t; ue <= e; ue++) {
+ var fe = this.particles[ue];
+ ie = 3 * (z = fe.idx), se = 4 * z, ce = 2 * z, this.updateParticle(fe);
+ var ve = fe._rotationMatrix, Te = fe.position, Re = fe._globalPosition;
+ if (this._computeParticleRotation && fe.getRotationMatrix(i), fe.parentId !== null) {
+ var Ae = this.particles[fe.parentId], Ee = Ae._rotationMatrix, Se = Ae._globalPosition, De = Te.x * Ee[1] + Te.y * Ee[4] + Te.z * Ee[7], xe = Te.x * Ee[0] + Te.y * Ee[3] + Te.z * Ee[6], Le = Te.x * Ee[2] + Te.y * Ee[5] + Te.z * Ee[8];
+ if (Re.x = Se.x + xe, Re.y = Se.y + De, Re.z = Se.z + Le, this._computeParticleRotation) {
+ var Me = i.m;
+ ve[0] = Me[0] * Ee[0] + Me[1] * Ee[3] + Me[2] * Ee[6], ve[1] = Me[0] * Ee[1] + Me[1] * Ee[4] + Me[2] * Ee[7], ve[2] = Me[0] * Ee[2] + Me[1] * Ee[5] + Me[2] * Ee[8], ve[3] = Me[4] * Ee[0] + Me[5] * Ee[3] + Me[6] * Ee[6], ve[4] = Me[4] * Ee[1] + Me[5] * Ee[4] + Me[6] * Ee[7], ve[5] = Me[4] * Ee[2] + Me[5] * Ee[5] + Me[6] * Ee[8], ve[6] = Me[8] * Ee[0] + Me[9] * Ee[3] + Me[10] * Ee[6], ve[7] = Me[8] * Ee[1] + Me[9] * Ee[4] + Me[10] * Ee[7], ve[8] = Me[8] * Ee[2] + Me[9] * Ee[5] + Me[10] * Ee[8];
+ }
+ } else
+ Re.x = 0, Re.y = 0, Re.z = 0, this._computeParticleRotation && (Me = i.m, ve[0] = Me[0], ve[1] = Me[1], ve[2] = Me[2], ve[3] = Me[4], ve[4] = Me[5], ve[5] = Me[6], ve[6] = Me[8], ve[7] = Me[9], ve[8] = Me[10]);
+ var we = p[11];
+ fe.translateFromPivot ? we.setAll(0) : we.copyFrom(fe.pivot);
+ var Ye = p[0];
+ Ye.copyFrom(fe.position);
+ var et = Ye.x - fe.pivot.x, nt = Ye.y - fe.pivot.y, ct = Ye.z - fe.pivot.z, Ke = et * ve[0] + nt * ve[3] + ct * ve[6], rt = et * ve[1] + nt * ve[4] + ct * ve[7], it = et * ve[2] + nt * ve[5] + ct * ve[8];
+ Ke += we.x, rt += we.y, it += we.z;
+ var qe = s[ie] = Re.x + y.x * Ke + P.x * rt + R.x * it, ut = s[ie + 1] = Re.y + y.y * Ke + P.y * rt + R.y * it, Ve = s[ie + 2] = Re.z + y.z * Ke + P.z * rt + R.z * it;
+ if (this._computeBoundingBox && (B.minimizeInPlaceFromFloats(qe, ut, Ve), F.maximizeInPlaceFromFloats(qe, ut, Ve)), this._computeParticleColor && fe.color) {
+ var Ze = fe.color, vt = this._colors32;
+ vt[se] = Ze.r, vt[se + 1] = Ze.g, vt[se + 2] = Ze.b, vt[se + 3] = Ze.a;
+ }
+ if (this._computeParticleTexture && fe.uv) {
+ var jt = fe.uv, Dt = this._uvs32;
+ Dt[ce] = jt.x, Dt[ce + 1] = jt.y;
+ }
+ }
+ return n && (this._computeParticleColor && o.updateVerticesData(Oe.b.ColorKind, a, !1, !1), this._computeParticleTexture && o.updateVerticesData(Oe.b.UVKind, d, !1, !1), o.updateVerticesData(Oe.b.PositionKind, s, !1, !1)), this._computeBoundingBox && (o._boundingInfo ? o._boundingInfo.reConstruct(B, F, o._worldMatrix) : o._boundingInfo = new Mi.a(B, F, o._worldMatrix)), this.afterUpdateParticles(t, e, n), this;
+ }, r.prototype.dispose = function() {
+ this.mesh.dispose(), this.vars = null, this._positions = null, this._indices = null, this._normals = null, this._uvs = null, this._colors = null, this._indices32 = null, this._positions32 = null, this._uvs32 = null, this._colors32 = null;
+ }, r.prototype.refreshVisibleSize = function() {
+ return this._isVisibilityBoxLocked || this.mesh.refreshBoundingInfo(), this;
+ }, r.prototype.setVisibilityBox = function(t) {
+ var e = t / 2;
+ this.mesh._boundingInfo = new Mi.a(new u.e(-e, -e, -e), new u.e(e, e, e));
+ }, Object.defineProperty(r.prototype, "isAlwaysVisible", { get: function() {
+ return this._alwaysVisible;
+ }, set: function(t) {
+ this._alwaysVisible = t, this.mesh.alwaysSelectAsActiveMesh = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "computeParticleRotation", { set: function(t) {
+ this._computeParticleRotation = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "computeParticleColor", { get: function() {
+ return this._computeParticleColor;
+ }, set: function(t) {
+ this._computeParticleColor = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "computeParticleTexture", { get: function() {
+ return this._computeParticleTexture;
+ }, set: function(t) {
+ this._computeParticleTexture = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "computeBoundingBox", { get: function() {
+ return this._computeBoundingBox;
+ }, set: function(t) {
+ this._computeBoundingBox = t;
+ }, enumerable: !1, configurable: !0 }), r.prototype.initParticles = function() {
+ }, r.prototype.recycleParticle = function(t) {
+ return t;
+ }, r.prototype.updateParticle = function(t) {
+ return t;
+ }, r.prototype.beforeUpdateParticles = function(t, e, n) {
+ }, r.prototype.afterUpdateParticles = function(t, e, n) {
+ }, r;
+ }();
+ _e.a.prototype.getPhysicsEngine = function() {
+ return this._physicsEngine;
+ }, _e.a.prototype.enablePhysics = function(r, t) {
+ if (r === void 0 && (r = null), this._physicsEngine)
+ return !0;
+ var e = this._getComponent(ot.a.NAME_PHYSICSENGINE);
+ e || (e = new hd(this), this._addComponent(e));
+ try {
+ return this._physicsEngine = new Sr(r, t), this._physicsTimeAccumulator = 0, !0;
+ } catch (n) {
+ return l.a.Error(n.message), !1;
+ }
+ }, _e.a.prototype.disablePhysicsEngine = function() {
+ this._physicsEngine && (this._physicsEngine.dispose(), this._physicsEngine = null);
+ }, _e.a.prototype.isPhysicsEnabled = function() {
+ return this._physicsEngine !== void 0;
+ }, _e.a.prototype.deleteCompoundImpostor = function(r) {
+ var t = r.parts[0].mesh;
+ t.physicsImpostor && (t.physicsImpostor.dispose(), t.physicsImpostor = null);
+ }, _e.a.prototype._advancePhysicsEngineStep = function(r) {
+ if (this._physicsEngine) {
+ var t = this._physicsEngine.getSubTimeStep();
+ if (t > 0)
+ for (this._physicsTimeAccumulator += r; this._physicsTimeAccumulator > t; )
+ this.onBeforePhysicsObservable.notifyObservers(this), this._physicsEngine._step(t / 1e3), this.onAfterPhysicsObservable.notifyObservers(this), this._physicsTimeAccumulator -= t;
+ else
+ this.onBeforePhysicsObservable.notifyObservers(this), this._physicsEngine._step(r / 1e3), this.onAfterPhysicsObservable.notifyObservers(this);
+ }
+ }, Object.defineProperty(Mt.a.prototype, "physicsImpostor", { get: function() {
+ return this._physicsImpostor;
+ }, set: function(r) {
+ var t = this;
+ this._physicsImpostor !== r && (this._disposePhysicsObserver && this.onDisposeObservable.remove(this._disposePhysicsObserver), this._physicsImpostor = r, r && (this._disposePhysicsObserver = this.onDisposeObservable.add(function() {
+ t.physicsImpostor && (t.physicsImpostor.dispose(), t.physicsImpostor = null);
+ })));
+ }, enumerable: !0, configurable: !0 }), Mt.a.prototype.getPhysicsImpostor = function() {
+ return this.physicsImpostor;
+ }, Mt.a.prototype.applyImpulse = function(r, t) {
+ return this.physicsImpostor ? (this.physicsImpostor.applyImpulse(r, t), this) : this;
+ }, Mt.a.prototype.setPhysicsLinkWith = function(r, t, e, n) {
+ return this.physicsImpostor && r.physicsImpostor ? (this.physicsImpostor.createJoint(r.physicsImpostor, Jt.e.HingeJoint, { mainPivot: t, connectedPivot: e, nativeParams: n }), this) : this;
+ };
+ var go, Or, hd = function() {
+ function r(t) {
+ var e = this;
+ this.name = ot.a.NAME_PHYSICSENGINE, this.scene = t, this.scene.onBeforePhysicsObservable = new C.c(), this.scene.onAfterPhysicsObservable = new C.c(), this.scene.getDeterministicFrameTime = function() {
+ return e.scene._physicsEngine ? 1e3 * e.scene._physicsEngine.getTimeStep() : 1e3 / 60;
+ };
+ }
+ return r.prototype.register = function() {
+ }, r.prototype.rebuild = function() {
+ }, r.prototype.dispose = function() {
+ this.scene.onBeforePhysicsObservable.clear(), this.scene.onAfterPhysicsObservable.clear(), this.scene._physicsEngine && this.scene.disablePhysicsEngine();
+ }, r;
+ }(), Tm = function() {
+ function r(t) {
+ this._scene = t, this._physicsEngine = this._scene.getPhysicsEngine(), this._physicsEngine || l.a.Warn("Physics engine not enabled. Please enable the physics before you can use the methods.");
+ }
+ return r.prototype.applyRadialExplosionImpulse = function(t, e, n, i) {
+ if (!this._physicsEngine)
+ return l.a.Warn("Physics engine not enabled. Please enable the physics before you call this method."), null;
+ var o = this._physicsEngine.getImpostors();
+ if (o.length === 0)
+ return null;
+ typeof e == "number" && ((e = new Mr()).radius = e, e.strength = n || e.strength, e.falloff = i || e.falloff);
+ var a = new dd(this._scene, e), s = Array();
+ return o.forEach(function(d) {
+ var p = a.getImpostorHitData(d, t);
+ p && (d.applyImpulse(p.force, p.contactPoint), s.push({ impostor: d, hitData: p }));
+ }), a.triggerAffectedImpostorsCallback(s), a.dispose(!1), a;
+ }, r.prototype.applyRadialExplosionForce = function(t, e, n, i) {
+ if (!this._physicsEngine)
+ return l.a.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."), null;
+ var o = this._physicsEngine.getImpostors();
+ if (o.length === 0)
+ return null;
+ typeof e == "number" && ((e = new Mr()).radius = e, e.strength = n || e.strength, e.falloff = i || e.falloff);
+ var a = new dd(this._scene, e), s = Array();
+ return o.forEach(function(d) {
+ var p = a.getImpostorHitData(d, t);
+ p && (d.applyForce(p.force, p.contactPoint), s.push({ impostor: d, hitData: p }));
+ }), a.triggerAffectedImpostorsCallback(s), a.dispose(!1), a;
+ }, r.prototype.gravitationalField = function(t, e, n, i) {
+ if (!this._physicsEngine)
+ return l.a.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."), null;
+ if (this._physicsEngine.getImpostors().length === 0)
+ return null;
+ typeof e == "number" && ((e = new Mr()).radius = e, e.strength = n || e.strength, e.falloff = i || e.falloff);
+ var o = new Em(this, this._scene, t, e);
+ return o.dispose(!1), o;
+ }, r.prototype.updraft = function(t, e, n, i, o) {
+ if (!this._physicsEngine)
+ return l.a.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."), null;
+ if (this._physicsEngine.getImpostors().length === 0)
+ return null;
+ typeof e == "number" && ((e = new Tc()).radius = e, e.strength = n || e.strength, e.height = i || e.height, e.updraftMode = o || e.updraftMode);
+ var a = new Sm(this._scene, t, e);
+ return a.dispose(!1), a;
+ }, r.prototype.vortex = function(t, e, n, i) {
+ if (!this._physicsEngine)
+ return l.a.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."), null;
+ if (this._physicsEngine.getImpostors().length === 0)
+ return null;
+ typeof e == "number" && ((e = new Ec()).radius = e, e.strength = n || e.strength, e.height = i || e.height);
+ var o = new Am(this._scene, t, e);
+ return o.dispose(!1), o;
+ }, r;
+ }(), dd = function() {
+ function r(t, e) {
+ this._scene = t, this._options = e, this._dataFetched = !1, this._options = Object(c.a)(Object(c.a)({}, new Mr()), this._options);
+ }
+ return r.prototype.getData = function() {
+ return this._dataFetched = !0, { sphere: this._sphere };
+ }, r.prototype.getImpostorHitData = function(t, e) {
+ if (t.mass === 0 || !this._intersectsWithSphere(t, e, this._options.radius) || t.object.getClassName() !== "Mesh" && t.object.getClassName() !== "InstancedMesh")
+ return null;
+ var n = t.getObjectCenter().subtract(e), i = new dn.a(e, n, this._options.radius).intersectsMesh(t.object).pickedPoint;
+ if (!i)
+ return null;
+ var o = u.e.Distance(e, i);
+ if (o > this._options.radius)
+ return null;
+ var a = this._options.falloff === go.Constant ? this._options.strength : this._options.strength * (1 - o / this._options.radius);
+ return { force: n.multiplyByFloats(a, a, a), contactPoint: i, distanceFromOrigin: o };
+ }, r.prototype.triggerAffectedImpostorsCallback = function(t) {
+ this._options.affectedImpostorsCallback && this._options.affectedImpostorsCallback(t);
+ }, r.prototype.dispose = function(t) {
+ var e = this;
+ t === void 0 && (t = !0), t ? this._sphere.dispose() : setTimeout(function() {
+ e._dataFetched || e._sphere.dispose();
+ }, 0);
+ }, r.prototype._prepareSphere = function() {
+ this._sphere || (this._sphere = Nn.a.CreateSphere("radialExplosionEventSphere", this._options.sphere, this._scene), this._sphere.isVisible = !1);
+ }, r.prototype._intersectsWithSphere = function(t, e, n) {
+ var i = t.object;
+ return this._prepareSphere(), this._sphere.position = e, this._sphere.scaling = new u.e(2 * n, 2 * n, 2 * n), this._sphere._updateBoundingInfo(), this._sphere.computeWorldMatrix(!0), this._sphere.intersectsMesh(i, !0);
+ }, r;
+ }(), Em = function() {
+ function r(t, e, n, i) {
+ this._physicsHelper = t, this._scene = e, this._origin = n, this._options = i, this._dataFetched = !1, this._options = Object(c.a)(Object(c.a)({}, new Mr()), this._options), this._tickCallback = this._tick.bind(this), this._options.strength = -1 * this._options.strength;
+ }
+ return r.prototype.getData = function() {
+ return this._dataFetched = !0, { sphere: this._sphere };
+ }, r.prototype.enable = function() {
+ this._tickCallback.call(this), this._scene.registerBeforeRender(this._tickCallback);
+ }, r.prototype.disable = function() {
+ this._scene.unregisterBeforeRender(this._tickCallback);
+ }, r.prototype.dispose = function(t) {
+ var e = this;
+ t === void 0 && (t = !0), t ? this._sphere.dispose() : setTimeout(function() {
+ e._dataFetched || e._sphere.dispose();
+ }, 0);
+ }, r.prototype._tick = function() {
+ if (this._sphere)
+ this._physicsHelper.applyRadialExplosionForce(this._origin, this._options);
+ else {
+ var t = this._physicsHelper.applyRadialExplosionForce(this._origin, this._options);
+ t && (this._sphere = t.getData().sphere.clone("radialExplosionEventSphereClone"));
+ }
+ }, r;
+ }(), Sm = function() {
+ function r(t, e, n) {
+ this._scene = t, this._origin = e, this._options = n, this._originTop = u.e.Zero(), this._originDirection = u.e.Zero(), this._cylinderPosition = u.e.Zero(), this._dataFetched = !1, this._physicsEngine = this._scene.getPhysicsEngine(), this._options = Object(c.a)(Object(c.a)({}, new Tc()), this._options), this._origin.addToRef(new u.e(0, this._options.height / 2, 0), this._cylinderPosition), this._origin.addToRef(new u.e(0, this._options.height, 0), this._originTop), this._options.updraftMode === Or.Perpendicular && (this._originDirection = this._origin.subtract(this._originTop).normalize()), this._tickCallback = this._tick.bind(this), this._prepareCylinder();
+ }
+ return r.prototype.getData = function() {
+ return this._dataFetched = !0, { cylinder: this._cylinder };
+ }, r.prototype.enable = function() {
+ this._tickCallback.call(this), this._scene.registerBeforeRender(this._tickCallback);
+ }, r.prototype.disable = function() {
+ this._scene.unregisterBeforeRender(this._tickCallback);
+ }, r.prototype.dispose = function(t) {
+ var e = this;
+ t === void 0 && (t = !0), this._cylinder && (t ? this._cylinder.dispose() : setTimeout(function() {
+ e._dataFetched || e._cylinder.dispose();
+ }, 0));
+ }, r.prototype.getImpostorHitData = function(t) {
+ if (t.mass === 0 || !this._intersectsWithCylinder(t))
+ return null;
+ var e = t.getObjectCenter();
+ if (this._options.updraftMode === Or.Perpendicular)
+ var n = this._originDirection;
+ else
+ n = e.subtract(this._originTop);
+ var i = u.e.Distance(this._origin, e), o = -1 * this._options.strength;
+ return { force: n.multiplyByFloats(o, o, o), contactPoint: e, distanceFromOrigin: i };
+ }, r.prototype._tick = function() {
+ var t = this;
+ this._physicsEngine.getImpostors().forEach(function(e) {
+ var n = t.getImpostorHitData(e);
+ n && e.applyForce(n.force, n.contactPoint);
+ });
+ }, r.prototype._prepareCylinder = function() {
+ this._cylinder || (this._cylinder = ci.a.CreateCylinder("updraftEventCylinder", { height: this._options.height, diameter: 2 * this._options.radius }, this._scene), this._cylinder.isVisible = !1);
+ }, r.prototype._intersectsWithCylinder = function(t) {
+ var e = t.object;
+ return this._cylinder.position = this._cylinderPosition, this._cylinder.intersectsMesh(e, !0);
+ }, r;
+ }(), Am = function() {
+ function r(t, e, n) {
+ this._scene = t, this._origin = e, this._options = n, this._originTop = u.e.Zero(), this._cylinderPosition = u.e.Zero(), this._dataFetched = !1, this._physicsEngine = this._scene.getPhysicsEngine(), this._options = Object(c.a)(Object(c.a)({}, new Ec()), this._options), this._origin.addToRef(new u.e(0, this._options.height / 2, 0), this._cylinderPosition), this._origin.addToRef(new u.e(0, this._options.height, 0), this._originTop), this._tickCallback = this._tick.bind(this), this._prepareCylinder();
+ }
+ return r.prototype.getData = function() {
+ return this._dataFetched = !0, { cylinder: this._cylinder };
+ }, r.prototype.enable = function() {
+ this._tickCallback.call(this), this._scene.registerBeforeRender(this._tickCallback);
+ }, r.prototype.disable = function() {
+ this._scene.unregisterBeforeRender(this._tickCallback);
+ }, r.prototype.dispose = function(t) {
+ var e = this;
+ t === void 0 && (t = !0), t ? this._cylinder.dispose() : setTimeout(function() {
+ e._dataFetched || e._cylinder.dispose();
+ }, 0);
+ }, r.prototype.getImpostorHitData = function(t) {
+ if (t.mass === 0 || !this._intersectsWithCylinder(t) || t.object.getClassName() !== "Mesh" && t.object.getClassName() !== "InstancedMesh")
+ return null;
+ var e = t.getObjectCenter(), n = new u.e(this._origin.x, e.y, this._origin.z), i = e.subtract(n), o = new dn.a(n, i, this._options.radius).intersectsMesh(t.object), a = o.pickedPoint;
+ if (!a)
+ return null;
+ var s = o.distance / this._options.radius, d = a.normalize();
+ if (s > this._options.centripetalForceThreshold && (d = d.negate()), s > this._options.centripetalForceThreshold)
+ var p = d.x * this._options.centripetalForceMultiplier, y = d.y * this._options.updraftForceMultiplier, P = d.z * this._options.centripetalForceMultiplier;
+ else {
+ var R = u.e.Cross(n, e).normalize();
+ p = (R.x + d.x) * this._options.centrifugalForceMultiplier, y = this._originTop.y * this._options.updraftForceMultiplier, P = (R.z + d.z) * this._options.centrifugalForceMultiplier;
+ }
+ var B = new u.e(p, y, P);
+ return { force: B = B.multiplyByFloats(this._options.strength, this._options.strength, this._options.strength), contactPoint: e, distanceFromOrigin: s };
+ }, r.prototype._tick = function() {
+ var t = this;
+ this._physicsEngine.getImpostors().forEach(function(e) {
+ var n = t.getImpostorHitData(e);
+ n && e.applyForce(n.force, n.contactPoint);
+ });
+ }, r.prototype._prepareCylinder = function() {
+ this._cylinder || (this._cylinder = ci.a.CreateCylinder("vortexEventCylinder", { height: this._options.height, diameter: 2 * this._options.radius }, this._scene), this._cylinder.isVisible = !1);
+ }, r.prototype._intersectsWithCylinder = function(t) {
+ var e = t.object;
+ return this._cylinder.position = this._cylinderPosition, this._cylinder.intersectsMesh(e, !0);
+ }, r;
+ }(), Mr = function() {
+ this.radius = 5, this.strength = 10, this.falloff = go.Constant, this.sphere = { segments: 32, diameter: 1 };
+ }, Tc = function() {
+ this.radius = 5, this.strength = 10, this.height = 10, this.updraftMode = Or.Center;
+ }, Ec = function() {
+ this.radius = 5, this.strength = 10, this.height = 10, this.centripetalForceThreshold = 0.7, this.centripetalForceMultiplier = 5, this.centrifugalForceMultiplier = 0.5, this.updraftForceMultiplier = 0.02;
+ };
+ (function(r) {
+ r[r.Constant = 0] = "Constant", r[r.Linear = 1] = "Linear";
+ })(go || (go = {})), function(r) {
+ r[r.Center = 0] = "Center", r[r.Perpendicular = 1] = "Perpendicular";
+ }(Or || (Or = {}));
+ var Pm = `
+varying vec2 vUV;
+uniform sampler2D textureSampler;
+uniform float degree;
+void main(void)
+{
+vec3 color=texture2D(textureSampler,vUV).rgb;
+float luminance=dot(color,vec3(0.3,0.59,0.11));
+vec3 blackAndWhite=vec3(luminance,luminance,luminance);
+gl_FragColor=vec4(color-((color-blackAndWhite)*degree),1.0);
+}`;
+ ze.a.ShadersStore.blackAndWhitePixelShader = Pm;
+ var fd = function(r) {
+ function t(e, n, i, o, a, s) {
+ var d = r.call(this, e, "blackAndWhite", ["degree"], null, n, i, o, a, s) || this;
+ return d.degree = 1, d.onApplyObservable.add(function(p) {
+ p.setFloat("degree", d.degree);
+ }), d;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "BlackAndWhitePostProcess";
+ }, t._Parse = function(e, n, i, o) {
+ return L.a.Parse(function() {
+ return new t(e.name, e.options, n, e.renderTargetSamplingMode, i.getEngine(), e.reusable);
+ }, e, i, o);
+ }, Object(c.c)([Object(L.c)()], t.prototype, "degree", void 0), t;
+ }(ft);
+ O.a.RegisteredTypes["BABYLON.BlackAndWhitePostProcess"] = fd;
+ var xt = function() {
+ function r(t, e, n, i) {
+ this._name = e, this._singleInstance = i || !0, this._getPostProcesses = n, this._cameras = {}, this._indicesForCamera = {}, this._postProcesses = {};
+ }
+ return Object.defineProperty(r.prototype, "isSupported", { get: function() {
+ for (var t in this._postProcesses)
+ if (this._postProcesses.hasOwnProperty(t)) {
+ for (var e = this._postProcesses[t], n = 0; n < e.length; n++)
+ if (!e[n].isSupported)
+ return !1;
+ }
+ return !0;
+ }, enumerable: !1, configurable: !0 }), r.prototype._update = function() {
+ }, r.prototype._attachCameras = function(t) {
+ var e, n = this, i = Xe.b.MakeArray(t || this._cameras);
+ if (i)
+ for (var o = 0; o < i.length; o++) {
+ var a = i[o];
+ if (a) {
+ var s = a.name;
+ if (e = this._singleInstance ? 0 : s, !this._postProcesses[e]) {
+ var d = this._getPostProcesses();
+ d && (this._postProcesses[e] = Array.isArray(d) ? d : [d]);
+ }
+ this._indicesForCamera[s] || (this._indicesForCamera[s] = []), this._postProcesses[e].forEach(function(p) {
+ var y = a.attachPostProcess(p);
+ n._indicesForCamera[s].push(y);
+ }), this._cameras[s] || (this._cameras[s] = a);
+ }
+ }
+ }, r.prototype._detachCameras = function(t) {
+ var e = Xe.b.MakeArray(t || this._cameras);
+ if (e)
+ for (var n = 0; n < e.length; n++) {
+ var i = e[n], o = i.name, a = this._postProcesses[this._singleInstance ? 0 : o];
+ a && a.forEach(function(s) {
+ i.detachPostProcess(s);
+ }), this._cameras[o] && (this._cameras[o] = null);
+ }
+ }, r.prototype._enable = function(t) {
+ var e = this, n = Xe.b.MakeArray(t || this._cameras);
+ if (n)
+ for (var i = 0; i < n.length; i++)
+ for (var o = n[i], a = o.name, s = 0; s < this._indicesForCamera[a].length; s++)
+ o._postProcesses[this._indicesForCamera[a][s]] !== void 0 && o._postProcesses[this._indicesForCamera[a][s]] !== null || this._postProcesses[this._singleInstance ? 0 : a].forEach(function(d) {
+ n[i].attachPostProcess(d, e._indicesForCamera[a][s]);
+ });
+ }, r.prototype._disable = function(t) {
+ var e = Xe.b.MakeArray(t || this._cameras);
+ if (e)
+ for (var n = 0; n < e.length; n++) {
+ var i = e[n], o = i.name;
+ this._postProcesses[this._singleInstance ? 0 : o].forEach(function(a) {
+ i.detachPostProcess(a);
+ });
+ }
+ }, r.prototype.getPostProcesses = function(t) {
+ return this._singleInstance ? this._postProcesses[0] : t ? this._postProcesses[t.name] : null;
+ }, r;
+ }(), xm = `#include
+
+varying vec2 vUV;
+uniform sampler2D textureSampler;
+uniform float threshold;
+uniform float exposure;
+void main(void)
+{
+gl_FragColor=texture2D(textureSampler,vUV);
+float luma=getLuminance(gl_FragColor.rgb*exposure);
+gl_FragColor.rgb=step(threshold,luma)*gl_FragColor.rgb;
+}`;
+ ze.a.ShadersStore.extractHighlightsPixelShader = xm;
+ var Sc = function(r) {
+ function t(e, n, i, o, a, s, d, p) {
+ d === void 0 && (d = h.a.TEXTURETYPE_UNSIGNED_INT), p === void 0 && (p = !1);
+ var y = r.call(this, e, "extractHighlights", ["threshold", "exposure"], null, n, i, o, a, s, null, d, void 0, null, p) || this;
+ return y.threshold = 0.9, y._exposure = 1, y._inputPostProcess = null, y.onApplyObservable.add(function(P) {
+ y._inputPostProcess && P.setTextureFromPostProcess("textureSampler", y._inputPostProcess), P.setFloat("threshold", Math.pow(y.threshold, Vt.b)), P.setFloat("exposure", y._exposure);
+ }), y;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "ExtractHighlightsPostProcess";
+ }, Object(c.c)([Object(L.c)()], t.prototype, "threshold", void 0), t;
+ }(ft);
+ O.a.RegisteredTypes["BABYLON.ExtractHighlightsPostProcess"] = Sc;
+ var Cm = `uniform sampler2D textureSampler;
+uniform sampler2D bloomBlur;
+varying vec2 vUV;
+uniform float bloomWeight;
+void main(void)
+{
+gl_FragColor=texture2D(textureSampler,vUV);
+vec3 blurred=texture2D(bloomBlur,vUV).rgb;
+gl_FragColor.rgb=gl_FragColor.rgb+(blurred.rgb*bloomWeight);
+}
+`;
+ ze.a.ShadersStore.bloomMergePixelShader = Cm;
+ var Ac = function(r) {
+ function t(e, n, i, o, a, s, d, p, y, P, R) {
+ P === void 0 && (P = h.a.TEXTURETYPE_UNSIGNED_INT), R === void 0 && (R = !1);
+ var B = r.call(this, e, "bloomMerge", ["bloomWeight"], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2", "bloomBlur"], a, s, d, p, y, null, P, void 0, null, !0) || this;
+ return B.weight = 1, B.weight = o, B.onApplyObservable.add(function(F) {
+ F.setTextureFromPostProcess("textureSampler", n), F.setTextureFromPostProcessOutput("bloomBlur", i), F.setFloat("bloomWeight", B.weight);
+ }), R || B.updateEffect(), B;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "BloomMergePostProcess";
+ }, Object(c.c)([Object(L.c)()], t.prototype, "weight", void 0), t;
+ }(ft);
+ O.a.RegisteredTypes["BABYLON.BloomMergePostProcess"] = Ac;
+ var Pc = function(r) {
+ function t(e, n, i, o, a, s) {
+ a === void 0 && (a = 0), s === void 0 && (s = !1);
+ var d = r.call(this, e.getEngine(), "bloom", function() {
+ return d._effects;
+ }, !0) || this;
+ return d.bloomScale = n, d._effects = [], d._downscale = new Sc("highlights", 1, null, Ne.a.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, a, s), d._blurX = new _n("horizontal blur", new u.d(1, 0), 10, n, null, Ne.a.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, a, void 0, s), d._blurX.alwaysForcePOT = !0, d._blurX.autoClear = !1, d._blurY = new _n("vertical blur", new u.d(0, 1), 10, n, null, Ne.a.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, a, void 0, s), d._blurY.alwaysForcePOT = !0, d._blurY.autoClear = !1, d.kernel = o, d._effects = [d._downscale, d._blurX, d._blurY], d._merge = new Ac("bloomMerge", d._downscale, d._blurY, i, n, null, Ne.a.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, a, s), d._merge.autoClear = !1, d._effects.push(d._merge), d;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "threshold", { get: function() {
+ return this._downscale.threshold;
+ }, set: function(e) {
+ this._downscale.threshold = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "weight", { get: function() {
+ return this._merge.weight;
+ }, set: function(e) {
+ this._merge.weight = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "kernel", { get: function() {
+ return this._blurX.kernel / this.bloomScale;
+ }, set: function(e) {
+ this._blurX.kernel = e * this.bloomScale, this._blurY.kernel = e * this.bloomScale;
+ }, enumerable: !1, configurable: !0 }), t.prototype.disposeEffects = function(e) {
+ for (var n = 0; n < this._effects.length; n++)
+ this._effects[n].dispose(e);
+ }, t.prototype._updateEffects = function() {
+ for (var e = 0; e < this._effects.length; e++)
+ this._effects[e].updateEffect();
+ }, t.prototype._isReady = function() {
+ for (var e = 0; e < this._effects.length; e++)
+ if (!this._effects[e].isReady())
+ return !1;
+ return !0;
+ }, t;
+ }(xt), Rm = `
+uniform sampler2D textureSampler;
+
+uniform float chromatic_aberration;
+uniform float radialIntensity;
+uniform vec2 direction;
+uniform vec2 centerPosition;
+uniform float screen_width;
+uniform float screen_height;
+
+varying vec2 vUV;
+void main(void)
+{
+vec2 centered_screen_pos=vec2(vUV.x-centerPosition.x,vUV.y-centerPosition.y);
+vec2 directionOfEffect=direction;
+if(directionOfEffect.x == 0. && directionOfEffect.y == 0.){
+directionOfEffect=normalize(centered_screen_pos);
+}
+float radius2=centered_screen_pos.x*centered_screen_pos.x
++centered_screen_pos.y*centered_screen_pos.y;
+float radius=sqrt(radius2);
+vec4 original=texture2D(textureSampler,vUV);
+
+vec3 ref_indices=vec3(-0.3,0.0,0.3);
+float ref_shiftX=chromatic_aberration*pow(radius,radialIntensity)*directionOfEffect.x/screen_width;
+float ref_shiftY=chromatic_aberration*pow(radius,radialIntensity)*directionOfEffect.y/screen_height;
+
+vec2 ref_coords_r=vec2(vUV.x+ref_indices.r*ref_shiftX,vUV.y+ref_indices.r*ref_shiftY*0.5);
+vec2 ref_coords_g=vec2(vUV.x+ref_indices.g*ref_shiftX,vUV.y+ref_indices.g*ref_shiftY*0.5);
+vec2 ref_coords_b=vec2(vUV.x+ref_indices.b*ref_shiftX,vUV.y+ref_indices.b*ref_shiftY*0.5);
+original.r=texture2D(textureSampler,ref_coords_r).r;
+original.g=texture2D(textureSampler,ref_coords_g).g;
+original.b=texture2D(textureSampler,ref_coords_b).b;
+original.a=clamp(texture2D(textureSampler,ref_coords_r).a+texture2D(textureSampler,ref_coords_g).a+texture2D(textureSampler,ref_coords_b).a,0.,1.);
+gl_FragColor=original;
+}`;
+ ze.a.ShadersStore.chromaticAberrationPixelShader = Rm;
+ var xc = function(r) {
+ function t(e, n, i, o, a, s, d, p, y, P) {
+ y === void 0 && (y = h.a.TEXTURETYPE_UNSIGNED_INT), P === void 0 && (P = !1);
+ var R = r.call(this, e, "chromaticAberration", ["chromatic_aberration", "screen_width", "screen_height", "direction", "radialIntensity", "centerPosition"], [], o, a, s, d, p, null, y, void 0, null, P) || this;
+ return R.aberrationAmount = 30, R.radialIntensity = 0, R.direction = new u.d(0.707, 0.707), R.centerPosition = new u.d(0.5, 0.5), R.screenWidth = n, R.screenHeight = i, R.onApplyObservable.add(function(B) {
+ B.setFloat("chromatic_aberration", R.aberrationAmount), B.setFloat("screen_width", n), B.setFloat("screen_height", i), B.setFloat("radialIntensity", R.radialIntensity), B.setFloat2("direction", R.direction.x, R.direction.y), B.setFloat2("centerPosition", R.centerPosition.x, R.centerPosition.y);
+ }), R;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "ChromaticAberrationPostProcess";
+ }, t._Parse = function(e, n, i, o) {
+ return L.a.Parse(function() {
+ return new t(e.name, e.screenWidth, e.screenHeight, e.options, n, e.renderTargetSamplingMode, i.getEngine(), e.reusable, e.textureType, !1);
+ }, e, i, o);
+ }, Object(c.c)([Object(L.c)()], t.prototype, "aberrationAmount", void 0), Object(c.c)([Object(L.c)()], t.prototype, "radialIntensity", void 0), Object(c.c)([Object(L.c)()], t.prototype, "direction", void 0), Object(c.c)([Object(L.c)()], t.prototype, "centerPosition", void 0), Object(c.c)([Object(L.c)()], t.prototype, "screenWidth", void 0), Object(c.c)([Object(L.c)()], t.prototype, "screenHeight", void 0), t;
+ }(ft);
+ O.a.RegisteredTypes["BABYLON.ChromaticAberrationPostProcess"] = xc;
+ var Om = `
+uniform sampler2D depthSampler;
+
+varying vec2 vUV;
+
+uniform vec2 cameraMinMaxZ;
+
+uniform float focusDistance;
+uniform float cocPrecalculation;
+void main(void)
+{
+float depth=texture2D(depthSampler,vUV).r;
+float pixelDistance=(cameraMinMaxZ.x+(cameraMinMaxZ.y-cameraMinMaxZ.x)*depth)*1000.0;
+float coc=abs(cocPrecalculation* ((focusDistance-pixelDistance)/pixelDistance));
+coc=clamp(coc,0.0,1.0);
+gl_FragColor=vec4(coc,depth,coc,1.0);
+}
+`;
+ ze.a.ShadersStore.circleOfConfusionPixelShader = Om;
+ var Cc = function(r) {
+ function t(e, n, i, o, a, s, d, p, y) {
+ p === void 0 && (p = h.a.TEXTURETYPE_UNSIGNED_INT), y === void 0 && (y = !1);
+ var P = r.call(this, e, "circleOfConfusion", ["cameraMinMaxZ", "focusDistance", "cocPrecalculation"], ["depthSampler"], i, o, a, s, d, null, p, void 0, null, y) || this;
+ return P.lensSize = 50, P.fStop = 1.4, P.focusDistance = 2e3, P.focalLength = 50, P._depthTexture = null, P._depthTexture = n, P.onApplyObservable.add(function(R) {
+ if (P._depthTexture) {
+ R.setTexture("depthSampler", P._depthTexture);
+ var B = P.lensSize / P.fStop * P.focalLength / (P.focusDistance - P.focalLength);
+ R.setFloat("focusDistance", P.focusDistance), R.setFloat("cocPrecalculation", B), R.setFloat2("cameraMinMaxZ", P._depthTexture.activeCamera.minZ, P._depthTexture.activeCamera.maxZ);
+ } else
+ l.a.Warn("No depth texture set on CircleOfConfusionPostProcess");
+ }), P;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "CircleOfConfusionPostProcess";
+ }, Object.defineProperty(t.prototype, "depthTexture", { set: function(e) {
+ this._depthTexture = e;
+ }, enumerable: !1, configurable: !0 }), Object(c.c)([Object(L.c)()], t.prototype, "lensSize", void 0), Object(c.c)([Object(L.c)()], t.prototype, "fStop", void 0), Object(c.c)([Object(L.c)()], t.prototype, "focusDistance", void 0), Object(c.c)([Object(L.c)()], t.prototype, "focalLength", void 0), t;
+ }(ft);
+ O.a.RegisteredTypes["BABYLON.CircleOfConfusionPostProcess"] = Cc;
+ var Mm = `
+uniform sampler2D textureSampler;
+uniform sampler2D colorTable;
+
+varying vec2 vUV;
+
+const float SLICE_COUNT=16.0;
+
+vec4 sampleAs3DTexture(sampler2D textureSampler,vec3 uv,float width) {
+float sliceSize=1.0/width;
+float slicePixelSize=sliceSize/width;
+float sliceInnerSize=slicePixelSize*(width-1.0);
+float zSlice0=min(floor(uv.z*width),width-1.0);
+float zSlice1=min(zSlice0+1.0,width-1.0);
+float xOffset=slicePixelSize*0.5+uv.x*sliceInnerSize;
+float s0=xOffset+(zSlice0*sliceSize);
+float s1=xOffset+(zSlice1*sliceSize);
+vec4 slice0Color=texture2D(textureSampler,vec2(s0,uv.y));
+vec4 slice1Color=texture2D(textureSampler,vec2(s1,uv.y));
+float zOffset=mod(uv.z*width,1.0);
+vec4 result=mix(slice0Color,slice1Color,zOffset);
+return result;
+}
+void main(void)
+{
+vec4 screen_color=texture2D(textureSampler,vUV);
+gl_FragColor=sampleAs3DTexture(colorTable,screen_color.rgb,SLICE_COUNT);
+}`;
+ ze.a.ShadersStore.colorCorrectionPixelShader = Mm;
+ var pd = function(r) {
+ function t(e, n, i, o, a, s, d) {
+ var p = r.call(this, e, "colorCorrection", null, ["colorTable"], i, o, a, s, d) || this;
+ return p._colorTableTexture = new Ne.a(n, o.getScene(), !0, !1, Ne.a.TRILINEAR_SAMPLINGMODE), p._colorTableTexture.anisotropicFilteringLevel = 1, p._colorTableTexture.wrapU = Ne.a.CLAMP_ADDRESSMODE, p._colorTableTexture.wrapV = Ne.a.CLAMP_ADDRESSMODE, p.colorTableUrl = n, p.onApply = function(y) {
+ y.setTexture("colorTable", p._colorTableTexture);
+ }, p;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "ColorCorrectionPostProcess";
+ }, t._Parse = function(e, n, i, o) {
+ return L.a.Parse(function() {
+ return new t(e.name, e.colorTableUrl, e.options, n, e.renderTargetSamplingMode, i.getEngine(), e.reusable);
+ }, e, i, o);
+ }, Object(c.c)([Object(L.c)()], t.prototype, "colorTableUrl", void 0), t;
+ }(ft);
+ O.a.RegisteredTypes["BABYLON.ColorCorrectionPostProcess"] = pd;
+ var Im = `
+varying vec2 vUV;
+uniform sampler2D textureSampler;
+uniform vec2 screenSize;
+uniform float kernel[9];
+void main(void)
+{
+vec2 onePixel=vec2(1.0,1.0)/screenSize;
+vec4 colorSum =
+texture2D(textureSampler,vUV+onePixel*vec2(-1,-1))*kernel[0] +
+texture2D(textureSampler,vUV+onePixel*vec2(0,-1))*kernel[1] +
+texture2D(textureSampler,vUV+onePixel*vec2(1,-1))*kernel[2] +
+texture2D(textureSampler,vUV+onePixel*vec2(-1,0))*kernel[3] +
+texture2D(textureSampler,vUV+onePixel*vec2(0,0))*kernel[4] +
+texture2D(textureSampler,vUV+onePixel*vec2(1,0))*kernel[5] +
+texture2D(textureSampler,vUV+onePixel*vec2(-1,1))*kernel[6] +
+texture2D(textureSampler,vUV+onePixel*vec2(0,1))*kernel[7] +
+texture2D(textureSampler,vUV+onePixel*vec2(1,1))*kernel[8];
+float kernelWeight =
+kernel[0] +
+kernel[1] +
+kernel[2] +
+kernel[3] +
+kernel[4] +
+kernel[5] +
+kernel[6] +
+kernel[7] +
+kernel[8];
+if (kernelWeight<=0.0) {
+kernelWeight=1.0;
+}
+gl_FragColor=vec4((colorSum/kernelWeight).rgb,1);
+}`;
+ ze.a.ShadersStore.convolutionPixelShader = Im;
+ var _d = function(r) {
+ function t(e, n, i, o, a, s, d, p) {
+ p === void 0 && (p = h.a.TEXTURETYPE_UNSIGNED_INT);
+ var y = r.call(this, e, "convolution", ["kernel", "screenSize"], null, i, o, a, s, d, null, p) || this;
+ return y.kernel = n, y.onApply = function(P) {
+ P.setFloat2("screenSize", y.width, y.height), P.setArray("kernel", y.kernel);
+ }, y;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "ConvolutionPostProcess";
+ }, t._Parse = function(e, n, i, o) {
+ return L.a.Parse(function() {
+ return new t(e.name, e.kernel, e.options, n, e.renderTargetSamplingMode, i.getEngine(), e.reusable, e.textureType);
+ }, e, i, o);
+ }, t.EdgeDetect0Kernel = [1, 0, -1, 0, 0, 0, -1, 0, 1], t.EdgeDetect1Kernel = [0, 1, 0, 1, -4, 1, 0, 1, 0], t.EdgeDetect2Kernel = [-1, -1, -1, -1, 8, -1, -1, -1, -1], t.SharpenKernel = [0, -1, 0, -1, 5, -1, 0, -1, 0], t.EmbossKernel = [-2, -1, 0, -1, 1, 1, 0, 1, 2], t.GaussianKernel = [0, 1, 0, 1, 1, 1, 0, 1, 0], Object(c.c)([Object(L.c)()], t.prototype, "kernel", void 0), t;
+ }(ft);
+ O.a.RegisteredTypes["BABYLON.ConvolutionPostProcess"] = _d;
+ var pa = function(r) {
+ function t(e, n, i, o, a, s, d, p, y, P, R, B, F) {
+ p === void 0 && (p = null), y === void 0 && (y = Ne.a.BILINEAR_SAMPLINGMODE), B === void 0 && (B = h.a.TEXTURETYPE_UNSIGNED_INT), F === void 0 && (F = !1);
+ var z = r.call(this, e, i, o, a, s, y = h.a.TEXTURE_BILINEAR_SAMPLINGMODE, P, R, B = h.a.TEXTURETYPE_UNSIGNED_INT, `#define DOF 1\r
+`, F) || this;
+ return z.direction = i, z.onApplyObservable.add(function(J) {
+ p != null && J.setTextureFromPostProcess("textureSampler", p), J.setTextureFromPostProcessOutput("circleOfConfusionSampler", d), n.activeCamera && J.setFloat2("cameraMinMaxZ", n.activeCamera.minZ, n.activeCamera.maxZ);
+ }), z;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "DepthOfFieldBlurPostProcess";
+ }, Object(c.c)([Object(L.c)()], t.prototype, "direction", void 0), t;
+ }(_n);
+ O.a.RegisteredTypes["BABYLON.DepthOfFieldBlurPostProcess"] = pa;
+ var Dm = `uniform sampler2D textureSampler;
+varying vec2 vUV;
+uniform sampler2D circleOfConfusionSampler;
+uniform sampler2D blurStep0;
+#if BLUR_LEVEL>0
+uniform sampler2D blurStep1;
+#endif
+#if BLUR_LEVEL>1
+uniform sampler2D blurStep2;
+#endif
+void main(void)
+{
+float coc=texture2D(circleOfConfusionSampler,vUV).r;
+#if BLUR_LEVEL == 0
+vec4 original=texture2D(textureSampler,vUV);
+vec4 blurred0=texture2D(blurStep0,vUV);
+gl_FragColor=mix(original,blurred0,coc);
+#endif
+#if BLUR_LEVEL == 1
+if(coc<0.5){
+vec4 original=texture2D(textureSampler,vUV);
+vec4 blurred1=texture2D(blurStep1,vUV);
+gl_FragColor=mix(original,blurred1,coc/0.5);
+}else{
+vec4 blurred0=texture2D(blurStep0,vUV);
+vec4 blurred1=texture2D(blurStep1,vUV);
+gl_FragColor=mix(blurred1,blurred0,(coc-0.5)/0.5);
+}
+#endif
+#if BLUR_LEVEL == 2
+if(coc<0.33){
+vec4 original=texture2D(textureSampler,vUV);
+vec4 blurred2=texture2D(blurStep2,vUV);
+gl_FragColor=mix(original,blurred2,coc/0.33);
+}else if(coc<0.66){
+vec4 blurred1=texture2D(blurStep1,vUV);
+vec4 blurred2=texture2D(blurStep2,vUV);
+gl_FragColor=mix(blurred2,blurred1,(coc-0.33)/0.33);
+}else{
+vec4 blurred0=texture2D(blurStep0,vUV);
+vec4 blurred1=texture2D(blurStep1,vUV);
+gl_FragColor=mix(blurred1,blurred0,(coc-0.66)/0.34);
+}
+#endif
+}
+`;
+ ze.a.ShadersStore.depthOfFieldMergePixelShader = Dm;
+ var Ji, Lm = function() {
+ }, md = function(r) {
+ function t(e, n, i, o, a, s, d, p, y, P, R) {
+ P === void 0 && (P = h.a.TEXTURETYPE_UNSIGNED_INT), R === void 0 && (R = !1);
+ var B = r.call(this, e, "depthOfFieldMerge", [], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2"], a, s, d, p, y, null, P, void 0, null, !0) || this;
+ return B.blurSteps = o, B.onApplyObservable.add(function(F) {
+ F.setTextureFromPostProcess("textureSampler", n), F.setTextureFromPostProcessOutput("circleOfConfusionSampler", i), o.forEach(function(z, J) {
+ F.setTextureFromPostProcessOutput("blurStep" + (o.length - J - 1), z);
+ });
+ }), R || B.updateEffect(), B;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "DepthOfFieldMergePostProcess";
+ }, t.prototype.updateEffect = function(e, n, i, o, a, s) {
+ e === void 0 && (e = null), n === void 0 && (n = null), i === void 0 && (i = null), e || (e = "", e += "#define BLUR_LEVEL " + (this.blurSteps.length - 1) + `
+`), r.prototype.updateEffect.call(this, e, n, i, o, a, s);
+ }, t;
+ }(ft);
+ (function(r) {
+ r[r.Low = 0] = "Low", r[r.Medium = 1] = "Medium", r[r.High = 2] = "High";
+ })(Ji || (Ji = {}));
+ var Rc = function(r) {
+ function t(e, n, i, o, a) {
+ i === void 0 && (i = Ji.Low), o === void 0 && (o = 0), a === void 0 && (a = !1);
+ var s = r.call(this, e.getEngine(), "depth of field", function() {
+ return s._effects;
+ }, !0) || this;
+ s._effects = [], s._circleOfConfusion = new Cc("circleOfConfusion", n, 1, null, Ne.a.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, o, a), s._depthOfFieldBlurY = [], s._depthOfFieldBlurX = [];
+ var d = 1, p = 15;
+ switch (i) {
+ case Ji.High:
+ d = 3, p = 51;
+ break;
+ case Ji.Medium:
+ d = 2, p = 31;
+ break;
+ default:
+ p = 15, d = 1;
+ }
+ for (var y = p / Math.pow(2, d - 1), P = 1, R = 0; R < d; R++) {
+ var B = new pa("verticle blur", e, new u.d(0, 1), y, P, null, s._circleOfConfusion, R == 0 ? s._circleOfConfusion : null, Ne.a.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, o, a);
+ B.autoClear = !1, P = 0.75 / Math.pow(2, R);
+ var F = new pa("horizontal blur", e, new u.d(1, 0), y, P, null, s._circleOfConfusion, null, Ne.a.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, o, a);
+ F.autoClear = !1, s._depthOfFieldBlurY.push(B), s._depthOfFieldBlurX.push(F);
+ }
+ for (s._effects = [s._circleOfConfusion], R = 0; R < s._depthOfFieldBlurX.length; R++)
+ s._effects.push(s._depthOfFieldBlurY[R]), s._effects.push(s._depthOfFieldBlurX[R]);
+ return s._dofMerge = new md("dofMerge", s._circleOfConfusion, s._circleOfConfusion, s._depthOfFieldBlurX, P, null, Ne.a.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, o, a), s._dofMerge.autoClear = !1, s._effects.push(s._dofMerge), s;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "focalLength", { get: function() {
+ return this._circleOfConfusion.focalLength;
+ }, set: function(e) {
+ this._circleOfConfusion.focalLength = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "fStop", { get: function() {
+ return this._circleOfConfusion.fStop;
+ }, set: function(e) {
+ this._circleOfConfusion.fStop = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "focusDistance", { get: function() {
+ return this._circleOfConfusion.focusDistance;
+ }, set: function(e) {
+ this._circleOfConfusion.focusDistance = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "lensSize", { get: function() {
+ return this._circleOfConfusion.lensSize;
+ }, set: function(e) {
+ this._circleOfConfusion.lensSize = e;
+ }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
+ return "DepthOfFieldEffect";
+ }, Object.defineProperty(t.prototype, "depthTexture", { set: function(e) {
+ this._circleOfConfusion.depthTexture = e;
+ }, enumerable: !1, configurable: !0 }), t.prototype.disposeEffects = function(e) {
+ for (var n = 0; n < this._effects.length; n++)
+ this._effects[n].dispose(e);
+ }, t.prototype._updateEffects = function() {
+ for (var e = 0; e < this._effects.length; e++)
+ this._effects[e].updateEffect();
+ }, t.prototype._isReady = function() {
+ for (var e = 0; e < this._effects.length; e++)
+ if (!this._effects[e].isReady())
+ return !1;
+ return !0;
+ }, t;
+ }(xt), Nm = `
+varying vec2 vUV;
+uniform sampler2D textureSampler;
+uniform sampler2D passSampler;
+void main(void)
+{
+gl_FragColor=texture2D(passSampler,vUV);
+}`;
+ ze.a.ShadersStore.displayPassPixelShader = Nm;
+ var gd = function(r) {
+ function t(e, n, i, o, a, s) {
+ return r.call(this, e, "displayPass", ["passSampler"], ["passSampler"], n, i, o, a, s) || this;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "DisplayPassPostProcess";
+ }, t._Parse = function(e, n, i, o) {
+ return L.a.Parse(function() {
+ return new t(e.name, e.options, n, e.renderTargetSamplingMode, i.getEngine(), e.reusable);
+ }, e, i, o);
+ }, t;
+ }(ft);
+ O.a.RegisteredTypes["BABYLON.DisplayPassPostProcess"] = gd;
+ var wm = `
+varying vec2 vUV;
+uniform sampler2D textureSampler;
+uniform mat4 kernelMatrix;
+void main(void)
+{
+vec3 baseColor=texture2D(textureSampler,vUV).rgb;
+vec3 updatedColor=(kernelMatrix*vec4(baseColor,1.0)).rgb;
+gl_FragColor=vec4(updatedColor,1.0);
+}`;
+ ze.a.ShadersStore.filterPixelShader = wm;
+ var vd = function(r) {
+ function t(e, n, i, o, a, s, d) {
+ var p = r.call(this, e, "filter", ["kernelMatrix"], null, i, o, a, s, d) || this;
+ return p.kernelMatrix = n, p.onApply = function(y) {
+ y.setMatrix("kernelMatrix", p.kernelMatrix);
+ }, p;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "FilterPostProcess";
+ }, t._Parse = function(e, n, i, o) {
+ return L.a.Parse(function() {
+ return new t(e.name, e.kernelMatrix, e.options, n, e.renderTargetSamplingMode, i.getEngine(), e.reusable);
+ }, e, i, o);
+ }, Object(c.c)([Object(L.j)()], t.prototype, "kernelMatrix", void 0), t;
+ }(ft);
+ O.a.RegisteredTypes["BABYLON.FilterPostProcess"] = vd;
+ var Fm = `uniform sampler2D textureSampler;
+uniform vec2 texelSize;
+varying vec2 vUV;
+varying vec2 sampleCoordS;
+varying vec2 sampleCoordE;
+varying vec2 sampleCoordN;
+varying vec2 sampleCoordW;
+varying vec2 sampleCoordNW;
+varying vec2 sampleCoordSE;
+varying vec2 sampleCoordNE;
+varying vec2 sampleCoordSW;
+const float fxaaQualitySubpix=1.0;
+const float fxaaQualityEdgeThreshold=0.166;
+const float fxaaQualityEdgeThresholdMin=0.0833;
+const vec3 kLumaCoefficients=vec3(0.2126,0.7152,0.0722);
+#define FxaaLuma(rgba) dot(rgba.rgb,kLumaCoefficients)
+void main(){
+vec2 posM;
+posM.x=vUV.x;
+posM.y=vUV.y;
+vec4 rgbyM=texture2D(textureSampler,vUV,0.0);
+float lumaM=FxaaLuma(rgbyM);
+float lumaS=FxaaLuma(texture2D(textureSampler,sampleCoordS,0.0));
+float lumaE=FxaaLuma(texture2D(textureSampler,sampleCoordE,0.0));
+float lumaN=FxaaLuma(texture2D(textureSampler,sampleCoordN,0.0));
+float lumaW=FxaaLuma(texture2D(textureSampler,sampleCoordW,0.0));
+float maxSM=max(lumaS,lumaM);
+float minSM=min(lumaS,lumaM);
+float maxESM=max(lumaE,maxSM);
+float minESM=min(lumaE,minSM);
+float maxWN=max(lumaN,lumaW);
+float minWN=min(lumaN,lumaW);
+float rangeMax=max(maxWN,maxESM);
+float rangeMin=min(minWN,minESM);
+float rangeMaxScaled=rangeMax*fxaaQualityEdgeThreshold;
+float range=rangeMax-rangeMin;
+float rangeMaxClamped=max(fxaaQualityEdgeThresholdMin,rangeMaxScaled);
+#ifndef MALI
+if(range=edgeVert;
+float subpixA=subpixNSWE*2.0+subpixNWSWNESE;
+if (!horzSpan)
+{
+lumaN=lumaW;
+}
+if (!horzSpan)
+{
+lumaS=lumaE;
+}
+if (horzSpan)
+{
+lengthSign=texelSize.y;
+}
+float subpixB=(subpixA*(1.0/12.0))-lumaM;
+float gradientN=lumaN-lumaM;
+float gradientS=lumaS-lumaM;
+float lumaNN=lumaN+lumaM;
+float lumaSS=lumaS+lumaM;
+bool pairN=abs(gradientN)>=abs(gradientS);
+float gradient=max(abs(gradientN),abs(gradientS));
+if (pairN)
+{
+lengthSign=-lengthSign;
+}
+float subpixC=clamp(abs(subpixB)*subpixRcpRange,0.0,1.0);
+vec2 posB;
+posB.x=posM.x;
+posB.y=posM.y;
+vec2 offNP;
+offNP.x=(!horzSpan) ? 0.0 : texelSize.x;
+offNP.y=(horzSpan) ? 0.0 : texelSize.y;
+if (!horzSpan)
+{
+posB.x+=lengthSign*0.5;
+}
+if (horzSpan)
+{
+posB.y+=lengthSign*0.5;
+}
+vec2 posN;
+posN.x=posB.x-offNP.x*1.5;
+posN.y=posB.y-offNP.y*1.5;
+vec2 posP;
+posP.x=posB.x+offNP.x*1.5;
+posP.y=posB.y+offNP.y*1.5;
+float subpixD=((-2.0)*subpixC)+3.0;
+float lumaEndN=FxaaLuma(texture2D(textureSampler,posN,0.0));
+float subpixE=subpixC*subpixC;
+float lumaEndP=FxaaLuma(texture2D(textureSampler,posP,0.0));
+if (!pairN)
+{
+lumaNN=lumaSS;
+}
+float gradientScaled=gradient*1.0/4.0;
+float lumaMM=lumaM-lumaNN*0.5;
+float subpixF=subpixD*subpixE;
+bool lumaMLTZero=lumaMM<0.0;
+lumaEndN-=lumaNN*0.5;
+lumaEndP-=lumaNN*0.5;
+bool doneN=abs(lumaEndN)>=gradientScaled;
+bool doneP=abs(lumaEndP)>=gradientScaled;
+if (!doneN)
+{
+posN.x-=offNP.x*3.0;
+}
+if (!doneN)
+{
+posN.y-=offNP.y*3.0;
+}
+bool doneNP=(!doneN) || (!doneP);
+if (!doneP)
+{
+posP.x+=offNP.x*3.0;
+}
+if (!doneP)
+{
+posP.y+=offNP.y*3.0;
+}
+if (doneNP)
+{
+if (!doneN) lumaEndN=FxaaLuma(texture2D(textureSampler,posN.xy,0.0));
+if (!doneP) lumaEndP=FxaaLuma(texture2D(textureSampler,posP.xy,0.0));
+if (!doneN) lumaEndN=lumaEndN-lumaNN*0.5;
+if (!doneP) lumaEndP=lumaEndP-lumaNN*0.5;
+doneN=abs(lumaEndN)>=gradientScaled;
+doneP=abs(lumaEndP)>=gradientScaled;
+if (!doneN) posN.x-=offNP.x*12.0;
+if (!doneN) posN.y-=offNP.y*12.0;
+doneNP=(!doneN) || (!doneP);
+if (!doneP) posP.x+=offNP.x*12.0;
+if (!doneP) posP.y+=offNP.y*12.0;
+}
+float dstN=posM.x-posN.x;
+float dstP=posP.x-posM.x;
+if (!horzSpan)
+{
+dstN=posM.y-posN.y;
+}
+if (!horzSpan)
+{
+dstP=posP.y-posM.y;
+}
+bool goodSpanN=(lumaEndN<0.0) != lumaMLTZero;
+float spanLength=(dstP+dstN);
+bool goodSpanP=(lumaEndP<0.0) != lumaMLTZero;
+float spanLengthRcp=1.0/spanLength;
+bool directionN=dstN -1 ? `#define MALI 1
+` : null;
+ }, t._Parse = function(e, n, i, o) {
+ return L.a.Parse(function() {
+ return new t(e.name, e.options, n, e.renderTargetSamplingMode, i.getEngine(), e.reusable);
+ }, e, i, o);
+ }, t;
+ }(ft);
+ O.a.RegisteredTypes["BABYLON.FxaaPostProcess"] = vo;
+ var Um = `#include
+
+uniform sampler2D textureSampler;
+
+uniform float intensity;
+uniform float animatedSeed;
+
+varying vec2 vUV;
+void main(void)
+{
+gl_FragColor=texture2D(textureSampler,vUV);
+vec2 seed=vUV*(animatedSeed);
+float grain=dither(seed,intensity);
+
+float lum=getLuminance(gl_FragColor.rgb);
+float grainAmount=(cos(-PI+(lum*PI*2.))+1.)/2.;
+gl_FragColor.rgb+=grain*grainAmount;
+gl_FragColor.rgb=max(gl_FragColor.rgb,0.0);
+}`;
+ ze.a.ShadersStore.grainPixelShader = Um;
+ var Oc = function(r) {
+ function t(e, n, i, o, a, s, d, p) {
+ d === void 0 && (d = h.a.TEXTURETYPE_UNSIGNED_INT), p === void 0 && (p = !1);
+ var y = r.call(this, e, "grain", ["intensity", "animatedSeed"], [], n, i, o, a, s, null, d, void 0, null, p) || this;
+ return y.intensity = 30, y.animated = !1, y.onApplyObservable.add(function(P) {
+ P.setFloat("intensity", y.intensity), P.setFloat("animatedSeed", y.animated ? Math.random() + 1 : 1);
+ }), y;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "GrainPostProcess";
+ }, t._Parse = function(e, n, i, o) {
+ return L.a.Parse(function() {
+ return new t(e.name, e.options, n, e.renderTargetSamplingMode, i.getEngine(), e.reusable);
+ }, e, i, o);
+ }, Object(c.c)([Object(L.c)()], t.prototype, "intensity", void 0), Object(c.c)([Object(L.c)()], t.prototype, "animated", void 0), t;
+ }(ft);
+ O.a.RegisteredTypes["BABYLON.GrainPostProcess"] = Oc;
+ var Vm = `
+varying vec2 vUV;
+uniform sampler2D textureSampler;
+const vec3 RGBLuminanceCoefficients=vec3(0.2126,0.7152,0.0722);
+void main(void)
+{
+vec4 tex=texture2D(textureSampler,vUV);
+vec3 c=tex.rgb;
+float luma=dot(c.rgb,RGBLuminanceCoefficients);
+
+
+gl_FragColor=vec4(pow(c,vec3(25.0-luma*15.0)),tex.a);
+}`;
+ ze.a.ShadersStore.highlightsPixelShader = Vm;
+ var km = function(r) {
+ function t(e, n, i, o, a, s, d) {
+ return d === void 0 && (d = h.a.TEXTURETYPE_UNSIGNED_INT), r.call(this, e, "highlights", null, null, n, i, o, a, s, null, d) || this;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "HighlightsPostProcess";
+ }, t;
+ }(ft);
+ ze.a.IncludesShadersStore.mrtFragmentDeclaration = `#if __VERSION__>=200
+layout(location=0) out vec4 glFragData[{X}];
+#endif
+`;
+ var Gm = `#extension GL_EXT_draw_buffers : require
+#if defined(BUMP) || !defined(NORMAL)
+#extension GL_OES_standard_derivatives : enable
+#endif
+precision highp float;
+precision highp int;
+#ifdef BUMP
+varying mat4 vWorldView;
+varying vec3 vNormalW;
+#else
+varying vec3 vNormalV;
+#endif
+varying vec4 vViewPos;
+#if defined(POSITION) || defined(BUMP)
+varying vec3 vPositionW;
+#endif
+#ifdef VELOCITY
+varying vec4 vCurrentPosition;
+varying vec4 vPreviousPosition;
+#endif
+#ifdef NEED_UV
+varying vec2 vUV;
+#endif
+#ifdef BUMP
+uniform vec3 vBumpInfos;
+uniform vec2 vTangentSpaceParams;
+#endif
+#ifdef REFLECTIVITY
+varying vec2 vReflectivityUV;
+uniform sampler2D reflectivitySampler;
+#endif
+#ifdef ALPHATEST
+uniform sampler2D diffuseSampler;
+#endif
+#include[RENDER_TARGET_COUNT]
+#include
+#include
+void main() {
+#ifdef ALPHATEST
+if (texture2D(diffuseSampler,vUV).a<0.4)
+discard;
+#endif
+vec3 normalOutput;
+#ifdef BUMP
+vec3 normalW=normalize(vNormalW);
+#include
+normalOutput=normalize(vec3(vWorldView*vec4(normalW,0.0)));
+#else
+normalOutput=normalize(vNormalV);
+#endif
+#ifdef PREPASS
+#ifdef PREPASS_DEPTHNORMAL
+gl_FragData[DEPTHNORMAL_INDEX]=vec4(vViewPos.z/vViewPos.w,normalOutput);
+#endif
+#else
+gl_FragData[0]=vec4(vViewPos.z/vViewPos.w,0.0,0.0,1.0);
+gl_FragData[1]=vec4(normalOutput,1.0);
+#endif
+#ifdef POSITION
+gl_FragData[POSITION_INDEX]=vec4(vPositionW,1.0);
+#endif
+#ifdef VELOCITY
+vec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;
+vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;
+vec2 velocity=abs(a-b);
+velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;
+gl_FragData[VELOCITY_INDEX]=vec4(velocity,0.0,1.0);
+#endif
+#ifdef REFLECTIVITY
+#ifdef HAS_SPECULAR
+
+vec4 reflectivity=texture2D(reflectivitySampler,vReflectivityUV);
+#elif HAS_REFLECTIVITY
+
+vec4 reflectivity=vec4(texture2D(reflectivitySampler,vReflectivityUV).rgb,1.0);
+#else
+vec4 reflectivity=vec4(0.0,0.0,0.0,1.0);
+#endif
+gl_FragData[REFLECTIVITY_INDEX]=reflectivity;
+#endif
+}`;
+ ze.a.ShadersStore.geometryPixelShader = Gm;
+ var zm = `precision highp float;
+precision highp int;
+#include
+#include
+#include[0..maxSimultaneousMorphTargets]
+#include
+attribute vec3 position;
+attribute vec3 normal;
+#ifdef NEED_UV
+varying vec2 vUV;
+#ifdef ALPHATEST
+uniform mat4 diffuseMatrix;
+#endif
+#ifdef BUMP
+uniform mat4 bumpMatrix;
+varying vec2 vBumpUV;
+#endif
+#ifdef REFLECTIVITY
+uniform mat4 reflectivityMatrix;
+varying vec2 vReflectivityUV;
+#endif
+#ifdef UV1
+attribute vec2 uv;
+#endif
+#ifdef UV2
+attribute vec2 uv2;
+#endif
+#endif
+
+uniform mat4 viewProjection;
+uniform mat4 view;
+#ifdef BUMP
+varying mat4 vWorldView;
+#endif
+#ifdef BUMP
+varying vec3 vNormalW;
+#else
+varying vec3 vNormalV;
+#endif
+varying vec4 vViewPos;
+#if defined(POSITION) || defined(BUMP)
+varying vec3 vPositionW;
+#endif
+#ifdef VELOCITY
+uniform mat4 previousWorld;
+uniform mat4 previousViewProjection;
+#ifdef BONES_VELOCITY_ENABLED
+#if NUM_BONE_INFLUENCERS>0
+uniform mat4 mPreviousBones[BonesPerMesh];
+#endif
+#endif
+varying vec4 vCurrentPosition;
+varying vec4 vPreviousPosition;
+#endif
+void main(void)
+{
+vec3 positionUpdated=position;
+vec3 normalUpdated=normal;
+#ifdef UV1
+vec2 uvUpdated=uv;
+#endif
+#include[0..maxSimultaneousMorphTargets]
+#include
+#if defined(VELOCITY) && !defined(BONES_VELOCITY_ENABLED)
+
+vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);
+vPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0);
+#endif
+#include
+vec4 pos=vec4(finalWorld*vec4(positionUpdated,1.0));
+#ifdef BUMP
+vWorldView=view*finalWorld;
+vNormalW=normalUpdated;
+#else
+vNormalV=normalize(vec3((view*finalWorld)*vec4(normalUpdated,0.0)));
+#endif
+vViewPos=view*pos;
+#if defined(VELOCITY) && defined(BONES_VELOCITY_ENABLED)
+vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);
+#if NUM_BONE_INFLUENCERS>0
+mat4 previousInfluence;
+previousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0];
+#if NUM_BONE_INFLUENCERS>1
+previousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1];
+#endif
+#if NUM_BONE_INFLUENCERS>2
+previousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2];
+#endif
+#if NUM_BONE_INFLUENCERS>3
+previousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3];
+#endif
+#if NUM_BONE_INFLUENCERS>4
+previousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];
+#endif
+#if NUM_BONE_INFLUENCERS>5
+previousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];
+#endif
+#if NUM_BONE_INFLUENCERS>6
+previousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];
+#endif
+#if NUM_BONE_INFLUENCERS>7
+previousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];
+#endif
+vPreviousPosition=previousViewProjection*previousWorld*previousInfluence*vec4(positionUpdated,1.0);
+#else
+vPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0);
+#endif
+#endif
+#if defined(POSITION) || defined(BUMP)
+vPositionW=pos.xyz/pos.w;
+#endif
+gl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);
+#ifdef NEED_UV
+#ifdef UV1
+#ifdef ALPHATEST
+vUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));
+#else
+vUV=uv;
+#endif
+#ifdef BUMP
+vBumpUV=vec2(bumpMatrix*vec4(uvUpdated,1.0,0.0));
+#endif
+#ifdef REFLECTIVITY
+vReflectivityUV=vec2(reflectivityMatrix*vec4(uvUpdated,1.0,0.0));
+#endif
+#endif
+#ifdef UV2
+#ifdef ALPHATEST
+vUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
+#else
+vUV=uv2;
+#endif
+#ifdef BUMP
+vBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));
+#endif
+#ifdef REFLECTIVITY
+vReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));
+#endif
+#endif
+#endif
+#include
+}
+`;
+ ze.a.ShadersStore.geometryVertexShader = zm;
+ var ri = function() {
+ function r(t, e) {
+ e === void 0 && (e = 1), this._previousTransformationMatrices = {}, this._previousBonesTransformationMatrices = {}, this.excludedSkinnedMeshesFromVelocity = [], this.renderTransparentMeshes = !0, this._resizeObserver = null, this._enablePosition = !1, this._enableVelocity = !1, this._enableReflectivity = !1, this._positionIndex = -1, this._velocityIndex = -1, this._reflectivityIndex = -1, this._depthNormalIndex = -1, this._linkedWithPrePass = !1, this._scene = t, this._ratio = e, r._SceneComponentInitialization(this._scene), this._createRenderTargets();
+ }
+ return r.prototype._linkPrePassRenderer = function(t) {
+ this._linkedWithPrePass = !0, this._prePassRenderer = t, this._multiRenderTarget && (this._multiRenderTarget.onClearObservable.clear(), this._multiRenderTarget.onClearObservable.add(function(e) {
+ }));
+ }, r.prototype._unlinkPrePassRenderer = function() {
+ this._linkedWithPrePass = !1, this._createRenderTargets();
+ }, r.prototype._resetLayout = function() {
+ this._enablePosition = !1, this._enableReflectivity = !1, this._enableVelocity = !1, this._attachments = [];
+ }, r.prototype._forceTextureType = function(t, e) {
+ t === r.POSITION_TEXTURE_TYPE ? (this._positionIndex = e, this._enablePosition = !0) : t === r.VELOCITY_TEXTURE_TYPE ? (this._velocityIndex = e, this._enableVelocity = !0) : t === r.REFLECTIVITY_TEXTURE_TYPE ? (this._reflectivityIndex = e, this._enableReflectivity = !0) : t === r.DEPTHNORMAL_TEXTURE_TYPE && (this._depthNormalIndex = e);
+ }, r.prototype._setAttachments = function(t) {
+ this._attachments = t;
+ }, r.prototype._linkInternalTexture = function(t) {
+ this._multiRenderTarget._texture = t;
+ }, Object.defineProperty(r.prototype, "renderList", { get: function() {
+ return this._multiRenderTarget.renderList;
+ }, set: function(t) {
+ this._multiRenderTarget.renderList = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "isSupported", { get: function() {
+ return this._multiRenderTarget.isSupported;
+ }, enumerable: !1, configurable: !0 }), r.prototype.getTextureIndex = function(t) {
+ switch (t) {
+ case r.POSITION_TEXTURE_TYPE:
+ return this._positionIndex;
+ case r.VELOCITY_TEXTURE_TYPE:
+ return this._velocityIndex;
+ case r.REFLECTIVITY_TEXTURE_TYPE:
+ return this._reflectivityIndex;
+ default:
+ return -1;
+ }
+ }, Object.defineProperty(r.prototype, "enablePosition", { get: function() {
+ return this._enablePosition;
+ }, set: function(t) {
+ this._enablePosition = t, this._linkedWithPrePass || (this.dispose(), this._createRenderTargets());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "enableVelocity", { get: function() {
+ return this._enableVelocity;
+ }, set: function(t) {
+ this._enableVelocity = t, t || (this._previousTransformationMatrices = {}), this._linkedWithPrePass || (this.dispose(), this._createRenderTargets());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "enableReflectivity", { get: function() {
+ return this._enableReflectivity;
+ }, set: function(t) {
+ this._enableReflectivity = t, this._linkedWithPrePass || (this.dispose(), this._createRenderTargets());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "scene", { get: function() {
+ return this._scene;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "ratio", { get: function() {
+ return this._ratio;
+ }, enumerable: !1, configurable: !0 }), r.prototype.isReady = function(t, e) {
+ var n = t.getMaterial();
+ if (n && n.disableDepthWrite)
+ return !1;
+ var i = [], o = [Oe.b.PositionKind, Oe.b.NormalKind], a = t.getMesh();
+ if (n) {
+ var s = !1;
+ n.needAlphaTesting() && (i.push("#define ALPHATEST"), s = !0), n.bumpTexture && Nt.a.BumpTextureEnabled && (i.push("#define BUMP"), i.push("#define BUMPDIRECTUV 0"), s = !0), this._enableReflectivity && (n instanceof Nt.a && n.specularTexture ? (i.push("#define HAS_SPECULAR"), s = !0) : n instanceof $r && n.reflectivityTexture && (i.push("#define HAS_REFLECTIVITY"), s = !0)), s && (i.push("#define NEED_UV"), a.isVerticesDataPresent(Oe.b.UVKind) && (o.push(Oe.b.UVKind), i.push("#define UV1")), a.isVerticesDataPresent(Oe.b.UV2Kind) && (o.push(Oe.b.UV2Kind), i.push("#define UV2")));
+ }
+ this._linkedWithPrePass && (i.push("#define PREPASS"), this._depthNormalIndex !== -1 && (i.push("#define DEPTHNORMAL_INDEX " + this._depthNormalIndex), i.push("#define PREPASS_DEPTHNORMAL"))), this._enablePosition && (i.push("#define POSITION"), i.push("#define POSITION_INDEX " + this._positionIndex)), this._enableVelocity && (i.push("#define VELOCITY"), i.push("#define VELOCITY_INDEX " + this._velocityIndex), this.excludedSkinnedMeshesFromVelocity.indexOf(a) === -1 && i.push("#define BONES_VELOCITY_ENABLED")), this._enableReflectivity && (i.push("#define REFLECTIVITY"), i.push("#define REFLECTIVITY_INDEX " + this._reflectivityIndex)), a.useBones && a.computeBonesUsingShaders ? (o.push(Oe.b.MatricesIndicesKind), o.push(Oe.b.MatricesWeightsKind), a.numBoneInfluencers > 4 && (o.push(Oe.b.MatricesIndicesExtraKind), o.push(Oe.b.MatricesWeightsExtraKind)), i.push("#define NUM_BONE_INFLUENCERS " + a.numBoneInfluencers), i.push("#define BonesPerMesh " + (a.skeleton ? a.skeleton.bones.length + 1 : 0))) : i.push("#define NUM_BONE_INFLUENCERS 0");
+ var d = a.morphTargetManager, p = 0;
+ d && d.numInfluencers > 0 && (p = d.numInfluencers, i.push("#define MORPHTARGETS"), i.push("#define NUM_MORPH_INFLUENCERS " + p), $e.a.PrepareAttributesForMorphTargetsInfluencers(o, a, p)), e && (i.push("#define INSTANCES"), $e.a.PushAttributesForInstances(o), t.getRenderingMesh().hasThinInstances && i.push("#define THIN_INSTANCES")), this._linkedWithPrePass ? i.push("#define RENDER_TARGET_COUNT " + this._attachments.length) : i.push("#define RENDER_TARGET_COUNT " + this._multiRenderTarget.textures.length);
+ var y = i.join(`
+`);
+ return this._cachedDefines !== y && (this._cachedDefines = y, this._effect = this._scene.getEngine().createEffect("geometry", o, ["world", "mBones", "viewProjection", "diffuseMatrix", "view", "previousWorld", "previousViewProjection", "mPreviousBones", "morphTargetInfluences", "bumpMatrix", "reflectivityMatrix", "vTangentSpaceParams", "vBumpInfos"], ["diffuseSampler", "bumpSampler", "reflectivitySampler"], y, void 0, void 0, void 0, { buffersCount: this._multiRenderTarget.textures.length - 1, maxSimultaneousMorphTargets: p })), this._effect.isReady();
+ }, r.prototype.getGBuffer = function() {
+ return this._multiRenderTarget;
+ }, Object.defineProperty(r.prototype, "samples", { get: function() {
+ return this._multiRenderTarget.samples;
+ }, set: function(t) {
+ this._multiRenderTarget.samples = t;
+ }, enumerable: !1, configurable: !0 }), r.prototype.dispose = function() {
+ this._resizeObserver && (this._scene.getEngine().onResizeObservable.remove(this._resizeObserver), this._resizeObserver = null), this.getGBuffer().dispose();
+ }, r.prototype._assignRenderTargetIndices = function() {
+ var t = 2;
+ return this._enablePosition && (this._positionIndex = t, t++), this._enableVelocity && (this._velocityIndex = t, t++), this._enableReflectivity && (this._reflectivityIndex = t, t++), t;
+ }, r.prototype._createRenderTargets = function() {
+ var t = this, e = this._scene.getEngine(), n = this._assignRenderTargetIndices();
+ if (this._multiRenderTarget = new Vs("gBuffer", { width: e.getRenderWidth() * this._ratio, height: e.getRenderHeight() * this._ratio }, n, this._scene, { generateMipMaps: !1, generateDepthTexture: !0, defaultType: h.a.TEXTURETYPE_FLOAT }), this.isSupported) {
+ this._multiRenderTarget.wrapU = Ne.a.CLAMP_ADDRESSMODE, this._multiRenderTarget.wrapV = Ne.a.CLAMP_ADDRESSMODE, this._multiRenderTarget.refreshRate = 1, this._multiRenderTarget.renderParticles = !1, this._multiRenderTarget.renderList = null, this._multiRenderTarget.onClearObservable.add(function(o) {
+ o.clear(new I.b(0, 0, 0, 1), !0, !0, !0);
+ }), this._resizeObserver = e.onResizeObservable.add(function() {
+ t._multiRenderTarget && t._multiRenderTarget.resize({ width: e.getRenderWidth() * t._ratio, height: e.getRenderHeight() * t._ratio });
+ });
+ var i = function(o) {
+ var a = o.getRenderingMesh(), s = o.getEffectiveMesh(), d = t._scene, p = d.getEngine(), y = o.getMaterial();
+ if (y) {
+ if (s._internalAbstractMeshDataInfo._isActiveIntermediate = !1, t._enableVelocity && !t._previousTransformationMatrices[s.uniqueId] && (t._previousTransformationMatrices[s.uniqueId] = { world: u.a.Identity(), viewProjection: d.getTransformMatrix() }, a.skeleton)) {
+ var P = a.skeleton.getTransformMatrices(a);
+ t._previousBonesTransformationMatrices[a.uniqueId] = t._copyBonesTransformationMatrices(P, new Float32Array(P.length));
+ }
+ var R = a._getInstancesRenderList(o._id, !!o.getReplacementMesh());
+ if (!R.mustReturn) {
+ var B = p.getCaps().instancedArrays && (R.visibleInstances[o._id] !== null || a.hasThinInstances), F = s.getWorldMatrix();
+ if (t.isReady(o, B)) {
+ if (p.enableEffect(t._effect), a._bind(o, t._effect, y.fillMode), t._effect.setMatrix("viewProjection", d.getTransformMatrix()), t._effect.setMatrix("view", d.getViewMatrix()), y) {
+ var z, J = s._instanceDataStorage;
+ if (J.isFrozen || !y.backFaceCulling && y.overrideMaterialSideOrientation === null)
+ z = J.sideOrientation;
+ else {
+ var ie = s._getWorldMatrixDeterminant();
+ (z = y.overrideMaterialSideOrientation) == null && (z = y.sideOrientation), ie < 0 && (z = z === zt.a.ClockWiseSideOrientation ? zt.a.CounterClockWiseSideOrientation : zt.a.ClockWiseSideOrientation);
+ }
+ if (y._preBind(t._effect, z), y.needAlphaTesting()) {
+ var se = y.getAlphaTestTexture();
+ se && (t._effect.setTexture("diffuseSampler", se), t._effect.setMatrix("diffuseMatrix", se.getTextureMatrix()));
+ }
+ y.bumpTexture && d.getEngine().getCaps().standardDerivatives && Nt.a.BumpTextureEnabled && (t._effect.setFloat3("vBumpInfos", y.bumpTexture.coordinatesIndex, 1 / y.bumpTexture.level, y.parallaxScaleBias), t._effect.setMatrix("bumpMatrix", y.bumpTexture.getTextureMatrix()), t._effect.setTexture("bumpSampler", y.bumpTexture), t._effect.setFloat2("vTangentSpaceParams", y.invertNormalMapX ? -1 : 1, y.invertNormalMapY ? -1 : 1)), t._enableReflectivity && (y instanceof Nt.a && y.specularTexture ? (t._effect.setMatrix("reflectivityMatrix", y.specularTexture.getTextureMatrix()), t._effect.setTexture("reflectivitySampler", y.specularTexture)) : y instanceof $r && y.reflectivityTexture && (t._effect.setMatrix("reflectivityMatrix", y.reflectivityTexture.getTextureMatrix()), t._effect.setTexture("reflectivitySampler", y.reflectivityTexture)));
+ }
+ a.useBones && a.computeBonesUsingShaders && a.skeleton && (t._effect.setMatrices("mBones", a.skeleton.getTransformMatrices(a)), t._enableVelocity && t._effect.setMatrices("mPreviousBones", t._previousBonesTransformationMatrices[a.uniqueId])), $e.a.BindMorphTargetParameters(a, t._effect), t._enableVelocity && (t._effect.setMatrix("previousWorld", t._previousTransformationMatrices[s.uniqueId].world), t._effect.setMatrix("previousViewProjection", t._previousTransformationMatrices[s.uniqueId].viewProjection)), a._processRendering(s, o, t._effect, y.fillMode, R, B, function(ce, ue) {
+ return t._effect.setMatrix("world", ue);
+ });
+ }
+ t._enableVelocity && (t._previousTransformationMatrices[s.uniqueId].world = F.clone(), t._previousTransformationMatrices[s.uniqueId].viewProjection = t._scene.getTransformMatrix().clone(), a.skeleton && t._copyBonesTransformationMatrices(a.skeleton.getTransformMatrices(a), t._previousBonesTransformationMatrices[s.uniqueId]));
+ }
+ }
+ };
+ this._multiRenderTarget.customRenderFunction = function(o, a, s, d) {
+ var p;
+ if (t._linkedWithPrePass) {
+ if (!t._prePassRenderer.enabled)
+ return;
+ t._scene.getEngine().bindAttachments(t._attachments);
+ }
+ if (d.length) {
+ for (e.setColorWrite(!1), p = 0; p < d.length; p++)
+ i(d.data[p]);
+ e.setColorWrite(!0);
+ }
+ for (p = 0; p < o.length; p++)
+ i(o.data[p]);
+ for (p = 0; p < a.length; p++)
+ i(a.data[p]);
+ if (t.renderTransparentMeshes)
+ for (p = 0; p < s.length; p++)
+ i(s.data[p]);
+ };
+ }
+ }, r.prototype._copyBonesTransformationMatrices = function(t, e) {
+ for (var n = 0; n < t.length; n++)
+ e[n] = t[n];
+ return e;
+ }, r.DEPTHNORMAL_TEXTURE_TYPE = 0, r.POSITION_TEXTURE_TYPE = 1, r.VELOCITY_TEXTURE_TYPE = 2, r.REFLECTIVITY_TEXTURE_TYPE = 3, r._SceneComponentInitialization = function(t) {
+ throw En.a.WarnImport("GeometryBufferRendererSceneComponent");
+ }, r;
+ }(), jm = function() {
+ this.enabled = !1, this.name = "motionBlur", this.texturesRequired = [h.a.PREPASS_VELOCITY_TEXTURE_TYPE];
+ };
+ Object.defineProperty(_e.a.prototype, "geometryBufferRenderer", { get: function() {
+ this._geometryBufferRenderer;
+ }, set: function(r) {
+ r && r.isSupported && (this._geometryBufferRenderer = r);
+ }, enumerable: !0, configurable: !0 }), _e.a.prototype.enableGeometryBufferRenderer = function(r) {
+ return r === void 0 && (r = 1), this._geometryBufferRenderer || (this._geometryBufferRenderer = new ri(this, r), this._geometryBufferRenderer.isSupported || (this._geometryBufferRenderer = null)), this._geometryBufferRenderer;
+ }, _e.a.prototype.disableGeometryBufferRenderer = function() {
+ this._geometryBufferRenderer && (this._geometryBufferRenderer.dispose(), this._geometryBufferRenderer = null);
+ };
+ var yd = function() {
+ function r(t) {
+ this.name = ot.a.NAME_GEOMETRYBUFFERRENDERER, this.scene = t;
+ }
+ return r.prototype.register = function() {
+ this.scene._gatherRenderTargetsStage.registerStep(ot.a.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER, this, this._gatherRenderTargets);
+ }, r.prototype.rebuild = function() {
+ }, r.prototype.dispose = function() {
+ }, r.prototype._gatherRenderTargets = function(t) {
+ this.scene._geometryBufferRenderer && t.push(this.scene._geometryBufferRenderer.getGBuffer());
+ }, r;
+ }();
+ ri._SceneComponentInitialization = function(r) {
+ var t = r._getComponent(ot.a.NAME_GEOMETRYBUFFERRENDERER);
+ t || (t = new yd(r), r._addComponent(t));
+ };
+ var Hm = `
+varying vec2 vUV;
+uniform sampler2D textureSampler;
+uniform float motionStrength;
+uniform float motionScale;
+uniform vec2 screenSize;
+#ifdef OBJECT_BASED
+uniform sampler2D velocitySampler;
+#else
+uniform sampler2D depthSampler;
+uniform mat4 inverseViewProjection;
+uniform mat4 prevViewProjection;
+#endif
+void main(void)
+{
+#ifdef GEOMETRY_SUPPORTED
+#ifdef OBJECT_BASED
+vec2 texelSize=1.0/screenSize;
+vec2 velocityColor=texture2D(velocitySampler,vUV).rg*2.0-1.0;
+vec2 velocity=vec2(pow(velocityColor.r,3.0),pow(velocityColor.g,3.0));
+velocity*=motionScale*motionStrength;
+float speed=length(velocity/texelSize);
+int samplesCount=int(clamp(speed,1.0,SAMPLES));
+velocity=normalize(velocity)*texelSize;
+float hlim=float(-samplesCount)*0.5+0.5;
+vec4 result=texture2D(textureSampler,vUV);
+for (int i=1; i=samplesCount)
+break;
+vec2 offset=vUV+velocity*(hlim+float(i));
+result+=texture2D(textureSampler,offset);
+}
+gl_FragColor=result/float(samplesCount);
+gl_FragColor.a=1.0;
+#else
+vec2 texelSize=1.0/screenSize;
+float depth=texture2D(depthSampler,vUV).r;
+vec4 cpos=vec4(vUV*2.0-1.0,depth,1.0);
+cpos=cpos*inverseViewProjection;
+vec4 ppos=cpos*prevViewProjection;
+ppos.xyz/=ppos.w;
+ppos.xy=ppos.xy*0.5+0.5;
+vec2 velocity=(ppos.xy-vUV)*motionScale*motionStrength;
+float speed=length(velocity/texelSize);
+int nSamples=int(clamp(speed,1.0,SAMPLES));
+vec4 result=texture2D(textureSampler,vUV);
+for (int i=1; i=nSamples)
+break;
+vec2 offset1=vUV+velocity*(float(i)/float(nSamples-1)-0.5);
+result+=texture2D(textureSampler,offset1);
+}
+gl_FragColor=result/float(nSamples);
+#endif
+#else
+gl_FragColor=texture2D(textureSampler,vUV);
+#endif
+}
+`;
+ ze.a.ShadersStore.motionBlurPixelShader = Hm;
+ var Mc = function(r) {
+ function t(e, n, i, o, a, s, d, p, y, P) {
+ p === void 0 && (p = h.a.TEXTURETYPE_UNSIGNED_INT), y === void 0 && (y = !1), P === void 0 && (P = !0);
+ var R = r.call(this, e, "motionBlur", ["motionStrength", "motionScale", "screenSize", "inverseViewProjection", "prevViewProjection"], ["velocitySampler"], i, o, a, s, d, `#define GEOMETRY_SUPPORTED
+#define SAMPLES 64.0
+#define OBJECT_BASED`, p, void 0, null, y) || this;
+ return R.motionStrength = 1, R._motionBlurSamples = 32, R._isObjectBased = !0, R._forceGeometryBuffer = !1, R._geometryBufferRenderer = null, R._prePassRenderer = null, R._invViewProjection = null, R._previousViewProjection = null, R._forceGeometryBuffer = P, R._forceGeometryBuffer ? (R._geometryBufferRenderer = n.enableGeometryBufferRenderer(), R._geometryBufferRenderer && (R._geometryBufferRenderer.enableVelocity = !0)) : (R._prePassRenderer = n.enablePrePassRenderer(), R._prePassRenderer && (R._prePassRenderer.markAsDirty(), R._prePassEffectConfiguration = new jm())), R._applyMode(), R;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "motionBlurSamples", { get: function() {
+ return this._motionBlurSamples;
+ }, set: function(e) {
+ this._motionBlurSamples = e, this._updateEffect();
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "isObjectBased", { get: function() {
+ return this._isObjectBased;
+ }, set: function(e) {
+ this._isObjectBased !== e && (this._isObjectBased = e, this._applyMode());
+ }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
+ return "MotionBlurPostProcess";
+ }, t.prototype.excludeSkinnedMesh = function(e) {
+ if (e.skeleton) {
+ var n = void 0;
+ if (this._geometryBufferRenderer)
+ n = this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity;
+ else {
+ if (!this._prePassRenderer)
+ return;
+ n = this._prePassRenderer.excludedSkinnedMesh;
+ }
+ n.push(e);
+ }
+ }, t.prototype.removeExcludedSkinnedMesh = function(e) {
+ if (e.skeleton) {
+ var n = void 0;
+ if (this._geometryBufferRenderer)
+ n = this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity;
+ else {
+ if (!this._prePassRenderer)
+ return;
+ n = this._prePassRenderer.excludedSkinnedMesh;
+ }
+ var i = n.indexOf(e);
+ i !== -1 && n.splice(i, 1);
+ }
+ }, t.prototype.dispose = function(e) {
+ this._geometryBufferRenderer && (this._geometryBufferRenderer._previousTransformationMatrices = {}, this._geometryBufferRenderer._previousBonesTransformationMatrices = {}, this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity = []), r.prototype.dispose.call(this, e);
+ }, t.prototype._applyMode = function() {
+ var e = this;
+ if (!this._geometryBufferRenderer && !this._prePassRenderer)
+ return l.a.Warn("Multiple Render Target support needed to compute object based motion blur"), this.updateEffect();
+ this._updateEffect(), this._invViewProjection = null, this._previousViewProjection = null, this.isObjectBased ? (this._prePassRenderer && this._prePassEffectConfiguration && (this._prePassEffectConfiguration.texturesRequired[0] = h.a.PREPASS_VELOCITY_TEXTURE_TYPE), this.onApply = function(n) {
+ return e._onApplyObjectBased(n);
+ }) : (this._invViewProjection = u.a.Identity(), this._previousViewProjection = u.a.Identity(), this._prePassRenderer && this._prePassEffectConfiguration && (this._prePassEffectConfiguration.texturesRequired[0] = h.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE), this.onApply = function(n) {
+ return e._onApplyScreenBased(n);
+ });
+ }, t.prototype._onApplyObjectBased = function(e) {
+ if (e.setVector2("screenSize", new u.d(this.width, this.height)), e.setFloat("motionScale", this._scene.getAnimationRatio()), e.setFloat("motionStrength", this.motionStrength), this._geometryBufferRenderer) {
+ var n = this._geometryBufferRenderer.getTextureIndex(ri.VELOCITY_TEXTURE_TYPE);
+ e.setTexture("velocitySampler", this._geometryBufferRenderer.getGBuffer().textures[n]);
+ } else
+ this._prePassRenderer && (n = this._prePassRenderer.getIndex(h.a.PREPASS_VELOCITY_TEXTURE_TYPE), e.setTexture("velocitySampler", this._prePassRenderer.prePassRT.textures[n]));
+ }, t.prototype._onApplyScreenBased = function(e) {
+ var n = this._scene.getProjectionMatrix().multiply(this._scene.getViewMatrix());
+ if (n.invertToRef(this._invViewProjection), e.setMatrix("inverseViewProjection", this._invViewProjection), e.setMatrix("prevViewProjection", this._previousViewProjection), this._previousViewProjection = n, e.setVector2("screenSize", new u.d(this.width, this.height)), e.setFloat("motionScale", this._scene.getAnimationRatio()), e.setFloat("motionStrength", this.motionStrength), this._geometryBufferRenderer) {
+ var i = this._geometryBufferRenderer.getTextureIndex(ri.DEPTHNORMAL_TEXTURE_TYPE);
+ e.setTexture("depthSampler", this._geometryBufferRenderer.getGBuffer().textures[i]);
+ } else
+ this._prePassRenderer && (i = this._prePassRenderer.getIndex(h.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE), e.setTexture("depthSampler", this._prePassRenderer.prePassRT.textures[i]));
+ }, t.prototype._updateEffect = function() {
+ if (this._geometryBufferRenderer || this._prePassRenderer) {
+ var e = ["#define GEOMETRY_SUPPORTED", "#define SAMPLES " + this._motionBlurSamples.toFixed(1), this._isObjectBased ? "#define OBJECT_BASED" : "#define SCREEN_BASED"];
+ this.updateEffect(e.join(`
+`));
+ }
+ }, t._Parse = function(e, n, i, o) {
+ return L.a.Parse(function() {
+ return new t(e.name, i, e.options, n, e.renderTargetSamplingMode, i.getEngine(), e.reusable, e.textureType, !1);
+ }, e, i, o);
+ }, Object(c.c)([Object(L.c)()], t.prototype, "motionStrength", void 0), Object(c.c)([Object(L.c)()], t.prototype, "motionBlurSamples", null), Object(c.c)([Object(L.c)()], t.prototype, "isObjectBased", null), t;
+ }(ft);
+ O.a.RegisteredTypes["BABYLON.MotionBlurPostProcess"] = Mc;
+ var Wm = `
+varying vec2 vUV;
+uniform sampler2D textureSampler;
+uniform sampler2D refractionSampler;
+
+uniform vec3 baseColor;
+uniform float depth;
+uniform float colorLevel;
+void main() {
+float ref=1.0-texture2D(refractionSampler,vUV).r;
+vec2 uv=vUV-vec2(0.5);
+vec2 offset=uv*depth*ref;
+vec3 sourceColor=texture2D(textureSampler,vUV-offset).rgb;
+gl_FragColor=vec4(sourceColor+sourceColor*ref*colorLevel,1.0);
+}`;
+ ze.a.ShadersStore.refractionPixelShader = Wm;
+ var bd = function(r) {
+ function t(e, n, i, o, a, s, d, p, y, P) {
+ var R = r.call(this, e, "refraction", ["baseColor", "depth", "colorLevel"], ["refractionSampler"], s, d, p, y, P) || this;
+ return R._ownRefractionTexture = !0, R.color = i, R.depth = o, R.colorLevel = a, R.refractionTextureUrl = n, R.onActivateObservable.add(function(B) {
+ R._refTexture = R._refTexture || new Ne.a(n, B.getScene());
+ }), R.onApplyObservable.add(function(B) {
+ B.setColor3("baseColor", R.color), B.setFloat("depth", R.depth), B.setFloat("colorLevel", R.colorLevel), B.setTexture("refractionSampler", R._refTexture);
+ }), R;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "refractionTexture", { get: function() {
+ return this._refTexture;
+ }, set: function(e) {
+ this._refTexture && this._ownRefractionTexture && this._refTexture.dispose(), this._refTexture = e, this._ownRefractionTexture = !1;
+ }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
+ return "RefractionPostProcess";
+ }, t.prototype.dispose = function(e) {
+ this._refTexture && this._ownRefractionTexture && (this._refTexture.dispose(), this._refTexture = null), r.prototype.dispose.call(this, e);
+ }, t._Parse = function(e, n, i, o) {
+ return L.a.Parse(function() {
+ return new t(e.name, e.refractionTextureUrl, e.color, e.depth, e.colorLevel, e.options, n, e.renderTargetSamplingMode, i.getEngine(), e.reusable);
+ }, e, i, o);
+ }, Object(c.c)([Object(L.c)()], t.prototype, "color", void 0), Object(c.c)([Object(L.c)()], t.prototype, "depth", void 0), Object(c.c)([Object(L.c)()], t.prototype, "colorLevel", void 0), Object(c.c)([Object(L.c)()], t.prototype, "refractionTextureUrl", void 0), t;
+ }(ft);
+ O.a.RegisteredTypes["BABYLON.RefractionPostProcess"] = bd;
+ var Xm = `
+varying vec2 vUV;
+uniform sampler2D textureSampler;
+uniform vec2 screenSize;
+uniform vec2 sharpnessAmounts;
+void main(void)
+{
+vec2 onePixel=vec2(1.0,1.0)/screenSize;
+vec4 color=texture2D(textureSampler,vUV);
+vec4 edgeDetection=texture2D(textureSampler,vUV+onePixel*vec2(0,-1)) +
+texture2D(textureSampler,vUV+onePixel*vec2(-1,0)) +
+texture2D(textureSampler,vUV+onePixel*vec2(1,0)) +
+texture2D(textureSampler,vUV+onePixel*vec2(0,1)) -
+color*4.0;
+gl_FragColor=max(vec4(color.rgb*sharpnessAmounts.y,color.a)-(sharpnessAmounts.x*vec4(edgeDetection.rgb,0)),0.);
+}`;
+ ze.a.ShadersStore.sharpenPixelShader = Xm;
+ var Ic = function(r) {
+ function t(e, n, i, o, a, s, d, p) {
+ d === void 0 && (d = h.a.TEXTURETYPE_UNSIGNED_INT), p === void 0 && (p = !1);
+ var y = r.call(this, e, "sharpen", ["sharpnessAmounts", "screenSize"], null, n, i, o, a, s, null, d, void 0, null, p) || this;
+ return y.colorAmount = 1, y.edgeAmount = 0.3, y.onApply = function(P) {
+ P.setFloat2("screenSize", y.width, y.height), P.setFloat2("sharpnessAmounts", y.edgeAmount, y.colorAmount);
+ }, y;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "SharpenPostProcess";
+ }, t._Parse = function(e, n, i, o) {
+ return L.a.Parse(function() {
+ return new t(e.name, e.options, n, e.renderTargetSamplingMode, i.getEngine(), e.textureType, e.reusable);
+ }, e, i, o);
+ }, Object(c.c)([Object(L.c)()], t.prototype, "colorAmount", void 0), Object(c.c)([Object(L.c)()], t.prototype, "edgeAmount", void 0), t;
+ }(ft);
+ O.a.RegisteredTypes["BABYLON.SharpenPostProcess"] = Ic;
+ var Ir = function() {
+ function r(t, e) {
+ this.engine = t, this._name = e, this._renderEffects = {}, this._renderEffectsForIsolatedPass = new Array(), this._cameras = [];
+ }
+ return Object.defineProperty(r.prototype, "name", { get: function() {
+ return this._name;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "cameras", { get: function() {
+ return this._cameras;
+ }, enumerable: !1, configurable: !0 }), r.prototype.getClassName = function() {
+ return "PostProcessRenderPipeline";
+ }, Object.defineProperty(r.prototype, "isSupported", { get: function() {
+ for (var t in this._renderEffects)
+ if (this._renderEffects.hasOwnProperty(t) && !this._renderEffects[t].isSupported)
+ return !1;
+ return !0;
+ }, enumerable: !1, configurable: !0 }), r.prototype.addEffect = function(t) {
+ this._renderEffects[t._name] = t;
+ }, r.prototype._rebuild = function() {
+ }, r.prototype._enableEffect = function(t, e) {
+ var n = this._renderEffects[t];
+ n && n._enable(Xe.b.MakeArray(e || this._cameras));
+ }, r.prototype._disableEffect = function(t, e) {
+ var n = this._renderEffects[t];
+ n && n._disable(Xe.b.MakeArray(e || this._cameras));
+ }, r.prototype._attachCameras = function(t, e) {
+ var n = Xe.b.MakeArray(t || this._cameras);
+ if (n) {
+ var i, o = [];
+ for (i = 0; i < n.length; i++) {
+ var a = n[i];
+ if (a) {
+ var s = a.name;
+ this._cameras.indexOf(a) === -1 ? this._cameras[s] = a : e && o.push(i);
+ }
+ }
+ for (i = 0; i < o.length; i++)
+ t.splice(o[i], 1);
+ for (var d in this._renderEffects)
+ this._renderEffects.hasOwnProperty(d) && this._renderEffects[d]._attachCameras(n);
+ }
+ }, r.prototype._detachCameras = function(t) {
+ var e = Xe.b.MakeArray(t || this._cameras);
+ if (e) {
+ for (var n in this._renderEffects)
+ this._renderEffects.hasOwnProperty(n) && this._renderEffects[n]._detachCameras(e);
+ for (var i = 0; i < e.length; i++)
+ this._cameras.splice(this._cameras.indexOf(e[i]), 1);
+ }
+ }, r.prototype._update = function() {
+ for (var t in this._renderEffects)
+ this._renderEffects.hasOwnProperty(t) && this._renderEffects[t]._update();
+ for (var e = 0; e < this._cameras.length; e++)
+ if (this._cameras[e]) {
+ var n = this._cameras[e].name;
+ this._renderEffectsForIsolatedPass[n] && this._renderEffectsForIsolatedPass[n]._update();
+ }
+ }, r.prototype._reset = function() {
+ this._renderEffects = {}, this._renderEffectsForIsolatedPass = new Array();
+ }, r.prototype._enableMSAAOnFirstPostProcess = function(t) {
+ if (this.engine.webGLVersion === 1)
+ return !1;
+ var e = Object.keys(this._renderEffects);
+ if (e.length > 0) {
+ var n = this._renderEffects[e[0]].getPostProcesses();
+ n && (n[0].samples = t);
+ }
+ return !0;
+ }, r.prototype.setPrePassRenderer = function(t) {
+ return !1;
+ }, r.prototype.dispose = function() {
+ }, Object(c.c)([Object(L.c)()], r.prototype, "_name", void 0), r;
+ }(), Td = function() {
+ function r() {
+ this._renderPipelines = {};
+ }
+ return Object.defineProperty(r.prototype, "supportedPipelines", { get: function() {
+ var t = [];
+ for (var e in this._renderPipelines)
+ if (this._renderPipelines.hasOwnProperty(e)) {
+ var n = this._renderPipelines[e];
+ n.isSupported && t.push(n);
+ }
+ return t;
+ }, enumerable: !1, configurable: !0 }), r.prototype.addPipeline = function(t) {
+ this._renderPipelines[t._name] = t;
+ }, r.prototype.attachCamerasToRenderPipeline = function(t, e, n) {
+ n === void 0 && (n = !1);
+ var i = this._renderPipelines[t];
+ i && i._attachCameras(e, n);
+ }, r.prototype.detachCamerasFromRenderPipeline = function(t, e) {
+ var n = this._renderPipelines[t];
+ n && n._detachCameras(e);
+ }, r.prototype.enableEffectInPipeline = function(t, e, n) {
+ var i = this._renderPipelines[t];
+ i && i._enableEffect(e, n);
+ }, r.prototype.disableEffectInPipeline = function(t, e, n) {
+ var i = this._renderPipelines[t];
+ i && i._disableEffect(e, n);
+ }, r.prototype.update = function() {
+ for (var t in this._renderPipelines)
+ if (this._renderPipelines.hasOwnProperty(t)) {
+ var e = this._renderPipelines[t];
+ e.isSupported ? e._update() : (e.dispose(), delete this._renderPipelines[t]);
+ }
+ }, r.prototype._rebuild = function() {
+ for (var t in this._renderPipelines)
+ this._renderPipelines.hasOwnProperty(t) && this._renderPipelines[t]._rebuild();
+ }, r.prototype.dispose = function() {
+ for (var t in this._renderPipelines)
+ this._renderPipelines.hasOwnProperty(t) && this._renderPipelines[t].dispose();
+ }, r;
+ }();
+ Object.defineProperty(_e.a.prototype, "postProcessRenderPipelineManager", { get: function() {
+ if (!this._postProcessRenderPipelineManager) {
+ var r = this._getComponent(ot.a.NAME_POSTPROCESSRENDERPIPELINEMANAGER);
+ r || (r = new Ed(this), this._addComponent(r)), this._postProcessRenderPipelineManager = new Td();
+ }
+ return this._postProcessRenderPipelineManager;
+ }, enumerable: !0, configurable: !0 });
+ var Ed = function() {
+ function r(t) {
+ this.name = ot.a.NAME_POSTPROCESSRENDERPIPELINEMANAGER, this.scene = t;
+ }
+ return r.prototype.register = function() {
+ this.scene._gatherRenderTargetsStage.registerStep(ot.a.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER, this, this._gatherRenderTargets);
+ }, r.prototype.rebuild = function() {
+ this.scene._postProcessRenderPipelineManager && this.scene._postProcessRenderPipelineManager._rebuild();
+ }, r.prototype.dispose = function() {
+ this.scene._postProcessRenderPipelineManager && this.scene._postProcessRenderPipelineManager.dispose();
+ }, r.prototype._gatherRenderTargets = function() {
+ this.scene._postProcessRenderPipelineManager && this.scene._postProcessRenderPipelineManager.update();
+ }, r;
+ }(), Sd = function(r) {
+ function t(e, n, i, o, a) {
+ e === void 0 && (e = ""), n === void 0 && (n = !0), i === void 0 && (i = te.a.LastCreatedScene), a === void 0 && (a = !0);
+ var s = r.call(this, i.getEngine(), e) || this;
+ s._camerasToBeAttached = [], s.SharpenPostProcessId = "SharpenPostProcessEffect", s.ImageProcessingPostProcessId = "ImageProcessingPostProcessEffect", s.FxaaPostProcessId = "FxaaPostProcessEffect", s.ChromaticAberrationPostProcessId = "ChromaticAberrationPostProcessEffect", s.GrainPostProcessId = "GrainPostProcessEffect", s._glowLayer = null, s.animations = [], s._imageProcessingConfigurationObserver = null, s._sharpenEnabled = !1, s._bloomEnabled = !1, s._depthOfFieldEnabled = !1, s._depthOfFieldBlurLevel = Ji.Low, s._fxaaEnabled = !1, s._imageProcessingEnabled = !0, s._bloomScale = 0.5, s._chromaticAberrationEnabled = !1, s._grainEnabled = !1, s._buildAllowed = !0, s.onBuildObservable = new C.c(), s._resizeObserver = null, s._hardwareScaleLevel = 1, s._bloomKernel = 64, s._bloomWeight = 0.15, s._bloomThreshold = 0.9, s._samples = 1, s._hasCleared = !1, s._prevPostProcess = null, s._prevPrevPostProcess = null, s._depthOfFieldSceneObserver = null, s._cameras = o || i.cameras, s._cameras = s._cameras.slice(), s._camerasToBeAttached = s._cameras.slice(), s._buildAllowed = a, s._scene = i;
+ var d = s._scene.getEngine().getCaps();
+ s._hdr = n && (d.textureHalfFloatRender || d.textureFloatRender), s._hdr ? d.textureHalfFloatRender ? s._defaultPipelineTextureType = h.a.TEXTURETYPE_HALF_FLOAT : d.textureFloatRender && (s._defaultPipelineTextureType = h.a.TEXTURETYPE_FLOAT) : s._defaultPipelineTextureType = h.a.TEXTURETYPE_UNSIGNED_INT, i.postProcessRenderPipelineManager.addPipeline(s);
+ var p = s._scene.getEngine();
+ return s.sharpen = new Ic("sharpen", 1, null, Ne.a.BILINEAR_SAMPLINGMODE, p, !1, s._defaultPipelineTextureType, !0), s._sharpenEffect = new xt(p, s.SharpenPostProcessId, function() {
+ return s.sharpen;
+ }, !0), s.depthOfField = new Rc(s._scene, null, s._depthOfFieldBlurLevel, s._defaultPipelineTextureType, !0), s.bloom = new Pc(s._scene, s._bloomScale, s._bloomWeight, s.bloomKernel, s._defaultPipelineTextureType, !0), s.chromaticAberration = new xc("ChromaticAberration", p.getRenderWidth(), p.getRenderHeight(), 1, null, Ne.a.BILINEAR_SAMPLINGMODE, p, !1, s._defaultPipelineTextureType, !0), s._chromaticAberrationEffect = new xt(p, s.ChromaticAberrationPostProcessId, function() {
+ return s.chromaticAberration;
+ }, !0), s.grain = new Oc("Grain", 1, null, Ne.a.BILINEAR_SAMPLINGMODE, p, !1, s._defaultPipelineTextureType, !0), s._grainEffect = new xt(p, s.GrainPostProcessId, function() {
+ return s.grain;
+ }, !0), s._resizeObserver = p.onResizeObservable.add(function() {
+ s._hardwareScaleLevel = p.getHardwareScalingLevel(), s.bloomKernel = s.bloomKernel;
+ }), s._imageProcessingConfigurationObserver = s._scene.imageProcessingConfiguration.onUpdateParameters.add(function() {
+ s.bloom._downscale._exposure = s._scene.imageProcessingConfiguration.exposure, s.imageProcessingEnabled !== s._scene.imageProcessingConfiguration.isEnabled && (s._imageProcessingEnabled = s._scene.imageProcessingConfiguration.isEnabled, s._buildPipeline());
+ }), s._buildPipeline(), s;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "scene", { get: function() {
+ return this._scene;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "sharpenEnabled", { get: function() {
+ return this._sharpenEnabled;
+ }, set: function(e) {
+ this._sharpenEnabled !== e && (this._sharpenEnabled = e, this._buildPipeline());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "bloomKernel", { get: function() {
+ return this._bloomKernel;
+ }, set: function(e) {
+ this._bloomKernel = e, this.bloom.kernel = e / this._hardwareScaleLevel;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "bloomWeight", { get: function() {
+ return this._bloomWeight;
+ }, set: function(e) {
+ this._bloomWeight !== e && (this.bloom.weight = e, this._bloomWeight = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "bloomThreshold", { get: function() {
+ return this._bloomThreshold;
+ }, set: function(e) {
+ this._bloomThreshold !== e && (this.bloom.threshold = e, this._bloomThreshold = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "bloomScale", { get: function() {
+ return this._bloomScale;
+ }, set: function(e) {
+ this._bloomScale !== e && (this._bloomScale = e, this._rebuildBloom(), this._buildPipeline());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "bloomEnabled", { get: function() {
+ return this._bloomEnabled;
+ }, set: function(e) {
+ this._bloomEnabled !== e && (this._bloomEnabled = e, this._buildPipeline());
+ }, enumerable: !1, configurable: !0 }), t.prototype._rebuildBloom = function() {
+ var e = this.bloom;
+ this.bloom = new Pc(this._scene, this.bloomScale, this._bloomWeight, this.bloomKernel, this._defaultPipelineTextureType, !1), this.bloom.threshold = e.threshold;
+ for (var n = 0; n < this._cameras.length; n++)
+ e.disposeEffects(this._cameras[n]);
+ }, Object.defineProperty(t.prototype, "depthOfFieldEnabled", { get: function() {
+ return this._depthOfFieldEnabled;
+ }, set: function(e) {
+ this._depthOfFieldEnabled !== e && (this._depthOfFieldEnabled = e, this._buildPipeline());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "depthOfFieldBlurLevel", { get: function() {
+ return this._depthOfFieldBlurLevel;
+ }, set: function(e) {
+ if (this._depthOfFieldBlurLevel !== e) {
+ this._depthOfFieldBlurLevel = e;
+ var n = this.depthOfField;
+ this.depthOfField = new Rc(this._scene, null, this._depthOfFieldBlurLevel, this._defaultPipelineTextureType, !1), this.depthOfField.focalLength = n.focalLength, this.depthOfField.focusDistance = n.focusDistance, this.depthOfField.fStop = n.fStop, this.depthOfField.lensSize = n.lensSize;
+ for (var i = 0; i < this._cameras.length; i++)
+ n.disposeEffects(this._cameras[i]);
+ this._buildPipeline();
+ }
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "fxaaEnabled", { get: function() {
+ return this._fxaaEnabled;
+ }, set: function(e) {
+ this._fxaaEnabled !== e && (this._fxaaEnabled = e, this._buildPipeline());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "samples", { get: function() {
+ return this._samples;
+ }, set: function(e) {
+ this._samples !== e && (this._samples = e, this._buildPipeline());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "imageProcessingEnabled", { get: function() {
+ return this._imageProcessingEnabled;
+ }, set: function(e) {
+ this._imageProcessingEnabled !== e && (this._scene.imageProcessingConfiguration.isEnabled = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "glowLayerEnabled", { get: function() {
+ return this._glowLayer != null;
+ }, set: function(e) {
+ e && !this._glowLayer ? this._glowLayer = new Ko("", this._scene) : !e && this._glowLayer && (this._glowLayer.dispose(), this._glowLayer = null);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "glowLayer", { get: function() {
+ return this._glowLayer;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "chromaticAberrationEnabled", { get: function() {
+ return this._chromaticAberrationEnabled;
+ }, set: function(e) {
+ this._chromaticAberrationEnabled !== e && (this._chromaticAberrationEnabled = e, this._buildPipeline());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "grainEnabled", { get: function() {
+ return this._grainEnabled;
+ }, set: function(e) {
+ this._grainEnabled !== e && (this._grainEnabled = e, this._buildPipeline());
+ }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
+ return "DefaultRenderingPipeline";
+ }, t.prototype.prepare = function() {
+ var e = this._buildAllowed;
+ this._buildAllowed = !0, this._buildPipeline(), this._buildAllowed = e;
+ }, t.prototype._setAutoClearAndTextureSharing = function(e, n) {
+ n === void 0 && (n = !1), this._hasCleared ? e.autoClear = !1 : (e.autoClear = !0, this._scene.autoClear = !1, this._hasCleared = !0), n || (this._prevPrevPostProcess ? e.shareOutputWith(this._prevPrevPostProcess) : e.useOwnOutput(), this._prevPostProcess && (this._prevPrevPostProcess = this._prevPostProcess), this._prevPostProcess = e);
+ }, t.prototype._buildPipeline = function() {
+ var e = this;
+ if (this._buildAllowed) {
+ this._scene.autoClear = !0;
+ var n = this._scene.getEngine();
+ if (this._disposePostProcesses(), this._cameras !== null && (this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras), this._cameras = this._camerasToBeAttached.slice()), this._reset(), this._prevPostProcess = null, this._prevPrevPostProcess = null, this._hasCleared = !1, this.depthOfFieldEnabled) {
+ if (this._cameras.length > 1) {
+ for (var i = 0, o = this._cameras; i < o.length; i++) {
+ var a = o[i];
+ (s = this._scene.enableDepthRenderer(a)).useOnlyInActiveCamera = !0;
+ }
+ this._depthOfFieldSceneObserver = this._scene.onAfterRenderTargetsRenderObservable.add(function(d) {
+ e._cameras.indexOf(d.activeCamera) > -1 && (e.depthOfField.depthTexture = d.enableDepthRenderer(d.activeCamera).getDepthMap());
+ });
+ } else {
+ this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
+ var s = this._scene.enableDepthRenderer(this._cameras[0]);
+ this.depthOfField.depthTexture = s.getDepthMap();
+ }
+ this.depthOfField._isReady() || this.depthOfField._updateEffects(), this.addEffect(this.depthOfField), this._setAutoClearAndTextureSharing(this.depthOfField._effects[0], !0);
+ } else
+ this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
+ this.bloomEnabled && (this.bloom._isReady() || this.bloom._updateEffects(), this.addEffect(this.bloom), this._setAutoClearAndTextureSharing(this.bloom._effects[0], !0)), this._imageProcessingEnabled && (this.imageProcessing = new Io("imageProcessing", 1, null, Ne.a.BILINEAR_SAMPLINGMODE, n, !1, this._defaultPipelineTextureType), this._hdr ? (this.addEffect(new xt(n, this.ImageProcessingPostProcessId, function() {
+ return e.imageProcessing;
+ }, !0)), this._setAutoClearAndTextureSharing(this.imageProcessing)) : this._scene.imageProcessingConfiguration.applyByPostProcess = !1, this.cameras && this.cameras.length !== 0 || (this._scene.imageProcessingConfiguration.applyByPostProcess = !1), this.imageProcessing.getEffect() || this.imageProcessing._updateParameters()), this.sharpenEnabled && (this.sharpen.isReady() || this.sharpen.updateEffect(), this.addEffect(this._sharpenEffect), this._setAutoClearAndTextureSharing(this.sharpen)), this.grainEnabled && (this.grain.isReady() || this.grain.updateEffect(), this.addEffect(this._grainEffect), this._setAutoClearAndTextureSharing(this.grain)), this.chromaticAberrationEnabled && (this.chromaticAberration.isReady() || this.chromaticAberration.updateEffect(), this.addEffect(this._chromaticAberrationEffect), this._setAutoClearAndTextureSharing(this.chromaticAberration)), this.fxaaEnabled && (this.fxaa = new vo("fxaa", 1, null, Ne.a.BILINEAR_SAMPLINGMODE, n, !1, this._defaultPipelineTextureType), this.addEffect(new xt(n, this.FxaaPostProcessId, function() {
+ return e.fxaa;
+ }, !0)), this._setAutoClearAndTextureSharing(this.fxaa, !0)), this._cameras !== null && this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras), this._scene.activeCameras && this._scene.activeCameras.length > 1 && (this._scene.autoClear = !0), !this._enableMSAAOnFirstPostProcess(this.samples) && this.samples > 1 && l.a.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0"), this.onBuildObservable.notifyObservers(this);
+ }
+ }, t.prototype._disposePostProcesses = function(e) {
+ e === void 0 && (e = !1);
+ for (var n = 0; n < this._cameras.length; n++) {
+ var i = this._cameras[n];
+ this.imageProcessing && this.imageProcessing.dispose(i), this.fxaa && this.fxaa.dispose(i), e && (this.sharpen && this.sharpen.dispose(i), this.depthOfField && (this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver), this.depthOfField.disposeEffects(i)), this.bloom && this.bloom.disposeEffects(i), this.chromaticAberration && this.chromaticAberration.dispose(i), this.grain && this.grain.dispose(i), this._glowLayer && this._glowLayer.dispose());
+ }
+ this.imageProcessing = null, this.fxaa = null, e && (this.sharpen = null, this._sharpenEffect = null, this.depthOfField = null, this.bloom = null, this.chromaticAberration = null, this._chromaticAberrationEffect = null, this.grain = null, this._grainEffect = null, this._glowLayer = null);
+ }, t.prototype.addCamera = function(e) {
+ this._camerasToBeAttached.push(e), this._buildPipeline();
+ }, t.prototype.removeCamera = function(e) {
+ var n = this._camerasToBeAttached.indexOf(e);
+ this._camerasToBeAttached.splice(n, 1), this._buildPipeline();
+ }, t.prototype.dispose = function() {
+ this.onBuildObservable.clear(), this._disposePostProcesses(!0), this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras), this._scene.autoClear = !0, this._resizeObserver && (this._scene.getEngine().onResizeObservable.remove(this._resizeObserver), this._resizeObserver = null), this._scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigurationObserver), r.prototype.dispose.call(this);
+ }, t.prototype.serialize = function() {
+ var e = L.a.Serialize(this);
+ return e.customType = "DefaultRenderingPipeline", e;
+ }, t.Parse = function(e, n, i) {
+ return L.a.Parse(function() {
+ return new t(e._name, e._name._hdr, n);
+ }, e, n, i);
+ }, Object(c.c)([Object(L.c)()], t.prototype, "sharpenEnabled", null), Object(c.c)([Object(L.c)()], t.prototype, "bloomKernel", null), Object(c.c)([Object(L.c)()], t.prototype, "_bloomWeight", void 0), Object(c.c)([Object(L.c)()], t.prototype, "_bloomThreshold", void 0), Object(c.c)([Object(L.c)()], t.prototype, "_hdr", void 0), Object(c.c)([Object(L.c)()], t.prototype, "bloomWeight", null), Object(c.c)([Object(L.c)()], t.prototype, "bloomThreshold", null), Object(c.c)([Object(L.c)()], t.prototype, "bloomScale", null), Object(c.c)([Object(L.c)()], t.prototype, "bloomEnabled", null), Object(c.c)([Object(L.c)()], t.prototype, "depthOfFieldEnabled", null), Object(c.c)([Object(L.c)()], t.prototype, "depthOfFieldBlurLevel", null), Object(c.c)([Object(L.c)()], t.prototype, "fxaaEnabled", null), Object(c.c)([Object(L.c)()], t.prototype, "samples", null), Object(c.c)([Object(L.c)()], t.prototype, "imageProcessingEnabled", null), Object(c.c)([Object(L.c)()], t.prototype, "glowLayerEnabled", null), Object(c.c)([Object(L.c)()], t.prototype, "chromaticAberrationEnabled", null), Object(c.c)([Object(L.c)()], t.prototype, "grainEnabled", null), t;
+ }(Ir);
+ O.a.RegisteredTypes["BABYLON.DefaultRenderingPipeline"] = Sd;
+ var Ym = `
+uniform sampler2D textureSampler;
+
+uniform float gain;
+uniform float threshold;
+uniform float screen_width;
+uniform float screen_height;
+
+varying vec2 vUV;
+
+vec4 highlightColor(vec4 color) {
+vec4 highlight=color;
+float luminance=dot(highlight.rgb,vec3(0.2125,0.7154,0.0721));
+float lum_threshold;
+if (threshold>1.0) { lum_threshold=0.94+0.01*threshold; }
+else { lum_threshold=0.5+0.44*threshold; }
+luminance=clamp((luminance-lum_threshold)*(1.0/(1.0-lum_threshold)),0.0,1.0);
+highlight*=luminance*gain;
+highlight.a=1.0;
+return highlight;
+}
+void main(void)
+{
+vec4 original=texture2D(textureSampler,vUV);
+
+if (gain == -1.0) {
+gl_FragColor=vec4(0.0,0.0,0.0,1.0);
+return;
+}
+float w=2.0/screen_width;
+float h=2.0/screen_height;
+float weight=1.0;
+
+vec4 blurred=vec4(0.0,0.0,0.0,0.0);
+#ifdef PENTAGON
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.84*w,0.43*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.48*w,-1.29*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.61*w,1.51*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.55*w,-0.74*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.71*w,-0.52*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.94*w,1.59*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.40*w,-1.87*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.62*w,1.16*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.09*w,0.25*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.46*w,-1.71*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.08*w,2.42*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.85*w,-1.89*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.89*w,0.16*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.29*w,1.88*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.40*w,-2.81*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.54*w,2.26*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.60*w,-0.61*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.31*w,-1.30*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.83*w,2.53*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.12*w,-2.48*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.60*w,1.11*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.82*w,0.99*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.50*w,-2.81*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.85*w,3.33*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.94*w,-1.92*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.27*w,-0.53*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.95*w,2.48*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.23*w,-3.04*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.17*w,2.05*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.97*w,-0.04*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.25*w,-2.00*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.31*w,3.08*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.94*w,-2.59*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.37*w,0.64*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.13*w,1.93*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.03*w,-3.65*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.60*w,3.17*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.14*w,-1.19*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.00*w,-1.19*h)));
+#else
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.85*w,0.36*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.52*w,-1.14*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.46*w,1.42*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.46*w,-0.83*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.79*w,-0.42*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.11*w,1.62*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.29*w,-2.07*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.69*w,1.39*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.28*w,0.12*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.65*w,-1.69*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.08*w,2.44*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.63*w,-1.90*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.55*w,0.31*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.13*w,1.52*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.56*w,-2.61*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.38*w,2.34*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.64*w,-0.81*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.53*w,-1.21*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.06*w,2.63*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.00*w,-2.69*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.59*w,1.32*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.82*w,0.78*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.57*w,-2.50*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.54*w,2.93*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.39*w,-1.81*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.01*w,-0.28*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.04*w,2.25*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.02*w,-3.05*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.09*w,2.25*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.07*w,-0.25*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.44*w,-1.90*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.52*w,3.05*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.68*w,-2.61*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.01*w,0.79*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.76*w,1.46*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.05*w,-2.94*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.21*w,2.88*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.84*w,-1.30*h)));
+blurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.98*w,-0.96*h)));
+#endif
+blurred/=39.0;
+gl_FragColor=blurred;
+
+}`;
+ ze.a.ShadersStore.lensHighlightsPixelShader = Ym;
+ var Km = `
+
+
+
+
+uniform sampler2D textureSampler;
+uniform sampler2D highlightsSampler;
+uniform sampler2D depthSampler;
+uniform sampler2D grainSampler;
+
+uniform float grain_amount;
+uniform bool blur_noise;
+uniform float screen_width;
+uniform float screen_height;
+uniform float distortion;
+uniform bool dof_enabled;
+
+uniform float screen_distance;
+uniform float aperture;
+uniform float darken;
+uniform float edge_blur;
+uniform bool highlights;
+
+uniform float near;
+uniform float far;
+
+varying vec2 vUV;
+
+#define PI 3.14159265
+#define TWOPI 6.28318530
+#define inverse_focal_length 0.1
+
+vec2 centered_screen_pos;
+vec2 distorted_coords;
+float radius2;
+float radius;
+
+vec2 rand(vec2 co)
+{
+float noise1=(fract(sin(dot(co,vec2(12.9898,78.233)))*43758.5453));
+float noise2=(fract(sin(dot(co,vec2(12.9898,78.233)*2.0))*43758.5453));
+return clamp(vec2(noise1,noise2),0.0,1.0);
+}
+
+vec2 getDistortedCoords(vec2 coords) {
+if (distortion == 0.0) { return coords; }
+vec2 direction=1.0*normalize(centered_screen_pos);
+vec2 dist_coords=vec2(0.5,0.5);
+dist_coords.x=0.5+direction.x*radius2*1.0;
+dist_coords.y=0.5+direction.y*radius2*1.0;
+float dist_amount=clamp(distortion*0.23,0.0,1.0);
+dist_coords=mix(coords,dist_coords,dist_amount);
+return dist_coords;
+}
+
+float sampleScreen(inout vec4 color,const in vec2 offset,const in float weight) {
+
+vec2 coords=distorted_coords;
+float angle=rand(coords*100.0).x*TWOPI;
+coords+=vec2(offset.x*cos(angle)-offset.y*sin(angle),offset.x*sin(angle)+offset.y*cos(angle));
+color+=texture2D(textureSampler,coords)*weight;
+return weight;
+}
+
+float getBlurLevel(float size) {
+return min(3.0,ceil(size/1.0));
+}
+
+vec4 getBlurColor(float size) {
+vec4 col=texture2D(textureSampler,distorted_coords);
+if (size == 0.0) { return col; }
+
+
+float blur_level=getBlurLevel(size);
+float w=(size/screen_width);
+float h=(size/screen_height);
+float total_weight=1.0;
+vec2 sample_coords;
+total_weight+=sampleScreen(col,vec2(-0.50*w,0.24*h),0.93);
+total_weight+=sampleScreen(col,vec2(0.30*w,-0.75*h),0.90);
+total_weight+=sampleScreen(col,vec2(0.36*w,0.96*h),0.87);
+total_weight+=sampleScreen(col,vec2(-1.08*w,-0.55*h),0.85);
+total_weight+=sampleScreen(col,vec2(1.33*w,-0.37*h),0.83);
+total_weight+=sampleScreen(col,vec2(-0.82*w,1.31*h),0.80);
+total_weight+=sampleScreen(col,vec2(-0.31*w,-1.67*h),0.78);
+total_weight+=sampleScreen(col,vec2(1.47*w,1.11*h),0.76);
+total_weight+=sampleScreen(col,vec2(-1.97*w,0.19*h),0.74);
+total_weight+=sampleScreen(col,vec2(1.42*w,-1.57*h),0.72);
+if (blur_level>1.0) {
+total_weight+=sampleScreen(col,vec2(0.01*w,2.25*h),0.70);
+total_weight+=sampleScreen(col,vec2(-1.62*w,-1.74*h),0.67);
+total_weight+=sampleScreen(col,vec2(2.49*w,0.20*h),0.65);
+total_weight+=sampleScreen(col,vec2(-2.07*w,1.61*h),0.63);
+total_weight+=sampleScreen(col,vec2(0.46*w,-2.70*h),0.61);
+total_weight+=sampleScreen(col,vec2(1.55*w,2.40*h),0.59);
+total_weight+=sampleScreen(col,vec2(-2.88*w,-0.75*h),0.56);
+total_weight+=sampleScreen(col,vec2(2.73*w,-1.44*h),0.54);
+total_weight+=sampleScreen(col,vec2(-1.08*w,3.02*h),0.52);
+total_weight+=sampleScreen(col,vec2(-1.28*w,-3.05*h),0.49);
+}
+if (blur_level>2.0) {
+total_weight+=sampleScreen(col,vec2(3.11*w,1.43*h),0.46);
+total_weight+=sampleScreen(col,vec2(-3.36*w,1.08*h),0.44);
+total_weight+=sampleScreen(col,vec2(1.80*w,-3.16*h),0.41);
+total_weight+=sampleScreen(col,vec2(0.83*w,3.65*h),0.38);
+total_weight+=sampleScreen(col,vec2(-3.16*w,-2.19*h),0.34);
+total_weight+=sampleScreen(col,vec2(3.92*w,-0.53*h),0.31);
+total_weight+=sampleScreen(col,vec2(-2.59*w,3.12*h),0.26);
+total_weight+=sampleScreen(col,vec2(-0.20*w,-4.15*h),0.22);
+total_weight+=sampleScreen(col,vec2(3.02*w,3.00*h),0.15);
+}
+col/=total_weight;
+
+if (darken>0.0) {
+col.rgb*=clamp(0.3,1.0,1.05-size*0.5*darken);
+}
+
+
+
+
+return col;
+}
+void main(void)
+{
+
+centered_screen_pos=vec2(vUV.x-0.5,vUV.y-0.5);
+radius2=centered_screen_pos.x*centered_screen_pos.x+centered_screen_pos.y*centered_screen_pos.y;
+radius=sqrt(radius2);
+distorted_coords=getDistortedCoords(vUV);
+vec2 texels_coords=vec2(vUV.x*screen_width,vUV.y*screen_height);
+float depth=texture2D(depthSampler,distorted_coords).r;
+float distance=near+(far-near)*depth;
+vec4 color=texture2D(textureSampler,vUV);
+
+
+float coc=abs(aperture*(screen_distance*(inverse_focal_length-1.0/distance)-1.0));
+
+if (dof_enabled == false || coc<0.07) { coc=0.0; }
+
+float edge_blur_amount=0.0;
+if (edge_blur>0.0) {
+edge_blur_amount=clamp((radius*2.0-1.0+0.15*edge_blur)*1.5,0.0,1.0)*1.3;
+}
+
+float blur_amount=max(edge_blur_amount,coc);
+
+if (blur_amount == 0.0) {
+gl_FragColor=texture2D(textureSampler,distorted_coords);
+}
+else {
+
+gl_FragColor=getBlurColor(blur_amount*1.7);
+
+if (highlights) {
+gl_FragColor.rgb+=clamp(coc,0.0,1.0)*texture2D(highlightsSampler,distorted_coords).rgb;
+}
+if (blur_noise) {
+
+vec2 noise=rand(distorted_coords)*0.01*blur_amount;
+vec2 blurred_coord=vec2(distorted_coords.x+noise.x,distorted_coords.y+noise.y);
+gl_FragColor=0.04*texture2D(textureSampler,blurred_coord)+0.96*gl_FragColor;
+}
+}
+
+if (grain_amount>0.0) {
+vec4 grain_color=texture2D(grainSampler,texels_coords*0.003);
+gl_FragColor.rgb+=(-0.5+grain_color.rgb)*0.30*grain_amount;
+}
+}
+`;
+ ze.a.ShadersStore.depthOfFieldPixelShader = Km;
+ var Qm = function(r) {
+ function t(e, n, i, o, a) {
+ o === void 0 && (o = 1);
+ var s = r.call(this, i.getEngine(), e) || this;
+ return s.LensChromaticAberrationEffect = "LensChromaticAberrationEffect", s.HighlightsEnhancingEffect = "HighlightsEnhancingEffect", s.LensDepthOfFieldEffect = "LensDepthOfFieldEffect", s._pentagonBokehIsEnabled = !1, s._scene = i, s._depthTexture = i.enableDepthRenderer().getDepthMap(), n.grain_texture ? s._grainTexture = n.grain_texture : s._createGrainTexture(), s._edgeBlur = n.edge_blur ? n.edge_blur : 0, s._grainAmount = n.grain_amount ? n.grain_amount : 0, s._chromaticAberration = n.chromatic_aberration ? n.chromatic_aberration : 0, s._distortion = n.distortion ? n.distortion : 0, s._highlightsGain = n.dof_gain !== void 0 ? n.dof_gain : -1, s._highlightsThreshold = n.dof_threshold ? n.dof_threshold : 1, s._dofDistance = n.dof_focus_distance !== void 0 ? n.dof_focus_distance : -1, s._dofAperture = n.dof_aperture ? n.dof_aperture : 1, s._dofDarken = n.dof_darken ? n.dof_darken : 0, s._dofPentagon = n.dof_pentagon === void 0 || n.dof_pentagon, s._blurNoise = n.blur_noise === void 0 || n.blur_noise, s._createChromaticAberrationPostProcess(o), s._createHighlightsPostProcess(o), s._createDepthOfFieldPostProcess(o / 4), s.addEffect(new xt(i.getEngine(), s.LensChromaticAberrationEffect, function() {
+ return s._chromaticAberrationPostProcess;
+ }, !0)), s.addEffect(new xt(i.getEngine(), s.HighlightsEnhancingEffect, function() {
+ return s._highlightsPostProcess;
+ }, !0)), s.addEffect(new xt(i.getEngine(), s.LensDepthOfFieldEffect, function() {
+ return s._depthOfFieldPostProcess;
+ }, !0)), s._highlightsGain === -1 && s._disableEffect(s.HighlightsEnhancingEffect, null), i.postProcessRenderPipelineManager.addPipeline(s), a && i.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(e, a), s;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "LensRenderingPipeline";
+ }, Object.defineProperty(t.prototype, "scene", { get: function() {
+ return this._scene;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "edgeBlur", { get: function() {
+ return this._edgeBlur;
+ }, set: function(e) {
+ this.setEdgeBlur(e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "grainAmount", { get: function() {
+ return this._grainAmount;
+ }, set: function(e) {
+ this.setGrainAmount(e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "chromaticAberration", { get: function() {
+ return this._chromaticAberration;
+ }, set: function(e) {
+ this.setChromaticAberration(e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "dofAperture", { get: function() {
+ return this._dofAperture;
+ }, set: function(e) {
+ this.setAperture(e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "edgeDistortion", { get: function() {
+ return this._distortion;
+ }, set: function(e) {
+ this.setEdgeDistortion(e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "dofDistortion", { get: function() {
+ return this._dofDistance;
+ }, set: function(e) {
+ this.setFocusDistance(e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "darkenOutOfFocus", { get: function() {
+ return this._dofDarken;
+ }, set: function(e) {
+ this.setDarkenOutOfFocus(e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "blurNoise", { get: function() {
+ return this._blurNoise;
+ }, set: function(e) {
+ this._blurNoise = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "pentagonBokeh", { get: function() {
+ return this._pentagonBokehIsEnabled;
+ }, set: function(e) {
+ e ? this.enablePentagonBokeh() : this.disablePentagonBokeh();
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "highlightsGain", { get: function() {
+ return this._highlightsGain;
+ }, set: function(e) {
+ this.setHighlightsGain(e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "highlightsThreshold", { get: function() {
+ return this._highlightsThreshold;
+ }, set: function(e) {
+ this.setHighlightsThreshold(e);
+ }, enumerable: !1, configurable: !0 }), t.prototype.setEdgeBlur = function(e) {
+ this._edgeBlur = e;
+ }, t.prototype.disableEdgeBlur = function() {
+ this._edgeBlur = 0;
+ }, t.prototype.setGrainAmount = function(e) {
+ this._grainAmount = e;
+ }, t.prototype.disableGrain = function() {
+ this._grainAmount = 0;
+ }, t.prototype.setChromaticAberration = function(e) {
+ this._chromaticAberration = e;
+ }, t.prototype.disableChromaticAberration = function() {
+ this._chromaticAberration = 0;
+ }, t.prototype.setEdgeDistortion = function(e) {
+ this._distortion = e;
+ }, t.prototype.disableEdgeDistortion = function() {
+ this._distortion = 0;
+ }, t.prototype.setFocusDistance = function(e) {
+ this._dofDistance = e;
+ }, t.prototype.disableDepthOfField = function() {
+ this._dofDistance = -1;
+ }, t.prototype.setAperture = function(e) {
+ this._dofAperture = e;
+ }, t.prototype.setDarkenOutOfFocus = function(e) {
+ this._dofDarken = e;
+ }, t.prototype.enablePentagonBokeh = function() {
+ this._highlightsPostProcess.updateEffect(`#define PENTAGON
+`), this._pentagonBokehIsEnabled = !0;
+ }, t.prototype.disablePentagonBokeh = function() {
+ this._pentagonBokehIsEnabled = !1, this._highlightsPostProcess.updateEffect();
+ }, t.prototype.enableNoiseBlur = function() {
+ this._blurNoise = !0;
+ }, t.prototype.disableNoiseBlur = function() {
+ this._blurNoise = !1;
+ }, t.prototype.setHighlightsGain = function(e) {
+ this._highlightsGain = e;
+ }, t.prototype.setHighlightsThreshold = function(e) {
+ this._highlightsGain === -1 && (this._highlightsGain = 1), this._highlightsThreshold = e;
+ }, t.prototype.disableHighlights = function() {
+ this._highlightsGain = -1;
+ }, t.prototype.dispose = function(e) {
+ e === void 0 && (e = !1), this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras), this._chromaticAberrationPostProcess = null, this._highlightsPostProcess = null, this._depthOfFieldPostProcess = null, this._grainTexture.dispose(), e && this._scene.disableDepthRenderer();
+ }, t.prototype._createChromaticAberrationPostProcess = function(e) {
+ var n = this;
+ this._chromaticAberrationPostProcess = new ft("LensChromaticAberration", "chromaticAberration", ["chromatic_aberration", "screen_width", "screen_height", "direction", "radialIntensity", "centerPosition"], [], e, null, Ne.a.TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1), this._chromaticAberrationPostProcess.onApply = function(i) {
+ i.setFloat("chromatic_aberration", n._chromaticAberration), i.setFloat("screen_width", n._scene.getEngine().getRenderWidth()), i.setFloat("screen_height", n._scene.getEngine().getRenderHeight()), i.setFloat("radialIntensity", 1), i.setFloat2("direction", 17, 17), i.setFloat2("centerPosition", 0.5, 0.5);
+ };
+ }, t.prototype._createHighlightsPostProcess = function(e) {
+ var n = this;
+ this._highlightsPostProcess = new ft("LensHighlights", "lensHighlights", ["gain", "threshold", "screen_width", "screen_height"], [], e, null, Ne.a.TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1, this._dofPentagon ? `#define PENTAGON
+` : ""), this._highlightsPostProcess.onApply = function(i) {
+ i.setFloat("gain", n._highlightsGain), i.setFloat("threshold", n._highlightsThreshold), i.setTextureFromPostProcess("textureSampler", n._chromaticAberrationPostProcess), i.setFloat("screen_width", n._scene.getEngine().getRenderWidth()), i.setFloat("screen_height", n._scene.getEngine().getRenderHeight());
+ };
+ }, t.prototype._createDepthOfFieldPostProcess = function(e) {
+ var n = this;
+ this._depthOfFieldPostProcess = new ft("LensDepthOfField", "depthOfField", ["grain_amount", "blur_noise", "screen_width", "screen_height", "distortion", "dof_enabled", "screen_distance", "aperture", "darken", "edge_blur", "highlights", "near", "far"], ["depthSampler", "grainSampler", "highlightsSampler"], e, null, Ne.a.TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1), this._depthOfFieldPostProcess.onApply = function(i) {
+ i.setTexture("depthSampler", n._depthTexture), i.setTexture("grainSampler", n._grainTexture), i.setTextureFromPostProcess("textureSampler", n._highlightsPostProcess), i.setTextureFromPostProcess("highlightsSampler", n._depthOfFieldPostProcess), i.setFloat("grain_amount", n._grainAmount), i.setBool("blur_noise", n._blurNoise), i.setFloat("screen_width", n._scene.getEngine().getRenderWidth()), i.setFloat("screen_height", n._scene.getEngine().getRenderHeight()), i.setFloat("distortion", n._distortion), i.setBool("dof_enabled", n._dofDistance !== -1), i.setFloat("screen_distance", 1 / (0.1 - 1 / n._dofDistance)), i.setFloat("aperture", n._dofAperture), i.setFloat("darken", n._dofDarken), i.setFloat("edge_blur", n._edgeBlur), i.setBool("highlights", n._highlightsGain !== -1), n._scene.activeCamera && (i.setFloat("near", n._scene.activeCamera.minZ), i.setFloat("far", n._scene.activeCamera.maxZ));
+ };
+ }, t.prototype._createGrainTexture = function() {
+ this._grainTexture = new pi.a("LensNoiseTexture", 512, this._scene, !1, Ne.a.BILINEAR_SAMPLINGMODE), this._grainTexture.wrapU = Ne.a.WRAP_ADDRESSMODE, this._grainTexture.wrapV = Ne.a.WRAP_ADDRESSMODE;
+ for (var e, n, i, o = this._grainTexture.getContext(), a = 0; a < 512; a++)
+ for (var s = 0; s < 512; s++)
+ e = Math.floor(255 * (n = 0.42, i = 0.58, Math.random() * (i - n) + n)), o.fillStyle = "rgb(" + e + ", " + e + ", " + e + ")", o.fillRect(a, s, 1, 1);
+ this._grainTexture.update(!1);
+ }, t;
+ }(Ir), qm = function() {
+ this.enabled = !1, this.name = "ssao2", this.texturesRequired = [h.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE];
+ }, Zm = `
+precision highp float;
+uniform sampler2D textureSampler;
+uniform float near;
+uniform float far;
+uniform float radius;
+float scales[16]=float[16](
+0.1,
+0.11406250000000001,
+0.131640625,
+0.15625,
+0.187890625,
+0.2265625,
+0.272265625,
+0.325,
+0.384765625,
+0.4515625,
+0.525390625,
+0.60625,
+0.694140625,
+0.7890625,
+0.891015625,
+1.0
+);
+varying vec2 vUV;
+float perspectiveDepthToViewZ( const in float invClipZ,const in float near,const in float far ) {
+return ( near*far )/( ( far-near )*invClipZ-far );
+}
+float viewZToPerspectiveDepth( const in float viewZ,const in float near,const in float far ) {
+return ( near*far/viewZ+far)/( far-near );
+}
+float viewZToOrthographicDepth( const in float viewZ,const in float near,const in float far ) {
+return ( viewZ+near )/( near-far );
+}
+#ifdef SSAO
+uniform sampler2D randomSampler;
+#ifndef GEOMETRYBUFFER
+uniform sampler2D depthNormalSampler;
+#else
+uniform sampler2D depthSampler;
+uniform sampler2D normalSampler;
+#endif
+uniform float randTextureTiles;
+uniform float samplesFactor;
+uniform vec3 sampleSphere[SAMPLES];
+uniform float totalStrength;
+uniform float base;
+uniform float xViewport;
+uniform float yViewport;
+uniform float maxZ;
+uniform float minZAspect;
+uniform vec2 texelSize;
+uniform mat4 projection;
+void main()
+{
+vec3 random=texture2D(randomSampler,vUV*randTextureTiles).rgb;
+#ifndef GEOMETRYBUFFER
+float depth=texture2D(depthNormalSampler,vUV).r;
+#else
+float depth=texture2D(depthSampler,vUV).r;
+#endif
+float depthSign=depth/abs(depth);
+depth=depth*depthSign;
+#ifndef GEOMETRYBUFFER
+vec3 normal=texture2D(depthNormalSampler,vUV).gba;
+#else
+vec3 normal=texture2D(normalSampler,vUV).rgb;
+#endif
+float occlusion=0.0;
+float correctedRadius=min(radius,minZAspect*depth/near);
+vec3 vViewRay=vec3((vUV.x*2.0-1.0)*xViewport,(vUV.y*2.0-1.0)*yViewport,depthSign);
+vec3 origin=vViewRay*depth;
+vec3 rvec=random*2.0-1.0;
+rvec.z=0.0;
+
+float dotProduct=dot(rvec,normal);
+rvec=1.0-abs(dotProduct)>1e-2 ? rvec : vec3(-rvec.y,0.0,rvec.x);
+vec3 tangent=normalize(rvec-normal*dot(rvec,normal));
+vec3 bitangent=cross(normal,tangent);
+mat3 tbn=mat3(tangent,bitangent,normal);
+float difference;
+for (int i=0; i1.0 || offset.y>1.0) {
+continue;
+}
+
+#ifndef GEOMETRYBUFFER
+float sampleDepth=abs(texture2D(depthNormalSampler,offset.xy).r);
+#else
+float sampleDepth=abs(texture2D(depthSampler,offset.xy).r);
+#endif
+
+difference=depthSign*samplePosition.z-sampleDepth;
+float rangeCheck=1.0-smoothstep(correctedRadius*0.5,correctedRadius,difference);
+occlusion+=(difference>=0.0 ? 1.0 : 0.0)*rangeCheck;
+}
+occlusion=occlusion*(1.0-smoothstep(maxZ*0.75,maxZ,depth));
+float ao=1.0-totalStrength*occlusion*samplesFactor;
+float result=clamp(ao+base,0.0,1.0);
+gl_FragColor=vec4(vec3(result),1.0);
+}
+#endif
+#ifdef BILATERAL_BLUR
+uniform sampler2D depthNormalSampler;
+uniform float outSize;
+uniform float samplerOffsets[SAMPLES];
+vec4 blur9(sampler2D image,vec2 uv,float resolution,vec2 direction) {
+vec4 color=vec4(0.0);
+vec2 off1=vec2(1.3846153846)*direction;
+vec2 off2=vec2(3.2307692308)*direction;
+color+=texture2D(image,uv)*0.2270270270;
+color+=texture2D(image,uv+(off1/resolution))*0.3162162162;
+color+=texture2D(image,uv-(off1/resolution))*0.3162162162;
+color+=texture2D(image,uv+(off2/resolution))*0.0702702703;
+color+=texture2D(image,uv-(off2/resolution))*0.0702702703;
+return color;
+}
+vec4 blur13(sampler2D image,vec2 uv,float resolution,vec2 direction) {
+vec4 color=vec4(0.0);
+vec2 off1=vec2(1.411764705882353)*direction;
+vec2 off2=vec2(3.2941176470588234)*direction;
+vec2 off3=vec2(5.176470588235294)*direction;
+color+=texture2D(image,uv)*0.1964825501511404;
+color+=texture2D(image,uv+(off1/resolution))*0.2969069646728344;
+color+=texture2D(image,uv-(off1/resolution))*0.2969069646728344;
+color+=texture2D(image,uv+(off2/resolution))*0.09447039785044732;
+color+=texture2D(image,uv-(off2/resolution))*0.09447039785044732;
+color+=texture2D(image,uv+(off3/resolution))*0.010381362401148057;
+color+=texture2D(image,uv-(off3/resolution))*0.010381362401148057;
+return color;
+}
+vec4 blur13Bilateral(sampler2D image,vec2 uv,float resolution,vec2 direction) {
+vec4 color=vec4(0.0);
+vec2 off1=vec2(1.411764705882353)*direction;
+vec2 off2=vec2(3.2941176470588234)*direction;
+vec2 off3=vec2(5.176470588235294)*direction;
+float compareDepth=abs(texture2D(depthNormalSampler,uv).r);
+float sampleDepth;
+float weight;
+float weightSum=30.0;
+color+=texture2D(image,uv)*30.0;
+sampleDepth=abs(texture2D(depthNormalSampler,uv+(off1/resolution)).r);
+weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);
+weightSum+=weight;
+color+=texture2D(image,uv+(off1/resolution))*weight;
+sampleDepth=abs(texture2D(depthNormalSampler,uv-(off1/resolution)).r);
+weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);
+weightSum+=weight;
+color+=texture2D(image,uv-(off1/resolution))*weight;
+sampleDepth=abs(texture2D(depthNormalSampler,uv+(off2/resolution)).r);
+weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);
+weightSum+=weight;
+color+=texture2D(image,uv+(off2/resolution))*weight;
+sampleDepth=abs(texture2D(depthNormalSampler,uv-(off2/resolution)).r);
+weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);
+weightSum+=weight;
+color+=texture2D(image,uv-(off2/resolution))*weight;
+sampleDepth=abs(texture2D(depthNormalSampler,uv+(off3/resolution)).r);
+weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);
+weightSum+=weight;
+color+=texture2D(image,uv+(off3/resolution))*weight;
+sampleDepth=abs(texture2D(depthNormalSampler,uv-(off3/resolution)).r);
+weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);
+weightSum+=weight;
+color+=texture2D(image,uv-(off3/resolution))*weight;
+return color/weightSum;
+}
+void main()
+{
+#if EXPENSIVE
+float compareDepth=abs(texture2D(depthNormalSampler,vUV).r);
+float texelsize=1.0/outSize;
+float result=0.0;
+float weightSum=0.0;
+for (int i=0; i= 2;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "scene", { get: function() {
+ return this._scene;
+ }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
+ return "SSAO2RenderingPipeline";
+ }, t.prototype.dispose = function(e) {
+ e === void 0 && (e = !1);
+ for (var n = 0; n < this._scene.cameras.length; n++) {
+ var i = this._scene.cameras[n];
+ this._originalColorPostProcess.dispose(i), this._ssaoPostProcess.dispose(i), this._blurHPostProcess.dispose(i), this._blurVPostProcess.dispose(i), this._ssaoCombinePostProcess.dispose(i);
+ }
+ this._randomTexture.dispose(), e && this._scene.disableGeometryBufferRenderer(), this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras), r.prototype.dispose.call(this);
+ }, t.prototype._createBlurPostProcess = function(e, n) {
+ var i = this;
+ this._samplerOffsets = [];
+ for (var o = this.expensiveBlur, a = -8; a < 8; a++)
+ this._samplerOffsets.push(2 * a + 0.5);
+ this._blurHPostProcess = new ft("BlurH", "ssao2", ["outSize", "samplerOffsets", "near", "far", "radius"], ["depthNormalSampler"], e, null, Ne.a.TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1, `#define BILATERAL_BLUR
+#define BILATERAL_BLUR_H
+#define SAMPLES 16
+#define EXPENSIVE ` + (o ? "1" : "0") + `
+`), this._blurHPostProcess.onApply = function(s) {
+ i._scene.activeCamera && (s.setFloat("outSize", i._ssaoCombinePostProcess.width > 0 ? i._ssaoCombinePostProcess.width : i._originalColorPostProcess.width), s.setFloat("near", i._scene.activeCamera.minZ), s.setFloat("far", i._scene.activeCamera.maxZ), s.setFloat("radius", i.radius), i._forceGeometryBuffer ? s.setTexture("depthNormalSampler", i._scene.enableGeometryBufferRenderer().getGBuffer().textures[0]) : s.setTexture("depthNormalSampler", i._prePassRenderer.prePassRT.textures[i._prePassRenderer.getIndex(h.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)]), s.setArray("samplerOffsets", i._samplerOffsets));
+ }, this._blurVPostProcess = new ft("BlurV", "ssao2", ["outSize", "samplerOffsets", "near", "far", "radius"], ["depthNormalSampler"], n, null, Ne.a.TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1, `#define BILATERAL_BLUR
+#define BILATERAL_BLUR_V
+#define SAMPLES 16
+#define EXPENSIVE ` + (o ? "1" : "0") + `
+`), this._blurVPostProcess.onApply = function(s) {
+ i._scene.activeCamera && (s.setFloat("outSize", i._ssaoCombinePostProcess.height > 0 ? i._ssaoCombinePostProcess.height : i._originalColorPostProcess.height), s.setFloat("near", i._scene.activeCamera.minZ), s.setFloat("far", i._scene.activeCamera.maxZ), s.setFloat("radius", i.radius), i._forceGeometryBuffer ? s.setTexture("depthNormalSampler", i._scene.enableGeometryBufferRenderer().getGBuffer().textures[0]) : s.setTexture("depthNormalSampler", i._prePassRenderer.prePassRT.textures[i._prePassRenderer.getIndex(h.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)]), s.setArray("samplerOffsets", i._samplerOffsets));
+ }, this._blurHPostProcess.samples = this.textureSamples, this._blurVPostProcess.samples = this.textureSamples;
+ }, t.prototype._rebuild = function() {
+ r.prototype._rebuild.call(this);
+ }, t.prototype._radicalInverse_VdC = function(e) {
+ return this._bits[0] = e, this._bits[0] = (this._bits[0] << 16 | this._bits[0] >> 16) >>> 0, this._bits[0] = (1431655765 & this._bits[0]) << 1 | (2863311530 & this._bits[0]) >>> 1 >>> 0, this._bits[0] = (858993459 & this._bits[0]) << 2 | (3435973836 & this._bits[0]) >>> 2 >>> 0, this._bits[0] = (252645135 & this._bits[0]) << 4 | (4042322160 & this._bits[0]) >>> 4 >>> 0, this._bits[0] = (16711935 & this._bits[0]) << 8 | (4278255360 & this._bits[0]) >>> 8 >>> 0, 23283064365386963e-26 * this._bits[0];
+ }, t.prototype._hammersley = function(e, n) {
+ return [e / n, this._radicalInverse_VdC(e)];
+ }, t.prototype._hemisphereSample_uniform = function(e, n) {
+ var i = 2 * n * Math.PI, o = 1 - (0.85 * e + 0.15), a = Math.sqrt(1 - o * o);
+ return new u.e(Math.cos(i) * a, Math.sin(i) * a, o);
+ }, t.prototype._generateHemisphere = function() {
+ for (var e, n = this.samples, i = [], o = 0; o < n; ) {
+ if (n < 16)
+ e = this._hemisphereSample_uniform(Math.random(), Math.random());
+ else {
+ var a = this._hammersley(o, n);
+ e = this._hemisphereSample_uniform(a[0], a[1]);
+ }
+ i.push(e.x, e.y, e.z), o++;
+ }
+ return i;
+ }, t.prototype._getDefinesForSSAO = function() {
+ var e = "#define SAMPLES " + this.samples + `
+#define SSAO`;
+ return this._forceGeometryBuffer && (e += `
+#define GEOMETRYBUFFER`), e;
+ }, t.prototype._createSSAOPostProcess = function(e) {
+ var n = this;
+ this._sampleSphere = this._generateHemisphere();
+ var i, o = this._getDefinesForSSAO();
+ i = this._forceGeometryBuffer ? ["randomSampler", "depthSampler", "normalSampler"] : ["randomSampler", "depthNormalSampler"], this._ssaoPostProcess = new ft("ssao2", "ssao2", ["sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius", "base", "range", "projection", "near", "far", "texelSize", "xViewport", "yViewport", "maxZ", "minZAspect"], i, e, null, Ne.a.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1, o), this._ssaoPostProcess.onApply = function(a) {
+ n._scene.activeCamera && (a.setArray3("sampleSphere", n._sampleSphere), a.setFloat("randTextureTiles", 32), a.setFloat("samplesFactor", 1 / n.samples), a.setFloat("totalStrength", n.totalStrength), a.setFloat2("texelSize", 1 / n._ssaoPostProcess.width, 1 / n._ssaoPostProcess.height), a.setFloat("radius", n.radius), a.setFloat("maxZ", n.maxZ), a.setFloat("minZAspect", n.minZAspect), a.setFloat("base", n.base), a.setFloat("near", n._scene.activeCamera.minZ), a.setFloat("far", n._scene.activeCamera.maxZ), a.setFloat("xViewport", Math.tan(n._scene.activeCamera.fov / 2) * n._scene.getEngine().getAspectRatio(n._scene.activeCamera, !0)), a.setFloat("yViewport", Math.tan(n._scene.activeCamera.fov / 2)), a.setMatrix("projection", n._scene.getProjectionMatrix()), n._forceGeometryBuffer ? (a.setTexture("depthSampler", n._scene.enableGeometryBufferRenderer().getGBuffer().textures[0]), a.setTexture("normalSampler", n._scene.enableGeometryBufferRenderer().getGBuffer().textures[1])) : a.setTexture("depthNormalSampler", n._prePassRenderer.prePassRT.textures[n._prePassRenderer.getIndex(h.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)]), a.setTexture("randomSampler", n._randomTexture));
+ }, this._ssaoPostProcess.samples = this.textureSamples;
+ }, t.prototype._createSSAOCombinePostProcess = function(e) {
+ var n = this;
+ this._ssaoCombinePostProcess = new ft("ssaoCombine", "ssaoCombine", [], ["originalColor", "viewport"], e, null, Ne.a.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), !1), this._ssaoCombinePostProcess.onApply = function(i) {
+ var o = n._scene.activeCamera.viewport;
+ i.setVector4("viewport", u.c.Vector4[0].copyFromFloats(o.x, o.y, o.width, o.height)), i.setTextureFromPostProcessOutput("originalColor", n._originalColorPostProcess);
+ }, this._ssaoCombinePostProcess.samples = this.textureSamples, this._forceGeometryBuffer || (this._ssaoCombinePostProcess._prePassEffectConfiguration = new qm());
+ }, t.prototype._createRandomTexture = function() {
+ this._randomTexture = new pi.a("SSAORandomTexture", 128, this._scene, !1, Ne.a.TRILINEAR_SAMPLINGMODE), this._randomTexture.wrapU = Ne.a.WRAP_ADDRESSMODE, this._randomTexture.wrapV = Ne.a.WRAP_ADDRESSMODE;
+ for (var e = this._randomTexture.getContext(), n = function(s, d) {
+ return Math.random() * (d - s) + s;
+ }, i = u.e.Zero(), o = 0; o < 128; o++)
+ for (var a = 0; a < 128; a++)
+ i.x = n(0, 1), i.y = n(0, 1), i.z = 0, i.normalize(), i.scaleInPlace(255), i.x = Math.floor(i.x), i.y = Math.floor(i.y), e.fillStyle = "rgb(" + i.x + ", " + i.y + ", " + i.z + ")", e.fillRect(o, a, 1, 1);
+ this._randomTexture.update(!1);
+ }, t.prototype.serialize = function() {
+ var e = L.a.Serialize(this);
+ return e.customType = "SSAO2RenderingPipeline", e;
+ }, t.Parse = function(e, n, i) {
+ return L.a.Parse(function() {
+ return new t(e._name, n, e._ratio);
+ }, e, n, i);
+ }, Object(c.c)([Object(L.c)()], t.prototype, "totalStrength", void 0), Object(c.c)([Object(L.c)()], t.prototype, "maxZ", void 0), Object(c.c)([Object(L.c)()], t.prototype, "minZAspect", void 0), Object(c.c)([Object(L.c)("samples")], t.prototype, "_samples", void 0), Object(c.c)([Object(L.c)("textureSamples")], t.prototype, "_textureSamples", void 0), Object(c.c)([Object(L.c)()], t.prototype, "_ratio", void 0), Object(c.c)([Object(L.c)("expensiveBlur")], t.prototype, "_expensiveBlur", void 0), Object(c.c)([Object(L.c)()], t.prototype, "radius", void 0), Object(c.c)([Object(L.c)()], t.prototype, "base", void 0), t;
+ }(Ir);
+ O.a.RegisteredTypes["BABYLON.SSAO2RenderingPipeline"] = Ad;
+ var $m = `
+uniform sampler2D textureSampler;
+varying vec2 vUV;
+#ifdef SSAO
+uniform sampler2D randomSampler;
+uniform float randTextureTiles;
+uniform float samplesFactor;
+uniform vec3 sampleSphere[SAMPLES];
+uniform float totalStrength;
+uniform float radius;
+uniform float area;
+uniform float fallOff;
+uniform float base;
+vec3 normalFromDepth(float depth,vec2 coords)
+{
+vec2 offset1=vec2(0.0,radius);
+vec2 offset2=vec2(radius,0.0);
+float depth1=texture2D(textureSampler,coords+offset1).r;
+float depth2=texture2D(textureSampler,coords+offset2).r;
+vec3 p1=vec3(offset1,depth1-depth);
+vec3 p2=vec3(offset2,depth2-depth);
+vec3 normal=cross(p1,p2);
+normal.z=-normal.z;
+return normalize(normal);
+}
+void main()
+{
+vec3 random=normalize(texture2D(randomSampler,vUV*randTextureTiles).rgb);
+float depth=texture2D(textureSampler,vUV).r;
+vec3 position=vec3(vUV,depth);
+vec3 normal=normalFromDepth(depth,vUV);
+float radiusDepth=radius/depth;
+float occlusion=0.0;
+vec3 ray;
+vec3 hemiRay;
+float occlusionDepth;
+float difference;
+for (int i=0; i0.0)
+hitCoord-=dir;
+else
+hitCoord+=dir;
+info.color+=texture2D(textureSampler,projectedCoord.xy).rgb;
+}
+projectedCoord=projection*vec4(hitCoord,1.0);
+projectedCoord.xy/=projectedCoord.w;
+projectedCoord.xy=0.5*projectedCoord.xy+vec2(0.5);
+
+info.coords=vec4(projectedCoord.xy,sampledDepth,1.0);
+info.color+=texture2D(textureSampler,projectedCoord.xy).rgb;
+info.color/=float(SMOOTH_STEPS+1);
+return info;
+}
+
+ReflectionInfo getReflectionInfo(vec3 dir,vec3 hitCoord)
+{
+ReflectionInfo info;
+vec4 projectedCoord;
+float sampledDepth;
+dir*=step;
+for(int i=0; i> 0)), e.push("#define SMOOTH_STEPS " + (this._smoothSteps >> 0)), this.updateEffect(e.join(`
+`));
+ }, t._Parse = function(e, n, i, o) {
+ return L.a.Parse(function() {
+ return new t(e.name, i, e.options, n, e.renderTargetSamplingMode, i.getEngine(), e.textureType, e.reusable);
+ }, e, i, o);
+ }, Object(c.c)([Object(L.c)()], t.prototype, "threshold", void 0), Object(c.c)([Object(L.c)()], t.prototype, "strength", void 0), Object(c.c)([Object(L.c)()], t.prototype, "reflectionSpecularFalloffExponent", void 0), Object(c.c)([Object(L.c)()], t.prototype, "step", void 0), Object(c.c)([Object(L.c)()], t.prototype, "roughnessFactor", void 0), Object(c.c)([Object(L.c)()], t.prototype, "enableSmoothReflections", null), Object(c.c)([Object(L.c)()], t.prototype, "reflectionSamples", null), Object(c.c)([Object(L.c)()], t.prototype, "smoothSteps", null), t;
+ }(ft);
+ O.a.RegisteredTypes["BABYLON.ScreenSpaceReflectionPostProcess"] = Dc;
+ var ig = `uniform sampler2D textureSampler;
+varying vec2 vUV;
+#if defined(PASS_POST_PROCESS)
+void main(void)
+{
+vec4 color=texture2D(textureSampler,vUV);
+gl_FragColor=color;
+}
+#endif
+#if defined(DOWN_SAMPLE_X4)
+uniform vec2 dsOffsets[16];
+void main(void)
+{
+vec4 average=vec4(0.0,0.0,0.0,0.0);
+average=texture2D(textureSampler,vUV+dsOffsets[0]);
+average+=texture2D(textureSampler,vUV+dsOffsets[1]);
+average+=texture2D(textureSampler,vUV+dsOffsets[2]);
+average+=texture2D(textureSampler,vUV+dsOffsets[3]);
+average+=texture2D(textureSampler,vUV+dsOffsets[4]);
+average+=texture2D(textureSampler,vUV+dsOffsets[5]);
+average+=texture2D(textureSampler,vUV+dsOffsets[6]);
+average+=texture2D(textureSampler,vUV+dsOffsets[7]);
+average+=texture2D(textureSampler,vUV+dsOffsets[8]);
+average+=texture2D(textureSampler,vUV+dsOffsets[9]);
+average+=texture2D(textureSampler,vUV+dsOffsets[10]);
+average+=texture2D(textureSampler,vUV+dsOffsets[11]);
+average+=texture2D(textureSampler,vUV+dsOffsets[12]);
+average+=texture2D(textureSampler,vUV+dsOffsets[13]);
+average+=texture2D(textureSampler,vUV+dsOffsets[14]);
+average+=texture2D(textureSampler,vUV+dsOffsets[15]);
+average/=16.0;
+gl_FragColor=average;
+}
+#endif
+#if defined(BRIGHT_PASS)
+uniform vec2 dsOffsets[4];
+uniform float brightThreshold;
+void main(void)
+{
+vec4 average=vec4(0.0,0.0,0.0,0.0);
+average=texture2D(textureSampler,vUV+vec2(dsOffsets[0].x,dsOffsets[0].y));
+average+=texture2D(textureSampler,vUV+vec2(dsOffsets[1].x,dsOffsets[1].y));
+average+=texture2D(textureSampler,vUV+vec2(dsOffsets[2].x,dsOffsets[2].y));
+average+=texture2D(textureSampler,vUV+vec2(dsOffsets[3].x,dsOffsets[3].y));
+average*=0.25;
+float luminance=length(average.rgb);
+if (luminanceshadowPixelDepth)
+accumFog+=sunColor*computeScattering(dot(rayDirection,sunDirection));
+currentPosition+=stepL;
+}
+accumFog/=NB_STEPS;
+vec3 color=accumFog*scatteringPower;
+gl_FragColor=vec4(color*exp(color) ,1.0);
+}
+#endif
+#if defined(VLSMERGE)
+uniform sampler2D originalSampler;
+void main(void)
+{
+gl_FragColor=texture2D(originalSampler,vUV)+texture2D(textureSampler,vUV);
+}
+#endif
+#if defined(LUMINANCE)
+uniform vec2 lumOffsets[4];
+void main()
+{
+float average=0.0;
+vec4 color=vec4(0.0);
+float maximum=-1e20;
+vec3 weight=vec3(0.299,0.587,0.114);
+for (int i=0; i<4; i++)
+{
+color=texture2D(textureSampler,vUV+ lumOffsets[i]);
+
+float GreyValue=dot(color.rgb,vec3(0.33,0.33,0.33));
+
+#ifdef WEIGHTED_AVERAGE
+float GreyValue=dot(color.rgb,weight);
+#endif
+#ifdef BRIGHTNESS
+float GreyValue=max(color.r,max(color.g,color.b));
+#endif
+#ifdef HSL_COMPONENT
+float GreyValue=0.5*(max(color.r,max(color.g,color.b))+min(color.r,min(color.g,color.b)));
+#endif
+#ifdef MAGNITUDE
+float GreyValue=length(color.rgb);
+#endif
+maximum=max(maximum,GreyValue);
+average+=(0.25*log(1e-5+GreyValue));
+}
+average=exp(average);
+gl_FragColor=vec4(average,maximum,0.0,1.0);
+}
+#endif
+#if defined(LUMINANCE_DOWN_SAMPLE)
+uniform vec2 dsOffsets[9];
+uniform float halfDestPixelSize;
+#ifdef FINAL_DOWN_SAMPLER
+#include
+#endif
+void main()
+{
+vec4 color=vec4(0.0);
+float average=0.0;
+for (int i=0; i<9; i++)
+{
+color=texture2D(textureSampler,vUV+vec2(halfDestPixelSize,halfDestPixelSize)+dsOffsets[i]);
+average+=color.r;
+}
+average/=9.0;
+#ifdef FINAL_DOWN_SAMPLER
+gl_FragColor=pack(average);
+#else
+gl_FragColor=vec4(average,average,0.0,1.0);
+#endif
+}
+#endif
+#if defined(HDR)
+uniform sampler2D textureAdderSampler;
+uniform float averageLuminance;
+void main()
+{
+vec4 color=texture2D(textureAdderSampler,vUV);
+#ifndef AUTO_EXPOSURE
+vec4 adjustedColor=color/averageLuminance;
+color=adjustedColor;
+color.a=1.0;
+#endif
+gl_FragColor=color;
+}
+#endif
+#if defined(LENS_FLARE)
+#define GHOSTS 3
+uniform sampler2D lensColorSampler;
+uniform float strength;
+uniform float ghostDispersal;
+uniform float haloWidth;
+uniform vec2 resolution;
+uniform float distortionStrength;
+float hash(vec2 p)
+{
+float h=dot(p,vec2(127.1,311.7));
+return -1.0+2.0*fract(sin(h)*43758.5453123);
+}
+float noise(in vec2 p)
+{
+vec2 i=floor(p);
+vec2 f=fract(p);
+vec2 u=f*f*(3.0-2.0*f);
+return mix(mix(hash(i+vec2(0.0,0.0)),
+hash(i+vec2(1.0,0.0)),u.x),
+mix(hash(i+vec2(0.0,1.0)),
+hash(i+vec2(1.0,1.0)),u.x),u.y);
+}
+float fbm(vec2 p)
+{
+float f=0.0;
+f+=0.5000*noise(p); p*=2.02;
+f+=0.2500*noise(p); p*=2.03;
+f+=0.1250*noise(p); p*=2.01;
+f+=0.0625*noise(p); p*=2.04;
+f/=0.9375;
+return f;
+}
+vec3 pattern(vec2 uv)
+{
+vec2 p=-1.0+2.0*uv;
+float p2=dot(p,p);
+float f=fbm(vec2(15.0*p2))/2.0;
+float r=0.2+0.6*sin(12.5*length(uv-vec2(0.5)));
+float g=0.2+0.6*sin(20.5*length(uv-vec2(0.5)));
+float b=0.2+0.6*sin(17.2*length(uv-vec2(0.5)));
+return (1.0-f)*vec3(r,g,b);
+}
+float luminance(vec3 color)
+{
+return dot(color.rgb,vec3(0.2126,0.7152,0.0722));
+}
+vec4 textureDistorted(sampler2D tex,vec2 texcoord,vec2 direction,vec3 distortion)
+{
+return vec4(
+texture2D(tex,texcoord+direction*distortion.r).r,
+texture2D(tex,texcoord+direction*distortion.g).g,
+texture2D(tex,texcoord+direction*distortion.b).b,
+1.0
+);
+}
+void main(void)
+{
+vec2 uv=-vUV+vec2(1.0);
+vec2 ghostDir=(vec2(0.5)-uv)*ghostDispersal;
+vec2 texelSize=1.0/resolution;
+vec3 distortion=vec3(-texelSize.x*distortionStrength,0.0,texelSize.x*distortionStrength);
+vec4 result=vec4(0.0);
+float ghostIndice=1.0;
+for (int i=0; i=nSamples)
+break;
+vec2 offset1=vUV+velocity*(float(i)/float(nSamples-1)-0.5);
+result+=texture2D(textureSampler,offset1);
+}
+gl_FragColor=result/float(nSamples);
+}
+#endif
+`;
+ ze.a.ShadersStore.standardPixelShader = ig;
+ var Pd = function(r) {
+ function t(e, n, i, o, a) {
+ o === void 0 && (o = null);
+ var s = r.call(this, n.getEngine(), e) || this;
+ return s.downSampleX4PostProcess = null, s.brightPassPostProcess = null, s.blurHPostProcesses = [], s.blurVPostProcesses = [], s.textureAdderPostProcess = null, s.volumetricLightPostProcess = null, s.volumetricLightSmoothXPostProcess = null, s.volumetricLightSmoothYPostProcess = null, s.volumetricLightMergePostProces = null, s.volumetricLightFinalPostProcess = null, s.luminancePostProcess = null, s.luminanceDownSamplePostProcesses = [], s.hdrPostProcess = null, s.textureAdderFinalPostProcess = null, s.lensFlareFinalPostProcess = null, s.hdrFinalPostProcess = null, s.lensFlarePostProcess = null, s.lensFlareComposePostProcess = null, s.motionBlurPostProcess = null, s.depthOfFieldPostProcess = null, s.fxaaPostProcess = null, s.screenSpaceReflectionPostProcess = null, s.brightThreshold = 1, s.blurWidth = 512, s.horizontalBlur = !1, s.lensTexture = null, s.volumetricLightCoefficient = 0.2, s.volumetricLightPower = 4, s.volumetricLightBlurScale = 64, s.sourceLight = null, s.hdrMinimumLuminance = 1, s.hdrDecreaseRate = 0.5, s.hdrIncreaseRate = 0.5, s.lensColorTexture = null, s.lensFlareStrength = 20, s.lensFlareGhostDispersal = 1.4, s.lensFlareHaloWidth = 0.7, s.lensFlareDistortionStrength = 16, s.lensFlareBlurWidth = 512, s.lensStarTexture = null, s.lensFlareDirtTexture = null, s.depthOfFieldDistance = 10, s.depthOfFieldBlurWidth = 64, s.animations = [], s._currentDepthOfFieldSource = null, s._fixedExposure = 1, s._currentExposure = 1, s._hdrAutoExposure = !1, s._hdrCurrentLuminance = 1, s._motionStrength = 1, s._isObjectBasedMotionBlur = !1, s._camerasToBeAttached = [], s._bloomEnabled = !1, s._depthOfFieldEnabled = !1, s._vlsEnabled = !1, s._lensFlareEnabled = !1, s._hdrEnabled = !1, s._motionBlurEnabled = !1, s._fxaaEnabled = !1, s._screenSpaceReflectionsEnabled = !1, s._motionBlurSamples = 64, s._volumetricLightStepsCount = 50, s._samples = 1, s._cameras = a || n.cameras, s._cameras = s._cameras.slice(), s._camerasToBeAttached = s._cameras.slice(), s._scene = n, s._basePostProcess = o, s._ratio = i, s._floatTextureType = n.getEngine().getCaps().textureFloatRender ? h.a.TEXTURETYPE_FLOAT : h.a.TEXTURETYPE_HALF_FLOAT, n.postProcessRenderPipelineManager.addPipeline(s), s._buildPipeline(), s;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "exposure", { get: function() {
+ return this._fixedExposure;
+ }, set: function(e) {
+ this._fixedExposure = e, this._currentExposure = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "hdrAutoExposure", { get: function() {
+ return this._hdrAutoExposure;
+ }, set: function(e) {
+ if (this._hdrAutoExposure = e, this.hdrPostProcess) {
+ var n = ["#define HDR"];
+ e && n.push("#define AUTO_EXPOSURE"), this.hdrPostProcess.updateEffect(n.join(`
+`));
+ }
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "motionStrength", { get: function() {
+ return this._motionStrength;
+ }, set: function(e) {
+ this._motionStrength = e, this._isObjectBasedMotionBlur && this.motionBlurPostProcess && (this.motionBlurPostProcess.motionStrength = e);
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "objectBasedMotionBlur", { get: function() {
+ return this._isObjectBasedMotionBlur;
+ }, set: function(e) {
+ var n = this._isObjectBasedMotionBlur !== e;
+ this._isObjectBasedMotionBlur = e, n && this._buildPipeline();
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "BloomEnabled", { get: function() {
+ return this._bloomEnabled;
+ }, set: function(e) {
+ this._bloomEnabled !== e && (this._bloomEnabled = e, this._buildPipeline());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "DepthOfFieldEnabled", { get: function() {
+ return this._depthOfFieldEnabled;
+ }, set: function(e) {
+ this._depthOfFieldEnabled !== e && (this._depthOfFieldEnabled = e, this._buildPipeline());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "LensFlareEnabled", { get: function() {
+ return this._lensFlareEnabled;
+ }, set: function(e) {
+ this._lensFlareEnabled !== e && (this._lensFlareEnabled = e, this._buildPipeline());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "HDREnabled", { get: function() {
+ return this._hdrEnabled;
+ }, set: function(e) {
+ this._hdrEnabled !== e && (this._hdrEnabled = e, this._buildPipeline());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "VLSEnabled", { get: function() {
+ return this._vlsEnabled;
+ }, set: function(e) {
+ if (this._vlsEnabled !== e) {
+ if (e && !this._scene.enableGeometryBufferRenderer())
+ return void l.a.Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");
+ this._vlsEnabled = e, this._buildPipeline();
+ }
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "MotionBlurEnabled", { get: function() {
+ return this._motionBlurEnabled;
+ }, set: function(e) {
+ this._motionBlurEnabled !== e && (this._motionBlurEnabled = e, this._buildPipeline());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "fxaaEnabled", { get: function() {
+ return this._fxaaEnabled;
+ }, set: function(e) {
+ this._fxaaEnabled !== e && (this._fxaaEnabled = e, this._buildPipeline());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "screenSpaceReflectionsEnabled", { get: function() {
+ return this._screenSpaceReflectionsEnabled;
+ }, set: function(e) {
+ this._screenSpaceReflectionsEnabled !== e && (this._screenSpaceReflectionsEnabled = e, this._buildPipeline());
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "volumetricLightStepsCount", { get: function() {
+ return this._volumetricLightStepsCount;
+ }, set: function(e) {
+ this.volumetricLightPostProcess && this.volumetricLightPostProcess.updateEffect(`#define VLS
+#define NB_STEPS ` + e.toFixed(1)), this._volumetricLightStepsCount = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "motionBlurSamples", { get: function() {
+ return this._motionBlurSamples;
+ }, set: function(e) {
+ this.motionBlurPostProcess && (this._isObjectBasedMotionBlur ? this.motionBlurPostProcess.motionBlurSamples = e : this.motionBlurPostProcess.updateEffect(`#define MOTION_BLUR
+#define MAX_MOTION_SAMPLES ` + e.toFixed(1))), this._motionBlurSamples = e;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(t.prototype, "samples", { get: function() {
+ return this._samples;
+ }, set: function(e) {
+ this._samples !== e && (this._samples = e, this._buildPipeline());
+ }, enumerable: !1, configurable: !0 }), t.prototype._buildPipeline = function() {
+ var e = this, n = this._ratio, i = this._scene;
+ this._disposePostProcesses(), this._cameras !== null && (this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras), this._cameras = this._camerasToBeAttached.slice()), this._reset(), this._screenSpaceReflectionsEnabled && (this.screenSpaceReflectionPostProcess = new Dc("HDRPass", i, n, null, Ne.a.BILINEAR_SAMPLINGMODE, i.getEngine(), !1, this._floatTextureType), this.screenSpaceReflectionPostProcess.onApplyObservable.add(function() {
+ e._currentDepthOfFieldSource = e.screenSpaceReflectionPostProcess;
+ }), this.addEffect(new xt(i.getEngine(), "HDRScreenSpaceReflections", function() {
+ return e.screenSpaceReflectionPostProcess;
+ }, !0))), this._basePostProcess ? this.originalPostProcess = this._basePostProcess : this.originalPostProcess = new ft("HDRPass", "standard", [], [], n, null, Ne.a.BILINEAR_SAMPLINGMODE, i.getEngine(), !1, "#define PASS_POST_PROCESS", this._floatTextureType), this.originalPostProcess.autoClear = !this.screenSpaceReflectionPostProcess, this.originalPostProcess.onApplyObservable.add(function() {
+ e._currentDepthOfFieldSource = e.originalPostProcess;
+ }), this.addEffect(new xt(i.getEngine(), "HDRPassPostProcess", function() {
+ return e.originalPostProcess;
+ }, !0)), this._bloomEnabled && (this._createDownSampleX4PostProcess(i, n / 4), this._createBrightPassPostProcess(i, n / 4), this._createBlurPostProcesses(i, n / 4, 1), this._createTextureAdderPostProcess(i, n), this.textureAdderFinalPostProcess = new ft("HDRDepthOfFieldSource", "standard", [], [], n, null, Ne.a.BILINEAR_SAMPLINGMODE, i.getEngine(), !1, "#define PASS_POST_PROCESS", h.a.TEXTURETYPE_UNSIGNED_INT), this.addEffect(new xt(i.getEngine(), "HDRBaseDepthOfFieldSource", function() {
+ return e.textureAdderFinalPostProcess;
+ }, !0))), this._vlsEnabled && (this._createVolumetricLightPostProcess(i, n), this.volumetricLightFinalPostProcess = new ft("HDRVLSFinal", "standard", [], [], n, null, Ne.a.BILINEAR_SAMPLINGMODE, i.getEngine(), !1, "#define PASS_POST_PROCESS", h.a.TEXTURETYPE_UNSIGNED_INT), this.addEffect(new xt(i.getEngine(), "HDRVLSFinal", function() {
+ return e.volumetricLightFinalPostProcess;
+ }, !0))), this._lensFlareEnabled && (this._createLensFlarePostProcess(i, n), this.lensFlareFinalPostProcess = new ft("HDRPostLensFlareDepthOfFieldSource", "standard", [], [], n, null, Ne.a.BILINEAR_SAMPLINGMODE, i.getEngine(), !1, "#define PASS_POST_PROCESS", h.a.TEXTURETYPE_UNSIGNED_INT), this.addEffect(new xt(i.getEngine(), "HDRPostLensFlareDepthOfFieldSource", function() {
+ return e.lensFlareFinalPostProcess;
+ }, !0))), this._hdrEnabled && (this._createLuminancePostProcesses(i, this._floatTextureType), this._createHdrPostProcess(i, n), this.hdrFinalPostProcess = new ft("HDRPostHDReDepthOfFieldSource", "standard", [], [], n, null, Ne.a.BILINEAR_SAMPLINGMODE, i.getEngine(), !1, "#define PASS_POST_PROCESS", h.a.TEXTURETYPE_UNSIGNED_INT), this.addEffect(new xt(i.getEngine(), "HDRPostHDReDepthOfFieldSource", function() {
+ return e.hdrFinalPostProcess;
+ }, !0))), this._depthOfFieldEnabled && (this._createBlurPostProcesses(i, n / 2, 3, "depthOfFieldBlurWidth"), this._createDepthOfFieldPostProcess(i, n)), this._motionBlurEnabled && this._createMotionBlurPostProcess(i, n), this._fxaaEnabled && (this.fxaaPostProcess = new vo("fxaa", 1, null, Ne.a.BILINEAR_SAMPLINGMODE, i.getEngine(), !1, h.a.TEXTURETYPE_UNSIGNED_INT), this.addEffect(new xt(i.getEngine(), "HDRFxaa", function() {
+ return e.fxaaPostProcess;
+ }, !0))), this._cameras !== null && this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras), !this._enableMSAAOnFirstPostProcess(this._samples) && this._samples > 1 && l.a.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
+ }, t.prototype._createDownSampleX4PostProcess = function(e, n) {
+ var i = this, o = new Array(32);
+ this.downSampleX4PostProcess = new ft("HDRDownSampleX4", "standard", ["dsOffsets"], [], n, null, Ne.a.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, "#define DOWN_SAMPLE_X4", this._floatTextureType), this.downSampleX4PostProcess.onApply = function(a) {
+ for (var s = 0, d = i.downSampleX4PostProcess.width, p = i.downSampleX4PostProcess.height, y = -2; y < 2; y++)
+ for (var P = -2; P < 2; P++)
+ o[s] = (y + 0.5) * (1 / d), o[s + 1] = (P + 0.5) * (1 / p), s += 2;
+ a.setArray2("dsOffsets", o);
+ }, this.addEffect(new xt(e.getEngine(), "HDRDownSampleX4", function() {
+ return i.downSampleX4PostProcess;
+ }, !0));
+ }, t.prototype._createBrightPassPostProcess = function(e, n) {
+ var i = this, o = new Array(8);
+ this.brightPassPostProcess = new ft("HDRBrightPass", "standard", ["dsOffsets", "brightThreshold"], [], n, null, Ne.a.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, "#define BRIGHT_PASS", this._floatTextureType), this.brightPassPostProcess.onApply = function(a) {
+ var s = 1 / i.brightPassPostProcess.width, d = 1 / i.brightPassPostProcess.height;
+ o[0] = -0.5 * s, o[1] = 0.5 * d, o[2] = 0.5 * s, o[3] = 0.5 * d, o[4] = -0.5 * s, o[5] = -0.5 * d, o[6] = 0.5 * s, o[7] = -0.5 * d, a.setArray2("dsOffsets", o), a.setFloat("brightThreshold", i.brightThreshold);
+ }, this.addEffect(new xt(e.getEngine(), "HDRBrightPass", function() {
+ return i.brightPassPostProcess;
+ }, !0));
+ }, t.prototype._createBlurPostProcesses = function(e, n, i, o) {
+ var a = this;
+ o === void 0 && (o = "blurWidth");
+ var s = e.getEngine(), d = new _n("HDRBlurH_" + i, new u.d(1, 0), this[o], n, null, Ne.a.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, this._floatTextureType), p = new _n("HDRBlurV_" + i, new u.d(0, 1), this[o], n, null, Ne.a.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, this._floatTextureType);
+ d.onActivateObservable.add(function() {
+ var y = d.width / s.getRenderWidth();
+ d.kernel = a[o] * y;
+ }), p.onActivateObservable.add(function() {
+ var y = p.height / s.getRenderHeight();
+ p.kernel = a.horizontalBlur ? 64 * y : a[o] * y;
+ }), this.addEffect(new xt(e.getEngine(), "HDRBlurH" + i, function() {
+ return d;
+ }, !0)), this.addEffect(new xt(e.getEngine(), "HDRBlurV" + i, function() {
+ return p;
+ }, !0)), this.blurHPostProcesses.push(d), this.blurVPostProcesses.push(p);
+ }, t.prototype._createTextureAdderPostProcess = function(e, n) {
+ var i = this;
+ this.textureAdderPostProcess = new ft("HDRTextureAdder", "standard", ["exposure"], ["otherSampler", "lensSampler"], n, null, Ne.a.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, "#define TEXTURE_ADDER", this._floatTextureType), this.textureAdderPostProcess.onApply = function(o) {
+ o.setTextureFromPostProcess("otherSampler", i._vlsEnabled ? i._currentDepthOfFieldSource : i.originalPostProcess), o.setTexture("lensSampler", i.lensTexture), o.setFloat("exposure", i._currentExposure), i._currentDepthOfFieldSource = i.textureAdderFinalPostProcess;
+ }, this.addEffect(new xt(e.getEngine(), "HDRTextureAdder", function() {
+ return i.textureAdderPostProcess;
+ }, !0));
+ }, t.prototype._createVolumetricLightPostProcess = function(e, n) {
+ var i = this, o = e.enableGeometryBufferRenderer();
+ o.enablePosition = !0;
+ var a = o.getGBuffer();
+ this.volumetricLightPostProcess = new ft("HDRVLS", "standard", ["shadowViewProjection", "cameraPosition", "sunDirection", "sunColor", "scatteringCoefficient", "scatteringPower", "depthValues"], ["shadowMapSampler", "positionSampler"], n / 8, null, Ne.a.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, `#define VLS
+#define NB_STEPS ` + this._volumetricLightStepsCount.toFixed(1));
+ var s = u.d.Zero();
+ this.volumetricLightPostProcess.onApply = function(d) {
+ if (i.sourceLight && i.sourceLight.getShadowGenerator() && i._scene.activeCamera) {
+ var p = i.sourceLight.getShadowGenerator();
+ d.setTexture("shadowMapSampler", p.getShadowMap()), d.setTexture("positionSampler", a.textures[2]), d.setColor3("sunColor", i.sourceLight.diffuse), d.setVector3("sunDirection", i.sourceLight.getShadowDirection()), d.setVector3("cameraPosition", i._scene.activeCamera.globalPosition), d.setMatrix("shadowViewProjection", p.getTransformMatrix()), d.setFloat("scatteringCoefficient", i.volumetricLightCoefficient), d.setFloat("scatteringPower", i.volumetricLightPower), s.x = i.sourceLight.getDepthMinZ(i._scene.activeCamera), s.y = i.sourceLight.getDepthMaxZ(i._scene.activeCamera), d.setVector2("depthValues", s);
+ }
+ }, this.addEffect(new xt(e.getEngine(), "HDRVLS", function() {
+ return i.volumetricLightPostProcess;
+ }, !0)), this._createBlurPostProcesses(e, n / 4, 0, "volumetricLightBlurScale"), this.volumetricLightMergePostProces = new ft("HDRVLSMerge", "standard", [], ["originalSampler"], n, null, Ne.a.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, "#define VLSMERGE"), this.volumetricLightMergePostProces.onApply = function(d) {
+ d.setTextureFromPostProcess("originalSampler", i._bloomEnabled ? i.textureAdderFinalPostProcess : i.originalPostProcess), i._currentDepthOfFieldSource = i.volumetricLightFinalPostProcess;
+ }, this.addEffect(new xt(e.getEngine(), "HDRVLSMerge", function() {
+ return i.volumetricLightMergePostProces;
+ }, !0));
+ }, t.prototype._createLuminancePostProcesses = function(e, n) {
+ var i = this, o = Math.pow(3, t.LuminanceSteps);
+ this.luminancePostProcess = new ft("HDRLuminance", "standard", ["lumOffsets"], [], { width: o, height: o }, null, Ne.a.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, "#define LUMINANCE", n);
+ var a = [];
+ this.luminancePostProcess.onApply = function(P) {
+ var R = 1 / i.luminancePostProcess.width, B = 1 / i.luminancePostProcess.height;
+ a[0] = -0.5 * R, a[1] = 0.5 * B, a[2] = 0.5 * R, a[3] = 0.5 * B, a[4] = -0.5 * R, a[5] = -0.5 * B, a[6] = 0.5 * R, a[7] = -0.5 * B, P.setArray2("lumOffsets", a);
+ }, this.addEffect(new xt(e.getEngine(), "HDRLuminance", function() {
+ return i.luminancePostProcess;
+ }, !0));
+ for (var s = t.LuminanceSteps - 1; s >= 0; s--) {
+ o = Math.pow(3, s);
+ var d = `#define LUMINANCE_DOWN_SAMPLE
+`;
+ s === 0 && (d += "#define FINAL_DOWN_SAMPLER");
+ var p = new ft("HDRLuminanceDownSample" + s, "standard", ["dsOffsets", "halfDestPixelSize"], [], { width: o, height: o }, null, Ne.a.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, d, n);
+ this.luminanceDownSamplePostProcesses.push(p);
+ }
+ var y = this.luminancePostProcess;
+ this.luminanceDownSamplePostProcesses.forEach(function(P, R) {
+ var B = new Array(18);
+ P.onApply = function(F) {
+ if (y) {
+ for (var z = 0, J = -1; J < 2; J++)
+ for (var ie = -1; ie < 2; ie++)
+ B[z] = J / y.width, B[z + 1] = ie / y.height, z += 2;
+ F.setArray2("dsOffsets", B), F.setFloat("halfDestPixelSize", 0.5 / y.width), y = R === i.luminanceDownSamplePostProcesses.length - 1 ? i.luminancePostProcess : P;
+ }
+ }, R === i.luminanceDownSamplePostProcesses.length - 1 && (P.onAfterRender = function() {
+ var F = e.getEngine().readPixels(0, 0, 1, 1), z = new u.f(1 / 16581375, 1 / 65025, 1 / 255, 1);
+ i._hdrCurrentLuminance = (F[0] * z.x + F[1] * z.y + F[2] * z.z + F[3] * z.w) / 100;
+ }), i.addEffect(new xt(e.getEngine(), "HDRLuminanceDownSample" + R, function() {
+ return P;
+ }, !0));
+ });
+ }, t.prototype._createHdrPostProcess = function(e, n) {
+ var i = this, o = ["#define HDR"];
+ this._hdrAutoExposure && o.push("#define AUTO_EXPOSURE"), this.hdrPostProcess = new ft("HDR", "standard", ["averageLuminance"], ["textureAdderSampler"], n, null, Ne.a.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, o.join(`
+`), h.a.TEXTURETYPE_UNSIGNED_INT);
+ var a = 1, s = 0, d = 0;
+ this.hdrPostProcess.onApply = function(p) {
+ if (p.setTextureFromPostProcess("textureAdderSampler", i._currentDepthOfFieldSource), s += e.getEngine().getDeltaTime(), a < 0)
+ a = i._hdrCurrentLuminance;
+ else {
+ var y = (d - s) / 1e3;
+ i._hdrCurrentLuminance < a + i.hdrDecreaseRate * y ? a += i.hdrDecreaseRate * y : i._hdrCurrentLuminance > a - i.hdrIncreaseRate * y ? a -= i.hdrIncreaseRate * y : a = i._hdrCurrentLuminance;
+ }
+ i.hdrAutoExposure ? i._currentExposure = i._fixedExposure / a : (a = $.a.Clamp(a, i.hdrMinimumLuminance, 1e20), p.setFloat("averageLuminance", a)), d = s, i._currentDepthOfFieldSource = i.hdrFinalPostProcess;
+ }, this.addEffect(new xt(e.getEngine(), "HDR", function() {
+ return i.hdrPostProcess;
+ }, !0));
+ }, t.prototype._createLensFlarePostProcess = function(e, n) {
+ var i = this;
+ this.lensFlarePostProcess = new ft("HDRLensFlare", "standard", ["strength", "ghostDispersal", "haloWidth", "resolution", "distortionStrength"], ["lensColorSampler"], n / 2, null, Ne.a.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, "#define LENS_FLARE", h.a.TEXTURETYPE_UNSIGNED_INT), this.addEffect(new xt(e.getEngine(), "HDRLensFlare", function() {
+ return i.lensFlarePostProcess;
+ }, !0)), this._createBlurPostProcesses(e, n / 4, 2, "lensFlareBlurWidth"), this.lensFlareComposePostProcess = new ft("HDRLensFlareCompose", "standard", ["lensStarMatrix"], ["otherSampler", "lensDirtSampler", "lensStarSampler"], n, null, Ne.a.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, "#define LENS_FLARE_COMPOSE", h.a.TEXTURETYPE_UNSIGNED_INT), this.addEffect(new xt(e.getEngine(), "HDRLensFlareCompose", function() {
+ return i.lensFlareComposePostProcess;
+ }, !0));
+ var o = new u.d(0, 0);
+ this.lensFlarePostProcess.onApply = function(d) {
+ d.setTextureFromPostProcess("textureSampler", i._bloomEnabled ? i.blurHPostProcesses[0] : i.originalPostProcess), d.setTexture("lensColorSampler", i.lensColorTexture), d.setFloat("strength", i.lensFlareStrength), d.setFloat("ghostDispersal", i.lensFlareGhostDispersal), d.setFloat("haloWidth", i.lensFlareHaloWidth), o.x = i.lensFlarePostProcess.width, o.y = i.lensFlarePostProcess.height, d.setVector2("resolution", o), d.setFloat("distortionStrength", i.lensFlareDistortionStrength);
+ };
+ var a = u.a.FromValues(2, 0, -1, 0, 0, 2, -1, 0, 0, 0, 1, 0, 0, 0, 0, 1), s = u.a.FromValues(0.5, 0, 0.5, 0, 0, 0.5, 0.5, 0, 0, 0, 1, 0, 0, 0, 0, 1);
+ this.lensFlareComposePostProcess.onApply = function(d) {
+ if (i._scene.activeCamera) {
+ d.setTextureFromPostProcess("otherSampler", i.lensFlarePostProcess), d.setTexture("lensDirtSampler", i.lensFlareDirtTexture), d.setTexture("lensStarSampler", i.lensStarTexture);
+ var p = i._scene.activeCamera.getViewMatrix().getRow(0), y = i._scene.activeCamera.getViewMatrix().getRow(2), P = u.e.Dot(p.toVector3(), new u.e(1, 0, 0)) + u.e.Dot(y.toVector3(), new u.e(0, 0, 1));
+ P *= 4;
+ var R = u.a.FromValues(0.5 * Math.cos(P), -Math.sin(P), 0, 0, Math.sin(P), 0.5 * Math.cos(P), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), B = s.multiply(R).multiply(a);
+ d.setMatrix("lensStarMatrix", B), i._currentDepthOfFieldSource = i.lensFlareFinalPostProcess;
+ }
+ };
+ }, t.prototype._createDepthOfFieldPostProcess = function(e, n) {
+ var i = this;
+ this.depthOfFieldPostProcess = new ft("HDRDepthOfField", "standard", ["distance"], ["otherSampler", "depthSampler"], n, null, Ne.a.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, "#define DEPTH_OF_FIELD", h.a.TEXTURETYPE_UNSIGNED_INT), this.depthOfFieldPostProcess.onApply = function(o) {
+ o.setTextureFromPostProcess("otherSampler", i._currentDepthOfFieldSource), o.setTexture("depthSampler", i._getDepthTexture()), o.setFloat("distance", i.depthOfFieldDistance);
+ }, this.addEffect(new xt(e.getEngine(), "HDRDepthOfField", function() {
+ return i.depthOfFieldPostProcess;
+ }, !0));
+ }, t.prototype._createMotionBlurPostProcess = function(e, n) {
+ var i = this;
+ if (this._isObjectBasedMotionBlur) {
+ var o = new Mc("HDRMotionBlur", e, n, null, Ne.a.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, h.a.TEXTURETYPE_UNSIGNED_INT);
+ o.motionStrength = this.motionStrength, o.motionBlurSamples = this.motionBlurSamples, this.motionBlurPostProcess = o;
+ } else {
+ this.motionBlurPostProcess = new ft("HDRMotionBlur", "standard", ["inverseViewProjection", "prevViewProjection", "screenSize", "motionScale", "motionStrength"], ["depthSampler"], n, null, Ne.a.BILINEAR_SAMPLINGMODE, e.getEngine(), !1, `#define MOTION_BLUR
+#define MAX_MOTION_SAMPLES ` + this.motionBlurSamples.toFixed(1), h.a.TEXTURETYPE_UNSIGNED_INT);
+ var a = 0, s = u.a.Identity(), d = u.a.Identity(), p = u.a.Identity(), y = u.d.Zero();
+ this.motionBlurPostProcess.onApply = function(P) {
+ (p = e.getProjectionMatrix().multiply(e.getViewMatrix())).invertToRef(d), P.setMatrix("inverseViewProjection", d), P.setMatrix("prevViewProjection", s), s = p, y.x = i.motionBlurPostProcess.width, y.y = i.motionBlurPostProcess.height, P.setVector2("screenSize", y), a = e.getEngine().getFps() / 60, P.setFloat("motionScale", a), P.setFloat("motionStrength", i.motionStrength), P.setTexture("depthSampler", i._getDepthTexture());
+ };
+ }
+ this.addEffect(new xt(e.getEngine(), "HDRMotionBlur", function() {
+ return i.motionBlurPostProcess;
+ }, !0));
+ }, t.prototype._getDepthTexture = function() {
+ return this._scene.getEngine().getCaps().drawBuffersExtension ? this._scene.enableGeometryBufferRenderer().getGBuffer().textures[0] : this._scene.enableDepthRenderer().getDepthMap();
+ }, t.prototype._disposePostProcesses = function() {
+ for (var e = 0; e < this._cameras.length; e++) {
+ var n = this._cameras[e];
+ this.originalPostProcess && this.originalPostProcess.dispose(n), this.screenSpaceReflectionPostProcess && this.screenSpaceReflectionPostProcess.dispose(n), this.downSampleX4PostProcess && this.downSampleX4PostProcess.dispose(n), this.brightPassPostProcess && this.brightPassPostProcess.dispose(n), this.textureAdderPostProcess && this.textureAdderPostProcess.dispose(n), this.volumetricLightPostProcess && this.volumetricLightPostProcess.dispose(n), this.volumetricLightSmoothXPostProcess && this.volumetricLightSmoothXPostProcess.dispose(n), this.volumetricLightSmoothYPostProcess && this.volumetricLightSmoothYPostProcess.dispose(n), this.volumetricLightMergePostProces && this.volumetricLightMergePostProces.dispose(n), this.volumetricLightFinalPostProcess && this.volumetricLightFinalPostProcess.dispose(n), this.lensFlarePostProcess && this.lensFlarePostProcess.dispose(n), this.lensFlareComposePostProcess && this.lensFlareComposePostProcess.dispose(n);
+ for (var i = 0; i < this.luminanceDownSamplePostProcesses.length; i++)
+ this.luminanceDownSamplePostProcesses[i].dispose(n);
+ for (this.luminancePostProcess && this.luminancePostProcess.dispose(n), this.hdrPostProcess && this.hdrPostProcess.dispose(n), this.hdrFinalPostProcess && this.hdrFinalPostProcess.dispose(n), this.depthOfFieldPostProcess && this.depthOfFieldPostProcess.dispose(n), this.motionBlurPostProcess && this.motionBlurPostProcess.dispose(n), this.fxaaPostProcess && this.fxaaPostProcess.dispose(n), i = 0; i < this.blurHPostProcesses.length; i++)
+ this.blurHPostProcesses[i].dispose(n);
+ for (i = 0; i < this.blurVPostProcesses.length; i++)
+ this.blurVPostProcesses[i].dispose(n);
+ }
+ this.originalPostProcess = null, this.downSampleX4PostProcess = null, this.brightPassPostProcess = null, this.textureAdderPostProcess = null, this.textureAdderFinalPostProcess = null, this.volumetricLightPostProcess = null, this.volumetricLightSmoothXPostProcess = null, this.volumetricLightSmoothYPostProcess = null, this.volumetricLightMergePostProces = null, this.volumetricLightFinalPostProcess = null, this.lensFlarePostProcess = null, this.lensFlareComposePostProcess = null, this.luminancePostProcess = null, this.hdrPostProcess = null, this.hdrFinalPostProcess = null, this.depthOfFieldPostProcess = null, this.motionBlurPostProcess = null, this.fxaaPostProcess = null, this.screenSpaceReflectionPostProcess = null, this.luminanceDownSamplePostProcesses = [], this.blurHPostProcesses = [], this.blurVPostProcesses = [];
+ }, t.prototype.dispose = function() {
+ this._disposePostProcesses(), this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras), r.prototype.dispose.call(this);
+ }, t.prototype.serialize = function() {
+ var e = L.a.Serialize(this);
+ return this.sourceLight && (e.sourceLightId = this.sourceLight.id), this.screenSpaceReflectionPostProcess && (e.screenSpaceReflectionPostProcess = L.a.Serialize(this.screenSpaceReflectionPostProcess)), e.customType = "StandardRenderingPipeline", e;
+ }, t.Parse = function(e, n, i) {
+ var o = L.a.Parse(function() {
+ return new t(e._name, n, e._ratio);
+ }, e, n, i);
+ return e.sourceLightId && (o.sourceLight = n.getLightByID(e.sourceLightId)), e.screenSpaceReflectionPostProcess && L.a.Parse(function() {
+ return o.screenSpaceReflectionPostProcess;
+ }, e.screenSpaceReflectionPostProcess, n, i), o;
+ }, t.LuminanceSteps = 6, Object(c.c)([Object(L.c)()], t.prototype, "brightThreshold", void 0), Object(c.c)([Object(L.c)()], t.prototype, "blurWidth", void 0), Object(c.c)([Object(L.c)()], t.prototype, "horizontalBlur", void 0), Object(c.c)([Object(L.c)()], t.prototype, "exposure", null), Object(c.c)([Object(L.m)("lensTexture")], t.prototype, "lensTexture", void 0), Object(c.c)([Object(L.c)()], t.prototype, "volumetricLightCoefficient", void 0), Object(c.c)([Object(L.c)()], t.prototype, "volumetricLightPower", void 0), Object(c.c)([Object(L.c)()], t.prototype, "volumetricLightBlurScale", void 0), Object(c.c)([Object(L.c)()], t.prototype, "hdrMinimumLuminance", void 0), Object(c.c)([Object(L.c)()], t.prototype, "hdrDecreaseRate", void 0), Object(c.c)([Object(L.c)()], t.prototype, "hdrIncreaseRate", void 0), Object(c.c)([Object(L.c)()], t.prototype, "hdrAutoExposure", null), Object(c.c)([Object(L.m)("lensColorTexture")], t.prototype, "lensColorTexture", void 0), Object(c.c)([Object(L.c)()], t.prototype, "lensFlareStrength", void 0), Object(c.c)([Object(L.c)()], t.prototype, "lensFlareGhostDispersal", void 0), Object(c.c)([Object(L.c)()], t.prototype, "lensFlareHaloWidth", void 0), Object(c.c)([Object(L.c)()], t.prototype, "lensFlareDistortionStrength", void 0), Object(c.c)([Object(L.c)()], t.prototype, "lensFlareBlurWidth", void 0), Object(c.c)([Object(L.m)("lensStarTexture")], t.prototype, "lensStarTexture", void 0), Object(c.c)([Object(L.m)("lensFlareDirtTexture")], t.prototype, "lensFlareDirtTexture", void 0), Object(c.c)([Object(L.c)()], t.prototype, "depthOfFieldDistance", void 0), Object(c.c)([Object(L.c)()], t.prototype, "depthOfFieldBlurWidth", void 0), Object(c.c)([Object(L.c)()], t.prototype, "motionStrength", null), Object(c.c)([Object(L.c)()], t.prototype, "objectBasedMotionBlur", null), Object(c.c)([Object(L.c)()], t.prototype, "_ratio", void 0), Object(c.c)([Object(L.c)()], t.prototype, "BloomEnabled", null), Object(c.c)([Object(L.c)()], t.prototype, "DepthOfFieldEnabled", null), Object(c.c)([Object(L.c)()], t.prototype, "LensFlareEnabled", null), Object(c.c)([Object(L.c)()], t.prototype, "HDREnabled", null), Object(c.c)([Object(L.c)()], t.prototype, "VLSEnabled", null), Object(c.c)([Object(L.c)()], t.prototype, "MotionBlurEnabled", null), Object(c.c)([Object(L.c)()], t.prototype, "fxaaEnabled", null), Object(c.c)([Object(L.c)()], t.prototype, "screenSpaceReflectionsEnabled", null), Object(c.c)([Object(L.c)()], t.prototype, "volumetricLightStepsCount", null), Object(c.c)([Object(L.c)()], t.prototype, "motionBlurSamples", null), Object(c.c)([Object(L.c)()], t.prototype, "samples", null), t;
+ }(Ir);
+ O.a.RegisteredTypes["BABYLON.StandardRenderingPipeline"] = Pd;
+ var rg = `const vec3 TWO=vec3(2.0,2.0,2.0);
+varying vec2 vUV;
+uniform sampler2D camASampler;
+uniform sampler2D textureSampler;
+uniform vec2 stepSize;
+void main(void)
+{
+bool useCamA;
+bool useCamB;
+vec2 texCoord1;
+vec2 texCoord2;
+vec3 frag1;
+vec3 frag2;
+#ifdef IS_STEREOSCOPIC_HORIZ
+useCamB=vUV.x>0.5;
+useCamA=!useCamB;
+texCoord1=vec2(useCamB ? (vUV.x-0.5)*2.0 : vUV.x*2.0,vUV.y);
+texCoord2=vec2(texCoord1.x+stepSize.x,vUV.y);
+#else
+#ifdef IS_STEREOSCOPIC_INTERLACED
+float rowNum=floor(vUV.y/stepSize.y);
+useCamA=mod(rowNum,2.0) == 1.0;
+useCamB=mod(rowNum,2.0) == 0.0;
+texCoord1=vec2(vUV.x,vUV.y);
+texCoord2=vec2(vUV.x,vUV.y);
+#else
+useCamB=vUV.y>0.5;
+useCamA=!useCamB;
+texCoord1=vec2(vUV.x,useCamB ? (vUV.y-0.5)*2.0 : vUV.y*2.0);
+texCoord2=vec2(vUV.x,texCoord1.y+stepSize.y);
+#endif
+#endif
+
+if (useCamB){
+frag1=texture2D(textureSampler,texCoord1).rgb;
+frag2=texture2D(textureSampler,texCoord2).rgb;
+}else if (useCamA){
+frag1=texture2D(camASampler ,texCoord1).rgb;
+frag2=texture2D(camASampler ,texCoord2).rgb;
+}else {
+discard;
+}
+gl_FragColor=vec4((frag1+frag2)/TWO,1.0);
+}
+`;
+ ze.a.ShadersStore.stereoscopicInterlacePixelShader = rg;
+ var og = function(r) {
+ function t(e, n, i, o, a, s, d) {
+ var p = r.call(this, e, "stereoscopicInterlace", ["stepSize"], ["camASampler"], 1, n[1], a, s, d, o ? "#define IS_STEREOSCOPIC_INTERLACED 1" : i ? "#define IS_STEREOSCOPIC_HORIZ 1" : void 0) || this;
+ return p._passedProcess = n[0]._rigPostProcess, p._stepSize = new u.d(1 / p.width, 1 / p.height), p.onSizeChangedObservable.add(function() {
+ p._stepSize = new u.d(1 / p.width, 1 / p.height);
+ }), p.onApplyObservable.add(function(y) {
+ y.setTextureFromPostProcess("camASampler", p._passedProcess), y.setFloat2("stepSize", p._stepSize.x, p._stepSize.y);
+ }), p;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "StereoscopicInterlacePostProcessI";
+ }, t;
+ }(ft), ag = function(r) {
+ function t(e, n, i, o, a, s) {
+ var d = r.call(this, e, "stereoscopicInterlace", ["stepSize"], ["camASampler"], 1, n[1], o, a, s, i ? "#define IS_STEREOSCOPIC_HORIZ 1" : void 0) || this;
+ return d._passedProcess = n[0]._rigPostProcess, d._stepSize = new u.d(1 / d.width, 1 / d.height), d.onSizeChangedObservable.add(function() {
+ d._stepSize = new u.d(1 / d.width, 1 / d.height);
+ }), d.onApplyObservable.add(function(p) {
+ p.setTextureFromPostProcess("camASampler", d._passedProcess), p.setFloat2("stepSize", d._stepSize.x, d._stepSize.y);
+ }), d;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "StereoscopicInterlacePostProcess";
+ }, t;
+ }(ft), sg = `
+varying vec2 vUV;
+uniform sampler2D textureSampler;
+
+uniform float _ExposureAdjustment;
+#if defined(HABLE_TONEMAPPING)
+const float A=0.15;
+const float B=0.50;
+const float C=0.10;
+const float D=0.20;
+const float E=0.02;
+const float F=0.30;
+const float W=11.2;
+#endif
+float Luminance(vec3 c)
+{
+return dot(c,vec3(0.22,0.707,0.071));
+}
+void main(void)
+{
+vec3 colour=texture2D(textureSampler,vUV).rgb;
+#if defined(REINHARD_TONEMAPPING)
+float lum=Luminance(colour.rgb);
+float lumTm=lum*_ExposureAdjustment;
+float scale=lumTm/(1.0+lumTm);
+colour*=scale/lum;
+#elif defined(HABLE_TONEMAPPING)
+colour*=_ExposureAdjustment;
+const float ExposureBias=2.0;
+vec3 x=ExposureBias*colour;
+vec3 curr=((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;
+x=vec3(W,W,W);
+vec3 whiteScale=1.0/(((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F);
+colour=curr*whiteScale;
+#elif defined(OPTIMIZED_HEJIDAWSON_TONEMAPPING)
+colour*=_ExposureAdjustment;
+vec3 X=max(vec3(0.0,0.0,0.0),colour-0.004);
+vec3 retColor=(X*(6.2*X+0.5))/(X*(6.2*X+1.7)+0.06);
+colour=retColor*retColor;
+#elif defined(PHOTOGRAPHIC_TONEMAPPING)
+colour=vec3(1.0,1.0,1.0)-exp2(-_ExposureAdjustment*colour);
+#endif
+gl_FragColor=vec4(colour.rgb,1.0);
+}`;
+ ze.a.ShadersStore.tonemapPixelShader = sg;
+ var $i;
+ (function(r) {
+ r[r.Hable = 0] = "Hable", r[r.Reinhard = 1] = "Reinhard", r[r.HejiDawson = 2] = "HejiDawson", r[r.Photographic = 3] = "Photographic";
+ })($i || ($i = {}));
+ var cg = function(r) {
+ function t(e, n, i, o, a, s, d) {
+ a === void 0 && (a = h.a.TEXTURE_BILINEAR_SAMPLINGMODE), d === void 0 && (d = h.a.TEXTURETYPE_UNSIGNED_INT);
+ var p = r.call(this, e, "tonemap", ["_ExposureAdjustment"], null, 1, o, a, s, !0, null, d) || this;
+ p._operator = n, p.exposureAdjustment = i;
+ var y = "#define ";
+ return p._operator === $i.Hable ? y += "HABLE_TONEMAPPING" : p._operator === $i.Reinhard ? y += "REINHARD_TONEMAPPING" : p._operator === $i.HejiDawson ? y += "OPTIMIZED_HEJIDAWSON_TONEMAPPING" : p._operator === $i.Photographic && (y += "PHOTOGRAPHIC_TONEMAPPING"), p.updateEffect(y), p.onApply = function(P) {
+ P.setFloat("_ExposureAdjustment", p.exposureAdjustment);
+ }, p;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "TonemapPostProcess";
+ }, t;
+ }(ft), lg = `uniform sampler2D textureSampler;
+uniform sampler2D lightScatteringSampler;
+uniform float decay;
+uniform float exposure;
+uniform float weight;
+uniform float density;
+uniform vec2 meshPositionOnScreen;
+varying vec2 vUV;
+void main(void) {
+vec2 tc=vUV;
+vec2 deltaTexCoord=(tc-meshPositionOnScreen.xy);
+deltaTexCoord*=1.0/float(NUM_SAMPLES)*density;
+float illuminationDecay=1.0;
+vec4 color=texture2D(lightScatteringSampler,tc)*0.4;
+for(int i=0; i
+#include
+#include[0..maxSimultaneousMorphTargets]
+
+#include
+uniform mat4 viewProjection;
+uniform vec2 depthValues;
+#if defined(ALPHATEST) || defined(NEED_UV)
+varying vec2 vUV;
+uniform mat4 diffuseMatrix;
+#ifdef UV1
+attribute vec2 uv;
+#endif
+#ifdef UV2
+attribute vec2 uv2;
+#endif
+#endif
+void main(void)
+{
+vec3 positionUpdated=position;
+#if (defined(ALPHATEST) || defined(NEED_UV)) && defined(UV1)
+vec2 uvUpdated=uv;
+#endif
+#include[0..maxSimultaneousMorphTargets]
+#include
+#include
+gl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);
+#if defined(ALPHATEST) || defined(BASIC_RENDER)
+#ifdef UV1
+vUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));
+#endif
+#ifdef UV2
+vUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
+#endif
+#endif
+}
+`;
+ ze.a.ShadersStore.volumetricLightScatteringPassVertexShader = ug;
+ var hg = `#if defined(ALPHATEST) || defined(NEED_UV)
+varying vec2 vUV;
+#endif
+#if defined(ALPHATEST)
+uniform sampler2D diffuseSampler;
+#endif
+void main(void)
+{
+#if defined(ALPHATEST)
+vec4 diffuseColor=texture2D(diffuseSampler,vUV);
+if (diffuseColor.a<0.4)
+discard;
+#endif
+gl_FragColor=vec4(0.0,0.0,0.0,1.0);
+}
+`;
+ ze.a.ShadersStore.volumetricLightScatteringPassPixelShader = hg;
+ var xd = function(r) {
+ function t(e, n, i, o, a, s, d, p, y) {
+ a === void 0 && (a = 100), s === void 0 && (s = Ne.a.BILINEAR_SAMPLINGMODE);
+ var P = r.call(this, e, "volumetricLightScattering", ["decay", "exposure", "weight", "meshPositionOnScreen", "density"], ["lightScatteringSampler"], n.postProcessRatio || n, i, s, d, p, "#define NUM_SAMPLES " + a) || this;
+ return P._screenCoordinates = u.d.Zero(), P.customMeshPosition = u.e.Zero(), P.useCustomMeshPosition = !1, P.invert = !0, P.excludedMeshes = new Array(), P.exposure = 0.3, P.decay = 0.96815, P.weight = 0.58767, P.density = 0.926, d = (y = i === null ? y : i.getScene()).getEngine(), P._viewPort = new jn.a(0, 0, 1, 1).toGlobal(d.getRenderWidth(), d.getRenderHeight()), P.mesh = o !== null ? o : t.CreateDefaultMesh("VolumetricLightScatteringMesh", y), P._createPass(y, n.passRatio || n), P.onActivate = function(R) {
+ P.isSupported || P.dispose(R), P.onActivate = null;
+ }, P.onApplyObservable.add(function(R) {
+ P._updateMeshScreenCoordinates(y), R.setTexture("lightScatteringSampler", P._volumetricLightScatteringRTT), R.setFloat("exposure", P.exposure), R.setFloat("decay", P.decay), R.setFloat("weight", P.weight), R.setFloat("density", P.density), R.setVector2("meshPositionOnScreen", P._screenCoordinates);
+ }), P;
+ }
+ return Object(c.d)(t, r), Object.defineProperty(t.prototype, "useDiffuseColor", { get: function() {
+ return l.a.Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead"), !1;
+ }, set: function(e) {
+ l.a.Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
+ }, enumerable: !1, configurable: !0 }), t.prototype.getClassName = function() {
+ return "VolumetricLightScatteringPostProcess";
+ }, t.prototype._isReady = function(e, n) {
+ var i = e.getMesh();
+ if (i === this.mesh && i.material)
+ return i.material.isReady(i);
+ var o = [], a = [Oe.b.PositionKind], s = e.getMaterial();
+ s && (s.needAlphaTesting() && o.push("#define ALPHATEST"), i.isVerticesDataPresent(Oe.b.UVKind) && (a.push(Oe.b.UVKind), o.push("#define UV1")), i.isVerticesDataPresent(Oe.b.UV2Kind) && (a.push(Oe.b.UV2Kind), o.push("#define UV2"))), i.useBones && i.computeBonesUsingShaders ? (a.push(Oe.b.MatricesIndicesKind), a.push(Oe.b.MatricesWeightsKind), o.push("#define NUM_BONE_INFLUENCERS " + i.numBoneInfluencers), o.push("#define BonesPerMesh " + (i.skeleton ? i.skeleton.bones.length + 1 : 0))) : o.push("#define NUM_BONE_INFLUENCERS 0"), n && (o.push("#define INSTANCES"), $e.a.PushAttributesForInstances(a), e.getRenderingMesh().hasThinInstances && o.push("#define THIN_INSTANCES"));
+ var d = o.join(`
+`);
+ return this._cachedDefines !== d && (this._cachedDefines = d, this._volumetricLightScatteringPass = i.getScene().getEngine().createEffect("volumetricLightScatteringPass", a, ["world", "mBones", "viewProjection", "diffuseMatrix"], ["diffuseSampler"], d, void 0, void 0, void 0, { maxSimultaneousMorphTargets: i.numBoneInfluencers })), this._volumetricLightScatteringPass.isReady();
+ }, t.prototype.setCustomMeshPosition = function(e) {
+ this.customMeshPosition = e;
+ }, t.prototype.getCustomMeshPosition = function() {
+ return this.customMeshPosition;
+ }, t.prototype.dispose = function(e) {
+ var n = e.getScene().customRenderTargets.indexOf(this._volumetricLightScatteringRTT);
+ n !== -1 && e.getScene().customRenderTargets.splice(n, 1), this._volumetricLightScatteringRTT.dispose(), r.prototype.dispose.call(this, e);
+ }, t.prototype.getPass = function() {
+ return this._volumetricLightScatteringRTT;
+ }, t.prototype._meshExcluded = function(e) {
+ return this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(e) !== -1;
+ }, t.prototype._createPass = function(e, n) {
+ var i = this, o = e.getEngine();
+ this._volumetricLightScatteringRTT = new on("volumetricLightScatteringMap", { width: o.getRenderWidth() * n, height: o.getRenderHeight() * n }, e, !1, !0, h.a.TEXTURETYPE_UNSIGNED_INT), this._volumetricLightScatteringRTT.wrapU = Ne.a.CLAMP_ADDRESSMODE, this._volumetricLightScatteringRTT.wrapV = Ne.a.CLAMP_ADDRESSMODE, this._volumetricLightScatteringRTT.renderList = null, this._volumetricLightScatteringRTT.renderParticles = !1, this._volumetricLightScatteringRTT.ignoreCameraViewport = !0;
+ var a = this.getCamera();
+ a ? a.customRenderTargets.push(this._volumetricLightScatteringRTT) : e.customRenderTargets.push(this._volumetricLightScatteringRTT);
+ var s, d = function(y) {
+ var P = y.getRenderingMesh(), R = y.getEffectiveMesh();
+ if (!i._meshExcluded(P)) {
+ R._internalAbstractMeshDataInfo._isActiveIntermediate = !1;
+ var B = y.getMaterial();
+ if (B) {
+ var F = P.getScene(), z = F.getEngine();
+ z.setState(B.backFaceCulling);
+ var J = P._getInstancesRenderList(y._id, !!y.getReplacementMesh());
+ if (!J.mustReturn) {
+ var ie = z.getCaps().instancedArrays && (J.visibleInstances[y._id] !== null || P.hasThinInstances);
+ if (i._isReady(y, ie)) {
+ var se = i._volumetricLightScatteringPass;
+ if (P === i.mesh && (se = y.effect ? y.effect : B.getEffect()), z.enableEffect(se), P._bind(y, se, B.fillMode), P === i.mesh)
+ B.bind(R.getWorldMatrix(), P);
+ else {
+ if (i._volumetricLightScatteringPass.setMatrix("viewProjection", F.getTransformMatrix()), B && B.needAlphaTesting()) {
+ var ce = B.getAlphaTestTexture();
+ i._volumetricLightScatteringPass.setTexture("diffuseSampler", ce), ce && i._volumetricLightScatteringPass.setMatrix("diffuseMatrix", ce.getTextureMatrix());
+ }
+ P.useBones && P.computeBonesUsingShaders && P.skeleton && i._volumetricLightScatteringPass.setMatrices("mBones", P.skeleton.getTransformMatrices(P));
+ }
+ P._processRendering(R, y, i._volumetricLightScatteringPass, zt.a.TriangleFillMode, J, ie, function(ue, fe) {
+ return se.setMatrix("world", fe);
+ });
+ }
+ }
+ }
+ }
+ }, p = new I.b(0, 0, 0, 1);
+ this._volumetricLightScatteringRTT.onBeforeRenderObservable.add(function() {
+ s = e.clearColor, e.clearColor = p;
+ }), this._volumetricLightScatteringRTT.onAfterRenderObservable.add(function() {
+ e.clearColor = s;
+ }), this._volumetricLightScatteringRTT.customRenderFunction = function(y, P, R, B) {
+ var F, z = e.getEngine();
+ if (B.length) {
+ for (z.setColorWrite(!1), F = 0; F < B.length; F++)
+ d(B.data[F]);
+ z.setColorWrite(!0);
+ }
+ for (F = 0; F < y.length; F++)
+ d(y.data[F]);
+ for (F = 0; F < P.length; F++)
+ d(P.data[F]);
+ if (R.length) {
+ for (F = 0; F < R.length; F++) {
+ var J = R.data[F], ie = J.getBoundingInfo();
+ ie && e.activeCamera && (J._alphaIndex = J.getMesh().alphaIndex, J._distanceToCamera = ie.boundingSphere.centerWorld.subtract(e.activeCamera.position).length());
+ }
+ var se = R.data.slice(0, R.length);
+ for (se.sort(function(ce, ue) {
+ return ce._alphaIndex > ue._alphaIndex ? 1 : ce._alphaIndex < ue._alphaIndex ? -1 : ce._distanceToCamera < ue._distanceToCamera ? 1 : ce._distanceToCamera > ue._distanceToCamera ? -1 : 0;
+ }), z.setAlphaMode(h.a.ALPHA_COMBINE), F = 0; F < se.length; F++)
+ d(se[F]);
+ z.setAlphaMode(h.a.ALPHA_DISABLE);
+ }
+ };
+ }, t.prototype._updateMeshScreenCoordinates = function(e) {
+ var n, i = e.getTransformMatrix();
+ n = this.useCustomMeshPosition ? this.customMeshPosition : this.attachedNode ? this.attachedNode.position : this.mesh.parent ? this.mesh.getAbsolutePosition() : this.mesh.position;
+ var o = u.e.Project(n, u.a.Identity(), i, this._viewPort);
+ this._screenCoordinates.x = o.x / this._viewPort.width, this._screenCoordinates.y = o.y / this._viewPort.height, this.invert && (this._screenCoordinates.y = 1 - this._screenCoordinates.y);
+ }, t.CreateDefaultMesh = function(e, n) {
+ var i = Ie.a.CreatePlane(e, 1, n);
+ i.billboardMode = Mt.a.BILLBOARDMODE_ALL;
+ var o = new Nt.a(e + "Material", n);
+ return o.emissiveColor = new I.a(1, 1, 1), i.material = o, i;
+ }, Object(c.c)([Object(L.o)()], t.prototype, "customMeshPosition", void 0), Object(c.c)([Object(L.c)()], t.prototype, "useCustomMeshPosition", void 0), Object(c.c)([Object(L.c)()], t.prototype, "invert", void 0), Object(c.c)([Object(L.k)()], t.prototype, "mesh", void 0), Object(c.c)([Object(L.c)()], t.prototype, "excludedMeshes", void 0), Object(c.c)([Object(L.c)()], t.prototype, "exposure", void 0), Object(c.c)([Object(L.c)()], t.prototype, "decay", void 0), Object(c.c)([Object(L.c)()], t.prototype, "weight", void 0), Object(c.c)([Object(L.c)()], t.prototype, "density", void 0), t;
+ }(ft);
+ O.a.RegisteredTypes["BABYLON.VolumetricLightScatteringPostProcess"] = xd;
+ var dg = `
+
+precision highp float;
+
+varying vec2 vUV;
+uniform sampler2D textureSampler;
+uniform sampler2D normalSampler;
+uniform float curvature_ridge;
+uniform float curvature_valley;
+#ifndef CURVATURE_OFFSET
+#define CURVATURE_OFFSET 1
+#endif
+float curvature_soft_clamp(float curvature,float control)
+{
+if (curvature<0.5/control)
+return curvature*(1.0-curvature*control);
+return 0.25/control;
+}
+float calculate_curvature(ivec2 texel,float ridge,float valley)
+{
+vec2 normal_up=texelFetchOffset(normalSampler,texel,0,ivec2(0,CURVATURE_OFFSET)).rb;
+vec2 normal_down=texelFetchOffset(normalSampler,texel,0,ivec2(0,-CURVATURE_OFFSET)).rb;
+vec2 normal_left=texelFetchOffset(normalSampler,texel,0,ivec2(-CURVATURE_OFFSET,0)).rb;
+vec2 normal_right=texelFetchOffset(normalSampler,texel,0,ivec2( CURVATURE_OFFSET,0)).rb;
+float normal_diff=((normal_up.g-normal_down.g)+(normal_right.r-normal_left.r));
+if (normal_diff<0.0)
+return -2.0*curvature_soft_clamp(-normal_diff,valley);
+return 2.0*curvature_soft_clamp(normal_diff,ridge);
+}
+void main(void)
+{
+ivec2 texel=ivec2(gl_FragCoord.xy);
+vec4 baseColor=texture2D(textureSampler,vUV);
+float curvature=calculate_curvature(texel,curvature_ridge,curvature_valley);
+baseColor.rgb*=curvature+1.0;
+gl_FragColor=baseColor;
+}`;
+ ze.a.ShadersStore.screenSpaceCurvaturePixelShader = dg;
+ var Cd = function(r) {
+ function t(e, n, i, o, a, s, d, p, y) {
+ p === void 0 && (p = h.a.TEXTURETYPE_UNSIGNED_INT), y === void 0 && (y = !1);
+ var P = r.call(this, e, "screenSpaceCurvature", ["curvature_ridge", "curvature_valley"], ["textureSampler", "normalSampler"], i, o, a, s, d, void 0, p, void 0, null, y) || this;
+ return P.ridge = 1, P.valley = 1, P._geometryBufferRenderer = n.enableGeometryBufferRenderer(), P._geometryBufferRenderer ? P.onApply = function(R) {
+ R.setFloat("curvature_ridge", 0.5 / Math.max(P.ridge * P.ridge, 1e-4)), R.setFloat("curvature_valley", 0.7 / Math.max(P.valley * P.valley, 1e-4));
+ var B = P._geometryBufferRenderer.getGBuffer().textures[1];
+ R.setTexture("normalSampler", B);
+ } : l.a.Error("Multiple Render Target support needed for screen space curvature post process. Please use IsSupported test first."), P;
+ }
+ return Object(c.d)(t, r), t.prototype.getClassName = function() {
+ return "ScreenSpaceCurvaturePostProcess";
+ }, Object.defineProperty(t, "IsSupported", { get: function() {
+ var e = te.a.LastCreatedEngine;
+ return !!e && (e.webGLVersion > 1 || e.getCaps().drawBuffersExtension);
+ }, enumerable: !1, configurable: !0 }), t._Parse = function(e, n, i, o) {
+ return L.a.Parse(function() {
+ return new t(e.name, i, e.options, n, e.renderTargetSamplingMode, i.getEngine(), e.textureType, e.reusable);
+ }, e, i, o);
+ }, Object(c.c)([Object(L.c)()], t.prototype, "ridge", void 0), Object(c.c)([Object(L.c)()], t.prototype, "valley", void 0), t;
+ }(ft);
+ O.a.RegisteredTypes["BABYLON.ScreenSpaceCurvaturePostProcess"] = Cd, f(166), f(167), Object.defineProperty(_e.a.prototype, "forceShowBoundingBoxes", { get: function() {
+ return this._forceShowBoundingBoxes || !1;
+ }, set: function(r) {
+ this._forceShowBoundingBoxes = r, r && this.getBoundingBoxRenderer();
+ }, enumerable: !0, configurable: !0 }), _e.a.prototype.getBoundingBoxRenderer = function() {
+ return this._boundingBoxRenderer || (this._boundingBoxRenderer = new Rd(this)), this._boundingBoxRenderer;
+ }, Object.defineProperty(Mt.a.prototype, "showBoundingBox", { get: function() {
+ return this._showBoundingBox || !1;
+ }, set: function(r) {
+ this._showBoundingBox = r, r && this.getScene().getBoundingBoxRenderer();
+ }, enumerable: !0, configurable: !0 });
+ var Rd = function() {
+ function r(t) {
+ this.name = ot.a.NAME_BOUNDINGBOXRENDERER, this.frontColor = new I.a(1, 1, 1), this.backColor = new I.a(0.1, 0.1, 0.1), this.showBackLines = !0, this.onBeforeBoxRenderingObservable = new C.c(), this.onAfterBoxRenderingObservable = new C.c(), this.onResourcesReadyObservable = new C.c(), this.enabled = !0, this.renderList = new si.a(32), this._vertexBuffers = {}, this._fillIndexBuffer = null, this._fillIndexData = null, this.scene = t, t._addComponent(this);
+ }
+ return r.prototype.register = function() {
+ this.scene._beforeEvaluateActiveMeshStage.registerStep(ot.a.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER, this, this.reset), this.scene._preActiveMeshStage.registerStep(ot.a.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER, this, this._preActiveMesh), this.scene._evaluateSubMeshStage.registerStep(ot.a.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER, this, this._evaluateSubMesh), this.scene._afterRenderingGroupDrawStage.registerStep(ot.a.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER, this, this.render);
+ }, r.prototype._evaluateSubMesh = function(t, e) {
+ if (t.showSubMeshesBoundingBox) {
+ var n = e.getBoundingInfo();
+ n != null && (n.boundingBox._tag = t.renderingGroupId, this.renderList.push(n.boundingBox));
+ }
+ }, r.prototype._preActiveMesh = function(t) {
+ if (t.showBoundingBox || this.scene.forceShowBoundingBoxes) {
+ var e = t.getBoundingInfo();
+ e.boundingBox._tag = t.renderingGroupId, this.renderList.push(e.boundingBox);
+ }
+ }, r.prototype._prepareResources = function() {
+ if (!this._colorShader) {
+ this._colorShader = new ea.a("colorShader", this.scene, "color", { attributes: [Oe.b.PositionKind], uniforms: ["world", "viewProjection", "color"] }), this._colorShader.reservedDataStore = { hidden: !0 };
+ var t = this.scene.getEngine(), e = ht.a.CreateBox({ size: 1 });
+ this._vertexBuffers[Oe.b.PositionKind] = new Oe.b(t, e.positions, Oe.b.PositionKind, !1), this._createIndexBuffer(), this._fillIndexData = e.indices, this.onResourcesReadyObservable.notifyObservers(this);
+ }
+ }, r.prototype._createIndexBuffer = function() {
+ var t = this.scene.getEngine();
+ this._indexBuffer = t.createIndexBuffer([0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 7, 1, 6, 2, 5, 3, 4]);
+ }, r.prototype.rebuild = function() {
+ var t = this._vertexBuffers[Oe.b.PositionKind];
+ t && t._rebuild(), this._createIndexBuffer();
+ }, r.prototype.reset = function() {
+ this.renderList.reset();
+ }, r.prototype.render = function(t) {
+ if (this.renderList.length !== 0 && this.enabled && (this._prepareResources(), this._colorShader.isReady())) {
+ var e = this.scene.getEngine();
+ e.setDepthWrite(!1), this._colorShader._preBind();
+ for (var n = 0; n < this.renderList.length; n++) {
+ var i = this.renderList.data[n];
+ if (i._tag === t) {
+ this.onBeforeBoxRenderingObservable.notifyObservers(i);
+ var o = i.minimum, a = i.maximum.subtract(o), s = o.add(a.scale(0.5)), d = u.a.Scaling(a.x, a.y, a.z).multiply(u.a.Translation(s.x, s.y, s.z)).multiply(i.getWorldMatrix());
+ e.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect()), this.showBackLines && (e.setDepthFunctionToGreaterOrEqual(), this.scene.resetCachedMaterial(), this._colorShader.setColor4("color", this.backColor.toColor4()), this._colorShader.bind(d), e.drawElementsType(zt.a.LineListDrawMode, 0, 24)), e.setDepthFunctionToLess(), this.scene.resetCachedMaterial(), this._colorShader.setColor4("color", this.frontColor.toColor4()), this._colorShader.bind(d), e.drawElementsType(zt.a.LineListDrawMode, 0, 24), this.onAfterBoxRenderingObservable.notifyObservers(i);
+ }
+ }
+ this._colorShader.unbind(), e.setDepthFunctionToLessOrEqual(), e.setDepthWrite(!0);
+ }
+ }, r.prototype.renderOcclusionBoundingBox = function(t) {
+ if (this._prepareResources(), this._colorShader.isReady() && t._boundingInfo) {
+ var e = this.scene.getEngine();
+ this._fillIndexBuffer || (this._fillIndexBuffer = e.createIndexBuffer(this._fillIndexData)), e.setDepthWrite(!1), e.setColorWrite(!1), this._colorShader._preBind();
+ var n = t._boundingInfo.boundingBox, i = n.minimum, o = n.maximum.subtract(i), a = i.add(o.scale(0.5)), s = u.a.Scaling(o.x, o.y, o.z).multiply(u.a.Translation(a.x, a.y, a.z)).multiply(n.getWorldMatrix());
+ e.bindBuffers(this._vertexBuffers, this._fillIndexBuffer, this._colorShader.getEffect()), e.setDepthFunctionToLess(), this.scene.resetCachedMaterial(), this._colorShader.bind(s), e.drawElementsType(zt.a.TriangleFillMode, 0, 36), this._colorShader.unbind(), e.setDepthFunctionToLessOrEqual(), e.setDepthWrite(!0), e.setColorWrite(!0);
+ }
+ }, r.prototype.dispose = function() {
+ if (this._colorShader) {
+ this.onBeforeBoxRenderingObservable.clear(), this.onAfterBoxRenderingObservable.clear(), this.onResourcesReadyObservable.clear(), this.renderList.dispose(), this._colorShader.dispose();
+ var t = this._vertexBuffers[Oe.b.PositionKind];
+ t && (t.dispose(), this._vertexBuffers[Oe.b.PositionKind] = null), this.scene.getEngine()._releaseBuffer(this._indexBuffer), this._fillIndexBuffer && (this.scene.getEngine()._releaseBuffer(this._fillIndexBuffer), this._fillIndexBuffer = null);
+ }
+ }, r;
+ }();
+ _e.a.prototype.enableDepthRenderer = function(r, t, e) {
+ if (t === void 0 && (t = !1), e === void 0 && (e = !1), !(r = r || this.activeCamera))
+ throw "No camera available to enable depth renderer";
+ if (this._depthRenderer || (this._depthRenderer = {}), !this._depthRenderer[r.id]) {
+ var n = !!this.getEngine().getCaps().textureFloatRender, i = 0;
+ i = !this.getEngine().getCaps().textureHalfFloatRender || e && n ? n ? h.a.TEXTURETYPE_FLOAT : h.a.TEXTURETYPE_UNSIGNED_BYTE : h.a.TEXTURETYPE_HALF_FLOAT, this._depthRenderer[r.id] = new Qo(this, i, r, t);
+ }
+ return this._depthRenderer[r.id];
+ }, _e.a.prototype.disableDepthRenderer = function(r) {
+ (r = r || this.activeCamera) && this._depthRenderer && this._depthRenderer[r.id] && (this._depthRenderer[r.id].dispose(), delete this._depthRenderer[r.id]);
+ };
+ var Od = function() {
+ function r(t) {
+ this.name = ot.a.NAME_DEPTHRENDERER, this.scene = t;
+ }
+ return r.prototype.register = function() {
+ this.scene._gatherRenderTargetsStage.registerStep(ot.a.STEP_GATHERRENDERTARGETS_DEPTHRENDERER, this, this._gatherRenderTargets), this.scene._gatherActiveCameraRenderTargetsStage.registerStep(ot.a.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER, this, this._gatherActiveCameraRenderTargets);
+ }, r.prototype.rebuild = function() {
+ }, r.prototype.dispose = function() {
+ for (var t in this.scene._depthRenderer)
+ this.scene._depthRenderer[t].dispose();
+ }, r.prototype._gatherRenderTargets = function(t) {
+ if (this.scene._depthRenderer)
+ for (var e in this.scene._depthRenderer) {
+ var n = this.scene._depthRenderer[e];
+ n.enabled && !n.useOnlyInActiveCamera && t.push(n.getDepthMap());
+ }
+ }, r.prototype._gatherActiveCameraRenderTargets = function(t) {
+ if (this.scene._depthRenderer)
+ for (var e in this.scene._depthRenderer) {
+ var n = this.scene._depthRenderer[e];
+ n.enabled && n.useOnlyInActiveCamera && this.scene.activeCamera.id === e && t.push(n.getDepthMap());
+ }
+ }, r;
+ }();
+ Qo._SceneComponentInitialization = function(r) {
+ var t = r._getComponent(ot.a.NAME_DEPTHRENDERER);
+ t || (t = new Od(r), r._addComponent(t));
+ }, ze.a.ShadersStore.linePixelShader = `uniform vec4 color;
+void main(void) {
+gl_FragColor=color;
+}`;
+ var fg = `#include
+
+attribute vec3 position;
+attribute vec4 normal;
+
+uniform mat4 viewProjection;
+uniform float width;
+uniform float aspectRatio;
+void main(void) {
+#include
+mat4 worldViewProjection=viewProjection*finalWorld;
+vec4 viewPosition=worldViewProjection*vec4(position,1.0);
+vec4 viewPositionNext=worldViewProjection*vec4(normal.xyz,1.0);
+vec2 currentScreen=viewPosition.xy/viewPosition.w;
+vec2 nextScreen=viewPositionNext.xy/viewPositionNext.w;
+currentScreen.x*=aspectRatio;
+nextScreen.x*=aspectRatio;
+vec2 dir=normalize(nextScreen-currentScreen);
+vec2 normalDir=vec2(-dir.y,dir.x);
+normalDir*=width/2.0;
+normalDir.x/=aspectRatio;
+vec4 offset=vec4(normalDir*normal.w,0.0,0.0);
+gl_Position=viewPosition+offset;
+}`;
+ ze.a.ShadersStore.lineVertexShader = fg, Mt.a.prototype.disableEdgesRendering = function() {
+ return this._edgesRenderer && (this._edgesRenderer.dispose(), this._edgesRenderer = null), this;
+ }, Mt.a.prototype.enableEdgesRendering = function(r, t, e) {
+ return r === void 0 && (r = 0.95), t === void 0 && (t = !1), this.disableEdgesRendering(), this._edgesRenderer = new Lc(this, r, t, !0, e), this;
+ }, Object.defineProperty(Mt.a.prototype, "edgesRenderer", { get: function() {
+ return this._edgesRenderer;
+ }, enumerable: !0, configurable: !0 }), ho.b.prototype.enableEdgesRendering = function(r, t) {
+ return r === void 0 && (r = 0.95), t === void 0 && (t = !1), this.disableEdgesRendering(), this._edgesRenderer = new Md(this, r, t), this;
+ }, ho.a.prototype.enableEdgesRendering = function(r, t) {
+ return r === void 0 && (r = 0.95), t === void 0 && (t = !1), ho.b.prototype.enableEdgesRendering.apply(this, arguments), this;
+ };
+ var pg = function() {
+ this.edges = new Array(), this.edgesConnectedCount = 0;
+ }, Lc = function() {
+ function r(t, e, n, i, o) {
+ var a, s = this;
+ e === void 0 && (e = 0.95), n === void 0 && (n = !1), i === void 0 && (i = !0), this.edgesWidthScalerForOrthographic = 1e3, this.edgesWidthScalerForPerspective = 50, this._linesPositions = new Array(), this._linesNormals = new Array(), this._linesIndices = new Array(), this._buffers = {}, this._buffersForInstances = {}, this._checkVerticesInsteadOfIndices = !1, this.isEnabled = !0, this.customInstances = new si.a(32), this._source = t, this._checkVerticesInsteadOfIndices = n, this._options = o ?? null, this._epsilon = e, this._prepareRessources(), i && ((a = o == null ? void 0 : o.useAlternateEdgeFinder) === null || a === void 0 || a ? this._generateEdgesLinesAlternate() : this._generateEdgesLines()), this._meshRebuildObserver = this._source.onRebuildObservable.add(function() {
+ s._rebuild();
+ }), this._meshDisposeObserver = this._source.onDisposeObservable.add(function() {
+ s.dispose();
+ });
+ }
+ return Object.defineProperty(r.prototype, "linesPositions", { get: function() {
+ return this._linesPositions;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "linesNormals", { get: function() {
+ return this._linesNormals;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "linesIndices", { get: function() {
+ return this._linesIndices;
+ }, enumerable: !1, configurable: !0 }), r.GetShader = function(t) {
+ if (!t._edgeRenderLineShader) {
+ var e = new ea.a("lineShader", t, "line", { attributes: ["position", "normal"], uniforms: ["world", "viewProjection", "color", "width", "aspectRatio"] });
+ e.disableDepthWrite = !0, e.backFaceCulling = !1, t._edgeRenderLineShader = e;
+ }
+ return t._edgeRenderLineShader;
+ }, r.prototype._prepareRessources = function() {
+ this._lineShader || (this._lineShader = r.GetShader(this._source.getScene()));
+ }, r.prototype._rebuild = function() {
+ var t = this._buffers[Oe.b.PositionKind];
+ t && t._rebuild(), (t = this._buffers[Oe.b.NormalKind]) && t._rebuild();
+ var e = this._source.getScene().getEngine();
+ this._ib = e.createIndexBuffer(this._linesIndices);
+ }, r.prototype.dispose = function() {
+ this._source.onRebuildObservable.remove(this._meshRebuildObserver), this._source.onDisposeObservable.remove(this._meshDisposeObserver);
+ var t = this._buffers[Oe.b.PositionKind];
+ t && (t.dispose(), this._buffers[Oe.b.PositionKind] = null), (t = this._buffers[Oe.b.NormalKind]) && (t.dispose(), this._buffers[Oe.b.NormalKind] = null), this._ib && this._source.getScene().getEngine()._releaseBuffer(this._ib), this._lineShader.dispose();
+ }, r.prototype._processEdgeForAdjacencies = function(t, e, n, i, o) {
+ return t === n && e === i || t === i && e === n ? 0 : t === i && e === o || t === o && e === i ? 1 : t === o && e === n || t === n && e === o ? 2 : -1;
+ }, r.prototype._processEdgeForAdjacenciesWithVertices = function(t, e, n, i, o) {
+ var a = 1e-10;
+ return t.equalsWithEpsilon(n, a) && e.equalsWithEpsilon(i, a) || t.equalsWithEpsilon(i, a) && e.equalsWithEpsilon(n, a) ? 0 : t.equalsWithEpsilon(i, a) && e.equalsWithEpsilon(o, a) || t.equalsWithEpsilon(o, a) && e.equalsWithEpsilon(i, a) ? 1 : t.equalsWithEpsilon(o, a) && e.equalsWithEpsilon(n, a) || t.equalsWithEpsilon(n, a) && e.equalsWithEpsilon(o, a) ? 2 : -1;
+ }, r.prototype._checkEdge = function(t, e, n, i, o) {
+ var a;
+ e === void 0 ? a = !0 : a = u.e.Dot(n[t], n[e]) < this._epsilon, a && this.createLine(i, o, this._linesPositions.length / 3);
+ }, r.prototype.createLine = function(t, e, n) {
+ this._linesPositions.push(t.x, t.y, t.z, t.x, t.y, t.z, e.x, e.y, e.z, e.x, e.y, e.z), this._linesNormals.push(e.x, e.y, e.z, -1, e.x, e.y, e.z, 1, t.x, t.y, t.z, -1, t.x, t.y, t.z, 1), this._linesIndices.push(n, n + 1, n + 2, n, n + 2, n + 3);
+ }, r.prototype._tessellateTriangle = function(t, e, n, i) {
+ var o = function(Ae, Ee, Se) {
+ Se >= 0 && Ee.push(Se);
+ for (var De = 0; De < Ae.length; ++De)
+ Ee.push(Ae[De][0]);
+ }, a = 0;
+ t[1].length >= t[0].length && t[1].length >= t[2].length ? a = 1 : t[2].length >= t[0].length && t[2].length >= t[1].length && (a = 2);
+ for (var s = 0; s < 3; ++s)
+ s === a ? t[s].sort(function(Ae, Ee) {
+ return Ae[1] < Ee[1] ? -1 : Ae[1] > Ee[1] ? 1 : 0;
+ }) : t[s].sort(function(Ae, Ee) {
+ return Ae[1] > Ee[1] ? -1 : Ae[1] < Ee[1] ? 1 : 0;
+ });
+ var d = [], p = [];
+ o(t[a], d, -1);
+ for (var y = d.length, P = a + 2; P >= a + 1; --P)
+ o(t[P % 3], p, P !== a + 2 ? i[n[e + (P + 1) % 3]] : -1);
+ var R = p.length;
+ n.push(i[n[e + a]], d[0], p[0]), n.push(i[n[e + (a + 1) % 3]], p[R - 1], d[y - 1]);
+ for (var B = y <= R, F = B ? y : R, z = B ? R : y, J = B ? y - 1 : R - 1, ie = B ? 0 : 1, se = y + R - 2, ce = 0, ue = 0, fe = B ? d : p, ve = B ? p : d, Te = 0; se-- > 0; ) {
+ ie ? n.push(fe[ce], ve[ue]) : n.push(ve[ue], fe[ce]);
+ var Re = void 0;
+ (Te += F) >= z && ce < J ? (Re = fe[++ce], Te -= z) : Re = ve[++ue], n.push(Re);
+ }
+ n[e + 0] = n[n.length - 3], n[e + 1] = n[n.length - 2], n[e + 2] = n[n.length - 1], n.length = n.length - 3;
+ }, r.prototype._generateEdgesLinesAlternate = function() {
+ var t, e, n, i, o, a, s, d, p, y = this._source.getVerticesData(Oe.b.PositionKind), P = this._source.getIndices();
+ if (P && y) {
+ Array.isArray(P) || (P = Xe.b.SliceToArray(P));
+ var R = (e = (t = this._options) === null || t === void 0 ? void 0 : t.useFastVertexMerger) === null || e === void 0 || e, B = R ? Math.round(-Math.log((i = (n = this._options) === null || n === void 0 ? void 0 : n.epsilonVertexMerge) !== null && i !== void 0 ? i : 1e-6) / Math.log(10)) : (a = (o = this._options) === null || o === void 0 ? void 0 : o.epsilonVertexMerge) !== null && a !== void 0 ? a : 1e-6, F = [], z = [];
+ if (R)
+ for (var J = {}, ie = 0; ie < y.length; ie += 3) {
+ var se = y[ie + 0], ce = y[ie + 1], ue = y[ie + 2];
+ if (J[Rt = se.toFixed(B) + "|" + ce.toFixed(B) + "|" + ue.toFixed(B)] !== void 0)
+ F.push(J[Rt]);
+ else {
+ var fe = ie / 3;
+ J[Rt] = fe, F.push(fe), z.push(fe);
+ }
+ }
+ else
+ for (ie = 0; ie < y.length; ie += 3) {
+ se = y[ie + 0], ce = y[ie + 1], ue = y[ie + 2];
+ for (var ve = !1, Te = 0; Te < ie && !ve; Te += 3) {
+ var Re = y[Te + 0], Ae = y[Te + 1], Ee = y[Te + 2];
+ if (Math.abs(se - Re) < B && Math.abs(ce - Ae) < B && Math.abs(ue - Ee) < B) {
+ F.push(Te / 3), ve = !0;
+ break;
+ }
+ }
+ ve || (F.push(ie / 3), z.push(ie / 3));
+ }
+ if (!((s = this._options) === null || s === void 0) && s.applyTessellation) {
+ for (var Se = (p = (d = this._options) === null || d === void 0 ? void 0 : d.epsilonVertexAligned) !== null && p !== void 0 ? p : 1e-6, De = [], xe = 0; xe < P.length; xe += 3)
+ for (var Le = void 0, Me = 0; Me < 3; ++Me) {
+ var we = F[P[xe + Me]], Ye = F[P[xe + (Me + 1) % 3]], et = F[P[xe + (Me + 2) % 3]];
+ if (we !== Ye)
+ for (var nt = y[3 * we + 0], ct = y[3 * we + 1], Ke = y[3 * we + 2], rt = y[3 * Ye + 0], it = y[3 * Ye + 1], qe = y[3 * Ye + 2], ut = Math.sqrt((rt - nt) * (rt - nt) + (it - ct) * (it - ct) + (qe - Ke) * (qe - Ke)), Ve = 0; Ve < z.length - 1; Ve++) {
+ var Ze = z[Ve];
+ if (Ze !== we && Ze !== Ye && Ze !== et) {
+ var vt = y[3 * Ze + 0], jt = y[3 * Ze + 1], Dt = y[3 * Ze + 2], Yt = Math.sqrt((vt - nt) * (vt - nt) + (jt - ct) * (jt - ct) + (Dt - Ke) * (Dt - Ke)), mt = Math.sqrt((vt - rt) * (vt - rt) + (jt - it) * (jt - it) + (Dt - qe) * (Dt - qe));
+ Math.abs(Yt + mt - ut) < Se && (Le || (Le = { index: xe, edgesPoints: [[], [], []] }, De.push(Le)), Le.edgesPoints[Me].push([Ze, Yt]));
+ }
+ }
+ }
+ for (var qt = 0; qt < De.length; ++qt) {
+ var Ht = De[qt];
+ this._tessellateTriangle(Ht.edgesPoints, Ht.index, P, F);
+ }
+ De = null;
+ }
+ var kt = {};
+ for (xe = 0; xe < P.length; xe += 3) {
+ var Wt = void 0;
+ for (Me = 0; Me < 3; ++Me)
+ if (we = F[P[xe + Me]], Ye = F[P[xe + (Me + 1) % 3]], et = F[P[xe + (Me + 2) % 3]], we !== Ye) {
+ if (u.c.Vector3[0].copyFromFloats(y[3 * we + 0], y[3 * we + 1], y[3 * we + 2]), u.c.Vector3[1].copyFromFloats(y[3 * Ye + 0], y[3 * Ye + 1], y[3 * Ye + 2]), u.c.Vector3[2].copyFromFloats(y[3 * et + 0], y[3 * et + 1], y[3 * et + 2]), Wt || (u.c.Vector3[1].subtractToRef(u.c.Vector3[0], u.c.Vector3[3]), u.c.Vector3[2].subtractToRef(u.c.Vector3[1], u.c.Vector3[4]), (Wt = u.e.Cross(u.c.Vector3[3], u.c.Vector3[4])).normalize()), we > Ye) {
+ var bt = we;
+ we = Ye, Ye = bt;
+ }
+ (Zt = kt[Rt = we + "_" + Ye]) ? Zt.done || (u.e.Dot(Wt, Zt.normal) < this._epsilon && this.createLine(u.c.Vector3[0], u.c.Vector3[1], this._linesPositions.length / 3), Zt.done = !0) : kt[Rt] = { normal: Wt, done: !1, index: xe, i: Me };
+ }
+ }
+ for (var Rt in kt) {
+ var Zt;
+ (Zt = kt[Rt]).done || (we = F[P[Zt.index + Zt.i]], Ye = F[P[Zt.index + (Zt.i + 1) % 3]], u.c.Vector3[0].copyFromFloats(y[3 * we + 0], y[3 * we + 1], y[3 * we + 2]), u.c.Vector3[1].copyFromFloats(y[3 * Ye + 0], y[3 * Ye + 1], y[3 * Ye + 2]), this.createLine(u.c.Vector3[0], u.c.Vector3[1], this._linesPositions.length / 3));
+ }
+ var Mn = this._source.getScene().getEngine();
+ this._buffers[Oe.b.PositionKind] = new Oe.b(Mn, this._linesPositions, Oe.b.PositionKind, !1), this._buffers[Oe.b.NormalKind] = new Oe.b(Mn, this._linesNormals, Oe.b.NormalKind, !1, !1, 4), this._buffersForInstances[Oe.b.PositionKind] = this._buffers[Oe.b.PositionKind], this._buffersForInstances[Oe.b.NormalKind] = this._buffers[Oe.b.NormalKind], this._ib = Mn.createIndexBuffer(this._linesIndices), this._indicesCount = this._linesIndices.length;
+ }
+ }, r.prototype._generateEdgesLines = function() {
+ var t = this._source.getVerticesData(Oe.b.PositionKind), e = this._source.getIndices();
+ if (e && t) {
+ var n, i, o = new Array(), a = new Array();
+ for (n = 0; n < e.length; n += 3) {
+ i = new pg();
+ var s = e[n], d = e[n + 1], p = e[n + 2];
+ i.p0 = new u.e(t[3 * s], t[3 * s + 1], t[3 * s + 2]), i.p1 = new u.e(t[3 * d], t[3 * d + 1], t[3 * d + 2]), i.p2 = new u.e(t[3 * p], t[3 * p + 1], t[3 * p + 2]);
+ var y = u.e.Cross(i.p1.subtract(i.p0), i.p2.subtract(i.p1));
+ y.normalize(), a.push(y), o.push(i);
+ }
+ for (n = 0; n < o.length; n++) {
+ i = o[n];
+ for (var P = n + 1; P < o.length; P++) {
+ var R = o[P];
+ if (i.edgesConnectedCount === 3)
+ break;
+ if (R.edgesConnectedCount !== 3)
+ for (var B = e[3 * P], F = e[3 * P + 1], z = e[3 * P + 2], J = 0; J < 3; J++) {
+ var ie = 0;
+ if (i.edges[J] === void 0) {
+ switch (J) {
+ case 0:
+ ie = this._checkVerticesInsteadOfIndices ? this._processEdgeForAdjacenciesWithVertices(i.p0, i.p1, R.p0, R.p1, R.p2) : this._processEdgeForAdjacencies(e[3 * n], e[3 * n + 1], B, F, z);
+ break;
+ case 1:
+ ie = this._checkVerticesInsteadOfIndices ? this._processEdgeForAdjacenciesWithVertices(i.p1, i.p2, R.p0, R.p1, R.p2) : this._processEdgeForAdjacencies(e[3 * n + 1], e[3 * n + 2], B, F, z);
+ break;
+ case 2:
+ ie = this._checkVerticesInsteadOfIndices ? this._processEdgeForAdjacenciesWithVertices(i.p2, i.p0, R.p0, R.p1, R.p2) : this._processEdgeForAdjacencies(e[3 * n + 2], e[3 * n], B, F, z);
+ }
+ if (ie !== -1 && (i.edges[J] = P, R.edges[ie] = n, i.edgesConnectedCount++, R.edgesConnectedCount++, i.edgesConnectedCount === 3))
+ break;
+ }
+ }
+ }
+ }
+ for (n = 0; n < o.length; n++) {
+ var se = o[n];
+ this._checkEdge(n, se.edges[0], a, se.p0, se.p1), this._checkEdge(n, se.edges[1], a, se.p1, se.p2), this._checkEdge(n, se.edges[2], a, se.p2, se.p0);
+ }
+ var ce = this._source.getScene().getEngine();
+ this._buffers[Oe.b.PositionKind] = new Oe.b(ce, this._linesPositions, Oe.b.PositionKind, !1), this._buffers[Oe.b.NormalKind] = new Oe.b(ce, this._linesNormals, Oe.b.NormalKind, !1, !1, 4), this._buffersForInstances[Oe.b.PositionKind] = this._buffers[Oe.b.PositionKind], this._buffersForInstances[Oe.b.NormalKind] = this._buffers[Oe.b.NormalKind], this._ib = ce.createIndexBuffer(this._linesIndices), this._indicesCount = this._linesIndices.length;
+ }
+ }, r.prototype.isReady = function() {
+ return this._lineShader.isReady(this._source, this._source.hasInstances && this.customInstances.length > 0 || this._source.hasThinInstances);
+ }, r.prototype.render = function() {
+ var t = this._source.getScene();
+ if (this.isReady() && t.activeCamera) {
+ var e = t.getEngine();
+ this._lineShader._preBind(), this._source.edgesColor.a !== 1 ? e.setAlphaMode(h.a.ALPHA_COMBINE) : e.setAlphaMode(h.a.ALPHA_DISABLE);
+ var n = this._source.hasInstances && this.customInstances.length > 0, i = n || this._source.hasThinInstances, o = 0;
+ if (i)
+ if (this._buffersForInstances.world0 = this._source.getVertexBuffer("world0"), this._buffersForInstances.world1 = this._source.getVertexBuffer("world1"), this._buffersForInstances.world2 = this._source.getVertexBuffer("world2"), this._buffersForInstances.world3 = this._source.getVertexBuffer("world3"), n) {
+ var a = this._source._instanceDataStorage;
+ if (o = this.customInstances.length, !a.isFrozen) {
+ for (var s = 0, d = 0; d < o; ++d)
+ this.customInstances.data[d].copyToArray(a.instancesData, s), s += 16;
+ a.instancesBuffer.updateDirectly(a.instancesData, 0, o);
+ }
+ } else
+ o = this._source.thinInstanceCount;
+ e.bindBuffers(i ? this._buffersForInstances : this._buffers, this._ib, this._lineShader.getEffect()), t.resetCachedMaterial(), this._lineShader.setColor4("color", this._source.edgesColor), t.activeCamera.mode === _t.a.ORTHOGRAPHIC_CAMERA ? this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForOrthographic) : this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForPerspective), this._lineShader.setFloat("aspectRatio", e.getAspectRatio(t.activeCamera)), this._lineShader.bind(this._source.getWorldMatrix()), e.drawElementsType(zt.a.TriangleFillMode, 0, this._indicesCount, o), this._lineShader.unbind(), i && e.unbindInstanceAttributes(), this._source.getScene()._activeMeshesFrozen || this.customInstances.reset();
+ }
+ }, r;
+ }(), Md = function(r) {
+ function t(e, n, i) {
+ n === void 0 && (n = 0.95), i === void 0 && (i = !1);
+ var o = r.call(this, e, n, i, !1) || this;
+ return o._generateEdgesLines(), o;
+ }
+ return Object(c.d)(t, r), t.prototype._generateEdgesLines = function() {
+ var e = this._source.getVerticesData(Oe.b.PositionKind), n = this._source.getIndices();
+ if (n && e) {
+ for (var i = u.c.Vector3[0], o = u.c.Vector3[1], a = n.length - 1, s = 0, d = 0; s < a; s += 2, d += 4)
+ u.e.FromArrayToRef(e, 3 * n[s], i), u.e.FromArrayToRef(e, 3 * n[s + 1], o), this.createLine(i, o, d);
+ var p = this._source.getScene().getEngine();
+ this._buffers[Oe.b.PositionKind] = new Oe.b(p, this._linesPositions, Oe.b.PositionKind, !1), this._buffers[Oe.b.NormalKind] = new Oe.b(p, this._linesNormals, Oe.b.NormalKind, !1, !1, 4), this._ib = p.createIndexBuffer(this._linesIndices), this._indicesCount = this._linesIndices.length;
+ }
+ }, t;
+ }(Lc), Nc = function() {
+ function r(t) {
+ this._textureFormats = [{ type: h.a.PREPASS_IRRADIANCE_TEXTURE_TYPE, format: h.a.TEXTURETYPE_HALF_FLOAT }, { type: h.a.PREPASS_POSITION_TEXTURE_TYPE, format: h.a.TEXTURETYPE_HALF_FLOAT }, { type: h.a.PREPASS_VELOCITY_TEXTURE_TYPE, format: h.a.TEXTURETYPE_HALF_FLOAT }, { type: h.a.PREPASS_REFLECTIVITY_TEXTURE_TYPE, format: h.a.TEXTURETYPE_UNSIGNED_INT }, { type: h.a.PREPASS_COLOR_TEXTURE_TYPE, format: h.a.TEXTURETYPE_HALF_FLOAT }, { type: h.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE, format: h.a.TEXTURETYPE_HALF_FLOAT }, { type: h.a.PREPASS_ALBEDO_TEXTURE_TYPE, format: h.a.TEXTURETYPE_UNSIGNED_INT }], this.excludedSkinnedMesh = [], this.excludedMaterials = [], this._textureIndices = [], this._isDirty = !1, this.mrtCount = 0, this._postProcesses = [], this._clearColor = new I.b(0, 0, 0, 0), this._effectConfigurations = [], this._mrtFormats = [], this._enabled = !1, this._useGeometryBufferFallback = !1, this.disableGammaTransform = !1, this._scene = t, this._engine = t.getEngine(), r._SceneComponentInitialization(this._scene), this._resetLayout();
+ }
+ return Object.defineProperty(r.prototype, "enabled", { get: function() {
+ return this._enabled;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "samples", { get: function() {
+ return this.prePassRT.samples;
+ }, set: function(t) {
+ this.imageProcessingPostProcess || this._createCompositionEffect(), this.prePassRT.samples = t;
+ }, enumerable: !1, configurable: !0 }), Object.defineProperty(r.prototype, "useGeometryBufferFallback", { get: function() {
+ return this._useGeometryBufferFallback;
+ }, set: function(t) {
+ if (this._useGeometryBufferFallback = t, t) {
+ if (this._geometryBuffer = this._scene.enableGeometryBufferRenderer(), !this._geometryBuffer)
+ return void (this._useGeometryBufferFallback = !1);
+ this._geometryBuffer.renderList = [], this._geometryBuffer._linkPrePassRenderer(this), this._updateGeometryBufferLayout();
+ } else
+ this._geometryBuffer && this._geometryBuffer._unlinkPrePassRenderer(), this._geometryBuffer = null, this._scene.disableGeometryBufferRenderer();
+ }, enumerable: !1, configurable: !0 }), r.prototype._initializeAttachments = function() {
+ for (var t = [], e = [!1], n = [!0], i = 0; i < this.mrtCount; i++)
+ t.push(!0), i > 0 && (e.push(!0), n.push(!1));
+ this._multiRenderAttachments = this._engine.buildTextureLayout(t), this._clearAttachments = this._engine.buildTextureLayout(e), this._defaultAttachments = this._engine.buildTextureLayout(n);
+ }, r.prototype._createCompositionEffect = function() {
+ this.prePassRT = new Vs("sceneprePassRT", { width: this._engine.getRenderWidth(), height: this._engine.getRenderHeight() }, this.mrtCount, this._scene, { generateMipMaps: !1, generateDepthTexture: !0, defaultType: h.a.TEXTURETYPE_UNSIGNED_INT, types: this._mrtFormats }), this.prePassRT.samples = 1, this._initializeAttachments(), this._useGeometryBufferFallback && !this._geometryBuffer && (this.useGeometryBufferFallback = !0), this.imageProcessingPostProcess = new Io("sceneCompositionPass", 1, null, void 0, this._engine), this.imageProcessingPostProcess.autoClear = !1;
+ }, Object.defineProperty(r.prototype, "isSupported", { get: function() {
+ return this._engine.webGLVersion > 1 || this._scene.getEngine().getCaps().drawBuffersExtension;
+ }, enumerable: !1, configurable: !0 }), r.prototype.bindAttachmentsForEffect = function(t, e) {
+ if (this.enabled) {
+ if (t._multiTarget)
+ this._engine.bindAttachments(this._multiRenderAttachments);
+ else if (this._engine.bindAttachments(this._defaultAttachments), this._geometryBuffer) {
+ var n = e.getMaterial();
+ n && this.excludedMaterials.indexOf(n) === -1 && this._geometryBuffer.renderList.push(e.getRenderingMesh());
+ }
+ }
+ }, r.prototype.restoreAttachments = function() {
+ this.enabled && this._defaultAttachments && this._engine.bindAttachments(this._defaultAttachments);
+ }, r.prototype._beforeCameraDraw = function() {
+ this._isDirty && this._update(), this._geometryBuffer && (this._geometryBuffer.renderList.length = 0), this._bindFrameBuffer();
+ }, r.prototype._afterCameraDraw = function() {
+ if (this._enabled) {
+ var t = this._scene.activeCamera && this._scene.activeCamera._getFirstPostProcess();
+ t && this._postProcesses.length && this._scene.postProcessManager._prepareFrame(), this._scene.postProcessManager.directRender(this._postProcesses, t ? t.inputTexture : null);
+ }
+ }, r.prototype._checkRTSize = function() {
+ var t = this._engine.getRenderWidth(!0), e = this._engine.getRenderHeight(!0), n = this.prePassRT.getRenderWidth(), i = this.prePassRT.getRenderHeight();
+ n === t && i === e || (this.prePassRT.resize({ width: t, height: e }), this._updateGeometryBufferLayout(), this._bindPostProcessChain());
+ }, r.prototype._bindFrameBuffer = function() {
+ if (this._enabled) {
+ this._checkRTSize();
+ var t = this.prePassRT.getInternalTexture();
+ t && this._engine.bindFramebuffer(t);
+ }
+ }, r.prototype.clear = function() {
+ this._enabled && (this._bindFrameBuffer(), this._engine.clear(this._scene.clearColor, this._scene.autoClear || this._scene.forceWireframe || this._scene.forcePointsCloud, this._scene.autoClearDepthAndStencil, this._scene.autoClearDepthAndStencil), this._engine.bindAttachments(this._clearAttachments), this._engine.clear(this._clearColor, !0, !1, !1), this._engine.bindAttachments(this._defaultAttachments));
+ }, r.prototype._setState = function(t) {
+ this._enabled = t, this._scene.prePass = t, this.imageProcessingPostProcess && (this.imageProcessingPostProcess.imageProcessingConfiguration.applyByPostProcess = t);
+ }, r.prototype._updateGeometryBufferLayout = function() {
+ if (this._geometryBuffer) {
+ this._geometryBuffer._resetLayout();
+ for (var t = [], e = 0; e < this._mrtLayout.length; e++)
+ t.push(!1);
+ this._geometryBuffer._linkInternalTexture(this.prePassRT.getInternalTexture());
+ var n = [{ prePassConstant: h.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE, geometryBufferConstant: ri.DEPTHNORMAL_TEXTURE_TYPE }, { prePassConstant: h.a.PREPASS_POSITION_TEXTURE_TYPE, geometryBufferConstant: ri.POSITION_TEXTURE_TYPE }, { prePassConstant: h.a.PREPASS_REFLECTIVITY_TEXTURE_TYPE, geometryBufferConstant: ri.REFLECTIVITY_TEXTURE_TYPE }, { prePassConstant: h.a.PREPASS_VELOCITY_TEXTURE_TYPE, geometryBufferConstant: ri.VELOCITY_TEXTURE_TYPE }];
+ for (e = 0; e < n.length; e++) {
+ var i = this._mrtLayout.indexOf(n[e].prePassConstant);
+ i !== -1 && (this._geometryBuffer._forceTextureType(n[e].geometryBufferConstant, i), t[i] = !0);
+ }
+ this._geometryBuffer._setAttachments(this._engine.buildTextureLayout(t));
+ }
+ }, r.prototype.addEffectConfiguration = function(t) {
+ for (var e = 0; e < this._effectConfigurations.length; e++)
+ if (this._effectConfigurations[e].name === t.name)
+ return this._effectConfigurations[e];
+ return this._effectConfigurations.push(t), t;
+ }, r.prototype.getIndex = function(t) {
+ return this._textureIndices[t];
+ }, r.prototype._enable = function() {
+ for (var t, e, n = this.mrtCount, i = 0; i < this._effectConfigurations.length; i++)
+ this._effectConfigurations[i].enabled && this._enableTextures(this._effectConfigurations[i].texturesRequired);
+ for (this.prePassRT && this.mrtCount !== n && this.prePassRT.updateCount(this.mrtCount, { types: this._mrtFormats }), this._updateGeometryBufferLayout(), this._resetPostProcessChain(), i = 0; i < this._effectConfigurations.length; i++)
+ this._effectConfigurations[i].enabled && (!this._effectConfigurations[i].postProcess && this._effectConfigurations[i].createPostProcess && this._effectConfigurations[i].createPostProcess(), this._effectConfigurations[i].postProcess && this._postProcesses.push(this._effectConfigurations[i].postProcess));
+ this._initializeAttachments(), this.imageProcessingPostProcess || this._createCompositionEffect();
+ var o = !1;
+ if (!((t = this._scene.activeCamera) === null || t === void 0) && t._postProcesses)
+ for (i = 0; i < this._scene.activeCamera._postProcesses.length; i++)
+ ((e = this._scene.activeCamera._postProcesses[i]) === null || e === void 0 ? void 0 : e.getClassName()) === "ImageProcessingPostProcess" && (o = !0);
+ o || this.disableGammaTransform || this._postProcesses.push(this.imageProcessingPostProcess), this._bindPostProcessChain(), this._setState(!0);
+ }, r.prototype._disable = function() {
+ this._setState(!1), this._resetLayout();
+ for (var t = 0; t < this._effectConfigurations.length; t++)
+ this._effectConfigurations[t].enabled = !1;
+ }, r.prototype._resetLayout = function() {
+ for (var t = 0; t < this._textureFormats.length; t++)
+ this._textureIndices[this._textureFormats[t].type] = -1;
+ this._textureIndices[h.a.PREPASS_COLOR_TEXTURE_TYPE] = 0, this._mrtLayout = [h.a.PREPASS_COLOR_TEXTURE_TYPE], this._mrtFormats = [h.a.TEXTURETYPE_HALF_FLOAT], this.mrtCount = 1;
+ }, r.prototype._resetPostProcessChain = function() {
+ this._postProcesses = [], this.imageProcessingPostProcess && this.imageProcessingPostProcess.restoreDefaultInputTexture();
+ for (var t = 0; t < this._effectConfigurations.length; t++)
+ this._effectConfigurations[t].postProcess && this._effectConfigurations[t].postProcess.restoreDefaultInputTexture();
+ }, r.prototype._bindPostProcessChain = function() {
+ var t;
+ if (this._postProcesses.length)
+ this._postProcesses[0].inputTexture = this.prePassRT.getInternalTexture();
+ else {
+ var e = (t = this._scene.activeCamera) === null || t === void 0 ? void 0 : t._getFirstPostProcess();
+ e && (e.inputTexture = this.prePassRT.getInternalTexture());
+ }
+ }, r.prototype.markAsDirty = function() {
+ this._isDirty = !0;
+ }, r.prototype._enableTextures = function(t) {
+ for (var e = 0; e < t.length; e++) {
+ var n = t[e];
+ this._textureIndices[n] === -1 && (this._textureIndices[n] = this._mrtLayout.length, this._mrtLayout.push(n), this._mrtFormats.push(this._textureFormats[n].format), this.mrtCount++);
+ }
+ }, r.prototype._update = function() {
+ this._disable();
+ for (var t = !1, e = 0; e < this._scene.materials.length; e++)
+ this._scene.materials[e].setPrePassRenderer(this) && (t = !0);
+ var n = this._scene.activeCamera;
+ if (n) {
+ var i = n._postProcesses.filter(function(o) {
+ return o != null;
+ });
+ if (i)
+ for (e = 0; e < i.length; e++)
+ i[e].setPrePassRenderer(this) && (t = !0);
+ this._markAllMaterialsAsPrePassDirty(), this._isDirty = !1, t && this._enable(), this.enabled || (this._engine.restoreDefaultFramebuffer(), this._engine.restoreSingleAttachment());
+ }
+ }, r.prototype._markAllMaterialsAsPrePassDirty = function() {
+ for (var t = this._scene.materials, e = 0; e < t.length; e++)
+ t[e].markAsDirty(zt.a.PrePassDirtyFlag);
+ }, r.prototype.dispose = function() {
+ for (var t = 0; t < this._effectConfigurations.length; t++)
+ this._effectConfigurations[t].dispose && this._effectConfigurations[t].dispose();
+ this.imageProcessingPostProcess.dispose(), this.prePassRT.dispose();
+ }, r._SceneComponentInitialization = function(t) {
+ throw En.a.WarnImport("PrePassRendererSceneComponent");
+ }, r;
+ }();
+ Object.defineProperty(_e.a.prototype, "prePassRenderer", { get: function() {
+ return this._prePassRenderer;
+ }, set: function(r) {
+ r && r.isSupported && (this._prePassRenderer = r);
+ }, enumerable: !0, configurable: !0 }), _e.a.prototype.enablePrePassRenderer = function() {
+ return this._prePassRenderer || (this._prePassRenderer = new Nc(this), this._prePassRenderer.isSupported || (this._prePassRenderer = null, l.a.Error(`PrePassRenderer needs WebGL 2 support.
+Maybe you tried to use the following features that need the PrePassRenderer :
+ + Subsurface Scattering`))), this._prePassRenderer;
+ }, _e.a.prototype.disablePrePassRenderer = function() {
+ this._prePassRenderer && (this._prePassRenderer.dispose(), this._prePassRenderer = null);
+ };
+ var Id = function() {
+ function r(t) {
+ this.name = ot.a.NAME_PREPASSRENDERER, this.scene = t;
+ }
+ return r.prototype.register = function() {
+ this.scene._beforeCameraDrawStage.registerStep(ot.a.STEP_BEFORECAMERADRAW_PREPASS, this, this._beforeCameraDraw), this.scene._afterCameraDrawStage.registerStep(ot.a.STEP_AFTERCAMERADRAW_PREPASS, this, this._afterCameraDraw), this.scene._beforeClearStage.registerStep(ot.a.STEP_BEFORECLEARSTAGE_PREPASS, this, this._beforeClearStage), this.scene._beforeRenderingMeshStage.registerStep(ot.a.STEP_BEFORERENDERINGMESH_PREPASS, this, this._beforeRenderingMeshStage), this.scene._afterRenderingMeshStage.registerStep(ot.a.STEP_AFTERRENDERINGMESH_PREPASS, this, this._afterRenderingMeshStage);
+ }, r.prototype._beforeCameraDraw = function() {
+ this.scene.prePassRenderer && this.scene.prePassRenderer._beforeCameraDraw();
+ }, r.prototype._afterCameraDraw = function() {
+ this.scene.prePassRenderer && this.scene.prePassRenderer._afterCameraDraw();
+ }, r.prototype._beforeClearStage = function() {
+ this.scene.prePassRenderer && this.scene.prePassRenderer.clear();
+ }, r.prototype._beforeRenderingMeshStage = function(t, e, n, i) {
+ if (i) {
+ var o = t.getScene();
+ o.prePassRenderer && o.prePassRenderer.bindAttachmentsForEffect(i, e);
+ }
+ }, r.prototype._afterRenderingMeshStage = function(t) {
+ var e = t.getScene();
+ e.prePassRenderer && e.prePassRenderer.restoreAttachments();
+ }, r.prototype.rebuild = function() {
+ }, r.prototype.dispose = function() {
+ }, r;
+ }();
+ Nc._SceneComponentInitialization = function(r) {
+ var t = r._getComponent(ot.a.NAME_PREPASSRENDERER);
+ t || (t = new Id(r), r._addComponent(t));
+ };
+ var _g = `#define rcp(x) 1./x
+#define GOLDEN_RATIO 1.618033988749895
+#define TWO_PI 6.2831855
+
+
+vec2 Golden2dSeq(int i,float n)
+{
+
+
+return vec2(float(i)/n+(0.5/n),fract(float(i)*rcp(GOLDEN_RATIO)));
+}
+vec2 SampleDiskGolden(int i,int sampleCount)
+{
+vec2 f=Golden2dSeq(i,float(sampleCount));
+return vec2(sqrt(f.x),TWO_PI*f.y);
+}`;
+ ze.a.IncludesShadersStore.fibonacci = _g;
+ var mg = `uniform vec3 diffusionS[5];
+uniform float diffusionD[5];
+uniform float filterRadii[5];`;
+ ze.a.IncludesShadersStore.diffusionProfile = mg;
+ var gg = `
+#include
+#include
+#include
+#include
+varying vec2 vUV;
+uniform vec2 texelSize;
+uniform sampler2D textureSampler;
+uniform sampler2D irradianceSampler;
+uniform sampler2D depthSampler;
+uniform sampler2D albedoSampler;
+uniform vec2 viewportSize;
+uniform float metersPerUnit;
+const float LOG2_E=1.4426950408889634;
+const float SSS_PIXELS_PER_SAMPLE=4.;
+const int _SssSampleBudget=40;
+#define rcp(x) 1./x
+#define Sq(x) x*x
+#define SSS_BILATERAL_FILTER true
+
+
+vec3 EvalBurleyDiffusionProfile(float r,vec3 S)
+{
+vec3 exp_13=exp2(((LOG2_E*(-1.0/3.0))*r)*S);
+vec3 expSum=exp_13*(1.+exp_13*exp_13);
+return (S*rcp(8.*PI))*expSum;
+}
+
+
+
+
+
+
+vec2 SampleBurleyDiffusionProfile(float u,float rcpS)
+{
+u=1.-u;
+float g=1.+(4.*u)*(2.*u+sqrt(1.+(4.*u)*u));
+float n=exp2(log2(g)*(-1.0/3.0));
+float p=(g*n)*n;
+float c=1.+p+n;
+float d=(3./LOG2_E*2.)+(3./LOG2_E)*log2(u);
+float x=(3./LOG2_E)*log2(c)-d;
+
+
+
+
+
+
+float rcpExp=((c*c)*c)*rcp((4.*u)*((c*c)+(4.*u)*(4.*u)));
+float r=x*rcpS;
+float rcpPdf=(8.*PI*rcpS)*rcpExp;
+return vec2(r,rcpPdf);
+}
+
+
+vec3 ComputeBilateralWeight(float xy2,float z,float mmPerUnit,vec3 S,float rcpPdf)
+{
+#ifndef SSS_BILATERAL_FILTER
+z=0.;
+#endif
+
+
+
+float r=sqrt(xy2+(z*mmPerUnit)*(z*mmPerUnit));
+float area=rcpPdf;
+#if SSS_CLAMP_ARTIFACT
+return clamp(EvalBurleyDiffusionProfile(r,S)*area,0.0,1.0);
+#else
+return EvalBurleyDiffusionProfile(r,S)*area;
+#endif
+}
+void EvaluateSample(int i,int n,vec3 S,float d,vec3 centerPosVS,float mmPerUnit,float pixelsPerMm,
+float phase,inout vec3 totalIrradiance,inout vec3 totalWeight)
+{
+
+float scale=rcp(float(n));
+float offset=rcp(float(n))*0.5;
+
+float sinPhase,cosPhase;
+sinPhase=sin(phase);
+cosPhase=cos(phase);
+vec2 bdp=SampleBurleyDiffusionProfile(float(i)*scale+offset,d);
+float r=bdp.x;
+float rcpPdf=bdp.y;
+float phi=SampleDiskGolden(i,n).y;
+float sinPhi,cosPhi;
+sinPhi=sin(phi);
+cosPhi=cos(phi);
+float sinPsi=cosPhase*sinPhi+sinPhase*cosPhi;
+float cosPsi=cosPhase*cosPhi-sinPhase*sinPhi;
+vec2 vec=r*vec2(cosPsi,sinPsi);
+
+vec2 position;
+float xy2;
+position=vUV+round((pixelsPerMm*r)*vec2(cosPsi,sinPsi))*texelSize;
+xy2=r*r;
+vec4 textureSample=texture2D(irradianceSampler,position);
+float viewZ=texture2D(depthSampler,position).r;
+vec3 irradiance=textureSample.rgb;
+if (testLightingForSSS(textureSample.a))
+{
+
+float relZ=viewZ-centerPosVS.z;
+vec3 weight=ComputeBilateralWeight(xy2,relZ,mmPerUnit,S,rcpPdf);
+totalIrradiance+=weight*irradiance;
+totalWeight+=weight;
+}
+else
+{
+
+
+
+
+
+
+}
+}
+void main(void)
+{
+vec4 irradianceAndDiffusionProfile=texture2D(irradianceSampler,vUV);
+vec3 centerIrradiance=irradianceAndDiffusionProfile.rgb;
+int diffusionProfileIndex=int(round(irradianceAndDiffusionProfile.a*255.));
+float centerDepth=0.;
+vec4 inputColor=texture2D(textureSampler,vUV);
+bool passedStencilTest=testLightingForSSS(irradianceAndDiffusionProfile.a);
+if (passedStencilTest)
+{
+centerDepth=texture2D(depthSampler,vUV).r;
+}
+if (!passedStencilTest) {
+gl_FragColor=inputColor;
+return;
+}
+float distScale=1.;
+vec3 S=diffusionS[diffusionProfileIndex];
+float d=diffusionD[diffusionProfileIndex];
+float filterRadius=filterRadii[diffusionProfileIndex];
+
+vec2 centerPosNDC=vUV;
+vec2 cornerPosNDC=vUV+0.5*texelSize;
+vec3 centerPosVS=vec3(centerPosNDC*viewportSize,1.0)*centerDepth;
+vec3 cornerPosVS=vec3(cornerPosNDC*viewportSize,1.0)*centerDepth;
+
+float mmPerUnit=1000.*(metersPerUnit*rcp(distScale));
+float unitsPerMm=rcp(mmPerUnit);
+
+
+float unitsPerPixel=2.*abs(cornerPosVS.x-centerPosVS.x);
+float pixelsPerMm=rcp(unitsPerPixel)*unitsPerMm;
+
+float filterArea=PI*Sq(filterRadius*pixelsPerMm);
+int sampleCount=int(filterArea*rcp(SSS_PIXELS_PER_SAMPLE));
+int sampleBudget=_SssSampleBudget;
+int texturingMode=0;
+vec3 albedo=texture2D(albedoSampler,vUV).rgb;
+if (distScale == 0. || sampleCount<1)
+{
+#ifdef DEBUG_SSS_SAMPLES
+vec3 green=vec3(0.,1.,0.);
+gl_FragColor=vec4(green,1.0);
+return;
+#endif
+gl_FragColor=vec4(inputColor.rgb+albedo*centerIrradiance,1.0);
+return;
+}
+#ifdef DEBUG_SSS_SAMPLES
+vec3 red=vec3(1.,0.,0.);
+vec3 blue=vec3(0.,0.,1.);
+gl_FragColor=vec4(mix(blue,red,clamp(float(sampleCount)/float(sampleBudget),0.0,1.0)),1.0);
+return;
+#endif
+
+float phase=0.;
+int n=min(sampleCount,sampleBudget);
+
+vec3 centerWeight=vec3(0.);
+vec3 totalIrradiance=vec3(0.);
+vec3 totalWeight=vec3(0.);
+for (int i=0; i= 5)
+ return l.a.Error("You already reached the maximum number of diffusion profiles."), 0;
+ for (var e = 0; e < this._ssDiffusionS.length / 3; e++)
+ if (this._ssDiffusionS[3 * e] === t.r && this._ssDiffusionS[3 * e + 1] === t.g && this._ssDiffusionS[3 * e + 2] === t.b)
+ return e;
+ return this._ssDiffusionS.push(t.r, t.b, t.g), this._ssDiffusionD.push(Math.max(Math.max(t.r, t.b), t.g)), this._ssFilterRadii.push(this.getDiffusionProfileParameters(t)), this.ssDiffusionProfileColors.push(t), this._ssDiffusionD.length - 1;
+ }, r.prototype.createPostProcess = function() {
+ return this.postProcess = new vg("subSurfaceScattering", this._scene, 1, null, void 0, this._scene.getEngine()), this.postProcess.autoClear = !1, this.postProcess;
+ }, r.prototype.clearAllDiffusionProfiles = function() {
+ this._ssDiffusionD = [], this._ssDiffusionS = [], this._ssFilterRadii = [], this.ssDiffusionProfileColors = [];
+ }, r.prototype.dispose = function() {
+ this.clearAllDiffusionProfiles(), this.postProcess.dispose();
+ }, r.prototype.getDiffusionProfileParameters = function(t) {
+ var e = Math.max(t.r, t.g, t.b);
+ return this._sampleBurleyDiffusionProfile(0.997, e);
+ }, r.prototype._sampleBurleyDiffusionProfile = function(t, e) {
+ var n = 1 + 4 * (t = 1 - t) * (2 * t + Math.sqrt(1 + 4 * t * t)), i = Math.pow(n, -1 / 3), o = 1 + n * i * i + i;
+ return 3 * Math.log(o / (4 * t)) * e;
+ }, r._SceneComponentInitialization = function(t) {
+ throw En.a.WarnImport("PrePassRendererSceneComponent");
+ }, r;
+ }();
+ V.a.AddParser(ot.a.NAME_SUBSURFACE, function(r, t) {
+ if (r.ssDiffusionProfileColors !== void 0 && r.ssDiffusionProfileColors !== null && (t.enableSubSurfaceForPrePass(), t.subSurfaceConfiguration))
+ for (var e = 0, n = r.ssDiffusionProfileColors.length; e < n; e++) {
+ var i = r.ssDiffusionProfileColors[e];
+ t.subSurfaceConfiguration.addDiffusionProfile(new I.a(i.r, i.g, i.b));
+ }
+ }), Object.defineProperty(_e.a.prototype, "subSurfaceConfiguration", { get: function() {
+ return this._subSurfaceConfiguration;
+ }, set: function(r) {
+ r && this.enablePrePassRenderer() && (this._subSurfaceConfiguration = r);
+ }, enumerable: !0, configurable: !0 }), _e.a.prototype.enableSubSurfaceForPrePass = function() {
+ if (this._subSurfaceConfiguration)
+ return this._subSurfaceConfiguration;
+ var r = this.enablePrePassRenderer();
+ return r ? (this._subSurfaceConfiguration = new Dd(this), r.addEffectConfiguration(this._subSurfaceConfiguration), this._subSurfaceConfiguration) : null;
+ }, _e.a.prototype.disableSubSurfaceForPrePass = function() {
+ this._subSurfaceConfiguration && (this._subSurfaceConfiguration.dispose(), this._subSurfaceConfiguration = null);
+ };
+ var Ld = function() {
+ function r(t) {
+ this.name = ot.a.NAME_PREPASSRENDERER, this.scene = t;
+ }
+ return r.prototype.register = function() {
+ }, r.prototype.serialize = function(t) {
+ if (this.scene.subSurfaceConfiguration) {
+ var e = this.scene.subSurfaceConfiguration.ssDiffusionProfileColors;
+ t.ssDiffusionProfileColors = [];
+ for (var n = 0; n < e.length; n++)
+ t.ssDiffusionProfileColors.push({ r: e[n].r, g: e[n].g, b: e[n].b });
+ }
+ }, r.prototype.addFromContainer = function(t) {
+ }, r.prototype.removeFromContainer = function(t, e) {
+ this.scene.prePassRenderer && this.scene.subSurfaceConfiguration && this.scene.subSurfaceConfiguration.clearAllDiffusionProfiles();
+ }, r.prototype.rebuild = function() {
+ }, r.prototype.dispose = function() {
+ }, r;
+ }();
+ Dd._SceneComponentInitialization = function(r) {
+ var t = r._getComponent(ot.a.NAME_SUBSURFACE);
+ t || (t = new Ld(r), r._addComponent(t));
+ };
+ var yg = `#ifdef LOGARITHMICDEPTH
+#extension GL_EXT_frag_depth : enable
+#endif
+uniform vec4 color;
+#ifdef ALPHATEST
+varying vec2 vUV;
+uniform sampler2D diffuseSampler;
+#endif
+#include
+void main(void) {
+#ifdef ALPHATEST
+if (texture2D(diffuseSampler,vUV).a<0.4)
+discard;
+#endif
+#include
+gl_FragColor=color;
+}`;
+ ze.a.ShadersStore.outlinePixelShader = yg;
+ var bg = `
+attribute vec3 position;
+attribute vec3 normal;
+#include
+#include
+#include